{"text": "------------------------------------------------------------------------\n-- Heterogeneous equality\n------------------------------------------------------------------------\n\nmodule Relation.Binary.HeterogeneousEquality where\n\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.Consequences\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; refl)\nopen import Data.Function\nopen import Data.Product\n\n------------------------------------------------------------------------\n-- Heterogeneous equality\n\ninfix 4 _≅_ _≇_ _≅₁_ _≇₁_\n\ndata _≅_ {a : Set} (x : a) : {b : Set} → b → Set where\n refl : x ≅ x\n\ndata _≅₁_ {a : Set₁} (x : a) : {b : Set₁} → b → Set where\n refl : x ≅₁ x\n\n-- Nonequality.\n\n_≇_ : {a : Set} → a → {b : Set} → b → Set\nx ≇ y = ¬ x ≅ y\n\n_≇₁_ : {a : Set₁} → a → {b : Set₁} → b → Set\nx ≇₁ y = ¬ x ≅₁ y\n\n------------------------------------------------------------------------\n-- Conversion\n\n≡-to-≅ : ∀ {a} {x y : a} → x ≡ y → x ≅ y\n≡-to-≅ refl = refl\n\n≅-to-≡ : ∀ {a} {x y : a} → x ≅ y → x ≡ y\n≅-to-≡ refl = refl\n\n------------------------------------------------------------------------\n-- Some properties\n\nreflexive : ∀ {a} → _⇒_ {a} _≡_ (λ x y → x ≅ y)\nreflexive refl = refl\n\nsym : ∀ {a b} {x : a} {y : b} → x ≅ y → y ≅ x\nsym refl = refl\n\ntrans : ∀ {a b c} {x : a} {y : b} {z : c} → x ≅ y → y ≅ z → x ≅ z\ntrans refl refl = refl\n\nsubst : ∀ {a} → Substitutive {a} (λ x y → x ≅ y)\nsubst P refl p = p\n\nsubst₂ : ∀ {A B} (P : A → B → Set) →\n ∀ {x₁ x₂ y₁ y₂} → x₁ ≅ x₂ → y₁ ≅ y₂ → P x₁ y₁ → P x₂ y₂\nsubst₂ P refl refl p = p\n\nsubst₁ : ∀ {a} (P : a → Set₁) → ∀ {x y} → x ≅ y → P x → P y\nsubst₁ P refl p = p\n\nsubst-removable : ∀ {a} (P : a → Set) {x y} (eq : x ≅ y) z →\n subst P eq z ≅ z\nsubst-removable P refl z = refl\n\n≡-subst-removable : ∀ {a} (P : a → Set) {x y} (eq : x ≡ y) z →\n PropEq.subst P eq z ≅ z\n≡-subst-removable P refl z = refl\n\ncong : ∀ {A : Set} {B : A → Set} {x y}\n (f : (x : A) → B x) → x ≅ y → f x ≅ f y\ncong f refl = refl\n\ncong₂ : ∀ {A : Set} {B : A → Set} {C : ∀ x → B x → Set} {x y u v}\n (f : (x : A) (y : B x) → C x y) → x ≅ y → u ≅ v → f x u ≅ f y v\ncong₂ f refl refl = refl\n\nresp₂ : ∀ {a} (∼ : Rel a) → ∼ Respects₂ (λ x y → x ≅ y)\nresp₂ _∼_ = subst⟶resp₂ _∼_ subst\n\nisEquivalence : ∀ {a} → IsEquivalence {a} (λ x y → x ≅ y)\nisEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n\nsetoid : Set → Setoid\nsetoid a = record\n { carrier = a\n ; _≈_ = λ x y → x ≅ y\n ; isEquivalence = isEquivalence\n }\n\ndecSetoid : ∀ {a} → Decidable (λ x y → _≅_ {a} x y) → DecSetoid\ndecSetoid dec = record\n { _≈_ = λ x y → x ≅ y\n ; isDecEquivalence = record\n { isEquivalence = isEquivalence\n ; _≟_ = dec\n }\n }\n\nisPreorder : ∀ {a} → IsPreorder {a} (λ x y → x ≅ y) (λ x y → x ≅ y)\nisPreorder = record\n { isEquivalence = isEquivalence\n ; reflexive = id\n ; trans = trans\n ; ∼-resp-≈ = resp₂ (λ x y → x ≅ y)\n }\n\nisPreorder-≡ : ∀ {a} → IsPreorder {a} _≡_ (λ x y → x ≅ y)\nisPreorder-≡ = record\n { isEquivalence = PropEq.isEquivalence\n ; reflexive = reflexive\n ; trans = trans\n ; ∼-resp-≈ = PropEq.resp₂ (λ x y → x ≅ y)\n }\n\npreorder : Set → Preorder\npreorder a = record\n { carrier = a\n ; _≈_ = _≡_\n ; _∼_ = λ x y → x ≅ y\n ; isPreorder = isPreorder-≡\n }\n\n------------------------------------------------------------------------\n-- The inspect idiom\n\n-- See Relation.Binary.PropositionalEquality.Inspect.\n\ndata Inspect {a : Set} (x : a) : Set where\n _with-≅_ : (y : a) (eq : y ≅ x) → Inspect x\n\ninspect : ∀ {a} (x : a) → Inspect x\ninspect x = x with-≅ refl\n\n------------------------------------------------------------------------\n-- Convenient syntax for equational reasoning\n\nmodule ≅-Reasoning where\n\n -- The code in Relation.Binary.EqReasoning cannot handle\n -- heterogeneous equalities, hence the code duplication here.\n\n infix 4 _IsRelatedTo_\n infix 2 _∎\n infixr 2 _≅⟨_⟩_ _≡⟨_⟩_\n infix 1 begin_\n\n data _IsRelatedTo_ {A} (x : A) {B} (y : B) : Set where\n relTo : (x≅y : x ≅ y) → x IsRelatedTo y\n\n begin_ : ∀ {A} {x : A} {B} {y : B} → x IsRelatedTo y → x ≅ y\n begin relTo x≅y = x≅y\n\n _≅⟨_⟩_ : ∀ {A} (x : A) {B} {y : B} {C} {z : C} →\n x ≅ y → y IsRelatedTo z → x IsRelatedTo z\n _ ≅⟨ x≅y ⟩ relTo y≅z = relTo (trans x≅y y≅z)\n\n _≡⟨_⟩_ : ∀ {A} (x : A) {y} {C} {z : C} →\n x ≡ y → y IsRelatedTo z → x IsRelatedTo z\n _ ≡⟨ x≡y ⟩ relTo y≅z = relTo (trans (reflexive x≡y) y≅z)\n\n _∎ : ∀ {A} (x : A) → x IsRelatedTo x\n _∎ _ = relTo refl\n", "meta": {"hexsha": "171b5ad4b0eb9ef7cb8a7448da013864b7e596d2", "size": 4624, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/HeterogeneousEquality.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/HeterogeneousEquality.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/HeterogeneousEquality.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.0409356725, "max_line_length": 72, "alphanum_fraction": 0.4649653979, "num_tokens": 1808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435030872968, "lm_q2_score": 0.7772998663336158, "lm_q1q2_score": 0.5999538517802255}} {"text": "{-\n\nThis file proves a variety of basic results about paths:\n\n- refl, sym, cong and composition of paths. This is used to set up\n equational reasoning.\n\n- Transport, subst and functional extensionality\n\n- J and its computation rule (up to a path)\n\n- Σ-types and contractibility of singletons\n\n- Converting PathP to and from a homogeneous path with transp\n\n- Direct definitions of lower h-levels\n\n- Export natural numbers\n\n- Export universe lifting\n\n-}\n{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Foundations.Prelude where\n\nopen import Cubical.Core.Primitives public\n\ninfixr 30 _∙_\ninfix 3 _∎\ninfixr 2 _≡⟨_⟩_\n\n-- Basic theory about paths. These proofs should typically be\n-- inlined. This module also makes equational reasoning work with\n-- (non-dependent) paths.\n\nprivate\n variable\n ℓ ℓ' : Level\n A : Type ℓ\n B : A → Type ℓ\n x y z : A\n\nrefl : x ≡ x\nrefl {x = x} = λ _ → x\n\nsym : x ≡ y → y ≡ x\nsym p i = p (~ i)\n\nsymP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} →\n (p : PathP A x y) → PathP (λ i → A (~ i)) y x\nsymP p j = p (~ j)\n\ncong : ∀ (f : (a : A) → B a) (p : x ≡ y) →\n PathP (λ i → B (p i)) (f x) (f y)\ncong f p i = f (p i)\n\ncong₂ : ∀ {C : (a : A) → (b : B a) → Type ℓ} →\n (f : (a : A) → (b : B a) → C a b) →\n (p : x ≡ y) →\n {u : B x} {v : B y} (q : PathP (λ i → B (p i)) u v) →\n PathP (λ i → C (p i) (q i)) (f x u) (f y v)\ncong₂ f p q i = f (p i) (q i)\n\n-- The filler of homogeneous path composition:\n-- compPath-filler p q = PathP (λ i → x ≡ q i) p (p ∙ q)\n\ncompPath-filler : ∀ {x y z : A} → x ≡ y → y ≡ z → I → I → A\ncompPath-filler {x = x} p q j i =\n hfill (λ j → λ { (i = i0) → x\n ; (i = i1) → q j }) (inS (p i)) j\n\n_∙_ : x ≡ y → y ≡ z → x ≡ z\n(p ∙ q) j = compPath-filler p q i1 j\n\n-- The filler of heterogeneous path composition:\n-- compPathP-filler p q = PathP (λ i → PathP (λ j → (compPath-filler (λ i → A i) B i j)) x (q i)) p (compPathP p q)\n\ncompPathP-filler : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → {B_i1 : Type ℓ} {B : A i1 ≡ B_i1} → {z : B i1} →\n (p : PathP A x y) → (q : PathP (λ i → B i) y z) → ∀ (i j : I) → compPath-filler (λ i → A i) B j i\ncompPathP-filler {A = A} {x = x} {B = B} p q i =\n fill (λ j → compPath-filler (λ i → A i) B j i)\n (λ j → λ { (i = i0) → x ;\n (i = i1) → q j }) (inS (p i))\n\ncompPathP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → {B_i1 : Type ℓ} {B : (A i1) ≡ B_i1} → {z : B i1} →\n (p : PathP A x y) → (q : PathP (λ i → B i) y z) → PathP (λ j → ((λ i → A i) ∙ B) j) x z\ncompPathP p q j = compPathP-filler p q j i1\n\n_≡⟨_⟩_ : (x : A) → x ≡ y → y ≡ z → x ≡ z\n_ ≡⟨ x≡y ⟩ y≡z = x≡y ∙ y≡z\n\n\n≡⟨⟩-syntax : (x : A) → x ≡ y → y ≡ z → x ≡ z\n≡⟨⟩-syntax = _≡⟨_⟩_\ninfixr 2 ≡⟨⟩-syntax\nsyntax ≡⟨⟩-syntax x (λ i → B) y = x ≡[ i ]⟨ B ⟩ y\n\n_∎ : (x : A) → x ≡ x\n_ ∎ = refl\n\n-- another definition of composition, useful for some proofs\ncompPath'-filler : ∀ {x y z : A} → x ≡ y → y ≡ z → I → I → A\ncompPath'-filler {z = z} p q j i =\n hfill (λ j → λ { (i = i0) → p (~ j)\n ; (i = i1) → z }) (inS (q i)) j\n\n_□_ : x ≡ y → y ≡ z → x ≡ z\n(p □ q) j = compPath'-filler p q i1 j\n\n□≡∙ : (p : x ≡ y) (q : y ≡ z) → p □ q ≡ p ∙ q\n□≡∙ {x = x} {y = y} {z = z} p q i j = hcomp (λ k → \\ { (i = i0) → compPath'-filler p q k j\n ; (i = i1) → compPath-filler p q k j\n ; (j = i0) → p ( ~ i ∧ ~ k)\n ; (j = i1) → q (k ∨ ~ i) }) (helper i j)\n where\n helper : PathP (λ i → p (~ i) ≡ q (~ i)) q p\n helper i j = hcomp (λ k → \\ { (i = i0) → q (k ∧ j)\n ; (i = i1) → p (~ k ∨ j)\n ; (j = i0) → p (~ i ∨ ~ k)\n ; (j = i1) → q (~ i ∧ k) })\n y\n\n-- Transport, subst and functional extensionality\n\n-- transport is a special case of transp\ntransport : {A B : Type ℓ} → A ≡ B → A → B\ntransport p a = transp (λ i → p i) i0 a\n\n-- Transporting in a constant family is the identity function (up to a\n-- path). If we would have regularity this would be definitional.\ntransportRefl : (x : A) → transport refl x ≡ x\ntransportRefl {A = A} x i = transp (λ _ → A) i x\n\n-- We want B to be explicit in subst\nsubst : (B : A → Type ℓ') (p : x ≡ y) → B x → B y\nsubst B p pa = transport (λ i → B (p i)) pa\n\nsubstRefl : (px : B x) → subst B refl px ≡ px\nsubstRefl px = transportRefl px\n\nfunExt : {f g : (x : A) → B x} → ((x : A) → f x ≡ g x) → f ≡ g\nfunExt p i x = p x i\n\n-- J for paths and its computation rule\n\nmodule _ (P : ∀ y → x ≡ y → Type ℓ') (d : P x refl) where\n J : (p : x ≡ y) → P y p\n J p = transport (λ i → P (p i) (λ j → p (i ∧ j))) d\n\n JRefl : J refl ≡ d\n JRefl = transportRefl d\n\n-- Contractibility of singletons\n\nsingl : (a : A) → Type _\nsingl {A = A} a = Σ[ x ∈ A ] (a ≡ x)\n\ncontrSingl : (p : x ≡ y) → Path (singl x) (x , refl) (y , p)\ncontrSingl p i = (p i , λ j → p (i ∧ j))\n\n\n-- Converting to and from a PathP\n\nmodule _ {A : I → Type ℓ} {x : A i0} {y : A i1} where\n toPathP : transp A i0 x ≡ y → PathP A x y\n toPathP p i = hcomp (λ j → λ { (i = i0) → x\n ; (i = i1) → p j })\n (transp (λ j → A (i ∧ j)) (~ i) x)\n\n fromPathP : PathP A x y → transp A i0 x ≡ y\n fromPathP p i = transp (λ j → A (i ∨ j)) i (p i)\n\n\n-- Direct definitions of lower h-levels\n\nisContr : Type ℓ → Type ℓ\nisContr A = Σ[ x ∈ A ] (∀ y → x ≡ y)\n\nisProp : Type ℓ → Type ℓ\nisProp A = (x y : A) → x ≡ y\n\nisSet : Type ℓ → Type ℓ\nisSet A = (x y : A) → isProp (x ≡ y)\n\nSquare\n : ∀{w x y z : A}\n → (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)\n → Set _\nSquare p q r s = PathP (λ i → p i ≡ s i) q r\n\nisSet' : Type ℓ → Type ℓ\nisSet' A\n = {x y z w : A}\n → (p : x ≡ y) (q : z ≡ w) (r : x ≡ z) (s : y ≡ w)\n → Square r p q s\n\nisGroupoid : Type ℓ → Type ℓ\nisGroupoid A = ∀ a b → isSet (Path A a b)\n\nCube\n : ∀{w x y z w' x' y' z' : A}\n → {p : w ≡ y} {q : w ≡ x} {r : y ≡ z} {s : x ≡ z}\n → {p' : w' ≡ y'} {q' : w' ≡ x'} {r' : y' ≡ z'} {s' : x' ≡ z'}\n → {a : w ≡ w'} {b : x ≡ x'} {c : y ≡ y'} {d : z ≡ z'}\n → (ps : Square a p p' c) (qs : Square a q q' b)\n → (rs : Square c r r' d) (ss : Square b s s' d)\n → (f0 : Square p q r s) (f1 : Square p' q' r' s')\n → Set _\nCube ps qs rs ss f0 f1\n = PathP (λ k → Square (ps k) (qs k) (rs k) (ss k)) f0 f1\n\nisGroupoid' : Set ℓ → Set ℓ\nisGroupoid' A\n = ∀{w x y z w' x' y' z' : A}\n → {p : w ≡ y} {q : w ≡ x} {r : y ≡ z} {s : x ≡ z}\n → {p' : w' ≡ y'} {q' : w' ≡ x'} {r' : y' ≡ z'} {s' : x' ≡ z'}\n → {a : w ≡ w'} {b : x ≡ x'} {c : y ≡ y'} {d : z ≡ z'}\n → (fp : Square a p p' c) → (fq : Square a q q' b)\n → (fr : Square c r r' d) → (fs : Square b s s' d)\n → (f0 : Square p q r s) → (f1 : Square p' q' r' s')\n → Cube fp fq fr fs f0 f1\n\nis2Groupoid : Type ℓ → Type ℓ\nis2Groupoid A = ∀ a b → isGroupoid (Path A a b)\n\n-- Essential consequences of isProp and isContr\nisProp→PathP\n : ((x : A) → isProp (B x)) → {a0 a1 : A}\n → (p : a0 ≡ a1) (b0 : B a0) (b1 : B a1)\n → PathP (λ i → B (p i)) b0 b1\nisProp→PathP {B = B} P p b0 b1 = toPathP {A = λ i → B (p i)} {b0} {b1} (P _ _ _)\n\nisPropIsContr : isProp (isContr A)\nisPropIsContr z0 z1 j =\n ( z0 .snd (z1 .fst) j\n , λ x i → hcomp (λ k → λ { (i = i0) → z0 .snd (z1 .fst) j\n ; (i = i1) → z0 .snd x (j ∨ k)\n ; (j = i0) → z0 .snd x (i ∧ k)\n ; (j = i1) → z1 .snd x i })\n (z0 .snd (z1 .snd x i) j))\n\nisContr→isProp : isContr A → isProp A\nisContr→isProp (x , p) a b i =\n hcomp (λ j → λ { (i = i0) → p a j\n ; (i = i1) → p b j }) x\n\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-- Universe lifting\n\nrecord Lift {i j} (A : Type i) : Type (ℓ-max i j) where\n instance constructor lift\n field\n lower : A\n\nopen Lift public\n", "meta": {"hexsha": "e7ffb877208996e5e4600fa372acd7b7a350d81a", "size": 7994, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/Prelude.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/Prelude.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/Prelude.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.5114503817, "max_line_length": 115, "alphanum_fraction": 0.4653490118, "num_tokens": 3463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998560157665, "lm_q2_score": 0.7718434978390747, "lm_q1q2_score": 0.5999538397370183}} {"text": "module Naturals where\n\nopen import Library\nopen import Categories\nopen import Functors\n\n\nopen Fun\n\nrecord NatT {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(F G : Fun C D) : \n Set (a ⊔ b ⊔ c ⊔ d) where\n constructor natural\n open Cat\n field cmp : ∀ {X} → Hom D (OMap F X) (OMap G X)\n nat : ∀{X Y}{f : Hom C X Y} → \n comp D (HMap G f) cmp ≅ comp D cmp (HMap F f)\n\nNatTEq : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G : Fun C D}\n {α β : NatT F G} → \n (λ {X} → NatT.cmp α {X}) ≅ (λ {X} → NatT.cmp β {X}) → \n α ≅ β\nNatTEq {α = natural cmp _} {natural .cmp _} refl =\n cong (natural cmp) (iext λ _ → iext λ _ → iext λ _ → ir _ _)\n\nidNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F : Fun C D} → NatT F F\nidNat {D = D}{F} = let open Cat D in record {\n cmp = iden;\n nat = λ{X}{Y}{f} → \n proof\n comp (HMap F f) iden\n ≅⟨ idr ⟩ \n HMap F f\n ≅⟨ sym idl ⟩ \n comp iden (HMap F f) ∎} \n\ncompNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G H : Fun C D} → \n NatT G H → NatT F G → NatT F H\ncompNat {D = D}{F}{G}{H} α β = let open Cat D; open NatT in record {\n cmp = comp (cmp α) (cmp β);\n nat = λ{X}{Y}{f} → \n proof\n comp (HMap H f) (comp (cmp α) (cmp β)) \n ≅⟨ sym ass ⟩\n comp (comp (HMap H f) (cmp α)) (cmp β)\n ≅⟨ cong (λ f₁ → comp f₁ (cmp β)) (nat α) ⟩\n comp (comp (cmp α) (HMap G f)) (cmp β)\n ≅⟨ ass ⟩\n comp (cmp α) (comp (HMap G f) (cmp β))\n ≅⟨ cong (comp (cmp α)) (nat β) ⟩\n comp (cmp α) (comp (cmp β) (HMap F f))\n ≅⟨ sym ass ⟩\n comp (comp (cmp α) (cmp β)) (HMap F f) \n ∎}\n\nidlNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G : Fun C D}\n {α : NatT F G} → compNat idNat α ≅ α\nidlNat {D = D} = NatTEq (iext λ _ → Cat.idl D)\n\nidrNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G : Fun C D}\n {α : NatT F G} → compNat α idNat ≅ α\nidrNat {D = D} = NatTEq (iext λ _ → Cat.idr D)\n \nassNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{E F G H : Fun C D}\n {α : NatT G H}{β : NatT F G}{η : NatT E F} → \n compNat (compNat α β) η ≅ compNat α (compNat β η)\nassNat {D = D} = NatTEq (iext λ _ → Cat.ass D)\n\n-- Natural isomorphism\n\nrecord Iso {l m}(C : Cat {l}{m}){A B}(f : Cat.Hom C A B) : Set (l ⊔ m)\n where\n constructor iso\n open Cat C\n field inv : Hom B A\n rinv : comp f inv ≅ iden {B}\n linv : comp inv f ≅ iden {A}\n\n\nrecord NatI {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(F G : Fun C D) : \n Set (a ⊔ b ⊔ c ⊔ d) where\n constructor natural\n open Cat\n field cmp : ∀ {X} → Hom D (OMap F X) (OMap G X)\n cmpI : ∀{X} -> Iso D (cmp {X})\n nat : ∀{X Y}{f : Hom C X Y} → \n comp D (HMap G f) cmp ≅ comp D cmp (HMap F f)\n", "meta": {"hexsha": "5600dc0ae58742db06a99c1fa14f49107643ca07", "size": 2693, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Naturals.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": "Naturals.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": "Naturals.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.9540229885, "max_line_length": 74, "alphanum_fraction": 0.4864463424, "num_tokens": 1189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797172476384, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.5999366719926911}} {"text": "-- Andreas, 2013-03-15\n-- Paolo Capriotti's formalization of Russell's paradox\n{-# OPTIONS --cubical-compatible --type-in-type #-}\nmodule Russell where\n\nopen import Common.Product\nopen import Common.Equality\n\ndata ⊥ : Set where\n\n¬ : Set → Set\n¬ A = A → ⊥\n\n-- a model of set theory, uses Set : Set\ndata U : Set where\n set : (I : Set) → (I → U) → U\n\n-- a set is regular if it doesn't contain itself\nregular : U → Set\nregular (set I f) = (i : I) → ¬ (f i ≡ set I f)\n\n-- Russell's set: the set of all regular sets\nR : U\nR = set (Σ U regular) proj₁\n\n-- R is not regular\nR-nonreg : ¬ (regular R)\nR-nonreg reg = reg (R , reg) refl\n\n-- R is regular\nR-reg : regular R\nR-reg (x , reg) p = subst regular p reg (x , reg) p\n\n-- contradiction\n\nabsurd : ⊥\nabsurd = R-nonreg R-reg\n", "meta": {"hexsha": "6690cbaf1196a60f475d457e01de1eae135dde99", "size": 766, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Russell.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/Russell.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/Russell.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": 20.1578947368, "max_line_length": 55, "alphanum_fraction": 0.635770235, "num_tokens": 253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797172476384, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.5999366658853647}} {"text": "module unit where\n\nopen import level\nopen import eq\n\ndata ⊤ {ℓ : Level} : Set ℓ where\n triv : ⊤\n\n{-# COMPILE GHC ⊤ = data () (()) #-}\n\nsingle-range : ∀{ℓ}{U : Set ℓ}{g : U → ⊤ {ℓ}} → ∀{u : U} → g u ≡ triv\nsingle-range {_}{U}{g}{u} with g u\n... | triv = refl\n", "meta": {"hexsha": "4bb7cff6a1fe984ea35cd1fd7e761a5ab2722c88", "size": 259, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "unit.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": "unit.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": "unit.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": 18.5, "max_line_length": 69, "alphanum_fraction": 0.5250965251, "num_tokens": 106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.853912760387131, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.5998993752469842}} {"text": "{-# OPTIONS --no-termination-check #-}\n\nmodule Lambda where\n\nmodule Prelude where\n\n data Bool : Set where\n true : Bool\n false : Bool\n\n if_then_else_ : {A : Set} -> Bool -> A -> A -> A\n if true then x else y = x\n if false then x else y = y\n\n _∧_ : Bool -> Bool -> Bool\n true ∧ y = y\n false ∧ y = false\n\n _∨_ : Bool -> Bool -> Bool\n true ∨ y = true\n false ∨ y = y\n\n ¬_ : Bool -> Bool\n ¬ true = false\n ¬ false = true\n\n data List (A : Set) : Set where\n nil : List A\n _::_ : A -> List A -> List A\n\n _++_ : {A : Set} -> List A -> List A -> List A\n nil ++ ys = ys\n (x :: xs) ++ ys = x :: xs ++ ys\n\n filter : {A : Set} -> (A -> Bool) -> List A -> List A\n filter p nil = nil\n filter p (x :: xs) = if p x then x :: filter p xs else filter p xs\n\n postulate\n String : Set\n Char : Set\n\n {-# BUILTIN BOOL Bool #-}\n {-# BUILTIN FALSE false #-}\n {-# BUILTIN TRUE true #-}\n {-# BUILTIN STRING String #-}\n {-# BUILTIN CHAR Char #-}\n {-# BUILTIN LIST List #-}\n {-# BUILTIN NIL nil #-}\n {-# BUILTIN CONS _::_ #-}\n\n primitive\n primStringEquality : String -> String -> Bool\n\n _==_ = primStringEquality\n\n infix 10 if_then_else_\n infixr 50 _::_ _++_\n infixl 5 _∨_\n infixl 7 _∧_\n infix 50 ¬_\n infix 15 _==_\n\nopen Prelude\n\nName : Set\nName = String\n\ndata Exp : Set where\n var : Name -> Exp\n ƛ_⟶_ : Name -> Exp -> Exp\n _$_ : Exp -> Exp -> Exp\n\ninfixl 50 _$_\ninfix 20 ƛ_⟶_\n\ninfix 80 _[_/_]\ninfix 15 _∈_\n\n_∈_ : Name -> List Name -> Bool\nx ∈ y :: ys = x == y ∨ x ∈ ys\nx ∈ nil = false\n\n-- Free variables\nFV : Exp -> List Name\nFV (var x) = x :: nil\nFV (s $ t) = FV s ++ FV t\nFV (ƛ x ⟶ t) = filter (\\y -> ¬ (x == y)) (FV t)\n\n-- Fresh names\nfresh : Name -> Exp -> Name\nfresh x e = fresh' (FV e)\n where\n fresh' : List Name -> Name\n fresh' xs = \"z\" -- TODO\n\n-- Substitution\n_[_/_] : Exp -> Exp -> Name -> Exp\nvar x [ r / z ] = if x == z then r else var x\n(s $ t) [ r / z ] = s [ r / z ] $ t [ r / z ]\n(ƛ x ⟶ t) [ r / z ] =\n if x == z then ƛ x ⟶ t\n else if x ∈ FV r then ( let y : Name\n y = fresh x r\n in ƛ y ⟶ t [ var y / x ] [ r / z ]\n )\n else ƛ x ⟶ t [ r / z ]\n\n", "meta": {"hexsha": "0dedd0bd966af5fbc7eeb78e998889e6d542d525", "size": 2274, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Lambda.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/Lambda.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/Lambda.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": 20.8623853211, "max_line_length": 68, "alphanum_fraction": 0.4806508355, "num_tokens": 829, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517044, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.5998993700233737}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Example of a Quotient: ℤ as (ℕ × ℕ / ∼)\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Relation.Binary.HeterogeneousEquality.Quotients.Examples where\n\nopen import Relation.Binary.HeterogeneousEquality.Quotients\nopen import Level using (0ℓ)\nopen import Relation.Binary\nopen import Relation.Binary.HeterogeneousEquality hiding (isEquivalence)\nimport Relation.Binary.PropositionalEquality as ≡\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Product\nopen import Function\nopen ≅-Reasoning\n\nℕ² = ℕ × ℕ\n\n_∼_ : ℕ² → ℕ² → Set\n(x , y) ∼ (x' , y') = x + y' ≅ x' + y\n\ninfix 10 _∼_\n\n∼-trans : ∀ {i j k} → i ∼ j → j ∼ k → i ∼ k\n∼-trans {x₁ , y₁} {x₂ , y₂} {x₃ , y₃} p q =\n ≡-to-≅ $ +-cancelˡ-≡ y₂ $ ≅-to-≡ $ begin\n y₂ + (x₁ + y₃) ≡⟨ ≡.sym (+-assoc y₂ x₁ y₃) ⟩\n y₂ + x₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm y₂ x₁) ⟩\n x₁ + y₂ + y₃ ≅⟨ cong (_+ y₃) p ⟩\n x₂ + y₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm x₂ y₁) ⟩\n y₁ + x₂ + y₃ ≡⟨ +-assoc y₁ x₂ y₃ ⟩\n y₁ + (x₂ + y₃) ≅⟨ cong (y₁ +_) q ⟩\n y₁ + (x₃ + y₂) ≡⟨ +-comm y₁ (x₃ + y₂) ⟩\n x₃ + y₂ + y₁ ≡⟨ ≡.cong (_+ y₁) (+-comm x₃ y₂) ⟩\n y₂ + x₃ + y₁ ≡⟨ +-assoc y₂ x₃ y₁ ⟩\n y₂ + (x₃ + y₁) ∎\n\n∼-isEquivalence : IsEquivalence _∼_\n∼-isEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = λ {i} {j} {k} → ∼-trans {i} {j} {k}\n }\n\nℕ²-∼-setoid : Setoid 0ℓ 0ℓ\nℕ²-∼-setoid = record { isEquivalence = ∼-isEquivalence }\n\nmodule Integers (quot : Quotients 0ℓ 0ℓ) where\n\n Int : Quotient ℕ²-∼-setoid\n Int = quot _\n\n open Quotient Int renaming (Q to ℤ)\n\n _+²_ : ℕ² → ℕ² → ℕ²\n (x₁ , y₁) +² (x₂ , y₂) = x₁ + x₂ , y₁ + y₂\n\n +²-cong : ∀{a b a' b'} → a ∼ a' → b ∼ b' → a +² b ∼ a' +² b'\n +²-cong {a₁ , b₁} {c₁ , d₁} {a₂ , b₂} {c₂ , d₂} ab∼cd₁ ab∼cd₂ = begin\n (a₁ + c₁) + (b₂ + d₂) ≡⟨ ≡.cong (_+ (b₂ + d₂)) (+-comm a₁ c₁) ⟩\n (c₁ + a₁) + (b₂ + d₂) ≡⟨ +-assoc c₁ a₁ (b₂ + d₂) ⟩\n c₁ + (a₁ + (b₂ + d₂)) ≡⟨ ≡.cong (c₁ +_) (≡.sym (+-assoc a₁ b₂ d₂)) ⟩\n c₁ + (a₁ + b₂ + d₂) ≅⟨ cong (λ n → c₁ + (n + d₂)) ab∼cd₁ ⟩\n c₁ + (a₂ + b₁ + d₂) ≡⟨ ≡.cong (c₁ +_) (+-assoc a₂ b₁ d₂) ⟩\n c₁ + (a₂ + (b₁ + d₂)) ≡⟨ ≡.cong (λ n → c₁ + (a₂ + n)) (+-comm b₁ d₂) ⟩\n c₁ + (a₂ + (d₂ + b₁)) ≡⟨ ≡.sym (+-assoc c₁ a₂ (d₂ + b₁)) ⟩\n (c₁ + a₂) + (d₂ + b₁) ≡⟨ ≡.cong (_+ (d₂ + b₁)) (+-comm c₁ a₂) ⟩\n (a₂ + c₁) + (d₂ + b₁) ≡⟨ +-assoc a₂ c₁ (d₂ + b₁) ⟩\n a₂ + (c₁ + (d₂ + b₁)) ≡⟨ ≡.cong (a₂ +_) (≡.sym (+-assoc c₁ d₂ b₁)) ⟩\n a₂ + (c₁ + d₂ + b₁) ≅⟨ cong (λ n → a₂ + (n + b₁)) ab∼cd₂ ⟩\n a₂ + (c₂ + d₁ + b₁) ≡⟨ ≡.cong (a₂ +_) (+-assoc c₂ d₁ b₁) ⟩\n a₂ + (c₂ + (d₁ + b₁)) ≡⟨ ≡.cong (λ n → a₂ + (c₂ + n)) (+-comm d₁ b₁) ⟩\n a₂ + (c₂ + (b₁ + d₁)) ≡⟨ ≡.sym (+-assoc a₂ c₂ (b₁ + d₁)) ⟩\n (a₂ + c₂) + (b₁ + d₁) ∎\n\n module _ (ext : ∀ {a b} {A : Set a} {B₁ B₂ : A → Set b} {f₁ : ∀ a → B₁ a}\n {f₂ : ∀ a → B₂ a} → (∀ a → f₁ a ≅ f₂ a) → f₁ ≅ f₂) where\n\n _+ℤ_ : ℤ → ℤ → ℤ\n _+ℤ_ = Properties₂.lift₂ ext Int Int (λ i j → abs (i +² j))\n $ λ {a} {b} {c} p p' → compat-abs (+²-cong {a} {b} {c} p p')\n\n zero² : ℕ²\n zero² = 0 , 0\n\n zeroℤ : ℤ\n zeroℤ = abs zero²\n\n +²-identityʳ : (i : ℕ²) → (i +² zero²) ∼ i\n +²-identityʳ (x , y) = begin\n (x + 0) + y ≡⟨ ≡.cong (_+ y) (+-identityʳ x) ⟩\n x + y ≡⟨ ≡.cong (x +_) (≡.sym (+-identityʳ y)) ⟩\n x + (y + 0) ∎\n\n +ℤ-on-abs≅abs-+₂ : ∀ a b → abs a +ℤ abs b ≅ abs (a +² b)\n +ℤ-on-abs≅abs-+₂ = Properties₂.lift₂-conv ext Int Int _\n $ λ {a} {b} {c} p p′ → compat-abs (+²-cong {a} {b} {c} p p′)\n\n +ℤ-identityʳ : ∀ i → i +ℤ zeroℤ ≅ i\n +ℤ-identityʳ = lift _ eq (≅-heterogeneous-irrelevantʳ _ _ ∘ compat-abs) where\n\n eq : ∀ a → abs a +ℤ zeroℤ ≅ abs a\n eq a = begin\n abs a +ℤ zeroℤ ≡⟨⟩\n abs a +ℤ abs zero² ≅⟨ +ℤ-on-abs≅abs-+₂ a zero² ⟩\n abs (a +² zero²) ≅⟨ compat-abs (+²-identityʳ a) ⟩\n abs a ∎\n\n +²-identityˡ : (i : ℕ²) → (zero² +² i) ∼ i\n +²-identityˡ i = refl\n\n +ℤ-identityˡ : (i : ℤ) → zeroℤ +ℤ i ≅ i\n +ℤ-identityˡ = lift _ eq (≅-heterogeneous-irrelevantʳ _ _ ∘ compat-abs) where\n\n eq : ∀ a → zeroℤ +ℤ abs a ≅ abs a\n eq a = begin\n zeroℤ +ℤ abs a ≡⟨⟩\n abs zero² +ℤ abs a ≅⟨ +ℤ-on-abs≅abs-+₂ zero² a ⟩\n abs (zero² +² a) ≅⟨ compat-abs (+²-identityˡ a) ⟩\n abs a ∎\n\n +²-assoc : (i j k : ℕ²) → (i +² j) +² k ∼ i +² (j +² k)\n +²-assoc (a , b) (c , d) (e , f) = begin\n ((a + c) + e) + (b + (d + f)) ≡⟨ ≡.cong (_+ (b + (d + f))) (+-assoc a c e) ⟩\n (a + (c + e)) + (b + (d + f)) ≡⟨ ≡.cong ((a + (c + e)) +_) (≡.sym (+-assoc b d f)) ⟩\n (a + (c + e)) + ((b + d) + f) ∎\n\n +ℤ-assoc : ∀ i j k → (i +ℤ j) +ℤ k ≅ i +ℤ (j +ℤ k)\n +ℤ-assoc = Properties₃.lift₃ ext Int Int Int eq compat₃ where\n\n eq : ∀ i j k → (abs i +ℤ abs j) +ℤ abs k ≅ abs i +ℤ (abs j +ℤ abs k)\n eq i j k = begin\n (abs i +ℤ abs j) +ℤ abs k ≅⟨ cong (_+ℤ abs k) (+ℤ-on-abs≅abs-+₂ i j) ⟩\n (abs (i +² j) +ℤ abs k) ≅⟨ +ℤ-on-abs≅abs-+₂ (i +² j) k ⟩\n abs ((i +² j) +² k) ≅⟨ compat-abs (+²-assoc i j k) ⟩\n abs (i +² (j +² k)) ≅⟨ sym (+ℤ-on-abs≅abs-+₂ i (j +² k)) ⟩\n (abs i +ℤ abs (j +² k)) ≅⟨ cong (abs i +ℤ_) (sym (+ℤ-on-abs≅abs-+₂ j k)) ⟩\n abs i +ℤ (abs j +ℤ abs k) ∎\n\n compat₃ : ∀ {a a′ b b′ c c′} → a ∼ a′ → b ∼ b′ → c ∼ c′ → eq a b c ≅ eq a′ b′ c′\n compat₃ p q r = ≅-heterogeneous-irrelevantˡ _ _\n $ cong₂ _+ℤ_ (cong₂ _+ℤ_ (compat-abs p) (compat-abs q))\n $ compat-abs r\n", "meta": {"hexsha": "cc9e7421dcc80f35ed1c46942560c321dabba195", "size": 5639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/HeterogeneousEquality/Quotients/Examples.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/HeterogeneousEquality/Quotients/Examples.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/HeterogeneousEquality/Quotients/Examples.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.8456375839, "max_line_length": 90, "alphanum_fraction": 0.4484837737, "num_tokens": 2846, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127566694177, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.5998993673168938}} {"text": "module Categories.Fam where\n\nopen import Level\nopen import Relation.Binary using (Rel)\nimport Relation.Binary.HeterogeneousEquality as Het\nopen Het using (_≅_) renaming (refl to ≣-refl)\n\nopen import Categories.Support.PropositionalEquality\n\nopen import Categories.Category\n\nmodule Fam {a b : Level} where\n record Fam : Set (suc a ⊔ suc b) where\n constructor _,_\n field\n U : Set a \n T : U → Set b\n open Fam public\n\n record Hom (A B : Fam) : Set (a ⊔ b) where\n constructor _,_\n field\n f : U A → U B\n φ : (x : U A) → T A x → T B (f x)\n\n record _≡Fam_ {X Y} (f g : (Hom X Y)) : Set (a ⊔ b) where\n constructor _,_\n field\n f≡g : {x : _} → Hom.f f x ≣ Hom.f g x\n φ≡γ : {x : _} {bx : _} → Hom.φ f x bx ≅ Hom.φ g x bx\n\n module Eq = _≡Fam_\n\n Cat : Category (suc a ⊔ suc b) (a ⊔ b) (a ⊔ b)\n Cat = record {\n Obj = Fam;\n _⇒_ = Hom;\n _≡_ = _≡Fam_;\n id = id′;\n _∘_ = _∘′_;\n assoc = ≣-refl , ≣-refl;\n identityˡ = ≣-refl , ≣-refl;\n identityʳ = ≣-refl , ≣-refl;\n equiv = record {\n refl = ≣-refl , ≣-refl;\n sym = \\ { (f≡g , φ≡γ) → ≣-sym f≡g , Het.sym φ≡γ }; \n trans = λ {(f≡g , φ≡γ) (g≡h , γ≡η) → ≣-trans f≡g g≡h , Het.trans φ≡γ γ≡η} };\n ∘-resp-≡ = ∘-resp-≡′ }\n where\n id′ : {A : Fam} → Hom A A\n id′ = (\\ x → x) , (\\ x bx → bx)\n \n _∘′_ : {A B C : Fam} → Hom B C → Hom A B → Hom A C\n _∘′_ (f , φ) (g , γ) = (λ x → f (g x)) , (λ x bx → φ (g x) (γ x bx))\n \n sym′ : ∀ {X Y} → Relation.Binary.Symmetric (_≡Fam_ {X} {Y})\n sym′ {Ax , Bx} {Ay , By} {f , φ} {g , γ} (f≡g , φ≡γ) = ≣-sym f≡g , Het.sym φ≡γ\n\n ∘-resp-≡′ : {A B C : Fam} {f h : Hom B C} {g i : Hom A B} → f ≡Fam h → g ≡Fam i → (f ∘′ g) ≡Fam (h ∘′ i)\n ∘-resp-≡′ {f = (f , φ)} {g , γ} {h , η} {i , ι} (f≡g , φ≡γ) (h≡i , η≡ι) = \n ≣-trans f≡g (≣-cong g h≡i) , Het.trans φ≡γ (Het.cong₂ γ (Het.≡-to-≅ h≡i) η≡ι)\n\n open Category Cat public\n\n\nFam : ∀ a b → Category (suc a ⊔ suc b) (a ⊔ b) (a ⊔ b)\nFam a b = Fam.Cat {a} {b}\n", "meta": {"hexsha": "a02f75789e3792ecf17a8368e8d47a451524d0bf", "size": 2165, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Fam.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/Fam.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/Fam.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.8382352941, "max_line_length": 109, "alphanum_fraction": 0.4443418014, "num_tokens": 929, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.5998993647050884}} {"text": "-- Agda is an /interactive/ language;\n-- that's very important difference (compared to language-pts)\nmodule J where\n\nopen import Level\nopen import Data.Bool using (Bool; true; false)\n\ndata ⊤ : Set where\n I : ⊤\n\ndata ⊥ : Set where\n\ndata Eq {ℓ : Level} (A : Set ℓ) : A → A → Set ℓ where\n refl : {x : A} → Eq A x x\n\nJ : ∀ {ℓ ℓ′} (A : Set ℓ)\n → (C : (x : A) → (y : A) → (p : Eq A x y) → Set ℓ′)\n → (r : (x : A) → C x x refl)\n → (u : A)\n → (v : A)\n → (p : Eq A u v)\n → C u v p\nJ A C r u .u refl = r u\n\nEq-sym : ∀ {ℓ} (A : Set ℓ) (x y : A) → Eq A x y → Eq A y x\nEq-sym A x .x refl = refl\n\nEq-sym-with-J : ∀ {ℓ} (A : Set ℓ) (x y : A) → Eq A x y → Eq A y x\nEq-sym-with-J A = J A (λ x y _ → Eq A y x) (λ x → refl)\n\nEq-trans-with-J : ∀ {ℓ} (A : Set ℓ) (x y z : A) → Eq A x y → Eq A y z → Eq A x z\nEq-trans-with-J A x y z p = J A (λ u v _ → Eq A v z → Eq A u z) (λ _ r → r) x y p\n\nBool-elim : ∀ {ℓ} (P : Bool → Set ℓ) → P true → P false → (b : Bool) → P b\nBool-elim P t f false = f\nBool-elim P t f true = t\n\nif1 : (r : Set1) → Bool → r → r → r\nif1 r b t f = Bool-elim (λ _ → r) t f b\n\nlemma-motive : Bool → Bool → Set\nlemma-motive u v = if1 Set u (if1 Set v ⊤ ⊥) ⊤\n\nlemma : Eq Bool true false → ⊥\nlemma p = J Bool\n (λ u v _ → lemma-motive u v)\n (λ b → Bool-elim (λ c → lemma-motive c c) I I b )\n true false p\n", "meta": {"hexsha": "288b91c0413a097a66f77f160117e681a73342f6", "size": 1311, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/J.agda", "max_stars_repo_name": "phadej/language-pts", "max_stars_repo_head_hexsha": "761e5b92b14506b75164bd3162487df2d7fbfa93", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-10-11T07:34:45.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:35:55.000Z", "max_issues_repo_path": "notes/J.agda", "max_issues_repo_name": "phadej/language-pts", "max_issues_repo_head_hexsha": "761e5b92b14506b75164bd3162487df2d7fbfa93", "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": "notes/J.agda", "max_forks_repo_name": "phadej/language-pts", "max_forks_repo_head_hexsha": "761e5b92b14506b75164bd3162487df2d7fbfa93", "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.7551020408, "max_line_length": 81, "alphanum_fraction": 0.5156369184, "num_tokens": 577, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583695, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.5998969457568055}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Instances.CommRings where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Structure\n\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.FiberedProduct\nopen import Cubical.Algebra.CommRing.Instances.Unit\n\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Limits.Terminal\nopen import Cubical.Categories.Limits.Pullback\n\nopen Category hiding (_∘_)\nopen CommRingHoms\n\nprivate\n variable\n ℓ : Level\n\nCommRingsCategory : Category (ℓ-suc ℓ) ℓ\nob CommRingsCategory = CommRing _\nHom[_,_] CommRingsCategory = CommRingHom\nid CommRingsCategory {R} = idCommRingHom R\n_⋆_ CommRingsCategory {R} {S} {T} = compCommRingHom R S T\n⋆IdL CommRingsCategory {R} {S} = compIdCommRingHom {R = R} {S}\n⋆IdR CommRingsCategory {R} {S} = idCompCommRingHom {R = R} {S}\n⋆Assoc CommRingsCategory {R} {S} {T} {U} = compAssocCommRingHom {R = R} {S} {T} {U}\nisSetHom CommRingsCategory = isSetRingHom _ _\n\nTerminalCommRing : Terminal {ℓ-suc ℓ-zero} CommRingsCategory\nfst TerminalCommRing = UnitCommRing\nfst (fst (snd TerminalCommRing y)) _ = tt\nsnd (fst (snd TerminalCommRing y)) = makeIsRingHom refl (λ _ _ → refl) (λ _ _ → refl)\nsnd (snd TerminalCommRing y) f = RingHom≡ (funExt (λ _ → refl))\n\n\nopen Pullback\n\n{-\n A x_C B -----> A\n | |\n | | α\n | |\n V V\n B --------> C\n β\n-}\nPullbackCommRing : Pullbacks {ℓ-suc ℓ} CommRingsCategory\npbOb (PullbackCommRing (cospan A C B α β)) = fiberedProduct A B C α β\npbPr₁ (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₁ A B C α β\npbPr₂ (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₂ A B C α β\npbCommutes (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₁₂Commutes A B C α β\nunivProp (PullbackCommRing (cospan A C B α β)) {d = D} = fiberedProductUnivProp A B C α β D\n", "meta": {"hexsha": "1944b479cb72eb23fb4f52a312b4cd5b0cf0e9c5", "size": 2160, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/CommRings.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/Categories/Instances/CommRings.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/Categories/Instances/CommRings.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": 34.8387096774, "max_line_length": 91, "alphanum_fraction": 0.6888888889, "num_tokens": 676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.849971190859164, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5998969353411225}} {"text": "{-# OPTIONS --type-in-type #-}\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Bool\nopen import Data.Product hiding ( curry ; uncurry )\nopen import Data.Nat\nopen import Data.String\nopen import Relation.Binary.PropositionalEquality using ( refl ; _≢_ ; _≡_ )\nopen import Function\nmodule ClosedTheory where\n\nnoteq = _≢_\n\n----------------------------------------------------------------------\n\ndata Desc (I : Set) : Set₁ where\n End : (i : I) → Desc I\n Rec : (i : I) (D : Desc I) → Desc I\n Arg : (A : Set) (B : A → Desc I) → Desc I\n\nISet : Set → Set₁\nISet I = I → Set\n\nEl : {I : Set} (D : Desc I) → ISet I → ISet I\nEl (End j) X i = j ≡ i\nEl (Rec j D) X i = X j × El D X i\nEl (Arg A B) X i = Σ A (λ a → El (B a) X i)\n\n----------------------------------------------------------------------\n\nUncurriedEl : {I : Set} (D : Desc I) (X : ISet I) → Set\nUncurriedEl D X = ∀{i} → El D X i → X i\n\nCurriedEl : {I : Set} (D : Desc I) (X : ISet I) → Set\nCurriedEl (End i) X = X i\nCurriedEl (Rec i D) X = (x : X i) → CurriedEl D X\nCurriedEl (Arg A B) X = (a : A) → CurriedEl (B a) X\n\nCurriedEl' : {I : Set} (D : Desc I) (X : ISet I) (i : I) → Set\nCurriedEl' (End j) X i = j ≡ i → X i\nCurriedEl' (Rec j D) X i = (x : X j) → CurriedEl' D X i\nCurriedEl' (Arg A B) X i = (a : A) → CurriedEl' (B a) X i\n\ncurryEl : {I : Set} (D : Desc I) (X : ISet I)\n → UncurriedEl D X → CurriedEl D X\ncurryEl (End i) X cn = cn refl\ncurryEl (Rec i D) X cn = λ x → curryEl D X (λ xs → cn (x , xs))\ncurryEl (Arg A B) X cn = λ a → curryEl (B a) X (λ xs → cn (a , xs))\n\nuncurryEl : {I : Set} (D : Desc I) (X : ISet I)\n → CurriedEl D X → UncurriedEl D X\nuncurryEl (End i) X cn refl = cn\nuncurryEl (Rec i D) X cn (x , xs) = uncurryEl D X (cn x) xs\nuncurryEl (Arg A B) X cn (a , xs) = uncurryEl (B a) X (cn a) xs\n\n----------------------------------------------------------------------\n\ndata μ {I : Set} (D : Desc I) (i : I) : Set where\n init : El D (μ D) i → μ D i\n\nInj : {I : Set} (D : Desc I) → Set\nInj D = CurriedEl D (μ D)\n\ninj : {I : Set} (D : Desc I) → Inj D\ninj D = curryEl D (μ D) init\n\n----------------------------------------------------------------------\n\ndata VecT : Set where\n nilT consT : VecT\n\nVecC : (A : Set) → VecT → Desc ℕ\nVecC A nilT = End zero\nVecC A consT = Arg ℕ (λ n → Arg A λ _ → Rec n (End (suc n)))\n\nVecD : (A : Set) → Desc ℕ\nVecD A = Arg VecT (VecC A)\n\nVec : (A : Set) → ℕ → Set\nVec A = μ (VecD A)\n\nInjConsT : Set → ℕ → Set\nInjConsT A m = El (VecC A consT) (Vec A) m → Vec A m\n\nInjConsT' : Set → ℕ → Set\nInjConsT' A m = Σ ℕ (λ n → A × Vec A n × suc n ≡ m) → Vec A m\n\ntest-InjConsT : (A : Set) (n : ℕ) → InjConsT A n ≡ InjConsT' A n\ntest-InjConsT A n = refl\n\nnil : (A : Set) → Vec A zero\nnil A = init (nilT , refl)\n\ncons : (A : Set) (n : ℕ) (x : A) (xs : Vec A n) → Vec A (suc n)\ncons A n x xs = init (consT , n , x , xs , refl)\n\nnil2 : (A : Set) → Vec A zero\nnil2 A = inj (VecD A) nilT\n\ncons2 : (A : Set) (n : ℕ) (x : A) (xs : Vec A n) → Vec A (suc n)\ncons2 A = inj (VecD A) consT\n\nbit : Vec Bool (suc zero)\nbit = cons Bool zero true (nil Bool)\n\nbit2 : Vec Bool (suc zero)\nbit2 = init (consT , zero , true , init (nilT , refl) , refl)\n\n----------------------------------------------------------------------\n\ndata TreeT : Set where\n leaf₁T leaf₂T branchT : TreeT\n\nTreeC : (A B : Set) → TreeT → Desc (ℕ × ℕ)\nTreeC A B leaf₁T = Arg A λ _ → End (suc zero , zero)\nTreeC A B leaf₂T = Arg B λ _ → End (zero , suc zero)\nTreeC A B branchT = Arg ℕ λ m → Arg ℕ λ n\n → Arg ℕ λ x → Arg ℕ λ y\n → Rec (m , n) $ Rec (x , y)\n $ End (m + x , n + y)\n\nTreeD : (A B : Set) → Desc (ℕ × ℕ)\nTreeD A B = Arg TreeT (TreeC A B)\n\nTree : (A B : Set) (m n : ℕ) → Set\nTree A B m n = μ (TreeD A B) (m , n)\n\nleaf₁ : (A B : Set) → A → Tree A B (suc zero) zero\nleaf₁ A B a = init (leaf₁T , a , refl)\n\nleaf₁2 : (A B : Set) → A → Tree A B (suc zero) zero\nleaf₁2 A B = inj (TreeD A B) leaf₁T\n\n----------------------------------------------------------------------\n", "meta": {"hexsha": "cd6991fc1c56cec434310ae712871e2cd745dfe9", "size": 3979, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "slides/ClosedTheory.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/ClosedTheory.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/ClosedTheory.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": 29.4740740741, "max_line_length": 76, "alphanum_fraction": 0.4950992712, "num_tokens": 1511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.849971175657575, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5998969246120688}} {"text": "module prelude.Stream where\nopen import prelude\nopen import Data.List as L using (List)\n\nrecord Stream (a : Set) : Set where\n constructor _∷_\n coinductive\n field\n hd : a\n tl : Stream a\nopen Stream\n\n\ntake : ∀ {a} → ℕ → Stream a → List a\ntake ℕz xs = L.[]\ntake (ℕs n) xs = hd xs L.∷ take n (tl xs)\n", "meta": {"hexsha": "87658d6a90797166226205fe3146e90a4ab86916", "size": 319, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "code-examples/agda/prelude/Stream.agda", "max_stars_repo_name": "mstone/poly", "max_stars_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2021-02-18T16:31:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:08:27.000Z", "max_issues_repo_path": "code-examples/agda/prelude/Stream.agda", "max_issues_repo_name": "dspivak/poly", "max_issues_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-09-02T02:29:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-12T10:06:32.000Z", "max_forks_repo_path": "code-examples/agda/prelude/Stream.agda", "max_forks_repo_name": "dspivak/poly", "max_forks_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-07-10T17:19:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T11:45:57.000Z", "avg_line_length": 18.7647058824, "max_line_length": 41, "alphanum_fraction": 0.6144200627, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.84997116805678, "lm_q2_score": 0.7057850278370111, "lm_q1q2_score": 0.5998969245076113}} {"text": "-- Andreas, 2022-06-14, issue #4725 reported by nad\n\n-- The termination checker needs to recognize\n-- dotted variable and record patterns as patterns\n-- for this example to pass.\n-- These should be harmless even with --cubical\n-- (dotted constructor patterns are not, see #4606).\n-- Keep fingers crossed.\n\n{-# OPTIONS --cubical #-}\n\nopen import Agda.Builtin.Sigma\n\nmutual\n\n data D : Set where\n d : S → D\n\n S : Set\n S = Σ D λ x → R x\n\n fst′ : S → D\n fst′ s = fst s\n\n data R : D → Set where\n r : ∀ x → R (fst′ x) → R (d x)\n\nmodule _\n (P : D → Set)\n (Q : ∀ x → P x → R x → Set)\n (p : ∀ s (p : P (fst s)) → Q (fst s) p (snd s) → P (d s))\n (q : ∀ s rs (ps : P (fst s)) (qs : Q (fst s) ps (snd s)) →\n Q (fst s) ps rs → Q (d s) (p s ps qs) (r s rs))\n where\n\n mutual\n\n f : (x : D) → P x\n f (d (x , r₁)) = p (x , r₁) (f x) (g x r₁)\n\n g : (x : D) (x⊑y : R x) → Q x (f x) x⊑y\n g (d (x , r₁)) (r .(x , r₁) r₂) =\n q (x , r₁) r₂ (f x) (g x r₁) (g (fst′ (x , r₁)) r₂)\n\n-- Should termination check.\n", "meta": {"hexsha": "f2309ff6854b1a9c7420045e71780b14fe5ae43a", "size": 1024, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue4725.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/Issue4725.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/Issue4725.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.2608695652, "max_line_length": 60, "alphanum_fraction": 0.5107421875, "num_tokens": 417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104788995148792, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.5998957070397465}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.NaturalTransformation.Properties where\n\nopen import Level\nopen import Data.Product using (Σ; _,_)\nopen import Function.Equality using (Π)\n\nopen import Categories.Category\nopen import Categories.Category.Product\nopen import Categories.Category.Instance.Setoids\nopen import Categories.Functor\nopen import Categories.Functor.Construction.Constant\nopen import Categories.Functor.Construction.LiftSetoids\nopen import Categories.Functor.Bifunctor\nopen import Categories.NaturalTransformation renaming (id to idN)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\nopen import Categories.NaturalTransformation.Dinatural hiding (_≃_)\n\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ ℓ′ e : Level\n C D E : Category o ℓ e\n\nmodule _ {F G : Functor C D} where\n private\n module C = Category C\n module D = Category D\n open D\n open MR D\n open HomReasoning\n open Functor\n\n F′ : Bifunctor C.op C D\n F′ = F ∘F πʳ\n\n G′ : Bifunctor C.op C D\n G′ = G ∘F πʳ\n\n NT⇒Dinatural : NaturalTransformation F G → DinaturalTransformation F′ G′\n NT⇒Dinatural β = dtHelper record\n { α = η\n ; commute = λ f → ∘-resp-≈ʳ (elimʳ (identity F)) ○ ⟺ (commute f) ○ introˡ (identity G)\n }\n where open NaturalTransformation β\n\n Dinatural⇒NT : DinaturalTransformation F′ G′ → NaturalTransformation F G\n Dinatural⇒NT θ = ntHelper record\n { η = α\n ; commute = λ f → introˡ (identity G) ○ ⟺ (commute f) ○ ∘-resp-≈ʳ (elimʳ (identity F))\n }\n where open DinaturalTransformation θ\n\n replaceˡ : ∀ {F′} → NaturalTransformation F G → F ≃ F′ → NaturalTransformation F′ G\n replaceˡ {F′} α F≃F′ = ntHelper record\n { η = λ X → η X ∘ ⇐.η X\n ; commute = λ {X Y} f → begin\n (η Y ∘ ⇐.η Y) ∘ F₁ F′ f ≈⟨ pullʳ (⇐.commute f) ⟩\n η Y ∘ F₁ F f ∘ ⇐.η X ≈⟨ pullˡ (commute f) ○ assoc ⟩\n F₁ G f ∘ η X ∘ ⇐.η X ∎\n }\n where open NaturalIsomorphism F≃F′\n open NaturalTransformation α\n\n replaceʳ : ∀ {G′} → NaturalTransformation F G → G ≃ G′ → NaturalTransformation F G′\n replaceʳ {G′} α G≃G′ = ntHelper record\n { η = λ X → ⇒.η X ∘ η X\n ; commute = λ {X Y} f → begin\n (⇒.η Y ∘ η Y) ∘ F₁ F f ≈⟨ pullʳ (commute f) ⟩\n ⇒.η Y ∘ F₁ G f ∘ η X ≈⟨ pullˡ (⇒.commute f) ○ assoc ⟩\n F₁ G′ f ∘ ⇒.η X ∘ η X ∎\n }\n where open NaturalIsomorphism G≃G′\n open NaturalTransformation α \n\nmodule _ (F : Bifunctor C D E) where\n\n -- there is natural transformation between two partially applied bifunctors.\n\n appˡ-nat : ∀ {X Y} → (f : Category._⇒_ C X Y) → NaturalTransformation (appˡ F X) (appˡ F Y)\n appˡ-nat f = F ∘ˡ (constNat f ※ⁿ idN)\n\n appʳ-nat : ∀ {X Y} → (f : Category._⇒_ D X Y) → NaturalTransformation (appʳ F X) (appʳ F Y)\n appʳ-nat f = F ∘ˡ (idN ※ⁿ constNat f)\n\nmodule _ {F G : Bifunctor C D E} (α : NaturalTransformation F G) where\n private\n module C = Category C\n module D = Category D\n module E = Category E\n\n appˡ′ : ∀ X → NaturalTransformation (appˡ F X) (appˡ G X)\n appˡ′ X = α ∘ₕ idN\n\n appʳ′ : ∀ X → NaturalTransformation (appʳ F X) (appʳ G X)\n appʳ′ X = α ∘ₕ idN\n\n-- unlift universe level\nmodule _ {c ℓ ℓ′ e} {F G : Functor C (Setoids c ℓ)} (α : NaturalTransformation (LiftSetoids ℓ′ e ∘F F) (LiftSetoids ℓ′ e ∘F G)) where\n open NaturalTransformation α\n open Π\n\n unlift-nat : NaturalTransformation F G\n unlift-nat = ntHelper record\n { η = λ X → record\n { _⟨$⟩_ = λ x → lower (η X ⟨$⟩ lift x)\n ; cong = λ eq → lower (cong (η X) (lift eq))\n }\n ; commute = λ f eq → lower (commute f (lift eq))\n }\n", "meta": {"hexsha": "fd38778622d8de28aae8c4989a5aa92cd02dd5a8", "size": 3623, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/NaturalTransformation/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/NaturalTransformation/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/NaturalTransformation/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": 32.0619469027, "max_line_length": 133, "alphanum_fraction": 0.6329009108, "num_tokens": 1317, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430394931456, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.5998718471902703}} {"text": "module Data.Num.Redundant where\n\n-- Base: 2\n-- Digit: { 0, 1, 2 }\n--\n-- Numeral System which maxports efficient addition, substraction\n-- and arithmetic shift.\n\nopen import Data.List using (List ; []; _∷_) public\nopen import Data.Nat renaming (_+_ to _+ℕ_; _<_ to _<ℕ_)\nopen import Data.Num.Bij\n\nopen import Data.Empty\nopen import Relation.Nullary\nopen import Relation.Nullary.Negation using (contradiction; contraposition)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_)\nimport Level\nopen PropEq.≡-Reasoning\n\n--------------------------------------------------------------------------------\n-- Digits\n--------------------------------------------------------------------------------\n\ndata Digit : Set where\n zero : Digit\n one : Digit\n two : Digit\n\n-- plus\n_⊕_ : Digit → Digit → Digit\nzero ⊕ y = y\nx ⊕ zero = x\none ⊕ one = two\none ⊕ two = one\ntwo ⊕ one = one\ntwo ⊕ two = two\n\n-- minus\n_⊝_ : Digit → Digit → Digit\nzero ⊝ y = zero\nx ⊝ zero = x\none ⊝ one = zero\none ⊝ two = one\ntwo ⊝ one = one\ntwo ⊝ two = zero\n\n-- carry\n_⊙_ : Digit → Digit → Digit\none ⊙ two = one\ntwo ⊙ one = one\ntwo ⊙ two = one\n_ ⊙ _ = zero\n\n-- borrow\n_⊘_ : Digit → Digit → Digit\nzero ⊘ one = one\nzero ⊘ two = one\none ⊘ two = one\n_ ⊘ _ = zero\n\n--------------------------------------------------------------------------------\n-- Sequence of Digits\n--------------------------------------------------------------------------------\n\nRedundant : Set\nRedundant = List Digit\n\n-- \"one-sided\"\nincr : Digit → Redundant → Redundant\nincr x [] = x ∷ []\nincr x (y ∷ ys) = x ⊕ y ∷ incr (x ⊙ y) ys\n\ndecr : Digit → Redundant → Redundant\ndecr x [] = []\ndecr x (y ∷ ys) = x ⊝ y ∷ decr (x ⊘ y) ys\n\n-- \"two-sided\"\n_+_ : Redundant → Redundant → Redundant\n[] + ys = ys\nxs + [] = xs\n(x ∷ xs) + (y ∷ ys) = x ⊕ y ∷ incr (x ⊙ y) (xs + ys)\n\n_─_ : Redundant → Redundant → Redundant\n[] ─ ys = []\nxs ─ [] = xs\n(x ∷ xs) ─ (y ∷ ys) = x ⊝ y ∷ decr (x ⊘ y) (xs ─ ys)\n\n-- arithmetic shift\n>> : Redundant → Redundant\n>> xs = zero ∷ xs\n\n<< : Redundant → Redundant\n<< [] = []\n<< (x ∷ xs) = xs\n\n_>>>_ : ℕ → Redundant → Redundant\nzero >>> xs = xs\nsuc n >>> xs = n >>> (>> xs)\n\n_<<<_ : ℕ → Redundant → Redundant\nzero <<< xs = xs\nsuc n <<< [] = []\nsuc n <<< (x ∷ xs) = n <<< xs\n\n--------------------------------------------------------------------------------\n-- instances of Conversion, so that we can convert Redundant to B\n--------------------------------------------------------------------------------\n\ninstance convRedundant : Conversion Redundant\nconvRedundant = conversion [_]' !_!' [!!]-id'\n where [_]' : Redundant → Bij\n [ [] ]' = []\n [ zero ∷ xs ]' = *2 [ xs ]'\n [ one ∷ xs ]' = one ∷ [ xs ]'\n [ two ∷ xs ]' = two ∷ [ xs ]'\n\n !_!' : Bij → Redundant\n ! [] !' = []\n ! one ∷ xs !' = one ∷ ! xs !'\n ! two ∷ xs !' = two ∷ ! xs !'\n\n [!!]-id' : ∀ xs → [ ! xs !' ]' ≡ xs\n [!!]-id' [] = PropEq.refl\n [!!]-id' (one ∷ xs) = PropEq.cong (λ x → one ∷ x) ([!!]-id' xs)\n [!!]-id' (two ∷ xs) = PropEq.cong (λ x → two ∷ x) ([!!]-id' xs)\n\n--------------------------------------------------------------------------------\n-- Equivalence relation\n--------------------------------------------------------------------------------\n\ninfix 4 _≈_ _≉_\n\ndata _≈_ (a b : Redundant) : Set where\n eq : ([a]≡[b] : [ a ] ≡ [ b ]) → a ≈ b\n\n-- the inverse of `eq`\nto≡ : ∀ {a b} → a ≈ b → [ a ] ≡ [ b ]\nto≡ (eq x) = x\n\n_≉_ : (a b : Redundant) → Set\na ≉ b = a ≈ b → ⊥\n\n-- decidable\n{-\n_≈?_ : Decidable {A = Redundant} _≈_\na ≈? b with [ a ] ≟ [ b ]\na ≈? b | yes p = yes (eq p)\na ≈? b | no ¬p = no (contraposition to≡ ¬p)\n-}\n\n--------------------------------------------------------------------------------\n-- Ordering\n--------------------------------------------------------------------------------\n\ninfix 4 _≲_ _<_\ndata _≲_ : Rel Redundant Level.zero where\n le : ∀ {a b} ([a]≤[b] : [ a ] ≤B [ b ]) → a ≲ b\n\n-- the inverse of `le`\nto≤ : ∀ {a b} → a ≲ b → [ a ] ≤B [ b ]\nto≤ (le [a]≤B[b]) = [a]≤B[b]\n\n_<_ : Rel Redundant Level.zero\na < b = incr one a ≲ b\n\n{-\n-- decidable\n_≲?_ : Decidable _≲_\na ≲? b with [ a ] ≤? [ b ]\na ≲? b | yes p = yes (le p)\na ≲? b | no ¬p = no (contraposition to≤ ¬p)\n-}\n", "meta": {"hexsha": "17bcec9daac48b7ea35b54144e9dadaa9899397d", "size": 4360, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/Data/Num/Redundant.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/Data/Num/Redundant.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/Data/Num/Redundant.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": 24.9142857143, "max_line_length": 80, "alphanum_fraction": 0.4139908257, "num_tokens": 1465, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681122619883, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.5997981554943023}} {"text": "module Issue462 where\n\ndata _≡_ {A : Set} : A → A → Set where\n ≡-refl : (x : A) → x ≡ x\n\npostulate A : Set\n\nrecord R (_≈_ _∼_ : A → A → Set) : Set where\n field\n ≈-refl : (x : A) → x ≈ x\n ∼-reflexive : (x y : A) → x ≈ y → x ∼ y\n\n ∼-refl : (x : A) → x ∼ x\n ∼-refl x = ∼-reflexive x x (≈-refl x)\n\npostulate\n _≈_ : A → A → Set\n ≈-refl : ((x : A) → x ≡ x) → (x : A) → x ≈ x\n ≈-irr : (x : A) (p : x ≈ x) → p ≡ p\n\n≡-r : R _≡_ _≡_\n≡-r = record\n { ≈-refl = ≡-refl\n ; ∼-reflexive = λ _ _ p → p\n }\n\n≈-reflexive : (x y : A) → x ≡ y → x ≈ y\n≈-reflexive .x .x (≡-refl x) = ≈-refl (R.∼-refl ≡-r) x\n\n≈-r : R _≡_ _≈_\n≈-r = record\n { ≈-refl = ≡-refl\n ; ∼-reflexive = ≈-reflexive\n }\n\nfoo : A → Set₁\nfoo x with ≈-irr x (R.∼-refl ≈-r x)\nfoo x | _ = Set\n\n-- The generated with function should not contain unsolved\n-- meta-variables.\n", "meta": {"hexsha": "f9c05f60849cec8a3e5cd02b506bbd183f519567", "size": 849, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue462.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/Issue462.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/Issue462.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": 20.2142857143, "max_line_length": 58, "alphanum_fraction": 0.4628975265, "num_tokens": 454, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.5997981396575233}} {"text": "module Mockingbird.Forest.Base where\n\nopen import Algebra using (Op₂; Congruent₂; LeftCongruent; RightCongruent)\nopen import Level using (_⊔_) renaming (suc to lsuc)\nopen import Relation.Binary using (Rel; IsEquivalence; Setoid)\nopen import Relation.Nullary using (¬_)\n\nrecord IsForest {b ℓ} (Bird : Set b) (_≈_ : Rel Bird ℓ) (_∙_ : Op₂ Bird) : Set (b ⊔ ℓ) where\n field\n isEquivalence : IsEquivalence _≈_\n cong : Congruent₂ _≈_ _∙_\n\n open IsEquivalence isEquivalence public\n\n setoid : Setoid b ℓ\n setoid = record { isEquivalence = isEquivalence }\n\n congˡ : LeftCongruent _≈_ _∙_\n congˡ A≈B = cong refl A≈B\n\n congʳ : RightCongruent _≈_ _∙_\n congʳ A≈B = cong A≈B refl\n\nrecord Forest {b ℓ} : Set (lsuc (b ⊔ ℓ)) where\n infix 4 _≈_\n infixl 6 _∙_\n\n field\n Bird : Set b\n _≈_ : Rel Bird ℓ\n _∙_ : Op₂ Bird\n isForest : IsForest Bird _≈_ _∙_\n\n _≉_ : Rel Bird ℓ\n x ≉ y = ¬ (x ≈ y)\n\n open IsForest isForest public\n\n import Relation.Binary.Reasoning.Base.Single _≈_ refl trans as Base\n open Base using (begin_; _∎) public\n\n infixr 2 _≈⟨⟩_ step-≈ step-≈˘\n\n _≈⟨⟩_ : ∀ x {y} → x Base.IsRelatedTo y → x Base.IsRelatedTo y\n _ ≈⟨⟩ x≈y = x≈y\n\n step-≈ = Base.step-∼\n syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z\n\n step-≈˘ : ∀ x {y z} → y Base.IsRelatedTo z → y ≈ x → x Base.IsRelatedTo z\n step-≈˘ x y∼z y≈x = x ≈⟨ sym y≈x ⟩ y∼z\n syntax step-≈˘ x y≈z y≈x = x ≈˘⟨ y≈x ⟩ y≈z\n", "meta": {"hexsha": "1db0bdc8478cdb2e2fe60699328d63ca48c729be", "size": 1389, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Mockingbird/Forest/Base.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/Base.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/Base.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": 26.2075471698, "max_line_length": 92, "alphanum_fraction": 0.6342692585, "num_tokens": 612, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.5997981342815825}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Relation.Nullary.Decidable where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Data.Empty using (⊥)\n\nprivate\n variable\n ℓ : Level\n\n-- Negation\ninfix 3 ¬_\n\n¬_ : Type ℓ → Type ℓ\n¬ A = A → ⊥\n\n-- Decidable types (inspired by standard library)\ndata Dec (P : Type ℓ) : Type ℓ where\n yes : ( p : P) → Dec P\n no : (¬p : ¬ P) → Dec P\n\ndata IsYes {P : Type ℓ} : Dec P → Type ℓ where\n isYes : ∀ {x} → IsYes (yes x)\n\nDiscrete : Type ℓ → Type ℓ\nDiscrete A = ∀ x y → Dec (Path A x y)\n", "meta": {"hexsha": "ea4ae71fae164356fc80821ccae6101ec7489227", "size": 557, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Relation/Nullary/Decidable.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/Nullary/Decidable.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/Nullary/Decidable.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": 20.6296296296, "max_line_length": 50, "alphanum_fraction": 0.6211849192, "num_tokens": 200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8459424217727027, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5997893683186624}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Structures.NAryOp where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\n\nopen import Cubical.Functions.FunExtEquiv\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Vec\n\nopen import Cubical.Foundations.SIP renaming (SNS-PathP to SNS)\n\nprivate\n variable\n ℓ ℓ' : Level\n\n-- TODO: generalize to different target type?\nnAryFunStructure : (n : ℕ) → Type (ℓ-max (ℓ-suc ℓ) (nAryLevel ℓ ℓ n))\nnAryFunStructure {ℓ = ℓ} n = TypeWithStr _ (λ (X : Type ℓ) → nAryOp n X X)\n\n-- iso for n-ary functions\nnAryFunIso : (n : ℕ) → StrIso (λ (X : Type ℓ) → nAryOp n X X) ℓ\nnAryFunIso n (X , fX) (Y , fY) f =\n (xs : Vec X n) → equivFun f (fX $ⁿ xs) ≡ fY $ⁿ map (equivFun f) xs\n\nnAryFunSNS : (n : ℕ) → SNS {ℓ} _ (nAryFunIso n)\nnAryFunSNS n = SNS-≡→SNS-PathP (nAryFunIso n) (nAryFunExtEquiv n)\n\n-- Some specializations that are not used at the moment, but kept as\n-- they might become useful later.\nprivate\n\n -- unary\n unaryFunIso : StrIso (λ (X : Type ℓ) → nAryOp 1 X X) ℓ\n unaryFunIso (A , f) (B , g) e =\n (x : A) → equivFun e (f x) ≡ g (equivFun e x)\n\n unaryFunSNS : SNS {ℓ} _ unaryFunIso\n unaryFunSNS = SNS-≡→SNS-PathP unaryFunIso (λ s t → compEquiv lem (nAryFunExtEquiv 1 s t))\n where\n lem : ∀ {X} → {s t : X → X} →\n ((x : X) → s x ≡ t x) ≃\n ((xs : Vec X 1) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))\n lem {X} {s} {t} = isoToEquiv f\n where\n f : Iso ((x : X) → s x ≡ t x)\n ((xs : Vec X 1) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))\n Iso.fun f p (x ∷ []) = p x\n Iso.inv f p x = p (x ∷ [])\n Iso.rightInv f p _ xs@(x ∷ []) = p xs\n Iso.leftInv f p _ = p\n\n -- binary\n binaryFunIso : StrIso (λ (X : Type ℓ) → nAryOp 2 X X) ℓ\n binaryFunIso (A , f) (B , g) e =\n (x y : A) → equivFun e (f x y) ≡ g (equivFun e x) (equivFun e y)\n\n binaryFunSNS : SNS {ℓ} _ binaryFunIso\n binaryFunSNS = SNS-≡→SNS-PathP binaryFunIso (λ s t → compEquiv lem (nAryFunExtEquiv 2 s t))\n where\n lem : ∀ {X} → {s t : X → X → X} →\n ((x y : X) → s x y ≡ t x y) ≃\n ((xs : Vec X 2) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))\n lem {X} {s} {t} = isoToEquiv f\n where\n f : Iso ((x y : X) → s x y ≡ t x y)\n ((xs : Vec X 2) → (s $ⁿ xs) ≡ (t $ⁿ map (λ x → x) xs))\n Iso.fun f p (x ∷ y ∷ []) = p x y\n Iso.inv f p x y = p (x ∷ y ∷ [])\n Iso.rightInv f p _ xs@(x ∷ y ∷ []) = p xs\n Iso.leftInv f p _ = p\n", "meta": {"hexsha": "aaf38af83e21d72252e41d58aa802511e34e0ee1", "size": 2603, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Structures/NAryOp.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/NAryOp.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/NAryOp.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": 35.1756756757, "max_line_length": 93, "alphanum_fraction": 0.5336150595, "num_tokens": 1071, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424256566558, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.5997893658711426}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Algebra.BasicProp 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.Structures.Group\n\n\n\nprivate\n variable\n ℓ ℓ' : Level\n\n---------------------------------------------------------------------\n-- Groups basic properties\n---------------------------------------------------------------------\n\n-- We will use the multiplicative notation for groups\n\nmodule _ (G : Group {ℓ}) where\n\n open group-·syntax G\n\n private\n ₁· = group-lid G\n\n ·₁ = group-rid G\n\n ·-assoc = group-assoc G\n\n ⁻¹· = group-linv G\n\n ·⁻¹ = group-rinv G\n\n id-is-unique : isContr (Σ[ x ∈ ⟨ G ⟩ ] ∀ (y : ⟨ G ⟩) → (x · y ≡ y) × (y · x ≡ y))\n id-is-unique = (₁ , λ y → ₁· y , ·₁ y) ,\n λ { (e , is-unit) → ΣProp≡ (λ x → isPropΠ λ y → isPropΣ (group-is-set G _ _)\n λ _ → group-is-set G _ _)\n (₁ ≡⟨ sym (snd (is-unit ₁)) ⟩\n ₁ · e ≡⟨ ₁· e ⟩\n e ∎\n )}\n\n are-inverses : ∀ (x y : ⟨ G ⟩)\n → x · y ≡ ₁\n → (y ≡ x ⁻¹) × (x ≡ y ⁻¹)\n are-inverses x y eq = (y ≡⟨ sym (₁· y) ⟩\n ₁ · y ≡⟨ sym (·-assoc _ _ _ ∙ cong (_· y) (⁻¹· _)) ⟩\n (x ⁻¹) · (x · y) ≡⟨ cong ((x ⁻¹) ·_) eq ⟩\n (x ⁻¹) · ₁ ≡⟨ ·₁ _ ⟩\n x ⁻¹ ∎)\n , (x ≡⟨ sym (·₁ x) ⟩\n x · ₁ ≡⟨ cong (x ·_) (sym (·⁻¹ y)) ∙ ·-assoc _ _ _ ⟩\n (x · y) · (y ⁻¹) ≡⟨ cong (_· (y ⁻¹)) eq ⟩\n ₁ · (y ⁻¹) ≡⟨ ₁· _ ⟩\n y ⁻¹ ∎)\n\n inv-involutive : ∀ (x : ⟨ G ⟩)\n → (x ⁻¹) ⁻¹ ≡ x\n inv-involutive x = sym (snd (are-inverses x (x ⁻¹) (·⁻¹ x)))\n\n inv-distr : ∀ (x y : ⟨ G ⟩) → (x · y) ⁻¹ ≡ (y ⁻¹) · (x ⁻¹)\n inv-distr x y = sym (fst (are-inverses _ _ γ))\n where γ : (x · y) · ((y ⁻¹) · (x ⁻¹)) ≡ ₁\n γ = (x · y) · ((y ⁻¹) · (x ⁻¹)) ≡⟨ sym (cong (x ·_) (sym (·-assoc _ _ _)) ∙ ·-assoc _ _ _) ⟩\n x · ((y · (y ⁻¹)) · (x ⁻¹)) ≡⟨ cong (λ - → x · (- · (x ⁻¹))) (·⁻¹ y) ⟩\n x · (₁ · (x ⁻¹)) ≡⟨ cong (x ·_) (₁· (x ⁻¹)) ⟩\n x · (x ⁻¹) ≡⟨ ·⁻¹ x ⟩\n ₁ ∎\n\n left-cancel : ∀ (x y z : ⟨ G ⟩) → x · y ≡ x · z → y ≡ z\n left-cancel x y z eq = y ≡⟨ sym (cong (_· y) (⁻¹· x) ∙ ₁· y) ⟩\n ((x ⁻¹) · x) · y ≡⟨ sym (·-assoc _ _ _) ⟩\n (x ⁻¹) · (x · y) ≡⟨ cong ((x ⁻¹) ·_) eq ⟩\n (x ⁻¹) · (x · z) ≡⟨ ·-assoc _ _ _ ⟩\n ((x ⁻¹) · x) · z ≡⟨ cong (_· z) (⁻¹· x) ∙ ₁· z ⟩\n z ∎\n\n right-cancel : ∀ (x y z : ⟨ G ⟩) → x · z ≡ y · z → x ≡ y\n right-cancel x y z eq = x ≡⟨ sym (cong (x ·_) (·⁻¹ z) ∙ ·₁ x) ⟩\n x · (z · (z ⁻¹)) ≡⟨ ·-assoc _ _ _ ⟩\n (x · z) · (z ⁻¹) ≡⟨ cong (_· (z ⁻¹)) eq ⟩\n (y · z) · (z ⁻¹) ≡⟨ sym (·-assoc _ _ _) ⟩\n y · (z · (z ⁻¹)) ≡⟨ cong (y ·_) (·⁻¹ z) ∙ ·₁ y ⟩\n y ∎\n", "meta": {"hexsha": "804248b8d8ddcbe8369c448ea30f20e459140352", "size": 3468, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/BasicProp.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/Algebra/BasicProp.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/Algebra/BasicProp.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": 38.9662921348, "max_line_length": 102, "alphanum_fraction": 0.3027681661, "num_tokens": 1309, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.5997881314431379}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\nmodule Extensions where\n\n ExtensionOf : ∀ {ℓ} {A B : Type ℓ} (f : A → B) (P : B → Type ℓ) (φ : (a : A) → P (f a)) → Type ℓ\n ExtensionOf {A = A} {B = B} f P φ = Σ (Π B P) (λ ψ → (a : A) → ψ (f a) == φ a)\n\n syntax ExtensionOf f P φ = ⟨ P ⟩⟨ φ ↗ f ⟩\n\n path-extension : ∀ {ℓ} {A B : Type ℓ} {f : A → B}\n {P : B → Type ℓ} {φ : (a : A) → P (f a)}\n (e₀ e₁ : ⟨ P ⟩⟨ φ ↗ f ⟩) →\n ⟨ (λ b → fst e₀ b == fst e₁ b) ⟩⟨ (λ a → snd e₀ a ∙ ! (snd e₁ a)) ↗ f ⟩ ≃ (e₀ == e₁)\n path-extension {f = f} (ψ₀ , ε₀) (ψ₁ , ε₁) = equiv to {!!} {!!} {!!} \n\n where to : ExtensionOf f (λ b → ψ₀ b == ψ₁ b) (λ a → ε₀ a ∙ ! (ε₁ a)) → (ψ₀ , ε₀) == (ψ₁ , ε₁)\n to (α , β) = pair= (λ= α) {!!}\n\n from : (ψ₀ , ε₀) == (ψ₁ , ε₁) → ExtensionOf f (λ b → ψ₀ b == ψ₁ b) (λ a → ε₀ a ∙ ! (ε₁ a))\n from p = {!!}\n \n -- from : (e₀ == e₁) → ⟨ (λ b → fst e₀ b == fst e₁ b) ⟩⟨ (λ a → snd e₀ a ∙ ! (snd e₁ a)) ↗ f ⟩\n -- from = {!!}\n \n -- Definition equiv_path_extension `{Funext} {A B : Type} {f : A -> B}\n -- {P : B -> Type} {d : forall x:A, P (f x)}\n -- (ext ext' : ExtensionAlong f P d)\n -- : (ExtensionAlong f\n -- (fun y => pr1 ext y = pr1 ext' y)\n -- (fun x => pr2 ext x @ (pr2 ext' x)^))\n -- <~> ext = ext'.\n \n", "meta": {"hexsha": "4448d1c96c7342ba91e56169d5a9b6410a3ecc93", "size": 1431, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/stash/modalities/Extensions.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/Extensions.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/Extensions.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": 40.8857142857, "max_line_length": 104, "alphanum_fraction": 0.3787561146, "num_tokens": 603, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382200964034, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.5995947074766274}} {"text": "{-# OPTIONS --without-K #-}\nmodule hott.level.closure.lift where\n\nopen import level\nopen import function.isomorphism.lift\nopen import hott.level.core\nopen import hott.level.closure.core\n\n-- lifting preserves h-levels\n↑-level : ∀ {i n} j {X : Set i}\n → h n X\n → h n (↑ j X)\n↑-level j {X} = iso-level (lift-iso j X)\n", "meta": {"hexsha": "2711bfdf52d86df49ae0db72837570581b746dfa", "size": 328, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "hott/level/closure/lift.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/hott/level/closure/lift.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/hott/level/closure/lift.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": 23.4285714286, "max_line_length": 40, "alphanum_fraction": 0.6524390244, "num_tokens": 95, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110540642805, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.599592841325908}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import Base\n\n{-\n This file contains the lemma that\n a point (1 -> A) has n-connected fibers\n if A is (S n)-connected.\n\n The other direction will be added whenever\n it is needed.\n-}\n\nmodule Homotopy.PointConnected {i} (A : Set i) (a : A) where\n\n open import Homotopy.Connected\n open import Homotopy.Truncation\n open import Homotopy.PathTruncation\n\n point : unit {i} → A\n point _ = a\n\n abstract\n point-has-connected-fibers : ∀ {n} →\n is-connected (S n) A → has-connected-fibers n point\n point-has-connected-fibers {n} A-is-conn a₂ = center [a≡a₂]n , path\n where\n [a≡a₂]n : τ n (a ≡ a₂)\n [a≡a₂]n = connected-has-all-τ-paths A-is-conn a a₂\n\n center : τ n (a ≡ a₂) → τ n (hfiber point a₂)\n center = τ-extend-nondep ⦃ τ-is-truncated n _ ⦄\n (λ shift → proj $ tt , shift)\n\n path′ : ∀ f → proj f ≡ center [a≡a₂]n\n path′ (tt , a≡a₂) = ap center $ contr-has-all-paths\n (connected-has-connected-paths A-is-conn a a₂) (proj a≡a₂) [a≡a₂]n\n\n path : ∀ f → f ≡ center [a≡a₂]n\n path = τ-extend ⦃ λ _ → ≡-is-truncated n $ τ-is-truncated n _ ⦄ path′\n", "meta": {"hexsha": "31ae06f50dcc946b15b2fb26c2a3b410e52c30d7", "size": 1175, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Homotopy/PointConnected.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/Homotopy/PointConnected.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/Homotopy/PointConnected.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": 28.6585365854, "max_line_length": 77, "alphanum_fraction": 0.589787234, "num_tokens": 417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110396870288, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.5995928316596257}} {"text": "open import Data.Graph\n\nmodule Data.Graph.Path.Search {ℓᵥ ℓₑ} (g : FiniteGraph ℓᵥ ℓₑ) where\n\nopen import Data.Graph.Path.Cut g\nopen import Data.Graph.Path.Finite g\nopen import Data.Product as Σ\nopen import Data.Sum as ⊎\nopen import Data.Vec as Vec\nopen import Finite\nopen import Function\nopen import Level\nopen import Relation.Binary\nopen import Relation.Binary.Construct.Closure.ReflexiveTransitive\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary hiding (module Dec)\nopen import Relation.Nullary.Decidable as Dec\nopen import Relation.Nullary.Negation as ¬\n\nopen FiniteGraph g\nopen IsFinite\n\npathSearchFrom : ∀ {ℓ} {P : Vertex → Set ℓ} →\n (∀ b → Dec (P b)) → ∀ a → Dec (∃ λ b → P b × ∃ (Path a b))\npathSearchFrom P? a =\n case ∃? (Path≤-finite (size vertexFinite) a) (P? ∘ proj₁) of λ where\n (yes ((_ , _ , _ , p) , pb)) → yes (-, pb , (-, p))\n (no ¬p) → no λ where (_ , pb , _ , p) → ¬p ((-, shortEnoughPath p) , pb)\n\npathSearchAcyclicFrom : ∀ {ℓ} {P : Vertex → Set ℓ} →\n (∀ b → Dec (P b)) → ∀ a →\n Dec (∃ λ b → P b × ∃₂ λ n (p : Path a b n) → Acyclic p)\npathSearchAcyclicFrom P? a =\n case ∃? (Path≤-finite (size vertexFinite) a) (P? ∘ proj₁) of λ where\n (yes ((_ , _ , _ , p) , pb)) →\n let (x , x≤n , p′) , ¬r′ = acyclicPath p in\n yes (-, pb , (-, (p′ , ¬r′)))\n (no ¬p) → no λ where (_ , pb , _ , p , r) → ¬p ((-, shortEnoughPath p) , pb)\n\npathSearchBetween : ∀ a b → Dec (∃ (Path a b))\npathSearchBetween a b =\n case pathSearchFrom (decEqVertex b) a of λ where\n (yes (_ , refl , p)) → yes p\n (no ¬p) → no λ where (n , p) → ¬p (-, refl , -, p)\n\nsearchFrom : ∀ {ℓ} {P : Vertex → Set ℓ} →\n (∀ b → Dec (P b)) →\n ∀ a → Dec (∃ λ b → P b × Star Edge a b)\nsearchFrom P? a =\n Dec.map′\n (Σ.map₂ (Σ.map₂ (toStar ∘ proj₂)))\n (Σ.map₂ (Σ.map₂ (-,_ ∘ fromStar)))\n (pathSearchFrom P? a)\n\nsearchBetween : ∀ a b → Dec (Star Edge a b)\nsearchBetween a b = Dec.map′ (toStar ∘ proj₂) (-,_ ∘ fromStar) (pathSearchBetween a b)\n\nmodule _\n {ℓ ℓ≈ ℓ<}\n {P : Vertex → Set ℓ} (P? : ∀ a → Dec (P a))\n {_≈_ : ∀ {a} → Rel (∃ (Star Edge a)) ℓ≈}\n {_<_ : ∀ {a} → Rel (∃ (Star Edge a)) ℓ<}\n (<-po : ∀ {a} → IsDecStrictPartialOrder (_≈_ {a}) _<_)\n where\n\n record MaximalPath a : Set (ℓ ⊔ ℓᵥ ⊔ ℓₑ ⊔ ℓ<) where\n field\n destination : Vertex\n predicate : P destination\n path : Star Edge a destination\n acyclic : Acyclic (fromStar path)\n isMax : ∀\n {b} (p : Star Edge a b) (pb : P b) → Acyclic (fromStar p) →\n ¬ ((-, path) < (-, p))\n\n searchMaximalFrom : ∀ a → Dec (MaximalPath a)\n searchMaximalFrom a =\n case max of λ where\n (inj₁ ¬p) →\n no λ mp →\n let open MaximalPath mp in\n ¬p ((-, path , fromWitness acyclic) , fromWitness predicate)\n\n (inj₂ (((b , p , acp) , pb) , isMax)) →\n yes record\n { destination = b\n ; predicate = toWitness pb\n ; path = p\n ; acyclic = toWitness acp\n ; isMax = λ q pb acq → isMax ((-, q , fromWitness acq) , fromWitness pb)\n }\n where\n module DPO = IsDecStrictPartialOrder <-po\n\n _≈′_ = _≈_ on λ where ((b , p , acp) , pb) → b , p\n _<′_ = _<_ on λ where ((b , p , acp) , pb) → b , p\n\n <′-IsDecStrictPartialOrder : IsDecStrictPartialOrder _≈′_ _<′_\n <′-IsDecStrictPartialOrder = record\n { isStrictPartialOrder = record\n { isEquivalence = record\n { refl = IsEquivalence.refl DPO.isEquivalence\n ; sym = IsEquivalence.sym DPO.isEquivalence\n ; trans = IsEquivalence.trans DPO.isEquivalence\n }\n ; irrefl = DPO.irrefl\n ; trans = DPO.trans\n ; <-resp-≈ = proj₁ DPO.<-resp-≈ , proj₂ DPO.<-resp-≈\n }\n ; _≟_ = λ _ _ → _ DPO.≟ _\n ; _-}\ncoh : {A : Type i} {a : A} →\n Coh ({b : A} (p : a == b)\n {d : A} {s : d == b}\n {c : A} {r : b == c}\n {f : A} {u : f == c}\n {e : A} {t : e == c}\n {w : f == e} (ν : Square w idp t u)\n {v : d == e} (α : Square v s t r)\n {vw : d == f} (vw= : vw == v ∙ ! w)\n → Square (p ∙ ! s) p vw (r ∙ ! u))\ncoh = path-induction\n{--}\n", "meta": {"hexsha": "1e1d60e8f2af70b0b80f70ae0909908f74476641", "size": 589, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ExPathInduction.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": "ExPathInduction.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": "ExPathInduction.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": 29.45, "max_line_length": 86, "alphanum_fraction": 0.3820033956, "num_tokens": 221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9252299570920386, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.5993623174001301}} {"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nmodule HoTT-UF-Agda where\n\nopen import Universes public\n\nvariable\n 𝓤 𝓥 𝓦 𝓣 : Universe\n\ndata 𝟙 : 𝓤₀ ̇ where\n ⋆ : 𝟙\n\n𝟙-induction : (A : 𝟙 → 𝓤 ̇ ) → A ⋆ → (x : 𝟙) → A x\n𝟙-induction A a ⋆ = a\n\n𝟙-recursion : (B : 𝓤 ̇ ) → B → (𝟙 → B)\n𝟙-recursion B b x = 𝟙-induction (λ _ → B) b x\n\n!𝟙' : (X : 𝓤 ̇ ) → X → 𝟙\n!𝟙' X x = ⋆\n\n!𝟙 : {X : 𝓤 ̇ } → X → 𝟙\n!𝟙 x = ⋆\n\ndata 𝟘 : 𝓤₀ ̇ where\n\n𝟘-induction : (A : 𝟘 → 𝓤 ̇ ) → (x : 𝟘) → A x\n𝟘-induction A ()\n\n𝟘-recursion : (A : 𝓤 ̇ ) → 𝟘 → A\n𝟘-recursion A a = 𝟘-induction (λ _ → A) a\n\n!𝟘 : (A : 𝓤 ̇ ) → 𝟘 → A\n!𝟘 = 𝟘-recursion\n\nis-empty : 𝓤 ̇ → 𝓤 ̇\nis-empty X = X → 𝟘\n\n¬ : 𝓤 ̇ → 𝓤 ̇\n¬ X = X → 𝟘\n\ndata ℕ : 𝓤₀ ̇ where\n zero : ℕ\n succ : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n\nℕ-induction : (A : ℕ → 𝓤 ̇ )\n → A 0\n → ((n : ℕ) → A n → A (succ n))\n → (n : ℕ) → A n\n\nℕ-induction A a₀ f = h\n where\n h : (n : ℕ) → A n\n h 0 = a₀\n h (succ n) = f n (h n)\n\nℕ-recursion : (X : 𝓤 ̇ )\n → X\n → (ℕ → X → X)\n → ℕ → X\n\nℕ-recursion X = ℕ-induction (λ _ → X)\n\nℕ-iteration : (X : 𝓤 ̇ )\n → X\n → (X → X)\n → ℕ → X\n\nℕ-iteration X x f = ℕ-recursion X x (λ _ x → f x)\n\nmodule Arithmetic where\n\n _+_ _×_ : ℕ → ℕ → ℕ\n\n x + 0 = x\n x + succ y = succ (x + y)\n\n x × 0 = 0\n x × succ y = x + x × y\n\n infixl 20 _+_\n infixl 21 _×_\n\nmodule Arithmetic' where\n\n _+_ _×_ : ℕ → ℕ → ℕ\n\n x + y = h y\n where\n h : ℕ → ℕ\n h = ℕ-iteration ℕ x succ\n\n x × y = h y\n where\n h : ℕ → ℕ\n h = ℕ-iteration ℕ 0 (x +_)\n\n infixl 20 _+_\n infixl 21 _×_\n\nmodule ℕ-order where\n\n _≤_ _≥_ : ℕ → ℕ → 𝓤₀ ̇\n 0 ≤ y = 𝟙\n succ x ≤ 0 = 𝟘\n succ x ≤ succ y = x ≤ y\n\n x ≥ y = y ≤ x\n\n infix 10 _≤_\n infix 10 _≥_\n\ndata _+_ {𝓤 𝓥} (X : 𝓤 ̇ ) (Y : 𝓥 ̇ ) : 𝓤 ⊔ 𝓥 ̇ where\n inl : X → X + Y\n inr : Y → X + Y\n\n+-induction : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (A : X + Y → 𝓦 ̇ )\n → ((x : X) → A (inl x))\n → ((y : Y) → A (inr y))\n → (z : X + Y) → A z\n\n+-induction A f g (inl x) = f x\n+-induction A f g (inr y) = g y\n\n+-recursion : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {A : 𝓦 ̇ } → (X → A) → (Y → A) → X + Y → A\n+-recursion {𝓤} {𝓥} {𝓦} {X} {Y} {A} = +-induction (λ _ → A)\n\n𝟚 : 𝓤₀ ̇\n𝟚 = 𝟙 + 𝟙\n\npattern ₀ = inl ⋆\npattern ₁ = inr ⋆\n\n𝟚-induction : (A : 𝟚 → 𝓤 ̇ ) → A ₀ → A ₁ → (n : 𝟚) → A n\n𝟚-induction A a₀ a₁ ₀ = a₀\n𝟚-induction A a₀ a₁ ₁ = a₁\n\n𝟚-induction' : (A : 𝟚 → 𝓤 ̇ ) → A ₀ → A ₁ → (n : 𝟚) → A n\n𝟚-induction' A a₀ a₁ = +-induction A\n (𝟙-induction (λ (x : 𝟙) → A (inl x)) a₀)\n (𝟙-induction (λ (y : 𝟙) → A (inr y)) a₁)\n\nrecord Σ {𝓤 𝓥} {X : 𝓤 ̇ } (Y : X → 𝓥 ̇ ) : 𝓤 ⊔ 𝓥 ̇ where\n constructor\n _,_\n field\n x : X\n y : Y x\n\npr₁ : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } → Σ Y → X\npr₁ (x , y) = x\n\npr₂ : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } → (z : Σ Y) → Y (pr₁ z)\npr₂ (x , y) = y\n\n-Σ : {𝓤 𝓥 : Universe} (X : 𝓤 ̇ ) (Y : X → 𝓥 ̇ ) → 𝓤 ⊔ 𝓥 ̇\n-Σ X Y = Σ Y\n\nsyntax -Σ X (λ x → y) = Σ x ꞉ X , y\n\nΣ-induction : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } {A : Σ Y → 𝓦 ̇ }\n → ((x : X) (y : Y x) → A (x , y))\n → ((x , y) : Σ Y) → A (x , y)\n\nΣ-induction g (x , y) = g x y\n\ncurry : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } {A : Σ Y → 𝓦 ̇ }\n → (((x , y) : Σ Y) → A (x , y))\n → ((x : X) (y : Y x) → A (x , y))\n\ncurry f x y = f (x , y)\n\n_×_ : 𝓤 ̇ → 𝓥 ̇ → 𝓤 ⊔ 𝓥 ̇\nX × Y = Σ x ꞉ X , Y\n\nΠ : {X : 𝓤 ̇ } (A : X → 𝓥 ̇ ) → 𝓤 ⊔ 𝓥 ̇\nΠ {𝓤} {𝓥} {X} A = (x : X) → A x\n\n-Π : {𝓤 𝓥 : Universe} (X : 𝓤 ̇ ) (Y : X → 𝓥 ̇ ) → 𝓤 ⊔ 𝓥 ̇\n-Π X Y = Π Y\n\nsyntax -Π A (λ x → b) = Π x ꞉ A , b\n\nid : {X : 𝓤 ̇ } → X → X\nid x = x\n\n𝑖𝑑 : (X : 𝓤 ̇ ) → X → X\n𝑖𝑑 X = id\n\n_∘_ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {Z : Y → 𝓦 ̇ }\n → ((y : Y) → Z y)\n → (f : X → Y)\n → (x : X) → Z (f x)\n\ng ∘ f = λ x → g (f x)\n\ndomain : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } → (X → Y) → 𝓤 ̇\ndomain {𝓤} {𝓥} {X} {Y} f = X\n\ncodomain : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } → (X → Y) → 𝓥 ̇\ncodomain {𝓤} {𝓥} {X} {Y} f = Y\n\ntype-of : {X : 𝓤 ̇ } → X → 𝓤 ̇\ntype-of {𝓤} {X} x = X\n\ndata Id {𝓤} (X : 𝓤 ̇ ) : X → X → 𝓤 ̇ where\n refl : (x : X) → Id X x x\n\n_≡_ : {X : 𝓤 ̇ } → X → X → 𝓤 ̇\nx ≡ y = Id _ x y\n\n𝕁 : (X : 𝓤 ̇ ) (A : (x y : X) → x ≡ y → 𝓥 ̇ )\n → ((x : X) → A x x (refl x))\n → (x y : X) (p : x ≡ y) → A x y p\n𝕁 X A f x x (refl x) = f x\n\nℍ : {X : 𝓤 ̇ } (x : X) (B : (y : X) → x ≡ y → 𝓥 ̇ )\n → B x (refl x)\n → (y : X) (p : x ≡ y) → B y p\nℍ x B b x (refl x) = b\n\n𝕁' : (X : 𝓤 ̇ ) (A : (x y : X) → x ≡ y → 𝓥 ̇ )\n → ((x : X) → A x x (refl x))\n → (x y : X) (p : x ≡ y) → A x y p\n𝕁' X A f x = ℍ x (A x) (f x)\n\n𝕁s-agreement : (X : 𝓤 ̇ ) (A : (x y : X) → x ≡ y → 𝓥 ̇ )\n (f : (x : X) → A x x (refl x)) (x y : X) (p : x ≡ y)\n → 𝕁 X A f x y p ≡ 𝕁' X A f x y p\n𝕁s-agreement X A f x x (refl x) = refl (f x)\n\ntransport : {X : 𝓤 ̇ } (A : X → 𝓥 ̇ ) {x y : X}\n → x ≡ y → A x → A y\ntransport A (refl x) = 𝑖𝑑 (A x)\n\ntransport𝕁 : {X : 𝓤 ̇ } (A : X → 𝓥 ̇ ) {x y : X}\n → x ≡ y → A x → A y\ntransport𝕁 {𝓤} {𝓥} {X} A {x} {y} = 𝕁 X (λ x y _ → A x → A y) (λ x → 𝑖𝑑 (A x)) x y\n\nnondep-ℍ : {X : 𝓤 ̇ } (x : X) (A : X → 𝓥 ̇ )\n → A x → (y : X) → x ≡ y → A y\nnondep-ℍ x A = ℍ x (λ y _ → A y)\n\ntransportℍ : {X : 𝓤 ̇ } (A : X → 𝓥 ̇ ) {x y : X}\n → x ≡ y → A x → A y\ntransportℍ A {x} {y} p a = nondep-ℍ x A a y p\n\ntransports-agreement : {X : 𝓤 ̇ } (A : X → 𝓥 ̇ ) {x y : X} (p : x ≡ y)\n → (transportℍ A p ≡ transport A p)\n × (transport𝕁 A p ≡ transport A p)\ntransports-agreement A (refl x) = refl (transport A (refl x)) ,\n refl (transport A (refl x))\n\nlhs : {X : 𝓤 ̇ } {x y : X} → x ≡ y → X\nlhs {𝓤} {X} {x} {y} p = x\n\nrhs : {X : 𝓤 ̇ } {x y : X} → x ≡ y → X\nrhs {𝓤} {X} {x} {y} p = y\n\n_∙_ : {X : 𝓤 ̇ } {x y z : X} → x ≡ y → y ≡ z → x ≡ z\np ∙ q = transport (lhs p ≡_) q p\n\n_≡⟨_⟩_ : {X : 𝓤 ̇ } (x : X) {y z : X} → x ≡ y → y ≡ z → x ≡ z\nx ≡⟨ p ⟩ q = p ∙ q\n\n_∎ : {X : 𝓤 ̇ } (x : X) → x ≡ x\nx ∎ = refl x\n\n_⁻¹ : {X : 𝓤 ̇ } → {x y : X} → x ≡ y → y ≡ x\np ⁻¹ = transport (_≡ lhs p) p (refl (lhs p))\n\n_∙'_ : {X : 𝓤 ̇ } {x y z : X} → x ≡ y → y ≡ z → x ≡ z\np ∙' q = transport (_≡ rhs q) (p ⁻¹) q\n\n∙agreement : {X : 𝓤 ̇ } {x y z : X} (p : x ≡ y) (q : y ≡ z)\n → (p ∙' q) ≡ (p ∙ q)\n∙agreement (refl x) (refl x) = refl (refl x)\n\nrdnel : {X : 𝓤 ̇ } {x y : X} (p : x ≡ y)\n → (p ∙ refl y) ≡ p\n\nrdnel p = refl p\n\nrdner : {X : 𝓤 ̇ } {y z : X} (q : y ≡ z)\n → (refl y ∙' q) ≡ q\n\nrdner q = refl q\n\nap : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (f : X → Y) {x x' : X} → x ≡ x' → f x ≡ f x'\nap f {x} {x'} p = transport (λ - → f x ≡ f -) p (refl (f x))\n\n_∼_ : {X : 𝓤 ̇ } {A : X → 𝓥 ̇ } → Π A → Π A → 𝓤 ⊔ 𝓥 ̇\nf ∼ g = ∀ x → f x ≡ g x\n\n¬¬ ¬¬¬ : 𝓤 ̇ → 𝓤 ̇\n¬¬ A = ¬(¬ A)\n¬¬¬ A = ¬(¬¬ A)\n\ndni : (A : 𝓤 ̇ ) → A → ¬¬ A\ndni A a u = u a\n\ncontrapositive : {A : 𝓤 ̇ } {B : 𝓥 ̇ } → (A → B) → (¬ B → ¬ A)\ncontrapositive f v a = v (f a)\n\ntno : (A : 𝓤 ̇ ) → ¬¬¬ A → ¬ A\ntno A = contrapositive (dni A)\n\n_⇔_ : 𝓤 ̇ → 𝓥 ̇ → 𝓤 ⊔ 𝓥 ̇\nX ⇔ Y = (X → Y) × (Y → X)\n\nlr-implication : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } → (X ⇔ Y) → (X → Y)\nlr-implication = pr₁\n\nrl-implication : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } → (X ⇔ Y) → (Y → X)\nrl-implication = pr₂\n\nabsurdity³-is-absurdity : {A : 𝓤 ̇ } → ¬¬¬ A ⇔ ¬ A\nabsurdity³-is-absurdity {𝓤} {A} = firstly , secondly\n where\n firstly : ¬¬¬ A → ¬ A\n firstly = contrapositive (dni A)\n\n secondly : ¬ A → ¬¬¬ A\n secondly = dni (¬ A)\n\n_≢_ : {X : 𝓤 ̇ } → X → X → 𝓤 ̇\nx ≢ y = ¬(x ≡ y)\n\n≢-sym : {X : 𝓤 ̇ } {x y : X} → x ≢ y → y ≢ x\n≢-sym {𝓤} {X} {x} {y} u = λ (p : y ≡ x) → u (p ⁻¹)\n\nId→Fun : {X Y : 𝓤 ̇ } → X ≡ Y → X → Y\nId→Fun {𝓤} = transport (𝑖𝑑 (𝓤 ̇ ))\n\nId→Fun' : {X Y : 𝓤 ̇ } → X ≡ Y → X → Y\nId→Fun' (refl X) = 𝑖𝑑 X\n\nId→Funs-agree : {X Y : 𝓤 ̇ } (p : X ≡ Y)\n → Id→Fun p ≡ Id→Fun' p\n\nId→Funs-agree (refl X) = refl (𝑖𝑑 X)\n\n𝟙-is-not-𝟘 : 𝟙 ≢ 𝟘\n𝟙-is-not-𝟘 p = Id→Fun p ⋆\n\n₁-is-not-₀ : ₁ ≢ ₀\n₁-is-not-₀ p = 𝟙-is-not-𝟘 q\n where\n f : 𝟚 → 𝓤₀ ̇\n f ₀ = 𝟘\n f ₁ = 𝟙\n\n q : 𝟙 ≡ 𝟘\n q = ap f p\n\n₁-is-not-₀[not-an-MLTT-proof] : ¬(₁ ≡ ₀)\n₁-is-not-₀[not-an-MLTT-proof] ()\n\ndecidable : 𝓤 ̇ → 𝓤 ̇\ndecidable A = A + ¬ A\n\nhas-decidable-equality : 𝓤 ̇ → 𝓤 ̇\nhas-decidable-equality X = (x y : X) → decidable (x ≡ y)\n\n𝟚-has-decidable-equality : has-decidable-equality 𝟚\n𝟚-has-decidable-equality ₀ ₀ = inl (refl ₀)\n𝟚-has-decidable-equality ₀ ₁ = inr (≢-sym ₁-is-not-₀)\n𝟚-has-decidable-equality ₁ ₀ = inr ₁-is-not-₀\n𝟚-has-decidable-equality ₁ ₁ = inl (refl ₁)\n\nnot-zero-is-one : (n : 𝟚) → n ≢ ₀ → n ≡ ₁\nnot-zero-is-one ₀ f = !𝟘 (₀ ≡ ₁) (f (refl ₀))\nnot-zero-is-one ₁ f = refl ₁\n\ninl-inr-disjoint-images : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {x : X} {y : Y} → inl x ≢ inr y\ninl-inr-disjoint-images {𝓤} {𝓥} {X} {Y} p = 𝟙-is-not-𝟘 q\n where\n f : X + Y → 𝓤₀ ̇\n f (inl x) = 𝟙\n f (inr y) = 𝟘\n\n q : 𝟙 ≡ 𝟘\n q = ap f p\n\nright-fails-gives-left-holds : {P : 𝓤 ̇ } {Q : 𝓥 ̇ } → P + Q → ¬ Q → P\nright-fails-gives-left-holds (inl p) u = p\nright-fails-gives-left-holds (inr q) u = !𝟘 _ (u q)\n\nmodule twin-primes where\n\n open Arithmetic renaming (_×_ to _*_ ; _+_ to _∔_)\n open ℕ-order\n\n is-prime : ℕ → 𝓤₀ ̇\n is-prime n = (n ≥ 2) × ((x y : ℕ) → x * y ≡ n → (x ≡ 1) + (x ≡ n))\n\n twin-prime-conjecture : 𝓤₀ ̇\n twin-prime-conjecture =\n (n : ℕ) → -Σ ℕ (λ p → ((p ≥ n) × is-prime p) × is-prime (p ∔ 2))\n\npositive-not-zero : (x : ℕ) → succ x ≢ 0\npositive-not-zero x p = 𝟙-is-not-𝟘 q where\n f : ℕ → 𝓤₀ ̇\n f zero = 𝟘\n f (succ n) = 𝟙\n\n q : 𝟙 ≡ 𝟘\n q = ap f p\n\npred : ℕ → ℕ\npred 0 = 0\npred (succ n) = n\n\nsucc-lc : {x y : ℕ} → succ x ≡ succ y → x ≡ y\nsucc-lc = ap pred\n\nℕ-has-decidable-equality : has-decidable-equality ℕ\nℕ-has-decidable-equality 0 0 = inl (refl 0)\nℕ-has-decidable-equality 0 (succ y) = inr (≢-sym (positive-not-zero y))\nℕ-has-decidable-equality (succ x) 0 = inr (positive-not-zero x)\nℕ-has-decidable-equality (succ x) (succ y) = f (ℕ-has-decidable-equality x y)\n where\n f : decidable (x ≡ y) → decidable (succ x ≡ succ y)\n f (inl p) = inl (ap succ p)\n f (inr k) = inr (λ (s : succ x ≡ succ y) → k (succ-lc s))\n\n\n\nmodule basic-arithmetic-and-order where\n\n open ℕ-order public\n open Arithmetic renaming (_+_ to _∔_) hiding (_×_)\n\n +-assoc : (x y z : ℕ) → ((x ∔ y) ∔ z) ≡ (x ∔ (y ∔ z))\n +-assoc x y zero = ((x ∔ y) ∔ 0) ≡⟨ (refl _) ⟩\n (x ∔ (y ∔ 0)) ∎\n\n +-assoc x y (succ z) = ((x ∔ y) ∔ succ z) ≡⟨ (refl _) ⟩\n (succ ((x ∔ y) ∔ z)) ≡⟨ ap succ IH ⟩\n (succ (x ∔ (y ∔ z))) ≡⟨ refl _ ⟩\n (x ∔ (y ∔ succ z)) ∎\n where\n IH : ((x ∔ y) ∔ z) ≡ (x ∔ (y ∔ z))\n IH = +-assoc x y z\n\n +-base-on-first : (x : ℕ) → 0 ∔ x ≡ x\n +-base-on-first 0 = refl 0\n +-base-on-first (succ x) = 0 ∔ succ x ≡⟨ refl _ ⟩\n succ (0 ∔ x) ≡⟨ ap succ IH ⟩\n succ x ∎\n where\n IH : 0 ∔ x ≡ x\n IH = +-base-on-first x\n\n\n +-step-on-first : (x y : ℕ) → succ x ∔ y ≡ succ (x ∔ y)\n +-step-on-first x zero = refl (succ x)\n +-step-on-first x (succ y) = succ x ∔ succ y ≡⟨ refl _ ⟩\n succ (succ x ∔ y) ≡⟨ ap succ IH ⟩\n succ (x ∔ succ y) ∎\n where\n IH : succ x ∔ y ≡ succ (x ∔ y)\n IH = +-step-on-first x y\n\n +-comm : (x y : ℕ) → x ∔ y ≡ y ∔ x\n +-comm 0 y = 0 ∔ y ≡⟨ +-base-on-first y ⟩\n y ≡⟨ refl _ ⟩\n y ∔ 0 ∎\n +-comm (succ x) y = succ x ∔ y ≡⟨ +-step-on-first x y ⟩\n succ(x ∔ y) ≡⟨ ap succ IH ⟩\n succ(y ∔ x) ≡⟨ refl _ ⟩\n y ∔ succ x ∎\n where\n IH : x ∔ y ≡ y ∔ x\n IH = +-comm x y\n\n +-lc : (x y z : ℕ) → x ∔ y ≡ x ∔ z → y ≡ z\n +-lc 0 y z p = y ≡⟨ (+-base-on-first y)⁻¹ ⟩\n 0 ∔ y ≡⟨ p ⟩\n 0 ∔ z ≡⟨ +-base-on-first z ⟩\n z ∎\n +-lc (succ x) y z p = IH\n where\n q = succ (x ∔ y) ≡⟨ (+-step-on-first x y)⁻¹ ⟩\n succ x ∔ y ≡⟨ p ⟩\n succ x ∔ z ≡⟨ +-step-on-first x z ⟩\n succ (x ∔ z) ∎\n \n IH : y ≡ z\n IH = +-lc x y z (succ-lc q)\n\n _≼_ : ℕ → ℕ → 𝓤₀ ̇\n x ≼ y = Σ z ꞉ ℕ , x ∔ z ≡ y\n\n ≤-gives-≼ : (x y : ℕ) → x ≤ y → x ≼ y\n ≤-gives-≼ 0 0 l = 0 , refl 0\n ≤-gives-≼ 0 (succ y) l = succ y , +-base-on-first (succ y)\n ≤-gives-≼ (succ x) 0 l = !𝟘 (succ x ≼ zero) l\n ≤-gives-≼ (succ x) (succ y) l = γ\n where\n IH : x ≼ y\n IH = ≤-gives-≼ x y l\n\n z : ℕ\n z = pr₁ IH\n\n p : x ∔ z ≡ y\n p = pr₂ IH\n\n γ : succ x ≼ succ y\n γ = z , (succ x ∔ z ≡⟨ +-step-on-first x z ⟩\n succ (x ∔ z) ≡⟨ ap succ p ⟩\n succ y ∎)\n\n\n ≼-gives-≤ : (x y : ℕ) → x ≼ y → x ≤ y\n ≼-gives-≤ 0 0 (z , p) = ⋆\n ≼-gives-≤ 0 (succ y) (z , p) = ⋆\n ≼-gives-≤ (succ x) 0 (z , p) = positive-not-zero (x ∔ z) q\n where\n q = succ (x ∔ z) ≡⟨ (+-step-on-first x z)⁻¹ ⟩\n succ x ∔ z ≡⟨ p ⟩\n zero ∎\n ≼-gives-≤ (succ x) (succ y) (z , p) = IH\n where\n q = succ (x ∔ z) ≡⟨ (+-step-on-first x z)⁻¹ ⟩\n succ x ∔ z ≡⟨ p ⟩\n succ y ∎\n\n IH : x ≤ y\n IH = ≼-gives-≤ x y (z , succ-lc q)\n\n ≤-refl : (n : ℕ) → n ≤ n\n ≤-refl zero = ⋆\n ≤-refl (succ n) = ≤-refl n\n\n ≤-trans : (l m n : ℕ) → l ≤ m → m ≤ n → l ≤ n\n ≤-trans zero m n p q = ⋆\n ≤-trans (succ l) zero n p q = !𝟘 (succ l ≤ n) p\n ≤-trans (succ l) (succ m) zero p q = q\n ≤-trans (succ l) (succ m) (succ n) p q = ≤-trans l m n p q\n\n ≤-anti : (m n : ℕ) → m ≤ n → n ≤ m → m ≡ n\n ≤-anti zero zero p q = refl zero\n ≤-anti zero (succ n) p q = !𝟘 (zero ≡ succ n) q\n ≤-anti (succ m) zero p q = !𝟘 (succ m ≡ zero) p\n ≤-anti (succ m) (succ n) p q = ap succ (≤-anti m n p q)\n\n ≤-succ : (n : ℕ) → n ≤ succ n\n ≤-succ zero = ⋆\n ≤-succ (succ n) = ≤-succ n\n\n zero-minimal : (n : ℕ) → zero ≤ n\n zero-minimal n = ⋆\n\n unique-minimal : (n : ℕ) → n ≤ zero → n ≡ zero\n unique-minimal zero p = refl zero\n unique-minimal (succ n) p = !𝟘 (succ n ≡ zero) p\n\n ≤-split : (m n : ℕ) → m ≤ succ n → (m ≤ n) + (m ≡ succ n)\n ≤-split zero n l = inl l\n ≤-split (succ m) zero l = inr (ap succ (unique-minimal m l))\n ≤-split (succ m) (succ n) l = +-recursion inl (inr ∘ ap succ) (≤-split m n l)\n\n _<_ : ℕ → ℕ → 𝓤₀ ̇\n x < y = succ x ≤ y\n\n infix 10 _<_\n\n not-<-gives-≥ : (m n : ℕ) → ¬(n < m) → m ≤ n\n not-<-gives-≥ zero n u = zero-minimal n\n not-<-gives-≥ (succ m) zero u = dni (zero < succ m) (zero-minimal m) u\n not-<-gives-≥ (succ m) (succ n) u = not-<-gives-≥ m n u\n\n bounded-∀-next : (A : ℕ → 𝓤 ̇ ) (k : ℕ)\n → A k\n → ((n : ℕ) → n < k → A n)\n → (n : ℕ) → n < succ k → A n\n bounded-∀-next A k a φ n l = +-recursion f g s\n where\n s : (n < k) + (succ n ≡ succ k)\n s = ≤-split (succ n) k l\n\n f : n < k → A n\n f = φ n\n\n g : succ n ≡ succ k → A n\n g p = transport A ((succ-lc p)⁻¹) a\n\n root : (ℕ → ℕ) → 𝓤₀ ̇\n root f = Σ n ꞉ ℕ , f n ≡ 0\n\n _has-no-root<_ : (ℕ → ℕ) → ℕ → 𝓤₀ ̇\n f has-no-root< k = (n : ℕ) → n < k → f n ≢ 0\n\n is-minimal-root : (ℕ → ℕ) → ℕ → 𝓤₀ ̇\n is-minimal-root f m = (f m ≡ 0) × (f has-no-root< m)\n\n\n at-most-one-minimal-root : (f : ℕ → ℕ) (m n : ℕ)\n → is-minimal-root f m → is-minimal-root f n → m ≡ n\n\n at-most-one-minimal-root f m n (p , φ) (q , ψ) = c m n a b\n where\n a : ¬(m < n)\n a u = ψ m u p\n\n b : ¬(n < m)\n b v = φ n v q\n\n c : (m n : ℕ) → ¬(m < n) → ¬(n < m) → m ≡ n\n c m n u v = ≤-anti m n (not-<-gives-≥ m n v) (not-<-gives-≥ n m u)\n\n minimal-root : (ℕ → ℕ) → 𝓤₀ ̇\n minimal-root f = Σ m ꞉ ℕ , is-minimal-root f m\n\n minimal-root-is-root : ∀ f → minimal-root f → root f\n minimal-root-is-root f (m , p , _) = m , p\n\n bounded-ℕ-search : ∀ k f → (minimal-root f) + (f has-no-root< k)\n bounded-ℕ-search zero f = inr (λ n → !𝟘 (f n ≢ 0))\n bounded-ℕ-search (succ k) f = +-recursion φ γ (bounded-ℕ-search k f)\n where\n A : ℕ → (ℕ → ℕ) → 𝓤₀ ̇\n A k f = (minimal-root f) + (f has-no-root< k)\n\n φ : minimal-root f → A (succ k) f\n φ = inl\n\n γ : f has-no-root< k → A (succ k) f\n γ u = +-recursion γ₀ γ₁ (ℕ-has-decidable-equality (f k) 0)\n where\n γ₀ : f k ≡ 0 → A (succ k) f\n γ₀ p = inl (k , p , u)\n\n γ₁ : f k ≢ 0 → A (succ k) f\n γ₁ v = inr (bounded-∀-next (λ n → f n ≢ 0) k v u)\n\n root-gives-minimal-root : ∀ f → root f → minimal-root f\n root-gives-minimal-root f (n , p) = γ\n where\n g : ¬(f has-no-root< (succ n))\n g φ = φ n (≤-refl n) p\n\n γ : minimal-root f\n γ = right-fails-gives-left-holds (bounded-ℕ-search (succ n) f) g\n\nis-singleton : 𝓤 ̇ → 𝓤 ̇\nis-singleton X = Σ c ꞉ X , ((x : X) → c ≡ x)\n\nis-center : (X : 𝓤 ̇ ) → X → 𝓤 ̇\nis-center X c = (x : X) → c ≡ x\n\n𝟙-is-singleton : is-singleton 𝟙\n𝟙-is-singleton = ⋆ , λ x → 𝟙-induction (λ y → ⋆ ≡ y) (refl ⋆) x\n\ncenter : (X : 𝓤 ̇ ) → is-singleton X → X\ncenter X (c , φ) = c\n\ncentrality : (X : 𝓤 ̇ ) (i : is-singleton X) (x : X) → center X i ≡ x\ncentrality X (c , φ) = φ\n\nis-subsingleton : 𝓤 ̇ → 𝓤 ̇\nis-subsingleton X = (x y : X) → x ≡ y\n\n𝟘-is-subsingleton : is-subsingleton 𝟘\n𝟘-is-subsingleton x y = !𝟘 (x ≡ y) x\n\nsingletons-are-subsingletons : (X : 𝓤 ̇ ) → is-singleton X → is-subsingleton X\nsingletons-are-subsingletons X (c , φ) x y = x ≡⟨ (φ x)⁻¹ ⟩\n c ≡⟨ φ y ⟩\n y ∎\n\n𝟙-is-subsingleton : is-subsingleton 𝟙\n𝟙-is-subsingleton = singletons-are-subsingletons 𝟙 𝟙-is-singleton\n\npointed-subsingletons-are-singletons : (X : 𝓤 ̇ )\n → X → is-subsingleton X → is-singleton X\n\npointed-subsingletons-are-singletons X x s = (x , s x)\n\n\nsingleton-iff-pointed-and-subsingleton : {X : 𝓤 ̇ }\n → is-singleton X ⇔ (X × is-subsingleton X)\n\nsingleton-iff-pointed-and-subsingleton {𝓤} {X} = (a , b)\n where\n a : is-singleton X → X × is-subsingleton X\n a s = center X s , singletons-are-subsingletons X s\n\n b : X × is-subsingleton X → is-singleton X\n b (x , t) = pointed-subsingletons-are-singletons X x t\n\nis-prop is-truth-value : 𝓤 ̇ → 𝓤 ̇\nis-prop = is-subsingleton\nis-truth-value = is-subsingleton\n\nis-set : 𝓤 ̇ → 𝓤 ̇\nis-set X = (x y : X) → is-subsingleton (x ≡ y)\n\nEM EM' : ∀ 𝓤 → 𝓤 ⁺ ̇\nEM 𝓤 = (X : 𝓤 ̇ ) → is-subsingleton X → X + ¬ X\nEM' 𝓤 = (X : 𝓤 ̇ ) → is-subsingleton X → is-singleton X + is-empty X\n\nEM-gives-EM' : EM 𝓤 → EM' 𝓤\nEM-gives-EM' em X s = γ (em X s)\n where\n γ : X + ¬ X → is-singleton X + is-empty X\n γ (inl x) = inl (pointed-subsingletons-are-singletons X x s)\n γ (inr x) = inr x\n\nEM'-gives-EM : EM' 𝓤 → EM 𝓤\nEM'-gives-EM em' X s = γ (em' X s)\n where\n γ : is-singleton X + is-empty X → X + ¬ X\n γ (inl i) = inl (center X i)\n γ (inr x) = inr x\n\nno-unicorns : ¬(Σ X ꞉ 𝓤 ̇ , is-subsingleton X × ¬(is-singleton X) × ¬(is-empty X))\nno-unicorns (X , i , f , g) = c\n where\n e : is-empty X\n e x = f (pointed-subsingletons-are-singletons X x i)\n\n c : 𝟘\n c = g e\n\nmodule magmas where\n\n Magma : (𝓤 : Universe) → 𝓤 ⁺ ̇\n Magma 𝓤 = Σ X ꞉ 𝓤 ̇ , is-set X × (X → X → X)\n\n ⟨_⟩ : Magma 𝓤 → 𝓤 ̇\n ⟨ X , i , _·_ ⟩ = X\n\n magma-is-set : (M : Magma 𝓤) → is-set ⟨ M ⟩\n magma-is-set (X , i , _·_) = i\n\n magma-operation : (M : Magma 𝓤) → ⟨ M ⟩ → ⟨ M ⟩ → ⟨ M ⟩\n magma-operation (X , i , _·_) = _·_\n\n syntax magma-operation M x y = x ·⟨ M ⟩ y\n\n is-magma-hom : (M N : Magma 𝓤) → (⟨ M ⟩ → ⟨ N ⟩) → 𝓤 ̇\n is-magma-hom M N f = (x y : ⟨ M ⟩) → f (x ·⟨ M ⟩ y) ≡ f x ·⟨ N ⟩ f y\n\n id-is-magma-hom : (M : Magma 𝓤) → is-magma-hom M M (𝑖𝑑 ⟨ M ⟩)\n id-is-magma-hom M = λ (x y : ⟨ M ⟩) → refl (x ·⟨ M ⟩ y)\n\n is-magma-iso : (M N : Magma 𝓤) → (⟨ M ⟩ → ⟨ N ⟩) → 𝓤 ̇\n is-magma-iso M N f = is-magma-hom M N f\n × (Σ g ꞉ (⟨ N ⟩ → ⟨ M ⟩), is-magma-hom N M g\n × (g ∘ f ∼ 𝑖𝑑 ⟨ M ⟩)\n × (f ∘ g ∼ 𝑖𝑑 ⟨ N ⟩))\n\n id-is-magma-iso : (M : Magma 𝓤) → is-magma-iso M M (𝑖𝑑 ⟨ M ⟩)\n id-is-magma-iso M = id-is-magma-hom M ,\n 𝑖𝑑 ⟨ M ⟩ ,\n id-is-magma-hom M ,\n refl ,\n refl\n\n Id→iso : {M N : Magma 𝓤} → M ≡ N → ⟨ M ⟩ → ⟨ N ⟩\n Id→iso p = transport ⟨_⟩ p\n\n Id→iso-is-iso : {M N : Magma 𝓤} (p : M ≡ N) → is-magma-iso M N (Id→iso p)\n Id→iso-is-iso (refl M) = id-is-magma-iso M\n\n _≅ₘ_ : Magma 𝓤 → Magma 𝓤 → 𝓤 ̇\n M ≅ₘ N = Σ f ꞉ (⟨ M ⟩ → ⟨ N ⟩), is-magma-iso M N f\n\n magma-Id→iso : {M N : Magma 𝓤} → M ≡ N → M ≅ₘ N\n magma-Id→iso p = Id→iso p , Id→iso-is-iso p\n\n ∞-Magma : (𝓤 : Universe) → 𝓤 ⁺ ̇\n ∞-Magma 𝓤 = Σ X ꞉ 𝓤 ̇ , (X → X → X)\n\nmodule monoids where\n\n left-neutral : {X : 𝓤 ̇ } → X → (X → X → X) → 𝓤 ̇\n left-neutral e _·_ = ∀ x → e · x ≡ x\n\n right-neutral : {X : 𝓤 ̇ } → X → (X → X → X) → 𝓤 ̇\n right-neutral e _·_ = ∀ x → x · e ≡ x\n\n associative : {X : 𝓤 ̇ } → (X → X → X) → 𝓤 ̇\n associative _·_ = ∀ x y z → (x · y) · z ≡ x · (y · z)\n\n Monoid : (𝓤 : Universe) → 𝓤 ⁺ ̇\n Monoid 𝓤 = Σ X ꞉ 𝓤 ̇ , is-set X\n × (Σ · ꞉ (X → X → X) , (Σ e ꞉ X , (left-neutral e ·)\n × (right-neutral e ·)\n × (associative ·)))\n\nmodule groups where\n\n left-neutral : {X : 𝓤 ̇ } → X → (X → X → X) → 𝓤 ̇\n left-neutral e _·_ = ∀ x → e · x ≡ x\n\n right-neutral : {X : 𝓤 ̇ } → X → (X → X → X) → 𝓤 ̇\n right-neutral e _·_ = ∀ x → x · e ≡ x\n\n associative : {X : 𝓤 ̇ } → (X → X → X) → 𝓤 ̇\n associative _·_ = ∀ x y z → (x · y) · z ≡ x · (y · z)\n\n inverse : {X : 𝓤 ̇ } → X → (X → X → X) → 𝓤 ̇\n inverse e _·_ = ∀ x → Σ (λ x' → x · x' ≡ e)\n\n Monoid : (𝓤 : Universe) → 𝓤 ⁺ ̇\n Monoid 𝓤 = Σ X ꞉ 𝓤 ̇ , is-set X\n × (Σ · ꞉ (X → X → X) , (Σ e ꞉ X , (left-neutral e ·)\n × (right-neutral e ·)\n × (associative ·)\n × (inverse e ·)))\n\nrefl-left : {X : 𝓤 ̇ } {x y : X} {p : x ≡ y} → refl x ∙ p ≡ p\nrefl-left {𝓤} {X} {x} {x} {refl x} = refl (refl x)\n\nrefl-right : {X : 𝓤 ̇ } {x y : X} {p : x ≡ y} → p ∙ refl y ≡ p\nrefl-right {𝓤} {X} {x} {y} {p} = refl p\n\n∙assoc : {X : 𝓤 ̇ } {x y z t : X} (p : x ≡ y) (q : y ≡ z) (r : z ≡ t)\n → (p ∙ q) ∙ r ≡ p ∙ (q ∙ r)\n∙assoc p q (refl z) = refl (p ∙ q)\n\n⁻¹-left∙ : {X : 𝓤 ̇ } {x y : X} (p : x ≡ y)\n → p ⁻¹ ∙ p ≡ refl y\n⁻¹-left∙ (refl x) = refl (refl x)\n\n⁻¹-right∙ : {X : 𝓤 ̇ } {x y : X} (p : x ≡ y)\n → p ∙ p ⁻¹ ≡ refl x\n⁻¹-right∙ (refl x) = refl (refl x)\n\n⁻¹-involutive : {X : 𝓤 ̇ } {x y : X} (p : x ≡ y)\n → (p ⁻¹)⁻¹ ≡ p\n⁻¹-involutive (refl x) = refl (refl x)\n\nap-refl : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (f : X → Y) (x : X)\n → ap f (refl x) ≡ refl (f x)\nap-refl f x = refl (refl (f x))\n\nap-∙ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (f : X → Y) {x y z : X} (p : x ≡ y) (q : y ≡ z)\n → ap f (p ∙ q) ≡ ap f p ∙ ap f q\nap-∙ f p (refl y) = refl (ap f p)\n\nap⁻¹ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (f : X → Y) {x y : X} (p : x ≡ y)\n → (ap f p)⁻¹ ≡ ap f (p ⁻¹)\nap⁻¹ f (refl x) = refl (refl (f x))\n\nap-id : {X : 𝓤 ̇ } {x y : X} (p : x ≡ y)\n → ap id p ≡ p\nap-id (refl x) = refl (refl x)\n\n\nap-∘ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {Z : 𝓦 ̇ }\n (f : X → Y) (g : Y → Z) {x y : X} (p : x ≡ y)\n → ap (g ∘ f) p ≡ (ap g ∘ ap f) p\nap-∘ f g (refl x) = refl (refl (g (f x)))\n\ntransport∙ : {X : 𝓤 ̇ } (A : X → 𝓥 ̇ ) {x y z : X} (p : x ≡ y) (q : y ≡ z)\n → transport A (p ∙ q) ≡ transport A q ∘ transport A p\ntransport∙ A p (refl y) = refl (transport A p)\n\nNat : {X : 𝓤 ̇ } → (X → 𝓥 ̇ ) → (X → 𝓦 ̇ ) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ̇\nNat A B = (x : domain A) → A x → B x\n\nNats-are-natural : {X : 𝓤 ̇ } (A : X → 𝓥 ̇ ) (B : X → 𝓦 ̇ ) (τ : Nat A B)\n → {x y : X} (p : x ≡ y)\n → τ y ∘ transport A p ≡ transport B p ∘ τ x\nNats-are-natural A B τ (refl x) = refl (τ x)\n\nNatΣ : {X : 𝓤 ̇ } {A : X → 𝓥 ̇ } {B : X → 𝓦 ̇ } → Nat A B → Σ A → Σ B\nNatΣ τ (x , a) = (x , τ x a)\n\ntransport-ap : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (A : Y → 𝓦 ̇ )\n (f : X → Y) {x x' : X} (p : x ≡ x') (a : A (f x))\n → transport (A ∘ f) p a ≡ transport A (ap f p) a\ntransport-ap A f (refl x) a = refl a\n\ndata Color : 𝓤₀ ̇ where\n Black White : Color\n\napd : {X : 𝓤 ̇ } {A : X → 𝓥 ̇ } (f : (x : X) → A x) {x y : X}\n (p : x ≡ y) → transport A p (f x) ≡ f y\napd f (refl _) = refl (f _)\n\nmodule Exercise where\n\n ≤ : ℕ → ℕ → 𝓤₀ ̇\n ≤ x = ℕ-induction (λ _ → ℕ → 𝓤₀ ̇) (λ _ → 𝟙)\n (λ _ f x₂ → ℕ-induction (λ _ → 𝓤₀ ̇) 𝟘 (λ n _ → f n) x₂) x\n\n ℍ' : {X : 𝓤 ̇ } (x : X) (B : (y : X) → x ≡ y → 𝓥 ̇ )\n → B x (refl x)\n → (y : X) (p : x ≡ y) → B y p\n ℍ' {X} x B b y p = {!!}\n\n ℕ-has-decidable-equality' : has-decidable-equality ℕ\n ℕ-has-decidable-equality' = ℕ-induction (λ z → (x : ℕ) → Id ℕ z x + (z ≢ x))\n (λ m → ℕ-induction\n (λ x → Id ℕ zero x + (zero ≢ x))\n (inl (refl zero))\n (λ n _ → inr (λ ())) m)\n λ n f → ℕ-induction (λ x → Id ℕ (succ n) x + (succ n ≢ x))\n (inr (λ ()))\n λ n₁ x → g (f n₁)\n where\n g : {x y : ℕ} → decidable (x ≡ y) → decidable (succ x ≡ succ y)\n g (inl p) = inl (ap succ p)\n g {x} {y} (inr k) = inr (λ (s : succ x ≡ succ y) → k (succ-lc s))\n \n Sub-EM Sub-EM' : ∀ 𝓤 → 𝓤 ⁺ ̇\n Sub-EM 𝓤 = (X : 𝓤 ̇ ) → is-subsingleton X → ¬¬(is-singleton X + is-empty X)\n Sub-EM' 𝓤 = ¬¬((X : 𝓤 ̇ ) → is-subsingleton X → is-singleton X + is-empty X)\n\n Sub-EM-gives-Sub-EM' : Sub-EM 𝓤 → Sub-EM' 𝓤\n Sub-EM-gives-Sub-EM' {𝓤} sub neg = {!!}\n\n Sub-EM'-gives-Sub-EM : Sub-EM' 𝓤 → Sub-EM 𝓤\n Sub-EM'-gives-Sub-EM sub' X subsing neg = sub' λ z → neg (z X subsing)\n\n ∙assoc' : {X : 𝓤 ̇ } {x y z t : X} (p : x ≡ y) (q : y ≡ z) (r : z ≡ t)\n → (p ∙ q) ∙ r ≡ p ∙ (q ∙ r)\n ∙assoc' p q r = {!𝕁!}\n\ninfix 0 _∼_\ninfixr 50 _,_\ninfixr 30 _×_\ninfixr 20 _+_\ninfixl 70 _∘_\ninfix 0 Id\ninfix 0 _≡_\ninfix 10 _⇔_\ninfixl 30 _∙_\ninfixr 0 _≡⟨_⟩_\ninfix 1 _∎\ninfix 40 _⁻¹\ninfix 10 _◁_\ninfixr 0 _◁⟨_⟩_\ninfix 1 _◀\ninfix 10 _≃_\ninfixl 30 _●_\ninfixr 0 _≃⟨_⟩_\ninfix 1 _■\ninfix 40 _∈_\ninfix 30 _[_,_]\ninfixr -1 -Σ\ninfixr -1 -Π\ninfixr -1 -∃!\n", "meta": {"hexsha": "02fcc4b38d769001457c587ec732da1ad5513fdb", "size": 26427, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT-UT-Agda/HoTT-UF-Agda.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": "HoTT-UT-Agda/HoTT-UF-Agda.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": "HoTT-UT-Agda/HoTT-UF-Agda.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": 27.7594537815, "max_line_length": 100, "alphanum_fraction": 0.4114352745, "num_tokens": 13197, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278757303677, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.599326205294077}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LogicalFramework.UniversalQuantifier where\n\npostulate D : Set\n\n-- The universal quantifier type on D.\ndata ForAll (A : D → Set) : Set where\n dfun : ((t : D) → A t) → ForAll A\n\ndapp : {A : D → Set}(t : D) → ForAll A → A t\ndapp t (dfun f) = f t\n", "meta": {"hexsha": "0884a22b6bebf20f19b5d7fc1edddc55417a65e5", "size": 424, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/LogicalFramework/UniversalQuantifier.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/UniversalQuantifier.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/UniversalQuantifier.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.5, "max_line_length": 49, "alphanum_fraction": 0.5613207547, "num_tokens": 122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8376199795472731, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.5992534428803488}} {"text": "\nopen import Common.Prelude\nopen import Common.Reflection\nopen import Common.Equality\n\ndata Dec {a} (A : Set a) : Set a where\n yes : A → Dec A\n no : Dec A\n\nrecord Eq {a} (A : Set a) : Set a where\n constructor eqDict\n field\n _==_ : (x y : A) → Dec (x ≡ y)\n\nmodule M {a} {A : Set a} {{EqA : Eq A}} where\n _==_ : (x y : A) → Dec (x ≡ y)\n _==_ = Eq._==_ EqA\n\nopen Eq {{...}}\n\nprivate\n eqNat : (x y : Nat) → Dec (x ≡ y)\n eqNat zero zero = yes refl\n eqNat zero (suc y) = no\n eqNat (suc x) zero = no\n eqNat (suc x) (suc y) with eqNat x y\n eqNat (suc x) (suc .x) | yes refl = yes refl\n ... | no = no\n\n eqBool : (x y : Bool) → Dec (x ≡ y)\n eqBool true true = yes refl\n eqBool true false = no\n eqBool false true = no\n eqBool false false = yes refl\n\nunquoteDecl EqNat = define (iArg EqNat)\n (funDef (def (quote Eq) (vArg (def (quote Nat) []) ∷ []))\n (clause [] (con (quote eqDict) (vArg (def (quote eqNat) []) ∷ [])) ∷ []))\n\ninstance\n EqBool : Eq Bool\n unquoteDef EqBool =\n defineFun EqBool (clause [] (con (quote eqDict) (vArg (def (quote eqBool) []) ∷ [])) ∷ [])\n\nid : {A : Set} → A → A\nid x = x\n\ntm : QName → Term\ntm eq = def (quote id) (vArg (def eq (vArg (lit (nat 0)) ∷ vArg (lit (nat 1)) ∷ [])) ∷ [])\n\ntm₂ : QName → Term\ntm₂ eq = def eq (iArg (def (quote EqNat) []) ∷ vArg (lit (nat 0)) ∷ vArg (lit (nat 1)) ∷ [])\n\n_==′_ : ∀ {a} {A : Set a} {{EqA : Eq A}} (x y : A) → Dec (x ≡ y)\n_==′_ = _==_\n\nok₁ : Dec (0 ≡ 1)\nok₁ = unquote (give (tm (quote _==′_)))\n\nok₂ : Dec (0 ≡ 1)\nok₂ = unquote (give (tm₂ (quote _==_)))\n\nok₃ : Dec (0 ≡ 1)\nok₃ = unquote (give (tm (quote M._==_)))\n\nok₄ : Dec (true ≡ false)\nok₄ = true == false\n\nok₅ : Dec (2 ≡ 2)\nok₅ = 2 == 2\n\n-- Was bad.\nbad : Dec (0 ≡ 1)\nbad = unquote (give (tm (quote _==_)))\n", "meta": {"hexsha": "a69662f04eaf9c28d277bcce6270f90699fcaf08", "size": 1756, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/UnquoteInstance.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/UnquoteInstance.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/UnquoteInstance.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.4133333333, "max_line_length": 94, "alphanum_fraction": 0.5410022779, "num_tokens": 727, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199754937772, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.5992534247335292}} {"text": "module Testing where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n{-# BUILTIN NATURAL Nat #-}\n\nplus : Nat -> Nat -> Nat\nplus zero n = n\nplus (suc m) n = suc (plus m n)\n\ntimes : Nat -> Nat -> Nat\ntimes zero n = zero\ntimes (suc m) n = plus n (times m n)\n\ndata List (A : Set) : Nat -> Set where\n nil : List A 0\n cons : {n : Nat} -> A -> List A n -> List A (suc n)\n\nf : Nat -> (b : Nat) -> (a : Nat) -> Nat\nf x = plus\n\n-- Push argument doesn't work with implicit\n-- Toggle implicit generates code that the tool can't handle\n-- also, want to include {something = x} in language\n\nmap : {n : Nat} -> {A : Set} -> {B : Set} -> {renameMe0 : A -> B} -> List A n ->\n List B n\nmap {renameMe0 = f} nil = nil\nmap {renameMe0 = f} (cons x xs) = cons (f x) (map {_} {_} {_} {f} xs)\n\nmap2 : {n : Nat} -> {A : Set} -> {B : Set} -> (A -> B) -> List A n ->\n List B n\nmap2 f nil = nil\nmap2 f (cons x xs) = cons (f x) (map2 f xs)\n{-\ndata Eq {A : Set} (x : A) : A -> Set where\n refl : Eq x x\n\nsubst : {A : Set} -> (P : A -> Set) ->\n {x : A} -> {y : A} -> Eq x y -> P x -> P y\nsubst P refl px = px\n\ndata Foo : Set where\n foo : Foo\n bar : Foo\n\n-- Refactoring to introduce these!\n{-# FOREIGN GHC data Foo = Foo | Bar #-}\n{-# COMPILE GHC Foo = data Foo (Foo | Bar) #-}\n-}\n", "meta": {"hexsha": "666f35fcff9d7dc955725ea9da8a28f7185e6e02", "size": 1280, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/ManualTestFiles/Testing.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/ManualTestFiles/Testing.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/ManualTestFiles/Testing.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": 24.1509433962, "max_line_length": 80, "alphanum_fraction": 0.53359375, "num_tokens": 455, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128672997041659, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.5992117744984697}} {"text": "\nmodule Issue628 where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN ZERO zero #-}\n\ndata _≡_ {A : Set}(x : A) : A → Set where\n refl : x ≡ x\n\ndata ⊥ : Set where\n\n0≢1+n : ∀ {n} -> 0 ≡ suc n → ⊥\n0≢1+n ()\n\ndivSucAux : (k m n j : ℕ) -> ℕ\ndivSucAux k m zero j = k\ndivSucAux k m (suc n) zero = divSucAux (suc k) m n m\ndivSucAux k m (suc n) (suc j) = divSucAux k m n j\n{-# BUILTIN NATDIVSUCAUX divSucAux #-}\n\noh-noes : ⊥\noh-noes = 0≢1+n {divSucAux 0 0 0 1} refl\n", "meta": {"hexsha": "a4c00731ba194e6485718d16b645b32b6ae2214c", "size": 518, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/fail/Issue628.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/fail/Issue628.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/fail/Issue628.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": 18.5, "max_line_length": 52, "alphanum_fraction": 0.5694980695, "num_tokens": 224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9099070084811307, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.5990986921689083}} {"text": "\nmodule Pat (BaseType : Set) where\n\ndata Ty : Set where\n ι : BaseType -> Ty\n _⟶_ : Ty -> Ty -> Ty\n\ndata Bwd (A : Set) : Set where\n • : Bwd A\n _◄_ : Bwd A -> A -> Bwd A\n\ninfixl 30 _◄_\n\nCtx = Bwd Ty\n\ndata Take {A : Set} : Bwd A -> A -> Bwd A -> Set where\n hd : forall {x xs} -> Take (xs ◄ x) x xs\n tl : forall {x y xs ys} -> Take xs x ys -> Take (xs ◄ y) x (ys ◄ y)\n\ndata Pat : Ctx -> Ctx -> Ty -> Ctx -> Set\n\ndata Pats : Ctx -> Ty -> Ctx -> Ty -> Set where\n ε : forall {Θ τ} -> Pats Θ τ Θ τ\n _,_ : forall {Θ₁ Θ₂ Θ₃ ρ σ τ} ->\n Pat • Θ₁ ρ Θ₂ -> Pats Θ₂ σ Θ₃ τ ->\n Pats Θ₁ (ρ ⟶ σ) Θ₃ τ\n\ndata Pat where\n ƛ : forall {Δ Θ Θ' σ τ} -> Pat (Δ ◄ σ) Θ τ Θ' ->\n Pat Δ Θ (σ ⟶ τ) Θ'\n _[_] : forall {Θ Θ' Δ σ τ} ->\n Take Θ σ Θ' -> Pats Δ σ • τ -> Pat Δ Θ τ Θ'\n\n", "meta": {"hexsha": "8dcaa6aeab872b35410e62c4b4d4775a47bbd083", "size": 792, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Miller/Pat.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/Miller/Pat.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/Miller/Pat.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.2941176471, "max_line_length": 69, "alphanum_fraction": 0.4772727273, "num_tokens": 368, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.868826769445233, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.5988871777374971}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Category.Complete.Properties {o ℓ e} (C : Category o ℓ e) where\n\nopen import Level\nopen import Data.Product\nopen import Relation.Binary\n\nopen import Categories.Category.Complete\nopen import Categories.Category.Complete.Finitely\nopen import Categories.Category.Construction.Functors\nopen import Categories.Diagram.Limit as Lim\nopen import Categories.Diagram.Limit.Properties\nopen import Categories.Diagram.Equalizer.Limit C\nopen import Categories.Diagram.Cone.Properties\nopen import Categories.Object.Product.Limit C\nopen import Categories.Object.Terminal.Limit C\nopen import Categories.Functor\nopen import Categories.Functor.Continuous\nopen import Categories.Functor.Properties\nopen import Categories.NaturalTransformation\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_)\n\nimport Categories.Category.Construction.Cones as Co\nimport Categories.Morphism.Reasoning as MR\nimport Categories.Morphism as Mor\nimport Categories.Morphism.Properties as Morₚ\n\nprivate\n variable\n o′ ℓ′ e′ o″ ℓ″ e″ : Level\n module C = Category C\n\nmodule _ (Com : Complete o′ ℓ′ e′ C) where\n\n Complete⇒FinitelyComplete : FinitelyComplete C\n Complete⇒FinitelyComplete = record\n { cartesian = record\n { terminal = limit⇒⊥ (Com (⊥⇒limit-F _ _ _))\n ; products = record\n { product = λ {A B} → limit⇒product (Com (product⇒limit-F _ _ _ A B))\n }\n }\n ; equalizer = λ f g → limit⇒equalizer (Com (equalizer⇒limit-F _ _ _ f g))\n }\n\nmodule _ {D : Category o′ ℓ′ e′} (Com : Complete o″ ℓ″ e″ D) where\n private\n D^C = Functors C D\n module D^C = Category D^C\n module D = Category D \n\n module _ {J : Category o″ ℓ″ e″} (F : Functor J D^C) where\n private\n module J = Category J\n module F = Functor F\n open F\n module F₀ j = Functor (F₀ j)\n module F₁ {a b} (f : a J.⇒ b) = NaturalTransformation (F₁ f)\n\n F[-,_] : C.Obj → Functor J D\n F[-, X ] = record\n { F₀ = λ j → F₀.₀ j X\n ; F₁ = λ f → F₁.η f X\n ; identity = identity\n ; homomorphism = homomorphism\n ; F-resp-≈ = λ eq → F-resp-≈ eq -- this application cannot be eta reduced\n }\n\n F[-,-] : Functor C (Functors J D)\n F[-,-] = record\n { F₀ = F[-,_]\n ; F₁ = λ f → ntHelper record\n { η = λ j → F₀.₁ j f\n ; commute = λ g → F₁.sym-commute g f\n }\n ; identity = F₀.identity _\n ; homomorphism = F₀.homomorphism _\n ; F-resp-≈ = λ eq → F₀.F-resp-≈ _ eq\n }\n\n module F[-,-] = Functor F[-,-]\n\n module LimFX X = Limit (Com F[-, X ])\n open LimFX hiding (commute)\n\n K⇒lim : ∀ {X Y} (f : X C.⇒ Y) K → Co.Cones F[-, Y ] [ nat-map-Cone (F[-,-].₁ f) K , limit Y ]\n K⇒lim f K = rep-cone _ (nat-map-Cone (F[-,-].₁ f) K)\n\n lim⇒lim : ∀ {X Y} (f : X C.⇒ Y) → Co.Cones F[-, Y ] [ nat-map-Cone (F[-,-].₁ f) (limit X) , limit Y ]\n lim⇒lim f = K⇒lim f (limit _)\n\n module lim⇒lim {X Y} (f : X C.⇒ Y) = Co.Cone⇒ F[-, Y ] (lim⇒lim f)\n\n module FCone (K : Co.Cone F) where\n open Co.Cone F K public\n module N = Functor N\n module ψ j = NaturalTransformation (ψ j)\n\n module FCone⇒ {K K′ : Co.Cone F} (K⇒K′ : Co.Cone⇒ F K K′) where\n open Co.Cone⇒ F K⇒K′ public\n module arr = NaturalTransformation arr\n\n FXcone : ∀ X → (K : Co.Cone F) → Co.Cone F[-, X ]\n FXcone X K = record\n { N = N.₀ X\n ; apex = record\n { ψ = λ j → ψ.η j X\n ; commute = λ f → commute f -- this application cannot be eta reduced\n }\n }\n where open FCone K\n\n ⊤ : Co.Cone F\n ⊤ = record\n { N = record\n { F₀ = λ X → apex X\n ; F₁ = λ {A B} f → lim⇒lim.arr f\n ; identity = λ {X} →\n terminal.!-unique X record\n { arr = D.id\n ; commute = D.identityʳ ○ ⟺ (elimˡ (F₀.identity _))\n }\n ; homomorphism = λ {X Y Z} {f g} →\n terminal.!-unique₂ Z\n {nat-map-Cone (F[-,-].₁ (g C.∘ f)) (limit X)}\n {terminal.! Z}\n {record { commute = λ {j} →\n begin\n proj Z j ∘ lim⇒lim.arr g ∘ lim⇒lim.arr f\n ≈⟨ pullˡ (lim⇒lim.commute g) ⟩\n (F₀.₁ j g ∘ proj Y j) ∘ lim⇒lim.arr f\n ≈⟨ pullʳ (lim⇒lim.commute f) ⟩\n F₀.₁ j g ∘ F₀.₁ j f ∘ proj X j\n ≈˘⟨ pushˡ (F₀.homomorphism j) ⟩\n F₀.₁ j (g C.∘ f) ∘ proj X j\n ∎ }}\n ; F-resp-≈ = λ {A B} {f g} eq → terminal.!-unique B record\n { commute = lim⇒lim.commute g ○ ∘-resp-≈ˡ (F₀.F-resp-≈ _ (C.Equiv.sym eq)) }\n }\n ; apex = record\n { ψ = λ j → ntHelper record\n { η = λ X → proj X j\n ; commute = λ _ → LimFX.commute _\n }\n ; commute = λ f {X} → limit-commute X f\n }\n }\n where open D\n open D.HomReasoning\n open MR D\n\n K⇒⊤′ : ∀ X {K} → Co.Cones F [ K , ⊤ ] → Co.Cones F[-, X ] [ FXcone X K , LimFX.limit X ]\n K⇒⊤′ X {K} K⇒⊤ = record\n { arr = arr.η X\n ; commute = comm\n }\n where open FCone⇒ K⇒⊤ renaming (commute to comm)\n\n complete : Limit F\n complete = record\n { terminal = record\n { ⊤ = ⊤\n ; ! = λ {K} →\n let module K = FCone K\n in record\n { arr = ntHelper record\n { η = λ X → rep X (FXcone X K)\n ; commute = λ {X Y} f →\n terminal.!-unique₂ Y\n {nat-map-Cone (F[-,-].₁ f) (FXcone X K)}\n {record { commute = λ {j} →\n begin\n proj Y j ∘ rep Y (FXcone Y K) ∘ K.N.₁ f ≈⟨ pullˡ (LimFX.commute Y) ⟩\n K.ψ.η j Y ∘ K.N.F₁ f ≈⟨ K.ψ.commute j f ⟩\n F₀.₁ j f ∘ K.ψ.η j X ∎ }}\n {record { commute = λ {j} →\n begin\n proj Y j ∘ lim⇒lim.arr f ∘ rep X (FXcone X K) ≈⟨ pullˡ (lim⇒lim.commute f) ⟩\n (F₀.₁ j f ∘ proj X j) ∘ rep X (FXcone X K) ≈⟨ pullʳ (LimFX.commute X) ⟩\n F₀.₁ j f ∘ K.ψ.η j X ∎ }}\n }\n ; commute = λ {_} {X} → LimFX.commute X\n }\n ; !-unique = λ K⇒⊤ {X} → terminal.!-unique X (K⇒⊤′ X K⇒⊤)\n }\n } \n where open D\n open D.HomReasoning\n open MR D\n\n ev : C.Obj → Functor D^C D\n ev = evalF C D\n\n module _ (L : Limit F) (X : C.Obj) where\n private\n module ev = Functor (ev X)\n open Mor D^C\n module DM = Mor D\n open Morₚ D\n open D.HomReasoning\n open MR D\n\n L′ : Limit (ev X ∘F F)\n L′ = Com (ev X ∘F F)\n\n Fiso : F[-, X ] ≃ ev X ∘F F\n Fiso = record\n { F⇒G = ntHelper record\n { η = λ _ → D.id\n ; commute = λ _ → id-comm-sym ○ D.∘-resp-≈ˡ (introʳ (F₀.identity _))\n }\n ; F⇐G = ntHelper record\n { η = λ _ → D.id\n ; commute = λ _ → D.∘-resp-≈ʳ (elimʳ (F₀.identity _)) ○ id-comm-sym\n }\n ; iso = λ _ → record\n { isoˡ = D.identity²\n ; isoʳ = D.identity²\n }\n }\n\n apex-iso : Limit.apex L ≅ Limit.apex complete\n apex-iso = up-to-iso F L complete\n\n apex-iso′ : Limit.apex (Com F[-, X ]) DM.≅ Limit.apex L′\n apex-iso′ = ≃⇒lim≅ Fiso (Com F[-, X ]) L′\n\n project-iso : Functor.F₀ (Limit.apex L) X DM.≅ Limit.apex L′\n project-iso = record\n { from = ai.from D.∘ from.η X\n ; to = to.η X D.∘ ai.to\n ; iso = Iso-∘ (record { isoˡ = isoˡ ; isoʳ = isoʳ }) ai.iso\n }\n where open _≅_ apex-iso\n module from = NaturalTransformation from\n module to = NaturalTransformation to\n module ai = DM._≅_ apex-iso′\n\n Functors-Complete : Complete o″ ℓ″ e″ D^C\n Functors-Complete F = complete F\n\n evalF-Continuous : ∀ X → Continuous o″ ℓ″ e″ (evalF C D X)\n evalF-Continuous X {J} {F} L = Com (evalF C D X ∘F F) , project-iso F L X\n", "meta": {"hexsha": "5e6b420205cef42344186a2b5a0bfd0a5f20226d", "size": 8474, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Complete/Properties.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/Complete/Properties.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/Complete/Properties.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": 34.3076923077, "max_line_length": 107, "alphanum_fraction": 0.4815907482, "num_tokens": 2810, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267626522814, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.5988871619643888}} {"text": "{-# OPTIONS --safe #-}\n\nmodule Cubical.Categories.Instances.Functors where\n\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor.Base\nopen import Cubical.Categories.NaturalTransformation.Base\nopen import Cubical.Categories.NaturalTransformation.Properties\nopen import Cubical.Categories.Morphism renaming (isIso to isIsoC)\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓC ℓC' ℓD ℓD' : Level\n\nmodule _ (C : Category ℓC ℓC') (D : Category ℓD ℓD') where\n open Category\n open NatTrans\n open Functor\n\n FUNCTOR : Category (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) (ℓ-max (ℓ-max ℓC ℓC') ℓD')\n ob FUNCTOR = Functor C D\n Hom[_,_] FUNCTOR = NatTrans\n id FUNCTOR {F} = idTrans F\n _⋆_ FUNCTOR = seqTrans\n ⋆IdL FUNCTOR α = makeNatTransPath λ i x → D .⋆IdL (α .N-ob x) i\n ⋆IdR FUNCTOR α = makeNatTransPath λ i x → D .⋆IdR (α .N-ob x) i\n ⋆Assoc FUNCTOR α β γ = makeNatTransPath λ i x → D .⋆Assoc (α .N-ob x) (β .N-ob x) (γ .N-ob x) i\n isSetHom FUNCTOR = isSetNat\n\n open isIsoC renaming (inv to invC)\n -- componentwise iso is an iso in Functor\n FUNCTORIso : ∀ {F G : Functor C D} (α : F ⇒ G)\n → (∀ (c : C .ob) → isIsoC D (α ⟦ c ⟧))\n → isIsoC FUNCTOR α\n FUNCTORIso α is .invC .N-ob c = (is c) .invC\n FUNCTORIso {F} {G} α is .invC .N-hom {c} {d} f\n = invMoveL areInv-αc\n ( α ⟦ c ⟧ ⋆⟨ D ⟩ (G ⟪ f ⟫ ⋆⟨ D ⟩ is d .invC)\n ≡⟨ sym (D .⋆Assoc _ _ _) ⟩\n (α ⟦ c ⟧ ⋆⟨ D ⟩ G ⟪ f ⟫) ⋆⟨ D ⟩ is d .invC\n ≡⟨ sym (invMoveR areInv-αd (α .N-hom f)) ⟩\n F ⟪ f ⟫\n ∎ )\n where\n areInv-αc : areInv _ (α ⟦ c ⟧) ((is c) .invC)\n areInv-αc = isIso→areInv (is c)\n\n areInv-αd : areInv _ (α ⟦ d ⟧) ((is d) .invC)\n areInv-αd = isIso→areInv (is d)\n FUNCTORIso α is .sec = makeNatTransPath (funExt (λ c → (is c) .sec))\n FUNCTORIso α is .ret = makeNatTransPath (funExt (λ c → (is c) .ret))\n", "meta": {"hexsha": "8cc1e5e481bb9824067297909cddff2a386a6096", "size": 1978, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/Functors.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/Functors.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/Functors.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": 37.320754717, "max_line_length": 97, "alphanum_fraction": 0.5793731041, "num_tokens": 778, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245828938679, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.5988223624148846}} {"text": "{-# OPTIONS --type-in-type #-}\nmodule chu where\nopen import functors\nopen import prelude\n \nrecord Chu : Set where\n constructor _,_!_\n field\n _⁺ _⁻ : Set\n _Ω_ : _⁺ → _⁻ → Set\n\nmodule _ (A@(A⁺ , A⁻ ! _Ω₁_) B@(B⁺ , B⁻ ! _Ω₂_) : Chu) where\n record Chu[_,_] : Set where -- Morphisms of chu spaces\n constructor _↔_!_\n field\n to : A⁺ → B⁺\n from : B⁻ → A⁻\n adj : ∀ a⁺ b⁻ → to a⁺ Ω₂ b⁻ ≡ a⁺ Ω₁ from b⁻\nmodule _ {A@(A⁺ , A⁻ ! _Ω₁_)\n B@(B⁺ , B⁻ ! _Ω₂_)\n C@(C⁺ , C⁻ ! _Ω₃_) : Chu}\n (F@(f ↔ fᵗ ! _†₁_) : Chu[ A , B ])\n (G@(g ↔ gᵗ ! _†₂_) : Chu[ B , C ]) where\n adj-comp : ∀ a⁺ c⁻ → (g ∘ f) a⁺ Ω₃ c⁻ ≡ a⁺ Ω₁ (fᵗ ∘ gᵗ) c⁻\n adj-comp a⁺ c⁻ = trans (f a⁺ †₂ c⁻) -- g (f a⁺) Ω₃ c⁻\n ( a⁺ †₁ gᵗ c⁻) -- f a⁺ Ω₂ gᵗ c⁻\n -- a⁺ Ω₁ fᵗ (gᵗ c⁻)\n chu-comp : Chu[ A , C ]\n chu-comp = (g ∘ f) ↔ (fᵗ ∘ gᵗ) ! adj-comp\n\ninstance\n chu-cat : Category Chu[_,_]\n chu-cat = 𝒾: (id ↔ id ! λ _ _ → refl)\n ▸: chu-comp\n 𝒾▸: (λ (_ ↔ _ ! _†_) → (λ x → _ ↔ _ ! x) ⟨$⟩\n extensionality2 λ a⁺ b⁻ → trans-refl (a⁺ † b⁻))\n ▸𝒾: (λ _ → refl)\n", "meta": {"hexsha": "40878ff55ba439ece0b78fdc890d092b92dc0ffd", "size": 1255, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "code-examples/agda/chu.agda", "max_stars_repo_name": "mstone/poly", "max_stars_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2021-02-18T16:31:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:08:27.000Z", "max_issues_repo_path": "code-examples/agda/chu.agda", "max_issues_repo_name": "dspivak/poly", "max_issues_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-09-02T02:29:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-12T10:06:32.000Z", "max_forks_repo_path": "code-examples/agda/chu.agda", "max_forks_repo_name": "dspivak/poly", "max_forks_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-07-10T17:19:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T11:45:57.000Z", "avg_line_length": 33.0263157895, "max_line_length": 69, "alphanum_fraction": 0.3896414343, "num_tokens": 585, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505402422645, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.5988088932696995}} {"text": "{-# OPTIONS --guardedness #-}\n\nmodule Stream where\n\nimport Lvl\nopen import Data.Boolean\nopen import Data.List as List using (List)\nimport Data.List.Functions as List\nimport Data.List.Proofs as List\nimport Data.List.Equiv.Id as List\nopen import Functional\nopen import Function.Iteration\nopen import Function.Iteration.Proofs\nopen import Logic\nopen import Logic.Propositional\nopen import Numeral.Natural\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable a x init : T\nprivate variable f : A → B\nprivate variable n : ℕ\n\n-- A countably infinite list\nrecord Stream (T : Type{ℓ}) : Type{ℓ} where\n coinductive\n field\n head : T\n tail : Stream(T)\nopen Stream\n\nmodule _ where\n -- The n:th element of a stream.\n -- Example: index(2)(0,1,2,…) = 2\n index : Stream(T) → ℕ → T\n index(l)(𝟎) = head(l)\n index(l)(𝐒(n)) = index(tail(l))(n)\n\n -- The constant stream, consisting of a single element repeated.\n -- Example: repeat(x) = (x,x,x,..)\n repeat : T → Stream(T)\n head(repeat(x)) = x\n tail(repeat(x)) = repeat(x)\n\n -- The stream consisting of a list repeated (concatenated infinite many times).\n -- Example: loop(1,2,3) = (1,2,3 , 1,2,3 , 1,2,3 , …)\n loop : (l : List(T)) → (l ≢ List.∅) → Stream(T)\n loop List.∅ p with () ← p [≡]-intro\n head (loop (x List.⊰ l) p) = x\n tail (loop (x List.⊰ l) p) = loop (List.postpend x l) List.[∅]-postpend-unequal\n\n -- The stream of two interleaved streams.\n -- Example: interleave₂(1,2,3,‥)(a,b,c,…) = (1,a , 2,b , 3,c , …)\n interleave₂ : Stream(T) -> Stream(T) -> Stream(T)\n head(interleave₂(a)(b)) = head(a)\n tail(interleave₂(a)(b)) = interleave₂(b)(tail a)\n\n -- A stream which skips the first n number of elements from the specified stream.\n -- From the stream of (index 0 l , index 1 l , index 2 l , ..), the stream of (index n l , index (n+1) l , index (n+2) l , ..)\n -- Example: skip(2)(1,2,3,4,…) = (3,4,…)\n skip : ℕ → Stream(T) -> Stream(T)\n head(skip 𝟎 l) = head(l)\n tail(skip 𝟎 l) = tail(l)\n head(skip (𝐒(n)) l) = head(skip n (tail(l)))\n tail(skip (𝐒(n)) l) = tail(skip n (tail(l)))\n\n -- From the stream of (index 0 l , index 1 l , index 2 l , ..), the stream of (index 0 l , index n l , index (2⋅n) l , ..)\n -- Example: takeMultiples(3)(0,1,2,…) = (0,3,6,…)\n takeMultiples : ℕ → Stream(T) -> Stream(T)\n head(takeMultiples _ l) = head(l)\n tail(takeMultiples n l) = takeMultiples n ((tail ^ n) l)\n\n -- From the stream of (a,b,c,..), the stream of (x,a,b,c,..)\n _⊰_ : T → Stream(T) -> Stream(T)\n head(x ⊰ _) = x\n tail(_ ⊰ l) = l\n\n -- Stream of (init , f(init) , f(f(init)) , ..)\n iterated : T -> (T → T) → Stream(T)\n head(iterated init _) = init\n tail(iterated init f) = iterated (f(init)) f\n\n -- List from the initial part of the stream\n take : ℕ → Stream(T) → List(T)\n take(𝟎) (l) = List.∅\n take(𝐒(n))(l) = head(l) List.⊰ take(n)(tail(l))\n\n -- Example: indexIntervals(0,0,2,0,1,2,…)(0,1,2,3,…) = (0,0,2,2,3,5,…)\n indexIntervals : Stream(ℕ) → Stream(T) → Stream(T)\n head (indexIntervals i l) = index l (head i)\n tail (indexIntervals i l) = indexIntervals (tail i) (skip (head i) l)\n\nmodule _ where\n -- From the stream of (a,b,c,..), the stream of (f(a),f(b),f(c),..)\n map : (A → B) → Stream(A) → Stream(B)\n head(map f(l)) = f(head(l))\n tail(map f(l)) = map f(tail(l))\n\n{- TODO: May not terminate. For example when P = const 𝐹\nmodule _ {ℓ} {A : Type{ℓ}} where\n filter : (A → Bool) → Stream(A) → Stream(A)\n head(filter p(l)) with p(head(l))\n ... | 𝑇 = head(l)\n ... | 𝐹 = head(filter p(tail(l)))\n tail(filter p(l)) = filter p(tail(l))\n-}\n\nmodule _ where\n data _∈_ {T : Type{ℓ}} : T → Stream(T) → Stmt{ℓ} where\n [∈]-head : ∀{l} → (head(l) ∈ l)\n [∈]-tail : ∀{a l} → (a ∈ tail(l)) → (a ∈ l)\n\n private variable l : Stream(T)\n\n index-of-[∈] : (x ∈ l) → ℕ\n index-of-[∈] [∈]-head = 𝟎\n index-of-[∈] ([∈]-tail p) = 𝐒(index-of-[∈] p)\n\n index-of-[∈]-correctness : ∀{p : (x ∈ l)} → (index l (index-of-[∈] p) ≡ x)\n index-of-[∈]-correctness {x = .(head l)} {l} {[∈]-head} = [≡]-intro\n index-of-[∈]-correctness {x = x} {l} {[∈]-tail p} = index-of-[∈]-correctness {x = x} {tail l} {p}\n\n _⊆_ : Stream(T) → Stream(T) → Stmt\n _⊆_ l₁ l₂ = ∀{a} → (a ∈ l₁) → (a ∈ l₂)\n\n [∈]-tails : ((tail ^ n)(l) ⊆ l)\n [∈]-tails {n = 𝟎} {l = l} {a} tailn = tailn\n [∈]-tails {n = 𝐒 n} {l = l} {a} tailn = [∈]-tail ([∈]-tails {n = n} {l = tail l} {a} ([≡]-substitutionₗ ([^]-inner-value {f = tail}{x = l}{n}) {a ∈_} tailn))\n\n [∈]-head-tail : (head(tail(l)) ∈ l)\n [∈]-head-tail = [∈]-tail ([∈]-head)\n\n [∈]-head-tails-membership : (head((tail ^ n)(l)) ∈ l)\n [∈]-head-tails-membership{𝟎} = [∈]-head\n [∈]-head-tails-membership{𝐒(n)}{l} = [∈]-tails {n = n} ([∈]-head-tail)\n\n [∈]-disjunction : (x ∈ l) → ((x ≡ head(l)) ∨ (x ∈ tail(l)))\n [∈]-disjunction ([∈]-head) = [∨]-introₗ [≡]-intro\n [∈]-disjunction ([∈]-tail proof) = [∨]-introᵣ proof\n\n [∈]-index : (index l n ∈ l)\n [∈]-index {n = 𝟎} = [∈]-head\n [∈]-index {n = 𝐒(n)} = [∈]-tail ([∈]-index {n = n})\n\n repeat-[∈] : (x ∈ repeat(a)) ↔ (x ≡ a)\n repeat-[∈] {x = x}{a = a} = [↔]-intro left right where\n left : (x ∈ repeat(a)) ← (x ≡ a)\n left ([≡]-intro) = [∈]-head\n\n right : (x ∈ repeat(a)) → (x ≡ a)\n right ([∈]-head) = [≡]-intro\n right ([∈]-tail proof) = right(proof)\n\n map-[∈] : (x ∈ l) → (f(x) ∈ map f(l))\n map-[∈] ([∈]-head) = [∈]-head\n map-[∈] {l = l} ([∈]-tail proof) = [∈]-tail (map-[∈] {l = tail l} (proof))\n\n [⊰][∈] : (a ∈ (x ⊰ l)) ↔ ((x ≡ a) ∨ (a ∈ l))\n [⊰][∈] {a = a}{x = x}{l = l} = [↔]-intro ll rr where\n ll : (a ∈ (x ⊰ l)) ← ((x ≡ a) ∨ (a ∈ l))\n ll ([∨]-introₗ ([≡]-intro)) = [∈]-head\n ll ([∨]-introᵣ (proof)) = [∈]-tail (proof)\n\n rr : (a ∈ (x ⊰ l)) → ((x ≡ a) ∨ (a ∈ l))\n rr ([∈]-head) = [∨]-introₗ ([≡]-intro)\n rr ([∈]-tail (proof)) = [∨]-introᵣ (proof)\n\n iterated-init-[∈] : (init ∈ iterated(init)(f))\n iterated-init-[∈] = [∈]-head\n\n iterated-next-[∈] : (x ∈ iterated(init)(f)) → (f(x) ∈ iterated(init)(f))\n iterated-next-[∈] ([∈]-head) = [∈]-tail ([∈]-head)\n iterated-next-[∈] ([∈]-tail proof) = [∈]-tail (iterated-next-[∈] (proof))\n -- First:\n -- head(iterated(init)(f)) ∈ iterated(init)(f)\n -- init ∈ iterated(init)(f)\n -- ...\n -- Second:\n -- x ∈ tail(iterated(init)(f))\n -- x ∈ iterated (f(init)) f\n -- ...\n\n iterated-[∈] : ((f ^ n)(init) ∈ iterated(init)(f))\n iterated-[∈] {n = 𝟎} = iterated-init-[∈]\n iterated-[∈] {n = 𝐒 n} = iterated-next-[∈] (iterated-[∈] {n = n})\n\n-- Stream of (0,1,2,3,..)\n[ℕ]-stream : Stream(ℕ)\n[ℕ]-stream = iterated(𝟎)(𝐒)\n\n[ℕ]-stream-[∈] : (n ∈ [ℕ]-stream)\n[ℕ]-stream-[∈]{𝟎} = [∈]-head\n[ℕ]-stream-[∈]{𝐒(n)} = iterated-next-[∈]([ℕ]-stream-[∈]{n})\n\n-- Stream of (f(0),f(1),f(2),f(3),..)\n[ℕ]-function-stream : (ℕ → T) → Stream(T)\n[ℕ]-function-stream f = map f([ℕ]-stream)\n\nmodule _ {ℓ} {T : Type{ℓ}} where\n open import Logic.Predicate\n open import Logic.Predicate.Theorems\n open import Structure.Function.Domain\n open import Type.Size.Countable\n\n -- This provides another way of proving that a type is countable.\n -- The method is: If a stream can enumerate every object of a certain type, then it is countable.\n countable-equivalence : ∃(l ↦ ∀{x : T} → (x ∈ l)) ↔ Countable(T)\n countable-equivalence = [↔]-intro left right where\n left : ∃(l ↦ ∀{x : T} → (x ∈ l)) ← Countable(T)\n ∃.witness (left ([∃]-intro f ⦃ intro proof ⦄)) = [ℕ]-function-stream f\n ∃.proof (left ([∃]-intro f ⦃ intro proof ⦄)) {x} with proof{x}\n ... | [∃]-intro n ⦃ [≡]-intro ⦄ = map-[∈] [ℕ]-stream-[∈]\n\n right : ∃(l ↦ ∀{x : T} → (x ∈ l)) → Countable(T)\n ∃.witness (right ([∃]-intro l ⦃ p ⦄)) = index l\n ∃.witness (Surjective.proof (∃.proof (right ([∃]-intro l ⦃ p ⦄))) {x}) = index-of-[∈] (p{x})\n ∃.proof (Surjective.proof (∃.proof (right ([∃]-intro l ⦃ p ⦄))) {x}) = index-of-[∈]-correctness {p = p}\n", "meta": {"hexsha": "eab37a366c4e69e69138f5a7b93c172dfc7b683d", "size": 7972, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Stream.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": "Stream.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": "Stream.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.07239819, "max_line_length": 159, "alphanum_fraction": 0.5353738083, "num_tokens": 3275, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.7549149923816046, "lm_q1q2_score": 0.5987275730959591}} {"text": "{-# OPTIONS --without-K #-}\nmodule Util.Induction.WellFounded where\n\nopen import Induction.WellFounded public using\n ( Acc ; acc ; WellFounded ; module Subrelation ; module InverseImage\n ; module TransitiveClosure ; module Lexicographic )\n\nopen import Relation.Binary using (Rel)\n\nopen import Util.HoTT.FunctionalExtensionality using (funext)\nopen import Util.HoTT.HLevel using (IsProp ; ∀-IsProp)\nopen import Util.Prelude\n\n\nmodule _ {α β} {A : Set α} {_<_ : Rel A β} where\n\n\n Acc-IsProp : ∀ {x} → IsProp (Acc _<_ x)\n Acc-IsProp (acc rs₀) (acc rs₁)\n = cong acc (funext λ y → funext λ y Ty\n\ninfixl 2 _&&_\ninfixl 1 _||_\ninfixr 0 _=>_\ndata Ty where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n _&&_ : Ty -> Ty -> Ty\n _||_ : Ty -> Ty -> Ty\n FALSE : Ty\n FORALL : Pred -> Ty\n EXISTS : Pred -> 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/individual judgement\n\ndata El : Set where\n mkTrue : Ty -> El\n mkIndiv : Indiv -> El\n\nCx : Set1\nCx = El -> Set\n\nisTrue : Ty -> Cx -> Set\nisTrue a tc = tc (mkTrue a)\n\nisIndiv : Indiv -> Cx -> Set\nisIndiv x tc = tc (mkIndiv x)\n\n\n-- Terms\n\nmodule M where\n infixl 2 _$$_\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 pi' : forall {p} -> (forall {x} -> isIndiv x tc -> Tm tc (p x)) -> Tm tc (FORALL p)\n _$$_ : forall {p x} -> Tm tc (FORALL p) -> isIndiv x tc -> Tm tc (p x)\n sig' : forall {p x} -> isIndiv x tc -> Tm tc (p x) -> Tm tc (EXISTS p)\n split' : forall {p x a} -> Tm tc (EXISTS p) -> (isTrue (p x) tc -> Tm tc a) -> Tm tc a\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 split'' : forall {tc p x a} -> Tm tc (EXISTS p) -> (Tm tc (p x) -> Tm tc a) -> Tm tc a\n split'' x f = split' x \\y -> f (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 syntax pi' (\\x -> px) = pi x => px\n syntax sig' x px = [ x ,, px ]\n syntax split'' x (\\y -> z) = split x as y => z\n\n Thm : Ty -> Set1\n Thm a = forall {tc} -> Tm tc a\nopen M public\n", "meta": {"hexsha": "8ac00b2f15ac5896dcd97539b9587111dd0b17eb", "size": 2721, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Pi/M.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/M.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/M.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": 29.9010989011, "max_line_length": 114, "alphanum_fraction": 0.4439544285, "num_tokens": 1065, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527869325345, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.5985224296895623}} {"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\nopen import Sets.EquivalenceRelations\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nmodule Rings.UniqueFactorisationDomains.Lemmas {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 import Rings.Divisible.Definition R\nopen import Rings.Divisible.Lemmas R\nopen import Rings.UniqueFactorisationDomains.Definition intDom\nopen Ring R\nopen Setoid S\nopen Equivalence eq\n\nufdImpliesUfd' : UFD → UFD'\nUFD'.factorisation (ufdImpliesUfd' x) = UFD.factorisation x\nPrime.isPrime (UFD'.irreduciblesArePrime (ufdImpliesUfd' ufd) {r} irreducible) a b (s , ab=rs) rNotDivA = {!!}\n where\n -- we can't factorise a, it might be a unit :(\n factA : Factorisation {a} (λ p → rNotDivA (divisibleWellDefined reflexive (symmetric p) (everythingDividesZero r))) {!!}\n factA = UFD.factorisation ufd {a} {!!} {!!}\n fact1 : Factorisation {r} {!!} {!!}\n fact1 = {!!}\n fact2 : Factorisation {r} {!!} {!!}\n fact2 = {!!}\nPrime.nonzero (UFD'.irreduciblesArePrime (ufdImpliesUfd' x) irreducible) = Irreducible.nonzero irreducible\nPrime.nonunit (UFD'.irreduciblesArePrime (ufdImpliesUfd' x) irreducible) = Irreducible.nonunit irreducible\n\nprivate\n lemma2 : UFD' → {r : A} → .(nonzero : (r ∼ 0R) → False) .(nonunit : (Unit r) → False) → (f1 f2 : Factorisation {r} nonzero nonunit) → factorisationEquality f1 f2\n lemma2 x nonzero nonunit record { len = lenA ; factorise = factoriseA ; factoriseIsFactorisation = factoriseIsFactorisationA ; factoriseIsIrreducibles = factoriseIsIrreduciblesA ; distinct = distinctA } record { len = lenB ; factorise = factoriseB ; factoriseIsFactorisation = factoriseIsFactorisationB ; factoriseIsIrreducibles = factoriseIsIrreduciblesB ; distinct = distinctB } with ℕDecideEquality lenA lenB\n lemma2 x nonzero nonunit record { len = zero ; factorise = [] ; factoriseIsFactorisation = factoriseIsFactorisationA ; factoriseIsIrreducibles = factoriseIsIrreduciblesA ; distinct = distinctA } record { len = .0 ; factorise = [] ; factoriseIsFactorisation = factoriseIsFactorisationB ; factoriseIsIrreducibles = factoriseIsIrreduciblesB ; distinct = distinctB } | inl refl = record {}\n lemma2 ufd' {r} nonzero nonunit record { len = (succ len) ; factorise = (a1 ,, n1) ,- factoriseA ; factoriseIsFactorisation = factoriseIsFactorisationA ; factoriseIsIrreducibles = factoriseIsIrreduciblesA ; distinct = distinctA } record { len = .(succ len) ; factorise = factoriseB ; factoriseIsFactorisation = factoriseIsFactorisationB ; factoriseIsIrreducibles = factoriseIsIrreduciblesB ; distinct = distinctB } | inl refl = {!!}\n where\n a1Prime : Prime a1\n a1Prime = UFD'.irreduciblesArePrime ufd' (_&&_.fst factoriseIsIrreduciblesA)\n a1DivR : a1 ∣ r\n a1DivR = {!!}\n\n ... | inr neq = {!!}\n\nufd'ImpliesUfd : UFD' → UFD\nUFD.factorisation (ufd'ImpliesUfd x) = UFD'.factorisation x\nUFD.uniqueFactorisation (ufd'ImpliesUfd x) {r} nonzero nonunit f1 f2 = lemma2 x nonzero nonunit f1 f2\n", "meta": {"hexsha": "8aa666027ff1ad34342a3a30051aa80b5522c488", "size": 3490, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/UniqueFactorisationDomains/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/UniqueFactorisationDomains/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/UniqueFactorisationDomains/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": 60.1724137931, "max_line_length": 434, "alphanum_fraction": 0.7446991404, "num_tokens": 1086, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677737461007, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.5984829640459519}} {"text": "------------------------------------------------------------------------------\n-- Inductive Peano arithmetic base\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule PA.Inductive.Base where\n\ninfixl 7 _*_\ninfixl 6 _+_\n\n------------------------------------------------------------------------------\n-- PA universe\nopen import PA.Inductive.Base.Core public\n\n-- First-order logic (without equality)\n--\nopen import Common.FOL.FOL public hiding ( _,_ ; ∃ )\n-- 2012-04-24. Agda bug? Why it is necessary to use the modifier\n-- @using@ in the following importation?\nopen import PA.Inductive.Existential public using ( _,_ ; ∃ )\n\n-- The induction principle on the PA universe\nℕ-ind : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n\nℕ-ind A A0 h zero = A0\nℕ-ind A A0 h (succ n) = h n (ℕ-ind A A0 h n)\n\n-- The identity type on the PA universe\nopen import PA.Inductive.Relation.Binary.PropositionalEquality public\n\n-- PA primitive recursive functions\n_+_ : ℕ → ℕ → ℕ\nzero + n = n\nsucc m + n = succ (m + n)\n\n_*_ : ℕ → ℕ → ℕ\nzero * n = zero\nsucc m * n = n + m * n\n\n------------------------------------------------------------------------------\n-- ATPs helper\n-- We don't traslate the body of functions, only the types. Therefore\n-- we need to feed the ATPs with the functions' equations.\n\n-- Addition axioms\n+-0x : ∀ n → zero + n ≡ n\n+-0x n = refl\n-- {-# ATP hint +-0x #-}\n\n+-Sx : ∀ m n → succ m + n ≡ succ (m + n)\n+-Sx m n = refl\n{-# ATP hint +-Sx #-}\n\n-- Multiplication axioms\n*-0x : ∀ n → zero * n ≡ zero\n*-0x n = refl\n-- {-# ATP hint *-0x #-}\n\n*-Sx : ∀ m n → succ m * n ≡ n + m * n\n*-Sx m n = refl\n-- {-# ATP hint *-Sx #-}\n", "meta": {"hexsha": "e36be06e94c6b04021132f144c6d306e6b5ab382", "size": 1842, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/Base.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/Base.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/Base.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.3384615385, "max_line_length": 78, "alphanum_fraction": 0.493485342, "num_tokens": 506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619634, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.5984829638702746}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.Sigma\nopen import lib.types.Bool\nopen import lib.types.Nat\nopen import lib.types.Fin\n\nmodule lib.types.Vec where\n\ninfixr 5 _∷_\n\ndata Vec {i} (A : Type i) : ℕ → Type i where\n [] : Vec A 0\n _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (S n)\n\ninfix 4 _[_]=_\n\ndata _[_]=_ {i} {A : Type i} : ∀ {n} → Vec A n → ℕ → A → Type i where\n here : ∀ {n} {x} {xs : Vec A n} → x ∷ xs [ 0 ]= x\n there : ∀ {n} {m} {x y} {xs : Vec A n}\n (xs[m]=x : xs [ m ]= x) → y ∷ xs [ S m ]= x\n\nmodule _ {i} {A : Type i} where\n\n length : ∀ {n} → Vec A n → ℕ\n length {n = n} _ = n\n\n head : ∀ {n} → Vec A (S n) → A\n head (x ∷ xs) = x\n\n vtail : ∀ {n} → Vec A (S n) → Vec A n\n vtail (x ∷ xs) = xs\n\n lookup : ∀ {n} → Vec A n → Fin n → A\n lookup [] ()\n lookup (x ∷ xs) (O , _) = x\n lookup (x ∷ xs) (S n , p) = lookup xs (n , <-cancel-S p)\n\n updateAt : ∀ {n} → Fin n → (A → A) → Vec A n → Vec A n\n updateAt (_ , _) _ [] = []\n updateAt (O , _) f (x ∷ xs) = (f x) ∷ xs\n updateAt (S n , p) f (x ∷ xs) = x ∷ (updateAt (n , <-cancel-S p) f xs)\n", "meta": {"hexsha": "259d7b55e666c43435cdce168da892f32708ed5e", "size": 1119, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/Vec.agda", "max_stars_repo_name": "maxdore/hott-morse", "max_stars_repo_head_hexsha": "01bbd8841f9b9b25666b91e65b196d8f472b9978", "max_stars_repo_licenses": ["MIT"], "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/Vec.agda", "max_issues_repo_name": "maxdore/hott-morse", "max_issues_repo_head_hexsha": "01bbd8841f9b9b25666b91e65b196d8f472b9978", "max_issues_repo_licenses": ["MIT"], "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/Vec.agda", "max_forks_repo_name": "maxdore/hott-morse", "max_forks_repo_head_hexsha": "01bbd8841f9b9b25666b91e65b196d8f472b9978", "max_forks_repo_licenses": ["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.4318181818, "max_line_length": 72, "alphanum_fraction": 0.4834673816, "num_tokens": 485, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619634, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.5984829638702744}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category.Core using (Category)\n\n-- Defines BinaryProducts -- for when a Category has all Binary Products\n\nmodule Categories.Category.BinaryProducts {o ℓ e} (𝒞 : Category o ℓ e) where\n\nopen import Level hiding (suc)\nopen import Data.Product using (uncurry)\n\nopen Category 𝒞\nopen HomReasoning\n\nopen import Categories.Object.Product 𝒞\nopen import Categories.Morphism 𝒞 using (_≅_; module Iso)\nopen import Categories.Morphism.Reasoning 𝒞 using (pullʳ; pullˡ; elimʳ; cancelˡ)\nopen import Categories.Category.Monoidal.Core using (Monoidal)\n\nopen import Categories.Functor using (Functor) renaming (id to idF)\nopen import Categories.Functor.Bifunctor using (Bifunctor; appʳ; appˡ)\n\nprivate\n variable\n A B C D X Y Z : Obj\n f f′ g g′ h i : A ⇒ B\n\nrecord BinaryProducts : Set (levelOfTerm 𝒞) where\n\n infixr 7 _×_\n infixr 8 _⁂_\n infix 11 ⟨_,_⟩\n\n field\n product : ∀ {A B} → Product A B\n\n private\n module product {A} {B} = Product (product {A} {B})\n\n _×_ : Obj → Obj → Obj\n A × B = Product.A×B (product {A} {B})\n\n ×-comm : A × B ≅ B × A\n ×-comm = Commutative product product\n\n ×-assoc : X × Y × Z ≅ (X × Y) × Z\n ×-assoc = Associative product product product product\n\n open product hiding (⟨_,_⟩; ∘-distribʳ-⟨⟩) public\n\n -- define it like this instead of reexporting to redefine fixity\n ⟨_,_⟩ : X ⇒ A → X ⇒ B → X ⇒ A × B\n ⟨_,_⟩ = Product.⟨_,_⟩ product\n\n _⁂_ : A ⇒ B → C ⇒ D → A × C ⇒ B × D\n f ⁂ g = [ product ⇒ product ] f × g\n\n assocˡ : (A × B) × C ⇒ A × B × C\n assocˡ = _≅_.to ×-assoc\n\n assocʳ : A × B × C ⇒ (A × B) × C\n assocʳ = _≅_.from ×-assoc\n\n assocʳ∘assocˡ : assocʳ {A}{B}{C} ∘ assocˡ {A}{B}{C} ≈ id\n assocʳ∘assocˡ = Iso.isoʳ (_≅_.iso ×-assoc)\n\n assocˡ∘assocʳ : assocˡ {A}{B}{C} ∘ assocʳ {A}{B}{C} ≈ id\n assocˡ∘assocʳ = Iso.isoˡ (_≅_.iso ×-assoc)\n\n ⟨⟩-congʳ : f ≈ f′ → ⟨ f , g ⟩ ≈ ⟨ f′ , g ⟩\n ⟨⟩-congʳ pf = ⟨⟩-cong₂ pf Equiv.refl\n\n ⟨⟩-congˡ : g ≈ g′ → ⟨ f , g ⟩ ≈ ⟨ f , g′ ⟩\n ⟨⟩-congˡ pf = ⟨⟩-cong₂ Equiv.refl pf\n\n swap : A × B ⇒ B × A\n swap = ⟨ π₂ , π₁ ⟩\n\n -- TODO: this is probably harder to use than necessary because of this definition. Maybe make a version\n -- that doesn't have an explicit id in it, too?\n first : A ⇒ B → A × C ⇒ B × C\n first f = f ⁂ id\n\n second : C ⇒ D → A × C ⇒ A × D\n second g = id ⁂ g\n\n -- Just to make this more obvious\n π₁∘⁂ : π₁ ∘ (f ⁂ g) ≈ f ∘ π₁\n π₁∘⁂ {f = f} {g} = project₁\n\n π₂∘⁂ : π₂ ∘ (f ⁂ g) ≈ g ∘ π₂\n π₂∘⁂ {f = f} {g} = project₂\n\n ⁂-cong₂ : f ≈ g → h ≈ i → f ⁂ h ≈ g ⁂ i\n ⁂-cong₂ = [ product ⇒ product ]×-cong₂\n\n ⁂∘⟨⟩ : (f ⁂ g) ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f ∘ f′ , g ∘ g′ ⟩\n ⁂∘⟨⟩ = [ product ⇒ product ]×∘⟨⟩\n\n first∘⟨⟩ : first f ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f ∘ f′ , g′ ⟩\n first∘⟨⟩ = [ product ⇒ product ]×id∘⟨⟩\n\n second∘⟨⟩ : second g ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f′ , g ∘ g′ ⟩\n second∘⟨⟩ = [ product ⇒ product ]id×∘⟨⟩\n\n ⁂∘⁂ : (f ⁂ g) ∘ (f′ ⁂ g′) ≈ (f ∘ f′) ⁂ (g ∘ g′)\n ⁂∘⁂ = [ product ⇒ product ⇒ product ]×∘×\n\n ⟨⟩∘ : ⟨ f , g ⟩ ∘ h ≈ ⟨ f ∘ h , g ∘ h ⟩\n ⟨⟩∘ = [ product ]⟨⟩∘\n\n first∘first : ∀ {C} → first {C = C} f ∘ first g ≈ first (f ∘ g)\n first∘first = [ product ⇒ product ⇒ product ]×id∘×id\n\n second∘second : ∀ {A} → second {A = A} f ∘ second g ≈ second (f ∘ g)\n second∘second = [ product ⇒ product ⇒ product ]id×∘id×\n\n first∘second : first f ∘ second g ≈ f ⁂ g\n first∘second {f = f} {g = g} = begin\n first f ∘ second g ≈⟨ first∘⟨⟩ ⟩\n ⟨ f ∘ id ∘ π₁ , g ∘ π₂ ⟩ ≈⟨ ⟨⟩-congʳ (∘-resp-≈ʳ identityˡ) ⟩\n f ⁂ g ∎\n\n second∘first : second f ∘ first g ≈ g ⁂ f\n second∘first {f = f} {g = g} = begin\n second f ∘ first g ≈⟨ second∘⟨⟩ ⟩\n ⟨ g ∘ π₁ , f ∘ id ∘ π₂ ⟩ ≈⟨ ⟨⟩-congˡ (∘-resp-≈ʳ identityˡ) ⟩\n g ⁂ f ∎\n\n first↔second : first f ∘ second g ≈ second g ∘ first f\n first↔second = [ product ⇒ product , product ⇒ product ]first↔second\n\n firstid : ∀ {f : A ⇒ A} (g : A ⇒ C) → first {C = C} f ≈ id → f ≈ id\n firstid {f = f} g eq = begin\n f ≈˘⟨ elimʳ project₁ ⟩\n f ∘ π₁ ∘ ⟨ id , g ⟩ ≈⟨ pullˡ fπ₁≈π₁ ⟩\n π₁ ∘ ⟨ id , g ⟩ ≈⟨ project₁ ⟩\n id ∎\n where fπ₁≈π₁ = begin\n f ∘ π₁ ≈˘⟨ project₁ ⟩\n π₁ ∘ first f ≈⟨ refl⟩∘⟨ eq ⟩\n π₁ ∘ id ≈⟨ identityʳ ⟩\n π₁ ∎\n\n swap∘⟨⟩ : swap ∘ ⟨ f , g ⟩ ≈ ⟨ g , f ⟩\n swap∘⟨⟩ {f = f} {g = g} = begin\n ⟨ π₂ , π₁ ⟩ ∘ ⟨ f , g ⟩ ≈⟨ ⟨⟩∘ ⟩\n ⟨ π₂ ∘ ⟨ f , g ⟩ , π₁ ∘ ⟨ f , g ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ project₂ project₁ ⟩\n ⟨ g , f ⟩ ∎\n\n swap∘⁂ : swap ∘ (f ⁂ g) ≈ (g ⁂ f) ∘ swap\n swap∘⁂ {f = f} {g = g} = begin\n swap ∘ (f ⁂ g) ≈⟨ swap∘⟨⟩ ⟩\n ⟨ g ∘ π₂ , f ∘ π₁ ⟩ ≈˘⟨ ⁂∘⟨⟩ ⟩\n (g ⁂ f) ∘ swap ∎\n\n swap∘swap : (swap {A}{B}) ∘ (swap {B}{A}) ≈ id\n swap∘swap = Equiv.trans swap∘⟨⟩ η\n\n assocʳ∘⟨⟩ : assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈ ⟨ ⟨ f , g ⟩ , h ⟩\n assocʳ∘⟨⟩ {f = f} {g = g} {h = h} = begin\n assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈⟨ ⟨⟩∘ ⟩\n ⟨ ⟨ π₁ , π₁ ∘ π₂ ⟩ ∘ ⟨ f , ⟨ g , h ⟩ ⟩\n , (π₂ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩\n ⟩ ≈⟨ ⟨⟩-cong₂ ⟨⟩∘ (pullʳ project₂) ⟩\n ⟨ ⟨ π₁ ∘ ⟨ f , ⟨ g , h ⟩ ⟩\n , (π₁ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩\n ⟩\n , π₂ ∘ ⟨ g , h ⟩\n ⟩ ≈⟨ ⟨⟩-cong₂ (⟨⟩-cong₂ project₁\n (pullʳ project₂ ○ project₁))\n project₂ ⟩\n ⟨ ⟨ f , g ⟩ , h ⟩ ∎\n\n assocˡ∘⟨⟩ : assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ≈ ⟨ f , ⟨ g , h ⟩ ⟩\n assocˡ∘⟨⟩ {f = f} {g = g} {h = h} = begin\n assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ≈˘⟨ refl⟩∘⟨ assocʳ∘⟨⟩ ⟩\n assocˡ ∘ assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈⟨ cancelˡ assocˡ∘assocʳ ⟩\n ⟨ f , ⟨ g , h ⟩ ⟩ ∎\n\n assocʳ∘⁂ : assocʳ ∘ (f ⁂ (g ⁂ h)) ≈ ((f ⁂ g) ⁂ h) ∘ assocʳ\n assocʳ∘⁂ {f = f} {g = g} {h = h} =\n begin\n assocʳ ∘ (f ⁂ (g ⁂ h))\n ≈⟨ refl⟩∘⟨ ⟨⟩-congˡ ⟨⟩∘ ⟩\n assocʳ ∘ ⟨ f ∘ π₁ , ⟨ (g ∘ π₁) ∘ π₂ , (h ∘ π₂) ∘ π₂ ⟩ ⟩\n ≈⟨ assocʳ∘⟨⟩ ⟩\n ⟨ ⟨ f ∘ π₁ , (g ∘ π₁) ∘ π₂ ⟩ , (h ∘ π₂) ∘ π₂ ⟩\n ≈⟨ ⟨⟩-cong₂ (⟨⟩-congˡ assoc) assoc ⟩\n ⟨ ⟨ f ∘ π₁ , g ∘ π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩\n ≈˘⟨ ⟨⟩-congʳ ⁂∘⟨⟩ ⟩\n ⟨ (f ⁂ g) ∘ ⟨ π₁ , π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩\n ≈˘⟨ ⁂∘⟨⟩ ⟩\n ((f ⁂ g) ⁂ h) ∘ assocʳ\n ∎\n\n assocˡ∘⁂ : assocˡ ∘ ((f ⁂ g) ⁂ h) ≈ (f ⁂ (g ⁂ h)) ∘ assocˡ\n assocˡ∘⁂ {f = f} {g = g} {h = h} =\n begin\n assocˡ ∘ ((f ⁂ g) ⁂ h)\n ≈⟨ refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩\n assocˡ ∘ ⟨ ⟨ (f ∘ π₁) ∘ π₁ , (g ∘ π₂) ∘ π₁ ⟩ , h ∘ π₂ ⟩\n ≈⟨ assocˡ∘⟨⟩ ⟩\n ⟨ (f ∘ π₁) ∘ π₁ , ⟨ (g ∘ π₂) ∘ π₁ , h ∘ π₂ ⟩ ⟩\n ≈⟨ ⟨⟩-cong₂ assoc (⟨⟩-congʳ assoc) ⟩\n ⟨ f ∘ π₁ ∘ π₁ , ⟨ g ∘ π₂ ∘ π₁ , h ∘ π₂ ⟩ ⟩\n ≈˘⟨ ⟨⟩-congˡ ⁂∘⟨⟩ ⟩\n ⟨ f ∘ π₁ ∘ π₁ , (g ⁂ h) ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩\n ≈˘⟨ ⁂∘⟨⟩ ⟩\n (f ⁂ (g ⁂ h)) ∘ assocˡ\n ∎\n\n Δ : ∀ {C} → C ⇒ C × C\n Δ {C} = ⟨ id {C} , id ⟩\n\n Δ∘ : Δ ∘ f ≈ ⟨ f , f ⟩\n Δ∘ {f = f} = begin\n Δ ∘ f ≈⟨ ⟨⟩∘ ⟩\n ⟨ id ∘ f , id ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ identityˡ ⟩\n ⟨ f , f ⟩ ∎\n\n ⁂∘Δ : (f ⁂ g) ∘ Δ ≈ ⟨ f , g ⟩\n ⁂∘Δ {f = f} {g = g} = begin\n (f ⁂ g) ∘ Δ ≈⟨ ⁂∘⟨⟩ ⟩\n ⟨ f ∘ id , g ∘ id ⟩ ≈⟨ ⟨⟩-cong₂ identityʳ identityʳ ⟩\n ⟨ f , g ⟩ ∎\n\n -×- : Bifunctor 𝒞 𝒞 𝒞\n -×- = record\n { F₀ = uncurry _×_\n ; F₁ = uncurry _⁂_\n ; identity = id×id product\n ; homomorphism = ⟺ ⁂∘⁂\n ; F-resp-≈ = uncurry [ product ⇒ product ]×-cong₂\n }\n\n -×_ : Obj → Functor 𝒞 𝒞\n -×_ = appʳ -×-\n\n _×- : Obj → Functor 𝒞 𝒞\n _×- = appˡ -×-\n", "meta": {"hexsha": "42371d4cd63955d24fe253cbd259b91ec1d969ac", "size": 7390, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/BinaryProducts.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/BinaryProducts.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/BinaryProducts.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.5371900826, "max_line_length": 105, "alphanum_fraction": 0.4297699594, "num_tokens": 3746, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778257, "lm_q2_score": 0.7057850340255387, "lm_q1q2_score": 0.5984829531992535}} {"text": "module FOLsequent where\n\nopen import Data.Empty\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.String using (String)\nopen import Data.Sum\nopen import Relation.Binary.PropositionalEquality as PropEq\n using (_≡_; _≢_; refl; sym; cong; subst)\nopen import Relation.Nullary\nopen import Data.List.Base as List using (List; []; _∷_; [_]; _++_)\nopen import Data.List.Any as LAny\nopen LAny.Membership-≡\n\ndata Term : Set where\n $ : ℕ → Term\n Fun : String → List Term → Term\n\nConst : String -> Term\nConst n = Fun n []\n\ndata Formula : Set where\n _⟨_⟩ : String → List Term → Formula\n _∧_ : Formula → Formula → Formula\n _∨_ : Formula → Formula → Formula\n _⟶_ : Formula → Formula → Formula\n ~_ : Formula → Formula\n All : (Term → Formula) → Formula\n Ex : (Term → Formula) → Formula\n\n-- data Structure : Set where\n-- ∣_∣ : Formula → Structure\n-- _,,_ : Structure → Structure → Structure\n-- Ø : Structure\n\n\nStructure = List Formula\n\nmutual\n FVt : Term → List ℕ\n FVt ($ x) = [ x ]\n FVt (Fun _ args) = FVlst args\n\n FVlst : List Term -> List ℕ\n FVlst [] = []\n FVlst (x ∷ xs) = (FVt x) ++ (FVlst xs)\n\n FVf : Formula → List ℕ\n FVf (_ ⟨ lst ⟩) = FVlst lst\n FVf (f ∧ f₁) = FVf f ++ FVf f₁\n FVf (f ∨ f₁) = FVf f ++ FVf f₁\n FVf (f ⟶ f₁) = FVf f ++ FVf f₁\n FVf (~ f) = FVf f\n FVf (All x) = FVf (x (Const \"\"))\n FVf (Ex x) = FVf (x (Const \"\"))\n\nFV : Structure → List ℕ\nFV [] = []\nFV (f ∷ l) = FVf f ++ FV l\n\n_#_ : ℕ -> List ℕ -> Set\nx # xs = x ∉ xs\n\n∪ : List ℕ -> ℕ\n∪ [] = 0\n∪ (x ∷ xs) = x ⊔ (∪ xs)\n\n∃# : List ℕ -> ℕ\n∃# xs = suc (∪ xs)\n\n\n------------------------------------------------------------------------------------\n\nℕ-meet-dist : ∀ {x y z : ℕ} -> (x ≤ y) ⊎ (x ≤ z) -> x ≤ y ⊔ z\nℕ-meet-dist {zero} x≤y⊎x≤z = z≤n\nℕ-meet-dist {suc x} {zero} {zero} (inj₁ ())\nℕ-meet-dist {suc x} {zero} {zero} (inj₂ ())\nℕ-meet-dist {suc x} {zero} {suc z} (inj₁ ())\nℕ-meet-dist {suc x} {zero} {suc z} (inj₂ sx≤sz) = sx≤sz\nℕ-meet-dist {suc x} {suc y} {zero} (inj₁ sx≤sy) = sx≤sy\nℕ-meet-dist {suc x} {suc y} {zero} (inj₂ ())\nℕ-meet-dist {suc x} {suc y} {suc z} (inj₁ (s≤s x≤y)) = s≤s (ℕ-meet-dist (inj₁ x≤y))\nℕ-meet-dist {suc x} {suc y} {suc z} (inj₂ (s≤s y≤z)) =\n s≤s (ℕ-meet-dist {_} {y} {z} (inj₂ y≤z))\n------------------------------------------------------------------------------------\n\n≤-refl : ∀ {x : ℕ} -> x ≤ x\n≤-refl {zero} = z≤n\n≤-refl {suc x} = s≤s ≤-refl\n------------------------------------------------------------------------------------\n\n∈-cons : ∀ {L} {x y : ℕ} -> x ∈ (y ∷ L) -> ¬(x ≡ y) -> x ∈ L\n∈-cons {[]} (here refl) ¬x≡y = ⊥-elim (¬x≡y refl)\n∈-cons {[]} (there ()) ¬x≡y\n∈-cons {y ∷ L} {x} (here refl) ¬x≡y = ⊥-elim (¬x≡y refl)\n∈-cons {y ∷ L} {x} (there x∈L) ¬x≡y = x∈L\n------------------------------------------------------------------------------------\n\n∃#-lemma' : ∀ x L -> x ∈ L -> x ≤ ∪ L\n∃#-lemma' x [] ()\n∃#-lemma' x (y ∷ L) x∈y∷L with x ≟ y\n∃#-lemma' x (.x ∷ L) x∈y∷L | yes refl = ℕ-meet-dist {x} {x} (inj₁ ≤-refl)\n∃#-lemma' x (y ∷ L) x∈y∷L | no ¬x≡y =\n ℕ-meet-dist {x} {y} (inj₂ (∃#-lemma' x L (∈-cons x∈y∷L ¬x≡y)))\n------------------------------------------------------------------------------------\n\n∃#-lemma'' : ∀ x L -> x ∈ L -> ¬ (x ≡ ∃# L)\n∃#-lemma'' .(suc (∪ L)) L x∈L refl =\n 1+n≰n {∪ L} (∃#-lemma' (suc (∪ L)) L x∈L)\n------------------------------------------------------------------------------------\n\n∃#-lemma : ∀ L -> ∃# L ∉ L\n∃#-lemma L ∃#L∈L = ∃#-lemma'' (∃# L) L ∃#L∈L refl\n\n\ndata _⊢_ : Structure → Structure → Set where\n I : ∀ {A} → [ A ] ⊢ [ A ]\n Cut : ∀ A {Γ Σ Δ Π} →\n Γ ⊢ (Δ ++ [ A ]) → ([ A ] ++ Σ) ⊢ Π →\n ------------------------------------\n (Γ ++ Σ) ⊢ (Δ ++ Π)\n ∧L₁ : ∀ {Γ Δ A B} → (Γ ++ [ A ]) ⊢ Δ → (Γ ++ [ A ∧ B ]) ⊢ Δ\n ∧L₂ : ∀ {Γ Δ A B} → (Γ ++ [ B ]) ⊢ Δ → (Γ ++ [ A ∧ B ]) ⊢ Δ\n ∧R : ∀ {Γ Σ Δ Π A B} →\n Γ ⊢ ([ A ] ++ Δ) → Σ ⊢ ([ B ] ++ Π) →\n -----------------------------------\n (Γ ++ Σ) ⊢ ([ A ∧ B ] ++ Δ ++ Π)\n ∨R₁ : ∀ {Γ Δ A B} → Γ ⊢ ([ A ] ++ Δ) → Γ ⊢ ([ A ∨ B ] ++ Δ)\n ∨R₂ : ∀ {Γ Δ A B} → Γ ⊢ ([ B ] ++ Δ) → Γ ⊢ ([ A ∨ B ] ++ Δ)\n ∨L : ∀ {Γ Σ Δ Π A B} →\n (Γ ++ [ A ]) ⊢ Δ → (Σ ++ [ B ]) ⊢ Π →\n -----------------------------------\n (Γ ++ Σ ++ [ A ∨ B ]) ⊢ (Δ ++ Π)\n ⟶L : ∀ {Γ Σ Δ Π A B} →\n Γ ⊢ ([ A ] ++ Δ) → (Σ ++ [ B ]) ⊢ Π →\n ------------------------------------\n (Γ ++ Σ ++ [ A ⟶ B ]) ⊢ (Δ ++ Π)\n ⟶R : ∀ {Γ Δ A B} → (Γ ++ [ A ]) ⊢ ([ B ] ++ Δ) → Γ ⊢ ([ A ⟶ B ] ++ Δ)\n ~L : ∀ {Γ Δ A} → Γ ⊢ ([ A ] ++ Δ) → (Γ ++ [ ~ A ]) ⊢ Δ\n ~R : ∀ {Γ Δ A} → (Γ ++ [ A ]) ⊢ Δ → Γ ⊢ ([ ~ A ] ++ Δ)\n AllL : ∀ {Γ Δ A t} → (Γ ++ [ A t ]) ⊢ Δ → (Γ ++ [ All A ]) ⊢ Δ\n AllR : ∀ {Γ Δ A y} →\n Γ ⊢ ([ A ($ y) ] ++ Δ) → (y-fresh : y # FV (Γ ++ Δ)) →\n ----------------------\n Γ ⊢ ([ All A ] ++ Δ)\n ExL : ∀ {Γ Δ A y} →\n (Γ ++ [ A ($ y) ]) ⊢ Δ → (y-fresh : y # FV (Γ ++ Δ)) →\n ----------------------\n (Γ ++ [ Ex A ]) ⊢ Δ\n ExR : ∀ {Γ Δ A t} → Γ ⊢ ([ A t ] ++ Δ) → Γ ⊢ ([ Ex A ] ++ Δ)\n WL : ∀ {Γ Δ A} → Γ ⊢ Δ → (Γ ++ [ A ]) ⊢ Δ\n WR : ∀ {Γ Δ A} → Γ ⊢ Δ → Γ ⊢ ([ A ] ++ Δ)\n CL : ∀ {Γ Δ A} → (Γ ++ [ A ] ++ [ A ]) ⊢ Δ → (Γ ++ [ A ]) ⊢ Δ\n CR : ∀ {Γ Δ A} → Γ ⊢ ([ A ] ++ [ A ] ++ Δ) → Γ ⊢ ([ A ] ++ Δ)\n PL : ∀ {Γ₁ Γ₂ Δ A B} →\n (Γ₁ ++ [ A ] ++ [ B ] ++ Γ₂) ⊢ Δ →\n ------------------------------------\n (Γ₁ ++ [ B ] ++ [ A ] ++ Γ₂) ⊢ Δ\n PR : ∀ {Γ Δ₁ Δ₂ A B} →\n Γ ⊢ (Δ₁ ++ [ A ] ++ [ B ] ++ Δ₂) →\n ------------------------------------\n Γ ⊢ (Δ₁ ++ [ B ] ++ [ A ] ++ Δ₂)\n\n\nPL' : ∀ {A B Δ} -> (A ∷ [ B ]) ⊢ Δ → (B ∷ [ A ]) ⊢ Δ\nPL' {A} {B} A,B⊢Δ = PL {[]} {[]} {_} {A} {B} A,B⊢Δ\n\nPR' : ∀ {A B Γ} -> Γ ⊢ (A ∷ [ B ]) → Γ ⊢ (B ∷ [ A ])\nPR' {A} {B} Γ⊢A,B = PR {_} {[]} {[]} {A} {B} Γ⊢A,B\n\n\n_>>_ : ∀ {A B : Set} -> (A → B) -> A -> B\nA→B >> A = A→B A\n\nopen import Data.Product\n_>>₂_ : ∀ {A B C : Set} -> (A → B → C) -> A × B -> C\nA→B→C >>₂ (A , B) = A→B→C A B\n\ninfixr 4 _>>_\ninfixr 4 _>>₂_\n\nlemma : ∀ {A B C} -> [] ⊢ [ (A ⟶ (B ∨ C)) ⟶ (((B ⟶ (~ A)) ∧ (~ C)) ⟶ (~ A)) ]\nlemma {A} {B} {C} = ⟶R >> ⟶R >> PL' >> CR >> ⟶L {[]} {[ (B ⟶ (~ A)) ∧ (~ C) ]} {[ ~ A ]} {[ ~ A ]} >>₂\n (PR' >> ~R >> I) ,\n PL' >> CL {[ B ∨ C ]} {A = (B ⟶ (~ A)) ∧ (~ C)} >> ∧L₂ {(B ∨ C) ∷ [ (B ⟶ (~ A)) ∧ (~ C) ]}\n >> PL {[ B ∨ C ]} {[]} >> ∧L₁ {(B ∨ C) ∷ [ ~ C ]} >> ⟶L {(B ∨ C) ∷ [ ~ C ]} {[]} {[]} >>₂\n (~L {[ B ∨ C ]} >> PR' >> ∨L {[]} {[]} {[ B ]} >>₂ I , I) ,\n I\n\n\n\n-- AllR {y = y} (AllL {[]} {t = $ y} I) y-fresh\n-- where\n-- y = ∃# (FV [ All (λ x → P ⟨ [ x ] ⟩) ])\n-- y-fresh = ∃#-lemma (FV [ All (λ x → P ⟨ [ x ] ⟩) ])\n\nAllR# : ∀ {Γ Δ A} → Γ ⊢ ([ A ($ (∃# (FV (Γ ++ Δ)))) ] ++ Δ) → Γ ⊢ ([ All A ] ++ Δ)\nAllR# {Γ} {Δ} Γ⊢[y/x]A,Δ = AllR Γ⊢[y/x]A,Δ (∃#-lemma (FV (Γ ++ Δ)))\n\nExL# : ∀ {Γ Δ A} → (Γ ++ [ A ($ (∃# (FV (Γ ++ Δ)))) ]) ⊢ Δ → (Γ ++ [ Ex A ]) ⊢ Δ\nExL# {Γ} {Δ} Γ,[y/x]A⊢Δ = ExL {Γ} Γ,[y/x]A⊢Δ (∃#-lemma (FV (Γ ++ Δ)))\n\nlemma₁ : ∀ {P} → [ All (λ x → P ⟨ [ x ] ⟩) ] ⊢ [ All (λ y → P ⟨ [ y ] ⟩) ]\nlemma₁ {P} = AllR# (AllL {[]} I)\n\n\nlemma₂ : ∀ {P} →\n [ Ex (λ y → All (λ x → P ⟨ x ∷ [ y ] ⟩)) ] ⊢ [ All (λ x → Ex (λ y → P ⟨ x ∷ [ y ] ⟩)) ]\nlemma₂ {P} = AllR# >> ExL# {[]} >> ExR >> AllL {[]} >> I\n", "meta": {"hexsha": "46a1d051bce0214a790f216cc534f3dd53bcc206", "size": 7028, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "FOLsequent.agda", "max_stars_repo_name": "goodlyrottenapple/FOLdisplay", "max_stars_repo_head_hexsha": "b4f3ce288633417ce309a0a1371ad0907a007b30", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FOLsequent.agda", "max_issues_repo_name": "goodlyrottenapple/FOLdisplay", "max_issues_repo_head_hexsha": "b4f3ce288633417ce309a0a1371ad0907a007b30", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FOLsequent.agda", "max_forks_repo_name": "goodlyrottenapple/FOLdisplay", "max_forks_repo_head_hexsha": "b4f3ce288633417ce309a0a1371ad0907a007b30", "max_forks_repo_licenses": ["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.4666666667, "max_line_length": 102, "alphanum_fraction": 0.3375071144, "num_tokens": 3337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677622198947, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5984829454155847}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Categories.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 Precategory\n\nmodule _ ℓ where\n SET : Precategory (ℓ-suc ℓ) ℓ\n SET .ob = Σ (Type ℓ) isSet\n SET .Hom[_,_] (A , _) (B , _) = A → B\n SET .id _ = λ x → x\n SET ._⋆_ f g = λ x → g (f x)\n SET .⋆IdL f = refl\n SET .⋆IdR f = refl\n SET .⋆Assoc f g h = refl\n\nmodule _ {ℓ} where\n isSetExpIdeal : {A B : Type ℓ} → isSet B → isSet (A → B)\n isSetExpIdeal B/set = isSetΠ λ _ → B/set\n\n isSetLift : {A : Type ℓ} → isSet A → isSet (Lift {ℓ} {ℓ-suc ℓ} A)\n isSetLift = isOfHLevelLift 2\n\n module _ {A B : SET ℓ .ob} where\n -- monic/surjectiveness\n open import Cubical.Categories.Morphism\n isSurjSET : (f : SET ℓ [ A , B ]) → Type _\n isSurjSET f = ∀ (b : fst B) → Σ[ a ∈ fst A ] f a ≡ b\n\n -- isMonic→isSurjSET : {f : SET ℓ [ A , B ]}\n -- → isEpic {C = SET ℓ} {x = A} {y = B} f\n -- → isSurjSET f\n -- isMonic→isSurjSET ism b = {!!} , {!!}\n\n instance\n SET-category : isCategory (SET ℓ)\n SET-category .isSetHom {_} {B , B/set} = isSetExpIdeal B/set\n\nprivate\n variable\n ℓ ℓ' : Level\n\nopen Functor\n\n-- Hom functors\n_[-,_] : (C : Precategory ℓ ℓ') → (c : C .ob) → ⦃ isCat : isCategory C ⦄ → Functor (C ^op) (SET _)\n(C [-, c ]) ⦃ isCat ⦄ .F-ob x = (C [ x , c ]) , isCat .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 : Precategory ℓ ℓ') → (c : C .ob) → ⦃ isCat : isCategory C ⦄ → Functor C (SET _)\n(C [ c ,-]) ⦃ isCat ⦄ .F-ob x = (C [ c , x ]) , isCat .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 : Precategory ℓ ℓ'} ⦃ _ : isCategory C ⦄ {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 {C = 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": "0007b441a6e07f044c0619a5cc2b12ca486fb40c", "size": 3053, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Sets.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/Sets.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/Sets.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": 32.4787234043, "max_line_length": 98, "alphanum_fraction": 0.5158860138, "num_tokens": 1295, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677506936878, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5984829425282322}} {"text": "module FunctionProofs where\nopen FunctionSet ⦃ signature ⦄\n\n[∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] : ∀{D : Domain}{P : BinaryRelator} → Proof(∀ₗ(x ↦ ∃ₗ(y ↦ (x ∈ D) ⟶ P(x)(y))) ⟷ ∀ₛ(D)(x ↦ ∃ₗ(y ↦ P(x)(y))))\n[∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] {D}{P} = [↔]-with-[∀] ([∃]-unrelatedᵣ-[→])\n\n[∀ₛ∃!]-to[∀ₛ∃] : ∀{P : BinaryRelator}{D : Domain} → Proof(∀ₛ(D)(x ↦ ∃ₗ!(y ↦ P(x)(y)))) → Proof(∀ₛ(D)(x ↦ ∃ₗ(y ↦ P(x)(y))))\n[∀ₛ∃!]-to[∀ₛ∃] proof =\n ([∀ₛ]-intro(\\{x} → xinD ↦\n [∧].elimₗ([∀ₛ]-elim proof {x} xinD)\n ))\n\n-- The construction of a meta-function in the meta-logic from a function in the set theory\nfnset-witness : ∀{D} → (f : Domain) → ⦃ _ : Proof(Total(D)(f)) ⦄ → Function\nfnset-witness f ⦃ proof ⦄ = [∃]-fn-witness ⦃ [↔].elimₗ [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] (proof) ⦄\n\nfnset-value : ∀{D} → (f : Domain) → ⦃ proof : Proof(Total(D)(f)) ⦄ → Proof(∀ₛ(D)(x ↦ (x , fnset-witness f(x)) ∈ f))\nfnset-value{D} f ⦃ proof ⦄ = [∃]-fn-proof ⦃ [↔].elimₗ [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] (proof) ⦄\n\nfnset-proof : ∀{D} → (f : Domain) → ⦃ _ : Proof(FunctionSet(f)) ⦄ → ⦃ total : Proof(Total(D)(f)) ⦄ → Proof(∀ₛ(D)(x ↦ ∀ₗ(y ↦ (fnset-witness{D} f ⦃ total ⦄ x ≡ y) ⟷ ((x , y) ∈ f))))\nfnset-proof{D} f ⦃ function ⦄ ⦃ total ⦄ =\n ([∀ₛ]-intro(\\{x} → x∈D ↦\n ([∀].intro(\\{y} →\n ([↔].intro\n (xy∈f ↦\n ([→].elim\n ([∀].elim([∀].elim([∀].elim function{x}) {fnset-witness f(x)}) {y})\n ([∧].intro\n ([∀ₛ]-elim(fnset-value f) {x} (x∈D))\n (xy∈f)\n )\n )\n )\n\n (fx≡y ↦\n [≡].elimᵣ (fx≡y) ([∀ₛ]-elim (fnset-value(f)) {x} (x∈D))\n )\n )\n ))\n ))\n\n[→ₛₑₜ]-witness : ∀{A B} → (f : Domain) → ⦃ _ : Proof(f ∈ (A →ₛₑₜ B)) ⦄ → Function\n[→ₛₑₜ]-witness f ⦃ proof ⦄ (x) =\n (fnset-witness f\n ⦃ [∧].elimᵣ([∧].elimᵣ([↔].elimᵣ\n ([∀].elim([∀].elim filter-membership))\n (proof)\n )) ⦄\n (x)\n )\n", "meta": {"hexsha": "1b02fbfbac81799074fb464e0521f87b97b6383e", "size": 1872, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/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": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/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": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/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.7058823529, "max_line_length": 179, "alphanum_fraction": 0.4588675214, "num_tokens": 963, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314617436728, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.5984783856120514}} {"text": "module Numeral.Natural.Oper.Modulo.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.Modulo\nopen import Numeral.Natural.Oper.Modulo.Proofs.Algorithm\nopen import Numeral.Natural.Relation.DivisibilityWithRemainder hiding (base₀ ; base₊ ; step)\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Relator\nopen import Syntax.Transitivity\n\n-- The remainder of the divisibility relation is given by the modulo operation.\n[mod][∣ᵣₑₘ]-remainder-equality : ∀{x y r}{p : (𝐒(y) ∣ᵣₑₘ x)(r)} → ((x mod 𝐒(y)) ≡ 𝕟-to-ℕ ([∣ᵣₑₘ]-remainder p))\n[mod][∣ᵣₑₘ]-remainder-equality {𝟎} {_} {𝟎} {DivRem𝟎} = [≡]-intro\n[mod][∣ᵣₑₘ]-remainder-equality {𝐒 .(𝕟-to-ℕ r)} {𝐒 y} {𝐒 r} {DivRem𝟎} = mod'-lesser-dividend {1}{𝐒(y)}{𝕟-to-ℕ r}{y} ([≤]-without-[𝐒] 𝕟.bounded)\n[mod][∣ᵣₑₘ]-remainder-equality {𝐒 x} {𝟎} {𝟎} {DivRem𝐒 p} = mod'-zero-all-except-dividend {x}\n{-# CATCHALL #-}\n[mod][∣ᵣₑₘ]-remainder-equality {𝐒 .(x + y)} {y} {r} {DivRem𝐒 {x = x} p} =\n ([ 𝟎 , y ] 𝐒(x + y) mod' y) 🝖[ _≡_ ]-[]\n ([ 𝟎 , y ] (𝐒(x) + y) mod' y) 🝖[ _≡_ ]-[ mod'-sumᵣ-modulo {0}{y}{x}{y} ]\n ([ 𝟎 , y ] x mod' y) 🝖[ _≡_ ]-[ [mod][∣ᵣₑₘ]-remainder-equality {p = p} ]\n 𝕟-to-ℕ ([∣ᵣₑₘ]-remainder p) 🝖[ _≡_ ]-[]\n 𝕟-to-ℕ ([∣ᵣₑₘ]-remainder (DivRem𝐒 p)) 🝖-end\n", "meta": {"hexsha": "0a3cfee32acdb18126f0021fef6846a1a4907937", "size": 1542, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/Modulo/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/Modulo/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/Modulo/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": 51.4, "max_line_length": 142, "alphanum_fraction": 0.6335927367, "num_tokens": 686, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511616741042, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.598457703204965}} {"text": "{-# OPTIONS --without-K #-}\nmodule Model.Stream where\n\nopen import Model.Size as MS using\n ( Size ; Sizes ; _≤_ ; _<_ ; ≤-IsProp ; ≤-trans ; nat )\nopen import Model.Type.Core\nopen import Util.HoTT.FunctionalExtensionality\nopen import Util.HoTT.HLevel\nopen import Util.Prelude\n\nimport Data.Nat.Properties as ℕ\n\nopen Size\n\n\nColist : Size → Set\nColist n = ∀ m → nat m ≤ n → ℕ\n\n\nabstract\n Colist-≡⁺ : ∀ {n} {xs ys : Colist n}\n → (∀ m m≤n → xs m m≤n ≡ ys m m≤n)\n → xs ≡ ys\n Colist-≡⁺ eq = funext λ m → funext λ m≤n → eq m m≤n\n\n\n Colist-≡⁻ : ∀ {n} {xs ys : Colist n}\n → xs ≡ ys\n → ∀ m m≤n₀ m≤n₁ → xs m m≤n₀ ≡ ys m m≤n₁\n Colist-≡⁻ {xs = xs} refl m m≤n₀ m≤n₁ = cong (xs m) (≤-IsProp _ _)\n\n\n Colist-IsSet : ∀ {n} → IsSet (Colist n)\n Colist-IsSet = ∀-IsSet λ m → ∀-IsSet λ m≤n → ℕ.≡-irrelevant\n\n\ncastColist : ∀ {n m} → n ≤ m → Colist m → Colist n\ncastColist n≤m xs k k≤n = xs k go\n where abstract go = ≤-trans k≤n n≤m\n\n\nStream : ⟦Type⟧ Sizes\nStream = record\n { ObjHSet = λ n → HLevel⁺ (Colist n) Colist-IsSet\n ; eqHProp = λ {n} {n′} _ xs ys\n → ∀-HProp ℕ λ m → ∀-HProp (nat m ≤ n) λ m≤n → ∀-HProp (nat m ≤ n′) λ m≤n′\n → HLevel⁺ (xs m m≤n ≡ ys m m≤n′) ℕ.≡-irrelevant\n ; eq-refl = λ x m m≤n m≤n′ → cong (x m) (≤-IsProp _ _)\n }\n\n\ncons : ∀ {n} → ℕ → (∀ m → m < n → Colist m) → Colist n\ncons x xs zero _ = x\ncons x xs (suc k) Sk≤n = xs (nat k) go k MS.≤-refl\n where abstract go = MS.Sn≤m→n_ : Tm -> Tm -> Set\n diamond : ∀{M N P : Tm} → (M => N) → (M => P) →\n Σ[ Q :: Tm ] (N => Q × P => Q)\n\n\ndata _=>*_ : Tm → Tm → Set where\n eval-refl : {e : Tm} → e =>* e\n eval-cons : {e e' e'' : Tm} → \n (S1 : e => e') → (D : e' =>* e'') → e =>* e''\n\nstrip : ∀{M N P : Tm} → (M => N) → (M =>* P) →\n Σ[ Q :: Tm ] (N =>* Q × P => Q)\nstrip S1 eval-refl = , (eval-refl , S1)\nstrip S1 (eval-cons S2 D) with diamond S1 S2\n... | Q' , S1' , S2' with strip S2' D\n... | Q , D1 , S' = Q , ((eval-cons S1' D1) , S')\n\nconfluence : ∀{M N P : Tm} → (M =>* N) → (M =>* P) →\n Σ[ Q :: Tm ] (N =>* Q × P =>* Q)\nconfluence eval-refl D2 = , (D2 , eval-refl)\nconfluence (eval-cons S1 D1) D2 with strip S1 D2\n... | M' , D3 , S3 with confluence D1 D3\n... | Q , D4 , D4' = Q , D4 , eval-cons S3 D4'\n", "meta": {"hexsha": "9d5c78c188f580d91397aa36765e82dcb5501635", "size": 974, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Confluence.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": "Confluence.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": "Confluence.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": 30.4375, "max_line_length": 82, "alphanum_fraction": 0.4681724846, "num_tokens": 411, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.5977891974388738}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import cohomology.Theory\n\n{- Cohomology groups of the n-torus (S¹)ⁿ.\n - We have Ĉᵏ(Tⁿ) == C⁰(S⁰)^(n choose' k) where _choose'_ defined as below.\n - This argument could give Cᵏ((Sᵐ)ⁿ) with a little more work. -}\n\nmodule cohomology.Torus {i} (OT : OrdinaryTheory i) where\n\nopen OrdinaryTheory OT\nopen import cohomology.Sn OT\nopen import cohomology.SphereProduct cohomology-theory\nopen import cohomology.Unit cohomology-theory\n\n\n{- Almost n choose k, but with n choose' O = 0 for any n. -}\n_choose'_ : ℕ → ℤ → ℕ\nn choose' (neg _) = 0\nn choose' O = 0\nn choose' pos O = n\nO choose' (pos (S k)) = 0\nS n choose' pos (S k) = (n choose' (pos k)) + (n choose' (pos (S k)))\n\n\n_-⊙Torus : ℕ → Ptd i\nO -⊙Torus = ⊙Lift ⊙Unit\n(S n) -⊙Torus = (⊙Sphere {i} 1) ⊙× (n -⊙Torus)\n\nC-nTorus : (k : ℤ) (n : ℕ)\n → C k (n -⊙Torus) == (C O (⊙Sphere 0)) ^ᴳ (n choose' k)\n\nC-nTorus (neg k) O = C-Unit-is-trivial (neg k)\n\nC-nTorus (neg k) (S n) =\n C-Sphere× (neg k) 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C (neg k) (⊙Susp^ 1 (n -⊙Torus))\n ×ᴳ C (neg k) (n -⊙Torus)))\n (C-Sphere-≠ (neg k) 1 (ℤ-neg≠pos _ _))\n ∙ ×ᴳ-unit-l {G = C (neg k) (⊙Susp (n -⊙Torus))\n ×ᴳ C (neg k) (n -⊙Torus)}\n ∙ ap (λ K → C (neg k) (⊙Susp (n -⊙Torus)) ×ᴳ K)\n (C-nTorus (neg k) n)\n ∙ ×ᴳ-unit-r {G = C (neg k) (⊙Susp (n -⊙Torus))}\n ∙ C-Susp (neg (S k)) (n -⊙Torus)\n ∙ C-nTorus (neg (S k)) n\n\nC-nTorus O O = C-Unit-is-trivial O\n\nC-nTorus O (S n) =\n C-Sphere× O 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C O (⊙Susp (n -⊙Torus)) ×ᴳ C O (n -⊙Torus)))\n (C-Sphere-≠ O 1 (ℤ-O≠pos _))\n ∙ ×ᴳ-unit-l {G = C O (⊙Susp (n -⊙Torus)) ×ᴳ C O (n -⊙Torus)}\n ∙ ap (λ K → C O (⊙Susp (n -⊙Torus)) ×ᴳ K)\n (C-nTorus O n)\n ∙ ×ᴳ-unit-r {G = C O (⊙Susp (n -⊙Torus))}\n ∙ C-Susp (neg O) (n -⊙Torus)\n ∙ C-nTorus (neg O) n\n\nC-nTorus (pos O) O =\n C-Unit-is-trivial (pos O)\n\nC-nTorus (pos O) (S n) =\n C-Sphere× (pos O) 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C (pos O) (⊙Susp (n -⊙Torus))\n ×ᴳ C (pos O) (n -⊙Torus)))\n (C-Sphere-diag 1)\n ∙ ap (λ K → C O (⊙Sphere O) ×ᴳ K)\n (ap2 _×ᴳ_\n (C-Susp O (n -⊙Torus) ∙ C-nTorus O n)\n (C-nTorus (pos O) n)\n ∙ ×ᴳ-unit-l {G = C O (⊙Sphere 0) ^ᴳ (n choose' pos O)})\n\nC-nTorus (pos (S k)) O =\n C-Unit-is-trivial (pos (S k))\n\nC-nTorus (pos (S k)) (S n) =\n C-Sphere× (pos (S k)) 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C (pos (S k)) (⊙Susp (n -⊙Torus))\n ×ᴳ C (pos (S k)) (n -⊙Torus)))\n (C-Sphere-≠ (pos (S k)) 1 (ℕ-S≠O k ∘ pos-injective (S k) 0))\n ∙ ×ᴳ-unit-l {G = (C (pos (S k)) (⊙Susp (n -⊙Torus))\n ×ᴳ (C (pos (S k)) (n -⊙Torus)))}\n ∙ ap2 _×ᴳ_ (C-Susp (pos k) (n -⊙Torus) ∙ C-nTorus (pos k) n)\n (C-nTorus (pos (S k)) n)\n ∙ ^ᴳ-sum (C O (⊙Sphere 0)) (n choose' pos k) (n choose' pos (S k))\n", "meta": {"hexsha": "92ad38abee8a5cd1dc9a1c798017cd838cef2532", "size": 2850, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "cohomology/Torus.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/Torus.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/Torus.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": 32.0224719101, "max_line_length": 76, "alphanum_fraction": 0.5028070175, "num_tokens": 1429, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.6825737279551493, "lm_q1q2_score": 0.5977891917837641}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of operations on floats\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Float.Properties where\n\nopen import Data.Bool.Base as Bool using (Bool)\nopen import Data.Float.Base\nimport Data.Word.Base as Word\nimport Data.Word.Properties as Wₚ\nopen import Relation.Nullary.Decidable as RN using (map′)\nopen import Relation.Binary\nimport Relation.Binary.Construct.On as On\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- Primitive properties\n\nopen import Agda.Builtin.Float.Properties\n renaming (primFloatToWord64Injective to toWord-injective)\n public\n\n------------------------------------------------------------------------\n-- Properties of _≈_\n\n≈⇒≡ : _≈_ ⇒ _≡_\n≈⇒≡ eq = toWord-injective _ _ (Wₚ.≈⇒≡ eq)\n\n≈-reflexive : _≡_ ⇒ _≈_\n≈-reflexive eq = Wₚ.≈-reflexive (cong toWord eq)\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 _≈_\n_≈?_ = On.decidable toWord Word._≈_ Wₚ._≈?_\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 Float\nx ≟ y = map′ ≈⇒≡ ≈-reflexive (x ≈? y)\n\n≡-setoid : Setoid _ _\n≡-setoid = setoid Float\n\n≡-decSetoid : DecSetoid _ _\n≡-decSetoid = decSetoid _≟_\n\n------------------------------------------------------------------------\n-- Boolean equality test.\n\ninfix 4 _==_\n_==_ : Float → Float → Bool\nw₁ == w₂ = RN.⌊ w₁ ≟ w₂ ⌋\n\n------------------------------------------------------------------------\n-- Properties of _<_\n\ninfix 4 _>=_)\nopen import Data.String using (String; toVec; _==_; strictTotalOrder)\n renaming (_++_ to _∥_)\nopen import Data.Product using (_×_; _,_; proj₁)\nopen import Coinduction\nopen import IO\n\nopen import Relation.Binary\nopen StrictTotalOrder Data.String.strictTotalOrder renaming (compare to str_cmp)\n\ndata Order : Set where\n LT EQ GT : Order\n\nmodule InsertionSort where\n insert : {A : Set} → (A → A → Order) → A → List A → List A\n insert _ e [] = e ∷ []\n insert cmp e (l ∷ ls) with cmp e l\n ... | GT = l ∷ insert cmp e ls\n ... | _ = e ∷ l ∷ ls\n\n sort : {A : Set} → (A → A → Order) → List A → List A\n sort cmp = foldr (insert cmp) []\nopen InsertionSort using (insert; sort)\n\n\n-- Universe U exists of type U and el : U → Set\ndata U : Set where\n CHAR NAT BOOL : U\n VEC : U → ℕ → U\n \nel : U → Set\nel CHAR = Char\nel NAT = ℕ\nel (VEC u n) = Vec (el u) n\nel BOOL = Bool\n\nparens : String → String\nparens str = \"(\" ∥ str ∥ \")\"\n\nshow : {u : U} → el u → String\nshow {CHAR } c = charToString c\nshow {NAT } zero = \"Zero\"\nshow {NAT } (suc k) = \"Succ \" ∥ parens (show k)\nshow {VEC u zero } Nil = \"Nil\"\nshow {VEC u (suc k)} (x ∷ xs) = parens (show x) ∥ \" ∷ \" ∥ parens (show xs)\nshow {BOOL } true = \"True\"\nshow {BOOL } false = \"False\"\n\n_=ᴺ_ : ℕ → ℕ → Bool\nzero =ᴺ zero = true\nsuc m =ᴺ suc n = (m =ᴺ n)\n_ =ᴺ _ = false\n\n_≤ᴺ_ : ℕ → ℕ → Order\nzero ≤ᴺ zero = EQ\nzero ≤ᴺ _ = LT\n_ ≤ᴺ zero = GT\nsuc a ≤ᴺ suc b = a ≤ᴺ b\n\n_=ᵁ_ : U → U → Bool\nCHAR =ᵁ CHAR = true\nNAT =ᵁ NAT = true\nBOOL =ᵁ BOOL = true\nVEC u x =ᵁ VEC u' x' = (u =ᵁ u') ∧ (x =ᴺ x')\n_ =ᵁ _ = false\n\n_≤ᵁ_ : U → U → Order\nCHAR ≤ᵁ CHAR = EQ\nCHAR ≤ᵁ _ = LT\n_ ≤ᵁ CHAR = GT\nNAT ≤ᵁ NAT = EQ\nNAT ≤ᵁ _ = LT\n_ ≤ᵁ NAT = GT\nBOOL ≤ᵁ BOOL = EQ\nBOOL ≤ᵁ _ = LT\n_ ≤ᵁ BOOL = GT\nVEC a x ≤ᵁ VEC b y with a ≤ᵁ b\n... | LT = LT\n... | EQ = x ≤ᴺ y\n... | GT = GT\n\n\nSo : Bool → Set\nSo true = ⊤\nSo false = ⊥\n\ndata SqlValue : Set where\n SqlString : String → SqlValue\n SqlChar : Char → SqlValue\n SqlBool : Bool → SqlValue\n SqlInteger : ℤ → SqlValue\n--{-# COMPILED_DATA SqlValue SqlValue SqlString SqlChar SqlBool SqlInteger #-}\n\nmodule OrderedSchema where\n SchemaDescription = List (List SqlValue)\n\n Attribute : Set\n Attribute = String × U\n\n -- Compare on type if names are equal.\n -- SQL DB's probably don't allow columns with the same name\n -- but nothing prevents us from writing a Schema that does,\n -- this is necessary to make our sort return a unique answer.\n attr_cmp : Attribute → Attribute → Order\n attr_cmp (nm₁ , U₁) (nm₂ , U₂) with str_cmp nm₁ nm₂ | U₁ ≤ᵁ U₂\n ... | tri< _ _ _ | _ = LT\n ... | tri≈ _ _ _ | U₁≤U₂ = U₁≤U₂\n ... | tri> _ _ _ | _ = GT\n\n\n data Schema : Set where\n sorted : List Attribute → Schema\n\n mkSchema : List Attribute → Schema\n mkSchema xs = sorted (sort attr_cmp xs)\n\n expandSchema : Attribute → Schema → Schema\n expandSchema x (sorted xs) = sorted (insert attr_cmp x xs)\n\n schemify : SchemaDescription → Schema\n schemify sdesc = {!!}\n\n\n disjoint : Schema → Schema → Bool\n disjoint (sorted [] ) (_ ) = true\n disjoint (_ ) (sorted [] ) = true\n disjoint (sorted (x ∷ xs)) (sorted (y ∷ ys)) with attr_cmp x y\n ... | LT = disjoint (sorted xs ) (sorted (y ∷ ys))\n ... | EQ = false\n ... | GT = disjoint (sorted (x ∷ xs)) (sorted ys )\n\n sub : Schema → Schema → Bool\n sub (sorted [] ) (_ ) = true\n sub (sorted (x ∷ _) ) (sorted [] ) = false\n sub (sorted (x ∷ xs)) (sorted (X ∷ Xs)) with attr_cmp x X\n ... | LT = false\n ... | EQ = sub (sorted xs ) (sorted Xs)\n ... | GT = sub (sorted (x ∷ xs)) (sorted Xs)\n\n same' : List Attribute → List Attribute → Bool\n same' ([] ) ([] ) = true\n same' ((nm₁ , ty₁) ∷ xs) ((nm₂ , ty₂) ∷ ys) =\n (nm₁ == nm₂) ∧ (ty₁ =ᵁ ty₂) ∧ same' xs ys\n same' (_ ) (_ ) = false\n\n same : Schema → Schema → Bool\n same (sorted xs) (sorted ys) = same' xs ys\n\n occurs : String → Schema → Bool\n occurs nm (sorted s) = any (_==_ nm) (map (proj₁) s)\n\n lookup' : (nm : String) → (s : List Attribute)\n → So (occurs nm (sorted s)) → U\n lookup' _ [] ()\n lookup' nm ((name , type) ∷ s') p with nm == name\n ... | true = type\n ... | false = lookup' nm s' p\n\n lookup : (nm : String) → (s : Schema) → So (occurs nm s) → U\n lookup nm (sorted s) = lookup' nm s\n\n append : (s s' : Schema) → Schema\n append (sorted s) (sorted s') = mkSchema (s ++ s')\nopen OrderedSchema using (Schema; mkSchema; expandSchema; schemify;\n disjoint; sub; same; occurs; lookup;\n append)\n\n\ndata Row : Schema → Set where\n EmptyRow : Row (mkSchema [])\n ConsRow : ∀ {name u s} → el u → Row s → Row (expandSchema (name , u) s)\n\nTable : Schema → Set\nTable s = List (Row s)\n\nDatabasePath = String\nTableName = String\n\npostulate\n Connection : Set\n connectSqlite3 : DatabasePath → IO Connection\n describe_table : TableName → Connection → IO (List (List SqlValue))\n-- {-# COMPILED_TYPE Connection Connection #-}\n-- {-# COMPILED connectSqlite3 connectSqlite3 #-}\n-- {-# COMPILED describe_table describe_table #-}\n\n\ndata Handle : Schema → Set where\n conn : Connection → (s : Schema) → Handle s\n\n-- Connect currently ignores differences between\n-- the expected schema and the actual schema.\n-- According to tpop this should result in\n-- \"a *runtime exception* in the *IO* monad.\"\n-- Agda does not have exceptions(?)\n-- -> postulate error with a compiled pragma?\nconnect : DatabasePath → TableName → (s : Schema) → IO (Handle s)\nconnect DB table schema_expect =\n ♯ (connectSqlite3 DB) >>=\n (λ sqlite_conn →\n ♯ (♯ (describe_table table sqlite_conn) >>=\n (λ description →\n ♯ (♯ (return (schemify description)) >>=\n (λ schema_actual →\n ♯ (♯ (return (same schema_expect schema_actual)) >>=\n (λ { true → ♯ (return (conn sqlite_conn schema_expect));\n false → ♯ (return (conn sqlite_conn schema_expect)) })))))))\n\n\ndata Expr : Schema → U → Set where\n equal : ∀ {u s} → Expr s u → Expr s u → Expr s BOOL\n lessThan : ∀ {u s} → Expr s u → Expr s u → Expr s BOOL\n _!_ : (s : Schema) → (nm : String) → {p : So (occurs nm s)}\n → Expr s (lookup nm s p)\n\n\ndata RA : Schema → Set where\n Read : ∀ {s} → Handle s → RA s\n Union : ∀ {s} → RA s → RA s → RA s\n Diff : ∀ {s} → RA s → RA s → RA s\n Product : ∀ {s s'} → {_ : So (disjoint s s')} → RA s → RA s'\n → RA (append s s')\n Project : ∀ {s} → (s' : Schema) → {_ : So (sub s' s)} → RA s → RA s'\n Select : ∀ {s} → Expr s BOOL → RA s → RA s\n -- ...\n{- \n As we mentioned previously, we have taken a very minimal set of relational\n algebra operators. It should be fairly straightforward to add operators\n for the many other operators in relational algebra, such as the\n\n natural join, θ-join, equijoin, renaming, or division,\n\n using the same techniques. Alternatively, you can define many of these\n operations in terms of the operations we have implemented in the RA data type.\n-}\n\n\n-- We could:\npostulate\n toSQL : ∀ {s} → RA s → String\n\n-- We can do much better:\npostulate\n query : {s : Schema} → RA s → IO (List (Row s))\n{-\n The *query* function uses *toSQL* to produce a query, and passes this to the\n database server. When the server replies, however, we know exactly how to\n parse the response: we know the schema of the table resulting from our query,\n and can use this to parse the database server's response in a type-safe\n manner. The type checker can then statically check that the program uses the\n returned list in a way consistent with its type.\n-}\n\n\nCars : Schema\nCars = mkSchema ((\"Model\" , VEC CHAR 20) ∷ (\"Time\" , VEC CHAR 6)\n ∷ (\"Wet\" , BOOL) ∷ [])\n\nzonda : Row Cars\nzonda = ConsRow (toVec \"Pagani Zonda C12 F \")\n (ConsRow (toVec \"1:18.4\")\n (ConsRow false EmptyRow))\n\nModels : Schema\nModels = mkSchema ((\"Model\" , VEC CHAR 20) ∷ [])\n\nmodels : Handle Cars → RA Models\nmodels h = Project Models (Read h)\n\nwet : Handle Cars → RA Models\nwet h = Project Models (Select (Cars ! \"Wet\") (Read h))\n\n\n{- Discussion\n ==========\n\n There are many, many aspects of this proposal that can be improved. Some\n attributes of a schema contain *NULL*-values; we should close our universe\n under *Maybe* accordingly. Some database servers silently truncate strings\n longer than 255 characters. We would do well to ensure statically that this\n never happens. Our goal, however, was not to provide a complete model of all\n of SQL's quirks and idiosyncrasies: we want to show how a language with\n dependent types can schine where Haskell struggles.\n Our choice of *Schema* data type suffers from the usual disadvantages of\n using a list to represent a set: our *Schema* data type may contain\n duplicates and the order of the elements matters. The first problem is easy\n to solve. Using an implicit proof argument in the *Cons* case, we can define\n a data type for lists that do not contain duplicates. The type of *Cons* then\n becomes:\n Cons : (nm : String) → (u : U) → (s : Schema) → {_ : So (not (elem nm s))}\n → Schema\n The second point is a bit trickier. The real solution would involve quotient\n types to make the order of the elements unobservable. As Agda does not\n support quotient types, however, the best we can do is parameterise our\n constructors by an additional proof argument, when necessary. For example,\n the *Union* constructor could be defined as follows:\n Union : ∀ {s s'} → {_ : So (permute s s')} → RA s → RA s' → RA s\n Instead of requiring that both arguments of *Union* are indexed by the same\n schema, we should only require that the two schemas are equal up to a\n permutation of the elements. Alternatively, we could represent the *Schema*\n using a data structure that fixes the order in which its constituent\n elements occur, such as a trie or sorted list.\n Finally, we would like to return to our example table. We chose to model\n the lap time as a fixed-length string ─ clearly, a triple of integers would\n be a better representation. Unfortunately, most database servers only\n support a handful of built-in types, such as strings, numbers, bits. There\n is no way to extend these primitive types. This problem is sometimes\n referred to as the *object-relational impedance mismatch*. We believe the\n generic programming techniques and views from the previous sections can be\n used to marshall data between a low-level representation in the database\n and the high-level representation in our programming language.\n-}\n", "meta": {"hexsha": "4424fe3b3f4b8be02715101ee6918423a5a5857f", "size": 11234, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "relational-algebra.agda", "max_stars_repo_name": "toonn/agda-casestt", "max_stars_repo_head_hexsha": "b397a6d9b84e29bbaa260f85f036869d511eb3eb", "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": "relational-algebra.agda", "max_issues_repo_name": "toonn/agda-casestt", "max_issues_repo_head_hexsha": "b397a6d9b84e29bbaa260f85f036869d511eb3eb", "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": "relational-algebra.agda", "max_forks_repo_name": "toonn/agda-casestt", "max_forks_repo_head_hexsha": "b397a6d9b84e29bbaa260f85f036869d511eb3eb", "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": 34.0424242424, "max_line_length": 80, "alphanum_fraction": 0.6199928788, "num_tokens": 3344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5972547346175009}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Functor.Bifunctor\n\nmodule Categories.Diagram.Coend {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 B : Obj\n f g : A ⇒ B\n\nopen import Level\nopen import Data.Product using (Σ; _,_)\n\nopen import Categories.Functor\nopen import Categories.Functor.Construction.Constant\nopen import Categories.NaturalTransformation.Dinatural\nopen import Categories.Morphism.Reasoning D\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) ○ ⟺ assoc)\n }\n where open Cowedge W\n\nrecord Coend : Set (levelOfTerm F) where\n field\n cowedge : Cowedge\n\n module cowedge = Cowedge cowedge\n open cowedge public\n open Cowedge\n\n field\n factor : (W : Cowedge) → cowedge.E ⇒ E W\n universal : ∀ {W : Cowedge} {A} → factor W ∘ cowedge.dinatural.α A ≈ dinatural.α W A\n unique : ∀ {W : Cowedge} {g : cowedge.E ⇒ E W} → (∀ {A} → g ∘ cowedge.dinatural.α A ≈ dinatural.α W A) → factor W ≈ g\n\n η-id : factor cowedge ≈ D.id\n η-id = unique identityˡ\n\n unique′ :(∀ {A} → f ∘ cowedge.dinatural.α A ≈ g ∘ cowedge.dinatural.α A) → f ≈ g\n unique′ {f = f} {g = g} eq = ⟺ (unique {W = Cowedge-∘ cowedge f} refl) ○ unique (⟺ eq)\n", "meta": {"hexsha": "779b6442200727c4fcbc5fb72f6b967e066fccfd", "size": 1739, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Diagram/Coend.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/Diagram/Coend.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/Diagram/Coend.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.5081967213, "max_line_length": 124, "alphanum_fraction": 0.6446233468, "num_tokens": 594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972717658209, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.5971857352780268}} {"text": "------------------------------------------------------------------------------\n-- The paradoxical combinator\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- See (Barendregt 2004, corollary 6.1.3).\n\nmodule FOT.LTC-PCF.Y where\n\nopen import LTC-PCF.Base hiding ( fix ; fix-eq )\n\n------------------------------------------------------------------------------\n-- This is the fixed-point combinator used by (Dybjer 1985).\nY : D\nY = lam (λ f → lam (λ x → f · (x · x)) · lam (λ x → f · (x · x)))\n\n-- We define a higher-order Y.\nY₁ : (D → D) → D\nY₁ f = Y · lam f\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Barendregt, Henk (2004). The Lambda Calculus. Its Syntax and\n-- Semantics. 2nd ed. Vol. 103. Studies in Logic and the Foundations\n-- of Mathematics. 6th impression. Elsevier.\n--\n-- Dybjer, Peter (1985). Program Verification in a Logical Theory of\n-- Constructions. In: Functional Programming Languages and Computer\n-- Architecture. Ed. by Jouannaud,\n-- Jean-Pierre. Vol. 201. LNCS. Appears in revised form as Programming\n-- Methodology Group Report 26, University of Gothenburg and Chalmers\n-- University of Technology, June 1986. Springer, pp. 334–349 (cit. on\n-- p. 26).\n", "meta": {"hexsha": "4e8ecf4dfde645764d739d342414e8decb64e4ef", "size": 1435, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/LTC-PCF/Y.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/LTC-PCF/Y.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/LTC-PCF/Y.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.7948717949, "max_line_length": 78, "alphanum_fraction": 0.5087108014, "num_tokens": 342, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972784807408, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5971857287054797}} {"text": "\nopen import Agda.Primitive\nopen import Agda.Builtin.Equality\n\nvariable\n ℓ : Level\n A : Set ℓ\n P : A → Set ℓ\n x y : A\n f : (x : A) → P x\n\ncong : x ≡ y → f x ≡ f y\ncong refl = refl\n", "meta": {"hexsha": "5de7b258c451deccab10c0212a64fd4c553a2b55", "size": 185, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue3340.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/Issue3340.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/Issue3340.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.2142857143, "max_line_length": 33, "alphanum_fraction": 0.5783783784, "num_tokens": 80, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972616934406, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.5971857283688827}} {"text": "open import Prelude\nopen import dynamics-core\n\nopen import progress-checks\n\nmodule finality where\n finality : Σ[ d ∈ ihexp ] (d final × (Σ[ d' ∈ ihexp ] (d ↦ d'))) → ⊥\n finality (π1 , π2 , π3 , π4) = final-not-step π2 (π3 , π4)\n\n -- a slight restatement of the above, generalizing it to the\n -- multistep judgement\n finality* : ∀{d d'} → d final → d ↦* d' → d == d'\n finality* fin MSRefl = refl\n finality* fin (MSStep x ms) = abort (final-not-step fin (_ , x))\n", "meta": {"hexsha": "72c359edb843a5f60368092a18932dd22922a4bd", "size": 468, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "finality.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": "finality.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": "finality.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": 31.2, "max_line_length": 70, "alphanum_fraction": 0.6282051282, "num_tokens": 166, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972650509008, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5971857194932884}} {"text": "module sum where\n\nopen import level\nopen import bool\nopen import eq\nopen import maybe\nopen import product\n\n----------------------------------------------------------------------\n-- datatypes\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 ℓ') → Set (ℓ ⊔ ℓ')\n_∨_ = _⊎_\n\n----------------------------------------------------------------------\n-- syntax\n----------------------------------------------------------------------\n\ninfixr 0 _⊎_ _∨_\n\n----------------------------------------------------------------------\n-- operations\n----------------------------------------------------------------------\n\n_≫=⊎_ : ∀ {ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}{C : Set (ℓ ⊔ ℓ')} → A ⊎ B → (B → A ⊎ C) → A ⊎ C\ninj₁ x ≫=⊎ f = inj₁ x\ninj₂ x ≫=⊎ f = f x\n\nreturn⊎ : ∀ {ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → B → A ⊎ B\nreturn⊎ b = inj₂ b\n\ninfix 5 error⊎_\n\nerror⊎_ : ∀ {ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → A → A ⊎ B\nerror⊎_ a = inj₁ a\n\nextract-inj₁≡ : ∀{ℓ}{ℓ'}{A : Set ℓ}{B : Set ℓ'}{a a' : A} → inj₁{B = B} a ≡ inj₁ a' → a ≡ a'\nextract-inj₁≡ refl = refl\n\nextract-inj₂≡ : ∀{ℓ}{ℓ'}{A : Set ℓ}{B : Set ℓ'}{b b' : B} → inj₂{A = A} b ≡ inj₂ b' → b ≡ b'\nextract-inj₂≡ refl = refl\n\n=⊎ : ∀{ℓ}{ℓ'}{A : Set ℓ}{B : Set ℓ'} → (A → A → 𝔹) → (B → B → 𝔹) → A ⊎ B → A ⊎ B → 𝔹\n=⊎ eqa eqb (inj₁ a) (inj₁ a') = eqa a a'\n=⊎ eqa eqb (inj₂ b) (inj₂ b') = eqb b b'\n=⊎ _ _ _ _ = ff\n\n\n=⊎-to-≡ : ∀{ℓ}{ℓ'}{A : Set ℓ}{B : Set ℓ'} → (_eqa_ : A → A → 𝔹) → (_eqb_ : B → B → 𝔹) → ((a a' : A) → (a eqa a' ≡ tt) → a ≡ a') → ((b b' : B) → (b eqb b' ≡ tt) → b ≡ b') → (x y : A ⊎ B) → =⊎ _eqa_ _eqb_ x y ≡ tt → x ≡ y \n=⊎-to-≡ eqa eqb risea riseb (inj₁ a) (inj₁ a') p rewrite risea a a' p = refl\n=⊎-to-≡ eqa eqb risea riseb (inj₂ b) (inj₂ b') p rewrite riseb b b' p = refl\n=⊎-to-≡ eqa eqb risea riseb (inj₁ a) (inj₂ b) ()\n=⊎-to-≡ eqa eqb risea riseb (inj₂ b) (inj₁ a) ()\n\n\n\n\n≡⊎-to-= : ∀{ℓ}{ℓ'}{A : Set ℓ}{B : Set ℓ'} → (_eqa_ : A → A → 𝔹) → (_eqb_ : B → B → 𝔹) → ((a a' : A) → a ≡ a' → a eqa a' ≡ tt) → ((b b' : B) → b ≡ b' → b eqb b' ≡ tt) → (x y : A ⊎ B) → x ≡ y → =⊎ _eqa_ _eqb_ x y ≡ tt\n≡⊎-to-= eqa eqb dropa dropb (inj₁ a) (inj₁ a') p = dropa a a' (extract-inj₁≡ p)\n≡⊎-to-= eqa eqb dropa dropb (inj₂ b) (inj₂ b') p = dropb b b' (extract-inj₂≡ p)\n≡⊎-to-= eqa eqb dropa dropb (inj₁ a) (inj₂ b) ()\n≡⊎-to-= eqa eqb dropa dropb (inj₂ b) (inj₁ a) ()\n", "meta": {"hexsha": "e54d26e2b39a7aca2af5e4094e5074e49937168d", "size": 2446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "sum.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": "sum.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": "sum.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.9705882353, "max_line_length": 222, "alphanum_fraction": 0.3904333606, "num_tokens": 1191, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972616934406, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5971857116009192}} {"text": "-- Andreas, 2011-04-05\nmodule EtaContractToMillerPattern where\n\ndata _==_ {A : Set}(a : A) : A -> Set where\n refl : a == a\n\nrecord Prod (A B : Set) : Set where\n constructor _,_\n field fst : A\n snd : B\nopen Prod\n\npostulate A B C : Set\n\ntest : let X : (Prod A B -> C) -> (Prod A B -> C)\n X = _\n in (x : Prod A B -> C) -> \n X (\\ z -> x (fst z , snd z)) == x\ntest x = refl \n-- eta contracts unification problem to X x = x", "meta": {"hexsha": "69f1bc4cc0122aec5ff6aa45b2dafb2906037fe9", "size": 455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/EtaContractToMillerPattern.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/EtaContractToMillerPattern.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/EtaContractToMillerPattern.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.75, "max_line_length": 49, "alphanum_fraction": 0.5296703297, "num_tokens": 154, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583696, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.5971303094525093}} {"text": "module Structure.Relator.Function where\n\nimport Lvl\nopen import Lang.Instance\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Functional\nopen import Structure.Setoid\nopen import Structure.Setoid.Uniqueness\nopen import Structure.Relator\nopen import Type\n\nprivate variable ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₑ₂ : Lvl.Level\n\nmodule _ {A : Type{ℓₒ₁}}{B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ (φ : A → B → Stmt{ℓₒ₃}) where\n module _ (f : A → B) where\n record Computable : Stmt{ℓₒ₁ Lvl.⊔ ℓₒ₂ Lvl.⊔ ℓₒ₃ Lvl.⊔ ℓₑ₂} where\n constructor intro\n field proof : ∀{x}{y} → (f(x) ≡ y) → φ(x)(y)\n computable = inst-fn Computable.proof\n\n -- A binary operation is total when every LHS have at least one RHS in which the relation holds.\n record Total : Stmt{ℓₒ₁ Lvl.⊔ ℓₒ₂ Lvl.⊔ ℓₒ₃} where\n constructor intro\n field proof : ∀{x} → ∃(y ↦ φ(x)(y))\n\n compute : A → B\n compute(x) = [∃]-witness(proof{x})\n\n computableFunction : ⦃ _ : ∀{x} → UnaryRelator(φ(x)) ⦄ → ∃(Computable)\n ∃.witness computableFunction = compute\n Computable.proof (∃.proof computableFunction) {x} eq = substitute₁(φ(x)) eq ([∃]-proof(proof{x}))\n total = inst-fn Total.proof\n\n -- A binary operation is a function when every LHS have at least one RHS in which the relation holds.\n record Function : Stmt{ℓₒ₁ Lvl.⊔ ℓₒ₂ Lvl.⊔ ℓₒ₃ Lvl.⊔ ℓₑ₂} where\n constructor intro\n field proof : ∀{x} → Unique(φ(x))\n function = inst-fn Function.proof\n -- (∀{x}{y₁ y₂} → φ(x)(y₁) → φ(x)(y₂) → (y₁ ≡ y₂))\n\n totalFunction : ⦃ _ : Total ⦄ → ⦃ _ : Function ⦄ → (∀{x} → ∃!(φ(x)))\n totalFunction = [∧]-intro total function\n", "meta": {"hexsha": "53c679512d69472527ff8261cc1e23f4e347f2da", "size": 1622, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Relator/Function.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.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.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.0444444444, "max_line_length": 103, "alphanum_fraction": 0.6572133169, "num_tokens": 629, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.849971175657575, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.5971302988189862}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Algebra.Construct.Free.Semilattice.Definition where\n\nopen import Prelude\n\ninfixr 5 _∷_\ndata 𝒦 (A : Type a) : Type a where\n [] : 𝒦 A\n _∷_ : A → 𝒦 A → 𝒦 A\n com : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs\n dup : ∀ x xs → x ∷ x ∷ xs ≡ x ∷ xs\n trunc : isSet (𝒦 A)\n", "meta": {"hexsha": "b347a91d20e971712e22e349f029fe1191b34689", "size": 305, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Algebra/Construct/Free/Semilattice/Definition.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/Construct/Free/Semilattice/Definition.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/Construct/Free/Semilattice/Definition.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.7857142857, "max_line_length": 58, "alphanum_fraction": 0.5442622951, "num_tokens": 137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8499711604559846, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.5971302987268845}} {"text": "--- Sample Sit file\n\n{-# OPTIONS --experimental-irrelevance #-}\n{-# OPTIONS --sized-types #-}\n\nopen import Base\n\n--; --- Leibniz-equality\n\nEq : forall (A : Set) (a b : A) -> Set1 --;\nEq = \\ A a b -> (P : A -> Set) -> (P a) -> P b\n\n--; --- Reflexivity\n\nrefl : forall (A : Set) (a : A) -> Eq A a a --;\nrefl = \\ A a P pa -> pa\n\n--; --- Symmetry\n\nsym : forall (A : Set) (a b : A) -> Eq A a b -> Eq A b a --;\nsym = \\ A a b eq P pb -> eq (\\ x -> P x -> P a) (\\ pa -> pa) pb\n\n--; --- Transitivity\n\ntrans : forall (A : Set) (a b c : A) -> Eq A a b -> Eq A b c -> Eq A a c --;\ntrans = \\ A a b c p q P pa -> q P (p P pa)\n\n--; --- Congruence\n\ncong : forall (A B : Set) (f : A -> B) (a a' : A) -> Eq A a a' -> Eq B (f a) (f a') --;\ncong = \\ A B f a a' eq P pfa -> eq (\\ x -> P (f x)) pfa\n\n--; --- Addition\n\nplus : forall .i -> Nat i -> Nat oo -> Nat oo --;\nplus = \\ i x y ->\n fix (\\ i x -> Nat oo)\n (\\ _ f -> \\\n { (zero _) -> y\n ; (suc _ x) -> suc oo (f x)\n })\n x\n\n--; --- Unit tests for plus\n\ninc : Nat oo -> Nat oo --;\ninc = \\ x -> suc oo x --;\n\none : Nat oo --;\none = inc (zero oo) --;\n\ntwo : Nat oo --;\ntwo = inc one --;\n\nthree : Nat oo --;\nthree = inc two --;\n\nfour : Nat oo --;\nfour = inc three --;\n\nfive : Nat oo --;\nfive = inc four --;\n\nsix : Nat oo --;\nsix = inc five --;\n\nplus_one_zero : Eq (Nat oo) (plus oo one (zero oo)) one --;\nplus_one_zero = refl (Nat oo) one --;\n\nplus_one_one : Eq (Nat oo) (plus oo one one) two --;\nplus_one_one = refl (Nat oo) two --;\n\n--; --- Reduction rules for plus\n\nplus_red_zero : forall .i (y : Nat oo) -> Eq (Nat oo) (plus (i + 1) (zero i) y) y --;\nplus_red_zero = \\ i y -> refl (Nat oo) y --;\n\nplus_red_suc : forall .i (x : Nat i) (y : Nat oo) -> Eq (Nat oo) (plus (i + 1) (suc i x) y) (suc oo (plus i x y)) --;\nplus_red_suc = \\ i x y -> refl (Nat oo) (suc oo (plus i x y)) --;\n\n--; --- Law: x + 0 = x\n\nplus_zero : forall .i (x : Nat i) -> Eq (Nat oo) (plus i x (zero oo)) x --;\nplus_zero = \\ i x ->\n fix (\\ i x -> Eq (Nat oo) (plus i x (zero oo)) x)\n (\\ j f -> \\\n { (zero _) -> refl (Nat oo) (zero oo)\n ; (suc _ y) -> cong (Nat oo) (Nat oo) inc (plus j y (zero oo)) y (f y)\n })\n x\n\n--; --- Law: x + suc y = suc x + y\n\nplus_suc : forall .i (x : Nat i) (y : Nat oo) -> Eq (Nat oo) (plus i x (inc y)) (inc (plus i x y)) --;\nplus_suc = \\ i x y ->\n fix (\\ i x -> Eq (Nat oo) (plus i x (inc y)) (inc (plus i x y)))\n (\\ j f -> \\\n { (zero _) -> refl (Nat oo) (inc y)\n ; (suc _ x') -> cong (Nat oo) (Nat oo) inc (plus j x' (inc y)) (inc (plus j x' y)) (f x')\n })\n x\n\n--; --- Another definition of addition\n\nplus' : forall .i -> Nat i -> Nat oo -> Nat oo --;\nplus' = \\ i x ->\n fix (\\ i x -> Nat oo -> Nat oo)\n (\\ _ f -> \\\n { (zero _) -> \\ y -> y\n ; (suc _ x) -> \\ y -> suc oo (f x y)\n })\n x\n\n--; --- Predecessor\n\npred : forall .i -> Nat i -> Nat i --;\npred = \\ i n ->\n fix (\\ i _ -> Nat i)\n (\\ i _ -> \\{ (zero _) -> zero i ; (suc _ y) -> y })\n n\n\n--; --- Subtraction\n\nsub : forall .j -> Nat j -> forall .i -> Nat i -> Nat i --;\nsub = \\ j y ->\n fix (\\ _ _ -> forall .i -> Nat i -> Nat i)\n (\\ _ f -> \\\n { (zero _) -> \\ i x -> x\n ; (suc _ y) -> \\ i x -> f y i (pred i x)\n }) --- pred i (f y i x) })\n y\n\n--; --- Lemma: x - x == 0\n\nsub_diag : forall .i (x : Nat i) -> Eq (Nat oo) (sub i x i x) (zero oo) --;\nsub_diag = \\ i x ->\n fix (\\ i x -> Eq (Nat oo) (sub i x i x) (zero oo))\n (\\ _ f -> \\\n { (zero _) -> refl (Nat oo) (zero oo)\n ; (suc _ y) -> f y\n })\n x\n\n--- Large eliminations\n\n--; --- Varying arity\n\nFun : forall .i (n : Nat i) (A : Set) (B : Set) -> Set --;\nFun = \\ i n A B ->\n fix (\\ _ _ -> Set)\n (\\ _ f -> \\\n { (zero _) -> B\n ; (suc _ x) -> A -> f x\n })\n n\n\n--; --- Type of n-ary Sum function\n\nSum : forall .i (n : Nat i) -> Set --;\nSum = \\ i n -> Nat oo -> Fun i n (Nat oo) (Nat oo)\n\n--; --- n-ary summation function\n\nsum : forall .i (n : Nat i) -> Sum i n --;\nsum = \\ _ n ->\n fix (\\ i n -> Sum i n)\n (\\ _ f -> \\\n { (zero _) -> \\ acc -> acc\n ; (suc _ x) -> \\ acc -> \\ k -> f x (plus oo k acc)\n })\n n\n\n--; --- Testing sum\n\nsum123 : Eq (Nat oo) (sum oo three (zero oo) one two three) six --;\nsum123 = refl (Nat oo) six\n", "meta": {"hexsha": "36abe0234eb5abf4650d025c1e52c3554d82d951", "size": 4376, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Test.agda", "max_stars_repo_name": "andreasabel/S", "max_stars_repo_head_hexsha": "262b8a87db8ab58aa77f60a749eacb8c49c7471f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2017-05-16T02:28:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-07T19:52:52.000Z", "max_issues_repo_path": "test/Test.agda", "max_issues_repo_name": "andreasabel/Sit", "max_issues_repo_head_hexsha": "262b8a87db8ab58aa77f60a749eacb8c49c7471f", "max_issues_repo_licenses": ["MIT"], "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/Test.agda", "max_forks_repo_name": "andreasabel/Sit", "max_forks_repo_head_hexsha": "262b8a87db8ab58aa77f60a749eacb8c49c7471f", "max_forks_repo_licenses": ["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.7231638418, "max_line_length": 118, "alphanum_fraction": 0.4337294333, "num_tokens": 1598, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711756575749, "lm_q2_score": 0.7025300449389327, "lm_q1q2_score": 0.5971302882315135}} {"text": "module Formalization.LambdaCalculus.Semantics where\n\nopen import Data\nopen import Formalization.LambdaCalculus\nopen import Syntax.Number\nopen import Type\n\n-- A value in the language of lambda calculus is a irreducible term by a standard reduction definition.\n-- It can also be defined as terms that are lambda abstractions because an application of a lambda is supposed to be β-reducible.\ndata Value : Expression → Type{0} where\n instance abs : ∀{body : Term(1)} → Value(Abstract body)\n", "meta": {"hexsha": "ff97ab7be53bff0b1ec2aee22008bdffa8b422fe", "size": 487, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/LambdaCalculus/Semantics.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.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.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.5833333333, "max_line_length": 129, "alphanum_fraction": 0.7926078029, "num_tokens": 109, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.5971022730517126}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.Group\nopen import lib.types.CommutingSquare\nopen import lib.groups.Homomorphism\nopen import lib.groups.Isomorphism\n\nmodule lib.groups.CommutingSquare where\n\n-- A new type to keep the parameters.\nrecord CommSquareᴳ {i₀ i₁ j₀ j₁}\n {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁}\n (φ₀ : G₀ →ᴳ H₀) (φ₁ : G₁ →ᴳ H₁) (ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁)\n : Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) where\n constructor comm-sqrᴳ\n field\n commutesᴳ : ∀ g₀ → GroupHom.f (ξH ∘ᴳ φ₀) g₀ == GroupHom.f (φ₁ ∘ᴳ ξG) g₀\n\ninfix 0 _□$ᴳ_\n_□$ᴳ_ = CommSquareᴳ.commutesᴳ\n\nCommSquareᴳ-∘v : ∀ {i₀ i₁ i₂ j₀ j₁ j₂}\n {G₀ : Group i₀} {G₁ : Group i₁} {G₂ : Group i₂}\n {H₀ : Group j₀} {H₁ : Group j₁} {H₂ : Group j₂}\n {φ : G₀ →ᴳ H₀} {ψ : G₁ →ᴳ H₁} {χ : G₂ →ᴳ H₂}\n {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}\n {μA : G₁ →ᴳ G₂} {μB : H₁ →ᴳ H₂}\n → CommSquareᴳ ψ χ μA μB\n → CommSquareᴳ φ ψ ξG ξH\n → CommSquareᴳ φ χ (μA ∘ᴳ ξG) (μB ∘ᴳ ξH)\nCommSquareᴳ-∘v {ξG = ξG} {μB = μB} (comm-sqrᴳ □₁₂) (comm-sqrᴳ □₀₁) =\n comm-sqrᴳ λ g₀ → ap (GroupHom.f μB) (□₀₁ g₀) ∙ □₁₂ (GroupHom.f ξG g₀)\n\nCommSquareᴳ-inverse-v : ∀ {i₀ i₁ j₀ j₁}\n {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁}\n {φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}\n → CommSquareᴳ φ₀ φ₁ ξG ξH\n → (ξG-ise : is-equiv (GroupHom.f ξG)) (ξH-ise : is-equiv (GroupHom.f ξH))\n → CommSquareᴳ φ₁ φ₀ (GroupIso.g-hom (ξG , ξG-ise)) (GroupIso.g-hom (ξH , ξH-ise))\nCommSquareᴳ-inverse-v (comm-sqrᴳ □) ξG-ise ξH-ise =\n comm-sqrᴳ (commutes (CommSquare-inverse-v (comm-sqr □) ξG-ise ξH-ise))\n", "meta": {"hexsha": "0401ce367792165a644f613408acae8cbedd10b5", "size": 1623, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/CommutingSquare.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/CommutingSquare.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/CommutingSquare.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.7441860465, "max_line_length": 83, "alphanum_fraction": 0.6161429452, "num_tokens": 880, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.5971022730517126}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- An inductive definition of the sublist relation with respect to a\n-- setoid which is decidable. This is a generalisation of what is\n-- commonly known as Order Preserving Embeddings (OPE).\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Data.List.Relation.Binary.Sublist.DecSetoid\n {c ℓ} (S : DecSetoid c ℓ) where\n\nimport Data.List.Relation.Binary.Equality.DecSetoid as DecSetoidEquality\nimport Data.List.Relation.Binary.Sublist.Setoid as SetoidSublist\nimport Data.List.Relation.Binary.Sublist.Heterogeneous.Properties\n as HeterogeneousProperties\nopen import Level using (_⊔_)\n\nopen DecSetoid S\nopen DecSetoidEquality S\n\n------------------------------------------------------------------------\n-- Re-export core definitions\n\nopen SetoidSublist setoid public\n\n------------------------------------------------------------------------\n-- Additional relational properties\n\n_⊆?_ : Decidable _⊆_\n_⊆?_ = HeterogeneousProperties.sublist? _≟_\n\n⊆-isDecPartialOrder : IsDecPartialOrder _≋_ _⊆_\n⊆-isDecPartialOrder = record\n { isPartialOrder = ⊆-isPartialOrder\n ; _≟_ = _≋?_\n ; _≤?_ = _⊆?_\n }\n\n⊆-decPoset : DecPoset c (c ⊔ ℓ) (c ⊔ ℓ)\n⊆-decPoset = record\n { isDecPartialOrder = ⊆-isDecPartialOrder\n }\n", "meta": {"hexsha": "9b8287eef9e0de81aca2a87641d1001c54350209", "size": 1422, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/DecSetoid.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/Sublist/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/Sublist/DecSetoid.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.2553191489, "max_line_length": 72, "alphanum_fraction": 0.5857946554, "num_tokens": 360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127380808499, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.5971022680049795}} {"text": "open import Logic\nopen import Structure.Setoid\nopen import Structure.Operator.Ring\nopen import Structure.OrderedField\nopen import Type\n\nmodule Structure.OrderedField.AbsoluteValue\n {ℓ ℓₗ ℓₑ}\n {F : Type{ℓ}}\n ⦃ equiv : Equiv{ℓₑ}(F) ⦄\n (_+_ _⋅_ : F → F → F)\n (_≤_ : F → F → Stmt{ℓₗ})\n ⦃ ring : Ring(_+_)(_⋅_) ⦄ -- TODO: The definition does not require a ring, only some kind of total order compatible with an operation with an identity and an inverse\n -- ⦃ identity : Identity(_+_) ⦄\n -- ⦃ inverseFunction : InverseFunction(_+_)(−_) ⦄\n ⦃ ordered : Ordered(_+_)(_⋅_)(_≤_) ⦄\n where\n\nopen Ring(ring)\nopen Ordered(ordered)\n\nimport Lvl\nopen import Data.Boolean\nopen import Data.Boolean.Proofs\nimport Data.Either as Either\nopen import Functional\nopen import Logic.IntroInstances\nopen import Logic.Propositional\nopen import Structure.Function.Domain\nopen import Structure.Function.Ordering\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Operator.Proofs\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Ring.Proofs\nopen import Structure.Relator.Properties\nopen import Syntax.Implication\nopen import Syntax.Transitivity\n\n‖_‖ : F → F\n‖ x ‖ = if Either.isRight(converseTotal(_≤_){𝟎}{x}) then (− x) else x\n\ninstance\n abs-function : Function(‖_‖)\n Function.congruence abs-function {x}{y} xy with converseTotal(_≤_){𝟎}{x} | converseTotal(_≤_){𝟎}{y}\n ... | Either.Left p | Either.Left q = xy\n ... | Either.Left p | Either.Right q = antisymmetry(_≤_)(_≡_) (sub₂(_≡_)(_≤_) xy 🝖 q) p 🝖 antisymmetry(_≤_)(_≡_) ([↔]-to-[→] [≤]-flip-negative q) ([↔]-to-[→] [≤]-flip-positive(p 🝖 sub₂(_≡_)(_≤_) xy))\n ... | Either.Right p | Either.Left q = antisymmetry(_≤_)(_≡_) ([↔]-to-[→] [≤]-flip-positive(q 🝖 sub₂(_≡_)(_≤_) (symmetry(_≡_) xy))) ([↔]-to-[→] [≤]-flip-negative p) 🝖 antisymmetry(_≤_)(_≡_) q (sub₂(_≡_)(_≤_) (symmetry(_≡_) xy) 🝖 p)\n ... | Either.Right p | Either.Right q = congruence₁(−_) xy\n\nabs-positive : ∀{x} → (‖ x ‖ ≥ 𝟎)\nabs-positive{x} = if-either-bool-intro {P = _≥ 𝟎} {x = x} {y = − x} id ([↔]-to-[→] [≤]-flip-negative) (converseTotal(_≤_){𝟎}{x})\n\nabs-values : ∀{x} → (‖ x ‖ ≡ x) ∨ (‖ x ‖ ≡ − x)\nabs-values{x} with converseTotal(_≤_){𝟎}{x}\n... | [∨]-introₗ _ = [∨]-introₗ (reflexivity(_≡_))\n... | [∨]-introᵣ _ = [∨]-introᵣ (reflexivity(_≡_))\n\nabs-of-zero : (‖ 𝟎 ‖ ≡ 𝟎)\nabs-of-zero with abs-values{𝟎}\n... | Either.Left p = p\n... | Either.Right p = p 🝖 [−]-of-𝟎\n\nabs-when-zero : ∀{x} → (‖ x ‖ ≡ 𝟎) ↔ (x ≡ 𝟎)\nabs-when-zero{x} = [↔]-intro (p ↦ congruence₁(‖_‖) p 🝖 abs-of-zero) (p ↦ symmetry(_≡_) ([∨]-elim id (q ↦ p 🝖 symmetry(_≡_) ([↔]-to-[→] [−]-is-𝟎 (symmetry(_≡_) q 🝖 p))) abs-values) 🝖 p)\n\nabs-of-negation : ∀{x} → (‖ − x ‖ ≡ ‖ x ‖)\nabs-of-negation{x} with converseTotal(_≤_){𝟎}{x} | converseTotal(_≤_){𝟎}{− x}\n... | [∨]-introₗ _ | [∨]-introᵣ _ = involution(−_)\n... | [∨]-introᵣ _ | [∨]-introₗ _ = reflexivity(_≡_)\n... | [∨]-introₗ zx | [∨]-introₗ znx = antisymmetry(_≤_)(_≡_) (nxz 🝖 zx) (xz 🝖 znx) where\n nxz : (− x) ≤ 𝟎\n nxz = [↔]-to-[←] [≤]-flip-negative (zx 🝖 (sub₂(_≡_)(_≤_) $ symmetry(_≡_) $ involution(−_)))\n\n xz : x ≤ 𝟎\n xz = [↔]-to-[←] [≤]-flip-negative znx\n... | [∨]-introᵣ xz | [∨]-introᵣ nxz = antisymmetry(_≤_)(_≡_) (involution(−_) 🝖-subₗ (xz 🝖 znx)) (nxz 🝖 zx 🝖-subᵣ symmetry(_≡_) (involution(−_))) where\n znx : 𝟎 ≤ (− x)\n znx = [↔]-to-[→] [≤]-flip-negative xz\n\n zx : 𝟎 ≤ x\n zx = [↔]-to-[→] [≤]-flip-negative nxz 🝖 (sub₂(_≡_)(_≤_) $ involution(−_))\n\ninstance\n abs-idempotent : Idempotent(‖_‖)\n Idempotent.proof abs-idempotent {x} with abs-values{x}\n ... | Either.Left p = congruence₁(‖_‖) p\n ... | Either.Right p = congruence₁(‖_‖) p 🝖 abs-of-negation\n\nabs-order : ∀{x} → ((− ‖ x ‖) ≤ ‖ x ‖)\nabs-order{x} = [↔]-to-[→] [≤]-flip-positive(abs-positive{x}) 🝖 abs-positive{x}\n\nabs-order-pos : ∀{x} → (x ≤ ‖ x ‖)\nabs-order-pos {x} with converseTotal(_≤_){𝟎}{x}\n... | Either.Left p = reflexivity(_≤_)\n... | Either.Right p = p 🝖 [↔]-to-[→] [≤]-flip-negative p\n\nabs-order-neg : ∀{x} → ((− x) ≤ ‖ x ‖)\nabs-order-neg {x} with converseTotal(_≤_){𝟎}{x}\n... | Either.Left p = [↔]-to-[→] [≤]-flip-positive p 🝖 p\n... | Either.Right p = reflexivity(_≤_)\n\nabs-of-positive : ∀{x} → (𝟎 ≤ x) → (‖ x ‖ ≡ x)\nabs-of-positive {x} ox = antisymmetry(_≤_)(_≡_) p abs-order-pos where\n p : ‖ x ‖ ≤ x\n p with converseTotal(_≤_){𝟎}{x}\n ... | Either.Left _ = reflexivity(_≤_)\n ... | Either.Right _ = [↔]-to-[→] [≤]-flip-positive ox 🝖 ox\n -- Alternative 1:\n -- with abs-values{x}\n -- ... | Either.Left p = p\n -- ... | Either.Right p = [↔]-to-[←] abs-when-zero xzero 🝖 symmetry(_≡_) xzero where\n -- xzero : (x ≡ 𝟎)\n -- xzero = antisymmetry(_≤_)(_≡_) ([↔]-to-[←] [≤]-flip-negative (abs-positive{x} 🝖 sub₂(_≡_)(_≤_) p)) ox\n -- Alternative 2: antisymmetry(_≤_)(_≡_) (sub₂(_≡_)(_≤_) p 🝖 [≤]-flip-positive ox 🝖 ox) (sub₂(_≡_)(_≤_) (symmetry(_≡_) (congruence₁(−_) p 🝖 [−−]-elim)) 🝖 abs-order{x})\n\nabs-of-negative : ∀{x} → (x ≤ 𝟎) → (‖ x ‖ ≡ − x)\nabs-of-negative {x} xo = antisymmetry(_≤_)(_≡_) p abs-order-neg where\n p : ‖ x ‖ ≤ (− x)\n p with converseTotal(_≤_){𝟎}{x}\n ... | Either.Left _ = xo 🝖 [↔]-to-[→] [≤]-flip-negative xo\n ... | Either.Right _ = reflexivity(_≤_)\n -- Alternative 1:\n -- with abs-values{x}\n -- ... | Either.Right p = p\n -- ... | Either.Left p = symmetry(_≡_) abs-of-negation 🝖 [↔]-to-[←] abs-when-zero xzero 🝖 symmetry(_≡_) xzero where\n -- xzero : (− x ≡ 𝟎)\n -- xzero = antisymmetry(_≤_)(_≡_) ([↔]-to-[←] [≤]-flip-negative (abs-positive{x} 🝖 sub₂(_≡_)(_≤_) p 🝖 sub₂(_≡_)(_≤_) (symmetry(_≡_) [−−]-elim))) ([↔]-to-[→] [≤]-flip-negative xo)\n\nabs-triangle-inequality : ∀{x y} → (‖ x + y ‖ ≤ (‖ x ‖ + ‖ y ‖))\nabs-triangle-inequality {x}{y} with converseTotal(_≤_){𝟎}{x + y}\n... | Either.Left p =\n (x + y) 🝖[ _≤_ ]-[ [≤][+]-preserve abs-order-pos abs-order-pos ]\n (‖ x ‖ + ‖ y ‖) 🝖-end\n... | Either.Right p =\n −(x + y) 🝖[ _≡_ ]-[ [+]-negation-distribution ]-sub\n (− x) + (− y) 🝖[ _≤_ ]-[ [≤][+]-preserve abs-order-neg abs-order-neg ]\n (‖ x ‖ + ‖ y ‖) 🝖-end\n\n-- TODO: True in rings? Only division rings? Maybe ≤ instead of ≡ is better because of zero divisors\n-- abs-scaling : ∀{a x} → (‖ a ⋅ x ‖ ≡ (‖ a ‖ ⋅ ‖ x ‖))\n-- abs-scaling{a}{x} with converseTotal(_≤_){𝟎}{a ⋅ x} | converseTotal(_≤_){𝟎}{a} | converseTotal(_≤_){𝟎}{x}\n{-... | Either.Left p =\n (a ⋅ x) 🝖[ _≡_ ]-[ {!!} ]\n (‖ a ‖ ⋅ ‖ x ‖) 🝖-end\n... | Either.Right p = {!!}\n-}\n\n-- Distance\n_𝄩_ : F → F → F\nx 𝄩 y = ‖ x − y ‖\n\nopen import Structure.Function.Proofs\nopen import Structure.Operator.Proofs.Util\n\ninstance\n [𝄩]-binaryOperator : BinaryOperator(_𝄩_)\n [𝄩]-binaryOperator = [∘₂]-function {f = ‖_‖} ⦃ oper = [−]-binaryOperator ⦄\n\ninstance\n [𝄩]-commutativity : Commutativity(_𝄩_)\n Commutativity.proof [𝄩]-commutativity {x}{y} =\n ‖ x − y ‖ 🝖-[ abs-of-negation ]-sym\n ‖ −(x − y) ‖ 🝖-[ congruence₁(‖_‖) [−]-negation-distribution ]\n ‖ y − x ‖ 🝖-end\n\n[𝄩]-triangle-inequality : ∀{x y z} → ((x 𝄩 z) ≤ ((x 𝄩 y) + (y 𝄩 z)))\n[𝄩]-triangle-inequality {x}{y}{z} =\n x 𝄩 z 🝖[ _≤_ ]-[]\n ‖ x − z ‖ 🝖[ _≡_ ]-[ congruence₁(‖_‖) (congruence₂ₗ(_−_) ⦃ [−]-binaryOperator ⦄ (z) (symmetry(_≡_) (identityᵣ(_+_)(𝟎)))) ]-sub\n ‖ (x + 𝟎) − z ‖ 🝖[ _≡_ ]-[ congruence₁(‖_‖) (congruence₂ₗ(_−_) ⦃ [−]-binaryOperator ⦄ (z) (congruence₂ᵣ(_+_)(x) (symmetry(_≡_) (inverseFunctionₗ(_+_)(−_))))) ]-sub\n ‖ (x + ((− y) + y)) − z ‖ 🝖[ _≡_ ]-[ congruence₁(‖_‖) ((One.associate4-213-222 {_▫_ = _+_} {a = x}{− y}{y}{− z})) ]-sub\n ‖ (x + (− y)) + (y − z) ‖ 🝖[ _≤_ ]-[]\n ‖ (x − y) + (y − z) ‖ 🝖[ _≤_ ]-[ abs-triangle-inequality ]\n (‖ x − y ‖) + (‖ y − z ‖) 🝖[ _≤_ ]-[]\n (x 𝄩 y) + (y 𝄩 z) 🝖-end\n\n[𝄩]-self : ∀{x y} → (x 𝄩 y ≡ 𝟎) ↔ (x ≡ y)\n[𝄩]-self {x}{y} = [↔]-intro l r where\n l =\n (x ≡ y) ⇒-[ symmetry(_≡_) ∘ congruence₂ᵣ(_𝄩_)(x) ]\n (x 𝄩 y ≡ x 𝄩 x) ⇒-[]\n (_ ≡ ‖ x − x ‖) ⇒-[ _🝖 congruence₁(‖_‖) (inverseFunctionᵣ(_+_)(−_)) ]\n (_ ≡ ‖ 𝟎 ‖) ⇒-[ _🝖 abs-of-zero ]\n (_ ≡ 𝟎) ⇒-end\n r =\n (x 𝄩 y ≡ 𝟎) ⇒-[ [↔]-to-[→] (abs-when-zero{x − y}) ]\n (x − y ≡ 𝟎) ⇒-[ [↔]-to-[→] [−]-difference-is-𝟎 ]\n (x ≡ y) ⇒-end\n", "meta": {"hexsha": "28b53fbd7c3d06957aa2c695d62fdeccc01d1975", "size": 8120, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/OrderedField/AbsoluteValue.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/OrderedField/AbsoluteValue.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/OrderedField/AbsoluteValue.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.7368421053, "max_line_length": 234, "alphanum_fraction": 0.5411330049, "num_tokens": 3743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127455162773, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.5971022625006794}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- This module constructs the zero R-module, and similar for weaker\n-- module-like structures.\n-- The intended universal property is that, given any R-module M, there\n-- is a unique map into and a unique map out of the zero R-module\n-- from/to M.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Algebra.Module.Construct.Zero where\n\nopen import Algebra.Bundles\nopen import Algebra.Module.Bundles\nopen import Data.Unit\nopen import Level\n\nprivate\n variable\n r s ℓr ℓs : Level\n\nleftSemimodule : {R : Semiring r ℓr} → LeftSemimodule R 0ℓ 0ℓ\nleftSemimodule = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n\nrightSemimodule : {S : Semiring s ℓs} → RightSemimodule S 0ℓ 0ℓ\nrightSemimodule = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n\nbisemimodule :\n {R : Semiring r ℓr} {S : Semiring s ℓs} → Bisemimodule R S 0ℓ 0ℓ\nbisemimodule = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n\nsemimodule : {R : CommutativeSemiring r ℓr} → Semimodule R 0ℓ 0ℓ\nsemimodule = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n\nleftModule : {R : Ring r ℓr} → LeftModule R 0ℓ 0ℓ\nleftModule = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n\nrightModule : {S : Ring s ℓs} → RightModule S 0ℓ 0ℓ\nrightModule = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n\nbimodule : {R : Ring r ℓr} {S : Ring s ℓs} → Bimodule R S 0ℓ 0ℓ\nbimodule = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n\n⟨module⟩ : {R : CommutativeRing r ℓr} → Module R 0ℓ 0ℓ\n⟨module⟩ = record\n { Carrierᴹ = ⊤\n ; _≈ᴹ_ = λ _ _ → ⊤\n }\n", "meta": {"hexsha": "e6f8af4a3edcade50ffc2f9ca3294ac9221b943a", "size": 1657, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Module/Construct/Zero.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/Zero.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/Zero.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": 23.0138888889, "max_line_length": 72, "alphanum_fraction": 0.5769462885, "num_tokens": 655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127455162773, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.5971022571489016}} {"text": "------------------------------------------------------------------------\n-- The partiality monad\n------------------------------------------------------------------------\n\nmodule Category.Monad.Partiality where\n\nopen import Coinduction\nopen import Category.Monad\nopen import Data.Nat\nopen import Data.Bool\n\n-- The partiality monad.\n\ndata _⊥ (A : Set) : Set where\n now : (x : A) → A ⊥\n later : (x : ∞ (A ⊥)) → A ⊥\n\nmonad : RawMonad _⊥\nmonad = record\n { return = now\n ; _>>=_ = _>>=_\n }\n where\n _>>=_ : ∀ {A B} → A ⊥ → (A → B ⊥) → B ⊥\n now x >>= f = f x\n later x >>= f = later (♯ ♭ x >>= f)\n\n-- run x for n steps peels off at most n \"later\" constructors from x.\n\nrun_for_steps : ∀ {A} → A ⊥ → ℕ → A ⊥\nrun now x for n steps = now x\nrun later x for zero steps = later x\nrun later x for suc n steps = run ♭ x for n steps\n\n-- Is the computation done?\n\nisNow : ∀ {A} → A ⊥ → Bool\nisNow (now x) = true\nisNow (later x) = false\n\n------------------------------------------------------------------------\n-- Productivity checker workaround\n\n-- The monad can be awkward to use, due to the limitations of guarded\n-- coinduction. The following code provides a (limited) workaround.\n\ninfixl 1 _>>=_\n\ndata _⊥-prog : Set → Set₁ where\n now : ∀ {A} (x : A) → A ⊥-prog\n later : ∀ {A} (x : ∞₁ (A ⊥-prog)) → A ⊥-prog\n _>>=_ : ∀ {A B} (x : A ⊥-prog) (f : A → B ⊥-prog) → B ⊥-prog\n\ndata _⊥-whnf : Set → Set₁ where\n now : ∀ {A} (x : A) → A ⊥-whnf\n later : ∀ {A} (x : A ⊥-prog) → A ⊥-whnf\n\nwhnf : ∀ {A} → A ⊥-prog → A ⊥-whnf\nwhnf (now x) = now x\nwhnf (later x) = later (♭₁ x)\nwhnf (x >>= f) with whnf x\nwhnf (x >>= f) | now x′ = whnf (f x′)\nwhnf (x >>= f) | later x′ = later (x′ >>= f)\n\nmutual\n\n value : ∀ {A} → A ⊥-whnf → A ⊥\n value (now x) = now x\n value (later x) = later (♯ run x)\n\n run : ∀ {A} → A ⊥-prog → A ⊥\n run x = value (whnf x)\n\n------------------------------------------------------------------------\n-- Examples\n\nmodule Examples where\n\n open import Relation.Nullary\n\n -- McCarthy's f91:\n\n f91′ : ℕ → ℕ ⊥-prog\n f91′ n with n ≤? 100\n ... | yes _ = later (♯₁ (f91′ (11 + n) >>= f91′))\n ... | no _ = now (n ∸ 10)\n\n f91 : ℕ → ℕ ⊥\n f91 n = run (f91′ n)\n", "meta": {"hexsha": "5e70d56688ef61c7de448fb2ce972bd52a718393", "size": 2184, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Category/Monad/Partiality.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/Category/Monad/Partiality.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/Category/Monad/Partiality.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": 24.2666666667, "max_line_length": 72, "alphanum_fraction": 0.4684065934, "num_tokens": 793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424489603725, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.597053514888006}} {"text": "{-# OPTIONS --cubical-compatible #-}\nmodule Common.Nat where\n\nopen import Agda.Builtin.Nat public\n using ( Nat; zero; suc; _+_; _*_ )\n renaming ( _-_ to _∸_ )\n\n\npred : Nat → Nat\npred zero = zero\npred (suc n) = n\n\n", "meta": {"hexsha": "4d04760abadabadf249cb8c67524c9d5fbfc5028", "size": 221, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Common/Nat.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/Common/Nat.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/Common/Nat.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": 17.0, "max_line_length": 39, "alphanum_fraction": 0.6244343891, "num_tokens": 72, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8459424528443251, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.5970535071589653}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Theorems of ¬ connective.\n------------------------------------------------------------------------------\n\nopen import Data.Nat using ( ℕ )\n\nmodule Data.PropFormula.Theorems.Negation ( n : ℕ ) where\n\n------------------------------------------------------------------------------\n\nopen import Data.PropFormula.Properties n using ( ¬-injective ; subst )\nopen import Data.PropFormula.Syntax n\nopen import Data.PropFormula.Theorems.Classical n\nopen import Data.PropFormula.Theorems.Implication n using ( subst⊢⊃₁ )\n\nopen import Function using ( _$_ ; _∘_ )\nopen import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym )\n\n------------------------------------------------------------------------------\n\n-- Theorem.\n¬-equiv₁\n : ∀ {Γ} {φ}\n → Γ ⊢ ¬ φ\n → Γ ⊢ φ ⊃ ⊥\n¬-to-⊃⊥ = ¬-equiv₁\n\n-- Proof.\n¬-equiv₁ {φ = φ} Γ⊢¬φ =\n ⊃-intro\n (¬-elim\n (weaken φ Γ⊢¬φ)\n (assume φ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬-equiv₂\n : ∀ {Γ} {φ}\n → Γ ⊢ φ ⊃ ⊥\n → Γ ⊢ ¬ φ\n⊃⊥-to-¬ = ¬-equiv₂\n\n-- Proof.\n¬-equiv₂ {φ = φ} Γ⊢φ⊃⊥ =\n ¬-intro\n (⊃-elim\n (weaken φ Γ⊢φ⊃⊥)\n (assume φ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬¬-equiv₁\n : ∀ {Γ} {φ}\n → Γ ⊢ ¬ (¬ φ)\n → Γ ⊢ φ\n\n-- Proof.\n¬¬-equiv₁ {Γ}{φ} Γ⊢¬¬φ =\n (⊃-elim\n (⊃-intro $ RAA\n (¬-elim\n (weaken (¬ φ) $\n assume $ ¬ (¬ φ))\n (assume {Γ = Γ , ¬ (¬ φ)} $ ¬ φ)))\n Γ⊢¬¬φ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬¬-equiv₂\n : ∀ {Γ} {φ}\n → Γ ⊢ φ\n → Γ ⊢ ¬ (¬ φ)\n\n-- Proof.\n¬¬-equiv₂ {Γ}{φ} Γ⊢φ =\n ⊃⊥-to-¬\n (⊃-intro\n (¬-elim\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 (⊃-intro $\n ⊥-elim {Γ = Γ , ¬ φ , φ} ψ\n (¬-elim\n (weaken φ $\n assume (¬ φ))\n (assume {Γ = Γ , ¬ φ} φ)))\n (⊃-intro $\n weaken φ $\n assume ψ)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬⊤-to-⊥\n : ∀ {Γ}\n → Γ ⊢ ¬ ⊤\n → Γ ⊢ ⊥\n\n-- Proof.\n¬⊤-to-⊥ Γ⊢¬⊤ = ¬-elim Γ⊢¬⊤ ⊤-intro\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⊤-to-¬⊥\n : ∀ {Γ}\n → Γ ⊢ ⊤\n → Γ ⊢ ¬ ⊥\n\n-- Proof.\n⊤-to-¬⊥ = λ _ → ¬-intro (assume ⊥)\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬⊥-to-⊤\n : ∀ {Γ}\n → Γ ⊢ ¬ ⊥\n → Γ ⊢ ⊤\n\n-- Proof.\n¬⊥-to-⊤ Γ⊢¬⊥ = ⊤-intro\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⊥-to-¬⊤\n : ∀ {Γ}\n → Γ ⊢ ⊥\n → Γ ⊢ ¬ ⊤\n\n-- Proof.\n⊥-to-¬⊤ = ¬-intro ∘ weaken ⊤\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬-inside\n : ∀ {Γ} {φ ψ}\n → φ ≡ ψ\n → Γ ⊢ ¬ φ\n → Γ ⊢ ¬ ψ\n≡-¬-to-¬ = ¬-inside\n\n-- Proof.\n¬-inside {φ = φ}{ψ} φ≡ψ Γ⊢¬φ =\n ¬-equiv₂\n (⊃-intro\n (⊃-elim\n (¬-equiv₁\n (weaken ψ Γ⊢¬φ))\n (subst\n (sym φ≡ψ)\n (assume ψ))))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nsubst⊢¬\n : ∀ {Γ} {φ γ}\n → Γ ⊢ γ ⊃ φ\n → Γ ⊢ ¬ φ\n → Γ ⊢ ¬ γ\n\n-- Proof.\nsubst⊢¬ Γ⊢γ⊃φ Γ⊢¬φ = ⊃⊥-to-¬ (subst⊢⊃₁ Γ⊢γ⊃φ (¬-to-⊃⊥ Γ⊢¬φ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬⇔-to-⊃¬∧⊃¬\n : ∀ {Γ} {φ₁ φ₂}\n → Γ ⊢ ¬ (φ₁ ⇔ φ₂)\n → Γ ⊢ (φ₁ ⊃ ¬ φ₂) ∧ (φ₂ ⊃ ¬ φ₁)\n\n-- Proof.\n¬⇔-to-⊃¬∧⊃¬ {Γ}{φ₁}{φ₂} thm =\n ∧-intro\n (⊃-intro\n (¬-intro\n (¬-elim\n (weaken φ₂ $ weaken φ₁ thm)\n (⇔-intro\n (weaken φ₁ $ assume {Γ = Γ , φ₁} φ₂)\n (weaken φ₂ $ weaken φ₂ $ assume φ₁)))))\n (⊃-intro\n (¬-intro\n (¬-elim (weaken φ₁ $ weaken φ₂ thm)\n (⇔-intro\n (weaken φ₁ $ weaken φ₁ $ assume φ₂)\n (weaken φ₂ $ assume {Γ = Γ , φ₂} φ₁)))))\n-------------------------------------------------------------------------- ∎\n", "meta": {"hexsha": "9acd121d179915930130e69f78d9425ea82a9e24", "size": 4235, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Negation.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/Negation.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/Negation.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.175, "max_line_length": 78, "alphanum_fraction": 0.2887839433, "num_tokens": 1604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424295406088, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.5970535064169654}} {"text": "{-# OPTIONS --without-K #-}\nopen import HoTT.Base\n\nmodule HoTT.Transport.Coproduct where\n\nprivate\n variable\n i : Level\n X : 𝒰 i\n A B : X → 𝒰 i\n x₁ x₂ : X\n\ntransport-+ : (p : x₁ == x₂) →\n transport (λ x → A x + B x) p ~\n +-rec (inl ∘ transport A p) (inr ∘ transport B p)\ntransport-+ refl (inl a) = refl\ntransport-+ refl (inr b) = refl\n", "meta": {"hexsha": "b9ca2677d9a99d6d04ae3a1d534412c84ff25a11", "size": 373, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Transport/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/Transport/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/Transport/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": 20.7222222222, "max_line_length": 63, "alphanum_fraction": 0.5442359249, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.90192067652954, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5970019279970055}} {"text": "module Logic.DiagonalProof {ℓ₁} {ℓ₂} where\n\nimport Lvl\nopen import Logic.Propositional{ℓ₁ Lvl.⊔ ℓ₂}\nopen import Logic.Predicate{ℓ₁}{ℓ₂}\nopen import Functional\nopen import Relator.Equals{ℓ₁}{ℓ₂}\nopen import Relator.Equals.Proofs{ℓ₁}{ℓ₂}\nopen import Type{ℓ₂}\n\ndiagonal-proof : ∀{T₁ T₂ : Type}(diff-oper : T₂ → T₂) → (∀{x} → (x ≢ diff-oper(x))) → (ff : T₁ → T₁ → T₂) → ∃{T₁ → T₂}(f ↦ (∀{a : T₁} → ¬(ff(a)(a) ≡ f(a))))\ndiagonal-proof(diff-oper)(diff-proof)(ff) = [∃]-intro (a ↦ diff-oper(ff(a)(a))) ⦃ \\{a} → diff-proof{ff(a)(a)} ⦄\n", "meta": {"hexsha": "172b0f8c6e4408996b3a782e4f153b710412a086", "size": 532, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Logic/DiagonalProof.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/Logic/DiagonalProof.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/Logic/DiagonalProof.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.9230769231, "max_line_length": 156, "alphanum_fraction": 0.6221804511, "num_tokens": 229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9019206791658465, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.5970019177118708}} {"text": "module Type.Dependent.Functions where\n\nimport Lvl\nopen import Functional.Dependent\nopen import Type\nopen import Type.Dependent\nopen import Syntax.Function\n\nmodule _ {ℓ₁ ℓ₂ ℓ₃}\n {A : Type{ℓ₁}}\n {B : A → Type{ℓ₂}}\n {C : ∀{x} → B(x) → Type{ℓ₃}}\n where\n _[Π]-∘_ : (∀{x} → Π(B(x))(C)) → (g : Π(A)(B)) → Π(A)(\\x → C(Π.apply g x))\n Π.apply (f [Π]-∘ g) x = Π.apply f (Π.apply g x)\n\n depCurry : (Π(Σ A B) (C ∘ Σ.right)) → (Π A (a ↦ (Π(B(a)) C)))\n Π.apply (Π.apply (depCurry f) a) b = Π.apply f (intro a b)\n\n depUncurry : (Π A (a ↦ Π(B(a)) C)) → (Π(Σ A B) (C ∘ Σ.right))\n Π.apply (depUncurry f) (intro a b) = Π.apply(Π.apply f a) b\n\nmodule _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄}\n {A₁ : Type{ℓ₁}}\n {B₁ : A₁ → Type{ℓ₂}}\n {A₂ : Type{ℓ₃}}\n {B₂ : A₂ → Type{ℓ₄}}\n where\n [Σ]-apply : (x : Σ(A₁)(B₁)) → (l : A₁ → A₂) → (r : B₁(Σ.left x) → B₂(l(Σ.left x))) → Σ(A₂)(B₂)\n [Σ]-apply x l r = intro(l(Σ.left x))(r(Σ.right x))\n\n [ℰ]-apply : (x : Σ(A₁)(B₁)) → {l : A₁ → A₂} → (r : B₁(Σ.left x) → B₂(l(Σ.left x))) → Σ(A₂)(B₂)\n [ℰ]-apply x {l} r = [Σ]-apply x l r\n\n [Σ]-map : (l : A₁ → A₂) → (∀{a} → B₁(a) → B₂(l(a))) → (Σ(A₁)(B₁) → Σ(A₂)(B₂))\n [Σ]-map l r (intro left right) = intro (l left) (r right)\n\n [ℰ]-map : ∀{l : A₁ → A₂} → (∀{a} → B₁(a) → B₂(l(a))) → (Σ(A₁)(B₁) → Σ(A₂)(B₂))\n [ℰ]-map {l} = [Σ]-map l\n\nmodule _ {ℓ₁ ℓ₂ ℓ₃}\n {A : Type{ℓ₁}}\n {B₁ : A → Type{ℓ₂}}\n {B₂ : A → Type{ℓ₃}}\n where\n [Σ]-applyᵣ : (x : Σ(A)(B₁)) → (r : B₁(Σ.left x) → B₂(Σ.left x)) → Σ(A)(B₂)\n [Σ]-applyᵣ x r = intro(Σ.left x)(r(Σ.right x))\n\nmodule _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ ℓ₆}\n {A₁ : Type{ℓ₁}}\n {B₁ : A₁ → Type{ℓ₂}}\n {A₂ : Type{ℓ₃}}\n {B₂ : A₂ → Type{ℓ₄}}\n {A₃ : Type{ℓ₅}}\n {B₃ : A₃ → Type{ℓ₆}}\n where\n [Σ]-apply₂ : (x : Σ(A₁)(B₁)) → (y : Σ(A₂)(B₂)) → (l : A₁ → A₂ → A₃) → (r : B₁(Σ.left x) → B₂(Σ.left y) → B₃(l(Σ.left x)(Σ.left y))) → Σ(A₃)(B₃)\n [Σ]-apply₂ x y l r = intro(l(Σ.left x)(Σ.left y))(r(Σ.right x)(Σ.right y))\n\n [ℰ]-apply₂ : (x : Σ(A₁)(B₁)) → (y : Σ(A₂)(B₂)) → {l : A₁ → A₂ → A₃} → (r : B₁(Σ.left x) → B₂(Σ.left y) → B₃(l(Σ.left x)(Σ.left y))) → Σ(A₃)(B₃)\n [ℰ]-apply₂ x y {l} r = [Σ]-apply₂ x y l r\n\n [Σ]-map₂ : (l : A₁ → A₂ → A₃) → (∀{a₁}{a₂} → B₁(a₁) → B₂(a₂) → B₃(l a₁ a₂)) → (Σ(A₁)(B₁) → Σ(A₂)(B₂) → Σ(A₃)(B₃))\n [Σ]-map₂ l r (intro left₁ right₁) (intro left₂ right₂) = intro (l left₁ left₂) (r right₁ right₂)\n\n [ℰ]-map₂ : ∀{l : A₁ → A₂ → A₃} → (∀{a₁}{a₂} → B₁(a₁) → B₂(a₂) → B₃(l a₁ a₂)) → (Σ(A₁)(B₁) → Σ(A₂)(B₂) → Σ(A₃)(B₃))\n [ℰ]-map₂ {l} = [Σ]-map₂ l\n", "meta": {"hexsha": "9bdd7efe40b30f9b93b14196630b6dae0c4183e4", "size": 2579, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Dependent/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": "Type/Dependent/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": "Type/Dependent/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": 37.9264705882, "max_line_length": 145, "alphanum_fraction": 0.4587049244, "num_tokens": 1399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681122619883, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.5969708640862011}} {"text": "import Relation.Binary.PropositionalEquality as PEq\n\nmodule Relation.Binary.PropositionalEquality.Extensionality\n (funext : ∀ {ℓ₁ ℓ₂} → PEq.Extensionality ℓ₁ ℓ₂) where\n\n\nfunext² : ∀ {p q r}{P : Set p}{Q : P → Set q}\n {R : (p : P) → Q p → Set r} →\n {f g : ∀ (p : P)(q : Q p) → R p q} → (∀ p q → f p q PEq.≡ g p q) →\n f PEq.≡ g\nfunext² f = funext λ p → funext λ q → f p q\n\nfunext³ : ∀ {p q r s}{P : Set p}{Q : P → Set q}\n {R : (p : P) → Q p → Set r}{S : (p : P)(q : Q p) → R p q → Set s} →\n {f g : ∀ (p : P)(q : Q p)(r : R p q) → S p q r} → (∀ p q r → f p q r PEq.≡ g p q r) →\n f PEq.≡ g\nfunext³ f = funext λ p → funext λ q → funext λ r → f p q r\n", "meta": {"hexsha": "7148ddb0ea100b95938a4a3148178007d8a06116", "size": 700, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Relation/Binary/PropositionalEquality/Extensionality.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/Binary/PropositionalEquality/Extensionality.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/Binary/PropositionalEquality/Extensionality.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": 38.8888888889, "max_line_length": 95, "alphanum_fraction": 0.4771428571, "num_tokens": 304, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680904463333, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.5969708380849319}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- An inductive definition of the sublist relation. This is commonly\n-- known as Order Preserving Embeddings (OPE).\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Relation.Binary.Sublist.Propositional\n {a} {A : Set a} where\n\nopen import Data.List.Relation.Binary.Equality.Propositional using (≋⇒≡)\nimport Data.List.Relation.Binary.Sublist.Setoid as SetoidSublist\nopen import Data.List.Relation.Unary.Any using (Any)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Unary using (Pred)\n\n------------------------------------------------------------------------\n-- Re-export definition and operations from setoid sublists\n\nopen SetoidSublist (setoid A) public\n hiding\n (lookup; ⊆-reflexive; ⊆-antisym\n ; ⊆-isPreorder; ⊆-isPartialOrder\n ; ⊆-preorder; ⊆-poset\n )\n\n------------------------------------------------------------------------\n-- Additional operations\n\nmodule _ {p} {P : Pred A p} where\n\n lookup : ∀ {xs ys} → xs ⊆ ys → Any P xs → Any P ys\n lookup = SetoidSublist.lookup (setoid A) (subst _)\n\n------------------------------------------------------------------------\n-- Relational properties\n\n⊆-reflexive : _≡_ ⇒ _⊆_\n⊆-reflexive refl = ⊆-refl\n\n⊆-antisym : Antisymmetric _≡_ _⊆_\n⊆-antisym xs⊆ys ys⊆xs = ≋⇒≡ (SetoidSublist.⊆-antisym (setoid A) xs⊆ys ys⊆xs)\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 a a a\n⊆-preorder = record\n { isPreorder = ⊆-isPreorder\n }\n\n⊆-poset : Poset a a a\n⊆-poset = record\n { isPartialOrder = ⊆-isPartialOrder\n }\n", "meta": {"hexsha": "14d11b5ef187f67caeaca439012a5944f7df96c4", "size": 1951, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/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/Sublist/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/Sublist/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": 28.2753623188, "max_line_length": 76, "alphanum_fraction": 0.5658636597, "num_tokens": 588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256313782276, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.5968704799578801}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Implications of nullary relations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Nullary.Implication where\n\nopen import Data.Bool.Base\nopen import Data.Empty\nopen import Function.Base\nopen import Relation.Nullary\nopen import Level\n\nprivate\n variable\n p q : Level\n P : Set p\n Q : Set q\n\n------------------------------------------------------------------------\n-- Some properties which are preserved by _→_.\n\ninfixr 2 _→-reflects_ _→-dec_\n\n_→-reflects_ : ∀ {bp bq} → Reflects P bp → Reflects Q bq →\n Reflects (P → Q) (not bp ∨ bq)\nofʸ p →-reflects ofʸ q = ofʸ (const q)\nofʸ p →-reflects ofⁿ ¬q = ofⁿ (¬q ∘ (_$ p))\nofⁿ ¬p →-reflects _ = ofʸ (⊥-elim ∘ ¬p)\n\n_→-dec_ : Dec P → Dec Q → Dec (P → Q)\ndoes (p? →-dec q?) = not (does p?) ∨ does q?\nproof (p? →-dec q?) = proof p? →-reflects proof q?\n", "meta": {"hexsha": "cdf257c78d5d697ee1b3ec3dbac29d7f1cd4bc0d", "size": 1019, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Nullary/Implication.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/Implication.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/Implication.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.5405405405, "max_line_length": 72, "alphanum_fraction": 0.481844946, "num_tokens": 287, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.727975460709318, "lm_q1q2_score": 0.596862228944156}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Adjoint.Instance.PosetCore where\n\n-- The adjunction between the \"forgetful\" functor from Posets to\n-- Setoids and the core functor for posets.\n\nopen import Level using (_⊔_)\nimport Function\nopen import Function.Equality using (Π; _⟶_)\nopen import Relation.Binary using (Setoid; Poset)\nopen import Relation.Binary.OrderMorphism using (_⇒-Poset_) renaming (_∘_ to _∙_)\n\nopen import Categories.Adjoint using (_⊣_)\nimport Categories.Adjoint.Instance.0-Truncation as Setd\nimport Categories.Adjoint.Instance.01-Truncation as Pos\nopen import Categories.Category using (Category)\nopen import Categories.Category.Construction.Thin\nopen import Categories.Category.Instance.Posets using (fun-resp-≈; Posets)\nopen import Categories.Category.Instance.Setoids using (Setoids)\nopen import Categories.Functor.Instance.Core using () renaming (Core to CatCore)\nimport Categories.Functor.Instance.Core as Cat\nopen import Categories.Functor using (Functor; _∘F_; id)\nimport Categories.Morphism as Morphism\nopen import Categories.Morphism.IsoEquiv using (⌞_⌟)\nopen import Categories.NaturalTransformation using (ntHelper)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n using (_≃_; niHelper)\n\nopen Π\nopen _⇒-Poset_\n\n-- The \"forgetful\" functor from Setoids to Posets (forgetting symmetry).\n\nForgetful : ∀ {c ℓ} → Functor (Setoids c ℓ) (Posets c ℓ ℓ)\nForgetful = record\n { F₀ = Forgetful₀\n ; F₁ = λ f → record { fun = _⟨$⟩_ f ; monotone = cong f }\n ; identity = λ {S} → refl S\n ; homomorphism = λ {_ _ S} → refl S\n ; F-resp-≈ = λ {S _} f≗g → f≗g (refl S)\n }\n where\n Forgetful₀ : ∀ {c ℓ} → Setoid c ℓ → Poset c ℓ ℓ\n Forgetful₀ S = record\n { _≈_ = _≈_\n ; _≤_ = _≈_\n ; isPartialOrder = record\n { isPreorder = record\n { isEquivalence = isEquivalence\n ; reflexive = Function.id\n ; trans = trans\n }\n ; antisym = Function.const\n }\n }\n where open Setoid S\n\n open Setoid\n\n-- The \"core\" functor from Posets to Setoids.\n--\n-- This functor simply forgets the _≤_ relation, mapping a Poset to\n-- the Setoid over which it is defined. This Setoid is the \"core\" of\n-- the Poset in the sense that the \"equality\" _≈_ associated with the\n-- Poset is really an equivalence, and antisymmetry ensures that this\n-- equivalence is equivalent to the symmetric core of _≤_.\n\nCore : ∀ {c ℓ₁ ℓ₂} → Functor (Posets c ℓ₁ ℓ₂) (Setoids c ℓ₁)\nCore = record\n { F₀ = λ A → record { isEquivalence = isEquivalence A }\n ; F₁ = λ f → record { _⟨$⟩_ = fun f ; cong = fun-resp-≈ f }\n ; identity = Function.id\n ; homomorphism = λ {_ _ _ f g} → fun-resp-≈ (g ∙ f)\n ; F-resp-≈ = λ {_ B} {f _} f≗g x≈y → Eq.trans B (fun-resp-≈ f x≈y) f≗g\n }\n where open Poset\n\n-- Core is right-adjoint to the forgetful functor\n\nCoreAdj : ∀ {o ℓ} → Forgetful ⊣ Core {o} {ℓ} {ℓ}\nCoreAdj = record\n { unit = ntHelper record { η = unit ; commute = cong }\n ; counit = ntHelper record { η = counit ; commute = λ {_ B} _ → Eq.refl B }\n ; zig = λ {S} → Setoid.refl S\n ; zag = Function.id\n }\n where\n open Poset\n open Functor Core using () renaming (F₀ to Core₀; F₁ to Core₁)\n open Functor Forgetful using () renaming (F₀ to U₀ ; F₁ to U₁)\n\n unit : ∀ S → S ⟶ Core₀ (U₀ S)\n unit S = record { _⟨$⟩_ = Function.id ; cong = Function.id }\n\n counit : ∀ A → U₀ (Core₀ A) ⇒-Poset A\n counit C = record { fun = Function.id ; monotone = reflexive C }\n\n-- The core functor commutes with inclusion, i.e. the core of a thin\n-- category is the 0-Groupoid generated by the associated equivalence.\n--\n-- Note that the core functor does not commute with truncation,\n-- because the latter forgets too much (there are many more isos in\n-- the (0,1)-truncated category).\n\nCore-commutes : ∀ {c ℓ} e → Setd.Inclusion e ∘F Core ≃\n Cat.Core ∘F Pos.Inclusion {c} {ℓ ⊔ e} {ℓ} e\nCore-commutes e = niHelper record\n { η = λ A → record { F₀ = Function.id ; F₁ = EqIsIso.≈⇒≅ e A }\n ; η⁻¹ = λ A → record { F₀ = Function.id ; F₁ = EqIsIso.≅⇒≈ e A }\n ; commute = λ {A B} f →\n let open Morphism (Thin e B)\n in niHelper record { η = λ _ → ≅.refl ; η⁻¹ = λ _ → ≅.refl }\n ; iso = λ A →\n let open Poset A\n open Morphism (Thin e A)\n in record\n { isoˡ = niHelper record { η = λ _ → Eq.refl ; η⁻¹ = λ _ → Eq.refl }\n ; isoʳ = niHelper record { η = λ _ → ≅.refl ; η⁻¹ = λ _ → ≅.refl }\n }\n }\n", "meta": {"hexsha": "dc2195168e2cf1aa46609141717a6b6e09817bc1", "size": 4563, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Adjoint/Instance/PosetCore.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/Adjoint/Instance/PosetCore.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/Adjoint/Instance/PosetCore.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": 37.4016393443, "max_line_length": 81, "alphanum_fraction": 0.6300679378, "num_tokens": 1483, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.819893335913536, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.5968622144279355}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Symmetric closures of binary relations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Construct.Closure.Symmetric where\n\nopen import Data.Sum as Sum using (_⊎_)\nopen import Function using (id)\nopen import Relation.Binary\n\nopen Sum public using () renaming (inj₁ to fwd; inj₂ to bwd)\n\n-- The symmetric closure of a relation.\n\nSymClosure : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Rel A ℓ\nSymClosure _∼_ a b = a ∼ b ⊎ b ∼ a\n\nmodule _ {a ℓ} {A : Set a} where\n\n -- Symmetric closures are symmetric.\n\n symmetric : (_∼_ : Rel A ℓ) → Symmetric (SymClosure _∼_)\n symmetric _ (fwd a∼b) = bwd a∼b\n symmetric _ (bwd b∼a) = fwd b∼a\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 → SymClosure P =[ f ]⇒ SymClosure Q\n gmap _ g = Sum.map g g\n\n map : ∀ {ℓ₂} {P : Rel A ℓ} {Q : Rel A ℓ₂} →\n P ⇒ Q → SymClosure P ⇒ SymClosure Q\n map = gmap id\n", "meta": {"hexsha": "4b3aa74abacf4f0f1343bff4d96077cd2c9426e3", "size": 1148, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Symmetric.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/Closure/Symmetric.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/Symmetric.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.4358974359, "max_line_length": 72, "alphanum_fraction": 0.5409407666, "num_tokens": 361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.5967417755320357}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Rings.PrincipalIdealDomains.Definition\nopen import Rings.IntegralDomains.Definition\nopen import Rings.Ideals.Maximal.Definition\n\nmodule Rings.PrincipalIdealDomains.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) (pid : {c : _} → PrincipalIdealDomain intDom {c}) where\n\nopen import Rings.Ideals.Definition R\nopen import Rings.Irreducibles.Definition intDom\nopen import Rings.Ideals.Principal.Definition R\nopen import Rings.Divisible.Definition R\nopen import Rings.Associates.Lemmas intDom\nopen import Rings.Ideals.Lemmas R\nopen import Rings.Units.Definition R\nopen import Rings.Irreducibles.Lemmas intDom\nopen import Rings.Units.Lemmas R\nopen import Rings.Ideals.Prime.Definition {R = R}\nopen import Rings.Ideals.Prime.Lemmas {R = R}\nopen import Rings.Primes.Definition intDom\nopen import Rings.Primes.Lemmas intDom\nopen import Rings.Ideals.Principal.Lemmas R\nopen import Rings.Ideals.Maximal.Lemmas {R = R}\n\nopen Ring R\nopen Setoid S\nopen Equivalence eq\n\nirreducibleImpliesMaximalIdeal : {r : A} → Irreducible r → {d : _} → MaximalIdeal (generatedIdeal r) {d}\nMaximalIdeal.notContained (irreducibleImpliesMaximalIdeal {r} irred {d}) = 1R\nMaximalIdeal.notContainedIsNotContained (irreducibleImpliesMaximalIdeal {r} irred {d}) = Irreducible.nonunit irred\nMaximalIdeal.isMaximal (irreducibleImpliesMaximalIdeal {r} irred {d}) {biggerPred} bigger biggerContains (outsideR , (biggerContainsOutside ,, notInR)) {x} = biggerPrincipal' (unitImpliesGeneratedIdealEverything w {x})\n where\n biggerGen : A\n biggerGen = PrincipalIdeal.generator (pid bigger)\n biggerPrincipal : {x : A} → biggerPred x → biggerGen ∣ x\n biggerPrincipal = PrincipalIdeal.genGenerates (pid bigger)\n bp : biggerPred biggerGen\n bp = PrincipalIdeal.genIsInIdeal (pid bigger)\n biggerPrincipal' : {x : A} → biggerGen ∣ x → biggerPred x\n biggerPrincipal' {y} bg|y = memberDividesImpliesMember bigger bp bg|y\n u : biggerGen ∣ r\n u = biggerPrincipal (biggerContains (1R , transitive *Commutative identIsIdent))\n biggerGenNonzero : biggerGen ∼ 0R → False\n biggerGenNonzero bg=0 = notInR (Ideal.isSubset (generatedIdeal r) (symmetric t) (Ideal.containsIdentity (generatedIdeal r)))\n where\n t : outsideR ∼ 0R\n t with biggerPrincipal {outsideR} biggerContainsOutside\n ... | mult , pr = transitive (symmetric pr) (transitive (*WellDefined bg=0 reflexive) (transitive *Commutative timesZero))\n v : (r ∣ biggerGen) → False\n v r|bg with mutualDivisionImpliesAssociate r|bg u (Irreducible.nonzero irred)\n v r|bg | assoc = notInR (associateImpliesGeneratedIdealsEqual' assoc (PrincipalIdeal.genGenerates (pid bigger) biggerContainsOutside))\n w : Unit biggerGen\n w = dividesIrreducibleImpliesUnit irred u v\n\nprimeIdealIsMaximal : {c : _} {pred : A → Set c} → {i : Ideal pred} → (nonzero : Sg A (λ a → ((a ∼ 0R) → False) && pred a)) → PrimeIdeal i → {d : _} → MaximalIdeal i {d}\nprimeIdealIsMaximal {pred = pred} {i} (m , (m!=0 ,, predM)) prime {d = d} = maximalIdealWellDefined (generatedIdeal (PrincipalIdeal.generator princ)) i (memberDividesImpliesMember i (PrincipalIdeal.genIsInIdeal princ)) (PrincipalIdeal.genGenerates princ) isMaximal\n where\n princ : PrincipalIdeal i\n princ = pid i\n isPrime : Prime (PrincipalIdeal.generator princ)\n isPrime = primeIdealImpliesPrime (λ gen=0 → PrimeIdeal.notContainedIsNotContained prime (exFalso (m!=0 (generatorZeroImpliesAllZero princ gen=0 predM)))) (primeIdealWellDefined i (generatedIdeal (PrincipalIdeal.generator princ)) (PrincipalIdeal.genGenerates princ) (memberDividesImpliesMember i (PrincipalIdeal.genIsInIdeal princ)) prime)\n isIrreducible : Irreducible (PrincipalIdeal.generator princ)\n isIrreducible = primeIsIrreducible isPrime\n isMaximal : MaximalIdeal (generatedIdeal (PrincipalIdeal.generator princ)) {d}\n isMaximal = irreducibleImpliesMaximalIdeal isIrreducible {d}\n\nirreducibleImpliesPrime : {x : A} → Irreducible x → Prime x\nirreducibleImpliesPrime {x} irred = primeIdealImpliesPrime (Irreducible.nonzero irred) (idealMaximalImpliesIdealPrime (generatedIdeal x) (irreducibleImpliesMaximalIdeal irred))\n", "meta": {"hexsha": "0b2ec2e82730d119bd61fce9af9dabcba8a39833", "size": 4378, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/PrincipalIdealDomains/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/PrincipalIdealDomains/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/PrincipalIdealDomains/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": 59.1621621622, "max_line_length": 342, "alphanum_fraction": 0.7608497031, "num_tokens": 1264, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.596737544858873}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Heterogeneous equality\n------------------------------------------------------------------------\n\n-- This file contains some core definitions which are reexported by\n-- Relation.Binary.HeterogeneousEquality.\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Relation.Binary.HeterogeneousEquality.Core where\n\nopen import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)\n\n------------------------------------------------------------------------\n-- Heterogeneous equality\n\ninfix 4 _≅_\n\ndata _≅_ {ℓ} {A : Set ℓ} (x : A) : {B : Set ℓ} → B → Set ℓ where\n refl : x ≅ x\n\n------------------------------------------------------------------------\n-- Conversion\n\n≅-to-≡ : ∀ {a} {A : Set a} {x y : A} → x ≅ y → x ≡ y\n≅-to-≡ refl = refl\n\n≡-to-≅ : ∀ {a} {A : Set a} {x y : A} → x ≡ y → x ≅ y\n≡-to-≅ refl = refl\n", "meta": {"hexsha": "e9f109ac4094546c59202b51b7872a48b31958e6", "size": 908, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/HeterogeneousEquality/Core.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/HeterogeneousEquality/Core.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/HeterogeneousEquality/Core.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.375, "max_line_length": 72, "alphanum_fraction": 0.4218061674, "num_tokens": 232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382129861583, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.5967375363890893}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.ZCohomology.Groups.Connected where\n\nopen import Cubical.ZCohomology.Base\nopen import Cubical.ZCohomology.Properties\nopen import Cubical.ZCohomology.Groups.Unit\n\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.GroupoidLaws\n\nopen import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2)\nopen import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁)\nopen import Cubical.HITs.Nullification\n\nopen import Cubical.Data.Sigma hiding (_×_)\nopen import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc)\nopen import Cubical.Data.Nat\nopen import Cubical.HITs.Truncation renaming (rec to trRec)\nopen import Cubical.Algebra.Group\n\nopen import Cubical.Homotopy.Connected\nopen import Cubical.Foundations.Equiv\n\nprivate\n H⁰-connected-type : ∀ {ℓ} {A : Type ℓ} (a : A) → isConnected 2 A → Iso (coHom 0 A) Int\n Iso.fun (H⁰-connected-type a con) = sRec isSetInt λ f → f a\n Iso.inv (H⁰-connected-type a con) b = ∣ (λ x → b) ∣₂\n Iso.rightInv (H⁰-connected-type a con) b = refl\n Iso.leftInv (H⁰-connected-type a con) =\n sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)\n λ f → cong ∣_∣₂ (funExt λ x → trRec (isSetInt _ _) (cong f) (isConnectedPath 1 con a x .fst))\n\nH⁰-connected : ∀ {ℓ} {A : Type ℓ} (a : A) → ((x : A) → ∥ a ≡ x ∥₁) → GroupIso (coHomGr 0 A) intGroup\nGroupHom.fun (GroupIso.map (H⁰-connected a con)) = sRec isSetInt (λ f → f a)\nGroupHom.isHom (GroupIso.map (H⁰-connected a con)) =\n sElim2 (λ _ _ → isProp→isSet (isSetInt _ _)) λ x y → addLemma (x a) (y a)\nGroupIso.inv (H⁰-connected a con) b = ∣ (λ _ → b) ∣₂\nGroupIso.rightInv (H⁰-connected a con) _ = refl\nGroupIso.leftInv (H⁰-connected a con) =\n sElim (λ _ → isProp→isSet (setTruncIsSet _ _))\n (λ f → cong ∣_∣₂ (funExt λ x → pRec (isSetInt _ _) (cong f) (con x)))\n", "meta": {"hexsha": "280be782b8d40042abe5e8b4e54f9a476bae45c7", "size": 2012, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/ZCohomology/Groups/Connected.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/Connected.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/ZCohomology/Groups/Connected.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": 45.7272727273, "max_line_length": 104, "alphanum_fraction": 0.7072564612, "num_tokens": 717, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.5965798967047176}} {"text": "-- Andreas, issue reported by Matteo Acerbi, 2014-09-04.\n-- Short summary: x = c x is not impossible for coinductive constructors c,\n-- so x should not be considered a strictly rigid occurrence in (c x).\n\n-- Matteo:\n\n-- In the following I cannot understand what justifies the absurd pattern\n-- in the definition of ¬id≡In: as νId is coinductive, elaboration of the\n-- no-cycles check to eliminators should not be possible (as far as I know).\n\n-- Any two inhabitants of νId are bisimilar, but it seems that current\n-- pattern matching makes it inconsistent to assume that bisimilarity\n-- implies equality for νId, which *might* upset some. :-)\n\n{-# OPTIONS --copatterns #-}\n\n-- False and equality.\n\n⊥ = (X : Set) → X\n\ndata _≡_ {A : Set}(x : A) : A → Set where\n <> : x ≡ x\n\n-- The cofixpoint of the identity functor.\n\nrecord νId : Set where\n coinductive\n constructor In\n field Out : νId\nopen νId\n\n-- The \"only\" inhabitant of νId.\n\ntt : νId\nOut tt = tt\n\n-- x ≡ In x is considered absurd.\n\n¬id≡In : {x : νId} → x ≡ In x → ⊥\n¬id≡In ()\n\n-- _≈_ is bisimilarity for elements of νId.\n\nrecord _≈νId_ (x y : νId) : Set where\n coinductive\n field step : Out x ≈νId Out y\nopen _≈νId_\n\n-- Any two elements are bisimilar.\n\ntrivial-≈νId : ∀ {x y} → x ≈νId y\nstep trivial-≈νId = trivial-≈νId\n\n-- For νId it is not consistent to assume that bisimilarity implies\n-- equality.\n\nproblem? : (ext : ∀ {x y} → x ≈νId y → x ≡ y) → ⊥\nproblem? ext = ¬id≡In {tt} (ext trivial-≈νId)\n", "meta": {"hexsha": "43b605ba6176f2f50165213f11a8344aa454ad32", "size": 1465, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue1271.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/Issue1271.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/Issue1271.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": 24.8305084746, "max_line_length": 76, "alphanum_fraction": 0.6689419795, "num_tokens": 479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.5965798909306569}} {"text": "module Numeral.Real where\n\nopen import Data.Tuple\nopen import Logic\nimport Lvl\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Rational\nopen import Numeral.Rational.Oper\nopen import Relator.Equals\nopen import Type\nopen import Type.Quotient\n\n-- TODO: This will not work, but it is the standard concept at least. Maybe there is a better way\n\nrecord CauchySequence (a : ℕ → ℚ) : Stmt where\n field\n N : ℚ₊ → ℕ\n ∀{ε : ℚ₊}{m n : ℕ} → (m > N(ε)) → (n > N(ε)) → (‖ a(m) − a(n) ‖ < ε)\n\n_converges-to-same_ : Σ(CauchySequence) → Σ(CauchySequence) → Stmt{Lvl.𝟎}\na converges-to-same b = lim(n ↦ Σ.left(a) − Σ.left(b)) ≡ 𝟎\n\nℝ : Type{Lvl.𝟎}\nℝ = Σ(CauchySequence) / (_converges-to-same_)\n\n-- TODO: Here is another idea: https://github.com/dylanede/cubical-experiments/blob/master/scratch.agda\n-- TODO: Also these: https://en.wikipedia.org/wiki/Construction_of_the_real_numbers#Construction_from_Cauchy_sequences\n", "meta": {"hexsha": "27d931f1845f86d669d03f0d042e133528bd2ddf", "size": 942, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Mathematical/Numeral/Real.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/Mathematical/Numeral/Real.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/Mathematical/Numeral/Real.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.4827586207, "max_line_length": 118, "alphanum_fraction": 0.7154989384, "num_tokens": 323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898127684336, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.5965195602024196}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\n{- Proof that if [A] and [B] are two propositions, then so is [A * B]. -}\n\nmodule homotopy.PropJoinProp\n {i} {A : Type i} (pA : is-prop A)\n {j} {B : Type j} (pB : is-prop B) where\n\ncontr-left : (a : A) → is-contr (A * B)\ncontr-left a = left a , Pushout-elim\n (λ a' → ap left (prop-has-all-paths pA a a'))\n (λ b' → glue (a , b'))\n (λ {(a' , b') → ↓-cst=idf-in' $ ! $\n ↓-app=cst-out (apd (λ a → glue (a , b')) (prop-has-all-paths pA a a'))})\n\ncontr-right : (b : B) → is-contr (A * B)\ncontr-right b = right b , Pushout-elim\n (λ a' → ! (glue (a' , b)))\n (λ b' → ap right (prop-has-all-paths pB b b'))\n (λ {(a' , b') → ↓-cst=idf-in' $\n ! (glue (a' , b)) ∙ glue (a' , b')\n =⟨ ! (↓-cst=app-out' $ apd (λ b → glue (a' , b)) (prop-has-all-paths pB b b'))\n |in-ctx ! (glue (a' , b)) ∙_ ⟩\n ! (glue (a' , b)) ∙ glue (a' , b) ∙ ap right (prop-has-all-paths pB b b')\n =⟨ ! $ ∙-assoc (! (glue (a' , b))) (glue (a' , b)) (ap right (prop-has-all-paths pB b b')) ⟩\n (! (glue (a' , b)) ∙ glue (a' , b)) ∙ ap right (prop-has-all-paths pB b b')\n =⟨ !-inv-l (glue (a' , b)) |in-ctx _∙ ap right (prop-has-all-paths pB b b') ⟩\n ap right (prop-has-all-paths pB b b')\n =∎})\n\nprop*prop-is-prop : is-prop (A * B)\nprop*prop-is-prop = inhab-to-contr-is-prop $\n Pushout-rec contr-left contr-right (λ _ → prop-has-all-paths is-contr-is-prop _ _)\n", "meta": {"hexsha": "1c07c86a8cf521a3443549b005f3728f98836e00", "size": 1424, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/PropJoinProp.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/PropJoinProp.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/PropJoinProp.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": 39.5555555556, "max_line_length": 98, "alphanum_fraction": 0.5175561798, "num_tokens": 587, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045996818986, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.5964957760238091}} {"text": "module Formalization.Polynomial where\n\nimport Lvl\nopen import Data.ListSized\nopen import Numeral.Natural as ℕ using (ℕ)\nopen import Type\n\nprivate variable ℓ ℓₑ : Lvl.Level\nprivate variable T : Type{ℓ}\nprivate variable n n₁ n₂ : ℕ\n\n-- TODO: Some of the operations should work with arbitrary Rg structures, not just ℕ, and some other stuff should work with more assumptions. Currently, one of the function that needs to be modified is 𝐷 and normalize for this to work because their implementations depend on ℕ.\n-- TODO: Composition of polynomials, power operation\n\nmodule _ where\n -- A polynomial of a finite degree represented as a list of its coefficients.\n -- Examples:\n -- (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x² + a₃⋅x³ + a₄⋅x⁴) of degree 4 is [a₀,a₁,a₂,a₃,a₄]\n -- (5 + 7⋅x + x³) of maximal degree 3 is [5,7,0,1]\n Polynomial : ℕ → Type\n Polynomial(n) = List(ℕ)(ℕ.𝐒(n))\n\n open import Data.ListSized.Functions\n import Functional as Fn\n open import Logic.Propositional\n open import Logic.Predicate\n import Numeral.Natural.Function as ℕ\n open import Numeral.Natural.Function.Proofs\n import Numeral.Natural.Oper as ℕ\n open import Numeral.Natural.Relation.Order\n open import Numeral.Natural.Relation.Order.Proofs\n open import Relator.Equals\n open import Relator.Equals.Proofs.Equiv{T = ℕ}\n\n -- Constant polynomial.\n -- Semantically, this corresponds to a constant.\n const : ℕ → Polynomial(n)\n const {n} a = a ⊰ repeat ℕ.𝟎 n\n\n -- Zero polynomial.\n -- Semantically, this corresponds to zero.\n 𝟎 : Polynomial(n)\n 𝟎 {n} = const{n} ℕ.𝟎\n\n -- Unit polynomial.\n -- Semantically, this corresponds to one.\n 𝟏 : Polynomial(n)\n 𝟏 {n} = const{n}(ℕ.𝐒(ℕ.𝟎))\n\n -- Increases the degree of the polynomial by adding a zero term at the beginning.\n -- Semantically, this corresponds to multiplying the whole polynomial by the variable.\n -- Example: (var⋅ [a₀,a₁,a₂] = [0,a₀,a₁,a₂])\n -- x ⋅ (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²)\n -- = a₀⋅x¹ + a₁⋅x² + a₂⋅x³\n var⋅_ : Polynomial(n) → Polynomial(ℕ.𝐒(n))\n var⋅_ = ℕ.𝟎 ⊰_\n\n -- Single variable polynomial.\n var : Polynomial(ℕ.𝐒(n))\n var = var⋅ 𝟏\n\n -- Polynomial addition.\n -- Adds the powers component-wise.\n -- Examples: ([a₀,a₁,a₂] + [b₀,b₁,b₂] = [a₀b₀ , a₁+b₁ , a₂+b₂])\n -- (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²) + (b₀⋅x⁰ + b₁⋅x¹ + b₂⋅x²)\n -- = (a₀+b₀)⋅x⁰ + (a₁+b₁)⋅x¹ + (a₂+b₂)⋅x²\n -- of maximal degree 2 is [a₀+b₀ , a₁+b₁ , a₂+b₂]\n _+_ : Polynomial(n₁) → Polynomial(n₂) → Polynomial(ℕ.max n₁ n₂)\n _+_ = map₂(ℕ._+_) Fn.id Fn.id\n\n -- Polymonial scalar multiplication.\n -- Multiplies every component by a factor.\n -- Example: (n ⋅ [a₀,a₁,a₂] = [n⋅a₀ , n⋅a₁ , n⋅a₂])\n -- n ⋅ (a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²)\n -- = (n⋅a₀)⋅x⁰ + (n⋅a₁)⋅x¹ + (n⋅a₂)⋅x²\n _⋅_ : ℕ → Polynomial(n) → Polynomial(n)\n n ⋅ as = map (n ℕ.⋅_) as\n\n -- Increases the degree of the polynomial by adding zero terms at the end.\n -- Semantically, this corresponds to adding terms multiplied by zero.\n -- Example: (pad [a₀,a₁,a₂] = [a₀,a₁,a₂,0,0])\n -- a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x²\n -- = a₀⋅x⁰ + a₁⋅x¹ + a₂⋅x² + 0⋅x³ + 0⋅x⁴\n pad : ⦃ _ : (n₁ ≤ n₂)⦄ → Polynomial(n₁) → Polynomial(n₂)\n pad {n₁ = ℕ.𝟎} {n₂ = ℕ.𝟎} ⦃ min ⦄ (a ⊰ ∅) = singleton a\n pad {n₁ = ℕ.𝟎} {n₂ = ℕ.𝐒(n₂)} ⦃ min ⦄ (a ⊰ ∅) = a ⊰ 𝟎\n pad {n₁ = ℕ.𝐒(n₁)} {n₂ = ℕ.𝐒(n₂)} ⦃ succ p ⦄ (a ⊰ as) = a ⊰ pad ⦃ p ⦄ as\n\n -- Polynomial multiplication.\n -- Proof of step:\n -- ∑(0‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(0‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ)\n -- = (a + ∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ)) ⋅ (b + ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))\n -- = (a ⋅ b) + (a ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ)) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ b) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))\n -- = (a⋅b) + (a ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ)) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ b⋅x) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))\n -- = (a⋅b) + (a ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ)⋅x) + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ)⋅x ⋅ b) + (∑(1‥𝐒(n₁))(i ↦ aᵢ⋅xⁱ) ⋅ ∑(1‥𝐒(n₂))(i ↦ bᵢ⋅xⁱ))\n -- = (a⋅b) + (a ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ))⋅x + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ b)⋅x + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ))⋅x²\n -- = (a⋅b) + ((a ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ)) + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ b) + (∑(0‥n₁)(i ↦ aᵢ⋅xⁱ) ⋅ ∑(0‥n₂)(i ↦ bᵢ⋅xⁱ))⋅x)⋅x\n -- Also see `eval-preserves-multiplication`.\n _⨯_ : Polynomial(n₁) → Polynomial(n₂) → Polynomial(n₁ ℕ.+ n₂)\n _⨯_ as@(_ ⊰ _) (b ⊰ ∅) = b ⋅ as\n _⨯_ (a ⊰ ∅) bs@(_ ⊰ _ ⊰ _) = a ⋅ bs\n _⨯_ {ℕ.𝐒 n₁}{ℕ.𝐒 n₂} (a ⊰ as@(_ ⊰ _)) (b ⊰ bs@(_ ⊰ _)) = (a ℕ.⋅ b) ⊰ lr where\n l : Polynomial(n₁ ℕ.+ n₂)\n l = pad ⦃ max-order-[+] ⦄ ((b ⋅ as) + (a ⋅ bs))\n\n r : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))\n r = var⋅ (as ⨯ bs)\n\n lr : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))\n lr = [≡]-substitutionᵣ ([↔]-to-[→] max-defᵣ [≤]-of-[𝐒]) {Polynomial} (l + r)\n\n normalize : Polynomial(n) → ∃(Polynomial)\n normalize {ℕ.𝟎} (x ⊰ ∅) = [∃]-intro ℕ.𝟎 ⦃ x ⊰ ∅ ⦄\n normalize {ℕ.𝐒 n} (ℕ.𝟎 ⊰ p) with normalize{n} p\n ... | [∃]-intro ℕ.𝟎 ⦃ singleton ℕ.𝟎 ⦄ = [∃]-intro ℕ.𝟎 ⦃ singleton ℕ.𝟎 ⦄\n {-# CATCHALL #-}\n ... | [∃]-intro m ⦃ a ⦄ = [∃]-intro (ℕ.𝐒(m)) ⦃ ℕ.𝟎 ⊰ a ⦄\n normalize {ℕ.𝐒 n} (ℕ.𝐒(x) ⊰ p) = [∃]-map ℕ.𝐒 (ℕ.𝐒(x) ⊰_) (normalize{n} p)\n\n degree : Polynomial(n) → ℕ\n degree = [∃]-witness Fn.∘ normalize\n\n 𝐷 : Polynomial(n) → Polynomial(ℕ.𝐏(n))\n 𝐷 {ℕ.𝟎} = Fn.id\n 𝐷 {ℕ.𝐒 n} = map₂₌(ℕ._⋅_) (accumulateIterate n ℕ.𝐒(ℕ.𝐒(ℕ.𝟎))) Fn.∘ tail\n\n import Numeral.Natural.Oper.FlooredDivision as ℕ\n ∫ : Polynomial(n) → Polynomial(ℕ.𝐒(n))\n ∫ {n} p = var⋅(map₂₌(ℕ._⌊/⌋₀_) p (accumulateIterate n ℕ.𝐒(ℕ.𝐒(ℕ.𝟎))))\n\nmodule Semantics where\n open import Data.ListSized.Functions\n open import Logic.Propositional\n open import Numeral.Finite as 𝕟 using (𝕟)\n import Numeral.Natural.Oper as ℕ\n open import Numeral.Natural.Oper.Proofs\n open import Numeral.Natural.Relation.Order\n open import Relator.Equals.Proofs.Equiv{T = ℕ}\n open import Structure.Function.Multi\n open import Structure.Operator\n open import Structure.Operator.Proofs.Util\n open import Structure.Operator.Properties\n open import Structure.Relator.Properties\n open import Structure.Setoid\n open import Syntax.Function\n open import Syntax.Transitivity\n\n eval : Polynomial(n) → (ℕ → ℕ)\n eval (singleton a) _ = a\n eval (a ⊰ al@(_ ⊰ _)) x = a ℕ.+ (x ℕ.⋅ (eval al x))\n\n module Proofs where\n eval-of-[⊰] : ∀{x}{a}{al : Polynomial(n)} → (eval (a ⊰ al) x ≡ a ℕ.+ (x ℕ.⋅ (eval al x)))\n eval-of-[⊰] {ℕ.𝟎} {x} {a} {b ⊰ ∅} = reflexivity(_≡_)\n eval-of-[⊰] {ℕ.𝐒 n} {x} {a} {b ⊰ c ⊰ al} = reflexivity(_≡_)\n\n eval-preserves-var⋅ : ∀{x}{a : Polynomial(n)} → (eval (var⋅ a) x ≡ x ℕ.⋅ (eval a x))\n eval-preserves-var⋅ {n}{x}{a} = eval-of-[⊰] {n}{x}{ℕ.𝟎}{a}\n\n eval-preserves-zero : ∀{x} → (eval{n} 𝟎 x ≡ ℕ.𝟎)\n eval-preserves-zero {ℕ.𝟎} {x} = reflexivity(_≡_)\n eval-preserves-zero {ℕ.𝐒 n} {x} =\n eval(𝟎 {ℕ.𝐒 n}) x 🝖[ _≡_ ]-[]\n eval(ℕ.𝟎 ⊰ 𝟎 {n}) x 🝖[ _≡_ ]-[]\n ℕ.𝟎 ℕ.+ (x ℕ.⋅ eval (𝟎 {n}) x) 🝖[ _≡_ ]-[]\n x ℕ.⋅ eval (𝟎 {n}) x 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-zero{n}{x}) ]\n x ℕ.⋅ ℕ.𝟎 🝖[ _≡_ ]-[ absorberᵣ(ℕ._⋅_)(ℕ.𝟎) {x} ]\n ℕ.𝟎 🝖-end\n\n eval-preserves-const : ∀{x}{a} → (eval{n} (const a) x ≡ a)\n eval-preserves-const {ℕ.𝟎} {x}{a} = reflexivity(_≡_)\n eval-preserves-const {ℕ.𝐒 n} {x}{a} =\n eval{ℕ.𝐒 n} (const a) x 🝖[ _≡_ ]-[]\n eval(a ⊰ repeat ℕ.𝟎 (ℕ.𝐒 n)) x 🝖[ _≡_ ]-[ eval-of-[⊰] {x = x}{a}{repeat ℕ.𝟎 (ℕ.𝐒 n)} ]\n a ℕ.+ (x ℕ.⋅ eval(repeat ℕ.𝟎 (ℕ.𝐒 n)) x) 🝖[ _≡_ ]-[]\n a ℕ.+ (x ℕ.⋅ eval{n} 𝟎 x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (eval-preserves-zero{ℕ.𝐒 n}{x = x}) ]\n a ℕ.+ (x ℕ.⋅ ℕ.𝟎) 🝖[ _≡_ ]-[]\n a ℕ.+ ℕ.𝟎 🝖[ _≡_ ]-[ identityᵣ(ℕ._+_)(ℕ.𝟎) ]\n a 🝖-end\n\n eval-preserves-one : ∀{x} → (eval{n} 𝟏 x ≡ ℕ.𝐒(ℕ.𝟎))\n eval-preserves-one {n}{x} = eval-preserves-const {n}{x}{ℕ.𝐒(ℕ.𝟎)}\n\n eval-preserves-var : ∀{x}{a : Polynomial(n)} → (eval (var{n}) x ≡ x)\n eval-preserves-var {n}{x}{a} =\n eval (var{n}) x 🝖[ _≡_ ]-[ eval-preserves-var⋅{n}{x}{𝟏} ]\n x ℕ.⋅ eval (𝟏 {n}) x 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-one {n}{x}) ]\n x ℕ.⋅ ℕ.𝐒(ℕ.𝟎) 🝖[ _≡_ ]-[ identityᵣ(ℕ._⋅_)(ℕ.𝐒(ℕ.𝟎)) {x} ]\n x 🝖-end\n\n eval-preserves-addition : ∀{x}{a : Polynomial(n₁)}{b : Polynomial(n₂)} → (eval (a + b) x ≡ (eval a x) ℕ.+ (eval b x))\n eval-preserves-addition {x = x} {singleton a} {singleton b} = reflexivity(_≡_)\n eval-preserves-addition {x = x} {singleton a} {b ⊰ bs@(_ ⊰ _)} = associativity(ℕ._+_) {a}{b}\n eval-preserves-addition {x = x} {a ⊰ as@(_ ⊰ _)} {singleton b} =\n eval ((a ⊰ as) + (singleton b)) x 🝖[ _≡_ ]-[]\n (a ℕ.+ b) ℕ.+ (x ℕ.⋅ (eval as x)) 🝖[ _≡_ ]-[ associativity(ℕ._+_) {a}{b} ]\n a ℕ.+ (b ℕ.+ (x ℕ.⋅ (eval as x))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (commutativity(ℕ._+_) {x = b}) ]\n a ℕ.+ ((x ℕ.⋅ (eval as x)) ℕ.+ b) 🝖[ _≡_ ]-[ associativity(ℕ._+_) {a}{x ℕ.⋅ eval as x} ]-sym\n (a ℕ.+ (x ℕ.⋅ (eval as x))) ℕ.+ b 🝖[ _≡_ ]-[]\n (eval (a ⊰ as) x) ℕ.+ (eval (singleton b) x) 🝖-end\n eval-preserves-addition {x = x} {a ⊰ as@(_ ⊰ _)} {b ⊰ bs@(_ ⊰ _)} =\n eval ((a ⊰ as) + (b ⊰ bs)) x 🝖[ _≡_ ]-[]\n eval ((a ℕ.+ b) ⊰ (as + bs)) x 🝖[ _≡_ ]-[]\n (a ℕ.+ b) ℕ.+ (x ℕ.⋅ (eval (as + bs) x)) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.+ b) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-addition {x = x}{as}{bs})) ]\n (a ℕ.+ b) ℕ.+ (x ℕ.⋅ ((eval as x) ℕ.+ (eval bs x))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.+ b) (distributivityₗ(ℕ._⋅_)(ℕ._+_) {x}{eval as x}{eval bs x}) ]\n (a ℕ.+ b) ℕ.+ ((x ℕ.⋅ (eval as x)) ℕ.+ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[ One.associate-commute4 {a = a}{b = b}{c = x ℕ.⋅ (eval as x)}{d = x ℕ.⋅ (eval bs x)} (commutativity(ℕ._+_) {b}) ]\n (a ℕ.+ (x ℕ.⋅ (eval as x))) ℕ.+ (b ℕ.+ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[]\n (eval (a ⊰ as) x) ℕ.+ (eval (b ⊰ bs) x) 🝖-end\n\n eval-preserves-scalar-multiplication : ∀{x}{a}{b : Polynomial(n)} → (eval (a ⋅ b) x ≡ a ℕ.⋅ (eval b x))\n eval-preserves-scalar-multiplication {ℕ.𝟎} {x} {a} {b ⊰ ∅} = reflexivity(_≡_)\n eval-preserves-scalar-multiplication {ℕ.𝐒 n} {x} {a} {b ⊰ bs@(_ ⊰ _)} =\n eval (a ⋅ (b ⊰ bs)) x 🝖[ _≡_ ]-[]\n eval ((a ℕ.⋅ b) ⊰ (a ⋅ bs)) x 🝖[ _≡_ ]-[]\n (a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (eval (a ⋅ bs) x)) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-scalar-multiplication {n} {x}{a}{bs})) ]\n (a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (a ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (One.commuteₗ-assocᵣ {a = x}{b = a}{c = eval bs x}) ]\n (a ℕ.⋅ b) ℕ.+ (a ℕ.⋅ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[ distributivityₗ(ℕ._⋅_)(ℕ._+_) {x = a}{y = b}{z = x ℕ.⋅ (eval bs x)} ]-sym\n a ℕ.⋅ (b ℕ.+ (x ℕ.⋅ (eval bs x))) 🝖[ _≡_ ]-[]\n a ℕ.⋅ eval (b ⊰ bs) x 🝖-end\n\n eval-preserves-pad : ∀{x}{a : Polynomial(n₁)} ⦃ ord : (n₁ ≤ n₂) ⦄ → (eval (pad ⦃ ord ⦄ a) x ≡ eval a x)\n eval-preserves-pad {ℕ.𝟎} {ℕ.𝟎} {x} {a ⊰ ∅} ⦃ ord@min ⦄ = reflexivity(_≡_)\n eval-preserves-pad {ℕ.𝟎} {ℕ.𝐒 n₂} {x} {a ⊰ ∅} ⦃ ord@min ⦄ =\n eval (pad ⦃ ord ⦄ (a ⊰ ∅)) x 🝖[ _≡_ ]-[]\n a ℕ.+ (x ℕ.⋅ eval (𝟎 {n₂}) x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-zero{n₂}{x})) ]\n a ℕ.+ (x ℕ.⋅ ℕ.𝟎) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (absorberᵣ(ℕ._⋅_)(ℕ.𝟎) {x}) ]\n a ℕ.+ ℕ.𝟎 🝖[ _≡_ ]-[ identityᵣ(ℕ._+_)(ℕ.𝟎) ]\n a 🝖[ _≡_ ]-[]\n eval (a ⊰ ∅) x 🝖-end\n eval-preserves-pad {ℕ.𝐒 n₁} {ℕ.𝐒 n₂} {x} {a ⊰ as@(_ ⊰ _)} ⦃ ord@(succ p) ⦄ =\n eval (pad ⦃ ord ⦄ (a ⊰ as)) x 🝖[ _≡_ ]-[]\n eval (a ⊰ pad ⦃ _ ⦄ as) x 🝖[ _≡_ ]-[ eval-of-[⊰] {n₂}{x}{a}{pad ⦃ p ⦄ as} ]\n a ℕ.+ (x ℕ.⋅ eval (pad ⦃ _ ⦄ as) x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a) (congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-pad {n₁}{n₂}{x}{as} ⦃ p ⦄)) ]\n a ℕ.+ (x ℕ.⋅ eval as x) 🝖[ _≡_ ]-[ eval-of-[⊰] {n₁}{x}{a}{as} ]-sym\n eval (a ⊰ as) x 🝖-end\n\n eval-preserves-multiplication : ∀{x}{a : Polynomial(n₁)}{b : Polynomial(n₂)} → (eval (a ⨯ b) x ≡ (eval a x) ℕ.⋅ (eval b x))\n eval-preserves-multiplication {n₁} {ℕ.𝟎} {x} {a ⊰ as} {b ⊰ ∅} =\n eval ((a ⊰ as) ⨯ (b ⊰ ∅)) x 🝖[ _≡_ ]-[]\n eval (b ⋅ (a ⊰ as)) x 🝖[ _≡_ ]-[ eval-preserves-scalar-multiplication {x = x}{b}{a ⊰ as} ]\n b ℕ.⋅ eval (a ⊰ as) x 🝖[ _≡_ ]-[ commutativity(ℕ._⋅_) {b}{eval(a ⊰ as) x} ]\n eval (a ⊰ as) x ℕ.⋅ b 🝖[ _≡_ ]-[]\n (eval (a ⊰ as) x ℕ.⋅ eval (b ⊰ ∅) x) 🝖-end\n eval-preserves-multiplication {ℕ.𝟎} {ℕ.𝐒 n₂}{x} {a ⊰ ∅} {b ⊰ bs@(_ ⊰ _)} =\n eval ((a ⊰ ∅) ⨯ (b ⊰ bs)) x 🝖[ _≡_ ]-[]\n eval (a ⋅ (b ⊰ bs)) x 🝖[ _≡_ ]-[ eval-preserves-scalar-multiplication {x = x}{a}{b ⊰ bs} ]\n a ℕ.⋅ (b ℕ.+ (x ℕ.⋅ eval bs x)) 🝖[ _≡_ ]-[]\n eval (a ⊰ ∅) x ℕ.⋅ eval (b ⊰ bs) x 🝖-end\n eval-preserves-multiplication {ℕ.𝐒 n₁}{ℕ.𝐒 n₂}{x} {a ⊰ as@(_ ⊰ _)} {b ⊰ bs@(_ ⊰ _)} =\n eval((a ℕ.⋅ b) ⊰ lr) x 🝖[ _≡_ ]-[ eval-of-[⊰] {x = x}{a = a ℕ.⋅ b}{al = lr} ]\n (a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ eval lr x) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂ᵣ(ℕ._⋅_)(x) eval-lr) ]\n (a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (((b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x)) ℕ.+ (x ℕ.⋅ (eval as x ℕ.⋅ eval bs x)))) 🝖[ _≡_ ]-[ alg{a}{b}{x}{eval as x}{eval bs x} ]\n (a ℕ.+ (x ℕ.⋅ eval as x)) ℕ.⋅ (b ℕ.+ (x ℕ.⋅ eval bs x)) 🝖[ _≡_ ]-[ congruence₂(ℕ._⋅_) (eval-of-[⊰] {x = x}{a = a}{al = as}) (eval-of-[⊰] {x = x}{a = b}{al = bs}) ]\n (eval(a ⊰ as) x ℕ.⋅ eval(b ⊰ bs) x) 🝖-end\n where\n open import Numeral.Natural.Function\n open import Numeral.Natural.Function.Proofs\n open import Numeral.Natural.Relation.Order.Proofs\n open import Relator.Equals using ([≡]-intro)\n\n l : Polynomial(n₁ ℕ.+ n₂)\n l = pad ⦃ max-order-[+] ⦄ ((b ⋅ as) + (a ⋅ bs))\n\n r : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))\n r = var⋅ (as ⨯ bs)\n\n lr : Polynomial(ℕ.𝐒(n₁ ℕ.+ n₂))\n lr = [≡]-substitutionᵣ ([↔]-to-[→] max-defᵣ [≤]-of-[𝐒]) {Polynomial} (l + r)\n\n eval-l : (eval l x ≡ (b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x))\n eval-l =\n eval l x 🝖[ _≡_ ]-[]\n eval (pad ⦃ max-order-[+] ⦄ ((b ⋅ as) + (a ⋅ bs))) x 🝖[ _≡_ ]-[ eval-preserves-pad {x = x}{(b ⋅ as) + (a ⋅ bs)} ⦃ max-order-[+] ⦄ ]\n eval ((b ⋅ as) + (a ⋅ bs)) x 🝖[ _≡_ ]-[ eval-preserves-addition {x = x}{b ⋅ as}{a ⋅ bs} ]\n eval (b ⋅ as) x ℕ.+ eval (a ⋅ bs) x 🝖[ _≡_ ]-[ congruence₂(ℕ._+_) (eval-preserves-scalar-multiplication {x = x}{b}{as}) (eval-preserves-scalar-multiplication {x = x}{a}{bs}) ]\n (b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x) 🝖-end\n\n eval-r : (eval r x ≡ x ℕ.⋅ (eval as x ℕ.⋅ eval bs x))\n eval-r =\n eval r x 🝖[ _≡_ ]-[]\n eval (var⋅ (as ⨯ bs)) x 🝖[ _≡_ ]-[ eval-preserves-var⋅ {x = x}{as ⨯ bs} ]\n x ℕ.⋅ eval (as ⨯ bs) x 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._⋅_)(x) (eval-preserves-multiplication {x = x}{as}{bs}) ]\n x ℕ.⋅ (eval as x ℕ.⋅ eval bs x) 🝖-end\n\n eval-substitution : ∀{m n}{a : Polynomial(m)}{eq : (m ≡ n)}{x} → (eval ([≡]-substitutionᵣ eq {Polynomial} a) x ≡ eval a x)\n eval-substitution {eq = [≡]-intro} = [≡]-intro\n\n eval-lr : (eval lr x ≡ ((b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x)) ℕ.+ (x ℕ.⋅ (eval as x ℕ.⋅ eval bs x)))\n eval-lr =\n eval lr x 🝖[ _≡_ ]-[ eval-substitution{a = l + r}{[↔]-to-[→] max-defᵣ [≤]-of-[𝐒]}{x = x} ]\n eval (l + r) x 🝖[ _≡_ ]-[ eval-preserves-addition{x = x}{l}{r} ]\n eval l x ℕ.+ eval r x 🝖[ _≡_ ]-[ congruence₂(ℕ._+_) eval-l eval-r ]\n ((b ℕ.⋅ eval as x) ℕ.+ (a ℕ.⋅ eval bs x)) ℕ.+ (x ℕ.⋅ (eval as x ℕ.⋅ eval bs x)) 🝖-end\n\n alg : ∀{a b x q r} → ((a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (((b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r)) ℕ.+ (x ℕ.⋅ (q ℕ.⋅ r)))) ≡ (a ℕ.+ (x ℕ.⋅ q)) ℕ.⋅ (b ℕ.+ (x ℕ.⋅ r)))\n alg {a}{b}{x}{q}{r} =\n (a ℕ.⋅ b) ℕ.+ (x ℕ.⋅ (((b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r)) ℕ.+ (x ℕ.⋅ (q ℕ.⋅ r)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (distributivityₗ(ℕ._⋅_)(ℕ._+_) {x}{(b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r)}{x ℕ.⋅ (q ℕ.⋅ r)}) ]\n (a ℕ.⋅ b) ℕ.+ ((x ℕ.⋅ ((b ℕ.⋅ q) ℕ.+ (a ℕ.⋅ r))) ℕ.+ (x ℕ.⋅ (x ℕ.⋅ (q ℕ.⋅ r)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂(ℕ._+_) (distributivityₗ(ℕ._⋅_)(ℕ._+_) {x}{b ℕ.⋅ q}{a ℕ.⋅ r}) (symmetry(_≡_) (associativity(ℕ._⋅_) {x}{x}{q ℕ.⋅ r}))) ]\n (a ℕ.⋅ b) ℕ.+ (((x ℕ.⋅ (b ℕ.⋅ q)) ℕ.+ (x ℕ.⋅ (a ℕ.⋅ r))) ℕ.+ ((x ℕ.⋅ x) ℕ.⋅ (q ℕ.⋅ r))) 🝖[ _≡_ ]-[ congruence₂ᵣ(ℕ._+_)(a ℕ.⋅ b) (congruence₂(ℕ._+_) (congruence₂(ℕ._+_) (One.commuteᵣ-assocᵣ {_▫_ = ℕ._⋅_}{a = x}{b}{q}) (One.commuteₗ-assocᵣ {_▫_ = ℕ._⋅_}{a = x}{a}{r})) (One.associate-commute4-c {_▫_ = ℕ._⋅_}{a = x}{x}{q}{r})) ]\n (a ℕ.⋅ b) ℕ.+ ((((x ℕ.⋅ q) ℕ.⋅ b) ℕ.+ (a ℕ.⋅ (x ℕ.⋅ r))) ℕ.+ ((x ℕ.⋅ q) ℕ.⋅ (x ℕ.⋅ r))) 🝖[ _≡_ ]-[ One.associate4-231-222 {_▫_ = ℕ._+_} {a = a ℕ.⋅ b}{(x ℕ.⋅ q) ℕ.⋅ b}{a ℕ.⋅ (x ℕ.⋅ r)}{(x ℕ.⋅ q) ℕ.⋅ (x ℕ.⋅ r)} ]\n ((a ℕ.⋅ b) ℕ.+ ((x ℕ.⋅ q) ℕ.⋅ b)) ℕ.+ ((a ℕ.⋅ (x ℕ.⋅ r)) ℕ.+ ((x ℕ.⋅ q) ℕ.⋅ (x ℕ.⋅ r))) 🝖[ _≡_ ]-[ OneTypeTwoOp.cross-distribute{a = a}{x ℕ.⋅ q}{b}{x ℕ.⋅ r} ]-sym\n (a ℕ.+ (x ℕ.⋅ q)) ℕ.⋅ (b ℕ.+ (x ℕ.⋅ r)) 🝖-end\n", "meta": {"hexsha": "0b368956c4f9a2ff926ef1af52856caeea7c34ca", "size": 18202, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/Polynomial.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/Polynomial.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/Polynomial.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": 60.0726072607, "max_line_length": 338, "alphanum_fraction": 0.4531919569, "num_tokens": 9124, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872046026642944, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.5964957663790761}} {"text": "module Issue690a where\n\ndata ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n-- A negative type.\ndata T : Set → Set where\n c : T (T ℕ)\n\n-- From Andreas (2012-09-07) message on Agda mailing list \"Forget\n-- Hurken's paradox ...\"\n--\n-- Trying to make sense of T in terms of inductive types, explaining\n-- indices via equalities, one arrives at\n--\n-- data T (X : Set) : Set where\n-- c : (X ≡ T ℕ) → T X\n--\n-- which has a non-positive occurrence of T in (X ≡ T ℕ).\n--\n-- An argument for the existence of T would have to argue for the\n-- existence this least fixed point:\n--\n-- lfp \\lambda T X → (X ≡ T ℕ)\n\n\n-- ASR (14 August 2014): In Coq'Art, § 14.1.2.1, the type T is\n-- rejected due to the head type constrains.\n", "meta": {"hexsha": "3176c89c379feab32995354a595adab0d08108b9", "size": 709, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue690a.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/Issue690a.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/Issue690a.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.6333333333, "max_line_length": 68, "alphanum_fraction": 0.634696756, "num_tokens": 226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240895276223, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.5964038246894637}} {"text": "{-# OPTIONS --cubical --no-import-sorts #-}\n\nmodule SetQuotientTest where\n\nopen import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)\nopen import Cubical.Foundations.Logic renaming (inl to inlᵖ; inr to inrᵖ)\nopen import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥)\nopen import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)\nopen import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_)\nopen import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)\nopen import Cubical.Data.NatPlusOne using (HasFromNat; 1+_; ℕ₊₁; ℕ₊₁→ℕ)\nopen import Cubical.HITs.Ints.QuoInt using (HasFromNat; signed) renaming\n ( abs to absᶻ\n ; pos to pos\n ; neg to neg\n )\nopen import Cubical.HITs.Ints.QuoInt hiding (_+_; -_; +-assoc; +-comm)\nopen import Cubical.HITs.Rationals.QuoQ using\n ( ℚ\n ; onCommonDenom\n ; onCommonDenomSym\n ; eq/\n ; _//_\n ; _∼_\n ; isSetℚ\n )\n renaming\n ( [_] to [_]ᶠ\n ; ℕ₊₁→ℤ to [1+_ⁿ]ᶻ\n )\nopen import Cubical.HITs.SetQuotients as SetQuotient using () renaming (_/_ to _//_)\n\npostulate\n _<ᶻ_ : ℤ → ℤ → hProp ℓ-zero\n\n_<'_ : ℤ × ℕ₊₁ → ℤ × ℕ₊₁ → hProp ℓ-zero\n(aᶻ , aⁿ) <' (bᶻ , bⁿ) =\n let aⁿᶻ = [1+ aⁿ ⁿ]ᶻ\n bⁿᶻ = [1+ bⁿ ⁿ]ᶻ\n in (aᶻ * bⁿᶻ) <ᶻ (bᶻ * aⁿᶻ)\n\npostulate\n <'-respects-∼ˡ : ∀ a b x → a ∼ b → a <' x ≡ b <' x\n <'-respects-∼ʳ : ∀ x a b → a ∼ b → x <' a ≡ x <' b\n\n_<_ : ℚ → ℚ → hProp ℓ-zero\na < b = SetQuotient.rec2 {R = _∼_} {B = hProp ℓ-zero} isSetHProp _<'_ <'-respects-∼ˡ <'-respects-∼ʳ a b\n\nisProp⊎ˡ : ∀{ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → isProp A → isProp B → (A → ¬ᵗ B) → isProp (A ⊎ B)\nisProp⊎ˡ pA pB A⇒¬B (inl x) (inl y) = cong inl (pA x y)\nisProp⊎ˡ pA pB A⇒¬B (inr x) (inr y) = cong inr (pB x y)\nisProp⊎ˡ pA pB A⇒¬B (inl x) (inr y) = ⊥-elim (A⇒¬B x y)\nisProp⊎ˡ pA pB A⇒¬B (inr x) (inl y) = ⊥-elim (A⇒¬B y x)\n\n⊎ᵖ-syntax : ∀{ℓ ℓ'} (P : hProp ℓ) (Q : hProp ℓ') → {[ P ] → [ ¬ Q ]} → hProp _\n⊎ᵖ-syntax P Q {P⇒¬Q} = ([ P ] ⊎ [ Q ]) , isProp⊎ˡ (isProp[] P) (isProp[] Q) P⇒¬Q\n\nsyntax ⊎ᵖ-syntax P Q {P⇒¬Q} = [ P⇒¬Q ] P ⊎ᵖ Q\n\npostulate\n <-asym : ∀ x y → [ x < y ] → [ ¬(y < x) ]\n\n_#_ : ℚ → ℚ → hProp ℓ-zero\nx # y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x)\n\n_⁻¹''' : (x : ℚ) → [ x # 0 ] → ℚ\n_⁻¹''' = SetQuotient.elim {R = _∼_} {B = λ x → [ x # 0 ] → ℚ} φ _⁻¹'' ⁻¹''-respects-∼ where\n φ : ∀ x → isSet ([ x # 0 ] → ℚ)\n φ x = isSetΠ (λ _ → isSetℚ)\n _⁻¹'' : (a : ℤ × ℕ₊₁) → [ [ a ]ᶠ # 0 ] → ℚ\n x ⁻¹'' = {!!}\n ⁻¹''-respects-∼ : (a b : ℤ × ℕ₊₁) (r : a ∼ b)\n → PathP (λ i → [ eq/ a b r i # 0 ] → ℚ) (a ⁻¹'') (b ⁻¹'')\n ⁻¹''-respects-∼ a b r = {!!}\n", "meta": {"hexsha": "219e51b894ccb1f1ff1f536302a42d526f729935", "size": 2547, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/SetQuotientTest.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": "test/SetQuotientTest.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": "test/SetQuotientTest.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": 33.96, "max_line_length": 103, "alphanum_fraction": 0.537887711, "num_tokens": 1326, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240895276223, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5964038246894636}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Almost commutative rings\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Tactic.RingSolver.Core.AlmostCommutativeRing where\n\nopen import Level\nopen import Relation.Binary\nopen import Algebra.Core using (Op₁; Op₂)\nopen import Algebra.Structures using (IsCommutativeSemiring)\nopen import Algebra.Definitions\nopen import Algebra.Bundles using (RawRing; CommutativeRing; CommutativeSemiring)\nimport Algebra.Morphism as Morphism\nopen import Function\nopen import Level\nopen import Data.Maybe.Base as Maybe using (Maybe; just; nothing)\n\nrecord IsAlmostCommutativeRing\n {a ℓ} {A : Set a} (_≈_ : Rel A ℓ)\n (_+_ _*_ : A → A → A) (-_ : A → A) (0# 1# : A) : Set (a ⊔ ℓ) where\n field\n isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1#\n -‿cong : -_ Preserves _≈_ ⟶ _≈_\n -‿*-distribˡ : ∀ x y → ((- x) * y) ≈ (- (x * y))\n -‿+-comm : ∀ x y → ((- x) + (- y)) ≈ (- (x + y))\n\n open IsCommutativeSemiring isCommutativeSemiring public\n\nimport Algebra.Operations.Ring as Exp\n\nrecord AlmostCommutativeRing c ℓ : Set (suc (c ⊔ ℓ)) where\n infix 8 -_\n infixl 7 _*_\n infixl 6 _+_\n infix 4 _≈_\n infixr 8 _^_\n field\n Carrier : Set c\n _≈_ : Rel Carrier ℓ\n _+_ : Op₂ Carrier\n _*_ : Op₂ Carrier\n -_ : Op₁ Carrier\n 0# : Carrier\n 0≟_ : (x : Carrier) → Maybe (0# ≈ x)\n 1# : Carrier\n isAlmostCommutativeRing :\n IsAlmostCommutativeRing _≈_ _+_ _*_ -_ 0# 1#\n\n open IsAlmostCommutativeRing isAlmostCommutativeRing hiding (refl) public\n open import Data.Nat.Base as ℕ using (ℕ)\n\n commutativeSemiring : CommutativeSemiring _ _\n commutativeSemiring = record\n { isCommutativeSemiring = isCommutativeSemiring\n }\n\n open CommutativeSemiring commutativeSemiring public\n using ( +-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 _^_ : Carrier → ℕ → Carrier\n _^_ = Exp._^_ rawRing\n {-# NOINLINE _^_ #-}\n\n refl : ∀ {x} → x ≈ x\n refl = IsAlmostCommutativeRing.refl isAlmostCommutativeRing\n\nrecord _-Raw-AlmostCommutative⟶_\n {r₁ r₂ r₃ r₄}\n (From : RawRing r₁ r₂)\n (To : AlmostCommutativeRing r₃ r₄) : Set (r₁ ⊔ r₂ ⊔ r₃ ⊔ r₄) where\n private\n module F = RawRing From\n module T = AlmostCommutativeRing To\n open Morphism.Definitions F.Carrier T.Carrier T._≈_\n field\n ⟦_⟧ : Morphism\n +-homo : Homomorphic₂ ⟦_⟧ F._+_ T._+_\n *-homo : Homomorphic₂ ⟦_⟧ F._*_ T._*_\n -‿homo : Homomorphic₁ ⟦_⟧ F.-_ T.-_\n 0-homo : Homomorphic₀ ⟦_⟧ F.0# T.0#\n 1-homo : Homomorphic₀ ⟦_⟧ F.1# T.1#\n\n-raw-almostCommutative⟶\n : ∀ {r₁ r₂} (R : AlmostCommutativeRing r₁ 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-- A homomorphism induces a notion of equivalence on the raw ring.\n\nInduced-equivalence :\n ∀ {c₁ c₂ c₃ ℓ} {Coeff : RawRing c₁ c₂} {R : AlmostCommutativeRing c₃ ℓ} →\n Coeff -Raw-AlmostCommutative⟶ R → Rel (RawRing.Carrier Coeff) ℓ\nInduced-equivalence {R = R} morphism a b = ⟦ a ⟧ ≈ ⟦ b ⟧\n where\n open AlmostCommutativeRing R\n open _-Raw-AlmostCommutative⟶_ morphism\n\n------------------------------------------------------------------------\n-- Conversions\n\n-- Commutative rings are almost commutative rings.\n\nfromCommutativeRing : ∀ {r₁ r₂} (CR : CommutativeRing r₁ r₂) →\n (open CommutativeRing CR) →\n (∀ x → Maybe (0# ≈ x)) →\n AlmostCommutativeRing _ _\nfromCommutativeRing CR 0≟_ = record\n { isAlmostCommutativeRing = record\n { isCommutativeSemiring = isCommutativeSemiring\n ; -‿cong = -‿cong\n ; -‿*-distribˡ = -‿*-distribˡ\n ; -‿+-comm = ⁻¹-∙-comm\n }\n ; 0≟_ = 0≟_\n }\n where\n open CommutativeRing CR\n open import Algebra.Properties.Ring ring\n open import Algebra.Properties.AbelianGroup +-abelianGroup\n\nfromCommutativeSemiring : ∀ {r₁ r₂} (CS : CommutativeSemiring r₁ r₂)\n (open CommutativeSemiring CS) →\n (∀ x → Maybe (0# ≈ x)) →\n AlmostCommutativeRing _ _\nfromCommutativeSemiring CS 0≟_ = record\n { -_ = id\n ; isAlmostCommutativeRing = record\n { isCommutativeSemiring = isCommutativeSemiring\n ; -‿cong = id\n ; -‿*-distribˡ = λ _ _ → refl\n ; -‿+-comm = λ _ _ → refl\n }\n ; 0≟_ = 0≟_\n }\n where open CommutativeSemiring CS\n", "meta": {"hexsha": "7eb859d28ca4c0ea3abf4723a0b0324848a4225a", "size": 5138, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/AlmostCommutativeRing.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/AlmostCommutativeRing.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/AlmostCommutativeRing.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.9130434783, "max_line_length": 81, "alphanum_fraction": 0.5607240171, "num_tokens": 1723, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240860523328, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5964038222939271}} {"text": "module Data.Star.Indexed where\n\nopen import Relation.Binary\nopen import Function\nopen import Level\n\ninfixr 10 _◅_\ndata Star {i a t}(I : Set i){A : I → Set a}\n (T : ∀ n m → REL (A n) (A m) t) : ∀ {n m : I} → REL (A n) (A m) (i ⊔ a ⊔ t) where\n ε : ∀ {i}{x : A i} → Star I T x x\n _◅_ : ∀ {n m k : I}{x : A n}{y : A m}{z : A k} → T n m x y → Star I T y z → Star I T x z\n", "meta": {"hexsha": "a6348f727b7c34400c8c305739f778a228a36af9", "size": 374, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Star/Indexed.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/Star/Indexed.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/Star/Indexed.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": 31.1666666667, "max_line_length": 90, "alphanum_fraction": 0.5160427807, "num_tokens": 165, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240686758841, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.5964037992715435}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Categories.Definition\n\nmodule Categories.Functor.Definition where\n\nrecord Functor {a b c d : _} (C : Category {a} {b}) (D : Category {c} {d}) : Set (a ⊔ b ⊔ c ⊔ d) where\n field\n onObj : Category.objects C → Category.objects D\n onArrow : {S T : Category.objects C} → Category.arrows C S T → Category.arrows D (onObj S) (onObj T)\n mapId : {T : Category.objects C} → onArrow (Category.id C T) ≡ Category.id D (onObj T)\n mapCompose : {X Y Z : Category.objects C} → (f : Category.arrows C X Y) (g : Category.arrows C Y Z) → onArrow (Category._∘_ C g f) ≡ Category._∘_ D (onArrow g) (onArrow f)\n", "meta": {"hexsha": "663546f348297e0ae3378abd5879ec509c41155f", "size": 753, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Functor/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": "Categories/Functor/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": "Categories/Functor/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": 50.2, "max_line_length": 175, "alphanum_fraction": 0.6653386454, "num_tokens": 244, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513731336202, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.5963751329212214}} {"text": "{-\n\nThis file contains basic theory about subgroups.\n\nThe definition is the same as the first definition of subgroups in:\n\nhttps://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#subgroups-sip\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Group.Subgroup where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Powerset\nopen import Cubical.Foundations.GroupoidLaws hiding (assoc)\nopen import Cubical.Data.Sigma\nopen import Cubical.HITs.PropositionalTruncation\n\nopen import Cubical.Algebra.Group.Base\nopen import Cubical.Algebra.Group.Properties\nopen import Cubical.Algebra.Group.Morphisms\nopen import Cubical.Algebra.Group.MorphismProperties\n\nprivate\n variable\n ℓ : Level\n\n-- We assume an ambient group\nmodule _ (G' : Group ℓ) where\n\n open GroupStr (snd G')\n private G = ⟨ G' ⟩\n\n record isSubgroup (H : ℙ G) : Type ℓ where\n field\n id-closed : (1g ∈ H)\n op-closed : {x y : G} → x ∈ H → y ∈ H → x · y ∈ H\n inv-closed : {x : G} → x ∈ H → inv x ∈ H\n\n open isSubgroup\n\n Subgroup : Type (ℓ-suc ℓ)\n Subgroup = Σ[ H ∈ ℙ G ] isSubgroup H\n\n isPropIsSubgroup : (H : ℙ G) → isProp (isSubgroup H)\n id-closed (isPropIsSubgroup H h1 h2 i) =\n ∈-isProp H 1g (h1 .id-closed) (h2 .id-closed) i\n op-closed (isPropIsSubgroup H h1 h2 i) Hx Hy =\n ∈-isProp H _ (h1 .op-closed Hx Hy) (h2 .op-closed Hx Hy) i\n inv-closed (isPropIsSubgroup H h1 h2 i) Hx =\n ∈-isProp H _ (h1 .inv-closed Hx) (h2 .inv-closed Hx) i\n\n isSetSubgroup : isSet Subgroup\n isSetSubgroup = isSetΣ isSetℙ λ x → isProp→isSet (isPropIsSubgroup x)\n\n Subgroup→Group : Subgroup → Group ℓ\n Subgroup→Group (H , Hh) = makeGroup-right 1HG _·HG_ invHG isSetHG assocHG ridHG invrHG\n where\n HG = Σ[ x ∈ G ] ⟨ H x ⟩\n isSetHG = isSetΣ is-set (λ x → isProp→isSet (H x .snd))\n\n 1HG : HG\n 1HG = (1g , (id-closed Hh))\n\n _·HG_ : HG → HG → HG\n (x , Hx) ·HG (y , Hy) = (x · y) , (op-closed Hh Hx Hy)\n\n invHG : HG → HG\n invHG (x , Hx) = inv x , inv-closed Hh Hx\n\n assocHG : (x y z : HG) → x ·HG (y ·HG z) ≡ (x ·HG y) ·HG z\n assocHG (x , Hx) (y , Hy) (z , Hz) =\n ΣPathP (·Assoc x y z , isProp→PathP (λ i → H (·Assoc x y z i) .snd) _ _)\n\n ridHG : (x : HG) → x ·HG 1HG ≡ x\n ridHG (x , Hx) = ΣPathP (·IdR x , isProp→PathP (λ i → H (·IdR x i) .snd) _ _)\n\n invrHG : (x : HG) → x ·HG invHG x ≡ 1HG\n invrHG (x , Hx) = ΣPathP (·InvR x , isProp→PathP (λ i → H (·InvR x i) .snd) _ _)\n\n⟪_⟫ : {G' : Group ℓ} → Subgroup G' → ℙ (G' .fst)\n⟪ H , _ ⟫ = H\n\nmodule _ {G' : Group ℓ} where\n\n open GroupStr (snd G')\n open isSubgroup\n open GroupTheory G'\n private G = ⟨ G' ⟩\n\n isNormal : Subgroup G' → Type ℓ\n isNormal H = (g h : G) → h ∈ ⟪ H ⟫ → g · h · inv g ∈ ⟪ H ⟫\n\n isPropIsNormal : (H : Subgroup G') → isProp (isNormal H)\n isPropIsNormal H = isPropΠ3 λ g h _ → ∈-isProp ⟪ H ⟫ (g · h · inv g)\n\n ·CommNormalSubgroup : (H : Subgroup G') (Hnormal : isNormal H) {x y : G}\n → x · y ∈ ⟪ H ⟫ → y · x ∈ ⟪ H ⟫\n ·CommNormalSubgroup H Hnormal {x = x} {y = y} Hxy =\n subst-∈ ⟪ H ⟫ rem (Hnormal (inv x) (x · y) Hxy)\n where\n rem : inv x · (x · y) · inv (inv x) ≡ y · x\n rem = inv x · (x · y) · inv (inv x) ≡⟨ ·Assoc _ _ _ ⟩\n (inv x · x · y) · inv (inv x) ≡⟨ (λ i → ·Assoc (inv x) x y i · invInv x i) ⟩\n ((inv x · x) · y) · x ≡⟨ cong (λ z → (z · y) · x) (·InvL x) ⟩\n (1g · y) · x ≡⟨ cong (_· x) (·IdL y) ⟩\n y · x ∎\n\n\n -- Examples of subgroups\n\n -- We can view all of G as a subset of itself\n groupSubset : ℙ G\n groupSubset x = (x ≡ x) , is-set x x\n\n isSubgroupGroup : isSubgroup G' groupSubset\n id-closed isSubgroupGroup = refl\n op-closed isSubgroupGroup _ _ = refl\n inv-closed isSubgroupGroup _ = refl\n\n groupSubgroup : Subgroup G'\n groupSubgroup = groupSubset , isSubgroupGroup\n\n -- The trivial subgroup\n trivialSubset : ℙ G\n trivialSubset x = (x ≡ 1g) , is-set x 1g\n\n isSubgroupTrivialGroup : isSubgroup G' trivialSubset\n id-closed isSubgroupTrivialGroup = refl\n op-closed isSubgroupTrivialGroup hx hy = cong (_· _) hx ∙∙ ·IdL _ ∙∙ hy\n inv-closed isSubgroupTrivialGroup hx = cong inv hx ∙ inv1g\n\n trivialSubgroup : Subgroup G'\n trivialSubgroup = trivialSubset , isSubgroupTrivialGroup\n\n isNormalTrivialSubgroup : isNormal trivialSubgroup\n isNormalTrivialSubgroup g h h≡1 =\n (g · h · inv g) ≡⟨ (λ i → g · h≡1 i · inv g) ⟩\n (g · 1g · inv g) ≡⟨ ·Assoc _ _ _ ∙ cong (_· inv g) (·IdR g) ⟩\n (g · inv g) ≡⟨ ·InvR g ⟩\n 1g ∎\n\nNormalSubgroup : (G : Group ℓ) → Type _\nNormalSubgroup G = Σ[ G ∈ Subgroup G ] isNormal G\n\n\n-- Can one get this to work with different universes for G and H?\nmodule _ {G H : Group ℓ} (ϕ : GroupHom G H) where\n\n open isSubgroup\n open GroupTheory\n\n private\n module G = GroupStr (snd G)\n module H = GroupStr (snd H)\n f = ϕ .fst\n module ϕ = IsGroupHom (ϕ .snd)\n\n imSubset : ℙ ⟨ H ⟩\n imSubset x = isInIm ϕ x , isPropIsInIm ϕ x\n\n isSubgroupIm : isSubgroup H imSubset\n id-closed isSubgroupIm = ∣ G.1g , ϕ.pres1 ∣₁\n op-closed isSubgroupIm =\n map2 λ { (x , hx) (y , hy) → x G.· y , ϕ.pres· x y ∙ λ i → hx i H.· hy i }\n inv-closed isSubgroupIm = map λ { (x , hx) → G.inv x , ϕ.presinv x ∙ cong H.inv hx }\n\n imSubgroup : Subgroup H\n imSubgroup = imSubset , isSubgroupIm\n\n imGroup : Group ℓ\n imGroup = Subgroup→Group _ imSubgroup\n\n isNormalIm : ((x y : ⟨ H ⟩) → x H.· y ≡ y H.· x)\n → isNormal imSubgroup\n isNormalIm comm x y =\n map λ {(g , p)\n → g ,\n (ϕ .fst g ≡⟨ p ⟩\n y ≡⟨ sym (H.·IdR y) ⟩\n (y H.· H.1g) ≡⟨ cong (y H.·_) (sym (H.·InvR x)) ⟩\n (y H.· (x H.· H.inv x)) ≡⟨ H.·Assoc y x (H.inv x) ⟩\n ((y H.· x) H.· H.inv x) ≡⟨ cong (H._· H.inv x) (comm y x) ⟩\n ((x H.· y) H.· H.inv x) ≡⟨ sym (H.·Assoc x y (H.inv x)) ⟩\n x H.· y H.· H.inv x ∎ )}\n\n kerSubset : ℙ ⟨ G ⟩\n kerSubset x = isInKer ϕ x , isPropIsInKer ϕ x\n\n isSubgroupKer : isSubgroup G kerSubset\n id-closed isSubgroupKer = ϕ.pres1\n op-closed isSubgroupKer {x} {y} hx hy =\n ϕ.pres· x y ∙∙ (λ i → hx i H.· hy i) ∙∙ H.·IdR _\n inv-closed isSubgroupKer hx = ϕ.presinv _ ∙∙ cong H.inv hx ∙∙ inv1g H\n\n kerSubgroup : Subgroup G\n kerSubgroup = kerSubset , isSubgroupKer\n\n isNormalKer : isNormal kerSubgroup\n isNormalKer x y hy =\n f (x G.· y G.· G.inv x) ≡⟨ ϕ.pres· _ _ ⟩\n f x H.· f (y G.· G.inv x) ≡⟨ cong (f x H.·_) (ϕ.pres· _ _) ⟩\n f x H.· f y H.· f (G.inv x) ≡⟨ (λ i → f x H.· hy i H.· f (G.inv x)) ⟩\n f x H.· (H.1g H.· f (G.inv x)) ≡⟨ cong (f x H.·_) (H.·IdL _) ⟩\n f x H.· f (G.inv x) ≡⟨ cong (f x H.·_) (ϕ.presinv x) ⟩\n f x H.· H.inv (f x) ≡⟨ H.·InvR _ ⟩\n H.1g ∎\n", "meta": {"hexsha": "3e060f289b790f8a05a6152c2a8e754bf53b48c3", "size": 6878, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Subgroup.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/Subgroup.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/Subgroup.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.7523809524, "max_line_length": 92, "alphanum_fraction": 0.5703692934, "num_tokens": 2799, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146848, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.5963082984256621}} {"text": "module bools where\r\n\r\nopen import lib\r\n\r\n----------------------------------------------------------------------\r\n-- these problems are about the nand operator, also known as the Scheffer stroke\r\n----------------------------------------------------------------------\r\nnand-not : ∀ (b : 𝔹) → ~ b ≡ b nand b\r\nnand-not tt = refl\r\nnand-not ff = refl\r\n\r\nnand-or : ∀ (b1 b2 : 𝔹) → b1 || b2 ≡ (b1 nand b1) nand (b2 nand b2)\r\nnand-or tt tt = refl\r\nnand-or tt ff = refl\r\nnand-or ff tt = refl\r\nnand-or ff ff = refl\r\n\r\nnand-and : ∀ (b1 b2 : 𝔹) → b1 && b2 ≡ (b1 nand b2) nand (b1 nand b2)\r\nnand-and tt tt = refl\r\nnand-and tt ff = refl\r\nnand-and ff tt = refl\r\nnand-and ff ff = refl\r\n\r\nnand-imp : ∀ (b1 b2 : 𝔹) → b1 imp b2 ≡ b1 nand (b2 nand b2)\r\nnand-imp tt tt = refl\r\nnand-imp tt ff = refl\r\nnand-imp ff tt = refl\r\nnand-imp ff ff = refl\r\n\r\nite-not : ∀(A : Set)(x : 𝔹)(y : A)(z : A) → if x then y else z ≡ if ~ x then z else y\r\nite-not A tt y z = refl\r\nite-not A ff y z = refl\r\n\r\n&&-distrib : ∀ x y z → x && (y || z) ≡ (x && y) || (x && z)\r\n&&-distrib tt tt tt = refl\r\n&&-distrib tt tt ff = refl\r\n&&-distrib tt ff tt = refl\r\n&&-distrib tt ff ff = refl\r\n&&-distrib ff tt tt = refl\r\n&&-distrib ff tt ff = refl\r\n&&-distrib ff ff tt = refl\r\n&&-distrib ff ff ff = refl\r\n\r\ncombK : ∀ x y → x imp (y imp x) ≡ tt\r\ncombK tt tt = refl\r\ncombK tt ff = refl\r\ncombK ff tt = refl\r\ncombK ff ff = refl \r\n\r\ncombS : ∀ x y z → (x imp (y imp z)) ≡ tt → (x imp y) ≡ tt → x ≡ tt → z ≡ tt\r\ncombS tt tt tt x₁ x₂ x₃ = refl\r\n", "meta": {"hexsha": "2ba45644141ea02aba82bac9bc9c453d8d1e49c8", "size": 1482, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "bools.agda", "max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout6", "max_stars_repo_head_hexsha": "51d54ed9c232f93baad238d328b77dd024344226", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bools.agda", "max_issues_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout6", "max_issues_repo_head_hexsha": "51d54ed9c232f93baad238d328b77dd024344226", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bools.agda", "max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout6", "max_forks_repo_head_hexsha": "51d54ed9c232f93baad238d328b77dd024344226", "max_forks_repo_licenses": ["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.5, "max_line_length": 86, "alphanum_fraction": 0.5148448043, "num_tokens": 553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478255, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.5963082892263895}} {"text": "------------------------------------------------------------------------------\n-- Properties of the Collatz function\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.Program.Collatz.PropertiesATP where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.PropertiesATP using ( ∸-N )\nopen import FOTC.Data.Nat.UnaryNumbers\nopen import FOTC.Data.Nat.UnaryNumbers.TotalityATP using ( 2-N )\nopen import FOTC.Program.Collatz.Collatz\nopen import FOTC.Program.Collatz.Data.Nat\nopen import FOTC.Program.Collatz.Data.Nat.PropertiesATP\n\n------------------------------------------------------------------------------\n\nhelper : ∀ {n} → N n → collatz (2' ^ succ₁ n) ≡ collatz (2' ^ n)\nhelper nzero = prf\n where postulate prf : collatz (2' ^ succ₁ zero) ≡ collatz (2' ^ zero)\n {-# ATP prove prf #-}\nhelper (nsucc {n} Nn) = prf\n where postulate prf : collatz (2' ^ succ₁ (succ₁ n)) ≡ collatz (2' ^ succ₁ n)\n {-# ATP prove prf +∸2 ^-N 2-N 2^x≢0 2^[x+1]≢1 div-2^[x+1]-2≡2^x\n x-Even→SSx-Even ∸-N ∸-Even 2^[x+1]-Even 2-Even\n #-}\n\ncollatz-2^x : ∀ {n} → N n → collatz (2' ^ n) ≡ 1'\ncollatz-2^x nzero = prf\n where postulate prf : collatz (2' ^ 0') ≡ 1'\n {-# ATP prove prf #-}\n\ncollatz-2^x (nsucc {n} Nn) = prf (collatz-2^x Nn)\n where postulate prf : collatz (2' ^ n) ≡ 1' → collatz (2' ^ succ₁ n) ≡ 1'\n {-# ATP prove prf helper #-}\n", "meta": {"hexsha": "e864b352e6809fb9934687c5a58c5f5f1f95f5ae", "size": 1608, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Program/Collatz/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/Program/Collatz/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/Program/Collatz/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": 39.2195121951, "max_line_length": 79, "alphanum_fraction": 0.5161691542, "num_tokens": 509, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146848, "lm_q2_score": 0.7401743505760728, "lm_q1q2_score": 0.5963082891907457}} {"text": "\nmodule Prelude.Int.Properties where\n\nopen import Prelude.Unit\nopen import Prelude.Nat\nopen import Prelude.Nat.Properties\nopen import Prelude.Number\nopen import Prelude.Equality\nopen import Prelude.Int.Core\nopen import Prelude.Smashed\nopen import Prelude.Ord\nopen import Prelude.Semiring\nopen import Prelude.Function\n\n--- Specification functions ---\n--- sucInt a = 1 + a\n--- predInt a = -1 + a\n--- sucsInt n a = pos n + a\n--- predsInt n a = neg n + a\n--- diffNat a b = a -NZ b\n\nsucInt : Int → Int\nsucInt (pos n) = pos (suc n)\nsucInt (negsuc zero) = pos zero\nsucInt (negsuc (suc n)) = negsuc n\n\npredInt : Int → Int\npredInt (pos zero) = negsuc zero\npredInt (pos (suc n)) = pos n\npredInt (negsuc n) = negsuc (suc n)\n\nsucsInt : Nat → Int → Int\nsucsInt zero b = b\nsucsInt (suc a) b = sucInt (sucsInt a b)\n\npredsInt : Nat → Int → Int\npredsInt zero b = b\npredsInt (suc a) b = predInt (predsInt a b)\n\ndiffNat : Nat → Nat → Int\ndiffNat a zero = pos a\ndiffNat zero (suc b) = negsuc b\ndiffNat (suc a) (suc b) = diffNat a b\n\n--- Injectivity proofs ---\n\npos-inj : ∀ {a b} → pos a ≡ pos b → a ≡ b\npos-inj refl = refl\n\nnegsuc-inj : ∀ {a b} → negsuc a ≡ negsuc b → a ≡ b\nnegsuc-inj refl = refl\n\nneg-inj : ∀ {a b} → neg a ≡ neg b → a ≡ b\nneg-inj {zero} {zero} eq = refl\nneg-inj {zero} {suc b} ()\nneg-inj {suc a} {zero} ()\nneg-inj {suc a} {suc b} eq = suc $≡ negsuc-inj eq\n\nnegate-inj : {a b : Int} → negate a ≡ negate b → a ≡ b\nnegate-inj {pos a} {pos b} eq = pos $≡ neg-inj eq\nnegate-inj {pos zero} {negsuc b} ()\nnegate-inj {pos (suc a)} {negsuc b} ()\nnegate-inj {negsuc a} {pos zero} ()\nnegate-inj {negsuc a} {pos (suc _)} ()\nnegate-inj {negsuc a} {negsuc b} eq = negsuc $≡ suc-inj (pos-inj eq)\n\nsucInt-inj : ∀ a b → sucInt a ≡ sucInt b → a ≡ b\nsucInt-inj (pos a) (pos a) refl = refl\nsucInt-inj (pos a) (negsuc zero) ()\nsucInt-inj (pos a) (negsuc (suc b)) ()\nsucInt-inj (negsuc zero) (pos b) ()\nsucInt-inj (negsuc (suc a)) (pos b) ()\nsucInt-inj (negsuc zero) (negsuc zero) eq = refl\nsucInt-inj (negsuc zero) (negsuc (suc b)) ()\nsucInt-inj (negsuc (suc a)) (negsuc zero) ()\nsucInt-inj (negsuc (suc a)) (negsuc (suc a)) refl = refl\n\npredInt-inj : ∀ a b → predInt a ≡ predInt b → a ≡ b\npredInt-inj (pos zero) (pos zero) eq = refl\npredInt-inj (pos zero) (pos (suc b)) ()\npredInt-inj (pos (suc a)) (pos zero) ()\npredInt-inj (pos (suc a)) (pos (suc a)) refl = refl\npredInt-inj (pos zero) (negsuc b) ()\npredInt-inj (pos (suc a)) (negsuc b) ()\npredInt-inj (negsuc a) (pos zero) ()\npredInt-inj (negsuc a) (pos (suc b)) ()\npredInt-inj (negsuc a) (negsuc a) refl = refl\n\n--- sucInt and predInt are inverses --\n\nsucInt-predInt : ∀ a → sucInt (predInt a) ≡ a\nsucInt-predInt (pos zero) = refl\nsucInt-predInt (pos (suc n)) = refl\nsucInt-predInt (negsuc n) = refl\n\npredInt-sucInt : ∀ a → predInt (sucInt a) ≡ a\npredInt-sucInt (pos n) = refl\npredInt-sucInt (negsuc zero) = refl\npredInt-sucInt (negsuc (suc n)) = refl\n\n--- Commutativity of _+_ is easy\n\naddInt-commute : (a b : Int) → a + b ≡ b + a\naddInt-commute (pos a) (pos b) = pos $≡ add-commute a b\naddInt-commute (pos a) (negsuc b) = refl\naddInt-commute (negsuc a) (pos b) = refl\naddInt-commute (negsuc a) (negsuc b) = negsuc ∘ suc $≡ add-commute a b\n\n--- Proving _-NZ_ == diffNat\n\n-NZ-suc : ∀ a b → suc a -NZ suc b ≡ a -NZ b\n-NZ-suc a b rewrite smashed {x = compare (suc a) (suc b)} {suc-comparison (compare a b)}\n with compare a b\n... | less (diff! k) = refl\n... | equal eq = refl\n... | greater (diff! k) = refl\n\n-NZ-spec : ∀ a b → a -NZ b ≡ diffNat a b\n-NZ-spec zero zero = refl\n-NZ-spec (suc a) zero = refl\n-NZ-spec zero (suc b) = refl\n-NZ-spec (suc a) (suc b) = -NZ-suc a b ⟨≡⟩ -NZ-spec a b\n\n--- diffNat distributes over suc in both arguments...\n\ndiffNat-suc-l : ∀ a b → diffNat (suc a) b ≡ sucInt (diffNat a b)\ndiffNat-suc-l a 0 = refl\ndiffNat-suc-l 0 1 = refl\ndiffNat-suc-l 0 (suc (suc b)) = refl\ndiffNat-suc-l (suc a) (suc b) = diffNat-suc-l a b\n\ndiffNat-suc-r : ∀ a b → diffNat a (suc b) ≡ predInt (diffNat a b)\ndiffNat-suc-r zero zero = refl\ndiffNat-suc-r zero (suc b) = refl\ndiffNat-suc-r (suc a) zero = refl\ndiffNat-suc-r (suc a) (suc b) = diffNat-suc-r a b\n\n--- ...and thus so does _-NZ_\n\n-NZ-suc-l : ∀ a b → suc a -NZ b ≡ sucInt (a -NZ b)\n-NZ-suc-l a b = -NZ-spec (suc a) b ⟨≡⟩ diffNat-suc-l a b ⟨≡⟩ʳ sucInt $≡ -NZ-spec a b\n\n-NZ-suc-r : ∀ a b → a -NZ suc b ≡ predInt (a -NZ b)\n-NZ-suc-r a b = -NZ-spec a (suc b) ⟨≡⟩ diffNat-suc-r a b ⟨≡⟩ʳ predInt $≡ -NZ-spec a b\n\n--- We need some lemmas about how sucInt and predInt relates to _+_.\n--- These are special cases of the computation rules below, so we make them private.\n\nprivate\n sucInt-spec : ∀ a → 1 + a ≡ sucInt a\n sucInt-spec (pos n) = refl\n sucInt-spec (negsuc zero) = refl\n sucInt-spec (negsuc (suc n)) = refl\n\n predInt-spec : ∀ a → -1 + a ≡ predInt a\n predInt-spec (pos zero) = refl\n predInt-spec (pos (suc n)) = -NZ-spec (suc n) 1\n predInt-spec (negsuc n) = refl\n\n addInt-suc : ∀ a b → pos (suc a) + b ≡ sucInt (pos a + b)\n addInt-suc a (pos b) = refl\n addInt-suc a (negsuc b) = -NZ-suc-l a (suc b)\n\n addInt-negsuc : ∀ a b → negsuc (suc a) + b ≡ predInt (negsuc a + b)\n addInt-negsuc a (pos b) = -NZ-suc-r b (suc a)\n addInt-negsuc a (negsuc b) = refl\n\n--- Now we can prove some \"computation\" rules for _+_\n\naddInt-zero-l : (a : Int) → 0 + a ≡ a\naddInt-zero-l (pos a) = refl\naddInt-zero-l (negsuc a) = -NZ-spec 0 (suc a)\n\naddInt-zero-r : (a : Int) → a + 0 ≡ a\naddInt-zero-r (pos a) = pos $≡ add-zero-r a\naddInt-zero-r (negsuc a) = -NZ-spec 0 (suc a)\n\naddInt-sucInt-l : ∀ a b → sucInt a + b ≡ sucInt (a + b)\naddInt-sucInt-l (pos a) b = addInt-suc a b\naddInt-sucInt-l (negsuc zero) b = addInt-zero-l b ⟨≡⟩ʳ sucInt $≡ predInt-spec b ⟨≡⟩ sucInt-predInt b\naddInt-sucInt-l (negsuc (suc a)) b = sucInt-predInt (negsuc a + b) ʳ⟨≡⟩ʳ sucInt $≡ addInt-negsuc a b\n\naddInt-predInt-l : ∀ a b → predInt a + b ≡ predInt (a + b)\naddInt-predInt-l (pos zero) b = predInt-spec b ⟨≡⟩ʳ predInt $≡ addInt-zero-l b\naddInt-predInt-l (pos (suc a)) b = predInt-sucInt (pos a + b) ʳ⟨≡⟩ʳ predInt $≡ addInt-suc a b\naddInt-predInt-l (negsuc a) b = addInt-negsuc a b\n\n--- Adding a non-negative number is equivalent to sucsInt and adding a negative number\n--- to predsInt.\n\naddInt-pos : ∀ a b → pos a + b ≡ sucsInt a b\naddInt-pos zero b = addInt-zero-l b\naddInt-pos (suc a) b = addInt-suc a b ⟨≡⟩ sucInt $≡ addInt-pos a b\n\naddInt-neg : ∀ a b → neg a + b ≡ predsInt a b\naddInt-neg zero b = addInt-zero-l b\naddInt-neg (suc zero) b = addInt-predInt-l 0 b ⟨≡⟩ predInt $≡ addInt-zero-l b -- predInt-spec b\naddInt-neg (suc (suc a)) b = addInt-predInt-l (negsuc a) b ⟨≡⟩ predInt $≡ addInt-neg (suc a) b\n\n--- sucsInt and predsInt have the appropriate associativity properties\n\nprivate\n sucsInt-assoc : ∀ a b c → sucsInt a (b + c) ≡ sucsInt a b + c\n sucsInt-assoc zero b c = refl\n sucsInt-assoc (suc a) b c = sucInt $≡ sucsInt-assoc a b c ⟨≡⟩ʳ\n addInt-sucInt-l (sucsInt a b) c\n\n predsInt-assoc : ∀ a b c → predsInt a (b + c) ≡ predsInt a b + c\n predsInt-assoc zero b c = refl\n predsInt-assoc (suc a) b c = predInt $≡ predsInt-assoc a b c ⟨≡⟩ʳ\n addInt-predInt-l (predsInt a b) c\n\n--- Finally we can prove associativity of _+_\n\naddInt-assoc : (a b c : Int) → a + (b + c) ≡ (a + b) + c\naddInt-assoc (pos a) b c = addInt-pos a (b + c) ⟨≡⟩ sucsInt-assoc a b c ⟨≡⟩ʳ _+ c $≡ addInt-pos a b\naddInt-assoc (negsuc a) b c = addInt-neg (suc a) (b + c) ⟨≡⟩ predsInt-assoc (suc a) b c ⟨≡⟩ʳ _+ c $≡ addInt-neg (suc a) b\n\n--- Injectivity of _+_\n\nprivate\n sucsInt-inj : ∀ a b c → sucsInt a b ≡ sucsInt a c → b ≡ c\n sucsInt-inj zero b c eq = eq\n sucsInt-inj (suc a) b c eq = sucsInt-inj a b c (sucInt-inj _ _ eq)\n\n predsInt-inj : ∀ a b c → predsInt a b ≡ predsInt a c → b ≡ c\n predsInt-inj zero b c eq = eq\n predsInt-inj (suc a) b c eq = predsInt-inj a b c (predInt-inj _ _ eq)\n\naddInt-inj₂ : (a b c : Int) → a + b ≡ a + c → b ≡ c\naddInt-inj₂ (pos a) b c eq = sucsInt-inj a b c (addInt-pos a b ʳ⟨≡⟩ eq ⟨≡⟩ addInt-pos a c)\naddInt-inj₂ (negsuc a) b c eq = predsInt-inj a b c (predInt-inj _ _ (addInt-neg (suc a) b ʳ⟨≡⟩ eq ⟨≡⟩ addInt-neg (suc a) c))\n\naddInt-inj₁ : (a b c : Int) → a + c ≡ b + c → a ≡ b\naddInt-inj₁ a b c eq = addInt-inj₂ c a b (addInt-commute c a ⟨≡⟩ eq ⟨≡⟩ addInt-commute b c)\n\n--- Properties of negate ---\n\nnegate-idempotent : (a : Int) → negate (negate a) ≡ a\nnegate-idempotent (pos zero) = refl\nnegate-idempotent (pos (suc n)) = refl\nnegate-idempotent (negsuc n) = refl\n\nprivate\n neg-add : ∀ a b → neg (a + b) ≡ neg a + neg b\n neg-add zero b = sym (addInt-zero-l (neg b))\n neg-add (suc a) zero = negsuc $≡ add-zero-r a ⟨≡⟩ʳ -NZ-spec 0 (suc a)\n neg-add (suc a) (suc b) = negsuc $≡ add-suc-r a b\n\n negate-diffNat : ∀ a b → negate (diffNat a b) ≡ diffNat b a\n negate-diffNat zero zero = refl\n negate-diffNat zero (suc b) = refl\n negate-diffNat (suc a) zero = refl\n negate-diffNat (suc a) (suc b) = negate-diffNat a b\n\nnegate-NZ : ∀ a b → negate (a -NZ b) ≡ b -NZ a\nnegate-NZ a b = negate $≡ -NZ-spec a b ⟨≡⟩ negate-diffNat a b ⟨≡⟩ʳ -NZ-spec b a\n\nnegate-addInt : (a b : Int) → negate (a + b) ≡ negate a + negate b\nnegate-addInt (pos a) (pos b) = neg-add a b\nnegate-addInt (pos zero) (negsuc b) = refl\nnegate-addInt (pos (suc a)) (negsuc b) = negate-NZ (suc a) (suc b)\nnegate-addInt (negsuc a) (pos zero) = pos ∘ suc $≡ sym (add-zero-r a)\nnegate-addInt (negsuc a) (pos (suc b)) = negate-NZ (suc b) (suc a)\nnegate-addInt (negsuc a) (negsuc b) = pos $≡ sym (add-suc-r (suc a) b)\n\nnegate-subInt : (a b : Int) → negate (a - b) ≡ b - a\nnegate-subInt a b = negate-addInt a (negate b) ⟨≡⟩\n negate a +_ $≡ negate-idempotent b ⟨≡⟩\n addInt-commute (negate a) b\n\n--- Properties of subtraction ---\n\nprivate\n diffNat-equal : ∀ a → diffNat a a ≡ 0\n diffNat-equal zero = refl\n diffNat-equal (suc a) = diffNat-equal a\n\nsubInt-equal : (a b : Int) → a ≡ b → a - b ≡ 0\nsubInt-equal (pos zero) _ refl = refl\nsubInt-equal (pos (suc n)) _ refl = -NZ-spec (suc n) (suc n) ⟨≡⟩ diffNat-equal n\nsubInt-equal (negsuc n) _ refl = -NZ-spec (suc n) (suc n) ⟨≡⟩ diffNat-equal n\n", "meta": {"hexsha": "89fbc56288c875c695f33ab7190529d1cd23f06e", "size": 10531, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Int/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/Prelude/Int/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/Prelude/Int/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": 37.2120141343, "max_line_length": 124, "alphanum_fraction": 0.5908270819, "num_tokens": 4305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246035907933, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.5961804126293826}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Helper where\n\nopen import Level\nopen import Relation.Binary using (Rel; IsEquivalence)\n\nopen import Categories.Category.Core using (Category)\n\n-- Since we add extra proofs in the definition of `Category` (i.e. `sym-assoc` and\n-- `identity²`), we might still want to construct a `Category` in its originally\n-- easier manner. Thus, this redundant definition is here to ease the construction.\nrecord CategoryHelper (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where\n infix 4 _≈_ _⇒_\n infixr 9 _∘_\n\n field\n Obj : Set o\n _⇒_ : Rel Obj ℓ\n _≈_ : ∀ {A B} → Rel (A ⇒ B) e\n\n id : ∀ {A} → (A ⇒ A)\n _∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)\n\n field\n assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≈ h ∘ (g ∘ f)\n identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f\n identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f\n equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})\n ∘-resp-≈ : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i\n\ncategoryHelper : ∀ {o ℓ e} → CategoryHelper o ℓ e → Category o ℓ e\ncategoryHelper C = record\n { Obj = Obj\n ; _⇒_ = _⇒_\n ; _≈_ = _≈_\n ; id = id\n ; _∘_ = _∘_\n ; assoc = assoc\n ; sym-assoc = sym assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n ; identity² = identityˡ\n ; equiv = equiv\n ; ∘-resp-≈ = ∘-resp-≈\n }\n where open CategoryHelper C\n module _ {A B} where\n open IsEquivalence (equiv {A} {B}) public\n", "meta": {"hexsha": "4cef9e39f6ce2c5af0f90b394ee96b3a14c3478d", "size": 1531, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Helper.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/Helper.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/Helper.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": 31.2448979592, "max_line_length": 91, "alphanum_fraction": 0.5342913129, "num_tokens": 606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245911726382, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.5961804037451367}} {"text": "------------------------------------------------------------------------\n-- INCREMENTAL λ-CALCULUS\n--\n-- Variables and contexts\n--\n-- This module defines the syntax of contexts and subcontexts,\n-- together with variables and properties of these notions.\n--\n-- This module is parametric in the syntax of types, so it\n-- can be reused for different calculi.\n------------------------------------------------------------------------\n\nmodule Base.Syntax.Context\n (Type : Set)\n where\n\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\n-- Typing Contexts\n-- ===============\n\nimport Data.List as List\nopen import Base.Data.ContextList public\n\nContext : Set\nContext = List.List Type\n\n-- Variables\n-- =========\n--\n-- Here it is clear that we are using de Bruijn indices,\n-- encoded as natural numbers, more or less.\ndata Var : Context → Type → Set where\n this : ∀ {Γ τ} → Var (τ • Γ) τ\n that : ∀ {Γ σ τ} → (x : Var Γ τ) → Var (σ • Γ) τ\n\n-- Weakening\n-- =========\n--\n-- We define weakening based on subcontext relationship.\n\n-- Subcontexts\n-- -----------\n--\n-- Useful as a reified weakening operation,\n-- and for making theorems strong enough to prove by induction.\n--\n-- The contents of this module are currently exported at the end\n-- of this file.\n\n-- This handling of contexts is recommended by [this\n-- email](https://lists.chalmers.se/pipermail/agda/2011/003423.html) and\n-- attributed to Conor McBride.\n--\n-- The associated thread discusses a few alternatives solutions, including one\n-- where beta-reduction can handle associativity of ++.\n\nmodule Subcontexts where\n infix 4 _≼_\n\n data _≼_ : (Γ₁ Γ₂ : Context) → Set where\n ∅ : ∅ ≼ ∅\n keep_•_ : ∀ {Γ₁ Γ₂} →\n (τ : Type) →\n Γ₁ ≼ Γ₂ →\n τ • Γ₁ ≼ τ • Γ₂\n drop_•_ : ∀ {Γ₁ Γ₂} →\n (τ : Type) →\n Γ₁ ≼ Γ₂ →\n Γ₁ ≼ τ • Γ₂\n\n -- Properties\n\n ∅≼Γ : ∀ {Γ} → ∅ ≼ Γ\n ∅≼Γ {∅} = ∅\n ∅≼Γ {τ • Γ} = drop τ • ∅≼Γ\n\n ≼-refl : Reflexive _≼_\n ≼-refl {∅} = ∅\n ≼-refl {τ • Γ} = keep τ • ≼-refl\n\n ≼-reflexive : ∀ {Γ₁ Γ₂} → Γ₁ ≡ Γ₂ → Γ₁ ≼ Γ₂\n ≼-reflexive refl = ≼-refl\n\n ≼-trans : Transitive _≼_\n ≼-trans ≼₁ ∅ = ≼₁\n ≼-trans (keep .τ • ≼₁) (keep τ • ≼₂) = keep τ • ≼-trans ≼₁ ≼₂\n ≼-trans (drop .τ • ≼₁) (keep τ • ≼₂) = drop τ • ≼-trans ≼₁ ≼₂\n ≼-trans ≼₁ (drop τ • ≼₂) = drop τ • ≼-trans ≼₁ ≼₂\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 { Carrier = Context\n ; _≈_ = _≡_\n ; _∼_ = _≼_\n ; isPreorder = ≼-isPreorder\n }\n\n module ≼-Reasoning where\n open import Relation.Binary.PreorderReasoning ≼-preorder public\n renaming\n ( _≈⟨_⟩_ to _≡⟨_⟩_\n ; _∼⟨_⟩_ to _≼⟨_⟩_\n ; _≈⟨⟩_ to _≡⟨⟩_\n )\n\n -- Lift a variable to a super context\n\n weaken-var : ∀ {Γ₁ Γ₂ τ} → Γ₁ ≼ Γ₂ → Var Γ₁ τ → Var Γ₂ τ\n weaken-var (keep τ • ≼₁) this = this\n weaken-var (keep τ • ≼₁) (that x) = that (weaken-var ≼₁ x)\n weaken-var (drop τ • ≼₁) x = that (weaken-var ≼₁ x)\n\n-- Currently, we export the subcontext relation.\n\nopen Subcontexts public\n", "meta": {"hexsha": "1d2ae4d857f10898eec54863e616755066cf35c7", "size": 3128, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Base/Syntax/Context.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/Syntax/Context.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/Syntax/Context.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": 25.024, "max_line_length": 78, "alphanum_fraction": 0.5684143223, "num_tokens": 1106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.5960173059660279}} {"text": "-- Andreas, 2015-06-24\n\nopen import Common.Equality\nopen import Common.Product\n\nSing : {A : Set} (a : A) → Set\nSing a = ∃ λ b → a ≡ b\n\nworks : {A : Set} (f : ∀{a : A} → Sing a) (a : A) → Sing a\nworks f a = let b , p = f {_} in b , p\n\ntest : {A : Set} (f : ∀{a : A} → Sing a) (a : A) → Sing a\ntest f a = let b , p = f in b , p\n\n-- ERROR WAS:\n-- Type mismatch\n-- when checking that the pattern b , p has type\n-- {a = a₁ : .A} → Sing a₁\n\n-- should work now\n", "meta": {"hexsha": "0e53000a716987c45387117c5f4d1b8e68f90007", "size": 454, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1584.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/Issue1584.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/Issue1584.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.619047619, "max_line_length": 58, "alphanum_fraction": 0.5352422907, "num_tokens": 180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.5959827096955221}} {"text": "{-# OPTIONS --without-K #-}\nmodule Wow-It-is-FV where\n\nopen import Agda.Builtin.Nat\nopen import Agda.Builtin.Equality\nopen import Agda.Primitive\n\nlevelEq : lzero ≡ lzero\nlevelEq = refl\n\nlevelEq′ : lsuc lzero ≡ lsuc lzero\nlevelEq′ = refl\n\ntrans : {l : Level} {Q : Set l} {a b c : Q}\n → a ≡ b → b ≡ c → a ≡ c\ntrans refl refl = refl\n\nJ : {A : Set} (P : (x y : A) → x ≡ y → Set)\n → ((x : A) → P x x refl)\n → (x y : A) (xy : x ≡ y) → P x y xy\nJ P p x .x refl = p x\n\ncong : {A B : Set} (f : A → B)\n → {m n : A} → m ≡ n → f m ≡ f n\ncong f refl = refl\n\nsym : {A : Set} {m n : A} → m ≡ n → n ≡ m\nsym refl = refl\n\ntheorem : suc zero + suc zero ≡ _\ntheorem = refl\n\ntheorem′ : 1 + 1 ≡ 2\ntheorem′ = refl\n\ntrivialEq : {a : _} {A : Set a} → A ≡ A\ntrivialEq = refl\n\ntrivialEq′ : ∀ {a} {A : Set a} → A ≡ A\ntrivialEq′ = refl\n\ntrivialEq′′ : ∀ a b → a + b ≡ a + b\ntrivialEq′′ a b = refl\n\ntrans′ : ∀ {a} {A : Set a} (a b c : A)\n → a ≡ b → b ≡ c → a ≡ c\ntrans′ a .a c refl bc = bc\n\ndata _<=_ : (a b : Nat) → Set where\n 0ltn : ∀ {n} → 0 <= n\n nltm : ∀ {n m} → n <= m → suc n <= suc m\n\n7lt13 : 7 <= 13\n7lt13 = nltm (nltm (nltm (nltm (nltm (nltm (nltm 0ltn))))))\n\nabc : ∀ {a b c} → a <= b → b <= c → a <= c\nabc 0ltn bc = 0ltn\nabc (nltm ab) (nltm bc) = nltm (abc ab bc)\n\ndata ⊥ : Set where\n\nridiculous : ⊥ → ⊥\nridiculous a = a\n\nridiculous′ : 1 ≡ 0 → ⊥\nridiculous′ ()\n\n⊥-elim : ∀ {a} {A : Set a} → ⊥ → A\n⊥-elim ()\n\n4lt3 : 4 <= 3 → ⊥\n4lt3 (nltm (nltm (nltm ())))\n\ninfix 3 ¬_\n¬_ : ∀ {a} → Set a → Set a\n¬ P = P → ⊥\n\n_!=_ : ∀ {a} {A : Set a} → A → A → Set a\nx != y = ¬ x ≡ y\n\n_≡⟨_⟩_ : ∀ {A : Set} (x : A) {y z : A} → x ≡ y → y ≡ z → x ≡ z\n_ ≡⟨ refl ⟩ c = c\n\n_QED : ∀ {A : Set} (x : A) → x ≡ x\n_ QED = refl\n\nlemma₀ : ∀ n → n + 0 ≡ n\nlemma₀ zero = refl\nlemma₀ (suc n) = cong suc (lemma₀ n)\n\nlemma₁ : ∀ n m → suc (n + m) ≡ n + suc m\nlemma₁ zero _ = refl\nlemma₁ (suc n) m = cong suc (lemma₁ n m)\n\ncomm : ∀ n m → n + m ≡ m + n\ncomm zero n = sym (lemma₀ n)\ncomm (suc n) m = suc n + m\n ≡⟨ refl ⟩ suc (n + m)\n ≡⟨ cong suc (comm n m) ⟩ suc (m + n)\n ≡⟨ lemma₁ m n ⟩ m + suc n QED\n\ninfixr 2 _≡⟨_⟩_\ninfix 3 _QED\n", "meta": {"hexsha": "d1b49b7dde0c2e2908c1430c819d52bc0fca3e27", "size": 2094, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Obsolete/Wow-FV-zh/Wow-It-is-FV.agda", "max_stars_repo_name": "ice1000/Books", "max_stars_repo_head_hexsha": "a875d10f9a25d28e8e4f77e6ca32625a1e389227", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 133, "max_stars_repo_stars_event_min_datetime": "2018-10-08T16:02:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-05T10:37:03.000Z", "max_issues_repo_path": "Wow-FV-zh/Wow-It-is-FV.agda", "max_issues_repo_name": "ice1000/Books", "max_issues_repo_head_hexsha": "a875d10f9a25d28e8e4f77e6ca32625a1e389227", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-10-09T22:48:45.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-16T19:29:15.000Z", "max_forks_repo_path": "Wow-FV-zh/Wow-It-is-FV.agda", "max_forks_repo_name": "ice1000/Books", "max_forks_repo_head_hexsha": "a875d10f9a25d28e8e4f77e6ca32625a1e389227", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-10-09T03:41:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-24T16:49:13.000Z", "avg_line_length": 20.1346153846, "max_line_length": 62, "alphanum_fraction": 0.4923591213, "num_tokens": 1013, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324848629214, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.5959826968600458}} {"text": "module Data.Finitude.Exponent where\nopen import Data.Finitude\nopen import Data.Fin as Fin using (Fin; toℕ)\nopen import Data.Nat\nopen import Data.Vec as Vec\nopen import Relation.Binary.PropositionalEquality as P\nopen import Data.Nat.DivMod\nopen import Relation.Nullary.Decidable\nopen import Function\nopen import Function.Equality as F using (_⟶_; _⟨$⟩_; _⇨_) \nopen import Function.Inverse as Inv using (module Inverse; Inverse)\nopen import Data.Product\nopen import Data.Sum\nopen import Data.Empty\nopen import Relation.Binary\n\nexponent : ∀ {m} {n} → Finitude (P.setoid (Vec (Fin m) n)) (m ^ n)\nexponent {m} {n} = 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 {m}{n}\n }\n }\n where\n open import Data.Nat.Properties \n open import Data.Fin.Properties hiding (≤-refl; _≟_; <-cmp)\n open import Relation.Nullary.Negation \n shift : ∀ {m n} (i : Fin m)(j : Fin n) → toℕ j + (toℕ i) * n < m * n\n shift {m}{n} i j =\n begin suc (toℕ j) + toℕ i * n \n ≤⟨ +-mono-≤ (toℕ (λ sm≤q → <⇒≱ (toℕ : ∀ {m n} → m ≢ n → m < n ⊎ n < m\n ≢→<⊎> {m}{n} m≢n with <-cmp m n\n ≢→<⊎> {m} {n} m≢n | tri< m {m} {n} m≢n | tri≈ _ m≡n _ = ⊥-elim (m≢n m≡n)\n ≢→<⊎> {m} {n} m≢n | tri> _ _ n k₀≢k₁\n ... | inj₁ k₀ (λ sm≤q → <⇒≱ (toℕ Bool -> Bool\r\ntt || y = tt\r\nff || y = y\r\n\r\n_&&_ : Bool -> Bool -> Bool\r\ntt && y = y\r\nff && y = ff\r\n\r\nif_then_else : {A : Set} -> Bool -> A -> A -> A\r\nif tt then x else _ = x\r\nif ff then _ else y = y\r\n\r\n-- Eq \"type class\"\r\nrecord Eq (A : Set) : Set where\r\n field\r\n _==_ : A -> A -> Bool\r\n\r\nopen Eq {{...}} public\r\n\r\n-- Function composition\r\n_∘_ : ∀ {x y z : Set} -> (y -> z) -> (x -> y) -> (x -> z)\r\n(f ∘ g) x = f (g x)\r\n\r\n-- Product type\r\ndata _×_ (A B : Set) : Set where\r\n _,_ : A -> B -> A × B\r\n\r\nuncurry : ∀ {x y z : Set} -> (x -> y -> z) -> (x × y) -> z\r\nuncurry f (a , b) = f a b\r\n\r\n-- Lists\r\ndata List (A : Set) : Set where\r\n [] : List A\r\n _::_ : A -> List A -> List A\r\n\r\ninfixr 20 _::_\r\ninfixr 15 _++_\r\n\r\n[_] : ∀ {A} -> A -> List A\r\n[ x ] = x :: []\r\n\r\n_++_ : ∀ {A} -> List A -> List A -> List A\r\n[] ++ l = l\r\n(x :: xs) ++ l = x :: (xs ++ l)\r\n\r\nfoldr : ∀ {A B : Set} -> (A -> B -> B) -> B -> List A -> B\r\nfoldr f b [] = b\r\nfoldr f b (x :: xs) = f x (foldr f b xs)\r\n\r\nmap : ∀ {A B} -> (A -> B) -> List A -> List B\r\nmap f [] = []\r\nmap f (x :: xs) = f x :: map f xs\r\n\r\nzip : ∀ {A B} -> List A -> List B -> List (A × B)\r\nzip [] _ = []\r\nzip _ [] = []\r\nzip (x :: xs) (y :: ys) = (x , y) :: zip xs ys\r\n\r\n-- Bottom type\r\n-- data ⊥ : Set where\r\n\r\n-- ¬ : Set -> Set\r\n-- ¬ A = A -> ⊥\r\n\r\n-- Decidable propositions and relations:\r\n-- Rel : Set -> Set₁\r\n-- Rel a = a -> a -> Set\r\n\r\n-- data Dec (P : Set) : Set where\r\n-- yes : (p : P) → Dec P\r\n-- no : (¬p : ¬ P) → Dec P\r\n\r\n-- Decidable : {a : Set} → Rel a → Set\r\n-- Decidable _∼_ = forall x y → Dec (x ∼ y)\r\n\r\n-- Natural numbers\r\ndata ℕ : Set where\r\n zero : ℕ\r\n suc : ℕ -> ℕ\r\n", "meta": {"hexsha": "ef138dc7eeea1454c37561c0f090113be03ac680", "size": 1772, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude.agda", "max_stars_repo_name": "tuura/selective-theory-agda", "max_stars_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2018-07-11T14:42:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-22T12:31:48.000Z", "max_issues_repo_path": "src/Prelude.agda", "max_issues_repo_name": "tuura/selective-theory-agda", "max_issues_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63", "max_issues_repo_licenses": ["MIT"], "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.agda", "max_forks_repo_name": "tuura/selective-theory-agda", "max_forks_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63", "max_forks_repo_licenses": ["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.367816092, "max_line_length": 59, "alphanum_fraction": 0.4221218962, "num_tokens": 667, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.7718434925908525, "lm_q1q2_score": 0.5957423811056515}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Results concerning function extensionality for propositional equality\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Axiom.Extensionality.Propositional where\n\nopen import Function\nopen import Level using (Level; _⊔_; suc; lift)\nopen import Relation.Binary.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 : A → Set b} {f g : (x : A) → B x} →\n (∀ x → f x ≡ g x) → f ≡ g\n\n------------------------------------------------------------------------\n-- Properties\n\n-- If extensionality holds for a given universe level, then it also\n-- holds for lower ones.\n\nlower-extensionality : ∀ {a₁ b₁} a₂ b₂ →\n Extensionality (a₁ ⊔ a₂) (b₁ ⊔ b₂) →\n Extensionality a₁ b₁\nlower-extensionality a₂ b₂ ext f≡g = cong (λ h → Level.lower ∘ h ∘ lift) $\n ext (cong (lift {ℓ = b₂}) ∘ f≡g ∘ Level.lower {ℓ = a₂})\n\n-- Functional extensionality implies a form of extensionality for\n-- Π-types.\n\n∀-extensionality : ∀ {a b} → Extensionality a (suc b) →\n {A : Set a} (B₁ B₂ : A → Set b) →\n (∀ x → B₁ x ≡ B₂ x) →\n (∀ 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": "196b6a1ae1e2f5626639ee16cfc3457b087d7ad9", "size": 1712, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Axiom/Extensionality/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/Axiom/Extensionality/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/Axiom/Extensionality/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": 36.4255319149, "max_line_length": 74, "alphanum_fraction": 0.5210280374, "num_tokens": 447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677506936878, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.5957228272828609}} {"text": "open import SingleSorted.AlgebraicTheory\nopen import Agda.Primitive using (lzero; lsuc; _⊔_)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\nopen import SingleSorted.Substitution\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_)\n\nmodule SingleSorted.Group where\n\ndata GroupOp : Set where\n e : GroupOp\n inv : GroupOp\n mul : GroupOp\n\n_ : Context\n_ = ctx-empty\n\n_ : Context\n_ = ctx-concat ctx-slot ctx-empty\n\n_ : var ctx-slot\n_ = var-var\n\n_ : var (ctx-concat ctx-slot ctx-slot)\n_ = var-inl var-var\n\n_ : var (ctx-concat ctx-slot ctx-slot)\n_ = var-inr var-var\n\nctx-1 : Context\nctx-1 = ctx-slot\n\nctx-2 : Context\nctx-2 = ctx-concat ctx-1 ctx-1\n\nctx : ∀ (n : ℕ) → Context\nctx zero = ctx-empty\nctx (suc n) = ctx-concat (ctx n) ctx-slot\n\n-- the signature of the theory of groups\n-- has one constant, one unary operation, one binary operation\nΣ : Signature\nΣ = record { oper = GroupOp ; oper-arity = λ{ e → ctx-empty ; inv → ctx 1 ; mul → ctx 2} }\n\nopen Signature Σ\n\n-- some example terms\n_ : Term ctx-1\n_ = tm-var var-var\n\n_ : Term ctx-2\n_ = tm-var (var-inr var-var)\n\n_ : Term ctx-2\n_ = tm-var (var-inr var-var)\n\n\n-- helper functions for creating terms\ne' : ∀ {Γ : Context} → Term Γ\ne' {Γ} = tm-oper e λ()\n\n-- inv' : ∀ {Γ : Context} → Term Γ → Term Γ\n-- inv' x = tm-oper inv λ{ _ → x}\n\n-- mul' : ∀ {Γ : Context} → Term Γ → Term Γ → Term Γ\n-- mul' x y = tm-oper mul λ{ (var-inl _) → x ; (var-inr _) → y}\n\nconcat-empty : var (ctx-concat ctx-empty ctx-slot) → (var ctx-slot)\nconcat-empty (var-inr x) = x\n\n\nx*y : Term ctx-2\nx*y = tm-oper mul λ{ (var-inl x) → tm-var (var-inl (concat-empty x)) ; (var-inr y) → tm-var (var-inr y)}\n\n-- concat-empty-idʳ : ctx-concat ctx-empty ctx-slot ≡ ctx-slot\n-- concat-empty-idʳ = {!!}\n\nsingleton-context : (var ctx-slot) → var (ctx-concat ctx-empty ctx-slot)\nsingleton-context (var-var) = var-inr var-var\n\nσ : ∀ {Γ : Context} {t : Term Γ} → Γ ⇒s (ctx 1)\nσ {Γ} {t} = λ{ (var-inr var-var) → t}\n\nδ : ∀ {Γ : Context} {t : Term Γ} {s : Term Γ} → Γ ⇒s (ctx 2)\nδ {Γ} {t} {s} = λ{ (var-inl x) → t ; (var-inr y) → s}\n\n_∗_ : ∀ {Γ} → Term Γ → Term Γ → Term Γ\nt ∗ s = tm-oper mul λ{ xs → δ {t = t} {s = s} xs}\n\n_ⁱ : ∀ {Γ : Context} → Term Γ → Term Γ\nt ⁱ = tm-oper inv λ{ x → σ {t = t} x}\n\n-- _∗_ : ∀ {Γ} → Term Γ → Term Γ → Term Γ\n-- t ∗ s = tm-oper mul λ{ (var-inl x) → t ; (var-inr args) → s}\n\n-- _ⁱ : ∀ {Γ : Context} → Term Γ → Term Γ\n-- t ⁱ = tm-oper inv λ{ x → t }\n\ninfixl 5 _∗_\ninfix 6 _ⁱ\n\n_ : Term (ctx 2)\n_ = tm-var (var-inl (var-inr var-var)) ∗ tm-var (var-inr var-var)\n\n_ : Term (ctx 1)\n_ = e' ∗ a\n where\n a : Term (ctx 1)\n a = tm-var (var-inr var-var)\n\n-- group equations\ndata GroupEq : Set where\n mul-assoc e-left e-right inv-left inv-right : GroupEq\n\nmul-assoc-ax : Equation\ne-left-ax : Equation\ne-right-ax : Equation\ninv-left-ax : Equation\ninv-right-ax : Equation\n\nmul-assoc-ax = record { eq-ctx = ctx 3\n ; eq-lhs = x ∗ y ∗ z\n ; eq-rhs = x ∗ (y ∗ z)\n }\n where\n x : Term (ctx 3)\n y : Term (ctx 3)\n z : Term (ctx 3)\n x = tm-var (var-inl (var-inl (var-inr var-var)))\n y = tm-var (var-inl (var-inr var-var))\n z = tm-var (var-inr var-var)\n\ne-left-ax = record { eq-ctx = ctx 1 ; eq-lhs = e' ∗ x ; eq-rhs = x }\n where\n x : Term (ctx 1)\n x = tm-var (var-inr var-var)\n\ne-right-ax = record { eq-ctx = ctx 1 ; eq-lhs = x ∗ e' ; eq-rhs = x }\n where\n x : Term (ctx 1)\n x = tm-var (var-inr var-var)\n\n\ninv-left-ax = record { eq-ctx = ctx 1 ; eq-lhs = x ⁱ ∗ x ; eq-rhs = e' }\n where\n x : Term (ctx 1)\n x = tm-var (var-inr var-var)\n\ninv-right-ax = record { eq-ctx = ctx 1 ; eq-lhs = x ∗ x ⁱ ; eq-rhs = e' }\n where\n x : Term (ctx 1)\n x = tm-var (var-inr var-var)\n\n\n𝒢 : Theory lzero Σ\n𝒢 = record { ax = GroupEq\n ; ax-eq = λ{ mul-assoc → mul-assoc-ax\n ; e-left → e-left-ax\n ; e-right → e-right-ax\n ; inv-left → inv-left-ax\n ; inv-right → inv-right-ax\n }\n }\n", "meta": {"hexsha": "25421e0ec2f663a8552d028896a13011398825fc", "size": 4089, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/SingleSorted/Group.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/SingleSorted/Group.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/SingleSorted/Group.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": 25.0858895706, "max_line_length": 104, "alphanum_fraction": 0.5519686965, "num_tokens": 1482, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672227971211, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.5956733492375887}} {"text": "module Syntax where\n\nopen import Data.List using (List; []; _∷_; _++_; lookup; length)\nopen import Data.Product using (Σ; Σ-syntax; proj₁; proj₂)\nopen import Data.Unit renaming (⊤ to top)\nopen import Data.Empty renaming (⊥ to bot)\n\nopen import Level using (suc; _⊔_)\n\nmodule PType {ℓ} (Gr : Set ℓ) where\n infixr 10 _*_\n infixr 9 _=>_\n\n data Type : Set ℓ where\n ⌊_⌋ : Gr -> Type\n Unit : Type\n _*_ : Type -> Type -> Type\n _=>_ : Type -> Type -> Type\n\n record Sorting : Set ℓ where\n field\n dom : Type\n cod : Type\n\n Context : Set ℓ\n Context = List Type\n\nrecord Signature ℓ₁ ℓ₂ : Set (suc (ℓ₁ ⊔ ℓ₂)) where\n field\n Gr : Set ℓ₁\n Func : Set ℓ₂\n\n open PType Gr public\n\n field\n sorting : Func -> Sorting\n\n dom : Func -> Type\n dom f = Sorting.dom (sorting f)\n\n cod : Func -> Type\n cod f = Sorting.cod (sorting f)\n\nmodule Term {ℓ₁ ℓ₂} (Sg : Signature ℓ₁ ℓ₂) where\n open Signature Sg\n\n infix 3 _⊨_\n infix 8 _∙_\n\n infix 3 _⊢_\n infixl 4 _[_]\n\n data _⊨_ : Context -> Context -> Set (ℓ₁ ⊔ ℓ₂)\n data _⊢_ : Context -> Type -> Set (ℓ₁ ⊔ ℓ₂)\n\n data _⊨_ where\n id : forall {Γ} -> Γ ⊨ Γ -- identity morphism\n _∙_ : forall {Γ Γ′ Γ′′} -> Γ′ ⊨ Γ′′ -> Γ ⊨ Γ′ -> Γ ⊨ Γ′′ -- composition of morphisms\n weaken : forall {Γ A} -> A ∷ Γ ⊨ Γ -- the first projection\n ext : forall {Γ Γ′ A} -> Γ ⊨ Γ′ -> Γ ⊢ A -> Γ ⊨ A ∷ Γ′ -- the unique morphism into the product\n ! : forall {Γ} -> Γ ⊨ [] -- the unique morphism into the terminal object\n\n data _⊢_ where\n func : forall {Γ} (f : Func) -> Γ ⊢ dom f -> Γ ⊢ cod f\n\n var : forall {Γ A} -> A ∷ Γ ⊢ A\n\n unit : forall {Γ} -> Γ ⊢ Unit\n\n pair : forall {Γ A B} -> Γ ⊢ A -> Γ ⊢ B -> Γ ⊢ A * B\n fst : forall {Γ A B} -> Γ ⊢ A * B -> Γ ⊢ A\n snd : forall {Γ A B} -> Γ ⊢ A * B -> Γ ⊢ B\n\n abs : forall {Γ A B} -> A ∷ Γ ⊢ B -> Γ ⊢ A => B\n app : forall {Γ A B} -> Γ ⊢ A => B -> Γ ⊢ A -> Γ ⊢ B\n\n _[_] : forall {Γ Γ′ A} -> Γ′ ⊢ A -> Γ ⊨ Γ′ -> Γ ⊢ A\n\n infix 10 _×id′\n\n _×id′ : forall {Γ Γ′} {A} -> Γ ⊨ Γ′ -> A ∷ Γ ⊨ A ∷ Γ′\n γ ×id′ = ext (γ ∙ weaken) var\n", "meta": {"hexsha": "f710728d2edc5af922b30b0bf38865e09d769185", "size": 2047, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Syntax.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": "Syntax.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": "Syntax.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": 24.6626506024, "max_line_length": 98, "alphanum_fraction": 0.5285784074, "num_tokens": 842, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672227971211, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.5956733399054158}} {"text": "------------------------------------------------------------------------\n-- H-levels\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\n-- Partly based on Voevodsky's work on so-called univalent\n-- foundations.\n\nopen import Equality\n\nmodule H-level\n {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where\n\nopen Derived-definitions-and-properties eq\nopen import Logical-equivalence hiding (id; _∘_)\nopen import Nat eq\nopen import Prelude\nopen import Surjection eq hiding (id; _∘_)\n\nprivate\n variable\n a ℓ : Level\n m n : ℕ\n A B : Type a\n\n------------------------------------------------------------------------\n-- H-levels\n\n-- H-levels (\"homotopy levels\").\n\nH-level : ℕ → Type ℓ → Type ℓ\nH-level zero A = Contractible A\nH-level (suc zero) A = Is-proposition A\nH-level (suc (suc n)) A = {x y : A} → H-level (suc n) (x ≡ y)\n\nprivate\n\n -- Note that H-level 2 is a synonym for Is-set.\n\n H-level-2≡Is-set : H-level 2 A ≡ Is-set A\n H-level-2≡Is-set = refl _\n\n-- For-iterated-equality n P A means that P holds for (equalities\n-- over)^n A.\n\nFor-iterated-equality : ℕ → (Type ℓ → Type ℓ) → (Type ℓ → Type ℓ)\nFor-iterated-equality zero P A = P A\nFor-iterated-equality (suc n) P A =\n (x y : A) → For-iterated-equality n P (x ≡ y)\n\n-- An alternative definition of h-levels.\n--\n-- In some cases this definition, with only two cases, is easier to\n-- use. In other cases the definition above, which is less complicated\n-- for positive h-levels, is easier to use.\n\nH-level′ : ℕ → Type ℓ → Type ℓ\nH-level′ = flip For-iterated-equality Contractible\n\n-- Propositions are propositional types.\n\nProposition : (ℓ : Level) → Type (lsuc ℓ)\nProposition _ = ∃ Is-proposition\n\n-- Types that are sets.\n\nSet : (ℓ : Level) → Type (lsuc ℓ)\nSet _ = ∃ Is-set\n\n-- The underlying type.\n\n⌞_⌟ : Set ℓ → Type ℓ\n⌞ A ⌟ = proj₁ A\n\n------------------------------------------------------------------------\n-- General properties\n\n-- H-level′ is upwards closed in its first argument.\n\nmono₁′ : ∀ n → H-level′ n A → H-level′ (1 + n) A\nmono₁′ (suc n) h x y = mono₁′ n (h x y)\nmono₁′ {A = A} zero h x y = trivial x y , irr\n where\n trivial : (x y : A) → x ≡ y\n trivial x y =\n x ≡⟨ sym $ proj₂ h x ⟩\n proj₁ h ≡⟨ proj₂ h y ⟩∎\n y ∎\n\n irr : (x≡y : x ≡ y) → trivial x y ≡ x≡y\n irr = elim (λ {x y} x≡y → trivial x y ≡ x≡y)\n (λ x → trans-symˡ (proj₂ h x))\n\n-- H-level and H-level′ are pointwise logically equivalent.\n\nH-level⇔H-level′ : H-level n A ⇔ H-level′ n A\nH-level⇔H-level′ = record { to = to _; from = from _ }\n where\n to : ∀ n → H-level n A → H-level′ n A\n to zero h = h\n to (suc zero) h = λ x → mono₁′ 0 (x , h x) x\n to (suc (suc n)) h = λ x y → to (suc n) h\n\n from : ∀ n → H-level′ n A → H-level n A\n from zero h = h\n from (suc zero) h x y = proj₁ (h x y)\n from (suc (suc n)) h {x = x} {y = y} = from (suc n) (h x y)\n\n-- If A has h-level 1 + n, then the types of equality proofs between\n-- elements of type A have h-level n.\n\n+⇒≡ : {x y : A} → H-level (suc n) A → H-level n (x ≡ y)\n+⇒≡ h = _⇔_.from H-level⇔H-level′ $ _⇔_.to H-level⇔H-level′ h _ _\n\n-- H-level is upwards closed in its first argument.\n\nmono₁ : ∀ n → H-level n A → H-level (1 + n) A\nmono₁ n =\n _⇔_.from H-level⇔H-level′ ∘\n mono₁′ n ∘\n _⇔_.to H-level⇔H-level′\n\nabstract\n\n mono : m ≤ n → H-level m A → H-level n A\n mono (≤-refl′ eq) = subst (λ n → H-level n _) eq\n mono (≤-step′ m≤n eq) =\n subst (λ n → H-level n _) eq ∘\n mono₁ _ ∘\n mono m≤n\n\n -- If A has h-level n, then the types of equality proofs between\n -- elements of type A also have h-level n.\n\n ⇒≡ : {x y : A} → ∀ n → H-level n A → H-level n (x ≡ y)\n ⇒≡ _ = +⇒≡ ∘ mono₁ _\n\n -- If something is contractible given the assumption that it is\n -- inhabited, then it is propositional.\n\n [inhabited⇒contractible]⇒propositional :\n (A → Contractible A) → Is-proposition A\n [inhabited⇒contractible]⇒propositional h x = mono₁ 0 (h x) x\n\n -- If something has h-level (1 + n) given the assumption that it is\n -- inhabited, then it has h-level (1 + n).\n\n [inhabited⇒+]⇒+ : ∀ n → (A → H-level (1 + n) A) → H-level (1 + n) A\n [inhabited⇒+]⇒+ n h =\n _⇔_.from H-level⇔H-level′ λ x → _⇔_.to H-level⇔H-level′ (h x) x\n\n -- An alternative characterisation of sets and higher h-levels.\n --\n -- This is Theorem 7.2.7 from the HoTT book.\n\n 2+⇔∀1+≡ :\n ∀ n → H-level (2 + n) A ⇔ ((x : A) → H-level (1 + n) (x ≡ x))\n 2+⇔∀1+≡ n = record\n { to = λ h _ → h\n ; from = λ h → [inhabited⇒+]⇒+ _\n (elim (λ {x y} _ → H-level (1 + n) (x ≡ y)) h)\n }\n\n-- If a propositional type is inhabited, then it is contractible.\n\npropositional⇒inhabited⇒contractible :\n Is-proposition A → A → Contractible A\npropositional⇒inhabited⇒contractible p x = (x , p x)\n\n-- H-level′ n respects (split) surjections.\n\nrespects-surjection′ :\n A ↠ B → ∀ n → H-level′ n A → H-level′ n B\nrespects-surjection′ A↠B zero (x , irr) = (to x , irr′)\n where\n open _↠_ A↠B\n\n irr′ : ∀ y → to x ≡ y\n irr′ = λ y →\n to x ≡⟨ cong to (irr (from y)) ⟩\n to (from y) ≡⟨ right-inverse-of y ⟩∎\n y ∎\n\nrespects-surjection′ A↠B (suc n) h = λ x y →\n respects-surjection′ (↠-≡ A↠B) n (h (from x) (from y))\n where open _↠_ A↠B\n\n-- H-level n respects (split) surjections.\n\nrespects-surjection :\n A ↠ B → ∀ n → H-level n A → H-level n B\nrespects-surjection A↠B n =\n _⇔_.from H-level⇔H-level′ ∘\n respects-surjection′ A↠B n ∘\n _⇔_.to H-level⇔H-level′\n", "meta": {"hexsha": "0c6188078c53910b5cc02b16b5a4247d19619f2c", "size": 5534, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/H-level.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/H-level.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/H-level.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.0913705584, "max_line_length": 72, "alphanum_fraction": 0.5556559451, "num_tokens": 2050, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.7371581626286833, "lm_q1q2_score": 0.5956733356084806}} {"text": "{-\n\nDefinition of the torus as a HIT together with a proof that it is\nequivalent to two circles\n\n-}\n{-# OPTIONS --cubical --safe #-}\nmodule Cubical.HITs.Torus.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.Nat\nopen import Cubical.Data.Int\nopen import Cubical.Data.Prod hiding (_×_) renaming (_×Σ_ to _×_)\n\nopen import Cubical.HITs.S1\n\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\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\nTorus≡S¹×S¹ : Torus ≡ S¹ × S¹\nTorus≡S¹×S¹ = isoToPath (iso t2c c2t t2c-c2t c2t-t2c)\n\nΩTorus : Type₀\nΩTorus = point ≡ point\n\n-- TODO: upstream\nlemPathAnd : ∀ {ℓ} {A B : Type ℓ} (t u : A × B) →\n Path _ (t ≡ u) ((t .fst ≡ u .fst) × ((t .snd) ≡ (u .snd)))\nlemPathAnd t u = isoToPath (iso (λ tu → (λ i → tu i .fst) , λ i → tu i .snd)\n (λ tu i → tu .fst i , tu .snd i)\n (λ y → refl)\n (λ x → refl))\n\nfunDep : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) (u0 : A) (u1 : B) →\n (Path A u0 (transport (λ i → p (~ i)) u1)) ≡ (Path B (transport p u0) u1)\nfunDep p u0 u1 i = Path (p i) (transp (λ j → p (i ∧ j)) (~ i) u0) (transp (λ j → p (i ∨ ~ j)) i u1)\n\n-- Can this proof be simplified?\nΩTorus≡Int×Int : ΩTorus ≡ Int × Int\nΩTorus≡Int×Int =\n ΩTorus\n ≡⟨ (λ i → Path Torus point (transp (\\ j → Torus≡S¹×S¹ (~ j ∧ i)) (~ i)\n (glue (λ { (i = i0) → point\n ; (i = i1) → (base , base) }) (base , base)))) ⟩\n Path Torus point (transp (\\ i → Torus≡S¹×S¹ (~ i)) i0 (base , base))\n ≡⟨ funDep (λ i → Torus≡S¹×S¹ i) point (base , base) ⟩\n Path (S¹ × S¹) (transp (\\ i → Torus≡S¹×S¹ i) i0 point) (base , base)\n ≡⟨ (λ i → Path _ (transp (λ j → Torus≡S¹×S¹ (j ∨ i)) i\n (glue (λ { (i = i0) → point\n ; (i = i1) → (base , base) }) (base , base))) (base , base)) ⟩\n Path (S¹ × S¹) (base , base) (base , base)\n ≡⟨ lemPathAnd (base , base) (base , base) ⟩\n ΩS¹ × ΩS¹\n ≡⟨ (λ i → ΩS¹≡Int i × ΩS¹≡Int i) ⟩\n Int × Int ∎\n\n-- Computing the winding numbers on the torus\nwindingTorus : ΩTorus → Int × Int\nwindingTorus l = ( winding (λ i → t2c (l i) .fst)\n , winding (λ i → t2c (l i) .snd))\n\nmodule _ where\n private\n test1 : windingTorus (line1 ∙ line2) ≡ (pos 1 , pos 1)\n test1 = refl\n\n test2 : windingTorus (line1 ∙ line2 ∙ sym line1 ∙ sym line1) ≡ (negsuc 0 , pos 1)\n test2 = refl\n", "meta": {"hexsha": "71fdd013cee661b557c0001a00671d759685ee64", "size": 3297, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Torus/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/Torus/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/Torus/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": 32.6435643564, "max_line_length": 100, "alphanum_fraction": 0.5347285411, "num_tokens": 1353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214155, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.5956707894353712}} {"text": "{-# OPTIONS --type-in-type #-}\n\ndata ⊥ : Set where\n\n℘ : ∀ {ℓ} → Set ℓ → Set _\n℘ {ℓ} S = S → Set\n\nU : Set\nU = ∀ (X : Set) → (℘ (℘ X) → X) → ℘ (℘ X)\n\n{- If using two impredicative universe layers instead of type-in-type:\nU : Set₁\nU = ∀ (X : Set₁) → (℘ (℘ X) → X) → ℘ (℘ X)\n-}\n\nτ : ℘ (℘ U) → U\nτ t = λ X f p → t (λ x → p (f (x X f)))\n\nσ : U → ℘ (℘ U)\nσ s = s U τ\n\nΔ : ℘ U\nΔ y = (∀ p → σ y p → p (τ (σ y))) → ⊥\n\nΩ : U \nΩ = τ (λ p → (∀ x → σ x p → p x))\n\nR : ∀ p → (∀ x → σ x p → p x) → p Ω\nR _ 𝟙 = 𝟙 Ω (λ x → 𝟙 (τ (σ x)))\n\nM : ∀ x → σ x Δ → Δ x\nM _ 𝟚 𝟛 = 𝟛 Δ 𝟚 (λ p → 𝟛 (λ y → p (τ (σ y))))\n\nL : (∀ p → (∀ x → σ x p → p x) → p Ω) → ⊥\nL 𝟘 = 𝟘 Δ M (λ p → 𝟘 (λ y → p (τ (σ y))))\n\nfalse : ⊥\nfalse = L R", "meta": {"hexsha": "0bdb33a245e87c059b1d20d535bc900079280c90", "size": 694, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "_assets/agda/Girard.agda", "max_stars_repo_name": "ionathanch/ionathanch.github.io", "max_stars_repo_head_hexsha": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "_assets/agda/Girard.agda", "max_issues_repo_name": "ionathanch/ionathanch.github.io", "max_issues_repo_head_hexsha": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "_assets/agda/Girard.agda", "max_forks_repo_name": "ionathanch/ionathanch.github.io", "max_forks_repo_head_hexsha": "d54cdaf24391b2726e491a18cba2d2d8ae3ac20b", "max_forks_repo_licenses": ["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.2631578947, "max_line_length": 70, "alphanum_fraction": 0.3674351585, "num_tokens": 395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505402422645, "lm_q2_score": 0.6584174871563662, "lm_q1q2_score": 0.5956377354609609}} {"text": "\nmodule Trans where\n\nopen import Prelude\n\nRel : Set -> Set1\nRel A = A -> A -> Set\n\ndata [_]* {A : Set}(R : Rel A)(x : A) : A -> Set where\n ref : [ R ]* x x\n _▹_ : {y z : A} -> R x y -> [ R ]* y z -> [ R ]* x z\n\ninfixr 40 _▹_ _▹◃_\n\nlength : {A : Set}{R : Rel A}{x y : A} -> [ R ]* x y -> Nat\nlength ref = zero\nlength (x ▹ xs) = suc (length xs)\n\n_=[_]=>_ : {A B : Set}(R : Rel A)(i : A -> B)(S : Rel B) -> Set\nR =[ i ]=> S = forall {x y} -> R x y -> S (i x) (i y)\n\nmap : {A B : Set}{R : Rel A}{S : Rel B}(i : A -> B) ->\n (R =[ i ]=> S) ->\n {x y : A} -> [ R ]* x y -> [ S ]* (i x) (i y)\nmap i f ref = ref\nmap i f (x ▹ xs) = f x ▹ map i f xs\n\nlem-length-map :\n {A B : Set}{R : Rel A}{S : Rel B}(i : A -> B)\n (f : R =[ i ]=> S){x y : A}(xs : [ R ]* x y) ->\n length xs ≡ length (map {S = S} i f xs)\nlem-length-map i f ref = refl\nlem-length-map i f (x ▹ xs) = cong suc (lem-length-map i f xs)\n\n_▹◃_ : {A : Set}{R : Rel A}{x y z : A} ->\n [ R ]* x y -> [ R ]* y z -> [ R ]* x z\nref ▹◃ ys = ys\n(x ▹ xs) ▹◃ ys = x ▹ (xs ▹◃ ys)\n\nlem-length▹◃ : {A : Set}{R : Rel A}{x y z : A}\n (r₁ : [ R ]* x y)(r₂ : [ R ]* y z) ->\n length r₁ + length r₂ ≡ length (r₁ ▹◃ r₂)\nlem-length▹◃ ref ys = refl\nlem-length▹◃ (x ▹ xs) ys = cong suc (lem-length▹◃ xs ys)\n", "meta": {"hexsha": "fb55825eecdcabc7543dc1794bbd8658f356f29f", "size": 1316, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/tait/Trans.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/tait/Trans.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/tait/Trans.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": 29.2444444444, "max_line_length": 63, "alphanum_fraction": 0.4171732523, "num_tokens": 581, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.855851143290548, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5956367281624552}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule sets.int.utils where\n\nopen import sum\nopen import equality\nopen import function\nopen import sets.nat.core\nopen import sets.int.definition\nopen import hott.level\n\nmodule _ {i}{X : Set i}(hX : h 2 X)\n (f : ℕ → ℕ → ℕ → ℕ → X)\n (u : ∀ n n' d m m' e → f n n' m m' ≡ f (d + n) (d + n') (e + m) (e + m')) where\n\n private\n g : ℕ → ℕ → ℤ → X\n g n n' = elim-ℤ hX (f n n' , u n n' 0)\n\n lem : (n n' d m m' : ℕ) → g n n' (m [-] m') ≡ g (d + n) (d + n') (m [-] m')\n lem n n' d m m' = u n n' d m m' 0\n\n v : (n n' d : ℕ) → g n n' ≡ g (d + n) (d + n')\n v n n' d = funext λ m → elim-prop-ℤ\n (λ m → hX (g n n' m) (g (d + n) (d + n') m))\n (lem n n' d) m\n\n hX' : h 2 (ℤ → X)\n hX' = Π-level λ _ → hX\n\n elim₂-ℤ : ℤ → ℤ → X\n elim₂-ℤ = elim-ℤ hX' (g , v)\n\nelim₂-prop-ℤ : ∀ {i}{X : ℤ → ℤ → Set i} → (∀ n m → h 1 (X n m))\n → ((n n' m m' : ℕ) → X (n [-] n') (m [-] m'))\n → ∀ n m → X n m\nelim₂-prop-ℤ {i}{X} hX f = elim-prop-ℤ hX' g\n where\n g : (n n' : ℕ) → ∀ m → X (n [-] n') m\n g n n' = elim-prop-ℤ (hX (n [-] n')) (f n n')\n\n hX' : ∀ n → h 1 (∀ m → X n m)\n hX' n = Π-level λ m → hX n m\n\nelim₃-prop-ℤ : ∀ {i}{X : ℤ → ℤ → ℤ → Set i} → (∀ n m p → h 1 (X n m p))\n → ((n n' m m' p p' : ℕ) → X (n [-] n') (m [-] m') (p [-] p'))\n → ∀ n m p → X n m p\nelim₃-prop-ℤ {i}{X} hX f = elim-prop-ℤ hX' g\n where\n g : (n n' : ℕ) → ∀ m p → X (n [-] n') m p\n g n n' = elim₂-prop-ℤ (hX (n [-] n')) (f n n')\n\n hX' : ∀ n → h 1 (∀ m p → X n m p)\n hX' n = Π-level λ m → Π-level λ p → hX n m p\n", "meta": {"hexsha": "c79988714b1e3b49fb174545a05e11b9850746f4", "size": 1590, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sets/int/utils.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/utils.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/utils.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": 28.9090909091, "max_line_length": 81, "alphanum_fraction": 0.4006289308, "num_tokens": 770, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.5956085124611538}} {"text": "------------------------------------------------------------------------\n-- An ad-hoc but straightforward solution to the problem of showing\n-- that elegant definitions of the Hamming numbers (see EWD 792) and\n-- the Fibonacci sequence are productive\n------------------------------------------------------------------------\n\nmodule StreamProg where\n\nopen import Codata.Musical.Notation\nopen import Codata.Musical.Stream as S using (Stream; _∷_; _≈_)\nopen import Data.Nat\nopen import Relation.Binary\nimport Relation.Binary.PropositionalEquality as P\n\nprivate\n module SS {A : Set} = Setoid (S.setoid A)\n\n------------------------------------------------------------------------\n-- Merging of streams\n\ndata Ord : Set where\n lt : Ord\n eq : Ord\n gt : Ord\n\nmerge : {A : Set} → (A → A → Ord) → Stream A → Stream A → Stream A\nmerge cmp (x ∷ xs) (y ∷ ys) with cmp x y\n... | lt = x ∷ ♯ merge cmp (♭ xs) (y ∷ ys)\n... | eq = x ∷ ♯ merge cmp (♭ xs) (♭ ys)\n... | gt = y ∷ ♯ merge cmp (x ∷ xs) (♭ ys)\n\n------------------------------------------------------------------------\n-- Stream programs\n\ninfixr 5 _∷_\n\ndata StreamP (A : Set) : Set1 where\n _∷_ : (x : A) (xs : ∞ (StreamP A)) → StreamP A\n zipWith : ∀ {B C} (f : B → C → A)\n (xs : StreamP B) (ys : StreamP C) → StreamP A\n map : ∀ {B} (f : B → A) (xs : StreamP B) → StreamP A\n mergeP : (cmp : A → A → Ord)\n (xs : StreamP A) (ys : StreamP A) → StreamP A\n\ndata StreamW A : Set1 where\n _∷_ : (x : A) (xs : StreamP A) → StreamW A\n\nzipWithW : {A B C : Set} →\n (A → B → C) → StreamW A → StreamW B → StreamW C\nzipWithW f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys\n\nmapW : {A B : Set} → (A → B) → StreamW A → StreamW B\nmapW f (x ∷ xs) = f x ∷ map f xs\n\nmergeW : {A : Set} →\n (A → A → Ord) → StreamW A → StreamW A → StreamW A\nmergeW cmp (x ∷ xs) (y ∷ ys) with cmp x y\n... | lt = x ∷ mergeP cmp xs (y ∷ ♯ ys)\n... | eq = x ∷ mergeP cmp xs ys\n... | gt = y ∷ mergeP cmp (x ∷ ♯ xs) ys\n\nwhnf : ∀ {A} → StreamP A → StreamW A\nwhnf (x ∷ xs) = x ∷ ♭ xs\nwhnf (zipWith f xs ys) = zipWithW f (whnf xs) (whnf ys)\nwhnf (map f xs) = mapW f (whnf xs)\nwhnf (mergeP cmp xs ys) = mergeW cmp (whnf xs) (whnf 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------------------------------------------------------------------------\n-- Examples\n\nfib : StreamP ℕ\nfib = 0 ∷ ♯ zipWith _+_ fib (1 ∷ ♯ fib)\n\n-- Alternative definition showing that definitions do not need to\n-- start with a cons constructor.\n\nfib′ : StreamP ℕ\nfib′ = zipWith _+_ (0 ∷ ♯ fib′) (0 ∷ ♯ (1 ∷ ♯ fib′))\n\ncmp : ℕ → ℕ → Ord\ncmp m n = toOrd (compare m n)\n where\n toOrd : ∀ {m n} → Ordering m n → Ord\n toOrd (less _ _) = lt\n toOrd (equal _) = eq\n toOrd (greater _ _) = gt\n\nhamming : StreamP ℕ\nhamming = 1 ∷ ♯ mergeP cmp (map (_*_ 2) hamming) (map (_*_ 3) hamming)\n\n------------------------------------------------------------------------\n-- The definition of fib is correct\n\n-- ⟦_⟧P is homomorphic with respect to zipWith/S.zipWith.\n\nzipWith-hom : ∀ {A B C} (_∙_ : A → B → C) xs ys →\n ⟦ zipWith _∙_ xs ys ⟧P ≈ S.zipWith _∙_ ⟦ xs ⟧P ⟦ ys ⟧P\nzipWith-hom _∙_ xs ys with whnf xs | whnf ys\nzipWith-hom _∙_ xs ys | x ∷ xs′ | y ∷ ys′ =\n P.refl ∷ ♯ zipWith-hom _∙_ xs′ ys′\n\n-- Unfortunately Agda's definitional equality for coinductive\n-- constructors is currently a little strange, so the result type\n-- cannot be written out completely here:\n\nfib-correct′ :\n ⟦ fib ⟧P ≈ 0 ∷ ♯ S.zipWith _+_ ⟦ fib ⟧P (1 ∷ _ {- ♯ ⟦ fib ⟧P -})\nfib-correct′ = P.refl ∷ ♯ zipWith-hom _+_ fib (1 ∷ ♯ fib)\n\n-- Fortunately there is a workaround.\n\nfib-correct : ⟦ fib ⟧P ≈ 0 ∷ ♯ S.zipWith _+_ ⟦ fib ⟧P (1 ∷ ♯ ⟦ fib ⟧P)\nfib-correct =\n P.refl ∷ ♯ SS.trans (zipWith-hom _+_ fib (1 ∷ ♯ fib))\n (S.zipWith-cong _+_ (SS.refl {x = 0 ∷ _})\n (P.refl ∷ ♯ SS.refl))\n\n-- For a proof showing that the given equation for fib has a unique\n-- solution, see MapIterate.\n\n------------------------------------------------------------------------\n-- The definition of hamming is correct\n\n-- ⟦_⟧P is homomorphic with respect to map/S.map.\n\nmap-hom : ∀ {A B} (f : A → B) xs →\n ⟦ map f xs ⟧P ≈ S.map f ⟦ xs ⟧P\nmap-hom f xs with whnf xs\n... | x ∷ xs′ = P.refl ∷ ♯ map-hom f xs′\n\n-- ⟦_⟧P is homomorphic with respect to mergeP/merge.\n\nmerge-hom : ∀ {A} (cmp : A → A → Ord) xs ys →\n ⟦ mergeP cmp xs ys ⟧P ≈ merge cmp ⟦ xs ⟧P ⟦ ys ⟧P\nmerge-hom cmp xs ys with whnf xs | whnf ys\n... | x ∷ xs′ | y ∷ ys′ with cmp x y\n... | lt = P.refl ∷ ♯ merge-hom cmp xs′ (y ∷ ♯ ys′)\n... | eq = P.refl ∷ ♯ merge-hom cmp xs′ ys′\n... | gt = P.refl ∷ ♯ merge-hom cmp (x ∷ ♯ xs′) ys′\n\n-- merge is a congruence.\n\nmerge-cong : ∀ {A} (cmp : A → A → Ord) {xs xs′ ys ys′} →\n xs ≈ xs′ → ys ≈ ys′ →\n merge cmp xs ys ≈ merge cmp xs′ ys′\nmerge-cong cmp (_∷_ {x = x} P.refl xs≈)\n (_∷_ {x = y} P.refl ys≈) with cmp x y\n... | lt = P.refl ∷ ♯ merge-cong cmp (♭ xs≈) (P.refl ∷ ys≈)\n... | eq = P.refl ∷ ♯ merge-cong cmp (♭ xs≈) (♭ ys≈)\n... | gt = P.refl ∷ ♯ merge-cong cmp (P.refl ∷ xs≈) (♭ ys≈)\n\n-- hamming is correct.\n\nhamming-correct : ⟦ hamming ⟧P ≈\n 1 ∷ ♯ merge cmp (S.map (_*_ 2) ⟦ hamming ⟧P)\n (S.map (_*_ 3) ⟦ hamming ⟧P)\nhamming-correct =\n P.refl ∷ ♯ SS.trans (merge-hom cmp (map (_*_ 2) hamming)\n (map (_*_ 3) hamming))\n (merge-cong cmp (map-hom (_*_ 2) hamming)\n (map-hom (_*_ 3) hamming))\n", "meta": {"hexsha": "499361beb58656190173932e9e497e8459afa113", "size": 5652, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "StreamProg.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": "StreamProg.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": "StreamProg.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": 33.2470588235, "max_line_length": 72, "alphanum_fraction": 0.4902689314, "num_tokens": 2038, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837581726991, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.5955119069294224}} {"text": "-- Copyright: (c) 2016 Ertugrul Söylemez\n-- License: BSD3\n-- Maintainer: Ertugrul Söylemez \n\nmodule Data.Mod where\n\nopen import Core\nopen import Data.Int.Core hiding (module Props)\nimport Data.Int.Core as ℤ\nopen import Data.Nat.Core using (ℕ)\nimport Data.Nat.Core as ℕ\n\n\nprivate module ℤP = ℤ.Props\n\n\nModEq : ℕ → Equiv ℤ\nModEq n =\n record {\n _≈_ = _≈_;\n refl = λ {x} → 0 , ℤP.+-right-inv x;\n sym = λ {x} {y} → sym' x y;\n trans = λ {x} {y} {z} → trans' x y z\n }\n\n where\n infix 4 _≈_\n\n _≈_ : ℤ → ℤ → Set\n x ≈ y = ∃ (λ k → x - y ≡ k * pos n)\n\n sym' : ∀ x y → x ≈ y → y ≈ x\n sym' x y (k , p) =\n neg k ,\n (begin\n y - x || sym (ℤP.neg-flip x y) ::\n neg (x - y) || cong neg p ::\n neg (k * pos n) || sym (ℤP.*-assoc -1 k (pos n)) ::\n neg k * pos n\n qed)\n\n where\n open Equiv (PropEq ℤ)\n\n trans' : ∀ x y z → x ≈ y → y ≈ z → x ≈ z\n trans' x y z (k1 , p1) (k2 , p2) =\n k1 + k2 ,\n (begin\n x - z || cong (x +_) (sym (ℤP.+-left-id (neg z))) ::\n x + (0 - z) || cong (λ a → x + (a - z)) (sym (ℤP.+-left-inv y)) ::\n x + (neg y + y - z) || cong (x +_) (ℤP.+-assoc (neg y) y (neg z)) ::\n x + (neg y + (y - z)) || sym (ℤP.+-assoc x (neg y) (y + neg z)) ::\n x + neg y + (y - z) || cong2 _+_ p1 p2 ::\n k1 * pos n + k2 * pos n || sym (ℤP.*-+-right-dist k1 k2 (pos n)) ::\n (k1 + k2) * pos n\n qed)\n\n where\n open Equiv (PropEq ℤ)\n\n\nmodule Props (n : ℕ) where\n open Equiv (ModEq n) using (_≈_)\n open Equiv (PropEq ℤ) hiding (_≈_)\n\n +-cong : ∀ {x1 x2 y1 y2} → x1 ≈ x2 → y1 ≈ y2 → x1 + y1 ≈ x2 + y2\n +-cong {x1} {x2} {y1} {y2} (k1 , p1) (k2 , p2) =\n k1 + k2 ,\n (begin\n x1 + y1 - (x2 + y2) || ℤP.+-assoc x1 y1 _ ::\n x1 + (y1 - (x2 + y2)) ||\n cong (x1 +_) (\n y1 - (x2 + y2) || cong (y1 +_) (ℤP.*-+-left-dist -1 x2 y2) ::\n y1 + (neg x2 + neg y2) || sym (ℤP.+-assoc y1 (neg x2) (neg y2)) ::\n (y1 + neg x2 + neg y2) || cong (_+ neg y2) (ℤP.+-comm y1 (neg x2)) ::\n neg x2 + y1 + neg y2 || ℤP.+-assoc (neg x2) y1 _ ::\n neg x2 + (y1 + neg y2)\n qed) ::\n x1 + (neg x2 + (y1 + neg y2)) || sym (ℤP.+-assoc x1 (neg x2) _) ::\n x1 - x2 + (y1 - y2) || cong2 _+_ p1 p2 ::\n k1 * pos n + k2 * pos n || sym (ℤP.*-+-right-dist k1 k2 (pos n)) ::\n (k1 + k2) * pos n\n qed)\n", "meta": {"hexsha": "9a0f5d67026ba16684d6c0080155d6aed3064c3c", "size": 2415, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Mod.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/Mod.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/Mod.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": 28.75, "max_line_length": 84, "alphanum_fraction": 0.4426501035, "num_tokens": 1061, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942232112239, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5955002318283282}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.PushoutSplit\n\nmodule cw.cohomology.CofiberGrid {i j k}\n {A : Type i} {B : Type j} {C : Type k}\n (f : A → B) (g : B → C) where\n\n {-\n A -------> B -----------> C\n | | _/|\n | | _/ |\n | | __.D_ |\n v v .--' | `-.v\n 1 ------> B/A ------|-> C/A\n | | |\n | v |\n | __.E_ |\n v .--' `-.v\n 1 ---------> C/B\n -}\n\n open import cw.cohomology.GridMap f g\n\n private\n B-to-B/A : B → B/A\n B-to-B/A = cfcod' f\n\n D-span : Span\n D-span = span B/A C B B-to-B/A g\n D : Type (lmax i (lmax j k))\n D = Pushout D-span\n\n private\n module VSplit = PushoutRSplit (λ _ → tt) f g\n module C/AToD = VSplit.Split\n C/A-to-D : C/A → D\n C/A-to-D = C/AToD.f\n\n B/A-to-D : B/A → D\n B/A-to-D = left\n\n private\n E : Type (lmax i (lmax j k))\n E = Cofiber B/A-to-D\n\n private\n module HSplit = PushoutLSplit B-to-B/A (λ _ → tt) g\n module C/BToE = HSplit.Split\n C/B-to-E : C/B → E\n C/B-to-E = C/BToE.f\n\n private\n module DToC/B = HSplit.Inner\n D-to-C/B : D → C/B\n D-to-C/B = DToC/B.f\n\n D-to-E : D → E\n D-to-E = cfcod\n\n C/A-to-D-to-C/B : ∀ c/a → D-to-C/B (C/A-to-D c/a) == C/A-to-C/B c/a\n C/A-to-D-to-C/B = Cofiber-elim\n idp\n (λ c → idp)\n (λ a → ↓-='-in' $ ! $\n ap (D-to-C/B ∘ C/A-to-D) (glue a)\n =⟨ ap-∘ D-to-C/B C/A-to-D (glue a) ⟩\n ap D-to-C/B (ap C/A-to-D (glue a))\n =⟨ C/AToD.glue-β a |in-ctx ap D-to-C/B ⟩\n ap D-to-C/B (ap left (glue a) ∙ glue (f a))\n =⟨ ap-∙ D-to-C/B (ap left (glue a)) (glue (f a)) ⟩\n ap D-to-C/B (ap left (glue a)) ∙ ap D-to-C/B (glue (f a))\n =⟨ ap2 _∙_ (∘-ap D-to-C/B left (glue a)) (DToC/B.glue-β (f a)) ⟩\n ap (λ _ → cfbase) (glue a) ∙ glue (f a)\n =⟨ ap-cst cfbase (glue a) |in-ctx _∙ glue (f a) ⟩\n glue (f a)\n =⟨ ! $ C/AToC/B.glue-β a ⟩\n ap C/A-to-C/B (glue a)\n =∎)\n\n D-to-C/B-to-E : ∀ d → C/B-to-E (D-to-C/B d) == D-to-E d\n D-to-C/B-to-E = HSplit.split-inner\n\n {- The public interface -}\n\n C/A-to-C/B-comm-square : CommSquare C/A-to-C/B D-to-E C/A-to-D C/B-to-E\n C/A-to-C/B-comm-square = comm-sqr λ c/a → ap C/B-to-E (! (C/A-to-D-to-C/B c/a))\n ∙ D-to-C/B-to-E (C/A-to-D c/a)\n\n B/A-to-C/A-comm-square : CommSquare B/A-to-C/A B/A-to-D (idf B/A) C/A-to-D\n B/A-to-C/A-comm-square = comm-sqr VSplit.split-inner\n\n C/A-to-D-is-equiv : is-equiv C/A-to-D\n C/A-to-D-is-equiv = snd VSplit.split-equiv\n\n C/B-to-E-is-equiv : is-equiv C/B-to-E\n C/B-to-E-is-equiv = snd HSplit.split-equiv\n", "meta": {"hexsha": "46da7b9fea7bba3bb37d5d1ca2c4c7b73fd5497f", "size": 2761, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cw/cohomology/CofiberGrid.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/cw/cohomology/CofiberGrid.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/cw/cohomology/CofiberGrid.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": 27.8888888889, "max_line_length": 81, "alphanum_fraction": 0.4516479536, "num_tokens": 1084, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942203004186, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5955002298813481}} {"text": "module proofs where\n\nopen import lambdasyntax\nopen import static\nopen import dynamic\n\nopen import Data.Empty\nopen import Data.Nat\nopen import Function\nopen import Data.Vec using (Vec; [])\nopen import Data.Bool using (Bool; true; false)\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\n\n-- label precision\ndata _⊑ˡ_ : (ℓ₁ ℓ₂ : Label) → Set where\n ℓ⊑✭ : ∀ {ℓ} → ℓ ⊑ˡ ✭ \n ℓ⊑ℓ : ∀ {ℓ} → ℓ ⊑ˡ ℓ\n\n_⊑ˡ?_ : ∀ (ℓ₁ ℓ₂ : Label) → Dec (ℓ₁ ⊑ˡ ℓ₂)\n⊤ ⊑ˡ? ⊤ = yes ℓ⊑ℓ\n⊤ ⊑ˡ? ⊥ = no (λ ())\n⊤ ⊑ˡ? ✭ = yes ℓ⊑✭\n⊥ ⊑ˡ? ⊤ = no (λ ())\n⊥ ⊑ˡ? ⊥ = yes ℓ⊑ℓ\n⊥ ⊑ˡ? ✭ = yes ℓ⊑✭\n✭ ⊑ˡ? ⊤ = no (λ ())\n✭ ⊑ˡ? ⊥ = no (λ ())\n✭ ⊑ˡ? ✭ = yes ℓ⊑✭\n\n-- type precision\ndata _⊑_ : (t₁ t₂ : GType) → Set where\n b⊑b : ∀ {ℓ₁ ℓ₂} → ℓ₁ ⊑ˡ ℓ₂ → bool ℓ₁ ⊑ bool ℓ₂\n λ⊑λ : ∀ {s₁₁ s₂₁ s₁₂ s₂₂ ℓ₁ ℓ₂} → s₁₁ ⊑ s₂₁ → s₁₂ ⊑ s₂₂ → ℓ₁ ⊑ˡ ℓ₂ → ((s₁₁ ⇒ ℓ₁) s₁₂) ⊑ ((s₂₁ ⇒ ℓ₂) s₂₂)\n\nlem₁ : ∀ {t₁ t₂ t₃ t₄ ℓ ℓ₁} → (x : (t₁ ⇒ ℓ) t₂ ⊑ (t₃ ⇒ ℓ₁) t₄) → t₃ ⊑ t₁\nlem₁ (λ⊑λ x x₁ x₂) = {! !}\n\n_⊑?_ : ∀ (t₁ t₂ : GType) → Dec (t₁ ⊑ t₂)\nbool x ⊑? bool x₁ with x ⊑ˡ? x₁\nbool x ⊑? bool x₁ | yes p = yes (b⊑b p)\nbool x ⊑? bool x₁ | no ¬p = no (¬p ∘ lem)\n where lem : ∀ {ℓ₁ ℓ₂ : Label} → (bool ℓ₁ ⊑ bool ℓ₂) → ℓ₁ ⊑ˡ ℓ₂\n lem (b⊑b x) = x\nbool x ⊑? (t₂ ⇒ x₁) t₃ = no (λ ())\nbool x ⊑? err = no (λ ())\n(t₁ ⇒ x) t₂ ⊑? bool x₁ = no (λ ())\n(t₁ ⇒ ℓ) t₂ ⊑? (t₃ ⇒ ℓ₁) t₄ with t₃ ⊑? t₁ | t₂ ⊑? t₄\n(t₁ ⇒ ℓ) t₂ ⊑? (t₃ ⇒ ℓ₁) t₄ | yes p | (yes p₁) = yes {! !}\n(t₁ ⇒ ℓ) t₂ ⊑? (t₃ ⇒ ℓ₁) t₄ | yes p | (no ¬p) = no (¬p ∘ lem)\n where lem : ∀ {t₁ t₂ t₃ t₄ ℓ ℓ₁} (x : (t₁ ⇒ ℓ) t₂ ⊑ (t₃ ⇒ ℓ₁) t₄) → t₂ ⊑ t₄\n lem (λ⊑λ x x₁ x₂) = x₁\n(t₁ ⇒ ℓ) t₂ ⊑? (t₃ ⇒ ℓ₁) t₄ | no ¬p | (yes p) = no {!!} \n(t₁ ⇒ ℓ) t₂ ⊑? (t₃ ⇒ ℓ₁) t₄ | no ¬p | (no ¬p₁) = no (¬p ∘ {! !})\n(t₁ ⇒ x) t₂ ⊑? err = no (λ ())\nerr ⊑? bool x = no (λ ())\nerr ⊑? (t₂ ⇒ x) t₃ = no (λ ())\nerr ⊑? err = no (λ ())\n", "meta": {"hexsha": "beb1a435a01a0b612dd2214b9b99e3bad732de5b", "size": 1902, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Gradual Security/proofs.agda", "max_stars_repo_name": "kellino/TypeSystems", "max_stars_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-10-27T08:05:40.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-26T23:06:17.000Z", "max_issues_repo_path": "Agda/Gradual Security/proofs.agda", "max_issues_repo_name": "kellino/TypeSystems", "max_issues_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_issues_repo_licenses": ["MIT"], "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/Gradual Security/proofs.agda", "max_forks_repo_name": "kellino/TypeSystems", "max_forks_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_forks_repo_licenses": ["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.2372881356, "max_line_length": 108, "alphanum_fraction": 0.4616193481, "num_tokens": 1093, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473879530492, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.5954414142999493}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Group.DirProd where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Sigma\nopen import Cubical.Algebra.Group.Base\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Semigroup\n\nopen GroupStr\nopen IsGroup hiding (rid ; lid ; invr ; invl)\nopen IsMonoid hiding (rid ; lid)\nopen IsSemigroup\n\nDirProd : ∀ {ℓ ℓ'} → Group ℓ → Group ℓ' → Group (ℓ-max ℓ ℓ')\nfst (DirProd G H) = fst G × fst H\n1g (snd (DirProd G H)) = (1g (snd G)) , (1g (snd H))\n_·_ (snd (DirProd G H)) x y = _·_ (snd G) (fst x) (fst y)\n , _·_ (snd H) (snd x) (snd y)\n(inv (snd (DirProd G H))) x = (inv (snd G) (fst x)) , (inv (snd H) (snd x))\nis-set (isSemigroup (isMonoid (isGroup (snd (DirProd G H))))) =\n isSet× (is-set (snd G)) (is-set (snd H))\nassoc (isSemigroup (isMonoid (isGroup (snd (DirProd G H))))) x y z i =\n assoc (snd G) (fst x) (fst y) (fst z) i , assoc (snd H) (snd x) (snd y) (snd z) i\nfst (identity (isMonoid (isGroup (snd (DirProd G H)))) x) i =\n rid (snd G) (fst x) i , rid (snd H) (snd x) i\nsnd (identity (isMonoid (isGroup (snd (DirProd G H)))) x) i =\n lid (snd G) (fst x) i , lid (snd H) (snd x) i\nfst (inverse (isGroup (snd (DirProd G H))) x) i =\n (invr (snd G) (fst x) i) , invr (snd H) (snd x) i\nsnd (inverse (isGroup (snd (DirProd G H))) x) i =\n (invl (snd G) (fst x) i) , invl (snd H) (snd x) i\n", "meta": {"hexsha": "352d5446fc029d5f369d325f61d2711d31ead933", "size": 1428, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/DirProd.agda", "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 301, "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_issues_repo_path": "Cubical/Algebra/Group/DirProd.agda", "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 584, "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_forks_repo_path": "Cubical/Algebra/Group/DirProd.agda", "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 134, "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "avg_line_length": 42.0, "max_line_length": 83, "alphanum_fraction": 0.6169467787, "num_tokens": 539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473614033683, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.5954413961778345}} {"text": "{-# OPTIONS --without-K #-}\nopen import Library\nopen import Basic\n\n--------------------------------------------------------------------------------\n-- Universes for a Functor\n--------------------------------------------------------------------------------\n\nrecord FntrLevel : Set where\n field\n C : CatLevel\n D : CatLevel\n\n module C = CatLevel C\n module D = CatLevel D\n\n Fntr : Level\n Fntr = ℓ-max C.Cat D.Cat\n\n--------------------------------------------------------------------------------\n-- Definition of a Functor\n--------------------------------------------------------------------------------\n\nmodule _ {ℓ : FntrLevel} (let module ℓ = FntrLevel ℓ)\n (C : Category ℓ.C) (let module C = Category C)\n (open C using () renaming (_⇒_ to _⇒ᶜ_ ; _∘_ to _∘ᶜ_))\n (D : Category ℓ.D) (let module D = Category D)\n (open D using () renaming (_⇒_ to _⇒ᵈ_ ; _∘_ to _∘ᵈ_)) where\n\n record Functor : Set ℓ.Fntr where\n field\n map : C.Obj → D.Obj\n fmap : ∀{X Y} → X ⇒ᶜ Y → (map X) ⇒ᵈ (map Y)\n\n field\n id : ∀{X} → fmap (C.id X) ≡ D.id (map X)\n comp : ∀{X Y Z}{f : X ⇒ᶜ Y}{g : Y ⇒ᶜ Z}\n → fmap (g ∘ᶜ f) ≡ (fmap g) ∘ᵈ (fmap f)\n\n--------------------------------------------------------------------------------\n-- Definition of a Natural Transformation and a Natural Isomorphism\n--------------------------------------------------------------------------------\n\nmodule _ {ℓ : FntrLevel} (let module ℓ = FntrLevel ℓ)\n {C : Category ℓ.C} (let module C = Category C)\n (open C using () renaming (_⇒_ to _⇒ᶜ_ ; _∘_ to _∘ᶜ_))\n {D : Category ℓ.D} (let module D = Category D)\n (open D using () renaming (_⇒_ to _⇒ᵈ_ ; _∘_ to _∘ᵈ_))\n (F G : Functor C D) (let module F = Functor F)\n (let module G = Functor G) where\n\n record NaturalTrans : Set ℓ.Fntr where\n field\n map : (X : C.Obj) → (F.map X) ⇒ᵈ (G.map X)\n nat-sq : {X Y : C.Obj}{f : X ⇒ᶜ Y} →\n (G.fmap f) ∘ᵈ (map X) ≡ (map Y) ∘ᵈ (F.fmap f)\n\n is-natrual-isomorphism : Set (ℓ-max ℓ.C.Obj ℓ.D.Hom)\n is-natrual-isomorphism = ∀(X : C.Obj) → D.is-isomorphism (map X)\n\n NaturalIso : Set ℓ.Fntr\n NaturalIso = Σ NaturalTrans NaturalTrans.is-natrual-isomorphism\n\n--------------------------------------------------------------------------------\n-- Category of Functors\n--------------------------------------------------------------------------------\n\nmodule _ {ℓ : FntrLevel} (let module ℓ = FntrLevel ℓ)\n (C : Category ℓ.C) (let module C = Category C)\n (open C using () renaming (_⇒_ to _⇒ᶜ_ ; _∘_ to _∘ᶜ_))\n (D : Category ℓ.D) (let module D = Category D)\n (open D using () renaming (_⇒_ to _⇒ᵈ_ ; _∘_ to _∘ᵈ_)) where\n\n FntrCat : Category (record { Obj = ℓ.Fntr ; Hom = ℓ.Fntr })\n FntrCat = record { Obj = Functor C D\n ; _⇒_ = NaturalTrans\n ; id = natural-trans-id\n ; _∘_ = vertical-comp\n ; idl = {!!}\n ; idr = {!!}\n ; assoc = {!!} }\n where\n natural-trans-id : (F : Functor C D) → NaturalTrans F F\n natural-trans-id F = record\n { map = λ (X : C.Obj) → D.id (F.map X)\n ; nat-sq = λ {X Y : C.Obj} {f : X ⇒ᶜ Y} → ≡-proof\n (F.fmap f) ∘ᵈ D.id (F.map X) ≡⟨ D.idr ⟩\n F.fmap f ≡⟨ ≡-sym D.idl ⟩\n D.id (F.map Y) ∘ᵈ (F.fmap f) ≡-qed\n } where module F = Functor F\n\n vertical-comp : {F G H : Functor C D}\n → NaturalTrans G H → NaturalTrans F G → NaturalTrans F H\n vertical-comp {F} {G} {H} β α = record\n { map = λ (X : C.Obj) → (β.map X) ∘ᵈ (α.map X)\n ; nat-sq = λ {X Y : C.Obj} {f : X ⇒ᶜ Y} → ≡-proof\n H.fmap f ∘ᵈ (β.map X ∘ᵈ α.map X) ≡⟨ ≡-sym D.assoc ⟩\n (H.fmap f ∘ᵈ β.map X) ∘ᵈ α.map X ≡⟨ {!!} ⟩\n (β.map Y ∘ᵈ G.fmap f) ∘ᵈ α.map X ≡⟨ D.assoc ⟩\n β.map Y ∘ᵈ (G.fmap f ∘ᵈ α.map X) ≡⟨ {!!} ⟩\n β.map Y ∘ᵈ (α.map Y ∘ᵈ F.fmap f) ≡⟨ ≡-sym D.assoc ⟩\n (β.map Y ∘ᵈ α.map Y) ∘ᵈ F.fmap f ≡-qed\n } where module F = Functor F\n module G = Functor G\n module H = Functor H\n module α = NaturalTrans α\n module β = NaturalTrans β\n\n--------------------------------------------------------------------------------\n-- Definition of Presheaf\n--------------------------------------------------------------------------------\n\n-- module _ {C : CatLevel} (open CatLevel C)\n-- (C : Category C) (let module C = Category C) where\n-- Presheaf : Category (record { Obj = ℓ-suc Obj ; Hom = ℓ-suc Hom })\n-- Presheaf C = record { Obj = Functor C.op (Type Hom)\n-- ; _⇒_ = NaturalTrans\n-- ; id = NaturalTrans-id\n-- ; __}\n", "meta": {"hexsha": "775b2202ee27b8f4cffafcabcc61bdd39c6cc472", "size": 5070, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Naturality.agda", "max_stars_repo_name": "gunpinyo/agda-cat", "max_stars_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3", "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/Naturality.agda", "max_issues_repo_name": "gunpinyo/agda-cat", "max_issues_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3", "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/Naturality.agda", "max_forks_repo_name": "gunpinyo/agda-cat", "max_forks_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3", "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": 42.25, "max_line_length": 80, "alphanum_fraction": 0.3956607495, "num_tokens": 1571, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473746782093, "lm_q2_score": 0.6825737214979746, "lm_q1q2_score": 0.5954413939730934}} {"text": "module Structure.Operator.Monoid.Invertible.Proofs where\n\nimport Data.Tuple as Tuple\nimport Lvl\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Structure.Operator\nopen import Structure.Operator.Monoid\nopen import Structure.Operator.Monoid.Invertible\nopen import Structure.Operator.Properties hiding (InverseOperatorₗ ; InverseOperatorᵣ)\nopen import Structure.Relator.Properties\nopen import Structure.Setoid\nopen import Syntax.Transitivity\nopen import Type\n\nprivate variable ℓ ℓₗ ℓₑ : Lvl.Level\nprivate variable T : Type{ℓ}\nprivate variable _▫_ : T → T → T\nprivate variable _⨞_ : T → T → Type{ℓₗ}\n\nmodule _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ ⦃ monoid : Monoid{T = T}(_▫_) ⦄ ⦃ invRel : InverseRelationᵣ(_▫_){ℓₗ}(_⨞_) ⦄ where\n open Monoid(monoid) using (id)\n\n instance\n inverseRelationᵣ-reflexivity : Reflexivity(_⨞_)\n Reflexivity.proof inverseRelationᵣ-reflexivity = [↔]-to-[←] (InverseRelationᵣ.proof invRel) ([∃]-intro id ⦃ identityᵣ(_▫_)(id) ⦄)\n\n instance\n inverseRelationᵣ-transitivity : Transitivity(_⨞_)\n Transitivity.proof inverseRelationᵣ-transitivity xy yz\n with [∃]-intro a ⦃ pa ⦄ ← [↔]-to-[→] (InverseRelationᵣ.proof invRel) xy\n with [∃]-intro b ⦃ pb ⦄ ← [↔]-to-[→] (InverseRelationᵣ.proof invRel) yz\n = [↔]-to-[←] (InverseRelationᵣ.proof invRel) ([∃]-intro (a ▫ b) ⦃ symmetry(_≡_) (associativity(_▫_)) 🝖 congruence₂ₗ(_▫_)(b) pa 🝖 pb ⦄)\n\n inverseRelationᵣ-with-opᵣ : ∀{a x y} → (x ⨞ y) → ((a ▫ x) ⨞ (a ▫ y))\n inverseRelationᵣ-with-opᵣ {a}{x}{y} xy\n with [∃]-intro z ⦃ xzy ⦄ ← [↔]-to-[→] (InverseRelationᵣ.proof invRel) xy\n = [↔]-to-[←] (InverseRelationᵣ.proof invRel) ([∃]-intro z ⦃ associativity(_▫_) 🝖 congruence₂ᵣ(_▫_)(a) xzy ⦄)\n\n inverseRelationᵣ-without-opᵣ : ⦃ cancₗ : Cancellationₗ(_▫_) ⦄ → ∀{a x y} → ((a ▫ x) ⨞ (a ▫ y)) → (x ⨞ y)\n inverseRelationᵣ-without-opᵣ {a}{x}{y} xy\n with [∃]-intro z ⦃ xzy ⦄ ← [↔]-to-[→] (InverseRelationᵣ.proof invRel) xy\n = [↔]-to-[←] (InverseRelationᵣ.proof invRel) ([∃]-intro z ⦃ cancellationₗ(_▫_) (symmetry(_≡_) (associativity(_▫_)) 🝖 xzy) ⦄)\n\n inverseRelationᵣ-of-idₗ : ∀{x} → (id ⨞ x)\n inverseRelationᵣ-of-idₗ {x} = [↔]-to-[←] (InverseRelationᵣ.proof invRel) ([∃]-intro x ⦃ identityₗ(_▫_)(id) ⦄)\n\n module _ {_⋄_ : (x : T) → (y : T) → . ⦃ inv : (y ⨞ x) ⦄ → T} ⦃ invOper : InverseOperatorᵣ(_▫_)(_⋄_) ⦄ where\n {-op-cancellationᵣ : ∀{a x y} → (a ⨞ x) → (a ⨞ y) → (a ▫ x ≡ a ▫ y) → (x ≡ y)\n op-cancellationᵣ {a}{x}{y} ax ay axay\n with [∃]-intro r ⦃ pr ⦄ ← [↔]-to-[→] (InverseRelationᵣ.proof invRel) ax\n with [∃]-intro s ⦃ ps ⦄ ← [↔]-to-[→] (InverseRelationᵣ.proof invRel) ay\n =\n x 🝖[ _≡_ ]-[ {!!} ]\n y 🝖-end-}\n\n inverseRelationᵣ-to-invertibleᵣ : ∀{x} → ⦃ x ⨞ id ⦄ → InvertibleElementᵣ(_▫_) ⦃ Monoid.identity-existenceᵣ(monoid) ⦄ (x)\n inverseRelationᵣ-to-invertibleᵣ {x} ⦃ xid ⦄ = [∃]-intro (id ⋄ x) ⦃ intro p ⦄ where\n p =\n (x ▫ (id ⋄ x)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_▫_)(x) (InverseOperatorᵣ.proof invOper {id}{x}) ]\n (x ▫ [∃]-witness([↔]-to-[→] (InverseRelationᵣ.proof invRel) xid)) 🝖[ _≡_ ]-[ [∃]-proof([↔]-to-[→] (InverseRelationᵣ.proof invRel) xid) ]\n id 🝖-end\n\n {- TODO: Should this not be possible without cancellation?\n inverseOperator-self : ∀{x} → let instance _ = reflexivity(_⨞_) in (x ⋄ x ≡ id)\n inverseOperator-self {x} = let instance _ = reflexivity(_⨞_) {x} in\n (x ⋄ x) 🝖[ _≡_ ]-[ InverseOperatorᵣ.proof invOper {x}{x} ]\n [∃]-witness([↔]-to-[→] (InverseRelationᵣ.proof invRel) (reflexivity(_⨞_) {x})) 🝖[ _≡_ ]-[]\n ∃.witness(Tuple.right(InverseRelationᵣ.proof invRel) (reflexivity(_⨞_))) 🝖[ _≡_ ]-[ {!!} ]\n id 🝖-end\n -}\n", "meta": {"hexsha": "3d7f7d61026b6666e15eb94fa57f7a988a00d2b9", "size": 3914, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Monoid/Invertible/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/Monoid/Invertible/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/Monoid/Invertible/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": 54.3611111111, "max_line_length": 148, "alphanum_fraction": 0.5738375064, "num_tokens": 1609, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473647220787, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5954413871773001}} {"text": "module Data.Union.Relation.Binary.Subtype where\n\nopen import Data.List using (List)\nopen import Data.List.Relation.Unary.Any using (here; there)\nopen import Data.List.Relation.Binary.Subset.Propositional using (_⊆_)\n\nopen import Data.Union using (Union; here; there; inj)\n\nopen import Function using (_∘_; id)\n\nopen import Relation.Binary.PropositionalEquality using () renaming (refl to refl≡)\n\nopen import Level using (Level; _⊔_)\n\n-- ----------------------------------------------------------------------\n-- Subtyping\n\nprivate\n variable\n a b c d f : Level\n A : Set a\n B : Set b\n C : Set c\n D : Set d\n\n F : A → Set f\n ts ts′ : List A\n\n\ninfix 4 _≼_ _,_⊢_≼_\n\n_≼_ : Set a → Set b → Set (a ⊔ b)\nA ≼ B = A → B\n\n_,_⊢_≼_ : (A : Set a) → (F : A → Set b) → List A → List A → Set (a ⊔ b)\nA , F ⊢ ts ≼ ts′ = Union A F ts ≼ Union A F ts′\n\nrefl : A ≼ A\nrefl = id\n\ntrans : A ≼ B → B ≼ C → A ≼ C\ntrans A≼B B≼C = B≼C ∘ A≼B\n\ngeneralize : ts ⊆ ts′ → A , F ⊢ ts ≼ ts′\ngeneralize ts⊆ts′ (here x) = inj (ts⊆ts′ (here refl≡)) x\ngeneralize ts⊆ts′ (there x) = generalize (ts⊆ts′ ∘ there) x\n\nfunction : C ≼ A → B ≼ D → (A → B) ≼ (C → D) \nfunction C≼A B≼D f = B≼D ∘ f ∘ C≼A\n\ncoerce : A ≼ B → A → B\ncoerce = id", "meta": {"hexsha": "62c22ad3afd8149d4378a494e86fc50d69007c20", "size": 1207, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Union/Relation/Binary/Subtype.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/Relation/Binary/Subtype.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/Relation/Binary/Subtype.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": 23.2115384615, "max_line_length": 83, "alphanum_fraction": 0.5584092792, "num_tokens": 469, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637469145054, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.5954391915834752}} {"text": "{-# OPTIONS --cubical --guardedness --safe #-}\n\nmodule Data.PolyP.Universe where\n\nopen import Prelude hiding (_⟨_⟩_)\nopen import Data.Vec.Iterated\nopen import Data.Fin.Indexed\n\n--------------------------------------------------------------------------------\n--\n-- The Universe of functors we're interested in.\n--\n--------------------------------------------------------------------------------\ndata Functor (n : ℕ) : Type where\n ! : Fin n → Functor n\n _⊕_ : (F G : Functor n) → Functor n\n _⊗_ : (F G : Functor n) → Functor n\n μ⟨_⟩ : Functor (suc n) → Functor n\n ⓪ : Functor n\n ① : Functor n\n\ninfixl 6 _⊕_\ninfixl 7 _⊗_\n\nParams : ℕ → Type₁\nParams = Vec Type\n\nvariable\n n m k : ℕ\n F G : Functor n\n As Bs : Params n\n\n---------------------------------------------------------------------------------\n--\n-- Interpretation\n--\n---------------------------------------------------------------------------------\n\nmutual\n ⟦_⟧ : Functor n → Params n → Type\n ⟦ ! i ⟧ xs = xs [ i ]\n ⟦ F ⊕ G ⟧ xs = ⟦ F ⟧ xs ⊎ ⟦ G ⟧ xs\n ⟦ F ⊗ G ⟧ xs = ⟦ F ⟧ xs × ⟦ G ⟧ xs\n ⟦ μ⟨ F ⟩ ⟧ xs = μ F xs\n ⟦ ⓪ ⟧ xs = ⊥\n ⟦ ① ⟧ xs = ⊤\n\n record μ (F : Functor (suc n)) (As : Params n) : Type where\n pattern; inductive; constructor ⟨_⟩\n field unwrap : ⟦ F ⟧ (μ F As ∷ As)\nopen μ public\n", "meta": {"hexsha": "8917daa12417924921f58144a0d67d9ce5db7656", "size": 1304, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/PolyP/Universe.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/PolyP/Universe.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/PolyP/Universe.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": 25.0769230769, "max_line_length": 81, "alphanum_fraction": 0.4079754601, "num_tokens": 416, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894745194281, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.5954023642007408}} {"text": "module lib.libraryDec where\n\n-- old version of Dec\n--\n\nopen import Data.Empty\nopen import Level\nopen import Relation.Nullary using ( ¬_ )\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": "32db726b76e219bc6eee6f54c25da6ce276a5eec", "size": 233, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/lib/libraryDec.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": "src/lib/libraryDec.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": "src/lib/libraryDec.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": 17.9230769231, "max_line_length": 41, "alphanum_fraction": 0.6137339056, "num_tokens": 77, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8947894576856559, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.5954023589364507}} {"text": "\nmodule Prelude.Equality.Inspect where\n\nopen import Prelude.Function using (id)\nopen import Prelude.Equality\nopen import Prelude.Product\n\nmodule _ {a b} {A : Set a} {B : A → Set b} (f : ∀ x → B x) (x : A) where\n\n -- The Graph idiom is more powerful than the old Inspect idiom\n -- (defined in terms of Graph below), in that it lets you both\n -- abstract over a term and keep the equation that the old term\n -- equals the abstracted variable.\n\n -- Use as follows:\n -- example : Γ → T (f e)\n -- example xs with f e | graphAt f e\n -- ... | z | ingraph eq = ? -- eq : f e ≡ z, goal : T z\n\n data Graph (y : B x) : Set b where\n ingraph : f x ≡ y → Graph y\n\n graphAt : Graph (f x)\n graphAt = ingraph refl\n {-# INLINE graphAt #-}\n\nmodule _ {a} {A : Set a} where\n\n Inspect : A → Set a\n Inspect x = Σ _ λ y → Graph id x y\n\n infix 4 _with≡_\n pattern _with≡_ x eq = x , ingraph eq\n\n inspect : ∀ x → Inspect x\n inspect x = x , ingraph refl\n {-# INLINE inspect #-}\n", "meta": {"hexsha": "563d36b35685ebbcc59c8064b791d3b66a0ef3fd", "size": 979, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Equality/Inspect.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/Equality/Inspect.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/Equality/Inspect.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.7631578947, "max_line_length": 72, "alphanum_fraction": 0.6159346272, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339556397749, "lm_q2_score": 0.709019146082187, "lm_q1q2_score": 0.5953874521639303}} {"text": "module Numeral.FixedPositional where\n\nimport Lvl\nopen import Data using (<>)\nopen import Data.List\nopen import Data.Boolean hiding (elim)\nopen import Data.Boolean.Stmt\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Functional\nopen import Syntax.Number\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable z : Bool\nprivate variable b n : ℕ\n\n-- A formalization of the fixed positional radix numeral system for the notation of numbers.\n-- Each number is represented by a list of digits.\n-- Digits are a finite set of ordered objects starting with zero (0), and a finite number of its successors.\n-- Examples using radix 10 (b = 10):\n-- ∅ represents 0\n-- # 0 represents 0\n-- # 0 · 0 represents 0\n-- # 2 represents 2\n-- # 1 · 3 represents 13\n-- # 5 · 0 · 4 · 0 · 0 represents 50400\n-- # 0 · 5 · 0 · 4 · 0 · 0 represents 50400\n-- # 0 · 0 · 0 · 5 · 0 · 4 · 0 · 0 represents 50400\n-- # 5 · 0 · 4 · 0 · 0 · 0 represents 504000\n-- Example using radix 2 (b = 2):\n-- # 1 · 1 represents 3\n-- # 0 · 1 · 0 · 1 · 1 represents 11\n-- Note: The radix is also called base.\n-- Note: This representation is in little endian: The deepest digit in the list is the most significant digit (greatest), and the first position of the list is the least significant digit. Note that the (_·_) operator is a reversed list cons operator, so it constructs a list from right to left when written without parenthesis.\nPositional = List ∘ 𝕟\npattern # n = n ⊰ ∅\npattern _·_ a b = b ⊰ a\ninfixl 100 _·_\n\nprivate variable x y : Positional(b)\nprivate variable d : 𝕟(n)\n\n-- Two positionals are equal when the sequence of digits in the lists are the same.\n-- But also, when there are zeroes at the most significant positions, they should be skipped.\n-- Examples:\n-- # 4 · 5 ≡ₚₒₛ # 4 · 5\n-- # 0 · 0 · 4 · 5 ≡ₚₒₛ # 4 · 5\n-- # 4 · 5 ≡ₚₒₛ # 0 · 0 · 4 · 5\n-- # 0 · 0 · 4 · 5 ≡ₚₒₛ # 0 · 4 · 5\ndata _≡ₚₒₛ_ : Positional b → Positional b → Type{Lvl.𝟎} where\n empty : (_≡ₚₒₛ_ {b} ∅ ∅)\n skipₗ : (x ≡ₚₒₛ ∅) → (x · 𝟎 ≡ₚₒₛ ∅)\n skipᵣ : (∅ ≡ₚₒₛ y) → (∅ ≡ₚₒₛ y · 𝟎)\n step : (x ≡ₚₒₛ y) → (x · d ≡ₚₒₛ y · d)\n\nmodule _ where\n open import Numeral.Natural.Oper\n\n -- Converts a positional to a number by adding the first digit and multiplying the rest with the radix.\n -- Examples in radix 10 (b = 10):\n -- to-ℕ (# 1 · 2 · 3) = 10 ⋅ (10 ⋅ (10 ⋅ 0 + 1) + 2) + 3 = ((0 + 100) + 20) + 3 = 100 + 20 + 3 = 123\n -- to-ℕ (# a · b · c) = 10 ⋅ (10 ⋅ (10 ⋅ 0 + a) + b) + c = (10² ⋅ a) + (10¹ ⋅ b) + c = (10² ⋅ a) + (10¹ ⋅ b) + (10⁰ ⋅ c)\n to-ℕ : Positional b → ℕ\n to-ℕ ∅ = 𝟎\n to-ℕ {b} (l · n) = (b ⋅ (to-ℕ l)) + (𝕟-to-ℕ n)\n\n import Data.List.Functions as List\n open import Logic.Propositional\n open import Numeral.Finite.Proofs\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 import Structure.Relator.Names as Names\n open import Structure.Relator.Equivalence\n open import Structure.Relator.Properties\n open import Syntax.Transitivity\n open import Type.Properties.Decidable\n open import Type.Properties.Decidable.Proofs\n\n -- Converts a number to its positional representation in the specified radix.\n -- This is done by extracting the next digit using modulo of the radix and then dividing the rest.\n -- This is the inverse of to-ℕ.\n from-ℕ-rec : ⦃ b-size : IsTrue(b >? 1) ⦄ → (x : ℕ) → ((prev : ℕ) ⦃ _ : prev < x ⦄ → Positional(b)) → Positional(b)\n from-ℕ-rec b@{𝐒(𝐒 _)} 𝟎 _ = ∅\n from-ℕ-rec b@{𝐒(𝐒 _)} n@(𝐒 _) prev = (prev(n ⌊/⌋ b) ⦃ [⌊/⌋]-ltₗ {n}{b} ⦄) · (ℕ-to-𝕟 (n mod b) ⦃ [↔]-to-[→] decider-true (mod-maxᵣ{n}{b}) ⦄)\n from-ℕ : ℕ → Positional(b)\n from-ℕ {0} = const ∅\n from-ℕ {1} = List.repeat 𝟎\n from-ℕ b@{𝐒(𝐒 _)} = Strict.Properties.wellfounded-recursion(_<_) from-ℕ-rec\n\n instance\n [≡ₚₒₛ]-reflexivity : Reflexivity(_≡ₚₒₛ_ {b})\n [≡ₚₒₛ]-reflexivity = intro p where\n p : Names.Reflexivity(_≡ₚₒₛ_ {b})\n p {x = ∅} = empty\n p {x = _ ⊰ _} = _≡ₚₒₛ_.step p\n\n instance\n [≡ₚₒₛ]-symmetry : Symmetry(_≡ₚₒₛ_ {b})\n [≡ₚₒₛ]-symmetry = intro p where\n p : Names.Symmetry(_≡ₚₒₛ_ {b})\n p empty = empty\n p (skipₗ eq) = skipᵣ (p eq)\n p (skipᵣ eq) = skipₗ (p eq)\n p (_≡ₚₒₛ_.step eq) = _≡ₚₒₛ_.step (p eq)\n\n instance\n [≡ₚₒₛ]-transitivity : Transitivity(_≡ₚₒₛ_ {b})\n [≡ₚₒₛ]-transitivity = intro p where\n p : Names.Transitivity(_≡ₚₒₛ_ {b})\n p empty empty = empty\n p empty (skipᵣ b) = skipᵣ b\n p (skipₗ a) empty = skipₗ a\n p (skipₗ a) (skipᵣ b) = _≡ₚₒₛ_.step (p a b)\n p (skipᵣ a) (skipₗ b) = p a b\n p (skipᵣ a) (_≡ₚₒₛ_.step b) = skipᵣ (p a b)\n p (_≡ₚₒₛ_.step a) (skipₗ b) = skipₗ (p a b)\n p (_≡ₚₒₛ_.step a) (_≡ₚₒₛ_.step b) = _≡ₚₒₛ_.step (p a b)\n\n instance\n [≡ₚₒₛ]-equivalence : Equivalence(_≡ₚₒₛ_ {b})\n [≡ₚₒₛ]-equivalence = intro\n\n open import Structure.Setoid using (Equiv ; intro)\n\n Positional-equiv : Equiv(Positional(b))\n Positional-equiv {b} = intro _ ⦃ [≡ₚₒₛ]-equivalence {b} ⦄\n\n open import Lang.Instance\n open import Numeral.Natural.Relation.Proofs\n open import Structure.Function\n open import Structure.Operator\n open import Relator.Equals\n open import Relator.Equals.Proofs\n\n from-ℕ-digit : ⦃ b-size : IsTrue(b >? 1) ⦄ → ⦃ _ : IsTrue(n ? 1) ⦄\n → let pos = [↔]-to-[←] Positive-greater-than-zero ([≤]-predecessor ([↔]-to-[←] (decider-true ⦃ [<]-decider {1}{b} ⦄) b-size))\n in (from-ℕ {b} n ≡ₚₒₛ (from-ℕ {b} ((n ⌊/⌋ b) ⦃ pos ⦄)) · (ℕ-to-𝕟 ((n mod b) ⦃ pos ⦄) ⦃ [↔]-to-[→] decider-true (mod-maxᵣ{n}{b} ⦃ pos ⦄) ⦄))\n from-ℕ-step b@{𝐒(𝐒 bb)} {n} = Strict.Properties.wellfounded-recursion-intro(_<_) {rec = from-ℕ-rec} {φ = \\{n} expr → (expr ≡ₚₒₛ from-ℕ {b} (n ⌊/⌋ b) · (ℕ-to-𝕟 (n mod b) ⦃ ord n ⦄))} p {n} where\n ord = \\n → [↔]-to-[→] decider-true (mod-maxᵣ{n}{b})\n p : (y : ℕ) → _ → _ → Strict.Properties.accessible-recursion(_<_) from-ℕ-rec y ≡ₚₒₛ from-ℕ (y ⌊/⌋ b) · ℕ-to-𝕟 (y mod b) ⦃ ord y ⦄\n p 𝟎 prev eq = skipᵣ empty\n p (𝐒 y) prev eq = (sub₂(_≡_)(_≡ₚₒₛ_) (eq {y} ⦃ reflexivity(_≤_) ⦄))\n\n open import Numeral.Natural.Oper.FlooredDivision.Proofs.Inverse\n open import Numeral.Natural.Oper.Proofs\n open import Structure.Operator.Properties\n from-ℕ-step-invs : ⦃ b-size : IsTrue(b >? 1) ⦄ → (from-ℕ {b} ((b ⋅ n) + (𝕟-to-ℕ d)) ≡ₚₒₛ (from-ℕ {b} n) · d)\n from-ℕ-step-invs b@{𝐒(𝐒 bb)} {n}{d} =\n from-ℕ (b ⋅ n + 𝕟-to-ℕ d) 🝖[ _≡ₚₒₛ_ ]-[ from-ℕ-step {n = b ⋅ n + 𝕟-to-ℕ d} ]\n from-ℕ ((b ⋅ n + 𝕟-to-ℕ d) ⌊/⌋ b) · (ℕ-to-𝕟 ((b ⋅ n + 𝕟-to-ℕ d) mod b) ⦃ _ ⦄) 🝖[ _≡ₚₒₛ_ ]-[ sub₂(_≡_)(_≡ₚₒₛ_) (congruence₂(_·_) (congruence₁(from-ℕ) r) (congruence-ℕ-to-𝕟 ⦃ infer ⦄ ⦃ ord1 ⦄ ⦃ ord2 ⦄ q 🝖 ℕ-𝕟-inverse)) ]\n from-ℕ n · d 🝖-end where\n ord1 = [↔]-to-[→] decider-true (mod-maxᵣ{(b ⋅ n) + (𝕟-to-ℕ d)}{b})\n ord2 = [↔]-to-[→] decider-true ([<]-of-𝕟-to-ℕ {b}{d})\n q =\n ((b ⋅ n) + 𝕟-to-ℕ d) mod b 🝖[ _≡_ ]-[ congruence₁(_mod b) (commutativity(_+_) {b ⋅ n}{𝕟-to-ℕ d}) ]\n (𝕟-to-ℕ d + (b ⋅ n)) mod b 🝖[ _≡_ ]-[ mod-of-modulus-sum-multiple {𝕟-to-ℕ d}{b}{n} ]\n (𝕟-to-ℕ d) mod b 🝖[ _≡_ ]-[ mod-lesser-than-modulus ⦃ [≤]-without-[𝐒] [<]-of-𝕟-to-ℕ ⦄ ]\n 𝕟-to-ℕ d 🝖-end\n r =\n (b ⋅ n + 𝕟-to-ℕ d) ⌊/⌋ b 🝖[ _≡_ ]-[ [⌊/⌋][+]-distributivityᵣ {b ⋅ n}{𝕟-to-ℕ d}{b} ]\n ((b ⋅ n) ⌊/⌋ b) + ((𝕟-to-ℕ d) ⌊/⌋ b) 🝖[ _≡_ ]-[ congruence₂(_+_) ([⌊/⌋][swap⋅]-inverseOperatorᵣ {b}{n}) ([⌊/⌋]-zero ([<]-of-𝕟-to-ℕ {b}{d})) ]\n n + 𝟎 🝖[ _≡_ ]-[]\n n 🝖-end\n\n open import Numeral.Natural.Oper.DivMod.Proofs\n open import Structure.Function.Domain\n import Structure.Function.Names as Names\n\n instance\n from-to-inverse : ⦃ b-size : IsTrue(b >? 1) ⦄ → Inverseᵣ ⦃ Positional-equiv{b} ⦄ from-ℕ to-ℕ\n from-to-inverse b@{𝐒(𝐒 _)} = intro p where\n p : Names.Inverses ⦃ Positional-equiv{b} ⦄ from-ℕ to-ℕ\n p{x = ∅} = empty\n p{x = x · n} = from-ℕ-step-invs{b}{to-ℕ x}{n} 🝖 _≡ₚₒₛ_.step (p{x = x})\n\n instance\n to-from-inverse : ⦃ b-size : IsTrue(b >? 1) ⦄ → Inverseᵣ(to-ℕ{b}) (from-ℕ{b})\n to-from-inverse {b@(𝐒(𝐒 bb))} = intro (\\{n} → Strict.Properties.wellfounded-recursion-intro(_<_) {rec = from-ℕ-rec {b}} {φ = \\{n} expr → (to-ℕ expr ≡ n)} p {n}) where\n p : (y : ℕ) → _ → _ → (to-ℕ {b} (from-ℕ {b} y) ≡ y)\n p 𝟎 _ _ = [≡]-intro\n p (𝐒 y) prev eq =\n to-ℕ {b} (from-ℕ (𝐒 y)) 🝖[ _≡_ ]-[ congruence₁(to-ℕ) (eq {𝐒(y) ⌊/⌋ b} ⦃ ord2 ⦄) ]\n to-ℕ {b} ((from-ℕ (𝐒(y) ⌊/⌋ b)) · (ℕ-to-𝕟 (𝐒(y) mod b) ⦃ _ ⦄)) 🝖[ _≡_ ]-[]\n (b ⋅ to-ℕ {b} (from-ℕ {b} (𝐒(y) ⌊/⌋ b))) + 𝕟-to-ℕ (ℕ-to-𝕟 (𝐒(y) mod b) ⦃ _ ⦄) 🝖[ _≡_ ]-[ congruence₂(_+_) (congruence₂ᵣ(_⋅_)(b) (prev{𝐒(y) ⌊/⌋ b} ⦃ ord2 ⦄)) (𝕟-ℕ-inverse {b}{𝐒(y) mod b} ⦃ ord1 ⦄) ]\n (b ⋅ (𝐒(y) ⌊/⌋ b)) + (𝐒(y) mod b) 🝖[ _≡_ ]-[ [⌊/⌋][mod]-is-division-with-remainder-pred-commuted {𝐒 y}{b} ]\n 𝐒(y) 🝖-end\n where\n ord1 = [↔]-to-[→] decider-true (mod-maxᵣ{𝐒(y)}{b})\n ord2 = [⌊/⌋]-ltₗ {𝐒 y}{b}\n\n instance\n to-ℕ-function : ⦃ b-size : IsTrue(b >? 1) ⦄ → Function ⦃ Positional-equiv ⦄ ⦃ [≡]-equiv ⦄ (to-ℕ {b})\n to-ℕ-function {b} = intro p where\n p : Names.Congruence₁ ⦃ Positional-equiv ⦄ ⦃ [≡]-equiv ⦄ (to-ℕ {b})\n p empty = reflexivity(_≡_)\n p (skipₗ xy) rewrite p xy = reflexivity(_≡_)\n p (skipᵣ {y = ∅} xy) = reflexivity(_≡_)\n p (skipᵣ {y = 𝟎 ⊰ y} (skipᵣ xy))\n rewrite symmetry(_≡_) (p xy) = reflexivity(_≡_)\n p (_≡ₚₒₛ_.step xy)\n rewrite p xy = reflexivity(_≡_)\n\n open import Logic.Predicate\n open import Structure.Function.Domain.Proofs\n\n instance\n from-ℕ-bijective : ⦃ b-size : IsTrue(b >? 1) ⦄ → Bijective ⦃ [≡]-equiv ⦄ ⦃ Positional-equiv ⦄ (from-ℕ {b})\n from-ℕ-bijective = [↔]-to-[→] (invertible-when-bijective ⦃ _ ⦄ ⦃ _ ⦄) ([∃]-intro to-ℕ ⦃ [∧]-intro infer ([∧]-intro infer infer) ⦄)\n\n instance\n to-ℕ-bijective : ⦃ b-size : IsTrue(b >? 1) ⦄ → Bijective ⦃ Positional-equiv ⦄ ⦃ [≡]-equiv ⦄ (to-ℕ {b})\n to-ℕ-bijective = [↔]-to-[→] (invertible-when-bijective ⦃ _ ⦄ ⦃ _ ⦄) ([∃]-intro from-ℕ ⦃ [∧]-intro ([≡]-to-function ⦃ Positional-equiv ⦄) ([∧]-intro infer infer) ⦄)\n\n import Data.Option.Functions as Option\n open import Function.Names\n open import Numeral.Natural.Relation.Order.Proofs\n\n -- TODO: Trying to define a bijection, but not really possible because not all functions\n PositionalSequence : List(𝕟(𝐒 b)) → (ℕ → 𝕟(𝐒 b))\n PositionalSequence l n = (List.index₀ n l) Option.or 𝟎\n\n sequencePositional : (f : ℕ → 𝕟(𝐒 b)) → ∃(N ↦ (f ∘ (_+ N) ⊜ const 𝟎)) → List(𝕟(𝐒 b))\n sequencePositional f ([∃]-intro 𝟎) = ∅\n sequencePositional f ([∃]-intro (𝐒 N) ⦃ p ⦄) = f(𝟎) ⊰ sequencePositional (f ∘ 𝐒) ([∃]-intro N ⦃ \\{n} → p{n} ⦄)\n", "meta": {"hexsha": "02772f709c2b06e4a2c9fc2699357d125d45cbb4", "size": 13415, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "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": "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": "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": 53.4462151394, "max_line_length": 328, "alphanum_fraction": 0.5257547521, "num_tokens": 6165, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505966, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5953874498445361}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Functor.Algebras where\n\nopen import Level hiding (lift)\n\nopen import Categories.Category\nopen import Categories.Functor hiding (_≡_; id; _∘_; equiv; assoc; identityˡ; identityʳ; ∘-resp-≡)\nopen import Categories.Functor.Algebra\n\nrecord F-Algebra-Morphism {o ℓ e} {C : Category o ℓ e} {F : Endofunctor C} (X Y : F-Algebra F) : Set (ℓ ⊔ e) where\n constructor _,_\n open Category C\n module X = F-Algebra X\n module Y = F-Algebra Y\n open Functor F\n field\n f : X.A ⇒ Y.A\n .commutes : f ∘ X.α ≡ Y.α ∘ F₁ f\n\nF-Algebras : ∀ {o ℓ e} {C : Category o ℓ e} → Endofunctor C → Category (ℓ ⊔ o) (e ⊔ ℓ) e\nF-Algebras {C = C} F = record \n { Obj = Obj′\n ; _⇒_ = Hom′\n ; _≡_ = _≡′_\n ; _∘_ = _∘′_\n ; id = id′\n ; assoc = assoc\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 C\n open Equiv\n open Functor F\n\n Obj′ = F-Algebra F\n\n Hom′ : (A B : Obj′) → Set _\n Hom′ = F-Algebra-Morphism\n\n _≡′_ : ∀ {A B} (f g : Hom′ A B) → Set _\n (f , _) ≡′ (g , _) = f ≡ g\n\n _∘′_ : ∀ {A B C} → Hom′ B C → Hom′ A B → Hom′ A C\n _∘′_ {A} {B} {C} (f , pf₁) (g , pf₂) = _,_ {X = A} {C} (f ∘ g) pf -- TODO: find out why the hell I need to provide these implicits\n where\n module A = F-Algebra A\n module B = F-Algebra B\n module C = F-Algebra C\n\n .pf : (f ∘ g) ∘ A.α ≡ C.α ∘ (F₁ (f ∘ g))\n pf = begin\n (f ∘ g) ∘ A.α\n ↓⟨ assoc ⟩\n f ∘ (g ∘ A.α)\n ↓⟨ ∘-resp-≡ʳ pf₂ ⟩\n f ∘ (B.α ∘ F₁ g)\n ↑⟨ assoc ⟩\n (f ∘ B.α) ∘ F₁ g\n ↓⟨ ∘-resp-≡ˡ pf₁ ⟩\n (C.α ∘ F₁ f) ∘ F₁ g\n ↓⟨ assoc ⟩\n C.α ∘ (F₁ f ∘ F₁ g)\n ↑⟨ ∘-resp-≡ʳ homomorphism ⟩\n C.α ∘ (F₁ (f ∘ g))\n ∎\n where\n open HomReasoning\n\n id′ : ∀ {A} → Hom′ A A\n id′ {A} = _,_ {X = A} {A} id pf\n where\n module A = F-Algebra A\n\n .pf : id ∘ A.α ≡ A.α ∘ F₁ id\n pf = begin\n id ∘ A.α\n ↓⟨ identityˡ ⟩\n A.α\n ↑⟨ identityʳ ⟩\n A.α ∘ id\n ↑⟨ ∘-resp-≡ʳ identity ⟩\n A.α ∘ F₁ id\n ∎\n where\n open HomReasoning\n\n\nopen import Categories.Object.Initial\n\nmodule Lambek {o ℓ e} {C : Category o ℓ e} {F : Endofunctor C} (I : Initial (F-Algebras F)) where\n open Category C\n open Equiv\n module FA = Category (F-Algebras F) renaming (_∘_ to _∘FA_; _≡_ to _≡FA_)\n open Functor F\n import Categories.Morphisms as Morphisms\n open Morphisms C\n open Initial I\n open F-Algebra ⊥\n\n lambek : A ≅ F₀ A\n lambek = record \n { f = f′\n ; g = g′\n ; iso = iso′\n }\n where\n f′ : A ⇒ F₀ A\n f′ = F-Algebra-Morphism.f (! {lift ⊥}) \n\n g′ : F₀ A ⇒ A\n g′ = α\n\n .iso′ : Iso f′ g′\n iso′ = record \n { isoˡ = isoˡ′\n ; isoʳ = begin\n f′ ∘ g′\n ↓⟨ F-Algebra-Morphism.commutes (! {lift ⊥}) ⟩\n F₁ g′ ∘ F₁ f′\n ↑⟨ homomorphism ⟩\n F₁ (g′ ∘ f′)\n ↓⟨ F-resp-≡ isoˡ′ ⟩\n F₁ id\n ↓⟨ identity ⟩\n id\n ∎\n }\n where\n open FA hiding (id; module HomReasoning)\n open HomReasoning\n\n isoˡ′ = ⊥-id ((_,_ {C = C} {F} g′ refl) ∘FA !)\n\nopen Lambek public\n", "meta": {"hexsha": "ebc0d4d18abc7377c68a7f368b3fc1f41617d478", "size": 3340, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Functor/Algebras.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/Algebras.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/Algebras.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.5211267606, "max_line_length": 132, "alphanum_fraction": 0.4769461078, "num_tokens": 1369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.5953327254415763}} {"text": "-- Andreas, 2015-06-17\n-- Postponing checkArguments dropped already inserted implicit arguments.\n\n{-# OPTIONS --show-implicit #-}\n-- {-# OPTIONS -v tc.def.alias:100 -v tc.decl:10 -v tc.term.expr:20 -v tc.data.con:20 #-}\n-- {-# OPTIONS -v tc.meta.assign:10 #-}\n-- {-# OPTIONS -v tc.term.expr.args:80 #-}\n-- {-# OPTIONS -v tc.term.args:30 #-}\n\npostulate\n S : Set\n Cxt : Set\n N : (Γ : Cxt) → Set\n\n NeP : ∀ (i : S) Δ (n : N Δ) → Set\n inhN : ∀ i Δ (v : N Δ) → NeP i Δ v\n\ndata Val (Δ : Cxt) : Set where\n ne : ∀ (n : N Δ) → Val Δ\n\n-- BEGIN mutual\n\ndata ValP i Δ : (v : Val Δ) → Set\nNeO : _\n\ndata ValP i Δ where\n cn : ∀ (n : N Δ) → NeO n i → ValP i Δ (ne n)\n-- adding constructor cn : (n : N Δ) → _24 i Δ n → ValP i Δ (ne n)\n-- LATER : term _24 i Δ n := NeO n i\n-- SHOULD BE: term _24 i Δ n := NeO {Δ} i n\n\n-- must be last in mutual block for error\n-- implicit argument needed for error\n-- NeO_[_] : ∀ {Δ} (n : N Δ) (i : S) → Set -- full type signature removes error\nNeO = λ {Δ} n i → NeP i Δ n\n\n-- END mutual\n\ninhVal : ∀ i Δ (v : Val Δ) → ValP i Δ v\ninhVal i Δ (ne n) = cn n (inhN i Δ n)\n\n-- Checking inhN i Δ n : NeO n [ i ] --> λ i₁ → NeP i₁ n i\n\n-- ANALYSIS:\n-- checked type signature NeO : _20\n-- checking constructor cn : (n : N Δ) → NeO n i → ValP i Δ (ne n)\n-- adding constructor cn : (n : N Δ) → _24 i Δ n → ValP i Δ (ne n)\n-- postponed checking arguments [n, i] against _20\n-- progress: checked [] remaining [n, i] : _20\n-- term _20 :>= {Δ : _27} → _29 {Δ}\n-- term _20 :>= {Δ : _27} → _29 {Δ}\n-- solving _20 := {Δ : _27} → _29 {Δ}\n-- postponed checking arguments [n, i] against _29 {_Δ_30 i Δ n}\n-- progress: checked [] remaining [n, i] : _29 {_Δ_30 i Δ n}\n-- Checking λ n i → NeP i Δ n : _29 {Δ}\n-- solving _29 := λ {Δ} → (n : N Δ) (i : S) → Set\n-- solving _24 := (λ i Δ n → NeO n i)\n", "meta": {"hexsha": "6111fa0d0e7ed9edc02eeb7f88ede2cf8c2035a9", "size": 1805, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1545.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/Issue1545.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/Issue1545.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.1206896552, "max_line_length": 89, "alphanum_fraction": 0.5606648199, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744717487329, "lm_q2_score": 0.727975460709318, "lm_q1q2_score": 0.595174152735461}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Adjoint.Alternatives 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.NaturalTransformation\n\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e : Level\n C D : Category o ℓ e\n\n module _ (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 record FromUnit : Set (levelOfTerm L ⊔ levelOfTerm R) where\n \n field\n unit : NaturalTransformation idF (R ∘F L)\n \n module unit = NaturalTransformation unit\n \n field\n θ : ∀ {X Y} → C [ X , R.₀ Y ] → D [ L.₀ X , Y ]\n commute : ∀ {X Y} (g : C [ X , R.₀ Y ]) → g C.≈ R.₁ (θ g) C.∘ unit.η X\n unique : ∀ {X Y} {f : D [ L.₀ X , Y ]} {g : C [ X , R.₀ Y ]} →\n g C.≈ R.₁ f C.∘ unit.η X → θ g D.≈ f\n \n module _ where\n open C.HomReasoning\n open MR C\n \n θ-natural : ∀ {X Y Z} (f : D [ Y , Z ]) (g : C [ X , R.₀ Y ]) → θ (R.₁ f C.∘ g) D.≈ θ (R.₁ f) D.∘ L.₁ g\n θ-natural {X} {Y} f g = unique eq\n where eq : R.₁ f C.∘ g C.≈ R.₁ (θ (R.₁ f) D.∘ L.₁ g) C.∘ unit.η X\n eq = begin\n R.₁ f C.∘ g ≈⟨ commute (R.₁ f) ⟩∘⟨refl ⟩\n (R.₁ (θ (R.₁ f)) C.∘ unit.η (R.F₀ Y)) C.∘ g ≈⟨ C.assoc ⟩\n R.₁ (θ (R.₁ f)) C.∘ unit.η (R.₀ Y) C.∘ g ≈⟨ pushʳ (unit.commute g) ⟩\n (R.₁ (θ (R.₁ f)) C.∘ R.₁ (L.₁ g)) C.∘ unit.η X ≈˘⟨ R.homomorphism ⟩∘⟨refl ⟩\n R.₁ (θ (R.₁ f) D.∘ L.₁ g) C.∘ unit.η X ∎\n \n θ-cong : ∀ {X Y} {f g : C [ X , R.₀ Y ]} → f C.≈ g → θ f D.≈ θ g\n θ-cong eq = unique (eq ○ commute _)\n \n θ-natural′ : ∀ {X Y} (g : C [ X , R.₀ Y ]) → θ g D.≈ θ C.id D.∘ L.₁ g\n θ-natural′ g = θ-cong (introˡ R.identity) ○ θ-natural D.id g ○ D.∘-resp-≈ˡ (θ-cong R.identity)\n where open D.HomReasoning\n open MR C\n \n counit : NaturalTransformation (L ∘F R) idF\n counit = ntHelper record\n { η = λ d → θ C.id\n ; commute = λ f → begin\n θ C.id D.∘ L.₁ (R.₁ f) ≈˘⟨ θ-natural′ (R.₁ f) ⟩\n θ (R.₁ f) ≈⟨ unique (CH.⟺ (MR.cancelʳ C (CH.⟺ (commute C.id))) CH.○ CH.⟺ (C.∘-resp-≈ˡ R.homomorphism)) ⟩\n f D.∘ θ C.id ∎\n }\n where open D.HomReasoning\n module CH = C.HomReasoning\n \n unique′ : ∀ {X Y} {f g : D [ L.₀ X , Y ]} (h : C [ X , R.₀ Y ]) →\n h C.≈ R.₁ f C.∘ unit.η X →\n h C.≈ R.₁ g C.∘ unit.η X → f D.≈ g\n unique′ _ eq₁ eq₂ = ⟺ (unique eq₁) ○ unique eq₂\n where open D.HomReasoning\n \n zig : ∀ {A} → θ C.id D.∘ L.F₁ (unit.η A) D.≈ D.id\n zig {A} = unique′ (unit.η A)\n (commute (unit.η A) ○ (C.∘-resp-≈ˡ (R.F-resp-≈ (θ-natural′ (unit.η A)))))\n (introˡ R.identity)\n where open C.HomReasoning\n open MR C\n\n L⊣R : L ⊣ R\n L⊣R = record\n { unit = unit\n ; counit = counit\n ; zig = zig\n ; zag = C.Equiv.sym (commute C.id)\n }\n\n record FromCounit : Set (levelOfTerm L ⊔ levelOfTerm R) where\n \n field\n counit : NaturalTransformation (L ∘F R) idF\n \n module counit = NaturalTransformation counit\n \n field\n θ : ∀ {X Y} → D [ L.₀ X , Y ] → C [ X , R.₀ Y ]\n commute : ∀ {X Y} (g : D [ L.₀ X , Y ]) → g D.≈ counit.η Y D.∘ L.₁ (θ g)\n unique : ∀ {X Y} {f : C [ X , R.₀ Y ]} {g : D [ L.₀ X , Y ]} →\n g D.≈ counit.η Y D.∘ L.₁ f → θ g C.≈ f\n\n module _ where\n open D.HomReasoning\n open MR D\n \n θ-natural : ∀ {X Y Z} (f : C [ X , Y ]) (g : D [ L.₀ Y , Z ]) → θ (g D.∘ L.₁ f) C.≈ R.₁ g C.∘ θ (L.₁ f)\n θ-natural {X} {Y} {Z} f g = unique eq\n where eq : g D.∘ L.₁ f D.≈ counit.η Z D.∘ L.₁ (R.₁ g C.∘ θ (L.₁ f))\n eq = begin\n g D.∘ L.₁ f ≈⟨ pushʳ (commute (L.₁ f)) ⟩\n (g D.∘ counit.η (L.F₀ Y)) D.∘ L.F₁ (θ (L.F₁ f)) ≈⟨ pushˡ (counit.sym-commute g) ⟩\n counit.η Z D.∘ L.₁ (R.₁ g) D.∘ L.₁ (θ (L.₁ f)) ≈˘⟨ refl⟩∘⟨ L.homomorphism ⟩\n counit.η Z D.∘ L.₁ (R.₁ g C.∘ θ (L.₁ f)) ∎\n \n θ-cong : ∀ {X Y} {f g : D [ L.₀ X , Y ]} → f D.≈ g → θ f C.≈ θ g\n θ-cong eq = unique (eq ○ commute _)\n \n θ-natural′ : ∀ {X Y} (g : D [ L.₀ X , Y ]) → θ g C.≈ R.₁ g C.∘ θ D.id\n θ-natural′ g = θ-cong (introʳ L.identity) ○ θ-natural C.id g ○ C.∘-resp-≈ʳ (θ-cong L.identity)\n where open C.HomReasoning\n open MR D\n\n unit : NaturalTransformation idF (R ∘F L)\n unit = ntHelper record\n { η = λ _ → θ D.id\n ; commute = λ f → begin\n θ D.id C.∘ f ≈˘⟨ unique (DH.⟺ (cancelˡ (DH.⟺ (commute D.id))) DH.○ D.∘-resp-≈ʳ (DH.⟺ L.homomorphism)) ⟩\n θ (L.₁ f) ≈⟨ θ-natural′ (L.₁ f) ⟩\n R.₁ (L.₁ f) C.∘ θ D.id ∎\n }\n where open C.HomReasoning\n module DH = D.HomReasoning\n open MR D\n \n unique′ : ∀ {X Y} {f g : C [ X , R.₀ Y ]} (h : D [ L.₀ X , Y ]) →\n h D.≈ counit.η Y D.∘ L.₁ f →\n h D.≈ counit.η Y D.∘ L.₁ g →\n f C.≈ g\n unique′ _ eq₁ eq₂ = ⟺ (unique eq₁) ○ unique eq₂\n where open C.HomReasoning\n \n zag : ∀ {B} → R.F₁ (counit.η B) C.∘ θ D.id C.≈ C.id\n zag {B} = unique′ (counit.η B)\n (⟺ (cancelʳ (⟺ (commute D.id))) ○ pushˡ (counit.sym-commute (counit.η B)) ○ D.∘-resp-≈ʳ (⟺ L.homomorphism))\n (introʳ L.identity)\n where open D.HomReasoning\n open MR D\n\n L⊣R : L ⊣ R\n L⊣R = record\n { unit = unit\n ; counit = counit\n ; zig = D.Equiv.sym (commute D.id)\n ; zag = zag\n }\n\nmodule _ {L : Functor C D} {R : Functor D C} where\n\n fromUnit : FromUnit L R → L ⊣ R\n fromUnit = FromUnit.L⊣R\n \n fromCounit : FromCounit L R → L ⊣ R\n fromCounit = FromCounit.L⊣R\n", "meta": {"hexsha": "4b6336843edd74997942d3a1af4cee2650bdb5c8", "size": 6279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Adjoint/Alternatives.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/Alternatives.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/Alternatives.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.375, "max_line_length": 131, "alphanum_fraction": 0.4376493072, "num_tokens": 2580, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.5951741414960822}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import Base\nopen import Integers\nopen import Homotopy.Truncation\nopen import Spaces.Spheres\nopen import Spaces.Suspension\nopen import Homotopy.Connected\nopen import Homotopy.ConnectedSuspension\nopen import Homotopy.Pointed\nopen import Homotopy.HomotopyGroups\n\nmodule Spaces.PikSn where\n\nabstract\n Sⁿ-S-is-connected : (n : ℕ) → is-connected ⟨ n ⟩ (Sⁿ (S n))\n Sⁿ-S-is-connected n =\n suspension-is-connected-S (Sⁿ n) ind-hyp (proj (⋆Sⁿ n)) where\n ind-hyp : is-connected (n -1) (Sⁿ n)\n ind-hyp with n\n ind-hyp | O = inhab-prop-is-contr (proj true) (τ-is-truncated _ _)\n ind-hyp | S n = Sⁿ-S-is-connected n\n\nSⁿ⋆ : (n : ℕ) → pType₀\nSⁿ⋆ n = ⋆[ Sⁿ n , ⋆Sⁿ n ]\n\nabstract\n πk-Sⁿ-is-contr : (k n : ℕ) (lt : k < n)\n → is-contr⋆ (πⁿ k (Sⁿ⋆ n))\n πk-Sⁿ-is-contr k O ()\n πk-Sⁿ-is-contr k (S n) lt = connected-πⁿ k n lt _ (Sⁿ-S-is-connected n)\n", "meta": {"hexsha": "3eea826b92026d846c1aca87544720b7eca3f4d7", "size": 892, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Spaces/PikSn.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/Spaces/PikSn.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/Spaces/PikSn.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": 27.875, "max_line_length": 73, "alphanum_fraction": 0.6547085202, "num_tokens": 347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213745668094, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.5951490179842901}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\n{-\n Ribbon is an explicit covering space construction.\n\n This construction is given by Daniel Grayson, Favonia\n and Guillaume Brunerie together.\n-}\n\nopen import HoTT\n\n-- A is the pointed base space.\n-- El is intended to be a (group-)set,\nmodule homotopy.RibbonCover {i : ULevel} where\n\n -- The HIT ribbon---reconstructed covering space\n\n module _ (X : Ptd i) {j} (gs : GroupSet (πS 0 X) j) (a₂ : de⊙ X) where\n private\n A = de⊙ X\n a₁ = pt X\n El = GroupSet.El gs\n El-level = GroupSet.El-level gs\n infix 80 _⊙_\n _⊙_ = GroupSet.act gs\n\n RibbonSet : Type (lmax i j)\n RibbonSet = El × (a₁ =₀ a₂)\n\n data RibbonRel : RibbonSet → RibbonSet → Type (lmax i j) where\n ribbon-rel : ∀ el loop (p : a₁ =₀ a₂)\n → RibbonRel (el ⊙ loop , p) (el , loop ∙₀ p)\n\n Ribbon : Type (lmax i j)\n Ribbon = SetQuot RibbonRel\n\n module _ {X : Ptd i} {j} {gs : GroupSet (πS 0 X) j} {a₂ : de⊙ X} where\n private\n A = de⊙ X\n a = pt X\n El = GroupSet.El gs\n El-level = GroupSet.El-level gs\n infix 80 _⊙_\n _⊙_ = GroupSet.act gs\n\n -- A point in the fiber [a₂].\n {-\n [e] is a point in the [fiber a], and\n [p] is a path to transport [y] to fiber [a₂].\n -}\n trace : El → a =₀ a₂ → Ribbon X gs a₂\n trace el p = q[ el , p ]\n\n {-\n A loop based at [a] can used as a group action\n or for concatination. Both should be equivalent.\n -}\n paste : ∀ el loop (p : a =₀ a₂) → trace (el ⊙ loop) p == trace el (loop ∙₀ p)\n paste el loop p = quot-rel (ribbon-rel el loop p)\n\n {-\n Make each fiber a set and cancel all higher structures\n due to [paste].\n -}\n Ribbon-level : is-set (Ribbon X gs a₂)\n Ribbon-level = SetQuot-level\n\n Ribbon-is-set = Ribbon-level\n\n -- Elimination rules.\n module RibbonElim {j} {P : Ribbon X gs a₂ → Type j}\n (P-level : ∀ r → is-set (P r))\n (trace* : ∀ el p → P (trace el p))\n (paste* : ∀ el loop p\n → trace* (el ⊙ loop) p == trace* el (loop ∙₀ p)\n [ P ↓ paste el loop p ]) where\n\n private\n q[_]* : (α : RibbonSet X gs a₂) → P q[ α ]\n q[ el , p ]* = trace* el p\n\n rel* : ∀ {α₁ α₂} (r : RibbonRel X gs a₂ α₁ α₂) → q[ α₁ ]* == q[ α₂ ]* [ P ↓ quot-rel r ]\n rel* (ribbon-rel el loop p) = paste* el loop p\n\n module M = SetQuotElim P-level q[_]* rel*\n\n f : Π (Ribbon X gs a₂) P\n f = M.f\n\n open RibbonElim public using () renaming (f to Ribbon-elim)\n\n module RibbonRec {j} {P : Type j}\n (P-level : is-set P)\n (trace* : ∀ el p → P)\n (paste* : ∀ el loop p\n → trace* (el ⊙ loop) p == trace* el (loop ∙₀ p)) where\n\n private\n module M = RibbonElim (λ _ → P-level) trace*\n (λ el loop p → ↓-cst-in (paste* el loop p))\n\n f : Ribbon X gs a₂ → P\n f = M.f\n\n open RibbonRec public using () renaming (f to Ribbon-rec)\n\n -- This data structure gives a cover.\n Ribbon-cover : ∀ (X : Ptd i) {j} (gs : GroupSet (πS 0 X) j)\n → Cover (de⊙ X) (lmax i j)\n Ribbon-cover X gs = record\n { Fiber = Ribbon X gs\n ; Fiber-level = λ a → Ribbon-level\n }\n\n transp-trace : ∀ {A : Type i} {a₁} {j}\n {gs : GroupSet (πS 0 ⊙[ A , a₁ ]) j}\n {a₂} (q : a₁ == a₂) y p\n → transport (Ribbon ⊙[ A , a₁ ] gs) q (trace y p) == trace y (p ∙₀ [ q ])\n transp-trace idp y p = ap (trace y) $ ! $ ∙₀-unit-r p\n", "meta": {"hexsha": "fde4d608d512dd5a528403d560428d57bc6b628b", "size": 3431, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/RibbonCover.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/RibbonCover.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/RibbonCover.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": 28.5916666667, "max_line_length": 96, "alphanum_fraction": 0.5371611775, "num_tokens": 1186, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.5951406855756316}} {"text": "\n\nopen import SOAS.Common\nopen import SOAS.Families.Core\n\n-- Algebras for a signature endofunctor\nmodule SOAS.Metatheory.Algebra {T : Set} (⅀F : Functor (𝔽amiliesₛ {T}) (𝔽amiliesₛ {T})) where\n\n\nmodule ⅀ = Functor ⅀F\n\n⅀ : Familyₛ → Familyₛ\n⅀ = ⅀.₀\n\n⅀₁ : {𝒳 𝒴 : Familyₛ} → 𝒳 ⇾̣ 𝒴 → ⅀ 𝒳 ⇾̣ ⅀ 𝒴\n⅀₁ = Functor.₁ ⅀F\n", "meta": {"hexsha": "43b2358713e0f3ecaa8c921343e6650a064b5d20", "size": 309, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SOAS/Metatheory/Algebra.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/Metatheory/Algebra.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/Metatheory/Algebra.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.1764705882, "max_line_length": 93, "alphanum_fraction": 0.6310679612, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.913676530465412, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.5951276404825783}} {"text": "module Section3 where\n\nopen import Section1 public\n\n\n-- 3. The calculus of proof trees\n-- ==============================\n--\n-- We define the set of proof trees of implicational logic in the ordinary style à la Church,\n-- except that we use explicit substitutions.\n\n\n-- 3.1. Definition of types\n-- ------------------------\n--\n-- The types we have are base type and function types. The set of types `𝒯 : Set` is introduced\n-- by:\n\ninfixr 7 _⊃_\ndata 𝒯 : Set where\n • : 𝒯\n _⊃_ : 𝒯 → 𝒯 → 𝒯\n\n-- Types are denoted by `A`, `B`. (…)\n--\n-- We write `•` for the base type and `A ⊃ B` for the function type.\n\nmodule _ where\n inj₁⊃ : ∀ {A A′ B B′} → A ⊃ B ≡ A′ ⊃ B′ → A ≡ A′\n inj₁⊃ refl = refl\n\n inj₂⊃ : ∀ {A A′ B B′} → A ⊃ B ≡ A′ ⊃ B′ → B ≡ B′\n inj₂⊃ refl = refl\n\n _≟𝒯_ : (A A′ : 𝒯) → Dec (A ≡ A′)\n • ≟𝒯 • = yes refl\n • ≟𝒯 (A′ ⊃ B′) = no λ ()\n (A ⊃ B) ≟𝒯 • = no λ ()\n (A ⊃ B) ≟𝒯 (A′ ⊃ B′) with A ≟𝒯 A′ | B ≟𝒯 B′\n … | yes refl | yes refl = yes refl\n … | yes refl | no B≢B′ = no (λ p → inj₂⊃ p ↯ B≢B′)\n … | no A≢A′ | _ = no (λ p → inj₁⊃ p ↯ A≢A′)\n\n\n-- 3.2. Definition of contexts\n-- ---------------------------\n--\n-- Suppose a countably infinite set, `Name`, with names together with a decidable equality on it.\n-- The set of contexts `𝒞` is mutually defined with a boolean-valued function `fresh` which describes\n-- when a name is fresh in a context. (…)\n--\n-- Ordinarily, the freshness condition is written as a side-condition, but since we are to\n-- formalise the proof trees, this information must be represented, too.\n--\n-- We write `[]` for the empty context and `[ Γ , x ∷ A ]` for adding an element to a context,\n-- hence when we write `[ Γ , x ∷ A ]`\n-- it is implicit that we also have a proof that `x` is fresh in `Γ` (when `[ Γ , x ∷ A ]` occurs in the\n-- conclusion of a statement, then it is implicit that `T (fresh x Γ)` is an assumption.) The\n-- function `fresh` is defined by induction on the context as:\n\nmutual\n data 𝒞 : Set where\n [] : 𝒞\n [_,_∷_] : (Γ : 𝒞) (x : Name) {{_ : T (fresh x Γ)}} → 𝒯 → 𝒞\n\n fresh : Name → 𝒞 → Bool\n fresh x [] = true\n fresh x [ Γ , y ∷ A ] = and (x ≠ y) (fresh x Γ)\n\n-- We use `Γ`, `Δ` and `Θ` for contexts.\n--\n-- The predicate `Γ ∋ x ∷ A` is true when a name with its type occurs in a context.\n--\n-- The introduction rules are:\n\ndata _∋_∷_ : 𝒞 → Name → 𝒯 → Set where\n zero : ∀ {Γ A x} {{_ : T (fresh x Γ)}} →\n [ Γ , x ∷ A ] ∋ x ∷ A\n suc : ∀ {Γ A B x y} {{_ : T (fresh y Γ)}} →\n Γ ∋ x ∷ A →\n [ Γ , y ∷ B ] ∋ x ∷ A\n\nmodule _ where\n injsuc : ∀ {Γ A B x y} {{_ : T (fresh y Γ)}} {i i′ : Γ ∋ x ∷ A} →\n suc {B = B} {y = y} i ≡ suc i′ → i ≡ i′\n injsuc refl = refl\n\n _≟∋_ : ∀ {Γ A x} → (i i′ : Γ ∋ x ∷ A) → Dec (i ≡ i′)\n zero ≟∋ zero = yes refl\n zero ≟∋ suc i′ = no (λ ())\n suc i ≟∋ zero = no (λ ())\n suc i ≟∋ suc i′ with i ≟∋ i′\n … | yes refl = yes refl\n … | no i≢i′ = no (λ p → injsuc p ↯ i≢i′)\n\nmodule _ where\n _∌_∷_ : 𝒞 → Name → 𝒯 → Set\n Γ ∌ x ∷ A = ¬ (Γ ∋ x ∷ A)\n\n fresh→∌ : ∀ {x Γ A} {{_ : T (fresh x Γ)}} → Γ ∌ x ∷ A\n fresh→∌ {x} {{φ}} zero with x ≟ x\n fresh→∌ {x} {{()}} zero | yes refl\n fresh→∌ {x} {{φ}} zero | no x≢x = refl ↯ x≢x\n fresh→∌ {x} {{φ}} (suc {y = y} i) with x ≟ y\n fresh→∌ {x} {{()}} (suc {y = .x} i) | yes refl\n fresh→∌ {x} {{φ}} (suc {y = y} i) | no x≢y = i ↯ fresh→∌\n\n freshlem₁ : ∀ {b′} → (x : Name) → ¬ (T (and (x ≠ x) b′))\n freshlem₁ x p with x ≟ x\n … | yes refl = p\n … | no x≢x = refl ↯ x≢x\n\n freshlem₂ : ∀ {b′} → (x {y} : Name) → T (and (x ≠ y) b′) → T b′\n freshlem₂ x {y} p with x ≟ y\n … | yes refl = elim⊥ p\n … | no x≢y = p\n\n-- We also define the relation that describes when a context contains another.\n--\n-- We use the notational convention `Γ ⊇ Δ` for `Γ` being greater than `Δ`.\n-- The set `_⊇_` has the constructors:\n\ninfix 3 _⊇_\ndata _⊇_ : 𝒞 → 𝒞 → Set where\n done : ∀ {Γ} →\n Γ ⊇ []\n step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} →\n Γ ⊇ Δ → Γ ∋ x ∷ A →\n Γ ⊇ [ Δ , x ∷ A ]\n\nmodule _ where\n inj₁step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} {c c′ : Γ ⊇ Δ} {i i′ : Γ ∋ x ∷ A} →\n step c i ≡ step c′ i′ → c ≡ c′\n inj₁step refl = refl\n\n inj₂step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} {c c′ : Γ ⊇ Δ} {i i′ : Γ ∋ x ∷ A} →\n step c i ≡ step c′ i′ → i ≡ i′\n inj₂step refl = refl\n\n _≟⊇_ : ∀ {Γ Δ} → (c c′ : Γ ⊇ Δ) → Dec (c ≡ c′)\n done ≟⊇ done = yes refl\n step c i ≟⊇ step c′ i′ with c ≟⊇ c′ | i ≟∋ i′\n … | yes refl | yes refl = yes refl\n … | yes refl | no i≢i′ = no (λ p → inj₂step p ↯ i≢i′)\n … | no c≢c′ | _ = no (λ p → inj₁step p ↯ c≢c′)\n\n-- The following lemmas are easy to prove:\n\n-- Lemma 1.\next⊇ : ∀ {Δ Γ} → (∀ {A x} → Δ ∋ x ∷ A → Γ ∋ x ∷ A) → Γ ⊇ Δ\next⊇ {[]} f = done\next⊇ {[ Δ , x ∷ A ]} f = step (ext⊇ (λ i → f (suc i))) (f zero)\n\n-- Lemma 2.\nmodule _ where\n ↑⟨_⟩∋ : ∀ {Γ Δ A x} → Δ ⊇ Γ → Γ ∋ x ∷ A → Δ ∋ x ∷ A\n ↑⟨ done ⟩∋ ()\n ↑⟨ step c i ⟩∋ zero = i\n ↑⟨ step c i ⟩∋ (suc j) = ↑⟨ c ⟩∋ j\n\n instance\n raise∋ : ∀ {A x} → Raiseable (_∋ x ∷ A)\n raise∋ = record { ↑⟨_⟩ = ↑⟨_⟩∋ }\n\n-- Lemma 3.\nrefl⊇ : ∀ {Γ} → Γ ⊇ Γ\nrefl⊇ = ext⊇ id\n\n-- Lemma 4.\nmodule _ where\n _○_ : ∀ {Γ Δ Θ} → Γ ⊇ Δ → Θ ⊇ Γ → Θ ⊇ Δ\n c ○ c′ = ext⊇ (λ i → ↑⟨ c′ ⟩ (↑⟨ c ⟩ i))\n\n trans⊇ : ∀ {Γ Δ Θ} → Θ ⊇ Γ → Γ ⊇ Δ → Θ ⊇ Δ\n trans⊇ = flip _○_\n\n-- Lemma 5.\nweak⊇ : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⊇ Γ\nweak⊇ = ext⊇ suc\n\n-- Lemma 6.\nuniq∋ : ∀ {Γ A x} → (i i′ : Γ ∋ x ∷ A) → i ≡ i′\nuniq∋ zero zero = refl\nuniq∋ zero (suc i′) = i′ ↯ fresh→∌\nuniq∋ (suc i) zero = i ↯ fresh→∌\nuniq∋ (suc i) (suc i′) = cong suc (uniq∋ i i′)\n\n-- Lemma 7.\nuniq⊇ : ∀ {Γ Δ} → (c c′ : Γ ⊇ Δ) → c ≡ c′\nuniq⊇ done done = refl\nuniq⊇ (step c i) (step c′ i′) = cong² step (uniq⊇ c c′) (uniq∋ i i′)\n\n-- `ext⊇`, `↑⟨_⟩∋` and `uniq⊇` are proven by induction on `Δ` and `uniq∋` is proven by\n-- induction on `Γ`. `refl⊇` and `weak⊇` are direct consequences of `ext⊇` and for `trans⊇`\n-- we also use `↑⟨_⟩∋`. (…)\n--\n-- The last two lemmas may seem slightly strange: they are used for guaranteeing independence\n-- of the proofs of `_∋_∷_` and `_⊇_`. For example, `uniq∋` says that if it can be shown that\n-- `x ∷ A` occurs in a context `Γ`, then there is a unique proof of this fact. The need to prove\n-- independence of proofs might point to a problem in using type theory for formalising proofs. On\n-- the other hand, as we shall see, proof objects can also be useful: the present formalisation\n-- heavily uses the possibilities to perform case analysis on proof objects, which reduces the\n-- number of cases to consider.\n\nmodule _ where\n id₁○ : ∀ {Γ Δ} → (c : Γ ⊇ Γ) (c′ : Δ ⊇ Γ) → c ○ c′ ≡ c′\n id₁○ c c′ = uniq⊇ (c ○ c′) c′\n\n id₂○ : ∀ {Γ Δ} → (c : Δ ⊇ Γ) (c′ : Δ ⊇ Δ) → c ○ c′ ≡ c\n id₂○ c c′ = uniq⊇ (c ○ c′) c\n\n assoc○ : ∀ {Γ Δ Θ Ω} → (c : Δ ⊇ Γ) (c′ : Θ ⊇ Δ) (c″ : Ω ⊇ Θ) →\n c ○ (c′ ○ c″) ≡ (c ○ c′) ○ c″\n assoc○ c c′ c″ = uniq⊇ (c ○ (c′ ○ c″)) ((c ○ c′) ○ c″)\n\n comp○ : ∀ {Γ Δ Θ} → (c : Δ ⊇ Γ) (c′ : Θ ⊇ Δ) (c″ : Θ ⊇ Γ) →\n c ○ c′ ≡ c″\n comp○ c c′ c″ = uniq⊇ (c ○ c′) c″\n\n\n-- 3.3. Definition of proof trees\n-- ------------------------------\n--\n-- Proof trees and substitutions are mutually inductively defined. (…)\n--\n-- We use the notational convention `Γ ⊢ A` and `Δ ⋙ Γ` for a proof of `A` in context `Γ` and\n-- a substitution of `Γ` by `Δ`, respectively.\n--\n-- A substitution of type `Δ ⋙ Γ` intuitively is a list that associates to each `x ∷ A` in `Γ` a unique\n-- proof tree of type `Δ ⊢ A`.\n--\n-- The proof trees are defined by the following rules.\n--\n-- We recall that hidden assumptions in the definition above are implicitly universally defined\n-- and that the notation `[ Γ , x ∷ A ]` implies that `x` is fresh in `Γ`. (…)\n--\n-- In the definition of variables we can see that a proof of occurrence is part of the proof\n-- tree. The advantage is that we can do case-analysis on this proof to find out where in the\n-- context `x ∷ A` occurs. The disadvantage is that we need to prove that two variables are the\n-- same even if they have two possibly different proofs of occurrence of `x ∷ A` (by Lemma 6 we\n-- know that the proofs are the same).\n\nmutual\n infix 3 _⊢_\n data _⊢_ : 𝒞 → 𝒯 → Set where\n ν : ∀ {Γ A} →\n (x : Name) → Γ ∋ x ∷ A →\n Γ ⊢ A\n ƛ : ∀ {Γ A B} →\n (x : Name) {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⊢ B →\n Γ ⊢ A ⊃ B\n _∙_ : ∀ {Γ A B} →\n Γ ⊢ A ⊃ B → Γ ⊢ A →\n Γ ⊢ B\n _▶_ : ∀ {Γ Δ A} →\n Γ ⊢ A → Δ ⋙ Γ →\n Δ ⊢ A\n\n infix 3 _⋙_\n data _⋙_ : 𝒞 → 𝒞 → Set where\n π⟨_⟩ : ∀ {Γ Δ} →\n Δ ⊇ Γ →\n Δ ⋙ Γ\n _●_ : ∀ {Γ Δ Θ} →\n Γ ⋙ Δ → Θ ⋙ Γ →\n Θ ⋙ Δ\n [_,_≔_] : ∀ {Γ Δ A} →\n Δ ⋙ Γ → (x : Name) {{_ : T (fresh x Γ)}} → Δ ⊢ A →\n Δ ⋙ [ Γ , x ∷ A ]\n\n-- Explicit substitutions are built from a projection map, update and composition (see below\n-- for a discussion on the projection map).\n--\n-- We use the following notational conventions:\n--\n-- - `ν x` for referencing the occurrence `x`, where `x : Γ ∋ x ∷ A`\n-- - `M ▶ γ` for applying the substitution `γ` to the term `M`\n-- - `ƛ x M` for abstracting the occurrence `x` from the term `M`, where `M : [ Γ , x ∷ A ] ⊢ B`\n-- - `M ∙ N` for applying the term `M` to the term `N`\n-- - `π⟨ c ⟩` for projecting the inclusion `c` as a substitution\n-- - `[ γ , x ≔ M ]` for updating the substitution `γ` with the term `M` for the occurrence `x`\n-- - `γ ● δ` for composing the substitution `δ` with the substitution `γ`\n--\n-- Proof trees and substitutions are named `M, N` and `γ, δ, θ` respectively.\n--\n-- The substitution `π⟨_⟩` is not a standard primitive for explicit substitutions. Often one rather\n-- has an identity substitution (in `Γ ⋙ Γ`) [1, 13] or the empty substitution (in `Γ ⋙ []`) [5].\n-- Instead we have taken `π⟨_⟩` as primitive. If `c : Γ ⊇ Γ`, then `π⟨ c ⟩` is the identity substitution and\n-- if `c : Γ ⊇ []`, then `π⟨ c ⟩` is the empty substitution. Abadi et al. [1] use a substitution `↑` that\n-- corresponds to a shift on substitutions; the same substitution is here defined as `π⟨ c ⟩` where\n-- `c : [ Γ , x ∷ A ] ⊇ Γ`. In Martin-Löf’s substitution calculus [13, 20] we have as primitives also\n-- thinning rules (i.e., if a term is well-typed in a given context, then it is also well-typed in a\n-- larger context and likewise for substitutions.) Here, thinning is achieved using `π⟨_⟩`, since if,\n-- for example, `M : Γ ⊢ A` and `c : Δ ⊇ Γ`, then `M ▶ π⟨ c ⟩ : Δ ⊢ A`.\n--\n-- The first version of our work used combinators for the thinning rules, since we wanted it to\n-- be a start for a complete mechanical analysis of Martin-Löf’s substitution calculus [13, 20].\n-- The set of conversion rules we obtained using these combinators suggested the use of `π⟨_⟩`,\n-- which gives fewer conversion rules. There might be other advantages in using `π⟨_⟩`: if a proof\n-- tree is of the form `M ▶ π⟨_⟩` we know which are the possible free variables of the term `M`,\n-- information that might be used in a computation.\n\nmodule _ where\n ↑⟨_⟩⊢ : ∀ {Γ Δ A} → Δ ⊇ Γ → Γ ⊢ A → Δ ⊢ A\n ↑⟨ c ⟩⊢ M = M ▶ π⟨ c ⟩\n\n ↑⟨_⟩⋙ : ∀ {Γ Δ Θ} → Δ ⊇ Γ → Γ ⋙ Θ → Δ ⋙ Θ\n ↑⟨ c ⟩⋙ δ = δ ● π⟨ c ⟩\n\n ↓⟨_⟩⋙ : ∀ {Γ Δ Θ} → Δ ⊇ Γ → Θ ⋙ Δ → Θ ⋙ Γ\n ↓⟨ c ⟩⋙ δ = π⟨ c ⟩ ● δ\n\n refl⋙ : ∀ {Γ} → Γ ⋙ Γ\n refl⋙ = π⟨ refl⊇ ⟩\n\n trans⋙ : ∀ {Γ Δ Θ} → Θ ⋙ Γ → Γ ⋙ Δ → Θ ⋙ Δ\n trans⋙ = flip _●_\n\n weak⋙ : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⋙ Γ\n weak⋙ = π⟨ weak⊇ ⟩\n\n instance\n raise⊢ : ∀ {A} → Raiseable (_⊢ A)\n raise⊢ = record { ↑⟨_⟩ = ↑⟨_⟩⊢ }\n\n raise⋙ : ∀ {Γ} → Raiseable (_⋙ Γ)\n raise⋙ = record { ↑⟨_⟩ = ↑⟨_⟩⋙ }\n\n lower⋙ : ∀ {Δ} → Lowerable (Δ ⋙_)\n lower⋙ = record { ↓⟨_⟩ = ↓⟨_⟩⋙ }\n\n\n-- 3.4. Convertibility of proof trees\n-- ----------------------------------\n--\n-- The rules for conversion between proof trees and substitutions are inductively defined.\n--\n-- We use the notational convention `M ≅ N` and `γ ≅ₛ δ` for convertibility on proof trees and\n-- on substitutions respectively. (…)\n--\n-- The conversion rules for proof trees are the reflexivity, symmetry, transitivity, congruence\n-- rules and the following rules:\n\nmutual\n infix 3 _≅_\n data _≅_ : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A → Set where\n refl≅ : ∀ {Γ A} {M : Γ ⊢ A} →\n M ≅ M\n sym≅ : ∀ {Γ A} {M M′ : Γ ⊢ A} →\n M ≅ M′ →\n M′ ≅ M\n trans≅ : ∀ {Γ A} {M M′ M″ : Γ ⊢ A} →\n M ≅ M′ → M′ ≅ M″ →\n M ≅ M″\n\n congƛ≅ : ∀ {Γ A B x} {{_ : T (fresh x Γ)}} {M M′ : [ Γ , x ∷ A ] ⊢ B} →\n M ≅ M′ →\n ƛ x M ≅ ƛ x M′\n cong∙≅ : ∀ {Γ A B} {M M′ : Γ ⊢ A ⊃ B} {N N′ : Γ ⊢ A} →\n M ≅ M′ → N ≅ N′ →\n M ∙ N ≅ M′ ∙ N′\n cong▶≅ : ∀ {Γ Δ A} {M M′ : Γ ⊢ A} {γ γ′ : Δ ⋙ Γ} →\n M ≅ M′ → γ ≅ₛ γ′ →\n M ▶ γ ≅ M′ ▶ γ′\n\n conv₁≅ : ∀ {Γ Δ A B x} {{_ : T (fresh x Γ)}} →\n (M : [ Γ , x ∷ A ] ⊢ B) (N : Δ ⊢ A) (γ : Δ ⋙ Γ) →\n (ƛ x M ▶ γ) ∙ N ≅ M ▶ [ γ , x ≔ N ]\n conv₂≅ : ∀ {Γ A B x} {{_ : T (fresh x Γ)}} →\n (c : [ Γ , x ∷ A ] ⊇ Γ) (M : Γ ⊢ A ⊃ B) →\n M ≅ ƛ x ((M ▶ π⟨ c ⟩) ∙ ν x zero)\n conv₃≅ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} →\n (M : Δ ⊢ A) (γ : Δ ⋙ Γ) →\n ν x zero ▶ [ γ , x ≔ M ] ≅ M\n conv₄≅ : ∀ {Γ Δ A x} →\n (c : Δ ⊇ Γ) (i : Γ ∋ x ∷ A) (j : Δ ∋ x ∷ A) →\n ν x i ▶ π⟨ c ⟩ ≅ ν x j\n conv₅≅ : ∀ {Γ A} →\n (c : Γ ⊇ Γ) (M : Γ ⊢ A) →\n M ▶ π⟨ c ⟩ ≅ M\n conv₆≅ : ∀ {Γ Δ A B} →\n (M : Γ ⊢ A ⊃ B) (N : Γ ⊢ A) (γ : Δ ⋙ Γ) →\n (M ∙ N) ▶ γ ≅ (M ▶ γ) ∙ (N ▶ γ)\n conv₇≅ : ∀ {Γ Δ Θ A} →\n (M : Γ ⊢ A) (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) →\n (M ▶ γ) ▶ δ ≅ M ▶ (γ ● δ)\n\n infix 3 _≅ₛ_\n data _≅ₛ_ : ∀ {Γ Δ} → Δ ⋙ Γ → Δ ⋙ Γ → Set where\n refl≅ₛ : ∀ {Γ Δ} {γ : Δ ⋙ Γ} →\n γ ≅ₛ γ\n sym≅ₛ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} →\n γ ≅ₛ γ′ →\n γ′ ≅ₛ γ\n trans≅ₛ : ∀ {Γ Δ} {γ γ′ γ″ : Δ ⋙ Γ} →\n γ ≅ₛ γ′ → γ′ ≅ₛ γ″ →\n γ ≅ₛ γ″\n\n cong●≅ₛ : ∀ {Γ Δ Θ} {γ γ′ : Δ ⋙ Γ} {δ δ′ : Θ ⋙ Δ} →\n γ ≅ₛ γ′ → δ ≅ₛ δ′ →\n γ ● δ ≅ₛ γ′ ● δ′\n cong≔≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} {γ γ′ : Δ ⋙ Γ} {M M′ : Δ ⊢ A} →\n γ ≅ₛ γ′ → M ≅ M′ →\n [ γ , x ≔ M ] ≅ₛ [ γ′ , x ≔ M′ ]\n\n conv₁≅ₛ : ∀ {Γ Δ Θ Ω} →\n (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) (θ : Ω ⋙ Θ) →\n (γ ● δ) ● θ ≅ₛ γ ● (δ ● θ)\n conv₂≅ₛ : ∀ {Γ Δ Θ A x} {{_ : T (fresh x Γ)}} →\n (M : Δ ⊢ A) (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) →\n [ γ , x ≔ M ] ● δ ≅ₛ [ γ ● δ , x ≔ M ▶ δ ]\n conv₃≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} →\n (c : [ Γ , x ∷ A ] ⊇ Γ) (M : Δ ⊢ A) (γ : Δ ⋙ Γ) →\n π⟨ c ⟩ ● [ γ , x ≔ M ] ≅ₛ γ\n conv₄≅ₛ : ∀ {Γ Δ Θ} →\n (c : Θ ⊇ Γ) (c′ : Δ ⊇ Γ) (c″ : Θ ⊇ Δ) →\n π⟨ c′ ⟩ ● π⟨ c″ ⟩ ≅ₛ π⟨ c ⟩\n conv₅≅ₛ : ∀ {Γ Δ} →\n (c : Δ ⊇ Δ) (γ : Δ ⋙ Γ) →\n γ ● π⟨ c ⟩ ≅ₛ γ\n conv₆≅ₛ : ∀ {Γ} →\n (c : Γ ⊇ []) (γ : Γ ⋙ []) →\n γ ≅ₛ π⟨ c ⟩\n conv₇≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} →\n (c : [ Γ , x ∷ A ] ⊇ Γ) (γ : Δ ⋙ [ Γ , x ∷ A ]) (i : [ Γ , x ∷ A ] ∋ x ∷ A) →\n γ ≅ₛ [ π⟨ c ⟩ ● γ , x ≔ ν x i ▶ γ ]\n\n-- The first two `conv≅` rules correspond to the ordinary β- and η-rules, the next three define the effect\n-- of substitutions and the last two rules can be seen as the correspondence of the η-rule for\n-- substitutions. The remaining `conv≅ₛ` rules define how the substitutions distribute.\n\nmodule _ where\n ≡→≅ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≡ M′ → M ≅ M′\n ≡→≅ refl = refl≅\n\n module ≅-Reasoning where\n infix 1 begin_\n begin_ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≅ M′ → M ≅ M′\n begin p = p\n\n infixr 2 _≅⟨⟩_\n _≅⟨⟩_ : ∀ {Γ A} (M {M′} : Γ ⊢ A) → M ≅ M′ → M ≅ M′\n M ≅⟨⟩ p = p\n\n infixr 2 _≅⟨_⟩_\n _≅⟨_⟩_ : ∀ {Γ A} (M {M′ M″} : Γ ⊢ A) → M ≅ M′ → M′ ≅ M″ → M ≅ M″\n M ≅⟨ p ⟩ p′ = trans≅ p p′\n\n infixr 2 _≡⟨⟩_\n _≡⟨⟩_ : ∀ {Γ A} (M {M′} : Γ ⊢ A) → M ≅ M′ → M ≅ M′\n M ≡⟨⟩ p = p\n\n infixr 2 _≡⟨_⟩_\n _≡⟨_⟩_ : ∀ {Γ A} (M {M′ M″} : Γ ⊢ A) → M ≡ M′ → M′ ≅ M″ → M ≅ M″\n M ≡⟨ p ⟩ p′ = trans≅ (≡→≅ p) p′\n\n infix 3 _∎\n _∎ : ∀ {Γ A} (M : Γ ⊢ A) → M ≅ M\n M ∎ = refl≅\n\n ≡→≅ₛ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≡ γ′ → γ ≅ₛ γ′\n ≡→≅ₛ refl = refl≅ₛ\n\n module ≅ₛ-Reasoning where\n infix 1 begin_\n begin_ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≅ₛ γ′ → γ ≅ₛ γ′\n begin p = p\n\n infixr 2 _≅ₛ⟨⟩_\n _≅ₛ⟨⟩_ : ∀ {Γ Δ} (γ {γ′} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ ≅ₛ γ′\n γ ≅ₛ⟨⟩ p = p\n\n infixr 2 _≅ₛ⟨_⟩_\n _≅ₛ⟨_⟩_ : ∀ {Γ Δ} (γ {γ′ γ″} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″\n γ ≅ₛ⟨ p ⟩ p′ = trans≅ₛ p p′\n\n infixr 2 _≡⟨⟩_\n _≡⟨⟩_ : ∀ {Γ Δ} (γ {γ′} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ ≅ₛ γ′\n γ ≡⟨⟩ p = p\n\n infixr 2 _≡⟨_⟩_\n _≡⟨_⟩_ : ∀ {Γ Δ} (γ {γ′ γ″} : Δ ⋙ Γ) → γ ≡ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″\n γ ≡⟨ p ⟩ p′ = trans≅ₛ (≡→≅ₛ p) p′\n\n infix 3 _∎\n _∎ : ∀ {Γ Δ} (γ : Δ ⋙ Γ) → γ ≅ₛ γ\n γ ∎ = refl≅ₛ\n", "meta": {"hexsha": "b124fec5b9f403ca7b2dcc7b6921eb87e8dfda59", "size": 17407, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Section3.agda", "max_stars_repo_name": "mietek/coquand", "max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_stars_repo_licenses": ["X11"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z", "max_issues_repo_path": "src/Section3.agda", "max_issues_repo_name": "mietek/coquand", "max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "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/Section3.agda", "max_forks_repo_name": "mietek/coquand", "max_forks_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "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": 35.6700819672, "max_line_length": 109, "alphanum_fraction": 0.4464295973, "num_tokens": 7820, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835452961425, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.5950582652586621}} {"text": "open import MJ.Types as Types\nimport MJ.Classtable.Core as Core\n\nmodule MJ.Semantics.Values {c}(Ct : Core.Classtable c) where\n\nopen import Prelude\n\nopen import Level renaming (suc to lsuc; zero to lzero)\nopen import Data.List hiding (null)\nopen import Data.List.Membership.Propositional\nopen import Data.List.Prefix\n\nopen Core c\nopen Classtable Ct\nopen import MJ.Classtable.Membership Ct\nopen import MJ.LexicalScope c\nopen import Common.Weakening\n\n{-\nMJ inherits the values of STLC+Ref. In contrast to STCL+Ref, MJ also has\nnull-pointers; which we add as a constructor to our value type Val. The value\nconstructed by null is typed with an arbitrary reference type as it can be used\nin place of any proper reference.\n-}\ndata Val (W : World c) : Ty c → Set where\n num : ℕ → Val W int\n unit : Val W void\n null : ∀ {C} → Val W (ref C)\n ref : ∀ {C P} → (obj C) ∈ W → Σ ⊢ C <: P → Val W (ref P)\n\n{-\nWe can construct default values out of thin air for every type\n-}\ndefault : ∀ {W} → (a : Ty c) → Val W a\ndefault void = unit\ndefault int = num 0\ndefault (ref x) = null\n\n{-\nValue weakening\n-}\nweaken-val : ∀ {a}{W W' : World c} → W ⊒ W' → Val W' a → Val W a\nweaken-val ext (num n) = num n\nweaken-val ext unit = unit\nweaken-val ext null = null\nweaken-val ext (ref x sub) = ref (∈-⊒ x ext) sub\n\ninstance\n val-weakenable : ∀ {a} → Weakenable (λ W → Val W a)\n val-weakenable = record { wk = weaken-val }\n\n", "meta": {"hexsha": "4f5a51ec1713df87a1129e5bf78e421bb4befeac", "size": 1400, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/MJ/Semantics/Values.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/MJ/Semantics/Values.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/MJ/Semantics/Values.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": 26.9230769231, "max_line_length": 79, "alphanum_fraction": 0.6892857143, "num_tokens": 441, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835371034369, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.5950582645268622}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- There are really all 'private' sub-pieces of\n-- Categories.Category.Monoidal.Closed.IsClosed, but that is taking\n-- forever to typecheck, so the idea is to split things into pieces and\n-- hope that that will help.\n\nopen import Categories.Category using (Category)\nopen import Categories.Category.Monoidal\nopen import Categories.Category.Monoidal.Closed using (Closed)\n\nmodule Categories.Category.Monoidal.Closed.IsClosed.Identity\n {o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (Cl : Closed M) where\n\nopen import Function using (_$_) renaming (_∘_ to _∙_)\n\nopen import Categories.Category.Monoidal.Utilities M\nopen import Categories.Morphism C using (Iso)\nopen import Categories.Morphism.Properties C using (Iso-resp-≈)\nopen import Categories.Morphism.Reasoning C using (pullʳ; pullˡ; pushˡ; cancelʳ)\nopen import Categories.Functor using (Functor) renaming (id to idF)\nopen import Categories.Functor.Bifunctor\nopen import Categories.Functor.Bifunctor.Properties\nopen import Categories.NaturalTransformation hiding (id)\nopen import Categories.NaturalTransformation.Dinatural\n using (Extranaturalʳ; extranaturalʳ; DinaturalTransformation)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n using (NaturalIsomorphism)\nimport Categories.Category.Closed as Cls\n\nopen Closed Cl\nopen Category C -- most of it is used\n\nopen HomReasoning\nopen adjoint renaming (unit to η; counit to ε; Ladjunct to 𝕃)\n\nprivate\n λ⇒ = unitorˡ.from\n λ⇐ = unitorˡ.to\n ρ⇒ = unitorʳ.from\n ρ⇐ = unitorʳ.to\n\nidentity : NaturalIsomorphism idF [ unit ,-]\nidentity = record\n { F⇒G = F∘id⇒F ∘ᵥ ([ unit ,-] ∘ˡ (unitorʳ-natural.F⇒G)) ∘ᵥ η\n ; F⇐G = ε ∘ᵥ (unitorʳ-natural.F⇐G ∘ʳ [ unit ,-]) ∘ᵥ F⇒id∘F\n ; iso = λ X → Iso-resp-≈ (iso X) (⟺ identityˡ) (⟺ (∘-resp-≈ʳ identityʳ))\n }\n where\n open Functor\n iso : ∀ X → Iso (𝕃 unitorʳ.from) (ε.η X ∘ unitorʳ.to)\n iso X = record\n { isoˡ = begin\n (ε.η X ∘ ρ⇐) ∘ 𝕃 ρ⇒ ≈⟨ pullʳ unitorʳ-commute-to ⟩\n ε.η X ∘ 𝕃 ρ⇒ ⊗₁ id ∘ ρ⇐ ≈˘⟨ assoc ⟩\n Radjunct (𝕃 ρ⇒) ∘ ρ⇐ ≈⟨ RLadjunct≈id ⟩∘⟨refl ⟩\n ρ⇒ ∘ ρ⇐ ≈⟨ unitorʳ.isoʳ ⟩\n id ∎\n ; isoʳ = begin\n 𝕃 ρ⇒ ∘ ε.η X ∘ ρ⇐ ≈⟨ pullʳ (η.commute _) ⟩\n [ id , ρ⇒ ]₁ ∘ 𝕃 ((ε.η X ∘ ρ⇐) ⊗₁ id) ≈˘⟨ pushˡ (homomorphism [ unit ,-]) ⟩\n 𝕃 (ρ⇒ ∘ (ε.η X ∘ ρ⇐) ⊗₁ id) ≈⟨ F-resp-≈ [ unit ,-] unitorʳ-commute-from ⟩∘⟨refl ⟩\n 𝕃 ((ε.η X ∘ ρ⇐) ∘ ρ⇒) ≈⟨ F-resp-≈ [ unit ,-] (cancelʳ unitorʳ.isoˡ) ⟩∘⟨refl ⟩\n 𝕃 (ε.η X) ≈⟨ zag ⟩\n id ∎\n }\n\nmodule identity = NaturalIsomorphism identity\n\ndiagonal : Extranaturalʳ unit [-,-]\ndiagonal = extranaturalʳ (λ X → 𝕃 λ⇒)\n $ λ {X Y f} → begin\n [ id , f ]₁ ∘ 𝕃 λ⇒ ≈˘⟨ pushˡ (homomorphism [ X ,-]) ⟩\n [ id , f ∘ λ⇒ ]₁ ∘ η.η unit ≈˘⟨ F-resp-≈ [ X ,-] unitorˡ-commute-from ⟩∘⟨refl ⟩\n [ id , λ⇒ ∘ id ⊗₁ f ]₁ ∘ η.η unit ≈⟨ homomorphism [ X ,-] ⟩∘⟨refl ⟩\n ([ id , λ⇒ ]₁ ∘ [ id , id ⊗₁ f ]₁) ∘ η.η unit ≈⟨ pullʳ (mate.commute₁ f) ⟩\n [ id , λ⇒ ]₁ ∘ [ f , id ]₁ ∘ η.η unit ≈⟨ pullˡ [ [-,-] ]-commute ⟩\n ([ f , id ]₁ ∘ [ id , λ⇒ ]₁) ∘ η.η unit ≈⟨ assoc ⟩\n [ f , id ]₁ ∘ 𝕃 λ⇒ ∎\n where open Functor\n\nmodule diagonal = DinaturalTransformation diagonal\n", "meta": {"hexsha": "f54cf258182f14fc664bba242ee2fbc6a213f34e", "size": 3404, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Category/Monoidal/Closed/IsClosed/Identity.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/Monoidal/Closed/IsClosed/Identity.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/Monoidal/Closed/IsClosed/Identity.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": 41.0120481928, "max_line_length": 102, "alphanum_fraction": 0.5831374853, "num_tokens": 1376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835371034368, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.595058254320245}} {"text": "module Section8 where\n\nopen import Section7 public\n\n\n-- 8. Correctness of conversion between terms\n-- ==========================================\n--\n-- The conversion rules for terms are sound:\n\n-- Theorem 9.\npostulate\n thm₉ : ∀ {Γ A t₀ t₁} →\n (M N : Γ ⊢ A) → t₀ 𝒟 M → t₁ 𝒟 N → Γ ⊢ t₀ ≊ t₁ ∷ A →\n M ≅ N\n\n-- Proof: The proof is by induction on the proof of `Γ ⊢ t₀ ≊ t₁ ∷ A`. We illustrate the proof\n-- with the reflexivity case. In this case we have that `t₀` and `t₁` are the same, hence by Corollary 3\n-- we get `M ≅ N`.\n--\n-- To prove that the conversion rules are complete\n-- is straightforward by induction on the proof of `M ≅ N`.\n\n-- Theorem 10.\npostulate\n thm₁₀ : ∀ {Γ A} →\n (M N : Γ ⊢ A) → M ≅ N →\n Γ ⊢ M ⁻ ≊ N ⁻ ∷ A\n", "meta": {"hexsha": "c6b791c9d08037cd69736c4682e8914bd43cac5f", "size": 771, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Section8.agda", "max_stars_repo_name": "mietek/coquand", "max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_stars_repo_licenses": ["X11"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z", "max_issues_repo_path": "src/Section8.agda", "max_issues_repo_name": "mietek/coquand", "max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "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/Section8.agda", "max_forks_repo_name": "mietek/coquand", "max_forks_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "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": 26.5862068966, "max_line_length": 105, "alphanum_fraction": 0.5499351492, "num_tokens": 265, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8244619350028204, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.595049805373826}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Util.HoTT.Equiv.Core where\n\nopen import Util.Prelude\nopen import Util.HoTT.HLevel.Core\n\n\ninfix 4 _≅_ _≃_\n\n\nprivate\n variable\n α β γ : Level\n A B C : Set α\n\n\nInjective : (f : A → B) → Set _\nInjective f = ∀ {x y} → f x ≡ f y → x ≡ y\n\n\nrecord IsIso {A : Set α} {B : Set β} (forth : A → B) : Set (α ⊔ℓ β)\n where\n field\n back : B → A\n back∘forth : ∀ x → back (forth x) ≡ x\n forth∘back : ∀ x → forth (back x) ≡ x\n\n\nrecord _≅_ (A : Set α) (B : Set β) : Set (α ⊔ℓ β) where\n field\n forth : A → B\n isIso : IsIso forth\n\n open IsIso isIso public\n\nopen _≅_ public\n\n\nIsEquiv : {A : Set α} {B : Set β} (forth : A → B)\n → Set (α ⊔ℓ β)\nIsEquiv {A = A} {B} forth\n = ∀ b → IsContr (Σ[ a ∈ A ] forth a ≡ b)\n\n\nrecord _≃_ (A : Set α) (B : Set β) : Set (α ⊔ℓ β) where\n field\n forth : A → B\n isEquiv : IsEquiv forth\n\nopen _≃_ public\n", "meta": {"hexsha": "f1691fe4060eeec9391233404f107784ce4f54c8", "size": 886, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Util/HoTT/Equiv/Core.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/Util/HoTT/Equiv/Core.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/Util/HoTT/Equiv/Core.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": 17.3725490196, "max_line_length": 67, "alphanum_fraction": 0.5474040632, "num_tokens": 369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869786798663, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.5948158609345392}} {"text": "------------------------------------------------------------------------\n-- The semantics is deterministic\n------------------------------------------------------------------------\n\nopen import Atom\n\nmodule Deterministic (atoms : χ-atoms) where\n\nopen import Equality.Propositional\nopen import Prelude hiding (const)\nopen import Tactic.By.Propositional\n\nopen import Chi atoms\n\nopen χ-atoms atoms\n\nLookup-deterministic :\n ∀ {c₁ c₂ bs xs₁ xs₂ e₁ e₂} →\n Lookup c₁ bs xs₁ e₁ → Lookup c₂ bs xs₂ e₂ →\n c₁ ≡ c₂ → xs₁ ≡ xs₂ × e₁ ≡ e₂\nLookup-deterministic here here _ = refl , refl\nLookup-deterministic here (there q _) refl = ⊥-elim (q refl)\nLookup-deterministic (there p _) here refl = ⊥-elim (p refl)\nLookup-deterministic (there p₁ p₂) (there q₁ q₂) refl =\n Lookup-deterministic p₂ q₂ refl\n\n↦-deterministic :\n ∀ {e xs es e₁ e₂} →\n e [ xs ← es ]↦ e₁ → e [ xs ← es ]↦ e₂ → e₁ ≡ e₂\n↦-deterministic [] [] = refl\n↦-deterministic (∷ p) (∷ q) = by (↦-deterministic p q)\n\nmutual\n\n ⇓-deterministic : ∀ {e v₁ v₂} → e ⇓ v₁ → e ⇓ v₂ → v₁ ≡ v₂\n ⇓-deterministic (apply p₁ p₂ p₃) (apply q₁ q₂ q₃)\n with ⇓-deterministic p₁ q₁ | ⇓-deterministic p₂ q₂\n ... | refl | refl = ⇓-deterministic p₃ q₃\n\n ⇓-deterministic (case p₁ p₂ p₃ p₄) (case q₁ q₂ q₃ q₄)\n with ⇓-deterministic p₁ q₁\n ... | refl with Lookup-deterministic p₂ q₂ refl\n ... | refl , refl rewrite ↦-deterministic p₃ q₃ =\n ⇓-deterministic p₄ q₄\n\n ⇓-deterministic (rec p) (rec q) = ⇓-deterministic p q\n ⇓-deterministic lambda lambda = refl\n ⇓-deterministic (const ps) (const qs) = by (⇓⋆-deterministic ps qs)\n\n ⇓⋆-deterministic : ∀ {es vs₁ vs₂} → es ⇓⋆ vs₁ → es ⇓⋆ vs₂ → vs₁ ≡ vs₂\n ⇓⋆-deterministic [] [] = refl\n ⇓⋆-deterministic (p ∷ ps) (q ∷ qs) =\n cong₂ _∷_ (⇓-deterministic p q) (⇓⋆-deterministic ps qs)\n", "meta": {"hexsha": "a9cc66f7c06af638a0b171e5e233679a52102200", "size": 1845, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Deterministic.agda", "max_stars_repo_name": "nad/chi", "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_issues_repo_path": "src/Deterministic.agda", "max_issues_repo_name": "nad/chi", "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_forks_repo_path": "src/Deterministic.agda", "max_forks_repo_name": "nad/chi", "max_forks_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": ["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.1666666667, "max_line_length": 72, "alphanum_fraction": 0.5712737127, "num_tokens": 700, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869884059267, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.5948158561659417}} {"text": "open import Agda.Primitive using (lzero; lsuc; _⊔_; Level)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; subst)\nopen import Relation.Binary using (Setoid)\n\n-- A formalization of raw syntax\n\nmodule Syntax where\n\n -- Syntactic classes\n\n data ObjectClass : Set where\n Ty Tm : ObjectClass\n\n data Class : Set where\n obj : ObjectClass → Class\n EqTy EqTm : Class\n\n -- Variable context shape\n\n infixl 6 _⊕_\n\n data VShape : Set where\n 𝟘 : VShape\n 𝟙 : VShape\n _⊕_ : VShape → VShape → VShape\n\n data var : VShape → Set where\n var-here : var 𝟙\n var-left : ∀ {γ δ} → var γ → var (γ ⊕ δ)\n var-right : ∀ {γ δ} → var δ → var (γ ⊕ δ)\n\n -- Metavariable context shapes\n\n infixl 9 _⊕ᵐᵛ_\n\n data MShape : Set where\n 𝟘ᵐᵛ : MShape\n 𝟙ᵐᵛ : ∀ (cl : Class) (γ : VShape) → MShape\n _⊕ᵐᵛ_ : MShape → MShape → MShape\n\n infix 8 [_,_]∈_\n\n data [_,_]∈_ : Class → VShape → MShape → Set where\n mv-here : ∀ cl γ → [ cl , γ ]∈ 𝟙ᵐᵛ cl γ\n mv-left : ∀ {𝕂 𝕄} cl γ → [ cl , γ ]∈ 𝕂 → [ cl , γ ]∈ 𝕂 ⊕ᵐᵛ 𝕄\n mv-right : ∀ {𝕂 𝕄} cl γ → [ cl , γ ]∈ 𝕄 → [ cl , γ ]∈ 𝕂 ⊕ᵐᵛ 𝕄\n\n -- Symbol signature\n\n record Signature : Set₁ where\n field\n symb : ObjectClass → Set -- a set of symbol names, one for each class\n symb-arg : ∀ {cl} → symb cl → MShape\n\n -- Expressions\n\n module Expression (𝕊 : Signature) where\n open Signature 𝕊\n\n data Expr : Class → (𝕄 : MShape) → (γ : VShape) → Set\n\n Arg : ∀ (cl : Class) (𝕄 : MShape) (γ : VShape) (δ : VShape) → Set\n Arg cl 𝕄 γ δ = Expr cl 𝕄 (γ ⊕ δ)\n\n ExprObj : ∀ (cl : ObjectClass) (𝕄 : MShape) (γ : VShape) → Set\n ExprObj cl = Expr (obj cl)\n\n ExprTm = ExprObj Tm\n ExprTy = ExprObj Ty\n\n data Expr where\n expr-var : ∀ {𝕄} {γ} (x : var γ) → ExprTm 𝕄 γ\n expr-symb : ∀ {cl 𝕄 γ} (S : symb cl) →\n (es : ∀ {clⁱ γⁱ} (i : [ clⁱ , γⁱ ]∈ symb-arg S) → Arg clⁱ 𝕄 γ γⁱ) →\n ExprObj cl 𝕄 γ\n expr-meta : ∀ {cl 𝕄 γ} {γᴹ} (M : [ obj cl , γᴹ ]∈ 𝕄) → (ts : ∀ (i : var γᴹ) → ExprTm 𝕄 γ) → ExprObj cl 𝕄 γ\n expr-eqty : ∀ {γ} {𝕄} → Expr EqTy 𝕄 γ\n expr-eqtm : ∀ {γ} {𝕄} → Expr EqTm 𝕄 γ\n\n expr-meta-generic : ∀ {𝕄} {cl} {γ γᴹ} (M : [ cl , γᴹ ]∈ 𝕄) → Arg cl 𝕄 γ γᴹ\n expr-meta-generic {cl = obj _} M = expr-meta M (λ i → expr-var (var-right i))\n expr-meta-generic {cl = EqTy} M = expr-eqty\n expr-meta-generic {cl = EqTm} M = expr-eqtm\n\n -- Syntactic equality\n\n module Equality {𝕊 : Signature} where\n\n open Signature 𝕊\n open Expression 𝕊\n\n infix 4 _≈_\n\n data _≈_ : ∀ {cl 𝕄 γ} → Expr cl 𝕄 γ → Expr cl 𝕄 γ → Set where\n ≈-≡ : ∀ {cl 𝕄 γ} {t u : Expr cl 𝕄 γ} (ξ : t ≡ u) → t ≈ u\n ≈-symb : ∀ {cl 𝕄 γ} {S : symb cl} →\n {ds es : ∀ {cⁱ γⁱ} (i : [ cⁱ , γⁱ ]∈ symb-arg S) → Arg cⁱ 𝕄 γ γⁱ}\n (ξ : ∀ {cⁱ γⁱ} (i : [ cⁱ , γⁱ ]∈ symb-arg S) → ds i ≈ es i) → expr-symb S ds ≈ expr-symb S es\n ≈-meta : ∀ {cl 𝕄 γ} {γᴹ} {M : [ obj cl , γᴹ ]∈ 𝕄} → {ts us : ∀ (i : var γᴹ) → ExprTm 𝕄 γ}\n (ξ : ∀ i → ts i ≈ us i) → expr-meta M ts ≈ expr-meta M us\n\n ≈-refl : ∀ {cl 𝕄 γ} {t : Expr cl 𝕄 γ} → t ≈ t\n ≈-refl = ≈-≡ refl\n\n ≈-eqty : ∀ {𝕄 γ} {s t : Expr EqTy 𝕄 γ} → s ≈ t\n ≈-eqty {s = expr-eqty} {t = expr-eqty} = ≈-refl\n\n ≈-eqtm : ∀ {𝕄 γ} {s t : Expr EqTm 𝕄 γ} → s ≈ t\n ≈-eqtm {s = expr-eqtm} {t = expr-eqtm} = ≈-refl\n\n ≈-sym : ∀ {cl 𝕄 γ} {t u : Expr cl 𝕄 γ} → t ≈ u → u ≈ t\n ≈-sym (≈-≡ refl) = ≈-≡ refl\n ≈-sym (≈-symb ε) = ≈-symb (λ i → ≈-sym (ε i))\n ≈-sym (≈-meta ε) = ≈-meta (λ i → ≈-sym (ε i))\n\n ≈-trans : ∀ {cl 𝕄 γ} {t u v : Expr cl 𝕄 γ} → t ≈ u → u ≈ v → t ≈ v\n ≈-trans (≈-≡ refl) ξ = ξ\n ≈-trans (≈-symb ζ) (≈-≡ refl) = ≈-symb ζ\n ≈-trans (≈-symb ζ) (≈-symb ξ) = ≈-symb (λ i → ≈-trans (ζ i) (ξ i))\n ≈-trans (≈-meta ζ) (≈-≡ refl) = ≈-meta ζ\n ≈-trans (≈-meta ζ) (≈-meta ξ) = ≈-meta (λ i → ≈-trans (ζ i) (ξ i))\n\n -- the setoid of expressions\n\n Expr-setoid : ∀ (cl : Class) (𝕄 : MShape) (γ : VShape) → Setoid lzero lzero\n Expr-setoid cl 𝕄 γ =\n record\n { Carrier = Expr cl 𝕄 γ\n ; _≈_ = _≈_\n ; isEquivalence = record { refl = ≈-refl ; sym = ≈-sym ; trans = ≈-trans }\n }\n\n infix 4 _%_≈_\n\n _%_≈_ : ∀ (𝕊 : Signature) {cl 𝕄 γ} → (t u : Expression.Expr 𝕊 cl 𝕄 γ) → Set\n _%_≈_ 𝕊 = Equality._≈_ {𝕊 = 𝕊}\n", "meta": {"hexsha": "aa2d0cc7e01fac4fc5512ce86b1377cc01333d77", "size": 4279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Syntax.agda", "max_stars_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_stars_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2021-05-25T11:14:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-14T01:48:00.000Z", "max_issues_repo_path": "src/Syntax.agda", "max_issues_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_issues_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "max_issues_repo_licenses": ["MIT"], "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/Syntax.agda", "max_forks_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_forks_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "max_forks_repo_licenses": ["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.2335766423, "max_line_length": 112, "alphanum_fraction": 0.5024538444, "num_tokens": 2033, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357598021708, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.5947427069089133}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import homotopy.elims.Lemmas\nopen import homotopy.elims.CofPushoutSection\n\nmodule homotopy.elims.SuspSmash {i j k} {X : Ptd i} {Y : Ptd j}\n {P : Suspension (X ∧ Y) → Type k}\n (north* : P north) (south* : P south)\n (cod* : (s : fst X × fst Y) → north* == south* [ P ↓ merid (cfcod s) ])\n where\n\nprivate\n base* = transport (λ κ → north* == south* [ P ↓ merid κ ])\n (! (cfglue (winl (snd X))))\n (cod* (snd X , snd Y))\n\n coh* : (s : X ∧ Y) → north* == south* [ P ↓ merid s ]\n coh* = CofPushoutSection.elim (λ _ → tt) (λ _ → idp)\n base*\n (λ {(x , y) →\n (fst (fillX x) ∙ fst (fillY y)) ◃ fst fill0 ◃ cod* (x , y)})\n (↓↓-from-squareover ∘ λ x →\n snd (fillX x) ↓⊡h∙\n ap (λ p → p ◃ fst fill0 ◃ cod* (x , snd Y))\n (! (ap (λ q → fst (fillX x) ∙ q) fillY-lemma ∙ ∙-unit-r _)))\n (↓↓-from-squareover ∘ λ y →\n snd (fillY y) ↓⊡h∙\n ap (λ p → p ◃ fst fill0 ◃ cod* (snd X , y))\n (! (ap (λ q → q ∙ fst (fillY y)) fillX-lemma)))\n where\n fill-lemma : (w : X ∨ Y)\n (α : north* == south* [ P ↓ merid (cfcod (∨-in-× X Y w)) ])\n → Σ (north* == north*)\n (λ p → SquareOver P (natural-square merid (cfglue w))\n base*\n (↓-ap-in _ _ (apd (λ _ → north*) (cfglue w)))\n (↓-ap-in _ _ (apd (λ _ → south*) (cfglue w)))\n (p ◃ α))\n fill-lemma w α = fill-upper-right _ _ _ _ _\n\n fill0 = fill-lemma (winl (snd X)) (cod* (snd X , snd Y))\n fillX = λ x → fill-lemma (winl x) (fst fill0 ◃ cod* (x , snd Y))\n fillY = λ y → fill-lemma (winr y) (fst fill0 ◃ cod* (snd X , y))\n\n fillX-lemma : fst (fillX (snd X)) == idp\n fillX-lemma = ! $\n fill-upper-right-unique _ _ _ _ _ idp (snd fill0 ↓⊡h∙ ! (idp◃ _))\n\n fillY-lemma : fst (fillY (snd Y)) == idp\n fillY-lemma = ! $\n fill-upper-right-unique _ _ _ _ _ idp (snd fill0 ↓⊡h∙ ! (idp◃ _))\n ∙ ap (λ w → fst (fill-lemma w (fst fill0 ◃ cod* (∨-in-× X Y w))))\n wglue\n\nsusp-smash-elim : Π (Suspension (X ∧ Y)) P\nsusp-smash-elim = Suspension-elim north* south* coh*\n", "meta": {"hexsha": "d7ef8fccba58384166121778db0eeb3f1539936d", "size": 2120, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/elims/SuspSmash.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/elims/SuspSmash.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/elims/SuspSmash.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": 36.5517241379, "max_line_length": 73, "alphanum_fraction": 0.5014150943, "num_tokens": 836, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5947427060559631}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Decidable setoid membership over lists\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Decidable; DecSetoid)\n\nmodule Data.List.Membership.DecSetoid {a ℓ} (DS : DecSetoid a ℓ) where\n\nopen import Data.List.Relation.Unary.Any using (any)\nopen DecSetoid DS\n\n------------------------------------------------------------------------\n-- Re-export contents of propositional membership\n\nopen import Data.List.Membership.Setoid (DecSetoid.setoid DS) public\n\n------------------------------------------------------------------------\n-- Other operations\n\ninfix 4 _∈?_\n\n_∈?_ : Decidable _∈_\nx ∈? xs = any (x ≟_) xs\n", "meta": {"hexsha": "9aedee23edd5540a0642bdbaed10f82056d797d8", "size": 806, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Membership/DecSetoid.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/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/List/Membership/DecSetoid.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": 28.7857142857, "max_line_length": 72, "alphanum_fraction": 0.4665012407, "num_tokens": 155, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357460591568, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5947426919154443}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\nmodule groups.Image where\n\nmodule _ {i j k} {G : Group i} {H : Group j}\n {K : Group k} (φ : H →ᴳ K) (ψ : G →ᴳ H) where\n\n abstract\n im-sub-im-∘ : is-surjᴳ ψ → im-propᴳ φ ⊆ᴳ im-propᴳ (φ ∘ᴳ ψ)\n im-sub-im-∘ ψ-is-surj k = Trunc-rec Trunc-level\n (λ{(h , φh=k) → Trunc-rec Trunc-level\n (λ{(g , ψg=h) → [ g , ap (GroupHom.f φ) ψg=h ∙ φh=k ]})\n (ψ-is-surj h)})\n\n im-∘-sub-im : im-propᴳ (φ ∘ᴳ ψ) ⊆ᴳ im-propᴳ φ\n im-∘-sub-im k = Trunc-rec Trunc-level\n (λ{(g , φψg=k) → [ GroupHom.f ψ g , φψg=k ]})\n\n im-iso-im-pre∘ : is-surjᴳ ψ → Im φ ≃ᴳ Im (φ ∘ᴳ ψ)\n im-iso-im-pre∘ ψ-is-surj = Subgroup-emap-r\n (im-propᴳ φ) (im-propᴳ (φ ∘ᴳ ψ))\n (im-sub-im-∘ ψ-is-surj) im-∘-sub-im\n", "meta": {"hexsha": "702b0d307be35589dc1dd33b48e3f9a0a82b4813", "size": 758, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/groups/Image.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/Image.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/Image.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.32, "max_line_length": 63, "alphanum_fraction": 0.5316622691, "num_tokens": 380, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391685381605, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.594645019252531}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- A Monad in a Bicategory.\n-- For the more elementary version of Monads, see 'Categories.Monad'.\nmodule Categories.Bicategory.Monad where\n\nopen import Level\nopen import Data.Product using (_,_)\n\nopen import Categories.Bicategory\nimport Categories.Bicategory.Extras as Bicat\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)\n\n\nrecord Monad {o ℓ e t} (𝒞 : Bicategory o ℓ e t) : Set (o ⊔ ℓ ⊔ e ⊔ t) where\n open Bicat 𝒞\n\n field\n C : Obj\n T : C ⇒₁ C\n η : id₁ ⇒₂ T\n μ : (T ⊚₀ T) ⇒₂ T\n\n assoc : μ ∘ᵥ (T ▷ μ) ∘ᵥ associator.from ≈ (μ ∘ᵥ (μ ◁ T))\n sym-assoc : μ ∘ᵥ (μ ◁ T) ∘ᵥ associator.to ≈ (μ ∘ᵥ (T ▷ μ))\n identityˡ : μ ∘ᵥ (T ▷ η) ∘ᵥ unitorʳ.to ≈ id₂\n identityʳ : μ ∘ᵥ (η ◁ T) ∘ᵥ unitorˡ.to ≈ id₂\n", "meta": {"hexsha": "b78750c067cc0913374f11644c8757e3c54385e1", "size": 797, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Bicategory/Monad.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/Bicategory/Monad.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/Bicategory/Monad.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.4642857143, "max_line_length": 90, "alphanum_fraction": 0.6361355082, "num_tokens": 322, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9230391706552536, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.5946449953965264}} {"text": "\n-- Forced constructor arguments don't count towards the size of the datatype\n-- (only if not --withoutK).\n\ndata _≡_ {a} {A : Set a} : A → A → Set where\n refl : ∀ x → x ≡ x\n\ndata Singleton {a} {A : Set a} : A → Set where\n [_] : ∀ x → Singleton x\n", "meta": {"hexsha": "c93cb7234ea09dd012a710b75c6f30bbb5a8683e", "size": 248, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/LargeIndices.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/LargeIndices.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/LargeIndices.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": 24.8, "max_line_length": 76, "alphanum_fraction": 0.5967741935, "num_tokens": 84, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8311430478583168, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.5946196803664516}} {"text": "module Implicits.Syntax.Type.Constructors where\n\nopen import Prelude\nopen import Implicits.Syntax.Type\nopen import Implicits.Substitutions\nopen TypeSubst\n\n-- polymorphic identity\ntid : ∀ {n} → Type n\ntid = ∀' (simpl ((TVar zero) →' (TVar zero)))\n\n-- type of bools encoding\ntbool : Type 0\ntbool = ∀' (simpl ((TVar zero) →' (simpl ((TVar zero) →' (TVar zero)))))\n\n-- church numerals\ntnat : Type 0\ntnat = ∀' (simpl ((simpl ((TVar zero) →' (TVar zero))) →' (simpl ((TVar zero) →' (TVar zero)))))\n\n-- existential quantification\n∃' : ∀ {n} → (Type (suc n)) → Type n\n∃' a = ∀' (∀' (simpl ((a tp/tp (wk ↑)) →' (simpl ((TVar (suc zero)) →' (TVar zero))))))\n\n-- unit type\n⊤' : ∀ {n} → Type n\n⊤' = tid\n\n-- 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 →ⁿ (simpl (a →' z))\n\n-- Record/finite tuple\nrec : ∀ {n k} → Vec (Type n) k → Type n\nrec [] = ⊤'\nrec (a ∷ as) = ∀' (simpl ((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": "aa7b2b89d99c518b1018accf58dc588639a50141", "size": 1127, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Implicits/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/Implicits/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/Implicits/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": 24.5, "max_line_length": 96, "alphanum_fraction": 0.5510204082, "num_tokens": 465, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8311430311279739, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.5946196633541779}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Sublist-related properties\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.List.Relation.Binary.Sublist.Propositional.Properties {a} {A : Set a} where\n\nopen import Data.List using (map)\nopen import Data.List.Relation.Unary.Any using (Any; here; there)\nopen import Data.List.Relation.Unary.Any.Properties using (here-injective; there-injective)\nopen import Data.List.Relation.Binary.Sublist.Propositional\n hiding (map)\nimport Data.List.Relation.Binary.Sublist.Setoid.Properties\n as SetoidProperties\nopen import Function\nopen import Relation.Binary.PropositionalEquality as P hiding ([_])\nopen import Relation.Unary as U using (Pred)\n\n------------------------------------------------------------------------\n-- Re-exporting setoid properties\n\nopen SetoidProperties (P.setoid A) public\n hiding (map⁺)\n\n------------------------------------------------------------------------\n-- map\n\nmodule _ {b} {B : Set b} where\n\n map⁺ : ∀ {as bs} (f : A → B) → as ⊆ bs → map f as ⊆ map f bs\n map⁺ f = SetoidProperties.map⁺ (setoid A) (setoid B) (cong f)\n\n------------------------------------------------------------------------\n-- The `lookup` function induced by a proof that `xs ⊆ ys` is injective\n\nmodule _ {p} {P : Pred A p} where\n\n lookup-injective : ∀ {xs ys} {p : xs ⊆ ys} {v w : Any P xs} →\n lookup p v ≡ lookup p w → v ≡ w\n lookup-injective {p = []} {}\n lookup-injective {p = _ ∷ʳ _} {v} {w} =\n lookup-injective ∘′ there-injective\n lookup-injective {p = x≡y ∷ _} {here pv} {here pw} =\n cong here ∘′ subst-injective x≡y ∘′ here-injective\n lookup-injective {p = _ ∷ _} {there v} {there w} =\n cong there ∘′ lookup-injective ∘′ there-injective\n lookup-injective {p = _ ∷ _} {here _} {there _} ()\n lookup-injective {p = _ ∷ _} {there _} {here _} ()\n", "meta": {"hexsha": "9916d43b6c0f92e468076f3ec59063f7c8226ce9", "size": 1991, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Propositional/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/Sublist/Propositional/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/Sublist/Propositional/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": 38.2884615385, "max_line_length": 91, "alphanum_fraction": 0.5349070819, "num_tokens": 520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696748, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.5944887307906763}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Algebra.Group.Action 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\nopen import Cubical.Algebra.Group.Base\nopen import Cubical.Algebra.Group.Morphism\nopen import Cubical.Algebra.Group.Properties\nopen import Cubical.Algebra.Group.Notation\nopen import Cubical.Algebra.Group.MorphismProperties\nopen import Cubical.Structures.LeftAction\nopen import Cubical.Structures.Axioms\nopen import Cubical.Structures.Macro\nopen import Cubical.Structures.Auto\nopen import Cubical.Data.Sigma\n\nprivate\n variable\n ℓ ℓ' : Level\n\nrecord IsGroupAction (G : Group {ℓ = ℓ})\n (H : Group {ℓ = ℓ'})\n (_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩) : Type (ℓ-max ℓ ℓ') where\n \n constructor isgroupaction\n\n open GroupNotationG G\n\n field\n isHom : (g : ⟨ G ⟩) → isGroupHom H H (g α_)\n identity : (h : ⟨ H ⟩) → 0ᴳ α h ≡ h\n assoc : (g g' : ⟨ G ⟩) → (h : ⟨ H ⟩) → (g +ᴳ g') α h ≡ g α (g' α h)\n\nrecord GroupAction (G : Group {ℓ}) (H : Group {ℓ'}): Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n\n constructor groupaction\n\n field\n _α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩\n isGroupAction : IsGroupAction G H _α_\n\nmodule ActionΣTheory {ℓ ℓ' : Level} where\n\n module _ (G : Group {ℓ}) (H : Group {ℓ'}) (_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩) where\n\n open GroupNotationG G\n\n IsGroupActionΣ : Type (ℓ-max ℓ ℓ')\n IsGroupActionΣ = ((g : ⟨ G ⟩) → isGroupHom H H (g α_))\n × ((h : ⟨ H ⟩) → 0ᴳ α h ≡ h)\n × ((g g' : ⟨ G ⟩) → (h : ⟨ H ⟩) → (g +ᴳ g') α h ≡ g α (g' α h))\n\n isPropIsGroupActionΣ : isProp IsGroupActionΣ\n isPropIsGroupActionΣ = isPropΣ isPropIsHom λ _ → isPropΣ isPropIdentity λ _ → isPropAssoc\n where\n isPropIsHom = isPropΠ (λ g → isPropIsGroupHom H H)\n isPropIdentity = isPropΠ (λ h → GroupStr.is-set (snd H) (0ᴳ α h) h)\n isPropAssoc = isPropΠ3 (λ g g' h → GroupStr.is-set (snd H) ((g +ᴳ g') α h) (g α (g' α h)))\n\n IsGroupAction→IsGroupActionΣ : IsGroupAction G H _α_ → IsGroupActionΣ\n IsGroupAction→IsGroupActionΣ (isgroupaction isHom identity assoc) = isHom , identity , assoc\n\n IsGroupActionΣ→IsGroupAction : IsGroupActionΣ → IsGroupAction G H _α_\n IsGroupActionΣ→IsGroupAction (isHom , identity , assoc) = isgroupaction isHom identity assoc\n\n IsGroupActionΣIso : Iso (IsGroupAction G H _α_) IsGroupActionΣ\n Iso.fun IsGroupActionΣIso = IsGroupAction→IsGroupActionΣ\n Iso.inv IsGroupActionΣIso = IsGroupActionΣ→IsGroupAction \n Iso.rightInv IsGroupActionΣIso = λ _ → refl\n Iso.leftInv IsGroupActionΣIso = λ _ → refl\n\nopen ActionΣTheory\n\nisPropIsGroupAction : {ℓ ℓ' : Level }\n (G : Group {ℓ}) (H : Group {ℓ'})\n (_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩)\n → isProp (IsGroupAction G H _α_)\nisPropIsGroupAction G H _α_ = isOfHLevelRespectEquiv 1\n (invEquiv (isoToEquiv (IsGroupActionΣIso G H _α_)))\n (isPropIsGroupActionΣ G H _α_)\n\n\nmodule ActionNotationα {N : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction H N) where\n _α_ = GroupAction._α_ Act\n private\n isGroupAction = GroupAction.isGroupAction Act\n α-id = IsGroupAction.identity isGroupAction\n α-hom = IsGroupAction.isHom isGroupAction\n α-assoc = IsGroupAction.assoc isGroupAction\n\nmodule ActionLemmas {G : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction G H) where\n open ActionNotationα {N = H} {H = G} Act\n open GroupNotationᴴ H\n open GroupNotationG G\n open MorphismLemmas {G = H} {H = H}\n open GroupLemmas\n\n abstract\n actOnUnit : (g : ⟨ G ⟩) → g α 0ᴴ ≡ 0ᴴ\n actOnUnit g = mapId (grouphom (g α_) (α-hom g))\n\n actOn-Unit : (g : ⟨ G ⟩) → g α (-ᴴ 0ᴴ) ≡ 0ᴴ\n actOn-Unit g = (cong (g α_) (invId H)) ∙ actOnUnit g\n\n actOn- : (g : ⟨ G ⟩) (h : ⟨ H ⟩) → g α (-ᴴ h) ≡ -ᴴ (g α h)\n actOn- g h = mapInv (grouphom (g α_) (α-hom g)) h\n\n -idAct : (h : ⟨ H ⟩) → (-ᴳ 0ᴳ) α h ≡ h\n -idAct h = (cong (_α h) (invId G)) ∙ (α-id h)\n\n-- Examples\n-- left adjoint action of a group on a normal subgroup\n", "meta": {"hexsha": "655ec4a63580e18d0699a3b2e78dd35b45bb1cab", "size": 4298, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Action.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/Action.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/Action.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.735042735, "max_line_length": 104, "alphanum_fraction": 0.6263378315, "num_tokens": 1511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738057795403, "lm_q2_score": 0.7401743735019595, "lm_q1q2_score": 0.5944886685060558}} {"text": "-- Andreas, 2015-07-18\n-- Postpone checking of record expressions when type is blocked.\n-- Guess type of record expressions when type is blocked.\n\nopen import Common.Product\nopen import Common.Prelude\nopen import Common.Equality\n\nT : Bool → Set\nT true = Bool × Nat\nT false = ⊥\n\nworks : (P : ∀{b} → b ≡ true → T b → Set) → Set\nworks P = P refl record{ proj₁ = true; proj₂ = 0 }\n\n-- Guess or postpone.\ntest : (P : ∀{b} → T b → b ≡ true → Set) → Set\ntest P = P record{ proj₁ = true; proj₂ = 0 } refl\n\nguess : (P : ∀{b} → T b → Set) → Set\nguess P = P record{ proj₁ = true; proj₂ = 0 }\n\nrecord R : Set where\n field\n f : Bool\n\nrecord S : Set where\n field\n f : Bool\n\nU : Bool → Set\nU true = R\nU false = S\n\npostpone : (P : ∀{b} → U b → b ≡ true → Set) → Set\npostpone P = P record{ f = false } refl\n\n-- ambiguous : (P : ∀{b} → U b → Set) → Set\n-- ambiguous P = P record{ f = false }\n", "meta": {"hexsha": "8c7ab7d0a106183733a8a81392d3163b957f20c8", "size": 883, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/PostponeRecordExpr.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/PostponeRecordExpr.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/PostponeRecordExpr.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.075, "max_line_length": 64, "alphanum_fraction": 0.6002265006, "num_tokens": 305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.5944886523249244}} {"text": "-- Andreas, 2015-06-11\n-- testing with in copattern matching with dependent record\n\n-- {-# OPTIONS -v tc.with:20 #-}\n\nopen import Common.Prelude\nopen import Common.Equality\n\ndata Dec P : Set where\n yes : (p : P) → Dec P\n no : (¬p : P → ⊥) → Dec P\n\npostulate\n _≟_ : (n m : Nat) → Dec (n ≡ m)\n boring : {A : Set} → A\n\nrecord R : Set₁ where\n field\n Car : Set\n el : Car\n same : (x : Car) → Dec (x ≡ el)\n\ntest : (n : Nat) → R\nR.Car (test n) = Nat\nR.el (test n) = n\nR.same (test zero) zero = yes refl\nR.same (test zero) (suc x) = no λ()\nR.same (test (suc n)) zero = no λ()\nR.same (test (suc n)) (suc x) with n ≟ x\nR.same (test (suc n)) (suc .n) | yes refl = yes refl\nR.same (test (suc n)) (suc x) | no ¬p = no boring\n", "meta": {"hexsha": "0d64c5b9a927cb64b712ba20d655f99b2a55407f", "size": 732, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1546.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/Issue1546.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/Issue1546.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": 22.875, "max_line_length": 59, "alphanum_fraction": 0.5655737705, "num_tokens": 287, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392725805823, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.5943676378836511}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties for Conats\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe --sized-types #-}\n\nmodule Codata.Conat.Properties where\n\nopen import Size\nopen import Data.Nat.Base using (ℕ; zero; suc)\nopen import Codata.Thunk\nopen import Codata.Conat\nopen import Codata.Conat.Bisimilarity\nopen import Function\nopen import Relation.Nullary\nopen import Relation.Nullary.Decidable using (map′)\nopen import Relation.Binary\n\nprivate\n variable\n i : Size\n\n0∸m≈0 : ∀ m → i ⊢ zero ∸ m ≈ zero\n0∸m≈0 zero = refl\n0∸m≈0 (suc m) = 0∸m≈0 m\n\nsℕ≤s⁻¹ : ∀ {m n} → suc m ℕ≤ suc n → m ℕ≤ n .force\nsℕ≤s⁻¹ (sℕ≤s p) = p\n\n_ℕ≤?_ : Decidable _ℕ≤_\nzero ℕ≤? n = yes zℕ≤n\nsuc m ℕ≤? zero = no (λ ())\nsuc m ℕ≤? suc n = map′ sℕ≤s sℕ≤s⁻¹ (m ℕ≤? n .force)\n\n0ℕ+-identity : ∀ {n} → i ⊢ 0 ℕ+ n ≈ n\n0ℕ+-identity = refl\n\n+ℕ0-identity : ∀ {n} → i ⊢ n +ℕ 0 ≈ n\n+ℕ0-identity {n = zero} = zero\n+ℕ0-identity {n = suc n} = suc λ where .force → +ℕ0-identity\n", "meta": {"hexsha": "12dfbaef6f703c7485e9f11ff3aa1d8d49e7b16d", "size": 1080, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Codata/Conat/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/Codata/Conat/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/Codata/Conat/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": 25.1162790698, "max_line_length": 72, "alphanum_fraction": 0.5481481481, "num_tokens": 410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711756575749, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5943461076781443}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommAlgebra.Instances.Initial where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\n\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Sigma.Properties using (Σ≡Prop)\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.Algebra.Base using (IsAlgebraHom)\nopen import Cubical.Algebra.CommAlgebra.Base\n\nprivate\n variable\n ℓ : Level\n\nmodule _ ((R , str) : CommRing ℓ) where\n\n initialCAlg : CommAlgebra (R , str) ℓ\n initialCAlg =\n let open CommRingStr str\n in (R , commalgebrastr _ _ _ _ _ (λ r x → r · x)\n (makeIsCommAlgebra (isSetRing (CommRing→Ring (R , str)))\n +Assoc +Rid +Rinv +Comm\n ·Assoc ·Lid\n ·Ldist+ ·Comm\n (λ x y z → sym (·Assoc x y z)) ·Ldist+ ·Rdist+ ·Lid\n λ x y z → sym (·Assoc x y z)))\n\n\n module _ (A : CommAlgebra (R , str) ℓ) where\n open CommAlgebraStr ⦃... ⦄\n private\n instance\n _ : CommAlgebraStr (R , str) (fst A)\n _ = snd A\n _ : CommAlgebraStr (R , str) R\n _ = snd initialCAlg\n\n _*_ : R → (fst A) → (fst A)\n r * a = CommAlgebraStr._⋆_ (snd A) r a\n\n initialMap : CommAlgebraHom initialCAlg A\n initialMap =\n makeCommAlgebraHom {M = initialCAlg} {N = A}\n (λ r → r * 1a)\n (⋆-lid _)\n (λ x y → ⋆-ldist x y 1a)\n (λ x y → (x · y) * 1a ≡⟨ ⋆-assoc _ _ _ ⟩\n x * (y * 1a) ≡[ i ]⟨ x * (·Lid (y * 1a) (~ i)) ⟩\n x * (1a · (y * 1a)) ≡⟨ sym (⋆-lassoc _ _ _) ⟩\n (x * 1a) · (y * 1a) ∎)\n (λ r x → (r · x) * 1a ≡⟨ ⋆-assoc _ _ _ ⟩\n (r * (x * 1a)) ∎)\n\n initialMapEq : (f : CommAlgebraHom initialCAlg A)\n → f ≡ initialMap\n initialMapEq f =\n let open IsAlgebraHom (snd f)\n in Σ≡Prop\n (isPropIsCommAlgebraHom {M = initialCAlg} {N = A})\n λ i x →\n ((fst f) x ≡⟨ cong (fst f) (sym (·Rid _)) ⟩\n fst f (x · 1a) ≡⟨ pres⋆ x 1a ⟩\n CommAlgebraStr._⋆_ (snd A) x (fst f 1a) ≡⟨ cong\n (λ u → (snd A CommAlgebraStr.⋆ x) u)\n pres1 ⟩\n (CommAlgebraStr._⋆_ (snd A) x 1a) ∎) i\n\n initialityIso : Iso (CommAlgebraHom initialCAlg A) (Unit* {ℓ = ℓ})\n initialityIso = iso (λ _ → tt*)\n (λ _ → initialMap)\n (λ {tt*x → refl})\n λ f → sym (initialMapEq f)\n\n initialityPath : CommAlgebraHom initialCAlg A ≡ Unit*\n initialityPath = isoToPath initialityIso\n", "meta": {"hexsha": "8e8e630997d1567a08f71348f9f5aa3fc6bdec83", "size": 2924, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Initial.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/Algebra/CommAlgebra/Instances/Initial.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/CommAlgebra/Instances/Initial.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": 36.0987654321, "max_line_length": 95, "alphanum_fraction": 0.4815321477, "num_tokens": 946, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583695, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.5943461023388844}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Morphism.Cartesian where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Functor hiding (_≡_; _∘_)\n\nrecord CartesianProperties {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} \n {E : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} \n {p : Functor E B} {e′ e} {φ : E [ e′ , e ]}\n {e′′ : Category.Obj E} {ψ : E [ e′′ , e ]}\n {g : B [ Functor.F₀ p e′′ , Functor.F₀ p e′ ]}\n (pf : Category._≡_ B (Category._∘_ B (Functor.F₁ p φ) g) (Functor.F₁ p ψ)) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ ℓ₁ ⊔ e₁) where\n private module E = Category E\n private module B = Category B\n open B using (_∘_; _≡_)\n open E using () renaming (_∘_ to _∘E_; _≡_ to _≡E_)\n open Functor p renaming (F₀ to p₀; F₁ to p₁)\n\n field\n χ : E [ e′′ , e′ ]\n ψ≡φ∘χ : ψ ≡E φ ∘E χ\n p₁[χ]≡g : p₁ χ ≡ g\n\n χ-unique : (f : E [ e′′ , e′ ]) → ψ ≡E φ ∘E f → p₁ f ≡ g → f ≡E χ\n\n\nrecord Cartesian {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {E : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} (p : Functor E B) {e′ e} (φ : E [ e′ , e ]) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ ℓ₁ ⊔ e₁) where\n private module E = Category E\n private module B = Category B\n open B using (_∘_; _≡_)\n open E using () renaming (_∘_ to _∘E_; _≡_ to _≡E_)\n open Functor p renaming (F₀ to p₀; F₁ to p₁)\n\n field\n properties : ∀ {e′′} (ψ : E [ e′′ , e ]) (g : B [ p₀ e′′ , p₀ e′ ]) (pf : p₁ φ ∘ g ≡ p₁ ψ) → CartesianProperties {p = p} pf\n", "meta": {"hexsha": "8d74f01636e8cee41a024c4bb7fa63892419a545", "size": 1515, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Morphism/Cartesian.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/Morphism/Cartesian.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/Morphism/Cartesian.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.8684210526, "max_line_length": 167, "alphanum_fraction": 0.5155115512, "num_tokens": 623, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84997116805678, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.5943460970361804}} {"text": "module Structure.Operator.Field.VectorSpace where\n\nimport Lvl\nopen import Structure.Setoid\nopen import Structure.Operator.Field\nopen import Structure.Operator.Properties using (associativity ; identityₗ ; distributivityᵣ)\nopen import Structure.Operator.Vector\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 ⦃ [⋅]-oper : BinaryOperator(_⋅_) ⦄\n (field-structure : Field{T = T}(_+_)(_⋅_))\n where\n open Field(field-structure)\n\n fieldVectorSpace : VectorSpace(_+_)(_⋅_)(_+_)(_⋅_)\n VectorSpace.scalarField fieldVectorSpace = field-structure\n VectorSpace.[⋅ₛᵥ]-binaryOperator fieldVectorSpace = [⋅]-oper\n VectorSpace.[⋅ₛ][⋅ₛᵥ]-compatibility fieldVectorSpace = associativity(_⋅_)\n VectorSpace.[⋅ₛᵥ][+ᵥ]-distributivityₗ fieldVectorSpace = [⋅][+]-distributivityₗ\n VectorSpace.[⋅ₛᵥ][+ₛ][+ᵥ]-distributivityᵣ fieldVectorSpace = distributivityᵣ(_⋅_)(_+_)\n", "meta": {"hexsha": "74210b12b4aec24d32a9c3bd9163a46cd6d49820", "size": 1077, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Field/VectorSpace.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/Field/VectorSpace.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/Field/VectorSpace.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.1379310345, "max_line_length": 93, "alphanum_fraction": 0.7121634169, "num_tokens": 384, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9124361700013356, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.5943197256771519}} {"text": "module Simple where\n\nopen import Data.Nat renaming (_≟_ to _≟ℕ_)\nopen import Data.Fin hiding (_+_; inject)\nopen import Data.String hiding (_++_) renaming (_≟_ to _≟S_)\nopen import Relation.Nullary using (¬_; yes; no)\nopen import Relation.Binary.PropositionalEquality using (refl; _≡_)\n\nopen import Data.List\n\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\n\nFName : Set\nFName = String\n\nFNames : Set\nFNames = List FName\n\ndata Expr : ℕ → Set where\n num : ∀ {n} → ℕ → Expr n\n bv : ∀ {n} → (i : Fin n) → Expr n\n fv : ∀ {n} → (x : FName) → Expr n\n ƛ : ∀ {n} → (e : Expr (suc n)) → Expr n\n _·_ : ∀ {n} → (f : Expr n) → (e : Expr n) → Expr n\n\n-- This idx indicates the amount of existence of lambda\n-- out of current express\n\nExpr0 : Set\nExpr0 = Expr zero\n\n↓ℕ≠ℕ : ∀ {n m} {i : Fin m}\n → ¬ (suc n ≡ toℕ (suc i))\n → ¬ (n ≡ toℕ i)\n↓ℕ≠ℕ {n} {m} {i} sn≠si n≡i rewrite n≡i = sn≠si refl\n-- ↓ℕ≠ℕ {n} {m} {i} sn≠si n≡i with n≡i\n-- ↓ℕ≠ℕ sn≠si n≡i | refl = sn≠si refl\n\n↓fin : ∀ {n} → (i : Fin (suc n)) → ¬ (n ≡ toℕ i) → Fin n\n↓fin {zero} zero 0≠0 with 0≠0 refl\n↓fin {zero} zero 0≠0 | ()\n↓fin {zero} (suc ()) 0≠n\n↓fin {suc n} zero i≠0 = zero\n↓fin {suc n} (suc i) sn≠si = suc (↓fin i (↓ℕ≠ℕ sn≠si))\n\n↑expr : ∀ {n} → Expr n → Expr (suc n)\n↑expr (num i) = num i\n↑expr (bv i) = bv (inject₁ i)\n-- inject₁ : ∀ {m} → Fin m → Fin (suc m)\n↑expr (fv x) = fv x\n↑expr (ƛ e) = ƛ (↑expr e)\n↑expr (e · e₁) = ↑expr e · ↑expr e₁\n\n{- substitution for bounded and free variable-}\n\n[_↦_] : ∀ n → Expr n → Expr (suc n) → Expr n\n[ m ↦ t ] (num i) = num i\n[ m ↦ t ] (bv i) with m ≟ℕ toℕ i\n... | yes m=i = t\n... | no m≠i = bv (↓fin i m≠i)\n[ m ↦ t ] (fv x) = fv x\n[ m ↦ t ] (ƛ e) = ƛ ([ suc m ↦ ↑expr t ] e)\n[ m ↦ t ] (e · e₁) = [ m ↦ t ] e · [ m ↦ t ] e₁\n\n[_↤_] : ∀ n → FName → Expr n → Expr (suc n)\n[ m ↤ name ] (num x) = num x\n[ m ↤ name ] (bv i) = ↑expr (bv i)\n[ m ↤ name ] (fv x) with x ≟S name\n[ m ↤ name ] (fv x) | yes p = bv (fromℕ m)\n[ m ↤ name ] (fv x) | no ¬p = fv x\n[ m ↤ name ] (ƛ t) = ƛ ([ suc m ↤ name ] t)\n[ m ↤ name ] (t · t₁) = [ m ↤ name ] t · [ m ↤ name ] t₁\n\n[_↝_] : ∀ {n} → FName → Expr n → Expr n → Expr n\n[ n ↝ t ] (num i) = num i\n[ n ↝ t ] (bv i) = bv i\n[ n ↝ t ] (fv x) with n ≟S x\n[ n ↝ t ] (fv x) | yes p = t\n[ n ↝ t ] (fv x) | no ¬p = fv x\n[ n ↝ t ] (ƛ x) = ƛ ([ n ↝ ↑expr t ] x)\n[ n ↝ t ] (x · y) = [ n ↝ t ] x · [ n ↝ t ] y\n\n_₀↦_ : Expr 1 → Expr 0 → Expr 0\nm ₀↦ t = [ 0 ↦ t ] m\n\n\n_↦₀_ : FName → Expr 0 → Expr 1\nname ↦₀ t = [ 0 ↤ name ] t\n\n_₀↤_ : Expr 0 → FName → Expr 1\nt ₀↤ x = [ 0 ↤ x ] t\n\n_₀↝_ : Expr 1 → FName → Expr 0\nx ₀↝ s = x ₀↦ (fv s)\n\nfvars : ∀ {n} → Expr n → FNames\nfvars (num x) = []\nfvars (bv i) = []\nfvars (fv x) = x ∷ []\nfvars (ƛ f) = fvars f\nfvars (f · x) = fvars f ++ fvars x\n\n-- ############################## --\n{- locally closed -}\n-- ############################## --\n\nopen import Data.List.Any as Any\nopen Any.Membership-≡ using (_∈_; _∉_)\nopen import Data.Product\n\ndata LC : ∀ {n} → Expr n → Set where\n numᶜ : ∀ {n} → (i : ℕ) → LC {n} (num i)\n fvᶜ : ∀ {n}\n → (x : FName)\n → LC {n} (fv x)\n _·ᶜ_ : ∀ {n} {f x}\n → LC {n} f\n → LC {n} x\n → LC {n} (f · x)\n ƛᶜ : ∀ {e}\n → (ns : FNames)\n → ( ∀ {x} → x ∉ ns → LC {0} (e ₀↦ fv x) )\n → LC {0} (ƛ e)\n\npostulate fresh-gen : FNames → FName\npostulate fresh-gen-spec : ∀ ns → fresh-gen ns ∉ ns\n\ngenName : (ns : FNames) → ∃ (λ x → x ∉ ns)\ngenName ns = fresh-gen ns , fresh-gen-spec ns\n\norz : ∀ {e} {nn} → nn ↦₀ (e ₀↦ fv nn) ≡ e\norz = {! !}\n\nfoo : ∀ {nn} → (e : Expr 1) → LC {0} (e ₀↦ fv nn) → LC {1} e\nfoo (num i) lcp = {! !}\nfoo (bv i) lcp = {! !}\nfoo (fv y) lcp = {! !}\nfoo (ƛ e) lcp = {! !}\nfoo (f · x) lcp = {! !}\n\nabsᶜ : ∀ {e} → LC {0} (ƛ e) → LC {1} e\nabsᶜ (ƛᶜ ns lcex) = {! !}\n where nn = proj₁ (genName ns)\n nn∉ns = proj₂ (genName ns)\n x = lcex {nn} nn∉ns\n\nappᶜ₁ : ∀ {n} {f x} → LC {n} (f · x) → LC {n} f\nappᶜ₁ (lcf ·ᶜ lcx) = lcf\n\nappᶜ₂ : ∀ {n} {f x} → LC {n} (f · x) → LC {n} x\nappᶜ₂ (lcf ·ᶜ lcx) = lcx\n\nlc? : ∀ {n} → (e : Expr n) → (LC {n} e ⊎ ¬ LC {n} e)\nlc? (num x) = inj₁ (numᶜ x)\nlc? (bv i) = inj₂ (λ ())\nlc? (fv x) = inj₁ (fvᶜ x)\nlc? (ƛ e) with lc? e\nlc? (ƛ e) | inj₁ x = inj₁ {! !}\nlc? (ƛ e) | inj₂ y = inj₂ {! !}\nlc? (f · x) with lc? f | lc? x\nlc? (f · x) | inj₁ f' | inj₁ x' = inj₁ (f' ·ᶜ x')\nlc? (f · x) | inj₁ f' | inj₂ x' = inj₂ (λ p → x' (appᶜ₂ p))\nlc? (f · x) | inj₂ f' | _ = inj₂ (λ p → f' (appᶜ₁ p))\n\n-- ############################## --\n{- value and semantics -}\n-- ############################## --\n\ndata Val : Expr0 → Set where\n num⁰ : ∀ n → Val (num n)\n ƛ⁰ : ∀ e → Val (ƛ e)\n\nvar? : (e : Expr0) → (Val e ⊎ ¬ (Val e))\nvar? (num i) = inj₁ (num⁰ i)\nvar? (bv i) = inj₂ (λ ())\nvar? (fv x) = inj₂ (λ ())\nvar? (ƛ x) = inj₁ (ƛ⁰ x)\nvar? (x · y) = inj₂ (λ ())\n\n-- don't know what the hell this shit is\ndata _⟼_ : Expr 0 → Expr 0 → Set where\n app : ∀ {body para}\n → ((ƛ body) · para) ⟼ (body ₀↦ para)\n", "meta": {"hexsha": "215b3744b11d0787246c14e7982de37426b167e8", "size": 4963, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "another/Simple.agda", "max_stars_repo_name": "jaiyalas/ParametricLambda", "max_stars_repo_head_hexsha": "ee174590136f7162af308502233e5317b009a858", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-10-15T05:57:05.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-15T05:57:52.000Z", "max_issues_repo_path": "another/Simple.agda", "max_issues_repo_name": "jaiyalas/haha", "max_issues_repo_head_hexsha": "ee174590136f7162af308502233e5317b009a858", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "another/Simple.agda", "max_forks_repo_name": "jaiyalas/haha", "max_forks_repo_head_hexsha": "ee174590136f7162af308502233e5317b009a858", "max_forks_repo_licenses": ["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.972826087, "max_line_length": 67, "alphanum_fraction": 0.4555712271, "num_tokens": 2348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152497, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.594316320092383}} {"text": "-- Very simple facts about natural numbers\nmodule NatSimple where\n\nimport Data.Fin as F\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 _○_) \nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nopen import FT\n\n------------------------------------------------------------------------------\n-- Equivalences (not used)\n\ndata Dec (A : Set) : Set where\n yes : A → Dec A\n no : (A → ⊥) → Dec A\n \nsucEq : {n : ℕ} → (i j : F.Fin n) → (F.suc i) ≡ (F.suc j) → i ≡ j\nsucEq i .i refl = refl\n\n_=F=_ : {n : ℕ} → (i j : F.Fin n) → Dec (i ≡ j)\nF.zero =F= F.zero = yes refl\n(F.suc i) =F= F.zero = no (λ ())\nF.zero =F= (F.suc j) = no (λ ())\n(F.suc i) =F= (F.suc j) with i =F= j\n(F.suc i) =F= (F.suc .i) | yes refl = yes refl \n(F.suc i) =F= (F.suc j) | no p = no (λ q → p (sucEq i j q))\n\n------------------------------------------------------------------\n-- Finite Types and the natural numbers are intimately related.\n\ntoℕ : FT → ℕ\ntoℕ ZERO = zero\ntoℕ ONE = suc zero\ntoℕ (PLUS b₀ b₁) = (toℕ b₀) + (toℕ b₁) \ntoℕ (TIMES b₀ b₁) = (toℕ b₀) * (toℕ b₁)\n\nfromℕ : ℕ → FT\nfromℕ zero = ZERO\nfromℕ (suc n) = PLUS ONE (fromℕ n)\n\nnormalize : FT → FT\nnormalize = fromℕ ○ toℕ\n\nassocr : {m : ℕ} (n : ℕ) → (PLUS (fromℕ n) (fromℕ m)) ⇛ fromℕ (n + m)\nassocr zero = unite₊⇛\nassocr (suc n) = assocr₊⇛ ◎ (id⇛ ⊕ (assocr n))\n\ndistr : (n₀ : ℕ) {n₁ : ℕ} → TIMES (fromℕ n₀) (fromℕ n₁) ⇛ fromℕ (n₀ * n₁)\ndistr zero = distz⇛\ndistr (suc n) {m} = dist⇛ ◎ (unite⋆⇛ ⊕ distr n) ◎ assocr m\n\nnormal : (b : FT) → b ⇛ normalize b\nnormal ZERO = id⇛\nnormal ONE = uniti₊⇛ ◎ swap₊⇛\nnormal (PLUS b₀ b₁) = (normal b₀ ⊕ normal b₁) ◎ assocr (toℕ b₀)\nnormal (TIMES b₀ b₁) = (normal b₀ ⊗ normal b₁) ◎ distr (toℕ b₀)\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\n⟦_⟧ℕ : ℕ → Set\n⟦ zero ⟧ℕ = ⊥\n⟦ suc n ⟧ℕ = ⊤ ⊎ ⟦ n ⟧ℕ\n\n-- Take a natural number n, and a value of the type represented by that n,\n-- and return the canonical finite set of size n.\nfromNormalNat : (n : ℕ) → ⟦ n ⟧ℕ → F.Fin n\nfromNormalNat zero ()\nfromNormalNat (suc n) (inj₁ tt) = F.zero\nfromNormalNat (suc n) (inj₂ x) = F.suc (fromNormalNat n x)\n\n-- Take a natural number n, a finite set of size n, and return a\n-- (canonical) value of the type represented by n\ntoNormalNat : (n : ℕ) → F.Fin n → ⟦ n ⟧ℕ\ntoNormalNat zero ()\ntoNormalNat (suc n) F.zero = inj₁ tt\ntoNormalNat (suc n) (F.suc f) = inj₂ (toNormalNat n f)\n\n-- BEGIN CODE COPIED (AND SOMEWHAT MODIFIED) FROM Nat.Properties\n-- (for some reason +-comm is a private field so I can't get to it without\n-- importing superfluous files and going through a bunch of administrative\n-- garbage that isn't worth my time)\n\nm+1+n≡1+m+n : ∀ m n → m + suc n ≡ suc (m + n)\nm+1+n≡1+m+n zero n = refl\nm+1+n≡1+m+n (suc m) n = cong suc (m+1+n≡1+m+n m n)\n\n+-identity : {n : ℕ} → n + zero ≡ n\n+-identity = n+0≡n _\n where\n n+0≡n : (n : ℕ) → n + zero ≡ n\n n+0≡n zero = refl\n n+0≡n (suc n) = cong suc (n+0≡n n)\n\n+-comm : (m n : ℕ) → m + n ≡ n + m \n+-comm zero n = sym +-identity\n+-comm (suc m) n = begin\n suc m + n\n ≡⟨ refl ⟩\n suc (m + n)\n ≡⟨ cong suc (+-comm m n) ⟩\n suc (n + m)\n ≡⟨ sym (m+1+n≡1+m+n n m) ⟩\n n + suc m\n ∎\n\n-- END CODE COPIED FROM Nat.Properties \n\n-- \nadd1modn : ℕ → ℕ → ℕ → ℕ\nadd1modn zero zero acc = zero\nadd1modn zero (suc n) acc = (suc n) + acc\nadd1modn (suc max) zero acc = suc acc\nadd1modn (suc max) (suc n) acc = add1modn max n (suc acc)\n\n-- Useful for testing\none : ℕ\none = suc (zero)\n\ntwo : ℕ\ntwo = suc one\n\nthree : ℕ\nthree = suc two\n\nfour : ℕ\nfour = suc three\n\nfive : ℕ\nfive = suc four\n\nsix : ℕ\nsix = suc five", "meta": {"hexsha": "8d41ffffa5a5e4951e1e38f46910ec5f3d56dbcb", "size": 3890, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/OldUnivalence/NatSimple.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/NatSimple.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/NatSimple.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.5886524823, "max_line_length": 78, "alphanum_fraction": 0.5658097686, "num_tokens": 1543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.819893335913536, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.5943163137122823}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Semirings.Definition\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Semiring\nopen import Orders.Total.Definition\nopen import Orders.Partial.Definition\n\nmodule Numbers.Naturals.Order where\nopen Semiring ℕSemiring\nopen import Decidable.Lemmas ℕDecideEquality\n\nprivate\n infix 5 _ do not export them. \nprivate\n open import Data.Nat using (ℕ)\n open import Data.Fin using (Fin)\n open import Data.Vec using (Vec)\n open import Data.Vec.Properties using (lookup-allFin)\n open import Proofs using (finext; lookupassoc; _!!_)\n \n ∘̂-assoc : {m₁ m₂ m₃ m₄ : ℕ} →\n (a : Vec (Fin m₂) m₁) (b : Vec (Fin m₃) m₂) (c : Vec (Fin m₄) m₃) → \n a ∘̂ (b ∘̂ c) ≡ (a ∘̂ b) ∘̂ c\n ∘̂-assoc a b c = finext (lookupassoc a b c)\n\n ∘̂-rid : {m n : ℕ} → (π : Vec (Fin m) n) → π ∘̂ 1C ≡ π\n ∘̂-rid π = trans (finext (λ i → lookup-allFin (π !! i))) (cauchyext π)\n\n ∘̂-lid : {m n : ℕ} → (π : Vec (Fin m) n) → 1C ∘̂ π ≡ π\n ∘̂-lid π = trans (finext (λ i → cong (_!!_ π) (lookup-allFin i))) (cauchyext π)\n\n------------------------------------------------------------------------------\n-- Properties of concrete permutations that are needed to show that\n-- this is also a symmetric rig groupoid\n\n-- If the forward components are equal, then so are the backward ones\n\nπᵒ≡ : ∀ {m n} → (π₁ π₂ : CPerm m n) → (CPerm.π π₁ ≡ CPerm.π π₂) →\n (CPerm.πᵒ π₁ ≡ CPerm.πᵒ π₂)\nπᵒ≡ {n} (cp π πᵒ αp βp) (cp .π πᵒ₁ αp₁ βp₁) refl =\n begin (\n πᵒ ≡⟨ sym (∘̂-rid πᵒ) ⟩\n πᵒ ∘̂ 1C ≡⟨ cong (_∘̂_ πᵒ) (sym αp₁) ⟩\n πᵒ ∘̂ (π ∘̂ πᵒ₁) ≡⟨ ∘̂-assoc πᵒ π πᵒ₁ ⟩\n (πᵒ ∘̂ π) ∘̂ πᵒ₁ ≡⟨ cong (λ x → x ∘̂ πᵒ₁) βp ⟩\n 1C ∘̂ πᵒ₁ ≡⟨ ∘̂-lid πᵒ₁ ⟩\n πᵒ₁ ∎)\n where open ≡-Reasoning\n\n-- If the forward components are equal, then so are the entire\n-- concrete permutations\n\np≡ : ∀ {m n} → {π₁ π₂ : CPerm m n} → (CPerm.π π₁ ≡ CPerm.π π₂) → π₁ ≡ π₂\np≡ {m} {n} {cp π πᵒ αp βp} {cp .π πᵒ₁ αp₁ βp₁} refl with\n πᵒ≡ (cp π πᵒ αp βp) (cp π πᵒ₁ αp₁ βp₁) refl\np≡ {m} {n} {cp π πᵒ αp βp} {cp .π .πᵒ αp₁ βp₁} refl | refl\n with proof-irrelevance αp αp₁ | proof-irrelevance βp βp₁\np≡ {m} {n} {cp π πᵒ αp βp} {cp .π .πᵒ .αp .βp} refl | refl | refl | refl = refl\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "16caec11276f30601bf73e1b061b62cbc46b3fc2", "size": 2447, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/ConcretePermutationProperties.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/ConcretePermutationProperties.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/ConcretePermutationProperties.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": 39.4677419355, "max_line_length": 81, "alphanum_fraction": 0.5251328157, "num_tokens": 1043, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.5942536307561105}} {"text": "{-# OPTIONS --cubical #-}\nmodule Cubical.Foundations.Equiv.Fiberwise where\n\nopen import Cubical.Core.Everything\n\nopen import Cubical.Foundations.Everything\n\nmodule _ {a p q} {A : Type a} (P : A → Type p) (Q : A → Type q)\n (f : ∀ x → P x → Q x)\n where\n private\n total : (Σ A P) → (Σ A Q)\n total = (\\ p → p .fst , f (p .fst) (p .snd))\n\n -- Thm 4.7.6\n fibers-total : ∀ {xv} → Iso (fiber total (xv)) (fiber (f (xv .fst)) (xv .snd))\n fibers-total {xv} = iso h g h-g g-h\n where\n h : ∀ {xv} → fiber total xv → fiber (f (xv .fst)) (xv .snd)\n h {xv} (p , eq) = J (\\ xv eq → fiber (f (xv .fst)) (xv .snd)) ((p .snd) , refl) eq\n g : ∀ {xv} → fiber (f (xv .fst)) (xv .snd) → fiber total xv\n g {xv} (p , eq) = (xv .fst , p) , (\\ i → _ , eq i)\n h-g : ∀ {xv} y → h {xv} (g {xv} y) ≡ y\n h-g {x , v} (p , eq) = J (λ _ eq₁ → h (g (p , eq₁)) ≡ (p , eq₁)) (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) ((p , refl))) (eq)\n g-h : ∀ {xv} y → g {xv} (h {xv} y) ≡ y\n g-h {xv} ((a , p) , eq) = J (λ _ eq₁ → g (h ((a , p) , eq₁)) ≡ ((a , p) , eq₁))\n (cong g (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) (p , refl)))\n eq\n -- half of Thm 4.7.7 (fiberwise equivalences)\n fiberEquiv : ([tf] : isEquiv total)\n → ∀ x → isEquiv (f x)\n fiberEquiv [tf] x .equiv-proof y = retractIsContr (fibers-total .Iso.inv) (fibers-total .Iso.fun) (fibers-total .Iso.rightInv)\n ([tf] .equiv-proof (x , y))\n\n\nmodule _ {ℓ : Level} {U : Type ℓ} {ℓr} (_~_ : U → U → Type ℓr)\n (idTo~ : ∀ {A B} → A ≡ B → A ~ B)\n (c : ∀ A → isContr (Σ U \\ X → A ~ X))\n where\n\n isContrToUniv : ∀ {A B} → isEquiv (idTo~ {A} {B})\n isContrToUniv {A} {B}\n = fiberEquiv (λ z → A ≡ z) (λ z → A ~ z) (\\ B → idTo~ {A} {B})\n (λ { .equiv-proof y\n → isContrSigma ((_ , refl) , (\\ z → contrSingl (z .snd)))\n \\ a → isContrPath (c A) _ _\n })\n B\n", "meta": {"hexsha": "24c09bb2fa559d128c93657781934e4d334afaaa", "size": 2086, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/Equiv/Fiberwise.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/Equiv/Fiberwise.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/Equiv/Fiberwise.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": 42.5714285714, "max_line_length": 140, "alphanum_fraction": 0.4386385427, "num_tokens": 828, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972549785201, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5942468251214055}} {"text": "module Numeral.Natural.UnclosedOper where\n\nimport Lvl\nopen import Data\nopen import Data.Boolean.Stmt\nopen import Data.Option as Option using (Option)\nopen import Data.Option.Functions as Option\nopen import Logic.Propositional\nopen import Numeral.Finite as 𝕟\n using (𝕟)\nimport Numeral.Finite.Bound as 𝕟bound\nopen import Numeral.Integer as ℤ\n using (ℤ)\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.Modulo\nopen import Numeral.Natural.Oper.Modulo.Proofs\nopen import Numeral.Natural.Relation.Order\nopen import Numeral.Natural.Relation.Order.Decidable\nopen import Numeral.Natural.Relation.Order.Proofs\nimport Numeral.Sign as Sign\nopen import Type.Properties.Decidable.Proofs\n\ninfix 10010 _−_\n\n-- TODO _/_ : ℕ → ℕ → ℚ\n\n-- Unclosed total subtraction from natural numbers to an optional natural number.\n-- When the subtraction gives a negative number semantically, this operation gives Option.None.\n_−?_ : ℕ → ℕ → Option(ℕ)\na −? 𝟎 = Option.Some(a)\n𝟎 −? 𝐒(b) = Option.None\n𝐒(a) −? 𝐒(b) = a −? b\n\n-- Unclosed total floored division\n{-# TERMINATING #-}\n_⌊/₀⌋_ : ℕ → ℕ → ℕ\n𝐒(x) ⌊/₀⌋ 𝐒(y) with (𝐒(x) −? 𝐒(y))\n... | Option.Some(𝐒x𝐒y) = 𝐒(𝐒x𝐒y ⌊/₀⌋ 𝐒(y))\n... | Option.None = 𝟎\n{-# CATCHALL #-}\n_ ⌊/₀⌋ _ = 𝟎\n\n-- Unclosed total subtraction from natural numbers to an optional natural number.\n-- When dividing by 0, this operation gives Option.None.\n{-# TERMINATING #-}\n_⌊/⌋?_ : ℕ → ℕ → Option(ℕ)\n_ ⌊/⌋? 𝟎 = Option.None\n𝟎 ⌊/⌋? 𝐒(_) = Option.Some(𝟎)\n𝐒(x) ⌊/⌋? 𝐒(y) with (𝐒(x) −? 𝐒(y))\n... | Option.Some(𝐒x𝐒y) = Option.map 𝐒(𝐒x𝐒y ⌊/⌋? 𝐒(y))\n... | Option.None = Option.Some(𝟎)\n\n-- Unclosed total subtraction from natural numbers to an optional natural number.\n-- When dividing by 0 or the division gives a rational number semantically, this operation gives Option.None.\n{-# TERMINATING #-}\n_/?_ : ℕ → ℕ → Option(ℕ)\n_ /? 𝟎 = Option.None\n𝟎 /? 𝐒(_) = Option.Some(𝟎)\n𝐒(x) /? 𝐒(y) with (𝐒(x) −? 𝐒(y))\n... | Option.Some(𝐒x𝐒y) = Option.map 𝐒(𝐒x𝐒y /? 𝐒(y))\n... | Option.None = Option.None\n\n-- Unclosed total subtraction from natural numbers to finite natural numbers\n_−₀fin_ : (x : ℕ) → ℕ → 𝕟(𝐒(x))\n𝟎 −₀fin _ = 𝕟.𝟎\n𝐒(x) −₀fin 𝟎 = 𝕟.𝐒(x −₀fin 𝟎)\n𝐒(x) −₀fin 𝐒(y) = 𝕟bound.bound-𝐒 (x −₀fin y)\n\n-- Unclosed total subtraction from a natural number and a finite natural number to a finite natural number\n_−fin_ : (x : ℕ) → 𝕟(𝐒(x)) → 𝕟(𝐒(x))\n𝟎 −fin 𝕟.𝟎 = 𝕟.𝟎\n𝐒(x) −fin 𝕟.𝟎 = 𝕟.𝐒(x −fin 𝕟.𝟎)\n𝐒(x) −fin 𝕟.𝐒(y) = 𝕟bound.bound-𝐒 (x −fin y)\n\n-- Modulo operation to upper bounded natural numbers.\n_modfin_ : ℕ → (b : ℕ) → ⦃ _ : IsTrue(b ≢? 𝟎) ⦄ → 𝕟(b)\na modfin 𝐒 b = 𝕟.ℕ-to-𝕟 (a mod 𝐒(b)) ⦃ [↔]-to-[→] decider-true (mod-maxᵣ{a}{𝐒 b}) ⦄\n", "meta": {"hexsha": "667cf8ac483cebd572d4f88f1b33608b80c7fa28", "size": 2769, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/UnclosedOper.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/UnclosedOper.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/UnclosedOper.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.6125, "max_line_length": 109, "alphanum_fraction": 0.6565547129, "num_tokens": 1148, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122238669025, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.5941940052284226}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Half adjoint equivalences\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Function.HalfAdjointEquivalence where\n\nopen import Function\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Inverse as Inv using (_↔_; module Inverse)\nopen import Level\nopen import Relation.Binary.PropositionalEquality\n\n-- Half adjoint equivalences (see the HoTT book).\n\nrecord _≃_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where\n field\n to : A → B\n from : B → A\n left-inverse-of : ∀ x → from (to x) ≡ x\n right-inverse-of : ∀ x → to (from x) ≡ x\n left-right :\n ∀ x → cong to (left-inverse-of x) ≡ right-inverse-of (to x)\n\n -- Half adjoint equivalences can be turned into inverses.\n\n inverse : A ↔ B\n inverse = Inv.inverse to from left-inverse-of right-inverse-of\n\n -- The forward direction of a half adjoint equivalence is injective.\n\n injective : ∀ {x y} → to x ≡ to y → x ≡ y\n injective {x} {y} to-x≡to-y =\n x ≡⟨ sym (left-inverse-of _) ⟩\n from (to x) ≡⟨ cong from to-x≡to-y ⟩\n from (to y) ≡⟨ left-inverse-of _ ⟩\n y ∎\n where\n open ≡-Reasoning\n\n-- Inverses can be turned into half adjoint equivalences.\n--\n-- (This proof is based on one in the HoTT book.)\n\n↔→≃ : ∀ {a b} {A : Set a} {B : Set b} → A ↔ B → A ≃ B\n↔→≃ A↔B = record\n { to = to ⟨$⟩_\n ; from = from ⟨$⟩_\n ; left-inverse-of = left-inverse-of\n ; right-inverse-of = right-inverse-of\n ; left-right = left-right\n }\n where\n open ≡-Reasoning\n open module A↔B = Inverse A↔B using (to; from; left-inverse-of)\n\n right-inverse-of : ∀ x → to ⟨$⟩ (from ⟨$⟩ x) ≡ x\n right-inverse-of x =\n to ⟨$⟩ (from ⟨$⟩ x) ≡⟨ sym (A↔B.right-inverse-of _) ⟩\n to ⟨$⟩ (from ⟨$⟩ (to ⟨$⟩ (from ⟨$⟩ x))) ≡⟨ cong (to ⟨$⟩_) (left-inverse-of _) ⟩\n to ⟨$⟩ (from ⟨$⟩ x) ≡⟨ A↔B.right-inverse-of _ ⟩\n x ∎\n\n left-right :\n ∀ x →\n cong (to ⟨$⟩_) (left-inverse-of x) ≡ right-inverse-of (to ⟨$⟩ x)\n left-right x =\n cong (to ⟨$⟩_) (left-inverse-of x) ≡⟨⟩\n\n trans refl (cong (to ⟨$⟩_) (left-inverse-of _)) ≡⟨ cong (λ p → trans p (cong (to ⟨$⟩_) _))\n (sym (trans-symˡ (A↔B.right-inverse-of _))) ⟩\n trans (trans (sym (A↔B.right-inverse-of _))\n (A↔B.right-inverse-of _))\n (cong (to ⟨$⟩_) (left-inverse-of _)) ≡⟨ trans-assoc (sym (A↔B.right-inverse-of _)) ⟩\n\n trans (sym (A↔B.right-inverse-of _))\n (trans (A↔B.right-inverse-of _)\n (cong (to ⟨$⟩_) (left-inverse-of _))) ≡⟨ cong (trans (sym (A↔B.right-inverse-of _))) lemma ⟩\n\n trans (sym (A↔B.right-inverse-of _))\n (trans (cong (to ⟨$⟩_) (left-inverse-of _))\n (trans (A↔B.right-inverse-of _) refl)) ≡⟨⟩\n\n right-inverse-of (to ⟨$⟩ x) ∎\n where\n lemma =\n trans (A↔B.right-inverse-of _)\n (cong (to ⟨$⟩_) (left-inverse-of _)) ≡⟨ cong (trans (A↔B.right-inverse-of _)) (sym (cong-id _)) ⟩\n\n trans (A↔B.right-inverse-of _)\n (cong id (cong (to ⟨$⟩_) (left-inverse-of _))) ≡⟨ sym (naturality A↔B.right-inverse-of) ⟩\n\n trans (cong ((to ⟨$⟩_) ∘ (from ⟨$⟩_))\n (cong (to ⟨$⟩_) (left-inverse-of _)))\n (A↔B.right-inverse-of _) ≡⟨ cong (λ p → trans p (A↔B.right-inverse-of _))\n (sym (cong-∘ _)) ⟩\n trans (cong ((to ⟨$⟩_) ∘ (from ⟨$⟩_) ∘ (to ⟨$⟩_))\n (left-inverse-of _))\n (A↔B.right-inverse-of _) ≡⟨ cong (λ p → trans p (A↔B.right-inverse-of _))\n (cong-∘ _) ⟩\n trans (cong (to ⟨$⟩_)\n (cong ((from ⟨$⟩_) ∘ (to ⟨$⟩_))\n (left-inverse-of _)))\n (A↔B.right-inverse-of _) ≡⟨ cong (λ p → trans (cong (to ⟨$⟩_) p) _)\n (cong-≡id left-inverse-of) ⟩\n trans (cong (to ⟨$⟩_) (left-inverse-of _))\n (A↔B.right-inverse-of _) ≡⟨ cong (trans (cong (to ⟨$⟩_) (left-inverse-of _)))\n (sym (trans-reflʳ _)) ⟩\n trans (cong (to ⟨$⟩_) (left-inverse-of _))\n (trans (A↔B.right-inverse-of _) refl) ∎\n", "meta": {"hexsha": "268d03d46acecaac6be6e0f7cdf1688fb687e7c5", "size": 4634, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Function/HalfAdjointEquivalence.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/HalfAdjointEquivalence.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/HalfAdjointEquivalence.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": 40.649122807, "max_line_length": 117, "alphanum_fraction": 0.4577039275, "num_tokens": 1450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.5941479374874362}} {"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.Product.Relation.Binary.Lex.Strict using (×-Lex; ×-transitive)\nopen import Data.List using (List)\nopen import Data.List.Relation.Binary.Lex.Strict using (Lex-<) renaming (<-transitive to Lex<-trans)\nopen import Relation.Binary using (Rel;_Respects₂_;Transitive;IsEquivalence)\n\nopen import Relation.Binary.PropositionalEquality as PropEq using (_≡_)\n\nopen import Level using (0ℓ)\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 : Size → Set where\n TyApp : {z : Size} (n : ℕ) → (as : Vec (Type z) n) → Type (↑ z)\n\n<-transf : ∀ {z} → Rel (Type z) 0ℓ → Rel (ℕ × List (Type z)) 0ℓ\n<-transf _<_ = ×-Lex _≡_ _N<_ (Lex-< _≡_ _<_)\n\ninfix 4 _<_\ndata _<_ : {z : Size} → Rel (Type z) 0ℓ where\n TyApp (x : Fin (suc n)) (y : Fin n) -> Fin (suc n)\nthin zero y = suc y\nthin (suc x) zero = zero\nthin (suc x) (suc y) = suc (thin x y)\n\np : ∀ {n} -> Fin (suc (suc n)) -> Fin (suc n)\np (suc x) = x\np zero = zero\n\nmodule Thin where\n fact1 : ∀ {n} x y z -> thin {n} x y ≡ thin x z -> y ≡ z\n fact1 zero y .y refl = refl\n fact1 (suc x) zero zero r = refl\n fact1 (suc x) zero (suc z) ()\n fact1 (suc x) (suc y) zero ()\n fact1 (suc x) (suc y) (suc z) r = cong suc (fact1 x y z (cong p r))\n\n fact2 : ∀ {n} x y -> ¬ thin {n} x y ≡ x\n fact2 zero y ()\n fact2 (suc x) zero ()\n fact2 (suc x) (suc y) r = fact2 x y (cong p r)\n\n fact3 : ∀{n} x y -> ¬ x ≡ y -> ∃ λ y' -> thin {n} x y' ≡ y\n fact3 zero zero ne = ⊥-elim (ne refl)\n fact3 zero (suc y) _ = y , refl\n fact3 {zero} (suc ()) _ _\n fact3 {suc n} (suc x) zero ne = zero , refl\n fact3 {suc n} (suc x) (suc y) ne with y | fact3 x y (ne ∘ cong suc)\n ... | .(thin x y') | y' , refl = suc y' , refl\n\nopen import Data.Maybe\nopen import Category.Functor\nopen import Category.Monad\nimport Level\nopen RawMonad (Data.Maybe.monad {Level.zero})\n\nthick : ∀ {n} -> (x y : Fin (suc n)) -> Maybe (Fin n)\nthick zero zero = nothing\nthick zero (suc y) = just y\nthick {zero} (suc ()) _\nthick {suc _} (suc x) zero = just zero\nthick {suc _} (suc x) (suc y) = suc <$> (thick x y)\n\nopen import Data.Sum\n\n_≡Fin_ : ∀ {n} -> (x y : Fin n) -> Dec (x ≡ y)\nzero ≡Fin zero = yes refl\nzero ≡Fin suc y = no λ ()\nsuc x ≡Fin zero = no λ ()\nsuc {suc _} x ≡Fin suc y with x ≡Fin y\n... | yes r = yes (cong suc r)\n... | no r = no λ e -> r (cong p e)\nsuc {zero} () ≡Fin _\n\nmodule Thick where\n half1 : ∀ {n} (x : Fin (suc n)) -> thick x x ≡ nothing\n half1 zero = refl\n half1 {suc _} (suc x) = cong (_<$>_ suc) (half1 x)\n half1 {zero} (suc ())\n\n half2 : ∀ {n} (x : Fin (suc n)) y -> ∀ y' -> thin x y' ≡ y -> thick x y ≡ just y'\n half2 zero zero y' ()\n half2 zero (suc y) .y refl = refl\n half2 {suc n} (suc x) zero zero refl = refl\n half2 {suc _} (suc _) zero (suc _) ()\n half2 {suc n} (suc x) (suc y) zero ()\n half2 {suc n} (suc x) (suc .(thin x y')) (suc y') refl with thick x (thin x y') | half2 x (thin x y') y' refl\n ... | .(just y') | refl = refl\n half2 {zero} (suc ()) _ _ _\n\n fact1 : ∀ {n} (x : Fin (suc n)) y r\n -> thick x y ≡ r\n -> x ≡ y × r ≡ nothing ⊎ ∃ λ y' -> thin x y' ≡ y × r ≡ just y'\n fact1 x y .(thick x y) refl with x ≡Fin y\n fact1 x .x ._ refl | yes refl = inj₁ (refl , half1 x)\n ... | no el with Thin.fact3 x y el\n ... | y' , thinxy'=y = inj₂ (y' , ( thinxy'=y , half2 x y y' thinxy'=y ))\n", "meta": {"hexsha": "54ff792af70e23ec5c508143fd6cfce3bbb41acc", "size": 3030, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/UnifyFin.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/UnifyFin.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/UnifyFin.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.0449438202, "max_line_length": 111, "alphanum_fraction": 0.5435643564, "num_tokens": 1212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117812622843, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.5940704602517335}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\n-- Proof that 'Free' is a functor\nmodule Categories.Free.Functor where\n\nopen import Categories.Support.PropositionalEquality\n\nopen import Categories.Categories\nopen import Categories.Category\n renaming (_[_∼_] to _[_~C_])\nopen import Categories.Free.Core\nopen import Categories.Functor\n using (Functor)\n renaming (_≡_ to _≡F_; _∘_ to _∘F_)\nopen import Categories.Graphs\nopen import Data.Product\nopen import Graphs.Graph\n renaming (_[_~_] to _[_~G_]; module Heterogeneous to HeterogeneousG)\nopen import Graphs.GraphMorphism\n renaming (_∘_ to _∘G_)\nopen import Data.Star\nopen import Data.Star.Properties\n using (gmap-◅◅; gmap-id)\nopen import Categories.Support.StarEquality\nopen import Level using (_⊔_)\n\nε∼ε : ∀{o₁ ℓ₁ e₁}{X : Graph o₁ ℓ₁ e₁}\n {o₂ ℓ₂ e₂}{Y : Graph o₂ ℓ₂ e₂}\n → (F G : GraphMorphism X Y)\n → F ≈ G\n → {x : Graph.Obj X}\n → Free₀ Y [ ε {x = GraphMorphism.F₀ F x} ~C ε {x = GraphMorphism.F₀ G x} ]\nε∼ε {Y = Y} F G (F≈G₀ , F≈G₁) {x} = ≣-subst (λ z → Free₀ Y [ ε {x = GraphMorphism.F₀ F x} ~C ε {x = z} ]) (F≈G₀ x) (Heterogeneous.refl (Free₀ Y))\n-- the below should probably work, but there's an agda bug\n-- XXX bug id? mokus? anybody? bueller?\n{-\nε∼ε {Y = Y} F G F≈G {x} rewrite proj₁ F≈G x = refl\n where open Heterogeneous (Free₀ Y)\n-}\n\n_◅~◅_ : \n ∀ {o ℓ e}{G : Graph o ℓ e}\n {a₀ a₁ b₀ b₁ c₀ c₁ : Graph.Obj G}\n {f : G [ a₀ ↝ b₀ ]}\n {g : G [ a₁ ↝ b₁ ]}\n {fs : Free₀ G [ b₀ , c₀ ]}\n {gs : Free₀ G [ b₁ , c₁ ]}\n → G [ f ~G g ]\n → Free₀ G [ fs ~C gs ]\n → Free₀ G [ (f ◅ fs) ~C (g ◅ gs) ]\n_◅~◅_ {G = G} (HeterogeneousG.≈⇒~ hd) (Heterogeneous.≡⇒∼ tl)\n = ≡⇒∼ (hd ◅-cong tl)\n where\n open Heterogeneous (Free₀ G)\n open PathEquality G\n\nFree : ∀ {o ℓ e} → Functor (Graphs o ℓ e) (Categories o (o ⊔ ℓ) (o ⊔ ℓ ⊔ e))\nFree {o}{ℓ}{e} = record\n { F₀ = Free₀\n ; F₁ = Free₁\n ; identity = λ {A} f → Heterogeneous.reflexive (Free₀ A) (gmap-id f)\n ; homomorphism = λ {X}{Y}{Z}{f}{g} → homomorphism {X}{Y}{Z}{f}{g}\n ; F-resp-≡ = λ {X}{Y}{F G : GraphMorphism X Y} → Free₁-resp-≡ {X}{Y}{F}{G}\n }\n where\n module Graphs = Category (Graphs o ℓ e)\n module Categories = Category (Categories o (o ⊔ ℓ) (o ⊔ ℓ ⊔ e))\n \n .homomorphism : ∀ {X Y Z} {f : GraphMorphism X Y} {g : GraphMorphism Y Z}\n → Free₁ (g ∘G f) ≡F (Free₁ g ∘F Free₁ f)\n homomorphism ε = Heterogeneous.refl _\n homomorphism {X}{Y}{Z}{f}{g}{S}{U} (_◅_ {.S}{T}{.U} h hs) = \n HeterogeneousG.refl Z ◅~◅ homomorphism {X}{Y}{Z}{f}{g}{T}{U} hs\n \n .Free₁-resp-≡ : ∀ {X Y} {F G : GraphMorphism X Y} \n → F ≈ G\n → Free₁ F ≡F Free₁ G\n Free₁-resp-≡ {X}{Y}{F}{G} F≈G {S}{.S} ε = ε∼ε F G F≈G\n Free₁-resp-≡ {X}{Y}{F}{G} F≈G {S}{U} (_◅_ {.S}{T}{.U} h hs) \n = proj₂ F≈G h ◅~◅ Free₁-resp-≡ {X}{Y}{F}{G} F≈G {T}{U} hs\n", "meta": {"hexsha": "7623c9138c590edb9a7c44071db24b9c3bd7da2b", "size": 2860, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Free/Functor.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/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": 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/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": 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.3086419753, "max_line_length": 145, "alphanum_fraction": 0.5688811189, "num_tokens": 1216, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117898012105, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.5940704564233662}} {"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 public\n\nType : (ℓ : Level) → Set (ℓsuc ℓ)\nType ℓ = Set ℓ\n\nType₀ = Type ℓzero\nType₁ = Type (ℓsuc ℓzero)\nType₂ = Type (ℓsuc (ℓsuc ℓzero))\nType₃ = Type (ℓsuc (ℓsuc (ℓsuc ℓzero)))\n\nvariable\n a b c : Level\n A : Type a\n B : Type b\n C : Type c\n\n", "meta": {"hexsha": "a250e7eba74b53c4cc0a662f3104651d90ee30ac", "size": 425, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Level.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/Level.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/Level.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": 16.3461538462, "max_line_length": 39, "alphanum_fraction": 0.5929411765, "num_tokens": 179, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117855317474, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.594070453355354}} {"text": "------------------------------------------------------------------------\n-- Properties of homogeneous binary relations\n------------------------------------------------------------------------\n\nmodule Relation.Binary where\n\nopen import Data.Product\nopen import Data.Sum\nopen import Data.Function\nimport Relation.Binary.PropositionalEquality.Core as PropEq\nopen import Relation.Binary.Consequences\nopen import Relation.Binary.Core as Core using (_≡_)\n\n------------------------------------------------------------------------\n-- Simple properties and equivalence relations\n\nopen Core public hiding (_≡_; refl; _≢_)\n\n------------------------------------------------------------------------\n-- Preorders\n\nrecord IsPreorder {a : Set}\n (_≈_ : Rel a) -- The underlying equality.\n (_∼_ : Rel a) -- The relation.\n : Set where\n field\n isEquivalence : IsEquivalence _≈_\n -- Reflexivity is expressed in terms of an underlying equality:\n reflexive : _≈_ ⇒ _∼_\n trans : Transitive _∼_\n ∼-resp-≈ : _∼_ Respects₂ _≈_\n\n module Eq = IsEquivalence isEquivalence\n\n refl : Reflexive _∼_\n refl = reflexive Eq.refl\n\nrecord Preorder : Set₁ where\n infix 4 _≈_ _∼_\n field\n carrier : Set\n _≈_ : Rel carrier -- The underlying equality.\n _∼_ : Rel carrier -- The relation.\n isPreorder : IsPreorder _≈_ _∼_\n\n open IsPreorder isPreorder public\n\n------------------------------------------------------------------------\n-- Setoids\n\n-- Equivalence relations are defined in Relation.Binary.Core.\n\nrecord Setoid : Set₁ where\n infix 4 _≈_\n field\n carrier : Set\n _≈_ : Rel carrier\n isEquivalence : IsEquivalence _≈_\n\n open IsEquivalence isEquivalence public\n\n isPreorder : IsPreorder _≡_ _≈_\n isPreorder = record\n { isEquivalence = PropEq.isEquivalence\n ; reflexive = reflexive\n ; trans = trans\n ; ∼-resp-≈ = PropEq.resp₂ _≈_\n }\n\n preorder : Preorder\n preorder = record { isPreorder = isPreorder }\n\n------------------------------------------------------------------------\n-- Decidable equivalence relations\n\nrecord IsDecEquivalence {a : Set} (_≈_ : Rel a) : Set where\n field\n isEquivalence : IsEquivalence _≈_\n _≟_ : Decidable _≈_\n\n open IsEquivalence isEquivalence public\n\nrecord DecSetoid : Set₁ where\n infix 4 _≈_\n field\n carrier : Set\n _≈_ : Rel carrier\n isDecEquivalence : IsDecEquivalence _≈_\n\n open IsDecEquivalence isDecEquivalence public\n\n setoid : Setoid\n setoid = record { isEquivalence = isEquivalence }\n\n open Setoid setoid public using (preorder)\n\n------------------------------------------------------------------------\n-- Partial orders\n\nrecord IsPartialOrder {a : Set} (_≈_ _≤_ : Rel a) : Set where\n field\n isPreorder : IsPreorder _≈_ _≤_\n antisym : Antisymmetric _≈_ _≤_\n\n open IsPreorder isPreorder public\n renaming (∼-resp-≈ to ≤-resp-≈)\n\nrecord Poset : Set₁ where\n infix 4 _≈_ _≤_\n field\n carrier : Set\n _≈_ : Rel carrier\n _≤_ : Rel carrier\n isPartialOrder : IsPartialOrder _≈_ _≤_\n\n open IsPartialOrder isPartialOrder public\n\n preorder : Preorder\n preorder = record { isPreorder = isPreorder }\n\n------------------------------------------------------------------------\n-- Strict partial orders\n\nrecord IsStrictPartialOrder {a : Set} (_≈_ _<_ : Rel a) : Set where\n field\n isEquivalence : IsEquivalence _≈_\n irrefl : Irreflexive _≈_ _<_\n trans : Transitive _<_\n <-resp-≈ : _<_ Respects₂ _≈_\n\n module Eq = IsEquivalence isEquivalence\n\nrecord StrictPartialOrder : Set₁ where\n infix 4 _≈_ _<_\n field\n carrier : Set\n _≈_ : Rel carrier\n _<_ : Rel carrier\n isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_\n\n open IsStrictPartialOrder isStrictPartialOrder public\n\n------------------------------------------------------------------------\n-- Total orders\n\nrecord IsTotalOrder {a : Set} (_≈_ _≤_ : Rel a) : Set where\n field\n isPartialOrder : IsPartialOrder _≈_ _≤_\n total : Total _≤_\n\n open IsPartialOrder isPartialOrder public\n\nrecord TotalOrder : Set₁ where\n infix 4 _≈_ _≤_\n field\n carrier : Set\n _≈_ : Rel carrier\n _≤_ : Rel carrier\n isTotalOrder : IsTotalOrder _≈_ _≤_\n\n open IsTotalOrder isTotalOrder public\n\n poset : Poset\n poset = record { isPartialOrder = isPartialOrder }\n\n open Poset poset public using (preorder)\n\n------------------------------------------------------------------------\n-- Decidable total orders\n\nrecord IsDecTotalOrder {a : Set} (_≈_ _≤_ : Rel a) : Set where\n field\n isTotalOrder : IsTotalOrder _≈_ _≤_\n _≟_ : Decidable _≈_\n _≤?_ : Decidable _≤_\n\n private\n module TO = IsTotalOrder isTotalOrder\n open TO public hiding (module Eq)\n\n module Eq where\n\n isDecEquivalence : IsDecEquivalence _≈_\n isDecEquivalence = record\n { isEquivalence = TO.isEquivalence\n ; _≟_ = _≟_\n }\n\n open IsDecEquivalence isDecEquivalence public\n\nrecord DecTotalOrder : Set₁ where\n infix 4 _≈_ _≤_\n field\n carrier : Set\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\n totalOrder = record { isTotalOrder = isTotalOrder }\n\n open TotalOrder totalOrder public using (poset; preorder)\n\n module Eq where\n\n decSetoid : DecSetoid\n decSetoid = record { isDecEquivalence = DTO.Eq.isDecEquivalence }\n\n open DecSetoid decSetoid public\n\n------------------------------------------------------------------------\n-- Strict total orders\n\n-- Note that these orders are decidable (see compare).\n\nrecord IsStrictTotalOrder {a : Set} (_≈_ _<_ : Rel a) : Set where\n field\n isEquivalence : IsEquivalence _≈_\n trans : Transitive _<_\n compare : Trichotomous _≈_ _<_\n <-resp-≈ : _<_ Respects₂ _≈_\n\n _≟_ : Decidable _≈_\n _≟_ = tri⟶dec≈ compare\n\n isDecEquivalence : IsDecEquivalence _≈_\n isDecEquivalence = record\n { isEquivalence = isEquivalence\n ; _≟_ = _≟_\n }\n\n module Eq = IsDecEquivalence isDecEquivalence\n\n isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_\n isStrictPartialOrder = record\n { isEquivalence = isEquivalence\n ; irrefl = tri⟶irr <-resp-≈ Eq.sym compare\n ; trans = trans\n ; <-resp-≈ = <-resp-≈\n }\n\n open IsStrictPartialOrder isStrictPartialOrder using (irrefl)\n\nrecord StrictTotalOrder : Set₁ where\n infix 4 _≈_ _<_\n field\n carrier : Set\n _≈_ : Rel carrier\n _<_ : Rel carrier\n isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_\n\n open IsStrictTotalOrder isStrictTotalOrder public\n hiding (module Eq)\n\n strictPartialOrder : StrictPartialOrder\n strictPartialOrder =\n record { isStrictPartialOrder = isStrictPartialOrder }\n\n decSetoid : DecSetoid\n decSetoid = record { isDecEquivalence = isDecEquivalence }\n\n module Eq = DecSetoid decSetoid\n", "meta": {"hexsha": "d5c03b88dbc38579b2947cbe5e8414129d797564", "size": 7203, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary.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.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.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.9775280899, "max_line_length": 72, "alphanum_fraction": 0.5800360961, "num_tokens": 1954, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117983401363, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.5940704525949981}} {"text": "------------------------------------------------------------------------------\n-- Terminating mirror function\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.MirrorListTerminatingSL where\n\nopen import Data.List\n\n------------------------------------------------------------------------------\n-- The rose tree type.\ndata Tree (A : Set) : Set where\n tree : A → List (Tree A) → Tree A\n\n------------------------------------------------------------------------------\n-- An alternative and terminating definition of mirror. Adapted from\n-- http://stackoverflow.com/questions/9146928/termination-of-structural-induction\n\n-- The mirror function.\nmirror : {A : Set} → Tree A → Tree A\nmirrorBranch : {A : Set} → List (Tree A) → List (Tree A)\n\nmirror (tree a ts) = tree a (reverse (mirrorBranch ts))\nmirrorBranch [] = []\nmirrorBranch (t ∷ ts) = mirror t ∷ mirrorBranch ts\n", "meta": {"hexsha": "65073adbf7abbff98760e25ac743949cdde05ef4", "size": 1121, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorListTerminatingSL.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/MirrorListTerminatingSL.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/MirrorListTerminatingSL.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.3666666667, "max_line_length": 81, "alphanum_fraction": 0.4576271186, "num_tokens": 211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.826711776992821, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.5940704522015252}} {"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 Data.Sum\nopen import Function\nopen import Relation.Binary using (Decidable)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary using (yes; no)\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n inj₁-injective : ∀ {x y} → (A ⊎ B ∋ inj₁ x) ≡ inj₁ y → x ≡ y\n inj₁-injective refl = refl\n\n inj₂-injective : ∀ {x y} → (A ⊎ B ∋ inj₂ x) ≡ inj₂ y → x ≡ y\n inj₂-injective refl = refl\n\n ≡-dec : Decidable _≡_ → Decidable _≡_ → Decidable {A = A ⊎ B} _≡_\n ≡-dec dec₁ dec₂ (inj₁ x) (inj₁ y) with dec₁ x y\n ... | yes refl = yes refl\n ... | no x≢y = no (x≢y ∘ inj₁-injective)\n ≡-dec dec₁ dec₂ (inj₁ x) (inj₂ y) = no λ()\n ≡-dec dec₁ dec₂ (inj₂ x) (inj₁ y) = no λ()\n ≡-dec dec₁ dec₂ (inj₂ x) (inj₂ y) with dec₂ x y\n ... | yes refl = yes refl\n ... | no x≢y = no (x≢y ∘ inj₂-injective)\n\n swap-involutive : swap {A = A} {B} ∘ swap ≗ id\n swap-involutive = [ (λ _ → refl) , (λ _ → refl) ]\n", "meta": {"hexsha": "0b1644efecf2ce86c8fda916cdf633ebe87d966f", "size": 1211, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/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/Sum/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/Sum/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": 32.7297297297, "max_line_length": 72, "alphanum_fraction": 0.5350949628, "num_tokens": 426, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619947119304, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.5938885641974989}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics hiding (_⊔_)\nopen import lib.types.Sigma\nopen import lib.types.Bool\nopen import lib.types.Empty\n\nopen import Preliminaries\nopen import Truncation_Level_Criteria\nopen import Anonymous_Existence_CollSplit\nopen import Anonymous_Existence_Populatedness\n\n\nmodule Anonymous_Existence_Comparison where\n\n-- Chapter 4.3: Comparison of Notions of Existence\n\n-- Section 4.3.1: Inhabited and Merely Inhabited\n\n-- Lemma 4.3.1\ncoll-family-dec : ∀ {i} {X : Type i} → (x₁ x₂ : X) → ((x : X) → coll (Coprod (x₁ == x) (x₂ == x))) → Coprod (x₁ == x₂) (¬(x₁ == x₂))\ncoll-family-dec {i} {X} x₁ x₂ coll-fam = solution where\n f₋ : (x : X) → Coprod (x₁ == x) (x₂ == x) → Coprod (x₁ == x) (x₂ == x)\n f₋ x = fst (coll-fam x)\n\n E₋ : X → Type i\n E₋ x = fix (f₋ x)\n\n E : Type i\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 (coll-fam x))) _ _ p\n\n r : Bool → E\n r true = x₁ , to-fix (f₋ x₁) (snd (coll-fam x₁)) (inl idp) \n r false = x₂ , to-fix (f₋ x₂) (snd (coll-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 : Coprod (s (r true) == s (r false)) (¬(s (r true) == s (r false)))\n check-bool = Bool-has-dec-eq _ _\n\n solution : Coprod (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-- definition: \"all types have a weakly constant endofunction\".\n-- this assumption is, if we have ∣∣_∣∣, logically equivalent to saying that\n-- every type has split support.\nall-coll : ∀ {i} → Type (lsucc i)\nall-coll {i} = (X : Type i) → coll X\n\n-- Proposition 4.3.2\nall-coll→dec-eq : ∀ {i} → all-coll {i} → (X : Type i) → has-dec-eq X\nall-coll→dec-eq all-coll X x₁ x₂ = coll-family-dec x₁ x₂ (λ x → all-coll _)\n\n\nopen with-weak-trunc\nopen wtrunc\n\n\n-- Proposition 4.3.3\nmodule functional-subrelation {i : ULevel} (ac : all-coll {i}) (X : Type i) (R : X × X → Type i) where\n\n all-sets : (Y : Type i) → is-set Y\n all-sets Y = pathColl→isSet (λ y₁ y₂ → ac _)\n\n R₋ : (x : X) → Type i\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 SS : X × X → Type i\n SS (x , y) = Σ (R(x , y)) λ a → \n (y , a) == k x (y , a)\n\n -- the relation S\n SS₋ : (x : X) → Type i\n SS₋ x = Σ X λ y → SS(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-SS : (x : X) → (fix (k x)) ≃ SS₋ x\n fixk-SS 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 (SS₋ x) ≃∎\n\n -- claim (0)\n subrelation : (x y : X) → SS(x , y) → R(x , y)\n subrelation x y (r , _) = r\n\n -- claim (1)\n prop-SSx : (x : X) → is-prop (SS₋ x)\n prop-SSx x = equiv-preserves-level {A = fix (k x)} {B = (SS₋ x)} (fixk-SS x) (fixed-point _ (kc x)) \n\n -- claim (2)\n same-domain : (x : X) → (R₋ x) ↔ (SS₋ x)\n same-domain x = rs , sr where\n rs : (R₋ x) → (SS₋ x)\n rs a = –> (fixk-SS x) (to-fix (k x) (kc x) a)\n sr : (SS₋ x) → (R₋ x)\n sr (y , r , _) = y , r\n\n -- claim (3) \n prop-SS : (x y : X) → is-prop (SS (x , y))\n prop-SS x y = all-paths-is-prop all-paths where\n all-paths : (s₁ s₂ : SS(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-SSx 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 : ∀ {i j} {U : Type i} {V : Type j} → (U → V) → Type (i ⊔ j)\nis-split-epimorphism {U = U} {V = V} e = Σ (V → U) λ s → (v : V) → e (s v) == v\n\nis-epimorphism : ∀ {i j} {U : Type i} {V : Type j} → (U → V) → Type (lsucc (i ⊔ j))\nis-epimorphism {i} {j} {U = U} {V = V} e = (W : Type (i ⊔ j)) → (f g : V → W) → ((u : U) → f (e u) == g (e u)) → (v : V) → f v == g v\n\n-- Lemma 4.3.4\npath-trunc-epi→set : ∀ {i} {Y : Type i} → ((y₁ y₂ : Y) → is-epimorphism (∣_∣ {X = y₁ == y₂})) → is-set Y\npath-trunc-epi→set {Y = Y} path-epi = reminder special-case where\n\n f : (y₁ y₂ : Y) → ∣∣ y₁ == y₂ ∣∣ → Y\n f y₁ _ _ = y₁\n\n g : (y₁ y₂ : Y) → ∣∣ y₁ == y₂ ∣∣ → Y\n g _ y₂ _ = y₂\n\n special-case : (y₁ y₂ : Y) → ∣∣ y₁ == y₂ ∣∣ → y₁ == y₂\n special-case y₁ y₂ = path-epi y₁ y₂ Y (f y₁ y₂) (g y₁ y₂) (idf _)\n\n -- we know that hSeparated(X) implies that X is a set, \n -- from the previous Proposition 3.1.9; \n -- however, we have proved it in such a way which forces \n -- us to combine three directions:\n reminder : hSeparated Y → is-set Y\n reminder = (fst (set-characterisations Y)) ∘ (fst (snd (snd (set-characterisations Y)))) ∘ (snd (snd (snd (snd (set-characterisations Y)))))\n\n-- Proposition 4.3.5 (1)\nall-split→all-deceq : ∀ {i} → ((X : Type i) → is-split-epimorphism (∣_∣ {X = X})) → (X : Type i) → has-dec-eq X\nall-split→all-deceq {i} all-split = all-coll→dec-eq ac where\n ac : (X : Type i) → coll X\n ac X = snd coll↔splitSup (fst (all-split X))\n\n-- Proposition 4.3.5 (2)\nall-epi→all-set : ∀ {i} → ((X : Type i) → is-epimorphism (∣_∣ {X = X})) → (X : Type i) → is-set X\nall-epi→all-set all-epi X = path-trunc-epi→set (λ y₁ y₂ → all-epi (y₁ == y₂))\n\n\n-- Section 4.3.2: Merely Inhabited and Populated\n\n-- Lemma 4.3.6, first proof\npop-hstable-1 : ∀ {i} {X : Type i} → ⟪ splitSup X ⟫\npop-hstable-1 {X = X} f c = to-fix f c (coll→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 tr-is-prop ∣ x₁ ∣ ∣ x₂ ∣) ⟩\n f (λ _ → x₂) ∣ x₂ ∣ =⟨ idp ⟩\n g x₂ ∎ \n\n-- Lemma 4.3.6, second proof\npop-hstable-2 : ∀ {i} {X : Type i} → ⟪ splitSup X ⟫\npop-hstable-2 {i} {X} = snd (pop-alt₂ {X = splitSup X}) get-P where\n get-P : (P : Type i) → 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 : ∣∣ X ∣∣ → P\n zp = tr-rec pp xp\n\n free-hst : splitSup X\n free-hst z = phst (zp z) z\n\n-- Lemma 4.3.6, third proof\npop-hstable-3 : ∀ {i} {X : Type i} → ⟪ splitSup X ⟫\npop-hstable-3 {X = 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 : ∣∣ splitSup (splitSup X) ∣∣ → ∣∣ splitSup X ∣∣ \n translation = trunc-functorial translation-aux\n\n-- Lemma 4.3.7\nmodule tlem437 {i : ULevel} where\n\n One = (X : Type i) → ⟪ X ⟫ → ∣∣ X ∣∣\n\n Two = (X : Type i) → ∣∣ splitSup X ∣∣\n\n Three = (P : Type i) → is-prop P → (Y : P → Type i) → ((p : P) → ∣∣ Y p ∣∣) → ∣∣ ((p : P) → Y p) ∣∣\n\n Four = (X Y : Type i) → (X → Y) → (⟪ X ⟫ → ⟪ Y ⟫)\n\n\n One→Two : One → Two\n One→Two poptr X = poptr (splitSup X) pop-hstable-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 = prop-pop tr-is-prop pz where -- (tr-rec _) pz where\n pz : ⟪ ∣∣ X ∣∣ ⟫\n pz = funct X (∣∣ 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) → ∣∣ Y p ∣∣) → ∣∣ ((p : P) → Y p) ∣∣\n contr-trick p₀ py = tr-rec {X = Y p₀} \n {P = ∣∣ ((p : P) → Y p) ∣∣} \n tr-is-prop \n (λ y₀ → ∣ (λ p → transport Y (prop-has-all-paths pp p₀ p) y₀) ∣) \n (py p₀) \n\n Three→Two : Three → Two\n Three→Two proj X = proj (∣∣ X ∣∣) tr-is-prop (λ _ → X) (idf _)\n\n\n-- Section 4.3.3: Populated and Non-Empty\n\n-- We now need function extensionality. We \n-- start with some very simple auxiliary \n-- lemmata (not numbered in the thesis).\n\n-- If P is a proposition, so is P + ¬ P\ndec-is-prop : ∀ {i} {P : Type i} → is-prop P → is-prop (Coprod P (¬ P))\ndec-is-prop {P = P} pp = all-paths-is-prop (λ { (inl p₁) (inl p₂) → ap inl (prop-has-all-paths pp _ _) ; \n (inl p₁) (inr np₂) → Empty-elim {P = λ _ → inl p₁ == inr np₂} (np₂ p₁) ; \n (inr np₁) (inl p₂) → Empty-elim {P = λ _ → inr np₁ == inl p₂} (np₁ p₂) ; \n (inr np₁) (inr np₂) → ap inr (λ= (λ x → prop-has-all-paths Empty-is-prop _ _ )) }) \n\n\n-- Proposition 4.3.8\nnonempty-pop→LEM : ∀ {i} → ((X : Type i) → (¬(¬ X) → ⟪ X ⟫)) → LEM {i}\nnonempty-pop→LEM {i} nn-pop P pp = from-fix {X = dec} (idf _) (nn-pop dec nndec (idf _) idc) where\n dec : Type i\n dec = Coprod P (¬ P)\n\n idc : const (idf dec)\n idc = λ _ _ → prop-has-all-paths (dec-is-prop {P = P} pp) _ _\n\n nndec : ¬(¬ dec)\n nndec ndec = (λ np → ndec (inr np)) λ p → ndec (inl p)\n\n-- Corollary 4.3.9\nnonempty-pop↔lem : ∀ {i} → ((X : Type i) → (¬(¬ X) → ⟪ X ⟫)) ↔ LEM {i}\nnonempty-pop↔lem {i} = nonempty-pop→LEM , other where\n other : LEM {i} → ((X : Type i) → (¬(¬ X) → ⟪ X ⟫))\n other lem X nnX = p where\n pnp : Coprod ⟪ X ⟫ (¬ ⟪ X ⟫)\n pnp = lem ⟪ X ⟫ pop-property₂\n\n p : ⟪ X ⟫\n p = match pnp withl idf _ withr (λ np → Empty-elim {P = λ _ → ⟪ X ⟫} (nnX (λ x → np (pop-property₁ x))))\n", "meta": {"hexsha": "acdc7af860fe84e87e5b2cc8f86c91e0d874440f", "size": 10403, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/thesis/Anonymous_Existence_Comparison.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/Anonymous_Existence_Comparison.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/Anonymous_Existence_Comparison.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": 33.9967320261, "max_line_length": 142, "alphanum_fraction": 0.5145631068, "num_tokens": 4419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146848, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.5938783557161856}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Instance.Quivers where\n\n-- The Category of Quivers\n\nopen import Level using (Level; suc; _⊔_)\nopen import Relation.Binary.PropositionalEquality.Core using (refl)\nopen import Data.Quiver using (Quiver)\nopen import Data.Quiver.Morphism using (Morphism; id; _∘_; _≃_; ≃-Equivalence; ≃-resp-∘)\n\nopen import Categories.Category.Core using (Category)\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n\nQuivers : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)\nQuivers o ℓ e = record\n { Obj = Quiver o ℓ e\n ; _⇒_ = Morphism\n ; _≈_ = _≃_\n ; id = id\n ; _∘_ = _∘_\n ; assoc = λ {_ _ _ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }\n ; sym-assoc = λ {_ _ _ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }\n ; identityˡ = λ {_ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }\n ; identityʳ = λ {_ G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }\n ; identity² = λ {G} → record { F₀≡ = refl ; F₁≡ = Equiv.refl G }\n ; equiv = ≃-Equivalence\n ; ∘-resp-≈ = ≃-resp-∘\n }\n where open Quiver using (module Equiv)\n", "meta": {"hexsha": "0b98f5c14bd54e1b649e009add08f15a00818196", "size": 1128, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/Quivers.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/Quivers.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/Quivers.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.1764705882, "max_line_length": 88, "alphanum_fraction": 0.5744680851, "num_tokens": 436, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382058759129, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5938631243855227}} {"text": "\nmodule _ where\n\nrecord Pair (A B : Set) : Set where\n field\n π₁ : A\n π₂ : B\n\nopen Pair\n\nfoo : {A B : Set} → Pair A B → Pair A B\nfoo = λ { x → {!x!} }\n{- Case splitting on x produces:\n foo = λ { record { π₁ = π₃ ; π₂ = π₃ } → ? }\n Repeated variables in pattern: π₃\n-}\n", "meta": {"hexsha": "1b5583e116df1d377a12efe0d93dfb6d026a72f5", "size": 279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue2669.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/Issue2669.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/Issue2669.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.4117647059, "max_line_length": 47, "alphanum_fraction": 0.5376344086, "num_tokens": 108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.593671538069392}} {"text": "module EqBase where\nimport PolyDepPrelude\nopen PolyDepPrelude using\n ( Bool; true; false; _&&_\n ; Unit; unit\n ; Pair; pair\n ; Either; left; right\n ; Absurd\n ; Datoid; datoid; pElem\n ; True )\n\n-- import And\nAnd = Pair\n\n-- import Sigma\ndata Sigma (A : Set)(B : A -> Set) : Set where\n si : (a : A) -> (b : B a) -> Sigma A B\n\nEq : Set -> Set -> Set\nEq a b = a -> b -> Bool\n\neqEmpty : Eq Absurd Absurd\neqEmpty () -- empty\n\n\neqUnit : Eq Unit Unit\neqUnit unit unit = true\n\neqPair : {A1 A2 B1 B2 : Set} ->\n (Eq A1 A2) ->\n (Eq B1 B2) ->\n Eq (And A1 B1) (And A2 B2)\neqPair ea eb (pair a b) (pair a' b') = ea a a' && eb b b'\n\ncaseOn : (D : Datoid)\n {B1 B2 : pElem D -> Set}\n (ifTrue : (b : pElem D) -> B1 b -> B2 b -> Bool)\n (a b : pElem D)\n (pa : B1 a)\n (pb : B2 b)\n (e : Bool)\n (cast : True e -> B1 a -> B1 b)\n -> Bool\ncaseOn D ifTrue a b pa pb (false) cast = false\ncaseOn D ifTrue a b pa pb (true) cast = ifTrue b (cast unit pa) pb\n\neqEither : {A1 A2 B1 B2 : Set}\n (eq1 : A1 -> B1 -> Bool)\n (eq2 : A2 -> B2 -> Bool)\n -> Either A1 A2 -> Either B1 B2 -> Bool\neqEither eq1 eq2 (left a1) (left b1) = eq1 a1 b1\neqEither eq1 eq2 (right a2) (right b2) = eq2 a2 b2\neqEither eq1 eq2 _ _ = false\n\n{-\n case x of {\n (inl x') ->\n case y of {\n (inl x0) -> eq1 x' x0;\n (inr y') -> false@_;};\n (inr y') ->\n case y of {\n (inl x') -> false@_;\n (inr y0) -> eq2 y' y0;};}\n-}\n{-\n\neqSigma2 (D : Datoid)\n (|B1 |B2 : pElem D -> Set)\n (ifTrue : (b : pElem D) -> Eq (B1 b) (B2 b))\n (x : Sigma pElem D B1)\n (y : Sigma pElem D B2)\n : Bool\n = case x of {\n (si a pa) ->\n case y of {\n (si b pb) ->\n caseOn D ifTrue a b pa pb (D.eq a b) (D.subst B1);};}\n\neqSigma (D : Datoid)(|B1 : (a : pElem D) -> Set)(|B2 : (a : pElem D) -> Set)\n : ((a : pElem D) -> Eq (B1 a) (B2 a)) ->\n Eq (Sigma pElem D B1) (Sigma pElem D B2)\n = eqSigma2 D\n-- More readable but less useful definition of eqSigma : \n\neqSigmaLocalLet (D : Datoid)\n (|B1 |B2 : pElem D -> Set)\n (ifTrue : (b : pElem D) -> Eq (B1 b) (B2 b))\n (x : Sigma pElem D B1)\n (y : Sigma pElem D B2)\n : Bool\n = case x of {\n (si a pa) ->\n case y of {\n (si b pb) ->\n let caseOn (e : Bool)(cast : True e -> B1 a -> B1 b) : Bool\n = case e of {\n (false) -> false@_;\n (true) -> ifTrue b (cast tt@_ pa) pb;}\n in caseOn (D.eq a b) (D.subst B1);};}\n\n\neqSum' (D : Datoid)\n (|B1 |B2 : (a : pElem D) -> Set)\n : ((a : pElem D) -> Eq (B1 a) (B2 a)) ->\n Eq (Sum pElem D B1) (Sum pElem D B2)\n = \\(e : (a : pElem D) -> Eq (B1 a) (B2 a)) ->\n \\(p1 : Sum pElem D B1) ->\n \\(p2 : Sum pElem D B2) ->\n caseOn D e p1.fst p2.fst p1.snd p2.snd (D.eq p1.fst p2.fst)\n (D.subst B1)\n\n\neqSum : (D : Datoid)\n {B1 B2 : (a : pElem D) -> Set}\n -> ((a : pElem D) -> Eq (B1 a) (B2 a)) ->\n Eq (Sum pElem D B1) (Sum pElem D B2)\neqSum e p1 p2 =\n caseOn D e p1.fst p2.fst p1.snd p2.snd (D.eq p1.fst p2.fst)\n (D.subst B1)\n-}\n", "meta": {"hexsha": "42b3a0ad353652ce5968a53664713b71ac2e4331", "size": 3372, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM5/PolyDep/EqBase.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/EqBase.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/EqBase.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": 27.6393442623, "max_line_length": 76, "alphanum_fraction": 0.4492882562, "num_tokens": 1260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.59352060178924}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.GradedRing.Instances.Polynomials where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Equiv\n\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Nat using (ℕ)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Vec.OperationsNat\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Monoid.Instances.NatVec\nopen import Cubical.Algebra.AbGroup\nopen import Cubical.Algebra.AbGroup.Instances.Unit\nopen import Cubical.Algebra.DirectSum.DirectSumHIT.Base\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.GradedRing.Base\nopen import Cubical.Algebra.GradedRing.DirectSumHIT\n\nprivate variable\n ℓ : Level\n\nopen Iso\nopen GradedRing-⊕HIT-index\nopen GradedRing-⊕HIT-⋆\n\nmodule _\n (ARing@(A , Astr) : Ring ℓ)\n (n : ℕ)\n where\n\n open RingStr Astr\n open RingTheory ARing\n\n PolyGradedRing : GradedRing ℓ-zero ℓ\n PolyGradedRing = makeGradedRingSelf\n (NatVecMonoid n)\n (λ _ → A)\n (λ _ → snd (Ring→AbGroup ARing))\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", "meta": {"hexsha": "82f0f4b40b20b92c6a7d10d791fa11911e158d76", "size": 1479, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/GradedRing/Instances/Polynomials.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/GradedRing/Instances/Polynomials.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/GradedRing/Instances/Polynomials.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.1836734694, "max_line_length": 77, "alphanum_fraction": 0.676132522, "num_tokens": 438, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111797027760039, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.5935013319881196}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Substream (A : Set) where\n\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as PE\nopen import PropsAsTypes\nopen import Stream\n\nopen Bisim A\nopen ~-Reasoning\n\nmutual\n record Sel : Set where\n coinductive\n field out : Selμ\n\n data Selμ : Set where\n pres : Sel → Selμ\n drop : Selμ → Selμ\n\nopen Sel public\n\nfilterμ : Selμ → Stream A → Stream A\nfilter : Sel → Stream A → Stream A\n\nfilter x = filterμ (x .out)\n\nfilterμ (pres x) s .hd = s .hd\nfilterμ (pres x) s .tl = filter x (s .tl)\nfilterμ (drop u) s = filterμ u (s .tl)\n\n_≤[_]_ : Stream A → Sel → Stream A → Prop\ns ≤[ x ] t = s ~ filter x t\n\n_≤μ[_]_ : Stream A → Selμ → Stream A → Prop\ns ≤μ[ u ] t = s ~ filterμ u t\n\n_≤'_ : Stream A → Stream A → Prop\ns ≤' t = ∃[ x ∈ Sel ] (s ≤[ x ] t)\n\n_•_ : Sel → Sel → Sel\n_•μ_ : Selμ → Selμ → Selμ\n\n(x • y) .out = (x .out) •μ (y .out)\n\n(pres x') •μ (pres y') = pres (x' • y')\n(drop u') •μ (pres y') = drop (u' •μ (y' .out))\nu •μ (drop v') = drop (u •μ v')\n\nfilter-hom : ∀ x y s → filter (y • x) s ~ filter y (filter x s)\nfilterμ-hom : ∀ u v s → filterμ (v •μ u) s ~ filterμ v (filterμ u s)\n\nfilter-hom x y s = filterμ-hom (x .out) (y .out) s\n\nfilterμ-hom (pres x) (pres y) s .hd≡ = refl\nfilterμ-hom (pres x) (pres y) s .tl~ = filter-hom x y (s .tl)\nfilterμ-hom (pres x) (drop v) s = filterμ-hom (x .out) v (s .tl)\nfilterμ-hom (drop u) (pres x) s = filterμ-hom u (pres x) (s .tl)\nfilterμ-hom (drop u) (drop v) s = filterμ-hom u (drop v) (s .tl)\n\nfilter-resp~ : ∀{s t} (x : Sel) → s ~ t → filter x s ~ filter x t\nfilterμ-resp~ : ∀{s t} (u : Selμ) → s ~ t → filterμ u s ~ filterμ u t\n\nfilter-resp~ x p = filterμ-resp~ (x .out) p\n\nfilterμ-resp~ (pres x) p .hd≡ = p .hd≡\nfilterμ-resp~ (pres x) p .tl~ = filter-resp~ x (p .tl~)\nfilterμ-resp~ (drop u) p = filterμ-resp~ u (p .tl~)\n\n≤-witness-trans : ∀{r s t} {x y} → r ≤[ x ] s → s ≤[ y ] t → r ≤[ x • y ] t\n≤-witness-trans {r} {s} {t} {x} {y} p q =\n begin\n r\n ~⟨ p ⟩\n filter x s\n ~⟨ filter-resp~ x q ⟩\n filter x (filter y t)\n ~⟨ S.sym (filter-hom y x t) ⟩\n filter (x • y) t\n ∎\n where\n module S = Setoid stream-setoid\n\n≤'-trans : ∀{r s t} → r ≤' s → s ≤' t → r ≤' t\n≤'-trans = ∃₂-elim (λ x y p q →\n ∃-intro (x • y) (≤-witness-trans {x = x} {y} p q))\n\nmutual\n record _≤_ (s t : Stream A) : Prop where\n coinductive\n field out≤ : s ≤μ t\n\n data _≤μ_ (s t : Stream A) : Prop where\n match : (s .hd ≡ t .hd) → (s .tl ≤ t .tl) → s ≤μ t\n skip : (s ≤μ t .tl) → s ≤μ t\n\nopen _≤_ public\n\nwitness : {s t : Stream A} → s ≤ t → Sel\nwitnessμ : {s t : Stream A} → s ≤μ t → Selμ\n\nwitness p .out = witnessμ (p .out≤)\n\nwitnessμ (match _ t≤) = pres (witness t≤)\nwitnessμ (skip u) = drop (witnessμ u)\n\n≤-implies-witnessed≤ : ∀{s t} → (p : s ≤ t) → s ≤[ witness p ] t\n≤μ-implies-witnessed≤μ : ∀{s t} → (p : s ≤μ t) → s ≤μ[ witnessμ p ] t\n\n≤-implies-witnessed≤ {s} {t} p = ≤μ-implies-witnessed≤μ (p .out≤)\n\n≤μ-implies-witnessed≤μ (match h≡ t≤) .hd≡ = h≡\n≤μ-implies-witnessed≤μ (match h≡ t≤) .tl~ = ≤-implies-witnessed≤ t≤\n≤μ-implies-witnessed≤μ (skip q) = ≤μ-implies-witnessed≤μ q\n\n≤-implies-≤' : _≤_ ⊑ _≤'_\n≤-implies-≤' p = ∃-intro (witness p) (≤-implies-witnessed≤ p)\n\nwitnessed≤-implies-≤ : ∀{s t} (x : Sel) → s ≤[ x ] t → s ≤ t\nwitnessed≤μ-implies-≤μ : ∀{s t} (u : Selμ) → s ≤μ[ u ] t → s ≤μ t\n\nwitnessed≤-implies-≤ x p .out≤ = witnessed≤μ-implies-≤μ (x .out) p\n\nwitnessed≤μ-implies-≤μ (pres x) p = match (p .hd≡) (witnessed≤-implies-≤ x (p .tl~))\nwitnessed≤μ-implies-≤μ (drop u) p = skip (witnessed≤μ-implies-≤μ u p)\n\n≤'-implies-≤ : _≤'_ ⊑ _≤_\n≤'-implies-≤ = ∃-elim witnessed≤-implies-≤\n\n≤-and-≤'-equivalent : ∀ {s t} → s ≤ t ⇔ s ≤' t\n≤-and-≤'-equivalent = equivalence ≤-implies-≤' ≤'-implies-≤\n\n≤-trans : ∀{r s t} → r ≤ s → s ≤ t → r ≤ t\n≤-trans p q = ≤'-implies-≤ (≤'-trans (≤-implies-≤' p) (≤-implies-≤' q))\n", "meta": {"hexsha": "ca4d5a0e83f003efadc1b3bd9a578f1c19828a8a", "size": 3956, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TypeTheory/Lecture/Substream.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/Lecture/Substream.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/Lecture/Substream.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": 29.0882352941, "max_line_length": 85, "alphanum_fraction": 0.5401921132, "num_tokens": 1814, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301567, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.5934692487458708}} {"text": "------------------------------------------------------------------------\n-- List membership and some related definitions\nopen import Level using (Level; _⊔_)\nopen import Relation.Binary\nopen import Relation.Binary.List.Pointwise as ListEq using ([]; _∷_)\nopen import Relation.Nullary\nopen import Data.List\nopen import Data.List.Any\nopen import Function\nimport Relation.Binary.InducedPreorders as Ind\nopen import Data.Product as Prod using (∃; _×_; _,_)\nmodule Membership-old {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 = Data.List.Any.map (flip resp px) x∈xs\n", "meta": {"hexsha": "ada23fc138c1e66f317da46a6851e454c23a2e5e", "size": 2628, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "unused/Membership-old.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": "unused/Membership-old.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": "unused/Membership-old.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": 28.5652173913, "max_line_length": 72, "alphanum_fraction": 0.5608828006, "num_tokens": 985, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.5934692422099931}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Relations between properties of functions, such as associativity and\n-- commutativity\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel; Setoid; Substitutive; Symmetric; Total)\n\nmodule Algebra.FunctionProperties.Consequences\n {a ℓ} (S : Setoid a ℓ) where\n\nopen Setoid S renaming (Carrier to A)\n\nopen import Algebra.FunctionProperties _≈_\nopen import Data.Sum using (inj₁; inj₂)\nopen import Data.Product using (_,_)\nimport Relation.Binary.Consequences as Bin\nopen import Relation.Binary.Reasoning.Setoid S\nopen import Relation.Unary using (Pred)\n\n------------------------------------------------------------------------\n-- Re-export core properties\n\nopen import Algebra.FunctionProperties.Consequences.Core public\n\n------------------------------------------------------------------------\n-- Magma-like structures\n\nmodule _ {_•_ : Op₂ A} (comm : Commutative _•_) where\n\n comm+cancelˡ⇒cancelʳ : LeftCancellative _•_ → RightCancellative _•_\n comm+cancelˡ⇒cancelʳ cancelˡ {x} y z eq = cancelˡ x (begin\n x • y ≈⟨ comm x y ⟩\n y • x ≈⟨ eq ⟩\n z • x ≈⟨ comm z x ⟩\n x • z ∎)\n\n comm+cancelʳ⇒cancelˡ : RightCancellative _•_ → LeftCancellative _•_\n comm+cancelʳ⇒cancelˡ cancelʳ x {y} {z} eq = cancelʳ y z (begin\n y • x ≈⟨ comm y x ⟩\n x • y ≈⟨ eq ⟩\n x • z ≈⟨ comm x z ⟩\n z • x ∎)\n\n------------------------------------------------------------------------\n-- Monoid-like structures\n\nmodule _ {_•_ : Op₂ A} (comm : Commutative _•_) {e : A} where\n\n comm+idˡ⇒idʳ : LeftIdentity e _•_ → RightIdentity e _•_\n comm+idˡ⇒idʳ idˡ x = begin\n x • e ≈⟨ comm x e ⟩\n e • x ≈⟨ idˡ x ⟩\n x ∎\n\n comm+idʳ⇒idˡ : RightIdentity e _•_ → LeftIdentity e _•_\n comm+idʳ⇒idˡ idʳ x = begin\n e • x ≈⟨ comm e x ⟩\n x • e ≈⟨ idʳ x ⟩\n x ∎\n\n comm+zeˡ⇒zeʳ : LeftZero e _•_ → RightZero e _•_\n comm+zeˡ⇒zeʳ zeˡ x = begin\n x • e ≈⟨ comm x e ⟩\n e • x ≈⟨ zeˡ x ⟩\n e ∎\n\n comm+zeʳ⇒zeˡ : RightZero e _•_ → LeftZero e _•_\n comm+zeʳ⇒zeˡ zeʳ x = begin\n e • x ≈⟨ comm e x ⟩\n x • e ≈⟨ zeʳ x ⟩\n e ∎\n\n------------------------------------------------------------------------\n-- Group-like structures\n\nmodule _ {_•_ : Op₂ A} {_⁻¹ : Op₁ A} {e} (comm : Commutative _•_) where\n\n comm+invˡ⇒invʳ : LeftInverse e _⁻¹ _•_ → RightInverse e _⁻¹ _•_\n comm+invˡ⇒invʳ invˡ x = begin\n x • (x ⁻¹) ≈⟨ comm x (x ⁻¹) ⟩\n (x ⁻¹) • x ≈⟨ invˡ x ⟩\n e ∎\n\n comm+invʳ⇒invˡ : RightInverse e _⁻¹ _•_ → LeftInverse e _⁻¹ _•_\n comm+invʳ⇒invˡ invʳ x = begin\n (x ⁻¹) • x ≈⟨ comm (x ⁻¹) x ⟩\n x • (x ⁻¹) ≈⟨ invʳ x ⟩\n e ∎\n\nmodule _ {_•_ : Op₂ A} {_⁻¹ : Op₁ A} {e} (cong : Congruent₂ _•_) where\n\n assoc+id+invʳ⇒invˡ-unique : Associative _•_ →\n Identity e _•_ → RightInverse e _⁻¹ _•_ →\n ∀ x y → (x • y) ≈ e → x ≈ (y ⁻¹)\n assoc+id+invʳ⇒invˡ-unique assoc (idˡ , idʳ) invʳ x y eq = begin\n x ≈⟨ sym (idʳ x) ⟩\n x • e ≈⟨ cong refl (sym (invʳ y)) ⟩\n x • (y • (y ⁻¹)) ≈⟨ sym (assoc x y (y ⁻¹)) ⟩\n (x • y) • (y ⁻¹) ≈⟨ cong eq refl ⟩\n e • (y ⁻¹) ≈⟨ idˡ (y ⁻¹) ⟩\n y ⁻¹ ∎\n\n assoc+id+invˡ⇒invʳ-unique : Associative _•_ →\n Identity e _•_ → LeftInverse e _⁻¹ _•_ →\n ∀ x y → (x • y) ≈ e → y ≈ (x ⁻¹)\n assoc+id+invˡ⇒invʳ-unique assoc (idˡ , idʳ) invˡ x y eq = begin\n y ≈⟨ sym (idˡ y) ⟩\n e • y ≈⟨ cong (sym (invˡ x)) refl ⟩\n ((x ⁻¹) • x) • y ≈⟨ assoc (x ⁻¹) x y ⟩\n (x ⁻¹) • (x • y) ≈⟨ cong refl eq ⟩\n (x ⁻¹) • e ≈⟨ idʳ (x ⁻¹) ⟩\n x ⁻¹ ∎\n\n----------------------------------------------------------------------\n-- Bisemigroup-like structures\n\nmodule _ {_•_ _◦_ : Op₂ A}\n (◦-cong : Congruent₂ _◦_)\n (•-comm : Commutative _•_)\n where\n\n comm+distrˡ⇒distrʳ : _•_ DistributesOverˡ _◦_ → _•_ DistributesOverʳ _◦_\n comm+distrˡ⇒distrʳ distrˡ x y z = begin\n (y ◦ z) • x ≈⟨ •-comm (y ◦ z) x ⟩\n x • (y ◦ z) ≈⟨ distrˡ x y z ⟩\n (x • y) ◦ (x • z) ≈⟨ ◦-cong (•-comm x y) (•-comm x z) ⟩\n (y • x) ◦ (z • x) ∎\n\n comm+distrʳ⇒distrˡ : _•_ DistributesOverʳ _◦_ → _•_ DistributesOverˡ _◦_\n comm+distrʳ⇒distrˡ distrˡ x y z = begin\n x • (y ◦ z) ≈⟨ •-comm x (y ◦ z) ⟩\n (y ◦ z) • x ≈⟨ distrˡ x y z ⟩\n (y • x) ◦ (z • x) ≈⟨ ◦-cong (•-comm y x) (•-comm z x) ⟩\n (x • y) ◦ (x • z) ∎\n\n comm⇒sym[distribˡ] : ∀ x → Symmetric (λ y z → (x ◦ (y • z)) ≈ ((x ◦ y) • (x ◦ z)))\n comm⇒sym[distribˡ] x {y} {z} prf = begin\n x ◦ (z • y) ≈⟨ ◦-cong refl (•-comm z y) ⟩\n x ◦ (y • z) ≈⟨ prf ⟩\n (x ◦ y) • (x ◦ z) ≈⟨ •-comm (x ◦ y) (x ◦ z) ⟩\n (x ◦ z) • (x ◦ y) ∎\n\n----------------------------------------------------------------------\n-- Ring-like structures\n\nmodule _ {_+_ _*_ : Op₂ A}\n {_⁻¹ : Op₁ A} {0# : A}\n (+-cong : Congruent₂ _+_)\n (*-cong : Congruent₂ _*_)\n where\n\n assoc+distribʳ+idʳ+invʳ⇒zeˡ : Associative _+_ → _*_ DistributesOverʳ _+_ →\n RightIdentity 0# _+_ → RightInverse 0# _⁻¹ _+_ →\n LeftZero 0# _*_\n assoc+distribʳ+idʳ+invʳ⇒zeˡ +-assoc distribʳ idʳ invʳ x = begin\n 0# * x ≈⟨ sym (idʳ _) ⟩\n (0# * x) + 0# ≈⟨ +-cong refl (sym (invʳ _)) ⟩\n (0# * x) + ((0# * x) + ((0# * x)⁻¹)) ≈⟨ sym (+-assoc _ _ _) ⟩\n ((0# * x) + (0# * x)) + ((0# * x)⁻¹) ≈⟨ +-cong (sym (distribʳ _ _ _)) refl ⟩\n ((0# + 0#) * x) + ((0# * x)⁻¹) ≈⟨ +-cong (*-cong (idʳ _) refl) refl ⟩\n (0# * x) + ((0# * x)⁻¹) ≈⟨ invʳ _ ⟩\n 0# ∎\n\n assoc+distribˡ+idʳ+invʳ⇒zeʳ : Associative _+_ → _*_ DistributesOverˡ _+_ →\n RightIdentity 0# _+_ → RightInverse 0# _⁻¹ _+_ →\n RightZero 0# _*_\n assoc+distribˡ+idʳ+invʳ⇒zeʳ +-assoc distribˡ idʳ invʳ x = begin\n x * 0# ≈⟨ sym (idʳ _) ⟩\n (x * 0#) + 0# ≈⟨ +-cong refl (sym (invʳ _)) ⟩\n (x * 0#) + ((x * 0#) + ((x * 0#)⁻¹)) ≈⟨ sym (+-assoc _ _ _) ⟩\n ((x * 0#) + (x * 0#)) + ((x * 0#)⁻¹) ≈⟨ +-cong (sym (distribˡ _ _ _)) refl ⟩\n (x * (0# + 0#)) + ((x * 0#)⁻¹) ≈⟨ +-cong (*-cong refl (idʳ _)) refl ⟩\n ((x * 0#) + ((x * 0#)⁻¹)) ≈⟨ invʳ _ ⟩\n 0# ∎\n\n------------------------------------------------------------------------\n-- Without Loss of Generality\n\nmodule _ {p} {f : Op₂ A} {P : Pred A p}\n (≈-subst : Substitutive _≈_ p)\n (comm : Commutative f)\n where\n\n subst+comm⇒sym : Symmetric (λ a b → P (f a b))\n subst+comm⇒sym = ≈-subst P (comm _ _)\n\n wlog : ∀ {r} {_R_ : Rel _ r} → Total _R_ →\n (∀ a b → a R b → P (f a b)) →\n ∀ a b → P (f a b)\n wlog r-total = Bin.wlog r-total subst+comm⇒sym\n", "meta": {"hexsha": "a5cfd5b7eb2b9dbdb99979c345d1a8f15f470237", "size": 7079, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/FunctionProperties/Consequences.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/FunctionProperties/Consequences.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/FunctionProperties/Consequences.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.3025641026, "max_line_length": 84, "alphanum_fraction": 0.4331120215, "num_tokens": 2951, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.5934692422099931}} {"text": "{-# OPTIONS --safe --warning=error #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import LogicalFormulae\nopen import Functions.Definition\nopen import Boolean.Definition\n\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Vectors\n\nmodule Logic.PropositionalLogic where\n\ndata Propositions {a : _} (primitives : Set a) : Set a where\n ofPrimitive : primitives → Propositions primitives\n false : Propositions primitives\n implies : (a b : Propositions primitives) → Propositions primitives\n\nprNot : {a : _} {pr : Set a} → Propositions pr → Propositions pr\nprNot p = implies p false\n\nimpliesIsBigger : {a : _} {pr : Set a} {P Q : Propositions pr} → Q ≡ implies P Q → False\nimpliesIsBigger {P = P} {Q} ()\n\nimpliesInjectiveL : {a : _} {A : Set a} → {p q r : Propositions A} → implies p q ≡ implies r q → p ≡ r\nimpliesInjectiveL refl = refl\n\nimpliesInjectiveR : {a : _} {A : Set a} → {p q r : Propositions A} → implies p q ≡ implies p r → q ≡ r\nimpliesInjectiveR refl = refl\n\nimpliesInjective : {a : _} {A : Set a} → {p q r s : Propositions A} → implies p q ≡ implies r s → (p ≡ r) && (q ≡ s)\nimpliesInjective refl = refl ,, refl\n\nrecord Valuation {a : _} (primitives : Set a) : Set a where\n field\n v : Propositions primitives → Bool\n vFalse : v false ≡ BoolFalse\n vImplicationF : {p q : Propositions primitives} → v p ≡ BoolTrue → v q ≡ BoolFalse → v (implies p q) ≡ BoolFalse\n vImplicationVacuous : {p q : Propositions primitives} → v p ≡ BoolFalse → v (implies p q) ≡ BoolTrue\n vImplicationT : {p q : Propositions primitives} → v q ≡ BoolTrue → v (implies p q) ≡ BoolTrue\n\n-- Proposition 1a\nvaluationIsDetermined : {a : _} {pr : Set a} → (v1 v2 : Valuation pr) → ({x : pr} → Valuation.v v1 (ofPrimitive x) ≡ Valuation.v v2 (ofPrimitive x)) → {x : Propositions pr} → Valuation.v v1 x ≡ Valuation.v v2 x\nvaluationIsDetermined v1 v2 pr {ofPrimitive x} = pr\nvaluationIsDetermined v1 v2 pr {false} rewrite Valuation.vFalse v1 | Valuation.vFalse v2 = refl\nvaluationIsDetermined v1 v2 pr {implies x y} with valuationIsDetermined v1 v2 pr {x}\nvaluationIsDetermined v1 v2 pr {implies x y} | eqX with valuationIsDetermined v1 v2 pr {y}\n... | eqY with inspect (Valuation.v v1 x)\nvaluationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolTrue with≡ p with inspect (Valuation.v v1 y)\nvaluationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolTrue with≡ p | BoolTrue with≡ q rewrite p | q | Valuation.vImplicationT v2 {p = x} {q = y} (equalityCommutative eqY) | Valuation.vImplicationT v1 {p = x} {q = y} q = refl\nvaluationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolTrue with≡ p | BoolFalse with≡ q rewrite p | q | Valuation.vImplicationF v1 p q | Valuation.vImplicationF v2 (equalityCommutative eqX) (equalityCommutative eqY) = refl\nvaluationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolFalse with≡ p rewrite p | Valuation.vImplicationVacuous v1 {q = y} p | Valuation.vImplicationVacuous v2 {q = y} (equalityCommutative eqX) = refl\n\nextendValuationV : {a : _} {pr : Set a} → (w : pr → Bool) → Propositions pr → Bool\nextendValuationV w (ofPrimitive x) = w x\nextendValuationV w false = BoolFalse\nextendValuationV w (implies x y) with extendValuationV w x\n... | BoolTrue with extendValuationV w y\nextendValuationV w (implies x y) | BoolTrue | BoolTrue = BoolTrue\n... | BoolFalse = BoolFalse\nextendValuationV w (implies x y) | BoolFalse = BoolTrue\n\nextendValuation : {a : _} {pr : Set a} → (w : pr → Bool) → Valuation pr\nValuation.v (extendValuation w) = extendValuationV w\nValuation.vFalse (extendValuation w) = refl\nValuation.vImplicationF (extendValuation w) {p} {q} pT qF with Valuation.v (extendValuation w) p\nValuation.vImplicationF (extendValuation w) {p} {q} refl qF | BoolTrue with Valuation.v (extendValuation w) q\nValuation.vImplicationF (extendValuation w) {p} {q} refl () | BoolTrue | BoolTrue\nValuation.vImplicationF (extendValuation w) {p} {q} refl refl | BoolTrue | BoolFalse = refl\nValuation.vImplicationF (extendValuation w) {p} {q} () qF | BoolFalse\nValuation.vImplicationVacuous (extendValuation w) {p} {q} pF with Valuation.v (extendValuation w) p\nValuation.vImplicationVacuous (extendValuation w) {p} {q} () | BoolTrue\nValuation.vImplicationVacuous (extendValuation w) {p} {q} refl | BoolFalse = refl\nValuation.vImplicationT (extendValuation w) {p} {q} qT with Valuation.v (extendValuation w) p\nValuation.vImplicationT (extendValuation w) {p} {q} qT | BoolTrue with Valuation.v (extendValuation w) q\nValuation.vImplicationT (extendValuation w) {p} {q} refl | BoolTrue | BoolTrue = refl\nValuation.vImplicationT (extendValuation w) {p} {q} () | BoolTrue | BoolFalse\nValuation.vImplicationT (extendValuation w) {p} {q} qT | BoolFalse = refl\n\n-- Proposition 1b\nvaluationsAreFree : {a : _} {pr : Set a} → (w : pr → Bool) → {x : pr} → Valuation.v (extendValuation w) (ofPrimitive x) ≡ w x\nvaluationsAreFree w = refl\n\nTautology : {a : _} {pr : Set a} (prop : Propositions pr) → Set a\nTautology {pr = pr} prop = (v : Valuation pr) → Valuation.v v prop ≡ BoolTrue\n\nrecord IsSubset {a b : _} (sub : Set a) (super : Set b) : Set (a ⊔ b) where\n field\n ofElt : sub → super\n\nmapProp : {a b : _} {pr1 : Set a} {pr2 : Set b} → (pr1 → pr2) → Propositions pr1 → Propositions pr2\nmapProp f (ofPrimitive x) = ofPrimitive (f x)\nmapProp f false = false\nmapProp f (implies p q) = implies (mapProp f p) (mapProp f q)\n\ninheritedValuation : {a b : _} {sub : Set a} {super : Set b} → (IsSubset sub super) → Valuation super → Valuation sub\nValuation.v (inheritedValuation isSub v) prop = Valuation.v v (mapProp (IsSubset.ofElt isSub) prop)\nValuation.vFalse (inheritedValuation isSub v) = Valuation.vFalse v\nValuation.vImplicationF (inheritedValuation isSub v) pT qF = Valuation.vImplicationF v pT qF\nValuation.vImplicationVacuous (inheritedValuation isSub v) pF = Valuation.vImplicationVacuous v pF\nValuation.vImplicationT (inheritedValuation isSub v) qT = Valuation.vImplicationT v qT\n\ninheritedValuation' : {a b : _} {sub : Set a} {super : Set b} → (IsSubset sub (Propositions super)) → Valuation super → (x : sub) → Bool\ninheritedValuation' subset v x = Valuation.v v (IsSubset.ofElt subset x)\n\nEntails : {a b : _} {sub : Set a} {super : Set b} (S : IsSubset sub (Propositions super)) (P : Propositions super) → Set (a ⊔ b)\nEntails {sub = sub} {super = super} S P = {v : Valuation super} → ({s : sub} → inheritedValuation' S v s ≡ BoolTrue) → Valuation.v v P ≡ BoolTrue\n\ndata ThreeElements : Set where\n One : ThreeElements\n Two : ThreeElements\n Three : ThreeElements\n\nindexAxiom : {a : _} (A : Set a) → ThreeElements → Set a\nindexAxiom A One = Propositions A && Propositions A\nindexAxiom A Two = Propositions A & Propositions A & Propositions A\nindexAxiom A Three = Propositions A\n\nindexPropositionalAxioms : {a : _} {A : Set a} → Set a\nindexPropositionalAxioms {A = A} = Sg ThreeElements (indexAxiom A)\n\n-- An axiom system is simply a subset of a set of propositions.\npropositionalAxioms : {a : _} {A : Set a} → IsSubset (indexPropositionalAxioms {A = A}) (Propositions A)\nIsSubset.ofElt propositionalAxioms (One , (p ,, q)) = implies p (implies q p)\nIsSubset.ofElt propositionalAxioms (Two , record { one = p ; two = q ; three = r }) = implies (implies p (implies q r)) (implies (implies p q) (implies p r))\nIsSubset.ofElt propositionalAxioms (Three , p) = implies (prNot (prNot p)) p\n\nrecord Selection {a : _} {A : Set a} {n : ℕ} (l : Vec A n) : Set a where\n field\n element : A\n position : ℕ\n pos` x2) = aeval Γ x1 + aeval Γ x2 + (Γ \">\")\ntbeval Γ (x1 ≤` x2) = aeval Γ x1 + aeval Γ x2 + (Γ \"≤\")\ntbeval Γ (x1 ≥` x2) = aeval Γ x1 + aeval Γ x2 + (Γ \"≥\")\ntbeval Γ (x1 ≡` x2) = aeval Γ x1 + aeval Γ x2 + (Γ \"≡\")\ntbeval Γ (¬` b) = tbeval Γ b + (Γ \"NOT\")\ntbeval Γ (b &&` b₁) = tbeval Γ b + tbeval Γ b₁ + (Γ \"AND\")\ntbeval Γ (b ||` b₁) = tbeval Γ b + tbeval Γ b₁ + (Γ \"OR\")\n\n\n-- Making the tuple type needed to hold the program\ndata TProgTuple {A : Set} : Set where\n _,_,_,_ : (a : ATuple) → (r : RTuple) → (c : Cmd {A}) → (cmt : ℕ) → TProgTuple\n\n-- Getting stuff from the TProgTuple\ngetProgCmdT : {A : Set} → (p : Maybe (TProgTuple {A})) → Cmd {A}\ngetProgCmdT (just (_ , _ , c , _)) = c\ngetProgCmdT nothing = SKIP -- Dangerous\n\ngetProgArgsT : {A : Set} → (p : Maybe (TProgTuple {A})) → ATuple \ngetProgArgsT (just (a , _ , _ , _)) = a\ngetProgArgsT nothing = Arg \"VOID\"\n\ngetProgRetsT : {A : Set} → (p : Maybe (TProgTuple {A})) → RTuple \ngetProgRetsT (just (_ , r , _ , _)) = r\ngetProgRetsT nothing = Ret \"VOID\"\n\ngetProgTimeT : {A : Set} → (p : Maybe (TProgTuple {A})) → ℕ\ngetProgTimeT (just (_ , _ , _ , t)) = t\ngetProgTimeT nothing = 0\n\n\ndata _,_=[_]=>ᴬ_ (Γ : (String → ℕ)) : ℕ → (ATuple) → ℕ → Set where\n\n hd : ∀ (W : ℕ) → ∀ (v : String) →\n Γ , W =[ Arg v ]=>ᴬ (W + (Γ \"arg-copy\"))\n\n tl : (l r : ATuple) → (W W' W'' : ℕ) →\n (Γ , W =[ l ]=>ᴬ (W + W')) → (Γ , W + W' =[ r ]=>ᴬ (W + W' + W'')) →\n -----------------------------------------------------------\n Γ , W =[ (l ,` r) ]=>ᴬ (W + W' + W'')\n\nnumargs : ∀ (args : ATuple) → ℕ\nnumargs (Arg v) = 1\nnumargs (args ,` args₁) = numargs args + numargs args₁\n\n-- soundness theorem for arg copy\nargs-sound : ∀ (Γ : (String → ℕ)) → ∀ (args : ATuple) → (W W' : ℕ)\n → (Γ , W =[ args ]=>ᴬ W')\n → (W + numargs args * (Γ \"arg-copy\")) ≡ W'\nargs-sound Γ .(Arg v) W .(W + Γ \"arg-copy\") (hd .W v)\n rewrite +-comm (Γ \"arg-copy\") 0 = refl\nargs-sound Γ .(l ,` r) W .(W + W' + W'') (tl l r .W W' W'' cmd cmd₁)\n with (Γ \"arg-copy\") in eq\n... | u rewrite *-distribʳ-+ u (numargs l) (numargs r)\n | +-comm W (((numargs l) * u) + ((numargs r) * u))\n | +-comm ((numargs l) * u) ((numargs r) * u)\n | +-assoc ((numargs r) * u) ((numargs l) * u) W\n | +-comm ((numargs l) * u) W\n | +-comm ((numargs r) * u) (W + ((numargs l) * u))\n with args-sound Γ l W (W + W') cmd\n... | j with args-sound Γ r (W + W') (W + W' + W'') cmd₁\n... | k with +-cancelˡ-≡ W j | +-cancelˡ-≡ (W + W') k | eq\n... | refl | refl | refl = refl\n\n\ndata _,_=[_]=>ᴿ_ (Γ : (String → ℕ)) : ℕ → RTuple → ℕ → Set where\n hd : ∀ (W : ℕ) → ∀ (v : String) →\n Γ , W =[ Ret v ]=>ᴿ (W + (Γ \"ret-copy\"))\n\n tl : (l r : RTuple) → (W W' W'' : ℕ) →\n (Γ , W =[ l ]=>ᴿ (W + W')) → (Γ , W + W' =[ r ]=>ᴿ (W + W' + W'')) →\n -----------------------------------------------------------\n Γ , W =[ (l ,` r) ]=>ᴿ (W + W' + W'')\n\nnumrets : ∀ (rets : RTuple) → ℕ\nnumrets (Ret v) = 1\nnumrets (rets ,` rets₁) = numrets rets + numrets rets₁\n\n-- soundness theorem for ret copy\nrets-sound : ∀ (Γ : (String → ℕ)) → ∀ (rets : RTuple) → (W W' : ℕ)\n → Γ , W =[ rets ]=>ᴿ W'\n → (W + numrets rets * (Γ \"ret-copy\")) ≡ W'\nrets-sound Γ .(Ret v) W .(W + Γ \"ret-copy\") (hd .W v)\n rewrite +-comm (Γ \"ret-copy\") 0 = refl\nrets-sound Γ .(l ,` r) W .(W + W' + W'') (tl l r .W W' W'' cmd cmd₁)\n with (Γ \"ret-copy\") in eq\n... | u rewrite *-distribʳ-+ u (numrets l) (numrets r)\n | +-comm W (((numrets l) * u) + ((numrets r) * u))\n | +-comm ((numrets l) * u) ((numrets r) * u)\n | +-assoc ((numrets r) * u) ((numrets l) * u) W\n | +-comm ((numrets l) * u) W\n | +-comm ((numrets r) * u) (W + ((numrets l) * u))\n with rets-sound Γ l W (W + W') cmd\n... | j with rets-sound Γ r (W + W') (W + W' + W'') cmd₁\n... | k with +-cancelˡ-≡ W j | +-cancelˡ-≡ (W + W') k | eq\n... | refl | refl | refl = refl\n\nmutual\n-- Semantics of time from here\n data _,_,_=[_]=>_ (Γ : (String → Maybe (TProgTuple {ℕ}))) (st : String → ℕ) :\n ℕ → Cmd {ℕ} → ℕ → Set where\n TSKIP : ∀ (W : ℕ) → Γ , st , W =[ SKIP ]=> (W + 0)\n\n TASSIGN : ∀ (X : String) → ∀ (n : ℕ) → ∀ (e : Aexp {ℕ})\n → ∀ (W : ℕ) →\n ---------------------------------\n Γ , st , W =[ (Var X := e) ]=> (W + (taeval st e) + (st \"store\"))\n\n TSEQ : ∀ (c1 c2 : Cmd {ℕ})\n → ∀ (W W' W'' : ℕ)\n → Γ , st , W =[ c1 ]=> (W + W')\n → Γ , st , (W + W') =[ c2 ]=> (W + (W' + W'')) →\n --------------------------------------------\n Γ , st , W =[ c1 ; c2 ]=> (W + (W' + W''))\n\n -- XXX: Hack, st contains both exec time and state!\n TIFT : (n1 : ℕ) → (b : Bexp {ℕ}) →\n (t e : Cmd {ℕ}) → ∀ (W W' W'' : ℕ)\n → (beval st b ≡ true)\n → Γ , st , W =[ t ]=> (W + W')\n → Γ , st , W =[ e ]=> (W + W'')\n → Γ , st , W =[ (IF b THEN t ELSE e END) ]=>\n (W + W' + (tbeval st b))\n\n TIFE : (n1 : ℕ) → (b : Bexp {ℕ}) →\n (t e : Cmd {ℕ}) → ∀ (W W' W'' : ℕ)\n → (beval st b ≡ false)\n → Γ , st , W =[ t ]=> (W + W')\n → Γ , st , W =[ e ]=> (W + W'')\n → Γ , st , W =[ (IF b THEN t ELSE e END) ]=>\n (W + W'' + (tbeval st b))\n\n TLF : (b : Bexp {ℕ}) → (c : Cmd {ℕ}) →\n beval st b ≡ false →\n ∀ (W : ℕ) →\n -----------------------------------------------------------\n Γ , st , W =[ (WHILE b DO c END) ]=>\n (W + 0 + (tbeval st b))\n\n TLT : (b : Bexp {ℕ}) → (c : Cmd {ℕ}) →\n beval st b ≡ true → ∀ (W W' : ℕ) →\n -----------------------------------------------------------\n Γ , st , W =[ c ]=> (W + W') →\n Γ , st , W =[ (WHILE b DO c END) ]=>\n (W + ((st \"loop-count\") * (W' + (tbeval st b))) + (tbeval st b))\n\n -- CEX : ∀ (f : FuncCall {ℕ}) → ∀ (st st' : (String → ℕ))\n -- → Γ , st =[ f ]=>ᶠ st'\n -- -----------------------------------------------------------\n -- → Γ , st =[ EXEC f ]=> st'\n \n data _,_,_=[_]=>ᶠ_ (Γ : String → (Maybe (TProgTuple {ℕ})))\n (st : String → ℕ) :\n ℕ → FuncCall {ℕ} → ℕ → Set where\n\n Base : ∀ (fname : String) → -- name of the function\n ∀ (W W' W'' W''' : ℕ)\n\n -- time to put args on function stack\n → st , W =[ getProgArgsT (Γ fname) ]=>ᴬ (W + W') \n\n -- Proof that WCET is what we have in the tuple\n → (wcet-is : (getProgTimeT (Γ fname)) ≡ W'')\n -- time to run the function\n → Γ , st , (W + W') =[ getProgCmdT (Γ fname) ]=> (W + W' + W'')\n\n -- copying ret values back on caller' stack\n → st , (W + W' + W'')\n =[ getProgRetsT (Γ fname) ]=>ᴿ (W + W' + W'' + W''')\n\n -----------------------------------------------------------\n → Γ , st , W =[ < getProgRetsT (Γ fname) >:=\n fname < getProgArgsT (Γ fname) > ]=>ᶠ (W + W' + W'' + W''')\n\n PAR : ∀ (l r : FuncCall {ℕ}) → ∀ (W X1 X2 : ℕ)\n → Γ , st , W =[ l ]=>ᶠ (W + X1)\n → Γ , st , W =[ r ]=>ᶠ (W + X2)\n -----------------------------------------------------------\n → Γ , st , W =[ l ||` r ]=>ᶠ (W + (max X1 X2) + ((2 * (st \"fork\"))\n + (2 * (st \"join\"))))\n\n-- Soundness theorem for SKIP WCET rule\nskip-sound : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ) -- map of labels to execution times\n → ∀ (W W' X : ℕ) → (cmd : Γ , Γᵗ , W =[ SKIP ]=> W')\n → (W ≡ X) → (W' ≡ X)\nskip-sound Γ Γᵗ W .(W + 0) .W (TSKIP .W) refl rewrite +-comm W 0 = refl\n\n-- Soundness theorem for Assign WCET rule\nassign-sound : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : (String → ℕ))\n → (S : String) → (e : Aexp {ℕ})\n → (W W' : ℕ) → (cmd : Γ , Γᵗ , W =[ Var S := e ]=> W')\n → (W' ≡ W + (taeval Γᵗ e) + (Γᵗ \"store\"))\nassign-sound Γ Γᵗ S e W .(W + taeval Γᵗ e + Γᵗ \"store\") (TASSIGN .S n .e .W)\n = refl\n\n\n-- Deterministic exec\nΔ-exec : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → ∀ (W W' W'' : ℕ) → (c1 : Cmd {ℕ})\n → (Γ , Γᵗ , W =[ c1 ]=> W')\n → (Γ , Γᵗ , W =[ c1 ]=> W'')\n → W' ≡ W''\nΔ-exec Γ Γᵗ W .(W + taeval Γᵗ e + Γᵗ \"store\")\n .(W + taeval Γᵗ e + Γᵗ \"store\") (Var X := e) (TASSIGN .X n₁ .e .W)\n (TASSIGN .X n .e .W) = refl\nΔ-exec Γ Γᵗ W .(W + 0) .(W + 0) .SKIP (TSKIP .W) (TSKIP .W) = refl\nΔ-exec Γ Γᵗ W .(W + (W' + W''')) .(W + (W'' + W''''))\n .(c1 ; c2) (TSEQ c1 c2 .W W' W''' p1 p3) (TSEQ .c1 .c2 .W W'' W'''' p2 p4)\n with Δ-exec Γ Γᵗ W (W + W') (W + W'') c1 p1 p2\n... | r with +-cancelˡ-≡ W r\n... | refl\n with Δ-exec Γ Γᵗ (W + W') (W + (W' + W''')) (W + (W' + W'''')) c2 p3 p4\n... | rr with +-cancelˡ-≡ W rr\n... | rm with +-cancelˡ-≡ W' rm\n... | refl = refl\nΔ-exec Γ Γᵗ W .(W + 0 + tbeval Γᵗ b)\n .(W + 0 + tbeval Γᵗ b) WHILE b DO c END (TLF .b .c x .W)\n (TLF .b .c x₁ .W) = refl\nΔ-exec Γ Γᵗ W .(W + Γᵗ \"loop-count\" * (W' + tbeval Γᵗ b) + _)\n .(W + 0 + tbeval Γᵗ b) WHILE b DO c END (TLT .b .c x .W W' x₂)\n (TLF .b .c x₁ .W) = ⊥-elim (contradiction-lemma b Γᵗ x x₁)\nΔ-exec Γ Γᵗ W .(W + 0 + tbeval Γᵗ b)\n .(W + Γᵗ \"loop-count\" * (W'' + tbeval Γᵗ b) + _) WHILE b DO c END\n (TLF .b .c x .W) (TLT .b .c x₁ .W W'' x₂)\n = ⊥-elim (contradiction-lemma b Γᵗ x₁ x)\nΔ-exec Γ Γᵗ W .(W + Γᵗ \"loop-count\" * (W' + tbeval Γᵗ b) + _)\n .(W + Γᵗ \"loop-count\" * (W'' + tbeval Γᵗ b) + _) WHILE b DO c END\n (TLT .b .c x .W W' x₃) (TLT .b .c x₁ .W W'' x₂)\n with Δ-exec Γ Γᵗ W (W + W') (W + W'') c x₃ x₂\n... | l with +-cancelˡ-≡ W l\n... | refl = refl\nΔ-exec Γ Γᵗ W .(W + W' + tbeval Γᵗ b)\n .(W + W'' + tbeval Γᵗ b) IF b THEN t ELSE e END\n (TIFT n2 .b .t .e .W W' W'''' x x₄ x₅)\n (TIFT n1 .b .t .e .W W'' W''' x₁ x₂ x₃)\n with Δ-exec Γ Γᵗ W (W + W') (W + W'') t x₄ x₂\n... | y with +-cancelˡ-≡ W y\n... | refl = refl\nΔ-exec Γ Γᵗ W .(W + W'''' + tbeval Γᵗ b)\n .(W + W'' + tbeval Γᵗ b) IF b THEN t ELSE e END\n (TIFE n2 .b .t .e .W W' W'''' x x₄ x₅)\n (TIFT n1 .b .t .e .W W'' W''' x₁ x₂ x₃)\n = ⊥-elim (contradiction-lemma b Γᵗ x₁ x)\nΔ-exec Γ Γᵗ W .(W + W' + tbeval Γᵗ b)\n .(W + W''' + tbeval Γᵗ b) IF b THEN t ELSE e END\n (TIFT n2 .b .t .e .W W' W'''' x x₄ x₅)\n (TIFE n1 .b .t .e .W W'' W''' x₁ x₂ x₃)\n = ⊥-elim (contradiction-lemma b Γᵗ x x₁)\nΔ-exec Γ Γᵗ W .(W + W'''' + tbeval Γᵗ b)\n .(W + W''' + tbeval Γᵗ b) IF b THEN t ELSE e END\n (TIFE n2 .b .t .e .W W' W'''' x x₄ x₅)\n (TIFE n1 .b .t .e .W W'' W''' x₁ x₂ x₃)\n with Δ-exec Γ Γᵗ W (W + W''') (W + W'''') e x₃ x₅\n... | y with +-cancelˡ-≡ W y\n... | refl = refl\n\n\n-- Deterministic execution of a function\nΔ-exec-func : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ) → (l : FuncCall {ℕ})\n → (W W' W'' : ℕ)\n → Γ , Γᵗ , W =[ l ]=>ᶠ W'\n → Γ , Γᵗ , W =[ l ]=>ᶠ W''\n → W' ≡ W''\nΔ-exec-func Γ Γᵗ\n .(< getProgRetsT (Γ fname) >:= fname < getProgArgsT (Γ fname) >) W\n .(W + W' + getProgTimeT (Γ fname) + W'''')\n .(W + W'' + getProgTimeT (Γ fname) + W'''''')\n (Base fname .W W' .(getProgTimeT (Γ fname)) W'''' x refl x₁ x₂)\n (Base .fname .W W'' .(getProgTimeT (Γ fname)) W'''''' x₃ refl x₄ x₅)\n with args-sound Γᵗ (getProgArgsT (Γ fname)) W (W + W') x\n | args-sound Γᵗ (getProgArgsT (Γ fname)) W (W + W'') x₃\n | rets-sound Γᵗ (getProgRetsT (Γ fname)) (W + W' + getProgTimeT (Γ fname))\n (W + W' + getProgTimeT (Γ fname) + W'''') x₂\n | rets-sound Γᵗ (getProgRetsT (Γ fname)) (W + W'' + getProgTimeT (Γ fname))\n (W + W'' + getProgTimeT (Γ fname) + W'''''') x₅\n... | l | l1 | r1 | r2\n with +-cancelˡ-≡ W l | +-cancelˡ-≡ W l1\n... | refl | refl with +-cancelˡ-≡\n (W + numargs (getProgArgsT (Γ fname)) * Γᵗ \"arg-copy\"\n + getProgTimeT (Γ fname)) r2\n... | refl with +-cancelˡ-≡\n (W + numargs (getProgArgsT (Γ fname)) * Γᵗ \"arg-copy\"\n + getProgTimeT (Γ fname)) r1\n... | refl = refl\nΔ-exec-func Γ Γᵗ .(l ||` r) W\n .(W + max X1 X2 + (2 * Γᵗ \"fork\" + 2 * Γᵗ \"join\"))\n .(W + max X3 X4 + (2 * Γᵗ \"fork\" + 2 * Γᵗ \"join\"))\n (PAR l r .W X1 X2 e1 e3) (PAR .l .r .W X3 X4 e2 e4)\n with Δ-exec-func Γ Γᵗ l W (W + X1) (W + X3) e1 e2\n | Δ-exec-func Γ Γᵗ r W (W + X2) (W + X4) e3 e4\n... | m | y with +-cancelˡ-≡ W m | +-cancelˡ-≡ W y\n... | refl | refl = refl\n\n\nskip-cancel : ∀ (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → ∀ (W1 W2 X1 X2 : ℕ)\n → (Γ , Γᵗ , W1 =[ SKIP ]=> (W1 + X1))\n → (Γ , Γᵗ , W2 =[ SKIP ]=> (W2 + X2))\n → X1 ≡ X2\nskip-cancel Γ Γᵗ W1 W2 X1 X2 p1 p2 with (W1 + X1) in eq1\nskip-cancel Γ Γᵗ W1 W2 X1 X2 (TSKIP .W1) p2 | .(W1 + 0)\n with +-cancelˡ-≡ W1 eq1\nskip-cancel Γ Γᵗ W1 W2 X1 X2 (TSKIP .W1) p2 | .(W1 + 0) | refl\n with (W2 + X2) in eq2\nskip-cancel Γ Γᵗ W1 W2 _ X2 (TSKIP .W1) (TSKIP .W2)\n | .(W1 + _) | refl | .(W2 + 0) with +-cancelˡ-≡ W2 eq2\n... | refl = refl\n\nassign-cancel : ∀ (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → ∀ (W1 W2 X1 X2 : ℕ)\n → (S : String) → (e : Aexp {ℕ})\n → (Γ , Γᵗ , W1 =[ Var S := e ]=> (W1 + X1))\n → (Γ , Γᵗ , W2 =[ Var S := e ]=> (W2 + X2))\n → X1 ≡ X2\nassign-cancel Γ Γᵗ W1 W2 X1 X2 S e cmd1 cmd2 with (W1 + X1) in eq1\n | (W2 + X2) in eq2\nassign-cancel Γ Γᵗ W1 W2 X1 X2 S e (TASSIGN .S n .e .W1)\n (TASSIGN .S n₁ .e .W2) | .(W1 + taeval Γᵗ e + Γᵗ \"store\")\n | .(W2 + taeval Γᵗ e + Γᵗ \"store\")\n rewrite +-assoc W1 (taeval Γᵗ e) (Γᵗ \"store\")\n | +-assoc W2 (taeval Γᵗ e) (Γᵗ \"store\")\n with +-cancelˡ-≡ W1 eq1 | +-cancelˡ-≡ W2 eq2\n... | refl | refl = refl\n\nloop-cancel : ∀ (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → ∀ (W1 W2 X1 X2 : ℕ)\n → (b : Bexp {ℕ})\n → (c : Cmd {ℕ}) \n → (Γ , Γᵗ , W1 =[ (WHILE b DO c END) ]=> (W1 + X1))\n → (Γ , Γᵗ , W2 =[ (WHILE b DO c END) ]=> (W2 + X2))\n → X1 ≡ X2\nife-cancel : ∀ (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → ∀ (W1 W2 X1 X2 : ℕ)\n → (b : Bexp {ℕ})\n → (t e : Cmd {ℕ}) \n → (Γ , Γᵗ , W1 =[ ( IF b THEN t ELSE e END ) ]=> (W1 + X1))\n → (Γ , Γᵗ , W2 =[ ( IF b THEN t ELSE e END ) ]=> (W2 + X2))\n → X1 ≡ X2\nseq-cancel : ∀ (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → ∀ (W1 W2 X1 X2 : ℕ)\n → (c1 c2 : Cmd {ℕ}) \n → (Γ , Γᵗ , W1 =[ ( c1 ; c2) ]=> (W1 + X1))\n → (Γ , Γᵗ , W2 =[ ( c1 ; c2) ]=> (W2 + X2))\n → X1 ≡ X2\n\n-- The general case of cancellation.\neq-cancel : ∀ (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → ∀ (c : Cmd {ℕ})\n → ∀ (W1 W2 X1 X2 : ℕ)\n → (Γ , Γᵗ , W1 =[ c ]=> (W1 + X1))\n → (Γ , Γᵗ , W2 =[ c ]=> (W2 + X2))\n → X1 ≡ X2\n\nloop-cancel Γ Γᵗ W1 W2 X1 X2 b c cmd1 cmd2\n with (W1 + X1) in eq1 | (W2 + X2) in eq2\nloop-cancel Γ Γᵗ W1 W2 X1 X2 b c (TLF .b .c x .W1)\n (TLF .b .c x₁ .W2) | .(W1 + 0 + tbeval Γᵗ b) | .(W2 + 0 + tbeval Γᵗ b)\n rewrite +-assoc W1 0 (tbeval Γᵗ b) | +-assoc W2 0 (tbeval Γᵗ b)\n with +-cancelˡ-≡ W1 eq1 | +-cancelˡ-≡ W2 eq2\n... | refl | refl = refl\nloop-cancel Γ Γᵗ W1 W2 X1 X2 b c (TLF .b .c x .W1)\n (TLT .b .c x₁ .W2 W' cmd2) | .(W1 + 0 + tbeval Γᵗ b)\n | .(W2 + Γᵗ \"loop-count\" * (W' + tbeval Γᵗ b) + tbeval Γᵗ b)\n = ⊥-elim (contradiction-lemma b Γᵗ x₁ x)\nloop-cancel Γ Γᵗ W1 W2 X1 X2 b c (TLT .b .c x .W1 W' cmd1)\n (TLF .b .c x₁ .W2)\n | .(W1 + Γᵗ \"loop-count\" * (W' + tbeval Γᵗ b) + tbeval Γᵗ b)\n | .(W2 + 0 + tbeval Γᵗ b) = ⊥-elim (contradiction-lemma b Γᵗ x x₁)\nloop-cancel Γ Γᵗ W1 W2 X1 X2 b c (TLT .b .c x .W1 W' cmd1)\n (TLT .b .c x₁ .W2 W'' cmd2)\n | .(W1 + Γᵗ \"loop-count\" * (W' + tbeval Γᵗ b) + tbeval Γᵗ b)\n | .(W2 + Γᵗ \"loop-count\" * (W'' + tbeval Γᵗ b) + tbeval Γᵗ b)\n with eq-cancel Γ Γᵗ c W1 W2 W' W'' cmd1 cmd2\n... | refl with (Γᵗ \"loop-count\") | (tbeval Γᵗ b)\n... | LC | BC rewrite +-assoc W2 (LC * (W' + BC)) BC\n | +-assoc W1 (LC * (W' + BC)) BC\n with +-cancelˡ-≡ W2 eq2 | +-cancelˡ-≡ W1 eq1\n... | refl | refl = refl\n\nife-cancel Γ Γᵗ W1 W2 X1 X2 b t e p1 p2 with (W1 + X1) in eq1\n | (W2 + X2) in eq2\nife-cancel Γ Γᵗ W1 W2 X1 X2 b t e (TIFT n1 .b .t .e .W1 W' W'' x p1 p3)\n (TIFT n2 .b .t .e .W2 W''' W'''' x₁ p2 p4) | .(W1 + W' + tbeval Γᵗ b)\n | .(W2 + W''' + tbeval Γᵗ b) with eq-cancel Γ Γᵗ t W1 W2 W' W''' p1 p2\n... | refl rewrite +-assoc W2 W' (tbeval Γᵗ b) | +-assoc W1 W' (tbeval Γᵗ b)\n with +-cancelˡ-≡ W2 eq2 | +-cancelˡ-≡ W1 eq1\n... | refl | refl = refl\nife-cancel Γ Γᵗ W1 W2 X1 X2 b t e (TIFT n1 .b .t .e .W1 W' W'' x p1 p3)\n (TIFE n2 .b .t .e .W2 W''' W'''' x₁ p2 p4) | .(W1 + W' + tbeval Γᵗ b)\n | .(W2 + W'''' + tbeval Γᵗ b) = ⊥-elim (contradiction-lemma b Γᵗ x x₁)\nife-cancel Γ Γᵗ W1 W2 X1 X2 b t e (TIFE n1 .b .t .e .W1 W' W'' x p1 p3)\n (TIFT n2 .b .t .e .W2 W''' W'''' x₁ p2 p4) | .(W1 + W'' + tbeval Γᵗ b)\n | .(W2 + W''' + tbeval Γᵗ b) = ⊥-elim (contradiction-lemma b Γᵗ x₁ x)\nife-cancel Γ Γᵗ W1 W2 X1 X2 b t e (TIFE n1 .b .t .e .W1 W' W'' x p1 p3)\n (TIFE n2 .b .t .e .W2 W''' W'''' x₁ p2 p4) | .(W1 + W'' + tbeval Γᵗ b)\n | .(W2 + W'''' + tbeval Γᵗ b) rewrite +-assoc W1 W'' (tbeval Γᵗ b)\n | +-assoc W2 W'''' (tbeval Γᵗ b) with +-cancelˡ-≡ W2 eq2\n | +-cancelˡ-≡ W1 eq1 | eq-cancel Γ Γᵗ e W1 W2 W'' W'''' p3 p4\n... | refl | refl | refl = refl\n\nseq-cancel Γ Γᵗ W1 W2 X1 X2 c1 c2 p1 p2 with (W1 + X1) in eq1\n | (W2 + X2) in eq2\nseq-cancel Γ Γᵗ W1 W2 X1 X2 c1 c2 (TSEQ .c1 .c2 .W1 W' W'' p1 p3)\n (TSEQ .c1 .c2 .W2 W''' W'''' p2 p4)\n | .(W1 + (W' + W'')) | .(W2 + (W''' + W''''))\n rewrite +-cancelˡ-≡ W1 eq1 | +-cancelˡ-≡ W2 eq2\n with eq-cancel Γ Γᵗ c1 W1 W2 W' W''' p1 p2\n... | refl\n rewrite \n +-comm W''' W''\n | +-comm W1 (W'' + W''') | +-assoc W'' W''' W1 | +-comm W''' W1\n | +-comm W'' (W1 + W''') | +-comm W''' W'''' | +-comm W2 (W'''' + W''')\n | +-assoc W'''' W''' W2 | +-comm W''' W2 | +-comm W'''' (W2 + W''')\n with (W1 + W''') | (W2 + W''')\n... | l | m\n with eq-cancel Γ Γᵗ c2 l m W'' W'''' p3 p4\n... | refl = refl\n\neq-cancel Γ Γᵗ SKIP W1 W2 X1 X2 p1 p2 = skip-cancel Γ Γᵗ W1 W2 X1 X2 p1 p2\neq-cancel Γ Γᵗ (Var x := r) W1 W2 X1 X2 p1 p2\n = assign-cancel Γ Γᵗ W1 W2 X1 X2 x r p1 p2\neq-cancel Γ Γᵗ (c ; c₁) W1 W2 X1 X2 p1 p2\n = seq-cancel Γ Γᵗ W1 W2 X1 X2 c c₁ p1 p2\neq-cancel Γ Γᵗ IF b THEN c ELSE c₁ END W1 W2 X1 X2 p1 p2\n = ife-cancel Γ Γᵗ W1 W2 X1 X2 b c c₁ p1 p2\neq-cancel Γ Γᵗ WHILE b DO c END W1 W2 X1 X2 p1 p2\n = loop-cancel Γ Γᵗ W1 W2 X1 X2 b c p1 p2\n\n-- TODO: The function call case and concurrency cases will go here\n\n-- Soundness theorem for Seq WCET rule\nseq-sound : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → (c1 c2 : Cmd {ℕ})\n → (W X1 X2 W' : ℕ)\n → (cmd : Γ , Γᵗ , W =[ c1 ; c2 ]=> W')\n → (p1 : Γ , Γᵗ , W =[ c1 ]=> (W + X1))\n → (p2 : Γ , Γᵗ , W =[ c2 ]=> (W + X2))\n → (W' ≡ W + (X1 + X2))\nseq-sound Γ Γᵗ c1 c2 W X1 X2 .(W + (W' + W''))\n (TSEQ .c1 .c2 .W W' W'' cmd cmd₁) p1 p2\n with Δ-exec Γ Γᵗ W (W + W') (W + X1) c1 cmd p1\n... | q with +-cancelˡ-≡ W q\n... | refl rewrite +-comm W (X1 + W'') | +-comm X1 W'' | +-assoc W'' X1 W\n | +-comm X1 W | +-comm W'' (W + X1) | +-comm X1 X2 | +-comm W (X2 + X1)\n | +-assoc X2 X1 W | +-comm X2 (X1 + W) | +-comm X1 W with (W + X1)\n... | rl with eq-cancel Γ Γᵗ c2 rl W W'' X2 cmd₁ p2\n... | refl = refl\n\n\n-- Helping lemma for ife\nplus-≤ : ∀ (m n p : ℕ) → (m ≤ n) → (m + p) ≤ (n + p)\nplus-≤ .zero n p z≤n = m≤n+m p n\nplus-≤ .(suc _) .(suc _) p (s≤s {m} {n} q) with plus-≤ m n p q\n... | H0 = s≤s H0\n\n≤-rela1 : ∀ (m n : ℕ) → ¬ (m ≤ n) → (n < m)\n≤-rela1 zero n p = ⊥-elim (p z≤n)\n≤-rela1 (suc m) zero p = s≤s z≤n\n≤-rela1 (suc m) (suc n) p = s≤s (≤-rela1 m n (λ z → p (s≤s z)))\n\n≤-rela2 : ∀ (m n : ℕ) → (suc n ≤ m) → (n ≤ m)\n≤-rela2 m n p with n≤1+n n\n... | q = ≤-trans q p\n\n-- if-helper\nif-helper : ∀ (X1 X2 : ℕ) → (X1 ≤ max X1 X2)\nif-helper X1 X2 with (X1 ≤? X2)\n... | false Relation.Nullary.because proof = ≤′⇒≤ ≤′-refl\n... | true Relation.Nullary.because Relation.Nullary.ofʸ p = p\n\nif-helper2 : ∀ (X1 X2 : ℕ) → (X2 ≤ max X1 X2)\nif-helper2 X1 X2 with (X1 ≤? X2)\nif-helper2 X1 X2 | false Relation.Nullary.because Relation.Nullary.ofⁿ ¬p\n with ≤-rela1 X1 X2 (¬p)\n... | q = ≤-rela2 X1 X2 q\nif-helper2 X1 X2 | true Relation.Nullary.because _ = ≤′⇒≤ ≤′-refl\n\n-- Soundness theorem for If-else WCET rule\nife-sound : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → (t e : Cmd {ℕ})\n → (b : Bexp {ℕ})\n → (W X1 X2 W' : ℕ)\n → (tcmd : Γ , Γᵗ , W =[ t ]=> (W + X1))\n → (ecmd : Γ , Γᵗ , W =[ e ]=> (W + X2))\n → (cmd : Γ , Γᵗ , W =[ (IF b THEN t ELSE e END) ]=> W')\n → (W' ≤ W + (max X1 X2) + (tbeval Γᵗ b))\nife-sound Γ Γᵗ t e b W X1 X2 .(W + W' + tbeval Γᵗ b) tcmd ecmd\n (TIFT n1 .b .t .e .W W' W'' x cmd cmd₁)\n with Δ-exec Γ Γᵗ W (W + W') (W + X1) t cmd tcmd\n... | l with +-cancelˡ-≡ W l\n... | refl rewrite +-assoc W X1 (tbeval Γᵗ b) | +-comm W (X1 + (tbeval Γᵗ b))\n | +-assoc X1 (tbeval Γᵗ b) W with (tbeval Γᵗ b)\n... | Y with max X1 X2 in eq\n... | M rewrite +-assoc W M Y | +-comm W (M + Y) | +-assoc M Y W\n with (Y + W)\n... | L with if-helper X1 X2 | eq\n... | T | refl = plus-≤ X1 M L T\nife-sound Γ Γᵗ t e b W X1 X2 .(W + W'' + tbeval Γᵗ b) tcmd ecmd\n (TIFE n1 .b .t .e .W W' W'' x cmd cmd₁)\n with (tbeval Γᵗ b) | Δ-exec Γ Γᵗ W (W + W'') (W + X2) e cmd₁ ecmd\n... | Y | l with +-cancelˡ-≡ W l\n... | refl with max X1 X2 in eq\n... | M rewrite +-assoc W X2 Y | +-assoc W M Y | +-comm W (X2 + Y)\n | +-comm W (M + Y) | +-assoc X2 Y W | +-assoc M Y W with (Y + W)\n... | L with if-helper2 X1 X2 | eq\n... | T | refl = plus-≤ X2 M L T\n\n-- Helper for loop\nloop-helper : ∀ (l g : ℕ) → (l ≤′ (g + l))\nloop-helper l zero = ≤′-refl\nloop-helper l (suc g) = ≤′-step (loop-helper l g)\n\n-- XXX: Using well founded recursion here\nloop-sound-≤′ : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → (c : Cmd {ℕ})\n → (b : Bexp {ℕ})\n → (W W' X1 : ℕ)\n → (Γ , Γᵗ , W =[ c ]=> (W + X1))\n → (cmd : Γ , Γᵗ , W =[ (WHILE b DO c END) ]=> W')\n → W' ≤′\n W + ((Γᵗ \"loop-count\") * (X1 + (tbeval Γᵗ b))) + (tbeval Γᵗ b)\nloop-sound-≤′ Γ Γᵗ c b W .(W + 0 + tbeval Γᵗ b) X1 cmd (TLF .b .c x .W)\n with (Γᵗ \"loop-count\")\n... | zero = ≤′-refl\n... | suc m rewrite +-comm W 0\n with (tbeval Γᵗ b)\n... | q\n with (X1 + q + m * (X1 + q))\n... | t rewrite +-comm W t | +-assoc t W q with (W + q)\n... | l = loop-helper l t\nloop-sound-≤′ Γ Γᵗ c b W\n .(W + Γᵗ \"loop-count\" * (W' + tbeval Γᵗ b) + tbeval Γᵗ b) X1 cmd\n (TLT .b .c x .W W' cmd1)\n with Δ-exec Γ Γᵗ W (W + W') (W + X1) c cmd1 cmd\n... | r with +-cancelˡ-≡ W r\n... | refl = ≤′-refl\n\n-- The general case \nloop-sound : (Γ : String → Maybe (TProgTuple {ℕ}))\n → (Γᵗ : String → ℕ)\n → (c : Cmd {ℕ})\n → (b : Bexp {ℕ})\n → (W W' X1 : ℕ)\n → (Γ , Γᵗ , W =[ c ]=> (W + X1))\n → (cmd : Γ , Γᵗ , W =[ (WHILE b DO c END) ]=> W')\n → W' ≤\n W + ((Γᵗ \"loop-count\") * (X1 + (tbeval Γᵗ b))) + (tbeval Γᵗ b)\nloop-sound Γ Γᵗ c b W W' X1 c2 cmd =\n ≤′⇒≤ (loop-sound-≤′ Γ Γᵗ c b W W' X1 c2 cmd)\n\n\n-- The soundness theorem for a single function call\nfunc-sound : (Γ : String → Maybe (TProgTuple {ℕ})) → ∀ (Γᵗ : String → ℕ)\n → ∀ (fname : String) → ∀ (W W' : ℕ)\n → Γ , Γᵗ , W =[ < getProgRetsT (Γ fname) >:=\n fname < getProgArgsT (Γ fname) > ]=>ᶠ W'\n → W' ≡ (W +\n ((numargs $ getProgArgsT $ (Γ fname)) * (Γᵗ \"arg-copy\"))\n + (getProgTimeT (Γ fname))\n + ((numrets $ getProgRetsT $ (Γ fname)) * (Γᵗ \"ret-copy\")))\nfunc-sound Γ Γᵗ fname W .(W + W' + getProgTimeT (Γ fname) + W''')\n (Base .fname .W W' .(getProgTimeT (Γ fname)) W''' x refl x₁ x₂)\n with args-sound Γᵗ (getProgArgsT (Γ fname)) W (W + W') x\n | rets-sound Γᵗ (getProgRetsT (Γ fname))\n (W + W' + getProgTimeT (Γ fname))\n (W + W' + getProgTimeT (Γ fname) + W''') x₂\n... | l | m with +-cancelˡ-≡ W l\n... | refl\n with +-cancelˡ-≡ (W + numargs (getProgArgsT (Γ fname)) * Γᵗ \"arg-copy\"\n + getProgTimeT (Γ fname)) m\n... | refl = refl\n\n-- The soundness theorem for PAR (||`) execution of threads\npar-sound : (Γ : String → Maybe (TProgTuple {ℕ})) → ∀ (Γᵗ : String → ℕ)\n → (l r : FuncCall {ℕ}) → (W W' X1 X2 : ℕ)\n → Γ , Γᵗ , W =[ l ||` r ]=>ᶠ W'\n → Γ , Γᵗ , W =[ l ]=>ᶠ (W + X1)\n → Γ , Γᵗ , W =[ r ]=>ᶠ (W + X2)\n → W' ≡ W + (max X1 X2) + 2 * ((Γᵗ \"fork\") + (Γᵗ \"join\"))\npar-sound Γ Γᵗ l r W .(W + max X3 X4 + (2 * Γᵗ \"fork\" + 2 * Γᵗ \"join\"))\n X1 X2 (PAR .l .r .W X3 X4 pare pare₁) parl parr\n with (Γᵗ \"fork\") | (Γᵗ \"join\")\n... | tf | tj rewrite *-distribˡ-+ 2 tf tj\n | +-assoc tf tj 0 | +-comm tj 0 | +-comm tf 0\n | +-assoc tf tj (tf + tj) | +-comm tj (tf + tj)\n | +-assoc tf tj tj | +-comm tf (tf + (tj + tj))\n | +-comm tf (tj + tj) with (tf + tf + (tj + tj))\n... | m with Δ-exec-func Γ Γᵗ l W (W + X1) (W + X3) parl pare\n... | q with Δ-exec-func Γ Γᵗ r W (W + X2) (W + X4) parr pare₁\n... | q2 with +-cancelˡ-≡ W q | +-cancelˡ-≡ W q2\n... | refl | refl = refl\n", "meta": {"hexsha": "89a79dd1c2738638cacabd05d09f0313bbae507e", "size": 26581, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Time.agda", "max_stars_repo_name": "amal029/compositional-real-time-contracts", "max_stars_repo_head_hexsha": "bff8c271b54f55ceac550c603e468f68838a07ee", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Time.agda", "max_issues_repo_name": "amal029/compositional-real-time-contracts", "max_issues_repo_head_hexsha": "bff8c271b54f55ceac550c603e468f68838a07ee", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Time.agda", "max_forks_repo_name": "amal029/compositional-real-time-contracts", "max_forks_repo_head_hexsha": "bff8c271b54f55ceac550c603e468f68838a07ee", "max_forks_repo_licenses": ["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.3390357698, "max_line_length": 80, "alphanum_fraction": 0.4580715549, "num_tokens": 12032, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324713956854, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.5934692243270036}} {"text": "\n\nmodule Utils.Decidable where\n\nopen import Data.Nat\nopen import Data.Char\nopen import Data.String\nopen import Data.Bool\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary.Decidable hiding (True; False)\nopen import Relation.Nullary\nopen import Data.Product\nopen import Data.Sum\nopen import Function\nimport Level as L\n\n{-\nA type class for decidable types.\n\nThe part we actually end up using in the formal semantics proofs is\nmostly decidable equality (_≡⁇_).\n-}\n\n_=>_ : ∀ {α β} → Set α → Set β → Set (α L.⊔ β)\nDict => A = ⦃ _ : Dict ⦄ → A\ninfixr 5 _=>_\n\nrecord Decidable {a}(A : Set a) : Set a where\n constructor rec\n field\n decide : Dec A \n\nDecRel : ∀ {a b}{A : Set a}{B : Set b} → (A → B → Set (a L.⊔ b)) → Set (a L.⊔ b)\nDecRel Rel = ∀ {x y} → Decidable (Rel x y)\n\nDecEq : ∀ {a} → Set a → Set a\nDecEq A = DecRel (_≡_ {_} {A})\n\n_⁇ : ∀ {a} A → Decidable {a} A => Dec A\n_⁇ A ⦃ dict ⦄ = Decidable.decide dict\n\n_≡⁇_ : ∀ {a A} → DecEq {a} A => ((x y : A) → Dec (x ≡ y))\nx ≡⁇ y = (x ≡ y) ⁇\n\nTrue : ∀ {a} A → Decidable {a} A => Set\nTrue A = T ⌊ A ⁇ ⌋\n\nF : Bool → Set\nF = T ∘ not\n\nFalse : ∀ {a} A → Decidable {a} A => Set\nFalse A = F ⌊ A ⁇ ⌋\n\n_≤⁇_ : ∀ a b → Dec (a ≤ b)\n_≤⁇_ = _≤?_\n\n_<⁇_ : ∀ a b → Dec (a < b)\na <⁇ b = suc a ≤⁇ b\n\nmodule _ where\n open import Data.Nat.Properties\n _≤′⁇_ : ∀ a b → Dec (a ≤′ b)\n _≤′⁇_ a b with a ≤⁇ b\n ... | yes p = yes (≤⇒≤′ p)\n ... | no p = no (p ∘ ≤′⇒≤)\n\n_<′⁇_ : ∀ a b → Dec (a <′ b)\na <′⁇ b = suc a ≤′⁇ b\n\n\ninstance\n DecEqBool : DecEq Bool\n DecEqBool = rec (_ Data.Bool.≟ _)\n\ninstance\n DecEqChar : DecEq Char\n DecEqChar = rec (_ Data.Char.≟ _)\n\nmodule _ where\n open import Data.Fin\n open import Data.Fin.Properties\n \n instance\n DecEqFin : ∀ {n} → DecEq (Fin n)\n DecEqFin = rec (_ Data.Fin.Properties.≟ _)\n\ninstance\n DecEqℕ : DecEq ℕ\n DecEqℕ = rec (_ Data.Nat.≟ _)\n\ninstance\n DecEqString : DecEq String\n DecEqString = rec (_ Data.String.≟ _)\n\ninstance\n Decℕ≤ : DecRel _≤_\n Decℕ≤ = rec (_ ≤⁇ _)\n \ninstance\n Decℕ≤′ : DecRel _≤′_\n Decℕ≤′ = rec (_ ≤′⁇ _)\n \n \n-- Conversions between decidable / boolean \n--------------------------------------------------\n\nT→∧ : ∀ {a b} → T (a ∧ b) → T a × T b\nT→∧ {true} {true} x = _\nT→∧ {true} {false} ()\nT→∧ {false} ()\n\n∧→T : ∀ {a b} → T a → T b → T (a ∧ b)\n∧→T {true} {true} p1 p2 = _\n∧→T {true} {false} p1 ()\n∧→T {false} () p2\n\nF-not-elim : ∀ {b} → F (not b) → T b\nF-not-elim {true} p = p\nF-not-elim {false} p = p\n\nF-not-add : ∀ {b} → T b → F (not b)\nF-not-add {true} p = p\nF-not-add {false} p = p\n\nF-not-≡ : ∀ b → T b ≡ F (not b)\nF-not-≡ true = refl\nF-not-≡ false = refl\n\nTrueA→A : ∀ {a A}⦃ _ : Decidable {a} A ⦄ → True A → A\nTrueA→A = toWitness\n\nFalseA→¬A : ∀ {a A}⦃ _ : Decidable {a} A ⦄ → False A → ¬ A\nFalseA→¬A = toWitnessFalse\n\nA→TrueA : ∀ {a A}⦃ _ : Decidable {a} A ⦄ → A → True A\nA→TrueA = fromWitness\n\n¬A→FalseA : ∀ {a A}⦃ _ : Decidable {a} A ⦄ → ¬ A → False A\n¬A→FalseA = fromWitnessFalse\n\nT→≡true : ∀ {b} → T b → b ≡ true\nT→≡true {true} p = refl\nT→≡true {false} ()\n\n≡true→T : ∀ {b} → b ≡ true → T b\n≡true→T {true} p = _\n≡true→T {false} ()\n\n≡false→F : ∀ {b} → b ≡ false → F b\n≡false→F {true} ()\n≡false→F {false} p = _\n\nF→≡false : ∀ {b} → F b → b ≡ false\nF→≡false {true} ()\nF→≡false {false} p = refl\n\nA→≡true : ∀ {a A}{Q : Dec {a} A} → A → ⌊ Q ⌋ ≡ true\nA→≡true = T→≡true ∘ fromWitness\n\n¬A→≡false : ∀ {a A}{Q : Dec {a} A} → ¬ A → ⌊ Q ⌋ ≡ false\n¬A→≡false = F→≡false ∘ fromWitnessFalse\n\n≡true→A : ∀ {a A}{Q : Dec {a} A} → ⌊ Q ⌋ ≡ true → A\n≡true→A = toWitness ∘ ≡true→T\n\n≡false→¬A : ∀ {a A}{Q : Dec {a} A} → ⌊ Q ⌋ ≡ false → ¬ A\n≡false→¬A = toWitnessFalse ∘ ≡false→F\n\n\n-----------------------------------------------------------\n\ninstance\n Dec¬ :\n ∀ {α A}\n → Decidable {α} A\n => Decidable (¬ A)\n \n Dec¬ {_}{A} = rec dec¬ where\n \n dec¬ : Dec (¬ A)\n dec¬ with A ⁇\n ... | yes p = no (λ z → z p)\n ... | no ¬p = yes ¬p\n\ninstance\n Dec⊎ : \n ∀ {α β A B}\n → Decidable {α} A\n => Decidable {β} B\n => Decidable (A ⊎ B)\n \n Dec⊎ {_}{_}{A}{B} = rec dec⊎ where\n \n dec⊎ : Dec (A ⊎ B)\n dec⊎ with A ⁇ | B ⁇\n ... | yes p | _ = yes (inj₁ p)\n ... | _ | yes p = yes (inj₂ p)\n ... | no ¬p₁ | no ¬p₂ = no [ ¬p₁ , ¬p₂ ]′\n\ninstance\n Dec× :\n ∀ {α β A B}\n → Decidable {α} A\n => Decidable {β} B\n => Decidable (A × B)\n \n Dec× {_}{_}{A}{B} = rec dec× where\n \n dec× : Dec (A × B)\n dec× with A ⁇ | B ⁇\n ... | yes p | yes p₁ = yes (p , p₁)\n ... | yes p | no ¬p = no (¬p ∘ proj₂)\n ... | no ¬p | _ = no (¬p ∘ proj₁)\n\n", "meta": {"hexsha": "144cd033501a0b00fa0819346c1bc1b524194f2e", "size": 4530, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Utils/Decidable.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/Decidable.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/Decidable.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": 21.0697674419, "max_line_length": 80, "alphanum_fraction": 0.5004415011, "num_tokens": 1991, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.7634837581726991, "lm_q1q2_score": 0.5934558192367704}} {"text": "module Category.Functor.Const where\nopen import Category.Functor using (RawFunctor ; module RawFunctor )\nopen import Category.Functor.Lawful\nopen import Relation.Binary.PropositionalEquality using (refl)\n\nConst : ∀ {l₁ l₂} (R : Set l₂) (_ : Set l₁) → Set l₂ \nConst R _ = R\n\nconstFunctor : ∀ {l₁} {R : Set l₁} → RawFunctor (Const {l₁} R)\nconstFunctor = record { _<$>_ = λ _ z → z }\n\nconstLawfulFunctor : ∀ {l₁} {R : Set l₁} → LawfulFunctorImp (constFunctor {l₁} {R})\nconstLawfulFunctor = record { <$>-identity = refl ; <$>-compose = refl }\n\n", "meta": {"hexsha": "37295079d21f39350f7cf621adad431b4082833b", "size": 550, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Category/Functor/Const.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/Category/Functor/Const.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/Category/Functor/Const.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": 36.6666666667, "max_line_length": 83, "alphanum_fraction": 0.6763636364, "num_tokens": 184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045877523147, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.5934336415142061}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties, related to products, that rely on the K rule\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Data.Product.Properties.WithK where\n\nopen import Data.Product\nopen import Data.Product.Properties\nopen import Function\nopen import Relation.Binary using (Decidable)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary using (yes; no)\n\n------------------------------------------------------------------------\n-- Equality\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n ,-injective : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → a ≡ c × b ≡ d\n ,-injective refl = refl , refl\n\nmodule _ {a b} {A : Set a} {B : A → Set b} where\n\n ,-injectiveʳ : ∀ {a} {b c : B a} → (Σ A B ∋ (a , b)) ≡ (a , c) → b ≡ c\n ,-injectiveʳ refl = refl\n\n ≡-dec : Decidable _≡_ → (∀ {a} → Decidable {A = B a} _≡_) →\n Decidable {A = Σ A B} _≡_\n ≡-dec dec₁ dec₂ (a , x) (b , y) with dec₁ a b\n ... | no a≢b = no (a≢b ∘ ,-injectiveˡ)\n ... | yes refl with dec₂ x y\n ... | no x≢y = no (x≢y ∘ ,-injectiveʳ)\n ... | yes refl = yes refl\n", "meta": {"hexsha": "0d3a8dafb04ece27f1300d0f87353562da1df1de", "size": 1226, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/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/Product/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/Product/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": 32.2631578947, "max_line_length": 73, "alphanum_fraction": 0.4787928222, "num_tokens": 383, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.5934336337917686}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.HITs.S1.Properties where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.GroupoidLaws\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.HITs.S1.Base\nopen import Cubical.HITs.PropositionalTruncation\n\nisConnectedS¹ : (s : S¹) → ∥ base ≡ s ∥\nisConnectedS¹ base = ∣ refl ∣\nisConnectedS¹ (loop i) =\n squash ∣ (λ j → loop (i ∧ j)) ∣ ∣ (λ j → loop (i ∨ ~ j)) ∣ i\n\nisGroupoidS¹ : isGroupoid S¹\nisGroupoidS¹ s t =\n recPropTrunc isPropIsSet\n (λ p →\n subst (λ s → isSet (s ≡ t)) p\n (recPropTrunc isPropIsSet\n (λ q → subst (λ t → isSet (base ≡ t)) q isSetΩS¹)\n (isConnectedS¹ t)))\n (isConnectedS¹ s)\n\n", "meta": {"hexsha": "9316dc20bfbdab346ee2220d944589dd1e68940a", "size": 836, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/S1/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/S1/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/S1/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": 28.8275862069, "max_line_length": 62, "alphanum_fraction": 0.6973684211, "num_tokens": 289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045877523148, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.5934336298020371}} {"text": "\nmodule Successor where\n\nopen import OscarPrelude\n\nrecord Successor {ℓᴬ} (A : Set ℓᴬ) {ℓᴮ} (B : Set ℓᴮ) : Set (ℓᴬ ⊔ ℓᴮ)\n where\n field\n ⊹ : A → B\n\nopen Successor ⦃ … ⦄ public\n\ninstance SuccessorNat : Successor Nat Nat\nSuccessor.⊹ SuccessorNat = suc\n\ninstance SuccessorLevel : Successor Level Level\nSuccessor.⊹ SuccessorLevel = lsuc\n", "meta": {"hexsha": "0c22eb7475071af36911e97259d6a2d088fda18b", "size": 335, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/Successor.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/Successor.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/Successor.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": 18.6111111111, "max_line_length": 68, "alphanum_fraction": 0.7104477612, "num_tokens": 135, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8872045877523147, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.593433629802037}} {"text": "----------------------------------------------------------------------------\n-- Well-founded induction on the 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\nmodule FOT.FOTC.Data.Nat.Induction.NonAcc.WF-I where\n\nopen import FOTC.Base\n\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.Inequalities.EliminationPropertiesI\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n-- Well-founded induction\npostulate\n <-wfind₁ : (A : D → Set) →\n (∀ {n} → N n → (∀ {m} → N m → m < n → A m) → A n) →\n ∀ {n} → N n → A n\n\npostulate PN : ∀ {n m} → N n → m < n → N m\n\n-- Well-founded induction removing N m from the second line.\n<-wfind₂ : (A : D → Set) →\n (∀ {n} → N n → (∀ {m} → m < n → A m) → A n) →\n ∀ {n} → N n → A n\n<-wfind₂ A h = <-wfind₁ A (λ Nn' h' → h Nn' (λ p → h' (PN Nn' p) p))\n\n-- Well-founded induction removing N n from the second line.\n<-wfind₃ : (A : D → Set) →\n (∀ {n} → (∀ {m} → N m → m < n → A m) → A n) →\n ∀ {n} → N n → A n\n<-wfind₃ A h = <-wfind₁ A (λ Nn' h' → h h')\n", "meta": {"hexsha": "caf58ddc55b1f303aa357a76e46ecd1167916253", "size": 1377, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/NonAcc/WF-I.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/WF-I.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/WF-I.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.3076923077, "max_line_length": 78, "alphanum_fraction": 0.4299201162, "num_tokens": 408, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.5934094290878775}} {"text": "module Structure.Relator.Function.Proofs where\n\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Functional\nopen import Structure.Relator.Function\nopen import Structure.Setoid\nopen import Structure.Setoid.Uniqueness\nopen import Structure.Relator.Properties\nopen import Structure.Relator\nopen import Type\n\nprivate variable ℓ₁ ℓ₂ ℓ₃ ℓₗ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level\n\nmodule _ {A : Type{ℓₒ₁}}{B : Type{ℓₒ₁ Lvl.⊔ ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ (φ : A → B → Stmt{ℓₗ}) ⦃ totality : Total(φ)⦄ ⦃ func : Function(φ)⦄ ⦃ _ : ∀{x} → UnaryRelator(φ(x)) ⦄ where\n -- There is a function for a binary relation that is total and function-like.\n relation-function-existence : ∃(f ↦ ∀{x}{y} → (f(x) ≡ y) ↔ φ(x)(y))\n relation-function-existence = [∃]-intro(f) ⦃ \\{x y} → proof{x}{y} ⦄ where\n -- The function\n f : A → B\n f(x) = [∃]-witness(total(φ){x})\n\n -- Proof that the function returns the value that the binary relation defines the element from Y that an element from X is associated with.\n proof : ∀{x}{y} → (f(x) ≡ y) ↔ φ(x)(y)\n proof{x}{y} = [↔]-intro l r where\n r : (f(x) ≡ y) → φ(x)(y)\n r(fxy) = substitute₁(φ(x)) fxy ([∃]-proof(total(φ){x}))\n\n l : (f(x) ≡ y) ← φ(x)(y)\n l(φxy) = [∃!]-existence-eq-any(totalFunction(φ)) φxy\n\n -- Constructing a total function from a a binary operation with conditions.\n relation-function : A → B\n relation-function = [∃]-witness(relation-function-existence)\n\nmodule _ {A : Type{ℓₒ₁}} {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(B) ⦄ {f : A → B} where\n -- A function is total\n -- ∀{x} → ∃(y ↦ f(x) ≡ y)\n Function-totality : Total(x ↦ y ↦ f(x) ≡ y)\n Total.proof(Function-totality) {x} = [∃]-intro(f(x)) ⦃ reflexivity(_≡_) ⦄\n\nmodule _ {X : Type{ℓₒ₁}} {Y : X → Type{ℓₒ₂}} {φ : (x : X) → Y(x) → Stmt{ℓₗ}} where\n -- Every binary predicate that have its first argument defined for all values\n -- have at least one choice function that can determine the second argument from the first.\n -- Proposition: ∀(X: Type)∀(Y: Type)∀(φ: X → Y → Stmt). (∀(x: X)∃(y: Y). φ(x)(y)) → (∃(choice: X → Y)∀(x: X). φ(x)(choice(x)))\n -- ∀(x: X)∃(y: Y). φ(x)(y) means that the predicate φ holds for every x and some y (which may depend on x). In other words: it associates every element in X with a subset of Y, a function (X → ℘(Y)).\n -- ∃(choice: X → Y)∀(x: X). φ(x)(choice(x)) means that there is a function that picks out a particular y.\n -- Note: This proposition can be recognised as one equivalent variant of \"Axiom of Choice\" from set theory when formulated in classical logic.\n -- Note: This is similar to what one does in the process of \"Skolemization\" for an existentially quantified formula in logic.\n dependent-function-predicate-choice : (∀{x : X} → ∃{Obj = Y(x)}(y ↦ φ(x)(y))) → ∃{Obj = (x : X) → Y(x)}(choice ↦ ∀{x : X} → φ(x)(choice(x)))\n dependent-function-predicate-choice(function) = [∃]-intro(x ↦ [∃]-witness(function{x})) ⦃ \\{x} → [∃]-proof(function{x}) ⦄\n\nmodule _ {X : Type{ℓₒ₁}} {Y : Type{ℓₒ₂}} {φ : X → Y → Stmt{ℓₗ}} where\n function-predicate-choice : (∀{x} → ∃(y ↦ φ(x)(y))) → ∃{Obj = X → Y}(choice ↦ ∀{x} → φ(x)(choice(x)))\n function-predicate-choice = dependent-function-predicate-choice\n\n{-\nmodule _ {ℓₗ₁ ℓₗ₂ ℓₒ} {X : Type{ℓₒ}} {P : (X → Stmt{ℓₗ₁}) → Stmt{ℓₗ₂}} where\n standard-choice : (∀{Q : X → Stmt{ℓₗ₁}} → P(Q) → (∃ P)) → ∃{Obj = (X → Stmt{ℓₗ₁}) → X}(f ↦ ∀{Q : X → Stmt{ℓₗ₁}} → P(Q) → Q(f(Q)))\n standard-choice ep = [∃]-intro (choice) ⦃ \\{x} → proof{x} ⦄ where\n choice : (X → Stmt{ℓₗ₁}) → X\n choice(R) = [∃]-witness(ep{R} (pr))\n\n proof : ∀{Q : X → Stmt{ℓₗ₁}} → P(Q) → Q(choice(Q))\n proof{Q} pq = [∃]-proof(surjective{x})\n-}\n", "meta": {"hexsha": "bc66e29df500caf3ac4174096195e70d31446d81", "size": 3699, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Relator/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/Relator/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/Relator/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": 53.6086956522, "max_line_length": 203, "alphanum_fraction": 0.6131386861, "num_tokens": 1454, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.5934094143249812}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category)\nopen import Categories.Category.Monoidal using (Monoidal)\n\nmodule Categories.Category.Monoidal.Reasoning {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where\n\nopen import Data.Product using (_,_)\n\nopen import Categories.Functor renaming (id to idF)\n\nprivate\n module C = Category C\n\nopen C hiding (id; identityˡ; identityʳ; assoc)\n\nprivate\n variable\n X Y : Obj\n f g h i : X ⇒ Y\n\nopen Monoidal M using (_⊗₁_; ⊗)\nopen Functor ⊗ using (F-resp-≈; homomorphism)\nopen HomReasoning public\n\ninfixr 6 _⟩⊗⟨_ refl⟩⊗⟨_\ninfixl 7 _⟩⊗⟨refl\n\n⊗-resp-≈ : f ≈ h → g ≈ i → (f ⊗₁ g) ≈ (h ⊗₁ i)\n⊗-resp-≈ p q = F-resp-≈ (p , q)\n\n⊗-resp-≈ˡ : f ≈ h → (f ⊗₁ g) ≈ (h ⊗₁ g)\n⊗-resp-≈ˡ p = ⊗-resp-≈ p Equiv.refl\n\n⊗-resp-≈ʳ : g ≈ i → (f ⊗₁ g) ≈ (f ⊗₁ i)\n⊗-resp-≈ʳ p = ⊗-resp-≈ Equiv.refl p\n\n_⟩⊗⟨_ : f ≈ h → g ≈ i → (f ⊗₁ g) ≈ (h ⊗₁ i)\n_⟩⊗⟨_ = ⊗-resp-≈\n\nrefl⟩⊗⟨_ : g ≈ i → (f ⊗₁ g) ≈ (f ⊗₁ i)\nrefl⟩⊗⟨_ = ⊗-resp-≈ʳ\n\n_⟩⊗⟨refl : f ≈ h → (f ⊗₁ g) ≈ (h ⊗₁ g)\n_⟩⊗⟨refl = ⊗-resp-≈ˡ\n\n-- removing the {_} makes the whole thing not type check anymore for some reason\n-- an issue was raised on the main agda GitHub repository about this\n-- (https://github.com/agda/agda/issues/4140)\n-- if this is fixed feel free to remove the {_}\n⊗-distrib-over-∘ : ((f ∘ h) ⊗₁ (g ∘ i)) ≈ ((f ⊗₁ g) ∘ (h ⊗₁ i))\n⊗-distrib-over-∘ {_} = homomorphism\n -- This also corresponds with the graphical coherence property of diagrams modelling monoidal categories:\n-- | | | |\n-- [h] [i] [h] [i]\n-- | | ≈ | |\n-- [f] [g] | |\n-- | | | |\n-- [f] [g]\n-- | |\n\n-- Parallel-to-serial conversions\n--\n-- | | | | | |\n-- | | | [g] [f] |\n-- [f] [g] = | | = | |\n-- | | [f] | | [g]\n-- | | | | | |\n\nserialize₁₂ : ∀ {X₁ Y₁ X₂ Y₂} {f : X₁ ⇒ Y₁} {g : X₂ ⇒ Y₂} →\n f ⊗₁ g ≈ f ⊗₁ C.id ∘ C.id ⊗₁ g\nserialize₁₂ {f = f} {g} = begin\n f ⊗₁ g ≈˘⟨ C.identityʳ ⟩⊗⟨ C.identityˡ ⟩\n (f ∘ C.id) ⊗₁ (C.id ∘ g) ≈⟨ ⊗-distrib-over-∘ ⟩\n f ⊗₁ C.id ∘ C.id ⊗₁ g ∎\n\nserialize₂₁ : ∀ {X₁ Y₁ X₂ Y₂} {f : X₁ ⇒ Y₁} {g : X₂ ⇒ Y₂} →\n f ⊗₁ g ≈ C.id ⊗₁ g ∘ f ⊗₁ C.id\nserialize₂₁ {f = f} {g} = begin\n f ⊗₁ g ≈˘⟨ C.identityˡ ⟩⊗⟨ C.identityʳ ⟩\n (C.id ∘ f) ⊗₁ (g ∘ C.id) ≈⟨ ⊗-distrib-over-∘ ⟩\n C.id ⊗₁ g ∘ f ⊗₁ C.id ∎\n\n-- Split a composite in the first component\n--\n-- | | | | | |\n-- [g] | [g] | [g] [h]\n-- | [h] = | | = | |\n-- [f] | [f] [h] [f] |\n-- | | | | | |\n\nsplit₁ʳ : ∀ {X₁ Y₁ Z₁ X₂ Y₂} {f : Y₁ ⇒ Z₁} {g : X₁ ⇒ Y₁} {h : X₂ ⇒ Y₂} →\n (f ∘ g) ⊗₁ h ≈ f ⊗₁ h ∘ g ⊗₁ C.id\nsplit₁ʳ {f = f} {g} {h} = begin\n (f ∘ g) ⊗₁ h ≈˘⟨ refl⟩⊗⟨ C.identityʳ ⟩\n (f ∘ g) ⊗₁ (h ∘ C.id) ≈⟨ ⊗-distrib-over-∘ ⟩\n f ⊗₁ h ∘ g ⊗₁ C.id ∎\n\nsplit₁ˡ : ∀ {X₁ Y₁ Z₁ X₂ Y₂} {f : Y₁ ⇒ Z₁} {g : X₁ ⇒ Y₁} {h : X₂ ⇒ Y₂} →\n (f ∘ g) ⊗₁ h ≈ f ⊗₁ C.id ∘ g ⊗₁ h\nsplit₁ˡ {f = f} {g} {h} = begin\n (f ∘ g) ⊗₁ h ≈˘⟨ refl⟩⊗⟨ C.identityˡ ⟩\n (f ∘ g) ⊗₁ (C.id ∘ h) ≈⟨ ⊗-distrib-over-∘ ⟩\n f ⊗₁ C.id ∘ g ⊗₁ h ∎\n\n-- Split a composite in the second component\n--\n-- | | | | | |\n-- | [h] | [h] [f] [h]\n-- [f] | = | | = | |\n-- | [g] [f] [g] | [g]\n-- | | | | | |\n\nsplit₂ʳ : ∀ {X₁ Y₁ X₂ Y₂ Z₂} {f : X₁ ⇒ Y₁} {g : Y₂ ⇒ Z₂} {h : X₂ ⇒ Y₂} →\n f ⊗₁ (g ∘ h) ≈ f ⊗₁ g ∘ C.id ⊗₁ h\nsplit₂ʳ {f = f} {g} {h} = begin\n f ⊗₁ (g ∘ h) ≈˘⟨ C.identityʳ ⟩⊗⟨refl ⟩\n (f ∘ C.id) ⊗₁ (g ∘ h) ≈⟨ ⊗-distrib-over-∘ ⟩\n f ⊗₁ g ∘ C.id ⊗₁ h ∎\n\nsplit₂ˡ : ∀ {X₁ Y₁ X₂ Y₂ Z₂} {f : X₁ ⇒ Y₁} {g : Y₂ ⇒ Z₂} {h : X₂ ⇒ Y₂} →\n f ⊗₁ (g ∘ h) ≈ C.id ⊗₁ g ∘ f ⊗₁ h\nsplit₂ˡ {f = f} {g} {h} = begin\n f ⊗₁ (g ∘ h) ≈˘⟨ C.identityˡ ⟩⊗⟨refl ⟩\n (C.id ∘ f) ⊗₁ (g ∘ h) ≈⟨ ⊗-distrib-over-∘ ⟩\n C.id ⊗₁ g ∘ f ⊗₁ h ∎\n", "meta": {"hexsha": "af88d075a52cafe2c093d019beb9b69e9538b5fe", "size": 4056, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Reasoning.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/Monoidal/Reasoning.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/Monoidal/Reasoning.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.937007874, "max_line_length": 107, "alphanum_fraction": 0.4146942801, "num_tokens": 2033, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.5934094129567836}} {"text": "\nmodule UniDB.Morph.Sum where\n\nopen import UniDB.Spec\n\n--------------------------------------------------------------------------------\n\ndata Sum (Ξ Ζ : MOR) (γ₁ γ₂ : Dom) : Set where\n inl : Ξ γ₁ γ₂ → Sum Ξ Ζ γ₁ γ₂\n inr : Ζ γ₁ γ₂ → Sum Ξ Ζ γ₁ γ₂\n\ninstance\n iUpSum : {Ξ Ζ : MOR} {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} → Up (Sum Ξ Ζ)\n _↑₁ {{iUpSum}} (inl ξ) = inl (ξ ↑₁)\n _↑₁ {{iUpSum}} (inr ζ) = inr (ζ ↑₁)\n _↑_ {{iUpSum}} ξ 0 = ξ\n _↑_ {{iUpSum}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁\n ↑-zero {{iUpSum}} ξ = refl\n ↑-suc {{iUpSum}} ξ δ⁺ = refl\n\n iLkSum :\n {T : STX}\n {Ξ : MOR} {{lkTΞ : Lk T Ξ}}\n {Ζ : MOR} {{lkTΖ : Lk T Ζ}} →\n Lk T (Sum Ξ Ζ)\n lk {{iLkSum {T} {Ξ} {Ζ}}} (inl ξ) i = lk {T} {Ξ} ξ i\n lk {{iLkSum {T} {Ξ} {Ζ}}} (inr ζ) i = lk {T} {Ζ} ζ i\n\n iLkUpSum :\n {T : STX} {{vrT : Vr T}} {{wkT : Wk T}}\n {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{lkUpTΞ : LkUp T Ξ}}\n {Ζ : MOR} {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}} {{lkUpTΖ : LkUp T Ζ}} →\n LkUp T (Sum Ξ Ζ)\n lk-↑₁-zero {{iLkUpSum {T} {Ξ} {Ζ}}} (inl ξ) = lk-↑₁-zero {T} {Ξ} ξ\n lk-↑₁-zero {{iLkUpSum {T} {Ξ} {Ζ}}} (inr ζ) = lk-↑₁-zero {T} {Ζ} ζ\n lk-↑₁-suc {{iLkUpSum {T} {Ξ} {Ζ}}} (inl ξ) = lk-↑₁-suc {T} {Ξ} ξ\n lk-↑₁-suc {{iLkUpSum {T} {Ξ} {Ζ}}} (inr ζ) = lk-↑₁-suc {T} {Ζ} ζ\n\nmodule _\n (Ξ Ζ : MOR) {{upΞ : Up Ξ}} {{upΖ : Up Ζ}}\n where\n\n inl-↑ : {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (δ : Dom) →\n inl {Ξ} {Ζ} ξ ↑ δ ≡ inl (ξ ↑ δ)\n inl-↑ ξ zero rewrite ↑-zero ξ = refl\n inl-↑ ξ (suc δ) rewrite inl-↑ ξ δ | ↑-suc ξ δ = refl\n\n inr-↑ : {γ₁ γ₂ : Dom} (ζ : Ζ γ₁ γ₂) (δ : Dom) →\n inr {Ξ} {Ζ} ζ ↑ δ ≡ inr (ζ ↑ δ)\n inr-↑ ζ zero rewrite ↑-zero ζ = refl\n inr-↑ ζ (suc δ) rewrite inr-↑ ζ δ | ↑-suc ζ δ = refl\n\n--------------------------------------------------------------------------------\n", "meta": {"hexsha": "470c62983105841313f027e7908e7d73b6f499a5", "size": 1777, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "UniDB/Morph/Sum.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/Morph/Sum.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/Morph/Sum.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": 32.9074074074, "max_line_length": 80, "alphanum_fraction": 0.4141812043, "num_tokens": 948, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278757303677, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.5932842388865505}} {"text": "-- This test case seems to be due to Andreas Abel, Andrea Vezzosi and\n-- NAD. The code below should be rejected.\n\nopen import Agda.Builtin.Size\n\ndata SizeLt (i : Size) : Set where\n size : (j : Size< i) → SizeLt i\n\n-- Legal again in 2.5.1\ngetSize : ∀{i} → SizeLt i → Size\ngetSize (size j) = j\n\n-- Structurally inductive (c), coinductive via sizes.\ndata U (i : Size) : Set where\n c : ((s : SizeLt i) → U (getSize s)) → U i\n\ndata ⊥ : Set where\n\nempty : U ∞ → ⊥\nempty (c f) = empty (f (size ∞)) -- f x <= f < c f\n\n-- If U is a data type this should not be possible:\ninh : ∀ i → U i\ninh i = c λ{ (size j) → inh j }\n\nabsurd : ⊥\nabsurd = empty (inh ∞)\n", "meta": {"hexsha": "a9a5a214bbf22c22e371a90066fa63ab0d74ca17", "size": 648, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1946-1.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "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/Issue1946-1.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/Issue1946-1.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": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "avg_line_length": 23.1428571429, "max_line_length": 69, "alphanum_fraction": 0.6064814815, "num_tokens": 232, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278633625322, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.5932842247776782}} {"text": "{-\n\nThis file contains:\n\n- Definition of groupoid quotients\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.GroupoidQuotients.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Relation.Binary.Base\n\n-- Groupoid quotients as a higher inductive type:\n-- For the definition, only transitivity is needed\ndata _//_ {ℓ ℓ'} (A : Type ℓ) {R : A → A → Type ℓ'}\n (Rt : BinaryRelation.isTrans R) : Type (ℓ-max ℓ ℓ') where\n [_] : (a : A) → A // Rt\n eq// : {a b : A} → (r : R a b) → [ a ] ≡ [ b ]\n comp// : {a b c : A} → (r : R a b) → (s : R b c)\n → PathP (λ j → [ a ] ≡ eq// s j) (eq// r) (eq// (Rt a b c r s))\n squash// : ∀ (x y : A // Rt) (p q : x ≡ y) (r s : p ≡ q) → r ≡ s\n\n{- The comp// constructor fills the square:\n\n eq// (Rt a b c r s)\n [a]— — — >[c]\n ‖ ^\n ‖ | eq// s ^\n ‖ | j |\n [a]— — — >[b] ∙ — >\n eq// r i\n\n We use this to give another constructor-like construction:\n-}\n\ncomp'// : {ℓ ℓ' : Level} (A : Type ℓ) {R : A → A → Type ℓ'}\n (Rt : BinaryRelation.isTrans R)\n {a b c : A} → (r : R a b) → (s : R b c)\n → eq// {Rt = Rt} (Rt a b c r s) ≡ eq// r ∙ eq// s\ncomp'// A Rt r s i = compPath-unique refl (eq// r) (eq// s)\n (eq// {Rt = Rt} (Rt _ _ _ r s) , comp// r s)\n (eq// r ∙ eq// s , compPath-filler (eq// r) (eq// s)) i .fst\n", "meta": {"hexsha": "0e141fea7a1792714762e3c127daed21cf34e9ca", "size": 1404, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/GroupoidQuotients/Base.agda", "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 301, "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_issues_repo_path": "Cubical/HITs/GroupoidQuotients/Base.agda", "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 584, "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_forks_repo_path": "Cubical/HITs/GroupoidQuotients/Base.agda", "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 134, "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "avg_line_length": 31.9090909091, "max_line_length": 73, "alphanum_fraction": 0.4786324786, "num_tokens": 543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672227971211, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.5932179320039406}} {"text": "{-# OPTIONS --without-K #-}\n-- most of this is subsumed by crypto-agda Search code\nopen import Type hiding (★)\nopen import Data.Nat.NP hiding (_==_) renaming (_<=_ to _ℕ<=_)\nopen import Data.Bits\nopen import Data.Bit hiding (_==_)\nopen import Data.Bool.Properties using (not-involutive)\nimport Data.Vec.NP as V\nopen V hiding (rewire; rewireTbl; sum) renaming (map to vmap; swap to vswap)\n\nimport Relation.Binary.PropositionalEquality.NP as ≡\nopen ≡\nopen import Function.NP hiding (_→⟨_⟩_)\nopen import Algebra.FunctionProperties.NP\n\nmodule Data.Bits.Search where\nmodule Search {i} {I : ★ i} (`1 : I) (`2*_ : I → I)\n {a} {A : I → ★ a} (_∙_ : ∀ {m} → A m → A m → A (`2* m)) where\n\n `2^_ : ℕ → I\n `2^_ = fold `1 `2*_\n\n search : ∀ {n} → (Bits n → A `1) → A (`2^ n)\n search {zero} f = f []\n search {suc n} f = search (f ∘ 0∷_) ∙ search (f ∘ 1∷_)\n\n searchBit : (Bit → A `1) → A (`2* `1)\n searchBit f = f 0b ∙ f 1b\n\n -- search-ext\n search-≗ : ∀ {n} (f g : Bits n → A `1) → f ≗ g → search f ≡ search g\n search-≗ {zero} f g f≗g = f≗g []\n search-≗ {suc n} f g f≗g\n rewrite search-≗ (f ∘ 0∷_) (g ∘ 0∷_) (f≗g ∘ 0∷_)\n | search-≗ (f ∘ 1∷_) (g ∘ 1∷_) (f≗g ∘ 1∷_) = refl\n\n module Comm (∙-comm : ∀ {m} (x y : A m) → x ∙ y ≡ y ∙ x) where\n\n {- This pad bit vector allows to specify which bit do we negate in the vector. -}\n search-comm : ∀ {n} (pad : Bits n) (f : Bits n → A `1) → search f ≡ search (f ∘ _⊕_ pad)\n search-comm {zero} pad f = refl\n search-comm {suc n} (b ∷ pad) f\n rewrite search-comm pad (f ∘ 0∷_)\n | search-comm pad (f ∘ 1∷_)\n with b\n ... | true = ∙-comm (search (f ∘ 0∷_ ∘ _⊕_ pad)) _\n ... | false = refl\n open Comm public\n\nmodule SimpleSearch {a} {A : ★ a} (_∙_ : A → A → A) where\n\n open Search 1 2*_ {A = const A} _∙_ public\n\n module SearchUnit ε (ε∙ε : ε ∙ ε ≡ ε) where\n search-constε≡ε : ∀ n → search {n = n} (const ε) ≡ ε\n search-constε≡ε zero = refl\n search-constε≡ε (suc n) rewrite search-constε≡ε n = ε∙ε\n\n searchBit-search : ∀ n (f : Bits (suc n) → A) → searchBit (λ b → search (f ∘ _∷_ b)) ≡ search f\n searchBit-search n f = refl\n\n search-≗₂ : ∀ {m n} (f g : Bits m → Bits n → A) → f ≗₂ g\n → search (search ∘ f) ≡ search (search ∘ g)\n search-≗₂ f g f≗g = search-≗ (search ∘ f) (search ∘ g) (λ xs →\n search-≗ (f xs) (g xs) (λ ys →\n f≗g xs ys))\n\n search-+ : ∀ {m n} (f : Bits (m + n) → A) →\n search {m + n} f\n ≡ search {m} (λ xs → search {n} (λ ys → f (xs ++ ys)))\n search-+ {zero} f = refl\n search-+ {suc m} f rewrite search-+ {m} (f ∘ 0∷_)\n | search-+ {m} (f ∘ 1∷_) = refl\n\n module SearchInterchange (∙-interchange : Interchange _≡_ _∙_ _∙_) where\n\n search-dist : ∀ {n} (f₀ f₁ : Bits n → A) → search (λ x → f₀ x ∙ f₁ x) ≡ search f₀ ∙ search f₁\n search-dist {zero} _ _ = refl\n search-dist {suc n} f₀ f₁\n rewrite search-dist (f₀ ∘ 0∷_) (f₁ ∘ 0∷_)\n | search-dist (f₀ ∘ 1∷_) (f₁ ∘ 1∷_)\n = ∙-interchange _ _ _ _\n\n search-searchBit : ∀ {n} (f : Bits (suc n) → A) →\n search (λ xs → searchBit (λ b → f (b ∷ xs))) ≡ search f\n search-searchBit f = search-dist (f ∘ 0∷_) (f ∘ 1∷_)\n\n search-search : ∀ {m n} (f : Bits (m + n) → A) →\n search {m} (λ xs → search {n} (λ ys → f (xs ++ ys)))\n ≡ search {n} (λ ys → search {m} (λ xs → f (xs ++ ys)))\n search-search {zero} f = refl\n search-search {suc m} {n} f\n rewrite search-search {m} {n} (f ∘ 0∷_)\n | search-search {m} {n} (f ∘ 1∷_)\n | search-searchBit {n} (λ { (b ∷ ys) → search {m} (λ xs → f (b ∷ xs ++ ys)) })\n = refl\n {- -- It might also be done by using search-dist twice and commutativity of addition.\n -- However, this also affect 'f' and makes this proof actually longer.\n search-search {m} {n} f =\n search {m} (λ xs → search {n} (λ ys → f (xs ++ ys)))\n ≡⟨ {!!} ⟩\n search {m + n} f\n ≡⟨ {!!} ⟩\n search {n + m} (f ∘ vswap n)\n ≡⟨ {!!} ⟩\n search {n} (λ ys → search {m} (λ xs → f (vswap n (ys ++ xs))))\n ≡⟨ {!!} ⟩\n search {n} (λ ys → search {m} (λ xs → f (xs ++ ys)))\n ∎\n where open ≡-Reasoning\n -}\n\n search-swap : ∀ {m n} (f : Bits (m + n) → A) → search {n + m} (f ∘ vswap n) ≡ search {m + n} f\n search-swap {m} {n} f =\n search {n + m} (f ∘ vswap n)\n ≡⟨ search-+ {n} {m} (f ∘ vswap n) ⟩\n search {n} (λ ys → search {m} (λ xs → f (vswap n (ys ++ xs))))\n ≡⟨ search-≗₂ {n} {m}\n (λ ys → f ∘ vswap n ∘ _++_ ys)\n (λ ys → f ∘ flip _++_ ys)\n (λ ys xs → cong f (swap-++ n ys xs)) ⟩\n search {n} (λ ys → search {m} (λ xs → f (xs ++ ys)))\n ≡⟨ sym (search-search {m} {n} f) ⟩\n search {m} (λ xs → search {n} (λ ys → f (xs ++ ys)))\n ≡⟨ sym (search-+ {m} {n} f) ⟩\n search {m + n} f\n ∎ where open ≡-Reasoning\n\n search-0↔1 : ∀ {n} (f : Bits n → A) → search {n} (f ∘ 0↔1) ≡ search {n} f\n search-0↔1 {zero} _ = refl\n search-0↔1 {suc zero} _ = refl\n search-0↔1 {suc (suc n)} _ = ∙-interchange _ _ _ _\n\n module Bij (∙-comm : Commutative _≡_ _∙_)\n (∙-interchange : Interchange _≡_ _∙_ _∙_) where\n open SearchInterchange ∙-interchange using (search-0↔1)\n open import Data.Bits.OperationSyntax hiding (_∙_)\n search-bij : ∀ {n} f (g : Bits n → A) → search (g ∘ eval f) ≡ search g\n search-bij `id _ = refl\n search-bij `0↔1 f = search-0↔1 f\n search-bij (f `⁏ g) h\n rewrite search-bij f (h ∘ eval g)\n | search-bij g h\n = refl\n search-bij {suc n} (`id `∷ f) g\n rewrite search-bij (f 0b) (g ∘ 0∷_)\n | search-bij (f 1b) (g ∘ 1∷_)\n = refl\n search-bij {suc n} (`notᴮ `∷ f) g\n rewrite search-bij (f 1b) (g ∘ 0∷_)\n | search-bij (f 0b) (g ∘ 1∷_)\n = ∙-comm _ _\n\n|de-morgan| : ∀ {n} (f g : Bits n → Bit) → f |∨| g ≗ not ∘ ((not ∘ f) |∧| (not ∘ g))\n|de-morgan| f g x with f x\n... | true = refl\n... | false = sym (not-involutive _)\n\nopen SimpleSearch\n\nsearch-de-morgan : ∀ {n} op (f g : Bits n → Bit) →\n search op (f |∨| g) ≡ search op (not ∘ ((not ∘ f) |∧| (not ∘ g)))\nsearch-de-morgan op f g = search-≗ op _ _ (|de-morgan| f g)\n\nsearch-hom :\n ∀ {n a b}\n {A : ★ a} {B : ★ b}\n (_+_ : A → A → A)\n (_*_ : B → B → B)\n (f : A → B)\n (p : Bits n → A)\n (hom : ∀ x y → f (x + y) ≡ f x * f y)\n → f (search _+_ p) ≡ search _*_ (f ∘ p)\nsearch-hom {zero} _ _ _ _ _ = refl\nsearch-hom {suc n} _+_ _*_ f p hom =\n trans (hom _ _)\n (cong₂ _*_ (search-hom _+_ _*_ f (p ∘ 0∷_) hom)\n (search-hom _+_ _*_ f (p ∘ 1∷_) hom))\n", "meta": {"hexsha": "58f3c2e23f8be82de847c8c2fb750f777f33f1d3", "size": 7432, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Explore/Experimental/DataBitsSearch.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/Experimental/DataBitsSearch.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/Experimental/DataBitsSearch.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": 41.5195530726, "max_line_length": 102, "alphanum_fraction": 0.4413347686, "num_tokens": 2756, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527631, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.5932179158163305}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule EqBool where\n\nopen import Data.Bool\n\nrecord HasEqBool {a} (A : Set a) : Set a where\n field _==_ : A → A → Bool\n\nopen HasEqBool ⦃ ... ⦄ public\n\nopen import Data.List as List using (List; _∷_; [])\n\n==[] : ∀ {a} {A : Set a} → ⦃ _ : HasEqBool A ⦄ → List A → List A → Bool\n==[] [] [] = true\n==[] [] (x ∷ ys) = false\n==[] (x ∷ xs) [] = false\n==[] (x ∷ xs) (y ∷ ys) = x == y ∧ ==[] xs ys\n\ninstance\n eqList : ∀ {a} {A : Set a} → ⦃ _ : HasEqBool A ⦄ → HasEqBool (List A)\n _==_ ⦃ eqList ⦄ = ==[]\n\nopen import Data.Nat using (ℕ)\ninstance\n eqNat : HasEqBool ℕ\n _==_ ⦃ eqNat ⦄ = Agda.Builtin.Nat._==_\n where import Agda.Builtin.Nat\n\ninstance\n eqBool : HasEqBool Bool\n _==_ ⦃ eqBool ⦄ false false = true\n _==_ ⦃ eqBool ⦄ false true = false\n _==_ ⦃ eqBool ⦄ true y = y\n\nopen import Data.String using (String)\ninstance\n eqString : HasEqBool String\n _==_ ⦃ eqString ⦄ = Data.String._==_\n where import Data.String\n", "meta": {"hexsha": "dc9f62b9b6332c460a849770f5ace82345194cf6", "size": 956, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/EqBool.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/EqBool.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/EqBool.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": 23.3170731707, "max_line_length": 71, "alphanum_fraction": 0.5763598326, "num_tokens": 377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.5930972211583929}} {"text": "open import FRP.JS.Level using ( Level ; _⊔_ ) renaming ( zero to o ; suc to ↑ )\nopen import FRP.JS.Time using ( Time ; _≤_ ; _<_ )\nopen import FRP.JS.Bool using ( Bool ; true ; false ; not ; _≟_ ) \nopen import FRP.JS.True using ( True ; tt )\n\nmodule FRP.JS.Model where\n\n-- This model is essentially System F-omega with a kind time\n-- together with a type for the partial order on time,\n-- and expressions for reflexivity and transitivity.\n-- We prove parametricity, and then show that parametricity implies causality.\n\n-- Note that this is a \"deep\" notion of causality, not the \"shallow\"\n-- causality usually used in FRP. The pragmatic upshot of this is that\n-- there is only one time model: nested signals are in the same time\n-- model, not a simulated time model. This fits with the JS implementation,\n-- which uses wall clock time for all signals.\n\n-- Propositional equality\n\ndata _≡_ {α} {A : Set α} (a : A) : A → Set α where\n refl : a ≡ a\n\nsym : ∀ {α} {A : Set α} {a b : A} → (a ≡ b) → (b ≡ a)\nsym refl = refl\n\ntrans : ∀ {α} {A : Set α} {a b c : A} → (a ≡ b) → (b ≡ c) → (a ≡ c)\ntrans refl refl = refl\n\ncong : ∀ {α β} {A : Set α} {B : Set β} (f : A → B) {a₁ a₂ : A} →\n (a₁ ≡ a₂) → (f a₁ ≡ f a₂)\ncong f refl = refl\n\napply : ∀ {α β} {A : Set α} {B : Set β} {F G : A → B} → (F ≡ G) → \n ∀ {a b} → (a ≡ b) → (F a ≡ G b)\napply refl refl = refl\n\ncast : ∀ {α} {A B : Set α} → (A ≡ B) → A → B\ncast refl a = a\n\ncast² : ∀ {α} {A B : Set α} {ℜ ℑ : A → B → Set α} → (ℜ ≡ ℑ) → ∀ {a b} → ℜ a b → ℑ a b\ncast² refl aℜb = aℜb\n\nirrel : ∀ b → (b₁ b₂ : True b) → (b₁ ≡ b₂)\nirrel true tt tt = refl\nirrel false () ()\n\n-- Postulates (including dependent extensionality)\n\ndata _≤?_ (t u : Time) : Set where\n leq : True (t ≤ u) → (t ≤? u)\n geq : True (u ≤ t) → (t ≤? u)\n\npostulate\n ≤-refl : ∀ t → True (t ≤ t)\n ≤-trans : ∀ t u v → True (t ≤ u) → True (u ≤ v) → True (t ≤ v)\n ≤-asym : ∀ t u → True (t ≤ u) → True (u ≤ t) → (t ≡ u)\n ≤-total : ∀ t u → (t ≤? u) \n dext : ∀ {α β} {A : Set α} {B : A → Set β} {F G : ∀ a → B a} → (∀ a → F a ≡ G a) → (F ≡ G)\n\next : ∀ {α β} {A : Set α} {B : Set β} {F G : A → B} →\n (∀ a → F a ≡ G a) → (F ≡ G)\next = dext\n\niext : ∀ {α β} {A : Set α} {B : A → Set β} {F G : ∀ {a} → B a} → \n (∀ a → F {a} ≡ G {a}) → ((λ {a} → F {a}) ≡ (λ {a} → G {a}))\niext F≈G = cong (λ X {a} → X a) (dext F≈G)\n\n-- Finite products\n\nrecord ⊤ {α} : Set α where\n constructor tt\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_×_ : ∀ {α β} → Set α → Set β → Set (α ⊔ β)\nA × B = Σ A (λ a → B)\n\n_ײ_ : ∀ {α β} {A C : Set α} {B D : Set β} → \n (A → C → Set α) → (B → D → Set β) → ((A × B) → (C × D) → Set (α ⊔ β))\n(ℜ ײ ℑ) (a , b) (c , d) = (ℜ a c × ℑ b d)\n\n_→²_ : ∀ {α β} {A C : Set α} {B D : Set β} → \n (A → C → Set α) → (B → D → Set β) → ((A → B) → (C → D) → Set (α ⊔ β))\n(ℜ →² ℑ) f g = ∀ {a b} → ℜ a b → ℑ (f a) (g b)\n\n-- Case on booleans\n\ndata Case (c : Bool) : Set where\n _,_ : ∀ b → True (b ≟ c) → Case c\n\nswitch : ∀ b → Case b\nswitch true = (true , tt)\nswitch false = (false , tt)\n\n-- Reactive sets\n\nRSet : ∀ α → Set (↑ α)\nRSet α = Time → Set α\n\n-- Equalitional reasoning\n\ninfix 4 _IsRelatedTo_\ninfix 2 _∎\ninfixr 2 _≡⟨_⟩_\ninfix 1 begin_\n\ndata _IsRelatedTo_ {α} {A : Set α} (a b : A) : Set α where\n relTo : (a≡b : a ≡ b) → a IsRelatedTo b\n\nbegin_ : ∀ {α} {A : Set α} {a b : A} → a IsRelatedTo b → a ≡ b\nbegin relTo a≡b = a≡b\n\n_≡⟨_⟩_ : ∀ {α} {A : Set α} a {b c : A} → a ≡ b → b IsRelatedTo c → a IsRelatedTo c\n_ ≡⟨ a≡b ⟩ relTo b≡c = relTo (trans a≡b b≡c)\n\n_∎ : ∀ {α} {A : Set α} (a : A) → a IsRelatedTo a\n_∎ _ = relTo refl\n\n-- Kinds\n\ndata Kind : Set where\n time : Kind\n set : Level → Kind\n _⇒_ : Kind → Kind → Kind\n\nlevel : Kind → Level\nlevel time = o\nlevel (set α) = ↑ α\nlevel (K ⇒ L) = level K ⊔ level L\n\nK⟦_⟧ : ∀ K → Set (level K)\nK⟦ time ⟧ = Time\nK⟦ set α ⟧ = Set α\nK⟦ K ⇒ L ⟧ = K⟦ K ⟧ → K⟦ L ⟧\n\n_∋_↔_ : ∀ K → K⟦ K ⟧ → K⟦ K ⟧ → Set (level K)\ntime ∋ t ↔ u = (t ≡ u)\nset α ∋ A ↔ B = A → B → Set α\n(K ⇒ L) ∋ F ↔ G = ∀ {A B} → (K ∋ A ↔ B) → (L ∋ F A ↔ G B)\n\n-- ≡ can be used as a structural equivalence on relations.\n\nstruct : ∀ K {A B C D} → (A ≡ B) → (K ∋ B ↔ D) → (C ≡ D) → (K ∋ A ↔ C)\nstruct K refl ℜ refl = ℜ\n\nstruct-ext : ∀ K L {A B} {F G H I : K⟦ K ⇒ L ⟧} \n (F≈G : ∀ A → F A ≡ G A) (ℜ : (K ⇒ L) ∋ G ↔ I) (H≈I : ∀ B → H B ≡ I B) (ℑ : K ∋ A ↔ B) →\n struct L (F≈G A) (ℜ ℑ) (H≈I B) ≡ struct (K ⇒ L) (ext F≈G) ℜ (ext H≈I) ℑ\nstruct-ext K L {A} {B} F≈G ℜ H≈I ℑ \n with ext F≈G | ext H≈I | F≈G A | H≈I B\n... | refl | refl | refl | refl = refl\n\nstruct-apply : ∀ K L {F G H I A B C D} → \n (F≡G : F ≡ G) (ℜ : (K ⇒ L) ∋ G ↔ I) (H≡I : H ≡ I) → \n (A≡B : A ≡ B) (ℑ : K ∋ B ↔ D) (C≡D : C ≡ D) → \n struct (K ⇒ L) F≡G ℜ H≡I (struct K A≡B ℑ C≡D)\n ≡ struct L (apply F≡G A≡B) (ℜ ℑ) (apply H≡I C≡D)\nstruct-apply K L refl ℜ refl refl ℑ refl = refl\n\nstruct-cast : ∀ {α A B C D} (ℜ : set α ∋ B ↔ D) (A≡B : A ≡ B) (C≡D : C ≡ D) {a c} →\n struct (set α) A≡B ℜ C≡D a c → ℜ (cast A≡B a) (cast C≡D c)\nstruct-cast ℜ refl refl aℜc = aℜc\n\nstruct-sym : ∀ K {A B C D ℑ ℜ} → (A≡B : A ≡ B) → (C≡D : C ≡ D) →\n (ℑ ≡ struct K A≡B ℜ C≡D) → \n (ℜ ≡ struct K (sym A≡B) ℑ (sym C≡D))\nstruct-sym K refl refl refl = refl\n\nstruct-trans : ∀ K {A B C D E F}\n (A≡B : A ≡ B) (B≡C : B ≡ C) (ℜ : K ∋ C ↔ F) (E≡F : E ≡ F) (D≡E : D ≡ E) →\n struct K A≡B (struct K B≡C ℜ E≡F) D≡E ≡\n struct K (trans A≡B B≡C) ℜ (trans D≡E E≡F)\nstruct-trans K refl refl ℜ refl refl = refl\n\n-- Type contexts\n\ninfixr 4 _∷_\n\ndata Kinds : Set where\n [] : Kinds\n _∷_ : Kind → Kinds → Kinds\n\nlevels : Kinds → Level\nlevels [] = o\nlevels (K ∷ Σ) = level K ⊔ levels Σ\n\nΣ⟦_⟧ : ∀ Σ → Set (levels Σ)\nΣ⟦ [] ⟧ = ⊤\nΣ⟦ K ∷ Σ ⟧ = K⟦ K ⟧ × Σ⟦ Σ ⟧\n\n_∋_↔*_ : ∀ Σ → Σ⟦ Σ ⟧ → Σ⟦ Σ ⟧ → Set (levels Σ)\n[] ∋ tt ↔* tt = ⊤\n(K ∷ Σ) ∋ (A , As) ↔* (B , Bs) = (K ∋ A ↔ B) × (Σ ∋ As ↔* Bs)\n\n-- Inclusion order on type contexts.\n-- Credited by Randy Pollack to Geuvers and Nederhof, JAR 1991.\n-- http://thread.gmane.org/gmane.comp.lang.agda/3259/focus=3267\n\ndata _⊑_ : Kinds → Kinds → Set where\n id : ∀ {Σ} → Σ ⊑ Σ\n keep : ∀ K {Σ Υ} → (Σ ⊑ Υ) → ((K ∷ Σ) ⊑ (K ∷ Υ))\n skip : ∀ K {Σ Υ} → (Σ ⊑ Υ) → (Σ ⊑ (K ∷ Υ))\n\n⊑⟦_⟧ : ∀ {Σ Υ} → (Σ ⊑ Υ) → Σ⟦ Υ ⟧ → Σ⟦ Σ ⟧\n⊑⟦ id ⟧ As = As\n⊑⟦ keep K Σ⊑Υ ⟧ (A , As) = (A , ⊑⟦ Σ⊑Υ ⟧ As)\n⊑⟦ skip K Σ⊑Υ ⟧ (A , As) = ⊑⟦ Σ⊑Υ ⟧ As\n\n⊑⟦_⟧² : ∀ {Σ Υ} → (Σ⊑Υ : Σ ⊑ Υ) → ∀ {As Bs} → (Υ ∋ As ↔* Bs) → (Σ ∋ ⊑⟦ Σ⊑Υ ⟧ As ↔* ⊑⟦ Σ⊑Υ ⟧ Bs)\n⊑⟦ id ⟧² ℜs = ℜs\n⊑⟦ keep K Σ⊑Υ ⟧² (ℜ , ℜs) = (ℜ , ⊑⟦ Σ⊑Υ ⟧² ℜs)\n⊑⟦ skip K Σ⊑Υ ⟧² (ℜ , ℜs) = ⊑⟦ Σ⊑Υ ⟧² ℜs\n\n-- Concatenation of type contexts\n\n_++_ : Kinds → Kinds → Kinds\n[] ++ Υ = Υ\n(K ∷ Σ) ++ Υ = K ∷ (Σ ++ Υ)\n\n_∋_++_∋_ : ∀ Σ → Σ⟦ Σ ⟧ → ∀ Υ → Σ⟦ Υ ⟧ → Σ⟦ Σ ++ Υ ⟧\n[] ∋ tt ++ Υ ∋ Bs = Bs\n(K ∷ Σ) ∋ (A , As) ++ Υ ∋ Bs = (A , (Σ ∋ As ++ Υ ∋ Bs))\n\n_∋_++²_∋_ : ∀ Σ {As Bs} → (Σ ∋ As ↔* Bs) → ∀ Υ {Cs Ds} → (Υ ∋ Cs ↔* Ds) → \n ((Σ ++ Υ) ∋ (Σ ∋ As ++ Υ ∋ Cs) ↔* (Σ ∋ Bs ++ Υ ∋ Ds))\n[] ∋ tt ++² Υ ∋ ℑs = ℑs\n(K ∷ Σ) ∋ (ℜ , ℜs) ++² Υ ∋ ℑs = (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))\n\n-- Type variables\n\ndata TVar (K : Kind) : Kinds → Set where\n zero : ∀ {Σ} → TVar K (K ∷ Σ)\n suc : ∀ {L Σ} → TVar K Σ → TVar K (L ∷ Σ)\n\nτ⟦_⟧ : ∀ {Σ K} (τ : TVar K Σ) → Σ⟦ Σ ⟧ → K⟦ K ⟧\nτ⟦ zero ⟧ (A , As) = A\nτ⟦ suc τ ⟧ (A , As) = τ⟦ τ ⟧ As\n\nτ⟦_⟧² : ∀ {Σ K} (τ : TVar K Σ) {As Bs} → (Σ ∋ As ↔* Bs) → (K ∋ τ⟦ τ ⟧ As ↔ τ⟦ τ ⟧ Bs)\nτ⟦ zero ⟧² (ℜ , ℜs) = ℜ\nτ⟦ suc τ ⟧² (ℜ , ℜs) = τ⟦ τ ⟧² ℜs\n\n-- Type constants\n\ndata TConst : Kind → Set where\n prod fun : ∀ {α β} → TConst (set α ⇒ (set β ⇒ set (α ⊔ β)))\n leq : TConst (time ⇒ (time ⇒ set o))\n univ : ∀ K {α} → TConst ((K ⇒ set α) ⇒ set (level K ⊔ α))\n\nC⟦_⟧ : ∀ {K} → (TConst K) → K⟦ K ⟧\nC⟦ prod ⟧ = λ A B → (A × B)\nC⟦ fun ⟧ = λ A B → (A → B)\nC⟦ leq ⟧ = λ t u → True (t ≤ u)\nC⟦ univ K ⟧ = λ F → ∀ A → F A\n\nC⟦_⟧² : ∀ {K} (C : TConst K) → (K ∋ C⟦ C ⟧ ↔ C⟦ C ⟧)\nC⟦ prod ⟧² = λ ℜ ℑ → (ℜ ײ ℑ)\nC⟦ fun ⟧² = λ ℜ ℑ → (ℜ →² ℑ)\nC⟦ leq ⟧² = λ _ _ _ _ → ⊤\nC⟦ univ K ⟧² = λ ℜ f g → ∀ {a b} ℑ → ℜ ℑ (f a) (g b)\n\n-- Types\n\ndata Typ (Σ : Kinds) : Kind → Set where\n const : ∀ {K} → TConst K → Typ Σ K\n abs : ∀ K {L} → Typ (K ∷ Σ) L → Typ Σ (K ⇒ L)\n app : ∀ {K L} → Typ Σ (K ⇒ L) → Typ Σ K → Typ Σ L\n var : ∀ {K} → TVar K Σ → Typ Σ K\n\ntlevel : ∀ {Σ α} → Typ Σ (set α) → Level\ntlevel {Σ} {α} T = α\n\nT⟦_⟧ : ∀ {Σ K} (T : Typ Σ K) → Σ⟦ Σ ⟧ → K⟦ K ⟧\nT⟦ const C ⟧ As = C⟦ C ⟧\nT⟦ abs K T ⟧ As = λ A → T⟦ T ⟧ (A , As)\nT⟦ app T U ⟧ As = T⟦ T ⟧ As (T⟦ U ⟧ As)\nT⟦ var τ ⟧ As = τ⟦ τ ⟧ As\n\nT⟦_⟧² : ∀ {Σ K} (T : Typ Σ K) {As Bs} → (Σ ∋ As ↔* Bs) → (K ∋ T⟦ T ⟧ As ↔ T⟦ T ⟧ Bs)\nT⟦ const C ⟧² ℜs = C⟦ C ⟧²\nT⟦ abs K T ⟧² ℜs = λ ℜ → T⟦ T ⟧² (ℜ , ℜs)\nT⟦ app T U ⟧² ℜs = T⟦ T ⟧² ℜs (T⟦ U ⟧² ℜs)\nT⟦ var τ ⟧² ℜs = τ⟦ τ ⟧² ℜs\n\n-- Type shorthands\n\napp₂ : ∀ {Σ K L M} → Typ Σ (K ⇒ (L ⇒ M)) → Typ Σ K → Typ Σ L → Typ Σ M\napp₂ T U V = app (app T U) V\n\ncapp : ∀ {Σ K L} → TConst (K ⇒ L) → Typ Σ K → Typ Σ L\ncapp C = app (const C)\n\ncapp₂ : ∀ {Σ K L M} → TConst (K ⇒ (L ⇒ M)) → Typ Σ K → Typ Σ L → Typ Σ M\ncapp₂ C = app₂ (const C)\n\n_⊗_ : ∀ {Σ α β} → Typ Σ (set α) → Typ Σ (set β) → Typ Σ (set (α ⊔ β))\n_⊗_ = capp₂ prod\n\n_⊸_ : ∀ {Σ α β} → Typ Σ (set α) → Typ Σ (set β) → Typ Σ (set (α ⊔ β))\n_⊸_ = capp₂ fun\n\n_≼_ : ∀ {Σ} → Typ Σ time → Typ Σ time → Typ Σ (set o)\n_≼_ = capp₂ leq\n\nΠ : ∀ {Σ α} K → Typ (K ∷ Σ) (set α) → Typ Σ (set (level K ⊔ α))\nΠ K T = capp (univ K) (abs K T)\n\ntvar₀ : ∀ {Σ K} → Typ (K ∷ Σ) K\ntvar₀ = var zero\n\ntvar₁ : ∀ {Σ K L} → Typ (L ∷ K ∷ Σ) K\ntvar₁ = var (suc zero)\n\ntvar₂ : ∀ {Σ K L M} → Typ (M ∷ L ∷ K ∷ Σ) K\ntvar₂ = var (suc (suc zero))\n\ntvar₃ : ∀ {Σ K L M N} → Typ (N ∷ M ∷ L ∷ K ∷ Σ) K\ntvar₃ = var (suc (suc (suc zero)))\n\nrset : Level → Kind\nrset α = time ⇒ set α\n\nrset₀ : Kind\nrset₀ = rset o\n\nprodʳ : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β)))\nprodʳ {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (app tvar₂ tvar₀ ⊗ app tvar₁ tvar₀)))\n\n_⊗ʳ_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β))\n_⊗ʳ_ = app₂ prodʳ\n\nfunʳ : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β)))\nfunʳ {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (app tvar₂ tvar₀ ⊸ app tvar₁ tvar₀)))\n\n_⊸ʳ_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β))\n_⊸ʳ_ = app₂ funʳ\n\nalways : ∀ {Σ α} → Typ Σ (set α ⇒ rset α)\nalways {Σ} {α} = abs (set α) (abs time tvar₁)\n\ninterval : ∀ {Σ α} → Typ Σ (rset α ⇒ (time ⇒ (time ⇒ set α)))\ninterval {Σ} {α} = abs (rset α) (abs time (abs time (Π time \n ((tvar₂ ≼ tvar₀) ⊸ ((tvar₀ ≼ tvar₁) ⊸ app tvar₃ tvar₀)))))\n\n_[_,_] : ∀ {Σ α} → Typ Σ (rset α) → Typ Σ time → Typ Σ time → Typ Σ (set α)\nT [ t , u ] = app (app (app interval T) t) u\n\nconstreq : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β)))\nconstreq {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (Π time \n ((tvar₁ ≼ tvar₀) ⊸ ((tvar₃ [ tvar₁ , tvar₀ ]) ⊸ app tvar₂ tvar₀)))))\n\n_⊵_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β))\nT ⊵ U = app₂ constreq T U\n\n-- Contexts\n\ndata Typs (Σ : Kinds) : Set where\n [] : Typs Σ\n _∷_ : ∀ {α} → (Typ Σ (set α)) → Typs Σ → Typs Σ\n\ntlevels : ∀ {Σ} → Typs Σ → Level\ntlevels [] = o\ntlevels (T ∷ Γ) = tlevel T ⊔ tlevels Γ\n\nΓ⟦_⟧ : ∀ {Σ} (Γ : Typs Σ) → Σ⟦ Σ ⟧ → Set (tlevels Γ)\nΓ⟦ [] ⟧ As = ⊤\nΓ⟦ T ∷ Γ ⟧ As = T⟦ T ⟧ As × Γ⟦ Γ ⟧ As\n\nΓ⟦_⟧² : ∀ {Σ} (Γ : Typs Σ) {As Bs} (ℜs : Σ ∋ As ↔* Bs) → (Γ⟦ Γ ⟧ As → Γ⟦ Γ ⟧ Bs → Set (tlevels Γ))\nΓ⟦ [] ⟧² ℜs tt tt = ⊤\nΓ⟦ T ∷ Γ ⟧² ℜs (a , as) (b , bs) = T⟦ T ⟧² ℜs a b × Γ⟦ Γ ⟧² ℜs as bs\n\n-- Weakening of type variables\n\nτweaken : ∀ {Σ Υ K} → (Σ ⊑ Υ) → TVar K Σ → TVar K Υ\nτweaken id x = x\nτweaken (keep K Σ⊑Υ) zero = zero\nτweaken (keep K Σ⊑Υ) (suc x) = suc (τweaken Σ⊑Υ x)\nτweaken (skip K Σ⊑Υ) x = suc (τweaken Σ⊑Υ x)\n\nτweaken⟦_⟧ : ∀ {Σ Υ K} (τ : TVar K Σ) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) → \n τ⟦ τ ⟧ (⊑⟦ Σ⊑Υ ⟧ As) ≡ τ⟦ τweaken Σ⊑Υ τ ⟧ As\nτweaken⟦ τ ⟧ id As = refl\nτweaken⟦ zero ⟧ (keep K Σ⊑Υ) (A , As) = refl\nτweaken⟦ suc τ ⟧ (keep K Σ⊑Υ) (A , As) = τweaken⟦ τ ⟧ Σ⊑Υ As\nτweaken⟦ τ ⟧ (skip K Σ⊑Υ) (A , As) = τweaken⟦ τ ⟧ Σ⊑Υ As\n\nτweaken⟦_⟧² : ∀ {Σ Υ K} (τ : TVar K Σ) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) → \n τ⟦ τ ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ≡ \n struct K (τweaken⟦ τ ⟧ Σ⊑Υ As) (τ⟦ τweaken Σ⊑Υ τ ⟧² ℜs) (τweaken⟦ τ ⟧ Σ⊑Υ Bs)\nτweaken⟦ τ ⟧² id ℜs = refl\nτweaken⟦ zero ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) = refl\nτweaken⟦ suc τ ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) = τweaken⟦ τ ⟧² Σ⊑Υ ℜs\nτweaken⟦ τ ⟧² (skip K Σ⊑Υ) (ℜ , ℜs) = τweaken⟦ τ ⟧² Σ⊑Υ ℜs\n\n-- Weakening of types\n\nweaken : ∀ {Σ Υ K} → (Σ ⊑ Υ) → Typ Σ K → Typ Υ K\nweaken Σ⊑Υ (const C) = const C\nweaken Σ⊑Υ (abs K T) = abs K (weaken (keep K Σ⊑Υ) T)\nweaken Σ⊑Υ (app T U) = app (weaken Σ⊑Υ T) (weaken Σ⊑Υ U)\nweaken Σ⊑Υ (var τ) = var (τweaken Σ⊑Υ τ)\n\nweaken⟦_⟧ : ∀ {Σ Υ K} (T : Typ Σ K) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) → \n T⟦ T ⟧ (⊑⟦ Σ⊑Υ ⟧ As) ≡ T⟦ weaken Σ⊑Υ T ⟧ As\nweaken⟦ const C ⟧ Σ⊑Υ As = refl\nweaken⟦ abs K T ⟧ Σ⊑Υ As = ext (λ A → weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As))\nweaken⟦ app T U ⟧ Σ⊑Υ As = apply (weaken⟦ T ⟧ Σ⊑Υ As) (weaken⟦ U ⟧ Σ⊑Υ As) \nweaken⟦ var τ ⟧ Σ⊑Υ As = τweaken⟦ τ ⟧ Σ⊑Υ As\n \nweaken⟦_⟧² : ∀ {Σ Υ K} (T : Typ Σ K) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) → \n T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ≡ struct K (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs)\nweaken⟦ const C ⟧² Σ⊑Υ ℜs = refl\nweaken⟦ abs K {L} T ⟧² Σ⊑Υ {As} {Bs} ℜs =\n iext (λ A → iext (λ B → ext (λ ℜ → begin\n T⟦ abs K T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ℜ\n ≡⟨ weaken⟦ T ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) ⟩\n struct L \n (weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As)) \n (T⟦ weaken (keep K Σ⊑Υ) T ⟧² (ℜ , ℜs)) \n (weaken⟦ T ⟧ (keep K Σ⊑Υ) (B , Bs))\n ≡⟨ struct-ext K L \n (λ A → weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As)) \n (λ ℜ → T⟦ weaken (keep K Σ⊑Υ) T ⟧² (ℜ , ℜs)) \n (λ B → weaken⟦ T ⟧ (keep K Σ⊑Υ) (B , Bs)) ℜ ⟩\n struct (K ⇒ L) \n (weaken⟦ abs K T ⟧ Σ⊑Υ As)\n (T⟦ weaken Σ⊑Υ (abs K T) ⟧² ℜs) \n (weaken⟦ abs K T ⟧ Σ⊑Υ Bs) ℜ\n ∎)))\nweaken⟦ app {K} {L} T U ⟧² Σ⊑Υ {As} {Bs} ℜs = \n begin\n T⟦ app T U ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs)\n ≡⟨ cong (T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs)) (weaken⟦ U ⟧² Σ⊑Υ ℜs) ⟩\n T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs)\n (struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs))\n ≡⟨ cong (λ X → X (struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs)))\n (weaken⟦ T ⟧² Σ⊑Υ ℜs) ⟩\n (struct (K ⇒ L) (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs))\n (struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs))\n ≡⟨ struct-apply K L \n (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs) \n (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs) ⟩\n struct L\n (weaken⟦ app T U ⟧ Σ⊑Υ As)\n (T⟦ weaken Σ⊑Υ (app T U) ⟧² ℜs) \n (weaken⟦ app T U ⟧ Σ⊑Υ Bs)\n ∎\nweaken⟦ var τ ⟧² Σ⊑Υ ℜs = τweaken⟦ τ ⟧² Σ⊑Υ ℜs\n\n-- Weakening on type contexts\n\nweakens : ∀ {Σ Υ} → (Σ ⊑ Υ) → Typs Σ → Typs Υ\nweakens Σ⊑Υ [] = []\nweakens Σ⊑Υ (T ∷ Γ) = weaken Σ⊑Υ T ∷ weakens Σ⊑Υ Γ\n\nweakens⟦_⟧ : ∀ {Σ Υ} (Γ : Typs Σ) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) → \n Γ⟦ Γ ⟧ (⊑⟦ Σ⊑Υ ⟧ As) → Γ⟦ weakens Σ⊑Υ Γ ⟧ As\nweakens⟦ [] ⟧ Σ⊑Υ As tt = tt\nweakens⟦ T ∷ Γ ⟧ Σ⊑Υ As (B , Bs) = (cast (weaken⟦ T ⟧ Σ⊑Υ As) B , weakens⟦ Γ ⟧ Σ⊑Υ As Bs)\n\nweakens⟦_⟧² : ∀ {Σ Υ} (Γ : Typs Σ) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) {as bs} → \n Γ⟦ Γ ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) as bs → \n Γ⟦ weakens Σ⊑Υ Γ ⟧² ℜs (weakens⟦ Γ ⟧ Σ⊑Υ As as) (weakens⟦ Γ ⟧ Σ⊑Υ Bs bs)\nweakens⟦ [] ⟧² Σ⊑Υ ℜs tt\n = tt\nweakens⟦ T ∷ Γ ⟧² Σ⊑Υ ℜs (aℜb , asℜbs) \n = ( struct-cast (T⟦ weaken Σ⊑Υ T ⟧² ℜs) \n (weaken⟦ T ⟧ Σ⊑Υ _) (weaken⟦ T ⟧ Σ⊑Υ _) (cast² (weaken⟦ T ⟧² Σ⊑Υ ℜs) aℜb)\n , weakens⟦ Γ ⟧² Σ⊑Υ ℜs asℜbs)\n\n-- Susbtitution on type variables under a context\n\nτsubstn+ : ∀ Σ {Υ K L} → TVar K (Σ ++ (L ∷ Υ)) → Typ Υ L → Typ (Σ ++ Υ) K\nτsubstn+ [] zero U = U\nτsubstn+ [] (suc τ) U = var τ\nτsubstn+ (K ∷ Σ) zero U = var zero\nτsubstn+ (K ∷ Σ) (suc τ) U = weaken (skip K id) (τsubstn+ Σ τ U)\n\nτsubstn+_⟦_⟧⟦_⟧ : ∀ Σ {Υ K L} (τ : TVar K (Σ ++ (L ∷ Υ))) (U : Typ Υ L) \n (As : Σ⟦ Σ ⟧) (Bs : Σ⟦ Υ ⟧) →\n τ⟦ τ ⟧ (Σ ∋ As ++ (L ∷ Υ) ∋ (T⟦ U ⟧ Bs , Bs)) ≡ \n T⟦ τsubstn+ Σ τ U ⟧ (Σ ∋ As ++ Υ ∋ Bs)\nτsubstn+ [] ⟦ zero ⟧⟦ U ⟧ tt Bs = refl\nτsubstn+ [] ⟦ suc τ ⟧⟦ U ⟧ tt Bs = refl\nτsubstn+ (K ∷ Σ) ⟦ zero ⟧⟦ U ⟧ (A , As) Bs = refl\nτsubstn+ (K ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (A , As) Bs = trans \n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Bs) \n (weaken⟦ τsubstn+ Σ τ U ⟧ (skip K id) (A , (Σ ∋ As ++ _ ∋ Bs)))\n\nτsubstn+_⟦_⟧⟦_⟧² : ∀ Σ {Υ L K} (τ : TVar K (Σ ++ (L ∷ Υ))) (U : Typ Υ L) {As Bs Cs Ds} \n (ℜs : Σ ∋ As ↔* Bs) → (ℑs : Υ ∋ Cs ↔* Ds) →\n τ⟦ τ ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡ \n struct K \n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) \n (T⟦ τsubstn+ Σ τ U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs) )\n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)\nτsubstn+ [] ⟦ zero ⟧⟦ U ⟧² tt ℑs = refl\nτsubstn+ [] ⟦ suc τ ⟧⟦ U ⟧² tt ℑs = refl\nτsubstn+ (J ∷ Σ) ⟦ zero ⟧⟦ U ⟧² (ℜ , ℜs) ℑs = refl\nτsubstn+_⟦_⟧⟦_⟧² (J ∷ Σ) {Υ} {L} {K} (suc τ) U {A , As} {B , Bs} {Cs} {Ds} (ℜ , ℜs) ℑs = \n begin\n τ⟦ τ ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs))\n ≡⟨ τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧² ℜs ℑs ⟩\n struct K \n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs)\n (T⟦ τsubstn+ Σ τ U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))\n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)\n ≡⟨ cong (λ X → struct K (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) X (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)) \n (weaken⟦ τsubstn+ Σ τ U ⟧² (skip J id) (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))) ⟩\n struct K \n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) \n (struct K\n (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (A , (Σ ∋ As ++ Υ ∋ Cs))) \n (T⟦ weaken (skip J id) (τsubstn+ Σ τ U) ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))) \n (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (B , (Σ ∋ Bs ++ Υ ∋ Ds)))) \n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)\n ≡⟨ struct-trans K \n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) \n (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (A , (Σ ∋ As ++ Υ ∋ Cs)))\n (T⟦ weaken (skip J id) (τsubstn+ Σ τ U) ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs)))\n (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (B , (Σ ∋ Bs ++ Υ ∋ Ds)))\n (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds) ⟩\n struct K \n (τsubstn+ (J ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (A , As) Cs) \n (T⟦ τsubstn+ (J ∷ Σ) (suc τ) U ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs)) )\n (τsubstn+ (J ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (B , Bs) Ds) \n ∎\n\n-- Substitution on types under a context\n\nsubstn+ : ∀ Σ {Υ K L} → Typ (Σ ++ (L ∷ Υ)) K → Typ Υ L → Typ (Σ ++ Υ) K\nsubstn+ Σ (const C) U = const C\nsubstn+ Σ (abs K T) U = abs K (substn+ (K ∷ Σ) T U)\nsubstn+ Σ (app S T) U = app (substn+ Σ S U) (substn+ Σ T U)\nsubstn+ Σ (var τ) U = τsubstn+ Σ τ U\n\nsubstn+_⟦_⟧⟦_⟧ : ∀ Σ {Υ K L} (T : Typ (Σ ++ (L ∷ Υ)) K) (U : Typ Υ L) \n (As : Σ⟦ Σ ⟧) (Bs : Σ⟦ Υ ⟧) →\n T⟦ T ⟧ (Σ ∋ As ++ (L ∷ Υ) ∋ (T⟦ U ⟧ Bs , Bs)) ≡ \n T⟦ substn+ Σ T U ⟧ (Σ ∋ As ++ Υ ∋ Bs)\nsubstn+ Σ ⟦ const C ⟧⟦ U ⟧ As Bs = refl\nsubstn+ Σ ⟦ abs K T ⟧⟦ U ⟧ As Bs = ext (λ A → substn+ K ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Bs)\nsubstn+ Σ ⟦ app S T ⟧⟦ U ⟧ As Bs = apply (substn+ Σ ⟦ S ⟧⟦ U ⟧ As Bs) (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Bs)\nsubstn+ Σ ⟦ var τ ⟧⟦ U ⟧ As Bs = τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Bs\n\nsubstn+_⟦_⟧⟦_⟧² : ∀ Σ {Υ L K} (T : Typ (Σ ++ (L ∷ Υ)) K) (U : Typ Υ L) {As Bs Cs Ds} \n (ℜs : Σ ∋ As ↔* Bs) → (ℑs : Υ ∋ Cs ↔* Ds) →\n T⟦ T ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡ \n struct K \n (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs) \n (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs) )\n (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds)\nsubstn+ Σ ⟦ const C ⟧⟦ U ⟧² ℜs ℑs = refl\nsubstn+_⟦_⟧⟦_⟧² Σ {Υ} {L} (abs J {K} T) U {As} {Bs} {Cs} {Ds} ℜs ℑs = \n iext (λ A → iext (λ B → ext (λ ℜ → begin\n T⟦ abs J T ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ℜ\n ≡⟨ substn+ (J ∷ Σ) ⟦ T ⟧⟦ U ⟧² (ℜ , ℜs) ℑs ⟩\n struct K \n (substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Cs) \n (T⟦ substn+ (J ∷ Σ) T U ⟧² ((J ∷ Σ) ∋ (ℜ , ℜs) ++² Υ ∋ ℑs)) \n (substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (B , Bs) Ds)\n ≡⟨ struct-ext J K \n (λ A → substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Cs) \n (λ ℜ → T⟦ substn+ (J ∷ Σ) T U ⟧² ((J ∷ Σ) ∋ ℜ , ℜs ++² Υ ∋ ℑs))\n (λ B → substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (B , Bs) Ds) ℜ ⟩\n struct (J ⇒ K) \n (substn+ Σ ⟦ abs J T ⟧⟦ U ⟧ As Cs) \n (T⟦ substn+ Σ (abs J T) U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) \n (substn+ Σ ⟦ abs J T ⟧⟦ U ⟧ Bs Ds) ℜ\n ∎)))\nsubstn+_⟦_⟧⟦_⟧² Σ {Υ} {L} (app {J} {K} S T) U {As} {Bs} {Cs} {Ds} ℜs ℑs = \n begin\n T⟦ app S T ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs))\n ≡⟨ cong (T⟦ S ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs))) (substn+ Σ ⟦ T ⟧⟦ U ⟧² ℜs ℑs) ⟩\n T⟦ S ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs))\n (struct J \n (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)\n (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))\n (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds))\n ≡⟨ cong (λ X → X (struct J \n (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)\n (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))\n (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds))) \n (substn+ Σ ⟦ S ⟧⟦ U ⟧² ℜs ℑs) ⟩\n struct (J ⇒ K) \n (substn+ Σ ⟦ S ⟧⟦ U ⟧ As Cs) \n (T⟦ substn+ Σ S U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))\n (substn+ Σ ⟦ S ⟧⟦ U ⟧ Bs Ds) \n (struct J \n (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)\n (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))\n (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds))\n ≡⟨ struct-apply J K \n (substn+ Σ ⟦ S ⟧⟦ U ⟧ As Cs) \n (T⟦ substn+ Σ S U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) \n (substn+ Σ ⟦ S ⟧⟦ U ⟧ Bs Ds) \n (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)\n (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))\n (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds) ⟩\n struct K \n (substn+ Σ ⟦ app S T ⟧⟦ U ⟧ As Cs)\n (T⟦ substn+ Σ (app S T) U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))\n (substn+ Σ ⟦ app S T ⟧⟦ U ⟧ Bs Ds)\n ∎\nsubstn+ Σ ⟦ var τ ⟧⟦ U ⟧² ℜs ℑs = τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧² ℜs ℑs\n\n-- Substitution on types\n\nsubstn : ∀ {Σ K L} → Typ (L ∷ Σ) K → Typ Σ L → Typ Σ K\nsubstn = substn+ []\n\nsubstn⟦_⟧⟦_⟧ : ∀ {Σ K L} (T : Typ (L ∷ Σ) K) (U : Typ Σ L) (As : Σ⟦ Σ ⟧)→\n T⟦ T ⟧ (T⟦ U ⟧ As , As) ≡ T⟦ substn T U ⟧ As\nsubstn⟦ T ⟧⟦ U ⟧ = substn+ [] ⟦ T ⟧⟦ U ⟧ tt\n\nsubstn⟦_⟧⟦_⟧² : ∀ {Σ K L} (T : Typ (L ∷ Σ) K) (U : Typ Σ L) {As Bs} (ℜs : Σ ∋ As ↔* Bs) →\n T⟦ T ⟧² (T⟦ U ⟧² ℜs , ℜs) ≡ \n struct K (substn⟦ T ⟧⟦ U ⟧ As) (T⟦ substn T U ⟧² ℜs) (substn⟦ T ⟧⟦ U ⟧ Bs)\nsubstn⟦ T ⟧⟦ U ⟧² = substn+ [] ⟦ T ⟧⟦ U ⟧² tt\n\n-- Eta-beta equivalence on types\n\ndata _∋_≣_ {Σ} : ∀ K → Typ Σ K → Typ Σ K → Set where\n abs : ∀ K {L T U} → (L ∋ T ≣ U) → ((K ⇒ L) ∋ abs K T ≣ abs K U)\n app : ∀ {K L F G T U} → ((K ⇒ L) ∋ F ≣ G) → (K ∋ T ≣ U) → (L ∋ app F T ≣ app G U)\n beta : ∀ {K L} T U → (L ∋ app (abs K T) U ≣ substn T U)\n eta : ∀ {K L} T → ((K ⇒ L) ∋ T ≣ abs K (app (weaken (skip K id) T) tvar₀))\n ≣-refl : ∀ {K T} → (K ∋ T ≣ T)\n ≣-sym : ∀ {K T U} → (K ∋ T ≣ U) → (K ∋ U ≣ T)\n ≣-trans : ∀ {K T U V} → (K ∋ T ≣ U) → (K ∋ U ≣ V) → (K ∋ T ≣ V)\n\n≣⟦_⟧ : ∀ {Σ K} {T U : Typ Σ K} → (K ∋ T ≣ U) → ∀ As → T⟦ T ⟧ As ≡ T⟦ U ⟧ As\n≣⟦ abs K T≣U ⟧ As = ext (λ A → ≣⟦ T≣U ⟧ (A , As))\n≣⟦ app F≣G T≣U ⟧ As = apply (≣⟦ F≣G ⟧ As) (≣⟦ T≣U ⟧ As)\n≣⟦ beta T U ⟧ As = substn⟦ T ⟧⟦ U ⟧ As\n≣⟦ eta {K} T ⟧ As = ext (λ A → apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl)\n≣⟦ ≣-refl ⟧ As = refl\n≣⟦ ≣-sym T≣U ⟧ As = sym (≣⟦ T≣U ⟧ As)\n≣⟦ ≣-trans T≣U U≣V ⟧ As = trans (≣⟦ T≣U ⟧ As) (≣⟦ U≣V ⟧ As)\n\n≣⟦_⟧² : ∀ {Σ K} {T U : Typ Σ K} (T≣U : K ∋ T ≣ U) {As Bs} (ℜs : Σ ∋ As ↔* Bs) → \n T⟦ T ⟧² ℜs ≡ struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)\n≣⟦ abs K {L} {T} {U} T≣U ⟧² {As} {Bs} ℜs = \n iext (λ A → iext (λ B → ext (λ ℜ → begin\n T⟦ T ⟧² (ℜ , ℜs)\n ≡⟨ ≣⟦ T≣U ⟧² (ℜ , ℜs) ⟩\n struct L (≣⟦ T≣U ⟧ (A , As)) (T⟦ U ⟧² (ℜ , ℜs)) (≣⟦ T≣U ⟧ (B , Bs))\n ≡⟨ struct-ext K L (λ A → ≣⟦ T≣U ⟧ (A , As)) (λ ℜ' → T⟦ U ⟧² (ℜ' , ℜs)) (λ B → ≣⟦ T≣U ⟧ (B , Bs)) ℜ ⟩\n struct (K ⇒ L) (≣⟦ abs K T≣U ⟧ As) (T⟦ abs K U ⟧² ℜs) (≣⟦ abs K T≣U ⟧ Bs) ℜ\n ∎)))\n≣⟦ app {K} {L} {F} {G} {T} {U} F≣G T≣U ⟧² {As} {Bs} ℜs = \n begin\n T⟦ app F T ⟧² ℜs\n ≡⟨ cong (T⟦ F ⟧² ℜs) (≣⟦ T≣U ⟧² ℜs) ⟩\n T⟦ F ⟧² ℜs (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs))\n ≡⟨ cong (λ X → X (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)))\n (≣⟦ F≣G ⟧² ℜs) ⟩\n struct (K ⇒ L) (≣⟦ F≣G ⟧ As) (T⟦ G ⟧² ℜs) (≣⟦ F≣G ⟧ Bs)\n (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs))\n ≡⟨ struct-apply K L\n (≣⟦ F≣G ⟧ As) (T⟦ G ⟧² ℜs) (≣⟦ F≣G ⟧ Bs)\n (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs) ⟩\n struct L (≣⟦ app F≣G T≣U ⟧ As) (T⟦ app G U ⟧² ℜs) (≣⟦ app F≣G T≣U ⟧ Bs)\n ∎\n≣⟦ beta T U ⟧² ℜs = substn⟦ T ⟧⟦ U ⟧² ℜs\n≣⟦ eta {K} {L} T ⟧² {As} {Bs} ℜs = iext (λ A → iext (λ B → ext (λ ℜ → \n begin\n T⟦ T ⟧² ℜs ℜ\n ≡⟨ cong (λ X → X ℜ) (weaken⟦ T ⟧² (skip K id) (ℜ , ℜs)) ⟩\n struct (K ⇒ L) \n (weaken⟦ T ⟧ (skip K id) (A , As))\n (T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs))\n (weaken⟦ T ⟧ (skip K id) (B , Bs)) ℜ\n ≡⟨ struct-apply K L \n (weaken⟦ T ⟧ (skip K id) (A , As)) \n (T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs)) \n (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl ℜ refl ⟩\n struct L \n (apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl)\n (T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs) ℜ)\n (apply (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl)\n ≡⟨ struct-ext K L\n (λ A → apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl) \n (λ ℜ → T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs) ℜ) \n (λ B → apply (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl) ℜ ⟩\n struct (K ⇒ L) \n (≣⟦ eta T ⟧ As)\n (T⟦ abs K (app (weaken (skip K id) T) (var zero)) ⟧² ℜs)\n (≣⟦ eta T ⟧ Bs) ℜ\n ∎)))\n≣⟦ ≣-refl ⟧² ℜs = refl\n≣⟦ ≣-sym {K} {T} {U} T≣U ⟧² {As} {Bs} ℜs = \n struct-sym K (≣⟦ T≣U ⟧ As) (≣⟦ T≣U ⟧ Bs) (≣⟦ T≣U ⟧² ℜs)\n≣⟦ ≣-trans {K} {T} {U} {V} T≣U U≣V ⟧² {As} {Bs} ℜs =\n begin\n T⟦ T ⟧² ℜs\n ≡⟨ ≣⟦ T≣U ⟧² ℜs ⟩\n struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)\n ≡⟨ cong (λ X → struct K (≣⟦ T≣U ⟧ As) X (≣⟦ T≣U ⟧ Bs)) (≣⟦ U≣V ⟧² ℜs) ⟩\n struct K (≣⟦ T≣U ⟧ As) (struct K (≣⟦ U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ U≣V ⟧ Bs)) (≣⟦ T≣U ⟧ Bs)\n ≡⟨ struct-trans K (≣⟦ T≣U ⟧ As) (≣⟦ U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ U≣V ⟧ Bs) (≣⟦ T≣U ⟧ Bs) ⟩\n struct K (≣⟦ ≣-trans T≣U U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ ≣-trans T≣U U≣V ⟧ Bs)\n ∎\n\n-- Variables\n\ndata Var {Σ : Kinds} {α} (T : Typ Σ (set α)) : Typs Σ → Set where\n zero : ∀ {Γ} → Var T (T ∷ Γ)\n suc : ∀ {β Γ} {U : Typ Σ (set β)} → Var T Γ → Var T (U ∷ Γ)\n\nx⟦_⟧ : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} → \n Var T Γ → (As : Σ⟦ Σ ⟧) → (as : Γ⟦ Γ ⟧ As) → (T⟦ T ⟧ As)\nx⟦ zero ⟧ As (a , as) = a\nx⟦ suc x ⟧ As (a , as) = x⟦ x ⟧ As as\n\nx⟦_⟧² : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} (x : Var T Γ) → \n ∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) {as bs} → \n (Γ⟦ Γ ⟧² ℜs as bs) → (T⟦ T ⟧² ℜs (x⟦ x ⟧ As as) (x⟦ x ⟧ Bs bs))\nx⟦ zero ⟧² ℜs (aℜb , asℜbs) = aℜb\nx⟦ suc x ⟧² ℜs (aℜb , asℜbs) = x⟦ x ⟧² ℜs asℜbs\n\n-- Constants\n\ndata Const {Σ : Kinds} : ∀ {α} → Typ Σ (set α) → Set where\n pair : ∀ {α β} → Const (Π (set α) (Π (set β) (tvar₁ ⊸ (tvar₀ ⊸ (tvar₁ ⊗ tvar₀)))))\n fst : ∀ {α β} → Const (Π (set α) (Π (set β) ((tvar₁ ⊗ tvar₀) ⊸ tvar₁)))\n snd : ∀ {α β} → Const (Π (set α) (Π (set β) ((tvar₁ ⊗ tvar₀) ⊸ tvar₀)))\n ≼-refl : Const (Π time (tvar₀ ≼ tvar₀))\n ≼-trans : Const (Π time (Π time (Π time ((tvar₂ ≼ tvar₁) ⊸ ((tvar₁ ≼ tvar₀) ⊸ (tvar₂ ≼ tvar₀))))))\n ≼-antisym : ∀ {α} → Const (Π (rset α) (Π time (Π time ((tvar₁ ≼ tvar₀) ⊸ ((tvar₀ ≼ tvar₁) ⊸ (app tvar₂ tvar₁ ⊸ app tvar₂ tvar₀))))))\n ≼-case : ∀ {α} → Const (Π (set α) (Π time (Π time (((tvar₁ ≼ tvar₀) ⊸ tvar₂) ⊸ (((tvar₀ ≼ tvar₁) ⊸ tvar₂) ⊸ tvar₂)))))\n\n≤-antisym : ∀ {α} (A : RSet α) t u → True (t ≤ u) → True (u ≤ t) → A t → A u\n≤-antisym A t u t≤u u≤t a with ≤-asym t u t≤u u≤t\n≤-antisym A t .t _ _ a | refl = a\n\n≤-case′ : ∀ {α} {A : Set α} {t u} → (t ≤? u) → (True (t ≤ u) → A) → (True (u ≤ t) → A) → A\n≤-case′ (leq t≤u) f g = f t≤u\n≤-case′ (geq u≤t) f g = g u≤t\n\n≤-case : ∀ {α} (A : Set α) t u → (True (t ≤ u) → A) → (True (u ≤ t) → A) → A\n≤-case A t u = ≤-case′ (≤-total t u)\n\nc⟦_⟧ : ∀ {Σ} {α} {T : Typ Σ (set α)} → \n Const T → (As : Σ⟦ Σ ⟧) → (T⟦ T ⟧ As)\nc⟦ pair ⟧ As = λ A B a b → (a , b)\nc⟦ fst ⟧ As = λ A B → proj₁\nc⟦ snd ⟧ As = λ A B → proj₂\nc⟦ ≼-refl ⟧ As = ≤-refl\nc⟦ ≼-trans ⟧ As = ≤-trans\nc⟦ ≼-antisym ⟧ As = ≤-antisym\nc⟦ ≼-case ⟧ As = ≤-case\n\nc⟦_⟧² : ∀ {Σ} {α} {T : Typ Σ (set α)} (c : Const T) → \n ∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) → \n (T⟦ T ⟧² ℜs (c⟦ c ⟧ As) (c⟦ c ⟧ Bs))\nc⟦ pair ⟧² ℜs = λ ℜ ℑ aℜb cℑd → (aℜb , cℑd)\nc⟦ fst ⟧² ℜs = λ ℜ ℑ → proj₁\nc⟦ snd ⟧² ℜs = λ ℜ ℑ → proj₂\nc⟦ ≼-refl ⟧² ℜs = _\nc⟦ ≼-trans ⟧² ℜs = _\nc⟦ ≼-antisym {α} ⟧² ℜs = lemma where\n lemma : ∀ {α} {A B : RSet α} (ℜ : rset α ∋ A ↔ B) → \n {t u : Time} → (t≡u : t ≡ u) → {v w : Time} → (v≡w : v ≡ w) →\n {t≤v : True (t ≤ v)} {u≤w : True (u ≤ w)} → ⊤ →\n {v≤t : True (v ≤ t)} {w≤u : True (w ≤ u)} → ⊤ →\n {a : A t} {b : B u} → ℜ t≡u a b →\n ℜ v≡w (≤-antisym A t v t≤v v≤t a) (≤-antisym B u w u≤w w≤u b)\n lemma ℜ {t} refl {v} refl {t≤v} {u≤w} tt {v≤t} {w≤u} tt aℜb \n with irrel (t ≤ v) t≤v u≤w | irrel (v ≤ t) v≤t w≤u\n lemma ℜ {t} refl {v} refl {t≤v} tt {v≤t} tt aℜb\n | refl | refl with ≤-asym t v t≤v v≤t\n lemma ℜ refl refl tt tt aℜb\n | refl | refl | refl = aℜb\nc⟦ ≼-case {α} ⟧² ℜs = lemma where\n lemma : ∀ {α} {A B : Set α} (ℜ : set α ∋ A ↔ B) →\n ∀ {t u : Time} → (t≡u : t ≡ u) → ∀ {v w : Time} → (v≡w : v ≡ w) → \n ∀ {f g} → (∀ {t≤v} {u≤w} → ⊤ → ℜ (f t≤v) (g u≤w)) →\n ∀ {h i} → (∀ {v≤t} {w≤u} → ⊤ → ℜ (h v≤t) (i w≤u)) →\n ℜ (≤-case A t v f h) (≤-case B u w g i)\n lemma ℜ {t} refl {v} refl {f} {g} fℜg {h} {i} hℜi = lemma′ (≤-total t v) where\n lemma′ : ∀ t≤?v → ℜ (≤-case′ t≤?v f h) (≤-case′ t≤?v g i)\n lemma′ (leq t≤v) = fℜg {t≤v} {t≤v} tt\n lemma′ (geq v≤t) = hℜi {v≤t} {v≤t} tt\n \n-- Expressions\n\ndata Exp {Σ : Kinds} (Γ : Typs Σ) : ∀ {α} → Typ Σ (set α) → Set where\n const : ∀ {α} {T : Typ Σ (set α)} → Const T → Exp Γ T\n abs : ∀ {α β} (T : Typ Σ (set α)) {U : Typ Σ (set β)} (M : Exp (T ∷ Γ) U) → Exp Γ (T ⊸ U)\n app : ∀ {α β} {T : Typ Σ (set α)} {U : Typ Σ (set β)} (M : Exp Γ (T ⊸ U)) (N : Exp Γ T) → Exp Γ U\n var : ∀ {α} {T : Typ Σ (set α)} → Var T Γ → Exp Γ T\n tabs : ∀ K {α} {T : Typ (K ∷ Σ) (set α)} (M : Exp (weakens (skip K id) Γ) T) → Exp Γ (Π K T)\n tapp : ∀ {K α} {T : Typ (K ∷ Σ) (set α)} → Exp Γ (Π K T) → ∀ U → Exp Γ (substn T U)\n eq : ∀ {α T U} → (set α ∋ T ≣ U) → (Exp Γ T) → (Exp Γ U)\n\nctxt : ∀ {Σ Γ α T} → Exp {Σ} Γ {α} T → Typs Σ\nctxt {Σ} {Γ} M = Γ\n\nM⟦_⟧ : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} → \n Exp Γ T → (As : Σ⟦ Σ ⟧) → (as : Γ⟦ Γ ⟧ As) → (T⟦ T ⟧ As)\nM⟦ const c ⟧ As as = c⟦ c ⟧ As\nM⟦ abs T M ⟧ As as = λ a → M⟦ M ⟧ As (a , as)\nM⟦ app M N ⟧ As as = M⟦ M ⟧ As as (M⟦ N ⟧ As as)\nM⟦ var x ⟧ As as = x⟦ x ⟧ As as\nM⟦ tabs K M ⟧ As as = λ A → \n M⟦ M ⟧ (A , As) (weakens⟦ ctxt (tabs K M) ⟧ (skip K id) (A , As) as)\nM⟦ tapp {T = T} M U ⟧ As as = \n cast (substn⟦ T ⟧⟦ U ⟧ As) (M⟦ M ⟧ As as (T⟦ U ⟧ As))\nM⟦ eq T≣U M ⟧ As as = cast (≣⟦ T≣U ⟧ As) (M⟦ M ⟧ As as)\n\nM⟦_⟧² : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} (M : Exp Γ T) → \n ∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) {as bs} → \n (Γ⟦ Γ ⟧² ℜs as bs) → (T⟦ T ⟧² ℜs (M⟦ M ⟧ As as) (M⟦ M ⟧ Bs bs))\nM⟦ const c ⟧² ℜs asℜbs = c⟦ c ⟧² ℜs\nM⟦ abs T M ⟧² ℜs asℜbs = λ aℜb → M⟦ M ⟧² ℜs (aℜb , asℜbs)\nM⟦ app M N ⟧² ℜs asℜbs = M⟦ M ⟧² ℜs asℜbs (M⟦ N ⟧² ℜs asℜbs)\nM⟦ var x ⟧² ℜs asℜbs = x⟦ x ⟧² ℜs asℜbs\nM⟦ tabs K M ⟧² ℜs asℜbs = λ ℜ → \n M⟦ M ⟧² (ℜ , ℜs) (weakens⟦ ctxt (tabs K M) ⟧² (skip K id) (ℜ , ℜs) asℜbs)\nM⟦ tapp {T = T} M U ⟧² ℜs asℜbs = \n struct-cast (T⟦ substn T U ⟧² ℜs) (substn⟦ T ⟧⟦ U ⟧ _) (substn⟦ T ⟧⟦ U ⟧ _)\n (cast² (substn⟦ T ⟧⟦ U ⟧² ℜs) (M⟦ M ⟧² ℜs asℜbs (T⟦ U ⟧² ℜs)))\nM⟦ eq {α} {T} {U} T≣U M ⟧² {As} {Bs} ℜs asℜbs = \n struct-cast (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ As) (≣⟦ T≣U ⟧ Bs) (cast² (≣⟦ T≣U ⟧² ℜs) (M⟦ M ⟧² ℜs asℜbs))\n\n-- Types with a chosen free world variable\n\n_∷ʳ_ : Kinds → Kind → Kinds\n[] ∷ʳ K = K ∷ []\n(T ∷ Σ) ∷ʳ K = T ∷ (Σ ∷ʳ K)\n\nTVar+ : Kind → Kinds → Set\nTVar+ K Σ = TVar K (Σ ∷ʳ rset₀)\n\nTyp+ : Kinds → Kind → Set\nTyp+ Σ = Typ (Σ ∷ʳ rset₀)\n\nwvar : ∀ Σ → TVar+ rset₀ Σ\nwvar [] = zero\nwvar (K ∷ Σ) = suc (wvar Σ)\n\nworld : ∀ {Σ} → Typ+ Σ rset₀\nworld {Σ} = var (wvar Σ)\n\nWorld : Time → Set\nWorld t = ⊤\n\ntaut : ∀ {Σ α} → Typ+ Σ (rset α ⇒ set α)\ntaut {Σ} {α} = abs (rset α) (Π time \n (app (world {time ∷ rset α ∷ Σ}) tvar₀ ⊸ app tvar₁ tvar₀))\n\n-- Surface types\n\ndata STyp : Kind → Set where\n ⟨_⟩ : ∀ {α} → STyp (set α) → STyp (rset α)\n [_] : ∀ {α} → STyp (rset α) → STyp (set α)\n _⊠_ _↦_ : ∀ {α β} → STyp (set α) → STyp (set β) → STyp (set (α ⊔ β))\n _∧_ _⇒_ : ∀ {α β} → STyp (rset α) → STyp (rset β) → STyp (rset (α ⊔ β))\n □ : ∀ {α} → STyp (rset α) → STyp (rset α)\n\n⟪_⟫ : ∀ {K} → STyp K → Typ+ [] K\n⟪ ⟨ T ⟩ ⟫ = app always ⟪ T ⟫\n⟪ [ T ] ⟫ = app (taut {[]}) ⟪ T ⟫\n⟪ T ⊠ U ⟫ = ⟪ T ⟫ ⊗ ⟪ U ⟫\n⟪ T ↦ U ⟫ = ⟪ T ⟫ ⊸ ⟪ U ⟫\n⟪ T ∧ U ⟫ = ⟪ T ⟫ ⊗ʳ ⟪ U ⟫\n⟪ T ⇒ U ⟫ = ⟪ T ⟫ ⊸ʳ ⟪ U ⟫\n⟪ □ T ⟫ = tvar₀ ⊵ ⟪ T ⟫\n\nT⟪_⟫ : ∀ {K} → STyp K → K⟦ K ⟧\nT⟪ T ⟫ = T⟦ ⟪ T ⟫ ⟧ (World , tt)\n\n-- Signals of T are iso to □ T\n\nSignal : ∀ {α} → RSet α → RSet α\nSignal A s = ∀ t → True (s ≤ t) → A t\n\nsig : ∀ {α} (T : STyp (rset α)) s → \n T⟪ □ T ⟫ s → Signal T⟪ T ⟫ s\nsig T s σ t s≤t = σ t s≤t _\n\nsig⁻¹ : ∀ {α} (T : STyp (rset α)) s → \n Signal T⟪ T ⟫ s → T⟪ □ T ⟫ s\nsig⁻¹ T s σ t s≤t _ = σ t s≤t\n\nsig-iso : ∀ {α} (T : STyp (rset α)) s σ → \n (sig T s (sig⁻¹ T s σ) ≡ σ)\nsig-iso T s σ = refl\n\nsig-iso⁻¹ : ∀ {α} (T : STyp (rset α)) s σ →\n (sig⁻¹ T s (sig T s σ) ≡ σ)\nsig-iso⁻¹ T s σ = refl\n\n-- Signal functions from T to U are iso to □ T ⇒ □ U\n\nSF : ∀ {α β} → RSet α → RSet β → RSet (α ⊔ β)\nSF A B s = Signal A s → Signal B s\n\nsf : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s →\n T⟪ □ T ⇒ □ U ⟫ s → SF T⟪ T ⟫ T⟪ U ⟫ s\nsf T U s f σ = sig U s (f (sig⁻¹ T s σ))\n\nsf⁻¹ : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s →\n SF T⟪ T ⟫ T⟪ U ⟫ s → T⟪ □ T ⇒ □ U ⟫ s\nsf⁻¹ T U s f σ = sig⁻¹ U s (f (sig T s σ))\n\nsf-iso : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s f → \n (sf T U s (sf⁻¹ T U s f) ≡ f)\nsf-iso T U s f = refl\n\nsf-iso⁻¹ : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s f → \n (sf⁻¹ T U s (sf T U s f) ≡ f)\nsf-iso⁻¹ T U s f = refl\n\n-- Causality\n\nmutual\n\n _at_⊨_≈[_]_ : ∀ {α} (T : STyp (rset α)) s → T⟪ T ⟫ s → Time → T⟪ T ⟫ s → Set α\n ⟨ T ⟩ at s ⊨ a ≈[ u ] b = T ⊨ a ≈[ u ] b\n (T ∧ U) at s ⊨ (a , b) ≈[ u ] (c , d) = (T at s ⊨ a ≈[ u ] c) × (U at s ⊨ b ≈[ u ] d)\n (T ⇒ U) at s ⊨ f ≈[ u ] g = ∀ a b → (T at s ⊨ a ≈[ u ] b) → (U at s ⊨ f a ≈[ u ] g b)\n □ T at s ⊨ σ ≈[ u ] τ = (∀ t s≤t → True (t ≤ u) → (T at t ⊨ σ t s≤t _ ≈[ u ] τ t s≤t _))\n\n _⊨_≈[_]_ : ∀ {α} → (T : STyp (set α)) → T⟪ T ⟫ → Time → T⟪ T ⟫ → Set α\n [ T ] ⊨ σ ≈[ u ] τ = ∀ s → True (s ≤ u) → (T at s ⊨ σ s _ ≈[ u ] τ s _)\n (T ⊠ U) ⊨ (a , b) ≈[ u ] (c , d) = (T ⊨ a ≈[ u ] c) × (U ⊨ b ≈[ u ] d)\n (T ↦ U) ⊨ f ≈[ u ] g = ∀ a b → (T ⊨ a ≈[ u ] b) → (U ⊨ f a ≈[ u ] g b)\n\nCausal : ∀ {α β} (T : STyp (set α)) (U : STyp (set β)) → T⟪ T ↦ U ⟫ → Set (α ⊔ β)\nCausal T U f = ∀ u σ τ → \n (T ⊨ σ ≈[ u ] τ) → (U ⊨ f σ ≈[ u ] f τ)\n\n-- Parametricity implies causality\n\nℜ[_] : Time → (rset o ∋ World ↔ World)\nℜ[ u ] {t} s≡t tt tt = True (t ≤ u)\n\nmutual\n\n ℜ-impl-≈_at : ∀ {α} (T : STyp (rset α)) s u → True (s ≤ u) → ∀ a b →\n (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) refl a b) → (T at s ⊨ a ≈[ u ] b)\n ℜ-impl-≈ ⟨ T ⟩ at s u s≤u a b aℜb\n = ℜ-impl-≈ T u a b aℜb\n ℜ-impl-≈ (T ∧ U) at s u s≤u (a , b) (c , d) (aℜc , bℜd) \n = (ℜ-impl-≈ T at s u s≤u a c aℜc , ℜ-impl-≈ U at s u s≤u b d bℜd)\n ℜ-impl-≈ (T ⇒ U) at s u s≤u f g fℜg\n = λ a b a≈b → ℜ-impl-≈ U at s u s≤u (f a) (g b) (fℜg (≈-impl-ℜ T at s u s≤u a b a≈b))\n ℜ-impl-≈_at (□ T) s u s≤u σ τ σℜτ = λ t s≤t t≤u → \n ℜ-impl-≈ T at t u t≤u (σ t s≤t _) (τ t s≤t _) \n (σℜτ refl tt (λ {r} _ _ {r≤t} _ → ≤-trans r t u r≤t t≤u))\n\n ≈-impl-ℜ_at : ∀ {α} (T : STyp (rset α)) s u → True (s ≤ u) → ∀ a b →\n (T at s ⊨ a ≈[ u ] b) → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) refl a b)\n ≈-impl-ℜ ⟨ T ⟩ at s u s≤u a b a≈b\n = ≈-impl-ℜ T u a b a≈b\n ≈-impl-ℜ (T ∧ U) at s u s≤u (a , b) (c , d) (a≈c , b≈d)\n = (≈-impl-ℜ T at s u s≤u a c a≈c , ≈-impl-ℜ U at s u s≤u b d b≈d)\n ≈-impl-ℜ (T ⇒ U) at s u s≤u f g f≈g\n = λ {a} {b} aℜb → ≈-impl-ℜ U at s u s≤u (f a) (g b) (f≈g a b (ℜ-impl-≈ T at s u s≤u a b aℜb))\n ≈-impl-ℜ (□ T) at s u s≤u σ τ σ≈τ = lemma where\n lemma : T⟦ ⟪ □ T ⟫ ⟧² (ℜ[ u ] , tt) {s} refl σ τ\n lemma {t} refl {s≤t} {s≤t′} tt kℜk′ with irrel (s ≤ t) s≤t s≤t′\n lemma {t} refl {s≤t} tt kℜk′ | refl\n = ≈-impl-ℜ T at t u t≤u (σ t s≤t _) (τ t s≤t _) (σ≈τ t s≤t t≤u) where\n t≤u = kℜk′ {t} refl {s≤t} {s≤t} tt {≤-refl t} {≤-refl t} tt\n\n ℜ-impl-≈ : ∀ {α} (T : STyp (set α)) (u : Time) (a b : T⟪ T ⟫) →\n (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) a b) → (T ⊨ a ≈[ u ] b)\n ℜ-impl-≈ (T ⊠ U) u (a , b) (c , d) (aℜc , bℜd)\n = (ℜ-impl-≈ T u a c aℜc , ℜ-impl-≈ U u b d bℜd)\n ℜ-impl-≈ (T ↦ U) u f g fℜg\n = λ a b a≈b → ℜ-impl-≈ U u (f a) (g b) (fℜg (≈-impl-ℜ T u a b a≈b))\n ℜ-impl-≈ [ T ] u σ τ σℜτ\n = λ s s≤u → ℜ-impl-≈ T at s u s≤u (σ s _) (τ s _) (σℜτ refl s≤u)\n\n ≈-impl-ℜ : ∀ {α} (T : STyp (set α)) (u : Time) (a b : T⟪ T ⟫) →\n (T ⊨ a ≈[ u ] b) → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) a b)\n ≈-impl-ℜ (T ⊠ U) u (a , b) (c , d) (a≈c , b≈d)\n = (≈-impl-ℜ T u a c a≈c , ≈-impl-ℜ U u b d b≈d)\n ≈-impl-ℜ (T ↦ U) u f g f≈g\n = λ {a} {b} aℜb → ≈-impl-ℜ U u (f a) (g b) (f≈g a b (ℜ-impl-≈ T u a b aℜb))\n ≈-impl-ℜ [ T ] u σ τ σ≈τ = lemma where\n lemma : T⟦ ⟪ [ T ] ⟫ ⟧² (ℜ[ u ] , tt) σ τ\n lemma {s} refl s≤u = ≈-impl-ℜ T at s u s≤u (σ s _) (τ s _) (σ≈τ s s≤u)\n\n-- Every F-omega function is causal\n\ncausality : ∀ {α β} (T : STyp (set α)) (U : STyp (set β)) (M : Exp [] ⟪ T ↦ U ⟫) → \n Causal T U (M⟦ M ⟧ (World , tt) tt)\ncausality T U M u\n = ℜ-impl-≈ (T ↦ U) u\n (M⟦ M ⟧ (World , tt) tt) \n (M⟦ M ⟧ (World , tt) tt) \n (M⟦ M ⟧² (ℜ[ u ] , _) tt)\n", "meta": {"hexsha": "3fb837cf23c0bc7bf7e37cf48d1152a487aa51bc", "size": 37421, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/agda/FRP/JS/Model.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/Model.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/Model.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": 37.1608738828, "max_line_length": 134, "alphanum_fraction": 0.4363592635, "num_tokens": 22276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214155, "lm_q2_score": 0.7154239836484144, "lm_q1q2_score": 0.5930427044500766}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.Group\nopen import lib.types.Lift\nopen import lib.groups.Homomorphism\nopen import lib.groups.Isomorphism\n\nmodule lib.groups.Lift where\n\nLift-group-structure : ∀ {i j} {A : Type i}\n → GroupStructure A → GroupStructure (Lift {j = j} A)\nLift-group-structure GS = record\n { ident = lift ident\n ; inv = λ {(lift x) → lift (inv x)}\n ; comp = λ {(lift x) (lift y) → lift (comp x y)}\n ; unit-l = λ {(lift y) → ap lift (unit-l y)}\n ; assoc = λ {(lift x) (lift y) (lift z) → ap lift (assoc x y z)}\n ; inv-l = λ {(lift x) → ap lift (inv-l x)}\n }\n where open GroupStructure GS\n\nLift-group : ∀ {i j} → Group i → Group (lmax i j)\nLift-group {j = j} G = group (Lift {j = j} El) (Lift-level El-level)\n (Lift-group-structure group-struct)\n where open Group G\n\nlift-hom : ∀ {i j} {G : Group i} → (G →ᴳ Lift-group {j = j} G)\nlift-hom = group-hom lift (λ _ _ → idp)\n\nlower-hom : ∀ {i j} {G : Group i} → (Lift-group {j = j} G →ᴳ G)\nlower-hom = group-hom lower (λ _ _ → idp)\n\nlift-iso : ∀ {i j} {G : Group i} → (G ≃ᴳ Lift-group {j = j} G)\nlift-iso = lift-hom , snd lift-equiv\n\nlower-iso : ∀ {i j} {G : Group i} → (Lift-group {j = j} G ≃ᴳ G)\nlower-iso = lower-hom , snd lower-equiv\n\nLift-group-is-abelian : ∀ {i j} (G : Group i) → is-abelian G → is-abelian (Lift-group {j = j} G)\nLift-group-is-abelian G comm (lift g₁) (lift g₂) = ap lift (comm g₁ g₂)\n\nLift-abgroup : ∀ {i j} (G : AbGroup i) → AbGroup (lmax i j)\nLift-abgroup {j = j} G = Lift-group {j = j} (AbGroup.grp G)\n , Lift-group-is-abelian (AbGroup.grp G) (AbGroup.comm G)\n", "meta": {"hexsha": "02e7ff7fa2f368c9bc5b109183c2a1b1a1e36627", "size": 1632, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/Lift.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/Lift.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/Lift.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": 35.4782608696, "max_line_length": 96, "alphanum_fraction": 0.6017156863, "num_tokens": 598, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267864276108, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.5930383441693531}} {"text": "-- Discrete category over a type A\n-- A must be an h-groupoid for the homs to be sets\n{-# OPTIONS --safe #-}\n\nmodule Cubical.Categories.Instances.Discrete where\n\nopen import Cubical.Categories.Category.Base\nopen import Cubical.Categories.Functor.Base\nopen import Cubical.Foundations.GroupoidLaws\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Transport\n\nprivate\n variable\n ℓ ℓC ℓC' : Level\n\nopen Category\n\n-- Discrete category\nDiscreteCategory : hGroupoid ℓ → Category ℓ ℓ\nDiscreteCategory A .ob = A .fst\nDiscreteCategory A .Hom[_,_] a a' = a ≡ a'\nDiscreteCategory A .id = refl\nDiscreteCategory A ._⋆_ = _∙_\nDiscreteCategory A .⋆IdL f = sym (lUnit f)\nDiscreteCategory A .⋆IdR f = sym (rUnit f)\nDiscreteCategory A .⋆Assoc f g h = sym (assoc f g h)\nDiscreteCategory A .isSetHom {x} {y} = A .snd x y\n\n\nmodule _ {A : hGroupoid ℓ}\n {C : Category ℓC ℓC'} where\n open Functor\n\n -- Functions f: A → ob C give functors F: DiscreteCategory A → C\n DiscFunc : (fst A → ob C) → Functor (DiscreteCategory A) C\n DiscFunc f .F-ob = f\n DiscFunc f .F-hom {x} p = subst (λ z → C [ f x , f z ]) p (id C)\n DiscFunc f .F-id {x} = substRefl {B = λ z → C [ f x , f z ]} (id C)\n\n -- Preserves composition\n DiscFunc f .F-seq {x} {y} p q =\n let open Category C using () renaming (_⋆_ to _●_) in\n\n let Hom[fx,f—] = (λ (w : A .fst) → C [ f x , f w ]) in\n let Hom[fy,f—] = (λ (w : A .fst) → C [ f y , f w ]) in\n let id-fx = id C {f x} in\n let id-fy = id C {f y} in\n let Fp = (subst Hom[fx,f—] (p) id-fx) in\n\n subst Hom[fx,f—] (p ∙ q) id-fx ≡⟨ substComposite Hom[fx,f—] _ _ _ ⟩\n subst Hom[fx,f—] (q) (Fp) ≡⟨ cong (subst _ q) (sym (⋆IdR C _)) ⟩\n subst Hom[fx,f—] (q) (Fp ● id-fy) ≡⟨ substCommSlice _ _ (λ _ → Fp ●_) q _ ⟩\n Fp ● (subst Hom[fy,f—] (q) id-fy) ∎\n", "meta": {"hexsha": "8fff2527cb891245511bb02b9b9e9c8fed84c862", "size": 1905, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/Discrete.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/Discrete.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/Discrete.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": 34.0178571429, "max_line_length": 89, "alphanum_fraction": 0.6104986877, "num_tokens": 707, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677737461008, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5929452200218325}} {"text": "module Structure.Category.Functor.Category where\n\nopen import Data.Tuple\nopen import Function.Equals\nimport Lvl\nopen import Logic\nopen import Logic.Predicate\nopen import Structure.Setoid\nopen import Structure.Category\nopen import Structure.Category.Functor\nopen import Structure.Category.NaturalTransformation\nopen import Structure.Category.NaturalTransformation.Equiv\nopen import Structure.Category.NaturalTransformation.NaturalTransformations\nopen import Structure.Categorical.Properties\nopen import Structure.Operator\nopen import Syntax.Transitivity\nopen import Type\n\nmodule _\n {ℓₗₒ ℓₗₘ ℓₗₑ ℓᵣₒ ℓᵣₘ ℓᵣₑ}\n {catₗ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ}}\n {catᵣ : CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ}}\n where\n\n open Category ⦃ … ⦄\n open Wrapped\n\n private open module MorphismEquivₗ {x}{y} = Equiv(CategoryObject.morphism-equiv catₗ {x}{y}) using ()\n private open module MorphismEquivᵣ {x}{y} = Equiv(CategoryObject.morphism-equiv catᵣ {x}{y}) using ()\n private instance _ = CategoryObject.category-instance catₗ\n private instance _ = CategoryObject.category-instance catᵣ\n\n -- Natural transformations are morphisms on functors.\n functorCategory : Category{Obj = catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} (_→ᴺᵀ_)\n Category._∘_ functorCategory = _∘ᴺᵀ_\n Category.id functorCategory = idᴺᵀ\n Dependent._⊜_.proof (BinaryOperator.congruence (Category.binaryOperator functorCategory) (Dependent.intro xy1) (Dependent.intro xy2)) = congruence₂(_∘_) xy1 xy2\n Dependent._⊜_.proof (Morphism.Associativity.proof (Category.associativity functorCategory)) = Morphism.associativity(_∘_)\n Dependent._⊜_.proof (Morphism.Identityₗ.proof (left (Category.identity functorCategory)) {F₁} {F₂} {ηᴺᵀ}) {x} =\n ∃.witness (idᴺᵀ ∘ᴺᵀ ηᴺᵀ)(x) 🝖[ _≡_ ]-[]\n ∃.witness(idᴺᵀ{F = F₂})(x) ∘ ∃.witness ηᴺᵀ(x) 🝖[ _≡_ ]-[]\n id ∘ ∃.witness ηᴺᵀ(x) 🝖[ _≡_ ]-[ Morphism.identityₗ(_∘_)(id) ]\n ∃.witness ηᴺᵀ(x) 🝖-end\n Dependent._⊜_.proof (Morphism.Identityᵣ.proof (right (Category.identity functorCategory)) {F₁} {F₂} {ηᴺᵀ}) {x} =\n ∃.witness (ηᴺᵀ ∘ᴺᵀ idᴺᵀ)(x) 🝖[ _≡_ ]-[]\n ∃.witness ηᴺᵀ(x) ∘ ∃.witness(idᴺᵀ{F = F₁})(x) 🝖[ _≡_ ]-[]\n ∃.witness ηᴺᵀ(x) ∘ id 🝖[ _≡_ ]-[ Morphism.identityᵣ(_∘_)(id) ]\n ∃.witness ηᴺᵀ(x) 🝖-end\n", "meta": {"hexsha": "bb11df88a02a842d632b50aedaec2e1d6a99b3c4", "size": 2327, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Category/Functor/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/Category/Functor/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/Category/Functor/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": 47.4897959184, "max_line_length": 162, "alphanum_fraction": 0.6850021487, "num_tokens": 915, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.5929451986464612}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Equivalence.Strong where\n\n-- Strong equivalence of categories. Same as ordinary equivalence in Cat.\n-- May not include everything we'd like to think of as equivalences, namely\n-- the full, faithful functors that are essentially surjective on objects.\n\nopen import Level\nopen import Relation.Binary using (IsEquivalence; module IsEquivalence)\nopen import Function using () renaming (_∘_ to _∙_)\n\nopen import Categories.Category\nopen import Categories.Functor hiding (equiv)\nopen import Categories.NaturalIsomorphism as NI hiding (equiv)\nopen import Categories.NaturalTransformation as NT hiding (id; equiv)\nopen import Categories.Morphisms using (Iso; module Iso)\n\nrecord WeakInverse {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F : Functor C D) (G : Functor D C) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n field\n F∘G≅id : NaturalIsomorphism (F ∘ G) id\n G∘F≅id : NaturalIsomorphism (G ∘ F) id\n F∘G⇒id = NaturalIsomorphism.F⇒G F∘G≅id\n id⇒F∘G = NaturalIsomorphism.F⇐G F∘G≅id\n G∘F⇒id = NaturalIsomorphism.F⇒G G∘F≅id\n id⇒G∘F = NaturalIsomorphism.F⇐G G∘F≅id\n .F∘G-iso : _\n F∘G-iso = NaturalIsomorphism.iso F∘G≅id\n .F∘G-isoˡ : _\n F∘G-isoˡ = λ x → Iso.isoˡ {C = D} (F∘G-iso x)\n .F∘G-isoʳ : _\n F∘G-isoʳ = λ x → Iso.isoʳ {C = D} (F∘G-iso x)\n .G∘F-iso : _\n G∘F-iso = NaturalIsomorphism.iso G∘F≅id\n .G∘F-isoˡ : _\n G∘F-isoˡ = λ x → Iso.isoˡ {C = C} (G∘F-iso x)\n .G∘F-isoʳ : _\n G∘F-isoʳ = λ x → Iso.isoʳ {C = C} (G∘F-iso x)\n\nrecord StrongEquivalence {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n field\n F : Functor C D\n G : Functor D C\n weak-inverse : WeakInverse F G\n open WeakInverse weak-inverse public\n\nmodule Equiv where\n refl : ∀ {o ℓ e} {C : Category o ℓ e} → StrongEquivalence C C\n refl = record\n { F = id\n ; G = id\n ; weak-inverse = record\n { F∘G≅id = IsEquivalence.refl NI.equiv\n ; G∘F≅id = IsEquivalence.refl NI.equiv\n }\n }\n\n sym : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → StrongEquivalence C D → StrongEquivalence D C\n sym Inv = record\n { F = Inv.G\n ; G = Inv.F\n ; weak-inverse = record\n { F∘G≅id = Inv.G∘F≅id\n ; G∘F≅id = Inv.F∘G≅id\n }\n }\n where\n module Inv = StrongEquivalence Inv\n\n trans : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃} {C₁ : Category o₁ ℓ₁ e₁} {C₂ : Category o₂ ℓ₂ e₂} {C₃ : Category o₃ ℓ₃ e₃} → StrongEquivalence C₁ C₂ → StrongEquivalence C₂ C₃ → StrongEquivalence C₁ C₃\n trans {C₁ = C₁} {C₂} {C₃} A B = record\n { F = B.F ∘ A.F\n ; G = A.G ∘ B.G\n ; weak-inverse = record\n { F∘G≅id = IsEquivalence.trans NI.equiv ((B.F ⓘˡ A.F∘G≅id) ⓘʳ B.G) B.F∘G≅id\n ; G∘F≅id = IsEquivalence.trans NI.equiv ((A.G ⓘˡ B.G∘F≅id) ⓘʳ A.F) A.G∘F≅id\n }\n }\n where\n module A = StrongEquivalence A\n module B = StrongEquivalence B\n\nequiv : ∀ {o ℓ e} → IsEquivalence (StrongEquivalence {o} {ℓ} {e})\nequiv = record { refl = Equiv.refl; sym = Equiv.sym; trans = Equiv.trans }\n", "meta": {"hexsha": "c6d12ebfa8e56550ef6ce9578a880b54b2a563f9", "size": 3037, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Equivalence/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/Equivalence/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/Equivalence/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": 36.1547619048, "max_line_length": 193, "alphanum_fraction": 0.6243002963, "num_tokens": 1269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519528170040852, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.5929236609022637}} {"text": "{-\nThis second-order signature was created from the following second-order syntax description:\n\nsyntax Empty | E\n\ntype\n 𝟘 : 0-ary\n\nterm\n abort : 𝟘 -> α\n\ntheory\n (𝟘η) e : 𝟘 c : α |> abort(e) = c\n-}\n\nmodule Empty.Signature where\n\nopen import SOAS.Context\n\n-- Type declaration\ndata ET : Set where\n 𝟘 : ET\n\n\n\nopen import SOAS.Syntax.Signature ET public\nopen import SOAS.Syntax.Build ET public\n\n-- Operator symbols\ndata Eₒ : Set where\n abortₒ : {α : ET} → Eₒ\n\n-- Term signature\nE:Sig : Signature Eₒ\nE:Sig = sig λ\n { (abortₒ {α}) → (⊢₀ 𝟘) ⟼₁ α\n }\n\nopen Signature E:Sig public\n", "meta": {"hexsha": "22c98666f8c3dc390041636fec687fbc9c552380", "size": 580, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Empty/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/Empty/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/Empty/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": 14.5, "max_line_length": 91, "alphanum_fraction": 0.6672413793, "num_tokens": 206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519528094861981, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5929236502975586}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nopen import Categories.Category\nopen import Categories.Object.BinaryProducts\nopen import Categories.Object.Exponentiating\n\nmodule Categories.Object.Exponentiating.Adjunction {o ℓ e}\n (C : Category o ℓ e)\n (binary : BinaryProducts C)\n (Σ : Category.Obj C)\n (exponentiating : Exponentiating C binary Σ) where\n\nopen Category C\nopen BinaryProducts binary\nopen Exponentiating exponentiating\n\nimport Categories.Object.Product\nopen Categories.Object.Product C\n\nimport Categories.Object.Product.Morphisms\nopen Categories.Object.Product.Morphisms C\n\nopen Equiv\nopen HomReasoning\n\nimport Categories.Object.Exponentiating.Functor\nopen Categories.Object.Exponentiating.Functor C binary Σ exponentiating\n\nopen import Categories.Functor\n using (Functor; Contravariant)\n renaming (id to idF; _≡_ to _≡F_; _∘_ to _∘F_)\n\nopen import Categories.Adjunction hiding (_≡_; id)\nopen import Categories.NaturalTransformation\n using (NaturalTransformation; module NaturalTransformation)\nopen import Categories.Monad\n using (Monad)\n\nΣ↑-Self-Adjunction : Adjunction (Functor.op Σ↑-Functor) Σ↑-Functor\nΣ↑-Self-Adjunction = record\n { unit = record\n { η = λ _ → flip id\n ; commute = unit-commute\n }\n ; counit = record\n { η = λ _ → flip id\n ; commute = counit-commute\n }\n ; zig = zig-zag\n ; zag = zig-zag\n } where\n .lem₁ : ∀{A B C D}{f : (B × C) ⇒ D}{g : A ⇒ (C × B)}\n → (f ∘ swap ∘ second id) ∘ g\n ≡ f ∘ swap ∘ g\n lem₁ {A}{B}{C}{D}{f}{g} =\n begin\n (f ∘ swap ∘ second id) ∘ g\n ↓⟨ (refl ⟩∘⟨ refl ⟩∘⟨ second-id product) ⟩∘⟨ refl ⟩\n (f ∘ swap ∘ id) ∘ g\n ↓⟨ (refl ⟩∘⟨ identityʳ) ⟩∘⟨ refl ⟩\n (f ∘ swap) ∘ g\n ↓⟨ assoc ⟩\n f ∘ swap ∘ g\n ∎\n \n .lem₂ : ∀ {X Y}{f : X ⇒ Y}\n → eval {Σ↑ Y} ∘ first (flip id ∘ f)\n ≡ eval {X} ∘ swap ∘ second [Σ↑ f ]\n lem₂ {X}{Y}{f} =\n begin\n eval {Σ↑ Y} ∘ first (flip id ∘ f)\n ↑⟨ refl ⟩∘⟨ first∘first ⟩\n eval {Σ↑ Y} ∘ first (flip id) ∘ first f\n ↑⟨ assoc ⟩\n (eval {Σ↑ Y} ∘ first (flip id)) ∘ first f\n ↓⟨ β ⟩∘⟨ refl ⟩\n (eval {Y} ∘ swap ∘ second id) ∘ first f\n ↓⟨ lem₁ ⟩\n eval {Y} ∘ swap ∘ first f\n ↓⟨ refl ⟩∘⟨ swap∘⁂ ⟩\n eval {Y} ∘ second f ∘ swap\n ↑⟨ assoc ⟩\n (eval {Y} ∘ second f) ∘ swap\n ↑⟨ β ⟩∘⟨ refl ⟩\n (eval {X} ∘ first (λ-abs X (eval {Y} ∘ second f))) ∘ swap\n ↓⟨ assoc ⟩\n eval {X} ∘ first (λ-abs X (eval {Y} ∘ second f)) ∘ swap\n ↑⟨ refl ⟩∘⟨ swap∘⁂ ⟩\n eval {X} ∘ swap ∘ second (λ-abs X (eval ∘ second f))\n ∎\n \n .unit-commute : ∀ {X Y} (f : X ⇒ Y)\n → flip id ∘ f ≡ [Σ² f ] ∘ flip id\n unit-commute {X}{Y} f =\n begin\n flip id ∘ f\n ↓⟨ λ-unique lem₂ ⟩\n flip [Σ↑ f ]\n ↑⟨ λ-cong lem₁ ⟩\n λ-abs (Σ↑ Y) ((eval {X} ∘ swap ∘ second id) ∘ second [Σ↑ f ])\n ↓⟨ λ-distrib ⟩\n [Σ↑ [Σ↑ f ] ] ∘ flip id\n ∎\n \n .counit-commute : ∀ {X Y} (f : X ⇒ Y)\n → [Σ² f ] ∘ flip id ≡ flip id ∘ f\n counit-commute f = sym (unit-commute f)\n \n .zig-zag : ∀{X}\n → id ≡ [Σ↑ flip id ] ∘ flip id\n zig-zag {X} =\n begin\n id\n ↑⟨ flip² ⟩\n flip (flip id)\n ↑⟨ λ-cong lem₁ ⟩\n λ-abs X ((eval ∘ swap ∘ second id) ∘ second (flip id))\n ↓⟨ λ-distrib ⟩\n [Σ↑ flip id ] ∘ flip id\n ∎\n", "meta": {"hexsha": "f8d51fff80869e07c8a5f48025e20f53c1b8ad57", "size": 3394, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Object/Exponentiating/Adjunction.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/Exponentiating/Adjunction.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/Exponentiating/Adjunction.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": 28.2833333333, "max_line_length": 71, "alphanum_fraction": 0.5332940483, "num_tokens": 1285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527906914788, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.5929236425897859}} {"text": "module Numeral.Natural.Decidable where\n\nopen import Data\nopen import Data.Boolean\nopen import Functional\nopen import Lang.Inspect\nopen import Logic.Propositional\nopen import Numeral.Natural\nopen import Structure.Function\nopen import Structure.Function.Domain\nopen import Structure.Relator.Properties\nopen import Type.Properties.Decidable\n\nmodule _ where\n open import Numeral.Natural.Oper.Comparisons\n open import Numeral.Natural.Oper.Proofs\n open import Relator.Equals\n open import Relator.Equals.Proofs.Equiv\n\n instance\n [≡?]-decider : Decider(2)(_≡_)(_≡?_)\n [≡?]-decider {𝟎} {𝟎} = true [≡]-intro\n [≡?]-decider {𝟎} {𝐒 y} = false \\()\n [≡?]-decider {𝐒 x} {𝟎} = false \\()\n [≡?]-decider {𝐒 x} {𝐒 y} with (x ≡? y) | [≡?]-decider {x} {y}\n ... | 𝑇 | true xy = true (congruence₁(𝐒) xy)\n ... | 𝐹 | false nxy = false (nxy ∘ injective(𝐒))\n\n zero?-decider : Decider(1)(_≡ 𝟎)(zero?)\n zero?-decider {𝟎} = true [≡]-intro\n zero?-decider {𝐒 x} = false \\()\n\nmodule _ where\n open import Numeral.Natural.Oper.Comparisons\n open import Numeral.Natural.Oper.Proofs\n open import Numeral.Natural.Oper.Divisibility\n open import Numeral.Natural.Oper.Modulo\n open import Numeral.Natural.Oper.Modulo.Proofs\n open import Numeral.Natural.Relation.Divisibility\n open import Numeral.Natural.Relation.Divisibility.Proofs\n open import Relator.Equals\n open import Relator.Equals.Proofs.Equiv\n\n instance\n [∣]-decider : Decider(2)(_∣_)(_∣₀?_)\n [∣]-decider {𝟎} {𝟎} = true Div𝟎\n [∣]-decider {𝟎} {𝐒 y} = false [0]-divides-not\n [∣]-decider {𝐒 x} {y} with y mod 𝐒(x) | inspect(\\x → y mod 𝐒(x)) x\n ... | 𝟎 | intro eq = true ([↔]-to-[→] mod-divisibility eq)\n ... | 𝐒 _ | intro eq = false ([𝐒]-not-0 ∘ transitivity(_≡_) (symmetry(_≡_) eq) ∘ [↔]-to-[←] mod-divisibility)\n\nmodule _ where\n open import Data.Boolean.Stmt\n open import Data.Boolean.Stmt.Proofs\n open import Data.List\n open import Data.List.Decidable as List\n open import Data.List.Equiv.Id\n open import Lang.Inspect\n open import Logic.Classical\n open import Logic.Predicate\n open import Numeral.Natural.LinearSearch\n open import Numeral.Natural.Oper.Divisibility\n open import Numeral.Natural.Prime\n open import Numeral.Natural.Prime.Proofs\n open import Numeral.Natural.Relation.Divisibility\n open import Numeral.Natural.Relation.Divisibility.Proofs\n open import Numeral.Natural.Relation.Order\n open import Numeral.Natural.Relation.Order.Classical\n open import Numeral.Natural.Relation.Order.Proofs\n open import Relator.Equals\n open import Relator.Equals.Proofs.Equiv\n open import Type.Properties.Decidable.Proofs\n open import Syntax.Implication.Dependent\n open import Syntax.Implication using (•_•_⇒₂-[_]_)\n\n -- A naive primality test using bruteforce.\n -- It checks if there are any divisors between 2 and p.\n -- Note: The performance and space should be terrible on this implementation because it checks whether the list of all divisors is empty.\n prime? : ℕ → Bool\n prime? 0 = 𝐹\n prime? 1 = 𝐹\n prime? n@(𝐒(𝐒 _)) = decide(2)(_≡_) ⦃ [∃]-intro _ ⦃ List.[≡]-decider ⦃ dec = [≡?]-decider ⦄ ⦄ ⦄ (findBoundedAll 2 n (_∣₀? n)) ∅\n\n instance\n Prime-decider : Decider(1)(Prime)(prime?)\n Prime-decider {𝟎} = false \\()\n Prime-decider {𝐒 𝟎} = false \\()\n Prime-decider {n@(𝐒(𝐒 x))} with prime? n | inspect prime? n\n ... | 𝑇 | intro eq = true $\n eq ⇒\n (prime? n ≡ 𝑇) ⇒-[ [↔]-to-[←] IsTrue.is-𝑇 ]\n IsTrue(prime? n) ⇒-[ [↔]-to-[←] (decider-true ⦃ List.[≡]-decider ⦃ dec = [≡?]-decider ⦄ ⦄) ]\n findBoundedAll 2 n (_∣₀? n) ≡ ∅ ⇒-[ (\\empty {_} → [↔]-to-[←] (findBoundedAll-emptyness{f = _∣₀? n}) empty) ]\n (∀{d} → (2 ≤ d) → (d < n) → IsFalse(d ∣₀? n)) ⇒-[ (\\p {i} → [↔]-to-[←] (decider-false ⦃ [∣]-decider ⦄) ∘₂ p) ]\n (∀{d} → (2 ≤ d) → (d < n) → ¬(d ∣ n)) ⇒-[]\n (∀{d} → (2 ≤ d) → (d < 𝐒(𝐒(x))) → ¬(d ∣ 𝐒(𝐒(x)))) ⇒-[ (\\p {d} div 2d dx → p{d} 2d (succ dx) div) ]\n (∀{d} → (d ∣ 𝐒(𝐒(x))) → (2 ≤ d) → ¬(d ≤ 𝐒(x))) ⇒-[ (\\p {d} div → [¬→]-disjunctive-formᵣ ⦃ decider-to-classical ⦃ [≡?]-decider ⦄ ⦄ \\ nd0 → antisymmetry(_≤_)(_≡_) ([≤]-without-[𝐒] (divides-upper-limit div)) (sub₂(_≯_)(_≤_) (p{𝐒 d} div (succ ([≢]-to-[<]-of-0ᵣ nd0))))) ]\n (∀{d} → (𝐒(d) ∣ 𝐒(𝐒(x))) → ((d ≡ 0) ∨ (d ≡ 𝐒(x)))) ⇒-[ intro ]\n Prime n ⇒-end\n ... | 𝐹 | intro eq = false \\p →\n • (\n p ⇒\n Prime(n) ⇒-[ prime-only-divisors ]\n (∀{d} → (d ∣ n) → ((d ≡ 1) ∨ (d ≡ n))) ⇒-[ (\\p {d} 2d dn div → [∨]-elim (\\{[≡]-intro → [≤][0]ᵣ-negation ([≤]-without-[𝐒] 2d)}) (\\{[≡]-intro → irreflexivity(_<_) dn}) (p div)) ]\n (∀{d} → (2 ≤ d) → (d < n) → ¬(d ∣ n)) ⇒-[ ((\\p {i} → [↔]-to-[→] (decider-false ⦃ [∣]-decider ⦄) ∘₂ p)) ]\n (∀{d} → (2 ≤ d) → (d < n) → IsFalse(d ∣₀? n)) ⇒-[ [↔]-to-[→] findBoundedAll-emptyness ]\n findBoundedAll 2 n (_∣₀? n) ≡ ∅ ⇒-[ [↔]-to-[→] (decider-true ⦃ List.[≡]-decider ⦃ dec = [≡?]-decider ⦄ ⦄) ]\n IsTrue(prime? n) ⇒-end\n )\n • (\n eq ⇒\n (prime? n ≡ 𝐹) ⇒-[ [↔]-to-[←] IsFalse.is-𝐹 ]\n IsFalse(prime? n) ⇒-end\n )\n ⇒₂-[ disjointness ]\n Empty ⇒-end\n\n import Data.Either as Either\n open import Data.List.Relation.Membership using (_∈_)\n open import Data.List.Relation.Membership.Proofs\n open import Data.Tuple as Tuple using (_⨯_ ; _,_)\n open import Logic.Propositional.Theorems\n open import Numeral.Natural.Oper\n open import Numeral.Natural.Oper.Proofs\n open import Numeral.Natural.Proofs\n open import Numeral.Natural.Relation.Order.Existence using ([≤]-equivalence)\n open import Structure.Function.Domain\n open import Structure.Operator\n open import Structure.Operator.Properties\n open import Syntax.Transitivity\n\n prime-composite-not : ∀{n} → Prime(n) → Composite(n) → ⊥\n prime-composite-not {.(𝐒(𝐒(a)) ⋅ 𝐒(𝐒(b)))} p (intro a b) =\n Either.map1\n (\\())\n ((\\()) ∘ cancellationₗ(_+_) {x = a} ∘ injective(𝐒) ∘ injective(𝐒))\n (prime-only-divisors p {𝐒(𝐒(a))} (divides-with-[⋅] {c = 𝐒(𝐒(b))} ([∨]-introₗ divides-reflexivity)))\n\n -- Using Numeral.Natural.Decidable.prime?, when it is false, there is a divisor d between 2 and n for n. This means that (d ∣ n). Equivalently ∃(k ↦ d ⋅ k ≡ n). The proof of Composite uses these d and k.\n prime-or-composite : ∀{n} → Prime(𝐒(𝐒(n))) ∨ Composite(𝐒(𝐒(n)))\n prime-or-composite{n} = [¬→]-disjunctive-formᵣ ⦃ decider-to-classical ⦃ Prime-decider ⦄ ⦄ $\n ¬ Prime(𝐒(𝐒(n))) ⇒-[ [↔]-to-[→] (decider-false ⦃ Prime-decider ⦄) ]\n IsFalse(prime? (𝐒(𝐒(n)))) ⇒-[ [↔]-to-[←] (decider-false ⦃ List.[≡]-decider ⦃ dec = [≡?]-decider ⦄ ⦄) ]\n findBoundedAll 2 (𝐒(𝐒(n))) (_∣₀? 𝐒(𝐒(n))) ≢ ∅ ⇒-[ non-empty-inclusion-existence ]\n ∃(_∈ findBoundedAll 2 (𝐒(𝐒(n))) (_∣₀? 𝐒(𝐒(n)))) ⇒-[ [∃]-map-proof ([↔]-to-[→] (findBoundedAll-membership {f = _∣₀? 𝐒(𝐒(n))})) ]\n ∃(d ↦ (2 ≤ d) ∧ (d < 𝐒(𝐒(n))) ∧ IsTrue(d ∣₀? 𝐒(𝐒(n)))) ⇒-[ [∃]-map-proof ([∧]-map id ([↔]-to-[←] (decider-true ⦃ [∣]-decider ⦄))) ]\n ∃(d ↦ (2 ≤ d) ∧ (d < 𝐒(𝐒(n))) ∧ (d ∣ 𝐒(𝐒(n)))) ⇒-[ (\\{([∃]-intro (𝐒 𝟎) ⦃ [∧]-intro ([∧]-intro (succ()) _) _ ⦄) ; ([∃]-intro (𝐒(𝐒 d)) ⦃ [∧]-intro ([∧]-intro d2 dn) div ⦄) → [∃]-intro d ⦃ [∧]-intro dn div ⦄}) ]\n ∃(d ↦ (𝐒(𝐒(d)) < 𝐒(𝐒(n))) ∧ (𝐒(𝐒(d)) ∣ 𝐒(𝐒(n)))) ⇒-[ (\\{([∃]-intro d ⦃ [∧]-intro dn div ⦄) → [∃]-intro d ⦃ [∧]-intro dn ([∃]-intro div ⦃ divides-quotient-correctness {yx = div} ⦄) ⦄}) ]\n ∃(d ↦ (𝐒(𝐒(d)) < 𝐒(𝐒(n))) ∧ ∃{Obj = 𝐒(𝐒(d)) ∣ 𝐒(𝐒(n))}(q ↦ (𝐒(𝐒(d)) ⋅ divides-quotient q ≡ 𝐒(𝐒(n))))) ⇒-[ (\\{([∃]-intro d ⦃ [∧]-intro dn ([∃]-intro q ⦃ prod ⦄) ⦄) → [∃]-intro (d , [∃]-witness ([↔]-to-[←] [≤]-equivalence (divides-quotient-composite (succ (succ min)) dn {q}))) ⦃ congruence₂ᵣ(_⋅_)(𝐒(𝐒(d))) (([∃]-proof ([↔]-to-[←] [≤]-equivalence (divides-quotient-composite (succ (succ min)) dn {q})))) 🝖 prod ⦄}) ]\n ∃{Obj = ℕ ⨯ ℕ}(\\(a , b) → (𝐒(𝐒(a)) ⋅ 𝐒(𝐒(b)) ≡ 𝐒(𝐒(n)))) ⇒-[ [↔]-to-[←] composite-existence ]\n Composite(𝐒(𝐒 n)) ⇒-end\n\n prime-xor-composite : ∀{n} → Prime(𝐒(𝐒(n))) ⊕ Composite(𝐒(𝐒(n)))\n prime-xor-composite {n} = [⊕]-or-not-both prime-or-composite (Tuple.uncurry prime-composite-not)\n\n open import Data.Tuple\n -- open import Numeral.Natural.Inductions\n {-# TERMINATING #-}\n -- TODO: Use strong induction. (a < n) because (a ⋅ b = n).\n prime-factor-existence : ∀{n} → ∃(PrimeFactor(𝐒(𝐒(n))))\n prime-factor-existence {n} with prime-or-composite{n}\n ... | Either.Left p = [∃]-intro (𝐒(𝐒(n))) ⦃ intro ⦃ p ⦄ ⦄\n ... | Either.Right c\n with [∃]-intro(a , b) ⦃ p ⦄ ← [↔]-to-[→] composite-existence c\n with [∃]-intro d ⦃ pa ⦄ ← prime-factor-existence{a}\n = [∃]-intro d ⦃ divisor-primeFactors ([↔]-to-[→] divides-[⋅]-existence ([∃]-intro (𝐒 (𝐒 b)) ⦃ p ⦄)) pa ⦄\n \n", "meta": {"hexsha": "b371d33f9a9e26b1b16306ebb4793d399e0a6256", "size": 9260, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/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": "Numeral/Natural/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": "Numeral/Natural/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": 55.119047619, "max_line_length": 418, "alphanum_fraction": 0.5379049676, "num_tokens": 3734, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527906914787, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5929236372172171}} {"text": "------------------------------------------------------------------------\n-- INCREMENTAL λ-CALCULUS\n--\n-- Postulate extensionality of functions.\n--\n-- Justification on Agda mailing list:\n-- http://permalink.gmane.org/gmane.comp.lang.agda/2343\n------------------------------------------------------------------------\n\nmodule Postulate.Extensionality where\n\n\nopen import Relation.Binary.PropositionalEquality\n\npostulate ext : ∀ {a b} → Extensionality a b\n\n-- Convenience of using extensionality 3 times in a row\n-- (using it twice in a row is moderately tolerable)\next³ : ∀\n {A : Set}\n {B : A → Set}\n {C : (a : A) → B a → Set }\n {D : (a : A) → (b : B a) → C a b → Set}\n {f g : (a : A) → (b : B a) → (c : C a b) → D a b c} →\n ((a : A) (b : B a) (c : C a b) → f a b c ≡ g a b c) → f ≡ g\n\next³ fabc=gabc = ext (λ a → ext (λ b → ext (λ c → fabc=gabc a b c)))\n", "meta": {"hexsha": "56069262c6c6cc86afd689294d1cd50213f696e5", "size": 858, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Postulate/Extensionality.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": "Postulate/Extensionality.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": "Postulate/Extensionality.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": 30.6428571429, "max_line_length": 72, "alphanum_fraction": 0.493006993, "num_tokens": 267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.5929236344607166}} {"text": "module Deriv where\n\nopen import Relation.Binary.Bundles using (DecSetoid)\nopen import Algebra.Bundles using (Semiring)\nopen import Level using (0ℓ)\nopen import Relation.Nullary using (yes; no)\n\nmodule _ (S : DecSetoid 0ℓ 0ℓ) (Targ : Set) where\n\n open DecSetoid S renaming (Carrier to Key)\n\n\n infixl 6 _+_\n infixl 7 _*_\n data Expr : Set where\n ↑ : Targ → Expr\n ! : Key → Expr\n _+_ : Expr → Expr → Expr\n _*_ : Expr → Expr → Expr\n \n\nmodule _ {S : DecSetoid 0ℓ 0ℓ} (R : Semiring 0ℓ 0ℓ) where\n\n private module S = DecSetoid S\n open S renaming (Carrier to Key)\n private module R = Semiring R\n open R using (0#; 1#) renaming (Carrier to Targ)\n\n eval\n : (lookup : Key → Targ)\n → (expr : Expr S Targ)\n → Targ\n eval lookup (↑ x) = x\n eval lookup (! x) = lookup x\n eval lookup (x + x₁) = eval lookup x₁ R.+ eval lookup x₁\n eval lookup (x * x₁) = eval lookup x₁ R.* eval lookup x₁\n\n\n deriv : Expr S Targ → Key → Expr S Targ\n deriv (↑ x) k = ↑ 0#\n deriv (! x) k with x ≟ k\n deriv (! x) k | yes _ = ↑ 1#\n deriv (! x) k | no _ = ↑ 0#\n deriv (e + e₁) k = deriv e k + deriv e₁ k\n deriv (e * e₁) k = (deriv e k * e₁) + (e * deriv e₁ k)\n\n\nopen import Data.Nat using (ℕ)\nopen import Data.Nat.Properties using (+-*-semiring)\nopen import Data.String\nopen import Relation.Binary.PropositionalEquality using (decSetoid)\n\nasdf : Expr (decSetoid _≟_) ℕ\nasdf = ↑ 2 + (↑ 5 * (! \"hello\" * ! \"goodbye\"))\n\nasdf' : Expr (decSetoid _≟_) ℕ\nasdf' = deriv +-*-semiring asdf \"hello\"\n\nnormalize : ∀ {D} → Expr D ℕ → Expr D ℕ\nnormalize (x + y) with normalize x | normalize y\nnormalize (x + y) | ↑ w | ↑ z = ↑ (w Data.Nat.+ z)\nnormalize (x + y) | ↑ 0 | z = z\nnormalize (x + y) | w | ↑ 0 = w\nnormalize (x + y) | w | z = w + z\nnormalize (x * y) with normalize x | normalize y\nnormalize (x * y) | ↑ w | ↑ z = ↑ (w Data.Nat.* z)\nnormalize (x * y) | ↑ 0 | z = ↑ 0\nnormalize (x * y) | w | ↑ 0 = ↑ 0\nnormalize (x * y) | ↑ 1 | z = z\nnormalize (x * y) | w | ↑ 1 = w\nnormalize (x * y) | w | z = w * z\nnormalize z = z\n\nmodule _ (R : Semiring 0ℓ 0ℓ) where\n open Semiring R\n private module R = Semiring R\n\n asdf'' : Carrier\n asdf'' = 1# R.+ 0#", "meta": {"hexsha": "cd4aeba472b17858c08a09a8683d46a004e02ff2", "size": 2159, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Deriv.agda", "max_stars_repo_name": "cspollard/diff", "max_stars_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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/Deriv.agda", "max_issues_repo_name": "cspollard/diff", "max_issues_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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/Deriv.agda", "max_forks_repo_name": "cspollard/diff", "max_forks_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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": 27.3291139241, "max_line_length": 67, "alphanum_fraction": 0.5882352941, "num_tokens": 807, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951104066295, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.5928616856053963}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.Unit.Polymorphic where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Relation.Nullary using (yes)\nopen import Cubical.Relation.Binary.Raw using (Decidable)\n\nimport Cubical.Data.Unit.Base as ⊤\n\n⊤ : {ℓ : Level} → Type ℓ\n⊤ = Lift ⊤.⊤\n\npattern tt = lift ⊤.tt\n\ninfix 4 _≟_\n\n_≟_ : {ℓ : Level} → Decidable {A = ⊤ {ℓ}} _≡_\n_ ≟ _ = yes refl\n\nisContr⊤ : {ℓ : Level} → isContr (⊤ {ℓ})\nisContr⊤ = tt , λ {tt → refl}\n\nisProp⊤ : {ℓ : Level} → isProp (⊤ {ℓ})\nisProp⊤ _ _ i = tt\n", "meta": {"hexsha": "b49ef480db266dd6e999989cec64c0be987a732f", "size": 585, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Unit/Polymorphic.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/Unit/Polymorphic.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/Unit/Polymorphic.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": 22.5, "max_line_length": 57, "alphanum_fraction": 0.6564102564, "num_tokens": 229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438951104066295, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.5928616803495025}} {"text": "-- Non-indexed (plain) monads in form of Kleisli triple, presented in point-free style.\n\nmodule Control.Comonad where\n\nopen import Function using (id) renaming (_∘′_ to _∘_)\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nopen import Axiom.FunctionExtensionality\nopen import Control.Functor\n\nrecord IsComonad (W : Set → Set) : Set₁ where\n\n -- Methods.\n\n field\n extract : ∀ {A } → W A → A\n extend : ∀ {A B} → (W A → B) → W A → W B\n\n -- Laws.\n\n field\n\n extend-β : ∀ {A B} {k : W A → B} →\n\n extract ∘ extend k ≡ k\n\n extend-η : ∀ {A} →\n\n extend {A = A} extract ≡ id\n\n extend-∘ : ∀ {A B C} {k : W A → B} {l : W B → C} →\n\n extend (l ∘ extend k) ≡ extend l ∘ extend k\n\n -- Comonadic composition.\n\n comComp : ∀ {A B C : Set} (l : W B → C) (k : W A → B) → (W A → C)\n comComp l k = l ∘ extend k\n\n -- Functoriality.\n\n isFunctor : IsFunctor W\n isFunctor = record\n { ops = record { map = map }\n ; laws = record { map-id = extend-η ; map-∘ = λ {A B C f g} → sym (map-∘-sym f g) }\n }\n where\n map : ∀ {A B} → (A → B) → W A → W B\n map f = extend (f ∘ extract)\n\n map-∘-sym : ∀ {A B C} (f : A → B) (g : B → C) → map g ∘ map f ≡ map (g ∘ f)\n map-∘-sym f g = begin\n map g ∘ map f ≡⟨⟩\n extend (g ∘ extract) ∘ extend (f ∘ extract) ≡⟨ sym extend-∘ ⟩\n extend (g ∘ extract ∘ extend (f ∘ extract)) ≡⟨ cong (λ z → extend (g ∘ z)) extend-β ⟩\n extend (g ∘ f ∘ extract) ≡⟨⟩\n map (g ∘ f) ∎\n\n open IsFunctor isFunctor public\n\n-- Monads in Kleisli Triple presentation.\n\nrecord Comonad : Set₁ where\n constructor comonad\n field\n W : Set → Set\n W! : IsComonad W\n\n open IsComonad W! public\n\n-- Casting a Comonad to a Functor\n\nFunctorOfComonad : Comonad → Functor\nFunctorOfComonad WW = functor W isFunctor\n where open Comonad WW\n", "meta": {"hexsha": "22a2e80c8608329a491c4aa3146cb5202e862d73", "size": 1919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Comonad.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/Comonad.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/Comonad.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.9220779221, "max_line_length": 94, "alphanum_fraction": 0.5377800938, "num_tokens": 691, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.843895106480586, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.5928616670795513}} {"text": "{-# OPTIONS --cubical #-}\nmodule _ where\n\n-- Test case by Ulf Norell, 16/09/2020\n\nopen import Agda.Primitive.Cubical renaming (primIMin to _∧_)\nopen import Agda.Builtin.Cubical.Path using (_≡_)\n\ndata Nat : Set where\n zero : Nat\n suc : Nat → Nat\n\nrecord Pos : Set where\n constructor 1+_\n field unpos : Nat\n\nopen Pos\n\nPos→Nat : Pos → Nat\nPos→Nat (1+ n) = suc n\n\nvariable\n A : Set\n x : A\n\nrefl : x ≡ x\nrefl {x = x} i = x\n\nid : Pos → Pos\nid n = n\n\n-- (i ∧ j) in the system caused a mishandling of de Bruijn indexes.\nfoo : (n : Pos) (i j : I) → Nat\nfoo n i j = primHComp\n (λ k → primPOr (i ∧ j) (i ∧ j)\n (λ _ → suc (n .unpos)) (λ _ → suc (n .unpos)))\n (suc (n .unpos))\n\n-- The test triggers normalization to make sure the `primHComp` in\n-- `foo` reduces properly.\n -- v foil syntactic equality check\ntest : ∀ n i j → foo n i j ≡ foo (id n) i j\ntest n i j = refl\n", "meta": {"hexsha": "61ed1704063efe3a2d8dc4c4903d6dac2b123560", "size": 966, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue4928.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/Issue4928.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/Issue4928.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.9545454545, "max_line_length": 75, "alphanum_fraction": 0.5548654244, "num_tokens": 328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503681, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.5928616585446272}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Equality where\n\nopen import Cubical.Core.Everything using (_≡_; Level; Type; Σ; _,_; fst; snd; _≃_; ~_)\nopen import Cubical.Foundations.Prelude using (refl; sym; cong; transport; subst; funExt; transp; I; i0; i1)\nopen import Cubical.Foundations.Function using (_∘_)\nopen import Cubical.Foundations.Univalence using (ua)\nopen import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract)\n\nopen import Data.Bool.Base using (Bool; true; false; _∧_)\nopen import Data.Nat.Base using (ℕ; zero; suc; _+_)\nopen import Data.Fin using (Fin; toℕ; fromℕ; #_; opposite) renaming (zero to fz; suc to fs)\nopen import Data.Product using (_×_; proj₁; proj₂)\n\n-- mutual recursion\ndata Γ : ℕ → Type\ndata U : {n : ℕ} → Γ n → Type\n\n-- context (snoc list of dependent types)\ndata Γ where\n ε : Γ 0\n _∙_ : {n : ℕ} → (γ : Γ n) → U γ → Γ (suc n)\n\ntail : {n : ℕ} → Γ (suc n) → Γ n\ntail (γ ∙ _) = γ\n\ndrop : {n : ℕ} → (k : ℕ) → Γ (k + n) → Γ n\ndrop zero γ = γ\ndrop (suc k) (γ ∙ x) = drop k γ\n\nhead : {n : ℕ} → (γ : Γ (suc n)) → U (tail γ)\nhead (_ ∙ A) = A\n\n-- lookup a type in a context at position k\nlookup : {n : ℕ} → (k : ℕ) → (γ : Γ (k + suc n)) → U (tail (drop k γ))\nlookup k γ = head (drop k γ)\n\n-- type universe\ndata U where\n nat : {n : ℕ} → {γ : Γ n} → U γ\n pi : {n : ℕ} → {γ : Γ n} → (A : U γ) → U (γ ∙ A) → U γ\n\ndata Term : {n : ℕ} → (γ : Γ n) → U γ → Type where\n-- v : {n : ℕ} → (k : ℕ) → {γ : Γ (k + suc n)} → {A : U (tail (drop k γ))} → Term (tail (drop k γ)) A\n v : {n : ℕ} → (k : ℕ) → {γ : Γ (k + suc n)} → {A : U (tail (drop k γ))} → Term (tail (drop k γ)) A\n tz : {n : ℕ} → {γ : Γ n} → Term γ nat -- zero\n ts : {n : ℕ} → {γ : Γ n} → Term γ nat → Term γ nat -- suc\n-- tn : (P : Term nat → U) → Term (P tz) → ((n : Term nat) → Term (P n) → Term (P (ts n))) → (n : Term nat) → Term (P n) -- natrec\n tλ : {n : ℕ} → {γ : Γ n} → {A : U γ} → {B : U (γ ∙ A)} → Term (γ ∙ A) B → Term γ (pi A B)\n ta : {n : ℕ} → {γ : Γ n} → {A : U γ} → {B : U (γ ∙ A)} → Term γ (pi A B) → Term γ A → Term (γ ∙ A) B\n\n--+1 : Term ε (pi nat nat)\n--+1 = tλ {!!} --(v {n = 0} 0)\n\ndata Eq : Type where\n eq : Eq -- equal\n ne : Eq -- not equal\n\ndata Maybe (a : Type) : Type where\n nothing : Maybe a\n just : a → Maybe a\n\nℕeq : ℕ → ℕ → Eq\nℕeq zero zero = eq\nℕeq zero (suc n) = ne\nℕeq (suc m) zero = ne\nℕeq (suc m) (suc n) = ℕeq m n\n\n\nnatrec : (P : ℕ → Type) → P 0 → ((n : ℕ) → P n → P (suc n)) → (n : ℕ) → P n\nnatrec P z s zero = z\nnatrec P z s (suc n) = s n (natrec P z s n)\n\n\n_+'_ : ℕ → ℕ → ℕ\n_+'_ = λ m → λ n → natrec (λ _ → ℕ) n (λ _ → suc) m\n\n0=0 : 0 ≡ 0\n0=0 = refl\n\nsuc=suc : (m n : ℕ) → m ≡ n → suc m ≡ suc n\nsuc=suc m n e = cong suc e\n\n0+n=n : (n : ℕ) → 0 + n ≡ n\n0+n=n = natrec (λ k → 0 + k ≡ k) 0=0 (λ n e → suc=suc n n e)\n\nn=0+n : (n : ℕ) → n + 0 ≡ n\nn=0+n = natrec (λ k → k + 0 ≡ k) 0=0 λ n e → suc=suc (n + 0) n e\n\n", "meta": {"hexsha": "ba470138ab8f5da7b668fb29a263293fcb52cc0f", "size": 2935, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Equality.agda", "max_stars_repo_name": "halfaya/Alae", "max_stars_repo_head_hexsha": "5b22f5cb073dc2508ad158959a096df7763c57c4", "max_stars_repo_licenses": ["MIT"], "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/Equality.agda", "max_issues_repo_name": "halfaya/Alae", "max_issues_repo_head_hexsha": "5b22f5cb073dc2508ad158959a096df7763c57c4", "max_issues_repo_licenses": ["MIT"], "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/Equality.agda", "max_forks_repo_name": "halfaya/Alae", "max_forks_repo_head_hexsha": "5b22f5cb073dc2508ad158959a096df7763c57c4", "max_forks_repo_licenses": ["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.2527472527, "max_line_length": 131, "alphanum_fraction": 0.5028960818, "num_tokens": 1260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503681, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.5928616585446271}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Math.FormalLanguage where\n\n-- agda-stdlib\nimport Algebra.FunctionProperties as FP\nimport Algebra.Structures as Structures\nopen import Level renaming (zero to lzero; suc to lsuc)\nopen import Data.List as L using (List; []; _++_)\nimport Data.List.Properties as Lₚ\nopen import Data.Nat hiding (_⊔_; _^_)\nopen import Data.Empty\nopen import Data.Product using (proj₁; proj₂; _,_; _×_; ∃₂; ∃)\nopen import Function using (_$_)\nimport Function as F\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary\nopen import Relation.Unary hiding (∅; {_})\nimport Relation.Unary as U\nimport Relation.Unary.Properties as Uₚ\n\n-- Equivalence of predicate\ninfix 4 _≡ᴾ_\n_≡ᴾ_ : ∀ {a l} {A : Set a} → Rel (Pred A l) (a ⊔ l)\n_≡ᴾ_ P Q = (P ⊆ Q) × (Q ⊆ P)\n\n≡ᴾ-refl : ∀ {a l} {A : Set a} → Reflexive {A = Pred A l} _≡ᴾ_\n≡ᴾ-refl = F.id , F.id\n\n≡ᴾ-sym : ∀ {a l} {A : Set a} → Symmetric {A = Pred A l} _≡ᴾ_\n≡ᴾ-sym = Data.Product.swap\n\n≡ᴾ-trans : ∀ {a l} {A : Set a} → Transitive {A = Pred A l} _≡ᴾ_\n≡ᴾ-trans P≡Q Q≡R = proj₁ Q≡R F.∘ proj₁ P≡Q , proj₂ P≡Q F.∘ proj₂ Q≡R\n\n≡ᴾ-isEquivalence : ∀ {a l} {A : Set a} → IsEquivalence {A = Pred A l} _≡ᴾ_\n≡ᴾ-isEquivalence = record\n { refl = ≡ᴾ-refl\n ; sym = ≡ᴾ-sym\n ; trans = ≡ᴾ-trans\n }\n\n≡ᴾ-setoid : ∀ {a l} {A : Set a} → Setoid _ _\n≡ᴾ-setoid {a} {l} {A} = record\n { Carrier = Pred A l\n ; _≈_ = _≡ᴾ_\n ; isEquivalence = ≡ᴾ-isEquivalence\n }\n\n∅ : ∀ {a l} {A : Set a} → Pred A l\n∅ {l = l} = λ _ → Lift l ⊥\n\n{_} : ∀ {a l} {A : Set a} → A → Pred A (a ⊔ l)\n{_}{l = l} x = λ y → Lift l (y ≡ x)\n\nLang : ∀ {s} → Set s → (l : Level) → Set _\nLang Σ l = Pred (List Σ) l\n\n-- TODO Move Math.FormalLanguage.Construct.EmptyLang\ndata EmptyLang {a l} {A : Set a} : Lang A (a ⊔ l) where\n mkEmptyLang : EmptyLang []\n\n-- TODO Move Math.FormalLanguage.Construct.Concat\n-- TODO Hetero\n-- Lang A l → Lang B l → Lang (A ⊎ B) l\n-- map inj₁ xs ++ map inj₂ ys\n-- concatenation of formal language\ndata _<>_ {a l} {A : Set a} (L₁ L₂ : Lang A l) : Lang A (a ⊔ l) where\n mk<> : ∀ {xs ys} → L₁ xs → L₂ ys → (L₁ <> L₂) (xs ++ ys)\n\n-- TODO Move Math.FormalLanguage.Construct.Concat.Properties\nmodule _ {s l} {Σ : Set s} where\n open FP {A = Lang Σ (s ⊔ l)} _≡ᴾ_\n\n <>-identityˡ : LeftIdentity (EmptyLang {l = l}) _<>_\n <>-identityˡ L = to , from\n where\n to : EmptyLang <> L ⊆ L\n to (mk<> mkEmptyLang x₁) = x₁\n from : L ⊆ EmptyLang <> L\n from Lx = mk<> mkEmptyLang Lx\n\n <>-identityʳ : RightIdentity (EmptyLang {l = l}) _<>_\n <>-identityʳ L = to , from\n where\n to : L <> EmptyLang ⊆ L\n to (mk<> Lx mkEmptyLang) = subst L (sym $ Lₚ.++-identityʳ _) Lx\n from : L ⊆ L <> EmptyLang\n from {xs} x = subst (L <> EmptyLang) (Lₚ.++-identityʳ xs) $\n mk<> {xs = xs} {ys = []} x mkEmptyLang\n\n{- TODO move contents of agda-combinatorics to agda-misc\n <>-dec : ∀ {L₁ L₂ : Lang Σ l} →\n U.Decidable L₁ → U.Decidable L₂ → U.Decidable (L₁ <> L₂)\n <>-dec L₁? L₂? zs with L.filter (L₁? Uₚ.×? L₂?) (splits₂ zs)\n ... | x = ?\n-}\n", "meta": {"hexsha": "20fff9337a60567cf4b67a8ee1e2e04698842c2f", "size": 3015, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Math/FormalLanguage.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": "Math/FormalLanguage.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": "Math/FormalLanguage.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": 30.7653061224, "max_line_length": 74, "alphanum_fraction": 0.5936981758, "num_tokens": 1247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339797047029, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5926716650448511}} {"text": "-- Classical propositional logic, de Bruijn approach, final encoding\n\nmodule Bf.Cp 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 Cp where\n record Tm (tr : TmRepr) : Set1 where\n infixr 0 abort=>_\n field\n abort=>_ : forall {tc a} -> tr (tc , NOT a) 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 Cp public\n", "meta": {"hexsha": "d20f798668c962669016096bdbe890cf2daf9d7f", "size": 2232, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Bf/Cp.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/Cp.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/Cp.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.7446808511, "max_line_length": 94, "alphanum_fraction": 0.4811827957, "num_tokens": 826, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.839733955639775, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.5926716428634689}} {"text": "{-\n\nAn experiment of transporting rev-++-distr from lists to lists where\nthe arguments to cons have been flipped inspired by section 2 of\nhttps://arxiv.org/abs/2010.00774\n\nNote that Agda doesn't care about the order of constructors so we\ncan't do exactly the same example.\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Experiments.List where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.Data.Sigma\n\ninfixr 5 _∷_\ninfixl 5 _∷'_\ninfixr 5 _++_\n\n-- Normal lists\ndata List (A : Type) : Type where\n [] : List A\n _∷_ : (x : A) (xs : List A) → List A\n\n-- Lists where the arguments to cons have been flipped\ndata List' (A : Type) : Type where\n [] : List' A\n _∷'_ : (xs : List' A) (x : A) → List' A\n\nvariable\n A : Type\n\n\n-- Some operations and properties for List\n\n_++_ : List A → List A → List A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ xs ++ ys\n\nrev : List A → List A\nrev [] = []\nrev (x ∷ xs) = rev xs ++ (x ∷ [])\n\n++-unit-r : (xs : List A) → xs ++ [] ≡ xs\n++-unit-r [] = refl\n++-unit-r (x ∷ xs) = cong (_∷_ x) (++-unit-r xs)\n\n++-assoc : (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs\n++-assoc [] ys zs = refl\n++-assoc (x ∷ xs) ys zs = cong (_∷_ x) (++-assoc xs ys zs)\n\nrev-++-distr : (xs ys : List A) → rev (xs ++ ys) ≡ rev ys ++ rev xs\nrev-++-distr [] ys = sym (++-unit-r (rev ys))\nrev-++-distr (x ∷ xs) ys = cong (_++ _) (rev-++-distr xs ys) ∙ ++-assoc (rev ys) (rev xs) (x ∷ [])\n\n\n\n-- We now want to transport this to List'. For this we first establish\n-- an isomorphism of the types.\n\ntoList' : List A → List' A\ntoList' [] = []\ntoList' (x ∷ xs) = toList' xs ∷' x\n\nfromList' : List' A → List A\nfromList' [] = []\nfromList' (xs ∷' x) = x ∷ fromList' xs\n\ntoFrom : (xs : List' A) → toList' (fromList' xs) ≡ xs\ntoFrom [] = refl\ntoFrom (xs ∷' x) i = toFrom xs i ∷' x\n\nfromTo : (xs : List A) → fromList' (toList' xs) ≡ xs\nfromTo [] = refl\nfromTo (x ∷ xs) i = x ∷ fromTo xs i\n\nListIso : Iso (List A) (List' A)\nListIso = iso toList' fromList' toFrom fromTo\n\nListEquiv : List A ≃ List' A\nListEquiv = isoToEquiv ListIso\n\n-- We then use univalence to turn this into a path\nListPath : (A : Type) → List A ≡ List' A\nListPath A = isoToPath (ListIso {A = A})\n\n\n-- We can now use this path to transport the operations and properties\n-- from List to List'\nmodule transport where\n\n -- First make a suitable Σ-type packaging what we need for the\n -- transport (note that _++_ and rev here are part of the Σ-type).\n -- It should be possible to automatically generate this given a module/file.\n T : Type → Type\n T X = Σ[ _++_ ∈ (X → X → X) ] Σ[ rev ∈ (X → X) ] ((xs ys : X) → rev (xs ++ ys) ≡ rev ys ++ rev xs)\n\n -- We can now transport the instance of T for List to List'\n T-List' : T (List' A)\n T-List' {A = A} = transport (λ i → T (ListPath A i)) (_++_ , rev , rev-++-distr)\n\n -- Getting the operations and property for List' is then just a matter of projecting them out\n _++'_ : List' A → List' A → List' A\n _++'_ = T-List' .fst\n\n rev' : List' A → List' A\n rev' = T-List' .snd .fst\n\n rev-++-distr' : (xs ys : List' A) → rev' (xs ++' ys) ≡ rev' ys ++' rev' xs\n rev-++-distr' = T-List' .snd .snd\n\n\n-- To connect this with the Cubical Agda paper consider the following\n-- (painfully) manual transport. This is really what the above code\n-- unfolds to.\nmodule manualtransport where\n\n _++'_ : List' A → List' A → List' A\n _++'_ {A = A} = transport (λ i → ListPath A i → ListPath A i → ListPath A i) _++_\n\n rev' : List' A → List' A\n rev' {A = A} = transport (λ i → ListPath A i → ListPath A i) rev\n\n rev-++-distr' : (xs ys : List' A) → rev' (xs ++' ys) ≡ rev' ys ++' rev' xs\n rev-++-distr' {A = A} = transport (λ i → (xs ys : ListPath A i)\n → revP i (appP i xs ys) ≡ appP i (revP i ys) (revP i xs))\n rev-++-distr\n where\n appP : PathP (λ i → ListPath A i → ListPath A i → ListPath A i) _++_ _++'_\n appP i = transp (λ j → ListPath A (i ∧ j) → ListPath A (i ∧ j) → ListPath A (i ∧ j)) (~ i) _++_\n\n revP : PathP (λ i → ListPath A i → ListPath A i) rev rev'\n revP i = transp (λ j → ListPath A (i ∧ j) → ListPath A (i ∧ j)) (~ i) rev\n\n\n\n-- The above operations for List' are derived by going back and\n-- forth. With the SIP we can do better and transport properties for\n-- user defined operations (assuming that the operations are\n-- well-defined wrt to the forward direction of the equivalence).\nopen import Cubical.Foundations.SIP\nopen import Cubical.Structures.Axioms\nopen import Cubical.Structures.Product\nopen import Cubical.Structures.Pointed\nopen import Cubical.Structures.Function\n\n\n-- For illustrative purposes we first apply the SIP manually. This\n-- requires quite a bit of boilerplate code which is automated in the\n-- next module.\nmodule manualSIP (A : Type) where\n\n -- First define the raw structure without axioms. This is just the\n -- signature of _++_ and rev.\n RawStruct : Type → Type\n RawStruct X = (X → X → X) × (X → X)\n\n -- Some boilerplate code which can be automated\n e1 : StrEquiv (λ x → x → x → x) ℓ-zero\n e1 = FunctionEquivStr+ pointedEquivAction\n (FunctionEquivStr+ pointedEquivAction PointedEquivStr)\n\n e2 : StrEquiv (λ x → x → x) ℓ-zero\n e2 = FunctionEquivStr+ pointedEquivAction PointedEquivStr\n\n RawEquivStr : StrEquiv RawStruct _\n RawEquivStr = ProductEquivStr e1 e2\n\n rawUnivalentStr : UnivalentStr _ RawEquivStr\n rawUnivalentStr = productUnivalentStr e1 he1 e2 he2\n where\n he2 : UnivalentStr (λ z → z → z) e2\n he2 = functionUnivalentStr+ pointedEquivAction pointedTransportStr\n PointedEquivStr pointedUnivalentStr\n\n he1 : UnivalentStr (λ z → z → z → z) e1\n he1 = functionUnivalentStr+ pointedEquivAction pointedTransportStr e2 he2\n\n -- Now the property that we want to transport\n P : (X : Type) → RawStruct X → Type\n P X (_++_ , rev) = ((xs ys : X) → rev (xs ++ ys) ≡ rev ys ++ rev xs)\n\n -- Package things up for List\n List-Struct : Σ[ X ∈ Type ] (Σ[ s ∈ RawStruct X ] (P X s))\n List-Struct = List A , (_++_ , rev) , rev-++-distr\n\n\n -- We now give direct definitions of ++' and rev' for List'\n _++'_ : List' A → List' A → List' A\n [] ++' ys = ys\n (xs ∷' x) ++' ys = (xs ++' ys) ∷' x\n\n rev' : List' A → List' A\n rev' [] = []\n rev' (xs ∷' x) = rev' xs ++' ([] ∷' x)\n\n -- We then package this up into a raw structure on List'\n List'-RawStruct : Σ[ X ∈ Type ] (RawStruct X)\n List'-RawStruct = List' A , (_++'_ , rev')\n\n -- Finally we prove that toList' commutes with _++_ and rev. Note\n -- that this could be a lot more complex, see for example the Matrix\n -- example (Cubical.Algebra.Matrix).\n toList'-++ : (xs ys : List A) → toList' (xs ++ ys) ≡ toList' xs ++' toList' ys\n toList'-++ [] ys = refl\n toList'-++ (x ∷ xs) ys i = toList'-++ xs ys i ∷' x\n\n toList'-rev : (xs : List A) → toList' (rev xs) ≡ rev' (toList' xs)\n toList'-rev [] = refl\n toList'-rev (x ∷ xs) = toList'-++ (rev xs) (x ∷ []) ∙ cong (_++' ([] ∷' x)) (toList'-rev xs)\n\n -- We can now get the property for ++' and rev' via the SIP\n rev-++-distr' : (xs ys : List' A) → rev' (xs ++' ys) ≡ rev' ys ++' rev' xs\n rev-++-distr' = transferAxioms rawUnivalentStr List-Struct List'-RawStruct\n (ListEquiv , toList'-++ , toList'-rev)\n\n -- Note that rev-++-distr' is really talking about the direct\n -- definitions of ++' and rev', not the transported operations as in\n -- the previous attempt.\n\n\n\n-- We now automate parts of the above construction\nopen import Cubical.Structures.Auto\n\nmodule SIP-auto (A : Type) where\n\n -- First define the raw structure without axioms. This is just the\n -- signature of _++_ and rev.\n RawStruct : Type → Type\n RawStruct X = (X → X → X) × (X → X)\n\n -- Some automated SIP magic\n RawEquivStr : _\n RawEquivStr = AutoEquivStr RawStruct\n\n rawUnivalentStr : UnivalentStr _ RawEquivStr\n rawUnivalentStr = autoUnivalentStr RawStruct\n\n -- Now the property that we want to transport\n P : (X : Type) → RawStruct X → Type\n P X (_++_ , rev) = ((xs ys : X) → rev (xs ++ ys) ≡ rev ys ++ rev xs)\n\n -- Package things up for List\n List-Struct : Σ[ X ∈ Type ] (Σ[ s ∈ RawStruct X ] (P X s))\n List-Struct = List A , (_++_ , rev) , rev-++-distr\n\n\n -- We now give direct definitions of ++' and rev' for List'\n _++'_ : List' A → List' A → List' A\n [] ++' ys = ys\n (xs ∷' x) ++' ys = (xs ++' ys) ∷' x\n\n rev' : List' A → List' A\n rev' [] = []\n rev' (xs ∷' x) = rev' xs ++' ([] ∷' x)\n\n -- We then package this up into a raw structure on List'\n List'-RawStruct : Σ[ X ∈ Type ] (RawStruct X)\n List'-RawStruct = List' A , (_++'_ , rev')\n\n -- Finally we prove that toList' commutes with _++_ and rev. Note\n -- that this could be a lot more complex, see for example the Matrix\n -- example (Cubical.Algebra.Matrix).\n toList'-++ : (xs ys : List A) → toList' (xs ++ ys) ≡ toList' xs ++' toList' ys\n toList'-++ [] ys = refl\n toList'-++ (x ∷ xs) ys i = toList'-++ xs ys i ∷' x\n\n toList'-rev : (xs : List A) → toList' (rev xs) ≡ rev' (toList' xs)\n toList'-rev [] = refl\n toList'-rev (x ∷ xs) = toList'-++ (rev xs) (x ∷ []) ∙ cong (_++' ([] ∷' x)) (toList'-rev xs)\n\n -- We can now get the property for ++' and rev' via the SIP\n rev-++-distr' : (xs ys : List' A) → rev' (xs ++' ys) ≡ rev' ys ++' rev' xs\n rev-++-distr' = transferAxioms rawUnivalentStr List-Struct List'-RawStruct\n (ListEquiv , toList'-++ , toList'-rev)\n\n -- Note that rev-++-distr' is really talking about the direct\n -- definitions of ++' and rev', not the transported operations as in\n -- the previous attempt.\n", "meta": {"hexsha": "5cd54deba3c3ee3306d64f16eb1ca6f79579f978", "size": 9766, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Experiments/List.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/Experiments/List.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/Experiments/List.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": 34.1468531469, "max_line_length": 100, "alphanum_fraction": 0.6041368011, "num_tokens": 3320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.5926517034707731}} {"text": "{-\n\nThis file proves the higher groupoid structure of types\nfor homogeneous and heterogeneous paths\n\n-}\n{-# OPTIONS --cubical --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 : 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\nlCancel : (p : x ≡ y) → p ⁻¹ ∙ p ≡ refl\nlCancel p = rCancel (p ⁻¹)\n\n-- The filler of the three-out-of-four identification: 3outof4-filler α p β =\n-- PathP (λ i → PathP (λ j → PathP (λ k → A) (α i i0) (α i i1))\n-- (λ j → α i j) (λ j → β i j)) (λ j i → α i0 i) (3outof4 α p β)\n\n3outof4-filler : (α : I → I → A) → (p : α i1 i0 ≡ α i1 i1) →\n (β : PathP (λ j → Path A (α j i0) (α j i1)) (λ i → α i0 i) p) → I → I → I → A\n3outof4-filler α p β k j i =\n hfill (λ k → λ { (i = i0) → α k i0\n ; (i = i1) → α k i1\n ; (j = i0) → α k i\n ; (j = i1) → β k i\n }) (inS (α i0 i)) k\n\n3outof4 : (α : I → I → A) → (p : α i1 i0 ≡ α i1 i1) →\n (β : PathP (λ j → Path A (α j i0) (α j i1)) (λ i → α i0 i) p) → (λ i → α i1 i) ≡ p\n3outof4 α p β j i = 3outof4-filler α p β i1 j i\n\n-- The filler of the pre-associative square: preassoc p q r =\n-- PathP (λ i → PathP (λ j → PathP (λ k → A) x (compPath-filler q r i j))\n-- (refl i) (λ j → compPath-filler (p ∙ q) r i j)) (λ j i → compPath-filler p q j i) (preassoc p q r)\n\npreassoc-filler : {x y z w : A} (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) → I → I → I → A\npreassoc-filler {x = x} p q r k j i =\n hfill (λ k → λ { (i = i0) → x\n ; (i = i1) → compPath-filler q r k j\n ; (j = i0) → p i\n -- ; (j = i1) → compPath-filler (p ∙ q) r k i\n }) (inS (compPath-filler p q j i)) k\n\npreassoc : (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) →\n PathP (λ j → Path A x ((q ∙ r) j)) p ((p ∙ q) ∙ r)\npreassoc {x = x} p q r j i = preassoc-filler p q r i1 j i\n\nassoc : (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) →\n p ∙ q ∙ r ≡ (p ∙ q) ∙ r\nassoc p q r = 3outof4 (compPath-filler p (q ∙ r)) ((p ∙ q) ∙ r) (preassoc p q r)\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 i j\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\n3outof4P : {A : I → I → Type ℓ} {P : (A i0 i1) ≡ (A i1 i1)}\n {B : PathP (λ j → Path (Type ℓ) (A i0 j) (A i1 j)) (λ i → A i i0) P}\n (α : ∀ (i j : I) → A j i)\n (p : PathP (λ i → P i) (α i1 i0) (α i1 i1)) →\n (β : PathP (λ j → PathP (λ i → B j i) (α j i0) (α j i1)) (λ i → α i0 i) p) →\n PathP (λ j → PathP (λ i → 3outof4 (λ j i → A i j) P B j i) (α i1 i0) (α i1 i1)) (λ i → α i1 i) p\n3outof4P {A = A} {P} {B} α p β j i =\n comp (λ k → 3outof4-filler (λ j i → A i j) P B k j i)\n (λ k → λ { (i = i0) → α k i0\n ; (i = i1) → α k i1\n ; (j = i0) → α k i\n ; (j = i1) → β k i\n }) (α i0 i)\n\npreassocP : {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 → preassoc (λ i → A i) B C j i) x ((compPathP q r) j)) p (compPathP (compPathP p q) r)\npreassocP {A = A} {x = x} {B = B} {C = C} p q r j i =\n comp (λ k → preassoc-filler (λ i → A i) B C k j i)\n (λ k → λ { (i = i0) → x\n ; (i = i1) → compPathP-filler q r j k\n ; (j = i0) → p i\n -- ; (j = i1) → compPathP-filler (compPathP p q) r i k\n }) (compPathP-filler p q i j)\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 p q r =\n 3outof4P (λ i j → compPathP-filler p (compPathP q r) j i) (compPathP (compPathP p q) r) (preassocP p q r)\n\n\n\n-- Loic's code below\n\n\n-- simultaneaous composition on both sides of a path\n\ndoubleCompPath-filler : {ℓ : Level} {A : Type ℓ} {w x y z : A} → w ≡ x → x ≡ y → y ≡ z →\n I → I → A\ndoubleCompPath-filler p q r i =\n hfill (λ t → λ { (i = i0) → p (~ t)\n ; (i = i1) → r t })\n (inS (q i))\n\ndoubleCompPath : {ℓ : Level} {A : Type ℓ} {w x y z : A} → w ≡ x → x ≡ y → y ≡ z → w ≡ z\ndoubleCompPath p q r i = doubleCompPath-filler p q r i i1\n\n_∙∙_∙∙_ : {ℓ : Level} {A : Type ℓ} {w x y z : A} → w ≡ x → x ≡ y → y ≡ z → w ≡ z\np ∙∙ q ∙∙ r = doubleCompPath p q r\n\n-- some exchange law for doubleCompPath and refl\n\nrhombus-filler : {ℓ : Level} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → I → I → A\nrhombus-filler p q i j =\n hcomp (λ t → λ { (i = i0) → p (~ t ∨ j)\n ; (i = i1) → q (t ∧ j)\n ; (j = i0) → p (~ t ∨ i)\n ; (j = i1) → q (t ∧ i) })\n (p i1)\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 (rhombus-filler p q 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 i j =\n hcomp (λ t → λ { (j = i0) → p (~ i ∧ ~ t)\n ; (j = 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 i j =\n hcomp (λ t → λ { (j = i0) → p (~ t)\n ; (j = i1) → r (i ∨ 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-- deducing associativity for compPath\n\n-- assoc : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) →\n-- (p ∙ q) ∙ r ≡ p ∙ (q ∙ r)\n-- assoc p q r = (sym (doubleCompPath-elim p q r)) ∙ (doubleCompPath-elim' p q r)\n\nhcomp-unique : ∀ {ℓ} {A : Set ℓ} {φ} → (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 : Set ℓ} {φ} → (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' : Set ℓ}\n (A : (i : I) → Set ℓ [ φ ↦ (λ _ → A') ]) (let B = \\ (i : I) → outS (A i))\n → ∀ {ψ} (u : I → Partial ψ (B i0)) → (u0 : B i0 [ ψ ↦ u i0 ]) →\n (transp B φ (hcomp u (outS u0)) ≡ hcomp (\\ i o → transp B φ (u i o)) (transp B φ (outS u0)))\n [ ψ ↦ (\\ { (ψ = i1) → (\\ i → transp B φ (u i1 1=1))}) ]\ntransp-hcomp φ A u u0 = inS (sym (outS (hcomp-unique\n ((\\ i o → transp B φ (u i o))) (inS (transp B φ (outS u0)))\n \\ i → inS (transp B φ (hfill u u0 i)))))\n where\n B = \\ (i : I) → outS (A i)\n\n\nhcomp-cong : ∀ {ℓ} {A : Set ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →\n (u' : I → Partial φ A) → (u0' : A [ φ ↦ u' i0 ]) →\n\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\nsqueezeSq≡\n : ∀{w x y z : A}\n → (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)\n → (q ≡ p ∙∙ r ∙∙ sym s) ≡ (Square p q r s)\nsqueezeSq≡ p q r s k\n = Square\n (λ j → p (j ∧ k))\n q\n (λ j → doubleCompPath-filler p r (sym s) j (~ k))\n (λ j → s (j ∧ k))\n", "meta": {"hexsha": "fa30ebef834f7a7572e3238d04ade87e3ae3ca9b", "size": 11760, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/GroupoidLaws.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/GroupoidLaws.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/GroupoidLaws.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": 41.554770318, "max_line_length": 124, "alphanum_fraction": 0.4213435374, "num_tokens": 5320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.5926354412129264}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Sums (disjoint unions)\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Sum.Base where\n\nopen import Function using (_∘_; _-[_]-_ ; id)\nopen import Relation.Nullary using (Dec; yes; no; ¬_)\nopen import Level using (_⊔_)\n\n------------------------------------------------------------------------\n-- Definition\n\ninfixr 1 _⊎_\n\ndata _⊎_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where\n inj₁ : (x : A) → A ⊎ B\n inj₂ : (y : B) → A ⊎ B\n\n------------------------------------------------------------------------\n-- Functions\n\n[_,_] : ∀ {a b c} {A : Set a} {B : Set b} {C : A ⊎ B → Set c} →\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\n[_,_]′ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →\n (A → C) → (B → C) → (A ⊎ B → C)\n[_,_]′ = [_,_]\n\nswap : ∀ {a b} {A : Set a} {B : Set b} → A ⊎ B → B ⊎ A\nswap (inj₁ x) = inj₂ x\nswap (inj₂ x) = inj₁ x\n\nmap : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →\n (A → C) → (B → D) → (A ⊎ B → C ⊎ D)\nmap f g = [ inj₁ ∘ f , inj₂ ∘ g ]\n\nmap₁ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}→\n (A → C) → (A ⊎ B → C ⊎ B)\nmap₁ f = map f id\n\nmap₂ : ∀ {a b d} {A : Set a} {B : Set b} {D : Set d} →\n (B → D) → (A ⊎ B → A ⊎ D)\nmap₂ = map id\n\ninfixr 1 _-⊎-_\n_-⊎-_ : ∀ {a b c d} {A : Set a} {B : Set b} →\n (A → B → Set c) → (A → B → Set d) → (A → B → Set (c ⊔ d))\nf -⊎- g = f -[ _⊎_ ]- g\n\nmodule _ {p} {P : Set p} where\n\n-- Conversion back and forth with Dec\n\n fromDec : Dec P → P ⊎ ¬ P\n fromDec (yes p) = inj₁ p\n fromDec (no ¬p) = inj₂ ¬p\n\n toDec : P ⊎ ¬ P → Dec P\n toDec (inj₁ p) = yes p\n toDec (inj₂ ¬p) = no ¬p\n", "meta": {"hexsha": "ee1dbc118d8ca55f2ade33df436a39e06bf21b69", "size": 1856, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/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/Sum/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/Sum/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": 26.8985507246, "max_line_length": 72, "alphanum_fraction": 0.3712284483, "num_tokens": 756, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.5926354363536093}} {"text": "module Sigma.Renaming.Properties where\n\nopen import Data.Nat using (ℕ; _+_; zero; suc)\nopen import Data.Fin using (Fin; zero; suc)\n\nopen import Sigma.Subst.Core\nopen import Sigma.Renaming.Base\n\nopen import Sigma.Subst.Properties using (extensionality)\n\nopen import Function using (_∘_)\n\nopen import Relation.Binary.PropositionalEquality as Eq\n using (_≡_; refl; cong; cong₂)\nopen Eq.≡-Reasoning\n\n-- ------------------------------------------------------------------------\n\n⇑-cong : ∀ { m n } { ρ₁ ρ₂ : Ren m n } \n → ρ₁ ≡ ρ₂\n -- -----------\n → ρ₁ ⇑ ≡ ρ₂ ⇑\n⇑-cong ρ₁≡ρ₂ = cong (_⇑) ρ₁≡ρ₂\n\n\n⇑✶-cong : ∀ { m n } k { ρ₁ ρ₂ : Ren m n } \n → ρ₁ ≡ ρ₂\n -- -----------\n → ρ₁ ⇑✶ k ≡ ρ₂ ⇑✶ k\n⇑✶-cong k ρ₁≡ρ₂ = cong (_⇑✶ k) ρ₁≡ρ₂\n\n-- ------------------------------------------------------------------------\n\n∘-⇑-distrib : ∀ { m n k } ( ρ₁ : Ren m n ) ( ρ₂ : Ren n k )\n → (ρ₂ ⇑ ∘ ρ₁ ⇑) ≡ (ρ₂ ∘ ρ₁) ⇑\n∘-⇑-distrib ρ₁ ρ₂ = extensionality lemma\n where \n lemma : ∀ x → (ρ₂ ⇑ ∘ ρ₁ ⇑) x ≡ ((ρ₂ ∘ ρ₁) ⇑) x\n lemma zero = refl\n lemma (suc x) = refl\n\n-- TODO:\n-- generalized for ⇑✶\n\n-- ------------------------------------------------------------------------\n\n⇑-id : ∀ { n } → (id { n }) ⇑ ≡ id\n⇑-id = extensionality lemma\n where \n lemma : ∀ { n } x → (id { n } ⇑) x ≡ x\n lemma zero = refl\n lemma (suc x) = refl", "meta": {"hexsha": "049bc70d3796e5d20e31c486b871863d3a1dcb29", "size": 1314, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Sigma/Renaming/Properties.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": "src/Sigma/Renaming/Properties.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": "src/Sigma/Renaming/Properties.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": 25.2692307692, "max_line_length": 75, "alphanum_fraction": 0.4497716895, "num_tokens": 518, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.5925341707602312}} {"text": "{-# OPTIONS --without-K --safe #-}\n-- Take a relation that is already reflexive and transitive\n-- and make it symmetric.\n-- (Borrowed from Categories/Support/ZigZag from copumpkin's Categories library\n\nmodule Relation.Binary.Construct.Symmetrize where\n\nopen import Level\nopen import Relation.Binary\nopen import Relation.Binary.Construct.On using () renaming (isEquivalence to on-preserves-equivalence)\n\ndata Direction : Set where\n ↘ ↗ : Direction\n\nrotate : Direction → Direction\nrotate ↘ = ↗\nrotate ↗ = ↘\n\nprivate\n variable\n c ℓ₁ ℓ₂ : Level\n Carrier : Set c\n\ndata ZigZag′ (_∼_ : Rel Carrier ℓ₂) : (x y : Carrier) (begin end : Direction) → Set (levelOfTerm x ⊔ ℓ₂) where\n zig : ∀ {x y z e} (first : x ∼ y) (rest : ZigZag′ _∼_ y z ↗ e) → ZigZag′ _∼_ x z ↘ e\n zag : ∀ {x y z e} (first : y ∼ x) (rest : ZigZag′ _∼_ y z ↘ e) → ZigZag′ _∼_ x z ↗ e\n slish : ∀ {x y} (last : x ∼ y) → ZigZag′ _∼_ x y ↘ ↘\n slash : ∀ {x y} (last : y ∼ x) → ZigZag′ _∼_ x y ↗ ↗\n\ndata Alternating′ (_∼_ : Carrier -> Carrier -> Set ℓ₂) (x y : Carrier) : Set (levelOfTerm x ⊔ ℓ₂) where\n disorient : ∀ {begin end} (zz : ZigZag′ _∼_ x y begin end) → Alternating′ _∼_ x y\n\nmodule _ (Base : Preorder c ℓ₁ ℓ₂) where\n\n ZigZag : (x y : Preorder.Carrier Base) (begin end : Direction) → Set (c ⊔ ℓ₂)\n ZigZag = ZigZag′ (Preorder._∼_ Base)\n\n private\n sym′ : {x y z : Preorder.Carrier Base} {begin middle end : Direction} → ZigZag y z middle end →\n ZigZag y x middle begin → ZigZag z x (rotate end) begin\n sym′ (zig first rest) accum = sym′ rest (zag first accum)\n sym′ (zag first rest) accum = sym′ rest (zig first accum)\n sym′ (slish last) accum = zag last accum\n sym′ (slash last) accum = zig last accum\n\n sym : ∀ {x y begin end} → ZigZag x y begin end → ZigZag y x (rotate end) (rotate begin)\n sym (zig first rest) = sym′ rest (slash first)\n sym (zag first rest) = sym′ rest (slish first)\n sym (slish last) = slash last\n sym (slash last) = slish last\n\n trans : ∀ {x y z begin end begin′ end′} → ZigZag x y begin end → ZigZag y z begin′ end′ → ZigZag x z begin end′\n trans (zig first rest) yz = zig first (trans rest yz)\n trans (zag first rest) yz = zag first (trans rest yz)\n trans (slish last) (zig first rest) = zig (Preorder.trans Base last first) rest\n trans (slish last) (zag first rest) = zig last (zag first rest)\n trans (slish last) (slish only) = slish (Preorder.trans Base last only)\n trans (slish last) (slash only) = zig last (slash only)\n trans (slash last) (zig first rest) = zag last (zig first rest)\n trans (slash last) (zag first rest) = zag (Preorder.trans Base first last) rest\n trans (slash last) (slish only) = zag last (slish only)\n trans (slash last) (slash only) = slash (Preorder.trans Base only last)\n\n Alternating : (x y : Preorder.Carrier Base) → Set (c ⊔ ℓ₂)\n Alternating = Alternating′ (Preorder._∼_ Base)\n\n private\n is-equivalence : IsEquivalence Alternating\n is-equivalence = record\n { refl = disorient (slash (Preorder.refl Base))\n ; sym = λ where (disorient zz) → disorient (sym zz)\n ; trans = λ where (disorient ij) (disorient jk) → disorient (trans ij jk)\n }\n\n setoid : Setoid c (c ⊔ ℓ₂)\n setoid = record\n { Carrier = Preorder.Carrier Base\n ; _≈_ = Alternating\n ; isEquivalence = is-equivalence\n }\n\n -- the main eliminators for Alternating -- they prove that any equivalence that\n -- respects the base preorder also respects its Alternating completion.\n locally-minimal : ∀ {ℓ′} {_≈_ : Rel (Preorder.Carrier Base) ℓ′} (≈-isEquivalence : IsEquivalence _≈_) →\n (Preorder._∼_ Base ⇒ _≈_) → (Alternating ⇒ _≈_)\n locally-minimal {_} {_≋_} isEq inj (disorient zz) = impl zz\n where\n open IsEquivalence isEq renaming (sym to >sym; trans to _>trans>_)\n\n impl : {i j : Preorder.Carrier Base} {b e : Direction} → ZigZag i j b e → i ≋ j\n impl (zig first rest) = inj first >trans> impl rest\n impl (zag first rest) = >sym (inj first) >trans> impl rest\n impl (slish last) = inj last\n impl (slash last) = >sym (inj last)\n\n minimal : ∀ {c′ ℓ′} (Dest : Setoid c′ ℓ′) (f : Preorder.Carrier Base → Setoid.Carrier Dest) →\n (Preorder._∼_ Base =[ f ]⇒ Setoid._≈_ Dest) → (Alternating =[ f ]⇒ Setoid._≈_ Dest)\n minimal Dest f inj = locally-minimal (on-preserves-equivalence f (Setoid.isEquivalence Dest)) inj\n", "meta": {"hexsha": "346183f569ea537c782232a9cbf131fb26993c46", "size": 4341, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relation/Binary/Construct/Symmetrize.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": "Relation/Binary/Construct/Symmetrize.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": "Relation/Binary/Construct/Symmetrize.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.8484848485, "max_line_length": 113, "alphanum_fraction": 0.6489288182, "num_tokens": 1470, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.5925341663810475}} {"text": "\n-- This module introduces operators.\n\nmodule Introduction.Operators where\n\n-- Agda has a very flexible mechanism for defining operators, supporting infix,\n-- prefix, postfix and mixfix operators.\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n-- Any name containing underscores (_) can be used as an operator by writing\n-- the arguments where the underscores are. For instance, the function _+_ is\n-- the infix addition function. This function can be used either as a normal\n-- function: '_+_ zero zero', or as an operator: 'zero + zero'.\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n-- A fixity declaration specifies precedence level (50 in this case) and\n-- associativity (left associative here) of an operator. Only infix operators\n-- (whose names start and end with _) have associativity.\ninfixl 50 _+_\n\n-- The only restriction on where _ can appear in a name is that there cannot be\n-- two underscores in sequence. For instance, we can define an if-then-else\n-- operator:\n\ndata Bool : Set where\n false : Bool\n true : Bool\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\n-- if_then_else_ is treated as a prefix operator (ends, but doesn't begin with\n-- an _), so the declared precedence determines how something in an else branch\n-- should be parsed. For instance, with the given precedences\n-- if x then y else a + b\n-- is parsed as\n-- if x then y else (a + b)\n-- and not\n-- (if x then y else a) + b\n\ninfix 10 if_then_else_\n\n-- In Agda there is no restriction on what characters are allowed to appear in\n-- an operator (as opposed to a function symbol). For instance, it is allowed\n-- (but not recommended) to define 'f' to be an infix operator and '+' to be a\n-- function symbol.\n\nmodule BadIdea where\n\n _f_ : Nat -> Nat -> Nat\n zero f zero = zero\n zero f suc n = suc n\n suc n f zero = suc n\n suc n f suc m = suc (n f m)\n\n + : Nat -> Nat\n + n = suc n\n\n", "meta": {"hexsha": "f3381578f68abe662d4bea4cebf4eb763fd25934", "size": 1964, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Introduction/Operators.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/Operators.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/Operators.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": 29.7575757576, "max_line_length": 79, "alphanum_fraction": 0.6899185336, "num_tokens": 535, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.5925075704242835}} {"text": "{-\n\nThis file contains:\n - Pushout-products of two maps;\n - The connectivity of pushout-product maps.\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.HITs.Pushout.PushoutProduct where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Equiv.Properties\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Sigma\n\nopen import Cubical.HITs.Pushout.Base\nopen import Cubical.HITs.Pushout.Properties\n\nopen import Cubical.Homotopy.Connected\n\nprivate\n variable\n ℓ ℓ' ℓ'' ℓ''' : Level\n A : Type ℓ\n B : Type ℓ'\n X : Type ℓ''\n Y : Type ℓ'''\n\n\n-- The definition of pushout-product\n\nPushProd : (f : X → A)(g : Y → B) → Type _\nPushProd f g = Pushout (map-× (idfun _) g) (map-× f (idfun _))\n\n_×̂_ : (f : X → A)(g : Y → B) → PushProd f g → A × B\n(f ×̂ g) (inl (x , b)) = f x , b\n(f ×̂ g) (inr (a , y)) = a , g y\n(f ×̂ g) (push (x , y) i) = f x , g y\n\ninfixr 5 _×̂_\n\n\nmodule _\n (m n : ℕ)(f : X → A)(g : Y → B)\n (connf : isConnectedFun m f)\n (conng : isConnectedFun n g)\n (P : A × B → TypeOfHLevel ℓ (m + n)) where\n\n module _\n (sec : (x : PushProd f g) → P ((f ×̂ g) x) .fst) where\n\n private\n fam : A → Type _\n fam a = Σ[ k ∈ ((b : B) → P (a , b) .fst) ] ((y : Y) → k (g y) ≡ sec (inr (a , y)))\n\n open Iso\n\n fiberEquiv : (a : A)\n → fam a ≃ fiber (λ(s : (b : B) → P (a , b) .fst) → s ∘ g) (λ y → sec (inr (a , y)))\n fiberEquiv a = isoToEquiv\n (iso (λ (k , p) → k , λ i y → p y i)\n (λ (k , p) → k , λ y i → p i y)\n (λ _ → refl) (λ _ → refl))\n\n is-m-trunc-fam : (a : A) → isOfHLevel m (fam a)\n is-m-trunc-fam a =\n isOfHLevelRespectEquiv _ (invEquiv (fiberEquiv a))\n (isOfHLevelPrecomposeConnected m n (λ b → P (a , b)) g conng _)\n\n sec-fam : (x : X) → fam (f x)\n sec-fam x = (λ b → sec (inl (x , b))) , (λ y i → sec (push (x , y) i))\n\n map-iso = elim.isIsoPrecompose f _ (λ a → fam a , is-m-trunc-fam a) connf\n\n k = map-iso .inv sec-fam\n ϕ = map-iso .rightInv sec-fam\n\n ext : (x : A × B) → P x .fst\n ext (a , b) = k a .fst b\n\n ext-path : (x : PushProd f g) → ext ((f ×̂ g) x) ≡ sec x\n ext-path (inl (x , b)) i = ϕ i x .fst b\n ext-path (inr (a , y)) i = k a .snd y i\n ext-path (push (x , y) i) j =\n hcomp (λ k → λ\n { (i = i0) → ϕ j x .snd y i0\n ; (i = i1) → ϕ i0 x .snd y (j ∨ ~ k)\n ; (j = i0) → ϕ i0 x .snd y (i ∧ ~ k)\n ; (j = i1) → ϕ i1 x .snd y i })\n (ϕ j x .snd y i)\n\n lifting : hasSection (λ(s : (x : A × B) → P x .fst) → s ∘ (f ×̂ g))\n lifting .fst sec = ext sec\n lifting .snd sec i x = ext-path sec x i\n\n-- The connectivity of pushout-product\n\nisConnected×̂ : {m n : ℕ}{f : A → B}{g : X → Y}\n → isConnectedFun m f → isConnectedFun n g\n → isConnectedFun (m + n) (f ×̂ g)\nisConnected×̂ congf congg =\n elim.isConnectedPrecompose _ _ (lifting _ _ _ _ congf congg)\n", "meta": {"hexsha": "edc5db256855f898f1006c5b0061f9ea6abe90a2", "size": 3032, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Pushout/PushoutProduct.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/Pushout/PushoutProduct.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/Pushout/PushoutProduct.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.0740740741, "max_line_length": 91, "alphanum_fraction": 0.5389182058, "num_tokens": 1182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.5924797710006681}} {"text": "open import Agda.Primitive\n\nopen import Equality\n\nmodule Quotient where\n\n is-prop : ∀ {ℓ} (A : Set ℓ) → Set ℓ\n is-prop A = ∀ (x y : A) → x ≡ y\n\n record is-equivalence {ℓ k} {A : Set ℓ} (E : A → A → Set k) : Set (ℓ ⊔ k) where\n field\n equiv-prop : ∀ {x y} → is-prop (E x y)\n equiv-refl : ∀ {x} → E x x\n equiv-symm : ∀ {x y} → E x y → E y x\n equiv-tran : ∀ {x y z} → E x y → E y z → E x z\n\n record Equivalence {ℓ} (A : Set ℓ) : Set (lsuc ℓ) where\n field\n equiv-relation : A → A → Set ℓ\n equiv-is-equivalence : is-equivalence equiv-relation\n\n is-set : ∀ {ℓ} (A : Set ℓ) → Set ℓ\n is-set A = ∀ (x y : A) (p q : x ≡ y) → p ≡ q\n\n record HSet ℓ : Set (lsuc ℓ) where\n field\n hset-type : Set ℓ\n hset-is-set : is-set hset-type\n\n record Quotient {ℓ} (A : Set ℓ) (E : Equivalence A) : Set (lsuc ℓ) where\n open Equivalence\n\n field\n quot-type : Set ℓ\n quot-class : ∀ (x : A) → quot-type\n quot-≡ : ∀ {x y : A} → equiv-relation E x y → quot-class x ≡ quot-class y\n quot-is-set : is-set quot-type\n quot-elim :\n ∀ (B : ∀ quot-type → Set ℓ)\n (f : ∀ (x : A) → B (quot-class x)) →\n (∀ (x y : A) {ε : equiv-relation E x y} → transport B (quot-≡ ε) (f x) ≡ f y) →\n ∀ (ξ : quot-type) → B ξ\n quot-compute :\n ∀ (B : ∀ quot-type → Set ℓ) →\n (f : ∀ (x : A) → B (quot-class x)) →\n (η : ∀ (x y : A) {ε : equiv-relation E x y} → transport B (quot-≡ ε) (f x) ≡ f y) →\n (quot-elim ? quot-class η)\n", "meta": {"hexsha": "510462dc35b80708c339795b59c0d27dc5a25a19", "size": 1524, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Experimental/Quotient.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/Quotient.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/Quotient.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": 31.75, "max_line_length": 93, "alphanum_fraction": 0.4901574803, "num_tokens": 600, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5924797653358389}} {"text": "open import Relation.Nullary using (¬_; Dec; yes; no)\nopen import Relation.Binary using (Decidable)\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\nopen import Relation.Nullary.Decidable using (False; map)\nopen import Function.Equivalence as FE using ()\n\nmodule AKS.Nat.Base where\n\nopen import Agda.Builtin.FromNat using (Number)\nopen import Data.Nat using (ℕ; _+_; _∸_; _*_; _≟_; _<ᵇ_; pred) public\nopen ℕ public\nopen import Data.Nat.Literals using (number)\n\ninstance\n ℕ-number : Number ℕ\n ℕ-number = number\n\ndata ℕ⁺ : Set where\n ℕ+ : ℕ → ℕ⁺\n\n_+⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺\nℕ+ n +⁺ ℕ+ m = ℕ+ (suc (n + m))\n\n_*⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺\nℕ+ n *⁺ ℕ+ m = ℕ+ (n + m * (suc n))\n\n_≟⁺_ : Decidable {A = ℕ⁺} _≡_\nℕ+ n ≟⁺ ℕ+ m = map (FE.equivalence (λ { refl → refl }) (λ { refl → refl })) (n ≟ m)\n\n⟅_⇑⟆ : ∀ n {≢0 : False (n ≟ zero)} → ℕ⁺\n⟅ suc n ⇑⟆ = ℕ+ n\n\n⟅_⇓⟆ : ℕ⁺ → ℕ\n⟅ ℕ+ n ⇓⟆ = suc n\n\ninstance\n ℕ⁺-number : Number ℕ⁺\n ℕ⁺-number = record\n { Constraint = λ n → False (n ≟ zero)\n ; fromNat = λ n {{≢0}} → ⟅ n ⇑⟆ {≢0}\n }\n\ninfix 4 _≤_\nrecord _≤_ (n : ℕ) (m : ℕ) : Set where\n constructor lte\n field\n k : ℕ\n ≤-proof : n + k ≡ m\n\ninfix 4 _≥_\n_≥_ : ℕ → ℕ → Set\nn ≥ m = m ≤ n\n\ninfix 4 _≰_\n_≰_ : ℕ → ℕ → Set\nn ≰ m = ¬ (n ≤ m)\n\ninfix 4 _≱_\n_≱_ : ℕ → ℕ → Set\nn ≱ m = ¬ (m ≤ n)\n\ninfix 4 _<_\n_<_ : ℕ → ℕ → Set\nn < m = suc n ≤ m\n\ninfix 4 _≮_\n_≮_ : ℕ → ℕ → Set\nn ≮ m = ¬ (n < m)\n\ninfix 4 _>_\n_>_ : ℕ → ℕ → Set\nn > m = m < n\n\ninfix 4 _≯_\n_≯_ : ℕ → ℕ → Set\nn ≯ m = m ≮ n\n\n", "meta": {"hexsha": "18c6f37c38d1da2d59f65215f76e720c82c087a7", "size": 1471, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proofs/AKS/Nat/Base.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/Nat/Base.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/Nat/Base.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": 18.858974359, "max_line_length": 83, "alphanum_fraction": 0.5418082937, "num_tokens": 680, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.679178692681616, "lm_q1q2_score": 0.5924797540061804}} {"text": "open import Categories\nopen import Monads\n\nmodule Monads.Kleisli.Adjunction {a b}{C : Cat {a}{b}}(M : Monad C) where\n\nopen Cat C\nopen Monad M\n\nopen import Library\nopen import Functors\nopen import Monads.Kleisli M\nopen import Adjunctions\nopen import Monads.Kleisli.Functors M\nopen Fun\n\nKlAdj : Adj C Kl\nKlAdj = record {\n L = KlL;\n R = KlR;\n left = id;\n right = id;\n lawa = λ _ → refl;\n lawb = λ _ → refl;\n natleft = lem;\n natright = lem}\n where \n lem = λ {X}{X'}{Y}{Y'} (f : Hom X' X)(g : Hom Y (T Y')) h → \n proof\n comp (bind g) (comp h f) \n ≅⟨ cong (λ h → comp (bind g) (comp h f)) (sym law2) ⟩\n comp (bind g) (comp (comp (bind h) η) f) \n ≅⟨ cong (comp (bind g)) ass ⟩\n comp (bind g) (comp (bind h) (comp η f)) \n ∎\n", "meta": {"hexsha": "1b4e9d072b017a146fff5503097e06fae56c9bf3", "size": 778, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Monads/Kleisli/Adjunction.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/Adjunction.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/Adjunction.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": 22.2285714286, "max_line_length": 73, "alphanum_fraction": 0.5719794344, "num_tokens": 298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9196425267730008, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.5924568110215015}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Dodo.Binary.Trichotomous where\n\n-- Stdlib imports\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; _≢_; refl; cong; subst; subst₂) renaming (sym to ≡-sym)\nopen import Level using (Level)\nopen import Function using (flip; _∘_; _∘₂_)\nopen import Data.Empty using (⊥-elim)\nopen import Data.Product using (_,_)\nopen import Relation.Unary using (Pred)\nopen import Relation.Binary using (Rel; Irreflexive; Trichotomous; Tri; tri<; tri≈; tri>)\nopen import Relation.Binary.Construct.Closure.Transitive using ([_])\n-- Local imports\nopen import Dodo.Unary.Equality\nopen import Dodo.Binary.Equality\nopen import Dodo.Binary.Immediate\nopen import Dodo.Binary.Filter\n\n\n-- # Definitions\n\ntri-immˡ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {R : Rel A ℓ₂}\n → Trichotomous _≈_ R → {x y z : A}\n → immediate R x z → immediate R y z\n ---------------------------------\n → x ≈ y\ntri-immˡ triR {x} {y} {z} (Rxz , ¬∃y) (Ryz , ¬∃x) with triR x y\n... | tri< Rxy x≢y ¬Ryx = ⊥-elim (¬∃y (y , Rxy , [ Ryz ]))\n... | tri≈ ¬Rxy x≡y ¬Ryx = x≡y\n... | tri> ¬Rxy x≢y Ryx = ⊥-elim (¬∃x (x , Ryx , [ Rxz ]))\n\n\ntri-immʳ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {R : Rel A ℓ₂}\n → Trichotomous _≈_ R → {x y z : A}\n → immediate R x y → immediate R x z\n ---------------------------------\n → y ≈ z\ntri-immʳ triR {x} {y} {z} (Rxy , ¬∃z) (Rxz , ¬∃y) with triR y z\n... | tri< Ryz y≢z ¬Rzy = ⊥-elim (¬∃y (y , Rxy , [ Ryz ]))\n... | tri≈ ¬Ryz y≡z ¬Rzy = y≡z\n... | tri> ¬Ryz y≢z Rzy = ⊥-elim (¬∃z (z , Rxz , [ Rzy ]))\n\n\ntri-irreflexive : {a ℓ₁ ℓ₂ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂}\n → Trichotomous _≈_ _<_\n --------------------\n → Irreflexive _≈_ _<_\ntri-irreflexive triR {x} {y} x≈y x x≮y x≉y x>y = x≉y x≈y\n\n\ntri-flip : ∀ {a ℓ : Level} {A : Set a} {R : Rel A ℓ}\n → {x y : A}\n → Tri (R x y) (x ≡ y) (R y x)\n -------------------------------------\n → Tri (flip R x y) (x ≡ y) (flip R y x)\ntri-flip (tri< Rxy x≢y ¬Ryx) = tri> ¬Ryx x≢y Rxy\ntri-flip (tri≈ ¬Rxy x≡y ¬Ryx) = tri≈ ¬Ryx x≡y ¬Rxy\ntri-flip (tri> ¬Rxy x≢y Ryx) = tri< Ryx x≢y ¬Rxy\n\n\ntrichotomous-flip : ∀ {a ℓ : Level} {A : Set a} {R : Rel A ℓ}\n → Trichotomous _≡_ R\n -------------------------\n → Trichotomous _≡_ (flip R)\ntrichotomous-flip {R = R} triR = tri-flip {R = R} ∘₂ triR\n", "meta": {"hexsha": "028ddec51d216bf7d3bee175e1677daf87e37fdc", "size": 2413, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Dodo/Binary/Trichotomous.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/Trichotomous.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/Trichotomous.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": 33.985915493, "max_line_length": 89, "alphanum_fraction": 0.5408205553, "num_tokens": 1062, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.5924537221510069}} {"text": "module container.m.core where\n\nopen import level\nopen import sum\nopen import equality.core\nopen import equality.calculus\nopen import function.core\nopen import function.isomorphism\nopen import function.extensionality\nopen import container.core\nopen import container.equality\nopen import container.fixpoint\n\ninfix 1000 ♯_\n\npostulate\n ∞ : ∀ {a} (A : Set a) → Set a\n ♯_ : ∀ {a} {A : Set a} → A → ∞ A\n ♭ : ∀ {a} {A : Set a} → ∞ A → A\n\n{-# BUILTIN INFINITY ∞ #-}\n{-# BUILTIN SHARP ♯_ #-}\n{-# BUILTIN FLAT ♭ #-}\n\nmodule Definition {li la lb}(c : Container li la lb) where\n open Container c public\n\n -- definition of indexed M-types using native Agda coinduction\n data M (i : I) : Set (la ⊔ lb) where\n inf : (a : A i) → ((b : B a) → ∞ (M (r b))) → M i\n\n -- the terminal coalgebra\n out : M →ⁱ F M\n out i (inf a f) = a , ♭ ∘' f\n\n -- normally, the constructor can be defined in terms of out and unfold, but\n -- Agda provides it natively, together with a definitional β rule\n inM' : F M →ⁱ M\n inM' i (a , f) = inf a (λ x → ♯ (f x))\n\n inM'-β : {i : I}(x : F M i) → out i (inM' i x) ≡ x\n inM'-β x = refl\n\n module Elim {lx}{X : I → Set lx}\n (α : X →ⁱ F X) where\n -- anamorphisms\n unfold : X →ⁱ M\n unfold i x = inf a f\n where\n u : F X i\n u = α i x\n\n a : A i\n a = proj₁ u\n\n f : (b : B a) → ∞ (M (r b))\n f b = ♯ unfold (r b) (proj₂ u b)\n\n -- computational rule for anamorphisms\n -- this holds definitionally\n unfold-β : {i : I}(x : X i)\n → out i (unfold i x) ≡ imap unfold i (α i x)\n unfold-β x = refl\n\n -- the corresponding η rule doesn't hold, so we postulate it\n postulate\n unfold-η : (h : X →ⁱ M)\n → (∀ {i} (x : X i) → out i (h i x) ≡ imap h i (α i x))\n → ∀ {i} (x : X i) → h i x ≡ unfold i x\n open Elim public\n\n -- using η, we can prove that the unfolding of out is the identity\n unfold-id : ∀ {i} (x : M i) → unfold out i x ≡ x\n unfold-id x = sym (unfold-η out idⁱ (λ _ → refl) x)\n\n -- the usual definition of the constructor\n inM : F M →ⁱ M\n inM = unfold (imap out)\n\n -- the constructor is the inverse of the destructor\n inM-η : ∀ {i} (x : M i) → inM i (out i x) ≡ x\n inM-η x = unfold-η out (inM ∘ⁱ out) (λ _ → refl) x · unfold-id x\n\n inM-β : ∀ {i} (x : F M i) → out i (inM i x) ≡ x\n inM-β {i} x = ap u (funext (λ i → funext inM-η))\n where\n u : (M →ⁱ M) → F M i\n u h = imap h i x\n\n fixpoint : ∀ i → M i ≅ F M i\n fixpoint i = iso (out i) (inM i) inM-η inM-β\n\n -- now we can prove that the constructor provided by Agda is equal to the\n -- usual one\n inM-alt : ∀ {i} (x : F M i) → inM' i x ≡ inM i x\n inM-alt {i} x = sym (inM-η (inM' i x))\n", "meta": {"hexsha": "8efc7279cabdfa5a7ecf629b61a9948897fae628", "size": 2719, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "container/m/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": "container/m/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": "container/m/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.0309278351, "max_line_length": 77, "alphanum_fraction": 0.5502022803, "num_tokens": 1020, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619306896956, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.5924537202817571}} {"text": "module Categories.Terminal where\n\nopen import Library\nopen import Categories\nopen import Categories.Sets\nopen Cat\n\nrecord Term {a b} (C : Cat {a}{b})(T : Obj C) : Set (a ⊔ b) where\n constructor term\n field t : ∀{X} → Hom C X T\n law : ∀{X}{f : Hom C X T} → t {X} ≅ f\n\nOneSet : Term Sets ⊤\nOneSet = record {t = λ _ → _; law = ext (λ _ → refl)}\n", "meta": {"hexsha": "1c2f39bd02752ad5115c4e1d41b89aa2bf6c9c0b", "size": 351, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Terminal.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/Terminal.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/Terminal.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": 23.4, "max_line_length": 65, "alphanum_fraction": 0.6096866097, "num_tokens": 123, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505376715775, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.592450862652922}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\n\nopen import LogicalFormulae\nopen import Functions.Definition\n\nmodule Orders.Partial.Definition {a : _} (carrier : Set a) where\n\nrecord PartialOrder {b : _} : Set (a ⊔ lsuc b) where\n field\n _<_ : Rel {a} {b} carrier\n irreflexive : {x : carrier} → (x < x) → False\n Set)\n (_==_ : {a b : U} -> T a -> T b -> Set)\n (refl : {a : U}(x : T a) -> x == x)\n (trans : {a b c : U}(x : T a)(y : T b)(z : T c) -> x == y -> y == z -> x == z)\n where\n\ninfix 30 _∼_\ninfix 3 proof_\ninfixl 2 _≡_by_\ninfix 1 _qed\n\ndata _∼_ {a b : U}(x : T a)(y : T b) : Set where\n prf : x == y -> x ∼ y\n\nproof_ : {a : U}(x : T a) -> x ∼ x\nproof x = prf (refl x)\n\n_≡_by_ : {a b c : U}{x : T a}{y : T b} -> x ∼ y -> (z : T c) -> y == z -> x ∼ z\nprf p ≡ z by q = prf (trans _ _ _ p q)\n\n_qed : {a b : U}{x : T a}{y : T b} -> x ∼ y -> x == y\nprf p qed = p\n", "meta": {"hexsha": "cb402aca562b3db4110afe310a1e4ae9d0fc4f2f", "size": 589, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/cwf/Chain.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": "benchmark/cwf/Chain.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": "benchmark/cwf/Chain.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.56, "max_line_length": 80, "alphanum_fraction": 0.4108658744, "num_tokens": 298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314768368161, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.5923814069736693}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Data.Integer where\n\nopen import Level\n\nopen import Data.Nat using (ℕ; suc; zero)\nimport Data.Nat as ℕ\nimport Data.Nat.Properties as ℕ\nopen import Data.Bool\n\ndata ℤ : Type where\n ⁺ : ℕ → ℤ\n ⁻suc : ℕ → ℤ\n\n⁻ : ℕ → ℤ\n⁻ zero = ⁺ zero\n⁻ (suc n) = ⁻suc n\n\n{-# DISPLAY ⁻suc n = ⁻ suc n #-}\n\nnegate : ℤ → ℤ\nnegate (⁺ x) = ⁻ x\nnegate (⁻suc x) = ⁺ (suc x)\n\n{-# DISPLAY negate x = ⁻ x #-}\n\ninfixl 6 _+_\n\n_-suc_ : ℕ → ℕ → ℤ\nx -suc y =\n if y ℕ.<ᴮ x\n then ⁺ (x ℕ.∸ (suc y))\n else ⁻suc (y ℕ.∸ x)\n\n_+_ : ℤ → ℤ → ℤ\n⁺ x + ⁺ y = ⁺ (x ℕ.+ y)\n⁺ x + ⁻suc y = x -suc y\n⁻suc x + ⁺ y = y -suc x\n⁻suc x + ⁻suc y = ⁻suc (suc x ℕ.+ y)\n\n_*-suc_ : ℕ → ℕ → ℤ\nzero *-suc m = ⁺ zero\nsuc n *-suc m = ⁻suc (n ℕ.+ m ℕ.+ n ℕ.* m)\n\ninfixl 7 _*_\n_*_ : ℤ → ℤ → ℤ\n⁺ x * ⁺ y = ⁺ (x ℕ.* y)\n⁺ x * ⁻suc y = x *-suc y\n⁻suc x * ⁺ y = y *-suc x\n⁻suc x * ⁻suc y = ⁺ (suc x ℕ.* suc y)\n", "meta": {"hexsha": "4720bc99e86b312f4f528244cef7b39d7de07bfe", "size": 914, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Integer.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/Integer.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/Integer.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": 17.5769230769, "max_line_length": 42, "alphanum_fraction": 0.4737417943, "num_tokens": 471, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314798554445, "lm_q2_score": 0.6688802471698041, "lm_q1q2_score": 0.5923814031470691}} {"text": "module L0 where\n\nopen import Common\n\n-- Syntax\n\ndata Name : Set where\n d n j m : Name\n\ndata Pred1 : Set where\n M B : Pred1\n\ndata Pred2 : Set where\n K L : Pred2\n\ndata Expr : Set where\n _⦅_⦆ : Pred1 -> Name -> Expr\n _⦅_,_⦆ : Pred2 -> Name -> Name -> Expr\n ¬ : Expr -> Expr\n [_∧_] : Expr -> Expr -> Expr\n [_∨_] : Expr -> Expr -> Expr\n [_⇒_] : Expr -> Expr -> Expr\n [_⇔_] : Expr -> Expr -> Expr\n\nexample1 : Expr\nexample1 = [ K ⦅ d , j ⦆ ∧ M ⦅ d ⦆ ]\nexample2 : Expr\nexample2 = ¬ [ M ⦅ d ⦆ ∨ B ⦅ m ⦆ ]\nexample3 : Expr\nexample3 = [ L ⦅ n , j ⦆ ⇒ [ B ⦅ d ⦆ ∨ ¬ (K ⦅ m , m ⦆) ] ]\nexample4 : Expr\nexample4 = [ ¬ (¬ (¬ (B ⦅ n ⦆))) ⇔ ¬ (M ⦅ n ⦆) ]\n\n-- Semantics\n \ndata Person : Set where\n Richard_Nixon : Person\n Noam_Chomsky : Person\n John_Mitchell : Person\n Muhammad_Ali : Person\n\ninstance\n eqPerson : Eq Person\n -- _==_ ⦃ eqPerson ⦄ x y = isEq x y (refl {!x y!})\n _==_ ⦃ eqPerson ⦄ Richard_Nixon Richard_Nixon = true\n _==_ ⦃ eqPerson ⦄ Noam_Chomsky Noam_Chomsky = true\n _==_ ⦃ eqPerson ⦄ John_Mitchell John_Mitchell = true\n _==_ ⦃ eqPerson ⦄ Muhammad_Ali Muhammad_Ali = true\n _==_ ⦃ eqPerson ⦄ _ _ = false\n\n_∈_ : {A : Set} {{_ : Eq A}} -> A -> PSet A -> Bool\nx ∈ ⦃⦄ = false\nx ∈ (x₁ :: xs) = (x == x₁) || (x ∈ xs)\n\n⟦_⟧ₙ : Name -> Person\n⟦ d ⟧ₙ = Richard_Nixon\n⟦ n ⟧ₙ = Noam_Chomsky\n⟦ j ⟧ₙ = John_Mitchell\n⟦ m ⟧ₙ = Muhammad_Ali\n\n⟦_⟧ₚ₁ : Pred1 -> PSet Person\n⟦ x ⟧ₚ₁ = {!!}\n\n⟦_⟧ₚ₂ : Pred2 -> PSet (Pair Person)\n⟦ x ⟧ₚ₂ = {!!}\n\n⟦_⟧ₑ : Expr -> Bool\n{-# TERMINATING #-}\n⟦ x ⦅ x₁ ⦆ ⟧ₑ = ⟦ x₁ ⟧ₙ ∈ ⟦ x ⟧ₚ₁ \n⟦ x ⦅ x₁ , x₂ ⦆ ⟧ₑ = < ⟦ x₁ ⟧ₙ , ⟦ x₂ ⟧ₙ > ∈ ⟦ x ⟧ₚ₂\n⟦ ¬ x ⟧ₑ = neg ⟦ x ⟧ₑ\n⟦ [ x ∧ x₁ ] ⟧ₑ = ⟦ x ⟧ₑ && ⟦ x₁ ⟧ₑ\n⟦ [ x ∨ x₁ ] ⟧ₑ = ⟦ x ⟧ₑ || ⟦ x₁ ⟧ₑ\n⟦ [ x ⇒ x₁ ] ⟧ₑ = (neg ⟦ x₁ ⟧ₑ) || ⟦ x ⟧ₑ\n⟦ [ x ⇔ x₁ ] ⟧ₑ = ⟦ [ x ⇒ x₁ ] ⟧ₑ && ⟦ [ x₁ ⇒ x ] ⟧ₑ\n", "meta": {"hexsha": "4ba72218cc306d19d228f9e58c768fbafee358c8", "size": 1753, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "L0.agda", "max_stars_repo_name": "daherb/Agda-Montague", "max_stars_repo_head_hexsha": "9f8bbff7248dbeb54919e03957daf9b35ec1ac23", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-12-18T11:56:24.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-18T11:56:24.000Z", "max_issues_repo_path": "L0.agda", "max_issues_repo_name": "daherb/Agda-Montague", "max_issues_repo_head_hexsha": "9f8bbff7248dbeb54919e03957daf9b35ec1ac23", "max_issues_repo_licenses": ["Artistic-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": "L0.agda", "max_forks_repo_name": "daherb/Agda-Montague", "max_forks_repo_head_hexsha": "9f8bbff7248dbeb54919e03957daf9b35ec1ac23", "max_forks_repo_licenses": ["Artistic-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.0657894737, "max_line_length": 58, "alphanum_fraction": 0.5094124358, "num_tokens": 906, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835371034369, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.592373803494765}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- \"Finite\" sets indexed on coinductive \"natural\" numbers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --sized-types --guardedness #-}\n\nmodule Codata.Musical.Cofin where\n\nopen import Codata.Musical.Notation\nopen import Codata.Musical.Conat as Conat using (Coℕ; suc; ∞ℕ)\nopen import Data.Nat.Base using (ℕ; zero; suc)\nopen import Data.Fin using (Fin; zero; suc)\nopen import Relation.Binary.PropositionalEquality using (_≡_ ; refl)\nopen import Function\n\n------------------------------------------------------------------------\n-- The type\n\n-- Note that Cofin ∞ℕ is /not/ finite. Note also that this is not a\n-- coinductive type, but it is indexed on a coinductive type.\n\ndata Cofin : Coℕ → Set where\n zero : ∀ {n} → Cofin (suc n)\n suc : ∀ {n} (i : Cofin (♭ n)) → Cofin (suc n)\n\nsuc-injective : ∀ {m} {p q : Cofin (♭ m)} → (Cofin (suc m) ∋ suc p) ≡ suc q → p ≡ q\nsuc-injective refl = refl\n\n------------------------------------------------------------------------\n-- Some operations\n\nfromℕ : ℕ → Cofin ∞ℕ\nfromℕ zero = zero\nfromℕ (suc n) = suc (fromℕ n)\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\nimport Codata.Cofin as C\n\nfromMusical : ∀ {n} → Cofin n → C.Cofin (Conat.fromMusical n)\nfromMusical zero = C.zero\nfromMusical (suc n) = C.suc (fromMusical n)\n\ntoMusical : ∀ {n} → C.Cofin n → Cofin (Conat.toMusical n)\ntoMusical C.zero = zero\ntoMusical (C.suc n) = suc (toMusical n)\n", "meta": {"hexsha": "cb278711777ab9a701ad37e40b1878d9cc836744", "size": 1810, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/Musical/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/Musical/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/Musical/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.1666666667, "max_line_length": 83, "alphanum_fraction": 0.5475138122, "num_tokens": 590, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916029436189, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.5922430050408853}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n-- This module provides the basic expression type for polynomials.\n\nmodule Polynomial.Expr where\n\nopen import Data.Nat using (ℕ)\nopen import Data.Fin using (Fin)\n\ninfixl 6 _⊕_\ninfixl 7 _⊗_\ninfixr 8 _⊛_\ndata Expr {ℓ} (A : Set ℓ) (n : ℕ) : Set ℓ where\n Κ : A → Expr A n\n Ι : Fin n → Expr A n\n _⊕_ : Expr A n → Expr A n → Expr A n\n _⊗_ : Expr A n → Expr A n → Expr A n\n _⊛_ : Expr A n → ℕ → Expr A n\n ⊝_ : Expr A n → Expr A n\n\nopen import Polynomial.Parameters\n\nmodule Eval {c r₁ r₂ r₃} (homo : Homomorphism c r₁ r₂ r₃) where\n open Homomorphism homo\n open import Polynomial.Exponentiation rawRing\n\n open import Data.Vec as Vec using (Vec)\n\n ⟦_⟧ : ∀ {n} → Expr Raw.Carrier n → Vec Carrier n → Carrier\n ⟦ Κ x ⟧ ρ = ⟦ x ⟧ᵣ\n ⟦ Ι x ⟧ ρ = Vec.lookup ρ x\n ⟦ x ⊕ y ⟧ ρ = ⟦ x ⟧ ρ + ⟦ y ⟧ ρ\n ⟦ x ⊗ y ⟧ ρ = ⟦ x ⟧ ρ * ⟦ y ⟧ ρ\n ⟦ ⊝ x ⟧ ρ = - ⟦ x ⟧ ρ\n ⟦ x ⊛ i ⟧ ρ = ⟦ x ⟧ ρ ^ i\n", "meta": {"hexsha": "d453b9def9169483b03a0bb25d043a0dadb2981a", "size": 919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Polynomial/Expr.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/Expr.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/Expr.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": 25.5277777778, "max_line_length": 66, "alphanum_fraction": 0.5756256801, "num_tokens": 414, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970779778824, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.5921877960690198}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import cohomology.Theory\n\nopen import cw.CW\n\nmodule cw.cohomology.TipAndAugment {i} (OT : OrdinaryTheory i)\n (⊙skel : ⊙Skeleton {i} 0) where\n\nopen OrdinaryTheory OT\nopen import homotopy.DisjointlyPointedSet\nopen import cohomology.DisjointlyPointedSet OT\n\nmodule _ (m : ℤ) where\n CX₀ : Group i\n CX₀ = C m (⊙cw-head ⊙skel)\n\n CX₀-is-abelian : is-abelian CX₀\n CX₀-is-abelian = C-is-abelian m (⊙cw-head ⊙skel)\n\n C2×CX₀ : Group i\n C2×CX₀ = C2 m ×ᴳ CX₀\n\n abstract\n C2×CX₀-is-abelian : is-abelian C2×CX₀\n C2×CX₀-is-abelian = ×ᴳ-is-abelian (C2 m) CX₀ (C2-is-abelian m) CX₀-is-abelian\n\n C2×CX₀-abgroup : AbGroup i\n C2×CX₀-abgroup = C2×CX₀ , C2×CX₀-is-abelian\n\n CX₀-β : ⊙has-cells-with-choice 0 ⊙skel i\n → CX₀ ≃ᴳ Πᴳ (MinusPoint (⊙cw-head ⊙skel)) (λ _ → C2 m)\n CX₀-β ac = C-set m (⊙cw-head ⊙skel) (snd (⊙Skeleton.skel ⊙skel)) (⊙Skeleton.pt-dec ⊙skel) ac\n\nabstract\n CX₀-≠-is-trivial : ∀ {m} (m≠0 : m ≠ 0)\n → ⊙has-cells-with-choice 0 ⊙skel i\n → is-trivialᴳ (CX₀ m)\n CX₀-≠-is-trivial {m} m≠0 ac =\n iso-preserves'-trivial (CX₀-β m ac) $\n Πᴳ-is-trivial (MinusPoint (⊙cw-head ⊙skel))\n (λ _ → C2 m) (λ _ → C-dimension m≠0)\n\ncw-coε : C2 0 →ᴳ C2×CX₀ 0\ncw-coε = ×ᴳ-inl {G = C2 0} {H = CX₀ 0}\n", "meta": {"hexsha": "3f7b5752591469cff8e4fbffeb045a91f9c78519", "size": 1277, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cw/cohomology/TipAndAugment.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/cw/cohomology/TipAndAugment.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/cw/cohomology/TipAndAugment.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": 27.170212766, "max_line_length": 94, "alphanum_fraction": 0.6358653093, "num_tokens": 593, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970873650401, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.5921877908145484}} {"text": "{-\n\n Agda Implementors' Meeting VI\n\n Göteborg\n May 24 - 30, 2007\n\n\n Hello Agda!\n\n Ulf Norell\n\n-}\n\n{-\n\n Getting your hands on Agda\n\n http://www.cs.chalmers.se/~ulfn/Agda\n\n darcs get --partial http://www.cs.chalmers.se/~ulfn/darcs/Agda2\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-- 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)(f : B -> C)(g : A -> B) -> A -> C\ncompose = \\(A B C : Set) -> \\ 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 disappeared\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-- You can give implicit arguments explicitly.\nid₅ : {A : Set} -> A -> A\nid₅ {A} x = id₄ {A} x\n\n-- If you want to give a particular implicit argument, you can refer\n-- to it by name.\nconst : {A B : Set} -> A -> B -> A\nconst = \\ x y -> x\n\nconst' : (A : Set) -> A -> A -> A\nconst' = \\ A -> const {B = A}\n\n-- It also works the other way around. If you think the type checker\n-- should figure out the value of 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": "34ca2514ca0168f9cd4cfe8fa7da4cd71698856f", "size": 1967, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/HelloAgda/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/AIM6/HelloAgda/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/AIM6/HelloAgda/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": 20.2783505155, "max_line_length": 68, "alphanum_fraction": 0.5948144382, "num_tokens": 621, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342624, "lm_q2_score": 0.7371581568543044, "lm_q1q2_score": 0.5920661084101527}} {"text": "\ndata ⊤ : Set where tt : ⊤\n\nrecord R : Set where\n constructor r\n field .x : ⊤\n\nf : R → R\nR.x (f (r x)) = {!x!}\n", "meta": {"hexsha": "5b4dec09dfba3d3165c703e632cfe7e23628fa3b", "size": 113, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue3452.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/Issue3452.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/Issue3452.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": 11.3, "max_line_length": 25, "alphanum_fraction": 0.4955752212, "num_tokens": 49, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8311430478583169, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.5919668334679404}} {"text": "{-\n\nThe James Construction,\n also known as James Reduced Product\n\nA very fundamental and useful construction in classical homotopy theory.\nIt can be seen as the free A∞-monoid constructed out of a given type,\nnamely the \"correct higher version\" of free monoid that is meaningful for all types,\ninstead of only h-Sets.\n\nReferrence:\n Guillaume Brunerie,\n \"The James construction and π₄(𝕊³) in homotopy type theory\"\n (https://arxiv.org/abs/1710.10307)\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.HITs.James.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Pointed\n\nprivate\n variable\n ℓ ℓ' : Level\n\nmodule _\n ((X , x₀) : Pointed ℓ) where\n\n infixr 5 _∷_\n\n -- The James Construction\n\n data James : Type ℓ where\n [] : James\n _∷_ : X → James → James\n unit : (xs : James) → xs ≡ x₀ ∷ xs\n\n James∙ : Pointed ℓ\n James∙ = James , []\n\n\n-- Basic operations on James construction, imitating those in Cubical.Data.List.Base\n\nmodule _\n {X∙@(X , x₀) : Pointed ℓ} where\n\n infixr 5 _++_\n infixl 5 _∷ʳ_\n\n [_] : X → James X∙\n [ x ] = x ∷ []\n\n _++_ : James X∙ → James X∙ → James X∙\n [] ++ ys = ys\n (x ∷ xs) ++ ys = x ∷ xs ++ ys\n (unit xs i) ++ ys = unit (xs ++ ys) i\n\n ++₀ : (xs : James X∙) → xs ≡ xs ++ [ x₀ ]\n ++₀ [] = unit []\n ++₀ (x ∷ xs) i = x ∷ ++₀ xs i\n ++₀ (unit xs i) j = unit (++₀ xs j) i\n\n rev : James X∙ → James X∙\n rev [] = []\n rev (x ∷ xs) = rev xs ++ [ x ]\n rev (unit xs i) = ++₀ (rev xs) i\n\n _∷ʳ_ : James X∙ → X → James X∙\n xs ∷ʳ x = xs ++ x ∷ []\n\nmap : {X : Pointed ℓ}{Y : Pointed ℓ'} → (X →∙ Y) → James X → James Y\nmap f [] = []\nmap f (x ∷ xs) = f .fst x ∷ map f xs\nmap f (unit xs i) = (unit (map f xs) ∙ (λ i → f .snd (~ i) ∷ map f xs)) i\n\nmap∙ : {X : Pointed ℓ}{Y : Pointed ℓ'} → (X →∙ Y) → James∙ X →∙ James∙ Y\nmap∙ f .fst = map f\nmap∙ f .snd = refl\n", "meta": {"hexsha": "a4f12011dbc4c06ff36cc3f472ae05359091a484", "size": 1825, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/James/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/James/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/James/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": 22.8125, "max_line_length": 84, "alphanum_fraction": 0.5775342466, "num_tokens": 705, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583169, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.5919668233143488}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Automatic solvers for equations over booleans\n------------------------------------------------------------------------\n\n-- See README.Nat for examples of how to use similar solvers\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Bool.Solver where\n\nimport Algebra.Solver.Ring.Simple as Solver\nimport Algebra.Solver.Ring.AlmostCommutativeRing as ACR\nopen import Data.Bool using (_≟_)\nopen import Data.Bool.Properties\n\n------------------------------------------------------------------------\n-- A module for automatically solving propositional equivalences\n-- containing _∨_ and _∧_\n\nmodule ∨-∧-Solver =\n Solver (ACR.fromCommutativeSemiring ∨-∧-commutativeSemiring) _≟_\n\n------------------------------------------------------------------------\n-- A module for automatically solving propositional equivalences\n-- containing _xor_ and _∧_\n\nmodule xor-∧-Solver =\n Solver (ACR.fromCommutativeRing xor-∧-commutativeRing) _≟_\n", "meta": {"hexsha": "59239d2bfb4590f3c574c14326a4560a522bf7c8", "size": 1028, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Bool/Solver.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/Bool/Solver.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/Bool/Solver.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.1612903226, "max_line_length": 72, "alphanum_fraction": 0.5515564202, "num_tokens": 208, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9086178969328286, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.591832699588635}} {"text": "{-# OPTIONS --without-K #-}\nopen import HoTT.Base\nopen import HoTT.Identity\n\nmodule HoTT.Homotopy where\n\nopen variables\nprivate variable f g : A → B\n\n-- Lemma 2.4.3\n~-natural : (α : f ~ g) {x y : A} (p : x == y) → α x ∙ ap g p == ap f p ∙ α y\n~-natural α {x} refl rewrite α x = refl\n\n~-natural-id : (α : f ~ id) {x y : A} (p : x == y) → α x ∙ p == ap f p ∙ α y\n~-natural-id α {x} refl rewrite α x = refl\n\n-- Corollary 2.4.4\n~-natural-comm : {f : A → A} (α : f ~ id) → α ∘ f ~ ap f ∘ α\n~-natural-comm {f = f} α x = cancelᵣ (α (f x) ∙ₗ ap-id (α x) ⁻¹ ∙ ~-natural α (α x))\n\nmodule ~-Reasoning where\n _~⟨_⟩_ : (f : Π A P) {g h : Π A P} → f ~ g → g ~ h → f ~ h\n x ~⟨ α ⟩ β = α ∙ₕ β\n infixr 2 _~⟨_⟩_\n\n _∎ : (f : Π A P) → f ~ f\n _ ∎ = reflₕ\n infix 3 _∎\n", "meta": {"hexsha": "292c830abb899876b30072a04e35ddcba3c72600", "size": 752, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Homotopy.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/Homotopy.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/Homotopy.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": 25.9310344828, "max_line_length": 84, "alphanum_fraction": 0.5066489362, "num_tokens": 349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869851639065, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.5918258540445499}} {"text": "\n-- Some basic stuff for Conor's talk.\nmodule SomeBasicStuff where\n\ninfixr 40 _::_ _↦_∣_\ninfix 30 _∈_ _==_\ninfixr 10 _,_\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n refl : x == x\n\ndata Σ (A : Set)(B : A -> Set) : Set where\n _,_ : (x : A) -> B x -> Σ A B\n\n_×_ : Set -> Set -> Set\nA × B = Σ A \\_ -> B\n\nfst : {A : Set}{B : A -> Set} -> Σ A B -> A\nfst (x , y) = x\n\nsnd : {A : Set}{B : A -> Set}(p : Σ A B) -> B (fst p)\nsnd (x , y) = y\n\ndata False : Set where\nrecord True : Set where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\ndata [_] (A : Set) : Set where\n [] : [ A ]\n _::_ : A -> [ A ] -> [ A ]\n\ndata _∈_ {A : Set} : A -> [ A ] -> Set where\n zero : forall {x xs} -> x ∈ x :: xs\n suc : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs\n\npostulate Tag : Set\n{-# BUILTIN STRING Tag #-}\n\nEnumeration = [ Tag ]\n\ndata Enum (ts : Enumeration) : Set where\n enum : (t : Tag) -> t ∈ ts -> Enum ts\n\ndata Table (A : Set1) : Enumeration -> Set1 where\n [] : Table A []\n _↦_∣_ : forall {ts} -> (t : Tag) -> A -> Table A ts ->\n Table A (t :: ts)\n\nlookup : forall {A ts} -> Table A ts -> Enum ts -> A\nlookup [] (enum _ ())\nlookup (.t ↦ v ∣ tbl) (enum t zero) = v\nlookup (_ ↦ v ∣ tbl) (enum t (suc p)) = lookup tbl (enum t p)\n", "meta": {"hexsha": "bb535dbc5fdd688607e83ef7d1e21c4d873b0267", "size": 1255, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/DTP08/conor/SomeBasicStuff.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/DTP08/conor/SomeBasicStuff.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/DTP08/conor/SomeBasicStuff.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.4107142857, "max_line_length": 62, "alphanum_fraction": 0.4916334661, "num_tokens": 487, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869884059267, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5918258505165984}} {"text": "{-# OPTIONS --without-K #-}\nopen import Type\nopen import Type.Identities\nopen import Level.NP\nopen import Explore.Core\nopen import Explore.Properties\nopen import Explore.Explorable\nopen import Data.Zero\nopen import Function.NP\nopen import Function.Extensionality\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality.NP using (_≡_; refl; _∙_; !_)\nopen import HoTT\nopen Equivalences\n\nimport Explore.Monad\nopen import Explore.Isomorphism\n\nmodule Explore.Zero where\n\n\nmodule _ {ℓ} where\n 𝟘ᵉ : Explore ℓ 𝟘\n 𝟘ᵉ = empty-explore\n {- or\n 𝟘ᵉ ε _ _ = ε\n -}\n\n 𝟘ⁱ : ∀ {p} → ExploreInd p 𝟘ᵉ\n 𝟘ⁱ = empty-explore-ind\n {- or\n 𝟘ⁱ _ Pε _ _ = Pε\n -}\n\nmodule _ {ℓ₁ ℓ₂ ℓᵣ} {R : 𝟘 → 𝟘 → ★₀} where\n ⟦𝟘ᵉ⟧ : ⟦Explore⟧ {ℓ₁} {ℓ₂} ℓᵣ R 𝟘ᵉ 𝟘ᵉ\n ⟦𝟘ᵉ⟧ _ εᵣ _ _ = εᵣ\n\nmodule 𝟘ⁱ = FromExploreInd 𝟘ⁱ\nopen 𝟘ⁱ public using ()\n renaming (sum to 𝟘ˢ\n ;product to 𝟘ᵖ\n ;reify to 𝟘ʳ\n ;unfocus to 𝟘ᵘ\n )\n\nmodule _ {ℓ} where\n\n 𝟘ˡ : Lookup {ℓ} 𝟘ᵉ\n 𝟘ˡ _ ()\n\n 𝟘ᶠ : Focus {ℓ} 𝟘ᵉ\n 𝟘ᶠ ((), _)\n\n module _ {{_ : UA}} where\n Σᵉ𝟘-ok : Adequate-Σ {ℓ} (Σᵉ 𝟘ᵉ)\n Σᵉ𝟘-ok _ = ! Σ𝟘-lift∘fst\n\n module _ {{_ : UA}}{{_ : FunExt}} where\n Πᵉ𝟘-ok : Adequate-Π {ℓ} (Πᵉ 𝟘ᵉ)\n Πᵉ𝟘-ok _ = ! Π𝟘-uniq _\n\nopen Adequacy _≡_\nmodule _ {{_ : UA}} where\n 𝟘ˢ-ok : Adequate-sum 𝟘ˢ\n 𝟘ˢ-ok _ = Fin0≡𝟘 ∙ ! Σ𝟘-fst\n\n adequate-sum𝟘 = 𝟘ˢ-ok\n\nmodule _ {{_ : UA}}{{_ : FunExt}} where\n 𝟘ᵖ-ok : Adequate-product 𝟘ᵖ\n 𝟘ᵖ-ok _ = Fin1≡𝟙 ∙ ! (Π𝟘-uniq₀ _)\n\n adequate-product𝟘 = 𝟘ᵖ-ok\n\nexplore𝟘 = 𝟘ᵉ\nexplore𝟘-ind = 𝟘ⁱ\nlookup𝟘 = 𝟘ˡ\nreify𝟘 = 𝟘ʳ\nfocus𝟘 = 𝟘ᶠ\nunfocus𝟘 = 𝟘ᵘ\nsum𝟘 = 𝟘ˢ\nproduct𝟘 = 𝟘ᵖ\n\n\nLift𝟘ᵉ : ∀ {m} → Explore m (Lift 𝟘)\nLift𝟘ᵉ = explore-iso (≃-sym Lift≃id) 𝟘ᵉ\n\nΣᵉLift𝟘-ok : ∀ {{_ : UA}}{{_ : FunExt}}{m} → Adequate-Σ {m} (Σᵉ Lift𝟘ᵉ)\nΣᵉLift𝟘-ok = Σ-iso-ok (≃-sym Lift≃id) {Aᵉ = 𝟘ᵉ} Σᵉ𝟘-ok\n\n-- -}\n", "meta": {"hexsha": "1fb9eba379e7e401139a13fa2492001344590bc3", "size": 1947, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Explore/Zero.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/Zero.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/Zero.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": 20.935483871, "max_line_length": 79, "alphanum_fraction": 0.5731895223, "num_tokens": 1056, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869786798663, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.5918258325064829}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Group.Instances.NProd where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Nat using (ℕ)\n\nopen import Cubical.Algebra.Group\n\nprivate variable\n ℓ : Level\n\nopen GroupStr\n\nNProd-Group : (G : (n : ℕ) → Type ℓ) → (Gstr : (n : ℕ) → GroupStr (G n)) → Group ℓ\nfst (NProd-Group G Gstr) = (n : ℕ) → G n\n1g (snd (NProd-Group G Gstr)) = λ n → 1g (Gstr n)\nGroupStr._·_ (snd (NProd-Group G Gstr)) = λ f g n → Gstr n ._·_ (f n) (g n)\ninv (snd (NProd-Group G Gstr)) = λ f n → (Gstr n).inv (f n)\nisGroup (snd (NProd-Group G Gstr)) = makeIsGroup (isSetΠ (λ _ → is-set (Gstr _)))\n (λ f g h → funExt λ n → ·Assoc (Gstr n) _ _ _)\n (λ f → funExt λ n → ·IdR (Gstr n) _)\n (λ f → funExt λ n → ·IdL (Gstr n) _)\n (λ f → funExt λ n → ·InvR (Gstr n) _)\n λ f → funExt λ n → ·InvL (Gstr n) _\n", "meta": {"hexsha": "8169e1da5fed15cc28ed752d38e4c186ee879601", "size": 1109, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/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/Group/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/Group/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": 41.0740740741, "max_line_length": 95, "alphanum_fraction": 0.4887285843, "num_tokens": 352, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357598021707, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.5918158476343973}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Categories.Equivalence.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor\nopen import Cubical.Categories.NaturalTransformation\n\nopen Precategory\nopen Functor\n\nprivate\n variable\n ℓC ℓC' ℓD ℓD' : Level\n\n-- Definition\n\nrecord isEquivalence {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'}\n (func : Functor C D) : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where\n field\n invFunc : Functor D C\n\n η : 𝟙⟨ C ⟩ ≅ᶜ invFunc ∘F func\n ε : func ∘F invFunc ≅ᶜ 𝟙⟨ D ⟩\n\nrecord _≃ᶜ_ (C : Precategory ℓC ℓC') (D : Precategory ℓD ℓD') : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where\n field\n func : Functor C D\n isEquiv : isEquivalence func\n\n", "meta": {"hexsha": "a5177b6a1272c429e7ecacc78e825832c060e4b4", "size": 813, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Equivalence/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/Categories/Equivalence/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/Categories/Equivalence/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": 25.40625, "max_line_length": 112, "alphanum_fraction": 0.6740467405, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5918158467261058}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.NType2\nopen import lib.Function2\nopen import lib.types.Group\nopen import lib.types.Sigma\nopen import lib.types.Truncation\nopen import lib.groups.Homomorphism\nopen import lib.groups.Isomorphism\nopen import lib.groups.SubgroupProp\n\nmodule lib.groups.Subgroup where\n\nmodule _ {i j} {G : Group i} (P : SubgroupProp G j) where\n private\n module G = Group G\n module P = SubgroupProp P\n\n subgroup-struct : GroupStructure P.SubEl\n subgroup-struct = record {M} where\n module M where\n ident : P.SubEl\n ident = G.ident , P.ident\n\n inv : P.SubEl → P.SubEl\n inv (g , p) = G.inv g , P.inv p\n\n comp : P.SubEl → P.SubEl → P.SubEl\n comp (g₁ , p₁) (g₂ , p₂) = G.comp g₁ g₂ , P.comp p₁ p₂\n\n abstract\n unit-l : ∀ g → comp ident g == g\n unit-l (g , _) = Subtype=-out P.subEl-prop (G.unit-l g)\n\n assoc : ∀ g₁ g₂ g₃ → comp (comp g₁ g₂) g₃ == comp g₁ (comp g₂ g₃)\n assoc (g₁ , _) (g₂ , _) (g₃ , _) = Subtype=-out P.subEl-prop (G.assoc g₁ g₂ g₃)\n\n inv-l : ∀ g → comp (inv g) g == ident\n inv-l (g , _) = Subtype=-out P.subEl-prop (G.inv-l g)\n\n Subgroup : Group (lmax i j)\n Subgroup = group _ SubEl-level subgroup-struct\n where abstract SubEl-level = Subtype-level P.subEl-prop G.El-level\n\nmodule Subgroup {i j} {G : Group i} (P : SubgroupProp G j) where\n private\n module P = SubgroupProp P\n module G = Group G\n\n grp = Subgroup P\n open Group grp public\n\n El=-out : ∀ {s₁ s₂ : El} → fst s₁ == fst s₂ → s₁ == s₂\n El=-out = Subtype=-out P.subEl-prop\n\n inject : Subgroup P →ᴳ G\n inject = record {f = fst; pres-comp = λ _ _ → idp}\n\n inject-lift : ∀ {j} {H : Group j} (φ : H →ᴳ G)\n → Π (Group.El H) (P.prop ∘ GroupHom.f φ)\n → (H →ᴳ Subgroup P)\n inject-lift {H = H} φ P-all = record {M} where\n module H = Group H\n module φ = GroupHom φ\n module M where\n f : H.El → P.SubEl\n f h = φ.f h , P-all h\n\n abstract\n pres-comp : ∀ h₁ h₂ → f (H.comp h₁ h₂) == Group.comp (Subgroup P) (f h₁) (f h₂)\n pres-comp h₁ h₂ = Subtype=-out P.subEl-prop (φ.pres-comp h₁ h₂)\n\nfull-subgroup : ∀ {i j} {G : Group i} {P : SubgroupProp G j}\n → is-fullᴳ P → Subgroup P ≃ᴳ G\nfull-subgroup {G = G} {P} full = Subgroup.inject P , is-eq _ from to-from from-to where\n from : Group.El G → Subgroup.El P\n from g = g , full g\n\n abstract\n from-to : ∀ p → from (fst p) == p\n from-to p = Subtype=-out (SubgroupProp.subEl-prop P) idp\n\n to-from : ∀ g → fst (from g) == g\n to-from g = idp\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 = Subgroup (ker-propᴳ φ)\n Ker = Ker.grp\n\n module Im = Subgroup (im-propᴳ φ)\n Im = Im.grp\n\n im-lift : G →ᴳ Im\n im-lift = Im.inject-lift φ (λ g → [ g , idp ])\n\n im-lift-is-surj : is-surjᴳ im-lift\n im-lift-is-surj (_ , s) = Trunc-fmap\n (λ {(g , p) → (g , Subtype=-out (_ , λ _ → Trunc-level) p)}) s\n\nmodule _ {i j k} {G : Group i} (P : SubgroupProp G j)\n (Q : SubgroupProp G k) where\n\n -- FIXME looks like a bad name\n Subgroup-fmap-r : P ⊆ᴳ Q → Subgroup P →ᴳ Subgroup Q\n Subgroup-fmap-r P⊆Q = group-hom (Σ-fmap-r P⊆Q)\n (λ _ _ → Subtype=-out (SubgroupProp.subEl-prop Q) idp)\n\n Subgroup-emap-r : P ⊆ᴳ Q → Q ⊆ᴳ P → Subgroup P ≃ᴳ Subgroup Q\n Subgroup-emap-r P⊆Q Q⊆P = Subgroup-fmap-r P⊆Q ,\n is-eq _ (Σ-fmap-r Q⊆P)\n (λ _ → Subtype=-out (SubgroupProp.subEl-prop Q) idp)\n (λ _ → Subtype=-out (SubgroupProp.subEl-prop P) idp)\n", "meta": {"hexsha": "230011ed9a3458dc259d19b4c5061c2d1fd17551", "size": 3570, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/groups/Subgroup.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/Subgroup.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/Subgroup.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.75, "max_line_length": 87, "alphanum_fraction": 0.5971988796, "num_tokens": 1331, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357735451834, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5918158346206108}} {"text": "{- Basic definitions using Σ-types\n\nΣ-types are defined in Core/Primitives as they are needed for Glue types.\n\nThe file contains:\n\n- Non-dependent pair types: A × B\n- Mere existence: ∃[x ∈ A] B\n- Unique existence: ∃![x ∈ A] B\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Data.Sigma.Base where\n\nopen import Cubical.Core.Primitives public\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.HITs.PropositionalTruncation.Base\n\n\n-- Non-dependent pair types\n\n_×_ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ')\nA × B = Σ A (λ _ → B)\n\ninfixr 5 _×_\n\n\n-- Mere existence\n\n∃ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')\n∃ A B = ∥ Σ A B ∥\n\ninfix 2 ∃-syntax\n\n∃-syntax : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')\n∃-syntax = ∃\n\nsyntax ∃-syntax A (λ x → B) = ∃[ x ∈ A ] B\n\n\n-- Unique existence\n\n∃! : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')\n∃! A B = isContr (Σ A B)\n\ninfix 2 ∃!-syntax\n\n∃!-syntax : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')\n∃!-syntax = ∃!\n\nsyntax ∃!-syntax A (λ x → B) = ∃![ x ∈ A ] B\n", "meta": {"hexsha": "13c9745ad8708f1171dd5014975461a78ebec59e", "size": 1102, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/Sigma/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/Sigma/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/Sigma/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": 20.7924528302, "max_line_length": 73, "alphanum_fraction": 0.5753176044, "num_tokens": 463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.5917524548987183}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Products of nullary relations\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Nullary.Product where\n\nopen import Data.Bool.Base\nopen import Data.Product\nopen import Function\nopen import Level\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------------------------------------------------------------------------\n-- Some properties which are preserved by _×_.\n\ninfixr 2 _×-reflects_ _×-dec_\n\n_×-reflects_ : ∀ {bp bq} → Reflects P bp → Reflects Q bq →\n Reflects (P × Q) (bp ∧ bq)\nofʸ p ×-reflects ofʸ q = ofʸ (p , q)\nofʸ p ×-reflects ofⁿ ¬q = ofⁿ (¬q ∘ proj₂)\nofⁿ ¬p ×-reflects _ = ofⁿ (¬p ∘ proj₁)\n\n_×-dec_ : Dec P → Dec Q → Dec (P × Q)\ndoes (p? ×-dec q?) = does p? ∧ does q?\nproof (p? ×-dec q?) = proof p? ×-reflects proof q?\n", "meta": {"hexsha": "f0655607636b9ead268b87ab775ba575fa6b0e93", "size": 1032, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Nullary/Product.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/Product.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/Product.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.1578947368, "max_line_length": 72, "alphanum_fraction": 0.492248062, "num_tokens": 285, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128672997041659, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.5917474326058552}} {"text": "module RMonads.CatofRMonads where\n\nopen import Categories\nopen import Functors\nopen import RMonads\nopen import RMonads.RMonadMorphs\n\nCatofRMonads : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(J : Fun C D) → Cat\nCatofRMonads J = record\n { Obj = RMonad J\n ; Hom = RMonadMorph\n ; iden = IdRMonadMorph _\n ; comp = CompRMonadMorph\n ; idl = idl _\n ; idr = idr _\n ; ass = λ{_ _ _ _ f g h} → ass f g h\n }\n", "meta": {"hexsha": "e57da8f51f53ee9f88d552c618b8e798327b2dc0", "size": 529, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "RMonads/CatofRMonads.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/CatofRMonads.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/CatofRMonads.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": 29.3888888889, "max_line_length": 76, "alphanum_fraction": 0.4952741021, "num_tokens": 167, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032941988938413, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.5915626096299079}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Groups.Definition\nopen import Setoids.Setoids\nopen import LogicalFormulae\nopen import Sets.EquivalenceRelations\nopen import Groups.Homomorphisms.Definition\nopen import Groups.Homomorphisms.Lemmas\nopen import Groups.Isomorphisms.Definition\nopen import Groups.Subgroups.Definition\nopen import Groups.Lemmas\n\n\nmodule Groups.FirstIsomorphismTheorem {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+G_ : A → A → A} {_+H_ : B → B → B} {G : Group S _+G_} {H : Group T _+H_} {f : A → B} (fHom : GroupHom G H f) where\n\nopen import Groups.Homomorphisms.Image fHom\nopen import Groups.Homomorphisms.Kernel fHom\nopen import Groups.Cosets G groupKernelIsSubgroup\nopen import Groups.QuotientGroup.Definition G fHom\nopen Setoid T\nopen Equivalence eq\nopen import Setoids.Subset T\n\ngroupFirstIsomorphismTheoremWellDefined : {x y : A} → groupKernelPred (Group.inverse G y +G x) → Setoid._∼_ (subsetSetoid imageGroupSubset) (f x , (x , reflexive)) (f y , (y , reflexive))\ngroupFirstIsomorphismTheoremWellDefined {x} {y} pr = transitive (symmetric (invTwice H _)) (transitive (symmetric u) (invTwice H _))\n where\n t : Setoid._∼_ T (Group.inverse H (f y) +H (f x)) (Group.0G H)\n t = transitive (transitive (Group.+WellDefined H (symmetric (homRespectsInverse fHom)) reflexive) (symmetric (GroupHom.groupHom fHom))) pr\n u : Setoid._∼_ T (Group.inverse H (Group.inverse H (f y))) (Group.inverse H (Group.inverse H (f x)))\n u = inverseWellDefined H (transferToRight' H t)\n\ngroupFirstIsomorphismTheorem : GroupsIsomorphic (cosetGroup groupKernelIsNormalSubgroup) (subgroupIsGroup H imageGroupSubgroup)\nGroupsIsomorphic.isomorphism groupFirstIsomorphismTheorem x = f x , (x , reflexive)\nGroupHom.groupHom (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem)) {x} {y} = GroupHom.groupHom fHom\nGroupHom.wellDefined (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem)) {x} {y} = groupFirstIsomorphismTheoremWellDefined {x} {y}\nSetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) = groupFirstIsomorphismTheoremWellDefined\nSetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) fx=fy = transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive fx=fy) (transitive (symmetric (GroupHom.groupHom fHom)) (transitive (GroupHom.wellDefined fHom (Group.invLeft G)) (imageOfIdentityIsIdentity fHom))))\nSetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) = groupFirstIsomorphismTheoremWellDefined\nSetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) {b , (a , fa=b)} = a , fa=b\n\ngroupFirstIsomorphismTheoremWellDefined' : {x y : A} → f (x +G (Group.inverse G y)) ∼ Group.0G H → Setoid._∼_ (subsetSetoid imageGroupSubset) (f x , (x , reflexive)) (f y , (y , reflexive))\ngroupFirstIsomorphismTheoremWellDefined' {x} {y} pr = transferToRight H (transitive (symmetric (transitive (GroupHom.groupHom fHom) (Group.+WellDefined H reflexive (homRespectsInverse fHom)))) pr)\n\ngroupFirstIsomorphismTheorem' : GroupsIsomorphic (quotientGroupByHom) (subgroupIsGroup H imageGroupSubgroup)\nGroupsIsomorphic.isomorphism groupFirstIsomorphismTheorem' a = f a , (a , reflexive)\nGroupHom.groupHom (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem')) {x} {y} = GroupHom.groupHom fHom\nGroupHom.wellDefined (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem')) {x} {y} = groupFirstIsomorphismTheoremWellDefined'\nSetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} = groupFirstIsomorphismTheoremWellDefined' {x} {y}\nSetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} fx=fy = transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive (homRespectsInverse fHom)) (transferToRight'' H fx=fy))\nSetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} = groupFirstIsomorphismTheoremWellDefined'\nSetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {b , (a , fa=b)} = a , fa=b\n", "meta": {"hexsha": "d01d8f32909e72df3ea23d1c33933750c88f0926", "size": 4507, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/FirstIsomorphismTheorem.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/FirstIsomorphismTheorem.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/FirstIsomorphismTheorem.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": 86.6730769231, "max_line_length": 354, "alphanum_fraction": 0.7865542489, "num_tokens": 1383, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711908591638, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.5915445370371776}} {"text": "open import Agda.Primitive using (Level; lsuc)\n\nvariable\n ℓ p : Level\n A B : Set ℓ\n x y z : A\n\npostulate\n easy : A\n\nrecord R a : Set (lsuc a) where\n field\n _≡_ : {A : Set a} → A → A → Set a\n\nmodule _ (r : ∀ ℓ → R ℓ) where\n\n open module R′ {ℓ} = R (r ℓ)\n\n postulate\n refl : (x : A) → x ≡ x\n cong : (f : A → B) → x ≡ y → f x ≡ f y\n subst : (P : A → Set p) → x ≡ y → P x → P y\n trans : x ≡ y → y ≡ z → x ≡ z\n elim : (P : {x y : A} → x ≡ y → Set p) →\n (∀ x → P (refl x)) →\n (x≡y : x ≡ y) → P x≡y\n elim-refl : (P : {x y : A} → x ≡ y → Set p)\n (r : ∀ x → P (refl x)) →\n elim P r (refl x) ≡ r x\n\n [subst≡]≡[trans≡trans] :\n {p : x ≡ y} {q : x ≡ x} {r : y ≡ y} →\n (subst (λ z → z ≡ z) p q ≡ r)\n ≡\n (trans q p ≡ trans p r)\n [subst≡]≡[trans≡trans] {p = p} {q} {r} = elim\n (λ {x y} p → {q : x ≡ x} {r : y ≡ y} →\n (subst (λ z → z ≡ z) p q ≡ r)\n ≡\n (trans q p ≡ trans p r))\n (λ _ → easy)\n p\n\n [subst≡]≡[trans≡trans]-refl :\n {q r : x ≡ x} →\n [subst≡]≡[trans≡trans] {p = refl x} {q = q} {r = r} ≡\n easy\n [subst≡]≡[trans≡trans]-refl {q = q} {r = r} =\n cong (λ f → f {q = q} {r = r})\n (elim-refl (λ {x y} _ → {q : x ≡ x} {r : y ≡ y} → _) _)\n", "meta": {"hexsha": "f13915f46d54fabf71ab6da84e876e9512118faf", "size": 1332, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue3960a.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/Issue3960a.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/Issue3960a.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.1176470588, "max_line_length": 61, "alphanum_fraction": 0.3701201201, "num_tokens": 622, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711908591638, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5915445263170327}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\nmodule homotopy.AnyUniversalCoverIsPathSet {i} (X : Ptd i) where\n\nprivate\n a₁ = pt X\n\npath-set-is-universal : is-universal (path-set-cover X)\npath-set-is-universal = has-level-in ([ pt X , idp₀ ] ,\n Trunc-elim\n {P = λ xp₀ → [ pt X , idp₀ ] == xp₀}\n (λ{(x , p₀) → Trunc-elim\n {P = λ p₀ → [ pt X , idp₀ ] == [ x , p₀ ]}\n (λ p → ap [_] $ pair= p (lemma p))\n p₀ }))\n where\n lemma : ∀ {x} (p : pt X == x) → idp₀ == [ p ] [ (pt X =₀_) ↓ p ]\n lemma idp = idp\n\nmodule _ {j} (univ-cov : ⊙UniversalCover X j) where\n private\n module univ-cov = ⊙UniversalCover univ-cov\n instance _ = univ-cov.is-univ\n\n -- One-to-one mapping between the universal cover\n -- and the truncated path spaces from one point.\n\n [path] : ∀ (a⇑₁ a⇑₂ : univ-cov.TotalSpace) → a⇑₁ =₀ a⇑₂\n [path] a⇑₁ a⇑₂ = –> (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ])\n (contr-has-all-paths [ a⇑₁ ] [ a⇑₂ ])\n\n abstract\n [path]-has-all-paths :\n ∀ {a⇑₁ a⇑₂ : univ-cov.TotalSpace}\n → has-all-paths (a⇑₁ =₀ a⇑₂)\n [path]-has-all-paths {a⇑₁} {a⇑₂} =\n transport has-all-paths (ua (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ])) $\n contr-has-all-paths {{has-level-apply (raise-level -2 univ-cov.is-univ) [ a⇑₁ ] [ a⇑₂ ]}}\n\n to : ∀ {a₂} → univ-cov.Fiber a₂ → a₁ =₀ a₂\n to {a₂} a⇑₂ = ap₀ fst ([path] (a₁ , univ-cov.pt) (a₂ , a⇑₂))\n\n from : ∀ {a₂} → a₁ =₀ a₂ → univ-cov.Fiber a₂\n from p = cover-trace univ-cov.cov univ-cov.pt p\n\n abstract\n to-from : ∀ {a₂} (p : a₁ =₀ a₂) → to (from p) == p\n to-from = Trunc-elim\n (λ p → lemma p)\n where\n lemma : ∀ {a₂} (p : a₁ == a₂) → to (from [ p ]) == [ p ]\n lemma idp =\n ap₀ fst ([path] (a₁ , univ-cov.pt) (a₁ , univ-cov.pt))\n =⟨ ap (ap₀ fst)\n $ [path]-has-all-paths\n ([path] (a₁ , univ-cov.pt) (a₁ , univ-cov.pt))\n (idp₀ :> ((a₁ , univ-cov.pt) =₀ (a₁ , univ-cov.pt))) ⟩\n (idp₀ :> (a₁ =₀ a₁))\n ∎\n\n from-to : ∀ {a₂} (a⇑₂ : univ-cov.Fiber a₂) → from (to a⇑₂) == a⇑₂\n from-to {a₂} a⇑₂ = Trunc-elim\n {{λ p → =-preserves-level\n {x = from (ap₀ fst p)}\n {y = a⇑₂}\n univ-cov.Fiber-is-set}}\n (λ p → to-transp $ snd= p)\n ([path] (a₁ , univ-cov.pt) (a₂ , a⇑₂))\n\n theorem : ∀ a₂ → univ-cov.Fiber a₂ ≃ (a₁ =₀ a₂)\n theorem a₂ = to , is-eq _ from to-from from-to\n", "meta": {"hexsha": "928acf17701ba255d4d70fb01317e4f04145696e", "size": 2491, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/AnyUniversalCoverIsPathSet.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/AnyUniversalCoverIsPathSet.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/AnyUniversalCoverIsPathSet.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": 33.6621621622, "max_line_length": 99, "alphanum_fraction": 0.4877559213, "num_tokens": 1014, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711794579723, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.5915445237423509}} {"text": "open import Data.Product using ( _×_ ; _,_ )\nopen import Relation.Unary using ( _∈_ )\nopen import Web.Semantic.DL.ABox using ( ABox ; ε ; _,_ ; _∼_ ; _∈₁_ ; _∈₂_ )\nopen import Web.Semantic.DL.ABox.Interp using ( ⌊_⌋ ; ind )\nopen import Web.Semantic.DL.ABox.Model using ( _⊨a_ )\nopen import Web.Semantic.DL.Concept.Model using ( ⟦⟧₁-resp-≈ )\nopen import Web.Semantic.DL.Concept.Skolemization using ( CSkolems ; cskolem ; cskolem-sound )\nopen import Web.Semantic.DL.FOL using ( Formula ; true ; _∧_ ; _∈₁_ ; _∈₂_ ; _∼_ )\nopen import Web.Semantic.DL.FOL.Model using ( _⊨f_ )\nopen import Web.Semantic.DL.Role.Skolemization using ( rskolem ; rskolem-sound )\nopen import Web.Semantic.DL.Role.Model using ( ⟦⟧₂-resp-≈ )\nopen import Web.Semantic.DL.Signature using ( Signature )\nopen import Web.Semantic.Util using ( True ; tt )\n\nmodule Web.Semantic.DL.ABox.Skolemization {Σ : Signature} {X : Set} where\n\naskolem : ∀ {Δ} → (X → Δ) → ABox Σ X → Formula Σ Δ\naskolem i ε = true\naskolem i (A , B) = (askolem i A) ∧ (askolem i B)\naskolem i (x ∼ y) = i x ∼ i y\naskolem i (x ∈₁ c) = i x ∈₁ c\naskolem i ((x , y) ∈₂ r) = (i x , i y) ∈₂ r\n\naskolem-sound : ∀ I A → (⌊ I ⌋ ⊨f askolem (ind I) A) → (I ⊨a A)\naskolem-sound I ε _ = tt\naskolem-sound I (A , B) (I⊨A , I⊨B) = (askolem-sound I A I⊨A , askolem-sound I B I⊨B)\naskolem-sound I (x ∼ y) I⊨x∼y = I⊨x∼y\naskolem-sound I (x ∈₁ c) I⊨x∈c = I⊨x∈c\naskolem-sound I ((x , y) ∈₂ r) I⊨xy∈r = I⊨xy∈r\n", "meta": {"hexsha": "f62b76fd7a8fd6734497adf5db0b29185b2a0437", "size": 1422, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Web/Semantic/DL/ABox/Skolemization.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/Skolemization.agda", "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "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/Skolemization.agda", "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "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": 47.4, "max_line_length": 94, "alphanum_fraction": 0.6490857947, "num_tokens": 618, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.849971175657575, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.5915445103772878}} {"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nopen import Fragment.Algebra.Signature\n\nmodule Fragment.Algebra.Algebra (Σ : Signature) where\n\nopen import Level using (Level; _⊔_; suc)\nopen import Data.Vec using (Vec)\nopen import Data.Vec.Relation.Binary.Pointwise.Inductive using (Pointwise)\nopen import Relation.Binary using (Setoid; Rel; IsEquivalence)\n\nprivate\n variable\n a ℓ : Level\n\nmodule _ (S : Setoid a ℓ) where\n\n open import Data.Vec.Relation.Binary.Equality.Setoid S using (_≋_)\n\n open Setoid S renaming (Carrier to A)\n\n Interpretation : Set a\n Interpretation = ∀ {arity} → (f : ops Σ arity) → Vec A arity → A\n\n Congruence : Interpretation → Set (a ⊔ ℓ)\n Congruence ⟦_⟧ = ∀ {arity}\n → (f : ops Σ arity)\n → ∀ {xs ys} → Pointwise _≈_ xs ys → ⟦ f ⟧ xs ≈ ⟦ f ⟧ ys\n\n record IsAlgebra : Set (a ⊔ ℓ) where\n field\n ⟦_⟧ : Interpretation\n ⟦⟧-cong : Congruence ⟦_⟧\n\nrecord Algebra : Set (suc a ⊔ suc ℓ) where\n constructor algebra\n field\n ∥_∥/≈ : Setoid a ℓ\n ∥_∥/≈-isAlgebra : IsAlgebra ∥_∥/≈\n\n ∥_∥ : Set a\n ∥_∥ = Setoid.Carrier ∥_∥/≈\n\n infix 10 _⟦_⟧_\n\n _⟦_⟧_ : Interpretation (∥_∥/≈)\n _⟦_⟧_ = IsAlgebra.⟦_⟧ ∥_∥/≈-isAlgebra\n\n _⟦_⟧-cong : Congruence (∥_∥/≈) (_⟦_⟧_)\n _⟦_⟧-cong = IsAlgebra.⟦⟧-cong ∥_∥/≈-isAlgebra\n\n ≈[_] : Rel ∥_∥ ℓ\n ≈[_] = Setoid._≈_ ∥_∥/≈\n\n ≈[_]-isEquivalence : IsEquivalence ≈[_]\n ≈[_]-isEquivalence = Setoid.isEquivalence ∥_∥/≈\n\nopen Algebra public\n\ninfix 5 ≈-syntax\n\n≈-syntax : (A : Algebra {a} {ℓ}) → ∥ A ∥ → ∥ A ∥ → Set ℓ\n≈-syntax A x y = Setoid._≈_ ∥ A ∥/≈ x y\n\nsyntax ≈-syntax A x y = x =[ A ] y\n", "meta": {"hexsha": "ca3b4764d5839912a046027ff6147b038f81c38c", "size": 1614, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Algebra/Algebra.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/Algebra.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/Algebra.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": 24.4545454545, "max_line_length": 74, "alphanum_fraction": 0.5978934325, "num_tokens": 680, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84997116805678, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.5915445050874514}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Concrete.Properties where\n\nopen import Data.Unit.Polymorphic\nopen import Function.Equality using (Π; _⟨$⟩_; const; _∘_)\nopen import Level\nopen import Relation.Binary using (Setoid)\nimport Relation.Binary.Reasoning.Setoid as SR\n\nopen import Categories.Adjoint using (_⊣_; Adjoint)\nopen import Categories.Category.Core using (Category)\nopen import Categories.Category.Instance.Setoids using (Setoids)\nopen import Categories.Category.Concrete\nopen import Categories.Functor.Core using (Functor)\nopen import Categories.Functor.Representable using (Representable)\nopen import Categories.Functor.Properties using (Faithful)\nimport Categories.Morphism.Reasoning as MR\nopen import Categories.NaturalTransformation using (NaturalTransformation; ntHelper)\n\nopen Concrete\n\n⊣⇒Representable : {o ℓ e : Level} (C : Category o ℓ e) (conc : Concrete C ℓ e) → (F : Functor (Setoids ℓ e) C) →\n F ⊣ concretize conc → RepresentablyConcrete C\n⊣⇒Representable {_} {ℓ} {e} C conc F L = record\n { conc = conc\n ; representable = record\n { A = F.₀ OneS\n ; Iso = record\n { F⇒G = ntHelper record\n { η = λ X → record\n { _⟨$⟩_ = λ x → L.counit.η X C.∘ F.₁ (const x)\n ; cong = λ i≈j → C.∘-resp-≈ʳ (F.F-resp-≈ λ _ → i≈j)\n }\n ; commute = λ {X} {Y} f {x} {y} x≈y →\n let open C.HomReasoning in begin\n L.counit.η Y C.∘ F.₁ (const (U.₁ f ⟨$⟩ x)) ≈⟨ refl⟩∘⟨ F.F-resp-≈ (λ _ → Π.cong (U.₁ f) x≈y) ⟩\n L.counit.η Y C.∘ F.₁ (U.F₁ f ∘ const y) ≈⟨ pushʳ F.homomorphism ⟩\n ((L.counit.η Y C.∘ F.₁ (U.₁ f)) C.∘ F.₁ (const y)) ≈⟨ pushˡ (commute L.counit f) ⟩\n f C.∘ L.counit.η X C.∘ F.₁ (const y) ≈˘⟨ C.identityʳ ⟩\n (f C.∘ L.counit.η X C.∘ F.₁ (const y)) C.∘ C.id ∎\n }\n ; F⇐G = ntHelper record\n { η = λ c → record\n { _⟨$⟩_ = λ 1⇒c → U.₁ 1⇒c ⟨$⟩ η1\n ; cong = λ i≈j → U.F-resp-≈ i≈j (Setoid.refl (U.₀ (F.₀ OneS)))\n }\n ; commute = λ {X} {Y} f {x} {y} x≈y →\n let module CH = C.HomReasoning in\n let open SR (U.₀ Y) in\n begin\n U.₁ ((f C.∘ x) C.∘ C.id) ⟨$⟩ η1 ≈⟨ U.F-resp-≈ (C.identityʳ CH.○ (CH.refl⟩∘⟨ x≈y)) Srefl ⟩\n U.₁ (f C.∘ y) ⟨$⟩ η1 ≈⟨ U.homomorphism Srefl ⟩\n U.₁ f ⟨$⟩ (U.₁ y ⟨$⟩ η1) ∎\n }\n ; iso = λ X → record\n { isoˡ = λ {x} {y} x≈y → Setoid.trans (U.₀ X) (L.LRadjunct≈id {OneS} {X} {const x} tt) x≈y\n ; isoʳ = λ {1⇒x} {1⇒y} x≈y →\n let open C.HomReasoning in begin\n L.counit.η X C.∘ F.₁ (const (U.₁ 1⇒x ⟨$⟩ η1)) ≈⟨ (refl⟩∘⟨ F.F-resp-≈ λ _ → U.F-resp-≈ x≈y Srefl) ⟩\n L.counit.η X C.∘ F.₁ (U.₁ 1⇒y ∘ L.unit.η OneS) ≈⟨ L.RLadjunct≈id {OneS} {X} {1⇒y} ⟩\n 1⇒y ∎\n }\n }\n }\n }\n where\n module C = Category C\n module U = Functor (concretize conc)\n module F = Functor F\n module L = Adjoint L\n open NaturalTransformation\n open MR C\n -- Is this somewhere else? Should it be?\n OneS : Setoid ℓ e\n OneS = record { Carrier = ⊤ {ℓ} ; _≈_ = λ _ _ → ⊤ {e}}\n η1 : Setoid.Carrier (U.₀ (F.₀ OneS))\n η1 = L.unit.η OneS ⟨$⟩ tt\n Srefl = Setoid.refl (U.₀ (F.₀ OneS))\n", "meta": {"hexsha": "5d305df6a1d79fa01b05db2dda252c7f827a2f87", "size": 3257, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Concrete/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/Category/Concrete/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/Category/Concrete/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": 40.7125, "max_line_length": 114, "alphanum_fraction": 0.546208167, "num_tokens": 1339, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84594244507642, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5915289999827678}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Functor hiding (id)\n\n-- Coimit of a Cocone over a Functor F : J → C\nmodule Categories.Diagram.Colimit\n {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where\n\nprivate\n module C = Category C\n module J = Category J\nopen C\nopen HomReasoning\nopen Functor F\n\nopen import Level\nopen import Data.Product using (proj₂)\n\nopen import Categories.Category.Construction.Cocones F renaming (Cocone⇒ to _⇨_)\nopen import Categories.Object.Initial as I hiding (up-to-iso; transport-by-iso)\nopen import Categories.Morphism.Reasoning C\nopen import Categories.Morphism C\nopen import Categories.Morphism Cocones as MC using () renaming (_≅_ to _⇔_)\n\nprivate\n variable\n K K′ : Cocone\n A B : J.Obj\n X Y Z : Obj\n q : K ⇨ K′\n\n-- A Colimit is an Initial object in the category of Cocones\n-- (This could be unpacked...)\nrecord Colimit : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where\n field\n initial : Initial Cocones\n\n module initial = Initial initial\n\n open initial using () renaming (⊥ to colimit) public\n open Cocone colimit hiding (coapex) renaming (N to coapex; ψ to proj; commute to colimit-commute) public\n\n rep-cocone : ∀ K → colimit ⇨ K\n rep-cocone K = initial.! {K}\n\n rep : ∀ K → coapex ⇒ Cocone.N K\n rep K = arr\n where open _⇨_ (rep-cocone K)\n\n unrep : coapex ⇒ X → Cocone\n unrep f = record {\n coapex = record\n { ψ = λ A → f ∘ proj A\n ; commute = λ g → pullʳ (colimit-commute g)\n }\n }\n\n coconify : (f : coapex ⇒ X) → colimit ⇨ unrep f\n coconify f = record\n { arr = f\n ; commute = refl\n }\n\n commute : rep K ∘ proj A ≈ Cocone.ψ K A\n commute {K = K} = _⇨_.commute (rep-cocone K)\n\n unrep-cone : (colimit ⇨ K) → Cocone\n unrep-cone f = unrep (_⇨_.arr f)\n\n g-η : ∀ {f : coapex ⇒ X} → rep (unrep f) ≈ f\n g-η {f = f} = initial.!-unique (coconify f)\n\n η-cocone : Cocones [ rep-cocone colimit ≈ Category.id Cocones ]\n η-cocone = initial.⊥-id (rep-cocone colimit)\n\n η : rep colimit ≈ id\n η = η-cocone\n\n rep-cocone∘ : Cocones [ Cocones [ q ∘ rep-cocone K ] ≈ rep-cocone K′ ]\n rep-cocone∘ {K = K} {q = q} = Equiv.sym (initial.!-unique (Cocones [ q ∘ rep-cocone K ]))\n\n rep∘ : ∀ {q : K ⇨ K′} → _⇨_.arr q ∘ rep K ≈ rep K′\n rep∘ {q = q} = rep-cocone∘ {q = q}\n\n rep-cone-self-id : Cocones [ rep-cocone colimit ≈ Cocones.id ]\n rep-cone-self-id = initial.!-unique ( Cocones.id )\n\n rep-self-id : rep colimit ≈ id\n rep-self-id = rep-cone-self-id\n\nopen Colimit\n\nup-to-iso-cone : (L₁ L₂ : Colimit) → colimit L₁ ⇔ colimit L₂\nup-to-iso-cone L₁ L₂ = I.up-to-iso Cocones (initial L₁) (initial L₂)\n\nup-to-iso : (L₁ L₂ : Colimit) → coapex L₁ ≅ coapex L₂\nup-to-iso L₁ L₂ = iso-cocone⇒iso-coapex (up-to-iso-cone L₁ L₂)\n\ntransport-by-iso-cocone : (C : Colimit) → colimit C ⇔ K → Colimit\ntransport-by-iso-cocone C C⇿K = record\n { initial = I.transport-by-iso Cocones (initial C) C⇿K\n }\n\ntransport-by-iso : (C : Colimit) → coapex C ≅ X → Colimit\ntransport-by-iso C C≅X = transport-by-iso-cocone C (proj₂ p)\n where p = cocone-resp-iso (colimit C) C≅X\n", "meta": {"hexsha": "ce5f839cdfd5ea0cab23db6c49ec0b7a20653666", "size": 3130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Colimit.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/Colimit.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/Colimit.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": 28.9814814815, "max_line_length": 106, "alphanum_fraction": 0.6332268371, "num_tokens": 1170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085146, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5915289945510255}} {"text": "{-\n\nThis file contains:\n\n- Definition of set truncations\n\n-}\n{-# OPTIONS --safe #-}\nmodule Cubical.HITs.SetTruncation.Base where\n\nopen import Cubical.Core.Primitives\nopen import Cubical.Foundations.Pointed\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\n-- Pointed version\n∥_∥₂∙ : ∀ {ℓ} (A : Pointed ℓ) → Pointed ℓ\nfst ∥ A ∥₂∙ = ∥ fst A ∥₂\nsnd ∥ A ∥₂∙ = ∣ pt A ∣₂\n", "meta": {"hexsha": "033d8650632c431ce06d438397872b50a0036999", "size": 478, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/SetTruncation/Base.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/HITs/SetTruncation/Base.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/HITs/SetTruncation/Base.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": 19.9166666667, "max_line_length": 50, "alphanum_fraction": 0.6087866109, "num_tokens": 203, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8459424256566558, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.5915289704979366}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Vectors\n------------------------------------------------------------------------\n\nmodule Data.Vec where\n\nopen import Category.Applicative\nopen import Data.Nat\nopen import Data.Fin using (Fin; zero; suc)\nopen import Data.List as List using (List)\nopen import Data.Product as Prod using (∃; ∃₂; _×_; _,_)\nopen import Function\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n\n------------------------------------------------------------------------\n-- Types\n\ninfixr 5 _∷_\n\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\ninfix 4 _∈_\n\ndata _∈_ {a} {A : Set a} : A → {n : ℕ} → Vec A n → Set a where\n here : ∀ {n} {x} {xs : Vec A n} → x ∈ x ∷ xs\n there : ∀ {n} {x y} {xs : Vec A n} (x∈xs : x ∈ xs) → x ∈ y ∷ xs\n\ninfix 4 _[_]=_\n\ndata _[_]=_ {a} {A : Set a} :\n {n : ℕ} → Vec A n → Fin n → A → Set a where\n here : ∀ {n} {x} {xs : Vec A n} → x ∷ xs [ zero ]= x\n there : ∀ {n} {i} {x y} {xs : Vec A n}\n (xs[i]=x : xs [ i ]= x) → y ∷ xs [ suc i ]= x\n\n------------------------------------------------------------------------\n-- Some operations\n\nhead : ∀ {a n} {A : Set a} → Vec A (1 + n) → A\nhead (x ∷ xs) = x\n\ntail : ∀ {a n} {A : Set a} → Vec A (1 + n) → Vec A n\ntail (x ∷ xs) = xs\n\n[_] : ∀ {a} {A : Set a} → A → Vec A 1\n[ x ] = x ∷ []\n\ninfixr 5 _++_\n\n_++_ : ∀ {a m n} {A : Set a} → Vec A m → Vec A n → Vec A (m + n)\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\ninfixl 4 _⊛_\n\n_⊛_ : ∀ {a b n} {A : Set a} {B : Set b} →\n Vec (A → B) n → Vec A n → Vec B n\n[] ⊛ _ = []\n(f ∷ fs) ⊛ (x ∷ xs) = f x ∷ (fs ⊛ xs)\n\nreplicate : ∀ {a n} {A : Set a} → A → Vec A n\nreplicate {n = zero} x = []\nreplicate {n = suc n} x = x ∷ replicate x\n\napplicative : ∀ {a n} → RawApplicative (λ (A : Set a) → Vec A n)\napplicative = record\n { pure = replicate\n ; _⊛_ = _⊛_\n }\n\nmap : ∀ {a b n} {A : Set a} {B : Set b} →\n (A → B) → Vec A n → Vec B n\nmap f xs = replicate f ⊛ xs\n\nzipWith : ∀ {a b c n} {A : Set a} {B : Set b} {C : Set c} →\n (A → B → C) → Vec A n → Vec B n → Vec C n\nzipWith _⊕_ xs ys = replicate _⊕_ ⊛ xs ⊛ ys\n\nzip : ∀ {a b n} {A : Set a} {B : Set b} →\n Vec A n → Vec B n → Vec (A × B) n\nzip = zipWith _,_\n\nunzip : ∀ {a b n} {A : Set a} {B : Set b} →\n Vec (A × B) n → Vec A n × Vec B n\nunzip [] = [] , []\nunzip ((x , y) ∷ xys) = Prod.map (_∷_ x) (_∷_ y) (unzip xys)\n\nfoldr : ∀ {a b} {A : Set a} (B : ℕ → Set b) {m} →\n (∀ {n} → A → B n → B (suc n)) →\n B zero →\n Vec A m → B m\nfoldr b _⊕_ n [] = n\nfoldr b _⊕_ n (x ∷ xs) = x ⊕ foldr b _⊕_ n xs\n\nfoldr₁ : ∀ {a} {A : Set a} {m} →\n (A → A → A) → Vec A (suc m) → A\nfoldr₁ _⊕_ (x ∷ []) = x\nfoldr₁ _⊕_ (x ∷ y ∷ ys) = x ⊕ foldr₁ _⊕_ (y ∷ ys)\n\nfoldl : ∀ {a b} {A : Set a} (B : ℕ → Set b) {m} →\n (∀ {n} → B n → A → B (suc n)) →\n B zero →\n Vec A m → B m\nfoldl b _⊕_ n [] = n\nfoldl b _⊕_ n (x ∷ xs) = foldl (λ n → b (suc n)) _⊕_ (n ⊕ x) xs\n\nfoldl₁ : ∀ {a} {A : Set a} {m} →\n (A → A → A) → Vec A (suc m) → A\nfoldl₁ _⊕_ (x ∷ xs) = foldl _ _⊕_ x xs\n\nconcat : ∀ {a m n} {A : Set a} →\n Vec (Vec A m) n → Vec A (n * m)\nconcat [] = []\nconcat (xs ∷ xss) = xs ++ concat xss\n\nsplitAt : ∀ {a} {A : Set a} m {n} (xs : Vec A (m + n)) →\n ∃₂ λ (ys : Vec A m) (zs : Vec A n) → xs ≡ ys ++ zs\nsplitAt zero xs = ([] , xs , refl)\nsplitAt (suc m) (x ∷ xs) with splitAt m xs\nsplitAt (suc m) (x ∷ .(ys ++ zs)) | (ys , zs , refl) =\n ((x ∷ ys) , zs , refl)\n\ntake : ∀ {a} {A : Set a} m {n} → Vec A (m + n) → Vec A m\ntake m xs with splitAt m xs\ntake m .(ys ++ zs) | (ys , zs , refl) = ys\n\ndrop : ∀ {a} {A : Set a} m {n} → Vec A (m + n) → Vec A n\ndrop m xs with splitAt m xs\ndrop m .(ys ++ zs) | (ys , zs , refl) = zs\n\ngroup : ∀ {a} {A : Set a} n k (xs : Vec A (n * k)) →\n ∃ λ (xss : Vec (Vec A k) n) → xs ≡ concat xss\ngroup zero k [] = ([] , refl)\ngroup (suc n) k xs with splitAt k xs\ngroup (suc n) k .(ys ++ zs) | (ys , zs , refl) with group n k zs\ngroup (suc n) k .(ys ++ concat zss) | (ys , ._ , refl) | (zss , refl) =\n ((ys ∷ zss) , refl)\n\n-- Splits a vector into two \"halves\".\n\nsplit : ∀ {a n} {A : Set a} → Vec A n → Vec A ⌈ n /2⌉ × Vec A ⌊ n /2⌋\nsplit [] = ([] , [])\nsplit (x ∷ []) = (x ∷ [] , [])\nsplit (x ∷ y ∷ xs) = Prod.map (_∷_ x) (_∷_ y) (split xs)\n\nreverse : ∀ {a n} {A : Set a} → Vec A n → Vec A n\nreverse {A = A} = foldl (Vec A) (λ rev x → x ∷ rev) []\n\nsum : ∀ {n} → Vec ℕ n → ℕ\nsum = foldr _ _+_ 0\n\ntoList : ∀ {a n} {A : Set a} → Vec A n → List A\ntoList [] = List.[]\ntoList (x ∷ xs) = List._∷_ x (toList xs)\n\nfromList : ∀ {a} {A : Set a} → (xs : List A) → Vec A (List.length xs)\nfromList List.[] = []\nfromList (List._∷_ x xs) = x ∷ fromList xs\n\n-- Snoc.\n\ninfixl 5 _∷ʳ_\n\n_∷ʳ_ : ∀ {a n} {A : Set a} → Vec A n → A → Vec A (1 + n)\n[] ∷ʳ y = [ y ]\n(x ∷ xs) ∷ʳ y = x ∷ (xs ∷ʳ y)\n\ninitLast : ∀ {a n} {A : Set a} (xs : Vec A (1 + n)) →\n ∃₂ λ (ys : Vec A n) (y : A) → xs ≡ ys ∷ʳ y\ninitLast {n = zero} (x ∷ []) = ([] , x , refl)\ninitLast {n = suc n} (x ∷ xs) with initLast xs\ninitLast {n = suc n} (x ∷ .(ys ∷ʳ y)) | (ys , y , refl) =\n ((x ∷ ys) , y , refl)\n\ninit : ∀ {a n} {A : Set a} → Vec A (1 + n) → Vec A n\ninit xs with initLast xs\ninit .(ys ∷ʳ y) | (ys , y , refl) = ys\n\nlast : ∀ {a n} {A : Set a} → Vec A (1 + n) → A\nlast xs with initLast xs\nlast .(ys ∷ʳ y) | (ys , y , refl) = y\n\ninfixl 1 _>>=_\n\n_>>=_ : ∀ {a b m n} {A : Set a} {B : Set b} →\n Vec A m → (A → Vec B n) → Vec B (m * n)\nxs >>= f = concat (map f xs)\n\ninfixl 4 _⊛*_\n\n_⊛*_ : ∀ {a b m n} {A : Set a} {B : Set b} →\n Vec (A → B) m → Vec A n → Vec B (m * n)\nfs ⊛* xs = fs >>= λ f → map f xs\n\n-- Interleaves the two vectors.\n\ninfixr 5 _⋎_\n\n_⋎_ : ∀ {a m n} {A : Set a} →\n Vec A m → Vec A n → Vec A (m +⋎ n)\n[] ⋎ ys = ys\n(x ∷ xs) ⋎ ys = x ∷ (ys ⋎ xs)\n\n-- A lookup function.\n\nlookup : ∀ {a n} {A : Set a} → Fin n → Vec A n → A\nlookup zero (x ∷ xs) = x\nlookup (suc i) (x ∷ xs) = lookup i xs\n\n-- An inverse of flip lookup.\n\ntabulate : ∀ {n a} {A : Set a} → (Fin n → A) → Vec A n\ntabulate {zero} f = []\ntabulate {suc n} f = f zero ∷ tabulate (f ∘ suc)\n\n-- Update.\n\ninfixl 6 _[_]≔_\n\n_[_]≔_ : ∀ {a n} {A : Set a} → Vec A n → Fin n → A → Vec A n\n[] [ () ]≔ y\n(x ∷ xs) [ zero ]≔ y = y ∷ xs\n(x ∷ xs) [ suc i ]≔ y = x ∷ xs [ i ]≔ y\n\n-- Generates a vector containing all elements in Fin n. This function\n-- is not placed in Data.Fin because Data.Vec depends on Data.Fin.\n--\n-- The implementation was suggested by Conor McBride (\"Fwd: how to\n-- count 0..n-1\", http://thread.gmane.org/gmane.comp.lang.agda/2554).\n\nallFin : ∀ n → Vec (Fin n) n\nallFin _ = tabulate id\n", "meta": {"hexsha": "923ed2c82ddbcccd292833380e357282c01b5bb9", "size": 6917, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Vec.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.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.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.1856540084, "max_line_length": 72, "alphanum_fraction": 0.4384848923, "num_tokens": 2940, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.7662936377487305, "lm_q1q2_score": 0.591458761731809}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Bool.Base where\n\nopen import Level\nopen import Agda.Builtin.Bool using (Bool; true; false) public\nopen import Data.Unit\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{-# INLINE bool #-}\n\nbool′ : A → A → Bool → A\nbool′ = bool\n{-# INLINE bool′ #-}\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 p then x else y = bool y x p\n{-# INLINE if_then_else_ #-}\n\n", "meta": {"hexsha": "9dab142c1b3e1259175007a53e8aa5f40a26d4fe", "size": 710, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Bool/Base.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/Bool/Base.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/Bool/Base.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.1891891892, "max_line_length": 78, "alphanum_fraction": 0.6197183099, "num_tokens": 245, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5914558172107853}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Bicategory.Monad.Properties where\n\nopen import Categories.Category\nopen import Categories.Bicategory.Instance.Cats\nopen import Categories.NaturalTransformation using (NaturalTransformation)\nopen import Categories.Functor using (Functor)\n\nimport Categories.Bicategory.Monad as BicatMonad\nimport Categories.Monad as ElemMonad\n\nimport Categories.Morphism.Reasoning as MR\n\n--------------------------------------------------------------------------------\n-- Bicategorical Monads in Cat are the same as the more elementary\n-- definition of Monads.\n\nCatMonad⇒Monad : ∀ {o ℓ e} → (T : BicatMonad.Monad (Cats o ℓ e)) → ElemMonad.Monad (BicatMonad.Monad.C T)\nCatMonad⇒Monad T = record\n { F = T.T\n ; η = T.η\n ; μ = T.μ\n ; assoc = λ {X} → begin\n η T.μ X ∘ F₁ T.T (η T.μ X) ≈⟨ intro-ids ⟩\n (η T.μ X ∘ (F₁ T.T (η T.μ X) ∘ id) ∘ id) ≈⟨ T.assoc ⟩\n (η T.μ X ∘ F₁ T.T id ∘ η T.μ (F₀ T.T X)) ≈⟨ ∘-resp-≈ʳ (∘-resp-≈ˡ (identity T.T) ○ identityˡ) ⟩\n η T.μ X ∘ η T.μ (F₀ T.T X) ∎\n ; sym-assoc = λ {X} → begin\n η T.μ X ∘ η T.μ (F₀ T.T X) ≈⟨ intro-F-ids ⟩\n η T.μ X ∘ (F₁ T.T id ∘ η T.μ (F₀ T.T X)) ∘ id ≈⟨ T.sym-assoc ⟩\n η T.μ X ∘ F₁ T.T (η T.μ X) ∘ id ≈⟨ ∘-resp-≈ʳ identityʳ ⟩\n η T.μ X ∘ F₁ T.T (η T.μ X) ∎\n ; identityˡ = λ {X} → begin\n η T.μ X ∘ F₁ T.T (η T.η X) ≈⟨ intro-ids ⟩\n η T.μ X ∘ (F₁ T.T (η T.η X) ∘ id) ∘ id ≈⟨ T.identityˡ ⟩\n id ∎\n ; identityʳ = λ {X} → begin\n η T.μ X ∘ η T.η (F₀ T.T X) ≈⟨ intro-F-ids ⟩\n η T.μ X ∘ (F₁ T.T id ∘ η T.η (F₀ T.T X)) ∘ id ≈⟨ T.identityʳ ⟩\n id ∎\n }\n where\n module T = BicatMonad.Monad T\n open Category (BicatMonad.Monad.C T)\n open HomReasoning\n open Equiv\n open MR (BicatMonad.Monad.C T)\n\n open NaturalTransformation\n open Functor\n\n intro-ids : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → f ∘ g ≈ f ∘ (g ∘ id) ∘ id\n intro-ids = ⟺ (∘-resp-≈ʳ identityʳ) ○ ⟺ (∘-resp-≈ʳ identityʳ)\n\n intro-F-ids : ∀ {X Y Z} {f : F₀ T.T Y ⇒ Z} {g : X ⇒ F₀ T.T Y} → f ∘ g ≈ f ∘ (F₁ T.T id ∘ g) ∘ id\n intro-F-ids = ∘-resp-≈ʳ (⟺ identityˡ ○ ⟺ (∘-resp-≈ˡ (identity T.T))) ○ ⟺ (∘-resp-≈ʳ identityʳ)\n\nMonad⇒CatMonad : ∀ {o ℓ e} {𝒞 : Category o ℓ e} → (T : ElemMonad.Monad 𝒞) → BicatMonad.Monad (Cats o ℓ e)\nMonad⇒CatMonad {𝒞 = 𝒞} T = record\n { C = 𝒞\n ; T = T.F\n ; η = T.η\n ; μ = T.μ\n ; assoc = λ {X} → begin\n T.μ.η X ∘ (T.F.F₁ (T.μ.η X) ∘ id) ∘ id ≈⟨ eliminate-ids ⟩\n T.μ.η X ∘ T.F.F₁ (T.μ.η X) ≈⟨ T.assoc ⟩\n T.μ.η X ∘ T.μ.η (T.F.F₀ X) ≈⟨ ∘-resp-≈ʳ (⟺ identityˡ ○ ∘-resp-≈ˡ (⟺ T.F.identity)) ⟩\n T.μ.η X ∘ T.F.F₁ id ∘ T.μ.η (T.F.F₀ X) ∎\n ; sym-assoc = λ {X} → begin\n T.μ.η X ∘ (T.F.F₁ id ∘ T.μ.η (T.F.F₀ X)) ∘ id ≈⟨ eliminate-F-ids ⟩\n T.μ.η X ∘ T.μ.η (T.F.F₀ X) ≈⟨ T.sym-assoc ⟩\n T.μ.η X ∘ T.F.F₁ (T.μ.η X) ≈⟨ ∘-resp-≈ʳ (⟺ identityʳ) ⟩\n T.μ.η X ∘ T.F.F₁ (T.μ.η X) ∘ id ∎\n ; identityˡ = λ {X} → begin\n T.μ.η X ∘ (T.F.F₁ (T.η.η X) ∘ id) ∘ id ≈⟨ eliminate-ids ⟩\n T.μ.η X ∘ T.F.F₁ (T.η.η X) ≈⟨ T.identityˡ ⟩\n id ∎\n ; identityʳ = λ {X} → begin\n (T.μ.η X ∘ (T.F.F₁ id ∘ T.η.η (T.F.F₀ X)) ∘ id) ≈⟨ eliminate-F-ids ⟩\n T.μ.η X ∘ T.η.η (T.F.F₀ X) ≈⟨ T.identityʳ ⟩\n id ∎\n }\n where\n module T = ElemMonad.Monad T\n open Category 𝒞\n open HomReasoning\n open MR 𝒞\n\n eliminate-ids : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → f ∘ (g ∘ id) ∘ id ≈ f ∘ g\n eliminate-ids = ∘-resp-≈ʳ identityʳ ○ ∘-resp-≈ʳ identityʳ\n\n eliminate-F-ids : ∀ {X Y Z} {f : T.F.F₀ Y ⇒ Z} {g : X ⇒ T.F.F₀ Y} → f ∘ (T.F.F₁ id ∘ g) ∘ id ≈ f ∘ g\n eliminate-F-ids = ∘-resp-≈ʳ identityʳ ○ ∘-resp-≈ʳ (∘-resp-≈ˡ T.F.identity ○ identityˡ)\n", "meta": {"hexsha": "c4df88c1b02ed9c6f25e861dd4802d20970026ab", "size": 3953, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Bicategory/Monad/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/Bicategory/Monad/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/Bicategory/Monad/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": 42.0531914894, "max_line_length": 105, "alphanum_fraction": 0.4710346572, "num_tokens": 1802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117855317473, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.5914494439503144}} {"text": "{-# OPTIONS --no-termination-check #-}\n\nmodule AC where\n\nimport Nat\nimport Bool\nimport List\nimport Fin\nimport Logic\nimport Vec\nimport EqProof\n\nopen Nat hiding (_<_) renaming (_==_ to _=Nat=_)\nopen Bool\nopen List hiding (module Eq)\nopen Fin renaming (_==_ to _=Fin=_)\nopen Logic\nopen Vec\n\ninfix 20 _○_\ninfix 10 _≡_\n\nForAll : {A : Set}(n : Nat) -> (Vec n A -> Set) -> Set\nForAll zero F = F ε\nForAll {A} (suc n) F = (x : A) -> ForAll _ \\xs -> F (x ∷ xs)\n\napply : {n : Nat}{A : Set}(F : Vec n A -> Set) -> ForAll n F -> (xs : Vec n A) -> F xs\napply {zero} F t (vec vnil) = t\napply {suc n} F f (vec (vcons x xs)) = apply _ (f x) xs\n\nlambda : {n : Nat}{A : Set}(F : Vec n A -> Set) -> ((xs : Vec n A) -> F xs) -> ForAll n F\nlambda {zero } F f = f ε\nlambda {suc n} F f = \\x -> lambda _ (\\xs -> f (x ∷ xs))\n\ndata Expr (n : Nat) : Set where\n zro : Expr n\n var : Fin n -> Expr n\n _○_ : Expr n -> Expr n -> Expr n\n\ndata Theorem (n : Nat) : Set where\n _≡_ : Expr n -> Expr n -> Theorem n\n\ntheorem : (n : Nat) -> ({m : Nat} -> ForAll {Expr m} n \\_ -> Theorem m) -> Theorem n\ntheorem n thm = apply _ thm (map var (fzeroToN-1 n))\n\nmodule Provable where\n\n NF : Nat -> Set\n NF n = List (Fin n)\n\n infix 12 _⊕_\n\n _⊕_ : {n : Nat} -> NF n -> NF n -> NF n\n [] ⊕ ys = ys\n x :: xs ⊕ [] = x :: xs\n x :: xs ⊕ y :: ys = if x < y\n then x :: (xs ⊕ y :: ys)\n else y :: (x :: xs ⊕ ys)\n\n normalise : {n : Nat} -> Expr n -> NF n\n normalise zro = []\n normalise (var n) = n :: []\n normalise (a ○ b) = normalise a ⊕ normalise b\n\n infix 30 _↓\n\n _↓ : {n : Nat} -> NF n -> Expr n\n (i :: is) ↓ = var i ○ is ↓\n [] ↓ = zro\n\n infix 10 _=Expr=_ _=NF=_\n\n _=NF=_ : {n : Nat} -> NF n -> NF n -> Bool\n _=NF=_ = ListEq._==_\n where\n module ListEq = List.Eq _=Fin=_\n\n substNF : {n : Nat}{xs ys : NF n}(P : NF n -> Set) -> IsTrue (xs =NF= ys) -> P xs -> P ys\n substNF = List.Subst.subst _=Fin=_ (subst {_})\n\n _=Expr=_ : {n : Nat} -> Expr n -> Expr n -> Bool\n a =Expr= b = normalise a =NF= normalise b\n\n provable : {n : Nat} -> Theorem n -> Bool\n provable (a ≡ b) = a =Expr= b\n\nmodule Semantics\n {A : Set}\n (_==_ : A -> A -> Set)\n (_*_ : A -> A -> A)\n (one : A)\n (refl : {x : A} -> x == x)\n (sym : {x y : A} -> x == y -> y == x)\n (trans : {x y z : A} -> x == y -> y == z -> x == z)\n (idL : {x : A} -> (one * x) == x)\n (idR : {x : A} -> (x * one) == x)\n (comm : {x y : A} -> (x * y) == (y * x))\n (assoc : {x y z : A} -> (x * (y * z)) == ((x * y) * z))\n (congL : {x y z : A} -> y == z -> (x * y) == (x * z))\n (congR : {x y z : A} -> x == y -> (x * z) == (y * z))\n where\n\n open Provable\n\n module EqP = EqProof _==_ refl trans\n open EqP\n\n expr[_] : {n : Nat} -> Expr n -> Vec n A -> A\n expr[ zro ] ρ = one\n expr[ var i ] ρ = ρ ! i\n expr[ a ○ b ] ρ = expr[ a ] ρ * expr[ b ] ρ\n\n eq[_] : {n : Nat} -> Theorem n -> Vec n A -> Set\n eq[ a ≡ b ] ρ = expr[ a ] ρ == expr[ b ] ρ\n\n data CantProve (A : Set) : Set where\n no-proof : CantProve A\n\n Prf : {n : Nat} -> Theorem n -> Bool -> Set\n Prf thm true = ForAll _ \\ρ -> eq[ thm ] ρ\n Prf thm false = CantProve (Prf thm true)\n\n Proof : {n : Nat} -> Theorem n -> Set\n Proof thm = Prf thm (provable thm)\n\n lem0 : {n : Nat} -> (xs ys : NF n) -> (ρ : Vec n A) ->\n eq[ xs ↓ ○ ys ↓ ≡ (xs ⊕ ys) ↓ ] ρ\n lem0 [] ys ρ = idL\n lem0 (x :: xs) [] ρ = idR\n lem0 (x :: xs) (y :: ys) ρ = if' x < y then less else more\n where\n lhs = (var x ○ xs ↓) ○ (var y ○ ys ↓)\n lbranch = x :: (xs ⊕ y :: ys)\n rbranch = y :: (x :: xs ⊕ ys)\n\n P = \\z -> eq[ lhs ≡ (if z then lbranch else rbranch) ↓ ] ρ\n\n less : IsTrue (x < y) -> _\n less x _\n spine {x'}{xs'}{y'}{ys'}{zs} h =\n eqProof> (x' * xs') * (y' * ys')\n === x' * (xs' * (y' * ys')) by sym assoc\n === x' * zs by congL h\n\n more : IsFalse (x < y) -> _\n more x>=y = BoolEq.subst {false}{x < y} P x>=y\n (spine (lem0 (x :: xs) ys ρ))\n where\n spine : forall {x' xs' y' ys' zs} h -> _\n spine {x'}{xs'}{y'}{ys'}{zs} h =\n eqProof> (x' * xs') * (y' * ys')\n === (y' * ys') * (x' * xs') by comm\n === y' * (ys' * (x' * xs')) by sym assoc\n === y' * ((x' * xs') * ys') by congL comm\n === y' * zs by congL h\n\n lem1 : {n : Nat} -> (e : Expr n) -> (ρ : Vec n A) -> eq[ e ≡ normalise e ↓ ] ρ\n lem1 zro ρ = refl\n lem1 (var i) ρ = sym idR\n lem1 (a ○ b) ρ = trans step1 (trans step2 step3)\n where\n step1 : eq[ a ○ b ≡ normalise a ↓ ○ b ] ρ\n step1 = congR (lem1 a ρ)\n\n step2 : eq[ normalise a ↓ ○ b ≡ normalise a ↓ ○ normalise b ↓ ] ρ\n step2 = congL (lem1 b ρ)\n\n step3 : eq[ normalise a ↓ ○ normalise b ↓ ≡ (normalise a ⊕ normalise b) ↓ ] ρ\n step3 = lem0 (normalise a) (normalise b) ρ\n\n lem2 : {n : Nat} -> (xs ys : NF n) -> (ρ : Vec n A) -> IsTrue (xs =NF= ys) -> eq[ xs ↓ ≡ ys ↓ ] ρ\n lem2 xs ys ρ eq = substNF {_}{xs}{ys} (\\z -> eq[ xs ↓ ≡ z ↓ ] ρ) eq refl\n\n prove : {n : Nat} -> (thm : Theorem n) -> Proof thm\n prove thm = proof (provable thm) thm (\\h -> h)\n where\n proof : {n : Nat}(valid : Bool)(thm : Theorem n) -> (IsTrue valid -> IsTrue (provable thm)) -> Prf thm valid\n proof false _ _ = no-proof\n proof true (a ≡ b) isValid = lambda eq[ a ≡ b ] \\ρ ->\n trans (step-a ρ) (trans (step-ab ρ) (step-b ρ))\n where\n step-a : forall ρ -> eq[ a ≡ normalise a ↓ ] ρ\n step-a ρ = lem1 a ρ\n\n step-b : forall ρ -> eq[ normalise b ↓ ≡ b ] ρ\n step-b ρ = sym (lem1 b ρ)\n\n step-ab : forall ρ -> eq[ normalise a ↓ ≡ normalise b ↓ ] ρ\n step-ab ρ = lem2 (normalise a) (normalise b) ρ (isValid tt)\n\n", "meta": {"hexsha": "7625729d648096f78cfa71988de638acf2efdd88", "size": 6039, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/ac/AC.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": "benchmark/ac/AC.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/ac/AC.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": 31.1288659794, "max_line_length": 114, "alphanum_fraction": 0.4527239609, "num_tokens": 2399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.591407809461646}} {"text": "{-# OPTIONS --postfix-projections #-}\n\nmodule StateSizedIO.cellStateDependent where\n\nopen import Data.Product\nopen import Data.String.Base\n\n{-\nopen import SizedIO.Object\nopen import SizedIO.ConsoleObject\n-}\n\nopen import SizedIO.Console hiding (main)\n\nopen import SizedIO.Base\n\nopen import NativeIO\n\nopen import StateSizedIO.Object\nopen import StateSizedIO.IOObject\n\n\nopen import Size\n\ndata CellStateˢ : Set where\n empty full : CellStateˢ\n\ndata CellMethodEmpty A : Set where\n put : A → CellMethodEmpty A\n\ndata CellMethodFull A : Set where\n get : CellMethodFull A\n put : A → CellMethodFull A\n\n\nCellMethodˢ : (A : Set) → CellStateˢ → Set\nCellMethodˢ A empty = CellMethodEmpty A\nCellMethodˢ A full = CellMethodFull A\n\nputGen : {A : Set} → {i : CellStateˢ} → A → CellMethodˢ A i\nputGen {i = empty} = put\nputGen {i = full} = put\n\n\nCellResultFull : ∀{A} → CellMethodFull A → Set\nCellResultFull {A} get = A\nCellResultFull (put _) = Unit\n\nCellResultEmpty : ∀{A} → CellMethodEmpty A → Set\nCellResultEmpty (put _) = Unit\n\n\nCellResultˢ : (A : Set) → (s : CellStateˢ) → CellMethodˢ A s → Set\nCellResultˢ A empty = CellResultEmpty{A}\nCellResultˢ A full = CellResultFull{A}\n\n\nnˢ : ∀{A} → (s : CellStateˢ) → (c : CellMethodˢ A s) → (CellResultˢ A s c) → CellStateˢ\nnˢ _ _ _ = full\n\nCellInterfaceˢ : (A : Set) → Interfaceˢ\nStateˢ (CellInterfaceˢ A) = CellStateˢ\nMethodˢ (CellInterfaceˢ A) = CellMethodˢ A\nResultˢ (CellInterfaceˢ A) = CellResultˢ A\nnextˢ (CellInterfaceˢ A) = nˢ\n\nmutual\n cellPempty : (i : Size) → IOObjectˢ consoleI (CellInterfaceˢ String) i empty\n method (cellPempty i) {j} (put str) = do (putStrLn (\"put (\" ++ str ++ \")\")) λ _ →\n return (unit , cellPfull j str)\n\n cellPfull : (i : Size) → (str : String) → IOObjectˢ consoleI (CellInterfaceˢ String) i full\n method (cellPfull i str) {j} get = do (putStrLn (\"get (\" ++ str ++ \")\")) λ _ →\n return (str , cellPfull j str)\n method (cellPfull i str) {j} (put str') = do (putStrLn (\"put (\" ++ str' ++ \")\")) λ _ →\n return (unit , cellPfull j str')\n\n\n-- UNSIZED Version, without IO\nmutual\n cellPempty' : ∀{A} → Objectˢ (CellInterfaceˢ A) empty\n cellPempty' .objectMethod (put a) = (_ , cellPfull' a)\n\n cellPfull' : ∀{A} → A → Objectˢ (CellInterfaceˢ A) full\n cellPfull' a .objectMethod get = (a , cellPfull' a)\n cellPfull' a .objectMethod (put a') = (_ , cellPfull' a')\n", "meta": {"hexsha": "656b236a10b7aba686c2db50c4f6aed52cce878d", "size": 2497, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/StateSizedIO/cellStateDependent.agda", "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_issues_repo_path": "src/StateSizedIO/cellStateDependent.agda", "max_issues_repo_name": "stephanadls/state-dependent-gui", "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_issues_repo_licenses": ["MIT"], "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/StateSizedIO/cellStateDependent.agda", "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": ["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.7011494253, "max_line_length": 94, "alphanum_fraction": 0.642370845, "num_tokens": 814, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256313782276, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.5914078038858964}} {"text": "module Categories.Agda.ISetoids.Complete where\n\nopen import Level\nopen import Relation.Binary using (Setoid; module Setoid; Preorder; module Preorder; Rel; _=[_]⇒_)\nopen import Data.Product using (Σ; _,_; proj₁; proj₂)\nopen import Categories.Support.IProduct\n-- import Relation.Binary.EqReasoning as EqReasoning\n\nopen import Categories.Support.Equivalence using (module I→R-Wrapper; setoid-i→r; Fam-setoid; ∀[_]-setoid_) \n renaming (Setoid to ISetoid; module Setoid to ISetoid)\nopen import Categories.Support.SetoidFunctions using (module _⟶_)\nopen import Categories.Support.PropositionalEquality\nimport Categories.Support.ZigZag as ZigZag\n\nopen import Categories.Category\nopen import Categories.Functor\nimport Categories.NaturalTransformation as NT\nopen import Categories.Agda\nopen import Categories.Colimit\nopen import Categories.Object.Initial\nopen import Categories.Cocones\nopen import Categories.Cocone\n\nISetoidsComplete : ∀ {o ℓ e c ℓ′} → Cocomplete o ℓ e (Category.op (ISetoids (c ⊔ ℓ′ ⊔ (o ⊔ ℓ ⊔ e)) (c ⊔ (o ⊔ ℓ ⊔ e))))\nISetoidsComplete {o} {ℓ} {e} {c} {cℓ} = record { colimit = colimit }\n where\n c′ = c ⊔ cℓ ⊔ (o ⊔ ℓ ⊔ e)\n ℓ′ = c ⊔ (o ⊔ ℓ ⊔ e)\n C = Category.op (ISetoids c′ ℓ′)\n colimit : ∀ {J : Category o ℓ e} (F : Functor J C) → Colimit F\n colimit {J} F = record { initial = record \n { ⊥ = record \n { N = Fam-setoid (Σ′ (∀ j → Carrier (F₀ j)) (λ f → ∀ {a b} (h : a J.⇒ b) → (F₀ a ≈ F₁ h ⟨$⟩ f b) (f a)))\n (∀[ J.Obj ]-setoid F₀) proj₁′ \n ; ψ = λ X → record \n { _⟨$⟩_ = λ f → proj₁′ f X\n ; cong = λ eq → eq X \n }\n ; commute = λ {X} {Y} h {f} {g} f≈g → trans (F₀ X) (f≈g X) (sym (F₀ X) (proj₂′ g h))\n }\n ; ! = λ {A} → record \n { f = record \n { _⟨$⟩_ = λ X → (λ j → Cocone.ψ A j ⟨$⟩ X) , (λ {a} {b} h → sym (F₀ a) (Cocone.commute A h (refl (Cocone.N A))))\n ; cong = λ i≈j a → cong (Cocone.ψ A a) i≈j \n }\n ; commute = λ {X} x≈y → cong (Cocone.ψ A X) x≈y \n }\n ; !-unique = λ {A} f x≈y a → sym (F₀ a) (CoconeMorphism.commute f (sym (Cocone.N A) x≈y)) \n } }\n where\n module J = Category J\n open Functor F\n open ISetoid\n open _⟶_\n", "meta": {"hexsha": "bfe6d6590bc2900aebd91310b1aee88d706abef3", "size": 2278, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Agda/ISetoids/Complete.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/Agda/ISetoids/Complete.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/Agda/ISetoids/Complete.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": 41.4181818182, "max_line_length": 126, "alphanum_fraction": 0.5737489025, "num_tokens": 799, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887588023318196, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.5913894912507652}} {"text": "module TypesMore where\n\nopen import Basics\nopen import Types4\n\nmodule DESC (I : Set) where\n\n data Desc : Set1 where\n inx : I -> Desc\n sg : (A : Set)(D : A -> Desc) -> Desc\n _!_ : I -> Desc -> Desc\n\n Node : Desc -> (I -> Set) -> I -> Set\n Node (inx x) R i = x == i\n Node (sg A D) R i = Sg A \\ a -> Node (D a) R i\n Node (x ! D) R i = R x * Node D R i\n\n data Mu (D : Desc)(i : I) : Set where\n [_] : Node D (Mu D) i -> Mu D i\n\n cata : forall D {X} -> ({i : I} -> Node D X i -> X i) ->\n forall {i} -> Mu D i -> X i\n mapCata : forall {D} E {X} -> ({i : I} -> Node D X i -> X i) ->\n forall {i} -> Node E (Mu D) i -> Node E X i\n cata D f [ x ] = f (mapCata D f x)\n mapCata (inx x) f q = q\n mapCata (sg A E) f (a , e) = a , mapCata (E a) f e\n mapCata (i ! E) f (x , e) = cata _ f x , mapCata E f e\n\n module ORN (J : Set)(ji : J -> I) where\n\n Hits : I -> Set\n Hits i = Sg J \\ j -> ji j == i\n\n data Orn : Desc -> Set1 where\n inx : forall {i} -> Hits i -> Orn (inx i)\n sg : forall A {D} -> ((a : A) -> Orn (D a)) -> Orn (sg A D)\n _!_ : forall {i D} -> Hits i -> Orn D -> Orn (i ! D)\n ins : forall (X : Set) {D} -> (X -> Orn D) -> Orn D\n del : forall {A D} a -> Orn (D a) -> Orn (sg A D)\n\nopen DESC\n\nNatDesc : Desc One\nNatDesc = sg Two \\ { tt -> inx <> ; ff -> <> ! inx <> }\n\nNAT : Set\nNAT = Mu One NatDesc <>\npattern ZE = [ tt , refl ]\npattern SU n = [ ff , n , refl ]\nPLUS : NAT -> NAT -> NAT\nPLUS ZE y = y\nPLUS (SU x) y = SU (PLUS x y)\n\nopen ORN\n\norned : forall {I D J ji} -> Orn I J ji D -> Desc J\norned (inx (j , q)) = inx j\norned (sg A D) = sg A \\ a -> orned (D a)\norned ((j , q) ! O) = j ! orned O\norned (ins X O) = sg X \\ x -> orned (O x)\norned (del a O) = orned O\n\nListOrn : Set -> Orn One One _ NatDesc\nListOrn X = sg Two \\\n { tt -> inx (<> , refl)\n ; ff -> ins X \\ _ -> (<> , refl) ! (inx (<> , refl))\n }\n\nforget : forall {I D J ji} (O : Orn I J ji D) {P : I -> Set} ->\n {j : J} -> Node J (orned O) (\\ j -> P (ji j)) j ->\n Node I D P (ji j)\nforget (inx (j , refl)) refl = refl\nforget (sg A O) (a , o) = a , forget (O a) o\nforget ((j , refl) ! O) (p , o) = p , forget O o\nforget (ins X O) (x , o) = forget (O x) o\nforget (del a O) o = a , forget O o\n\nplain : forall {I D J ji} (O : Orn I J ji D)\n {j : J} -> Mu J (orned O) j -> Mu I D (ji j)\nplain O = cata _ (orned O) (\\ x -> [ forget O {Mu _ _} x ])\n", "meta": {"hexsha": "f1dad5e2831fac5398d125f190494cf44e73bdbe", "size": 2417, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TypesMore.agda", "max_stars_repo_name": "pigworker/WhatRTypes4", "max_stars_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-06-11T09:12:25.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-09T05:38:44.000Z", "max_issues_repo_path": "TypesMore.agda", "max_issues_repo_name": "pigworker/WhatRTypes4", "max_issues_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "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": "TypesMore.agda", "max_forks_repo_name": "pigworker/WhatRTypes4", "max_forks_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-06-09T05:39:02.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-09T05:39:02.000Z", "avg_line_length": 29.4756097561, "max_line_length": 66, "alphanum_fraction": 0.4737277617, "num_tokens": 965, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094032139576, "lm_q2_score": 0.6619228891883799, "lm_q1q2_score": 0.5913019411145303}} {"text": "\nopen import Agda.Builtin.Nat\n\ndata Sing : Nat → Set where\n i : (k : Nat) → Sing k\n\ntoSing : (n : Nat) → Sing n\ntoSing n = i n\n\nfun : (n : Nat) → Nat\nfun n with toSing n\nfun .n | i n with toSing n\nfun .(n + n) | i .n | i n = {!!}\n", "meta": {"hexsha": "527a8dba4a5959d36dd305257d63926252050d77", "size": 237, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue142.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/Issue142.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/Issue142.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.9285714286, "max_line_length": 32, "alphanum_fraction": 0.5400843882, "num_tokens": 95, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972751232809, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.5912911135169426}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- A pointwise lifting of a relation to incorporate an additional point.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\n-- This module is designed to be used with\n-- Relation.Nullary.Construct.Add.Point\n\nopen import Relation.Binary\n\nmodule Relation.Binary.Construct.Add.Point.Equality\n {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where\n\nopen import Level using (_⊔_)\nopen import Function\nimport Relation.Binary.PropositionalEquality as P\nopen import Relation.Nullary\nopen import Relation.Nullary.Construct.Add.Point\nimport Relation.Nullary.Decidable as Dec\n\n------------------------------------------------------------------------\n-- Definition\n\ndata _≈∙_ : Rel (Pointed A) (a ⊔ ℓ) where\n ∙≈∙ : ∙ ≈∙ ∙\n [_] : {k l : A} → k ≈ l → [ k ] ≈∙ [ l ]\n\n------------------------------------------------------------------------\n-- Relational properties\n\n[≈]-injective : ∀ {k l} → [ k ] ≈∙ [ l ] → k ≈ l\n[≈]-injective [ k≈l ] = k≈l\n\n≈∙-refl : Reflexive _≈_ → Reflexive _≈∙_\n≈∙-refl ≈-refl {∙} = ∙≈∙\n≈∙-refl ≈-refl {[ k ]} = [ ≈-refl ]\n\n≈∙-sym : Symmetric _≈_ → Symmetric _≈∙_\n≈∙-sym ≈-sym ∙≈∙ = ∙≈∙\n≈∙-sym ≈-sym [ x≈y ] = [ ≈-sym x≈y ]\n\n≈∙-trans : Transitive _≈_ → Transitive _≈∙_\n≈∙-trans ≈-trans ∙≈∙ ∙≈z = ∙≈z\n≈∙-trans ≈-trans [ x≈y ] [ y≈z ] = [ ≈-trans x≈y y≈z ]\n\n≈∙-dec : Decidable _≈_ → Decidable _≈∙_\n≈∙-dec _≟_ ∙ ∙ = yes ∙≈∙\n≈∙-dec _≟_ ∙ [ l ] = no (λ ())\n≈∙-dec _≟_ [ k ] ∙ = no (λ ())\n≈∙-dec _≟_ [ k ] [ l ] = Dec.map′ [_] [≈]-injective (k ≟ l)\n\n≈∙-irrelevant : Irrelevant _≈_ → Irrelevant _≈∙_\n≈∙-irrelevant ≈-irr ∙≈∙ ∙≈∙ = P.refl\n≈∙-irrelevant ≈-irr [ p ] [ q ] = P.cong _ (≈-irr p q)\n\n≈∙-substitutive : ∀ {ℓ} → Substitutive _≈_ ℓ → Substitutive _≈∙_ ℓ\n≈∙-substitutive ≈-subst P ∙≈∙ = id\n≈∙-substitutive ≈-subst P [ p ] = ≈-subst (P ∘′ [_]) p\n\n------------------------------------------------------------------------\n-- Structures\n\n≈∙-isEquivalence : IsEquivalence _≈_ → IsEquivalence _≈∙_\n≈∙-isEquivalence ≈-isEquivalence = record\n { refl = ≈∙-refl refl\n ; sym = ≈∙-sym sym\n ; trans = ≈∙-trans trans\n } where open IsEquivalence ≈-isEquivalence\n\n≈∙-isDecEquivalence : IsDecEquivalence _≈_ → IsDecEquivalence _≈∙_\n≈∙-isDecEquivalence ≈-isDecEquivalence = record\n { isEquivalence = ≈∙-isEquivalence isEquivalence\n ; _≟_ = ≈∙-dec _≟_\n } where open IsDecEquivalence ≈-isDecEquivalence\n", "meta": {"hexsha": "42ce4591bcec4518d46db71022cf18bbe779ecd0", "size": 2525, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Point/Equality.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/Add/Point/Equality.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/Add/Point/Equality.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.3717948718, "max_line_length": 72, "alphanum_fraction": 0.4986138614, "num_tokens": 1002, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901036, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.5912643671943248}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Data.Sum where\n\nopen import Level\nopen import Cubical.Data.Sum using (_⊎_; inl; inr) public\nopen import Data.Bool using (Bool; true; false)\nopen import Function using (const)\n\neither : ∀ {ℓ} {C : A ⊎ B → Type ℓ} → ((a : A) → C (inl a)) → ((b : B) → C (inr b))\n → (x : A ⊎ B) → C x\neither f _ (inl x) = f x\neither _ g (inr y) = g y\n\n⟦l_,r_⟧ = either\n\neither′ : (A → C) → (B → C) → (A ⊎ B) → C\neither′ = either\n\nis-l : A ⊎ B → Bool\nis-l = either′ (const true) (const false)\n\nmap-⊎ : ∀ {a₁ a₂ b₁ b₂} {A₁ : Type a₁} {A₂ : Type a₂} {B₁ : Type b₁} {B₂ : Type b₂} →\n (A₁ → A₂) →\n (B₁ → B₂) →\n (A₁ ⊎ B₁) →\n (A₂ ⊎ B₂)\nmap-⊎ f g (inl x) = inl (f x)\nmap-⊎ f g (inr x) = inr (g x)\n\nmapˡ : (A → B) → A ⊎ C → B ⊎ C\nmapˡ f (inl x) = inl (f x)\nmapˡ f (inr x) = inr x\n\nmapʳ : (A → B) → C ⊎ A → C ⊎ B\nmapʳ f (inl x) = inl x\nmapʳ f (inr x) = inr (f x)\n", "meta": {"hexsha": "a3aa1d0a28e2718266a4c7344e9a9a2892c1693e", "size": 902, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Data/Sum.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/Sum.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/Sum.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": 23.7368421053, "max_line_length": 85, "alphanum_fraction": 0.5022172949, "num_tokens": 433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.7606506635289836, "lm_q1q2_score": 0.5912536473152366}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.ListedFiniteSet.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Sum as ⊎ using (_⊎_; inl; inr)\n\nopen import Cubical.Functions.Logic\n\nprivate\n variable\n ℓ : Level\n A B : Type ℓ\n\ninfixr 20 _∷_\n-- infix 30 _∈_\ninfixr 5 _++_\n\ndata LFSet (A : Type ℓ) : Type ℓ where\n [] : LFSet A\n _∷_ : (x : A) → (xs : LFSet A) → LFSet A\n dup : ∀ x xs → x ∷ x ∷ xs ≡ x ∷ xs\n comm : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs\n trunc : isSet (LFSet A)\n\n-- Membership.\n--\n-- Doing some proofs with equational reasoning adds an extra \"_∙ refl\"\n-- at the end.\n-- We might want to avoid it, or come up with a more clever equational reasoning.\n_∈_ : {A : Type ℓ} → A → LFSet A → hProp ℓ\nz ∈ [] = Lift ⊥.⊥ , isOfHLevelLift 1 isProp⊥\nz ∈ (y ∷ xs) = (z ≡ₚ y) ⊔ (z ∈ xs)\nz ∈ dup x xs i = proof i\n where\n -- proof : z ∈ (x ∷ x ∷ xs) ≡ z ∈ (x ∷ xs)\n proof = z ≡ₚ x ⊔ (z ≡ₚ x ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ x) (z ∈ xs) ⟩\n (z ≡ₚ x ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-idem (z ≡ₚ x)) ⟩\n z ≡ₚ x ⊔ z ∈ xs ∎\nz ∈ comm x y xs i = proof i\n where\n -- proof : z ∈ (x ∷ y ∷ xs) ≡ z ∈ (y ∷ x ∷ xs)\n proof = z ≡ₚ x ⊔ (z ≡ₚ y ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ y) (z ∈ xs) ⟩\n (z ≡ₚ x ⊔ z ≡ₚ y) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-comm (z ≡ₚ x) (z ≡ₚ y)) ⟩\n (z ≡ₚ y ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ sym (⊔-assoc (z ≡ₚ y) (z ≡ₚ x) (z ∈ xs)) ⟩\n z ≡ₚ y ⊔ (z ≡ₚ x ⊔ z ∈ xs) ∎\nx ∈ trunc xs ys p q i j = isSetHProp (x ∈ xs) (x ∈ ys) (cong (x ∈_) p) (cong (x ∈_) q) i j\n\nmodule Elim {ℓ}\n {B : LFSet A → Type ℓ}\n ([]* : B [])\n (_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs))\n (comm* : (x y : A) {xs : LFSet A} (b : B xs)\n → PathP (λ i → B (comm x y xs i)) (x ∷* (y ∷* b)) (y ∷* (x ∷* b)))\n (dup* : (x : A) {xs : LFSet A} (b : B xs)\n → PathP (λ i → B (dup x xs i)) (x ∷* (x ∷* b)) (x ∷* b))\n (trunc* : (xs : LFSet A) → isSet (B xs)) where\n\n f : ∀ x → B x\n f [] = []*\n f (x ∷ xs) = x ∷* f xs\n f (dup x xs i) = dup* x (f xs) i\n f (comm x y xs i) = comm* x y (f xs) i\n f (trunc x y p q i j) =\n isOfHLevel→isOfHLevelDep 2 trunc*\n (f x) (f y)\n (λ i → f (p i)) (λ i → f (q i))\n (trunc x y p q) i j\n\nmodule Rec {ℓ} {B : Type ℓ}\n ([]* : B)\n (_∷*_ : (x : A) → B → B)\n (comm* : (x y : A) (xs : B) → (x ∷* (y ∷* xs)) ≡ (y ∷* (x ∷* xs)))\n (dup* : (x : A) (b : B) → (x ∷* (x ∷* b)) ≡ (x ∷* b))\n (trunc* : isSet B) where\n\n f : LFSet A → B\n f =\n Elim.f\n []* (λ x xs → x ∷* xs)\n (λ x y b → comm* x y b) (λ x b → dup* x b)\n λ _ → trunc*\n\nmodule PropElim {ℓ}\n {B : LFSet A → Type ℓ}\n ([]* : B []) (_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs))\n (trunc* : (xs : LFSet A) → isProp (B xs)) where\n\n f : ∀ x → B x\n f =\n Elim.f\n []* _∷*_\n (λ _ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _)\n (λ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _)\n λ xs → isProp→isSet (trunc* xs)\n\n_++_ : ∀ (xs ys : LFSet A) → LFSet A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ (xs ++ ys)\ndup x xs i ++ ys = dup x (xs ++ ys) i\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\nmap : (A → B) → LFSet A → LFSet B\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ map f xs\nmap f (dup x xs i) = dup (f x) (map f xs) i\nmap f (comm x y xs i) = comm (f x) (f y) (map f xs) i\nmap f (trunc xs ys p q i j) =\n trunc (map f xs) (map f ys) (cong (map f) p) (cong (map f) q) i j\n\ndisj-union : LFSet A → LFSet B → LFSet (A ⊎ B)\ndisj-union xs ys = map ⊎.inl xs ++ map ⊎.inr ys\n", "meta": {"hexsha": "f8e27e06ef153be063b073c7534157d28dd9bca8", "size": 3790, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/ListedFiniteSet/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/ListedFiniteSet/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/HITs/ListedFiniteSet/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": 32.6724137931, "max_line_length": 90, "alphanum_fraction": 0.4530343008, "num_tokens": 1794, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.7606506526772883, "lm_q1q2_score": 0.5912536467284945}} {"text": "module Structure.Operator where\n\nimport Lvl\nopen import Functional using (_$_)\nopen import Lang.Instance\nopen import Logic.Predicate\nopen import Logic\nopen import Structure.Setoid\nopen import Structure.Function.Names\nopen import Structure.Function\nopen import Structure.Relator.Properties\nopen import Syntax.Function\nopen import Syntax.Transitivity\nopen import Type\n\nprivate variable ℓ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ ℓₗ₄ : Lvl.Level\nprivate variable A₁ A₂ A₃ B : Type{ℓ}\n\nmodule _\n ⦃ equiv-A₁ : Equiv{ℓₗ₁}(A₁) ⦄\n ⦃ equiv-A₂ : Equiv{ℓₗ₂}(A₂) ⦄\n ⦃ equiv-B : Equiv{ℓₗ₃}(B) ⦄\n (_▫_ : A₁ → A₂ → B)\n where\n\n -- The operator `_▫_` \"(behaves like)/is a function\" in the context of `_≡_` from the Equiv instance.\n -- `congruence` is the defining property of a binary operation.\n record BinaryOperator : Type{Lvl.of(A₁) Lvl.⊔ Lvl.of(A₂) Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃} where\n constructor intro\n field congruence : Congruence₂(_▫_)\n\n instance\n left : ∀{x} → Function(_▫ x)\n left = intro(proof ↦ congruence proof (reflexivity(_≡_)))\n\n instance\n right : ∀{x} → Function(x ▫_)\n right = intro(proof ↦ congruence (reflexivity(_≡_)) proof)\n\n congruenceₗ : ∀{x₁ x₂}{y} → (x₁ ≡ x₂) → (x₁ ▫ y ≡ x₂ ▫ y)\n congruenceₗ = Function.congruence(left)\n\n congruenceᵣ : ∀{x}{y₁ y₂} → (y₁ ≡ y₂) → (x ▫ y₁ ≡ x ▫ y₂)\n congruenceᵣ = Function.congruence(right)\n\n [≡]-congruence2-left : ⦃ inst : BinaryOperator ⦄ → (x : _) → Function(_▫ x)\n [≡]-congruence2-left = x ↦ inst-fn(BinaryOperator.left) {x}\n\n [≡]-congruence2-right : ⦃ inst : BinaryOperator ⦄ → (x : _) → Function(x ▫_)\n [≡]-congruence2-right = x ↦ inst-fn(BinaryOperator.right) {x}\n\n congruence₂ = inst-fn BinaryOperator.congruence\n\n congruence₂ₗ : ⦃ inst : BinaryOperator ⦄ → (a : A₂) → ∀{x y : A₁} → (x ≡ y) → (x ▫ a ≡ y ▫ a)\n congruence₂ₗ _ = inst-fn BinaryOperator.congruenceₗ -- (congruence₁(_▫ a) ⦃ [≡]-congruence2-left ⦃ inst ⦄ a ⦄)\n\n congruence₂ᵣ : ⦃ inst : BinaryOperator ⦄ → (a : A₁) → ∀{x y : A₂} → (x ≡ y) → (a ▫ x ≡ a ▫ y)\n congruence₂ᵣ _ = inst-fn BinaryOperator.congruenceᵣ\n\n functions-to-binaryOperator : ⦃ l : ∀{y} → Function(_▫ y) ⦄ ⦃ r : ∀{x} → Function(x ▫_) ⦄ → BinaryOperator\n BinaryOperator.congruence functions-to-binaryOperator {x₁} {y₁} {x₂} {y₂} leq req =\n (x₁ ▫ x₂) 🝖[ _≡_ ]-[ congruence₁(_▫ x₂) leq ]\n (y₁ ▫ x₂) 🝖[ _≡_ ]-[ congruence₁(y₁ ▫_) req ]\n (y₁ ▫ y₂) 🝖-end\n\nmodule _\n ⦃ equiv-A₁ : Equiv{ℓₗ₁}(A₁) ⦄\n ⦃ equiv-A₂ : Equiv{ℓₗ₂}(A₂) ⦄\n ⦃ equiv-A₃ : Equiv{ℓₗ₃}(A₃) ⦄\n ⦃ equiv-B : Equiv{ℓₗ₄}(B) ⦄\n (_▫_▫_ : A₁ → A₂ → A₃ → B)\n where\n\n record TrinaryOperator : Type{Lvl.of(A₁) Lvl.⊔ Lvl.of(A₂) Lvl.⊔ Lvl.of(A₃) Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃ Lvl.⊔ ℓₗ₄} where\n constructor intro\n field congruence : Congruence₃(_▫_▫_)\n\n congruence₃ = inst-fn TrinaryOperator.congruence\n", "meta": {"hexsha": "0e0aeaa8372529803c9c5a53a87f6133cce3229b", "size": 2807, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator.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.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.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.5316455696, "max_line_length": 123, "alphanum_fraction": 0.6394727467, "num_tokens": 1283, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.5912536425109838}} {"text": "open import Prelude\n\nmodule Implicits.Syntax.Context where\n\nopen import Implicits.Syntax.Type\nopen import Data.List.All\nopen import Data.Vec\nopen import Data.List\n\nCtx : ℕ → ℕ → Set\nCtx ν n = Vec (Type ν) n\n\nICtx : ℕ → Set\nICtx ν = List (Type ν)\n\n-- wellformed implicit contexts\n_⊢OK : ∀ {ν} → ICtx ν → Set\nΔ ⊢OK = All (λ a → List.[] ⊢unamb a) Δ\n\nKtx : ℕ → ℕ → Set\nKtx ν n = Ctx ν n × ICtx ν\n\n_∷Γ_ : ∀ {ν n} → Type ν → Ktx ν n → Ktx ν (suc n)\na ∷Γ (Γ , Δ) = (a ∷ Γ) , Δ\n\n_∷Δ_ : ∀ {ν n} → Type ν → Ktx ν n → Ktx ν n\na ∷Δ (Γ , Δ) = Γ , a List.∷ Δ\n\n_∷K_ : ∀ {ν n} → Type ν → Ktx ν n → Ktx ν (suc n)\na ∷K (Γ , Δ) = a ∷ Γ , a List.∷ Δ\n\nnil : ∀ {ν} → Ktx ν 0\nnil = [] , List.[]\n", "meta": {"hexsha": "afad3da5e97dfb90c1ea73f57d2b0c8eaf5b2e39", "size": 672, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Implicits/Syntax/Context.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/Implicits/Syntax/Context.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/Implicits/Syntax/Context.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": 19.7647058824, "max_line_length": 49, "alphanum_fraction": 0.5520833333, "num_tokens": 308, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.5911796452270837}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties satisfied by bounded meet semilattices\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary.Lattice\n\nmodule Relation.Binary.Properties.BoundedMeetSemilattice\n {c ℓ₁ ℓ₂} (M : BoundedMeetSemilattice c ℓ₁ ℓ₂) where\n\nopen BoundedMeetSemilattice 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.BoundedJoinSemilattice as J\n\n-- The dual construction is a bounded join semilattice.\n\ndualIsBoundedJoinSemilattice : IsBoundedJoinSemilattice _≈_ (flip _≤_) _∧_ ⊤\ndualIsBoundedJoinSemilattice = record\n { isJoinSemilattice = record\n { isPartialOrder = invIsPartialOrder\n ; supremum = infimum\n }\n ; minimum = maximum\n }\n\ndualBoundedJoinSemilattice : BoundedJoinSemilattice c ℓ₁ ℓ₂\ndualBoundedJoinSemilattice = record\n { ⊥ = ⊤\n ; isBoundedJoinSemilattice = dualIsBoundedJoinSemilattice\n }\n\nopen J dualBoundedJoinSemilattice\n hiding (dualIsBoundedMeetSemilattice; dualBoundedMeetSemilattice) public\n", "meta": {"hexsha": "13344eb6dc059353d990d4b98628b9b81e013083", "size": 1329, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/BoundedMeetSemilattice.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/BoundedMeetSemilattice.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/BoundedMeetSemilattice.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.6428571429, "max_line_length": 76, "alphanum_fraction": 0.6802106847, "num_tokens": 340, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5911796239543876}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of These\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.These.Properties where\n\nopen import Data.These\nopen import Function using (_∘_)\nopen import Relation.Binary using (Decidable)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary using (yes; no)\n\n------------------------------------------------------------------------\n-- Equality\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n this-injective : ∀ {x y : A} → this {B = B} x ≡ this y → x ≡ y\n this-injective refl = refl\n\n that-injective : ∀ {a b : B} → that {A = A} a ≡ that b → a ≡ b\n that-injective refl = refl\n\n these-injectiveˡ : ∀ {x y : A} {a b : B} → these x a ≡ these y b → x ≡ y\n these-injectiveˡ refl = refl\n\n these-injectiveʳ : ∀ {x y : A} {a b : B} → these x a ≡ these y b → a ≡ b\n these-injectiveʳ refl = refl\n\n ≡-dec : Decidable _≡_ → Decidable _≡_ → Decidable {A = These A B} _≡_\n ≡-dec dec₁ dec₂ (this x) (this y) with dec₁ x y\n ... | yes refl = yes refl\n ... | no x≢y = no (x≢y ∘ this-injective)\n ≡-dec dec₁ dec₂ (this x) (that y) = no λ()\n ≡-dec dec₁ dec₂ (this x) (these y b) = no λ()\n ≡-dec dec₁ dec₂ (that x) (this y) = no λ()\n ≡-dec dec₁ dec₂ (that x) (that y) with dec₂ x y\n ... | yes refl = yes refl\n ... | no x≢y = no (x≢y ∘ that-injective)\n ≡-dec dec₁ dec₂ (that x) (these y b) = no λ()\n ≡-dec dec₁ dec₂ (these x a) (this y) = no λ()\n ≡-dec dec₁ dec₂ (these x a) (that y) = no λ()\n ≡-dec dec₁ dec₂ (these x a) (these y b) with dec₁ x y | dec₂ a b\n ... | yes refl | yes refl = yes refl\n ... | no x≢y | _ = no (x≢y ∘ these-injectiveˡ)\n ... | yes _ | no a≢b = no (a≢b ∘ these-injectiveʳ)\n", "meta": {"hexsha": "6891135eceaf6e3f9dc3cdcd7407673eeadba247", "size": 1866, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/These/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/These/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/These/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": 36.5882352941, "max_line_length": 74, "alphanum_fraction": 0.5064308682, "num_tokens": 650, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619947119304, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5911796125107998}} {"text": "{-# OPTIONS --enable-prop #-}\n\ndata Squash {ℓ} (A : Set ℓ) : Prop ℓ where\n squash : A → Squash A\n\nsquash-elim : ∀ {ℓ₁ ℓ₂} (A : Set ℓ₁) (P : Prop ℓ₂)\n → (A → P) → Squash A → P\nsquash-elim A P f (squash x) = f x\n", "meta": {"hexsha": "b9bd4d8e3586a17d2462245a2df6235257d8e005", "size": 222, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/PropSquash.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/PropSquash.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/PropSquash.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": 24.6666666667, "max_line_length": 50, "alphanum_fraction": 0.5225225225, "num_tokens": 95, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952975813454, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.5910582880825406}} {"text": "\ndata _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\npostulate\n A : Set\n a : A\n\nrecord Eq (a : A) : Set where\n constructor mkEq\n field\n v : A\n p : a ≡ v\nopen Eq\n\nrecord S : Set1 where\n constructor mkS\n field\n u : A\n e : Eq u\n open Eq e public\nopen S\n\ntest : ∀ (b : A) → S\nu (test b) = b\nv (e (test b)) = a\np (e (test b)) = refl\n", "meta": {"hexsha": "8e8f87787a5c553b728e56c10de69fa71bfeb26c", "size": 362, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue2806.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/Fail/Issue2806.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/Fail/Issue2806.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": 12.9285714286, "max_line_length": 50, "alphanum_fraction": 0.5138121547, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952838963489, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.5910582790720996}} {"text": "{-# OPTIONS --type-in-type #-}\nmodule Record where\n\nopen import Prelude\n\nrecord Sigma (A : Set)(B : A -> Set) : Set\nrecord Sigma A B where\n constructor pair\n field\n fst : A\n snd : B fst\n\nopen Sigma\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": "e1dd10f5c29cdbebdfefa96061db49560f993689", "size": 1650, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/prototyping/term/examples/Record.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/Record.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/Record.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": 28.4482758621, "max_line_length": 72, "alphanum_fraction": 0.423030303, "num_tokens": 576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122313857378, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.590982235684113}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Transitivity\nopen import Oscar.Class.Transextensionality\nopen import Oscar.Class.Transassociativity\n\nmodule Oscar.Class.IsPrecategory where\n\nmodule _\n {𝔬} {𝔒 : Ø 𝔬}\n {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)\n {ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ) (let infix 4 _∼̇_ ; _∼̇_ = _∼̇_)\n (_↦_ : Transitivity.type _∼_)\n where\n record IsPrecategory : Ø 𝔬 ∙̂ 𝔯 ∙̂ ℓ where\n constructor ∁\n field\n ⦃ `𝓣ransextensionality ⦄ : Transextensionality.class _∼_ _∼̇_ _↦_\n ⦃ `𝓣ransassociativity ⦄ : Transassociativity.class _∼_ _∼̇_ _↦_\n", "meta": {"hexsha": "d7646527929992675d20e4ed572795c40f0a523c", "size": 612, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/IsPrecategory.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/IsPrecategory.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/IsPrecategory.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.1428571429, "max_line_length": 77, "alphanum_fraction": 0.6617647059, "num_tokens": 267, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9073122238669025, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.5909822185055583}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule HLevels where\n\nopen import Path\nopen import Cubical.Foundations.Everything\n using (isProp\n ;isSet\n ;isContr\n ;isPropIsContr\n ;isProp→isSet\n ;isOfHLevel→isOfHLevelDep\n ;hProp\n ;isSetHProp\n ;isPropIsProp\n )\n public\n\nopen import Level\nopen import Data.Sigma\n\nhSet : ∀ ℓ → Type (ℓsuc ℓ)\nhSet ℓ = Σ (Type ℓ) isSet\n", "meta": {"hexsha": "4ab5a541e6bb8825a3cea85a9398212a5a02346b", "size": 415, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/HLevels.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/HLevels.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/HLevels.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": 17.2916666667, "max_line_length": 42, "alphanum_fraction": 0.6144578313, "num_tokens": 138, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.590971665881845}} {"text": "open import Functional\nopen import Logic\nopen import Logic.Propositional\nopen import Type\n\nmodule Relator.Ordering where\n\nmodule From-[<][≡] {ℓ₁}{ℓ₂}{ℓ₃} {T : Type{ℓ₁}} (_<_ : T → T → Stmt{ℓ₂}) (_≡_ : T → T → Stmt{ℓ₃}) where\n -- Greater than\n _>_ : T → T → Stmt\n _>_ = swap(_<_)\n\n -- Lesser than or equals\n _≤_ : T → T → Stmt\n x ≤ y = (x < y) ∨ (x ≡ y)\n\n -- Greater than or equals\n _≥_ : T → T → Stmt\n x ≥ y = (x > y) ∨ (x ≡ y)\n\n -- In an open interval\n _<_<_ : T → T → T → Stmt\n x < y < z = (x < y) ∧ (y < z)\n\n -- In an closed interval\n _≤_≤_ : T → T → T → Stmt\n x ≤ y ≤ z = (x ≤ y) ∧ (y ≤ z)\n\n _≮_ : T → T → Stmt\n _≮_ = (¬_) ∘₂ (_<_)\n\n _≯_ : T → T → Stmt\n _≯_ = (¬_) ∘₂ (_>_)\n\n _≰_ : T → T → Stmt\n _≰_ = (¬_) ∘₂ (_≤_)\n\n _≱_ : T → T → Stmt\n _≱_ = (¬_) ∘₂ (_≥_)\n\nmodule From-[≤] {ℓ₁}{ℓ₂} {T : Type{ℓ₁}} (_≤_ : T → T → Stmt{ℓ₂}) where\n -- Greater than or equals\n _≥_ : T → T → Stmt\n _≥_ = swap(_≤_)\n\n _≰_ : T → T → Stmt\n _≰_ = (¬_) ∘₂ (_≤_)\n\n _≱_ : T → T → Stmt\n _≱_ = swap(_≰_)\n\n -- Greater than\n _>_ : T → T → Stmt\n _>_ = _≰_\n\n -- Lesser than or equals\n _<_ : T → T → Stmt\n _<_ = swap(_>_)\n\n -- In an open interval\n _<_<_ : T → T → T → Stmt\n x < y < z = (x < y) ∧ (y < z)\n\n -- In an closed interval\n _≤_≤_ : T → T → T → Stmt\n x ≤ y ≤ z = (x ≤ y) ∧ (y ≤ z)\n\n _≮_ : T → T → Stmt\n _≮_ = (¬_) ∘₂ (_<_)\n\n _≯_ : T → T → Stmt\n _≯_ = (¬_) ∘₂ (_>_)\n\nmodule From-[≤][<] {ℓ₁}{ℓ₂}{ℓ₃} {T : Type{ℓ₁}} (_≤_ : T → T → Stmt{ℓ₂}) (_<_ : T → T → Stmt{ℓ₃}) where\n -- Greater than\n _>_ : T → T → Stmt\n _>_ = swap(_<_)\n\n -- Greater than or equals\n _≥_ : T → T → Stmt\n _≥_ = swap(_≤_)\n\n -- In an open interval\n _<_<_ : T → T → T → Stmt\n x < y < z = (x < y) ∧ (y < z)\n\n -- In an closed interval\n _≤_≤_ : T → T → T → Stmt\n x ≤ y ≤ z = (x ≤ y) ∧ (y ≤ z)\n\n _≮_ : T → T → Stmt\n _≮_ = (¬_) ∘₂ (_<_)\n\n _≯_ : T → T → Stmt\n _≯_ = (¬_) ∘₂ (_>_)\n\n _≰_ : T → T → Stmt\n _≰_ = (¬_) ∘₂ (_≤_)\n\n _≱_ : T → T → Stmt\n _≱_ = (¬_) ∘₂ (_≥_)\n\nmodule From-[≤][≢] {ℓ₁}{ℓ₂}{ℓ₃} {T : Type{ℓ₁}} (_≤_ : T → T → Stmt{ℓ₂}) (_≢_ : T → T → Stmt{ℓ₃}) where\n -- Lesser than or equals\n _<_ : T → T → Stmt\n x < y = (x ≤ y) ∧ (x ≢ y)\n\n -- Greater than\n _>_ : T → T → Stmt\n _>_ = swap(_<_)\n\n -- Greater than or equals\n _≥_ : T → T → Stmt\n _≥_ = swap(_≤_)\n\n -- In an open interval\n _<_<_ : T → T → T → Stmt\n x < y < z = (x < y) ∧ (y < z)\n\n -- In an closed interval\n _≤_≤_ : T → T → T → Stmt\n x ≤ y ≤ z = (x ≤ y) ∧ (y ≤ z)\n\n _≮_ : T → T → Stmt\n _≮_ = (¬_) ∘₂ (_<_)\n\n _≯_ : T → T → Stmt\n _≯_ = (¬_) ∘₂ (_>_)\n\n _≰_ : T → T → Stmt\n _≰_ = (¬_) ∘₂ (_≤_)\n\n _≱_ : T → T → Stmt\n _≱_ = (¬_) ∘₂ (_≥_)\n", "meta": {"hexsha": "f6197a2778774a1f163d015581efa3a06f056c0c", "size": 2618, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relator/Ordering.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/Ordering.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/Ordering.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.3925925926, "max_line_length": 102, "alphanum_fraction": 0.4281894576, "num_tokens": 1336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382165412808, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5909716645740605}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Sets.EquivalenceRelations\nopen import Functions.Definition\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_; Setω)\nopen import Setoids.Setoids\nopen import Groups.Definition\nopen import LogicalFormulae\nopen import Orders.WellFounded.Definition\nopen import Numbers.Naturals.Semiring\nopen import Groups.Lemmas\n\nmodule Groups.FreeProduct.Definition {i : _} {I : Set i} (decidableIndex : (x y : I) → ((x ≡ y) || ((x ≡ y) → False))) {a b : _} {A : I → Set a} {S : (i : I) → Setoid {a} {b} (A i)} {_+_ : (i : I) → (A i) → (A i) → A i} (decidableGroups : (i : I) → (x y : A i) → ((Setoid._∼_ (S i) x y)) || ((Setoid._∼_ (S i) x y) → False)) (G : (i : I) → Group (S i) (_+_ i)) where\n\ndata ReducedSequenceBeginningWith : I → Set (a ⊔ b ⊔ i) where\n ofEmpty : (i : I) → (g : A i) → .(nonZero : (Setoid._∼_ (S i) g (Group.0G (G i))) → False) → ReducedSequenceBeginningWith i\n prependLetter : (i : I) → (g : A i) → .(nonZero : Setoid._∼_ (S i) g (Group.0G (G i)) → False) → {j : I} → ReducedSequenceBeginningWith j → ((i ≡ j) → False) → ReducedSequenceBeginningWith i\n\ndata ReducedSequence : Set (a ⊔ b ⊔ i) where\n empty : ReducedSequence\n nonempty : (i : I) → ReducedSequenceBeginningWith i → ReducedSequence\n\ninjection : {i : I} (x : A i) .(nonzero : (Setoid._∼_ (S i) x (Group.0G (G i))) → False) → ReducedSequence\ninjection {i} x nonzero = nonempty i (ofEmpty i x nonzero)\n", "meta": {"hexsha": "2cb88e4a68c2519792f7bb427aabc8a08170e640", "size": 1441, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/FreeProduct/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/FreeProduct/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/FreeProduct/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": 57.64, "max_line_length": 366, "alphanum_fraction": 0.6363636364, "num_tokens": 521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615381952105441, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5909716499422534}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Maybes where one of the elements satisfies a given property\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Maybe.Relation.Unary.Any where\n\nopen import Data.Maybe.Base using (Maybe; just; nothing)\nopen import Data.Product as Prod using (∃; _,_; -,_)\nopen import Function using (id)\nopen import Function.Equivalence using (_⇔_; equivalence)\nopen import Level\nopen import Relation.Binary.PropositionalEquality as P using (_≡_; cong)\nopen import Relation.Unary\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\n\n------------------------------------------------------------------------\n-- Definition\n\ndata Any {a p} {A : Set a} (P : Pred A p) : Pred (Maybe A) (a ⊔ p) where\n just : ∀ {x} → P x → Any P (just x)\n\n------------------------------------------------------------------------\n-- Basic operations\n\nmodule _ {a p} {A : Set a} {P : Pred A p} where\n\n drop-just : ∀ {x} → Any P (just x) → P x\n drop-just (just px) = px\n\n just-equivalence : ∀ {x} → P x ⇔ Any P (just x)\n just-equivalence = equivalence just drop-just\n\n map : ∀ {q} {Q : Pred A q} → P ⊆ Q → Any P ⊆ Any Q\n map f (just px) = just (f px)\n\n satisfied : ∀ {x} → Any P x → ∃ P\n satisfied (just p) = -, p\n\n------------------------------------------------------------------------\n-- (un/)zip(/With)\n\nmodule _ {a p q r} {A : Set a} {P : Pred A p} {Q : Pred A q} {R : Pred A r} where\n\n zipWith : P ∩ Q ⊆ R → Any P ∩ Any Q ⊆ Any R\n zipWith f (just px , just qx) = just (f (px , qx))\n\n unzipWith : P ⊆ Q ∩ R → Any P ⊆ Any Q ∩ Any R\n unzipWith f (just px) = Prod.map just just (f px)\n\nmodule _ {a p q} {A : Set a} {P : Pred A p} {Q : Pred A q} where\n\n zip : Any P ∩ Any Q ⊆ Any (P ∩ Q)\n zip = zipWith id\n\n unzip : Any (P ∩ Q) ⊆ Any P ∩ Any Q\n unzip = unzipWith id\n\n------------------------------------------------------------------------\n-- Seeing Any as a predicate transformer\n\nmodule _ {a p} {A : Set a} {P : Pred A p} where\n\n dec : Decidable P → Decidable (Any P)\n dec P-dec nothing = no λ ()\n dec P-dec (just x) = Dec.map just-equivalence (P-dec x)\n\n irrelevant : Irrelevant P → Irrelevant (Any P)\n irrelevant P-irrelevant (just p) (just q) = cong just (P-irrelevant p q)\n\n satisfiable : Satisfiable P → Satisfiable (Any P)\n satisfiable P-satisfiable = Prod.map just just P-satisfiable\n", "meta": {"hexsha": "714e6fc985326e23703c58dcccd3baf088961a9c", "size": 2470, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/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/Maybe/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/Maybe/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.0779220779, "max_line_length": 81, "alphanum_fraction": 0.5182186235, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.685949442167993, "lm_q1q2_score": 0.5909716492883614}} {"text": "module Haskell.RangedSetsProp.BoundariesProperties where\n\nopen import Haskell.RangedSetsProp.library\n\nopen import Agda.Builtin.Equality\nopen import Agda.Builtin.Bool\n\nopen import Haskell.Prim\nopen import Haskell.Prim.Ord\nopen import Haskell.Prim.Bool\nopen import Haskell.Prim.Maybe\nopen import Haskell.Prim.Enum\nopen import Haskell.Prim.Eq\nopen import Haskell.Prim.List\nopen import Haskell.Prim.Integer\nopen import Haskell.Prim.Double\n\nopen import Haskell.RangedSets.Boundaries\n\nprop_no_boundary_smaller : {{ o : Ord a }} -> {{ dio : DiscreteOrdered a}} -> (r1 : Boundary a) -> (r1 < BoundaryBelowAll) ≡ false \nprop_no_boundary_smaller BoundaryBelowAll = refl\nprop_no_boundary_smaller BoundaryAboveAll = refl\nprop_no_boundary_smaller (BoundaryAbove x) = refl\nprop_no_boundary_smaller (BoundaryBelow x) = refl\n\nprop_no_boundary_greater : {{ o : Ord a }} -> {{ dio : DiscreteOrdered a}} -> (r1 : Boundary a) -> (r1 > BoundaryAboveAll) ≡ false \nprop_no_boundary_greater BoundaryBelowAll = refl\nprop_no_boundary_greater BoundaryAboveAll = refl\nprop_no_boundary_greater (BoundaryAbove x) = refl\nprop_no_boundary_greater (BoundaryBelow x) = refl\n\nBoundaryBelowAllSmaller : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b : Boundary a)\n → (BoundaryBelowAll <= b) ≡ true\nBoundaryBelowAllSmaller BoundaryBelowAll = refl\nBoundaryBelowAllSmaller BoundaryAboveAll = refl\nBoundaryBelowAllSmaller (BoundaryBelow _) = refl\nBoundaryBelowAllSmaller (BoundaryAbove _) = refl\n\npostulate\n prop_max_sym : {{ o : Ord a }} -> {{ dio : DiscreteOrdered a}} -> (r1 : Boundary a) -> (r2 : Boundary a) -> max r1 r2 ≡ max r2 r1 \n prop_min_sym : {{ o : Ord a }} -> {{ dio : DiscreteOrdered a}} -> (r1 : Boundary a) -> (r2 : Boundary a) -> min r1 r2 ≡ min r2 r1 \n \n-- prop_max_sym : {{ o : Ord a }} -> {{ dio : DiscreteOrdered a}} -> (r1 : Boundary a) -> (r2 : Boundary a) -> max r1 r2 ≡ max r2 r1 \n-- prop_max_sym {{o}} {{dio}} r1 r2 = \n-- begin\n-- max r1 r2\n-- =⟨⟩ \n-- if (compare x y == GT) then x else y\n-- =⟨⟩ \n-- if (compare y x == GT) then y else x \n-- =⟨⟩ \n-- max r2 r1 \n-- end ", "meta": {"hexsha": "6a478321edff0c17049862a3e85cc412b73e6419", "size": 2137, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/RangedSetsProp/BoundariesProperties.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/RangedSetsProp/BoundariesProperties.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/RangedSetsProp/BoundariesProperties.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": 40.320754717, "max_line_length": 133, "alphanum_fraction": 0.6888160973, "num_tokens": 628, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245870332531, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.5908430768601376}} {"text": "\nmodule Issue152 where\n\ndata ℕ : Set where\n zero : ℕ\n suc : ℕ → ℕ\n\n{-# BUILTIN NATURAL ℕ #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n\nf : ℕ → ℕ\nf 0 with zero\nf 0 | n = n\nf 1 with zero\nf 1 | n = n\nf n = n\n\ng : ℕ → ℕ\ng 0 with zero\ng zero | n = n\ng 1 with zero\ng (suc zero) | n = n\ng n = n\n\nh : ℕ → ℕ\nh zero with zero\nh 0 | n = n\nh (suc zero) with zero\nh 1 | n = n\nh n = n\n\n", "meta": {"hexsha": "3d9a1dc882daf6666acd8d6ec21af235ded28e4a", "size": 404, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Issue152.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/Issue152.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/Issue152.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": 12.2424242424, "max_line_length": 28, "alphanum_fraction": 0.5074257426, "num_tokens": 173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891392358014, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.5908205149973861}} {"text": "module Esterel.Variable.Shared 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\ndata SharedVar : Set where\n _ₛₕ : ℕ → SharedVar\n\nunwrap : SharedVar → ℕ\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 : SharedVar} → ∀{k2 : SharedVar} → ¬ k1 ≡ k2 → ¬ (unwrap k1) ≡ (unwrap k2)\nunwrap-neq = (_∘ unwrap-injective)\n\nwrap : ℕ → SharedVar\nwrap = _ₛₕ\n\nbijective : ∀{x} → unwrap (wrap x) ≡ x\nbijective = refl\n\n\n\n_≟_ : Decidable {A = SharedVar} _≡_\n(s ₛₕ) ≟ (t ₛₕ) with s ≟ℕ t\n... | yes p = yes (cong _ₛₕ p)\n... | no ¬p = no (¬p ∘ cong unwrap)\n\ndata Status : Set where\n ready : Status\n new : Status\n old : Status\n\n_≟ₛₜ_ : Decidable {A = Status} _≡_\nready ≟ₛₜ ready = yes refl\nready ≟ₛₜ new = no λ()\nready ≟ₛₜ old = no λ()\nnew ≟ₛₜ ready = no λ()\nnew ≟ₛₜ new = yes refl\nnew ≟ₛₜ old = no λ()\nold ≟ₛₜ ready = no λ()\nold ≟ₛₜ new = no λ()\nold ≟ₛₜ old = yes refl\n", "meta": {"hexsha": "8c8213a141a08228c69d6c0738b68ee3987b4902", "size": 1366, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Esterel/Variable/Shared.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/Shared.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/Shared.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.5517241379, "max_line_length": 92, "alphanum_fraction": 0.6273792094, "num_tokens": 553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891479496521, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5908205063942898}} {"text": "module Esterel.Variable.Signal 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\ndata Signal : Set where\n _ₛ : (S : ℕ) → Signal\n\nunwrap : Signal → ℕ\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\nwrap : ℕ → Signal\nwrap = _ₛ\n\nbijective : ∀{x} → unwrap (wrap x) ≡ x\nbijective = refl\n\n-- for backward compatibility\nunwrap-neq : ∀{k1 : Signal} → ∀{k2 : Signal} → ¬ k1 ≡ k2 → ¬ (unwrap k1) ≡ (unwrap k2)\nunwrap-neq = (_∘ unwrap-injective)\n\n_≟_ : Decidable {A = Signal} _≡_\n(s ₛ) ≟ (t ₛ) with s ≟ℕ t\n... | yes p = yes (cong _ₛ p)\n... | no ¬p = no (¬p ∘ cong unwrap)\n\ndata Status : Set where\n present : Status\n absent : Status\n unknown : Status\n\n_≟ₛₜ_ : Decidable {A = Status} _≡_\npresent ≟ₛₜ present = yes refl\npresent ≟ₛₜ absent = no λ()\npresent ≟ₛₜ unknown = no λ()\nabsent ≟ₛₜ present = no λ()\nabsent ≟ₛₜ absent = yes refl\nabsent ≟ₛₜ unknown = no λ()\nunknown ≟ₛₜ present = no λ()\nunknown ≟ₛₜ absent = no λ()\nunknown ≟ₛₜ unknown = yes refl\n", "meta": {"hexsha": "75d5b62fad16ee91ab8fe95161b4e2c71795bc31", "size": 1385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Esterel/Variable/Signal.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/Signal.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/Signal.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": 24.7321428571, "max_line_length": 90, "alphanum_fraction": 0.6433212996, "num_tokens": 529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5908204938708412}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some derivable properties\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra.Bundles\n\nmodule Algebra.Properties.Group {g₁ g₂} (G : Group g₁ g₂) where\n\nopen Group G\nopen import Algebra.Definitions _≈_\nopen import Relation.Binary.Reasoning.Setoid setoid\nopen import Function\nopen import Data.Product\n\nε⁻¹≈ε : ε ⁻¹ ≈ ε\nε⁻¹≈ε = begin\n ε ⁻¹ ≈⟨ sym $ identityʳ (ε ⁻¹) ⟩\n ε ⁻¹ ∙ ε ≈⟨ inverseˡ ε ⟩\n ε ∎\n\nprivate\n\n left-helper : ∀ x y → x ≈ (x ∙ y) ∙ y ⁻¹\n left-helper x y = begin\n x ≈⟨ sym (identityʳ x) ⟩\n x ∙ ε ≈⟨ ∙-congˡ $ sym (inverseʳ y) ⟩\n x ∙ (y ∙ y ⁻¹) ≈⟨ sym (assoc x y (y ⁻¹)) ⟩\n (x ∙ y) ∙ y ⁻¹ ∎\n\n right-helper : ∀ x y → y ≈ x ⁻¹ ∙ (x ∙ y)\n right-helper x y = begin\n y ≈⟨ sym (identityˡ y) ⟩\n ε ∙ y ≈⟨ ∙-congʳ $ sym (inverseˡ x) ⟩\n (x ⁻¹ ∙ x) ∙ y ≈⟨ assoc (x ⁻¹) x y ⟩\n x ⁻¹ ∙ (x ∙ y) ∎\n\n∙-cancelˡ : LeftCancellative _∙_\n∙-cancelˡ x {y} {z} eq = begin\n y ≈⟨ right-helper x y ⟩\n x ⁻¹ ∙ (x ∙ y) ≈⟨ ∙-congˡ eq ⟩\n x ⁻¹ ∙ (x ∙ z) ≈˘⟨ right-helper x z ⟩\n z ∎\n\n∙-cancelʳ : RightCancellative _∙_\n∙-cancelʳ {x} y z eq = begin\n y ≈⟨ left-helper y x ⟩\n y ∙ x ∙ x ⁻¹ ≈⟨ ∙-congʳ eq ⟩\n z ∙ x ∙ x ⁻¹ ≈˘⟨ left-helper z x ⟩\n z ∎\n\n∙-cancel : Cancellative _∙_\n∙-cancel = ∙-cancelˡ , ∙-cancelʳ\n\n⁻¹-involutive : ∀ x → x ⁻¹ ⁻¹ ≈ x\n⁻¹-involutive x = begin\n x ⁻¹ ⁻¹ ≈˘⟨ identityʳ _ ⟩\n x ⁻¹ ⁻¹ ∙ ε ≈˘⟨ ∙-congˡ $ inverseˡ _ ⟩\n x ⁻¹ ⁻¹ ∙ (x ⁻¹ ∙ x) ≈˘⟨ right-helper (x ⁻¹) x ⟩\n x ∎\n\n⁻¹-injective : ∀ {x y} → x ⁻¹ ≈ y ⁻¹ → x ≈ y\n⁻¹-injective {x} {y} eq = ∙-cancelʳ x y ( begin\n x ∙ x ⁻¹ ≈⟨ inverseʳ x ⟩\n ε ≈˘⟨ inverseʳ y ⟩\n y ∙ y ⁻¹ ≈˘⟨ ∙-congˡ eq ⟩\n y ∙ x ⁻¹ ∎ )\n\n⁻¹-anti-homo-∙ : ∀ x y → (x ∙ y) ⁻¹ ≈ y ⁻¹ ∙ x ⁻¹\n⁻¹-anti-homo-∙ x y = ∙-cancelˡ _ ( begin\n x ∙ y ∙ (x ∙ y) ⁻¹ ≈⟨ inverseʳ _ ⟩\n ε ≈˘⟨ inverseʳ _ ⟩\n x ∙ x ⁻¹ ≈⟨ ∙-congʳ (left-helper x y) ⟩\n (x ∙ y) ∙ y ⁻¹ ∙ x ⁻¹ ≈⟨ assoc (x ∙ y) (y ⁻¹) (x ⁻¹) ⟩\n x ∙ y ∙ (y ⁻¹ ∙ x ⁻¹) ∎ )\n\nidentityˡ-unique : ∀ x y → x ∙ y ≈ y → x ≈ ε\nidentityˡ-unique x y eq = begin\n x ≈⟨ left-helper x y ⟩\n (x ∙ y) ∙ y ⁻¹ ≈⟨ ∙-congʳ eq ⟩\n y ∙ y ⁻¹ ≈⟨ inverseʳ y ⟩\n ε ∎\n\nidentityʳ-unique : ∀ x y → x ∙ y ≈ x → y ≈ ε\nidentityʳ-unique x y eq = begin\n y ≈⟨ right-helper x y ⟩\n x ⁻¹ ∙ (x ∙ y) ≈⟨ refl ⟨ ∙-cong ⟩ eq ⟩\n x ⁻¹ ∙ x ≈⟨ inverseˡ x ⟩\n ε ∎\n\nidentity-unique : ∀ {x} → Identity x _∙_ → x ≈ ε\nidentity-unique {x} id = identityˡ-unique x x (proj₂ id x)\n\ninverseˡ-unique : ∀ x y → x ∙ y ≈ ε → x ≈ y ⁻¹\ninverseˡ-unique x y eq = begin\n x ≈⟨ left-helper x y ⟩\n (x ∙ y) ∙ y ⁻¹ ≈⟨ ∙-congʳ eq ⟩\n ε ∙ y ⁻¹ ≈⟨ identityˡ (y ⁻¹) ⟩\n y ⁻¹ ∎\n\ninverseʳ-unique : ∀ x y → x ∙ y ≈ ε → y ≈ x ⁻¹\ninverseʳ-unique x y eq = begin\n y ≈⟨ sym (⁻¹-involutive y) ⟩\n y ⁻¹ ⁻¹ ≈⟨ ⁻¹-cong (sym (inverseˡ-unique x y eq)) ⟩\n x ⁻¹ ∎\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\nleft-identity-unique = identityˡ-unique\n{-# WARNING_ON_USAGE left-identity-unique\n\"Warning: left-identity-unique was deprecated in v1.1.\nPlease use identityˡ-unique instead.\"\n#-}\nright-identity-unique = identityʳ-unique\n{-# WARNING_ON_USAGE right-identity-unique\n\"Warning: right-identity-unique was deprecated in v1.1.\nPlease use identityʳ-unique instead.\"\n#-}\nleft-inverse-unique = inverseˡ-unique\n{-# WARNING_ON_USAGE left-inverse-unique\n\"Warning: left-inverse-unique was deprecated in v1.1.\nPlease use inverseˡ-unique instead.\"\n#-}\nright-inverse-unique = inverseʳ-unique\n{-# WARNING_ON_USAGE right-inverse-unique\n\"Warning: right-inverse-unique was deprecated in v1.1.\nPlease use inverseʳ-unique instead.\"\n#-}\n", "meta": {"hexsha": "c3508362a1fa198bc05bc89780dd9e00b478f9c4", "size": 4137, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Properties/Group.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/Group.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/Group.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.7625899281, "max_line_length": 72, "alphanum_fraction": 0.4919023447, "num_tokens": 1788, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5908204938708412}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Instance.Groupoids where\n\n-- The category of groupoids.\n--\n-- This category should maybe be called \"Ho(Groupoids)\" or \"Ho(Gpd)\"\n-- instead. The \"homsets\" are not the \"usual\" ones consisting of\n-- functors, but consist instead of equivalence classes of functors up\n-- to natural isomorphism. This is because homsets here are really\n-- hom-setoids and we pick natural isomorphism as the equivalence\n-- relation for these setoids.\n--\n-- See https://ncatlab.org/nlab/show/Ho%28Cat%29\n\nopen import Level\nopen import Categories.Category\nopen import Categories.Category.Groupoid\nopen import Categories.Functor as Fctr using (Functor; _∘F_)\nopen import Categories.Functor.Properties using ([_]-resp-Iso)\nimport Categories.Morphism.IsoEquiv as IsoEquiv\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n using (NaturalIsomorphism; associator; unitorˡ; unitorʳ; unitor²; isEquivalence; _ⓘₕ_; sym)\nprivate\n variable\n o ℓ e : Level\n\nopen Groupoid using (category)\n\n-- The category of groupoids.\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 ; _≈_ = NaturalIsomorphism\n ; id = Fctr.id\n ; _∘_ = _∘F_\n ; assoc = λ {_ _ _ _ F G H} → associator F G H\n ; sym-assoc = λ {_ _ _ _ F G H} → sym (associator F G H)\n ; identityˡ = unitorˡ\n ; identityʳ = unitorʳ\n ; identity² = unitor²\n ; equiv = isEquivalence\n ; ∘-resp-≈ = _ⓘₕ_\n }\n\nmodule _ {o ℓ e o′ ℓ′ e′} {G : Groupoid o ℓ e} {H : Groupoid o′ ℓ′ e′}\n (F : Functor (category G) (category H))\n where\n\n private\n module G = Groupoid G\n module H = Groupoid H\n open Functor F\n open IsoEquiv (category H) using (to-unique)\n\n -- Functors preserve inverses\n\n F-resp-⁻¹ : ∀ {A B} (f : A G.⇒ B) → F₁ (f G.⁻¹) H.≈ (F₁ f) H.⁻¹\n F-resp-⁻¹ f = to-unique ([ F ]-resp-Iso G.iso) H.iso H.Equiv.refl\n", "meta": {"hexsha": "407bb6167fc6ee65f0fa471b37b776cd3de025b8", "size": 2005, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/Groupoids.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/Groupoids.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/Groupoids.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.868852459, "max_line_length": 93, "alphanum_fraction": 0.6603491272, "num_tokens": 683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5908204938708412}} {"text": "module Extensions.ListFirstFunctional where\n\nopen import Prelude hiding (_⊔_)\nopen import Level\n\nprivate\n lemma : ∀ {a b} {A : Set a} {P : A → Set b} (decP : ∀ a → (Dec $ P a)) v {x y} →\n any decP (x List.∷ v) ≡ yes (there {x = x} y) → ¬ P x\n lemma decP v {x} {y} eq p with decP x\n lemma decP v () p | yes _\n lemma decP v eq p | no ¬p = ¬p p\n\n-- first is functionally defined as the element matched by 'any'\nFirst : ∀ {a b} {A : Set a} {P : A → Set b} (decP : ∀ a → (Dec $ P a)) → List A → Set (a ⊔ b)\nFirst f v = ∃ λ m → any f v ≡ yes m\n\nprivate\n There : ∀ {a b} {A : Set a} {P : A → Set b} {f v} → (f : First {P = P} f v) → Set\n There (here px , _) = ⊥\n There (there _ , _) = ⊤\n\n head-first : ∀ {a b} {A : Set a} {P : A → Set b} {f v} → First {P = P} f v → A\n head-first (here {x} _ , _) = x\n head-first (there {x} _ , _) = x\n\n-- we can recover the negative evidence even though Any does not \"save it\" for there-instances\nthere⟶¬x' : ∀ {a b} {A : Set a} {P : A → Set b} {decP v} →\n (f : First {P = P} decP v) → {x : There f} → ¬ P (head-first f)\nthere⟶¬x' (here px , proj₂) {x = ()}\nthere⟶¬x' {P = P} {decP = decP} (there {x = x'} {xs = xs} tail , proj₂) px with lemma decP xs\nthere⟶¬x' {P = P} {decP = decP} (there {x = x'} {xs = xs} tail , proj₂) px | ¬px = ¬px proj₂ px\n", "meta": {"hexsha": "2e3ac8301d278f34f08820d90270c386b77aa02d", "size": 1343, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Extensions/ListFirstFunctional.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/Extensions/ListFirstFunctional.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/Extensions/ListFirstFunctional.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": 41.96875, "max_line_length": 95, "alphanum_fraction": 0.5130305287, "num_tokens": 537, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867729389246, "lm_q2_score": 0.7401743735019594, "lm_q1q2_score": 0.5907973945976192}} {"text": "open import Level using (0ℓ)\nopen import Function using (_$_; _∘_)\n\nopen import Relation.Nullary using (yes; no)\nopen import Relation.Nullary.Decidable using (False; True)\nopen import Relation.Nullary.Negation using (contradiction)\nopen import Relation.Binary\n using (Reflexive; Transitive; Trans; Antisymmetric; Asymmetric; Irreflexive; Decidable; Total; IsPreorder; IsPartialOrder; IsTotalOrder; TotalOrder; _Preserves₂_⟶_⟶_; Trichotomous; Tri; Irrelevant; Connex)\nopen Tri\nopen import Relation.Binary.PropositionalEquality\n using (_≡_; _≢_; refl; sym; trans; cong; resp₂; module ≡-Reasoning)\n renaming (isEquivalence to ≡-isEquivalence)\nopen import Relation.Binary.PropositionalEquality.WithK using (≡-erase)\n\nopen import Data.Bool using (T)\nopen import Data.Bool.Properties using (T?)\nopen import Data.Unit using (tt)\n\nopen import Data.List using (List)\nopen List\nopen import Data.Sum using (_⊎_)\nopen _⊎_\n\nmodule AKS.Nat.Properties where\n\nopen import Data.Nat.Properties using (+-assoc; +-suc; +-comm; *-identityʳ; +-identityʳ; m+n≡0⇒m≡0; +-cancelʳ-≡; +-cancelˡ-≡; 1+n≢0; suc-injective) public\nopen import Data.Nat.Properties using (n∸n≡0; ∸-+-assoc) public\nopen import Data.Nat.Properties using (*-comm; *-1-commutativeMonoid) public\n\nopen import Polynomial.Simple.AlmostCommutativeRing using (AlmostCommutativeRing)\nopen import Polynomial.Simple.AlmostCommutativeRing.Instances using (module Nat)\nopen import Polynomial.Simple.Reflection using (solveOver)\nopen Nat.Reflection using (∀⟨_⟩)\n\nopen import AKS.Nat.Base using (ℕ; _+_; _*_; _∸_; lte; _≤_; _≥_; _≰_; _≱_; _<_; _≮_; _>_; _≯_; _<ᵇ_; _≟_; ℕ⁺; ℕ+; ⟅_⇓⟆; ⟅_⇑⟆; pred)\nopen ℕ\nopen import Algebra.Definitions {A = ℕ} _≡_ using (_DistributesOverˡ_)\n\n≢⇒¬≟ : ∀ {n m} → n ≢ m → False (n ≟ m)\n≢⇒¬≟ {n} {m} n≢m with n ≟ m\n... | yes n≡m = contradiction n≡m n≢m\n... | no _ = tt\n\n¬≟⇒≢ : ∀ {n m} → False (n ≟ m) → n ≢ m\n¬≟⇒≢ {n} {m} ¬n≟m n≡m with n ≟ m\n... | no n≢m = contradiction n≡m n≢m\n\nℕ→ℕ⁺→ℕ : ∀ n {n≢0} → ⟅ ⟅ n ⇑⟆ {n≢0} ⇓⟆ ≡ n\nℕ→ℕ⁺→ℕ (suc n) {n≢0} = refl\n\n⟅⇓⟆-injective : ∀ {n m} → pred ⟅ n ⇓⟆ ≡ pred ⟅ m ⇓⟆ → n ≡ m\n⟅⇓⟆-injective {ℕ+ n} {ℕ+ m} refl = refl\n\nn≢0∧m≢0⇒n*m≢0 : ∀ {n m} → n ≢ 0 → m ≢ 0 → n * m ≢ 0\nn≢0∧m≢0⇒n*m≢0 {zero} {m} n≢0 m≢0 = contradiction refl n≢0\nn≢0∧m≢0⇒n*m≢0 {suc n} {zero} n≢0 m≢0 = contradiction refl m≢0\nn≢0∧m≢0⇒n*m≢0 {suc n} {suc m} n≢0 m≢0 ()\n\nsuc-injective-≡ : ∀ {n m} → suc n ≡ suc m → n ≡ m\nsuc-injective-≡ refl = refl\n\n------------ _≤_ --------------\n\n0≤n : ∀ {n} → 0 ≤ n\n0≤n {n} = lte n refl\n\n≤-refl : Reflexive _≤_\n≤-refl {x} = lte 0 (≡-erase ∀⟨ x ∷ [] ⟩)\n\n≤-reflexive : ∀ {n m} → n ≡ m → n ≤ m\n≤-reflexive refl = ≤-refl\n\n≤-trans : Transitive _≤_\n≤-trans {x} (lte k₁ refl) (lte k₂ refl) = lte (k₁ + k₂) (≡-erase ∀⟨ x ∷ k₁ ∷ k₂ ∷ [] ⟩)\n\nn+m≡n⇒m≡0 : ∀ {n m} → n + m ≡ n → m ≡ 0\nn+m≡n⇒m≡0 {n} {m} n+m≡n = m≡0\n where\n open ≡-Reasoning\n m≡0 : m ≡ 0\n m≡0 = +-cancelˡ-≡ n $ begin\n n + m ≡⟨ n+m≡n ⟩\n n ≡⟨ sym (+-identityʳ n) ⟩\n n + 0 ∎\n\n≤-antisym : Antisymmetric _≡_ _≤_\n≤-antisym {x} {y} (lte k₁ x+k₁≡y) (lte k₂ y+k₂≡x) = ≡-erase (+-cancelʳ-≡ x y x+k₁≡y+k₁)\n where\n open ≡-Reasoning\n\n k₁+k₂≡0 : k₁ + k₂ ≡ 0\n k₁+k₂≡0 = n+m≡n⇒m≡0 $ begin\n x + (k₁ + k₂) ≡⟨ sym (+-assoc x k₁ k₂) ⟩\n (x + k₁) + k₂ ≡⟨ cong (λ t → t + k₂) x+k₁≡y ⟩\n y + k₂ ≡⟨ y+k₂≡x ⟩\n x ∎\n\n x+k₁≡y+k₁ : x + k₁ ≡ y + k₁\n x+k₁≡y+k₁ = begin\n x + k₁ ≡⟨ x+k₁≡y ⟩\n y ≡⟨ sym (+-identityʳ y) ⟩\n y + 0 ≡⟨ cong (λ t → y + t) (sym (m+n≡0⇒m≡0 k₁ k₁+k₂≡0)) ⟩\n y + k₁ ∎\n\nsuc-mono-≤ : ∀ {n m} → n ≤ m → suc n ≤ suc m\nsuc-mono-≤ (lte k₁ refl) = lte k₁ refl\n\nsuc-injective-≤ : ∀ {n m} → suc n ≤ suc m → n ≤ m\nsuc-injective-≤ (lte k refl) = lte k refl\n\nm≤m+n : ∀ {m n} → m ≤ m + n\nm≤m+n {m} {n} = lte n refl\n\nm≤n+m : ∀ {m n} → m ≤ n + m\nm≤n+m {m} {n} = lte n (+-comm m n)\n\n≤-erase : ∀ {n m} → n ≤ m → n ≤ m\n≤-erase (lte k ≤-proof) = lte k (≡-erase ≤-proof)\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------------ _<_ --------------\n\n<-trans : Transitive _<_\n<-trans {x} (lte k₁ refl) (lte k₂ refl) = lte (suc (k₁ + k₂)) (≡-erase ∀⟨ x ∷ k₁ ∷ k₂ ∷ [] ⟩)\n\n<-≤-trans : Trans _<_ _≤_ _<_\n<-≤-trans xm = <-asym nm\n\nn<1+n : ∀ {n} → n < 1 + n\nn<1+n = ≤-refl\n\n0<1+n : ∀ {n} → 0 < 1 + n\n0<1+n {n} = lte n refl\n\nn≮0 : ∀ {n} → n ≮ 0\nn≮0 ()\n\nsuc-mono-< : ∀ {n m} → n < m → suc n < suc m\nsuc-mono-< (lte k₁ refl) = lte k₁ refl\n\n+-mono-≤ : _+_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_\n+-mono-≤ {x} {_} {u} (lte k refl) (lte m refl) = lte (k + m) (≡-erase (solveOver (x ∷ u ∷ k ∷ m ∷ []) Nat.ring))\n\n+-mono-< : _+_ Preserves₂ _<_ ⟶ _<_ ⟶ _<_\n+-mono-< {x} {_} {u} (lte k refl) (lte m refl) = lte (suc (k + m)) (≡-erase (solveOver (x ∷ u ∷ k ∷ m ∷ []) Nat.ring))\n\nprivate\n a+b∸a≡b+[a∸a] : ∀ a b → a + b ∸ a ≡ b + (a ∸ a)\n a+b∸a≡b+[a∸a] zero b = sym (+-identityʳ b)\n a+b∸a≡b+[a∸a] (suc a) b = a+b∸a≡b+[a∸a] a b\n\nm+[n∸m]≡n : ∀ {m n} → m ≤ n → m + (n ∸ m) ≡ n\nm+[n∸m]≡n {m} {n} (lte k refl) = begin\n m + (m + k ∸ m) ≡⟨ cong (λ x → m + x) (a+b∸a≡b+[a∸a] m k) ⟩\n m + (k + (m ∸ m)) ≡⟨ cong (λ x → m + (k + x)) (n∸n≡0 m) ⟩\n m + (k + 0) ≡⟨ cong (λ x → m + x) (+-identityʳ k) ⟩\n m + k ∎\n where\n open ≡-Reasoning\n\n[n∸m]+m≡n : ∀ {m n} → m ≤ n → (n ∸ m) + m ≡ n\n[n∸m]+m≡n {m} {n} rewrite +-comm (n ∸ m) m = m+[n∸m]≡n\n\nmn = <-asym mn\n... | inj₂ m≡n = <-irrefl (sym m≡n) m (m≮n ∘ <⇒<ᵇ m n) m≢n (≤∧≢⇒< (≮⇒≥ (m≮n ∘ <⇒<ᵇ m n)) (m≢n ∘ sym))\n\n_ _ _ a>b = no λ ab a _ _ n>m = inj₂ (<⇒≤ n>m)\n\n<-irrelevant : Irrelevant _<_\n<-irrelevant {x} (lte k₁ 1+x+k₁≡y) (lte k₂ 1+x+k₂≡y) with +-cancelˡ-≡ (1 + x) (trans 1+x+k₁≡y (sym 1+x+k₂≡y))\n<-irrelevant {x} (lte k₁ refl) (lte .k₁ refl) | refl = refl\n\n≤-total : Total _≤_\n≤-total n m with <-cmp n m\n... | tri< n _ _ n>m = inj₂ (<⇒≤ n>m)\n\n≤-isTotalOrder : IsTotalOrder _≡_ _≤_\n≤-isTotalOrder = record\n { isPartialOrder = ≤-isPartialOrder\n ; total = ≤-total\n }\n\n≤-totalOrder : TotalOrder 0ℓ 0ℓ 0ℓ\n≤-totalOrder = record { isTotalOrder = ≤-isTotalOrder }\n\nopen import Algebra.Construct.NaturalChoice.Max ≤-totalOrder public\n\n+-distribˡ-⊔ : _+_ DistributesOverˡ _⊔_\n+-distribˡ-⊔ x y z with ≤-total z y\n+-distribˡ-⊔ x y z | inj₁ z≤y with ≤-total (x + z) (x + y)\n+-distribˡ-⊔ x y z | inj₁ z≤y | inj₁ x+z≤x+y = refl\n+-distribˡ-⊔ x y z | inj₁ z≤y | inj₂ x+y≤x+z = ≤-antisym x+y≤x+z (+-mono-≤ ≤-refl z≤y)\n+-distribˡ-⊔ x y z | inj₂ y≤z with ≤-total (x + z) (x + y)\n+-distribˡ-⊔ x y z | inj₂ y≤z | inj₁ x+z≤x+y = ≤-antisym x+z≤x+y (+-mono-≤ ≤-refl y≤z)\n+-distribˡ-⊔ x y z | inj₂ y≤z | inj₂ x+y≤x+z = refl\n\n⊔-least-≤ : ∀ n m o → n ≤ o → m ≤ o → n ⊔ m ≤ o\n⊔-least-≤ n m o n≤o m≤o with ≤-total m n\n... | inj₁ _ = n≤o\n... | inj₂ _ = m≤o\n\n⊔-least-< : ∀ n m o → n < o → m < o → n ⊔ m < o\n⊔-least-< n m o n>=_ : ∀{A B : Set} → M A → (A → M B) → M B\n\ninfixr 1 bind\nbind : _\nbind = _>>=_\n\ninfix 0 id\nid : ∀{A : Set} → A → A\nid = λ x → x\n\nsyntax id x = do x\nsyntax bind ma (λ x → f) = x ← ma , f\n\nswapM′ : ∀ {A B} → M (A × B) → M (B × A)\nswapM′ mAB =\n do\n (a , b) ← mAB\n , return $ b , a\n\n-- Was:\n-- An internal error has occurred. Please report this as a bug.\n-- Location of the error:\n-- src/full/Agda/TypeChecking/Monad/Base.hs:1793\n", "meta": {"hexsha": "6ac5181c4ba31c585384fa9bd278943c1254db2b", "size": 536, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue1129b.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/Fail/Issue1129b.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/Fail/Issue1129b.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": 17.8666666667, "max_line_length": 63, "alphanum_fraction": 0.5074626866, "num_tokens": 222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772351648677, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5906704597886486}} {"text": "{-# OPTIONS -v tc.lhs.unify:80 #-}\ndata _≡_ {A : Set} (x : A) : A → Set where\n refl : x ≡ x\n\npostulate\n A : Set\n a : A\n\nrecord Foo : Set where\n constructor foo\n field anA : A\n\ntest : (f : A → A) (x : Foo) → foo (f a) ≡ x → A\ntest f .(foo (f a)) refl = a\n", "meta": {"hexsha": "3648c91a12c5bd3a05c81f291699f3f039a182c9", "size": 259, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1809.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/Issue1809.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/Issue1809.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.2666666667, "max_line_length": 48, "alphanum_fraction": 0.5212355212, "num_tokens": 110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772286044094, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5906704496476936}} {"text": "{-# OPTIONS --without-K #-}\ninfixr 1 _‘→’_\n\nrecord ⊤ : Set where\n constructor tt\n\ndata ⊥ : Set where\n\nmutual\n data Type : Set where\n _‘→’_ : Type → Type → Type\n ‘□’ : Type → Type\n ‘⊤’ : Type\n ‘⊥’ : Type\n\n data □ : Type → Set where\n Lӧb : ∀ {X} → □ (‘□’ X ‘→’ X) → □ X\n ‘tt’ : □ ‘⊤’\n\nmutual\n ⌞_⌟ : Type → Set\n ⌞ A ‘→’ B ⌟ = ⌞ A ⌟ → ⌞ B ⌟\n ⌞ ‘□’ T ⌟ = □ T\n ⌞ ‘⊤’ ⌟ = ⊤\n ⌞ ‘⊥’ ⌟ = ⊥\n\n ⌞_⌟t : ∀ {T : Type} → □ T → ⌞ T ⌟\n ⌞ (Lӧb □‘X’→X) ⌟t = ⌞ □‘X’→X ⌟t (Lӧb □‘X’→X)\n ⌞ ‘tt’ ⌟t = tt\n\n¬_ : Set → Set\n¬ T = T → ⊥\n\n‘¬’_ : Type → Type\n‘¬’ T = T ‘→’ ‘⊥’\n\nlӧb : ∀ {‘X’} → □ (‘□’ ‘X’ ‘→’ ‘X’) → ⌞ ‘X’ ⌟\nlӧb f = ⌞ Lӧb f ⌟t\n\nincompleteness : ¬ □ (‘¬’ (‘□’ ‘⊥’))\nincompleteness = lӧb\n\nsoundness : ¬ □ ‘⊥’\nsoundness x = ⌞ x ⌟t\n\nnon-emptyness : □ ‘⊤’\nnon-emptyness = ‘tt’\n", "meta": {"hexsha": "092aa5fc37103f66b6ddb36bbbc79968378f5a4c", "size": 794, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "internal/mini-mini-lob.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/mini-mini-lob.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/mini-mini-lob.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": 16.5416666667, "max_line_length": 46, "alphanum_fraction": 0.3803526448, "num_tokens": 499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9019206712569267, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.5906630936202988}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Definition.Typed.Consequences.Inversion where\n\nopen import Definition.Untyped\nopen import Definition.Typed\nopen import Definition.Typed.Properties\n\nopen import Definition.Typed.Consequences.Syntactic\nopen import Definition.Typed.Consequences.Substitution\n\nopen import Tools.Product\n\n\n-- Inversion of natural number type.\ninversion-ℕ : ∀ {Γ C} → Γ ⊢ ℕ ∷ C → Γ ⊢ C ≡ U\ninversion-ℕ (ℕⱼ x) = refl (Uⱼ x)\ninversion-ℕ (conv x x₁) = trans (sym x₁) (inversion-ℕ x)\n\n-- Inversion of Π-types.\ninversion-Π : ∀ {F G Γ C}\n → Γ ⊢ Π F ▹ G ∷ C → Γ ⊢ F ∷ U × Γ ∙ F ⊢ G ∷ U × Γ ⊢ C ≡ U\ninversion-Π (Πⱼ x ▹ x₁) = x , x₁ , refl (Uⱼ (wfTerm x))\ninversion-Π (conv x x₁) = let a , b , c = inversion-Π x\n in a , b , trans (sym x₁) c\n\n-- Inversion of zero.\ninversion-zero : ∀ {Γ C} → Γ ⊢ zero ∷ C → Γ ⊢ C ≡ ℕ\ninversion-zero (zeroⱼ x) = refl (ℕⱼ x)\ninversion-zero (conv x x₁) = trans (sym x₁) (inversion-zero x)\n\n-- Inversion of successor.\ninversion-suc : ∀ {Γ t C} → Γ ⊢ suc t ∷ C → Γ ⊢ t ∷ ℕ × Γ ⊢ C ≡ ℕ\ninversion-suc (sucⱼ x) = x , refl (ℕⱼ (wfTerm x))\ninversion-suc (conv x x₁) =\n let a , b = inversion-suc x\n in a , trans (sym x₁) b\n\n-- Inversion of natural recursion.\ninversion-natrec : ∀ {Γ c g n A C} → Γ ⊢ natrec C c g n ∷ A\n → (Γ ∙ ℕ ⊢ C)\n × Γ ⊢ c ∷ C [ zero ]\n × Γ ⊢ g ∷ Π ℕ ▹ (C ▹▹ C [ suc (var 0) ]↑)\n × Γ ⊢ n ∷ ℕ\n × Γ ⊢ A ≡ C [ n ]\ninversion-natrec (natrecⱼ x d d₁ n) = x , d , d₁ , n , refl (substType x n)\ninversion-natrec (conv d x) = let a , b , c , d , e = inversion-natrec d\n in a , b , c , d , trans (sym x) e\n\n-- Inversion of application.\ninversion-app : ∀ {Γ f a A} → Γ ⊢ (f ∘ a) ∷ A →\n ∃₂ λ F G → Γ ⊢ f ∷ Π F ▹ G × Γ ⊢ a ∷ F × Γ ⊢ A ≡ G [ a ]\ninversion-app (d ∘ⱼ d₁) = _ , _ , d , d₁ , refl (substTypeΠ (syntacticTerm d) d₁)\ninversion-app (conv d x) = let a , b , c , d , e = inversion-app d\n in a , b , c , d , trans (sym x) e\n\n-- Inversion of lambda.\ninversion-lam : ∀ {t A Γ} → Γ ⊢ lam t ∷ A →\n ∃₂ λ F G → Γ ⊢ F × (Γ ∙ F ⊢ t ∷ G × Γ ⊢ A ≡ Π F ▹ G)\ninversion-lam (lamⱼ x x₁) = _ , _ , x , x₁ , refl (Πⱼ x ▹ (syntacticTerm x₁))\ninversion-lam (conv x x₁) = let a , b , c , d , e = inversion-lam x\n in a , b , c , d , trans (sym x₁) e\n", "meta": {"hexsha": "b4cbcaa7f7e6c9498ce5256d7d4c29cfe655797b", "size": 2308, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Definition/Typed/Consequences/Inversion.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": "Definition/Typed/Consequences/Inversion.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": "Definition/Typed/Consequences/Inversion.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": 36.6349206349, "max_line_length": 81, "alphanum_fraction": 0.5441941075, "num_tokens": 964, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240791017536, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5905792363628511}} {"text": "\nopen import Agda.Builtin.Equality\nopen import Agda.Builtin.Nat\n\ndata D (A : Set) : Set → Set₁ where\n c₁ : {B : Set} → D A B\n c₂ : D A A\n\nrecord P {A B : Set} (p : D A B) : Set₁ where\n constructor c\n field\n d : D A B\n\nQ : {A B₁ B₂ C : Set} {x : D A (B₁ → C)} {y : D A B₂} →\n P x → P y → B₁ ≡ B₂ → Nat\nQ (c c₁) _ refl = 0\nQ _ (c c₁) refl = 1\nQ _ _ _ = 2\n\nmodule _ {A B C : Set} where\n\n checkQ₀ : {x : D A (B → C)} {y : D A B} (px : P x) (py : P y) →\n Q {x = x} {y = y} (c c₁) py refl ≡ 0\n checkQ₀ _ _ = refl\n\n checkQ₁ : {x : D (A → B) (A → B)} {y : D (A → B) A} (px : P x) (py : P y) →\n Q {x = x} {y = y} (c c₂) (c c₁) refl ≡ 1\n checkQ₁ _ _ = refl\n\n checkQ₂ : {x : D (A → B) (A → B)} {y : D (A → B) (A → B)} (px : P x) (py : P y) (eq : A ≡ (A → B)) →\n Q {x = x} {y = y} (c c₂) (c c₂) eq ≡ 2\n checkQ₂ _ _ _ = refl\n\nR : {A B₁ B₂ C : Set} {x : D A (B₁ → C)} {y : D A B₂} →\n P x → P y → B₁ ≡ B₂ → Nat\nR (c c₂) _ refl = 0\nR _ (c c₂) refl = 1\nR _ _ _ = 2\n\nmodule _ {A B C : Set} where\n\n checkR₀ : ∀ {B C} {x : D (B → C) (B → C)} {y : D (B → C) B} (px : P x) (py : P y) →\n R {x = x} {y = y} (c c₂) py refl ≡ 0\n checkR₀ _ _ = refl\n\n checkR₁ : ∀ {A B} {x : D A (A → B)} {y : D A A} (px : P x) (py : P y) →\n R {x = x} {y = y} (c c₁) (c c₂) refl ≡ 1\n checkR₁ _ _ = refl\n\n checkR₂ : ∀ {A B C} {x : D A (B → C)} {y : D A B} (px : P x) (py : P y) →\n R {x = x} {y = y} (c c₁) (c c₁) refl ≡ 2\n checkR₂ _ _ = refl\n", "meta": {"hexsha": "2ca41112885ebc1f101aa02cf411cec7cbee6a6a", "size": 1542, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue4254.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/Issue4254.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/Issue4254.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": 29.0943396226, "max_line_length": 102, "alphanum_fraction": 0.4007782101, "num_tokens": 768, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240825770432, "lm_q2_score": 0.6825737344123243, "lm_q1q2_score": 0.5905792331480896}} {"text": "------------------------------------------------------------------------------\n-- Group theory\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule GroupTheory.README where\n\n------------------------------------------------------------------------------\n-- Description\n\n-- Theory of groups using Agda postulates for the group axioms.\n\n------------------------------------------------------------------------------\n-- The axioms\nopen import GroupTheory.Base\n\n-- Basic properties\nopen import GroupTheory.PropertiesATP\nopen import GroupTheory.PropertiesI\n\n-- Commutator properties\nopen import GroupTheory.Commutator.PropertiesATP\nopen import GroupTheory.Commutator.PropertiesI\n\n-- Abelian groups\nopen import GroupTheory.AbelianGroup.PropertiesATP\n", "meta": {"hexsha": "e0b1f8f26908170399b51590794299821ab9028d", "size": 950, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/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/GroupTheory/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/GroupTheory/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": 30.6451612903, "max_line_length": 78, "alphanum_fraction": 0.4842105263, "num_tokens": 143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240791017536, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.5905792307759481}} {"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 {- de Bruijn indices are represented as proofs that\n an element is in a list -}\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 {- types of the STLC -}\n data TType : Set where\n b : TType -- uninterpreted base type\n _⇒_ : TType → TType → TType -- type \\=>\n\n {- contexts are lists of TType's -}\n Ctx = List\n _,,_ : ∀ {A} → Ctx A → TType → Ctx A\n Γ ,, τ = τ ∷ Γ\n\n infixr 10 _⇒_\n infixr 9 _,,_\n infixr 8 _⊢_ -- type \\entails\n\n {- Γ ⊢ τ represents a term of type τ in context Γ -}\n data _⊢_ (Γ : Ctx) : TType → Set where\n c : Γ ⊢ b -- some constant of the base type\n v : {τ : TType} → τ ∈ Γ → Γ ⊢ τ\n lam : {τ1 τ2 : TType} → Γ ,, τ1 ⊢ τ2 → Γ ⊢ τ1 ⇒ τ2\n app : {τ1 τ2 : TType} → Γ ⊢ τ1 ⇒ τ2 → Γ ⊢ τ1 → Γ ⊢ τ2\n\n module Examples where\n i : [] ⊢ b ⇒ b\n i = lam (v i0) -- \\ x -> x\n\n k : [] ⊢ b ⇒ b ⇒ b\n k = lam (lam (v (iS i0))) -- \\ x -> \\ y -> x\n\n {- TASK 1: Define a term representing \\ x -> \\ y -> y -}\n k' : [] ⊢ b ⇒ b ⇒ b\n k' = {!!}\n\n\n {- The following proof is like a \"0-ary\" logical relation.\n It gives a semantics of the STLC in Agda.\n This shows that the STLC is sound, relative to Agda.\n -}\n module Semantics (B : Set) (elB : B) where\n -- works for any interpretation of the base type b\n\n -- function mapping STLC types to Agda types\n ⟦_⟧t : TType → Set -- type \\(0 and \\)0\n ⟦ b ⟧t = B\n ⟦ τ1 ⇒ τ2 ⟧t = ⟦ τ1 ⟧t → ⟦ τ2 ⟧t\n\n -- function mapping STLC contexts to Agda types\n ⟦_⟧c : Ctx → Set\n ⟦ [] ⟧c = ⊤\n ⟦ τ ∷ Γ ⟧c = ⟦ Γ ⟧c × ⟦ τ ⟧t\n\n {- TASK 2 : Define the interpretation of terms -}\n ⟦_⟧ : {Γ : Ctx} {τ : TType} → Γ ⊢ τ → ⟦ Γ ⟧c → ⟦ τ ⟧t\n ⟦ e ⟧ γ = {!!}\n\n {- the following test should pass\n test : ⟦ Examples.k ⟧ == \\ γ x y → x\n test = Refl\n -}\n\n\n\n {- you can ignore the implementation of this module.\n the interface for the components you need is listed below\n -}\n module RenamingAndSubstitution where\n\n -- renamings = variable for variable substitutions\n\n infix 9 _⊇_\n\n _⊇_ : Ctx → Ctx → Set -- type \\sup=\n Γ' ⊇ [] = ⊤\n Γ' ⊇ (τ ∷ Γ) = (Γ' ⊇ Γ) × (τ ∈ Γ')\n\n extend⊇ : {Γ : Ctx} (Γ' : Ctx) {τ : TType} → Γ ⊇ Γ' → (Γ ,, τ) ⊇ Γ'\n extend⊇ [] ren = tt\n extend⊇ (τ ∷ Γ') (ρ , x) = extend⊇ Γ' ρ , iS x\n\n open import Data.List using (_++_)\n extend⊇* : {Γ : Ctx} (Γ' : Ctx) (Γ'' : Ctx) → Γ ⊇ Γ' → (Γ'' ++ Γ) ⊇ Γ'\n extend⊇* Γ' [] ρ = ρ\n extend⊇* Γ' (x ∷ Γ'') ρ = extend⊇ _ (extend⊇* Γ' Γ'' ρ)\n\n shift : {Γ : Ctx} {τ : TType} (Γ' : Ctx) (i : τ ∈ Γ) → τ ∈ (Γ' ++ Γ)\n shift [] i = i\n shift (τ ∷ Γ) i = iS (shift Γ i)\n\n ⊇-id : (Γ : Ctx) → Γ ⊇ Γ\n ⊇-id [] = tt\n ⊇-id (τ ∷ Γ) = extend⊇ Γ (⊇-id Γ) , i0\n\n ⊇-single : {Γ : Ctx} {τ : TType} → (Γ ,, (τ ⊇ Γ))\n ⊇-single = extend⊇ _ (⊇-id _)\n\n -- you can rename a term\n\n rename : {Γ Γ' : Ctx} {τ : TType} → Γ' ⊇ Γ → Γ ⊢ τ → Γ' ⊢ τ\n rename ρ c = c\n rename (_ , x') (v i0) = v x'\n rename (ρ , _) (v (iS x)) = rename ρ (v x)\n rename ρ (lam e) = lam (rename (extend⊇ _ ρ , i0) e)\n rename ρ (app e e') = app (rename ρ e) (rename ρ e')\n\n\n -- expression-for-variable substitutions\n\n _⊢c_ : Ctx → Ctx → Set\n Γ' ⊢c [] = tt\n Γ' ⊢c (τ ∷ Γ) = (Γ' ⊢c Γ) × (Γ' ⊢ τ)\n\n rename-subst : {Γ1 Γ2 Γ3 : Ctx} → Γ1 ⊇ Γ2 → Γ2 ⊢c Γ3 → Γ1 ⊢c Γ3\n rename-subst {Γ1} {Γ2} {[]} ρ θ = tt\n rename-subst {Γ1} {Γ2} {τ3 ∷ Γ3} ρ (θ , e) = rename-subst ρ θ , rename ρ e\n\n addvar : {Γ Γ' : Ctx} {τ : TType} → Γ ⊢c Γ' → (Γ ,, τ) ⊢c (Γ' ,, τ)\n addvar θ = rename-subst ⊇-single θ , v i0\n\n id-subst : {Γ : Ctx} → Γ ⊢c Γ\n id-subst {[]} = tt\n id-subst {τ ∷ Γ} = rename-subst ⊇-single (id-subst {Γ}) , v i0\n\n subst : {Γ Γ' : Ctx}{τ : TType} → Γ ⊢c Γ' → Γ' ⊢ τ → Γ ⊢ τ\n subst θ c = c\n subst (θ , e) (v i0) = e\n subst (θ , e) (v (iS x)) = subst θ (v x)\n subst θ (lam e) = lam (subst (addvar θ) e)\n subst θ (app e e') = app (subst θ e) (subst θ e')\n\n subst1 : {τ τ0 : TType} → [] ⊢ τ0 → ([] ,, τ0) ⊢ τ → [] ⊢ τ\n subst1 e0 e = subst (tt , e0) e\n\n -- these are not tasks (unless you really want); I didn't get to prove them; sorry!\n compose : {τ1 τ2 : TType} {Γ : Ctx} (θ : [] ⊢c Γ) (e' : [] ⊢ τ1) (e : Γ ,, τ1 ⊢ τ2)\n → subst (θ , e') e ≡ subst1 e' (subst (addvar θ) e)\n compose = {!!}\n\n ident : {Γ : Ctx} {τ : TType} {e : Γ ⊢ τ} → e ≡ subst (id-subst) e\n ident = {!!}\n\n open RenamingAndSubstitution using (subst1 ; _⊢c_ ; subst ; ident ; compose)\n {- θ : Γ ⊢c Γ' means θ is a substitution for Γ' in terms of Γ. It is defined as follows:\n\n _⊢c_ : Ctx → Ctx → Set\n Γ' ⊢c [] = Unit\n Γ' ⊢c (τ ∷ Γ) = (Γ' ⊢c Γ) × (Γ' ⊢ τ)\n\n -- apply a substitution to a term\n subst : {Γ Γ' : Ctx}{τ : TType} → Γ ⊢c Γ' → Γ' ⊢ τ → Γ ⊢ τ\n\n -- substitution for a single variable\n subst1 : {τ τ0 : TType} → [] ⊢ τ0 → ([] ,, τ0) ⊢ τ → [] ⊢ τ\n\n -- you will need these two properties:\n compose : {τ1 τ2 : TType} {Γ : Ctx} (θ : [] ⊢c Γ) (e' : [] ⊢ τ1) (e : Γ ,, τ1 ⊢ τ2)\n → subst (θ , e') e == subst1 e' (subst (addvar θ) e)\n\n ident : {Γ : Ctx} {τ : TType} {e : Γ ⊢ τ} → e == subst (id-subst) e\n -}\n\n\n module OpSem where\n -- step relation\n data _↦_ : {τ : TType} → [] ⊢ τ → [] ⊢ τ → Set where\n Step/app :{τ1 τ2 : TType} {e e' : [] ⊢ τ1 ⇒ τ2} {e1 : [] ⊢ τ1}\n → e ↦ e'\n → (app e e1) ↦ (app e' e1)\n Step/β : {τ1 τ2 : TType} {e : [] ,, τ1 ⊢ τ2} {e1 : [] ⊢ τ1}\n → (app (lam e) e1) ↦ subst1 e1 e\n\n -- reflexive/transitive closure\n data _↦*_ : {τ : TType} → [] ⊢ τ → [] ⊢ τ → Set where\n Done : {τ : TType} {e : [] ⊢ τ} → e ↦* e\n Step : {τ : TType} {e1 e2 e3 : [] ⊢ τ}\n → e1 ↦ e2 → e2 ↦* e3\n → e1 ↦* e3\n open OpSem\n\n\n {- Next, you will prove \"very weak normalization\". The theorem is\n that any closed term *of base type b* evaluates to the constant c.\n No claims are made about terms of function type.\n -}\n module VeryWeakNormalization where\n\n WN : (τ : TType) → [] ⊢ τ → Set\n -- WN_τ(e) iff e ↦* c\n WN b e = e ↦* c\n -- WN_τ(e) iff for all e1 : τ1, if WN_τ1(e1) then WN_τ2(e e1)\n WN (τ1 ⇒ τ2) e = (e1 : [] ⊢ τ1) → WN τ1 e1 → WN τ2 (app e e1)\n\n -- extend WN to contexts and substitutions\n WNc : (Γ : Ctx) → [] ⊢c Γ → Set\n WNc [] θ = tt\n WNc (τ ∷ Γ) (θ , e) = WNc Γ θ × WN τ e\n\n {- TASK 3 : show that the relation is closed under head expansion: -}\n head-expand : (τ : TType) {e e' : [] ⊢ τ} → e ↦ e' → WN τ e' → WN τ e\n head-expand = {!!}\n\n {- TASK 4 : prove the fundamental theorem\n\n Hint: you may find it helpful to use\n transport : {A : Set} (B : A → Set) {a1 a2 : A} → a1 == a2 → (B a1 → B a2)\n to coerce by a propositional equality.\n -}\n fund : {Γ : Ctx} {τ : TType} {θ : [] ⊢c Γ}\n → (e : Γ ⊢ τ)\n → WNc Γ θ\n → WN τ (subst θ e)\n fund = {!!}\n\n {- TASK 5 : conclude weak normalization at base type -}\n corollary : (e : [] ⊢ b) → e ↦* c\n corollary = {!!}\n\n {- TASK 6 : change the definition of the logical relation so that you also can conclude normalization\n at function type.\n -}\n module WeakNormalization where\n\n open RenamingAndSubstitution using (addvar)\n --- you will want to use\n -- addvar : {Γ Γ' : Ctx} {τ : TType} → Γ ⊢c Γ' → (Γ ,, τ) ⊢c (Γ' ,, τ)\n\n -- Hint: you will need a couple of lemmas about ↦* that we didn't need above\n -- (I used three of them)\n\n {- TASK 6a -}\n corollary1 : (e : [] ⊢ b) → e ↦* c\n corollary1 e = {!!}\n\n {- TASK 6b -}\n corollary2 : {τ1 τ2 : TType} (e : [] ⊢ τ1 ⇒ τ2) → Σ \\(e' : _) → e ↦* (lam e')\n corollary2 e = {!!}\n", "meta": {"hexsha": "26efbd3e203e7bcb6784114f0f06b1fb8615b8fd", "size": 7936, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SystemT-original.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-original.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-original.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": 32.0, "max_line_length": 103, "alphanum_fraction": 0.4865171371, "num_tokens": 3350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.7853085808877581, "lm_q1q2_score": 0.5905619358382722}} {"text": "module RAdjunctions.RAdj2RMon where\n\nopen import Function\nopen import Relation.Binary.HeterogeneousEquality\nopen import Categories\nopen import Functors\nopen import RMonads\nopen import RAdjunctions\n\nopen Cat\nopen Fun\nopen RAdj\n\nAdj2Mon : ∀{a b c d e f}{C : Cat {a}{b}}{D : Cat {c}{d}}{E : Cat {e}{f}}\n {J : Fun C D} → RAdj J E → RMonad J\nAdj2Mon {C = C}{D}{E}{J} A = record{\n T = OMap (R A) ∘ OMap (L A);\n η = left A (iden E);\n bind = HMap (R A) ∘ right A;\n law1 = trans (cong (HMap (R A)) (lawa A (iden E))) (fid (R A));\n law2 = λ {_ _ f} → \n trans (cong (comp D (HMap (R A) (right A f))) \n (trans (sym (idr D)) \n (cong (comp D (left A (iden E))) (sym (fid J)))))\n (trans (natleft A (iden C) (right A f) (iden E)) \n (trans (cong (left A) \n (trans (cong (comp E (right A f)) \n (trans (idl E) (fid (L A))))\n (idr E)))\n (lawb A f)));\n law3 = λ{_ _ _ f g} → \n trans (cong (HMap (R A)) \n (trans (trans (cong (right A) \n (cong (comp D (HMap (R A) (right A g))) \n (trans (sym (idr D)) \n (cong (comp D f) \n (sym (fid J)))))) \n (trans (natright A (iden C) (right A g) f) \n (trans (sym (ass E)) \n (cong (comp E (comp E (right A g) \n (right A f)))\n (fid (L A)))))) \n (idr E))) \n (fcomp (R A))}\n", "meta": {"hexsha": "b9828cad4aa42f8f605dcb524249543143e68d4d", "size": 1848, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "RAdjunctions/RAdj2RMon.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": "RAdjunctions/RAdj2RMon.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": "RAdjunctions/RAdj2RMon.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": 41.0666666667, "max_line_length": 79, "alphanum_fraction": 0.3668831169, "num_tokens": 504, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278788223264, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.5902385951698699}} {"text": "module Subset where\n\ndata Subset (A : Set) (P : A -> Set) : Set where\n inn : (a : A) -> .(P a) -> Subset A P\n\nout : forall {A P} -> Subset A P -> A\nout (inn a p) = a\n\n", "meta": {"hexsha": "2504096de7478508c400260afef81024e9051920", "size": 168, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Subset.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/Subset.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/Subset.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.6666666667, "max_line_length": 48, "alphanum_fraction": 0.5238095238, "num_tokens": 64, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278664544912, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.5902385927218241}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.SphereEndomorphism\nopen import groups.Pointed\nopen import groups.SphereEndomorphism\nopen import groups.FromSusp\nopen import cohomology.Theory\n\nmodule cohomology.SphereEndomorphism (CT : CohomologyTheory lzero) (n : ℤ) (m : ℕ) where\n\n open CohomologyTheory CT\n open import cohomology.Cogroup CT n\n (Susp-cogroup-structure (⊙Sphere m))\n (⊙Sphere (S m))\n \n private\n C-fmap' : Trunc-⊙Sphere-endo (S m) → (C n (⊙Sphere (S m)) →ᴳ C n (⊙Sphere (S m)))\n C-fmap' = Trunc-rec λ f → C-fmap n f\n\n CEl-fmap' : Trunc-⊙Sphere-endo (S m) → (CEl n (⊙Sphere (S m)) → CEl n (⊙Sphere (S m)))\n CEl-fmap' f = GroupHom.f (C-fmap' f)\n\n C-fmap'-hom : Trunc-⊙SphereS-endo-group m →ᴳ\n (hom-group (C n (⊙Sphere (S m))) (C-abgroup n (⊙Sphere (S m))))\n C-fmap'-hom = group-hom C-fmap'\n (Trunc-elim λ f → Trunc-elim λ g → C-fmap-preserves-comp f g)\n\n CEl-fmap'-η : ∀ (f : Trunc-⊙Sphere-endo (S m)) (g : CEl n (⊙Sphere (S m)))\n → CEl-fmap' f g == Group.exp (C n (⊙Sphere (S m))) g (Trunc-⊙SphereS-endo-degree m f)\n CEl-fmap'-η f g =\n CEl-fmap' f g\n =⟨ ! $ ap (λ f → CEl-fmap' f g) $ is-equiv.f-g (Trunc-⊙SphereS-endo-⊙group-is-infinite-cyclic m) f ⟩\n CEl-fmap' (Group.exp (Trunc-⊙SphereS-endo-group m) [ ⊙idf _ ] (Trunc-⊙SphereS-endo-degree m f)) g\n =⟨ GroupHom.pres-exp\n (app-hom g ∘ᴳ C-fmap'-hom)\n [ ⊙idf _ ]\n (Trunc-⊙SphereS-endo-degree m f) ⟩\n Group.exp\n (C n (⊙Sphere (S m)))\n (CEl-fmap' [ ⊙idf _ ] g)\n (Trunc-⊙SphereS-endo-degree m f)\n =⟨ ap (λ g → Group.exp (C n (⊙Sphere (S m))) g (Trunc-⊙SphereS-endo-degree m f)) $\n CEl-fmap-idf n g ⟩\n Group.exp\n (C n (⊙Sphere (S m))) g\n (Trunc-⊙SphereS-endo-degree m f)\n =∎\n abstract\n CEl-fmap-⊙Sphere-endo-η : ∀ (f : ⊙Sphere-endo (S m)) (g : CEl n (⊙Sphere (S m)))\n → CEl-fmap n f g == Group.exp (C n (⊙Sphere (S m))) g (⊙SphereS-endo-degree m f)\n CEl-fmap-⊙Sphere-endo-η f = CEl-fmap'-η [ f ]\n", "meta": {"hexsha": "51b26c1a81e3c9074fc9ff774516d90023f54716", "size": 2078, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/SphereEndomorphism.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/SphereEndomorphism.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/SphereEndomorphism.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": 39.2075471698, "max_line_length": 108, "alphanum_fraction": 0.5707410972, "num_tokens": 855, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278633625321, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.5902385906536737}} {"text": "------------------------------------------------------------------------\n-- Properties related to negation\n------------------------------------------------------------------------\n\nmodule Relation.Nullary.Negation where\n\nopen import Relation.Nullary\nopen import Relation.Unary\nopen import Data.Empty\nopen import Data.Function\nopen import Data.Product as Prod\nopen import Data.Fin\nopen import Data.Fin.Dec\nopen import Category.Monad\n\ncontradiction : ∀ {P whatever} → P → ¬ P → whatever\ncontradiction p ¬p = ⊥-elim (¬p p)\n\ncontraposition : ∀ {P Q} → (P → Q) → ¬ Q → ¬ P\ncontraposition f ¬q p = contradiction (f p) ¬q\n\n-- Note also the following use of flip:\n\nprivate\n note : ∀ {P Q} → (P → ¬ Q) → Q → ¬ P\n note = flip\n\n------------------------------------------------------------------------\n-- Quantifier juggling\n\n∃⟶¬∀¬ : ∀ {A} {P : Pred A} → ∃ P → ¬ (∀ x → ¬ P x)\n∃⟶¬∀¬ = flip uncurry\n\n∀⟶¬∃¬ : ∀ {A} {P : Pred A} → (∀ x → P x) → ¬ ∃ λ x → ¬ P x\n∀⟶¬∃¬ ∀xPx (x , ¬Px) = ¬Px (∀xPx x)\n\n¬∃⟶∀¬ : ∀ {A} {P : Pred A} → ¬ ∃ (λ x → P x) → ∀ x → ¬ P x\n¬∃⟶∀¬ = curry\n\n∀¬⟶¬∃ : ∀ {A} {P : Pred A} → (∀ x → ¬ P x) → ¬ ∃ (λ x → P x)\n∀¬⟶¬∃ = uncurry\n\n∃¬⟶¬∀ : ∀ {A} {P : Pred A} → ∃ (λ x → ¬ P x) → ¬ (∀ x → P x)\n∃¬⟶¬∀ = flip ∀⟶¬∃¬\n\n-- When P is a decidable predicate over a finite set the following\n-- lemma can be proved.\n\n¬∀⟶∃¬ : ∀ n (P : Pred (Fin n)) → (∀ i → Dec (P i)) →\n ¬ (∀ i → P i) → ∃ λ i → ¬ P i\n¬∀⟶∃¬ n P dec ¬P = Prod.map id proj₁ $ ¬∀⟶∃¬-smallest n P dec ¬P\n\n------------------------------------------------------------------------\n-- Double-negation\n\n¬¬-map : ∀ {P Q} → (P → Q) → ¬ ¬ P → ¬ ¬ Q\n¬¬-map f = contraposition (contraposition f)\n\n¬¬-drop : {P : Set} → ¬ ¬ ¬ P → ¬ P\n¬¬-drop ¬¬¬P P = ¬¬¬P (λ ¬P → ¬P P)\n\n¬¬-drop-Dec : {P : Set} → Dec P → ¬ ¬ P → P\n¬¬-drop-Dec (yes p) ¬¬p = p\n¬¬-drop-Dec (no ¬p) ¬¬p = ⊥-elim (¬¬p ¬p)\n\n¬-drop-Dec : {P : Set} → Dec (¬ ¬ P) → Dec (¬ P)\n¬-drop-Dec (yes ¬¬p) = no ¬¬p\n¬-drop-Dec (no ¬¬¬p) = yes (¬¬-drop ¬¬¬p)\n\n-- Double-negation is a monad (if we assume that all elements of ¬ ¬ P\n-- are equal).\n\n¬¬-Monad : RawMonad (λ P → ¬ ¬ P)\n¬¬-Monad = record\n { return = contradiction\n ; _>>=_ = λ x f → ¬¬-drop (¬¬-map f x)\n }\n\n¬¬-push : {P : Set} {Q : P → Set} →\n ¬ ¬ ((x : P) → Q x) → (x : P) → ¬ ¬ Q x\n¬¬-push ¬¬P⟶Q P ¬Q = ¬¬P⟶Q (λ P⟶Q → ¬Q (P⟶Q P))\n\n-- A double-negation-translated variant of excluded middle (or: every\n-- nullary relation is decidable in the double-negation monad).\n\nexcluded-middle : {P : Set} → ¬ ¬ Dec P\nexcluded-middle ¬h = ¬h (no (λ p → ¬h (yes p)))\n\n-- If whatever is instantiated with ¬ ¬ something, then this function\n-- is call with current continuation in the double-negation monad, or,\n-- if you will, a double-negation translation of Peirce's law.\n--\n-- In order to prove ¬ ¬ P one can assume ¬ P and prove ⊥. However, it\n-- is sometimes nice to avoid leaving the double-negation monad; in\n-- that case this function can be used (with whatever instantiated to\n-- ⊥).\n\ncall/cc : ∀ {whatever P : Set} → ((P → whatever) → ¬ ¬ P) → ¬ ¬ P\ncall/cc hyp ¬p = hyp (λ p → ⊥-elim (¬p p)) ¬p\n", "meta": {"hexsha": "2d2971e75210d3612cdcf63ad7c582fab8181300", "size": 3067, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Relation/Nullary/Negation.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/Negation.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/Negation.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.67, "max_line_length": 72, "alphanum_fraction": 0.485164656, "num_tokens": 1159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.7371581510799252, "lm_q1q2_score": 0.5902366358495373}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Decidable semi-heterogeneous vector equality over setoids\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary\n\nmodule Data.Vec.Relation.Binary.Equality.DecSetoid\n {a ℓ} (DS : DecSetoid a ℓ) where\n\nopen import Data.Nat using (ℕ)\nimport Data.Vec.Relation.Binary.Equality.Setoid as Equality\nimport Data.Vec.Relation.Binary.Pointwise.Inductive as PW\nopen import Level using (_⊔_)\nopen import Relation.Binary using (Decidable)\n\nopen DecSetoid DS\n\n------------------------------------------------------------------------\n-- Make all definitions from equality available\n\nopen Equality setoid public\n\n------------------------------------------------------------------------\n-- Additional properties\n\ninfix 4 _≋?_\n\n_≋?_ : ∀ {m n} → Decidable (_≋_ {m} {n})\n_≋?_ = PW.decidable _≟_\n\n≋-isDecEquivalence : ∀ n → IsDecEquivalence (_≋_ {n})\n≋-isDecEquivalence = PW.isDecEquivalence isDecEquivalence\n\n≋-decSetoid : ℕ → DecSetoid a (a ⊔ ℓ)\n≋-decSetoid = PW.decSetoid DS\n", "meta": {"hexsha": "ea630b979b2a408e24e472443a79e6f8b0a4a5f7", "size": 1148, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/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/Vec/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/Vec/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.7, "max_line_length": 72, "alphanum_fraction": 0.5496515679, "num_tokens": 274, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.590150231498281}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Addition\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Multiplication\nopen import Semirings.Definition\nopen import Orders.Total.Definition\n\nmodule Numbers.Naturals.Naturals where\n\nrecord subtractionNResult (a b : ℕ) .(p : a ≤N b) : Set where\n field\n result : ℕ\n pr : a +N result ≡ b\n\nsubtractionNWellDefined : {a b : ℕ} → {p1 p2 : a ≤N b} → (s : subtractionNResult a b p1) → (t : subtractionNResult a b p2) → (subtractionNResult.result s ≡ subtractionNResult.result t)\nsubtractionNWellDefined {a} {b} {inl x} {pr2} record { result = result1 ; pr = pr1 } record { result = result ; pr = pr } = canSubtractFromEqualityLeft {a} (transitivity pr1 (equalityCommutative pr))\nsubtractionNWellDefined {a} {.a} {inr refl} {pr2} record { result = result1 ; pr = pr1 } record { result = result2 ; pr = pr } = transitivity g' (equalityCommutative g)\n where\n g : result2 ≡ 0\n g = canSubtractFromEqualityLeft {a} {_} {0} (transitivity pr (equalityCommutative (addZeroRight a)))\n g' : result1 ≡ 0\n g' = canSubtractFromEqualityLeft {a} {_} {0} (transitivity pr1 (equalityCommutative (addZeroRight a)))\n\n-N : {a : ℕ} → {b : ℕ} → (pr : a ≤N b) → subtractionNResult a b pr\n-N {zero} {b} prAB = record { result = b ; pr = refl }\n-N {succ a} {zero} (inl ())\n-N {succ a} {zero} (inr ())\n-N {succ a} {succ b} (inl x) with -N {a} {b} (inl (canRemoveSuccFrom>=_\n\n field\n return : ∀ {A} → A → M A\n _>>=_ : ∀ {A B} → M A → (A → M B) → M B\n\n\n------------------------------------------------------------------------\n-- The partiality monad\n\ndata _⊥ {a} (A : Set a) : Set a where\n now : (x : A) → A ⊥\n later : (x : ∞ (A ⊥)) → A ⊥\n\n-- Fails if hidden pattern {f} is removed\nmonad : ∀ {f} → RawMonad {f = f} _⊥\n-- monad {f} = record\nmonad = record\n { return = now\n ; _>>=_ = _>>=_\n }\n where\n _>>=_ : ∀ {A B} → A ⊥ → (A → B ⊥) → B ⊥\n now x >>= f = f x\n later x >>= f = later (♯ (♭ x >>= f))\n", "meta": {"hexsha": "2492bd3ebc76db77e12da03bb29c616072e21b3a", "size": 797, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/PartialityMonad.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/PartialityMonad.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/PartialityMonad.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.7714285714, "max_line_length": 72, "alphanum_fraction": 0.4592220828, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5901502208030031}} {"text": "module Function.Iteration.Proofs where\n\nimport Lvl\nopen import Functional\nopen import Function.Names as Names using (_⊜_)\nopen import Function.Iteration\nopen import Function.Proofs\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper using (_+_ ; _⋅_ ; _𝄩_)\nopen import Numeral.Natural.Oper.Proofs\nimport Structure.Function.Names as Names\nimport Structure.Function\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Proofs.Util\nimport Structure.Operator.Names as Names\nimport Structure.Operator\nopen import Structure.Relator.Properties\nopen import Structure.Function.Domain\nopen import Syntax.Transitivity\nopen import Type\n\nprivate variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level\nprivate variable T A B C X Y Z : Type{ℓ}\n\nmodule _ where\n open import Structure.Setoid\n open Structure.Function\n open Structure.Operator\n\n module _ ⦃ equiv-X : Equiv{ℓₑ}(X) ⦄ where\n -- Propositions that state something about arbitrary composed functions also apply to arbitrary function iterations of the first function.\n [^]-from-[∘]-proof : ∀{ℓ₂}{P : (X → X) → Type{ℓ₂}} → (∀{f g : X → X} → P(f ∘ g)) → (∀{f : X → X}{n} → P(f ^ n))\n [^]-from-[∘]-proof {P = P} p {f} {𝟎} = p{id}{id}\n [^]-from-[∘]-proof {P = P} p {f} {𝐒 n} = p{f}{f ^ n}\n\n [^]-function-raw : ∀{f : X → X} → Names.Congruence₁(f) → ∀{n} → Names.Congruence₁(f ^ n)\n [^]-function-raw func-f {𝟎} xy = xy\n [^]-function-raw func-f {𝐒(n)} xy = func-f([^]-function-raw func-f {n} xy)\n\n -- Iterated function is a function when the function is.\n [^]-function : ∀{f : X → X} → ⦃ func : Function(f) ⦄ → ∀{n} → Function(f ^ n)\n Function.congruence ([^]-function ⦃ intro func-f ⦄ {n}) = [^]-function-raw func-f {n}\n\n [^]-injective-raw : ∀{f : X → X} → Names.Injective(f) → ∀{n} → Names.Injective(f ^ n)\n [^]-injective-raw inj-f {𝟎} fnxfny = fnxfny\n [^]-injective-raw inj-f {𝐒(n)} fnxfny = [^]-injective-raw inj-f {n} (inj-f fnxfny)\n\n -- Iterated function is injective when the function is.\n [^]-injective : ∀{f : X → X} → ⦃ inj : Injective(f) ⦄ → ∀{n} → Injective(f ^ n)\n Injective.proof ([^]-injective ⦃ intro inj-f ⦄ {n}) = [^]-injective-raw inj-f {n}\n\n [^]-surjective-raw : ∀{f : X → X} → ⦃ func : Function(f) ⦄ → Names.Surjective(f) → ∀{n} → Names.Surjective(f ^ n)\n [^]-surjective-raw surj-f {𝟎} {y} = [∃]-intro y ⦃ reflexivity(_≡_) ⦄\n [^]-surjective-raw {f} surj-f {𝐒(n)} {y} = [∃]-map-proof (p ↦ (congruence₁(f) p) 🝖 [∃]-proof(surj-f {y})) ([^]-surjective-raw surj-f {n} {[∃]-witness(surj-f {y})})\n\n -- Iterated function is surjective when the function is.\n [^]-surjective : ∀{f : X → X} → ⦃ func : Function(f) ⦄ → ⦃ surj : Surjective(f) ⦄ → ∀{n} → Surjective(f ^ n)\n Surjective.proof ([^]-surjective ⦃ _ ⦄ ⦃ intro surj-f ⦄ {n}) = [^]-surjective-raw surj-f {n}\n\n -- Argument applied to the iterated function is one extra iteration.\n -- Note: This implies: (f ^ n)(f x) ≡ f((f ^ n)(x))\n [^]-inner-value : ∀{f : X → X} → ⦃ func : Function(f) ⦄ → ∀{x}{n} → ((f ^ n)(f x) ≡ (f ^ (𝐒(n)))(x))\n [^]-inner-value {f} {x} {𝟎} = reflexivity(_≡_)\n [^]-inner-value {f} {x} {𝐒 n} = congruence₁(f) ([^]-inner-value {f} {x} {n})\n\n -- A fixpoint of the function is also a fixpoint of the iterated function.\n [^]-of-fixpoint : ∀{f : X → X} → ⦃ func : Function(f) ⦄ → ∀{x : X} → ⦃ fix : Fixpoint f(x) ⦄ → ∀{n} → ((f ^ n)(x) ≡ x)\n [^]-of-fixpoint {f} {x} {𝟎} = reflexivity(_≡_)\n [^]-of-fixpoint {f} {x} {𝐒(n)} =\n (f ^ 𝐒(n))(x) 🝖-[ reflexivity(_≡_) ]\n (f ∘ (f ^ n))(x) 🝖-[ reflexivity(_≡_) ]\n f((f ^ n)(x)) 🝖-[ congruence₁(f) ([^]-of-fixpoint {f} {x} {n}) ]\n f(x) 🝖-[ fixpoint f(x) ]\n x 🝖-end\n\n module _ ⦃ equiv-XX : Equiv{ℓₑ}(X → X) ⦄ where\n [^]-by-1 : ∀{f : X → X} → (f ^ 1 ≡ f)\n [^]-by-1 {f} = reflexivity(_≡_)\n\n [^]-of-id : ∀{n} → (id ^ n ≡ id)\n [^]-of-id {𝟎} = reflexivity(_≡_)\n [^]-of-id {𝐒 n} = [^]-of-id {n}\n\n [^]-inner : ∀{f : X → X} → ⦃ _ : Function(f ∘_) ⦄ → ∀{n} → ((f ^ n) ∘ f ≡ f ^ (𝐒(n)))\n [^]-inner {f} {𝟎} = reflexivity(_≡_)\n [^]-inner {f} {𝐒 n} = congruence₁(f ∘_) ([^]-inner {f} {n})\n\n [^]-add : ⦃ [∘]-op : BinaryOperator(_∘_) ⦄ → ∀{f : X → X} → ∀{a b} → ((f ^ a) ∘ (f ^ b) ≡ f ^ (a + b))\n [^]-add {f} {𝟎} {𝟎} = reflexivity(_≡_)\n [^]-add {f} {𝟎} {𝐒 b} = reflexivity(_≡_)\n [^]-add {f} {𝐒 a} {𝟎} = reflexivity(_≡_)\n [^]-add ⦃ [∘]-op ⦄ {f} {𝐒 a} {𝐒 b} =\n (f ^ 𝐒(a)) ∘ (f ^ 𝐒(b)) 🝖-[ reflexivity(_≡_) ]\n (f ^ 𝐒(a)) ∘ (f ∘ (f ^ b)) 🝖-[ reflexivity(_≡_) ]\n ((f ^ 𝐒(a)) ∘ f) ∘ (f ^ b) 🝖-[ congruence₂ₗ(_∘_)(f ^ b) ([^]-inner {f} ⦃ [≡]-congruence2-right(_∘_)(f) ⦄ {𝐒(a)}) ]\n f ∘ ((f ^ 𝐒(a)) ∘ (f ^ b)) 🝖-[ reflexivity(_≡_) ]\n (f ∘ (f ^ 𝐒(a))) ∘ (f ^ b) 🝖-[ congruence₂ᵣ(_∘_)(f) ([^]-add{f} {𝐒 a} {b}) ]\n f ∘ (f ^ (𝐒(a) + b)) 🝖-[ reflexivity(_≡_) ]\n f ^ (𝐒(a) + 𝐒(b)) 🝖-end\n\n [^]-multiply : ⦃ [∘]-op : BinaryOperator(_∘_) ⦄ → ∀{f : X → X} → ∀{a b} → ((f ^ a) ^ b ≡ f ^ (a ⋅ b))\n [^]-multiply ⦃ [∘]-op ⦄ {f} {𝟎} {𝟎} = reflexivity(_≡_)\n [^]-multiply ⦃ [∘]-op ⦄ {f} {𝟎} {𝐒 b} = [^]-of-id {𝐒 b}\n [^]-multiply ⦃ [∘]-op ⦄ {f} {𝐒 a} {𝟎} = reflexivity(_≡_)\n [^]-multiply ⦃ [∘]-op ⦄ {f} {𝐒 a} {𝐒 b} =\n (f ^ 𝐒(a)) ^ 𝐒(b) 🝖-[ reflexivity(_≡_) ]\n (f ^ 𝐒(a)) ∘ ((f ^ 𝐒(a)) ^ b) 🝖-[ congruence₂ᵣ(_∘_)(f ^ 𝐒(a)) ([^]-multiply{f} {𝐒 a} {b}) ]\n (f ^ 𝐒(a)) ∘ (f ^ (𝐒(a) ⋅ b)) 🝖-[ [^]-add {f} {𝐒(a)} {𝐒(a) ⋅ b} ]\n f ^ (𝐒(a) + (𝐒(a) ⋅ b)) 🝖-[ reflexivity(_≡_) ]\n f ^ (𝐒(a) ⋅ 𝐒(b)) 🝖-end\n\n [^]-distanceₗ : ⦃ [∘]-op : BinaryOperator(_∘_) ⦄ → ∀{f : X → X}{a b} → (f ^ a ≡ f ^ b) ← (f ^ (a 𝄩 b) ≡ id)\n [^]-distanceₗ {f} {𝟎} {𝟎} = id\n [^]-distanceₗ {f} {𝟎} {𝐒 b} = symmetry(_≡_)\n [^]-distanceₗ {f} {𝐒 a} {𝟎} = id\n [^]-distanceₗ {f} {𝐒 a} {𝐒 b} = congruence₂ᵣ(_∘_)(f) ∘ ([^]-distanceₗ {f} {a} {b})\n\n [^]-distanceᵣ : ⦃ [∘]-op : BinaryOperator(_∘_) ⦄ → ⦃ [∘]-cancₗ : Cancellationₗ(_∘_) ⦄ → ∀{f : X → X}{a b} → (f ^ a ≡ f ^ b) → (f ^ (a 𝄩 b) ≡ id)\n [^]-distanceᵣ {f} {𝟎} {𝟎} = id\n [^]-distanceᵣ {f} {𝟎} {𝐒 b} = symmetry(_≡_)\n [^]-distanceᵣ {f} {𝐒 a} {𝟎} = id\n [^]-distanceᵣ {f} {𝐒 a} {𝐒 b} p = [^]-distanceᵣ {f} {a} {b} (cancellationₗ(_∘_) {f} p)\n\n module _ ⦃ op : BinaryOperator(_∘_) ⦄ ⦃ assoc : Associativity(_∘_) ⦄ where\n [^]-commuting : ∀{f g : X → X} → Names.Commuting(_∘_)(f)(g) → ∀{a b} → Names.Commuting(_∘_)(f ^ a)(g ^ b)\n [^]-commuting {f} {g} com {𝟎} {𝟎} = reflexivity(_≡_)\n [^]-commuting {f} {g} com {𝟎} {𝐒 b} = reflexivity(_≡_)\n [^]-commuting {f} {g} com {𝐒 a} {𝟎} = reflexivity(_≡_)\n [^]-commuting {f} {g} com {𝐒 a} {𝐒 b} =\n (f ^ 𝐒(a)) ∘ (g ^ 𝐒(b)) 🝖-[ reflexivity(_≡_) ]\n (f ∘ (f ^ a)) ∘ (g ∘ (g ^ b)) 🝖-[ One.associate-commute4 {a = f} {f ^ a} {g} {g ^ b} ([^]-commuting {f} {g} com {a} {1}) ]\n (f ∘ g) ∘ ((f ^ a) ∘ (g ^ b)) 🝖-[ congruence₂(_∘_) com ([^]-commuting {f} {g} com {a} {b}) ]\n (g ∘ f) ∘ ((g ^ b) ∘ (f ^ a)) 🝖-[ One.associate-commute4 {a = g} {f} {g ^ b} {f ^ a} ([^]-commuting {f} {g} com {1} {b}) ]\n (g ∘ (g ^ b)) ∘ (f ∘ (f ^ a)) 🝖-[ reflexivity(_≡_) ]\n (g ^ 𝐒(b)) ∘ (f ^ 𝐒(a)) 🝖-end\n\n [^]-of-[∘] : ∀{f : X → X}{g : X → X} → Names.Commuting(_∘_)(f)(g) → ∀{n} → ((f ∘ g) ^ n ≡ (f ^ n) ∘ (g ^ n))\n [^]-of-[∘] {f}{g} com {𝟎} = reflexivity(_≡_)\n [^]-of-[∘] {f}{g} com {𝐒 n} =\n (f ∘ g) ^ 𝐒(n) 🝖-[ reflexivity(_≡_) ]\n (f ∘ g) ∘ ((f ∘ g) ^ n) 🝖-[ congruence₂ᵣ(_∘_)(f ∘ g) ([^]-of-[∘] {f}{g} com {n}) ]\n (f ∘ g) ∘ ((f ^ n) ∘ (g ^ n)) 🝖-[ One.associate-commute4 {a = f} {g} {f ^ n}{g ^ n} (symmetry(_≡_) ([^]-commuting {f} {g} com {n} {1})) ]\n (f ∘ (f ^ n)) ∘ (g ∘ (g ^ n)) 🝖-[ reflexivity(_≡_) ]\n (f ^ 𝐒(n)) ∘ (g ^ 𝐒(n)) 🝖-end\n\n module _ {ℓ₁}{ℓ₂} {X : Type{ℓ₁}} ⦃ equiv-x : Equiv{ℓₑ₁}(X) ⦄ {Y : Type{ℓ₂}} ⦃ equiv-y : Equiv{ℓₑ₂}(Y) ⦄ where\n private variable n : ℕ\n private variable x : X\n private variable init : Y\n\n repeatᵣₗ-flip-equality : ∀{_▫_ : Y → X → Y} → ⦃ op : BinaryOperator(_▫_) ⦄ → (repeatᵣ n (swap(_▫_)) x init ≡ repeatₗ n (_▫_) init x)\n repeatᵣₗ-flip-equality {n = 𝟎} = reflexivity(_≡_)\n repeatᵣₗ-flip-equality {n = 𝐒(n)}{x = x}{_▫_ = _▫_} = congruence₂ₗ(_▫_)(x) (repeatᵣₗ-flip-equality {n = n}{_▫_ = _▫_})\n\n repeatₗᵣ-flip-equality : ∀{_▫_ : X → Y → Y} → ⦃ op : BinaryOperator(_▫_) ⦄ → (repeatₗ n (swap _▫_) init x ≡ repeatᵣ n (_▫_) x init)\n repeatₗᵣ-flip-equality {n = n}{init = init}{x = x}{_▫_ = _▫_} = symmetry(_≡_) (repeatᵣₗ-flip-equality {n = n}{x = x}{init = init}{_▫_ = swap(_▫_)} ⦃ op = swap-binaryOperator ⦄)\n\n module _ ⦃ equiv-X : Equiv{ℓₑ}(X) ⦄ where\n private variable f : X → X\n private variable _▫_ : X → X → X\n private variable x elem init : X\n private variable n : ℕ\n\n [^]-from-repeatᵣ-alt : ⦃ func : Function(f) ⦄ → ((f ^ n) ⊜ repeatᵣ(n) (f ∘_) id)\n [^]-from-repeatᵣ-alt {n = 𝟎} = reflexivity(_≡_)\n [^]-from-repeatᵣ-alt {f}{n = 𝐒 n} = congruence₁(f) ([^]-from-repeatᵣ-alt {n = n})\n\n [^]-from-repeatᵣ : ⦃ func : Function(f) ⦄ → ((f ^ n) ⊜ repeatᵣ(n) (_∘_) f id)\n [^]-from-repeatᵣ {n = 𝟎} = reflexivity(_≡_)\n [^]-from-repeatᵣ {f}{n = 𝐒 n} = congruence₁(f) ([^]-from-repeatᵣ {f}{n = n})\n\n -- TODO: Should also be provable using associativity? Prove (CommutingOn(_▫_)(x)(x) → AssociativityOn(_▫_)(x)). Is this helping?\n repeat-swap-side : ⦃ op : BinaryOperator(_▫_) ⦄ ⦃ comm : Commutativity(_▫_) ⦄ → (repeatₗ n (_▫_) x x ≡ repeatᵣ n (_▫_) x x)\n repeat-swap-side {n = 𝟎} = reflexivity(_≡_)\n repeat-swap-side {_▫_ = _▫_}{n = 𝐒 n}{x} = congruence₂ₗ(_▫_)(x) (repeat-swap-side {n = n}) 🝖 commutativity(_▫_)\n\n repeat-swap-side-by-associativity : ⦃ op : BinaryOperator(_▫_) ⦄ ⦃ _ : Associativity(_▫_) ⦄ → (repeatₗ n (_▫_) x x ≡ repeatᵣ n (_▫_) x x)\n repeat-swap-side-by-associativity {n = 𝟎} = reflexivity(_≡_)\n repeat-swap-side-by-associativity {n = 𝐒 𝟎} {x} = reflexivity(_≡_)\n repeat-swap-side-by-associativity {_▫_ = _▫_} {n = 𝐒(𝐒 n)}{x} =\n repeatₗ (𝐒(𝐒(n))) (_▫_) x x 🝖[ _≡_ ]-[]\n repeatₗ (𝐒(n)) (_▫_) x x ▫ x 🝖[ _≡_ ]-[ congruence₂ₗ(_▫_)(x) (repeat-swap-side-by-associativity {n = 𝐒 n}) ]\n repeatᵣ (𝐒(n)) (_▫_) x x ▫ x 🝖[ _≡_ ]-[]\n (x ▫ repeatᵣ n (_▫_) x x) ▫ x 🝖[ _≡_ ]-[ associativity(_▫_) ]\n x ▫ (repeatᵣ n (_▫_) x x ▫ x) 🝖[ _≡_ ]-[ congruence₂ᵣ(_▫_)(x) (congruence₂ₗ(_▫_)(x) (repeat-swap-side-by-associativity {n = n})) ]-sym\n x ▫ (repeatₗ n (_▫_) x x ▫ x) 🝖[ _≡_ ]-[]\n x ▫ repeatₗ (𝐒(n)) (_▫_) x x 🝖[ _≡_ ]-[ congruence₂ᵣ(_▫_)(x) (repeat-swap-side-by-associativity {n = 𝐒(n)}) ]\n x ▫ repeatᵣ (𝐒(n)) (_▫_) x x 🝖[ _≡_ ]-[]\n repeatᵣ (𝐒(𝐒(n))) (_▫_) x x 🝖[ _≡_ ]-end\n\n repeat-with-id-swap-side : ⦃ op : BinaryOperator(_▫_) ⦄ ⦃ comm : Commutativity(_▫_) ⦄ ⦃ ident : Identity(_▫_)(init) ⦄ → (repeatₗ n (_▫_) init x ≡ repeatᵣ n (_▫_) x init)\n repeat-with-id-swap-side {n = 𝟎} = reflexivity(_≡_)\n repeat-with-id-swap-side {_▫_ = _▫_}{n = 𝐒 n}{x = x} = congruence₂ₗ(_▫_)(x) (repeat-with-id-swap-side {n = n}) 🝖 commutativity(_▫_)\n\n repeat-raise-equality : ⦃ op : BinaryOperator(_▫_) ⦄ → (repeatᵣ n (_▫_) elem (x) ≡ ((elem ▫_) ^ n)(x))\n repeat-raise-equality {n = 𝟎} = reflexivity(_≡_)\n repeat-raise-equality{_▫_ = _▫_}{n = 𝐒(n)}{elem}{x} = congruence₂ᵣ(_▫_)(elem) (repeat-raise-equality{_▫_ = _▫_}{n = n}{elem}{x})\n\n\nmodule _ {X : Type{ℓ}} where\n open import Relator.Equals\n open import Relator.Equals.Proofs\n\n raise-repeat-equality : ∀{n : ℕ}{f : X → X} → (f ^ n ≡ repeatᵣ n (_∘_) f id)\n raise-repeat-equality{𝟎} = reflexivity(_≡_)\n raise-repeat-equality{𝐒(n)}{f} = [≡]-with(f ∘_) (raise-repeat-equality{n}{f})\n\nmodule _ where\n open import Structure.Setoid\n open Structure.Function\n open Structure.Operator\n\n module _ ⦃ equiv-X : Equiv{ℓₑ}(X) ⦄ where\n repeatₗ-by-0 : ∀{_▫_ : X → X → X}{x id} → ⦃ _ : Identityᵣ(_▫_)(id) ⦄ → (repeatᵣ 0 (_▫_) x id ≡ id)\n repeatₗ-by-0 {_▫_} {x}{id} ⦃ identᵣ ⦄ = reflexivity(_≡_)\n\n repeatₗ-by-1 : ∀{_▫_ : X → X → X}{x id} → ⦃ _ : Identityᵣ(_▫_)(id) ⦄ → (repeatᵣ 1 (_▫_) x id ≡ x)\n repeatₗ-by-1 {_▫_} {x}{id} ⦃ identᵣ ⦄ = identityᵣ(_▫_)(id)\n\n repeatₗ-by-sum : ∀{_▫_ : X → X → X}{x id} → ⦃ _ : BinaryOperator(_▫_) ⦄ → ⦃ _ : Identityᵣ(_▫_)(id) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → ∀{a b} → ((repeatₗ a (_▫_) id x) ▫ (repeatₗ b (_▫_) id x) ≡ repeatₗ (a + b) (_▫_) id x)\n repeatₗ-by-sum {_▫_} {x} {id} ⦃ identᵣ ⦄ {a} {𝟎} =\n (repeatₗ a (_▫_) id x) ▫ (repeatₗ 𝟎 (_▫_) id x) 🝖-[ reflexivity(_≡_) ]\n (repeatₗ a (_▫_) id x) ▫ id 🝖-[ identityᵣ(_▫_)(id) ]\n repeatₗ a (_▫_) id x 🝖-[ reflexivity(_≡_) ]\n repeatₗ (a + 𝟎) (_▫_) id x 🝖-end\n repeatₗ-by-sum {_▫_} {x} {id} ⦃ identᵣ ⦄ {a} {𝐒 b} =\n (repeatₗ a (_▫_) id x) ▫ (repeatₗ (𝐒(b)) (_▫_) id x) 🝖-[ reflexivity(_≡_) ]\n (repeatₗ a (_▫_) id x) ▫ ((repeatₗ b (_▫_) id x) ▫ x) 🝖-[ symmetry(_≡_) (associativity(_▫_)) ]\n ((repeatₗ a (_▫_) id x) ▫ (repeatₗ b (_▫_) id x)) ▫ x 🝖-[ congruence₂ₗ(_▫_)(_) (repeatₗ-by-sum{a = a}{b = b}) ]\n (repeatₗ (a + b) (_▫_) id x) ▫ x 🝖-[ reflexivity(_≡_) ]\n repeatₗ (a + 𝐒(b)) (_▫_) id x 🝖-end\n\n repeatₗ-by-product : ∀{_▫_ : X → X → X}{x id} → ⦃ _ : BinaryOperator(_▫_) ⦄ → ⦃ _ : Identityᵣ(_▫_)(id) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → ∀{a b} → (repeatₗ b (_▫_) id ((repeatₗ a (_▫_) id x)) ≡ repeatₗ (a ⋅ b) (_▫_) id x)\n repeatₗ-by-product {_▫_} {x} {id} ⦃ identᵣ ⦄ {a} {𝟎} =\n repeatₗ 𝟎 (_▫_) id ((repeatₗ a (_▫_) id x)) 🝖-[ reflexivity(_≡_) ]\n repeatₗ (a ⋅ 𝟎) (_▫_) id x 🝖-end\n repeatₗ-by-product {_▫_} {x} {id} ⦃ identᵣ ⦄ {a} {𝐒 b} =\n repeatₗ (𝐒(b)) (_▫_) id ((repeatₗ a (_▫_) id x)) 🝖-[ reflexivity(_≡_) ]\n (repeatₗ b (_▫_) id ((repeatₗ a (_▫_) id x))) ▫ (repeatₗ a (_▫_) id x) 🝖-[ congruence₂ₗ(_▫_)(_) (repeatₗ-by-product{a = a}{b = b}) ]\n (repeatₗ (a ⋅ b) (_▫_) id x) ▫ (repeatₗ a (_▫_) id x) 🝖-[ repeatₗ-by-sum {a = a ⋅ b}{a} ]\n repeatₗ ((a ⋅ b) + a) (_▫_) id x 🝖-[ [≡]-to-equivalence (congruence₁(expr ↦ repeatₗ expr (_▫_) id x) {a ⋅ b + a}{a + a ⋅ b} (commutativity(_+_) {a ⋅ b})) ]\n repeatₗ (a ⋅ 𝐒(b)) (_▫_) id x 🝖-end\n where\n open import Relator.Equals.Proofs.Equiv using ([≡]-to-equivalence)\n\n repeatₗ-by-distanceₗ : ∀{_▫_ : X → X → X}{x id} → ⦃ _ : BinaryOperator(_▫_) ⦄ → ⦃ _ : Identityᵣ(_▫_)(id) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → ∀{a b} → (repeatₗ a (_▫_) id x ≡ repeatₗ b (_▫_) id x) ← (repeatₗ (a 𝄩 b) (_▫_) id x ≡ id)\n repeatₗ-by-distanceₗ {_▫_} {x} {id} {𝟎} {𝟎} p = p\n repeatₗ-by-distanceₗ {_▫_} {x} {id} {𝟎} {𝐒 b} p = symmetry(_≡_) p\n repeatₗ-by-distanceₗ {_▫_} {x} {id} {𝐒 a} {𝟎} p = p\n repeatₗ-by-distanceₗ {_▫_} {x} {id} {𝐒 a} {𝐒 b} p = congruence₂ₗ(_▫_)(_) (repeatₗ-by-distanceₗ {_▫_} {x} {id} {a} {b} p)\n\n repeatₗ-by-distanceᵣ : ∀{_▫_ : X → X → X}{x id} → ⦃ _ : BinaryOperator(_▫_) ⦄ → ⦃ _ : Identityᵣ(_▫_)(id) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → ⦃ cancᵣ : Cancellationᵣ(_▫_) ⦄ → ∀{a b} → (repeatₗ a (_▫_) id x ≡ repeatₗ b (_▫_) id x) → (repeatₗ (a 𝄩 b) (_▫_) id x ≡ id)\n repeatₗ-by-distanceᵣ {_▫_} {x} {id} {𝟎} {𝟎} p = p\n repeatₗ-by-distanceᵣ {_▫_} {x} {id} {𝟎} {𝐒 b} p = symmetry(_≡_) p\n repeatₗ-by-distanceᵣ {_▫_} {x} {id} {𝐒 a} {𝟎} p = p\n repeatₗ-by-distanceᵣ {_▫_} {x} {id} {𝐒 a} {𝐒 b} p = repeatₗ-by-distanceᵣ {_▫_} {x} {id} {a} {b} (cancellationᵣ(_▫_) {x} p)\n", "meta": {"hexsha": "6222abf5579673f94fe073185babf3f418396fc7", "size": 15853, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Function/Iteration/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": "Function/Iteration/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": "Function/Iteration/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": 61.2084942085, "max_line_length": 265, "alphanum_fraction": 0.4910742446, "num_tokens": 7576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5901502208030031}} {"text": "-- Andreas, 2019-03-02, issue #3601 reported by 3abc\n\n{-# OPTIONS --cubical --safe #-}\n\nopen import Agda.Primitive.Cubical renaming\n (primINeg to ~_; primIMin to _∧_; primTransp to transp)\n\nopen import Agda.Builtin.Cubical.Path\n\nmodule _ (A : Set) (x y z t : A) (f : y ≡ z) (g : y ≡ x) (h : z ≡ t) where\n\n test : PathP (λ i → g i ≡ h i) f (transp (λ i → g i ≡ h i) i0 f)\n test k i = transp (λ i → g (i ∧ k) ≡ h (i ∧ k)) (~ k) f i\n\n-- Should pass.\n-- Problem was: Agda did not accept overapplied primTransp\n\n\n -- Also should pass.\n -- We had a problem with checking the sides at the right type.\n test2 : ∀ {ℓ} (i : I) {A : Partial i (Set ℓ)}\n → PartialP i (λ z → A z)\n → (r : IsOne i)\n → A r\n test2 i {A} u r = primPOr i i {A} u (λ o → u o) r\n", "meta": {"hexsha": "bba999a0dd415d4be2658e1108579b489c4fc0df", "size": 776, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue3601.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/Issue3601.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/Issue3601.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": 29.8461538462, "max_line_length": 74, "alphanum_fraction": 0.5631443299, "num_tokens": 301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677545357568, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.5901502127816446}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Container Morphisms\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Container.Morphism where\n\nopen import Data.Container.Core\nimport Function as F\n\nmodule _ {s p} (C : Container s p) where\n\n id : C ⇒ C\n id .shape = F.id\n id .position = F.id\n\nmodule _ {s₁ s₂ s₃ p₁ p₂ p₃}\n {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂} {C₃ : Container s₃ p₃}\n where\n\n infixr 9 _∘_\n _∘_ : C₂ ⇒ C₃ → C₁ ⇒ C₂ → C₁ ⇒ C₃\n (f ∘ g) .shape = shape f F.∘′ shape g\n (f ∘ g) .position = position g F.∘′ position f\n", "meta": {"hexsha": "b0f68b963141143212b4c44f1a2f456aaf684c66", "size": 702, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Morphism.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/Morphism.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/Morphism.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": 25.0714285714, "max_line_length": 77, "alphanum_fraction": 0.4686609687, "num_tokens": 215, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513731336202, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.5901076009881481}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of the polymorphic unit type\n-- Defines Decidable Equality and Decidable Ordering as well\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Unit.Polymorphic.Properties where\n\nopen import Level\nopen import Data.Sum.Base using (inj₁)\nopen import Data.Unit.Polymorphic.Base using (⊤; tt)\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\nprivate\n variable\n ℓ : Level\n\n------------------------------------------------------------------------\n-- Equality\n------------------------------------------------------------------------\n\ninfix 4 _≟_\n\n_≟_ : Decidable {A = ⊤ {ℓ}} _≡_\n_ ≟ _ = yes refl\n\n≡-setoid : ∀ ℓ → Setoid ℓ ℓ\n≡-setoid _ = setoid ⊤\n\n≡-decSetoid : ∀ ℓ → DecSetoid ℓ ℓ\n≡-decSetoid _ = decSetoid _≟_\n\n------------------------------------------------------------------------\n-- Ordering\n------------------------------------------------------------------------\n\n≡-total : Total {A = ⊤ {ℓ}} _≡_\n≡-total _ _ = inj₁ refl\n\n≡-antisym : Antisymmetric {A = ⊤ {ℓ}} _≡_ _≡_\n≡-antisym p _ = p\n\n------------------------------------------------------------------------\n-- Structures\n\n≡-isPreorder : ∀ ℓ → IsPreorder {ℓ} {_} {⊤} _≡_ _≡_\n≡-isPreorder ℓ = record\n { isEquivalence = isEquivalence\n ; reflexive = λ x → x\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------------------------------------------------------------------------\n-- Bundles\n\n≡-preorder : ∀ ℓ → Preorder ℓ ℓ ℓ\n≡-preorder ℓ = record\n { isPreorder = ≡-isPreorder ℓ\n }\n\n≡-poset : ∀ ℓ → Poset ℓ ℓ ℓ\n≡-poset ℓ = record\n { isPartialOrder = ≡-isPartialOrder ℓ\n }\n\n≡-totalOrder : ∀ ℓ → TotalOrder ℓ ℓ ℓ\n≡-totalOrder ℓ = record\n { isTotalOrder = ≡-isTotalOrder ℓ\n }\n\n≡-decTotalOrder : ∀ ℓ → DecTotalOrder ℓ ℓ ℓ\n≡-decTotalOrder ℓ = record\n { isDecTotalOrder = ≡-isDecTotalOrder ℓ\n }\n", "meta": {"hexsha": "c0ddf92e095adca471404c2e68fa04543e85ac32", "size": 2446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Unit/Polymorphic/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/Unit/Polymorphic/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/Unit/Polymorphic/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": 24.7070707071, "max_line_length": 72, "alphanum_fraction": 0.484055601, "num_tokens": 779, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.851952809486198, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5900982780944402}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties satisfied by bounded lattice\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary.Lattice\n\nmodule Relation.Binary.Properties.BoundedLattice\n {c ℓ₁ ℓ₂} (L : BoundedLattice c ℓ₁ ℓ₂) where\n\nopen BoundedLattice L\n\nopen import Algebra.FunctionProperties _≈_\nopen import Data.Product using (_,_)\nopen import Relation.Binary using (Setoid)\nopen import Relation.Binary.Properties.MeetSemilattice meetSemilattice\nopen import Relation.Binary.Properties.JoinSemilattice joinSemilattice\n\nopen Setoid setoid renaming (trans to ≈-trans)\n\n∧-zeroʳ : RightZero ⊥ _∧_\n∧-zeroʳ x = y≤x⇒x∧y≈y (minimum x)\n\n∧-zeroˡ : LeftZero ⊥ _∧_\n∧-zeroˡ x = ≈-trans (∧-comm ⊥ x) (∧-zeroʳ x)\n\n∧-zero : Zero ⊥ _∧_\n∧-zero = ∧-zeroˡ , ∧-zeroʳ\n\n∨-zeroʳ : RightZero ⊤ _∨_\n∨-zeroʳ x = x≤y⇒x∨y≈y (maximum x)\n\n∨-zeroˡ : LeftZero ⊤ _∨_\n∨-zeroˡ x = ≈-trans (∨-comm ⊤ x) (∨-zeroʳ x)\n\n∨-zero : Zero ⊤ _∨_\n∨-zero = ∨-zeroˡ , ∨-zeroʳ\n", "meta": {"hexsha": "8400aee1d572f8e632c216825f70fb937ef961d8", "size": 1088, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/BoundedLattice.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/BoundedLattice.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/BoundedLattice.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.5365853659, "max_line_length": 72, "alphanum_fraction": 0.6029411765, "num_tokens": 374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.6926419704455588, "lm_q1q2_score": 0.5900982622747408}} {"text": "\nmodule _ where\n\nopen import Common.Prelude renaming (_∸_ to _-_) -- work-around for #1855\n\n_<_ : Nat → Nat → Bool\na < b with b - a\n... | zero = false\n... | suc _ = true\n\ninsert : Nat → List Nat → List Nat\ninsert x [] = x ∷ []\ninsert x (y ∷ xs) = if x < y then x ∷ y ∷ xs else (y ∷ insert x xs)\n\nsort : List Nat → List Nat\nsort [] = []\nsort (x ∷ xs) = insert x (sort xs)\n\ndownFrom : Nat → List Nat\ndownFrom zero = []\ndownFrom (suc n) = n ∷ downFrom n\n\nmapM! : {A : Set} → (A → IO Unit) → List A → IO Unit\nmapM! f [] = return unit\nmapM! f (x ∷ xs) = f x >>= λ _ → mapM! f xs\n\nmain : IO Unit\nmain = mapM! printNat (sort (downFrom 1200))\n\n-- 1000 0.6s\n-- 2000 4.8s\n-- 4000 36.2s\n", "meta": {"hexsha": "3e78f03a129675265809bb5c038f3718017af2ae", "size": 683, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Compiler/simple/Sort.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/Compiler/simple/Sort.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/Compiler/simple/Sort.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.696969697, "max_line_length": 73, "alphanum_fraction": 0.5680819912, "num_tokens": 269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.590097386660092}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n{-\n Useful notation for Epimorphisms, Mononmorphisms, and isomorphisms\n-}\nmodule Categories.Morphism.Notation where\n\nopen import Level\n\nopen import Categories.Category.Core\nopen import Categories.Morphism\n\nprivate\n variable\n o ℓ e : Level\n\n_[_↣_] : (𝒞 : Category o ℓ e) → (A B : Category.Obj 𝒞) → Set (o ⊔ ℓ ⊔ e)\n𝒞 [ A ↣ B ] = _↣_ 𝒞 A B\n\n_[_↠_] : (𝒞 : Category o ℓ e) → (A B : Category.Obj 𝒞) → Set (o ⊔ ℓ ⊔ e)\n𝒞 [ A ↠ B ] = _↠_ 𝒞 A B\n\n_[_≅_] : (𝒞 : Category o ℓ e) → (A B : Category.Obj 𝒞) → Set (ℓ ⊔ e)\n𝒞 [ A ≅ B ] = _≅_ 𝒞 A B\n", "meta": {"hexsha": "42449f4d218c7bfe1a91ad99fe546751909ad0f5", "size": 570, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Morphism/Notation.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/Notation.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/Notation.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": 22.8, "max_line_length": 72, "alphanum_fraction": 0.5964912281, "num_tokens": 246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267762381844, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.5900886509781346}} {"text": "\nmodule Prelude.Applicative.Indexed {i} {I : Set i} where\n\nopen import Agda.Primitive\nopen import Prelude.Unit\nopen import Prelude.Functor\nopen import Prelude.Function\nopen import Prelude.Equality\nopen import Prelude.Number\nopen import Prelude.Semiring\nopen import Prelude.Fractional\n\nrecord IApplicative {a b} (F : I → I → Set a → Set b) : Set (i ⊔ lsuc a ⊔ b) where\n infixl 4 _<*>_ _<*_ _*>_\n field\n pure : ∀ {A i} → A → F i i A\n _<*>_ : ∀ {A B i j k} → F i j (A → B) → F j k A → F i k B\n overlap {{super}} : ∀ {i j} → Functor (F i j)\n\n _<*_ : ∀ {A B i j k} → F i j A → F j k B → F i k A\n a <* b = ⦇ const a b ⦈\n\n _*>_ : ∀ {A B i j k} → F i j A → F j k B → F i k B\n a *> b = ⦇ (const id) a b ⦈\n\nopen IApplicative {{...}} public\n\n{-# DISPLAY IApplicative.pure _ = pure #-}\n{-# DISPLAY IApplicative._<*>_ _ = _<*>_ #-}\n{-# DISPLAY IApplicative._<*_ _ = _<*_ #-}\n{-# DISPLAY IApplicative._*>_ _ = _*>_ #-}\n\n-- Level polymorphic functors\nrecord IApplicative′ {a b} (F : ∀ {a} → I → I → Set a → Set a) : Set (i ⊔ lsuc (a ⊔ b)) where\n infixl 4 _<*>′_\n field\n _<*>′_ : {A : Set a} {B : Set b} {i j k : I} → F i j (A → B) → F j k A → F i k B\n overlap {{super}} : ∀ {i j} → Functor′ {a} {b} (F i j)\n\nopen IApplicative′ {{...}} public\n\nmodule _ {F : ∀ {a} → I → I → Set a → Set a}\n {{_ : ∀ {a} → IApplicative {a = a} F}}\n {{_ : ∀ {a b} → IApplicative′ {a = a} {b = b} F}}\n {a b} {A : Set a} {B : Set b} {i j k} where\n\n infixl 4 _<*′_ _*>′_\n _<*′_ : F i j A → F j k B → F i k A\n a <*′ b = pure const <*>′ a <*>′ b\n\n _*>′_ : F i j A → F j k B → F i k B\n a *>′ b = pure (const id) <*>′ a <*>′ b\n", "meta": {"hexsha": "e18439020520e0fe2cd7c139b4439d8498819b1a", "size": 1643, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Applicative/Indexed.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/Applicative/Indexed.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/Applicative/Indexed.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.0, "max_line_length": 93, "alphanum_fraction": 0.5106512477, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267864276108, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.5900886466146417}} {"text": "open import Prelude\nopen import Nat\nopen import dynamics-core\nopen import contexts\n\nmodule lemmas-disjointness where\n -- disjointness is commutative\n ##-comm : {A : Set} {Δ1 Δ2 : A ctx} → Δ1 ## Δ2 → Δ2 ## Δ1\n ##-comm (π1 , π2) = π2 , π1\n\n -- the empty context is disjoint from any context\n empty-disj : {A : Set} (Γ : A ctx) → ∅ ## Γ\n empty-disj Γ = ed1 , ed2\n where\n ed1 : {A : Set} (n : Nat) → dom {A} ∅ n → n # Γ\n ed1 n (π1 , ())\n\n ed2 : {A : Set} (n : Nat) → dom Γ n → _#_ {A} n ∅\n ed2 _ _ = refl\n\n -- two singleton contexts with different indices are disjoint\n disjoint-singles : {A : Set} {x y : A} {u1 u2 : Nat} →\n u1 ≠ u2 →\n (■ (u1 , x)) ## (■ (u2 , y))\n disjoint-singles {_} {x} {y} {u1} {u2} neq = ds1 , ds2\n where\n ds1 : (n : Nat) → dom (■ (u1 , x)) n → n # (■ (u2 , y))\n ds1 n d with lem-dom-eq d\n ds1 .u1 d | refl with natEQ u2 u1\n ds1 .u1 d | refl | Inl xx = abort (neq (! xx))\n ds1 .u1 d | refl | Inr x₁ = refl\n\n ds2 : (n : Nat) → dom (■ (u2 , y)) n → n # (■ (u1 , x))\n ds2 n d with lem-dom-eq d\n ds2 .u2 d | refl with natEQ u1 u2\n ds2 .u2 d | refl | Inl x₁ = abort (neq x₁)\n ds2 .u2 d | refl | Inr x₁ = refl\n\n apart-noteq : {A : Set} (p r : Nat) (q : A) → p # (■ (r , q)) → p ≠ r\n apart-noteq p r q apt with natEQ r p\n apart-noteq p .p q apt | Inl refl = abort (somenotnone apt)\n apart-noteq p r q apt | Inr x₁ = flip x₁\n\n -- if singleton contexts are disjoint, their indices must be disequal\n singles-notequal : {A : Set} {x y : A} {u1 u2 : Nat} →\n (■ (u1 , x)) ## (■ (u2 , y)) →\n u1 ≠ u2\n singles-notequal {A} {x} {y} {u1} {u2} (d1 , d2) = apart-noteq u1 u2 y (d1 u1 (lem-domsingle u1 x))\n\n -- dual of lem2 above; if two indices are disequal, then either is apart\n -- from the singleton formed with the other\n apart-singleton : {A : Set} → ∀{x y} → {τ : A} →\n x ≠ y →\n x # (■ (y , τ))\n apart-singleton {A} {x} {y} {τ} neq with natEQ y x\n apart-singleton neq | Inl x₁ = abort ((flip neq) x₁)\n apart-singleton neq | Inr x₁ = refl\n\n -- if an index is apart from two contexts, it's apart from their union as\n -- well. used below and in other files, so it's outside the local scope.\n apart-parts : {A : Set} (Γ1 Γ2 : A ctx) (n : Nat) → n # Γ1 → n # Γ2 → n # (Γ1 ∪ Γ2)\n apart-parts Γ1 Γ2 n apt1 apt2 with Γ1 n\n apart-parts _ _ n refl apt2 | .None = apt2\n\n -- this is just for convenience; it shows up a lot.\n apart-extend1 : {A : Set} → ∀{x y τ} → (Γ : A ctx) → x ≠ y → x # Γ → x # (Γ ,, (y , τ))\n apart-extend1 {A} {x} {y} {τ} Γ neq apt with natEQ y x\n ... | Inl refl = abort (neq refl)\n ... | Inr y≠x = apt\n\n -- if an index is in the domain of a union, it's in the domain of one or\n -- the other unand\n dom-split : {A : Set} → (Γ1 Γ2 : A ctx) (n : Nat) → dom (Γ1 ∪ Γ2) n → dom Γ1 n + dom Γ2 n\n dom-split Γ4 Γ5 n (π1 , π2) with Γ4 n\n dom-split Γ4 Γ5 n (π1 , π2) | Some x = Inl (x , refl)\n dom-split Γ4 Γ5 n (π1 , π2) | None = Inr (π1 , π2)\n\n -- if both parts of a union are disjoint with a target, so is the union\n disjoint-parts : {A : Set} {Γ1 Γ2 Γ3 : A ctx} → Γ1 ## Γ3 → Γ2 ## Γ3 → (Γ1 ∪ Γ2) ## Γ3\n disjoint-parts {_} {Γ1} {Γ2} {Γ3} D13 D23 = d31 , d32\n where\n d31 : (n : Nat) → dom (Γ1 ∪ Γ2) n → n # Γ3\n d31 n D with dom-split Γ1 Γ2 n D\n d31 n D | Inl x = π1 D13 n x\n d31 n D | Inr x = π1 D23 n x\n\n d32 : (n : Nat) → dom Γ3 n → n # (Γ1 ∪ Γ2)\n d32 n D = apart-parts Γ1 Γ2 n (π2 D13 n D) (π2 D23 n D)\n\n apart-union1 : {A : Set} (Γ1 Γ2 : A ctx) (n : Nat) → n # (Γ1 ∪ Γ2) → n # Γ1\n apart-union1 Γ1 Γ2 n aprt with Γ1 n\n apart-union1 Γ1 Γ2 n () | Some x\n apart-union1 Γ1 Γ2 n aprt | None = refl\n\n apart-union2 : {A : Set} (Γ1 Γ2 : A ctx) (n : Nat) → n # (Γ1 ∪ Γ2) → n # Γ2\n apart-union2 Γ1 Γ2 n aprt with Γ1 n\n apart-union2 Γ3 Γ4 n () | Some x\n apart-union2 Γ3 Γ4 n aprt | None = aprt\n\n -- if a union is disjoint with a target, so is the left unand\n disjoint-union1 : {A : Set} {Γ1 Γ2 Δ : A ctx} → (Γ1 ∪ Γ2) ## Δ → Γ1 ## Δ\n disjoint-union1 {Γ1 = Γ1} {Γ2 = Γ2} {Δ = Δ} (ud1 , ud2) = du11 , du12\n where\n dom-union1 : {A : Set} (Γ1 Γ2 : A ctx) (n : Nat) → dom Γ1 n → dom (Γ1 ∪ Γ2) n\n dom-union1 Γ1 Γ2 n (π1 , π2) with Γ1 n\n dom-union1 Γ1 Γ2 n (π1 , π2) | Some x = x , refl\n dom-union1 Γ1 Γ2 n (π1 , ()) | None\n\n du11 : (n : Nat) → dom Γ1 n → n # Δ\n du11 n dom = ud1 n (dom-union1 Γ1 Γ2 n dom)\n\n du12 : (n : Nat) → dom Δ n → n # Γ1\n du12 n dom = apart-union1 Γ1 Γ2 n (ud2 n dom)\n\n -- if a union is disjoint with a target, so is the right unand\n disjoint-union2 : {A : Set} {Γ1 Γ2 Δ : A ctx} → (Γ1 ∪ Γ2) ## Δ → Γ2 ## Δ\n disjoint-union2 {Γ1 = Γ1} {Γ2 = Γ2} {Δ = Δ} (ud1 , ud2) = du21 , du22\n where\n dom-union2 : {A : Set} (Γ1 Γ2 : A ctx) (n : Nat) → dom Γ2 n → dom (Γ1 ∪ Γ2) n\n dom-union2 Γ1 Γ2 n (π1 , π2) with Γ1 n\n dom-union2 Γ3 Γ4 n (π1 , π2) | Some x = x , refl\n dom-union2 Γ3 Γ4 n (π1 , π2) | None = π1 , π2\n\n du21 : (n : Nat) → dom Γ2 n → n # Δ\n du21 n dom = ud1 n (dom-union2 Γ1 Γ2 n dom)\n\n du22 : (n : Nat) → dom Δ n → n # Γ2\n du22 n dom = apart-union2 Γ1 Γ2 n (ud2 n dom)\n\n -- if x isn't in a context and y is then they can't be equal\n lem-dom-apt : {A : Set} {G : A ctx} {x y : Nat} → x # G → dom G y → x ≠ y\n lem-dom-apt {x = x} {y = y} apt dom with natEQ x y\n lem-dom-apt apt dom | Inl refl = abort (somenotnone (! (π2 dom) · apt))\n lem-dom-apt apt dom | Inr x₁ = x₁\n", "meta": {"hexsha": "f7408472e80f85bfa8ac49b2592c69ba285666cf", "size": 5584, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lemmas-disjointness.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-disjointness.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-disjointness.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": 41.362962963, "max_line_length": 101, "alphanum_fraction": 0.5275787966, "num_tokens": 2349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.817574471748733, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.5900788157336495}} {"text": "\nmodule Prelude.Vec where\n\nopen import Prelude.Nat\nopen import Prelude.Fin\nopen import Prelude.Function\nopen import Prelude.Functor\nopen import Prelude.Applicative\nopen import Prelude.List\nopen import Prelude.Equality\nopen import Prelude.Decidable\nopen import Prelude.Ord\nopen import Prelude.Semiring\n\ninfixr 5 _∷_\ndata Vec {a} (A : Set a) : Nat → Set a where\n [] : Vec A zero\n _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)\n\nprivate\n -- These are private. Use pure and _<*>_ instead.\n vec : ∀ {a} {A : Set a} {n} → A → Vec A n\n vec {n = zero } x = []\n vec {n = suc n} x = x ∷ vec x\n\n vapp : ∀ {a b} {A : Set a} {B : Set b} {n} → Vec (A → B) n → Vec A n → Vec B n\n vapp [] _ = []\n vapp (f ∷ fs) (x ∷ xs) = f x ∷ vapp fs xs\n\n vmap : ∀ {a b} {A : Set a} {B : Set b} {n} → (A → B) → Vec A n → Vec B n\n vmap f [] = []\n vmap f (x ∷ xs) = f x ∷ vmap f xs\n\nvecToList : ∀ {a} {A : Set a} {@erased n} → Vec A n → List A\nvecToList [] = []\nvecToList (x ∷ xs) = x ∷ vecToList xs\n\nlistToVec : ∀ {a} {A : Set a} (xs : List A) → Vec A (length xs)\nlistToVec [] = []\nlistToVec (x ∷ xs) = x ∷ listToVec xs\n\n--- Lookup ---\n\nindexVec : ∀ {a} {A : Set a} {n} → Vec A n → Fin n → A\nindexVec (x ∷ xs) zero = x\nindexVec (x ∷ xs) (suc i) = indexVec xs i\n\ntabulate : ∀ {a} {A : Set a} {n} → (Fin n → A) → Vec A n\ntabulate {n = zero } f = []\ntabulate {n = suc n} f = f zero ∷ tabulate (f ∘ suc)\n\n--- Folding ---\n\nvfoldr : ∀ {a b} {A : Set a} {B : Nat → Set b} → (∀ {@erased n} → A → B n → B (suc n)) → B 0 → ∀ {@erased n} → Vec A n → B n\nvfoldr f z [] = z\nvfoldr f z (x ∷ xs) = f x (vfoldr (λ {n} → f {n}) z xs)\n\nvfoldl : ∀ {a b} {A : Set a} {B : Nat → Set b} → (∀ {n} → B n → A → B (suc n)) → B 0 → ∀ {@erased n} → Vec A n → B n\nvfoldl f z [] = z\nvfoldl {B = B} f z (x ∷ xs) = vfoldl {B = B ∘ suc} f (f z x) xs\n\n--- Other list functions ---\n\nmodule _ {a} {A : Set a} where\n\n infixr 5 _v++_\n _v++_ : ∀ {m n} → Vec A m → Vec A n → Vec A (m + n)\n [] v++ ys = ys\n (x ∷ xs) v++ ys = x ∷ xs v++ ys\n\n vreverse : ∀ {@erased n} → Vec A n → Vec A n\n vreverse xs = vfoldl {B = Vec A} (flip _∷_) [] xs\n\n--- Equality ---\n\nvcons-inj-head : ∀ {a} {A : Set a} {x y : A} {n}\n {xs ys : Vec A n} → x Vec.∷ xs ≡ y ∷ ys → x ≡ y\nvcons-inj-head refl = refl\n\nvcons-inj-tail : ∀ {a} {A : Set a} {x y : A} {n}\n {xs ys : Vec A n} → x Vec.∷ xs ≡ y ∷ ys → xs ≡ ys\nvcons-inj-tail refl = refl\n\ninstance\n EqVec : ∀ {a} {A : Set a} {{EqA : Eq A}} {n} → Eq (Vec A n)\n _==_ {{EqVec}} [] [] = yes refl\n _==_ {{EqVec}} (x ∷ xs) (y ∷ ys) with x == y\n ... | no neq = no λ eq → neq (vcons-inj-head eq)\n ... | yes eq with xs == ys\n ... | no neq = no λ eq₁ → neq (vcons-inj-tail eq₁)\n ... | yes eq₁ = yes (_∷_ $≡ eq *≡ eq₁)\n\n--- Ord ---\n\ndata LessVec {a} {A : Set a} {{OrdA : Ord A}} : ∀ {n} → Vec A n → Vec A n → Set a where\n head< : ∀ {@erased x y n} {@erased xs ys : Vec A n} → x < y → LessVec (x ∷ xs) (y ∷ ys)\n tail< : ∀ {@erased x n} {@erased xs ys : Vec A n} → LessVec xs ys → LessVec (x ∷ xs) (x ∷ ys)\n\nprivate\n compareVec : ∀ {a} {A : Set a} {{OrdA : Ord A}} {@erased n} (xs ys : Vec A n) → Comparison LessVec xs ys\n compareVec [] [] = equal refl\n compareVec (x ∷ xs) (y ∷ ys) with compare x y\n compareVec (x ∷ xs) (y ∷ ys) | less x_ {{ApplicativeVec}} = vapp\n\n ApplicativeVec′ : ∀ {a b n} → Applicative′ {a} {b} (flip Vec n)\n _<*>′_ {{ApplicativeVec′}} = vapp\n", "meta": {"hexsha": "4f991f7511df22e7f859676098633f350e06e8b4", "size": 5202, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Vec.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/Vec.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/Vec.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": 36.125, "max_line_length": 134, "alphanum_fraction": 0.5173010381, "num_tokens": 2193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.7279754607093178, "lm_q1q2_score": 0.5900087569344631}} {"text": "\nmodule Bool where\n\ndata Bool : Set where\n false : Bool\n true : Bool\n\ndata IsTrue : Bool -> Set where\n isTrue : IsTrue true\n\nopen import Vec\nopen import All\n\nallEnvs : {n : Nat} -> List (Vec Bool n)\nallEnvs {zero } = ε :: []\nallEnvs {suc n} = map (_►_ false) allEnvs ++ map (_►_ true) allEnvs\n\n∈++left : {A : Set}{x : A}{xs ys : List A} -> x ∈ xs -> x ∈ (xs ++ ys)\n∈++left (hd p) = hd p\n∈++left (tl q) = tl (∈++left q)\n\n∈++right : {A : Set}{x : A}{xs ys : List A} -> x ∈ ys -> x ∈ (xs ++ ys)\n∈++right {xs = []} p = p\n∈++right {xs = x :: xs} p = tl (∈++right {xs = xs} p)\n\n∈map : {A B : Set}{f : A -> B}{x : A}{xs : List A} -> x ∈ xs -> f x ∈ map f xs\n∈map (hd refl) = hd refl\n∈map (tl q) = tl (∈map q)\n\ncovered : {n : Nat} -> (xs : Vec Bool n) -> xs ∈ allEnvs\ncovered ε = hd refl\ncovered (false ► xs) = ∈++left (∈map (covered xs))\ncovered (true ► xs) = ∈++right {xs = map (_►_ false) allEnvs}\n (∈map (covered xs))\n\nSat : {A : Set} -> (A -> Bool) -> A -> Set\nSat f x = IsTrue (f x)\n\nlem₁ : {n : Nat}(f : Vec Bool n -> Bool) ->\n All (Sat f) allEnvs -> (xs : Vec Bool n) -> Sat f xs\nlem₁ f p xs with p ! covered xs\n... | (.xs , p , refl) = p\n\ndata False : Set where\n\n¬_ : Set -> Set\n¬ P = P -> False\n\ndata _∨_ (A B : Set) : Set where\n inl : A -> A ∨ B\n inr : B -> A ∨ B\n\n¬IsTrue-false : ¬ IsTrue false\n¬IsTrue-false ()\n\ndecide : {A : Set}(p : A -> Bool)(x : A) ->\n Sat p x ∨ ¬ Sat p x\ndecide p x with p x\n... | true = inl isTrue\n... | false = inr ¬IsTrue-false\n\nall : {A : Set}(p : A -> Bool)(xs : List A) ->\n All (Sat p) xs ∨ Some (\\x -> ¬ Sat p x) xs\nall p [] = inl ∅\nall p (x :: xs) with decide p x\n... | inr ¬px = inr (hd ¬px)\n... | inl px with all p xs\n... | inl ps = inl (px ▹ ps)\n... | inr q = inr (tl q)\n\ndata NoProof : Set where\n no-proof : NoProof\n\nProof : {n : Nat} -> (Vec Bool n -> Bool) -> Set\nProof {n} f with all f allEnvs\n... | inl _ = (xs : Vec Bool n) -> Sat f xs\n... | inr _ = NoProof\n\nprove : {n : Nat}(f : Vec Bool n -> Bool) -> Proof f\nprove f with all f allEnvs\n... | inl ps = lem₁ f ps\n... | inr _ = no-proof\n", "meta": {"hexsha": "2f41756f64def9e877e832f70b543ecc8bfb5b8a", "size": 2115, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/tactics/bool/Bool.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/tactics/bool/Bool.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/tactics/bool/Bool.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.4819277108, "max_line_length": 78, "alphanum_fraction": 0.5011820331, "num_tokens": 832, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767810736693, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.5899554609707085}} {"text": "{-# OPTIONS --guardedness --cubical #-}\n\nmodule Issue2799 where\n\nopen import Agda.Primitive.Cubical\nopen import Agda.Builtin.Cubical.Path\n\nrecord Stream (A : Set) : Set where\n coinductive\n constructor _,_\n field\n head : A\n tail : Stream A\n\nopen Stream\n\nmapS : ∀ {A B} → (A → B) → Stream A → Stream B\nhead (mapS f xs) = f (head xs)\ntail (mapS f xs) = mapS f (tail xs)\n\n\nmapS-id : ∀ {A} {xs : Stream A} → mapS (λ x → x) xs ≡ xs\nhead (mapS-id {xs = xs} i) = head xs\ntail (mapS-id {xs = xs} i) = mapS-id {xs = tail xs} i\n", "meta": {"hexsha": "37c9a75155bdeeb38ee86bba6f78f63f336059ff", "size": 526, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2799.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/Issue2799.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/Issue2799.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.04, "max_line_length": 56, "alphanum_fraction": 0.6197718631, "num_tokens": 191, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511506439708, "lm_q2_score": 0.6893056295505784, "lm_q1q2_score": 0.5899430161962291}} {"text": "-- Andreas, 2019-06-26, issue #3872, make --no-forcing a pragma option\n\n{-# OPTIONS --no-forcing #-}\n\nopen import Agda.Builtin.Nat\n\ndata List {a} (A : Set a) : Set a where\n [] : List A\n _∷_ : A → List A → List A\n\npattern [_] x = x ∷ []\n\nmodule _ {a} {A : Set a} where\n\n _++_ : List A → List A → List A\n [] ++ ys = ys\n (x ∷ xs) ++ ys = x ∷ (xs ++ ys)\n\n variable\n x y z : A\n @0 xs ys zs : List A\n\n data FSet : List A → Set a where\n ∅ : FSet []\n _∪_ : FSet xs → FSet ys → FSet (xs ++ ys)\n sg : (x : A) → FSet [ x ]\n -- x is forced here, but this is not wanted.\n -- We need a way to tell the forcing machinery to not erase x.\n\n -- Since xs is erased, we cannot get x from sg x : FSet xs (with xs = [ x ])\n -- unless x is retained in sg x.\n elements : {@0 xs : List A} → FSet xs → List A\n elements ∅ = []\n elements (s ∪ t) = elements s ++ elements t\n elements (sg x) = [ x ]\n\n-- ERROR WAS:\n-- Variable x is declared erased, so it cannot be used here\n-- when checking that the expression x has type A\n\nmySet = (sg 1 ∪ sg 2) ∪ (sg 3 ∪ sg 4)\n", "meta": {"hexsha": "167a2423efd3e30ee8cc92d1ccaab32db625666d", "size": 1084, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue3872.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/Issue3872.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/Issue3872.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.8095238095, "max_line_length": 78, "alphanum_fraction": 0.5535055351, "num_tokens": 384, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.855851154320682, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.5899430078055538}} {"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.Union.Definition {a b : _} {A : Set a} (S : Setoid {a} {b} A) where\n\nopen Setoid S\nopen Equivalence eq\nopen import Setoids.Subset S\n\nunionPredicate : {c d : _} {pred1 : A → Set c} {pred2 : A → Set d} (s1 : subset pred1) (s2 : subset pred2) → A → Set (c ⊔ d)\nunionPredicate {pred1 = pred1} {pred2} s1 s2 a = pred1 a || pred2 a\n\nunion : {c d : _} {pred1 : A → Set c} {pred2 : A → Set d} (s1 : subset pred1) (s2 : subset pred2) → subset (unionPredicate s1 s2)\nunion s1 s2 {x1} {x2} x1=x2 (inl x) = inl (s1 x1=x2 x)\nunion s1 s2 {x1} {x2} x1=x2 (inr x) = inr (s2 x1=x2 x)\n", "meta": {"hexsha": "bdfb31d179eeb276d00fe4a8a04919a479ba32bc", "size": 788, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Union/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/Union/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/Union/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": 39.4, "max_line_length": 129, "alphanum_fraction": 0.654822335, "num_tokens": 306, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511469672595, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.5899429972742717}} {"text": "open import Mockingbird.Forest using (Forest)\n\n-- Is There a Sage Bird?\nmodule Mockingbird.Problems.Chapter10 {b ℓ} (forest : Forest {b} {ℓ}) where\n\nopen import Data.Product using (_,_; proj₁; proj₂; ∃-syntax)\nopen import Function using (_$_)\n\nopen import Mockingbird.Forest.Birds forest\n\nopen Forest forest\n\nmodule _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasLark ⦄ where\n private\n hasMockingbirdComposer : ∃[ A ] (∀ x y → A ∙ x ∙ y ≈ x ∙ (M ∙ y))\n hasMockingbirdComposer = (L , isMockingbirdComposer)\n where\n isMockingbirdComposer = λ x y → begin\n L ∙ x ∙ y ≈⟨ isLark x y ⟩\n x ∙ (y ∙ y) ≈˘⟨ congˡ $ isMockingbird y ⟩\n x ∙ (M ∙ y) ∎\n\n hasSageBird : HasSageBird\n hasSageBird = record\n { Θ = M ∘ L\n ; isSageBird = λ x → begin\n x ∙ ((M ∘ L) ∙ x) ≈⟨ congˡ $ isComposition M L x ⟩\n x ∙ (M ∙ (L ∙ x)) ≈⟨ congˡ $ isMockingbird (L ∙ x) ⟩\n x ∙ ((L ∙ x) ∙ (L ∙ x)) ≈˘⟨ isLark x (L ∙ x) ⟩\n (L ∙ x) ∙ (L ∙ x) ≈˘⟨ isMockingbird (L ∙ x) ⟩\n M ∙ (L ∙ x) ≈˘⟨ isComposition M L x ⟩\n (M ∘ L) ∙ x ∎\n }\n\nmodule _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄\n (hasMockingbirdComposer : ∃[ A ] (∀ x y → A ∙ x ∙ y ≈ x ∙ (M ∙ y))) where\n\n private\n A = proj₁ hasMockingbirdComposer\n [Ax]y≈x[My] = proj₂ hasMockingbirdComposer\n\n instance\n hasLark : HasLark\n hasLark = record\n { L = A\n ; isLark = λ x y → begin\n (A ∙ x) ∙ y ≈⟨ [Ax]y≈x[My] x y ⟩\n x ∙ (M ∙ y) ≈⟨ congˡ $ isMockingbird y ⟩\n x ∙ (y ∙ y) ∎\n }\n\n hasSageBird′ : HasSageBird\n hasSageBird′ = hasSageBird\n", "meta": {"hexsha": "03734d2c50fc6c13af1c1247930406c7e5df8440", "size": 1688, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Mockingbird/Problems/Chapter10.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/Problems/Chapter10.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/Problems/Chapter10.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": 31.2592592593, "max_line_length": 82, "alphanum_fraction": 0.5148104265, "num_tokens": 711, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511359371249, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5899429951336644}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Dodo.Nullary.Unique where\n\n-- Stdlib imports\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_)\nopen import Level using (Level)\n\n\n-- # Definitions\n\nUnique : ∀ {a : Level} (A : Set a) → Set _\nUnique A = ∀ (x y : A) → x ≡ y\n", "meta": {"hexsha": "28421984db128b172b9fad95eee3a73a45cee5d7", "size": 285, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Dodo/Nullary/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/Nullary/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/Nullary/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": 19.0, "max_line_length": 50, "alphanum_fraction": 0.6561403509, "num_tokens": 82, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511322604133, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5899429925992865}} {"text": "{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-}\n\n-- Construction of M-types from\n-- https://arxiv.org/pdf/1504.02949.pdf\n-- \"Non-wellfounded trees in Homotopy Type Theory\"\n-- Benedikt Ahrens, Paolo Capriotti, Régis Spadotti\n\nmodule Cubical.Codata.M.AsLimit.M.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv using (_≃_)\nopen import Cubical.Foundations.Function using (_∘_)\n\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Prod\nopen import Cubical.Data.Nat as ℕ using (ℕ ; suc ; _+_ )\nopen import Cubical.Data.Sigma hiding (_×_)\nopen import Cubical.Data.Nat.Algebra\n\nopen import Cubical.Foundations.Transport\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Path\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.GroupoidLaws\n\nopen import Cubical.Data.Sum\n\nopen import Cubical.Codata.M.AsLimit.helper\nopen import Cubical.Codata.M.AsLimit.Container\n\nopen import Cubical.Codata.M.AsLimit.Coalg.Base\n\nopen Iso\n\nprivate\n limit-collapse : ∀ {ℓ} {S : Container ℓ} (X : ℕ → Type ℓ) (l : (n : ℕ) → X n → X (suc n)) → (x₀ : X 0) → ∀ (n : ℕ) → X n\n limit-collapse X l x₀ 0 = x₀\n limit-collapse {S = S} X l x₀ (suc n) = l n (limit-collapse {S = S} X l x₀ n)\n\nlemma11-Iso :\n ∀ {ℓ} {S : Container ℓ} (X : ℕ → Type ℓ) (l : (n : ℕ) → X n → X (suc n))\n → Iso (Σ[ x ∈ ((n : ℕ) → X n)] ((n : ℕ) → x (suc n) ≡ l n (x n)))\n (X 0)\nfun (lemma11-Iso X l) (x , y) = x 0\ninv (lemma11-Iso {S = S} X l) x₀ = limit-collapse {S = S} X l x₀ , (λ n → refl {x = limit-collapse {S = S} X l x₀ (suc n)})\nrightInv (lemma11-Iso X l) _ = refl\nleftInv (lemma11-Iso {ℓ = ℓ} {S = S} X l) (x , y) i =\n let temp = χ-prop (x 0) (fst (inv (lemma11-Iso {S = S} X l) (fun (lemma11-Iso {S = S} X l) (x , y))) , refl , (λ n → refl {x = limit-collapse {S = S} X l (x 0) (suc n)})) (x , refl , y)\n in temp i .fst , proj₂ (temp i .snd)\n where\n open AlgebraPropositionality\n open NatSection\n\n X-fiber-over-ℕ : (x₀ : X 0) -> NatFiber NatAlgebraℕ ℓ\n X-fiber-over-ℕ x₀ = record { Fiber = X ; fib-zero = x₀ ; fib-suc = λ {n : ℕ} xₙ → l n xₙ }\n\n X-section : (x₀ : X 0) → (z : Σ[ x ∈ ((n : ℕ) → X n)] (x 0 ≡ x₀) × (∀ n → (x (suc n)) ≡ l n (x n))) -> NatSection (X-fiber-over-ℕ x₀)\n X-section = λ x₀ z → record { section = fst z ; sec-comm-zero = proj₁ (snd z) ; sec-comm-suc = proj₂ (snd z) }\n\n Z-is-Section : (x₀ : X 0) →\n Iso (Σ[ x ∈ ((n : ℕ) → X n)] (x 0 ≡ x₀) × (∀ n → (x (suc n)) ≡ l n (x n)))\n (NatSection (X-fiber-over-ℕ x₀))\n fun (Z-is-Section x₀) (x , (z , y)) = record { section = x ; sec-comm-zero = z ; sec-comm-suc = y }\n inv (Z-is-Section x₀) x = NatSection.section x , (sec-comm-zero x , sec-comm-suc x)\n rightInv (Z-is-Section x₀) _ = refl\n leftInv (Z-is-Section x₀) (x , (z , y)) = refl\n\n -- S≡T\n χ-prop' : (x₀ : X 0) → isProp (NatSection (X-fiber-over-ℕ x₀))\n χ-prop' x₀ a b = SectionProp.S≡T isNatInductiveℕ (X-section x₀ (inv (Z-is-Section x₀) a)) (X-section x₀ (inv (Z-is-Section x₀) b))\n\n χ-prop : (x₀ : X 0) → isProp (Σ[ x ∈ ((n : ℕ) → X n) ] (x 0 ≡ x₀) × (∀ n → (x (suc n)) ≡ l n (x n)))\n χ-prop x₀ = subst isProp (sym (isoToPath (Z-is-Section x₀))) (χ-prop' x₀)\n\n-----------------------------------------------------\n-- Shifting the limit of a chain is an equivalence --\n-----------------------------------------------------\n\n-- Shift is equivalence (12) and (13) in the proof of Theorem 7\n-- https://arxiv.org/pdf/1504.02949.pdf\n-- \"Non-wellfounded trees in Homotopy Type Theory\"\n-- Benedikt Ahrens, Paolo Capriotti, Régis Spadotti\n\n-- TODO: This definition is inefficient, it should be updated to use some cubical features!\nshift-iso : ∀ {ℓ} (S : Container ℓ) -> Iso (P₀ S (M S)) (M S)\nshift-iso S@(A , B) =\n P₀ S (M S)\n Iso⟨ Σ-cong-iso-snd\n (λ x → iso (λ f → (λ n z → f z .fst n) , λ n i a → f a .snd n i)\n (λ (u , q) z → (λ n → u n z) , λ n i → q n i z)\n (λ _ → refl)\n (λ _ → refl)) ⟩\n (Σ[ a ∈ A ] (Σ[ u ∈ ((n : ℕ) → B a → X (sequence S) n) ] ((n : ℕ) → π (sequence S) ∘ (u (suc n)) ≡ u n)))\n Iso⟨ invIso α-iso-step-5-Iso ⟩\n (Σ[ a ∈ (Σ[ a ∈ ((n : ℕ) → A) ] ((n : ℕ) → a (suc n) ≡ a n)) ]\n Σ[ u ∈ ((n : ℕ) → B (a .fst n) → X (sequence S) n) ]\n ((n : ℕ) → PathP (λ x → B (a .snd n x) → X (sequence S) n)\n (π (sequence S) ∘ u (suc n))\n (u n)))\n Iso⟨ α-iso-step-1-4-Iso-lem-12 ⟩\n M S ∎Iso\n where\n α-iso-step-5-Iso-helper0 :\n ∀ (a : (ℕ -> A))\n → (p : (n : ℕ) → a (suc n) ≡ a n)\n → (n : ℕ)\n → a n ≡ a 0\n α-iso-step-5-Iso-helper0 a p 0 = refl\n α-iso-step-5-Iso-helper0 a p (suc n) = p n ∙ α-iso-step-5-Iso-helper0 a p n\n\n α-iso-step-5-Iso-helper1-Iso :\n ∀ (a : ℕ -> A)\n → (p : (n : ℕ) → a (suc n) ≡ a n)\n → (u : (n : ℕ) → B (a n) → Wₙ S n)\n → (n : ℕ)\n → (PathP (λ x → B (p n x) → Wₙ S n) (πₙ S ∘ u (suc n)) (u n)) ≡\n (πₙ S ∘ (subst (\\k -> B k → Wₙ S (suc n)) (α-iso-step-5-Iso-helper0 a p (suc n))) (u (suc n))\n ≡ subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p n) (u n))\n α-iso-step-5-Iso-helper1-Iso a p u n =\n PathP (λ x → B (p n x) → Wₙ S n) (πₙ S ∘ u (suc n)) (u n)\n ≡⟨ PathP≡Path (λ x → B (p n x) → Wₙ S n) (πₙ S ∘ u (suc n)) (u n) ⟩\n subst (λ k → B k → Wₙ S n) (p n) (πₙ S ∘ u (suc n)) ≡ (u n)\n ≡⟨ (λ i → transp (λ j → B (α-iso-step-5-Iso-helper0 a p n (i ∧ j)) → Wₙ S n) (~ i) (subst (λ k → B k → Wₙ S n) (p n) (πₙ S ∘ u (suc n)))\n ≡ transp (λ j → B (α-iso-step-5-Iso-helper0 a p n (i ∧ j)) → Wₙ S n) (~ i) (u n)) ⟩\n subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p n) (subst (λ k → B k → Wₙ S n) (p n) (πₙ S ∘ u (suc n))) ≡\n subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p n) (u n)\n ≡⟨ (λ i → sym (substComposite (λ k → B k → Wₙ S n) (p n) (α-iso-step-5-Iso-helper0 a p n) (πₙ S ∘ u (suc n))) i\n ≡ subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p n) (u n)) ⟩\n subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p (suc n)) (πₙ S ∘ u (suc n)) ≡\n subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p n) (u n)\n ≡⟨ (λ i → substCommSlice (λ k → B k → Wₙ S (suc n)) (λ k → B k → Wₙ S n)\n (λ a x x₁ → (πₙ S) (x x₁))\n (α-iso-step-5-Iso-helper0 a p (suc n)) (u (suc n)) i\n ≡ subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p n) (u n)) ⟩\n πₙ S ∘ subst (λ k → B k → Wₙ S (suc n)) (α-iso-step-5-Iso-helper0 a p (suc n)) (u (suc n))\n ≡\n subst (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 a p n) (u n) ∎\n\n α-iso-step-5-Iso :\n Iso\n (Σ[ a ∈ (Σ[ a ∈ ((n : ℕ) → A) ] ((n : ℕ) → a (suc n) ≡ a n)) ]\n Σ[ u ∈ ((n : ℕ) → B (a .fst n) → X (sequence S) n) ]\n ((n : ℕ) → PathP (λ x → B (a .snd n x) → X (sequence S) n)\n (π (sequence S) ∘ u (suc n))\n (u n)))\n (Σ[ a ∈ A ] (Σ[ u ∈ ((n : ℕ) → B a → X (sequence S) n) ] ((n : ℕ) → π (sequence S) ∘ (u (suc n)) ≡ u n)))\n α-iso-step-5-Iso =\n Σ-cong-iso (lemma11-Iso {S = S} (λ _ → A) (λ _ x → x)) (λ a,p →\n Σ-cong-iso (pathToIso (cong (λ k → (n : ℕ) → k n) (funExt λ n → cong (λ k → B k → Wₙ S n) (α-iso-step-5-Iso-helper0 (a,p .fst) (a,p .snd) n)))) λ u →\n pathToIso (cong (λ k → (n : ℕ) → k n) (funExt λ n → α-iso-step-5-Iso-helper1-Iso (a,p .fst) (a,p .snd) u n)))\n\n α-iso-step-1-4-Iso-lem-12 :\n Iso (Σ[ a ∈ (Σ[ a ∈ ((n : ℕ) → A)] ((n : ℕ) → a (suc n) ≡ a n)) ]\n (Σ[ u ∈ ((n : ℕ) → B (a .fst n) → X (sequence S) n) ]\n ((n : ℕ) → PathP (λ x → B (a .snd n x) → X (sequence S) n)\n (π (sequence S) ∘ u (suc n))\n (u n))))\n (limit-of-chain (sequence S))\n fun α-iso-step-1-4-Iso-lem-12 (a , b) = (λ { 0 → lift tt ; (suc n) → (a .fst n) , (b .fst n)}) , λ { 0 → refl {x = lift tt} ; (suc m) i → a .snd m i , b .snd m i }\n inv α-iso-step-1-4-Iso-lem-12 x = ((λ n → (x .fst) (suc n) .fst) , λ n i → (x .snd) (suc n) i .fst) , (λ n → (x .fst) (suc n) .snd) , λ n i → (x .snd) (suc n) i .snd\n fst (rightInv α-iso-step-1-4-Iso-lem-12 (b , c) i) 0 = lift tt\n fst (rightInv α-iso-step-1-4-Iso-lem-12 (b , c) i) (suc n) = refl i\n snd (rightInv α-iso-step-1-4-Iso-lem-12 (b , c) i) 0 = refl\n snd (rightInv α-iso-step-1-4-Iso-lem-12 (b , c) i) (suc n) = c (suc n)\n leftInv α-iso-step-1-4-Iso-lem-12 (a , b) = refl\n\nshift : ∀ {ℓ} (S : Container ℓ) -> P₀ S (M S) ≡ M S\nshift S = isoToPath (shift-iso S) -- lemma 13 & lemma 12\n\n-- Transporting along shift\n\nin-fun : ∀ {ℓ} {S : Container ℓ} -> P₀ S (M S) -> M S\nin-fun {S = S} = fun (shift-iso S)\n\nout-fun : ∀ {ℓ} {S : Container ℓ} -> M S -> P₀ S (M S)\nout-fun {S = S} = inv (shift-iso S)\n\n-- Property of functions into M-types\n\nlift-to-M : ∀ {ℓ} {A : Type ℓ} {S : Container ℓ}\n → (x : (n : ℕ) -> A → X (sequence S) n)\n → ((n : ℕ) → (a : A) → π (sequence S) (x (suc n) a) ≡ x n a)\n ---------------\n → (A → M S)\nlift-to-M x p a = (λ n → x n a) , λ n i → p n a i\n\nlift-direct-M : ∀ {ℓ} {S : Container ℓ}\n → (x : (n : ℕ) → X (sequence S) n)\n → ((n : ℕ) → π (sequence S) (x (suc n)) ≡ x n)\n ---------------\n → M S\nlift-direct-M x p = x , p\n", "meta": {"hexsha": "992810c3ecdb50c614d39c859ae66d27adecde6d", "size": 9631, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Codata/M/AsLimit/M/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/Codata/M/AsLimit/M/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/Codata/M/AsLimit/M/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": 49.3897435897, "max_line_length": 187, "alphanum_fraction": 0.4840618835, "num_tokens": 4004, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.839733963661418, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.5899383392278039}} {"text": "\n-- A Typed version of a subset of Landin's ISWIM from \"The Next 700 Programming\n-- Languages\"\n\nmodule ISWIM where\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN NATPLUS _+_ #-}\n\ndata Bool : Set where\n true : Bool\n false : Bool\n\nmodule Syntax where\n\n infixl 100 _∙_\n infixl 80 _WHERE_ _PP_\n infixr 60 _─→_\n infixl 40 _,_\n\n data Type : Set where\n nat : Type\n bool : Type\n _─→_ : Type -> Type -> Type\n\n data Context : Set where\n ε : Context\n _,_ : Context -> Type -> Context\n\n data Var : Context -> Type -> Set where\n vz : {Γ : Context}{τ : Type} -> Var (Γ , τ) τ\n vs : {Γ : Context}{σ τ : Type} -> Var Γ τ -> Var (Γ , σ) τ\n\n data Expr (Γ : Context) : Type -> Set where\n var : {τ : Type} -> Var Γ τ -> Expr Γ τ\n litNat : Nat -> Expr Γ nat\n litBool : Bool -> Expr Γ bool\n plus : Expr Γ (nat ─→ nat ─→ nat)\n if : {τ : Type} -> Expr Γ (bool ─→ τ ─→ τ ─→ τ)\n _∙_ : {σ τ : Type} -> Expr Γ (σ ─→ τ) -> Expr Γ σ -> Expr Γ τ\n _WHERE_ : {σ τ ρ : Type} -> Expr (Γ , σ ─→ τ) ρ -> Expr (Γ , σ) τ -> Expr Γ ρ\n _PP_ : {σ τ ρ : Type} -> Expr (Γ , σ ─→ τ) ρ -> Expr (Γ , σ) ρ -> Expr Γ ρ\n\n -- ƛ x. e = f where f x = e\n ƛ : {Γ : Context}{σ τ : Type} -> Expr (Γ , σ) τ -> Expr Γ (σ ─→ τ)\n ƛ e = var vz WHERE e\n\nmodule Cont (R : Set) where\n\n C : Set -> Set\n C a = (a -> R) -> R\n\n callcc : {a : Set} -> (({b : Set} -> a -> C b) -> C a) -> C a\n callcc {a} g = \\k -> g (\\x _ -> k x) k\n\n return : {a : Set} -> a -> C a\n return x = \\k -> k x\n\n infixr 10 _>>=_\n\n _>>=_ : {a b : Set} -> C a -> (a -> C b) -> C b\n (m >>= k) ret = m \\x -> k x ret\n\nmodule Semantics (R : Set) where\n\n open module C = Cont R\n open Syntax\n\n infix 60 _!_\n infixl 40 _||_\n\n ⟦_⟧type : Type -> Set\n\n ⟦_⟧type' : Type -> Set\n ⟦ nat ⟧type' = Nat\n ⟦ bool ⟧type' = Bool\n ⟦ σ ─→ τ ⟧type' = ⟦ σ ⟧type' -> ⟦ τ ⟧type\n\n ⟦ τ ⟧type = C ⟦ τ ⟧type'\n\n data ⟦_⟧ctx : Context -> Set where\n ★ : ⟦ ε ⟧ctx\n _||_ : {Γ : Context}{τ : Type} -> ⟦ Γ ⟧ctx -> ⟦ τ ⟧type' -> ⟦ Γ , τ ⟧ctx\n\n _!_ : {Γ : Context}{τ : Type} -> ⟦ Γ ⟧ctx -> Var Γ τ -> ⟦ τ ⟧type'\n ★ ! ()\n (ρ || v) ! vz = v\n (ρ || v) ! vs x = ρ ! x\n\n ⟦_⟧ : {Γ : Context}{τ : Type} -> Expr Γ τ -> ⟦ Γ ⟧ctx -> ⟦ τ ⟧type\n ⟦ var x ⟧ ρ = return (ρ ! x)\n ⟦ litNat n ⟧ ρ = return n\n ⟦ litBool b ⟧ ρ = return b\n ⟦ plus ⟧ ρ = return \\n -> return \\m -> return (n + m)\n ⟦ f ∙ e ⟧ ρ = ⟦ e ⟧ ρ >>= \\v ->\n ⟦ f ⟧ ρ >>= \\w ->\n w v\n ⟦ e WHERE f ⟧ ρ = ⟦ e ⟧ (ρ || (\\x -> ⟦ f ⟧ (ρ || x)))\n ⟦ e PP f ⟧ ρ = callcc \\k ->\n let throw = \\x -> ⟦ f ⟧ (ρ || x) >>= k\n in ⟦ e ⟧ (ρ || throw)\n ⟦ if ⟧ ρ = return \\x -> return \\y -> return \\z -> return (iff x y z)\n where\n iff : {A : Set} -> Bool -> A -> A -> A\n iff true x y = x\n iff false x y = y\n\nmodule Test where\n\n open Syntax\n open module C = Cont Nat\n open module S = Semantics Nat\n\n run : Expr ε nat -> Nat\n run e = ⟦ e ⟧ ★ \\x -> x\n\n -- 1 + 1\n two : Expr ε nat\n two = plus ∙ litNat 1 ∙ litNat 1\n\n -- f 1 + f 2 where f x = x\n three : Expr ε nat\n three = plus ∙ (var vz ∙ litNat 1) ∙ (var vz ∙ litNat 2) WHERE var vz\n\n -- 1 + f 1 where pp f x = x\n one : Expr ε nat\n one = plus ∙ litNat 1 ∙ (var vz ∙ litNat 1) PP var vz\n\nopen Test\n\ndata _==_ {a : Set}(x : a) : a -> Set where\n refl : x == x\n\ntwoOK : run two == 2\ntwoOK = refl\n\nthreeOK : run three == 3\nthreeOK = refl\n\noneOK : run one == 1\noneOK = refl\n\nopen Cont\nopen Syntax\nopen Semantics\n\n", "meta": {"hexsha": "edfaa245d96a9151a45665eeffc99333fc2afdbc", "size": 3702, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/ISWIM.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/ISWIM.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/ISWIM.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": 23.5796178344, "max_line_length": 81, "alphanum_fraction": 0.4648838466, "num_tokens": 1535, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619091240701, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.5898398434017067}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Ternary.Separation.Construct.Product where\n\nopen import Level\nopen import Data.Product\n\nopen import Relation.Unary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Ternary.Separation\nopen import Data.Product.Relation.Binary.Pointwise.NonDependent\n\nmodule _ {ℓ₁ ℓ₂} {C₁ : Set ℓ₁} {C₂ : Set ℓ₂} where\n\n _×-⊎_ : RawSep C₁ → RawSep C₂ → RawSep (C₁ × C₂)\n R₁ ×-⊎ R₂ =\n let\n module R₁ = RawSep R₁\n module R₂ = RawSep R₂\n in record\n { _⊎_≣_ = λ Φ₁ Φ₂ Φ →\n (proj₁ Φ₁) R₁.⊎ (proj₁ Φ₂) ≣ proj₁ Φ\n × (proj₂ Φ₁) R₂.⊎ (proj₂ Φ₂) ≣ proj₂ Φ }\n\n instance ×-rawsep : ⦃ _ : RawSep C₁ ⦄ ⦃ _ : RawSep C₂ ⦄ → RawSep (C₁ × C₂)\n ×-rawsep ⦃ R₁ ⦄ ⦃ R₂ ⦄ = R₁ ×-⊎ R₂\n\nmodule _\n {ℓ₁ ℓ₂} {C₁ : Set ℓ₁} {C₂ : Set ℓ₂}\n {{R₁ : RawSep C₁}} {{R₂ : RawSep C₂}}\n ⦃ s₁ : IsSep R₁ ⦄ ⦃ s₂ : IsSep R₂ ⦄\n where\n\n instance ×-isSep : IsSep (R₁ ×-⊎ R₂)\n ×-isSep = record\n { ⊎-comm = λ where (l , r) → ⊎-comm l , ⊎-comm r\n ; ⊎-assoc = λ where\n (l₁ , r₁) (l₂ , r₂) →\n let\n _ , l₃ , l₄ = ⊎-assoc l₁ l₂\n _ , r₃ , r₄ = ⊎-assoc r₁ r₂\n in -, (l₃ , r₃) , l₄ , r₄ }\n\nmodule _\n {ℓ₁ ℓ₂} {C₁ : Set ℓ₁} {C₂ : Set ℓ₂}\n {{R₁ : RawSep C₁}} {{R₂ : RawSep C₂}} {u₁ u₂}\n ⦃ s₁ : IsUnitalSep R₁ u₁ ⦄ ⦃ s₂ : IsUnitalSep R₂ u₂ ⦄\n where\n\n instance ×-isUnitalSep : IsUnitalSep ×-rawsep (u₁ , u₂)\n ×-isUnitalSep = record\n { isSep = ×-isSep\n ; ⊎-idˡ = ⊎-idˡ , ⊎-idˡ \n ; ⊎-id⁻ˡ = λ where\n (fst , snd) → cong₂ _,_ (⊎-id⁻ˡ fst) (⊎-id⁻ˡ snd)\n }\n\n instance _×-ε-separation_ : UnitalSep _\n _×-ε-separation_ = record\n { isUnitalSep = ×-isUnitalSep }\n\nmodule _\n {ℓ₁ ℓ₂}\n ⦃ s₁ : Separation ℓ₁ ⦄ ⦃ s₂ : Separation ℓ₂ ⦄\n where\n\n private\n module S₁ = Separation s₁\n module S₂ = Separation s₂\n\n ×-separation : Separation _\n ×-separation = record\n { isSep = ×-isSep {{ _ }} {{ _ }} ⦃ Separation.isSep s₁ ⦄ ⦃ Separation.isSep s₂ ⦄ }\n\nmodule _\n {ℓ₁ ℓ₂}\n {C₁ : Set ℓ₁} {C₂ : Set ℓ₂}\n ⦃ sep₁ : RawSep C₁ ⦄ ⦃ sep₂ : RawSep C₂ ⦄\n ⦃ s₁ : IsConcattative sep₁ ⦄ ⦃ s₂ : IsConcattative sep₂ ⦄\n where\n\n private\n module S₁ = IsConcattative s₁\n module S₂ = IsConcattative s₂\n\n instance ×-concat : IsConcattative ×-rawsep\n ×-concat = record\n { _∙_ = (λ where (a , b) (c , d) → (a S₁.∙ c , b S₂.∙ d))\n ; ⊎-∙ₗ = λ where (p , q) → ⊎-∙ₗ p , ⊎-∙ₗ q }\n\n{- Some useful type-formers for this instance -}\nmodule _ {ℓ} {A : Set ℓ} {{ r : RawSep A }} {u} {{s : IsUnitalSep r u}} where\n\n data Π₁ {p} (P : Pred A p) : Pred (A × A) (ℓ ⊔ p) where\n fst : ∀ {a} → P a → Π₁ P (a , ε)\n\n data Π₂ {p} (P : Pred A p) : Pred (A × A) (ℓ ⊔ p) where\n snd : ∀ {a} → P a → Π₂ P (ε , a)\n", "meta": {"hexsha": "549bdcdf61e2d87d3bcce41d7aa99e2e1730c911", "size": 2718, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Relation/Ternary/Separation/Construct/Product.agda", "max_stars_repo_name": "laMudri/linear.agda", "max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z", "max_issues_repo_path": "src/Relation/Ternary/Separation/Construct/Product.agda", "max_issues_repo_name": "laMudri/linear.agda", "max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_issues_repo_licenses": ["MIT"], "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/Ternary/Separation/Construct/Product.agda", "max_forks_repo_name": "laMudri/linear.agda", "max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z", "avg_line_length": 27.18, "max_line_length": 87, "alphanum_fraction": 0.5562913907, "num_tokens": 1291, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.589839840737219}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nopen import Prelude hiding (sym; refl)\nopen import Relation.Binary\n\nmodule Relation.Binary.Lattice {ℓ₁ ℓ₂ ℓ₃} {𝑆 : Type ℓ₁} (totalOrder : TotalOrder 𝑆 ℓ₂ ℓ₃) where\n\nopen TotalOrder totalOrder\n\nimport Path as ≡\n\nmin-max : 𝑆 → 𝑆 → 𝑆 × 𝑆\nmin-max x y = bool′ (y , x) (x , y) (x <ᵇ y)\n\n_⊔_ : 𝑆 → 𝑆 → 𝑆\nx ⊔ y = snd (min-max x y)\n\n_⊓_ : 𝑆 → 𝑆 → 𝑆\nx ⊓ y = fst (min-max x y)\n\nmin-max-assoc : ∀ x y z → map-Σ (_⊓ z) (_⊔ z) (min-max x y) ≡ map-Σ (x ⊓_) (x ⊔_) (min-max y z)\nmin-max-assoc x y z with x (ε.at (omap A)) ∘ (δ.at A) ≈ id\n ε-unit2 : ∀ {A : obj} -> (fmap (ε.at A)) ∘ (δ.at A) ≈ id\n\n -- Duplication can be performed on both sides (coassociativity)\n δ-assoc : ∀ {A : obj} -> (δ.at (omap A)) ∘ (δ.at A)\n ≈ (fmap (δ.at A)) ∘ (δ.at A)\n", "meta": {"hexsha": "eabae152dde6c6bb0befa1ceb738d186f3902152", "size": 985, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/CategoryTheory/Comonad.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/Comonad.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/Comonad.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": 28.1428571429, "max_line_length": 72, "alphanum_fraction": 0.5512690355, "num_tokens": 312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.936285002192296, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.5896485131683615}} {"text": "------------------------------------------------------------------------------\n-- Addition as a function constant\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOTC.AddConstant where\n\n------------------------------------------------------------------------------\n-- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n-- Algebra.agda and Relation/Binary/Core.agda).\ninfixl 9 _·_\ninfix 7 _≡_\n\npostulate\n D : Set\n _·_ : D → D → D\n true false if : D\n zero succ pred iszero : D\n _≡_ : D → D → Set\n\npostulate\n if-true : ∀ t {t'} → if · true · t · t' ≡ t\n if-false : ∀ {t} t' → if · false · t · t' ≡ t'\n pred-0 : pred · zero ≡ zero\n pred-S : ∀ n → pred · (succ · n) ≡ n\n iszero-0 : iszero · zero ≡ true\n iszero-S : ∀ n → iszero · (succ · n) ≡ false\n{-# ATP axioms if-true if-false pred-0 pred-S iszero-0 iszero-S #-}\n\npostulate\n + : D\n +-eq : ∀ m n → + · m · n ≡\n if · (iszero · m) · n · (succ · (+ · (pred · m) · n))\n{-# ATP axiom +-eq #-}\n\npostulate\n +-0x : ∀ n → + · zero · n ≡ n\n +-Sx : ∀ m n → + · (succ · m) · n ≡ succ · (+ · m · n)\n{-# ATP prove +-0x #-}\n{-# ATP prove +-Sx #-}\n\n-- $ cd fotc/notes/thesis\n-- $ agda -i. -i ~/fot FOTC/AddConstant.agda\n-- $ apia -i. -i ~/fot FOTC/AddConstant.agda\n-- Proving the conjecture in /tmp/FOTC/AddConstant/37-43-0x.tptp ...\n-- Vampire 0.6 (revision 903) proved the conjecture\n-- Proving the conjecture in /tmp/FOTC/AddConstant/38-43-Sx.tptp ...\n-- Vampire 0.6 (revision 903) proved the conjecture\n", "meta": {"hexsha": "f925817b7b0d83b28d5471ec26449ec041b4c46e", "size": 1767, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/FOTC/AddConstant.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/AddConstant.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/AddConstant.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.3396226415, "max_line_length": 78, "alphanum_fraction": 0.4589700057, "num_tokens": 548, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.5896255720722603}} {"text": "------------------------------------------------------------------------------\n-- Totality of predecessor function\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 FOT.FOTC.Data.Nat.PredTotality where\n\nopen import FOTC.Base\n\ndata N : D → Set where\n nzero : N zero\n nsucc : ∀ {n} → N n → N (succ₁ n)\n\n-- Induction principle generated by Coq 8.4pl4 when we define the data\n-- type N in Prop.\nN-ind₁ : (A : D → Set) →\n A zero →\n (∀ {n} → N n → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\nN-ind₁ A A0 h nzero = A0\nN-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.\nN-ind₂ : (A : D → Set) →\n A zero →\n (∀ {n} → A n → A (succ₁ n)) →\n ∀ {n} → N n → A n\nN-ind₂ A A0 h nzero = A0\nN-ind₂ A A0 h (nsucc Nn) = h (N-ind₂ A A0 h Nn)\n\n-- Proof by pattern matching.\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-- Proof using N-ind₁.\npred-N₁ : ∀ {n} → N n → N (pred₁ n)\npred-N₁ = N-ind₁ A A0 is\n where\n A : D → Set\n A i = N (pred₁ i)\n\n A0 : A zero\n A0 = subst N (sym pred-0) nzero\n\n is : ∀ {i} → N i → A i → A (succ₁ i)\n is {i} Ni Ai = subst N (sym (pred-S i)) Ni\n\n-- Proof using N-ind₂.\n-- pred-N₂ : ∀ {n} → N n → N (pred₁ n)\n-- pred-N₂ = N-ind₂ A A0 is\n-- where\n-- A : D → Set\n-- A i = N (pred₁ i)\n\n-- A0 : A zero\n-- A0 = subst N (sym pred-0) nzero\n\n-- is : ∀ {i} → A i → A (succ₁ i)\n-- is {i} Ai = {!!}\n", "meta": {"hexsha": "b0b87d768ef23605cd081dd3b537f768dcecfd9d", "size": 1799, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/PredTotality.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/PredTotality.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/PredTotality.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.8507462687, "max_line_length": 78, "alphanum_fraction": 0.4724847137, "num_tokens": 629, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342624, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.5896255558107014}} {"text": "-- Minimal implicational logic, PHOAS approach, initial encoding\n\nmodule STLC where\n\n\n-- Types\n\ninfixr 0 _=>_\n\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n\n\n-- Context\n\nCx : Set1\nCx = Ty -> Set\n\n\n-- Terms\n\ninfixl 1 _$_\n\ndata Tm (tc : Cx) : Ty -> Set\n where\n var : forall {a} -> tc a\n ----------\n -> Tm tc a\n\n lam : forall {a b} -> (tc a -> Tm tc b)\n ---------------------\n -> Tm tc (a => b)\n\n _$_ : forall {a b} -> Tm tc (a => b) -> Tm tc a\n ----------------------------\n -> Tm tc b\n\nT : Ty -> Set1\nT a = forall {tc} -> Tm tc a\n\n\n-- Example theorems\n\nI : forall {a} -> T (a => a)\nI = lam \\x ->\n var x\n\nK : forall {a b} -> T (a => b => a)\nK = lam \\x ->\n lam \\_ ->\n var x\n\nS : forall {a b c} -> T ((a => b => c) => (a => b) => a => c)\nS = lam \\f ->\n lam \\g ->\n lam \\x ->\n (var f $ var x) $ (var g $ var x)\n\nSKK : forall {a} -> T (a => a)\nSKK {a = a} = S {b = a => a} $ K $ K\n", "meta": {"hexsha": "449396912a1e1ade1a2e34b03b6d232cb90f1d94", "size": 1091, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/STLC.agda", "max_stars_repo_name": "mietek/haskell-exchange-2015", "max_stars_repo_head_hexsha": "3f8e19674283d64d6c7e50f66a3e8f33138e9195", "max_stars_repo_licenses": ["X11"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-10-09T09:19:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-19T18:09:21.000Z", "max_issues_repo_path": "src/STLC.agda", "max_issues_repo_name": "mietek/haskell-exchange-2015", "max_issues_repo_head_hexsha": "3f8e19674283d64d6c7e50f66a3e8f33138e9195", "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/STLC.agda", "max_forks_repo_name": "mietek/haskell-exchange-2015", "max_forks_repo_head_hexsha": "3f8e19674283d64d6c7e50f66a3e8f33138e9195", "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": 17.5967741935, "max_line_length": 64, "alphanum_fraction": 0.35472044, "num_tokens": 358, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156294, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5895014800847672}} {"text": "------------------------------------------------------------------------\n-- Some examples\n------------------------------------------------------------------------\n\nmodule Contractive.Examples where\n\nopen import Codata.Musical.Notation\nopen import Codata.Musical.Stream\nopen import Data.Nat\nopen import Data.Nat.Properties\nimport Data.Vec as Vec\nopen Vec using (_∷_; [])\nopen import Function\nopen import Contractive\nimport Contractive.Stream as S\nopen import StreamProg using (Ord; lt; eq; gt; merge)\nopen import Relation.Binary.PropositionalEquality\nopen ≡-Reasoning\n\nopen COFE (S.cofe 0)\n\nfibF : ContractiveFun (S.cofe 0)\nfibF = record\n { F = F\n ; isContractive = isCon _ _ _\n }\n where\n F = λ xs → 0 ∷ ♯ (1 ∷ ♯ zipWith _+_ xs (tail xs))\n\n lemma₁ : ∀ _∙_ (xs ys : Stream ℕ) n →\n take n (zipWith _∙_ xs ys) ≡\n Vec.zipWith _∙_ (take n xs) (take n ys)\n lemma₁ _∙_ _ _ zero = refl\n lemma₁ _∙_ (x ∷ xs) (y ∷ ys) (suc n) =\n cong (_∷_ (x ∙ y)) (lemma₁ _∙_ (♭ xs) (♭ ys) n)\n\n lemma₂ : ∀ (xs ys : Stream ℕ) n →\n Eq n xs ys → take n xs ≡ take n ys\n lemma₂ _ _ zero _ = refl\n lemma₂ (x ∷ xs) ( y ∷ ys) (suc n) hyp\n with cong Vec.head hyp | take n (♭ xs) | lemma₂ (♭ xs) (♭ ys) n (cong Vec.tail hyp)\n lemma₂ (x ∷ xs) (.x ∷ ys) (suc n) hyp | refl | .(take n (♭ ys)) | refl = refl\n\n isCon : ∀ (xs ys : Stream ℕ) n →\n (∀ {m} → m <′ n → Eq m xs ys) →\n Eq n (F xs) (F ys)\n isCon _ _ zero _ = refl\n isCon (x ∷ xs) (y ∷ ys) (suc n) hyp = cong (λ zs → 0 ∷ 1 ∷ zs) (begin\n take n (zipWith _+_ (x ∷ xs) (♭ xs)) ≡⟨ lemma₁ _+_ (x ∷ xs) (♭ xs) n ⟩\n Vec.zipWith _+_ (take n (x ∷ xs)) (take n (♭ xs)) ≡⟨ cong₂ (Vec.zipWith _+_)\n (lemma₂ _ _ n (hyp ≤′-refl))\n (cong Vec.tail (hyp ≤′-refl)) ⟩\n Vec.zipWith _+_ (take n (y ∷ ys)) (take n (♭ ys)) ≡⟨ sym $ lemma₁ _+_ (y ∷ ys) (♭ ys) n ⟩\n take n (zipWith _+_ (y ∷ ys) (♭ ys)) ∎)\n\nfib : Stream ℕ\nfib = ContractiveFun.fixpoint fibF\n\n-- Note that I could not be bothered to finish the following\n-- definition.\n\nhammingF : ContractiveFun (S.cofe 0)\nhammingF = record\n { F = F\n ; isContractive = isCon _ _ _\n }\n where\n toOrd : ∀ {m n} → Ordering m n → Ord\n toOrd (less _ _) = lt\n toOrd (equal _) = eq\n toOrd (greater _ _) = gt\n\n cmp : ℕ → ℕ → Ord\n cmp m n = toOrd (compare m n)\n\n F = λ (xs : _) → 0 ∷ ♯ merge cmp (map (_*_ 2) xs) (map (_*_ 3) xs)\n\n postulate\n lemma : ∀ n → cmp (2 * suc n) (3 * suc n) ≡ lt\n\n isCon : ∀ (xs ys : Stream ℕ) n →\n (∀ {m} → m <′ n → Eq m xs ys) →\n Eq n (F xs) (F ys)\n isCon _ _ zero _ = refl\n isCon (x ∷ xs) (y ∷ ys) (suc n) hyp with cong Vec.head (hyp (s≤′s z≤′n))\n isCon (0 ∷ xs) (.0 ∷ ys) (suc n) hyp | refl =\n cong (λ zs → 0 ∷ 0 ∷ zs) (begin\n take n (merge cmp (map (_*_ 2) (♭ xs)) (map (_*_ 3) (♭ xs))) ≡⟨ iCantBeBothered ⟩\n take n (merge cmp (map (_*_ 2) (♭ ys)) (map (_*_ 3) (♭ ys))) ∎)\n where postulate iCantBeBothered : _\n isCon (suc x ∷ xs) (.(suc x) ∷ ys) (suc n) hyp | refl\n with cmp (2 * suc x) (3 * suc x) | lemma x\n isCon (suc x ∷ xs) (.(suc x) ∷ ys) (suc n) hyp | refl | .lt | refl =\n cong (λ zs → 0 ∷ 2 * suc x ∷ zs) (begin\n take n (merge cmp (map (_*_ 2) (♭ xs))\n (map (_*_ 3) (suc x ∷ xs))) ≡⟨ iCantBeBothered ⟩\n take n (merge cmp (map (_*_ 2) (♭ ys))\n (map (_*_ 3) (suc x ∷ ys))) ∎)\n where postulate iCantBeBothered : _\n\nhamming : Stream ℕ\nhamming = ContractiveFun.fixpoint hammingF\n", "meta": {"hexsha": "acd2356ce69d3454342b560191f950099ec8f243", "size": 3712, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Contractive/Examples.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": "Contractive/Examples.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": "Contractive/Examples.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": 36.0388349515, "max_line_length": 95, "alphanum_fraction": 0.484375, "num_tokens": 1400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473713594992, "lm_q2_score": 0.6757645879592642, "lm_q1q2_score": 0.5895014619640992}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule PComp where\n\nopen import Data.Empty\nopen import Data.Sum\nopen import Data.Nat as Nat\nopen import Data.Nat.Properties.Simple\nopen import Data.Nat.Properties\nopen import Data.Product\nopen import Data.Bool renaming (Bool to 𝔹)\nopen import Data.Bool.Properties\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\n\nopen import Relation.Binary\nopen DecTotalOrder ≤-decTotalOrder using ()\n renaming (refl to ≤-refl; trans to ≤-trans)\n\n-- open import Size\n\n-- record D {i : Size} (A : Set) : Set where\n-- coinductive\n-- field step : {j : Size< i} → A ⊎ D {j} A\n\n-- open D public\n\n-- μ' : ∀{i} → (ℕ → 𝔹) → ℕ → D {i} ℕ\n-- μ' p n .step = if p n then inj₁ n else inj₂ (μ' p (suc n))\n\nprimRec : {X Y : Set} → (X → Y) → (ℕ → Y → X → Y) → ℕ → X → Y\nprimRec f g zero x = f x\nprimRec f g (suc n) x = g n (primRec f g n x) x\n\nrecord D (A : Set) : Set where\n coinductive\n field step : A ⊎ D A\n\nopen D public\n\nμ' : (ℕ → 𝔹) → ℕ → D ℕ\nc : (ℕ → 𝔹) → ℕ → 𝔹 → ℕ ⊎ (D ℕ)\n\nμ' p n .step = c p n (p n)\n\nc p n false = inj₂ (μ' p (1 + n))\nc p n true = inj₁ n\n\nμ : (ℕ → 𝔹) → D ℕ\nμ p = μ' p 0\n\nisEven : ℕ → 𝔹\nisEven zero = true\nisEven (suc zero) = false\nisEven (suc (suc n)) = isEven n\n\ndata _↓_ {A : Set} (d : D A) (a : A) : Set where\n now : d .step ≡ inj₁ a → d ↓ a\n later : {d' : D A} → d .step ≡ inj₂ d' → d' ↓ a → d ↓ a\n\nfoo : μ' isEven 3 ↓ 4\nfoo = later (cong inj₂ refl) (now refl)\n\nμ-finds-tt : ∀{p : ℕ → 𝔹} {m n : ℕ} → μ' p m ↓ n → p n ≡ true\nμ-finds-tt {p} {m} (now q) with p m | inspect p m\nμ-finds-tt {p} {m} (now ()) | false | _\nμ-finds-tt {p} {m} (now refl) | true | [ eq ] = eq\nμ-finds-tt {p} {m} (later q t) with p m\nμ-finds-tt {p} {m} (later refl t) | false = μ-finds-tt t\nμ-finds-tt {p} {m} (later () t) | true\n\n-- | Compute the number of steps taken to obtain p n = tt.\nμ-dist : ∀{p : ℕ → 𝔹} {m n : ℕ} → μ' p m ↓ n → ∃ λ k → n ≡ m + k\nμ-dist {p} {m} (now q) with p m\nμ-dist {p} {m} (now ()) | false\nμ-dist {p} {m} (now refl) | true = (0 , sym (+-identityʳ m))\nμ-dist {p} {m} (later q t) with p m\nμ-dist {p} {m} (later refl t) | false =\n let (k , e) = μ-dist t\n in (1 + k , trans e (sym (+-suc m k)))\nμ-dist {p} {m} (later () t) | true\n\nempty-interval : ∀ {m k} → m ≤ k → k < m → ⊥\nempty-interval z≤n ()\nempty-interval (s≤s p) (s≤s q) = empty-interval p q\n\nsuc≤⇒≤ : ∀ m n → suc m ≤ n → m ≤ n\nsuc≤⇒≤ m zero ()\nsuc≤⇒≤ .0 (suc n) (s≤s z≤n) = z≤n\nsuc≤⇒≤ .(suc _) (suc .(suc _)) (s≤s (s≤s p)) = s≤s (suc≤⇒≤ _ _ (s≤s p))\n\n-- | The proof proceeds by induction on the termination proof t : μ' p m ↓ n.\n-- In the process, we first distinguishing whether m = k or m < k.\n-- Next, we check whether the computation has termination, that is, whether\n-- t = now ... or t = later.\n-- Finally, we distinguish on the values of p m, which allows us to make\n-- a computation step with μ'. The other cases follow then from there.\nμ-min : ∀{p : ℕ → 𝔹} {m n : ℕ} → μ' p m ↓ n → ∀ k → m ≤′ k → k < n → p k ≡ false\n-- m = k\n---- t = now\nμ-min {p} {.m} (now q) m ≤′-refl u with p m\nμ-min {p} {.m} (now q) m ≤′-refl u | false = refl\nμ-min {p} {.m} (now refl) m ≤′-refl u | true = ⊥-elim (1+n≰n u)\n\n-- m = k\n---- t = later\nμ-min {p} {.m} (later q t) m ≤′-refl u with p m\nμ-min {p} {.m} (later q t) m ≤′-refl u | false = refl\nμ-min {p} {.m} (later () t) m ≤′-refl u | true\n\n-- m < k\n---- t = now\nμ-min {p} {m} (now q) .(suc _) (≤′-step l) u with p m\nμ-min {p} {m} (now ()) .(suc _) (≤′-step l) u | false\nμ-min {p} {.(suc _)} (now refl) .(suc _) (≤′-step l) (s≤s u) | true =\n ⊥-elim (empty-interval (suc≤⇒≤ _ _ (≤′⇒≤ l)) u)\n\n-- m < k\n---- t = later\nμ-min {p} {m} (later q t) .(suc _) (≤′-step {k'} l) u with p m\nμ-min {p} {m} (later refl t) .(suc _) (≤′-step {k'} l) u | false =\n μ-min t (suc k') (s≤′s l) u\nμ-min {p} {m} (later () t) .(suc n) (≤′-step {n} l) u | true\n\nMin : (ℕ → Set) → ℕ → Set\nMin P n = P n × ∀ k → k < n → ¬ (P k)\n\n-- | Definition of partial correctness for the μ-operator.\n-- This states that if μ p terminates with n as result, then n is the\n-- minimal number, for which p n ≡ true.\nPartialCorrectness : Set\nPartialCorrectness = ∀{p : ℕ → 𝔹} {n : ℕ} →\n μ p ↓ n → Min (λ k → p k ≡ true) n\n\nμ-pcorrect : PartialCorrectness\nμ-pcorrect t = (μ-finds-tt t , (λ k u → not-¬ (μ-min t k (z≤′n) u)))\n\n-- Correctness : Set\n-- Correctness = ∀{p : ℕ → 𝔹} →\n-- ¬(∃ λ n → μ p ↓ n) → ∀ n → ¬(p n ≡ true)\n\n-- find-min' : ∀{p : ℕ → 𝔹} → ∀ n → p n ≡ true → (m : ℕ) → m ≤ n →\n-- (∃ λ k → k ≤ n × p k ≡ true)\n-- find-min' {p} last pt zero l with p 0 | inspect p 0\n-- find-min' {p} last pt zero l | false | e = (last , ≤-refl , pt)\n-- find-min' {p} last pt zero l | true | [ e ] = (zero , l , e)\n-- find-min' {p} last pt (suc m) l with p m | inspect p m\n-- find-min' {p} last pt (suc m) l | false | e =\n-- find-min' last pt m (suc≤⇒≤ m last l)\n-- find-min' {p} last pt (suc m) l | true | [ e ] =\n-- let (k , k≤last , q) = find-min' {p} m e m ≤-refl\n-- in (k , ≤-trans k≤last (suc≤⇒≤ m last l) , q)\n\n-- find-min : ∀{p : ℕ → 𝔹} → ∀ n → p n ≡ true → (∃ λ k → k ≤ n × p k ≡ true)\n-- find-min {p} n pt = find-min' {p} n pt n ≤-refl\n\n-- min-terminate : ∀{p : ℕ → 𝔹} → ∀ n (e : p n ≡ true) (m : ℕ) → m ≤ n → ∃ λ k → μ p ↓ k\n-- min-terminate {p} last pt zero m≤n with p 0 | inspect p 0\n-- min-terminate {p} last pt zero m≤n | false | e = {!!} , {!!}\n-- min-terminate {p} last pt zero m≤n | true | e = {!!}\n-- min-terminate {p} last pt (suc m) m≤n = {!!}\n\n\n-- lem : ∀{p : ℕ → 𝔹} → ∀ n → p n ≡ true → ∃ λ k → μ p ↓ k\n-- lem {p} zero q with p 0 | inspect p 0\n-- lem {p} zero () | false | _\n-- lem {p} zero q | true | [ e ] = (0 , now (cong (c p 0) e))\n-- lem {p} (suc n) q with p (suc n) | inspect p (suc n)\n-- lem {p} (suc n) () | false | e\n-- lem {p} (suc n) q | true | e =\n-- let (k , t) = lem n {!!}\n-- in (suc n , now {!!})\n\n-- μ-correct : Correctness\n-- μ-correct q n pt = q (lem n pt)\n", "meta": {"hexsha": "b224d39af4524d84974218bae4a8974af27c6b0e", "size": 6051, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Partial/PComp.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": "Partial/PComp.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": "Partial/PComp.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": 34.3806818182, "max_line_length": 88, "alphanum_fraction": 0.505536275, "num_tokens": 2604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.7690802317779601, "lm_q1q2_score": 0.5893412926345274}} {"text": "open import Agda.Primitive\nopen import Agda.Builtin.Equality\nopen import Agda.Builtin.List\nopen import Agda.Builtin.Reflection\n\ntestQuote : quoteTerm Setω ≡ agda-sort (inf 0)\ntestQuote = refl\n\nmacro\n doUnquote : Term → Term → TC _\n doUnquote t hole = bindTC (unquoteTC t) (unify hole)\n\ntestUnquote : doUnquote (agda-sort (inf 0))\ntestUnquote = ∀ ℓ → Set ℓ\n", "meta": {"hexsha": "c2721b12eca202d9cda4ae444a4c5735ebfc3c67", "size": 358, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/QuoteSetOmega.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/QuoteSetOmega.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/QuoteSetOmega.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.8666666667, "max_line_length": 54, "alphanum_fraction": 0.7458100559, "num_tokens": 115, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.5893284347036052}} {"text": "{-# OPTIONS --without-K #-}\nmodule function.isomorphism.two-out-of-six where\n\nopen import sum\nopen import equality\nopen import function.core\nopen import function.isomorphism.core\nopen import function.overloading\nopen import hott.equivalence.core\nopen import hott.equivalence.biinvertible\n\nmodule two-out-of-six\n {i j k l}{X : Set i}{Y : Set j}{Z : Set k}{W : Set l}\n (f : X → Y)(g : Y → Z)(h : Z → W)\n (gf-equiv : weak-equiv (g ∘ f))\n (hg-equiv : weak-equiv (h ∘ g)) where\n private\n r : X ≅ Z\n r = ≈⇒≅ (g ∘ f , gf-equiv)\n\n s : Y ≅ W\n s = ≈⇒≅ (h ∘ g , hg-equiv)\n\n gl : Z → Y\n gl = invert s ∘ h\n\n gr : Z → Y\n gr = f ∘ invert r\n\n g-iso : Y ≅ Z\n g-iso = b⇒≅ (g , (gl , _≅_.iso₁ s) , (gr , _≅_.iso₂ r))\n\n f-iso : X ≅ Y\n f-iso = record\n { to = f\n ; from = λ y → invert r (g y)\n ; iso₁ = _≅_.iso₁ r\n ; iso₂ = λ y → sym (_≅_.iso₁ g-iso (f (invert r (g y))))\n · ap (invert g-iso) (_≅_.iso₂ r (g y))\n · _≅_.iso₁ g-iso y }\n\n h-iso : Z ≅ W\n h-iso = record\n { to = h\n ; from = λ w → g (invert s w)\n ; iso₁ = λ z → sym (ap (λ z → g (invert s (h z))) (_≅_.iso₂ g-iso z))\n · ap g (_≅_.iso₁ s (invert g-iso z))\n · _≅_.iso₂ g-iso z\n ; iso₂ = _≅_.iso₂ s }\n", "meta": {"hexsha": "6ffefed050c26399766c28dc1e294f987844bba5", "size": 1288, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/function/isomorphism/two-out-of-six.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/function/isomorphism/two-out-of-six.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/function/isomorphism/two-out-of-six.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.76, "max_line_length": 73, "alphanum_fraction": 0.4937888199, "num_tokens": 500, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314798554444, "lm_q2_score": 0.6654105587468141, "lm_q1q2_score": 0.5893085378543791}} {"text": "module lambda.stack where\n\nopen import Relation.Binary.PropositionalEquality\n\ninfixr 40 _▸_\ninfixl 35 _∈_\n\ndata stack (T : Set) : Set where\n ε : stack T\n _▸_ : stack T → T → stack T\n\ndata _∈_ {T : Set} (x : T) : stack T → Set where\n here : ∀ {Γ} → x ∈ Γ ▸ x\n there : ∀ {Γ y} → x ∈ Γ → x ∈ Γ ▸ y\n\ndata _⊇_ {T : Set} : stack T → stack T → Set where\n bot : ε ⊇ ε\n skip : ∀ {Γ Δ x} → Γ ⊇ Δ → Γ ▸ x ⊇ Δ\n keep : ∀ {Γ Δ x} → Γ ⊇ Δ → Γ ▸ x ⊇ Δ ▸ x\n\nmodule _ {T : Set} where\n\n id : ∀ {Γ : stack T} → Γ ⊇ Γ\n id {ε} = bot\n id {Γ ▸ x} = keep id\n\n\n shift : ∀ {Γ Δ} {x : T} → Γ ⊇ Δ → x ∈ Δ → x ∈ Γ\n shift bot ()\n shift (skip x) v = there (shift x v)\n shift (keep _) here = here\n shift (keep x) (there y) = there (shift x y)\n\n shift-id : ∀ {Γ : stack T} {x} → (e : x ∈ Γ) → shift id e ≡ e\n shift-id here = refl\n shift-id (there e) = cong there (shift-id e)\n\n _∘⊇_ : {Γ Δ Λ : stack T} → Γ ⊇ Δ → Δ ⊇ Λ → Γ ⊇ Λ\n bot ∘⊇ bot = bot\n skip x ∘⊇ y = skip (x ∘⊇ y)\n keep x ∘⊇ skip y = skip (x ∘⊇ y)\n keep x ∘⊇ keep y = keep (x ∘⊇ y)\n\n ∘⊇-idˡ : {Γ Δ : stack T} → (w : Γ ⊇ Δ) → id ∘⊇ w ≡ w\n ∘⊇-idˡ bot = refl\n ∘⊇-idˡ (skip x) = cong skip (∘⊇-idˡ x)\n ∘⊇-idˡ (keep x) = cong keep (∘⊇-idˡ x)\n\n ∘⊇-idʳ : {Δ Γ : stack T} → (w : Γ ⊇ Δ) → w ∘⊇ id ≡ w\n ∘⊇-idʳ bot = refl\n ∘⊇-idʳ (skip x) = cong skip (∘⊇-idʳ x)\n ∘⊇-idʳ (keep x) = cong keep (∘⊇-idʳ x)\n\n ∘⊇-assoc : {Γ Δ Λ Ω : stack T} → (w₁ : Γ ⊇ Δ) → (w₂ : Δ ⊇ Λ) → (w₃ : Λ ⊇ Ω) → (w₁ ∘⊇ w₂) ∘⊇ w₃ ≡ w₁ ∘⊇ (w₂ ∘⊇ w₃)\n ∘⊇-assoc bot bot bot = refl\n ∘⊇-assoc (skip w₁) w₂ w₃ = cong skip (∘⊇-assoc w₁ w₂ w₃)\n ∘⊇-assoc (keep w₁) (skip w₂) w₃ = cong skip (∘⊇-assoc w₁ w₂ w₃)\n ∘⊇-assoc (keep w₁) (keep w₂) (skip w₃) = cong skip (∘⊇-assoc w₁ w₂ w₃)\n ∘⊇-assoc (keep w₁) (keep w₂) (keep w₃) = cong keep (∘⊇-assoc w₁ w₂ w₃)\n", "meta": {"hexsha": "d1bf880ddc0f28b602c8549f145c61855c42d51f", "size": 1765, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lambda/stack.agda", "max_stars_repo_name": "Lapin0t/lambda", "max_stars_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2", "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": "lambda/stack.agda", "max_issues_repo_name": "Lapin0t/lambda", "max_issues_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2", "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": "lambda/stack.agda", "max_forks_repo_name": "Lapin0t/lambda", "max_forks_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2", "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.4166666667, "max_line_length": 115, "alphanum_fraction": 0.4883852691, "num_tokens": 981, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314677809303, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.5893085239435548}} {"text": "------------------------------------------------------------------------\n-- Binomial theorem\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe --exact-split #-}\n\nmodule Math.BinomialTheorem.Nat where\n\n-- agda-stdlib\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Data.Nat.Solver\nopen import Relation.Binary.PropositionalEquality\nopen import Function\n\n-- agda-combinatorics\nopen import Math.Combinatorics.Function\nopen import Math.Combinatorics.Function.Properties\n\n-- agda-misc\nopen import Math.NumberTheory.Summation.Nat\nopen import Math.NumberTheory.Summation.Nat.Properties\n\nopen ≤-Reasoning\n\nprivate\n lemma₁ : ∀ x y n k → x * (C n k * (x ^ k * y ^ (n ∸ k))) ≡\n C n k * (x ^ suc k * y ^ (n ∸ k))\n lemma₁ x y n k =\n solve 4 (λ m n o p → m :* (n :* (o :* p)) := n :* (m :* o :* p))\n refl x (C n k) (x ^ k) (y ^ (n ∸ k))\n where open +-*-Solver\n\n lemma₂ : ∀ x y n k → y * (C n k * (x ^ k * y ^ (n ∸ k))) ≡\n C n k * (x ^ k * y ^ suc (n ∸ k))\n lemma₂ x y n k =\n solve 4 (λ m n o p → m :* (n :* (o :* p)) := n :* (o :* (m :* p)) )\n refl y (C n k) (x ^ k) (y ^ (n ∸ k))\n where open +-*-Solver\n\n glemma₃ : ∀ x y m n → C m m * (x ^ suc n * y ^ (n ∸ n)) ≡ x ^ suc n\n glemma₃ x y m n = begin-equality\n C m m * (x ^ suc n * y ^ (n ∸ n))\n ≡⟨ cong₂ (λ u v → u * (x ^ suc n * y ^ v)) (C[n,n]≡1 m) (n∸n≡0 n) ⟩\n 1 * (x ^ suc n * 1)\n ≡⟨ *-identityˡ (x ^ suc n * 1) ⟩\n x ^ suc n * 1\n ≡⟨ *-identityʳ (x ^ suc n) ⟩\n x ^ suc n\n ∎\n\n lemma₃ : ∀ x y n → C n n * (x ^ suc n * y ^ (n ∸ n)) ≡ x ^ suc n\n lemma₃ x y n = glemma₃ x y n n\n\n lemma₄ : ∀ {k n} → k < n → suc (n ∸ suc k) ≡ suc n ∸ suc k\n lemma₄ k 0 -}\nmodule Susp^Stable {i} (X : Ptd i) (cX : is-connected ⟨0⟩ (fst X))\n (n : ℕ) (k : ℕ) (tk : k ≠ 0) (tsk : S k ≠ 0) (kle : k ≤ n *2) where\n\n private\n lemma : ∀ {i} (C : (n : ℕ) → n ≠ 0 → S n ≠ 0 → Type i)\n → ((n : ℕ) (tsn : S n ≠ 0) (tssn : S (S n) ≠ 0)\n → C (S n) tsn tssn)\n → ((n : ℕ) (tn : n ≠ 0) (tsn : S n ≠ 0)\n → C n tn tsn)\n lemma C f O tn _ = ⊥-rec (tn idp)\n lemma C f (S n) tsn tssn = f n tsn tssn\n\n abstract\n stable : π (S k) tsk (⊙Susp^ (S n) X) == π k tk (⊙Susp^ n X)\n stable = lemma\n (λ r tr tsr → (r ≤ n *2) →\n π (S r) tsr (⊙Susp^ (S n) X) == π r tr (⊙Susp^ n X))\n (λ r' tsr' tssr' → λ rle →\n Susp^StableSucc.stable X cX n r' rle tsr' tssr')\n k tk tsk kle\n", "meta": {"hexsha": "8037cba0a161b226e3a77818260f117c71661e76", "size": 2502, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "homotopy/IterSuspensionStable.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": "homotopy/IterSuspensionStable.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": "homotopy/IterSuspensionStable.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": 33.8108108108, "max_line_length": 74, "alphanum_fraction": 0.4512390088, "num_tokens": 1170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942377652497, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5893061222142526}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lists where every pair of elements are related (symmetrically)\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel)\n\nmodule Data.List.Relation.Unary.AllPairs\n {a ℓ} {A : Set a} {R : Rel 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 (_⊔_)\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)\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Nullary.Product using (_×-dec_)\n\n------------------------------------------------------------------------\n-- Definition\n\nopen import Data.List.Relation.Unary.AllPairs.Core public\n\n------------------------------------------------------------------------\n-- Operations\n\nhead : ∀ {x xs} → AllPairs R (x ∷ xs) → All (R x) xs\nhead (px ∷ pxs) = px\n\ntail : ∀ {x xs} → AllPairs R (x ∷ xs) → AllPairs R xs\ntail (px ∷ pxs) = pxs\n\nuncons : ∀ {x xs} → AllPairs R (x ∷ xs) → All (R x) xs × AllPairs R xs\nuncons = < head , tail >\n\nmodule _ {q} {S : Rel A q} where\n\n map : R ⇒ S → AllPairs R ⊆ AllPairs S\n map ~₁⇒~₂ [] = []\n map ~₁⇒~₂ (x~xs ∷ pxs) = All.map ~₁⇒~₂ x~xs ∷ (map ~₁⇒~₂ pxs)\n\nmodule _ {s t} {S : Rel A s} {T : Rel A t} where\n\n zipWith : R ∩ᵇ S ⇒ T → AllPairs R ∩ᵘ AllPairs S ⊆ AllPairs T\n zipWith f ([] , []) = []\n zipWith f (px ∷ pxs , qx ∷ qxs) = All.zipWith f (px , qx) ∷ zipWith f (pxs , qxs)\n\n unzipWith : T ⇒ R ∩ᵇ S → AllPairs T ⊆ AllPairs R ∩ᵘ AllPairs S\n unzipWith f [] = [] , []\n unzipWith f (rx ∷ rxs) = Prod.zip _∷_ _∷_ (All.unzipWith f rx) (unzipWith f rxs)\n\nmodule _ {s} {S : Rel A s} where\n\n zip : AllPairs R ∩ᵘ AllPairs S ⊆ AllPairs (R ∩ᵇ S)\n zip = zipWith id\n\n unzip : AllPairs (R ∩ᵇ S) ⊆ AllPairs R ∩ᵘ AllPairs S\n unzip = unzipWith id\n\n------------------------------------------------------------------------\n-- Properties of predicates preserved by AllPairs\n\nallPairs? : B.Decidable R → U.Decidable (AllPairs R)\nallPairs? R? [] = yes []\nallPairs? R? (x ∷ xs) =\n Dec.map′ (uncurry _∷_) uncons (All.all (R? x) xs ×-dec allPairs? R? xs)\n\nirrelevant : B.Irrelevant R → U.Irrelevant (AllPairs R)\nirrelevant irr [] [] = refl\nirrelevant irr (px₁ ∷ pxs₁) (px₂ ∷ pxs₂) =\n cong₂ _∷_ (All.irrelevant irr px₁ px₂) (irrelevant irr pxs₁ pxs₂)\n\nsatisfiable : U.Satisfiable (AllPairs R)\nsatisfiable = [] , []\n", "meta": {"hexsha": "31d0b7fb9d7a9680187d82108ac74af9cbca9a60", "size": 2878, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/AllPairs.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.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.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.6746987952, "max_line_length": 83, "alphanum_fraction": 0.5566365532, "num_tokens": 917, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.5892963399957165}} {"text": "\nmodule Control.Monad.Reader where\n\nopen import Prelude\nopen import Control.Monad.Zero\nopen import Control.Monad.Identity\nopen import Control.Monad.Transformer\n\nrecord ReaderT {a} (R : Set a) (M : Set a → Set a) (A : Set a) : Set a where\n no-eta-equality\n constructor readerT\n field runReaderT : R → M A\n\nopen ReaderT public\n\nmodule _ {a} {R : Set a} {M : Set a → Set a} where\n\n instance\n FunctorReaderT : {{_ : Functor M}} → Functor {a = a} (ReaderT R M)\n runReaderT (fmap {{ FunctorReaderT }} f m) r = f <$> runReaderT m r\n\n FunctorZeroReaderT : {{_ : FunctorZero M}} → FunctorZero {a = a} (ReaderT R M)\n runReaderT (empty {{FunctorZeroReaderT}}) r = empty\n\n AlternativeReaderT : {{_ : Alternative M}} → Alternative {a = a} (ReaderT R M)\n runReaderT (_<|>_ {{AlternativeReaderT}} x y) r = runReaderT x r <|> runReaderT y r\n\n module _ {{_ : Monad M}} where\n\n private\n bindReaderT : ∀ {A B} → ReaderT R M A → (A → ReaderT R M B) → ReaderT R M B\n runReaderT (bindReaderT m f) r = runReaderT m r >>= λ x → runReaderT (f x) r\n\n instance\n ApplicativeReaderT : Applicative {a = a} (ReaderT R M)\n runReaderT (pure {{ApplicativeReaderT}} x) r = pure x\n _<*>_ {{ApplicativeReaderT}} = monadAp bindReaderT\n\n MonadReaderT : Monad {a = a} (ReaderT R M)\n _>>=_ {{MonadReaderT}} = bindReaderT\n\n liftReaderT : {A : Set a} → M A → ReaderT R M A\n runReaderT (liftReaderT m) r = m\n\n asks : {A : Set a} → (R → A) → ReaderT R M A\n runReaderT (asks f) r = return (f r)\n\n ask : ReaderT R M R\n ask = asks id\n\n local : {A : Set a} → (R → R) → ReaderT R M A → ReaderT R M A\n runReaderT (local f m) r = runReaderT m (f r)\n\ninstance\n TransformerReaderT : ∀ {a} {R : Set a} → Transformer (ReaderT R)\n lift {{TransformerReaderT}} = liftReaderT\n\nReader : ∀ {a} (R : Set a) (A : Set a) → Set a\nReader R = ReaderT R Identity\n\nrunReader : ∀ {a} {R : Set a} {A : Set a} → Reader R A → R → A\nrunReader m r = runIdentity (runReaderT m r)\n", "meta": {"hexsha": "ed9d8c08c13764fa0a4a4013c8bd292500bd22fa", "size": 1994, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Monad/Reader.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/Control/Monad/Reader.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/Control/Monad/Reader.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.6507936508, "max_line_length": 87, "alphanum_fraction": 0.6208625878, "num_tokens": 676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430520409022, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5892963319198612}} {"text": "------------------------------------------------------------------------------\n-- First-order logic (without equality)\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- This module is re-exported by the \"base\" modules whose theories are\n-- defined on first-order logic (without equality).\n\n-- The logical connectives are hard-coded in our translation, i.e. the\n-- symbols ⊥, ⊤, ¬, ∧, ∨, → and ↔ must be used.\n--\n-- N.B. For the implication we use the Agda function type.\n--\n-- N.B For the universal quantifier we use the Agda (dependent)\n-- function type.\n\nmodule Common.FOL.FOL where\n\ninfixr 4 _,_\ninfix 3 ¬_\ninfixr 2 _∧_\ninfix 2 ∃\ninfixr 1 _∨_\ninfixr 0 _↔_\n\n----------------------------------------------------------------------------\n-- The universe of discourse/universal domain.\npostulate D : Set\n\n------------------------------------------------------------------------------\n-- The conjunction data type.\n\n-- It is not necessary to add the data constructor _,_ as an\n-- axiom because the ATPs implement it.\ndata _∧_ (A B : Set) : Set where\n _,_ : A → B → A ∧ B\n\n-- It is not strictly necessary define the projections ∧-proj₁ and\n-- ∧-proj₂ because the ATPs implement them. For the same reason, it is\n-- not necessary to add them as (general/local) hints.\n∧-proj₁ : ∀ {A B} → A ∧ B → A\n∧-proj₁ (a , _) = a\n\n∧-proj₂ : ∀ {A B} → A ∧ B → B\n∧-proj₂ (_ , b) = b\n\n-----------------------------------------------------------------------------\n-- The disjunction data type.\n\n-- It is not necessary to add the data constructors inj₁ and inj₂ as\n-- axioms because the ATPs implement them.\ndata _∨_ (A B : Set) : Set where\n inj₁ : A → A ∨ B\n inj₂ : B → A ∨ B\n\n-- It is not strictly necessary define the eliminator `case` because\n-- the ATPs implement it. For the same reason, it is not necessary to\n-- add it as a (general/local) hint.\ncase : ∀ {A B} → {C : Set} → (A → C) → (B → C) → A ∨ B → C\ncase f g (inj₁ a) = f a\ncase f g (inj₂ b) = g b\n\n------------------------------------------------------------------------------\n-- The empty type.\ndata ⊥ : Set where\n\n⊥-elim : {A : Set} → ⊥ → A\n⊥-elim ()\n\n------------------------------------------------------------------------------\n-- The unit type.\n-- N.B. The name of this type is \"\\top\", not T.\ndata ⊤ : Set where\n tt : ⊤\n\n------------------------------------------------------------------------------\n-- Negation.\n\n-- The underscore allows to write for example '¬ ¬ A' instead of '¬ (¬ A)'.\n\n-- We do not add a definition because: i) the definition of negation\n-- is not a FOL-definition and ii) the translation of the neagation is\n-- hard-coded in Apia.\n\n¬_ : Set → Set\n¬ A = A → ⊥\n\n------------------------------------------------------------------------------\n-- Biconditional.\n\n-- We do not add a definition because: i) the definition of the\n-- biconditional is not a FOL-definition, ii) the translation of the\n-- biconditional is hard-coded in Apia.\n\n_↔_ : Set → Set → Set\nA ↔ B = (A → B) ∧ (B → A)\n\n------------------------------------------------------------------------------\n-- The existential quantifier type on D.\ndata ∃ (A : D → Set) : Set where\n _,_ : (t : D) → A t → ∃ A\n\n-- Sugar syntax for the existential quantifier.\nsyntax ∃ (λ x → e) = ∃[ x ] e\n\n-- 2012-03-05: We avoid to use the existential elimination or the\n-- existential projections because we use pattern matching (and the\n-- Agda's with constructor).\n\n-- The existential elimination.\n--\n-- NB. We do not use the usual type theory elimination with two\n-- projections because we are working in first-order logic where we do\n-- not need extract a witness from an existence proof.\n-- ∃-elim : {A : D → Set}{B : Set} → ∃ A → (∀ {x} → A x → B) → B\n-- ∃-elim (_ , Ax) h = h Ax\n\n-- The existential proyections.\n-- ∃-proj₁ : ∀ {A} → ∃ A → D\n-- ∃-proj₁ (x , _) = x\n\n-- ∃-proj₂ : ∀ {A} → (h : ∃ A) → A (∃-proj₁ h)\n-- ∃-proj₂ (_ , Ax) = Ax\n\n------------------------------------------------------------------------------\n-- Properties\n\n→-trans : {A B C : Set} → (A → B) → (B → C) → A → C\n→-trans f g a = g (f a)\n", "meta": {"hexsha": "2883f938b3b6cfd4a3d2e2d0ca131082616a2230", "size": 4235, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/Common/FOL/FOL.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/Common/FOL/FOL.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/Common/FOL/FOL.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.6044776119, "max_line_length": 78, "alphanum_fraction": 0.492798111, "num_tokens": 1129, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355188, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.5892899907726986}} {"text": "{-# OPTIONS --type-in-type #-}\n\ndata IBool : Set where\n itrue ifalse : IBool\n\nBool : Set; Bool\n = (B : Set) → B → B → B\n\ntoIBool : Bool → IBool\ntoIBool b = b _ itrue ifalse\n\ntrue : Bool; true\n = λ B t f → t\n\nand : Bool → Bool → Bool; and\n = λ a b B t f → a B (b B t f) f\n\nNat : Set; Nat\n = (n : Set) → (n → n) → n → n\n\nadd : Nat → Nat → Nat; add\n = λ a b n s z → a n s (b n s z)\n\nmul : Nat → Nat → Nat; mul\n = λ a b n s → a n (b n s)\n\nsuc : Nat → Nat; suc\n = λ a n s z → s (a n s z)\n\nEq : {A : Set} → A → A → Set\nEq {A} x y = (P : A → Set) → P x → P y\n\nrefl : {A : Set}{x : A} → Eq {A} x x; refl\n = λ P px → px\n\nn2 : Nat; n2 = λ N s z → s (s z)\nn3 : Nat; n3 = λ N s z → s (s (s z))\nn4 : Nat; n4 = λ N s z → s (s (s (s z)))\nn5 : Nat; n5 = λ N s z → s (s (s (s (s z))))\nn10 = mul n2 n5\nn10b = mul n5 n2\nn15 = add n10 n5\nn15b = add n10b n5\nn18 = add n15 n3\nn18b = add n15b n3\nn19 = add n15 n4\nn19b = add n15b n4\nn20 = mul n2 n10\nn20b = mul n2 n10b\nn21 = suc n20\nn21b = suc n20b\nn22 = suc n21\nn22b = suc n21b\nn23 = suc n22\nn23b = suc n22b\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\nn5M = mul n1M n5\nn5Mb = mul n1Mb n5\nn10M = mul n5M n2\nn10Mb = mul n5Mb n2\n\nTree : Set; Tree = (T : Set) → (T → T → T) → T → T\nleaf : Tree; leaf = λ T n l → l\nnode : Tree → Tree → Tree; node = λ t1 t2 T n l → n (t1 T n l) (t2 T n l)\n\nfullTree : Nat → Tree; fullTree\n = λ n → n Tree (λ t → node t t) leaf\n\n-- full tree with given trees at bottom level\nfullTreeWithLeaf : Tree → Nat → Tree; fullTreeWithLeaf\n = λ bottom n → n Tree (λ t → node t t) bottom\n\nforceTree : Tree → Bool; forceTree\n = λ t → t Bool and true\n\nt15 = fullTree n15\nt15b = fullTree n15b\nt18 = fullTree n18\nt18b = fullTree n18b\nt19 = fullTree n19\nt19b = fullTree n19b\nt20 = fullTree n20\nt20b = fullTree n20b\nt21 = fullTree n21\nt21b = fullTree n21b\nt22 = fullTree n22\nt22b = fullTree n22b\nt23 = fullTree n23\nt23b = fullTree n23b\n\n-- Nat conversion\n--------------------------------------------------------------------------------\n\n-- convn1M : Eq n1M n1Mb; convn1M = refl\n-- convn5M : Eq n5M n5Mb; convn5M = refl\n-- convn10M : Eq n10M n10Mb; convn10M = refl\n\n-- Full tree conversion\n--------------------------------------------------------------------------------\n\n-- convt15 : Eq t15 t15b; convt15 = refl -- 16 ms\n-- convt18 : Eq t18 t18b; convt18 = refl -- 20 ms\n-- convt19 : Eq t19 t19b; convt19 = refl -- 30 ms\n-- convt20 : Eq t20 t20b; convt20 = refl -- 1.7 s\n-- convt21 : Eq t21 t21b; convt21 = refl -- 3.4 s\n-- convt22 : Eq t22 t22b; convt22 = refl -- 6.6 s\n-- convt23 : Eq t23 t23b; convt23 = refl -- 13.1 s\n\n-- Full meta-containing tree conversion\n--------------------------------------------------------------------------------\n\n-- convmt15 : Eq t15b (fullTreeWithLeaf _ n15 ); convmt15 = refl --\n-- convmt18 : Eq t18b (fullTreeWithLeaf _ n18 ); convmt18 = refl --\n-- convmt19 : Eq t19b (fullTreeWithLeaf _ n19 ); convmt19 = refl --\n-- convmt20 : Eq t20b (fullTreeWithLeaf _ n20 ); convmt20 = refl --\n-- convmt21 : Eq t21b (fullTreeWithLeaf _ n21 ); convmt21 = refl\n-- convmt22 : Eq t22b (fullTreeWithLeaf _ n22 ); convmt22 = refl\n-- convmt23 : Eq t23b (fullTreeWithLeaf _ n23 ); convmt23 = refl\n\n-- Full tree forcing\n--------------------------------------------------------------------------------\n\n-- forcet15 : Eq (toIBool (forceTree t15)) itrue; forcet15 = refl -- 50 ms\n-- forcet18 : Eq (toIBool (forceTree t18)) itrue; forcet18 = refl -- 450 ms\n-- forcet19 : Eq (toIBool (forceTree t19)) itrue; forcet19 = refl -- 900 ms\n-- forcet20 : Eq (toIBool (forceTree t20)) itrue; forcet20 = refl -- 1.75 s\n-- forcet21 : Eq (toIBool (forceTree t21)) itrue; forcet21 = refl -- 3.5 s\n-- forcet22 : Eq (toIBool (forceTree t22)) itrue; forcet22 = refl -- 7.5 s\n-- forcet23 : Eq (toIBool (forceTree t23)) itrue; forcet23 = refl -- 15 s\n", "meta": {"hexsha": "44e434184168326d20ef6e47cb8bda38e330ae19", "size": 4025, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "bench/conv_eval.agda", "max_stars_repo_name": "int-index/smalltt", "max_stars_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 377, "max_stars_repo_stars_event_min_datetime": "2017-11-26T16:57:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T21:31:01.000Z", "max_issues_repo_path": "bench/conv_eval.agda", "max_issues_repo_name": "int-index/smalltt", "max_issues_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-03-16T09:14:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T21:51:10.000Z", "max_forks_repo_path": "bench/conv_eval.agda", "max_forks_repo_name": "int-index/smalltt", "max_forks_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2018-12-05T21:11:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T19:46:54.000Z", "avg_line_length": 29.3795620438, "max_line_length": 80, "alphanum_fraction": 0.5542857143, "num_tokens": 1624, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.5892233620073764}} {"text": "-- In a mutual block, either all or none must have a MEASURE declaration.\n\nmodule _ where\n\nopen import Common.Prelude\n\nmutual\n\n {-# MEASURE n #-}\n f : (n : Nat) → Nat\n f zero = zero\n f (suc n) = g n\n\n {-# MEASURE n #-}\n g : (n : Nat) → Nat\n g zero = zero\n g (suc n) = suc (f n)\n\n\n", "meta": {"hexsha": "0fa05b7e8cf45373d3e3c54ab6f18958b70d47f4", "size": 288, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/MeasureMutual.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": "test/succeed/MeasureMutual.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/MeasureMutual.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": 14.4, "max_line_length": 73, "alphanum_fraction": 0.5694444444, "num_tokens": 102, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.5892233589168805}} {"text": "module Function.Proofs where\n\nimport Lvl\nopen import Logic\nopen import Logic.Classical\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Logic.Predicate\nopen import Functional\nopen import Function.Inverseᵣ\nopen import Function.Names using (_⊜_)\nopen import Structure.Setoid using (Equiv) renaming (_≡_ to _≡ₛ_)\nopen import Structure.Setoid.Uniqueness\nopen import Structure.Relator.Properties\nopen import Structure.Relator\nopen import Structure.Function.Domain\nopen import Structure.Function.Domain.Proofs\nopen import Structure.Function\nopen import Structure.Operator\nopen import Syntax.Transitivity\nopen import Type\nopen import Type.Properties.Empty\n\nprivate variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓₗ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₒ₅ ℓₒ₆ ℓₒ₇ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ ℓₑ₅ ℓₑ₆ ℓₑ₇ : Lvl.Level\n\nmodule _ {T : Type{ℓₒ}} ⦃ eq : Equiv{ℓₑ}(T) ⦄ where\n instance\n -- Identity function is a function.\n id-function : Function(id)\n Function.congruence(id-function) = id\n\n instance\n -- Identity function is injective.\n id-injective : Injective(id)\n Injective.proof(id-injective) = id\n\n instance\n -- Identity function is surjective.\n id-surjective : Surjective(id)\n Surjective.proof(id-surjective) {y} = [∃]-intro (y) ⦃ reflexivity(_≡ₛ_) ⦄\n\n instance\n -- Identity function is bijective.\n id-bijective : Bijective(id)\n id-bijective = injective-surjective-to-bijective(id)\n\n instance\n id-idempotent : Idempotent(id)\n id-idempotent = intro(reflexivity _)\n\n instance\n id-involution : Involution(id)\n id-involution = intro(reflexivity _)\n\n instance\n id-inverseₗ : Inverseₗ(id)(id)\n id-inverseₗ = intro(reflexivity _)\n\n instance\n id-inverseᵣ : Inverseᵣ(id)(id)\n id-inverseᵣ = intro(reflexivity _)\n\n instance\n id-inverse : Inverse(id)(id)\n id-inverse = [∧]-intro id-inverseₗ id-inverseᵣ\n\nmodule _ {A : Type{ℓₒ₁}} ⦃ eq-a : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ eq-b : Equiv{ℓₑ₂}(B) ⦄ where\n instance\n -- Constant functions are functions.\n const-function : ∀{c : B} → Function {A = A}{B = B} (const(c))\n Function.congruence(const-function) _ = reflexivity(_≡ₛ_)\n\n instance\n -- Constant functions are constant.\n const-constant : ∀{c : B} → Constant {A = A}{B = B} (const(c))\n Constant.proof const-constant = reflexivity(_≡ₛ_)\n\nmodule _ {A : Type{ℓₒ₁}} ⦃ eq-a : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ eq-b : Equiv{ℓₑ₂}(B) ⦄ where\n open import Function.Equals\n open import Function.Equals.Proofs\n\n -- The constant function is extensionally a function.\n instance\n const-function-function : ∀{c : B} → Function {A = B}{B = A → B} const\n Function.congruence const-function-function = [⊜]-abstract\n\nmodule _ {a : Type{ℓₒ₁}}{b : Type{ℓₒ₂}}{c : Type{ℓₒ₃}}{d : Type{ℓₒ₄}} ⦃ _ : Equiv{ℓₑ}(a → d) ⦄ where\n -- Function composition is associative.\n [∘]-associativity : ∀{f : c → d}{g : b → c}{h : a → b} → ((f ∘ (g ∘ h)) ≡ₛ ((f ∘ g) ∘ h))\n [∘]-associativity = reflexivity(_≡ₛ_)\n\nmodule _ {a : Type{ℓₒ₁}}{b : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ}(a → b) ⦄ {f : a → b} where\n -- Function composition has left identity element.\n [∘]-identityₗ : (id ∘ f ≡ₛ f)\n [∘]-identityₗ = reflexivity(_≡ₛ_)\n\n -- Function composition has right identity element.\n [∘]-identityᵣ : (f ∘ id ≡ₛ f)\n [∘]-identityᵣ = reflexivity(_≡ₛ_)\n\nmodule _ {a : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₑ₁}(a) ⦄ {b : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(b) ⦄ {c : Type{ℓₒ₃}} ⦃ _ : Equiv{ℓₑ₃}(c) ⦄ where\n -- The composition of injective functions is injective.\n -- Source: https://math.stackexchange.com/questions/2049511/is-the-composition-of-two-injective-functions-injective/2049521\n -- Alternative proof: [∘]-associativity {f⁻¹}{g⁻¹}{g}{f} becomes id by inverseₗ-value injective equivalence\n [∘]-injective : ∀{f : b → c}{g : a → b} → ⦃ inj-f : Injective(f) ⦄ → ⦃ inj-g : Injective(g) ⦄ → Injective(f ∘ g)\n Injective.proof([∘]-injective {f = f}{g = g} ⦃ inj-f ⦄ ⦃ inj-g ⦄ ) {x₁}{x₂} = (injective(g) ⦃ inj-g ⦄ {x₁} {x₂}) ∘ (injective(f) ⦃ inj-f ⦄ {g(x₁)} {g(x₂)})\n\n -- RHS of composition is injective if the composition is injective.\n [∘]-injective-elim : ∀{f : b → c} → ⦃ func-f : Function(f) ⦄ → ∀{g : a → b} → ⦃ inj-fg : Injective(f ∘ g) ⦄ → Injective(g)\n Injective.proof([∘]-injective-elim {f = f}{g = g} ⦃ inj-fg ⦄) {x₁}{x₂} (gx₁gx₂) = injective(f ∘ g) ⦃ inj-fg ⦄ {x₁} {x₂} (congruence₁(f) (gx₁gx₂))\n\nmodule _ {a : Type{ℓₒ₁}} {b : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(b) ⦄ {c : Type{ℓₒ₃}} ⦃ _ : Equiv{ℓₑ₃}(c) ⦄ where\n -- The composition of surjective functions is surjective.\n [∘]-surjective : ∀{f : b → c} → ⦃ func-f : Function(f) ⦄ → ∀{g : a → b} → ⦃ surj-f : Surjective(f) ⦄ → ⦃ surj-g : Surjective(g) ⦄ → Surjective(f ∘ g)\n Surjective.proof([∘]-surjective {f = f}{g = g}) {y}\n with [∃]-intro (a) ⦃ fa≡y ⦄ ← surjective(f) {y}\n with [∃]-intro (x) ⦃ gx≡a ⦄ ← surjective(g) {a}\n = [∃]-intro (x) ⦃ congruence₁(f) gx≡a 🝖 fa≡y ⦄\n\n -- LHS of composition is surjective if the composition is surjective.\n [∘]-surjective-elim : ∀{f : b → c}{g : a → b} → ⦃ _ : Surjective(f ∘ g) ⦄ → Surjective(f)\n Surjective.proof([∘]-surjective-elim {f = f}{g = g}) {y} with (surjective(f ∘ g) {y})\n ... | [∃]-intro (x) ⦃ fgx≡y ⦄ = [∃]-intro (g(x)) ⦃ fgx≡y ⦄\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 -- Bijective functions are closed under function composition.\n -- The composition of bijective functions is bijective.\n [∘]-bijective : ∀{f : b → c} → ⦃ func-f : Function(f) ⦄ → ∀{g : a → b} → ⦃ bij-f : Bijective(f) ⦄ → ⦃ bij-g : Bijective(g) ⦄ → Bijective(f ∘ g)\n [∘]-bijective {f = f} {g = g} =\n injective-surjective-to-bijective(f ∘ g)\n ⦃ [∘]-injective\n ⦃ inj-f = bijective-to-injective(f) ⦄\n ⦃ inj-g = bijective-to-injective(g) ⦄\n ⦄\n ⦃ [∘]-surjective\n ⦃ surj-f = bijective-to-surjective(f) ⦄\n ⦃ surj-g = bijective-to-surjective(g) ⦄\n ⦄\n\n [∘]-inverseᵣ : ∀{f : b → c} ⦃ func-f : Function(f) ⦄ {f⁻¹ : b ← c}{g : a → b}{g⁻¹ : a ← b} → ⦃ inv-f : Inverseᵣ(f)(f⁻¹) ⦄ ⦃ inv-g : Inverseᵣ(g)(g⁻¹) ⦄ → Inverseᵣ(f ∘ g)(g⁻¹ ∘ f⁻¹)\n Inverseᵣ.proof ([∘]-inverseᵣ {f} {f⁻¹} {g} {g⁻¹}) {x} =\n ((f ∘ g) ∘ (g⁻¹ ∘ f⁻¹))(x) 🝖[ _≡ₛ_ ]-[]\n (f ∘ ((g ∘ g⁻¹) ∘ f⁻¹))(x) 🝖[ _≡ₛ_ ]-[ congruence₁(f) (inverseᵣ(g)(g⁻¹)) ]\n (f ∘ (id ∘ f⁻¹))(x) 🝖[ _≡ₛ_ ]-[]\n (f ∘ f⁻¹)(x) 🝖[ _≡ₛ_ ]-[ inverseᵣ(f)(f⁻¹) ]\n x 🝖-end\n\n -- The composition of functions is a function.\n [∘]-function : ∀{f : b → c}{g : a → b} → ⦃ func-f : Function(f) ⦄ → ⦃ func-g : Function(g) ⦄ → Function(f ∘ g)\n Function.congruence([∘]-function {f = f}{g = g}) = congruence₁(f) ∘ congruence₁(g)\n\nmodule _\n {a₁ : Type{ℓₒ₁}} ⦃ equiv-a₁ : Equiv{ℓₑ₁}(a₁) ⦄\n {b₁ : Type{ℓₒ₂}} ⦃ equiv-b₁ : Equiv{ℓₑ₂}(b₁) ⦄\n {a₂ : Type{ℓₒ₃}} ⦃ equiv-a₂ : Equiv{ℓₑ₃}(a₂) ⦄\n {b₂ : Type{ℓₒ₄}} ⦃ equiv-b₂ : Equiv{ℓₑ₄}(b₂) ⦄\n {c : Type{ℓₒ₅}} ⦃ equiv-c : Equiv{ℓₑ₅}(c) ⦄\n {f : a₂ → b₂ → c} ⦃ func-f : BinaryOperator(f) ⦄\n {g : a₁ → b₁ → a₂} ⦃ func-g : BinaryOperator(g) ⦄\n {h : a₁ → b₁ → b₂} ⦃ func-h : BinaryOperator(h) ⦄\n where\n\n [∘]-binaryOperator : BinaryOperator(x ↦ y ↦ f(g x y)(h x y))\n BinaryOperator.congruence [∘]-binaryOperator xy1 xy2 = congruence₂(f) (congruence₂(g) xy1 xy2) (congruence₂(h) xy1 xy2)\n\nmodule _\n {a : Type{ℓₒ₁}} ⦃ equiv-a : Equiv{ℓₑ₁}(a) ⦄\n {b : Type{ℓₒ₂}} ⦃ equiv-b : Equiv{ℓₑ₂}(b) ⦄\n {f : a → a → b} ⦃ func-f : BinaryOperator(f) ⦄\n where\n\n [$₂]-function : Function(f $₂_)\n Function.congruence [$₂]-function = congruence₂(f) $₂_\n\nmodule _ {X : Type{ℓ₁}} {Y : Type{ℓ₂}} {Z : Type{ℓ₃}} where\n swap-involution : ⦃ _ : Equiv{ℓₑ}(X → Y → Z) ⦄ → ∀{f : X → Y → Z} → (swap(swap(f)) ≡ₛ f)\n swap-involution = reflexivity(_≡ₛ_)\n\n swap-involution-fn : ⦃ _ : Equiv{ℓₑ}((X → Y → Z) → (X → Y → Z)) ⦄ → (swap ∘ swap ≡ₛ id {T = X → Y → Z})\n swap-involution-fn = reflexivity(_≡ₛ_)\n\n swap-binaryOperator : ⦃ _ : Equiv{ℓₑ₁}(X) ⦄ ⦃ _ : Equiv{ℓₑ₂}(Y) ⦄ ⦃ _ : Equiv{ℓₑ₃}(Z) ⦄ → ∀{_▫_ : X → Y → Z} → ⦃ _ : BinaryOperator(_▫_) ⦄ → BinaryOperator(swap(_▫_))\n BinaryOperator.congruence (swap-binaryOperator {_▫_ = _▫_} ⦃ intro p ⦄) x₁y₁ x₂y₂ = p x₂y₂ x₁y₁\n\nmodule _ {X : Type{ℓ₁}} {Y : Type{ℓ₂}} where\n s-combinator-const-id : ⦃ _ : Equiv{ℓₑ}(X → X) ⦄ → (_∘ₛ_ {X = X}{Y = Y → X}{Z = X} const const ≡ₛ id)\n s-combinator-const-id = reflexivity(_≡ₛ_)\n\nmodule _ {X : Type{ℓ₁}} {Y : Type{ℓ₂}} {Z : Type{ℓ₃}} ⦃ equiv-z : Equiv{ℓₑ₃}(Z) ⦄ where\n s-combinator-const-eq : ∀{f}{a}{b} → (_∘ₛ_{X = X}{Y = Y}{Z = Z} f (const b) a ≡ₛ f a b)\n s-combinator-const-eq = reflexivity(_≡ₛ_)\n\n{- TODO: Maybe this is unprovable because types. https://plato.stanford.edu/entries/axiom-choice/#AxiChoLog https://plato.stanford.edu/entries/axiom-choice/choice-and-type-theory.html https://en.wikipedia.org/wiki/Diaconescu%27s_theorem\nmodule _ {fn-ext : FunctionExtensionality} where\n open import Function.Names\n open import Data.Boolean\n\n function-extensionality-to-classical : ∀{P} → (P ∨ (¬ P))\n function-extensionality-to-classical{P} = where\n A : Bool → Stmt\n A(x) = (P ∨ (x ≡ 𝐹))\n\n B : Bool → Stmt\n B(x) = (P ∨ (x ≡ 𝑇))\n\n C : (Bool → Stmt) → Stmt\n C(F) = (F ⊜ A) ∨ (F ⊜ B)\n-}\n\nmodule _ {X : Type{ℓₒ₁}} ⦃ eq-x : Equiv{ℓₑ₁}(X) ⦄ {Y : Type{ℓₒ₂}} ⦃ eq-y : Equiv{ℓₑ₂}(Y) ⦄ {Z : Type{ℓₒ₃}} ⦃ eq-z : Equiv{ℓₑ₃}(Z) ⦄ where\n open import Function.Equals\n open import Function.Equals.Proofs\n\n s-combinator-injective : Injective(_∘ₛ_ {X = X}{Y = Y}{Z = Z})\n _⊜_.proof (Injective.proof s-combinator-injective {f} {g} sxsy) {x} = Function.Equals.intro(\\{a} → [⊜]-apply([⊜]-apply sxsy {const(a)}){x})\n\n s-combinator-inverseₗ : Inverseₗ(_∘ₛ_ {X = X}{Y = Y}{Z = Z})(f ↦ a ↦ b ↦ f (const b) a)\n _⊜_.proof (Inverseᵣ.proof s-combinator-inverseₗ) = reflexivity(_≡ₛ_)\n\nmodule _ {A : Type{ℓ}} ⦃ equiv-A : Equiv{ℓₑ}(A) ⦄ where\n classical-constant-endofunction-existence : ⦃ classical : Classical(A) ⦄ → ∃{Obj = A → A}(Constant)\n classical-constant-endofunction-existence with excluded-middle(A)\n ... | [∨]-introₗ a = [∃]-intro (const a)\n ... | [∨]-introᵣ na = [∃]-intro id ⦃ intro(\\{a} → [⊥]-elim(na a)) ⦄\n\nmodule _ {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where\n open import Logic.Propositional.Theorems\n open import Structure.Operator.Properties\n\n proj₂ₗ-associativity : Associativity{T = T}(proj₂ₗ)\n proj₂ₗ-associativity = intro(reflexivity(_))\n\n proj₂ᵣ-associativity : Associativity{T = T}(proj₂ᵣ)\n proj₂ᵣ-associativity = intro(reflexivity(_))\n\n proj₂ₗ-identityₗ : ∀{id : T} → Identityₗ(proj₂ₗ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))\n proj₂ₗ-identityₗ = [↔]-intro intro Identityₗ.proof\n\n proj₂ₗ-identityᵣ : ∀{id : T} → Identityᵣ(proj₂ₗ)(id)\n proj₂ₗ-identityᵣ = intro(reflexivity(_))\n\n proj₂ₗ-identity : ∀{id : T} → Identity(proj₂ₗ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))\n proj₂ₗ-identity =\n [↔]-transitivity\n ([↔]-intro (l ↦ intro ⦃ left = l ⦄ ⦃ right = proj₂ₗ-identityᵣ ⦄) Identity.left)\n proj₂ₗ-identityₗ\n\n proj₂ᵣ-identityₗ : ∀{id : T} → Identityₗ(proj₂ᵣ)(id)\n proj₂ᵣ-identityₗ = intro(reflexivity(_))\n\n proj₂ᵣ-identityᵣ : ∀{id : T} → Identityᵣ(proj₂ᵣ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))\n proj₂ᵣ-identityᵣ = [↔]-intro intro Identityᵣ.proof\n\n proj₂ᵣ-identity : ∀{id : T} → Identity(proj₂ᵣ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))\n proj₂ᵣ-identity =\n [↔]-transitivity\n ([↔]-intro (r ↦ intro ⦃ left = proj₂ᵣ-identityₗ ⦄ ⦃ right = r ⦄) Identity.right)\n proj₂ᵣ-identityᵣ\n\nmodule _ {T : Type{ℓₒ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where\n instance\n id-inversePair : InversePair{A = T}([↔]-reflexivity)\n id-inversePair = intro ⦃ left = intro(reflexivity(_≡ₛ_)) ⦄ ⦃ right = intro(reflexivity(_≡ₛ_)) ⦄\n\nmodule _\n {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n {p : A ↔ B}\n where\n\n sym-inversePair : ⦃ InversePair(p) ⦄ → InversePair([↔]-symmetry p)\n sym-inversePair = intro\n\nmodule _\n {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n {C : Type{ℓₒ₃}} ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄\n {p₁ : A ↔ B} ⦃ func-p₁ₗ : Function([↔]-to-[←] p₁) ⦄\n {p₂ : B ↔ C} ⦃ func-p₂ᵣ : Function([↔]-to-[→] p₂) ⦄\n where\n\n trans-inversePair : ⦃ inv₁ : InversePair(p₁) ⦄ → ⦃ inv₂ : InversePair(p₂) ⦄ → InversePair([↔]-transitivity p₁ p₂)\n trans-inversePair = intro ⦃ left = [∘]-inverseᵣ {f = [↔]-to-[→] p₂} ⦄ ⦃ right = [∘]-inverseᵣ {f = [↔]-to-[←] p₁} ⦄\n", "meta": {"hexsha": "82e0765b903bc30bb0b8ef0b7a3f306d1db63f87", "size": 12317, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "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": "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": "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": 42.6193771626, "max_line_length": 236, "alphanum_fraction": 0.6025006089, "num_tokens": 5588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673223709252, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.5892233556307889}} {"text": "------------------------------------------------------------------------------\n-- LTC-PCF terms 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.Base.Properties where\n\nopen import LTC-PCF.Base\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\nsuccCong : ∀ {m n} → m ≡ n → succ₁ m ≡ succ₁ n\nsuccCong refl = refl\n\npredCong : ∀ {m n} → m ≡ n → pred₁ m ≡ pred₁ n\npredCong refl = refl\n\n------------------------------------------------------------------------------\n\nS≢0 : ∀ {n} → succ₁ n ≢ zero\nS≢0 S≡0 = 0≢S (sym S≡0)\n\n-- We added Common.Relation.Binary.PropositionalEquality.cong, so this\n-- theorem is not necessary.\n-- x≡y→Sx≡Sy : ∀ {m n} → m ≡ n → succ₁ m ≡\n-- succ₁ n x≡y→Sx≡Sy refl = refl\n", "meta": {"hexsha": "cb42725ccb89e4e1ee0f6e590e1610bcc6f8d9bb", "size": 1121, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Base/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/Base/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/Base/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": 29.5, "max_line_length": 78, "alphanum_fraction": 0.409455843, "num_tokens": 305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7745833945721304, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.589187360431509}} {"text": "\nmodule _ where\n\nrecord Structure : Set1 where\n infixl 20 _×_\n infix 8 _⟶_\n infixl 20 _,_\n infixr 40 _∘_\n\n infix 5 _~_\n\n field\n Type : Set\n _×_ : Type → Type → Type\n\n _⟶_ : Type → Type → Set\n _∘_ : ∀ {X Y Z} → Y ⟶ Z → X ⟶ Y → X ⟶ Z\n _,_ : ∀ {X A B} → X ⟶ A → X ⟶ B → X ⟶ A × B\n π₁ : ∀ {A B} → A × B ⟶ A\n π₂ : ∀ {A B} → A × B ⟶ B\n Op3 : ∀ {X} → X × X × X ⟶ X\n\n _~_ : ∀ {X Y} → X ⟶ Y → X ⟶ Y → Set\n\nrecord Map {{C : Structure}} {{D : Structure}} : Set1 where\n open Structure {{...}}\n field\n Ty⟦_⟧ : Structure.Type C → Structure.Type D\n Tm⟦_⟧ : ∀ {X A} → X ⟶ A → Ty⟦ X ⟧ ⟶ Ty⟦ A ⟧\n\n ×-inv : ∀ {X A} → Ty⟦ X ⟧ × Ty⟦ A ⟧ ⟶ Ty⟦ X × A ⟧\n\n ⟦Op3⟧ : ∀ {X} → Tm⟦ Op3 {X = X} ⟧ ∘ ×-inv ∘ (×-inv ∘ (π₁ ∘ π₁ , π₂ ∘ π₁) , π₂) ~ Op3\n", "meta": {"hexsha": "0d1dd1d921c8d0957b3eae149425ffc660d8ec8e", "size": 769, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1952.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/Issue1952.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/Issue1952.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.6176470588, "max_line_length": 88, "alphanum_fraction": 0.4187256177, "num_tokens": 391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.894789457685656, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.5891450502532695}} {"text": "open import Level hiding ( suc ; zero )\nopen import Algebra\nmodule sym3n 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\n\nsym3solvable : solvable (Symmetric 3)\nsolvable.dervied-length sym3solvable = 2\nsolvable.end sym3solvable x d = solved1 x d where\n\n open import Data.List using ( List ; [] ; _∷_ )\n\n open Solvable (Symmetric 3)\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 ) :: f0))) =p= pid\n p0id = pleq _ _ refl\n\n open import Data.List.Fresh.Relation.Unary.Any\n open import FLComm\n\n stage3FList : CommFListN 3 2 ≡ cons (zero :: zero :: zero :: f0) [] (Level.lift tt)\n stage3FList = refl\n\n solved1 : (x : Permutation 3 3) → deriving 2 x → x =p= pid\n solved1 x dr = CommSolved 3 x ( CommFListN 3 2 ) stage3FList p0id solved2 where\n solved2 : Any (perm→FL x ≡_) ( CommFListN 3 2 )\n solved2 = CommStage→ 3 2 x dr\n\n\n", "meta": {"hexsha": "ef6192515c9400199d5c3935555a7bc70e83662b", "size": 1451, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sym3n.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/sym3n.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/sym3n.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": 27.9038461538, "max_line_length": 86, "alphanum_fraction": 0.6974500345, "num_tokens": 482, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.894789454880027, "lm_q2_score": 0.6584175005616829, "lm_q1q2_score": 0.5891450364110582}} {"text": "------------------------------------------------------------------------------\n-- The gcd is commutative\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.GCD.Total.CommutativeI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Induction.NonAcc.LexicographicI\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.Inequalities.EliminationPropertiesI\nopen import FOTC.Data.Nat.Inequalities.PropertiesI\nopen import FOTC.Data.Nat.PropertiesI\nopen import FOTC.Program.GCD.Total.ConversionRulesI\nopen import FOTC.Program.GCD.Total.GCD\n\n------------------------------------------------------------------------------\n-- Informal proof:\n-- 1. gcd 0 n = n -- gcd def\n-- = gcd n 0 -- gcd def\n\n-- 2. gcd n 0 = n -- gcd def\n-- = gcd 0 n -- gcd def\n\n-- 3.1. Case: S m > S n\n-- gcd (S m) (S n) = gcd (S m - S n) (S n) -- gcd def\n-- = gcd (S n) (S m - S n) -- IH\n-- = gcd (S n) (S m) -- gcd def\n\n-- 3.2. Case: S m ≮ S n\n-- gcd (S m) (S n) = gcd (S m) (S n - S m) -- gcd def\n-- = gcd (S n - S m) (S m) -- IH\n-- = gcd (S n) (S m) -- gcd def\n\n------------------------------------------------------------------------------\n-- Commutativity property.\nComm : D → D → Set\nComm t t' = gcd t t' ≡ gcd t' t\n{-# ATP definition Comm #-}\n\nx>y→y≯x : ∀ {m n} → N m → N n → m > n → n ≯ m\nx>y→y≯x nzero Nn 0>n = ⊥-elim (0>x→⊥ Nn 0>n)\n{-# CATCHALL #-}\nx>y→y≯x Nm nzero _ = 0≯x Nm\nx>y→y≯x (nsucc {m} Nm) (nsucc {n} Nn) Sm>Sn =\n trans (lt-SS m n) (x>y→y≯x Nm Nn (trans (sym (lt-SS n m)) Sm>Sn))\n\npostulate x≯Sy→Sy>x : ∀ {m n} → N m → N n → m ≯ succ₁ n → succ₁ n > m\n-- x≯Sy→Sy>x {n = n} nzero Nn _ = <-0S n\n-- x≯Sy→Sy>x {n = n} (nsucc {m} Nm) Nn h = {!!}\n\n------------------------------------------------------------------------------\n-- gcd 0 0 is commutative.\ngcd-00-comm : Comm zero zero\ngcd-00-comm = refl\n\n------------------------------------------------------------------------------\n-- gcd (succ₁ n) 0 is commutative.\ngcd-S0-comm : ∀ n → Comm (succ₁ n) zero\ngcd-S0-comm n = trans (gcd-S0 n) (sym (gcd-0S n))\n\n------------------------------------------------------------------------------\n-- gcd (succ₁ m) (succ₁ n) when succ₁ m > succ₁ n is commutative.\ngcd-S>S-comm : ∀ {m n} → N m → N n →\n Comm (succ₁ m ∸ succ₁ n) (succ₁ n) →\n succ₁ m > succ₁ n →\n Comm (succ₁ m) (succ₁ n)\ngcd-S>S-comm {m} {n} Nm Nn ih Sm>Sn =\n gcd (succ₁ m) (succ₁ n)\n ≡⟨ gcd-S>S m n Sm>Sn ⟩\n gcd (succ₁ m ∸ succ₁ n) (succ₁ n)\n ≡⟨ ih ⟩\n gcd (succ₁ n) (succ₁ m ∸ succ₁ n)\n ≡⟨ sym (gcd-S≯S n m (x>y→y≯x (nsucc Nm) (nsucc Nn) Sm>Sn)) ⟩\n gcd (succ₁ n) (succ₁ m) ∎\n\n------------------------------------------------------------------------------\n-- gcd (succ₁ m) (succ₁ n) when succ₁ m ≯ succ₁ n is commutative.\ngcd-S≯S-comm : ∀ {m n} → N m → N n →\n Comm (succ₁ m) (succ₁ n ∸ succ₁ m) →\n succ₁ m ≯ succ₁ n →\n Comm (succ₁ m) (succ₁ n)\ngcd-S≯S-comm {m} {n} Nm Nn ih Sm≯Sn =\n gcd (succ₁ m) (succ₁ n)\n ≡⟨ gcd-S≯S m n Sm≯Sn ⟩\n gcd (succ₁ m) (succ₁ n ∸ succ₁ m)\n ≡⟨ ih ⟩\n gcd (succ₁ n ∸ succ₁ m) (succ₁ m)\n ≡⟨ sym (gcd-S>S n m (x≯Sy→Sy>x (nsucc Nm) Nn Sm≯Sn)) ⟩\n gcd (succ₁ n) (succ₁ m) ∎\n\n------------------------------------------------------------------------------\n-- gcd m n when m > n is commutative.\ngcd-x>y-comm :\n ∀ {m n} → N m → N n →\n (∀ {o p} → N o → N p → Lexi o p m n → Comm o p) →\n m > n →\n Comm m n\ngcd-x>y-comm nzero Nn _ 0>n = ⊥-elim (0>x→⊥ Nn 0>n)\ngcd-x>y-comm (nsucc {n} _) nzero _ _ = gcd-S0-comm n\ngcd-x>y-comm (nsucc {m} Nm) (nsucc {n} Nn) ah Sm>Sn = gcd-S>S-comm Nm Nn ih Sm>Sn\n where\n -- Inductive hypothesis.\n ih : Comm (succ₁ m ∸ succ₁ n) (succ₁ n)\n ih = ah {succ₁ m ∸ succ₁ n}\n {succ₁ n}\n (∸-N (nsucc Nm) (nsucc Nn))\n (nsucc Nn)\n ([Sx∸Sy,Sy]<[Sx,Sy] Nm Nn)\n\n------------------------------------------------------------------------------\n-- gcd m n when m ≯ n is commutative.\ngcd-x≯y-comm :\n ∀ {m n} → N m → N n →\n (∀ {o p} → N o → N p → Lexi o p m n → Comm o p) →\n m ≯ n →\n Comm m n\ngcd-x≯y-comm nzero nzero _ _ = gcd-00-comm\ngcd-x≯y-comm nzero (nsucc {n} _) _ _ = sym (gcd-S0-comm n)\ngcd-x≯y-comm (nsucc _) nzero _ Sm≯0 = ⊥-elim (S≯0→⊥ Sm≯0)\ngcd-x≯y-comm (nsucc {m} Nm) (nsucc {n} Nn) ah Sm≯Sn = gcd-S≯S-comm Nm Nn ih Sm≯Sn\n where\n -- Inductive hypothesis.\n ih : Comm (succ₁ m) (succ₁ n ∸ succ₁ m)\n ih = ah {succ₁ m}\n {succ₁ n ∸ succ₁ m}\n (nsucc Nm)\n (∸-N (nsucc Nn) (nsucc Nm))\n ([Sx,Sy∸Sx]<[Sx,Sy] Nm Nn)\n\n------------------------------------------------------------------------------\n-- gcd is commutative.\ngcd-comm : ∀ {m n} → N m → N n → Comm m n\ngcd-comm = Lexi-wfind A h\n where\n A : D → D → Set\n A i j = Comm i j\n\n h : ∀ {i j} → N i → N j → (∀ {k l} → N k → N l → Lexi k l i j → A k l) →\n A i j\n h Ni Nj ah = case (gcd-x>y-comm Ni Nj ah)\n (gcd-x≯y-comm Ni Nj ah)\n (x>y∨x≯y Ni Nj)\n", "meta": {"hexsha": "2e00de36f1d93b8fb9376fef886c1ab206489fb9", "size": 5481, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Program/GCD/Total/CommutativeI.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/GCD/Total/CommutativeI.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/GCD/Total/CommutativeI.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.298013245, "max_line_length": 81, "alphanum_fraction": 0.4241926656, "num_tokens": 1964, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478256, "lm_q2_score": 0.7310585786300048, "lm_q1q2_score": 0.5889643161519321}} {"text": "module Data.List.Properties.Extra {a}{A : Set a} where\n\nopen import Data.Nat\nopen import Data.Fin hiding (_<_)\nopen import Data.List\nopen import Data.Product hiding (map)\nopen import Data.Fin using (fromℕ≤; zero; suc)\nopen import Data.List.Relation.Unary.All hiding (map; lookup; _[_]≔_)\nopen import Data.List.Relation.Unary.Any hiding (map; lookup)\nopen import Data.List.Membership.Propositional\n\nopen import Data.List.Relation.Binary.Pointwise hiding (refl; map)\nopen import Relation.Binary.PropositionalEquality\n\n∈-∷ʳ : ∀ (l : List A)(x : A) → x ∈ (l ∷ʳ x)\n∈-∷ʳ [] x = here refl\n∈-∷ʳ (x ∷ l) y = there (∈-∷ʳ l y)\n\ninfixl 10 _[_]≔_\n_[_]≔_ : (l : List A) → Fin (length l) → A → List A\n[] [ () ]≔ x\n(x ∷ xs) [ zero ]≔ x' = x' ∷ xs\n(x ∷ xs) [ suc i ]≔ y = x ∷ xs [ i ]≔ y\n\ninfixl 10 _[_]≔'_\n_[_]≔'_ : ∀ {x} → (l : List A) → x ∈ l → A → List A\n[] [ () ]≔' y\n(x ∷ l) [ here px ]≔' y = y ∷ l\n(x ∷ l) [ there px ]≔' y = x ∷ (l [ px ]≔' y)\n\n≔'-[]= : ∀ {x}{l : List A} (p : x ∈ l) → ∀ {y} → y ∈ (l [ p ]≔' y)\n≔'-[]= (here px) = here refl\n≔'-[]= (there p) = there (≔'-[]= p)\n\ndrop-prefix : ∀ (l m : List A) → drop (length l) (l ++ m) ≡ m\ndrop-prefix [] m = refl\ndrop-prefix (x ∷ l) m = drop-prefix l m\n", "meta": {"hexsha": "33efbb571ef208aa882e5a8e6f0a96c15e57f7ec", "size": 1195, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/Properties/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/List/Properties/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/List/Properties/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": 31.4473684211, "max_line_length": 69, "alphanum_fraction": 0.559832636, "num_tokens": 498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7401743677704878, "lm_q1q2_score": 0.5889257311757127}} {"text": "module RenamingAndSubstitution where\n\nopen import Library\nopen import Syntax\nopen ≡-Reasoning\n\ninfixr 4 _,_\n\n------------------------------------------------------------------------\n-- Renaming\n------------------------------------------------------------------------\n\n-- Renamings from Γ to Δ are snoc-lists of variables living in Δ,\n-- one for each entry in Γ.\n\ndata Ren (Δ : Cxt) : (Γ : Cxt) → Set where\n ε : Ren Δ ε\n _,_ : ∀ {Γ a} (ρ : Ren Δ Γ) (x : Var Δ a) → Ren Δ (Γ , a)\n\n-- A renaming in Ren Δ Γ is a code for a\n-- renaming function in Var Γ ∙→ Var Δ.\n\nlookr : ∀{Γ Δ} → Ren Δ Γ → ∀ {σ} → Var Γ σ → Var Δ σ\nlookr (xs , x) zero = x\nlookr (xs , x) (suc i) = lookr xs i\n\n-- Weaking a renaming by increasing all variables by 1.\n-- This lets them live in the extended context Γ , σ.\n\nwkr : ∀{Γ Δ σ} → Ren Γ Δ → Ren (Γ , σ) Δ\nwkr ε = ε\nwkr (xs , x) = wkr xs , suc x\n\n-- Lifting a renaming to go under a binder.\n\nliftr : ∀{Γ Δ σ} → Ren Γ Δ → Ren (Γ , σ) (Δ , σ)\nliftr xs = wkr xs , zero\n\n-- The category of renamings (operations only).\n------------------------------------------------------------------------\n\n-- The identity renaming.\n\nrenId : ∀{Γ} → Ren Γ Γ\nrenId {ε} = ε\nrenId {Γ , _} = liftr (renId {Γ})\n\n-- Forward composition of renamings.\n\nrenComp : ∀{Φ Γ Δ} → Ren Δ Γ → Ren Γ Φ → Ren Δ Φ\nrenComp xs ε = ε\nrenComp xs (ys , y) = renComp xs ys , lookr xs y\n\n-- Various combinations of renamings.\n------------------------------------------------------------------------\n\n-- Weakening a renaming acts behaves like\n-- post-composing the renaming function with successor.\n\nlookrwkr : ∀{Γ Δ σ τ}(xs : Ren Δ Γ)(i : Var Γ σ) →\n lookr (wkr {σ = τ} xs) i ≡ suc (lookr xs i)\nlookrwkr (xs , _) zero = refl\nlookrwkr (xs , _) (suc i) = lookrwkr xs i\n\n-- A weakning cancels a renaming extension.\n\nlemrr : ∀{Φ Γ Δ σ}(xs : Ren Φ Γ)(x : Var Φ σ)(ys : Ren Γ Δ) →\n renComp (xs , x) (wkr ys) ≡ renComp xs ys\nlemrr xs x ε = refl\nlemrr xs x (ys , y) = cong (_, lookr xs y) (lemrr xs x ys)\n\n-- Associativity of renaming composition in case the first\n-- renaming is a weakening.\n\nwkrcomp : ∀{Φ Γ Δ σ}(xs : Ren Φ Γ)(ys : Ren Γ Δ) →\n renComp (wkr {σ = σ} xs) ys ≡ wkr {σ = σ} (renComp xs ys)\nwkrcomp xs ε = refl\nwkrcomp xs (ys , y) = cong₂ _,_ (wkrcomp xs ys) (lookrwkr xs y)\n\n-- Composition of liftings is a lifting.\n\nliftrcomp : ∀{Φ Γ Δ σ}(xs : Ren Φ Γ)(ys : Ren Γ Δ) →\n renComp (liftr {σ = σ} xs) (liftr {σ = σ} ys) ≡ liftr {σ = σ} (renComp xs ys)\nliftrcomp xs ys = begin\n renComp (wkr xs , zero) (wkr ys) , zero ≡⟨ cong (_, zero) (lemrr (wkr xs) zero ys) ⟩\n renComp (wkr xs) ys , zero ≡⟨ cong (_, zero) (wkrcomp xs ys) ⟩\n wkr (renComp xs ys) , zero ∎\n\n-- lookr is a morphism from the category Ren\n-- to the category of the corresponding renaming functions on variables.\n------------------------------------------------------------------------\n\n-- The identity renaming corresponds to the identity function.\n\nlookrid : ∀{Γ σ}(x : Var Γ σ) → lookr renId x ≡ x\nlookrid zero = refl\nlookrid (suc x) = begin\n lookr (wkr renId) x ≡⟨ lookrwkr renId x ⟩\n suc (lookr renId x) ≡⟨ cong suc (lookrid x) ⟩\n suc x ∎\n\n-- A composition of renamings corresponds to the composition\n-- of the corresponding renaming functions.\n\nlookrcomp : ∀{Φ Γ Δ}(f : Ren Δ Γ)(g : Ren Γ Φ){σ}(i : Var Φ σ) →\n lookr (renComp f g) i ≡ (lookr f ∘ lookr g) i\nlookrcomp f (g , v) zero = refl\nlookrcomp f (g , v) (suc i) = lookrcomp f g i\n\n-- Laws for the category of renamings.\n------------------------------------------------------------------------\n\n-- Left identity of forward composition\n\nlidr : ∀{Φ Γ}(xs : Ren Φ Γ) → renComp renId xs ≡ xs\nlidr ε = refl\nlidr (xs , x) = cong₂ _,_ (lidr xs) (lookrid x)\n\n-- Right identity of forward composition\n\nridr : ∀{Φ Γ}(xs : Ren Φ Γ) → renComp xs renId ≡ xs\nridr {Γ = ε} ε = refl\nridr {Γ = Γ , σ} (xs , x) = begin\n renComp (xs , x) (wkr renId) , x ≡⟨ cong (_, x) (lemrr xs x renId) ⟩\n renComp xs renId , x ≡⟨ cong (_, x) (ridr xs) ⟩\n xs , x ∎\n\n\n-- Renaming of terms.\n------------------------------------------------------------------------\n\n-- Renaming in a term.\n\nren : ∀{Γ Δ} → Ren Δ Γ → ∀ {σ} → Tm Γ σ → Tm Δ σ\nren xs (var x) = var (lookr xs x)\nren xs (abs t) = abs (ren (liftr xs) t)\nren xs (app t u) = app (ren xs t) (ren xs u)\n\n-- ren is a morphism from Ren\n-- to the corresponding category of renaming functions on terms.\n\nrenid : ∀{Γ σ}(t : Tm Γ σ) → ren renId t ≡ t\nrenid (var x) = cong var (lookrid x)\nrenid (abs t) = cong abs (renid t)\nrenid (app t u) = cong₂ app (renid t) (renid u)\n\nrencomp : ∀ {Φ Γ Δ}(f : Ren Δ Γ)(g : Ren Γ Φ){σ}(t : Tm Φ σ) →\n ren (renComp f g) t ≡ (ren f ∘ ren g) t\nrencomp f g (var x) = cong var (lookrcomp f g x)\nrencomp f g (abs t) = begin\n abs (ren (liftr (renComp f g)) t) ≡⟨ cong (λ xs → abs $ ren xs t) (sym $ liftrcomp f g) ⟩\n abs (ren (renComp (liftr f) (liftr g)) t) ≡⟨ cong abs (rencomp (liftr f) (liftr g) t) ⟩\n abs (ren (liftr f) (ren (liftr g) t)) ∎\nrencomp f g (app t u) = cong₂ app (rencomp f g t) (rencomp f g u)\n\n-- Weakening a term.\n\nweak : ∀{Γ b} a → Tm Γ b → Tm (Γ , a) b\nweak a = ren (wkr renId)\n\n\n-- Renaming of normal forms.\n------------------------------------------------------------------------\n\nmutual\n rennf : ∀{Γ Δ} → Ren Γ Δ → ∀{a} → Nf Δ a → Nf Γ a\n rennf α (ne t) = ne (rennen α t)\n rennf α (abs t) = abs (rennf (liftr α) t)\n\n rennen : ∀{Γ Δ} → Ren Γ Δ → ∀{a} → Ne Δ a → Ne Γ a\n rennen α (var x) = var (lookr α x)\n rennen α (app n x) = app (rennen α n) (rennf α x)\n\n------------------------------------------------------------------------\n-- Substitution\n------------------------------------------------------------------------\n\ndata Sub (Δ : Cxt) : (Γ : Cxt) → Set where\n ε : Sub Δ ε\n _,_ : ∀ {Γ a} (ρ : Sub Δ Γ) (v : Tm Δ a) → Sub Δ (Γ , a)\n\nren2sub : ∀{Γ Δ} → Ren Γ Δ → Sub Γ Δ\nren2sub ε = ε\nren2sub (xs , x) = ren2sub xs , var x\n\nlooks : ∀{Γ Δ} → Sub Δ Γ → ∀ {σ} → Var Γ σ → Tm Δ σ\nlooks (xs , x) zero = x\nlooks (xs , x) (suc i) = looks xs i\n\nwks : ∀{Γ Δ σ} → Sub Γ Δ → Sub (Γ , σ) Δ\nwks ε = ε\nwks (xs , x) = wks xs , ren (wkr renId) x\n\nlifts : ∀{Γ Δ σ} → Sub Γ Δ → Sub (Γ , σ) (Δ , σ)\nlifts xs = wks xs , var zero\n\nsub : ∀{Γ Δ} → Sub Δ Γ → ∀{σ} → Tm Γ σ → Tm Δ σ\nsub xs (var x) = looks xs x\nsub xs (abs t) = abs (sub (lifts xs) t)\nsub xs (app t u) = app (sub xs t) (sub xs u)\n\nsubId : ∀{Γ} → Sub Γ Γ\nsubId {ε} = ε\nsubId {Γ , _} = lifts (subId {Γ})\n\nsubComp : ∀{Φ Γ Δ} → Sub Δ Γ → Sub Γ Φ → Sub Δ Φ\nsubComp xs ε = ε\nsubComp xs (ys , y) = subComp xs ys , sub xs y\n\n-- Substitute the last variable\n\nsub0 : ∀{Γ a b} → Tm (Γ , a) b → Tm Γ a → Tm Γ b\nsub0 t u = sub (subId , u) t\n\n-- Substitution laws\n\nlookswks : ∀{Γ Δ σ τ}(i : Var Γ σ)(xs : Sub Δ Γ) →\n looks (wks {σ = τ} xs) i ≡ ren (wkr {σ = τ} renId) (looks xs i)\nlookswks zero (xs , _) = refl\nlookswks (suc i) (xs , _) = lookswks i xs\n\nlemsr : ∀{Φ Γ Δ σ}(xs : Sub Φ Γ)(x : Tm Φ σ)(ys : Ren Γ Δ) →\n subComp (xs , x) (ren2sub (wkr ys)) ≡ subComp xs (ren2sub ys)\nlemsr xs x ε = refl\nlemsr xs x (ys , y) = cong (λ zs → zs , looks xs y) (lemsr xs x ys)\n\nlookslookr : ∀{Φ Γ Δ}(f : Sub Δ Γ)(g : Ren Γ Φ){σ}(x : Var Φ σ) →\n looks (subComp f (ren2sub g)) x ≡ looks f (lookr g x)\nlookslookr f (g , _) zero = refl\nlookslookr f (g , _) (suc x) = lookslookr f g x\n\nwksrcomp : ∀{Φ Γ Δ σ}(xs : Sub Φ Γ)(ys : Ren Γ Δ) →\n subComp (wks {σ = σ} xs) (ren2sub ys) ≡ wks {σ = σ} (subComp xs (ren2sub ys))\nwksrcomp xs ε = refl\nwksrcomp xs (ys , y) = cong₂ Sub._,_ (wksrcomp xs ys) (lookswks y xs)\n\nliftsrcomp : ∀{Φ Γ Δ σ}(xs : Sub Φ Γ)(ys : Ren Γ Δ) →\n subComp (lifts {σ = σ} xs) (ren2sub (liftr ys)) ≡ lifts {σ = σ} (subComp xs (ren2sub ys))\nliftsrcomp xs ys = begin\n subComp (wks xs , var zero) (ren2sub (wkr ys)) , var zero ≡⟨ cong (_, var zero) (lemsr (wks xs) (var zero) ys) ⟩\n subComp (wks xs) (ren2sub ys) , var zero ≡⟨ cong (_, var zero) (wksrcomp xs ys) ⟩\n wks (subComp xs (ren2sub ys)) , var zero ∎\n\nsubren : ∀{Φ Γ Δ}(f : Sub Δ Γ)(g : Ren Γ Φ){σ}(t : Tm Φ σ) →\n (sub f ∘ ren g) t ≡ sub (subComp f (ren2sub g)) t\nsubren f g (var x) = sym $ lookslookr f g x\nsubren f g (abs t) = begin\n abs (sub (lifts f) (ren (liftr g) t)) ≡⟨ cong abs $ subren (lifts f) (liftr g) t ⟩\n abs (sub (subComp (lifts f) (ren2sub (liftr g))) t) ≡⟨ cong (λ f → abs (sub f t)) $ liftsrcomp f g ⟩\n abs (sub (lifts (subComp f (ren2sub g))) t) ∎\nsubren f g (app t u) = cong₂ app (subren f g t) (subren f g u)\n\nlooksid : ∀{Γ σ}(x : Var Γ σ) → looks subId x ≡ var x\nlooksid zero = refl\nlooksid (suc x) = begin\n looks (wks subId) x ≡⟨ lookswks x subId ⟩\n ren (wkr renId) (looks subId x) ≡⟨ cong (ren (wkr renId)) (looksid x) ⟩\n ren (wkr renId) (var x) ≡⟨⟩\n var (lookr (wkr renId) x) ≡⟨ cong var $ lookrwkr renId x ⟩\n var (suc (lookr renId x)) ≡⟨ cong (λ x → var (suc x)) (lookrid x) ⟩ -- using ∘ makes it go yellow\n var (suc x) ∎\n\nsubid : ∀{Γ σ}(t : Tm Γ σ) → sub subId t ≡ t\nsubid (var x) = looksid x\nsubid (abs t) = cong abs (subid t)\nsubid (app t u) = cong₂ app (subid t) (subid u)\n\nsidl : ∀{Φ Γ}(xs : Sub Φ Γ) → subComp subId xs ≡ xs\nsidl ε = refl\nsidl (xs , t) = cong₂ _,_ (sidl xs) (subid t)\n\nsidr2 : ∀{Φ Γ}(xs : Sub Φ Γ) → subComp xs (ren2sub renId) ≡ xs\nsidr2 {Γ = ε} ε = refl\nsidr2 {Γ = Γ , a} (xs , x) = begin\n subComp (xs , x) (ren2sub (wkr renId)) , x ≡⟨ cong (_, x) (lemsr xs x renId) ⟩\n subComp xs (ren2sub renId) , x ≡⟨ cong (_, x) (sidr2 xs) ⟩\n xs , x ∎\n\nliftSubRen : ∀{Γ Δ a b} (f : Sub Δ Γ) (t : Tm Γ b)\n → sub (lifts f) (weak a t) ≡ sub (wks f) t\nliftSubRen {a = a} f t = begin\n sub (lifts f) (weak a t) ≡⟨ subren (lifts f) (wkr renId) t ⟩\n sub (subComp (lifts f) (ren2sub (wkr renId))) t ≡⟨ cong (λ f' → sub f' t) (lemsr (wks f) (var zero) renId) ⟩\n sub (subComp (wks f) (ren2sub renId)) t ≡⟨ cong (λ f' → sub f' t) (sidr2 (wks f)) ⟩\n sub (wks f) t ∎\n\nlemss : ∀{Φ Γ Δ σ}(xs : Sub Φ Γ)(x : Tm Φ σ)(ys : Sub Γ Δ) →\n subComp (xs , x) (wks ys) ≡ subComp xs ys\nlemss xs x ε = refl\nlemss xs x (ys , y) = begin\n subComp (xs , x) (wks ys) , sub (xs , x) (ren (wkr renId) y) ≡⟨ cong₂ _,_ (lemss xs x ys) (subren (xs , x) (wkr renId) y) ⟩\n subComp xs ys , sub (subComp (xs , x) (ren2sub (wkr renId))) y ≡⟨ cong (λ g → subComp xs ys , sub g y) (lemsr xs x renId) ⟩\n subComp xs ys , sub (subComp xs (ren2sub renId)) y ≡⟨ cong (λ g → subComp xs ys , sub g y) (sidr2 xs) ⟩\n subComp xs ys , sub xs y ∎\n\nren2sublook : ∀{Γ Δ σ}(f : Ren Δ Γ)(i : Var Γ σ) →\n var (lookr f i) ≡ looks (ren2sub f) i\nren2sublook (f , _) zero = refl\nren2sublook (f , _) (suc i) = ren2sublook f i\n\nren2subwk : ∀{Γ Δ σ}(g : Ren Δ Γ) →\n ren2sub (wkr {σ = σ} g) ≡ wks {σ = σ} (ren2sub g)\nren2subwk ε = refl\nren2subwk (g , x) = begin\n (ren2sub (wkr g) , var (suc x)) ≡⟨ cong₂ (λ xs x → xs , var (suc x)) (ren2subwk g) (sym $ lookrid x) ⟩\n (wks (ren2sub g) , var (suc (lookr renId x))) ≡⟨ cong (λ x → wks (ren2sub g) , var x) (sym $ lookrwkr renId x) ⟩\n (wks (ren2sub g) , var (lookr (wkr renId) x)) ∎\n\nren2sublift : ∀{Γ Δ σ}(g : Ren Δ Γ) →\n ren2sub (liftr {σ = σ} g) ≡ lifts {σ = σ} (ren2sub g)\nren2sublift g = cong (_, var zero) (ren2subwk g)\n\nren2subren : ∀{Γ Δ σ}(f : Ren Δ Γ)(t : Tm Γ σ) → ren f t ≡ sub (ren2sub f) t\nren2subren f (var x) = ren2sublook f x\nren2subren f (abs t) = begin\n abs (ren (liftr f) t) ≡⟨ cong abs (ren2subren (liftr f) t) ⟩\n abs (sub (ren2sub (liftr f)) t) ≡⟨ cong (λ f → abs (sub f t)) (ren2sublift f) ⟩\n abs (sub (lifts (ren2sub f)) t) ∎\nren2subren f (app t u) = cong₂ app (ren2subren f t) (ren2subren f u)\n\nwkrscomp : ∀{Φ Γ Δ σ}(xs : Ren Φ Γ)(ys : Sub Γ Δ) →\n subComp (ren2sub (wkr {σ = σ} xs)) ys ≡ wks {σ = σ} (subComp (ren2sub xs) ys)\nwkrscomp xs ε = refl\nwkrscomp xs (ys , y) = begin\n subComp (ren2sub (wkr xs)) ys , sub (ren2sub (wkr xs)) y ≡⟨ cong₂ _,_ (wkrscomp xs ys) (sym $ ren2subren (wkr xs) y) ⟩\n wks (subComp (ren2sub xs) ys) , ren (wkr xs) y ≡⟨ cong (λ f → wks (subComp (ren2sub xs) ys) , ren (wkr f) y) (sym $ lidr xs) ⟩\n wks (subComp (ren2sub xs) ys) , ren (wkr (renComp renId xs)) y ≡⟨ cong (λ f → wks (subComp (ren2sub xs) ys) , ren f y) (sym $ wkrcomp renId xs) ⟩\n wks (subComp (ren2sub xs) ys) , ren (renComp (wkr renId) xs) y ≡⟨ cong (wks (subComp (ren2sub xs) ys) ,_) (rencomp (wkr renId) xs y) ⟩\n wks (subComp (ren2sub xs) ys) , ren (wkr renId) (ren xs y) ≡⟨ cong (λ t → wks (subComp (ren2sub xs) ys) , ren (wkr renId) t) (ren2subren xs y) ⟩\n wks (subComp (ren2sub xs) ys) , ren (wkr renId) (sub (ren2sub xs) y) ∎\n\nliftrscomp : ∀{Φ Γ Δ σ}(xs : Ren Φ Γ)(ys : Sub Γ Δ) →\n subComp (ren2sub (liftr {σ = σ} xs)) (lifts ys) ≡ lifts {σ = σ} (subComp (ren2sub xs) ys)\nliftrscomp xs ys = begin\n (subComp (ren2sub (wkr xs) , var zero) (wks ys) , var zero) ≡⟨ cong (_, var zero) (lemss (ren2sub (wkr xs)) (var zero) ys) ⟩\n (subComp (ren2sub (wkr xs)) ys , var zero) ≡⟨ cong (_, var zero) (wkrscomp xs ys) ⟩\n (wks (subComp (ren2sub xs) ys) , var zero) ∎\n\nrenlooks : ∀{Φ Γ Δ}(f : Ren Δ Γ)(g : Sub Γ Φ){σ}(x : Var Φ σ) →\n (ren f ∘ looks g) x ≡ looks (subComp (ren2sub f) g) x\nrenlooks f (_ , v) zero = ren2subren f v\nrenlooks f (g , _) (suc x) = renlooks f g x\n\nrensub : ∀{Φ Γ Δ}(f : Ren Δ Γ)(g : Sub Γ Φ){σ}(t : Tm Φ σ) →\n (ren f ∘ sub g) t ≡ sub (subComp (ren2sub f) g) t\nrensub f g (var x) = renlooks f g x\nrensub f g (abs t) = begin\n abs (ren (liftr f) (sub (lifts g) t)) ≡⟨ cong abs $ rensub (liftr f) (lifts g) t ⟩\n abs (sub (subComp (ren2sub (liftr f)) (lifts g)) t) ≡⟨ cong (λ f → abs (sub f t)) (liftrscomp f g) ⟩\n abs (sub (lifts (subComp (ren2sub f) g)) t) ∎\nrensub f g (app t u) = cong₂ app (rensub f g t) (rensub f g u)\n\nlookscomp : ∀{Φ Γ Δ}(f : Sub Δ Γ)(g : Sub Γ Φ){σ}(x : Var Φ σ) →\n looks (subComp f g) x ≡ sub f (looks g x)\nlookscomp f (g , _) zero = refl\nlookscomp f (g , _) (suc x) = lookscomp f g x\n\nren2subid : ∀{Γ} → subId {Γ} ≡ ren2sub renId\nren2subid {ε} = refl\nren2subid {Γ , a} = begin\n (wks subId , var zero) ≡⟨ cong (λ f → wks f , var zero) (ren2subid {Γ}) ⟩\n (wks (ren2sub renId) , var zero) ≡⟨ cong (_, var zero) (sym $ ren2subwk renId) ⟩\n (ren2sub (wkr renId) , var zero) ∎\n\nwksscomp : ∀{Φ Γ Δ σ}(xs : Sub Φ Γ)(ys : Sub Γ Δ) →\n subComp (wks {σ = σ} xs) ys ≡ wks {σ = σ} (subComp xs ys)\nwksscomp xs ε = refl\nwksscomp xs (ys , y) = begin\n subComp (wks xs) ys , sub (wks xs) y ≡⟨ cong (λ f → subComp (wks xs) ys , sub (wks f) y) (sym $ sidl xs) ⟩\n subComp (wks xs) ys , sub (wks (subComp subId xs)) y ≡⟨ cong₂ _,_ (wksscomp xs ys) (cong (λ f → sub (wks (subComp f xs)) y) ren2subid) ⟩\n wks (subComp xs ys) , sub (wks (subComp (ren2sub renId) xs)) y ≡⟨ cong (λ f → wks (subComp xs ys) , sub f y) (sym $ wkrscomp renId xs) ⟩\n wks (subComp xs ys) , sub (subComp (ren2sub (wkr renId)) xs) y ≡⟨ cong (wks (subComp xs ys) ,_) (sym $ rensub (wkr renId) xs y) ⟩\n wks (subComp xs ys) , ren (wkr renId) (sub xs y) ∎\n\nsidr : ∀{Φ Γ}(xs : Sub Φ Γ) → subComp xs subId ≡ xs\nsidr xs = begin\n subComp xs subId ≡⟨ cong (subComp xs) ren2subid ⟩\n subComp xs (ren2sub renId) ≡⟨ sidr2 xs ⟩\n xs ∎\n\nliftscomp : ∀{Φ Γ Δ σ}(xs : Sub Φ Γ)(ys : Sub Γ Δ) →\n subComp (lifts {σ = σ} xs) (lifts ys) ≡ lifts {σ = σ} (subComp xs ys)\nliftscomp xs ys = begin\n subComp (wks xs , var zero) (wks ys) , var zero ≡⟨ cong (_, var zero) (lemss (wks xs) (var zero) ys) ⟩\n subComp (wks xs) ys , var zero ≡⟨ cong (_, var zero) (wksscomp xs ys) ⟩\n wks (subComp xs ys) , var zero ∎\n\nsubcomp : ∀{Φ Γ Δ}(f : Sub Δ Γ)(g : Sub Γ Φ){σ}(t : Tm Φ σ) →\n sub (subComp f g) t ≡ (sub f ∘ sub g) t\nsubcomp f g (var x) = lookscomp f g x\nsubcomp f g (abs t) = begin\n abs (sub (lifts (subComp f g)) t) ≡⟨ cong (λ f → abs (sub f t)) (sym $ liftscomp f g) ⟩\n abs (sub (subComp (lifts f) (lifts g)) t) ≡⟨ cong abs (subcomp (lifts f) (lifts g) t) ⟩\n abs (sub (lifts f) (sub (lifts g) t)) ∎\nsubcomp f g (app t u) = cong₂ app (subcomp f g t) (subcomp f g u)\n\n--\n\nmutual\n renembNe : ∀{Γ Δ a}(u : Ne Γ a)(σ : Ren Δ Γ) →\n ren σ (embNe u) ≡ embNe (rennen σ u)\n renembNe (var x) σ = refl\n renembNe (app u n) σ = cong₂ app (renembNe u σ) (renembNf n σ)\n\n renembNf : ∀{Γ Δ a}(n : Nf Γ a)(σ : Ren Δ Γ) →\n ren σ (embNf n) ≡ embNf (rennf σ n)\n renembNf (abs n) σ = cong abs (renembNf n (liftr σ))\n renembNf (ne n) σ = renembNe n σ\n-- -}\n", "meta": {"hexsha": "ee03be0db93b994f21e4baa1660e5c6d037e98a2", "size": 17026, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/RenamingAndSubstitution.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/RenamingAndSubstitution.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/RenamingAndSubstitution.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": 41.5268292683, "max_line_length": 161, "alphanum_fraction": 0.5230823446, "num_tokens": 6983, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.588925726615421}} {"text": "------------------------------------------------------------------------------\n-- Exclusive disjunction theorems\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule FOL.ExclusiveDisjunction.TheoremsATP where\n\n-- The theorems below are valid on intuitionistic logic and with an\n-- empty domain.\nopen import FOL.Base hiding ( D≢∅ ; pem )\nopen import FOL.ExclusiveDisjunction.Base\n\n------------------------------------------------------------------------------\n-- We postulate some propositional formulae (which are translated as\n-- 0-ary predicates).\npostulate P Q : Set\n\n-- We do not use the _⊻_ operator because its definition is not a\n-- FOL-definition.\n\npostulate\n p⊻q→p→¬q : ((P ∨ Q) ∧ ¬ (P ∧ Q)) → P → ¬ Q\n{-# ATP prove p⊻q→p→¬q #-}\n\npostulate\n p⊻q→q→¬p : ((P ∨ Q) ∧ ¬ (P ∧ Q)) → Q → ¬ P\n{-# ATP prove p⊻q→q→¬p #-}\n\npostulate\n p⊻q→¬p→q : ((P ∨ Q) ∧ ¬ (P ∧ Q)) → ¬ P → Q\n{-# ATP prove p⊻q→¬p→q #-}\n\npostulate\n p⊻q→¬q→p : ((P ∨ Q) ∧ ¬ (P ∧ Q)) → ¬ Q → P\n{-# ATP prove p⊻q→¬q→p #-}\n\npostulate\n ¬[p⊻q] : ¬ ((P ∨ Q) ∧ ¬ (P ∧ Q)) → ((P ∧ Q) ∨ (¬ P ∧ ¬ Q))\n{-# ATP prove ¬[p⊻q] #-}\n", "meta": {"hexsha": "12c889a0470cec8f09f26fca7873ef56ed979d18", "size": 1292, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOL/ExclusiveDisjunction/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/ExclusiveDisjunction/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/ExclusiveDisjunction/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": 29.3636363636, "max_line_length": 78, "alphanum_fraction": 0.4496904025, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357735451835, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.5888722288149483}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Decision procedures for finite sets and subsets of finite sets\n------------------------------------------------------------------------\n\nmodule Data.Fin.Dec where\n\nopen import Function\nimport Data.Bool as Bool\nopen import Data.Nat hiding (_<_)\nopen import Data.Vec hiding (_∈_)\nopen import Data.Vec.Equality as VecEq\n using () renaming (module PropositionalEquality to PropVecEq)\nopen import Data.Fin\nopen import Data.Fin.Subset\nopen import Data.Fin.Subset.Properties\nopen import Data.Product as Prod\nopen import Data.Empty\nopen import Function\nimport Function.Equivalence as Eq\nopen import Relation.Binary as B\nimport Relation.Binary.HeterogeneousEquality as H\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Unary as U using (Pred)\n\ninfix 4 _∈?_\n\n_∈?_ : ∀ {n} x (p : Subset n) → Dec (x ∈ p)\nzero ∈? inside ∷ p = yes here\nzero ∈? outside ∷ p = no λ()\nsuc n ∈? s ∷ p with n ∈? p\n... | yes n∈p = yes (there n∈p)\n... | no n∉p = no (n∉p ∘ drop-there)\n\nprivate\n\n restrictP : ∀ {p n} → (Fin (suc n) → Set p) → (Fin n → Set p)\n restrictP P f = P (suc f)\n\n restrict : ∀ {p n} {P : Fin (suc n) → Set p} →\n U.Decidable P → U.Decidable (restrictP P)\n restrict dec f = dec (suc f)\n\nany? : ∀ {n} {P : Fin n → Set} →\n U.Decidable P → Dec (∃ P)\nany? {zero} dec = no λ { (() , _) }\nany? {suc n} {P} dec with dec zero | any? (restrict dec)\n... | yes p | _ = yes (_ , p)\n... | _ | yes (_ , p') = yes (_ , p')\n... | no ¬p | no ¬p' = no helper\n where\n helper : ∄ P\n helper (zero , p) = ¬p p\n helper (suc f , p') = ¬p' (_ , p')\n\nnonempty? : ∀ {n} (p : Subset n) → Dec (Nonempty p)\nnonempty? p = any? (λ x → x ∈? p)\n\nprivate\n\n restrict∈ : ∀ {p q n}\n (P : Fin (suc n) → Set p) {Q : Fin (suc n) → Set q} →\n (∀ {f} → Q f → Dec (P f)) →\n (∀ {f} → restrictP Q f → Dec (restrictP P f))\n restrict∈ _ dec {f} Qf = dec {suc f} Qf\n\ndecFinSubset : ∀ {p q n} {P : Fin n → Set p} {Q : Fin n → Set q} →\n U.Decidable Q →\n (∀ {f} → Q f → Dec (P f)) →\n Dec (∀ {f} → Q f → P f)\ndecFinSubset {n = zero} _ _ = yes λ{}\ndecFinSubset {n = suc n} {P} {Q} decQ decP = helper\n where\n helper : Dec (∀ {f} → Q f → P f)\n helper with decFinSubset (restrict decQ) (restrict∈ P decP)\n helper | no ¬q⟶p = no (λ q⟶p → ¬q⟶p (λ {f} q → q⟶p {suc f} q))\n helper | yes q⟶p with decQ zero\n helper | yes q⟶p | yes q₀ with decP q₀\n helper | yes q⟶p | yes q₀ | no ¬p₀ = no (λ q⟶p → ¬p₀ (q⟶p {zero} q₀))\n helper | yes q⟶p | yes q₀ | yes p₀ = yes (λ {_} → hlpr _)\n where\n hlpr : ∀ f → Q f → P f\n hlpr zero _ = p₀\n hlpr (suc f) qf = q⟶p qf\n helper | yes q⟶p | no ¬q₀ = yes (λ {_} → hlpr _)\n where\n hlpr : ∀ f → Q f → P f\n hlpr zero q₀ = ⊥-elim (¬q₀ q₀)\n hlpr (suc f) qf = q⟶p qf\n\nall∈? : ∀ {n p} {P : Fin n → Set p} {q} →\n (∀ {f} → f ∈ q → Dec (P f)) →\n Dec (∀ {f} → f ∈ q → P f)\nall∈? {q = q} dec = decFinSubset (λ f → f ∈? q) dec\n\nall? : ∀ {n p} {P : Fin n → Set p} →\n U.Decidable P → Dec (∀ f → P f)\nall? dec with all∈? {q = ⊤} (λ {f} _ → dec f)\n... | yes ∀p = yes (λ f → ∀p ∈⊤)\n... | no ¬∀p = no (λ ∀p → ¬∀p (λ {f} _ → ∀p f))\n\ndecLift : ∀ {n} {P : Fin n → Set} →\n U.Decidable P → U.Decidable (Lift P)\ndecLift dec p = all∈? (λ {x} _ → dec x)\n\nprivate\n\n restrictSP : ∀ {n} → Side → (Subset (suc n) → Set) → (Subset n → Set)\n restrictSP s P p = P (s ∷ p)\n\n restrictS : ∀ {n} {P : Subset (suc n) → Set} →\n (s : Side) → U.Decidable P → U.Decidable (restrictSP s P)\n restrictS s dec p = dec (s ∷ p)\n\nanySubset? : ∀ {n} {P : Subset n → Set} →\n U.Decidable P → Dec (∃ P)\nanySubset? {zero} {P} dec with dec []\n... | yes P[] = yes (_ , P[])\n... | no ¬P[] = no helper\n where\n helper : ∄ P\n helper ([] , P[]) = ¬P[] P[]\nanySubset? {suc n} {P} dec with anySubset? (restrictS inside dec)\n | anySubset? (restrictS outside dec)\n... | yes (_ , Pp) | _ = yes (_ , Pp)\n... | _ | yes (_ , Pp) = yes (_ , Pp)\n... | no ¬Pp | no ¬Pp' = no helper\n where\n helper : ∄ P\n helper (inside ∷ p , Pp) = ¬Pp (_ , Pp)\n helper (outside ∷ p , Pp') = ¬Pp' (_ , Pp')\n\n-- If a decidable predicate P over a finite set is sometimes false,\n-- then we can find the smallest value for which this is the case.\n\n¬∀⟶∃¬-smallest :\n ∀ n {p} (P : Fin n → Set p) → U.Decidable P →\n ¬ (∀ i → P i) → ∃ λ i → ¬ P i × ((j : Fin′ i) → P (inject j))\n¬∀⟶∃¬-smallest zero P dec ¬∀iPi = ⊥-elim (¬∀iPi (λ()))\n¬∀⟶∃¬-smallest (suc n) P dec ¬∀iPi with dec zero\n¬∀⟶∃¬-smallest (suc n) P dec ¬∀iPi | no ¬P0 = (zero , ¬P0 , λ ())\n¬∀⟶∃¬-smallest (suc n) P dec ¬∀iPi | yes P0 =\n Prod.map suc (Prod.map id extend′) $\n ¬∀⟶∃¬-smallest n (λ n → P (suc n)) (dec ∘ suc) (¬∀iPi ∘ extend)\n where\n extend : (∀ i → P (suc i)) → (∀ i → P i)\n extend ∀iP[1+i] zero = P0\n extend ∀iP[1+i] (suc i) = ∀iP[1+i] i\n\n extend′ : ∀ {i : Fin n} →\n ((j : Fin′ i) → P (suc (inject j))) →\n ((j : Fin′ (suc i)) → P (inject j))\n extend′ g zero = P0\n extend′ g (suc j) = g j\n\n-- Decision procedure for _⊆_ (obtained via the natural lattice\n-- order).\n\ninfix 4 _⊆?_\n\n_⊆?_ : ∀ {n} → B.Decidable (_⊆_ {n = n})\np₁ ⊆? p₂ =\n Dec.map (Eq.sym NaturalPoset.orders-equivalent) $\n Dec.map′ PropVecEq.to-≡ PropVecEq.from-≡ $\n VecEq.DecidableEquality._≟_ Bool.decSetoid p₁ (p₁ ∩ p₂)\n", "meta": {"hexsha": "6318eb8125d5a8e627b952e597e4ea9bac5419c6", "size": 5647, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Fin/Dec.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/Dec.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/Dec.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.6130952381, "max_line_length": 72, "alphanum_fraction": 0.4967239242, "num_tokens": 2174, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.7799929104825007, "lm_q1q2_score": 0.5888283463754652}} {"text": "-- Andreas, 2012-06-05 let for record patterns\n\n-- {-# OPTIONS --show-implicit #-}\n-- {-# OPTIONS -v tc.term.let.pattern:100 #-}\n-- {-# OPTIONS -v tc.lhs.top:100 #-}\n\nmodule LetPair where\n\nimport Common.Level\nopen import Common.Equality\n\ninfixl 6 _×_\ninfixl 0 _,_\n\nrecord _×_ (A B : Set) : Set where\n constructor _,_\n field\n fst : A\n snd : B\nopen _×_\n\nswap : {A B : Set} → A × B → B × A\nswap p =\n let (a , b) = p\n in (b , a)\n\nprop_swap : {A B : Set}{p : A × B} →\n (fst (swap p) ≡ snd p) ×\n (snd (swap p) ≡ fst p)\nprop_swap = refl , refl\n\nrot3 : {A B C : Set} → A × B × C → B × C × A\nrot3 = λ t → let\n a , b , c = t\n in b , c , a\n\npostulate\n A B C : Set\n\nrot3' = λ t → let\n x : A × B × C\n x = t\n a , b , c = x\n in b , c , a\n\nrecord ⊤ : Set where\n constructor tt\n\ntest = let tt , _ = tt , tt in A\n\n", "meta": {"hexsha": "55c2b7dc5ad9b7d4178541826587a2f2158a62e2", "size": 835, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/LetPair.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/LetPair.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/LetPair.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.3725490196, "max_line_length": 46, "alphanum_fraction": 0.5185628743, "num_tokens": 328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117983401362, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.5888107498679029}} {"text": "------------------------------------------------------------------------------\n-- Co-inductive 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\nmodule GFPs.Conat where\n\nopen import FOTC.Base\nopen import FOTC.Base.PropertiesI\n\n------------------------------------------------------------------------------\n-- Conat is a greatest fixed-point of a functor\n\n-- The functor.\nNatF : (D → Set) → D → Set\nNatF A n = n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')\n\n-- The co-natural numbers are the greatest fixed-point of NatF.\npostulate\n Conat : D → Set\n\n -- Conat is a post-fixed point of NatF, i.e.\n --\n -- Conat ≤ NatF Conat.\n Conat-out : ∀ {n} → Conat n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')\n\n -- The higher-order version.\n Conat-out-ho : ∀ {n} → Conat n → NatF Conat n\n\n -- Conat is the greatest post-fixed point of NatF, i.e.\n --\n -- ∀ A. A ≤ NatF A ⇒ A ≤ Conat.\n Conat-coind :\n (A : D → Set) →\n -- A is post-fixed point of ConatF.\n (∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) →\n -- Conat is greater than A.\n ∀ {n} → A n → Conat n\n\n -- The higher-order version.\n Conat-coind-ho :\n (A : D → Set) → (∀ {n} → A n → NatF A n) → ∀ {n} → A n → Conat n\n\n -- 22 December 2013. This is a stronger induction principle. If we\n -- use it, we can use the trivial predicate A = λ x → x ≡ x in the\n -- proofs. Unfortunately, we don't have a justification/proof for\n -- this principle.\n Conat-stronger-coind₁ :\n ∀ (A : D → Set) {n} →\n (A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) →\n A n → Conat n\n\n -- Other stronger co-induction principle\n --\n -- Adapted from (Paulson, 1997. p. 16).\n Conat-stronger-coind₂ :\n (A : D → Set) →\n (∀ {n} → A n → (n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) ∨ Conat n) →\n ∀ {n} → A n → Conat n\n\n------------------------------------------------------------------------------\n-- Conat-out and Conat-out-ho are equivalents\n\nConat-out-fo : ∀ {n} → Conat n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')\nConat-out-fo = Conat-out-ho\n\nConat-out-ho' : ∀ {n} → Conat n → NatF Conat n\nConat-out-ho' = Conat-out\n\n------------------------------------------------------------------------------\n-- Conat-coind and Conat-coind-ho are equivalents\n\nConat-coind-fo :\n (A : D → Set) →\n (∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) →\n ∀ {n} → A n → Conat n\nConat-coind-fo = Conat-coind-ho\n\nConat-coind-ho' :\n (A : D → Set) → (∀ {n} → A n → NatF A n) → ∀ {n} → A n → Conat n\nConat-coind-ho' = Conat-coind\n\n------------------------------------------------------------------------------\n-- Because a greatest post-fixed point is a fixed-point, then the\n-- Conat predicate is also a pre-fixed point of the functional NatF,\n-- i.e.\n--\n-- NatF Conat ≤ Conat.\nConat-in : ∀ {n} →\n n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n') →\n Conat n\nConat-in h = Conat-coind A h' h\n where\n A : D → Set\n A n = n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')\n\n h' : ∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')\n h' (inj₁ n≡0) = inj₁ n≡0\n h' (inj₂ (n' , prf , Cn')) = inj₂ (n' , prf , Conat-out Cn')\n\n-- The higher-order version.\nConat-in-ho : ∀ {n} → NatF Conat n → Conat n\nConat-in-ho = Conat-in\n\n-- A different definition.\nConat-in' : (∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')) →\n ∀ {n} → Conat n\nConat-in' h = Conat-coind (λ m → m ≡ m) (h' h) refl\n where\n h' : (∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')) →\n ∀ {m} → m ≡ m → m ≡ zero ∨ (∃[ m' ] m ≡ succ₁ m' ∧ m' ≡ m')\n h' h'' {m} _ with (h'' {m})\n ... | inj₁ m≡0 = inj₁ m≡0\n ... | inj₂ (m' , prf , _) = inj₂ (m' , prf , refl)\n\nConat-in-ho' : (∀ {n} → NatF Conat n) → ∀ {n} → Conat n\nConat-in-ho' = Conat-in'\n\n------------------------------------------------------------------------------\n-- From Conat-coind/Conat-stronger-coind₁ to Conat-stronger-coind₁/Conat-coind\n\nConat-coind'' :\n (A : D → Set) →\n (∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) →\n ∀ {n} → A n → Conat n\nConat-coind'' A h An = Conat-stronger-coind₁ A h An\n\n-- 22 December 2013: We couln't prove Conat-stronger-coind₁ using\n-- Conat-coind.\nConat-stronger-coind₁' :\n ∀ (A : D → Set) {n} →\n (A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) →\n A n → Conat n\nConat-stronger-coind₁' A {n} h An = Conat-in (case prf₁ prf₂ (h An))\n where\n prf₁ : n ≡ zero → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')\n prf₁ n≡0 = inj₁ n≡0\n\n prf₂ : ∃[ n' ] n ≡ succ₁ n' ∧ A n' →\n n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')\n prf₂ (n' , prf , An') = inj₂ (n' , prf , {!!})\n\n------------------------------------------------------------------------------\n-- From Conat-stronger-coind₂ to Conat-stronger-coind₁\n\n-- 13 January 2014: We couln't prove Conat-stronger-coind₁ using\n-- Conat-stronger-coind₂.\nConat-stronger-coind₁'' :\n ∀ (A : D → Set) {n} →\n (A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) →\n A n → Conat n\nConat-stronger-coind₁'' A h An = Conat-stronger-coind₂ A {!!} An\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": "99b2c1c2d8eb5f1560e1f38674b7de3495c996c7", "size": 5481, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/fixed-points/GFPs/Conat.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/Conat.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/Conat.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.2181818182, "max_line_length": 78, "alphanum_fraction": 0.4643313264, "num_tokens": 1976, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424411924673, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.588740679112353}} {"text": "------------------------------------------------------------------------------\n-- 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.Axiomatic.Mendelson.PropertiesATP where\n\nopen import PA.Axiomatic.Mendelson.Base\n\n------------------------------------------------------------------------------\n\n+-leftIdentity : ∀ n → zero + n ≈ n\n+-leftIdentity = S₅\n\n-- See Issue https://github.com/asr/apia/issues/81 .\n+-rightIdentityA : ℕ → Set\n+-rightIdentityA i = i + zero ≈ i\n{-# ATP definition +-rightIdentityA #-}\n\n+-rightIdentity : ∀ n → n + zero ≈ n\n+-rightIdentity = S₉ +-rightIdentityA A0 is\n where\n A0 : +-rightIdentityA zero\n A0 = +-leftIdentity zero\n\n postulate is : ∀ i → +-rightIdentityA i → +-rightIdentityA (succ i)\n {-# ATP prove is #-}\n\n-- See Issue https://github.com/asr/apia/issues/81 .\nx+Sy≈S[x+y]A : ℕ → ℕ → Set\nx+Sy≈S[x+y]A n i = i + succ n ≈ succ (i + n)\n{-# ATP definition x+Sy≈S[x+y]A #-}\n\nx+Sy≈S[x+y] : ∀ m n → m + succ n ≈ succ (m + n)\nx+Sy≈S[x+y] m n = S₉ (x+Sy≈S[x+y]A n) A0 is m\n where\n postulate A0 : x+Sy≈S[x+y]A n zero\n {-# ATP prove A0 #-}\n\n postulate is : ∀ i → x+Sy≈S[x+y]A n i → x+Sy≈S[x+y]A n (succ i)\n {-# ATP prove is #-}\n\n-- See Issue https://github.com/asr/apia/issues/81 .\n+-leftCongA : ℕ → ℕ → ℕ → Set\n+-leftCongA m n i = m + i ≈ n + i\n{-# ATP definition +-leftCongA #-}\n\n+-leftCong : ∀ {m n o} → m ≈ n → m + o ≈ n + o\n+-leftCong {m} {n} {o} h = S₉ (+-leftCongA m n) A0 is o\n where\n postulate A0 : +-leftCongA m n zero\n {-# ATP prove A0 +-rightIdentity #-}\n\n postulate is : ∀ i → +-leftCongA m n i → +-leftCongA m n (succ i)\n {-# ATP prove is x+Sy≈S[x+y] #-}\n\n-- See Issue https://github.com/asr/apia/issues/81 .\n+-commA : ℕ → ℕ → Set\n+-commA n i = i + n ≈ n + i\n{-# ATP definition +-commA #-}\n\n+-comm : ∀ m n → m + n ≈ n + m\n+-comm m n = S₉ (+-commA n) A0 is m\n where\n postulate A0 : +-commA n zero\n {-# ATP prove A0 +-rightIdentity #-}\n\n postulate is : ∀ i → +-commA n i → +-commA n (succ i)\n {-# ATP prove is x+Sy≈S[x+y] #-}\n\n+-asocc : ∀ m n o → m + n + o ≈ m + (n + o)\n+-asocc m n o = S₉ A A0 is m\n where\n A : ℕ → Set\n A i = i + n + o ≈ i + (n + o)\n {-# ATP definition A #-}\n\n postulate A0 : A zero\n {-# ATP prove A0 +-leftCong #-}\n\n postulate is : ∀ i → A i → A (succ i)\n {-# ATP prove is +-leftCong #-}\n", "meta": {"hexsha": "67b82a28591c8f51cb9f79cd487a5330b514723d", "size": 2496, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Axiomatic/Mendelson/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/Axiomatic/Mendelson/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/Axiomatic/Mendelson/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": 28.6896551724, "max_line_length": 78, "alphanum_fraction": 0.5024038462, "num_tokens": 860, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.849971190859164, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5887257258513671}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category using (Category; module Commutation)\nopen import Categories.Category.Monoidal\nopen import Categories.Category.Monoidal.Braided using (Braided)\n\nmodule Categories.Category.Monoidal.Braided.Properties\n {o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (BM : Braided M) where\n\nopen import Data.Product using (_,_)\n\nopen import Categories.Category.Monoidal.Properties M\nopen import Categories.Category.Monoidal.Reasoning M\nopen import Categories.Category.Monoidal.Utilities M\nopen import Categories.Functor using (Functor)\nopen import Categories.Morphism C using (module ≅)\nopen import Categories.Morphism.IsoEquiv C using (_≃_; ⌞_⌟)\nopen import Categories.Morphism.Reasoning C hiding (push-eq)\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper)\nopen import Categories.NaturalTransformation.NaturalIsomorphism.Properties\n using (push-eq)\n\nopen Category C\nopen Braided BM\nopen Commutation C\n\nprivate\n variable\n X Y Z : Obj\n\n -- A shorthand for the braiding\n B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X\n B {X} {Y} = braiding.⇒.η (X , Y)\n\n\n -- It's easier to prove the following lemma, which is the desired\n -- coherence theorem moduolo application of the |-⊗ unit| functor.\n -- Because |-⊗ unit| is equivalent to the identity functor, the\n -- lemma and the theorem are equivalent.\n\n -- The following diagram illustrates the hexagon that we are\n -- operating on. The main outer hexagon is hexagon₁, the braiding\n -- coherence, instantiated with X, 1 and 1 (Here we denote the unit\n -- by 1 for brevity).\n -- In the middle are X1 and 1X along with morphisms towards them.\n -- The lower hexagon (given by the double lines) commutes and is\n -- an intermediary in the final proof. It is there to effectively\n -- get rid of the top half of the main hexagon.\n -- The rest of the proof is isolating the bottom left triangle\n -- which represents our desired identity. It is doing that by\n -- proving that the pentagon to the right of it commutes.\n -- The pentagon commuting is, in turn, proved by gluing the\n -- rightmost \"square\" onto the middle triangle.\n --\n --\n -- ┌─────> X(11) ─────────> (11)X ──────┐\n -- ┌┘ α │ B │ α └┐\n -- ┌┘ │id⊗λ │λ⊗id └┐\n -- ┌┘ V V V\n -- (X1)1 ═══════> X1 ════════════> 1X <══════ 1(1X)\n -- ╚╗ ρ⊗id Λ <───┐ B λ Λ\n -- ╚╗ │λ⊗id └────────┐ ╔╝\n -- ╚╗ │ λ └┐ ╔╝\n -- ╚═════> (1X)1 ═════════> 1(X1) ═════╝\n -- B⊗id α id⊗B\n\n braiding-coherence⊗unit : [ (X ⊗₀ unit) ⊗₀ unit ⇒ X ⊗₀ unit ]⟨\n B ⊗₁ id ⇒⟨ (unit ⊗₀ X) ⊗₀ unit ⟩\n unitorˡ.from ⊗₁ id\n ≈ unitorʳ.from ⊗₁ id\n ⟩\n braiding-coherence⊗unit = cancel-fromˡ braiding.FX≅GX (\n begin\n B ∘ unitorˡ.from ⊗₁ id ∘ B ⊗₁ id ≈⟨ pullˡ (⟺ (glue◽◃ unitorˡ-commute-from coherence₁)) ⟩\n (unitorˡ.from ∘ id ⊗₁ B ∘ associator.from) ∘ B ⊗₁ id ≈⟨ assoc²' ⟩\n unitorˡ.from ∘ id ⊗₁ B ∘ associator.from ∘ B ⊗₁ id ≈⟨ refl⟩∘⟨ hexagon₁ ⟩\n unitorˡ.from ∘ associator.from ∘ B ∘ associator.from ≈⟨ pullˡ coherence₁ ⟩\n unitorˡ.from ⊗₁ id ∘ B ∘ associator.from ≈˘⟨ pushˡ (braiding.⇒.commute _) ⟩\n (B ∘ id ⊗₁ unitorˡ.from) ∘ associator.from ≈⟨ pullʳ triangle ⟩\n B ∘ unitorʳ.from ⊗₁ id\n ∎)\n\n-- The desired theorem follows from |braiding-coherence⊗unit| by\n-- translating it along the right unitor (which is a natural iso).\n\nbraiding-coherence : [ X ⊗₀ unit ⇒ X ]⟨\n B ⇒⟨ unit ⊗₀ X ⟩\n unitorˡ.from\n ≈ unitorʳ.from\n ⟩\nbraiding-coherence = push-eq unitorʳ-naturalIsomorphism (begin\n (unitorˡ.from ∘ B) ⊗₁ id ≈⟨ homomorphism ⟩\n (unitorˡ.from ⊗₁ id) ∘ (B ⊗₁ id) ≈⟨ braiding-coherence⊗unit ⟩\n unitorʳ.from ⊗₁ id ∎)\n where open Functor (-⊗ unit)\n\n\n-- Shorthands for working with isomorphisms.\n\nopen ≅ using () renaming (refl to idᵢ; sym to _⁻¹)\ninfixr 9 _∘ᵢ_\nprivate\n _∘ᵢ_ = λ {A B C} f g → ≅.trans {A} {B} {C} g f\n Bᵢ = braiding.FX≅GX\n B⁻¹ = λ {X} {Y} → braiding.⇐.η (X , Y)\n\n-- Variants of the hexagon identities defined on isos.\n\nhexagon₁-iso : idᵢ ⊗ᵢ Bᵢ ∘ᵢ associator ∘ᵢ Bᵢ {X , Y} ⊗ᵢ idᵢ {Z} ≃\n associator ∘ᵢ Bᵢ {X , Y ⊗₀ Z} ∘ᵢ associator\nhexagon₁-iso = ⌞ hexagon₁ ⌟\n\nhexagon₂-iso : (Bᵢ ⊗ᵢ idᵢ ∘ᵢ associator ⁻¹) ∘ᵢ idᵢ {X} ⊗ᵢ Bᵢ {Y , Z} ≃\n (associator ⁻¹ ∘ᵢ Bᵢ {X ⊗₀ Y , Z}) ∘ᵢ associator ⁻¹\nhexagon₂-iso = ⌞ hexagon₂ ⌟\n\n-- A variants of the above coherence law defined on isos.\n\nbraiding-coherence-iso : unitorˡ ∘ᵢ Bᵢ ≃ unitorʳ {X}\nbraiding-coherence-iso = ⌞ braiding-coherence ⌟\n\n-- The inverse of the braiding is also a braiding on M.\n\ninv-Braided : Braided M\ninv-Braided = record\n { braiding = niHelper (record\n { η = λ _ → B⁻¹\n ; η⁻¹ = λ _ → B\n ; commute = λ{ (f , g) → braiding.⇐.commute (g , f) }\n ; iso = λ{ (X , Y) → record\n { isoˡ = braiding.iso.isoʳ (Y , X)\n ; isoʳ = braiding.iso.isoˡ (Y , X) } }\n })\n ; hexagon₁ = _≃_.to-≈ hexagon₂-iso\n ; hexagon₂ = _≃_.to-≈ hexagon₁-iso\n }\n\n-- A variant of the above coherence law for the inverse of the braiding.\n\ninv-braiding-coherence : [ unit ⊗₀ X ⇒ X ]⟨\n B⁻¹ ⇒⟨ X ⊗₀ unit ⟩\n unitorʳ.from\n ≈ unitorˡ.from\n ⟩\ninv-braiding-coherence = ⟺ (switch-fromtoʳ Bᵢ braiding-coherence)\n", "meta": {"hexsha": "a61306f456609bc54e42a7c357f83b20e1e488d0", "size": 5758, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Monoidal/Braided/Properties.agda", "max_stars_repo_name": "TOTBWF/agda-categories", "max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_stars_repo_licenses": ["MIT"], "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/Braided/Properties.agda", "max_issues_repo_name": "TOTBWF/agda-categories", "max_issues_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_issues_repo_licenses": ["MIT"], "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/Braided/Properties.agda", "max_forks_repo_name": "TOTBWF/agda-categories", "max_forks_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_forks_repo_licenses": ["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.4383561644, "max_line_length": 124, "alphanum_fraction": 0.5672108371, "num_tokens": 2073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711756575749, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.5887257207148258}} {"text": "{-# OPTIONS --safe #-}\nmodule STLC.Denotational where\n\nopen import STLC.Syntax\nopen import STLC.Typing\nopen import Data.Nat using (ℕ; suc)\nopen import Data.Fin using (Fin) renaming (zero to fzero; suc to fsuc)\nopen import Data.Product using (_×_; _,_; proj₁; proj₂)\nopen import Data.Unit using (⊤; tt)\n\nprivate\n variable\n n : ℕ\n Γ : Ctx n\n A : Type\n\n⟦_⟧ : Type → Set\n⟦ A ⇒ B ⟧ = ⟦ A ⟧ → ⟦ B ⟧\n⟦ unit ⟧ = ⊤\n⟦ A ×' B ⟧ = ⟦ A ⟧ × ⟦ B ⟧\n\ndata Env : Ctx n → Set where\n ∅ : Env ●\n ⟨_,_⟩ : Env Γ → ⟦ A ⟧ → Env (Γ ,- A)\n\nlookup : Env {n} Γ → (v : Fin n) → ⟦ find Γ v ⟧\nlookup ⟨ ρ , term ⟩ fzero = term\nlookup ⟨ ρ , term ⟩ (fsuc n) = lookup ρ n\n\n⟦_⟧⟨_⟩ : ∀ {term : Term n} {type : Type} → (Γ ⊢ term ∈ type) → Env Γ → ⟦ type ⟧\n⟦ ty-abs body ⟧⟨ ρ ⟩ = λ x → ⟦ body ⟧⟨ ⟨ ρ , x ⟩ ⟩\n⟦ ty-app f x ⟧⟨ ρ ⟩ = ⟦ f ⟧⟨ ρ ⟩ ⟦ x ⟧⟨ ρ ⟩\n⟦ ty-var v ⟧⟨ ρ ⟩ = lookup ρ v\n⟦ ty-⋆ ⟧⟨ _ ⟩ = tt\n⟦ ty-pair l r ⟧⟨ ρ ⟩ = ⟦ l ⟧⟨ ρ ⟩ , ⟦ r ⟧⟨ ρ ⟩\n⟦ ty-projₗ p ⟧⟨ ρ ⟩ = proj₁ ⟦ p ⟧⟨ ρ ⟩\n⟦ ty-projᵣ p ⟧⟨ ρ ⟩ = proj₂ ⟦ p ⟧⟨ ρ ⟩\n", "meta": {"hexsha": "817839b92ff66406a26a0751abe5fe8260ce5bb1", "size": 999, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "STLC/Denotational.agda", "max_stars_repo_name": "TypesLogicsCats/STLC", "max_stars_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-03-16T23:53:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-16T23:53:48.000Z", "max_issues_repo_path": "STLC/Denotational.agda", "max_issues_repo_name": "TrulyNonstrict/STLC", "max_issues_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "STLC/Denotational.agda", "max_forks_repo_name": "TrulyNonstrict/STLC", "max_forks_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc", "max_forks_repo_licenses": ["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.2894736842, "max_line_length": 79, "alphanum_fraction": 0.5005005005, "num_tokens": 518, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8499711870587667, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.5887257178263349}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Pointwise lifting of binary relations to sigma types\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Product.Relation.Binary.Pointwise.Dependent where\n\nopen import Data.Product as Prod\nopen import Level\nopen import Function\nopen import Relation.Binary as B\n using (_⇒_; Setoid; IsEquivalence)\nopen import Relation.Binary.Indexed.Heterogeneous as I\n using (IREL; IRel; IndexedSetoid; IsIndexedEquivalence)\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\n------------------------------------------------------------------------\n-- Pointwise lifting\n\ninfixr 4 _,_\n\nrecord POINTWISE {a₁ a₂ b₁ b₂ ℓ₁ ℓ₂}\n {A₁ : Set a₁} (B₁ : A₁ → Set b₁)\n {A₂ : Set a₂} (B₂ : A₂ → Set b₂)\n (_R₁_ : B.REL A₁ A₂ ℓ₁) (_R₂_ : IREL B₁ B₂ ℓ₂)\n (xy₁ : Σ A₁ B₁) (xy₂ : Σ A₂ B₂)\n : Set (a₁ ⊔ a₂ ⊔ b₁ ⊔ b₂ ⊔ ℓ₁ ⊔ ℓ₂) where\n constructor _,_\n field\n proj₁ : (proj₁ xy₁) R₁ (proj₁ xy₂)\n proj₂ : (proj₂ xy₁) R₂ (proj₂ xy₂)\n\nopen POINTWISE public\n\nPointwise : ∀ {a b ℓ₁ ℓ₂} {A : Set a} (B : A → Set b)\n (_R₁_ : B.Rel A ℓ₁) (_R₂_ : IRel B ℓ₂) → B.Rel (Σ A B) _\nPointwise B = POINTWISE B B\n\n------------------------------------------------------------------------\n-- Pointwise preserves many relational properties\n\nmodule _ {a b ℓ₁ ℓ₂} {A : Set a} {B : A → Set b}\n {R : B.Rel A ℓ₁} {S : IRel B ℓ₂} where\n\n private\n R×S = Pointwise B R S\n\n refl : B.Reflexive R → I.Reflexive B S → B.Reflexive R×S\n refl refl₁ refl₂ = (refl₁ , refl₂)\n\n symmetric : B.Symmetric R → I.Symmetric B S → B.Symmetric R×S\n symmetric sym₁ sym₂ (x₁Rx₂ , y₁Ry₂) = (sym₁ x₁Rx₂ , sym₂ y₁Ry₂)\n\n transitive : B.Transitive R → I.Transitive B S → B.Transitive R×S\n transitive trans₁ trans₂ (x₁Rx₂ , y₁Ry₂) (x₂Rx₃ , y₂Ry₃) =\n (trans₁ x₁Rx₂ x₂Rx₃ , trans₂ y₁Ry₂ y₂Ry₃)\n\n isEquivalence : IsEquivalence R → IsIndexedEquivalence B S →\n IsEquivalence R×S\n isEquivalence eq₁ eq₂ = record\n { refl = refl Eq.refl IEq.refl\n ; sym = symmetric Eq.sym IEq.sym\n ; trans = transitive Eq.trans IEq.trans\n } where\n module Eq = IsEquivalence eq₁\n module IEq = IsIndexedEquivalence eq₂\n\nmodule _ {a b ℓ₁ ℓ₂} where\n\n setoid : (A : Setoid a ℓ₁) →\n IndexedSetoid (Setoid.Carrier A) b ℓ₂ →\n Setoid _ _\n setoid s₁ s₂ = record\n { isEquivalence = isEquivalence Eq.isEquivalence IEq.isEquivalence\n } where\n module Eq = Setoid s₁\n module IEq = IndexedSetoid s₂\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\nRel = Pointwise\n{-# WARNING_ON_USAGE Rel\n\"Warning: Rel was deprecated in v0.15.\nPlease use Pointwise instead.\"\n#-}\n\n-- Version 0.15\n\nREL = POINTWISE\n{-# WARNING_ON_USAGE REL\n\"Warning: REL was deprecated in v1.0.\nPlease use POINTWISE instead.\"\n#-}\n", "meta": {"hexsha": "95bda87ed8be9eed2fb37e55e17b951a89877010", "size": 3189, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/Dependent.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/Product/Relation/Binary/Pointwise/Dependent.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/Product/Relation/Binary/Pointwise/Dependent.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.9611650485, "max_line_length": 72, "alphanum_fraction": 0.5572279712, "num_tokens": 973, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711718571775, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5887257126897936}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Categories.Category\n\nmodule Categories.Object.Product.Core {o ℓ e} (𝒞 : Category o ℓ e) where\n\nopen import Level\nopen import Function using (flip; _$_)\n\nopen import Categories.Morphism 𝒞\nopen import Categories.Morphism.Reasoning 𝒞\n\nopen Category 𝒞\nopen HomReasoning\n\nprivate\n variable\n A B C D X Y Z : Obj\n h i j : A ⇒ B\n\n-- Borrowed from Dan Doel's definition of products\nrecord Product (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where\n\n infix 10 ⟨_,_⟩\n\n field\n A×B : Obj\n π₁ : A×B ⇒ A\n π₂ : A×B ⇒ B\n ⟨_,_⟩ : C ⇒ A → C ⇒ B → C ⇒ A×B\n\n project₁ : π₁ ∘ ⟨ h , i ⟩ ≈ h\n project₂ : π₂ ∘ ⟨ h , i ⟩ ≈ i\n unique : π₁ ∘ h ≈ i → π₂ ∘ h ≈ j → ⟨ i , j ⟩ ≈ h\n\n g-η : ⟨ π₁ ∘ h , π₂ ∘ h ⟩ ≈ h\n g-η = unique refl refl\n\n η : ⟨ π₁ , π₂ ⟩ ≈ id\n η = unique identityʳ identityʳ\n\n ⟨⟩-cong₂ : ∀ {f f′ : C ⇒ A} {g g′ : C ⇒ B} → f ≈ f′ → g ≈ g′ → ⟨ f , g ⟩ ≈ ⟨ f′ , g′ ⟩\n ⟨⟩-cong₂ f≡f′ g≡g′ = unique (project₁ ○ ⟺ f≡f′) (project₂ ○ ⟺ g≡g′)\n\n ∘-distribʳ-⟨⟩ : ∀ {f : C ⇒ A} {g : C ⇒ B} {q : D ⇒ C} → ⟨ f , g ⟩ ∘ q ≈ ⟨ f ∘ q , g ∘ q ⟩\n ∘-distribʳ-⟨⟩ = ⟺ $ unique (pullˡ project₁) (pullˡ project₂)\n\n unique′ : π₁ ∘ h ≈ π₁ ∘ i → π₂ ∘ h ≈ π₂ ∘ i → h ≈ i\n unique′ eq₁ eq₂ = trans (sym (unique eq₁ eq₂)) g-η\n\nmodule _ {A B : Obj} where\n open Product {A} {B} renaming (⟨_,_⟩ to _⟨_,_⟩)\n\n repack : (p₁ p₂ : Product A B) → A×B p₁ ⇒ A×B p₂\n repack p₁ p₂ = p₂ ⟨ π₁ p₁ , π₂ p₁ ⟩\n\n repack∘ : (p₁ p₂ p₃ : Product A B) → repack p₂ p₃ ∘ repack p₁ p₂ ≈ repack p₁ p₃\n repack∘ p₁ p₂ p₃ = ⟺ $ unique p₃\n (glueTrianglesʳ (project₁ p₃) (project₁ p₂))\n (glueTrianglesʳ (project₂ p₃) (project₂ p₂))\n\n repack≡id : (p : Product A B) → repack p p ≈ id\n repack≡id = η\n\n repack-cancel : (p₁ p₂ : Product A B) → repack p₁ p₂ ∘ repack p₂ p₁ ≈ id\n repack-cancel p₁ p₂ = repack∘ p₂ p₁ p₂ ○ repack≡id p₂\n\nup-to-iso : ∀ (p₁ p₂ : Product A B) → Product.A×B p₁ ≅ Product.A×B p₂\nup-to-iso p₁ p₂ = record\n { from = repack p₁ p₂\n ; to = repack p₂ p₁\n ; iso = record\n { isoˡ = repack-cancel p₂ p₁\n ; isoʳ = repack-cancel p₁ p₂\n }\n }\n\ntransport-by-iso : ∀ (p : Product A B) → ∀ {X} → Product.A×B p ≅ X → Product A B\ntransport-by-iso p {X} p≅X = record\n { A×B = X\n ; π₁ = π₁ ∘ to\n ; π₂ = π₂ ∘ to\n ; ⟨_,_⟩ = λ h₁ h₂ → from ∘ ⟨ h₁ , h₂ ⟩\n ; project₁ = cancelInner isoˡ ○ project₁\n ; project₂ = cancelInner isoˡ ○ project₂\n ; unique = λ {_ i l r} pf₁ pf₂ → begin\n from ∘ ⟨ l , r ⟩ ≈˘⟨ refl⟩∘⟨ ⟨⟩-cong₂ pf₁ pf₂ ⟩\n from ∘ ⟨ (π₁ ∘ to) ∘ i , (π₂ ∘ to) ∘ i ⟩ ≈⟨ refl⟩∘⟨ unique (⟺ assoc) (⟺ assoc) ⟩\n from ∘ to ∘ i ≈⟨ cancelˡ isoʳ ⟩\n i ∎\n }\n where open Product p\n open _≅_ p≅X\n\nReversible : (p : Product A B) → Product B A\nReversible p = record\n { A×B = A×B\n ; π₁ = π₂\n ; π₂ = π₁\n ; ⟨_,_⟩ = flip ⟨_,_⟩\n ; project₁ = project₂\n ; project₂ = project₁\n ; unique = flip unique\n }\n where open Product p\n\nCommutative : (p₁ : Product A B) (p₂ : Product B A) → Product.A×B p₁ ≅ Product.A×B p₂\nCommutative p₁ p₂ = up-to-iso p₁ (Reversible p₂)\n\nAssociable : ∀ (p₁ : Product X Y) (p₂ : Product Y Z) (p₃ : Product X (Product.A×B p₂)) → Product (Product.A×B p₁) Z\nAssociable p₁ p₂ p₃ = record\n { A×B = A×B p₃\n ; π₁ = p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩\n ; π₂ = π₂ p₂ ∘ π₂ p₃\n ; ⟨_,_⟩ = λ f g → p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩\n ; project₁ = λ {_ f g} → begin\n p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩ ∘ p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩ ≈⟨ ∘-distribʳ-⟨⟩ p₁ ⟩\n p₁ ⟨ π₁ p₃ ∘ p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩\n , (π₁ p₂ ∘ π₂ p₃) ∘ p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₁ (project₁ p₃) (glueTrianglesˡ (project₁ p₂) (project₂ p₃)) ⟩\n p₁ ⟨ π₁ p₁ ∘ f , π₂ p₁ ∘ f ⟩ ≈⟨ g-η p₁ ⟩\n f ∎\n ; project₂ = λ {_ f g} → glueTrianglesˡ (project₂ p₂) (project₂ p₃)\n ; unique = λ {_ i f g} pf₁ pf₂ → begin\n p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₃ (∘-resp-≈ʳ (sym pf₁))\n (⟨⟩-cong₂ p₂ (∘-resp-≈ʳ (sym pf₁)) (sym pf₂)) ⟩\n p₃ ⟨ π₁ p₁ ∘ p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩ ∘ i\n , p₂ ⟨ π₂ p₁ ∘ p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩ ∘ i\n , (π₂ p₂ ∘ π₂ p₃) ∘ i ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₃ (pullˡ (project₁ p₁))\n (⟨⟩-cong₂ p₂ (trans (pullˡ (project₂ p₁)) assoc)\n assoc) ⟩\n p₃ ⟨ π₁ p₃ ∘ i\n , p₂ ⟨ π₁ p₂ ∘ π₂ p₃ ∘ i , π₂ p₂ ∘ π₂ p₃ ∘ i ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₃ refl (g-η p₂) ⟩\n p₃ ⟨ π₁ p₃ ∘ i , π₂ p₃ ∘ i ⟩ ≈⟨ g-η p₃ ⟩\n i ∎\n }\n where open Product renaming (⟨_,_⟩ to _⟨_,_⟩)\n\nAssociative : ∀ (p₁ : Product X Y) (p₂ : Product Y Z)\n (p₃ : Product X (Product.A×B p₂)) (p₄ : Product (Product.A×B p₁) Z) →\n (Product.A×B p₃) ≅ (Product.A×B p₄)\nAssociative p₁ p₂ p₃ p₄ = up-to-iso (Associable p₁ p₂ p₃) p₄\n\nMobile : ∀ {A₁ B₁ A₂ B₂} (p : Product A₁ B₁) → A₁ ≅ A₂ → B₁ ≅ B₂ → Product A₂ B₂\nMobile p A₁≅A₂ B₁≅B₂ = record\n { A×B = A×B\n ; π₁ = from A₁≅A₂ ∘ π₁\n ; π₂ = from B₁≅B₂ ∘ π₂\n ; ⟨_,_⟩ = λ h k → ⟨ to A₁≅A₂ ∘ h , to B₁≅B₂ ∘ k ⟩\n ; project₁ = begin\n (from A₁≅A₂ ∘ π₁) ∘ ⟨ to A₁≅A₂ ∘ _ , to B₁≅B₂ ∘ _ ⟩ ≈⟨ pullʳ project₁ ⟩\n from A₁≅A₂ ∘ (to A₁≅A₂ ∘ _) ≈⟨ cancelˡ (isoʳ A₁≅A₂) ⟩\n _ ∎\n ; project₂ = begin\n (from B₁≅B₂ ∘ π₂) ∘ ⟨ to A₁≅A₂ ∘ _ , to B₁≅B₂ ∘ _ ⟩ ≈⟨ pullʳ project₂ ⟩\n from B₁≅B₂ ∘ (to B₁≅B₂ ∘ _) ≈⟨ cancelˡ (isoʳ B₁≅B₂) ⟩\n _ ∎\n ; unique = λ pfˡ pfʳ → unique (switch-fromtoˡ A₁≅A₂ (⟺ assoc ○ pfˡ))\n (switch-fromtoˡ B₁≅B₂ (⟺ assoc ○ pfʳ))\n }\n where open Product p\n open _≅_\n", "meta": {"hexsha": "5c528c05dfd44b7c22d32e29467fb883eba4db40", "size": 6137, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Object/Product/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/Object/Product/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/Object/Product/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": 38.1180124224, "max_line_length": 150, "alphanum_fraction": 0.4544565749, "num_tokens": 2799, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84997116805678, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.5887257100574789}} {"text": "module Data.Num.Binary where\n\n\n-- open import Data.Product using (_×_; Σ; _,_)\nopen import Data.List\nopen import Data.Unit\nopen import Data.Empty\n-- open import Data.Nat renaming (_+_ to _⊹_)\n--\n-- data Bin : Set where\n-- [] : Bin\n-- 0- : Bin → Bin\n-- 1- : Bin → Bin\n--\n-- carry : Bin → Bin\n-- carry [] = 1- []\n-- carry (0- xs) = 1- xs\n-- carry (1- xs) = 0- (carry xs)\n--\n-- _+_ : Bin → Bin → Bin\n-- [] + ys = ys\n-- xs + [] = xs\n-- 0- xs + 0- ys = 0- (xs + ys)\n-- 0- xs + 1- ys = 1- (xs + ys)\n-- 1- xs + 0- ys = 1- (xs + ys)\n-- 1- xs + 1- ys = 0- (carry (xs + ys))\n--\n\n-- data Desc : Set₁ where\n-- arg : (A : Set) -- a bag of tags to choose constructors with\n-- → (A → Desc) -- given a tag, return the description of the constructor it corresponds to\n-- → Desc\n-- rec : Desc → Desc -- recursive subnode\n-- ret : Desc -- stop\n--\n-- -- the \"decoder\", \"interpreter\"\n-- -- ⟦_⟧ : Desc → Set → Set\n-- -- ⟦ arg A D ⟧ R = Σ A (λ a → ⟦ D a ⟧ R)\n-- -- ⟦ rec D ⟧ R = R × ⟦ D ⟧ R\n-- -- ⟦ ret ⟧ R = ⊤\n\n-- data BinF : Set where\n-- arg : (ℕ → BinF) → BinF\n-- rec : BinF → BinF\n-- ret : BinF\n--\n-- ⟦_⟧ : BinF → Set → Set\n-- ⟦_⟧ (arg F) X = Σ ℕ (λ n → ⟦ F n ⟧ X)\n-- ⟦_⟧ (rec F) X = X × ⟦ F ⟧ X\n-- ⟦_⟧ ret X = ⊤\n--\n-- data μ (F : BinF) : Set where\n-- ⟨_⟩ : ⟦ F ⟧ (μ F) → μ F\n--\n-- Bin : Set\n-- Bin = μ (arg {! λ !})\n\n--\n-- data Digit : Set where\n-- [0] : Digit\n-- [1] : Digit\n--\n-- Binary : Set\n-- Binary = List Digit\n--\n-- _⊕_ : Digit → Digit → Digit\n-- [0] ⊕ [0] = [0]\n-- [0] ⊕ [1] = [1]\n-- [1] ⊕ [0] = [1]\n-- [1] ⊕ [1] = [0]\n--\n-- _⊚_ : Digit → Digit → Digit\n-- [1] ⊚ [1] = [1]\n-- _ ⊚ _ = [0]\n--\n-- carry : Digit → Binary → Binary\n-- carry [0] ys = ys\n-- carry [1] [] = [1] ∷ []\n-- carry [1] ([0] ∷ ys) = [1] ∷ ys\n-- carry [1] ([1] ∷ ys) = [0] ∷ carry [1] ys\n--\n-- _+_ : Binary → Binary → Binary\n-- [] + ys = ys\n-- xs + [] = xs\n-- (x ∷ xs) + (y ∷ ys) = x ⊕ y ∷ carry (x ⊚ y) (xs + ys)\n--\n-- _≈_ : Binary → Binary → Set\n-- [] ≈ [] = ⊤\n-- [] ≈ (y ∷ ys) = ⊥\n-- (x ∷ xs) ≈ [] = ⊥\n-- ([0] ∷ xs) ≈ ([0] ∷ ys) = xs ≈ ys\n-- ([0] ∷ xs) ≈ ([1] ∷ ys) = ⊥\n-- ([1] ∷ xs) ≈ ([0] ∷ ys) = ⊥\n-- ([1] ∷ xs) ≈ ([1] ∷ ys) = xs ≈ ys\n\ndata Bin : Set where\n ∙ : Bin\n [0]_ : Bin → Bin\n [1]_ : Bin → Bin\n\ntwo : Bin\ntwo = [1] [0] ∙\n\n1+ : Bin → Bin\n1+ ∙ = [1] ∙\n1+ ([0] x) = [1] x\n1+ ([1] x) = [0] 1+ x\n\n_+_ : Bin → Bin → Bin\n∙ + ys = ys\nxs + ∙ = xs\n([0] xs) + ([0] ys) = [0] (xs + ys)\n([0] xs) + ([1] ys) = [1] (xs + ys)\n([1] xs) + ([0] ys) = [1] (xs + ys)\n([1] xs) + ([1] ys) = [0] (1+ (xs + ys))\n", "meta": {"hexsha": "825103b23d51003f8512f47d6ee4a8faefa33221", "size": 2592, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Num/Sandbox/Binary.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/Binary.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/Binary.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": 22.3448275862, "max_line_length": 110, "alphanum_fraction": 0.3989197531, "num_tokens": 1171, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127603871312, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.5886068619796143}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Ring.Kernel where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Powerset\n\nopen import Cubical.Algebra.Ring.Base\nopen import Cubical.Algebra.Ring.Properties\nopen import Cubical.Algebra.Ring.Ideal\n\nprivate\n variable\n ℓ : Level\n\nmodule _ {{R S : Ring {ℓ}}} (f′ : RingHom R S) where\n open RingHom f′\n open HomTheory f′\n open RingStr ⦃...⦄\n open isIdeal\n open Theory\n private\n instance\n _ = R\n _ = S\n _ = snd R\n _ = snd S\n\n kernel : ⟨ R ⟩ → hProp ℓ\n kernel x = (f x ≡ 0r) , isSetRing S _ _\n\n kernelIsIdeal : isIdeal R kernel\n +-closed kernelIsIdeal =\n λ fx≡0 fy≡0 → f (_ + _) ≡⟨ isHom+ _ _ ⟩\n f _ + f _ ≡⟨ cong (λ u → u + f _) fx≡0 ⟩\n 0r + f _ ≡⟨ cong (λ u → 0r + u) fy≡0 ⟩\n 0r + 0r ≡⟨ 0-idempotent S ⟩\n 0r ∎\n -closed kernelIsIdeal =\n λ fx≡0 → f (- _) ≡⟨ -commutesWithHom _ ⟩\n - f _ ≡⟨ cong -_ fx≡0 ⟩\n - 0r ≡⟨ 0-selfinverse S ⟩\n 0r ∎\n 0r-closed kernelIsIdeal = f 0r ≡⟨ homPres0 ⟩ 0r ∎\n ·-closedLeft kernelIsIdeal = λ r fx≡0 →\n f (r · _) ≡⟨ isHom· _ _ ⟩\n f r · f (_) ≡⟨ cong (λ u → f r · u) fx≡0 ⟩\n f r · 0r ≡⟨ 0-rightNullifies S _ ⟩\n 0r ∎\n ·-closedRight kernelIsIdeal = λ r fx≡0 →\n f (_ · r) ≡⟨ isHom· _ _ ⟩\n f _ · f r ≡⟨ cong (λ u → u · f r) fx≡0 ⟩\n 0r · f r ≡⟨ 0-leftNullifies S _ ⟩\n 0r ∎\n", "meta": {"hexsha": "a146f89ccc858025434b05890c50382f0b9766e6", "size": 1623, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Ring/Kernel.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/Ring/Kernel.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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/Algebra/Ring/Kernel.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": 28.4736842105, "max_line_length": 59, "alphanum_fraction": 0.5465187924, "num_tokens": 658, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127603871312, "lm_q2_score": 0.6893056040203136, "lm_q1q2_score": 0.5886068510793048}} {"text": "{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-}\n\nmodule 17-groups where\n\nimport 16-sets\nopen 16-sets public\n\n-- Section 12.3 Groups in univalent mathematics\n\n{- We first introduce semi-groups, and then groups. We do this because the\n category of groups is a full subcategory of the category of semi-groups.\n In particular, it is a proposition for a semi-group to be a group. Therefore\n this approach gives us in a straightforward way that equality of groups is \n equality of semi-groups. This will be useful in showing that group \n isomorphisms are equivalent to identifications of groups. -}\n\nhas-associative-mul :\n {l : Level} (X : UU-Set l) → UU l\nhas-associative-mul X =\n Σ ( ( type-Set X) →\n ( ( type-Set X) → (type-Set X))) (λ μ →\n ( x y z : type-Set X) → Id (μ (μ x y) z) (μ x (μ y z)))\n\nSemi-Group :\n (l : Level) → UU (lsuc l)\nSemi-Group l = Σ (UU-Set l) has-associative-mul\n\n{- Bureaucracy of semi-groups. -}\n\nset-Semi-Group :\n {l : Level} → Semi-Group l → UU-Set l\nset-Semi-Group G = pr1 G\n\ntype-Semi-Group :\n {l : Level} → Semi-Group l → UU l\ntype-Semi-Group G = pr1 (set-Semi-Group G)\n\nis-set-type-Semi-Group :\n {l : Level} (G : Semi-Group l) → is-set (type-Semi-Group G)\nis-set-type-Semi-Group G = pr2 (set-Semi-Group G)\n\nassociative-mul-Semi-Group :\n {l : Level} (G : Semi-Group l) →\n has-associative-mul (set-Semi-Group G)\nassociative-mul-Semi-Group G = pr2 G\n\nmul-Semi-Group :\n {l : Level} (G : Semi-Group l) →\n type-Semi-Group G →\n type-Semi-Group G → type-Semi-Group G\nmul-Semi-Group G = pr1 (associative-mul-Semi-Group G)\n\nis-associative-mul-Semi-Group :\n {l : Level} (G : Semi-Group l) (x y z : type-Semi-Group G) →\n Id ( mul-Semi-Group G (mul-Semi-Group G x y) z)\n ( mul-Semi-Group G x (mul-Semi-Group G y z))\nis-associative-mul-Semi-Group G = pr2 (associative-mul-Semi-Group G)\n\n{- The property that a semi-group is a monoid is just that the semi-group \n possesses a unit that satisfies the left and right unit laws. -}\n\nis-unital :\n {l : Level} → Semi-Group l → UU l\nis-unital G =\n Σ ( type-Semi-Group G)\n ( λ e →\n ( (y : type-Semi-Group G) → Id (mul-Semi-Group G e y) y) ×\n ( (x : type-Semi-Group G) → Id (mul-Semi-Group G x e) x))\n\n{- We show that is-unital is a proposition. -}\n\nabstract\n is-prop-is-unital' :\n {l : Level} (G : Semi-Group l) → is-prop' (is-unital G)\n is-prop-is-unital' (pair (pair X is-set-X) (pair μ assoc-μ))\n (pair e (pair left-unit-e right-unit-e))\n (pair e' (pair left-unit-e' right-unit-e')) =\n eq-subtype\n ( λ e → is-prop-prod\n ( is-prop-Π (λ y → is-set-X (μ e y) y))\n ( is-prop-Π (λ x → is-set-X (μ x e) x)))\n ( (inv (left-unit-e' e)) ∙ (right-unit-e e'))\n\nabstract\n is-prop-is-unital :\n {l : Level} (G : Semi-Group l) → is-prop (is-unital G)\n is-prop-is-unital G = is-prop-is-prop' (is-prop-is-unital' G)\n\n{- The property that a monoid is a group is just the property that the monoid\n that every element is invertible, i.e., it comes equipped with an inverse\n operation that satisfies the left and right inverse laws. -}\n\nis-group' :\n {l : Level} (G : Semi-Group l) → is-unital G → UU l\nis-group' G is-unital-G =\n Σ ( type-Semi-Group G → type-Semi-Group G)\n ( λ i →\n ( (x : type-Semi-Group G) →\n Id (mul-Semi-Group G (i x) x) (pr1 is-unital-G)) ×\n ( (x : type-Semi-Group G) →\n Id (mul-Semi-Group G x (i x)) (pr1 is-unital-G)))\n\nis-group :\n {l : Level} (G : Semi-Group l) → UU l\nis-group G =\n Σ (is-unital G) (is-group' G)\n\nGroup :\n (l : Level) → UU (lsuc l)\nGroup l = Σ (Semi-Group l) is-group\n\n{- Some bureaucracy of Groups. -}\n\nsemi-group-Group :\n {l : Level} → Group l → Semi-Group l\nsemi-group-Group G = pr1 G\n\nset-Group :\n {l : Level} → Group l → UU-Set l\nset-Group G = pr1 (semi-group-Group G)\n\ntype-Group :\n {l : Level} → Group l → UU l\ntype-Group G = pr1 (set-Group G)\n\nis-set-type-Group :\n {l : Level} (G : Group l) → is-set (type-Group G)\nis-set-type-Group G = pr2 (set-Group G)\n\nassociative-mul-Group :\n {l : Level} (G : Group l) → has-associative-mul (set-Group G)\nassociative-mul-Group G = pr2 (semi-group-Group G)\n\nmul-Group :\n {l : Level} (G : Group l) →\n type-Group G → type-Group G → type-Group G\nmul-Group G = pr1 (associative-mul-Group G)\n\nis-associative-mul-Group :\n {l : Level} (G : Group l) (x y z : type-Group G) →\n Id (mul-Group G (mul-Group G x y) z) (mul-Group G x (mul-Group G y z))\nis-associative-mul-Group G = pr2 (associative-mul-Group G)\n\nis-group-Group :\n {l : Level} (G : Group l) → is-group (semi-group-Group G)\nis-group-Group G = pr2 G\n\nis-unital-Group :\n {l : Level} (G : Group l) → is-unital (semi-group-Group G)\nis-unital-Group G = pr1 (is-group-Group G)\n\nunit-Group :\n {l : Level} (G : Group l) → type-Group G\nunit-Group G = pr1 (is-unital-Group G)\n\nleft-unit-law-Group :\n {l : Level} (G : Group l) (x : type-Group G) →\n Id (mul-Group G (unit-Group G) x) x\nleft-unit-law-Group G = pr1 (pr2 (is-unital-Group G))\n\nright-unit-law-Group :\n {l : Level} (G : Group l) (x : type-Group G) →\n Id (mul-Group G x (unit-Group G)) x\nright-unit-law-Group G = pr2 (pr2 (is-unital-Group G))\n\nhas-inverses-Group :\n {l : Level} (G : Group l) →\n is-group' (semi-group-Group G) (is-unital-Group G)\nhas-inverses-Group G = pr2 (is-group-Group G)\n\ninv-Group :\n {l : Level} (G : Group l) →\n type-Group G → type-Group G\ninv-Group G = pr1 (has-inverses-Group G)\n\nleft-inverse-law-Group :\n {l : Level} (G : Group l) (x : type-Group G) →\n Id (mul-Group G (inv-Group G x) x) (unit-Group G)\nleft-inverse-law-Group G = pr1 (pr2 (has-inverses-Group G))\n\nright-inverse-law-Group :\n {l : Level} (G : Group l) (x : type-Group G) →\n Id (mul-Group G x (inv-Group G x)) (unit-Group G)\nright-inverse-law-Group G = pr2 (pr2 (has-inverses-Group G))\n\n{- We show that being a group is a proposition. -}\n\nabstract\n is-prop-is-group' :\n {l : Level} (G : Semi-Group l) (e : is-unital G) → is-prop' (is-group' G e)\n is-prop-is-group'\n ( pair (pair G is-set-G) (pair μ assoc-G))\n ( pair e (pair left-unit-G right-unit-G))\n ( pair i (pair left-inv-i right-inv-i))\n ( pair i' (pair left-inv-i' right-inv-i')) =\n eq-subtype\n ( λ i →\n is-prop-prod\n ( is-prop-Π (λ x → is-set-G (μ (i x) x) e))\n ( is-prop-Π (λ x → is-set-G (μ x (i x)) e)))\n ( eq-htpy\n ( λ x → -- ix\n ( inv (left-unit-G (i x))) ∙ -- = 1·(ix)\n ( ( ap (λ y → μ y (i x)) (inv (left-inv-i' x))) ∙ -- = (i'x·x)·(ix)\n ( ( assoc-G (i' x) x (i x)) ∙ -- = (i'x)·(x·i'x)\n ( ( ap (μ (i' x)) (right-inv-i x)) ∙ -- = (i'x)·1\n ( right-unit-G (i' x))))))) -- = i'x\n\nabstract\n is-prop-is-group :\n {l : Level} (G : Semi-Group l) → is-prop (is-group G)\n is-prop-is-group G =\n is-prop-Σ\n ( is-prop-is-unital G)\n ( λ e → is-prop-is-prop' (is-prop-is-group' G e))\n\n{- We give two examples of groups. The first is the group ℤ of integers. The\n second is the loop space of a pointed 1-type. -}\n\n{- The group of integers. -}\n\nsemi-group-ℤ : Semi-Group lzero\nsemi-group-ℤ = pair set-ℤ (pair add-ℤ associative-add-ℤ)\n\ngroup-ℤ : Group lzero\ngroup-ℤ =\n pair\n ( semi-group-ℤ)\n ( pair\n ( pair zero-ℤ (pair left-unit-law-add-ℤ right-unit-law-add-ℤ))\n ( pair neg-ℤ (pair left-inverse-law-add-ℤ right-inverse-law-add-ℤ)))\n\n{- The loop space of a 1-type as a group. -}\n\nloop-space :\n {l : Level} {A : UU l} → A → UU l\nloop-space a = Id a a\n\nset-loop-space :\n {l : Level} (A : UU l) (a : A) (is-set-Ω : is-set (Id a a)) → UU-Set l\nset-loop-space A a is-set-Ω = pair (Id a a) is-set-Ω\n\nsemi-group-loop-space :\n {l : Level} (A : UU l) (a : A) (is-set-Ω : is-set (Id a a)) → Semi-Group l\nsemi-group-loop-space A a is-set-Ω =\n pair\n ( set-loop-space A a is-set-Ω)\n ( pair (λ p q → p ∙ q) assoc)\n\ngroup-loop-space :\n {l : Level} (A : UU l) (a : A) (is-set-Ω : is-set (Id a a)) → Group l\ngroup-loop-space A a is-set-Ω =\n pair\n ( semi-group-loop-space A a is-set-Ω)\n ( pair\n ( pair refl (pair (λ q → left-unit) (λ p → right-unit)))\n ( pair inv (pair left-inv right-inv)))\n\nset-loop-space-1-type :\n {l : Level} (A : 1-type l) (a : pr1 A) → UU-Set l\nset-loop-space-1-type (pair A is-1-type-A) a =\n set-loop-space A a (is-1-type-A a a)\n\nsemi-group-loop-space-1-type :\n {l : Level} (A : 1-type l) (a : pr1 A) → Semi-Group l\nsemi-group-loop-space-1-type (pair A is-1-type-A) a =\n semi-group-loop-space A a (is-1-type-A a a)\n\ngroup-loop-space-1-type :\n {l : Level} (A : 1-type l) (a : pr1 A) → Group l\ngroup-loop-space-1-type (pair A is-1-type-A) a =\n group-loop-space A a (is-1-type-A a a)\n\n{- We introduce the automorphism group on a set X. -}\n\naut-Set :\n {l : Level} (X : UU-Set l) → UU-Set l\naut-Set X = set-equiv X X\n\nassociative-comp-equiv :\n {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {C : UU l3} {D : UU l4} →\n (e : A ≃ B) (f : B ≃ C) (g : C ≃ D) →\n Id ((g ∘e f) ∘e e) (g ∘e (f ∘e e))\nassociative-comp-equiv e f g = eq-htpy-equiv refl-htpy\n\nhas-associative-mul-aut-Set :\n {l : Level} (X : UU-Set l) → has-associative-mul (aut-Set X)\nhas-associative-mul-aut-Set X =\n pair\n ( λ e f → f ∘e e)\n ( λ e f g → inv (associative-comp-equiv e f g))\n\naut-Semi-Group :\n {l : Level} (X : UU-Set l) → Semi-Group l\naut-Semi-Group X =\n pair\n ( aut-Set X)\n ( has-associative-mul-aut-Set X)\n\nleft-unit-law-equiv :\n {l1 l2 : Level} {X : UU l1} {Y : UU l2} (e : X ≃ Y) →\n Id ((equiv-id Y) ∘e e) e\nleft-unit-law-equiv e = eq-htpy-equiv refl-htpy\n\nright-unit-law-equiv :\n {l1 l2 : Level} {X : UU l1} {Y : UU l2} (e : X ≃ Y) →\n Id (e ∘e (equiv-id X)) e\nright-unit-law-equiv e = eq-htpy-equiv refl-htpy\n\nis-unital-aut-Semi-Group :\n {l : Level} (X : UU-Set l) → is-unital (aut-Semi-Group X)\nis-unital-aut-Semi-Group X =\n pair\n ( equiv-id (type-Set X))\n ( pair\n ( right-unit-law-equiv)\n ( left-unit-law-equiv))\n\nleft-inverse-law-equiv :\n {l1 l2 : Level} {X : UU l1} {Y : UU l2} (e : X ≃ Y) →\n Id ((inv-equiv e) ∘e e) (equiv-id X)\nleft-inverse-law-equiv e =\n eq-htpy-equiv (isretr-inv-is-equiv (is-equiv-map-equiv e))\n\nright-inverse-law-equiv :\n {l1 l2 : Level} {X : UU l1} {Y : UU l2} (e : X ≃ Y) →\n Id (e ∘e (inv-equiv e)) (equiv-id Y)\nright-inverse-law-equiv e =\n eq-htpy-equiv (issec-inv-is-equiv (is-equiv-map-equiv e))\n\nis-group-aut-Semi-Group' :\n {l : Level} (X : UU-Set l) →\n is-group' (aut-Semi-Group X) (is-unital-aut-Semi-Group X)\nis-group-aut-Semi-Group' X =\n pair\n ( inv-equiv)\n ( pair right-inverse-law-equiv left-inverse-law-equiv)\n\naut-Group :\n {l : Level} → UU-Set l → Group l\naut-Group X =\n pair\n ( aut-Semi-Group X)\n ( pair (is-unital-aut-Semi-Group X) (is-group-aut-Semi-Group' X))\n\n{- Now we introduce homomorphisms of semi-groups. Group homomorphisms are just\n homomorphisms between their underlying semi-groups. -}\n\npreserves-mul :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n (type-Semi-Group G → type-Semi-Group H) → UU (l1 ⊔ l2)\npreserves-mul G H f =\n (x y : type-Semi-Group G) →\n Id (f (mul-Semi-Group G x y)) (mul-Semi-Group H (f x) (f y))\n\nabstract\n is-prop-preserves-mul :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : type-Semi-Group G → type-Semi-Group H) →\n is-prop (preserves-mul G H f)\n is-prop-preserves-mul G (pair (pair H is-set-H) (pair μ-H assoc-H)) f =\n is-prop-Π (λ x →\n is-prop-Π (λ y →\n is-set-H (f (mul-Semi-Group G x y)) (μ-H (f x) (f y))))\n\nhom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) → UU (l1 ⊔ l2)\nhom-Semi-Group G H =\n Σ ( type-Semi-Group G → type-Semi-Group H)\n ( preserves-mul G H)\n\n{- Bureaucracy of homomorphisms of semi-groups. -}\n\nmap-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( hom-Semi-Group G H) →\n ( type-Semi-Group G) → (type-Semi-Group H)\nmap-hom-Semi-Group G H f = pr1 f\n\npreserves-mul-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) →\n preserves-mul G H (map-hom-Semi-Group G H f)\npreserves-mul-hom-Semi-Group G H f = pr2 f\n\n{- We characterize the identity type of the semi-group homomorphisms. -}\n\nhtpy-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2)\n (f g : hom-Semi-Group G H) → UU (l1 ⊔ l2)\nhtpy-hom-Semi-Group G H f g =\n (map-hom-Semi-Group G H f) ~ (map-hom-Semi-Group G H g)\n\nreflexive-htpy-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) → htpy-hom-Semi-Group G H f f\nreflexive-htpy-hom-Semi-Group G H f = refl-htpy\n\nhtpy-hom-Semi-Group-eq :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f g : hom-Semi-Group G H) → Id f g → htpy-hom-Semi-Group G H f g\nhtpy-hom-Semi-Group-eq G H f .f refl = reflexive-htpy-hom-Semi-Group G H f \n\nabstract\n is-contr-total-htpy-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) →\n is-contr (Σ (hom-Semi-Group G H) (htpy-hom-Semi-Group G H f))\n is-contr-total-htpy-hom-Semi-Group G H f =\n is-contr-total-Eq-substructure\n ( is-contr-total-htpy (map-hom-Semi-Group G H f))\n ( is-prop-preserves-mul G H)\n ( map-hom-Semi-Group G H f)\n ( refl-htpy)\n ( preserves-mul-hom-Semi-Group G H f)\n\nabstract\n is-equiv-htpy-hom-Semi-Group-eq :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f g : hom-Semi-Group G H) → is-equiv (htpy-hom-Semi-Group-eq G H f g)\n is-equiv-htpy-hom-Semi-Group-eq G H f =\n fundamental-theorem-id f\n ( reflexive-htpy-hom-Semi-Group G H f)\n ( is-contr-total-htpy-hom-Semi-Group G H f)\n ( htpy-hom-Semi-Group-eq G H f)\n\neq-htpy-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n { f g : hom-Semi-Group G H} → htpy-hom-Semi-Group G H f g → Id f g\neq-htpy-hom-Semi-Group G H {f} {g} =\n inv-is-equiv (is-equiv-htpy-hom-Semi-Group-eq G H f g)\n\n{- We show that the type of semi-group homomorphisms between two semi-groups is\n a set. -}\n\nis-set-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n is-set (hom-Semi-Group G H)\nis-set-hom-Semi-Group G H (pair f μ-f) (pair g μ-g) =\n is-prop-is-equiv\n ( htpy-hom-Semi-Group G H (pair f μ-f) (pair g μ-g))\n ( htpy-hom-Semi-Group-eq G H (pair f μ-f) (pair g μ-g))\n ( is-equiv-htpy-hom-Semi-Group-eq G H (pair f μ-f) (pair g μ-g))\n ( is-prop-Π (λ x → is-set-type-Semi-Group H (f x) (g x)))\n\n{- We introduce group homomorphisms. -}\n\nhom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) → UU (l1 ⊔ l2)\nhom-Group G H =\n hom-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)\n\n{- Bureaucracy of group homomorphisms. -}\n\nmap-hom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( hom-Group G H) →\n ( type-Group G) → (type-Group H)\nmap-hom-Group G H f = pr1 f\n\npreserves-mul-hom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Group G H) →\n preserves-mul\n ( semi-group-Group G)\n ( semi-group-Group H)\n ( map-hom-Group G H f)\npreserves-mul-hom-Group G H f = pr2 f\n\n{- We characterize the identity type of the group homomorphisms. -}\n\nhtpy-hom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2)\n (f g : hom-Group G H) → UU (l1 ⊔ l2)\nhtpy-hom-Group G H =\n htpy-hom-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)\n\nreflexive-htpy-hom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Group G H) → htpy-hom-Group G H f f\nreflexive-htpy-hom-Group G H =\n reflexive-htpy-hom-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)\n\nhtpy-hom-Group-eq :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f g : hom-Group G H) → Id f g → htpy-hom-Group G H f g\nhtpy-hom-Group-eq G H =\n htpy-hom-Semi-Group-eq\n ( semi-group-Group G)\n ( semi-group-Group H)\n\nabstract\n is-contr-total-htpy-hom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Group G H) →\n is-contr (Σ (hom-Group G H) (htpy-hom-Group G H f))\n is-contr-total-htpy-hom-Group G H =\n is-contr-total-htpy-hom-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)\n\nabstract\n is-equiv-htpy-hom-Group-eq :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f g : hom-Group G H) → is-equiv (htpy-hom-Group-eq G H f g)\n is-equiv-htpy-hom-Group-eq G H =\n is-equiv-htpy-hom-Semi-Group-eq\n ( semi-group-Group G)\n ( semi-group-Group H)\n\neq-htpy-hom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n { f g : hom-Group G H} → htpy-hom-Group G H f g → Id f g\neq-htpy-hom-Group G H =\n eq-htpy-hom-Semi-Group (semi-group-Group G) (semi-group-Group H)\n\n{- Next, we construct the identity group homomorphism, and we show that\n compositions of group homomorphisms are again group homomorphisms. -}\n\npreserves-mul-id :\n {l : Level} (G : Semi-Group l) → preserves-mul G G id\npreserves-mul-id (pair (pair G is-set-G) (pair μ-G assoc-G)) x y = refl\n\nid-Semi-Group :\n {l : Level} (G : Semi-Group l) → hom-Semi-Group G G\nid-Semi-Group G =\n pair id (preserves-mul-id G)\n\nid-Group :\n {l : Level} (G : Group l) → hom-Group G G\nid-Group G = id-Semi-Group (semi-group-Group G)\n\ncomposition-Semi-Group :\n {l1 l2 l3 : Level} →\n (G : Semi-Group l1) (H : Semi-Group l2) (K : Semi-Group l3) →\n (hom-Semi-Group H K) → (hom-Semi-Group G H) → (hom-Semi-Group G K)\ncomposition-Semi-Group G H K (pair g μ-g) (pair f μ-f) =\n pair\n ( g ∘ f)\n ( λ x y → (ap g (μ-f x y)) ∙ (μ-g (f x) (f y)))\n\ncomposition-Group :\n {l1 l2 l3 : Level} (G : Group l1) (H : Group l2) (K : Group l3) →\n (hom-Group H K) → (hom-Group G H) → (hom-Group G K)\ncomposition-Group G H K =\n composition-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)\n ( semi-group-Group K)\n\n{- Next, we prove the that the laws for a category hold for group homomorphisms,\n i.e., we show that composition is associative and satisfies the left and\n right unit laws. Before we show that these laws hold, we will characterize\n the identity type of the types of semi-group homomorphisms and group \n homomorphisms. -}\n\nassociative-Semi-Group :\n { l1 l2 l3 l4 : Level} (G : Semi-Group l1) (H : Semi-Group l2)\n ( K : Semi-Group l3) (L : Semi-Group l4) (h : hom-Semi-Group K L) →\n ( g : hom-Semi-Group H K) (f : hom-Semi-Group G H) →\n Id ( composition-Semi-Group G H L\n ( composition-Semi-Group H K L h g) f)\n ( composition-Semi-Group G K L h\n ( composition-Semi-Group G H K g f))\nassociative-Semi-Group G H K L (pair h μ-h) (pair g μ-g) (pair f μ-f) =\n eq-htpy-hom-Semi-Group G L refl-htpy\n\nleft-unit-law-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2)\n ( f : hom-Semi-Group G H) →\n Id ( composition-Semi-Group G H H (id-Semi-Group H) f) f\nleft-unit-law-Semi-Group G\n (pair (pair H is-set-H) (pair μ-H assoc-H)) (pair f μ-f) =\n eq-htpy-hom-Semi-Group G\n ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( refl-htpy)\n\nright-unit-law-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2)\n ( f : hom-Semi-Group G H) →\n Id ( composition-Semi-Group G G H f (id-Semi-Group G)) f\nright-unit-law-Semi-Group\n (pair (pair G is-set-G) (pair μ-G assoc-G)) H (pair f μ-f) =\n eq-htpy-hom-Semi-Group\n ( pair (pair G is-set-G) (pair μ-G assoc-G)) H refl-htpy\n\n{- Now we introduce the notion of group isomorphism. Finally, we will show that\n isomorphic groups are equal. -}\n\nis-iso-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) → UU (l1 ⊔ l2)\nis-iso-Semi-Group G H f =\n Σ ( hom-Semi-Group H G) (λ g →\n ( Id (composition-Semi-Group H G H f g) (id-Semi-Group H)) ×\n ( Id (composition-Semi-Group G H G g f) (id-Semi-Group G)))\n\niso-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) → UU (l1 ⊔ l2)\niso-Semi-Group G H =\n Σ (hom-Semi-Group G H) (is-iso-Semi-Group G H)\n\nabstract\n is-prop-is-iso-Semi-Group' :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) → is-prop' (is-iso-Semi-Group G H f)\n is-prop-is-iso-Semi-Group' G H f\n (pair g (pair issec isretr)) (pair g' (pair issec' isretr')) =\n eq-subtype\n ( λ h →\n is-prop-prod\n ( is-set-hom-Semi-Group H H\n ( composition-Semi-Group H G H f h)\n ( id-Semi-Group H))\n ( is-set-hom-Semi-Group G G\n ( composition-Semi-Group G H G h f)\n ( id-Semi-Group G)))\n ( ( inv (left-unit-law-Semi-Group H G g)) ∙\n ( ( inv (ap (λ h → composition-Semi-Group H G G h g) isretr')) ∙\n ( ( associative-Semi-Group H G H G g' f g) ∙\n ( ( ap (composition-Semi-Group H H G g') issec) ∙\n ( right-unit-law-Semi-Group H G g')))))\n\nabstract\n is-prop-is-iso-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) → is-prop (is-iso-Semi-Group G H f)\n is-prop-is-iso-Semi-Group G H f =\n is-prop-is-prop' (is-prop-is-iso-Semi-Group' G H f)\n\nabstract\n preserves-mul-inv-is-equiv-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H)\n ( is-equiv-f : is-equiv (map-hom-Semi-Group G H f)) →\n preserves-mul H G (inv-is-equiv is-equiv-f)\n preserves-mul-inv-is-equiv-Semi-Group\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( pair f μ-f) is-equiv-f x y =\n inv-is-equiv\n ( is-emb-is-equiv f is-equiv-f\n ( inv-is-equiv is-equiv-f (μ-H x y))\n ( μ-G (inv-is-equiv is-equiv-f x) (inv-is-equiv is-equiv-f y)))\n ( ( ( issec-inv-is-equiv is-equiv-f (μ-H x y)) ∙\n ( ( ap (λ t → μ-H t y) (inv (issec-inv-is-equiv is-equiv-f x))) ∙\n ( ap\n ( μ-H (f (inv-is-equiv is-equiv-f x)))\n ( inv (issec-inv-is-equiv is-equiv-f y))))) ∙\n ( inv (μ-f (inv-is-equiv is-equiv-f x) (inv-is-equiv is-equiv-f y))))\n\nabstract\n is-iso-is-equiv-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) (is-equiv-f : is-equiv (pr1 f)) →\n is-iso-Semi-Group G H f\n is-iso-is-equiv-hom-Semi-Group\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( pair f μ-f) is-equiv-f =\n pair\n ( pair\n ( inv-is-equiv is-equiv-f)\n ( preserves-mul-inv-is-equiv-Semi-Group\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( pair f μ-f) is-equiv-f))\n ( pair\n ( eq-htpy-hom-Semi-Group\n ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( issec-inv-is-equiv is-equiv-f))\n ( eq-htpy-hom-Semi-Group\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( isretr-inv-is-equiv is-equiv-f)))\n\nabstract\n is-equiv-hom-is-iso-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n ( f : hom-Semi-Group G H) (is-iso-f : is-iso-Semi-Group G H f) →\n ( is-equiv (pr1 f))\n is-equiv-hom-is-iso-Semi-Group\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( pair f μ-f)\n ( pair (pair g μ-g) (pair issec isretr)) =\n is-equiv-has-inverse g\n ( htpy-eq (ap pr1 issec))\n ( htpy-eq (ap pr1 isretr))\n\nequiv-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) → UU (l1 ⊔ l2)\nequiv-Semi-Group G H =\n Σ ( type-Semi-Group G ≃ type-Semi-Group H)\n ( λ e → preserves-mul G H (map-equiv e))\n\ntotal-is-equiv-hom-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) → UU (l1 ⊔ l2)\ntotal-is-equiv-hom-Semi-Group G H =\n Σ (hom-Semi-Group G H) (λ f → is-equiv (map-hom-Semi-Group G H f))\n\npreserves-mul' :\n { l1 l2 : Level} (G : Semi-Group l1) (H : UU-Set l2)\n ( μ-H : has-associative-mul H) →\n ( e : (type-Semi-Group G) ≃ (type-Set H)) →\n UU (l1 ⊔ l2)\npreserves-mul' G H μ-H e = preserves-mul G (pair H μ-H) (map-equiv e)\n\nequiv-Semi-Group' :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) → UU (l1 ⊔ l2)\nequiv-Semi-Group' G H = equiv-Semi-Group G (pair (pr1 H) (pr2 H))\n\nabstract\n equiv-iso-Semi-Group-equiv-Semi-Group :\n { l1 l2 : Level} (G : Semi-Group l1) (H : Semi-Group l2) →\n equiv-Semi-Group' G H ≃ iso-Semi-Group G H\n equiv-iso-Semi-Group-equiv-Semi-Group G H =\n ( ( ( equiv-total-subtype\n ( λ f → is-subtype-is-equiv (map-hom-Semi-Group G H f))\n ( is-prop-is-iso-Semi-Group G H)\n ( is-iso-is-equiv-hom-Semi-Group G H)\n ( is-equiv-hom-is-iso-Semi-Group G H)) ∘e\n ( ( inv-equiv\n ( equiv-Σ-assoc\n ( type-Semi-Group G → type-Semi-Group H)\n ( preserves-mul G H)\n ( λ f → is-equiv (map-hom-Semi-Group G H f)))) ∘e\n ( equiv-tot\n ( λ f → equiv-swap-prod (is-equiv f) (preserves-mul G H f))))) ∘e\n ( equiv-Σ-assoc\n ( type-Semi-Group G → type-Semi-Group H)\n ( is-equiv)\n ( λ e → preserves-mul G H (map-equiv e)))) ∘e\n ( equiv-tr (equiv-Semi-Group G) (η-pair H))\n\ncenter-total-preserves-mul-id :\n { l1 : Level} (G : Semi-Group l1) →\n Σ (has-associative-mul (pr1 G)) (λ μ → preserves-mul G (pair (pr1 G) μ) id)\ncenter-total-preserves-mul-id (pair (pair G is-set-G) (pair μ-G assoc-G)) =\n pair (pair μ-G assoc-G) (λ x y → refl)\n\ncontraction-total-preserves-mul-id :\n { l1 : Level} (G : Semi-Group l1) →\n ( t : Σ ( has-associative-mul (pr1 G))\n ( λ μ → preserves-mul G (pair (pr1 G) μ) id)) →\n Id (center-total-preserves-mul-id G) t\ncontraction-total-preserves-mul-id\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair (pair μ-G' assoc-G') μ-id) =\n eq-subtype\n ( λ μ →\n is-prop-preserves-mul\n ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair (pair G is-set-G) μ) id)\n ( eq-subtype\n ( λ μ →\n is-prop-Π (λ x →\n is-prop-Π (λ y →\n is-prop-Π (λ z →\n is-set-G (μ (μ x y) z) (μ x (μ y z))))))\n ( eq-htpy (λ x → eq-htpy (λ y → μ-id x y))))\n\nis-contr-total-preserves-mul-id :\n { l1 : Level} (G : Semi-Group l1) →\n is-contr (Σ (has-associative-mul (pr1 G)) (λ μ → preserves-mul G (pair (pr1 G) μ) id))\nis-contr-total-preserves-mul-id G =\n pair\n ( center-total-preserves-mul-id G)\n ( contraction-total-preserves-mul-id G)\n\nis-contr-total-equiv-Semi-Group :\n { l1 : Level} (G : Semi-Group l1) →\n is-contr (Σ (Semi-Group l1) (λ H → equiv-Semi-Group' G H))\nis-contr-total-equiv-Semi-Group {l1} G =\n is-contr-total-Eq-structure\n ( preserves-mul' G)\n ( is-contr-total-Eq-substructure\n ( is-contr-total-equiv (type-Semi-Group G))\n ( is-prop-is-set)\n ( type-Semi-Group G)\n ( equiv-id (type-Semi-Group G))\n ( is-set-type-Semi-Group G))\n ( pair (pr1 G) (equiv-id (type-Semi-Group G)))\n ( is-contr-total-preserves-mul-id G)\n\nis-contr-total-iso-Semi-Group :\n { l1 : Level} (G : Semi-Group l1) →\n is-contr (Σ (Semi-Group l1) (iso-Semi-Group G))\nis-contr-total-iso-Semi-Group {l1} G =\n is-contr-equiv'\n ( Σ (Semi-Group l1) (λ H → equiv-Semi-Group' G H))\n ( equiv-tot (λ H → equiv-iso-Semi-Group-equiv-Semi-Group G H))\n ( is-contr-total-equiv-Semi-Group G)\n\niso-id-Semi-Group :\n { l1 : Level} (G : Semi-Group l1) → iso-Semi-Group G G\niso-id-Semi-Group G =\n pair\n ( id-Semi-Group G)\n ( pair\n ( id-Semi-Group G)\n ( pair\n ( left-unit-law-Semi-Group G G (id-Semi-Group G))\n ( right-unit-law-Semi-Group G G (id-Semi-Group G))))\n\niso-eq-Semi-Group :\n { l1 : Level} (G H : Semi-Group l1) → Id G H → iso-Semi-Group G H\niso-eq-Semi-Group G .G refl = iso-id-Semi-Group G\n\nis-equiv-iso-eq-Semi-Group :\n { l1 : Level} (G H : Semi-Group l1) → is-equiv (iso-eq-Semi-Group G H)\nis-equiv-iso-eq-Semi-Group G =\n fundamental-theorem-id G\n ( iso-id-Semi-Group G)\n ( is-contr-total-iso-Semi-Group G)\n ( iso-eq-Semi-Group G)\n\nequiv-iso-eq-Semi-Group :\n { l1 : Level} (G H : Semi-Group l1) → Id G H ≃ iso-Semi-Group G H\nequiv-iso-eq-Semi-Group G H =\n pair (iso-eq-Semi-Group G H) (is-equiv-iso-eq-Semi-Group G H)\n\neq-iso-Semi-Group :\n { l1 : Level} (G H : Semi-Group l1) → iso-Semi-Group G H → Id G H\neq-iso-Semi-Group G H = inv-is-equiv (is-equiv-iso-eq-Semi-Group G H)\n\n{- Finally we show that isomorphic groups are equal. -}\n\niso-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) → UU (l1 ⊔ l2)\niso-Group G H =\n iso-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)\n\niso-id-Group :\n { l1 : Level} (G : Group l1) → iso-Group G G\niso-id-Group G = iso-id-Semi-Group (semi-group-Group G)\n\niso-eq-Group :\n { l1 : Level} (G H : Group l1) → Id G H → iso-Group G H\niso-eq-Group G .G refl = iso-id-Group G\n\nabstract\n equiv-iso-eq-Group' :\n { l1 : Level} (G H : Group l1) → Id G H ≃ iso-Group G H\n equiv-iso-eq-Group' G H =\n ( equiv-iso-eq-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)) ∘e\n ( equiv-ap-pr1-is-subtype is-prop-is-group {s = G} {t = H})\n\nabstract\n is-contr-total-iso-Group :\n { l1 : Level} (G : Group l1) → is-contr (Σ (Group l1) (iso-Group G))\n is-contr-total-iso-Group {l1} G =\n is-contr-equiv'\n ( Σ (Group l1) (Id G))\n ( equiv-tot (λ H → equiv-iso-eq-Group' G H))\n ( is-contr-total-path G)\n\nis-equiv-iso-eq-Group :\n { l1 : Level} (G H : Group l1) → is-equiv (iso-eq-Group G H)\nis-equiv-iso-eq-Group G =\n fundamental-theorem-id G\n ( iso-id-Group G)\n ( is-contr-total-iso-Group G)\n ( iso-eq-Group G)\n\neq-iso-Group :\n { l1 : Level} (G H : Group l1) → iso-Group G H → Id G H\neq-iso-Group G H = inv-is-equiv (is-equiv-iso-eq-Group G H)\n\n-- Categories\n\nunderlying-type-Set :\n {l : Level} → UU-Set l → UU l\nunderlying-type-Set A = pr1 A\n\nis-set-underlying-type-Set :\n {l : Level} (A : UU-Set l) → is-set (underlying-type-Set A)\nis-set-underlying-type-Set A = pr2 A\n\nassociative-composition-structure :\n {l1 l2 : Level} (A : UU l1) (hom : A → A → UU-Set l2) → UU (l1 ⊔ l2)\nassociative-composition-structure A hom =\n Σ ( (x y z : A)\n → underlying-type-Set (hom x y)\n → underlying-type-Set (hom y z)\n → underlying-type-Set (hom x z))\n ( λ μ → (x y z w : A) (f : underlying-type-Set (hom x y)) (g : underlying-type-Set (hom y z)) (h : underlying-type-Set (hom z w)) →\n Id (μ x z w (μ x y z f g) h) (μ x y w f (μ y z w g h)))\n\nis-unital-composition-structure :\n {l1 l2 : Level} (A : UU l1) (hom : A → A → UU-Set l2) →\n associative-composition-structure A hom → UU _\nis-unital-composition-structure A hom (pair μ assoc-μ) =\n Σ ( (x : A) → underlying-type-Set (hom x x))\n ( λ e →\n ( (x y : A) (f : underlying-type-Set (hom x y)) → Id (μ x x y (e x) f) f)\n × ( (x y : A) (f : underlying-type-Set (hom x y)) → Id (μ x y y f (e y)) f))\n\nis-prop-is-unital-composition-structure' :\n {l1 l2 : Level} (A : UU l1) (hom : A → A → UU-Set l2) →\n ( μ : associative-composition-structure A hom) →\n is-prop' (is-unital-composition-structure A hom μ)\nis-prop-is-unital-composition-structure' A hom\n ( pair μ assoc-μ)\n ( pair e (pair left-unit-law-e right-unit-law-e))\n ( pair e' (pair left-unit-law-e' right-unit-law-e')) =\n eq-subtype\n ( λ x →\n is-prop-prod\n ( is-prop-Π\n ( λ a → is-prop-Π\n ( λ b → is-prop-Π\n ( λ f' →\n is-set-underlying-type-Set (hom a b) (μ a a b (x a) f') f'))))\n ( is-prop-Π\n ( λ a → is-prop-Π\n ( λ b → is-prop-Π\n ( λ f' →\n is-set-underlying-type-Set (hom a b) (μ a b b f' (x b)) f')))))\n ( eq-htpy\n ( λ x → (inv (left-unit-law-e' x x (e x))) ∙ right-unit-law-e x x (e' x)))\n\nPrecategory :\n (l1 l2 : Level) → UU (lsuc l1 ⊔ lsuc l2)\nPrecategory l1 l2 =\n Σ ( UU l1) (λ A →\n Σ (A → A → UU-Set l2) (λ hom →\n Σ ( associative-composition-structure A hom)\n ( is-unital-composition-structure A hom)))\n\nobj-Precat :\n {l1 l2 : Level} → Precategory l1 l2 → UU l1\nobj-Precat C = pr1 C\n\nhom-Set-Precat :\n {l1 l2 : Level} (C : Precategory l1 l2) (x y : obj-Precat C) → UU-Set l2\nhom-Set-Precat C = pr1 (pr2 C)\n\nhom-Precat :\n {l1 l2 : Level} (C : Precategory l1 l2) (x y : obj-Precat C) → UU l2\nhom-Precat C x y = pr1 (hom-Set-Precat C x y)\n\nis-set-hom-Precat :\n {l1 l2 : Level} (C : Precategory l1 l2) (x y : obj-Precat C) →\n is-set (hom-Precat C x y)\nis-set-hom-Precat C x y = pr2 (hom-Set-Precat C x y)\n\nassociative-composition-Precat :\n {l1 l2 : Level} (C : Precategory l1 l2) →\n associative-composition-structure (obj-Precat C) (hom-Set-Precat C)\nassociative-composition-Precat C = pr1 (pr2 (pr2 C))\n\ncomposition-Precat :\n {l1 l2 : Level} (C : Precategory l1 l2) {x y z : obj-Precat C} →\n hom-Precat C x y → hom-Precat C y z → hom-Precat C x z\ncomposition-Precat C {x} {y} {z} =\n pr1 (associative-composition-Precat C) x y z\n\nis-associative-composition-Precat :\n { l1 l2 : Level} (C : Precategory l1 l2) {x y z w : obj-Precat C} →\n ( f : hom-Precat C x y) (g : hom-Precat C y z) (h : hom-Precat C z w) →\n Id (composition-Precat C (composition-Precat C f g) h)\n (composition-Precat C f (composition-Precat C g h))\nis-associative-composition-Precat C {x} {y} {z} {w} =\n pr2 (associative-composition-Precat C) x y z w\n\nis-unital-Precat :\n { l1 l2 : Level} (C : Precategory l1 l2) →\n is-unital-composition-structure\n ( obj-Precat C)\n ( hom-Set-Precat C)\n ( associative-composition-Precat C)\nis-unital-Precat C = pr2 (pr2 (pr2 C))\n\nid-Precat :\n { l1 l2 : Level} (C : Precategory l1 l2) {x : obj-Precat C} →\n hom-Precat C x x\nid-Precat (pair A (pair hom (pair (pair μ assoc-μ) t))) {x} =\n pr1 (is-unital-Precat {!!}) x\n\n-- Exercises\n\n-- Exercise\n\n{- We show that group homomorphisms preserve the unit. -}\n\npreserves-unit :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Semi-Group\n ( semi-group-Group G)\n ( semi-group-Group H)) →\n UU l2\npreserves-unit G H f =\n Id (map-hom-Group G H f (unit-Group G)) (unit-Group H)\n\nabstract\n preserves-unit-group-hom :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Group G H) → preserves-unit G H f\n preserves-unit-group-hom\n ( pair ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair ( pair e-G (pair left-unit-G right-unit-G))\n ( pair i-G (pair left-inv-G right-inv-G))))\n ( pair ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( pair ( pair e-H (pair left-unit-H right-unit-H))\n ( pair i-H (pair left-inv-H right-inv-H))))\n ( pair f μ-f) =\n ( inv (left-unit-H (f e-G))) ∙\n ( ( ap (λ x → μ-H x (f e-G)) (inv (left-inv-H (f e-G)))) ∙\n ( ( assoc-H (i-H (f e-G)) (f e-G) (f e-G)) ∙\n ( ( ap (μ-H (i-H (f e-G))) (inv (μ-f e-G e-G))) ∙\n ( ( ap (λ x → μ-H (i-H (f e-G)) (f x)) (left-unit-G e-G)) ∙\n ( left-inv-H (f e-G))))))\n\n{- We show that group homomorphisms preserve inverses. -}\n\npreserves-inverses :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Group G H) → UU (l1 ⊔ l2)\npreserves-inverses G H f =\n ( x : type-Group G) →\n Id ( map-hom-Group G H f (inv-Group G x))\n ( inv-Group H (map-hom-Group G H f x))\n\nabstract\n preserves-inverses-group-hom' :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Group G H) →\n preserves-unit G H f → preserves-inverses G H f\n preserves-inverses-group-hom'\n ( pair ( pair (pair G is-set-G) (pair μ-G assoc-G))\n ( pair ( pair e-G (pair left-unit-G right-unit-G))\n ( pair i-G (pair left-inv-G right-inv-G))))\n ( pair ( pair (pair H is-set-H) (pair μ-H assoc-H))\n ( pair ( pair e-H (pair left-unit-H right-unit-H))\n ( pair i-H (pair left-inv-H right-inv-H))))\n ( pair f μ-f) preserves-unit-f x =\n ( inv ( right-unit-H (f (i-G x)))) ∙\n ( ( ap (μ-H (f (i-G x))) (inv (right-inv-H (f x)))) ∙\n ( ( inv (assoc-H (f (i-G x)) (f x) (i-H (f x)))) ∙\n ( ( inv (ap (λ y → μ-H y (i-H (f x))) (μ-f (i-G x) x))) ∙\n ( ( ap (λ y → μ-H (f y) (i-H (f x))) (left-inv-G x)) ∙\n ( ( ap\n ( λ y → μ-H y (i-H (f x)))\n ( preserves-unit-f)) ∙\n ( left-unit-H (i-H (f x))))))))\n\nabstract\n preserves-inverses-group-hom :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n ( f : hom-Group G H) → preserves-inverses G H f\n preserves-inverses-group-hom G H f =\n preserves-inverses-group-hom' G H f (preserves-unit-group-hom G H f)\n\nhom-Group' :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) → UU (l1 ⊔ l2)\nhom-Group' G H =\n Σ ( hom-Group G H) (λ f →\n ( preserves-unit G H f) × (preserves-inverses G H f))\n\npreserves-all-hom-Group :\n { l1 l2 : Level} (G : Group l1) (H : Group l2) →\n hom-Group G H → hom-Group' G H\npreserves-all-hom-Group G H f =\n pair f\n ( pair\n ( preserves-unit-group-hom G H f)\n ( preserves-inverses-group-hom G H f))\n\n-- Exercise\n\n{-\nhom-mul-Group :\n {l : Level} (G : Group l) →\n hom-Group G Aut\n-}\n", "meta": {"hexsha": "6c777f13afd2acf3bdd9b102b782fe8db0a46e6d", "size": 37090, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/17-groups.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/17-groups.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/17-groups.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": 34.0900735294, "max_line_length": 135, "alphanum_fraction": 0.5840388245, "num_tokens": 14012, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.5885720338824239}} {"text": "\nopen import Agda.Builtin.Equality\n\n_∋_ : ∀ {a} (A : Set a) → A → A\nA ∋ x = x\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\nrecord IsRG (Node : Set) (Edge : Set) : Set where\n field\n src : Edge → Node\n tgt : Edge → Node\n rfl : Node → Edge\n eq-src-rfl : ∀{x} → src (rfl x) ≡ x\n eq-tgt-rfl : ∀{x} → tgt (rfl x) ≡ x\nopen IsRG {{...}} public\n\nmodule norecord where\n\n source : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → Edge → Node\n source x = src x\n\n lemma1 : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → (e : Edge) → (Node ∋ source e) ≡ src e\n lemma1 e = refl\n\n rfl-src : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → Edge → Edge\n rfl-src {Node} e = rfl (Node ∋ src e)\n\n lemma2 : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → (n : Node) → rfl-src {Node} (rfl n) ≡ (Edge ∋ rfl n)\n lemma2 {Node}{Edge} n = cong (rfl {Node = Node}) (eq-src-rfl {Edge = Edge})\n\nmodule yesrecord where\n\n record RG : Set₁ where\n constructor mkRG\n field\n Node : Set\n Edge : Set\n {{isRG}} : IsRG Node Edge\n open RG public\n\n source : ∀{rg} → Edge rg → Node rg\n source x = src x\n\n lemma1 : ∀{rg} → (e : Edge rg) → (Node rg ∋ source {mkRG (Node rg) (Edge rg)} e) ≡ src e\n --causes problems:\n --lemma1 : ∀{rg} → (e : Edge rg) → (Node rg ∋ source {_} e) ≡ src e\n lemma1 e = refl\n\n rfl-src : ∀{rg} → Edge rg → Edge rg\n rfl-src {rg} e = rfl (Node rg ∋ src e)\n\n lemma2 : ∀{rg} → (n : Node rg) → rfl-src {rg} (rfl n) ≡ (Edge rg ∋ rfl n)\n lemma2 {rg} n = cong (rfl {Node = Node rg}) (eq-src-rfl {Edge = Edge rg})\n", "meta": {"hexsha": "a8f548fb81c96609fe9e5f7b8b1be18e559da6a9", "size": 1586, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2670.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/Issue2670.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/Issue2670.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.8245614035, "max_line_length": 107, "alphanum_fraction": 0.5365699874, "num_tokens": 626, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.7826624890918021, "lm_q1q2_score": 0.5885720328071754}} {"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.DistributiveLattice\n {dl₁ dl₂} (DL : DistributiveLattice dl₁ dl₂)\n where\n\nopen DistributiveLattice DL\nimport Algebra.Properties.Lattice\nprivate\n open module L = Algebra.Properties.Lattice lattice public\n hiding (replace-equality)\nopen import Algebra.Structures\nopen import Algebra.FunctionProperties _≈_\nopen import Relation.Binary\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 (_,_)\n\n∨-∧-distribˡ : _∨_ DistributesOverˡ _∧_\n∨-∧-distribˡ x y z = begin\n x ∨ y ∧ z ≈⟨ ∨-comm _ _ ⟩\n y ∧ z ∨ x ≈⟨ ∨-∧-distribʳ _ _ _ ⟩\n (y ∨ x) ∧ (z ∨ x) ≈⟨ ∨-comm _ _ ⟨ ∧-cong ⟩ ∨-comm _ _ ⟩\n (x ∨ y) ∧ (x ∨ z) ∎\n\n∨-∧-distrib : _∨_ DistributesOver _∧_\n∨-∧-distrib = ∨-∧-distribˡ , ∨-∧-distribʳ\n\n∧-∨-distribˡ : _∧_ DistributesOverˡ _∨_\n∧-∨-distribˡ x y z = begin\n x ∧ (y ∨ z) ≈⟨ ∧-congʳ $ sym (∧-absorbs-∨ _ _) ⟩\n (x ∧ (x ∨ y)) ∧ (y ∨ z) ≈⟨ ∧-congʳ $ ∧-congˡ $ ∨-comm _ _ ⟩\n (x ∧ (y ∨ x)) ∧ (y ∨ z) ≈⟨ ∧-assoc _ _ _ ⟩\n x ∧ ((y ∨ x) ∧ (y ∨ z)) ≈⟨ ∧-congˡ $ sym (∨-∧-distribˡ _ _ _) ⟩\n x ∧ (y ∨ x ∧ z) ≈⟨ ∧-congʳ $ sym (∨-absorbs-∧ _ _) ⟩\n (x ∨ x ∧ z) ∧ (y ∨ x ∧ z) ≈⟨ sym $ ∨-∧-distribʳ _ _ _ ⟩\n x ∧ y ∨ x ∧ z ∎\n\n∧-∨-distribʳ : _∧_ DistributesOverʳ _∨_\n∧-∨-distribʳ x y z = begin\n (y ∨ z) ∧ x ≈⟨ ∧-comm _ _ ⟩\n x ∧ (y ∨ z) ≈⟨ ∧-∨-distribˡ _ _ _ ⟩\n x ∧ y ∨ x ∧ z ≈⟨ ∧-comm _ _ ⟨ ∨-cong ⟩ ∧-comm _ _ ⟩\n y ∧ x ∨ z ∧ x ∎\n\n∧-∨-distrib : _∧_ DistributesOver _∨_\n∧-∨-distrib = ∧-∨-distribˡ , ∧-∨-distribʳ\n\n-- The dual construction is also a distributive lattice.\n\n∧-∨-isDistributiveLattice : IsDistributiveLattice _≈_ _∧_ _∨_\n∧-∨-isDistributiveLattice = record\n { isLattice = ∧-∨-isLattice\n ; ∨-∧-distribʳ = ∧-∨-distribʳ\n }\n\n∧-∨-distributiveLattice : DistributiveLattice _ _\n∧-∨-distributiveLattice = record\n { _∧_ = _∨_\n ; _∨_ = _∧_\n ; isDistributiveLattice = ∧-∨-isDistributiveLattice\n }\n\n-- One can replace the underlying equality with an equivalent one.\n\nreplace-equality :\n {_≈′_ : Rel Carrier dl₂} →\n (∀ {x y} → x ≈ y ⇔ (x ≈′ y)) → DistributiveLattice _ _\nreplace-equality {_≈′_} ≈⇔≈′ = record\n { _≈_ = _≈′_\n ; _∧_ = _∧_\n ; _∨_ = _∨_\n ; isDistributiveLattice = record\n { isLattice = Lattice.isLattice (L.replace-equality ≈⇔≈′)\n ; ∨-∧-distribʳ = λ x y z → to ⟨$⟩ ∨-∧-distribʳ x y z\n }\n } where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})\n", "meta": {"hexsha": "e393d36e48ec105ffb384ff1d2b9d9f25aa35579", "size": 2906, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Properties/DistributiveLattice.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/DistributiveLattice.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/DistributiveLattice.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.0227272727, "max_line_length": 72, "alphanum_fraction": 0.5306262904, "num_tokens": 1238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.5885720251826217}} {"text": "{-# OPTIONS --without-K #-}\nmodule PathOperations where\n\nopen import Types\n\ninfixr 4 _·_\ninfix 9 _⁻¹\n\n_⁻¹ : ∀ {a} {A : Set a} {x y : A} →\n x ≡ y → y ≡ x\n_⁻¹ = J (λ x y _ → y ≡ x) (λ _ → refl) _ _\n\n_·_ : ∀ {a} {A : Set a} {x y z : A} →\n x ≡ y → y ≡ z → x ≡ z\n_·_ {z = z} = J (λ x y _ → y ≡ z → x ≡ z) (λ _ p′ → p′) _ _\n\ntr : ∀ {a p} {A : Set a} (P : A → Set p) {x y : A} (p : x ≡ y) →\n P x → P y\ntr P = J (λ x y _ → P x → P y) (λ _ x → x) _ _\n\nap : ∀ {a b} {A : Set a} {B : Set b} {x y : A} (f : A → B) →\n x ≡ y → f x ≡ f y\nap f = J (λ x y _ → f x ≡ f y) (λ _ → refl) _ _\n\nap₂ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}\n {x x′ y y′} (f : A → B → C) (p : x ≡ x′) (q : y ≡ y′) →\n f x y ≡ f x′ y′\nap₂ f p q = ap (λ _ → f _ _) p · ap (f _) q\n\napd : ∀ {a b} {A : Set a} {B : A → Set b} {x y : A}\n (f : ∀ a → B a) (p : x ≡ y) →\n tr B p (f x) ≡ f y\napd {B = B} f = J\n (λ x y p → tr B p (f x) ≡ f y)\n (λ _ → refl) _ _\n\nhapply : ∀ {a b} {A : Set a} {B : A → Set b} {f g : (x : A) → B x} →\n f ≡ g → ∀ x → f x ≡ g x\nhapply p x = ap (λ f → f x) p\n", "meta": {"hexsha": "52ad02ddc85e80600e4f619e391d499ce986f5b7", "size": 1053, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/PathOperations.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/PathOperations.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/PathOperations.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": 26.325, "max_line_length": 68, "alphanum_fraction": 0.3779677113, "num_tokens": 578, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.588453206611311}} {"text": "{-# OPTIONS --sized-types #-}\n\nmodule Ex where\n\nopen import Size\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Nat\nopen import Data.Product\nopen import Data.Sum\nopen import Data.Fin\nopen import Function\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\n\n• : Set\n• = ⊤\n\n-- | Container for defining signatures\nrecord Cont : Set₁ where\n constructor cont\n field\n Pos : Set\n Sh : Pos → Set\nopen Cont\n\n-- | Extension of a container\n⟪_⟫ : Cont → Set → Set\n⟪ cont P S ⟫ X = Σ P (λ p → S p → X)\n\n-- | Finite and infinite trees over a signature\nrecord T∞ {i : Size} (C : Cont) : Set where\n coinductive\n field\n out : ∀ {j : Size< i} → • ⊎ ⟪ C ⟫ (T∞ {j} C)\nopen T∞\n\n------\n-- Example due to Fu Peng\n-----\n\n-- In the following, we give two interpretations to the logic program\n-- ⇒ P(c)\n-- P(x), P(f(f x)) ⇒ P(f x).\n-- The first is an inductive interpretation, the second is coinductive.\n-- In both cases we are able to prove that there is a tree x : Tree sig₁,\n-- such that P x holds.\n\n-- | Signature has two symbols, a nullary and a unary symbol.\nsig₁ : Cont\nsig₁ = cont (⊤ ⊎ ⊤) S\n where\n S : ⊤ ⊎ ⊤ → Set\n S (inj₁ tt) = Fin 0\n S (inj₂ tt) = Fin 1\n\n-- | Symbol names\nc' f' : Pos sig₁\nc' = inj₁ tt\nf' = inj₂ tt\n\n-- | Symbol constructor for c\nc : T∞ sig₁\nout c = inj₂ (c' , (λ ()))\n\n-- | Constructor for symbol f\nf : T∞ sig₁ → T∞ sig₁\nout (f x) = inj₂ (f' , (λ _ → x))\n\n-- | c and f a distinct constructors\nc≢f : (x : T∞ sig₁) → c ≡ f x → ⊥\nc≢f x p = lem x (cong (λ t → out t {∞}) p)\n where\n lem : (y : T∞ sig₁) → out c ≡ out (f y) → ⊥\n lem y ()\n\n-- | Inductive interpretation of LP\ndata P-ind : T∞ sig₁ → Set where\n c-P : P-ind c\n f-P : (x : T∞ sig₁) → P-ind x → P-ind (f (f x)) → P-ind (f x)\n\n-- | P c holds immediately.\np-ind₀ : ∃ λ x → P-ind x\np-ind₀ = (c , c-P)\n\nunprvbl-lem : (x : T∞ sig₁) → P-ind (f x) → ⊥\nunprvbl-lem x q = m x (f x) q refl\n where\n m : (x y : T∞ sig₁) → P-ind y → y ≡ f x → ⊥\n m x .c c-P p = (c≢f x p)\n m x .(f x₁) (f-P x₁ p q₁) e = m (f x₁) (f (f x₁)) q₁ refl\n\n-- | We can show that there is no tree x, s.t. P-ind (f x) holds.\nunprvbl : ¬ (∃ λ x → P-ind (f x))\nunprvbl (x , q) = unprvbl-lem x q\n\n-------\n-- Coinductive interpretation of LP\n\nF : (T∞ sig₁ → Set) → T∞ sig₁ → Set\nF G x = m (out x)\n where\n m : ⊤ ⊎ ⟪ sig₁ ⟫ (T∞ sig₁) → Set\n m (inj₁ tt) = ⊥ -- case for •\n m (inj₂ (inj₁ tt , _)) = ⊤ -- case for c, k₀\n m (inj₂ (inj₂ tt , α)) = -- case for f x, k₁\n let x = α zero\n in G x × G (f (f x))\n\nrecord P-coind' (x : T∞ sig₁) : Set where\n coinductive\n field\n p-out' : F P-coind' x\nopen P-coind'\n\n\nrecord P-coind {i : Size} (x : T∞ sig₁) : Set where\n coinductive\n field\n p-out : ∀ {j : Size< i} → F (P-coind {j}) x\nopen P-coind\n\n-- | Trivial proof\nk₀ : P-coind c\np-out k₀ = tt\n\n-- | Non-trivial proof\np-coind : ∃ λ x → P-coind (f x)\np-coind = (_ , k _ k₀)\n where\n k : ∀{i} → (x : T∞ sig₁) → P-coind {i} x → P-coind {i} (f x)\n p-out (k x q) = (q , k (f x) (k x q))\n\n-------------------------------------------\n------- From example\n-------------------------------------------\n\n-- | The signature has two symbols: S of arity 1 and cons of arity 2.\nsig₂ : Cont\nsig₂ = cont (⊤ ⊎ ⊤) ar₂\n where\n ar₂ : ⊤ ⊎ ⊤ → Set\n ar₂ (inj₁ tt) = Fin 1\n ar₂ (inj₂ tt) = Fin 2\n\n-- | Easier to read symbol names\nS' cons' : Pos sig₂\nS' = inj₁ tt\ncons' = inj₂ tt\n\n-- | Tree constructors for S\nS : ∀{i} → T∞ {i} sig₂ → T∞ {i} sig₂\nout (S x) = inj₂ (S' , (λ _ → x))\n\n-- | Tree constructors for cons\ncons : T∞ sig₂ → T∞ sig₂ → T∞ sig₂\nout (cons x y) = inj₂ (cons' , α)\n where\n α : Sh sig₂ cons' → T∞ sig₂\n α zero = x\n α (suc _) = y\n\n-- | Coinductive conlusion for the rule\n-- from(S x, y) ⇒ from(x, cons (x, y)).\n-- Note that we need to encode this as\n-- from(S x, y) ∧ x ≡ x' ⇒ from(x, cons (x', y)).\nFrom-Enc : (T∞ sig₂ → T∞ sig₂ → Set) → T∞ sig₂ → T∞ sig₂ → Set\nFrom-Enc G x y with (out y)\n... | inj₁ tt = ⊥ -- no clause for from(x, •)\n... | inj₂ (inj₁ tt , _) = ⊥ -- neither for from(x, S y)\n... | inj₂ (inj₂ tt , α) = -- from(S x, y) ∧ x ≡ x' ⇒ from(x, cons (x', y))\n let x' = α zero\n y = α (suc zero)\n in x ≡ x' × G (S x) y\n\n-- | Define From as coinductive relation.\nrecord From (x y : T∞ sig₂) : Set where\n coinductive\n field\n out-From : From-Enc From x y\nopen From\n\n----- Below, we construct for each x : T∞ sig₂ a term tₓ that is related to x\n----- via From, and prove that this is indeed the case.\n\n-- | t x = cons x (cons (s x) ...\nt : T∞ sig₂ → T∞ sig₂\nout (t x) = inj₂ (cons' , α)\n where\n α : Sh sig₂ cons' → T∞ sig₂\n α zero = x\n α (suc _) = t (S x)\n\n-- | Prove that x and tₓ are related via From.\nlem : (x : T∞ sig₂) → From x (t x)\nout-From (lem x) = (refl , lem (S x))\n\n-- | From is inhabitated if T∞ sig₂ is.\nthm : (x : T∞ sig₂) → ∃ λ y → From x y\nthm x = , (lem x)\n\n----------------------------------------\n-- Different approach to show that From is inhabited:\n-- The separate definition of T∞ and From makes it impossible, or at least\n-- extremly difficult, to construct y and From x y at the same time.\n-- The predicate ∃-From x thus simultaneously defines a special existential\n-- quantifier for T∞ sig₂ that ensures that the given witness y fulfills\n-- From x y.\n-- Note that elements of ∃-From contain a lot of junk, as we always just use\n-- the root of a tree. This make the first projection rather complicated, see\n-- p₁. I guess, this could be made more economical.\n\n∃-From-Enc : ∀{i} → (T∞ {i} sig₂ → Set) → T∞ {i} sig₂ → Set\n∃-From-Enc {i} G x = Σ (⟪ sig₂ ⟫ (T∞ sig₂)) m\n where\n m : ⟪ sig₂ ⟫ (T∞ {i} sig₂) → Set\n m (inj₁ tt , _) = ⊥\n m (inj₂ tt , α) =\n let x' = α zero\n y = α (suc zero)\n in x ≡ x' × G (S x)\n\nrecord ∃-From {i : Size} (x : T∞ {i} sig₂) : Set where\n coinductive\n field\n out-∃-From : {j : Size< i} → ∃-From-Enc (∃-From {j}) x\nopen ∃-From\n\npostulate\n T∞-ext : ∀{C} → (x y : T∞ C) → out x ≡ out y → x ≡ y\n\n-- | Project out the witness.\np₁ : ∀ {i x} → ∃-From {i} x → T∞ {i} sig₂\nout (p₁ u) {j} with out-∃-From u\n... | (inj₁ tt , _) , ()\n... | (inj₂ tt , α) , q , u' = inj₂ (cons' , α')\n where\n t' = p₁ u'\n α' : Fin 2 → T∞ {j} sig₂\n α' zero = α zero\n α' (suc _) = t'\n\np₂ : ∀ {x} → (u : ∃-From x) → From x (p₁ u)\nout-From (p₂ {x} u) = {!!}\n where\n m : (v : ∃-From-Enc ∃-From x) → v ≡ out-∃-From u → From-Enc From x (p₁ u)\n m v p with v\n ... | ((inj₁ tt , _) , ())\n ... | ((inj₂ tt , α) , q , u') = {!!} -- subst (From-Enc From x) s m'\n where\n v' : From (S x) (p₁ u')\n v' = p₂ u'\n\n α' : Fin 2 → T∞ sig₂\n α' zero = α zero\n α' (suc _) = p₁ u'\n\n s : ∀ {α q u'} → ((inj₂ tt , α) , q , u') ≡ out-∃-From u →\n record { out = inj₂ (cons' , α') } ≡ p₁ u\n s p with out-∃-From u\n s p | r = {!!}\n\n{-\n s p with out-∃-From u\n s p | (inj₁ tt , _) , ()\n s p | ((inj₂ tt , α₁) , q₁ , u'₁) = ?\n -- T∞-ext (record { out = inj₂ (cons' , α') }) (p₁ u) {!!}\n-}\n\n m' : From-Enc From x (record { out = inj₂ (cons' , α') })\n m' = (q , v')\n\nthm₂ : ∀{i} → (x : T∞ {i} sig₂) → ∃-From {i} x\nout-∃-From (thm₂ {i} x) {j} = ((cons' , α) , refl , u)\n where\n u = thm₂ {j} (S x)\n\n α : Sh sig₂ cons' → T∞ {j} sig₂\n α zero = x\n α (suc _) = p₁ u\n\n---------------------\n-- Some other tries\n--------------------\n{-\nF : (ℕ → Set) → ℕ → Set\nF G 0 = ⊤\nF G (suc n) = G n\n\nrecord NatLp (n : ℕ) : Set where\n coinductive\n field\n out : F NatLp n\nopen NatLp\n\nlem : (n : ℕ) → NatLp n\nout (lem zero) = tt\nout (lem (suc n)) = lem n\n\nrecord bad (A : Set) (a : A) : Set where\n coinductive\n field\n bad-out : bad A a\nopen bad\n\nbad-lem : (n : ℕ) → bad ℕ n\nbad-out (bad-lem n) = bad-lem n\n\n-}\n", "meta": {"hexsha": "0029eed8d60a21ff085bf8a6a61a57fe30ba083a", "size": 7779, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LP2/Ex.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": "LP2/Ex.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": "LP2/Ex.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": 25.0935483871, "max_line_length": 77, "alphanum_fraction": 0.5136907057, "num_tokens": 3147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8152324803738429, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.588388514021618}} {"text": "module plantsigma where\n\n\ndata Tree : Set where\n oak : Tree\n pine : Tree\n spruce : Tree\n\ndata Flower : Set where\n rose : Flower\n lily : Flower\n\n\ndata PlantGroup : Set where\n tree : PlantGroup\n flower : PlantGroup\n\n\nPlantsInGroup : PlantGroup -> Set\nPlantsInGroup tree = Tree\nPlantsInGroup flower = Flower\n\n\ndata Plant : Set where\n plant : (g : PlantGroup) -> PlantsInGroup g -> Plant\n\nf : Plant -> PlantGroup\nf (plant g pg) = g\n ", "meta": {"hexsha": "df5abf9f90815fa57da1b8a9b3e4985afb379440", "size": 448, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/plantsigma.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/plantsigma.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/plantsigma.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": 15.4482758621, "max_line_length": 54, "alphanum_fraction": 0.6741071429, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577681195338728, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.588385579624619}} {"text": "{-\n\nThis file contains:\n\n- Definition of groupoid truncations\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.GroupoidTruncation.Base where\n\nopen import Cubical.Core.Primitives\n\n-- groupoid truncation as a higher inductive type:\n\ndata ∥_∥₃ {ℓ} (A : Type ℓ) : Type ℓ where\n ∣_∣₃ : A → ∥ A ∥₃\n squash₃ : ∀ (x y : ∥ A ∥₃) (p q : x ≡ y) (r s : p ≡ q) → r ≡ s\n", "meta": {"hexsha": "1aaf63dc1f2a696279bc1a16cfdc3e22b8b71a4d", "size": 384, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/GroupoidTruncation/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/GroupoidTruncation/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/GroupoidTruncation/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": 21.3333333333, "max_line_length": 64, "alphanum_fraction": 0.6302083333, "num_tokens": 150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.5883855641413718}} {"text": "module Shallow where\n\nopen import Level using (_⊔_) renaming (suc to lsuc)\nopen import Function\nopen import Data.Unit\nopen import Data.Empty\nopen import Data.Product\nopen import Data.Sum\nopen import Data.Nat hiding (_⊔_)\nopen import Data.Fin\nopen import Relation.Binary.PropositionalEquality as PE hiding ([_]; subst)\n\nΠ : ∀ {a b} (A : Set a) (B : A → Set b) → Set (a ⊔ b)\nΠ A B = (a : A) → B a\n\nFam : ∀ {a} → Set a → Set (lsuc a)\nFam {a} I = I → Set a\n\ndata Σ' {A B : Set} (f : A → B) (P : Fam A) : B → Set where\n ins : (a : A) → P a → Σ' f P (f a)\n\nΠ' : {I J : Set} (u : I → J) (P : Fam I) → Fam J\nΠ' {I} u P j = Π (∃ λ i → u i ≡ j) (λ { (i , _) → P i})\n\n_* : {I J : Set} → (I → J) → Fam J → Fam I\n(u *) A i = A (u i)\n\nFin⁺ : ℕ → Set\nFin⁺ = Fin ∘ suc\n\nVec⁺ : ∀ {a} → Set a → ℕ → Set a\nVec⁺ A n = Fin⁺ n → A\n\n[_] : ∀ {a} {A : Set a} → A → Vec⁺ A 0\n[ x ] _ = x\n\n_∷_ : ∀ {a} {A : Set a} {n : ℕ} → A → Vec⁺ A n → Vec⁺ A (suc n)\n(x ∷ v) zero = x\n(x ∷ v) (suc k) = v k\n\nmodule Simple where\n module _ where\n mutual\n data U : Set where\n zero : U\n one : U\n sigma : (A : U) → (Elem A → U) → U\n pi : (A : U) → (Elem A → U) → U\n\n Elem : U → Set\n Elem zero = ⊥\n Elem one = ⊤\n Elem (sigma A B) = Σ (Elem A) (λ x → Elem (B x))\n Elem (pi A B) = Π (Elem A) (λ x → Elem (B x))\n\nmodule Recursive where\n module _ where\n ∐ : {n : ℕ} {I : Set} → (Fin⁺ n → Fam I) → Fam I\n ∐ {zero} f = f zero\n ∐ {suc n} f i = f zero i ⊎ ∐ (λ k → f (suc k)) i\n\n ∏ : {n : ℕ} {I : Set} → (Fin⁺ n → Fam I) → Fam I\n ∏ {zero} f = f zero\n ∏ {suc n} f i = f zero i × ∏ (λ k → f (suc k)) i\n\n data FP : Set where\n μ : FP\n ν : FP\n\n mutual\n data U : Set where\n fp : {n : ℕ} (A : U) (o : Vec⁺ U n) →\n FP → Functor [ A ] o → Subst o A → U\n\n -- | Substitutions\n Subst : {n : ℕ} → Vec⁺ U n → U → Set\n Subst {n} o A = (k : Fin⁺ n) → Elem (o k) → Elem A\n\n data Functor : {m n : ℕ} → Vec⁺ U m → Vec⁺ U n → Set where\n K : {m : ℕ} (v : Vec⁺ U m) (A : U) → Functor v [ A ]\n π : {m : ℕ} (v : Vec⁺ U m) (i : Fin⁺ m) → Functor v [ v i ]\n fpF : {m n : ℕ} {v : Vec⁺ U m} {o : Vec⁺ U n} {A : U} →\n FP → Functor (A ∷ v) o → Subst o A → Functor v [ A ]\n\n Elem : U → Set\n Elem (fp A o μ F u) = {!!} -- LFP F u {!!}\n where\n G : Fam (Elem A) → Fam (Elem A)\n G = IndFun F u\n\n Elem (fp A o ν F u) = {!!}\n\n IdxFam : {m : ℕ} → Vec⁺ U m → Set₁\n IdxFam {m} v = (k : Fin⁺ m) → Fam (Elem (v k))\n\n ⟦_⟧ : {m n : ℕ} {i : Vec⁺ U m} {o : Vec⁺ U n} →\n Functor i o → (IdxFam i → IdxFam o)\n ⟦ K v A ⟧ x k i = Elem A\n ⟦ π v k ⟧ x zero i = x k i\n ⟦ π v k ⟧ x (suc ()) i\n ⟦ fpF μ F u ⟧ x = {!!}\n ⟦ fpF ν F u ⟧ x = {!!}\n\n IndFun : {n : ℕ} {A : U} {o : Vec⁺ U n} →\n (F : Functor [ A ] o) →\n -- (F : Fam (Elem A) → IdxFam o) →\n (u : Subst o A) →\n (Fam (Elem A) → Fam (Elem A))\n IndFun {n} {A} F u X = ∐ f\n where\n f : Fin⁺ n → Fam (Elem A)\n f k = Σ' (u k) (⟦ F ⟧ (λ _ → X) k)\n\n CoindFun : {n : ℕ} {A : U} {o : Vec⁺ U n} →\n (F : Functor [ A ] o) →\n -- (F : Fam (Elem A) → IdxFam o) →\n (u : Subst o A) →\n (Fam (Elem A) → Fam (Elem A))\n CoindFun {n} {A} F u X = ∏ f\n where\n f : Fin⁺ n → Fam (Elem A)\n f k = Π' (u k) (⟦ F ⟧ (λ _ → X) k)\n\n data LFP {n : ℕ} {A : U} {o : Vec⁺ U n}\n (F : Functor [ A ] o) (u : Subst o A) : Elem A → Set where\n-- α : (a : Elem A) → IndFun F u (LFP F u) a → LFP F u a\n\n{-\n data U : Set where\n fp : {n : ℕ} (C : Cat) (o : Vec Cat n) →\n FP → Functor [ C ] o → Subst o C → U\n\n -- | Index of a fibre\n Cat : Set\n Cat = Σ U Elem\n\n Mor : Cat → Set\n Mor C = ? -- (A , x) = -- Σ U (λ B → {!Elem B → x!})\n\n -- | Substitutions\n Subst : {n : ℕ} → Vec Cat n → Cat → Set\n Subst {n} o C = Vec {!!} n\n\n data Functor : {m n : ℕ} → Vec Cat m → Vec Cat n → Set where\n K : {m : ℕ} (v : Vec Cat m) → {A : U} → (x : Elem A) → Functor v [ , x ]\n π : {m : ℕ} (v : Vec Cat m) → (i : Fin m) → Functor v [ lookup i v ]\n fpF : {m n : ℕ} {v : Vec Cat m} {o : Vec Cat n} {C : Cat} →\n FP → Functor (C ∷ v) o → Subst o C → Functor v [ C ]\n\n Elem : U → Set\n Elem x = {!!}\n-}\n\nmodule DepPoly where\n module _ where\n record DPoly (J I : Set) : Set₁ where\n constructor dpoly\n field\n -- J <- Shapes -> Pos -> I\n Pos : Set\n Shapes : Set\n s : Shapes → J\n f : Shapes → Pos\n t : Pos → I\n open DPoly\n\n ⟦_⟧ : {J I : Set} → DPoly J I → Fam J → Fam I\n ⟦ dpoly A B s f t ⟧ X = Σ' t (Π' f ((s *) X))\n\n data W {I : Set} (P : DPoly I I) : I → Set where\n α : (i : I) → ⟦ P ⟧ (W P) i → W P i\n\n record M {I : Set} (P : DPoly I I) (i : I) : Set where\n coinductive\n field\n ξ : ⟦ P ⟧ (M P) i\n\n data FP : Set where\n μ : FP\n ν : FP\n\n mutual\n data U : Set where\n fp : {n : ℕ} (A : U) (o : Vec⁺ U n) →\n FP → Functor [ A ] o → Subst o A → U\n\n -- | Substitutions\n Subst : {n : ℕ} → Vec⁺ U n → U → Set\n Subst {n} o A = (k : Fin⁺ n) → Elem (o k) → Elem A\n\n data Functor : {m n : ℕ} → Vec⁺ U m → Vec⁺ U n → Set where\n K : {m : ℕ} (v : Vec⁺ U m) {I A : U} → (Elem A → Elem I) → Functor v [ I ]\n π : {m : ℕ} (v : Vec⁺ U m) (i : Fin⁺ m) → Functor v [ v i ]\n fpF : {m n : ℕ} {v : Vec⁺ U m} {o : Vec⁺ U n} {A : U} →\n FP → Functor (A ∷ v) o → Subst o A → Functor v [ A ]\n\n Elem : U → Set\n Elem (fp A o μ F u) = Σ (Elem A) (W (Poly F u))\n Elem (fp A o ν F u) = {!!}\n\n Poly : {n : ℕ} {I : U} {o : Vec⁺ U n} (F : Functor [ I ] o) →\n (u : Subst o I) → DPoly (Elem I) (Elem I)\n Poly (K ._ {J} {A} B) u =\n dpoly (Elem A) ⊥ (λ ()) (λ ()) (u zero ∘ B)\n Poly {I = I} (π ._ i) u =\n dpoly (Elem I) (Elem I) id id id\n Poly (fpF μ F v) u =\n {!!}\n Poly (fpF ν F v) u =\n {!!}\n", "meta": {"hexsha": "68d967d90023a894a377230744ec6ba8085954e1", "size": 6258, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TypeTheory/FibDataTypes/Shallow.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/FibDataTypes/Shallow.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/FibDataTypes/Shallow.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": 29.6587677725, "max_line_length": 82, "alphanum_fraction": 0.3990092681, "num_tokens": 2560, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681086260461, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5883855611284876}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- M-types (the dual of W-types)\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe --sized-types #-}\n\nmodule Codata.M where\n\nopen import Size\nopen import Level\nopen import Codata.Thunk using (Thunk; force)\nopen import Data.Product hiding (map)\nopen import Data.Container.Core as C hiding (map)\n\ndata M {s p} (C : Container s p) (i : Size) : Set (s ⊔ p) where\n inf : ⟦ C ⟧ (Thunk (M C) i) → M C i\n\nmodule _ {s p} {C : Container s p} where\n\n head : ∀ {i} → M C i → Shape C\n head (inf (x , f)) = x\n\n tail : (x : M C ∞) → Position C (head x) → M C ∞\n tail (inf (x , f)) = λ p → f p .force\n\n-- map\n\nmodule _ {s₁ s₂ p₁ p₂} {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂}\n (m : C₁ ⇒ C₂) where\n\n map : ∀ {i} → M C₁ i → M C₂ i\n map (inf t) = inf (⟪ m ⟫ (C.map (λ t → λ where .force → map (t .force)) t))\n\n-- unfold\n\nmodule _ {s p ℓ} {C : Container s p} (open Container C)\n {S : Set ℓ} (alg : S → ⟦ C ⟧ S) where\n\n unfold : S → ∀ {i} → M C i\n unfold seed = let (x , next) = alg seed in\n inf (x , λ p → λ where .force → unfold (next p))\n", "meta": {"hexsha": "7f4eefc59fd34fc63d61b4ba510d69d3579e7be2", "size": 1223, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/M.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.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.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.7954545455, "max_line_length": 77, "alphanum_fraction": 0.4873262469, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972650509008, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.5883188077804902}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Matrix where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.HLevels\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 hiding (_+_ ; _·_; +-comm ; +-assoc; ·-assoc)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Sigma.Base\nopen import Cubical.Data.FinData\nopen import Cubical.Relation.Nullary\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.Ring.BigOps\n\nopen Iso\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 (M fm))\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 (⊥.rec ∘ ¬Fin0)\nFinMatrix→VecMatrix→FinMatrix {n = zero} M = funExt₂ (λ _ → ⊥.rec ∘ ¬Fin0)\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 (M ∘ suc)) fm fn ≡ M fm fn\n goal zero zero = refl\n goal zero (suc fn) i = FinVec→Vec→FinVec (M zero ∘ suc) i fn\n goal (suc fm) fn i = FinMatrix→VecMatrix→FinMatrix (M ∘ suc) 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)\nfun (FinMatrixIsoVecMatrix A m n) = FinMatrix→VecMatrix\ninv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix\nrightInv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix→VecMatrix\nleftInv (FinMatrixIsoVecMatrix A m n) = 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-- Define abelian group structure on matrices\nmodule FinMatrixAbGroup (G' : AbGroup ℓ) where\n\n open AbGroupStr (snd G') renaming ( is-set to isSetG )\n private G = ⟨ G' ⟩\n\n zeroFinMatrix : ∀ {m n} → FinMatrix G m n\n zeroFinMatrix _ _ = 0g\n\n negFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n\n negFinMatrix M i j = - M i j\n\n addFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n → FinMatrix G m n\n addFinMatrix M N i j = M i j + N i j\n\n isSetFinMatrix : ∀ {m n} → isSet (FinMatrix G m n)\n isSetFinMatrix = isSetΠ2 λ _ _ → isSetG\n\n addFinMatrixAssoc : ∀ {m n} → (M N K : FinMatrix G m n)\n → addFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (addFinMatrix M N) K\n addFinMatrixAssoc M N K i j k = assoc (M j k) (N j k) (K j k) i\n\n addFinMatrix0r : ∀ {m n} → (M : FinMatrix G m n)\n → addFinMatrix M zeroFinMatrix ≡ M\n addFinMatrix0r M i j k = rid (M j k) i\n\n addFinMatrix0l : ∀ {m n} → (M : FinMatrix G m n)\n → addFinMatrix zeroFinMatrix M ≡ M\n addFinMatrix0l M i j k = lid (M j k) i\n\n addFinMatrixNegMatrixr : ∀ {m n} → (M : FinMatrix G m n)\n → addFinMatrix M (negFinMatrix M) ≡ zeroFinMatrix\n addFinMatrixNegMatrixr M i j k = invr (M j k) i\n\n addFinMatrixNegMatrixl : ∀ {m n} → (M : FinMatrix G m n)\n → addFinMatrix (negFinMatrix M) M ≡ zeroFinMatrix\n addFinMatrixNegMatrixl M i j k = invl (M j k) i\n\n addFinMatrixComm : ∀ {m n} → (M N : FinMatrix G m n)\n → addFinMatrix M N ≡ addFinMatrix N M\n addFinMatrixComm M N i k l = comm (M k l) (N k l) i\n\n FinMatrixAbGroup : (m n : ℕ) → AbGroup ℓ\n FinMatrixAbGroup m n =\n makeAbGroup {G = FinMatrix G m n} zeroFinMatrix addFinMatrix negFinMatrix\n isSetFinMatrix addFinMatrixAssoc addFinMatrix0r\n addFinMatrixNegMatrixr addFinMatrixComm\n\n\n-- Define a abelian group structure on vector matrices and prove that\n-- it is equal to FinMatrixAbGroup using the SIP\nmodule _ (G' : AbGroup ℓ) where\n\n open AbGroupStr (snd G')\n private G = ⟨ G' ⟩\n zeroVecMatrix : ∀ {m n} → VecMatrix G m n\n zeroVecMatrix = replicate (replicate 0g)\n\n negVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n\n negVecMatrix = map (map (λ x → - x))\n\n addVec : ∀ {m} → Vec G m → Vec G m → Vec G m\n addVec [] [] = []\n addVec (x ∷ xs) (y ∷ ys) = x + y ∷ addVec xs ys\n\n addVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n → VecMatrix G m n\n addVecMatrix [] [] = []\n addVecMatrix (M ∷ MS) (N ∷ NS) = addVec M N ∷ addVecMatrix MS NS\n\n open FinMatrixAbGroup\n\n -- Proof that FinMatrix→VecMatrix is a group homorphism\n FinMatrix→VecMatrixHomAdd : (m n : ℕ) (M N : FinMatrix G m n)\n → FinMatrix→VecMatrix (addFinMatrix G' M N) ≡\n addVecMatrix (FinMatrix→VecMatrix M) (FinMatrix→VecMatrix N)\n FinMatrix→VecMatrixHomAdd zero n M N = refl\n FinMatrix→VecMatrixHomAdd (suc m) n M N =\n λ i → lem n (M zero) (N zero) i\n ∷ FinMatrix→VecMatrixHomAdd m n (λ i j → M (suc i) j) (λ i j → N (suc i) j) i\n where\n lem : (n : ℕ) (V W : FinVec G n)\n → FinVec→Vec (λ j → V j + W j) ≡ addVec (FinVec→Vec V) (FinVec→Vec W)\n lem zero V W = refl\n lem (suc n) V W = λ i → V zero + W zero ∷ lem n (V ∘ suc) (W ∘ suc) i\n\n -- Combine everything to get an induced abelian group structure of\n -- VecMatrix that is equal to the one on FinMatrix\n VecMatrixAbGroup : (m n : ℕ) → AbGroup ℓ\n VecMatrixAbGroup m n =\n InducedAbGroup (FinMatrixAbGroup G' m n) addVecMatrix\n FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n)\n\n FinMatrixAbGroup≡VecMatrixAbGroup : (m n : ℕ) → FinMatrixAbGroup G' m n ≡ VecMatrixAbGroup m n\n FinMatrixAbGroup≡VecMatrixAbGroup m n =\n InducedAbGroupPath (FinMatrixAbGroup G' m n) addVecMatrix\n FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n)\n\n\n-- Define identity matrix and matrix multiplication for FinMatrix and\n-- prove that square matrices form a ring\nmodule _ (R' : Ring ℓ) where\n\n open RingStr (snd R') renaming ( is-set to isSetR )\n open RingTheory R'\n open KroneckerDelta R'\n open Sum R'\n open FinMatrixAbGroup (_ , abgroupstr _ _ _ (snd R' .RingStr.+IsAbGroup))\n\n private R = ⟨ R' ⟩\n\n oneFinMatrix : ∀ {n} → FinMatrix R n n\n oneFinMatrix i j = δ i j\n\n mulFinMatrix : ∀ {m1 m2 m3} → FinMatrix R m1 m2 → FinMatrix R m2 m3 → FinMatrix R m1 m3\n mulFinMatrix M N i k = ∑ λ j → M i j · N j k\n\n ∑Exchange : ∀ {m n} → (M : FinMatrix R m n) → ∑ (λ i → ∑ (λ j → M i j)) ≡ ∑ (λ j → ∑ (λ i → M i j))\n ∑Exchange {m = zero} {n = n} M = sym (∑0r n)\n ∑Exchange {m = suc m} {n = zero} M = cong (λ x → 0r + x) (∑0r m) ∙ +Rid 0r\n ∑Exchange {m = suc m} {n = suc n} M =\n let a = M zero zero\n L = ∑ λ j → M zero (suc j)\n C = ∑ λ i → M (suc i) zero\n N = ∑ λ i → ∑ λ j → M (suc i) (suc j)\n -- N reindexed\n N' = ∑ λ j → ∑ λ i → M (suc i) (suc j)\n in a + L + ∑ (λ i → ∑ (λ j → M (suc i) j)) ≡⟨ (λ k → a + L + ∑Split (λ i → M (suc i) zero) (λ i → ∑ (λ j → M (suc i) (suc j))) k) ⟩\n a + L + (C + N) ≡⟨ (λ k → a + L + (C + ∑Exchange (λ i j → M (suc i) (suc j)) k)) ⟩\n a + L + (C + N') ≡⟨ sym (+Assoc _ _ _) ⟩\n a + (L + (C + N')) ≡⟨ (λ k → a + +Assoc-comm1 L C N' k) ⟩\n a + (C + (L + N')) ≡⟨ +Assoc _ _ _ ⟩\n a + C + (L + N') ≡⟨ (λ k → a + C + ∑Split (λ j → M zero (suc j)) (λ j → ∑ (λ i → M (suc i) (suc j))) (~ k)) ⟩\n a + C + ∑ (λ j → ∑ (λ i → M i (suc j))) ∎\n\n\n mulFinMatrixAssoc : ∀ {m n k l} → (M : FinMatrix R m n) → (N : FinMatrix R n k) → (K : FinMatrix R k l)\n → mulFinMatrix M (mulFinMatrix N K) ≡ mulFinMatrix (mulFinMatrix M N) K\n mulFinMatrixAssoc M N K = funExt₂ λ i j →\n ∑ (λ k → M i k · ∑ (λ l → N k l · K l j)) ≡⟨ ∑Ext (λ k → ∑Mulrdist (M i k) (λ l → N k l · K l j)) ⟩\n ∑ (λ k → ∑ (λ l → M i k · (N k l · K l j))) ≡⟨ ∑Ext (λ k → ∑Ext (λ l → ·Assoc (M i k) (N k l) (K l j))) ⟩\n ∑ (λ k → ∑ (λ l → M i k · N k l · K l j)) ≡⟨ ∑Exchange (λ k l → M i k · N k l · K l j) ⟩\n ∑ (λ l → ∑ (λ k → M i k · N k l · K l j)) ≡⟨ ∑Ext (λ l → sym (∑Mulldist (K l j) (λ k → M i k · N k l))) ⟩\n ∑ (λ l → ∑ (λ k → M i k · N k l) · K l j) ∎\n\n mulFinMatrixr1 : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix M oneFinMatrix ≡ M\n mulFinMatrixr1 M = funExt₂ λ i j → ∑Mulr1 _ (M i) j\n\n mulFinMatrix1r : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix oneFinMatrix M ≡ M\n mulFinMatrix1r M = funExt₂ λ i j → ∑Mul1r _ (λ x → M x j) i\n\n mulFinMatrixrDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n)\n → mulFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (mulFinMatrix M N) (mulFinMatrix M K)\n mulFinMatrixrDistrAddFinMatrix M N K = funExt₂ λ i j →\n ∑ (λ k → M i k · (N k j + K k j)) ≡⟨ ∑Ext (λ k → ·Rdist+ (M i k) (N k j) (K k j)) ⟩\n ∑ (λ k → M i k · N k j + M i k · K k j) ≡⟨ ∑Split (λ k → M i k · N k j) (λ k → M i k · K k j) ⟩\n ∑ (λ k → M i k · N k j) + ∑ (λ k → M i k · K k j) ∎\n\n mulFinMatrixlDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n)\n → mulFinMatrix (addFinMatrix M N) K ≡ addFinMatrix (mulFinMatrix M K) (mulFinMatrix N K)\n mulFinMatrixlDistrAddFinMatrix M N K = funExt₂ λ i j →\n ∑ (λ k → (M i k + N i k) · K k j) ≡⟨ ∑Ext (λ k → ·Ldist+ (M i k) (N i k) (K k j)) ⟩\n ∑ (λ k → M i k · K k j + N i k · K k j) ≡⟨ ∑Split (λ k → M i k · K k j) (λ k → N i k · K k j) ⟩\n ∑ (λ k → M i k · K k j) + ∑ (λ k → N i k · K k j) ∎\n\n FinMatrixRing : (n : ℕ) → Ring ℓ\n FinMatrixRing n =\n makeRing {R = FinMatrix R n n} zeroFinMatrix oneFinMatrix addFinMatrix\n mulFinMatrix negFinMatrix isSetFinMatrix addFinMatrixAssoc\n addFinMatrix0r addFinMatrixNegMatrixr addFinMatrixComm\n mulFinMatrixAssoc mulFinMatrixr1 mulFinMatrix1r\n mulFinMatrixrDistrAddFinMatrix mulFinMatrixlDistrAddFinMatrix\n", "meta": {"hexsha": "cef98de17538165ab77fbc3c181e9beba05ea885", "size": 11006, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Matrix.agda", "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 301, "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_issues_repo_path": "Cubical/Algebra/Matrix.agda", "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 584, "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_forks_repo_path": "Cubical/Algebra/Matrix.agda", "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 134, "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "avg_line_length": 44.024, "max_line_length": 140, "alphanum_fraction": 0.5956750863, "num_tokens": 4133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7853085708384735, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.5882646043655861}} {"text": "{-# OPTIONS --type-in-type #-} -- yes, there will be some cheating in this lecture\n\nmodule Lec3Done where\n\nopen import Lec1Done\nopen import Lec2Done\n\npostulate\n extensionality : {S : Set}{T : S -> Set}\n {f g : (x : S) -> T x} ->\n ((x : S) -> f x == g x) ->\n f == g\n\nimp : {S : Set}{T : S -> Set}(f : (x : S) -> T x){x : S} -> T x\nimp f {x} = f x\n\nextensionality' : {S : Set}{T : S -> Set}\n {f g : {x : S} -> T x} ->\n ((x : S) -> f {x} == g {x}) ->\n _==_ {forall {x : S} -> T x} f g\nextensionality' {f = f}{g = g} q =\n refl imp =$= extensionality {f = \\ x -> f {x}}{g = \\ x -> g {x}}\n q \n\n_[QED] : {X : Set}(x : X) -> x == x\nx [QED] = refl x\n_=[_>=_ : {X : Set}(x : X){y z : X} -> x == y -> y == z -> x == z\nx =[ refl .x >= q = q\n_=<_]=_ : {X : Set}(x : X){y z : X} -> y == x -> y == z -> x == z\nx =< refl .x ]= q = q\ninfixr 1 _=[_>=_ _=<_]=_\ninfixr 2 _[QED]\n\nrecord Category : Set where\n field\n\n -- two types of thing\n Obj : Set -- \"objects\"\n _~>_ : Obj -> Obj -> Set -- \"arrows\" or \"morphisms\"\n -- or \"homomorphisms\"\n \n -- two operations\n id~> : {T : Obj} -> T ~> T\n _>~>_ : {R S T : Obj} -> R ~> S -> S ~> T -> R ~> T\n\n -- three laws\n law-id~>>~> : {S T : Obj} (f : S ~> T) ->\n (id~> >~> f) == f\n law->~>id~> : {S T : Obj} (f : S ~> T) ->\n (f >~> id~>) == f\n law->~>>~> : {Q R S T : Obj} (f : Q ~> R)(g : R ~> S)(h : S ~> T) ->\n ((f >~> g) >~> h) == (f >~> (g >~> h))\n\n assocn : {Q R R' S T : Obj}\n {f : Q ~> R} {g : R ~> S}\n {f' : Q ~> R'}{g' : R' ~> S}\n {h : S ~> T} ->\n (f >~> g) == (f' >~> g') ->\n (f >~> g >~> h) == (f' >~> g' >~> h)\n assocn {f = f} {g = g} {f' = f'} {g' = g'} {h = h} q =\n f >~> g >~> h\n =< law->~>>~> _ _ _ ]=\n (f >~> g) >~> h\n =[ refl _>~>_ =$= q =$= refl h >=\n (f' >~> g') >~> h\n =[ law->~>>~> _ _ _ >=\n f' >~> g' >~> h\n [QED]\n\n infixr 3 _>~>_\n\n-- Sets and functions are the classic example of a category.\nSET : Category\nSET = record\n { Obj = Set\n ; _~>_ = \\ S T -> S -> T\n ; id~> = id\n ; _>~>_ = _>>_\n ; law-id~>>~> = \\ f -> refl f\n ; law->~>id~> = \\ f -> refl f\n ; law->~>>~> = \\ f g h -> refl (f >> (g >> h))\n }\n\n-- A PREORDER is a category where there is at most one arrow between\n-- any two objects. (So arrows are unique.)\nNAT->= : Category\nunique->= : (m n : Nat)(p q : m >= n) -> p == q\nunique->= m zero p q = refl <>\nunique->= zero (suc n) () q\nunique->= (suc m) (suc n) p q = unique->= m n p q\n\nNAT->= = record\n { Obj = Nat\n ; _~>_ = _>=_\n ; id~> = \\ {n} -> refl->= n\n ; _>~>_ = \\ {m}{n}{p} m>=n n>=p -> trans->= m n p m>=n n>=p\n ; law-id~>>~> = \\ {m}{n} m>=n -> unique->= m n _ _\n ; law->~>id~> = \\ {m}{n} m>=n -> unique->= m n _ _\n ; law->~>>~> = \\ {m}{n}{p}{q} m>n n>=p p>=q -> unique->= m q _ _\n } where\n\n-- A MONOID is a category with Obj = One.\n-- The values in the monoid are the *arrows*.\nONE-Nat : Category\nONE-Nat = record\n { Obj = One\n ; _~>_ = \\ _ _ -> Nat\n ; id~> = 0\n ; _>~>_ = _+N_\n ; law-id~>>~> = \\ n -> zero-+N n\n ; law->~>id~> = \\ n -> +N-zero n\n ; law->~>>~> = \\ m n p -> assocLR-+N m n p\n }\n\neqUnique : {X : Set}{x y : X}(p q : x == y) -> p == q\neqUnique (refl x) (refl .x) = refl (refl x)\n\n-- A DISCRETE category is one where the only arrows are the identities.\nDISCRETE : (X : Set) -> Category\nDISCRETE X = record\n { Obj = X\n ; _~>_ = _==_\n ; id~> = refl _\n ; _>~>_ = \\ { {x} (refl .x) (refl .x) -> refl x }\n ; law-id~>>~> = \\ _ -> eqUnique _ _\n ; law->~>id~> = \\ _ -> eqUnique _ _\n ; law->~>>~> = \\ _ _ _ -> eqUnique _ _\n }\n\nmodule FUNCTOR where\n open Category\n \n record _=>_ (C D : Category) : Set where -- \"Functor from C to D\"\n field\n -- two actions\n F-Obj : Obj C -> Obj D\n F-map : {S T : Obj C} -> _~>_ C S T -> _~>_ D (F-Obj S) (F-Obj T)\n\n -- two laws\n F-map-id~> : {T : Obj C} -> F-map (id~> C {T}) == id~> D {F-Obj T}\n F-map->~> : {R S T : Obj C}(f : _~>_ C R S)(g : _~>_ C S T) ->\n F-map (_>~>_ C f g) == _>~>_ D (F-map f) (F-map g)\n\nopen FUNCTOR public\n\npostulate homework : {A : Set} -> A\n\nVEC : Nat -> SET => SET\nVEC n = record\n { F-Obj = \\ X -> Vec X n\n ; F-map = homework\n ; F-map-id~> = homework\n ; F-map->~> = homework\n }\n\nVTAKE : Set -> NAT->= => SET\nVTAKE X = record\n { F-Obj = Vec X\n ; F-map = \\ {m}{n} m>=n xs -> vTake m n m>=n xs\n ; F-map-id~> = \\ {n} -> extensionality \\ xs -> vTakeIdFact n xs\n ; F-map->~> = \\ {m}{n}{p} m>=n n>=p -> extensionality \\ xs ->\n vTakeCpFact m n p m>=n n>=p xs\n }\n\nADD : Nat -> NAT->= => NAT->=\nADD d = record { F-Obj = (d +N_)\n ; F-map = \\ {m}{n} -> help d m n\n ; F-map-id~> = \\ {n} -> unique->= (d +N n) (d +N n) _ _\n ; F-map->~> = \\ {m}{n}{p} x y ->\n unique->= (d +N m) (d +N p) _ _\n } where\n help : (d m n : Nat) -> m >= n -> (d +N m) >= (d +N n)\n help zero m n m>=n = m>=n\n help (suc d) m n m>=n = help d m n m>=n\n\nThing : {C D : Category}(F G : C => D) -> Set\nThing {C}{D}\n (record { F-Obj = F-Obj ; F-map = F-map\n ; F-map-id~> = F-map-id~> ; F-map->~> = F-map->~> })\n (record { F-Obj = G-Obj ; F-map = G-map\n ; F-map-id~> = G-map-id~> ; F-map->~> = G-map->~> })\n = Sg (F-Obj == G-Obj)\n \\ { (refl _) ->\n Sg (_==_ {forall {S T : Category.Obj C} →\n (C Category.~> S) T → (D Category.~> F-Obj S) (F-Obj T)}\n F-map G-map)\n \\ { (refl _) ->\n _==_ {forall {T : Category.Obj C} →\n F-map (Category.id~> C {T}) == Category.id~> D} F-map-id~> G-map-id~>\n *\n _==_ {forall {R S T : Category.Obj C} (f : (C Category.~> R) S)\n (g : (C Category.~> S) T) →\n F-map ((C Category.>~> f) g) == (D Category.>~> F-map f) (F-map g)}\n F-map->~> G-map->~>\n }}\n\nLemma : {C D : Category}{F G : C => D} -> Thing F G -> F == G\nLemma (refl _ , (refl _ , (refl _ , refl _))) = refl _\n\n\nCATEGORY : Category\nCATEGORY = record\n { Obj = Category\n ; _~>_ = _=>_\n ; id~> = record { F-Obj = \\ X -> X\n ; F-map = \\ a -> a\n ; F-map-id~> = refl _\n ; F-map->~> = \\ _ _ -> refl _ }\n ; _>~>_ = \\ {R}{S}{T} F G -> record\n { F-Obj = F-Obj F >> F-Obj G\n ; F-map = F-map F >> F-map G\n ; F-map-id~> = F-map G (F-map F (Category.id~> R))\n =[ refl (F-map G) =$= F-map-id~> F >=\n F-map G (Category.id~> S)\n =[ F-map-id~> G >=\n Category.id~> T\n [QED]\n ; F-map->~> = \\ f g ->\n F-map G (F-map F (Category._>~>_ R f g))\n =[ refl (F-map G) =$= F-map->~> F f g >=\n F-map G (Category._>~>_ S (F-map F f) (F-map F g))\n =[ F-map->~> G (F-map F f) (F-map F g) >=\n Category._>~>_ T (F-map G (F-map F f))\n (F-map G (F-map F g))\n [QED]\n }\n ; law-id~>>~> = \\ F -> Lemma\n ((refl _) , ((refl _) ,\n (extensionality' (\\ x -> eqUnique _ _) ,\n extensionality' (\\ x ->\n extensionality' \\ y -> extensionality' \\ z ->\n extensionality \\ f -> extensionality \\ g ->\n eqUnique _ _))))\n ; law->~>id~> = \\ F -> Lemma\n ((refl _) , ((refl _) ,\n (extensionality' (\\ x -> eqUnique _ _) ,\n extensionality' (\\ x ->\n extensionality' \\ y -> extensionality' \\ z ->\n extensionality \\ f -> extensionality \\ g ->\n eqUnique _ _))))\n ; law->~>>~> = \\ F G H -> Lemma\n ((refl _) , ((refl _) ,\n (extensionality' (\\ x -> eqUnique _ _) ,\n extensionality' (\\ x ->\n extensionality' \\ y -> extensionality' \\ z ->\n extensionality \\ f -> extensionality \\ g ->\n eqUnique _ _))))\n } where\n open _=>_\n \n", "meta": {"hexsha": "52b8d95462a20ebd0b6b67ac8e30023cde93173e", "size": 9003, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec3Done.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/Lec3Done.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/Lec3Done.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": 35.8685258964, "max_line_length": 83, "alphanum_fraction": 0.3548817061, "num_tokens": 3110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672043084051, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.5882530810336631}} {"text": "module PiFrac where\n\nopen import Level\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Sum\nopen import Data.Product\n\ninfixr 20 _◎_\n\ndata <_> {A : Set} : A → Set where\n singleton : (x : A) -> < x > \n\nmutual\n\n data B : Set₁ where\n ZERO : B \n ONE : B\n PLUS : B → B → B\n TIMES : B → B → B\n SING : (b : B) → ⟦ b ⟧ → B\n RECIP : (b : B) → ⟦ b ⟧ → B\n DPAIR : (b : B) → (⟦ b ⟧ → B) → B\n\n ⟦_⟧ : B → Set\n ⟦ ZERO ⟧ = ⊥\n ⟦ ONE ⟧ = ⊤\n ⟦ PLUS b₁ b₂ ⟧ = ⟦ b₁ ⟧ ⊎ ⟦ b₂ ⟧\n ⟦ TIMES b₁ b₂ ⟧ = ⟦ b₁ ⟧ × ⟦ b₂ ⟧\n ⟦ SING b v ⟧ = <_> {⟦ b ⟧} v\n ⟦ RECIP b v ⟧ = <_> {⟦ b ⟧} v → ⊤\n ⟦ DPAIR b c ⟧ = Σ ⟦ b ⟧ (λ v → ⟦ c v ⟧)\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 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 η : {b : B} → ONE ⟷ DPAIR b (λ v → RECIP b v)\n ε : {b : B} → DPAIR b (λ v → RECIP b v) ⟷ ONE \n\nmutual\n eval : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₁ ⟧ → ⟦ b₂ ⟧\n eval unite₊ (inj₁ ())\n eval unite₊ (inj₂ v) = v\n eval uniti₊ v = inj₂ v\n eval swap₊ (inj₁ x) = inj₂ x\n eval swap₊ (inj₂ y) = inj₁ y\n eval assocl₊ (inj₁ x) = inj₁ (inj₁ x)\n eval assocl₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x)\n eval assocl₊ (inj₂ (inj₂ x)) = inj₂ x\n eval assocr₊ (inj₁ (inj₁ x)) = inj₁ x\n eval assocr₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y)\n eval assocr₊ (inj₂ y) = inj₂ (inj₂ y)\n eval unite⋆ (tt , x) = x\n eval uniti⋆ v = ( tt , v)\n eval swap⋆ (v₁ , v₂) = (v₂ , v₁)\n eval assocl⋆ (x , (y , z)) = ((x , y), z)\n eval assocr⋆ ((x , y), z) = (x , (y , z))\n eval id⟷ v = v\n eval (sym c) v = evalB c v\n eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v)\n eval (c₁ ⊕ c₂) (inj₁ x) = inj₁ (eval c₁ x)\n eval (c₁ ⊕ c₂) (inj₂ y) = inj₂ (eval c₂ y)\n eval (c₁ ⊗ c₂) (x , y) = (eval c₁ x , eval c₂ y)\n eval (η {b}) tt = {!!}\n eval (ε {b}) (w , c) = c (singleton w)\n\n evalB : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₂ ⟧ → ⟦ b₁ ⟧\n evalB uniti₊ (inj₁ ())\n evalB uniti₊ (inj₂ v) = v\n evalB unite₊ v = inj₂ v\n evalB swap₊ (inj₁ x) = inj₂ x\n evalB swap₊ (inj₂ y) = inj₁ y\n evalB assocr₊ (inj₁ x) = inj₁ (inj₁ x)\n evalB assocr₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x)\n evalB assocr₊ (inj₂ (inj₂ x)) = inj₂ x\n evalB assocl₊ (inj₁ (inj₁ x)) = inj₁ x\n evalB assocl₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y)\n evalB assocl₊ (inj₂ y) = inj₂ (inj₂ y)\n evalB uniti⋆ (tt , x) = x\n evalB unite⋆ v = ( tt , v)\n evalB swap⋆ (v₁ , v₂) = (v₂ , v₁)\n evalB assocr⋆ (x , (y , z)) = ((x , y), z)\n evalB assocl⋆ ((x , y), z) = (x , (y , z))\n evalB id⟷ v = v\n evalB (sym c) v = eval c v\n evalB (c₁ ◎ c₂) v = evalB c₁ (evalB c₂ v)\n evalB (c₁ ⊕ c₂) (inj₁ x) = inj₁ (evalB c₁ x)\n evalB (c₁ ⊕ c₂) (inj₂ y) = inj₂ (evalB c₂ y)\n evalB (c₁ ⊗ c₂) (x , y) = (evalB c₁ x , evalB c₂ y)\n evalB (η {b}) (w , c) = c (singleton w)\n evalB (ε {b}) tt = {!!}\n\n\n -- this is better in that one can't use inj₂ tt on the rhs\n-- the overly precise version doesn't type check, don't know why\ntest : ⊤\ntest = eval (ε {PLUS ONE ONE}) (inj₁ tt , f)\n where f : < inj₁ {B = ⊤} tt > → ⊤\n-- f (singleton (inj₁ {B = ⊤} tt)) = tt\n f x = tt\n{-\nmutual\n data B : Set where\n ONE : B\n PLUS : B → B → B\n TIMES : B → B → B\n MATCH : {b : B} → Singleton b → B\n DPAIR : {b : B} → (Σ (BV b) Singleton) → B\n\n\nmutual \n eval : {b₁ b₂ : B} → b₁ ⟷ b₂ → BV b₁ → BV b₂\n eval swap₊ (LEFT v) = RIGHT v\n eval swap₊ (RIGHT v) = LEFT v\n eval (η {b₁} {v}) UNIT = NCPROD b₁ v\n eval assocl₊ (LEFT v) = LEFT (LEFT v)\n eval assocl₊ (RIGHT (LEFT v)) = LEFT (RIGHT v)\n eval assocl₊ (RIGHT (RIGHT v)) = RIGHT v\n eval assocr₊ (LEFT (LEFT v)) = LEFT v\n eval assocr₊ (LEFT (RIGHT v)) = RIGHT (LEFT v)\n eval assocr₊ (RIGHT v) = RIGHT (RIGHT v)\n eval unite⋆ (PAIR UNIT v) = v\n eval uniti⋆ v = PAIR UNIT v\n eval (ε {b₁} {v}) (NCPROD .b₁ .v) = UNIT\n eval id⟷ v = v\n eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v)\n eval (c₁ ⊕ c₂) (LEFT v) = LEFT (eval c₁ v)\n eval (c₁ ⊕ c₂) (RIGHT v) = RIGHT (eval c₂ v)\n eval (c₁ ⊗ c₂) (PAIR v₁ v₂) = PAIR (eval c₁ v₁) (eval c₂ v₂)\n eval (lift {b₁} {b₂} {v} c) (NCPROD .b₁ .v) = NCPROD b₂ (eval c v)\n \n-- name : {b₁ b₂ : B} {v : BV b₁} → (b₁ ⟷ b₂) → (ONE ⟷ DPAIR (v , singleton v))\n-- name {b₁} {b₂} {v} c = η {b₁} {v} ◎ (lift (id⟷ ⊗ c))\n\n\n--}\n\n--------------------------------------------------------------------------------\n-- Jacques's code\n\n{--\n\ndata Singleton {A : Set} : A → Set where\n singleton : (x : A) -> Singleton x\n\nmutual\n data B : Set where\n ONE : B\n PLUS : B → B → B\n TIMES : B → B → B\n MATCH : {b : B} → Singleton b → B\n DPAIR : {b : B} → (Σ (BV b) Singleton) → B\n\n data BV : B → Set where\n UNIT : BV ONE\n LEFT : {b₁ b₂ : B} → BV b₁ → BV (PLUS b₁ b₂)\n RIGHT : {b₁ b₂ : B} → BV b₂ → BV (PLUS b₁ b₂)\n PAIR : {b₁ b₂ : B} → BV b₁ → BV b₂ → BV (TIMES b₁ b₂)\n SINGLE : {b₁ : B} → BV b₁ → BV (MATCH {b₁} (singleton b₁)) \n NCPROD : (b₁ : B) → (v : BV b₁) → BV (DPAIR (v , (singleton v)))\n\nmutual \n data _⟷_ : B → B → Set where\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 η : {b₁ : B} {v : BV b₁} → ONE ⟷ DPAIR (v , (singleton v))\n ε : {b₁ : B} {v : BV b₁} → DPAIR (v , (singleton v)) ⟷ ONE\n id⟷ : {b : B } → b ⟷ b\n-- closure combinators \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-- refe⋆ : { b : BF } → RECIP (RECIP b) ⟺ b\n-- refi⋆ : { b : BF } → b ⟺ RECIP (RECIP b) \n-- rile⋆ : { b : BF } → TIMESF b (TIMESF b (RECIP b)) ⟺ b\n-- rili⋆ : { b : BF } → b ⟺ TIMESF b (TIMESF b (RECIP b)) \n lift : {b₁ b₂ : B} {v : BV b₁} → (c : b₁ ⟷ b₂) → \n DPAIR (v , (singleton v)) ⟷ DPAIR (eval c v , (singleton (eval c v)))\n \n eval : {b₁ b₂ : B} → b₁ ⟷ b₂ → BV b₁ → BV b₂\n eval swap₊ (LEFT v) = RIGHT v\n eval swap₊ (RIGHT v) = LEFT v\n eval (η {b₁} {v}) UNIT = NCPROD b₁ v\n eval assocl₊ (LEFT v) = LEFT (LEFT v)\n eval assocl₊ (RIGHT (LEFT v)) = LEFT (RIGHT v)\n eval assocl₊ (RIGHT (RIGHT v)) = RIGHT v\n eval assocr₊ (LEFT (LEFT v)) = LEFT v\n eval assocr₊ (LEFT (RIGHT v)) = RIGHT (LEFT v)\n eval assocr₊ (RIGHT v) = RIGHT (RIGHT v)\n eval unite⋆ (PAIR UNIT v) = v\n eval uniti⋆ v = PAIR UNIT v\n eval (ε {b₁} {v}) (NCPROD .b₁ .v) = UNIT\n eval id⟷ v = v\n eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v)\n eval (c₁ ⊕ c₂) (LEFT v) = LEFT (eval c₁ v)\n eval (c₁ ⊕ c₂) (RIGHT v) = RIGHT (eval c₂ v)\n eval (c₁ ⊗ c₂) (PAIR v₁ v₂) = PAIR (eval c₁ v₁) (eval c₂ v₂)\n eval (lift {b₁} {b₂} {v} c) (NCPROD .b₁ .v) = NCPROD b₂ (eval c v)\n \n-- name : {b₁ b₂ : B} {v : BV b₁} → (b₁ ⟷ b₂) → (ONE ⟷ DPAIR (v , singleton v))\n-- name {b₁} {b₂} {v} c = η {b₁} {v} ◎ (lift (id⟷ ⊗ c))\n\n--}\n", "meta": {"hexsha": "853fc6de7a10812e91492d3cc6a4faaacdbad1fc", "size": 7784, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PiFrac.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/PiFrac.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/PiFrac.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.5955555556, "max_line_length": 80, "alphanum_fraction": 0.4876670092, "num_tokens": 3886, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392909114836, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.5882490843852981}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Construction.Functors where\n\n-- the \"Functor Category\", often denoted [ C , D ]\n\nopen import Level\nopen import Data.Product using (_,_; proj₁; uncurry′)\n\nopen import Categories.Category using (Category; _[_∘_])\nopen import Categories.Category.Equivalence using (StrongEquivalence)\nopen import Categories.Category.Product using (_※ⁿ_) renaming (Product to _×_)\nopen import Categories.Functor using (Functor; _∘F_)\nopen import Categories.Functor.Bifunctor\nopen import Categories.Functor.Construction.Constant using (constNat)\nopen import Categories.NaturalTransformation\n using (NaturalTransformation; _∘ᵥ_; _∘ˡ_; _∘ₕ_) renaming (id to idN)\nopen import Categories.NaturalTransformation.Equivalence using (_≃_; ≃-isEquivalence)\nopen import Categories.NaturalTransformation.NaturalIsomorphism\n using (NaturalIsomorphism)\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o ℓ e o′ ℓ′ e′ : Level\n C D C₁ C₂ : Category o ℓ e\n\n-- The reason the proofs below are so easy is that _∘ᵥ_ 'computes' all the way down into\n-- expressions in D, from which the properties follow.\nFunctors : Category o ℓ e → Category o′ ℓ′ e′ → Category (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) (o ⊔ e′)\nFunctors C D = record\n { Obj = Functor C D\n ; _⇒_ = NaturalTransformation\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 module C = Category C\n module D = Category D\n open D\n\n-- Part of the proof that Cats is a CCC:\neval : Bifunctor (Functors C D) C D\neval {C = C} {D = D} = record\n { F₀ = uncurry′ Functor.F₀\n ; F₁ = λ where\n {F , _} {_ , B} (α , f) →\n let open NaturalTransformation α\n open Functor F\n in η B ∘ F₁ f\n ; identity = λ where\n {F , _} → elimʳ (Functor.identity F)\n ; homomorphism = λ where\n {F , _} {G , B} {_ , C} {α , f} {β , g} →\n let open NaturalTransformation\n open Functor\n in begin\n (η β C ∘ η α C) ∘ F₁ F (g C.∘ f) ≈⟨ refl ⟩∘⟨ homomorphism F ⟩\n (η β C ∘ η α C) ∘ F₁ F g ∘ F₁ F f ≈⟨ assoc ⟩\n η β C ∘ η α C ∘ F₁ F g ∘ F₁ F f ≈⟨ refl ⟩∘⟨ pullˡ (commute α g) ⟩\n η β C ∘ (F₁ G g ∘ η α B) ∘ F₁ F f ≈⟨ refl ⟩∘⟨ assoc ⟩\n η β C ∘ F₁ G g ∘ η α B ∘ F₁ F f ≈˘⟨ assoc ⟩\n (η β C ∘ F₁ G g) ∘ η α B ∘ F₁ F f ∎\n ; F-resp-≈ = λ where\n {F , _} (comm , eq) → ∘-resp-≈ comm (Functor.F-resp-≈ F eq)\n }\n where module C = Category C\n module D = Category D\n open D\n open MR D\n open HomReasoning\n\n-- Currying induces a functor between functor categories -- another\n-- part of the proof that Cats is a catesian closed (bi)category.\n\ncurry : Functor (Functors (C₁ × C₂) D) (Functors C₁ (Functors C₂ D))\ncurry {C₁ = C₁} {C₂ = C₂} {D = D} = record\n { F₀ = curry₀\n ; F₁ = curry₁\n ; identity = Equiv.refl D\n ; homomorphism = Equiv.refl D\n ; F-resp-≈ = λ F≈G {x₁} {x₂} → F≈G {x₁ , x₂}\n }\n where\n open Category\n\n curry₀ : Bifunctor C₁ C₂ D → Functor C₁ (Functors C₂ D)\n curry₀ F = record\n { F₀ = λ c → appˡ F c\n ; F₁ = λ f → F ∘ˡ (constNat f ※ⁿ idN)\n ; identity = identity\n ; homomorphism = λ {_} {_} {_} {f} {g} → begin\n F₁ (C₁ [ g ∘ f ] , id C₂)\n ≈˘⟨ F-resp-≈ (Equiv.refl C₁ , identityˡ C₂) ⟩\n F₁ (C₁ [ g ∘ f ] , C₂ [ id C₂ ∘ id C₂ ])\n ≈⟨ homomorphism ⟩\n D [ F₁ (g , id C₂) ∘ F₁ (f , id C₂) ]\n ∎\n ; F-resp-≈ = λ f≈g → F-resp-≈ (f≈g , Equiv.refl C₂)\n }\n where\n open Functor F\n open HomReasoning D\n\n curry₁ : {F G : Bifunctor C₁ C₂ D} →\n NaturalTransformation F G →\n NaturalTransformation (curry₀ F) (curry₀ G)\n curry₁ α = record\n { η = λ c → record\n { η = λ a → η α (c , a)\n ; commute = λ f → commute α (id C₁ , f)\n ; sym-commute = λ f → sym-commute α (id C₁ , f)\n }\n ; commute = λ f → commute α (f , id C₂)\n ; sym-commute = λ f → sym-commute α (f , id C₂)\n }\n where open NaturalTransformation\n\nmodule curry {o₁ e₁ ℓ₁} {C₁ : Category o₁ e₁ ℓ₁}\n {o₂ e₂ ℓ₂} {C₂ : Category o₂ e₂ ℓ₂}\n {o′ e′ ℓ′} {D : Category o′ e′ ℓ′}\n where\n open Functor (curry {C₁ = C₁} {C₂ = C₂} {D = D}) public\n open Category\n open NaturalIsomorphism\n\n -- Currying preserves natural isos.\n -- This makes |curry.F₀| a map between the hom-setoids of Cats.\n\n resp-NI : {F G : Bifunctor C₁ C₂ D} →\n NaturalIsomorphism F G → NaturalIsomorphism (F₀ F) (F₀ G)\n resp-NI α = record\n { F⇒G = F₁ (F⇒G α)\n ; F⇐G = F₁ (F⇐G α)\n ; iso = λ x → record\n { isoˡ = iso.isoˡ α (x , _)\n ; isoʳ = iso.isoʳ α (x , _)\n }\n }\n\n-- Godement product ?\nproduct : {A B C : Category o ℓ e} → Bifunctor (Functors B C) (Functors A B) (Functors A C)\nproduct {A = A} {B = B} {C = C} = record\n { F₀ = uncurry′ _∘F_\n ; F₁ = uncurry′ _∘ₕ_\n ; identity = λ {f} → identityʳ ○ identity {D = C} (proj₁ f)\n ; homomorphism = λ { {_ , F₂} {G₁ , G₂} {H₁ , _} {f₁ , f₂} {g₁ , g₂} {x} → begin\n F₁ H₁ (η g₂ x B.∘ η f₂ x) ∘ η g₁ (F₀ F₂ x) ∘ η f₁ (F₀ F₂ x)\n ≈⟨ ∘-resp-≈ˡ (homomorphism H₁) ○ assoc ○ ∘-resp-≈ʳ (⟺ assoc) ⟩\n F₁ H₁ (η g₂ x) ∘ (F₁ H₁ (η f₂ x) ∘ η g₁ (F₀ F₂ x)) ∘ η f₁ (F₀ F₂ x)\n ≈⟨ ⟺ ( refl⟩∘⟨ ( commute g₁ (η f₂ x) ⟩∘⟨refl) ) ⟩\n F₁ H₁ (η g₂ x) ∘ (η g₁ (F₀ G₂ x) ∘ F₁ G₁ (η f₂ x)) ∘ η f₁ (F₀ F₂ x)\n ≈⟨ ∘-resp-≈ʳ assoc ○ ⟺ assoc ⟩\n (F₁ H₁ (η g₂ x) ∘ η g₁ (F₀ G₂ x)) ∘ F₁ G₁ (η f₂ x) ∘ η f₁ (F₀ F₂ x) ∎ }\n ; F-resp-≈ = λ { {_} {g₁ , _} (≈₁ , ≈₂) → ∘-resp-≈ (F-resp-≈ g₁ ≈₂) ≈₁ }\n }\n where\n open Category C\n open HomReasoning\n open Functor\n module B = Category B\n open NaturalTransformation\n\n-- op induces a Functor on the Functors category.\n-- This is an instance where the proof-irrelevant version is simpler because (op op C) is\n-- just C. Here we rather need to be more explicit.\nopF⇒ : {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 = Equiv.refl\n ; homomorphism = Equiv.refl\n ; F-resp-≈ = λ eq → eq\n }\n where open Category B\n\nopF⇐ : {A : Category o ℓ e} {B : Category o′ ℓ′ e′} →\n Functor (Functors A B) (Category.op (Functors (Category.op A) (Category.op B)))\nopF⇐ {A = A} {B} = record\n { F₀ = Functor.op\n ; F₁ = NaturalTransformation.op\n ; identity = Equiv.refl\n ; homomorphism = Equiv.refl\n ; F-resp-≈ = λ eq → eq\n }\n where open Category B\n\nFunctorsᵒᵖ-equiv : {A : Category o ℓ e} {B : Category o′ ℓ′ e′} →\n StrongEquivalence (Category.op (Functors (Category.op A) (Category.op B))) (Functors A B)\nFunctorsᵒᵖ-equiv {B = B} = record\n { F = opF⇒\n ; G = opF⇐\n ; weak-inverse = record\n { F∘G≈id = record\n { F⇒G = record\n { η = λ _ → idN\n ; commute = λ _ → id-comm-sym\n ; sym-commute = λ _ → id-comm\n }\n ; F⇐G = record\n { η = λ _ → idN\n ; commute = λ _ → id-comm-sym\n ; sym-commute = λ _ → id-comm\n }\n ; iso = λ _ → record\n { isoˡ = identityˡ\n ; isoʳ = identityˡ\n }\n }\n ; G∘F≈id = record\n { F⇒G = record\n { η = λ _ → idN\n ; commute = λ _ → id-comm-sym\n ; sym-commute = λ _ → id-comm\n }\n ; F⇐G = record\n { η = λ _ → idN\n ; commute = λ _ → id-comm-sym\n ; sym-commute = λ _ → id-comm\n }\n ; iso = λ _ → record\n { isoˡ = identityˡ\n ; isoʳ = identityˡ\n }\n }\n }\n }\n where open Category B\n open HomReasoning\n open MR B\n", "meta": {"hexsha": "d0a1950b8a839432ab7b8c50695684f14ab1e2b8", "size": 8027, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Category/Construction/Functors.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/Functors.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/Functors.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.7268907563, "max_line_length": 110, "alphanum_fraction": 0.5355674598, "num_tokens": 3138, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392695254318, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.5882490701547932}} {"text": "\ninfixr 2 _×_\ninfixr 2 _,_\nrecord Σ (A : Set) (B : A → Set) : Set where\n constructor _,_\n field\n fst : A\n snd : B fst\n\n_×_ : Set → Set → Set\nA × B = Σ A λ _ → B\n\nsyntax Σ A (λ x → B) = Σ[ x ∶ A ] B\n\ndata W (A : Set) (B : A → Set) : Set where\n sup : (x : A) → ((p : B x) → W A B) → W A B\n\n-- Should be able to get φ (λ x → (k x) , rec φ (k x)))\n-- just using refine.\nrec : ∀ {S P}{X : Set} → (Σ[ s ∶ S ] (P s → W S P × X) → X) → W S P → X\nrec φ (sup s k) = {!!}\n\npostulate\n A : Set\n a : A\n\n-- Refine hole as far as possible.\n-- Should get: (? , ?) , (λ x → ?) , λ x → ?\ntest-refine : (A × A) × (A → A) × (A → A)\ntest-refine = {!!}\n", "meta": {"hexsha": "d6699a04d2c34fa2a06ef32bbb99a4901f5b7161", "size": 641, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue737.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/Issue737.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/Issue737.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": 20.6774193548, "max_line_length": 71, "alphanum_fraction": 0.4586583463, "num_tokens": 286, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891130942474, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.588213825568213}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.EilenbergMacLane\nopen import groups.ToOmega\nopen import cohomology.Theory\nopen import cohomology.SpectrumModel\n\nmodule cohomology.EMModel where\n\nmodule _ {i} (G : AbGroup i) where\n\n open EMExplicit G using (⊙EM; EM-level; EM-conn; spectrum)\n\n private\n E : (n : ℤ) → Ptd i\n E (pos m) = ⊙EM m\n E (negsucc m) = ⊙Lift ⊙Unit\n\n E-spectrum : (n : ℤ) → ⊙Ω (E (succ n)) ⊙≃ E n\n E-spectrum (pos n) = spectrum n\n E-spectrum (negsucc O) = ≃-to-⊙≃ {X = ⊙Ω (E 0)}\n (equiv (λ _ → _) (λ _ → idp)\n (λ _ → idp) (prop-has-all-paths _))\n idp\n E-spectrum (negsucc (S n)) = ≃-to-⊙≃ {X = ⊙Ω (E (negsucc n))}\n (equiv (λ _ → _) (λ _ → idp)\n (λ _ → idp) (prop-has-all-paths {{=-preserves-level ⟨⟩}} _))\n idp\n\n EM-Cohomology : CohomologyTheory i\n EM-Cohomology = spectrum-cohomology E E-spectrum\n\n open CohomologyTheory EM-Cohomology\n\n EM-dimension : {n : ℤ} → n ≠ 0 → is-trivialᴳ (C n (⊙Lift ⊙S⁰))\n EM-dimension {pos O} neq = ⊥-rec (neq idp)\n EM-dimension {pos (S n)} _ =\n contr-is-trivialᴳ (C (pos (S n)) (⊙Lift ⊙S⁰))\n {{connected-at-level-is-contr\n {{⟨⟩}}\n {{Trunc-preserves-conn $\n equiv-preserves-conn\n (pre⊙∘-equiv ⊙lower-equiv ∘e ⊙Bool→-equiv-idf _ ⁻¹)\n {{path-conn (connected-≤T (⟨⟩-monotone-≤ (≤-ap-S (O≤ n)))\n )}}}}}}\n EM-dimension {negsucc O} _ =\n contr-is-trivialᴳ (C (negsucc O) (⊙Lift ⊙S⁰))\n {{Trunc-preserves-level 0 (Σ-level (Π-level λ _ →\n inhab-prop-is-contr idp) ⟨⟩)}}\n\n EM-dimension {negsucc (S n)} _ =\n contr-is-trivialᴳ (C (negsucc (S n)) (⊙Lift ⊙S⁰))\n {{Trunc-preserves-level 0 (Σ-level (Π-level λ _ →\n =-preserves-level ⟨⟩) λ _ → =-preserves-level (=-preserves-level ⟨⟩))}}\n\n EM-Ordinary : OrdinaryTheory i\n EM-Ordinary = ordinary-theory EM-Cohomology EM-dimension\n", "meta": {"hexsha": "c6fa0c596cd2e0c6287d1312e895478dbaacab32", "size": 1938, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/EMModel.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/cohomology/EMModel.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/cohomology/EMModel.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": 32.8474576271, "max_line_length": 79, "alphanum_fraction": 0.5691434469, "num_tokens": 753, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.893309411735131, "lm_q2_score": 0.6584175139669998, "lm_q1q2_score": 0.5881705620779679}} {"text": "-- Martin-Löf identity type without the K axiom\n-- (we do not assume uniqueness of identity proofs).\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Tools.PropositionalEquality where\n\n-- We reexport Agda's builtin equality type.\n\nopen import Tools.Empty public\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; _≢_; refl; sym; trans; cong; cong₂; subst; subst₂) public\nopen Eq.≡-Reasoning public\n\n-- Non-dependent congruence rules.\n\ncong₃ : ∀ {A B C D : Set} {a a′ b b′ c c′}\n (f : A → B → C → D) → a ≡ a′ → b ≡ b′ → c ≡ c′\n → f a b c ≡ f a′ b′ c′\ncong₃ f refl refl refl = refl\n\ncong₄ : ∀ {A B C D E : Set} {a a′ b b′ c c′ d d′}\n (f : A → B → C → D → E) → a ≡ a′ → b ≡ b′ → c ≡ c′ → d ≡ d′\n → f a b c d ≡ f a′ b′ c′ d′\ncong₄ f refl refl refl refl = refl\n\n-- Substitution (type-cast).\n\n-- Three substitutions simultaneously.\n\nsubst₃ : ∀ {A B C : Set} {a a′ b b′ c c′} (F : A → B → C → Set)\n → a ≡ a′ → b ≡ b′ → c ≡ c′ → F a b c → F a′ b′ c′\nsubst₃ F refl refl refl f = f\n", "meta": {"hexsha": "70116308745733630fd83a93c05124e6e595304a", "size": 1017, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tools/PropositionalEquality.agda", "max_stars_repo_name": "fhlkfy/logrel-mltt", "max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 30, "max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z", "max_issues_repo_path": "Tools/PropositionalEquality.agda", "max_issues_repo_name": "fhlkfy/logrel-mltt", "max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z", "max_forks_repo_path": "Tools/PropositionalEquality.agda", "max_forks_repo_name": "fhlkfy/logrel-mltt", "max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z", "avg_line_length": 29.9117647059, "max_line_length": 77, "alphanum_fraction": 0.5703048181, "num_tokens": 386, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333245787544824, "lm_q2_score": 0.7057850278370111, "lm_q1q2_score": 0.5881480110134979}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Data.Probability where\n\nopen import Prelude\nimport Data.Nat as ℕ\nimport Data.Nat.Properties as ℕ\nopen import Data.Bits renaming (Bits to ℚ⁺; [] to 1ℚ; 0∷_ to lℚ; 1∷_ to rℚ)\nopen import Data.Bits.Equatable\n\nopen import Data.Bits.Fold\n\neuclidian : ℕ → ℕ → ℕ → ℚ⁺\neuclidian n m zero = 1ℚ\neuclidian n m (suc s) =\n if n ℕ.≡ᴮ m\n then 1ℚ\n else if n ℕ.<ᴮ m\n then lℚ (euclidian n (m ℕ.∸ (1 ℕ.+ n)) s)\n else rℚ (euclidian (n ℕ.∸ (1 ℕ.+ m)) m s)\n\nnormalise-suc : ℕ → ℕ → ℚ⁺\nnormalise-suc n m = euclidian n m (n ℕ.+ m)\n\ndata ℙ : Type where\n ℙ⁰ : ℙ\n ℙ¹ : ℙ\n ℙ∙ : ℚ⁺ → ℙ\n\nunEu : ℚ⁺ → ℙ\nunEu 1ℚ = ℙ¹\nunEu (lℚ x) = ℙ∙ x\nunEu (rℚ x) = ℙ¹ -- won't happen\n\n_/suc_ : ℕ → ℕ → ℙ\nzero /suc d = ℙ⁰\nsuc n /suc d = unEu (normalise-suc n d)\n\n_/_ : ℕ → ℕ → ℙ\nn / zero = ℙ⁰\nn / suc d = n /suc d\n\n\nzer : (ℕ × ℕ) → (ℕ × ℕ)\nzer (p , q) = p , suc p ℕ.+ q\n\none : (ℕ × ℕ) → (ℕ × ℕ)\none (p , q) = suc p ℕ.+ q , q\n\nnorm : (ℕ × ℕ) → ℕ × ℕ\nnorm (x , y) = suc x , suc y\n\nprob : ℙ → (ℕ × ℕ)\nprob ℙ⁰ = 0 , 1\nprob ℙ¹ = 1 , 1\nprob (ℙ∙ x) = norm (zer (foldr-bits zer one (0 , 0) x))\n\nmul″ : ℙ → ℙ → ℙ\nmul″ x y =\n let xn , xd = prob x\n yn , yd = prob y\n in (xn ℕ.* yn) / (xd ℕ.* yd)\n\n-- e = prob (5 /suc 22)\n\nnextFrac : ℚ⁺ → ℚ⁺\nnextFrac 1ℚ = lℚ 1ℚ\nnextFrac (lℚ x) = rℚ x\nnextFrac (rℚ x) = lℚ (nextFrac x)\n\nopen import Data.List\n\nfracs : ℕ → List ℙ\nfracs n = ℙ⁰ ∷ ℙ¹ ∷ go n 1ℚ\n where\n go : ℕ → ℚ⁺ → List ℙ\n go zero x = []\n go (suc n) x = ℙ∙ x ∷ go n (nextFrac x)\n\nopen import Data.List.Sugar using (liftA2)\n\n-- mul′ : ℚ⁺ → ℚ⁺ → ℚ⁺\n-- mul′ 1ℚ 1ℚ = lℚ (lℚ 1ℚ)\n-- mul′ 1ℚ (lℚ ys) = {!!}\n-- mul′ 1ℚ (rℚ ys) = {!!}\n-- mul′ (lℚ xs) 1ℚ = {!!}\n-- mul′ (lℚ xs) (lℚ ys) = {!!}\n-- mul′ (lℚ xs) (rℚ ys) = {!!}\n-- mul′ (rℚ xs) 1ℚ = {!!}\n-- mul′ (rℚ xs) (lℚ ys) = {!!}\n-- mul′ (rℚ xs) (rℚ ys) = {!!}\n\n-- mul : ℙ → ℙ → ℙ\n-- mul ℙ⁰ ys = ℙ⁰\n-- mul ℙ¹ ys = ys\n-- mul (ℙ∙ x) ℙ⁰ = ℙ⁰\n-- mul xs ℙ¹ = xs\n-- mul (ℙ∙ x) (ℙ∙ y) = ℙ∙ (mul′ x y)\n\n\n-- testMul : ℕ → Type\n-- testMul n = liftA2 mul xs xs ≡ liftA2 mul″ xs xs\n-- where\n-- xs : List ℙ\n-- xs = fracs n\n\n-- _ : testMul 5\n-- _ = refl\n", "meta": {"hexsha": "6c3e6db6f68de1f857ae05b1f405ad343fe415b7", "size": 2095, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Probability.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/Probability.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/Probability.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.2201834862, "max_line_length": 75, "alphanum_fraction": 0.5102625298, "num_tokens": 1106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.879146780175245, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.5880439156221552}} {"text": "{- This file describes properties of computable relations. -}\n\nopen import bool\nopen import level\nopen import eq\nopen import product\nopen import product-thms\n\nmodule relations {ℓ ℓ' : level}{A : Set ℓ} (_≥A_ : A → A → Set ℓ') where\n\nreflexive : Set (ℓ ⊔ ℓ')\nreflexive = ∀ {a : A} → a ≥A a \n\ntransitive : Set (ℓ ⊔ ℓ')\ntransitive = ∀ {a b c : A} → a ≥A b → b ≥A c → a ≥A c\n\npreorder : Set (ℓ ⊔ ℓ')\npreorder = reflexive ∧ transitive\n\n_iso_ : A → A → Set ℓ'\nd iso d' = d ≥A d' ∧ d' ≥A d\n\niso-intro : ∀{x y : A} → x ≥A y → y ≥A x → x iso y \niso-intro p1 p2 = p1 , p2\n\n", "meta": {"hexsha": "965b1a952dedf5b9014d436411dc31f59c146f58", "size": 563, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "relations.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": "relations.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": "relations.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": 21.6538461538, "max_line_length": 72, "alphanum_fraction": 0.593250444, "num_tokens": 224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467580102418, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5880439124022185}} {"text": "module prime 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\n\nopen import gcd\nopen import nat\n\nrecord Prime (i : ℕ ) : Set where\n field\n p>1 : i > 1\n isPrime : ( j : ℕ ) → j < i → 0 < j → gcd i j ≡ 1\n\n\nrecord NonPrime ( n : ℕ ) : Set where\n field\n factor : ℕ\n prime : Prime factor\n dividable : Dividable factor n\n\nPrimeP : ( n : ℕ ) → Dec ( Prime n )\nPrimeP 0 = no (λ p → ⊥-elim ( nat-<> (Prime.p>1 p) (s≤s z≤n))) \nPrimeP 1 = no (λ p → ⊥-elim ( nat-≤> (Prime.p>1 p) (s≤s (≤-refl))))\nPrimeP (suc (suc n)) = isPrime1 (suc (suc n)) (suc n) (s≤s (s≤s z≤n)) a n ¬a ¬b c = ⊥-elim ( nat-≤> c i 1 → m < n → ( (i : ℕ) → m < i → i < n → gcd n i ≡ 1 ) → Dec ( Prime n )\n isPrime1 n zero n>1 m1 = n>1 } \n isPrime1 n (suc m) n>1 m ( gcd>0 n (suc m) (<-trans (s≤s z≤n) n>1) (s≤s z≤n)) a )\n ... | tri≈ ¬a b ¬c = isPrime1 n m n>1 (<-trans a ¬a ¬b c = ⊥-elim ( nat-≤> m ¬a ¬b c = no ( λ p → nat-≡< (sym (Prime.isPrime p (suc m) m n≤j j ¬a ¬b c = ⊥-elim ( nat-≤> m1 = 1 ( gcd>0 n m (<-trans (s≤s z≤n) 1 a (subst (λ k → 1 < k) (sym (gcd20 n)) 1 ¬a ¬b c with PrimeP ( gcd n m )\n ... | yes y = record { factor = gcd n m ; prime = y ; dividable = proj1 (gcd-dividable n m ) }\n ... | no ngcd = np2 where\n skip-case : NonPrime (gcd n m) → NonPrime n\n skip-case cc = record { factor = NonPrime.factor cc ; prime = NonPrime.prime cc ; dividable =\n record { factor = (Dividable.factor (proj1 (gcd-dividable n m))) * (Dividable.factor (NonPrime.dividable cc))\n ; is-factor = begin\n Dividable.factor (proj1 (gcd-dividable n m)) * Dividable.factor (NonPrime.dividable cc) * NonPrime.factor cc + 0 ≡⟨ refl ⟩\n g * d * p + 0 ≡⟨ +-comm _ 0 ⟩\n g * d * p ≡⟨ *-assoc g d p ⟩\n g * (d * p) ≡⟨ cong (λ k → g * k ) (+-comm 0 _) ⟩\n g * (d * p + 0) ≡⟨ cong (λ k → g * k ) (Dividable.is-factor (NonPrime.dividable cc) ) ⟩\n g * gcd n m ≡⟨ +-comm 0 _ ⟩\n g * gcd n m + 0 ≡⟨ Dividable.is-factor (proj1 (gcd-dividable n m)) ⟩\n n ∎ }} where\n open ≡-Reasoning\n g = Dividable.factor (proj1 (gcd-dividable n m))\n d = Dividable.factor (NonPrime.dividable cc)\n p = NonPrime.factor cc\n np2 : NonPrime n\n np2 with <-cmp (gcd n m) m\n ... | tri< a ¬b ¬c = skip-case (np1 (gcd n m) m ngcd c (skipFactor (gcd n m) a ))\n ... | tri≈ ¬a b ¬c = skip-case (np1 (gcd n m) m ngcd c\n (subst (λ k → Factoring m k) (sym b) (findFactor m ≤-refl (λ j n≤j j n≤j j ¬a ¬b' c with <-cmp 0 m\n ... | tri< a ¬b ¬c = ⊥-elim ( nat-≤> (subst (λ k → k ≤ m) (gcdsym {m} {n}) (gcd-≤ a (<-trans a m≤n))) c ) \n ... | tri≈ ¬a' b' ¬c = ⊥-elim ( np record { isPrime = λ j lt 01 = 1 a n ¬a ¬b c = np1 n m np 1 n≤j j ¬a ¬b c = ⊥-elim ( nat-≤> c nm : {m : ℕ} → suc m < suc (factorial (suc m))\nf>m {m} = begin\n suc (suc m) ≡⟨ cong (λ k → 1 + suc k ) (+-comm _ m) ⟩\n suc (1 + 1 * m) ≡⟨ cong (λ k → suc (1 + k )) (*-comm 1 m) ⟩\n suc (1 + m * 1) ≤⟨ s≤s (s≤s (*-monoʳ-≤ m (factorial≥1 {m}) )) ⟩\n suc (1 + m * factorial m) ≤⟨ s≤s (+-monoˡ-≤ _ (factorial≥1 {m})) ⟩\n suc (factorial m + m * factorial m) ≡⟨ refl ⟩\n suc (factorial (suc m)) ∎ where open ≤-Reasoning\n\nprime-is-infinite : (max-prime : ℕ ) → ¬ ( (j : ℕ) → max-prime < j → ¬ Prime j ) \nprime-is-infinite zero pmax = pmax 3 (s≤s z≤n) record { isPrime = λ n lt 01 = s≤s (s≤s z≤n) } where\n pif3 : (n : ℕ) → n < 3 → 0 < n → gcd 3 n ≡ 1\n pif3 .1 (s≤s (s≤s z≤n)) _ = refl\n pif3 .2 (s≤s (s≤s (s≤s z≤n))) _ = refl\nprime-is-infinite (suc m) pmax = newPrime where \n prime ¬a ¬b c = ⊥-elim ( pmax n c p ) \n fact : (n : ℕ) → Prime n → Dividable n ( factorial (suc m) )\n fact n p = fact< m n (<-trans (s≤s z≤n) (Prime.p>1 p)) ( prime 1 → Dividable k i → ¬ Dividable k (suc i)\n newPrime : ⊥\n newPrime with PrimeP ( suc (factorial (suc m)) )\n ... | yes p = pmax _ f>m p -- yes, we found a prime not in list\n ... | no np = div+1 (Prime.p>1 (NonPrime.prime p1)) (fact (NonPrime.factor p1) (NonPrime.prime p1) ) (NonPrime.dividable p1) where\n -- n!+1 cannot be dividable, because n! is dividable\n -- the factor need not be a prime, but anyway we prove that there is a prime factor in NonPrime\n p1 : NonPrime ( suc (factorial (suc m)) )\n p1 = nonPrime (begin\n 2 ≤⟨ s≤s ( s≤s z≤n) ⟩\n suc (suc m) ≤⟨ s≤s (m Val -> Val -> Set\n\nRel = Val -> Val -> Set\n\nTransitive : Rel → Set\nTransitive R = ∀ {t1 t2 t3} → R t1 t2 → R t2 t3 → R t1 t3\n\npostulate\n LeftReflexive : Rel → Set\n RightReflexive : Rel → Set\n\nrecord PP (R : Rel) : Set where\n constructor pp\n field\n .leftRefl : LeftReflexive R\n .rightRefl : RightReflexive R\n .trans : Transitive R\nopen PP public\n\nrecord Those (P : Val → Set)(R : Rel)(P' : Val → Set) : Set where\n constructor those\n field\n B : Val\n B' : Val\n PB : P B\n PB' : P' B'\n RBB' : R B B'\n\nFam : Rel → Set1\nFam AA = ∀ {a a'} → .(AA a a') → Rel\n\nFamTrans : {AA : Rel}.(TA : Transitive AA)(FF : Fam AA) → Set\nFamTrans {AA = AA} TA FF = ∀ {a1 a2 a3}(a12 : AA a1 a2)(a23 : AA a2 a3) →\n ∀ {b1 b2 b3}(b12 : FF a12 b1 b2)(b23 : FF a23 b2 b3) →\n FF (TA a12 a23) b1 b3\n\nΠ : (AA : Rel) → Fam AA → Rel\nΠ AA FF g g' = ∀ {a a'} → .(a≼a' : AA a a') →\n Those (App g a) (FF a≼a') (App g' a')\n\nΠTrans : {AA : Rel}(PA : PP AA){FF : Fam AA}(TF : FamTrans {AA = AA} (trans PA) FF) →\n Transitive (Π AA FF)\nΠTrans (pp leftRefl rightRefl trans) TF f12 f23 a≼a' with (leftRefl a≼a')\n... | a≼a with f12 a≼a | f23 a≼a'\nΠTrans (pp leftRefl rightRefl trans) TF f12 f23 a≼a' | a≼a | those b1 b2 app1 app2 b1≼b2 | those b2' b3 app2' app3 b2'≼b3 = those b1 b3 app1 app3 ?\n\n-- This should not give the internal error:\n--\n-- An internal error has occurred. Please report this as a bug.\n-- Location of the error: src/full/Agda/TypeChecking/Substitute.hs:50\n--\n-- Instead it should complain that\n--\n-- Variable leftRefl is declared irrelevant, so it cannot be used here\n-- when checking that the expression leftRefl a≼a' has type\n-- _141 leftRefl rightRefl trans TF f12 f23 a≼a'\n", "meta": {"hexsha": "4710d17e2df971a0734d86f3fc1e6698bd82e234", "size": 1850, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/NotApplyingInDontCareTriggersInternalError.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/Fail/NotApplyingInDontCareTriggersInternalError.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/Fail/NotApplyingInDontCareTriggersInternalError.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": 29.3650793651, "max_line_length": 147, "alphanum_fraction": 0.6205405405, "num_tokens": 731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467643431002, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.5880439050323463}} {"text": "\nmodule _ where\n\nopen import Prelude\nopen import Numeric.Nat.Prime\n\n2^44+7 2^46+15 2^48+21 : Nat\n2^44+7 = 17592186044423\n2^46+15 = 70368744177679\n2^48+21 = 281474976710677\n\nmain : IO ⊤\nmain = print $ isPrime! 2^48+21\n", "meta": {"hexsha": "f4bb1dab67679f8d041955340081ef027db26612", "size": 220, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/PrimeTest.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": "test/PrimeTest.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": "test/PrimeTest.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": 15.7142857143, "max_line_length": 31, "alphanum_fraction": 0.7045454545, "num_tokens": 99, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9124361628580401, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.5878142966443287}} {"text": "------------------------------------------------------------------------\n-- This module proves that the recognisers correspond exactly to\n-- decidable predicates of type List Bool → Bool (when the alphabet is\n-- Bool)\n------------------------------------------------------------------------\n\n-- This result could be generalised to other finite alphabets.\n\nmodule TotalRecognisers.Simple.ExpressiveStrength where\n\nopen import Codata.Musical.Notation\nopen import Data.Bool\nopen import Data.Bool.Properties\nopen import Function.Base\nopen import Function.Equality using (_⟨$⟩_)\nopen import Function.Equivalence\n using (_⇔_; equivalence; module Equivalence)\nopen import Data.List\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary.Decidable\n\nimport TotalRecognisers.Simple\nopen TotalRecognisers.Simple Bool _≟_\n\n-- One direction of the correspondence has already been established:\n-- For every grammar there is an equivalent decidable predicate.\n\ngrammar⇒pred : ∀ {n} (p : P n) →\n ∃ λ (f : List Bool → Bool) → ∀ s → s ∈ p ⇔ T (f s)\ngrammar⇒pred p =\n ((λ s → ⌊ s ∈? p ⌋) , λ _ → equivalence fromWitness toWitness)\n\n-- For every decidable predicate there is a corresponding grammar.\n-- Note that these grammars are all \"infinite LL(1)\".\n\npred⇒grammar : (f : List Bool → Bool) →\n ∃ λ (p : P (f [])) → ∀ s → s ∈ p ⇔ T (f s)\npred⇒grammar f =\n (grammar f , λ s → equivalence (sound f) (complete f s))\n where\n accept-if-true : ∀ b → P b\n accept-if-true true = empty\n accept-if-true false = fail\n\n grammar : (f : List Bool → Bool) → P (f [])\n grammar f = tok true · ♯ grammar (f ∘ _∷_ true )\n ∣ tok false · ♯ grammar (f ∘ _∷_ false)\n ∣ accept-if-true (f [])\n\n accept-if-true-sound :\n ∀ b {s} → s ∈ accept-if-true b → s ≡ [] × T b\n accept-if-true-sound true empty = (refl , _)\n accept-if-true-sound false ()\n\n accept-if-true-complete : ∀ {b} → T b → [] ∈ accept-if-true b\n accept-if-true-complete ok with Equivalence.to T-≡ ⟨$⟩ ok\n ... | refl = empty\n\n sound : ∀ f {s} → s ∈ grammar f → T (f s)\n sound f (∣-right s∈) with accept-if-true-sound (f []) s∈\n ... | (refl , ok) = ok\n sound f (∣-left (∣-left (tok · s∈))) = sound (f ∘ _∷_ true ) s∈\n sound f (∣-left (∣-right (tok · s∈))) = sound (f ∘ _∷_ false) s∈\n\n complete : ∀ f s → T (f s) → s ∈ grammar f\n complete f [] ok =\n ∣-right {n₁ = false} $ accept-if-true-complete ok\n complete f (true ∷ bs) ok =\n ∣-left {n₁ = false} $ ∣-left {n₁ = false} $\n tok · complete (f ∘ _∷_ true ) bs ok\n complete f (false ∷ bs) ok =\n ∣-left {n₁ = false} $ ∣-right {n₁ = false} $\n tok · complete (f ∘ _∷_ false) bs ok\n", "meta": {"hexsha": "a229a4807c81f5e08b24ec0dae54398803a86d4b", "size": 2689, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TotalRecognisers/Simple/ExpressiveStrength.agda", "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_issues_repo_path": "TotalRecognisers/Simple/ExpressiveStrength.agda", "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TotalRecognisers/Simple/ExpressiveStrength.agda", "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": ["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.8533333333, "max_line_length": 72, "alphanum_fraction": 0.593529193, "num_tokens": 832, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.800691997339971, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.5878036395953241}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.Adjunction.CompositionLaws where\n\nopen import Level\n\nopen import Relation.Binary using (Rel; IsEquivalence)\nopen import Data.Sum\nopen import Data.Product\nopen import Function using (flip)\n\nopen import Categories.Category\nopen import Categories.Functor hiding (equiv; assoc; identityˡ; identityʳ; ∘-resp-≡) renaming (id to idF; _≡_ to _≡F_; _∘_ to _∘F_)\nopen import Categories.NaturalTransformation hiding (equiv; setoid) renaming (id to idT; _≡_ to _≡T_)\nopen import Categories.Monad\nopen import Categories.Support.Equivalence\n\nopen import Categories.Adjunction\nopen import Categories.Adjunction.Composition\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 {F′ : Functor C₁ C₀} {G′ : Functor C₂ C₁} {H′ : Functor C₃ C₂}\n {T : F ⊣ F′} {U : G ⊣ G′} {V : H ⊣ H′}\n → (V ∘ U) ∘ T ≡ V ∘ (U ∘ T)\nassoc {C₀ = C₀} {C₁} {C₂} {C₃} {F} {G} {H} {F′} {G′} {H′} {T} {U} {V} = (λ {x} → pf₀ {x}) , λ {x} → pf₁ {x}\n where\n module C₀ = Category C₀\n module C₁ = Category C₁\n module C₂ = Category C₂\n module C₃ = Category C₃\n module F = Functor F\n module G = Functor G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡)\n module H = Functor H renaming (F₀ to H₀; F₁ to H₁; F-resp-≡ to H-resp-≡)\n module F′ = Functor F′ renaming (F₀ to F′₀; F₁ to F′₁; F-resp-≡ to F′-resp-≡)\n module G′ = Functor G′ renaming (F₀ to G′₀; F₁ to G′₁; F-resp-≡ to G′-resp-≡)\n module H′ = Functor H′ renaming (F₀ to H′₀; F₁ to H′₁; F-resp-≡ to H′-resp-≡)\n module T = Adjunction T renaming (unit to Tη′; counit to Tε′)\n module U = Adjunction U renaming (unit to Uη′; counit to Uε′)\n module V = Adjunction V renaming (unit to Vη′; counit to Vε′)\n module Tη = NaturalTransformation (Adjunction.unit T)\n module Tε = NaturalTransformation (Adjunction.counit T)\n module Uη = NaturalTransformation (Adjunction.unit U)\n module Uε = NaturalTransformation (Adjunction.counit U)\n module Vη = NaturalTransformation (Adjunction.unit V)\n module Vε = NaturalTransformation (Adjunction.counit V)\n\n pf₀ : {x : C₀.Obj} → F′.F′₁ (G′.G′₁ (Vη.η (G.G₀ (F.F₀ x))) C₁.∘ Uη.η (F.F₀ x)) C₀.∘\n Tη.η x\n C₀.≡\n F′.F′₁ (G′.G′₁ (Vη.η (G.G₀ (F.F₀ x)))) C₀.∘\n F′.F′₁ (Uη.η (F.F₀ x)) C₀.∘ Tη.η x\n pf₀ {x} = begin\n F′.F′₁ (G′.G′₁ (Vη.η (G.G₀ (F.F₀ x))) C₁.∘ Uη.η (F.F₀ x)) C₀.∘\n Tη.η x\n ↓⟨ C₀.∘-resp-≡ˡ F′.homomorphism ⟩\n C₀ [ F′.F′₁ (G′.G′₁ (Vη.η (G.G₀ (F.F₀ x)))) ∘\n F′.F′₁ (Uη.η (F.F₀ x)) ]\n C₀.∘ Tη.η x\n ↓⟨ C₀.assoc ⟩\n F′.F′₁ (G′.G′₁ (Vη.η (G.G₀ (F.F₀ x)))) C₀.∘\n F′.F′₁ (Uη.η (F.F₀ x)) C₀.∘ Tη.η x\n ∎\n where open C₀.HomReasoning\n\n pf₁ : {x : C₃.Obj} → (Vε.η x C₃.∘ H.H₁ (Uε.η (H′.H′₀ x))) C₃.∘\n H.H₁ (G.G₁ (Tε.η (G′.G′₀ (H′.H′₀ x))))\n C₃.≡\n Vε.η x C₃.∘\n H.H₁ (Uε.η (H′.H′₀ x) C₂.∘ G.G₁ (Tε.η (G′.G′₀ (H′.H′₀ x))))\n pf₁ {x} = begin\n (Vε.η x C₃.∘ H.H₁ (Uε.η (H′.H′₀ x))) C₃.∘\n H.H₁ (G.G₁ (Tε.η (G′.G′₀ (H′.H′₀ x))))\n ↓⟨ C₃.assoc ⟩\n Vε.η x C₃.∘\n H.H₁ (Uε.η (H′.H′₀ x)) C₃.∘ H.H₁ (G.G₁ (Tε.η (G′.G′₀ (H′.H′₀ x))))\n ↑⟨ C₃.∘-resp-≡ʳ H.homomorphism ⟩\n Vε.η x C₃.∘\n H.H₁ (C₂ [ Uε.η (H′.H′₀ x) ∘ G.G₁ (Tε.η (G′.G′₀ (H′.H′₀ x))) ])\n ∎\n where open C₃.HomReasoning\n\n.identityˡ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F : Functor C D} {G : Functor D C} {T : F ⊣ G}\n → id ∘ T ≡ T\nidentityˡ {C = C} {D} {F} {G} {T} = ( (λ {x} → pf₀ {x}) , D.identityˡ )\n where\n module C = Category C\n module D = Category D\n module F = Functor F\n module G = Functor G\n module T = Adjunction T renaming (unit to Tη′; counit to Tε′)\n module Tη = NaturalTransformation T.Tη′\n module Tε = NaturalTransformation T.Tε′\n\n pf₀ : {x : C.Obj} → G.F₁ D.id C.∘ NaturalTransformation.η Tη.op x C.≡\n NaturalTransformation.η Tη.op x\n pf₀ {x} = begin\n G.F₁ D.id C.∘ NaturalTransformation.η Tη.op x\n ↓⟨ C.∘-resp-≡ˡ G.identity ⟩\n C.id C.∘ NaturalTransformation.η Tη.op x\n ↓⟨ C.identityˡ ⟩\n NaturalTransformation.η Tη.op x\n ∎\n where open C.HomReasoning\n\n.identityʳ : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F : Functor C D} {G : Functor D C} {T : F ⊣ G}\n → T ∘ id ≡ T\nidentityʳ {C = C} {D} {F} {G} {T} = (λ {x} → C.identityʳ) , (λ {x} → pf₀ {x})\n where\n module C = Category C\n module D = Category D\n module F = Functor F\n module G = Functor G\n module T = Adjunction T renaming (unit to Tη′; counit to Tε′)\n module Tη = NaturalTransformation T.Tη′\n module Tε = NaturalTransformation T.Tε′\n\n pf₀ : {x : D.Obj} → NaturalTransformation.η Tε.op x D.∘ F.F₁ C.id D.≡\n NaturalTransformation.η Tε.op x\n pf₀ {x} = begin\n NaturalTransformation.η Tε.op x D.∘ F.F₁ C.id\n ↓⟨ D.∘-resp-≡ʳ F.identity ⟩\n NaturalTransformation.η Tε.op x D.∘ D.id\n ↓⟨ D.identityʳ ⟩\n NaturalTransformation.η Tε.op x\n ∎\n where open D.HomReasoning\n\n.∘-resp-≡ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂}\n {A : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} {C : Category o₂ ℓ₂ e₂}\n {F : Functor B C} {G : Functor A B} {F′ : Functor C B} {G′ : Functor B A}\n {T T′ : G ⊣ G′} {U U′ : F ⊣ F′}\n → T ≡ T′ → U ≡ U′ → U ∘ T ≡ U′ ∘ T′\n∘-resp-≡ {A = A} {B} {C} {F} {G} {F′} {G′} {T} {T′} {U} {U′} (Tη≡T′η , Tε≡T′ε) (Uη≡U′η , Uε≡U′ε) =\n (λ {x} → A.∘-resp-≡ (G′.F-resp-≡ Uη≡U′η) Tη≡T′η)\n ,\n (λ {x} → C.∘-resp-≡ Uε≡U′ε (F.F-resp-≡ Tε≡T′ε))\n where\n module A = Category A\n module B = Category B\n module C = Category C\n module F = Functor F\n module G = Functor G\n module F′ = Functor F′\n module G′ = Functor G′\n module T = Adjunction T renaming (unit to Tη′; counit to Tε′)\n module U = Adjunction U renaming (unit to Uη′; counit to Uε′)\n module T′ = Adjunction T′ renaming (unit to T′η′; counit to T′ε′)\n module U′ = Adjunction U′ renaming (unit to U′η′; counit to U′ε′)\n module Tη = NaturalTransformation (Adjunction.unit T)\n module Tε = NaturalTransformation (Adjunction.counit T)\n module Uη = NaturalTransformation (Adjunction.unit U)\n module Uε = NaturalTransformation (Adjunction.counit U)\n module T′η = NaturalTransformation (Adjunction.unit T′)\n module T′ε = NaturalTransformation (Adjunction.counit T′)\n module U′η = NaturalTransformation (Adjunction.unit U′)\n module U′ε = NaturalTransformation (Adjunction.counit U′)\n", "meta": {"hexsha": "7562f82d5a2414e9703f1cff1f15ecfc61447bd0", "size": 7143, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Adjunction/CompositionLaws.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/Adjunction/CompositionLaws.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/Adjunction/CompositionLaws.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": 45.2088607595, "max_line_length": 131, "alphanum_fraction": 0.5284894302, "num_tokens": 2867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006919973399709, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.5878036395953241}} {"text": "module STLC.Semantics where\n\n-- This file contains the definitional interpreter for STLC described\n-- in Section 2 of the paper.\n\nopen import Data.Nat\nopen import Data.Integer\nopen import Data.List\nopen import Data.List.Membership.Propositional\nopen import Data.List.Relation.Unary.All as All\nopen import Data.Maybe.Base hiding (_>>=_)\n\n\n------------\n-- SYNTAX --\n------------\n\n-- These definitions correspond to Section 2.1, except we have\n-- included numbers (integers) and integer operations in the language.\n\ndata Ty : Set where\n unit : Ty\n _⇒_ : (a b : Ty) → Ty\n int : Ty\n\nCtx = List Ty\n\n-- Below, `Expr` uses `_∈_` from `Relation.Binary` in the Agda\n-- Standard Library to represent typed de Bruijn indices which witness\n-- the existence of an entry in the type context.\n\ndata Expr (Γ : Ctx) : Ty → Set where\n unit : Expr Γ unit\n var : ∀ {t} → t ∈ Γ → Expr Γ t\n ƛ : ∀ {a b} → Expr (a ∷ Γ) b → Expr Γ (a ⇒ b)\n _·_ : ∀ {a b} → Expr Γ (a ⇒ b) → Expr Γ a → Expr Γ b\n num : ℤ → Expr Γ int\n iop : (ℤ → ℤ → ℤ) → (l r : Expr Γ int) → Expr Γ int\n\n\n-----------------------------\n-- VALUES AND ENVIRONMENTS --\n-----------------------------\n\n-- These definitions correspond to Section 2.2.\n--\n-- Note that the `All` type described in Section 2.2 of the paper (for\n-- simplicity) does not mention universe levels, whereas the `All`\n-- definition below refers to `Data.List.All` in the Agda Standard\n-- Library which is defined in a universe polymorphic manner.\n\nmutual\n data Val : Ty → Set where\n unit : Val unit\n ⟨_,_⟩ : ∀ {Γ a b} → Expr (a ∷ Γ) b → Env Γ → Val (a ⇒ b)\n num : ℤ → Val int\n\n Env : Ctx → Set\n Env Γ = All Val Γ\n\n-- The `lookup` function described in Section 2.2 of the paper is also\n-- defined in `Data.List.All` in the Agda Standard Library.\n\n\n-----------\n-- MONAD --\n-----------\n\n-- These definitions correspond to Section 2.3.\n\nM : Ctx → Set → Set\nM Γ a = Env Γ → Maybe a\n\n_>>=_ : ∀ {Γ a b} → M Γ a → (a → M Γ b) → M Γ b\n(f >>= c) E with (f E)\n... | just x = c x E\n... | nothing = nothing\n\nreturn : ∀ {Γ a} → a → M Γ a\nreturn x E = just x\n\ngetEnv : ∀ {Γ} → M Γ (Env Γ)\ngetEnv E = return E E\n\nusingEnv : ∀ {Γ Γ' a} → Env Γ → M Γ a → M Γ' a\nusingEnv E f _ = f E\n\ntimeout : ∀ {Γ a} → M Γ a\ntimeout = λ _ → nothing\n\n\n-----------------\n-- INTERPRETER --\n-----------------\n\n-- These definitions correspond to Section 2.4.\n\neval : ℕ → ∀ {Γ t} → Expr Γ t → M Γ (Val t)\neval zero _ =\n timeout\neval (suc k) unit =\n return unit\neval (suc k) (var x) =\n getEnv >>= λ E →\n return (All.lookup E x)\neval (suc k) (ƛ b) =\n getEnv >>= λ E →\n return ⟨ b , E ⟩\neval (suc k) (l · r) =\n eval k l >>= λ{ ⟨ e , E ⟩ →\n eval k r >>= λ v →\n usingEnv (v ∷ E) (eval k e) }\neval (suc k) (num x) =\n return (num x)\neval (suc k) (iop f l r) =\n eval k l >>= λ{ (num vₗ) →\n eval k r >>= λ{ (num vᵣ) →\n return (num (f vₗ vᵣ)) }}\n", "meta": {"hexsha": "d830d4e7eb181b4bb4952aaa3f0dc00f6652bae1", "size": 2911, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/STLC/Semantics.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/STLC/Semantics.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/STLC/Semantics.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": 24.4621848739, "max_line_length": 70, "alphanum_fraction": 0.5616626589, "num_tokens": 983, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.5878036360966916}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.Polynomials.UnivariateList.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.Polynomials.UnivariatePolyList\nopen import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly\n\nopen import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.Poly0-A\nopen import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.An[Am[X]]-Anm[X]\nopen import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.AB-An[X]Bn[X]\nopen import Cubical.Algebra.Polynomials.UnivariateList.Poly1-1Poly\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) (nUnivariatePolyList 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 _ _ 1 (Equiv-Polyn-nPoly A' n)\n ∘-ecr CRE-Poly1-Poly: (nUnivariatePolyList A' n))\n", "meta": {"hexsha": "0e23678764864a5dac08faa2981e0a8ea4ea13ff", "size": 1468, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Polynomials/UnivariateList/Polyn-nPoly.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/UnivariateList/Polyn-nPoly.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/UnivariateList/Polyn-nPoly.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": 40.7777777778, "max_line_length": 110, "alphanum_fraction": 0.7098092643, "num_tokens": 431, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9073122163480667, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.5877552368764573}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Sum where\n\nopen import Level\nopen import Data.Bool.Base using (Bool; true; false)\nopen import Function using (const)\n\ndata _⊎_ (A : Type a) (B : Type b) : Type (a ℓ⊔ b) where\n inl : A → A ⊎ B\n inr : B → A ⊎ B\n\neither : ∀ {ℓ} {C : A ⊎ B → Type ℓ} → ((a : A) → C (inl a)) → ((b : B) → C (inr b))\n → (x : A ⊎ B) → C x\neither f _ (inl x) = f x\neither _ g (inr y) = g y\n\n⟦l_,r_⟧ = either\n\neither′ : (A → C) → (B → C) → (A ⊎ B) → C\neither′ = either\n\n_▿_ : (A → C) → (B → C) → A ⊎ B → C\n_▿_ = either\n\nis-l : A ⊎ B → Bool\nis-l = either′ (const true) (const false)\n\nmap-⊎ : ∀ {a₁ a₂ b₁ b₂} {A₁ : Type a₁} {A₂ : Type a₂} {B₁ : Type b₁} {B₂ : Type b₂} →\n (A₁ → A₂) →\n (B₁ → B₂) →\n (A₁ ⊎ B₁) →\n (A₂ ⊎ B₂)\nmap-⊎ f g (inl x) = inl (f x)\nmap-⊎ f g (inr x) = inr (g x)\n\nmapˡ : (A → B) → A ⊎ C → B ⊎ C\nmapˡ f (inl x) = inl (f x)\nmapˡ f (inr x) = inr x\n\nmapʳ : (A → B) → C ⊎ A → C ⊎ B\nmapʳ f (inl x) = inl x\nmapʳ f (inr x) = inr (f x)\n", "meta": {"hexsha": "c70ad26fc5e4368cdcbfb336b06d92ecb6f3ce77", "size": 995, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Sum.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/Sum.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/Sum.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": 22.6136363636, "max_line_length": 85, "alphanum_fraction": 0.4763819095, "num_tokens": 497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388252252041, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.5877334980155455}} {"text": "------------------------------------------------------------------------------\n-- Natural numbers (PCF version)\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 where\n\nopen import LTC-PCF.Base\nopen import LTC-PCF.Data.Nat.Rec\nopen import LTC-PCF.Data.Nat.Type public\n\ninfixl 7 _*_\ninfixl 6 _+_ _∸_\n\n------------------------------------------------------------------------------\n-- Addition with recursion on the first argument.\n_+_ : D → D → D\nm + n = rec m n (lam (λ _ → lam succ₁))\n\n-- Subtraction with recursion on the second argument.\n_∸_ : D → D → D\nm ∸ n = rec n m (lam (λ _ → lam pred₁))\n\n-- Multiplication with recursion on the first argument.\n_*_ : D → D → D\nm * n = rec m zero (lam (λ _ → lam (λ x → n + x)))\n", "meta": {"hexsha": "12acfb527cbd86c9aa451e0dc5cc4f51aa52347e", "size": 947, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/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/LTC-PCF/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/LTC-PCF/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": 30.5483870968, "max_line_length": 78, "alphanum_fraction": 0.4551214361, "num_tokens": 221, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772450055545, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.5876698393485336}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommAlgebra.FGIdeal where\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Powerset\n\nopen import Cubical.Data.FinData\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Vec\n\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.CommRing.FGIdeal using ()\n renaming (generatedIdeal to generatedIdealCommRing;\n indInIdeal to ringIncInIdeal;\n 0FGIdeal to 0FGIdealCommRing)\nopen import Cubical.Algebra.CommAlgebra\nopen import Cubical.Algebra.CommAlgebra.Ideal\n\nprivate\n variable\n ℓ : Level\n R : CommRing ℓ\n\ngeneratedIdeal : {n : ℕ} (A : CommAlgebra R ℓ) → FinVec (fst A) n → IdealsIn A\ngeneratedIdeal A = generatedIdealCommRing (CommAlgebra→CommRing A)\n\nincInIdeal : {n : ℕ} (A : CommAlgebra R ℓ)\n (U : FinVec ⟨ A ⟩ n) (i : Fin n) → U i ∈ fst (generatedIdeal A U)\nincInIdeal A = ringIncInIdeal (CommAlgebra→CommRing A)\n\nsyntax generatedIdeal A V = ⟨ V ⟩[ A ]\n\nmodule _ {R : CommRing ℓ} (A : CommAlgebra R ℓ) where\n open CommAlgebraStr (snd A)\n\n 0FGIdeal : {n : ℕ} → ⟨ replicateFinVec n 0a ⟩[ A ] ≡ (0Ideal A)\n 0FGIdeal = 0FGIdealCommRing (CommAlgebra→CommRing A)\n", "meta": {"hexsha": "e06ed81b11f3a1179beb778046dc6a0c84665109", "size": 1261, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/FGIdeal.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/CommAlgebra/FGIdeal.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/FGIdeal.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.1842105263, "max_line_length": 79, "alphanum_fraction": 0.7081681205, "num_tokens": 385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240964782011, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.5876417707226971}} {"text": "module Data.Boolean where\n\nimport Lvl\nopen import Type\n\n-- Boolean type\ndata Bool : Type{Lvl.𝟎} where\n 𝑇 : Bool -- Represents truth\n 𝐹 : Bool -- Represents falsity\n\n{-# BUILTIN BOOL Bool #-}\n{-# BUILTIN TRUE 𝑇 #-}\n{-# BUILTIN FALSE 𝐹 #-}\n\nelim : ∀{ℓ}{T : Bool → Type{ℓ}} → T(𝑇) → T(𝐹) → ((b : Bool) → T(b))\nelim t _ 𝑇 = t\nelim _ f 𝐹 = f\n\nnot : Bool → Bool\nnot 𝑇 = 𝐹\nnot 𝐹 = 𝑇\n{-# COMPILE GHC not = not #-}\n\n-- Control-flow if-else expression\nif_then_else_ : ∀{ℓ}{T : Type{ℓ}} → Bool → T → T → T\nif b then t else f = elim t f b\n", "meta": {"hexsha": "5065f13c75df4ba68fcfb4f294e4bf9ab7d2a742", "size": 531, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Boolean.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.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.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.6666666667, "max_line_length": 67, "alphanum_fraction": 0.5875706215, "num_tokens": 212, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.5875044439560668}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule PiTracedLevel0 where\n\nopen import Data.Empty using (⊥; ⊥-elim)\nopen import Data.Unit using (⊤; tt)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_×_; _,_; proj₁; proj₂)\n\n------------------------------------------------------------------------------\n-- Level 0 of Pi (with trace)\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\ninfix 30 _⟷_\ninfixr 50 _◎_\n\n-- Combinators, permutations, or paths depending on the perspective\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 absorbr : {t : U} → TIMES ZERO t ⟷ ZERO\n absorbl : {t : U} → TIMES t ZERO ⟷ ZERO\n factorzr : {t : U} → ZERO ⟷ TIMES t ZERO\n factorzl : {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 trace : {t t₁ t₂ : U} → (PLUS t₁ t ⟷ PLUS t₂ t) → (t₁ ⟷ t₂)\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! absorbl = factorzr\n! absorbr = factorzl\n! factorzl = absorbr\n! factorzr = absorbl\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! (trace c) = trace (! c)\n\n------------------------------------------------------------------------------\n-- Cat\n\nopen import Level using () renaming (zero to lzero)\nopen import Data.Unit\nopen import Relation.Binary.Core using (IsEquivalence)\nopen import Data.Product using (_,_)\n\nopen import Categories.Category\nopen import Categories.Groupoid\nopen import Categories.Monoidal\nopen import Categories.Monoidal.Helpers\nopen import Categories.Bifunctor\nopen import Categories.NaturalIsomorphism\nopen import Categories.Monoidal.Braided\nopen import Categories.Monoidal.Symmetric\nopen import Categories.RigCategory\nopen import Categories.Monoidal.Traced\n\ntriv≡ : {t₁ t₂ : U} → (f g : t₁ ⟷ t₂) → Set\ntriv≡ _ _ = ⊤\n\ntriv≡Equiv : {t₁ t₂ : U} → IsEquivalence (triv≡ {t₁} {t₂})\ntriv≡Equiv = record \n { refl = tt\n ; sym = λ _ → tt\n ; trans = λ _ _ → tt\n }\n\nPiCat : Category lzero lzero lzero\nPiCat = record\n { Obj = U\n ; _⇒_ = _⟷_\n ; _≡_ = triv≡ \n ; id = id⟷\n ; _∘_ = λ y⟷z x⟷y → x⟷y ◎ y⟷z \n ; assoc = tt \n ; identityˡ = tt \n ; identityʳ = tt \n ; equiv = triv≡Equiv \n ; ∘-resp-≡ = λ _ _ → tt \n }\n\n-- and a groupoid\n\nPiGroupoid : Groupoid PiCat\nPiGroupoid = record \n { _⁻¹ = ! \n ; iso = record { isoˡ = tt ; isoʳ = tt } \n }\n\n-- additive bifunctor and monoidal structure\n⊕-bifunctor : Bifunctor PiCat PiCat PiCat\n⊕-bifunctor = record\n { F₀ = λ {(u , v) → PLUS u v}\n ; F₁ = λ {(x⟷y , z⟷w) → x⟷y ⊕ z⟷w }\n ; identity = tt\n ; homomorphism = tt\n ; F-resp-≡ = λ _ → tt\n }\n\nmodule ⊎h = MonoidalHelperFunctors PiCat ⊕-bifunctor ZERO\n\n0⊕x≡x : NaturalIsomorphism ⊎h.id⊗x ⊎h.x\n0⊕x≡x = record \n { F⇒G = record\n { η = λ X → unite₊\n ; commute = λ _ → tt } \n ; F⇐G = record\n { η = λ X → uniti₊\n ; commute = λ _ → tt } \n ; iso = λ X → record { isoˡ = tt; isoʳ = tt }\n }\n\nx⊕0≡x : NaturalIsomorphism ⊎h.x⊗id ⊎h.x\nx⊕0≡x = record\n { F⇒G = record\n { η = λ X → swap₊ ◎ unite₊ -- !!!\n ; commute = λ _ → tt\n }\n ; F⇐G = record\n { η = λ X → uniti₊ ◎ swap₊\n ; commute = λ _ → tt\n }\n ; iso = λ X → record \n { isoˡ = tt\n ; isoʳ = tt\n }\n }\n\n[x⊕y]⊕z≡x⊕[y⊕z] : NaturalIsomorphism ⊎h.[x⊗y]⊗z ⊎h.x⊗[y⊗z]\n[x⊕y]⊕z≡x⊕[y⊕z] = record\n { F⇒G = record\n { η = λ X → assocr₊\n ; commute = λ f → tt\n }\n ; F⇐G = record\n { η = λ X → assocl₊\n ; commute = λ _ → tt\n }\n ; iso = λ X → record\n { isoˡ = tt\n ; isoʳ = tt\n }\n }\n\nM⊕ : Monoidal PiCat\nM⊕ = record\n { ⊗ = ⊕-bifunctor\n ; id = ZERO\n ; identityˡ = 0⊕x≡x\n ; identityʳ = x⊕0≡x\n ; assoc = [x⊕y]⊕z≡x⊕[y⊕z]\n ; triangle = tt\n ; pentagon = tt\n }\n\n-- multiplicative bifunctor and monoidal structure\n⊗-bifunctor : Bifunctor PiCat PiCat PiCat\n⊗-bifunctor = record\n { F₀ = λ {(u , v) → TIMES u v}\n ; F₁ = λ {(x⟷y , z⟷w) → x⟷y ⊗ z⟷w }\n ; identity = tt\n ; homomorphism = tt\n ; F-resp-≡ = λ _ → tt\n }\n\nmodule ⊗h = MonoidalHelperFunctors PiCat ⊗-bifunctor ONE\n\n1⊗x≡x : NaturalIsomorphism ⊗h.id⊗x ⊗h.x\n1⊗x≡x = record \n { F⇒G = record\n { η = λ X → unite⋆\n ; commute = λ _ → tt } \n ; F⇐G = record\n { η = λ X → uniti⋆\n ; commute = λ _ → tt } \n ; iso = λ X → record { isoˡ = tt; isoʳ = tt }\n }\n\nx⊗1≡x : NaturalIsomorphism ⊗h.x⊗id ⊗h.x\nx⊗1≡x = record\n { F⇒G = record\n { η = λ X → swap⋆ ◎ unite⋆ -- !!!\n ; commute = λ _ → tt\n }\n ; F⇐G = record\n { η = λ X → uniti⋆ ◎ swap⋆\n ; commute = λ _ → tt\n }\n ; iso = λ X → record \n { isoˡ = tt\n ; isoʳ = tt\n }\n }\n\n[x⊗y]⊗z≡x⊗[y⊗z] : NaturalIsomorphism ⊗h.[x⊗y]⊗z ⊗h.x⊗[y⊗z]\n[x⊗y]⊗z≡x⊗[y⊗z] = record\n { F⇒G = record\n { η = λ X → assocr⋆\n ; commute = λ f → tt\n }\n ; F⇐G = record\n { η = λ X → assocl⋆\n ; commute = λ _ → tt\n }\n ; iso = λ X → record\n { isoˡ = tt\n ; isoʳ = tt\n }\n }\n\nM⊗ : Monoidal PiCat\nM⊗ = record\n { ⊗ = ⊗-bifunctor\n ; id = ONE\n ; identityˡ = 1⊗x≡x\n ; identityʳ = x⊗1≡x\n ; assoc = [x⊗y]⊗z≡x⊗[y⊗z]\n ; triangle = tt\n ; pentagon = tt\n }\n\nx⊕y≡y⊕x : NaturalIsomorphism ⊎h.x⊗y ⊎h.y⊗x\nx⊕y≡y⊕x = record \n { F⇒G = record { η = λ X → swap₊ ; commute = λ f → tt } \n ; F⇐G = record { η = λ X → swap₊ ; commute = λ f → tt } \n ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } }\n\nBM⊕ : Braided M⊕\nBM⊕ = record { braid = x⊕y≡y⊕x ; hexagon₁ = tt ; hexagon₂ = tt }\n\nx⊗y≡y⊗x : NaturalIsomorphism ⊗h.x⊗y ⊗h.y⊗x\nx⊗y≡y⊗x = record \n { F⇒G = record { η = λ X → swap⋆ ; commute = λ f → tt } \n ; F⇐G = record { η = λ X → swap⋆ ; commute = λ f → tt } \n ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } }\n\nBM⊗ : Braided M⊗\nBM⊗ = record { braid = x⊗y≡y⊗x ; hexagon₁ = tt ; hexagon₂ = tt }\n\nSBM⊕ : Symmetric BM⊕\nSBM⊕ = record { symmetry = tt }\n\n-- trace\n\nPi0Traced : Traced SBM⊕\nPi0Traced = record {\n trace = trace\n ; vanish_id = tt\n ; vanish_⊗ = tt\n ; superpose = tt\n ; yank = tt \n }\n\n--\n\nSBM⊗ : Symmetric BM⊗\nSBM⊗ = record { symmetry = tt }\n\nmodule r = BimonoidalHelperFunctors SBM⊕ BM⊗\n\nx⊗0≡0 : NaturalIsomorphism r.x⊗0 r.0↑\nx⊗0≡0 = record \n { F⇒G = record { η = λ X → absorbl ; commute = λ f → tt } \n ; F⇐G = record { η = λ X → factorzr ; commute = λ f → tt } \n ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } \n }\n\n0⊗x≡0 : NaturalIsomorphism r.0⊗x r.0↑\n0⊗x≡0 = record\n { F⇒G = record { η = λ X → absorbr ; commute = λ f → tt }\n ; F⇐G = record { η = λ X → factorzl ; commute = λ f → tt }\n ; iso = λ X → record { isoˡ = tt ; isoʳ = tt }\n }\n\nx⊗[y⊕z]≡[x⊗y]⊕[x⊗z] : NaturalIsomorphism r.x⊗[y⊕z] r.[x⊗y]⊕[x⊗z]\nx⊗[y⊕z]≡[x⊗y]⊕[x⊗z] = record -- this probably says we need distl/distr\n { F⇒G = record { η = λ X → swap⋆ ◎ dist ◎ (swap⋆ ⊕ swap⋆) ; commute = λ f → tt }\n ; F⇐G = record { η = λ X → (swap⋆ ⊕ swap⋆) ◎ factor ◎ swap⋆ ; commute = λ f → tt }\n ; iso = λ X → record { isoˡ = tt ; isoʳ = tt }\n }\n\n[x⊕y]⊗z≡[x⊗z]⊕[y⊗z] : NaturalIsomorphism r.[x⊕y]⊗z r.[x⊗z]⊕[y⊗z]\n[x⊕y]⊗z≡[x⊗z]⊕[y⊗z] = record\n { F⇒G = record { η = λ X → dist ; commute = λ f → tt }\n ; F⇐G = record { η = λ X → factor ; commute = λ f → tt }\n ; iso = λ X → record { isoˡ = tt ; isoʳ = tt }\n }\n\nPi0Rig : RigCategory SBM⊕ BM⊗\nPi0Rig = record \n { distribₗ = x⊗[y⊕z]≡[x⊗y]⊕[x⊗z]\n ; distribᵣ = [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] \n ; annₗ = x⊗0≡0 \n ; annᵣ = 0⊗x≡0 \n }\n\n------------------------------------------------------------------------------\n\n", "meta": {"hexsha": "b5ec6d44bcb2a1ac2c25906a645839bee0ac1171", "size": 8881, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/PiTracedLevel0.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/PiTracedLevel0.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/PiTracedLevel0.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.5201149425, "max_line_length": 84, "alphanum_fraction": 0.5127800923, "num_tokens": 4355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5875044291746774}} {"text": "module Data.Tuple.Proofs where\n\nimport Lvl\nopen import Data using (Unit ; <>)\nopen import Data.Tuple as Tuple using (_⨯_ ; _,_)\nopen import Data.Tuple.Equiv\nopen import Function.Equals\nopen import Logic.Predicate\nopen import Logic.Propositional\nopen import Structure.Function.Domain\nopen import Structure.Function.Domain.Proofs\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Relator.Properties\nopen import Structure.Setoid\nopen import Type\n\nprivate variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ ℓₑ₅ ℓₑ₆ : Lvl.Level\nprivate variable A B A₁ B₁ A₂ B₂ : Type{ℓ}\nprivate variable f g : A → B\nprivate variable p : A ⨯ B\n\nmodule _\n ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄\n ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄\n ⦃ equiv-AB : Equiv{ℓₑ}(A ⨯ B) ⦄ ⦃ ext-AB : Extensionality(equiv-AB) ⦄\n where\n open Extensionality(ext-AB)\n\n [,]-left-right-inverses : ∀{x : A ⨯ B} → ((Tuple.left x , Tuple.right x) ≡ x)\n [,]-left-right-inverses {_ , _} = reflexivity(_≡_)\n\n left-right-[,]-inverses : ∀{a : A}{b : B} → ((Tuple.left(a , b) ≡ a) ∧ (Tuple.right(a , b) ≡ b))\n left-right-[,]-inverses = [∧]-intro (reflexivity(_≡_)) (reflexivity(_≡_))\n\n instance\n [,]ₗ-injective : ∀{r : B} → Injective(_, r)\n Injective.proof [,]ₗ-injective = congruence₁(Tuple.left)\n\n instance\n [,]ᵣ-injective : ∀{l : A} → Injective(l ,_)\n Injective.proof [,]ᵣ-injective = congruence₁(Tuple.right)\n\nmodule _\n ⦃ equiv-A₁ : Equiv{ℓₑ₁}(A₁) ⦄\n ⦃ equiv-B₁ : Equiv{ℓₑ₂}(B₁) ⦄\n ⦃ equiv-A₂ : Equiv{ℓₑ₃}(A₂) ⦄\n ⦃ equiv-B₂ : Equiv{ℓₑ₄}(B₂) ⦄\n ⦃ equiv-AB₁ : Equiv{ℓₑ₅}(A₁ ⨯ B₁) ⦄ ⦃ equiv-AB₁ : Extensionality(equiv-AB₁) ⦄\n ⦃ equiv-AB₂ : Equiv{ℓₑ₆}(A₂ ⨯ B₂) ⦄ ⦃ equiv-AB₂ : Extensionality(equiv-AB₂) ⦄\n {f : A₁ → A₂}\n {g : B₁ → B₂}\n where\n\n instance\n map-function : BinaryOperator(Tuple.map {A₁ = A₁}{A₂ = A₂}{B₁ = B₁}{B₂ = B₂})\n _⊜_.proof (BinaryOperator.congruence map-function (intro eq₁) (intro eq₂)) {_ , _} = congruence₂(_,_) eq₁ eq₂\n\n instance\n map-injective : ⦃ inj-f : Injective(f) ⦄ → ⦃ inj-g : Injective(g) ⦄ → Injective(Tuple.map f g)\n Injective.proof map-injective {_ , _} {_ , _} p = congruence₂(_,_) (injective(f) (congruence₁(Tuple.left) p)) (injective(g) (congruence₁(Tuple.right) p))\n\n instance\n map-surjective : ⦃ surj-f : Surjective(f) ⦄ → ⦃ surj-g : Surjective(g) ⦄ → Surjective(Tuple.map f g)\n ∃.witness (Surjective.proof map-surjective {l , r}) = ([∃]-witness(surjective(f) {l}) , [∃]-witness(surjective(g) {r}))\n ∃.proof (Surjective.proof map-surjective {l , r}) = congruence₂(_,_) ([∃]-proof(surjective(f) {l})) ([∃]-proof(surjective(g) {r}))\n\n instance\n map-bijective : ⦃ bij-f : Bijective(f) ⦄ → ⦃ bij-g : Bijective(g) ⦄ → Bijective(Tuple.map f g)\n map-bijective = injective-surjective-to-bijective(Tuple.map f g) where\n instance\n inj-f : Injective(f)\n inj-f = bijective-to-injective(f)\n instance\n inj-g : Injective(g)\n inj-g = bijective-to-injective(g)\n instance\n surj-f : Surjective(f)\n surj-f = bijective-to-surjective(f)\n instance\n surj-g : Surjective(g)\n surj-g = bijective-to-surjective(g)\n", "meta": {"hexsha": "fccd20fc24a6f0fec1eb59df70a1d125813f1f51", "size": 3104, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Tuple/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/Tuple/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/Tuple/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": 37.3975903614, "max_line_length": 157, "alphanum_fraction": 0.6382087629, "num_tokens": 1215, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.5874920866341447}} {"text": "------------------------------------------------------------------------------\n-- The the power function\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.Pow where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.UnaryNumbers\n\n------------------------------------------------------------------------------\n\ninfixr 11 _^_\n\npostulate\n _^_ : D → D → D\n ^-0 : ∀ n → n ^ zero ≡ 1'\n ^-S : ∀ m n → m ^ succ₁ n ≡ m * m ^ n\n{-# ATP axioms ^-0 ^-S #-}\n", "meta": {"hexsha": "855f0ce7049f2499ee792982938aecba99686251", "size": 705, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Pow.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/Pow.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/Pow.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.2, "max_line_length": 78, "alphanum_fraction": 0.3617021277, "num_tokens": 156, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.5874920799976361}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.ZCohomology.Groups.Unit where\n\nopen import Cubical.ZCohomology.Base\nopen import Cubical.ZCohomology.Properties\nopen import Cubical.HITs.Sn\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.HITs.Susp\nopen import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2)\nopen import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₋₁ ; ∣_∣ to ∣_∣₋₁)\nopen import Cubical.HITs.Nullification\nopen import Cubical.Data.Int hiding (_+_ ; +-comm)\nopen import Cubical.Data.Nat\nopen import Cubical.HITs.Truncation\nopen import Cubical.Homotopy.Connected\nopen import Cubical.Data.Unit\nopen import Cubical.Algebra.Group\n\n-- H⁰(Unit)\nopen GroupHom\nopen GroupIso\nH⁰-Unit≅ℤ : GroupIso (coHomGr 0 Unit) intGroup\nfun (GroupIso.map H⁰-Unit≅ℤ) = sRec isSetInt (λ f → f tt)\nisHom (GroupIso.map H⁰-Unit≅ℤ) = sElim2 (λ _ _ → isOfHLevelPath 2 isSetInt _ _) λ a b → addLemma (a tt) (b tt)\ninv H⁰-Unit≅ℤ a = ∣ (λ _ → a) ∣₂\nrightInv H⁰-Unit≅ℤ _ = refl\nleftInv H⁰-Unit≅ℤ = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ a → refl\n\n\n{- Hⁿ(Unit) for n ≥ 1 -}\nisContrHⁿ-Unit : (n : ℕ) → isContr (coHom (suc n) Unit)\nisContrHⁿ-Unit n = subst isContr (λ i → ∥ UnitToTypePath (coHomK (suc n)) (~ i) ∥₂) (helper' n)\n where\n helper' : (n : ℕ) → isContr (∥ coHomK (suc n) ∥₂)\n helper' n =\n subst isContr\n ((isoToPath (truncOfTruncIso {A = S₊ (1 + n)} 2 (1 + n)))\n ∙∙ sym propTrunc≡Trunc2\n ∙∙ λ i → ∥ hLevelTrunc (suc (+-comm n 2 i)) (S₊ (1 + n)) ∥₂)\n (isConnectedSubtr 2 (helper2 n .fst)\n (subst (λ x → isConnected x (S₊ (suc n))) (sym (helper2 n .snd)) (sphereConnected (suc n))) )\n where\n helper2 : (n : ℕ) → Σ[ m ∈ ℕ ] m + 2 ≡ 2 + n\n helper2 zero = 0 , refl\n helper2 (suc n) = (suc n) , λ i → suc (+-comm n 2 i)\n\nHⁿ-Unit≅0 : (n : ℕ) → GroupIso (coHomGr (suc n) Unit) trivialGroup\nGroupHom.fun (GroupIso.map (Hⁿ-Unit≅0 n)) _ = _\nGroupHom.isHom (GroupIso.map (Hⁿ-Unit≅0 n)) _ _ = refl\nGroupIso.inv (Hⁿ-Unit≅0 n) _ = 0ₕ (suc n)\nGroupIso.rightInv (Hⁿ-Unit≅0 n) _ = refl\nGroupIso.leftInv (Hⁿ-Unit≅0 n) _ = isOfHLevelSuc 0 (isContrHⁿ-Unit n) _ _\n\n\n{- Hⁿ for arbitrary contractible types -}\nprivate\n Hⁿ-contrTypeIso : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A\n → Iso (coHom (suc n) A) (coHom (suc n) Unit)\n Hⁿ-contrTypeIso n contr = compIso (setTruncIso (isContr→Iso2 contr))\n (setTruncIso (invIso (isContr→Iso2 isContrUnit)))\n\nHⁿ-contrType≅0 : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A\n → GroupIso (coHomGr (suc n) A) trivialGroup\nfun (GroupIso.map (Hⁿ-contrType≅0 _ _)) _ = _\nisHom (GroupIso.map (Hⁿ-contrType≅0 _ _)) _ _ = refl\ninv (Hⁿ-contrType≅0 n _) _ = 0ₕ (suc n)\nrightInv (Hⁿ-contrType≅0 _ _) _ = refl\nleftInv (Hⁿ-contrType≅0 {A = A} n contr) _ = isOfHLevelSuc 0 helper _ _\n where\n helper : isContr (coHom (suc n) A)\n helper = (Iso.inv (Hⁿ-contrTypeIso n contr) (0ₕ (suc n)))\n , λ y → cong (Iso.inv (Hⁿ-contrTypeIso n contr))\n (isOfHLevelSuc 0 (isContrHⁿ-Unit n) (0ₕ (suc n)) (Iso.fun (Hⁿ-contrTypeIso n contr) y))\n ∙ Iso.leftInv (Hⁿ-contrTypeIso n contr) y\n", "meta": {"hexsha": "62530cf7d7fa9d9ca6d9f14ff0a241a25730cdae", "size": 3338, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/ZCohomology/Groups/Unit.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/Unit.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/ZCohomology/Groups/Unit.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": 43.3506493506, "max_line_length": 135, "alphanum_fraction": 0.6470940683, "num_tokens": 1340, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.5874920703633482}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import cohomology.Theory\n\nmodule cw.cohomology.TopGrid {i} (OT : OrdinaryTheory i)\n (n : ℤ) {X Y Z : Ptd i} (f : X ⊙→ Y) (g : Y ⊙→ Z) where\n\n{-\n X --> Y ---> Z\n | | this |\n v v one v\n 1 -> Y/X -> Z/X\n-}\n\n open OrdinaryTheory OT\n open import cohomology.PtdMapSequence cohomology-theory\n open import cw.cohomology.GridPtdMap f g using (Y/X-to-Z/X)\n\n top-grid-comm-sqr : CommSquare (fst g) (fst Y/X-to-Z/X) cfcod cfcod\n top-grid-comm-sqr = comm-sqr λ _ → idp\n\n C-top-grid-commutes : CommSquareᴳ\n (C-fmap n Y/X-to-Z/X) (C-fmap n g) (C-fmap n (⊙cfcod' (g ⊙∘ f))) (C-fmap n (⊙cfcod' f))\n C-top-grid-commutes = C-comm-square n top-grid-comm-sqr\n", "meta": {"hexsha": "fd003316db28d02fe24fd80ffcbc8106023e9ed0", "size": 725, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cw/cohomology/TopGrid.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/cw/cohomology/TopGrid.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/cw/cohomology/TopGrid.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": 27.8846153846, "max_line_length": 91, "alphanum_fraction": 0.6151724138, "num_tokens": 284, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632936392131, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.587401415514178}} {"text": "------------------------------------------------------------------------\n-- Suspensions\n------------------------------------------------------------------------\n\n{-# OPTIONS --erased-cubical --safe #-}\n\n-- The beginning of this module follows the HoTT book rather closely.\n\n-- The module is parametrised by a notion of equality. The higher\n-- constructor of the HIT defining suspensions uses path equality, but\n-- the supplied notion of equality is used for many other things.\n\nimport Equality.Path as P\n\nmodule Suspension\n {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 (_↔_)\nopen import Embedding equality-with-J as Embedding using (Embedding)\nopen import Equality.Decision-procedures equality-with-J\nopen import Equality.Path.Isomorphisms eq\nopen import Equivalence equality-with-J using (_≃_)\nopen import Function-universe equality-with-J as F hiding (id; _∘_)\nopen import H-level equality-with-J\nopen import H-level.Closure equality-with-J\nopen import Injection equality-with-J using (_↣_)\nopen import Interval eq as Interval using (Interval; [0]; [1]; 0≡1)\nimport Nat equality-with-J as Nat\nopen import Pointed-type equality-with-J\n using (Pointed-type; _→ᴮ_; Ω)\nopen import Surjection equality-with-J using (_↠_)\n\nprivate\n variable\n a b ℓ ℓ₁ ℓ₂ p : Level\n A B : Type a\n C : Pointed-type a\n x y : A\n f g : A → B\n n : ℕ\n\n-- Suspensions.\n\ndata Susp (A : Type a) : Type a where\n north south : Susp A\n meridianᴾ : A → north P.≡ south\n\n-- Meridians.\n\nmeridian : A → _≡_ {A = Susp A} north south\nmeridian = _↔_.from ≡↔≡ ∘ meridianᴾ\n\n-- A dependent eliminator, expressed using paths.\n\nelimᴾ :\n (P : Susp A → Type p)\n (n : P north)\n (s : P south) →\n (∀ x → P.[ (λ i → P (meridianᴾ x i)) ] n ≡ s) →\n (x : Susp A) → P x\nelimᴾ _ n s n≡s = λ where\n north → n\n south → s\n (meridianᴾ x i) → n≡s x i\n\n-- A non-dependent eliminator, expressed using paths.\n\nrecᴾ : (n s : B) → (A → n P.≡ s) → Susp A → B\nrecᴾ = elimᴾ _\n\n-- A dependent eliminator.\n\nmodule Elim\n (P : Susp A → Type p)\n (n : P north)\n (s : P south)\n (n≡s : ∀ x → subst P (meridian x) n ≡ s)\n where\n\n elim : ∀ x → P x\n elim = elimᴾ P n s (subst≡→[]≡ ∘ n≡s)\n\n -- \"Computation\" rule for meridians.\n\n elim-meridian : dcong elim (meridian x) ≡ n≡s x\n elim-meridian = dcong-subst≡→[]≡ (refl _)\n\nopen Elim public\n\n-- A non-dependent eliminator.\n\nmodule Rec\n {B : Type b}\n (n s : B)\n (n≡s : A → n ≡ s)\n where\n\n rec : Susp A → B\n rec = recᴾ n s (_↔_.to ≡↔≡ ∘ n≡s)\n\n rec-meridian : cong rec (meridian x) ≡ n≡s x\n rec-meridian = cong-≡↔≡ (refl _)\n\nopen Rec public\n\n-- The universal property of suspensions.\n\nuniversal-property :\n (Susp A → B) ↔ (∃ λ (n : B) → ∃ λ (s : B) → A → n ≡ s)\nuniversal-property = record\n { surjection = record\n { logical-equivalence = record\n { to = λ f → f north , f south , cong f ∘ meridian\n ; from = λ { (n , s , f) → rec n s f }\n }\n ; right-inverse-of = λ { (n , s , f) →\n n , s , cong (rec n s f) ∘ meridian ≡⟨ cong (λ f → n , s , f) $ ⟨ext⟩ (λ _ → rec-meridian n s f) ⟩∎\n n , s , f ∎ }\n }\n ; left-inverse-of = λ f →\n let module R = Rec (f north) (f south) (cong f ∘ meridian) in\n\n R.rec ≡⟨ ⟨ext⟩ $ elim _ (refl _) (refl _) (λ x →\n\n subst (λ x → R.rec x ≡ f x) (meridian x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩\n\n trans (sym $ cong R.rec (meridian x))\n (trans (refl _) (cong f (meridian x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) R.rec-meridian (trans-reflˡ _) ⟩\n\n trans (sym $ cong f (meridian x)) (cong f (meridian x)) ≡⟨ trans-symˡ _ ⟩∎\n\n refl _ ∎) ⟩∎\n\n f ∎\n }\n\n-- Based maps from suspensions of pointed types (using north as the\n-- point) are isomorphic to based maps to loop spaces.\n\nSusp→ᴮ↔ : (Susp A , north) →ᴮ C ↔ (A , x) →ᴮ Ω C\nSusp→ᴮ↔ {A = A} {C = B , y} {x = x} =\n (Susp A , north) →ᴮ (B , y) ↔⟨⟩\n (∃ λ (f : Susp A → B) → f north ≡ y) ↝⟨ Σ-cong universal-property (λ _ → F.id) ⟩\n (∃ λ (f : ∃ λ n → ∃ λ s → A → n ≡ s) → proj₁ f ≡ y) ↝⟨ inverse Σ-assoc ⟩\n (∃ λ n → (∃ λ s → A → n ≡ s) × n ≡ y) ↝⟨ (∃-cong λ _ → inverse Σ-assoc) ⟩\n (∃ λ n → ∃ λ s → (A → n ≡ s) × n ≡ y) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ×-comm) ⟩\n (∃ λ n → ∃ λ s → n ≡ y × (A → n ≡ s)) ↝⟨ (∃-cong λ _ → ∃-comm) ⟩\n (∃ λ n → n ≡ y × ∃ λ s → A → n ≡ s) ↝⟨ Σ-assoc ⟩\n (∃ λ (p : ∃ λ n → n ≡ y) → ∃ λ s → A → proj₁ p ≡ s) ↝⟨ drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $ singleton-contractible _ ⟩\n (∃ λ s → A → y ≡ s) ↝⟨ (∃-cong λ _ → inverse $ drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $\n other-singleton-contractible _) ⟩\n (∃ λ s → ∃ λ (f : A → y ≡ s) → ∃ λ (eq : y ≡ s) → f x ≡ eq) ↝⟨ (∃-cong λ _ → ∃-comm) ⟩\n (∃ λ s → ∃ λ (eq : y ≡ s) → ∃ λ (f : A → y ≡ s) → f x ≡ eq) ↝⟨ Σ-assoc ⟩\n (∃ λ (p : ∃ λ s → y ≡ s) → ∃ λ (f : A → y ≡ proj₁ p) → f x ≡ proj₂ p) ↝⟨ drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $\n other-singleton-contractible _ ⟩\n (∃ λ (f : A → y ≡ y) → f x ≡ refl y) ↔⟨⟩\n (A , x) →ᴮ (Ω (B , y)) □\n\n-- The type of booleans can be expressed as a suspension.\n\nBool↔Susp-⊥ : Bool ↔ Susp (⊥ {ℓ = ℓ})\nBool↔Susp-⊥ = record\n { surjection = record\n { logical-equivalence = record\n { to = if_then north else south\n ; from = rec true false (λ ())\n }\n ; right-inverse-of = elim _ (refl _) (refl _) (λ ())\n }\n ; left-inverse-of = λ where\n true → refl _\n false → refl _\n }\n\nprivate\n\n -- A lemma used in some proofs below.\n\n subst-in-terms-of-trans-and-cong′ :\n {x≡y : x ≡ y} {fgx≡x : f (g x) ≡ x} →\n subst (λ z → f (g z) ≡ z) x≡y fgx≡x ≡\n trans (sym (cong f (cong g x≡y))) (trans fgx≡x x≡y)\n subst-in-terms-of-trans-and-cong′\n {f = f} {g = g} {x≡y = x≡y} {fgx≡x = fgx≡x} =\n\n subst (λ z → f (g z) ≡ z) x≡y fgx≡x ≡⟨ subst-in-terms-of-trans-and-cong ⟩\n trans (sym (cong (f ∘ g) x≡y)) (trans fgx≡x (cong id x≡y)) ≡⟨ sym $ cong₂ (λ p q → trans (sym p) (trans fgx≡x q)) (cong-∘ _ _ _) (cong-id _) ⟩∎\n trans (sym (cong f (cong g x≡y))) (trans fgx≡x x≡y) ∎\n\n-- The remainder of this module is not based on the HoTT book.\n\n-- The interval can be expressed as a suspension.\n\nInterval↔Susp-⊤ : Interval ↔ Susp ⊤\nInterval↔Susp-⊤ = record\n { surjection = record\n { logical-equivalence = record\n { to = to\n ; from = from\n }\n ; right-inverse-of = elim\n _\n (refl _)\n (refl _)\n (λ _ →\n subst (λ x → to (from x) ≡ x) (meridian tt) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong′ ⟩\n\n trans (sym (cong to (cong from (meridian tt))))\n (trans (refl _) (meridian tt)) ≡⟨ cong₂ (λ p q → trans (sym (cong to p)) q)\n (rec-meridian _ _ _)\n (trans-reflˡ _) ⟩\n trans (sym (cong to 0≡1)) (meridian tt) ≡⟨ cong (λ p → trans (sym p) (meridian tt)) $ Interval.rec-0≡1 _ _ _ ⟩\n\n trans (sym (meridian tt)) (meridian tt) ≡⟨ trans-symˡ _ ⟩∎\n\n refl _ ∎)\n }\n ; left-inverse-of = Interval.elim\n _\n (refl _)\n (refl _)\n (subst (λ x → from (to x) ≡ x) 0≡1 (refl _) ≡⟨ subst-in-terms-of-trans-and-cong′ ⟩\n trans (sym (cong from (cong to 0≡1))) (trans (refl _) 0≡1) ≡⟨ cong₂ (λ p q → trans (sym (cong from p)) q)\n (Interval.rec-0≡1 _ _ _)\n (trans-reflˡ _) ⟩\n trans (sym (cong from (meridian tt))) 0≡1 ≡⟨ cong (λ p → trans (sym p) 0≡1) $ rec-meridian _ _ _ ⟩\n trans (sym 0≡1) 0≡1 ≡⟨ trans-symˡ _ ⟩∎\n refl _ ∎)\n }\n where\n to = Interval.rec north south (meridian tt)\n from = rec [0] [1] λ _ → 0≡1\n\n-- A map function.\n\nmap : (A → B) → Susp A → Susp B\nmap A→B = rec north south (meridian ∘ A→B)\n\nprivate\n\n -- A helper function used to implement cong-↠ and cong-↔.\n\n map∘map :\n (∀ x → f (g x) ≡ x) →\n ∀ x → map f (map g x) ≡ x\n map∘map {f = f} {g = g} hyp = elim\n _\n (refl _)\n (refl _)\n (λ x →\n subst (λ x → map f (map g x) ≡ x) (meridian x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong′ ⟩\n\n trans (sym $ cong (map f) $ cong (map g) (meridian x))\n (trans (refl _) (meridian x)) ≡⟨ cong₂ (λ p q → trans (sym $ cong (map f) p) q)\n (rec-meridian _ _ _)\n (trans-reflˡ _) ⟩\n\n trans (sym $ cong (map f) $ meridian (g x)) (meridian x) ≡⟨ cong (λ p → trans (sym p) (meridian x)) $ rec-meridian _ _ _ ⟩\n\n trans (sym $ meridian (f (g x))) (meridian x) ≡⟨ cong (λ y → trans (sym $ meridian y) (meridian x)) $ hyp x ⟩\n\n trans (sym $ meridian x) (meridian x) ≡⟨ trans-symˡ _ ⟩∎\n\n refl _ ∎)\n\n-- Some preservation lemmas.\n\ncong-⇔ : A ⇔ B → Susp A ⇔ Susp B\ncong-⇔ A⇔B = record\n { to = map (_⇔_.to A⇔B)\n ; from = map (_⇔_.from A⇔B)\n }\n\ncong-↠ : A ↠ B → Susp A ↠ Susp B\ncong-↠ A↠B = record\n { logical-equivalence = cong-⇔ (_↠_.logical-equivalence A↠B)\n ; right-inverse-of = map∘map (_↠_.right-inverse-of A↠B)\n }\n\ncong-↔ : A ↔ B → Susp A ↔ Susp B\ncong-↔ A↔B = record\n { surjection = cong-↠ (_↔_.surjection A↔B)\n ; left-inverse-of = map∘map (_↔_.left-inverse-of A↔B)\n }\n\ncong-≃ : A ≃ B → Susp A ≃ Susp B\ncong-≃ = from-isomorphism ∘ cong-↔ ∘ from-isomorphism\n\nprivate\n\n -- Lemmas used to implement ¬-cong-↣ and ¬-cong-Embedding.\n\n ⊥↣⊤ : ⊥ {ℓ = ℓ₁} ↣ ↑ ℓ₂ ⊤\n ⊥↣⊤ = record\n { to = λ ()\n ; injective = λ {}\n }\n\n ¬Susp⊥↣Susp⊤ : ¬ (Susp (⊥ {ℓ = ℓ₁}) ↣ Susp (↑ ℓ₂ ⊤))\n ¬Susp⊥↣Susp⊤ =\n Susp ⊥ ↣ Susp (↑ _ ⊤) ↝⟨ (λ f → from-isomorphism (cong-↔ Bijection.↑↔) F.∘ f F.∘\n from-isomorphism (cong-↔ ⊥↔⊥)) ⟩\n Susp ⊥₀ ↣ Susp ⊤ ↝⟨ (λ f → from-isomorphism (inverse Interval↔Susp-⊤) F.∘ f F.∘\n from-isomorphism Bool↔Susp-⊥) ⟩\n Bool ↣ Interval ↝⟨ (λ inj → _↣_.to inj , _↣_.injective inj) ⟩\n (∃ λ (f : Bool → Interval) → f true ≡ f false → true ≡ false) ↝⟨ Σ-map id (λ f → f (mono₁ 0 Interval.interval-contractible _ _)) ⟩\n (Bool → Interval) × true ≡ false ↝⟨ proj₂ ⟩\n true ≡ false ↝⟨ Bool.true≢false ⟩□\n ⊥ □\n\n-- Some negative preservation results.\n\n¬-cong-↣ :\n ¬ (∀ {A : Type a} {B : Type b} → A ↣ B → Susp A ↣ Susp B)\n¬-cong-↣ {a = a} {b = b} =\n (∀ {A B} → A ↣ B → Susp A ↣ Susp B) ↝⟨ (λ hyp → hyp) ⟩\n (⊥ ↣ ↑ _ ⊤ → Susp ⊥ ↣ Susp (↑ _ ⊤)) ↝⟨ _$ ⊥↣⊤ ⟩\n Susp ⊥ ↣ Susp (↑ _ ⊤) ↝⟨ ¬Susp⊥↣Susp⊤ ⟩□\n ⊥ □\n\n¬-cong-Embedding :\n ¬ (∀ {A : Type a} {B : Type b} →\n Embedding A B → Embedding (Susp A) (Susp B))\n¬-cong-Embedding =\n (∀ {A B} → Embedding A B → Embedding (Susp A) (Susp B)) ↝⟨ (λ hyp → hyp) ⟩\n (Embedding ⊥ (↑ _ ⊤) → Embedding (Susp ⊥) (Susp (↑ _ ⊤))) ↝⟨ _$ Emb-⊥-⊤ ⟩\n Embedding (Susp ⊥) (Susp (↑ _ ⊤)) ↝⟨ Embedding.injection ⟩\n Susp ⊥ ↣ Susp (↑ _ ⊤) ↝⟨ ¬Susp⊥↣Susp⊤ ⟩□\n ⊥ □\n where\n Emb-⊥-⊤ : Embedding ⊥ (↑ _ ⊤)\n Emb-⊥-⊤ =\n _↔_.to (Embedding.↣↔Embedding\n ext\n (mono₁ 1 ⊥-propositional)\n (mono (Nat.zero≤ 2) (↑-closure 0 ⊤-contractible)))\n ⊥↣⊤\n", "meta": {"hexsha": "4a1e283ee4af22e47551bd091adb988d2e4d5e50", "size": 13106, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Suspension.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/Suspension.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/Suspension.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.2099125364, "max_line_length": 148, "alphanum_fraction": 0.4391118572, "num_tokens": 4645, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.6926419831347362, "lm_q1q2_score": 0.5873380751194903}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Category.Complete.Properties.Construction {o ℓ e} (C : Category o ℓ e) where\n\nopen import Level\nopen import Data.Product using (∃₂; _,_; -,_)\n\nopen import Categories.Category.Complete\nopen import Categories.Diagram.Equalizer C\nopen import Categories.Diagram.Limit as Lim\nopen import Categories.Object.Product.Indexed C\nopen import Categories.Functor\n\nimport Categories.Category.Construction.Cones as Co\nimport Categories.Morphism.Reasoning as MR\n\nprivate\n variable\n o′ ℓ′ e′ o″ ℓ″ e″ : Level\n module C = Category C\n\nmodule _ (prods : AllProductsOf (o′ ⊔ ℓ′)) (equalizer : ∀ {A B} (f g : A C.⇒ B) → Equalizer f g) where\n private\n module Prods {I} (P : I → C.Obj) = IndexedProductOf (prods P)\n open C.HomReasoning\n\n module _ {J : Category o′ ℓ′ e′} (F : Functor J C) where\n private\n module J = Category J\n open Functor F\n open MR C\n module OP = Prods {Lift ℓ′ J.Obj} (λ j → F₀ (lower j))\n module MP = Prods {∃₂ J._⇒_} (λ { (_ , B , _) → F₀ B })\n\n src : C.Obj\n src = OP.X\n\n dst : C.Obj\n dst = MP.X\n\n ϕ⇒ : (i : ∃₂ J._⇒_) → let (_ , B , _) = i in src C.⇒ F₀ B\n ϕ⇒ (_ , B , _) = OP.π (lift B)\n\n ϕ : src C.⇒ dst\n ϕ = MP.⟨ ϕ⇒ ⟩\n\n ψ⇒ : (i : ∃₂ J._⇒_) → let (_ , B , _) = i in src C.⇒ F₀ B\n ψ⇒ (A , B , f) = F₁ f C.∘ OP.π (lift A)\n\n ψ : src C.⇒ dst\n ψ = MP.⟨ ψ⇒ ⟩\n\n module eq = Equalizer (equalizer ϕ ψ)\n\n ⊤ : Co.Cone F\n ⊤ = record\n { N = eq.obj\n ; apex = record\n { ψ = λ X → OP.π (lift X) C.∘ eq.arr\n ; commute = λ {X Y} f → begin\n F₁ f C.∘ OP.π (lift X) C.∘ eq.arr ≈˘⟨ pushˡ (MP.commute ψ⇒ _) ⟩\n (MP.π (-, -, f) C.∘ ψ) C.∘ eq.arr ≈˘⟨ pushʳ eq.equality ⟩\n MP.π (-, -, f) C.∘ ϕ C.∘ eq.arr ≈⟨ pullˡ (MP.commute ϕ⇒ _ ) ⟩\n OP.π (lift Y) C.∘ eq.arr ∎\n }\n }\n\n module _ {K : Co.Cone F} where\n private\n module K = Co.Cone F K\n\n K⇒ : K.N C.⇒ src\n K⇒ = OP.⟨ (λ j → K.ψ (lower j)) ⟩\n\n Keq : (i : ∃₂ J._⇒_) → ϕ⇒ i C.∘ K⇒ C.≈ ψ⇒ i C.∘ K⇒\n Keq i@(A , B , f) = begin\n ϕ⇒ i C.∘ K⇒ ≈⟨ OP.commute _ _ ⟩\n K.ψ B ≈˘⟨ K.commute _ ⟩\n F₁ f C.∘ K.ψ A ≈˘⟨ pullʳ (OP.commute _ _) ⟩\n ψ⇒ i C.∘ K⇒ ∎\n\n !-eq : ϕ C.∘ K⇒ C.≈ ψ C.∘ K⇒\n !-eq = begin\n ϕ C.∘ K⇒ ≈⟨ MP.⟨⟩∘ _ _ ⟩\n MP.⟨ (λ i → ϕ⇒ i C.∘ K⇒) ⟩ ≈⟨ MP.⟨⟩-cong _ _ Keq ⟩\n MP.⟨ (λ i → ψ⇒ i C.∘ K⇒) ⟩ ≈˘⟨ MP.⟨⟩∘ _ _ ⟩\n ψ C.∘ K⇒ ∎\n\n ! : Co.Cones F [ K , ⊤ ]\n ! = record\n { arr = eq.equalize {h = K⇒} !-eq\n ; commute = λ {j} → begin\n (OP.π (lift j) C.∘ eq.arr) C.∘ eq.equalize !-eq ≈˘⟨ pushʳ eq.universal ⟩\n OP.π (lift j) C.∘ K⇒ ≈⟨ OP.commute _ _ ⟩\n K.ψ j ∎\n }\n\n !-unique : (f : Co.Cones F [ K , ⊤ ]) → Co.Cones F [ ! ≈ f ]\n !-unique f = ⟺ (eq.unique eq)\n where module f = Co.Cone⇒ F f\n eq : K⇒ C.≈ eq.arr C.∘ f.arr\n eq = OP.unique′ _ _ λ i → begin\n OP.π i C.∘ K⇒ ≈⟨ OP.commute _ _ ⟩\n K.ψ (lower i) ≈˘⟨ f.commute ⟩\n (OP.π i C.∘ eq.arr) C.∘ f.arr ≈⟨ C.assoc ⟩\n OP.π i C.∘ eq.arr C.∘ f.arr ∎\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 AllProducts×Equalizer⇒Complete : Complete o′ ℓ′ e′ C\n AllProducts×Equalizer⇒Complete = complete\n", "meta": {"hexsha": "ef6bb8c0c8515f336d707650864af97ac55fa4a4", "size": 3852, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Complete/Properties/Construction.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/Complete/Properties/Construction.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/Complete/Properties/Construction.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.3170731707, "max_line_length": 102, "alphanum_fraction": 0.4317237799, "num_tokens": 1565, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778257, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5873380644171273}} {"text": "{-# OPTIONS --safe --warning=error --with-K #-}\n\nopen import Sets.EquivalenceRelations\nopen import Groups.Definition\nopen import Orders\nopen import Rings.Definition\nopen import Numbers.Integers.Integers\nopen import Numbers.Integers.Multiplication\nopen import Setoids.Setoids\nopen import LogicalFormulae\nopen import Sets.FinSet\nopen import Functions\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.WithK\nopen import Numbers.Modulo.Definition\nopen import Numbers.Modulo.Addition\nopen import Numbers.Modulo.Group\nopen import Rings.Examples.Examples\nopen import Numbers.Primes.PrimeNumbers\nopen import Groups.Lemmas\nopen import Groups.Homomorphisms.Definition\nopen import Groups.Homomorphisms.Lemmas\nopen import Groups.Isomorphisms.Definition\nopen import Groups.Cyclic.Definition\nopen import Groups.QuotientGroup.Definition\nopen import Groups.Subgroups.Definition\nopen import Groups.Subgroups.Normal.Definition\n\nmodule Groups.Examples.Examples where\n\ntrivialGroup : Group (reflSetoid (FinSet 1)) λ _ _ → fzero\nGroup.+WellDefined trivialGroup _ _ = refl\nGroup.0G trivialGroup = fzero\nGroup.inverse trivialGroup _ = fzero\nGroup.+Associative trivialGroup = refl\nGroup.identRight trivialGroup {fzero} = refl\nGroup.identRight trivialGroup {fsucc ()}\nGroup.identLeft trivialGroup {fzero} = refl\nGroup.identLeft trivialGroup {fsucc ()}\nGroup.invLeft trivialGroup = refl\nGroup.invRight trivialGroup = refl\n\nelementPowZ : (n : ℕ) → (elementPower ℤGroup (nonneg 1) (nonneg n)) ≡ nonneg n\nelementPowZ zero = refl\nelementPowZ (succ n) rewrite elementPowZ n = refl\n\nℤCyclic : CyclicGroup ℤGroup\nCyclicGroup.generator ℤCyclic = nonneg 1\nCyclicGroup.cyclic ℤCyclic {nonneg x} = (nonneg x , elementPowZ x)\nCyclicGroup.cyclic ℤCyclic {negSucc x} = (negSucc x , ans)\n where\n ans : (Group.inverse ℤGroup ((nonneg 1) +Z elementPower ℤGroup (nonneg 1) (nonneg x))) ≡ negSucc x\n ans rewrite elementPowZ x = refl\n\nelementPowZn : (n : ℕ) → {pr : 0 >=_ = λ x f → negated-stable (¬¬-map f x)\n }\n\n¬¬-push : ∀ {p q} {P : Set p} {Q : P → Set q} →\n ¬ ¬ ((x : P) → Q x) → (x : P) → ¬ ¬ Q x\n¬¬-push ¬¬P⟶Q P ¬Q = ¬¬P⟶Q (λ P⟶Q → ¬Q (P⟶Q P))\n\n-- A double-negation-translated variant of excluded middle (or: every\n-- nullary relation is decidable in the double-negation monad).\n\nexcluded-middle : ∀ {p} {P : Set p} → ¬ ¬ Dec P\nexcluded-middle ¬h = ¬h (no (λ p → ¬h (yes p)))\n\n-- If Whatever is instantiated with ¬ ¬ something, then this function\n-- is call with current continuation in the double-negation monad, or,\n-- if you will, a double-negation translation of Peirce's law.\n--\n-- In order to prove ¬ ¬ P one can assume ¬ P and prove ⊥. However,\n-- sometimes it is nice to avoid leaving the double-negation monad; in\n-- that case this function can be used (with Whatever instantiated to\n-- ⊥).\n\ncall/cc : ∀ {w p} {Whatever : Set w} {P : Set p} →\n ((P → Whatever) → ¬ ¬ P) → ¬ ¬ P\ncall/cc hyp ¬p = hyp (λ p → ⊥-elim (¬p p)) ¬p\n\n-- The \"independence of premise\" rule, in the double-negation monad.\n-- It is assumed that the index set (Q) is inhabited.\n\nindependence-of-premise\n : ∀ {p q r} {P : Set p} {Q : Set q} {R : Q → Set r} →\n Q → (P → Σ Q R) → ¬ ¬ (Σ[ x ∈ Q ] (P → R x))\nindependence-of-premise {P = P} q f = ¬¬-map helper excluded-middle\n where\n helper : Dec P → _\n helper (yes p) = Prod.map id const (f p)\n helper (no ¬p) = (q , ⊥-elim ∘′ ¬p)\n\n-- The independence of premise rule for binary sums.\n\nindependence-of-premise-⊎\n : ∀ {p q r} {P : Set p} {Q : Set q} {R : Set r} →\n (P → Q ⊎ R) → ¬ ¬ ((P → Q) ⊎ (P → R))\nindependence-of-premise-⊎ {P = P} f = ¬¬-map helper excluded-middle\n where\n helper : Dec P → _\n helper (yes p) = Sum.map const const (f p)\n helper (no ¬p) = inj₁ (⊥-elim ∘′ ¬p)\n\nprivate\n\n -- Note that independence-of-premise-⊎ is a consequence of\n -- independence-of-premise (for simplicity it is assumed that Q and\n -- R have the same type here):\n\n corollary : ∀ {p ℓ} {P : Set p} {Q R : Set ℓ} →\n (P → Q ⊎ R) → ¬ ¬ ((P → Q) ⊎ (P → R))\n corollary {P = P} {Q} {R} f =\n ¬¬-map helper (independence-of-premise\n true ([ _,_ true , _,_ false ] ∘′ f))\n where\n helper : ∃ (λ b → P → if b then Q else R) → (P → Q) ⊎ (P → R)\n helper (true , f) = inj₁ f\n helper (false , f) = inj₂ f\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.0\n\nExcluded-Middle : (ℓ : Level) → Set (suc ℓ)\nExcluded-Middle p = {P : Set p} → Dec P\n{-# WARNING_ON_USAGE Excluded-Middle\n\"Warning: Excluded-Middle was deprecated in v1.0.\nPlease use ExcludedMiddle from `Axiom.ExcludedMiddle` instead.\"\n#-}\n\nDouble-Negation-Elimination : (ℓ : Level) → Set (suc ℓ)\nDouble-Negation-Elimination p = {P : Set p} → Stable P\n{-# WARNING_ON_USAGE Double-Negation-Elimination\n\"Warning: Double-Negation-Elimination was deprecated in v1.0.\nPlease use DoubleNegationElimination from `Axiom.DoubleNegationElimination` instead.\"\n#-}\n", "meta": {"hexsha": "158ce718d928634240a04970f2369299cfea35d6", "size": 6029, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Negation.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/Nullary/Negation.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/Nullary/Negation.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.7315789474, "max_line_length": 85, "alphanum_fraction": 0.5183280809, "num_tokens": 2151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.7662936377487305, "lm_q1q2_score": 0.5872059433440674}} {"text": "open import Type\n\nmodule Formalization.ClassicalPropositionalLogic.TruthTable {ℓₚ}{P : Type{ℓₚ}} where\n\nimport Lvl\nopen import Data\nopen import Data.Boolean\nopen import Data.Boolean.Operators using () renaming (module Logic to Bool)\nimport Data.Boolean.Proofs as Bool\nopen import Data.Boolean.Stmt\nopen import Data.Boolean.Stmt.Proofs\nopen import Data.Either as Either using (_‖_ ; Left ; Right)\nopen import Data.Tuple as Tuple using ()\nopen import Formalization.ClassicalPropositionalLogic.Syntax\nopen import Formalization.ClassicalPropositionalLogic.Semantics\nopen import Functional\nimport Logic.Propositional as Logic\nimport Logic.Propositional.Theorems as Logic\nopen import Logic\nopen import Relator.Equals.Proofs.Equiv\nimport Sets.PredicateSet\nopen Sets.PredicateSet.BoundedQuantifiers\n\nprivate variable ℓ : Lvl.Level\n\n-- `_⊧_`, but decidable.\neval : Model(P) → Formula(P) → Bool\neval env (• p) = env(p)\neval env (⊤) = 𝑇\neval env (⊥) = 𝐹\neval env (¬ φ) = Bool.¬(eval env (φ))\neval env (φ ∧ ψ) = eval env (φ) Bool.∧ eval env (ψ)\neval env (φ ∨ ψ) = eval env (φ) Bool.∨ eval env (ψ)\neval env (φ ⟶ ψ) = eval env (φ) Bool.⟶ eval env (ψ)\neval env (φ ⟷ ψ) = eval env (φ) Bool.⟷ eval env (ψ)\n\n_⊢_ : Formulas(P){ℓ} → Formula(P) → Stmt\nΓ ⊢ φ = ∀{𝔐} → (∀ₛ(Γ) (IsTrue ∘ eval 𝔐)) → IsTrue(eval 𝔐 φ)\n\nprivate variable Γ Γ₁ Γ₂ : Formulas(P){ℓ}\nprivate variable φ ψ : Formula(P)\nprivate variable 𝔐 : Model(P)\n\nmodels-to-eval : (𝔐 ⊧ φ) → IsTrue(eval 𝔐 φ)\neval-to-models : IsTrue(eval 𝔐 φ) → (𝔐 ⊧ φ)\n\neval-to-models {φ = • x} p = p\neval-to-models {φ = ⊤} p = <>\neval-to-models {φ = ⊥} p = p\neval-to-models {φ = ¬ φ} p = Logic.[↔]-to-[→] IsTrue.preserves-[!][¬] p ∘ models-to-eval {φ = φ}\neval-to-models {φ = φ ∧ ψ} p = Tuple.map (eval-to-models {φ = φ}) (eval-to-models {φ = ψ}) (Logic.[↔]-to-[→] IsTrue.preserves-[&&][∧] p)\neval-to-models {φ = φ ∨ ψ} p = Either.map (eval-to-models {φ = φ}) (eval-to-models {φ = ψ}) (Logic.[↔]-to-[→] IsTrue.preserves-[||][∨] p)\neval-to-models {φ = φ ⟶ ψ} p = Either.map (Logic.contrapositiveᵣ (models-to-eval {φ = φ}) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[!][¬]) (eval-to-models {φ = ψ}) (Logic.[↔]-to-[→] IsTrue.preserves-[||][∨] ([≡]-substitutionᵣ Bool.[→?]-disjunctive-form {f = IsTrue} p))\neval-to-models {φ = φ ⟷ ψ} p = Either.map (Tuple.map (eval-to-models {φ = φ}) (eval-to-models {φ = ψ}) ∘ (Logic.[↔]-to-[→] IsTrue.preserves-[&&][∧])) (Tuple.map (Logic.contrapositiveᵣ (models-to-eval {φ = φ}) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[!][¬]) (Logic.contrapositiveᵣ (models-to-eval {φ = ψ}) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[!][¬]) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[&&][∧]) (Logic.[↔]-to-[→] IsTrue.preserves-[||][∨] ([≡]-substitutionᵣ Bool.[==]-disjunctive-form {f = IsTrue} p))\n\nmodels-to-eval {φ = • x} p = p\nmodels-to-eval {φ = ⊤} p = <>\nmodels-to-eval {φ = ⊥} p = p\nmodels-to-eval {φ = ¬ φ} p = Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] (p ∘ eval-to-models {φ = φ})\nmodels-to-eval {φ = φ ∧ ψ} p = Logic.[↔]-to-[←] IsTrue.preserves-[&&][∧] (Tuple.map (models-to-eval {φ = φ}) (models-to-eval {φ = ψ}) p)\nmodels-to-eval {φ = φ ∨ ψ} p = Logic.[↔]-to-[←] IsTrue.preserves-[||][∨] (Either.map (models-to-eval {φ = φ}) (models-to-eval {φ = ψ}) p)\nmodels-to-eval {φ = φ ⟶ ψ} p = [≡]-substitutionₗ Bool.[→?]-disjunctive-form {f = IsTrue} (Logic.[↔]-to-[←] IsTrue.preserves-[||][∨] (Either.map (Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] ∘ Logic.contrapositiveᵣ (eval-to-models {φ = φ})) (models-to-eval {φ = ψ}) p))\nmodels-to-eval {φ = φ ⟷ ψ} p = [≡]-substitutionₗ Bool.[==]-disjunctive-form {f = IsTrue} (Logic.[↔]-to-[←] IsTrue.preserves-[||][∨] (Either.map (Logic.[↔]-to-[←] IsTrue.preserves-[&&][∧] ∘ Tuple.map (models-to-eval {φ = φ}) (models-to-eval {φ = ψ})) (Logic.[↔]-to-[←] IsTrue.preserves-[&&][∧] ∘ Tuple.map (Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] ∘ Logic.contrapositiveᵣ (eval-to-models {φ = φ})) (Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] ∘ Logic.contrapositiveᵣ (eval-to-models {φ = ψ}))) p))\n\ncompleteness : (Γ ⊨ φ) → (Γ ⊢ φ)\ncompleteness {φ = φ} Γφ {𝔐} a = models-to-eval {φ = φ} (Γφ (\\{γ} → eval-to-models {φ = γ} ∘ a))\n\nsoundness : (Γ ⊢ φ) → (Γ ⊨ φ)\nsoundness {φ = φ} Γφ {𝔐} a = eval-to-models {φ = φ} (Γφ (\\{γ} → models-to-eval {φ = γ} ∘ a))\n", "meta": {"hexsha": "e222f7b8b8cf27887768126e5c736c01249f44b3", "size": 4257, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/ClassicalPropositionalLogic/TruthTable.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/ClassicalPropositionalLogic/TruthTable.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/ClassicalPropositionalLogic/TruthTable.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": 60.8142857143, "max_line_length": 495, "alphanum_fraction": 0.6053558844, "num_tokens": 1713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339837155239, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.5871876953634491}} {"text": "{-# OPTIONS --without-K #-}\nmodule PathStructure.Id.Tr {a b} {A : Set a} {B : Set b} where\n\nopen import Equivalence\nopen import PathOperations\nopen import Types\n\ntr-split : {a a′ : A} {b b′ : B} (p : a ≡ a′) →\n tr (λ _ → B) p b ≡ b′ → b ≡ b′\ntr-split {b = b} {b′ = b′} = J\n (λ _ _ p → tr (λ _ → B) p b ≡ b′ → b ≡ b′)\n (λ _ p → p) _ _\n\ntr-merge : {a a′ : A} {b b′ : B} (p : a ≡ a′) →\n b ≡ b′ → tr (λ _ → B) p b ≡ b′\ntr-merge {b = b} {b′ = b′} = J\n (λ _ _ p → b ≡ b′ → tr (λ _ → B) p b ≡ b′)\n (λ _ p → p) _ _\n\ntr-eq : {a a′ : A} {b b′ : B} (p : a ≡ a′) →\n (tr (λ _ → B) p b ≡ b′) ≃ (b ≡ b′)\ntr-eq p\n = tr-split p\n , (tr-merge p , λ q → J\n (λ _ _ p → tr-split p (tr-merge p q) ≡ q)\n (λ _ → refl) _ _ p)\n , (tr-merge p , λ q → J\n (λ _ _ p → (b b′ : B) (q : tr (λ _ → B) p b ≡ b′) →\n tr-merge p (tr-split p q) ≡ q)\n (λ _ _ _ _ → refl) _ _ p _ _ q)\n\n-- In presence of univalence axiom, this statement\n-- can also be proven from tr-eq.\ntr-≡ : {a a′ : A} {b b′ : B} (p : a ≡ a′) →\n (tr (λ _ → B) p b ≡ b′) ≡ (b ≡ b′)\ntr-≡ {b = b} {b′ = b′} = J\n (λ _ _ p → (tr (λ _ → B) p b ≡ b′) ≡ (b ≡ b′))\n (λ _ → refl) _ _\n", "meta": {"hexsha": "868c79239d4b16ca25ad72628d3f186b1a0e0ac0", "size": 1142, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/PathStructure/Id/Tr.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/Id/Tr.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/Id/Tr.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": 29.2820512821, "max_line_length": 62, "alphanum_fraction": 0.4220665499, "num_tokens": 574, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339676722393, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5871876946709402}} {"text": "-- Minimal implicational logic, de Bruijn approach, final encoding\n\nmodule Bf.ArrMp where\n\nopen import Lib using (List; _,_; LMem; lzero; lsuc)\n\n\n-- Types\n\ninfixr 0 _=>_\ndata Ty : Set where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\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\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=> v0\n\naK : forall {a b} -> Thm (a => b => a)\naK =\n lam=>\n lam=> v1\n\naS : forall {a b c} -> Thm ((a => b => c) => (a => b) => a => c)\naS =\n lam=>\n lam=>\n lam=> v2 $ v0 $ (v1 $ v0)\n\ntSKK : forall {a} -> Thm (a => a)\ntSKK {a = a} =\n aS {b = a => a} $ aK $ aK\n", "meta": {"hexsha": "5356301331aa523980e0be87ef0ded463f398ff1", "size": 1367, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Bf/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/Bf/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/Bf/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.472972973, "max_line_length": 70, "alphanum_fraction": 0.4996342356, "num_tokens": 552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339676722394, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.5871876841451116}} {"text": "open import Level using (_⊔_; suc; Lift; lift)\nopen import Function using (_$_; _∘_; _⤖_)\nopen import Relation.Nullary using (¬_)\nopen import Relation.Nullary.Decidable using (False)\nopen import Relation.Binary using (Rel; Decidable; Setoid; DecSetoid; IsEquivalence; IsDecEquivalence)\n\nopen import Data.Empty using (⊥)\nopen import Data.Product using (∃-syntax; _,_)\nopen import Data.Sum using (_⊎_)\n\nmodule AKS.Algebra.Structures {c ℓ} (C : Set c) (_≈_ : Rel C ℓ) where\n\nopen import Data.Unit using (⊤; tt)\nopen import Agda.Builtin.FromNat using (Number)\nopen import AKS.Nat using (ℕ; _<_; _≟_)\nopen import AKS.Fin using (Fin)\n\nopen import Algebra.Core using (Op₂; Op₁)\nopen import Algebra.Structures _≈_ using (IsCommutativeRing; IsAbelianGroup)\n\ninfix 4 _≉_\n_≉_ : Rel C ℓ\nx ≉ y = x ≈ y → ⊥\n\nrecord IsNonZeroCommutativeRing (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) : Set (c ⊔ ℓ) where\n field\n isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#\n 0#≉1# : 0# ≉ 1#\n\n open IsCommutativeRing isCommutativeRing public\n open import Relation.Binary.Reasoning.Setoid setoid\n open import Algebra.Properties.Ring (record { isRing = isRing }) using (-‿distribˡ-*; -‿involutive)\n\n 1#≉0# : 1# ≉ 0#\n 1#≉0# = 0#≉1# ∘ sym\n\n 0#≉-1# : 0# ≉ - 1#\n 0#≉-1# 0#≈-1# = 0#≉1# $ begin\n 0# ≈⟨ sym (zeroʳ 0#) ⟩\n 0# * 0# ≈⟨ *-cong 0#≈-1# 0#≈-1# ⟩\n (- 1#) * (- 1#) ≈⟨ sym (-‿distribˡ-* 1# (- 1#)) ⟩\n - (1# * (- 1#)) ≈⟨ -‿cong (*-identityˡ (- 1#)) ⟩\n - (- 1#) ≈⟨ -‿involutive 1# ⟩\n 1# ∎\n\n -1#≉0# : - 1# ≉ 0#\n -1#≉0# = 0#≉-1# ∘ sym\n\n C/0 : Set (c ⊔ ℓ)\n C/0 = ∃[ x ] (x ≉ 0#)\n\n 1#-nonzero : C/0\n 1#-nonzero = 1# , 1#≉0#\n\n -1#-nonzero : C/0\n -1#-nonzero = - 1# , -1#≉0#\n\n fromNat : ℕ → C\n fromNat ℕ.zero = 0#\n fromNat (ℕ.suc ℕ.zero) = 1#\n fromNat (ℕ.suc (ℕ.suc n)) = 1# + fromNat (ℕ.suc n)\n\n instance\n C-number : Number C\n C-number = record\n { Constraint = λ _ → Lift c ⊤\n ; fromNat = λ n → fromNat n\n }\n\nrecord IsIntegralDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) : Set (c ⊔ ℓ) where\n field\n isNonZeroCommutativeRing : IsNonZeroCommutativeRing _+_ _*_ -_ 0# 1#\n *-cancelˡ : ∀ x {y z} → x ≉ 0# → (x * y) ≈ (x * z) → y ≈ z\n\n open IsNonZeroCommutativeRing isNonZeroCommutativeRing public\n open import Relation.Binary.Reasoning.Setoid setoid\n\n *-cancelʳ : ∀ x {y z} → x ≉ 0# → (y * x) ≈ (z * x) → y ≈ z\n *-cancelʳ x {y} {z} x≉0 y*x≈z*x = *-cancelˡ x x≉0 $ begin\n (x * y) ≈⟨ *-comm x y ⟩\n (y * x) ≈⟨ y*x≈z*x ⟩\n (z * x) ≈⟨ *-comm z x ⟩\n (x * z) ∎\n\n *≉0 : ∀ {c₁ c₂} → c₁ ≉ 0# → c₂ ≉ 0# → c₁ * c₂ ≉ 0#\n *≉0 {c₁} {c₂} c₁≉0 c₂≉0 c₁*c₂≈0 = c₂≉0 $ *-cancelˡ c₁ c₁≉0 $ begin\n (c₁ * c₂) ≈⟨ c₁*c₂≈0 ⟩\n (0#) ≈⟨ sym (zeroʳ c₁) ⟩\n (c₁ * 0#) ∎\n\n infixl 7 _*-nonzero_\n _*-nonzero_ : C/0 → C/0 → C/0\n (c₁ , c₁≉0) *-nonzero (c₂ , c₂≉0) = c₁ * c₂ , *≉0 c₁≉0 c₂≉0\n\nmodule Divisibility (_*_ : Op₂ C) where\n infix 4 _∣_\n record _∣_ (d : C) (a : C) : Set (c ⊔ ℓ) where\n constructor divides\n field\n quotient : C\n equality : a ≈ (quotient * d)\n\n infix 4 _∤_\n _∤_ : C → C → Set (c ⊔ ℓ)\n d ∤ a = ¬ (d ∣ a)\n\n record IsGCD (gcd : Op₂ C) : Set (c ⊔ ℓ) where\n field\n gcd[a,b]∣a : ∀ a b → gcd a b ∣ a\n gcd[a,b]∣b : ∀ a b → gcd a b ∣ b\n gcd-greatest : ∀ {c a b} → c ∣ a → c ∣ b → c ∣ gcd a b\n\nrecord IsGCDDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where\n open Divisibility _*_ public\n field\n isIntegralDomain : IsIntegralDomain _+_ _*_ -_ 0# 1#\n gcd-isGCD : IsGCD gcd\n\n open IsIntegralDomain isIntegralDomain public\n\nrecord IsUniqueFactorizationDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where\n field\n isGCDDomain : IsGCDDomain _+_ _*_ -_ 0# 1# gcd\n -- TODO define factorization\n\n open IsGCDDomain isGCDDomain public\n\nmodule Modulus\n (0# : C) (∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ) (_mod_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C)\n where\n data Remainder (n : C) (m : C) {m≉0 : m ≉ 0#} : Set (c ⊔ ℓ) where\n 0≈ : (r≈0 : (n mod m) {m≉0} ≈ 0#) → Remainder n m\n 0≉ : (r≉0 : (n mod m) {m≉0} ≉ 0#) → ∣ n mod m ∣ {r≉0} < ∣ m ∣ {m≉0} → Remainder n m\n\nmodule _\n (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ)\n (_div_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (_mod_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C)\n (gcd : Op₂ C)\n where\n\n record IsEuclideanDomain : Set (c ⊔ ℓ) where\n open Modulus 0# ∣_∣ _mod_ public\n field\n isUniqueFactorizationDomain : IsUniqueFactorizationDomain _+_ _*_ -_ 0# 1# gcd\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 div-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≈ x₂ → y₁ ≈ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ div y₁) {y₁≉0} ≈ (x₂ div y₂) {y₂≉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\n open IsUniqueFactorizationDomain isUniqueFactorizationDomain public\n\nrecord IsField (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where\n field\n isEuclideanDomain : IsEuclideanDomain _+_ _*_ -_ 0# 1# (λ _ → 0) _/_ (λ _ _ → 0#) gcd\n\n open IsEuclideanDomain isEuclideanDomain public renaming (div-cong to /-cong)\n open import Relation.Binary.Reasoning.Setoid setoid\n\n m*[n/m]≈n : ∀ n m {m≉0 : m ≉ 0#} → (m * (n / m) {m≉0}) ≈ n\n m*[n/m]≈n n m {m≉0} = begin\n (m * (n / m) {m≉0}) ≈⟨ sym (+-identityʳ (m * (n / m) {m≉0})) ⟩\n ((m * (n / m) {m≉0}) + 0#) ≈⟨ sym (division n m) ⟩\n n ∎\n\n [n/m]*m≈n : ∀ n m {m≉0 : m ≉ 0#} → ((n / m) {m≉0} * m) ≈ n\n [n/m]*m≈n n m {m≉0} = begin\n ((n / m) * m) ≈⟨ *-comm (n / m) m ⟩\n (m * (n / m)) ≈⟨ m*[n/m]≈n n m ⟩\n n ∎\n\n /≉0 : ∀ {c₁ c₂} → c₁ ≉ 0# → (c₂≉0 : c₂ ≉ 0#) → (c₁ / c₂) {c₂≉0} ≉ 0#\n /≉0 {c₁} {c₂} c₁≉0 c₂≉0 c₁/c₂≈0 = 0#≉1# $ *-cancelˡ c₂ c₂≉0 $ begin\n c₂ * 0# ≈⟨ *-congˡ (sym (zeroˡ ((c₂ / c₁) {c₁≉0}))) ⟩\n c₂ * (0# * (c₂ / c₁)) ≈⟨ *-congˡ (*-congʳ (sym (c₁/c₂≈0))) ⟩\n c₂ * ((c₁ / c₂) * (c₂ / c₁)) ≈⟨ sym (*-assoc c₂ (c₁ / c₂) (c₂ / c₁)) ⟩\n (c₂ * (c₁ / c₂)) * (c₂ / c₁) ≈⟨ *-congʳ (m*[n/m]≈n c₁ c₂) ⟩\n c₁ * (c₂ / c₁) ≈⟨ m*[n/m]≈n c₂ c₁ ⟩\n c₂ ≈⟨ sym (*-identityʳ c₂) ⟩\n c₂ * 1# ∎\n\n infixl 7 _/-nonzero_\n _/-nonzero_ : C/0 → C/0 → C/0\n (c₁ , c₁≉0) /-nonzero (c₂ , c₂≉0) = (c₁ / c₂) {c₂≉0} , /≉0 c₁≉0 c₂≉0\n\n infix 8 _⁻¹\n _⁻¹ : ∀ x {x≉0 : x ≉ 0#} → C\n _⁻¹ x {x≉0} = (1# / x) {x≉0}\n\n ⁻¹-inverseʳ : ∀ x {x≉0 : x ≉ 0#} → (x * (x ⁻¹) {x≉0}) ≈ 1#\n ⁻¹-inverseʳ = m*[n/m]≈n 1#\n\n ⁻¹-inverseˡ : ∀ x {x≉0 : x ≉ 0#} → ((x ⁻¹) {x≉0} * x) ≈ 1#\n ⁻¹-inverseˡ = [n/m]*m≈n 1#\n\n x⁻¹≉0 : ∀ x {x≉0 : x ≉ 0#} → (x ⁻¹) {x≉0} ≉ 0#\n x⁻¹≉0 x {x≉0} = /≉0 1#≉0# x≉0\n -- 0#≉1# $ begin\n -- 0# ≈⟨ sym (zeroʳ x) ⟩\n -- x * 0# ≈⟨ *-congˡ (sym x⁻¹≈0) ⟩\n -- x * (x ⁻¹) {x≉0} ≈⟨ ⁻¹-inverseʳ x ⟩\n -- 1# ∎\n\n ⁻¹-cong : ∀ {x y} {x≉0 : x ≉ 0#} {y≉0 : y ≉ 0#} → x ≈ y → (x ⁻¹) {x≉0} ≈ (y ⁻¹) {y≉0}\n ⁻¹-cong {x} {y} {x≉0} {y≉0} x≈y = *-cancelˡ x x≉0 $ begin\n (x * (x ⁻¹)) ≈⟨ ⁻¹-inverseʳ x ⟩\n 1# ≈⟨ sym (⁻¹-inverseʳ y {y≉0}) ⟩\n (y * (y ⁻¹)) ≈⟨ *-congʳ (sym x≈y) ⟩\n (x * (y ⁻¹)) ∎\n\nrecord IsDecField\n (_≈?_ : Decidable _≈_) (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C)\n (_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where\n field\n isField : IsField _+_ _*_ -_ 0# 1# _/_ gcd\n\n open IsField isField public\n\n isDecEquivalence : IsDecEquivalence _≈_\n isDecEquivalence = record\n { isEquivalence = isEquivalence\n ; _≟_ = _≈?_\n }\n\nrecord IsFiniteField\n (_≈?_ : Decidable _≈_) (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C)\n (_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C)\n (cardinality : ℕ) : Set (suc c ⊔ ℓ) where\n field\n isDecField : IsDecField _≈?_ _+_ _*_ -_ 0# 1# _/_ gcd\n C↦Fin[cardinality] : C ⤖ Fin cardinality\n\n open IsDecField isDecField public\n", "meta": {"hexsha": "540820cf21cf6a86b6b2baa400b95275bfc95e7b", "size": 7937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proofs/AKS/Algebra/Structures.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/Algebra/Structures.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/Algebra/Structures.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": 34.0643776824, "max_line_length": 130, "alphanum_fraction": 0.4936373945, "num_tokens": 4168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110540642805, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.5871840051902836}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.types.Truncation\nopen import lib.types.TwoSemiCategory\nopen import lib.two-semi-categories.Functor\nopen import lib.two-semi-categories.FunctorInverse\nopen import lib.two-semi-categories.GroupToCategory\n\nmodule lib.two-semi-categories.FundamentalCategory where\n\nmodule _ {i} (A : Type i) where\n\n 2-type-fundamental-cat : {{_ : has-level 2 A}} → TwoSemiCategory i i\n 2-type-fundamental-cat =\n record\n { El = A\n ; Arr = _==_\n ; Arr-level = λ _ _ → ⟨⟩\n ; two-semi-cat-struct = record\n { comp = _∙_\n ; assoc = ∙-assoc\n ; pentagon-identity = ∙-assoc-pentagon\n }\n }\n\n =ₜ-fundamental-cat : TwoSemiCategory i i\n =ₜ-fundamental-cat =\n record\n { El = Trunc 2 A\n ; Arr = _=ₜ_\n ; Arr-level = =ₜ-level\n ; two-semi-cat-struct = record\n { comp = λ {ta} → _∙ₜ_ {ta = ta}\n ; assoc = λ {ta} → ∙ₜ-assoc {ta = ta}\n ; pentagon-identity = λ {ta} → ∙ₜ-assoc-pentagon {ta = ta}\n }\n }\n\nmodule _ {i} (A : Type i) where\n\n 2-type-to-=ₜ-fundamental-cat :\n TwoSemiFunctor (2-type-fundamental-cat (Trunc 2 A))\n (=ₜ-fundamental-cat A)\n 2-type-to-=ₜ-fundamental-cat =\n record\n { F₀ = idf (Trunc 2 A)\n ; F₁ = λ {ta} {tb} → –> (=ₜ-equiv ta tb)\n ; pres-comp = –>-=ₜ-equiv-pres-∙\n -- TODO: The following line takes a really long time to check.\n -- Can we optimize this somehow?\n ; pres-comp-coh = λ {ta} → –>-=ₜ-equiv-pres-∙-coh {ta = ta}\n }\n\n private\n module FunctorInv =\n FunctorInverse 2-type-to-=ₜ-fundamental-cat\n (idf-is-equiv (Trunc 2 A))\n (λ ta tb → snd (=ₜ-equiv ta tb))\n module InvFunctor = TwoSemiFunctor FunctorInv.functor\n\n =ₜ-to-2-type-fundamental-cat :\n TwoSemiFunctor (=ₜ-fundamental-cat A)\n (2-type-fundamental-cat (Trunc 2 A))\n =ₜ-to-2-type-fundamental-cat =\n record\n { F₀ = idf (Trunc 2 A)\n ; F₁ = λ {ta} {tb} → <– (=ₜ-equiv ta tb)\n ; pres-comp = InvFunctor.pres-comp\n ; pres-comp-coh = InvFunctor.pres-comp-coh\n }\n\n module =ₜ-to-2-type-fundamental-cat = TwoSemiFunctor =ₜ-to-2-type-fundamental-cat\n\n =ₜ-to-2-type-fundamental-cat-pres-comp-β : {a b c : A}\n (p : a == b) (q : b == c)\n → =ₜ-to-2-type-fundamental-cat.pres-comp {x = [ a ]} {y = [ b ]} {z = [ c ]} [ p ]₁ [ q ]₁\n == ap-∙ [_] p q\n =ₜ-to-2-type-fundamental-cat-pres-comp-β {a} p@idp q@idp =\n =ₛ-out (FunctorInv.pres-comp-β {[ a ]} {[ a ]} {[ a ]} [ idp ]₁ [ idp ]₁)\n\nmodule _ {i} (C : Type i) (c₀ : C) {{C-level : has-level 1 C}} where\n\n open import lib.groups.LoopSpace\n\n fundamental-group-to-fundamental-groupoid :\n TwoSemiFunctor (group-to-cat (Ω^S-group 0 ⊙[ C , c₀ ]))\n (2-type-fundamental-cat C {{raise-level 1 C-level}})\n fundamental-group-to-fundamental-groupoid =\n record\n { F₀ = λ _ → c₀\n ; F₁ = λ p → p\n ; pres-comp = λ p q → idp\n ; pres-comp-coh =\n λ p q r → =ₛ-in $\n prop-path (has-level-apply (has-level-apply C-level _ _) _ _) _ _\n }\n", "meta": {"hexsha": "3fe8b4b34ea5120a40ead56259e2319d7df7c83f", "size": 3070, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/two-semi-categories/FundamentalCategory.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/two-semi-categories/FundamentalCategory.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/two-semi-categories/FundamentalCategory.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": 31.3265306122, "max_line_length": 94, "alphanum_fraction": 0.5762214984, "num_tokens": 1075, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278633625322, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.5871768234688783}} {"text": "open import Data.Nat using (ℕ; zero; suc; _+_; _∸_; _≥_; _≤_; z≤n; s≤s)\nopen import Function.Equivalence using (_⇔_)\nopen import Relation.Binary.PropositionalEquality using (→-to-⟶)\n\npostulate\n adjoint : ∀ {x y z} → x + y ≥ z ⇔ x ≥ z ∸ y\n unit : ∀ {x y} → x ≥ (x + y) ∸ y\n apply : ∀ {x y} → (x ∸ y) + y ≥ x\n\n", "meta": {"hexsha": "28bba263ed57852bf4c9366fb9c60331f76fb40d", "size": 311, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Monus.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/Monus.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/Monus.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": 31.1, "max_line_length": 71, "alphanum_fraction": 0.5659163987, "num_tokens": 136, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278664544912, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.5871768138161834}} {"text": "module Sets.ImageSet.Oper where\n\nopen import Data\nopen import Functional\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nimport Lvl\nopen import Sets.ImageSet\nopen import Structure.Function\nopen import Structure.Setoid renaming (_≡_ to _≡ₛ_)\nopen import Type\nopen import Type.Dependent\n\nprivate variable ℓ ℓₑ ℓᵢ ℓᵢ₁ ℓᵢ₂ ℓᵢ₃ ℓᵢₑ ℓ₁ ℓ₂ ℓ₃ : Lvl.Level\nprivate variable T X Y Z : Type{ℓ}\n\nmodule _ where\n open import Data.Boolean\n open import Data.Boolean.Stmt\n open import Data.Either as Either using (_‖_)\n open import Function.Domains\n\n ∅ : ImageSet{ℓᵢ}(T)\n ∅ = intro empty\n\n 𝐔 : ImageSet{Lvl.of(T)}(T)\n 𝐔 = intro id\n\n singleton : T → ImageSet{ℓᵢ}(T)\n singleton(x) = intro{Index = Unit} \\{<> → x}\n\n pair : T → T → ImageSet{ℓᵢ}(T)\n pair x y = intro{Index = Lvl.Up(Bool)} \\{(Lvl.up 𝐹) → x ; (Lvl.up 𝑇) → y}\n\n _∪_ : ImageSet{ℓᵢ₁}(T) → ImageSet{ℓᵢ₂}(T) → ImageSet{ℓᵢ₁ Lvl.⊔ ℓᵢ₂}(T)\n A ∪ B = intro{Index = Index(A) ‖ Index(B)} (Either.map1 (elem(A)) (elem(B)))\n\n ⋃ : ImageSet{ℓᵢ}(ImageSet{ℓᵢ}(T)) → ImageSet{ℓᵢ}(T)\n ⋃ A = intro{Index = Σ(Index(A)) (Index ∘ elem(A))} \\{(intro ia i) → elem(elem(A)(ia))(i)}\n\n indexFilter : (A : ImageSet{ℓᵢ}(T)) → (Index(A) → Stmt{ℓ}) → ImageSet{ℓᵢ Lvl.⊔ ℓ}(T)\n indexFilter A P = intro {Index = Σ(Index(A)) P} (elem(A) ∘ Σ.left)\n\n filter : (T → Stmt{ℓ}) → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ Lvl.⊔ ℓ}(T)\n filter P(A) = indexFilter A (P ∘ elem(A))\n\n indexFilterBool : (A : ImageSet{ℓᵢ}(T)) → (Index(A) → Bool) → ImageSet{ℓᵢ}(T)\n indexFilterBool A f = indexFilter A (IsTrue ∘ f)\n\n filterBool : (T → Bool) → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ}(T)\n filterBool f(A) = indexFilterBool A (f ∘ elem(A))\n\n map : (X → Y) → (ImageSet{ℓᵢ}(X) → ImageSet{ℓᵢ}(Y))\n map f(A) = intro{Index = Index(A)} (f ∘ elem(A))\n\n unapply : (X → Y) → ⦃ _ : Equiv{ℓₑ}(Y)⦄ → (Y → ImageSet{Lvl.of(X) Lvl.⊔ ℓₑ}(X))\n unapply f(y) = intro{Index = ∃(x ↦ f(x) ≡ₛ y)} [∃]-witness\n\n -- unmap : (X → Y) → ⦃ _ : Equiv{ℓₑ}(Y)⦄ → (ImageSet{{!Lvl.of(T) Lvl.⊔ ℓₑ!}}(Y) → ImageSet{Lvl.of(T) Lvl.⊔ ℓₑ}(X))\n -- unmap f(B) = intro{Index = ∃(x ↦ f(x) ∈ B)} [∃]-witness\n\n ℘ : ImageSet{ℓᵢ}(T) → ImageSet{Lvl.𝐒(ℓᵢ)}(ImageSet{ℓᵢ}(T))\n ℘(A) = intro{Index = Index(A) → Stmt} (indexFilter A)\n\n _∩_ : ⦃ _ : Equiv{ℓᵢ}(T) ⦄ → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ}(T)\n A ∩ B = indexFilter(A) (iA ↦ elem(A) iA ∈ B)\n\n ⋂ : ⦃ _ : Equiv{ℓᵢ}(T) ⦄ → ImageSet{Lvl.of(T)}(ImageSet{Lvl.of(T)}(T)) → ImageSet{ℓᵢ Lvl.⊔ Lvl.of(T)}(T)\n -- ⋂ As = intro{Index = Σ((iAs : Index(As)) → Index(elem(As) iAs)) (f ↦ (∀{iAs₁ iAs₂} → (elem(elem(As) iAs₁)(f iAs₁) ≡ₛ elem(elem(As) iAs₂)(f iAs₂))))} {!!} (TODO: I think this definition only works with excluded middle because one must determine if an A from AS is empty or not and if it is not, then one can apply its index to the function in the Σ)\n ⋂ As = indexFilter(⋃ As) (iUAs ↦ ∃{Obj = (iAs : Index(As)) → Index(elem(As) iAs)}(f ↦ ∀{iAs} → (elem(⋃ As) iUAs ≡ₛ elem(elem(As) iAs) (f iAs))))\n -- ⋂ As = indexFilter(⋃ As) (iUAs ↦ ∀{iAs} → (elem(⋃ As) iUAs ∈ elem(As) iAs))\n\n {-\nmodule _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where\n open import Data.Boolean\n open import Data.Either as Either using (_‖_)\n open import Data.Tuple as Tuple using (_⨯_ ; _,_)\n import Structure.Container.SetLike as Sets\n open import Structure.Function.Domain\n open import Structure.Operator.Properties\n open import Structure.Relator\n open import Structure.Relator.Properties\n open import Syntax.Transitivity\n\n private variable A B C : ImageSet{ℓₑ}(T)\n private variable x y a b : T\n\n [∈]-of-elem : ∀{ia : Index(A)} → (elem(A)(ia) ∈ A)\n ∃.witness ([∈]-of-elem {ia = ia}) = ia\n ∃.proof [∈]-of-elem = reflexivity(_≡ₛ_)\n\n instance\n ∅-membership : Sets.EmptySet(_∈_ {T = T}{ℓ})\n Sets.EmptySet.∅ ∅-membership = ∅\n Sets.EmptySet.membership ∅-membership ()\n\n instance\n 𝐔-membership : Sets.UniversalSet(_∈_ {T = T})\n Sets.UniversalSet.𝐔 𝐔-membership = 𝐔\n Sets.UniversalSet.membership 𝐔-membership {x = x} = [∃]-intro x ⦃ reflexivity(_≡ₛ_) ⦄\n\n instance\n singleton-membership : Sets.SingletonSet(_∈_ {T = T}{ℓ})\n Sets.SingletonSet.singleton singleton-membership = singleton\n Sets.SingletonSet.membership singleton-membership = proof where\n proof : (x ∈ singleton{ℓᵢ = ℓᵢ}(a)) ↔ (x ≡ₛ a)\n Tuple.left proof xin = [∃]-intro <> ⦃ xin ⦄\n Tuple.right proof ([∃]-intro i ⦃ eq ⦄ ) = eq\n\n instance\n pair-membership : Sets.PairSet(_∈_ {T = T}{ℓ})\n Sets.PairSet.pair pair-membership = pair\n Sets.PairSet.membership pair-membership = proof where\n proof : (x ∈ pair a b) ↔ (x ≡ₛ a)∨(x ≡ₛ b)\n Tuple.left proof ([∨]-introₗ p) = [∃]-intro (Lvl.up 𝐹) ⦃ p ⦄\n Tuple.left proof ([∨]-introᵣ p) = [∃]-intro (Lvl.up 𝑇) ⦃ p ⦄\n Tuple.right proof ([∃]-intro (Lvl.up 𝐹) ⦃ eq ⦄) = [∨]-introₗ eq\n Tuple.right proof ([∃]-intro (Lvl.up 𝑇) ⦃ eq ⦄) = [∨]-introᵣ eq\n\n instance\n [∪]-membership : Sets.UnionOperator(_∈_ {T = T})\n Sets.UnionOperator._∪_ [∪]-membership = _∪_\n Sets.UnionOperator.membership [∪]-membership = proof where\n proof : (x ∈ (A ∪ B)) ↔ (x ∈ A)∨(x ∈ B)\n Tuple.left proof ([∨]-introₗ ([∃]-intro ia)) = [∃]-intro (Either.Left ia)\n Tuple.left proof ([∨]-introᵣ ([∃]-intro ib)) = [∃]-intro (Either.Right ib)\n Tuple.right proof ([∃]-intro ([∨]-introₗ ia)) = [∨]-introₗ ([∃]-intro ia)\n Tuple.right proof ([∃]-intro ([∨]-introᵣ ib)) = [∨]-introᵣ ([∃]-intro ib)\n\n instance\n [∩]-membership : Sets.IntersectionOperator(_∈_ {T = T})\n Sets.IntersectionOperator._∩_ [∩]-membership = _∩_\n Sets.IntersectionOperator.membership [∩]-membership = proof where\n proof : (x ∈ (A ∩ B)) ↔ (x ∈ A)∧(x ∈ B)\n _⨯_.left proof ([↔]-intro ([∃]-intro iA ⦃ pA ⦄) ([∃]-intro iB ⦃ pB ⦄)) = [∃]-intro (intro iA ([∃]-intro iB ⦃ symmetry(_≡ₛ_) pA 🝖 pB ⦄))\n _⨯_.right proof ([∃]-intro (intro iA ([∃]-intro iB ⦃ pAB ⦄)) ⦃ pxAB ⦄) = [∧]-intro ([∃]-intro iA) ([∃]-intro iB ⦃ pxAB 🝖 pAB ⦄)\n\n instance\n map-membership : Sets.MapFunction(_∈_ {T = T})(_∈_ {T = T})\n Sets.MapFunction.map map-membership f = map f\n Sets.MapFunction.membership map-membership {f = f} ⦃ function ⦄ = proof where\n proof : (y ∈ map f(A)) ↔ ∃(x ↦ (x ∈ A) ∧ (f(x) ≡ₛ y))\n ∃.witness (Tuple.left (proof) ([∃]-intro x ⦃ [∧]-intro xA fxy ⦄)) = [∃]-witness xA\n ∃.proof (Tuple.left (proof {y = y} {A = A}) ([∃]-intro x ⦃ [∧]-intro xA fxy ⦄)) =\n y 🝖[ _≡ₛ_ ]-[ fxy ]-sym\n f(x) 🝖[ _≡ₛ_ ]-[ congruence₁(f) ⦃ function ⦄ ([∃]-proof xA) ]\n f(elem(A) ([∃]-witness xA)) 🝖[ _≡ₛ_ ]-[]\n elem (map f(A)) ([∃]-witness xA) 🝖[ _≡ₛ_ ]-end\n ∃.witness (Tuple.right (proof {A = A}) ([∃]-intro iA)) = elem(A) iA\n ∃.proof (Tuple.right proof ([∃]-intro iA ⦃ p ⦄)) = [∧]-intro ([∈]-of-elem {ia = iA}) (symmetry(_≡ₛ_) p)\n\n indexFilter-membership : ∀{P : Index(A) → Stmt{ℓ}} → (x ∈ indexFilter A P) ↔ ∃(i ↦ (x ≡ₛ elem(A) i) ∧ P(i))\n _⨯_.left indexFilter-membership ([∃]-intro iA ⦃ [∧]-intro xe p ⦄) = [∃]-intro (intro iA p) ⦃ xe ⦄\n _⨯_.right indexFilter-membership ([∃]-intro (intro iA p) ⦃ xe ⦄) = [∃]-intro iA ⦃ [∧]-intro xe p ⦄\n\n indexFilter-subset : ∀{P : Index(A) → Stmt{ℓₑ}} → (indexFilter{ℓₑ} A P ⊆ A)\n indexFilter-subset = [∃]-map-proof [∧]-elimₗ ∘ [↔]-to-[→] indexFilter-membership\n\n indexFilter-elem-membershipₗ : ∀{P : Index(A) → Stmt{ℓ}}{i : Index(A)} → (elem(A)(i) ∈ indexFilter A P) ← P(i)\n indexFilter-elem-membershipₗ {i = i} pi = [∃]-intro (intro i pi) ⦃ reflexivity _ ⦄\n\n indexFilter-elem-membershipᵣ : ⦃ _ : Equiv{ℓₑ}(Index(A)) ⦄ ⦃ _ : Injective(elem A) ⦄ → ∀{P : Index(A) → Stmt{ℓ}} ⦃ _ : UnaryRelator(P) ⦄{i : Index(A)} → (elem(A)(i) ∈ indexFilter A P) → P(i)\n indexFilter-elem-membershipᵣ {A = A}{P = P} {i = i} ([∃]-intro (intro iA PiA) ⦃ p ⦄) = substitute₁ₗ(P) (injective(elem A) p) PiA\n\n instance\n filter-membership : Sets.FilterFunction(_∈_ {T = T})\n Sets.FilterFunction.filter filter-membership f = filter{ℓ = ℓₑ} f\n Sets.FilterFunction.membership filter-membership {P = P} = proof where\n proof : (x ∈ filter P(A)) ↔ ((x ∈ A) ∧ P(x))\n Tuple.left proof ([∧]-intro ([∃]-intro i ⦃ p ⦄) pb) = [∃]-intro (intro i (substitute₁(P) p pb)) ⦃ p ⦄\n Tuple.left (Tuple.right proof ([∃]-intro (intro iA PiA))) = [∃]-intro iA\n Tuple.right (Tuple.right proof ([∃]-intro (intro iA PiA) ⦃ pp ⦄)) = substitute₁ₗ(P) pp PiA\n\n filter-subset : ∀{P : T → Stmt{ℓₑ}} → (filter P(A) ⊆ A)\n filter-subset ([∃]-intro (intro i p) ⦃ xf ⦄) = [∃]-intro i ⦃ xf ⦄\n\n instance\n postulate [∩]-commutativity : Commutativity(_∩_ {T = T})\n\n -- TODO: These should come from Structure.Container.SetLike, which in turn should come from Structure.Operator.Lattice, which in turn should come from Structure.Relator.Ordering.Lattice\n postulate [∩]-subset-of-right : (A ⊆ B) → (A ∩ B ≡ₛ B)\n postulate [∩]-subset-of-left : (B ⊆ A) → (A ∩ B ≡ₛ A)\n postulate [∩]-subsetₗ : (A ∩ B) ⊆ A\n [∩]-subsetᵣ : (A ∩ B) ⊆ B\n [∩]-subsetᵣ {A} {B} {x} xAB = indexFilter-subset ([↔]-to-[→] (commutativity(_∩_) ⦃ [∩]-commutativity ⦄ {A} {B} {x}) xAB)\n\n instance\n ℘-membership : Sets.PowerFunction(_∈_)(_∈_)\n Sets.PowerFunction.℘ ℘-membership = ℘\n Sets.PowerFunction.membership ℘-membership = [↔]-intro l r where\n l : (B ∈ ℘(A)) ← (B ⊆ A)\n ∃.witness (l {B} {A} BA) iA = elem(A) iA ∈ B\n _⨯_.left (∃.proof (l {B}{A} BA) {x}) a = apply a $\n A ∩ B 🝖[ _⊆_ ]-[ [∩]-subsetᵣ ]\n B 🝖[ _⊆_ ]-end\n _⨯_.right (∃.proof (l {B}{A} BA) {x}) b = apply b $\n B 🝖[ _⊆_ ]-[ BA ]\n A 🝖[ _⊆_ ]-[ sub₂(_≡_)(_⊇_) ([∩]-subset-of-left BA) ]\n A ∩ B 🝖[ _⊆_ ]-end\n\n r : (B ∈ ℘(A)) → (B ⊆ A)\n r ([∃]-intro _ ⦃ BA ⦄) xB with [↔]-to-[→] BA xB\n ... | [∃]-intro (intro iA _) ⦃ xe ⦄ = [∃]-intro iA ⦃ xe ⦄\n-}\n", "meta": {"hexsha": "daaa406e1383befcf7e9065abcd1b9325b813f59", "size": 9874, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sets/ImageSet/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/ImageSet/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/ImageSet/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": 47.932038835, "max_line_length": 353, "alphanum_fraction": 0.567044764, "num_tokens": 4284, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.5871670892513509}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Homotopy.WedgeConnectivity where\n\nopen import Cubical.Foundations.Everything\nopen import Cubical.Data.HomotopyGroup\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Sigma\nopen import Cubical.HITs.Nullification\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 -- TODO: left (pt A) ⁻¹ ∙ right (pt B) ≡ p\n", "meta": {"hexsha": "a39faec633900c6f4ea475f0c81df6db48dd2d0f", "size": 1600, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Homotopy/WedgeConnectivity.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/WedgeConnectivity.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/Homotopy/WedgeConnectivity.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": 31.3725490196, "max_line_length": 63, "alphanum_fraction": 0.56875, "num_tokens": 605, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267694452331, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.5871223865555152}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import lib.Basics\nopen import lib.Relation\nopen import lib.NType2\nopen import lib.types.Pi\n\nmodule lib.types.SetQuotient {i} {A : Type i} {j} where\n\npostulate -- HIT\n SetQuot : (R : Rel A j) → Type (lmax i j)\n\nmodule _ {R : Rel A j} where\n\n postulate -- HIT\n q[_] : (a : A) → SetQuot R\n quot-rel : {a₁ a₂ : A} → R a₁ a₂ → q[ a₁ ] == q[ a₂ ]\n SetQuot-level : is-set (SetQuot R)\n\n SetQuot-is-set = SetQuot-level\n\n module SetQuotElim {k} {P : SetQuot R → Type k}\n (p : (x : SetQuot R) → is-set (P x)) (q[_]* : (a : A) → P q[ a ])\n (rel* : ∀ {a₁ a₂} (r : R a₁ a₂) → q[ a₁ ]* == q[ a₂ ]* [ P ↓ quot-rel r ]) where\n\n postulate -- HIT\n f : Π (SetQuot R) P\n q[_]-β : (a : A) → f q[ a ] ↦ q[ a ]*\n {-# REWRITE q[_]-β #-}\n\n postulate -- HIT\n quot-rel-β : ∀ {a₁ a₂} (r : R a₁ a₂) → apd f (quot-rel r) == rel* r\n\n open SetQuotElim public using () renaming (f to SetQuot-elim)\n\n module SetQuotRec {k} {B : Type k} (p : is-set B)\n (q[_]* : A → B) (rel* : ∀ {a₁ a₂} (r : R a₁ a₂) → q[ a₁ ]* == q[ a₂ ]*) where\n\n private\n module M = SetQuotElim (λ x → p) q[_]* (λ {a₁ a₂} r → ↓-cst-in (rel* r))\n\n f : SetQuot R → B\n f = M.f\n\n open SetQuotRec public using () renaming (f to SetQuot-rec)\n\n -- If [R] is an equivalence relation, then [quot-rel] is an equivalence.\n\nmodule _ {R : Rel A j}\n (R-is-prop : ∀ {a b} → is-prop (R a b))\n (R-is-refl : is-refl R) (R-is-sym : is-sym R)\n (R-is-trans : is-trans R) where\n\n private\n Q : Type (lmax i j)\n Q = SetQuot R\n\n R'-over-quot : Q → Q → hProp j\n R'-over-quot = SetQuot-rec (→-is-set $ hProp-is-set j)\n (λ a → SetQuot-rec (hProp-is-set j)\n (λ b → R a b , R-is-prop)\n (nType=-out ∘ lemma-a))\n (λ ra₁a₂ → λ= $ SetQuot-elim\n (λ _ → raise-level -1 $ hProp-is-set j _ _)\n (λ _ → nType=-out $ lemma-b ra₁a₂)\n (λ _ → prop-has-all-paths-↓ $ hProp-is-set j _ _))\n where\n abstract\n lemma-a : ∀ {a b₁ b₂} → R b₁ b₂ → R a b₁ == R a b₂\n lemma-a rb₁b₂ = ua $ equiv\n (λ rab₁ → R-is-trans rab₁ rb₁b₂)\n (λ rab₂ → R-is-trans rab₂ (R-is-sym rb₁b₂))\n (λ _ → prop-has-all-paths R-is-prop _ _)\n (λ _ → prop-has-all-paths R-is-prop _ _)\n\n lemma-b : ∀ {a₁ a₂ b} → R a₁ a₂ → R a₁ b == R a₂ b\n lemma-b ra₁a₂ = ua $ equiv\n (λ ra₁b → R-is-trans (R-is-sym ra₁a₂) ra₁b)\n (λ ra₂b → R-is-trans ra₁a₂ ra₂b)\n (λ _ → prop-has-all-paths R-is-prop _ _)\n (λ _ → prop-has-all-paths R-is-prop _ _)\n\n R-over-quot : Q → Q → Type j\n R-over-quot q₁ q₂ = fst (R'-over-quot q₁ q₂)\n\n abstract\n R-over-quot-is-prop : {q₁ q₂ : Q} → is-prop (R-over-quot q₁ q₂)\n R-over-quot-is-prop {q₁} {q₂} = snd (R'-over-quot q₁ q₂)\n\n R-over-quot-is-refl : (q : Q) → R-over-quot q q\n R-over-quot-is-refl = SetQuot-elim\n (λ q → raise-level -1 (R-over-quot-is-prop {q} {q}))\n (λ a → R-is-refl a)\n (λ _ → prop-has-all-paths-↓ R-is-prop)\n\n path-to-R-over-quot : {q₁ q₂ : Q} → q₁ == q₂ → R-over-quot q₁ q₂\n path-to-R-over-quot {q} idp = R-over-quot-is-refl q\n\n quot-rel-equiv : ∀ {a₁ a₂ : A} → R a₁ a₂ ≃ (q[ a₁ ] == q[ a₂ ])\n quot-rel-equiv {a₁} {a₂} = equiv\n quot-rel (path-to-R-over-quot {q[ a₁ ]} {q[ a₂ ]})\n (λ _ → prop-has-all-paths (SetQuot-is-set _ _) _ _)\n (λ _ → prop-has-all-paths R-is-prop _ _)\n", "meta": {"hexsha": "501a36ee8612845a30f0dc1f5596a957046d874c", "size": 3442, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/SetQuotient.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/SetQuotient.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/SetQuotient.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.0961538462, "max_line_length": 84, "alphanum_fraction": 0.5185938408, "num_tokens": 1360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511579973932, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.5870706463857418}} {"text": "open import Agda.Builtin.Equality\n\n_∘_ : ∀ {a b c}\n {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} →\n (f : ∀ {x} (y : B x) → C y) →\n (g : (x : A) → B x) →\n ((x : A) → C (g x))\nf ∘ g = λ x → f (g x)\n\npostulate\n A : Set\n B : A → Set\n C : {x : A} → B x → Set\n f : ∀ {x : A} (y : B x) → C y\n g : (x : A) → B x\n\ntest : (f ∘ g) ≡ (f ∘ g)\ntest = {!!}\n\n-- WAS: goal displayed as ((λ {x} -> f) ∘ g) ≡ ((λ {x} -> f) ∘ g)\n-- WANT: no spurious hidden lambda i.e. (f ∘ g) ≡ (f ∘ g)\n", "meta": {"hexsha": "8363390bfd6296596b85eeac140ab8c5bbcd9f11", "size": 511, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue3238.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/Issue3238.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/Issue3238.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.2272727273, "max_line_length": 65, "alphanum_fraction": 0.3659491194, "num_tokens": 249, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.855851143290548, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.5870706362975893}} {"text": "-- Jesper, 2015-12-18: the helper function shouldn't be accepted, since it\n-- matches on a heterogeneous equality and the equation between the types\n-- Box A and Box B cannot be solved without injective type constructors.\n\ndata Box (A : Set) : Set where\n [_] : A → Box A\n\ndata _≡_ (A : Set) : Set → Set₁ where\n refl : A ≡ A\n\ndata _≅_ {A : Set₁} (x : A) : {B : Set₁} → B → Set₂ where\n refl : x ≅ x\n\ndata C : Set → Set₁ where\n c₁ c₂ : (A : Set) → C (Box A)\n\ndata D : {A : Set} → C A → Set₂ where\n d₁ : (A : Set) → D (c₁ A)\n d₂ : (A : Set) → D (c₂ A)\n\nD-elim-c₁-helper :\n (P : {A B : Set} {c : C A} →\n D c → A ≡ Box B → c ≅ c₁ B → Set₂) →\n ((A : Set) → P (d₁ A) refl refl) →\n {A B : Set} {c : C A}\n (x : D c) (eq₂ : c ≅ c₁ B) (eq₁ : A ≡ Box B) → P x eq₁ eq₂\nD-elim-c₁-helper P p (d₂ A) () _\nD-elim-c₁-helper P p (d₁ A) refl refl = p A\n", "meta": {"hexsha": "1462b56fae015a50ba80a74964ec63d986b5fa66", "size": 850, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue1435-helper.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/Issue1435-helper.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/Issue1435-helper.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": 29.3103448276, "max_line_length": 74, "alphanum_fraction": 0.5458823529, "num_tokens": 357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511506439707, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.5870706248577163}} {"text": "\nmodule Foundation.Primitive where\n\nopen import Agda.Primitive\n\ninfix -65536 ℞_\n℞_ : ∀ ℓ → Set _\n℞_ ℓ = Set ℓ\n\n⟰ : Level → Level\n⟰ = lsuc\n\ninfix -65536 ℞₁_\n℞₁_ : ∀ ℓ → Set _\n℞₁_ ℓ = ℞ ⟰ ℓ\n\n𝟘 : Level\n𝟘 = lzero\n\nopen import Agda.Primitive using (_⊔_) public\n", "meta": {"hexsha": "319b5160941f08a0daf129896412ac392349b0a5", "size": 256, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-1/Foundation/Primitive.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/Primitive.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/Primitive.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": 12.1904761905, "max_line_length": 45, "alphanum_fraction": 0.62890625, "num_tokens": 116, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511469672594, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.5870706223356783}} {"text": "import Lvl\nopen import Type\n\nmodule Structure.Logic.Constructive.Predicate\n {ℓₗ} {Formula : Type{ℓₗ}}\n {ℓₘₗ} (Proof : Formula → Type{ℓₘₗ})\n {ℓₚ} {Predicate : Type{ℓₚ}}\n {ℓₒ} {Domain : Type{ℓₒ}}\n (_$_ : Predicate → Domain → Formula)\n where\n\nimport Logic.Predicate as Meta\nimport Structure.Logic.Constructive.Propositional as Propositional\nopen import Type.Properties.Inhabited using (◊)\n\nprivate variable P : Predicate\nprivate variable X Y Q : Formula\nprivate variable x y z : Domain\n\n-- Rules of universal quantification (for all).\nrecord Universal(∀ₗ : Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where\n field\n intro : (∀{x} → Proof(P $ x)) → Proof(∀ₗ P)\n elim : Proof(∀ₗ P) → ∀{x} → Proof(P $ x)\n∀ₗ = \\ ⦃(Meta.[∃]-intro ▫) : Meta.∃(Universal)⦄ → ▫\nmodule ∀ₗ {▫} ⦃ p ⦄ = Universal {▫} p\n\n-- Rules of existential quantification (exists).\nrecord Existential(∃ : Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where\n field\n intro : Proof(P $ x) → Proof(∃ P)\n elim : (∀{x} → Proof(P $ x) → Proof(Q)) → (Proof(∃ P) → Proof(Q))\n∃ = \\ ⦃(Meta.[∃]-intro ▫) : Meta.∃(Existential)⦄ → ▫\nmodule ∃ {▫} ⦃ p ⦄ = Existential {▫} p\n\nrecord ExistentialWitness(∃ : Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where\n field\n witness : Proof(∃ P) → Domain\n proof : (p : Proof(∃ P)) → Proof(P $ witness p)\n\nNonEmptyDomain = ◊ Domain\n\nrecord Equality(_≡_ : Domain → Domain → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Domain)} where\n field\n reflexivity : Proof(x ≡ x)\n substitute : (P : Domain → Formula) → Proof(x ≡ y) → (Proof(P(x)) → Proof(P(y)))\n\nrecord Logic : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where\n field\n ⦃ propositional ⦄ : Propositional.Logic(Proof)\n ⦃ universal ⦄ : Meta.∃(Universal)\n ⦃ existential ⦄ : Meta.∃(Existential)\n", "meta": {"hexsha": "ffae660923f91cdb35493798d7f41f6b91c45396", "size": 2025, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Logic/Constructive/Predicate.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/Logic/Constructive/Predicate.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/Logic/Constructive/Predicate.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.2075471698, "max_line_length": 135, "alphanum_fraction": 0.6316049383, "num_tokens": 815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.855851143290548, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5870706198136402}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some algebraic structures defined over some other structure\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel; Setoid; IsEquivalence)\n\nmodule Algebra.Module.Structures where\n\nopen import Algebra.Bundles\nopen import Algebra.Core\nimport Algebra.Definitions as Defs\nopen import Algebra.Module.Definitions\nopen import Algebra.Structures\nopen import Data.Product using (_,_; proj₁; proj₂)\nopen import Level using (Level; _⊔_)\n\nprivate\n variable\n m ℓm r ℓr s ℓs : Level\n M : Set m\n\nmodule _ (semiring : Semiring r ℓr) (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M)\n where\n\n open Semiring semiring renaming (Carrier to R)\n\n record IsPreleftSemimodule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n open LeftDefs R ≈ᴹ\n field\n *ₗ-cong : Congruent _≈_ *ₗ\n *ₗ-zeroˡ : LeftZero 0# 0ᴹ *ₗ\n *ₗ-distribʳ : *ₗ DistributesOverʳ _+_ ⟶ +ᴹ\n *ₗ-identityˡ : LeftIdentity 1# *ₗ\n *ₗ-assoc : Associative _*_ *ₗ\n *ₗ-zeroʳ : RightZero 0ᴹ *ₗ\n *ₗ-distribˡ : *ₗ DistributesOverˡ +ᴹ\n\n record IsLeftSemimodule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n open LeftDefs R ≈ᴹ\n field\n +ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ\n isPreleftSemimodule : IsPreleftSemimodule *ₗ\n\n open IsPreleftSemimodule isPreleftSemimodule public\n\n open IsCommutativeMonoid +ᴹ-isCommutativeMonoid public\n using () renaming\n ( assoc to +ᴹ-assoc\n ; comm to +ᴹ-comm\n ; identity to +ᴹ-identity\n ; identityʳ to +ᴹ-identityʳ\n ; identityˡ to +ᴹ-identityˡ\n ; isEquivalence to ≈ᴹ-isEquivalence\n ; isMagma to +ᴹ-isMagma\n ; isMonoid to +ᴹ-isMonoid\n ; isPartialEquivalence to ≈ᴹ-isPartialEquivalence\n ; isSemigroup to +ᴹ-isSemigroup\n ; refl to ≈ᴹ-refl\n ; reflexive to ≈ᴹ-reflexive\n ; setoid to ≈ᴹ-setoid\n ; sym to ≈ᴹ-sym\n ; trans to ≈ᴹ-trans\n ; ∙-cong to +ᴹ-cong\n ; ∙-congʳ to +ᴹ-congʳ\n ; ∙-congˡ to +ᴹ-congˡ\n )\n\n *ₗ-congˡ : LeftCongruent *ₗ\n *ₗ-congˡ mm = *ₗ-cong refl mm\n\n *ₗ-congʳ : RightCongruent _≈_ *ₗ\n *ₗ-congʳ xx = *ₗ-cong xx ≈ᴹ-refl\n\n record IsPrerightSemimodule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n open RightDefs R ≈ᴹ\n field\n *ᵣ-cong : Congruent _≈_ *ᵣ\n *ᵣ-zeroʳ : RightZero 0# 0ᴹ *ᵣ\n *ᵣ-distribˡ : *ᵣ DistributesOverˡ _+_ ⟶ +ᴹ\n *ᵣ-identityʳ : RightIdentity 1# *ᵣ\n *ᵣ-assoc : Associative _*_ *ᵣ\n *ᵣ-zeroˡ : LeftZero 0ᴹ *ᵣ\n *ᵣ-distribʳ : *ᵣ DistributesOverʳ +ᴹ\n\n record IsRightSemimodule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n open RightDefs R ≈ᴹ\n field\n +ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ\n isPrerightSemimodule : IsPrerightSemimodule *ᵣ\n\n open IsPrerightSemimodule isPrerightSemimodule public\n\n open IsCommutativeMonoid +ᴹ-isCommutativeMonoid public\n using () renaming\n ( assoc to +ᴹ-assoc\n ; comm to +ᴹ-comm\n ; identity to +ᴹ-identity\n ; identityʳ to +ᴹ-identityʳ\n ; identityˡ to +ᴹ-identityˡ\n ; isEquivalence to ≈ᴹ-isEquivalence\n ; isMagma to +ᴹ-isMagma\n ; isMonoid to +ᴹ-isMonoid\n ; isPartialEquivalence to ≈ᴹ-isPartialEquivalence\n ; isSemigroup to +ᴹ-isSemigroup\n ; refl to ≈ᴹ-refl\n ; reflexive to ≈ᴹ-reflexive\n ; setoid to ≈ᴹ-setoid\n ; sym to ≈ᴹ-sym\n ; trans to ≈ᴹ-trans\n ; ∙-cong to +ᴹ-cong\n ; ∙-congʳ to +ᴹ-congʳ\n ; ∙-congˡ to +ᴹ-congˡ\n )\n\n *ᵣ-congˡ : LeftCongruent _≈_ *ᵣ\n *ᵣ-congˡ xx = *ᵣ-cong ≈ᴹ-refl xx\n\n *ᵣ-congʳ : RightCongruent *ᵣ\n *ᵣ-congʳ mm = *ᵣ-cong mm refl\n\nmodule _ (R-semiring : Semiring r ℓr) (S-semiring : Semiring s ℓs)\n (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M)\n where\n\n open Semiring R-semiring using () renaming (Carrier to R)\n open Semiring S-semiring using () renaming (Carrier to S)\n\n record IsBisemimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ S M)\n : Set (r ⊔ s ⊔ m ⊔ ℓr ⊔ ℓs ⊔ ℓm) where\n open BiDefs R S ≈ᴹ\n field\n +ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ\n isPreleftSemimodule : IsPreleftSemimodule R-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ\n isPrerightSemimodule : IsPrerightSemimodule S-semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ\n *ₗ-*ᵣ-assoc : Associative *ₗ *ᵣ\n\n isLeftSemimodule : IsLeftSemimodule R-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ\n isLeftSemimodule = record\n { +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid\n ; isPreleftSemimodule = isPreleftSemimodule\n }\n\n isRightSemimodule : IsRightSemimodule S-semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ\n isRightSemimodule = record\n { +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid\n ; isPrerightSemimodule = isPrerightSemimodule\n }\n\n open IsLeftSemimodule isLeftSemimodule public\n hiding (+ᴹ-isCommutativeMonoid; isPreleftSemimodule)\n open IsPrerightSemimodule isPrerightSemimodule public\n open IsRightSemimodule isRightSemimodule public\n using (*ᵣ-congˡ; *ᵣ-congʳ)\n\nmodule _ (commutativeSemiring : CommutativeSemiring r ℓr)\n (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M)\n where\n\n open CommutativeSemiring commutativeSemiring renaming (Carrier to R)\n\n -- An R-semimodule is an R-R-bisemimodule where R is commutative.\n -- This means that *ₗ and *ᵣ coincide up to mathematical equality, though it\n -- may be that they do not coincide up to definitional equality.\n\n record IsSemimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ R M)\n : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n field\n isBisemimodule : IsBisemimodule semiring semiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ\n\n open IsBisemimodule isBisemimodule public\n\n\nmodule _ (ring : Ring r ℓr)\n (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M)\n where\n\n open Ring ring renaming (Carrier to R)\n\n record IsLeftModule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n open Defs ≈ᴹ\n field\n isLeftSemimodule : IsLeftSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ₗ\n -ᴹ‿cong : Congruent₁ -ᴹ\n -ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ\n\n open IsLeftSemimodule isLeftSemimodule public\n\n +ᴹ-isAbelianGroup : IsAbelianGroup ≈ᴹ +ᴹ 0ᴹ -ᴹ\n +ᴹ-isAbelianGroup = record\n { isGroup = record\n { isMonoid = +ᴹ-isMonoid\n ; inverse = -ᴹ‿inverse\n ; ⁻¹-cong = -ᴹ‿cong\n }\n ; comm = +ᴹ-comm\n }\n\n open IsAbelianGroup +ᴹ-isAbelianGroup public\n using () renaming\n ( isGroup to +ᴹ-isGroup\n ; inverseˡ to -ᴹ‿inverseˡ\n ; inverseʳ to -ᴹ‿inverseʳ\n ; uniqueˡ-⁻¹ to uniqueˡ‿-ᴹ\n ; uniqueʳ-⁻¹ to uniqueʳ‿-ᴹ\n )\n\n record IsRightModule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n open Defs ≈ᴹ\n field\n isRightSemimodule : IsRightSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ\n -ᴹ‿cong : Congruent₁ -ᴹ\n -ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ\n\n open IsRightSemimodule isRightSemimodule public\n\n +ᴹ-isAbelianGroup : IsAbelianGroup ≈ᴹ +ᴹ 0ᴹ -ᴹ\n +ᴹ-isAbelianGroup = record\n { isGroup = record\n { isMonoid = +ᴹ-isMonoid\n ; inverse = -ᴹ‿inverse\n ; ⁻¹-cong = -ᴹ‿cong\n }\n ; comm = +ᴹ-comm\n }\n\n open IsAbelianGroup +ᴹ-isAbelianGroup public\n using () renaming\n ( isGroup to +ᴹ-isGroup\n ; inverseˡ to -ᴹ‿inverseˡ\n ; inverseʳ to -ᴹ‿inverseʳ\n ; uniqueˡ-⁻¹ to uniqueˡ‿-ᴹ\n ; uniqueʳ-⁻¹ to uniqueʳ‿-ᴹ\n )\n\nmodule _ (R-ring : Ring r ℓr) (S-ring : Ring s ℓs)\n (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M)\n where\n\n open Ring R-ring renaming (Carrier to R; semiring to R-semiring)\n open Ring S-ring renaming (Carrier to S; semiring to S-semiring)\n\n record IsBimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ S M)\n : Set (r ⊔ s ⊔ m ⊔ ℓr ⊔ ℓs ⊔ ℓm) where\n open Defs ≈ᴹ\n field\n isBisemimodule : IsBisemimodule R-semiring S-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ\n -ᴹ‿cong : Congruent₁ -ᴹ\n -ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ\n\n open IsBisemimodule isBisemimodule public\n\n isLeftModule : IsLeftModule R-ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ\n isLeftModule = record\n { isLeftSemimodule = isLeftSemimodule\n ; -ᴹ‿cong = -ᴹ‿cong\n ; -ᴹ‿inverse = -ᴹ‿inverse\n }\n\n open IsLeftModule isLeftModule public\n using ( +ᴹ-isAbelianGroup; +ᴹ-isGroup; -ᴹ‿inverseˡ; -ᴹ‿inverseʳ\n ; uniqueˡ‿-ᴹ; uniqueʳ‿-ᴹ)\n\n isRightModule : IsRightModule S-ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ᵣ\n isRightModule = record\n { isRightSemimodule = isRightSemimodule\n ; -ᴹ‿cong = -ᴹ‿cong\n ; -ᴹ‿inverse = -ᴹ‿inverse\n }\n\nmodule _ (commutativeRing : CommutativeRing r ℓr)\n (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M)\n where\n\n open CommutativeRing commutativeRing renaming (Carrier to R)\n\n -- An R-module is an R-R-bimodule where R is commutative.\n -- This means that *ₗ and *ᵣ coincide up to mathematical equality, though it\n -- may be that they do not coincide up to definitional equality.\n\n record IsModule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where\n field\n isBimodule : IsBimodule ring ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ *ᵣ\n\n open IsBimodule isBimodule public\n\n isSemimodule : IsSemimodule commutativeSemiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ\n isSemimodule = record { isBisemimodule = isBisemimodule }\n", "meta": {"hexsha": "d8952798f048c4a2cc30286b4a5ff452e58e0992", "size": 9633, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Algebra/Module/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/Module/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/Module/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": 32.9897260274, "max_line_length": 78, "alphanum_fraction": 0.5873559639, "num_tokens": 4008, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511396138365, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.5870706172916019}} {"text": "open import GGT\n\n-- Throughout the following assume A is a (right) Action\nmodule GGT.Theory\n {a b ℓ₁ ℓ₂}\n (A : Action a b ℓ₁ ℓ₂)\n where\n\nopen import Level\nopen import Relation.Unary hiding (_\\\\_; _⇒_)\nopen import Relation.Binary\nopen import Algebra\nopen import Data.Product\n\nopen Action A renaming (setoid to Ω')\nopen import Relation.Binary.Reasoning.MultiSetoid\n-- open import Relation.Binary.Reasoning.Setoid Ω' would be enough\n\nopen Group G renaming (setoid to S)\nopen import GGT.Group.Structures {a} {ℓ₂} {ℓ₁}\nopen import GGT.Group.Bundles {a} {ℓ₂} {ℓ₁}\nopen import Function.Bundles\nopen import Function.Base using (_on_)\n\norbitalEq : IsEquivalence _ω_\norbitalEq = record { refl = r ;\n sym = s ;\n trans = t } where\n open Setoid Ω' renaming (sym to σ)\n r : Reflexive _ω_\n r {o} = ε , actId o\n\n s : Symmetric _ω_\n s {x} {y} ( g , x·g≡y ) = (g ⁻¹ , y·g⁻¹≡x) where\n y·g⁻¹≡x = σ x≡y·g⁻¹ where\n x≡y·g⁻¹ = begin⟨ Ω' ⟩\n x ≈˘⟨ actId x ⟩\n x · ε ≈˘⟨ G-ext (inverseʳ _) ⟩\n x · (g ∙ g ⁻¹) ≈⟨ actAssoc _ _ _ ⟩\n x · g · g ⁻¹ ≈⟨ ·-cong (g ⁻¹) x·g≡y ⟩\n y · g ⁻¹ ∎\n t : Transitive _ω_\n t {x} {y} {z} ( g , x·g≡y ) ( h , y·h≡z ) = ( g ∙ h , x·gh≡z ) where\n x·gh≡z : _\n x·gh≡z = begin⟨ Ω' ⟩\n x · (g ∙ h) ≈⟨ actAssoc _ _ _ ⟩\n x · g · h ≈⟨ ·-cong _ x·g≡y ⟩\n y · h ≈⟨ y·h≡z ⟩\n z ∎\n\nω≤≋ : _≋_ ⇒ _ω_\nω≤≋ {o} {o'} o≋o' = (ε , oε≋o' ) where\n oε≋o' = begin⟨ Ω' ⟩\n o · ε ≈⟨ actId o ⟩\n o ≈⟨ o≋o' ⟩\n o' ∎\n\nstabIsSubGroup : ∀ (o : Ω) → (stab o) ≤ G\nstabIsSubGroup o = record { ε∈ = actId o ;\n ∙-⁻¹-closed = itis ;\n r = resp } where\n itis = λ {x} {y} px py → begin⟨ Ω' ⟩\n (o · (x - y)) ≡⟨⟩\n o · x ∙ (y ⁻¹) ≈⟨ actAssoc o x (y ⁻¹) ⟩\n o · x · y ⁻¹ ≈⟨ ·-cong (y ⁻¹) px ⟩\n o · y ⁻¹ ≈˘⟨ ·-cong (y ⁻¹) py ⟩\n o · y · y ⁻¹ ≈˘⟨ actAssoc o y (y ⁻¹) ⟩\n o · (y ∙ y ⁻¹) ≈⟨ G-ext (inverseʳ y) ⟩\n o · ε ≈⟨ actId o ⟩\n o ∎\n resp : ∀ {x y : Carrier} → x ≈ y → ((stab o) x) → ((stab o) y)\n resp {x} {y} x~y xfixeso = begin⟨ Ω' ⟩\n o · y ≈˘⟨ G-ext x~y ⟩\n o · x ≈⟨ xfixeso ⟩\n o ∎\n\nStab : Ω → SubGroup G\nStab o = record { P = stab o;\n isSubGroup = stabIsSubGroup o}\n\norbitalCorr : {o : Ω} → Bijection (Stab o \\\\ G) (Orbit o)\norbitalCorr {o} = record { f = f ;\n cong = cc ;\n bijective = inj ,′ surj } where\n open Setoid (Stab o \\\\ G) renaming (_≈_ to _≈₁_; Carrier to G')\n open Setoid (Orbit o) renaming (_≈_ to _≈₂_)\n open Setoid S renaming (refl to r)\n\n f : G' → Σ Ω (o ·G)\n f x = (o · x , ( x , G-ext r))\n\n cc : f Preserves _≈₁_ ⟶ _≈₂_\n cc {g} {h} g≈₁h = begin⟨ Ω' ⟩ -- f h ≈₂ f g\n o · g ≈˘⟨ actId (o · g) ⟩\n o · g · ε ≈˘⟨ G-ext (inverseˡ h) ⟩\n o · g · (h ⁻¹ ∙ h ) ≈˘⟨ actAssoc o g (h ⁻¹ ∙ h ) ⟩\n o · (g ∙ (h ⁻¹ ∙ h )) ≈˘⟨ G-ext (assoc _ _ _) ⟩\n o · ((g ∙ h ⁻¹) ∙ h ) ≈⟨ actAssoc _ _ h ⟩\n o · (g ∙ h ⁻¹) · h ≈⟨ ·-cong h g≈₁h ⟩\n -- g≈₁h ⇒ P (g ∙ h ⁻¹) ⇒ (g ∙ h ⁻¹) ∈ Stab o\n o · h ∎\n inj : _\n -- o · g = o · h ⇒ g ∙ h ⁻¹ ∈ Stab o\n inj {g} {h} fg≈₂fh = begin⟨ Ω' ⟩\n o · g ∙ h ⁻¹ ≈⟨ actAssoc _ _ _ ⟩\n o · g · h ⁻¹ ≈⟨ ·-cong _ fg≈₂fh ⟩\n o · h · h ⁻¹ ≈˘⟨ actAssoc _ _ _ ⟩\n o · (h ∙ h ⁻¹) ≈⟨ G-ext (inverseʳ h)⟩\n o · ε ≈⟨ actId o ⟩\n o ∎\n\n surj : _\n surj (_ , p) = p\n", "meta": {"hexsha": "f339dec3db62eacbd8dbf478e571ffdae4870aca", "size": 4005, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/ggt/Theory.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/Theory.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/Theory.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": 35.1315789474, "max_line_length": 72, "alphanum_fraction": 0.3895131086, "num_tokens": 1655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835493924953, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.5869523059074596}} {"text": "import Algebra.FunctionProperties using (LeftZero; RightZero; _DistributesOverˡ_;_DistributesOverʳ_; Idempotent)\nimport Function using (_on_)\nimport Level\nimport Relation.Binary.EqReasoning as EqReasoning\nimport Relation.Binary.On using (isEquivalence)\nimport Algebra.Structures using (module IsCommutativeMonoid; IsCommutativeMonoid)\nopen import Relation.Binary using (module IsEquivalence; IsEquivalence; _Preserves₂_⟶_⟶_ ; Setoid)\nopen import Data.Product renaming (_,_ to _,,_) -- just to avoid clash with other commas\n\nopen import Preliminaries using (Rel; UniqueSolution; LowerBound)\n\nmodule SemiNearRingRecords where\n\nrecord SemiNearRing : Set₁ where -- \\structure{1}{|SemiNearRing|}\n field -- \\structure{1.1}{Carriers, operators}\n s : Set\n _≃s_ : s → s → Set\n zers : s\n _+s_ : s → s → s\n _*s_ : s → s → s\n\n open Algebra.Structures using (IsCommutativeMonoid)\n open Algebra.FunctionProperties _≃s_ using (LeftZero; RightZero)\n\n field -- \\structure{1.2}{Commutative monoid |(+,0)|}\n isCommMon : IsCommutativeMonoid _≃s_ _+s_ zers\n\n zeroˡ : LeftZero zers _*s_ -- expands to |∀ x → (zers *s x) ≃s zers|\n zeroʳ : RightZero zers _*s_ -- expands to |∀ x → (x *s zers) ≃s zers|\n _<*>_ : ∀ {x y u v} → (x ≃s y) → (u ≃s v) → (x *s u ≃s y *s v)\n\n open Algebra.FunctionProperties _≃s_\n using (Idempotent; _DistributesOverˡ_; _DistributesOverʳ_)\n\n field -- \\structure{1.3}{Distributive, idempotent, \\ldots}\n idem : Idempotent _+s_\n\n distl : _*s_ DistributesOverˡ _+s_\n distr : _*s_ DistributesOverʳ _+s_\n -- expands to |∀ a b c → (a +s b) *s c ≃s (a *s c) +s (b *s c)|\n\n infix 4 _≤s_\n _≤s_ : s -> s -> Set\n x ≤s y = x +s y ≃s y\n\n infix 4 _≃s_; infixl 6 _+s_; infixl 7 _*s_\n\n -- \\structure{1.4}{Exporting commutative monoid operations}\n open Algebra.Structures.IsCommutativeMonoid isCommMon public\n hiding (refl)\n renaming\n ( isEquivalence to isEquivs\n ; assoc to assocs\n ; comm to comms\n ; ∙-cong to _<+>_\n ; identityˡ to identityˡs\n )\n identityʳs = proj₂ identity\n\n sSetoid : Setoid Level.zero Level.zero -- \\structure{1.5}{Setoid, \\ldots}\n sSetoid = record { Carrier = s;\n _≈_ = _≃s_;\n isEquivalence = isEquivs }\n\n open IsEquivalence isEquivs public\n hiding (reflexive) renaming (refl to refls ; sym to syms ; trans to transs)\n\n LowerBounds = LowerBound _≤s_ -- \\structure{1.6}{Lower bounds}\n\nrecord SemiNearRing2 : Set₁ where -- \\structure{2}{|SemiNearRing2|}\n field\n snr : SemiNearRing\n open SemiNearRing snr public -- public = export the \"local\" names from |SemiNearRing|\n field -- \\structure{2.1}{Plus and times for |u|, \\ldots}\n u : Set\n _+u_ : u → u → u\n _*u_ : u → u → u\n u2s : u → s\n\n _≃u_ : u → u → Set\n _≃u_ = _≃s_ Function.on u2s\n\n _u*s_ : u → s → s\n _u*s_ u s = u2s u *s s\n\n _s*u_ : s → u → s\n _s*u_ s u = s *s u2s u\n\n infix 4 _≃u_; infixl 6 _+u_; infixl 7 _*u_ _u*s_ _s*u_\n\n uSetoid : Setoid Level.zero Level.zero\n uSetoid = record { isEquivalence = Relation.Binary.On.isEquivalence u2s isEquivs }\n\n _≤u_ : u → u → Set\n _≤u_ = _≤s_ Function.on u2s\n\n L : u → s → u → s → Set -- \\structure{2.2}{Linear equation |L|}\n L a y b x = y +s (a u*s x +s x s*u b) ≃s x\n\n -- \\structure{2.3}{Properties of |L|}\n UniqueL = ∀ {a y b} → UniqueSolution _≃s_ (L a y b)\n CongL = ∀ {a x b} -> ∀ {y y'} -> y ≃s y' -> L a y b x -> L a y' b x\n", "meta": {"hexsha": "34d6dceddd0dea9f02a666554cae62944771323c", "size": 3918, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "code/SemiNearRingRecords.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/SemiNearRingRecords.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/SemiNearRingRecords.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": 38.0388349515, "max_line_length": 112, "alphanum_fraction": 0.5574272588, "num_tokens": 1368, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835289107307, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.5869522967219096}} {"text": "------------------------------------------------------------------------------\n-- Axiomatic PA propositional equality\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule PA.Axiomatic.Mendelson.Relation.Binary.PropositionalEqualityI where\n\nopen import PA.Axiomatic.Mendelson.Base\n\n------------------------------------------------------------------------------\n-- Identity properties\n\n≈-refl : ∀ {n} → n ≈ n\n≈-refl {n} = S₁ (S₅ n) (S₅ n)\n\n≈-sym : ∀ {m n} → m ≈ n → n ≈ m\n≈-sym h = S₁ h ≈-refl\n\n≈-trans : ∀ {m n o} → m ≈ n → n ≈ o → m ≈ o\n≈-trans h = S₁ (≈-sym h)\n\n------------------------------------------------------------------------------\n-- Substitution\n\n-- Using Mendelson's axioms we cannot prove\n\n-- a ≈ b A(x)\n-- ----------------- substitution\n-- A(x)\n\n-- where A(x) is an arbitrary propositional function, We can prove\n-- substitutivity of `_≈_` for the proper functional symbols of the\n-- language (`succ`, `add` and `mult`). That is, we can prove (by\n-- induction)\n\n-- succCong : ∀ {m n} → m ≈ n → succ m ≈ succ n\n-- +-rightCong : ∀ {m n p} → n ≈ p → m + n ≈ m + p\n-- +-leftCong : ∀ {m n p} → m ≈ n → m + p ≈ n + p\n-- *-rightCong : ∀ {m n p} → n ≈ p → m * n ≈ m * p\n-- *-leftCong : ∀ {m n p} → m ≈ n → m * p ≈ n * p\n\n-- The proofs of the above properties are in the `PropertiesI` module.\n", "meta": {"hexsha": "a21ba5ab5cbaf51f0413dea27f8fb3da03cceac6", "size": 1536, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Axiomatic/Mendelson/Relation/Binary/PropositionalEqualityI.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/Axiomatic/Mendelson/Relation/Binary/PropositionalEqualityI.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/Axiomatic/Mendelson/Relation/Binary/PropositionalEqualityI.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.6808510638, "max_line_length": 78, "alphanum_fraction": 0.4290364583, "num_tokens": 445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835289107309, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.5869522915184044}} {"text": "{-# OPTIONS --without-K #-}\nmodule Path2Equiv where\n\n-- nothing for the standard library needed directly!\n\nopen import FT\nopen import Equivalences\nopen import TypeEquivalences\n\n-- We now have enough to map each Pi combinator to the corresponding type equivalence\n\npath2equiv : {B₁ B₂ : FT} → (B₁ ⇛ B₂) → (⟦ B₁ ⟧ ≃ ⟦ B₂ ⟧)\npath2equiv unite₊⇛ = unite₊equiv\npath2equiv uniti₊⇛ = uniti₊equiv\npath2equiv swap₊⇛ = swap₊equiv\npath2equiv assocl₊⇛ = assocl₊equiv\npath2equiv assocr₊⇛ = assocr₊equiv\npath2equiv unite⋆⇛ = unite⋆equiv\npath2equiv uniti⋆⇛ = uniti⋆equiv\npath2equiv swap⋆⇛ = swap⋆equiv\npath2equiv assocl⋆⇛ = assocl⋆equiv\npath2equiv assocr⋆⇛ = assocr⋆equiv\npath2equiv distz⇛ = distzequiv\npath2equiv factorz⇛ = factorzequiv\npath2equiv dist⇛ = distequiv\npath2equiv factor⇛ = factorequiv\npath2equiv id⇛ = idequiv\npath2equiv (sym⇛ p) = sym≃ (path2equiv p)\npath2equiv (p ◎ q) = trans≃ (path2equiv p) (path2equiv q) \npath2equiv (p ⊕ q) = path⊎ (path2equiv p) (path2equiv q)\npath2equiv (p ⊗ q) = path× (path2equiv p) (path2equiv q) \n\n\n", "meta": {"hexsha": "53a4042c426c2f34a48c0e243accf81205d141f6", "size": 1049, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/OldUnivalence/Path2Equiv.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/Path2Equiv.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/Path2Equiv.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.8529411765, "max_line_length": 85, "alphanum_fraction": 0.7159199237, "num_tokens": 436, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513759047848, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.586950301976798}} {"text": "------------------------------------------------------------------------\n-- Bi-invertibility\n------------------------------------------------------------------------\n\n-- The development is based on the presentation of bi-invertibility\n-- (for types and functions) and related things in the HoTT book.\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Equality\nopen import Prelude hiding (id; _∘_)\n\n-- The code is parametrised by something like a \"raw\" category.\n\nmodule Bi-invertibility\n {e⁺}\n (eq : ∀ {a p} → Equality-with-J a p e⁺)\n {o h}\n (Obj : Type o)\n (Hom : Obj → Obj → Type h)\n (id : {A : Obj} → Hom A A)\n (_∘′_ : {A B C : Obj} → Hom B C → Hom A B → Hom A C)\n where\n\nopen Derived-definitions-and-properties eq\nopen import Equivalence eq as Eq using (_≃_; Is-equivalence)\nopen import Function-universe eq as F hiding (id; _∘_)\nopen import Logical-equivalence using (_⇔_)\nopen import H-level eq\nopen import H-level.Closure eq\nopen import Preimage eq\nopen import Surjection eq using (_↠_)\n\nprivate\n variable\n A B : Obj\n f : Hom A B\n\n infixr 9 _∘_\n\n _∘_ : {A B C : Obj} → Hom B C → Hom A B → Hom A C\n _∘_ = _∘′_\n\n-- Has-left-inverse f means that f has a left inverse.\n\nHas-left-inverse : Hom A B → Type h\nHas-left-inverse f = ∃ λ f⁻¹ → f⁻¹ ∘ f ≡ id\n\n-- Has-right-inverse f means that f has a right inverse.\n\nHas-right-inverse : Hom A B → Type h\nHas-right-inverse f = ∃ λ f⁻¹ → f ∘ f⁻¹ ≡ id\n\n-- Is-bi-invertible f means that f has a left inverse and a (possibly\n-- distinct) right inverse.\n\nIs-bi-invertible : Hom A B → Type h\nIs-bi-invertible f =\n Has-left-inverse f × Has-right-inverse f\n\n-- Has-quasi-inverse f means that f has a left inverse that is also a\n-- right inverse.\n\nHas-quasi-inverse : Hom A B → Type h\nHas-quasi-inverse f =\n ∃ λ f⁻¹ → f ∘ f⁻¹ ≡ id × f⁻¹ ∘ f ≡ id\n\n-- Some notions of isomorphism or equivalence.\n\ninfix 4 _≊_ _≅_\n\n_≊_ : Obj → Obj → Type h\nA ≊ B = ∃ λ (f : Hom A B) → Is-bi-invertible f\n\n_≅_ : Obj → Obj → Type h\nA ≅ B = ∃ λ (f : Hom A B) → Has-quasi-inverse f\n\n-- Morphisms with quasi-inverses are bi-invertible.\n\nHas-quasi-inverse→Is-bi-invertible :\n (f : Hom A B) → Has-quasi-inverse f → Is-bi-invertible f\nHas-quasi-inverse→Is-bi-invertible _ (f⁻¹ , f∘f⁻¹≡id , f⁻¹∘f≡id) =\n (f⁻¹ , f⁻¹∘f≡id)\n , (f⁻¹ , f∘f⁻¹≡id)\n\n≅→≊ : A ≅ B → A ≊ B\n≅→≊ = ∃-cong Has-quasi-inverse→Is-bi-invertible\n\n-- The remaining code relies on some further assumptions, similar to\n-- those of a precategory. However, note that Hom A B is not required\n-- to be a set (some properties require Hom A A to be a set for some\n-- A).\n\nmodule More\n (left-identity : {A B : Obj} (f : Hom A B) → id ∘ f ≡ f)\n (right-identity : {A B : Obj} (f : Hom A B) → f ∘ id ≡ f)\n (associativity : {A B C D : Obj}\n (f : Hom C D) (g : Hom B C) (h : Hom A B) →\n f ∘ (g ∘ h) ≡ (f ∘ g) ∘ h)\n where\n\n -- Bi-invertible morphisms have quasi-inverses.\n\n Is-bi-invertible→Has-quasi-inverse :\n Is-bi-invertible f → Has-quasi-inverse f\n Is-bi-invertible→Has-quasi-inverse\n {f = f} ((f⁻¹₁ , f⁻¹₁∘f≡id) , (f⁻¹₂ , f∘f⁻¹₂≡id)) =\n (f⁻¹₁ ∘ f ∘ f⁻¹₂)\n , (f ∘ f⁻¹₁ ∘ f ∘ f⁻¹₂ ≡⟨ cong (f ∘_) $ associativity _ _ _ ⟩\n f ∘ (f⁻¹₁ ∘ f) ∘ f⁻¹₂ ≡⟨ cong (λ f′ → f ∘ f′ ∘ f⁻¹₂) f⁻¹₁∘f≡id ⟩\n f ∘ id ∘ f⁻¹₂ ≡⟨ cong (f ∘_) $ left-identity _ ⟩\n f ∘ f⁻¹₂ ≡⟨ f∘f⁻¹₂≡id ⟩∎\n id ∎)\n , ((f⁻¹₁ ∘ f ∘ f⁻¹₂) ∘ f ≡⟨ cong (λ f′ → (f⁻¹₁ ∘ f′) ∘ f) f∘f⁻¹₂≡id ⟩\n (f⁻¹₁ ∘ id) ∘ f ≡⟨ cong (_∘ f) $ right-identity _ ⟩\n f⁻¹₁ ∘ f ≡⟨ f⁻¹₁∘f≡id ⟩∎\n id ∎)\n\n -- Has-left-inverse f is contractible if f has a quasi-inverse.\n\n Has-left-inverse-contractible :\n Has-quasi-inverse f → Contractible (Has-left-inverse f)\n Has-left-inverse-contractible\n {f = f} (f⁻¹ , f∘f⁻¹≡id , f⁻¹∘f≡id) =\n bijection⁻¹-contractible (record\n { surjection = record\n { logical-equivalence = record\n { to = _∘ f\n ; from = _∘ f⁻¹\n }\n ; right-inverse-of = λ g →\n (g ∘ f⁻¹) ∘ f ≡⟨ sym $ associativity _ _ _ ⟩\n g ∘ f⁻¹ ∘ f ≡⟨ cong (g ∘_) f⁻¹∘f≡id ⟩\n g ∘ id ≡⟨ right-identity _ ⟩∎\n g ∎\n }\n ; left-inverse-of = λ g →\n (g ∘ f) ∘ f⁻¹ ≡⟨ sym $ associativity _ _ _ ⟩\n g ∘ f ∘ f⁻¹ ≡⟨ cong (g ∘_) f∘f⁻¹≡id ⟩\n g ∘ id ≡⟨ right-identity _ ⟩∎\n g ∎\n })\n id\n\n -- Has-right-inverse f is contractible if f has a quasi-inverse.\n\n Has-right-inverse-contractible :\n Has-quasi-inverse f → Contractible (Has-right-inverse f)\n Has-right-inverse-contractible\n {f = f} (f⁻¹ , f∘f⁻¹≡id , f⁻¹∘f≡id) =\n bijection⁻¹-contractible (record\n { surjection = record\n { logical-equivalence = record\n { to = f ∘_\n ; from = f⁻¹ ∘_\n }\n ; right-inverse-of = λ g →\n f ∘ f⁻¹ ∘ g ≡⟨ associativity _ _ _ ⟩\n (f ∘ f⁻¹) ∘ g ≡⟨ cong (_∘ g) f∘f⁻¹≡id ⟩\n id ∘ g ≡⟨ left-identity _ ⟩∎\n g ∎\n }\n ; left-inverse-of = λ g →\n f⁻¹ ∘ f ∘ g ≡⟨ associativity _ _ _ ⟩\n (f⁻¹ ∘ f) ∘ g ≡⟨ cong (_∘ g) f⁻¹∘f≡id ⟩\n id ∘ g ≡⟨ left-identity _ ⟩∎\n g ∎\n })\n id\n\n -- Is-bi-invertible f is a proposition.\n\n Is-bi-invertible-propositional :\n (f : Hom A B) → Is-proposition (Is-bi-invertible f)\n Is-bi-invertible-propositional f =\n [inhabited⇒+]⇒+ 0 λ b →\n let q = Is-bi-invertible→Has-quasi-inverse b in\n mono₁ 0 $\n ×-closure 0\n (Has-left-inverse-contractible q)\n (Has-right-inverse-contractible q)\n\n -- If Hom A A is a set, where A is the domain of f, then\n -- Has-quasi-inverse f is a proposition.\n\n Has-quasi-inverse-propositional-domain :\n {f : Hom A B} →\n Is-set (Hom A A) →\n Is-proposition (Has-quasi-inverse f)\n Has-quasi-inverse-propositional-domain {f = f} s = $⟨ (λ inv → Σ-closure 1\n (mono₁ 0 $ Has-right-inverse-contractible inv)\n (λ _ → s)) ⟩\n (Has-quasi-inverse f →\n Is-proposition (∃ λ ((f⁻¹ , _) : Has-right-inverse f) →\n f⁻¹ ∘ f ≡ id)) ↝⟨ (∀-cong _ λ _ → H-level-cong _ 1 (inverse Σ-assoc)) ⟩\n\n (Has-quasi-inverse f → Is-proposition (Has-quasi-inverse f)) ↝⟨ [inhabited⇒+]⇒+ 0 ⟩□\n\n Is-proposition (Has-quasi-inverse f) □\n\n -- If Hom B B is a set, where B is the codomain of f, then\n -- Has-quasi-inverse f is a proposition.\n\n Has-quasi-inverse-propositional-codomain :\n {f : Hom A B} →\n Is-set (Hom B B) →\n Is-proposition (Has-quasi-inverse f)\n Has-quasi-inverse-propositional-codomain {f = f} s = $⟨ (λ inv → Σ-closure 1\n (mono₁ 0 $ Has-left-inverse-contractible inv)\n (λ _ → s)) ⟩\n (Has-quasi-inverse f →\n Is-proposition (∃ λ ((f⁻¹ , _) : Has-left-inverse f) →\n f ∘ f⁻¹ ≡ id)) ↝⟨ (∀-cong _ λ _ → H-level-cong _ 1 lemma) ⟩\n\n (Has-quasi-inverse f → Is-proposition (Has-quasi-inverse f)) ↝⟨ [inhabited⇒+]⇒+ 0 ⟩□\n\n Is-proposition (Has-quasi-inverse f) □\n where\n lemma =\n (∃ λ ((f⁻¹ , _) : Has-left-inverse f) → f ∘ f⁻¹ ≡ id) ↔⟨⟩\n (∃ λ ((f⁻¹ , _) : ∃ λ f⁻¹ → f⁻¹ ∘ f ≡ id) → f ∘ f⁻¹ ≡ id) ↝⟨ inverse Σ-assoc ⟩\n (∃ λ f⁻¹ → f⁻¹ ∘ f ≡ id × f ∘ f⁻¹ ≡ id) ↝⟨ (∃-cong λ _ → ×-comm) ⟩\n (∃ λ f⁻¹ → f ∘ f⁻¹ ≡ id × f⁻¹ ∘ f ≡ id) ↔⟨⟩\n Has-quasi-inverse f □\n\n -- There is a split surjection from Has-quasi-inverse f to\n -- Is-bi-invertible f.\n\n Has-quasi-inverse↠Is-bi-invertible :\n Has-quasi-inverse f ↠ Is-bi-invertible f\n Has-quasi-inverse↠Is-bi-invertible = record\n { logical-equivalence = record\n { to = Has-quasi-inverse→Is-bi-invertible _\n ; from = Is-bi-invertible→Has-quasi-inverse\n }\n ; right-inverse-of = λ _ → Is-bi-invertible-propositional _ _ _\n }\n\n -- There is a split surjection from A ≅ B to A ≊ B.\n\n ≅↠≊ : (A ≅ B) ↠ (A ≊ B)\n ≅↠≊ = ∃-cong λ _ → Has-quasi-inverse↠Is-bi-invertible\n\n -- Is-bi-invertible and Has-quasi-inverse are equivalent for\n -- morphisms with domain A for which Hom A A is a set.\n\n Is-bi-invertible≃Has-quasi-inverse-domain :\n {f : Hom A B} →\n Is-set (Hom A A) →\n Is-bi-invertible f ≃ Has-quasi-inverse f\n Is-bi-invertible≃Has-quasi-inverse-domain s =\n inverse $ Eq.↔⇒≃ (record\n { surjection = Has-quasi-inverse↠Is-bi-invertible\n ; left-inverse-of = λ _ →\n Has-quasi-inverse-propositional-domain s _ _\n })\n\n -- Is-bi-invertible and Has-quasi-inverse are equivalent for\n -- morphisms with codomain B for which Hom B B is a set.\n\n Is-bi-invertible≃Has-quasi-inverse-codomain :\n {f : Hom A B} →\n Is-set (Hom B B) →\n Is-bi-invertible f ≃ Has-quasi-inverse f\n Is-bi-invertible≃Has-quasi-inverse-codomain s =\n inverse $ Eq.↔⇒≃ (record\n { surjection = Has-quasi-inverse↠Is-bi-invertible\n ; left-inverse-of = λ _ →\n Has-quasi-inverse-propositional-codomain s _ _\n })\n\n -- A ≊ B and A ≅ B are equivalent if Hom A A is a set.\n\n ≊≃≅-domain :\n Is-set (Hom A A) →\n (A ≊ B) ≃ (A ≅ B)\n ≊≃≅-domain s =\n ∃-cong λ _ → Is-bi-invertible≃Has-quasi-inverse-domain s\n\n -- A ≊ B and A ≅ B are equivalent if Hom B B is a set.\n\n ≊≃≅-codomain :\n Is-set (Hom B B) →\n (A ≊ B) ≃ (A ≅ B)\n ≊≃≅-codomain s =\n ∃-cong λ _ → Is-bi-invertible≃Has-quasi-inverse-codomain s\n\n -- An equality characterisation lemma for _≊_.\n\n equality-characterisation-≊ :\n (f g : A ≊ B) → (f ≡ g) ≃ (proj₁ f ≡ proj₁ g)\n equality-characterisation-≊ _ _ =\n Eq.↔⇒≃ $ inverse $ ignore-propositional-component $\n Is-bi-invertible-propositional _\n\n -- Two equality characterisation lemmas for _≅_.\n\n equality-characterisation-≅-domain :\n Is-set (Hom A A) →\n (f g : A ≅ B) → (f ≡ g) ≃ (proj₁ f ≡ proj₁ g)\n equality-characterisation-≅-domain s _ _ =\n Eq.↔⇒≃ $ inverse $ ignore-propositional-component $\n Has-quasi-inverse-propositional-domain s\n\n equality-characterisation-≅-codomain :\n Is-set (Hom B B) →\n (f g : A ≅ B) → (f ≡ g) ≃ (proj₁ f ≡ proj₁ g)\n equality-characterisation-≅-codomain s _ _ =\n Eq.↔⇒≃ $ inverse $ ignore-propositional-component $\n Has-quasi-inverse-propositional-codomain s\n\n -- If f : Hom A B has a quasi-inverse, then Has-quasi-inverse f is\n -- equivalent to id ≡ id, where id stands for either the identity at\n -- A or at B.\n\n Has-quasi-inverse≃id≡id-domain :\n {f : Hom A B} →\n Has-quasi-inverse f →\n Has-quasi-inverse f ≃ (id ≡ id {A = A})\n Has-quasi-inverse≃id≡id-domain {f = f} q-inv@(f⁻¹ , _ , f⁻¹∘f≡id) =\n Has-quasi-inverse f ↔⟨ Σ-assoc ⟩\n (∃ λ ((f⁻¹ , _) : Has-right-inverse f) → f⁻¹ ∘ f ≡ id) ↔⟨ drop-⊤-left-Σ (_⇔_.to contractible⇔↔⊤ $ Has-right-inverse-contractible q-inv) ⟩\n (f⁻¹ ∘ id) ∘ f ≡ id ↝⟨ ≡⇒↝ _ $ cong (λ f′ → f′ ∘ _ ≡ _) $ right-identity _ ⟩\n f⁻¹ ∘ f ≡ id ↝⟨ ≡⇒↝ _ $ cong (_≡ _) f⁻¹∘f≡id ⟩□\n id ≡ id □\n\n Has-quasi-inverse≃id≡id-codomain :\n {f : Hom A B} →\n Has-quasi-inverse f →\n Has-quasi-inverse f ≃ (id ≡ id {A = B})\n Has-quasi-inverse≃id≡id-codomain {f = f} q-inv@(f⁻¹ , f∘f⁻¹≡id , _) =\n Has-quasi-inverse f ↔⟨ Σ-assoc F.∘ (∃-cong λ _ → ×-comm) ⟩\n (∃ λ ((f⁻¹ , _) : Has-left-inverse f) → f ∘ f⁻¹ ≡ id) ↔⟨ drop-⊤-left-Σ (_⇔_.to contractible⇔↔⊤ $ Has-left-inverse-contractible q-inv) ⟩\n f ∘ id ∘ f⁻¹ ≡ id ↝⟨ ≡⇒↝ _ $ cong (λ f′ → _ ∘ f′ ≡ _) $ left-identity _ ⟩\n f ∘ f⁻¹ ≡ id ↝⟨ ≡⇒↝ _ $ cong (_≡ _) f∘f⁻¹≡id ⟩□\n id ≡ id □\n\n ----------------------------------------------------------------------\n -- Univalence\n\n -- The relation _≅_ is reflexive.\n\n id-≅ : A ≅ A\n id-≅ = id , id , left-identity id , right-identity id\n\n -- Equal objects are related by _≅_.\n\n ≡→≅ : A ≡ B → A ≅ B\n ≡→≅ = elim (λ {A B} _ → A ≅ B) (λ _ → id-≅)\n\n -- A \"computation\" rule for ≡→≅.\n\n ≡→≅-refl : ≡→≅ (refl A) ≡ id-≅\n ≡→≅-refl = elim-refl _ _\n\n -- A notion of univalence, defined using _≅_.\n\n Univalence-≅ : Type (o ⊔ h)\n Univalence-≅ = {A B : Obj} → Is-equivalence (≡→≅ {A = A} {B = B})\n\n -- If equality is equivalent to _≅_, then univalence holds.\n\n ≡≃≅→Univalence-≅ :\n (∀ {A B} → (A ≡ B) ≃ (A ≅ B)) →\n Univalence-≅\n ≡≃≅→Univalence-≅ ≡≃≅ =\n Eq.≡≃→≡→→Is-equivalence (_ ≅_) ≡≃≅ ≡→≅\n\n -- The relation _≊_ is reflexive.\n\n id-≊ : A ≊ A\n id-≊ = id , (id , left-identity id) , (id , right-identity id)\n\n -- Equal objects are related by _≊_.\n\n ≡→≊ : A ≡ B → A ≊ B\n ≡→≊ = elim (λ {A B} _ → A ≊ B) (λ _ → id-≊)\n\n -- A \"computation\" rule for ≡→≊.\n\n ≡→≊-refl : ≡→≊ (refl A) ≡ id-≊\n ≡→≊-refl = elim-refl _ _\n\n -- A notion of univalence, defined using _≊_.\n\n Univalence-≊ : Type (o ⊔ h)\n Univalence-≊ = {A B : Obj} → Is-equivalence (≡→≊ {A = A} {B = B})\n\n -- If equality is equivalent to _≊_, then univalence holds.\n\n ≡≃≊→Univalence-≊ :\n (∀ {A B} → (A ≡ B) ≃ (A ≊ B)) →\n Univalence-≊\n ≡≃≊→Univalence-≊ ≡≃≊ =\n Eq.≡≃→≡→→Is-equivalence (_ ≊_) ≡≃≊ ≡→≊\n", "meta": {"hexsha": "27b1be3085eb506ad30bdd7ad01873201414ca43", "size": 13712, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Bi-invertibility.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/Bi-invertibility.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/Bi-invertibility.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.6262626263, "max_line_length": 142, "alphanum_fraction": 0.5075116686, "num_tokens": 5269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767778695834, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.5869269014427958}} {"text": "\n\nmodule SafetyProof where\n\nopen import Algebra\nimport Algebra.Properties.CommutativeSemigroup as CommutativeSemigroupProperties\nopen import Data.List\nopen import Data.List.Relation.Unary.All using (All; []; _∷_)\nopen import Data.Fin.Patterns using (0F; 1F)\nopen import Data.Nat using (z≤n; s≤s)\nopen import Data.Integer using (+≤+; +<+; +_)\nopen import Data.Vec using (_∷_)\nimport Data.Vec.Functional as Vector\nopen import Data.Product using (_×_; _,_; uncurry)\nopen import Data.Sum\nopen import Level using (0ℓ)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary using (yes; no)\n\nopen import Vehicle.Data.Tensor\nopen import AbstractRationals\nimport WindControllerSpec as Vehicle\n\nopen ≤-Reasoning\n\n------------------------------------------------------------------------\n-- Setup\n\ntoTensor : ℚ → ℚ → Tensor ℚ (2 ∷ [])\ntoTensor x y = Vector.fromList (x ∷ y ∷ [])\n\nroadWidth : ℚ\nroadWidth = + 3 / 1\n\nmaxWindShift : ℚ\nmaxWindShift = 1ℚ\n\nmaxSensorError : ℚ\nmaxSensorError = + 1 / 4\n\nroadWidth≥0 : roadWidth ≥ 0ℚ\nroadWidth≥0 = *≤* (+≤+ z≤n)\n\nmaxWindShift≥0 : maxWindShift ≥ 0ℚ\nmaxWindShift≥0 = *≤* (+≤+ z≤n)\n\nmaxSensorError≥0 : maxSensorError ≥ 0ℚ\nmaxSensorError≥0 = *≤* (+≤+ z≤n)\n\n------------------------------------------------------------------------\n-- Model data\n\nrecord State : Set where\n constructor state\n field\n windSpeed : ℚ\n position : ℚ\n velocity : ℚ\n sensor : ℚ\n\nopen State\n\nrecord Observation : Set where\n constructor observe\n field\n windShift : ℚ\n sensorError : ℚ\n\nopen Observation\n\n------------------------------------------------------------------------\n-- Model transitions\n\ninitialState : State\ninitialState = record\n { windSpeed = 0ℚ\n ; position = 0ℚ\n ; velocity = 0ℚ\n ; sensor = 0ℚ\n }\n\ncontroller : ℚ → ℚ → ℚ\ncontroller x y = Vehicle.controller (toTensor x y)\n\nnextState : Observation → State → State\nnextState o s = record\n { windSpeed = newWindSpeed\n ; position = newPosition\n ; velocity = newVelocity\n ; sensor = newSensor\n }\n where\n newWindSpeed = windSpeed s + windShift o\n newPosition = position s + velocity s + newWindSpeed\n newSensor = newPosition + sensorError o\n newVelocity = velocity s + controller newSensor (sensor s)\n\nfinalState : List Observation → State\nfinalState xs = foldr nextState initialState xs\n\n------------------------------------------------------------------------\n-- Definition of correctness\n\nnextPosition-windShift : State → ℚ\nnextPosition-windShift s = position s + velocity s + windSpeed s\n\n-- The vehicle is on the road if its position is less than the\n-- width of the road.\nOnRoad : State → Set\nOnRoad s = ∣ position s ∣ ≤ roadWidth\n\n-- The vehicle is in a \"safe\" state if it's more than the maxWindShift away\n-- from the edge of the road.\nSafeDistanceFromEdge : State → Set\nSafeDistanceFromEdge s = ∣ nextPosition-windShift s ∣ < roadWidth - maxWindShift\n\n-- The vehicle's previous sensor reading is accurate if it is no more than the\n-- maximum error away from it's true location.\nAccurateSensorReading : State → Set\nAccurateSensorReading s = ∣ position s - sensor s ∣ ≤ maxSensorError\n\n-- The vehicle's previous sensor reading was not off the road\nSensorReadingNotOffRoad : State → Set\nSensorReadingNotOffRoad s = ∣ sensor s ∣ ≤ roadWidth + maxSensorError\n\n-- A state is safe if it both a safe distance from the edge and it's sensor\n-- reading is accurate.\nSafeState : State → Set\nSafeState s = SafeDistanceFromEdge s\n × AccurateSensorReading s\n × SensorReadingNotOffRoad s\n\n-- An observation is valid if the observed sensor error and the wind shift\n-- are less than the expected maximum shifts.\nValidObservation : Observation → Set\nValidObservation o = ∣ sensorError o ∣ ≤ maxSensorError\n × ∣ windShift o ∣ ≤ maxWindShift\n\n------------------------------------------------------------------------\n-- Proof of correctness\n\n-- Initial state is both a safe distance from the edge and on the road\n\ninitialState-onRoad : OnRoad initialState\ninitialState-onRoad = roadWidth≥0\n\ninitialState-safe : SafeState initialState\ninitialState-safe rewrite +-eq | *-eq | neg-eq =\n *<* (+<+ (s≤s z≤n)) ,\n *≤* (+≤+ z≤n) ,\n *≤* (+≤+ z≤n)\n\n-- Transitions are well-behaved\n\ncontroller-lem : ∀ x y →\n ∣ x ∣ ≤ roadWidth + maxSensorError →\n ∣ y ∣ ≤ roadWidth + maxSensorError →\n ∣ controller x y + 2ℚ * x - y ∣ < roadWidth - maxWindShift - 3ℚ * maxSensorError\ncontroller-lem x y ∣x∣≤rw+εₘₐₓ ∣y∣≤rw+εₘₐₓ rewrite +-eq | *-eq | neg-eq =\n uncurry -p t2 == t1 ==> t4 → t2 == t4\n lemma-arr-l refl = refl\n\n lemma-arr-r : ∀{t1 t2 t3} → t1 ==> t2 == t3 ==> t2 → t1 == t3\n lemma-arr-r refl = refl\n\n lemma-arr-b : ∀{t1 t2 t3 t4} → t1 ==> t2 == t3 ==> t4 → t1 == t3\n lemma-arr-b refl = refl\n\n lemma-prod-l : ∀{t1 t2 t4} → t1 ⊗ t2 == t1 ⊗ t4 → t2 == t4\n lemma-prod-l refl = refl\n\n lemma-prod-r : ∀{t1 t2 t3} → t1 ⊗ t2 == t3 ⊗ t2 → t1 == t3\n lemma-prod-r refl = refl\n\n lemma-prod-b : ∀{t1 t2 t3 t4} → t1 ⊗ t2 == t3 ⊗ t4 → t1 == t3\n lemma-prod-b refl = refl\n\n -- types are decidable\n typ-dec : dec typ\n typ-dec b b = Inl refl\n typ-dec b ⦇·⦈ = Inr (λ ())\n typ-dec b (t2 ==> t3) = Inr (λ ())\n typ-dec ⦇·⦈ b = Inr (λ ())\n typ-dec ⦇·⦈ ⦇·⦈ = Inl refl\n typ-dec ⦇·⦈ (t2 ==> t3) = Inr (λ ())\n typ-dec (t1 ==> t2) b = Inr (λ ())\n typ-dec (t1 ==> t2) ⦇·⦈ = Inr (λ ())\n typ-dec (t1 ==> t2) (t3 ==> t4) with typ-dec t1 t3 | typ-dec t2 t4\n typ-dec (t1 ==> t2) (.t1 ==> .t2) | Inl refl | Inl refl = Inl refl\n typ-dec (t1 ==> t2) (.t1 ==> t4) | Inl refl | Inr x₁ = Inr (λ x → x₁ (lemma-arr-l x))\n typ-dec (t1 ==> t2) (t3 ==> .t2) | Inr x | Inl refl = Inr (λ x₁ → x (lemma-arr-r x₁))\n typ-dec (t1 ==> t2) (t3 ==> t4) | Inr x | Inr x₁ = Inr (λ x₂ → x (lemma-arr-b x₂))\n typ-dec b (t2 ⊗ t3) = Inr (λ ())\n typ-dec ⦇·⦈ (t2 ⊗ t3) = Inr (λ ())\n typ-dec (t1 ==> t2) (t3 ⊗ t4) = Inr (λ ())\n typ-dec (t1 ⊗ t2) b = Inr (λ ())\n typ-dec (t1 ⊗ t2) ⦇·⦈ = Inr (λ ())\n typ-dec (t1 ⊗ t2) (t3 ==> t4) = Inr (λ ())\n typ-dec (t1 ⊗ t2) (t3 ⊗ t4) with typ-dec t1 t3 | typ-dec t2 t4\n typ-dec (t1 ⊗ t2) (.t1 ⊗ .t2) | Inl refl | Inl refl = Inl refl\n typ-dec (t1 ⊗ t2) (.t1 ⊗ t4) | Inl refl | Inr x₁ = Inr (λ x → x₁ (lemma-prod-l x))\n typ-dec (t1 ⊗ t2) (t3 ⊗ .t2) | Inr x | Inl refl = Inr (λ x' → x (lemma-prod-r x'))\n typ-dec (t1 ⊗ t2) (t3 ⊗ t4) | Inr x | Inr x₁ = Inr (λ x' → x (lemma-prod-b x'))\n\n -- if an arrow is disequal, it disagrees in the first or second argument\n ne-factor : ∀{τ1 τ2 τ3 τ4} → (τ1 ==> τ2) ≠ (τ3 ==> τ4) → (τ1 ≠ τ3) + (τ2 ≠ τ4)\n ne-factor {τ1} {τ2} {τ3} {τ4} ne with typ-dec τ1 τ3 | typ-dec τ2 τ4\n ne-factor ne | Inl refl | Inl refl = Inl (λ x → ne refl)\n ne-factor ne | Inl x | Inr x₁ = Inr x₁\n ne-factor ne | Inr x | Inl x₁ = Inl x\n ne-factor ne | Inr x | Inr x₁ = Inl x\n", "meta": {"hexsha": "34eb6a106e7753e3a36699c5f76784f7c9beed78", "size": 2401, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "typ-dec.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": "typ-dec.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": "typ-dec.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": 40.6949152542, "max_line_length": 91, "alphanum_fraction": 0.5072886297, "num_tokens": 1194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898127684335, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.5868985861941574}} {"text": "\nmodule Functor where\n\nopen import Category as Cat\n\nrecord Functor (ℂ ⅅ : Cat) : Set1 where\n field\n F : Cat.Obj ℂ -> Cat.Obj ⅅ\n map : {A B : Cat.Obj ℂ} -> Cat._─→_ ℂ A B -> Cat._─→_ ⅅ (F A) (F B)\n mapEq : {A B : Cat.Obj ℂ}{f g : Cat._─→_ ℂ A B} -> Category._==_ ℂ f g ->\n Category._==_ ⅅ (map f) (map g)\n mapId : {A : Cat.Obj ℂ} -> Category._==_ ⅅ (map (Cat.id ℂ {A})) (Cat.id ⅅ)\n mapCompose : {A B C : Cat.Obj ℂ}{f : Cat._─→_ ℂ B C}{g : Cat._─→_ ℂ A B} ->\n Category._==_ ⅅ (map (Cat._∘_ ℂ f g)) (Cat._∘_ ⅅ (map f) (map g))\n\n", "meta": {"hexsha": "60060480b8b8f34bcc3bfce0714b1b1d897e123d", "size": 599, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/Functor.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/Functor.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/Functor.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": 37.4375, "max_line_length": 83, "alphanum_fraction": 0.4808013356, "num_tokens": 253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107984180245, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.5868103400489668}} {"text": "module x06-747Connectives-hc where\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------------------------------------------------------------------------------\n-- BEGIN : 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 : Copied from 747Isomorphism.\n------------------------------------------------------------------------------\n\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 (aka eliminators) for ×.\n\nproj₁ : ∀ {A B : Set}\n → A × B\n -----\n → A\n\nproj₁ ⟨ a , _ ⟩ = a\n\nproj₂ : ∀ {A B : Set}\n → A × B\n -----\n → B\n\nproj₂ ⟨ _ , b ⟩ = b\n\n-- equivalent construction using records\nrecord _×′_ (A B : Set) : Set where\n field\n proj₁′ : A\n proj₂′ : B\nopen _×′_\n\n-- eta-equivalence relates constructors and destructors\nη-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w\nη-× ⟨ a , b ⟩ = refl\n\n-- type with two members\ninfixr 2 _×_\ndata Bool : Set where\n true : Bool\n false : Bool\n\n-- type with three members (used in examples)\ndata Tri : Set where\n aa : Tri\n bb : Tri\n cc : Tri\n\n-- Bool × Tri has six members\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\nswap : ∀ {A B : Set} → A × B → B × A\nswap ⟨ a , b ⟩ = ⟨ b , a ⟩\n\n×-comm : ∀ {A B : Set} → A × B ≃ B × A\nto ×-comm = swap\nfrom ×-comm = swap\nfrom∘to ×-comm ⟨ _ , _ ⟩ = refl\nto∘from ×-comm ⟨ _ , _ ⟩ = refl\n\n×-assoc : ∀ {A B C : Set} → (A × B) × C ≃ A × (B × C)\nto ×-assoc ⟨ ⟨ a , b ⟩ , c ⟩ = ⟨ a , ⟨ b , c ⟩ ⟩\nfrom ×-assoc ⟨ a , ⟨ b , c ⟩ ⟩ = ⟨ ⟨ a , b ⟩ , c ⟩\nfrom∘to ×-assoc ⟨ ⟨ _ , _ ⟩ , _ ⟩ = refl\nto∘from ×-assoc ⟨ _ , ⟨ _ , _ ⟩ ⟩ = refl\n\n-- A ⇔ B is isomorphic to (A → B) × (B → A)\niff-iso-if-onlyif : ∀ {A B : Set} → A ⇔ B ≃ (A → B) × (B → A)\n_≃_.to iff-iso-if-onlyif record { to = to ; from = from } = ⟨ to , from ⟩\nto (_≃_.from iff-iso-if-onlyif ⟨ A→B , B→A ⟩) = A→B\nfrom (_≃_.from iff-iso-if-onlyif ⟨ A→B , B→A ⟩) = B→A\nfrom∘to iff-iso-if-onlyif record { to = to ; from = from } = refl\nto∘from iff-iso-if-onlyif ⟨ A→B , B→A ⟩ = refl\n\n------------------------------------------------------------------------------\n-- logical True is a type with one member (unit)\ndata ⊤ : Set where\n tt :\n --\n ⊤\n\nη-⊤ : ∀ (w : ⊤) → tt ≡ w\nη-⊤ tt = refl\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\nto ⊤-identityˡ ⟨ ⊤ , a ⟩ = a\nfrom ⊤-identityˡ a = ⟨ tt , a ⟩\nfrom∘to ⊤-identityˡ ⟨ tt , a ⟩ = refl\nto∘from ⊤-identityˡ a = refl\n\n⊤-identityʳ : ∀ {A : Set} → (A × ⊤) ≃ A\nto ⊤-identityʳ ⟨ a , ⊤ ⟩ = a\nfrom ⊤-identityʳ a = ⟨ a , tt ⟩\nfrom∘to ⊤-identityʳ ⟨ a , tt ⟩ = refl\nto∘from ⊤-identityʳ a = refl\n\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-- a way to eliminate a sum (but easier to use pattern-matching to eliminate sums)\ncase-⊎ : ∀ {A B C : Set}\n → (A → C)\n → (B → C)\n → A ⊎ B\n -----------\n → C\ncase-⊎ f g (inj₁ x) = f x\ncase-⊎ f g (inj₂ x) = g x\n\n-- eta equivalence for sums\nη-⊎ : ∀ {A B : Set} (w : A ⊎ B) → case-⊎ inj₁ inj₂ w ≡ w\nη-⊎ (inj₁ _) = refl\nη-⊎ (inj₂ _) = refl\n\n-- generalization\nuniq-⊎ : ∀ {A B C : Set}\n → (h : A ⊎ B → C) → (w : A ⊎ B)\n → case-⊎ (h ∘ inj₁) (h ∘ inj₂) w ≡ h w\nuniq-⊎ h (inj₁ _) = refl\nuniq-⊎ h (inj₂ _) = refl\n\ninfix 1 _⊎_\n\n-- Bool ⊎ Tri has five members\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-- Sum is commutative up to isomorphism.\n⊎-comm : ∀ {A B : Set} → A ⊎ B ≃ B ⊎ A\nto ⊎-comm (inj₁ a) = inj₂ a\nto ⊎-comm (inj₂ b) = inj₁ b\nfrom ⊎-comm (inj₁ b) = inj₂ b\nfrom ⊎-comm (inj₂ a) = inj₁ a\nfrom∘to ⊎-comm (inj₁ _) = refl\nfrom∘to ⊎-comm (inj₂ _) = refl\nto∘from ⊎-comm (inj₁ _) = refl\nto∘from ⊎-comm (inj₂ _) = refl\n\n-- Sum is associative up to isomorphism.\n⊎-assoc : ∀ {A B C : Set} → (A ⊎ B) ⊎ C ≃ A ⊎ (B ⊎ C)\nto ⊎-assoc (inj₁ (inj₁ a)) = inj₁ a\nto ⊎-assoc (inj₁ (inj₂ b)) = inj₂ (inj₁ b)\nto ⊎-assoc (inj₂ c) = inj₂ (inj₂ c)\nfrom ⊎-assoc (inj₁ a) = inj₁ (inj₁ a)\nfrom ⊎-assoc (inj₂ (inj₁ b)) = inj₁ (inj₂ b)\nfrom ⊎-assoc (inj₂ (inj₂ c)) = inj₂ c\nfrom∘to ⊎-assoc (inj₁ (inj₁ _)) = refl\nfrom∘to ⊎-assoc (inj₁ (inj₂ _)) = refl\nfrom∘to ⊎-assoc (inj₂ _) = refl\nto∘from ⊎-assoc (inj₁ _) = refl\nto∘from ⊎-assoc (inj₂ (inj₁ _)) = refl\nto∘from ⊎-assoc (inj₂ (inj₂ _)) = refl\n\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⊥-elim : ∀ {A : Set}\n → ⊥\n --\n → A\n\n⊥-elim ()\n\nuniq-⊥ : ∀ {C : Set}\n → (h : ⊥ → C) → (w : ⊥)\n → ⊥-elim w ≡ h w\nuniq-⊥ h ()\n\n⊥-count : ⊥ → ℕ\n⊥-count ()\n\n-- Empty is the left unit of sum up to isomorphism.\n⊎-identityˡ : ∀ {A : Set} → ⊥ ⊎ A ≃ A\nto ⊎-identityˡ (inj₂ a) = a\nfrom ⊎-identityˡ a = inj₂ a\nfrom∘to ⊎-identityˡ (inj₂ _) = refl\nto∘from ⊎-identityˡ _ = refl\n\n-- Empty is the right unit of sum up to isomorphism.\n⊎-identityʳ : ∀ {A : Set} → A ⊎ ⊥ ≃ A\nto ⊎-identityʳ (inj₁ a) = a\nfrom ⊎-identityʳ a = inj₁ a\nfrom∘to ⊎-identityʳ (inj₁ _) = refl\nto∘from ⊎-identityʳ _ = refl\n\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-- →-elim works because eta-reduction for → is built in\n\nη-→ : ∀ {A B : Set}\n → (f : A → B)\n → (λ (x : A) → f x) ≡ f\nη-→ f = refl\n\n-- The function space A → B is called the exponential Bᴬ.\n-- Bool → Tri has 3² (9) members.\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\n------------------------------------------------------------------------------\n-- \"currying\" : functions of multiple parameters\n-- math : (p ^ n) ^ m = p ^ (n * m)\n-- types : (A ^ B) ^ C ≃ A ^ (B × C)\ncurrying : ∀ {A B C : Set} → (A → B → C) ≃ (A × B → C)\nto currying f = λ { ⟨ a , b ⟩ → f a b }\nfrom currying f = λ a b → f ⟨ a , b ⟩\nfrom∘to currying _ = refl\nto∘from currying f = extensionality λ { ⟨ x , y ⟩ → refl }\n\n-- math, : p ^ (n + m) = (p ^ n) * (p ^ m)\n-- types : (A ⊎ B → C) ≃ ((A → C) × (B → C))\n→-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B → C) ≃ ((A → C) × (B → C))\nto →-distrib-⊎ f = ⟨ (λ a → f (inj₁ a)) , (λ b → f (inj₂ b)) ⟩\nfrom →-distrib-⊎ ⟨ A→C , B→C ⟩ = λ { (inj₁ a) → A→C a ; (inj₂ b) → B→C b }\nfrom∘to →-distrib-⊎ _ = extensionality λ { (inj₁ x) → refl ; (inj₂ x) → refl }\nto∘from →-distrib-⊎ = λ{ ⟨ g , h ⟩ → refl }\n\n-- math : (p * n) ^ m = (p ^ m) * (n ^ m)\n-- types : (A → B × C) ≃ (A → B) × (A → C)\n→-distrib-× : ∀ {A B C : Set} → (A → B × C) ≃ (A → B) × (A → C)\nto →-distrib-× f = ⟨ (λ a → proj₁ (f a)) , (λ a → proj₂ (f a)) ⟩\nfrom →-distrib-× f = λ a → ⟨ proj₁ f a , proj₂ f a ⟩\nfrom∘to →-distrib-× = λ a→b×c → extensionality λ a → η-× (a→b×c a)\nto∘from →-distrib-× = λ { ⟨ _ , _ ⟩ → refl }\n\n×-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B) × C ≃ (A × C) ⊎ (B × C)\nto ×-distrib-⊎ ⟨ inj₁ a , c ⟩ = inj₁ ⟨ a , c ⟩\nto ×-distrib-⊎ ⟨ inj₂ b , c ⟩ = inj₂ ⟨ b , c ⟩\nfrom ×-distrib-⊎ (inj₁ ⟨ a , c ⟩) = ⟨ inj₁ a , c ⟩\nfrom ×-distrib-⊎ (inj₂ ⟨ b , c ⟩) = ⟨ inj₂ b , c ⟩\nfrom∘to ×-distrib-⊎ = λ { ⟨ inj₁ a , c ⟩ → refl ; ⟨ inj₂ b , c ⟩ → refl }\nto∘from ×-distrib-⊎ = λ { ( inj₁ ⟨ a , c ⟩) → refl ; ( inj₂ ⟨ b , c ⟩) → refl }\n\n-- Think of a counterexample to show this is not an isomorphism. TODO\n⊎-distrib-× : ∀ {A B C : Set} → (A × B) ⊎ C ≲ (A ⊎ C) × (B ⊎ C)\nto ⊎-distrib-× (inj₁ ⟨ a , b ⟩) = ⟨ inj₁ a , inj₁ b ⟩\nto ⊎-distrib-× (inj₂ c) = ⟨ inj₂ c , inj₂ c ⟩\nfrom ⊎-distrib-× ⟨ inj₁ a , inj₁ b ⟩ = inj₁ ⟨ a , b ⟩\nfrom ⊎-distrib-× ⟨ inj₁ a , inj₂ c ⟩ = inj₂ c\nfrom ⊎-distrib-× ⟨ inj₂ c , inj₁ b ⟩ = inj₂ c\nfrom ⊎-distrib-× ⟨ inj₂ c , inj₂ C ⟩ = inj₂ c -- inj₂ C also valid (loses info)\nfrom∘to ⊎-distrib-× = λ { (inj₁ ⟨ a , b ⟩) → refl ; (inj₂ c) → refl }\n\n×-distrib-→ : ∀ {A B C : Set} → (C → (A × B)) ≃ (C → A) × (C → B)\nto ×-distrib-→ f = ⟨ (λ c → proj₁ (f c)) , (λ c → proj₂ (f c)) ⟩\nfrom ×-distrib-→ f = λ c → ⟨ proj₁ f c , proj₂ f c ⟩\nfrom∘to ×-distrib-→ = λ { c→a×b → extensionality λ c → η-× (c→a×b c) }\nto∘from ×-distrib-→ = λ { ⟨ c→a , c→b ⟩ → refl }\n\n⊎-distrib-→ : ∀ {A B C : Set} → ((A ⊎ B) → C) ≃ (A → C) × (B → C)\nto ⊎-distrib-→ f = ⟨ (λ a → f (inj₁ a)) , (λ b → f (inj₂ b)) ⟩\nfrom ⊎-distrib-→ f = λ { (inj₁ a) → (proj₁ f a) ; (inj₂ b) → (proj₂ f b) }\n--from∘to ⊎-distrib-→ f = extensionality λ a⊎b → {!!} -- TODO\nfrom∘to ⊎-distrib-→ = λ { a⊎b→c → extensionality λ { (inj₁ a) → refl ; (inj₂ b) → refl } }\nto∘from ⊎-distrib-→ = λ { ⟨ a→c , b→c ⟩ → refl }\n\n-- PLFA exercise: a weak distributive law.\n⊎-weak-× : ∀ {A B C : Set} → (A ⊎ B) × C → A ⊎ (B × C)\n⊎-weak-× ⟨ inj₁ a , c ⟩ = inj₁ a\n⊎-weak-× ⟨ inj₂ b , c ⟩ = inj₂ ⟨ b , c ⟩\n-- State and prove the strong law, and explain the relationship. TODO\n\n-- SumOfProdImpProdOfSum : disjunct of conjuncts implies a conjunct of disjuncts.\n⊎×-implies-×⊎ : ∀ {A B C D : Set}\n → (A × B) ⊎ (C × D)\n → (A ⊎ C) × (B ⊎ D)\n⊎×-implies-×⊎ (inj₁ ⟨ a , b ⟩) = ⟨ inj₁ a , inj₁ b ⟩\n⊎×-implies-×⊎ (inj₂ ⟨ c , d ⟩) = ⟨ inj₂ c , inj₂ d ⟩\n\n-- the converse is NOT true\n×⊎-implies-⊎×-not : ∀ {A B C D : Set}\n → (A ⊎ C) × (B ⊎ D)\n → (A × B) ⊎ (C × D)\n×⊎-implies-⊎×-not ⟨ inj₁ a , inj₁ b ⟩ = inj₁ ⟨ a , b ⟩\n×⊎-implies-⊎×-not ⟨ inj₁ a , inj₂ d ⟩ = {!!} -- A × B ⊎ C × D -- not possible\n×⊎-implies-⊎×-not ⟨ inj₂ c , inj₁ b ⟩ = {!!} -- A × B ⊎ C × D -- not possible\n×⊎-implies-⊎×-not ⟨ inj₂ c , inj₂ d ⟩ = inj₂ ⟨ c , d ⟩\n\n\n\n", "meta": {"hexsha": "5624a26ee44325d39cc1f4b33584b39fbc52a9ea", "size": 11711, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x06-747Connectives-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/x06-747Connectives-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/x06-747Connectives-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": 30.6570680628, "max_line_length": 96, "alphanum_fraction": 0.4417214585, "num_tokens": 5018, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.7549149923816046, "lm_q1q2_score": 0.5867953187769144}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Several kinds of \"relatedness\" for containers such as equivalences,\n-- surjections and bijections\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Container.Related where\n\nopen import Level using (_⊔_)\nopen import Data.Container.Core\nimport Function.Related as Related\nopen import Relation.Binary\nopen import Data.Container.Membership\n\nopen 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 : ∀ {s p ℓ} → Kind → Container s p → Set ℓ →\n Preorder (s ⊔ p ⊔ ℓ) (s ⊔ p ⊔ ℓ) (p ⊔ ℓ)\n[ k ]-Order C X = Related.InducedPreorder₂ k (_∈_ {C = C} {X = X})\n\n[_]-Equality : ∀ {s p ℓ} → Symmetric-kind → Container s p → Set ℓ →\n Setoid (s ⊔ p ⊔ ℓ) (p ⊔ ℓ)\n[ k ]-Equality C X = Related.InducedEquivalence₂ k (_∈_ {C = C} {X = X})\n\ninfix 4 _∼[_]_\n_∼[_]_ : ∀ {s p x} {C : Container s p} {X : Set x} →\n ⟦ C ⟧ X → Kind → ⟦ C ⟧ X → Set (p ⊔ x)\n_∼[_]_ {C = C} {X} xs k ys = Preorder._∼_ ([ k ]-Order C X) xs ys\n", "meta": {"hexsha": "0117335e355bd590c78d8dd1202fe346385f943b", "size": 1380, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Related.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/Related.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/Related.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.5, "max_line_length": 72, "alphanum_fraction": 0.5144927536, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637612961505, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5867839094378574}} {"text": "-- Example usage of solver\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Category.Cartesian\n\nmodule Experiment.Categories.Solver.Category.Cartesian.Example\n {o ℓ e} {𝒞 : Category o ℓ e} (cartesian : Cartesian 𝒞) where\n\nopen import Experiment.Categories.Solver.Category.Cartesian cartesian\n\nopen Category 𝒞\nopen Cartesian cartesian\nopen HomReasoning\n\nprivate\n variable\n A B C D E F : Obj\n\nmodule _ {f : D ⇒ E} {g : C ⇒ D} {h : B ⇒ C} {i : A ⇒ B} where\n _ : (f ∘ g) ∘ id ∘ h ∘ i ≈ f ∘ (g ∘ h) ∘ i\n _ = solve ((∥-∥ :∘ ∥-∥) :∘ :id :∘ ∥-∥ :∘ ∥-∥) (∥-∥ :∘ (∥-∥ :∘ ∥-∥) :∘ ∥-∥) refl\n\nswap∘swap≈id :\n ∀ {A B} → swap {A}{B} ∘ swap {B}{A} ≈ id\nswap∘swap≈id {A} {B} =\n solve (:swap {∥ A ∥} {∥ B ∥} :∘ :swap)\n :id\n refl\n\n\nassocʳ∘assocˡ≈id : ∀ {A B C} → assocʳ {A}{B}{C} ∘ assocˡ {A}{B}{C} ≈ id\nassocʳ∘assocˡ≈id = solve (:assocʳ {∥ _ ∥} {∥ _ ∥} {∥ _ ∥} :∘ :assocˡ) :id refl\n\nmodule _ {f : B ⇒ C} (f′ : A ⇒ B) {g : E ⇒ F} {g′ : D ⇒ E} where\n ⁂-∘ : (f ⁂ g) ∘ (f′ ⁂ g′) ≈ (f ∘ f′) ⁂ (g ∘ g′)\n ⁂-∘ = solve lhs rhs refl where\n lhs = (∥ f ∥ :⁂ ∥ g ∥) :∘ (∥ f′ ∥ :⁂ ∥ g′ ∥)\n rhs = (∥ f ∥ :∘ ∥ f′ ∥) :⁂ (∥ g ∥ :∘ ∥ g′ ∥)\n\nmodule _ {A B C D} where\n pentagon′ : (id ⁂ assocˡ) ∘ assocˡ ∘ (assocˡ ⁂ id) ≈\n assocˡ ∘ assocˡ {A × B} {C} {D}\n pentagon′ = solve lhs rhs refl where\n lhs = (:id :⁂ :assocˡ) :∘ :assocˡ :∘ (:assocˡ :⁂ :id)\n rhs = :assocˡ :∘ :assocˡ {∥ A ∥ :× ∥ B ∥} {∥ C ∥} {∥ D ∥}\n\nmodule _ {A B C} where\n hexagon₁′ : (id ⁂ swap) ∘ assocˡ ∘ (swap ⁂ id) ≈\n assocˡ ∘ swap ∘ assocˡ {A}{B}{C}\n hexagon₁′ = solve lhs rhs refl where\n lhs = (:id :⁂ :swap) :∘ :assocˡ :∘ (:swap :⁂ :id)\n rhs = :assocˡ :∘ :swap :∘ :assocˡ {∥ A ∥}{∥ B ∥}{∥ C ∥}\n\nmodule _ {f : A ⇒ B} where\n commute : ⟨ ! , id ⟩ ∘ f ≈ ⟨ id ∘ π₁ , f ∘ π₂ ⟩ ∘ ⟨ ! , id ⟩\n commute = solve (:⟨ :! , :id ⟩ :∘ ∥ f ∥)\n (:⟨ :id :∘ :π₁ , ∥ f ∥ :∘ :π₂ ⟩ :∘ :⟨ :! , :id ⟩)\n refl\n\n_ : id {⊤} ≈ !\n_ = solve (∥ id !∥) :! refl\n\n_ : π₁ {⊤} {⊤} ≈ π₂\n_ = solve (:π₁ {:⊤} {:⊤}) :π₂ refl\n\nmodule _ {f : A ⇒ B} {g : C ⇒ D} where\n first↔second′ : first f ∘ second g ≈ second g ∘ first f\n first↔second′ = solve (:first ∥ f ∥ :∘ :second ∥ g ∥)\n (:second ∥ g ∥ :∘ :first ∥ f ∥)\n refl\n", "meta": {"hexsha": "ada976e329647f2da9e4ed4a042bc05f1b3f1e1d", "size": 2302, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Experiment/Categories/Solver/Category/Cartesian/Example.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/Categories/Solver/Category/Cartesian/Example.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/Categories/Solver/Category/Cartesian/Example.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": 31.5342465753, "max_line_length": 81, "alphanum_fraction": 0.454821894, "num_tokens": 1128, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637577007393, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.5867839069837242}} {"text": "{-# OPTIONS -v treeless.opt:20 #-}\nmodule _ where\n\nopen import Agda.Builtin.Nat renaming (_<_ to _ BAut A)\nBAut-trunc-path {i} A X = Trunc-elim λ p → [ pair= p prop-has-all-paths-↓ ]\n\nBAut-conn : ∀ {i} (A : Type i) → is-connected 0 (BAut A)\nfst (has-level-apply (BAut-conn A)) = [ pt (pBAut A) ]\nsnd (has-level-apply (BAut-conn A)) = Trunc-elim (λ { (X , tp) → <– (=ₜ-equiv [ A , [ idp ] ] [ X , tp ])\n (BAut-trunc-path A X tp) })\n", "meta": {"hexsha": "e6ca12224092ab74eadd52bd9b57576b71fddbd8", "size": 1117, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "core/lib/types/BAut.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/types/BAut.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/types/BAut.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": 36.0322580645, "max_line_length": 105, "alphanum_fraction": 0.545210385, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637361282707, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5867838922589235}} {"text": "-----------------------------------------------------------------------------------\n-- This file contains facts about equational reasoning pertaining to categories. --\n-----------------------------------------------------------------------------------\nmodule Category.CatEq where\n\nopen import Level\n\nopen import Category.Category\nopen import Setoid.Total\n\n-- The following models the communative square:\n--\n-- A ---f₁---> C\n-- | |\n-- f₃ f₂\n-- | |\n‌-- V V\n-- D ---f₄---> D\n-- \n-- However, as an equation.\ncomm-square : {l : Level}{ℂ : Cat {l}}{A B D C : Obj ℂ} \n → el (Hom ℂ A B) \n → el (Hom ℂ B C) \n → el (Hom ℂ A D) \n → el (Hom ℂ D C) \n → Set l\ncomm-square {ℂ = ℂ}{A}{C = C} f₁ f₂ f₃ f₄ = ⟨ Hom ℂ A C ⟩[ f₁ ○[ comp ℂ ] f₂ ≡ f₃ ○[ comp ℂ ] f₄ ]\n", "meta": {"hexsha": "2ddce15ab9feaedd670bd7e3ed0d5ffb26c7e879", "size": 845, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "setoid-cats/Category/CatEq.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/CatEq.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/CatEq.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": 30.1785714286, "max_line_length": 98, "alphanum_fraction": 0.3976331361, "num_tokens": 243, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9263037323284109, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.5867303041602275}} {"text": "------------------------------------------------------------------------------\n-- Agda-Prop Library.\n-- Theorems of ⇔ connective.\n------------------------------------------------------------------------------\n\nopen import Data.Nat using ( ℕ )\n\nmodule Data.PropFormula.Theorems.Biimplication ( n : ℕ ) where\n\n------------------------------------------------------------------------------\n\nopen import Data.PropFormula.Theorems.Classical n\nopen import Data.PropFormula.Theorems.Implication n\n using ( ⊃-to-¬∨; ⊃⊃-to-∧⊃; ∧⊃-to-⊃⊃ )\nopen import Data.PropFormula.Theorems.Negation n\n using ( ¬-equiv₁ ; ¬-equiv₂; ¬∨-to-⊃; ¬¬-equiv₁; ¬¬-equiv₂ )\nopen import Data.PropFormula.Syntax n\n\nopen import Function using ( _$_ )\n\n------------------------------------------------------------------------------\n\n-- Theorem.\n⇔-equiv₁\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ φ ⇔ ψ\n → Γ ⊢ (φ ⊃ ψ) ∧ (ψ ⊃ φ)\n\n-- Proof.\n⇔-equiv₁ {Γ}{φ}{ψ} Γ⊢φ⇔ψ =\n ∧-intro\n (⊃-intro\n (⇔-elim₁\n (assume φ)\n (weaken φ Γ⊢φ⇔ψ)))\n (⊃-intro\n (⇔-elim₂\n (assume ψ)\n (weaken ψ Γ⊢φ⇔ψ)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⇔-equiv₂\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ (φ ⊃ ψ) ∧ (ψ ⊃ φ)\n → Γ ⊢ φ ⇔ ψ\n\n-- Proof.\n⇔-equiv₂ {φ = φ}{ψ} Γ⊢⟪φ⊃ψ⟫∧⟪ψ⊃φ⟫ =\n ⇔-intro\n (⊃-elim\n (weaken φ (∧-proj₁ Γ⊢⟪φ⊃ψ⟫∧⟪ψ⊃φ⟫))\n (assume φ))\n (⊃-elim\n (weaken ψ (∧-proj₂ Γ⊢⟪φ⊃ψ⟫∧⟪ψ⊃φ⟫))\n (assume ψ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⇔-equiv\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ (φ ⇔ ψ) ⇔ ((φ ⊃ ψ) ∧ (ψ ⊃ φ))\n\n-- Proof.\n⇔-equiv {Γ}{φ}{ψ} =\n ⇔-intro\n (⇔-equiv₁\n (assume (φ ⇔ ψ)))\n (⇔-equiv₂\n (assume ((φ ⊃ ψ) ∧ (ψ ⊃ φ))))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⇔-assoc₁\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ φ ⇔ (ψ ⇔ γ)\n → Γ ⊢ (φ ⇔ ψ) ⇔ γ\n\n-- Proof.\n⇔-assoc₁ {Γ}{φ = φ}{ψ}{γ} thm =\n ⇔-intro\n (RAA\n (¬-elim\n (¬-intro\n (¬-elim\n (¬-intro\n (¬-elim\n (weaken φ $ weaken (ψ ⇔ γ) $ assume {Γ = Γ , φ ⇔ ψ} (¬ γ))\n (⇔-elim₁\n (⇔-elim₁\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ ⇔ γ} φ)\n (weaken φ $ weaken (ψ ⇔ γ)\n (weaken (¬ γ) $ assume (φ ⇔ ψ))))\n (⇔-elim₁\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ ⇔ γ} φ)\n (weaken φ $ weaken (ψ ⇔ γ) $ weaken (¬ γ) $\n weaken (φ ⇔ ψ) thm)))))\n (⇔-elim₂\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ} (ψ ⇔ γ))\n (weaken (ψ ⇔ γ) $ weaken (¬ γ) $ weaken (φ ⇔ ψ) thm))))\n (⇔-intro\n (⊥-elim γ\n (¬-elim\n (⊥-elim (¬ ψ)\n (¬-elim\n (¬-intro -- ¬ φ\n (¬-elim\n (weaken φ $ weaken ψ $ assume {Γ = Γ , φ ⇔ ψ} (¬ γ))\n (⇔-elim₁\n (⇔-elim₁\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ} φ)\n (weaken φ\n (weaken ψ\n (weaken (¬ γ)\n (assume (φ ⇔ ψ))))))\n (⇔-elim₁\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ} φ)\n (weaken φ $\n weaken ψ $ weaken (¬ γ) $ weaken (φ ⇔ ψ) thm)))))\n (⇔-elim₂ -- φ\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ} ψ)\n (weaken ψ (weaken (¬ γ) (assume (φ ⇔ ψ)))))))\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ} ψ)))\n (⊥-elim ψ\n (¬-elim\n (weaken γ $ assume {Γ = Γ , φ ⇔ ψ} (¬ γ))\n (assume {Γ = Γ , φ ⇔ ψ , ¬ γ} γ))))))\n (⇔-intro\n (⇔-elim₂\n (weaken φ $ assume γ)\n (⇔-elim₁\n (assume {Γ = Γ , γ} φ)\n (weaken φ $ weaken γ thm)))\n (⇔-elim₂\n (⇔-intro\n (weaken ψ $ weaken ψ $ assume γ)\n (weaken γ $ assume {Γ = Γ , γ} ψ))\n (weaken ψ $ weaken γ thm)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⇔-assoc₂\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ (φ ⇔ ψ) ⇔ γ\n → Γ ⊢ φ ⇔ (ψ ⇔ γ)\n\n-- Proof.\n⇔-assoc₂ {Γ}{φ}{ψ}{γ} thm =\n ⇔-intro\n (⇔-intro\n (⇔-elim₁\n (⇔-intro\n (weaken φ (assume {Γ = Γ , φ} ψ))\n (weaken ψ (weaken ψ (assume φ))))\n (weaken ψ (weaken φ thm)))\n (⇔-elim₁\n (weaken γ (assume φ))\n (⇔-elim₂\n (assume {Γ = Γ , φ} γ)\n (weaken γ (weaken φ thm)))))\n (RAA\n (¬-elim\n (¬-intro\n (¬-elim\n (¬-intro\n (¬-elim\n (weaken γ $ weaken (φ ⇔ ψ) $ assume {Γ = Γ , ψ ⇔ γ} (¬ φ))\n (⇔-elim₂\n (⇔-elim₂\n (assume {Γ = Γ , ψ ⇔ γ , ¬ φ , (φ ⇔ ψ)} γ)\n (weaken γ $ weaken (φ ⇔ ψ) $ weaken (¬ φ) $\n assume (ψ ⇔ γ)))\n (⇔-elim₂\n (assume {Γ = Γ , ψ ⇔ γ , ¬ φ , (φ ⇔ ψ)} γ)\n (weaken γ $ weaken (φ ⇔ ψ) $ weaken (¬ φ) $\n weaken (ψ ⇔ γ) thm)))))\n (⇔-elim₁\n (assume {Γ = Γ , ψ ⇔ γ , ¬ φ} (φ ⇔ ψ))\n (weaken (φ ⇔ ψ) (weaken (¬ φ) (weaken (ψ ⇔ γ) thm))))))\n (⇔-intro\n (⊥-elim ψ\n (¬-elim\n (weaken φ $ assume {Γ = Γ , ψ ⇔ γ} (¬ φ))\n (assume {Γ = Γ , ψ ⇔ γ , ¬ φ} φ)))\n (⊥-elim φ\n (¬-elim\n (⊥-elim (¬ ψ)\n (¬-elim\n (¬-intro\n (¬-elim\n (weaken γ $ weaken ψ $ assume {Γ = Γ , ψ ⇔ γ} (¬ φ))\n (⇔-elim₂\n (weaken γ $ assume {Γ = Γ , ψ ⇔ γ , ¬ φ} ψ)\n (⇔-elim₂\n (assume {Γ = Γ , ψ ⇔ γ , ¬ φ , ψ} γ)\n (weaken γ $ weaken ψ $ weaken (¬ φ) $\n weaken (ψ ⇔ γ) thm)))))\n (⇔-elim₁\n (assume {Γ = Γ , ψ ⇔ γ , ¬ φ} ψ)\n (weaken ψ (weaken (¬ φ) (assume (ψ ⇔ γ)))))))\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 ⇔-intro\n (⇔-elim₂ (assume ψ) (weaken ψ Γ⊢φ⇔ψ))\n (⇔-elim₁ (assume φ) (weaken φ Γ⊢φ⇔ψ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⊃-⇔-¬∨\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ (φ ⊃ ψ) ⇔ (¬ φ ∨ ψ)\n\n-- Proof.\n\n⊃-⇔-¬∨ {Γ}{φ}{ψ} =\n ⇔-intro\n (⊃-to-¬∨ (assume (φ ⊃ ψ)))\n (¬∨-to-⊃ (assume (¬ φ ∨ ψ)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nbicon₀-thm\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ φ ⇔ ψ → Γ ⊢ ¬ φ\n → Γ ⊢ ¬ ψ\n⇔-¬-to-¬ = bicon₀-thm\n\n-- Proof.\nbicon₀-thm {Γ}{φ}{ψ} Γ⊢φ⇔ψ Γ⊢¬ψ =\n ¬-equiv₂\n (⊃-intro\n (¬-elim\n (weaken ψ Γ⊢¬ψ)\n (⇔-elim₂\n (assume ψ)\n (weaken ψ Γ⊢φ⇔ψ))))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\nbicon₁-thm\n : ∀ {Γ} {φ ψ}\n → Γ ⊢ ¬ φ ⇔ ψ → Γ ⊢ φ\n → Γ ⊢ ¬ ψ\n¬⇔-to-¬ = bicon₁-thm\n\n-- Proof.\nbicon₁-thm {Γ}{φ}{ψ} Γ⊢¬φ⇔ψ Γ⊢φ =\n ¬-equiv₂\n (⊃-intro\n (¬-elim\n (⇔-elim₂\n (assume ψ)\n (weaken ψ Γ⊢¬φ⇔ψ))\n (weaken ψ Γ⊢φ)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬-equiv\n : ∀ {Γ} {φ}\n → Γ ⊢ ¬ φ ⇔ (φ ⊃ ⊥)\n\n-- Proof.\n¬-equiv {Γ}{φ} =\n ⇔-intro\n (¬-equiv₁ (assume (¬ φ)))\n (¬-equiv₂ (assume (φ ⊃ ⊥)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n¬¬-equiv\n : ∀ {Γ} {φ}\n → Γ ⊢ ¬ (¬ φ) ⇔ φ\n\n-- Proof.\n¬¬-equiv {Γ}{φ} =\n ⇔-intro\n (¬¬-equiv₁ (assume (¬ (¬ φ))))\n (¬¬-equiv₂ (assume φ))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⊃⊃-⇔-∧⊃\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ (φ ⊃ (ψ ⊃ γ)) ⇔ ((φ ∧ ψ) ⊃ γ)\n\n-- Proof.\n⊃⊃-⇔-∧⊃ {φ = φ}{ψ}{γ} =\n ⇔-intro\n (⊃⊃-to-∧⊃ (assume (φ ⊃ ψ ⊃ γ)))\n (∧⊃-to-⊃⊃ (assume (φ ∧ ψ ⊃ γ)))\n-------------------------------------------------------------------------- ∎\n\n-- Theorem.\n⇔-trans\n : ∀ {Γ} {φ ψ γ}\n → Γ ⊢ γ ⇔ φ\n → Γ ⊢ φ ⇔ ψ\n → Γ ⊢ γ ⇔ ψ\nsubst⊢⇔₁ = ⇔-trans\n\n-- Proof.\n⇔-trans {φ = φ}{ψ}{γ} Γ⊢γ⇔φ Γ⊢φ⇔ψ =\n ⇔-intro\n (⇔-elim₁\n (⇔-elim₁\n (assume γ)\n (weaken γ Γ⊢γ⇔φ))\n (weaken γ Γ⊢φ⇔ψ))\n (⇔-elim₂\n (⇔-elim₂\n (assume ψ)\n (weaken ψ Γ⊢φ⇔ψ))\n (weaken ψ Γ⊢γ⇔φ))\n-------------------------------------------------------------------------- ∎\n", "meta": {"hexsha": "5e9d0d01f978a72e36610da8e2d7f93474598338", "size": 8931, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Biimplication.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/Biimplication.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/Biimplication.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.5803571429, "max_line_length": 78, "alphanum_fraction": 0.2850744597, "num_tokens": 3602, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.7217432062975978, "lm_q1q2_score": 0.5866814708144502}} {"text": "{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule LogicalFramework.AdequacyTheorems where\n\nmodule Example5 where\n\n -- First-order logic with equality.\n open import Common.FOL.FOL-Eq public\n\n postulate\n A B C : Set\n f₁ : A → C\n f₂ : B → C\n\n g : (A → C) → (B → C) → A ∨ B → C\n g f₁ f₂ (inj₁ a) = f₁ a\n g f₁ f₂ (inj₂ b) = f₂ b\n\n g' : (A → C) → (B → C) → A ∨ B → C\n g' f₁ f₂ x = case f₁ f₂ x\n\nmodule Example7 where\n\n -- First-order logic with equality.\n open import Common.FOL.FOL-Eq public\n\n postulate\n C : D → D → Set\n d : ∀ {a} → C a a\n\n g : ∀ {a b} → a ≡ b → C a b\n g refl = d\n\n g' : ∀ {a b} → a ≡ b → C a b\n g' {a} h = subst (C a) h d\n\nmodule Example10 where\n\n -- First-order logic with equality.\n open import Common.FOL.FOL-Eq public\n\n postulate\n A B C : Set\n f₁ : A → C\n f₂ : B → C\n\n f : A ∨ B → C\n f (inj₁ a) = f₁ a\n f (inj₂ b) = f₂ b\n\n f' : A ∨ B → C\n f' = case f₁ f₂\n\nmodule Example20 where\n\n -- First-order logic with equality.\n open import Common.FOL.FOL-Eq public\n\n f : {A : D → Set}{t t' : D} → t ≡ t' → A t → A t'\n f {A} {t} {.t} refl At = d At\n where\n postulate d : A t → A t\n\n f' : {A : D → Set}{t t' : D} → t ≡ t' → A t → A t'\n f' {A} h At = subst A h At\n\nmodule Example30 where\n\n -- First-order logic with equality.\n open import Common.FOL.FOL-Eq public\n\n postulate\n A B C E : Set\n f₁ : A → E\n f₂ : B → E\n f₃ : C → E\n\n g : (A ∨ B) ∨ C → E\n g (inj₁ (inj₁ a)) = f₁ a\n g (inj₁ (inj₂ b)) = f₂ b\n g (inj₂ c) = f₃ c\n\n g' : (A ∨ B) ∨ C → E\n g' = case (case f₁ f₂) f₃\n\nmodule Example40 where\n\n infixl 9 _+_ _+'_\n infix 7 _≡_\n\n data ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n ℕ-ind : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n\n ℕ-ind A A0 h zero = A0\n ℕ-ind A A0 h (succ n) = h n (ℕ-ind A A0 h n)\n\n data _≡_ (x : ℕ) : ℕ → Set where\n refl : x ≡ x\n\n subst : (A : ℕ → Set) → ∀ {x y} → x ≡ y → A x → A y\n subst A refl Ax = Ax\n\n _+_ : ℕ → ℕ → ℕ\n zero + n = n\n succ m + n = succ (m + n)\n\n _+'_ : ℕ → ℕ → ℕ\n m +' n = ℕ-ind (λ _ → ℕ) n (λ x y → succ y) m\n\n -- Properties using pattern matching.\n succCong : ∀ {m n} → m ≡ n → succ m ≡ succ n\n succCong refl = refl\n\n +-rightIdentity : ∀ n → n + zero ≡ n\n +-rightIdentity zero = refl\n +-rightIdentity (succ n) = succCong (+-rightIdentity n)\n\n -- Properties using the basic inductive constants.\n succCong' : ∀ {m n} → m ≡ n → succ m ≡ succ n\n succCong' {m} h = subst (λ x → succ m ≡ succ x) h refl\n\n +'-leftIdentity : ∀ n → zero +' n ≡ n\n +'-leftIdentity n = refl\n\n +'-rightIdentity : ∀ n → n +' zero ≡ n\n +'-rightIdentity = ℕ-ind A A0 is\n where\n A : ℕ → Set\n A n = n +' zero ≡ n\n\n A0 : A zero\n A0 = refl\n\n is : ∀ n → A n → A (succ n)\n is n ih = succCong' ih\n\nmodule Example50 where\n\n infixl 10 _*_\n infixl 9 _+_\n infix 7 _≡_\n\n data ℕ : Set where\n zero : ℕ\n succ : ℕ → ℕ\n\n ℕ-ind : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n\n ℕ-ind A A0 h zero = A0\n ℕ-ind A A0 h (succ n) = h n (ℕ-ind A A0 h n)\n\n data _≡_ (x : ℕ) : ℕ → Set where\n refl : x ≡ x\n\n ℕ-rec : {A : Set} → A → (ℕ → A → A) → ℕ → A\n ℕ-rec {A} = ℕ-ind (λ _ → A)\n\n _+_ : ℕ → ℕ → ℕ\n m + n = ℕ-rec n (λ _ x → succ x) m\n\n +-0x : ∀ n → zero + n ≡ n\n +-0x n = refl\n\n +-Sx : ∀ m n → succ m + n ≡ succ (m + n)\n +-Sx m n = refl\n\n _*_ : ℕ → ℕ → ℕ\n m * n = ℕ-rec zero (λ _ x → n + x) m\n\n *-0x : ∀ n → zero * n ≡ zero\n *-0x n = refl\n\n *-Sx : ∀ m n → succ m * n ≡ n + m * n\n *-Sx m n = refl\n", "meta": {"hexsha": "97a4aac62bdeba15ab685a91c1610590ab2f370c", "size": 3654, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/LogicalFramework/AdequacyTheorems.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/AdequacyTheorems.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/AdequacyTheorems.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.4134078212, "max_line_length": 71, "alphanum_fraction": 0.4860426929, "num_tokens": 1543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.8128673155708976, "lm_q1q2_score": 0.586681462634661}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\n\n{- Move (parts of) faces of a cube around -}\n\nmodule lib.cubical.elims.CubeMove where\n\nsquare-push-rb : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ b : A}\n {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀}\n {p₋₁ : a₀₁ == a₁₁} (p₁₋ : a₁₀ == b) (q : b == a₁₁)\n → Square p₀₋ p₋₀ p₋₁ (p₁₋ ∙ q)\n → Square p₀₋ p₋₀ (p₋₁ ∙' ! q) p₁₋\nsquare-push-rb idp idp sq = sq\n\nprivate\n right-from-front-lemma : ∀ {i} {A : Type i}\n {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A}\n {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀}\n {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀}\n {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left\n\n {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁}\n {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁}\n (sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) -- right\n\n {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁}\n {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁}\n {sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back\n {sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ (p₋₀₁ ∙ idp)} -- top\n {sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ (p₋₁₁ ∙ idp)} -- bottom\n {sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front\n → Cube sq₋₋₀ sq₋₋₁ sq₀₋₋ (square-push-rb p₋₀₁ idp sq₋₀₋)\n (square-push-rb p₋₁₁ idp sq₋₁₋) (sq₁₋₋ ⊡h' !□h hid-square)\n → Cube sq₋₋₀ (sq₋₋₁ ⊡h hid-square) sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋\n right-from-front-lemma ids cu = cu\n\ncube-right-from-front : ∀ {i} {A : Type i}\n {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ b₀ b₁ : A}\n {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀}\n {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀}\n {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left\n\n {p₀₋₁ : a₀₀₁ == a₀₁₁}\n {p₋₀₁ : a₀₀₁ == b₀} {q₋₀₁ : b₀ == a₁₀₁}\n {r : b₀ == b₁}\n {p₋₁₁ : a₀₁₁ == b₁} {q₋₁₁ : b₁ == a₁₁₁}\n {p₁₋₁ : a₁₀₁ == a₁₁₁}\n (sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ r) -- right\n\n {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁}\n {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁}\n {sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back\n {sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ (p₋₀₁ ∙ q₋₀₁)} -- top\n {sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ (p₋₁₁ ∙ q₋₁₁)} -- bottom\n {sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front\n (sq' : Square r q₋₀₁ q₋₁₁ p₁₋₁)\n → Cube sq₋₋₀ sq₋₋₁ sq₀₋₋ (square-push-rb p₋₀₁ q₋₀₁ sq₋₀₋)\n (square-push-rb p₋₁₁ q₋₁₁ sq₋₁₋) (sq₁₋₋ ⊡h' !□h sq')\n → Cube sq₋₋₀ (sq₋₋₁ ⊡h sq') sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋\ncube-right-from-front sq₋₋₁ ids cu = right-from-front-lemma sq₋₋₁ cu\n", "meta": {"hexsha": "61c180876d7d7b1145f8febb60974b215cee2776", "size": 2338, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/cubical/elims/CubeMove.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/cubical/elims/CubeMove.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/cubical/elims/CubeMove.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.7096774194, "max_line_length": 69, "alphanum_fraction": 0.5222412318, "num_tokens": 1510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.5866814610841049}} {"text": "{-# OPTIONS --without-K #-}\nmodule sum where\n\nopen import level using (Level; _⊔_)\nopen import function.core\n\ninfixr 4 _,_\ninfixr 2 _×_\ninfixr 1 _⊎_\n\nrecord Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σ public\n\n_×_ : {l k : Level} (A : Set l) (B : Set k) → Set (l ⊔ k)\nA × B = Σ A λ _ → B\n\nuncurry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : (x : A) → (B x) → Set c}\n → ((x : A) → (y : B x) → C x y) → ((xy : Σ A B) → C (proj₁ xy) (proj₂ xy))\nuncurry f (a , b) = f a b\n\nuncurry' : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k}\n → (X → Y → Z)\n → (X × Y) → Z\nuncurry' f (x , y) = f x y\n\ndata _⊎_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where\n inj₁ : (x : A) → A ⊎ B\n inj₂ : (y : B) → A ⊎ B\n\n[_,⊎_] : ∀ {i i' j}{A : Set i}{A' : Set i'}{B : Set j}\n → (A → B) → (A' → B)\n → A ⊎ A' → B\n[ f ,⊎ f' ] (inj₁ a) = f a\n[ f ,⊎ f' ] (inj₂ a') = f' a'\n\nmap-⊎ : ∀ {i i' j j'}{A : Set i}{A' : Set i'}\n → {B : Set j}{B' : Set j'}\n → (A → B) → (A' → B')\n → A ⊎ A' → B ⊎ B'\nmap-⊎ g g' = [ inj₁ ∘' g ,⊎ inj₂ ∘' g' ]\n", "meta": {"hexsha": "5e37eb1d9c791b710707b0dc6a6ac10651099ec8", "size": 1124, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "sum.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/sum.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": "sum.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.4347826087, "max_line_length": 82, "alphanum_fraction": 0.4145907473, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.5866814594054462}} {"text": "-- Category of sets and functions\n\nmodule Control.Category.SetsAndFunctions where\n\nopen import Level using (zero; suc; _⊔_)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary\nopen import Data.Product\n\nopen import Axiom.FunctionExtensionality\n\nopen import Control.Category\nopen import Control.Category.Product\n\n-- Category SET\n\nFunctions : Set → Set → Setoid _ _\nFunctions A B = setoid (A → B)\n\nsetIsCategory : IsCategory Functions\nsetIsCategory = record\n { ops = record\n { id = λ x → x\n ; _⟫_ = λ f g x → g (f x)\n }\n ; laws = record\n { id-first = refl\n ; id-last = refl\n ; ∘-assoc = λ f → refl\n ; ∘-cong = λ{ refl refl → refl }\n }\n }\n\nSET : Category _ _ _\nSET = record { Hom = Functions; isCategory = setIsCategory }\n\n{-\ntimesProductStructure : (A B : Set) → ProductStructure SET A B\ntimesProductStructure A B = record\n { A×B = A × B\n ; fst = proj₁\n ; snd = proj₂\n }\n\n⟨_,_⟩ : {A B C : Set} (f : C → A) (g : C → B) → C → A × B\n⟨ f , g ⟩ = λ x → f x , g x\n\npairIsPair : {A B C : Set} (f : C → A) (g : C → B) →\n IsPair (timesProductStructure A B) f g ⟨ f , g ⟩\npairIsPair f g = record\n { β-fst = refl\n ; β-snd = refl\n }\n\nopen IsPair\n\npairPair : {A B C : Set} (f : C → A) (g : C → B) →\n Pair (timesProductStructure A B) f g\npairPair f g = record\n { ⟨f,g⟩ = ⟨ f , g ⟩\n ; isPair = pairIsPair f g\n ; unique = λ p → fun-ext (λ x → cong₂ (λ f g → f x , g x) (β-fst p) (β-snd p))\n }\n\ntimesIsProduct : (A B : Set) → Product SET A B\ntimesIsProduct A B = record\n { productStructure = timesProductStructure A B\n ; isProduct = record { pair = pairPair }\n }\n\n-- -}\n", "meta": {"hexsha": "008d33b7fe83b8144d223849f1cd11825571ab49", "size": 1627, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Control/Category/SetsAndFunctions.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/SetsAndFunctions.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/SetsAndFunctions.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": 22.5972222222, "max_line_length": 81, "alphanum_fraction": 0.6078672403, "num_tokens": 562, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.5866814594054461}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import lib.Basics\n\nmodule lib.types.FreeGroup where\n\nmodule _ {i} where\n\n private\n data #FreeGroup-aux (A : Type i) : Type i where\n #fg-nil : #FreeGroup-aux A\n _#fg::_ : A → #FreeGroup-aux A → #FreeGroup-aux A\n _#fg-inv::_ : A → #FreeGroup-aux A → #FreeGroup-aux A\n\n {- Is this okay? The template is to have 'data' here,\n - but then the β rules for paths will not typecheck.\n -}\n record #FreeGroup (A : Type i) : Type i where\n constructor\n #freegroup\n field\n #freegroup-proj : #FreeGroup-aux A\n #freegroup-unit : Unit → Unit\n\n FreeGroup : (A : Type i) → Type i\n FreeGroup A = #FreeGroup A\n\n module _ {A : Type i} where\n\n fg-nil : FreeGroup A\n fg-nil = #freegroup #fg-nil _\n\n infixr 60 _fg::_\n _fg::_ : A → FreeGroup A → FreeGroup A\n a fg:: (#freegroup fg _) = #freegroup (a #fg:: fg) _\n \n infixr 60 _fg-inv::_\n _fg-inv::_ : A → FreeGroup A → FreeGroup A\n a fg-inv:: (#freegroup fg _) = #freegroup (a #fg-inv:: fg) _\n\n postulate -- HIT\n fg-inv-l : ∀ (a : A) → (fg : FreeGroup A) → a fg-inv:: a fg:: fg == fg\n fg-inv-r : ∀ (a : A) → (fg : FreeGroup A) → a fg:: a fg-inv:: fg == fg\n\n postulate -- HIT\n FreeGroup-level : is-set (FreeGroup A)\n\n FreeGroup-is-set = FreeGroup-level\n\n module FreeGroupElim {j} {P : FreeGroup A → Type j}\n (p : (x : FreeGroup A) → is-set (P x)) (nil* : P fg-nil)\n (_fg::*_ : ∀ a {fg} (fg* : P fg) → P (a fg:: fg))\n (_fg-inv::*_ : ∀ a {fg} (fg* : P fg) → P (a fg-inv:: fg))\n (fg-inv-l* : ∀ a {fg} (fg* : P fg) → (a fg-inv::* (a fg::* fg*)) == fg* [ P ↓ fg-inv-l a fg ] )\n (fg-inv-r* : ∀ a {fg} (fg* : P fg) → (a fg::* (a fg-inv::* fg*)) == fg* [ P ↓ fg-inv-r a fg ]) where\n\n\n f : Π (FreeGroup A) P\n f = f-aux phantom phantom phantom where\n\n f-aux* : Π (#FreeGroup-aux A) (P ∘ (λ fg → #freegroup fg _))\n f-aux* #fg-nil = nil*\n f-aux* (a #fg:: fg) = a fg::* f-aux* fg\n f-aux* (a #fg-inv:: fg) = a fg-inv::* f-aux* fg\n\n f-aux : Phantom p → Phantom fg-inv-l* → Phantom fg-inv-r*\n → Π (FreeGroup A) P\n f-aux phantom phantom phantom (#freegroup fg _) = f-aux* fg\n\n postulate -- HIT\n fg-inv-l-β : ∀ a fg → apd f (fg-inv-l a fg) == fg-inv-l* a (f fg)\n fg-inv-r-β : ∀ a fg → apd f (fg-inv-r a fg) == fg-inv-r* a (f fg)\n\nopen FreeGroupElim public renaming (f to FreeGroup-elim)\n\nmodule FreeGroupRec {i} {A : Type i} {j} {B : Type j} (p : is-set B)\n (nil* : B) (_fg::*[_]_ : A → FreeGroup A → B → B) (_fg-inv::*[_]_ : A → FreeGroup A → B → B)\n (fg-inv-l* : ∀ a {fg} fg* → (a fg-inv::*[ a fg:: fg ] (a fg::*[ fg ] fg*)) == fg*)\n (fg-inv-r* : ∀ a {fg} fg* → (a fg::*[ a fg-inv:: fg ] (a fg-inv::*[ fg ] fg*)) == fg*) where\n\n private\n module M = FreeGroupElim (λ x → p) nil*\n (λ a {fg} fg* → a fg::*[ fg ] fg*)\n (λ a {fg} fg* → a fg-inv::*[ fg ] fg*)\n (λ a {fg} fg* → ↓-cst-in (fg-inv-l* a {fg} fg*))\n (λ a {fg} fg* → ↓-cst-in (fg-inv-r* a {fg} fg*))\n\n f : FreeGroup A → B\n f = M.f\n\nopen FreeGroupRec public renaming (f to FreeGroup-rec)\n", "meta": {"hexsha": "ccc7e3ede5a8a6a80adfbc92d807f33e95a57c79", "size": 3172, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/types/FreeGroup.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/FreeGroup.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/FreeGroup.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": 34.4782608696, "max_line_length": 110, "alphanum_fraction": 0.5094577554, "num_tokens": 1159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.5866814545402735}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Integers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Integer where\n\nimport Data.Nat.Show as ℕ\nopen import Data.Sign as Sign using (Sign)\nopen import Data.String.Base using (String; _++_)\n\n------------------------------------------------------------------------\n-- Integers, basic types and operations\n\nopen import Data.Integer.Base public\n\n------------------------------------------------------------------------\n-- Re-export queries from the properties modules\n\nopen import Data.Integer.Properties public\n using (_≟_; _≤?_)\n\n------------------------------------------------------------------------\n-- Conversions\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-- Deprecated\n\n-- Version 0.17\n\nopen import Data.Integer.Properties public\n using (◃-cong; drop‿+≤+; drop‿-≤-)\n renaming (◃-inverse to ◃-left-inverse)\n", "meta": {"hexsha": "691db53d568fd83279416bca8621e3e2ec13daaa", "size": 1172, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer.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.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.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.6363636364, "max_line_length": 72, "alphanum_fraction": 0.4291808874, "num_tokens": 222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430353105599, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.586608315456753}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Finite sets, based on AVL trees\n------------------------------------------------------------------------\n\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality using (_≡_)\n\nmodule Data.AVL.Sets\n {k ℓ} {Key : Set k} {_<_ : Rel Key ℓ}\n (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_)\n where\n\nimport Data.AVL as AVL\nopen import Data.Bool\nopen import Data.List as List using (List)\nopen import Data.Maybe as Maybe\nopen import Data.Product as Prod using (_×_; _,_; proj₁)\nopen import Data.Unit\nopen import Function\nopen import Level\n\n-- The set type. (Note that Set is a reserved word.)\n\nprivate\n open module S = AVL (const ⊤) isStrictTotalOrder\n public using () renaming (Tree to ⟨Set⟩)\n\n-- Repackaged functions.\n\nempty : ⟨Set⟩\nempty = S.empty\n\nsingleton : Key → ⟨Set⟩\nsingleton k = S.singleton k _\n\ninsert : Key → ⟨Set⟩ → ⟨Set⟩\ninsert k = S.insert k _\n\ndelete : Key → ⟨Set⟩ → ⟨Set⟩\ndelete = S.delete\n\n_∈?_ : Key → ⟨Set⟩ → Bool\n_∈?_ = S._∈?_\n\nheadTail : ⟨Set⟩ → Maybe (Key × ⟨Set⟩)\nheadTail s = Maybe.map (Prod.map proj₁ id) (S.headTail s)\n\ninitLast : ⟨Set⟩ → Maybe (⟨Set⟩ × Key)\ninitLast s = Maybe.map (Prod.map id proj₁) (S.initLast s)\n\nfromList : List Key → ⟨Set⟩\nfromList = S.fromList ∘ List.map (λ k → (k , _))\n\ntoList : ⟨Set⟩ → List Key\ntoList = List.map proj₁ ∘ S.toList\n", "meta": {"hexsha": "78a6335e5ebe75f7a2a7b8be9677dd5fd8eab4c6", "size": 1415, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/AVL/Sets.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/AVL/Sets.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/AVL/Sets.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.3965517241, "max_line_length": 72, "alphanum_fraction": 0.6091872792, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.5866083147861295}} {"text": "------------------------------------------------------------------------\n-- Coinductive lists\n------------------------------------------------------------------------\n\nmodule Data.Colist where\n\nopen import Coinduction\nopen import Data.Bool using (Bool; true; false)\nopen import Data.Maybe using (Maybe; nothing; just)\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Data.Conat\nopen import Data.List using (List; []; _∷_)\nopen import Data.List.NonEmpty using (List⁺; _∷_)\n renaming ([_] to [_]⁺)\nopen import Data.BoundedVec.Inefficient as BVec\n using (BoundedVec; []; _∷_)\nopen import Data.Product using (_,_)\nopen import Data.Function\nopen import Relation.Binary\n\n------------------------------------------------------------------------\n-- The type\n\ninfixr 5 _∷_\n\ndata Colist (A : Set) : Set where\n [] : Colist A\n _∷_ : (x : A) (xs : ∞ (Colist A)) → Colist A\n\ndata Any {A} (P : A → Set) : Colist A → Set 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\ndata All {A} (P : A → Set) : Colist A → Set where\n [] : All P []\n _∷_ : ∀ {x xs} (px : P x) (pxs : ∞ (All P (♭ xs))) → All P (x ∷ xs)\n\n------------------------------------------------------------------------\n-- Some operations\n\nnull : ∀ {A} → Colist A → Bool\nnull [] = true\nnull (_ ∷ _) = false\n\nlength : ∀ {A} → Colist A → Coℕ\nlength [] = zero\nlength (x ∷ xs) = suc (♯ length (♭ xs))\n\nmap : ∀ {A B} → (A → B) → Colist A → Colist B\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ ♯ map f (♭ xs)\n\nfromList : ∀ {A} → List A → Colist A\nfromList [] = []\nfromList (x ∷ xs) = x ∷ ♯ fromList xs\n\ntake : ∀ {A} (n : ℕ) → Colist A → BoundedVec A n\ntake zero xs = []\ntake (suc n) [] = []\ntake (suc n) (x ∷ xs) = x ∷ take n (♭ xs)\n\nreplicate : ∀ {A} → Coℕ → A → Colist A\nreplicate zero x = []\nreplicate (suc n) x = x ∷ ♯ replicate (♭ n) x\n\nlookup : ∀ {A} → ℕ → Colist A → Maybe A\nlookup n [] = nothing\nlookup zero (x ∷ xs) = just x\nlookup (suc n) (x ∷ xs) = lookup n (♭ xs)\n\ninfixr 5 _++_\n\n_++_ : ∀ {A} → Colist A → Colist A → Colist A\n[] ++ ys = ys\n(x ∷ xs) ++ ys = x ∷ ♯ (♭ xs ++ ys)\n\nconcat : ∀ {A} → Colist (List⁺ A) → Colist A\nconcat [] = []\nconcat ([ x ]⁺ ∷ xss) = x ∷ ♯ concat (♭ xss)\nconcat ((x ∷ xs) ∷ xss) = x ∷ ♯ concat (xs ∷ xss)\n\n[_] : ∀ {A} → A → Colist A\n[ x ] = x ∷ ♯ []\n\n------------------------------------------------------------------------\n-- Equality and other relations\n\n-- xs ≈ ys means that xs and ys are equal.\n\ninfix 4 _≈_\n\ndata _≈_ {A} : (xs ys : Colist A) → Set where\n [] : [] ≈ []\n _∷_ : ∀ x {xs ys} (xs≈ : ∞ (♭ xs ≈ ♭ ys)) → x ∷ xs ≈ x ∷ ys\n\n-- x ∈ xs means that x is a member of xs.\n\ninfix 4 _∈_\n\ndata _∈_ {A : Set} : A → Colist 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 : Set} : Colist A → Colist 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 = Colist A\n ; _≈_ = _≈_\n ; isEquivalence = record\n { refl = refl\n ; sym = sym\n ; trans = trans\n }\n }\n where\n refl : Reflexive _≈_\n refl {[]} = []\n refl {x ∷ xs} = x ∷ ♯ refl\n\n sym : Symmetric _≈_\n sym [] = []\n sym (x ∷ xs≈) = x ∷ ♯ sym (♭ xs≈)\n\n trans : Transitive _≈_\n trans [] [] = []\n trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈)\n\nposet : Set → Poset\nposet A = record\n { carrier = Colist A\n ; _≈_ = _≈_\n ; _≤_ = _⊑_\n ; isPartialOrder = record\n { isPreorder = record\n { isEquivalence = Setoid.isEquivalence (setoid A)\n ; reflexive = reflexive\n ; trans = trans\n ; ∼-resp-≈ = ((λ {_} → ⊑-resp-≈ˡ) , λ {_} → ⊑-resp-≈ʳ)\n }\n ; antisym = antisym\n }\n }\n where\n reflexive : _≈_ ⇒ _⊑_\n reflexive [] = []\n reflexive (x ∷ xs≈) = x ∷ ♯ reflexive (♭ xs≈)\n\n trans : Transitive _⊑_\n trans [] _ = []\n trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈)\n\n ⊑-resp-≈ˡ : {xs : Colist A} → (λ ys → xs ⊑ ys) Respects _≈_\n ⊑-resp-≈ˡ _ [] = []\n ⊑-resp-≈ˡ (x ∷ xs≈) (.x ∷ p) = x ∷ ♯ ⊑-resp-≈ˡ (♭ xs≈) (♭ p)\n\n ⊑-resp-≈ʳ : {ys : Colist A} → (λ xs → xs ⊑ ys) Respects _≈_\n ⊑-resp-≈ʳ [] _ = []\n ⊑-resp-≈ʳ (x ∷ xs≈) (.x ∷ p) = x ∷ ♯ ⊑-resp-≈ʳ (♭ xs≈) (♭ p)\n\n antisym : Antisymmetric _≈_ _⊑_\n antisym [] [] = []\n antisym (x ∷ p₁) (.x ∷ p₂) = x ∷ ♯ antisym (♭ p₁) (♭ p₂)\n\nmap-cong : ∀ {A B} (f : A → B) → _≈_ =[ map f ]⇒ _≈_\nmap-cong f [] = []\nmap-cong f (x ∷ xs≈) = f x ∷ ♯ map-cong f (♭ xs≈)\n\ntake-⊑ : ∀ {A} n (xs : Colist A) →\n let toColist = fromList ∘ BVec.toList in\n toColist (take n xs) ⊑ xs\ntake-⊑ zero xs = []\ntake-⊑ (suc n) [] = []\ntake-⊑ (suc n) (x ∷ xs) = x ∷ ♯ take-⊑ n (♭ xs)\n", "meta": {"hexsha": "94519bcc9d6641c57639e2c66c8ee81831c97e81", "size": 5206, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Colist.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/Colist.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/Colist.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.2934782609, "max_line_length": 72, "alphanum_fraction": 0.4214368037, "num_tokens": 2031, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.5865258631231839}} {"text": "open import Agda.Primitive\nopen import Agda.Builtin.Equality renaming (_≡_ to _==_) --(( If I want to rename the built-in equality ))\n\n-- What follows is an attempt to formalize multicategories. For this purpose, we also need to define lists, since the source of a multimap in a multicategory is a list.\n-- For the moment, I do not try to prove that the lists an the associated concatenation form a monoid (because I do not know if this is useful or not).\n\nmodule MultiCategories where\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\n\n\n -- ** Lists **\n\n -- We first define lists\n data List {l : Level} (A : Set l) : Set l where\n [] : List A\n _::_ : A → List A → List A\n\n infixr 30 _::_\n\n open List\n\n -- We define equality on lists, that extends the built-in equality (since for the moment, we dont need other definitions of equality → but maybe we could do something more general by asking the \"equality\" as a parameter ?)\n data _≡ᴸ_ {l : Level} {A : Set l} : (u v : List {l} A) → Set (lsuc l) where\n eq-nil : [] ≡ᴸ []\n eq-cons : ∀ (x y : A) (su sv : List A) → (x == y) → (su ≡ᴸ sv) → ( (x :: su) ≡ᴸ (y :: sv))\n\n -- We define the mapping of lists\n list-map : ∀ {l : Level} {A B : Set l} → (f : A → B) → List A → List B\n list-map f [] = []\n list-map f (x :: u) = ((f x) :: (list-map f u))\n\n -- We define the concatenation of lists\n _++_ : ∀ {l}{A : Set l} → List A → List A → List A\n [] ++ ys = ys\n (x :: xs) ++ ys = x :: (xs ++ ys)\n\n -- We define a fold function\n fold : ∀ {l : Level} {A B : Set l} → (A → B → B) → B → List A → B\n fold _⊗_ e [] = e\n fold _⊗_ e (x :: xs) = x ⊗ (fold _⊗_ e xs)\n\n -- We define a flatten function\n flatten : ∀ {l : Level} {A : Set l} → (u : List ( List A)) → (List A)\n flatten [] = []\n flatten (x :: xs) = x ++ (flatten xs)\n -- (I wanted to do this with the above fold function, which would be more elegant, but I don't know why, I miserably failed at it - must be tired)\n\n -- We define a function that takes a list of functions and a list of arguments and apply the functions point to point\n list-apply : ∀ {l : Level} {A B : Set l} → (list-f : List (A → B)) → (list-arg : List A) → List B\n list-apply [] [] = []\n list-apply (f :: fs) [] = []\n list-apply [] (x :: xs) = []\n list-apply (f :: fs) (x :: xs) = (f x) :: (list-apply fs xs)\n -- The two cases in the middle should be forbidden, but I don't know how to do this\n\n\n -- ** Multicategories **\n\n -- -- We first define the multimaps on a set\n -- data Multimap {l : Level} {O : Setl l} : Set l where\n -- map : ()\n\n record MultiCategory {l : Level} : Set (lsuc l) where\n field\n -- Objects and maps\n object : Set l\n multimap : Set l\n sources : ∀ (m : multimap) → List object\n target : ∀ (m : multimap) → object\n -- Composition and associated equations / conditions\n _∘_ : ∀ (f : multimap) → (list : List multimap) → multimap\n plug : ∀ {g : multimap} → {f : multimap} → {list : List multimap} → {g == (f ∘ list)} → (sources f) ≡ᴸ (list-map target list)\n dom-comp : ∀ {f : multimap} → {list : List multimap} → ((flatten (list-map sources list)) ≡ᴸ (sources (f ∘ list)))\n comp-codom : ∀ (f : multimap) → (list : List multimap) → (target f == target (f ∘ list))\n -- Identities and associated equations / conditions\n id : ∀ (o : object) → multimap\n id-dom-codom : ∀ (o : object) → (sources (id o) == o :: [] )\n id-codom : ∀ (o : object) → (target (id o) == o)\n id-left : ∀ {o : object} {f : multimap} → {f == id o} → (list : List multimap) → ( (f ∘ list) == f)\n id-rigth : ∀ {f : multimap} {list : List multimap} → {list ≡ᴸ (list-map id (sources f))} → ((f ∘ list) == f)\n -- Associativity\n assoc : ∀ {f : multimap} {list-g : List multimap} {list-h : List (List multimap)} → (f ∘ (list-apply (list-map _∘_ list-g) list-h)) == ( (f ∘ list-g) ∘ (flatten list-h))\n\n open MultiCategory\n\n -- List over a list\n data ListOver {l : Level} {A : Set l} (B : A → Set l) : List A → Set l where\n [[]] : ListOver B []\n _:::_ : ∀ {x xs} → (y : B x) → (ys : ListOver B xs) → ListOver B (x :: xs)\n\n infixr 25 _:::_\n\n over-map : ∀ {l : Level} {A : Set l} {B : A → Set l} {xs} {C : Set l} → (∀ {x} → B x → C) → ListOver B xs → List C\n over-map f [[]] = []\n over-map f (y ::: ys) = f y :: over-map f ys\n\n over-over-map : ∀ {l : Level} {A : Set l} {B : A → Set l} {xs} {C : A → Set l} → (∀ {x} → B x → C x) → ListOver B xs → ListOver C xs\n over-over-map f [[]] = [[]]\n over-over-map f (y ::: ys) = f y ::: over-over-map f ys\n\n over-lift : ∀ {l : Level} {A : Set l} (list : List A) → ListOver (λ x → A) list\n over-lift [] = [[]]\n over-lift (y :: ys) = y ::: (over-lift ys)\n\n over-flatten : ∀ {l : Level} {A B : Set l} {list : List A} (list-ov : ListOver (λ x → List B) list) → List B\n over-flatten [[]] = []\n over-flatten (x ::: xs) = x ++ (over-flatten xs)\n\n -- Dependent sum\n record Σ {l} (A : Set l) (B : A → Set l) : Set l where\n constructor ⟨_,_⟩\n field\n π₁ : A\n π₂ : B π₁\n\n open Σ\n\n -- Shortcuts to map the projections on lists when the dependent sum is a \"product\"\n list-π₁ : ∀ {l : Level} {A : Set l} {B} (list : List ( Σ {l} A B)) → List A\n list-π₁ list = list-map π₁ list\n\n list-π₂ : ∀ {l : Level} {A C : Set l} (list : List ( Σ {l} A ( λ x → C))) → List C\n list-π₂ list = list-map π₂ list\n\n\n\n -- A more dependent attempt at multicategories\n record MultiCategory2 {l : Level} : Set (lsuc l) where\n field\n object : Set l\n multimap : List object → object → Set l\n 𝟙 : ∀ {x} → multimap (x :: []) x\n _•_ : ∀ {ys x} → multimap ys x → ∀ (gs : ListOver (λ y → Σ (List object) (λ zs → multimap zs y)) ys) →\n multimap (flatten (over-map π₁ gs)) x\n -- Another attempt to define multimaps, \"putting the dependance elsewhere\"\n _●_ : ∀ {x : object} {ys : List (Σ (List object) (λ x → object))} → multimap (list-π₂ ys) x → ListOver (λ y → multimap (π₁ y) (π₂ y)) ys → multimap (flatten (list-π₁ ys)) x\n -- here complications start\n -- 𝟙-left : ∀ {ys x} → (f : multimap ys x) → 𝟙 • (⟨ ys , f ⟩ ::: [[]]) == f\n -- 𝟙-right : ∀ {ys x} → (f : multimap ys x) → f • (over-over-map ? (over-lift ys)) == f\n --(ListOver ( λ y → ⟨ x ::: [[]] , 𝟙 ⟩ ) ys) == f\n -- Attempt with the alternative composition\n 𝟙-left-● : ∀ {x ys} → (f : multimap ys x) → 𝟙 ● (f ::: [[]]) == f -- Here it seems that we have a lemma to prove to say that ys = (ys ++ flatten (list-map π₁ [])). Do we do it locally or would it be useful to have a more genral lemma ?\n\n-- Here I tried to fix 𝟙-left and to define 𝟙-right, but I did not manage to do it, it both cases. Maybe we should revise the definition of _•_ ?\n-- Agda seems to struggle with the fact that thnigs that should be equal are not equal by definition (conversion/reduction problems). Maybe there are some lemmas to prove here.\n-- Also, I do not understand why we use the \"over-map\" : it would feel more natural to me if, once we lift a list to a dependent one, and use dependant lists, we only use dependeant lists, that's why I defined over-lift and over-over-map. (I also defined an \"over-flatten\" but don't know if it's useful)\n", "meta": {"hexsha": "efeb175ca824876233bf98b933f03ef3d3ba58f5", "size": 7290, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Experimental/MultiCategories.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/MultiCategories.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/MultiCategories.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": 48.2781456954, "max_line_length": 303, "alphanum_fraction": 0.5673525377, "num_tokens": 2512, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.5865258631231839}} {"text": "module Ex3Lec where\n\n----------------------------------------------------------------------------\n-- EXERCISE 3 -- MONADS FOR HUTTON'S RAZOR\n--\n-- VALUE: 15%\n-- DEADLINE: 5pm, Friday 20 November (week 9)\n--\n-- DON'T SUBMIT, COMMIT!\n--\n-- The purpose of this exercise is to introduce you to some useful\n-- mathematical structures and build good tools for working with\n-- vectors\n----------------------------------------------------------------------------\n\nopen import CS410-Prelude\nopen import CS410-Monoid\nopen import CS410-Nat\nopen import CS410-Vec\nopen import CS410-Functor\n\n-- HINT: your tasks are heralded with the eminently searchable tag, \"???\"\n\n----------------------------------------------------------------------------\n-- HUTTON'S RAZOR\n----------------------------------------------------------------------------\n\nHVal : Set -- the set of *values* for Hutton's Razor\nHVal = Two + Nat -- Booleans or natural numbers\n\nfoo : HVal\nfoo = tt , ff\n\ngoo : HVal\ngoo = ff , 42\n\n\n\ndata HExp (X : Set) : Set where\n var : X -> HExp X -- variables\n val : HVal -> HExp X -- values\n _+H_ _>=H_ : (e1 e2 : HExp X) -> HExp X -- addition, comparison\n ifH_then_else_ : (e1 e2 e3 : HExp X) -> HExp X -- conditional\n\n_>=2_ : Nat -> Nat -> Two\nx >=2 zero = tt\nzero >=2 suc _ = ff\nsuc m >=2 suc n = m >=2 n\n\n\n----------------------------------------------------------------------------\n-- ??? 3.1 the HExp syntax-with-substitution monad (score: ? / 2)\n----------------------------------------------------------------------------\n\n-- Show that HExp is a monad, where the \"bind\" operation performs\n-- simultaneous substitution (transforming all the variables in a term).\n\nhExpMonad : Monad HExp\nhExpMonad = record { return = {!!} ; _>>=_ = {!!} }\n\n\n----------------------------------------------------------------------------\n-- ??? 3.2 the error management monad (score: ? / 1)\n----------------------------------------------------------------------------\n\n-- show that \"+ E\" is monadic, generalising the \"Maybe\" monad by allowing\n-- some sort of error report\n\nerrorMonad : (E : Set) -> Monad \\ V -> V + E -- \"value or error\"\nerrorMonad E = {!!}\n\n\n----------------------------------------------------------------------------\n-- ??? 3.3 the environment monad transformer (score: ? / 1)\n----------------------------------------------------------------------------\n\n-- show that \"+ E\" is monadic, generalising the \"Maybe\" monad by allowing\n-- some sort of error report\n\nenvMonad : (G : Set){M : Set -> Set} -> Monad M ->\n Monad \\ V -> G -> M V -- \"computation in an environment\"\nenvMonad G MM = {!!} where\n open Monad MM\n\n----------------------------------------------------------------------------\n-- ??? 3.4 interpreting Hutton's Razor (score: ? / 3)\n----------------------------------------------------------------------------\n\n-- Implement an interpreter for Hutton's Razor.\n-- You will need to construct a type to represent possible run-time errors.\n-- Ensure that addition and comparison act on numbers, not Booleans.\n-- Ensure that the condition in an \"if\" is a Boolean, not a number.\n\ndata InterpretError : Set where\n\n-- helpful things to build\n\nEnv : Set -> Set -- an environment for a given set of variables\nEnv X = X -> HVal\n\nCompute : Set{- variables -} -> Set{- values -} -> Set\nCompute X V = Env X -> V + InterpretError -- how to compute a V\n\ncomputeMonad : {X : Set} -> Monad (Compute X)\ncomputeMonad = {!!} -- build this from the above parts\n\n-- This operation should explain how to get the value of a variable\n-- from the environment.\nvarVal : {X : Set} -> X -> Compute X HVal\nvarVal x = {!!}\n\n-- These operations should ensure that you get the sort of value\n-- that you want, in order to ensure that you don't do bogus\n-- computation.\nmustBeNat : {X : Set} -> HVal -> Compute X Nat\nmustBeNat v = {!!}\n\nmustBeTwo : {X : Set} -> HVal -> Compute X Two\nmustBeTwo v = {!!}\n\n-- Now, you're ready to go. Don't introduce the environent explicitly.\n-- Use the monad to thread it.\n\ninterpret : {X : Set} -> HExp X -> Compute X HVal\ninterpret {X} = go where\n open Monad (envMonad (Env X) (errorMonad InterpretError))\n go : HExp X -> Env X -> HVal + InterpretError\n go t = {!!}\n", "meta": {"hexsha": "2f3d8f69983ebbbfdb77b9f330f74d67ccb09bd3", "size": 4344, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ex3Lec.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": "Ex3Lec.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": "Ex3Lec.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": 33.6744186047, "max_line_length": 77, "alphanum_fraction": 0.494014733, "num_tokens": 1018, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473713594991, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.5865067847333149}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.PtdAdjoint\nopen import homotopy.SuspAdjointLoop\nopen import cohomology.WithCoefficients\n\nmodule cohomology.SuspAdjointLoopIso where\n\nmodule SuspAdjointLoopIso {i} where\n\n private\n hadj : HomAdjoint {i} {i} Σ⊣Ω.SuspFunctor Σ⊣Ω.LoopFunctor\n hadj = counit-unit-to-hom Σ⊣Ω.adj\n\n module A = HomAdjoint hadj\n\n module _ (X Y : Ptd i) where\n\n abstract\n pres-comp : (h₁ h₂ : ⊙Susp X ⊙→ ⊙Ω Y)\n → –> (A.eq X (⊙Ω Y)) (⊙Ω-∙ ⊙∘ ⊙fanout h₁ h₂)\n == ⊙Ω-∙ ⊙∘ ⊙fanout (–> (A.eq X (⊙Ω Y)) h₁) (–> (A.eq X (⊙Ω Y)) h₂)\n pres-comp h₁ h₂ =\n B.nat-cod h₁ h₂ ⊙Ω-∙\n ∙ ap (_⊙∘ ⊙fanout (–> (A.eq X (⊙Ω Y)) h₁) (–> (A.eq X (⊙Ω Y)) h₂))\n arr2-lemma\n where\n module A× = RightAdjoint× hadj\n module B = RightAdjointBinary hadj\n\n ap2-lemma : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}\n (f : A × B → C) {r s : A × B} (p : r == s)\n → ap f p == ap2 (curry f) (ap fst p) (ap snd p)\n ap2-lemma f idp = idp\n\n ⊙ap2-lemma : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k}\n (f : X ⊙× Y ⊙→ Z)\n → ⊙Ω-fmap f == ⊙Ω-fmap2 f ⊙∘ ⊙fanout (⊙Ω-fmap ⊙fst) (⊙Ω-fmap ⊙snd)\n ⊙ap2-lemma (f , idp) = ⊙λ= (ap2-lemma f) idp\n\n arr2-lemma : B.arr2 ⊙Ω-∙ == ⊙Ω-∙\n arr2-lemma =\n ⊙Ω-fmap ⊙Ω-∙ ⊙∘ A×.⊙out _ _\n =⟨ ⊙ap2-lemma ⊙Ω-∙ |in-ctx _⊙∘ A×.⊙out _ _ ⟩\n (⊙Ω-fmap2 ⊙Ω-∙ ⊙∘ A×.⊙into _ _) ⊙∘ A×.⊙out _ _\n =⟨ ⊙∘-assoc (⊙Ω-fmap2 ⊙Ω-∙) (A×.⊙into _ _) (A×.⊙out _ _) ⟩\n ⊙Ω-fmap2 ⊙Ω-∙ ⊙∘ (A×.⊙into _ _ ⊙∘ A×.⊙out _ _)\n =⟨ A×.⊙into-out _ _ |in-ctx ⊙Ω-fmap2 ⊙Ω-∙ ⊙∘_ ⟩\n ⊙Ω-fmap2 ⊙Ω-∙\n =⟨ ⊙Ω-fmap2-∙ ⟩\n ⊙Ω-∙ ∎\n\n iso : Trunc-⊙→Ω-group (⊙Susp X) Y ≃ᴳ Trunc-⊙→Ω-group X (⊙Ω Y)\n iso = Trunc-group-emap (≃-to-≃ᴳˢ (A.eq X (⊙Ω Y)) pres-comp)\n\n abstract\n nat-dom : {X Y : Ptd i} (f : X ⊙→ Y) (Z : Ptd i)\n → fst (iso X Z) ∘ᴳ Trunc-⊙→Ω-group-fmap-dom (⊙Susp-fmap f) Z\n == Trunc-⊙→Ω-group-fmap-dom f (⊙Ω Z) ∘ᴳ fst (iso Y Z)\n nat-dom f Z = group-hom= $ λ= $ Trunc-elim\n (λ _ → =-preserves-level Trunc-level)\n (λ g → ap [_] (! (A.nat-dom f (⊙Ω Z) g)))\n", "meta": {"hexsha": "e4569cc867ec0a8568e9b7100d61a8dec48d1dc6", "size": 2233, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/SuspAdjointLoopIso.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/SuspAdjointLoopIso.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/SuspAdjointLoopIso.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": 34.890625, "max_line_length": 77, "alphanum_fraction": 0.4751455441, "num_tokens": 1149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391599428538, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.5863971721654916}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nmodule Desc where\n\n--********************************************\n-- Prelude\n--********************************************\n\n-- Some preliminary stuffs, to avoid relying on the stdlib\n\n--****************\n-- Universe polymorphism\n--****************\n\ndata Level : Set where\n zero : Level\n suc : Level -> Level\n\n{-# BUILTIN LEVEL Level #-}\n{-# BUILTIN LEVELZERO zero #-}\n{-# BUILTIN LEVELSUC suc #-}\n\nmax : Level -> Level -> Level\nmax zero m = m\nmax (suc n) zero = suc n\nmax (suc n) (suc m) = suc (max n m)\n\n{-# BUILTIN LEVELMAX max #-}\n\ndata Lifted {l : Level} (A : Set l) : Set (suc l) where\n lifter : A → Lifted A\n\nlift : {i : Level} -> Set i -> Set (suc i) \nlift x = Lifted x\n\nunlift : {l : Level}{A : Set l} -> Lifted A -> A\nunlift (lifter a) = a\n\n--****************\n-- Sigma and friends\n--****************\n\ndata Sigma {i j : Level}(A : Set i) (B : A -> Set j) : Set (max i j) where\n _,_ : (x : A) (y : B x) -> Sigma A B\n\npair : {i j : Level}{A : Set i}{B : A -> Set j} -> \n (x : A) (y : B x) -> Sigma {i = i}{j = j} A B\npair x y = x , y\n\n_*_ : {i j : Level}(A : Set i)(B : Set j) -> Set (max i j)\nA * B = Sigma A \\_ -> B\n\nfst : {i j : Level}{A : Set i}{B : A -> Set j} -> Sigma A B -> A\nfst (a , _) = a\n\nsnd : {i j : Level}{A : Set i}{B : A -> Set j} (p : Sigma A B) -> B (fst p)\nsnd (a , b) = b\n\ndata Zero {i : Level} : Set i where\ndata Unit {i : Level} : Set i where\n Void : Unit\n\n--****************\n-- Sum and friends\n--****************\n\ndata _+_ {i j : Level}(A : Set i)(B : Set j) : Set (max i j) where\n l : A -> A + B\n r : B -> A + B\n\n--****************\n-- Equality\n--****************\n\ndata _==_ {l : Level}{A : Set l}(x : A) : A -> Set l where\n refl : x == x\n\ncong : {l m : Level}{A : Set l}{B : Set m}\n (f : A -> B){x y : A} -> x == y -> f x == f y\ncong f refl = refl\n\ncong2 : {l m n : Level}{A : Set l}{B : Set m}{C : Set n}\n (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\ntrans : {l : Level}{A : Set l}{x y z : A} -> x == y -> y == z -> x == z\ntrans refl refl = refl\n\nproof-lift-unlift-eq : {l : Level}{A : Set l}(x : Lifted A) -> lifter (unlift x) == x\nproof-lift-unlift-eq (lifter a) = refl\n\npostulate \n reflFun : {l m : Level}{A : Set l}{B : A -> Set m}(f : (a : A) -> B a)(g : (a : A) -> B a)-> ((a : A) -> f a == g a) -> f == g \n\n\n--********************************************\n-- Desc code\n--********************************************\n\n-- In the paper, we have presented Desc as the grammar of inductive\n-- types. Hence, the codes in the paper closely follow this\n-- grammar:\n\ndata DescPaper : Set1 where\n oneP : DescPaper\n sigmaP : (S : Set) -> (S -> DescPaper) -> DescPaper\n indx : DescPaper -> DescPaper\n hindx : Set -> DescPaper -> DescPaper\n\n-- We take advantage of this model to give you an alternative\n-- presentation. This alternative model is the one implemented in\n-- Epigram. It is also the one which inspired the code for indexed\n-- descriptions.\n\n-- With sigma, we are actually \"quoting\" a standard type-former,\n-- namely:\n-- |Sigma : (S : Set) -> (S -> Set) -> Set|\n-- With:\n-- |sigma : (S : Set) -> (S -> Desc) -> Desc|\n\n-- In the alternative presentation, we go further and present all our\n-- codes as quotations of standard type-formers:\n\ndata Desc {l : Level} : Set (suc l) where\n id : Desc\n const : Set l -> Desc\n prod : Desc -> Desc -> Desc\n sigma : (S : Set l) -> (S -> Desc) -> Desc\n pi : (S : Set l) -> (S -> Desc) -> Desc\n\n-- Note that we replace |oneP| by a more general |const| code. Whereas\n-- |oneP| was interpreted as the unit set, |const K| is\n-- interpreted as |K|, for any |K : Set|. Extensionally,\n-- |const K| and |sigma K (\\_ -> Unit)| are equivalent. However,\n-- |const| is *first-order*, unlike its equivalent encoding. From a\n-- definitional perspective, we are giving more opportunities to the\n-- type-system, hence reducing the burden on the programmer. For the same\n-- reason, we introduce |prod| that overlaps with |pi|.\n\n-- This reorganisation is strictly equivalent to the |DescPaper|. For\n-- instance, we can encode |indx| and |hindx| using the following\n-- code:\n\nindx2 : {l : Level} -> Desc {l = l} -> Desc {l = l}\nindx2 D = prod id D\n\nhindx2 : Set -> Desc -> Desc\nhindx2 H D = prod (pi H (\\_ -> id)) D\n\n\n--********************************************\n-- Desc interpretation\n--********************************************\n\n[|_|]_ : {l : Level} -> Desc -> Set l -> Set l\n[| id |] Z = Z\n[| const X |] Z = X\n[| prod D D' |] Z = [| D |] Z * [| D' |] Z\n[| sigma S T |] Z = Sigma S (\\s -> [| T s |] Z)\n[| pi S T |] Z = (s : S) -> [| T s |] Z\n\n--********************************************\n-- Fixpoint construction\n--********************************************\n\ndata Mu {l : Level}(D : Desc {l = l}) : Set l where\n con : [| D |] (Mu D) -> Mu D\n\n--********************************************\n-- Predicate: All\n--********************************************\n\nAll : {l : Level}(D : Desc)(X : Set)(P : X -> Set l) -> [| D |] X -> Set l\nAll id X P x = P x\nAll (const Z) X P x = Unit\nAll (prod D D') X P (d , d') = (All D X P d) * (All D' X P d')\nAll (sigma S T) X P (a , b) = All (T a) X P b\nAll (pi S T) X P f = (s : S) -> All (T s) X P (f s)\n\n\nall : {l : Level}(D : Desc)(X : Set)(P : X -> Set l)(R : (x : X) -> P x)(x : [| D |] X) -> All D X P x\nall id X P R x = R x\nall (const Z) X P R z = Void\nall (prod D D') X P R (d , d') = all D X P R d , all D' X P R d'\nall (sigma S T) X P R (a , b) = all (T a) X P R b\nall (pi S T) X P R f = \\ s -> all (T s) X P R (f s)\n\n--********************************************\n-- Map\n--********************************************\n\n-- This one is bonus: one could rightfully expect our so-called\n-- functors to have a morphism part! Here it is.\n\nmap : {l : Level}(D : Desc)(X Y : Set l)(f : X -> Y)(v : [| D |] X) -> [| D |] Y\nmap id X Y sig x = sig x\nmap (const Z) X Y sig z = z\nmap (prod D D') X Y sig (d , d') = map D X Y sig d , map D' X Y sig d'\nmap (sigma S T) X Y sig (a , b) = (a , map (T a) X Y sig b)\nmap (pi S T) X Y sig f = \\x -> map (T x) X Y sig (f x)\n\n-- Together with the proof that they respect the functor laws:\n\n-- map id = id\nproof-map-id : {l : Level}(D : Desc)(X : Set l)(v : [| D |] X) -> map D X X (\\x -> x) v == v\nproof-map-id id X v = refl\nproof-map-id (const Z) X v = refl\nproof-map-id (prod D D') X (v , v') = cong2 (\\x y -> (x , y)) (proof-map-id D X v) (proof-map-id D' X v')\nproof-map-id (sigma S T) X (a , b) = cong (\\x -> (a , x)) (proof-map-id (T a) X b) \nproof-map-id (pi S T) X f = reflFun (\\a -> map (T a) X X (\\x -> x) (f a)) f (\\a -> proof-map-id (T a) X (f a))\n\n-- map (f . g) = map f . map g\nproof-map-compos : {l : Level}(D : Desc)(X Y Z : Set l)\n (f : X -> Y)(g : Y -> Z)\n (v : [| D |] X) -> \n map D X Z (\\x -> g (f x)) v == map D Y Z g (map D X Y f v)\nproof-map-compos id X Y Z f g v = refl\nproof-map-compos (const K) X Y Z f g v = refl\nproof-map-compos (prod D D') X Y Z f g (v , v') = cong2 (\\x y -> (x , y)) \n (proof-map-compos D X Y Z f g v)\n (proof-map-compos D' X Y Z f g v')\nproof-map-compos (sigma S T) X Y Z f g (a , b) = cong (\\x -> (a , x)) (proof-map-compos (T a) X Y Z f g b)\nproof-map-compos (pi S T) X Y Z f g fc = reflFun (\\a -> map (T a) X Z (\\x -> g (f x)) (fc a))\n (\\a -> map (T a) Y Z g (map (T a) X Y f (fc a)))\n (\\a -> proof-map-compos (T a) X Y Z f g (fc a))\n\n\n--********************************************\n-- Elimination principle: induction\n--********************************************\n\n-- One would like to write the following:\n\n{-\nind : {l : Level}\n (D : Desc) \n (P : Mu D -> Set l) ->\n ( (x : [| D |] (Mu D)) -> \n All D (Mu D) P x -> P (con x)) ->\n (v : Mu D) ->\n P v\nind D P ms (con xs) = ms xs (all D (Mu D) P (\\x -> ind D P ms x) xs)\n-}\n\n-- But the termination checker is unhappy.\n-- So we write the following:\n\nmodule Elim {l : Level}\n (D : Desc)\n (P : Mu D -> Set l)\n (ms : (x : [| D |] (Mu D)) -> \n All D (Mu D) P x -> P (con x))\n where\n\n mutual\n ind : (x : Mu D) -> P x\n ind (con xs) = ms xs (hyps D xs)\n \n hyps : (D' : Desc)\n (xs : [| D' |] (Mu D)) ->\n All D' (Mu D) P xs\n hyps id x = ind x\n hyps (const Z) z = Void\n hyps (prod D D') (d , d') = hyps D d , hyps D' d'\n hyps (sigma S T) (a , b) = hyps (T a) b\n hyps (pi S T) f = \\s -> hyps (T s) (f s)\n \nind : {l : Level}\n (D : Desc) \n (P : Mu D -> Set l) ->\n ( (x : [| D |] (Mu D)) -> \n All D (Mu D) P x -> P (con x)) ->\n (v : Mu D) ->\n P v\nind D P ms x = Elim.ind D P ms x\n\n\n--********************************************\n-- Examples\n--********************************************\n\n--****************\n-- Nat\n--****************\n\ndata NatConst : Set where\n Ze : NatConst\n Su : NatConst\n\nnatCases : NatConst -> Desc\nnatCases Ze = const Unit\nnatCases Suc = id\n\nNatD : Desc\nNatD = sigma NatConst natCases\n\nNat : Set\nNat = Mu NatD\n\nze : Nat\nze = con (Ze , Void)\n\nsu : Nat -> Nat\nsu n = con (Su , n)\n\n-- Now we can get addition for example:\n\nplusCase : (xs : [| NatD |] Nat) ->\n All NatD Nat (\\_ -> Nat -> Nat) xs -> Nat -> Nat\nplusCase ( Ze , Void ) hs y = y\nplusCase ( Su , n ) hs y = su (hs y)\n\nplus : Nat -> Nat -> Nat\nplus x = ind NatD (\\ _ -> (Nat -> Nat)) plusCase x\n\n-- Do this thing in Epigram, you will see that this is *not*\n-- hieroglyphic with a bit of elaboration.\n\n--****************\n-- List\n--****************\n\ndata ListConst : Set where\n Nil : ListConst\n Cons : ListConst\n\nlistCases : Set -> ListConst -> Desc\nlistCases X Nil = const Unit\nlistCases X Cons = sigma X (\\_ -> id)\n\nListD : Set -> Desc\nListD X = sigma ListConst (listCases X)\n\nList : Set -> Set\nList X = Mu (ListD X)\n\nnil : {X : Set} -> List X\nnil = con ( Nil , Void )\n\ncons : {X : Set} -> X -> List X -> List X\ncons x t = con ( Cons , ( x , t ))\n\n--****************\n-- Tree\n--****************\n\ndata TreeConst : Set where\n Leaf : TreeConst\n Node : TreeConst\n\ntreeCases : Set -> TreeConst -> Desc\ntreeCases X Leaf = const Unit\ntreeCases X Node = sigma X (\\_ -> prod id id)\n\nTreeD : Set -> Desc\nTreeD X = sigma TreeConst (treeCases X)\n\nTree : Set -> Set\nTree X = Mu (TreeD X)\n\nleaf : {X : Set} -> Tree X\nleaf = con (Leaf , Void)\n\nnode : {X : Set} -> X -> Tree X -> Tree X -> Tree X\nnode x le ri = con (Node , (x , (le , ri)))\n\n--********************************************\n-- Finite sets\n--********************************************\n\n-- If we weren't such big fans of levitating things, we would\n-- implement finite sets with:\n\n{-\n\ndata En : Set where\n nE : En\n cE : En -> En\n\nspi : (e : En)(P : EnumT e -> Set) -> Set\nspi nE P = Unit\nspi (cE e) P = P EZe * spi e (\\e -> P (ESu e))\n\nswitch : (e : En)(P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x\nswitch nE P b ()\nswitch (cE e) P b EZe = fst b\nswitch (cE e) P b (ESu n) = switch e (\\e -> P (ESu e)) (snd b) n\n-}\n\n-- But no, we make it fly in Desc:\n\n--****************\n-- En\n--****************\n\n-- As we have no tags here, we use Nat instead of List. \n\nEnD : Desc\nEnD = NatD\n\nEn : Set\nEn = Nat\n\nnE : En\nnE = ze\n\ncE : En -> En\ncE e = su e \n\n--****************\n-- EnumT\n--****************\n\n-- Because I don't want to fall back on wacky unicode symbols, I will\n-- write EnumT for #, EZe for 0, and ESu for 1+. Sorry about that\n\ndata EnumT : (e : En) -> Set where\n EZe : {e : En} -> EnumT (cE e)\n ESu : {e : En} -> EnumT e -> EnumT (cE e)\n\n--****************\n-- Small Pi\n--****************\n\n-- This corresponds to the small pi |\\pi|.\n\ncasesSpi : {l : Level}(xs : [| EnD |] En) -> \n All EnD En (\\e -> (EnumT e -> Set l) -> Set l) xs -> \n (EnumT (con xs) -> Set l) -> Set l\ncasesSpi (Ze , Void) hs P' = Unit\ncasesSpi (Su , n) hs P' = P' EZe * hs (\\e -> P' (ESu e))\n\nspi : {l : Level}(e : En)(P : EnumT e -> Set l) -> Set l\nspi {x} e P = ind EnD (\\E -> (EnumT E -> Set x) -> Set x) casesSpi e P\n\n--****************\n-- Switch\n--****************\n\ncasesSwitch : {l : Level}\n (xs : [| EnD |] En) ->\n All EnD En (\\e -> (P' : EnumT e -> Set l)\n (b' : spi e P')\n (x' : EnumT e) -> P' x') xs ->\n (P' : EnumT (con xs) -> Set l)\n (b' : spi (con xs) P')\n (x' : EnumT (con xs)) -> P' x'\ncasesSwitch (Ze , Void) hs P' b' ()\ncasesSwitch (Su , n) hs P' b' EZe = fst b'\ncasesSwitch (Su , n) hs P' b' (ESu e') = hs (\\e -> P' (ESu e)) (snd b') e'\n\n\nswitch : {l : Level}\n (e : En)\n (P : EnumT e -> Set l)\n (b : spi e P)\n (x : EnumT e) -> P x\nswitch {x} e P b xs = ind EnD\n (\\e -> (P : EnumT e -> Set x)\n (b : spi e P)\n (xs : EnumT e) -> P xs) \n casesSwitch e P b xs \n\n--****************\n-- Desc\n--****************\n\n-- In the following, we implement Desc in itself. As usual, we have a\n-- finite set of constructors -- the name of the codes. Note that we\n-- could really define these as a finite set built above. However, in\n-- Agda, it's horribly verbose. For the sake of clarity, we won't do\n-- that here. \n\ndata DescDef : Set1 where\n DescId : DescDef\n DescConst : DescDef\n DescProd : DescDef\n DescSigma : DescDef\n DescPi : DescDef\n\n-- We slightly diverge here from the presentation of the paper: note\n-- the presence of terminating \"const Unit\". Recall our Lisp-ish\n-- notation for nested tuples:\n-- |[a b c]| \n-- Corresponds to \n-- |[a , [ b , [c , []]]]|\n-- So, if we want to write constructors using our Lisp-ish notation, the interpretation \n-- [| DescD |] (Mu DescD) have to evaluates to [ constructor , [ arg1 , [ arg2 , []]]]\n\n-- Hence, we define Desc's code as follow:\n\ndescCases : DescDef -> Desc\ndescCases DescId = const Unit\ndescCases DescConst = sigma Set (\\_ -> const Unit)\ndescCases DescProd = prod id (prod id (const Unit))\ndescCases DescSigma = sigma Set (\\S -> prod (pi (lift S) (\\_ -> id)) (const Unit))\ndescCases DescPi = sigma Set (\\S -> prod (pi (lift S) (\\_ -> id)) (const Unit))\n\nDescD : Desc\nDescD = sigma DescDef descCases\n\nDescIn : Set1\nDescIn = Mu DescD\n\n-- So that the constructors are:\n-- (Note the annoying |pair|s to set the implicit levels. I could not\n-- get rid of the yellow otherwise)\n\nidIn : DescIn\nidIn = con (pair {i = suc zero} {j = suc zero} DescId Void)\nconstIn : Set -> DescIn\nconstIn K = con (pair {i = suc zero} {j = suc zero} DescConst (K , Void))\nprodIn : (D D' : DescIn) -> DescIn\nprodIn D D' = con (pair {i = suc zero} {j = suc zero} DescProd (D , ( D' , Void )))\nsigmaIn : (S : Set)(D : S -> DescIn) -> DescIn\nsigmaIn S D = con (pair {i = suc zero} {j = suc zero} DescSigma (S , ((\\s -> D (unlift s)) , Void )))\npiIn : (S : Set)(D : S -> DescIn) -> DescIn\npiIn S D = con (pair {i = suc zero} {j = suc zero} DescPi (S , ((\\s -> D (unlift s)) , Void )))\n\n-- At this stage, we could prove the isomorphism between |DescIn| and\n-- |Desc|. While not technically difficult, it is long and\n-- laborious. We have carried this proof on the more complex and\n-- interesting |IDesc| universe, in IDesc.agda.\n\n\n--********************************************\n-- Tagged description\n--********************************************\n\nTagDesc : {l : Level} -> Set (suc l)\nTagDesc = Sigma En (\\e -> spi e (\\_ -> Desc))\n\nde : TagDesc -> Desc\nde (B , F) = sigma (EnumT B) (\\E -> switch B (\\_ -> Desc) F E)\n\n--********************************************\n-- Catamorphism\n--********************************************\n\ncata : (D : Desc)\n (T : Set) ->\n ([| D |] T -> T) ->\n (Mu D) -> T\ncata D T phi x = ind D (\\_ -> T) (\\x ms -> phi (replace D T x ms)) x\n where replace : (D' : Desc)(T : Set)(xs : [| D' |] (Mu D))(ms : All D' (Mu D) (\\_ -> T) xs) -> [| D' |] T\n replace id 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-- Free monad construction\n--********************************************\n\n_**_ : TagDesc -> (X : Set) -> TagDesc\n(e , D) ** X = cE e , (const X , D)\n\n--********************************************\n-- Substitution\n--********************************************\n\napply : (D : TagDesc)(X Y : Set) ->\n (X -> Mu (de (D ** Y))) ->\n [| de (D ** X) |] (Mu (de (D ** Y))) ->\n Mu (de (D ** Y))\napply (E , B) X Y sig (EZe , x) = sig x\napply (E , B) X Y sig (ESu n , t) = con (ESu n , t)\n\nsubst : (D : TagDesc)(X Y : Set) ->\n Mu (de (D ** X)) ->\n (X -> Mu (de (D ** Y))) ->\n Mu (de (D ** Y))\nsubst D X Y x sig = cata (de (D ** X)) (Mu (de (D ** Y))) (apply D X Y sig) x\n", "meta": {"hexsha": "5fad120cd4d4473dd5a259268f5b0f4732b37924", "size": 17294, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "models/Desc.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/Desc.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/Desc.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.0243055556, "max_line_length": 129, "alphanum_fraction": 0.4650167688, "num_tokens": 5595, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117983401363, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.5861544831490402}} {"text": "{-# OPTIONS --without-K #-}\nmodule NTypes.Nat where\n\nopen import NTypes\nopen import PathOperations\nopen import PathStructure.Nat\nopen import Types\n\nℕ-isSet : isSet ℕ\nℕ-isSet = ind\n (λ m → (n : ℕ) (p q : m ≡ n) → p ≡ q)\n (λ m-1 r → ind (λ n → (p q : suc m-1 ≡ n) → p ≡ q)\n (λ n-1 r′ p′ q′\n → split-eq p′ ⁻¹\n · ap (ap suc)\n (r _\n (merge-path m-1 n-1\n (tr (F (suc m-1)) p′ (F-lemma (suc m-1))))\n (merge-path m-1 n-1\n (tr (F (suc m-1)) q′ (F-lemma (suc m-1)))))\n · split-eq q′\n )\n (λ p q → 0-elim (split-path _ _ p)))\n (ind (λ n → (p q : 0 ≡ n) → p ≡ q)\n (λ _ _ p q → 0-elim (split-path _ _ p))\n (λ p q → split-eq p ⁻¹ · split-eq q))\n where\n split-eq : {x y : ℕ} → _\n split-eq {x} {y} = π₂ (π₂ (π₂ (split-merge-eq {x} {y})))\n", "meta": {"hexsha": "365051c0e586ad822dbd487df395080f9d9524e6", "size": 810, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/NTypes/Nat.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/Nat.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/Nat.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": 27.0, "max_line_length": 58, "alphanum_fraction": 0.4716049383, "num_tokens": 350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.894789457685656, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.5859929114946018}} {"text": "module bool where\n\nopen import level\n\n----------------------------------------------------------------------\n-- datatypes\n----------------------------------------------------------------------\n\nopen import unit\nopen import empty\n\ndata 𝔹 : Set where\n tt : 𝔹\n ff : 𝔹\n\n-- this is an alias for Mac users who cannot see blackboard b.\nbool : Set\nbool = 𝔹\n\n{-# BUILTIN BOOL 𝔹 #-}\n{-# BUILTIN TRUE tt #-}\n{-# BUILTIN FALSE ff #-}\n\n----------------------------------------------------------------------\n-- syntax\n----------------------------------------------------------------------\n\ninfix 7 ~_\ninfix 6 _xor_ _nand_\ninfixr 6 _&&_\ninfixr 5 _||_ \ninfix 4 if_then_else_ if*_then_else_\ninfixr 4 _imp_ \n\n----------------------------------------------------------------------\n-- operations\n----------------------------------------------------------------------\n\ntoSet : 𝔹 → Set\ntoSet tt = ⊤\ntoSet ff = ⊥\n\n-- not\n~_ : 𝔹 → 𝔹\n~ tt = ff\n~ ff = tt\n\n\n-- and\n_&&_ : 𝔹 → 𝔹 → 𝔹\ntt && b = b\nff && b = ff\n\n-- or\n_||_ : 𝔹 → 𝔹 → 𝔹\ntt || b = tt\nff || b = b\n\nif_then_else_ : ∀ {ℓ} {A : Set ℓ} → 𝔹 → A → A → A\nif tt then y else z = y\nif ff then y else z = z\n\nif*_then_else_ : ∀ {ℓ} {A B : Set ℓ} → (b : 𝔹) → A → B → if b then A else B\nif* tt then a else b = a\nif* ff then a else b = b\n\n_xor_ : 𝔹 → 𝔹 → 𝔹 \ntt xor ff = tt\nff xor tt = tt\ntt xor tt = ff\nff xor ff = ff\n\n-- implication\n_imp_ : 𝔹 → 𝔹 → 𝔹 \ntt imp b2 = b2\nff imp b2 = tt\n\n-- also called the Sheffer stroke\n_nand_ : 𝔹 → 𝔹 → 𝔹\ntt nand tt = ff\ntt nand ff = tt\nff nand tt = tt\nff nand ff = tt\n\n_nor_ : 𝔹 → 𝔹 → 𝔹\nx nor y = ~ (x || y)\n", "meta": {"hexsha": "25d7538e286c3cf4c80e556eb74caf62b8e9e273", "size": 1566, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "bool.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.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.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": 18.0, "max_line_length": 75, "alphanum_fraction": 0.4137931034, "num_tokens": 527, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5859120845971311}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.Algebra.GradedRing.Instances.CohomologyRing where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Monoid.Instances.NatPlusBis\nopen import Cubical.Algebra.AbGroup\nopen import Cubical.Algebra.AbGroup.Instances.Unit\nopen import Cubical.Algebra.DirectSum.DirectSumHIT.Base\nopen import Cubical.Algebra.GradedRing.Base\nopen import Cubical.Algebra.GradedRing.DirectSumHIT\n\nopen import Cubical.ZCohomology.Base\nopen import Cubical.ZCohomology.GroupStructure\nopen import Cubical.ZCohomology.RingStructure.CupProduct\nopen import Cubical.ZCohomology.RingStructure.RingLaws\nopen import Cubical.ZCohomology.RingStructure.GradedCommutativity\n\nprivate variable\n ℓ : Level\n\nopen PlusBis\nopen GradedRing-⊕HIT-index\nopen GradedRing-⊕HIT-⋆\n\nmodule _\n (A : Type ℓ)\n where\n\n CohomologyRing-GradedRing : GradedRing ℓ-zero ℓ\n CohomologyRing-GradedRing = makeGradedRingSelf\n NatPlusBis-Monoid\n (λ k → coHom k A)\n (λ k → snd (coHomGroup k A) )\n 1⌣\n _⌣_\n (λ {k} {l} → 0ₕ-⌣ k l)\n (λ {k} {l} → ⌣-0ₕ k l)\n (λ _ _ _ → sym (ΣPathTransport→PathΣ _ _ ((sym (+'-assoc _ _ _)) , (sym (assoc-⌣ _ _ _ _ _ _)))) )\n (λ _ → sym (ΣPathTransport→PathΣ _ _ (sym (+'-rid _) , sym (lUnit⌣ _ _))))\n (λ _ → ΣPathTransport→PathΣ _ _ (refl , transportRefl _ ∙ rUnit⌣ _ _))\n (λ _ _ _ → leftDistr-⌣ _ _ _ _ _)\n ( λ _ _ _ → rightDistr-⌣ _ _ _ _ _)\n", "meta": {"hexsha": "e6bc75e22ff1d0b1258c21ab85a0f7975656ed1d", "size": 1838, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/GradedRing/Instances/CohomologyRing.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/GradedRing/Instances/CohomologyRing.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/GradedRing/Instances/CohomologyRing.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": 38.2916666667, "max_line_length": 128, "alphanum_fraction": 0.60609358, "num_tokens": 547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357666736773, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.585912073273832}} {"text": "{-\n\nThis file contains:\n\n- Equivalence with the pushout definition\n Written by: Loïc Pujet, September 2019\n\n- Associativity of the join\n Written by: Loïc Pujet, September 2019\n\n-}\n\n{-# OPTIONS --cubical --safe #-}\n\nmodule Cubical.HITs.Join.Properties where\n\nopen import Cubical.Core.Glue\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.GroupoidLaws\n\nopen import Cubical.Data.Prod\n\nopen import Cubical.HITs.Join.Base\nopen import Cubical.HITs.Pushout\n\nprivate\n variable\n ℓ ℓ' : Level\n\n-- Alternative definition of the join using a pushout\njoinPushout : (A : Type ℓ) → (B : Type ℓ') → Type (ℓ-max ℓ ℓ')\njoinPushout A B = Pushout {A = A × B} proj₁ proj₂\n\n-- Proof that it is equal\njoinPushout-iso-join : (A : Type ℓ) → (B : Type ℓ') → Iso (joinPushout A B) (join A B)\njoinPushout-iso-join A B = iso joinPushout→join join→joinPushout join→joinPushout→join joinPushout→join→joinPushout\n where\n joinPushout→join : joinPushout A B → join A B\n joinPushout→join (inl x) = inl x\n joinPushout→join (inr x) = inr x\n joinPushout→join (push y i) = push (proj₁ y) (proj₂ y) i\n\n join→joinPushout : join A B → joinPushout A B\n join→joinPushout (inl x) = inl x\n join→joinPushout (inr x) = inr x\n join→joinPushout (push a b i) = push (a , b) i\n\n joinPushout→join→joinPushout : ∀ x → join→joinPushout (joinPushout→join x) ≡ x\n joinPushout→join→joinPushout (inl x) = refl\n joinPushout→join→joinPushout (inr x) = refl\n joinPushout→join→joinPushout (push (a , b) j) = refl\n\n join→joinPushout→join : ∀ x → joinPushout→join (join→joinPushout x) ≡ x\n join→joinPushout→join (inl x) = refl\n join→joinPushout→join (inr x) = refl\n join→joinPushout→join (push a b j) = refl\n\n-- We will need both the equivalence and path version\njoinPushout≃join : (A : Type ℓ) → (B : Type ℓ') → joinPushout A B ≃ join A B\njoinPushout≃join A B = isoToEquiv (joinPushout-iso-join A B)\n\njoinPushout≡join : (A : Type ℓ) → (B : Type ℓ') → joinPushout A B ≡ join A B\njoinPushout≡join A B = isoToPath (joinPushout-iso-join A B)\n\n\n{-\n Proof of associativity of the join\n-}\njoin-assoc : (A B C : Type₀) → join (join A B) C ≡ join A (join B C)\njoin-assoc A B C = (joinPushout≡join (join A B) C) ⁻¹\n ∙ (spanEquivToPushoutPath sp3≃sp4) ⁻¹\n ∙ (3x3-span.3x3-lemma span) ⁻¹\n ∙ (spanEquivToPushoutPath sp1≃sp2)\n ∙ (joinPushout≡join A (join B C))\n where\n -- the meat of the proof is handled by the 3x3 lemma applied to this diagram\n span : 3x3-span\n span = record {\n A00 = A; A02 = A × B; A04 = B;\n A20 = A × C; A22 = A × B × C; A24 = B × C;\n A40 = A × C; A42 = A × C; A44 = C;\n f10 = proj₁; f12 = proj₁₂; f14 = proj₁;\n f30 = λ x → x; f32 = proj₁₃; f34 = proj₂;\n f01 = proj₁; f21 = proj₁₃; f41 = λ x → x;\n f03 = proj₂; f23 = proj₂; f43 = proj₂;\n H11 = H11; H13 = H13; H31 = H31; H33 = H33 }\n where\n proj₁₃ : A × B × C → A × C\n proj₁₃ (a , (b , c)) = a , c\n\n proj₁₂ : A × B × C → A × B\n proj₁₂ (a , (b , c)) = a , b\n\n H11 : (x : A × B × C) → proj₁ (proj₁₂ x) ≡ proj₁ (proj₁₃ x)\n H11 (a , (b , c)) = refl\n\n H13 : (x : A × B × C) → proj₂ (proj₁₂ x) ≡ proj₁ (proj₂ x)\n H13 (a , (b , c)) = refl\n\n H31 : (x : A × B × C) → proj₁₃ x ≡ proj₁₃ x\n H31 (a , (b , c)) = refl\n\n H33 : (x : A × B × C) → proj₂ (proj₁₃ x) ≡ proj₂ (proj₂ x)\n H33 (a , (b , c)) = refl\n\n -- the first pushout span appearing in the 3x3 lemma\n sp1 : 3-span\n sp1 = record {\n A0 = 3x3-span.A□0 span;\n A2 = 3x3-span.A□2 span;\n A4 = 3x3-span.A□4 span;\n f1 = 3x3-span.f□1 span;\n f3 = 3x3-span.f□3 span }\n\n -- the first span we are interested in\n sp2 : 3-span\n sp2 = record {\n A0 = A ;\n A2 = A × (join B C) ;\n A4 = join B C ;\n f1 = proj₁ ;\n f3 = proj₂ }\n\n -- proof that they are in fact equivalent\n sp1≃sp2 : 3-span-equiv sp1 sp2\n sp1≃sp2 = record {\n e0 = A□0≃A;\n e2 = A□2≃A×join;\n e4 = joinPushout≃join B C;\n H1 = H1;\n H3 = H2 }\n where\n A×join : Type₀\n A×join = A × (join B C)\n\n A□2→A×join : 3x3-span.A□2 span → A×join\n A□2→A×join (inl (a , b)) = a , inl b\n A□2→A×join (inr (a , c)) = a , inr c\n A□2→A×join (push (a , (b , c)) i) = a , push b c i\n\n A×join→A□2 : A×join → 3x3-span.A□2 span\n A×join→A□2 (a , inl b) = inl (a , b)\n A×join→A□2 (a , inr c) = inr (a , c)\n A×join→A□2 (a , push b c i) = push (a , (b , c)) i\n\n A×join→A□2→A×join : ∀ x → A×join→A□2 (A□2→A×join x) ≡ x\n A×join→A□2→A×join (inl (a , b)) = refl\n A×join→A□2→A×join (inr (a , c)) = refl\n A×join→A□2→A×join (push (a , (b , c)) i) = refl\n\n A□2→A×join→A□2 : ∀ x → A□2→A×join (A×join→A□2 x) ≡ x\n A□2→A×join→A□2 (a , inl b) = refl\n A□2→A×join→A□2 (a , inr c) = refl\n A□2→A×join→A□2 (a , push b c i) = refl\n\n A□2≃A×join : 3x3-span.A□2 span ≃ A×join\n A□2≃A×join = isoToEquiv (iso A□2→A×join A×join→A□2 A□2→A×join→A□2 A×join→A□2→A×join)\n\n A→A□0 : A → 3x3-span.A□0 span\n A→A□0 b = inl b\n\n A□0→A : 3x3-span.A□0 span → A\n A□0→A (inl b) = b\n A□0→A (inr a) = proj₁ a\n A□0→A (push a i) = proj₁ a\n\n A→A□0→A : ∀ x → A□0→A (A→A□0 x) ≡ x\n A→A□0→A x = refl\n\n A□0→A→A□0 : ∀ x → A→A□0 (A□0→A x) ≡ x\n A□0→A→A□0 (inl b) = refl\n A□0→A→A□0 (inr a) j = push a j\n A□0→A→A□0 (push a i) j = push a (j ∧ i)\n\n A□0≃A : 3x3-span.A□0 span ≃ A\n A□0≃A = isoToEquiv (iso A□0→A A→A□0 A→A□0→A A□0→A→A□0)\n\n H1 : (x : 3x3-span.A□2 span) → proj₁ (A□2→A×join x) ≡ A□0→A (3x3-span.f□1 span x)\n H1 (inl (a , b)) = refl\n H1 (inr (a , c)) = refl\n H1 (push (a , (b , c)) i) j = A□0→A (doubleCompPath-filler refl (λ i → push (a , c) i) refl i j)\n\n H2 : (x : 3x3-span.A□2 span) → proj₂ (A□2→A×join x) ≡ fst (joinPushout≃join _ _) (3x3-span.f□3 span x)\n H2 (inl (a , b)) = refl\n H2 (inr (a , c)) = refl\n H2 (push (a , (b , c)) i) j = fst (joinPushout≃join _ _) (doubleCompPath-filler refl (λ i → push (b , c) i) refl i j)\n\n -- the second span appearing in 3x3 lemma\n sp3 : 3-span\n sp3 = record {\n A0 = 3x3-span.A0□ span;\n A2 = 3x3-span.A2□ span;\n A4 = 3x3-span.A4□ span;\n f1 = 3x3-span.f1□ span;\n f3 = 3x3-span.f3□ span }\n\n -- the second span we are interested in\n sp4 : 3-span\n sp4 = record {\n A0 = join A B ;\n A2 = (join A B) × C ;\n A4 = C ;\n f1 = proj₁ ;\n f3 = proj₂ }\n\n -- proof that they are in fact equivalent\n sp3≃sp4 : 3-span-equiv sp3 sp4\n sp3≃sp4 = record {\n e0 = joinPushout≃join A B;\n e2 = A2□≃join×C;\n e4 = A4□≃C;\n H1 = H4;\n H3 = H3 }\n where\n join×C : Type₀\n join×C = (join A B) × C\n\n A2□→join×C : 3x3-span.A2□ span → join×C\n A2□→join×C (inl (a , c)) = (inl a) , c\n A2□→join×C (inr (b , c)) = (inr b) , c\n A2□→join×C (push (a , (b , c)) i) = push a b i , c\n\n join×C→A2□ : join×C → 3x3-span.A2□ span\n join×C→A2□ (inl a , c) = inl (a , c)\n join×C→A2□ (inr b , c) = inr (b , c)\n join×C→A2□ (push a b i , c) = push (a , (b , c)) i\n\n join×C→A2□→join×C : ∀ x → join×C→A2□ (A2□→join×C x) ≡ x\n join×C→A2□→join×C (inl (a , c)) = refl\n join×C→A2□→join×C (inr (b , c)) = refl\n join×C→A2□→join×C (push (a , (b , c)) j) = refl\n\n A2□→join×C→A2□ : ∀ x → A2□→join×C (join×C→A2□ x) ≡ x\n A2□→join×C→A2□ (inl a , c) = refl\n A2□→join×C→A2□ (inr b , c) = refl\n A2□→join×C→A2□ (push a b i , c) = refl\n\n A2□≃join×C : 3x3-span.A2□ span ≃ join×C\n A2□≃join×C = isoToEquiv (iso A2□→join×C join×C→A2□ A2□→join×C→A2□ join×C→A2□→join×C)\n\n C→A4□ : C → 3x3-span.A4□ span\n C→A4□ b = inr b\n\n A4□→C : 3x3-span.A4□ span → C\n A4□→C (inl x) = proj₂ x\n A4□→C (inr c) = c\n A4□→C (push x i) = proj₂ x\n\n C→A4□→C : ∀ x → A4□→C (C→A4□ x) ≡ x\n C→A4□→C x = refl\n\n A4□→C→A4□ : ∀ x → C→A4□ (A4□→C x) ≡ x\n A4□→C→A4□ (inl x) j = push x (~ j)\n A4□→C→A4□ (inr c) = refl\n A4□→C→A4□ (push x i) j = push x (~ j ∨ i)\n\n A4□≃C : 3x3-span.A4□ span ≃ C\n A4□≃C = isoToEquiv (iso A4□→C C→A4□ C→A4□→C A4□→C→A4□)\n\n H3 : (x : 3x3-span.A2□ span) → proj₂ (A2□→join×C x) ≡ A4□→C (3x3-span.f3□ span x)\n H3 (inl (a , c)) = refl\n H3 (inr (b , c)) = refl\n H3 (push (a , (b , c)) i) j = A4□→C (doubleCompPath-filler refl (λ i → push (a , c) i) refl i j)\n\n H4 : (x : 3x3-span.A2□ span) → proj₁ (A2□→join×C x) ≡ fst (joinPushout≃join _ _) (3x3-span.f1□ span x)\n H4 (inl (a , c)) = refl\n H4 (inr (b , c)) = refl\n H4 (push (a , (b , c)) i) j = fst (joinPushout≃join _ _) (doubleCompPath-filler refl (λ i → push (a , b) i) refl i j)\n", "meta": {"hexsha": "86076564bbae6454cbeaae1e633f705d787284d9", "size": 9089, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Join/Properties.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/Join/Properties.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/Join/Properties.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.4154411765, "max_line_length": 125, "alphanum_fraction": 0.5119375069, "num_tokens": 4141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736773, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.5859120732738319}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.HITs.Colimit.Examples where\n\nopen import Cubical.Core.Glue\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.SumFin\n\nopen import Cubical.Data.Graph\nopen import Cubical.HITs.Colimit.Base\n\nopen import Cubical.HITs.Pushout\n\n\n-- Pushouts are colimits over the graph ⇐⇒\n\nmodule _ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} where\n\n PushoutDiag : (A → B) → (A → C) → Diag (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) ⇐⇒\n (PushoutDiag f g) $ fzero = Lift {j = ℓ-max ℓ ℓ'' } B\n (PushoutDiag f g) $ fsuc fzero = Lift {j = ℓ-max ℓ' ℓ'' } A\n (PushoutDiag f g) $ fsuc (fsuc fzero) = Lift {j = ℓ-max ℓ ℓ' } C\n _<$>_ (PushoutDiag f g) {fsuc fzero} {fzero} tt (lift a) = lift (f a)\n _<$>_ (PushoutDiag f g) {fsuc fzero} {fsuc (fsuc fzero)} tt (lift a) = lift (g a)\n\nmodule _ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} {f : A → B} {g : A → C} where\n\n PushoutCocone : Cocone _ (PushoutDiag f g) (Pushout f g)\n leg PushoutCocone fzero (lift b) = inl b\n leg PushoutCocone (fsuc fzero) (lift a) = inr (g a)\n leg PushoutCocone (fsuc (fsuc fzero)) (lift c) = inr c\n com PushoutCocone {fsuc fzero} {fzero} tt i (lift a) = push a i\n com PushoutCocone {fsuc fzero} {fsuc (fsuc fzero)} tt i (lift a) = inr (g a)\n\n private\n module _ ℓq (Y : Type ℓq) where\n\n fwd : (Pushout f g → Y) → Cocone ℓq (PushoutDiag f g) Y\n fwd = postcomp PushoutCocone\n\n module _ (C : Cocone ℓq (PushoutDiag f g) Y) where\n coml : ∀ a → leg C fzero (lift (f a)) ≡ leg C (fsuc fzero) (lift a)\n comr : ∀ a → leg C (fsuc (fsuc fzero)) (lift (g a)) ≡ leg C (fsuc fzero) (lift a)\n coml a i = com C {j = fsuc fzero} {k = fzero} tt i (lift a)\n comr a i = com C {j = fsuc fzero} {k = fsuc (fsuc fzero)} tt i (lift a)\n\n bwd : Cocone ℓq (PushoutDiag f g) Y → (Pushout f g → Y)\n bwd C (inl b) = leg C fzero (lift b)\n bwd C (inr c) = leg C (fsuc (fsuc fzero)) (lift c)\n bwd C (push a i) = (coml C a ∙ sym (comr C a)) i\n\n bwd-fwd : ∀ F → bwd (fwd F) ≡ F\n bwd-fwd F i (inl b) = F (inl b)\n bwd-fwd F i (inr c) = F (inr c)\n bwd-fwd F i (push a j) = compPath-filler (coml (fwd F) a) (sym (comr (fwd F) a)) (~ i) j\n\n fwd-bwd : ∀ C → fwd (bwd C) ≡ C\n leg (fwd-bwd C i) fzero (lift b) = leg C fzero (lift b)\n leg (fwd-bwd C i) (fsuc fzero) (lift a) = comr C a i\n leg (fwd-bwd C i) (fsuc (fsuc fzero)) (lift c) = leg C (fsuc (fsuc fzero)) (lift c)\n com (fwd-bwd C i) {fsuc fzero} {fzero} tt j (lift a) -- coml (fwd-bwd C i) = ...\n = compPath-filler (coml C a) (sym (comr C a)) (~ i) j\n com (fwd-bwd C i) {fsuc fzero} {fsuc (fsuc fzero)} tt j (lift a) -- comr (fwd-bwd C i) = ...\n = comr C a (i ∧ j)\n\n eqv : isEquiv {A = (Pushout f g → Y)} {B = Cocone ℓq (PushoutDiag f g) Y} (postcomp PushoutCocone)\n eqv = isoToIsEquiv (iso fwd bwd fwd-bwd bwd-fwd)\n\n isColimPushout : isColimit (PushoutDiag f g) (Pushout f g)\n cone isColimPushout = PushoutCocone\n univ isColimPushout = eqv\n\n colim≃Pushout : colim (PushoutDiag f g) ≃ Pushout f g\n colim≃Pushout = uniqColimit colimIsColimit isColimPushout\n\n", "meta": {"hexsha": "23434b998cc8a96bcc2e3df591683718c4a39cd8", "size": 3392, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Colimit/Examples.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/Colimit/Examples.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/Colimit/Examples.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": 43.4871794872, "max_line_length": 104, "alphanum_fraction": 0.5766509434, "num_tokens": 1375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.849971175657575, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5858899054864953}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Categories.Instances.Functors where\n\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Functor.Base\nopen import Cubical.Categories.NaturalTransformation.Base\nopen import Cubical.Categories.NaturalTransformation.Properties\nopen import Cubical.Categories.Morphism renaming (isIso to isIsoC)\nopen import Cubical.Foundations.Prelude\n\nprivate\n variable\n ℓC ℓC' ℓD ℓD' : Level\n\nmodule _ (C : Precategory ℓC ℓC') (D : Precategory ℓD ℓD') ⦃ isCatD : 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') ℓ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\n isCatFUNCTOR : isCategory FUNCTOR\n isCatFUNCTOR .isSetHom = isSetNat\n\n open isIsoC renaming (inv to invC)\n -- component wise iso is an iso in Functor\n FUNCTORIso : ∀ {F G : Functor C D} (α : F ⇒ G)\n → (∀ (c : C .ob) → isIsoC {C = D} (α ⟦ c ⟧))\n → isIsoC {C = FUNCTOR} α\n FUNCTORIso α is .invC .N-ob c = (is c) .invC\n FUNCTORIso {F} {G} α is .invC .N-hom {c} {d} f\n = invMoveL areInv-αc\n ( α ⟦ c ⟧ ⋆⟨ D ⟩ (G ⟪ f ⟫ ⋆⟨ D ⟩ is d .invC)\n ≡⟨ sym (D .⋆Assoc _ _ _) ⟩\n (α ⟦ c ⟧ ⋆⟨ D ⟩ G ⟪ f ⟫) ⋆⟨ D ⟩ is d .invC\n ≡⟨ sym (invMoveR areInv-αd (α .N-hom f)) ⟩\n F ⟪ f ⟫\n ∎ )\n where\n areInv-αc : areInv (α ⟦ c ⟧) ((is c) .invC)\n areInv-αc = isIso→areInv (is c)\n\n areInv-αd : areInv (α ⟦ d ⟧) ((is d) .invC)\n areInv-αd = isIso→areInv (is d)\n FUNCTORIso α is .sec = makeNatTransPath (funExt (λ c → (is c) .sec))\n FUNCTORIso α is .ret = makeNatTransPath (funExt (λ c → (is c) .ret))\n\ninstance\n ⦃isCatFUNCTOR⦄ : {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} ⦃ isCatD : isCategory D ⦄\n → isCategory (FUNCTOR C D)\n ⦃isCatFUNCTOR⦄ {C = C} {D} = isCatFUNCTOR C D\n", "meta": {"hexsha": "badb05c9871f25aaabc229bdb6cc21c54ffcc542", "size": 2236, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/Functors.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/Categories/Instances/Functors.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/Categories/Instances/Functors.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": 37.2666666667, "max_line_length": 98, "alphanum_fraction": 0.6010733453, "num_tokens": 908, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301567, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.5858215068545962}} {"text": "module All where\n\nopen import Basics\nopen import Ix\n\nAll : {X : Set} -> (X -> Set) -> (List X -> Set)\nAll P [] = One\nAll P (x ,- xs) = P x * All P xs\n\nallPu : forall {X}{T : X -> Set} -> [ T ] -> [ All T ]\nallPu t [] = <>\nallPu t (x ,- xs) = t x , allPu t xs\n\nallAp : forall {X}{S T : X -> Set} -> [ All (S -:> T) -:> All S -:> All T ]\nallAp [] <> <> = <>\nallAp (x ,- xs) (f , fs) (s , ss) = f s , allAp xs fs ss\n\nall : {X : Set}{S T : X -> Set} ->\n [ S -:> T ] -> [ All S -:> All T ]\nall f xs = allAp xs (allPu f xs)\n\nallRe : forall {X Y}(f : X -> Y){P : Y -> Set}\n (xs : List X) -> All (\\ x -> P (f x)) xs -> All P (list f xs)\nallRe f [] <> = <>\nallRe f (x ,- xs) (p , ps) = p , allRe f xs ps\n\ncollect : {I J : Set}(is : List I) -> All (\\ i -> List J) is -> List J\ncollect [] <> = []\ncollect (i ,- is) (js , jss) = js +L collect is jss\n", "meta": {"hexsha": "6b3033595ebf9de81e94a32700ea1f8fc426e92c", "size": 857, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "All.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": "All.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": "All.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": 28.5666666667, "max_line_length": 75, "alphanum_fraction": 0.4504084014, "num_tokens": 337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.5857966367837424}} {"text": "\ndata N : Set where\n suc : N → N\n\ndata Val : N → Set where\n valSuc : ∀ n → Val (suc n)\n\nrecord R : Set where\n constructor wrap\n field unwrap : N\n\ndata W (ft : R) : Set where\n immed : (v : Val (R.unwrap ft)) → W ft\n\ntest : (fa : R) → W fa → R\ntest fa (immed (valSuc a)) = fa\n\npostulate\n Evaluate : ∀ (ft : R) (P : (w : W ft) → Set) → Set\n\ntest₂ : ∀ (fa : R) → Set\ntest₂ fa = Evaluate fa testw\n where\n testw : W fa → Set\n testw (immed (valSuc a)) = W fa\n", "meta": {"hexsha": "2dd8ef7514bb6f07c69c7dd5477eebe9bcf23931", "size": 461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue2053.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/Issue2053.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/Issue2053.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.7307692308, "max_line_length": 52, "alphanum_fraction": 0.5596529284, "num_tokens": 180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869884059266, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.5857966346152191}} {"text": "\nmodule Oscar.Data.Proposequality where\n\nopen import Agda.Builtin.Equality public using (_≡_) renaming (refl to ∅) public\nopen import Relation.Binary.PropositionalEquality public using (_≢_) public\n\nopen import Oscar.Category.Setoid\n\nopen import Relation.Binary.PropositionalEquality using (sym; trans)\n\nopen import Oscar.Level\nopen import Oscar.Relation\n\ninstance\n\n IsSetoidProposequality : ∀ {a} {A : Set a} → IsSetoid (_≡_ {A = A})\n IsSetoid.reflexivity IsSetoidProposequality _ = ∅\n IsSetoid.symmetry IsSetoidProposequality = sym\n IsSetoid.transitivity IsSetoidProposequality = λ ‵ → trans ‵\n\nmodule _ {a} (A : Set a) where\n\n setoid : Setoid a a\n setoid = ↑ _≡_ {A = A}\n\n{-\n private\n\n infixl 7 _∙_\n _∙_ : Transitive (_≡_ {A = A})\n _∙_ = (λ y≡z x≡y → transitivity x≡y y≡z)\n-}\n\n open import Oscar.Category.Morphism\n open import Oscar.Function\n\n module _ {b} (B : A → A → Set b) where\n\n{-\n private\n\n infix 4 _≞_\n _≞_ = λ {x} {y} → _≡_ {A = B x y}\n-}\n morphism : Morphism a b b\n morphism = -- ↑ λ {x} {y} → _≞_ {x} {y} -- _≡_ {A = B x y}\n ↑ λ {x} {y} → _≡_ {A = B x y}\n\n open Morphism morphism\n\n open import Oscar.Category.Semigroupoid\n\n module _ (_∙_ : Transitive _↦_) (associativity : Associative _∙_ _≞_) where\n\n instance\n\n IsSemigroupoidProposequality : IsSemigroupoid morphism _∙_\n IsSemigroupoid.extensionality IsSemigroupoidProposequality ∅ ∅ = ∅\n IsSemigroupoid.associativity IsSemigroupoidProposequality = associativity\n\n-- instance\n\n-- IsSemigroupoidProposequality : ∀ {a} {A : Set a} {b} {B : A → A → Set b}\n-- → IsSemigroupoid (morphism B) {!!} -- (transitivity ⦃ setoid A ⦄)\n-- IsSemigroupoidProposequality = {!!}\n\n-- IsSemigroupoidProposequality' : ∀ {a} {A : Set a}\n-- → IsSemigroupoid (morphism (_≡_ {A = A})) (λ y≡z x≡y → transitivity x≡y y≡z) -- (transitivity ⦃ setoid A ⦄)\n-- IsSemigroupoid.extensionality IsSemigroupoidProposequality' = {!!} -- ∅ ∅ = ∅\n-- IsSemigroupoid.associativity IsSemigroupoidProposequality' ∅ _ _ = ∅\n\n-- -- semigroupoid : Semigroupoid\n\n\n\n-- -- setoid : ∀ {a} (A : Set a) → Setoid a a\n-- -- setoid A = ↑ _≡_ {A = A}\n\n-- -- open import Oscar.Category.Morphism\n-- -- open import Oscar.Function\n\n-- -- morphism : ∀ {a} {A : Set a} {b} (B : A → A → Set b) → Morphism a b b\n-- -- morphism B = ↑ λ {x} {y} → _≡_ {A = B x y}\n\n-- -- open import Oscar.Category.Semigroupoid\n\n-- -- infixl 7 _∙_\n-- -- _∙_ : ∀ {y z} → y ↦ z → ∀ {x} → x ↦ y → x ↦ z\n\n-- -- instance\n\n-- -- IsSemigroupoidProposequality : ∀ {a} {A : Set a} {b} {B : A → A → Set b}\n-- -- → IsSemigroupoid (morphism B) {!!} -- (transitivity ⦃ setoid A ⦄)\n-- -- IsSemigroupoidProposequality = {!!}\n\n-- -- IsSemigroupoidProposequality' : ∀ {a} {A : Set a}\n-- -- → IsSemigroupoid (morphism (_≡_ {A = A})) (λ y≡z x≡y → transitivity x≡y y≡z) -- (transitivity ⦃ setoid A ⦄)\n-- -- IsSemigroupoid.extensionality IsSemigroupoidProposequality' = {!!} -- ∅ ∅ = ∅\n-- -- IsSemigroupoid.associativity IsSemigroupoidProposequality' ∅ _ _ = ∅\n\n-- -- -- semigroupoid : Semigroupoid\n", "meta": {"hexsha": "4c2a904250643b13d61de5e8f4881608767bede1", "size": 3082, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-2/Oscar/Data/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-2/Oscar/Data/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-2/Oscar/Data/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": 30.2156862745, "max_line_length": 117, "alphanum_fraction": 0.6207008436, "num_tokens": 1121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757869851639065, "lm_q2_score": 0.6688802537704064, "lm_q1q2_score": 0.585796620885253}} {"text": "module Data.Fin.Subset.Properties.Cardinality where\n\nopen import Data.Nat as ℕ using (ℕ)\nopen import Data.Nat.Properties as NP\nopen import Data.Empty using (⊥-elim)\nopen import Data.Fin\nopen import Data.Fin.Subset\nopen import Data.Fin.Subset.Properties \nopen import Data.Vec using (_∷_; [])\nopen import Data.Vec.Any using (here ; there)\nopen import Data.Vec.Properties as VP\nopen import Data.Product\nopen import Data.Sum\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as Eq\nopen import Relation.Nullary.Negation\n\nopen import Function \n-- some trivial lemma\n\n∣p∣≡0→≡⊥ : ∀ {n}(p : Subset n) → ∣ p ∣ ≡ 0 → p ≡ ⊥\n∣p∣≡0→≡⊥ {ℕ.zero} [] refl = refl\n∣p∣≡0→≡⊥ {ℕ.suc n} (outside ∷ p) eq = cong (outside ∷_) (∣p∣≡0→≡⊥ p eq)\n∣p∣≡0→≡⊥ {ℕ.suc n} (inside ∷ p) () \n\n∣p∣≡n→≡⊤ : ∀ {n}(p : Subset n) → ∣ p ∣ ≡ n → p ≡ ⊤\n∣p∣≡n→≡⊤ {ℕ.zero} [] refl = refl\n∣p∣≡n→≡⊤ {ℕ.suc n} (outside ∷ p) eq = ⊥-elim (1+n≰n (≤-respˡ-≈ eq (∣p∣≤n p)))\n where\n open IsPartialOrder NP.≤-isPartialOrder using (≤-respˡ-≈) \n∣p∣≡n→≡⊤ {ℕ.suc n} (inside ∷ p) eq = cong (inside ∷_) (∣p∣≡n→≡⊤ p (NP.suc-injective eq)) \n\n∣p∣≡1→≡⁅x⁆ : ∀ {n}(p : Subset n) → ∣ p ∣ ≡ 1 → ∃ λ x → p ≡ ⁅ x ⁆ \n∣p∣≡1→≡⁅x⁆ {ℕ.zero} [] ()\n∣p∣≡1→≡⁅x⁆ {ℕ.suc n} (outside ∷ p) eq with ∣p∣≡1→≡⁅x⁆ p eq\n... | x , q = suc x , cong (outside ∷_) q\n∣p∣≡1→≡⁅x⁆ {ℕ.suc n} (inside ∷ p) eq rewrite ∣p∣≡0→≡⊥ p (NP.suc-injective eq) = zero , refl\n\n-- union\n\n≤∪ˡ : ∀ {n} {p} (q : Subset n) → ∣ p ∣ ℕ.≤ ∣ p ∪ q ∣ \n≤∪ˡ {n}{p} q = p⊆q⇒∣p∣<∣q∣ (p⊆p∪q {p = p} q)\n≤∪ʳ : ∀ {n} (p q : Subset n) → ∣ q ∣ ℕ.≤ ∣ p ∪ q ∣ \n≤∪ʳ p q = p⊆q⇒∣p∣<∣q∣ (q⊆p∪q p q)\n\n∪≤ : ∀ {n} (p q : Subset n) → ∣ p ∪ q ∣ ℕ.≤ ∣ p ∣ ℕ.+ ∣ q ∣\n∪≤ {ℕ.zero} [] [] = ℕ.z≤n\n∪≤ {ℕ.suc n} (outside ∷ p) (outside ∷ q) = ∪≤ p q\n∪≤ {ℕ.suc n} (outside ∷ p) (inside ∷ q) rewrite +-suc ∣ p ∣ ∣ q ∣ = ℕ.s≤s (∪≤ p q)\n∪≤ {ℕ.suc n} (inside ∷ p) (outside ∷ q) = ℕ.s≤s (∪≤ p q)\n∪≤ {ℕ.suc n} (inside ∷ p) (inside ∷ q) = ℕ.s≤s (NP.≤-trans (∪≤ p q) (NP.+-mono-≤ (≤-refl {∣ p ∣}) (n≤1+n _)))\n\n\n\ndisjoint-∪≡+ : ∀ {n} (p q : Subset n) → p ∩ q ≡ ⊥ → ∣ p ∪ q ∣ ≡ ∣ p ∣ ℕ.+ ∣ q ∣\ndisjoint-∪≡+ {ℕ.zero} [] [] refl = refl\ndisjoint-∪≡+ {ℕ.suc n} (outside ∷ p) (outside ∷ q) dis = disjoint-∪≡+ p q (VP.∷-injectiveʳ dis)\ndisjoint-∪≡+ {ℕ.suc n} (outside ∷ p) (inside ∷ q) dis =\n Eq.trans (Eq.cong ℕ.suc (disjoint-∪≡+ p q (VP.∷-injectiveʳ dis))) (Eq.sym (NP.+-suc _ _))\ndisjoint-∪≡+ {ℕ.suc n} (inside ∷ p) (outside ∷ q) dis = Eq.cong ℕ.suc (disjoint-∪≡+ p q (VP.∷-injectiveʳ dis))\ndisjoint-∪≡+ {ℕ.suc n} (inside ∷ p) (inside ∷ q) ()\n\n\nx∈p⇒⁅x⁆∪p≡p : ∀ {n} (x : Fin n)(p : Subset n) → x ∈ p → ⁅ x ⁆ ∪ p ≡ p\nx∈p⇒⁅x⁆∪p≡p x p x∈p = ⊆-antisym from to\n where\n from : ∀ {y} → y ∈ ⁅ x ⁆ ∪ p → y ∈ p\n from h with x∈p∪q⁻ ⁅ x ⁆ p h\n from h | inj₁ y∈⁅x⁆ rewrite x∈⁅y⁆⇒x≡y _ y∈⁅x⁆ = x∈p\n from h | inj₂ y∈p = y∈p\n \n \n to : ∀ {y} → y ∈ p → y ∈ ⁅ x ⁆ ∪ p\n to h = x∈p∪q⁺ (inj₂ h)\n\n\n∣⁅x⁆∪p∣≡1+∣p∣⇒x∉p : ∀ {n}(x : Fin n)(p : Subset n) → ∣ ⁅ x ⁆ ∪ p ∣ ≡ 1 ℕ.+ ∣ p ∣ → x ∉ p\n∣⁅x⁆∪p∣≡1+∣p∣⇒x∉p x p h x∈p rewrite x∈p⇒⁅x⁆∪p≡p x p x∈p = contradiction h lemma\n where\n lemma : ∀ {n} → n ≢ ℕ.suc n\n lemma ()\n\n∣⁅x⁆∪⁅y⁆∣≡2⇒x≢y : ∀ {n}(x y : Fin n) → ∣ ⁅ x ⁆ ∪ ⁅ y ⁆ ∣ ≡ 2 → x ≢ y\n∣⁅x⁆∪⁅y⁆∣≡2⇒x≢y x .x h refl with ∣⁅x⁆∪p∣≡1+∣p∣⇒x∉p x ⁅ x ⁆ (trans h (cong ℕ.suc (sym (∣⁅x⁆∣≡1 x))))\n... | x∉⁅y⁆ = contradiction (x∈⁅x⁆ _) x∉⁅y⁆\n\n\nmodule _ {n : ℕ} where\n open import Algebra.Structures {A = Subset n} _≡_\n open IsBooleanAlgebra (∪-∩-isBooleanAlgebra n) renaming (∧-complementʳ to ∩-complementʳ; ∨-complementʳ to ∪-complementʳ) \n ∣p∣+∣∁p∣≡n : ∀ (p : Subset n) → ∣ p ∣ ℕ.+ ∣ ∁ p ∣ ≡ n\n ∣p∣+∣∁p∣≡n p = ∣ p ∣ ℕ.+ ∣ ∁ p ∣\n ≡⟨ Eq.sym (disjoint-∪≡+ _ _ (∩-complementʳ p)) ⟩ _\n ≡⟨ Eq.cong ∣_∣ (∪-complementʳ p) ⟩ _ \n ≡⟨ ∣⊤∣≡n _ ⟩ n ∎\n where\n open Eq.≡-Reasoning\n\n∩≤ˡ : ∀ {n} (a b : Subset n) → ∣ a ∩ b ∣ ℕ.≤ ∣ a ∣\n∩≤ˡ {n} a b = p⊆q⇒∣p∣<∣q∣ (p∩q⊆p a b)\n\n∩≤ʳ : ∀ {n} (a b : Subset n) → ∣ a ∩ b ∣ ℕ.≤ ∣ b ∣\n∩≤ʳ {n} a b = p⊆q⇒∣p∣<∣q∣ (p∩q⊆q a b)\n\n∣p∣<∣q∣⇒∣∁q∣<∣∁p∣ : ∀ {n} (p q : Subset n) → ∣ p ∣ ℕ.< ∣ q ∣ → ∣ ∁ q ∣ ℕ.< ∣ ∁ p ∣\n∣p∣<∣q∣⇒∣∁q∣<∣∁p∣ p q p Bool\nnot true = false\nnot false = true\n\nnotnot : Bool -> Bool\nnotnot true = not (not true)\nnotnot false = not (not false)\n\nif_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A\nif true then t else f = t\nif false then t else f = f\n\n", "meta": {"hexsha": "0b23c146cc2c04909f07dd492cef030970354b0d", "size": 348, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Common/Bool.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/Common/Bool.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/Common/Bool.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": 19.3333333333, "max_line_length": 52, "alphanum_fraction": 0.6551724138, "num_tokens": 108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920211198871, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.5853527661886417}} {"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class\nopen import Oscar.Class.Reflexivity\nopen import Oscar.Class.Smap\nopen import Oscar.Class.Surjextensionality\nopen import Oscar.Class.Surjidentity\nopen import Oscar.Class.Surjtranscommutativity\nopen import Oscar.Class.HasEquivalence\nopen import Oscar.Class.Transitivity\nopen import Oscar.Class.Thickandthin\nopen import Oscar.Class.IsPrefunctor\nopen import Oscar.Class.IsFunctor\nopen import Oscar.Data.Maybe\nopen import Oscar.Data.¶\nopen import Oscar.Data.Fin\nopen import Oscar.Data.Proposequality\nopen import Oscar.Data.Substitunction\nopen import Oscar.Data.Term\nopen import Oscar.Data.Substitist\nopen import Oscar.Data.Descender\nimport Oscar.Property.Setoid.Proposextensequality\nimport Oscar.Property.Functor.SubstitunctionExtensionTerm\nimport Oscar.Property.Category.AListProposequality\nimport Oscar.Property.Category.ExtensionProposextensequality\nimport Oscar.Property.Thickandthin.FinFinProposequalityMaybeProposequality\nimport Oscar.Class.HasEquivalence.Substitunction\nimport Oscar.Class.Surjection.⋆\n\nmodule Oscar.Property.Functor.SubstitistProposequalitySubstitunctionProposextensequality where\n\nmodule _ {𝔭} {𝔓 : Ø 𝔭} where\n\n open Substitunction 𝔓\n open Term 𝔓\n open Substitist 𝔓\n\n _for_ : ∀ {n} (t' : Term n) (x : Fin (↑ n)) → Fin (↑ n) → Term n\n (t for x) y = maybe′ ε t (check[ Maybe ] x y)\n\n instance\n\n 𝓢urjectivitySubstitist,Substitunction : Smap.class Substitist Substitunction ¡ ¡\n 𝓢urjectivitySubstitist,Substitunction .⋆ _ _ ∅ = i\n 𝓢urjectivitySubstitist,Substitunction .⋆ _ _ ((x , t) , σ) = 𝓢urjectivitySubstitist,Substitunction .⋆ _ _ σ ∙ (t for x)\n\n 𝓢urjextensionalitySubstitist,Substitunction : Surjextensionality.class Substitist Proposequality Substitunction _≈_ ¡ smap\n 𝓢urjextensionalitySubstitist,Substitunction .⋆ _ _ _ _ ∅ _ = ∅\n\n 𝓢urjtranscommutativitySubstitist,Substitunction : Surjtranscommutativity.class Substitist Substitunction _≈_ smap transitivity transitivity\n 𝓢urjtranscommutativitySubstitist,Substitunction .⋆ ∅ _ _ = ∅\n 𝓢urjtranscommutativitySubstitist,Substitunction .⋆ ((π₀ , π₁) , f) g =\n let _⟪∙⟫′_ = flip (𝓢urjtranscommutativitySubstitist,Substitunction .⋆) in -- kludge for Agda's termination checker\n\n (\n § g ⟪∙⟫ §[ Substitunction ] f\n ∙\n ⟪ g ⟪∙⟫′ f ⟫[ Proposextensequality ]\n )\n ∘\n π₁ for π₀\n\n\n IsPrefunctorSubstitist,Substitunction : IsPrefunctor Substitist Proposequality transitivity Substitunction _≈_ transitivity smap\n IsPrefunctorSubstitist,Substitunction = ∁\n\n 𝓢urjidentitySubstitist,Substitunction : Surjidentity.class Substitist Substitunction _≈_ smap ε ε\n 𝓢urjidentitySubstitist,Substitunction .⋆ _ = ∅\n\n IsFunctorSubstitist,Substitunction : IsFunctor Substitist Proposequality ε transitivity Substitunction _≈_ ε transitivity smap\n IsFunctorSubstitist,Substitunction = ∁\n", "meta": {"hexsha": "09c38133265d08162f7f2c7bc592430597fc00ea", "size": 2894, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Functor/SubstitistProposequalitySubstitunctionProposextensequality.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/Functor/SubstitistProposequalitySubstitunctionProposextensequality.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/Functor/SubstitistProposequalitySubstitunctionProposextensequality.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.1944444444, "max_line_length": 143, "alphanum_fraction": 0.7791983414, "num_tokens": 907, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9136765234137296, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.5853339406243008}} {"text": "module Curry5 where\r\n\r\nopen import Relation.Binary.PropositionalEquality as PropEq using (_≡_; subst)\r\nopen import Function using (id)\r\n\r\nlemma1 : {X Y : Set} → (X ≡ (X → Y)) → X\r\nlemma1 p rewrite p = (λ x → let f = subst id p x in f x)\r\n\r\ncurry : {X Y : Set} → (X ≡ (X → Y)) → Y\r\ncurry p = (let f = subst id p (lemma1 p) in f (lemma1 p))\r\n\r\n\r\n\r\n", "meta": {"hexsha": "ce59376517b8f34e5f11f7b08b0d8dd7569675f4", "size": 346, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Curry5.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": "Curry5.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": "Curry5.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": 24.7142857143, "max_line_length": 79, "alphanum_fraction": 0.5924855491, "num_tokens": 119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.913676514011486, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.5853339346008865}} {"text": "module Data.QuadTree.Implementation.PropDepthRelation where\n\nopen import Haskell.Prelude\nopen import Data.Logic\n\n---- Properties of depth\n\nlteTransitiveWeird : (x y d : Nat) -> IsTrue (x < y) -> (y <= d) ≡ ((x <= d) && (y <= d))\nlteTransitiveWeird zero zero zero xlty = refl\nlteTransitiveWeird zero zero (suc d) xlty = refl\nlteTransitiveWeird zero (suc y) zero xlty = refl\nlteTransitiveWeird zero (suc y) (suc d) xlty = refl\nlteTransitiveWeird (suc x) (suc y) zero xlty = refl\nlteTransitiveWeird (suc x) (suc y) (suc d) xlty = lteTransitiveWeird x y d xlty\n\nlteTransitiveWeirdInv : (x y d : Nat) -> IsFalse (x < y) -> (x <= d) ≡ ((x <= d) && (y <= d))\nlteTransitiveWeirdInv zero zero zero xnlty = refl\nlteTransitiveWeirdInv zero zero (suc d) xnlty = refl\nlteTransitiveWeirdInv (suc x) zero zero xnlty = refl\nlteTransitiveWeirdInv (suc x) zero (suc d) xnlty =\n begin\n (suc x <= suc d)\n =⟨ sym $ boolAndTrue (suc x <= suc d) ⟩\n (suc x <= suc d) && true\n =⟨⟩\n ((suc x <= suc d) && (zero <= suc d))\n end\nlteTransitiveWeirdInv (suc x) (suc y) zero xnlty = refl\nlteTransitiveWeirdInv (suc x) (suc y) (suc d) xnlty = lteTransitiveWeirdInv x y d xnlty\n\nifComparisonMap : (x y d : Nat) -> ((x <= d) && (y <= d)) ≡ (if x < y then (y <= d) else (x <= d))\nifComparisonMap x y d = ifc x < y \n then (λ {{xlty}} ->\n begin\n (x <= d) && (y <= d)\n =⟨ sym $ lteTransitiveWeird x y d xlty ⟩\n y <= d\n =⟨ sym $ ifTrue (x < y) xlty ⟩\n (if x < y then (y <= d) else (x <= d))\n end\n )\n else (λ {{xnlty}} ->\n begin\n (x <= d) && (y <= d)\n =⟨ sym $ lteTransitiveWeirdInv x y d xnlty ⟩\n x <= d\n =⟨ sym $ ifFalse (x < y) xnlty ⟩\n (if x < y then (y <= d) else (x <= d))\n end\n )\n\npropMaxLte : (x y d : Nat) -> ((x <= d) && (y <= d)) ≡ (max x y <= d)\npropMaxLte x y d = \n begin\n (x <= d) && (y <= d)\n =⟨ ifComparisonMap x y d ⟩\n (if x < y then (y <= d) else (x <= d))\n =⟨ propFnIf (λ v -> v <= d) ⟩\n (if x < y then y else x) <= d\n =⟨⟩\n max x y <= d\n end\n\npropAndMap : (a b c d : Bool) -> a ≡ c -> b ≡ d -> (a && b) ≡ (c && d)\npropAndMap false false false false ac bd = refl\npropAndMap false true false true ac bd = refl\npropAndMap true false true false ac bd = refl\npropAndMap true true true true ac bd = refl\n\npropMaxLte4 : (w x y z d : Nat) -> (((w <= d) && (x <= d)) && ((y <= d) && (z <= d))) ≡ (max (max w x) (max y z) <= d)\npropMaxLte4 w x y z d =\n begin\n ((w <= d) && (x <= d)) && ((y <= d) && (z <= d))\n =⟨ propAndMap ((w <= d) && (x <= d)) ((y <= d) && (z <= d)) (max w x <= d) (max y z <= d) (propMaxLte w x d) (propMaxLte y z d) ⟩\n (max w x <= d) && (max y z <= d)\n =⟨ propMaxLte (if w < x then x else w) (if y < z then z else y) d ⟩\n (max (max w x) (max y z) <= d)\n end\n", "meta": {"hexsha": "1a2eb7f674ec4561c12315c884c154bf40eaf02f", "size": 2749, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/QuadTree/Implementation/PropDepthRelation.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/QuadTree/Implementation/PropDepthRelation.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/QuadTree/Implementation/PropDepthRelation.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": 34.7974683544, "max_line_length": 131, "alphanum_fraction": 0.5452891961, "num_tokens": 1120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587993853654, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.5851743413364678}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import cohomology.Exactness\nopen import cohomology.Theory\n\nmodule cohomology.Unit {i} (CT : CohomologyTheory i) where\n\nopen CohomologyTheory CT\n\nmodule _ (n : ℤ) where\n\n private\n ⊙LU = ⊙Lift {j = i} ⊙Unit\n\n Cof-Unit-is-Unit : ⊙Cof (⊙idf ⊙LU) == ⊙LU\n Cof-Unit-is-Unit = ⊙ua (⊙≃-in {X = _ , cfbase} e idp)\n where\n e : Cofiber (idf (Lift {j = i} Unit)) ≃ Lift Unit\n e = equiv (λ _ → lift unit)\n (λ _ → cfbase)\n (λ _ → idp)\n (Cofiber-elim {f = idf _}\n {P = λ c → cfbase == c}\n idp\n (λ _ → cfglue (lift unit))\n (λ _ → ↓-cst=idf-in idp))\n\n C-Unit-is-contr : is-contr (CEl n ⊙LU)\n C-Unit-is-contr =\n (Cid n ⊙LU , λ x → lemma₂ x ∙ app= (ap GroupHom.f (CF-ident n)) x)\n where\n lemma₁ : (x : CEl n (⊙Cof (⊙idf _)))\n → Cid n ⊙LU == CF n (⊙cfcod' (⊙idf _)) x\n lemma₁ x = ! (itok (C-exact n (⊙idf _)) _ [ x , idp ])\n ∙ app= (ap GroupHom.f (CF-ident n))\n (CF n (⊙cfcod' (⊙idf _)) x)\n\n lemma₂ : (x : CEl n ⊙LU) → Cid n ⊙LU == CF n (⊙idf _) x\n lemma₂ = transport\n {A = Σ (Ptd i) (λ X → fst (⊙LU ⊙→ X))}\n (λ {(X , H) → (c : CEl n X) → Cid n ⊙LU == CF n H c})\n (pair= Cof-Unit-is-Unit\n (prop-has-all-paths-↓ (⊙→-level (Lift-level Unit-is-prop))))\n lemma₁\n\n C-Unit : C n ⊙LU == 0ᴳ\n C-Unit = contr-is-0ᴳ _ C-Unit-is-contr\n", "meta": {"hexsha": "01695d42215c72f0931233c21e5ea46712afbff6", "size": 1465, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/Unit.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/Unit.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/Unit.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": 29.8979591837, "max_line_length": 73, "alphanum_fraction": 0.4860068259, "num_tokens": 603, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392848011833, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5851658257599713}} {"text": "{-# OPTIONS --warning=error --safe #-}\n\nopen import LogicalFormulae\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Functions.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\n\nmodule Numbers.Naturals.WithK where\n\nA_ : A → A → Set ℓ') where\n\n-- data tc : A → A → Set (ℓ ⊔ ℓ') where\n-- tc-step : ∀{a b : A} → a >A b → tc a b\n-- tc-trans : ∀{a b c : A} → tc a b → tc b c → tc a c\n\n-- data rc : A → A → Set (ℓ ⊔ ℓ') where\n-- rc-step : ∀{a b : A} → a >A b → rc a b\n-- rc-refl : ∀{a : A} → rc a a\n \n-- tc-transitive : transitive tc\n-- tc-transitive = tc-trans \n\n-- module combinations {ℓ ℓ' : level}{A : Set ℓ} (_>A_ : A → A → Set ℓ') where\n-- open basics public\n\n-- rtc : A → A → Set (ℓ ⊔ ℓ')\n-- rtc = rc (tc _>A_)\n\n-- rtc-refl : reflexive rtc\n-- rtc-refl = rc-refl\n\n-- rtc-trans : transitive rtc\n-- rtc-trans (rc-step{a}{b} x) (rc-step{.b}{c} x') = rc-step (tc-trans x x')\n-- rtc-trans (rc-step x) rc-refl = rc-step x\n-- rtc-trans rc-refl (rc-step x) = rc-step x\n-- rtc-trans rc-refl rc-refl = rc-refl\n\n", "meta": {"hexsha": "14c90209b52176a4d7353a32356eeef956ca13bb", "size": 1072, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "closures.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": "closures.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": "closures.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": 28.2105263158, "max_line_length": 81, "alphanum_fraction": 0.5195895522, "num_tokens": 392, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094032139576, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.5850236195685894}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommMonoid.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Equiv.HalfAdjoint\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Transport\nopen import Cubical.Foundations.SIP\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Semigroup\nopen import Cubical.Algebra.Monoid.Base\n\nopen import Cubical.Displayed.Base\nopen import Cubical.Displayed.Auto\nopen import Cubical.Displayed.Record\nopen import Cubical.Displayed.Universe\n\nopen import Cubical.Reflection.RecordEquiv\n\nopen Iso\n\nprivate\n variable\n ℓ ℓ' : Level\n\nrecord IsCommMonoid {A : Type ℓ} (ε : A) (_·_ : A → A → A) : Type ℓ where\n constructor iscommmonoid\n\n field\n isMonoid : IsMonoid ε _·_\n comm : (x y : A) → x · y ≡ y · x\n\n open IsMonoid isMonoid public\n\nunquoteDecl IsCommMonoidIsoΣ = declareRecordIsoΣ IsCommMonoidIsoΣ (quote IsCommMonoid)\n\nrecord CommMonoidStr (A : Type ℓ) : Type ℓ where\n constructor commmonoidstr\n\n field\n ε : A\n _·_ : A → A → A\n isCommMonoid : IsCommMonoid ε _·_\n\n infixl 7 _·_\n\n open IsCommMonoid isCommMonoid public\n\nCommMonoid : ∀ ℓ → Type (ℓ-suc ℓ)\nCommMonoid ℓ = TypeWithStr ℓ CommMonoidStr\n\ncommmonoid : (A : Type ℓ) (ε : A) (_·_ : A → A → A) (h : IsCommMonoid ε _·_) → CommMonoid ℓ\ncommmonoid A ε _·_ h = A , commmonoidstr ε _·_ h\n\n-- Easier to use constructors\nmakeIsCommMonoid : {M : Type ℓ} {ε : M} {_·_ : M → M → M}\n (is-setM : isSet M)\n (assoc : (x y z : M) → x · (y · z) ≡ (x · y) · z)\n (rid : (x : M) → x · ε ≡ x)\n (lid : (x : M) → ε · x ≡ x)\n (comm : (x y : M) → x · y ≡ y · x)\n → IsCommMonoid ε _·_\nIsCommMonoid.isMonoid (makeIsCommMonoid is-setM assoc rid lid comm) =\n makeIsMonoid is-setM assoc rid lid\nIsCommMonoid.comm (makeIsCommMonoid is-setM assoc rid lid comm) = comm\n\nmakeCommMonoid : {M : Type ℓ} (ε : M) (_·_ : M → M → M)\n (is-setM : isSet M)\n (assoc : (x y z : M) → x · (y · z) ≡ (x · y) · z)\n (rid : (x : M) → x · ε ≡ x)\n (lid : (x : M) → ε · x ≡ x)\n (comm : (x y : M) → x · y ≡ y · x)\n → CommMonoid ℓ\nmakeCommMonoid ε _·_ is-setM assoc rid lid comm =\n commmonoid _ ε _·_ (makeIsCommMonoid is-setM assoc rid lid comm)\n\n\n\nCommMonoidStr→MonoidStr : {A : Type ℓ} → CommMonoidStr A → MonoidStr A\nCommMonoidStr→MonoidStr (commmonoidstr _ _ H) = monoidstr _ _ (IsCommMonoid.isMonoid H)\n\nCommMonoid→Monoid : CommMonoid ℓ → Monoid ℓ\nCommMonoid→Monoid (_ , commmonoidstr _ _ H) = _ , monoidstr _ _ (IsCommMonoid.isMonoid H)\n\n\nCommMonoidHom : (L : CommMonoid ℓ) (M : CommMonoid ℓ') → Type (ℓ-max ℓ ℓ')\nCommMonoidHom L M = MonoidHom (CommMonoid→Monoid L) (CommMonoid→Monoid M)\n\nIsCommMonoidEquiv : {A : Type ℓ} {B : Type ℓ'}\n (M : CommMonoidStr A) (e : A ≃ B) (N : CommMonoidStr B) → Type (ℓ-max ℓ ℓ')\nIsCommMonoidEquiv M e N = IsMonoidHom (CommMonoidStr→MonoidStr M) (e .fst) (CommMonoidStr→MonoidStr N)\n\nCommMonoidEquiv : (M : CommMonoid ℓ) (N : CommMonoid ℓ') → Type (ℓ-max ℓ ℓ')\nCommMonoidEquiv M N = Σ[ e ∈ (M .fst ≃ N .fst) ] IsCommMonoidEquiv (M .snd) e (N .snd)\n\nisPropIsCommMonoid : {M : Type ℓ} (ε : M) (_·_ : M → M → M)\n → isProp (IsCommMonoid ε _·_)\nisPropIsCommMonoid ε _·_ (iscommmonoid MM MC) (iscommmonoid SM SC) =\n λ i → iscommmonoid (isPropIsMonoid _ _ MM SM i) (isPropComm MC SC i)\n where\n isSetM : isSet _\n isSetM = MM .IsMonoid.isSemigroup .IsSemigroup.is-set\n\n isPropComm : isProp ((x y : _) → x · y ≡ y · x)\n isPropComm = isPropΠ2 λ _ _ → isSetM _ _\n\n𝒮ᴰ-CommMonoid : DUARel (𝒮-Univ ℓ) CommMonoidStr ℓ\n𝒮ᴰ-CommMonoid =\n 𝒮ᴰ-Record (𝒮-Univ _) IsCommMonoidEquiv\n (fields:\n data[ ε ∣ autoDUARel _ _ ∣ presε ]\n data[ _·_ ∣ autoDUARel _ _ ∣ isHom ]\n prop[ isCommMonoid ∣ (λ _ _ → isPropIsCommMonoid _ _) ])\n where\n open CommMonoidStr\n open IsMonoidHom\n\nCommMonoidPath : (M N : CommMonoid ℓ) → CommMonoidEquiv M N ≃ (M ≡ N)\nCommMonoidPath = ∫ 𝒮ᴰ-CommMonoid .UARel.ua\n", "meta": {"hexsha": "7bec68f71e5a3c06afeb62c74c171198c75aa955", "size": 4228, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommMonoid/Base.agda", "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 301, "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_issues_repo_path": "Cubical/Algebra/CommMonoid/Base.agda", "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 584, "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_forks_repo_path": "Cubical/Algebra/CommMonoid/Base.agda", "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 134, "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "avg_line_length": 33.5555555556, "max_line_length": 102, "alphanum_fraction": 0.6449858089, "num_tokens": 1569, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.7690802370707281, "lm_q1q2_score": 0.585001384289053}} {"text": "module Category.Functor.Lawful where\nopen import Agda.Primitive using (lsuc; _⊔_)\nopen import Category.Functor\nopen import Category.Applicative\nopen import Function using (id; _∘_)\nopen import Relation.Binary.PropositionalEquality using (_≡_; module ≡-Reasoning; sym; cong)\n\nrecord LawfulFunctorImp {l₁ l₂} {F : Set l₁ → Set l₂} (FFunc : RawFunctor F) : Set (lsuc l₁ ⊔ l₂) where\n open RawFunctor FFunc\n field\n <$>-identity : ∀ {a} {x : F a} → (id <$> x) ≡ x\n <$>-compose : ∀ {a b c} {f : a → b} {g : b → c} {x : F a} → ((g ∘ f) <$> x) ≡ (g <$> (f <$> x))\n\nmodule LawfulFunctor {l₁ l₂} {F : Set l₁ → Set l₂} {FFunc : RawFunctor F} (FLawful : LawfulFunctorImp FFunc) where\n open RawFunctor FFunc public\n open LawfulFunctorImp FLawful public\n\nrecord LawfulApplicativeImp {l} {F : Set l → Set l} (FAppl : RawApplicative F) : Set (lsuc l) where\n open RawApplicative FAppl\n field\n ⊛-identity : ∀ {A} {u : F A} → (pure id ⊛ u) ≡ u\n ⊛-homomorphism : ∀ {A B} {u : A → B } {v : A} → (pure u ⊛ pure v) ≡ pure (u v)\n ⊛-interchange : ∀ {A B} {u : F (A → B)} {v : A} → (u ⊛ pure v) ≡ (pure (λ uᵢ → uᵢ v) ⊛ u)\n ⊛-composition : ∀ {A B C} {u : F (B → C)} {v : F (A → B)} {w : F A} → (pure (λ f g a → f (g a)) ⊛ u ⊛ v ⊛ w) ≡ (u ⊛ (v ⊛ w))\n open ≡-Reasoning\n private\n composelemma : ∀ {a b c} {f : a → b} {g : b → c} {x : F a} → ((g ∘ f) <$> x) ≡ (g <$> (f <$> x))\n composelemma {_} {_} {_} {f} {g} {x} =\n pure (λ x₁ → g (f x₁)) ⊛ x ≡⟨ cong (_⊛ x) (sym ⊛-homomorphism) ⟩\n pure (λ f x → g (f x)) ⊛ pure f ⊛ x ≡⟨ cong ((_⊛ x) ∘ (_⊛ pure f)) (sym ⊛-homomorphism) ⟩\n pure (λ g f x → g (f x)) ⊛ pure g ⊛ pure f ⊛ x ≡⟨ ⊛-composition ⟩\n pure g ⊛ (pure f ⊛ x) ∎\n isLawfulFunctor : LawfulFunctorImp rawFunctor\n isLawfulFunctor = record\n { <$>-identity = ⊛-identity\n ; <$>-compose = composelemma\n }\n\nmodule LawfulApplicative {l} {F : Set l → Set l} (FAppl : RawApplicative F) (FLawful : LawfulApplicativeImp FAppl) where\n open RawApplicative FAppl public\n open LawfulApplicativeImp FLawful public\n open LawfulFunctorImp isLawfulFunctor public\n", "meta": {"hexsha": "5b34c43eb121d8a498fce1fa6c42f314042e2b4e", "size": 2167, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Category/Functor/Lawful.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/Category/Functor/Lawful.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/Category/Functor/Lawful.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": 50.3953488372, "max_line_length": 129, "alphanum_fraction": 0.5574526996, "num_tokens": 877, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467580102418, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.5849935471346206}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nmodule hSet where\n \n open import lib.Basics\n open import lib.Funext\n open import lib.NType2\n open import lib.types.Truncation\n open import lib.types.Bool\n open import PropT\n\n _is-a-set : {i : ULevel} (A : Type i) → Type i\n A is-a-set = is-set A\n\n -- To get an element a of the set A is to give a : ∈ A.\n ∈ : {i : ULevel} (A : hSet i) → Type i\n ∈ = fst\n\n set-is-a-set : {i : ULevel} (A : hSet i) → (∈ A) is-a-set\n set-is-a-set A = snd A\n\n -- Equality for sets, landing in Prop\n _==ₚ_ : {i : ULevel} {A : hSet i}\n → (x y : ∈ A) → PropT i\n _==ₚ_ {_} {A} x y = (x == y) , has-level-apply (set-is-a-set A) x y\n\n _=bool=_ : {i : ULevel} {A : Type i} {p : has-dec-eq A}\n → (x y : A) → Bool\n _=bool=_ {p = p} x y = case (p x y)\n where case : Dec (x == y) → Bool\n case (inl _) = true\n case (inr _) = false\n\n ∥_∥₀ : ∀ {i} (A : Type i) → Type i\n ∥_∥₀ = Trunc 0\n", "meta": {"hexsha": "93445ee1d498c839d1c6edd25f2ddd4de79a84bd", "size": 955, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "cohesion/david_jaz_261/hSet.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/hSet.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/hSet.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": 26.5277777778, "max_line_length": 69, "alphanum_fraction": 0.5256544503, "num_tokens": 376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467738423874, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.5849935401696339}} {"text": "module Stack where\n\nopen import Data.Bool using (Bool; true; false)\nopen import Data.Nat using (ℕ; zero; suc)\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_≡_; refl; cong)\nopen Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎; step-≡)\n\nmodule V1 where\n {-\n This first version introduces the Stack abstract data type.\n -}\n\n data Stack (A : Set) : Set where\n ∅ : Stack A\n _>>_ : A → Stack A → Stack A\n\n infixr 50 _>>_\n\n push : ∀ {A} → A → Stack A → Stack A\n push a s = a >> s\n\n peek : ∀ {A} → (S : Stack A) → A\n -- May be absurd can be used here but how?\n peek (a >> _) = a\n\n pop : ∀ {A} → (S : Stack A) → Stack A\n -- May be absurd can be used here but how?\n pop (a >> s) = s\n\n module Example where\n _ : Stack Bool\n _ = true >> false >> ∅\n\n module Laws where\n law1 : ∀ {A} (a : A) (s : Stack A) -> peek (push a s) ≡ a\n law1 a s =\n begin\n peek (push a s)\n ≡⟨⟩\n peek (a >> s)\n ≡⟨⟩\n a\n ∎\n\n law2 : ∀ {A} {a : A} {s : Stack A} → pop (push a s) ≡ s\n law2 = refl\n\nmodule V2 where\n {-\n This second version introduces the expression as constraint in the type definition.\n This prevents incomplete pattern matching for peek and pop.\n\n For this purpose we first design empty? predicate and then we use it in the type definition\n of peek and pop.\n -}\n\n data Stack (A : Set) : Set where\n ∅ : Stack A\n _>>_ : A → Stack A → Stack A\n\n infixr 50 _>>_\n\n empty? : ∀ {A} → Stack A → Bool\n empty? ∅ = true\n empty? _ = false\n\n push : ∀ {A} → A → Stack A → Stack A\n push a s = a >> s\n\n peek : ∀ {A} → (S : Stack A) -> {empty? S ≡ false} → A\n peek (a >> _) = a\n\n pop : ∀ {A} → (S : Stack A) -> {empty? S ≡ false} → Stack A\n pop (a >> s) = s\n\n module Example where\n _ : Stack Bool\n _ = pop (push true ∅) {refl}\n\n module Laws where\n law1 : ∀ {A} {a : A} {s : Stack A} → peek (push a s) {refl} ≡ a\n law1 = refl\n\n law2 : ∀ {A} {a : A} {s : Stack A} → pop (push a s) {refl} ≡ s\n law2 = refl\n\nmodule V3 where\n {-\n In this third version we use a GADT for the Stack data representation.\n A Kind then is design on purpose and a phantom type is used for the\n association between the stack and the kind.\n -}\n\n data Kind : Set where\n Empty : Kind\n NotEmpty : Kind\n\n data Stack (A : Set) : Kind → Set where\n ∅ : Stack A Empty\n _>>_ : ∀ {B} → A → Stack A B → Stack A NotEmpty\n\n infixr 50 _>>_\n\n push : ∀ {A B} → A → Stack A B → Stack A NotEmpty\n push a s = a >> s\n\n peek : ∀ {A} → Stack A NotEmpty → A\n peek (a >> _) = a\n\n {-\n B is in the ouput only! => No constraint with the input.\n Writing such pop function is impossible as is.\n\n pop : ∀ {A B} → Stack A NotEmpty → Stack A B\n pop (_ >> s) = s\n -}\n\n module Example where\n _ : Stack Bool NotEmpty\n _ = push true ∅\n\n module Laws where\n law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a\n law1 = refl\n\n -- law2 cannot be expressed ...\n\nmodule V4 where\n {-\n In this fourth version we slightly review the NotEmpty construction.\n This opens the opportunity to express the pop function since a\n dependency can by modeled in the corresponding type definition.\n -}\n data Kind : Set where\n Empty : Kind\n NotEmpty : Kind → Kind\n\n data Stack (A : Set) : Kind → Set where\n ∅ : Stack A Empty\n _>>_ : ∀ {B} → A → Stack A B → Stack A (NotEmpty B)\n\n infixr 50 _>>_\n\n push : ∀ {A B} → A → Stack A B → Stack A (NotEmpty B)\n push a s = a >> s\n\n peek : ∀ {A B} → Stack A (NotEmpty B) → A\n peek (a >> _) = a\n\n pop : ∀ {A B} → Stack A (NotEmpty B) → Stack A B\n pop (_ >> s) = s\n\n module Example where\n _ : Stack Bool (NotEmpty Empty)\n _ = push true ∅\n\n module Laws where\n law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a\n law1 = refl\n\n law2 : ∀ {A B} {a : A} {s : Stack A B} → pop (push a s) ≡ s\n law2 = refl\n\nmodule V5 where\n {-\n In this last version we show that previous Kind definiton is isomorphic\n with the Natural.\n -}\n\n data Stack (A : Set) : ℕ → Set where\n ∅ : Stack A 0\n _>>_ : ∀ {B} → A → Stack A B → Stack A (suc B)\n\n infixr 50 _>>_\n\n push : ∀ {A B} → A → Stack A B → Stack A (suc B)\n push a s = a >> s\n\n peek : ∀ {A B} → Stack A (suc B) → A\n peek (a >> _) = a\n\n pop : ∀ {A B} → Stack A (suc B) → Stack A B\n pop (_ >> s) = s\n\n module Example where\n _ : Stack Bool 1\n _ = push true ∅\n\n module Laws where\n law1 : ∀ {A B} {a : A} {s : Stack A B} → peek (push a s) ≡ a\n law1 = refl\n\n law2 : ∀ {A B} {a : A} {s : Stack A B} → pop (push a s) ≡ s\n law2 = refl\n", "meta": {"hexsha": "500c028baa3002d38b1cd69b3b8c22e8010a6675", "size": 4952, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/exercices/stack.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/stack.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/stack.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.1370558376, "max_line_length": 95, "alphanum_fraction": 0.5102988691, "num_tokens": 1618, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.8104789109591832, "lm_q1q2_score": 0.5849576478322662}} {"text": "module plfa-exercises.Practice4 where\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Data.Product using (_×_ ; ∃-syntax; ∃; _,_) -- renaming (_,_ to ⟨_,_⟩)\nopen import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _≤_; _≤?_; _≟_; s≤s; z≤n)\nopen import Data.Nat.Binary.Properties using (≰⇒>)\nopen import Data.Nat.Properties using (≤-refl; ≤-trans; ≤-antisym; ≤-total)\nopen import Data.Maybe using (Maybe; just; nothing; maybe; _>>=_; from-just; From-just)\nopen import Data.Bool using (Bool; true; false; T; _∧_; _∨_; not)\nopen import Relation.Nullary.Decidable using (⌊_⌋; toWitness; fromWitness; from-yes; From-yes)\nopen import Relation.Nullary using (¬_; Dec; yes; no)\nopen import Data.Unit using (⊤; tt)\n\n--data OrderedTree (A : Set) : (smallest middle biggest : ℕ) → Set where\n-- leaf : ∀ (n : ℕ) → A → OrderedTree A n n\n-- node : ∀ {s₁ m₁ b₁ s₂ m₂ b₂ : ℕ}\n-- → (m : ℕ)\n-- → b₁ ≤ m\n-- → m ≤ s₂\n-- → OrderedTree A s₁ m₁ b₁\n-- → OrderedTree A s₂ m₂ b₂\n-- → OrderedTree A s₁ m b₂\n--\n---- node 7 _ _ (leaf 5 300) (leaf 10 200)\n----middle_values_in_node_are_smaller : \n--\n--insert_left : ∀ {s m b : ℕ} → (n : ℕ) → A → OrderedTree A s m b\n\ndata BST : ℕ → ℕ → Set where\n leaf : ∀ {l u : ℕ} → l ≤ u → BST l u\n node : ∀ {l l₀ u₁ u : ℕ} (d : ℕ)\n → BST l₀ d\n → BST d u₁\n → l ≤ l₀ -- This overcomplicates some stuff in later code. Better get rid off it\n → u₁ ≤ u\n → BST l u\n\n-- node {l = 0} {u = 30} 5 (leaf {2} {5} _) (leaf {5} {6} _)\n\n-- If we use the long definition of BST this function gets short, otherwise it's quite complicated\nwiden : ∀ {l l' u u' : ℕ}\n → BST l' u'\n → l ≤ l'\n → u' ≤ u\n → BST l u\nwiden (leaf l'≤u') l≤l' u'≤u = leaf (≤-trans l≤l' (≤-trans l'≤u' u'≤u))\nwiden (node d left right l'≤l₀ u₁≤u') l≤l' u'≤u = node d left right (≤-trans l≤l' l'≤l₀) (≤-trans u₁≤u' u'≤u)\n\n-- node {l = 0} {u = 30} 5 (leaf {2} {5} _) (widen (leaf {23} {29} _) _ _) z≤n _\n\na-tree : BST 0 30 -- A tree with a single node!!\n--a-tree = node 5 (leaf 2≤5) (leaf 5≤30) z≤n 30≤30\na-tree = node 5 (leaf 2≤5) (widen (leaf 23≤29) 5≤23 29≤30) z≤n 30≤30\n--a-tree = node {l = 0} {u = 30} 5 (leaf {2} {5} 2≤5) (widen (leaf {23} {29} 23≤29) 5≤23 29≤30) z≤n 30≤30\n where\n --2≤5 = toWitness {Q = 2 ≤? 5} tt\n 2≤5 = from-yes ( 2 ≤? 5)\n 23≤29 = from-yes (23 ≤? 29)\n 5≤23 = from-yes ( 5 ≤? 23)\n 29≤30 = from-yes (29 ≤? 30)\n 30≤30 = from-yes (30 ≤? 30)\n\nbinary-search : ∀ {l u : ℕ} → (n : ℕ) → l ≤ n → n ≤ u → BST l u → Maybe (∃[ l' ] (∃[ u' ] (BST l' u')))\nbinary-search _ _ _ (leaf _) = nothing\nbinary-search n l≤n n≤u (node {l'} {l₀} {u₁} {u'} d left right l'≤l₀ u₁≤u') with d ≟ n\n--binary-search n _ _ (node {_} {l} {_} {u} d left right l≤l₀ u₁≤u) with d ≟ n\n... | yes d=n = just (l' , u' , node d left right l'≤l₀ u₁≤u')\n... | no d≠n with ≤-total n d | l₀ ≤? n | n ≤? u₁\n... | inj₁ n≤d | yes l₀≤n | _ = binary-search n l₀≤n n≤d left\n... | inj₁ n≤d | no ¬l₀≤n | _ = nothing -- This shouldn't exist if the definition of BST wasn't so overcomcomplicated\n... | inj₂ d≤n | _ | yes n≤u₁ = binary-search n d≤n n≤u₁ right\n... | inj₂ d≤n | _ | no ¬n≤u₁ = nothing\n\nsmaller : ℕ → ℕ → Bool\nsmaller m n with m ≤? n\n... | yes m≤n = true\n... | _ = false\n\n_≤ℕ_ : ∀ (m n : ℕ) → From-yes (m ≤? n)\nm ≤ℕ n = from-yes (m ≤? n)\n\n--_ : Maybe (∃ (λ l' → ∃ (BST l')))\n--_ = binary-search 5 _ _ a-tree ≡ nothing\n --where\n --5≤30 = from-yes (5 ≤? 30)\n_ : binary-search 2 z≤n (2 ≤ℕ 30) a-tree ≡ nothing\n_ = refl\n\n_ : binary-search 5 z≤n (5 ≤ℕ 30) a-tree ≡ just (0 , 30 , node 5 _ _ _ _)\n_ = refl\n\ninsert : ∀ {l u} (d : ℕ) → l ≤ d → d ≤ u → BST l u → BST l u\ninsert d l≤d d≤u (leaf _) = node d (leaf l≤d) (leaf d≤u) ≤-refl ≤-refl\ninsert d l≤d d≤u (node {_} {l₀} m left right l≤m m≤u) with ≤-total m d\n... | inj₁ m≤d = node m (insert d ? ? left) right l≤m m≤u -- This shouldn't exist if the definition of BST wasn't so overcomcomplicated\n... | inj₂ d≤m = ?\n\n-- ≰⇒> ¬3≤4\n", "meta": {"hexsha": "c779329ec21b3ea8b5f2ffc87a4f23c6b53e6a6f", "size": 4244, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice4.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/Practice4.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/Practice4.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": 42.44, "max_line_length": 151, "alphanum_fraction": 0.5249764373, "num_tokens": 1807, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936438, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.5849123936483797}} {"text": "-- Andreas, 2015-06-11\n\n{-# OPTIONS --copatterns #-}\n\nopen import Common.Size\n\nmodule _ {C : Set} {R : C → Set} where\n\nmutual\n record IO (i : Size) (A : Set) : Set where\n coinductive\n constructor delay\n field\n force : {j : Size< i} → IO' j A\n\n data IO' (i : Size) (A : Set) : Set where\n do : (c : C) (f : R c → IO i A) → IO' i A\n return : (a : A) → IO' i A\n\nopen IO\n\nmodule Works where\n\n _>>=_ : ∀{i A B} (m : IO i A) (k : A → IO i B) → IO i B\n force (m >>= k) with force m\n force (m >>= k) {j} | do c f = do c λ x → f x >>= k\n force (m >>= k) {j} | return a = force (k a)\n\n_>>=_ : ∀{i A B} (m : IO i A) (k : A → IO i B) → IO i B\nforce (m >>= k) with force m\nforce (m >>= k) | do c f = do c λ x → f x >>= k\nforce (m >>= k) | return a = force (k a)\n\n-- Error WAS:\n-- Too few arguments given in with-clause\n-- when checking that the clause\n-- force (m >>= k) with force m\n-- force (m >>= k) | do c f = do c (λ x → f x >>= k)\n-- force (m >>= k) | return a = force (k a)\n-- has type {i : Size} {A B : Set} → IO i A → (A → IO i B) → IO i B\n", "meta": {"hexsha": "8785f61c475f7d2fd167dfa7b48b92b73fe1fade", "size": 1069, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1551.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/Issue1551.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/Issue1551.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": 26.0731707317, "max_line_length": 67, "alphanum_fraction": 0.4967259121, "num_tokens": 419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.5849123936483795}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule Cubical.Structures.Monoid 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)\n\nopen import Cubical.Structures.Pointed\nopen import Cubical.Structures.NAryOp\n\nprivate\n variable\n ℓ : Level\n\n-- Monoids\nraw-monoid-structure : Type ℓ → Type ℓ\nraw-monoid-structure X = X × (X → X → X)\n\n-- If we ignore the axioms we get a \"raw\" monoid\nraw-monoid-is-SNS : SNS {ℓ} raw-monoid-structure _\nraw-monoid-is-SNS = join-SNS pointed-iso pointed-is-SNS (nAryFunIso 2) (nAryFunSNS 2)\n\n-- Monoid axioms\nmonoid-axioms : (X : Type ℓ) → raw-monoid-structure X → Type ℓ\nmonoid-axioms X (e , _·_ ) = isSet X\n × ((x y z : X) → x · (y · z) ≡ (x · y) · z)\n × ((x : X) → x · e ≡ x)\n × ((x : X) → e · x ≡ x)\n\nmonoid-structure : Type ℓ → Type ℓ\nmonoid-structure = add-to-structure raw-monoid-structure monoid-axioms\n\nMonoid : Type (ℓ-suc ℓ)\nMonoid {ℓ} = TypeWithStr ℓ monoid-structure\n\n-- Monoid extractors\n\n⟨_⟩ : Monoid {ℓ} → Type ℓ\n⟨ G , _ ⟩ = G\n\nmonoid-id : (M : Monoid {ℓ}) → ⟨ M ⟩\nmonoid-id (_ , (e , _) , _) = e\n\nmonoid-operation : (M : Monoid {ℓ}) → ⟨ M ⟩ → ⟨ M ⟩ → ⟨ M ⟩\nmonoid-operation (_ , (_ , f) , _) = f\n\n-- Monoid syntax with explicit monoid\n\nmodule monoid-syntax where\n id : (M : Monoid {ℓ}) → ⟨ M ⟩\n id = monoid-id\n\n monoid-operation-syntax : (M : Monoid {ℓ}) → ⟨ M ⟩ → ⟨ M ⟩ → ⟨ M ⟩\n monoid-operation-syntax = monoid-operation\n\n infixr 18 monoid-operation-syntax\n syntax monoid-operation-syntax M x y = x ·⟨ M ⟩ y\n\nopen monoid-syntax\n\n-- More Monoid extractors\n\nmonoid-is-set : (M : Monoid {ℓ}) → isSet (⟨ M ⟩)\nmonoid-is-set (_ , _ , P , _) = P\n\nmonoid-assoc : (M : Monoid {ℓ})\n → (x y z : ⟨ M ⟩) → x ·⟨ M ⟩ (y ·⟨ M ⟩ z) ≡ (x ·⟨ M ⟩ y) ·⟨ M ⟩ z\nmonoid-assoc (_ , _ , _ , P , _) = P\n\nmonoid-rid : (M : Monoid {ℓ})\n → (x : ⟨ M ⟩) → x ·⟨ M ⟩ (id M) ≡ x\nmonoid-rid (_ , _ , _ , _ , P , _) = P\n\nmonoid-lid : (M : Monoid {ℓ})\n → (x : ⟨ M ⟩) → (id M) ·⟨ M ⟩ x ≡ x\nmonoid-lid (_ , _ , _ , _ , _ , P) = P\n\n-- Monoid equivalence\nmonoid-iso : StrIso monoid-structure ℓ\nmonoid-iso = add-to-iso (join-iso pointed-iso (nAryFunIso 2)) monoid-axioms\n\n-- We have to show that the monoid axioms are indeed propositions\nmonoid-axioms-are-Props : (X : Type ℓ) (s : raw-monoid-structure X) → isProp (monoid-axioms X s)\nmonoid-axioms-are-Props X (e , _·_) s = β s\n where\n α = s .fst\n β = isProp× isPropIsSet\n (isProp× (isPropΠ3 (λ x y z → α (x · (y · z)) ((x · y) · z)))\n (isProp× (isPropΠ (λ x → α (x · e) x)) (isPropΠ (λ x → α (e · x) x))))\n\nmonoid-is-SNS : SNS {ℓ} monoid-structure monoid-iso\nmonoid-is-SNS = add-axioms-SNS _ monoid-axioms-are-Props raw-monoid-is-SNS\n\nMonoidPath : (M N : Monoid {ℓ}) → (M ≃[ monoid-iso ] N) ≃ (M ≡ N)\nMonoidPath = SIP monoid-is-SNS\n\n-- Added for its use in groups\n-- If there exists a inverse of an element it is unique\n\ninv-lemma : (M : Monoid {ℓ})\n → (x y z : ⟨ M ⟩)\n → y ·⟨ M ⟩ x ≡ id M\n → x ·⟨ M ⟩ z ≡ id M\n → y ≡ z\ninv-lemma M x y z left-inverse right-inverse =\n y ≡⟨ sym (monoid-rid M y) ⟩\n y ·⟨ M ⟩ id M ≡⟨ cong (λ - → y ·⟨ M ⟩ -) (sym right-inverse) ⟩\n y ·⟨ M ⟩ (x ·⟨ M ⟩ z) ≡⟨ monoid-assoc M y x z ⟩\n (y ·⟨ M ⟩ x) ·⟨ M ⟩ z ≡⟨ cong (λ - → - ·⟨ M ⟩ z) left-inverse ⟩\n id M ·⟨ M ⟩ z ≡⟨ monoid-lid M z ⟩\n z ∎\n\n-- Monoid ·syntax\n\nmodule monoid-·syntax (M : Monoid {ℓ}) where\n\n infixr 18 _·_\n\n _·_ : ⟨ M ⟩ → ⟨ M ⟩ → ⟨ M ⟩\n _·_ = monoid-operation M\n\n ₁ : ⟨ M ⟩\n ₁ = monoid-id M\n", "meta": {"hexsha": "788318e4b334a0b0590e1a5cf7baabb8c198ec4c", "size": 3710, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Structures/Monoid.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/Monoid.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/Monoid.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.2125984252, "max_line_length": 96, "alphanum_fraction": 0.5595687332, "num_tokens": 1493, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.5848986703434955}} {"text": "{-# OPTIONS --cubical --no-import-sorts --prop #-}\n\nmodule Utils where\n\nopen import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)\nopen import Function.Base\n\nvariable\n ℓ ℓ' ℓ'' : Level\n\nmodule Test where\n import Algebra.Properties.BooleanAlgebra\n\n open import Algebra.Bundles\n \n\n module _ (B : BooleanAlgebra ℓ ℓ') where\n open BooleanAlgebra B\n open import Algebra.Definitions _≈_ \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\nopen import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)\n-- open import Cubical.Structures.CommRing\n-- open import Cubical.Relation.Nullary.Base -- ¬_\n-- open import Cubical.Relation.Binary.Base\n-- open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)\nopen import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_)\n-- open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim`\n-- -- open import Cubical.Structures.Poset\n-- open import Cubical.Foundations.Function\n-- open import Function.Base using (_∋_)\n-- open import Function.Base using (it) -- instance search\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Logic\n-- open import Algebra.Definitions\n-- open import Cubical.Data.Empty\nopen import Cubical.HITs.PropositionalTruncation\n\nimport Cubical.Data.Empty as ⊥\nopen import Cubical.Data.Unit.Base\n\n\n\n⊥↑ : ∀{ℓ} → hProp ℓ\n⊥↑ = Lift ⊥.⊥ , λ () \n\n⊤↑ : ∀{ℓ} → hProp ℓ\n⊤↑ = Lift Unit , isOfHLevelLift 1 (λ _ _ _ → tt)\n\n-- _ = {! ⇔toPath!}\n\n⊔-complementˡ : ∀ x → ¬ x ⊔ x ≡ ⊤↑ -- LeftInverse _≡_ ⊤ ¬_ _⊔_\n⊔-complementˡ = {! comm+invʳ⇒invˡ ⊔-comm ⊔-complementʳ !}\n\n-- ⊔-complementʳ : ∀ x → x ⊔ ¬ x ≡ ∥ [ ⊤ ] ∥ₚ\n-- ⊔-complementʳ : ∀(x : hProp ℓ) → x ⊔ ¬ x ≡ ((hProp ℓ) ∋ ⊤)\n⊔-complementʳ : ∀(x : hProp ℓ) → x ⊔ ¬ x ≡ ⊤↑\n⊔-complementʳ x = λ i → {! ⊔-comm x (¬ x) i !} \n\n⊔-complement : (∀ x → ¬ x ⊔ x ≡ ⊤↑) × (∀ x → x ⊔ ¬ x ≡ ⊤↑) -- Inverse _≡_ ⊤ ¬_ _⊔_\n⊔-complement = ⊔-complementˡ , {! ⊔-complementʳ !}\n\n-- agda deduces\n-- Σ Type (λ A → (x y : A) → x ≡ y)\n-- hProp normalizes to\n-- λ ℓ → Σ (Type ℓ) (λ A → (x y : A) → x ≡ y)\n-- \n⊓-complementˡ : ∀ x → ¬ x ⊓ x ≡ ⊥ -- LeftInverse _≡_ ⊥ ¬_ _⊓_\n⊓-complementˡ = {! isProp!} -- comm+invʳ⇒invˡ ⊓-comm ⊓-complementʳ \n\n⊓-complementʳ : ∀ x → x ⊓ ¬ x ≡ ⊥\n⊓-complementʳ = {!!}\n\n⊓-complement : (∀ x → ¬ x ⊓ x ≡ ⊥) × (∀ x → x ⊓ ¬ x ≡ ⊥) -- Inverse _≡_ ⊥ ¬_ _⊓_\n⊓-complement = ⊓-complementˡ , ⊓-complementʳ \n\n⊓-⊔-distribʳ : (P : hProp ℓ) (Q : hProp ℓ')(R : hProp ℓ'')\n → (Q ⊔ R) ⊓ P ≡ (Q ⊓ P) ⊔ (R ⊓ P)\n⊓-⊔-distribʳ P Q R = (\n (Q ⊔ R) ⊓ P ≡⟨ ⊓-comm _ _ ⟩\n P ⊓ (Q ⊔ R) ≡⟨ ⊓-⊔-distribˡ P Q R ⟩\n (P ⊓ Q) ⊔ (P ⊓ R) ≡⟨ ( λ i → ⊓-comm P Q i ⊔ ⊓-comm P R i) ⟩\n (Q ⊓ P) ⊔ (R ⊓ P) ∎)\n\n_ : isProp ≡ (λ(A : Type ℓ) → (x y : A) → x ≡ y)\n_ = refl\n\n-- `sq` stands for \"squashed\" and |_| is the constructor for ∥_∥\n-- \n-- data ∥_∥ {ℓ} (A : Type ℓ) : Type ℓ where\n-- ∣_∣ : A → ∥ A ∥\n-- squash : ∀ (x y : ∥ A ∥) → x ≡ y\n--\n-- (see https://ice1000.org/2018/12-06-CubicalAgda.html#propositional-truncation )\n-- we also have\n--\n-- hProp ℓ = Σ[ A ∈ Type ℓ ] (∀( x y : A) → x ≡ y)\n-- isContr {ℓ} = λ( A : Type ℓ ) → Σ[ x ∈ A ] (∀ y → x ≡ y)\n-- isProp {ℓ} = λ( A : Type ℓ ) → ∀( x y : A) → x ≡ y\n--\n-- and in `Cubical.Foundations.Id` we have\n--\n-- postulate\n-- Id : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ\n-- _≡_ : ∀ {ℓ} {A : Type ℓ} → A → A → Type ℓ\n-- _≡_ = Id\n--\n-- which is imported in `Cubical.Foundations.Everything`, but _≡_ is hidden in favour of the _≡_ from `Agda.Builtin.Cubical.Path`:\n--\n-- _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ\n-- _≡_ {A = A} = PathP (λ i → A)\n--\n-- we have conversion functions between `Id` and `PathP`\n\n-- recall from https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html\n--\n-- is-center X c = (x : X) → c ≡ x\n-- is-singleton X = Σ c ꞉ X , is-center X c\n-- is-subsingleton X = (x y : X) → x ≡ y\n-- 𝟘-is-subsingleton : is-subsingleton 𝟘\n-- singletons-are-subsingletons : (X : 𝓤 ̇ ) → is-singleton X → is-subsingleton X\n-- 𝟙-is-subsingleton : is-subsingleton 𝟙\n--\n-- now,\n-- see https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#axiomatic-approach\n-- see https://ice1000.org/2018/12-06-CubicalAgda.html#propositional-truncation\n-- However I would not only use recPropTrunc explicitly as we can just use pattern-matching to define functions out of HITs.\n-- see https://cstheory.stackexchange.com/questions/30542/squash-type-vs-propositional-truncation-type\n-- Squash types correspond to judgmental truncation, not propositional truncation.\n-- In a type theory without a type for judgmental equality, there's non much of a way to make use of an inhabitant of a squash type;\n-- there's no way to write an eliminator into any type except another squash type.\n-- Relatedly, having squash types, as presented in the book you linked, makes typechecking undecidable;\n-- having propositional truncation types does not result in this drawback.\n-- there is https://github.com/agda/cubical/pull/136\n-- Elimination of propositional truncation to higher types\n\nimport Cubical.Foundations.Id\nimport Cubical.HITs.PropositionalTruncation.Properties -- look here for examples\n\n∥∥-isProp : {A : Type ℓ} → ∀ (x y : ∥ A ∥) → x ≡ y\n∥∥-isProp {ℓ = ℓ} {A = A} x y = (squash x y)\n\n_ = propTruncIsProp\n\npropTruncIsProp' : {A : Type ℓ} → isProp ∥ A ∥\npropTruncIsProp' x y = squash x y\n\n{-\n\nt0 : {A : Type ℓ} → (x y : ∥ A ∥) → x ≡ y -- isProp (∥ A ∥)\nt0 x ∣ y ∣ = squash x ∣ y ∣\n-- Goal: ∥ A ∥\n-- ———— Boundary ——————————————————————————————————————————————\n-- i = i0 ⊢ t0 x y₀ j\n-- i = i1 ⊢ t0 x y₁ j\n-- j = i0 ⊢ x\n-- j = i1 ⊢ squash y₀ y₁ i\nt0 x (squash y₀ y₁ i) j = {! t0 !}\n\n-}\n\n{-\n-- Goal: ∣ x ∣ ≡ ∣ y ∣\nt0 ∣ x ∣ ∣ y ∣ = squash ∣ x ∣ ∣ y ∣\n\n-- Goal: ∣ x ∣ ≡ squash y₀ y₁ i\n-- ———— Boundary ——————————————————————————————————————————————\n-- i = i0 ⊢ t0 ∣ x ∣ y₀\n-- i = i1 ⊢ t0 ∣ x ∣ y₁\nt0 ∣ x ∣ (squash y₀ y₁ i) = squash ∣ x ∣ (squash y₀ y₁ i) -- {! squash ∣ x ∣ (squash y₀ y₁ i)!} -- {! λ j → squash ∣ x ∣ (squash y₁ y₂ j) {! !} !}\nt0 (squash x₁ x₂ i) ∣ y ∣ = squash (squash x₁ x₂ i) ∣ y ∣\nt0 (squash x₁ x₂ i) (squash y₁ y₂ j) = squash (squash x₁ x₂ i) (squash y₁ y₂ j) \n-}\n\n-- Definition 2.4.3. The propositional truncation of a type X\n-- is a proposition ∥ X ∥\n-- together with a truncation map |_| : X → ∥ X ∥\n-- such that for any other proposition Q, given a map g : X → Q, we obtain a map h : ∥ X ∥ → Q.\n--\n-- Remark 2.4.4. The uniqueness of the obtained map ∥ X ∥ → Q follows from the fact that Q is a proposition, and function extensionality\n--\n-- The propositional truncation ∥ X ∥ of a type X is a proposition. We may say, quite simply,\n-- that we have a constructor sq which is a proof that the type ∥ X ∥ is a squashed to be a propo-\n-- sition: it takes two elements of ∥ X ∥ and gives a proof that they are identical, i.e. squashed\n-- together.\n\n-- Definition 2.4.7.\n-- We refer to types that are propositions as properties.\n-- We refer to types that potentially have several witnesses as structure.\n\n{-\nmodule _ {ℓ} (X Y : Type ℓ) (g : X → Y) where\n\n f : ∥ X ∥ → Y\n f ∣ x ∣ = g x\n f (squash x₀ x₁ i) = {! !}\n-}\n\n-- well, that might not work at all\n-- ⊓-unliftˡ : {P : hProp ℓ} {Q : hProp ℓ'} \n\nimport Cubical.HITs.PropositionalTruncation.Properties\n\n-- _ : (P : hProp P.ℓ) (Q : hProp Q.ℓ) (R : hProp R.ℓ) → (hProp P.ℓ → hProp Q.ℓ → hProp R.ℓ) → h\n-- _ = ?\n\n--_ = _≡ₚ_\n\n⊓-identityˡ-↑ : (P : hProp ℓ) → ⊤↑ {ℓ} ⊓ P ≡ P\n⊓-identityˡ-↑ _ = ⇔toPath snd λ x → lift tt , x\n\n-- \\ is \\\\\n-- ↑ is \\u\n\n\nprivate\n lemma : ∀ x y → x ⊓ y ≡ ⊥ → x ⊔ y ≡ ⊤ → ¬ x ≡ y\n lemma x y x⊓y=⊥ x⊔y=⊤ = (\n ¬ x ≡⟨ sym (⊓-identityʳ _) ⟩\n ¬ x ⊓ ⊤ ≡⟨ (λ i → ¬ x ⊓ x⊔y=⊤ (~ i) ) ⟩\n ¬ x ⊓ (x ⊔ y) ≡⟨ ⊓-⊔-distribˡ (¬ x) x y ⟩\n (¬ x ⊓ x) ⊔ (¬ x ⊓ y) ≡⟨ (λ i → ⊓-complementˡ x i ⊔ (¬ x ⊓ y)) ⟩\n ⊥ ⊔ (¬ x ⊓ y) ≡⟨ (λ i → x⊓y=⊥ (~ i) ⊔ (¬ x ⊓ y)) ⟩\n (x ⊓ y) ⊔ (¬ x ⊓ y) ≡⟨ sym (⊓-⊔-distribʳ y x (¬ x)) ⟩\n (x ⊔ ¬ x) ⊓ y ≡⟨ (λ i → (⊔-complementʳ x) i ⊓ y ) ⟩\n ⊤↑ ⊓ y ≡⟨ ⊓-identityˡ-↑ _ ⟩\n y ∎)\n\n\ndata Prop2Type (P : Prop ℓ) : Type (ℓ-suc ℓ) where\n inₚ : (p : P) → Prop2Type P\n\nProp-to-hProp : Prop ℓ → hProp (ℓ-suc ℓ)\nProp-to-hProp P = Prop2Type P , λ{ (inₚ x) (inₚ y) → refl }\n", "meta": {"hexsha": "909a9360d80057710973251496fc7f5c20cca315", "size": 8756, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Utils.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": "test/Utils.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": "test/Utils.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": 35.3064516129, "max_line_length": 148, "alphanum_fraction": 0.5589310187, "num_tokens": 3736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.7745833737577159, "lm_q1q2_score": 0.5847445888861201}} {"text": "------------------------------------------------------------------------------\n-- Proving properties without using pattern matching on refl\n------------------------------------------------------------------------------\n\n{-# OPTIONS --no-pattern-matching #-}\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n\nmodule FOT.PA.Inductive2Mendelson.NoPatternMatchingOnRefl where\n\nopen import PA.Inductive.Base\n\n------------------------------------------------------------------------------\n-- From PA.Inductive2Mendelson\n\nS₁ : ∀ {m n o} → m ≡ n → m ≡ o → n ≡ o\nS₁ h₁ h₂ = trans (sym h₁) h₂\n\nS₂ : ∀ {m n} → m ≡ n → succ m ≡ succ n\nS₂ {m} h = subst (λ t → succ m ≡ succ t) h refl\n\n-- 20 May 2013. Requires the predecessor function.\n-- S₄ : ∀ {m n} → succ m ≡ succ n → m ≡ n\n", "meta": {"hexsha": "3b9205bd403de089edd732928af8eec2a9de8a7c", "size": 851, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/PA/Inductive2Mendelson/NoPatternMatchingOnRefl.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/PA/Inductive2Mendelson/NoPatternMatchingOnRefl.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/PA/Inductive2Mendelson/NoPatternMatchingOnRefl.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.04, "max_line_length": 78, "alphanum_fraction": 0.4383078731, "num_tokens": 211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.5846908096925005}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Vectors where all elements satisfy a given property\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Vec.Relation.Unary.All where\n\nopen import Data.Nat.Base using (zero; suc)\nopen import Data.Fin.Base using (Fin; zero; suc)\nopen import Data.Product as Prod using (_×_; _,_; uncurry; <_,_>)\nopen import Data.Vec.Base as Vec using (Vec; []; _∷_)\nopen import Function using (_∘_)\nopen import Level using (Level; _⊔_)\nopen import Relation.Nullary hiding (Irrelevant)\nimport Relation.Nullary.Decidable as Dec\nopen import Relation.Nullary.Product using (_×-dec_)\nopen import Relation.Unary\nopen import Relation.Binary.PropositionalEquality as P using (subst)\n\nprivate\n variable\n a b c p q r : Level\n A : Set a\n B : Set b\n C : Set c\n\n------------------------------------------------------------------------\n-- All P xs means that all elements in xs satisfy P.\n\ninfixr 5 _∷_\n\ndata All {a} {A : Set a} (P : Pred A p) : ∀ {n} → Vec A n → Set (p ⊔ a) where\n [] : All P []\n _∷_ : ∀ {n x} {xs : Vec A n} (px : P x) (pxs : All P xs) → All P (x ∷ xs)\n\n------------------------------------------------------------------------\n-- Operations on All\n\nmodule _ {P : Pred A p} where\n\n head : ∀ {n x} {xs : Vec A n} → All P (x ∷ xs) → P x\n head (px ∷ pxs) = px\n\n tail : ∀ {n x} {xs : Vec A n} → All P (x ∷ xs) → All P xs\n tail (px ∷ pxs) = pxs\n\n uncons : ∀ {n x} {xs : Vec A n} → All P (x ∷ xs) → P x × All P xs\n uncons = < head , tail >\n\n lookup : ∀ {n} {xs : Vec A n} (i : Fin n) →\n All P xs → P (Vec.lookup xs i)\n lookup zero (px ∷ pxs) = px\n lookup (suc i) (px ∷ pxs) = lookup i pxs\n\n tabulate : ∀ {n xs} → (∀ i → P (Vec.lookup xs i)) → All P {n} xs\n tabulate {xs = []} pxs = []\n tabulate {xs = _ ∷ _} pxs = pxs zero ∷ tabulate (pxs ∘ suc)\n\nmodule _ {P : Pred A p} {Q : Pred A q} where\n\n map : ∀ {n} → P ⊆ Q → All P {n} ⊆ All Q {n}\n map g [] = []\n map g (px ∷ pxs) = g px ∷ map g pxs\n\n zip : ∀ {n} → All P ∩ All Q ⊆ All (P ∩ Q) {n}\n zip ([] , []) = []\n zip (px ∷ pxs , qx ∷ qxs) = (px , qx) ∷ zip (pxs , qxs)\n\n unzip : ∀ {n} → All (P ∩ Q) {n} ⊆ All P ∩ All Q\n unzip [] = [] , []\n unzip (pqx ∷ pqxs) = Prod.zip _∷_ _∷_ pqx (unzip pqxs)\n\nmodule _ {P : Pred A p} {Q : Pred B q} {R : Pred C r} where\n\n zipWith : ∀ {_⊕_ : A → B → C} →\n (∀ {x y} → P x → Q y → R (x ⊕ y)) →\n ∀ {n xs ys} → All P {n} xs → All Q {n} ys →\n All R {n} (Vec.zipWith _⊕_ xs ys)\n zipWith _⊕_ {xs = []} {[]} [] [] = []\n zipWith _⊕_ {xs = x ∷ xs} {y ∷ ys} (px ∷ pxs) (qy ∷ qys) =\n px ⊕ qy ∷ zipWith _⊕_ pxs qys\n\n------------------------------------------------------------------------\n-- Properties of predicates preserved by All\n\nmodule _ {P : Pred A p} where\n\n all : ∀ {n} → Decidable P → Decidable (All P {n})\n all P? [] = yes []\n all P? (x ∷ xs) = Dec.map′ (uncurry _∷_) uncons (P? x ×-dec all P? xs)\n\n universal : Universal P → ∀ {n} → Universal (All P {n})\n universal u [] = []\n universal u (x ∷ xs) = u x ∷ universal u xs\n\n irrelevant : Irrelevant P → ∀ {n} → Irrelevant (All P {n})\n irrelevant irr [] [] = P.refl\n irrelevant irr (px₁ ∷ pxs₁) (px₂ ∷ pxs₂) =\n P.cong₂ _∷_ (irr px₁ px₂) (irrelevant irr pxs₁ pxs₂)\n\n satisfiable : Satisfiable P → ∀ {n} → Satisfiable (All P {n})\n satisfiable (x , p) {zero} = [] , []\n satisfiable (x , p) {suc n} = Prod.map (x ∷_) (p ∷_) (satisfiable (x , p))\n", "meta": {"hexsha": "14d4a3c05bb2487ab936638582e06ccfcbe3d1e0", "size": 3620, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Vec/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/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/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": 33.8317757009, "max_line_length": 77, "alphanum_fraction": 0.4779005525, "num_tokens": 1270, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.5846908049524335}} {"text": "module Luau.Heap where\n\nopen import Agda.Builtin.Equality using (_≡_)\nopen import FFI.Data.Maybe using (Maybe; just)\nopen import FFI.Data.Vector using (Vector; length; snoc; empty)\nopen import Luau.Addr using (Addr)\nopen import Luau.Var using (Var)\nopen import Luau.Syntax using (Block; Expr; nil; addr; function⟨_⟩_end)\n\ndata HeapValue : Set where\n function_⟨_⟩_end : Var → Var → Block → HeapValue\n\nHeap = Vector HeapValue\n\ndata _≡_⊕_↦_ : Heap → Heap → Addr → HeapValue → Set where\n\n defn : ∀ {H val} →\n\n -----------------------------------\n (snoc H val) ≡ H ⊕ (length H) ↦ val\n\nlookup : Heap → Addr → Maybe HeapValue\nlookup = FFI.Data.Vector.lookup\n\nemp : Heap\nemp = empty\n\ndata AllocResult (H : Heap) (V : HeapValue) : Set where\n ok : ∀ a H′ → (H′ ≡ H ⊕ a ↦ V) → AllocResult H V\n\nalloc : ∀ H V → AllocResult H V\nalloc H V = ok (length H) (snoc H V) defn\n\nnext : Heap → Addr\nnext = length\n\nallocated : Heap → HeapValue → Heap\nallocated = snoc\n\n-- next-emp : (length empty ≡ 0)\nnext-emp = FFI.Data.Vector.length-empty\n\n-- lookup-next : ∀ V H → (lookup (allocated H V) (next H) ≡ just V)\nlookup-next = FFI.Data.Vector.lookup-snoc\n\n-- lookup-next-emp : ∀ V → (lookup (allocated emp V) 0 ≡ just V)\nlookup-next-emp = FFI.Data.Vector.lookup-snoc-empty\n\n", "meta": {"hexsha": "1a0416e472bdad83a9ded3dca03908b866b48a6c", "size": 1258, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "prototyping/Luau/Heap.agda", "max_stars_repo_name": "FreakingBarbarians/luau", "max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z", "max_issues_repo_path": "prototyping/Luau/Heap.agda", "max_issues_repo_name": "FreakingBarbarians/luau", "max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_issues_repo_licenses": ["MIT"], "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/Heap.agda", "max_forks_repo_name": "FreakingBarbarians/luau", "max_forks_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_forks_repo_licenses": ["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.6734693878, "max_line_length": 71, "alphanum_fraction": 0.6518282989, "num_tokens": 400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240686758842, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.5846878088604746}} {"text": "module RMonads.SpecialCase where\n\nopen import Categories\nopen import Functors\nopen import Naturals hiding (Iso)\nopen import Monads\nopen import RMonads\n\n\nleftM : ∀{a}{b}{C : Cat {a}{b}} → Monad C → RMonad (IdF C)\nleftM M = record {\n T = T;\n η = η;\n bind = bind;\n law1 = law1;\n law2 = law2;\n law3 = law3} \n where open Monad M\n\nrightM : ∀{a b}{C : Cat {a}{b}} → RMonad (IdF C) → Monad C\nrightM {C = C} M = record {\n T = T;\n η = η;\n bind = bind; \n law1 = law1;\n law2 = law2;\n law3 = law3} where open RMonad M\n\nopen import Relation.Binary.HeterogeneousEquality\nopen import Isomorphism\n\nisoM : ∀{a b}{C : Cat {a}{b}} → Iso (RMonad (IdF C)) (Monad C)\nisoM = record {fun = rightM; inv = leftM; law1 = λ {(monad _ _ _ _ _ _) → refl}; law2 = λ {(rmonad _ _ _ _ _ _) → refl}}\n\nopen import Monads.MonadMorphs\nopen import RMonads.RMonadMorphs\n\nleftMM : ∀{a b}{C : Cat {a}{b}}{M M' : Monad C} → MonadMorph M M' → \n RMonadMorph (leftM M) (leftM M')\nleftMM MM = record { \n morph = morph; \n lawη = lawη; \n lawbind = lawbind} where open MonadMorph MM\n\nrightMM : ∀{a b}{C : Cat {a}{b}}{M M' : RMonad (IdF C)} → RMonadMorph M M' → \n MonadMorph (rightM M) (rightM M')\nrightMM MM = record { \n morph = morph; \n lawη = lawη; \n lawbind = lawbind} where open RMonadMorph MM\n\n\nisoMM : ∀{a b}{C : Cat {a}{b}}{M M' : Monad C} → \n Iso (RMonadMorph (leftM M) (leftM M')) (MonadMorph M M')\nisoMM {M = monad _ _ _ _ _ _}{M' = monad _ _ _ _ _ _} = record { \n fun = rightMM;\n inv = leftMM; \n law1 = λ {(monadmorph _ _ _) → refl};\n law2 = λ {(rmonadmorph _ _ _) → refl}}\n\nopen import Adjunctions\nopen import RAdjunctions\n\nleftA : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} → Adj C D → RAdj (IdF C) D\nleftA {C}{D} A = record{\n L = L;\n R = R;\n left = left; \n right = right; \n lawa = lawa; \n lawb = lawb; \n natleft = natleft;\n natright = natright} where open Adj A\n\nrightA : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} → RAdj (IdF C) D → Adj C D\nrightA {C = C}{D = D} A = record{\n L = L;\n R = R;\n left = left; \n right = right; \n lawa = lawa; \n lawb = lawb; \n natleft = natleft;\n natright = natright} where open RAdj A\n\nisoA : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} →\n Iso (RAdj (IdF C) D) (Adj C D)\nisoA = record {\n fun = rightA;\n inv = leftA;\n law1 = λ {(adjunction _ _ _ _ _ _ _ _) → refl};\n law2 = λ {(radjunction _ _ _ _ _ _ _ _) → refl}}\n\n", "meta": {"hexsha": "e7e277499917ee6cc635f955b88cb57694c5325f", "size": 2461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "RMonads/SpecialCase.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/SpecialCase.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/SpecialCase.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.1808510638, "max_line_length": 120, "alphanum_fraction": 0.5603413247, "num_tokens": 964, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240895276223, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.5846878060018829}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\n\nmodule homotopy.PathSetIsInitalCover {i} (X : Ptd i)\n -- and an arbitrary covering\n {k} (⊙cov : ⊙Cover X k) where\n\n open Cover\n\n private\n univ-cover = path-set-cover X\n module ⊙cov = ⊙Cover ⊙cov\n\n -- Weak initiality by transport.\n quotient-cover : CoverHom univ-cover ⊙cov.cov\n quotient-cover _ p = cover-trace ⊙cov.cov ⊙cov.pt p\n\n -- Strong initiality by path induction.\n module Uniqueness\n (cover-hom : CoverHom univ-cover ⊙cov.cov)\n (pres-pt : cover-hom (pt X) idp₀ == ⊙cov.pt)\n where\n\n private\n lemma₁ : ∀ a p → cover-hom a [ p ] == quotient-cover a [ p ]\n lemma₁ ._ idp = pres-pt\n\n lemma₂ : ∀ a p → cover-hom a p == quotient-cover a p\n lemma₂ a = Trunc-elim\n (λ p → =-preserves-set (⊙cov.Fiber-level a))\n (lemma₁ a)\n\n theorem : cover-hom == quotient-cover\n theorem = λ= λ a → λ= $ lemma₂ a\n", "meta": {"hexsha": "4ad3f66ced588ee98c6d0e9aafe26563ffd4df87", "size": 925, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/PathSetIsInitalCover.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/PathSetIsInitalCover.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/PathSetIsInitalCover.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": 25.6944444444, "max_line_length": 66, "alphanum_fraction": 0.6097297297, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772286044095, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.5846530100227231}} {"text": "open import Prelude\n\nmodule Implicits.Resolution.Termination.SizeMeasures where\n\nopen import Induction.WellFounded\nopen import Induction.Nat\nopen import Data.Product hiding (map)\nopen import Data.Nat.Base using (_<′_)\nopen import Data.Fin hiding (_+_; _≤_; _<_; _≤?_)\nopen import Data.List hiding (map)\nopen import Data.List.All\nopen import Implicits.Syntax\nopen import Implicits.Syntax.Type.Unification\nopen import Data.Nat hiding (_<_)\nopen import Data.Nat.Properties\n\n-- a strict sizemeasure for types\n||_|| : ∀ {ν} → Type ν → ℕ\n|| simpl (tc x) || = 1\n|| simpl (tvar n) || = 1\n|| simpl (a →' b) || = 1 + || a || + || b ||\n|| a ⇒ b || = 1 + || a || + || b ||\n|| ∀' a || = 1 + || a ||\n\n-- size of the head of a type\nh||_|| : ∀ {ν} → Type ν → ℕ\nh|| a || = || proj₂ (a ◁) ||\n\n-- type measure on metatypes\nm||_|| : ∀ {m ν} → MetaType m ν → ℕ\nm|| simpl (tc x) || = 1\nm|| simpl (tvar n) || = 1\nm|| simpl (mvar n) || = 1\nm|| simpl (a →' b) || = suc (m|| a || + m|| b ||)\nm|| a ⇒ b || = 1 + (m|| a || + m|| b ||)\nm|| ∀' a || = 1 + m|| a ||\n\n-- We package Type with it's deBruijn counter because\n-- we need to express orderings such as a sρ< ∀' a\n-- where the number of free variables varies.\n-- We could express that as ∀ {ν μ} → Type ν → Type μ → Set,\n-- but Well-founded _sρ<_ unifies ν and μ,\n-- such that the well-founded proof would be too narrow\n_hρ≤_ : (a b : ∃ Type) → Set\n(_ , a) hρ≤ (_ , b) = h|| a || ≤ h|| b ||\n\n_hρ<_ : (a b : ∃ Type) → Set\n(_ , a) hρ< (_ , b) = h|| a || < h|| b ||\n\n_hρ _ _ _\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 : Color → Height → Set a where\n E : Tree B 0\n R : ∀{h} → Tree B h → A → Tree B h → Tree R h\n B : ∀{cl cr h} → Tree cl h → A → Tree cr h → Tree B (suc h)\n\n data IRTree : Height → Set a where\n IRl : ∀{h} → Tree R h → A → Tree B h → IRTree h\n IRr : ∀{h} → Tree B h → A → Tree R h → IRTree h\n\n data OutOfBalance : Height → Set a where\n _◂_◂_ : ∀{c h} → IRTree h → A → Tree c h → OutOfBalance h\n _▸_▸_ : ∀{c h} → Tree c h → A → IRTree h → OutOfBalance h\n\n data Treeish : Color → Height → Set a where\n RB : ∀{c h} → Tree c h → Treeish c h\n IR : ∀{h} → IRTree h → Treeish R h\n\n -- Insertion\n\n balance : ∀{h} → OutOfBalance h → Tree R (suc h)\n balance (IRl (R a x b) y c ◂ z ◂ d) = R (B a x b) y (B c z d)\n balance (IRr a x (R b y c) ◂ z ◂ d) = R (B a x b) y (B c z d)\n balance (a ▸ x ▸ IRl (R b y c) z d) = R (B a x b) y (B c z d)\n balance (a ▸ x ▸ IRr b y (R c z d)) = R (B a x b) y (B c z d)\n\n blacken : ∀{c h} → (Treeish c h)\n → (if c =ᶜ B then Tree B h else Tree B (suc h))\n blacken (RB E) = E\n blacken (RB (R l b r)) = (B l b r)\n blacken (RB (B l b r)) = (B l b r)\n blacken (IR (IRl l b r)) = (B l b r)\n blacken (IR (IRr l b r)) = (B l b r)\n\n ins : ∀{c h} → (a : A) → (t : Tree c h)\n → Σ[ c' ∈ Color ] (if c =ᶜ B then (Tree c' h) else (Treeish c' h))\n ins a E = R , R E a E\n --\n ins a (R _ b _) with a ≤ b\n ins a (R l _ _) | LT with ins a l\n ins _ (R _ b r) | LT | R , t = R , IR (IRl t b r)\n ins _ (R _ b r) | LT | B , t = R , (RB (R t b r))\n ins _ (R l b r) | EQ = R , RB (R l b r)\n ins a (R _ _ r) | GT with ins a r\n ins _ (R l b _) | GT | R , t = R , (IR (IRr l b t))\n ins _ (R l b _) | GT | B , t = R , (RB (R l b t))\n --\n ins a (B _ b _) with a ≤ b\n ins a (B l _ _) | LT with ins a l\n ins _ (B {R} _ b r) | LT | c , RB t = B , B t b r\n ins _ (B {R} _ b r) | LT | .R , IR t = R , balance (t ◂ b ◂ r)\n ins _ (B {B} _ b r) | LT | c , t = B , B t b r\n ins _ (B l b r) | EQ = B , B l b r\n ins a (B _ _ r) | GT with ins a r\n ins _ (B {cr = R} l b _) | GT | c , RB t = B , B l b t\n ins _ (B {cr = R} l b _) | GT | .R , IR t = R , balance (l ▸ b ▸ t)\n ins _ (B {cr = B} l b _) | GT | c , t = B , B l b t\n\n insert : ∀{c h} → (a : A) → (t : Tree c h)\n → Tree B h ⊎ Tree B (suc h)\n insert {R} a t with ins a t\n ... | R , t' = h+1 (blacken t')\n ... | B , t' = h+0 (blacken t')\n insert {B} a t with ins a t\n ... | R , t' = h+1 (blacken (RB t'))\n ... | B , t' = h+0 (blacken (RB t'))\n\n\n -- Simple Set Operations\n set : ∀{c h} → Set _\n set {c}{h} = Tree c h\n\n empty : set\n empty = E\n\n member : ∀{c h} → (a : A) → set {c}{h} → Bool\n member a E = false\n member a (R l b r) with a ≤ b\n ... | LT = member a l\n ... | EQ = true\n ... | GT = member a r\n member a (B l b r) with a ≤ b\n ... | LT = member a l\n ... | EQ = true\n ... | GT = member a r\n\n\n\n\n-- Usage example\n\nopen import Relation.Binary.Properties.DecTotalOrder ℕ-DTO\nℕ-STO : StrictTotalOrder _ _ _\nℕ-STO = strictTotalOrder\n\nopen module rbtree = RBTree ℕ-STO\n\nt0 : Tree B 2\nt0 = B (R (B E 1 E) 2 (B (R E 3 E) 5 (R E 7 E)))\n 8\n (B E 9 (R E 10 E))\n\nt1 : Tree B 3\nt1 = B (B (B E 1 E) 2 (B E 3 E))\n 4\n (B (B E 5 (R E 7 E)) 8 (B E 9 (R E 10 E)))\n\nt2 : Tree B 3\nt2 = B (B (B E 1 E) 2 (B E 3 E))\n 4\n (B (R (B E 5 E) 6 (B E 7 E)) 8 (B E 9 (R E 10 E)))\n\nopen import Relation.Binary.PropositionalEquality\nt1≡t0+4 : h+1 t1 ≡ insert 4 t0\nt1≡t0+4 = refl\n\nt2≡t1+6 : h+0 t2 ≡ insert 6 t1\nt2≡t1+6 = refl\n", "meta": {"hexsha": "e4d8ad9a4999c447371b15ca8e2553eab343265a", "size": 4814, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "RedBlackTree.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": "RedBlackTree.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": "RedBlackTree.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": 27.8265895954, "max_line_length": 76, "alphanum_fraction": 0.5191109265, "num_tokens": 2065, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.5846445257447541}} {"text": "module Proofs where\n\nopen import Agda.Builtin.Equality\nopen import Relation.Binary.PropositionalEquality.Core\nopen import Data.Nat\n\nopen ≡-Reasoning\n\nopen import Classes\n\n\ndata Vec : ℕ → Set → Set where\n Nil : ∀ {a} → Vec 0 a\n Cons : ∀ {n A} → (a : A) → Vec n A → Vec (suc n) A\n\ncons-cong : ∀ {n A} {a c : A} {b d : Vec n A} → a ≡ c → b ≡ d → Cons a b ≡ Cons c d\ncons-cong {_} {_} {a} {c} {b} {d} p q = begin\n Cons a b ≡⟨ cong (λ x → Cons a x) q ⟩\n Cons a d ≡⟨ cong (λ x → Cons x d) p ⟩\n Cons c d ∎\n\ninstance\n VecF : {n : ℕ} → Functor (Vec n)\n VecF = record {\n fmap = fmap' ;\n F-id = id' ;\n F-∘ = comp' }\n where\n fmap' : ∀ {n A B} → (A → B) → Vec n A → Vec n B\n fmap' f Nil = Nil\n fmap' f (Cons a v) = Cons (f a) (fmap' f v)\n\n id' : ∀ {n A} → (a : Vec n A) → fmap' id a ≡ a\n id' Nil = refl\n id' (Cons a v) = cong (λ w → Cons a w) (id' v)\n\n comp' : ∀ {n A B C} → (g : B → C) (f : A → B) (a : Vec n A) → fmap' (g ∘ f) a ≡ (fmap' g ∘ fmap' f) a\n comp' g f Nil = refl\n comp' g f (Cons a v) = cons-cong refl (comp' g f v)\n\n\nfull : ∀ {A} → A → (n : ℕ) → Vec n A\nfull x zero = Nil\nfull x (suc n) = Cons x (full x n)\n\nzipWith : ∀ {n A B C} → (A → B → C) → Vec n A → Vec n B → Vec n C\nzipWith _ Nil Nil = Nil\nzipWith f (Cons a v) (Cons b w) = Cons (f a b) (zipWith f v w)\n\ninstance\n VecA : {n : ℕ} → Applicative (Vec n)\n VecA {n} = record\n { pure = λ x → full x n\n ; _<*>_ = ap'\n ; A-id = id'\n ; A-∘ = comp'\n ; A-hom = hom'\n ; A-ic = ic'\n }\n where\n ap' : ∀ {n A B} (v : Vec n (A → B)) (w : Vec n A) → Vec n B\n ap' Nil Nil = Nil\n ap' (Cons a v) (Cons b w) = Cons (a b) (ap' v w)\n \n id' : ∀ {n A} (v : Vec n A) → ap' (full id n) v ≡ v\n id' Nil = refl\n id' (Cons a v) = cons-cong refl (id' v)\n\n comp' : ∀ {n A B C} → (u : Vec n (B → C)) (v : Vec n (A → B)) (w : Vec n A)\n → ap' (ap' (ap' (full _∘_ n) u) v) w ≡ ap' u (ap' v w)\n comp' Nil Nil Nil = refl\n comp' (Cons a u) (Cons b v) (Cons c w) = cons-cong refl (comp' u v w)\n\n hom' : ∀ {n A B} (f : A → B) (x : A) → ap' (full f n) (full x n) ≡ full (f x) n\n hom' {zero} f x = refl\n hom' {suc n} f x = cons-cong refl (hom' {n} f x)\n\n ic' : ∀ {n A B} (u : Vec n (A → B)) (y : A) → ap' u (full y n) ≡ ap' (full (_$ y) n) u\n ic' Nil y = refl\n ic' (Cons a u) y = cons-cong refl (ic' u y)\n\n\ntail : ∀ {n A} → Vec (suc n) A → Vec n A\ntail (Cons x v) = v\n\ndiag : ∀ {n A} → Vec n (Vec n A) → Vec n A\ndiag Nil = Nil\ndiag (Cons (Cons a w) v) = Cons a (diag (fmap tail v))\n\nfmap-pure : ∀ {A B F} {{aF : Applicative F}} (f : A → B) (x : A)\n → fmap f (Applicative.pure aF x) ≡ Applicative.pure aF (f x)\nfmap-pure f x = begin\n fmap f (pure x) ≡⟨ sym (appFun f (pure x)) ⟩\n pure f <*> pure x ≡⟨ A-hom f x ⟩\n pure (f x) ∎\n\ndiag-full : ∀ {A} (n : ℕ) (v : Vec n A) → diag (full v n) ≡ v\ndiag-full _ Nil = refl\ndiag-full (suc n) (Cons a v) = cons-cong refl (begin\n diag (fmap tail (full (Cons a v) n)) ≡⟨ cong diag (fmap-pure tail (Cons a v)) ⟩\n diag (full v n) ≡⟨ diag-full n v ⟩\n v ∎)\n\ninstance\n VecM : {n : ℕ} → Monad (Vec n)\n VecM = record { _>>=_ = bind' ;\n left-1 = left' ;\n right-1 = {!!} ;\n assoc = {!!} }\n\n where\n bind' : ∀ {n A B} → Vec n A → (A → Vec n B) → Vec n B\n bind' v f = diag (fmap f v)\n\n left' : ∀ {n A B} (a : A) (k : A → Vec n B) → bind' (pure a) k ≡ k a\n left' {n} a k = begin\n diag (fmap k (full a n)) ≡⟨ cong diag (fmap-pure k a) ⟩\n diag (full (k a) n) ≡⟨ diag-full n (k a) ⟩\n k a ∎\n\n right' : ∀ {n A} (m : Vec n A) → bind' m pure ≡ m\n right' Nil = refl\n right' (Cons a m) = begin\n bind' (Cons a m) pure ≡⟨ refl ⟩\n diag (fmap pure (Cons a m)) ≡⟨ cons-cong refl {!!} ⟩ -- :(\n Cons a m ∎\n", "meta": {"hexsha": "242472bf2ad9b61901fc002512b5897cfaf4ff13", "size": 3916, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proofs/Proofs.agda", "max_stars_repo_name": "samuelhklumpers/strong-vector", "max_stars_repo_head_hexsha": "1b019ce3d7b978c369fcc82c97ccafdde8f7fd02", "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": "proofs/Proofs.agda", "max_issues_repo_name": "samuelhklumpers/strong-vector", "max_issues_repo_head_hexsha": "1b019ce3d7b978c369fcc82c97ccafdde8f7fd02", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2022-03-09T10:24:33.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-10T10:24:40.000Z", "max_forks_repo_path": "proofs/Proofs.agda", "max_forks_repo_name": "samuelhklumpers/strong-vector", "max_forks_repo_head_hexsha": "1b019ce3d7b978c369fcc82c97ccafdde8f7fd02", "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.8346456693, "max_line_length": 107, "alphanum_fraction": 0.4563329928, "num_tokens": 1632, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.5845592707398195}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Group.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Prod renaming (_×_ to _×'_)\nopen import Cubical.Data.Int renaming (_+_ to _+Int_ ; _-_ to _-Int_)\nopen import Cubical.Data.Unit\n\nopen import Cubical.Algebra.Monoid hiding (⟨_⟩)\nopen import Cubical.Algebra.Semigroup hiding (⟨_⟩)\nopen import Cubical.Foundations.HLevels\n\nprivate\n variable\n ℓ : Level\n\nrecord IsGroup {G : Type ℓ}\n (0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where\n\n no-eta-equality\n constructor isgroup\n\n field\n isMonoid : IsMonoid 0g _+_\n inverse : (x : G) → (x + (- x) ≡ 0g) × ((- x) + x ≡ 0g)\n\n open IsMonoid isMonoid public\n\n infixl 6 _-_\n\n _-_ : G → G → G\n x - y = x + (- y)\n\n invl : (x : G) → (- x) + x ≡ 0g\n invl x = inverse x .snd\n\n invr : (x : G) → x + (- x) ≡ 0g\n invr x = inverse x .fst\n\nη-isGroup : {G : Type ℓ} {0g 0g' : G} {_+_ _+'_ : G → G → G} { -_ -'_ : G → G}\n → 0g ≡ 0g'\n → _+_ ≡ _+'_\n → -_ ≡ -'_\n → IsGroup 0g _+_ -_ ≡ IsGroup 0g' _+'_ -'_\nη-isGroup id1 id2 id3 i = IsGroup (id1 i) (id2 i) (id3 i)\n\nrecord Group : Type (ℓ-suc ℓ) where\n no-eta-equality\n constructor group\n field\n Carrier : Type ℓ\n 0g : Carrier\n _+_ : Carrier → Carrier → Carrier\n -_ : Carrier → Carrier\n isGroup : IsGroup 0g _+_ -_\n\n infix 8 -_\n infixr 7 _+_\n\n open IsGroup isGroup public\n\nGroup₀ : Type₁\nGroup₀ = Group {ℓ-zero}\n\n-- Extractor for the carrier type\n⟨_⟩ : Group → Type ℓ\n⟨_⟩ = Group.Carrier\n\nisSetGroup : (G : Group {ℓ}) → isSet ⟨ G ⟩\nisSetGroup G = Group.isGroup G .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set\n\nmakeIsGroup : {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G}\n (is-setG : isSet G)\n (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)\n (rid : (x : G) → x + 0g ≡ x)\n (lid : (x : G) → 0g + x ≡ x)\n (rinv : (x : G) → x + (- x) ≡ 0g)\n (linv : (x : G) → (- x) + x ≡ 0g)\n → IsGroup 0g _+_ -_\nIsGroup.isMonoid (makeIsGroup is-setG assoc rid lid rinv linv) = makeIsMonoid is-setG assoc rid lid\nIsGroup.inverse (makeIsGroup is-setG assoc rid lid rinv linv) = λ x → rinv x , linv x\n\nmakeGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G)\n (is-setG : isSet G)\n (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)\n (rid : (x : G) → x + 0g ≡ x)\n (lid : (x : G) → 0g + x ≡ x)\n (rinv : (x : G) → x + (- x) ≡ 0g)\n (linv : (x : G) → (- x) + x ≡ 0g)\n → Group\nGroup.Carrier (makeGroup 0g _+_ -_ is-setG assoc rid lid rinv linv) = _\nGroup.0g (makeGroup 0g _+_ -_ is-setG assoc rid lid rinv linv) = 0g\nGroup._+_ (makeGroup 0g _+_ -_ is-setG assoc rid lid rinv linv) = _+_\nGroup.- makeGroup 0g _+_ -_ is-setG assoc rid lid rinv linv = -_\nGroup.isGroup (makeGroup 0g _+_ -_ is-setG assoc rid lid rinv linv) = makeIsGroup is-setG assoc rid lid rinv linv\n\nmakeGroup-right : ∀ {ℓ} {A : Type ℓ}\n → (id : A)\n → (comp : A → A → A)\n → (inv : A → A)\n → (set : isSet A)\n → (assoc : ∀ a b c → comp a (comp b c) ≡ comp (comp a b) c)\n → (rUnit : ∀ a → comp a id ≡ a)\n → (rCancel : ∀ a → comp a (inv a) ≡ id)\n → Group\nmakeGroup-right {A = A} id comp inv set assoc rUnit rCancel =\n makeGroup id comp inv set assoc rUnit lUnit rCancel lCancel\n where\n _⨀_ = comp\n abstract\n lCancel : ∀ a → comp (inv a) a ≡ id\n lCancel a =\n inv a ⨀ a\n ≡⟨ sym (rUnit (comp (inv a) a)) ⟩\n (inv a ⨀ a) ⨀ id\n ≡⟨ cong (comp (comp (inv a) a)) (sym (rCancel (inv a))) ⟩\n (inv a ⨀ a) ⨀ (inv a ⨀ (inv (inv a)))\n ≡⟨ assoc _ _ _ ⟩\n ((inv a ⨀ a) ⨀ (inv a)) ⨀ (inv (inv a))\n ≡⟨ cong (λ □ → □ ⨀ _) (sym (assoc _ _ _)) ⟩\n (inv a ⨀ (a ⨀ inv a)) ⨀ (inv (inv a))\n ≡⟨ cong (λ □ → (inv a ⨀ □) ⨀ (inv (inv a))) (rCancel a) ⟩\n (inv a ⨀ id) ⨀ (inv (inv a))\n ≡⟨ cong (λ □ → □ ⨀ (inv (inv a))) (rUnit (inv a)) ⟩\n inv a ⨀ (inv (inv a))\n ≡⟨ rCancel (inv a) ⟩\n id\n ∎\n\n lUnit : ∀ a → comp id a ≡ a\n lUnit a =\n id ⨀ a\n ≡⟨ cong (λ b → comp b a) (sym (rCancel a)) ⟩\n (a ⨀ inv a) ⨀ a\n ≡⟨ sym (assoc _ _ _) ⟩\n a ⨀ (inv a ⨀ a)\n ≡⟨ cong (comp a) (lCancel a) ⟩\n a ⨀ id\n ≡⟨ rUnit a ⟩\n a\n ∎\n\nmakeGroup-left : ∀ {ℓ} {A : Type ℓ}\n → (id : A)\n → (comp : A → A → A)\n → (inv : A → A)\n → (set : isSet A)\n → (assoc : ∀ a b c → comp a (comp b c) ≡ comp (comp a b) c)\n → (lUnit : ∀ a → comp id a ≡ a)\n → (lCancel : ∀ a → comp (inv a) a ≡ id)\n → Group\nmakeGroup-left {A = A} id comp inv set assoc lUnit lCancel =\n makeGroup id comp inv set assoc rUnit lUnit rCancel lCancel\n where\n abstract\n rCancel : ∀ a → comp a (inv a) ≡ id\n rCancel a =\n comp a (inv a)\n ≡⟨ sym (lUnit (comp a (inv a))) ⟩\n comp id (comp a (inv a))\n ≡⟨ cong (λ b → comp b (comp a (inv a))) (sym (lCancel (inv a))) ⟩\n comp (comp (inv (inv a)) (inv a)) (comp a (inv a))\n ≡⟨ sym (assoc (inv (inv a)) (inv a) (comp a (inv a))) ⟩\n comp (inv (inv a)) (comp (inv a) (comp a (inv a)))\n ≡⟨ cong (comp (inv (inv a))) (assoc (inv a) a (inv a)) ⟩\n comp (inv (inv a)) (comp (comp (inv a) a) (inv a))\n ≡⟨ cong (λ b → comp (inv (inv a)) (comp b (inv a))) (lCancel a) ⟩\n comp (inv (inv a)) (comp id (inv a))\n ≡⟨ cong (comp (inv (inv a))) (lUnit (inv a)) ⟩\n comp (inv (inv a)) (inv a)\n ≡⟨ lCancel (inv a) ⟩\n id\n ∎\n\n rUnit : ∀ a → comp a id ≡ a\n rUnit a =\n comp a id\n ≡⟨ cong (comp a) (sym (lCancel a)) ⟩\n comp a (comp (inv a) a)\n ≡⟨ assoc a (inv a) a ⟩\n comp (comp a (inv a)) a\n ≡⟨ cong (λ b → comp b a) (rCancel a) ⟩\n comp id a\n ≡⟨ lUnit a ⟩\n a\n ∎\n\nopen Group\nopen IsGroup\n\nη-Group : {G H : Group {ℓ}}\n → (p : ⟨ G ⟩ ≡ ⟨ H ⟩)\n → (q : PathP (λ i → p i) (0g G) (0g H))\n → (r : PathP (λ i → (p i) → (p i) → (p i)) (_+_ G) (_+_ H))\n → (s : PathP (λ i → p i → p i) (-_ G) (-_ H))\n → PathP (λ i → IsGroup (q i) (r i) (s i)) (isGroup G) (isGroup H)\n → G ≡ H\nCarrier (η-Group p _ _ _ _ i) = p i\n0g (η-Group _ q _ _ _ i) = q i\n_+_ (η-Group _ _ r _ _ i) = r i\n- η-Group _ _ _ s t i = s i\nisGroup (η-Group _ _ _ _ t i) = t i\n\nisSetCarrier : ∀ {ℓ} → (G : Group {ℓ}) → isSet ⟨ G ⟩\nisSetCarrier G = IsSemigroup.is-set (IsMonoid.isSemigroup (isMonoid G))\n\nopen IsMonoid\nopen IsSemigroup\ndirProd : ∀ {ℓ ℓ'} → Group {ℓ} → Group {ℓ'} → Group\nCarrier (dirProd A B) = Carrier A × Carrier B\n0g (dirProd A B) = (0g A) , (0g B)\n_+_ (dirProd A B) a b = (_+_ A (fst a) (fst b)) , _+_ B (snd a) (snd b)\n-_ (dirProd A B) a = (-_ A (fst a)) , (-_ B (snd a))\nis-set (isSemigroup (isMonoid (isGroup (dirProd A B)))) =\n isOfHLevelΣ 2 (isSetCarrier A) λ _ → isSetCarrier B\nassoc (isSemigroup (isMonoid (isGroup (dirProd A B)))) x y z i =\n assoc (isGroup A) (fst x) (fst y) (fst z) i , assoc (isGroup B) (snd x) (snd y) (snd z) i\nidentity (isMonoid (isGroup (dirProd A B))) x =\n (λ i → IsGroup.rid (isGroup A) (fst x) i , IsGroup.rid (isGroup B) (snd x) i)\n , λ i → IsGroup.lid (isGroup A) (fst x) i , IsGroup.lid (isGroup B) (snd x) i\ninverse (isGroup (dirProd A B)) x =\n (λ i → (fst (inverse (isGroup A) (fst x)) i) , (fst (inverse (isGroup B) (snd x)) i))\n , λ i → (snd (inverse (isGroup A) (fst x)) i) , (snd (inverse (isGroup B) (snd x)) i)\n\ntrivialGroup : Group₀\nCarrier trivialGroup = Unit\n0g trivialGroup = _\n_+_ trivialGroup _ _ = _\n-_ trivialGroup _ = _\nis-set (isSemigroup (isMonoid (isGroup trivialGroup))) = isSetUnit\nassoc (isSemigroup (isMonoid (isGroup trivialGroup))) _ _ _ = refl\nidentity (isMonoid (isGroup trivialGroup)) _ = refl , refl\ninverse (isGroup trivialGroup) _ = refl , refl\n\nintGroup : Group₀\nCarrier intGroup = Int\n0g intGroup = 0\n_+_ intGroup = _+Int_\n- intGroup = 0 -Int_\nis-set (isSemigroup (isMonoid (isGroup intGroup))) = isSetInt\nassoc (isSemigroup (isMonoid (isGroup intGroup))) = +-assoc\nidentity (isMonoid (isGroup intGroup)) x = refl , (+-comm (pos 0) x)\ninverse (isGroup intGroup) x = +-comm x (pos 0 -Int x) ∙ minusPlus x 0 , (minusPlus x 0)\n", "meta": {"hexsha": "91b4df6fd398c945aa15705f67376232a11c3cd6", "size": 8349, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/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/Group/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/Group/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": 34.0775510204, "max_line_length": 113, "alphanum_fraction": 0.5183854354, "num_tokens": 3351, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503205, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.5845592646236432}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Yoneda where\n\n-- Yoneda Lemma. In total, provides:\n-- * the Yoneda Embedding (called embed here) from any Category C into Presheaves C\n-- Worth noticing that there is no 'locally small' condition here; however, if one looks at\n-- the levels involved, there is indeed a raise from that of C to that of Presheaves C.\n-- * The traditional Yoneda lemma (yoneda-inverse) which says that for any object a of C, and\n-- any Presheaf F over C (where our presheaves are over Setoids), then\n-- Hom[ Presheaves C] (Functor.F₀ embed a , F) ≅ Functor.F₀ F a\n-- as Setoids. In addition, Yoneda (yoneda) also says that this isomorphism is natural in a and F.\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 (Presheaves)\nopen import Categories.Category.Construction.Functors using (eval)\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)\nopen 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[A,C]⇒Hom[B,C])\n private\n module CE = Category.Equiv C using (refl)\n module C = Category C using (op)\n\n -- The Yoneda embedding functor\n embed : Functor C (Presheaves C)\n embed = record\n { F₀ = Hom[ C ][-,_]\n ; F₁ = Hom[A,C]⇒Hom[B,C] -- A⇒B induces a NatTrans on the Homs.\n ; identity = identityˡ ○_\n ; homomorphism = λ h₁≈h₂ → ∘-resp-≈ʳ h₁≈h₂ ○ assoc\n ; F-resp-≈ = λ f≈g h≈i → ∘-resp-≈ f≈g h≈i\n }\n\n -- Using the adjunction between product and product, we get a kind of contravariant Bifunctor\n yoneda-inverse : (a : Obj) (F : Presheaf C (Setoids ℓ e)) →\n Inverse (Category.hom-setoid (Presheaves 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} Y⇒X {f} {g} f≈g →\n let module SR = SetoidR (F.₀ Y) in\n SR.begin\n F.₁ (id ∘ f ∘ Y⇒X) ⟨$⟩ x SR.≈⟨ F.F-resp-≈ (identityˡ ○ ∘-resp-≈ˡ f≈g) (SE.refl {x}) ⟩\n F.₁ (g ∘ Y⇒X) ⟨$⟩ x SR.≈⟨ F.homomorphism SE.refl ⟩\n F.₁ Y⇒X ⟨$⟩ (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} z≈y →\n let module S = Setoid (F.₀ x) in\n S.trans (S.sym (commute nat z CE.refl))\n (cong (η nat x) (identityˡ ○ identityˡ ○ z≈y))\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 -- in this bifunctor, a presheaf from Presheaves C goes from C to Setoids ℓ e,\n -- but the over Setoids has higher level than the hom setoids.\n Nat[Hom[C][-,c],F] : Bifunctor (Presheaves C) (Category.op C) (Setoids _ _)\n Nat[Hom[C][-,c],F] = Hom[ Presheaves C ][-,-] ∘F (Functor.op embed ∘F πʳ ※ πˡ)\n\n -- in this bifunctor, it needs to go from Presheaves which maps C to Setoids ℓ e,\n -- so the universe level needs to be lifted.\n FC : Bifunctor (Presheaves C) (Category.op C) (Setoids _ _)\n FC = LiftSetoids (o ⊔ ℓ ⊔ e) (o ⊔ ℓ) ∘F eval {C = Category.op 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) eq 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.op (Setoids ℓ e)}\n {A B : Obj} (f : B ⇒ A)\n (β γ : NaturalTransformation Hom[ C ][-, A ] F) →\n Setoid._≈_ (Functor.F₀ Nat[Hom[C][-,c],F] (F , A)) β γ →\n Setoid._≈_ (Functor.F₀ F B) (η β B ⟨$⟩ f ∘ id) (Functor.F₁ F f ⟨$⟩ (η γ A ⟨$⟩ id))\n helper {F} {A} {B} f β γ β≈γ = S.begin\n η β B ⟨$⟩ f ∘ id S.≈⟨ cong (η β B) (id-comm ○ (⟺ identityˡ)) ⟩\n η β B ⟨$⟩ id ∘ id ∘ f 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 (Category.op C) (Setoids ℓ e)}\n {A B Z : Obj}\n {h i : Z ⇒ B}\n {X Y : Setoid.Carrier (Functor.F₀ F A)}\n (α : NaturalTransformation F G)\n (f : B ⇒ A) →\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 (f ∘ i) ⟨$⟩ 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.₁ (f ∘ i) ⟨$⟩ 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": "52975067253129e7853ba5c0b677fabfef4cf0e2", "size": 7751, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Yoneda.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/Yoneda.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/Yoneda.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": 46.9757575758, "max_line_length": 108, "alphanum_fraction": 0.5555412205, "num_tokens": 2806, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951104066293, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5845171774755875}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Categories.Instances.Semilattice where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Algebra.Semilattice\n\nopen import Cubical.Categories.Category\nopen import Cubical.Categories.Instances.Poset\n\nopen Category\n\n\nmodule _ {ℓ} (L : Semilattice ℓ) where\n open JoinSemilattice L\n\n JoinSemilatticeCategory : Category ℓ ℓ\n JoinSemilatticeCategory = PosetCategory IndPoset\n\n\nmodule _ {ℓ} (L : Semilattice ℓ) where\n open MeetSemilattice L\n\n MeetSemilatticeCategory : Category ℓ ℓ\n MeetSemilatticeCategory = PosetCategory IndPoset\n", "meta": {"hexsha": "e698f39ae2c120961de2829833a6c3d0d0de817e", "size": 580, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Instances/Semilattice.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/Semilattice.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/Semilattice.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": 22.3076923077, "max_line_length": 53, "alphanum_fraction": 0.7982758621, "num_tokens": 162, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.5845171773910699}} {"text": "module Cats.Category.Constructions.Exponential where\n\nopen import Level\n\nopen import Cats.Category.Base\nopen import Cats.Category.Constructions.Product as Product using\n (HasBinaryProducts)\nopen import Cats.Util.Conv\n\nimport Cats.Category.Constructions.Unique as Unique\n\n\nmodule Build {lo la l≈}\n (Cat : Category lo la l≈)\n {{hasBinaryProducts : HasBinaryProducts Cat}}\n where\n\n open Category Cat\n open ≈-Reasoning\n open Unique.Build Cat\n open HasBinaryProducts hasBinaryProducts\n\n\n record Exp (B C : Obj) : Set (lo ⊔ la ⊔ l≈) where\n field\n Cᴮ : Obj\n eval : Cᴮ × B ⇒ C\n curry′ : ∀ {A} (f : A × B ⇒ C)\n → ∃![ f̃ ∈ A ⇒ Cᴮ ] (eval ∘ ⟨ f̃ × id ⟩ ≈ f)\n\n\n curry : ∀ {A} → A × B ⇒ C → A ⇒ Cᴮ\n curry f = curry′ f ⃗\n\n\n eval-curry : ∀ {A} {f : A × B ⇒ C}\n → eval ∘ ⟨ curry f × id ⟩ ≈ f\n eval-curry {f = f} = ∃!′.prop (curry′ f)\n\n\n curry-unique : ∀ {A} {f : A × B ⇒ C} {g}\n → eval ∘ ⟨ g × id ⟩ ≈ f\n → curry f ≈ g\n curry-unique {f = f} = ∃!′.unique (curry′ f)\n\n\n uncurry : ∀ {A} → A ⇒ Cᴮ → A × B ⇒ C\n uncurry f = eval ∘ ⟨ f × id ⟩\n\n\n curry∘uncurry : ∀ {A} {f : A ⇒ Cᴮ}\n → curry (uncurry f) ≈ f\n curry∘uncurry = curry-unique ≈.refl\n\n\n uncurry∘curry : ∀ {A} {f : A × B ⇒ C}\n → uncurry (curry f) ≈ f\n uncurry∘curry = eval-curry\n\n\n instance HasObj-Exp : ∀ {B C} → HasObj (Exp B C) lo la l≈\n HasObj-Exp = record { Cat = Cat ; _ᴼ = Exp.Cᴮ }\n\n open Exp public\n\n\n curry∘curry : ∀ {A B C Y Z} (Cᴮ : Exp B C) (Yᶻ : Exp Y Z)\n → {f : Cᴮ ᴼ × Y ⇒ Z} {g : A × B ⇒ C}\n → curry Yᶻ f ∘ curry Cᴮ g ≈ curry Yᶻ (f ∘ ⟨ curry Cᴮ g × id ⟩)\n curry∘curry Cᴮ Yᶻ {f} {g} = ≈.sym (curry-unique Yᶻ (\n begin\n eval Yᶻ ∘ ⟨ curry Yᶻ f ∘ curry Cᴮ g × id ⟩\n ≈⟨ ∘-resp-r (⟨×⟩-resp ≈.refl (≈.sym id-l)) ⟩\n eval Yᶻ ∘ ⟨ curry Yᶻ f ∘ curry Cᴮ g × id ∘ id ⟩\n ≈⟨ ∘-resp-r (≈.sym ⟨×⟩-∘) ⟩\n eval Yᶻ ∘ ⟨ curry Yᶻ f × id ⟩ ∘ ⟨ curry Cᴮ g × id ⟩\n ≈⟨ unassoc ⟩\n (eval Yᶻ ∘ ⟨ curry Yᶻ f × id ⟩) ∘ ⟨ curry Cᴮ g × id ⟩\n ≈⟨ ∘-resp-l (eval-curry Yᶻ) ⟩\n f ∘ ⟨ curry Cᴮ g × id ⟩\n ∎\n ))\n\n\nrecord HasExponentials {lo la l≈}\n (Cat : Category lo la l≈)\n : Set (lo ⊔ la ⊔ l≈)\n where\n private open module Bld = Build Cat using (Exp)\n open Category Cat\n open Unique.Build Cat\n\n infixr 1 _↝′_ _↝_\n\n field\n {{hasBinaryProducts}} : HasBinaryProducts Cat\n _↝′_ : ∀ B C → Exp B C\n\n\n open HasBinaryProducts hasBinaryProducts\n\n\n _↝_ : Obj → Obj → Obj\n B ↝ C = (B ↝′ C) ᴼ\n\n\n eval : ∀ {B C} → (B ↝ C) × B ⇒ C\n eval {B} {C} = Bld.eval (B ↝′ C)\n\n\n curry : ∀ {A B C} → A × B ⇒ C → A ⇒ B ↝ C\n curry {B = B} {C} f = Bld.curry (B ↝′ C) f\n\n\n uncurry : ∀ {A B C} → A ⇒ B ↝ C → A × B ⇒ C\n uncurry {B = B} {C} = Bld.uncurry (B ↝′ C)\n\n\n eval-curry : ∀ {A B C} {f : A × B ⇒ C}\n → eval ∘ ⟨ curry f × id ⟩ ≈ f\n eval-curry {B = B} {C} = Bld.eval-curry (B ↝′ C)\n\n\n curry∘uncurry : ∀ {A B C} {f : A ⇒ B ↝ C}\n → curry (uncurry f) ≈ f\n curry∘uncurry {B = B} {C} = Bld.curry∘uncurry (B ↝′ C)\n\n\n uncurry∘curry : ∀ {A B C} {f : A × B ⇒ C}\n → uncurry (curry f) ≈ f\n uncurry∘curry {B = B} {C} = Bld.uncurry∘curry (B ↝′ C)\n\n\n curry∘curry : ∀ {A B C Y Z}\n → {f : (B ↝ C) × Y ⇒ Z} {g : A × B ⇒ C}\n → curry f ∘ curry g ≈ curry (f ∘ ⟨ curry g × id ⟩)\n curry∘curry {B = B} {C} {Y} {Z} = Bld.curry∘curry (B ↝′ C) (Y ↝′ Z)\n", "meta": {"hexsha": "f72014abd17dcbdc16ea0adcd257c5f4efffd442", "size": 3327, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Constructions/Exponential.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/Exponential.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/Exponential.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.1086956522, "max_line_length": 69, "alphanum_fraction": 0.5031559964, "num_tokens": 1518, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545426, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.5845171773910699}} {"text": "module Issue533 where\n\ndata Empty : Set where\n\nempty : {A B : Set} → (B → Empty) → B → A\nempty f x with f x\n... | ()\n\nfail : ∀ {A : Set} → Empty → A\nfail {A} = empty absurd\n where\n absurd : _ → Empty\n absurd ()\n-- should check (due to postponed emptyness constraint, see issue 479)\n", "meta": {"hexsha": "0518bbd269a1cf28a863c947296e204f0799d1be", "size": 289, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue533.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/Issue533.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/Issue533.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.2666666667, "max_line_length": 70, "alphanum_fraction": 0.6055363322, "num_tokens": 90, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438950947024556, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.5845171773065521}} {"text": "{-# OPTIONS --universe-polymorphism #-}\n\nopen import Categories.Category\n\nmodule Categories.Functor.Core where\n\nopen import Level\nopen import Categories.Support.EqReasoning\n\nrecord Functor {o ℓ e o′ ℓ′ e′} (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\n field\n F₀ : C.Obj → D.Obj\n {F₁} : ∀ {A B} → 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 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\n\n\nEndofunctor : ∀ {o ℓ e} → Category o ℓ e → Set _\nEndofunctor C = Functor C C\n\nContravariant : ∀ {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Set _\nContravariant C D = Functor C.op D\n where module C = Category C\n\nid : ∀ {o ℓ e} {C : Category o ℓ e} → Endofunctor C\nid {C = C} = record \n { F₀ = λ x → x\n ; F₁ = λ x → x\n ; identity = refl\n ; homomorphism = refl\n ; F-resp-≡ = λ x → x\n }\n where open Category.Equiv C\n\ninfixr 9 _∘_\n\n_∘_ : ∀ {o ℓ e} {o′ ℓ′ e′} {o′′ ℓ′′ e′′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o′′ ℓ′′ e′′} \n → Functor D E → Functor C D → Functor C E\n_∘_ {C = C} {D = D} {E = E} F G = record \n { F₀ = λ x → F₀ (G₀ x)\n ; F₁ = λ f → F₁ (G₁ f)\n ; identity = identity′\n ; homomorphism = homomorphism′\n ; F-resp-≡ = ∘-resp-≡′\n }\n where\n module C = Category C\n module D = Category D\n module E = Category E\n module F = Functor F\n module G = Functor G\n open F\n open G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡)\n\n .identity′ : ∀ {A} → E [ F₁ (G₁ (C.id {A})) ≡ E.id ]\n identity′ = begin\n F₁ (G₁ C.id)\n ≈⟨ F-resp-≡ G.identity ⟩\n F₁ D.id\n ≈⟨ F.identity ⟩\n E.id\n ∎\n where\n open SetoidReasoning E.hom-setoid\n\n .homomorphism′ : ∀ {X Y Z} {f : C [ X , Y ]} {g : C [ Y , Z ]}\n → E [ F₁ (G₁ (C [ g ∘ f ])) ≡ E [ F₁ (G₁ g) ∘ F₁ (G₁ f) ] ]\n homomorphism′ {f = f} {g = g} = begin\n F₁ (G₁ (C [ g ∘ f ]))\n ≈⟨ F-resp-≡ G.homomorphism ⟩\n F₁ (D [ G₁ g ∘ G₁ f ])\n ≈⟨ F.homomorphism ⟩\n (E [ F₁ (G₁ g) ∘ F₁ (G₁ f) ])\n ∎\n where\n open SetoidReasoning E.hom-setoid\n\n .∘-resp-≡′ : ∀ {A B} {F G : C [ A , B ]} \n → C [ F ≡ G ] → E [ F₁ (G₁ F) ≡ F₁ (G₁ G) ]\n ∘-resp-≡′ = λ x → F-resp-≡ (G-resp-≡ x)\n", "meta": {"hexsha": "978b4dcfa52ba5ea3da143eb1c17c5dabb1923d0", "size": 2867, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/Functor/Core.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/Core.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/Core.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": 28.9595959596, "max_line_length": 115, "alphanum_fraction": 0.4489012905, "num_tokens": 1172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5845171665982175}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Vectors defined by recursion\n------------------------------------------------------------------------\n\n-- What is the point of this module? The n-ary products below are intended\n-- to be used with a fixed n, in which case the nil constructor can be\n-- avoided: pairs are represented as pairs (x , y), not as triples\n-- (x , y , unit).\n-- Additionally, vectors defined by recursion enjoy η-rules. That is to say\n-- that two vectors of known length are definitionally equal whenever their\n-- elements are.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Vec.Recursive where\n\nopen import Level using (Level; Lift; lift)\nopen import Data.Nat.Base as Nat using (ℕ; zero; suc)\nopen import Data.Empty\nopen import Data.Fin.Base as Fin using (Fin; zero; suc)\nopen import Data.Product as Prod using (_×_; _,_; proj₁; proj₂)\nopen import Data.Sum.Base as Sum using (_⊎_)\nopen import Data.Unit.Base\nopen import Data.Vec.Base as Vec using (Vec; _∷_)\nopen import Function\nopen import Relation.Unary\nopen import Agda.Builtin.Equality using (_≡_)\n\nprivate\n variable\n a b c p : Level\n A : Set a\n B : Set b\n C : Set c\n\n-- Types and patterns\n------------------------------------------------------------------------\n\npattern 2+_ n = suc (suc n)\n\ninfix 8 _^_\n_^_ : Set a → ℕ → Set a\nA ^ 0 = Lift _ ⊤\nA ^ 1 = A\nA ^ 2+ n = A × A ^ suc n\n\npattern [] = lift tt\n\ninfix 3 _∈[_]_\n_∈[_]_ : {A : Set a} → A → ∀ n → A ^ n → Set a\na ∈[ 0 ] as = Lift _ ⊥\na ∈[ 1 ] a′ = a ≡ a′\na ∈[ 2+ n ] a′ , as = a ≡ a′ ⊎ a ∈[ suc n ] as\n\n-- Basic operations\n------------------------------------------------------------------------\n\ncons : ∀ n → A → A ^ n → A ^ suc n\ncons 0 a _ = a\ncons (suc n) a as = a , as\n\nuncons : ∀ n → A ^ suc n → A × A ^ n\nuncons 0 a = a , lift tt\nuncons (suc n) (a , as) = a , as\n\nhead : ∀ n → A ^ suc n → A\nhead n as = proj₁ (uncons n as)\n\ntail : ∀ n → A ^ suc n → A ^ n\ntail n as = proj₂ (uncons n as)\n\nfromVec : ∀[ Vec A ⇒ (A ^_) ]\nfromVec = Vec.foldr (_ ^_) (cons _) _\n\ntoVec : Π[ (A ^_) ⇒ Vec A ]\ntoVec 0 as = Vec.[]\ntoVec (suc n) as = head n as ∷ toVec n (tail n as)\n\nlookup : ∀ {n} (k : Fin n) → A ^ n → A\nlookup zero = head _\nlookup (suc {n} k) = lookup k ∘′ tail n\n\nreplicate : ∀ n → A → A ^ n\nreplicate n a = fromVec (Vec.replicate a)\n\ntabulate : ∀ n → (Fin n → A) → A ^ n\ntabulate n f = fromVec (Vec.tabulate f)\n\nappend : ∀ m n → A ^ m → A ^ n → A ^ (m Nat.+ n)\nappend 0 n xs ys = ys\nappend 1 n x ys = cons n x ys\nappend (2+ m) n (x , xs) ys = x , append (suc m) n xs ys\n\nsplitAt : ∀ m n → A ^ (m Nat.+ n) → A ^ m × A ^ n\nsplitAt 0 n xs = [] , xs\nsplitAt (suc m) n xs =\n let (ys , zs) = splitAt m n (tail (m Nat.+ n) xs) in\n cons m (head (m Nat.+ n) xs) ys , zs\n\n\n-- Manipulating N-ary products\n------------------------------------------------------------------------\n\nmap : (A → B) → ∀ n → A ^ n → B ^ n\nmap f 0 as = lift tt\nmap f 1 a = f a\nmap f (2+ n) (a , as) = f a , map f (suc n) as\n\nap : ∀ n → (A → B) ^ n → A ^ n → B ^ n\nap 0 fs ts = []\nap 1 f t = f t\nap (2+ n) (f , fs) (t , ts) = f t , ap (suc n) fs ts\n\nmodule _ {P : ℕ → Set p} where\n\n foldr : P 0 → (A → P 1) → (∀ n → A → P (suc n) → P (2+ n)) →\n ∀ n → A ^ n → P n\n foldr p0 p1 p2+ 0 as = p0\n foldr p0 p1 p2+ 1 a = p1 a\n foldr p0 p1 p2+ (2+ n) (a , as) = p2+ n a (foldr p0 p1 p2+ (suc n) as)\n\nfoldl : (P : ℕ → Set p) →\n P 0 → (A → P 1) → (∀ n → A → P (suc n) → P (2+ n)) →\n ∀ n → A ^ n → P n\nfoldl P p0 p1 p2+ 0 as = p0\nfoldl P p0 p1 p2+ 1 a = p1 a\nfoldl P p0 p1 p2+ (2+ n) (a , as) = let p1′ = p1 a in\n foldl (P ∘′ suc) p1′ (λ a → p2+ 0 a p1′) (p2+ ∘ suc) (suc n) as\n\nreverse : ∀ n → A ^ n → A ^ n\nreverse = foldl (_ ^_) [] id (λ n → _,_)\n\nzipWith : (A → B → C) → ∀ n → A ^ n → B ^ n → C ^ n\nzipWith f 0 as bs = []\nzipWith f 1 a b = f a b\nzipWith f (2+ n) (a , as) (b , bs) = f a b , zipWith f (suc n) as bs\n\nunzipWith : (A → B × C) → ∀ n → A ^ n → B ^ n × C ^ n\nunzipWith f 0 as = [] , []\nunzipWith f 1 a = f a\nunzipWith f (2+ n) (a , as) = Prod.zip _,_ _,_ (f a) (unzipWith f (suc n) as)\n\nzip : ∀ n → A ^ n → B ^ n → (A × B) ^ n\nzip = zipWith _,_\n\nunzip : ∀ n → (A × B) ^ n → A ^ n × B ^ n\nunzip = unzipWith id\n", "meta": {"hexsha": "50e4eccb1bbe32d4822f42a7c144f1e976f96b0a", "size": 4466, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Vec/Recursive.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/Recursive.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/Recursive.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.7733333333, "max_line_length": 77, "alphanum_fraction": 0.4675324675, "num_tokens": 1662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.6926419704455588, "lm_q1q2_score": 0.5845171612440502}} {"text": "{-# OPTIONS --without-K --exact-split #-}\n\nmodule hott-i where\n\nimport 04-inductive-types\nopen 04-inductive-types public\n\ndata 𝕀 : UU lzero where\n left : 𝕀\n\npostulate right : 𝕀\n\ndata Path {l : Level} (A : 𝕀 → UU l) : (a : A left) (a' : A right) → UU l where\n pcon : (f : (x : 𝕀) → A x) → Path A (f left) (f right)\n\napply-path :\n {l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) →\n Path A a a' → (x : 𝕀) → A x\napply-path A .(f left) .(f right) (pcon f) x = f x\n\nrefl-path :\n {l : Level} (A : UU l) (a : A) → Path (λ x → A) a a\nrefl-path A a = pcon (λ x → a)\n\napply-path-pcon :\n {l : Level} (A : 𝕀 → UU l) (f : (x : 𝕀) → A x) →\n (x : 𝕀) → Path (λ y → A x) (apply-path A (f left) (f right) (pcon f) x) (f x)\napply-path-pcon A f x = refl-path (A x) (f x)\n\nleft-apply-path :\n {l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) (p : Path A a a') →\n Path (λ y → A left) (apply-path A a a' p left) a\nleft-apply-path A .(f left) .(f right) (pcon f) = refl-path (A left) (f left)\n\nright-apply-path :\n {l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) (p : Path A a a') →\n Path (λ y → A right) (apply-path A a a' p right) a'\nright-apply-path A .(f left) .(f right) (pcon f) = refl-path (A right) (f right)\n\nfree-transport-path :\n {l : Level} (A : 𝕀 → UU l) → A left → (x : 𝕀) → A x\nfree-transport-path A a left = a\n\ntransport-path :\n {l : Level} (A : 𝕀 → UU l) → A left → A right\ntransport-path A a = free-transport-path A a right\n\nelim-path-lemma :\n {l : Level} {A : UU l} (f : (x : 𝕀) → A) →\n (i : 𝕀) → Path (λ j → A) (f left) (f i)\nelim-path-lemma {A = A} f left = refl-path A (f left)\n\nelim-path :\n {l1 l2 : Level} (A : UU l1) (a : A)\n (B : (x : A) (p : Path (λ i → A) a x) → UU l2) →\n B a (refl-path A a) →\n (x : A) (p : Path (λ i → A) a x) → B x p\nelim-path A .(f left) B b .(f right) (pcon f) =\n transport-path (λ i → B (f i) {!elim-path-lemma f i!}) b\n \n\nconcat-path :\n {l : Level} {A : UU l} {x y z : A} →\n Path (λ i → A) x y → Path (λ i → A) y z → Path (λ i → A) x z\nconcat-path {l} {A} {x} p (pcon f) =\n transport-path (λ i → Path (λ j → A) x (f i)) p\n\nfunction-extensionality' :\n {l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g : (x : A) → B x} →\n (H : (x : A) → Path (λ i → B x) (f x) (g x)) →\n (i : 𝕀) (x : A) → B x\nfunction-extensionality' {B = B} {f} {g} H i x =\n apply-path (λ j → B x) (f x) (g x) (H x) i\n\nfunction-extensionality :\n {l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g : (x : A) → B x} →\n (H : (x : A) → Path (λ i → B x) (f x) (g x)) →\n Path (λ j → (x : A) → B x) f g\nfunction-extensionality {l1} {l2} {A} {B} {f} {g} H =\n concat-path\n ( concat-path\n {!!}\n ( pcon (function-extensionality' H)))\n ( {!!})\n\n{-\npcon-apply-path :\n {l : Level} (A : 𝕀 → UU l) (a : A left) (a' : A right) (p : Path A a a') →\n Path (λ y → Path A a a') (pcon (apply-path A a a' p)) ?\npcon-apply-path A a a' p = ?\n-}\n", "meta": {"hexsha": "9855b797050a29094ad82317eb6c55ad3597a9ad", "size": 2877, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/hott-i.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/hott-i.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/hott-i.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": 31.2717391304, "max_line_length": 80, "alphanum_fraction": 0.5060827251, "num_tokens": 1294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677699040321, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.5845089466478781}} {"text": "open import Prelude hiding (lift; id)\n\nmodule Implicits.Syntax.LNMetaType where\n\nopen import Implicits.Syntax.Type\nopen import Data.Nat as Nat\n\nmutual\n data MetaSType (m : ℕ) : Set where\n tvar : ℕ → MetaSType m\n mvar : Fin m → MetaSType m\n _→'_ : (a b : MetaType m) → MetaSType m\n tc : ℕ → MetaSType m\n\n data MetaType (m : ℕ) : Set where\n _⇒_ : (a b : MetaType m) → MetaType m\n ∀' : MetaType m → MetaType m\n simpl : MetaSType m → MetaType m\n\nmutual\n\n open-meta : ∀ {m} → ℕ → MetaType m → MetaType (suc m)\n open-meta k (a ⇒ b) = open-meta k a ⇒ open-meta k b\n open-meta k (∀' a) = ∀' (open-meta (suc k) a )\n open-meta k (simpl x) = simpl (open-st k x)\n where\n open-st : ∀ {m} → ℕ → MetaSType m → MetaSType (suc m)\n open-st k (tvar x) with Nat.compare x k\n open-st .(suc (x N+ k)) (tvar x) | less .x k = tvar x\n open-st k (tvar .k) | equal .k = mvar zero\n open-st k (tvar .(suc (k N+ x))) | greater .k x = tvar (k N+ x)\n open-st k (mvar x) = mvar (suc x)\n open-st k (a →' b) = open-meta k a →' open-meta k b\n open-st k (tc x) = tc x\n\nmutual\n\n data TClosedS {m} (n : ℕ) : MetaSType m → Set where\n tvar : ∀ {x} → (x N< n) → TClosedS n (tvar x)\n mvar : ∀ {x} → TClosedS n (mvar x)\n _→'_ : ∀ {a b} → TClosed n a → TClosed n b → TClosedS n (a →' b)\n tc : ∀ {c} → TClosedS n (tc c)\n\n data TClosed {m} (n : ℕ) : MetaType m → Set where\n _⇒_ : ∀ {a b} → TClosed n a → TClosed n b → TClosed n (a ⇒ b)\n ∀' : ∀ {a} → TClosed (suc n) a → TClosed n (∀' a)\n simpl : ∀ {τ} → TClosedS n τ → TClosed n (simpl τ)\n\nto-meta : ∀ {ν} → Type ν → MetaType zero\nto-meta (simpl (tc x)) = simpl (tc x)\nto-meta (simpl (tvar n)) = simpl (tvar (toℕ n))\nto-meta (simpl (a →' b)) = simpl (to-meta a →' to-meta b)\nto-meta (a ⇒ b) = to-meta a ⇒ to-meta b\nto-meta (∀' a) = ∀' (to-meta a) \n\nfrom-meta : ∀ {ν} {a : MetaType zero} → TClosed ν a → Type ν\nfrom-meta (a ⇒ b) = from-meta a ⇒ from-meta b\nfrom-meta (∀' a) = ∀' (from-meta a)\nfrom-meta (simpl (tvar x)) = simpl (tvar (fromℕ≤ x))\nfrom-meta (simpl (mvar {()}))\nfrom-meta (simpl (a →' b)) = simpl (from-meta a →' from-meta b)\nfrom-meta (simpl (tc {c})) = simpl (tc c)\n", "meta": {"hexsha": "8ef70e007ce91a270562c45ba54db41d5a5fc2e8", "size": 2183, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Implicits/Syntax/LNMetaType.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/Implicits/Syntax/LNMetaType.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/Implicits/Syntax/LNMetaType.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": 34.6507936508, "max_line_length": 69, "alphanum_fraction": 0.5551992671, "num_tokens": 868, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619634, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5845089439995185}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Groups\nopen import Functions.Definition\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Integers.Integers\nopen import Numbers.Modulo.Group\nopen import Numbers.Modulo.Definition\nopen import Rings.Examples.Proofs\nopen import Numbers.Primes.PrimeNumbers\nopen import Setoids.Setoids\nopen import Rings.Definition\nopen import Groups.Definition\nopen import Groups.Lemmas\nopen import Sets.EquivalenceRelations\n\nmodule Rings.Examples.Examples where\n\nmultiplicationNotGroup : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) → (nontrivial : Setoid._∼_ S (Ring.1R R) (Ring.0R R) → False) → Group S _*_ → False\nmultiplicationNotGroup {S = S} R 1!=0 gr = exFalso (1!=0 (groupsHaveLeftCancellation gr (Ring.0R R) (Ring.1R R) (Ring.0R R) (transitive (Ring.timesZero' R) (symmetric (Ring.timesZero' R)))))\n where\n open Setoid S\n open Equivalence eq\n\nnToZn : (n : ℕ) (pr : 0 t2) with construct-type t1 | construct-type t2\n ... | (l1 , ih1) | (l2 , ih2) = l1 ++ construct arrow :: l2 ++ [ move parent ] ,\n runtype++ ih1\n (DoType TMConArrow\n (runtype++ (ziplem-tmarr2 ih2)\n (DoType TMArrParent2 DoRefl)))\n construct-type (t1 ⊕ t2) with construct-type t1 | construct-type t2\n ... | (l1 , ih1) | (l2 , ih2) = l1 ++ construct sum :: l2 ++ [ move parent ] ,\n runtype++ ih1\n (DoType TMConPlus\n (runtype++ (ziplem-tmplus2 ih2)\n (DoType TMPlusParent2 DoRefl)))\n construct-type (t1 ⊠ t2) with construct-type t1 | construct-type t2\n ... | (l1 , ih1) | (l2 , ih2) = l1 ++ construct prod :: l2 ++ [ move parent ] ,\n runtype++ ih1\n (DoType TMConProd\n (runtype++ (ziplem-tmprod2 ih2)\n (DoType TMProdParent2 DoRefl)))\n mutual\n -- construction of expressions in synthetic positions\n construct-synth : {Γ : tctx} {u : Nat} {t : htyp} {e : hexp} →\n (Γ ⊢ e => t) →\n Σ[ L ∈ List action ]\n runsynth Γ ▹ ⦇-⦈[ u ] ◃ ⦇-⦈ L ▹ e ◃ t\n -- the three base cases\n construct-synth (SVar x) = [ construct (var _ irr-hole) ] , DoSynth (SAConVar x) DoRefl\n construct-synth SNum = [ construct (numlit _ irr-hole) ] , DoSynth SAConNumlit DoRefl\n construct-synth SEHole = [ del _ ] , DoSynth SADel DoRefl\n \n -- the inductive cases\n construct-synth (SPlus e1 e2 ) with construct-ana e1 | construct-ana e2\n ... | (l1 , ih1) | (l2 , ih2) =\n construct (plus irr-hole irr-hole) :: (l2 ++ move parent ::\n move (child 1) :: (l1 ++ [ move parent ])) ,\n DoSynth (SAConPlus1 TCHole2)\n (runsynth++ (ziplem-plus2 ih2)\n (DoSynth (SAMove EMPlusParent2)\n (DoSynth (SAMove EMPlusChild1)\n (runsynth++ (ziplem-plus1 ih1)\n (DoSynth (SAMove EMPlusParent1) DoRefl))))) \n\n construct-synth {t = t} (SAsc x) with construct-type t | construct-ana x\n ... | (l1 , ih1) | (l2 , ih2) =\n construct asc :: (l1 ++ move parent :: move (child 1) :: (l2 ++ [ move parent ])) ,\n DoSynth SAConAsc\n (runsynth++ (ziplem-asc2 ETTop ETTop ih1)\n (DoSynth (SAMove EMAscParent2)\n (DoSynth (SAMove EMAscChild1)\n (runsynth++ (ziplem-asc1 ih2)\n (DoSynth (SAMove EMAscParent1) DoRefl)))))\n \n construct-synth {t = t1 ==> t2} (SLam x wt) with construct-type t1 | construct-synth wt\n ... | l1 , ih1 | l2 , ih2 =\n construct (lam _ irr-hole irr-hole) ::\n (l1 ++ (move parent :: move (child 2) :: (l2 ++ [ move parent ]))) ,\n DoSynth (SAConLam x)\n (runsynth++ (ziplem-halflam1 x ETTop (rel◆t _) ih1)\n (DoSynth (SAMove EMHalfLamParent1)\n (DoSynth (SAMove EMHalfLamChild2)\n (runsynth++ (ziplem-halflam2 x EETop SEHole ih2)\n (DoSynth (SAMove EMHalfLamParent2) DoRefl)))))\n \n construct-synth (SAp e1 m e2) with construct-synth e1 | construct-ana e2\n ... | l1 , ih1 | l2 , ih2 =\n l1 ++ construct (ap irr-hole irr-hole) :: (l2 ++ [ move parent ]) ,\n runsynth++ ih1\n (DoSynth (SAConApArr m)\n (runsynth++ (ziplem-ap2 e1 m ih2)\n (DoSynth (SAMove EMApParent2) DoRefl)))\n\n construct-synth (SNEHole {u = u} wt) with construct-synth wt\n ... | l , ih = l ++ construct (nehole u) :: move parent :: [] ,\n runsynth++ ih\n (DoSynth SAConNEHole\n (DoSynth (SAMove EMNEHoleParent) DoRefl))\n\n construct-synth (SPair e1 e2) with construct-synth e1 | construct-synth e2\n ... | l1 , ih1 | l2 , ih2 =\n construct (pair irr-hole irr-hole) :: (l1 ++ move parent :: move (child 2)\n :: l2 ++ [ move parent ]) ,\n DoSynth SAConPair\n (runsynth++ (ziplem-pair1 EETop SEHole ih1 SEHole)\n (DoSynth (SAMove EMPairParent1)\n (DoSynth (SAMove EMPairChild2)\n (runsynth++ (ziplem-pair2 e1 EETop SEHole ih2)\n (DoSynth (SAMove EMPairParent2) DoRefl)))))\n \n construct-synth (SFst e pr) with construct-synth e\n ... | l , ih = l ++ [ construct (fst irr-hole) ] ,\n runsynth++ ih (DoSynth (SAConFst1 pr) DoRefl)\n \n construct-synth (SSnd e pr) with construct-synth e\n ... | l , ih = l ++ [ construct (snd irr-hole) ] ,\n runsynth++ ih (DoSynth (SAConSnd1 pr) DoRefl)\n \n -- construction of expressions in analytic positions\n construct-ana : {Γ : tctx} {u : Nat} {t : htyp} {e : hexp} →\n (Γ ⊢ e <= t) →\n Σ[ L ∈ List action ]\n runana Γ ▹ ⦇-⦈[ u ] ◃ L ▹ e ◃ t\n construct-ana (ASubsume x c) with construct-synth x\n ... | l , ih = construct (nehole irr-hole) :: l ++ (move parent :: finish :: []) ,\n DoAna (AASubsume EETop SEHole SAConNEHole TCHole1)\n (runana++ (ziplem-nehole-b SEHole c ih)\n (DoAna (AAMove EMNEHoleParent)\n (DoAna (AAFinish (ASubsume x c)) DoRefl)))\n\n construct-ana (ALam a m e) with construct-ana e\n ... | l , ih = construct (lam _ irr-hole irr-hole) :: (l ++ [ move parent ]) ,\n DoAna (AAConLam1 a m)\n (runana++ (ziplem-lam a m ih)\n (DoAna (AAMove EMLamParent) DoRefl))\n\n construct-ana (AInl m wt) with construct-ana wt\n ... | l , ih = construct (inl irr-hole irr-hole) :: l ++ [ move parent ] ,\n DoAna (AAConInl1 m)\n (runana++ (ziplem-inl m ih)\n (DoAna (AAMove EMInlParent) DoRefl))\n\n construct-ana (AInr m wt) with construct-ana wt\n ... | l , ih = construct (inr irr-hole irr-hole) :: l ++ [ move parent ] ,\n DoAna (AAConInr1 m)\n (runana++ (ziplem-inr m ih)\n (DoAna (AAMove EMInrParent) DoRefl))\n\n construct-ana (ACase {x = x} {y = y} x# y# m wt0 wt1 wt2)\n with construct-synth wt0\n | construct-ana wt1\n | construct-ana wt2\n ... | l0 , ih0 | l1 , ih1 | l2 , ih2 =\n construct (case x y irr-hole irr-hole irr-hole) :: construct (nehole irr-hole) ::\n l0 ++ (move parent :: finish :: move parent :: move (child 2) ::\n l1 ++ (move parent :: move (child 3) ::\n l2 ++ [ move parent ])) ,\n DoAna (AAConCase x# y#)\n (DoAna (AAZipCase1 x# y# EETop SEHole SAConNEHole MSHole\n (ASubsume SEHole TCHole1) (ASubsume SEHole TCHole1))\n (runana++ (ziplem-case1b x# y# EETop SEHole ih0)\n (DoAna (AAZipCase1 x# y# (EENEHole EETop)\n (SNEHole wt0) (SAMove EMNEHoleParent) MSHole (ASubsume SEHole TCHole1)\n (ASubsume SEHole TCHole1))\n (DoAna (AAZipCase1 x# y# EETop (SNEHole wt0) (SAFinish wt0) m\n (ASubsume SEHole TCHole1) (ASubsume SEHole TCHole1))\n (DoAna (AAMove EMCaseParent1)\n (DoAna (AAMove EMCaseChild2)\n (runana++ (ziplem-case2 x# y# wt0 (ASubsume SEHole TCHole1) m ih1)\n (DoAna (AAMove EMCaseParent2)\n (DoAna (AAMove EMCaseChild3)\n (runana++ (ziplem-case3 x# y# wt0 wt1 m ih2)\n (DoAna (AAMove EMCaseParent3) DoRefl)))))))))))\n", "meta": {"hexsha": "ad9ff9a638bda48dcb778a996a4a57700a886cb5", "size": 8632, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "constructability.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": "constructability.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": "constructability.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": 48.7683615819, "max_line_length": 91, "alphanum_fraction": 0.5444856348, "num_tokens": 2693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278757303677, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.584099203118728}} {"text": "module Dave.Extensionality where\n open import Dave.Equality\n\n postulate\n extensionality : ∀ {A B : Set} {f g : A → B} \n → (∀ (x : A) → f x ≡ g x) \n → f ≡ g\n\n postulate\n ∀-extensionality : ∀ {A : Set} {B : A → Set} {f g : ∀(x : A) → B x}\n → (∀ (x : A) → f x ≡ g x)\n → f ≡ g", "meta": {"hexsha": "f49d2e58d976d3719d3c1f86db178469a748717c", "size": 339, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Dave/Extensionality.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/Extensionality.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/Extensionality.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": 28.25, "max_line_length": 75, "alphanum_fraction": 0.4041297935, "num_tokens": 122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278602705731, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.5840991928855362}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Indexed M-types (the dual of indexed W-types aka Petersson-Synek\n-- trees).\n------------------------------------------------------------------------\n\nmodule Data.M.Indexed where\n\nopen import Level\nopen import Coinduction\nopen import Data.Product\nopen import Data.Container.Indexed.Core\nopen import Function\nopen import Relation.Unary\n\n-- The family of indexed M-types.\n\nmodule _ {ℓ c r} {O : Set ℓ} (C : Container O O c r) where\n\n data M (o : O) : Set (ℓ ⊔ c ⊔ r) where\n inf : ⟦ C ⟧ (∞ ∘ M) o → M o\n\n open Container C\n\n -- Projections.\n\n head : M ⊆ Command\n head (inf (c , _)) = c\n\n tail : ∀ {o} (m : M o) (r : Response (head m)) → M (next (head m) r)\n tail (inf (_ , k)) r = ♭ (k r)\n\n force : M ⊆ ⟦ C ⟧ M\n force (inf (c , k)) = c , λ r → ♭ (k r)\n\n -- Coiteration.\n\n coit : ∀ {ℓ} {X : Pred O ℓ} → X ⊆ ⟦ C ⟧ X → X ⊆ M\n coit ψ x = inf (proj₁ cs , λ r → ♯ coit ψ (proj₂ cs r))\n where\n cs = ψ x\n", "meta": {"hexsha": "efd87f9d0899f521e5a92c35deec456278a95c34", "size": 1020, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/M/Indexed.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/Indexed.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/Indexed.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.7209302326, "max_line_length": 72, "alphanum_fraction": 0.4911764706, "num_tokens": 335, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278757303677, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.5840991913485646}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Instance.Monoidals where\n\nopen import Level\n\nopen import Categories.Category\nopen import Categories.Category.Helper\nopen import Categories.Category.Monoidal\nopen import Categories.Functor.Monoidal\nopen import Categories.Functor.Monoidal.Properties\nopen import Categories.NaturalTransformation.NaturalIsomorphism.Monoidal\n\nmodule _ o ℓ e where\n\n Monoidals : Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)\n Monoidals = categoryHelper record\n { Obj = MonoidalCategory o ℓ e\n ; _⇒_ = MonoidalFunctor\n ; _≈_ = Lax._≃_\n ; id = idF-Monoidal _\n ; _∘_ = ∘-Monoidal\n -- NOTE: these η-expanded versions typecheck much faster...\n ; assoc = λ {_ _ _ _ F G H} → associator {F = F} {G} {H}\n ; identityˡ = λ {_ _ F} → unitorˡ {F = F}\n ; identityʳ = λ {_ _ F} → unitorʳ {F = F}\n ; equiv = isEquivalence\n ; ∘-resp-≈ = _ⓘₕ_\n }\n where open Lax\n\n StrongMonoidals : Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)\n StrongMonoidals = categoryHelper record\n { Obj = MonoidalCategory o ℓ e\n ; _⇒_ = StrongMonoidalFunctor\n ; _≈_ = Strong._≃_\n ; id = idF-StrongMonoidal _\n ; _∘_ = ∘-StrongMonoidal\n -- NOTE: these η-expanded versions typecheck much faster...\n ; assoc = λ {_ _ _ _ F G H} → associator {F = F} {G} {H}\n ; identityˡ = λ {_ _ F} → unitorˡ {F = F}\n ; identityʳ = λ {_ _ F} → unitorʳ {F = F}\n ; equiv = isEquivalence\n ; ∘-resp-≈ = _ⓘₕ_\n }\n where open Strong\n", "meta": {"hexsha": "4d624704f10bc909a879a4fe3feb502b4354bd89", "size": 1574, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/Monoidals.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/Monoidals.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/Monoidals.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.4893617021, "max_line_length": 72, "alphanum_fraction": 0.5959339263, "num_tokens": 547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278757303677, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.5840991913485645}} {"text": "{-# OPTIONS --cubical #-}\nmodule ExerciseSession2 where\n\nopen import Part1\nopen import Part2\nopen import Part3\nopen import Part4\n\n\n -- (* Construct a point if isContr A → Π (x y : A) . isContr (x = y) *)\n\n\n\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\nfoo : isProp A → isProp' A\nfoo h = λ x y → (h x y) , λ q → isProp→isSet h _ _ (h x y) q\n\n\n\n-- hProp : {ℓ : Level} → Type (ℓ-suc ℓ)\n-- hProp {ℓ = ℓ} = Σ[ A ∈ Type ℓ ] isProp A\n\n-- foo : isContr (Σ[ A ∈ hProp {ℓ = ℓ} ] (fst A))\n-- foo = ({!!} , {!!}) , {!!}\n\n\n\n\n\n-- Σ≡Prop : ((x : A) → isProp (B x)) → {u v : Σ A B}\n-- → (p : u .fst ≡ v .fst) → u ≡ v\n\n\n", "meta": {"hexsha": "78f24122620a4b7629d428105cdc596b322c7530", "size": 797, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession2.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/ExerciseSession2.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/ExerciseSession2.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": 19.925, "max_line_length": 75, "alphanum_fraction": 0.4579673777, "num_tokens": 333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110368115783, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.5840423473094973}} {"text": "{-# OPTIONS --with-K -vtc.lhs.unify:50 #-}\n\nopen import Agda.Primitive using (Setω)\nopen import Agda.Builtin.Equality using (_≡_; refl)\n\n-- change `Set` to `Setω` breaks `seq`\ndata RecD (I : Set) : Setω where\n ι : (i : I) → RecD I\n\ndata RecO {I J : Set} (e : I → J) : RecD I → RecD J → Setω where\n ι : (i : I) (j : J) (eq : e i ≡ j) → RecO e (ι i) (ι j)\n\nseq : {I J K : Set} {e : I → J} {f : J → K} {D : RecD I} {E : RecD J} {F : RecD K}\n → RecO f E F → RecO e D E\n → RecO (λ i → f (e i)) D F\nseq (ι _ _ refl) (ι _ _ refl) = ι _ _ refl\n", "meta": {"hexsha": "42e960d20f5c17ff3559bff442880ffa6028344c", "size": 548, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue5730.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/Issue5730.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/Issue5730.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": 32.2352941176, "max_line_length": 82, "alphanum_fraction": 0.5218978102, "num_tokens": 242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110454379297, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.5840423469520097}} {"text": "{-# OPTIONS --type-in-type #-}\nmodule chu.lens where\nopen import prelude\nopen import functors\nopen import chu\nopen import poly.core\n\n→∫ : Chu → ∫\n→∫ (A⁺ , A⁻ ! Ω) = A⁺ , λ a⁺ → ∃ (Ω a⁺)\n \n→Lens : {A B : Chu} → Chu[ A , B ] → ∫[ →∫ A , →∫ B ]\n→Lens (f ↔ fᵗ ! †) a⁺ = f a⁺ , λ (b⁻ , fa⁺Ωb⁻) → fᵗ b⁻ , subst id († a⁺ b⁻) fa⁺Ωb⁻\n\nmodule _ {A B C : Chu}\n (F@(f ↔ fᵗ ! _†₁_) : Chu[ A , B ])\n (G@(g ↔ gᵗ ! _†₂_) : Chu[ B , C ]) where\n\n comp₂ : ∀ a⁺ → π₂ (→Lens (F ▸ G) a⁺)\n ≡ π₂ ((→Lens F ▸ →Lens G) a⁺)\n comp₂ a⁺ = extensionality λ ( c⁻ , gfaΩc ) → (λ x → (fᵗ ∘ gᵗ) c⁻ , x) ⟨$⟩\n subst⋯ id (f a⁺ †₂ c⁻) (a⁺ †₁ gᵗ c⁻) gfaΩc\n\n comp∀ : ∀ a⁺ → →Lens (F ▸ G) a⁺ ≡ (→Lens F ▸ →Lens G) a⁺\n comp∀ a⁺ rewrite comp₂ a⁺ = refl\n\ninstance\n open Chu[_,_]\n chu-lens-functor : Functor →∫\n chu-lens-functor = φ: →Lens\n 𝒾: refl\n ▸: λ F G → extensionality (comp∀ F G)\n", "meta": {"hexsha": "fc92d74ef479febe9a9b7b0c3b5d4a2a435eafe8", "size": 967, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "code-examples/agda/chu/lens.agda", "max_stars_repo_name": "mstone/poly", "max_stars_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 53, "max_stars_repo_stars_event_min_datetime": "2021-02-18T16:31:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:08:27.000Z", "max_issues_repo_path": "code-examples/agda/chu/lens.agda", "max_issues_repo_name": "dspivak/poly", "max_issues_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-09-02T02:29:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-12T10:06:32.000Z", "max_forks_repo_path": "code-examples/agda/chu/lens.agda", "max_forks_repo_name": "dspivak/poly", "max_forks_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-07-10T17:19:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T11:45:57.000Z", "avg_line_length": 30.21875, "max_line_length": 83, "alphanum_fraction": 0.430196484, "num_tokens": 473, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110454379297, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.5840423469520097}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\n\nmodule Data.FingerTree.Measures\n {r m}\n (ℳ : Monoid r m)\n where\n\nopen import Level using (_⊔_)\n\nopen Monoid ℳ renaming (Carrier to 𝓡)\nopen import Data.List as List using (List; _∷_; [])\nopen import Data.Product\nopen import Function\n\n-- | A measure.\nrecord σ {a} (Σ : Set a) : Set (a ⊔ r) where field μ : Σ → 𝓡\nopen σ ⦃ ... ⦄\n{-# DISPLAY σ.μ _ = μ #-}\n\ninstance\n σ-List : ∀ {a} {Σ : Set a} → ⦃ _ : σ Σ ⦄ → σ (List Σ)\n μ ⦃ σ-List ⦄ = List.foldr (_∙_ ∘ μ) ε\n\n\n-- A \"fiber\" (I think) from the μ function.\n--\n-- μ⟨ Σ ⟩≈ 𝓂 means \"There exists a Σ such that μ Σ ≈ 𝓂\"\ninfixl 2 _⇑[_]\nrecord μ⟨_⟩≈_ {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ (𝓂 : 𝓡) : Set (a ⊔ r ⊔ m) where\n constructor _⇑[_]\n field\n 𝓢 : Σ\n .𝒻 : μ 𝓢 ≈ 𝓂\nopen μ⟨_⟩≈_ public\n\n-- Construct a measured value without any transformations of the measure.\ninfixl 2 _⇑\n_⇑ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ (𝓢 : Σ) → μ⟨ Σ ⟩≈ μ 𝓢\n𝓢 (x ⇑) = x\n𝒻 (x ⇑) = refl\n{-# INLINE _⇑ #-}\n\n-- These combinators allow for a kind of easoning syntax over the measures.\n-- The first is used like so:\n--\n-- xs ≈[ assoc _ _ _ ]\n--\n-- Which will have the type:\n--\n-- μ⟨ Σ ⟩≈ x ∙ y ∙ z → μ⟨ Σ ⟩≈ (x ∙ y) ∙ z\n--\n-- The second does the same:\n--\n-- xs ≈[ assoc _ _ _ ]′\n--\n-- However, when used in a chain, it typechecks after the ones used to its\n-- left. This means you can call the solver on the left.\n--\n-- xs ≈[ ℳ ↯ ] ≈[ assoc _ _ _ ]′\ninfixl 2 _≈[_] ≈-rev\n_≈[_] : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ {x : 𝓡} → μ⟨ Σ ⟩≈ x → ∀ {y} → .(x ≈ y) → μ⟨ Σ ⟩≈ y\n𝓢 (xs ≈[ y≈z ]) = 𝓢 xs\n𝒻 (xs ≈[ y≈z ]) = trans (𝒻 xs) y≈z\n{-# INLINE _≈[_] #-}\n\n≈-rev : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ {x : 𝓡} → ∀ {y} → .(x ≈ y) → μ⟨ Σ ⟩≈ x → μ⟨ Σ ⟩≈ y\n𝓢 (≈-rev y≈z xs) = 𝓢 xs\n𝒻 (≈-rev y≈z xs) = trans (𝒻 xs) y≈z\n{-# INLINE ≈-rev #-}\n\nsyntax ≈-rev y≈z x↦y = x↦y ≈[ y≈z ]′\n\ninfixr 2 ≈-right\n≈-right : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ {x : 𝓡} → μ⟨ Σ ⟩≈ x → ∀ {y} → .(x ≈ y) → μ⟨ Σ ⟩≈ y\n≈-right (x ⇑[ x≈y ]) y≈z = x ⇑[ trans x≈y y≈z ]\n\nsyntax ≈-right x x≈ = [ x≈ ]≈ x\n\ninfixr 1 _↤_\n-- A memoized application of μ\nrecord ⟪_⟫ {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ : Set (a ⊔ r ⊔ m) where\n constructor _↤_\n field\n 𝔐 : 𝓡\n 𝓕 : μ⟨ Σ ⟩≈ 𝔐\nopen ⟪_⟫ public\n\n-- Construct the memoized version\n⟪_⇓⟫ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → Σ → ⟪ Σ ⟫\n𝔐 ⟪ x ⇓⟫ = μ x\n𝓕 ⟪ x ⇓⟫ = x ⇑\n\ninstance\n σ-⟪⟫ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → σ ⟪ Σ ⟫\n μ ⦃ σ-⟪⟫ ⦄ = 𝔐\n\nopen import Algebra.FunctionProperties _≈_\n\n-- This section allows us to use the do-notation to clean up proofs.\n-- First, we construct arguments:\ninfixl 2 arg-syntax\nrecord Arg {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ (𝓂 : 𝓡) (f : 𝓡 → 𝓡) : Set (m ⊔ r ⊔ a) where\n constructor arg-syntax\n field\n .⟨f⟩ : Congruent₁ f\n arg : μ⟨ Σ ⟩≈ 𝓂\nopen Arg\n\nsyntax arg-syntax (λ sz → e₁) xs = xs [ e₁ ⟿ sz ]\n-- This syntax is meant to be used like so:\n--\n-- do x ← xs [ a ∙> (s <∙ b) ⟿ s ]\n--\n-- And it means \"the size of the variable I'm binding here will be stored in this\n-- part of the expression\". See, for example, the listToTree function:\n--\n-- listToTree [] = empty ⇑\n-- listToTree (x ∷ xs) = [ ℳ ↯ ]≈ do\n-- ys ← listToTree xs [ μ x ∙> s ⟿ s ]\n-- x ◂ ys\n--\ninfixl 1 _>>=_\n_>>=_ : ∀ {a b} {Σ₁ : Set a} {Σ₂ : Set b} ⦃ _ : σ Σ₁ ⦄ ⦃ _ : σ Σ₂ ⦄ {𝓂 f}\n → Arg Σ₁ 𝓂 f\n → ((x : Σ₁) → .⦃ x≈ : μ x ≈ 𝓂 ⦄ → μ⟨ Σ₂ ⟩≈ f (μ x))\n → μ⟨ Σ₂ ⟩≈ f 𝓂\narg-syntax cng xs >>= k = k (𝓢 xs) ⦃ 𝒻 xs ⦄ ≈[ cng (𝒻 xs) ]\n{-# INLINE _>>=_ #-}\n\n-- Inside the lambda generated by do notation, we can only pass one argument.\n-- So, to provide the proof (if needed)\n_≈?_ : ∀ x y → ⦃ x≈y : x ≈ y ⦄ → x ≈ y\n_≈?_ _ _ ⦃ x≈y ⦄ = x≈y\n", "meta": {"hexsha": "74d6e55a02865afce8f7faeb530945d13d2b82ce", "size": 3587, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/FingerTree/Measures.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/Measures.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/Measures.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.375, "max_line_length": 90, "alphanum_fraction": 0.5098968497, "num_tokens": 1831, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812552, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.5839788273237824}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Reflection utilities for Fin\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Fin.Reflection where\n\nopen import Data.Nat.Base as ℕ hiding (module ℕ)\nopen import Data.Fin.Base as Fin hiding (module Fin)\nopen import Data.List.Base\nopen import Reflection.Term\nopen import Reflection.Argument\n\n------------------------------------------------------------------------\n-- Term\n\ntoTerm : ∀ {n} → Fin n → Term\ntoTerm zero = con (quote Fin.zero) (1 ⋯⟅∷⟆ [])\ntoTerm (suc i) = con (quote Fin.suc) (1 ⋯⟅∷⟆ toTerm i ⟨∷⟩ [])\n", "meta": {"hexsha": "d9c70fe0a6ef70097d686f3610709d739f559bc4", "size": 696, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Fin/Reflection.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/Reflection.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/Reflection.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.2608695652, "max_line_length": 72, "alphanum_fraction": 0.4640804598, "num_tokens": 151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.5839544314968148}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Pi0Examples where\n\nopen import PiU using (U; ZERO; ONE; PLUS; TIMES)\nopen import PiLevel0\n using (_⟷_;\n unite₊l; uniti₊l; unite₊r; uniti₊r; swap₊; assocl₊; assocr₊;\n unite⋆l; uniti⋆l; unite⋆r; uniti⋆r; swap⋆; assocl⋆; assocr⋆;\n absorbr; absorbl; factorzr; factorzl;\n dist; factor; distl; factorl;\n id⟷; _◎_; _⊕_; _⊗_)\n\n------------------------------------------------------------------------------\n-- Example circuits on booleans\n\nBOOL : U\nBOOL = PLUS ONE ONE\n\nBOOL² : U\nBOOL² = TIMES BOOL BOOL\n\n-- Nicer syntax that shows intermediate values instead of the above\n-- point-free notation of permutations\n\ninfixr 2 _⟷⟨_⟩_\ninfix 3 _□\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\nfoldBool unfoldBool : BOOL ⟷ BOOL\nfoldBool = id⟷\nunfoldBool = id⟷\n\n------------------------------------------------------------------------------\n-- Many ways of negating a BOOL.\n\nNOT : BOOL ⟷ BOOL\nNOT = unfoldBool ◎ swap₊ ◎ foldBool\n-- spec: (false , true) ∷ (true , false) ∷ []\n\nNEG1 NEG2 NEG3 NEG4 NEG5 : BOOL ⟷ BOOL\nNEG1 = unfoldBool ◎ swap₊ ◎ foldBool\n-- spec: (false , true) ∷ (true , false) ∷ []\nNEG2 = id⟷ ◎ NOT\n-- spec: (false , true) ∷ (true , false) ∷ []\nNEG3 = NOT ◎ NOT ◎ NOT\n-- spec: (false , true) ∷ (true , false) ∷ []\nNEG4 = NOT ◎ id⟷\n-- spec: (false , true) ∷ (true , false) ∷ []\nNEG5 = uniti⋆l ◎ swap⋆ ◎ (NOT ⊗ id⟷) ◎ swap⋆ ◎ unite⋆l\n-- spec: (false , true) ∷ (true , false) ∷ []\nNEG6 = uniti⋆r ◎ (NOT ⊗ id⟷) ◎ unite⋆r -- same as above, but shorter\n\n-- CNOT\n\nCNOT : BOOL² ⟷ BOOL²\nCNOT = TIMES BOOL BOOL\n ⟷⟨ unfoldBool ⊗ id⟷ ⟩\n TIMES (PLUS x y) BOOL\n ⟷⟨ dist ⟩\n PLUS (TIMES x BOOL) (TIMES y BOOL)\n ⟷⟨ id⟷ ⊕ (id⟷ ⊗ NOT) ⟩\n PLUS (TIMES x BOOL) (TIMES y BOOL)\n ⟷⟨ factor ⟩\n TIMES (PLUS x y) BOOL\n ⟷⟨ foldBool ⊗ id⟷ ⟩\n TIMES BOOL BOOL □\n where x = ONE; y = ONE\n\n-- spec:\n-- ((false , false) , false , false) ∷\n-- ((false , true) , false , true) ∷\n-- ((true , false) , true , true) ∷\n-- ((true , true) , true , false) ∷ []\n\n-- TOFFOLI\n\nTOFFOLI : TIMES BOOL BOOL² ⟷ TIMES BOOL BOOL²\nTOFFOLI = TIMES BOOL BOOL²\n ⟷⟨ unfoldBool ⊗ id⟷ ⟩\n 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 ⟷⟨ foldBool ⊗ id⟷ ⟩\n TIMES BOOL BOOL² □\n where x = ONE; y = ONE\n\n-- spec:\n-- ((false , false , false) , false , false , false) ∷\n-- ((false , false , true) , false , false , true) ∷\n-- ((false , true , false) , false , true , false) ∷\n-- ((false , true , true) , false , true , true) ∷\n-- ((true , false , false) , true , false , false) ∷\n-- ((true , false , true) , true , false , true) ∷\n-- ((true , true , false) , true , true , true) ∷\n-- ((true , true , true) , true , true , false) ∷ []\n\n-- Swaps for the type 1+(1+1)\n-- We have three values in the type 1+(1+1)\n-- Let's call them a, b, and c\n-- There 6 permutations. Using the swaps below we can express every permutation:\n-- a b c id⟷\n-- a c b SWAP23\n-- b a c SWAP12\n-- b c a ROTL\n-- c a b ROTR\n-- c b a SWAP13\n\nSWAP12 SWAP23 SWAP13 ROTL ROTR :\n PLUS ONE (PLUS ONE ONE) ⟷ PLUS ONE (PLUS ONE ONE)\nSWAP12 = assocl₊ ◎ (swap₊ ⊕ id⟷) ◎ assocr₊\n-- spec:\n-- (inj₁ tt , inj₂ (inj₁ tt)) ∷\n-- (inj₂ (inj₁ tt) , inj₁ tt) ∷\n-- (inj₂ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ []\nSWAP23 = id⟷ ⊕ swap₊\n-- spec:\n-- (inj₁ tt , inj₁ tt) ∷\n-- (inj₂ (inj₁ tt) , inj₂ (inj₂ tt)) ∷\n-- (inj₂ (inj₂ tt) , inj₂ (inj₁ tt)) ∷ []\nSWAP13 = SWAP23 ◎ SWAP12 ◎ SWAP23\n-- spec:\n-- (inj₁ tt , inj₂ (inj₂ tt)) ∷\n-- (inj₂ (inj₁ tt) , inj₂ (inj₁ tt)) ∷\n-- (inj₂ (inj₂ tt) , inj₁ tt) ∷ []\nROTR = SWAP12 ◎ SWAP23\n-- spec:\n-- (inj₁ tt , inj₂ (inj₂ tt)) ∷\n-- (inj₂ (inj₁ tt) , inj₁ tt) ∷\n-- (inj₂ (inj₂ tt) , inj₂ (inj₁ tt)) ∷ []\nROTL = SWAP13 ◎ SWAP23\n-- spec:\n-- (inj₁ tt , inj₂ (inj₁ tt)) ∷\n-- (inj₂ (inj₁ tt) , inj₂ (inj₂ tt)) ∷\n-- (inj₂ (inj₂ tt) , inj₁ tt) ∷ []\n\n-- The Peres gate is a universal gate: it takes three inputs a, b, and c, and\n-- produces a, a xor b, (a and b) xor c\n\nPERES : TIMES (TIMES BOOL BOOL) BOOL ⟷ TIMES (TIMES BOOL BOOL) BOOL\nPERES = (id⟷ ⊗ NOT) ◎ assocr⋆ ◎ (id⟷ ⊗ swap⋆) ◎\n TOFFOLI ◎\n (id⟷ ⊗ (NOT ⊗ id⟷)) ◎\n TOFFOLI ◎\n (id⟷ ⊗ swap⋆) ◎ (id⟷ ⊗ (NOT ⊗ id⟷)) ◎\n TOFFOLI ◎\n (id⟷ ⊗ (NOT ⊗ id⟷)) ◎ assocl⋆\n-- spec:\n-- (((false , false) , false) , (false , false) , false) ∷\n-- (((false , false) , true) , (false , false) , true) ∷\n-- (((false , true) , false) , (false , true) , false) ∷\n-- (((false , true) , true) , (false , true) , true) ∷\n-- (((true , false) , false) , (true , true) , false) ∷\n-- (((true , false) , true) , (true , true) , true) ∷\n-- (((true , true) , false) , (true , false) , true) ∷\n-- (((true , true) , true) , (true , false) , false) ∷ []\n\n-- A reversible full adder: See http://arxiv.org/pdf/1008.3533.pdf\n-- Input: (z, ((n1, n2), cin)))\n-- Output (g1, (g2, (sum, cout)))\n-- where sum = n1 xor n2 xor cin\n-- and cout = ((n1 xor n2) and cin) xor (n1 and n2) xor z\nFULLADDER : TIMES BOOL (TIMES (TIMES BOOL BOOL) BOOL) ⟷\n TIMES BOOL (TIMES BOOL (TIMES BOOL BOOL))\nFULLADDER =\n -- (z,((n1,n2),cin))\n swap⋆ ◎\n -- (((n1,n2),cin),z)\n (swap⋆ ⊗ id⟷) ◎\n -- ((cin,(n1,n2)),z)\n assocr⋆ ◎\n -- (cin,((n1,n2),z))\n swap⋆ ◎\n -- (((n1,n2),z),cin)\n (PERES ⊗ id⟷) ◎\n -- (((n1,n1 xor n2),(n1 and n2) xor z),cin)\n assocr⋆ ◎\n -- ((n1,n1 xor n2),((n1 and n2) xor z,cin))\n (id⟷ ⊗ swap⋆) ◎\n -- ((n1,n1 xor n2),(cin,(n1 and n2) xor z))\n assocr⋆ ◎\n -- (n1,(n1 xor n2,(cin,(n1 and n2) xor z)))\n (id⟷ ⊗ assocl⋆) ◎\n -- (n1,((n1 xor n2,cin),(n1 and n2) xor z))\n (id⟷ ⊗ PERES) ◎\n -- (n1,((n1 xor n2,n1 xor n2 xor cin),\n -- ((n1 xor n2) and cin) xor (n1 and n2) xor z))\n (id⟷ ⊗ assocr⋆)\n -- (n1,(n1 xor n2,\n -- (n1 xor n2 xor cin,((n1 xor n2) and cin) xor (n1 and n2) xor z)))\n-- spec:\n-- ((false , (false , false) , false) , false , false , false , false) ∷\n-- ((false , (false , false) , true) , false , false , true , false) ∷\n-- ((false , (false , true) , false) , false , true , true , false) ∷\n-- ((false , (false , true) , true) , false , true , false , true) ∷\n-- ((false , (true , false) , false) , true , true , true , false) ∷\n-- ((false , (true , false) , true) , true , true , false , true) ∷\n-- ((false , (true , true) , false) , true , false , false , true) ∷\n-- ((false , (true , true) , true) , true , false , true , true) ∷\n-- ((true , (false , false) , false) , false , false , false , true) ∷\n-- ((true , (false , false) , true) , false , false , true , true) ∷\n-- ((true , (false , true) , false) , false , true , true , true) ∷\n-- ((true , (false , true) , true) , false , true , false , false) ∷\n-- ((true , (true , false) , false) , true , true , true , true) ∷\n-- ((true , (true , false) , true) , true , true , false , false) ∷\n-- ((true , (true , true) , false) , true , false , false , false) ∷\n-- ((true , (true , true) , true) , true , false , true , false) ∷ []\n\n------------------------------------------------------------------------------\n-- Generalized CNOT and TOFFOLI\n\nttt : {t₁ t₂ t₃ t₄ : U} →\n (TIMES (PLUS t₁ t₂) (PLUS t₃ t₄)) ⟷\n (PLUS (PLUS (PLUS (TIMES t₁ t₃) (TIMES t₂ t₃)) (TIMES t₁ t₄))) (TIMES t₂ t₄)\nttt {t₁} {t₂} {t₃} {t₄} =\n (distl ◎ (dist {t₁} {t₂} {t₃} ⊕ dist {t₁} {t₂} {t₄})) ◎ assocl₊\n\n-- generalized CNOT\n\ngcnot : {A B C : U} →\n (TIMES (PLUS A B) (PLUS C C)) ⟷ (TIMES (PLUS A B) (PLUS C C))\ngcnot = dist ◎ (id⟷ ⊕ (id⟷ ⊗ swap₊)) ◎ factor\n\n-- Generalized Toffolli gate. See what 'arithmetic' it performs.\n\nGToffoli : {A B C D E : U} →\n TIMES (PLUS A B) (TIMES (PLUS C D) (PLUS E E)) ⟷\n TIMES (PLUS A B) (TIMES (PLUS C D) (PLUS E E))\nGToffoli = dist ◎ (id⟷ ⊕ (id⟷ ⊗ gcnot)) ◎ factor\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "a97cc6c9524805076f0809ba11847b8e4ebcafb9", "size": 8202, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/Pi0Examples.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/Pi0Examples.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/Pi0Examples.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.8925619835, "max_line_length": 80, "alphanum_fraction": 0.4940258474, "num_tokens": 3449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933315126792, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.5839544283623829}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Solver for monoid equalities\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\n\nmodule Algebra.Solver.Monoid {m₁ m₂} (M : Monoid m₁ m₂) where\n\nopen import Data.Fin as Fin hiding (_≟_)\nimport Data.Fin.Properties as Fin\nopen import Data.List.Base hiding (lookup)\nimport Data.List.Relation.Binary.Equality.DecPropositional as ListEq\nopen import Data.Maybe as Maybe\n using (Maybe; decToMaybe; From-just; from-just)\nopen import Data.Nat.Base using (ℕ)\nopen import Data.Product\nopen import Data.Vec using (Vec; lookup)\nopen import Function using (_∘_; _$_)\nopen import Relation.Binary using (Decidable)\n\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\nimport Relation.Binary.Reflection\nopen import Relation.Nullary\nimport Relation.Nullary.Decidable as Dec\n\nopen Monoid M\nopen import Relation.Binary.Reasoning.Setoid setoid\n\n------------------------------------------------------------------------\n-- Monoid expressions\n\n-- There is one constructor for every operation, plus one for\n-- variables; there may be at most n variables.\n\ninfixr 5 _⊕_\n\ndata Expr (n : ℕ) : Set where\n var : Fin n → Expr n\n id : Expr n\n _⊕_ : Expr n → Expr n → Expr n\n\n-- An environment contains one value for every variable.\n\nEnv : ℕ → Set _\nEnv n = Vec Carrier n\n\n-- The semantics of an expression is a function from an environment to\n-- a value.\n\n⟦_⟧ : ∀ {n} → Expr n → Env n → Carrier\n⟦ var x ⟧ ρ = lookup ρ x\n⟦ id ⟧ ρ = ε\n⟦ e₁ ⊕ e₂ ⟧ ρ = ⟦ e₁ ⟧ ρ ∙ ⟦ e₂ ⟧ ρ\n\n------------------------------------------------------------------------\n-- Normal forms\n\n-- A normal form is a list of variables.\n\nNormal : ℕ → Set\nNormal n = List (Fin n)\n\n-- The semantics of a normal form.\n\n⟦_⟧⇓ : ∀ {n} → Normal n → Env n → Carrier\n⟦ [] ⟧⇓ ρ = ε\n⟦ x ∷ nf ⟧⇓ ρ = lookup ρ x ∙ ⟦ nf ⟧⇓ ρ\n\n-- A normaliser.\n\nnormalise : ∀ {n} → Expr n → Normal n\nnormalise (var x) = x ∷ []\nnormalise id = []\nnormalise (e₁ ⊕ e₂) = normalise e₁ ++ normalise e₂\n\n-- The normaliser is homomorphic with respect to _++_/_∙_.\n\nhomomorphic : ∀ {n} (nf₁ nf₂ : Normal n) (ρ : Env n) →\n ⟦ nf₁ ++ nf₂ ⟧⇓ ρ ≈ (⟦ nf₁ ⟧⇓ ρ ∙ ⟦ nf₂ ⟧⇓ ρ)\nhomomorphic [] nf₂ ρ = begin\n ⟦ nf₂ ⟧⇓ ρ ≈⟨ sym $ identityˡ _ ⟩\n ε ∙ ⟦ nf₂ ⟧⇓ ρ ∎\nhomomorphic (x ∷ nf₁) nf₂ ρ = begin\n lookup ρ x ∙ ⟦ nf₁ ++ nf₂ ⟧⇓ ρ ≈⟨ ∙-congˡ (homomorphic nf₁ nf₂ ρ) ⟩\n lookup ρ x ∙ (⟦ nf₁ ⟧⇓ ρ ∙ ⟦ nf₂ ⟧⇓ ρ) ≈⟨ sym $ assoc _ _ _ ⟩\n lookup ρ x ∙ ⟦ nf₁ ⟧⇓ ρ ∙ ⟦ nf₂ ⟧⇓ ρ ∎\n\n-- The normaliser preserves the semantics of the expression.\n\nnormalise-correct :\n ∀ {n} (e : Expr n) (ρ : Env n) → ⟦ normalise e ⟧⇓ ρ ≈ ⟦ e ⟧ ρ\nnormalise-correct (var x) ρ = begin\n lookup ρ x ∙ ε ≈⟨ identityʳ _ ⟩\n lookup ρ x ∎\nnormalise-correct id ρ = begin\n ε ∎\nnormalise-correct (e₁ ⊕ e₂) ρ = begin\n ⟦ normalise e₁ ++ normalise e₂ ⟧⇓ ρ ≈⟨ homomorphic (normalise e₁) (normalise e₂) ρ ⟩\n ⟦ normalise e₁ ⟧⇓ ρ ∙ ⟦ normalise e₂ ⟧⇓ ρ ≈⟨ ∙-cong (normalise-correct e₁ ρ) (normalise-correct e₂ ρ) ⟩\n ⟦ e₁ ⟧ ρ ∙ ⟦ e₂ ⟧ ρ ∎\n\n------------------------------------------------------------------------\n-- \"Tactics\"\n\nopen module R = Relation.Binary.Reflection\n setoid var ⟦_⟧ (⟦_⟧⇓ ∘ normalise) normalise-correct\n public using (solve; _⊜_)\n\n-- We can decide if two normal forms are /syntactically/ equal.\n\ninfix 5 _≟_\n\n_≟_ : ∀ {n} → Decidable {A = Normal n} _≡_\nnf₁ ≟ nf₂ = Dec.map′ ≋⇒≡ ≡⇒≋ (nf₁ ≋? nf₂)\n where open ListEq Fin._≟_\n\n-- We can also give a sound, but not necessarily complete, procedure\n-- for determining if two expressions have the same semantics.\n\nprove′ : ∀ {n} (e₁ e₂ : Expr n) → Maybe (∀ ρ → ⟦ e₁ ⟧ ρ ≈ ⟦ e₂ ⟧ ρ)\nprove′ e₁ e₂ =\n Maybe.map lemma $ decToMaybe (normalise e₁ ≟ normalise e₂)\n where\n lemma : normalise e₁ ≡ normalise e₂ → ∀ ρ → ⟦ e₁ ⟧ ρ ≈ ⟦ e₂ ⟧ ρ\n lemma eq ρ =\n R.prove ρ e₁ e₂ (begin\n ⟦ normalise e₁ ⟧⇓ ρ ≡⟨ P.cong (λ e → ⟦ e ⟧⇓ ρ) eq ⟩\n ⟦ normalise e₂ ⟧⇓ ρ ∎)\n\n-- This procedure can be combined with from-just.\n\nprove : ∀ n (es : Expr n × Expr n) →\n From-just (uncurry prove′ es)\nprove _ = from-just ∘ uncurry prove′\n", "meta": {"hexsha": "266add0fe6419395aff1794fe89820518e7b48b2", "size": 4242, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Solver/Monoid.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/Solver/Monoid.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/Solver/Monoid.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.5179856115, "max_line_length": 106, "alphanum_fraction": 0.5662423385, "num_tokens": 1541, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933315126792, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.5839544133381422}} {"text": "module Data.Num.Next where\n\nopen import Data.Num.Core\nopen import Data.Num.Maximum\nopen import Data.Num.Bounded\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-- next-numeral: NullBase\n--------------------------------------------------------------------------------\n\nnext-numeral-NullBase : ∀ {d o}\n → (xs : Numeral 0 (suc d) o)\n → ¬ (Maximum xs)\n → Numeral 0 (suc d) o\nnext-numeral-NullBase xs ¬max with Greatest? (lsd xs)\nnext-numeral-NullBase xs ¬max | yes greatest =\n contradiction (Maximum-NullBase-Greatest xs greatest) ¬max\nnext-numeral-NullBase (x ∙) ¬max | no ¬greatest = digit+1 x ¬greatest ∙\nnext-numeral-NullBase (x ∷ xs) ¬max | no ¬greatest = digit+1 x ¬greatest ∷ xs\n\nnext-numeral-NullBase-lemma : ∀ {d o}\n → (xs : Numeral 0 (suc d) o)\n → (¬max : ¬ (Maximum xs))\n → ⟦ next-numeral-NullBase xs ¬max ⟧ ≡ suc ⟦ xs ⟧\nnext-numeral-NullBase-lemma {d} {o} xs ¬max with Greatest? (lsd xs)\nnext-numeral-NullBase-lemma {d} {o} xs ¬max | yes greatest =\n contradiction (Maximum-NullBase-Greatest xs greatest) ¬max\nnext-numeral-NullBase-lemma {d} {o} (x ∙) ¬max | no ¬greatest =\n begin\n Digit-toℕ (digit+1 x ¬greatest) o\n ≡⟨ digit+1-toℕ x ¬greatest ⟩\n suc (Fin.toℕ x + o)\n ∎\nnext-numeral-NullBase-lemma {d} {o} (x ∷ xs) ¬max | no ¬greatest =\n begin\n ⟦ digit+1 x ¬greatest ∷ xs ⟧\n ≡⟨ refl ⟩\n Digit-toℕ (digit+1 x ¬greatest) o + ⟦ xs ⟧ * zero\n ≡⟨ cong (λ w → w + ⟦ xs ⟧ * zero) (digit+1-toℕ x ¬greatest) ⟩\n suc (Fin.toℕ x + o + ⟦ xs ⟧ * zero)\n ≡⟨ refl ⟩\n suc ⟦ x ∷ xs ⟧\n ∎\n\nnext-numeral-is-greater-NullBase : ∀ {d o}\n → (xs : Numeral 0 (suc d) o)\n → (¬max : ¬ (Maximum xs))\n → ⟦ next-numeral-NullBase xs ¬max ⟧ > ⟦ xs ⟧\nnext-numeral-is-greater-NullBase xs ¬max =\n start\n suc ⟦ xs ⟧\n ≈⟨ sym (next-numeral-NullBase-lemma xs ¬max) ⟩\n ⟦ next-numeral-NullBase xs ¬max ⟧\n □\n\nnext-numeral-is-immediate-NullBase : ∀ {d o}\n → (xs : Numeral 0 (suc d) o)\n → (ys : Numeral 0 (suc d) o)\n → (¬max : ¬ (Maximum xs))\n → ⟦ ys ⟧ > ⟦ xs ⟧\n → ⟦ ys ⟧ ≥ ⟦ next-numeral-NullBase xs ¬max ⟧\nnext-numeral-is-immediate-NullBase xs ys ¬max prop =\n start\n ⟦ next-numeral-NullBase xs ¬max ⟧\n ≈⟨ next-numeral-NullBase-lemma xs ¬max ⟩\n suc ⟦ xs ⟧\n ≤⟨ prop ⟩\n ⟦ ys ⟧\n □\n\n--------------------------------------------------------------------------------\n-- next-numeral: Proper\n--------------------------------------------------------------------------------\n\n\nmutual\n Gapped#0 : ∀ b d o → Set\n Gapped#0 b d o = suc d < carry o * suc b\n\n Gapped#N : ∀ b d o\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → Set\n Gapped#N b d o xs proper = suc d < (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n where\n next-xs : Numeral (suc b) (suc d) o\n next-xs = next-numeral-Proper xs proper\n\n Gapped#0? : ∀ b d o → Dec (Gapped#0 b d o)\n Gapped#0? b d o = suc (suc d) ≤? carry o * suc b\n\n Gapped#N? : ∀ b d o\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → Dec (Gapped#N b d o xs proper)\n Gapped#N? b d o xs proper = suc (suc d) ≤? (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n where\n next-xs : Numeral (suc b) (suc d) o\n next-xs = next-numeral-Proper xs proper\n\n -- Gap#N\n Gapped : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → Set\n Gapped {b} {d} {o} (x ∙) proper = Gapped#0 b d o\n Gapped {b} {d} {o} (x ∷ xs) proper = Gapped#N b d o xs proper\n\n Gapped? : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → Dec (Gapped {b} {d} {o} xs proper)\n Gapped? {b} {d} {o} (x ∙) proper = Gapped#0? b d o\n Gapped? {b} {d} {o} (x ∷ xs) proper = Gapped#N? b d o xs proper\n\n data NextView : (b d o : ℕ) (xs : Numeral b d o) (proper : 2 ≤ d + o) → Set where\n Interval : ∀ b d o\n → {xs : Numeral (suc b) (suc d) o}\n → {proper : 2 ≤ suc (d + o)}\n → (¬greatest : ¬ (Greatest (lsd xs)))\n → NextView (suc b) (suc d) o xs proper\n GappedEndpoint : ∀ b d o\n → {xs : Numeral (suc b) (suc d) o}\n → {proper : 2 ≤ suc (d + o)}\n → (greatest : Greatest (lsd xs))\n → (gapped : Gapped xs proper)\n → NextView (suc b) (suc d) o xs proper\n UngappedEndpoint : ∀ b d o\n → {xs : Numeral (suc b) (suc d) o}\n → {proper : 2 ≤ suc (d + o)}\n → (greatest : Greatest (lsd xs))\n → (¬gapped : ¬ (Gapped xs proper))\n → NextView (suc b) (suc d) o xs proper\n\n nextView : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → NextView (suc b) (suc d) o xs proper\n nextView {b} {d} {o} xs proper with Greatest? (lsd xs)\n nextView {b} {d} {o} xs proper | yes greatest with Gapped? xs proper\n nextView {b} {d} {o} xs proper | yes greatest | yes gapped = GappedEndpoint b d o greatest gapped\n nextView {b} {d} {o} xs proper | yes greatest | no ¬gapped = UngappedEndpoint b d o greatest ¬gapped\n nextView {b} {d} {o} xs proper | no ¬greatest = Interval b d o ¬greatest\n\n next-numeral-Proper-Interval : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (¬greatest : ¬ (Greatest (lsd xs)))\n → (proper : 2 ≤ suc (d + o))\n → Numeral (suc b) (suc d) o\n next-numeral-Proper-Interval (x ∙) ¬greatest proper = digit+1 x ¬greatest ∙\n next-numeral-Proper-Interval (x ∷ xs) ¬greatest proper = digit+1 x ¬greatest ∷ xs\n\n next-numeral-Proper-GappedEndpoint : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → (gapped : Gapped xs proper)\n → Numeral (suc b) (suc d) o\n next-numeral-Proper-GappedEndpoint {b} {d} {o} (x ∙) proper gapped = z ∷ carry-digit d o proper ∙\n next-numeral-Proper-GappedEndpoint {b} {d} {o} (x ∷ xs) proper gapped = z ∷ next-numeral-Proper xs proper\n\n next-numeral-Proper-UngappedEndpoint : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (greatest : Greatest (lsd xs))\n → (proper : 2 ≤ suc (d + o))\n → (¬gapped : ¬ (Gapped xs proper))\n → Numeral (suc b) (suc d) o\n next-numeral-Proper-UngappedEndpoint {b} {d} {o} (x ∙) greatest proper gapped\n = digit+1-n x greatest (carry o * suc b) lower-bound ∷ carry-digit d o proper ∙\n where\n lower-bound : carry o * suc b > 0\n lower-bound =\n start\n 1\n ≤⟨ m≤m*1+n 1 b ⟩\n 1 * suc b\n ≤⟨ *n-mono (suc b) (m≤m⊔n 1 o) ⟩\n carry o * suc b\n □\n\n next-numeral-Proper-UngappedEndpoint {b} {d} {o} (x ∷ xs) greatest proper gapped\n = digit+1-n x greatest gap lower-bound ∷ next-xs\n where\n next-xs : Numeral (suc b) (suc d) o\n next-xs = next-numeral-Proper xs proper\n\n gap : ℕ\n gap = (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n\n lower-bound : gap > 0\n lower-bound =\n start\n 1\n ≤⟨ m≤m*1+n 1 b ⟩\n 1 * suc b\n ≤⟨ *n-mono (suc b) (m≥n+o⇒m∸o≥n ⟦ next-xs ⟧ 1 ⟦ xs ⟧ (next-numeral-is-greater-Proper xs proper)) ⟩\n (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n □\n\n\n next-numeral-Proper : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → Numeral (suc b) (suc d) o\n next-numeral-Proper xs proper with nextView xs proper\n next-numeral-Proper xs proper | Interval b d o ¬greatest\n = next-numeral-Proper-Interval xs ¬greatest proper\n next-numeral-Proper xs proper | GappedEndpoint b d o greatest gapped\n = next-numeral-Proper-GappedEndpoint xs proper gapped\n next-numeral-Proper xs proper | UngappedEndpoint b d o greatest ¬gapped\n = next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped\n\n next-numeral-Proper-Interval-lemma : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (¬greatest : ¬ (Greatest (lsd xs)))\n → (proper : 2 ≤ suc (d + o))\n → ⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧ ≡ suc ⟦ xs ⟧\n next-numeral-Proper-Interval-lemma {b} {d} {o} (x ∙) ¬greatest proper =\n -- ⟦ digit+1 x ¬greatest ∙ ⟧ ≡ suc ⟦ x ∙ ⟧\n begin\n Digit-toℕ (digit+1 x ¬greatest) o\n ≡⟨ digit+1-toℕ x ¬greatest ⟩\n suc (Digit-toℕ x o)\n ∎\n next-numeral-Proper-Interval-lemma {b} {d} {o} (x ∷ xs) ¬greatest proper =\n -- ⟦ digit+1 x ¬greatest ∷ xs ⟧ ≡ suc ⟦ x ∷ xs ⟧\n begin\n Digit-toℕ (digit+1 x ¬greatest) o + ⟦ xs ⟧ * suc b\n ≡⟨ cong (λ w → w + ⟦ xs ⟧ * suc b) (digit+1-toℕ x ¬greatest) ⟩\n suc (Digit-toℕ x o) + ⟦ xs ⟧ * suc b\n ∎\n\n next-numeral-Proper-GappedEndpoint-lemma : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (greatest : Greatest (lsd xs))\n → (proper : 2 ≤ suc (d + o))\n → (gapped : Gapped xs proper)\n → ⟦ next-numeral-Proper-GappedEndpoint xs proper gapped ⟧ > suc ⟦ xs ⟧\n next-numeral-Proper-GappedEndpoint-lemma {b} {d} {o} (x ∙) greatest proper gapped =\n -- ⟦ z ∷ carry-digit d o proper ∙ ⟧ > suc ⟦ x ∙ ⟧\n start\n suc (suc (Fin.toℕ x + o))\n ≈⟨ cong (λ w → suc w + o) greatest ⟩\n suc (suc d) + o\n ≈⟨ +-comm (suc (suc d)) o ⟩\n o + suc (suc d)\n ≤⟨ n+-mono o gapped ⟩\n o + carry o * suc b\n ≈⟨ cong (λ w → o + w * suc b) (sym (carry-digit-toℕ d o proper)) ⟩\n o + (Digit-toℕ (carry-digit d o proper) o) * suc b\n □\n next-numeral-Proper-GappedEndpoint-lemma {b} {d} {o} (x ∷ xs) greatest proper gapped\n = proof\n where\n next-xs : Numeral (suc b) (suc d) o\n next-xs = next-numeral-Proper xs proper\n\n next-xs>xs : ⟦ next-xs ⟧ > ⟦ xs ⟧\n next-xs>xs = next-numeral-is-greater-Proper xs proper\n\n next : Numeral (suc b) (suc d) o\n next = z ∷ next-xs\n\n -- ⟦ z ∷ next-numeral-Proper xs (Maximum-Proper xs proper) proper ⟧ > suc ⟦ x ∷ xs ⟧\n proof : ⟦ next ⟧ > suc ⟦ x ∷ xs ⟧\n proof = start\n suc (suc (Digit-toℕ x o)) + ⟦ xs ⟧ * suc b\n ≈⟨ cong (λ w → suc (suc w) + ⟦ xs ⟧ * suc b) (greatest-digit-toℕ x greatest) ⟩\n suc (suc d) + o + ⟦ xs ⟧ * suc b\n ≈⟨ +-assoc (suc (suc d)) o (⟦ xs ⟧ * suc b) ⟩\n suc (suc d) + (o + ⟦ xs ⟧ * suc b)\n ≈⟨ a+[b+c]≡b+[a+c] (suc (suc d)) o (⟦ xs ⟧ * suc b) ⟩\n o + (suc (suc d) + ⟦ xs ⟧ * suc b)\n ≤⟨ n+-mono o (+n-mono (⟦ xs ⟧ * suc b) gapped) ⟩\n o + ((⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b + ⟦ xs ⟧ * suc b)\n ≈⟨ cong (λ w → o + w) (sym (distribʳ-*-+ (suc b) (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) ⟦ xs ⟧)) ⟩\n o + (⟦ next-xs ⟧ ∸ ⟦ xs ⟧ + ⟦ xs ⟧) * suc b\n ≈⟨ cong (λ w → o + w * suc b) (m∸n+n≡m (<⇒≤ next-xs>xs)) ⟩\n o + ⟦ next-xs ⟧ * suc b\n ≈⟨ refl ⟩\n ⟦ z ∷ next-xs ⟧\n □\n\n next-numeral-Proper-UngappedEndpoint-lemma : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (greatest : Greatest (lsd xs))\n → (proper : 2 ≤ suc (d + o))\n → (¬gapped : ¬ (Gapped xs proper))\n → ⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧ ≡ suc ⟦ xs ⟧\n next-numeral-Proper-UngappedEndpoint-lemma {b} {d} {o} (x ∙) greatest proper ¬gapped = proof\n -- ⟦ digit+1-n x greatest (carry o * suc b) lower-bound ∷ carry-digit d o proper ∙ ⟧ ≡ suc ⟦ x ∙ ⟧\n where\n lower-bound : carry o * suc b > 0\n lower-bound =\n start\n 1\n ≤⟨ m≤m*1+n 1 b ⟩\n 1 * suc b\n ≤⟨ *n-mono (suc b) (m≤m⊔n 1 o) ⟩\n carry o * suc b\n □\n\n upper-bound : carry o * suc b ≤ suc d\n upper-bound = ≤-pred $ ≰⇒> ¬gapped\n\n upper-bound' : carry o * suc b ≤ suc (Fin.toℕ x + o)\n upper-bound' = start\n carry o * suc b\n ≤⟨ upper-bound ⟩\n suc d\n ≈⟨ sym greatest ⟩\n suc (Fin.toℕ x)\n ≤⟨ m≤m+n (suc (Fin.toℕ x)) o ⟩\n suc (Fin.toℕ x + o)\n □\n\n next : Numeral (suc b) (suc d) o\n next = digit+1-n x greatest (carry o * suc b) lower-bound ∷ carry-digit d o proper ∙\n\n proof : ⟦ next ⟧ ≡ suc (Digit-toℕ x o)\n proof =\n begin\n Digit-toℕ (digit+1-n x greatest (carry o * suc b) lower-bound) o + Digit-toℕ (carry-digit d o proper) o * suc b\n ≡⟨ cong (λ w → Digit-toℕ (digit+1-n x greatest (carry o * suc b) lower-bound) o + w * suc b) (carry-digit-toℕ d o proper) ⟩\n Digit-toℕ (digit+1-n x greatest (carry o * suc b) lower-bound) o + carry o * suc b\n ≡⟨ cong (λ w → w + carry o * suc b) (digit+1-n-toℕ x greatest (carry o * suc b) lower-bound upper-bound) ⟩\n suc (Fin.toℕ x + o) ∸ carry o * suc b + carry o * suc b\n ≡⟨ m∸n+n≡m upper-bound' ⟩\n suc (Digit-toℕ x o)\n ∎\n next-numeral-Proper-UngappedEndpoint-lemma {b} {d} {o} (x ∷ xs) greatest proper ¬gapped = proof\n -- ⟦ digit+1-n x greatest gap gap>0 ∷ next ∙ ⟧ ≡ suc ⟦ x ∷ xs ⟧\n where\n ¬max-xs : ¬ (Maximum xs)\n ¬max-xs = Maximum-Proper xs proper\n\n next-xs : Numeral (suc b) (suc d) o\n next-xs = next-numeral-Proper xs proper\n\n lower-bound : (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b > 0\n lower-bound =\n start\n 1\n ≤⟨ m≤m*1+n 1 b ⟩\n 1 * suc b\n ≤⟨ *n-mono (suc b) (m≥n+o⇒m∸o≥n ⟦ next-xs ⟧ 1 ⟦ xs ⟧ (next-numeral-is-greater-Proper xs proper)) ⟩\n (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n □\n\n upper-bound : (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b ≤ suc d\n upper-bound = ≤-pred $ ≰⇒> ¬gapped\n\n next : Numeral (suc b) (suc d) o\n next = digit+1-n x greatest ((⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b) lower-bound ∷ next-xs\n\n ⟦next-xs⟧>⟦xs⟧ : ⟦ next-xs ⟧ > ⟦ xs ⟧\n ⟦next-xs⟧>⟦xs⟧ = next-numeral-is-greater-Proper xs proper\n\n upper-bound' : ⟦ next-xs ⟧ * suc b ∸ ⟦ xs ⟧ * suc b ≤ suc (Digit-toℕ x o)\n upper-bound' =\n start\n ⟦ next-xs ⟧ * suc b ∸ ⟦ xs ⟧ * suc b\n ≈⟨ sym (*-distrib-∸ʳ (suc b) ⟦ next-xs ⟧ ⟦ xs ⟧) ⟩\n (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n ≤⟨ upper-bound ⟩\n suc d\n ≤⟨ m≤m+n (suc d) o ⟩\n suc d + o\n ≈⟨ cong (λ w → w + o) (sym greatest) ⟩\n suc (Digit-toℕ x o)\n □\n\n proof : ⟦ next ⟧ ≡ suc ⟦ x ∷ xs ⟧\n proof =\n begin\n ⟦ next ⟧\n ≡⟨ cong (λ w → w + ⟦ next-xs ⟧ * suc b) (digit+1-n-toℕ x greatest ((⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b) lower-bound upper-bound) ⟩\n suc (Digit-toℕ x o) ∸ (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b + ⟦ next-xs ⟧ * suc b\n ≡⟨ cong (λ w → suc (Digit-toℕ x o) ∸ w + ⟦ next-xs ⟧ * suc b) (*-distrib-∸ʳ (suc b) ⟦ next-xs ⟧ ⟦ xs ⟧) ⟩\n suc (Digit-toℕ x o) ∸ (⟦ next-xs ⟧ * suc b ∸ ⟦ xs ⟧ * suc b) + ⟦ next-xs ⟧ * suc b\n ≡⟨ m∸[o∸n]+o≡m+n (suc (Digit-toℕ x o)) (⟦ xs ⟧ * suc b) (⟦ next-xs ⟧ * suc b) (*n-mono (suc b) (<⇒≤ ⟦next-xs⟧>⟦xs⟧)) upper-bound' ⟩\n suc ⟦ x ∷ xs ⟧\n ∎\n\n next-numeral-is-greater-Proper : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → ⟦ next-numeral-Proper xs proper ⟧ > ⟦ xs ⟧\n next-numeral-is-greater-Proper xs proper with nextView xs proper\n next-numeral-is-greater-Proper xs proper | Interval b d o ¬greatest =\n start\n suc ⟦ xs ⟧\n ≈⟨ sym (next-numeral-Proper-Interval-lemma xs ¬greatest proper) ⟩\n ⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧\n □\n next-numeral-is-greater-Proper xs proper | GappedEndpoint b d o greatest gapped =\n start\n suc ⟦ xs ⟧\n ≤⟨ n≤1+n (suc ⟦ xs ⟧) ⟩\n suc (suc ⟦ xs ⟧)\n ≤⟨ next-numeral-Proper-GappedEndpoint-lemma xs greatest proper gapped ⟩\n ⟦ next-numeral-Proper-GappedEndpoint xs proper gapped ⟧\n □\n next-numeral-is-greater-Proper xs proper | UngappedEndpoint b d o greatest ¬gapped =\n start\n suc ⟦ xs ⟧\n ≈⟨ sym (next-numeral-Proper-UngappedEndpoint-lemma xs greatest proper ¬gapped) ⟩\n ⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧\n □\n\n-- gap : ∀ {b d o}\n-- → (xs : Numeral (suc b) (suc d) o)\n-- → (proper : 2 ≤ suc (d + o))\n-- → ℕ\n-- gap {b} {d} {o} (x ∙) proper = carry o * suc b\n-- gap {b} {d} {o} (x ∷ xs) proper = (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n-- where\n-- next-xs : Numeral (suc b) (suc d) o\n-- next-xs = next-numeral-Proper xs proper\n--\n-- gap>0 : ∀ {b d o}\n-- → (xs : Numeral (suc b) (suc d) o)\n-- → (proper : 2 ≤ suc (d + o))\n-- → gap xs proper > 0\n-- gap>0 {b} {d} {o} (x ∙) proper =\n-- start\n-- 1\n-- ≤⟨ m≤m*1+n 1 b ⟩\n-- 1 * suc b\n-- ≤⟨ *n-mono (suc b) (m≤m⊔n 1 o) ⟩\n-- carry o * suc b\n-- □\n-- gap>0 {b} {d} {o} (x ∷ xs) proper =\n-- start\n-- 1\n-- ≤⟨ m≤m*1+n 1 b ⟩\n-- 1 * suc b\n-- ≤⟨ *n-mono (suc b) (m≥n+o⇒m∸o≥n ⟦ next-xs ⟧ 1 ⟦ xs ⟧ (next-numeral-is-greater-Proper xs proper)) ⟩\n-- (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b\n-- □\n-- where\n-- next-xs : Numeral (suc b) (suc d) o\n-- next-xs = next-numeral-Proper xs proper\n--------------------------------------------------------------------------------\n-- Properties of next-numeral on Proper Numbers\n--------------------------------------------------------------------------------\n\nnext-numeral-Proper-refine-target : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → NextView (suc b) (suc d) o xs proper\n → Set\nnext-numeral-Proper-refine-target xs proper (Interval b d o ¬greatest) = next-numeral-Proper xs proper ≡ next-numeral-Proper-Interval xs ¬greatest proper\nnext-numeral-Proper-refine-target xs proper (GappedEndpoint b d o greatest gapped) = next-numeral-Proper xs proper ≡ next-numeral-Proper-GappedEndpoint xs proper gapped\nnext-numeral-Proper-refine-target xs proper (UngappedEndpoint b d o greatest ¬gapped) = next-numeral-Proper xs proper ≡ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped\n\nnext-numeral-Proper-refine : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → (view : NextView (suc b) (suc d) o xs proper)\n → next-numeral-Proper-refine-target xs proper view\nnext-numeral-Proper-refine xs proper (Interval b d o ¬greatest) with nextView xs proper\nnext-numeral-Proper-refine xs proper (Interval b d o ¬greatest) | Interval _ _ _ _ = refl\nnext-numeral-Proper-refine xs proper (Interval b d o ¬greatest) | GappedEndpoint _ _ _ greatest _ = contradiction greatest ¬greatest\nnext-numeral-Proper-refine xs proper (Interval b d o ¬greatest) | UngappedEndpoint _ _ _ greatest _ = contradiction greatest ¬greatest\nnext-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) with nextView xs proper\nnext-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) | Interval _ _ _ ¬greatest = contradiction greatest ¬greatest\nnext-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) | GappedEndpoint _ _ _ _ _ = refl\nnext-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) | UngappedEndpoint _ _ _ _ ¬gapped = contradiction gapped ¬gapped\nnext-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) with nextView xs proper\nnext-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) | Interval _ _ _ ¬greatest = contradiction greatest ¬greatest\nnext-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) | GappedEndpoint _ _ _ _ gapped = contradiction gapped ¬gapped\nnext-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) | UngappedEndpoint _ _ _ _ _ = refl\n\n\n--------------------------------------------------------------------------------\n-- next-numeral-is-immediate-Proper\n--------------------------------------------------------------------------------\n\nnext-numeral-is-immediate-Proper : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (ys : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → ⟦ ys ⟧ > ⟦ xs ⟧\n → ⟦ ys ⟧ ≥ ⟦ next-numeral-Proper xs proper ⟧\nnext-numeral-is-immediate-Proper xs ys proper prop with nextView xs proper\nnext-numeral-is-immediate-Proper xs ys proper prop | Interval b d o ¬greatest =\n start\n ⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧\n ≈⟨ next-numeral-Proper-Interval-lemma xs ¬greatest proper ⟩\n suc ⟦ xs ⟧\n ≤⟨ prop ⟩\n ⟦ ys ⟧\n □\nnext-numeral-is-immediate-Proper xs (y ∙) proper prop | GappedEndpoint b d o greatest gapped\n = contradiction prop $ >⇒≰ $\n start\n suc (Digit-toℕ y o)\n ≤⟨ s≤s (greatest-of-all o (lsd xs) y greatest) ⟩\n suc (Digit-toℕ (lsd xs) o)\n ≤⟨ s≤s (lsd-toℕ xs) ⟩\n suc ⟦ xs ⟧\n □\nnext-numeral-is-immediate-Proper (x ∙) (y ∷ ys) proper prop | GappedEndpoint b d o greatest gapped =\n start\n o + (Digit-toℕ (carry-digit d o proper) o) * suc b\n ≈⟨ cong (λ w → o + w * suc b) (carry-digit-toℕ d o proper) ⟩\n o + carry o * suc b\n ≤⟨ n+-mono o (*n-mono (suc b) ys-lower-bound) ⟩\n o + ⟦ ys ⟧ * suc b\n ≤⟨ +n-mono (⟦ ys ⟧ * suc b) (n≤m+n (Fin.toℕ y) o) ⟩\n Digit-toℕ y o + ⟦ ys ⟧ * suc b\n □\n where\n ≥carry : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → ⟦ xs ⟧ > 0\n → ⟦ xs ⟧ ≥ carry o\n ≥carry {_} {_} {zero} xs proper prop = prop\n ≥carry {_} {_} {suc o} (x ∙) proper prop = n≤m+n (Fin.toℕ x) (suc o)\n ≥carry {b} {_} {suc o} (x ∷ xs) proper prop =\n start\n suc o\n ≤⟨ n≤m+n (Fin.toℕ x) (suc o) ⟩\n Fin.toℕ x + suc o\n ≤⟨ m≤m+n (Fin.toℕ x + suc o) (⟦ xs ⟧ * suc b) ⟩\n Fin.toℕ x + suc o + ⟦ xs ⟧ * suc b\n □\n\n ys-lower-bound : ⟦ ys ⟧ ≥ carry o\n ys-lower-bound = ≥carry ys proper (tail-mono-strict-Null x y ys greatest prop)\n\nnext-numeral-is-immediate-Proper (x ∷ xs) (y ∷ ys) proper prop | GappedEndpoint b d o greatest gapped =\n start\n o + ⟦ next-xs ⟧ * suc b\n ≤⟨ n+-mono o (*n-mono (suc b) ⟦next-xs⟧≤⟦ys⟧) ⟩\n o + ⟦ ys ⟧ * suc b\n ≤⟨ +n-mono (⟦ ys ⟧ * suc b) (n≤m+n (Fin.toℕ y) o) ⟩\n Digit-toℕ y o + ⟦ ys ⟧ * suc b\n □\n where\n next-xs : Numeral (suc b) (suc d) o\n next-xs = next-numeral-Proper xs proper\n\n ⟦xs⟧<⟦ys⟧ : ⟦ xs ⟧ < ⟦ ys ⟧\n ⟦xs⟧<⟦ys⟧ = tail-mono-strict x xs y ys greatest prop\n\n ⟦next-xs⟧≤⟦ys⟧ : ⟦ next-xs ⟧ ≤ ⟦ ys ⟧\n ⟦next-xs⟧≤⟦ys⟧ = next-numeral-is-immediate-Proper xs ys proper ⟦xs⟧<⟦ys⟧\n\nnext-numeral-is-immediate-Proper xs ys proper prop | UngappedEndpoint b d o greatest ¬gapped =\n start\n ⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧\n ≈⟨ next-numeral-Proper-UngappedEndpoint-lemma xs greatest proper ¬gapped ⟩\n suc ⟦ xs ⟧\n ≤⟨ prop ⟩\n ⟦ ys ⟧\n □\n\n--------------------------------------------------------------------------------\n-- next-numeral\n--------------------------------------------------------------------------------\n\nnext-numeral : ∀ {b d o}\n → (xs : Numeral b d o)\n → ¬ (Maximum xs)\n → Numeral b d o\nnext-numeral {b} {d} {o} xs ¬max with numView b d o\nnext-numeral xs ¬max | NullBase d o = next-numeral-NullBase xs ¬max\nnext-numeral xs ¬max | NoDigits b o = NoDigits-explode xs\nnext-numeral xs ¬max | AllZeros b = contradiction (Maximum-AllZeros xs) ¬max\nnext-numeral xs ¬max | Proper b d o proper = next-numeral-Proper xs proper\n\n\n--------------------------------------------------------------------------------\n-- next-numeral-is-greater\n--------------------------------------------------------------------------------\n\n\nnext-numeral-is-greater : ∀ {b d o}\n → (xs : Numeral b d o)\n → (¬max : ¬ (Maximum xs))\n → ⟦ next-numeral xs ¬max ⟧ > ⟦ xs ⟧\nnext-numeral-is-greater {b} {d} {o} xs ¬max with numView b d o\nnext-numeral-is-greater xs ¬max | NullBase d o = next-numeral-is-greater-NullBase xs ¬max\nnext-numeral-is-greater xs ¬max | NoDigits b o = NoDigits-explode xs\nnext-numeral-is-greater xs ¬max | AllZeros b = contradiction (Maximum-AllZeros xs) ¬max\nnext-numeral-is-greater xs ¬max | Proper b d o proper = next-numeral-is-greater-Proper xs proper\n\n--------------------------------------------------------------------------------\n-- next-numeral-is-immediate\n--------------------------------------------------------------------------------\n\nnext-numeral-is-immediate : ∀ {b d o}\n → (xs : Numeral b d o)\n → (ys : Numeral b d o)\n → (¬max : ¬ (Maximum xs))\n → ⟦ ys ⟧ > ⟦ xs ⟧\n → ⟦ ys ⟧ ≥ ⟦ next-numeral xs ¬max ⟧\nnext-numeral-is-immediate {b} {d} {o} xs ys ¬max prop with numView b d o\nnext-numeral-is-immediate xs ys ¬max prop | NullBase d o = next-numeral-is-immediate-NullBase xs ys ¬max prop\nnext-numeral-is-immediate xs ys ¬max prop | NoDigits b o = NoDigits-explode xs\nnext-numeral-is-immediate xs ys ¬max prop | AllZeros b = contradiction (Maximum-AllZeros xs) ¬max\nnext-numeral-is-immediate xs ys ¬max prop | Proper b d o proper = next-numeral-is-immediate-Proper xs ys proper prop\n\n--------------------------------------------------------------------------------\n-- properties of the gaps\n--------------------------------------------------------------------------------\n\n\nGapped#N⇒Gapped#0 : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → Gapped#N b d o xs proper\n → Gapped#0 b d o\nGapped#N⇒Gapped#0 xs proper gapped#N with nextView xs proper\nGapped#N⇒Gapped#0 xs proper gapped#N | Interval b d o ¬greatest =\n start\n suc (suc d)\n ≤⟨ gapped#N ⟩\n (⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧ ∸ ⟦ xs ⟧) * suc b\n ≤⟨ *n-mono (suc b) $\n start\n ⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧ ∸ ⟦ xs ⟧\n ≈⟨ cong (λ w → w ∸ ⟦ xs ⟧) (next-numeral-Proper-Interval-lemma xs ¬greatest proper) ⟩\n suc ⟦ xs ⟧ ∸ ⟦ xs ⟧\n ≈⟨ m+n∸n≡m (suc zero) ⟦ xs ⟧ ⟩\n suc zero\n ≤⟨ m≤m⊔n 1 o ⟩\n suc zero ⊔ o\n □\n ⟩\n (suc zero ⊔ o) * suc b\n □\nGapped#N⇒Gapped#0 (x ∙) proper gapped#N | GappedEndpoint b d o greatest gapped#0 = gapped#0\nGapped#N⇒Gapped#0 (x ∷ xs) proper _ | GappedEndpoint b d o greatest gapped#N = Gapped#N⇒Gapped#0 xs proper gapped#N\nGapped#N⇒Gapped#0 xs proper gapped#N | UngappedEndpoint b d o greatest ¬gapped =\n start\n suc (suc d)\n ≤⟨ gapped#N ⟩\n (⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧ ∸ ⟦ xs ⟧) * suc b\n ≤⟨ *n-mono (suc b) $\n start\n ⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧ ∸ ⟦ xs ⟧\n ≈⟨ cong (λ w → w ∸ ⟦ xs ⟧) (next-numeral-Proper-UngappedEndpoint-lemma xs greatest proper ¬gapped) ⟩\n suc ⟦ xs ⟧ ∸ ⟦ xs ⟧\n ≈⟨ m+n∸n≡m (suc zero) ⟦ xs ⟧ ⟩\n suc zero\n ≤⟨ m≤m⊔n 1 o ⟩\n suc zero ⊔ o\n □\n ⟩\n (suc zero ⊔ o) * suc b\n □\n\n-- ¬Gapped#0⇒¬Gapped#N : ∀ {b d o}\n-- → (xs : Numeral (suc b) (suc d) o)\n-- → (proper : 2 ≤ suc (d + o))\n-- → ¬ (Gapped#0 b d o)\n-- → ¬ (Gapped#N b d o xs proper)\n-- ¬Gapped#0⇒¬Gapped#N xs proper ¬Gapped#0 = contraposition (Gapped#N⇒Gapped#0 xs proper) ¬Gapped#0\n\n¬Gapped#0⇒¬Gapped : ∀ {b d o}\n → (xs : Numeral (suc b) (suc d) o)\n → (proper : 2 ≤ suc (d + o))\n → ¬ (Gapped#0 b d o)\n → ¬ (Gapped xs proper)\n¬Gapped#0⇒¬Gapped (x ∙) proper ¬Gapped#0 = ¬Gapped#0\n¬Gapped#0⇒¬Gapped (x ∷ xs) proper ¬Gapped#0 = contraposition\n (Gapped#N⇒Gapped#0 xs proper)\n ¬Gapped#0\n", "meta": {"hexsha": "32fd09dc9dfd8024a86370640f037890dedd6fba", "size": 29426, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Num/Next.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/Next.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/Next.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": 42.3395683453, "max_line_length": 183, "alphanum_fraction": 0.5012573914, "num_tokens": 10273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430394931456, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.5839029672387449}} {"text": "open import Formalization.PredicateLogic.Signature\n\nmodule Formalization.PredicateLogic.Classical.SequentCalculus (𝔏 : Signature) where\nopen Signature(𝔏)\n\nopen import Data.List\nopen import Data.List.Functions using () renaming (singleton to · ; _++_ to _∪_)\nopen import Data.List.Relation.Permutation\nopen import Formalization.PredicateLogic.Syntax(𝔏)\nopen import Formalization.PredicateLogic.Syntax.Substitution(𝔏)\nopen import Functional as Fn\nimport Lvl\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Type\n\nprivate variable ℓ : Lvl.Level\nprivate variable n vars : ℕ\n\n_∪·_ : ∀{T : Type{ℓ}} → List(T) → T → List(T)\n_∪·_ = Fn.swap(_⊰_)\ninfixl 1000 _∪·_\n\nmodule _ where\n private variable Γ Γ₁ Γ₂ Γ₃ Δ Δ₁ Δ₂ Δ₃ : List(Formula(vars))\n private variable φ φ₁ φ₂ ψ A B C : Formula(vars)\n private variable p : Prop(n)\n\n data _⇒_ : List(Formula(vars)) → List(Formula(vars)) → Type{Lvl.𝐒(ℓₚ Lvl.⊔ ℓₒ)} where\n axiom : ((· φ) ⇒ (· φ))\n\n weakenₗ : (Γ ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)\n permuteₗ : .(Γ₁ permutes Γ₂) → (Γ₁ ⇒ Δ) → (Γ₂ ⇒ Δ)\n contractₗ : ((Γ ∪· A ∪· A) ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)\n ⊥ₗ : (Γ ∪· ⊥) ⇒ ∅\n ∧ₗₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)\n ∧ₗᵣ : ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)\n ∨ₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∨ B)) ⇒ Δ)\n ⟶ₗ : (Γ ⇒ (Δ ∪· A)) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ⟶ B)) ⇒ Δ)\n Ɐₗ : ∀{t} → ((Γ ∪· (substitute0 t A)) ⇒ Δ) → ((Γ ∪· (Ɐ A)) ⇒ Δ)\n ∃ₗ : ∀{v}{n} → ((Γ ∪· (substituteN n (var v) A)) ⇒ Δ) → ((Γ ∪· (∃ A)) ⇒ Δ)\n\n weakenᵣ : (Γ ⇒ Δ) → (Γ ⇒ (Δ ∪· A))\n permuteᵣ : .(Δ₁ permutes Δ₂) → (Γ ⇒ Δ₁) → (Γ ⇒ Δ₂)\n contractᵣ : (Γ ⇒ (Δ ∪· A ∪· A)) → (Γ ⇒ (Δ ∪· A))\n ⊤ᵣ : ∅ ⇒ (Δ ∪· ⊤)\n ∧ᵣ : (Γ ⇒ (Δ ∪· A)) → (Γ ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ∧ B)))\n ∨ᵣₗ : (Γ ⇒ (Δ ∪· A)) → (Γ ⇒ (Δ ∪· (A ∨ B)))\n ∨ᵣᵣ : (Γ ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ∨ B)))\n ⟶ᵣ : ((Γ ∪· A) ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ⟶ B)))\n Ɐᵣ : ∀{v}{n} → (Γ ⇒ (Δ ∪· (substituteN n (var v) A))) → (Γ ⇒ (Δ ∪· (Ɐ A)))\n ∃ᵣ : ∀{t} → (Γ ⇒ (Δ ∪· (substitute0 t A))) → (Γ ⇒ (Δ ∪· (∃ A)))\n", "meta": {"hexsha": "c89e068e2e91a2c44f9d59a7c75f0a418c11abb9", "size": 2027, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/PredicateLogic/Classical/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/Classical/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/Classical/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": 38.2452830189, "max_line_length": 87, "alphanum_fraction": 0.4849531327, "num_tokens": 1034, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.831143031127974, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.5839029561854884}} {"text": "module my-integer where\n\nopen import bool\nopen import bool-thms2\nopen import eq\nopen import nat\nopen import nat-thms\nopen import product\n--open import product-thms\nopen import sum\n-- open import unit\n\ndata ⊤ : Set where\n triv : ⊤\n\nℤ-pos-t : ℕ → Set\nℤ-pos-t 0 = ⊤\nℤ-pos-t (suc _) = 𝔹\n\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", "meta": {"hexsha": "e4ac923c9ed576415051df5c9fe45b4d943be856", "size": 1245, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "my-integer.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": "my-integer.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": "my-integer.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": 21.8421052632, "max_line_length": 87, "alphanum_fraction": 0.5759036145, "num_tokens": 618, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767938900121, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.5838823295319232}} {"text": "module Formalization.ClassicalPropositionalLogic.NaturalDeduction.Proofs where\n\nopen import Data.Boolean\nopen import Data.Either\nopen import Functional\nopen import Formalization.ClassicalPropositionalLogic.NaturalDeduction\nopen import Formalization.ClassicalPropositionalLogic.Place\nopen import Formalization.ClassicalPropositionalLogic.Syntax\nimport Lvl\nopen import Logic\nimport Logic.Propositional as Meta\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to singleton ; _≡_ to _≡ₛ_)\nopen import Type\n\nprivate variable ℓₚ ℓ ℓ₁ ℓ₂ : Lvl.Level\nprivate variable T A B : Type{ℓ}\nprivate variable P : Type{ℓₚ}\nprivate variable φ ψ γ : Formula(P)\nprivate variable Γ : Formulas(P){ℓ}\nprivate variable f : A → B\nprivate variable s e : Bool\nprivate variable p : P\n\nmodule _ where\n [¬]-intro-converse : ((Γ ∪ singleton(φ)) ⊢ ⊥) ← (Γ ⊢ (¬ φ))\n [¬]-intro-converse {Γ = Γ}{φ = φ} Γ¬φ = [⊥]-intro (direct (Right [≡]-intro)) (weaken-union Γ¬φ)\n\n excluded-middle : Γ ⊢ (φ ∨ (¬ φ))\n excluded-middle =\n ([¬¬]-elim\n ([¬]-intro\n ([⊥]-intro\n ([∨]-introᵣ\n ([¬]-intro\n ([⊥]-intro\n ([∨]-introₗ (direct (Right [≡]-intro)))\n (direct (Left (Right [≡]-intro)))\n )\n )\n )\n (direct (Right [≡]-intro))\n )\n )\n )\n\n [→]-disjunctive-form : (Γ ⊢ (φ ⟶ ψ)) Meta.↔ (Γ ⊢ ((¬ φ) ∨ ψ))\n [→]-disjunctive-form = Meta.[↔]-intro l r where\n l = [∨]-elim\n ([⟶]-intro ([⊥]-elim ([⊥]-intro\n (direct (Right [≡]-intro))\n (direct (Left (Right [≡]-intro)))\n )))\n ([⟶]-intro (direct (Left (Right [≡]-intro))))\n r = pq ↦\n ([∨]-elim\n ([∨]-introᵣ ([⟶]-elim (direct (Right [≡]-intro)) (weaken Left pq)))\n ([∨]-introₗ (direct (Right [≡]-intro)))\n excluded-middle\n )\n\n [⟷]-negated : (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ ((¬ φ) ⟷ (¬ ψ)))\n [⟷]-negated p = [⟷]-intro\n ([¬]-intro ([⊥]-intro ([⟷]-elimᵣ (direct (Right [≡]-intro)) (weaken (Left ∘ Left) p)) (direct (Left (Right [≡]-intro)))))\n (([¬]-intro ([⊥]-intro ([⟷]-elimₗ (direct (Right [≡]-intro)) (weaken (Left ∘ Left) p)) (direct (Left (Right [≡]-intro))))))\n\n [⟷]-conjunction-disjunction-negation : (Γ ⊢ (φ ⟷ ψ)) Meta.↔ (Γ ⊢ ((φ ∧ ψ) ∨ ((¬ φ) ∧ (¬ ψ))))\n [⟷]-conjunction-disjunction-negation = Meta.[↔]-intro l r where\n l = [∨]-elim\n ([⟷]-intro\n ([∧]-elimₗ (direct (Left (Right [≡]-intro))))\n ([∧]-elimᵣ (direct (Left (Right [≡]-intro))))\n )\n ([⟷]-intro\n ([⊥]-elim ([⊥]-intro (direct (Right [≡]-intro)) ([∧]-elimᵣ (direct (Left (Right [≡]-intro))))))\n ([⊥]-elim ([⊥]-intro (direct (Right [≡]-intro)) ([∧]-elimₗ (direct (Left (Right [≡]-intro))))))\n )\n r = p ↦ [∨]-elim\n ([∨]-introₗ ([∧]-intro\n (direct (Right [≡]-intro))\n ([⟷]-elimᵣ (direct (Right [≡]-intro)) (weaken Left p))\n ))\n ([∨]-introᵣ ([∧]-intro\n (direct (Right [≡]-intro))\n ([⟷]-elimᵣ (direct (Right [≡]-intro)) (weaken Left ([⟷]-negated p)))\n ))\n excluded-middle\n\n-- TODO: The two proofs contain very similar cases (the structure is identical in all cases). Are there any good ways to generalize? Maybe by using the strict variants?\npositive-congruence : Positive(P) f → (Γ ⊢ (φ ⟶ ψ) ⟶ (f(φ) ⟶ f(ψ)))\nnegative-congruence : Negative(P) f → (Γ ⊢ (φ ⟶ ψ) ⟶ (f(φ) ⟵ f(ψ)))\n\npositive-congruence identity = [⟶]-intro ([⟶]-intro ([⟶]-elim (direct (Right [≡]-intro)) (direct (Left (Right [≡]-intro)))))\npositive-congruence (conjunctionₗ ctx) =\n [⟶]-intro ([⟶]-intro ([∧]-intro\n ([∧]-elimₗ (direct (Right [≡]-intro)))\n ([⟶]-elim ([∧]-elimᵣ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (positive-congruence ctx)))\n ))\npositive-congruence (conjunctionᵣ ctx) =\n [⟶]-intro ([⟶]-intro ([∧]-intro\n ([⟶]-elim ([∧]-elimₗ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (positive-congruence ctx)))\n ([∧]-elimᵣ (direct (Right [≡]-intro)))\n ))\npositive-congruence (disjunctionₗ ctx) =\n [⟶]-intro ([⟶]-intro ([∨]-elim\n ([∨]-introₗ (direct (Right [≡]-intro)))\n ([∨]-introᵣ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx))))\n (direct (Right [≡]-intro))\n ))\npositive-congruence (disjunctionᵣ ctx) =\n [⟶]-intro ([⟶]-intro ([∨]-elim\n ([∨]-introₗ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx))))\n ([∨]-introᵣ (direct (Right [≡]-intro)))\n (direct (Right [≡]-intro))\n ))\npositive-congruence (implicationₗ ctx) =\n [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim\n ([⟶]-elim (direct(Right [≡]-intro)) (direct (Left (Right [≡]-intro))))\n ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx))\n )))\npositive-congruence (implicationᵣ ctx) =\n [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim\n ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx)))\n (direct (Left (Right [≡]-intro)))\n )))\n\nnegative-congruence (conjunctionₗ ctx) =\n [⟶]-intro ([⟶]-intro ([∧]-intro\n ([∧]-elimₗ (direct (Right [≡]-intro)))\n ([⟶]-elim ([∧]-elimᵣ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (negative-congruence ctx)))\n ))\nnegative-congruence (conjunctionᵣ ctx) =\n [⟶]-intro ([⟶]-intro ([∧]-intro\n ([⟶]-elim ([∧]-elimₗ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (negative-congruence ctx)))\n ([∧]-elimᵣ (direct (Right [≡]-intro)))\n ))\nnegative-congruence (disjunctionₗ ctx) =\n [⟶]-intro ([⟶]-intro ([∨]-elim\n ([∨]-introₗ (direct (Right [≡]-intro)))\n ([∨]-introᵣ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx))))\n (direct (Right [≡]-intro))\n ))\nnegative-congruence (disjunctionᵣ ctx) =\n [⟶]-intro ([⟶]-intro ([∨]-elim\n ([∨]-introₗ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx))))\n ([∨]-introᵣ (direct (Right [≡]-intro)))\n (direct (Right [≡]-intro))\n ))\nnegative-congruence (implicationₗ ctx) =\n [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim\n ([⟶]-elim (direct(Right [≡]-intro)) (direct (Left (Right [≡]-intro))))\n ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx))\n )))\nnegative-congruence (implicationᵣ ctx) =\n [⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim\n ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx)))\n (direct (Left (Right [≡]-intro)))\n )))\n\n-- TODO: Mainly for results in minimal logic\ndata NegativeFragment {P : Type{ℓₚ}} : Formula(P) → Type{Lvl.of(P)} where\n atom : NegativeFragment(¬(• p))\n bottom : NegativeFragment(⊥)\n top : NegativeFragment(⊤)\n neg : NegativeFragment(φ) → NegativeFragment(¬ φ)\n and : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ∧ ψ)\n impl : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ⟶ ψ)\n eq : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ⟷ ψ)\n\nopen import Functional\nopen import Type.Dependent\nopen import Type.Dependent.Functions\n\nmodule GGNegativeTranslation where\n trans : Formula(P) → Formula(P)\n trans (• p) = ¬(¬(• p))\n trans ⊤ = ⊤\n trans ⊥ = ⊥\n trans (¬ φ) = ¬(trans φ)\n trans (φ ∧ ψ) = (trans φ) ∧ (trans ψ)\n trans (φ ∨ ψ) = ¬((¬(trans φ)) ∧ (¬(trans ψ)))\n trans (φ ⟶ ψ) = (trans φ) ⟶ (trans ψ)\n trans (φ ⟷ ψ) = (trans φ) ⟷ (trans ψ)\n\n trans-negativeFragment : NegativeFragment(trans(φ))\n trans-negativeFragment {φ = • p} = neg atom\n trans-negativeFragment {φ = ⊤} = top\n trans-negativeFragment {φ = ⊥} = bottom\n trans-negativeFragment {φ = ¬ φ} = neg trans-negativeFragment\n trans-negativeFragment {φ = φ ∧ ψ} = and trans-negativeFragment trans-negativeFragment\n trans-negativeFragment {φ = φ ∨ ψ} = neg(and(neg trans-negativeFragment) (neg trans-negativeFragment))\n trans-negativeFragment {φ = φ ⟶ ψ} = impl trans-negativeFragment trans-negativeFragment\n trans-negativeFragment {φ = φ ⟷ ψ} = eq trans-negativeFragment trans-negativeFragment\n", "meta": {"hexsha": "03beb8ee32a1eb92f5158e4da707d457f1cf564a", "size": 8326, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/ClassicalPropositionalLogic/NaturalDeduction/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": "Formalization/ClassicalPropositionalLogic/NaturalDeduction/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": "Formalization/ClassicalPropositionalLogic/NaturalDeduction/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": 42.6974358974, "max_line_length": 168, "alphanum_fraction": 0.5719433101, "num_tokens": 3075, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637469145054, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.583865305357638}} {"text": "module maybe-thms where\n\nopen import eq\nopen import level\nopen import maybe\nopen import product\nopen import sum\n\nmaybe-dec : ∀ {ℓ}{A : Set ℓ}(x : maybe A) → x ≡ nothing ∨ Σ A (λ a → x ≡ just a)\nmaybe-dec nothing = inj₁ refl\nmaybe-dec (just a) = inj₂ (a , refl)", "meta": {"hexsha": "3b8da0d318d5127894bebedba398fd38126e9a05", "size": 260, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "maybe-thms.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": "maybe-thms.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": "maybe-thms.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": 23.6363636364, "max_line_length": 80, "alphanum_fraction": 0.6769230769, "num_tokens": 90, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.5837776954642373}} {"text": "\nmodule Container.Bag where\n\nopen import Prelude\n\nBag : Set → Set\nBag A = List (Nat × A)\n\nFunctorBag : Functor Bag\nfmap {{FunctorBag}} f b = map (second f) b\n\nunion : {A : Set} {{OrdA : Ord A}} → Bag A → Bag A → Bag A\nunion a [] = a\nunion [] b = b\nunion ((i , x) ∷ a) ((j , y) ∷ b) with compare x y\n... | less _ = (i , x) ∷ union a ((j , y) ∷ b)\n... | equal _ = (i + j , x) ∷ union a b\n... | greater _ = (j , y) ∷ union ((i , x) ∷ a) b\n", "meta": {"hexsha": "d9a3616c8a9e0719be7a4ab31c6edcc0cd23475c", "size": 441, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Container/Bag.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/Container/Bag.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/Container/Bag.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": 23.2105263158, "max_line_length": 58, "alphanum_fraction": 0.5124716553, "num_tokens": 177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9059898305367526, "lm_q2_score": 0.6442251064863698, "lm_q1q2_score": 0.5836613950531075}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.CommRing.Integers where\n\nopen import Cubical.Foundations.Prelude\n\n\nopen import Cubical.Algebra.CommRing\n\nmodule _ where\n open import Cubical.HITs.Ints.BiInvInt\n renaming (\n _+_ to _+ℤ_;\n -_ to _-ℤ_;\n +-assoc to +ℤ-assoc;\n +-comm to +ℤ-comm\n )\n\n BiInvIntAsCommRing : CommRing {ℓ-zero}\n BiInvIntAsCommRing =\n makeCommRing\n zero (suc zero) _+ℤ_ _·_ _-ℤ_\n isSetBiInvInt\n +ℤ-assoc +-zero +-invʳ +ℤ-comm\n ·-assoc ·-identityʳ\n (λ x y z → sym (·-distribˡ x y z))\n ·-comm\n\n-- makeCommRing ? ? ? ? ? ? ? ? ? ? ? ? ? ?\n\nmodule _ where\n open import Cubical.Data.Int\n\n IntAsCommRing : CommRing {ℓ-zero}\n IntAsCommRing = makeCommRing {R = Int} 0 1 _+_ _·_ -_ isSetInt\n +-assoc +-identityʳ +-inverseʳ +-comm (λ x y z → sym (·-assoc x y z)) ·-identityʳ\n (λ x y z → sym (·-distribˡ x y z)) ·-comm\n\nmodule _ where\n open import Cubical.HITs.Ints.QuoInt\n\n QuoIntAsCommRing : CommRing {ℓ-zero}\n QuoIntAsCommRing = makeCommRing {R = ℤ} 0 1 _+_ _·_ -_ isSetℤ\n +-assoc +-identityʳ +-inverseʳ +-comm ·-assoc ·-identityʳ\n (λ x y z → sym (·-distribˡ x y z)) ·-comm\n\nmodule _ where\n open import Cubical.Data.DiffInt\n\n DiffIntAsCommRing : CommRing {ℓ-zero}\n DiffIntAsCommRing = makeCommRing {R = ℤ} 0 1 _+_ _·_ -_ isSetℤ\n +-assoc +-identityʳ +-inverseʳ +-comm ·-assoc ·-identityʳ ·-distribˡ ·-comm\n\nopen import Cubical.Algebra.Ring using (ringequiv)\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Reflection.Base using (_$_) -- TODO: add this to Foundation.Function\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\nopen import Cubical.Foundations.Structure\nopen import Cubical.HITs.Ints.BiInvInt using (BiInvInt)\nopen import Cubical.Data.Nat using (suc; zero) renaming (_·_ to _·ⁿ_; _+_ to _+ⁿ_)\nopen import Cubical.Data.Int as Int using (sucInt; predInt; Int) renaming\n ( _+_ to _+'_\n ; _·_ to _·'_\n ; -_ to -'_\n ; pos to pos'\n ; negsuc to negsuc'\n ; sgn to sgn'\n ; abs to abs'\n ; signed to signed'\n )\n\nmodule _ where\n open import Cubical.HITs.Ints.BiInvInt renaming\n ( fwd to ⟦_⟧\n ; suc to sucᵇ\n )\n\n private\n suc-⟦⟧ : ∀ x → sucᵇ ⟦ x ⟧ ≡ ⟦ sucInt x ⟧\n suc-⟦⟧ (pos' n) = refl\n suc-⟦⟧ (negsuc' zero) = suc-pred _\n suc-⟦⟧ (negsuc' (suc n)) = suc-pred _\n\n pred-⟦⟧ : ∀ x → predl ⟦ x ⟧ ≡ ⟦ predInt x ⟧\n pred-⟦⟧ (pos' zero) = refl\n pred-⟦⟧ (pos' (suc n)) = pred-suc _\n pred-⟦⟧ (negsuc' zero) = refl\n pred-⟦⟧ (negsuc' (suc n)) = refl\n\n neg-⟦⟧ : ∀ x → - ⟦ x ⟧ ≡ ⟦ -' x ⟧\n neg-⟦⟧ (pos' zero) = refl\n neg-⟦⟧ (pos' (suc n)) = (λ i → predl (neg-⟦⟧ (pos' n) i)) ∙ pred-⟦⟧ (-' pos' n) ∙ cong ⟦_⟧ (Int.predInt-neg (pos' n))\n neg-⟦⟧ (negsuc' zero) = refl\n neg-⟦⟧ (negsuc' (suc n)) = (λ i → sucᵇ (neg-⟦⟧ (negsuc' n) i))\n\n pres1 : 1 ≡ ⟦ 1 ⟧\n pres1 = refl\n\n isHom+ : ∀ x y → ⟦ x +' y ⟧ ≡ ⟦ x ⟧ + ⟦ y ⟧\n isHom+ (pos' zero) y i = ⟦ Int.+-comm 0 y i ⟧\n isHom+ (pos' (suc n)) y =\n ⟦ pos' (suc n) +' y ⟧ ≡[ i ]⟨ ⟦ Int.sucInt+ (pos' n) y (~ i) ⟧ ⟩\n ⟦ sucInt (pos' n +' y) ⟧ ≡⟨ sym $ suc-⟦⟧ _ ⟩\n sucᵇ ⟦ pos' n +' y ⟧ ≡[ i ]⟨ sucᵇ $ isHom+ (pos' n) y i ⟩\n sucᵇ (⟦ pos' n ⟧ + ⟦ y ⟧) ≡⟨ refl ⟩\n sucᵇ ⟦ pos' n ⟧ + ⟦ y ⟧ ∎\n isHom+ (negsuc' zero) y = pred-suc-inj _ _ (λ i → predl (γ i)) where\n -- γ = sucᵇ ⟦ negsuc' zero +' y ⟧ ≡⟨ suc-⟦⟧ (negsuc' zero +' y) ⟩\n -- ⟦ sucInt (negsuc' zero +' y)⟧ ≡⟨ cong ⟦_⟧ $ Int.sucInt+ (negsuc' zero) y ∙ Int.+-comm 0 y ⟩\n -- ⟦ y ⟧ ≡⟨ sym (suc-pred ⟦ y ⟧) ⟩\n -- sucᵇ (pred zero + ⟦ y ⟧) ∎\n γ = suc-⟦⟧ (negsuc' zero +' y) ∙ (λ i → ⟦ (Int.sucInt+ (negsuc' zero) y ∙ Int.+-comm 0 y) i ⟧) ∙ sym (suc-pred ⟦ y ⟧)\n isHom+ (negsuc' (suc n)) y = (λ i → ⟦ Int.predInt+ (negsuc' n) y (~ i) ⟧) ∙ sym (pred-⟦⟧ (negsuc' n +' y))\n ∙ (λ i → pred $ isHom+ (negsuc' n) y i)\n\n isHom· : ∀ x y → ⟦ x ·' y ⟧ ≡ ⟦ x ⟧ · ⟦ y ⟧\n isHom· (pos' zero) y i = ⟦ Int.signed-zero (Int.sgn y) i ⟧\n isHom· (pos' (suc n)) y =\n ⟦ pos' (suc n) ·' y ⟧ ≡⟨ cong ⟦_⟧ $ Int.·-pos-suc n y ⟩\n ⟦ y +' pos' n ·' y ⟧ ≡⟨ isHom+ y _ ⟩\n ⟦ y ⟧ + ⟦ pos' n ·' y ⟧ ≡[ i ]⟨ ⟦ y ⟧ + isHom· (pos' n) y i ⟩\n ⟦ y ⟧ + ⟦ pos' n ⟧ · ⟦ y ⟧ ≡⟨ (λ i → ⟦ y ⟧ + ·-comm ⟦ pos' n ⟧ ⟦ y ⟧ i)\n ∙ sym (·-suc ⟦ y ⟧ ⟦ pos' n ⟧) ∙ ·-comm ⟦ y ⟧ _ ⟩\n sucᵇ ⟦ pos' n ⟧ · ⟦ y ⟧ ∎\n isHom· (negsuc' zero) y =\n ⟦ -1 ·' y ⟧ ≡⟨ cong ⟦_⟧ (Int.·-neg1 y) ⟩\n ⟦ -' y ⟧ ≡⟨ sym (neg-⟦⟧ y) ⟩\n - ⟦ y ⟧ ≡⟨ sym (·-neg1 ⟦ y ⟧) ⟩\n -1 · ⟦ y ⟧ ∎\n isHom· (negsuc' (suc n)) y =\n ⟦ negsuc' (suc n) ·' y ⟧ ≡⟨ cong ⟦_⟧ $ Int.·-negsuc-suc n y ⟩\n ⟦ -' y +' negsuc' n ·' y ⟧ ≡⟨ isHom+ (-' y) _ ⟩\n ⟦ -' y ⟧ + ⟦ negsuc' n ·' y ⟧ ≡[ i ]⟨ ⟦ -' y ⟧ + isHom· (negsuc' n) y i ⟩\n ⟦ -' y ⟧ + ⟦ negsuc' n ⟧ · ⟦ y ⟧ ≡⟨ cong₂ _+_ (sym (neg-⟦⟧ y)) refl ⟩\n - ⟦ y ⟧ + ⟦ negsuc' n ⟧ · ⟦ y ⟧ ≡⟨ (λ i → - ⟦ y ⟧ + ·-comm ⟦ negsuc' n ⟧ ⟦ y ⟧ i)\n ∙ sym (·-pred ⟦ y ⟧ ⟦ negsuc' n ⟧) ∙ ·-comm ⟦ y ⟧ _ ⟩\n pred ⟦ negsuc' n ⟧ · ⟦ y ⟧ ∎\n\n ⟦⟧-isEquiv : isEquiv ⟦_⟧\n ⟦⟧-isEquiv = isoToIsEquiv (iso ⟦_⟧ bwd fwd-bwd bwd-fwd)\n\n Int≃BiInvInt-CommRingEquivΣ : Σ[ e ∈ ⟨ IntAsCommRing ⟩ ≃ ⟨ BiInvIntAsCommRing ⟩ ] CommRingEquiv IntAsCommRing BiInvIntAsCommRing e\n Int≃BiInvInt-CommRingEquivΣ .fst = ⟦_⟧ , ⟦⟧-isEquiv\n Int≃BiInvInt-CommRingEquivΣ .snd = ringequiv pres1 isHom+ isHom·\n\n Int≡BiInvInt-AsCommRing : IntAsCommRing ≡ BiInvIntAsCommRing\n Int≡BiInvInt-AsCommRing = CommRingPath _ _ .fst Int≃BiInvInt-CommRingEquivΣ\n\nmodule _ where\n open import Cubical.HITs.Ints.QuoInt as QuoInt renaming\n ( Int→ℤ to ⟦_⟧\n )\n open import Cubical.Data.Bool\n\n private\n suc-⟦⟧ : ∀ x → sucℤ ⟦ x ⟧ ≡ ⟦ sucInt x ⟧\n suc-⟦⟧ (pos' n) = refl\n suc-⟦⟧ (negsuc' zero) = sym posneg\n suc-⟦⟧ (negsuc' (suc n)) = refl\n\n pred-⟦⟧ : ∀ x → predℤ ⟦ x ⟧ ≡ ⟦ predInt x ⟧\n pred-⟦⟧ (pos' zero) = refl\n pred-⟦⟧ (pos' (suc n)) = refl\n pred-⟦⟧ (negsuc' n) = refl\n\n neg-⟦⟧ : ∀ x → - ⟦ x ⟧ ≡ ⟦ -' x ⟧\n neg-⟦⟧ (pos' zero) = sym posneg\n neg-⟦⟧ (pos' (suc n)) = refl\n neg-⟦⟧ (negsuc' n) = refl\n\n pres1 : 1 ≡ ⟦ 1 ⟧\n pres1 = refl\n\n isHom+ : ∀ x y → ⟦ x +' y ⟧ ≡ ⟦ x ⟧ + ⟦ y ⟧\n isHom+ (pos' zero) y i = ⟦ Int.+-comm 0 y i ⟧\n isHom+ (pos' (suc n)) y =\n ⟦ pos' (suc n) +' y ⟧ ≡[ i ]⟨ ⟦ Int.sucInt+ (pos' n) y (~ i) ⟧ ⟩\n ⟦ sucInt (pos' n +' y) ⟧ ≡⟨ sym $ suc-⟦⟧ _ ⟩\n sucℤ ⟦ pos' n +' y ⟧ ≡[ i ]⟨ sucℤ $ isHom+ (pos' n) y i ⟩\n sucℤ (⟦ pos' n ⟧ + ⟦ y ⟧) ≡⟨ refl ⟩\n sucℤ ⟦ pos' n ⟧ + ⟦ y ⟧ ∎\n isHom+ (negsuc' zero ) y = sucℤ-inj _ _ (suc-⟦⟧ (negsuc' zero +' y)\n ∙ (cong ⟦_⟧ $ Int.sucInt+ (negsuc' zero) y\n ∙ Int.+-identityˡ y)\n ∙ sym (sucPredℤ ⟦ y ⟧))\n isHom+ (negsuc' (suc n)) y = cong ⟦_⟧ (sym (Int.predInt+ (negsuc' n) y))\n ∙ (sym $ pred-⟦⟧ (negsuc' n +' y))\n ∙ (λ i → predℤ $ isHom+ (negsuc' n) y i)\n\n isHom· : ∀ x y → ⟦ x ·' y ⟧ ≡ ⟦ x ⟧ · ⟦ y ⟧\n isHom· (pos' zero) y = (cong ⟦_⟧ $ Int.signed-zero (sgn' y)) ∙ sym (signed-zero (sign ⟦ y ⟧) spos)\n isHom· (pos' (suc n)) y =\n ⟦ pos' (suc n) ·' y ⟧ ≡⟨ cong ⟦_⟧ $ Int.·-pos-suc n y ⟩\n ⟦ y +' pos' n ·' y ⟧ ≡⟨ isHom+ y _ ⟩\n ⟦ y ⟧ + ⟦ pos' n ·' y ⟧ ≡[ i ]⟨ ⟦ y ⟧ + isHom· (pos' n) y i ⟩\n ⟦ y ⟧ + ⟦ pos' n ⟧ · ⟦ y ⟧ ≡⟨ sym $ ·-pos-suc n ⟦ y ⟧ ⟩\n sucℤ ⟦ pos' n ⟧ · ⟦ y ⟧ ∎\n isHom· (negsuc' zero) y =\n ⟦ -1 ·' y ⟧ ≡⟨ cong ⟦_⟧ (Int.·-neg1 y) ⟩\n ⟦ -' y ⟧ ≡⟨ sym (neg-⟦⟧ y) ⟩\n - ⟦ y ⟧ ≡⟨ sym (·-neg1 ⟦ y ⟧) ⟩\n -1 · ⟦ y ⟧ ∎\n isHom· (negsuc' (suc n)) y =\n ⟦ negsuc' (suc n) ·' y ⟧ ≡⟨ cong ⟦_⟧ $ Int.·-negsuc-suc n y ⟩\n ⟦ -' y +' negsuc' n ·' y ⟧ ≡⟨ isHom+ (-' y) _ ⟩\n ⟦ -' y ⟧ + ⟦ negsuc' n ·' y ⟧ ≡[ i ]⟨ ⟦ -' y ⟧ + isHom· (negsuc' n) y i ⟩\n ⟦ -' y ⟧ + ⟦ negsuc' n ⟧ · ⟦ y ⟧ ≡⟨ cong₂ _+_ (sym (neg-⟦⟧ y)) refl ⟩\n - ⟦ y ⟧ + ⟦ negsuc' n ⟧ · ⟦ y ⟧ ≡⟨ sym (·-neg-suc (suc n) ⟦ y ⟧) ⟩\n predℤ ⟦ negsuc' n ⟧ · ⟦ y ⟧ ∎\n\n ⟦⟧-isEquiv : isEquiv ⟦_⟧\n ⟦⟧-isEquiv = isoToIsEquiv (iso ⟦_⟧ ℤ→Int ℤ→Int→ℤ Int→ℤ→Int)\n\n Int≃QuoInt-CommRingEquivΣ : Σ[ e ∈ ⟨ IntAsCommRing ⟩ ≃ ⟨ QuoIntAsCommRing ⟩ ] CommRingEquiv IntAsCommRing QuoIntAsCommRing e\n Int≃QuoInt-CommRingEquivΣ .fst = ⟦_⟧ , ⟦⟧-isEquiv\n Int≃QuoInt-CommRingEquivΣ .snd = ringequiv pres1 isHom+ isHom·\n\n Int≡QuoInt-AsCommRing : IntAsCommRing ≡ QuoIntAsCommRing\n Int≡QuoInt-AsCommRing = CommRingPath _ _ .fst Int≃QuoInt-CommRingEquivΣ\n\nQuoInt≡BiInvInt-AsCommRing : QuoIntAsCommRing ≡ BiInvIntAsCommRing\nQuoInt≡BiInvInt-AsCommRing = sym Int≡QuoInt-AsCommRing ∙ Int≡BiInvInt-AsCommRing\n\nopen import Cubical.HITs.SetQuotients\n\nmodule _ where\n open import Cubical.Data.Sigma\n open import Cubical.Data.Bool\n open import Cubical.Data.Nat using (ℕ) renaming (_·_ to _·ⁿ_)\n open import Cubical.HITs.Rationals.QuoQ using (ℚ) renaming (_+_ to _+ʳ_)\n open import Cubical.HITs.Ints.QuoInt using (ℤ; sign; signed; abs) renaming (_+_ to _+ᶻ_)\n open import Cubical.Data.NatPlusOne using (ℕ₊₁; 1+_)\n\n test1 : ℤ → _\n test1 x = {! x +ᶻ x !}\n -- Normal form:\n -- x +ᶻ x\n\n test2 : ℤ × ℕ₊₁ → _\n test2 x = {! [ x ] +ʳ [ x ] !}\n -- Normal form:\n -- [ signed (sign (fst x) ⊕ false) (abs (fst x) ·ⁿ suc (ℕ₊₁.n (snd x)))\n -- +ᶻ signed (sign (fst x) ⊕ false) (abs (fst x) ·ⁿ suc (ℕ₊₁.n (snd x)))\n -- , (1+ (ℕ₊₁.n (snd x) +ⁿ ℕ₊₁.n (snd x) ·ⁿ suc (ℕ₊₁.n (snd x))))\n -- ]\n\n test3 : ℚ → ℤ × ℕ₊₁ → _\n test3 x y = {! x +ʳ [ y ] !}\n -- Normal form:\n -- rec\n -- (λ f g F G i j z →\n -- squash/ (f z) (g z) (λ i₁ → F i₁ z) (λ i₁ → G i₁ z) i j)\n -- (λ a → ...\n -- ...\n -- ... 2000 more lines ...\n\nopen import Cubical.Data.DiffInt as DiffInt hiding (_+'_; _·'_)\n\n⟦⟧-isEquiv : isEquiv ⟦_⟧\n⟦⟧-isEquiv = isoToIsEquiv (iso ⟦_⟧ bwd fwd-bwd bwd-fwd)\n\npres1 : 1 ≡ ⟦ 1 ⟧\npres1 = refl\n\nisHom+ : ∀ x y → ⟦ x +' y ⟧ ≡ ⟦ x ⟧ + ⟦ y ⟧\nisHom+ (pos' zero) y = {! !}\nisHom+ (pos' (suc n)) y = {! !} -- ? ∙ λ i → sucℤ (isHom+ (pos' n) y i)\nisHom+ (negsuc' zero) y = {! [ 0 , 1 ] + ⟦ y ⟧ !}\nisHom+ (negsuc' (suc n)) y = {! !}\n\nisHom· : ∀ x y → ⟦ x ·' y ⟧ ≡ ⟦ x ⟧ · ⟦ y ⟧\nisHom· = {! !}\n\nInt≃DiffInt-CommRingEquivΣ : Σ[ e ∈ ⟨ IntAsCommRing ⟩ ≃ ⟨ DiffIntAsCommRing ⟩ ] CommRingEquiv IntAsCommRing DiffIntAsCommRing e\nInt≃DiffInt-CommRingEquivΣ .fst = ⟦_⟧ , ⟦⟧-isEquiv\nInt≃DiffInt-CommRingEquivΣ .snd = ringequiv pres1 isHom+ isHom·\n\nInt≡DiffInt-AsCommRing : IntAsCommRing ≡ DiffIntAsCommRing\nInt≡DiffInt-AsCommRing = CommRingPath _ _ .fst Int≃DiffInt-CommRingEquivΣ\n\nDiffInt≡BiInvInt-AsCommRing : DiffIntAsCommRing ≡ BiInvIntAsCommRing\nDiffInt≡BiInvInt-AsCommRing = sym Int≡DiffInt-AsCommRing ∙ Int≡BiInvInt-AsCommRing\n", "meta": {"hexsha": "27199ca54561cff38b2a09dd8b8d3b1b64fbcc62", "size": 10938, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommRing/Integers.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/Algebra/CommRing/Integers.agda", "max_issues_repo_name": "mchristianl/cubical", "max_issues_repo_head_hexsha": "cc6ad25d5ffbe4f20ea7020474f266d24b97caa0", "max_issues_repo_licenses": ["MIT"], "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/Integers.agda", "max_forks_repo_name": "mchristianl/cubical", "max_forks_repo_head_hexsha": "cc6ad25d5ffbe4f20ea7020474f266d24b97caa0", "max_forks_repo_licenses": ["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.6501766784, "max_line_length": 132, "alphanum_fraction": 0.5069482538, "num_tokens": 5260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867873410141, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.583521302911741}} {"text": "-- Andreas, 2016-06-01, issue 1997 reported by Andres\n\n{-# OPTIONS --rewriting #-}\n\ninfix 4 _≡_\ninfixl 6 _+_\n\ndata _≡_ {a} {A : Set a} (x : A) : A → Set a where\n refl : x ≡ x\n\n{-# BUILTIN REWRITE _≡_ #-}\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\ndata ℕ : Set where\n zero : ℕ\n suc : (n : ℕ) → ℕ\n\n_+_ : ℕ → ℕ → ℕ\nzero + m = m\nsuc n + m = suc (n + m)\n\nplus0 : (x : ℕ) → x + zero ≡ x\nplus0 zero = refl\nplus0 (suc x) = cong suc (plus0 x)\n\n{-# REWRITE plus0 #-}\n{-# REWRITE plus0 #-}\n\n-- Should complain about duplicate rewrite rule\n", "meta": {"hexsha": "e01f9afc9bd9bc35a097c2d07bcc7c2257efe559", "size": 599, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1997.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/Issue1997.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/Issue1997.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": 18.1515151515, "max_line_length": 53, "alphanum_fraction": 0.5258764608, "num_tokens": 247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5834494915878592}} {"text": "module Data.Lens.Proofs.LensLaws where\n\nopen import Haskell.Prelude renaming (zero to Z; suc to S)\nopen import Data.Lens.Lens\nopen import Data.Logic\nopen import Agda.Primitive\n\n\n-- First, define the lens laws\n\nViewSet : {a b : Set} -> (l : Lens a b) -> Set\nViewSet {a} {b} l = (v : b) (s : a) -> view l (set l v s) ≡ v\n\nSetView : {a b : Set} -> (l : Lens a b) -> Set\nSetView {a} {b} l = (s : a) -> set l (view l s) s ≡ s\n\nSetSet : {a b : Set} -> (l : Lens a b) -> Set\nSetSet {a} {b} l = (v1 v2 : b) (s : a) -> set l v2 (set l v1 s) ≡ set l v2 s\n\n-- Define ValidLens as a lens for which the laws hold\n\ndata ValidLens (a b : Set) : Set₁ where\n CValidLens : (l : Lens a b) -> ViewSet l -> SetView l -> SetSet l -> ValidLens a b\n\ntoLens : ValidLens a b -> Lens a b\ntoLens (CValidLens l _ _ _) = l\n", "meta": {"hexsha": "20f152bdfa894d785a75ecb2c120ec8a5cfde202", "size": 794, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Lens/Proofs/LensLaws.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/LensLaws.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/LensLaws.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": 29.4074074074, "max_line_length": 84, "alphanum_fraction": 0.6020151134, "num_tokens": 299, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297941266014, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.5833615836015635}} {"text": "{-# OPTIONS --rewriting #-}\n\nopen import Agda.Primitive\n\npostulate\n _↦_ : ∀{i j}{A : Set i}{B : Set j} → A → B → Set (i ⊔ j)\n\n{-# BUILTIN REWRITE _↦_ #-} -- currently fails a sanity check\n\npostulate\n resize : ∀{i j} → Set i → Set j\n resize-id : ∀{i} {j} {A : Set i} → resize {i} {j} A ↦ A\n\n{-# REWRITE resize-id #-}\n\n-- Impredicative quantification\n\nForall : ∀{i} (F : Set i → Set) → Set\nForall {i} F = resize ((X : Set i) → F X)\n\n-- Example: Impredicative encoding of natural numbers\n\nNat = Forall λ X → (X → X) → X → X\n\nzero : Nat\nzero X s z = z\n\nsuc : Nat → Nat\nsuc n X s z = s (n X s z)\n\n-- requires impredicativity:\n\nid : Nat → Nat\nid n = n Nat suc zero\n", "meta": {"hexsha": "22648cd63d1de3a6957823f9a4b8efdd055c4ba8", "size": 663, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/HeterogeneousRewriting.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/HeterogeneousRewriting.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/HeterogeneousRewriting.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": 18.9428571429, "max_line_length": 62, "alphanum_fraction": 0.5761689291, "num_tokens": 248, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314858927011, "lm_q2_score": 0.6584175005616829, "lm_q1q2_score": 0.5831152693602016}} {"text": "module Miscellaneous.TFlipFlop where\n\nopen import Data.Boolean\nimport Data.Boolean.Operators\nopen Data.Boolean.Operators.Logic\nopen import Data.Boolean.Numeral\nopen import Numeral.Natural\nopen import Syntax.Number\n\ntFlipFlop : Bool → (ℕ → Bool) → (ℕ → Bool)\ntFlipFlop init T(𝟎) = init\ntFlipFlop init T(𝐒(n)) = T(n) ⊕ tFlipFlop init T(n)\n\nopen import Data\nopen import Relator.Equals\n\nmodule _ where\n postulate Q₀ : ℕ → Bool\n postulate Q₁ : ℕ → Bool\n\n postulate f : Bool → Bool\n postulate g : Bool → Bool\n\n postulate q₀0 : Q₀(0) ≡ 1\n postulate q₁0 : Q₁(0) ≡ 1\n\n postulate q₀1 : Q₀(1) ≡ 0\n postulate q₁1 : Q₁(1) ≡ 1\n\n postulate q₀2 : Q₀(2) ≡ 1\n postulate q₁2 : Q₁(2) ≡ 0\n\n postulate q₀3 : Q₀(3) ≡ 0\n postulate q₁3 : Q₁(3) ≡ 0\n\n postulate q₀4 : Q₀(4) ≡ Q₀(0)\n postulate q₁4 : Q₁(4) ≡ Q₁(0)\n\n {-# REWRITE q₀0 q₁0 q₀1 q₁1 q₀2 q₁2 q₀3 q₁3 q₀4 q₁4 #-}\n\n private variable n : ℕ\n\n postulate q₀step : Q₀(𝐒 n) ≡ f(Q₁(n)) ⊕ Q₀(n)\n postulate q₁step : Q₁(𝐒 n) ≡ g(Q₀(n)) ⊕ Q₁(n)\n\n open import Numeral.Natural.Oper\n open import Relator.Equals.Proofs\n open import Structure.Function\n open import Structure.Operator\n open import Syntax.Transitivity\n\n q₀cyclic : Q₀(n + 4) ≡ Q₀(n)\n q₁cyclic : Q₁(n + 4) ≡ Q₁(n)\n\n q₀cyclic {𝟎} = [≡]-intro\n q₀cyclic {𝐒 n} =\n Q₀ (𝐒 n + 4) 🝖[ _≡_ ]-[]\n Q₀ (𝐒(n + 4)) 🝖[ _≡_ ]-[ q₀step{n + 4} ]\n f(Q₁(n + 4)) ⊕ Q₀(n + 4) 🝖[ _≡_ ]-[ congruence₂(_⊕_) (congruence₁(f) (q₁cyclic{n})) (q₀cyclic{n}) ]\n f(Q₁(n)) ⊕ Q₀(n) 🝖[ _≡_ ]-[ q₀step{n} ]-sym\n Q₀ (𝐒 n) 🝖-end\n\n q₁cyclic {𝟎} = [≡]-intro\n q₁cyclic {𝐒 n} =\n Q₁ (𝐒 n + 4) 🝖[ _≡_ ]-[]\n Q₁ (𝐒(n + 4)) 🝖[ _≡_ ]-[ q₁step{n + 4} ]\n g(Q₀(n + 4)) ⊕ Q₁(n + 4) 🝖[ _≡_ ]-[ congruence₂(_⊕_) (congruence₁(g) (q₀cyclic{n})) (q₁cyclic{n}) ]\n g(Q₀(n)) ⊕ Q₁(n) 🝖[ _≡_ ]-[ q₁step{n} ]-sym\n Q₁ (𝐒 n) 🝖-end\n\n f0 : f(0) ≡ 1\n f0 with f(0) | q₀step{2}\n ... | 𝑇 | q = [≡]-intro\n\n f1 : f(1) ≡ 1\n f1 with f(1) | q₀step{0}\n ... | 𝑇 | q = [≡]-intro\n\n f1' : f(1) ≡ 1\n f1' with f(1) | q₀step{1}\n ... | 𝑇 | q = [≡]-intro\n\n f1'' : f(1) ≡ 1\n f1'' with f(1) | q₀step{0}\n ... | 𝑇 | q = [≡]-intro\n\n\n\n g1 : g(1) ≡ 0\n g1 with g(1) | q₁step{0}\n ... | 𝐹 | q = [≡]-intro\n\n g0 : g(0) ≡ 1\n g0 with g(0) | q₁step{1}\n ... | 𝑇 | q = [≡]-intro\n\n g1' : g(1) ≡ 0\n g1' with g(1) | q₁step{2}\n ... | 𝐹 | q = [≡]-intro\n\n g1'' : g(0) ≡ 1\n g1'' with g(0) | q₁step{3}\n ... | 𝑇 | q = [≡]-intro\n", "meta": {"hexsha": "6750e3c414aad35c7127bbd6488f9b07cd9e5185", "size": 2514, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Miscellaneous/TFlipFlop.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": "Miscellaneous/TFlipFlop.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": "Miscellaneous/TFlipFlop.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.1730769231, "max_line_length": 106, "alphanum_fraction": 0.5099443119, "num_tokens": 1249, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84594244507642, "lm_q2_score": 0.6893056295505784, "lm_q1q2_score": 0.5831128896669573}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra.Structures.Bundles.Field\n\nmodule Algebra.Linear.Morphism.Bundles\n {k ℓᵏ} (K : Field k ℓᵏ)\n where\n\nopen import Algebra.FunctionProperties as FP\nopen import Relation.Binary using (Rel; Setoid)\nopen import Level\n\nimport Algebra.Linear.Structures.Bundles as VS\n\nopen import Algebra.Linear.Morphism.VectorSpace K\n\nopen import Function.Equality as FunEq using (_⟶_; _⟨$⟩_; setoid)\n\nmodule _\n {a₁ ℓ₁} (From : VS.VectorSpace K a₁ ℓ₁)\n {a₂ ℓ₂} (To : VS.VectorSpace K a₂ ℓ₂)\n where\n\n private\n module F = VS.VectorSpace From\n module T = VS.VectorSpace To\n\n K' : Set k\n K' = Field.Carrier K\n\n open F using ()\n renaming\n ( Carrier to A\n ; _≈_ to _≈₁_\n ; refl to ≈₁-refl\n ; sym to ≈₁-sym\n ; setoid to A-setoid\n ; _+_ to +₁\n ; _∙_ to ∙₁\n )\n\n open T using ()\n renaming\n ( Carrier to B\n ; _≈_ to _≈₂_\n ; refl to ≈₂-refl\n ; sym to ≈₂-sym\n ; trans to ≈₂-trans\n ; setoid to B-setoid\n ; _+_ to +₂\n ; _∙_ to ∙₂\n )\n\n hom-setoid : ∀ {Carrier} -> (Carrier -> (A-setoid ⟶ B-setoid))\n -> Setoid (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) (a₁ ⊔ ℓ₁ ⊔ ℓ₂)\n hom-setoid {Carrier} app = record\n { Carrier = Carrier\n ; _≈_ = λ f g → ∀ {x y} (r : x ≈₁ y) -> (app f ⟨$⟩ x) ≈₂ (app g ⟨$⟩ y)\n ; isEquivalence = record\n { refl = λ {f} -> FunEq.cong (app f)\n ; sym = λ r rₓ → ≈₂-sym (r (≈₁-sym rₓ))\n ; trans = λ r₁ r₂ rₓ → ≈₂-trans (r₁ ≈₁-refl) (r₂ rₓ)\n }\n }\n\n open LinearDefinitions A B _≈₂_\n\n record LinearMap : Set (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) where\n field\n ⟦_⟧ : Morphism\n isLinearMap : IsLinearMap From To ⟦_⟧\n\n infixr 25 _⟪$⟫_\n _⟪$⟫_ : A -> B\n _⟪$⟫_ = ⟦_⟧\n\n open IsLinearMap isLinearMap public\n\n linearMap-setoid : Setoid (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) (a₁ ⊔ ℓ₁ ⊔ ℓ₂)\n linearMap-setoid = hom-setoid {LinearMap} λ f → record\n { _⟨$⟩_ = λ x → f LinearMap.⟪$⟫ x\n ; cong = LinearMap.⟦⟧-cong f\n }\n\n record LinearIsomorphism : Set (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) where\n field\n ⟦_⟧ : Morphism\n isLinearIsomorphism : IsLinearIsomorphism From To ⟦_⟧\n\n open IsLinearIsomorphism isLinearIsomorphism public\n\n linearMap : LinearMap\n linearMap = record { ⟦_⟧ = ⟦_⟧ ; isLinearMap = isLinearMap }\n\n open LinearMap linearMap public\n using (_⟪$⟫_)\n\n linearIsomorphism-setoid : Setoid (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) (a₁ ⊔ ℓ₁ ⊔ ℓ₂)\n linearIsomorphism-setoid = hom-setoid {LinearIsomorphism} λ f → record\n { _⟨$⟩_ = λ x -> f LinearIsomorphism.⟪$⟫ x\n ; cong = LinearIsomorphism.⟦⟧-cong f\n }\n\nmodule _ {a ℓ} (V : VS.VectorSpace K a ℓ) where\n LinearEndomorphism : Set (suc (k ⊔ a ⊔ ℓ))\n LinearEndomorphism = LinearMap V V\n\n LinearAutomorphism : Set (suc (k ⊔ a ⊔ ℓ))\n LinearAutomorphism = LinearIsomorphism V V\n", "meta": {"hexsha": "067630df9447bfd41a9358cb807979fd2c942d68", "size": 2991, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Morphism/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/Morphism/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/Morphism/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": 27.1909090909, "max_line_length": 86, "alphanum_fraction": 0.5543296556, "num_tokens": 1151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424411924673, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5831128761911596}} {"text": "open import FRP.LTL.RSet.Core using ( RSet ; ⟦_⟧ )\nopen import FRP.LTL.RSet.Stateless using ( _⇒_ )\nopen import FRP.LTL.Time using ( _≤_ ; ≤-refl ; _≤-trans_ )\n\nmodule FRP.LTL.RSet.Globally where\n\n-- □ A is \"A holds globally in the future\"\n\n□ : RSet → RSet\n□ A t = ∀ {u} → (t ≤ u) → A u\n\n-- Comonad structure of □\n\nextend : ∀ {A B} → ⟦ A ⇒ B ⟧ → ⟦ □ A ⇒ □ B ⟧\nextend f a s≤t = f (a s≤t)\n\nextract : ∀ {A} → ⟦ □ A ⇒ A ⟧\nextract a = a ≤-refl\n\nduplicate : ∀ {A} → ⟦ □ A ⇒ □ (□ A) ⟧\nduplicate a s≤t t≤u = a (s≤t ≤-trans t≤u)\n\n-- Applicative structure of □\n\n[_] : ∀ {A} → ⟦ A ⟧ → ⟦ □ A ⟧\n[ a ] s≤t = a\n\n_⟨*⟩_ : ∀ {A B} → ⟦ □ (A ⇒ B) ⇒ □ A ⇒ □ B ⟧\n(f ⟨*⟩ a) s≤t = f s≤t (a s≤t)", "meta": {"hexsha": "c07a160a3ac72845e782d230464d4ba04dc90821", "size": 670, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FRP/LTL/RSet/Globally.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/Globally.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/Globally.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": 23.1034482759, "max_line_length": 59, "alphanum_fraction": 0.4940298507, "num_tokens": 340, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085145, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.5831128627153618}} {"text": "import Lvl\nopen import Structure.Operator.Vector\nopen import Structure.Setoid\nopen import Type\n\nmodule Structure.Operator.Vector.Subspaces.DirectSum\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 as Tuple using (_,_)\nopen import Logic.Propositional\nopen import Logic.Predicate\nimport Lvl\nopen import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator)\nopen import Structure.Container.SetLike using (SetElement)\nprivate open module SetLikeFunctionProperties{ℓ} = Structure.Container.SetLike.FunctionProperties{C = PredSet{ℓ}(V)}{E = V}(_∈_)\nopen import Structure.Operator\nopen import Structure.Operator.Proofs.Util\nopen import Structure.Operator.Properties\nopen import Structure.Operator.Vector\nopen import Structure.Operator.Vector.Subspace ⦃ vectorSpace = vectorSpace ⦄\nopen import Syntax.Transitivity\n\nprivate variable ℓ ℓ₁ ℓ₂ ℓₗ : Lvl.Level\n\nmodule _ where\n module _ where\n -- TODO: This operator can also be constructed for vector spaces, not just subspaces\n _+ˢᵘᵇ_ : SubspaceObject{ℓ₁} → SubspaceObject{ℓ₂} → SubspaceObject\n ([∃]-intro V₁ ⦃ p₁ ⦄) +ˢᵘᵇ ([∃]-intro V₂ ⦃ p₂ ⦄) = [∃]-intro (PredSet.map₂(_+ᵥ_) V₁ V₂) ⦃ p ⦄ where\n p : Subspace(PredSet.map₂(_+ᵥ_) V₁ V₂)\n ∃.witness (Structure.Container.SetLike.FunctionProperties._closed-under₂_.proof (Subspace.add-closure p) ([∃]-intro(a₁ , a₂)) ([∃]-intro(b₁ , b₂))) = ((a₁ +ᵥ b₁) , (a₂ +ᵥ b₂))\n ∃.proof (Structure.Container.SetLike.FunctionProperties._closed-under₂_.proof (Subspace.add-closure p) {a}{b} ([∃]-intro ([∧]-intro a₁ a₂) ⦃ [∧]-intro ([∧]-intro a₁V₁ a₂V₂) a₁a₂a ⦄) ([∃]-intro (b₁ , b₂) ⦃ [∧]-intro ([∧]-intro b₁V₁ b₂V₂) b₁b₂b ⦄)) = [∧]-intro ([∧]-intro l₁ l₂) r where\n l₁ : (a₁ +ᵥ b₁) ∈ V₁\n l₁ = (V₁ closureUnder₂(_+ᵥ_)) a₁V₁ b₁V₁\n l₂ : (a₂ +ᵥ b₂) ∈ V₂\n l₂ = (V₂ closureUnder₂(_+ᵥ_)) a₂V₂ b₂V₂\n r : (a₁ +ᵥ b₁) +ᵥ (a₂ +ᵥ b₂) ≡ a +ᵥ b\n r =\n (a₁ +ᵥ b₁) +ᵥ (a₂ +ᵥ b₂) 🝖[ _≡_ ]-[ One.associate-commute4-c {_▫_ = _+ᵥ_} ⦃ op = [+ᵥ]-binary-operator ⦄ ⦃ assoc = [+ᵥ]-associativity ⦄ ⦃ comm = [+ᵥ]-commutativity ⦄ ] -- TODO: Why are the instances not inferred?\n (a₁ +ᵥ a₂) +ᵥ (b₁ +ᵥ b₂) 🝖[ _≡_ ]-[ congruence₂(_+ᵥ_) ⦃ [+ᵥ]-binary-operator ⦄ a₁a₂a b₁b₂b ]\n a +ᵥ b 🝖-end\n ∃.witness (Structure.Container.SetLike.FunctionProperties._closed-under₁_.proof (Subspace.mul-closure p {s}) ([∃]-intro(v₁ , v₂))) = ((s ⋅ₛᵥ v₁) , (s ⋅ₛᵥ v₂))\n ∃.proof (Structure.Container.SetLike.FunctionProperties._closed-under₁_.proof (Subspace.mul-closure p {s}) {v} ([∃]-intro(v₁ , v₂) ⦃ [∧]-intro ([∧]-intro v₁V₁ v₂V₂) v₁v₂v ⦄)) = [∧]-intro ([∧]-intro l₁ l₂) r where\n l₁ : (s ⋅ₛᵥ v₁) ∈ V₁\n l₁ = (V₁ closureUnder₁(s ⋅ₛᵥ_)) v₁V₁\n l₂ : (s ⋅ₛᵥ v₂) ∈ V₂\n l₂ = (V₂ closureUnder₁(s ⋅ₛᵥ_)) v₂V₂\n r : (s ⋅ₛᵥ v₁) +ᵥ (s ⋅ₛᵥ v₂) ≡ (s ⋅ₛᵥ v)\n r =\n (s ⋅ₛᵥ v₁) +ᵥ (s ⋅ₛᵥ v₂) 🝖[ _≡_ ]-[ distributivityₗ(_⋅ₛᵥ_)(_+ᵥ_) ]-sym\n s ⋅ₛᵥ (v₁ +ᵥ v₂) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅ₛᵥ_)(s) v₁v₂v ]\n s ⋅ₛᵥ v 🝖-end\n\n -- TODO: Formulate\n -- [⊕ˢᵘᵇ]-span-vectorSpace : (V₁ ⊕ V₂ ⊕ … ≡ₛ 𝐔) ↔ (∀{v₁}{v₂}{…} → (v₁ ∈ V₁) → (v₂ ∈ V₂) → … → (v₁ + v₂ + … ≡ 𝟎ᵥ) → ((v₁ ≡ 𝟎ᵥ) ∧ (v₂ ≡ 𝟎ᵥ) ∧ …))\n -- [⊕ˢᵘᵇ]-span-existence-finite-space : Finite → ∃(\\{(V₁ , V₂ , …) → V₁ ⊕ V₂ ⊕ … ≡ₛ 𝐔}) -- TODO: Just take the \"standard\" \"axis aligned\" subspaces\n", "meta": {"hexsha": "283ed7e05f05afbd25496e60aaab6560815f4514", "size": 3635, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Vector/Subspaces/DirectSum.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/Subspaces/DirectSum.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/Subspaces/DirectSum.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": 55.0757575758, "max_line_length": 290, "alphanum_fraction": 0.601650619, "num_tokens": 1726, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.849971175657575, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.583037270171886}} {"text": "\nmodule Issue442 where\n\npostulate\n A : Set\n f : (P : A → A → Set) → (∀ {x} → P x x) →\n (∀ {x y z} → P y z → P x y → A) → A\n P : A → A → Set\n reflP : ∀ {x} → P x x\n g : ∀ {x y z} → P y z → P x y → A\n\na : A\na = f _ (λ {x} → reflP {x}) g\n\n-- Test case was:\n-- {-# OPTIONS --allow-unsolved-metas #-}\n-- a = f _ reflP g\n", "meta": {"hexsha": "330b542b33e6a21fbeaed20f5188d4fd4a80c915", "size": 325, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue442.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/Issue442.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/Issue442.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.0555555556, "max_line_length": 43, "alphanum_fraction": 0.4276923077, "num_tokens": 150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8499711908591638, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.583037269685608}} {"text": "{-# OPTIONS --cubical #-}\n\nmodule Type.Cubical.InductivePath where\n\nopen import Functional\nimport Lvl\nopen import Type\nimport Type.Cubical as Cubical\nopen import Type.Cubical.InductiveInterval\n\nprivate variable ℓ : Lvl.Level\nprivate variable A B P : Type{ℓ}\nprivate variable x y z : A\n\ndata Path {P : Type{ℓ}} : P → P → Type{ℓ} where\n intro : (p : Interval → P) → Path(p(𝟎)) (p(𝟏))\n\npoint : (x : P) → Path x x\npoint x = intro(const x)\n\npointOn : ∀{x y : A} → Path x y → (Interval → A)\npointOn (intro p) = p\n\nreverse : Path x y → Path y x\nreverse(intro f) = intro(f ∘ flip)\n\nspaceMap : Path A B → (A → B)\nspaceMap (intro p) = transp p\n\n{-\nconcat : Path x y → Path y z → Path x z\nconcat xy yz = {!xy yz!}\n-}\n\nmodule _ where\n private variable X : Type{ℓ}\n private variable Y : X → Type{ℓ}\n\n {- TODO: Define an eliminator for Path and use it to prove this?\n mapping : ∀{f g : (x : X) → Y(x)} → (∀{x} → Path(f(x)) (g(x))) → Path f g\n mapping {X = X}{Y = Y}{f = f}{g = g} ppt = intro(i ↦ x ↦ {!pointOn(ppt{x}) i!}) where\n p : (∀{x} → Path(f(x)) (g(x))) → Interval → (x : X) → Y(x)\n p ppt i x with ppt{x}\n ... | q = {!q!}\n -}\n \n mappingPoint : ∀{f g : (x : X) → Y(x)} → Path f g → (∀{x} → Path(f(x)) (g(x)))\n mappingPoint (intro pfg) {x} = intro (i ↦ pfg i x)\n\nmodule _ where\n private variable X X₁ X₂ Y Y₁ Y₂ : Type{ℓ}\n\n map : (f : X → Y) → ∀{a b} → Path a b → Path (f(a)) (f(b))\n map f (intro ab) = intro(f ∘ ab)\n\n liftedSpaceMap : (S : X → Type{ℓ}) → ∀{a b} → Path a b → S(a) → S(b)\n liftedSpaceMap S p = spaceMap(map S p)\n", "meta": {"hexsha": "f412892be2ca2388dd54b2917f32d7fc60b749c5", "size": 1553, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Cubical/InductivePath.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/InductivePath.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/InductivePath.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": 26.775862069, "max_line_length": 87, "alphanum_fraction": 0.5653573728, "num_tokens": 592, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583695, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.5830372644718472}} {"text": "------------------------------------------------------------------------\n-- A virtual machine\n------------------------------------------------------------------------\n\nmodule Lambda.VirtualMachine where\n\nopen import Category.Monad\nopen import Category.Monad.Partiality as P\n using (_⊥; never); open P._⊥\nopen import Codata.Musical.Notation\nopen import Data.Empty using (⊥-elim)\nopen import Data.Fin\nopen import Data.List hiding (lookup)\nopen import Data.Maybe\nopen import Data.Nat\nopen import Data.Product as Prod\nopen import Data.Vec using (Vec; []; _∷_; lookup)\nopen import Function.Base\nimport Level\nopen import Relation.Binary.Construct.Closure.ReflexiveTransitive\n hiding (return)\nopen import Relation.Binary.PropositionalEquality as PE using (_≡_)\nopen import Relation.Nullary\n\nopen RawMonad (P.monad {f = Level.zero})\n\nopen import Lambda.Syntax\nprivate module C = Closure Tm\n\n------------------------------------------------------------------------\n-- Instruction set\n\nmutual\n\n -- Instructions.\n\n data Instr (n : ℕ) : Set where\n var : (x : Fin n) → Instr n\n con : (i : ℕ) → Instr n\n clo : (c : Code (suc n)) → Instr n\n app : Instr n\n ret : Instr n\n\n -- Code.\n\n Code : ℕ → Set\n Code n = List (Instr n)\n\n-- Environments and values.\n\nopen Closure Code\n\n------------------------------------------------------------------------\n-- Compiler\n\n-- The compiler takes a code continuation.\n\ncomp : ∀ {n} → Tm n → Code n → Code n\ncomp (con i) c = con i ∷ c\ncomp (var x) c = var x ∷ c\ncomp (ƛ t) c = clo (comp t [ ret ]) ∷ c\ncomp (t₁ · t₂) c = comp t₁ (comp t₂ (app ∷ c))\n\n-- Environments and values can also be compiled.\n\nmutual\n\n comp-env : ∀ {n} → C.Env n → Env n\n comp-env [] = []\n comp-env (v ∷ ρ) = comp-val v ∷ comp-env ρ\n\n comp-val : C.Value → Value\n comp-val (C.con i) = con i\n comp-val (C.ƛ t ρ) = ƛ (comp t [ ret ]) (comp-env ρ)\n\n-- lookup x is homomorphic with respect to comp-env/comp-val.\n\nlookup-hom : ∀ {n} (x : Fin n) ρ →\n lookup (comp-env ρ) x ≡ comp-val (lookup ρ x)\nlookup-hom zero (v ∷ ρ) = PE.refl\nlookup-hom (suc x) (v ∷ ρ) = lookup-hom x ρ\n\n------------------------------------------------------------------------\n-- Stacks and states\n\n-- Stacks.\n\ndata StackElement : Set where\n val : (v : Value) → StackElement\n ret : ∀ {n} (c : Code n) (ρ : Env n) → StackElement\n\nStack : Set\nStack = List StackElement\n\n-- States.\n\ndata State : Set where\n ⟨_,_,_⟩ : ∀ {n} (c : Code n) (s : Stack) (ρ : Env n) → State\n\n------------------------------------------------------------------------\n-- Relational semantics of the VM\n\nmodule Relational where\n\n infix 4 _⟶_\n\n data _⟶_ : State → State → Set where\n var : ∀ {n} {x : Fin n} {c s ρ} →\n ⟨ var x ∷ c , s , ρ ⟩ ⟶ ⟨ c , val (lookup ρ x) ∷ s , ρ ⟩\n con : ∀ {n i} {c : Code n} {s ρ} →\n ⟨ con i ∷ c , s , ρ ⟩ ⟶ ⟨ c , val (con i) ∷ s , ρ ⟩\n clo : ∀ {n} {c : Code n} {c′ s ρ} →\n ⟨ clo c′ ∷ c , s , ρ ⟩ ⟶ ⟨ c , val (ƛ c′ ρ) ∷ s , ρ ⟩\n app : ∀ {n} {c : Code n} {v n′} {c′ : Code (suc n′)} {ρ′ s ρ} →\n ⟨ app ∷ c , val v ∷ val (ƛ c′ ρ′) ∷ s , ρ ⟩ ⟶ ⟨ c′ , ret c ρ ∷ s , v ∷ ρ′ ⟩\n ret : ∀ {n} {c : Code n} {v n′} {c′ : Code n′} {ρ′ s ρ} →\n ⟨ ret ∷ c , val v ∷ ret c′ ρ′ ∷ s , ρ ⟩ ⟶ ⟨ c′ , val v ∷ s , ρ′ ⟩\n\n -- Final (stuck) states.\n\n Final : State → Set\n Final s = ∄ λ s′ → s ⟶ s′\n\n -- s ⇓ v means that s is a successful final state, and that the\n -- corresponding value is v.\n\n infix 4 _⇓_\n\n data _⇓_ : State → Value → Set where\n final : ∀ {v} → ⟨ [] , val v ∷ [] , [] ⟩ ⇓ v\n\n -- Sanity check.\n\n ⇓-final : ∀ {s v} → s ⇓ v → Final s\n ⇓-final final (_ , ())\n\n -- Crashing stuck states.\n\n Stuck : State → Set\n Stuck s = Final s × ∄ (λ v → s ⇓ v)\n\n -- Reflexive transitive closure.\n\n infix 4 _⟶⋆_\n\n _⟶⋆_ : State → State → Set\n _⟶⋆_ = Star _⟶_\n\n -- Infinite sequences of steps.\n\n infixr 5 _◅_\n infix 4 _⟶∞\n\n data _⟶∞ : State → Set where\n _◅_ : ∀ {s₁ s₂} (s₁⟶s₂ : s₁ ⟶ s₂) (s₂⟶∞ : ∞ (s₂ ⟶∞)) → s₁ ⟶∞\n\n -- A variant of _⟶∞ which is easier to use.\n\n module InfiniteSequence where\n\n infix 4 _⟶∞′\n infix 3 _⟶∞⟨_⟩\n infixr 2 _⟶⟨_⟩′_ _⟶⋆⟨_⟩′_\n\n data _⟶∞′ : State → Set where\n _⟶⟨_⟩′_ : ∀ s₁ {s₂} (s₁⟶s₂ : s₁ ⟶ s₂) (s₂⟶∞ : ∞ (s₂ ⟶∞′)) → s₁ ⟶∞′\n _⟶⋆⟨_⟩′_ : ∀ s₁ {s₂} (s₁⟶⋆s₂ : s₁ ⟶⋆ s₂) (s₂⟶∞ : s₂ ⟶∞′) → s₁ ⟶∞′\n _⟶∞⟨_⟩ : ∀ s (s⟶∞ : s ⟶∞′) → s ⟶∞′\n\n sound : ∀ {s} → s ⟶∞′ → s ⟶∞\n sound (s₁ ⟶⟨ s₁⟶s₂ ⟩′ s₂⟶∞) = s₁⟶s₂ ◅ ♯ (sound (♭ s₂⟶∞))\n sound (s ⟶⋆⟨ ε ⟩′ s⟶∞) = sound s⟶∞\n sound (s₁ ⟶⋆⟨ s₁⟶s₂ ◅ s₂⟶⋆s₃ ⟩′ s₃⟶∞) = s₁⟶s₂ ◅ ♯ (sound (_ ⟶⋆⟨ s₂⟶⋆s₃ ⟩′ s₃⟶∞))\n sound (s ⟶∞⟨ s⟶∞ ⟩) = sound s⟶∞\n\n complete : ∀ {s} → s ⟶∞ → s ⟶∞′\n complete (s₁⟶s₂ ◅ s₂⟶∞) = _ ⟶⟨ s₁⟶s₂ ⟩′ ♯ complete (♭ s₂⟶∞)\n\n------------------------------------------------------------------------\n-- Functional semantics of the VM\n\nmodule Functional where\n\n -- The result of running the VM one step.\n\n data Result : Set where\n continue : (s : State) → Result\n done : (v : Value) → Result\n crash : Result\n\n -- A single step of the computation.\n\n step : State → Result\n step ⟨ [] , val v ∷ [] , [] ⟩ = done v\n step ⟨ var x ∷ c , s , ρ ⟩ = continue ⟨ c , val (lookup ρ x) ∷ s , ρ ⟩\n step ⟨ con i ∷ c , s , ρ ⟩ = continue ⟨ c , val (con i) ∷ s , ρ ⟩\n step ⟨ clo c′ ∷ c , s , ρ ⟩ = continue ⟨ c , val (ƛ c′ ρ) ∷ s , ρ ⟩\n step ⟨ app ∷ c , val v ∷ val (ƛ c′ ρ′) ∷ s , ρ ⟩ = continue ⟨ c′ , ret c ρ ∷ s , v ∷ ρ′ ⟩\n step ⟨ ret ∷ c , val v ∷ ret c′ ρ′ ∷ s , ρ ⟩ = continue ⟨ c′ , val v ∷ s , ρ′ ⟩\n step _ = crash\n\n -- The VM.\n\n exec : State → Maybe Value ⊥\n exec s with step s\n ... | continue s′ = later (♯ exec s′)\n ... | done v = return (just v)\n ... | crash = return nothing\n\n -- Equality for partial computations returning Maybe Value.\n --\n -- Note that propositional equality is used for the underlying\n -- values, which can include code components. In other words, if\n -- v₁ ≈ v₂, then any code components in these values have to be\n -- /syntactically/ equal.\n\n module Equality where\n\n private\n open module PEq {A : Set} = P.Equality {A = A} _≡_ public\n using (_≈_; now; later; laterˡ)\n\n open P public using (later⁻¹; now≉never)\n\n module EqReasoning {A : Set} = P.Reasoning {A = A} PE.isEquivalence\n\n------------------------------------------------------------------------\n-- Equivalence proof\n\nmodule Equivalence where\n\n open Relational\n open Functional\n open Functional.Equality\n\n ----------------------------------------------------------------------\n -- Classification of states\n\n -- Inductive characterisation of states which are stuck and not\n -- final.\n\n data Crashing : State → Set where\n crash₁ : ∀ {n ρ} → Crashing (⟨_,_,_⟩ { n} [] [] ρ )\n crash₂ : ∀ {n n′ c ρ′ s ρ} → Crashing (⟨_,_,_⟩ { n} [] ( ret {n′} c ρ′ ∷ s ) ρ )\n crash₃ : ∀ {n v e s ρ} → Crashing (⟨_,_,_⟩ { n} [] (val v ∷ e ∷ s ) ρ )\n crash₄ : ∀ {n v₁ v₂ ρ} → Crashing (⟨_,_,_⟩ {suc n} [] ( val v₁ ∷ []) (v₂ ∷ ρ))\n crash₅ : ∀ {n c ρ} → Crashing (⟨_,_,_⟩ { n} (app ∷ c) [] ρ )\n crash₆ : ∀ {n c v ρ} → Crashing (⟨_,_,_⟩ { n} (app ∷ c) ( val v ∷ []) ρ )\n crash₇ : ∀ {n c n′ c′ ρ′ s ρ} → Crashing (⟨_,_,_⟩ { n} (app ∷ c) ( ret {n′} c′ ρ′ ∷ s ) ρ )\n crash₈ : ∀ {n c v i s ρ} → Crashing (⟨_,_,_⟩ { n} (app ∷ c) (val v ∷ val (con i) ∷ s ) ρ )\n crash₉ : ∀ {n c v n′ c′ ρ′ s ρ} → Crashing (⟨_,_,_⟩ { n} (app ∷ c) (val v ∷ ret {n′} c′ ρ′ ∷ s ) ρ )\n crash₁₀ : ∀ {n c ρ} → Crashing (⟨_,_,_⟩ { n} (ret ∷ c) [] ρ )\n crash₁₁ : ∀ {n c v ρ} → Crashing (⟨_,_,_⟩ { n} (ret ∷ c) ( val v ∷ []) ρ )\n crash₁₂ : ∀ {n c n′ c′ ρ′ s ρ} → Crashing (⟨_,_,_⟩ { n} (ret ∷ c) ( ret {n′} c′ ρ′ ∷ s ) ρ )\n crash₁₃ : ∀ {n c v₁ v₂ s ρ} → Crashing (⟨_,_,_⟩ { n} (ret ∷ c) (val v₁ ∷ val v₂ ∷ s ) ρ )\n\n -- There are three kinds of states.\n\n data Kind (s : State) : Set where\n done : ∀ {v} (s⇓v : s ⇓ v) → Kind s\n continue : ∀ {s′} (s⟶s′ : s ⟶ s′) → Kind s\n crash : (s↯ : Crashing s) → Kind s\n\n -- We can assign (at least) one kind to every state.\n\n kind : ∀ s → Kind s\n kind ⟨ [] , val v ∷ [] , [] ⟩ = done final\n kind ⟨ var x ∷ c , s , ρ ⟩ = continue var\n kind ⟨ con i ∷ c , s , ρ ⟩ = continue con\n kind ⟨ clo c′ ∷ c , s , ρ ⟩ = continue clo\n kind ⟨ app ∷ c , val v ∷ val (ƛ c′ ρ′) ∷ s , ρ ⟩ = continue app\n kind ⟨ ret ∷ c , val v ∷ ret c′ ρ′ ∷ s , ρ ⟩ = continue ret\n\n kind ⟨ [] , [] , _ ⟩ = crash crash₁\n kind ⟨ [] , ret _ _ ∷ _ , _ ⟩ = crash crash₂\n kind ⟨ [] , val _ ∷ _ ∷ _ , _ ⟩ = crash crash₃\n kind ⟨ [] , val _ ∷ [] , _ ∷ _ ⟩ = crash crash₄\n kind ⟨ app ∷ _ , [] , _ ⟩ = crash crash₅\n kind ⟨ app ∷ _ , val _ ∷ [] , _ ⟩ = crash crash₆\n kind ⟨ app ∷ _ , ret _ _ ∷ _ , _ ⟩ = crash crash₇\n kind ⟨ app ∷ _ , val _ ∷ val (con _) ∷ _ , _ ⟩ = crash crash₈\n kind ⟨ app ∷ _ , val _ ∷ ret _ _ ∷ _ , _ ⟩ = crash crash₉\n kind ⟨ ret ∷ _ , [] , _ ⟩ = crash crash₁₀\n kind ⟨ ret ∷ _ , val _ ∷ [] , _ ⟩ = crash crash₁₁\n kind ⟨ ret ∷ _ , ret _ _ ∷ _ , _ ⟩ = crash crash₁₂\n kind ⟨ ret ∷ _ , val _ ∷ val _ ∷ _ , _ ⟩ = crash crash₁₃\n\n -- The functional semantics crashes for crashing states.\n\n exec-crashes : ∀ {s} → Crashing s → exec s ≈ return nothing\n exec-crashes crash₁ = now PE.refl\n exec-crashes crash₂ = now PE.refl\n exec-crashes crash₃ = now PE.refl\n exec-crashes crash₄ = now PE.refl\n exec-crashes crash₅ = now PE.refl\n exec-crashes crash₆ = now PE.refl\n exec-crashes crash₇ = now PE.refl\n exec-crashes crash₈ = now PE.refl\n exec-crashes crash₉ = now PE.refl\n exec-crashes crash₁₀ = now PE.refl\n exec-crashes crash₁₁ = now PE.refl\n exec-crashes crash₁₂ = now PE.refl\n exec-crashes crash₁₃ = now PE.refl\n\n -- The relational semantics also crashes for crashing states.\n\n ⟶-crashes : ∀ {s} → Crashing s → Stuck s\n ⟶-crashes s↯ = (helper₁ s↯ , helper₂ s↯)\n where\n helper₁ : ∀ {s} → Crashing s → Final s\n helper₁ crash₁ (_ , ())\n helper₁ crash₂ (_ , ())\n helper₁ crash₃ (_ , ())\n helper₁ crash₄ (_ , ())\n helper₁ crash₅ (_ , ())\n helper₁ crash₆ (_ , ())\n helper₁ crash₇ (_ , ())\n helper₁ crash₈ (_ , ())\n helper₁ crash₉ (_ , ())\n helper₁ crash₁₀ (_ , ())\n helper₁ crash₁₁ (_ , ())\n helper₁ crash₁₂ (_ , ())\n helper₁ crash₁₃ (_ , ())\n\n helper₂ : ∀ {s} → Crashing s → ∄ λ v → s ⇓ v\n helper₂ crash₁ (_ , ())\n helper₂ crash₂ (_ , ())\n helper₂ crash₃ (_ , ())\n helper₂ crash₄ (_ , ())\n helper₂ crash₅ (_ , ())\n helper₂ crash₆ (_ , ())\n helper₂ crash₇ (_ , ())\n helper₂ crash₈ (_ , ())\n helper₂ crash₉ (_ , ())\n helper₂ crash₁₀ (_ , ())\n helper₂ crash₁₁ (_ , ())\n helper₂ crash₁₂ (_ , ())\n helper₂ crash₁₃ (_ , ())\n\n ----------------------------------------------------------------------\n -- The relational semantics is sound with respect to the functional\n -- one\n\n -- Note that these proofs implicitly establish that the relational\n -- semantics is deterministic.\n\n ⇒⇓ : ∀ {s s′ v} → s ⟶⋆ s′ → s′ ⇓ v → exec s ≈ return (just v)\n ⇒⇓ ε final = now PE.refl\n ⇒⇓ (var ◅ s⟶⋆) ⇓ = laterˡ (⇒⇓ s⟶⋆ ⇓)\n ⇒⇓ (con ◅ s⟶⋆) ⇓ = laterˡ (⇒⇓ s⟶⋆ ⇓)\n ⇒⇓ (clo ◅ s⟶⋆) ⇓ = laterˡ (⇒⇓ s⟶⋆ ⇓)\n ⇒⇓ (app ◅ s⟶⋆) ⇓ = laterˡ (⇒⇓ s⟶⋆ ⇓)\n ⇒⇓ (ret ◅ s⟶⋆) ⇓ = laterˡ (⇒⇓ s⟶⋆ ⇓)\n\n ⇒⇑ : ∀ {s} → s ⟶∞ → exec s ≈ never\n ⇒⇑ (var ◅ s⟶∞) = later (♯ (⇒⇑ (♭ s⟶∞)))\n ⇒⇑ (con ◅ s⟶∞) = later (♯ (⇒⇑ (♭ s⟶∞)))\n ⇒⇑ (clo ◅ s⟶∞) = later (♯ (⇒⇑ (♭ s⟶∞)))\n ⇒⇑ (app ◅ s⟶∞) = later (♯ (⇒⇑ (♭ s⟶∞)))\n ⇒⇑ (ret ◅ s⟶∞) = later (♯ (⇒⇑ (♭ s⟶∞)))\n\n ⇒↯ : ∀ {s} → ∃ (λ s′ → s ⟶⋆ s′ × Stuck s′) → exec s ≈ return nothing\n ⇒↯ (_ , var ◅ s⟶⋆ , ↯) = laterˡ (⇒↯ (_ , s⟶⋆ , ↯))\n ⇒↯ (_ , con ◅ s⟶⋆ , ↯) = laterˡ (⇒↯ (_ , s⟶⋆ , ↯))\n ⇒↯ (_ , clo ◅ s⟶⋆ , ↯) = laterˡ (⇒↯ (_ , s⟶⋆ , ↯))\n ⇒↯ (_ , app ◅ s⟶⋆ , ↯) = laterˡ (⇒↯ (_ , s⟶⋆ , ↯))\n ⇒↯ (_ , ret ◅ s⟶⋆ , ↯) = laterˡ (⇒↯ (_ , s⟶⋆ , ↯))\n ⇒↯ (s , ε , ↯) with kind s\n ... | done s⇓v = ⊥-elim (proj₂ ↯ (-, s⇓v))\n ... | continue s₁⟶s₂ = ⊥-elim (proj₁ ↯ (-, s₁⟶s₂))\n ... | crash s↯ = exec-crashes s↯\n\n ----------------------------------------------------------------------\n -- The relational semantics is complete with respect to the\n -- functional one\n\n ⇐⇓ : ∀ {s v} → exec s ≈ return (just v) → ∃ λ s′ → s ⟶⋆ s′ × s′ ⇓ v\n ⇐⇓ {s = s} ⇓ with kind s\n ⇐⇓ (now PE.refl) | done final = (_ , ε , final)\n ⇐⇓ (laterˡ ⇓) | continue var = Prod.map id (Prod.map (_◅_ var) id) (⇐⇓ ⇓)\n ⇐⇓ (laterˡ ⇓) | continue con = Prod.map id (Prod.map (_◅_ con) id) (⇐⇓ ⇓)\n ⇐⇓ (laterˡ ⇓) | continue clo = Prod.map id (Prod.map (_◅_ clo) id) (⇐⇓ ⇓)\n ⇐⇓ (laterˡ ⇓) | continue app = Prod.map id (Prod.map (_◅_ app) id) (⇐⇓ ⇓)\n ⇐⇓ (laterˡ ⇓) | continue ret = Prod.map id (Prod.map (_◅_ ret) id) (⇐⇓ ⇓)\n ⇐⇓ {s} {v} ⇓ | crash s↯ with\n return (just v) ≈⟨ sym ⇓ ⟩\n exec s ≈⟨ exec-crashes s↯ ⟩\n return nothing ∎\n where open EqReasoning\n ... | now ()\n\n ⇐⇑ : ∀ {s} → exec s ≈ never → s ⟶∞\n ⇐⇑ {s = s} ⇑ with kind s\n ⇐⇑ ⇑ | done final = ⊥-elim (now≉never ⇑)\n ⇐⇑ ⇑ | continue var = var ◅ ♯ ⇐⇑ (later⁻¹ ⇑)\n ⇐⇑ ⇑ | continue con = con ◅ ♯ ⇐⇑ (later⁻¹ ⇑)\n ⇐⇑ ⇑ | continue clo = clo ◅ ♯ ⇐⇑ (later⁻¹ ⇑)\n ⇐⇑ ⇑ | continue app = app ◅ ♯ ⇐⇑ (later⁻¹ ⇑)\n ⇐⇑ ⇑ | continue ret = ret ◅ ♯ ⇐⇑ (later⁻¹ ⇑)\n ⇐⇑ {s} ⇑ | crash s↯ = ⊥-elim (now≉never (\n return nothing ≈⟨ sym $ exec-crashes s↯ ⟩\n exec s ≈⟨ ⇑ ⟩\n never ∎))\n where open EqReasoning\n\n ⇐↯ : ∀ {s} → exec s ≈ return nothing → ∃ λ s′ → s ⟶⋆ s′ × Stuck s′\n ⇐↯ {s = s} ↯ with kind s\n ⇐↯ (now ()) | done final\n ⇐↯ (laterˡ ↯) | continue var = Prod.map id (Prod.map (_◅_ var) id) $ ⇐↯ ↯\n ⇐↯ (laterˡ ↯) | continue con = Prod.map id (Prod.map (_◅_ con) id) $ ⇐↯ ↯\n ⇐↯ (laterˡ ↯) | continue clo = Prod.map id (Prod.map (_◅_ clo) id) $ ⇐↯ ↯\n ⇐↯ (laterˡ ↯) | continue app = Prod.map id (Prod.map (_◅_ app) id) $ ⇐↯ ↯\n ⇐↯ (laterˡ ↯) | continue ret = Prod.map id (Prod.map (_◅_ ret) id) $ ⇐↯ ↯\n ⇐↯ ↯ | crash s↯ = (_ , ε , ⟶-crashes s↯)\n", "meta": {"hexsha": "ecab07c5e2e3ff92fe1104c0c1e2bfb8f1502ed4", "size": 15020, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lambda/VirtualMachine.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": "Lambda/VirtualMachine.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": "Lambda/VirtualMachine.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": 36.1927710843, "max_line_length": 115, "alphanum_fraction": 0.4410785619, "num_tokens": 6177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711794579723, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.583037261864967}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Lexicographic induction\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Induction.Lexicographic where\n\nopen import Data.Product\nopen import Induction\nopen import Level\n\n-- The structure of lexicographic induction.\n\nΣ-Rec : ∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : A → Set b} →\n RecStruct A (ℓ₁ ⊔ b) ℓ₂ → (∀ x → RecStruct (B x) ℓ₁ ℓ₃) →\n RecStruct (Σ A B) _ _\nΣ-Rec RecA RecB P (x , y) =\n -- Either x is constant and y is \"smaller\", ...\n RecB x (λ y' → P (x , y')) y\n ×\n -- ...or x is \"smaller\" and y is arbitrary.\n RecA (λ x' → ∀ y' → P (x' , y')) x\n\n_⊗_ : ∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : Set b} →\n RecStruct A (ℓ₁ ⊔ b) ℓ₂ → RecStruct B ℓ₁ ℓ₃ →\n RecStruct (A × B) _ _\nRecA ⊗ RecB = Σ-Rec RecA (λ _ → RecB)\n\n-- Constructs a recursor builder for lexicographic induction.\n\nΣ-rec-builder :\n ∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : A → Set b}\n {RecA : RecStruct A (ℓ₁ ⊔ b) ℓ₂}\n {RecB : ∀ x → RecStruct (B x) ℓ₁ ℓ₃} →\n RecursorBuilder RecA → (∀ x → RecursorBuilder (RecB x)) →\n RecursorBuilder (Σ-Rec RecA RecB)\nΣ-rec-builder {RecA = RecA} {RecB = RecB} recA recB P f (x , y) =\n (p₁ x y p₂x , p₂x)\n where\n p₁ : ∀ x y →\n RecA (λ x' → ∀ y' → P (x' , y')) x →\n RecB x (λ y' → P (x , y')) y\n p₁ x y x-rec = recB x\n (λ y' → P (x , y'))\n (λ y y-rec → f (x , y) (y-rec , x-rec))\n y\n\n p₂ : ∀ x → RecA (λ x' → ∀ y' → P (x' , y')) x\n p₂ = recA (λ x → ∀ y → P (x , y))\n (λ x x-rec y → f (x , y) (p₁ x y x-rec , x-rec))\n\n p₂x = p₂ x\n\n[_⊗_] : ∀ {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : Set b}\n {RecA : RecStruct A (ℓ₁ ⊔ b) ℓ₂} {RecB : RecStruct B ℓ₁ ℓ₃} →\n RecursorBuilder RecA → RecursorBuilder RecB →\n RecursorBuilder (RecA ⊗ RecB)\n[ recA ⊗ recB ] = Σ-rec-builder recA (λ _ → recB)\n\n------------------------------------------------------------------------\n-- Example\n\nprivate\n\n open import Data.Nat\n open import Induction.Nat as N\n\n -- The Ackermann function à la Rózsa Péter.\n\n ackermann : ℕ → ℕ → ℕ\n ackermann m n =\n build [ N.recBuilder ⊗ N.recBuilder ]\n (λ _ → ℕ)\n (λ { (zero , n) _ → 1 + n\n ; (suc m , zero) (_ , ackm•) → ackm• 1\n ; (suc m , suc n) (ack[1+m]n , ackm•) → ackm• ack[1+m]n\n })\n (m , n)\n", "meta": {"hexsha": "bfa30777eaf75ec27b9d722039bea801c4576c60", "size": 2504, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Induction/Lexicographic.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/Induction/Lexicographic.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/Induction/Lexicographic.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.5365853659, "max_line_length": 72, "alphanum_fraction": 0.4536741214, "num_tokens": 943, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711756575749, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.5830372592580864}} {"text": "{-# OPTIONS --without-K --safe #-}\nmodule Source.Type where\n\nopen import Source.Size as S using\n ( Size ; Δ ; Δ′ ; Δ″ ; Ω ; Ω′ ; Ω″ ; n ; m ; o ; p ; b )\nopen import Source.Size.Substitution.Canonical as SC using\n ( Sub⊢ )\nopen import Source.Size.Substitution.Theory\nopen import Source.Size.Substitution.Universe as SU using\n ( σ ; τ ; ι ; ⟨_⟩ )\nopen import Util.Prelude\n\nopen S.Ctx\n\n\ninfixr 3 Π_,_\ninfixr 4 _⇒_\ninfixl 4 _∙_\n\n\ndata Type (Δ : S.Ctx) : Set where\n Nat : (n : Size Δ) → Type Δ\n Stream : (n : Size Δ) → Type Δ\n _⇒_ : (T U : Type Δ) → Type Δ\n Π_,_ : (n : Size Δ) (T : Type (Δ ∙ n)) → Type Δ\n\n\nvariable T U V W T′ U′ V′ W′ : Type Δ\n\n\nΠ-≡⁺ : ∀ {n m} {T : Type (Δ ∙ n)} {U : Type (Δ ∙ m)}\n → (n≡m : n ≡ m)\n → subst (λ n → Type (Δ ∙ n)) n≡m T ≡ U\n → (Π n , T) ≡ (Π m , U)\nΠ-≡⁺ refl refl = refl\n\n\ndata Ctx (Δ : S.Ctx) : Set where\n [] : Ctx Δ\n _∙_ : (Γ : Ctx Δ) (T : Type Δ) → Ctx Δ\n\n\nvariable Γ Γ′ Γ″ Ψ Ψ′ Ψ″ : Ctx Δ\n\n\nsub : SC.Sub Δ Ω → Type Ω → Type Δ\nsub σ (Nat n) = Nat (SC.sub σ n)\nsub σ (Stream n) = Stream (SC.sub σ n)\nsub σ (T ⇒ U) = sub σ T ⇒ sub σ U\nsub σ (Π n , T) = Π SC.sub σ n , sub (SC.Lift σ) T\n\n\nabstract\n sub->> : ∀ {Δ Δ′ Δ″} (σ : SC.Sub Δ Δ′) (τ : SC.Sub Δ′ Δ″) T\n → sub (σ SC.>> τ) T ≡ sub σ (sub τ T)\n sub->> σ τ (Nat n) = cong Nat (SC.sub->> n refl)\n sub->> σ τ (Stream n) = cong Stream (SC.sub->> n refl)\n sub->> σ τ (T ⇒ U) = cong₂ _⇒_ (sub->> σ τ T) (sub->> σ τ U)\n sub->> σ τ (Π n , T)\n rewrite SC.sub->> {σ = σ} {τ} n refl\n = cong (λ T → Π SC.sub σ (SC.sub τ n) , T)\n (trans (cong (λ σ → sub σ T) (sym SC.Lift>>Lift))\n (sub->> (SC.Lift σ) (SC.Lift τ) T))\n\n\n sub-Id : (T : Type Δ) → sub SC.Id T ≡ T\n sub-Id (Nat n) = cong Nat (SC.sub-Id n refl)\n sub-Id (Stream n) = cong Stream (SC.sub-Id n refl)\n sub-Id (T ⇒ U) = cong₂ _⇒_ (sub-Id T) (sub-Id U)\n sub-Id (Π n , T)\n rewrite SC.sub-Id n refl\n = cong (λ T → Π n , T) (sub-Id T)\n\n\ninstance\n SubTheory-Type : SubTheory Type\n SubTheory-Type = record\n { _[_] = λ T σ → sub σ T\n ; [Id] = sub-Id\n ; [>>] = sub->>\n }\n\n\nsubΓ : SC.Sub Δ Ω → Ctx Ω → Ctx Δ\nsubΓ σ [] = []\nsubΓ σ (Γ ∙ T) = subΓ σ Γ ∙ sub σ T\n\n\nabstract\n subΓ->> : ∀ (σ : SC.Sub Δ Δ′) (τ : SC.Sub Δ′ Δ″) Γ\n → subΓ (σ SC.>> τ) Γ ≡ subΓ σ (subΓ τ Γ)\n subΓ->> σ τ [] = refl\n subΓ->> σ τ (Γ ∙ T) = cong₂ _∙_ (subΓ->> σ τ Γ) (sub->> σ τ T)\n\n\n subΓ-Id : (Γ : Ctx Δ) → subΓ SC.Id Γ ≡ Γ\n subΓ-Id [] = refl\n subΓ-Id (Γ ∙ T) = cong₂ _∙_ (subΓ-Id Γ) (sub-Id T)\n\n\ninstance\n SubTheory-Ctx : SubTheory Ctx\n SubTheory-Ctx = record\n { _[_] = λ Γ σ → subΓ σ Γ\n ; [Id] = subΓ-Id\n ; [>>] = subΓ->>\n }\n", "meta": {"hexsha": "f24a5261592a0996c5c26c8671d18b5cbcc0a3ed", "size": 2606, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Source/Type.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/Source/Type.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/Source/Type.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": 24.1296296296, "max_line_length": 64, "alphanum_fraction": 0.5080583269, "num_tokens": 1198, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711794579723, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.5830372564080671}} {"text": "{-# OPTIONS --cubical --no-import-sorts #-}\n\nopen import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)\nopen import Function.Base using (_∋_; _$_)\nimport Cubical.Algebra.Monoid as Std\nopen import MorePropAlgebra.Bundles\n\nmodule MorePropAlgebra.Properties.Monoid {ℓ} (assumptions : Monoid {ℓ}) where\nopen Monoid assumptions renaming (Carrier to F)\n\nimport MorePropAlgebra.Properties.Semigroup\nmodule Semigroup'Properties = MorePropAlgebra.Properties.Semigroup (record { Monoid assumptions })\nmodule Semigroup' = Semigroup (record { Monoid assumptions })\n( Semigroup') = Semigroup ∋ (record { Monoid assumptions })\n\nstdIsMonoid : Std.IsMonoid ε _·_\nstdIsMonoid .Std.IsMonoid.isSemigroup = Semigroup'Properties.stdIsSemigroup\nstdIsMonoid .Std.IsMonoid.identity = is-identity\n\nstdMonoid : Std.Monoid {ℓ}\nstdMonoid = record { Monoid assumptions ; isMonoid = stdIsMonoid }\n", "meta": {"hexsha": "8c3ed2466fe57b65049d4ee7a959516dd7a69bcc", "size": 980, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/MorePropAlgebra/Properties/Monoid.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/Monoid.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/Monoid.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": 44.5454545455, "max_line_length": 100, "alphanum_fraction": 0.7112244898, "num_tokens": 261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970842359876, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.5830197449119802}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Group.Construct.Unit where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Algebra.Group\nopen import Cubical.Data.Prod using (_,_)\n\nopen import Cubical.Data.Unit\n\nimport Cubical.Algebra.Monoid.Construct.Unit as ⊤Monoid\nopen ⊤Monoid public hiding (⊤-isMonoid; ⊤-Monoid)\n\ninv : Op₁ ⊤\ninv _ = tt\n\n⊤-inverseˡ : LeftInverse tt inv _◯_\n⊤-inverseˡ _ = refl\n\n⊤-inverseʳ : RightInverse tt inv _◯_\n⊤-inverseʳ _ = refl\n\n⊤-inverse : Inverse tt inv _◯_\n⊤-inverse = ⊤-inverseˡ , ⊤-inverseʳ\n\n\n⊤-isGroup : IsGroup ⊤ _◯_ tt inv\n⊤-isGroup = record\n { isMonoid = ⊤Monoid.⊤-isMonoid\n ; inverse = ⊤-inverse\n }\n\n⊤-Group : Group ℓ-zero\n⊤-Group = record { isGroup = ⊤-isGroup }\n", "meta": {"hexsha": "ee2cddc479c34b250eafdc9b1cd2607ebc6c2b8c", "size": 781, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/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/Group/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/Group/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": 22.3142857143, "max_line_length": 55, "alphanum_fraction": 0.709346991, "num_tokens": 294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970748488296, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.5830197386984056}} {"text": "open import Mockingbird.Forest using (Forest)\n\nmodule Mockingbird.Forest.Combination.Base {b ℓ} (forest : Forest {b} {ℓ}) where\n\nopen import Level using (Level; _⊔_)\nopen import Relation.Unary using (Pred; _∈_)\n\nopen Forest forest\n\nprivate\n variable\n p : Level\n x y z : Bird\n P : Pred Bird p\n\n-- If P is a set of birds, we can think of ⟨ P ⟩ as the set of birds ‘generated\n-- by’ P.\ndata ⟨_⟩ (P : Pred Bird p) : Pred Bird (p ⊔ b ⊔ ℓ) where\n [_] : (x∈P : x ∈ P) → x ∈ ⟨ P ⟩\n\n _⟨∙⟩_∣_ :\n (x∈⟨P⟩ : x ∈ ⟨ P ⟩)\n → (y∈⟨P⟩ : y ∈ ⟨ P ⟩)\n → (xy≈z : x ∙ y ≈ z)\n → z ∈ ⟨ P ⟩\n\ninfixl 6 _⟨∙⟩_\n_⟨∙⟩_ : x ∈ ⟨ P ⟩ → y ∈ ⟨ P ⟩ → x ∙ y ∈ ⟨ P ⟩\n_⟨∙⟩_ = _⟨∙⟩_∣ refl\n", "meta": {"hexsha": "07367cb192b9c61cbe99879641a589fc8a23d1ab", "size": 673, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Mockingbird/Forest/Combination/Base.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/Combination/Base.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/Combination/Base.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": 22.4333333333, "max_line_length": 80, "alphanum_fraction": 0.5215453195, "num_tokens": 306, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.880797068590724, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.583019722807611}} {"text": "-- This is a selection of useful function\n-- from the standard library that we tend to use a lot.\nmodule Prelude where\n\n open import Data.Nat\n hiding (_⊔_)\n public\n\n open import Level\n renaming (suc to lsuc; zero to ℓ0)\n public\n\n open import Relation.Binary.PropositionalEquality\n renaming ([_] to Reveal[_] )\n public\n\n open import Relation.Unary\n public\n\n open import Data.Unit\n using (⊤; tt)\n public\n\n open import Data.Sum\n public\n\n open import Data.Nat.Properties\n public\n\n open import Relation.Nullary\n hiding (Irrelevant)\n public\n\n open import Data.Product\n using (_×_; proj₁; proj₂; Σ; _,_; ∃; Σ-syntax; ∃-syntax)\n public\n\n open import Data.Empty\n using (⊥; ⊥-elim)\n public\n\n open import Function\n using (_∘_)\n public\n\n open import Data.List.Relation.Unary.Any\n using (Any; here; there)\n public\n\n\n", "meta": {"hexsha": "294afd93527e4a3b47c9c932d612662c1773c891", "size": 878, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude.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/Prelude.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/Prelude.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": 17.2156862745, "max_line_length": 60, "alphanum_fraction": 0.6628701595, "num_tokens": 248, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8376199795472731, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.5829486032624585}} {"text": "------------------------------------------------------------------------------\n-- Natural numbers (added for the Collatz function example)\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\n-- We don't want populate the FOTC library with more first-order logic\n-- axioms.\n\nmodule FOTC.Program.Collatz.Data.Nat where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat\nopen import FOTC.Data.Nat.Inequalities\nopen import FOTC.Data.Nat.UnaryNumbers\n\ninfixr 8 _^_\n\n------------------------------------------------------------------------------\n\npostulate\n div : D → D → D\n div-xx : n > x) → Binding n x\n\ninspectBinding : ∀ n x → Binding n x\ninspectBinding n x with n ≤? x \n... | yes p = Free p\n... | no ¬p = Bound (≰⇒> ¬p)\n\n\n--------------------------------------------------------------------------------\n-- lifiting variables\n\nlift-var : (n i x : ℕ) → ℕ \nlift-var n i x with inspectBinding n x\n... | Free _ = i + x -- free \n... | Bound _ = x -- bound \n\n--------------------------------------------------------------------------------\n-- properties of lift-var\n\nopen import Relation.Binary.PropositionalEquality hiding ([_])\n\nmodule EQ where \n open ≡-Reasoning\n\n twist : ∀ l m n → l + (m + n) ≡ m + (l + n)\n twist l m n = \n begin\n l + (m + n)\n ≡⟨ sym (+-assoc l m n) ⟩ \n l + m + n\n ≡⟨ cong (_+ n) (+-comm l m) ⟩ \n m + l + n\n ≡⟨ +-assoc m l n ⟩ \n m + (l + n)\n ∎\n\n l+m+n≡m+x : ∀ l m n x → l + n ≡ x → l + m + n ≡ m + x\n l+m+n≡m+x l m n x l+n≡x = \n begin\n l + m + n\n ≡⟨ +-assoc l m n ⟩ \n l + (m + n)\n ≡⟨ twist l m n ⟩ \n m + (l + n)\n ≡⟨ cong (m +_) l+n≡x ⟩ \n m + x\n ∎\n\nmodule INEQ where \n open ≤-Reasoning\n\n m+n≰x+m : ∀ {m n x} → n ≰ x → m + n > x + m\n m+n≰x+m {m} {n} {x} n≰x = begin \n suc x + m \n ≡⟨ +-comm (suc x) m ⟩ \n m + suc x\n ≤⟨ +-monoʳ-≤ m (≰⇒> n≰x) ⟩ \n m + n \n ∎\n\n m+n≤x+m : ∀ {m n x} → n ≤ x → m + n ≤ x + m\n m+n≤x+m {m} {n} {x} n≤x = begin \n m + n \n ≤⟨ +-monoʳ-≤ m n≤x ⟩ \n m + x \n ≡⟨ +-comm m x ⟩ \n x + m \n ∎\n l+n≤n+i+x : ∀ l n i x → l ≤ x → l + n ≤ n + i + x\n l+n≤n+i+x l n i x l≤x = \n begin\n l + n\n ≤⟨ +-monoˡ-≤ n l≤x ⟩ \n x + n\n ≤⟨ m≤n+m (x + n) i ⟩ \n i + (x + n)\n ≡⟨ cong (i +_) (+-comm x n) ⟩ \n i + (n + x)\n ≡⟨ sym (+-assoc i n x) ⟩ \n i + n + x\n ≡⟨ cong (_+ x) (+-comm i n) ⟩ \n n + i + x\n ∎\n\n l+m+n≤m+x : ∀ l m n x → l + n ≤ x → l + m + n ≤ m + x\n l+m+n≤m+x l m n x l+n≤x = \n begin\n l + m + n\n ≡⟨ +-assoc l m n ⟩ \n l + (m + n)\n ≡⟨ EQ.twist l m n ⟩ \n m + (l + n)\n ≤⟨ +-monoʳ-≤ m l+n≤x ⟩ \n m + x\n ∎\n\n l+m+n>m+x : ∀ l m n x → l + n > x → l + m + n > m + x\n l+m+n>m+x l m n x l+n>x = \n begin\n suc m + x\n ≡⟨ sym (+-suc m x) ⟩ \n m + suc x\n ≤⟨ +-monoʳ-≤ m l+n>x ⟩ \n m + (l + n)\n ≡⟨ EQ.twist m l n ⟩ \n l + (m + n)\n ≡⟨ sym (+-assoc l m n) ⟩ \n l + m + n\n ∎\n\n\n l+m+n>x : ∀ l m n x → l > x → l + m + n > x\n l+m+n>x l m n x l>x = \n begin\n suc x\n ≤⟨ l>x ⟩ \n l\n ≤⟨ m≤m+n l m ⟩ \n l + m\n ≤⟨ m≤m+n (l + m) n ⟩ \n l + m + n\n ∎\n\nopen import Relation.Nullary.Negation using (contradiction)\nopen ≡-Reasoning\n\nlift-var-≤ : ∀ {n i x} → n ≤ x → lift-var n i x ≡ i + x\nlift-var-≤ {n} {i} {x} n≤x with inspectBinding n x \n... | Free ≤x = refl\n... | Bound >x = contradiction n≤x (<⇒≱ >x)\n\n\nlift-var-> : ∀ {n i x} → n > x → lift-var n i x ≡ x \nlift-var-> {n} {i} {x} n>x with inspectBinding n x \n... | Free ≤x = contradiction n>x (≤⇒≯ ≤x)\n... | Bound >x = refl\n\n-- lift-var-+ : ∀ n i x m → lift-var (m + n) i (x + m) ≡ lift-var n i x + m\n-- lift-var-+ n i x m with inspectBinding n x \n-- ... | Bound >x =\n-- lift-var (m + n) i (x + m) \n-- ≡⟨ lift-var-> (INEQ.m+n≰x+m (<⇒≱ >x)) ⟩ \n-- x + m \n-- ∎\n-- ... | Free ≤x = \n-- lift-var (m + n) i (x + m) \n-- ≡⟨ lift-var-≤ {m + n} {i} {x + m} (INEQ.m+n≤x+m ≤x) ⟩ \n-- i + (x + m) \n-- ≡⟨ sym (+-assoc i x m) ⟩ \n-- i + x + m\n-- ∎\n\n\n-- lift-var (l + n) i\n-- ∙ --------------------------> ∙\n-- | |\n-- | |\n-- lift-var l m lift-var l m\n-- | |\n-- ∨ ∨ \n-- ∙ --------------------------> ∙\n-- lift-var (l + m + n) i\n\nlift-var-lift-var : ∀ l m n i x → lift-var l m (lift-var (l + n) i x) ≡ lift-var (l + m + n) i (lift-var l m x)\nlift-var-lift-var l m n i x with inspectBinding l x | inspectBinding (l + n) x\n... | Free l≤x | Free l+n≤x =\n lift-var l m (i + x)\n ≡⟨ lift-var-≤ (≤-trans l≤x (m≤n+m x i)) ⟩ \n m + (i + x)\n ≡⟨ EQ.twist m i x ⟩ \n i + (m + x)\n ≡⟨ sym (lift-var-≤ (INEQ.l+m+n≤m+x l m n x l+n≤x)) ⟩ \n lift-var (l + m + n) i (m + x)\n ∎\n... | Free l≤x | Bound l+n>x = \n lift-var l m x\n ≡⟨ lift-var-≤ l≤x ⟩ \n m + x\n ≡⟨ sym (lift-var-> (INEQ.l+m+n>m+x l m n x l+n>x)) ⟩ \n lift-var (l + m + n) i (m + x)\n ∎\n... | Bound l>x | Free l+n≤x = contradiction (≤-trans (m≤m+n l n) l+n≤x) (<⇒≱ l>x)\n... | Bound l>x | Bound l+n>x =\n lift-var l m x\n ≡⟨ lift-var-> l>x ⟩ \n x\n ≡⟨ sym (lift-var-> (INEQ.l+m+n>x l m n x l>x)) ⟩ \n lift-var (l + m + n) i x\n ∎\n\n\n-- lift-var l (n + i)\n-- ∙ --------------------------> ∙\n-- | |\n-- | |\n-- lift-var l (n + m + i) lift-var (l + n) m\n-- | |\n-- ∨ ∨ \n-- ∙ --------------------------> ∙\n-- \n\nlift-var-lemma : ∀ l m n i x → lift-var l (n + m + i) x ≡ lift-var (l + n) m (lift-var l (n + i) x)\nlift-var-lemma l m n i x with inspectBinding l x \n... | Free n≤x = \n begin \n n + m + i + x\n ≡⟨ cong (λ w → w + i + x) (+-comm n m) ⟩ \n m + n + i + x\n ≡⟨ +-assoc (m + n) i x ⟩ \n m + n + (i + x)\n ≡⟨ +-assoc m n (i + x) ⟩ \n m + (n + (i + x))\n ≡⟨ cong (m +_) (sym (+-assoc n i x)) ⟩ \n m + (n + i + x)\n ≡⟨ sym (lift-var-≤ {l + n} {m} {n + i + x} (INEQ.l+n≤n+i+x l n i x n≤x)) ⟩ \n lift-var (l + n) m (n + i + x)\n ∎ \n... | Bound n>x =\n begin \n x\n ≡⟨ sym (lift-var-> {l + n} {m} {x} (≤-trans n>x (m≤m+n l n))) ⟩ \n lift-var (l + n) m x\n ∎ \n\n\n", "meta": {"hexsha": "e3d5709e4c8518c988ea309bf470085347abc9ce", "size": 6523, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LC/Subst/Var.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/Var.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/Var.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": 27.5232067511, "max_line_length": 111, "alphanum_fraction": 0.3246972252, "num_tokens": 2581, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127492339907, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.5828584141069395}} {"text": "-- Andreas, 2016-09-28\n-- Level constraints X <= a and a <= X should solve X = a.\n\n-- {-# OPTIONS -v tc.constr.add:40 #-}\n\nopen import Common.Level\n\nmodule _ (a : Level) where\n mutual\n X : Level\n X = _\n\n data C : Set (lsuc X) where\n c : Set a → C -- constrains X by a <= X\n\n data D : Set (lsuc a) where\n c : Set X → D -- constrains X by X <= a\n\n-- should succeed\n", "meta": {"hexsha": "4d3b7e8f78cbc5464053a30d33b5283c11cc343c", "size": 375, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/LevelLeqGeq.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/LevelLeqGeq.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/LevelLeqGeq.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.75, "max_line_length": 58, "alphanum_fraction": 0.576, "num_tokens": 127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8539127641048443, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5828584132296656}} {"text": "module Types4Crib where\n\nopen import Basics public\n\n_<=_ : Nat -> Nat -> Set\nze <= y = One\nsu x <= ze = Zero\nsu x <= su y = x <= y\n\ncmp : (x y : Nat) -> (x <= y) + (y <= x)\ncmp ze y = inl <>\ncmp (su x) ze = inr <>\ncmp (su x) (su y) = cmp x y\n\ndata Bnd : Set where\n bot : Bnd\n # : Nat -> Bnd\n top : Bnd\n\n_ Bnd -> Set\nbot Set where\n leaf : (lu : l T23 l u ze\n node2 : forall {h} x\n (tlx : T23 l (# x) h)(txu : T23 (# x) u h) ->\n T23 l u (su h)\n node3 : forall {h} x y\n (tlx : T23 l (# x) h)(txy : T23 (# x) (# y) h)(tyu : T23 (# y) u h) ->\n T23 l u (su h)\n\ndata Intv (l u : Bnd) : Set where\n intv : (x : Nat)(lx : l Intv l u\n\nTooBig : Bnd -> Bnd -> Nat -> Set\nTooBig l u h = Sg Nat \\ x -> T23 l (# x) h * T23 (# x) u h\n\ninsert : forall {h l u} -> Intv l u -> T23 l u h ->\n TooBig l u h + T23 l u h\ninsert (intv x lx xu) (leaf lu) = inl (x , (leaf lx , leaf xu))\ninsert (intv x lx xu) (node2 y tly tyu) with cmp x y\ninsert (intv x lx xu) (node2 y tly tyu) | inl xy with insert (intv x lx xy) tly\ninsert (intv x lx xu) (node2 y tly tyu) | inl xy | inl (z , tlz , tzu)\n = inr (node3 z y tlz tzu tyu)\ninsert (intv x lx xu) (node2 y tly tyu) | inl xy | inr tly'\n = inr (node2 y tly' tyu)\ninsert (intv x lx xu) (node2 y tly tyu) | inr yx with insert (intv x yx xu) tyu\ninsert (intv x lx xu) (node2 y tly tyu) | inr yx | inl (v , tyv , tvu) = inr (node3 y v tly tyv tvu)\ninsert (intv x lx xu) (node2 y tly tyu) | inr yx | inr tyv' = inr (node2 y tly tyv')\ninsert (intv x lx xu) (node3 y z tly tyz tzu) with cmp x y\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy with insert (intv x lx xy) tly\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy | inl (v , tlv , tvy) = inl (y , node2 v tlv tvy , node2 z tyz tzu)\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy | inr tly' = inr (node3 y z tly' tyz tzu)\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx with cmp x z\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz with insert (intv x yx xz) tyz\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz | inl (v , tyv , tvz)\n = inl (v , node2 y tly tyv , node2 z tvz tzu)\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz | inr tyz'\n = inr (node3 y z tly tyz' tzu)\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx with insert (intv x zx xu) tzu\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx | inl (v , tzv , tvu) = inl (z , node2 y tly tyz , node2 v tzv tvu)\ninsert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx | inr tzu' = inr (node3 y z tly tyz tzu') \n", "meta": {"hexsha": "608ff6c6725cdf5158af6c4b56dd21cb754106bb", "size": 2734, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Types4Crib.agda", "max_stars_repo_name": "pigworker/WhatRTypes4", "max_stars_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2016-06-11T09:12:25.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-09T05:38:44.000Z", "max_issues_repo_path": "Types4Crib.agda", "max_issues_repo_name": "pigworker/WhatRTypes4", "max_issues_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "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": "Types4Crib.agda", "max_forks_repo_name": "pigworker/WhatRTypes4", "max_forks_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-06-09T05:39:02.000Z", "max_forks_repo_forks_event_max_datetime": "2019-06-09T05:39:02.000Z", "avg_line_length": 41.4242424242, "max_line_length": 131, "alphanum_fraction": 0.5698610095, "num_tokens": 1236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009619539554, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.582820074055286}} {"text": "{-# OPTIONS --without-K --safe #-}\nopen import Axiom.Extensionality.Propositional using (Extensionality)\n\nmodule Cats.Category.Sets.Facts.Exponential\n (funext : ∀ {a b} → Extensionality a b)\n where\n\nopen import Data.Product using (_×_ ; _,_ ; proj₁ ; proj₂)\nopen import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym)\n\nopen import Cats.Category\nopen import Cats.Category.Sets using (Sets)\nopen import Cats.Category.Sets.Facts.Product using (hasBinaryProducts)\n\n\ninstance\n hasExponentials : ∀ {l} → HasExponentials (Sets l)\n hasExponentials .HasExponentials.hasBinaryProducts = hasBinaryProducts\n hasExponentials .HasExponentials._↝′_ B C = record\n { Cᴮ = B → C\n ; eval = λ { (f , x) → f x }\n ; curry′ = λ f → record\n { arr = λ a b → f (a , b)\n ; prop = λ x → refl\n ; unique = λ eq a → funext λ b → sym (eq _)\n }\n }\n", "meta": {"hexsha": "ce0cb9533e25768652825d2222a454caa166bd97", "size": 867, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Sets/Facts/Exponential.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/Exponential.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/Exponential.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": 30.9642857143, "max_line_length": 74, "alphanum_fraction": 0.6689734717, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8757869916479466, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.5827579172666467}} {"text": "module Computability.Enumeration.Diagonal where\n\nopen import Computability.Prelude\nopen import Computability.Function\nopen import Computability.Data.Fin.Opposite\nopen import Computability.Data.Nat.Iteration\nopen import Computability.Enumeration.Base\nopen import Data.Nat using (_∸_; pred; ⌊_/2⌋; _≤_; _<_; s≤s; z≤n)\nopen import Data.Nat.Properties using (+-suc; +-assoc; +-comm; +-identityʳ)\nopen import Data.Nat.Properties using (*-suc; *-assoc; *-comm; *-zeroʳ)\nopen import Data.Nat.Properties using (≤-step)\nopen import Data.Fin using (Fin; zero; suc; inject₁; fromℕ; fromℕ<; toℕ; opposite)\nopen import Data.Fin.Properties using (toℕ : (f₁ : Ren Δ Γ₁) (f₂ : Ren Δ Γ₂) → Ren Δ (Γ₁ ∙ Γ₂)\n<_,_> = {!!}\n\n<_,_>₁ : (f₁ : Ren Δ Γ₁) (f₂ : Ren Δ Γ₂) → Cxt → Ren Δ (Γ₁ ∙ Γ₂)\n< f₁ , f₂ >₁ x = {!!}\n", "meta": {"hexsha": "73023a80060635b7444b14ba13bb89a0d50101f5", "size": 323, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue3166.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/Issue3166.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/Issue3166.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.9444444444, "max_line_length": 64, "alphanum_fraction": 0.4767801858, "num_tokens": 168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333245870332531, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.5827059121054552}} {"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.Typed-Syntax {l}\n (index : Set l) (rule : index → GSeTT.Typed-Syntax.Ctx × (Globular-TT.Syntax.Pre-Ty index)) (eqdec-index : eqdec index) where\n\n open import Globular-TT.Syntax index\n open import Globular-TT.Rules index rule\n open import Globular-TT.Eqdec-syntax index eqdec-index\n open import Globular-TT.Uniqueness-Derivations index rule eqdec-index\n\n Ctx : Set (lsuc l)\n Ctx = Σ Pre-Ctx (λ Γ → Γ ⊢C)\n\n Ty : Ctx → Set (lsuc l)\n Ty (Γ , _) = Σ Pre-Ty (λ A → Γ ⊢T A)\n\n Tm : ∀ (Γ : Ctx) → Ty Γ → Set (lsuc l)\n Tm (Γ , _) (A , _) = Σ Pre-Tm (λ t → Γ ⊢t t # A)\n\n Sub : ∀ (Δ : Ctx) (Γ : Ctx) → Set (lsuc l)\n Sub (Δ , _) (Γ , _) = Σ Pre-Sub (λ γ → Δ ⊢S γ > Γ)\n\n eqC : ∀ (Γ Δ : Ctx) → fst Γ == fst Δ → Γ == Δ\n eqC (Γ , Γ⊢) (.Γ , Γ⊢') idp = Σ= idp (has-all-paths-⊢C _ _)\n\n eqT : ∀ {Γ} (A B : Ty Γ) → fst A == fst B → A == B\n eqT (A , Γ⊢A) (.A , Γ⊢'A) idp = Σ= idp (has-all-paths-⊢T _ _)\n\n eqt : ∀ {Γ A} (t u : Tm Γ A) → fst t == fst u → t == u\n eqt (t , Γ⊢t:A) (.t , Γ⊢':A) idp = Σ= idp (has-all-paths-⊢t _ _)\n\n eqS : ∀ {Γ Δ} (γ δ : Sub Γ Δ) → fst γ == fst δ → γ == δ\n eqS (γ , Γ⊢γ:Δ) (.γ , Γ⊢'γ:Δ) idp = Σ= idp (has-all-paths-⊢S _ _)\n\n trS : ∀ {Γ Δ Θ : Ctx} → (p : Δ == Θ) → {γ : Sub Γ Δ} → {δ : Sub Γ Θ} → fst γ == fst δ → transport p γ == δ\n trS {Γ} {Δ} {Θ} idp {γ} {δ} x = eqS {Γ} {Θ} γ δ x\n\n private\n eqdec-typedTy : ∀ Γ → eqdec (Ty Γ)\n eqdec-typedTy Γ (A , Γ⊢A) (B , Γ⊢B) with eqdec-Ty A B\n ... | inl idp = inl (eqT {Γ} (A , Γ⊢A) (B , Γ⊢B) idp)\n ... | inr A≠B = inr λ p → A≠B (fst-is-inj p)\n\n is-set-Ty : ∀ Γ → is-set (Ty Γ)\n is-set-Ty Γ = eqdec-is-set (eqdec-typedTy Γ)\n", "meta": {"hexsha": "778bab7ffcc6c9a234d164ec0c5db0598106c7cd", "size": 1807, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Globular-TT/Typed-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/Typed-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/Typed-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": 33.462962963, "max_line_length": 128, "alphanum_fraction": 0.5323741007, "num_tokens": 859, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.857768108626046, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.5825778226406204}} {"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Lists.Lists\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Semirings.Definition\nopen import Orders.Total.Definition\n\nmodule Numbers.BinaryNaturals.Definition where\n\ndata Bit : Set where\n zero : Bit\n one : Bit\n\nBinNat : Set\nBinNat = List Bit\n\n::Inj : {xs ys : BinNat} {i : Bit} → i :: xs ≡ i :: ys → xs ≡ ys\n::Inj {i = zero} refl = refl\n::Inj {i = one} refl = refl\n\nnonEmptyNotEmpty : {a : _} {A : Set a} {l1 : List A} {i : A} → i :: l1 ≡ [] → False\nnonEmptyNotEmpty {l1 = l1} {i} ()\n\n-- TODO - maybe we should do the floating-point style of assuming there's a leading bit and not storing it.\n-- That way, everything is already canonical.\n\ncanonical : BinNat → BinNat\ncanonical [] = []\ncanonical (zero :: n) with canonical n\ncanonical (zero :: n) | [] = []\ncanonical (zero :: n) | x :: bl = zero :: x :: bl\ncanonical (one :: n) = one :: canonical n\n\nCanonicalised : Set\nCanonicalised = Sg BinNat (λ i → canonical i ≡ i)\n\nbinNatToN : BinNat → ℕ\nbinNatToN [] = 0\nbinNatToN (zero :: b) = 2 *N binNatToN b\nbinNatToN (one :: b) = 1 +N (2 *N binNatToN b)\n\nincr : BinNat → BinNat\nincr [] = one :: []\nincr (zero :: n) = one :: n\nincr (one :: n) = zero :: (incr n)\n\nincrNonzero : (x : BinNat) → canonical (incr x) ≡ [] → False\n\nincrPreservesCanonical : (x : BinNat) → (canonical x ≡ x) → canonical (incr x) ≡ incr x\nincrPreservesCanonical [] pr = refl\nincrPreservesCanonical (zero :: xs) pr with canonical xs\nincrPreservesCanonical (zero :: xs) pr | x :: t = applyEquality (one ::_) (::Inj pr)\nincrPreservesCanonical (one :: xs) pr with inspect (canonical (incr xs))\nincrPreservesCanonical (one :: xs) pr | [] with≡ x = exFalso (incrNonzero xs x)\nincrPreservesCanonical (one :: xs) pr | (x₁ :: y) with≡ x rewrite x = applyEquality (zero ::_) (transitivity (equalityCommutative x) (incrPreservesCanonical xs (::Inj pr)))\n\nincrPreservesCanonical' : (x : BinNat) → canonical (incr x) ≡ incr (canonical x)\n\nincrC : Canonicalised → Canonicalised\nincrC (a , b) = incr a , incrPreservesCanonical a b\n\nNToBinNat : ℕ → BinNat\nNToBinNat zero = []\nNToBinNat (succ n) with NToBinNat n\nNToBinNat (succ n) | t = incr t\n\nNToBinNatC : ℕ → Canonicalised\nNToBinNatC zero = [] , refl\nNToBinNatC (succ n) = incrC (NToBinNatC n)\n\nincrInj : {x y : BinNat} → incr x ≡ incr y → canonical x ≡ canonical y\n\nincrNonzero' : (x : BinNat) → (incr x) ≡ [] → False\nincrNonzero' (zero :: xs) ()\nincrNonzero' (one :: xs) ()\n\ncanonicalRespectsIncr' : {x y : BinNat} → canonical (incr x) ≡ canonical (incr y) → canonical x ≡ canonical y\n\nbinNatToNSucc : (n : BinNat) → binNatToN (incr n) ≡ succ (binNatToN n)\nNToBinNatSucc : (n : ℕ) → incr (NToBinNat n) ≡ NToBinNat (succ n)\n\nbinNatToNZero : (x : BinNat) → binNatToN x ≡ 0 → canonical x ≡ []\nbinNatToNZero' : (x : BinNat) → canonical x ≡ [] → binNatToN x ≡ 0\n\nNToBinNatZero : (n : ℕ) → NToBinNat n ≡ [] → n ≡ 0\nNToBinNatZero zero pr = refl\nNToBinNatZero (succ n) pr with NToBinNat n\nNToBinNatZero (succ n) pr | zero :: bl = exFalso (nonEmptyNotEmpty pr)\nNToBinNatZero (succ n) pr | one :: bl = exFalso (nonEmptyNotEmpty pr)\n\ncanonicalAscends : {i : Bit} → (a : BinNat) → 0 2\n--\n-- all morphisms are 0 (because there is at most one morphism between each pair of objects). \nTriangleShape : FinCatShape\nTriangleShape = record\n { size = 3\n ; ∣_⇒_∣ = morph\n ; hasShape = record\n { id = id\n ; _∘_ = _∘_\n ; assoc = assoc\n ; identityˡ = identityˡ\n ; identityʳ = identityʳ\n }\n }\n where morph : Fin 3 → Fin 3 → ℕ\n morph 0F 0F = 1\n morph 0F 1F = 1\n morph 0F 2F = 1\n morph 1F 1F = 1\n morph 1F 2F = 1\n morph 2F 2F = 1\n morph _ _ = 0\n\n id : Fin (morph a a)\n id {0F} = 0F\n id {1F} = 0F\n id {2F} = 0F\n\n _∘_ : ∀ {a b c} → Fin (morph b c) → Fin (morph a b) → Fin (morph a c)\n _∘_ {0F} {0F} {0F} 0F 0F = 0F\n _∘_ {0F} {0F} {1F} 0F 0F = 0F\n _∘_ {0F} {0F} {2F} 0F 0F = 0F\n _∘_ {0F} {1F} {1F} 0F 0F = 0F\n _∘_ {0F} {1F} {2F} 0F 0F = 0F\n _∘_ {0F} {2F} {2F} 0F 0F = 0F\n _∘_ {1F} {1F} {1F} 0F 0F = 0F\n _∘_ {1F} {1F} {2F} 0F 0F = 0F\n _∘_ {1F} {2F} {2F} 0F 0F = 0F\n _∘_ {2F} {2F} {2F} 0F 0F = 0F\n\n assoc : ∀ {f : Fin (morph a b)} {g : Fin (morph b c)} {h : Fin (morph c d)} →\n ((h ∘ g) ∘ f) ≡ (h ∘ (g ∘ f))\n assoc {0F} {0F} {0F} {0F} {0F} {0F} {0F} = refl\n assoc {0F} {0F} {0F} {1F} {0F} {0F} {0F} = refl\n assoc {0F} {0F} {0F} {2F} {0F} {0F} {0F} = refl\n assoc {0F} {0F} {1F} {1F} {0F} {0F} {0F} = refl\n assoc {0F} {0F} {1F} {2F} {0F} {0F} {0F} = refl\n assoc {0F} {0F} {2F} {2F} {0F} {0F} {0F} = refl\n assoc {0F} {1F} {1F} {1F} {0F} {0F} {0F} = refl\n assoc {0F} {1F} {1F} {2F} {0F} {0F} {0F} = refl\n assoc {0F} {1F} {2F} {2F} {0F} {0F} {0F} = refl\n assoc {0F} {2F} {2F} {2F} {0F} {0F} {0F} = refl\n assoc {1F} {1F} {1F} {1F} {0F} {0F} {0F} = refl\n assoc {1F} {1F} {1F} {2F} {0F} {0F} {0F} = refl\n assoc {1F} {1F} {2F} {2F} {0F} {0F} {0F} = refl\n assoc {1F} {2F} {2F} {2F} {0F} {0F} {0F} = refl\n assoc {2F} {2F} {2F} {2F} {0F} {0F} {0F} = refl\n\n identityˡ : ∀ {f : Fin (morph a b)} → (id ∘ f) ≡ f\n identityˡ {0F} {0F} {0F} = refl\n identityˡ {0F} {1F} {0F} = refl\n identityˡ {0F} {2F} {0F} = refl\n identityˡ {1F} {1F} {0F} = refl\n identityˡ {1F} {2F} {0F} = refl\n identityˡ {2F} {2F} {0F} = refl\n\n identityʳ : ∀ {f : Fin (morph a b)} → (f ∘ id) ≡ f\n identityʳ {0F} {0F} {0F} = refl\n identityʳ {0F} {1F} {0F} = refl\n identityʳ {0F} {2F} {0F} = refl\n identityʳ {1F} {1F} {0F} = refl\n identityʳ {1F} {2F} {0F} = refl\n identityʳ {2F} {2F} {0F} = refl\n\nTriangle : Category _ _ _\nTriangle = FinCategory TriangleShape\n\nmodule Triangle = Category Triangle\n", "meta": {"hexsha": "ce15528945b86749baa56f081e8a2ba91cf96a4d", "size": 3229, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Finite/Fin/Instance/Triangle.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/Finite/Fin/Instance/Triangle.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/Finite/Fin/Instance/Triangle.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.0480769231, "max_line_length": 93, "alphanum_fraction": 0.475069681, "num_tokens": 1547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972751232808, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5823253320627506}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Dodo.Binary.Flip where\n\n-- Stdlib imports\nopen import Level using (Level; _⊔_)\nopen import Function.Base using (flip)\nopen import Relation.Binary using (Rel; REL)\nopen import Relation.Binary using (Symmetric)\n-- Local imports\nopen import Dodo.Binary.Equality\n\n\n-- # Operations\n\n-- ## Operations: ⊆₂\n\nmodule _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}\n {P : REL A B ℓ₁} {Q : REL A B ℓ₂} where\n\n flip-⊆₂ : P ⊆₂ Q → flip P ⊆₂ flip Q\n flip-⊆₂ (⊆: P⊆Q) = ⊆: (flip P⊆Q)\n\n\nmodule _ {a ℓ₁ : Level} {A : Set a} {P : Rel A ℓ₁} where\n\n flip-sym-⊆₂ : Symmetric P → P ⊆₂ flip P\n flip-sym-⊆₂ symP = ⊆: (λ _ _ → symP)\n \n\n-- ## Operations: ⇔₂\n\nmodule _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}\n {P : REL A B ℓ₁} {Q : REL A B ℓ₂} where\n \n flip-⇔₂ : P ⇔₂ Q → flip P ⇔₂ flip Q\n flip-⇔₂ = ⇔₂-compose flip-⊆₂ flip-⊆₂\n\n\nmodule _ {a ℓ₁ : Level} {A : Set a} {P : Rel A ℓ₁} where\n\n flip-sym-⇔₂ : Symmetric P → P ⇔₂ flip P\n flip-sym-⇔₂ symP = ⇔₂-intro (flip-sym-⊆₂ symP) (flip-sym-⊆₂ symP)\n", "meta": {"hexsha": "1c91cdf988fe14c50e4e57426fcc5160fbedae3d", "size": 1030, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Dodo/Binary/Flip.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/Flip.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/Flip.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": 23.4090909091, "max_line_length": 67, "alphanum_fraction": 0.5893203883, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744850834649, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.5823028612890284}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Circuits where\n\nopen import PiLevel0\n using (U; ZERO; ONE; PLUS; TIMES; BOOL; BOOL²;\n _⟷_;\n unite₊; uniti₊; swap₊; assocl₊; assocr₊;\n unite⋆; uniti⋆; swap⋆; assocl⋆; assocr⋆;\n absorbr; absorbl; factorzr; factorzl; dist; factor;\n id⟷; _◎_; _⊕_; _⊗_;\n _⟷⟨_⟩_; _□;\n NOT; CNOT; TOFFOLI)\n\n------------------------------------------------------------------------------\n\nSWAP : BOOL² ⟷ BOOL²\nSWAP = swap⋆\n\nCONTROL : {t : U} → (t ⟷ t) → (TIMES BOOL t ⟷ TIMES BOOL t)\nCONTROL {t} f = TIMES BOOL t\n ⟷⟨ id⟷ ⟩ \n TIMES (PLUS x y) t\n ⟷⟨ dist ⟩\n PLUS (TIMES x t) (TIMES y t)\n ⟷⟨ id⟷ ⊕ (id⟷ ⊗ f) ⟩ \n PLUS (TIMES x t) (TIMES y t)\n ⟷⟨ factor ⟩\n TIMES (PLUS x y) t\n ⟷⟨ id⟷ ⟩\n TIMES BOOL t □\n where x = ONE; y = ONE\n\nFREDKIN : TIMES BOOL BOOL² ⟷ TIMES BOOL BOOL²\nFREDKIN = CONTROL SWAP\n\n------------------------------------------------------------------------------\n-- Fig. 4 in http://arxiv.org/pdf/1110.2574v2.pdf\n\n-- (e) cycles\n\n-- (c) reversible truth table\n\n------------------------------------------------------------------------------\n\n", "meta": {"hexsha": "29f8e9810eab9bc3dcb59a5353cd74d2f7e5e733", "size": 1271, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Univalence/Circuits.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/Circuits.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/Circuits.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.6304347826, "max_line_length": 78, "alphanum_fraction": 0.3870967742, "num_tokens": 399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.5823028449695792}} {"text": "module Lists.Reverse where\n\nopen import Lists\nopen import Nats\nopen import Equality\nopen import Function\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n -- rev$v:a=a:rev$v : ∀ {n m} {A : Set n} (a : A) (v : List A m) →\n -- rev (v ∷ʳ a) ≡ a ∷ rev v\n -- rev$v:a=a:rev$v _ [] = refl\n -- rev$v:a=a:rev$v a (_ ∷ xs) with rev (xs ∷ʳ a) | rev$v:a=a:rev$v a xs\n -- ... | .(a ∷ rev xs) | refl = refl\n\n rev$v:a=a:rev$v : ∀ {n} {A : Set n} (a : A) (v : List A) →\n reverse (v ∷ʳ a) ≡ a ∷ reverse v\n rev$v:a=a:rev$v _ [] = refl\n rev$v:a=a:rev$v a (_ ∷ xs)\n rewrite rev$v:a=a:rev$v a xs\n = refl\n\n rev∘rev=id : ∀ {n} {A : Set n} (v : List A) → reverse (reverse v) ≡ v\n rev∘rev=id [] = refl\n rev∘rev=id (x ∷ xs)\n rewrite rev$v:a=a:rev$v x $ reverse xs\n | rev∘rev=id xs\n = refl\n\n------------------------------------------------------------------------\n-- public aliases\n\nlist-rev-rev-id : ∀ {n} {A : Set n} (v : List A) → reverse (reverse v) ≡ v\nlist-rev-rev-id = rev∘rev=id\n", "meta": {"hexsha": "c9cfd97d3cc6bb361d6ca5caf45da14293a35497", "size": 1122, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Lists/Reverse.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/Lists/Reverse.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/Lists/Reverse.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.5263157895, "max_line_length": 74, "alphanum_fraction": 0.4295900178, "num_tokens": 381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.582234565665}} {"text": "-- {-# OPTIONS -v tc.meta:100 #-}\n-- Andreas, 2011-04-20\n-- see Abel Pientka TLCA 2011\nmodule PruningNonMillerPattern where\n\ndata _≡_ {A : Set}(a : A) : A -> Set where\n refl : a ≡ a\n\ndata Nat : Set where\n zero : Nat\n suc : Nat -> Nat\n\n-- bad variable y in head position\ntest : let X : Nat -> Nat -> Nat\n X = _\n Y : Nat -> Nat -> Nat\n Y = _\n in (C : Set) ->\n (({x y : Nat} -> X x x ≡ suc (Y x y)) ->\n ({x y : Nat} -> Y x x ≡ x) ->\n ({x y : Nat} -> X (Y x y) y ≡ X x x) -> C) -> C\ntest C k = k refl refl refl\n{- none of these equations is immediately solvable. However,\n from 1. we deduce that Y does not depend on its second argument, thus\n from 2. we solve Y x y = x, and then\n eqn. 3. simplifies to X x y = X x x, thus, X does not depend on its second arg,\n we can then solve using 1. X x y = suc x\n-}\n\n-- a variant, where pruning is even triggered from a non-pattern\ntest' : let X : Nat -> Nat -> Nat\n X = _\n Y : Nat -> Nat -> Nat\n Y = _\n in (C : Set) ->\n (({x y : Nat} -> X x (suc x) ≡ suc (Y x y)) -> -- non-pattern lhs\n ({x y : Nat} -> Y x x ≡ x) ->\n ({x y : Nat} -> X (Y x y) y ≡ X x x) -> C) -> C\ntest' C k = k refl refl refl\n\n-- another variant, where the pruned argument does not have an offending\n-- variable in the head, but in a non-eliminateable position\n-- (argument to a datatype)\n\ndata Sing {A : Set} : A → Set where\n sing : (x : A) -> Sing x\n\n-- bad rigid under a data type constructor\ntest2 : let X : Nat -> Nat -> Nat\n X = _\n Y : Nat → Set -> Nat\n Y = _\n in (C : Set) ->\n (({x y : Nat} -> X x x ≡ suc (Y x (Sing (suc y)))) ->\n ({x y : Nat} -> Y x (Sing x) ≡ x) ->\n ({x y : Nat} -> X (Y x (Sing y)) y ≡ X x x) -> C) -> C\ntest2 C k = k refl refl refl\n\nT : Nat → Set\nT zero = Nat\nT (suc _) = Nat → Nat\n\n-- bad rigid y under a Pi type constructor\ntest3 : let X : Nat -> Nat -> Nat\n X = _\n Y : Nat → Set -> Nat\n Y = _\n in (C : Set) ->\n (({x y : Nat} -> X x x ≡ suc (Y x (T y -> T y))) ->\n ({x y : Nat} -> Y x (Sing x) ≡ x) ->\n ({x y : Nat} -> X (Y x (Sing y)) y ≡ X x x) -> C) -> C\ntest3 C k = k refl refl refl\n\n-- bad rigid y in head position under a lambda\ntest4 : let X : Nat -> Nat -> Nat\n X = _\n Y : Nat → (Nat → Nat) -> Nat\n Y = _\n in (C : Set) ->\n ((∀ {x : Nat} {y : Nat → Nat} -> X x x ≡ suc (Y x (λ k → y zero))) ->\n (∀ {x : Nat} {y : Nat → Nat} -> Y x (λ k → y zero) ≡ x) ->\n (∀ {x : Nat} {y : Nat } -> X (Y x (λ k → y)) y ≡ X x x) -> C) -> C\ntest4 C k = k refl refl refl\n\n-- bad variable in irrelevant position\ntest5 : let X : Nat -> Nat -> Nat\n X = _\n Y : Nat -> .Nat -> Nat\n Y = _\n in (C : Set) ->\n (({x y : Nat} -> X x (suc x) ≡ suc (Y x (suc y))) -> -- non-pattern lhs\n ({x y : Nat} -> Y x x ≡ x) ->\n ({x y : Nat} -> X (Y x (suc y)) y ≡ X x x) -> C) -> C\ntest5 C k = k refl refl refl\n", "meta": {"hexsha": "c0d0bd91f1dae9864bb7108b3083f339a718d996", "size": 3242, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/PruningNonMillerPattern.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/PruningNonMillerPattern.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/PruningNonMillerPattern.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": 34.1263157895, "max_line_length": 84, "alphanum_fraction": 0.4346082665, "num_tokens": 1094, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.5822345564379146}} {"text": "{-# OPTIONS --cubical-compatible --rewriting --confluence-check #-}\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\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\npostulate\n Circle : Set\n base : Circle\n loop : base == base\n\nmodule _ {i} {P : Circle → Set i} (base* : P base) (loop* : base* == base* [ P ↓ loop ])\n where\n postulate\n Circle-elim : (x : Circle) → P x\n Circle-base-β : Circle-elim base ↦ base*\n {-# REWRITE Circle-base-β #-}\n Circle-loop-β : ap Circle-elim loop ↦ loop*\n {-# REWRITE Circle-loop-β #-}\n\nidCircle : Circle → Circle\nidCircle = Circle-elim base loop\n", "meta": {"hexsha": "127157f5a25a76e5b32f805b644a32aada01ef20", "size": 1170, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue1663.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/Issue1663.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/Issue1663.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.5909090909, "max_line_length": 88, "alphanum_fraction": 0.5042735043, "num_tokens": 480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382165412808, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.5821970235379291}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nopen import Prelude\nopen import Relation.Binary\nopen import Function.Injective\n\nmodule Relation.Binary.Construct.On\n {a b ℓ₁ ℓ₂} {A : Type a} {B : Type b}\n (f : A → B) (f-inj : Injective f)\n (ord : TotalOrder B ℓ₁ ℓ₂)\n where\n\nopen TotalOrder ord renaming (refl to ≤-refl)\n\n_<′_ : A → A → Type _\nx <′ y = f x < f y\n\n_≤′_ : A → A → Type _\nx ≤′ y = f x ≤ f y\n\non-ord : TotalOrder A ℓ₁ ℓ₂\nStrictPreorder._<_ (StrictPartialOrder.strictPreorder (TotalOrder.strictPartialOrder on-ord)) = _<′_\nStrictPreorder.trans (StrictPartialOrder.strictPreorder (TotalOrder.strictPartialOrder on-ord)) = <-trans\nStrictPreorder.irrefl (StrictPartialOrder.strictPreorder (TotalOrder.strictPartialOrder on-ord)) = irrefl\nStrictPartialOrder.conn (TotalOrder.strictPartialOrder on-ord) p q = f-inj _ _ (conn p q)\nPreorder._≤_ (PartialOrder.preorder (TotalOrder.partialOrder on-ord)) = _≤′_\nPreorder.refl (PartialOrder.preorder (TotalOrder.partialOrder on-ord)) = ≤-refl\nPreorder.trans (PartialOrder.preorder (TotalOrder.partialOrder on-ord)) = ≤-trans\nPartialOrder.antisym (TotalOrder.partialOrder on-ord) p q = f-inj _ _ (antisym p q)\nTotalOrder._ on-ord = ≰⇒>\nTotalOrder.≮⇒≥ on-ord = ≮⇒≥\n", "meta": {"hexsha": "abb2c0a19167187ef6242032379578fa3494d5ba", "size": 1251, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Relation/Binary/Construct/On.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/Construct/On.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/Construct/On.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": 37.9090909091, "max_line_length": 106, "alphanum_fraction": 0.7154276579, "num_tokens": 429, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615381987656672, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.582197011525799}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Data.Nat.Order.Recursive where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Transport\n\nopen import Cubical.Data.Empty as Empty\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Sum as Sum\nopen import Cubical.Data.Unit\n\nopen import Cubical.Data.Nat.Base\nopen import Cubical.Data.Nat.Properties\n\nopen import Cubical.Induction.WellFounded\n\nopen import Cubical.Relation.Nullary\n\ninfix 4 _≤_ _<_\n\n_≤_ : ℕ → ℕ → Type₀\nzero ≤ _ = Unit\nsuc m ≤ zero = ⊥\nsuc m ≤ suc n = m ≤ n\n\n_<_ : ℕ → ℕ → Type₀\nm < n = suc m ≤ n\n\n_≤?_ : (m n : ℕ) → Dec (m ≤ n)\nzero ≤? _ = yes tt\nsuc m ≤? zero = no λ ()\nsuc m ≤? suc n = m ≤? n\n\ndata Trichotomy (m n : ℕ) : Type₀ where\n lt : m < n → Trichotomy m n\n eq : m ≡ n → Trichotomy m n\n gt : n < m → Trichotomy m n\n\nprivate\n variable\n ℓ : Level\n R : Type ℓ\n P : ℕ → Type ℓ\n k l m n : ℕ\n\nisProp≤ : isProp (m ≤ n)\nisProp≤ {zero} = isPropUnit\nisProp≤ {suc m} {zero} = isProp⊥\nisProp≤ {suc m} {suc n} = isProp≤ {m} {n}\n\n≤-k+ : m ≤ n → k + m ≤ k + n\n≤-k+ {k = zero} m≤n = m≤n\n≤-k+ {k = suc k} m≤n = ≤-k+ {k = k} m≤n\n\n≤-+k : m ≤ n → m + k ≤ n + k\n≤-+k {m} {n} {k} m≤n\n = transport (λ i → +-comm k m i ≤ +-comm k n i) (≤-k+ {m} {n} {k} m≤n)\n\n≤-refl : ∀ m → m ≤ m\n≤-refl zero = _\n≤-refl (suc m) = ≤-refl m\n\n≤-trans : k ≤ m → m ≤ n → k ≤ n\n≤-trans {zero} _ _ = _\n≤-trans {suc k} {suc m} {suc n} = ≤-trans {k} {m} {n}\n\n≤-antisym : m ≤ n → n ≤ m → m ≡ n\n≤-antisym {zero} {zero} _ _ = refl\n≤-antisym {suc m} {suc n} m≤n n≤m = cong suc (≤-antisym m≤n n≤m)\n\n≤-k+-cancel : k + m ≤ k + n → m ≤ n\n≤-k+-cancel {k = zero} m≤n = m≤n\n≤-k+-cancel {k = suc k} m≤n = ≤-k+-cancel {k} m≤n\n\n≤-+k-cancel : m + k ≤ n + k → m ≤ n\n≤-+k-cancel {m} {k} {n}\n = ≤-k+-cancel {k} {m} {n} ∘ transport λ i → +-comm m k i ≤ +-comm n k i\n\n¬m Set1}{E : Set1} -> OP I D E -> OP I D E -> OP I D E\nγ₀ +OP γ₁ = σ Two (\\x -> case₂ x γ₀ γ₁)\n\n-- First something simple.\n\nbool : OPr One (\\_ -> One')\nbool _ = ι★r +OP ι★r\n\nBool : Set\nBool = Ur bool ★\n\nfalse : Bool\nfalse = intror < ★₀ | ★ >\n\ntrue : Bool\ntrue = intror < ★₁ | ★ >\n\n-- We don't have universe subtyping, and we only setup large elimination rules.\nif_then_else_ : {A : Set1} -> Bool -> A -> A -> A\nif_then_else_ {A} b x y = Rr bool (\\_ _ -> A) (\\_ a _ -> case₂ (π₀ a) y x) ★ b\n\n-- Something recursive\n\nnat : OPr One (\\_ -> One')\nnat _ = ι★r +OP δ One (\\_ -> ★) (\\_ -> ι★r)\n\nNat : Set\nNat = Ur nat ★\n\nzero : Nat\nzero = intror < ★₀ | ★ >\n\nsuc : Nat -> Nat\nsuc n = intror < ★₁ | < (\\_ -> n) | ★ > >\n\n", "meta": {"hexsha": "e6c5f903c4b0f94ad9cd71819c781cd51715ea89", "size": 852, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/iird/Examples.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/iird/Examples.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/iird/Examples.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.1276595745, "max_line_length": 79, "alphanum_fraction": 0.558685446, "num_tokens": 323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467770088162, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.5819273570687297}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nopen import Prelude hiding (A; B)\nopen import Categories\n\nmodule Categories.Pushout {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) where\n\nopen Category C\n\nprivate\n variable\n A B : Ob\n h₁ h₂ j : A ⟶ B\n\nrecord Pushout (f : X ⟶ Y) (g : X ⟶ Z) : Type (ℓ₁ ℓ⊔ ℓ₂) where\n field\n {Q} : Ob\n i₁ : Y ⟶ Q\n i₂ : Z ⟶ Q\n commute : i₁ · f ≡ i₂ · g\n universal : h₁ · f ≡ h₂ · g → Q ⟶ Codomain h₁\n unique : ∀ {eq : h₁ · f ≡ h₂ · g} →\n j · i₁ ≡ h₁ → j · i₂ ≡ h₂ →\n j ≡ universal eq\n\n universal·i₁≡h₁ : ∀ {eq : h₁ · f ≡ h₂ · g} →\n universal eq · i₁ ≡ h₁\n universal·i₂≡h₂ : ∀ {eq : h₁ · f ≡ h₂ · g} →\n universal eq · i₂ ≡ h₂\n\nHasPushouts : Type (ℓ₁ ℓ⊔ ℓ₂)\nHasPushouts = ∀ {X Y Z} → (f : X ⟶ Y) → (g : X ⟶ Z) → Pushout f g\n", "meta": {"hexsha": "c5942ce6c1238af1d4aab88608cc8b5b07af1e27", "size": 823, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Categories/Pushout.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/Pushout.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/Pushout.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.9393939394, "max_line_length": 65, "alphanum_fraction": 0.4763061968, "num_tokens": 351, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467643431001, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.581927354548202}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.DStructures.Structures.Group 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\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\n\nprivate\n variable\n ℓ ℓ' : Level\n\nopen URGStr\n\n-------------------------------------------\n-- URG structure on the type of groups\n-------------------------------------------\n\n𝒮-group : (ℓ : Level) → URGStr (Group {ℓ}) ℓ\n𝒮-group ℓ ._≅_ = GroupEquiv\n𝒮-group ℓ .ρ = idGroupEquiv\n𝒮-group ℓ .uni = isUnivalent'→isUnivalent GroupEquiv\n idGroupEquiv\n λ G H → invEquiv (GroupPath G H)\n\n-------------------------------------------\n-- 𝒮ᴰ-hierarchies on top of 𝒮-group\n--\n-- Notation:\n--\n-- G - group\n-- G² - pair of groups\n-- F - morphism forth\n-- B - morphism back\n--\n-- F B (FB)\n-- \\ | /\n-- G\n-- |\n-- G\n-------------------------------------------\n\nmodule _ (ℓ ℓ' : Level) where\n\n ---- Underlying types\n\n -- pairs of groups\n G² = Group {ℓ} × Group {ℓ'}\n -- pairs of groups + a morphism forth\n G²F = Σ[ (G , H) ∈ G² ] GroupHom G H\n -- pairs of groups + a morphism back\n G²B = Σ[ (G , H) ∈ G² ] GroupHom H G\n -- pairs of groups + morphisms forth and back\n G²FB = Σ[ (G , H) ∈ G² ] GroupHom G H × GroupHom H G\n\n ---- 𝒮 and 𝒮ᴰ-structures\n\n -- Group morphisms displayed over pairs of groups\n 𝒮ᴰ-G²\\F : URGStrᴰ (𝒮-group ℓ ×𝒮 𝒮-group ℓ')\n (λ (G , H) → GroupHom G H)\n (ℓ-max ℓ ℓ')\n 𝒮ᴰ-G²\\F =\n make-𝒮ᴰ (λ {(G , H)} {(G' , H')} f (eG , eH) f' → (g : ⟨ G ⟩) → GroupEquiv.eq eH .fst ((f .fun) g) ≡ (f' .fun) (GroupEquiv.eq eG .fst g))\n (λ _ _ → refl)\n λ (G , H) f → isContrRespectEquiv (Σ-cong-equiv-snd (λ f' → isoToEquiv (invIso (GroupMorphismExtIso f f'))))\n (isContrSingl f)\n where open GroupHom\n\n -- URG structure on type of two groups with a group morphism\n 𝒮-G²F : URGStr G²F (ℓ-max ℓ ℓ')\n 𝒮-G²F = ∫⟨ 𝒮-group ℓ ×𝒮 𝒮-group ℓ' ⟩ 𝒮ᴰ-G²\\F\n\n -- Same as 𝒮-G²F but with the morphism going the other way\n 𝒮ᴰ-G²\\B : URGStrᴰ (𝒮-group ℓ ×𝒮 𝒮-group ℓ')\n (λ (G , H) → GroupHom H G)\n (ℓ-max ℓ ℓ')\n 𝒮ᴰ-G²\\B =\n make-𝒮ᴰ (λ {(_ , H)} f (eG , eH) f' → (h : ⟨ H ⟩) → GroupEquiv.eq eG .fst (f .fun h) ≡ f' .fun (GroupEquiv.eq eH .fst h))\n (λ _ _ → refl)\n λ _ f → isContrRespectEquiv (Σ-cong-equiv-snd (λ f' → isoToEquiv (invIso (GroupMorphismExtIso f f')))) (isContrSingl f)\n where open GroupHom\n\n -- Type of two groups with a group morphism going back\n 𝒮-G²B : URGStr G²B (ℓ-max ℓ ℓ')\n 𝒮-G²B = ∫⟨ 𝒮-group ℓ ×𝒮 𝒮-group ℓ' ⟩ 𝒮ᴰ-G²\\B\n\n\n -- Morphisms going forth and back displayed over pairs of groups\n 𝒮ᴰ-G²\\FB : URGStrᴰ (𝒮-group ℓ ×𝒮 𝒮-group ℓ')\n (λ (G , H) → GroupHom G H × GroupHom H G)\n (ℓ-max ℓ ℓ')\n 𝒮ᴰ-G²\\FB = combine-𝒮ᴰ 𝒮ᴰ-G²\\F 𝒮ᴰ-G²\\B\n\n -- URG structure on type of pairs of groups with morphisms going forth and back\n 𝒮-G²FB : URGStr G²FB (ℓ-max ℓ ℓ')\n 𝒮-G²FB = ∫⟨ 𝒮-group ℓ ×𝒮 𝒮-group ℓ' ⟩ 𝒮ᴰ-G²\\FB\n", "meta": {"hexsha": "66e9903aacc9796cfac68f47959c47cf83636ed4", "size": 3647, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/DStructures/Structures/Group.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/Group.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/Group.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": 31.9912280702, "max_line_length": 141, "alphanum_fraction": 0.5686865917, "num_tokens": 1344, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467801752451, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.5819273533014617}} {"text": "-- ----------------------------------------------------------------------\n-- The Agda Descriptor Library\n-- \n-- (Closed) Sets\n-- ----------------------------------------------------------------------\n\nmodule Data.Set where\n\nopen import Data.Empty using (⊥)\nopen import Data.Fin using (Fin; suc; zero)\nopen import Data.Nat using (ℕ)\nopen import Data.Product using (Σ)\nopen import Data.Unit using (⊤)\n\nopen import Data.Desc using (Desc; μ; _##_; _⟶_; Π)\n\nopen import Relation.Binary.PropositionalEquality using (_≡_; refl)\n\n\n-- ----------------------------------------------------------------------\n-- Definition\n-- \n-- A `Desc is a closed dependent type theory of\n-- strictly positive functors : Set/A → Set/A \n-- \n-- A `Set is a open dependent type theory of \n-- the Agda model\n-- \n-- To ensure a closed universe, we use \n-- induction recursion.\n\n\ndata `Set : Set\n⟦_⟧ : `Set → Set\n\n\nprivate\n variable\n A : `Set \n\ndata `Desc (A : `Set) : Set\n⟪_⟫ : `Desc A → Desc ⟦ A ⟧\n\ndata `Set where\n `Fin : ℕ → `Set\n `Σ `Π : (B : `Set) → (⟦ B ⟧ → `Set) → `Set\n `μ : `Desc A → ⟦ A ⟧ → `Set\n\n⟦ `Fin n ⟧ = Fin n\n⟦ `Σ A B ⟧ = Σ ⟦ A ⟧ (λ a → ⟦ B a ⟧ )\n⟦ `Π A B ⟧ = (a : ⟦ A ⟧) → ⟦ B a ⟧\n⟦ `μ d a ⟧ = μ ⟪ d ⟫ a\n\ninfixr 6 _⟶_\n\ndata `Desc A where\n `Π : (B : `Set) → (⟦ B ⟧ → `Desc A) → `Desc A\n _⟶_ : `Desc A → `Desc A → `Desc A\n _`##_ : (`Set → `Set) → ⟦ A ⟧ → `Desc A\n\n⟪ `Π B d ⟫ = Π ⟦ B ⟧ (λ b → ⟪ d b ⟫)\n⟪ d₁ ⟶ d₂ ⟫ = ⟪ d₁ ⟫ ⟶ ⟪ d₂ ⟫\n⟪ f `## a ⟫ = {! !} ## a\n\n\n-- ----------------------------------------------------------------------\n-- Example (Basic)\n\n-- `⊤ : `Set\n-- `⊤ = `Fin 1\n\n-- `tt : ⟦ `⊤ ⟧\n-- `tt = zero\n\n-- `const : `Set → `Desc `⊤\n-- `const A = `Π A λ _ → `# `tt\n\n-- _`≡_ : ⟦ A ⟧ → ⟦ A ⟧ → `Set\n-- x `≡ y = `μ (`# x) y\n\n\n\n-- ----------------------------------------------------------------------\n\n-- pattern nil = zero\n-- pattern cons = (suc zero)\n\n-- TODO: First order isomorphisms\n\n-- _ : ⟦ zero `≡ zero ⟧\n-- _ = {! refl !}\n\n\n-- ListD : `Set → `Desc `⊤\n-- ListD A = `Π (`Fin 2) \n-- λ{ nil → `# `tt\n-- ; cons → `const A ⟶ `# `tt ⟶ `# `tt }\n\n-- `List : `Set → `Set\n-- `List A = `μ (ListD A) `tt\n\n-- RoseD : `Set → `Desc `⊤\n-- RoseD A = `const A ⟶ `List $ (`# `tt) ⟶ `# `tt\n\n-- _#_ : (Set → Set) → A → Desc A\n-- \n-- Computional:\n-- f (X a)\n-- \n-- Propositional:\n-- f (a′ ≡ a)\n", "meta": {"hexsha": "ae1e438db49e8db007f43b019e9a77feb2c32e5c", "size": 2287, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Set.agda", "max_stars_repo_name": "johnyob/agda-desc", "max_stars_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f", "max_stars_repo_licenses": ["MIT"], "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/Set.agda", "max_issues_repo_name": "johnyob/agda-desc", "max_issues_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f", "max_issues_repo_licenses": ["MIT"], "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/Set.agda", "max_forks_repo_name": "johnyob/agda-desc", "max_forks_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f", "max_forks_repo_licenses": ["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.4196428571, "max_line_length": 73, "alphanum_fraction": 0.4105815479, "num_tokens": 862, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467611766711, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5819273524522702}} {"text": "module Issue470 where\n\ndata Bool : Set where\n true false : Bool\n\n_and_ : Bool → Bool → Bool\ntrue and x = x\nfalse and x = false\n\ninfixr 5 _∷_\n\ndata Foo : Bool → Set where\n [] : Foo true\n _∷_ : ∀ {b} (x : Bool) → Foo b → Foo (x and b)\n\nBaz : Bool → Set\nBaz true = Bool\nBaz false = Foo false\n\ndata Bar : ∀ {b} → Foo b → Set where\n [] : Bar []\n _∷_ : ∀ {b} {foo : Foo b} {x} (g : Baz x) → (bar : Bar foo) → Bar (x ∷ foo)\n\nfoo : Foo false\nfoo = false ∷ true ∷ []\n\nbar : Bar foo\nbar = (false ∷ []) ∷ false ∷ [] -- ← is yellow\n\n{-\n_59 := _55 ∷ false ∷ [] [blocked by problem 75]\n[75] [\"apply\" (_53 ∷ true ∷ [])] == [\"apply\" (false ∷ true ∷ [])] : Foo\n(_53 and (true and true)) → Set [blocked by problem 76]\n[76] (_53 and (true and true)) = false : Bool\n_54 := false ∷ [] :? Baz _53\n-}\n", "meta": {"hexsha": "f3fd8d2d5c1ca389602f33d82b4c7ebd95291b1a", "size": 786, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue470.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/Issue470.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/Issue470.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.2432432432, "max_line_length": 77, "alphanum_fraction": 0.5445292621, "num_tokens": 304, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.879146761176671, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5819273524522701}} {"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 Data.Fin hiding (_≟_; _<_; _+_; pred; _≤_; lift)\nopen import Data.List\nopen import Data.List.Properties\nopen import Relation.Nullary.Negation using (contradiction ; contraposition)\n\n\n\nopen import StateMachineModel\n\n\nmodule Examples.ProducerConsumer2\n (Message : Set) -- Message type\n where\n\n\n -----------------------------------------------------------------------------\n -- SPECIFICATION\n -----------------------------------------------------------------------------\n record State : Set where\n field\n produced : List Message\n consumed : List Message\n open State\n\n\n\n data MyEvent : Set where\n produce : Message → MyEvent\n consume : Message → MyEvent\n\n\n\n data MyEnabled : MyEvent → State → Set where\n prodEnabled : ∀ {st : State} {msg} -- always enabled\n → MyEnabled (produce msg) st\n consEnabled : ∀ {st : State} {msg}\n → (cons x₁≮y₁ x₁≉y₁ x₁>y₁ = inj₂ (inj₁ x₁>y₁)\n ... | tri≈ x₁≮y₁ x₁≈y₁ x₁≯y₁ with total₂ (proj₂ x) (proj₂ y)\n ... | inj₁ x₂≤y₂ = inj₁ (inj₂ (x₁≈y₁ , x₂≤y₂))\n ... | inj₂ x₂≥y₂ = inj₂ (inj₂ (sym₁ x₁≈y₁ , x₂≥y₂))\n\n -- Some collections of properties which are preserved by ×-Lex\n -- (under certain assumptions).\n\n ×-isPartialOrder :\n ∀ {_≈₁_ _≤₁_} → IsPartialOrder _≈₁_ _≤₁_ →\n ∀ {_≈₂_ _≤₂_} → IsPartialOrder _≈₂_ _≤₂_ →\n IsPartialOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)\n ×-isPartialOrder {_≈₁_} {_≤₁_} po₁\n {_≤₂_ = _≤₂_} po₂ = record\n { isPreorder = record\n { isEquivalence = Pointwise.×-isEquivalence\n (isEquivalence po₁)\n (isEquivalence po₂)\n ; reflexive = ×-reflexive _≈₁_ _≤₁_ _≤₂_ (reflexive po₂)\n ; trans = ×-transitive po₁ {_≤₂_ = _≤₂_} (trans po₂)\n }\n ; antisym = ×-antisymmetric {_≤₁_ = _≤₁_} po₁\n {_≤₂_ = _≤₂_} (antisym po₂)\n }\n where open IsPartialOrder\n\n ×-isTotalOrder :\n ∀ {_≈₁_ _≤₁_} → Decidable _≈₁_ → IsTotalOrder _≈₁_ _≤₁_ →\n ∀ {_≈₂_ _≤₂_} → IsTotalOrder _≈₂_ _≤₂_ →\n IsTotalOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)\n ×-isTotalOrder {_≤₁_ = _≤₁_} ≈₁-dec to₁ {_≤₂_ = _≤₂_} to₂ = record\n { isPartialOrder = ×-isPartialOrder\n (isPartialOrder to₁) (isPartialOrder to₂)\n ; total = ×-total {_≤₁_ = _≤₁_} (Eq.sym to₁) ≈₁-dec\n (antisym to₁) (total to₁)\n {_≤₂_ = _≤₂_} (total to₂)\n }\n where open IsTotalOrder\n\n ×-isDecTotalOrder :\n ∀ {_≈₁_ _≤₁_} → IsDecTotalOrder _≈₁_ _≤₁_ →\n ∀ {_≈₂_ _≤₂_} → IsDecTotalOrder _≈₂_ _≤₂_ →\n IsDecTotalOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)\n ×-isDecTotalOrder {_≤₁_ = _≤₁_} to₁ {_≤₂_ = _≤₂_} to₂ = record\n { isTotalOrder = ×-isTotalOrder (_≟_ to₁)\n (isTotalOrder to₁)\n (isTotalOrder to₂)\n ; _≟_ = Pointwise.×-decidable (_≟_ to₁) (_≟_ to₂)\n ; _≤?_ = ×-decidable (_≟_ to₁) (_≤?_ to₁) (_≤?_ to₂)\n }\n where open IsDecTotalOrder\n\n------------------------------------------------------------------------\n-- \"Packages\" can also be combined.\n\nmodule _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} where\n\n ×-poset : Poset ℓ₁ ℓ₂ _ → Poset ℓ₃ ℓ₄ _ → Poset _ _ _\n ×-poset p₁ p₂ = record\n { isPartialOrder = ×-isPartialOrder\n (isPartialOrder p₁) (isPartialOrder p₂)\n } where open Poset\n\n ×-totalOrder : DecTotalOrder ℓ₁ ℓ₂ _ → TotalOrder ℓ₃ ℓ₄ _ →\n TotalOrder _ _ _\n ×-totalOrder t₁ t₂ = record\n { isTotalOrder = ×-isTotalOrder T₁._≟_ T₁.isTotalOrder T₂.isTotalOrder\n }\n where\n module T₁ = DecTotalOrder t₁\n module T₂ = TotalOrder t₂\n\n ×-decTotalOrder : DecTotalOrder ℓ₁ ℓ₂ _ → DecTotalOrder ℓ₃ ℓ₄ _ →\n DecTotalOrder _ _ _\n ×-decTotalOrder t₁ t₂ = record\n { isDecTotalOrder = ×-isDecTotalOrder\n (isDecTotalOrder t₁) (isDecTotalOrder t₂)\n } where open DecTotalOrder\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\n_×-isPartialOrder_ = ×-isPartialOrder\n{-# WARNING_ON_USAGE _×-isPartialOrder_\n\"Warning: _×-isPartialOrder_ was deprecated in v0.15.\nPlease use ×-isPartialOrder instead.\"\n#-}\n_×-isDecTotalOrder_ = ×-isDecTotalOrder\n{-# WARNING_ON_USAGE _×-isDecTotalOrder_\n\"Warning: _×-isDecTotalOrder_ was deprecated in v0.15.\nPlease use ×-isDecTotalOrder instead.\"\n#-}\n_×-poset_ = ×-poset\n{-# WARNING_ON_USAGE _×-poset_\n\"Warning: _×-poset_ was deprecated in v0.15.\nPlease use ×-poset instead.\"\n#-}\n_×-totalOrder_ = ×-totalOrder\n{-# WARNING_ON_USAGE _×-totalOrder_\n\"Warning: _×-totalOrder_ was deprecated in v0.15.\nPlease use ×-totalOrder instead.\"\n#-}\n_×-decTotalOrder_ = ×-decTotalOrder\n{-# WARNING_ON_USAGE _×-decTotalOrder_\n\"Warning: _×-decTotalOrder_ was deprecated in v0.15.\nPlease use ×-decTotalOrder instead.\"\n#-}\n×-≈-respects₂ = ×-respects₂\n{-# WARNING_ON_USAGE ×-≈-respects₂\n\"Warning: ×-≈-respects₂ was deprecated in v0.15.\nPlease use ×-respects₂ instead.\"\n#-}\n", "meta": {"hexsha": "a1f6f46ecd6fd03c588834a85c90a84751640b37", "size": 8181, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Lex/NonStrict.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/Product/Relation/Binary/Lex/NonStrict.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/Product/Relation/Binary/Lex/NonStrict.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.875, "max_line_length": 76, "alphanum_fraction": 0.5544554455, "num_tokens": 3162, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.5816726772851578}} {"text": "module Formalization.ClassicalPropositionalLogic.NaturalDeduction where\n\nopen import Data.Either as Either using (Left ; Right)\nopen import Formalization.ClassicalPropositionalLogic.Syntax\nopen import Functional\nimport Lvl\nimport Logic.Propositional as Meta\nopen import Logic\nopen import Relator.Equals\nopen import Relator.Equals.Proofs.Equiv\nopen import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to singleton ; _≡_ to _≡ₛ_)\nopen import Type\n\nprivate variable ℓₚ ℓ ℓ₁ ℓ₂ : Lvl.Level\n\ndata _⊢_ {ℓ ℓₚ} {P : Type{ℓₚ}} : Formulas(P){ℓ} → Formula(P) → Stmt{Lvl.𝐒(ℓₚ Lvl.⊔ ℓ)} where\n direct : ∀{Γ} → (Γ ⊆ (Γ ⊢_))\n\n [⊤]-intro : ∀{Γ} → (Γ ⊢ ⊤)\n\n [⊥]-intro : ∀{Γ}{φ} → (Γ ⊢ φ) → (Γ ⊢ (¬ φ)) → (Γ ⊢ ⊥)\n [⊥]-elim : ∀{Γ}{φ} → (Γ ⊢ ⊥) → (Γ ⊢ φ)\n\n [¬]-intro : ∀{Γ}{φ} → ((Γ ∪ singleton(φ)) ⊢ ⊥) → (Γ ⊢ (¬ φ))\n [¬]-elim : ∀{Γ}{φ} → ((Γ ∪ singleton(¬ φ)) ⊢ ⊥) → (Γ ⊢ φ)\n\n [∧]-intro : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ ψ) → (Γ ⊢ (φ ∧ ψ))\n [∧]-elimₗ : ∀{Γ}{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ φ)\n [∧]-elimᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ ψ)\n\n [∨]-introₗ : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ∨ ψ))\n [∨]-introᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ∨ ψ))\n [∨]-elim : ∀{Γ}{φ ψ χ} → ((Γ ∪ singleton(φ)) ⊢ χ) → ((Γ ∪ singleton(ψ)) ⊢ χ) → (Γ ⊢ (φ ∨ ψ)) → (Γ ⊢ χ)\n\n [⟶]-intro : ∀{Γ}{φ ψ} → ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (φ ⟶ ψ))\n [⟶]-elim : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟶ ψ)) → (Γ ⊢ ψ)\n\n [⟷]-intro : ∀{Γ}{φ ψ} → ((Γ ∪ singleton(ψ)) ⊢ φ) → ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ))\n [⟷]-elimₗ : ∀{Γ}{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ φ)\n [⟷]-elimᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ ψ)\n\nmodule _ where\n private variable P : Type{ℓₚ}\n private variable Γ Γ₁ Γ₂ : Formulas(P){ℓ}\n private variable φ ψ : Formula(P)\n\n _⊬_ : Formulas(P){ℓ} → Formula(P) → Stmt\n _⊬_ = Meta.¬_ ∘₂ (_⊢_)\n\n weaken-union-singleton : (Γ₁ ⊆ Γ₂) → (((Γ₁ ∪ singleton(φ)) ⊢_) ⊆ ((Γ₂ ∪ singleton(φ)) ⊢_))\n\n weaken : (Γ₁ ⊆ Γ₂) → ((Γ₁ ⊢_) ⊆ (Γ₂ ⊢_))\n weaken Γ₁Γ₂ {φ} (direct p) = direct (Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {.⊤} [⊤]-intro = [⊤]-intro\n weaken Γ₁Γ₂ {.⊥} ([⊥]-intro p q) = [⊥]-intro (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)\n weaken Γ₁Γ₂ {φ} ([⊥]-elim p) = [⊥]-elim (weaken Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {.(¬ _)} ([¬]-intro p) = [¬]-intro (weaken-union-singleton Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {φ} ([¬]-elim p) = [¬]-elim (weaken-union-singleton Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {.(_ ∧ _)} ([∧]-intro p q) = [∧]-intro (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)\n weaken Γ₁Γ₂ {φ} ([∧]-elimₗ p) = [∧]-elimₗ (weaken Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {φ} ([∧]-elimᵣ p) = [∧]-elimᵣ (weaken Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introₗ p) = [∨]-introₗ (weaken Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introᵣ p) = [∨]-introᵣ (weaken Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {φ} ([∨]-elim p q r) = [∨]-elim (weaken-union-singleton Γ₁Γ₂ p) (weaken-union-singleton Γ₁Γ₂ q) (weaken Γ₁Γ₂ r)\n weaken Γ₁Γ₂ {.(_ ⟶ _)} ([⟶]-intro p) = [⟶]-intro (weaken-union-singleton Γ₁Γ₂ p)\n weaken Γ₁Γ₂ {φ} ([⟶]-elim p q) = [⟶]-elim (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)\n weaken Γ₁Γ₂ {.(_ ⟷ _)} ([⟷]-intro p q) = [⟷]-intro (weaken-union-singleton Γ₁Γ₂ p) (weaken-union-singleton Γ₁Γ₂ q)\n weaken Γ₁Γ₂ {φ} ([⟷]-elimₗ p q) = [⟷]-elimₗ (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)\n weaken Γ₁Γ₂ {φ} ([⟷]-elimᵣ p q) = [⟷]-elimᵣ (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)\n\n weaken-union-singleton Γ₁Γ₂ p = weaken (Either.mapLeft Γ₁Γ₂) p\n\n weaken-union : (Γ₁ ⊢_) ⊆ ((Γ₁ ∪ Γ₂) ⊢_)\n weaken-union = weaken Either.Left\n\n [⟵]-intro : ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (ψ ⟵ φ))\n [⟵]-intro = [⟶]-intro\n\n [⟵]-elim : (Γ ⊢ φ) → (Γ ⊢ (ψ ⟵ φ)) → (Γ ⊢ ψ)\n [⟵]-elim = [⟶]-elim\n\n [¬¬]-elim : (Γ ⊢ ¬(¬ φ)) → (Γ ⊢ φ)\n [¬¬]-elim nnφ =\n ([¬]-elim\n ([⊥]-intro\n (direct(Right [≡]-intro))\n (weaken-union nnφ)\n )\n )\n\n [¬¬]-intro : (Γ ⊢ φ) → (Γ ⊢ ¬(¬ φ))\n [¬¬]-intro Γφ =\n ([¬]-intro\n ([⊥]-intro\n (weaken-union Γφ)\n (direct (Right [≡]-intro))\n )\n )\n\n", "meta": {"hexsha": "204aca68e92a50a869b23ed561d2c359e9c7e7d7", "size": 4074, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Formalization/ClassicalPropositionalLogic/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/ClassicalPropositionalLogic/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/ClassicalPropositionalLogic/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": 40.74, "max_line_length": 159, "alphanum_fraction": 0.4764359352, "num_tokens": 2193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677468516188, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5816630138173928}} {"text": "{-\n This file contains cospans, cones, pullbacks and maps of cones in precategories.\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\n\nmodule Cubical.Categories.Pullback where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Data.Sigma\nopen import Cubical.Categories.Category\n\nprivate\n variable\n ℓ ℓ' : Level\n\nrecord Cospan (𝒞 : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where\n constructor cospan\n field\n S₁ S₂ vertex : Precategory.ob 𝒞\n s₁ : hom 𝒞 S₁ vertex\n s₂ : hom 𝒞 S₂ vertex\n\nrecord Cone {𝒞 : Precategory ℓ ℓ'} (cspn : Cospan 𝒞) (c : ob 𝒞) : Type (ℓ-max ℓ ℓ') where\n constructor cone\n field\n p₁ : hom 𝒞 c (Cospan.S₁ cspn)\n p₂ : hom 𝒞 c (Cospan.S₂ cspn)\n sq : seq 𝒞 p₁ (Cospan.s₁ cspn) ≡ seq 𝒞 p₂ (Cospan.s₂ cspn)\n\nrecord Pullback {𝒞 : Precategory ℓ ℓ'} (cspn : Cospan 𝒞) : Type (ℓ-max ℓ ℓ') where\n constructor pullback\n field\n c : ob 𝒞\n cn : Cone cspn c\n universal : {c' : ob 𝒞} (cn' : Cone cspn c') → ∃![ f ∈ 𝒞 .hom c' c ] Σ[ q ∈ Cone.p₁ cn' ≡ 𝒞 .seq f (Cone.p₁ cn) ] (Cone.p₂ cn' ≡ 𝒞 .seq f (Cone.p₂ cn))\n\n-- whisker the parallel morphisms g and g' with f\nlPrecatWhisker : {𝒞 : Precategory ℓ ℓ'} {x y z : 𝒞 .ob} (f : 𝒞 .hom x y) (g g' : 𝒞 .hom y z) (p : g ≡ g') → 𝒞 .seq f g ≡ 𝒞 .seq f g'\nlPrecatWhisker {𝒞 = 𝒞} f _ _ p = cong (𝒞 .seq f) p\n\n-- extend a cone on c by a morphism c'→c using precomposition\nconeMap : {𝒞 : Precategory ℓ ℓ'} {cspn : Cospan 𝒞} {c c' : ob 𝒞} (cn : Cone cspn c) (f : hom 𝒞 c' c) → Cone cspn c'\nconeMap {𝒞 = 𝒞} {cospan _ _ _ s₁ s₂} (cone p₁ p₂ sq) f =\n cone (𝒞 .seq f p₁) (𝒞 .seq f p₂) ((𝒞 .seq-α f p₁ s₁) ∙∙ lPrecatWhisker {𝒞 = 𝒞} f (𝒞 .seq p₁ s₁) (𝒞 .seq p₂ s₂) sq ∙∙ sym (𝒞 .seq-α f p₂ s₂))\n", "meta": {"hexsha": "242e742d04158ee1ff58d72809012be1f6525ba8", "size": 1679, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Categories/Pullback.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/Categories/Pullback.agda", "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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/Pullback.agda", "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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": 37.3111111111, "max_line_length": 155, "alphanum_fraction": 0.6158427635, "num_tokens": 769, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339797047029, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.5816349983527563}} {"text": "------------------------------------------------------------------------\n-- Raw terms\n------------------------------------------------------------------------\n\nimport Level\nopen import Data.Universe\n\nmodule README.DependentlyTyped.Raw-term\n (Uni₀ : Universe Level.zero Level.zero)\n where\n\nopen import Data.Nat\nimport README.DependentlyTyped.Term as Term; open Term Uni₀\nopen import Relation.Binary.PropositionalEquality as P using (_≡_)\n\nmutual\n\n infixl 9 _·_\n infix 5 _∶_\n\n -- Raw types.\n\n data Raw-ty : Set where\n ⋆ : Raw-ty\n el : (t : Raw) → Raw-ty\n π : (t₁ t₂ : Raw-ty) → Raw-ty\n\n -- Raw terms.\n --\n -- One could distinguish between \"checkable\" and \"inferrable\" terms,\n -- but without a corresponding split for the well-typed terms this\n -- seems awkward.\n\n data Raw : Set where\n var : (x : ℕ) → Raw\n ƛ : (t : Raw) → Raw\n _·_ : (t₁ t₂ : Raw) → Raw\n\n -- Type annotation.\n _∶_ : (t : Raw) (σ : Raw-ty) → Raw\n\n-- The context position corresponding to a variable.\n\nposition : ∀ {Γ σ} → Γ ∋ σ → ℕ\nposition zero = zero\nposition (suc x) = suc (position x)\n\n-- Well-typed terms can be turned into raw ones.\n\n⌊_⌋ : ∀ {Γ σ} → Γ ⊢ σ → Raw\n⌊ var x ⌋ = var (position x)\n⌊ ƛ t ⌋ = ƛ ⌊ t ⌋\n⌊ t₁ · t₂ ⌋ = ⌊ t₁ ⌋ · ⌊ t₂ ⌋\n\n-- The same applies to syntactic types.\n\n⌊_⌋ty : ∀ {Γ σ} → Γ ⊢ σ type → Raw-ty\n⌊ ⋆ ⌋ty = ⋆\n⌊ el t ⌋ty = el ⌊ t ⌋\n⌊ π σ′ τ′ ⌋ty = π ⌊ σ′ ⌋ty ⌊ τ′ ⌋ty\n\nmutual\n\n -- The following functions remove type-annotations.\n\n ⌊_⌋raw-ty : Raw-ty → Raw-ty\n ⌊ ⋆ ⌋raw-ty = ⋆\n ⌊ el t ⌋raw-ty = el ⌊ t ⌋raw\n ⌊ π t₁ t₂ ⌋raw-ty = π ⌊ t₁ ⌋raw-ty ⌊ t₂ ⌋raw-ty\n\n ⌊_⌋raw : Raw → Raw\n ⌊ var x ⌋raw = var x\n ⌊ ƛ t ⌋raw = ƛ ⌊ t ⌋raw\n ⌊ t₁ · t₂ ⌋raw = ⌊ t₁ ⌋raw · ⌊ t₂ ⌋raw\n ⌊ t ∶ σ ⌋raw = ⌊ t ⌋raw\n\n-- Some congruence lemmas.\n\nposition-cong : ∀ {Γ₁ σ₁} {x₁ : Γ₁ ∋ σ₁}\n {Γ₂ σ₂} {x₂ : Γ₂ ∋ σ₂} →\n x₁ ≅-∋ x₂ → position x₁ ≡ position x₂\nposition-cong P.refl = P.refl\n\n⌊⌋-cong : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ σ₁}\n {Γ₂ σ₂} {t₂ : Γ₂ ⊢ σ₂} →\n t₁ ≅-⊢ t₂ → ⌊ t₁ ⌋ ≡ ⌊ t₂ ⌋\n⌊⌋-cong P.refl = P.refl\n\n⌊⌋ty-cong : ∀ {Γ₁ σ₁} {σ′₁ : Γ₁ ⊢ σ₁ type}\n {Γ₂ σ₂} {σ′₂ : Γ₂ ⊢ σ₂ type} →\n σ′₁ ≅-type σ′₂ → ⌊ σ′₁ ⌋ty ≡ ⌊ σ′₂ ⌋ty\n⌊⌋ty-cong P.refl = P.refl\n", "meta": {"hexsha": "490ead96b3a092f27ec65c46095fea0014cdd4c5", "size": 2264, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "README/DependentlyTyped/Raw-term.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/DependentlyTyped/Raw-term.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/DependentlyTyped/Raw-term.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": 24.3440860215, "max_line_length": 72, "alphanum_fraction": 0.4946996466, "num_tokens": 1036, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339556397749, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5816349870121438}} {"text": "open import guarded-recursion.prelude\n\nmodule guarded-recursion.model where\n\n-- ℂʷᵒᵖ (ℂ^{ω}^{op})\n-- Notation:\n-- For the category ℂ we use superscript 'c' to disambiguate (e.g. _→ᶜ_)\n-- We use ᵖ for the presheaf category.\nmodule Presheaf\n {o m}\n (Objᶜ : Type_ o)\n (_→ᶜ_ : Objᶜ → Objᶜ → Type_ m)\n (idᶜ : {A : Objᶜ} → A →ᶜ A)\n (_∘ᶜ_ : {A B C : Objᶜ} → (B →ᶜ C) → (A →ᶜ B) → (A →ᶜ C))\n (∘-idᶜ : {A B : Objᶜ} {f : A →ᶜ B} → f ∘ᶜ idᶜ ≡ f)\n (id-∘ᶜ : {A B : Objᶜ} {f : A →ᶜ B} → idᶜ ∘ᶜ f ≡ f)\n (∘-assocᶜ : {A B C D : Objᶜ}\n {f : C →ᶜ D} {g : B →ᶜ C} {h : A →ᶜ B}\n → (f ∘ᶜ g) ∘ᶜ h ≡ f ∘ᶜ (g ∘ᶜ h))\n (𝟙ᶜ : Objᶜ)\n (!ᶜ : {A : Objᶜ} → A →ᶜ 𝟙ᶜ)\n (!-uniqᶜ : {A : Objᶜ} {f : A →ᶜ 𝟙ᶜ} → f ≡ !ᶜ)\n where\n\n -- Index preserving maps\n _→ᶜ°_ : (A B : ℕ → Objᶜ) → Type_ _\n A →ᶜ° B = (n : ℕ) → A n →ᶜ B n\n\n Endoᶜ° : (ℕ → Objᶜ) → Type_ _\n Endoᶜ° A = A →ᶜ° A\n\n -- Restriction maps\n Rmap : (ℕ → Objᶜ) → Type_ _\n Rmap A = (A ∘ S) →ᶜ° A\n\n Objᵖ : Type_ _\n Objᵖ = Σ (ℕ → Objᶜ) Rmap\n\n _→ᵖ_ : Objᵖ → Objᵖ → Type_ _\n (A , rᴬ) →ᵖ (B , rᴮ) = Σ (A →ᶜ° B) λ f →\n (n : ℕ) → f n ∘ᶜ rᴬ n ≡ rᴮ n ∘ᶜ f (1 + n)\n\n [_]ᵖ : Objᶜ → Objᵖ\n [ A ]ᵖ = (λ _ → A) , (λ _ → idᶜ)\n\n ⟨_⟩ᵖ : {A B : Objᶜ} → A →ᶜ B → [ A ]ᵖ →ᵖ [ B ]ᵖ\n ⟨ f ⟩ᵖ = (λ _ → f) , (λ n → ∘-idᶜ ∙ ! id-∘ᶜ)\n\n idᵖ : {A : Objᵖ} → A →ᵖ A\n idᵖ = (λ n → idᶜ) , (λ n → id-∘ᶜ ∙ ! ∘-idᶜ)\n\n {-\n B ---f--> D\n ^ ^\n | |\n g h\n | |\n A ---i--> C\n -}\n module _ {A B C D}\n (f : B →ᶜ D) (g : A →ᶜ B)\n (h : C →ᶜ D) (i : A →ᶜ C) where\n Squareᶜ = f ∘ᶜ g ≡ h ∘ᶜ i\n\n module _ {A B C} {f f' : B →ᶜ C} {g g' : A →ᶜ B} where\n ap-∘ᶜ : f ≡ f' → g ≡ g' → f ∘ᶜ g ≡ f' ∘ᶜ g'\n ap-∘ᶜ p q = ap (λ x → x ∘ᶜ g) p ∙ ap (_∘ᶜ_ f') q\n\n !-irrᶜ : {A : Objᶜ} {f g : A →ᶜ 𝟙ᶜ} → f ≡ g\n !-irrᶜ = !-uniqᶜ ∙ ! !-uniqᶜ\n\n ∘-!ᶜ : {A : Objᶜ} {f : 𝟙ᶜ →ᶜ A} { !g : 𝟙ᶜ →ᶜ 𝟙ᶜ} → f ∘ᶜ !g ≡ f\n ∘-!ᶜ = ap-∘ᶜ idp !-irrᶜ ∙ ∘-idᶜ\n\n with-∘-assocᶜ : {A B C C' D : Objᶜ}\n {f : C →ᶜ D} {g : B →ᶜ C}\n {f' : C' →ᶜ D} {g' : B →ᶜ C'}\n {h : A →ᶜ B}\n → f ∘ᶜ g ≡ f' ∘ᶜ g'\n → f ∘ᶜ (g ∘ᶜ h) ≡ f' ∘ᶜ (g' ∘ᶜ h)\n with-∘-assocᶜ p = ! ∘-assocᶜ ∙ ap-∘ᶜ p idp ∙ ∘-assocᶜ\n\n with-!∘-assocᶜ : {A B B' C D : Objᶜ}\n {f : C →ᶜ D}\n {g : B →ᶜ C} {h : A →ᶜ B}\n {g' : B' →ᶜ C} {h' : A →ᶜ B'}\n → g ∘ᶜ h ≡ g' ∘ᶜ h'\n → (f ∘ᶜ g) ∘ᶜ h ≡ (f ∘ᶜ g') ∘ᶜ h'\n with-!∘-assocᶜ p = ∘-assocᶜ ∙ ap-∘ᶜ idp p ∙ ! ∘-assocᶜ\n\n {-\n B ---f--> D ---e--> F\n ^ ^ ^\n | | |\n g L h R j\n | | |\n A ---i--> C ---k--> E\n -}\n module _\n {A B C D E F}\n {f : B →ᶜ D} {g : A →ᶜ B}\n {h : C →ᶜ D} {i : A →ᶜ C}\n {e : D →ᶜ F}\n {j : E →ᶜ F} {k : C →ᶜ E}\n (L : Squareᶜ f g h i)\n (R : Squareᶜ e h j k) where\n\n private\n efg-ehi : (e ∘ᶜ f) ∘ᶜ g ≡ e ∘ᶜ (h ∘ᶜ i)\n efg-ehi = ∘-assocᶜ ∙ ap-∘ᶜ idp L\n\n ehi-jki : e ∘ᶜ (h ∘ᶜ i) ≡ j ∘ᶜ (k ∘ᶜ i)\n ehi-jki = ! ∘-assocᶜ ∙ ap-∘ᶜ R idp ∙ ∘-assocᶜ\n\n LR : Squareᶜ (e ∘ᶜ f) g j (k ∘ᶜ i)\n LR = efg-ehi ∙ ehi-jki\n\n {-\n X\n / . \\\n / . \\\n / . \\\n f/ .u! \\g\n / . \\\n v v v\n A <---fst--- A×B ---snd---> B\n -}\n module _\n {A B A×B X : Objᶜ}\n {fstᶜ : A×B →ᶜ A}\n {sndᶜ : A×B →ᶜ B}\n {f : X →ᶜ A}\n {g : X →ᶜ B}\n (u! : X →ᶜ A×B)\n (fst-u! : fstᶜ ∘ᶜ u! ≡ f)\n (snd-u! : sndᶜ ∘ᶜ u! ≡ g)\n where\n 1-ProductDiagram = fst-u! , snd-u!\n\n module ProductDiagram\n {A B A×B : Objᶜ}\n {fstᶜ : A×B →ᶜ A}\n {sndᶜ : A×B →ᶜ B}\n {<_,_>ᶜ : ∀ {X} → X →ᶜ A → X →ᶜ B → X →ᶜ A×B}\n (fst-<,> : ∀ {X} {f : X →ᶜ A} {g : X →ᶜ B}\n → fstᶜ ∘ᶜ < f , g >ᶜ ≡ f)\n (snd-<,> : ∀ {X} {f : X →ᶜ A} {g : X →ᶜ B}\n → sndᶜ ∘ᶜ < f , g >ᶜ ≡ g)\n (<,>-uniq! : ∀ {A B X : Objᶜ} {f : X →ᶜ A×B}\n → < fstᶜ ∘ᶜ f , sndᶜ ∘ᶜ f >ᶜ ≡ f)\n where\n\n module _ {X} {f : X →ᶜ A} {g : X →ᶜ B} where\n 1-productDiagram = 1-ProductDiagram < f , g >ᶜ fst-<,> snd-<,>\n\n infixr 9 _∘ᵖ_\n _∘ᵖ_ : {A B C : Objᵖ} → (B →ᵖ C) → (A →ᵖ B) → (A →ᵖ C)\n (f , ☐f) ∘ᵖ (g , ☐g) = (λ n → f n ∘ᶜ g n)\n , (λ n → LR (☐g n) (☐f n))\n\n -- TODO: the real thing™\n _≡ᵖ_ : {A B : Objᵖ} (f g : A →ᵖ B) → Type_ _\n (f , _) ≡ᵖ (g , _) = ∀ n → f n ≡ g n\n infix 2 _≡ᵖ_\n\n ∘-idᵖ : {A B : Objᵖ} {f : A →ᵖ B} → f ∘ᵖ idᵖ ≡ᵖ f\n ∘-idᵖ _ = ∘-idᶜ\n\n id-∘ᵖ : {A B : Objᵖ} {f : A →ᵖ B} → idᵖ ∘ᵖ f ≡ᵖ f\n id-∘ᵖ _ = id-∘ᶜ\n\n ∘-assocᵖ : {A B C D : Objᵖ}\n {f : C →ᵖ D} {g : B →ᵖ C} {h : A →ᵖ B}\n → (f ∘ᵖ g) ∘ᵖ h ≡ᵖ f ∘ᵖ (g ∘ᵖ h)\n ∘-assocᵖ _ = ∘-assocᶜ\n\n 𝟙ᵖ : Objᵖ\n 𝟙ᵖ = (λ _ → 𝟙ᶜ) , (λ _ → idᶜ)\n !ᵖ : {A : Objᵖ} → A →ᵖ 𝟙ᵖ\n !ᵖ = (λ _ → !ᶜ) , (λ _ → !-irrᶜ)\n !-uniqᵖ : {A : Objᵖ} {f : A →ᵖ 𝟙ᵖ} → f ≡ᵖ !ᵖ\n !-uniqᵖ _ = !-uniqᶜ\n\n ▸ : Objᵖ → Objᵖ\n ▸ (A , rᴬ) = ▸A , ▸rᴬ\n module Later where\n ▸A : ℕ → Objᶜ\n ▸A 0 = 𝟙ᶜ\n ▸A (S n) = A n\n ▸rᴬ : (n : ℕ) → ▸A (1 + n) →ᶜ ▸A n\n ▸rᴬ 0 = !ᶜ\n ▸rᴬ (S n) = rᴬ n\n\n -- ▸ functor action on morphisms\n ▸[_] : {A B : Objᵖ} → (A →ᵖ B) → ▸ A →ᵖ ▸ B\n ▸[_] {A , rᴬ} {B , rᴮ} (f , ☐) = ▸f , ▸☐\n module Later[] where\n open Later A rᴬ\n open Later B rᴮ renaming (▸A to ▸B; ▸rᴬ to ▸rᴮ)\n ▸f : ▸A →ᶜ° ▸B\n ▸f 0 = !ᶜ\n ▸f (S n) = f n\n ▸☐ : (n : ℕ) → ▸f n ∘ᶜ ▸rᴬ n ≡ ▸rᴮ n ∘ᶜ ▸f (1 + n)\n ▸☐ 0 = !-irrᶜ\n ▸☐ (S n) = ☐ n\n\n ▸-id : {A : Objᵖ}\n → ▸[ idᵖ {A} ] ≡ᵖ idᵖ\n ▸-id 0 = !-irrᶜ\n ▸-id (S n) = idp\n\n ▸-∘ : {A B C : Objᵖ} {f : B →ᵖ C} {g : A →ᵖ B}\n → ▸[ f ∘ᵖ g ] ≡ᵖ ▸[ f ] ∘ᵖ ▸[ g ]\n ▸-∘ 0 = !-irrᶜ\n ▸-∘ (S n) = idp\n\n {-\n ▸-[]ᵖ : {A : Objᶜ} → ▸ [ A ]ᵖ →ᵖ [ A ]ᵖ\n ▸-[]ᵖ {A} = ▸f , ▸☐\n where\n open Later (λ _ → A) (λ _ → idᶜ)\n ▸f : ▸A →ᶜ° (λ _ → A)\n ▸f O = {!!}\n ▸f (S n) = idᶜ\n ▸☐ : (n : ℕ) → ▸f n ∘ᶜ ▸rᴬ n ≡ idᶜ ∘ᶜ ▸f (1 + n)\n ▸☐ O = {!!}\n ▸☐ (S n) = idp\n -}\n\n next : {A : Objᵖ} → A →ᵖ ▸ A\n next {A , rᴬ} = f , ☐\n module Next where\n open Later A rᴬ\n f : (n : ℕ) → A n →ᶜ ▸A n\n f 0 = !ᶜ\n f (S n) = rᴬ n\n\n ☐ : (n : ℕ) → f n ∘ᶜ rᴬ n ≡ ▸rᴬ n ∘ᶜ f (1 + n)\n ☐ 0 = idp\n ☐ (S n) = idp\n\n next-nat : {A B : Objᵖ} {f : A →ᵖ B} → ▸[ f ] ∘ᵖ next ≡ᵖ next ∘ᵖ f\n next-nat 0 = !-irrᶜ\n next-nat {f = f , ☐} (S n) = ☐ n\n\n module _ {A : Objᵖ} (f : A →ᵖ A) where\n Contractive = Σ (▸ A →ᵖ A) λ g → f ≡ᵖ g ∘ᵖ next\n\n module _ {A B : Objᶜ} {i : B →ᶜ B} {f : A →ᶜ B} where\n id-∘ᶜ' : i ≡ idᶜ → i ∘ᶜ f ≡ f\n id-∘ᶜ' p = ap-∘ᶜ p idp ∙ id-∘ᶜ\n module _ {A B : Objᶜ} {i : A →ᶜ A} {f : A →ᶜ B} where\n ∘-idᶜ' : i ≡ idᶜ → f ∘ᶜ i ≡ f\n ∘-idᶜ' p = ap-∘ᶜ idp p ∙ ∘-idᶜ\n\n fix1 : {A : Objᵖ} (f : ▸ A →ᵖ A) → 𝟙ᵖ →ᵖ A\n fix1 {A , rᴬ} (f , ☐) = fixf , λ n → ∘-idᶜ ∙ fix☐ n\n module Fix1 where\n open Later A rᴬ\n\n fixf : (n : ℕ) → 𝟙ᶜ →ᶜ A n\n fixf 0 = f 0\n fixf (S n) = f (S n) ∘ᶜ fixf n\n\n fix☐ : (n : ℕ) → fixf n ≡ rᴬ n ∘ᶜ fixf (1 + n)\n fix☐ 0 = ! ∘-!ᶜ ∙ with-∘-assocᶜ (☐ 0)\n fix☐ (S n) = ap-∘ᶜ idp (fix☐ n) ∙ with-∘-assocᶜ (☐ (S n))\n\n module WithProducts\n (_×ᶜ_ : Objᶜ → Objᶜ → Objᶜ)\n -- projections\n (fstᶜ : ∀ {A B} → (A ×ᶜ B) →ᶜ A)\n (sndᶜ : ∀ {A B} → (A ×ᶜ B) →ᶜ B)\n -- injection (pair creation)\n (<_,_>ᶜ : ∀ {A B C} → A →ᶜ B → A →ᶜ C → A →ᶜ (B ×ᶜ C))\n -- computation rules\n (fst-<,> : ∀ {A B C} {f : A →ᶜ B} {g : A →ᶜ C}\n → fstᶜ ∘ᶜ < f , g >ᶜ ≡ f)\n (snd-<,> : ∀ {A B C} {f : A →ᶜ B} {g : A →ᶜ C}\n → sndᶜ ∘ᶜ < f , g >ᶜ ≡ g)\n -- universal property\n (<,>-uniq! : ∀ {A B X : Objᶜ} {f : X →ᶜ (A ×ᶜ B)}\n → < fstᶜ ∘ᶜ f , sndᶜ ∘ᶜ f >ᶜ ≡ f)\n where\n\n firstᶜ : ∀ {A B C} → A →ᶜ B → (A ×ᶜ C) →ᶜ (B ×ᶜ C)\n firstᶜ f = < f ∘ᶜ fstᶜ , sndᶜ >ᶜ\n\n secondᶜ : ∀ {A B C} → B →ᶜ C → (A ×ᶜ B) →ᶜ (A ×ᶜ C)\n secondᶜ f = < fstᶜ , f ∘ᶜ sndᶜ >ᶜ\n\n <_×_>ᶜ : ∀ {A B C D} (f : A →ᶜ C) (g : B →ᶜ D) → (A ×ᶜ B) →ᶜ (C ×ᶜ D)\n < f × g >ᶜ = < f ∘ᶜ fstᶜ , g ∘ᶜ sndᶜ >ᶜ\n\n module _ {A B C} {f f' : A →ᶜ B} {g g' : A →ᶜ C} where\n ≡<_,_> : f ≡ f' → g ≡ g' → < f , g >ᶜ ≡ < f' , g' >ᶜ\n ≡< p , q > = ap (λ f → < f , g >ᶜ) p ∙ ap (λ g → < f' , g >ᶜ) q\n\n module _ {A B C X} {f₀ : A →ᶜ B} {f₁ : A →ᶜ C} {g : X →ᶜ A} where\n <,>-∘ : < f₀ , f₁ >ᶜ ∘ᶜ g ≡ < f₀ ∘ᶜ g , f₁ ∘ᶜ g >ᶜ\n <,>-∘ = ! <,>-uniq! ∙ ≡< ! ∘-assocᶜ ∙ ap-∘ᶜ fst-<,> idp\n , ! ∘-assocᶜ ∙ ap-∘ᶜ snd-<,> idp >\n\n module _ {A B} where\n -- η-rule\n : < fstᶜ , sndᶜ >ᶜ ≡ idᶜ {A ×ᶜ B}\n = ≡< ! ∘-idᶜ , ! ∘-idᶜ > ∙ <,>-uniq!\n\n : < fstᶜ , idᶜ ∘ᶜ sndᶜ >ᶜ ≡ idᶜ {A ×ᶜ B}\n = ≡< idp , id-∘ᶜ > ∙ \n\n _×ᶜ°_ : (A B : ℕ → Objᶜ) → ℕ → Objᶜ\n (A ×ᶜ° B) n = A n ×ᶜ B n\n\n _×ʳ_ : {A B : ℕ → Objᶜ} → Rmap A → Rmap B → Rmap (A ×ᶜ° B)\n (rᴬ ×ʳ rᴮ) n = < rᴬ n × rᴮ n >ᶜ\n\n _×ᵖ_ : Objᵖ → Objᵖ → Objᵖ\n (A , rᴬ) ×ᵖ (B , rᴮ) = (A ×ᶜ° B) , (rᴬ ×ʳ rᴮ)\n\n fstᵖ : ∀ {A B} → (A ×ᵖ B) →ᵖ A\n fstᵖ = (λ _ → fstᶜ) , (λ _ → fst-<,>)\n\n sndᵖ : ∀ {A B} → (A ×ᵖ B) →ᵖ B\n sndᵖ = (λ _ → sndᶜ) , (λ _ → snd-<,>)\n\n <_,_>ᵖ : ∀ {A B C} → A →ᵖ B → A →ᵖ C → A →ᵖ (B ×ᵖ C)\n <_,_>ᵖ {A , rᴬ} {B , rᴮ} {C , rᶜ} (f , f☐) (g , g☐) =\n (λ n → < f n , g n >ᶜ) ,\n (λ n → <,>-∘\n ∙ ≡< f☐ n ∙ ap-∘ᶜ idp (! fst-<,>) ∙ ! ∘-assocᶜ\n , g☐ n ∙ ap-∘ᶜ idp (! snd-<,>) ∙ ! ∘-assocᶜ >\n ∙ ! <,>-∘)\n\n firstᵖ : ∀ {A B C} → A →ᵖ B → (A ×ᵖ C) →ᵖ (B ×ᵖ C)\n firstᵖ f = < f ∘ᵖ fstᵖ , sndᵖ >ᵖ\n\n ▸-× : {A B : Objᵖ} → ▸(A ×ᵖ B) →ᵖ (▸ A ×ᵖ ▸ B)\n ▸-× {A , rᴬ} {B , rᴮ} = ▸f , ▸☐\n module LaterProduct where\n open Later A rᴬ\n open Later B rᴮ renaming (▸A to ▸B; ▸rᴬ to ▸rᴮ)\n open Later (A ×ᶜ° B) (rᴬ ×ʳ rᴮ) renaming (▸A to ▸AB; ▸rᴬ to ▸rᴬᴮ)\n ▸f : ▸AB →ᶜ° (▸A ×ᶜ° ▸B)\n ▸f 0 = < !ᶜ , !ᶜ >ᶜ\n ▸f (S n) = idᶜ\n ▸☐ : (n : ℕ) → ▸f n ∘ᶜ ▸rᴬᴮ n ≡ (▸rᴬ ×ʳ ▸rᴮ) n ∘ᶜ ▸f (1 + n)\n ▸☐ 0 = <,>-∘ ∙ ≡< !-irrᶜ , !-irrᶜ > ∙ ! ∘-idᶜ\n ▸☐ (S n) = id-∘ᶜ ∙ ! ∘-idᶜ\n\n _^_ : Objᶜ → ℕ → Objᶜ\n A ^ 0 = 𝟙ᶜ\n A ^(S n) = A ×ᶜ (A ^ n)\n\n fix : {A B : Objᵖ} (f : (B ×ᵖ ▸ A) →ᵖ A) → B →ᵖ A\n fix {A , rᴬ} {B , rᴮ} (f , ☐) = fixf , fix☐\n module Fix where\n open Later A rᴬ\n open Later B rᴮ renaming (▸A to ▸B; ▸rᴬ to ▸rᴮ)\n\n fixf : (n : ℕ) → B n →ᶜ A n\n fixf 0 = f 0 ∘ᶜ < idᶜ , !ᶜ >ᶜ\n fixf (S n) = f (S n) ∘ᶜ < idᶜ , fixf n ∘ᶜ rᴮ n >ᶜ\n\n fix☐ : (n : ℕ) → fixf n ∘ᶜ rᴮ n ≡ rᴬ n ∘ᶜ fixf (1 + n)\n fix☐ 0 = ∘-assocᶜ ∙ ap-∘ᶜ idp (<,>-∘ ∙ ≡< id-∘ᶜ ∙ ! (∘-idᶜ' fst-<,>) ∙ ! ∘-assocᶜ , !-irrᶜ > ∙ ! <,>-∘) ∙ with-∘-assocᶜ (☐ 0)\n fix☐ (S n) = ∘-assocᶜ ∙ ap-∘ᶜ idp (<,>-∘ ∙ ≡< id-∘ᶜ ∙ ! (∘-idᶜ' fst-<,>) ∙ ! ∘-assocᶜ , h > ∙ ! <,>-∘) ∙ with-∘-assocᶜ (☐ (S n))\n where h = ap-∘ᶜ (fix☐ n) idp ∙ with-!∘-assocᶜ (! snd-<,>)\n\n module _ {A} where\n initᶜ : ∀ n → (A ^(1 + n)) →ᶜ (A ^ n)\n initᶜ 0 = !ᶜ\n initᶜ (S n) = secondᶜ (initᶜ n)\n\n module Str1\n (A : Objᶜ)\n where\n\n Aᵖ = [ A ]ᵖ\n\n Str : ℕ → Objᶜ\n Str n = A ^(1 + n)\n\n rStr : (n : ℕ) → Str (1 + n) →ᶜ Str n\n rStr = λ n → initᶜ (1 + n)\n\n Strᵖ : Objᵖ\n Strᵖ = Str , rStr\n\n open Later Str (snd Strᵖ) renaming (▸A to ▸Str; ▸rᴬ to ▸rStr)\n\n roll : (n : ℕ) → (A ^ n) →ᶜ ▸Str n\n roll 0 = !ᶜ -- or idᶜ {𝟙ᶜ}\n roll (S n) = idᶜ\n unroll : (n : ℕ) → ▸Str n →ᶜ (A ^ n)\n unroll 0 = !ᶜ -- or idᶜ {𝟙ᶜ}\n unroll (S n) = idᶜ\n\n hdᵖ : Strᵖ →ᵖ Aᵖ\n hdᵖ = (λ _ → fstᶜ) , (λ n → fst-<,> ∙ ! id-∘ᶜ)\n\n tlᵖ : Strᵖ →ᵖ ▸ Strᵖ\n tlᵖ = f , ☐\n where\n f : (n : ℕ) → Str n →ᶜ ▸Str n\n f n = roll n ∘ᶜ sndᶜ\n ☐ : (n : ℕ) → f n ∘ᶜ rStr n ≡ ▸rStr n ∘ᶜ f (1 + n)\n ☐ 0 = !-irrᶜ\n ☐ (S n) = ∘-assocᶜ ∙ id-∘ᶜ ∙ snd-<,> ∙ ap-∘ᶜ idp (! id-∘ᶜ)\n\n ∷ᵖ : (Aᵖ ×ᵖ ▸ Strᵖ) →ᵖ Strᵖ\n ∷ᵖ = f , ☐\n where\n f : (n : ℕ) → (A ×ᶜ ▸Str n) →ᶜ Str n\n f n = secondᶜ (unroll n)\n ☐ : (n : ℕ) → f n ∘ᶜ snd (Aᵖ ×ᵖ ▸ Strᵖ) n ≡ rStr n ∘ᶜ f (1 + n)\n ☐ 0 = <,>-∘ ∙ ≡< fst-<,> ∙ id-∘ᶜ , !-irrᶜ > ∙ !(∘-idᶜ' )\n ☐ (S n) = id-∘ᶜ' ∙ ≡< id-∘ᶜ , idp > ∙ !(∘-idᶜ' )\n\n repeatᵖ : (𝟙ᵖ →ᵖ Aᵖ) → 𝟙ᵖ →ᵖ Strᵖ\n repeatᵖ f = fix1 it\n where it : ▸ Strᵖ →ᵖ Strᵖ\n it = ∷ᵖ ∘ᵖ < f ∘ᵖ !ᵖ , idᵖ >ᵖ\n\n {-\n iterate f x = x ∷ iterate f (f x)\n or \n iterate f = (∷) id (iterate f ∘ f)\n -}\n {-\n iterateᵖ : (Aᵖ →ᵖ Aᵖ) → Aᵖ →ᵖ Strᵖ\n iterateᵖ f = fix it -- sndᵖ ∘ᵖ fix it ∘ᵖ !ᵖ\n where\n it : Aᵖ ×ᵖ ▸ Strᵖ →ᵖ Strᵖ\n it = < fstᵖ , ∷ᵖ >ᵖ ∘ᵖ firstᵖ (f ∘ᵖ {!!}) ∘ᵖ ▸-×\n -}\n\n{-\n mapᵖ : ([ A ]ᵖ →ᵖ [ A ]ᵖ) → Strᵖ →ᵖ Strᵖ\n mapᵖ f = {!fix!}\n-}\n\n Objᶜ↑ : ℕ → Endo (ℕ → Objᶜ)\n Objᶜ↑ k A n = A (n + k)\n\n ↑ᶜ° : ∀ k {A B} → A →ᶜ° B → Objᶜ↑ k A →ᶜ° Objᶜ↑ k B\n ↑ᶜ° k f n = f (n + k)\n\n ↑r : ∀ k {A} → Rmap A → Rmap (Objᶜ↑ k A)\n ↑r k rᴬ n = rᴬ (n + k)\n\n Objᵖ↑ : ℕ → Endo Objᵖ\n Objᵖ↑ k (A , rᴬ) = Objᶜ↑ k A , ↑r k rᴬ\n\n r* : {A : ℕ → Objᶜ}\n (rᴬ : Rmap A)\n (n : ℕ) → A (1 + n) →ᶜ A 0\n r* rᴬ 0 = rᴬ 0\n r* rᴬ (S n) = r* rᴬ n ∘ᶜ rᴬ (S n)\n\n module _\n {A B : ℕ → Objᶜ}\n {rᴬ : (n : ℕ) → A (1 + n) →ᶜ A n}\n {rᴮ : (n : ℕ) → B (1 + n) →ᶜ B n}\n (f : (n : ℕ) → A n →ᶜ B n)\n (☐f : (n : ℕ) → f n ∘ᶜ rᴬ n ≡ rᴮ n ∘ᶜ f (1 + n))\n where\n\n ☐* : (n : ℕ) → f 0 ∘ᶜ r* rᴬ n ≡ r* rᴮ n ∘ᶜ f (1 + n)\n ☐* 0 = ☐f 0\n ☐* (S n) = ! ∘-assocᶜ\n ∙ ap-∘ᶜ (☐* n) idp\n ∙ ∘-assocᶜ\n ∙ ap-∘ᶜ idp (☐f (S n))\n ∙ ! ∘-assocᶜ\n\n module _\n {A B : ℕ → Objᶜ}\n {rᴬ : (n : ℕ) → A (1 + n) →ᶜ A n}\n {rᴮ : (n : ℕ) → B (1 + n) →ᶜ B n}\n (f : (n : ℕ) → A n →ᶜ B n)\n (☐f : (n : ℕ) → f n ∘ᶜ rᴬ n ≡ rᴮ n ∘ᶜ f (1 + n))\n (k : ℕ)\n where\n\n --☐*' : (n : ℕ) → f k ∘ᶜ r* (↑r k rᴬ) n ≡ r* (↑r k rᴮ) n ∘ᶜ f ((1 + n) + k)\n --☐*' n = ☐* (↑ᶜ° k f) {!!} n\n\n module WithMore -- TODO upto topos\n -- Initial object\n (𝟘ᶜ : Objᶜ)\n (¡ᶜ : {A : Objᶜ} → 𝟘ᶜ →ᶜ A)\n (¡-uniqᶜ : {A : Objᶜ} {f : 𝟘ᶜ →ᶜ A} → ¡ᶜ ≡ f)\n\n -- Coproducts\n (_+ᶜ_ : Objᶜ → Objᶜ → Objᶜ)\n -- injections\n (inlᶜ : ∀ {A B} → A →ᶜ (A +ᶜ B))\n (inrᶜ : ∀ {A B} → B →ᶜ (A +ᶜ B))\n -- projection (coproduct elimination)\n ([_,_]ᶜ : ∀ {A B C} → B →ᶜ A → C →ᶜ A → (B +ᶜ C) →ᶜ A)\n -- computation rules\n ([,]-inl : ∀ {A B C} {f : B →ᶜ A} {g : C →ᶜ A}\n → [ f , g ]ᶜ ∘ᶜ inlᶜ ≡ f)\n ([,]-inr : ∀ {A B C} {f : B →ᶜ A} {g : C →ᶜ A}\n → [ f , g ]ᶜ ∘ᶜ inrᶜ ≡ g)\n -- universal property\n ([,]-uniq! : ∀ {A B X : Objᶜ} {f : (A +ᶜ B) →ᶜ X}\n → [ f ∘ᶜ inlᶜ , f ∘ᶜ inrᶜ ]ᶜ ≡ f)\n where\n-- -}\n-- -}\n-- -}\n-- -}\n", "meta": {"hexsha": "f032f20f76590b23868086b91291c0bb9de216b4", "size": 15095, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "guarded-recursion/model.agda", "max_stars_repo_name": "np/guarded-recursion", "max_stars_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-12-06T23:04:56.000Z", "max_stars_repo_stars_event_max_datetime": "2016-12-06T23:04:56.000Z", "max_issues_repo_path": "guarded-recursion/model.agda", "max_issues_repo_name": "np/guarded-recursion", "max_issues_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "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": "guarded-recursion/model.agda", "max_forks_repo_name": "np/guarded-recursion", "max_forks_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-08-19T12:37:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-16T16:21:54.000Z", "avg_line_length": 29.3106796117, "max_line_length": 139, "alphanum_fraction": 0.3440874462, "num_tokens": 9497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772450055544, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.5816202337866726}} {"text": "{-# OPTIONS --without-K #-}\n\n-- The universe of all types\nmodule hott.core.universe where\n\nopen import Agda.Primitive public using (Level; lzero; lsuc; _⊔_)\n\n-- We give an new name for Set\nType : (ℓ : Level) → Set (lsuc ℓ)\nType ℓ = Set ℓ\n\nlone : Level; lone = lsuc lzero\nltwo : Level; ltwo = lsuc lone\nlthree : Level; lthree = lsuc ltwo\nlfour : Level; lfour = lsuc lthree\nlfive : Level; lfive = lsuc lfour\nlsix : Level; lsix = lsuc lfive\nlseven : Level; lseven = lsuc lsix\nleight : Level; leight = lsuc lseven\nlnine : Level; lnine = lsuc leight\n\nType₀ = Type lzero\nType₁ = Type lone\nType₂ = Type ltwo\nType₃ = Type lthree\nType₄ = Type lfour\nType₅ = Type lfive\nType₆ = Type lsix\nType₇ = Type lseven\nType₈ = Type leight\nType₉ = Type lnine\n", "meta": {"hexsha": "31c6a4af94679326887fcff9e5658eee607981bc", "size": 754, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/core/universe.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/core/universe.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/core/universe.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": 23.5625, "max_line_length": 65, "alphanum_fraction": 0.6856763926, "num_tokens": 279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772318846386, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.5816202250558765}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Algebra.Group.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.SIP\nopen import Cubical.Data.Sigma\nopen import Cubical.Data.Int renaming (_+_ to _+Int_ ; _-_ to _-Int_)\nopen import Cubical.Data.Unit\n\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.Semigroup\nopen import Cubical.Foundations.HLevels\n\nprivate\n variable\n ℓ : Level\n\nrecord IsGroup {G : Type ℓ}\n (0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where\n\n constructor isgroup\n\n field\n isMonoid : IsMonoid 0g _+_\n inverse : (x : G) → (x + (- x) ≡ 0g) × ((- x) + x ≡ 0g)\n\n open IsMonoid isMonoid public\n\n infixl 6 _-_\n\n _-_ : G → G → G\n x - y = x + (- y)\n\n invl : (x : G) → (- x) + x ≡ 0g\n invl x = inverse x .snd\n\n invr : (x : G) → x + (- x) ≡ 0g\n invr x = inverse x .fst\n\nrecord GroupStr (G : Type ℓ) : Type (ℓ-suc ℓ) where\n\n constructor groupstr\n\n field\n 0g : G\n _+_ : G → G → G\n -_ : G → G\n isGroup : IsGroup 0g _+_ -_\n\n infix 8 -_\n infixr 7 _+_\n\n open IsGroup isGroup public\n\nGroup : Type (ℓ-suc ℓ)\nGroup = TypeWithStr _ GroupStr\n\nGroup₀ : Type₁\nGroup₀ = Group {ℓ-zero}\n\ngroup : (G : Type ℓ) (0g : G) (_+_ : G → G → G) (-_ : G → G) (h : IsGroup 0g _+_ -_) → Group\ngroup G 0g _+_ -_ h = G , groupstr 0g _+_ -_ h\n\nisSetGroup : (G : Group {ℓ}) → isSet ⟨ G ⟩\nisSetGroup G = GroupStr.isGroup (snd G) .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set\n\nmakeIsGroup : {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G}\n (is-setG : isSet G)\n (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)\n (rid : (x : G) → x + 0g ≡ x)\n (lid : (x : G) → 0g + x ≡ x)\n (rinv : (x : G) → x + (- x) ≡ 0g)\n (linv : (x : G) → (- x) + x ≡ 0g)\n → IsGroup 0g _+_ -_\nIsGroup.isMonoid (makeIsGroup is-setG assoc rid lid rinv linv) = makeIsMonoid is-setG assoc rid lid\nIsGroup.inverse (makeIsGroup is-setG assoc rid lid rinv linv) = λ x → rinv x , linv x\n\nmakeGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G)\n (is-setG : isSet G)\n (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)\n (rid : (x : G) → x + 0g ≡ x)\n (lid : (x : G) → 0g + x ≡ x)\n (rinv : (x : G) → x + (- x) ≡ 0g)\n (linv : (x : G) → (- x) + x ≡ 0g)\n → Group\nmakeGroup 0g _+_ -_ is-setG assoc rid lid rinv linv = _ , helper\n where\n helper : GroupStr _\n GroupStr.0g helper = 0g\n GroupStr._+_ helper = _+_\n GroupStr.- helper = -_\n GroupStr.isGroup helper = makeIsGroup is-setG assoc rid lid rinv linv\n\nmakeGroup-right : ∀ {ℓ} {A : Type ℓ}\n → (id : A)\n → (comp : A → A → A)\n → (inv : A → A)\n → (set : isSet A)\n → (assoc : ∀ a b c → comp a (comp b c) ≡ comp (comp a b) c)\n → (rUnit : ∀ a → comp a id ≡ a)\n → (rCancel : ∀ a → comp a (inv a) ≡ id)\n → Group\nmakeGroup-right id comp inv set assoc rUnit rCancel =\n makeGroup id comp inv set assoc rUnit lUnit rCancel lCancel\n where\n _⨀_ = comp\n abstract\n lCancel : ∀ a → comp (inv a) a ≡ id\n lCancel a =\n inv a ⨀ a\n ≡⟨ sym (rUnit (comp (inv a) a)) ⟩\n (inv a ⨀ a) ⨀ id\n ≡⟨ cong (comp (comp (inv a) a)) (sym (rCancel (inv a))) ⟩\n (inv a ⨀ a) ⨀ (inv a ⨀ (inv (inv a)))\n ≡⟨ assoc _ _ _ ⟩\n ((inv a ⨀ a) ⨀ (inv a)) ⨀ (inv (inv a))\n ≡⟨ cong (λ □ → □ ⨀ _) (sym (assoc _ _ _)) ⟩\n (inv a ⨀ (a ⨀ inv a)) ⨀ (inv (inv a))\n ≡⟨ cong (λ □ → (inv a ⨀ □) ⨀ (inv (inv a))) (rCancel a) ⟩\n (inv a ⨀ id) ⨀ (inv (inv a))\n ≡⟨ cong (λ □ → □ ⨀ (inv (inv a))) (rUnit (inv a)) ⟩\n inv a ⨀ (inv (inv a))\n ≡⟨ rCancel (inv a) ⟩\n id\n ∎\n\n lUnit : ∀ a → comp id a ≡ a\n lUnit a =\n id ⨀ a\n ≡⟨ cong (λ b → comp b a) (sym (rCancel a)) ⟩\n (a ⨀ inv a) ⨀ a\n ≡⟨ sym (assoc _ _ _) ⟩\n a ⨀ (inv a ⨀ a)\n ≡⟨ cong (comp a) (lCancel a) ⟩\n a ⨀ id\n ≡⟨ rUnit a ⟩\n a\n ∎\n\nmakeGroup-left : ∀ {ℓ} {A : Type ℓ}\n → (id : A)\n → (comp : A → A → A)\n → (inv : A → A)\n → (set : isSet A)\n → (assoc : ∀ a b c → comp a (comp b c) ≡ comp (comp a b) c)\n → (lUnit : ∀ a → comp id a ≡ a)\n → (lCancel : ∀ a → comp (inv a) a ≡ id)\n → Group\nmakeGroup-left id comp inv set assoc lUnit lCancel =\n makeGroup id comp inv set assoc rUnit lUnit rCancel lCancel\n where\n abstract\n rCancel : ∀ a → comp a (inv a) ≡ id\n rCancel a =\n comp a (inv a)\n ≡⟨ sym (lUnit (comp a (inv a))) ⟩\n comp id (comp a (inv a))\n ≡⟨ cong (λ b → comp b (comp a (inv a))) (sym (lCancel (inv a))) ⟩\n comp (comp (inv (inv a)) (inv a)) (comp a (inv a))\n ≡⟨ sym (assoc (inv (inv a)) (inv a) (comp a (inv a))) ⟩\n comp (inv (inv a)) (comp (inv a) (comp a (inv a)))\n ≡⟨ cong (comp (inv (inv a))) (assoc (inv a) a (inv a)) ⟩\n comp (inv (inv a)) (comp (comp (inv a) a) (inv a))\n ≡⟨ cong (λ b → comp (inv (inv a)) (comp b (inv a))) (lCancel a) ⟩\n comp (inv (inv a)) (comp id (inv a))\n ≡⟨ cong (comp (inv (inv a))) (lUnit (inv a)) ⟩\n comp (inv (inv a)) (inv a)\n ≡⟨ lCancel (inv a) ⟩\n id\n ∎\n\n rUnit : ∀ a → comp a id ≡ a\n rUnit a =\n comp a id\n ≡⟨ cong (comp a) (sym (lCancel a)) ⟩\n comp a (comp (inv a) a)\n ≡⟨ assoc a (inv a) a ⟩\n comp (comp a (inv a)) a\n ≡⟨ cong (λ b → comp b a) (rCancel a) ⟩\n comp id a\n ≡⟨ lUnit a ⟩\n a\n ∎\n\nopen GroupStr hiding (0g ; _+_ ; -_)\n\nisSetCarrier : ∀ {ℓ} → (G : Group {ℓ}) → isSet ⟨ G ⟩\nisSetCarrier G = IsSemigroup.is-set (IsMonoid.isSemigroup (GroupStr.isMonoid (snd G)))\n\nopen GroupStr\n\ndirProd : ∀ {ℓ ℓ'} → Group {ℓ} → Group {ℓ'} → Group\ndirProd (GC , G) (HC , H) =\n makeGroup (0g G , 0g H)\n (λ { (x1 , x2) (y1 , y2) → _+_ G x1 y1 , _+_ H x2 y2 })\n (λ { (x1 , x2) → -_ G x1 , -_ H x2 })\n (isSet× (isSetCarrier (GC , G)) (isSetCarrier (HC , H)))\n (λ { (x1 , x2) (y1 , y2) (z1 , z2) i →\n assoc G x1 y1 z1 i , assoc H x2 y2 z2 i })\n (λ { (x1 , x2) i → GroupStr.rid G x1 i , GroupStr.rid H x2 i })\n (λ { (x1 , x2) i → GroupStr.lid G x1 i , GroupStr.lid H x2 i })\n (λ { (x1 , x2) i → GroupStr.invr G x1 i , GroupStr.invr H x2 i })\n (λ { (x1 , x2) i → GroupStr.invl G x1 i , GroupStr.invl H x2 i })\n\ntrivialGroup : Group₀\ntrivialGroup = Unit , groupstr tt (λ _ _ → tt) (λ _ → tt)\n (makeIsGroup isSetUnit (λ _ _ _ → refl) (λ _ → refl) (λ _ → refl)\n (λ _ → refl) (λ _ → refl))\n\nintGroup : Group₀\nintGroup = Int , groupstr 0 _+Int_ (0 -Int_)\n (makeIsGroup isSetInt +-assoc (λ x → refl) (λ x → +-comm 0 x)\n (λ x → +-comm x (pos 0 -Int x) ∙ minusPlus x 0) (λ x → minusPlus x 0))\n", "meta": {"hexsha": "407277ce24e9f24734b3fab004f79925051a3e71", "size": 6983, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Group/Base.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/Algebra/Group/Base.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/Algebra/Group/Base.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": 32.6308411215, "max_line_length": 100, "alphanum_fraction": 0.4791636832, "num_tokens": 2786, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.5815447959877847}} {"text": "{-# OPTIONS --without-K --safe #-}\n\n--------------------------------------------------------------------------------\n-- Simple implementation of sets of ℕ.\n--------------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Nat.Table where\n\nopen import Data.Nat as ℕ using (ℕ; suc; zero)\nopen import Data.List as List using (List; _∷_; [])\nopen import Function\n\nTable : Set\nTable = List ℕ\n\npara : ∀ {a b} {A : Set a} {B : Set b} → (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\ninsert : ℕ → Table → Table\ninsert x xs = para (go zero) (_∷ []) xs x\n where\n go : ℕ → ℕ → Table → (ℕ → Table) → ℕ → Table\n go k zero xs g zero = k ∷ xs\n go k zero xs g (suc i) = k ∷ g i\n go k (suc x) xs g zero = k ∷ x ∷ xs\n go k (suc x) xs g (suc i) = go (suc k) x xs g i\n\nopen import Data.Maybe as Maybe using (Maybe; just; nothing)\n\nmember : ℕ → Table → Maybe ℕ\nmember x xs = List.foldr go (const (const nothing)) xs x 0\n where\n go : ℕ → (ℕ → ℕ → Maybe ℕ) → ℕ → ℕ → Maybe ℕ\n go zero ys zero k = just k\n go zero ys (suc x) k = ys x (suc k)\n go (suc y) ys zero _ = nothing\n go (suc y) ys (suc x) k = go y ys x k\n\nfromList : List ℕ → Table\nfromList = List.foldr insert []\n\ntoList : Table → List ℕ\ntoList = tail′ ∘ List.map ℕ.pred ∘ List.scanl (λ x y → suc (y ℕ.+ x)) 0\n where\n tail′ : List ℕ → List ℕ\n tail′ [] = []\n tail′ (_ ∷ xs) = xs\n\nprivate\n open import Relation.Binary.PropositionalEquality\n example₁ : fromList (4 ∷ 3 ∷ 1 ∷ 0 ∷ 2 ∷ []) ≡ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ [])\n example₁ = refl\n\n example₂ : member 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", "meta": {"hexsha": "9a6c4e934adf4480572f8425c84cdd601ae2ba32", "size": 1806, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Nat/Table.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/Data/Nat/Table.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/Data/Nat/Table.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": 29.1290322581, "max_line_length": 82, "alphanum_fraction": 0.5055370986, "num_tokens": 662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.5815447895012478}} {"text": "\nmodule UnquoteDef where\n\nopen import Common.Reflection\nopen import Common.Prelude\n\nmodule Target where\n mutual\n even : Nat → Bool\n even zero = true\n even (suc n) = odd n\n\n odd : Nat → Bool\n odd zero = false\n odd (suc n) = even n\n\npattern `false = con (quote false) []\npattern `true = con (quote true) []\npattern `zero = con (quote zero) []\npattern `suc n = con (quote suc) (vArg n ∷ [])\n\npattern _`→_ a b = pi (vArg a) (abs \"A\" b)\npattern `Nat = def (quote Nat) []\npattern `Bool = def (quote Bool) []\n\n`idType = `Nat `→ `Nat\n\n-- Simple non-mutual case\n`id : QName → FunDef\n`id f = funDef `idType\n ( clause (vArg `zero ∷ []) `zero\n ∷ clause (vArg (`suc (var \"n\")) ∷ []) (`suc (def f (vArg (var 0 []) ∷ [])))\n ∷ [])\n\n`idDef : QName → List Clause\n`idDef f =\n clause (vArg `zero ∷ []) `zero\n ∷ clause (vArg (`suc (var \"n\")) ∷ []) (`suc (def f (vArg (var 0 []) ∷ [])))\n ∷ []\n\n-- id : Nat → Nat\n-- unquoteDef id = `idDef id\n\n-- Now for the mutal ones\n`evenOdd : Term → QName → List Clause\n`evenOdd base step =\n clause (vArg `zero ∷ []) base\n ∷ clause (vArg (`suc (var \"n\")) ∷ []) (def step (vArg (var 0 []) ∷ []))\n ∷ []\n\n_>>_ : TC ⊤ → TC ⊤ → TC ⊤\nm >> m₁ = bindTC m λ _ → m₁\n\neven odd : Nat → Bool\nunquoteDef even odd =\n defineFun even (`evenOdd `true odd) >>\n defineFun odd (`evenOdd `false even)\n", "meta": {"hexsha": "c205bb18036369a2fda7cb388a98ff64f3b03851", "size": 1385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/UnquoteDef.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/UnquoteDef.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/UnquoteDef.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.8793103448, "max_line_length": 83, "alphanum_fraction": 0.5458483755, "num_tokens": 486, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.5815447830147102}} {"text": "\n{-# OPTIONS --no-universe-polymorphism #-}\nopen import Induction.WellFounded as WF\nopen import Data.Product \nopen import Relation.Binary.Core\nopen import Relation.Unary as U using (Decidable)\nopen import Relation.Nullary\nimport Level as L using (zero)\n\n\nmodule DivideEtImpera where\n{-- This module implements a quite general version of Divide and Conquer as desribed by Douglas R. Smith in his paper \n \"The Design of Divide and Conquer Algorithms\" 1984. the function makeD&C requires a well founded relation, a decidable proposition \n of whether a given input is primitive, a composition and a decomposition function, a special function g and a function dirSolve.\n All of these functions have to fullfill certain conditions and lastly you also need an \"induction principle\" that describes that these\n functions work well together. After putting in all this work, you can finally reap your reward: an algorithm that does what you want:\n takes inputs that satisfy the input condition and returns results that satisfy the output condition. \n --}\n\n\n{-- these 2 functions should be somewhere in the agda standard libraries but i couln't find them so i just wrote them again --}\n\n\nfoldAcc : {A : Set} → {_<_ : Rel A L.zero} → {R : A → Set} →\n (step : (x : A) → ((y : A) → _<_ y x → R y) → R x) →\n (z : A) → Acc _<_ z → R z\nfoldAcc step z (acc a) = step z (λ y y ¬¬P∘suc⇑i)\n\n------------------------------------------------------------------------\n-- Has upper bound\n\nmodule Has-upper-bound where\n\n open Above using (_Above_)\n\n -- P Has-upper-bound i means that P does not hold for any j ≥ i.\n\n infix 4 _Has-upper-bound_\n\n _Has-upper-bound_ : (ℕ → Set) → (ℕ → Set)\n P Has-upper-bound i = ∀ j → i ≤ j → ¬ P j\n\n -- A closure lemma.\n\n up : ∀ {P i} → P Has-upper-bound i → (P ∘ suc) Has-upper-bound i\n up ¬p = λ j i≤j → ¬p (suc j) (NatProp.≤-step i≤j)\n\n -- A conversion lemma.\n\n move-suc : ∀ {P i} →\n P Has-upper-bound suc i ⇔ (P ∘ suc) Has-upper-bound i\n move-suc {P} {i} = equivalence ⇒ ⇐\n where\n ⇒ : P Has-upper-bound suc i → (P ∘ suc) Has-upper-bound i\n ⇒ P↯[1+i] j i≤j P[1+j] = P↯[1+i] (1 + j) (s≤s i≤j) P[1+j]\n\n ⇐ : (P ∘ suc) Has-upper-bound i → P Has-upper-bound suc i\n ⇐ P∘suc↯i .(1 + j) (s≤s {n = j} i≤j) Pj = P∘suc↯i j i≤j Pj\n\n -- _Has-upper-bound_ and _Above_ are mutually inconsistent.\n\n mutually-inconsistent :\n ∀ {P i} → P Has-upper-bound i ⇔ (¬ (P Above i))\n mutually-inconsistent {P} {i} = equivalence ⇒ ⇐\n where\n ⇒ : P Has-upper-bound i → ¬ (P Above i)\n ⇒ P↯i (j , i≤j , Pj) = P↯i j i≤j Pj\n\n ⇐ : ¬ (P Above i) → P Has-upper-bound i\n ⇐ ¬P⇑i j i≤j Pj = ¬P⇑i (j , i≤j , Pj)\n\n------------------------------------------------------------------------\n-- Below\n\nmodule Below where\n\n open Above using (_Above_)\n\n -- P Below i holds if P holds everywhere below i (including at i).\n\n infix 4 _Below_\n\n _Below_ : (ℕ → Set) → (ℕ → Set)\n P Below i = ∀ j → j ≤ i → P j\n\n -- _Below_ P has a comonadic structure (at least if morphism\n -- equality is trivial).\n\n map : ∀ {P Q} → P ⊆ Q → _Below_ P ⊆ _Below_ Q\n map P⊆Q P⇓i j j≤i = P⊆Q (P⇓i j j≤i)\n\n counit : ∀ {P} → _Below_ P ⊆ P\n counit P⇓i = P⇓i _ NatOrder.refl\n\n cojoin : ∀ {P} → _Below_ P ⊆ _Below_ (_Below_ P)\n cojoin P⇓i = λ j j≤i k k≤j → P⇓i _ (NatOrder.trans k≤j j≤i)\n\n -- _Above_ (_Below_ P) is pointwise equivalent to _Below_ P.\n\n ⇑⇓⇔⇓ : ∀ {P} i → (_Below_ P) Above i ⇔ P Below i\n ⇑⇓⇔⇓ {P} i = equivalence ⇒ ⇐\n where\n ⇒ : (_Below_ P) Above i → P Below i\n ⇒ (j , i≤j , P⇓j) k k≤i = P⇓j k (NatOrder.trans k≤i i≤j)\n\n ⇐ : P Below i → (_Below_ P) Above i\n ⇐ P⇓i = (i , NatOrder.refl , P⇓i)\n\n------------------------------------------------------------------------\n-- Mixed inductive/coinductive definition of \"true infinitely often\"\n\nmodule Mixed where\n\n open Above using (_Above_)\n\n -- Inf P means that P is true for infinitely many natural numbers.\n\n data Inf (P : ℕ → Set) : Set where\n now : (p : P 0) (inf : ∞ (Inf (P ∘ suc))) → Inf P\n skip : (inf : Inf (P ∘ suc) ) → Inf P\n\n -- Inf commutes with binary sums in the double-negation monad if one\n -- of the predicates satisfies a certain stability condition.\n\n up : ∀ {P} → Inf P → Inf (P ∘ suc)\n up (now p inf) = ♭ inf\n up (skip inf) = inf\n\n filter₁ : ∀ {P Q} → Inf (P ∪ Q) → ¬ ∃ Q → Inf P\n filter₁ (now (inj₁ p) inf) ¬q = now p (♯ filter₁ (♭ inf) (¬q ∘ Prod.map suc id))\n filter₁ (now (inj₂ q) inf) ¬q = ⊥-elim (¬q (0 , q))\n filter₁ (skip inf) ¬q = skip (filter₁ inf (¬q ∘ Prod.map suc id))\n\n filter₂ : ∀ {P Q} → (∀ i → Stable (Q Above i)) →\n Inf (P ∪ Q) → ¬ Inf P → Inf Q\n filter₂ {P} {Q} stable p∪q ¬p = helper witness stable p∪q ¬p\n where\n open Related.EquationalReasoning\n\n witness : ∃ Q\n witness = Prod.map id proj₂ $ stable 0 (\n ¬ (Q Above 0) ∼⟨ contraposition (Prod.map id (_,_ z≤n)) ⟩\n ¬ ∃ Q ∼⟨ filter₁ p∪q ⟩\n Inf P ∼⟨ ¬p ⟩\n ⊥ ∎)\n\n helper : ∀ {P Q} →\n ∃ Q → (∀ i → Stable (Q Above i)) →\n Inf (P ∪ Q) → ¬ Inf P → Inf Q\n helper (zero , q) stable p∪q ¬p = now q (♯ filter₂ (Above.stable-up stable) (up p∪q) (¬p ∘ skip))\n helper (suc i , q) stable p∪q ¬p = skip (helper (i , q) (Above.stable-up stable) (up p∪q) (¬p ∘ skip))\n\n commutes : ∀ {P Q} → (∀ i → Stable (Q Above i)) →\n Inf (P ∪ Q) → ¬ ¬ (Inf P ⊎ Inf Q)\n commutes stable p∪q =\n call/cc λ ¬[p⊎q] →\n return $ inj₂ $ filter₂ stable p∪q (¬[p⊎q] ∘ inj₁)\n\n------------------------------------------------------------------------\n-- Alternative inductive/coinductive definition of \"true infinitely\n-- often\"\n\nmodule Alternative where\n\n open Mixed using (now; skip)\n\n -- Always P means that P holds for every natural number.\n\n data Always (P : ℕ → Set) : Set where\n now : (p : P 0) (next : ∞ (Always (P ∘ suc))) → Always P\n\n -- Eventually P means that P holds for some natural number.\n\n data Eventually (P : ℕ → Set) : Set where\n now : (p : P 0) → Eventually P\n later : (p : Eventually (P ∘ suc)) → Eventually P\n\n -- Inf P means that P is true for infinitely many natural numbers.\n\n Inf : (ℕ → Set) → Set\n Inf P = Always (λ n → Eventually (P ∘ _+_ n))\n\n -- This definition is equivalent to the previous one.\n\n up : ∀ P → Inf P → Inf (P ∘ suc)\n up _ (now _ inf) = ♭ inf\n\n equivalent : ∀ {P} → Inf P ⇔ Mixed.Inf P\n equivalent = equivalence ⇒ ⇐\n where\n ⇒ : ∀ {P} → Inf P → Mixed.Inf P\n ⇒ (now p inf) = ⇒′ p (♭ inf)\n where\n ⇒′ : ∀ {P} → Eventually P → Inf (P ∘ suc) → Mixed.Inf P\n ⇒′ (now p) inf = now p (♯ ⇒ inf)\n ⇒′ {P} (later p) inf = skip (⇒′ p (up (P ∘ suc) inf))\n\n ⇐ : ∀ {P} → Mixed.Inf P → Inf P\n ⇐ inf = now (eventually inf) (♯ ⇐ (Mixed.up inf))\n where\n eventually : ∀ {P} → Mixed.Inf P → Eventually P\n eventually (now p _) = now p\n eventually (skip inf) = later (eventually inf)\n\n------------------------------------------------------------------------\n-- Functional/inductive definition of \"true infinitely often\"\n\nmodule Functional where\n\n open Mixed using (now; skip)\n open Above using (_Above_)\n\n -- Inf P means that P is true for infinitely many natural numbers.\n\n Inf : (ℕ → Set) → Set\n Inf P = ∀ i → P Above i\n\n -- This definition is equivalent to the ones above.\n\n up : ∀ {P} → Inf P → Inf (P ∘ suc)\n up ∀iP⇑i i = Equivalence.to Above.move-suc ⟨$⟩ ∀iP⇑i (suc i)\n\n equivalent : ∀ {P} → Inf P ⇔ Mixed.Inf P\n equivalent = equivalence ⇒ ⇐\n where\n ⇒ : ∀ {P} → Inf P → Mixed.Inf P\n ⇒ {P} inf with inf 0\n ... | (j , _ , p) = helper inf j p\n where\n helper : ∀ {P} → Inf P → ∀ j → P j → Mixed.Inf P\n helper inf zero p = now p (♯ ⇒ (up inf))\n helper inf (suc n) p = skip (helper (up inf) n p)\n\n ⇐ : ∀ {P} → Mixed.Inf P → Inf P\n ⇐ (now p inf) zero = (0 , z≤n , p)\n ⇐ (skip inf) zero = Prod.map suc (Prod.map (const z≤n) id) $ ⇐ inf zero\n ⇐ inf (suc i) = Prod.map suc (Prod.map s≤s id) $\n ⇐ (Mixed.up inf) i\n\n -- Inf is a functor (at least if morphism equality is trivial).\n\n map : ∀ {P₁ P₂} → P₁ ⊆ P₂ → Inf P₁ → Inf P₂\n map P₁⊆P₂ inf = λ i → Prod.map id (Prod.map id P₁⊆P₂) (inf i)\n\n------------------------------------------------------------------------\n-- Definition of \"only true finitely often\"\n\nmodule Fin where\n\n open Mixed using (now; skip)\n open Has-upper-bound using (_Has-upper-bound_)\n\n -- Fin P means that P is only true for finitely many natural\n -- numbers.\n\n Fin : (ℕ → Set) → Set\n Fin P = ∃ λ i → P Has-upper-bound i\n\n -- Fin implies the negation of Mixed.Inf.\n\n ⇐ : ∀ {P} → Fin P → ¬ Mixed.Inf P\n ⇐ = uncurry ⇐′\n where\n ⇐′ : ∀ {P} i → P Has-upper-bound i → ¬ Mixed.Inf P\n ⇐′ zero fin (now p inf) = fin 0 z≤n p\n ⇐′ zero fin (skip inf) = ⇐′ zero (λ j i≤j → fin (suc j) z≤n) inf\n ⇐′ (suc i) fin inf =\n ⇐′ i (Equivalence.to Has-upper-bound.move-suc ⟨$⟩ fin)\n (Mixed.up inf)\n\n -- The other direction (with a double-negated conclusion) implies\n -- that Mixed.Inf commutes with binary sums (in the double-negation\n -- monad).\n\n filter : ∀ {P Q} → Mixed.Inf (P ∪ Q) → Fin P → Mixed.Inf Q\n filter inf (i , fin) = filter′ inf i fin\n where\n filter′ : ∀ {P Q} →\n Mixed.Inf (P ∪ Q) →\n ∀ i → P Has-upper-bound i → Mixed.Inf Q\n filter′ (now (inj₁ p) inf) 0 fin = ⊥-elim (fin 0 z≤n p)\n filter′ (now (inj₁ p) inf) (suc i) fin = skip (filter′ (♭ inf) i (Equivalence.to Has-upper-bound.move-suc ⟨$⟩ fin))\n filter′ (now (inj₂ q) inf) i fin = now q (♯ filter′ (♭ inf) i (Has-upper-bound.up fin))\n filter′ (skip inf) i fin = skip (filter′ inf i (Has-upper-bound.up fin))\n\n commutes : ∀ {P Q} → (¬ Mixed.Inf P → ¬ ¬ Fin P) →\n Mixed.Inf (P ∪ Q) → ¬ ¬ (Mixed.Inf P ⊎ Mixed.Inf Q)\n commutes ⇒ p∪q =\n call/cc λ ¬[p⊎q] →\n ⇒ (¬[p⊎q] ∘ inj₁) >>= λ fin →\n return $ inj₂ (filter p∪q fin)\n\n -- Fin is preserved by binary sums.\n\n ∪-preserves : ∀ {P Q} → Fin P → Fin Q → Fin (P ∪ Q)\n ∪-preserves {P} {Q} (i , ¬p) (j , ¬q) = (i ⊔ j , helper)\n where\n open NatProp.≤-Reasoning\n\n helper : ∀ k → i ⊔ j ≤ k → ¬ (P ∪ Q) k\n helper k i⊔j≤k (inj₁ p) = ¬p k (begin\n i ≤⟨ NatProp.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 ≤⟨ NatProp.m≤m⊔n j i ⟩\n j ⊔ i ≡⟨ NatLattice.∧-comm j i ⟩\n i ⊔ j ≤⟨ i⊔j≤k ⟩\n k ∎) q\n\n------------------------------------------------------------------------\n-- Double-negation shift lemmas\n\nmodule Double-negation-shift where\n\n open Below using (_Below_)\n\n -- General double-negation shift property.\n\n DNS : (ℕ → Set) → Set\n DNS P = (∀ i → ¬ ¬ P i) → ¬ ¬ (∀ i → P i)\n\n -- DNS holds for stable predicates.\n\n Stable⇒DNS : ∀ {P} → (∀ i → Stable (P i)) → DNS P\n Stable⇒DNS stable ∀¬¬P = λ ¬∀P → ¬∀P (λ i → stable i (∀¬¬P i))\n\n -- DNS follows from excluded middle.\n\n EM⇒DNS : ∀ {P} → ExcludedMiddle Level.zero → DNS P\n EM⇒DNS {P} em hyp = return hyp′\n where\n hyp′ : ∀ i → P i\n hyp′ i = decidable-stable em (hyp i)\n\n -- DNS follows from the double-negation of excluded middle.\n\n ¬¬EM⇒DNS : ∀ {P} → ¬ ¬ ExcludedMiddle Level.zero → DNS P\n ¬¬EM⇒DNS em hyp =\n ¬¬-map lower (em >>= λ em → ¬¬-map lift (EM⇒DNS em hyp))\n\n -- DNS respects predicate equivalence.\n\n respects : ∀ {P₁ P₂} → (∀ i → P₁ i ⇔ P₂ i) → DNS P₁ → DNS P₂\n respects P₁⇔P₂ dns ∀i¬¬P₂i ¬∀iP₂i =\n dns (λ i ¬P₁i → ∀i¬¬P₂i i (λ P₂i →\n ¬P₁i (Equivalence.from (P₁⇔P₂ i) ⟨$⟩ P₂i)))\n (λ ∀iP₁i → ¬∀iP₂i (λ i → Equivalence.to (P₁⇔P₂ i) ⟨$⟩ ∀iP₁i i))\n\n -- Double-negation shift property restricted to predicates which are\n -- downwards closed.\n\n DNS⇓ : (ℕ → Set) → Set\n DNS⇓ P =\n (∀ {i j} → i ≥ j → P i → P j) →\n (∀ i → ¬ ¬ P i) → ¬ ¬ (∀ i → P i)\n\n -- Certain instances of DNS imply other instances of DNS⇓, and vice\n -- versa.\n\n DNS⇒DNS⇓ : ∀ {P} → DNS (_Below_ P) → DNS⇓ P\n DNS⇒DNS⇓ {P} shift downwards-closed ∀i¬¬Pi =\n _∘_ Below.counit <$> shift (λ i → unit <$> ∀i¬¬Pi i)\n where\n unit : P ⊆ _Below_ P\n unit Pi j j≤i = downwards-closed j≤i Pi\n\n -- The following lemma is due to Thierry Coquand (but the proof,\n -- including any inelegance, is due to me).\n\n DNS⇓⇒DNS : ∀ {P} → DNS⇓ (_Below_ P) → DNS P\n DNS⇓⇒DNS {P} shift ∀¬¬P = _∘_ Below.counit <$> ¬¬∀P⇓\n where\n P⇓-downwards-closed : ∀ {i j} → i ≥ j → P Below i → P Below j\n P⇓-downwards-closed i≥j P⇓i = λ j′ j′≤j →\n P⇓i j′ (NatOrder.trans j′≤j i≥j)\n\n Q : ℕ → Set\n Q i = ∀ {j} → j ≤′ i → P j\n\n q-zero : P 0 → Q 0\n q-zero P0 ≤′-refl = P0\n\n q-suc : ∀ {i} → P (suc i) → Q i → Q (suc i)\n q-suc P1+i Qi ≤′-refl = P1+i\n q-suc P1+i Qi (≤′-step j≤i) = Qi j≤i\n\n ∀¬¬Q : ∀ i → ¬ ¬ Q i\n ∀¬¬Q zero = q-zero <$> ∀¬¬P zero\n ∀¬¬Q (suc i) = q-suc <$> ∀¬¬P (suc i) ⊛ ∀¬¬Q i\n\n ∀¬¬P⇓ : ∀ i → ¬ ¬ (P Below i)\n ∀¬¬P⇓ i = (λ Qi j j≤i → Qi (NatProp.≤⇒≤′ j≤i)) <$> ∀¬¬Q i\n\n ¬¬∀P⇓ : ¬ ¬ (∀ i → P Below i)\n ¬¬∀P⇓ = shift P⇓-downwards-closed ∀¬¬P⇓\n\n------------------------------------------------------------------------\n-- \"Non-constructive\" definition of \"true infinitely often\"\n\nmodule NonConstructive where\n\n open Fin using (Fin)\n open Above using (_Above_)\n open Below using (_Below_)\n open Has-upper-bound using (_Has-upper-bound_)\n open Double-negation-shift using (DNS; DNS⇓)\n\n -- Inf P means that P is true for infinitely many natural numbers.\n\n Inf : (ℕ → Set) → Set\n Inf P = ¬ Fin P\n\n -- Inf commutes with binary sums (in the double-negation monad).\n\n commutes : ∀ {P Q} → Inf (P ∪ Q) → ¬ ¬ (Inf P ⊎ Inf Q)\n commutes p∪q =\n call/cc λ ¬[p⊎q] →\n (λ ¬p ¬q → ⊥-elim (p∪q $ Fin.∪-preserves ¬p ¬q))\n <$> ¬[p⊎q] ∘ inj₁ ⊛ ¬[p⊎q] ∘ inj₂\n\n -- Inf is a functor (at least if morphism equality is trivial).\n\n map : ∀ {P₁ P₂} → P₁ ⊆ P₂ → Inf P₁ → Inf P₂\n map P₁⊆P₂ ¬fin = λ fin →\n ¬fin (Prod.map id (λ never j i≤j P₁j → never j i≤j (P₁⊆P₂ P₁j)) fin)\n\n -- If we have a constructive proof of \"true infinitely often\", then\n -- we get a \"non-constructive\" proof as well.\n\n ⇒ : ∀ {P} → Functional.Inf P → Inf P\n ⇒ inf (i , fin) with inf i\n ... | (j , i≤j , p) = fin j i≤j p\n\n -- The other direction can be proved iff we have a double-negation\n -- shift lemma.\n\n Other-direction : (ℕ → Set) → Set\n Other-direction P = Inf P → ¬ ¬ Functional.Inf P\n\n equivalent₁ : ∀ {P} → Other-direction P ⇔ DNS (_Above_ P)\n equivalent₁ = equivalence ⇒shift shift⇒\n where\n shift⇒ : ∀ {P} → DNS (_Above_ P) → Other-direction P\n shift⇒ shift ¬fin =\n shift (λ i ¬p →\n ¬fin (i , Equivalence.from\n Has-upper-bound.mutually-inconsistent ⟨$⟩ ¬p))\n\n ⇒shift : ∀ {P} → Other-direction P → DNS (_Above_ P)\n ⇒shift hyp p =\n hyp (uncurry (λ i fin →\n p i (Equivalence.to\n Has-upper-bound.mutually-inconsistent ⟨$⟩ fin)))\n\n equivalent₂ : ∀ {P} → Other-direction (_Below_ P) ⇔ DNS P\n equivalent₂ {P} = equivalence ⇒shift shift⇒\n where\n shift⇒ : DNS P → Other-direction (_Below_ P)\n shift⇒ shift inf ¬inf =\n shift (λ i ¬Pi →\n inf (i , λ j i≤j ∀k≤j[Pk] → ¬Pi (∀k≤j[Pk] i i≤j)))\n (λ ∀iPi → ¬inf (λ i → i , NatOrder.refl , λ j j≤i → ∀iPi j))\n\n ⇒shift : ∀ {P} → Other-direction (_Below_ P) → DNS P\n ⇒shift {P} =\n Other-direction (_Below_ P) ∼⟨ (λ other₁ →\n Inf (_Below_ (_Below_ P)) ∼⟨ map Below.counit ⟩\n Inf (_Below_ P) ∼⟨ other₁ ⟩\n ¬ ¬ Functional.Inf (_Below_ P) ∼⟨ _<$>_ (Functional.map Below.cojoin) ⟩\n (¬ ¬ Functional.Inf (_Below_ (_Below_ P))) ∎) ⟩\n Other-direction (_Below_ (_Below_ P)) ∼⟨ _⟨$⟩_ (Equivalence.to equivalent₁) ⟩\n DNS (_Above_ (_Below_ (_Below_ P))) ∼⟨ Double-negation-shift.respects Below.⇑⇓⇔⇓ ⟩\n DNS (_Below_ (_Below_ P)) ∼⟨ Double-negation-shift.DNS⇒DNS⇓ ⟩\n DNS⇓ (_Below_ P) ∼⟨ Double-negation-shift.DNS⇓⇒DNS ⟩\n DNS P ∎\n where open Related.EquationalReasoning\n\n equivalent : (∀ P → Other-direction P) ⇔ (∀ P → DNS P)\n equivalent =\n equivalence (λ other P → _⟨$⟩_ (Equivalence.to equivalent₂)\n (other (_Below_ P)))\n (λ shift P → _⟨$⟩_ (Equivalence.from equivalent₁)\n (shift (_Above_ P)))\n\n -- Some lemmas used below.\n\n up : ∀ {P} → Inf P → Inf (P ∘ suc)\n up =\n contraposition\n (Prod.map suc (_⟨$⟩_ (Equivalence.from Has-upper-bound.move-suc)))\n\n witness : ∀ {P} → Inf P → ¬ ¬ ∃ P\n witness ¬fin ¬p = ¬fin (0 , λ i _ Pi → ¬p (i , Pi))\n\n------------------------------------------------------------------------\n-- Definition of \"true infinitely often\" which uses double-negation\n\nmodule DoubleNegated where\n\n open Fin using (Fin)\n open Has-upper-bound using (_Has-upper-bound_)\n\n infixl 4 _⟪$⟫_\n\n mutual\n\n -- Inf P means that P is true for infinitely many natural numbers.\n\n data Inf (P : ℕ → Set) : Set₁ where\n now : (p : P 0) (inf : ∞ (¬¬Inf (P ∘ suc))) → Inf P\n skip : (inf : Inf (P ∘ suc) ) → Inf P\n\n data ¬¬Inf (P : ℕ → Set) : Set₁ where\n _⟪$⟫_ : {A : Set} (f : A → Inf P) (m : ¬ ¬ A) → ¬¬Inf P\n\n -- ¬¬Inf is equivalent to the non-constructive definition given\n -- above.\n\n expand : ∀ {P} → ¬¬Inf P → ¬ ¬ Inf P\n expand (f ⟪$⟫ m) = λ ¬inf → m (¬inf ∘ f)\n\n ¬¬equivalent : ∀ {P} → NonConstructive.Inf P ⇔ ¬¬Inf P\n ¬¬equivalent = equivalence ⇒ ⇐\n where\n ⇒ : ∀ {P} → NonConstructive.Inf P → ¬¬Inf P\n ⇒ ¬fin = helper ¬fin ⟪$⟫ NonConstructive.witness ¬fin\n where\n helper : ∀ {P} → NonConstructive.Inf P → ∃ P → Inf P\n helper ¬fin (zero , p) = now p (♯ ⇒ (NonConstructive.up ¬fin))\n helper ¬fin (suc i , p) =\n skip (helper (NonConstructive.up ¬fin) (i , p))\n\n ⇐ : ∀ {P} → ¬¬Inf P → NonConstructive.Inf P\n ⇐ ¬¬inf (i , fin) = ⇐′ ¬¬inf i fin\n where\n mutual\n ⇐′ : ∀ {P} → ¬¬Inf P → ∀ i → ¬ P Has-upper-bound i\n ⇐′ ¬¬inf i fin = ¬¬-map (helper i fin) (expand ¬¬inf) id\n\n helper : ∀ {P} → ∀ i → P Has-upper-bound i → ¬ Inf P\n helper i ¬p (skip inf) = helper i (Has-upper-bound.up ¬p) inf\n helper zero ¬p (now p inf) = ¬p 0 z≤n p\n helper (suc i) ¬p (now p ¬¬inf) =\n ⇐′ (♭ ¬¬inf) i (λ j i≤j → ¬p (suc j) (s≤s i≤j))\n\n -- Inf is equivalent to the non-constructive definition given above\n -- (in the double-negation monad).\n\n ⇐ : ∀ {P} → Inf P → NonConstructive.Inf P\n ⇐ {P} =\n Inf P ∼⟨ (λ inf → const inf ⟪$⟫ return tt) ⟩\n ¬¬Inf P ∼⟨ _⟨$⟩_ (Equivalence.from ¬¬equivalent) ⟩\n NonConstructive.Inf P ∎\n where open Related.EquationalReasoning\n\n ⇒ : ∀ {P} → NonConstructive.Inf P → ¬ ¬ Inf P\n ⇒ {P} =\n NonConstructive.Inf P ∼⟨ _⟨$⟩_ (Equivalence.to ¬¬equivalent) ⟩\n ¬¬Inf P ∼⟨ expand ⟩\n (¬ ¬ Inf P) ∎\n where open Related.EquationalReasoning\n\n equivalent : ∀ {P} → ¬ ¬ (NonConstructive.Inf P ⇔ Inf P)\n equivalent {P} =\n (λ ⇒′ → equivalence (⇒′ ∘ lift) ⇐) <$>\n Univ.¬¬-pull (Univ._⇒_ _ Univ.Id) (λ inf → ⇒ (lower inf))\n\n -- Inf commutes with binary sums (in the double-negation monad).\n\n commutes : ∀ {P Q} → Inf (P ∪ Q) → ¬ ¬ (Inf P ⊎ Inf Q)\n commutes {P} {Q} p∪q =\n negated-stable $ ¬¬-map helper $ NonConstructive.commutes (⇐ p∪q)\n where\n helper : NonConstructive.Inf P ⊎ NonConstructive.Inf Q →\n ¬ ¬ (Inf P ⊎ Inf Q)\n helper (inj₁ p) = λ ¬p∪q → ⇒ p (¬p∪q ∘ inj₁)\n helper (inj₂ q) = λ ¬p∪q → ⇒ q (¬p∪q ∘ inj₂)\n\n-- You may wonder why double-negation is introduced in a roundabout\n-- way in ¬¬Inf above. The reason is that the more direct definition,\n-- used in DoubleNegated₂ below, is not strictly positive. Furthermore\n-- DoubleNegated₂.equivalent is not accepted by the termination\n-- checker.\n\n{-\nmodule DoubleNegated₂ where\n\n open DoubleNegated using (now; skip; _⟪$⟫_)\n\n data Inf (P : ℕ → Set) : Set where\n now : (p : P 0) (inf : ∞ (¬ ¬ Inf (P ∘ suc))) → Inf P\n skip : (inf : Inf (P ∘ suc) ) → Inf P\n\n equivalent : ∀ {P} → DoubleNegated.Inf P ⇔ Inf P\n equivalent = equivalence ⇒ ⇐\n where\n ⇐ : ∀ {P} → Inf P → DoubleNegated.Inf P\n ⇐ (now p inf) = now p (♯ (⇐ ⟪$⟫ ♭ inf))\n ⇐ (skip inf) = skip (⇐ inf)\n\n ⇒ : ∀ {P} → DoubleNegated.Inf P → Inf P\n ⇒ (now p inf) with ♭ inf\n ... | f ⟪$⟫ m = now p (♯ λ ¬inf → m (λ x → ¬inf (⇒ (f x))))\n ⇒ (skip inf) = skip (⇒ inf)\n-}\n", "meta": {"hexsha": "36c9979dd2ee40cdf2a75bd554cf439fb515eb4b", "size": 21428, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "InfinitelyOften.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": "InfinitelyOften.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": "InfinitelyOften.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": 33.1190108192, "max_line_length": 119, "alphanum_fraction": 0.5207205525, "num_tokens": 7827, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085859124003, "lm_q2_score": 0.7401743735019595, "lm_q1q2_score": 0.5812652905834206}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some Vec-related properties\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Vec.Properties where\n\nopen import Algebra.FunctionProperties\nopen import Data.Empty using (⊥-elim)\nopen import Data.Fin as Fin using (Fin; zero; suc; toℕ; fromℕ)\nopen import Data.Fin.Properties using (_+′_)\nopen import Data.List.Base as List using (List)\nopen import Data.Nat\nopen import Data.Nat.Properties using (+-assoc; ≤-step)\nopen import Data.Product as Prod\n using (_×_; _,_; proj₁; proj₂; <_,_>; uncurry)\nopen import Data.Vec\nopen import Function\nopen import Function.Inverse using (_↔_; inverse)\nopen import Relation.Binary as B hiding (Decidable)\nopen import Relation.Binary.PropositionalEquality as P\n using (_≡_; _≢_; refl; _≗_)\nopen import Relation.Unary using (Pred; Decidable)\nopen import Relation.Nullary using (yes; no)\n\n------------------------------------------------------------------------\n-- Properties of propositional equality over vectors\n\nmodule _ {a} {A : Set a} {n} {x y : A} {xs ys : Vec A n} where\n\n ∷-injectiveˡ : x ∷ xs ≡ y ∷ ys → x ≡ y\n ∷-injectiveˡ refl = refl\n\n ∷-injectiveʳ : x ∷ xs ≡ y ∷ ys → xs ≡ ys\n ∷-injectiveʳ refl = refl\n\n ∷-injective : (x ∷ xs) ≡ (y ∷ ys) → x ≡ y × xs ≡ ys\n ∷-injective refl = refl , refl\n\nmodule _ {a} {A : Set a} where\n\n ≡-dec : B.Decidable _≡_ → ∀ {n} → B.Decidable {A = Vec A n} _≡_\n ≡-dec _≟_ [] [] = yes refl\n ≡-dec _≟_ (x ∷ xs) (y ∷ ys) with x ≟ y | ≡-dec _≟_ xs ys\n ... | yes refl | yes refl = yes refl\n ... | no x≢y | _ = no (x≢y ∘ ∷-injectiveˡ)\n ... | yes _ | no xs≢ys = no (xs≢ys ∘ ∷-injectiveʳ)\n\n------------------------------------------------------------------------\n-- _[_]=_\n\nmodule _ {a} {A : Set a} where\n\n []=-injective : ∀ {n} {xs : Vec A n} {i x y} →\n xs [ i ]= x → xs [ i ]= y → x ≡ y\n []=-injective here here = refl\n []=-injective (there xsᵢ≡x) (there xsᵢ≡y) = []=-injective xsᵢ≡x xsᵢ≡y\n\n -- See also Data.Vec.Properties.WithK.[]=-irrelevant.\n\n------------------------------------------------------------------------\n-- lookup\n\nmodule _ {a} {A : Set a} where\n\n []=⇒lookup : ∀ {n} {x : A} {xs} {i : Fin n} →\n xs [ i ]= x → lookup xs i ≡ x\n []=⇒lookup here = refl\n []=⇒lookup (there xs[i]=x) = []=⇒lookup xs[i]=x\n\n lookup⇒[]= : ∀ {n} (i : Fin n) {x : A} xs →\n lookup xs i ≡ x → xs [ i ]= x\n lookup⇒[]= zero (_ ∷ _) refl = here\n lookup⇒[]= (suc i) (_ ∷ xs) p = there (lookup⇒[]= i xs p)\n\n []=↔lookup : ∀ {n i} {x} {xs : Vec A n} →\n xs [ i ]= x ↔ lookup xs i ≡ x\n []=↔lookup {i = i} =\n inverse []=⇒lookup (lookup⇒[]= _ _)\n lookup⇒[]=∘[]=⇒lookup ([]=⇒lookup∘lookup⇒[]= _ i)\n where\n lookup⇒[]=∘[]=⇒lookup :\n ∀ {n x xs} {i : Fin n} (p : xs [ i ]= x) →\n lookup⇒[]= i xs ([]=⇒lookup p) ≡ p\n lookup⇒[]=∘[]=⇒lookup here = refl\n lookup⇒[]=∘[]=⇒lookup (there p) =\n P.cong there (lookup⇒[]=∘[]=⇒lookup p)\n\n []=⇒lookup∘lookup⇒[]= :\n ∀ {n} xs (i : Fin n) {x} (p : lookup xs i ≡ x) →\n []=⇒lookup (lookup⇒[]= i xs p) ≡ p\n []=⇒lookup∘lookup⇒[]= (x ∷ xs) zero refl = refl\n []=⇒lookup∘lookup⇒[]= (x ∷ xs) (suc i) p =\n []=⇒lookup∘lookup⇒[]= xs i p\n\n------------------------------------------------------------------------\n-- updateAt (_[_]%=_)\n\nmodule _ {a} {A : Set a} where\n\n -- (+) updateAt i actually updates the element at index i.\n\n updateAt-updates : ∀ {n} (i : Fin n) {f : A → A} (xs : Vec A n) {x : A} →\n xs [ i ]= x → (updateAt i f xs) [ i ]= f x\n updateAt-updates zero (x ∷ xs) here = here\n updateAt-updates (suc i) (x ∷ xs) (there loc) = there (updateAt-updates i xs loc)\n\n -- (-) updateAt i does not touch the elements at other indices.\n\n updateAt-minimal : ∀ {n} (i j : Fin n) {f : A → A} {x : A} (xs : Vec A n) →\n i ≢ j → xs [ i ]= x → (updateAt j f xs) [ i ]= x\n updateAt-minimal zero zero (x ∷ xs) 0≢0 here = ⊥-elim (0≢0 refl)\n updateAt-minimal zero (suc j) (x ∷ xs) _ here = here\n updateAt-minimal (suc i) zero (x ∷ xs) _ (there loc) = there loc\n updateAt-minimal (suc i) (suc j) (x ∷ xs) i≢j (there loc) =\n there (updateAt-minimal i j xs (i≢j ∘ P.cong suc) loc)\n\n -- The other properties are consequences of (+) and (-).\n -- We spell the most natural properties out.\n -- Direct inductive proofs are in most cases easier than just using\n -- the defining properties.\n\n -- In the explanations, we make use of shorthand f = g ↾ x\n -- meaning that f and g agree at point x, i.e. f x ≡ g x.\n\n -- updateAt i is a morphism from the monoid of endofunctions A → A\n -- to the monoid of endofunctions Vec A n → Vec A n\n\n -- 1a. relative identity: f = id ↾ (lookup xs i)\n -- implies updateAt i f = id ↾ xs\n\n updateAt-id-relative : ∀ {n} (i : Fin n) (xs : Vec A n) {f : A → A} →\n f (lookup xs i) ≡ lookup xs i →\n updateAt i f xs ≡ xs\n updateAt-id-relative zero (x ∷ xs) eq = P.cong (_∷ xs) eq\n updateAt-id-relative (suc i) (x ∷ xs) eq = P.cong (x ∷_) (updateAt-id-relative i xs eq)\n\n -- 1b. identity: updateAt i id ≗ id\n\n updateAt-id : ∀ {n} (i : Fin n) (xs : Vec A n) →\n updateAt i id xs ≡ xs\n updateAt-id i xs = updateAt-id-relative i xs refl\n\n -- 2a. relative composition: f ∘ g = h ↾ (lookup i xs)\n -- implies updateAt i f ∘ updateAt i g ≗ updateAt i h\n\n updateAt-compose-relative : ∀ {n} (i : Fin n) {f g h : A → A} (xs : Vec A n) →\n f (g (lookup xs i)) ≡ h (lookup xs i) →\n updateAt i f (updateAt i g xs) ≡ updateAt i h xs\n updateAt-compose-relative zero (x ∷ xs) fg=h = P.cong (_∷ xs) fg=h\n updateAt-compose-relative (suc i) (x ∷ xs) fg=h =\n P.cong (x ∷_) (updateAt-compose-relative i xs fg=h)\n\n -- 2b. composition: updateAt i f ∘ updateAt i g ≗ updateAt i (f ∘ g)\n\n updateAt-compose : ∀ {n} (i : Fin n) {f g : A → A} →\n updateAt i f ∘ updateAt i g ≗ updateAt i (f ∘ g)\n updateAt-compose i xs = updateAt-compose-relative i xs refl\n\n -- 3. congruence: updateAt i is a congruence wrt. extensional equality.\n\n -- 3a. If f = g ↾ (lookup i xs)\n -- then updateAt i f = updateAt i g ↾ xs\n\n updateAt-cong-relative : ∀ {n} (i : Fin n) {f g : A → A} (xs : Vec A n) →\n f (lookup xs i) ≡ g (lookup xs i) →\n updateAt i f xs ≡ updateAt i g xs\n updateAt-cong-relative zero (x ∷ xs) f=g = P.cong (_∷ xs) f=g\n updateAt-cong-relative (suc i) (x ∷ xs) f=g = P.cong (x ∷_) (updateAt-cong-relative i xs f=g)\n\n -- 3b. congruence: f ≗ g → updateAt i f ≗ updateAt i g\n\n updateAt-cong : ∀ {n} (i : Fin n) {f g : A → A} →\n f ≗ g → updateAt i f ≗ updateAt i g\n updateAt-cong i f≗g xs = updateAt-cong-relative i xs (f≗g (lookup xs i))\n\n -- The order of updates at different indices i ≢ j does not matter.\n\n -- This a consequence of updateAt-updates and updateAt-minimal\n -- but easier to prove inductively.\n\n updateAt-commutes : ∀ {n} (i j : Fin n) {f g : A → A} → i ≢ j →\n updateAt i f ∘ updateAt j g ≗ updateAt j g ∘ updateAt i f\n updateAt-commutes zero zero 0≢0 (x ∷ xs) = ⊥-elim (0≢0 refl)\n updateAt-commutes zero (suc j) i≢j (x ∷ xs) = refl\n updateAt-commutes (suc i) zero i≢j (x ∷ xs) = refl\n updateAt-commutes (suc i) (suc j) i≢j (x ∷ xs) =\n P.cong (x ∷_) (updateAt-commutes i j (i≢j ∘ P.cong suc) xs)\n\n -- lookup after updateAt reduces.\n\n -- For same index this is an easy consequence of updateAt-updates\n -- using []=↔lookup.\n\n lookup∘updateAt : ∀ {n} (i : Fin n) {f : A → A} →\n ∀ xs → lookup (updateAt i f xs) i ≡ f (lookup xs i)\n lookup∘updateAt i xs =\n []=⇒lookup (updateAt-updates i xs (lookup⇒[]= i _ refl))\n\n -- For different indices it easily follows from updateAt-minimal.\n\n lookup∘updateAt′ : ∀ {n} (i j : Fin n) {f : A → A} → i ≢ j →\n ∀ xs → lookup (updateAt j f xs) i ≡ lookup xs i\n lookup∘updateAt′ i j xs i≢j =\n []=⇒lookup (updateAt-minimal i j i≢j xs (lookup⇒[]= i _ refl))\n\n -- Aliases for notation _[_]%=_\n\n []%=-id : ∀ {n} (xs : Vec A n) (i : Fin n) → xs [ i ]%= id ≡ xs\n []%=-id xs i = updateAt-id i xs\n\n []%=-compose : ∀ {n} (xs : Vec A n) (i : Fin n) {f g : A → A} →\n xs [ i ]%= f\n [ i ]%= g\n ≡ xs [ i ]%= g ∘ f\n []%=-compose xs i = updateAt-compose i xs\n\n------------------------------------------------------------------------\n-- _[_]≔_ (update)\n--\n-- _[_]≔_ is defined in terms of updateAt, and all of its properties\n-- are special cases of the ones for updateAt.\n\nmodule _ {a} {A : Set a} where\n\n []≔-idempotent : ∀ {n} (xs : Vec A n) (i : Fin n) {x₁ x₂ : A} →\n (xs [ i ]≔ x₁) [ i ]≔ x₂ ≡ xs [ i ]≔ x₂\n []≔-idempotent xs i = updateAt-compose i xs\n\n []≔-commutes : ∀ {n} (xs : Vec A n) (i j : Fin n) {x y : A} → i ≢ j →\n (xs [ i ]≔ x) [ j ]≔ y ≡ (xs [ j ]≔ y) [ i ]≔ x\n []≔-commutes xs i j i≢j = updateAt-commutes j i (i≢j ∘ P.sym) xs\n\n []≔-updates : ∀ {n} (xs : Vec A n) (i : Fin n) {x : A} →\n (xs [ i ]≔ x) [ i ]= x\n []≔-updates xs i = updateAt-updates i xs (lookup⇒[]= i xs refl)\n\n []≔-minimal : ∀ {n} (xs : Vec A n) (i j : Fin n) {x y : A} → i ≢ j →\n xs [ i ]= x → (xs [ j ]≔ y) [ i ]= x\n []≔-minimal xs i j i≢j loc = updateAt-minimal i j xs i≢j loc\n\n []≔-lookup : ∀ {n} (xs : Vec A n) (i : Fin n) →\n xs [ i ]≔ lookup xs i ≡ xs\n []≔-lookup xs i = updateAt-id-relative i xs refl\n\n lookup∘update : ∀ {n} (i : Fin n) (xs : Vec A n) x →\n lookup (xs [ i ]≔ x) i ≡ x\n lookup∘update i xs x = lookup∘updateAt i xs\n\n lookup∘update′ : ∀ {n} {i j : Fin n} → i ≢ j → ∀ (xs : Vec A n) y →\n lookup (xs [ j ]≔ y) i ≡ lookup xs i\n lookup∘update′ {n} {i} {j} i≢j xs y = lookup∘updateAt′ i j i≢j xs\n\n------------------------------------------------------------------------\n-- map\n\nmap-id : ∀ {a n} {A : Set a} → map {n = n} {A} id ≗ id\nmap-id [] = refl\nmap-id (x ∷ xs) = P.cong (x ∷_) (map-id xs)\n\nmap-cong : ∀ {a b n} {A : Set a} {B : Set b} {f g : A → B} →\n f ≗ g → map {n = n} f ≗ map g\nmap-cong f≗g [] = refl\nmap-cong f≗g (x ∷ xs) = P.cong₂ _∷_ (f≗g x) (map-cong f≗g xs)\n\nmap-∘ : ∀ {a b c n} {A : Set a} {B : Set b} {C : Set c}\n (f : B → C) (g : A → B) →\n map {n = n} (f ∘ g) ≗ map f ∘ map g\nmap-∘ f g [] = refl\nmap-∘ f g (x ∷ xs) = P.cong (f (g x) ∷_) (map-∘ f g xs)\n\nlookup-map : ∀ {a b n} {A : Set a} {B : Set b}\n (i : Fin n) (f : A → B) (xs : Vec A n) →\n lookup (map f xs) i ≡ f (lookup xs i)\nlookup-map zero f (x ∷ xs) = refl\nlookup-map (suc i) f (x ∷ xs) = lookup-map i f xs\n\nmap-updateAt : ∀ {n a b} {A : Set a} {B : Set b} →\n ∀ {f : A → B} {g : A → A} {h : B → B} (xs : Vec A n) (i : Fin n)\n → f (g (lookup xs i)) ≡ h (f (lookup xs i))\n → map f (updateAt i g xs) ≡ updateAt i h (map f xs)\nmap-updateAt (x ∷ xs) zero eq = P.cong (_∷ _) eq\nmap-updateAt (x ∷ xs) (suc i) eq = P.cong (_ ∷_) (map-updateAt xs i eq)\n\nmap-[]≔ : ∀ {n a b} {A : Set a} {B : Set b}\n (f : A → B) (xs : Vec A n) (i : Fin n) {x : A} →\n map f (xs [ i ]≔ x) ≡ map f xs [ i ]≔ f x\nmap-[]≔ f xs i = map-updateAt xs i refl\n\n------------------------------------------------------------------------\n-- _++_\n\nmodule _ {a} {A : Set a} {m} {ys ys' : Vec A m} where\n\n -- See also Data.Vec.Properties.WithK.++-assoc.\n\n ++-injectiveˡ : ∀ {n} (xs xs' : Vec A n) →\n xs ++ ys ≡ xs' ++ ys' → xs ≡ xs'\n ++-injectiveˡ [] [] _ = refl\n ++-injectiveˡ (x ∷ xs) (x' ∷ xs') eq =\n P.cong₂ _∷_ (∷-injectiveˡ eq) (++-injectiveˡ _ _ (∷-injectiveʳ eq))\n\n ++-injectiveʳ : ∀ {n} (xs xs' : Vec A n) →\n xs ++ ys ≡ xs' ++ ys' → ys ≡ ys'\n ++-injectiveʳ [] [] eq = eq\n ++-injectiveʳ (x ∷ xs) (x' ∷ xs') eq =\n ++-injectiveʳ xs xs' (∷-injectiveʳ eq)\n\n ++-injective : ∀ {n} (xs xs' : Vec A n) →\n xs ++ ys ≡ xs' ++ ys' → xs ≡ xs' × ys ≡ ys'\n ++-injective xs xs' eq =\n (++-injectiveˡ xs xs' eq , ++-injectiveʳ xs xs' eq)\n\nmodule _ {a} {A : Set a} where\n\n lookup-++-< : ∀ {m n} (xs : Vec A m) (ys : Vec A n) →\n ∀ i (i-zip : ∀ {a b c n} {A : Set a} {B : Set b} {C : Set c}\n (f : A → B) (g : A → C) (xs : Vec A n) →\n map < f , g > xs ≡ zip (map f xs) (map g xs)\nmap-<,>-zip f g [] = P.refl\nmap-<,>-zip f g (x ∷ xs) = P.cong (_ ∷_) (map-<,>-zip f g xs)\n\nmap-zip : ∀ {a b c d n} {A : Set a} {B : Set b} {C : Set c} {D : Set d}\n (f : A → B) (g : C → D) (xs : Vec A n) (ys : Vec C n) →\n map (Prod.map f g) (zip xs ys) ≡ zip (map f xs) (map g ys)\nmap-zip f g [] [] = refl\nmap-zip f g (x ∷ xs) (y ∷ ys) = P.cong (_ ∷_) (map-zip f g xs ys)\n\n------------------------------------------------------------------------\n-- unzip\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n lookup-unzip : ∀ {n} (i : Fin n) (xys : Vec (A × B) n) →\n let xs , ys = unzip xys\n in (lookup xs i , lookup ys i) ≡ lookup xys i\n lookup-unzip () []\n lookup-unzip zero ((x , y) ∷ xys) = refl\n lookup-unzip (suc i) ((x , y) ∷ xys) = lookup-unzip i xys\n\n map-unzip : ∀ {c d n} {C : Set c} {D : Set d}\n (f : A → B) (g : C → D) (xys : Vec (A × C) n) →\n let xs , ys = unzip xys\n in (map f xs , map g ys) ≡ unzip (map (Prod.map f g) xys)\n map-unzip f g [] = refl\n map-unzip f g ((x , y) ∷ xys) =\n P.cong (Prod.map (f x ∷_) (g y ∷_)) (map-unzip f g xys)\n\n -- Products of vectors are isomorphic to vectors of products.\n\n unzip∘zip : ∀ {n} (xs : Vec A n) (ys : Vec B n) →\n unzip (zip xs ys) ≡ (xs , ys)\n unzip∘zip [] [] = refl\n unzip∘zip (x ∷ xs) (y ∷ ys) =\n P.cong (Prod.map (x ∷_) (y ∷_)) (unzip∘zip xs ys)\n\n zip∘unzip : ∀ {n} (xys : Vec (A × B) n) →\n uncurry zip (unzip xys) ≡ xys\n zip∘unzip [] = refl\n zip∘unzip ((x , y) ∷ xys) = P.cong ((x , y) ∷_) (zip∘unzip xys)\n\n ×v↔v× : ∀ {n} → (Vec A n × Vec B n) ↔ Vec (A × B) n\n ×v↔v× = inverse (uncurry zip) unzip (uncurry unzip∘zip) zip∘unzip\n\n------------------------------------------------------------------------\n-- _⊛_\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n lookup-⊛ : ∀ {n} i (fs : Vec (A → B) n) (xs : Vec A n) →\n lookup (fs ⊛ xs) i ≡ (lookup fs i $ lookup xs i)\n lookup-⊛ zero (f ∷ fs) (x ∷ xs) = refl\n lookup-⊛ (suc i) (f ∷ fs) (x ∷ xs) = lookup-⊛ i fs xs\n\n map-is-⊛ : ∀ {n} (f : A → B) (xs : Vec A n) →\n map f xs ≡ (replicate f ⊛ xs)\n map-is-⊛ f [] = refl\n map-is-⊛ f (x ∷ xs) = P.cong (_ ∷_) (map-is-⊛ f xs)\n\n ⊛-is-zipWith : ∀ {n} (fs : Vec (A → B) n) (xs : Vec A n) →\n (fs ⊛ xs) ≡ zipWith _$_ fs xs\n ⊛-is-zipWith [] [] = refl\n ⊛-is-zipWith (f ∷ fs) (x ∷ xs) = P.cong (f x ∷_) (⊛-is-zipWith fs xs)\n\n zipWith-is-⊛ : ∀ {c} {C : Set c} {n} (f : A → B → C) →\n (xs : Vec A n) (ys : Vec B n) →\n zipWith f xs ys ≡ (replicate f ⊛ xs ⊛ ys)\n zipWith-is-⊛ f [] [] = refl\n zipWith-is-⊛ f (x ∷ xs) (y ∷ ys) = P.cong (_ ∷_) (zipWith-is-⊛ f xs ys)\n\n------------------------------------------------------------------------\n-- foldr\n\n-- See also Data.Vec.Properties.WithK.foldr-cong.\n\n-- The (uniqueness part of the) universality property for foldr.\n\nfoldr-universal : ∀ {a b} {A : Set a} (B : ℕ → Set b)\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 ≡⟨ P.cong (f x) (foldr-universal B f h base step xs) ⟩\n f x (foldr B f e xs)\n ∎\n where open P.≡-Reasoning\n\nfoldr-fusion : ∀ {a b c} {A : Set a}\n {B : ℕ → Set b} {f : ∀ {n} → A → B n → B (suc n)} e\n {C : ℕ → Set c} {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\nidIsFold : ∀ {a n} {A : Set a} → id ≗ foldr (Vec A) {n} _∷_ []\nidIsFold = foldr-universal _ _ id refl (λ _ _ → refl)\n\n------------------------------------------------------------------------\n-- sum\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) ≡⟨ P.cong (x +_) (sum-++-commute xs) ⟩\n x + (sum xs + sum ys) ≡⟨ P.sym (+-assoc x (sum xs) (sum ys)) ⟩\n sum (x ∷ xs) + sum ys ∎\n where open P.≡-Reasoning\n\n------------------------------------------------------------------------\n-- replicate\n\nlookup-replicate : ∀ {a n} {A : Set a} (i : Fin n) (x : A) →\n lookup (replicate x) i ≡ x\nlookup-replicate zero = λ _ → refl\nlookup-replicate (suc i) = lookup-replicate i\n\nmap-replicate : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) (x : A) →\n ∀ n → map f (replicate x) ≡ replicate {n = n} (f x)\nmap-replicate f x zero = refl\nmap-replicate f x (suc n) = P.cong (f x ∷_) (map-replicate f x n)\n\nmodule _ {a b c} {A : Set a} {B : Set b} {C : Set c} where\n\n zipWith-replicate₁ : ∀ {n} (_⊕_ : A → B → C) (x : A) (ys : Vec B n) →\n zipWith _⊕_ (replicate x) ys ≡ map (x ⊕_) ys\n zipWith-replicate₁ _⊕_ x [] = refl\n zipWith-replicate₁ _⊕_ x (y ∷ ys) =\n P.cong (x ⊕ y ∷_) (zipWith-replicate₁ _⊕_ x ys)\n\n zipWith-replicate₂ : ∀ {n} (_⊕_ : A → B → C) (xs : Vec A n) (y : B) →\n zipWith _⊕_ xs (replicate y) ≡ map (_⊕ y) xs\n zipWith-replicate₂ _⊕_ [] y = refl\n zipWith-replicate₂ _⊕_ (x ∷ xs) y =\n P.cong (x ⊕ y ∷_) (zipWith-replicate₂ _⊕_ xs y)\n\n------------------------------------------------------------------------\n-- tabulate\n\nlookup∘tabulate : ∀ {a n} {A : Set a} (f : Fin n → A) (i : Fin n) →\n lookup (tabulate f) i ≡ f i\nlookup∘tabulate f zero = refl\nlookup∘tabulate f (suc i) = lookup∘tabulate (f ∘ suc) i\n\ntabulate∘lookup : ∀ {a n} {A : Set a} (xs : Vec A n) →\n tabulate (lookup xs) ≡ xs\ntabulate∘lookup [] = refl\ntabulate∘lookup (x ∷ xs) = P.cong (x ∷_) (tabulate∘lookup xs)\n\ntabulate-∘ : ∀ {n a b} {A : Set a} {B : Set b}\n (f : A → B) (g : Fin n → A) →\n tabulate (f ∘ g) ≡ map f (tabulate g)\ntabulate-∘ {zero} f g = refl\ntabulate-∘ {suc n} f g = P.cong (f (g zero) ∷_) (tabulate-∘ f (g ∘ suc))\n\ntabulate-cong : ∀ {n a} {A : Set a} {f g : Fin n → A} → f ≗ g → tabulate f ≡ tabulate g\ntabulate-cong {zero} p = refl\ntabulate-cong {suc n} p = P.cong₂ _∷_ (p zero) (tabulate-cong (p ∘ suc))\n\n------------------------------------------------------------------------\n-- allFin\n\nlookup-allFin : ∀ {n} (i : Fin n) → lookup (allFin n) i ≡ i\nlookup-allFin = lookup∘tabulate id\n\nallFin-map : ∀ n → allFin (suc n) ≡ zero ∷ map suc (allFin n)\nallFin-map n = P.cong (zero ∷_) $ tabulate-∘ suc id\n\ntabulate-allFin : ∀ {n a} {A : Set a} (f : Fin n → A) →\n tabulate f ≡ map f (allFin n)\ntabulate-allFin f = tabulate-∘ f id\n\n-- If you look up every possible index, in increasing order, then you\n-- get back the vector you started with.\n\nmap-lookup-allFin : ∀ {a} {A : Set a} {n} (xs : Vec A n) →\n map (lookup xs) (allFin n) ≡ xs\nmap-lookup-allFin {n = n} xs = begin\n map (lookup xs) (allFin n) ≡˘⟨ tabulate-∘ (lookup xs) id ⟩\n tabulate (lookup xs) ≡⟨ tabulate∘lookup xs ⟩\n xs ∎\n where open P.≡-Reasoning\n\n------------------------------------------------------------------------\n-- count\n\nmodule _ {a p} {A : Set a} {P : Pred A p} (P? : Decidable P) where\n\n count≤n : ∀ {n} (xs : Vec A n) → count P? xs ≤ n\n count≤n [] = z≤n\n count≤n (x ∷ xs) with P? x\n ... | yes _ = s≤s (count≤n xs)\n ... | no _ = ≤-step (count≤n xs)\n\n------------------------------------------------------------------------\n-- insert\n\nmodule _ {a} {A : Set a} where\n\n insert-lookup : ∀ {n} (xs : Vec A n) (i : Fin (suc n)) (v : A) →\n lookup (insert xs i v) i ≡ v\n insert-lookup xs zero v = refl\n insert-lookup [] (suc ()) v\n insert-lookup (x ∷ xs) (suc i) v = insert-lookup xs i v\n\n insert-punchIn : ∀ {n} (xs : Vec A n) (i : Fin (suc n)) (v : A)\n (j : Fin n) →\n lookup (insert xs i v) (Fin.punchIn i j) ≡ lookup xs j\n insert-punchIn xs zero v j = refl\n insert-punchIn [] (suc ()) v j\n insert-punchIn (x ∷ xs) (suc i) v zero = refl\n insert-punchIn (x ∷ xs) (suc i) v (suc j) = insert-punchIn xs i v j\n\n remove-punchOut : ∀ {n} (xs : Vec A (suc n))\n {i : Fin (suc n)} {j : Fin (suc n)} (i≢j : i ≢ j) →\n lookup (remove xs i) (Fin.punchOut i≢j) ≡ lookup xs j\n remove-punchOut (x ∷ xs) {zero} {zero} i≢j = ⊥-elim (i≢j refl)\n remove-punchOut (x ∷ xs) {zero} {suc j} i≢j = refl\n remove-punchOut (x ∷ []) {suc ()} {j} i≢j\n remove-punchOut (x ∷ y ∷ xs) {suc i} {zero} i≢j = refl\n remove-punchOut (x ∷ y ∷ xs) {suc i} {suc j} i≢j =\n remove-punchOut (y ∷ xs) (i≢j ∘ P.cong suc)\n\n------------------------------------------------------------------------\n-- remove\n\n remove-insert : ∀ {n} (xs : Vec A n) (i : Fin (suc n)) (v : A) →\n remove (insert xs i v) i ≡ xs\n remove-insert xs zero v = refl\n remove-insert [] (suc ()) v\n remove-insert (x ∷ xs) (suc zero) v = refl\n remove-insert (x ∷ []) (suc (suc ())) v\n remove-insert (x ∷ y ∷ xs) (suc (suc i)) v =\n P.cong (x ∷_) (remove-insert (y ∷ xs) (suc i) v)\n\n insert-remove : ∀ {n} (xs : Vec A (suc n)) (i : Fin (suc n)) →\n insert (remove xs i) i (lookup xs i) ≡ xs\n insert-remove (x ∷ xs) zero = refl\n insert-remove (x ∷ []) (suc ())\n insert-remove (x ∷ y ∷ xs) (suc i) =\n P.cong (x ∷_) (insert-remove (y ∷ xs) i)\n\n------------------------------------------------------------------------\n-- Conversion function\n\nmodule _ {a} {A : Set a} where\n\n toList∘fromList : (xs : List A) → toList (fromList xs) ≡ xs\n toList∘fromList List.[] = refl\n toList∘fromList (x List.∷ xs) = P.cong (x List.∷_) (toList∘fromList xs)\n", "meta": {"hexsha": "835b7c1e17f0444d424c41b25c4da8eae586d585", "size": 29545, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/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/Vec/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/Vec/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": 39.9256756757, "max_line_length": 95, "alphanum_fraction": 0.4662379421, "num_tokens": 11592, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.5812652853005841}} {"text": "\n {-# OPTIONS --type-in-type #-}\n\nmodule DescTT 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\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 : Set}{B : A -> Set}(f : (a : A) -> B a)(g : (a : A) -> B a)-> ((a : A) -> f a == g a) -> f == g \n\n\n--********************************************\n-- Desc code\n--********************************************\n\ndata Desc : Set where\n id : Desc\n const : Set -> Desc\n prod : Desc -> Desc -> Desc\n sigma : (S : Set) -> (S -> Desc) -> Desc\n pi : (S : Set) -> (S -> Desc) -> Desc\n\n\n--********************************************\n-- Desc interpretation\n--********************************************\n\n[|_|]_ : Desc -> Set -> Set\n[| id |] Z = Z\n[| const X |] Z = X\n[| prod D D' |] Z = [| D |] Z * [| D' |] Z\n[| sigma S T |] Z = Sigma S (\\s -> [| T s |] Z)\n[| pi S T |] Z = (s : S) -> [| T s |] Z\n\n--********************************************\n-- Fixpoint construction\n--********************************************\n\ndata Mu (D : Desc) : Set where\n con : [| D |] (Mu D) -> Mu D\n\n--********************************************\n-- Predicate: All\n--********************************************\n\nAll : (D : Desc)(X : Set)(P : X -> Set) -> [| D |] X -> Set\nAll id X P x = P x\nAll (const Z) X P x = Unit\nAll (prod D D') X P (d , d') = (All D X P d) * (All D' X P d')\nAll (sigma S T) X P (a , b) = All (T a) X P b\nAll (pi S T) X P f = (s : S) -> All (T s) X P (f s)\n\nall : (D : Desc)(X : Set)(P : X -> Set)(R : (x : X) -> P x)(x : [| D |] X) -> All D X P x\nall id X P R x = R x\nall (const Z) X P R z = Void\nall (prod D D') X P R (d , d') = all D X P R d , all D' X P R d'\nall (sigma S T) X P R (a , b) = all (T a) X P R b\nall (pi S T) X P R f = \\ s -> all (T s) X P R (f s)\n\n--********************************************\n-- Map\n--********************************************\n\nmap : (D : Desc)(X Y : Set)(f : X -> Y)(v : [| D |] X) -> [| D |] Y\nmap id X Y sig x = sig x\nmap (const Z) X Y sig z = z\nmap (prod D D') X Y sig (d , d') = map D X Y sig d , map D' X Y sig d'\nmap (sigma S T) X Y sig (a , b) = (a , map (T a) X Y sig b)\nmap (pi S T) X Y sig f = \\x -> map (T x) X Y sig (f x)\n\n\nproof-map-id : (D : Desc)(X : Set)(v : [| D |] X) -> map D X X (\\x -> x) v == v\nproof-map-id id X v = refl\nproof-map-id (const Z) X v = refl\nproof-map-id (prod D D') X (v , v') = cong2 (\\x y -> (x , y)) (proof-map-id D X v) (proof-map-id D' X v')\nproof-map-id (sigma S T) X (a , b) = cong (\\x -> (a , x)) (proof-map-id (T a) X b) \nproof-map-id (pi S T) X f = reflFun (\\a -> map (T a) X X (\\x -> x) (f a)) f (\\a -> proof-map-id (T a) X (f a))\n\nproof-map-compos : (D : Desc)(X Y Z : Set)\n (f : X -> Y)(g : Y -> Z)\n (v : [| D |] X) -> \n map D X Z (\\x -> g (f x)) v == map D Y Z g (map D X Y f v)\nproof-map-compos id X Y Z f g v = refl\nproof-map-compos (const K) X Y Z f g v = refl\nproof-map-compos (prod D D') X Y Z f g (v , v') = cong2 (\\x y -> (x , y)) \n (proof-map-compos D X Y Z f g v)\n (proof-map-compos D' X Y Z f g v')\nproof-map-compos (sigma S T) X Y Z f g (a , b) = cong (\\x -> (a , x)) (proof-map-compos (T a) X Y Z f g b)\nproof-map-compos (pi S T) X Y Z f g fc = reflFun (\\a -> map (T a) X Z (\\x -> g (f x)) (fc a))\n (\\a -> map (T a) Y Z g (map (T a) X Y f (fc a)))\n (\\a -> proof-map-compos (T a) X Y Z f g (fc a))\n\n--********************************************\n-- Elimination principle: induction\n--********************************************\n\n{-\ninduction : (D : Desc) \n (P : Mu D -> Set) ->\n ( (x : [| D |] (Mu D)) -> \n All D (Mu D) P x -> P (con x)) ->\n (v : Mu D) ->\n P v\ninduction D P ms (con xs) = ms xs (all D (Mu D) P (\\x -> induction D P ms x) xs)\n-}\n\nmodule Elim (D : Desc)\n (P : Mu D -> Set)\n (ms : (x : [| D |] (Mu D)) -> \n All D (Mu D) P x -> P (con x))\n where\n\n mutual\n induction : (x : Mu D) -> P x\n induction (con xs) = ms xs (hyps D xs)\n \n hyps : (D' : Desc)\n (xs : [| D' |] (Mu D)) ->\n All D' (Mu D) P xs\n hyps id x = induction x\n hyps (const Z) z = Void\n hyps (prod D D') (d , d') = hyps D d , hyps D' d'\n hyps (sigma S T) (a , b) = hyps (T a) b\n hyps (pi S T) f = \\s -> hyps (T s) (f s)\n \ninduction : (D : Desc) \n (P : Mu D -> Set) ->\n ( (x : [| D |] (Mu D)) -> \n All D (Mu D) P x -> P (con x)) ->\n (v : Mu D) ->\n P v\ninduction D P ms x = Elim.induction D P ms x\n\n\n--********************************************\n-- Examples\n--********************************************\n\n--****************\n-- Nat\n--****************\n\ndata NatConst : Set where\n Ze : NatConst\n Suc : NatConst\n\nnatCases : NatConst -> Desc\nnatCases Ze = const Unit\nnatCases Suc = id\n\nNatD : Desc\nNatD = sigma NatConst natCases\n\nNat : Set\nNat = Mu NatD\n\nze : Nat\nze = con (Ze , Void)\n\nsuc : Nat -> Nat\nsuc n = con (Suc , n)\n\n--****************\n-- List\n--****************\n\ndata ListConst : Set where\n Nil : ListConst\n Cons : ListConst\n\nlistCases : Set -> ListConst -> Desc\nlistCases X Nil = const Unit\nlistCases X Cons = sigma X (\\_ -> id)\n\nListD : Set -> Desc\nListD X = sigma ListConst (listCases X)\n\nList : Set -> Set\nList X = Mu (ListD X)\n\nnil : {X : Set} -> List X\nnil = con ( Nil , Void )\n\ncons : {X : Set} -> X -> List X -> List X\ncons x t = con ( Cons , ( x , t ))\n\n--****************\n-- Tree\n--****************\n\ndata TreeConst : Set where\n Leaf : TreeConst\n Node : TreeConst\n\ntreeCases : Set -> TreeConst -> Desc\ntreeCases X Leaf = const Unit\ntreeCases X Node = sigma X (\\_ -> prod id id)\n\nTreeD : Set -> Desc\nTreeD X = sigma TreeConst (treeCases X)\n\nTree : Set -> Set\nTree X = Mu (TreeD X)\n\nleaf : {X : Set} -> Tree X\nleaf = con (Leaf , Void)\n\nnode : {X : Set} -> X -> Tree X -> Tree X -> Tree X\nnode x le ri = con (Node , (x , (le , ri)))\n\n--********************************************\n-- Finite sets\n--********************************************\n\nEnumU : Set\nEnumU = Nat\n\nnilE : EnumU\nnilE = ze\n\nconsE : EnumU -> EnumU\nconsE e = suc e\n\n{-\ndata EnumU : Set where\n nilE : EnumU\n consE : EnumU -> EnumU\n-}\n\ndata EnumT : (e : EnumU) -> Set where\n EZe : {e : EnumU} -> EnumT (consE e)\n ESu : {e : EnumU} -> EnumT e -> EnumT (consE e)\n\ncasesSpi : (xs : [| NatD |] Nat) -> \n All NatD Nat (\\e -> (P' : EnumT e -> Set) -> Set) xs -> \n (P' : EnumT (con xs) -> Set) -> Set\ncasesSpi (Ze , Void) hs P' = Unit\ncasesSpi (Suc , n) hs P' = P' EZe * hs (\\e -> P' (ESu e))\n\nspi : (e : EnumU)(P : EnumT e -> Set) -> Set\nspi e P = induction NatD (\\e -> (P : EnumT e -> Set) -> Set) casesSpi e P\n\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-}\n\n\ncasesSwitch : (xs : [| NatD |] Nat) ->\n All NatD Nat (\\e -> (P' : EnumT e -> Set)(b' : spi e P')(x' : EnumT e) -> P' x') xs ->\n (P' : EnumT (con xs) -> Set)(b' : spi (con xs) P')(x' : EnumT (con xs)) -> P' x'\ncasesSwitch (Ze , Void) hs P' b' ()\ncasesSwitch (Suc , n) hs P' b' EZe = fst b'\ncasesSwitch (Suc , n) hs P' b' (ESu e') = hs (\\e -> P' (ESu e)) (snd b') e'\n\nswitch : (e : EnumU)(P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x\nswitch e P b x = induction NatD (\\e -> (P : EnumT e -> Set)(b : spi e P)(x : EnumT e) -> P x) casesSwitch e P b x\n\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\n--********************************************\n-- Tagged description\n--********************************************\n\nTagDesc : Set\nTagDesc = Sigma EnumU (\\e -> spi e (\\_ -> Desc))\n\ntoDesc : TagDesc -> Desc\ntoDesc (B , F) = sigma (EnumT B) (\\e -> switch B (\\_ -> Desc) F e)\n\n--********************************************\n-- Catamorphism\n--********************************************\n\ncata : (D : Desc)\n (T : Set) ->\n ([| D |] T -> T) ->\n (Mu D) -> T\ncata D T phi x = induction D (\\_ -> T) (\\x ms -> phi (replace D T x ms)) x\n where replace : (D' : Desc)(T : Set)(xs : [| D' |] (Mu D))(ms : All D' (Mu D) (\\_ -> T) xs) -> [| D' |] T\n replace id 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--********************************************\n-- Free monad construction\n--********************************************\n\n_**_ : TagDesc -> (X : Set) -> TagDesc\n(e , D) ** X = consE e , (const X , D)\n\n--********************************************\n-- Substitution\n--********************************************\n\napply : (D : TagDesc)(X Y : Set) ->\n (X -> Mu (toDesc (D ** Y))) ->\n [| toDesc (D ** X) |] (Mu (toDesc (D ** Y))) ->\n Mu (toDesc (D ** Y))\napply (E , B) X Y sig (EZe , x) = sig x\napply (E , B) X Y sig (ESu n , t) = con (ESu n , t)\n\nsubst : (D : TagDesc)(X Y : Set) ->\n Mu (toDesc (D ** X)) ->\n (X -> Mu (toDesc (D ** Y))) ->\n Mu (toDesc (D ** Y))\nsubst D X Y x sig = cata (toDesc (D ** X)) (Mu (toDesc (D ** Y))) (apply D X Y sig) x\n", "meta": {"hexsha": "7da4bb5084c7885efd6cc6cdfebb5fdca4fc2a86", "size": 10498, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "models/DescTT.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/DescTT.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/DescTT.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": 28.9201101928, "max_line_length": 113, "alphanum_fraction": 0.398075824, "num_tokens": 3553, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.581180456596562}} {"text": "{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}\n\nmodule Cubical.Data.InfNat.Properties where\n\nopen import Cubical.Data.Nat as ℕ using (ℕ)\nopen import Cubical.Data.InfNat.Base\nopen import Cubical.Core.Primitives\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Relation.Nullary\nopen import Cubical.Data.Unit\nopen import Cubical.Data.Empty\n\nfromInf-def : ℕ → ℕ+∞ → ℕ\nfromInf-def n ∞ = n\nfromInf-def _ (fin n) = n\n\nfin-inj : (n m : ℕ) → fin n ≡ fin m → n ≡ m\nfin-inj x _ eq = cong (fromInf-def x) eq\n\ndiscreteInfNat : Discrete ℕ+∞\ndiscreteInfNat ∞ ∞ = yes (λ i → ∞)\ndiscreteInfNat ∞ (fin _) = no λ p → subst (caseInfNat ⊥ Unit) p tt\ndiscreteInfNat (fin _) ∞ = no λ p → subst (caseInfNat Unit ⊥) p tt\ndiscreteInfNat (fin n) (fin m) with ℕ.discreteℕ n m\ndiscreteInfNat (fin n) (fin m) | yes p = yes (cong fin p)\ndiscreteInfNat (fin n) (fin m) | no ¬p = no (λ p → ¬p (fin-inj n m p))\n", "meta": {"hexsha": "e2f2e10f1728e4828219ab6ac822167422d18088", "size": 909, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Data/InfNat/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/InfNat/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/InfNat/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": 33.6666666667, "max_line_length": 70, "alphanum_fraction": 0.6875687569, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8311430394931456, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.5811804553159401}} {"text": "{-# OPTIONS --without-K #-}\nmodule isos-examples where\n\nopen import Function\nopen import Function.Related.TypeIsomorphisms.NP\nimport Function.Inverse.NP as FI\nopen FI using (_↔_; inverses; module Inverse) renaming (_$₁_ to to; _$₂_ to from)\nimport Function.Related as FR\nopen import Type hiding (★)\nopen import Data.Product.NP\nopen import Data.Bool.NP using (✓)\nopen import Data.One using (𝟙)\nopen import Data.Bits\nopen import Relation.Binary\nimport Relation.Binary.PropositionalEquality as ≡\nopen ≡ using (_≡_; subst)\n\n_≈₂_ : ∀ {a} {A : ★ a} (f g : A → Bit) → ★ _\n_≈₂_ {A = A} f g = Σ A (✓ ∘ f) ↔ Σ A (✓ ∘ g)\n\nmodule _ {a r} {A : ★ a} {R : ★ r} where\n _≈_ : (f g : A → R) → ★ _\n f ≈ g = ∀ (O : R → ★ r) → Σ A (O ∘ f) ↔ Σ A (O ∘ g)\n\n ≈-refl : Reflexive {A = A → R} _≈_\n ≈-refl _ = FI.id\n\n ≈-trans : Transitive {A = A → R} _≈_\n ≈-trans p q O = q O FI.∘ p O\n\n ≈-sym : Symmetric {A = A → R} _≈_\n ≈-sym p O = FI.sym (p O)\n\nmodule _ {a r} {A : ★ a} {R : ★ r} (f : A → R) (p : A ↔ A) where\n stable : f ≈ (f ∘ from p)\n stable _ = first-iso p\n\n stable′ : f ≈ (f ∘ to p)\n stable′ _ = first-iso (FI.sym p)\n\nmodule _ {a b r} {A : ★ a} {B : ★ b} {R : ★ r} where\n _≋_ : (f : A → R) (g : B → R) → ★ _\n f ≋ g = (f ∘ proj₁) ≈ (g ∘ proj₂)\n\nmodule _ {a b r} {A : ★ a} {B : ★ b} {R : ★ r} where\n\n _≋′_ : (f : A → R) (g : B → R) → ★ _\n f ≋′ g = ∀ (O : R → ★ r) →\n (B × Σ A (O ∘ f)) ↔ (A × Σ B (O ∘ g))\n\n module _ {f : A → R} {g : B → R} where\n open FR.EquationalReasoning\n\n ≋′→≋ : f ≋′ g → f ≋ g\n ≋′→≋ h O = Σ (A × B) (O ∘ f ∘ proj₁)\n ↔⟨ Σ×-swap ⟩\n Σ (B × A) (O ∘ f ∘ proj₂)\n ↔⟨ Σ-assoc ⟩\n (B × Σ A (O ∘ f))\n ↔⟨ h O ⟩\n (A × Σ B (O ∘ g))\n ↔⟨ FI.sym Σ-assoc ⟩\n Σ (A × B) (O ∘ g ∘ proj₂)\n ∎\n\n ≋→≋′ : f ≋ g → f ≋′ g\n ≋→≋′ h O = (B × Σ A (O ∘ f))\n ↔⟨ FI.sym Σ-assoc ⟩\n Σ (B × A) (O ∘ f ∘ proj₂)\n ↔⟨ Σ×-swap ⟩\n Σ (A × B) (O ∘ f ∘ proj₁)\n ↔⟨ h O ⟩\n Σ (A × B) (O ∘ g ∘ proj₂)\n ↔⟨ Σ-assoc ⟩\n (A × Σ B (O ∘ g))\n ∎\n -- -}\n -- -}\n -- -}\n -- -}\n -- -}\n", "meta": {"hexsha": "10e0eae92cab52c912df6290a66ff88da1f1e01e", "size": 2254, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Explore/Experimental/iso-probabilistic-reasoning.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/Experimental/iso-probabilistic-reasoning.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/Experimental/iso-probabilistic-reasoning.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.487804878, "max_line_length": 81, "alphanum_fraction": 0.4046140195, "num_tokens": 987, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.58118045138749}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Indexed binary relations\n------------------------------------------------------------------------\n\n-- The contents of this module should be accessed via\n-- `Relation.Binary.Indexed.Heterogeneous`.\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Indexed.Heterogeneous.Bundles where\n\nopen import Function.Base\nopen import Level using (suc; _⊔_)\nopen import Relation.Binary using (_⇒_)\nopen import Relation.Binary.PropositionalEquality.Core as P using (_≡_)\nopen import Relation.Binary.Indexed.Heterogeneous.Core\nopen import Relation.Binary.Indexed.Heterogeneous.Structures\n\n------------------------------------------------------------------------\n-- Definitions\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\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", "meta": {"hexsha": "18d191506468614764f4a732b931cedae7755786", "size": 1411, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/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/Indexed/Heterogeneous/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/Indexed/Heterogeneous/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": 32.0681818182, "max_line_length": 72, "alphanum_fraction": 0.5804394047, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278602705731, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.5810059520999572}} {"text": "\nmodule Prelude.Maybe where\n\nopen import Prelude.Unit\nopen import Prelude.Empty\nopen import Prelude.Function\nopen import Prelude.Functor\nopen import Prelude.Applicative\nopen import Prelude.Monad\nopen import Prelude.Equality\nopen import Prelude.Decidable\n\ndata Maybe {a} (A : Set a) : Set a where\n nothing : Maybe A\n just : A → Maybe A\n\n{-# FOREIGN GHC type AgdaMaybe l = Maybe #-}\n{-# COMPILE GHC Maybe = data MAlonzo.Code.Prelude.Maybe.AgdaMaybe (Nothing | Just) #-}\n\nmaybe : ∀ {a b} {A : Set a} {B : Set b} → B → (A → B) → Maybe A → B\nmaybe z f nothing = z\nmaybe z f (just x) = f x\n{-# INLINE maybe #-}\n\nfromMaybe : ∀ {a} {A : Set a} → A → Maybe A → A\nfromMaybe z = maybe z id\n{-# INLINE fromMaybe #-}\n\nIsJust : ∀ {a} {A : Set a} → Maybe A → Set\nIsJust = maybe ⊥ (const ⊤)\n\nFromJust : ∀ {a} {A : Set a} → Maybe A → Set a\nFromJust {A = A} = maybe ⊤′ (const A)\n\nfromJust : ∀ {a} {A : Set a} (m : Maybe A) → FromJust m\nfromJust nothing = _\nfromJust (just x) = x\n\nmaybeYes : ∀ {a} {A : Set a} → Dec A → Maybe A\nmaybeYes (yes x) = just x\nmaybeYes (no _) = nothing\n\n--- Equality ---\n\njust-inj : ∀ {a} {A : Set a} {x y : A} → just x ≡ just y → x ≡ y\njust-inj refl = refl\n\ninstance\n EqMaybe : ∀ {a} {A : Set a} {{EqA : Eq A}} → Eq (Maybe A)\n _==_ {{EqMaybe}} nothing nothing = yes refl\n _==_ {{EqMaybe}} nothing (just x) = no λ ()\n _==_ {{EqMaybe}} (just x) nothing = no λ ()\n _==_ {{EqMaybe}} (just x) (just y) with x == y\n ... | yes eq = yes (just $≡ eq)\n ... | no neq = no (λ eq → neq (just-inj eq))\n\n--- Monad ---\n\ninstance\n FunctorMaybe : ∀ {a} → Functor (Maybe {a})\n fmap {{FunctorMaybe}} f m = maybe nothing (just ∘ f) m\n\n ApplicativeMaybe : ∀ {a} → Applicative (Maybe {a})\n pure {{ApplicativeMaybe}} = just\n _<*>_ {{ApplicativeMaybe}} mf mx = maybe nothing (λ f → fmap f mx) mf\n\n MonadMaybe : ∀ {a} → Monad {a} Maybe\n _>>=_ {{MonadMaybe}} m f = maybe nothing f m\n\n FunctorMaybe′ : ∀ {a b} → Functor′ {a} {b} Maybe\n fmap′ {{FunctorMaybe′}} f m = maybe nothing (just ∘ f) m\n\n ApplicativeMaybe′ : ∀ {a b} → Applicative′ {a} {b} Maybe\n _<*>′_ {{ApplicativeMaybe′}} (just f) (just x) = just (f x)\n _<*>′_ {{ApplicativeMaybe′}} _ _ = nothing\n\n MonadMaybe′ : ∀ {a b} → Monad′ {a} {b} Maybe\n _>>=′_ {{MonadMaybe′}} m f = maybe nothing f m\n", "meta": {"hexsha": "318c164701914e2387cd07a394605d514538b9a1", "size": 2281, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Maybe.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/Maybe.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/Maybe.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": 28.8734177215, "max_line_length": 86, "alphanum_fraction": 0.5896536607, "num_tokens": 808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637612961506, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5809303442763382}} {"text": "{-# OPTIONS --without-K #-}\n\nopen import HoTT\nopen import cohomology.Theory\n\n{- Ordinary cohomology groups of the n-torus Tⁿ = (S¹)ⁿ.\n - We have Cᵏ(Tⁿ) == C⁰(S⁰)^(n choose' k) where _choose'_ defined as below.\n - This argument could give Cᵏ((Sᵐ)ⁿ) with a little more work. -}\n\nmodule cohomology.Torus {i} (OT : OrdinaryTheory i) where\n\nopen OrdinaryTheory OT\nopen import cohomology.Sn OT\nopen import cohomology.SphereProduct cohomology-theory\nopen import cohomology.Unit cohomology-theory\n\n\n{- Almost n choose k, but with n choose' O = 0 for any n. -}\n_choose'_ : ℕ → ℤ → ℕ\nn choose' negsucc _ = 0\nn choose' pos O = 0\nn choose' pos (S O) = n\nO choose' pos (S (S k)) = 0\nS n choose' pos (S (S k)) = (n choose' (pos (S (S k)))) + (n choose' (pos (S k)))\n\n\n_-⊙Torus : ℕ → Ptd i\nO -⊙Torus = ⊙Lift ⊙Unit\n(S n) -⊙Torus = ⊙Lift {j = i} ⊙S¹ ⊙× (n -⊙Torus)\n\nC-nTorus : (k : ℤ) (n : ℕ)\n → C k (n -⊙Torus) == C 0 (⊙Lift ⊙S⁰) ^ᴳ (n choose' k)\n\nC-nTorus (negsucc k) O = C-Unit (negsucc k)\n\nC-nTorus (negsucc k) (S n) =\n C-Sphere× (negsucc k) 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C (negsucc k) (n -⊙Torus)\n ×ᴳ C (negsucc k) (⊙Susp^ 1 (n -⊙Torus))))\n (C-Sphere-≠ (negsucc k) 1 (ℤ-negsucc≠pos _ _))\n ∙ ×ᴳ-unit-l {G = C (negsucc k) (n -⊙Torus)\n ×ᴳ C (negsucc k) (⊙Susp (n -⊙Torus))}\n ∙ ap (λ K → K ×ᴳ C (negsucc k) (⊙Susp (n -⊙Torus)))\n (C-nTorus (negsucc k) n)\n ∙ ×ᴳ-unit-l {G = C (negsucc k) (⊙Susp (n -⊙Torus))}\n ∙ group-ua (C-Susp (negsucc (S k)) (n -⊙Torus))\n ∙ C-nTorus (negsucc (S k)) n\n\nC-nTorus (pos O) O = C-Unit (pos O)\n\nC-nTorus (pos O) (S n) =\n C-Sphere× (pos O) 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C 0 (n -⊙Torus) ×ᴳ C 0 (⊙Susp (n -⊙Torus))))\n (C-Sphere-≠ (pos O) 1 (pos-≠ (ℕ-O≠S _)))\n ∙ ×ᴳ-unit-l {G = C 0 (n -⊙Torus) ×ᴳ C 0 (⊙Susp (n -⊙Torus))}\n ∙ ap (λ K → K ×ᴳ C 0 (⊙Susp (n -⊙Torus)))\n (C-nTorus 0 n)\n ∙ ×ᴳ-unit-l {G = C 0 (⊙Susp (n -⊙Torus))}\n ∙ group-ua (C-Susp (negsucc O) (n -⊙Torus))\n ∙ C-nTorus (negsucc O) n\n\nC-nTorus (pos (S O)) O = C-Unit 1\n\nC-nTorus (pos (S O)) (S n) =\n C-Sphere× 1 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C 1 (n -⊙Torus)\n ×ᴳ C 1 (⊙Susp (n -⊙Torus))))\n (C-Sphere-diag 1)\n ∙ ap (λ K → C 0 (⊙Lift ⊙S⁰) ×ᴳ K)\n (ap2 _×ᴳ_\n (C-nTorus 1 n)\n (group-ua (C-Susp 0 (n -⊙Torus)) ∙ C-nTorus 0 n)\n ∙ ×ᴳ-unit-r {G = C 0 (⊙Lift ⊙S⁰) ^ᴳ (n choose' 1)})\n\nC-nTorus (pos (S (S k))) O =\n C-Unit (pos (S (S k)))\n\nC-nTorus (pos (S (S k))) (S n) =\n C-Sphere× (pos (S (S k))) 1 (n -⊙Torus)\n ∙ ap (λ K → K ×ᴳ (C (pos (S (S k))) (n -⊙Torus)\n ×ᴳ C (pos (S (S k))) (⊙Susp (n -⊙Torus))))\n (C-Sphere-≠ (pos (S (S k))) 1 (pos-≠ (ℕ-S-≠ (ℕ-S≠O k))))\n ∙ ×ᴳ-unit-l {G = (C (pos (S (S k))) (n -⊙Torus))\n ×ᴳ (C (pos (S (S k))) (⊙Susp (n -⊙Torus)))}\n ∙ ap2 _×ᴳ_ (C-nTorus (pos (S (S k))) n)\n (group-ua (C-Susp (pos (S k)) (n -⊙Torus)) ∙ C-nTorus (pos (S k)) n)\n ∙ ^ᴳ-sum (C 0 (⊙Lift ⊙S⁰)) (n choose' pos (S (S k))) (n choose' pos (S k))\n", "meta": {"hexsha": "ed1b50e21b6a8fd4cca392670cb6e0e46ea8fdb1", "size": 3007, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/Torus.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/Torus.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/Torus.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": 34.1704545455, "max_line_length": 81, "alphanum_fraction": 0.5038244097, "num_tokens": 1535, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637577007393, "lm_q2_score": 0.6757646075489391, "lm_q1q2_score": 0.5809303418466863}} {"text": "module LC.Base where \n\nopen import Data.Nat\n\n--------------------------------------------------------------------------------\n-- de Bruijn indexed lambda calculus\ninfix 5 ƛ_\ninfixl 7 _∙_\ninfix 9 var_\n\ndata Term : Set where\n var_ : (x : ℕ) → Term\n ƛ_ : (M : Term) → Term\n _∙_ : (M : Term) → (N : Term) → Term\n\n", "meta": {"hexsha": "c7fdd710454f970c2a86f1ddb361aff68a8f3f43", "size": 320, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LC/Base.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/Base.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/Base.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": 20.0, "max_line_length": 80, "alphanum_fraction": 0.446875, "num_tokens": 102, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110569397306, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.5808854763363216}} {"text": "------------------------------------------------------------------------------\n-- Common definitions\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split #-}\n{-# OPTIONS --no-sized-types #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K #-}\n\nmodule Common.DefinitionsI where\n\nopen import Common.FOL.FOL using ( ¬_ ; D )\nopen import Common.FOL.Relation.Binary.PropositionalEquality using ( _≡_ )\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-- Inequality.\n_≢_ : D → D → Set\nx ≢ y = ¬ x ≡ y\n", "meta": {"hexsha": "d620a198c144b8dc6d90cecf8950279f2f01fb34", "size": 748, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/Common/DefinitionsI.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/Common/DefinitionsI.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/Common/DefinitionsI.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.5217391304, "max_line_length": 78, "alphanum_fraction": 0.422459893, "num_tokens": 149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.5808299079081245}} {"text": "{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}\n\nopen import Light.Library.Data.Natural as ℕ using (ℕ ; predecessor ; zero)\nopen import Light.Package using (Package)\n\nmodule Light.Literals.Level ⦃ natural‐package : Package record { ℕ } ⦄ where\n\nopen import Light.Literals.Definition.Natural using (FromNatural)\nopen FromNatural using (convert)\nopen import Light.Level using (Level ; 0ℓ ; ++_)\nopen import Light.Library.Relation.Decidable using (if_then_else_)\nopen import Light.Library.Relation.Binary.Equality using (_≈_)\nopen import Light.Library.Relation.Binary.Equality.Decidable using (DecidableEquality)\n\ninstance from‐natural : FromNatural Level\nconvert from‐natural n =\n if n ≈ zero\n then 0ℓ\n else ++ convert from‐natural (predecessor n)\n", "meta": {"hexsha": "51a1fe974b67ec2f2130253588de5b24ff7b3fa3", "size": 793, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Light/Literals/Level.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/Literals/Level.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/Literals/Level.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": 39.65, "max_line_length": 86, "alphanum_fraction": 0.762925599, "num_tokens": 189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767810736693, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.580821948567817}} {"text": "{-# OPTIONS --cubical --safe #-}\nmodule JustBeInjective where\n\nopen import Cubical.Core.Everything\nopen import Cubical.Data.Unit\ndata maybe (A : Set) : Set where\n just : A -> maybe A\n nothing : maybe A\n\nvariable A : Set\n\nunwrap : A → (a : maybe A) → A\nunwrap _ (just x) = x\nunwrap a nothing = a\n\njust-injective : ∀ {A : Set} (a b : A) → just a ≡ just b → a ≡ b\njust-injective a b p i = unwrap a (p i)\n", "meta": {"hexsha": "da91190350526ff4406160cb94884e26bc1d10dd", "size": 403, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/JustBeInjective.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/JustBeInjective.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/JustBeInjective.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": 22.3888888889, "max_line_length": 64, "alphanum_fraction": 0.6401985112, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8267118026095992, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.5807898952854892}} {"text": "-- 2010-10-06 Andreas\n\nmodule TerminationRecordPatternListAppend where\n\ndata Empty : Set where\n\nrecord Unit : Set where\n constructor unit\n\ndata Bool : Set where\n true false : Bool\n\nT : Bool -> Set\nT true = Unit\nT false = Empty\n\n-- Thorsten suggests on the Agda list thread \"Coinductive families\"\n-- to encode lists as records\nrecord List (A : Set) : Set where\n constructor list\n field\n isCons : Bool\n head : T isCons -> A\n tail : T isCons -> List A\n\nopen List public\n\n-- if the record constructor list was counted as structural increase\n-- Thorsten's function would not be rejected\nappend : {A : Set} -> List A -> List A -> List A\nappend (list true h t) l' = list true h (\\ _ -> append (t _) l')\nappend (list false _ _) l' = l'\n\n-- but translating away the record pattern produces something\n-- that is in any case rejected by the termination checker\nappend1 : {A : Set} -> List A -> List A -> List A\nappend1 l l' = append1' l l' (isCons l)\n where append1' : {A : Set} -> List A -> List A -> Bool -> List A\n append1' l l' true = list true (head l) (\\ _ -> append (tail l) l')\n append1' l l' false = l'\n-- NEED inspect!\n", "meta": {"hexsha": "b106dc5773c908a2a768604804fe9e75d3bde7e8", "size": 1153, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/fail/TerminationRecordPatternListAppend.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/fail/TerminationRecordPatternListAppend.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/fail/TerminationRecordPatternListAppend.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.4523809524, "max_line_length": 76, "alphanum_fraction": 0.6556808326, "num_tokens": 330, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706735, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.5807898944355108}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.CommAlgebra.Base where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.SIP\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Semigroup\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.Algebra\n\nopen import Cubical.Displayed.Base\nopen import Cubical.Displayed.Auto\nopen import Cubical.Displayed.Record\nopen import Cubical.Displayed.Universe\n\nopen import Cubical.Reflection.RecordEquiv\n\nprivate\n variable\n ℓ ℓ' : Level\n\nrecord IsCommAlgebra (R : CommRing ℓ) {A : Type ℓ'}\n (0a : A) (1a : A)\n (_+_ : A → A → A) (_·_ : A → A → A) (-_ : A → A)\n (_⋆_ : ⟨ R ⟩ → A → A) : Type (ℓ-max ℓ ℓ') where\n\n constructor iscommalgebra\n\n field\n isAlgebra : IsAlgebra (CommRing→Ring R) 0a 1a _+_ _·_ -_ _⋆_\n ·-comm : (x y : A) → x · y ≡ y · x\n\n open IsAlgebra isAlgebra public\n\nunquoteDecl IsCommAlgebraIsoΣ = declareRecordIsoΣ IsCommAlgebraIsoΣ (quote IsCommAlgebra)\n\nrecord CommAlgebraStr (R : CommRing ℓ) (A : Type ℓ') : Type (ℓ-max ℓ ℓ') where\n\n constructor commalgebrastr\n\n field\n 0a : A\n 1a : A\n _+_ : A → A → A\n _·_ : A → A → A\n -_ : A → A\n _⋆_ : ⟨ R ⟩ → A → A\n isCommAlgebra : IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_\n\n open IsCommAlgebra isCommAlgebra public\n\n infix 8 -_\n infixl 7 _·_\n infixl 7 _⋆_\n infixl 6 _+_\n\nCommAlgebra : (R : CommRing ℓ) → ∀ ℓ' → Type (ℓ-max ℓ (ℓ-suc ℓ'))\nCommAlgebra R ℓ' = Σ[ A ∈ Type ℓ' ] CommAlgebraStr R A\n\nmodule _ {R : CommRing ℓ} where\n open CommRingStr (snd R) using (1r) renaming (_+_ to _+r_; _·_ to _·s_)\n\n CommAlgebraStr→AlgebraStr : {A : Type ℓ'} → CommAlgebraStr R A → AlgebraStr (CommRing→Ring R) A\n CommAlgebraStr→AlgebraStr (commalgebrastr _ _ _ _ _ _ (iscommalgebra isAlgebra ·-comm)) =\n algebrastr _ _ _ _ _ _ isAlgebra\n\n CommAlgebra→Algebra : (A : CommAlgebra R ℓ') → Algebra (CommRing→Ring R) ℓ'\n CommAlgebra→Algebra (_ , str) = (_ , CommAlgebraStr→AlgebraStr str)\n\n CommAlgebra→CommRing : (A : CommAlgebra R ℓ') → CommRing ℓ'\n CommAlgebra→CommRing (_ , commalgebrastr _ _ _ _ _ _ (iscommalgebra isAlgebra ·-comm)) =\n _ , commringstr _ _ _ _ _ (iscommring (IsAlgebra.isRing isAlgebra) ·-comm)\n\n isSetCommAlgebra : (A : CommAlgebra R ℓ') → isSet ⟨ A ⟩\n isSetCommAlgebra A = isSetAlgebra (CommAlgebra→Algebra A)\n\n makeIsCommAlgebra : {A : Type ℓ'} {0a 1a : A}\n {_+_ _·_ : A → A → A} { -_ : A → A} {_⋆_ : ⟨ R ⟩ → A → A}\n (isSet-A : isSet A)\n (+-assoc : (x y z : A) → x + (y + z) ≡ (x + y) + z)\n (+-rid : (x : A) → x + 0a ≡ x)\n (+-rinv : (x : A) → x + (- x) ≡ 0a)\n (+-comm : (x y : A) → x + y ≡ y + x)\n (·-assoc : (x y z : A) → x · (y · z) ≡ (x · y) · z)\n (·-lid : (x : A) → 1a · x ≡ x)\n (·-ldist-+ : (x y z : A) → (x + y) · z ≡ (x · z) + (y · z))\n (·-comm : (x y : A) → x · y ≡ y · x)\n (⋆-assoc : (r s : ⟨ R ⟩) (x : A) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x))\n (⋆-ldist : (r s : ⟨ R ⟩) (x : A) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))\n (⋆-rdist : (r : ⟨ R ⟩) (x y : A) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))\n (⋆-lid : (x : A) → 1r ⋆ x ≡ x)\n (⋆-lassoc : (r : ⟨ R ⟩) (x y : A) → (r ⋆ x) · y ≡ r ⋆ (x · y))\n → IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_\n makeIsCommAlgebra {A = A} {0a} {1a} {_+_} {_·_} { -_} {_⋆_} isSet-A\n +-assoc +-rid +-rinv +-comm\n ·-assoc ·-lid ·-ldist-+ ·-comm\n ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid ⋆-lassoc\n = iscommalgebra\n (makeIsAlgebra\n isSet-A\n +-assoc +-rid +-rinv +-comm\n ·-assoc\n (λ x → x · 1a ≡⟨ ·-comm _ _ ⟩ 1a · x ≡⟨ ·-lid _ ⟩ x ∎)\n ·-lid\n (λ x y z → x · (y + z) ≡⟨ ·-comm _ _ ⟩\n (y + z) · x ≡⟨ ·-ldist-+ _ _ _ ⟩\n (y · x) + (z · x) ≡⟨ cong (λ u → (y · x) + u) (·-comm _ _) ⟩\n (y · x) + (x · z) ≡⟨ cong (λ u → u + (x · z)) (·-comm _ _) ⟩\n (x · y) + (x · z) ∎)\n ·-ldist-+\n ⋆-assoc\n ⋆-ldist\n ⋆-rdist\n ⋆-lid\n ⋆-lassoc\n λ r x y → r ⋆ (x · y) ≡⟨ cong (λ u → r ⋆ u) (·-comm _ _) ⟩\n r ⋆ (y · x) ≡⟨ sym (⋆-lassoc _ _ _) ⟩\n (r ⋆ y) · x ≡⟨ ·-comm _ _ ⟩\n x · (r ⋆ y) ∎)\n ·-comm\n\n module _ (S : CommRing ℓ) where\n open CommRingStr (snd S) renaming (1r to 1S)\n open CommRingStr (snd R) using () renaming (_·_ to _·R_; _+_ to _+R_; 1r to 1R)\n commAlgebraFromCommRing :\n (_⋆_ : fst R → fst S → fst S)\n → ((r s : fst R) (x : fst S) → (r ·R s) ⋆ x ≡ r ⋆ (s ⋆ x))\n → ((r s : fst R) (x : fst S) → (r +R s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))\n → ((r : fst R) (x y : fst S) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))\n → ((x : fst S) → 1R ⋆ x ≡ x)\n → ((r : fst R) (x y : fst S) → (r ⋆ x) · y ≡ r ⋆ (x · y))\n → CommAlgebra R ℓ\n commAlgebraFromCommRing _⋆_ ·Assoc⋆ ⋆DistR ⋆DistL ⋆Lid ⋆Assoc· = fst S ,\n commalgebrastr 0r 1S _+_ _·_ -_ _⋆_\n (makeIsCommAlgebra is-set +Assoc +Rid +Rinv +Comm ·Assoc ·Lid ·Ldist+ ·Comm\n ·Assoc⋆ ⋆DistR ⋆DistL ⋆Lid ⋆Assoc·)\n\n\n IsCommAlgebraEquiv : {A B : Type ℓ'}\n (M : CommAlgebraStr R A) (e : A ≃ B) (N : CommAlgebraStr R B)\n → Type (ℓ-max ℓ ℓ')\n IsCommAlgebraEquiv M e N =\n IsAlgebraHom (CommAlgebraStr→AlgebraStr M) (e .fst) (CommAlgebraStr→AlgebraStr N)\n\n CommAlgebraEquiv : (M N : CommAlgebra R ℓ') → Type (ℓ-max ℓ ℓ')\n CommAlgebraEquiv M N = Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] IsCommAlgebraEquiv (M .snd) e (N .snd)\n\n IsCommAlgebraHom : {A B : Type ℓ'}\n (M : CommAlgebraStr R A) (f : A → B) (N : CommAlgebraStr R B)\n → Type (ℓ-max ℓ ℓ')\n IsCommAlgebraHom M f N =\n IsAlgebraHom (CommAlgebraStr→AlgebraStr M) f (CommAlgebraStr→AlgebraStr N)\n\n CommAlgebraHom : (M N : CommAlgebra R ℓ') → Type (ℓ-max ℓ ℓ')\n CommAlgebraHom M N = Σ[ f ∈ (⟨ M ⟩ → ⟨ N ⟩) ] IsCommAlgebraHom (M .snd) f (N .snd)\n\n module _ {M N : CommAlgebra R ℓ'} where\n open CommAlgebraStr {{...}}\n open IsAlgebraHom\n private\n instance\n _ = snd M\n _ = snd N\n\n makeCommAlgebraHom : (f : fst M → fst N)\n → (fPres1 : f 1a ≡ 1a)\n → (fPres+ : (x y : fst M) → f (x + y) ≡ f x + f y)\n → (fPres· : (x y : fst M) → f (x · y) ≡ f x · f y)\n → (fPres⋆ : (r : fst R) (x : fst M) → f (r ⋆ x) ≡ r ⋆ f x)\n → CommAlgebraHom M N\n makeCommAlgebraHom f fPres1 fPres+ fPres· fPres⋆ = f , isHom\n where fPres0 =\n f 0a ≡⟨ sym (+-rid _) ⟩\n f 0a + 0a ≡⟨ cong (λ u → f 0a + u) (sym (+-rinv (f 0a))) ⟩\n f 0a + (f 0a - f 0a) ≡⟨ +-assoc (f 0a) (f 0a) (- f 0a) ⟩\n (f 0a + f 0a) - f 0a ≡⟨ cong (λ u → u - f 0a) (sym (fPres+ 0a 0a)) ⟩\n f (0a + 0a) - f 0a ≡⟨ cong (λ u → f u - f 0a) (+-lid 0a) ⟩\n f 0a - f 0a ≡⟨ +-rinv (f 0a) ⟩\n 0a ∎\n\n isHom : IsCommAlgebraHom (snd M) f (snd N)\n pres0 isHom = fPres0\n pres1 isHom = fPres1\n pres+ isHom = fPres+\n pres· isHom = fPres·\n pres- isHom = (λ x →\n f (- x) ≡⟨ sym (+-rid _) ⟩\n (f (- x) + 0a) ≡⟨ cong (λ u → f (- x) + u) (sym (+-rinv (f x))) ⟩\n (f (- x) + (f x - f x)) ≡⟨ +-assoc _ _ _ ⟩\n ((f (- x) + f x) - f x) ≡⟨ cong (λ u → u - f x) (sym (fPres+ _ _)) ⟩\n (f ((- x) + x) - f x) ≡⟨ cong (λ u → f u - f x) (+-linv x) ⟩\n (f 0a - f x) ≡⟨ cong (λ u → u - f x) fPres0 ⟩\n (0a - f x) ≡⟨ +-lid _ ⟩ (- f x) ∎)\n pres⋆ isHom = fPres⋆\n\n isPropIsCommAlgebraHom : (f : fst M → fst N) → isProp (IsCommAlgebraHom (snd M) f (snd N))\n isPropIsCommAlgebraHom f = isPropIsAlgebraHom\n (CommRing→Ring R)\n (snd (CommAlgebra→Algebra M))\n f\n (snd (CommAlgebra→Algebra N))\n\nisPropIsCommAlgebra : (R : CommRing ℓ) {A : Type ℓ'}\n (0a 1a : A)\n (_+_ _·_ : A → A → A)\n (-_ : A → A)\n (_⋆_ : ⟨ R ⟩ → A → A)\n → isProp (IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_)\nisPropIsCommAlgebra R _ _ _ _ _ _ =\n isOfHLevelRetractFromIso 1 IsCommAlgebraIsoΣ\n (isPropΣ (isPropIsAlgebra _ _ _ _ _ _ _)\n (λ alg → isPropΠ2 λ _ _ → alg .IsAlgebra.is-set _ _))\n\n𝒮ᴰ-CommAlgebra : (R : CommRing ℓ) → DUARel (𝒮-Univ ℓ') (CommAlgebraStr R) (ℓ-max ℓ ℓ')\n𝒮ᴰ-CommAlgebra R =\n 𝒮ᴰ-Record (𝒮-Univ _) (IsCommAlgebraEquiv {R = R})\n (fields:\n data[ 0a ∣ nul ∣ pres0 ]\n data[ 1a ∣ nul ∣ pres1 ]\n data[ _+_ ∣ bin ∣ pres+ ]\n data[ _·_ ∣ bin ∣ pres· ]\n data[ -_ ∣ autoDUARel _ _ ∣ pres- ]\n data[ _⋆_ ∣ autoDUARel _ _ ∣ pres⋆ ]\n prop[ isCommAlgebra ∣ (λ _ _ → isPropIsCommAlgebra _ _ _ _ _ _ _) ])\n where\n open CommAlgebraStr\n open IsAlgebraHom\n\n -- faster with some sharing\n nul = autoDUARel (𝒮-Univ _) (λ A → A)\n bin = autoDUARel (𝒮-Univ _) (λ A → A → A → A)\n\nCommAlgebraPath : (R : CommRing ℓ) → (A B : CommAlgebra R ℓ') → (CommAlgebraEquiv A B) ≃ (A ≡ B)\nCommAlgebraPath R = ∫ (𝒮ᴰ-CommAlgebra R) .UARel.ua\n\nisGroupoidCommAlgebra : {R : CommRing ℓ} → isGroupoid (CommAlgebra R ℓ')\nisGroupoidCommAlgebra A B = isOfHLevelRespectEquiv 2 (CommAlgebraPath _ _ _) (isSetAlgebraEquiv _ _)\n", "meta": {"hexsha": "8e80df43a33a94cfc3a00d912425df35ac69e3b9", "size": 10028, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/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/Algebra/CommAlgebra/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/Algebra/CommAlgebra/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": 41.0983606557, "max_line_length": 100, "alphanum_fraction": 0.4706820901, "num_tokens": 4072, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706734, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.5807898892866371}} {"text": "module PushProdPull where\n\nopen import Categories.Category\nopen import Categories.Category.Cartesian.Bundle\nopen import Categories.Category.CartesianClosed.Canonical\nopen import Categories.Category.Core\nopen import Categories.Category.Product\nopen import Categories.Diagram.Pullback\nopen import Categories.Diagram.Pushout\nopen import Categories.Functor\nopen import Categories.Functor.Bifunctor\nopen import Data.Product\nopen import Function using (const)\nopen import Level\nopen import Relation.Binary.Core using (Rel)\nopen import Relation.Binary.PropositionalEquality\nopen Relation.Binary.PropositionalEquality.≡-Reasoning\n\npostulate\n extensionality : ∀ {A B : Set} {f g : A → B} →\n (∀ (x : A) → f x ≡ g x) →\n f ≡ g\n\ndata t : Set where\n ⊤ : t\n\n!-unique-lemma : ∀ (x : t) → ⊤ ≡ x\n!-unique-lemma ⊤ = refl\n\narrow : Category (suc zero) zero zero\narrow = record\n { Obj = Σ (Set × Set) (λ x → proj₁ x → proj₂ x)\n ; _⇒_ = arr\n ; _≈_ = _≡_\n ; id = (λ z → z) , λ z → z\n ; _∘_ = λ {A} {B} {C} f g → comp {A} {B} {C} f g\n ; assoc = refl\n ; sym-assoc = refl\n ; identityˡ = refl\n ; identityʳ = refl\n ; identity² = refl\n ; equiv = record { refl = refl ; sym = sym ; trans = trans }\n ; ∘-resp-≈ = λ {refl refl → refl}\n }\n where\n arr : Rel (Σ (Set × Set) (λ x → proj₁ x → proj₂ x)) zero\n arr ((a , b) , x1) ((c , d) , y1) = (a → c) × (b → d)\n comp : {A B C : Σ (Set × Set) (λ x → proj₁ x → proj₂ x)} → arr B C → arr A B → arr A C\n comp {A} {B} {C} (f0 , f1) (g0 , g1) = (λ x → f0 (g0 x)) , λ x → f1 (g1 x)\n\nopen Category arrow\n\nSetC : Category (suc zero) zero zero\nSetC =\n record\n { Obj = Set\n ; _⇒_ = λ x y → x → y\n ; _≈_ = _≡_\n ; id = λ x → x\n ; _∘_ = λ f g a → f (g a)\n ; assoc = refl\n ; sym-assoc = refl\n ; identityˡ = refl\n ; identityʳ = refl\n ; identity² = refl\n ; equiv = record { refl = refl ; sym = sym ; trans = trans }\n ; ∘-resp-≈ = λ {refl refl → refl}\n }\n\npushout-prod : (f g : Obj) → Obj\npushout-prod ((A0 , A1) , f) ((B0 , B1) , g) = {! !}\n-- Pushout SetC f×1 1×g\n-- where\n-- f×1 : A0 × B0 → A1 × B0\n-- f×1 (a , b) = f a , b\n-- 1×g : A0 × B0 → A0 × B1\n-- 1×g (a , b) = a , g b\n\npullback-hom : (f g : Obj) → Obj\npullback-hom ((A0 , A1) , f) ((B0 , B1) , g) = {! !}\n-- Pullback SetC [f,1] [1,g]\n-- where\n-- [f,1] : (A1 → B1) → A0 → B1\n-- [f,1] u = λ x → u (f x)\n-- [1,g] : (A0 → B0) → A0 → B1\n-- [1,g] u = λ x → g (u x)\n\npp-is-functor : Endobifunctor arrow\npp-is-functor =\n record\n { F₀ = F0\n ; F₁ = {! !}\n ; identity = {! !}\n ; homomorphism = {! !}\n ; F-resp-≈ = {! !}\n }\n where\n F0 : Category.Obj (Categories.Category.Product.Product arrow arrow) → Obj\n F0 x = pullback-hom (proj₁ x) (proj₂ x)\n F1 : {A B : Obj × Obj} → Product arrow arrow Categories.Category.[ A , B ] → arrow Categories.Category.[ F0 A , F0 B ]\n F1 {((A0 , A1) , a) , ((B0 , B1) , b)} {((C0 , C1) , c) , ((D0 , D1) , d)} ((u , v) , s , t) = {! !}", "meta": {"hexsha": "c22edf11c15e71da837ae70960890c23c5f30ecf", "size": 2881, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/PushProdPull.agda", "max_stars_repo_name": "tetrapharmakon/agda-categories", "max_stars_repo_head_hexsha": "cfa6aefd3069d4db995191b458c886edcfba8294", "max_stars_repo_licenses": ["MIT"], "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/PushProdPull.agda", "max_issues_repo_name": "tetrapharmakon/agda-categories", "max_issues_repo_head_hexsha": "cfa6aefd3069d4db995191b458c886edcfba8294", "max_issues_repo_licenses": ["MIT"], "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/PushProdPull.agda", "max_forks_repo_name": "tetrapharmakon/agda-categories", "max_forks_repo_head_hexsha": "cfa6aefd3069d4db995191b458c886edcfba8294", "max_forks_repo_licenses": ["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.5247524752, "max_line_length": 120, "alphanum_fraction": 0.5584866366, "num_tokens": 1172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267118026095992, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.5807898849877415}} {"text": "-- Intuitionistic logic, PHOAS approach, initial encoding\n\nmodule Pi.I (Indiv : Set) where\n\n\n-- Types\n\ndata Ty : Set\n\nPred : Set\nPred = Indiv -> Ty\n\ninfixl 2 _&&_\ninfixl 1 _||_\ninfixr 0 _=>_\ndata Ty where\n UNIT : Ty\n _=>_ : Ty -> Ty -> Ty\n _&&_ : Ty -> Ty -> Ty\n _||_ : Ty -> Ty -> Ty\n FALSE : Ty\n FORALL : Pred -> Ty\n EXISTS : Pred -> 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/individual judgement\n\ndata El : Set where\n mkTrue : Ty -> El\n mkIndiv : Indiv -> El\n\nCx : Set1\nCx = El -> Set\n\nisTrue : Ty -> Cx -> Set\nisTrue a tc = tc (mkTrue a)\n\nisIndiv : Indiv -> Cx -> Set\nisIndiv x tc = tc (mkIndiv x)\n\n\n-- Terms\n\nmodule I where\n infixl 2 _$$_\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 pi' : forall {p} -> (forall {x} -> isIndiv x tc -> Tm tc (p x)) -> Tm tc (FORALL p)\n _$$_ : forall {p x} -> Tm tc (FORALL p) -> isIndiv x tc -> Tm tc (p x)\n sig' : forall {p x} -> isIndiv x tc -> Tm tc (p x) -> Tm tc (EXISTS p)\n split' : forall {p x a} -> Tm tc (EXISTS p) -> (isTrue (p x) tc -> Tm tc a) -> Tm tc a\n abort : forall {a} -> Tm tc FALSE -> Tm tc a\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 split'' : forall {tc p x a} -> Tm tc (EXISTS p) -> (Tm tc (p x) -> Tm tc a) -> Tm tc a\n split'' x f = split' x \\y -> f (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 syntax pi' (\\x -> px) = pi x => px\n syntax sig' x px = [ x ,, px ]\n syntax split'' x (\\y -> z) = split x as y => z\n\n Thm : Ty -> Set1\n Thm a = forall {tc} -> Tm tc a\nopen I public\n\n\n-- Example theorems\n\nt214 : forall {p q : Pred} -> Thm (\n FORALL (\\x -> p x || NOT (p x)) && FORALL (\\x -> p x => EXISTS (\\y -> q y)) =>\n FORALL (\\x -> EXISTS (\\y -> p x => q y)))\nt214 =\n lam fg =>\n pi x =>\n case fst fg $$ x\n of px =>\n split snd fg $$ x $ px\n as qy =>\n [ x ,, lam _ => qy ]\n or npx =>\n [ x ,, lam px => abort (npx $ px) ]\n\nl5 : forall {a} -> Thm (a && FALSE <=> FALSE)\nl5 =\n [ lam xnt => snd xnt\n , lam nt => abort nt\n ]\n\nl10 : forall {a} -> Thm (a || FALSE <=> a)\nl10 =\n [ lam xnt =>\n case xnt\n of x => x\n or nt => abort nt\n , lam x => left x\n ]\n\nl20 : forall {a} -> Thm ((FALSE => a) <=> TRUE)\nl20 =\n [ lam _ => lam nt => nt\n , lam _ => lam nt => abort nt\n ]\n", "meta": {"hexsha": "4a4423f17d49d7de62a12b074cb1ecb7fd1dd595", "size": 3582, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Pi/I.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/I.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/I.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": 27.5538461538, "max_line_length": 114, "alphanum_fraction": 0.4349525405, "num_tokens": 1361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117983401363, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.5807898768394417}} {"text": "open import Data.Bool using (Bool; false; true; _∧_)\nopen import Data.Maybe\nopen import Data.Nat\nopen import Data.Nat.Properties --using (_≟_; _ (∀ (a b : K') (u v : A) -> (f ⟨$⟩ (a ∙₁ u +₁ b ∙₁ v)) ≈₂ a ∙₂ (f ⟨$⟩ u) +₂ b ∙₂ (f ⟨$⟩ v))\n -> IsLinearMap From To (f ⟨$⟩_)\n linear f lin = record\n { isAbelianGroupMorphism = record\n { gp-homo = record\n { mn-homo = record\n { sm-homo = record\n { ⟦⟧-cong = cong f\n ; ∙-homo = λ x y →\n begin\n f ⟨$⟩ x +₁ y\n ≈⟨ cong f (+₁-cong (≈₁-sym (∙₁-identity x)) (≈₁-sym (∙₁-identity y))) ⟩\n f ⟨$⟩ (1ᵏ ∙₁ x +₁ 1ᵏ ∙₁ y)\n ≈⟨ lin 1ᵏ 1ᵏ x y ⟩\n 1ᵏ ∙₂ (f ⟨$⟩ x) +₂ 1ᵏ ∙₂ (f ⟨$⟩ y)\n ≈⟨ +₂-cong (∙₂-identity (f ⟨$⟩ x)) (∙₂-identity (f ⟨$⟩ y)) ⟩\n (f ⟨$⟩ x) +₂ (f ⟨$⟩ y)\n ∎\n }\n ; ε-homo =\n begin\n f ⟨$⟩ 0₁\n ≈⟨ cong f (≈₁-trans (≈₁-sym (+₁-identityˡ 0₁)) (+₁-cong (≈₁-sym (∙₁-absorbˡ 0₁)) (≈₁-sym (∙₁-absorbˡ 0₁)))) ⟩\n f ⟨$⟩ 0ᵏ ∙₁ 0₁ +₁ 0ᵏ ∙₁ 0₁\n ≈⟨ lin 0ᵏ 0ᵏ 0₁ 0₁ ⟩\n 0ᵏ ∙₂ (f ⟨$⟩ 0₁) +₂ 0ᵏ ∙₂ (f ⟨$⟩ 0₁)\n ≈⟨ ≈₂-trans (+₂-cong (∙₂-absorbˡ (f ⟨$⟩ 0₁)) (∙₂-absorbˡ (f ⟨$⟩ 0₁))) (+₂-identityˡ 0₂) ⟩\n 0₂\n ∎\n }\n }\n }\n ; ∙-homo = λ c u →\n begin\n f ⟨$⟩ c ∙₁ u\n ≈⟨ cong f (≈₁-trans (≈₁-sym (+₁-identityˡ (c ∙₁ u))) (+₁-cong (≈₁-sym (∙₁-absorbˡ 0₁)) ≈₁-refl)) ⟩\n f ⟨$⟩ 0ᵏ ∙₁ 0₁ +₁ c ∙₁ u\n ≈⟨ lin 0ᵏ c 0₁ u ⟩\n 0ᵏ ∙₂ (f ⟨$⟩ 0₁) +₂ c ∙₂ (f ⟨$⟩ u)\n ≈⟨ ≈₂-trans (+₂-cong (∙₂-absorbˡ (f ⟨$⟩ 0₁)) ≈₂-refl) (+₂-identityˡ (c ∙₂ (f ⟨$⟩ u))) ⟩\n c ∙₂ (f ⟨$⟩ u)\n ∎\n }\n where open import Relation.Binary.EqReasoning setoid₂\n", "meta": {"hexsha": "5b02abb01686366bb1fe19666fdbcf2a88f5432c", "size": 3595, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Linear/Morphism/Properties.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/Properties.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/Properties.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.9583333333, "max_line_length": 121, "alphanum_fraction": 0.4787204451, "num_tokens": 1472, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7122321964553658, "lm_q1q2_score": 0.5806348265129506}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Membership of vectors, along with some additional definitions.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Setoid; _Respects_)\n\nmodule Data.Vec.Membership.Setoid {c ℓ} (S : Setoid c ℓ) where\n\nopen import Function\nopen import Data.Vec as Vec using (Vec; []; _∷_)\nopen import Data.Vec.Relation.Unary.Any as Any\n using (Any; here; there; index)\nopen import Data.Product using (∃; _×_; _,_)\nopen import Relation.Nullary using (¬_)\nopen import Relation.Unary using (Pred)\n\nopen Setoid S renaming (Carrier to A)\n\n------------------------------------------------------------------------\n-- Definitions\n\ninfix 4 _∈_ _∉_\n\n_∈_ : A → ∀ {n} → Vec A n → Set _\nx ∈ xs = Any (x ≈_) xs\n\n_∉_ : A → ∀ {n} → Vec A n → Set _\nx ∉ xs = ¬ x ∈ xs\n\n------------------------------------------------------------------------\n-- Operations\n\nmapWith∈ : ∀ {b} {B : Set b} {n}\n (xs : Vec A n) → (∀ {x} → x ∈ xs → B) → Vec B n\nmapWith∈ [] f = []\nmapWith∈ (x ∷ xs) f = f (here refl) ∷ mapWith∈ xs (f ∘ there)\n\n_∷=_ : ∀ {n} {xs : Vec A n} {x} → x ∈ xs → A → Vec A n\n_∷=_ {xs = xs} x∈xs v = xs Vec.[ index x∈xs ]≔ v\n\n------------------------------------------------------------------------\n-- Finding and losing witnesses\n\nmodule _ {p} {P : Pred A p} where\n\n find : ∀ {n} {xs : Vec A n} → Any P xs → ∃ λ x → x ∈ xs × P x\n find (here px) = (_ , here refl , px)\n find (there pxs) with find pxs\n ... | (x , x∈xs , px) = (x , there x∈xs , px)\n\n lose : P Respects _≈_ → ∀ {x n} {xs : Vec A n} → x ∈ xs → P x → Any P xs\n lose resp x∈xs px = Any.map (flip resp px) x∈xs\n", "meta": {"hexsha": "af54d76d48e779a1ede9c9774b315fc99703f463", "size": 1761, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Membership/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/Vec/Membership/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/Vec/Membership/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": 30.8947368421, "max_line_length": 74, "alphanum_fraction": 0.4571266326, "num_tokens": 536, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301567, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.5806348229482612}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Cubical.HITs.Modulo.Base where\n\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Empty\nopen import Cubical.Data.Fin\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Unit renaming (Unit to ⊤)\n\nopen import Cubical.Relation.Nullary\n\nNonZero : ℕ → Type₀\nNonZero 0 = ⊥\nNonZero _ = ⊤\n\nprivate\n variable\n ℓ : Level\n k : ℕ\n\n-- The Modulo type is similar to the Fin type, but instead of being\n-- inhabited by canonical values, the inhabitants are all naturals,\n-- and paths are added between numbers that have the same residue.\n--\n-- This representation makes it easier to do certain arithmetic\n-- without changing the modulus. For instance, we can just add any\n-- natural to a Modulo k to get another, whereas with Fin k, we must\n-- calculate the canonical representative.\n--\n-- The reason the path constructor is guarded is to avoid adding\n-- non-trivial path structure to the k=0 case. If it were not guarded,\n-- each `Modulo 0` would become like the circle, and guarding the\n-- constructor is somewhat easier to work with than truncation.\n--\n-- Note also that unlike `Fin 0`, `Modulo 0` is equivalent to the naturals.\ndata Modulo (k : ℕ) : Type₀ where\n embed : (n : ℕ) → Modulo k\n pre-step : NonZero k → (n : ℕ) → embed n ≡ embed (k + n)\n\n-- When we are working with k = suc k₀, the `step` alias is much\n-- we can use this alias.\npattern step n i = pre-step _ n i\n\n-- Helper to avoid having to case on `k` in certain places.\nztep : ∀{k} n → Path (Modulo k) (embed n) (embed (k + n))\nztep {0} n = refl\nztep {suc k} n = step n\n\n-- The standard eliminator for `Modulo`.\nelim\n : (P : ∀ k → Modulo k → Type ℓ)\n → (e : ∀ k n → P k (embed n))\n → (st : ∀ k n → PathP (λ i → P (suc k) (step n i)) (e (suc k) n) (e (suc k) (suc k + n)))\n → (m : Modulo k) → P k m\nelim P e st (embed n) = e _ n\nelim {k = suc k} P e st (step n i) = st k n i\n", "meta": {"hexsha": "c7005a40756f7e74078344257c0754bdd5a9c75a", "size": 2029, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Modulo/Base.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/Modulo/Base.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/Modulo/Base.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.7258064516, "max_line_length": 91, "alphanum_fraction": 0.6850665352, "num_tokens": 617, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301567, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.5806348229482611}} {"text": "------------------------------------------------------------------------\n-- A formalisation of one variant of the language χ, along with a\n-- number of properties\n--\n-- Nils Anders Danielsson\n------------------------------------------------------------------------\n\n-- A description of the language χ, as well as some of the definitions\n-- and proofs used in this development, can be found in \"The language\n-- χ\" by Bengt Nordström (edited by me):\n--\n-- * https://chalmers.instructure.com/courses/10744/file_contents/course%20files/reading/The_language_chi.pdf\n--\n-- See also the following lecture slides:\n--\n-- * https://chalmers.instructure.com/courses/10744/file_contents/course%20files/lectures/L4.pdf\n-- * https://chalmers.instructure.com/courses/10744/file_contents/course%20files/lectures/L5.pdf\n-- * https://chalmers.instructure.com/courses/10744/file_contents/course%20files/lectures/L6.pdf\n\nmodule README where\n\n-- Atoms.\n\nimport Atom\n\n-- Various constants.\n\nimport Constants\n\n-- A specification of the language χ.\n\nimport Chi\n\n-- The semantics is deterministic.\n\nimport Deterministic\n\n-- Values.\n\nimport Values\n\n-- Some cancellation lemmas.\n\nimport Cancellation\n\n-- \"Reasoning\" combinators.\n\nimport Reasoning\n\n-- The abstract syntax is a set, and the semantics is propositional.\n\nimport Propositional\n\n-- The \"terminates\" relation.\n\nimport Termination\n\n-- Compatibility lemmas.\n\nimport Compatibility\n\n-- Some substitution lemmas.\n\nimport Substitution\n\n-- Definitions of \"free in\" and \"closed\", along with some properties.\n\nimport Free-variables\n\n-- Alpha-equivalence.\n\nimport Alpha-equivalence\n\n-- Encoders and decoders.\n\nimport Coding\n\n-- Encoder and decoder instances.\n\nimport Coding.Instances\n\n-- Encoder and decoder instances for Atom.χ-ℕ-atoms.\n\nimport Coding.Instances.Nat\n\n-- Internal coding.\n\nimport Internal-coding\n\n-- Some χ program combinators.\n\nimport Combinators\n\n-- The rec construction can be encoded using λ-terms.\n\nimport Recursion-without-rec\n\n-- Definition of the size of an expression, along with some\n-- properties.\n\nimport Expression-size\n\n-- A self-interpreter (without correctness proof).\n\nimport Self-interpreter\n\n-- Partial functions, computability.\n\nimport Computability\n\n-- The halting problem.\n\nimport Halting-problem\n\n-- Rice's theorem.\n\nimport Rices-theorem\n\n-- A theorem related to pointwise equality.\n\nimport Pointwise-equality\n", "meta": {"hexsha": "9491fbbb6f14691e259259c17e04a9dd902a8d34", "size": 2372, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "README.agda", "max_stars_repo_name": "nad/chi", "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_issues_repo_path": "README.agda", "max_issues_repo_name": "nad/chi", "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_forks_repo_path": "README.agda", "max_forks_repo_name": "nad/chi", "max_forks_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": ["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.4426229508, "max_line_length": 109, "alphanum_fraction": 0.718381113, "num_tokens": 521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.76908023177796, "lm_q1q2_score": 0.5805901930728112}} {"text": "open import Type\n\nmodule Graph.Category {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where\n\nopen import Data.Tuple as Tuple using ()\nopen import Functional\nopen import Logic.Propositional\nimport Lvl\nopen import Graph{ℓ₁}{ℓ₂}(V)\nopen import Graph.Walk{ℓ₁}{ℓ₂}{V}\nopen import Graph.Walk.Proofs{ℓ₁}{ℓ₂}{V}\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Category\nimport Structure.Categorical.Names as Names\nopen import Structure.Categorical.Properties\nopen import Structure.Function\nopen import Structure.Operator\nopen import Structure.Relator.Properties\nopen import Syntax.Transitivity\n\nmodule _ (_⟶_ : Graph) where\n private variable a b c d : V\n private variable e e₁ e₂ e₃ : a ⟶ b\n private variable w w₁ w₂ w₃ : Walk(_⟶_) a b\n\n Walk-transitivity-raw-identityₗ-raw : (Walk-transitivity-raw at w ≡ w)\n Walk-transitivity-raw-identityₗ-raw = [≡]-intro\n\n Walk-transitivity-raw-identityᵣ-raw : (Walk-transitivity-raw w at ≡ w)\n Walk-transitivity-raw-identityᵣ-raw {a}{.a} {Walk.at} = [≡]-intro\n Walk-transitivity-raw-identityᵣ-raw {a}{c} {Walk.prepend {b = b} e w} = congruence₁(prepend e) (Walk-transitivity-raw-identityᵣ-raw {b}{c} {w})\n\n Walk-transitivity-raw-associativity-raw : Names.Morphism.Associativity{Obj = V}(\\{w} → Walk-transitivity-raw{_⟶_ = _⟶_}{z = w})\n Walk-transitivity-raw-associativity-raw {a}{b}{c}{d} {Walk.at} {w₂}{w₃} = [≡]-intro\n Walk-transitivity-raw-associativity-raw {a}{b}{c}{d} {Walk.prepend e w₁}{w₂}{w₃} = congruence₁(prepend e) (Walk-transitivity-raw-associativity-raw {a}{b}{c}{_} {w₁}{w₂}{w₃})\n\n instance\n Walk-transitivity-raw-identityₗ : Morphism.Identityₗ{Obj = V}(\\{w} → Walk-transitivity-raw{z = w})(at)\n Walk-transitivity-raw-identityₗ = Morphism.intro Walk-transitivity-raw-identityₗ-raw\n\n instance\n Walk-transitivity-raw-identityᵣ : Morphism.Identityᵣ{Obj = V}(\\{w} → Walk-transitivity-raw{z = w})(at)\n Walk-transitivity-raw-identityᵣ = Morphism.intro Walk-transitivity-raw-identityᵣ-raw\n\n instance\n Walk-transitivity-raw-identity : Morphism.Identity{Obj = V}(\\{w} → Walk-transitivity-raw{_⟶_ = _⟶_}{z = w})(at)\n Walk-transitivity-raw-identity = [∧]-intro Walk-transitivity-raw-identityₗ Walk-transitivity-raw-identityᵣ\n\n -- The category arising from a graph by its vertices and walks.\n -- Note that `Walk` is defined so that every sequence of edges have an unique walk. For example `ReflexitiveTransitiveClosure` (a relation equivalent to a walk) would not work.\n free-category : Category(Walk(_⟶_))\n Category._∘_ free-category = swap(transitivity(Walk(_⟶_)))\n Category.id free-category = reflexivity(Walk(_⟶_))\n BinaryOperator.congruence (Category.binaryOperator free-category) [≡]-intro [≡]-intro = [≡]-intro\n Morphism.Associativity.proof (Category.associativity free-category) {a}{b}{c}{d} {w₁}{w₂}{w₃} = symmetry(_≡_) (Walk-transitivity-raw-associativity-raw {d}{c}{b}{a} {w₃}{w₂}{w₁})\n Morphism.Identityₗ.proof (Tuple.left (Category.identity free-category)) = Walk-transitivity-raw-identityᵣ-raw\n Morphism.Identityᵣ.proof (Tuple.right (Category.identity free-category)) = Walk-transitivity-raw-identityₗ-raw\n", "meta": {"hexsha": "12fdb2b52721fb5010c8eabd62f2f95bb8652185", "size": 3186, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Graph/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": "Graph/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": "Graph/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": 53.1, "max_line_length": 179, "alphanum_fraction": 0.7281858129, "num_tokens": 1036, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916170039418, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.5804855529174116}} {"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.DirectSum.DirectSumHIT.UniversalProperty where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.HLevels\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Algebra.Group.Morphisms\nopen import Cubical.Algebra.Group.MorphismProperties\nopen import Cubical.Algebra.AbGroup\nopen import Cubical.Algebra.AbGroup.Instances.DirectSumHIT\nopen import Cubical.Algebra.DirectSum.DirectSumHIT.Base\n\n\nprivate variable\n ℓ ℓ' ℓ'' : Level\n\nopen AbGroupStr\nopen IsGroupHom\n\n-----------------------------------------------------------------------------\n-- Definition\n\nmodule _\n (Idx : Type ℓ)\n (G : (k : Idx) → Type ℓ')\n (Gstr : (k : Idx) → AbGroupStr (G k))\n (HAbGr@(H , Hstr) : AbGroup ℓ'')\n (fHhom : (k : Idx) → AbGroupHom ((G k) , (Gstr k)) HAbGr)\n where\n\n private\n fH : (k : Idx) → G k → H\n fH = λ k → fst (fHhom k)\n fHstr : (k : Idx) → _\n fHstr = λ k → snd (fHhom k)\n\n injₖ : (k : Idx) → G k → ⊕HIT Idx G Gstr\n injₖ k a = base k a\n\n injₖ-hom : (k : Idx) → AbGroupHom ((G k) , (Gstr k)) (⊕HIT-AbGr Idx G Gstr)\n injₖ-hom k = injₖ k , (makeIsGroupHom λ a b → sym (base-add _ _ _) )\n\n -- universalProperty :\n ⊕HIT→H : ⊕HIT Idx G Gstr → H\n ⊕HIT→H = DS-Rec-Set.f _ _ _ _ (is-set Hstr)\n (0g Hstr)\n (λ k a → fH k a)\n (Hstr ._+_)\n (+Assoc Hstr)\n (+IdR Hstr)\n (+Comm Hstr)\n (λ k → pres1 (fHstr k))\n λ k a b → sym (pres· (fHstr k) _ _)\n\n ⊕HIT→H-hom : AbGroupHom (⊕HIT-AbGr Idx G Gstr) HAbGr\n ⊕HIT→H-hom = ⊕HIT→H , (makeIsGroupHom (λ _ _ → refl))\n\n -- Universal Property\n up∃⊕HIT : (k : Idx) → fHhom k ≡ compGroupHom (injₖ-hom k) ⊕HIT→H-hom\n up∃⊕HIT k = ΣPathTransport→PathΣ _ _\n ((funExt (λ _ → refl))\n , isPropIsGroupHom _ _ _ _)\n\n\n upUnicity⊕HIT : (hhom : AbGroupHom (⊕HIT-AbGr Idx G Gstr) HAbGr) →\n (eqInj : (k : Idx) → fHhom k ≡ compGroupHom (injₖ-hom k) hhom)\n → hhom ≡ ⊕HIT→H-hom\n upUnicity⊕HIT (h , hstr) eqInj = ΣPathTransport→PathΣ _ _\n (helper , isPropIsGroupHom _ _ _ _)\n where\n\n helper : _\n helper = funExt (DS-Ind-Prop.f _ _ _ _ (λ _ → is-set Hstr _ _)\n (pres1 hstr)\n (λ k a → sym (funExt⁻ (cong fst (eqInj k)) a))\n λ {U V} ind-U ind-V → pres· hstr _ _ ∙ cong₂ (_+_ Hstr) ind-U ind-V)\n", "meta": {"hexsha": "26cb53b7c27bd6593ffd9595432af989a9c73630", "size": 2469, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/DirectSum/DirectSumHIT/UniversalProperty.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/DirectSum/DirectSumHIT/UniversalProperty.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/DirectSum/DirectSumHIT/UniversalProperty.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.253164557, "max_line_length": 88, "alphanum_fraction": 0.5398946942, "num_tokens": 911, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473879530491, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.5804691744155077}} {"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\nopen import Sets.FinSet.Definition\nopen import Numbers.Naturals.Semiring\n\nmodule Graphs.Colouring where\n\nColouring : (n : ℕ) {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) → Set (a ⊔ c)\nColouring n {V' = V'} G = {x y : V'} → (Graph._<->_ G x y) → FinSet n\n\ninheritColouring : {n : ℕ} {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} {G : Graph c V} → (k : Colouring n G) → {e : _} {pred : V' → Set e} {sub : subset V pred} {d : _} {_<->'_ : Rel {_} {d} (Sg V' pred)} (H : Subgraph G sub _<->'_) → Colouring n (subgraphIsGraph H)\ninheritColouring k H {v1 , _} {v2 , _} x-y = k (Subgraph.inherits H x-y)\n\nMonochromatic : {a b c : Level} {V' : Set a} {V : Setoid {a} {b} V'} {G : Graph c V} {n : ℕ} → (k : Colouring n G) → {d e : _} {pred : V' → Set d} {sub : subset V pred} {_<->'_ : Rel {_} {e} (Sg V' pred)} (H : Subgraph G sub _<->'_) → Set (a ⊔ d ⊔ e)\nMonochromatic {V' = V'} {n = n} k {pred = pred} {sub = sub} {_<->'_} H = Sg (FinSet n) (λ c → {x : Sg V' pred} {y : Sg V' pred} (edge : x <->' y) → (inheritColouring k H) edge ≡ c)\n", "meta": {"hexsha": "ad3ef1ffeff506a426a15a212a89238145d3e7de", "size": 1310, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Graphs/Colouring.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/Colouring.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/Colouring.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": 59.5454545455, "max_line_length": 271, "alphanum_fraction": 0.5816793893, "num_tokens": 523, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473779969194, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.5804691677905938}} {"text": "module Cats.Category.Lift where\n\nopen import Relation.Binary using (IsEquivalence)\nopen import Level as L using (Level ; suc ; _⊔_ ; lift ; lower)\n\nopen import Cats.Category.Base\n\nopen IsEquivalence\n\n\nLCategory : (l : Level) → Set (suc l)\nLCategory l = Category l l l\n\n\nLift : ∀ {lo la l≈ lo′ la′ l≈′} → Category lo la l≈\n → Category (lo ⊔ lo′) (la ⊔ la′) (l≈ ⊔ l≈′)\nLift {lo′ = lo′} {la′} {l≈′} C = record\n { Obj = L.Lift lo′ C.Obj\n ; _⇒_ = λ A B → L.Lift la′ (lower A C.⇒ lower B)\n ; _≈_ = λ f g → L.Lift l≈′ (lower f C.≈ lower g)\n ; id = lift C.id\n ; _∘_ = λ f g → lift (lower f C.∘ lower g)\n ; equiv = record\n { refl = lift (refl C.equiv)\n ; sym = λ eq → lift (sym C.equiv (lower eq))\n ; trans = λ eq₁ eq₂ → lift (trans C.equiv (lower eq₁) (lower eq₂))\n }\n ; ∘-resp = λ eq₁ eq₂ → lift (C.∘-resp (lower eq₁) (lower eq₂))\n ; id-r = lift C.id-r\n ; id-l = lift C.id-l\n ; assoc = lift C.assoc\n }\n where\n module C = Category C\n\n\nLiftEq : ∀ {lo la l≈} → Category lo la l≈\n → LCategory (lo ⊔ la ⊔ l≈)\nLiftEq {lo} {la} {l≈} = Lift {lo′ = la ⊔ l≈} {la′ = lo ⊔ l≈} {l≈′ = lo ⊔ la}\n", "meta": {"hexsha": "a167a3a1e784dc3a3f61f6810945f52db09976e6", "size": 1141, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cats/Category/Lift.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/Lift.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/Lift.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": 28.525, "max_line_length": 76, "alphanum_fraction": 0.5381244522, "num_tokens": 468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797003640646, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.5804495158794948}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Utils.EqReasoning where\n\nopen import Level\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Product using (Σ; _,_; _×_)\n\nopen import Categories.Utils.Product\n\nsubst₂-sym-subst₂ : {ℓa ℓb ℓp : Level} {A : Set ℓa} {B : Set ℓb} {a₁ a₂ : A} {b₁ b₂ : B}\n (R : A → B → Set ℓp) {p : R a₁ b₁} (eq₁ : a₁ ≡ a₂) (eq₂ : b₁ ≡ b₂) →\n subst₂ R (sym eq₁) (sym eq₂) (subst₂ R eq₁ eq₂ p) ≡ p\nsubst₂-sym-subst₂ R refl refl = refl\n\nsubst₂-subst₂-sym : {ℓa ℓb ℓp : Level} {A : Set ℓa} {B : Set ℓb} {a₁ a₂ : A} {b₁ b₂ : B}\n (R : A → B → Set ℓp) {p : R a₁ b₁} (eq₁ : a₂ ≡ a₁) (eq₂ : b₂ ≡ b₁) →\n subst₂ R eq₁ eq₂ (subst₂ R (sym eq₁) (sym eq₂) p) ≡ p\nsubst₂-subst₂-sym R refl refl = refl\n\nsubst₂-subst₂ : {ℓa ℓb ℓp : Level} {A : Set ℓa} {B : Set ℓb} {a₁ a₂ a₃ : A} {b₁ b₂ b₃ : B}\n (R : A → B → Set ℓp) {p : R a₁ b₁}\n (eq-a₁₂ : a₁ ≡ a₂) (eq-a₂₃ : a₂ ≡ a₃)\n (eq-b₁₂ : b₁ ≡ b₂) (eq-b₂₃ : b₂ ≡ b₃) →\n subst₂ R eq-a₂₃ eq-b₂₃ (subst₂ R eq-a₁₂ eq-b₁₂ p) ≡ subst₂ R (trans eq-a₁₂ eq-a₂₃) (trans eq-b₁₂ eq-b₂₃) p\nsubst₂-subst₂ R refl refl refl refl = refl\n\nsubst₂-app : ∀ {a₁ a₂ a₃ a₄ b₁ b₂} {A₁ : Set a₁} {A₂ : Set a₂} {A₃ : Set a₃} {A₄ : Set a₄}\n (B₁ : A₁ → A₃ → Set b₁) {B₂ : A₂ → A₄ → Set b₂}\n {f : A₂ → A₁} {h : A₄ → A₃} {x₁ x₂ : A₂} {x₃ x₄ : A₄} (y : B₂ x₁ x₃)\n (g : ∀ w z → B₂ w z → B₁ (f w) (h z)) (eq₁ : x₁ ≡ x₂) (eq₂ : x₃ ≡ x₄) →\n subst₂ B₁ (cong f eq₁) (cong h eq₂) (g x₁ x₃ y) ≡ g x₂ x₄ (subst₂ B₂ eq₁ eq₂ y)\nsubst₂-app _ _ _ refl refl = refl\n\nsubst₂-prod : ∀ {ℓa ℓb ℓr ℓs} {A : Set ℓa} {B : Set ℓb}\n (R : A → A → Set ℓr) (S : B → B → Set ℓs) {a b c d : A} {x y z w : B}\n {f : R a b} {g : S x y}\n (eq₁ : a ≡ c) (eq₂ : b ≡ d) (eq₃ : x ≡ z) (eq₄ : y ≡ w) →\n subst₂ (λ { (p , q) (r , s) → R p r × S q s })\n (sym (cong₂ _,_ (sym eq₁) (sym eq₃)))\n (sym (cong₂ _,_ (sym eq₂) (sym eq₄)))\n (f , g)\n ≡\n (subst₂ R eq₁ eq₂ f , subst₂ S eq₃ eq₄ g)\nsubst₂-prod R S refl refl refl refl = refl\n\n------------------\n-- For reasoning with things from Categories.Utils.Product\nsubst₂-expand : ∀ {a b ℓ ℓ′ p q} {A : Set a} {B : Set b}\n {P : A → Set p} {Q : B → Set q}\n (_∙_ : A → B → Set ℓ) → (_∘_ : ∀ {x y} → P x → Q y → Set ℓ′) →\n {a₁ a₂ : A} {b₁ b₂ : B} {p₁ p₂ : P a₁} {q₁ q₂ : Q b₁}\n (eq₁ : a₁ ≡ a₂) (eq₂ : p₁ ≡ p₂) (eq₃ : b₁ ≡ b₂) (eq₄ : q₁ ≡ q₂) →\n (F : a₁ ∙ b₁) → (G : p₁ ∘ q₁) →\n subst₂ (_∙_ -< _×_ >- _∘_)\n (cong₂ _,_ eq₁ eq₂)\n (cong₂ _,_ eq₃ eq₄)\n (F , G) ≡ (subst₂ _∙_ eq₁ eq₃ F , subst₂ _∘_ eq₂ eq₄ G)\nsubst₂-expand T₁ T₂ refl refl refl refl F G = refl\n", "meta": {"hexsha": "d8559d18c0b471a2f5b460090432c995db927f33", "size": 2756, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Utils/EqReasoning.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/EqReasoning.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/EqReasoning.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": 45.9333333333, "max_line_length": 120, "alphanum_fraction": 0.4883889695, "num_tokens": 1334, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.580436023243185}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule sets.unit where\n\nopen import level\n\nrecord ⊤ {i : Level} : Set i where\n constructor tt\n\n⊤-elim : ∀ {i j} (P : ⊤ {i} → Set j) → P tt → (x : ⊤) → P x\n⊤-elim P ptt tt = ptt\n", "meta": {"hexsha": "fa6f0bab6b70bd0385879f8ad3ae82fbddee5d9c", "size": 208, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/sets/unit.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/unit.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/unit.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": 17.3333333333, "max_line_length": 59, "alphanum_fraction": 0.5480769231, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.580397839586811}} {"text": "module Test where\n\nopen import Algebra using (CommutativeRing; IsCommutativeRing)\n\nopen import Assume using (assume)\nimport Data.Nat as ℕ\nopen ℕ using (ℕ; zero; suc)\n\nimport Data.Fin as F\nopen F using (Fin)\n\nopen import Relation.Binary using (Rel; Setoid; _Preserves_⟶_)\nopen import Function using (Inverse; _on_; _∘_; _|>_; id; flip)\n\nopen import Algebra.Module using (Module)\nmodule Mod = Module\n\nopen import Data.Product using (_,_; proj₂; _×_)\n\nopen import Algebra.Module.Construct.DirectProduct using () renaming (⟨module⟩ to ×-module)\nopen import Level using (_⊔_; Level; 0ℓ; Lift)\nopen import Data.Vec.Recursive\nopen import Algebra.Module.Vec.Recursive\n\n\nmodule _\n {r ℓ} {CR : CommutativeRing r ℓ}\n where\n\n -- D B k is the solution to\n -- (A → X) → A ^ suc k → B\n -- i.e. D B k ~ A ^ k → B\n\n open Module\n\n D : ∀ {m ℓm} (M : Module CR m ℓm) → ℕ → Set _\n D {m = m} M k = ∀ {X : Set m} → X ^ suc k → Carrierᴹ M\n\n const\n : ∀ {m ℓm} {{M : Module CR m ℓm}}\n → ∀ {k} → Carrierᴹ M → D M k\n const {k = zero} c x = c\n const {{M}} {k = suc k} c v = 0ᴹ M\n\n\n double\n : ∀ {m ℓm} {{M : Module CR m ℓm}}\n → ∀ {k} → D M k → D M k\n double {{M}} x y = let x' = x y in _+ᴹ_ M x' x'\n\n\n -- D : Level → ∀ {n ℓn} (N : Module CR n ℓn) → ℕ → Set _\n -- D m N k = {M : Set m} → M → M ^ k → Carrierᴹ N\n\n -- compose\n -- : ∀ {x} {X : Set x}\n -- → ∀ {n ℓn} {N : Module CR n ℓn}\n -- → ∀ {o ℓo} {O : Module CR o ℓo}\n -- → ∀ {k} → (f : X → D N k) → (g : Carrierᴹ N → D O k)\n -- → X → D O k\n -- compose = ?\n\n\n\n -- _th-derivative_ : ∀ k → (D k → D k) → M.Carrierᴹ → N.Carrierᴹ\n\n -- k th-derivative f = {! !}\n\n\n -- TODO\n -- can we use M → D N k everywhere?!\n -- data D : ℕ → Set (m ⊔ n) where\n -- z : N.Carrierᴹ → D zero\n -- d : ∀ {k} → (fx : N.Carrierᴹ) → (dfx : M.Carrierᴹ → D k) → D (suc k)\n\n\n-- module _\n-- {r ℓ} {CR : CommutativeRing r ℓ}\n-- {m ℓm} {M : Module CR m ℓm}\n-- {n ℓn} {N : Module CR n ℓn}\n-- where\n\n-- private\n-- module CR = CommutativeRing CR\n-- module M = Module M\n-- module N = Module N\n\n-- private\n-- module dmod where\n\n-- Carrierᴹ : ∀ {k : ℕ} → Set (m ⊔ n)\n-- Carrierᴹ {k} = D M N k\n\n-- _≈ᴹ_ : ∀ {k} → Rel (D M N k) (m ⊔ ℓn)\n-- _≈ᴹ_ (z x) (z y) = Lift (m ⊔ ℓn) (x N.≈ᴹ y)\n-- _≈ᴹ_ (d fx dfx) (d fy dfy) = (fx N.≈ᴹ fy) × (∀ v → dfx v ≈ᴹ dfy v)\n\n-- _+ᴹ_ : ∀ {k} → (x y : D M N k) → D M N k\n-- _+ᴹ_ (z x) (z y) = z (x N.+ᴹ y)\n-- _+ᴹ_ (d fx dfx) (d fy dfy) = d (fx N.+ᴹ fy) λ v → dfx v +ᴹ dfy v\n\n-- _*ₗ_ : ∀ {k} → (s : CR.Carrier) (x : D M N k) → D M N k\n-- _*ₗ_ s (z x) = z (s N.*ₗ x)\n-- _*ₗ_ s (d fx dfx) = d (s N.*ₗ fx) λ v → s *ₗ dfx v\n\n-- _*ᵣ_ : ∀ {k} → (x : D M N k) (s : CR.Carrier) → D M N k\n-- _*ᵣ_ = flip _*ₗ_\n\n-- 0ᴹ : ∀ {k} → D M N k\n-- 0ᴹ {zero} = z N.0ᴹ\n-- 0ᴹ {suc k} = d N.0ᴹ λ v → 0ᴹ\n\n-- -ᴹ_ : ∀ {k} → D M N k → D M N k\n-- -ᴹ_ (z x) = z (N.-ᴹ x)\n-- -ᴹ_ (d fx dfx) = d (N.-ᴹ fx) λ v → -ᴹ dfx v\n\n-- instance\n-- D-module : ∀ {k : ℕ} → Module CR _ _\n-- D-module {k} =\n-- record\n-- { Carrierᴹ = dmod.Carrierᴹ {k}\n-- ; isModule = assume\n-- ; dmod\n-- }\n\n-- private variable k : ℕ\n\n-- run : D M N k → N.Carrierᴹ\n-- run (z x) = x\n-- run (d x _) = x\n\n-- extract : D M N zero → N.Carrierᴹ\n-- extract = run\n\n-- diff : M.Carrierᴹ → D M N (suc k) → D M N k\n-- diff v (d _ x) = x v\n\n-- konst _# : ∀ (c : N.Carrierᴹ) → D M N k\n-- konst {k = zero} c = z c\n-- konst {k = suc k} c = d c (λ v → konst N.0ᴹ)\n-- x # = konst x\n\n-- jacobian : (df : D M N 1) (v : M.Carrierᴹ) → N.Carrierᴹ\n-- jacobian df v = df |> diff v |> extract\n\n-- hessian : (df : D M N 2) (v v' : M.Carrierᴹ) → N.Carrierᴹ\n-- hessian df v v' = df |> diff v |> diff v' |> extract\n\n-- hack : ∀ {l} → D M N (suc l) → D M N l\n-- hack {zero} (d fx dfx) = z fx\n-- hack {suc l} (d fx dfx) = d fx λ v → hack {l} (dfx v)\n\n\nmodule _ where\n import Real as ℝ\n open ℝ using (ℝ)\n\n open import Data.Vec.Recursive\n\n ℝ-isCommutativeRing : IsCommutativeRing ℝ._≈_ ℝ._+_ ℝ._*_ ℝ.-_ 0.0 1.0\n ℝ-isCommutativeRing = assume\n\n instance\n ℝ-commutativeRing : CommutativeRing 0ℓ 0ℓ\n ℝ-commutativeRing = record { isCommutativeRing = ℝ-isCommutativeRing }\n\n ℝ-cr : CommutativeRing 0ℓ 0ℓ\n ℝ-cr = ℝ-commutativeRing\n\n private\n ℝ-mod' : Module ℝ-commutativeRing 0ℓ 0ℓ\n ℝ-mod' = U.⟨module⟩\n where import Algebra.Module.Construct.TensorUnit as U\n\n ℝ^ : ∀ n → Module ℝ-commutativeRing 0ℓ 0ℓ\n ℝ^ n = ℝ-mod' ^ᴹ n\n\n ℝ-mod : Module ℝ-commutativeRing 0ℓ 0ℓ\n ℝ-mod = ℝ^ 1\n\n exp : ∀ {k} → D ℝ-mod k → D ℝ-mod k\n exp {0} f x = ℝ.e^ f x\n exp {1} f' xdx = let (fx , f'x) = f xdx in {! (ℝ.e^ fx) ℝ.* f'x !}\n exp {k} f y = {! !}\n\n-- -- TODO\n-- -- is this really the identity?\n-- var : ∀ {rank k} (c : Mod.Carrierᴹ (ℝ^ rank)) → D (ℝ^ rank) (ℝ^ rank) k\n-- var {rank} {zero} c = z c\n-- var {rank} {suc n} c = d c (λ v → konst (replicate rank 1.0))\n\n-- instance\n-- ℝ^n : ∀ {n} → Module ℝ-cr 0ℓ 0ℓ\n-- ℝ^n {n} = ℝ^ n\n\n\n-- infixl 6 _+_ _-_\n-- infixl 7 _*_\n-- -- linear and bilinear forms\n-- _*_\n-- : ∀ {m ℓm} {M : Module ℝ-cr m ℓm} {k rank}\n-- → (x y : D M (ℝ^ rank) k)\n-- → D M (ℝ^ rank) k\n\n-- open Module {{...}}\n-- _+_ _-_\n-- : ∀ {r ℓ} {CR : CommutativeRing r ℓ} {m ℓm} {{M : Module CR m ℓm}} (x y : Mod.Carrierᴹ M)\n-- → Mod.Carrierᴹ M\n-- x + y = x +ᴹ y\n-- x - y = x +ᴹ (-ᴹ y)\n\n\n-- _*_ {rank = rank} (z x) (z y) = z (zipWith ℝ._*_ rank x y)\n-- _*_ {rank = rank} dfx@(d fx f'x) dgx@(d gx g'x) =\n-- d (zipWith ℝ._*_ rank fx gx) (λ v → hack dfx * g'x v + hack dgx * f'x v)\n\n\n-- -- convenience function\n-- _>-<_\n-- : ∀ {k}\n-- → (f : ℝ → ℝ) (f' : ∀ {l} → D ℝ-mod ℝ-mod l → D ℝ-mod ℝ-mod l)\n-- → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k\n-- (f >-< _) (z x) = z (f x)\n-- (f >-< f') dfx@(d x dx) = d (f x) λ v → dx v * f' (hack dfx)\n\n\n-- ε : ∀ {rank} → Fin rank → ℝ ^ rank\n-- ε {zero} n = _\n-- ε {suc zero} _ = 1.0\n-- ε {2+ rank} F.zero = 1.0 , Mod.0ᴹ (ℝ^ (suc rank))\n-- ε {2+ rank} (F.suc n) = Mod.0ᴹ ℝ-mod , ε n\n\n\n-- ∇_ grad : ∀ {rank} → D (ℝ^ rank) (ℝ^ 1) 1 → ℝ ^ rank\n-- ∇_ {rank = rank} f = map (jacobian f) rank unitvecs\n-- where\n-- unitvecs : (ℝ ^ rank) ^ rank\n-- unitvecs = map ε rank (tabulate rank id)\n\n-- grad = ∇_\n\n\n-- infixl 8 _**_\n-- infixr 9 -_\n-- infixr 9 e^_\n\n-- -_\n-- : ∀ {r ℓ} {CR : CommutativeRing r ℓ} {m ℓm} {{M : Module CR m ℓm}} (x : Mod.Carrierᴹ M)\n-- → Mod.Carrierᴹ M\n-- -_ x = -ᴹ x\n\n\n-- ℝ-sgn : ℝ → ℝ\n-- ℝ-sgn x = if does (0.0 ℝ.≤? x) then 1.0 else ℝ.- 1.0\n-- where\n-- open import Data.Bool using (if_then_else_)\n-- open import Relation.Nullary using (does)\n\n-- ℝ-abs : ℝ → ℝ\n-- ℝ-abs x = x ℝ.* ℝ-sgn x\n\n\n-- -- the first is the zero-order \n-- poly : ∀ {rank k} → ℝ ^ suc rank → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k\n-- poly {rank = zero} cs x = konst cs\n-- poly {rank = suc rank} (c , cs) x = konst c + x * poly cs x\n\n-- pow : ℕ → ∀ {k} → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k\n-- pow 0 x = konst 1.0\n-- pow 1 x = x\n-- pow (suc n) dx = dx * pow n dx\n\n-- log e^_ recip abs sgn : ∀ {k} → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k\n-- log = ℝ.log >-< recip ∘ abs\n\n-- recip (z x) = z (1.0 ℝ.÷ x)\n-- recip dfx@(d fx f'x) = d (1.0 ℝ.÷ fx) λ x → - (f'x x * tmp * tmp)\n-- where\n-- tmp = recip (hack dfx)\n\n-- abs = ℝ-abs >-< sgn\n\n-- sgn = ℝ-sgn >-< λ _ → 0ᴹ\n\n-- e^ z x = z (ℝ.e^ x)\n-- e^ dfx@(d fx f'x) = d (run tmp) λ v → f'x v * tmp\n-- where\n-- tmp = e^ hack dfx\n\n-- infixl 7 _÷_\n-- _÷_ _**_ : ∀ {k} (x y : D ℝ-mod ℝ-mod k) → D ℝ-mod ℝ-mod k\n-- x ÷ y = x * recip x\n-- x ** y = e^ y * log x\n\n\n-- _! : ℕ → ℕ\n-- 0 ! = 1\n-- 1 ! = 1\n-- sucn@(suc n) ! = sucn ℕ.* (n !)\n\n\n-- sterling : ∀ {k} → ℕ → D ℝ-mod ℝ-mod k\n-- sterling {k} m = m' * log m' - m'\n-- where\n-- m' : D ℝ-mod ℝ-mod k\n-- m' = ℝ.fromℕ m #\n\n\n-- -- without the constant denominator term\n-- logPoisson' : ∀ {n} → ℕ → D ℝ-mod ℝ-mod n → D ℝ-mod ℝ-mod n\n-- logPoisson' k λ' = k' * log λ' - λ'\n-- where k' = ℝ.fromℕ k #\n\n-- logPoisson : ∀ {n} → ℕ → D ℝ-mod ℝ-mod n → D ℝ-mod ℝ-mod n\n-- logPoisson k λ' = logPoisson' k λ' - sterling k\n\n\n-- -- descend : ∀ {rank} (f : D (ℝ^ rank) 1 → D ℝ-mod 1) (steps : ℕ) (start : ℝ ^ rank) → ℝ ^ rank\n-- -- descend f zero start = start\n-- -- descend f (suc steps) start = {! !}\n\n\n-- module _ where\n-- open import Relation.Binary.PropositionalEquality using (refl)\n\n-- _ : (∇ (var 1.0 * var 1.0)) ℝ.≈ 2.0\n-- _ = refl\n\n-- -- -- -- _ : run e^_ 2.0 ℝ.≈ (ℝ.e^ 2.0)\n-- -- -- -- _ = refl\n\n\n-- -- -- -- testpoly : ∀ {n} → D ℝ-mod n → D ℝ-mod n\n-- -- -- -- testpoly = poly (1.0 , 2.0 , 3.0)\n\n\n-- -- -- -- _ : run testpoly 2.0 ℝ.≈ (1.0 + 4.0 + 12.0)\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ testpoly [ 2.0 ] ℝ.≈ (0.0 + 2.0 + 3.0 ℝ.* 2.0 ℝ.* 2.0)\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ testpoly [ 7.0 ] ℝ.≈ (0.0 + 2.0 + 2.0 ℝ.* 3.0 ℝ.* 7.0)\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : hessian e^_ 1.0 1.0 0.0 ℝ.≈ (ℝ.e^ 1.0)\n-- -- -- -- _ = refl\n\n-- -- -- -- asdf : D ℝ-mod 2\n-- -- -- -- asdf = e^ var (2.0 , 1.0 , 0.0)\n\n-- -- -- -- _ : hessian (poly (1.0 , 2.0 , 3.0)) 1.0 1.0 0.0 ℝ.≈ (2.0 ℝ.* 3.0)\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ log [ 1.0 ] ℝ.≈ 1.0\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ log [ -ᴹ 1.0 ] ℝ.≈ 1.0\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ sgn [ 2.0 ] ℝ.≈ 0.0\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ abs [ 2.0 ] ℝ.≈ 1.0\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : run abs (- 2.0) ℝ.≈ 2.0\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ abs [ - 1.0 ] ℝ.≈ (- 1.0)\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ recip [ - 2.0 ] ℝ.≈ (- 0.25)\n-- -- -- -- _ = refl\n\n-- -- -- -- _ : ∇ log [ 2.0 ] ℝ.≈ 0.5\n-- -- -- -- _ = refl", "meta": {"hexsha": "1a2a09e996b976d19aa195b12d74b2e4573290f1", "size": 9829, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Test.agda", "max_stars_repo_name": "cspollard/diff", "max_stars_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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/Test.agda", "max_issues_repo_name": "cspollard/diff", "max_issues_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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/Test.agda", "max_forks_repo_name": "cspollard/diff", "max_forks_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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.0716180371, "max_line_length": 100, "alphanum_fraction": 0.4570149557, "num_tokens": 4499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.800691997339971, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.5803978292443982}} {"text": "{-# OPTIONS --without-K #-}\n\nmodule Lecture6 where\n\nimport Lecture5\nopen Lecture5 public\n\n-- Section 6.1 Contractible types\n\nis-contr : {i : Level} → UU i → UU i\nis-contr A = Sigma A (λ a → (x : A) → Id a x)\n\ncenter : {i : Level} {A : UU i} → is-contr A → A\ncenter (dpair c C) = c\n\n-- We make sure that the contraction is coherent in a straightforward way\ncontraction : {i : Level} {A : UU i} (H : is-contr A) →\n (const A A (center H) ~ id)\ncontraction (dpair c C) x = concat _ (inv (C c)) (C x)\n\ncoh-contraction : {i : Level} {A : UU i} (H : is-contr A) →\n Id (contraction H (center H)) refl\ncoh-contraction (dpair c C) = left-inv (C c)\n\nev-pt : {i j : Level} (A : UU i) (a : A) (B : A → UU j) → ((x : A) → B x) → B a\nev-pt A a B f = f a\n\nsing-ind-is-contr : {i j : Level} (A : UU i) (H : is-contr A) (B : A → UU j) →\n B (center H) → (x : A) → B x\nsing-ind-is-contr A H B b x = tr B (contraction H x) b\n\nsing-comp-is-contr : {i j : Level} (A : UU i) (H : is-contr A) (B : A → UU j) →\n (((ev-pt A (center H) B) ∘ (sing-ind-is-contr A H B)) ~ id)\nsing-comp-is-contr A H B b =\n ap (λ (ω : Id (center H) (center H)) → tr B ω b) (coh-contraction H)\n\nis-sing-is-contr : {i j : Level} (A : UU i) (H : is-contr A) (B : A → UU j) →\n sec (ev-pt A (center H) B)\nis-sing-is-contr A H B =\n dpair (sing-ind-is-contr A H B) (sing-comp-is-contr A H B)\n\nis-sing : {i : Level} (A : UU i) → A → UU (lsuc i)\nis-sing {i} A a = (B : A → UU i) → sec (ev-pt A a B)\n\nis-contr-is-sing : {i : Level} (A : UU i) (a : A) →\n is-sing A a → is-contr A\nis-contr-is-sing A a S = dpair a (pr1 (S (λ y → Id a y)) refl)\n\nis-sing-unit : is-sing unit star\nis-sing-unit B = dpair ind-unit (λ b → refl)\n\nis-contr-unit : is-contr unit\nis-contr-unit = is-contr-is-sing unit star (is-sing-unit)\n\nis-sing-total-path : {i : Level} (A : UU i) (a : A) →\n is-sing (Σ A (λ x → Id a x)) (dpair a refl)\nis-sing-total-path A a B = dpair (ind-Σ ∘ (ind-Id _)) (λ b → refl)\n\nis-contr-total-path : {i : Level} (A : UU i) (a : A) →\n is-contr (Σ A (λ x → Id a x))\nis-contr-total-path A a = is-contr-is-sing _ _ (is-sing-total-path A a)\n\n-- Section 6.2 Contractible maps\n\nfib : {i j : Level} {A : UU i} {B : UU j} (f : A → B) (b : B) → UU (i ⊔ j)\nfib f b = Σ _ (λ x → Id (f x) b)\n\nis-contr-map : {i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)\nis-contr-map f = (y : _) → is-contr (fib f y)\n\n-- Our goal is to show that contractible maps are equivalences.\n-- First we construct the inverse of a contractible map.\ninv-is-contr-map : {i j : Level} {A : UU i} {B : UU j} {f : A → B} →\n is-contr-map f → B → A\ninv-is-contr-map H y = pr1 (center (H y))\n\n-- Then we show that the inverse is a section.\nissec-is-contr-map : {i j : Level} {A : UU i} {B : UU j} {f : A → B}\n (H : is-contr-map f) → (f ∘ (inv-is-contr-map H)) ~ id\nissec-is-contr-map H y = pr2 (center (H y))\n\n-- Then we show that the inverse is also a retraction.\nisretr-is-contr-map : {i j : Level} {A : UU i} {B : UU j} {f : A → B}\n (H : is-contr-map f) → ((inv-is-contr-map H) ∘ f) ~ id\nisretr-is-contr-map {_} {_} {A} {B} {f} H x =\n ap {_} {_} {fib f (f x)} {A} pr1\n {dpair (inv-is-contr-map H (f x)) (issec-is-contr-map H (f x))}\n {dpair x refl}\n ( concat (center (H (f x)))\n (inv (contraction (H (f x))\n (dpair (inv-is-contr-map H (f x)) (issec-is-contr-map H (f x)))))\n (contraction (H (f x)) (dpair x refl)))\n\n-- Finally we put it all together to show that contractible maps are equivalences.\nis-equiv-is-contr-map : {i j : Level} {A : UU i} {B : UU j} {f : A → B} →\n is-contr-map f → is-equiv f\nis-equiv-is-contr-map H =\n pair\n (dpair (inv-is-contr-map H) (issec-is-contr-map H))\n (dpair (inv-is-contr-map H) (isretr-is-contr-map H))\n\n-- Section 6.3 Equivalences are contractible maps\n\nhtpy-nat : {i j : Level} {A : UU i} {B : UU j} {f g : A → B} (H : f ~ g)\n {x y : A} (p : Id x y) →\n Id (concat _ (H x) (ap g p)) (concat _ (ap f p) (H y))\nhtpy-nat H refl = right-unit (H _)\n\n-- Should left-unwhisk and right-unwhisk be moved to Lecture 4? That's where they most naturally fit.\nleft-unwhisk : {i : Level} {A : UU i} {x y z : A} (p : Id x y) {q r : Id y z} →\n Id (concat _ p q) (concat _ p r) → Id q r\nleft-unwhisk refl s = concat _ (inv (left-unit _)) (concat _ s (left-unit _))\n\nright-unwhisk : {i : Level} {A : UU i} {x y z : A} {p q : Id x y}\n (r : Id y z) → Id (concat _ p r) (concat _ q r) → Id p q\nright-unwhisk refl s = concat _ (inv (right-unit _)) (concat _ s (right-unit _))\n\nhtpy-red : {i : Level} {A : UU i} {f : A → A} (H : f ~ id) →\n (x : A) → Id (H (f x)) (ap f (H x))\nhtpy-red {_} {A} {f} H x = right-unwhisk (H x)\n (concat (concat (f x) (H (f x)) (ap id (H x)))\n (ap (concat (f x) (H (f x))) (inv (ap-id (H x)))) (htpy-nat H (H x)))\n\ncenter-is-invertible : {i j : Level} {A : UU i} {B : UU j} {f : A → B} →\n is-invertible f → (y : B) → fib f y\ncenter-is-invertible {i} {j} {A} {B} {f}\n (dpair g (dpair issec isretr)) y =\n (dpair (g y)\n (concat _\n (inv (ap (f ∘ g) (issec y)))\n (concat _ (ap f (isretr (g y))) (issec y))))\n\nmv-left : {i : Level} {A : UU i} {x y z : A}\n (p : Id x y) {q : Id y z} {r : Id x z} →\n Id (concat _ p q) r → Id q (concat _ (inv p) r)\nmv-left refl s = s\n\nsquare : {i : Level} {A : UU i} {x y1 y2 z : A}\n (p1 : Id x y1) (q1 : Id y1 z) (p2 : Id x y2) (q2 : Id y2 z) → UU i\nsquare p q p' q' = Id (concat _ p q) (concat _ p' q')\n\nsq-left-whisk : {i : Level} {A : UU i} {x y1 y2 z : A} {p1 p1' : Id x y1}\n (s : Id p1 p1') {q1 : Id y1 z} {p2 : Id x y2} {q2 : Id y2 z} →\n square p1 q1 p2 q2 → square p1' q1 p2 q2\nsq-left-whisk refl sq = sq\n\nsq-top-whisk : {i : Level} {A : UU i} {x y1 y2 z : A}\n {p1 : Id x y1} {q1 : Id y1 z}\n {p2 p2' : Id x y2} (s : Id p2 p2') {q2 : Id y2 z} →\n square p1 q1 p2 q2 → square p1 q1 p2' q2\nsq-top-whisk refl sq = sq\n\ncontraction-is-invertible : {i j : Level} {A : UU i} {B : UU j} {f : A → B} →\n (I : is-invertible f) → (y : B) → (t : fib f y) →\n Id (center-is-invertible I y) t\ncontraction-is-invertible {i} {j} {A} {B} {f}\n (dpair g (dpair issec isretr)) y (dpair x refl) =\n eq-pair (dpair\n (isretr x)\n (concat _\n (tr-fib (isretr x) (f x)\n (pr2 (center-is-invertible\n (dpair g (dpair issec isretr))\n (f x))))\n (inv (mv-left (ap f (isretr x))\n (concat _ (right-unit (ap f (isretr x)))\n (mv-left (ap (f ∘ g) (issec y))\n (sq-left-whisk {_} {_} {f(g(f(g(f x))))} {f(g(f x))} {f(g(f x))} {f x}\n {issec (f(g(f x)))} {ap (f ∘ g) (issec (f x))}\n (htpy-red issec (f x)) {ap f (isretr x)} {ap f (isretr (g (f x)))}\n {issec (f x)}\n (sq-top-whisk {_} {_} {f(g(f(g(f x))))} {f(g(f x))} {f(g(f x))} {f x}\n {issec (f(g(f x)))} {_} {_} {_}\n (concat _ (ap-comp f (g ∘ f) (isretr x))\n (inv (ap (ap f) (htpy-red isretr x))))\n (htpy-nat (htpy-right-whisk issec f) (isretr x))))))))))\n\nis-contr-map-is-invertible : {i j : Level} {A : UU i} {B : UU j} {f : A → B} → is-invertible f → is-contr-map f\nis-contr-map-is-invertible {i} {j} {A} {B} {f} I y =\n dpair (center-is-invertible I y) (contraction-is-invertible I y)\n\nis-contr-map-is-equiv : {i j : Level} {A : UU i} {B : UU j} {f : A → B} → is-equiv f → is-contr-map f\nis-contr-map-is-equiv = is-contr-map-is-invertible ∘ is-invertible-is-equiv\n\nis-contr-total-path' : {i : Level} (A : UU i) (a : A) →\n is-contr (Σ A (λ x → Id x a))\nis-contr-total-path' A a = is-contr-map-is-equiv (is-equiv-id _) a\n\n-- Exercises\n\n-- Exercise 6.1\nis-prop-is-contr : {i : Level} {A : UU i} → is-contr A → (x y : A) → is-contr (Id x y)\nis-prop-is-contr {i} {A} C =\n sing-ind-is-contr A C\n (λ x → ((y : A) → is-contr (Id x y)))\n (λ y → dpair\n (contraction C y)\n (ind-Id\n (λ z (p : Id (center C) z) → Id (contraction C z) p)\n (coh-contraction C)\n y))\n\n-- Exercise 6.2\nis-contr-retract-of : {i j : Level} {A : UU i} (B : UU j) → A retract-of B → is-contr B → is-contr A\nis-contr-retract-of B (dpair i (dpair r isretr)) C =\n dpair\n (r (center C))\n (λ x → concat (r (i x)) (ap r (contraction C (i x))) (isretr x))\n\n-- Exercise 6.3\n\nis-equiv-const-is-contr : {i : Level} {A : UU i} → is-contr A → is-equiv (const A unit star)\nis-equiv-const-is-contr {i} {A} H = pair (dpair (ind-unit (center H)) (ind-unit refl)) (dpair (const unit A (center H)) (contraction H))\n\nis-contr-is-equiv-const : {i : Level} {A : UU i} → is-equiv (const A unit star) → is-contr A\nis-contr-is-equiv-const (dpair (dpair g issec) (dpair h isretr)) = dpair (h star) isretr\n\nis-contr-is-equiv : {i j : Level} {A : UU i} {B : UU j} (f : A → B) → is-equiv f → is-contr B → is-contr A\nis-contr-is-equiv f Ef C =\n is-contr-is-equiv-const\n (is-equiv-comp (λ x → refl) Ef (is-equiv-const-is-contr C))\n\nis-contr-is-equiv' : {i j : Level} {A : UU i} {B : UU j} (f : A → B) → is-equiv f → is-contr A → is-contr B\nis-contr-is-equiv' f Ef C = is-contr-is-equiv (inv-is-equiv Ef) (is-equiv-inv-is-equiv Ef) C\n\nis-equiv-is-contr : {i j : Level} {A : UU i} {B : UU j} (f : A → B) →\n is-contr A → is-contr B → is-equiv f\nis-equiv-is-contr {i} {j} {A} {B} f CA CB =\n pair\n (dpair\n (const B A (center CA))\n (sing-ind-is-contr B CB _ (inv (contraction CB (f (center CA))))))\n (dpair (const B A (center CA)) (contraction CA))\n", "meta": {"hexsha": "b8e1e1e4675cfa3b6f82468f2bccb9180d80eaae", "size": 9324, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lecture6.agda", "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_issues_repo_path": "Lecture6.agda", "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_forks_repo_path": "Lecture6.agda", "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "avg_line_length": 39.8461538462, "max_line_length": 136, "alphanum_fraction": 0.5440797941, "num_tokens": 3851, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303137346446, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.5803437307220104}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Pointwise equality for containers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Container.Relation.Binary.Pointwise where\n\nopen import Data.Product using (_,_; Σ-syntax; -,_; proj₁; proj₂)\nopen import Function\nopen import Level using (_⊔_)\nopen import Relation.Binary using (REL; _⇒_)\nopen import Relation.Binary.PropositionalEquality as P\n using (_≡_; subst; cong)\n\nopen import Data.Container.Core using (Container; ⟦_⟧)\n\n-- Equality, parametrised on an underlying relation.\n\nmodule _ {s p} (C : Container s p) where\n\n record Pointwise {x y e} {X : Set x} {Y : Set y} (R : REL X Y e)\n (cx : ⟦ C ⟧ X) (cy : ⟦ C ⟧ Y) : Set (s ⊔ p ⊔ e) where\n constructor _,_\n field shape : proj₁ cx ≡ proj₁ cy\n position : ∀ p → R (proj₂ cx p) (proj₂ cy (subst _ shape p))\n\nmodule _ {s p} {C : Container s p} {x y} {X : Set x} {Y : Set y}\n {ℓ ℓ′} {R : REL X Y ℓ} {R′ : REL X Y ℓ′}\n where\n\n map : R ⇒ R′ → Pointwise C R ⇒ Pointwise C R′\n map R⇒R′ (s , f) = s , R⇒R′ ∘ f\n", "meta": {"hexsha": "697b071f358a554ea7ea615ec6ff373859d2a9cb", "size": 1190, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/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/Container/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/Container/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.0555555556, "max_line_length": 72, "alphanum_fraction": 0.531092437, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.7057850216484837, "lm_q1q2_score": 0.5802887794346883}} {"text": "module PiFrac.AuxLemmas where\nopen import Data.Empty\nopen import Data.Unit hiding (_≟_)\nopen import Data.Sum\nopen import Data.Product\nopen import Relation.Binary.Core\nopen import Relation.Binary\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Function using (_∘_)\nopen import PiFrac.Syntax\nopen import PiFrac.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\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\nLemma₂ ↦η = refl , refl\nLemma₂ ↦ε₁ = refl , refl\n\nLemma₃ : ∀ {A B v v' κ} {c : A ↔ B}\n → (r : ⟨ c ∣ v ∣ κ ⟩ ↦ [ c ∣ v' ∣ κ ])\n → base c ⊎ dual c ⊎ A ≡ B\nLemma₃ (↦₁ {b = b}) = inj₁ b\nLemma₃ ↦₂ = inj₂ (inj₂ refl)\nLemma₃ ↦η = inj₂ (inj₁ tt)\nLemma₃ ↦ε₁ = inj₂ (inj₁ tt)\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\nLemma₅ : ∀ {A B v v' b κ} {c : A ↔ B ×ᵤ 𝟙/ b}\n → (r : ⟨ c ∣ v ∣ κ ⟩ ↦ [ c ∣ v' ∣ κ ])\n → base c ⊎ (b , ↻) ≡ v' ⊎ ¬ (dual c)\nLemma₅ (↦₁ {b = b}) = inj₁ b\nLemma₅ ↦₂ = inj₂ (inj₂ (λ ()))\nLemma₅ ↦η = inj₂ (inj₁ refl)\n\nLemma₆ : ∀ {A v v' κ} → v ≢ v' → ∄[ st' ] (st' ↦ [ ηₓ {A} v ∣ v' , ↻ ∣ κ ])\nLemma₆ neq (⟨ _ ∣ v ∣ _ ⟩ , r) with Lemma₁ r\n... | refl , refl with Lemma₂ r\n... | refl , refl with Lemma₅ r\n... | inj₂ (inj₁ refl) = neq refl\n... | inj₂ (inj₂ nd) = nd tt\n", "meta": {"hexsha": "d78d4e4805fafa8d137cbc7da5dbefae4aaf82db", "size": 1685, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "PiFrac/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": "PiFrac/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": "PiFrac/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": 29.0517241379, "max_line_length": 75, "alphanum_fraction": 0.5103857567, "num_tokens": 802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891261650247, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.58028877020953}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Data.Sigma.Properties where\n\nopen import Prelude hiding (B; C)\nopen import Cubical.Foundations.HLevels using (isOfHLevelΣ) public\nopen import Cubical.Data.Sigma.Properties using (Σ≡Prop) public\n\nprivate\n variable\n B : A → Type b\n C : Σ A B → Type c\n\nreassoc : Σ (Σ A B) C ⇔ Σ[ x ⦂ A ] × Σ[ y ⦂ B x ] × C (x , y)\nreassoc .fun ((x , y) , z) = x , (y , z)\nreassoc .inv (x , (y , z)) = (x , y) , z\nreassoc .leftInv ((x , y) , z) i = ((x , y) , z)\nreassoc .rightInv (x , (y , z)) i = (x , (y , z))\n\n≃ΣProp≡ : ∀ {A : Type a} {u} {U : A → Type u} → ((x : A) → isProp (U x)) → {p q : Σ A U} → (p ≡ q) ≃ (fst p ≡ fst q)\n≃ΣProp≡ {A = A} {U = U} pA {p} {q} = isoToEquiv (iso to fro (λ _ → refl) (J Jt Jp))\n where\n to : {p q : Σ A U} → p ≡ q → fst p ≡ fst q\n to = cong fst\n\n fro : ∀ {p q} → fst p ≡ fst q → p ≡ q\n fro = Σ≡Prop pA\n\n Jt : (q : Σ A U) → p ≡ q → Type _\n Jt q q≡ = fro (to q≡) ≡ q≡\n\n Jp : Jt p refl\n Jp i j .fst = p .fst\n Jp i j .snd = isProp→isSet (pA (p .fst)) (p .snd) (p .snd) (λ k → fro {p} {p} (to (refl {x = p})) k .snd) refl i j\n", "meta": {"hexsha": "5d3fbd5640c6f96994183f45eb3642c10d21ea68", "size": 1118, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Sigma/Properties.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/Sigma/Properties.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/Sigma/Properties.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": 31.9428571429, "max_line_length": 116, "alphanum_fraction": 0.4946332737, "num_tokens": 522, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256551882382, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.5802751578483487}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.elims.Lemmas\n\nmodule homotopy.elims.SuspSmash {i j k} {X : Ptd i} {Y : Ptd j}\n {P : Susp (X ∧ Y) → Type k}\n (north* : P north) (south* : P south)\n (smin* : (x : de⊙ X) (y : de⊙ Y) → north* == south* [ P ↓ merid (smin x y) ])\n where\n\nprivate\n smbase*-template : ∀ {s} (p : smin (pt X) (pt Y) == s)\n → north* == south* [ P ↓ merid s ]\n smbase*-template p = transport (λ κ → north* == south* [ P ↓ merid κ ])\n p (smin* (pt X) (pt Y))\n\n smbasel* = smbase*-template (smgluel (pt X))\n smbaser* = smbase*-template (smgluer (pt Y))\n\n -- note that [smin*] is adjusted.\n coh* : (s : X ∧ Y) → north* == south* [ P ↓ merid s ]\n coh* = Smash-elim\n (λ x y → fst (fill-l x) ◃ fst (fill-r y) ◃ fst fill-base ◃ smin* x y)\n smbasel* smbaser*\n (λ x → ↓↓-from-squareover $\n ap (λ p → fst (fill-l x) ◃ p ◃ fst fill-base ◃ smin* x (pt Y)) fill-r-β\n ∙h↓⊡ ap (fst (fill-l x) ◃_) (idp◃ _)\n ∙h↓⊡ snd (fill-l x))\n (λ y → ↓↓-from-squareover $\n ap (λ p → p ◃ fst (fill-r y) ◃ fst fill-base ◃ smin* (pt X) y) fill-l-β\n ∙h↓⊡ idp◃ _\n ∙h↓⊡ snd (fill-r y))\n where\n fill-template : ∀ {s₁ s₂} (p : s₁ == s₂)\n (α : north* == south* [ P ↓ merid s₁ ])\n (β : north* == south* [ P ↓ merid s₂ ])\n → Σ (north* == north*)\n (λ q → SquareOver P (natural-square merid p)\n (q ◃ α)\n (↓-ap-in _ _ (apd (λ _ → north*) p))\n (↓-ap-in _ _ (apd (λ _ → south*) p))\n β)\n fill-template p α β = fill-upper-left _ _ _ _ _\n\n fill-base = fill-template (smgluel (pt X)) (smin* (pt X) (pt Y)) smbasel*\n fill-l = λ x → fill-template (smgluel x) (fst fill-base ◃ smin* x (pt Y)) smbasel*\n fill-l-β : fst (fill-l (pt X)) == idp\n fill-l-β = ! $\n fill-upper-left-unique _ _ _ _ _ idp (idp◃ _ ∙h↓⊡ snd fill-base)\n\n fill-r = λ y → fill-template (smgluer y) (fst fill-base ◃ smin* (pt X) y) smbaser*\n fill-r-β : fst (fill-r (pt Y)) == idp\n fill-r-β = ! $\n fill-upper-left-unique _ _ _ _ _ idp (idp◃ _ ∙h↓⊡ snd fill-base)\n ∙ ap (λ sp → fst (fill-template (snd sp)\n (fst fill-base ◃ smin* (pt X) (pt Y))\n (smbase*-template (snd sp))))\n (contr-has-all-paths {{pathfrom-is-contr (smin (pt X) (pt Y))}}\n (smbasel , smgluel (pt X))\n (smbaser , smgluer (pt Y)))\n\nSuspSmash-elim : Π (Susp (X ∧ Y)) P\nSuspSmash-elim = Susp-elim north* south* coh*\n", "meta": {"hexsha": "d163bba88380f9e4dd3da1b0b59bc3047fc066a4", "size": 2601, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/elims/SuspSmash.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/homotopy/elims/SuspSmash.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/homotopy/elims/SuspSmash.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": 40.0153846154, "max_line_length": 86, "alphanum_fraction": 0.4890426759, "num_tokens": 971, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.5802751361607503}} {"text": "{-# OPTIONS --allow-unsolved-metas #-}\nmodule FLutil where\n\nopen import Level hiding ( suc ; zero )\nopen import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ ; _≟_)\nopen import Data.Fin.Properties hiding ( <-trans ; ≤-refl ; ≤-trans ; ≤-irrelevant ; _≟_ ) renaming ( <-cmp to <-fcmp )\nopen import Data.Fin.Permutation -- hiding ([_,_])\nopen import Data.Nat -- using (ℕ; suc; zero; s≤s ; z≤n )\nopen import Data.Nat.Properties as DNP\nopen import Relation.Binary.PropositionalEquality hiding ( [_] )\nopen import Data.List using (List; []; _∷_ ; length ; _++_ ; tail ) renaming (reverse to rev )\nopen import Data.Product\nopen import Relation.Nullary\nopen import Data.Empty\nopen import Relation.Binary.Core\nopen import Relation.Binary.Definitions \nopen import logic\nopen import nat\n\ninfixr 100 _::_\n\ndata FL : (n : ℕ )→ Set where\n f0 : FL 0 \n _::_ : { n : ℕ } → Fin (suc n ) → FL n → FL (suc n)\n\ndata _f<_ : {n : ℕ } (x : FL n ) (y : FL n) → Set where\n f : {n : ℕ } {x : FL n } {y : FL n} → x f< y → y f< x → ⊥\nf-<> (f x x₁\nf-<> (f (f (f lt lt2\n\nf-≡< : {n : ℕ } {x : FL n } {y : FL n} → x ≡ y → y f< x → ⊥\nf-≡< refl (f lt (f ¬a ¬b c = tri> (λ lt → f-<> lt (f lt (f ¬a₁ ¬b c = tri> (λ lt → f-<> lt (f ¬a ¬b c = no ( ¬a )\n\n_f≤_ : {n : ℕ } (x : FL n ) (y : FL n) → Set\n_f≤_ x y = (x ≡ y ) ∨ (x f< y )\n\nFL0 : {n : ℕ } → FL n\nFL0 {zero} = f0\nFL0 {suc n} = zero :: FL0\n\nfmax : { n : ℕ } → FL n\nfmax {zero} = f0\nfmax {suc n} = fromℕ< a (fmax1 x) lt where\n fmax1 : {n : ℕ } → (x : Fin (suc n)) → toℕ x ≤ toℕ (fromℕ< {n} a ¬a ¬b c = ⊥-elim (fmax< c)\n\nx≤fmax : {n : ℕ } → {x : FL n} → x f≤ fmax\nx≤fmax {n} {x} with FLcmp x fmax\n... | tri< a ¬b ¬c = case2 a\n... | tri≈ ¬a b ¬c = case1 b\n... | tri> ¬a ¬b c = ⊥-elim ( fmax< c )\n\nopen import Data.Nat.Properties using ( ≤-trans ; <-trans )\nfsuc : { n : ℕ } → (x : FL n ) → x f< fmax → FL n \nfsuc {n} (x :: y) (f ¬a ¬b lt = cons a ( x ∷# [] ) ( Level.lift (fromWitness lt) , Level.lift tt )\nFLinsert {suc n} x (cons a y yr) | tri> ¬a ¬b a ¬a ¬b b ¬a ¬b b ¬a ¬b b ¬a ¬b a ¬a ¬b a ¬a ¬b c = here refl\ninsAny {suc n} {x} {h} (cons a (cons a₁ L x₁) xr) (here refl) | tri> ¬a ¬b c = here refl\ninsAny {suc n} {x} {h} (cons a (cons a₁ L x₁) xr) (there any) | tri> ¬a ¬b c = there (insAny (cons a₁ L x₁) any)\n\n-- FLinsert membership\n\nmodule FLMB { n : ℕ } where\n\n FL-Setoid : Setoid Level.zero Level.zero\n FL-Setoid = record { Carrier = FL n ; _≈_ = _≡_ ; isEquivalence = record { sym = sym ; refl = refl ; trans = trans }}\n\n open import Data.List.Fresh.Membership.Setoid FL-Setoid\n\n FLinsert-mb : (x : FL n ) → (xs : FList n) → x ∈ FLinsert x xs\n FLinsert-mb x xs = x∈FLins {n} x xs \n\n \n", "meta": {"hexsha": "02b4588e2ea60d4703a02e3999c125427e6a5afb", "size": 11072, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FLutil.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/FLutil.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/FLutil.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.7058823529, "max_line_length": 130, "alphanum_fraction": 0.5135476879, "num_tokens": 4989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424528443251, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.5802737536347885}} {"text": "------------------------------------------------------------------------\n-- Vectors parameterised on types in Set₁\n------------------------------------------------------------------------\n\n-- I want universe polymorphism.\n\nmodule Data.Vec1 where\n\ninfixr 5 _∷_\n\nopen import Data.Nat\nopen import Data.Vec using (Vec; []; _∷_)\nopen import Data.Fin\n\n------------------------------------------------------------------------\n-- The type\n\ndata Vec₁ (a : Set₁) : ℕ → Set₁ where\n [] : Vec₁ a zero\n _∷_ : ∀ {n} (x : a) (xs : Vec₁ a n) → Vec₁ a (suc n)\n\n------------------------------------------------------------------------\n-- Some operations\n\nmap : ∀ {a b n} → (a → b) → Vec₁ a n → Vec₁ b n\nmap f [] = []\nmap f (x ∷ xs) = f x ∷ map f xs\n\nmap₀₁ : ∀ {a b n} → (a → b) → Vec a n → Vec₁ b n\nmap₀₁ f [] = []\nmap₀₁ f (x ∷ xs) = f x ∷ map₀₁ f xs\n\nmap₁₀ : ∀ {a b n} → (a → b) → Vec₁ a n → Vec b n\nmap₁₀ f [] = []\nmap₁₀ f (x ∷ xs) = f x ∷ map₁₀ f xs\n\nlookup : ∀ {a n} → Fin n → Vec₁ a n → a\nlookup zero (x ∷ xs) = x\nlookup (suc i) (x ∷ xs) = lookup i xs\n", "meta": {"hexsha": "46575d3999cf171bfae6a0828490af990bb8d053", "size": 1062, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Data/Vec1.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/Vec1.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/Vec1.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.55, "max_line_length": 72, "alphanum_fraction": 0.384180791, "num_tokens": 338, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9161096112990285, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.5802732304507212}} {"text": "{-# OPTIONS --cubical --no-import-sorts #-}\n\nopen import Bundles\n\nmodule Properties.ConstructiveField {ℓ ℓ'} (F : ConstructiveField {ℓ} {ℓ'}) 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.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\nopen import Function.Base using (it) -- instance search\n\nopen import MoreLogic\nopen MoreLogic.Reasoning\nimport MoreAlgebra\n\n-- Lemma 4.1.6.\n-- For a constructive field (F, 0, 1, +, ·, #), the following hold.\n-- 1. 1 # 0.\n-- 2. Addition + is #-compatible in the sense that for all x, y, z : F\n-- x # y ⇔ x + z # y + z.\n-- 3. Multiplication · is #-extensional in the sense that for all w, x, y, z : F\n-- w · x # y · z ⇒ w # y ∨ x # z.\n\nopen ConstructiveField F\n\nopen import Cubical.Structures.Ring\nR = (makeRing 0f 1f _+_ _·_ -_ is-set +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+)\nopen Cubical.Structures.Ring.Theory R\nopen MoreAlgebra.Properties.Ring R\n\n-- Lemma 4.1.6.1\n1f#0f : 1f # 0f\n1f#0f with ·-identity 1f\n1f#0f | 1·1≡1 , _ = fst (·-inv-back _ _ 1·1≡1)\n\n-- Lemma 4.1.6.2\n-- For #-compatibility of +, suppose x # y, that is, (x +z) −z # (y +z) −z.\n-- Then #-extensionality gives (x + z # y + z) ∨ (−z # −z), where the latter case is excluded by irreflexivity of #.\n+-#-compatible : ∀(x y z : Carrier) → x # y → x + z # y + z\n+-#-compatible x y z x#y with\n let P = transport (λ i → a+b-b≡a x z i # a+b-b≡a y z i ) x#y\n in +-#-extensional _ _ _ _ P\n... | inl x+z#y+z = x+z#y+z\n... | inr -z#-z = ⊥-elim (#-irrefl _ -z#-z)\n\n-- The other direction is similar.\n+-#-compatible-inv : ∀(x y z : Carrier) → x + z # y + z → x # y\n+-#-compatible-inv _ _ _ x+z#y+z with +-#-extensional _ _ _ _ x+z#y+z\n... | inl x#y = x#y\n... | inr z#z = ⊥-elim (#-irrefl _ z#z)\n\n-- Lemma 4.1.6.3\n·-#-extensional-case1 : ∀(w x y z : Carrier) → w · x # y · z → w · x # w · z → x # z\n·-#-extensional-case1 w x y z w·x#y·z w·x#w·z =\n let\n instance -- this allows to use ⁻¹ᶠ without an instance argument\n w·[z-x]#0f =\n ( w · x # w · z ⇒⟨ +-#-compatible _ _ (- (w · x)) ⟩\n w · x - w · x # w · z - w · x ⇒⟨ transport (λ i → (fst (+-inv (w · x)) i) # a·b-a·c≡a·[b-c] w z x i) ⟩\n 0f # w · (z - x) ⇒⟨ #-sym _ _ ⟩\n w · (z - x) # 0f ◼) w·x#w·z\n in ( w · (z - x) # 0f ⇒⟨ (λ _ → ·-rinv (w · (z - x)) it ) ⟩ -- NOTE: \"plugging in\" the instance did not work, ∴ `it`\n w · (z - x) · (w · (z - x)) ⁻¹ᶠ ≡ 1f ⇒⟨ transport (λ i → ·-comm w (z - x) i · (w · (z - x)) ⁻¹ᶠ ≡ 1f) ⟩\n (z - x) · w · (w · (z - x)) ⁻¹ᶠ ≡ 1f ⇒⟨ transport (λ i → ·-assoc (z - x) w ((w · (z - x)) ⁻¹ᶠ) (~ i) ≡ 1f) ⟩\n (z - x) · (w · (w · (z - x)) ⁻¹ᶠ) ≡ 1f ⇒⟨ fst ∘ (·-inv-back _ _) ⟩\n z - x # 0f ⇒⟨ +-#-compatible _ _ x ⟩\n (z - x) + x # 0f + x ⇒⟨ transport (λ i → +-assoc z (- x) x (~ i) # snd (+-identity x) i) ⟩\n z + (- x + x) # x ⇒⟨ transport (λ i → z + snd (+-inv x) i # x) ⟩\n z + 0f # x ⇒⟨ transport (λ i → fst (+-identity z) i # x) ⟩\n z # x ⇒⟨ #-sym _ _ ⟩\n x # z ◼) it -- conceptually we would plug `w·[z-x]#0f` in, but this breaks the very first step\n\n\n·-#-extensional : ∀(w x y z : Carrier) → w · x # y · z → (w # y) ⊎ (x # z)\n·-#-extensional w x y z w·x#y·z with #-cotrans _ _ w·x#y·z (w · z)\n... | inl w·x#w·z = inr (·-#-extensional-case1 w x y z w·x#y·z w·x#w·z) -- first case\n... | inr w·z#y·z = let z·w≡z·y = (transport (λ i → ·-comm w z i # ·-comm y z i) w·z#y·z)\n in inl (·-#-extensional-case1 _ _ _ _ z·w≡z·y z·w≡z·y) -- second case reduced to first case\n", "meta": {"hexsha": "9be9ac540dc52e2a1f978121027930c9dba34b59", "size": 4092, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Properties/ConstructiveField.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/Properties/ConstructiveField.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/Properties/ConstructiveField.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": 47.0344827586, "max_line_length": 145, "alphanum_fraction": 0.4946236559, "num_tokens": 1713, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.7745833789613197, "lm_q1q2_score": 0.5802304959934472}} {"text": "{-# OPTIONS --cubical --safe --no-import-sorts #-}\nmodule Cubical.Algebra.CommAlgebra.Base 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.Equiv.HalfAdjoint\nopen import Cubical.Foundations.SIP\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.Reflection.StrictEquiv\n\nopen import Cubical.Structures.Axioms\nopen import Cubical.Algebra.Semigroup\nopen import Cubical.Algebra.Monoid\nopen import Cubical.Algebra.CommRing\nopen import Cubical.Algebra.Ring\nopen import Cubical.Algebra.Algebra hiding (⟨_⟩a)\n\nprivate\n variable\n ℓ ℓ′ : Level\n\nrecord IsCommAlgebra (R : CommRing {ℓ}) {A : Type ℓ}\n (0a : A) (1a : A)\n (_+_ : A → A → A) (_·_ : A → A → A) (-_ : A → A)\n (_⋆_ : ⟨ R ⟩ → A → A) : Type ℓ where\n\n constructor iscommalgebra\n\n field\n isAlgebra : IsAlgebra (CommRing→Ring R) 0a 1a _+_ _·_ -_ _⋆_\n ·-comm : (x y : A) → x · y ≡ y · x\n\n open IsAlgebra isAlgebra public\n\nrecord CommAlgebra (R : CommRing {ℓ}) : Type (ℓ-suc ℓ) where\n\n constructor commalgebra\n\n field\n Carrier : Type ℓ\n 0a : Carrier\n 1a : Carrier\n _+_ : Carrier → Carrier → Carrier\n _·_ : Carrier → Carrier → Carrier\n -_ : Carrier → Carrier\n _⋆_ : ⟨ R ⟩ → Carrier → Carrier\n isCommAlgebra : IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_\n\n open IsCommAlgebra isCommAlgebra public\n\nmodule _ {R : CommRing {ℓ}} where\n open CommRingStr (snd R) using (1r) renaming (_+_ to _+r_; _·_ to _·s_)\n\n ⟨_⟩a : CommAlgebra R → Type ℓ\n ⟨_⟩a = CommAlgebra.Carrier\n\n CommAlgebra→Algebra : (A : CommAlgebra R) → Algebra (CommRing→Ring R)\n CommAlgebra→Algebra (commalgebra Carrier _ _ _ _ _ _ (iscommalgebra isAlgebra ·-comm)) =\n algebra Carrier _ _ _ _ _ _ isAlgebra\n\n CommAlgebra→CommRing : (A : CommAlgebra R) → CommRing {ℓ}\n CommAlgebra→CommRing (commalgebra Carrier _ _ _ _ _ _\n (iscommalgebra isAlgebra ·-comm)) =\n _ , commringstr _ _ _ _ _ (iscommring (IsAlgebra.isRing isAlgebra) ·-comm)\n\n CommAlgebraEquiv : (R S : CommAlgebra R) → Type ℓ\n CommAlgebraEquiv R S = AlgebraEquiv (CommAlgebra→Algebra R) (CommAlgebra→Algebra S)\n\n makeIsCommAlgebra : {A : Type ℓ} {0a 1a : A}\n {_+_ _·_ : A → A → A} { -_ : A → A} {_⋆_ : ⟨ R ⟩ → A → A}\n (isSet-A : isSet A)\n (+-assoc : (x y z : A) → x + (y + z) ≡ (x + y) + z)\n (+-rid : (x : A) → x + 0a ≡ x)\n (+-rinv : (x : A) → x + (- x) ≡ 0a)\n (+-comm : (x y : A) → x + y ≡ y + x)\n (·-assoc : (x y z : A) → x · (y · z) ≡ (x · y) · z)\n (·-lid : (x : A) → 1a · x ≡ x)\n (·-ldist-+ : (x y z : A) → (x + y) · z ≡ (x · z) + (y · z))\n (·-comm : (x y : A) → x · y ≡ y · x)\n (⋆-assoc : (r s : ⟨ R ⟩) (x : A) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x))\n (⋆-ldist : (r s : ⟨ R ⟩) (x : A) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))\n (⋆-rdist : (r : ⟨ R ⟩) (x y : A) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))\n (⋆-lid : (x : A) → 1r ⋆ x ≡ x)\n (⋆-lassoc : (r : ⟨ R ⟩) (x y : A) → (r ⋆ x) · y ≡ r ⋆ (x · y))\n → IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_\n makeIsCommAlgebra {A} {0a} {1a} {_+_} {_·_} { -_} {_⋆_} isSet-A\n +-assoc +-rid +-rinv +-comm\n ·-assoc ·-lid ·-ldist-+ ·-comm\n ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid ⋆-lassoc\n = iscommalgebra\n (makeIsAlgebra\n isSet-A\n +-assoc +-rid +-rinv +-comm\n ·-assoc\n (λ x → x · 1a ≡⟨ ·-comm _ _ ⟩ 1a · x ≡⟨ ·-lid _ ⟩ x ∎)\n ·-lid\n (λ x y z → x · (y + z) ≡⟨ ·-comm _ _ ⟩\n (y + z) · x ≡⟨ ·-ldist-+ _ _ _ ⟩\n (y · x) + (z · x) ≡⟨ cong (λ u → (y · x) + u) (·-comm _ _) ⟩\n (y · x) + (x · z) ≡⟨ cong (λ u → u + (x · z)) (·-comm _ _) ⟩\n (x · y) + (x · z) ∎)\n ·-ldist-+\n ⋆-assoc\n ⋆-ldist\n ⋆-rdist\n ⋆-lid\n ⋆-lassoc\n λ r x y → r ⋆ (x · y) ≡⟨ cong (λ u → r ⋆ u) (·-comm _ _) ⟩\n r ⋆ (y · x) ≡⟨ sym (⋆-lassoc _ _ _) ⟩\n (r ⋆ y) · x ≡⟨ ·-comm _ _ ⟩\n x · (r ⋆ y) ∎)\n ·-comm\n\nmodule CommAlgebraΣTheory (R : CommRing {ℓ}) where\n\n open AlgebraΣTheory (CommRing→Ring R)\n\n CommAlgebraAxioms : (A : Type ℓ) (s : RawAlgebraStructure A) → Type ℓ\n CommAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_) = AlgebraAxioms A (_+_ , _·_ , 1a , _⋆_)\n × ((x y : A) → x · y ≡ y · x)\n\n CommAlgebraStructure : Type ℓ → Type ℓ\n CommAlgebraStructure = AxiomsStructure RawAlgebraStructure CommAlgebraAxioms\n\n CommAlgebraΣ : Type (ℓ-suc ℓ)\n CommAlgebraΣ = TypeWithStr ℓ CommAlgebraStructure\n\n CommAlgebraEquivStr : StrEquiv CommAlgebraStructure ℓ\n CommAlgebraEquivStr = AxiomsEquivStr RawAlgebraEquivStr CommAlgebraAxioms\n\n isPropCommAlgebraAxioms : (A : Type ℓ) (s : RawAlgebraStructure A)\n → isProp (CommAlgebraAxioms A s)\n isPropCommAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_) =\n isPropΣ (isPropAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_))\n λ isAlgebra → isPropΠ2 λ _ _ → (isSetAlgebraΣ (A , _ , isAlgebra)) _ _\n\n CommAlgebra→CommAlgebraΣ : CommAlgebra R → CommAlgebraΣ\n CommAlgebra→CommAlgebraΣ (commalgebra _ _ _ _ _ _ _ (iscommalgebra G C)) =\n _ , _ , Algebra→AlgebraΣ (algebra _ _ _ _ _ _ _ G) .snd .snd , C\n\n CommAlgebraΣ→CommAlgebra : CommAlgebraΣ → CommAlgebra R\n CommAlgebraΣ→CommAlgebra (_ , _ , G , C) =\n commalgebra _ _ _ _ _ _ _ (iscommalgebra (AlgebraΣ→Algebra (_ , _ , G) .Algebra.isAlgebra) C)\n\n CommAlgebraIsoCommAlgebraΣ : Iso (CommAlgebra R) CommAlgebraΣ\n CommAlgebraIsoCommAlgebraΣ =\n iso CommAlgebra→CommAlgebraΣ CommAlgebraΣ→CommAlgebra (λ _ → refl) (λ _ → refl)\n\n commAlgebraUnivalentStr : UnivalentStr CommAlgebraStructure CommAlgebraEquivStr\n commAlgebraUnivalentStr = axiomsUnivalentStr _ isPropCommAlgebraAxioms rawAlgebraUnivalentStr\n\n CommAlgebraΣPath : (A B : CommAlgebraΣ) → (A ≃[ CommAlgebraEquivStr ] B) ≃ (A ≡ B)\n CommAlgebraΣPath = SIP commAlgebraUnivalentStr\n\n CommAlgebraEquivΣ : (A B : CommAlgebra R) → Type ℓ\n CommAlgebraEquivΣ A B = CommAlgebra→CommAlgebraΣ A ≃[ CommAlgebraEquivStr ] CommAlgebra→CommAlgebraΣ B\n\n CommAlgebraPath : (A B : CommAlgebra R) → (CommAlgebraEquiv A B) ≃ (A ≡ B)\n CommAlgebraPath A B =\n CommAlgebraEquiv A B ≃⟨ strictIsoToEquiv AlgebraEquivΣPath ⟩\n CommAlgebraEquivΣ A B ≃⟨ CommAlgebraΣPath _ _ ⟩\n CommAlgebra→CommAlgebraΣ A ≡ CommAlgebra→CommAlgebraΣ B\n ≃⟨ isoToEquiv (invIso (congIso CommAlgebraIsoCommAlgebraΣ)) ⟩\n A ≡ B ■\n\nCommAlgebraPath : (R : CommRing {ℓ}) → (A B : CommAlgebra R) → (CommAlgebraEquiv A B) ≃ (A ≡ B)\nCommAlgebraPath = CommAlgebraΣTheory.CommAlgebraPath\n", "meta": {"hexsha": "6d4e8ea1675666115fc2c7b2157cb053c5849e9d", "size": 7077, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/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/Algebra/CommAlgebra/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/Algebra/CommAlgebra/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": 41.1453488372, "max_line_length": 104, "alphanum_fraction": 0.5505157553, "num_tokens": 2736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199552262967, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.5801707415868171}} {"text": "module puzzle where\n\n---- 仮定\n-- 猫か犬を飼っている人は山羊を飼ってない\n-- 猫を飼ってない人は、犬かウサギを飼っている\n-- 猫も山羊も飼っていない人は、ウサギを飼っている\n--\n---- 問題\n-- 山羊を飼っている人は、犬を飼っていない\n-- 山羊を飼っている人は、ウサギを飼っている\n-- ウサギを飼っていない人は、猫を飼っている\n\nmodule pet-research where\n open import logic\n open import Relation.Nullary\n open import Data.Empty\n\n postulate \n lem : (a : Set) → a ∨ ( ¬ a )\n\n record PetResearch ( Cat Dog Goat Rabbit : Set ) : Set where\n field\n fact1 : ( Cat ∨ Dog ) → ¬ Goat\n fact2 : ¬ Cat → ( Dog ∨ Rabbit )\n fact3 : ¬ ( Cat ∨ Goat ) → Rabbit\n\n module tmp ( Cat Dog Goat Rabbit : Set ) (p : PetResearch Cat Dog Goat Rabbit ) where\n\n open PetResearch\n\n problem0 : Cat ∨ Dog ∨ Goat ∨ Rabbit\n problem0 with lem Cat | lem Goat\n ... | case1 c | g = case1 c\n ... | c | case1 g = case2 ( case2 ( case1 g ) )\n ... | case2 ¬c | case2 ¬g = case2 ( case2 ( case2 ( fact3 p lemma1 ))) where\n lemma1 : ¬ ( Cat ∨ Goat )\n lemma1 (case1 c) = ¬c c\n lemma1 (case2 g) = ¬g g\n\n problem1 : Goat → ¬ Dog\n problem1 g d = fact1 p (case2 d) g \n \n problem2 : Goat → Rabbit\n problem2 g with lem Cat | lem Dog\n problem2 g | case1 c | d = ⊥-elim ( fact1 p (case1 c ) g )\n problem2 g | case2 ¬c | case1 d = ⊥-elim ( fact1 p (case2 d ) g )\n problem2 g | case2 ¬c | case2 ¬d with lem Rabbit\n ... | case1 r = r\n ... | case2 ¬r = fact3 p lemma2 where\n lemma2 : ¬ ( Cat ∨ Goat )\n lemma2 (case1 c) = ¬c c\n lemma2 (case2 g) with fact2 p ¬c\n lemma2 (case2 g) | case1 d = ¬d d\n lemma2 (case2 g) | case2 r = ¬r r\n\n problem3 : (¬ Rabbit ) → Cat\n problem3 ¬r with lem Cat | lem Goat \n problem3 ¬r | case1 c | g = c\n problem3 ¬r | case2 ¬c | g = ⊥-elim ( ¬r ( fact3 p lemma3 )) where\n lemma3 : ¬ ( Cat ∨ Goat )\n lemma3 (case1 c) = ¬c c\n lemma3 (case2 g) with fact2 p ¬c\n lemma3 (case2 g) | case1 d = fact1 p (case2 d ) g\n lemma3 (case2 g) | case2 r = ¬r r\n\nmodule pet-research1 ( Cat Dog Goat Rabbit : Set ) where\n\n open import Data.Bool\n open import Relation.Binary\n open import Relation.Binary.PropositionalEquality \n\n _=>_ : Bool → Bool → Bool\n _ => true = true\n false => _ = true\n true => false = false\n\n ¬_ : Bool → Bool\n ¬ p = not p\n\n problem0 : ( Cat Dog Goat Rabbit : Bool ) →\n ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n => (Cat ∨ Dog ∨ Goat ∨ Rabbit) ≡ true\n problem0 true d g r = refl\n problem0 false true g r = refl\n problem0 false false true r = refl\n problem0 false false false true = refl\n problem0 false false false false = refl\n\n problem1 : ( Cat Dog Goat Rabbit : Bool ) →\n ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n => ( Goat => ( ¬ Dog )) ≡ true\n problem1 c false false r = refl\n problem1 c true false r = refl\n problem1 c false true r = refl\n problem1 false true true r = refl\n problem1 true true true r = refl\n\n problem2 : ( Cat Dog Goat Rabbit : Bool ) →\n ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n => ( Goat => Rabbit ) ≡ true\n problem2 c d false false = refl\n problem2 c d false true = refl\n problem2 c d true true = refl\n problem2 true d true false = refl\n problem2 false false true false = refl\n problem2 false true true false = refl\n\n problem3 : ( Cat Dog Goat Rabbit : Bool ) →\n ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n => ( (¬ Rabbit ) => Cat ) ≡ true\n problem3 false d g true = refl \n problem3 true d g true = refl\n problem3 true d g false = refl\n problem3 false false false false = refl\n problem3 false false true false = refl\n problem3 false true false false = refl\n problem3 false true true false = refl\n\n-- module pet-research2 ( Cat Dog Goat Rabbit : Set ) where\n-- \n-- open import Data.Bool hiding ( _∨_ )\n-- open import Relation.Binary\n-- open import Relation.Binary.PropositionalEquality \n-- \n-- ¬_ : Bool → Bool\n-- ¬ p = p xor true\n-- \n-- infixr 5 _∨_ \n-- _∨_ : Bool → Bool → Bool\n-- a ∨ b = ¬ ( (¬ a) ∧ (¬ b ) )\n-- \n-- _=>_ : Bool → Bool → Bool\n-- a => b = (¬ a ) ∨ b \n-- \n-- open import Data.Bool.Solver using (module xor-∧-Solver)\n-- open xor-∧-Solver\n-- \n-- problem0' : ( Cat : Bool ) → (Cat xor Cat ) ≡ false\n-- problem0' = solve 1 (λ c → (c :+ c ) := con false ) refl\n-- \n-- problem1' : ( Cat : Bool ) → (Cat ∧ (Cat xor true )) ≡ false \n-- problem1' = solve 1 (λ c → ((c :* (c :+ con true )) ) := con false ) {!!}\n-- \n-- open import Data.Nat\n-- :¬_ : {n : ℕ} → Polynomial n → Polynomial n\n-- :¬ p = p :+ con true\n-- \n-- _:∨_ : {n : ℕ} → Polynomial n → Polynomial n → Polynomial n\n-- a :∨ b = :¬ ( ( :¬ a ) :* ( :¬ b ))\n-- \n-- _:=>_ : {n : ℕ} → Polynomial n → Polynomial n → Polynomial n\n-- a :=> b = ( :¬ a ) :∨ b \n-- \n-- _:∧_ = _:*_\n-- \n-- infixr 6 _:∧_\n-- infixr 5 _:∨_ \n-- \n-- problem0 : ( Cat Dog Goat Rabbit : Bool ) →\n-- ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n-- => (Cat ∨ Dog ∨ Goat ∨ Rabbit) ≡ true\n-- problem0 = solve 4 ( λ Cat Dog Goat Rabbit → (\n-- ( ((Cat :∨ Dog ) :=> (:¬ Goat)) :∧ ( ((:¬ Cat ) :=> ( Dog :∨ Rabbit )) :∧ (( :¬ ( Cat :∨ Goat ) ) :=> Rabbit) ))\n-- :=> ( Cat :∨ (Dog :∨ ( Goat :∨ Rabbit))) ) := con true ) {!!}\n-- \n-- problem1 : ( Cat Dog Goat Rabbit : Bool ) →\n-- ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n-- => ( Goat => ( ¬ Dog )) ≡ true\n-- problem1 c false false r = {!!}\n-- problem1 c true false r = {!!}\n-- problem1 c false true r = {!!}\n-- problem1 false true true r = refl\n-- problem1 true true true r = refl\n-- \n-- problem2 : ( Cat Dog Goat Rabbit : Bool ) →\n-- ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n-- => ( Goat => Rabbit ) ≡ true\n-- problem2 c d false false = {!!}\n-- problem2 c d false true = {!!}\n-- problem2 c d true true = {!!}\n-- problem2 true d true false = refl\n-- problem2 false false true false = refl\n-- problem2 false true true false = refl\n-- \n-- problem3 : ( Cat Dog Goat Rabbit : Bool ) →\n-- ((( Cat ∨ Dog ) => (¬ Goat) ) ∧ ( (¬ Cat ) => ( Dog ∨ Rabbit ) ) ∧ ( ( ¬ ( Cat ∨ Goat ) ) => Rabbit ) )\n-- => ( (¬ Rabbit ) => Cat ) ≡ true\n-- problem3 false d g true = {!!}\n-- problem3 true d g true = {!!}\n-- problem3 true d g false = {!!}\n-- problem3 false false false false = refl\n-- problem3 false false true false = refl\n-- problem3 false true false false = refl\n-- problem3 false true true false = refl\n", "meta": {"hexsha": "96ce9153deef6a941ac421d21c7918ec289a178c", "size": 6778, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/puzzle.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/puzzle.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/puzzle.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": 34.758974359, "max_line_length": 122, "alphanum_fraction": 0.5247860726, "num_tokens": 2460, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619947119304, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5801707359715735}} {"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.Lemmas\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\nopen import Numbers.Naturals.Order.Lemmas\nopen import Semirings.Definition\n\nmodule Fields.CauchyCompletion.NearlyTotalOrder {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 SetoidTotalOrder (TotallyOrderedRing.total order)\nopen SetoidPartialOrder pOrder\nopen Equivalence eq\nopen PartiallyOrderedRing pRing\nopen Ring R\nopen Group additiveGroup\nopen Field F\nopen import Fields.Orders.Lemmas {F = F} {pRing} (record { oRing = order })\nopen import Setoids.Orders.Partial.Sequences pOrder\n\nopen import Rings.InitialRing R\nopen import Rings.Orders.Partial.Lemmas pRing\nopen import Rings.Orders.Total.Lemmas order\nopen import Rings.Orders.Total.Cauchy order\nopen import Rings.Orders.Total.AbsoluteValue order\nopen import Fields.Lemmas F\nopen import Fields.CauchyCompletion.Definition order F\nopen import Fields.CauchyCompletion.Setoid order F\nopen import Fields.CauchyCompletion.Group order F\nopen import Fields.CauchyCompletion.Addition order F\nopen import Fields.CauchyCompletion.Approximation order F\nopen import Fields.CauchyCompletion.Comparison order F\nopen import Fields.CauchyCompletion.PartiallyOrderedRing order F\nopen import Fields.Orders.Total.Lemmas {F = F} (record { oRing = order })\n\nmakeIncreasingLemma : (a : A) (s : Sequence A) → Sequence A\nSequence.head (makeIncreasingLemma a s) with totality a (Sequence.head s)\n... | inl (inl x) = Sequence.head s\n... | inl (inr x) = a\n... | inr x = a\nSequence.tail (makeIncreasingLemma a s) = makeIncreasingLemma (Sequence.head (makeIncreasingLemma a s)) (Sequence.tail s)\n\nmakeIncreasingLemmaIsIncreasing : (a : A) (s : Sequence A) → WeaklyIncreasing (makeIncreasingLemma a s)\nmakeIncreasingLemmaIsIncreasing a s zero with totality a (Sequence.head s)\nmakeIncreasingLemmaIsIncreasing a s zero | inl (inl x) with totality (Sequence.head s) (Sequence.head (Sequence.tail s))\nmakeIncreasingLemmaIsIncreasing a s zero | inl (inl x) | inl (inl y) = inl y\nmakeIncreasingLemmaIsIncreasing a s zero | inl (inl x) | inl (inr y) = inr reflexive\nmakeIncreasingLemmaIsIncreasing a s zero | inl (inl x) | inr y = inr reflexive\nmakeIncreasingLemmaIsIncreasing a s zero | inl (inr x) with totality a (Sequence.head (Sequence.tail s))\n... | inl (inl y) = inl y\n... | inl (inr y) = inr reflexive\n... | inr y = inr reflexive\nmakeIncreasingLemmaIsIncreasing a s zero | inr x with totality a (Sequence.head (Sequence.tail s))\n... | inl (inl y) = inl y\n... | inl (inr y) = inr reflexive\n... | inr y = inr reflexive\nmakeIncreasingLemmaIsIncreasing a s (succ m) = makeIncreasingLemmaIsIncreasing (Sequence.head (makeIncreasingLemma a s)) (Sequence.tail s) m\n\nmakeIncreasing : Sequence A → Sequence A\nSequence.head (makeIncreasing x) = Sequence.head x\nSequence.tail (makeIncreasing x) = makeIncreasingLemma (Sequence.head x) (Sequence.tail x)\n\nmakeIncreasingIsIncreasing : (a : Sequence A) → WeaklyIncreasing (makeIncreasing a)\nmakeIncreasingIsIncreasing a zero with totality (Sequence.head a) (Sequence.head (Sequence.tail a))\n... | inl (inl x) = inl x\n... | inl (inr x) = inr reflexive\n... | inr x = inr reflexive\nmakeIncreasingIsIncreasing a (succ m) = makeIncreasingLemmaIsIncreasing _ _ m\n\napproximateIncreasingSeqRaw : CauchyCompletion → Sequence A\napproximateIncreasingSeqRaw a = funcToSequence f\n where\n f : ℕ → A\n f n with allInvertible (fromN (succ n)) λ n=0 → irreflexive (>=_ = λ f k r → f r >>= λ x → k x r }\n where open RawMonad M\n\nmodule _ {Γ : List Ty} {i} where\n open RawMonad {lzero} (ReaderT (Env Γ) (Sequential.monad {i})) public\n\nM : List Ty → Size → Set → Set\nM Γ i A = Env Γ → Delay A i\n\ngetEnv : ∀ {Γ i} → M Γ i (Env Γ)\ngetEnv E = now E\n\nwithEnv : ∀ {Γ Γ' i A} → Env Γ → M Γ i A → M Γ' i A\nwithEnv E m _ = m E\n\nget : ∀ {Γ t i} → t ∈ Γ → M Γ i (Val t)\nget x E = now (lookup E x)\n\nmutual\n eval : ∀ {Γ t} → Expr Γ t → ∀ {i} → M Γ i (Val t)\n eval (add e₁ e₂) = do\n numv n₁ ← eval e₁\n numv n₂ ← eval e₁\n return (numv (n₁ + n₂))\n eval (num n) = do\n return (numv n)\n eval true′ = do\n return (boolv true)\n eval false′ = do\n return (boolv false)\n eval (if′ c then t else e) = do\n (boolv b) ← eval c\n if b then eval t else eval e\n eval (ƛ e) = do\n E ← getEnv\n return ⟨ƛ e , E ⟩\n eval (f ∙ a) = do\n ⟨ƛ e , E ⟩ ← eval f\n v ← eval a\n withEnv (v ∷ E) (▹eval e)\n eval (var x) = do\n get x\n\n ▹eval : ∀ {Γ i t} → Expr Γ t → M Γ i (Val t)\n ▹eval e E = later λ where .force → eval e E\n\n", "meta": {"hexsha": "317a8de5a527d5dc51a7e69e0bbbeef029ecfdb0", "size": 2365, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Typed/STLC/Delay.agda", "max_stars_repo_name": "laMudri/linear.agda", "max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z", "max_issues_repo_path": "src/Typed/STLC/Delay.agda", "max_issues_repo_name": "laMudri/linear.agda", "max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_issues_repo_licenses": ["MIT"], "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/Typed/STLC/Delay.agda", "max_forks_repo_name": "laMudri/linear.agda", "max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z", "avg_line_length": 23.1862745098, "max_line_length": 87, "alphanum_fraction": 0.555179704, "num_tokens": 942, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314828740729, "lm_q2_score": 0.6548947155710234, "lm_q1q2_score": 0.5799953780775596}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _⊔_)\nopen import Setoids.Setoids\nopen import Setoids.Functions.Definition\nopen import Sets.EquivalenceRelations\n\nmodule Setoids.Functions.Extension where\n\nExtensionallyEqual : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {f g : A → B} (fWd : WellDefined S T f) (gWd : WellDefined S T g) → Set (a ⊔ d)\nExtensionallyEqual {A = A} {T = T} {f = f} {g = g} fWD gWD = (∀ {x : A} → Setoid._∼_ T (f x) (g x))\n\nextensionallyEqualReflexive : {a b c d : _} {A : Set a} {B : Set b} (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f : A → B) (fWD1 fWD2 : WellDefined S T f) → ExtensionallyEqual {S = S} {T} fWD1 fWD2\nextensionallyEqualReflexive S T f fWD1 _ = Equivalence.reflexive (Setoid.eq T)\n\nextensionallyEqualSymmetric : {a b c d : _} {A : Set a} {B : Set b} (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f g : A → B) (fWD : WellDefined S T f) (gWD : WellDefined S T g) → ExtensionallyEqual {S = S} {T = T} fWD gWD → ExtensionallyEqual {S = S} {T} gWD fWD\nextensionallyEqualSymmetric S T f g fWD gWD pr = Equivalence.symmetric (Setoid.eq T) pr\n\nextensionallyEqualTransitive : {a b c d : _} {A : Set a} {B : Set b} (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f g h : A → B) (fWD : WellDefined S T f) (gWD : WellDefined S T g) (hWD : WellDefined S T h) → ExtensionallyEqual {S = S} {T} fWD gWD → ExtensionallyEqual {S = S} {T} gWD hWD → ExtensionallyEqual {S = S} {T} fWD hWD\nextensionallyEqualTransitive S T f g h fWD gWD hWD pr1 pr2 = Equivalence.transitive (Setoid.eq T) pr1 pr2\n", "meta": {"hexsha": "49fd828ed96a317251cf8799a76a5abd216ca989", "size": 1621, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Functions/Extension.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/Extension.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/Extension.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.1904761905, "max_line_length": 331, "alphanum_fraction": 0.6397285626, "num_tokens": 639, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925402, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.5799737477862531}} {"text": "{-# OPTIONS --with-K #-}\n\nopen import Agda.Builtin.Equality\nopen import Agda.Builtin.Nat\n\nsingle : {m n : Nat} → suc m ≡ suc n → n ≡ m\nsingle p with refl ← p = refl\n\ndouble : {m n p : Nat} → suc m ≡ n → suc n ≡ 2 + p → m ≡ p\ndouble p q with refl ← p | refl ← q = refl\n\n_∋_ : (A : Set) → A → A\nA ∋ a = a\n\n-- The second equality proof is only well-typed\n-- after the first one has been used\n\ntele : {m n : Nat} → suc m ≡ suc n → m ≡ n\ntele {m} {n} p\n with refl ← p\n | refl ← (n ≡ m) ∋ refl\n = refl\n\ntele' : {m n : Nat} → m ≡ n → m ≡ n\ntele' {m} {n} p with refl ← p with (n ≡ m) ∋ refl\n... | q = refl\n\n-- Further splitting after a using & with\n\ntele'' : {m n : Nat} → m ≡ n → Nat → Nat\ntele'' {m} {n} p r with refl ← p | (n ≡ m) ∋ refl\ntele'' {m} {m} p zero | q = m\ntele'' {m} {m} p (suc r) | q = r\n\ndata Vec {a} (A : Set a) : Nat → Set a where\n [] : Vec A 0\n _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)\n\nmodule _ {a} {A : Set a} {n} (xs : Vec A (suc n)) where\n\n head : A\n head with (x ∷ _) ← xs = x\n\n tail : Vec A n\n tail with (_ ∷ xs) ← xs = xs -- pattern shadows variable with'd on\n\ncastVec : ∀ {m n} → m ≡ n → Vec Nat m → Vec Nat n\ncastVec eq ms with refl ← eq = ms\n\ndata All (P : Nat → Set) : ∀ {n} → Vec Nat n → Set where\n [] : All P []\n _∷_ : ∀ {n x xs} → P x → All P {n} xs → All P (x ∷ xs)\n\nopen import Agda.Builtin.Sigma\n\ncastAll : ∀ {P m n xs ys} → Σ (m ≡ n) (λ eq → castVec eq xs ≡ ys) →\n All P xs → All P ys\ncastAll (refl , refl) all = all\n", "meta": {"hexsha": "4348889aa1be552adbf61d0b495e0ab549e78f7b", "size": 1483, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/UsingEq.agda", "max_stars_repo_name": "hborum/agda", "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "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/UsingEq.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/UsingEq.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": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "avg_line_length": 25.1355932203, "max_line_length": 68, "alphanum_fraction": 0.5158462576, "num_tokens": 611, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.5799737356998268}} {"text": "module my-bool-test where\n\nopen import bool\nopen import eq\nopen import level\n\n~~tt : ~ ~ tt ≡ tt\n~~tt = refl\n\n~~ff : ~ ~ ff ≡ ff\n~~ff = refl\n{-\n~~-elim : ∀ (b : 𝔹) → ~ ~ b ≡ b\n~~-elim tt = refl\n~~-elim ff = refl\n-}\n~~-elim2 : ∀ (b : 𝔹) → ~ ~ b ≡ b\n~~-elim2 tt = ~~tt\n~~-elim2 ff = ~~ff\n\n~~tt' : ~ ~ tt ≡ tt\n~~tt' = refl{lzero}{𝔹}{tt}\n\n~~ff' : ~ ~ ff ≡ ff\n~~ff' = refl{lzero}{𝔹}{ff}\n\n~~-elim : ∀ (b : 𝔹) → ~ ~ b ≡ b\n~~-elim tt = refl\n~~-elim ff = refl\n\n||≡ff₁ : ∀ {b1 b2} → b1 || b2 ≡ ff → b1 ≡ ff\n||≡ff₁ {ff} _ = refl{lzero}{𝔹}{ff}\n||≡ff₁ {tt} ()\n\n||≡ff₂ : ∀ {b1 b2} → b1 || b2 ≡ ff → ff ≡ b1\n||≡ff₂ {ff} _ = refl{lzero}{𝔹}{ff}\n||≡ff₂ {tt} p = sym p\n\n||-cong₁ : ∀ {b1 b1' b2} → b1 ≡ b1' → b1 || b2 ≡ b1' || b2\n||-cong₁{b1}{.b1}{b2} refl = refl\n\n||-cong₂ : ∀ {b1 b2 b2'} → b2 ≡ b2' → b1 || b2 ≡ b1 || b2'\n||-cong₂ p rewrite p = refl\n\nite-same : ∀{ℓ}{A : Set ℓ} →\n ∀(b : 𝔹) (x : A) →\n (if b then x else x) ≡ x\nite-same tt x = refl\nite-same ff x = refl\n\n𝔹-contra : ff ≡ tt → ∀ {P : Set} → P\n𝔹-contra ()\n\np : ff && ff ≡ ~ tt\np = refl\n", "meta": {"hexsha": "04cd1a57309e0fb14cdb3499fe7b89c47c31e4ca", "size": 1050, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "my-bool-test.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": "my-bool-test.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": "my-bool-test.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": 18.75, "max_line_length": 58, "alphanum_fraction": 0.4485714286, "num_tokens": 539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246035907933, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5799591953242144}} {"text": "module Generic.Lib.Data.Nat where\n\nopen import Data.Nat.Base hiding (_⊔_; _^_) public\n\nopen import Generic.Lib.Decidable\n\ninstance\n ℕEq : Eq ℕ\n ℕEq = viaBase Nat._≟_ where\n import Data.Nat as Nat\n\nfoldℕ : ∀ {α} {A : Set α} -> (A -> A) -> A -> ℕ -> A\nfoldℕ f x 0 = x\nfoldℕ f x (suc n) = f (foldℕ f x n)\n", "meta": {"hexsha": "ccb97f26d9d336da3ab4e6f754f2d68813c79d02", "size": 313, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Generic/Lib/Data/Nat.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/Data/Nat.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/Data/Nat.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": 20.8666666667, "max_line_length": 52, "alphanum_fraction": 0.6102236422, "num_tokens": 121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333246035907932, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.5799591848140219}} {"text": "{-# OPTIONS --without-K #-}\nmodule Util.HoTT.Univalence.Axiom where\n\nopen import Util.HoTT.Equiv\nopen import Util.HoTT.Univalence.Statement\nopen import Util.Prelude\nopen import Util.Relation.Binary.PropositionalEquality using (Σ-≡⁻)\n\n\nprivate\n variable\n α β γ : Level\n A B C : Set α\n\n\npostulate\n univalence : ∀ {α} → Univalence α\n\n\n≃→≡ : A ≃ B → A ≡ B\n≃→≡ A≃B = univalence A≃B .proj₁ .proj₁\n\n\n≡→≃∘≃→≡ : (p : A ≃ B) → ≡→≃ (≃→≡ p) ≡ p\n≡→≃∘≃→≡ p = univalence p .proj₁ .proj₂\n\n\n≃→≡∘≡→≃ : (p : A ≡ B) → ≃→≡ (≡→≃ p) ≡ p\n≃→≡∘≡→≃ p = Σ-≡⁻ (univalence (≡→≃ p) .proj₂ (p , refl)) .proj₁\n\n\n≃→≡-≡→≃-coh : (p : A ≡ B)\n → subst (λ q → ≡→≃ q ≡ ≡→≃ p) (≃→≡∘≡→≃ p) (≡→≃∘≃→≡ (≡→≃ p)) ≡ refl\n≃→≡-≡→≃-coh p = Σ-≡⁻ (univalence (≡→≃ p) .proj₂ (p , refl)) .proj₂\n\n\n≅→≡ : A ≅ B → A ≡ B\n≅→≡ = ≃→≡ ∘ ≅→≃\n", "meta": {"hexsha": "d75ea186fa6d51ad75395a40167112c498dc9e73", "size": 787, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Util/HoTT/Univalence/Axiom.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/Util/HoTT/Univalence/Axiom.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/Util/HoTT/Univalence/Axiom.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.1794871795, "max_line_length": 68, "alphanum_fraction": 0.4955527319, "num_tokens": 448, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357563664174, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.5799431081923017}} {"text": "module GTFL where\n\nopen import Data.Nat hiding (_⊓_; erase; _≟_; _≤_)\nopen import Data.Bool hiding (_≟_)\nopen import Data.Fin using (Fin; zero; suc; toℕ)\nopen import Data.Vec\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary\nopen import Data.Empty\nopen import Function using (_∘_)\n\n-- | Types\ninfixr 30 _⇒_\ndata GType : Set where\n nat : GType\n bool : GType\n _⇒_ : GType → GType → GType\n ✭ : GType\n err : GType -- easier to model this as a type in Agda\n\n-- | Untyped Expressions\ndata Expr : Set where\n litNat : ℕ → Expr\n litBool : Bool → Expr\n dyn : Expr\n err : Expr\n var : ℕ → Expr\n lam : GType → Expr → Expr\n _∙_ : Expr → Expr → Expr\n _⊕_ : Expr → Expr → Expr\n if_thn_els_ : Expr → Expr → Expr → Expr\n\nCtx : ℕ → Set\nCtx = Vec GType\n\ninfixr 10 _~_\ndata _~_ {A B : Set} (x : A) (y : B) : Set where\n cons : x ~ y\n\n~dom : ∀ (t : GType) → GType\n~dom (t ⇒ t₁) = t₁\n~dom _ = err\n\n~cod : ∀ (t : GType) → GType\n~cod (t ⇒ t₁) = t₁\n~cod _ = err\n\n_⊓_ : ∀ (t₁ t₂ : GType) → GType\nnat ⊓ nat = nat\nbool ⊓ bool = bool\nt₁ ⊓ ✭ = t₁\n✭ ⊓ t₂ = t₂\n(t₁ ⇒ t₂) ⊓ (t₃ ⇒ t₄) = (t₁ ⊓ t₃) ⇒ (t₂ ⊓ t₄)\n_ ⊓ _ = err\n\n-- | Typed Terms\ndata Term {n} (Γ : Ctx n) : GType → Set where\n Tx : ∀ {t} (v : Fin n) → t ≡ lookup v Γ → Term Γ t\n Tn : ℕ → Term Γ nat\n Tb : Bool → Term Γ bool\n Tdy : Term Γ ✭\n _T∙_ : ∀ {t₁ t₂} → Term Γ t₁ → Term Γ t₂ → t₂ ~ (~dom t₁) → Term Γ (~cod t₁)\n _T⊕_ : ∀ {t₁ t₂} → Term Γ t₁ → Term Γ t₂ → (t₁ ~ nat) → (t₂ ~ nat) → Term Γ (t₁ ⊓ t₂)\n Tif : ∀ {t₁ t₂ t₃} → Term Γ t₁ → Term Γ t₂ → Term Γ t₃ → (t₁ ~ bool) → Term Γ (t₂ ⊓ t₃)\n Tlam : ∀ t₁ {t₂} → Term (t₁ ∷ Γ) t₂ → Term Γ (t₁ ⇒ t₂)\n\nerase : ∀ {n} {Γ : Ctx n} {t} → Term Γ t → Expr\nerase (Tx v x) = var (toℕ v)\nerase (Tn x) = litNat x\nerase (Tb x) = litBool x\nerase Tdy = dyn\nerase ((term T∙ term₁) _) = (erase term) ∙ (erase term₁)\nerase ((term T⊕ term₁) _ _) = (erase term) ⊕ (erase term₁)\nerase (Tif b tt ff _) = if erase b thn erase tt els erase ff\nerase (Tlam t₁ term) = lam t₁ (erase term)\n\ndata Fromℕ (n : ℕ) : ℕ → Set where\n yes : (m : Fin n) → Fromℕ n (toℕ m)\n no : (m : ℕ) → Fromℕ n (n + m)\n\nfromℕ : ∀ n m → Fromℕ n m\nfromℕ zero m = no m\nfromℕ (suc n) zero = yes zero\nfromℕ (suc n) (suc m) with fromℕ n m\nfromℕ (suc n) (suc .(toℕ m)) | yes m = yes (suc m)\nfromℕ (suc n) (suc .(n + m)) | no m = no m\n\ndata Check {n} (Γ : Ctx n) : Expr → Set where\n yes : (τ : GType) (t : Term Γ τ) → Check Γ (erase t)\n no : {e : Expr} → Check Γ e\n\nstaticCheck : ∀ {n} (Γ : Ctx n) (t : Expr) → Check Γ t\n-- | primitives\nstaticCheck Γ (litNat x) = yes nat (Tn x)\nstaticCheck Γ (litBool x) = yes bool (Tb x)\nstaticCheck {n} Γ dyn = yes ✭ Tdy\nstaticCheck Γ err = no\n\n-- | var lookup\nstaticCheck {n} Γ (var v) with fromℕ n v \nstaticCheck {n} Γ (var .(toℕ m)) | yes m = yes (lookup m Γ) (Tx m refl)\nstaticCheck {n} Γ (var .(n + m)) | no m = no\n\n-- | lambda abstraction\nstaticCheck Γ (lam x t) with staticCheck (x ∷ Γ) t\nstaticCheck Γ (lam x .(erase t)) | yes τ t = yes (x ⇒ τ) (Tlam x t) -- double check this\nstaticCheck Γ (lam x t) | no = no\n\n-- | application\nstaticCheck Γ (t₁ ∙ t₂) with staticCheck Γ t₁ | staticCheck Γ t₂ \nstaticCheck Γ (.(erase t₁) ∙ .(erase t)) | yes (τ₁ ⇒ τ₂) t₁ | (yes τ t) = yes τ₂ ((t₁ T∙ t) cons)\nstaticCheck Γ (.(erase t₁) ∙ .(erase t)) | yes _ t₁ | (yes τ t) = no -- not sure about this\nstaticCheck Γ (t₁ ∙ t₂) | _ | _ = no\n\n-- | addition\nstaticCheck Γ (t₁ ⊕ t₂) with staticCheck Γ t₁ | staticCheck Γ t₂ \nstaticCheck Γ (.(erase t₁) ⊕ .(erase t)) | yes nat t₁ | (yes nat t) = yes nat ((t₁ T⊕ t) cons cons)\nstaticCheck Γ (.(erase t₁) ⊕ .(erase t)) | yes ✭ t₁ | (yes nat t) = yes (✭ ⊓ nat) ((t₁ T⊕ t) cons cons)\nstaticCheck Γ (.(erase t₁) ⊕ .(erase t)) | yes nat t₁ | (yes ✭ t) = yes (nat ⊓ ✭) ((t₁ T⊕ t) cons cons)\nstaticCheck Γ (.(erase t₁) ⊕ .(erase t)) | yes ✭ t₁ | (yes ✭ t) = yes ✭ ((t₁ T⊕ t) cons cons)\nstaticCheck Γ (t₁ ⊕ t₂) | _ | _ = no\n\n-- | if ... then ... else\nstaticCheck Γ (if t thn t₁ els t₂) with staticCheck Γ t\nstaticCheck Γ (if .(erase t) thn t₁ els t₂) | yes bool t with staticCheck Γ t₁ | staticCheck Γ t₂\nstaticCheck Γ (if .(erase t₂) thn .(erase t₁) els .(erase t)) | yes bool t₂ | (yes τ₁ t₁) | (yes τ₂ t) = yes (τ₁ ⊓ τ₂) (Tif t₂ t₁ t cons)\nstaticCheck Γ (if .(erase t₁) thn .(erase t) els t₂) | yes bool t₁ | (yes τ t) | no = no\nstaticCheck Γ (if .(erase t₂) thn t₁ els .(erase t)) | yes bool t₂ | no | (yes τ t) = no\nstaticCheck Γ (if .(erase t) thn t₁ els t₂) | yes bool t | no | _ = no\n\nstaticCheck Γ (if .(erase t) thn t₁ els t₂) | yes ✭ t with staticCheck Γ t₁ | staticCheck Γ t₂\nstaticCheck Γ (if .(erase t₂) thn .(erase t₁) els .(erase t)) | yes ✭ t₂ | (yes τ₁ t₁) | (yes τ₂ t) = yes (τ₁ ⊓ τ₂) (Tif t₂ t₁ t cons)\nstaticCheck Γ (if .(erase t₁) thn .(erase t) els t₂) | yes ✭ t₁ | (yes τ t) | no = no\nstaticCheck Γ (if .(erase t₂) thn t₁ els .(erase t)) | yes ✭ t₂ | no | (yes τ t) = no\nstaticCheck Γ (if .(erase t) thn t₁ els t₂) | yes ✭ t | no | no = no\n\nstaticCheck Γ (if .(erase t) thn t₁ els t₂) | yes _ t = no\nstaticCheck Γ (if t thn t₁ els t₂) | no = no\n\nextractType : ∀ {n} {Γ : Ctx n} {t : Expr} → Check Γ t → GType\nextractType (yes τ t) = τ\nextractType no = err\n\n-- Type Precision\ndata _⊑_ : GType → GType → Set where\n n⊑✭ : nat ⊑ ✭\n b⊑✭ : bool ⊑ ✭\n ⇒⊑ : ∀ (t₁ t₂ : GType) → (t₁ ⇒ t₂) ⊑ ✭\n n⊑n : nat ⊑ nat\n b⊑b : bool ⊑ bool\n ✭⊑✭ : ✭ ⊑ ✭\n app⊑ : ∀ (t₁ t₂ t₃ t₄ : GType) → t₁ ⊑ t₃ → t₂ ⊑ t₄ → (t₁ ⇒ t₃) ⊑ (t₃ ⇒ t₄)\n\n-- Term Precision\ndata _≤_ : Expr → Expr → Set where\n n≤n : ∀ {n} → litNat n ≤ litNat n\n b≤b : ∀ {b} → litBool b ≤ litBool b\n n≤✭ : ∀ {n} → litNat n ≤ dyn\n b≤✭ : ∀ {b} → litBool b ≤ dyn\n d≤d : dyn ≤ dyn\n\nssG : ∀ {n} {Γ : Ctx n} {e₁ e₂ : Expr} → e₁ ≤ e₂ → extractType (staticCheck Γ e₁) ⊑ extractType (staticCheck Γ e₂)\nssG n≤n = n⊑n\nssG b≤b = b⊑b\nssG n≤✭ = n⊑✭\nssG b≤✭ = b⊑✭\nssG d≤d = ✭⊑✭\n", "meta": {"hexsha": "1c08b2d9fe68d84d5fb0fa1648c8c509ece8a357", "size": 6067, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/GTFL.agda", "max_stars_repo_name": "kellino/TypeSystems", "max_stars_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-10-27T08:05:40.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-26T23:06:17.000Z", "max_issues_repo_path": "Agda/GTFL.agda", "max_issues_repo_name": "kellino/TypeSystems", "max_issues_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_issues_repo_licenses": ["MIT"], "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/GTFL.agda", "max_forks_repo_name": "kellino/TypeSystems", "max_forks_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_forks_repo_licenses": ["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.1130952381, "max_line_length": 137, "alphanum_fraction": 0.5450799407, "num_tokens": 2630, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357460591568, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5799430955750204}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.EilenbergMacLane\n\nmodule cohomology.CupProduct.OnEM.InLowDegrees2 {i} {j} (G : AbGroup i) (H : AbGroup j) where\n\nprivate\n module G = AbGroup G\n module H = AbGroup H\n module G⊗H = TensorProduct G H\n\nopen EMExplicit G⊗H.abgroup\nopen import cohomology.CupProduct.OnEM.InLowDegrees G H public\nopen import cohomology.CupProduct.OnEM.CommutativityInLowDegrees\nopen CP₁₁-comm G H\n\ncp₁₁-embase-r : (x : EM₁ G.grp) → cp₁₁ x embase == [ north ]₂\ncp₁₁-embase-r x = CP₁₁Comm.f x embase\n\nmodule ∧-cp₁₁-Rec =\n SmashRec {X = ⊙EM₁ G.grp} {Y = ⊙EM₁ H.grp} {C = EM 2}\n cp₁₁\n [ north ]₂ [ north ]₂\n cp₁₁-embase-r\n (λ y → idp)\n\n∧-cp₁₁ : ⊙EM₁ G.grp ∧ ⊙EM₁ H.grp → EM 2\n∧-cp₁₁ = ∧-cp₁₁-Rec.f\n\n⊙∧-cp₁₁ : ⊙EM₁ G.grp ⊙∧ ⊙EM₁ H.grp ⊙→ ⊙EM 2\n⊙∧-cp₁₁ = ∧-cp₁₁-Rec.f , idp\n", "meta": {"hexsha": "0b61e755fb073c8d03f1e6bf92ce9b305a5dd2ae", "size": 871, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/cohomology/CupProduct/OnEM/InLowDegrees2.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/cohomology/CupProduct/OnEM/InLowDegrees2.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/cohomology/CupProduct/OnEM/InLowDegrees2.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": 26.3939393939, "max_line_length": 93, "alphanum_fraction": 0.6383467279, "num_tokens": 357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970811069351, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.5799322185481361}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Algebra\nopen import Relation.Unary\nopen import Relation.Binary hiding (Decidable)\n\nmodule Data.FingerTree.Split.Intermediate\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 ℙ?\n\nopen import Data.Empty.Irrelevant using (⊥-elim)\n\nrecord Split′ (i : 𝓡) {a b} (Σ : Set a) (A : Set b) ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄ : Set (a ⊔ b ⊔ s) where\n constructor _∷⟨_⟩∷_[_]\n field\n left′ : Σ\n focus′ : A\n right′ : Σ\n .proof′ : i ∙ μ left′ ∣ μ focus′\nopen Split′ public\ninstance\n σ-Split′ : ∀ {a b} {Σ : Set a} {A : Set b} ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄ {i : 𝓡} → σ (Split′ i Σ A)\n μ ⦃ σ-Split′ {i = i} ⦄ (l ∷⟨ x ⟩∷ r [ _ ]) = i ∙ (μ l ∙ (μ x ∙ μ r))\n\ninfixl 2 _i≈[_]\n_i≈[_] : ∀ {a b} {Σ : Set a} {A : Set b} ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄\n → ∀ {i xs}\n → μ⟨ Split′ i Σ A ⟩≈ (i ∙ xs)\n → ∀ {j}\n → i ≈ j → μ⟨ Split′ j Σ A ⟩≈ (j ∙ xs)\nxs ∷⟨ x ⟩∷ ys [ p₁ ] ⇑[ p₂ ] i≈[ i≈ ] = xs ∷⟨ x ⟩∷ ys [ p₁ ≈◄⟅ ≪∙ i≈ ⟆ ] ⇑[ ≪∙ sym i≈ ⍮ p₂ ⍮ ≪∙ i≈ ]\n{-# INLINE _i≈[_] #-}\n", "meta": {"hexsha": "d60be980ebec736b2f83ef7dbd4b2190868dd20e", "size": 1908, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/FingerTree/Split/Intermediate.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/Intermediate.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/Intermediate.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.7741935484, "max_line_length": 100, "alphanum_fraction": 0.6016771488, "num_tokens": 799, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8902942377652497, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.579897494803326}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Code related to vector equality over propositional equality that\n-- makes use of heterogeneous equality\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Data.Vec.Relation.Binary.Equality.Propositional.WithK\n {a} {A : Set a} where\n\nopen import Data.Vec\nopen import Data.Vec.Relation.Binary.Equality.Propositional {A = A}\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary.HeterogeneousEquality as H using (_≅_)\n\n≋⇒≅ : ∀ {m n} {xs : Vec A m} {ys : Vec A n} →\n xs ≋ ys → xs ≅ ys\n≋⇒≅ p with length-equal p\n... | refl = H.≡-to-≅ (≋⇒≡ p)\n", "meta": {"hexsha": "1c0144b77602d34e5ebaae47bd7a1cb2abb2312f", "size": 738, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Relation/Binary/Equality/Propositional/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/Relation/Binary/Equality/Propositional/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/Relation/Binary/Equality/Propositional/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": 33.5454545455, "max_line_length": 72, "alphanum_fraction": 0.554200542, "num_tokens": 192, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8902942203004186, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.5798974653513627}} {"text": "open import Common.Equality\nopen import Common.Prelude renaming (Nat to ℕ)\n\ninfixr 4 _,_\ninfix 4 ,_\n\nrecord Σ (A : Set) (B : A → Set) : Set where\n constructor _,_\n field\n proj₁ : A\n proj₂ : B proj₁\n\nopen Σ\n\n,_ : {A : Set} {B : A → Set} {x : A} → B x → Σ A B\n, y = _ , y\n\nshould-be-accepted : Σ ℕ λ i → Σ ℕ λ j → Σ (i ≡ j) λ _ → Σ ℕ λ k → j ≡ k\nshould-be-accepted = 5 , , refl , , refl\n\n_⊕_ : ℕ → ℕ → ℕ\n_⊕_ = _+_\n\n_↓ : ℕ → ℕ\n_↓ = pred\n\ninfixl 6 _⊕_\ninfix 6 _↓\n\nshould-also-be-accepted : ℕ\nshould-also-be-accepted = 1 ⊕ 0 ↓ ⊕ 1 ↓ ⊕ 1 ⊕ 1 ↓\n\nparses-correctly : should-also-be-accepted ≡ 1\nparses-correctly = refl\n", "meta": {"hexsha": "e1382697eb692a7d0db16e1e47e3cc8bd3f79425", "size": 620, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Prefix-Right-Postfix-Left.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/Prefix-Right-Postfix-Left.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/Prefix-Right-Postfix-Left.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.7142857143, "max_line_length": 72, "alphanum_fraction": 0.5725806452, "num_tokens": 277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104788995148792, "lm_q2_score": 0.7154239836484143, "lm_q1q2_score": 0.5798360429539178}} {"text": "open import Categories\nopen import Monads\n\nmodule Monads.EM.Adjunction {a b}{C : Cat {a}{b}}(M : Monad C) where\n\nopen import Library\n\nopen import Functors\nopen import Adjunctions\nopen import Monads.EM M\nopen import Monads.EM.Functors M\n\nopen Cat C\nopen Fun\nopen Monad M\nopen Adj\nopen Alg\nopen AlgMorph\n\nEMAdj : Adj C EM\nEMAdj = record {\n L = EML;\n R = EMR;\n left = λ f → comp (amor f) η;\n right = λ {X}{Y} f → \n record{amor = astr Y X f;\n ahom = λ {Z}{g} → \n proof\n comp (astr Y X f) (astr (OMap EML X) Z g)\n ≅⟨ sym (alaw2 Y) ⟩\n astr Y Z (comp (astr Y X f) g) \n ∎};\n lawa = λ {X}{Y}(f : AlgMorph (OMap EML X) Y) → AlgMorphEq (\n proof \n astr Y X (comp (amor f) η) \n ≅⟨ sym (ahom f) ⟩ \n comp (amor f) (astr (OMap EML X) X η)\n ≡⟨⟩\n comp (amor f) (bind η)\n ≅⟨ cong (comp (amor f)) law1 ⟩\n comp (amor f) iden\n ≅⟨ idr ⟩\n amor f \n ∎);\n lawb = λ {X}{Y} f → \n proof \n comp (astr Y X f) η \n ≅⟨ sym (alaw1 Y) ⟩ \n f \n ∎;\n natleft = λ{X}{X'}{Y}{Y'} f g h → \n proof\n comp (amor g) (comp (comp (amor h) η) f) \n ≅⟨ cong (comp (amor g)) ass ⟩\n comp (amor g) (comp (amor h) (comp η f))\n ≅⟨ cong (comp (amor g) ∘ comp (amor h)) (sym law2) ⟩\n comp (amor g) (comp (amor h) (comp (bind (comp η f)) η))\n ≅⟨ cong (comp (amor g)) (sym ass) ⟩\n comp (amor g) (comp (comp (amor h) (bind (comp η f))) η)\n ≅⟨ sym ass ⟩\n comp (comp (amor g) (comp (amor h) (bind (comp η f)))) η\n ∎;\n natright = λ{X}{X'}{Y}{Y'} f g h → AlgMorphEq (\n proof\n astr Y' X' (comp (amor g) (comp h f)) \n ≅⟨ sym (ahom g) ⟩\n comp (amor g) (astr Y X' (comp h f))\n ≅⟨ cong (λ h → comp (amor g) (astr Y X' (comp h f))) (alaw1 Y) ⟩\n comp (amor g) (astr Y X' (comp (comp (astr Y X h) η) f))\n ≅⟨ cong (comp (amor g) ∘ astr Y X') ass ⟩\n comp (amor g) (astr Y X' (comp (astr Y X h) (comp η f)))\n ≅⟨ cong (comp (amor g)) (alaw2 Y) ⟩\n comp (amor g) (comp (astr Y X h) (bind (comp η f))) \n ∎)}\n", "meta": {"hexsha": "9d0f2863cb038dc652abc780245c42acf50dcef0", "size": 2021, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Monads/EM/Adjunction.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/EM/Adjunction.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/EM/Adjunction.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.9466666667, "max_line_length": 68, "alphanum_fraction": 0.5091538842, "num_tokens": 884, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757870046160257, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5797034527274919}} {"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Naturals\nopen import Numbers.Naturals.EuclideanAlgorithm\nopen import Semirings.Definition\nopen import Orders.Total.Definition\n\nmodule Numbers.Modulo.ModuloFunction where\n\nopen TotalOrder ℕTotalOrder\n\nprivate\n notBigger : (a : ℕ) {n : ℕ} → succ a +N n ≡ a → False\n notBigger (succ a) {n} pr = notBigger a {n} (succInjective pr)\n\n notBigger' : (a : ℕ) {n : ℕ} → succ a +N n ≡ n → False\n notBigger' (succ a) {succ n} pr rewrite Semiring.commutative ℕSemiring a (succ n) | Semiring.commutative ℕSemiring n a = notBigger' _ (succInjective pr)\n\nmod : (n : ℕ) → .(pr : 0 )\nopen import Data.Boolean\nopen import Data.Option\nopen import Data.Tuple using (_⨯_ ; _,_)\nopen import Functional as Fn using (_$_)\nopen import Numeral.Natural\nopen import Numeral.Natural.Function\nopen import Numeral.Natural.Oper hiding (_^_)\n\nemptyTree : BinaryTree{ℓₗ} Unit N\nemptyTree = Leaf <>\n\nsingleton : N → BinaryTree{ℓₗ} Unit N\nsingleton a = Node a emptyTree emptyTree\n\nisLeaf : BinaryTree L N → Bool\nisLeaf (Leaf _) = 𝑇\nisLeaf (Node _ _ _) = 𝐹\n\nisNode : BinaryTree L N → Bool\nisNode (Leaf _) = 𝐹\nisNode (Node _ _ _) = 𝑇\n\nroot : BinaryTree L N → Option(N)\nroot (Leaf _) = None\nroot (Node a _ _) = Some a\n\nflip : BinaryTree L N → BinaryTree L N\nflip (Leaf l) = Leaf l\nflip (Node n l r) = Node n (flip r) (flip l)\n\nfoldPreOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T\nfoldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id\nfoldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) =\n a ▫ₙ_ $\n Fn.swap(foldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $\n Fn.swap(foldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $\n id\n\nfoldInOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T\nfoldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id\nfoldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) =\n Fn.swap(foldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $\n a ▫ₙ_ $\n Fn.swap(foldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $\n id\n\nfoldPostOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T\nfoldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id\nfoldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) =\n Fn.swap(foldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $\n Fn.swap(foldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $\n a ▫ₙ_ $\n id\n\nfoldReversedPreOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T\nfoldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id\nfoldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) =\n a ▫ₙ_ $\n Fn.swap(foldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $\n Fn.swap(foldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $\n id\n\nfoldReversedInOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T\nfoldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id\nfoldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) =\n Fn.swap(foldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $\n a ▫ₙ_ $\n Fn.swap(foldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $\n id\n\nfoldReversedPostOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T\nfoldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id\nfoldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) =\n Fn.swap(foldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $\n Fn.swap(foldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $\n a ▫ₙ_ $\n id\n\n-- The size is the number of nodes in the tree.\nsize : BinaryTree L N → ℕ\nsize (Leaf _) = 𝟎\nsize (Node _ l r) = 𝐒(size(l) + size(r))\n\n-- The number of leaves in the tree.\nnumberOfLeaves : BinaryTree L N → ℕ\nnumberOfLeaves (Leaf _) = 1\nnumberOfLeaves (Node _ l r) = numberOfLeaves(l) + numberOfLeaves(r)\n\n-- The height is the length of the longest path from the root.\nheight : BinaryTree L N → ℕ\nheight (Leaf _) = 𝟎\nheight (Node _ l r) = 𝐒(max (height l) (height r))\n\nopen import Data.Boolean.Operators\nopen Data.Boolean.Operators.Programming\n\nisFull : BinaryTree L N → Bool\nisFull (Leaf _) = 𝑇\nisFull (Node _ (Leaf _) (Leaf _)) = 𝑇\nisFull (Node _ (Node _ _ _) (Leaf _)) = 𝐹\nisFull (Node _ (Leaf _) (Node _ _ _)) = 𝐹\nisFull (Node _ l@(Node _ _ _) r@(Node _ _ _)) = isFull l && isFull r\n\nopen import Data.List\nimport Data.List.Functions as List\n\ntreesOfDepth : ℕ → BinaryTree L N → List(BinaryTree L N)\ntreesOfDepth 𝟎 tree = tree ⊰ ∅\ntreesOfDepth (𝐒(_)) (Leaf _) = ∅\ntreesOfDepth (𝐒(n)) (Node _ l r) = (treesOfDepth n l) List.++ (treesOfDepth n r)\n", "meta": {"hexsha": "4e6418adb454b55ce849243a3c635fb0d2af934d", "size": 4717, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/BinaryTree.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/BinaryTree.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/BinaryTree.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.8515625, "max_line_length": 164, "alphanum_fraction": 0.6048335807, "num_tokens": 1761, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.817574471748733, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.5796759437640918}} {"text": "{-# OPTIONS --copatterns #-}\n\nopen import Common.Equality\nopen import Common.Product\n\nid : {A : Set} → A → A\nid x = x\n\nrecord Functor (F : Set → Set) : Set₁ where\n field\n map : ∀ {A B} → (A → B) → F A → F B\n map-id : ∀ {A}{x : F A} → map id x ≡ x\nopen Functor\n\ntest : {C : Set} → Functor (_×_ C)\nmap test f (c , a) = c , f a\nmap-id test = refl -- : map test id x ≡ x\n -- needs to match against record constructor\n -- x/(c,a) = proj₁ x / c, proj₂ x / a\n", "meta": {"hexsha": "38b9c99d43b89335e56640828f68aea3c221b943", "size": 474, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue959.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/Issue959.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/Issue959.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.7, "max_line_length": 51, "alphanum_fraction": 0.5400843882, "num_tokens": 171, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577681013541611, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5796493243795934}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- A bunch of properties about natural number operations\n------------------------------------------------------------------------\n\n-- See README.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\nopen import Algebra.Morphism\nopen import Function\nopen import Function.Injection using (_↣_)\nopen import Data.Nat.Base\nopen import Data.Product\nopen import Data.Sum\nopen import Data.Empty\nopen import Data.Bool.Base using (Bool; false; true; T)\nopen import Data.Bool.Properties using (T?)\n\nopen import Level using (0ℓ)\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality\n\nopen import Relation.Nullary\nopen import Relation.Nullary.Decidable using (True; via-injection; map′)\nopen import Relation.Nullary.Negation using (contradiction)\n\nopen import Algebra.FunctionProperties (_≡_ {A = ℕ})\n hiding (LeftCancellative; RightCancellative; Cancellative)\nopen import Algebra.FunctionProperties\n using (LeftCancellative; RightCancellative; Cancellative)\nopen import Algebra.FunctionProperties.Consequences.Propositional\nopen import Algebra.Structures (_≡_ {A = ℕ})\nopen ≡-Reasoning\n\n------------------------------------------------------------------------\n-- Properties of _≡_\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≡ᵇ⇒≡ zero (suc n) ()\n≡ᵇ⇒≡ (suc m) zero ()\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≡⇒≡ᵇ zero (suc n) ()\n≡⇒≡ᵇ (suc m) zero ()\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 sill takes a linear amount of time to generate the proof if it\n-- is inspected. We expect the main benefit to be visible in compiled\n-- code: the 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\n------------------------------------------------------------------------\n-- Properties of _≤_\n\n≤-pred : ∀ {m n} → suc m ≤ suc n → m ≤ n\n≤-pred (s≤s m≤n) = m≤n\n\n-- Relation-theoretic properties of _≤_\n≤-reflexive : _≡_ ⇒ _≤_\n≤-reflexive {zero} refl = z≤n\n≤-reflexive {suc m} refl = s≤s (≤-reflexive refl)\n\n≤-refl : Reflexive _≤_\n≤-refl = ≤-reflexive refl\n\n≤-antisym : Antisymmetric _≡_ _≤_\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≤-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\ninfix 4 _≤?_ _≥?_\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_≥?_ : Decidable _≥_\n_≥?_ = flip _≤?_\n\n≤-isPreorder : IsPreorder _≡_ _≤_\n≤-isPreorder = record\n { isEquivalence = isEquivalence\n ; reflexive = ≤-reflexive\n ; trans = ≤-trans\n }\n\n≤-preorder : Preorder 0ℓ 0ℓ 0ℓ\n≤-preorder = record\n { isPreorder = ≤-isPreorder\n }\n\n≤-isPartialOrder : IsPartialOrder _≡_ _≤_\n≤-isPartialOrder = record\n { isPreorder = ≤-isPreorder\n ; antisym = ≤-antisym\n }\n\n≤-poset : Poset 0ℓ 0ℓ 0ℓ\n≤-poset = record\n { isPartialOrder = ≤-isPartialOrder\n }\n\n≤-isTotalOrder : IsTotalOrder _≡_ _≤_\n≤-isTotalOrder = record\n { isPartialOrder = ≤-isPartialOrder\n ; total = ≤-total\n }\n\n≤-totalOrder : TotalOrder 0ℓ 0ℓ 0ℓ\n≤-totalOrder = record\n { isTotalOrder = ≤-isTotalOrder\n }\n\n≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_\n≤-isDecTotalOrder = record\n { isTotalOrder = ≤-isTotalOrder\n ; _≟_ = _≟_\n ; _≤?_ = _≤?_\n }\n\n≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ\n≤-decTotalOrder = record\n { isDecTotalOrder = ≤-isDecTotalOrder\n }\n\n-- Other properties of _≤_\ns≤s-injective : ∀ {m n} {p q : m ≤ n} → s≤s p ≡ s≤s q → p ≡ q\ns≤s-injective refl = refl\n\n≤-irrelevant : Irrelevant _≤_\n≤-irrelevant z≤n z≤n = refl\n≤-irrelevant (s≤s m≤n₁) (s≤s m≤n₂) = cong s≤s (≤-irrelevant m≤n₁ m≤n₂)\n\n≤-step : ∀ {m n} → m ≤ n → m ≤ 1 + n\n≤-step z≤n = z≤n\n≤-step (s≤s m≤n) = s≤s (≤-step m≤n)\n\nn≤1+n : ∀ n → n ≤ 1 + n\nn≤1+n _ = ≤-step ≤-refl\n\n1+n≰n : ∀ {n} → 1 + n ≰ n\n1+n≰n (s≤s le) = 1+n≰n le\n\nn≤0⇒n≡0 : ∀ {n} → n ≤ 0 → n ≡ 0\nn≤0⇒n≡0 z≤n = refl\n\n------------------------------------------------------------------------\n-- Properties of _<_\n\n-- Relation theoretic properties of _<_\n\n<-irrefl : Irreflexive _≡_ _<_\n<-irrefl refl (s≤s n (λ()) (λ()) (s≤s z≤n)\n<-cmp (suc m) (suc n) with <-cmp m n\n... | tri< ≤ ≢ ≱ = tri< (s≤s ≤) (≢ ∘ suc-injective) (≱ ∘ ≤-pred)\n... | tri≈ ≰ ≡ ≱ = tri≈ (≰ ∘ ≤-pred) (cong suc ≡) (≱ ∘ ≤-pred)\n... | tri> ≰ ≢ ≥ = tri> (≰ ∘ ≤-pred) (≢ ∘ suc-injective) (s≤s ≥)\n\ninfix 4 _?_\n\n_?_ : Decidable _>_\n_>?_ = flip _ : _≰_ ⇒ _>_\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\nn≮n : ∀ n → n ≮ n\nn≮n n = <-irrefl (refl {x = n})\n\nm′?_\n\n_≤′?_ : Decidable _≤′_\nx ≤′? y = map′ ≤⇒≤′ ≤′⇒≤ (x ≤? y)\n\n_<′?_ : Decidable _<′_\nx <′? y = suc x ≤′? y\n\n_≥′?_ : Decidable _≥′_\n_≥′?_ = flip _≤′?_\n\n_>′?_ : Decidable _>′_\n_>′?_ = flip _<′?_\n\n------------------------------------------------------------------------\n-- Properties of pred\n\npred-mono : pred Preserves _≤_ ⟶ _≤_\npred-mono z≤n = z≤n\npred-mono (s≤s le) = le\n\n≤pred⇒≤ : ∀ {m n} → m ≤ pred n → m ≤ n\n≤pred⇒≤ {m} {zero} le = le\n≤pred⇒≤ {m} {suc n} le = ≤-step le\n\n≤⇒pred≤ : ∀ {m n} → m ≤ n → pred m ≤ n\n≤⇒pred≤ {zero} le = le\n≤⇒pred≤ {suc m} le = ≤-trans (n≤1+n m) le\n\nm≢0⇒suc[pred[m]]≡m : ∀ {m} → m ≢ 0 → suc (pred m) ≡ m\nm≢0⇒suc[pred[m]]≡m {zero} m≢0 = ⊥-elim (m≢0 refl)\nm≢0⇒suc[pred[m]]≡m {suc m} m≢0 = refl\n\n------------------------------------------------------------------------\n-- Properties of _+_\n\n-- Algebraic properties of _+_\n+-suc : ∀ m n → m + suc n ≡ suc (m + n)\n+-suc zero n = refl\n+-suc (suc m) n = cong suc (+-suc m n)\n\n+-assoc : Associative _+_\n+-assoc zero _ _ = refl\n+-assoc (suc m) n o = cong suc (+-assoc m n o)\n\n+-identityˡ : LeftIdentity 0 _+_\n+-identityˡ _ = refl\n\n+-identityʳ : RightIdentity 0 _+_\n+-identityʳ zero = refl\n+-identityʳ (suc n) = cong suc (+-identityʳ n)\n\n+-identity : Identity 0 _+_\n+-identity = +-identityˡ , +-identityʳ\n\n+-comm : Commutative _+_\n+-comm zero n = sym (+-identityʳ n)\n+-comm (suc m) n = begin\n suc m + n ≡⟨⟩\n suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩\n suc (n + m) ≡⟨ sym (+-suc n m) ⟩\n n + suc m ∎\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+-0-isMonoid : IsMonoid _+_ 0\n+-0-isMonoid = record\n { isSemigroup = +-isSemigroup\n ; identity = +-identity\n }\n\n+-0-monoid : Monoid 0ℓ 0ℓ\n+-0-monoid = record\n { isMonoid = +-0-isMonoid\n }\n\n+-0-isCommutativeMonoid : IsCommutativeMonoid _+_ 0\n+-0-isCommutativeMonoid = record\n { isSemigroup = +-isSemigroup\n ; identityˡ = +-identityˡ\n ; comm = +-comm\n }\n\n+-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ\n+-0-commutativeMonoid = record\n { isCommutativeMonoid = +-0-isCommutativeMonoid\n }\n\n-- Other properties of _+_ and _≡_\n\n+-cancelˡ-≡ : LeftCancellative _≡_ _+_\n+-cancelˡ-≡ zero eq = eq\n+-cancelˡ-≡ (suc m) eq = +-cancelˡ-≡ m (cong pred eq)\n\n+-cancelʳ-≡ : RightCancellative _≡_ _+_\n+-cancelʳ-≡ = comm+cancelˡ⇒cancelʳ +-comm +-cancelˡ-≡\n\n+-cancel-≡ : Cancellative _≡_ _+_\n+-cancel-≡ = +-cancelˡ-≡ , +-cancelʳ-≡\n\nm≢1+m+n : ∀ m {n} → m ≢ suc (m + n)\nm≢1+m+n zero ()\nm≢1+m+n (suc m) eq = m≢1+m+n m (cong pred eq)\n\nm≢1+n+m : ∀ m {n} → m ≢ suc (n + m)\nm≢1+n+m m m≡1+n+m = m≢1+m+n m (trans m≡1+n+m (cong suc (+-comm _ m)))\n\ni+1+j≢i : ∀ i {j} → i + suc j ≢ i\ni+1+j≢i zero ()\ni+1+j≢i (suc i) = (i+1+j≢i i) ∘ suc-injective\n\ni+j≡0⇒i≡0 : ∀ i {j} → i + j ≡ 0 → i ≡ 0\ni+j≡0⇒i≡0 zero eq = refl\ni+j≡0⇒i≡0 (suc i) ()\n\ni+j≡0⇒j≡0 : ∀ i {j} → i + j ≡ 0 → j ≡ 0\ni+j≡0⇒j≡0 i {j} i+j≡0 = i+j≡0⇒i≡0 j (trans (+-comm j i) (i+j≡0))\n\n-- Properties of _+_ and orderings\n\n+-cancelˡ-≤ : LeftCancellative _≤_ _+_\n+-cancelˡ-≤ zero le = le\n+-cancelˡ-≤ (suc m) (s≤s le) = +-cancelˡ-≤ m le\n\n+-cancelʳ-≤ : RightCancellative _≤_ _+_\n+-cancelʳ-≤ {m} n o le =\n +-cancelˡ-≤ m (subst₂ _≤_ (+-comm n m) (+-comm o m) le)\n\n+-cancel-≤ : Cancellative _≤_ _+_\n+-cancel-≤ = +-cancelˡ-≤ , +-cancelʳ-≤\n\n+-cancelˡ-< : LeftCancellative _<_ _+_\n+-cancelˡ-< x {y} {z} = +-cancelˡ-≤ x ∘ subst (_≤ x + z) (sym (+-suc x y))\n\n+-cancelʳ-< : RightCancellative _<_ _+_\n+-cancelʳ-< y z y+x″?_\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-- irrelevance\n\n≤″-irrelevant : Irrelevant _≤″_\n≤″-irrelevant {m} (less-than-or-equal {k₁} eq₁)\n (less-than-or-equal {k₂} 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-- Other properties\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-- A module for reasoning about the _≤_ and _<_ relations\n\nmodule ≤-Reasoning where\n open import Relation.Binary.Reasoning.Base.Triple\n ≤-isPreorder\n <-trans\n (resp₂ _<_)\n <⇒≤\n <-transˡ\n <-transʳ\n public\n hiding (_≈⟨_⟩_)\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 = i+1+j≰i\n{-# WARNING_ON_USAGE ¬i+1+j≤i\n\"Warning: ¬i+1+j≤i was deprecated in v0.15.\nPlease use i+1+j≰i 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\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\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\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", "meta": {"hexsha": "c878d4993f2b53ac3b12dfee9ff279c846085f61", "size": 50927, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/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/Nat/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/Nat/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.6751126126, "max_line_length": 89, "alphanum_fraction": 0.4983211263, "num_tokens": 28165, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.5793067055366733}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some properties of equivalence closures.\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Relation.Binary.Construct.Closure.Equivalence.Properties where\n\nopen import Data.Sum.Base using (inj₁)\nopen import Function using (_∘′_)\nopen import Relation.Binary.Core using (Rel)\nopen import Relation.Binary.Construct.Closure.Equivalence\nopen import Relation.Binary.Construct.Closure.ReflexiveTransitive as RTrans\n\nmodule _ {a ℓ} {A : Set a} {_⟶_ : Rel A ℓ} where\n\n private\n _—↠_ = Star _⟶_\n _↔_ = EqClosure _⟶_\n\n a—↠b⇒a↔b : ∀ {a b} → a —↠ b → a ↔ b\n a—↠b⇒a↔b = RTrans.map inj₁\n\n a—↠b⇒b↔a : ∀ {a b} → a —↠ b → b ↔ a\n a—↠b⇒b↔a = symmetric _ ∘′ a—↠b⇒a↔b\n\n a—↠b&a—↠c⇒b↔c : ∀ {a b c} → a —↠ b → a —↠ c → b ↔ c\n a—↠b&a—↠c⇒b↔c a—↠b b—↠c = a—↠b⇒b↔a a—↠b ◅◅ a—↠b⇒a↔b b—↠c\n", "meta": {"hexsha": "d5b66ba124a9f90d5f192cd439e9b6df84116d2a", "size": 946, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Construct/Closure/Equivalence/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/Relation/Binary/Construct/Closure/Equivalence/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/Relation/Binary/Construct/Closure/Equivalence/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.5161290323, "max_line_length": 75, "alphanum_fraction": 0.521141649, "num_tokens": 373, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8705972549785201, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.5793046058786996}} {"text": "module Min where\n\nopen import Data.Nat using (ℕ; zero; suc)\nopen import Algebra.Bundles using (CommutativeRing)\nopen import Algebra.Module.Bundles using (Module)\nopen import Data.Product using (Σ-syntax; ∃-syntax; _×_; proj₁; proj₂; _,_)\nopen import Data.Sum using (_⊎_; inj₁; inj₂)\nopen import Relation.Binary.Core using (Rel)\nimport Algebra.Module.Construct.Zero as Zero\nimport Algebra.Module.Construct.DirectProduct as Prod\nimport Algebra.Module.Construct.TensorUnit as Unit\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 open import Linear MA MB\n\n module _\n {rel} (_<_ : Rel (CommutativeRing.Carrier CR) rel)\n (∥_∥ᴬ : A → R)\n (∥_∥ᴮ : B → R)\n (_÷_ : B → R → B)\n where\n\n\n _LimitOf_x→_ Limit-syntax : (L : B) (f : A → B) (c : A)→ Set _\n L LimitOf f x→ c = ∀ ε → ∃[ δ ] ∥ (f (c +ᴬ δ) -ᴮ L) ∥ᴮ < ∥ ε ∥ᴮ\n Limit-syntax = _LimitOf_x→_\n\n\n syntax Limit-syntax L (λ h → f) c = L LimitOf f ∶ h ⟶ c\n\n\n Diff' : (f : A → B) (x : A) (f' : A → A → B) → Set _\n Diff' f x f' = 0ᴮ LimitOf tmp dx ∶ dx ⟶ 0ᴬ\n where\n tmp : (dx : A) → B\n tmp dx = (f (x +ᴬ dx) -ᴮ f x -ᴮ f' x dx) ÷ ∥ dx ∥ᴬ\n\n\n Differentiable : (f : A → B) → A → Set _\n Differentiable f x =\n Σ[ f' ∈ (A → A → B) ]\n Linear (f' x)\n -- × ∀ dy → ∃[ dx ] (∥ ((f (x +ᴬ dx) -ᴮ f x) -ᴮ (f' x dx)) ∥ᴮ) < (∥ dy ∥ᴮ)\n \n D : {f : A → B} {x : A} (d : Differentiable f x) → A → B\n D {x = x} d = proj₁ d x\n\n\nn-module : ∀ {a b} {S : CommutativeRing a b} → ℕ → Module S a b\nn-module zero = Zero.⟨module⟩\nn-module (suc n) = Prod.⟨module⟩ Unit.⟨module⟩ (n-module n)\n\nopen import Tactic.RingSolver\n\nmodule Line {a b} (CR : CommutativeRing a b) where\n open CommutativeRing CR\n open import Relation.Binary.Reasoning.Setoid setoid\n\n open import Tactic.RingSolver.Core.AlmostCommutativeRing\n\n line : Carrier → Carrier → Carrier → Carrier\n line m b x = m * x + b\n\n x+y-x≈y : ∀ x y → (x + y) - x ≈ y\n x+y-x≈y x y =\n begin\n (x + y) - x\n ≈⟨ +-assoc x y (- x) ⟩\n x + (y - x)\n ≈⟨ +-cong refl (+-comm y (- x)) ⟩\n x + (- x + y)\n ≈⟨ sym (+-assoc x (- x) y) ⟩\n (x - x) + y\n ≈⟨ +-cong (proj₂ -‿inverse x) refl ⟩\n 0# + y\n ≈⟨ +-identityˡ y ⟩\n y\n ∎\n\n x+y+z≈x+z+y : ∀ x y z → x + y + z ≈ x + z + y\n x+y+z≈x+z+y x y z =\n begin\n (x + y) + z\n ≈⟨ +-assoc x y z ⟩\n x + (y + z)\n ≈⟨ +-cong refl (+-comm y z) ⟩\n x + (z + y)\n ≈⟨ sym (+-assoc x z y) ⟩\n (x + z) + y\n ∎\n\n linear-diff : ∀ m b x dy → line m b (x + dy) - line m b x ≈ m * dy\n linear-diff m b x dy =\n begin\n m * (x + dy) + b - (m * x + b)\n ≈⟨ +-cong (+-cong (distribˡ m x dy) refl) refl ⟩\n m * x + m * dy + b - (m * x + b)\n ≈⟨ +-cong (x+y+z≈x+z+y (m * x) (m * dy) b) refl ⟩\n m * x + b + m * dy - (m * x + b)\n ≈⟨ x+y-x≈y (m * x + b) (m * dy) ⟩\n m * dy\n ∎\n\n", "meta": {"hexsha": "a9dc5f56b1ea7b5a16f26221bffa8675e237ce62", "size": 2917, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Min.agda", "max_stars_repo_name": "cspollard/diff", "max_stars_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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/Min.agda", "max_issues_repo_name": "cspollard/diff", "max_issues_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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/Min.agda", "max_forks_repo_name": "cspollard/diff", "max_forks_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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.5181818182, "max_line_length": 82, "alphanum_fraction": 0.5005142269, "num_tokens": 1257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615381952105442, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.5792394443501938}} {"text": "{-# OPTIONS --cubical --safe #-}\n\nmodule Hyper where\n\nopen import Prelude hiding (⊥)\nopen import Data.Empty.UniversePolymorphic\nopen import Data.List using (List; _∷_; [])\nopen import Data.Vec.Iterated\nopen import Data.Nat using (_*_; _+_)\nopen import Data.Nat.Properties using (Even; Odd)\n\n\nprivate\n variable n m : ℕ\n\ninfixr 4 _#_↬_\n_#_↬_ : ℕ → Type a → Type b → Type (a ℓ⊔ b)\nzero # A ↬ B = ⊥\nsuc n # A ↬ B = n # B ↬ A → B\n\nmodule _ {a b} {A : Type a} {B : Type b} where\n yfld : Vec B n → 1 + (n * 2) # List (A × B) ↬ (A → List (A × B))\n yfld =\n foldr\n (λ n → 1 + (n * 2) # List (A × B) ↬ (A → List (A × B)))\n (λ y yk xk x → (x , y) ∷ xk yk)\n (λ ())\n\n xfld : Vec A n → (1 + n) * 2 # (A → List (A × B)) ↬ List (A × B)\n xfld =\n foldr\n (λ n → (1 + n) * 2 # (A → List (A × B)) ↬ List (A × B))\n (λ x xk yk → yk xk x)\n (λ _ → [])\n\n zip : Vec A n → Vec B n → List (A × B)\n zip xs ys = xfld xs (yfld ys)\n\ncata : Even n → (((C → A) → B) → C) → n # A ↬ B → C\ncata {n = suc (suc n)} e ϕ h = ϕ (λ g → h (g ∘ cata e ϕ))\n\npush : (A → B) → n # A ↬ B → 2 + n # A ↬ B\npush {n = suc n} f q k = f (k q)\n\none : Odd n → n # A ↬ A\none {n = suc zero} o ()\none {n = suc (suc n)} o k = k (one o)\n", "meta": {"hexsha": "fc91d7242621a285fec81f6b262c96661c54a4d5", "size": 1217, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Hyper.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": "Hyper.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": "Hyper.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": 25.3541666667, "max_line_length": 66, "alphanum_fraction": 0.4806902219, "num_tokens": 536, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.5792394425982146}} {"text": "module Numeral.Natural.Combinatorics.Proofs where\n\nopen import Functional\nimport Lvl\nopen import Logic\nopen import Logic.Propositional\nopen import Numeral.Natural\nopen import Numeral.Natural.Combinatorics\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Oper.Proofs.Multiplication\nopen import Numeral.Natural.Relation\nopen import Numeral.Natural.Relation.Order\nopen import Numeral.Natural.Relation.Order.Proofs\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Relator.Equals.Proofs.Equiv\nopen import Structure.Setoid hiding (_≡_ ; _≢_)\nopen import Structure.Function.Domain\nopen import Structure.Function\nopen import Structure.Operator.Proofs.Util\nopen import Structure.Operator.Properties\nopen import Structure.Operator\nopen import Structure.Relator.Properties\nopen import Syntax.Function\nopen import Syntax.Transitivity\nopen import Type\n\nfactorial-non-zero : ∀{n} → ((n !) ≢ 𝟎)\nfactorial-non-zero {𝟎} ()\nfactorial-non-zero {𝐒 n} p with [⋅]-product-is-0 {a = 𝐒 n}{b = n !} p\n... | [∨]-introᵣ n!0 = factorial-non-zero {n} n!0\n\ninstance\n factorial-positive : ∀{n} → Positive(n !)\n factorial-positive {n} = non-zero-positive(factorial-non-zero {n})\n\n-- Also called: Pascals's identity\n𝑐𝐶-step : ∀{n k} → (𝑐𝐶 (𝐒(n)) (𝐒(k)) ≡ 𝑐𝐶 n k + 𝑐𝐶 n (𝐒(k)))\n𝑐𝐶-step = [≡]-intro\n\n𝑐𝐶-empty-subsets : ∀{n} → (𝑐𝐶 n 𝟎 ≡ 𝐒(𝟎))\n𝑐𝐶-empty-subsets {𝟎} = [≡]-intro\n𝑐𝐶-empty-subsets {𝐒 n} = [≡]-intro\n\n𝑐𝐶-singleton-subsets : ∀{n} → (𝑐𝐶 n (𝐒 𝟎) ≡ n)\n𝑐𝐶-singleton-subsets {𝟎} = [≡]-intro\n𝑐𝐶-singleton-subsets {𝐒 n} = congruence₁(𝐒) (𝑐𝐶-singleton-subsets {n})\n{-# REWRITE 𝑐𝐶-singleton-subsets #-}\n\n𝑐𝐶-larger-subsets : ∀{n k} → (n < k) → (𝑐𝐶 n k ≡ 𝟎)\n𝑐𝐶-larger-subsets {𝟎} (succ _) = [≡]-intro\n𝑐𝐶-larger-subsets {𝐒 n} {𝐒 k} (succ p)\n rewrite 𝑐𝐶-larger-subsets {n} {k} p\n rewrite 𝑐𝐶-larger-subsets {n} {𝐒 k} ([≤]-successor p)\n = [≡]-intro\n\n𝑐𝐶-full-subsets : ∀{n} → (𝑐𝐶 n n ≡ 𝐒(𝟎))\n𝑐𝐶-full-subsets {𝟎} = [≡]-intro\n𝑐𝐶-full-subsets {𝐒 n}\n rewrite 𝑐𝐶-full-subsets {n}\n rewrite 𝑐𝐶-larger-subsets {n}{𝐒 n} (reflexivity(_≤_))\n = [≡]-intro\n\n𝑐𝐶-excluding-single-subsets : ∀{n} → (𝑐𝐶 (𝐒 n) n ≡ 𝐒(n))\n𝑐𝐶-excluding-single-subsets {𝟎} = [≡]-intro\n𝑐𝐶-excluding-single-subsets {𝐒 n}\n rewrite 𝑐𝐶-excluding-single-subsets {n}\n rewrite 𝑐𝐶-full-subsets {n}\n rewrite 𝑐𝐶-larger-subsets {n}{𝐒 n} (reflexivity(_≤_))\n = [≡]-intro\n\n{-\n𝑐𝐶-test2 : ∀{k₁ k₂} → (𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁) ≡ 𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₂))\n𝑐𝐶-test2 {𝟎} {𝟎} = [≡]-intro\n𝑐𝐶-test2 {𝟎} {𝐒 k₂}\n rewrite 𝑐𝐶-full-subsets {k₂}\n rewrite 𝑐𝐶-larger-subsets {k₂} (reflexivity(_≤_))\n rewrite 𝑐𝐶-larger-subsets {k₂} ([≤]-successor(reflexivity(_≤_)))\n rewrite 𝑐𝐶-excluding-single-subsets {k₂}\n = [≡]-intro\n𝑐𝐶-test2 {𝐒 k₁} {𝟎}\n rewrite 𝑐𝐶-full-subsets {k₁}\n rewrite 𝑐𝐶-larger-subsets {k₁} (reflexivity(_≤_))\n rewrite 𝑐𝐶-larger-subsets {k₁} ([≤]-successor(reflexivity(_≤_)))\n rewrite 𝑐𝐶-excluding-single-subsets {k₁}\n = [≡]-intro\n𝑐𝐶-test2 {𝐒 k₁} {𝐒 k₂}\n -- rewrite test2 {k₁ + k₂} {k₁} {k₂} [≡]-intro\n -- rewrite test2 {𝐒(k₁ + k₂)} {𝐒 k₁} {k₂} [≡]-intro\n -- rewrite test2 {𝐒(k₁ + k₂)} {k₁} {𝐒 k₂} [≡]-intro\n = {!!}\n\n𝑐𝐶-symmetric : ∀{n k₁ k₂} → (k₁ + k₂ ≡ n) → (𝑐𝐶 n k₁ ≡ 𝑐𝐶 n k₂)\n𝑐𝐶-symmetric {𝟎} {𝟎} {𝟎} x = [≡]-intro\n𝑐𝐶-symmetric {𝐒 n} {𝟎} {𝐒 .n} [≡]-intro\n rewrite 𝑐𝐶-full-subsets {n}\n rewrite 𝑐𝐶-larger-subsets {n} (reflexivity(_≤_))\n = [≡]-intro\n𝑐𝐶-symmetric {𝐒 n} {𝐒 .n} {𝟎} [≡]-intro\n rewrite 𝑐𝐶-full-subsets {n}\n rewrite 𝑐𝐶-larger-subsets {n} (reflexivity(_≤_))\n = [≡]-intro\n𝑐𝐶-symmetric {𝐒 .(𝐒(k₁ + k₂))} {𝐒 k₁} {𝐒 k₂} [≡]-intro\n =\n 𝑐𝐶 (𝐒(𝐒(k₁ + k₂))) (𝐒 k₁) 🝖[ _≡_ ]-[]\n 𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + 𝑐𝐶 (𝐒(k₁ + k₂)) (𝐒 k₁) 🝖[ _≡_ ]-[]\n 𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + (𝑐𝐶 (k₁ + k₂) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)) 🝖[ _≡_ ]-[ One.commuteₗ-assocᵣ {_▫_ = _+_}{a = 𝑐𝐶 (𝐒(k₁ + k₂)) k₁}{b = 𝑐𝐶 (k₁ + k₂) k₁}{c = 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)} ]\n 𝑐𝐶 (k₁ + k₂) k₁ + (𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)) 🝖[ _≡_ ]-[ congruence₂(_+_) (𝑐𝐶-symmetric {k₁ + k₂} {k₁} {k₂} [≡]-intro) (𝑐𝐶-test2 {k₁}{k₂}) ]\n 𝑐𝐶 (k₁ + k₂) k₂ + (𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₂)) 🝖[ _≡_ ]-[ One.commuteₗ-assocᵣ {_▫_ = _+_}{a = 𝑐𝐶 (𝐒(k₁ + k₂)) k₂}{b = 𝑐𝐶 (k₁ + k₂) k₂}{c = 𝑐𝐶 (k₁ + k₂) (𝐒 k₂)} ]-sym\n 𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + (𝑐𝐶 (k₁ + k₂) k₂ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₂)) 🝖[ _≡_ ]-[]\n 𝑐𝐶 (𝐒(k₁ + k₂)) k₂ + 𝑐𝐶 (𝐒(k₁ + k₂)) (𝐒 k₂) 🝖[ _≡_ ]-[]\n 𝑐𝐶 (𝐒(𝐒(k₁ + k₂))) (𝐒 k₂) 🝖-end\n-}\n\n\n-- ∀{n k} → 𝑐𝐶 n k ≡ 𝑐𝐶 n (n−k)\n-- ∀{n k} → 𝑐𝐶 (𝐒 n) (𝐒 k) ≡ 𝑐𝐶 n k ⋅ (𝐒 n) / (𝐒 k)\n-- ∀{n} → (∑(𝟎 ‥ n) (𝑐𝐶 n) ≡ 2 ^ n)\n-- ∀{n k} → (𝑐𝐶 (𝐒 n) (𝐒 k) ≡ ∑(0 ‥ n) (i ↦ 𝑐𝐶 i k) = ∑(k ‥ n) (i ↦ 𝑐𝐶 i k))\n\n𝑐𝑃-empty : ∀{n} → (𝑐𝑃 n 𝟎 ≡ 𝐒(𝟎))\n𝑐𝑃-empty {𝟎} = [≡]-intro\n𝑐𝑃-empty {𝐒 n} = [≡]-intro\n\n𝑐𝑃-singleton : ∀{n} → (𝑐𝑃 n (𝐒 𝟎) ≡ n)\n𝑐𝑃-singleton {𝟎} = [≡]-intro\n𝑐𝑃-singleton {𝐒 n} = [≡]-intro\n{-# REWRITE 𝑐𝑃-singleton #-}\n\n𝑐𝑃-step-diff : ∀{n k} → (𝑐𝑃 n k ⋅ n ≡ 𝑐𝑃 n k ⋅ k + 𝑐𝑃 n (𝐒 k)) -- TODO: Prove this for 𝑐𝐶 by using 𝑐𝐶-permutations-is-𝑐𝑃\n𝑐𝑃-step-diff {𝟎} {𝟎} = [≡]-intro\n𝑐𝑃-step-diff {𝟎} {𝐒 k} = [≡]-intro\n𝑐𝑃-step-diff {𝐒 n} {𝟎} = [≡]-intro\n𝑐𝑃-step-diff {𝐒 n} {𝐒 k} =\n 𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ (𝐒 n) 🝖[ _≡_ ]-[]\n (𝑐𝑃 n k ⋅ (𝐒 n)) ⋅ (𝐒 n) 🝖[ _≡_ ]-[]\n (𝑐𝑃 n k + 𝑐𝑃 n k ⋅ n) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝑃 n k}{y = 𝑐𝑃 n k ⋅ n}{z = 𝐒 n} ]\n (𝑐𝑃 n k ⋅ (𝐒 n)) + ((𝑐𝑃 n k ⋅ n) ⋅ (𝐒 n)) 🝖[ _≡_ ]-[ congruence₂(_+_) (reflexivity(_≡_) {x = 𝑐𝑃 (𝐒 n) (𝐒 k)}) proof1 ]\n 𝑐𝑃 (𝐒 n) (𝐒 k) + ((𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k))) 🝖[ _≡_ ]-[ associativity(_+_) {x = 𝑐𝑃 (𝐒 n) (𝐒 k)}{y = 𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k}{z = 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k))} ]-sym\n (𝑐𝑃 (𝐒 n) (𝐒 k) + (𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k)) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k)) 🝖[ _≡_ ]-[]\n (𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ 𝐒 k) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k)) 🝖-end\n where\n proof2 =\n (𝑐𝑃 n k ⋅ k) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ One.commuteᵣ-assocₗ {_▫_ = _⋅_}{a = 𝑐𝑃 n k}{b = k}{c = 𝐒 n} ]\n (𝑐𝑃 n k ⋅ (𝐒 n)) ⋅ k 🝖[ _≡_ ]-[]\n 𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k 🝖-end\n\n proof1 =\n (𝑐𝑃 n k ⋅ n) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(𝐒 n) (𝑐𝑃-step-diff {n}{k}) ]\n (𝑐𝑃 n k ⋅ k + 𝑐𝑃 n (𝐒 k)) ⋅ (𝐒 n) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝑃 n k ⋅ k}{y = 𝑐𝑃 n (𝐒 k)}{z = 𝐒 n} ]\n ((𝑐𝑃 n k ⋅ k) ⋅ (𝐒 n)) + (𝑐𝑃 n (𝐒 k) ⋅ (𝐒 n)) 🝖[ _≡_ ]-[ congruence₂(_+_) proof2 (reflexivity(_≡_)) ]\n (𝑐𝑃 (𝐒 n) (𝐒 k) ⋅ k) + 𝑐𝑃 (𝐒 n) (𝐒(𝐒 k)) 🝖-end\n\n𝑐𝑃-step-alt : ∀{n k} → (𝑐𝑃 (𝐒 n) (𝐒 k) ≡ (𝑐𝑃 n k ⋅ 𝐒 k) + 𝑐𝑃 n (𝐒 k))\n𝑐𝑃-step-alt {n}{k} rewrite 𝑐𝑃-step-diff {n}{k} = symmetry(_≡_) (associativity(_+_) {x = 𝑐𝑃 n k}{y = 𝑐𝑃 n k ⋅ k}{z = 𝑐𝑃 n (𝐒 k)})\n\n𝑐𝐶-permutations-is-𝑐𝑃 : ∀{n k} → (𝑐𝐶 n k ⋅ (k !) ≡ 𝑐𝑃 n k)\n𝑐𝐶-permutations-is-𝑐𝑃 {𝟎} {𝟎} = [≡]-intro\n𝑐𝐶-permutations-is-𝑐𝑃 {𝟎} {𝐒 k} = [≡]-intro\n𝑐𝐶-permutations-is-𝑐𝑃 {𝐒 n} {𝟎} = [≡]-intro\n𝑐𝐶-permutations-is-𝑐𝑃 {𝐒 n} {𝐒 k} =\n (𝑐𝐶 n k + 𝑐𝐶 n (𝐒 k)) ⋅ (𝐒 k ⋅ (k !)) 🝖-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝐶 n k}{y = 𝑐𝐶 n (𝐒 k)}{z = 𝐒 k ⋅ (k !)} ]\n (𝑐𝐶 n k ⋅ (𝐒 k ⋅ (k !))) + (𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k ⋅ (k !))) 🝖-[ congruence₂(_+_) l r ]\n (𝑐𝑃 n k ⋅ 𝐒 k) + 𝑐𝑃 n (𝐒 k) 🝖-[ 𝑐𝑃-step-alt {n}{k} ]-sym\n 𝑐𝑃 n k ⋅ 𝐒 n 🝖-end\n where\n l =\n 𝑐𝐶 n k ⋅ (𝐒 k ⋅ (k !)) 🝖-[ congruence₂ᵣ(_⋅_)(𝑐𝐶 n k) (commutativity(_⋅_) {𝐒 k}{k !}) ]\n 𝑐𝐶 n k ⋅ ((k !) ⋅ 𝐒 k) 🝖-[ associativity(_⋅_) {x = 𝑐𝐶 n k}{y = k !}{z = 𝐒 k} ]-sym\n (𝑐𝐶 n k ⋅ (k !)) ⋅ 𝐒 k 🝖-[ congruence₂ₗ(_⋅_)(𝐒 k) (𝑐𝐶-permutations-is-𝑐𝑃 {n} {k}) ]\n 𝑐𝑃 n k ⋅ 𝐒 k 🝖-end\n\n r =\n 𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k ⋅ (k !)) 🝖[ _≡_ ]-[]\n 𝑐𝐶 n (𝐒 k) ⋅ ((𝐒 k)!) 🝖[ _≡_ ]-[ 𝑐𝐶-permutations-is-𝑐𝑃 {n} {𝐒 k} ]\n 𝑐𝑃 n (𝐒 k) 🝖-end\n\n𝑐𝑃-full : ∀{n} → (𝑐𝑃 n n ≡ n !)\n𝑐𝑃-full {n} =\n 𝑐𝑃 n n 🝖[ _≡_ ]-[ 𝑐𝐶-permutations-is-𝑐𝑃 {n}{n} ]-sym\n 𝑐𝐶 n n ⋅ (n !) 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(n !) (𝑐𝐶-full-subsets {n}) ]\n 𝐒(𝟎) ⋅ (n !) 🝖[ _≡_ ]-[]\n n ! 🝖-end\n\n𝑐𝐶-step-diff : ∀{n k} → (𝑐𝐶 n k ⋅ n ≡ (𝑐𝐶 n k ⋅ k) + (𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k)))\n𝑐𝐶-step-diff {n}{k} = [⋅]-cancellationᵣ {x = k !} ⦃ factorial-positive {k} ⦄ $\n (𝑐𝐶 n k ⋅ n) ⋅ (k !) 🝖[ _≡_ ]-[ One.commuteᵣ-assocₗ {_▫_ = _⋅_}{a = 𝑐𝐶 n k}{b = n}{c = k !} ]\n (𝑐𝐶 n k ⋅ (k !)) ⋅ n 🝖[ _≡_ ]-[ congruence₁(_⋅ n) (𝑐𝐶-permutations-is-𝑐𝑃 {n}{k}) ]\n 𝑐𝑃 n k ⋅ n 🝖[ _≡_ ]-[ 𝑐𝑃-step-diff {n}{k} ]\n 𝑐𝑃 n k ⋅ k + 𝑐𝑃 n (𝐒 k) 🝖[ _≡_ ]-[ congruence₂(_+_) (congruence₁(_⋅ k) (symmetry(_≡_) (𝑐𝐶-permutations-is-𝑐𝑃 {n}{k}))) (symmetry(_≡_) (𝑐𝐶-permutations-is-𝑐𝑃 {n}{𝐒 k})) ]\n (𝑐𝐶 n k ⋅ (k !)) ⋅ k + (𝑐𝐶 n (𝐒 k) ⋅ ((𝐒 k) !)) 🝖[ _≡_ ]-[]\n (𝑐𝐶 n k ⋅ (k !)) ⋅ k + (𝑐𝐶 n (𝐒 k) ⋅ ((𝐒 k) ⋅ (k !))) 🝖[ _≡_ ]-[ congruence₂(_+_) (One.commuteᵣ-assocₗ {_▫_ = _⋅_}{a = 𝑐𝐶 n k}{b = k !}{c = k}) (symmetry(_≡_) (associativity(_⋅_) {x = 𝑐𝐶 n (𝐒 k)}{y = 𝐒 k}{z = k !})) ]\n (𝑐𝐶 n k ⋅ k) ⋅ (k !) + ((𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k)) ⋅ (k !)) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {x = 𝑐𝐶 n k ⋅ k}{y = 𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k)}{z = k !} ]-sym\n ((𝑐𝐶 n k ⋅ k) + (𝑐𝐶 n (𝐒 k) ⋅ (𝐒 k))) ⋅ (k !) 🝖-end\n\n{-\n-- Note: This is a variant of the usual definition of 𝑐𝐶 (The usual one: 𝑐𝐶 n k = (n !) / ((k !) ⋅ (n − k)!)).\nfactorial-of-[+] : ∀{k₁ k₂} → ((k₁ + k₂)! ≡ (k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁)\nfactorial-of-[+] {𝟎} {k₂} = [≡]-intro\nfactorial-of-[+] {𝐒 k₁} {k₂} =\n ((𝐒(k₁) + k₂) !) 🝖[ _≡_ ]-[]\n (𝐒(k₁ + k₂) !) 🝖[ _≡_ ]-[]\n 𝐒(k₁ + k₂) ⋅ ((k₁ + k₂) !) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅_)(𝐒(k₁ + k₂)) (factorial-of-[+] {k₁} {k₂}) ]\n 𝐒(k₁ + k₂) ⋅ ((k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[]\n (𝐒(k₁) + k₂) ⋅ ((k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ]\n ((𝐒(k₁) + k₂) ⋅ (k₁ !)) ⋅ ((k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ]\n ((𝐒(k₁) ⋅ (k₁ !)) + (k₂ ⋅ (k₁ !))) ⋅ ((k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ]\n ((𝐒(k₁) !) + (k₂ ⋅ (k₁ !))) ⋅ ((k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁) 🝖[ _≡_ ]-[ {!!} ]\n (𝐒(k₁) !) ⋅ (k₂ !) ⋅ 𝑐𝐶(𝐒(k₁) + k₂) (𝐒(k₁)) 🝖-end\n\n𝐒 k₁ ⋅ (k₁ !) ⋅ (k₂ !) ⋅ (𝑐𝐶 (k₁ + k₂) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁))\n-}\n{-factorial-of-[+] {𝟎} {𝟎} = [≡]-intro\nfactorial-of-[+] {𝟎} {𝐒 k₂} = [≡]-intro\nfactorial-of-[+] {𝐒 k₁} {𝟎}\n rewrite 𝑐𝐶-full-subsets {k₁}\n rewrite 𝑐𝐶-larger-subsets {k₁} {𝐒 k₁} (reflexivity(_≤_))\n = [≡]-intro\nfactorial-of-[+] {𝐒 k₁} {𝐒 k₂} = {!!}\n𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ ((k₁ + k₂)!))\n𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ ((k₁ !) ⋅ (k₂ !) ⋅ 𝑐𝐶 (k₁ + k₂) k₁))\n𝐒(k₁) ⋅ (k₁ !) ⋅ (𝐒 k₂ ⋅ (k₂ !)) ⋅ (𝑐𝐶 (𝐒(k₁ + k₂)) k₁ + (𝑐𝐶 (k₁ + k₂) k₁ + 𝑐𝐶 (k₁ + k₂) (𝐒 k₁)))\n-}\n\n{-\n-- Note: This is a variant of the usual definition of 𝑐𝑃 (The usual one: 𝑐𝑃 n k = (n !) / ((n − k)!)).\nfactorial-of-[+]-𝑐𝑃 : ∀{k₁ k₂} → ((k₁ + k₂)! ≡ 𝑐𝑃 (k₁ + k₂) k₂ ⋅ (k₁ !))\nfactorial-of-[+]-𝑐𝑃 {𝟎} {𝟎} = [≡]-intro\nfactorial-of-[+]-𝑐𝑃 {𝟎} {𝐒 k₂}\n rewrite 𝑐𝑃-full {k₂}\n =\n 𝐒 k₂ ⋅ (k₂ !) 🝖[ _≡_ ]-[ commutativity(_⋅_) {𝐒 k₂}{k₂ !} ]\n (k₂ !) ⋅ 𝐒 k₂ 🝖[ _≡_ ]-[]\n (k₂ !) + (k₂ !) ⋅ k₂ 🝖-end\nfactorial-of-[+]-𝑐𝑃 {𝐒 k₁} {𝟎} = [≡]-intro\nfactorial-of-[+]-𝑐𝑃 {𝐒 k₁} {𝐒 k₂} = {!!}\n𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ ((k₁ + k₂)!))\n𝐒(𝐒(k₁ + k₂)) ⋅ (𝐒(k₁ + k₂) ⋅ (𝑐𝑃 (k₁ + k₂) k₂ ⋅ (k₁ !)))\n(𝑐𝑃 (𝐒(k₁ + k₂)) k₂ + (𝑐𝑃 (𝐒(k₁ + k₂)) k₂ + 𝑐𝑃 (𝐒(k₁ + k₂)) k₂ ⋅ (k₁ + k₂))) ⋅ (𝐒 k₁ ⋅ (k₁ !))\n-}\n", "meta": {"hexsha": "24a1edddf0939af1ea60eedf5985dff0f9aac1ae", "size": 11426, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/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": "Numeral/Natural/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": "Numeral/Natural/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": 47.2148760331, "max_line_length": 219, "alphanum_fraction": 0.4684929109, "num_tokens": 7177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.86153820232079, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.5792394378177711}} {"text": "{-# OPTIONS --cubical --safe --postfix-projections #-}\n\nopen import Prelude\nopen import Relation.Binary\n\nmodule Data.RBTree {e} {E : Type e} {r₁ r₂} (totalOrder : TotalOrder E r₁ r₂) where\n\nopen import Relation.Binary.Construct.Bounded totalOrder\n\nopen TotalOrder totalOrder using (_≤?_)\n\ndata Colour : Type where\n red black : Colour\n\nadd-black : Colour → ℕ → ℕ\nadd-black red = λ n → n\nadd-black black = suc\n\nprivate\n variable\n n : ℕ\n\ndata Tree (lb ub : [∙]) : ℕ → Type (e ℓ⊔ r₂) where\n leaf : lb [≤] ub → Tree lb ub n\n node : (x : E) → (c : Colour) → Tree lb [ x ] n → Tree [ x ] ub n → Tree lb ub (add-black c n)\n\nprivate\n variable\n lb ub : [∙]\n\nIsBlack : Tree lb ub n → Type\nIsBlack (leaf x) = ⊤\nIsBlack (node x red tr tr₁) = ⊥\nIsBlack (node x black tr tr₁) = ⊤\n\nValid-rec : Tree lb ub n → Type\nValid-rec (leaf x) = ⊤\nValid-rec (node x red xs ys) = IsBlack xs × IsBlack ys × Valid-rec xs × Valid-rec ys\nValid-rec (node x black xs ys) = Valid-rec xs × Valid-rec ys\n\n\nValid : Tree lb ub n → Type\nValid tr = IsBlack tr × Valid-rec tr\n\n-- insertWithin : (x : E) →\n-- (lb [≤] [ x ]) →\n-- ([ x ] [≤] ub) →\n-- (tr : Tree lb ub n) →\n-- Valid-rec tr →\n-- ∃ c Σ (Tree lb ub (add-black c n)) Valid-rec\n-- insertWithin x lb≤x x≤ub (leaf _) val = red , node x red (leaf lb≤x) (leaf x≤ub) , tt , tt , tt , tt\n-- insertWithin x lb≤x x≤ub (node y c ls rs) val with x ≤? y\n-- insertWithin x lb≤x x≤ub (node y red ls rs) val | inl x≤y with insertWithin x lb≤x x≤y ls (fst (snd (snd val)))\n-- insertWithin x lb≤x x≤ub (node y red ls rs) val | inl x≤y | red , ls′ , val′ = black , node y black ls′ rs , val′ , snd (snd (snd val))\n-- insertWithin x lb≤x x≤ub (node y red ls rs) val | inl x≤y | black , ls′ , val′ = {!{!!} , node y {!!} ls′ rs , {!!}!}\n-- insertWithin x lb≤x x≤ub (node y black ls rs) val | inl x≤y with insertWithin x lb≤x x≤y ls (fst val)\n-- insertWithin x lb≤x x≤ub (node y black ls rs) val | inl x≤y | res = {!!}\n-- insertWithin x lb≤x x≤ub (node y c ls rs) val | inr y≤x = {!!}\n\n-- -- insertWithin x lb≤x x≤ub (node y ls rs) with x ≤? y\n-- -- insertWithin x lb≤x x≤ub (node y ls rs) | inl x≤y = node y (insertWithin x lb≤x x≤y ls) rs\n-- -- insertWithin x lb≤x x≤ub (node y ls rs) | inr y≤x = node y ls (insertWithin x y≤x x≤ub rs)\n", "meta": {"hexsha": "738c5289fdd242c32bb63899de746e726e5631e1", "size": 2332, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/RBTree.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/RBTree.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/RBTree.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": 37.0158730159, "max_line_length": 143, "alphanum_fraction": 0.582761578, "num_tokens": 878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213853793452, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5792365702401808}} {"text": "{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Functions.FunExtEquiv where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.CartesianKanOps\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Nat\n\nopen import Cubical.Reflection.StrictEquiv\n\nprivate\n variable\n ℓ ℓ₁ ℓ₂ ℓ₃ : Level\n\n-- Function extensionality is an equivalence\nmodule _ {A : Type ℓ} {B : A → I → Type ℓ₁}\n {f : (x : A) → B x i0} {g : (x : A) → B x i1} where\n\n funExtEquiv : (∀ x → PathP (B x) (f x) (g x)) ≃ PathP (λ i → ∀ x → B x i) f g\n unquoteDef funExtEquiv = defStrictEquiv funExtEquiv funExt funExt⁻\n\n funExtPath : (∀ x → PathP (B x) (f x) (g x)) ≡ PathP (λ i → ∀ x → B x i) f g\n funExtPath = ua funExtEquiv\n\n funExtIso : Iso (∀ x → PathP (B x) (f x) (g x)) (PathP (λ i → ∀ x → B x i) f g)\n funExtIso = iso funExt funExt⁻ (λ x → refl {x = x}) (λ x → refl {x = x})\n\n-- Function extensionality for binary functions\nfunExt₂ : {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → I → Type ℓ₂}\n {f : (x : A) → (y : B x) → C x y i0}\n {g : (x : A) → (y : B x) → C x y i1}\n → ((x : A) (y : B x) → PathP (C x y) (f x y) (g x y))\n → PathP (λ i → ∀ x y → C x y i) f g\nfunExt₂ p i x y = p x y i\n\n-- Function extensionality for binary functions is an equivalence\nmodule _ {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → I → Type ℓ₂}\n {f : (x : A) → (y : B x) → C x y i0}\n {g : (x : A) → (y : B x) → C x y i1} where\n private\n appl₂ : PathP (λ i → ∀ x y → C x y i) f g → ∀ x y → PathP (C x y) (f x y) (g x y)\n appl₂ eq x y i = eq i x y\n\n funExt₂Equiv : (∀ x y → PathP (C x y) (f x y) (g x y)) ≃ (PathP (λ i → ∀ x y → C x y i) f g)\n unquoteDef funExt₂Equiv = defStrictEquiv funExt₂Equiv funExt₂ appl₂\n\n funExt₂Path : (∀ x y → PathP (C x y) (f x y) (g x y)) ≡ (PathP (λ i → ∀ x y → C x y i) f g)\n funExt₂Path = ua funExt₂Equiv\n\n\n-- Function extensionality for ternary functions\nfunExt₃ : {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}\n {D : (x : A) → (y : B x) → C x y → I → Type ℓ₃}\n {f : (x : A) → (y : B x) → (z : C x y) → D x y z i0}\n {g : (x : A) → (y : B x) → (z : C x y) → D x y z i1}\n → ((x : A) (y : B x) (z : C x y) → PathP (D x y z) (f x y z) (g x y z))\n → PathP (λ i → ∀ x y z → D x y z i) f g\nfunExt₃ p i x y z = p x y z i\n\n-- Function extensionality for ternary functions is an equivalence\nmodule _ {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}\n {D : (x : A) → (y : B x) → C x y → I → Type ℓ₃}\n {f : (x : A) → (y : B x) → (z : C x y) → D x y z i0}\n {g : (x : A) → (y : B x) → (z : C x y) → D x y z i1} where\n private\n appl₃ : PathP (λ i → ∀ x y z → D x y z i) f g → ∀ x y z → PathP (D x y z) (f x y z) (g x y z)\n appl₃ eq x y z i = eq i x y z\n\n funExt₃Equiv : (∀ x y z → PathP (D x y z) (f x y z) (g x y z)) ≃ (PathP (λ i → ∀ x y z → D x y z i) f g)\n unquoteDef funExt₃Equiv = defStrictEquiv funExt₃Equiv funExt₃ appl₃\n\n funExt₃Path : (∀ x y z → PathP (D x y z) (f x y z) (g x y z)) ≡ (PathP (λ i → ∀ x y z → D x y z i) f g)\n funExt₃Path = ua funExt₃Equiv\n\n\n-- n-ary non-dependent funext\nnAryFunExt : {X : Type ℓ} {Y : I → Type ℓ₁} (n : ℕ) (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))\n → ((xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs))\n → PathP (λ i → nAryOp n X (Y i)) fX fY\nnAryFunExt zero fX fY p = p []\nnAryFunExt (suc n) fX fY p i x = nAryFunExt n (fX x) (fY x) (λ xs → p (x ∷ xs)) i\n\n-- n-ary funext⁻\nnAryFunExt⁻ : (n : ℕ) {X : Type ℓ} {Y : I → Type ℓ₁} (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))\n → PathP (λ i → nAryOp n X (Y i)) fX fY\n → ((xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs))\nnAryFunExt⁻ zero fX fY p [] = p\nnAryFunExt⁻ (suc n) fX fY p (x ∷ xs) = nAryFunExt⁻ n (fX x) (fY x) (λ i → p i x) xs\n\nnAryFunExtEquiv : (n : ℕ) {X : Type ℓ} {Y : I → Type ℓ₁} (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))\n → ((xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs)) ≃ PathP (λ i → nAryOp n X (Y i)) fX fY\nnAryFunExtEquiv n {X} {Y} fX fY = isoToEquiv (iso (nAryFunExt n fX fY) (nAryFunExt⁻ n fX fY)\n (linv n fX fY) (rinv n fX fY))\n where\n linv : (n : ℕ) (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))\n (p : PathP (λ i → nAryOp n X (Y i)) fX fY)\n → nAryFunExt n fX fY (nAryFunExt⁻ n fX fY p) ≡ p\n linv zero fX fY p = refl\n linv (suc n) fX fY p i j x = linv n (fX x) (fY x) (λ k → p k x) i j\n\n rinv : (n : ℕ) (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))\n (p : (xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs))\n → nAryFunExt⁻ n fX fY (nAryFunExt n fX fY p) ≡ p\n rinv zero fX fY p i [] = p []\n rinv (suc n) fX fY p i (x ∷ xs) = rinv n (fX x) (fY x) (λ ys i → p (x ∷ ys) i) i xs\n\n-- Funext when the domain also depends on the interval\n\nfunExtDep : {A : I → Type ℓ} {B : (i : I) → A i → Type ℓ₁}\n {f : (x : A i0) → B i0 x} {g : (x : A i1) → B i1 x}\n → ({x₀ : A i0} {x₁ : A i1} (p : PathP A x₀ x₁) → PathP (λ i → B i (p i)) (f x₀) (g x₁))\n → PathP (λ i → (x : A i) → B i x) f g\nfunExtDep {A = A} {B} {f} {g} h i x =\n comp\n (λ k → B i (coei→i A i x k))\n (λ k → λ\n { (i = i0) → f (coei→i A i0 x k)\n ; (i = i1) → g (coei→i A i1 x k)\n })\n (h (λ j → coei→j A i j x) i)\n\nfunExtDep⁻ : {A : I → Type ℓ} {B : (i : I) → A i → Type ℓ₁}\n {f : (x : A i0) → B i0 x} {g : (x : A i1) → B i1 x}\n → PathP (λ i → (x : A i) → B i x) f g\n → ({x₀ : A i0} {x₁ : A i1} (p : PathP A x₀ x₁) → PathP (λ i → B i (p i)) (f x₀) (g x₁))\nfunExtDep⁻ q p i = q i (p i)\n\nfunExtDepEquiv : {A : I → Type ℓ} {B : (i : I) → A i → Type ℓ₁}\n {f : (x : A i0) → B i0 x} {g : (x : A i1) → B i1 x}\n → ({x₀ : A i0} {x₁ : A i1} (p : PathP A x₀ x₁) → PathP (λ i → B i (p i)) (f x₀) (g x₁))\n ≃ PathP (λ i → (x : A i) → B i x) f g\nfunExtDepEquiv {A = A} {B} {f} {g} = isoToEquiv isom\n where\n open Iso\n isom : Iso _ _\n isom .fun = funExtDep\n isom .inv = funExtDep⁻\n isom .rightInv q m i x =\n comp\n (λ k → B i (coei→i A i x (k ∨ m)))\n (λ k → λ\n { (i = i0) → f (coei→i A i0 x (k ∨ m))\n ; (i = i1) → g (coei→i A i1 x (k ∨ m))\n ; (m = i1) → q i x\n })\n (q i (coei→i A i x m))\n isom .leftInv h m p i =\n comp\n (λ k → B i (lemi→i m k))\n (λ k → λ\n { (i = i0) → f (lemi→i m k)\n ; (i = i1) → g (lemi→i m k)\n ; (m = i1) → h p i\n })\n (h (λ j → lemi→j j m) i)\n where\n lemi→j : ∀ j → coei→j A i j (p i) ≡ p j\n lemi→j j =\n coei→j (λ k → coei→j A i k (p i) ≡ p k) i j (coei→i A i (p i))\n\n lemi→i : PathP (λ m → lemi→j i m ≡ p i) (coei→i A i (p i)) refl\n lemi→i =\n sym (coei→i (λ k → coei→j A i k (p i) ≡ p k) i (coei→i A i (p i)))\n ◁ λ m k → lemi→j i (m ∨ k)\n\nheteroHomotopy≃Homotopy : {A : I → Type ℓ} {B : (i : I) → Type ℓ₁}\n {f : A i0 → B i0} {g : A i1 → B i1}\n → ({x₀ : A i0} {x₁ : A i1} → PathP A x₀ x₁ → PathP B (f x₀) (g x₁))\n ≃ ((x₀ : A i0) → PathP B (f x₀) (g (transport (λ i → A i) x₀)))\nheteroHomotopy≃Homotopy {A = A} {B} {f} {g} = isoToEquiv isom\n where\n open Iso\n isom : Iso _ _\n isom .fun h x₀ = h (isContrSinglP A x₀ .fst .snd)\n isom .inv k {x₀} {x₁} p =\n subst (λ fib → PathP B (f x₀) (g (fib .fst))) (isContrSinglP A x₀ .snd (x₁ , p)) (k x₀)\n isom .rightInv k = funExt λ x₀ →\n cong (λ α → subst (λ fib → PathP B (f x₀) (g (fib .fst))) α (k x₀))\n (isProp→isSet isPropSinglP (isContrSinglP A x₀ .fst) _\n (isContrSinglP A x₀ .snd (isContrSinglP A x₀ .fst))\n refl)\n ∙ transportRefl (k x₀)\n isom .leftInv h j {x₀} {x₁} p =\n transp\n (λ i → PathP B (f x₀) (g (isContrSinglP A x₀ .snd (x₁ , p) (i ∨ j) .fst)))\n j\n (h (isContrSinglP A x₀ .snd (x₁ , p) j .snd))\n", "meta": {"hexsha": "10377696692f89008752fa02c3aff712c836de87", "size": 7992, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Functions/FunExtEquiv.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/Functions/FunExtEquiv.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/Functions/FunExtEquiv.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": 41.4093264249, "max_line_length": 106, "alphanum_fraction": 0.4953703704, "num_tokens": 3800, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.57921955787344}} {"text": "{-# OPTIONS --safe --experimental-lossy-unification #-}\nmodule Cubical.ZCohomology.Groups.WedgeOfSpheres where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Data.Sigma.Base\n\nopen import Cubical.ZCohomology.Base\nopen import Cubical.ZCohomology.GroupStructure\nopen import Cubical.ZCohomology.Groups.Unit\nopen import Cubical.ZCohomology.Groups.Sn\nopen import Cubical.ZCohomology.Groups.Wedge\nopen import Cubical.ZCohomology.Groups.Connected\nopen import Cubical.Data.Int renaming (_+_ to _ℤ+_)\n\nopen import Cubical.HITs.Sn\nopen import Cubical.HITs.S1\nopen import Cubical.HITs.Susp\nopen import Cubical.HITs.Wedge\nopen import Cubical.HITs.Pushout\nopen import Cubical.HITs.Truncation renaming (elim to trElim) hiding (map ; elim2)\nopen import Cubical.Algebra.Group renaming (ℤ to ℤGroup ; Bool to BoolGroup ; Unit to UnitGroup)\nopen import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim)\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¹) ℤGroup\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 ℤGroup ℤGroup)\nH¹-S¹⋁S¹ = (Hⁿ-⋁ _ _ 0) □ GroupIsoDirProd coHom1S1≃ℤ coHom1S1≃ℤ\n\n------------- H⁰(S²⋁S¹⋁S¹) ---------\nH⁰-S²⋁S¹⋁S¹ : GroupIso (coHomGr 0 S²⋁S¹⋁S¹) ℤGroup\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 ℤGroup ℤGroup)\nH¹-S²⋁S¹⋁S¹ =\n Hⁿ-⋁ (S₊∙ 2) (S¹⋁S¹ , inl base) 0\n □ GroupIsoDirProd (H¹-Sⁿ≅0 0) H¹-S¹⋁S¹\n □ lUnitGroupIso\n\n------------- H²(S²⋁S¹⋁S¹) ---------\n\nH²-S²⋁S¹⋁S¹ : GroupIso (coHomGr 2 S²⋁S¹⋁S¹) ℤGroup\nH²-S²⋁S¹⋁S¹ =\n compGroupIso\n (Hⁿ-⋁ _ _ 1)\n (GroupIsoDirProd {B = UnitGroup}\n (Hⁿ-Sⁿ≅ℤ 1)\n ((Hⁿ-⋁ _ _ 1) □ GroupIsoDirProd (Hⁿ-S¹≅0 0) (Hⁿ-S¹≅0 0) □ rUnitGroupIso)\n □ rUnitGroupIso)\n\nprivate\n open IsGroupHom\n open Iso\n\n to₂ : coHom 2 S²⋁S¹⋁S¹ → ℤ\n to₂ = fun (fst H²-S²⋁S¹⋁S¹)\n from₂ : ℤ → coHom 2 S²⋁S¹⋁S¹\n from₂ = inv (fst H²-S²⋁S¹⋁S¹)\n\n to₁ : coHom 1 S²⋁S¹⋁S¹ → ℤ × ℤ\n to₁ = fun (fst H¹-S²⋁S¹⋁S¹)\n from₁ : ℤ × ℤ → coHom 1 S²⋁S¹⋁S¹\n from₁ = inv (fst H¹-S²⋁S¹⋁S¹)\n\n to₀ : coHom 0 S²⋁S¹⋁S¹ → ℤ\n to₀ = fun (fst H⁰-S²⋁S¹⋁S¹)\n from₀ : ℤ → coHom 0 S²⋁S¹⋁S¹\n from₀ = inv (fst H⁰-S²⋁S¹⋁S¹)\n\n{-\n\n-- Compute pretty fast\ntest1 : to₁ (from₁ (1 , 0) +ₕ from₁ (0 , 1)) ≡ (1 , 1)\ntest1 = refl\n\n-- Computes, but only when computing some smaller numbers first\ntest2 : to₁ (from₁ (50 , 3) +ₕ from₁ (2 , -2)) ≡ (52 , 1)\ntest2 = refl\n\ntest3 : to₂ (from₂ 0) ≡ 0\ntest3 = refl\n\ntest4 : to₂ (from₂ 3) ≡ 3\ntest4 = refl\n\ntest5 : to₂ (from₂ 1 +ₕ from₂ 1) ≡ 2\ntest5 = refl\n-}\n\n g : S²⋁S¹⋁S¹ → ∥ Susp S¹ ∥ 4\n g (inl x) = ∣ x ∣\n g (inr x) = 0ₖ _\n g (push a i) = 0ₖ _\n\n G = ∣ g ∣₂\n\n{- Does not compute:\ntest₀ : to₂ (G +ₕ G) ≡ 2\ntest₀ = refl\n\nbut this does:\ntest₀ : to₂ (G +'ₕ G) ≡ 2\ntest₀ = refl\n-}\n", "meta": {"hexsha": "cdc616371c53fd4503a63a624e1bc1e46ec202c6", "size": 3233, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.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/ZCohomology/Groups/WedgeOfSpheres.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/ZCohomology/Groups/WedgeOfSpheres.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": 26.9416666667, "max_line_length": 96, "alphanum_fraction": 0.6269718528, "num_tokens": 1586, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619306896955, "lm_q2_score": 0.7025300698514778, "lm_q1q2_score": 0.5792092977573161}} {"text": "{-\n\n The flattening lemma for pushouts (Lemma 8.5.3 in the HoTT book) proved in a cubical style.\n\n The proof in the HoTT book (the core lying in Lemma 6.12.2, the flattening lemma for coequalizers)\n consists mostly of long strings of equalities about transport. This proof follows almost\n entirely from definitional equalities involving glue/unglue.\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.HITs.Pushout.Flattening 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\n\nopen import Cubical.Data.Sigma\n\nopen import Cubical.HITs.Pushout.Base\n\nmodule FlatteningLemma {ℓa ℓb ℓc} {A : Type ℓa} {B : Type ℓb} {C : Type ℓc} (f : A → B) (g : A → C)\n {ℓ} (F : B → Type ℓ) (G : C → Type ℓ) (e : ∀ a → F (f a) ≃ G (g a)) where\n\n E : Pushout f g → Type ℓ\n E (inl x) = F x\n E (inr x) = G x\n E (push a i) = ua (e a) i\n\n Σf : Σ[ a ∈ A ] F (f a) → Σ[ b ∈ B ] F b\n Σf (a , x) = (f a , x)\n\n Σg : Σ[ a ∈ A ] F (f a) → Σ[ c ∈ C ] G c\n Σg (a , x) = (g a , (e a) .fst x)\n\n module FlattenIso where\n\n fwd : Pushout Σf Σg → Σ (Pushout f g) E\n fwd (inl (b , x)) = (inl b , x)\n fwd (inr (c , x)) = (inr c , x)\n fwd (push (a , x) i) = (push a i , ua-gluePt (e a) i x)\n\n bwd : Σ (Pushout f g) E → Pushout Σf Σg\n bwd (inl b , x) = inl (b , x)\n bwd (inr c , x) = inr (c , x)\n bwd (push a i , x) = hcomp (λ j → λ { (i = i0) → push (a , x) (~ j)\n ; (i = i1) → inr (g a , x) })\n (inr (g a , ua-unglue (e a) i x))\n\n bwd-fwd : ∀ x → bwd (fwd x) ≡ x\n bwd-fwd (inl (b , x)) = refl\n bwd-fwd (inr (c , x)) = refl\n bwd-fwd (push (a , x) i) j =\n hcomp (λ k → λ { (i = i0) → push (a , ua-gluePt (e a) i0 x) (~ k)\n ; (i = i1) → inr (g a , ua-gluePt (e a) i1 x)\n ; (j = i1) → push (a , x) (i ∨ ~ k) })\n (inr (g a , ua-unglue (e a) i (ua-gluePt (e a) i x)))\n -- Note: the (j = i1) case typechecks because of the definitional equalities:\n -- ua-gluePt e i0 x ≡ x , ua-gluePt e i1 x ≡ e .fst x,\n -- ua-unglue-glue : ua-unglue e i (ua-gluePt e i x) ≡ e .fst x\n\n -- essentially: ua-glue e (i ∨ ~ k) ∘ ua-unglue e i\n sq : ∀ {ℓ} {A B : Type ℓ} (e : A ≃ B)\n → SquareP (λ i k → ua e i → ua e (i ∨ ~ k))\n {- i = i0 -} (λ k x → ua-gluePt e (~ k) x)\n {- i = i1 -} (λ k x → x)\n {- k = i0 -} (λ i x → ua-unglue e i x)\n {- k = i1 -} (λ i x → x)\n sq e i k x = ua-glue e (i ∨ ~ k) (λ { ((i ∨ ~ k) = i0) → x })\n (inS (ua-unglue e i x))\n -- Note: this typechecks because of the definitional equalities:\n -- ua-unglue e i0 x ≡ e .fst x, ua-glue e i1 _ (inS y) ≡ y, ua-unglue e i1 x ≡ x,\n -- ua-glue-unglue : ua-glue e i (λ { (i = i0) → x }) (inS (ua-unglue e i x)) ≡ x\n\n fwd-bwd : ∀ x → fwd (bwd x) ≡ x\n fwd-bwd (inl b , x) = refl\n fwd-bwd (inr c , x) = refl\n fwd-bwd (push a i , x) j =\n -- `fwd` (or any function) takes hcomps to comps on a constant family, so we must use a comp here\n comp (λ _ → Σ (Pushout f g) E)\n (λ k → λ { (i = i0) → push a (~ k) , ua-gluePt (e a) (~ k) x\n ; (i = i1) → inr (g a) , x\n ; (j = i1) → push a (i ∨ ~ k) , sq (e a) i k x })\n (inr (g a) , ua-unglue (e a) i x)\n\n isom : Iso (Σ (Pushout f g) E) (Pushout Σf Σg)\n isom = iso bwd fwd bwd-fwd fwd-bwd\n\n flatten : Σ (Pushout f g) E ≃ Pushout Σf Σg\n flatten = isoToEquiv FlattenIso.isom\n", "meta": {"hexsha": "0f89700caf0b6d7a4fd0c70941687a10dea04768", "size": 3684, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/Pushout/Flattening.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/Pushout/Flattening.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/Pushout/Flattening.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": 40.0434782609, "max_line_length": 103, "alphanum_fraction": 0.5002714441, "num_tokens": 1508, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.579209289592355}} {"text": "------------------------------------------------------------------------\n-- Comparisons of different kinds of lenses, focusing on the\n-- definition of composable record setters and getters\n------------------------------------------------------------------------\n\n{-# OPTIONS --cubical --safe #-}\n\n-- This module uses both dependent and non-dependent lenses, in order\n-- to illustrate a problem with the non-dependent ones. It also uses\n-- two kinds of dependent lenses, in order to illustrate a minor\n-- problem with one of them.\n\nmodule README.Record-getters-and-setters where\n\nopen import Equality.Propositional.Cubical\nopen import Prelude hiding (_∘_)\n\nopen import Bijection equality-with-J as Bij using (_↔_; module _↔_)\nopen import Equality.Decision-procedures equality-with-J\nimport Equivalence equality-with-J as Eq\nopen import Function-universe equality-with-J as F hiding (_∘_)\n\nimport Lens.Dependent\nimport Lens.Non-dependent.Higher equality-with-paths as Higher\n\n------------------------------------------------------------------------\n-- Dependent lenses with \"remainder types\" visible in the type\n\nmodule Dependent₃ where\n\n open Lens.Dependent\n\n -- Nested records.\n\n record R₁ (A : Set) : Set where\n field\n f : A → A\n x : A\n lemma : ∀ y → f y ≡ y\n\n record R₂ : Set₁ where\n field\n A : Set\n r₁ : R₁ A\n\n -- Lenses for each of the three fields of R₁.\n\n -- The x field is easiest, because it is independent of the others.\n --\n -- (Note that the from function is inferred automatically.)\n\n x : {A : Set} →\n Lens₃ (R₁ A) (∃ λ (f : A → A) → ∀ y → f y ≡ y) (λ _ → A)\n x = Eq.↔⇒≃ (record\n { surjection = record\n { logical-equivalence = record\n { to = λ r → (R₁.f r , R₁.lemma r) , R₁.x r\n ; from = _\n }\n ; right-inverse-of = λ _ → refl\n }\n ; left-inverse-of = λ _ → refl\n })\n\n -- The lemma field depends on the f field, so whenever the f field\n -- is set the lemma field needs to be updated as well.\n\n f : {A : Set} →\n Lens₃ (R₁ A) A (λ _ → ∃ λ (f : A → A) → ∀ y → f y ≡ y)\n f = Eq.↔⇒≃ (record\n { surjection = record\n { logical-equivalence = record\n { to = λ r → R₁.x r , (R₁.f r , R₁.lemma r)\n ; from = _\n }\n ; right-inverse-of = λ _ → refl\n }\n ; left-inverse-of = λ _ → refl\n })\n\n -- The lemma field can be updated independently.\n\n lemma : {A : Set} →\n Lens₃ (R₁ A) (A × (A → A)) (λ r → ∀ y → proj₂ r y ≡ y)\n lemma = Eq.↔⇒≃ (record\n { surjection = record\n { logical-equivalence = record\n { to = λ r → (R₁.x r , R₁.f r) , R₁.lemma r\n ; from = _\n }\n ; right-inverse-of = λ _ → refl\n }\n ; left-inverse-of = λ _ → refl\n })\n\n -- Note that the type of the last lens may not be quite\n -- satisfactory: the type of the lens does not guarantee that the\n -- lemma applies to the input's f field. The following lemma may\n -- provide some form of consolation:\n\n consolation : {A : Set} (r : R₁ A) → ∀ y → R₁.f r y ≡ y\n consolation = Lens₃.get lemma\n\n -- Let us now construct lenses for the same fields, but accessed\n -- through an R₂ record.\n\n -- First we define lenses for the fields of R₂ (note that the A lens\n -- does not seem to be very useful):\n\n A : Lens₃ R₂ ⊤ (λ _ → R₂)\n A = id₃\n\n r₁ : Lens₃ R₂ Set R₁\n r₁ = Eq.↔⇒≃ (record\n { surjection = record\n { logical-equivalence = record\n { to = λ r → R₂.A r , R₂.r₁ r\n ; from = _\n }\n ; right-inverse-of = λ _ → refl\n }\n ; left-inverse-of = λ _ → refl\n })\n\n -- The lenses for the three R₁ fields can now be defined by\n -- composition:\n\n x₂ : Lens₃ R₂ _ (λ r → proj₁ r)\n x₂ = x ₃∘₃ r₁\n\n f₂ : Lens₃ R₂ _ (λ r → ∃ λ (f : proj₁ r → proj₁ r) → ∀ y → f y ≡ y)\n f₂ = f ₃∘₃ r₁\n\n lemma₂ : Lens₃ R₂ _ (λ r → ∀ y → proj₂ (proj₂ r) y ≡ y)\n lemma₂ = lemma ₃∘₃ r₁\n\n consolation₂ : (r : R₂) → ∀ y → proj₁ (Lens₃.get f₂ r) y ≡ y\n consolation₂ = Lens₃.get lemma₂\n\n------------------------------------------------------------------------\n-- Dependent lenses without \"remainder types\" visible in the type\n\nmodule Dependent where\n\n open Lens.Dependent\n open Dependent₃ using (R₁; module R₁; R₂; module R₂)\n\n -- Lenses for each of the three fields of R₁.\n\n x : {A : Set} → Lens (R₁ A) (λ _ → A)\n x = Lens₃-to-Lens Dependent₃.x\n\n f : {A : Set} → Lens (R₁ A) (λ _ → ∃ λ (f : A → A) → ∀ y → f y ≡ y)\n f = Lens₃-to-Lens Dependent₃.f\n\n lemma : {A : Set} → Lens (R₁ A) (λ r → ∀ y → R₁.f r y ≡ y)\n lemma = Lens₃-to-Lens Dependent₃.lemma\n\n -- Note that the type of lemma is now more satisfactory: the type of\n -- the lens /does/ guarantee that the lemma applies to the input's f\n -- field.\n\n -- A lens for the r₁ field of R₂.\n\n r₁ : Lens R₂ (λ r → R₁ (R₂.A r))\n r₁ = Lens₃-to-Lens {-a = # 0-} Dependent₃.r₁\n\n -- Lenses for the fields of R₁, accessed through an R₂ record. Note\n -- the use of /forward/ composition.\n\n x₂ : Lens R₂ (λ r → R₂.A r)\n x₂ = r₁ ⨾ x\n\n f₂ : Lens R₂ (λ r → ∃ λ (f : R₂.A r → R₂.A r) → ∀ y → f y ≡ y)\n f₂ = r₁ ⨾ f\n\n lemma₂ : Lens R₂ (λ r → ∀ y → R₁.f (R₂.r₁ r) y ≡ y)\n lemma₂ = r₁ ⨾ lemma\n\n------------------------------------------------------------------------\n-- Non-dependent lenses\n\nmodule Non-dependent where\n\n open Higher\n open Lens-combinators\n\n -- Labels.\n\n data Label : Set where\n ″f″ ″x″ ″lemma″ ″A″ ″r₁″ : Label\n\n -- Labels come with decidable equality.\n\n Label↔Fin : Label ↔ Fin 5\n Label↔Fin = 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\n to : Label → Fin 5\n to ″f″ = fzero\n to ″x″ = fsuc fzero\n to ″lemma″ = fsuc (fsuc fzero)\n to ″A″ = fsuc (fsuc (fsuc fzero))\n to ″r₁″ = fsuc (fsuc (fsuc (fsuc fzero)))\n\n from : Fin 5 → Label\n from fzero = ″f″\n from (fsuc fzero) = ″x″\n from (fsuc (fsuc fzero)) = ″lemma″\n from (fsuc (fsuc (fsuc fzero))) = ″A″\n from (fsuc (fsuc (fsuc (fsuc fzero)))) = ″r₁″\n from (fsuc (fsuc (fsuc (fsuc (fsuc ())))))\n\n to∘from : ∀ i → to (from i) ≡ i\n to∘from fzero = refl\n to∘from (fsuc fzero) = refl\n to∘from (fsuc (fsuc fzero)) = refl\n to∘from (fsuc (fsuc (fsuc fzero))) = refl\n to∘from (fsuc (fsuc (fsuc (fsuc fzero)))) = refl\n to∘from (fsuc (fsuc (fsuc (fsuc (fsuc ())))))\n\n from∘to : ∀ ℓ → from (to ℓ) ≡ ℓ\n from∘to ″f″ = refl\n from∘to ″x″ = refl\n from∘to ″lemma″ = refl\n from∘to ″A″ = refl\n from∘to ″r₁″ = refl\n\n _≟_ : Decidable-equality Label\n _≟_ = Bij.decidable-equality-respects (inverse Label↔Fin) Fin._≟_\n\n -- Records.\n\n open import Records-with-with equality-with-J Label _≟_\n\n -- Nested records (defined using the record language from Record, so\n -- that we can use manifest fields).\n\n R₁ : Set → Signature _\n R₁ A = ∅ , ″f″ ∶ (λ _ → A → A)\n , ″x″ ∶ (λ _ → A)\n , ″lemma″ ∶ (λ r → ∀ y → (r · ″f″) y ≡ y)\n\n R₂ : Signature _\n R₂ = ∅ , ″A″ ∶ (λ _ → Set)\n , ″r₁″ ∶ (λ r → ↑ _ (Record (R₁ (r · ″A″))))\n\n -- Lenses for each of the three fields of R₁.\n\n -- The x field is easiest, because it is independent of the others.\n\n x : {A : Set} → Lens (Record (R₁ A)) A\n x {A} = isomorphism-to-lens\n\n (Record (R₁ A) ↝⟨ Record↔Recʳ ⟩\n (∃ λ (f : A → A) → ∃ λ (x : A) → ∀ y → f y ≡ y) ↝⟨ ∃-comm ⟩\n (A × ∃ λ (f : A → A) → ∀ y → f y ≡ y) ↝⟨ ×-comm ⟩□\n (∃ λ (f : A → A) → ∀ y → f y ≡ y) × A □)\n\n -- The lemma field depends on the f field, so whenever the f field\n -- is set the lemma field needs to be updated as well.\n\n f : {A : Set} →\n Lens (Record (R₁ A))\n (Record (∅ , ″f″ ∶ (λ _ → A → A)\n , ″lemma″ ∶ (λ r → ∀ x → (r · ″f″) x ≡ x)))\n f {A} = isomorphism-to-lens\n\n (Record (R₁ A) ↝⟨ Record↔Recʳ ⟩\n (∃ λ (f : A → A) → ∃ λ (x : A) → ∀ y → f y ≡ y) ↝⟨ ∃-comm ⟩\n A × (∃ λ (f : A → A) → ∀ y → f y ≡ y) ↝⟨ F.id ×-cong inverse Record↔Recʳ ⟩□\n A × Record _ □)\n\n -- The lemma field can be updated independently. Note the use of a\n -- manifest field in the type of the lens to capture the dependency\n -- between the two lens parameters.\n\n lemma : {A : Set} {f : A → A} →\n Lens (Record (R₁ A With ″f″ ≔ (λ _ → f)))\n (∀ x → f x ≡ x)\n lemma {A} {f} = isomorphism-to-lens\n\n (Record (R₁ A With ″f″ ≔ (λ _ → f)) ↝⟨ Record↔Recʳ ⟩□\n A × (∀ x → f x ≡ x) □)\n\n -- The use of a manifest field is problematic, because the domain of\n -- the lens is no longer Record (R₁ A). It is easy to convert\n -- records into the required form, but this conversion is not a\n -- non-dependent lens (due to the dependency).\n\n convert : {A : Set} (r : Record (R₁ A)) →\n Record (R₁ A With ″f″ ≔ (λ _ → r · ″f″))\n convert (rec (rec (rec (_ , f) , x) , lemma)) =\n rec (rec (_ , x) , lemma)\n\n -- Let us now try to construct lenses for the same fields, but\n -- accessed through an R₂ record.\n\n -- First we define a lens for the r₁ field.\n\n r₁ : {A : Set} →\n Lens (Record (R₂ With ″A″ ≔ λ _ → A)) (Record (R₁ A))\n r₁ {A} = isomorphism-to-lens\n\n (Record (R₂ With ″A″ ≔ λ _ → A) ↝⟨ Record↔Recʳ ⟩\n ↑ _ (Record (R₁ A)) ↝⟨ Bij.↑↔ ⟩\n Record (R₁ A) ↝⟨ inverse ×-left-identity ⟩\n ⊤ × Record (R₁ A) ↝⟨ inverse Bij.↑↔ ×-cong F.id ⟩□\n ↑ _ ⊤ × Record (R₁ A) □)\n\n -- It is now easy to construct lenses for the embedded x and f\n -- fields using composition of lenses.\n\n x₂ : {A : Set} →\n Lens (Record (R₂ With ″A″ ≔ λ _ → A)) A\n x₂ = ⟨ _ , _ ⟩ x ∘ r₁\n\n f₂ : {A : Set} →\n Lens (Record (R₂ With ″A″ ≔ λ _ → A))\n (Record (∅ , ″f″ ∶ (λ _ → A → A)\n , ″lemma″ ∶ (λ r → ∀ x → (r · ″f″) x ≡ x)))\n f₂ = ⟨ _ , _ ⟩ f ∘ r₁\n\n -- It is less obvious how to construct the corresponding lens for\n -- the embedded lemma field.\n\n module Lemma-lens\n (r₁₂ : {A : Set} {r : Record (R₁ A)} →\n Lens (Record (R₂ With ″A″ ≔ (λ _ → A)\n With ″r₁″ ≔ (λ _ → lift r)))\n (Record (R₁ A With ″f″ ≔ (λ _ → r · ″f″)))) where\n\n -- To start with, what should the type of the lemma lens be? The\n -- type used below is an obvious choice.\n\n lemma₂ : {A : Set} {r : Record (R₁ A)} →\n Lens (Record (R₂ With ″A″ ≔ (λ _ → A)\n With ″r₁″ ≔ (λ _ → lift r)))\n (∀ x → (r · ″f″) x ≡ x)\n\n -- If we can construct a suitable lens r₁₂, with the type\n -- signature given above, then we can define the lemma lens using\n -- composition.\n\n lemma₂ = ⟨ _ , _ ⟩ lemma ∘ r₁₂\n\n -- However, we cannot define r₁₂.\n\n not-r₁₂ : ⊥\n not-r₁₂ = no-isomorphism isomorphism\n where\n open Lens\n\n isomorphisms : ∀ _ _ → _\n isomorphisms = λ A r →\n ⊤ ↝⟨ inverse Bij.↑↔ ⟩\n ↑ _ ⊤ ↝⟨ inverse Record↔Recʳ ⟩\n Record (R₂ With ″A″ ≔ (λ _ → A)\n With ″r₁″ ≔ (λ _ → lift r)) ↔⟨ equiv r₁₂ ⟩\n R r₁₂ × Record (R₁ A With ″f″ ≔ (λ _ → r · ″f″)) ↝⟨ F.id ×-cong Record↔Recʳ ⟩□\n R r₁₂ × A × (∀ y → (r · ″f″) y ≡ y) □\n\n isomorphism : ∃ λ (A : Set₁) → ⊤ ↔ A × Bool\n isomorphism =\n _ ,\n (⊤ ↝⟨ isomorphisms Bool r ⟩\n R r₁₂ × Bool × (∀ b → b ≡ b) ↝⟨ F.id ×-cong ×-comm ⟩\n R r₁₂ × (∀ b → b ≡ b) × Bool ↝⟨ ×-assoc ⟩□\n (R r₁₂ × (∀ b → b ≡ b)) × Bool □)\n where\n r : Record (R₁ Bool)\n r = rec (rec (rec (_ , F.id) , true) , λ _ → refl)\n\n no-isomorphism : ¬ ∃ λ (A : Set₁) → ⊤ ↔ A × Bool\n no-isomorphism (A , iso) = Bool.true≢false (\n true ≡⟨⟩\n proj₂ (a , true) ≡⟨ cong proj₂ $ sym $ right-inverse-of (a , true) ⟩\n proj₂ (to (from (a , true))) ≡⟨⟩\n proj₂ (to (from (a , false))) ≡⟨ cong proj₂ $ right-inverse-of (a , false) ⟩\n proj₂ (a , false) ≡⟨ refl ⟩∎\n false ∎)\n where\n open _↔_ iso\n\n a : A\n a = proj₁ (to _)\n\n -- Conclusion: The use of manifest fields limits the usefulness of\n -- these lenses, because they do not compose as well as they do for\n -- non-dependent records. Dependent lenses seem to be more useful.\n", "meta": {"hexsha": "3e130041098c2e40fba3fffbecd2c7c4640a2cf4", "size": 12783, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "README/Record-getters-and-setters.agda", "max_stars_repo_name": "Saizan/dependent-lenses", "max_stars_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "README/Record-getters-and-setters.agda", "max_issues_repo_name": "Saizan/dependent-lenses", "max_issues_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_issues_repo_licenses": ["MIT"], "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/Record-getters-and-setters.agda", "max_forks_repo_name": "Saizan/dependent-lenses", "max_forks_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_forks_repo_licenses": ["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.9575, "max_line_length": 91, "alphanum_fraction": 0.4936243448, "num_tokens": 4434, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619350028204, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.579209285382832}} {"text": "------------------------------------------------------------------------------\n-- Inequalities 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.Inequalities where\n\nopen import LTC-PCF.Base\n\ninfix 4 _<_ _≮_ _>_ _≯_ _≤_ _≰_ _≥_ _≱_\n\n------------------------------------------------------------------------------\n-- The function terms.\n\nlth : D → D\nlth lt = lam (λ m → lam (λ n →\n if (iszero₁ n)\n then false\n else (if (iszero₁ m) then true else (lt · pred₁ m · pred₁ n))))\nlt : D → D → D\nlt m n = fix lth · m · n\n\nle : D → D → D\nle m n = lt m (succ₁ n)\n\ngt : D → D → D\ngt m n = lt n m\n\nge : D → D → D\nge m n = le n m\n\n------------------------------------------------------------------------\n-- The relations.\n\n_<_ : D → D → Set\nm < n = lt m n ≡ true\n\n_≮_ : D → D → Set\nm ≮ n = lt m n ≡ false\n\n_>_ : D → D → Set\nm > n = gt m n ≡ true\n\n_≯_ : D → D → Set\nm ≯ n = gt m n ≡ false\n\n_≤_ : D → D → Set\nm ≤ n = le m n ≡ true\n\n_≰_ : D → D → Set\nm ≰ n = le m n ≡ false\n\n_≥_ : D → D → Set\nm ≥ n = ge m n ≡ true\n\n_≱_ : D → D → Set\nm ≱ n = ge m n ≡ false\n\n------------------------------------------------------------------------------\n-- The lexicographical order.\nLexi : D → D → D → D → Set\nLexi m n m' n' = m < m' ∨ m ≡ m' ∧ n < n'\n", "meta": {"hexsha": "4bb8434406315484e1eb24c1acc2770945dbd33a", "size": 1508, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/LTC-PCF/Data/Nat/Inequalities.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/Inequalities.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/Inequalities.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": 22.5074626866, "max_line_length": 78, "alphanum_fraction": 0.3640583554, "num_tokens": 465, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128672997041659, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.5789502523647128}} {"text": "-----------------------------------------------------------------------------\n-- Existential elimination\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.Existential.Elimination where\n\n-----------------------------------------------------------------------------\n\npostulate D : Set\n\nmodule ∃₁ where\n -- Type theoretical version\n\n -- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n -- Data/Product.agda).\n infixr 7 _,_\n\n -- The existential quantifier type on D.\n data ∃ (A : D → Set) : Set where\n _,_ : (x : D) → A x → ∃ A\n\n -- Sugar syntax for the existential quantifier.\n syntax ∃ (λ x → e) = ∃[ x ] e\n\n -- The existential proyections.\n ∃-proj₁ : ∀ {A} → ∃ A → D\n ∃-proj₁ (x , _) = x\n\n ∃-proj₂ : ∀ {A} → (h : ∃ A) → A (∃-proj₁ h)\n ∃-proj₂ (_ , Ax) = Ax\n\n -- Some examples\n\n -- The order of quantifiers of the same sort is irrelevant.\n ∃-ord : {A² : D → D → Set} → (∃[ x ] ∃[ y ] A² x y) → (∃[ y ] ∃[ x ] A² x y)\n ∃-ord (x , y , h) = y , x , h\n\n-----------------------------------------------------------------------------\n\nmodule ∃₂ where\n -- First-order logic version\n\n -- We add 3 to the fixities of the Agda standard library 0.8.1 (see\n -- Data/Product.agda).\n infixr 7 _,_\n\n -- The existential quantifier type on D.\n data ∃ (A : D → Set) : Set where\n _,_ : (x : D) → A x → ∃ A\n\n -- Sugar syntax for the existential quantifier.\n syntax ∃ (λ x → e) = ∃[ x ] e\n\n -- Existential elimination\n -- ∃x.A(x) A(x) → B\n -- ------------------------\n -- B\n\n -- NB. We do not use the usual type theory elimination with two\n -- projections because we are working in first-order logic where we\n -- do need extract a witness from an existence proof.\n ∃-elim : {A : D → Set}{B : Set} → ∃ A → ((x : D) → A x → B) → B\n ∃-elim (x , Ax) h = h x Ax\n\n -- Some examples\n\n -- The order of quantifiers of the same sort is irrelevant.\n ∃-ord : {A² : D → D → Set} → (∃[ x ] ∃[ y ] A² x y) → (∃[ y ] ∃[ x ] A² x y)\n ∃-ord h = ∃-elim h (λ x h₁ → ∃-elim h₁ (λ y prf → y , x , prf))\n\n -- A proof non-FOL valid\n non-FOL : {A : D → Set} → ∃ A → D\n non-FOL h = ∃-elim h (λ x _ → x)\n\n-----------------------------------------------------------------------------\n\nmodule ∃₃ where\n -- First-order logic version\n\n -- A different version from the existential introduction\n -- A(x)\n -- ------------\n -- ∃x.A(x)\n\n -- The existential quantifier type on D.\n data ∃ (A : D → Set) : Set where\n ∃-intro : ((x : D) → A x) → ∃ A\n\n -- Sugar syntax for the existential quantifier.\n syntax ∃ (λ x → e) = ∃[ x ] e\n\n postulate d : D\n\n -- Existential elimination.\n -- NB. It is neccesary that D ≢ ∅.\n ∃-elim : {A : D → Set}{B : Set} → ∃ A → ((x : D) → A x → B) → B\n ∃-elim (∃-intro h₁) h₂ = h₂ d (h₁ d)\n\n -- Some examples\n\n -- Impossible\n -- thm : {A : D → Set} → ∃[ x ] A x → ∃[ y ] A y\n -- thm h = ∃-elim h (λ x prf → {!!})\n", "meta": {"hexsha": "032d4de150f454c79483c1ccc5d9d3941476805c", "size": 3115, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/Common/FOL/Existential/Elimination.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/Elimination.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/Elimination.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.5779816514, "max_line_length": 78, "alphanum_fraction": 0.4593900482, "num_tokens": 1015, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.7122321720225279, "lm_q1q2_score": 0.5789502488919834}} {"text": "module Lec6 where\n\nopen import CS410-Prelude\nopen import CS410-Functor\nopen import CS410-Monoid\nopen import CS410-Nat\n\ndata Maybe (X : Set) : Set where\n yes : X -> Maybe X\n no : Maybe X\n\nmaybeFunctor : Functor Maybe\nmaybeFunctor = record\n { map = \\ { f (yes x) -> yes (f x)\n ; f no -> no\n }\n ; mapid = \\ { (yes x) -> refl ; no -> refl }\n ; mapcomp = \\ { f g (yes x) -> refl ; f g no -> refl } }\n\nopen Functor maybeFunctor\n\ndata List (X : Set) : Set where -- X scopes over the whole declaration...\n [] : List X -- ...so you can use it here...\n _::_ : X -> List X -> List X -- ...and here.\ninfixr 3 _::_\n\nmay-take : {X : Set} -> Nat -> List X -> Maybe (List X)\nmay-take zero xs = yes []\nmay-take (suc n) [] = no\nmay-take (suc n) (x :: xs) = map (_::_ x) (may-take n xs)\n\ndata Hutton : Set where\n val : Nat -> Hutton\n _+H_ : Hutton -> Hutton -> Hutton\n fail : Hutton\n\nmaybeApplicative : Applicative Maybe\nmaybeApplicative = record\n { pure = yes\n ; _<*>_ = \\ { no mx -> no\n ; (yes f) no -> no\n ; (yes f) (yes x) -> yes (f x)\n }\n ; identity = \\ {(yes x) -> refl ; no -> refl}\n ; composition = \\\n { (yes f) (yes g) (yes x) -> refl\n ; (yes f) (yes g) no -> refl\n ; (yes x) no mx -> refl\n ; no mg mx -> refl\n }\n ; homomorphism = \\ f x -> refl\n ; interchange = \\ { (yes f) y -> refl ; no y → refl }\n }\n\nmodule Eval where\n open Applicative maybeApplicative public\n\n eval : Hutton -> Maybe Nat\n eval (val x) = yes x\n eval (h +H h') = pure _+N_ <*> eval h <*> eval h'\n eval fail = no\n\n\nlistTrav : forall {F} -> Applicative F -> forall {A B} ->\n (A -> F B) -> List A -> F (List B)\nlistTrav {F} appF = trav where\n open Applicative appF\n trav : forall {A B} -> (A -> F B) -> List A -> F (List B)\n trav f [] = pure []\n trav f (a :: as) = pure _::_ <*> f a <*> trav f as\n\nlistTraversable : Traversable List\nlistTraversable = record { traverse = listTrav }\n\nI : Set -> Set\nI X = X\n\niApplicative : Applicative I\niApplicative = record\n { pure = id\n ; _<*>_ = id\n ; identity = \\ v -> refl\n ; composition = \\ f g v -> refl\n ; homomorphism = \\ f x -> refl\n ; interchange = \\ u y -> refl\n }\n\nlmap : forall {A B} -> (A -> B) -> List A -> List B\nlmap = traverse iApplicative where\n open Traversable listTraversable\n\nMonCon : forall {X} -> Monoid X -> Applicative \\_ -> X\nMonCon M = record\n { pure = {!!}\n ; _<*>_ = op\n ; identity = {!!}\n ; composition = {!!}\n ; homomorphism = {!!}\n ; interchange = {!!}\n } where open Monoid M\n\nlCombine : forall {A X} -> Monoid X -> (A -> X) -> List A -> X\nlCombine M = traverse (MonCon M) {B = One} where\n open Traversable listTraversable\n\nCurryApplicative : forall {E} -> Applicative \\X -> E -> X\nCurryApplicative = record\n { pure = \\ x e -> x -- K\n ; _<*>_ = \\ ef ex e -> ef e (ex e) -- S\n ; identity = λ {X} v → refl\n ; composition = λ {X} {Y} {Z} u v w → refl\n ; homomorphism = λ {X} {Y} f x → refl\n ; interchange = λ {X} {Y} u y → refl\n }\n\n\n", "meta": {"hexsha": "988884cdb49fe34a5784330fdf08e6de3fa9adfe", "size": 3572, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lec6.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": "Lec6.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": "Lec6.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": 30.5299145299, "max_line_length": 74, "alphanum_fraction": 0.459406495, "num_tokens": 1047, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587875995482, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.5788973718476604}} {"text": "\nmodule Haskell.Prim.Bool where\n\nopen import Agda.Primitive\nopen import Agda.Builtin.Bool public\n\nprivate\n variable\n ℓ : Level\n\n--------------------------------------------------\n-- Booleans\n\ninfixr 3 _&&_\n_&&_ : Bool → Bool → Bool\nfalse && _ = false\ntrue && x = x\n\ninfixr 2 _||_\n_||_ : Bool → Bool → Bool\nfalse || x = x\ntrue || _ = true\n\nnot : Bool → Bool\nnot false = true\nnot true = false\n\notherwise : Bool\notherwise = true\n", "meta": {"hexsha": "46b86ad7f90ce6fd77f6c59901ad8b23c887f952", "size": 433, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/Prim/Bool.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": "lib/Haskell/Prim/Bool.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": "lib/Haskell/Prim/Bool.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": 14.4333333333, "max_line_length": 50, "alphanum_fraction": 0.5750577367, "num_tokens": 128, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.839733983715524, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.5788333462210712}} {"text": "{-# OPTIONS --cubical --no-import-sorts #-}\n\nopen import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)\n\nmodule Number.Bundles where\n\nprivate\n variable\n ℓ ℓ' : Level\n\nopen import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)\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 _×_)\n\nopen import MoreAlgebra\nopen import Number.Structures\n\n-- ℕ ℤ ℚ ℝ ℂ and ℚ₀⁺ ℝ₀⁺ ...\n-- ring without additive inverse\nrecord RCommSemiring : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n Carrier : Type ℓ\n _#_ : Rel Carrier Carrier ℓ'\n -- RCommSemiring\n 0f 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n isRCommSemiring : IsRCommSemiring _#_ 0f 1f _+_ _·_\n\n open IsRCommSemiring isRCommSemiring public\n\n-- ℤ ℚ ℝ ℂ\nrecord RCommRing : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n Carrier : Type ℓ\n _#_ : Rel Carrier Carrier ℓ'\n -- RCommSemiring\n 0f 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n -- RCommRing\n -_ : Carrier → Carrier\n isRCommRing : IsRCommRing _#_ 0f 1f _+_ _·_ -_\n\n open IsRCommRing isRCommRing public\n\n-- ℚ ℝ ℂ\nrecord RField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n Carrier : Type ℓ\n _#_ : Rel Carrier Carrier ℓ'\n -- RCommSemiring\n 0f 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n -- RCommRing\n -_ : Carrier → Carrier\n -- RField\n _⁻¹ : (x : Carrier) → {{ x # 0f }} → Carrier\n isRField : IsRField _#_ 0f 1f _+_ _·_ -_ _⁻¹\n\n-- Finₖ ℕ ℤ ℚ ℚ₀⁺ ℚ⁺ ℝ ℝ₀⁺ ℝ⁺\nrecord RLattice : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n constructor rlattice\n field\n Carrier : Type ℓ\n _<_ _≤_ _#_ : Rel Carrier Carrier ℓ'\n min max : Carrier → Carrier → Carrier\n isRLattice : IsRLattice _<_ _≤_ _#_ min max\n\n open IsRLattice isRLattice public\n\n infixl 4 _<_\n infixl 4 _≤_\n infixl 4 _#_\n\n-- ℕ ℤ ℚ ℚ₀⁺ ℚ⁺ ℝ ℝ₀⁺ ℝ⁺\n-- ring without additive inverse\nrecord ROrderedCommSemiring : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n -- RLattice\n Carrier : Type ℓ\n _<_ _≤_ _#_ : Rel Carrier Carrier ℓ'\n min max : Carrier → Carrier → Carrier\n -- ROrderedCommSemiring\n 0f 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n -- _-_ : (x y : Carrier) → (y ≤ x) → Carrier -- is that a good idea?\n isROrderedCommSemiring : IsROrderedCommSemiring _<_ _≤_ _#_ min max 0f 1f _+_ _·_\n \n open IsROrderedCommSemiring isROrderedCommSemiring public\n\n\n-- ℤ ℚ ℝ\nrecord ROrderedCommRing : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n -- RLattice\n Carrier : Type ℓ\n _<_ _≤_ _#_ : Rel Carrier Carrier ℓ'\n min max : Carrier → Carrier → Carrier\n -- ROrderedCommSemiring\n 0f 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n -- ROrderedCommRing\n -_ : Carrier → Carrier\n isROrderedCommRing : IsROrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_\n\n open IsROrderedCommRing isROrderedCommRing public\n\n abs : Carrier → Carrier\n abs x = max x (- x)\n\n field\n isAbsOrderedCommRing : IsAbsOrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ abs\n\n open IsAbsOrderedCommRing isAbsOrderedCommRing public \n\n-- ℚ ℝ\nrecord ROrderedField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n -- RLattice\n Carrier : Type ℓ\n _<_ _≤_ _#_ : Rel Carrier Carrier ℓ'\n min max : Carrier → Carrier → Carrier\n -- ROrderedCommSemiring\n 0f 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n -- ROrderedCommRing\n -_ : Carrier → Carrier\n -- ROrderedField\n _⁻¹ : (x : Carrier) → {{ x # 0f }} → Carrier\n isROrderedField : IsROrderedField _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ _⁻¹\n \n open IsROrderedField isROrderedField public\n\n abs : Carrier → Carrier\n abs x = max x (- x)\n\n field\n isAbsOrderedCommRing : IsAbsOrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ abs\n\n open IsAbsOrderedCommRing isAbsOrderedCommRing public\n\n{-\n\n-- ℚ₀⁺ ℝ₀⁺\nrecord ROrderedSemifield : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n -- RLattice\n Carrier : Type ℓ\n _<_ _≤_ _#_ : Rel Carrier Carrier ℓ'\n min max : Carrier → Carrier → Carrier\n -- ROrderedCommSemiring\n 0f 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n -- ROrderedSemifield\n _-_ : (x y : Carrier) → (y ≤ x) → Carrier -- is that a good idea?\n _⁻¹ : (x : Carrier) → {{ 0f < x }} → Carrier\n\n-- ℚ⁺ ℝ⁺\nrecord ROrderedSemifieldWithoutZero : Type (ℓ-suc (ℓ-max ℓ ℓ')) where\n field\n -- RLattice\n Carrier : Type ℓ\n _<_ _≤_ _#_ : Rel Carrier Carrier ℓ'\n min max : Carrier → Carrier → Carrier\n -- ROrderedSemifieldWithoutZero\n 1f : Carrier\n _+_ _·_ : Carrier → Carrier → Carrier\n _-_ : (x y : Carrier) → (y < x) → Carrier -- is that a good idea?\n _⁻¹ : Carrier → Carrier\n\n-}\n", "meta": {"hexsha": "e7321321efe964235dbbfc82bde4d47ff44e5db8", "size": 4983, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Number/Bundles.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/Number/Bundles.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/Number/Bundles.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": 28.9709302326, "max_line_length": 88, "alphanum_fraction": 0.6120810757, "num_tokens": 1816, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339516289534, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.5788333241036181}} {"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties, related to products, that rely on the K rule\n------------------------------------------------------------------------\n\n{-# OPTIONS --with-K --safe #-}\n\nmodule Data.Product.Properties.WithK where\n\nopen import Data.Bool.Base\nopen import Data.Product\nopen import Data.Product.Properties using (,-injectiveˡ)\nopen import Function\nopen import Relation.Binary using (Decidable)\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Nullary.Reflects\nopen import Relation.Nullary using (Dec; _because_; yes; no)\nopen import Relation.Nullary.Decidable using (map′)\n\n------------------------------------------------------------------------\n-- Equality\n\nmodule _ {a b} {A : Set a} {B : Set b} where\n\n ,-injective : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → a ≡ c × b ≡ d\n ,-injective refl = refl , refl\n\nmodule _ {a b} {A : Set a} {B : A → Set b} where\n\n ,-injectiveʳ : ∀ {a} {b c : B a} → (Σ A B ∋ (a , b)) ≡ (a , c) → b ≡ c\n ,-injectiveʳ refl = refl\n\n -- Note: this is not an instance of `_×-dec_`, because we need `x` and `y`\n -- to have the same type before we can test them for equality.\n ≡-dec : Decidable _≡_ → (∀ {a} → Decidable {A = B a} _≡_) →\n Decidable {A = Σ A B} _≡_\n ≡-dec dec₁ dec₂ (a , x) (b , y) with dec₁ a b\n ... | false because [a≢b] = no (invert [a≢b] ∘ ,-injectiveˡ)\n ... | yes refl = map′ (cong (a ,_)) ,-injectiveʳ (dec₂ x y)\n", "meta": {"hexsha": "0b4d117d685182d62c12f31b02d1603938b14df1", "size": 1498, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Product/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/Product/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/Product/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": 36.5365853659, "max_line_length": 76, "alphanum_fraction": 0.5373831776, "num_tokens": 448, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8397339516289534, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.5788333187439604}} {"text": "-- Non-deterministic insert and permutation with choose oracle\n-- The module abstracts over the choice structure by importing it.\n\nopen import bool\n\nmodule perm-keep-length\n (Choice : Set)\n (choose : Choice → 𝔹)\n (lchoice : Choice → Choice)\n (rchoice : Choice → Choice)\n where\n\nopen import eq\nopen import bool-thms\nopen import nat\nopen import nat-thms\nopen import list\n\n----------------------------------------------------------------------\n\n-- Non-deterministic insert:\nndinsert : {a : Set} → Choice → a → 𝕃 a → 𝕃 a\nndinsert _ n [] = n :: []\nndinsert ch n (x :: xs) =\n if choose ch then n :: x :: xs\n else x :: ndinsert (lchoice ch) n xs\n\nperm : {a : Set} → Choice → 𝕃 a → 𝕃 a\nperm _ [] = []\nperm ch (x :: xs) = ndinsert (lchoice ch) x (perm (rchoice ch) xs)\n\n----------------------------------------------------------------------\n\n-- Non-deterministic insertion increases the list length by one:\ninsert-inc-length : ∀ {a : Set} → (ch : Choice) (x : a) (xs : 𝕃 a)\n → length (ndinsert ch x xs) ≡ suc (length xs)\ninsert-inc-length ch x [] = refl\ninsert-inc-length ch x (y :: ys) with choose ch\n... | tt = refl\n... | ff rewrite insert-inc-length (lchoice ch) x ys = refl\n\n-- The length of a permuted list is identical to the length of the list:\nperm-length : ∀ {a : Set} → (ch : Choice) (xs : 𝕃 a)\n → length (perm ch xs) =ℕ length xs ≡ tt\nperm-length ch [] = refl\nperm-length ch (x :: xs)\n rewrite insert-inc-length (lchoice ch) x (perm (rchoice ch) xs)\n | perm-length (rchoice ch) xs\n = refl\n\n----------------------------------------------------------------------\n", "meta": {"hexsha": "6945ac43942ce3849b9c5640d4a54234de24acee", "size": 1635, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "choices/perm-keep-length.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": "choices/perm-keep-length.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": "choices/perm-keep-length.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": 31.4423076923, "max_line_length": 72, "alphanum_fraction": 0.5388379205, "num_tokens": 442, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677506936878, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.5788005087767332}} {"text": "{-# OPTIONS --universe-polymorphism #-}\nmodule Categories.NaturalTransformation where\n\nopen import Categories.Category\nopen import Categories.Functor hiding (equiv) renaming (id to idF; _≡_ to _≡F_; _∘_ to _∘F_)\nopen import Categories.NaturalTransformation.Core public\n\ninfixr 9 _∘ˡ_ _∘ʳ_\n\n_∘ˡ_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂}\n → {C : Category o₀ ℓ₀ e₀} {D : Category o₁ ℓ₁ e₁} {E : Category o₂ ℓ₂ e₂}\n → {F G : Functor C D} \n → (H : Functor D E) → (η : NaturalTransformation F G) → NaturalTransformation (H ∘F F) (H ∘F G)\n_∘ˡ_ {C = C} {D} {E} {F} {G} H η′ = record \n { η = λ X → Functor.F₁ H (NaturalTransformation.η η′ X)\n ; commute = commute′\n }\n where\n module C = Category C\n module D = Category D renaming (_∘_ to _∘D_; _≡_ to _≡D_)\n module E = Category E renaming (_∘_ to _∘E_; _≡_ to _≡E_)\n module H = Functor H\n open D\n open E\n\n .commute′ : ∀ {X Y} (f : C [ X , Y ]) →\n Functor.F₁ H (NaturalTransformation.η η′ Y) ∘E Functor.F₁ H (Functor.F₁ F f) ≡E\n Functor.F₁ H (Functor.F₁ G f) ∘E Functor.F₁ H (NaturalTransformation.η η′ X)\n commute′ {X} {Y} f = \n begin\n Functor.F₁ H (NaturalTransformation.η η′ Y) ∘E Functor.F₁ H (Functor.F₁ F f)\n ↑⟨ H.homomorphism ⟩\n Functor.F₁ H (NaturalTransformation.η η′ Y ∘D Functor.F₁ F f)\n ↓⟨ H.F-resp-≡ (NaturalTransformation.commute η′ f) ⟩\n Functor.F₁ H (Functor.F₁ G f ∘D NaturalTransformation.η η′ X)\n ↓⟨ H.homomorphism ⟩\n Functor.F₁ H (Functor.F₁ G f) ∘E Functor.F₁ H (NaturalTransformation.η η′ X)\n ∎\n where\n open E.HomReasoning\n\n\n_∘ʳ_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂}\n → {C : Category o₀ ℓ₀ e₀} {D : Category o₁ ℓ₁ e₁} {E : Category o₂ ℓ₂ e₂}\n → {F G : Functor C D} \n → (η : NaturalTransformation F G) → (K : Functor E C) → NaturalTransformation (F ∘F K) (G ∘F K)\n_∘ʳ_ η K = record\n { η = λ X → NaturalTransformation.η η (Functor.F₀ K X)\n ; commute = λ f → NaturalTransformation.commute η (Functor.F₁ K f)\n }\n\n\n\n-- The vertical versions\n.identity₁ˡ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} \n → id ∘₁ X ≡ X\nidentity₁ˡ {D = D} = Category.identityˡ D\n\n.identity₁ʳ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} \n → X ∘₁ id ≡ X\nidentity₁ʳ {D = D} = Category.identityʳ D\n\n\n\n.assoc₁ : ∀ {o ℓ e o′ ℓ′ e′} \n {P : Category o ℓ e} {Q : Category o′ ℓ′ e′} {A B C D : Functor P Q} \n {X : NaturalTransformation A B} {Y : NaturalTransformation B C} {Z : NaturalTransformation C D} \n → (Z ∘₁ Y) ∘₁ X ≡ Z ∘₁ (Y ∘₁ X)\nassoc₁ {Q = Q} = Category.assoc Q\n\n\n-- The horizontal ones\n.identity₀ˡ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} \n → id {F = idF} ∘₀ X ≡ X\nidentity₀ˡ {D = D} = Category.identityʳ D\n\n.identity₀ʳ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} {X : NaturalTransformation F G} \n → X ∘₀ id {F = idF} ≡ X\nidentity₀ʳ {C = C} {D} {F} {G} {X} = \n begin\n G₁ C.id ∘ (η _)\n ↓⟨ ∘-resp-≡ˡ G.identity ⟩\n D.id ∘ (η _)\n ↓⟨ D.identityˡ ⟩\n η _\n ∎\n where\n module C = Category C\n module D = Category D\n module F = Functor F\n module G = Functor G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡)\n open NaturalTransformation X\n open D.HomReasoning\n open F\n open G\n open D\n\nopen import Categories.Functor.Core using () renaming ( _∘_ to _∘F_)\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 G : Functor C₀ C₁} {H I : Functor C₁ C₂} {J K : Functor C₂ C₃}\n → {X : NaturalTransformation F G} → {Y : NaturalTransformation H I} → {Z : NaturalTransformation J K}\n → (Z ∘₀ Y) ∘₀ X ≡ (_∘₀_ {F = H ∘F F} {I ∘F G} Z (_∘₀_ {C = C₀} {C₁} {C₂} Y X))\nassoc₀ {C₀ = C₀} {C₁} {C₂} {C₃} {F} {G} {H} {I} {J} {K} {X} {Y} {Z} = \n begin\n K₁ (I₁ (X.η _)) ∘C₃ (K₁ (Y.η (F₀ _)) ∘C₃ Z.η (H₀ (F₀ _)))\n ↑⟨ C₃.assoc ⟩\n (K₁ (I₁ (X.η _)) ∘C₃ K₁ (Y.η (F₀ _))) ∘C₃ Z.η (H₀ (F₀ _))\n ↑⟨ C₃.∘-resp-≡ˡ K.homomorphism ⟩\n (K₁ ((I₁ (X.η _)) ∘C₂ Y.η (F₀ _))) ∘C₃ Z.η (H₀ (F₀ _))\n ∎\n where\n module C₂ = Category C₂ renaming (_∘_ to _∘C₂_; _≡_ to _≡C₂_)\n module C₃ = Category C₃ renaming (_∘_ to _∘C₃_; _≡_ to _≡C₃_)\n module F = Functor F\n module G = Functor G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡)\n module H = Functor H renaming (F₀ to H₀; F₁ to H₁; F-resp-≡ to H-resp-≡)\n module I = Functor I renaming (F₀ to I₀; F₁ to I₁; F-resp-≡ to I-resp-≡)\n module J = Functor J renaming (F₀ to J₀; F₁ to J₁; F-resp-≡ to J-resp-≡)\n module K = Functor K renaming (F₀ to K₀; F₁ to K₁; F-resp-≡ to K-resp-≡)\n module X = NaturalTransformation X\n module Y = NaturalTransformation Y\n module Z = NaturalTransformation Z\n open C₃.HomReasoning\n open C₂\n open C₃\n open F\n open H\n open I\n open K\n\n\n.interchange : ∀ {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {o₂ ℓ₂ e₂}\n {C₀ : Category o₀ ℓ₀ e₀} {C₁ : Category o₁ ℓ₁ e₁} {C₂ : Category o₂ ℓ₂ e₂}\n {F₀ F₁ F₅ : Functor C₀ C₁} {F₂ F₃ F₄ : Functor C₁ C₂} \n {α : NaturalTransformation F₃ F₄} \n {β : NaturalTransformation F₁ F₅} \n {γ : NaturalTransformation F₂ F₃} \n {δ : NaturalTransformation F₀ F₁} \n → (α ∘₀ β) ∘₁ (γ ∘₀ δ) ≡ (α ∘₁ γ) ∘₀ (β ∘₁ δ)\ninterchange {C₀ = C₀} {C₁} {C₂} {F₀} {F₁} {F₅} {F₂} {F₃} {F₄} {α} {β} {γ} {δ} = \n begin\n (F₄.F₁ (β.η _) ∘ α.η (F₁.F₀ _)) ∘ (F₃.F₁ (δ.η _) ∘ γ.η (F₀.F₀ _))\n ↓⟨ C₂.assoc ⟩\n F₄.F₁ (β.η _) ∘ (α.η (F₁.F₀ _) ∘ (F₃.F₁ (δ.η _) ∘ γ.η (F₀.F₀ _)))\n ↑⟨ C₂.∘-resp-≡ʳ C₂.assoc ⟩\n F₄.F₁ (β.η _) ∘ ((α.η (F₁.F₀ _) ∘ (F₃.F₁ (δ.η _))) ∘ γ.η (F₀.F₀ _))\n ↓⟨ C₂.∘-resp-≡ʳ (C₂.∘-resp-≡ˡ (α.commute (δ.η _))) ⟩\n F₄.F₁ (β.η _) ∘ ((F₄.F₁ (δ.η _) ∘ α.η (F₀.F₀ _)) ∘ γ.η (F₀.F₀ _))\n ↓⟨ C₂.∘-resp-≡ʳ C₂.assoc ⟩\n F₄.F₁ (β.η _) ∘ (F₄.F₁ (δ.η _) ∘ (α.η (F₀.F₀ _) ∘ γ.η (F₀.F₀ _)))\n ↑⟨ C₂.assoc ⟩\n (F₄.F₁ (β.η _) ∘ F₄.F₁ (δ.η _)) ∘ (α.η (F₀.F₀ _) ∘ γ.η (F₀.F₀ _))\n ↑⟨ C₂.∘-resp-≡ˡ F₄.homomorphism ⟩\n F₄.F₁ (β.η _ ∘C₁ δ.η _) ∘ (α.η (F₀.F₀ _) ∘ γ.η (F₀.F₀ _))\n ∎\n where\n module C₁ = Category C₁ renaming (_∘_ to _∘C₁_; _≡_ to _≡C₁_)\n module C₂ = Category C₂ \n module F₀ = Functor F₀\n module F₁ = Functor F₁\n module F₂ = Functor F₂\n module F₃ = Functor F₃\n module F₄ = Functor F₄\n module F₅ = Functor F₅\n module α = NaturalTransformation α\n module β = NaturalTransformation β\n module γ = NaturalTransformation γ\n module δ = NaturalTransformation δ\n open C₁\n open C₂\n open C₂.HomReasoning\n\n\n.∘₁-resp-≡ : ∀ {o ℓ e} {o′ ℓ′ e′}\n {D : Category o ℓ e} {E : Category o′ ℓ′ e′}\n {A B C : Functor D E} \n {f h : NaturalTransformation B C} {g i : NaturalTransformation A B} \n → f ≡ h → g ≡ i → f ∘₁ g ≡ h ∘₁ i\n∘₁-resp-≡ {E = E} f≡h g≡i = Category.∘-resp-≡ E f≡h g≡i\n\n.∘₀-resp-≡ : ∀ {o ℓ e} {o′ ℓ′ e′} {o″ ℓ″ e″}\n {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o″ ℓ″ e″}\n {F F′ : Functor C D} {G G′ : Functor D E}\n {f h : NaturalTransformation G G′} {g i : NaturalTransformation F F′}\n → f ≡ h → g ≡ i → f ∘₀ g ≡ h ∘₀ i\n∘₀-resp-≡ {E = E} {G′ = G′} f≡h g≡i = Category.∘-resp-≡ E (Functor.F-resp-≡ G′ g≡i) f≡h\n", "meta": {"hexsha": "d3b8f594984e717d3a39152eed15c5788c30b7ca", "size": 7489, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Categories/NaturalTransformation.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/NaturalTransformation.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/NaturalTransformation.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": 39.835106383, "max_line_length": 130, "alphanum_fraction": 0.5484043263, "num_tokens": 3401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677506936878, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5788005033012571}} {"text": "module Issue417 where\n\ndata _≡_ (A : Set₁) : Set₁ → Set₂ where\n refl : A ≡ A\n\nabstract\n\n A : Set₁\n A = Set\n\n unfold-A : A ≡ Set\n unfold-A = refl\n\n-- The result of inferring the type of unfold-A is the following:\n--\n-- Set ≡ Set\n", "meta": {"hexsha": "8cce996cc54af542fb45014d34b28b57c7fbf91c", "size": 235, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue417.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/Issue417.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/Issue417.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.8235294118, "max_line_length": 65, "alphanum_fraction": 0.6127659574, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240895276223, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.5787313085715047}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\nopen import Categories.Functor\n\nmodule Categories.Diagram.Limit.Properties\n {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} where\n\nopen import Categories.Diagram.Cone.Properties\nopen import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_; module ≃)\nopen import Categories.Morphism.Reasoning C\nopen import Categories.Morphism C\n\nimport Categories.Category.Construction.Cones as Con\nimport Categories.Diagram.Limit as Lim\n\nprivate\n module J = Category J\n module C = Category C\n\n open C\n variable\n X Y Z : Obj\n f g h : X ⇒ Y\n\nopen HomReasoning\n\n-- natural isomorphisms respects limits\nmodule _ {F G : Functor J C} (F≃G : F ≃ G) where\n private\n module F = Functor F\n module G = Functor G\n module LF = Lim F\n module LG = Lim G\n open NaturalIsomorphism F≃G\n\n ≃-resp-lim : LF.Limit → LG.Limit\n ≃-resp-lim L = record\n { terminal = record\n { ⊤ = record\n { apex = record\n { ψ = λ j → ⇒.η j ∘ proj j\n ; commute = λ {X Y} f → begin\n G.F₁ f ∘ ⇒.η X ∘ proj X ≈⟨ pullˡ (⇒.sym-commute f) ⟩\n (⇒.η Y ∘ F.F₁ f) ∘ proj X ≈⟨ pullʳ (limit-commute f) ⟩\n ⇒.η Y ∘ proj Y ∎\n }\n }\n ; ⊤-is-terminal = record\n { ! = λ {A} → record\n { arr = rep (nat-map-Cone F⇐G A)\n ; commute = λ {j} → assoc ○ ⟺ (switch-tofromˡ (record { iso = iso j }) (⟺ commute))\n }\n ; !-unique = λ {K} f →\n let module f = Con.Cone⇒ G f\n in terminal.!-unique record\n { arr = f.arr\n ; commute = λ {j} → switch-fromtoˡ (record { iso = iso j }) (sym-assoc ○ f.commute)\n }\n }\n }\n }\n where open LF.Limit L\n\n ≃⇒Cone⇒ : ∀ (Lf : LF.Limit) (Lg : LG.Limit) → Con.Cones G [ LG.Limit.limit (≃-resp-lim Lf) , LG.Limit.limit Lg ]\n ≃⇒Cone⇒ Lf Lg = rep-cone (LG.Limit.limit (≃-resp-lim Lf))\n where open LG.Limit Lg\n\n≃⇒lim≅ : ∀ {F G : Functor J C} (F≃G : F ≃ G) (Lf : Lim.Limit F) (Lg : Lim.Limit G) → Lim.Limit.apex Lf ≅ Lim.Limit.apex Lg\n≃⇒lim≅ {F = F} {G} F≃G Lf Lg = record\n { from = arr (≃⇒Cone⇒ F≃G Lf Lg)\n ; to = arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf)\n ; iso = record\n { isoˡ = Lf.terminal.⊤-id record\n { commute = λ {j} → begin\n Lf.proj j ∘ arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf) ∘ arr (≃⇒Cone⇒ F≃G Lf Lg) ≈⟨ pullˡ (⇒-commute (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf)) ⟩\n (⇐.η j ∘ Lg.proj j) ∘ arr (≃⇒Cone⇒ F≃G Lf Lg) ≈⟨ pullʳ (⇒-commute (≃⇒Cone⇒ F≃G Lf Lg)) ⟩\n ⇐.η j ∘ ⇒.η j ∘ Lf.proj j ≈⟨ cancelˡ (iso.isoˡ j) ⟩\n Lf.proj j ∎\n }\n ; isoʳ = Lg.terminal.⊤-id record\n { commute = λ {j} → begin\n Lg.proj j ∘ arr (≃⇒Cone⇒ F≃G Lf Lg) ∘ arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf) ≈⟨ pullˡ (⇒-commute (≃⇒Cone⇒ F≃G Lf Lg)) ⟩\n (⇒.η j ∘ Lf.proj j) ∘ arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf) ≈⟨ pullʳ (⇒-commute (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf)) ⟩\n ⇒.η j ∘ ⇐.η j ∘ Lg.proj j ≈⟨ cancelˡ (iso.isoʳ j) ⟩\n Lg.proj j ∎\n }\n }\n }\n where open Con.Cone⇒ renaming (commute to ⇒-commute)\n module Lf = Lim.Limit Lf\n module Lg = Lim.Limit Lg\n open NaturalIsomorphism F≃G\n", "meta": {"hexsha": "bd08b28e697521b422a3c80061bede06a1e23833", "size": 3486, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Limit/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/Limit/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/Limit/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": 37.085106383, "max_line_length": 128, "alphanum_fraction": 0.4928284567, "num_tokens": 1411, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240756264639, "lm_q2_score": 0.6688802537704064, "lm_q1q2_score": 0.5787312992732945}} {"text": "-- Andreas, 2014-10-09\n-- Reported by ohmanjoakim\n\ninfixr 8 _⇒_\n\ndata Ty : Set where\n _⇒_ : Ty → Ty → Ty\n\n⟦_⟧ : Ty → Set\n⟦ A ⇒ B ⟧ = ⟦ A ⟧ → ⟦ B ⟧\n\ndata Term : Ty → Set where\n K : (A B : Ty) → Term (A ⇒ B ⇒ A)\n\ntest : (A : Ty) (a : Term A) → ⟦ A ⟧\ntest A a = {!a!}\n\n-- When doing a case split on a in foo, the following is written:\n-- test .(x ⇒ x₁ ⇒ x) (K A B) x x₁ = ?\n\n-- Correct is\n-- test .(A ⇒ B ⇒ A) (K A B) x x₁ = ?\n", "meta": {"hexsha": "e98fdb7ecd53b2f50c674155f98db10936395669", "size": 426, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue1298.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/interaction/Issue1298.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/Issue1298.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": 18.5217391304, "max_line_length": 65, "alphanum_fraction": 0.4976525822, "num_tokens": 194, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.835483553488848, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.5786909747633732}} {"text": "\nmodule Prelude where\n\ninfixr 90 _∘_\ninfixr 50 _∧_\ninfix 20 _⟸⇒_\ninfixl 3 _from_\n\n_from_ : (A : Set) -> A -> A\nA from a = a\n\n_∘_ : {A B C : Set} -> (A -> B) -> (C -> A) -> C -> B\n(f ∘ g) x = f (g x)\n\nrecord _∧_ (A B : Set) : Set where\n field\n p₁ : A\n p₂ : B\n\nopen _∧_ public renaming (p₁ to fst; p₂ to snd)\n\n_,_ : {A B : Set} -> A -> B -> A ∧ B\nx , y = record { p₁ = x; p₂ = y }\n\nswap : {A B : Set} -> A ∧ B -> B ∧ A\nswap p = (snd p , fst p)\n\n_⇐⇒_ : Set -> Set -> Set\nA ⇐⇒ B = (A -> B) ∧ (B -> A)\n", "meta": {"hexsha": "49ff3483babdd8a3781d838ba3eeb183b8083c1f", "size": 506, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/lattice/Prelude.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/lattice/Prelude.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/lattice/Prelude.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.8666666667, "max_line_length": 53, "alphanum_fraction": 0.4604743083, "num_tokens": 247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933093975331751, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.5786842358018641}} {"text": "{-# OPTIONS --without-K --rewriting #-}\n\nopen import HoTT\nopen import homotopy.elims.SuspSmash\nopen import homotopy.elims.CofPushoutSection\n\n-- Σ(X∧Y) ≃ X * Y\n\nmodule homotopy.SuspSmash {i j} (X : Ptd i) (Y : Ptd j) where\n\nprivate\n\n {- path lemmas -}\n private\n reduce-x : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : z == y)\n → p ∙ ! q ∙ q ∙ ! p ∙ p == p\n reduce-x idp idp = idp\n\n reduce-y : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : x == z)\n → p ∙ ! p ∙ q ∙ ! q ∙ p == p\n reduce-y idp idp = idp\n\n module Into = SuspRec {A = Smash X Y}\n {C = de⊙ X * de⊙ Y}\n (left (pt X))\n (right (pt Y))\n (Smash-rec\n (λ x y →\n jglue (pt X) (pt Y) ∙ ! (jglue x (pt Y))\n ∙ jglue x y\n ∙ ! (jglue (pt X) y) ∙ jglue (pt X) (pt Y))\n (jglue (pt X) (pt Y))\n (jglue (pt X) (pt Y))\n (λ x → reduce-x (jglue (pt X) (pt Y)) (jglue x (pt Y)))\n (λ y → reduce-y (jglue (pt X) (pt Y)) (jglue (pt X) y)))\n\n into = Into.f\n\n module Out = JoinRec\n {C = Susp (Smash X Y)}\n (λ _ → north)\n (λ _ → south)\n (λ x y → merid (smin x y))\n\n out = Out.f\n\n abstract\n into-out : (j : de⊙ X * de⊙ Y) → into (out j) == j\n into-out = Join-elim\n (λ x → glue (pt X , pt Y) ∙ ! (glue (x , pt Y)))\n (λ y → ! (glue (pt X , pt Y)) ∙ glue (pt X , y))\n (λ x y → ↓-∘=idf-from-square into out $\n (ap (ap into) (Out.glue-β x y)\n ∙ Into.merid-β (smin x y))\n ∙v⊡ lemma (glue (pt X , pt Y)) (glue (x , pt Y))\n (glue (pt X , y)) (glue (x , y)))\n where\n lemma : ∀ {i} {A : Type i} {x y z w : A}\n (p : x == y) (q : z == y) (r : x == w) (s : z == w)\n → Square (p ∙ ! q) (p ∙ ! q ∙ s ∙ ! r ∙ p) s (! p ∙ r)\n lemma idp idp idp s =\n vert-degen-square (∙-unit-r s)\n\n out-into : (σ : Susp (Smash X Y)) → out (into σ) == σ\n out-into = SuspSmash-elim\n idp\n idp\n (λ x y → ↓-∘=idf-in' out into $\n ap (ap out) (Into.merid-β (smin x y))\n ∙ lemma₁ out (Out.glue-β (pt X) (pt Y))\n (Out.glue-β x (pt Y))\n (Out.glue-β x y)\n (Out.glue-β (pt X) y)\n (Out.glue-β (pt X) (pt Y))\n ∙ lemma₂ {p = merid (smin (pt X) (pt Y))}\n {q = merid (smin x (pt Y))}\n {r = merid (smin x y)}\n {s = merid (smin (pt X) y)}\n {t = merid (smin (pt X) (pt Y))}\n (ap merid (smgluel (pt X) ∙ ! (smgluel x)))\n (ap merid (smgluer y ∙ ! (smgluer (pt Y)))))\n where\n lemma₁ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)\n {x y z u v w : A}\n {p : x == y} {q : z == y} {r : z == u} {s : v == u} {t : v == w}\n {p' : f x == f y} {q' : f z == f y} {r' : f z == f u}\n {s' : f v == f u} {t' : f v == f w}\n (α : ap f p == p') (β : ap f q == q') (γ : ap f r == r')\n (δ : ap f s == s') (ε : ap f t == t')\n → ap f (p ∙ ! q ∙ r ∙ ! s ∙ t) == p' ∙ ! q' ∙ r' ∙ ! s' ∙ t'\n lemma₁ f {p = idp} {q = idp} {r = idp} {s = idp} {t = idp}\n idp idp idp idp idp\n = idp\n\n lemma₂ : ∀ {i} {A : Type i} {x y z u : A}\n {p q : x == y} {r : x == z} {s t : u == z}\n (α : p == q) (β : s == t)\n → p ∙ ! q ∙ r ∙ ! s ∙ t == r\n lemma₂ {p = idp} {r = idp} {s = idp} idp idp = idp\n\nmodule SuspSmash where\n\n eq : Susp (Smash X Y) ≃ (de⊙ X * de⊙ Y)\n eq = equiv into out into-out out-into\n\n ⊙eq : ⊙Susp (⊙Smash X Y) ⊙≃ (X ⊙* Y)\n ⊙eq = ≃-to-⊙≃ eq idp\n", "meta": {"hexsha": "0a50238da090830a3e47c5f144a5040527194426", "size": 3520, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "theorems/homotopy/SuspSmash.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/SuspSmash.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/SuspSmash.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": 32.5925925926, "max_line_length": 72, "alphanum_fraction": 0.4, "num_tokens": 1515, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.851952809486198, "lm_q2_score": 0.6791787121629465, "lm_q1q2_score": 0.57862821197044}} {"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Finite.Fin.Construction.Poset where\n\nopen import Data.Nat using (ℕ; z≤n; s≤s)\nopen import Data.Sum\nopen import Data.Product using (Σ; _,_; _×_)\nopen import Data.Fin\nopen import Data.Fin.Patterns\n\nopen import Relation.Binary.PropositionalEquality as ≡\n\nopen import Categories.Category.Finite.Fin\nopen import Categories.Category\n\nprivate\n card : ∀ {n} → Fin n → Fin n → ℕ\n card {ℕ.suc n} zero y = 1\n card {ℕ.suc n} (suc x) zero = 0\n card {ℕ.suc n} (suc x) (suc y) = card x y\n\n id : ∀ n {a : Fin n} → Fin (card a a)\n id .(ℕ.suc _) {zero} = 0F\n id (ℕ.suc n) {suc a} = id n\n\n comp : ∀ n {a b c : Fin n} → Fin (card b c) → Fin (card a b) → Fin (card a c)\n comp (ℕ.suc n) {0F} {b} {c} f g = 0F\n comp (ℕ.suc n) {suc a} {suc b} {suc c} f g = comp n f g\n\n assoc : ∀ n {a b c d : Fin n} {f : Fin (card a b)} {g : Fin (card b c)} {h : Fin (card c d)} →\n comp n (comp n h g) f ≡ comp n h (comp n g f)\n assoc (ℕ.suc n) {0F} {b} {c} {d} {f} {g} {h} = refl\n assoc (ℕ.suc n) {suc a} {suc b} {suc c} {suc d} {f} {g} {h} = assoc n\n\n identityˡ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n (id n) f ≡ f\n identityˡ (ℕ.suc n) {0F} {b} {0F} = refl\n identityˡ (ℕ.suc n) {suc a} {suc b} {f} = identityˡ n\n\n identityʳ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n f (id n) ≡ f\n identityʳ (ℕ.suc n) {0F} {b} {0F} = refl\n identityʳ (ℕ.suc n) {suc a} {suc b} {f} = identityʳ n\n\ncard-rel : ∀ {n} (x y : Fin n) → card x y ≡ 1 × x ≤ y ⊎ card x y ≡ 0 × y < x\ncard-rel {ℕ.suc n} 0F y = inj₁ (refl , z≤n)\ncard-rel {ℕ.suc n} (suc x) 0F = inj₂ (refl , s≤s z≤n)\ncard-rel {ℕ.suc n} (suc x) (suc y) with card-rel x y\n... | inj₁ (eq , x≤y) = inj₁ (eq , s≤s x≤y)\n... | inj₂ (eq , y