Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The Agda standard library -- -- A categorical view of Stream ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.Stream.Categorical where open import Data.Product using (<_,_>) open import Codata.Stream open import Function open import Category.Functor open import Category.Applicative open import Category.Comonad functor : ∀ {ℓ i} → RawFunctor {ℓ} (λ A → Stream A i) functor = record { _<$>_ = λ f → map f } applicative : ∀ {ℓ i} → RawApplicative {ℓ} (λ A → Stream A i) applicative = record { pure = repeat ; _⊛_ = ap } comonad : ∀ {ℓ} → RawComonad {ℓ} (λ A → Stream A _) comonad = record { extract = head ; extend = unfold ∘′ < tail ,_> }
{ "alphanum_fraction": 0.5425790754, "avg_line_length": 25.6875, "ext": "agda", "hexsha": "0380b5571c17025d892f61eadea7842f06dcb67c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/Stream/Categorical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/Stream/Categorical.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/Stream/Categorical.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 221, "size": 822 }
module Issue470 where data Bool : Set where true false : Bool _and_ : Bool → Bool → Bool true and x = x false and x = false infixr 5 _∷_ data Foo : Bool → Set where [] : Foo true _∷_ : ∀ {b} (x : Bool) → Foo b → Foo (x and b) Baz : Bool → Set Baz true = Bool Baz false = Foo false data Bar : ∀ {b} → Foo b → Set where [] : Bar [] _∷_ : ∀ {b} {foo : Foo b} {x} (g : Baz x) → (bar : Bar foo) → Bar (x ∷ foo) foo : Foo false foo = false ∷ true ∷ [] bar : Bar foo bar = (false ∷ []) ∷ false ∷ [] -- ← is yellow {- _59 := _55 ∷ false ∷ [] [blocked by problem 75] [75] ["apply" (_53 ∷ true ∷ [])] == ["apply" (false ∷ true ∷ [])] : Foo (_53 and (true and true)) → Set [blocked by problem 76] [76] (_53 and (true and true)) = false : Bool _54 := false ∷ [] :? Baz _53 -}
{ "alphanum_fraction": 0.5445292621, "avg_line_length": 21.2432432432, "ext": "agda", "hexsha": "f3fd8d2d5c1ca389602f33d82b4c7ebd95291b1a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue470.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue470.agda", "max_line_length": 77, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue470.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 304, "size": 786 }
module Data.Permutation where open import Prelude open import Data.Fin as Fin hiding (_==_; _<_) open import Data.Nat open import Data.Vec open import Logic.Identity open import Logic.Base import Logic.ChainReasoning -- What is a permutation? -- Answer 1: A bijection between Fin n and itself data Permutation (n : Nat) : Set where permutation : (π π⁻¹ : Fin n -> Fin n) -> (forall {i} -> π (π⁻¹ i) ≡ i) -> Permutation n module Permutation {n : Nat}(P : Permutation n) where private π' : Permutation n -> Fin n -> Fin n π' (permutation x _ _) = x π⁻¹' : Permutation n -> Fin n -> Fin n π⁻¹' (permutation _ x _) = x proof : (P : Permutation n) -> forall {i} -> π' P (π⁻¹' P i) ≡ i proof (permutation _ _ x) = x π : Fin n -> Fin n π = π' P π⁻¹ : Fin n -> Fin n π⁻¹ = π⁻¹' P module Proofs where ππ⁻¹-id : {i : Fin n} -> π (π⁻¹ i) ≡ i ππ⁻¹-id = proof P open module Chain = Logic.ChainReasoning.Poly.Homogenous _≡_ (\x -> refl) (\x y z -> trans) π⁻¹-inj : (i j : Fin n) -> π⁻¹ i ≡ π⁻¹ j -> i ≡ j π⁻¹-inj i j h = chain> i === π (π⁻¹ i) by sym ππ⁻¹-id === π (π⁻¹ j) by cong π h === j by ππ⁻¹-id -- Generalise lem : {n : Nat}(f g : Fin n -> Fin n) -> (forall i -> f (g i) ≡ i) -> (forall i -> g (f i) ≡ i) lem {zero} f g inv () lem {suc n} f g inv i = ? where gz≠gs : {i : Fin n} -> g fzero ≢ g (fsuc i) gz≠gs {i} gz=gs = fzero≠fsuc $ chain> fzero === f (g fzero) by sym (inv fzero) === f (g (fsuc i)) by cong f gz=gs === fsuc i by inv (fsuc i) z≠f-thin-gz : {i : Fin n} -> fzero ≢ f (thin (g fzero) i) z≠f-thin-gz {i} z=f-thin-gz = ? -- f (g fzero) -- = fzero -- = f (thin (g fzero) i) g' : Fin n -> Fin n g' j = thick (g fzero) (g (fsuc j)) gz≠gs f' : Fin n -> Fin n f' j = thick fzero (f (thin (g fzero) j)) ? g'f' : forall j -> g' (f' j) ≡ j g'f' = lem {n} f' g' ? π⁻¹π-id : forall {i} -> π⁻¹ (π i) ≡ i π⁻¹π-id = ? -- Answer 2: A Vec (Fin n) n with no duplicates {- infixr 40 _◅_ _↦_,_ infixr 20 _○_ data Permutation : Nat -> Set where ε : Permutation zero _◅_ : {n : Nat} -> Fin (suc n) -> Permutation n -> Permutation (suc n) _↦_,_ : {n : Nat}(i j : Fin (suc n)) -> Permutation n -> Permutation (suc n) fzero ↦ j , π = j ◅ π fsuc i ↦ j , j' ◅ π = thin j j' ◅ i ↦ ? , π indices : {n : Nat} -> Permutation n -> Vec (Fin n) n indices ε = [] indices (i ◅ π) = i :: map (thin i) (indices π) -- permute (i ◅ π) xs with xs [!] i where -- permute₁ (i ◅ π) .(insert i x xs) (ixV x xs) = x :: permute π xs permute : {n : Nat}{A : Set} -> Permutation n -> Vec A n -> Vec A n permute (i ◅ π) xs = permute' π i xs (xs [!] i) where permute' : {n : Nat}{A : Set} -> Permutation n -> (i : Fin (suc n))(xs : Vec A (suc n)) -> IndexView i xs -> Vec A (suc n) permute' π i .(insert i x xs') (ixV x xs') = x :: permute π xs' delete : {n : Nat} -> Fin (suc n) -> Permutation (suc n) -> Permutation n delete fzero (j ◅ π) = π delete {zero} (fsuc ()) _ delete {suc _} (fsuc i) (j ◅ π) = ? ◅ delete i π identity : {n : Nat} -> Permutation n identity {zero } = ε identity {suc n} = fzero ◅ identity _⁻¹ : {n : Nat} -> Permutation n -> Permutation n ε ⁻¹ = ε (i ◅ π) ⁻¹ = ? _○_ : {n : Nat} -> Permutation n -> Permutation n -> Permutation n ε ○ π₂ = ε i ◅ π₁ ○ π₂ = (indices π₂ ! i) ◅ (π₁ ○ delete i π₂) -}
{ "alphanum_fraction": 0.5268691589, "avg_line_length": 26.1374045802, "ext": "agda", "hexsha": "9db4549f15adf1152a36f5d04d6bba22e04d7264", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_line_length": 95, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 1435, "size": 3424 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory module cw.cohomology.TopGrid {i} (OT : OrdinaryTheory i) (n : ℤ) {X Y Z : Ptd i} (f : X ⊙→ Y) (g : Y ⊙→ Z) where {- X --> Y ---> Z | | this | v v one v 1 -> Y/X -> Z/X -} open OrdinaryTheory OT open import cohomology.PtdMapSequence cohomology-theory open import cw.cohomology.GridPtdMap f g using (Y/X-to-Z/X) top-grid-comm-sqr : CommSquare (fst g) (fst Y/X-to-Z/X) cfcod cfcod top-grid-comm-sqr = comm-sqr λ _ → idp C-top-grid-commutes : CommSquareᴳ (C-fmap n Y/X-to-Z/X) (C-fmap n g) (C-fmap n (⊙cfcod' (g ⊙∘ f))) (C-fmap n (⊙cfcod' f)) C-top-grid-commutes = C-comm-square n top-grid-comm-sqr
{ "alphanum_fraction": 0.6151724138, "avg_line_length": 27.8846153846, "ext": "agda", "hexsha": "fd003316db28d02fe24fd80ffcbc8106023e9ed0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/TopGrid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/TopGrid.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/TopGrid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 284, "size": 725 }
module my-nat where open import product open import bool open import eq data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} infixl 10 _*_ infixl 9 _+_ --infixl 8 _<_ _=ℕ_ _≤_ _>_ _≥_ _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) 0+ : ∀ (x : ℕ) → 0 + x ≡ x 0+ x = refl +0 : ∀ (x : ℕ) → x + 0 ≡ x +0 zero = refl +0 (suc x) rewrite +0 x = refl +assoc : ∀ (x y z : ℕ) → x + (y + z) ≡ (x + y) + z +assoc zero y z = refl +assoc (suc x) y z rewrite +assoc x y z = refl +suc : ∀ (x y : ℕ) → x + (suc y) ≡ suc(x + y) +suc zero y = refl +suc (suc x) y rewrite +suc x y = refl +comm : ∀ (x y : ℕ) → x + y ≡ y + x +comm zero y rewrite +0 y = refl +comm (suc x) y rewrite +suc y x | +comm x y = refl _*_ : ℕ → ℕ → ℕ zero * n = zero suc m * n = n + (m * n) *distribr : ∀ (x y z : ℕ) → (x + y) * z ≡ x * z + y * z --*distribr : ∀ (x y z : ℕ) → (x + y) * z ≡ x * z + y * z *distribr zero y z = refl *distribr (suc x) y z rewrite *distribr x y z = +assoc z (x * z) (y * z) *0 : ∀ (x : ℕ) → x * 0 ≡ 0 *0 zero = refl *0 (suc x) = *0 x *suc : ∀ (x y : ℕ) → x * (suc y) ≡ x + x * y *suc zero y = refl *suc (suc x) y rewrite *suc x y | +assoc y x (x * y) | +assoc x y (x * y) | +comm x y = refl *comm : ∀ (x y : ℕ) → x * y ≡ y * x *comm zero y rewrite *0 y = refl *comm (suc x) y rewrite *suc y x | *comm x y = refl *assoc : ∀ (x y z : ℕ) → x * (y * z) ≡ (x * y) * z *assoc zero y z = refl *assoc (suc x) y z rewrite *distribr y (x * y) z | *assoc x y z = refl _<_ : ℕ → ℕ → 𝔹 0 < 0 = ff 0 < (suc y) = tt (suc x) < (suc y) = x < y (suc x) < 0 = ff _=ℕ_ : ℕ → ℕ → 𝔹 0 =ℕ 0 = tt suc x =ℕ suc y = x =ℕ y _ =ℕ _ = ff =ℕ-refl : ∀ (x : ℕ) → (x =ℕ x) ≡ tt =ℕ-refl zero = refl =ℕ-refl (suc x) = =ℕ-refl x =ℕ-to-≡ : ∀ {x y : ℕ} → x =ℕ y ≡ tt → x ≡ y =ℕ-to-≡ {zero} {zero} u = refl =ℕ-to-≡ {zero} {suc y} () =ℕ-to-≡ {suc x} {zero} () =ℕ-to-≡ {suc x} {suc y} u rewrite =ℕ-to-≡ {x} {y} u = refl =ℕ-from-≡ : ∀ {x y : ℕ} → x ≡ y → x =ℕ y ≡ tt =ℕ-from-≡ {x} {.x} refl = =ℕ-refl x is-even : ℕ → 𝔹 is-odd : ℕ → 𝔹 is-even 0 = tt is-even (suc x) = is-odd x is-odd 0 = ff is-odd (suc x) = is-even x even~odd : ∀ (x : ℕ) → is-even x ≡ ~ is-odd x odd~even : ∀ (x : ℕ) → is-odd x ≡ ~ is-even x even~odd zero = refl even~odd (suc x) = odd~even x odd~even zero = refl odd~even (suc x) = even~odd x
{ "alphanum_fraction": 0.4661936561, "avg_line_length": 22.6037735849, "ext": "agda", "hexsha": "5681e4ad1dd05269c07f98c3481d356ff00cb7c2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_path": "my-nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "logicshan/IAL", "max_issues_repo_path": "my-nat.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_path": "my-nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1163, "size": 2396 }
module Common where ∗ : Set₁ ∗ = Set _∘_ : {A B C : ∗} → (B → C) → (A → B) → (A → C) f ∘ g = λ a → f (g a) infixr 2 _×_ infixr 1 _⊎_ data _×_ (A B : ∗) : ∗ where _,_ : A → B → A × B proj₁ : ∀ {A B} → A × B → A proj₁ (a , b) = a proj₂ : ∀ {A B} → A × B → B proj₂ (a , b) = b uncurry : {A B C : ∗} → (A → B → C) → (A × B → C) uncurry f (a , b) = f a b data _⊎_ (A B : ∗) : ∗ where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B
{ "alphanum_fraction": 0.3665254237, "avg_line_length": 18.1538461538, "ext": "agda", "hexsha": "2b7ec3285a75c604497a89685cbf13886752478f", "lang": "Agda", "max_forks_count": 399, "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_path": "papers/unraveling-recursion/Common.agda", "max_issues_count": 2493, "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_path": "papers/unraveling-recursion/Common.agda", "max_line_length": 51, "max_stars_count": 1299, "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_path": "papers/unraveling-recursion/Common.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "num_tokens": 257, "size": 472 }
open import Agda.Builtin.Equality open import Agda.Builtin.Size postulate P : (A : Set₁) → A → Set₁ p : (i : Size) (f : {_ : Size< i} → Set) (x : _) → P ({_ : Size< i} → Set) f
{ "alphanum_fraction": 0.544973545, "avg_line_length": 21, "ext": "agda", "hexsha": "070a637c1a575467560aa496023241e8e00ed433", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue2927.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue2927.agda", "max_line_length": 52, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue2927.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 76, "size": 189 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Foundations.Path where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Reflection.StrictEquiv private variable ℓ ℓ' : Level A : Type ℓ -- Less polymorphic version of `cong`, to avoid some unresolved metas cong′ : ∀ {B : Type ℓ'} (f : A → B) {x y : A} (p : x ≡ y) → Path B (f x) (f y) cong′ f = cong f {-# INLINE cong′ #-} PathP≡Path : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) → PathP P p q ≡ Path (P i1) (transport (λ i → P i) p) q PathP≡Path P p q i = PathP (λ j → P (i ∨ j)) (transport-filler (λ j → P j) p i) q PathP≡Path⁻ : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) → PathP P p q ≡ Path (P i0) p (transport⁻ (λ i → P i) q) PathP≡Path⁻ P p q i = PathP (λ j → P (~ i ∧ j)) p (transport⁻-filler (λ j → P j) q i) PathP≃Path : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) → PathP P p q ≃ Path (P i1) (transport (λ i → P i) p) q PathP≃Path P p q = transportEquiv (PathP≡Path P p q) -- Alternative more unfolded proof toPathP-isEquiv : ∀ (A : I → Type ℓ) {x y} → isEquiv (toPathP {A = A} {x} {y}) toPathP-isEquiv A {x} {y} = isoToIsEquiv (iso toPathP fromPathP to-from from-to) where to-from : ∀ (p : PathP A x y) → toPathP (fromPathP p) ≡ p to-from p h i = outS (hcomp-unique (λ { j (i = i0) → x ; j (i = i1) → fromPathP p j }) (inS (transp (λ j → A (i ∧ j)) (~ i) x)) \ h → inS (sq1 h i)) h where sq1 : (\ h → A [ x ≡ transp (\ j → A (h ∨ j)) h (p h) ]) [ (\ i → transp (λ j → A (i ∧ j)) (~ i) x) ≡ p ] sq1 = \ h i → comp (\ z → (hcomp (\ w → \ { (z = i1) → A (i ∧ (w ∨ h)) ; (z = i0) → A (i ∧ h) ; (i = i0) → A i0 ; (i = i1) → A (h ∨ (w ∧ z)) ; (h = i0) → A (i ∧ (w ∧ z)) ; (h = i1) → A i}) ((A (i ∧ h))))) (\ z → \ { (i = i0) → x ; (i = i1) → transp (\ j → A (h ∨ (z ∧ j))) (h ∨ ~ z) (p h) ; (h = i0) → transp (λ j → A ((i ∧ z) ∧ j)) (~ (i ∧ z)) x ; (h = i1) → p i }) (p (i ∧ h)) from-to : ∀ (q : transp (\ i → A i) i0 x ≡ y) → fromPathP (toPathP {A = A} q) ≡ q from-to q = (\ h i → outS (transp-hcomp i {A' = A i1} (\ j → inS (A (i ∨ j))) ((λ { j (i = i0) → x ; j (i = i1) → q j })) (inS ((transp (λ j → A (i ∧ j)) (~ i) x)))) h) ∙ (\ h i → outS (hcomp-unique {A = A i1} ((λ { j (i = i0) → transp (\ i → A i) i0 x ; j (i = i1) → q j })) (inS ((transp (λ j → A (i ∨ j)) i (transp (λ j → A (i ∧ j)) (~ i) x)))) \ h → inS (sq2 h i)) h) ∙ sym (lUnit q) where sq2 : (\ h → transp (\ i → A i) i0 x ≡ q h) [ (\ i → transp (\ j → A (i ∨ j)) i (transp (\ j → A (i ∧ j)) (~ i) x)) ≡ refl ∙ q ] sq2 = \ h i → comp (\ z → hcomp (\ w → \ { (i = i1) → A i1 ; (i = i0) → A (h ∨ (w ∧ z)) ; (h = i0) → A (i ∨ (w ∧ z)) ; (h = i1) → A i1 ; (z = i0) → A (i ∨ h) ; (z = i1) → A ((i ∨ h) ∨ w) }) (A (i ∨ h))) (\ z → \ { (i = i0) → transp (λ j → A ((z ∨ h) ∧ j)) (~ z ∧ ~ h) x ; (i = i1) → q (z ∧ h) ; (h = i1) → compPath-filler refl q z i ; (h = i0) → transp (\ j → A (i ∨ (z ∧ j))) (i ∨ ~ z) (transp (\ j → A (i ∧ j)) (~ i) x) }) (transp (\ j → A ((i ∨ h) ∧ j)) (~ (i ∨ h)) x) PathP≡compPath : ∀ {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) (r : x ≡ z) → (PathP (λ i → x ≡ q i) p r) ≡ (p ∙ q ≡ r) PathP≡compPath p q r k = PathP (λ i → p i0 ≡ q (i ∨ k)) (λ j → compPath-filler p q k j) r PathP≡doubleCompPathˡ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z) → (PathP (λ i → p i ≡ s i) q r) ≡ (p ⁻¹ ∙∙ q ∙∙ s ≡ r) PathP≡doubleCompPathˡ p q r s k = PathP (λ i → p (i ∨ k) ≡ s (i ∨ k)) (λ j → doubleCompPath-filler (p ⁻¹) q s k j) r PathP≡doubleCompPathʳ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z) → (PathP (λ i → p i ≡ s i) q r) ≡ (q ≡ p ∙∙ r ∙∙ s ⁻¹) PathP≡doubleCompPathʳ p q r s k = PathP (λ i → p (i ∧ (~ k)) ≡ s (i ∧ (~ k))) q (λ j → doubleCompPath-filler p r (s ⁻¹) k j) compPathl-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : x ≡ z) → p ∙ (sym p ∙ q) ≡ q compPathl-cancel p q = p ∙ (sym p ∙ q) ≡⟨ assoc p (sym p) q ⟩ (p ∙ sym p) ∙ q ≡⟨ cong (_∙ q) (rCancel p) ⟩ refl ∙ q ≡⟨ sym (lUnit q) ⟩ q ∎ compPathr-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : z ≡ y) (q : x ≡ y) → (q ∙ sym p) ∙ p ≡ q compPathr-cancel {x = x} p q i j = hcomp-equivFiller (doubleComp-faces (λ _ → x) (sym p) j) (inS (q j)) (~ i) compPathl-isEquiv : {x y z : A} (p : x ≡ y) → isEquiv (λ (q : y ≡ z) → p ∙ q) compPathl-isEquiv p = isoToIsEquiv (iso (p ∙_) (sym p ∙_) (compPathl-cancel p) (compPathl-cancel (sym p))) compPathlEquiv : {x y z : A} (p : x ≡ y) → (y ≡ z) ≃ (x ≡ z) compPathlEquiv p = (p ∙_) , compPathl-isEquiv p compPathr-isEquiv : {x y z : A} (p : y ≡ z) → isEquiv (λ (q : x ≡ y) → q ∙ p) compPathr-isEquiv p = isoToIsEquiv (iso (_∙ p) (_∙ sym p) (compPathr-cancel p) (compPathr-cancel (sym p))) compPathrEquiv : {x y z : A} (p : y ≡ z) → (x ≡ y) ≃ (x ≡ z) compPathrEquiv p = (_∙ p) , compPathr-isEquiv p -- Variations of isProp→isSet for PathP isProp→SquareP : ∀ {B : I → I → Type ℓ} → ((i j : I) → isProp (B i j)) → {a : B i0 i0} {b : B i0 i1} {c : B i1 i0} {d : B i1 i1} → (r : PathP (λ j → B j i0) a c) (s : PathP (λ j → B j i1) b d) → (t : PathP (λ j → B i0 j) a b) (u : PathP (λ j → B i1 j) c d) → SquareP B t u r s isProp→SquareP {B = B} isPropB {a = a} r s t u i j = hcomp (λ { k (i = i0) → isPropB i0 j (base i0 j) (t j) k ; k (i = i1) → isPropB i1 j (base i1 j) (u j) k ; k (j = i0) → isPropB i i0 (base i i0) (r i) k ; k (j = i1) → isPropB i i1 (base i i1) (s i) k }) (base i j) where base : (i j : I) → B i j base i j = transport (λ k → B (i ∧ k) (j ∧ k)) a isProp→isPropPathP : ∀ {ℓ} {B : I → Type ℓ} → ((i : I) → isProp (B i)) → (b0 : B i0) (b1 : B i1) → isProp (PathP (λ i → B i) b0 b1) isProp→isPropPathP {B = B} hB b0 b1 = isProp→SquareP (λ _ → hB) refl refl isProp→isContrPathP : {A : I → Type ℓ} → (∀ i → isProp (A i)) → (x : A i0) (y : A i1) → isContr (PathP A x y) isProp→isContrPathP h x y = isProp→PathP h x y , isProp→isPropPathP h x y _ -- Flipping a square along its diagonal flipSquare : {a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁} {a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁} {a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁} → Square a₀₋ a₁₋ a₋₀ a₋₁ → Square a₋₀ a₋₁ a₀₋ a₁₋ flipSquare sq i j = sq j i module _ {a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁} {a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁} {a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁} where flipSquareEquiv : Square a₀₋ a₁₋ a₋₀ a₋₁ ≃ Square a₋₀ a₋₁ a₀₋ a₁₋ unquoteDef flipSquareEquiv = defStrictEquiv flipSquareEquiv flipSquare flipSquare flipSquarePath : Square a₀₋ a₁₋ a₋₀ a₋₁ ≡ Square a₋₀ a₋₁ a₀₋ a₁₋ flipSquarePath = ua flipSquareEquiv module _ {a₀₀ a₁₁ : A} {a₋ : a₀₀ ≡ a₁₁} {a₁₀ : A} {a₁₋ : a₁₀ ≡ a₁₁} {a₋₀ : a₀₀ ≡ a₁₀} where slideSquareFaces : (i j k : I) → Partial (i ∨ ~ i ∨ j ∨ ~ j) A slideSquareFaces i j k (i = i0) = a₋ (j ∧ ~ k) slideSquareFaces i j k (i = i1) = a₁₋ j slideSquareFaces i j k (j = i0) = a₋₀ i slideSquareFaces i j k (j = i1) = a₋ (i ∨ ~ k) slideSquare : Square a₋ a₁₋ a₋₀ refl → Square refl a₁₋ a₋₀ a₋ slideSquare sq i j = hcomp (slideSquareFaces i j) (sq i j) slideSquareEquiv : (Square a₋ a₁₋ a₋₀ refl) ≃ (Square refl a₁₋ a₋₀ a₋) slideSquareEquiv = isoToEquiv (iso slideSquare slideSquareInv fillerTo fillerFrom) where slideSquareInv : Square refl a₁₋ a₋₀ a₋ → Square a₋ a₁₋ a₋₀ refl slideSquareInv sq i j = hcomp (λ k → slideSquareFaces i j (~ k)) (sq i j) fillerTo : ∀ p → slideSquare (slideSquareInv p) ≡ p fillerTo p k i j = hcomp-equivFiller (λ k → slideSquareFaces i j (~ k)) (inS (p i j)) (~ k) fillerFrom : ∀ p → slideSquareInv (slideSquare p) ≡ p fillerFrom p k i j = hcomp-equivFiller (slideSquareFaces i j) (inS (p i j)) (~ k) -- The type of fillers of a square is equivalent to the double composition identites Square≃doubleComp : {a₀₀ a₀₁ a₁₀ a₁₁ : A} (a₀₋ : a₀₀ ≡ a₀₁) (a₁₋ : a₁₀ ≡ a₁₁) (a₋₀ : a₀₀ ≡ a₁₀) (a₋₁ : a₀₁ ≡ a₁₁) → Square a₀₋ a₁₋ a₋₀ a₋₁ ≃ (a₋₀ ⁻¹ ∙∙ a₀₋ ∙∙ a₋₁ ≡ a₁₋) Square≃doubleComp a₀₋ a₁₋ a₋₀ a₋₁ = transportEquiv (PathP≡doubleCompPathˡ a₋₀ a₀₋ a₁₋ a₋₁) -- sym induces an equivalence on identity types of paths symIso : {a b : A} (p q : a ≡ b) → Iso (p ≡ q) (q ≡ p) symIso p q = iso sym sym (λ _ → refl) λ _ → refl
{ "alphanum_fraction": 0.4269839709, "avg_line_length": 51.8826530612, "ext": "agda", "hexsha": "9443d5cc9303f2e60a8c00a9048adea8f1609e2f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Foundations/Path.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Foundations/Path.agda", "max_line_length": 135, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Foundations/Path.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4108, "size": 10169 }
-- Andreas, 2019-09-10, issue #4065, reported by nad -- If the set of filtered unsolved constraints is empty, Agda -- should print at least something like "Unsolved constraints" postulate A : Set record R (F : A → Set) : Set where module M (r : (F : A → Set) → R F) where module T (F : _) = R (r (λ ℓ → F ℓ)) -- WAS (master after 2.6.0): -- <no error> when checking the module application ... -- Expected: -- Unsolved constraints when checking the module application ...
{ "alphanum_fraction": 0.6597510373, "avg_line_length": 24.1, "ext": "agda", "hexsha": "3a77ae4fc8d8f4c8903afb60b3877c40d9e2a1ed", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue4065.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue4065.agda", "max_line_length": 64, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue4065.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 143, "size": 482 }
module _ (A : Set) where id : A → A id x = x
{ "alphanum_fraction": 0.5106382979, "avg_line_length": 7.8333333333, "ext": "agda", "hexsha": "9475a8e89e5c022299099c1f5f650c5f6cf29a2e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/ParameterisedAnonymousModule.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/ParameterisedAnonymousModule.agda", "max_line_length": 24, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/ParameterisedAnonymousModule.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 21, "size": 47 }
{-# OPTIONS --without-K --safe --exact-split #-} module Constructive.Axiom.Properties where open import Constructive.Axiom.Properties.Base public open import Constructive.Axiom.Properties.Transport public open import Constructive.Axiom.Properties.Bool public
{ "alphanum_fraction": 0.816091954, "avg_line_length": 32.625, "ext": "agda", "hexsha": "b56f1f274aeffb65f4b7788109b187f674eacc0e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Constructive/Axiom/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Constructive/Axiom/Properties.agda", "max_line_length": 58, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Constructive/Axiom/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 53, "size": 261 }
module TemporalOps.OtherOps where open import CategoryTheory.Instances.Reactive open import CategoryTheory.Functor open import CategoryTheory.Monad open import CategoryTheory.Comonad open import CategoryTheory.NatTrans open import CategoryTheory.BCCCs open import CategoryTheory.CartesianStrength open import TemporalOps.Next open import TemporalOps.Delay open import TemporalOps.Diamond open import TemporalOps.Box open import TemporalOps.Common.Other open import Relation.Binary.PropositionalEquality as ≡ open import Data.Product open import Data.Sum open import Data.Nat hiding (_*_) open import Data.Nat.Properties using (+-identityʳ ; +-comm ; +-suc ; +-assoc) open import Holes.Term using (⌞_⌟) open import Holes.Cong.Propositional open Monad M-◇ open Comonad W-□ private module F-◇ = Functor F-◇ private module F-□ = Functor F-□ open ≡.≡-Reasoning -- | Natural transformations between modalities -- delay A by 1 is the same as ▹ A ▹¹-to-▹ : F-delay 1 ⟺ F-▹ ▹¹-to-▹ = record { to = record { at = λ A n x → x ; nat-cond = refl } ; from = record { at = λ A n x → x ; nat-cond = refl } ; iso1 = refl ; iso2 = refl } -- □ A is always available, in particular, after a delay by k □-to-▹ᵏ : ∀(k : ℕ) -> F-□ ⟹ F-delay k □-to-▹ᵏ k = record { at = at-□-▹ᵏ k ; nat-cond = nat-cond-□-▹ᵏ k } where at-□-▹ᵏ : ∀(k : ℕ)(A : τ) -> □ A ⇴ delay A by k at-□-▹ᵏ zero A n a = a n at-□-▹ᵏ (suc k) A zero a = top.tt at-□-▹ᵏ (suc k) A (suc n) a = at-□-▹ᵏ k A n a nat-cond-□-▹ᵏ : ∀(k : ℕ){A B : τ} {f : A ⇴ B} → Functor.fmap (F-delay k) f ∘ at-□-▹ᵏ k A ≈ at-□-▹ᵏ k B ∘ Functor.fmap F-□ f nat-cond-□-▹ᵏ zero {A} {B} {f} {n} {a} = refl nat-cond-□-▹ᵏ (suc k) {A} {B} {f} {zero} {a} = refl nat-cond-□-▹ᵏ (suc k) {A} {B} {f} {suc n} {a} = nat-cond-□-▹ᵏ k -- If A is delayed by k, then it is delayed ▹ᵏ-to-◇ : ∀(k : ℕ) -> F-delay k ⟹ F-◇ ▹ᵏ-to-◇ k = record { at = λ A n a → k , a ; nat-cond = refl } -- □ A is always available, in particular, after any delay □-to-◇ : ∀{k} -> F-□ ⟹ F-◇ □-to-◇ {k} = ▹ᵏ-to-◇ k ⊚ □-to-▹ᵏ k -- | Monadic operations for ◇ return : ∀{A : τ} -> A ⇴ ◇ A return {A} = η.at A -- Monadic extension _⋆ : ∀{A B : τ} -> (A ⇴ ◇ B) -> (◇ A ⇴ ◇ B) _⋆ {A} {B} f = μ.at B ∘ F-◇.fmap f infixl 55 _⋆ -- Bind operator _>>=_ : ∀{A B : τ}{n : ℕ} -> (◇ A) n -> (A ⇴ (◇ B)) -> (◇ B) n _>>=_ {n = n} a f = (f ⋆) n a -- Bind is associative >>=-assoc : ∀{A B C : τ}{n : ℕ} -> (a : (◇ A) n) -> (f : (A ⇴ (◇ B))) -> (g : (B ⇴ (◇ C))) -> (a >>= f) >>= g ≡ a >>= (λ k x → (f k x) >>= g) >>=-assoc {A}{B}{C} {n} a f g = begin ((a >>= f) >>= g) ≡⟨⟩ μ.at C n ⌞ (((fmap g ∘ μ.at B) ∘ fmap f) n a) ⌟ ≡⟨ cong! (≈-cong-left {f = fmap g} (μ.nat-cond {B} {◇ C} {g} {n} {fmap f n a}) {n} {a >>= f}) ⟩ (((μ.at C ∘ μ.at (◇ C)) ∘ fmap (fmap g)) ∘ fmap f) n a ≡⟨ lemma ⟩ (((μ.at C ∘ fmap (μ.at C)) ∘ fmap (fmap g)) ∘ fmap f) n a ≡⟨ cong (μ.at C n) (≈-cong-left {f = fmap g} (sym (fmap-∘ {a = fmap f n a})) {n} {a >>= f}) ⟩ μ.at C n ((fmap (μ.at C ∘ fmap g) ∘ fmap f) n a) ≡⟨ cong (μ.at C n) (sym (fmap-∘ {a = a})) ⟩ μ.at C n (fmap ((μ.at C ∘ fmap g) ∘ f) n a) ≡⟨⟩ (a >>= (λ k x → f k x >>= g)) ∎ where open Functor F-◇ lemma : (((μ.at C ∘ μ.at (◇ C)) ∘ fmap (fmap g)) ∘ fmap f) n a ≡ (((μ.at C ∘ fmap (μ.at C)) ∘ fmap (fmap g)) ∘ fmap f) n a lemma rewrite μ-assoc {C} {n} {((fmap (fmap g)) ∘ fmap f) n a} = refl -- Return is left unit to bind >>=-unit-left : ∀{A B : τ}{n : ℕ} -> (a : A n)(f : A ⇴ ◇ B) -> (η.at A n a) >>= f ≡ f n a >>=-unit-left a f = η-unit1 -- Return is right unit to bind >>=-unit-right : ∀{A : τ}{n : ℕ} -> (a : (◇ A) n) -> a >>= η.at A ≡ a >>=-unit-right a = η-unit2
{ "alphanum_fraction": 0.5050900548, "avg_line_length": 30.4047619048, "ext": "agda", "hexsha": "2744f359ac25a018e4b0584e733e57b586596e2f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/TemporalOps/OtherOps.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/TemporalOps/OtherOps.agda", "max_line_length": 99, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/TemporalOps/OtherOps.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 1736, "size": 3831 }
primitive primSetOmega : _
{ "alphanum_fraction": 0.7586206897, "avg_line_length": 9.6666666667, "ext": "agda", "hexsha": "de41f874ec028be89d8d6a2bac307be5b11426e5", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue3318-4.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue3318-4.agda", "max_line_length": 18, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue3318-4.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 8, "size": 29 }
-- Basic intuitionistic propositional calculus, without ∨ or ⊥. -- Gentzen-style formalisation of syntax. -- Normal forms, neutrals, and spines. module BasicIPC.Syntax.GentzenSpinalNormalForm where open import BasicIPC.Syntax.Gentzen public -- Derivations. mutual -- Normal forms, or introductions. infix 3 _⊢ⁿᶠ_ data _⊢ⁿᶠ_ (Γ : Cx Ty) : Ty → Set where neⁿᶠ : ∀ {P} → Γ ⊢ⁿᵉ α P → Γ ⊢ⁿᶠ α P lamⁿᶠ : ∀ {A B} → Γ , A ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ▻ B pairⁿᶠ : ∀ {A B} → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ∧ B unitⁿᶠ : Γ ⊢ⁿᶠ ⊤ -- Neutrals, or eliminations. infix 3 _⊢ⁿᵉ_ data _⊢ⁿᵉ_ (Γ : Cx Ty) : Ty → Set where spⁿᵉ : ∀ {A C} → A ∈ Γ → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ⁿᵉ C -- Spines. infix 3 _⊢ˢᵖ_⦙_ data _⊢ˢᵖ_⦙_ (Γ : Cx Ty) : Ty → Ty → Set where nilˢᵖ : ∀ {C} → Γ ⊢ˢᵖ C ⦙ C appˢᵖ : ∀ {A B C} → Γ ⊢ˢᵖ B ⦙ C → Γ ⊢ⁿᶠ A → Γ ⊢ˢᵖ A ▻ B ⦙ C fstˢᵖ : ∀ {A B C} → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ˢᵖ A ∧ B ⦙ C sndˢᵖ : ∀ {A B C} → Γ ⊢ˢᵖ B ⦙ C → Γ ⊢ˢᵖ A ∧ B ⦙ C -- Translation from normal forms to simple terms. mutual nf→tm : ∀ {A Γ} → Γ ⊢ⁿᶠ A → Γ ⊢ A nf→tm (neⁿᶠ t) = ne→tm t nf→tm (lamⁿᶠ t) = lam (nf→tm t) nf→tm (pairⁿᶠ t u) = pair (nf→tm t) (nf→tm u) nf→tm unitⁿᶠ = unit ne→tm : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊢ A ne→tm (spⁿᵉ i xs) = sp→tm (var i) xs sp→tm : ∀ {A C Γ} → Γ ⊢ A → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ C sp→tm t nilˢᵖ = t sp→tm t (appˢᵖ xs u) = sp→tm (app t (nf→tm u)) xs sp→tm t (fstˢᵖ xs) = sp→tm (fst t) xs sp→tm t (sndˢᵖ xs) = sp→tm (snd t) xs -- Monotonicity with respect to context inclusion. mutual mono⊢ⁿᶠ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᶠ A → Γ′ ⊢ⁿᶠ A mono⊢ⁿᶠ η (neⁿᶠ t) = neⁿᶠ (mono⊢ⁿᵉ η t) mono⊢ⁿᶠ η (lamⁿᶠ t) = lamⁿᶠ (mono⊢ⁿᶠ (keep η) t) mono⊢ⁿᶠ η (pairⁿᶠ t u) = pairⁿᶠ (mono⊢ⁿᶠ η t) (mono⊢ⁿᶠ η u) mono⊢ⁿᶠ η unitⁿᶠ = unitⁿᶠ mono⊢ⁿᵉ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᵉ A → Γ′ ⊢ⁿᵉ A mono⊢ⁿᵉ η (spⁿᵉ i xs) = spⁿᵉ (mono∈ η i) (mono⊢ˢᵖ η xs) mono⊢ˢᵖ : ∀ {A C Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ˢᵖ A ⦙ C → Γ′ ⊢ˢᵖ A ⦙ C mono⊢ˢᵖ η nilˢᵖ = nilˢᵖ mono⊢ˢᵖ η (appˢᵖ xs u) = appˢᵖ (mono⊢ˢᵖ η xs) (mono⊢ⁿᶠ η u) mono⊢ˢᵖ η (fstˢᵖ xs) = fstˢᵖ (mono⊢ˢᵖ η xs) mono⊢ˢᵖ η (sndˢᵖ xs) = sndˢᵖ (mono⊢ˢᵖ η xs)
{ "alphanum_fraction": 0.5253222836, "avg_line_length": 30.5915492958, "ext": "agda", "hexsha": "2e219116e89c89bbcb9488095eb64cc85bcbaa57", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIPC/Syntax/GentzenSpinalNormalForm.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIPC/Syntax/GentzenSpinalNormalForm.agda", "max_line_length": 63, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIPC/Syntax/GentzenSpinalNormalForm.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 1436, "size": 2172 }
module Agda.Builtin.FromNat where open import Agda.Primitive open import Agda.Builtin.Nat record Number {a} (A : Set a) : Set (lsuc a) where field Constraint : Nat → Set a fromNat : ∀ n → {{_ : Constraint n}} → A open Number {{...}} public using (fromNat) {-# BUILTIN FROMNAT fromNat #-} {-# DISPLAY Number.fromNat _ n = fromNat n #-}
{ "alphanum_fraction": 0.6542857143, "avg_line_length": 21.875, "ext": "agda", "hexsha": "de4acc8a433fbb2ec911663420f4ce8ae20efca1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/FromNat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/FromNat.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/FromNat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 105, "size": 350 }
open import Everything module Test.Factsurj3 where module Test0 {𝔵 𝔭 𝔯 ℓ} {𝔛 : Ø 𝔵} (𝔓 : π̂ 𝔭 𝔛) (_≈_ : ∀̇ π̂² ℓ 𝔓) (_≈'_ : ∀̇ π̂² ℓ 𝔓) (ℜ : π̂² 𝔯 𝔛) (ε : Reflexivity.type ℜ) (_◃_ : Smaphomarrow!.type ℜ 𝔓) (_◃'_ : Smaphomarrow!.type ℜ 𝔓) where test-class' : ⦃ _ : Leftunit,smaphomarrow.class ℜ 𝔓 ε surjection _◃_ _≈_ ⦄ → Leftunit,smaphomarrow.class ℜ 𝔓 ε surjection _◃_ _≈_ test-class' = ! test-method' : ⦃ _ : Leftunit,smaphomarrow.class ℜ 𝔓 ε surjection _◃_ _≈_ ⦄ → Leftunit,smaphomarrow.type ℜ 𝔓 ε surjection _◃_ _≈_ test-method' = leftunit test-class : ∀ {𝔵 𝔭 𝔯 ℓ} {𝔛 : Ø 𝔵} {𝔓 : π̂ 𝔭 𝔛} ⦃ _ : ∀ {x} → HasEquivalence (𝔓 x) ℓ ⦄ {ℜ : π̂² 𝔯 𝔛} ⦃ _ : Reflexivity.class ℜ ⦄ ⦃ _ : Smaphomarrow!.class ℜ 𝔓 ⦄ → ⦃ _ : Leftunit,equivalence,smaphomarrow!.class ℜ 𝔓 ⦄ → Leftunit,equivalence,smaphomarrow!.class ℜ 𝔓 test-class = !
{ "alphanum_fraction": 0.6082949309, "avg_line_length": 28, "ext": "agda", "hexsha": "db764e457e6aa7405d8a5a7cb74fabb23681b1e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/Factsurj3.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/Factsurj3.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/Factsurj3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 474, "size": 868 }
module Haskell.Prim.Foldable where open import Haskell.Prim open import Haskell.Prim.Num open import Haskell.Prim.Eq open import Haskell.Prim.List open import Haskell.Prim.Int open import Haskell.Prim.Bool open import Haskell.Prim.Maybe open import Haskell.Prim.Either open import Haskell.Prim.Tuple open import Haskell.Prim.Monoid -------------------------------------------------- -- Foldable record Foldable (t : Set → Set) : Set₁ where field foldMap : ⦃ Monoid b ⦄ → (a → b) → t a → b foldr : (a → b → b) → b → t a → b foldr f z t = foldMap ⦃ MonoidEndo ⦄ f t z foldl : (b → a → b) → b → t a → b foldl f z t = foldMap ⦃ MonoidEndoᵒᵖ ⦄ (flip f) t z any : (a → Bool) → t a → Bool any = foldMap ⦃ MonoidDisj ⦄ all : (a → Bool) → t a → Bool all = foldMap ⦃ MonoidConj ⦄ and : t Bool → Bool and = all id or : t Bool → Bool or = any id null : t a → Bool null = all (const false) concat : t (List a) → List a concat = foldMap id concatMap : (a → List b) → t a → List b concatMap = foldMap elem : ⦃ Eq a ⦄ → a → t a → Bool elem x = foldMap ⦃ MonoidDisj ⦄ (x ==_) notElem : ⦃ Eq a ⦄ → a → t a → Bool notElem x t = not (elem x t) toList : t a → List a toList = foldr _∷_ [] sum : ⦃ iNum : Num a ⦄ → t a → a sum = foldMap ⦃ MonoidSum ⦄ id product : ⦃ iNum : Num a ⦄ → t a → a product = foldMap ⦃ MonoidProduct ⦄ id length : t a → Int length = foldMap ⦃ MonoidSum ⦄ (const 1) open Foldable ⦃ ... ⦄ public instance iFoldableList : Foldable List iFoldableList .foldMap f [] = mempty iFoldableList .foldMap f (x ∷ xs) = f x <> foldMap f xs iFoldableMaybe : Foldable Maybe iFoldableMaybe .foldMap _ Nothing = mempty iFoldableMaybe .foldMap f (Just x) = f x iFoldableEither : Foldable (Either a) iFoldableEither .foldMap _ (Left _) = mempty iFoldableEither .foldMap f (Right x) = f x iFoldablePair : Foldable (a ×_) iFoldablePair .foldMap f (_ , x) = f x
{ "alphanum_fraction": 0.6104028557, "avg_line_length": 23.3452380952, "ext": "agda", "hexsha": "f12a519a12e060d11dd2b1f2d83d8eab50b7a585", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/agda2hs", "max_forks_repo_path": "lib/Haskell/Prim/Foldable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/agda2hs", "max_issues_repo_path": "lib/Haskell/Prim/Foldable.agda", "max_line_length": 57, "max_stars_count": null, "max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/agda2hs", "max_stars_repo_path": "lib/Haskell/Prim/Foldable.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 743, "size": 1961 }
{- This file defines cohomology of a type with coefficients in a dependent spectrum over it. * Cohom and Cohom' are two versions of the cohomology groups - the only difference is the carrier type. * 'commDegreeΩ' commutes Ωs with degree shifts of the spectrum * 'cohomMap' implement the application of the cohomology functors to maps between types This general cohomology coincides with ZCohomology when the coefficients are constantly the Eilenberg-MacLane spectrum for ℤ (not proven here/yet) -} {-# OPTIONS --safe #-} module Cubical.Cohomology.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed.Base open import Cubical.Foundations.Pointed.Properties open import Cubical.Foundations.Isomorphism using (isoToEquiv) open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence using (ua) open import Cubical.Functions.FunExtEquiv using (funExtEquiv) open import Cubical.Algebra.Group.Base using (Group; GroupStr) open import Cubical.Algebra.AbGroup.Base open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Data.Int.Base hiding (_·_) open import Cubical.Data.Nat.Base using (ℕ) open import Cubical.Data.Sigma open import Cubical.Homotopy.Group.Base open import Cubical.HITs.SetTruncation hiding (map) open import Cubical.Homotopy.Spectrum open import Cubical.Homotopy.Loopspace renaming (EH to isCommΩ) open import Cubical.Structures.Successor private variable ℓ : Level open Spectrum module _ (X : Type ℓ) (A : (x : X) → Spectrum ℓ) where CohomClasses : ℤ → Pointed ℓ CohomClasses k = Πᵘ∙ X (λ x → space (A x) k) CohomType : ℤ → Type ℓ CohomType k = ∥ (fst (CohomClasses k)) ∥₂ private commDegreeΩOnce : (k : ℤ) → (CohomClasses k) ≃∙ Πᵘ∙ X (λ x → Ω (space (A x) (sucℤ k))) commDegreeΩOnce k = (equivΠCod (λ x → fst (equivΩAt x))) , λ i x → snd (equivΩAt x) i where equivΩAt : (x : X) → space (A x) k ≃∙ Ω (space (A x) (sucℤ k)) equivΩAt x = (fst (map (A x) k) , equiv (A x) k) , snd (map (A x) k) commDegreeΩOnce' : (k : ℤ) → (CohomClasses k) ≃∙ Ω (CohomClasses (sucℤ k)) commDegreeΩOnce' k = compEquiv∙ (commDegreeΩOnce k) (funExtEquiv , refl) commDegreeΩ : (k : ℤ) (n : ℕ) → (CohomClasses k) ≃∙ (Ω^ n) (CohomClasses (k + (pos n))) commDegreeΩ k ℕ.zero = idEquiv∙ _ commDegreeΩ k (ℕ.suc n) = CohomClasses k ≃∙⟨ commDegreeΩ k n ⟩ (Ω^ n) (CohomClasses (k + (pos n))) ≃∙⟨ Ω^≃∙ n (commDegreeΩOnce' (k + pos n)) ⟩ (Ω^ n) (Ω (CohomClasses (sucℤ (k + (pos n))))) ≃∙⟨ invEquiv∙ (e n) ⟩ (Ω^ (ℕ.suc n)) (CohomClasses (sucℤ (k + (pos n)))) ∎≃∙ where e : {A : Pointed ℓ} (n : ℕ) → (Ω^ (ℕ.suc n)) A ≃∙ (Ω^ n) (Ω A) e ℕ.zero = isoToEquiv (flipΩIso ℕ.zero) , transportRefl refl e (ℕ.suc n) = isoToEquiv (flipΩIso (ℕ.suc n)) , flipΩrefl n {- Abelian group structure -} module abGroupStr (k : ℤ) where {- Use an equivalent type, where the group structure is just given by the homotopy group functor (index of homotopy groups is off by one below, we actually take π₂, to get an abelian group) -} CohomAsGroup : Group ℓ CohomAsGroup = (πGr 1) (Πᵘ∙ X (λ x → (space (A x) (k + 2)))) open GroupStr (snd CohomAsGroup) isComm : (a b : fst CohomAsGroup) → a · b ≡ b · a isComm = elim2 (λ _ _ → isSetPathImplicit) λ a b → ∣ a ∙ b ∣₂ ≡⟨ cong ∣_∣₂ (isCommΩ 0 a b) ⟩ ∣ b ∙ a ∣₂ ∎ π₂AbGroup : AbGroup ℓ π₂AbGroup = Group→AbGroup CohomAsGroup isComm module _ (k : ℤ) where Cohom' : AbGroup ℓ Cohom' = abGroupStr.π₂AbGroup k CohomType' : Type ℓ CohomType' = fst (abGroupStr.π₂AbGroup k) private shiftΩTwicePath : fst (abGroupStr.π₂AbGroup k) ≡ CohomType k shiftΩTwicePath = sym (cong ∥_∥₂ (ua (fst (commDegreeΩ k 2)))) Cohom : AbGroup ℓ Cohom = CohomType k , subst AbGroupStr shiftΩTwicePath (snd (abGroupStr.π₂AbGroup k)) CohomPath : Cohom' ≡ Cohom CohomPath = ΣPathTransport→PathΣ Cohom' Cohom (shiftΩTwicePath , refl) CohomEquiv : AbGroupEquiv Cohom' Cohom CohomEquiv = fst (invEquiv (AbGroupPath Cohom' Cohom)) CohomPath {- Functoriality in the type argument -} module _ {Y X : Type ℓ} (f : Y → X) (A : (x : X) → Spectrum ℓ) where {- The following will be used as coefficients for the cohomology of Y -} fA : (y : Y) → Spectrum ℓ fA y = A (f y) cohomMap' : (k : ℤ) → AbGroupHom (Cohom' X A k) (Cohom' Y fA k) cohomMap' k = πHom 1 mapOnClasses -- apply π₂ to a map on cohomology classes where mapOnClasses : CohomClasses X A (k + 2) →∙ CohomClasses Y fA (k + 2) mapOnClasses = (λ l → (λ y → l (f y))) , refl cohomMap : (k : ℤ) → AbGroupHom (Cohom X A k) (Cohom Y fA k) cohomMap k = compGroupHom (compGroupHom (GroupEquiv→GroupHom (invGroupEquiv (CohomEquiv X A k))) (cohomMap' k)) (GroupEquiv→GroupHom (CohomEquiv Y fA k))
{ "alphanum_fraction": 0.6336445037, "avg_line_length": 36.2, "ext": "agda", "hexsha": "a7e1620841686827fd0486c5b45be620371cdec8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Cohomology/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Cohomology/Base.agda", "max_line_length": 98, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Cohomology/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 1902, "size": 5249 }
open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import SingleSorted.Substitution open import Data.Nat using (ℕ; zero; suc) import MultiSorted.Context as Context module MultiSorted.Group where data 𝒜 : Set₀ where A : 𝒜 single-sort : ∀ (X : 𝒜) → X ≡ A single-sort A = refl open import MultiSorted.AlgebraicTheory open import MultiSorted.AlgebraicTheory data GroupOp : Set where e : GroupOp inv : GroupOp mul : GroupOp ctx : ∀ (n : ℕ) → Context.Context 𝒜 ctx zero = Context.ctx-empty ctx (suc n) = Context.ctx-concat (ctx n) (Context.ctx-slot A) -- the signature of the theory of small groups -- has one constant, one unary operation, one binary operation Σ : Signature {lzero} {lzero} Σ = record { sort = 𝒜 ; oper = GroupOp ; oper-arity = λ{ e → ctx 0 ; inv → ctx 1 ; mul → ctx 2} ; oper-sort = λ{ e → A ; inv → A ; mul → A} } open Signature Σ singleton-context : (var (ctx-slot A)) → var (ctx-concat ctx-empty (ctx-slot A)) singleton-context (var-var {A}) = var-inr (var-var {A}) single-sort-context : ∀ {Γ : Context} (x : var Γ) → sort-of Γ x ≡ A single-sort-context {Γ} x = single-sort (Context.sort-of 𝒜 Γ x) single-sort-terms : ∀ {X : 𝒜} {Γ : Context} → Term Γ X ≡ Term Γ A single-sort-terms {A} = refl σ : ∀ {Γ : Context} {t : Term Γ A} → Γ ⇒s (ctx 1) σ {Γ} {t} = λ{ (var-inr var-var) → t} δ : ∀ {Γ : Context} {t : Term Γ A} {s : Term Γ A} → Γ ⇒s (ctx 2) δ {Γ} {t} {s} = sub where sub : Γ ⇒s (ctx 2) sub (var-inl x) rewrite (single-sort-terms {(sort-of (ctx 2) (var-inl x))} {Γ}) = t sub (var-inr y) rewrite (single-sort-terms {(sort-of (ctx 2) (var-inr y))} {Γ}) = s -- helper functions for creating terms e' : ∀ {Γ : Context} → Term Γ A e' {Γ} = tm-oper e λ() _∗_ : ∀ {Γ} → Term Γ A → Term Γ A → Term Γ A t ∗ s = tm-oper mul λ{ xs → δ {t = t} {s = s} xs} _ⁱ : ∀ {Γ : Context} → Term Γ A → Term Γ A t ⁱ = tm-oper inv λ{ x → σ {t = t} x} -- _∗_ : ∀ {Γ} → Term Γ A → Term Γ A → Term Γ A -- _∗_ {Γ} t s = tm-oper mul λ{ (var-inl i) → {!!} ; (var-inr i) → {!!}} -- _ⁱ : ∀ {Γ : Context} → Term Γ A → Term Γ A -- t ⁱ = tm-oper inv λ{ x → t } infixl 5 _∗_ infix 6 _ⁱ _ : Term (ctx 2) A _ = tm-var (var-inl (var-inr var-var)) ∗ tm-var (var-inr var-var) -- group equations data GroupEq : Set where mul-assoc e-left e-right inv-left inv-right : GroupEq mul-assoc-eq : Equation Σ e-left-eq : Equation Σ e-right-eq : Equation Σ inv-left-eq : Equation Σ inv-right-eq : Equation Σ mul-assoc-eq = record { eq-ctx = ctx 3 ; eq-lhs = x ∗ y ∗ z ; eq-rhs = x ∗ (y ∗ z) } where x : Term (ctx 3) A y : Term (ctx 3) A z : Term (ctx 3) A x = tm-var (var-inl (var-inl (var-inr var-var))) y = tm-var (var-inl (var-inr var-var)) z = tm-var (var-inr var-var) e-left-eq = record { eq-ctx = ctx 1 ; eq-lhs = e' ∗ x ; eq-rhs = x } where x : Term (ctx 1) A x = tm-var (var-inr var-var) e-right-eq = record { eq-ctx = ctx 1 ; eq-lhs = x ∗ e' ; eq-rhs = x } where x : Term (ctx 1) A x = tm-var (var-inr var-var) inv-left-eq = record { eq-ctx = ctx 1 ; eq-lhs = x ⁱ ∗ x ; eq-rhs = e' } where x : Term (ctx 1) A x = tm-var (var-inr var-var) inv-right-eq = record { eq-ctx = ctx 1 ; eq-lhs = x ∗ x ⁱ ; eq-rhs = e' } where x : Term (ctx 1) A x = tm-var (var-inr var-var) 𝒢 : Theory lzero Σ 𝒢 = record { ax = GroupEq ; ax-eq = λ{ mul-assoc → mul-assoc-eq ; e-left → e-left-eq ; e-right → e-right-eq ; inv-left → inv-left-eq ; inv-right → inv-right-eq } }
{ "alphanum_fraction": 0.5426478284, "avg_line_length": 28.7368421053, "ext": "agda", "hexsha": "6175c5c1ec886cbca5ab478886e273f2b51e2006", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/MultiSorted/Group.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/MultiSorted/Group.agda", "max_line_length": 85, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/MultiSorted/Group.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 1400, "size": 3822 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Induction over _<_ for ℕᵇ. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Nat.Binary.Induction where open import Data.Nat.Binary.Base open import Data.Nat.Binary.Properties open import Data.Nat.Base as ℕ using (ℕ) import Data.Nat.Induction as ℕ open import Induction.WellFounded ------------------------------------------------------------------------ -- _<_ is wellFounded <-wellFounded : WellFounded _<_ <-wellFounded x = Subrelation.accessible <⇒<ℕ toℕ[x]-acc where toℕ[x]-acc = InverseImage.accessible toℕ (ℕ.<-wellFounded (toℕ x))
{ "alphanum_fraction": 0.5123966942, "avg_line_length": 30.25, "ext": "agda", "hexsha": "13bdb874caca60e0436cd801c8172ed14a9bc745", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Nat/Binary/Induction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/Binary/Induction.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/Binary/Induction.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 162, "size": 726 }
-- Andreas, 2018-05-28, issue #3095, cannot make hidden shadowing variable visible data Nat : Set where suc : {n : Nat} → Nat data IsSuc : Nat → Set where isSuc : ∀{n} → IsSuc (suc {n}) test : ∀{n} → IsSuc n → Set test p = aux p where aux : ∀{n} → IsSuc n → Set aux isSuc = {!n!} -- Split on n here -- Context: -- p : IsSuc n -- n : Nat (not in scope) -- n₁ : Nat (not in scope) -- WAS: ERROR -- Ambiguous variable n -- when checking that the expression ? has type Set
{ "alphanum_fraction": 0.6024590164, "avg_line_length": 21.2173913043, "ext": "agda", "hexsha": "eb0c35733b35aa3c279dda43e09c28e7ecb6c9b7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phadej/agda", "max_forks_repo_path": "test/interaction/Issue3095.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "phadej/agda", "max_issues_repo_path": "test/interaction/Issue3095.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phadej/agda", "max_stars_repo_path": "test/interaction/Issue3095.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 173, "size": 488 }
{-# OPTIONS --cubical #-} module PathWith where open import Agda.Builtin.Cubical.Path open import Agda.Primitive.Cubical open import Agda.Builtin.Nat pred : Nat → Nat pred (suc n) = n pred 0 = 0 f : Nat → Nat f n with pred n ... | zero = zero ... | suc m = suc m module _ (qqq : Nat) where test1 : f ≡ pred test1 i n with pred n ... | zero = zero ... | suc q = suc q test2 : test1 ≡ test1 test2 i n j x with pred x ... | zero = zero ... | suc q = suc q
{ "alphanum_fraction": 0.6132478632, "avg_line_length": 16.1379310345, "ext": "agda", "hexsha": "753dea1d1f06dec8cbe1b156476845e9cc533113", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/PathWith.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/PathWith.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/PathWith.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 168, "size": 468 }
-- a few random examples module Test where import Agda.Builtin.Bool data Nat : Set where zero : Nat -- Comment which gets eaten suc : Nat -> Nat --Comment which is preserved plus {- preserved comment {- which may be nested -} -} : {- comment after Colon, also preserved-} {-comments are essentially whitespace, even through they get parsed-} Nat -> {-comment, preserved-} Nat -> Nat {-# BUILTIN NATURAL Nat #-} plus zero m = m plus (suc n) m = suc (plus n m) {-# BUILTIN NATPLUS plus #-} --excess brackets are not preserved minus : ((Nat)) -> Nat -- We can nest holes correctly minus a = {! ? {! Hole inside hole !} !} -- Seriously long and complicated function type func : {A : Set} -> {B : A -> Set} -> {C : (x : A) -> B x -> Set} -> (f : {x : A} -> (y : B x) -> C x y) -> (g : (x : A) -> B x) -> (x : A) -> C x (g x) func f g x = f (g x) -- Holes can go here as well id : {a : Set} -> a -> {! !} id x = x -- and the code from the planning report, rewritten in Baby-Agda data List (A : Set) : Set where empty : List A cons : A -> List A -> List A append : {A : Set} -> List A -> List A -> List A append empty ys = ys append (cons x xs) ys = cons x (append xs ys) -- proposed code after refactoring data List2 (A : Set) : Nat -> Set where empty2 : List2 A 0 cons2 : {n : Nat} -> A -> List2 A n -> List2 A (plus 1 n) append2 : {n : Nat} -> {m : Nat} -> {A : Set} -> List2 A m -> List2 A n -> List2 A (plus m n) append2 empty2 ys = ys append2 (cons2 x xs) ys = cons2 x (append2 xs ys)
{ "alphanum_fraction": 0.5708836618, "avg_line_length": 27.1206896552, "ext": "agda", "hexsha": "18c12b19a0849193da4e59da89bc6f9568d7811c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/Test.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/Test.agda", "max_line_length": 114, "max_stars_count": 5, "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/Test.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "num_tokens": 498, "size": 1573 }
module Structure.Category.NaturalTransformation.Equiv where import Function.Equals open Function.Equals.Dependent import Lvl open import Logic open import Logic.Predicate open import Structure.Category open import Structure.Category.Functor open import Structure.Category.NaturalTransformation open import Structure.Setoid open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Type module _ {ℓₗₒ ℓₗₘ ℓₗₑ ℓᵣₒ ℓᵣₘ ℓᵣₑ} {catₗ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ}} {catᵣ : CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ}} {F₁ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} {F₂ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where _≡ᴺᵀ_ : (F₁ →ᴺᵀ F₂) → (F₁ →ᴺᵀ F₂) → Stmt [∃]-intro N₁ ≡ᴺᵀ [∃]-intro N₂ = N₁ ⊜ N₂ instance [≡ᴺᵀ]-reflexivity : Reflexivity(_≡ᴺᵀ_) Reflexivity.proof [≡ᴺᵀ]-reflexivity = reflexivity(_⊜_) instance [≡ᴺᵀ]-symmetry : Symmetry(_≡ᴺᵀ_) Symmetry.proof [≡ᴺᵀ]-symmetry = symmetry(_⊜_) instance [≡ᴺᵀ]-transitivity : Transitivity(_≡ᴺᵀ_) Transitivity.proof [≡ᴺᵀ]-transitivity = transitivity(_⊜_) instance [≡ᴺᵀ]-equivalence : Equivalence(_≡ᴺᵀ_) [≡ᴺᵀ]-equivalence = intro instance [→ᴺᵀ]-equiv : Equiv(F₁ →ᴺᵀ F₂) [→ᴺᵀ]-equiv = intro(_≡ᴺᵀ_) ⦃ [≡ᴺᵀ]-equivalence ⦄
{ "alphanum_fraction": 0.7005695688, "avg_line_length": 26.1489361702, "ext": "agda", "hexsha": "50b915177c809cd12b69c0196d24cc00e2885236", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Category/NaturalTransformation/Equiv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Category/NaturalTransformation/Equiv.agda", "max_line_length": 61, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Category/NaturalTransformation/Equiv.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 615, "size": 1229 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Functions.Definition open import Sets.CantorBijection.Proofs module Sets.CantorBijection.CantorBijection where open Sets.CantorBijection.Proofs using (cantorInverse ; cantorInverseLemma) public cantorBijection : Bijection cantorInverse Bijection.inj cantorBijection {x} {y} = cantorInverseInjective x y Bijection.surj cantorBijection = cantorInverseSurjective
{ "alphanum_fraction": 0.8243559719, "avg_line_length": 32.8461538462, "ext": "agda", "hexsha": "89e319d8e74bbbaa870b1607100d7a4d9c229421", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Sets/CantorBijection/CantorBijection.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Sets/CantorBijection/CantorBijection.agda", "max_line_length": 82, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Sets/CantorBijection/CantorBijection.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 120, "size": 427 }
module UniDB.Basic where open import UniDB.Spec open import UniDB.Subst open import Function module _ {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} {{apVrT : ApVr T}} {{apWkTT : ApWk T T}} {Ξ : MOR} {{upΞ : Up Ξ}} {{compΞ : Comp Ξ}} {{lkTΞ : Lk T Ξ}} {{lkUpTΞ : LkUp T Ξ}} {{lkCompTΞ : LkCompAp T Ξ}} where ⊙-↑₁-pointwise : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Ξ γ₁ γ₂) (ξ₂ : Ξ γ₂ γ₃) → [ T ] ((ξ₁ ⊙ ξ₂) ↑₁) ≃ (ξ₁ ↑₁ ⊙ ξ₂ ↑₁) lk≃ (⊙-↑₁-pointwise ξ₁ ξ₂) zero = begin lk {T} ((ξ₁ ⊙ ξ₂) ↑₁) zero ≡⟨ lk-↑₁-zero (ξ₁ ⊙ ξ₂) ⟩ vr zero ≡⟨ sym (lk-↑₁-zero ξ₂) ⟩ lk (ξ₂ ↑₁) zero ≡⟨ sym (ap-vr {T} (ξ₂ ↑₁) zero) ⟩ ap {T} (ξ₂ ↑₁) (vr zero) ≡⟨ cong (ap {T} (ξ₂ ↑₁)) (sym (lk-↑₁-zero ξ₁)) ⟩ ap {T} (ξ₂ ↑₁) (lk (ξ₁ ↑₁) zero) ≡⟨ sym (lk-⊙-ap {T} (ξ₁ ↑₁) (ξ₂ ↑₁) zero) ⟩ lk (ξ₁ ↑₁ ⊙ ξ₂ ↑₁) zero ∎ lk≃ (⊙-↑₁-pointwise ξ₁ ξ₂) (suc i) = begin lk ((ξ₁ ⊙ ξ₂) ↑₁) (wk₁ i) ≡⟨ lk-↑₁-suc (ξ₁ ⊙ ξ₂) i ⟩ wk₁ (lk (ξ₁ ⊙ ξ₂) i) ≡⟨ cong wk₁ (lk-⊙-ap {T} ξ₁ ξ₂ i) ⟩ wk₁ (ap {T} ξ₂ (lk ξ₁ i)) ≡⟨ sym (ap-wk₁ {T} ξ₂ (lk ξ₁ i)) ⟩ ap {T} (ξ₂ ↑₁) (wk₁ (lk ξ₁ i)) ≡⟨ cong (ap {T} (ξ₂ ↑₁)) (sym (lk-↑₁-suc ξ₁ i)) ⟩ ap {T} (ξ₂ ↑₁) (lk (ξ₁ ↑₁) (wk₁ i)) ≡⟨ sym (lk-⊙-ap {T} (ξ₁ ↑₁) (ξ₂ ↑₁) (wk₁ i) ) ⟩ lk (ξ₁ ↑₁ ⊙ ξ₂ ↑₁) (wk₁ i) ∎
{ "alphanum_fraction": 0.4268204758, "avg_line_length": 47.8275862069, "ext": "agda", "hexsha": "dc966c366aaf566bfaa5cda3fda99e0ec489a092", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_path": "UniDB/Basic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "skeuchel/unidb-agda", "max_issues_repo_path": "UniDB/Basic.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_path": "UniDB/Basic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 793, "size": 1387 }
{-# OPTIONS --without-K --safe #-} open import Algebra open import Relation.Unary open import Relation.Binary hiding (Decidable) module Data.FingerTree.Split {r m} (ℳ : Monoid r m) {s} {ℙ : Pred (Monoid.Carrier ℳ) s} (ℙ-resp : ℙ Respects (Monoid._≈_ ℳ)) (ℙ? : Decidable ℙ) where open import Relation.Nullary using (¬_; yes; no; Dec) open import Level using (_⊔_) open import Data.Product open import Function open import Data.List as List using (List; _∷_; []) open import Data.FingerTree.Measures ℳ open import Data.FingerTree.Structures ℳ open import Data.FingerTree.Reasoning ℳ open import Data.FingerTree.View ℳ using (deepₗ; deepᵣ) open import Data.FingerTree.Cons ℳ using (listToTree) open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable using (True; toWitness; False; toWitnessFalse) open σ ⦃ ... ⦄ open Monoid ℳ renaming (Carrier to 𝓡) open import Data.FingerTree.Relation.Binary.Reasoning.FasterInference.Setoid setoid open import Data.FingerTree.Split.Point ℳ ℙ-resp ℙ? open import Data.FingerTree.Split.StoredPredicate ℳ ℙ-resp ℙ? open import Data.FingerTree.Split.Intermediate ℳ ℙ-resp ℙ? open import Data.FingerTree.Split.Structures ℳ ℙ-resp ℙ? record Split {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ : Set (a ⊔ r ⊔ m ⊔ s) where constructor _∷⟨_⟩∷_[_] field left : Tree Σ focus : Σ right : Tree Σ is-split : μ left ∣ μ focus open Split public instance σ-Split : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → σ (Split Σ) μ ⦃ σ-Split ⦄ (l ∷⟨ x ⟩∷ r [ _ ]) = μ l ∙ (μ x ∙ μ r) split : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → {¬ℙ⟨ε⟩ : False (ℙ? ε)} → (xs : Tree Σ) → {ℙ⟨xs⟩ : True (ℙ? (μ xs))} → μ⟨ Split Σ ⟩≈ μ xs split {¬ℙ⟨ε⟩ = ¬ℙ⟨ε⟩} xs {ℙ⟨xs⟩} with splitTree ε xs (init-ℙ ¬ℙ⟨ε⟩ ℙ⟨xs⟩) ≈[ identityˡ _ ] ... | xs′ ∷⟨ x ⟩∷ ys [ p ] ⇑[ p₂ ] = xs′ ∷⟨ x ⟩∷ ys [ Relation.Nullary.recompute (_ ∣? _) p ≈◄⟅ identityˡ _ ⟆ ] ⇑[ sym (identityˡ _) ⍮ p₂ ]
{ "alphanum_fraction": 0.6447436561, "avg_line_length": 30.6507936508, "ext": "agda", "hexsha": "92b6a451de209ab3ecf05c5fb76da8c53e863bda", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_path": "src/Data/FingerTree/Split.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-indexed-fingertree", "max_issues_repo_path": "src/Data/FingerTree/Split.agda", "max_line_length": 140, "max_stars_count": 1, "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_path": "src/Data/FingerTree/Split.agda", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "num_tokens": 759, "size": 1931 }
open import prelude renaming (_≟Nat_ to _≟_) infixl 5 _$_ -- Copied pretty much verbatim Var = Nat data Term : Set where var : Var → Term fun : Term → Term _$_ : Term → Term → Term -- Doing full reduction, so values are either of the form -- (fun v) or (x v1 ... vN) data VarHeaded : Term → Set data Value : Term → Set data VarHeaded where var : (x : Var) → VarHeaded(var x) _$_ : ∀ {t u} → VarHeaded(t) → Value(u) → VarHeaded(t $ u) data Value where var : (x : Var) → Value(var x) fun : ∀ {t} → Value(t) → Value(fun t) _$_ : ∀ {t u} → VarHeaded(t) → Value(u) → Value(t $ u) -- Substitution is now total! shift : Var → Var → Term → Term shift c d (var x) = if (c ≤? x) (var (d + x)) (var x) shift c d (fun t) = fun (shift (1 + c) d t) shift c d (t₁ $ t₂) = (shift c d t₁) $ (shift c d t₂) [_↦_]_ : Var → Term → Term → Term [ x ↦ s ] var y = if (x ≟ y) (shift x 0 s) (if (x ≤? y) (var (y - 1)) (var y)) [ x ↦ s ] fun t = fun ([ (1 + x) ↦ s ] t) [ x ↦ s ] (t₁ $ t₂) = ([ x ↦ s ] t₁) $ ([ x ↦ s ] t₂) -- Reduction is as per TAPL data _⟶_ : Term → Term → Set where E─App1 : ∀ {t₁ t₁′ t₂} → (t₁ ⟶ t₁′) → ------------------------ (t₁ $ t₂) ⟶ (t₁′ $ t₂) E─App2 : ∀ {t₁ t₂ t₂′} → (t₂ ⟶ t₂′) → ------------------------ (t₁ $ t₂) ⟶ (t₁ $ t₂′) E─AppAbs : ∀ {t₁ t₂} → --------------------------------- (fun t₁ $ t₂) ⟶ ([ 0 ↦ t₂ ] t₁) -- Needed for full reduction! E─FunCong : ∀ {t t′} → (t ⟶ t′) → ---------------- fun t ⟶ fun t′ -- A redex is a term which can reduce data Redex : Term → Set where redex : ∀ {t t′} → t ⟶ t′ → -------- Redex(t) -- Proving that every closed term is a value or a redex data ValueOrRedex : Term → Set where value : ∀ {t} → (Value(t)) → --------------- ValueOrRedex(t) redex : ∀ {t t′} → t ⟶ t′ → --------------- ValueOrRedex(t) valueOrRedex : (t : Term) → ValueOrRedex(t) valueOrRedex (var x) = value (var x) valueOrRedex (fun t) = helper (valueOrRedex t) where helper : ValueOrRedex(t) → ValueOrRedex(fun t) helper (value v) = value (fun v) helper (redex r) = redex (E─FunCong r) valueOrRedex (t₁ $ t₂) = helper₁ (valueOrRedex t₁) where helper₃ : ∀ {t₁} → Value(t₁) → Value(t₂) → ValueOrRedex(t₁ $ t₂) helper₃ (var x) v = value (var x $ v) helper₃ (fun t) v = redex E─AppAbs helper₃ (t $ u) v = value (t $ u $ v) helper₂ : Value(t₁) → ValueOrRedex(t₂) → ValueOrRedex(t₁ $ t₂) helper₂ v₁ (value v₂) = helper₃ v₁ v₂ helper₂ v₁ (redex r) = redex (E─App2 r) helper₁ : ValueOrRedex(t₁) → ValueOrRedex(t₁ $ t₂) helper₁ (value v₁) = helper₂ v₁ (valueOrRedex t₂) helper₁ (redex r) = redex (E─App1 r) -- Interpreter! data _⟶*_ : Term → Term → Set where done : ∀ {t} → -------- t ⟶* t redex : ∀ {t t′ t″} → t ⟶ t′ → t′ ⟶* t″ → ---------- t ⟶* t″ -- An interpreter result data Result : Term → Set where result : ∀ {t t′} → t ⟶* t′ → Value(t′) → --------- Result(t) -- The interpreter just calls `valueOrRedex` until it is a value. -- This might not terminate! {-# NON_TERMINATING #-} interp : (t : Term) → Result(t) interp t = helper₂ (valueOrRedex t) where helper₁ : ∀ {t′} → (t ⟶ t′) → Result(t′) → Result(t) helper₁ r (result s v) = result (redex r s) v helper₂ : ValueOrRedex(t) → Result(t) helper₂ (value v) = result done v helper₂ (redex {t′ = t′} r) = helper₁ r (interp t′) -- Examples zer : Term zer = fun (fun (var 1)) succ : Term succ = fun (fun (fun (var 0 $ var 2))) add : Term add = fun (fun (var 1 $ var 0 $ succ)) two : Term two = succ $ (succ $ zer) four : Term four = add $ two $ two -- DANGER! Do not run interp loop loop : Term loop = (fun (var 0 $ var 0)) $ (fun (var 0 $ var 0))
{ "alphanum_fraction": 0.5212233061, "avg_line_length": 21.1899441341, "ext": "agda", "hexsha": "7622b7ff3cb33a1e29973f2c3656aa1dd694978d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "asajeffrey/tapl", "max_forks_repo_path": "ch6.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "asajeffrey/tapl", "max_issues_repo_path": "ch6.agda", "max_line_length": 79, "max_stars_count": 3, "max_stars_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "asajeffrey/tapl", "max_stars_repo_path": "ch6.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-15T12:09:59.000Z", "max_stars_repo_stars_event_min_datetime": "2021-03-12T22:44:19.000Z", "num_tokens": 1478, "size": 3793 }
module Data.Graph where open import Data.List as List using (List; []; _∷_) open import Data.Nat hiding (_⊔_) open import Data.Product open import Data.Vec as Vec using (Vec; []; _∷_) open import Data.Vec.Properties open import Level as ℓ using (Level; _⊔_) open import Finite open import Finite.Pigeonhole open import Function open import Relation.Binary open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Relation.Binary.HeterogeneousEquality as ≅ open import Relation.Binary.PropositionalEquality as ≡ open import Relation.Nullary open IsFinite module Path {ℓᵥ ℓₑ} {V : Set ℓᵥ} (_↦_ : V → V → Set ℓₑ) where data Path a : V → ℕ → Set (ℓᵥ ⊔ ℓₑ) where [] : Path a a zero _∷_ : ∀ {b c n} → a ↦ b → Path b c n → Path a c (suc n) Path≤ = λ a b n → ∃ λ m → m ≤ n × Path a b m Path< = λ a b n → ∃ λ m → m < n × Path a b m infixr 5 _∷ʳ_ _∷ʳ_ : ∀ {a b c n} → Path a b n → b ↦ c → Path a c (suc n) [] ∷ʳ e = e ∷ [] (e ∷ p) ∷ʳ e′ = e ∷ p ∷ʳ e′ unsnoc : ∀ {n a c} (p : Path a c (suc n)) → ∃ λ b → ∃₂ λ (p′ : Path a b n) (e : b ↦ c) → p ≡ p′ ∷ʳ e unsnoc (e ∷ []) = -, [] , e , refl unsnoc (e ∷ d ∷ p) with unsnoc (d ∷ p) … | b , p′ , e′ , eq rewrite eq = b , e ∷ p′ , e′ , refl infixl 5 _++_ _++_ : ∀ {a b c m n} → Path a b m → Path b c n → Path a c (m + n) [] ++ q = q (e ∷ p) ++ q = e ∷ (p ++ q) trail : ∀ {a b n} → Path a b n → Vec V n trail [] = [] trail {a} (e ∷ p) = a ∷ trail p toStar : ∀ {a b n} → Path a b n → Star _↦_ a b toStar [] = ε toStar (e ∷ p) = e ◅ toStar p starLength : ∀ {a b} → Star _↦_ a b → ℕ starLength = fold _ (const suc) zero fromStar : ∀ {a b} (p : Star _↦_ a b) → Path a b (starLength p) fromStar ε = [] fromStar (e ◅ p) = e ∷ fromStar p toStar-fromStar : ∀ {a b} (p : Star _↦_ a b) → p ≡ toStar (fromStar p) toStar-fromStar ε = refl toStar-fromStar (e ◅ p) = ≡.cong (e ◅_) (toStar-fromStar p) starLength-toStar : ∀ {a b n} (p : Path a b n) → n ≡ starLength (toStar p) starLength-toStar [] = refl starLength-toStar (e ∷ p) = ≡.cong suc (starLength-toStar p) fromStar-toStar : ∀ {a b n} (p : Path a b n) → p ≅ fromStar (toStar p) fromStar-toStar [] = refl fromStar-toStar (e ∷ p) = ≅.icong (Path _ _) {B = λ {x} _ → Path _ _ (suc x)} (starLength-toStar p) (e ∷_) (fromStar-toStar p) starTrail : ∀ {a b} (p : Star _↦_ a b) → Vec V (starLength p) starTrail ε = [] starTrail {a} (e ◅ p) = a ∷ starTrail p trail-fromStar : ∀ {a b} (p : Star _↦_ a b) → starTrail p ≡ trail (fromStar p) trail-fromStar ε = refl trail-fromStar (e ◅ p) = ≡.cong (_ ∷_) (trail-fromStar p) starTrail-toStar : ∀ {a b n} (p : Path a b n) → trail p ≅ starTrail (toStar p) starTrail-toStar [] = refl starTrail-toStar {a} {b} {suc n} (e ∷ p) = ≅.icong (λ i → Vec V i) {B = λ {i} _ → Vec V (suc i)} (starLength-toStar p) (λ as → a ∷ as) (starTrail-toStar p) module Embed {ℓᵥ ℓᵥ′ ℓₑ ℓₑ′} {V : Set ℓᵥ} {V′ : Set ℓᵥ′} {_↦_ : V → V → Set ℓₑ} {_↦′_ : V′ → V′ → Set ℓₑ′} {f} (r : _↦_ =[ f ]⇒ _↦′_) where open Path embedPath : ∀ {a b n} → Path _↦_ a b n → Path _↦′_ (f a) (f b) n embedPath [] = [] embedPath (e ∷ es) = r e ∷ embedPath es record FiniteGraph ℓᵥ ℓₑ : Set (ℓ.suc ℓᵥ ⊔ ℓ.suc ℓₑ) where field {Vertex} : Set ℓᵥ {Edge} : Vertex → Vertex → Set ℓₑ {{vertexFinite}} : IsFinite Vertex {{edgeFinite}} : ∀ a → IsFinite (∃ (Edge a)) decEqVertex : (a b : Vertex) → Dec (a ≡ b) open Path Edge public
{ "alphanum_fraction": 0.5538154897, "avg_line_length": 31.6396396396, "ext": "agda", "hexsha": "d910fec225343c5503f082d54b60135b929aab46", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0196cf8a136a4933cd6358e4c9692aaf919ca603", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kcsmnt0/graph", "max_forks_repo_path": "src/Data/Graph.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0196cf8a136a4933cd6358e4c9692aaf919ca603", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "kcsmnt0/graph", "max_issues_repo_path": "src/Data/Graph.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "0196cf8a136a4933cd6358e4c9692aaf919ca603", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kcsmnt0/graph", "max_stars_repo_path": "src/Data/Graph.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1511, "size": 3512 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommAlgebra.Instances.Unit where open import Cubical.Foundations.Prelude open import Cubical.Data.Unit open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Instances.Unit open import Cubical.Algebra.CommAlgebra private variable ℓ ℓ' : Level open CommAlgebraStr module _ (R : CommRing ℓ) where UnitCommAlgebra : CommAlgebra R ℓ' UnitCommAlgebra = commAlgebraFromCommRing UnitCommRing (λ _ _ → tt*) (λ _ _ _ → refl) (λ _ _ _ → refl) (λ _ _ _ → refl) (λ _ → refl) (λ _ _ _ → refl)
{ "alphanum_fraction": 0.722675367, "avg_line_length": 23.5769230769, "ext": "agda", "hexsha": "cbccbeaf919d66402d38856b9ab177a88e92ce8c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Unit.agda", "max_line_length": 55, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 185, "size": 613 }
factorial : ℕ → ℕ factorial zero = 1 factorial (suc n) = suc n * factorial n
{ "alphanum_fraction": 0.6753246753, "avg_line_length": 19.25, "ext": "agda", "hexsha": "7d45856f0af3eac00104077867aabab96725355e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": [ "Info-ZIP" ], "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_path": "Task/Factorial/Agda/factorial.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Info-ZIP" ], "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_path": "Task/Factorial/Agda/factorial.agda", "max_line_length": 39, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": [ "Info-ZIP" ], "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_path": "Task/Factorial/Agda/factorial.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T13:42:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-05T13:42:20.000Z", "num_tokens": 28, "size": 77 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.Queue.Truncated2List where open import Cubical.Foundations.Everything open import Cubical.Foundations.SIP open import Cubical.Structures.Queue open import Cubical.Data.Maybe open import Cubical.Data.List open import Cubical.Data.Sigma open import Cubical.Data.Queue.1List module Truncated2List {ℓ} (A : Type ℓ) (Aset : isSet A) where open Queues-on A Aset data Q : Type ℓ where Q⟨_,_⟩ : (xs ys : List A) → Q tilt : ∀ xs ys z → Q⟨ xs ++ [ z ] , ys ⟩ ≡ Q⟨ xs , ys ++ [ z ] ⟩ trunc : (q q' : Q) (α β : q ≡ q') → α ≡ β multitilt : (xs ys zs : List A) → Q⟨ xs ++ rev zs , ys ⟩ ≡ Q⟨ xs , ys ++ zs ⟩ multitilt xs ys [] = cong₂ Q⟨_,_⟩ (++-unit-r xs) (sym (++-unit-r ys)) multitilt xs ys (z ∷ zs) = cong (λ ws → Q⟨ ws , ys ⟩) (sym (++-assoc xs (rev zs) [ z ])) ∙ tilt (xs ++ rev zs) ys z ∙ multitilt xs (ys ++ [ z ]) zs ∙ cong (λ ws → Q⟨ xs , ws ⟩) (++-assoc ys [ z ] zs) -- enq into the first list, deq from the second if possible emp : Q emp = Q⟨ [] , [] ⟩ enq : A → Q → Q enq a Q⟨ xs , ys ⟩ = Q⟨ a ∷ xs , ys ⟩ enq a (tilt xs ys z i) = tilt (a ∷ xs) ys z i enq a (trunc q q' α β i j) = trunc _ _ (cong (enq a) α) (cong (enq a) β) i j deqFlush : List A → Maybe (Q × A) deqFlush [] = nothing deqFlush (x ∷ xs) = just (Q⟨ [] , xs ⟩ , x) deq : Q → Maybe (Q × A) deq Q⟨ xs , [] ⟩ = deqFlush (rev xs) deq Q⟨ xs , y ∷ ys ⟩ = just (Q⟨ xs , ys ⟩ , y) deq (tilt xs [] z i) = path i where path : deqFlush (rev (xs ++ [ z ])) ≡ just (Q⟨ xs , [] ⟩ , z) path = cong deqFlush (rev-++ xs [ z ]) ∙ cong (λ q → just (q , z)) (sym (multitilt [] [] (rev xs))) ∙ cong (λ ys → just (Q⟨ ys , [] ⟩ , z)) (rev-rev xs) deq (tilt xs (y ∷ ys) z i) = just (tilt xs ys z i , y) deq (trunc q q' α β i j) = isOfHLevelMaybe 0 (isSetΣ trunc λ _ → Aset) (deq q) (deq q') (cong deq α) (cong deq β) i j Raw : RawQueue Raw = (Q , emp , enq , deq) -- We construct an equivalence to 1Lists and prove this is an equivalence of queue structures private module One = 1List A Aset open One renaming (Q to Q₁; emp to emp₁; enq to enq₁; deq to deq₁) using () quot : Q₁ → Q quot xs = Q⟨ xs , [] ⟩ eval : Q → Q₁ eval Q⟨ xs , ys ⟩ = xs ++ rev ys eval (tilt xs ys z i) = path i where path : (xs ++ [ z ]) ++ rev ys ≡ xs ++ rev (ys ++ [ z ]) path = ++-assoc xs [ z ] (rev ys) ∙ cong (_++_ xs) (sym (rev-++ ys [ z ])) eval (trunc q q' α β i j) = -- truncated case isOfHLevelList 0 Aset (eval q) (eval q') (cong eval α) (cong eval β) i j quot∘eval : ∀ q → quot (eval q) ≡ q quot∘eval Q⟨ xs , ys ⟩ = multitilt xs [] ys quot∘eval (tilt xs ys z i) = -- truncated case isOfHLevelPathP' {A = λ i → quot (eval (tilt xs ys z i)) ≡ tilt xs ys z i} 0 (trunc _ _) (multitilt (xs ++ [ z ]) [] ys) (multitilt xs [] (ys ++ [ z ])) .fst i quot∘eval (trunc q q' α β i j) = -- truncated case isOfHLevelPathP' {A = λ i → PathP (λ j → quot (eval (trunc q q' α β i j)) ≡ trunc q q' α β i j) (quot∘eval q) (quot∘eval q')} 0 (isOfHLevelPathP' 1 (isOfHLevelSuc 2 trunc _ _) _ _) (cong quot∘eval α) (cong quot∘eval β) .fst i j eval∘quot : ∀ xs → eval (quot xs) ≡ xs eval∘quot = ++-unit-r -- We get our desired equivalence quotEquiv : Q₁ ≃ Q quotEquiv = isoToEquiv (iso quot eval quot∘eval eval∘quot) -- Now it only remains to prove that this is an equivalence of queue structures quot∘emp : quot emp₁ ≡ emp quot∘emp = refl quot∘enq : ∀ x xs → quot (enq₁ x xs) ≡ enq x (quot xs) quot∘enq x xs = refl quot∘deq : ∀ xs → deqMap quot (deq₁ xs) ≡ deq (quot xs) quot∘deq [] = refl quot∘deq (x ∷ []) = refl quot∘deq (x ∷ x' ∷ xs) = deqMap-∘ quot (enq₁ x) (deq₁ (x' ∷ xs)) ∙ sym (deqMap-∘ (enq x) quot (deq₁ (x' ∷ xs))) ∙ cong (deqMap (enq x)) (quot∘deq (x' ∷ xs)) ∙ lemma x x' (rev xs) where lemma : ∀ x x' ys → deqMap (enq x) (deqFlush (ys ++ [ x' ])) ≡ deqFlush ((ys ++ [ x' ]) ++ [ x ]) lemma x x' [] i = just (tilt [] [] x i , x') lemma x x' (y ∷ ys) i = just (tilt [] (ys ++ [ x' ]) x i , y) quotEquivHasQueueEquivStr : RawQueueEquivStr One.Raw Raw quotEquiv quotEquivHasQueueEquivStr = quot∘emp , quot∘enq , quot∘deq -- And we get a path between the raw 1Lists and 2Lists Raw-1≡2 : One.Raw ≡ Raw Raw-1≡2 = sip rawQueueUnivalentStr _ _ (quotEquiv , quotEquivHasQueueEquivStr) -- We derive the axioms for 2List from those for 1List WithLaws : Queue WithLaws = Q , str Raw , subst (uncurry QueueAxioms) Raw-1≡2 (snd (str One.WithLaws)) WithLaws-1≡2 : One.WithLaws ≡ WithLaws WithLaws-1≡2 = sip queueUnivalentStr _ _ (quotEquiv , quotEquivHasQueueEquivStr) Finite : FiniteQueue Finite = Q , str WithLaws , subst (uncurry FiniteQueueAxioms) WithLaws-1≡2 (snd (str One.Finite))
{ "alphanum_fraction": 0.57181015, "avg_line_length": 32.2317880795, "ext": "agda", "hexsha": "dd0b469e5cd48fca6abb8a9a0d714aa9362ed747", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Queue/Truncated2List.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Queue/Truncated2List.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Queue/Truncated2List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1961, "size": 4867 }
module Soundness where {- open import Relation.Binary.PropositionalEquality open import Data.Nat hiding (_>_) -} open import StdLibStuff open import Syntax open import STT open import FSC open import DerivedProps open import HelpDefs mutual sound : {n : ℕ} {Γ-t : Ctx n} (Γ : FSC-Ctx n Γ-t) (F : Form Γ-t $o) → Γ ⊢ F → ⊢ (hypos Γ F) sound Γ .(F || G) (||-I-l {F} {G} p) = inf-V (traverse-hypos F (F || G) Γ ax-2-s) (sound Γ F p) sound Γ .(F || G) (||-I-r {F} {G} p) = inf-V (traverse-hypos G (F || G) Γ (inf-V (inf-V ax-4-s ax-3-s) ax-2-s)) (sound Γ G p) sound Γ .(F & G) (&-I {F} {G} pF pG) = inf-V (inf-V (traverse-hypos-pair-I F G Γ) (sound Γ F pF)) (sound Γ G pG) sound Γ .(F => G) (=>-I {F} {G} p) = sound (F ∷h Γ) G p sound Γ .(~ F) (~-I {F} p) = inf-V (traverse-hypos (F => $false) (~ F) Γ (lem10 F)) (sound (F ∷h Γ) $false p) sound Γ .(![ t ] F) (!-I {t} {F} p) = traverse-=>-I-dep t F Γ (inf-VI-s (sound (t ∷ Γ) F p)) sound Γ .(!'[ t ] F) (!'-I {t} {F} p) = traverse-=>-I-dep' t F Γ (sound (t ∷ Γ) (weak F · $ this {refl}) p) sound Γ F (elim x p) = inf-V (traverse-hypos-elim F Γ x) (sound-elim Γ (lookup-hyp Γ x) F p) sound Γ F (ac {t} p) = inf-V (traverse-hypos ((![ t > $o ] ((?[ t ] (var (next this) refl · var this refl)) => (var this refl · (ι t (var (next this) refl · var this refl))))) => F) F Γ (inf-V (lemb3 (![ t > $o ] ((?[ t ] (var (next this) refl · var this refl)) => (var this refl · ι t (var (next this) refl · var this refl)))) F) (inf-VI-s (ax-11-s {_} {(t > $o) ∷ _} {t} {var (next this) refl · var this refl})))) (sound-elim Γ (![ t > $o ] ((?[ t ] (var (next this) refl · var this refl)) => (var this refl · (ι t (var (next this) refl · var this refl))))) F p) sound Γ F (ac' {t} p) = inf-V (traverse-hypos ((![ t > $o ] ((?[ t ] ($ (next this) {refl} · $ this {refl})) => ($ this {refl} · ι' t ($ this {refl})))) => F) F Γ (inf-V (lemb3 (![ t > $o ] ((?[ t ] ($ (next this) {refl} · $ this {refl})) => ($ this {refl} · ι' t ($ this {refl})))) F) (inf-VI-s (ax-11-s2 ($ this {refl}))))) (sound-elim Γ (![ t > $o ] ((?[ t ] ($ (next this) {refl} · $ this {refl})) => ($ this {refl} · ι' t ($ this {refl})))) F p) sound Γ .(?[ t ] F) (?-I {t} {F} G p) = inf-V (traverse-hypos (sub G F) (?[ t ] F) Γ (inf-V ax-3-s (ax-5-s (~ F) G))) (sound Γ (sub G F) p) sound Γ .(?'[ t ] F) (?'-I {t} {F} G p) = inf-V (traverse-hypos (app F G) (?'[ t ] F) Γ (inf-V ax-3-s (ax-5-s2 F G))) (sound Γ (app F G) p) sound Γ .$true $true-I = traverse-hypos-use $true Γ (inf-VI-s (inf-V (inf-V ax-4-s ax-1-s) ax-2-s)) sound Γ .(F == G) (==-I {t} {F} {G} p) = sound-== Γ t F G p sound Γ .(F ((^[ t ] G) · H)) (reduce {t} {u} {F} {G} {H} p) = inf-V (traverse-hypos (F (sub H G)) (F ((^[ t ] G) · H)) Γ (inf-III-samectx (λ x → (F x)) G H)) (sound Γ (F (sub H G)) p) sound Γ F (raa p) = inf-V (traverse-hypos (~ (~ F)) F Γ (lemb2 F)) (sound _ _ p) sound-elim : ∀ {n Γ-t} → (Γ : FSC-Ctx n Γ-t) (F G : Form Γ-t $o) → Γ , F ⊢ G → ⊢ (hypos Γ (F => G)) sound-elim Γ F G (use p) = inf-V (traverse-hypos (G == F) (F => G) Γ (lem13 F G)) (sound-↔ Γ $o G F p) sound-elim Γ .(F & G) H (&-E-l {F} {G} p) = inf-V (traverse-hypos (F => H) ((F & G) => H) Γ (lem6 F G H)) (sound-elim Γ F H p) sound-elim Γ .(F & G) H (&-E-r {F} {G} p) = inf-V (traverse-hypos (G => H) ((F & G) => H) Γ (lem6b F G H)) (sound-elim Γ G H p) sound-elim Γ .(F => G) H (=>-E {F} {G} p₁ p₂) = inf-V (inf-V (traverse-hypos2 F (G => H) ((F => G) => H) Γ (lem7 F G H)) (sound Γ F p₁)) (sound-elim Γ G H p₂) sound-elim Γ .(~ F) H (~-E {F} p) = inf-V (traverse-hypos F (~ F => H) Γ (lemb4 F H)) (sound Γ F p) sound-elim Γ .(![ t ] F) H (!-E {t} {F} G p) = inf-V (traverse-hypos (sub G F => H) (![ t ] F => H) Γ (inf-V (lem9 (![ t ] F) (sub G F) H) (ax-5-s F G))) (sound-elim Γ (sub G F) H p) sound-elim Γ .(!'[ t ] F) H (!'-E {t} {F} G p) = inf-V (traverse-hypos ((F · G) => H) (!'[ t ] F => H) Γ (inf-V (lem9 (!'[ t ] F) (F · G) H) (ax-5-s3 F G))) (sound-elim Γ (F · G) H p) sound-elim Γ .$false H $false-E = traverse-hypos-use ($false => H) Γ (lem11 H) sound-elim Γ .(F || G) H (||-E {F} {G} p₁ p₂) = inf-V (inf-V (traverse-hypos2 (F => H) (G => H) ((F || G) => H) Γ (lemb5 F G H)) (sound _ _ p₁)) (sound _ _ p₂) sound-elim Γ .(?[ t ] F) H (?-E {t} {F} p) = inf-V (traverse-hypos (sub (ι t F) F => H) (?[ t ] F => H) Γ (inf-V (lem9 (?[ t ] F) (sub (ι t F) F) H) (ax-11-s {_} {_} {_} {F}))) (sound-elim Γ (sub (ι t F) F) H p) sound-elim Γ .(?'[ t ] F) H (?'-E {t} {F} p) = inf-V (traverse-hypos ((F · ι' _ F) => H) (?'[ t ] F => H) Γ (inf-V (lem9 (?'[ t ] F) (F · ι' t F) H) (ax-11-s2 F))) (sound-elim Γ (F · ι' _ F) H p) sound-elim Γ .(F ((^[ t ] G) · H)) I (reduce {t} {u} {F} {G} {H} p) = inf-V (traverse-hypos (F (sub H G) => I) (F ((^[ t ] G) · H) => I) Γ (inf-V (lem9 (F ((^[ t ] G) · H)) (F (sub H G)) I) (inf-II-samectx (λ x → (F x)) G H))) (sound-elim Γ (F (sub H G)) I p) sound-elim Γ .(F == G) H (r-bool-ext {F} {G} p) = inf-V (traverse-hypos (((F => G) & (G => F)) => H) ((F == G) => H) Γ (inf-V (lem9 (F == G) ((F => G) & (G => F)) H) (inf-V (lem2 (F == G) (F => G) (G => F)) (inf-V (inf-V (lemb1 ((F == G) => (F => G)) ((F == G) => (G => F))) (inf-V ax-3-s (inf-V (inf-V ax-4-s (inf-V (lem5 (F == G) (G == F)) (lem15 F G))) (inf-V ax-3-s (lem13 F G))))) (lem13 G F))))) (sound-elim Γ ((F => G) & (G => F)) H p) sound-elim Γ .(F == G) H (r-fun-ext {t} {u} {F} {G} I p) = inf-V (traverse-hypos (((F · I) == (G · I)) => H) ((F == G) => H) Γ (inf-V (lem9 (F == G) ((F · I) == (G · I)) H) (inf-V (inf-V (lem4 (F == G) (I == I) ((F · I) == (G · I))) (lem16 F G I I)) (lem12 I)))) (sound-elim Γ ((F · I) == (G · I)) H p) sound-== : ∀ {n Γ-t} → (Γ : FSC-Ctx n Γ-t) (t : Type n) (F G : Form Γ-t t) → Γ ⊢ t ∋ F == G → ⊢ (hypos Γ (F == G)) sound-== Γ t F G (simp p) = sound-↔ Γ t F G p sound-== Γ t F G (step F' G' x p₁ p₂ p₃) = inf-V (inf-V (inf-V (traverse-hypos3 (F == F') (F' == G') (G' == G) (F == G) Γ (lem14 F F' G' G)) (sound-↔ Γ t F F' p₂)) (inf-V (traverse-hypos-elim (F' == G') Γ x) (sound-==-elim Γ (lookup-hyp Γ x) t F' G' p₁))) (sound-== Γ t G' G p₃) sound-== Γ .$o F G (bool-ext p) = inf-V (traverse-hypos ((F => G) & (G => F)) (F == G) Γ ax-10-a-s) (sound _ _ p) sound-== Γ .(t > u) F G (fun-ext {t} {u} p) = inf-V (traverse-hypos (![ t ] (((weak F) · $ this {refl}) == ((weak G) · $ this {refl}))) (F == G) Γ ax-10-b-s2) (traverse-=>-I-dep t ((weak F · $ this {refl}) == (weak G · $ this {refl})) Γ (inf-VI-s (sound-== (t ∷ Γ) u (weak F · $ this {refl}) (weak G · $ this {refl}) p))) sound-↔ : ∀ {n Γ-t} → (Γ : FSC-Ctx n Γ-t) (t : Type n) (F G : Form Γ-t t) → Γ ⊢ t ∋ F ↔ G → ⊢ (hypos Γ (F == G)) sound-↔ Γ t .(var x p) .(var x p) (head-var ._ x p) = traverse-hypos-use (var x p == var x p) Γ (lem12 (var x p)) sound-↔ Γ .t .c .c (head-const t c) = traverse-hypos-use (c == c) Γ (lem12 c) sound-↔ Γ .t₂ .(F₁ · G₁) .(F₂ · G₂) (head-app t₁ t₂ F₁ F₂ G₁ G₂ p₁ p₂) = inf-V (inf-V (traverse-hypos2 (F₁ == F₂) (G₁ == G₂) ((F₁ · G₁) == (F₂ · G₂)) Γ (lem16 F₁ F₂ G₁ G₂)) (sound-== Γ _ F₁ F₂ p₁)) (sound-== Γ _ G₁ G₂ p₂) sound-↔ Γ .(t₁ > t₂) .(lam t₁ F₁) .(lam t₁ F₂) (head-lam t₁ t₂ F₁ F₂ p) = traverse-hypos-eq-=>-I F₁ F₂ Γ (sound-== (t₁ ∷ Γ) t₂ F₁ F₂ p) sound-↔ Γ .(t₁ > t₂) .F₁ .(lam t₁ F₂) (head-lam-eta-left t₁ t₂ F₁ F₂ p) = inf-V (traverse-hypos (![ t₁ ] ((weak F₁ · $ this {refl}) == F₂)) (F₁ == lam t₁ F₂) Γ (inf-V (inf-V ax-4-s ax-10-b-s2) (subst (λ z → ⊢ ((![ t₁ ] ((weak F₁ · $ this {refl}) == z)) => (![ t₁ ] ((weak F₁ · $ this {refl}) == (weak (^[ t₁ ] F₂) · $ this {refl}))))) (sub-sub-weak-weak-p-3 F₂) (inf-III _ (t₁ ∷ ε) (λ z → ![ t₁ ] ((weak F₁ · $ this {refl}) == z)) (weak-i (t₁ ∷ ε) _ F₂) ($ this {refl}))))) (tst3' {_} {_} {ε} ((weak F₁ · $ this {refl}) == F₂) Γ refl (sound-== (t₁ ∷ Γ) t₂ (weak F₁ · $ this {refl}) F₂ p)) sound-↔ Γ .(t₁ > t₂) .(lam t₁ F₂) .F₁ (head-lam-eta-right t₁ t₂ F₁ F₂ p) = inf-V (traverse-hypos (![ t₁ ] (F₂ == (weak F₁ · $ this {refl}))) (lam t₁ F₂ == F₁) Γ (inf-V (inf-V ax-4-s ax-10-b-s2) (subst (λ z → ⊢ ((![ t₁ ] (z == (weak F₁ · $ this {refl}))) => (![ t₁ ] ((weak (^[ t₁ ] F₂) · $ this {refl}) == (weak F₁ · $ this {refl}))))) (sub-sub-weak-weak-p-3 F₂) (inf-III _ (t₁ ∷ ε) (λ z → ![ t₁ ] (z == (weak F₁ · $ this {refl}))) (weak-i (t₁ ∷ ε) _ F₂) ($ this {refl}))))) (tst3' {_} {_} {ε} (F₂ == (weak F₁ · $ this {refl})) Γ refl (sound-== (t₁ ∷ Γ) t₂ F₂ (weak F₁ · $ this {refl}) p)) sound-↔ Γ t .(F₁ ((^[ u ] G') · H)) G (reduce-l {.t} {u} {v} {F₁} {G'} {H} p) = inf-V (traverse-hypos (F₁ (sub H G') == G) (F₁ ((^[ u ] G') · H) == G) Γ (inf-III-samectx (λ x → (F₁ x == G)) G' H)) (sound-↔ Γ t (F₁ (sub H G')) G p) sound-↔ Γ t F .(F₂ ((^[ u ] G) · H)) (reduce-r {.t} {u} {v} {F₂} {G} {H} p) = inf-V (traverse-hypos (F == F₂ (sub H G)) (F == F₂ ((^[ u ] G) · H)) Γ (inf-III-samectx (λ x → (F == F₂ x)) G H)) (sound-↔ Γ t F (F₂ (sub H G)) p) sound-==-elim : ∀ {n Γ-t} → (Γ : FSC-Ctx n Γ-t) (F : Form Γ-t $o) (t : Type n) (G H : Form Γ-t t) → Γ , F ⊢ G == H → ⊢ (hypos Γ (F => (G == H))) sound-==-elim Γ .(G == H) t G H use = traverse-hypos-use ((G == H) => (G == H)) Γ (inf-V (inf-V ax-4-s ax-1-s) ax-2-s) sound-==-elim Γ F t G H (use' p) = traverse-hypos-use (F => (G == H)) Γ (hn-form (λ z → z => (G == H)) _ 2 (subst (λ z → ⊢ (z => (G == H))) p (hn-form (λ z → headNorm 2 (G == H) => z) _ 2 (inf-V (inf-V ax-4-s ax-1-s) ax-2-s)))) sound-==-elim Γ .(H == G) t G H use-sym = traverse-hypos-use ((H == G) => (G == H)) Γ (lem15 H G) sound-==-elim Γ .(F & G') t G H (&-E-l {F} {G'} p) = inf-V (traverse-hypos (F => (G == H)) ((F & G') => (G == H)) Γ (lem6 F G' (G == H))) (sound-==-elim Γ F t G H p) sound-==-elim Γ .(F & G') t G H (&-E-r {F} {G'} p) = inf-V (traverse-hypos (G' => (G == H)) ((F & G') => (G == H)) Γ (lem6b F G' (G == H))) (sound-==-elim Γ G' t G H p) sound-==-elim Γ .(F => G') t G H (=>-E {F} {G'} p₁ p₂) = inf-V (inf-V (traverse-hypos2 F (G' => (G == H)) ((F => G') => (G == H)) Γ (lem7 F G' (G == H))) (sound Γ F p₁)) (sound-==-elim Γ G' t G H p₂) sound-==-elim Γ .(![ u ] F) t G H (!-E {u} {F} G' p) = inf-V (traverse-hypos (sub G' F => (G == H)) (![ u ] F => (G == H)) Γ (inf-V (lem9 (![ u ] F) (sub G' F) (G == H)) (ax-5-s F G'))) (sound-==-elim Γ (sub G' F) t G H p) sound-==-elim Γ .(!'[ u ] F) t G H (!'-E {u} {F} G' p) = inf-V (traverse-hypos ((F · G') => (G == H)) (!'[ u ] F => (G == H)) Γ (inf-V (lem9 (!'[ u ] F) (F · G') (G == H)) (ax-5-s3 F G'))) (sound-==-elim Γ (F · G') t G H p) sound-==-elim Γ .(?[ u ] F) t G H (?-E {u} {F} p) = inf-V (traverse-hypos (sub (ι u F) F => (G == H)) (?[ u ] F => (G == H)) Γ (inf-V (lem9 (?[ u ] F) (sub (ι u F) F) (G == H)) (ax-11-s {_} {_} {_} {F}))) (sound-==-elim Γ (sub (ι u F) F) t G H p) sound-==-elim Γ .(?'[ u ] F) t G H (?'-E {u} {F} p) = inf-V (traverse-hypos ((F · ι' u F) => (G == H)) (?'[ u ] F => (G == H)) Γ (inf-V (lem9 (?'[ u ] F) (F · ι' u F) (G == H)) (ax-11-s2 F))) (sound-==-elim Γ (F · ι' u F) t G H p) sound-==-elim Γ .(F ((^[ u ] G') · H')) t G H (reduce {u} {v} {F} {G'} {H'} p) = inf-V (traverse-hypos (F (sub H' G') => (G == H)) (F ((^[ u ] G') · H') => (G == H)) Γ (inf-V (lem9 (F ((^[ u ] G') · H')) (F (sub H' G')) (G == H)) (inf-II-samectx (λ x → (F x)) G' H'))) (sound-==-elim Γ (F (sub H' G')) t G H p) sound-==-elim Γ .(F == G) t H I (r-bool-ext {F} {G} p) = inf-V (traverse-hypos (((F => G) & (G => F)) => (H == I)) ((F == G) => (H == I)) Γ (inf-V (lem9 (F == G) ((F => G) & (G => F)) (H == I)) (inf-V (lem2 (F == G) (F => G) (G => F)) (inf-V (inf-V (lemb1 ((F == G) => (F => G)) ((F == G) => (G => F))) (inf-V ax-3-s (inf-V (inf-V ax-4-s (inf-V (lem5 (F == G) (G == F)) (lem15 F G))) (inf-V ax-3-s (lem13 F G))))) (lem13 G F))))) (sound-==-elim Γ ((F => G) & (G => F)) t H I p) sound-==-elim Γ .(F == G) t H I (r-fun-ext {u} {v} {F} {G} J p) = inf-V (traverse-hypos (((F · J) == (G · J)) => (H == I)) ((F == G) => (H == I)) Γ (inf-V (lem9 (F == G) ((F · J) == (G · J)) (H == I)) (inf-V (inf-V (lem4 (F == G) (J == J) ((F · J) == (G · J))) (lem16 F G J J)) (lem12 J)))) (sound-==-elim Γ ((F · J) == (G · J)) t H I p) sound-top : {n : ℕ} (F : Form {n} ε $o) → ε ⊢ F → ⊢ F sound-top = sound ε
{ "alphanum_fraction": 0.4554512516, "avg_line_length": 121.44, "ext": "agda", "hexsha": "9f2bb374843069b82491d1291a4e0b4c594a52a3", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-15T11:51:19.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-17T20:28:10.000Z", "max_forks_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "frelindb/agsyHOL", "max_forks_repo_path": "soundness/Soundness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "frelindb/agsyHOL", "max_issues_repo_path": "soundness/Soundness.agda", "max_line_length": 590, "max_stars_count": 17, "max_stars_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "frelindb/agsyHOL", "max_stars_repo_path": "soundness/Soundness.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-19T20:53:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-04T14:38:28.000Z", "num_tokens": 5726, "size": 12144 }
{-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.polarity:10 #-} module Issue44 where data Ty : Set where ι : Ty _⇒_ : Ty -> Ty -> Ty data Con : Set where ε : Con _<_ : Con -> Ty -> Con data Var : Con -> Ty -> Set where vZ : forall {Γ σ} -> Var (Γ < σ) σ vS : forall {Γ σ}{τ : Ty} -> Var Γ σ -> Var (Γ < τ) σ {- stren : forall {Γ σ} -> Var Γ σ -> Con stren (vZ {Γ}) = Γ stren (vS {τ = τ} v) = stren v < τ _/_ : forall Γ {σ} -> Var Γ σ -> Con Γ / v = stren v -} -- However if I make stren a local function: _/_ : forall Γ {σ} -> Var Γ σ -> Con Γ / v = stren v where stren : forall {Γ σ} -> Var Γ σ -> Con stren (vZ {Γ}) = Γ stren (vS {τ = τ} v) = stren v < τ thin : forall {Γ σ τ}(v : Var Γ σ) -> Var (Γ / v) τ -> Var Γ τ thin vZ v' = vS v' thin (vS v) vZ = vZ thin (vS v) (vS v') = vS (thin v v')
{ "alphanum_fraction": 0.5126964933, "avg_line_length": 21.7631578947, "ext": "agda", "hexsha": "d1345972aca5222273349cc82fd57c1e6f4774d0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue44.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue44.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue44.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 351, "size": 827 }
open import Agda.Builtin.Nat open import Agda.Builtin.FromNat open import Data.Unit using (⊤) open import Function using (const) module Data.Nat.FromNat where instance NumberNat : Number Nat NumberNat = record { Constraint = const ⊤ ; fromNat = λ n → n }
{ "alphanum_fraction": 0.7432950192, "avg_line_length": 23.7272727273, "ext": "agda", "hexsha": "392fa60e7c95956e61144a43ab79c261e8437dfa", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "pepijnkokke/nodcap", "max_forks_repo_path": "src/cpnd1/Data/Nat/FromNat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "pepijnkokke/nodcap", "max_issues_repo_path": "src/cpnd1/Data/Nat/FromNat.agda", "max_line_length": 65, "max_stars_count": 4, "max_stars_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/nodcap", "max_stars_repo_path": "src/cpnd1/Data/Nat/FromNat.agda", "max_stars_repo_stars_event_max_datetime": "2019-09-24T20:16:35.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-05T08:58:11.000Z", "num_tokens": 72, "size": 261 }
module _ where open import Agda.Builtin.IO open import Agda.Builtin.String open import Agda.Builtin.Unit data D (A : Set) : Set where L : A → D A R : A → D A data T : Set where Var : (s : D String) → T test : T → String test (Var (L "abc")) = "" test (Var (L s)) = "" test (Var (R s)) = ""
{ "alphanum_fraction": 0.5880398671, "avg_line_length": 15.8421052632, "ext": "agda", "hexsha": "38bc22caa15419d21060b8c2d87b8d27d0d4ab04", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue2953.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue2953.agda", "max_line_length": 31, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2953.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 108, "size": 301 }
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open import Data.Nat using (ℕ; zero; suc) open import Relation.Nullary using (Dec; yes; no) data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n _≤?_ : ∀ (m n : ℕ) → Dec (m ≤ n) zero ≤? n = yes z≤n suc m ≤? zero = no λ() suc m ≤? suc n with m ≤? n ... | yes m≤n = yes (s≤s m≤n) ... | no ¬m≤n = no λ{ (s≤s m≤n) → ¬m≤n m≤n } _ : 2 ≤? 4 ≡ yes (s≤s (s≤s z≤n)) _ = refl _ : 4 ≤? 2 ≡ no {!!} _ = refl {- Using ^C ^N, the term 4 ≤? 2 evaluates to no (λ { (s≤s m≤n) → (λ { (s≤s m≤n) → (λ ()) 1 m≤n }) m≤n }) The 1 is spurious. -}
{ "alphanum_fraction": 0.4984802432, "avg_line_length": 21.9333333333, "ext": "agda", "hexsha": "9160fe4dc46f708081c3128f8be0187430390de3", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/DecidableBroken.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/DecidableBroken.agda", "max_line_length": 61, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/DecidableBroken.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 330, "size": 658 }
module Matrix where open import Data.Nat open import Data.Vec Matrix : (A : Set) → ℕ → ℕ → Set Matrix A m n = Vec (Vec A m) n transpose : ∀ {A m n} → Matrix A m n → Matrix A n m transpose [] = replicate [] transpose (xs ∷ xss) = zipWith _∷_ xs (transpose xss) a = (1 ∷ 2 ∷ 3 ∷ []) ∷ (4 ∷ 5 ∷ 6 ∷ []) ∷ [] b = transpose a
{ "alphanum_fraction": 0.5753846154, "avg_line_length": 21.6666666667, "ext": "agda", "hexsha": "0d86e59df63200ebaa6b07ee0cd76954933601b9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": [ "Info-ZIP" ], "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_path": "Task/Matrix-transposition/Agda/matrix-transposition-1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Info-ZIP" ], "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_path": "Task/Matrix-transposition/Agda/matrix-transposition-1.agda", "max_line_length": 53, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": [ "Info-ZIP" ], "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_path": "Task/Matrix-transposition/Agda/matrix-transposition-1.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "num_tokens": 126, "size": 325 }
-- Andreas, 2015-07-01, Issue 1599: -- abstract data needs to be positivity checked! -- {-# OPTIONS -v tc.pos:80 #-} data ⊥ : Set where abstract T : Set → Set T X = X → ⊥ data D : Set where lam : T D → D app : D → D → ⊥ app (lam f) = f omega : D omega = lam λ x → app x x Omega : ⊥ Omega = app omega omega absurd : ⊥ absurd = Omega
{ "alphanum_fraction": 0.5509641873, "avg_line_length": 13.4444444444, "ext": "agda", "hexsha": "445e385e62220ae736ceeaad9bab81ec8f9ec889", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/PositivityAbstract.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/PositivityAbstract.agda", "max_line_length": 48, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/PositivityAbstract.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 135, "size": 363 }
-- submitted by Nisse, 2011-06-21 -- {-# OPTIONS -v tc.lhs.unify:15 --show-implicit #-} module Issue423 where -- import Common.Level ------------------------------------------------------------------------ -- Prelude data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ curry : {A C : Set} {B : A → Set} → (Σ A B → C) → ((x : A) → B x → C) curry f x y = f (x , y) uncurry : {A C : Set} {B : A → Set} → ((x : A) → (y : B x) → C) → (Σ A B → C) uncurry f (x , y) = f x y ------------------------------------------------------------------------ -- Preliminaries postulate U : Set El : U → Set mutual data Ctxt : Set where _▻_ : (Γ : Ctxt) (σ : Type Γ) → Ctxt Type : Ctxt → Set Type Γ = Env Γ → U Env : Ctxt → Set Env (Γ ▻ σ) = Σ (Env Γ) λ γ → El (σ γ) postulate Γ : Ctxt σ : Type Γ ------------------------------------------------------------------------ -- Problem -- The following equalites hold definitionally. curry∘uncurry : (τ : (γ : Env Γ) → El (σ γ) → U) → curry (uncurry τ) ≡ τ curry∘uncurry τ = refl uncurry∘curry : (τ : Env (Γ ▻ σ) → U) → uncurry (curry τ) ≡ τ uncurry∘curry τ = refl -- Bug was: -- However, the two sides of curry∘uncurry behave differently. works : (τ₁ τ₂ : (γ : Env Γ) → El (σ γ) → U) → τ₁ ≡ τ₂ → Set₁ works τ .τ refl = Set works′ : (τ₁ τ₂ : (γ : Env Γ) → El (σ γ) → U) → curry (uncurry τ₁) ≡ τ₂ → Set₁ works′ τ .τ refl = Set fails : (τ₁ τ₂ : (γ : Env Γ) → El (σ γ) → U) → τ₁ ≡ curry (uncurry τ₂) → Set₁ fails τ .τ refl = Set fails′ : (τ₁ τ₂ : (γ : Env Γ) → El (σ γ) → U) → curry (uncurry τ₁) ≡ curry (uncurry τ₂) → Set₁ fails′ τ .τ refl = Set -- Bug was: -- I find it interesting that works′ works, whereas the symmetric -- variant fails fails.
{ "alphanum_fraction": 0.4639874739, "avg_line_length": 21.7727272727, "ext": "agda", "hexsha": "9e2a49b9ef0b6fdbcead462c31547f4d46b718c9", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue423.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue423.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue423.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 694, "size": 1916 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Relation.Nullary.Decidable.Base where open import Level open import Data.Bool open import Data.Empty data Reflects {a} (A : Type a) : Bool → Type a where ofʸ : (p : A) → Reflects A true ofⁿ : (¬p : ¬ A) → Reflects A false record Dec {a} (A : Type a) : Type a where constructor _because_ field does : Bool why : Reflects A does open Dec public pattern yes p = true because ofʸ p pattern no ¬p = false because ofⁿ ¬p map-reflects : ∀ {d} → (A → B) → (¬ A → ¬ B) → Reflects A d → Reflects B d map-reflects to fro (ofʸ p) = ofʸ (to p) map-reflects to fro (ofⁿ ¬p) = ofⁿ (fro ¬p) map-dec : (A → B) → (¬ A → ¬ B) → Dec A → Dec B map-dec to fro dec .does = dec .does map-dec to fro dec .why = map-reflects to fro (dec .why) ⟦yes_,no_⟧ : (A → B) → (B → A) → Dec A → Dec B ⟦yes to ,no fro ⟧ = map-dec to λ ¬A ¬B → ¬A (fro ¬B) ∣_∣yes⇒_∣no⇒_ : Dec A → (A → B) → (¬ A → ¬ B) → Dec B ∣ d ∣yes⇒ y ∣no⇒ n = map-dec y n d
{ "alphanum_fraction": 0.5841584158, "avg_line_length": 28.0555555556, "ext": "agda", "hexsha": "0c20ab0f85f392fa5b7b5e1442f7151de8326bda", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Relation/Nullary/Decidable/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Relation/Nullary/Decidable/Base.agda", "max_line_length": 74, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Relation/Nullary/Decidable/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 419, "size": 1010 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Numbers.Naturals.Definition open import Numbers.Naturals.Order open import Numbers.Naturals.Naturals -- for length open import Lists.Lists open import Orders.Partial.Definition open import Orders.Total.Definition open import Functions.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Groups.FinitePermutations open import Boolean.Definition module Lists.SortList where isSorted : {a b : _} {A : Set a} (ord : TotalOrder A) (l : List A) → Set (a ⊔ b) isSorted ord [] = True' isSorted ord (x :: []) = True' isSorted ord (x :: (y :: l)) = (TotalOrder._≤_ ord x y) && (isSorted ord (y :: l)) sortedTailIsSorted : {a b : _} {A : Set a} (ord : TotalOrder A) → (x : A) → (l : List A) → (isSorted ord (x :: l)) → isSorted ord l sortedTailIsSorted ord x [] pr = record {} sortedTailIsSorted ord x (y :: l) (fst ,, snd) = snd insert : {a b : _} {A : Set a} (ord : TotalOrder A) → (l : List A) → (isSorted ord l) → (x : A) → List A insert ord [] pr x = [ x ] insert ord (y :: l) pr x with TotalOrder.totality ord x y insert ord (y :: l) pr x | inl (inl x<y) = x :: (y :: l) insert ord (y :: l) pr x | inl (inr y<x) = y :: insert ord l (sortedTailIsSorted ord y l pr) x insert ord (y :: l) pr x | inr x=y = x :: (y :: l) insertionIncreasesLength : {a b : _} {A : Set a} (ord : TotalOrder A) → (l : List A) → (x : A) → (pr : isSorted ord l) → length (insert ord l pr x) ≡ succ (length l) insertionIncreasesLength ord [] x pr = refl insertionIncreasesLength ord (y :: l) x pr with TotalOrder.totality ord x y insertionIncreasesLength ord (y :: l) x pr | inl (inl x<y) = refl insertionIncreasesLength ord (y :: l) x pr | inl (inr y<x) = applyEquality succ (insertionIncreasesLength ord l x (sortedTailIsSorted ord y l pr)) insertionIncreasesLength ord (y :: l) x pr | inr x=y = refl isEmpty : {a : _} {A : Set a} (l : List A) → Bool isEmpty [] = BoolTrue isEmpty (x :: l) = BoolFalse minList : {a b : _} {A : Set a} (ord : TotalOrder A) → (l : List A) → (isEmpty l ≡ BoolFalse) → A minList ord [] () minList ord (x :: []) pr = x minList ord (x :: (y :: l)) refl with minList ord (y :: l) refl minList ord (x :: (y :: l)) refl | minSoFar with TotalOrder.totality ord x minSoFar minList ord (x :: (y :: l)) refl | minSoFar | inl (inl x<m) = x minList ord (x :: (y :: l)) refl | minSoFar | inl (inr m<x) = minSoFar minList ord (x :: (y :: l)) refl | minSoFar | inr x=m = x insertionSorts : {a b : _} {A : Set a} (ord : TotalOrder A) → (l : List A) → (pr : isSorted ord l) → (x : A) → isSorted ord (insert ord l pr x) insertionSorts ord [] _ _ = record {} insertionSorts ord (y :: l) pr x with TotalOrder.totality ord x y insertionSorts ord (y :: l) pr x | inl (inl x<y) = inl x<y ,, pr insertionSorts ord (y :: l) pr x | inl (inr y<x) with insertionSorts ord l (sortedTailIsSorted ord y l pr) x ... | bl = {!!} insertionSorts ord (y :: l) pr x | inr x=y = inr x=y ,, pr orderNotLessThanAndEqual : {a b : _} {A : Set a} (ord : TotalOrder A) → {x y : A} → (x ≡ y) → TotalOrder._<_ ord x y → False orderNotLessThanAndEqual ord {x} {y} x=y x<y rewrite x=y = PartialOrder.irreflexive (TotalOrder.order ord) x<y orderToDecidableEquality : {a b : _} {A : Set a} (ord : TotalOrder A) → {x y : A} → (x ≡ y) || ((x ≡ y) → False) orderToDecidableEquality ord {x} {y} with TotalOrder.totality ord x y orderToDecidableEquality ord {x} {y} | inl (inl x<y) = inr λ x=y → orderNotLessThanAndEqual ord x=y x<y orderToDecidableEquality ord {x} {y} | inl (inr y<x) = inr λ x=y → orderNotLessThanAndEqual ord (equalityCommutative x=y) y<x orderToDecidableEquality ord {x} {y} | inr x=y = inl x=y --SortingAlgorithm : {a b : _} → Set (lsuc a ⊔ lsuc b) --SortingAlgorithm {a} {b} = {A : Set a} → (ord : TotalOrder {a} {b} A) → (input : List A) → Sg (List A) (λ l → isSorted ord l && isPermutation (orderToDecidableEquality ord) l input) insertionSort : {a b : _} {A : Set a} (ord : TotalOrder A) (l : List A) → List A insertionSortIsSorted : {a b : _} {A : Set a} (ord : TotalOrder A) (l : List A) → isSorted ord (insertionSort ord l) insertionSort ord [] = [] insertionSort ord (x :: l) = insert ord (insertionSort ord l) (insertionSortIsSorted ord l) x insertionSortIsSorted ord [] = record {} insertionSortIsSorted ord (x :: l) = insertionSorts ord (insertionSort ord l) (insertionSortIsSorted ord l) x insertionSortLength : {a b : _} {A : Set a} (ord : TotalOrder A) (l : List A) → length l ≡ length (insertionSort ord l) insertionSortLength ord [] = refl insertionSortLength ord (x :: l) rewrite insertionIncreasesLength ord (insertionSort ord l) x (insertionSortIsSorted ord l) = {!!} --applyEquality succ (insertionSortLength ord l) isPermutation : {a b : _} {A : Set a} (ord : TotalOrder A) → (l m : List A) → Set a isPermutation ord l m = insertionSort ord l ≡ insertionSort ord m --insertionSort : {a b : _} → SortingAlgorithm {a} {b} --insertionSort {A = A} ord l = {!!} -- where -- lemma : Sg (List A) (isSorted ord) → (x : A) → Sg (List A) (isSorted ord) -- lemma (l , b) x = insert ord l b x , insertionSorts ord l b x --InsertionSort : {a b : _} → SortingAlgorithm {a} {b} --InsertionSort ord l = insertionSort ord l lexicographicOrderRel : {a b : _} {A : Set a} → (TotalOrder A) → Rel {a} {a ⊔ b} (List A) lexicographicOrderRel _ [] [] = False' lexicographicOrderRel _ [] (x :: l2) = True' lexicographicOrderRel _ (x :: l1) [] = False' lexicographicOrderRel order (x :: l1) (y :: l2) = (TotalOrder._<_ order x y) || ((x ≡ y) && lexicographicOrderRel order l1 l2) lexIrrefl : {a b : _} {A : Set a} (o : TotalOrder A) → {x : List A} → lexicographicOrderRel o x x → False lexIrrefl o {[]} () lexIrrefl o {x :: l} (inl x<x) = PartialOrder.irreflexive (TotalOrder.order o) x<x lexIrrefl o {x :: l} (inr (pr ,, l=l)) = lexIrrefl o {l} l=l lexTransitive : {a b : _} {A : Set a} (o : TotalOrder A) → {x y z : List A} → lexicographicOrderRel o x y → lexicographicOrderRel o y z → lexicographicOrderRel o x z lexTransitive o {[]} {[]} {z} x<y y<z = y<z lexTransitive o {[]} {x :: y} {[]} record {} y<z = y<z lexTransitive o {[]} {x :: y} {x₁ :: z} record {} y<z = record {} lexTransitive o {x :: xs} {[]} {z} () y<z lexTransitive o {x :: xs} {y :: ys} {[]} (inl x<y) () lexTransitive o {x :: xs} {y :: ys} {z :: zs} (inl x<y) (inl y<z) = inl (PartialOrder.<Transitive (TotalOrder.order o) x<y y<z) lexTransitive o {x :: xs} {y :: ys} {.y :: zs} (inl x<y) (inr (refl ,, ys<zs)) = inl x<y lexTransitive o {x :: xs} {.x :: ys} {[]} (inr (refl ,, xs<ys)) () lexTransitive o {x :: xs} {.x :: ys} {z :: zs} (inr (refl ,, xs<ys)) (inl y<z) = inl y<z lexTransitive o {x :: xs} {.x :: ys} {.x :: zs} (inr (refl ,, xs<ys)) (inr (refl ,, u)) = inr (refl ,, lexTransitive o xs<ys u) lexTotal : {a b : _} {A : Set a} (o : TotalOrder A) → (x y : List A) → ((lexicographicOrderRel o x y) || (lexicographicOrderRel o y x)) || (x ≡ y) lexTotal o [] [] = inr refl lexTotal o [] (x :: y) = inl (inl (record {})) lexTotal o (x :: xs) [] = inl (inr (record {})) lexTotal o (x :: xs) (y :: ys) with TotalOrder.totality o x y lexTotal o (x :: xs) (y :: ys) | inl (inl x<y) = inl (inl (inl x<y)) lexTotal o (x :: xs) (y :: ys) | inl (inr y<x) = inl (inr (inl y<x)) lexTotal o (x :: xs) (y :: ys) | inr x=y with lexTotal o xs ys lexTotal o (x :: xs) (y :: ys) | inr x=y | inl (inl xs<ys) = inl (inl (inr (x=y ,, xs<ys))) lexTotal o (x :: xs) (y :: ys) | inr x=y | inl (inr ys<xs) = inl (inr (inr (equalityCommutative x=y ,, ys<xs))) lexTotal o (x :: xs) (y :: ys) | inr x=y | inr xs=ys rewrite x=y | xs=ys = inr refl lexicographicOrder : {a b : _} {A : Set a} → (TotalOrder A) → TotalOrder (List A) PartialOrder._<_ (TotalOrder.order (lexicographicOrder order)) = lexicographicOrderRel order PartialOrder.irreflexive (TotalOrder.order (lexicographicOrder order)) = lexIrrefl order PartialOrder.<Transitive (TotalOrder.order (lexicographicOrder order)) = lexTransitive order TotalOrder.totality (lexicographicOrder order) = lexTotal order badSort : {a b : _} {A : Set a} (order : TotalOrder A) → ℕ → List A → List A badSortLength : {a b : _} {A : Set a} (order : TotalOrder A) → (n : ℕ) → (l : List A) → length (badSort order n l) ≡ length l allTrueRespectsBadsort : {a b c : _} {A : Set a} (order : TotalOrder A) → (n : ℕ) → (l : List A) → (pred : A → Set c) → allTrue pred l → allTrue pred (badSort order n l) badSort order zero = insertionSort order badSort order (succ n) [] = [] badSort {A = A} order (succ n) (x :: l) = head (badSort (lexicographicOrder order) n (permutations (x :: l))) bsNonempty where bs : List (List A) bs = badSort (lexicographicOrder order) n (permutations (x :: l)) bsNonempty : 0 <N length bs bsNonempty with bs bsNonempty | [] = {!!} bsNonempty | bl :: _ = succIsPositive _ allTrueRespectsBadsort order n [] pred record {} = {!!} allTrueRespectsBadsort order n (x :: l) pred (fst ,, snd) = {!!} badSortLength order zero [] = refl badSortLength order zero (x :: l) = transitivity (insertionIncreasesLength order (insertionSort order l) x (insertionSortIsSorted order l)) (applyEquality succ (equalityCommutative (insertionSortLength order l))) badSortLength order (succ n) [] = refl badSortLength order (succ n) (x :: l) = {!!} where allLen : allTrue (λ i → length i ≡ succ (length l)) (badSort (lexicographicOrder order) n (flatten (map (allInsertions x) (permutations l)))) allLen = {!!} -- TODO: show that insertion sort actually produces a permutation
{ "alphanum_fraction": 0.6197644649, "avg_line_length": 59.9079754601, "ext": "agda", "hexsha": "d65b2e54b30f599680b270304770ad3324771d2b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Lists/SortList.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Lists/SortList.agda", "max_line_length": 214, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Lists/SortList.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 3495, "size": 9765 }
-- Andreas, 2017-11-12, issue #2803 -- Problem: names of hidden variable patterns -- can get lost during case splitting. -- They actually get lost already during lhs type checking, -- but it is noticed only when printed back to the user -- during case splitting. -- {-# OPTIONS -v tc.lhs:40 #-} record HFun (A B : Set) : Set where field apply : {a : A} → B postulate A : Set test : HFun A (A → A) HFun.apply test {β} = {!!} -- C-c C-c -- YIELDS: -- HFun.apply test {a} x = ? -- EXPECTED: -- HFun.apply test {β} x = ?
{ "alphanum_fraction": 0.6337760911, "avg_line_length": 21.08, "ext": "agda", "hexsha": "18cd5779a5b14b1846a7202d3379de355baacbc1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/interaction/Issue2803.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/eagda", "max_issues_repo_path": "test/interaction/Issue2803.agda", "max_line_length": 59, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/interaction/Issue2803.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 161, "size": 527 }
{-# OPTIONS --injective-type-constructors #-} module InjectiveTypeConstructors where data D (A : Set) : Set where data _==_ (A : Set) : Set → Set where refl : A == A D' = D injD : ∀ {A B} → D A == D' B → A == B injD refl = refl
{ "alphanum_fraction": 0.5872340426, "avg_line_length": 16.7857142857, "ext": "agda", "hexsha": "8f001b68e6846adf85b916abd2d607d35dbe9e1e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/InjectiveTypeConstructors.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/InjectiveTypeConstructors.agda", "max_line_length": 45, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/InjectiveTypeConstructors.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 84, "size": 235 }
------------------------------------------------------------------------ -- A quotient inductive-inductive definition of the lifting -- construction on ω-cpos ------------------------------------------------------------------------ -- The code in this module is based on a suggestion from Paolo -- Capriotti. {-# OPTIONS --erased-cubical --safe #-} open import Omega-cpo module Lifting {ℓ} (cpo : ω-cpo ℓ ℓ) where import Equality.Path as P open import Equality.Propositional.Cubical open import Logical-equivalence using (_⇔_) open import Prelude hiding (⊥) open import Bijection equality-with-J using (_↔_) open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J hiding (_∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J private module CPO = ω-cpo cpo ------------------------------------------------------------------------ -- An ω-cppo -- The carrier type (Carrier) and the information ordering (_⊑_) are -- defined simultaneously. infix 4 _⊑_ _⊒_ data Carrier : Type ℓ data _⊑_ : Carrier → Carrier → Type ℓ _⊒_ : Carrier → Carrier → Type ℓ x ⊒ y = y ⊑ x private variable x y : Carrier -- Increasing sequences. Increasing-sequence : Type ℓ Increasing-sequence = ∃ λ (f : ℕ → Carrier) → ∀ n → f n ⊑ f (suc n) -- Projection functions for Increasing-sequence. infix 30 _[_] _[_] : Increasing-sequence → ℕ → Carrier _[_] = proj₁ increasing : (s : Increasing-sequence) → ∀ n → s [ n ] ⊑ s [ suc n ] increasing = proj₂ -- Upper bounds. Is-upper-bound : Increasing-sequence → Carrier → Type ℓ Is-upper-bound s x = ∀ n → s [ n ] ⊑ x -- Originally these types were postulated. After the release of -- Cubical Agda they were turned into a QIIT, but in order to not get -- any extra computation rules they were made abstract. abstract -- _⊥ "constructors". data Carrier where never′ : Carrier now′ : CPO.Carrier → Carrier ⨆′ : Increasing-sequence → Carrier antisymmetry′ : x ⊑ y → x ⊒ y → x P.≡ y -- We have chosen to explicitly make the type set-truncated. -- However, this constructor is only used in the definition of the -- eliminator below. ≡-propositional′ : P.Is-set Carrier -- _⊑_ "constructors". data _⊑_ where ⊑-refl′ : ∀ x → x ⊑ x ⊑-trans′ : ∀ x y z → x ⊑ y → y ⊑ z → x ⊑ z never⊑′ : ∀ x → never′ ⊑ x upper-bound′ : ∀ s → Is-upper-bound s (⨆′ s) least-upper-bound′ : ∀ s ub → Is-upper-bound s ub → ⨆′ s ⊑ ub now-mono′ : ∀ {x y} → x CPO.⊑ y → now′ x ⊑ now′ y now-⨆″ : ∀ s → now′ (CPO.⨆ s) ⊑ ⨆′ (Σ-map (now′ ∘_) (now-mono′ ∘_) s) ⊑-propositional′ : ∀ {x y} → P.Is-proposition (x ⊑ y) never : Carrier never = never′ now : CPO.Carrier → Carrier now = now′ ⨆ : Increasing-sequence → Carrier ⨆ = ⨆′ antisymmetry : x ⊑ y → y ⊑ x → x ≡ y antisymmetry = λ p q → _↔_.from ≡↔≡ (antisymmetry′ p q) ⊑-refl : ∀ x → x ⊑ x ⊑-refl = ⊑-refl′ ⊑-trans : ∀ x y z → x ⊑ y → y ⊑ z → x ⊑ z ⊑-trans = ⊑-trans′ never⊑ : ∀ x → never ⊑ x never⊑ = never⊑′ upper-bound : ∀ s → Is-upper-bound s (⨆ s) upper-bound = upper-bound′ least-upper-bound : ∀ s ub → Is-upper-bound s ub → ⨆ s ⊑ ub least-upper-bound = least-upper-bound′ now-mono : ∀ {x y} → x CPO.⊑ y → now x ⊑ now y now-mono = now-mono′ now-⨆′ : ∀ s → now (CPO.⨆ s) ⊑ ⨆ (Σ-map (now ∘_) (now-mono ∘_) s) now-⨆′ = now-⨆″ ⊑-propositional : ∀ {x y} → Is-proposition (x ⊑ y) ⊑-propositional {x = x} {y = y} = $⟨ ⊑-propositional′ ⟩ P.Is-proposition (x ⊑ y) ↝⟨ _↔_.from (H-level↔H-level 1) ⟩□ Is-proposition (x ⊑ y) □ -- The construction above is an ω-cppo. cppo : ω-cppo ℓ ℓ cppo = record { cpo = record { Carrier = Carrier ; _⊑_ = _⊑_ ; reflexivity = ⊑-refl _ ; antisymmetry = antisymmetry ; transitivity = ⊑-trans _ _ _ ; ⊑-propositional = ⊑-propositional ; ⨆ = ⨆ ; upper-bound = upper-bound ; least-upper-bound = least-upper-bound _ _ } ; least = never ; least⊑ = never⊑ _ } ------------------------------------------------------------------------ -- Dependent eliminators -- Predicate transformer related to increasing sequences. Inc : ∀ {p q} (P : Carrier → Type p) (Q : ∀ {x y} → P x → P y → x ⊑ y → Type q) → Increasing-sequence → Type (p ⊔ q) Inc P Q s = ∃ λ (p : ∀ n → P (s [ n ])) → ∀ n → Q (p n) (p (suc n)) (increasing s n) -- Record wrapping up the eliminators' arguments. record Rec-args {p q} (P : Carrier → Type p) (Q : ∀ {x y} → P x → P y → x ⊑ y → Type q) : Type (ℓ ⊔ p ⊔ q) where field pe : P never po : ∀ x → P (now x) pl : ∀ s (pq : Inc P Q s) → P (⨆ s) pa : ∀ {x y} (x⊑y : x ⊑ y) (x⊒y : x ⊒ y) (p-x : P x) (p-y : P y) (q-x⊑y : Q p-x p-y x⊑y) (q-x⊒y : Q p-y p-x x⊒y) → subst P (antisymmetry x⊑y x⊒y) p-x ≡ p-y pp : ∀ {x} {p₁ p₂ : P x} → Is-proposition (p₁ ≡ p₂) qr : ∀ x (p : P x) → Q p p (⊑-refl x) qt : ∀ {x y z} (x⊑y : x ⊑ y) (y⊑z : y ⊑ z) (p-x : P x) (p-y : P y) (p-z : P z) → Q p-x p-y x⊑y → Q p-y p-z y⊑z → Q p-x p-z (⊑-trans x y z x⊑y y⊑z) qe : ∀ x (p : P x) → Q pe p (never⊑ x) qu : ∀ s (pq : Inc P Q s) n → Q (proj₁ pq n) (pl s pq) (upper-bound s n) ql : ∀ s ub is-ub (pq : Inc P Q s) (pu : P ub) (qu : ∀ n → Q (proj₁ pq n) pu (is-ub n)) → Q (pl s pq) pu (least-upper-bound s ub is-ub) qm : ∀ {x y} (le : x CPO.⊑ y) → Q (po x) (po y) (now-mono le) q⨆ : ∀ s → Q (po (CPO.⨆ s)) (pl (Σ-map (now ∘_) (now-mono ∘_) s) ( (λ n → po (s CPO.[ n ])) , (λ n → qm (CPO.increasing s n)) )) (now-⨆′ s) qp : ∀ {x y} (p-x : P x) (p-y : P y) (x⊑y : x ⊑ y) → Is-proposition (Q p-x p-y x⊑y) -- The eliminators. module _ {p q} {P : Carrier → Type p} {Q : ∀ {x y} → P x → P y → x ⊑ y → Type q} (args : Rec-args P Q) where open Rec-args args mutual inc-rec : (s : Increasing-sequence) → Inc P Q s inc-rec (s , inc) = (λ n → ⊥-rec (s n)) , (λ n → ⊑-rec (inc n)) abstract ⊥-rec : (x : Carrier) → P x ⊥-rec never′ = pe ⊥-rec (now′ x) = po x ⊥-rec (⨆′ s) = pl s (inc-rec s) ⊥-rec (antisymmetry′ {x = x} {y = y} p q i) = subst≡→[]≡ {B = P} {eq = antisymmetry′ p q} (pa p q (⊥-rec x) (⊥-rec y) (⊑-rec p) (⊑-rec q)) i ⊥-rec (≡-propositional′ {x = x} {y = y} p q i j) = lemma i j where ≡-propositional : P.Is-set Carrier ≡-propositional = ≡-propositional′ lemma : P.[ (λ i → P.[ (λ j → P (≡-propositional p q i j)) ] ⊥-rec x ≡ ⊥-rec y) ] (λ i → ⊥-rec (p i)) ≡ (λ i → ⊥-rec (q i)) lemma = P.heterogeneous-UIP (λ x → _↔_.to (H-level↔H-level 2) (pp {x = x})) (≡-propositional′ p q) _ _ ⊑-rec : (x⊑y : x ⊑ y) → Q (⊥-rec x) (⊥-rec y) x⊑y ⊑-rec (⊑-refl′ x) = qr x (⊥-rec x) ⊑-rec (⊑-trans′ x y z p q) = qt p q (⊥-rec x) (⊥-rec y) (⊥-rec z) (⊑-rec p) (⊑-rec q) ⊑-rec (never⊑′ x) = qe x (⊥-rec x) ⊑-rec (upper-bound′ s n) = qu s (inc-rec s) n ⊑-rec (least-upper-bound′ s ub is-ub) = ql s ub is-ub (inc-rec s) (⊥-rec ub) (λ n → ⊑-rec {x = proj₁ s n} (is-ub n)) ⊑-rec (now-mono′ x) = qm x ⊑-rec (now-⨆″ s) = q⨆ s ⊑-rec (⊑-propositional′ {x = x} {y = y} p q i) = lemma i where ⊑-propositional″ : ∀ {x y} → P.Is-proposition (x ⊑ y) ⊑-propositional″ = ⊑-propositional′ lemma : P.[ (λ i → Q (⊥-rec x) (⊥-rec y) (⊑-propositional″ p q i)) ] ⊑-rec p ≡ ⊑-rec q lemma = P.heterogeneous-irrelevance (λ p → _↔_.to (H-level↔H-level 1) (qp (⊥-rec x) (⊥-rec y) p)) -- Some computation rules. ⊥-rec-never : ⊥-rec never ≡ pe ⊥-rec-never = refl ⊥-rec-now : ∀ x → ⊥-rec (now x) ≡ po x ⊥-rec-now _ = refl ⊥-rec-⨆ : ∀ s → ⊥-rec (⨆ s) ≡ pl s (inc-rec s) ⊥-rec-⨆ _ = refl ------------------------------------------------------------------------ -- Some lemmas -- The inequality now-⨆′ can be strengthened to an equality. now-⨆ : (s : CPO.Increasing-sequence) → now (CPO.⨆ s) ≡ ⨆ (Σ-map (now ∘_) (now-mono ∘_) s) now-⨆ s = antisymmetry (now-⨆′ s) (least-upper-bound _ _ λ n → now-mono (CPO.upper-bound s n)) private -- A lemma. Carrier-is-set-and-equality-characterisation : Is-set Carrier × _ Carrier-is-set-and-equality-characterisation = Eq.propositional-identity≃≡ (λ x y → x ⊑ y × x ⊒ y) (λ _ _ → ×-closure 1 ⊑-propositional ⊑-propositional) (λ x → ⊑-refl x , ⊑-refl x) (λ x y → uncurry {B = λ _ → x ⊒ y} antisymmetry) -- Carrier is a set. (This lemma is analogous to Theorem 11.3.9 in -- "Homotopy Type Theory: Univalent Foundations of Mathematics" (first -- edition).) Carrier-is-set : Is-set Carrier Carrier-is-set = proj₁ Carrier-is-set-and-equality-characterisation -- Equality characterisation lemma for Carrier. equality-characterisation-Carrier : ∀ {x y} → (x ⊑ y × x ⊒ y) ≃ (x ≡ y) equality-characterisation-Carrier = proj₂ Carrier-is-set-and-equality-characterisation ext -- Equality characterisation lemma for increasing sequences. equality-characterisation-increasing : {s₁ s₂ : Increasing-sequence} → (∀ n → s₁ [ n ] ≡ s₂ [ n ]) ↔ s₁ ≡ s₂ equality-characterisation-increasing {s₁} {s₂} = (∀ n → s₁ [ n ] ≡ s₂ [ n ]) ↔⟨ Eq.extensionality-isomorphism ext ⟩ proj₁ s₁ ≡ proj₁ s₂ ↝⟨ ignore-propositional-component (Π-closure ext 1 λ _ → ⊑-propositional) ⟩□ s₁ ≡ s₂ □
{ "alphanum_fraction": 0.486831761, "avg_line_length": 29.325648415, "ext": "agda", "hexsha": "879b431bbe9749a15573731c09ab1a55cd3f3a2e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Lifting.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Lifting.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Lifting.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 3805, "size": 10176 }
{-# OPTIONS --without-K #-} module Explore.Subset where open import Relation.Binary.PropositionalEquality -- TODO
{ "alphanum_fraction": 0.7586206897, "avg_line_length": 16.5714285714, "ext": "agda", "hexsha": "83ffa53b1b75f429742d6135c122a7f9b7d309cb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/Subset.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/Subset.agda", "max_line_length": 49, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/Subset.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 24, "size": 116 }
{-# OPTIONS --safe #-} module Cubical.HITs.FreeAbGroup where open import Cubical.HITs.FreeAbGroup.Base public
{ "alphanum_fraction": 0.7747747748, "avg_line_length": 22.2, "ext": "agda", "hexsha": "5a71a34d3efa5baafe2ee74a8320e42c4e9e1801", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/FreeAbGroup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/FreeAbGroup.agda", "max_line_length": 48, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/FreeAbGroup.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 29, "size": 111 }
-- Inductive types -- See Chapter 15 of "Practical Foundations for Programming Languages" by Robert Harper module ITypes where open import Data.Vec open import Data.Nat open import Data.List open import Data.Fin.Base -- auxiliary data Bool : Set where True False : Bool _if_else_ : {A : Set} → A → Bool → A → A A if True else B = A A if False else B = B -- end of auxiliary {-- required later on data IType' (n : ℕ) : Set data IType' n where Unit Nat : IType' n Pair Sum : IType n → IType n → IType' n Map'[_,_]_ : ∀ {n} → Fin n → IType' n → IType n → IType' n Map'[ var , Unit ] type' = Unit Map'[ var , Nat ] type' = Nat Map'[ var , Pair x x₁ ] type' = Pair (Map[ var , x ] type') (Map[ var , x₁ ] type') Map'[ var , Sum x x₁ ] type' = Sum (Map[ var , x ] type') (Map[ var , x₁ ] type') --} data IType (n : ℕ) : Set data IType n where Unit Nat : IType n Pair Sum : IType n → IType n → IType n Ind : IType (suc n) → IType n Var : Fin n → IType n Func : IType n → IType n → IType n FinEq : ∀ {n} → Fin n → Fin n → Bool FinEq zero zero = True FinEq zero (suc b) = False FinEq (suc a) zero = False FinEq (suc a) (suc b) = FinEq a b -- Substitute type' for var in type Map[_,_]_ : ∀ {n} → Fin (suc n) → IType (suc n) → IType n → IType n Map[ var , Unit ] type' = Unit Map[ var , Nat ] type' = Nat Map[ var , Pair type type₁ ] type' = Pair (Map[ var , type ] type') (Map[ var , type₁ ] type') Map[ var , Sum type type₁ ] type' = Pair (Map[ var , type ] type') (Map[ var , type₁ ] type') Map[ var , Ind x ] type' = {!!} --Ind (Map[ var , x ] type') Map[ var , Func a b ] type' = Func (Map[ var , a ] type') (Map[ var , b ] type') Map[ var , Var x ] type' = type' if (FinEq var x) else Var {!!} -- Alternative notation [_/_]_ : ∀ {n} → IType n → Fin (suc n) → IType (suc n) → IType n [ type' / var ] type = Map[ var , type ] type' Env : ℕ → Set Env n = List (IType n) -- Environment lookup data _∈`_ {n} : IType n → Env n → Set where here : ∀ {φ A} → A ∈` (A ∷ φ) there : ∀ {φ A A'} → A ∈` φ → A ∈` (A' ∷ φ) -- Expressions data Expr {n} : Env n → IType n → Set where -- Fold : ∀ {ϕ t τ} → Expr ϕ ([ Ind τ / t ] τ) → Expr ϕ (Ind τ) -- Rec : ∀ {ϕ t τ ρ} → Expr ((Map[ t , τ ] ρ) ∷ ϕ) ρ → Expr ϕ (Ind τ) → {!!} FoldNat : ∀ {ϕ} → Expr ϕ (Sum Unit Nat) → Expr ϕ Nat RecNat : ∀ {ϕ} → Expr (Sum Unit Nat ∷ ϕ) Nat → Expr ϕ Nat → Expr ϕ Nat Var : ∀ {φ τ} → τ ∈` φ → Expr φ τ Abs : ∀ {φ τ τ'} → Expr (τ ∷ φ) τ' → Expr φ (Func τ τ') App : ∀ {φ τ τ'} → Expr φ (Func τ τ') → Expr φ τ → Expr φ τ' -- Expression substitution [_//_] : ∀ {n ϕ} {τ τ' : IType n} → Expr (τ' ∷ ϕ) τ → Expr ϕ τ' → Expr ϕ τ -- TODO data _↦_ {n ϕ} : {τ : IType n} → Expr ϕ τ → Expr ϕ τ → Set where ξ-RecNat : ∀ {e} {e' e''} → e' ↦ e'' → _↦_ {τ = Nat} (RecNat e e') (RecNat e e'') β-RecNat : ∀ {e e'} → _↦_ {τ = Nat} (RecNat e (FoldNat e')) [ e // e' ] -- IValue -- data IValue (n : ℕ) : Set where -- Interpreter -- int : ∀ {n} → IType n → Set -- int' : ∀ {n} → IType' n → Set --- int {n} (Ind it') = IValue n (int' it')
{ "alphanum_fraction": 0.5145510836, "avg_line_length": 31.9801980198, "ext": "agda", "hexsha": "0460e509ce6d2a6e2d055e298a54187a8b80e077", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_path": "src/sigmatypes/ITypes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "kcaliban/ldlc", "max_issues_repo_path": "src/sigmatypes/ITypes.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_path": "src/sigmatypes/ITypes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1241, "size": 3230 }
module Numeric.Nat.BinarySearch where open import Prelude open import Numeric.Nat.Properties open import Tactic.Nat open import Control.WellFounded open import Numeric.Nat.DivMod data SearchResult! {a} (P : Nat → Set a) (lo hi : Nat) : Set a where here : ∀ k (!pk : ¬ P k) (psk : P (suc k)) (lo≤k : lo ≤ k) (k<hi : k < hi) → SearchResult! P lo hi data SearchResult {a} (P : Nat → Set a) (lo hi : Nat) : Set a where here : ∀ k (!pk : ¬ P k) (psk : P (suc k)) (lo≤k : lo ≤ k) (k<hi : k < hi) → SearchResult P lo hi below : P lo → SearchResult P lo hi none : ¬ P hi → SearchResult P lo hi bad-range : lo > hi → SearchResult P lo hi private infixr 0 _⟨=<⟩_ _⟨<=⟩_ _⟨=<⟩_ : ∀ {a : Nat} {b c} → a ≡ b → b < c → a < c refl ⟨=<⟩ b<c = b<c _⟨<=⟩_ : ∀ {a : Nat} {b c} → a < b → b ≡ c → a < c a<b ⟨<=⟩ refl = a<b private lem-half : ∀ n → suc n div 2 < suc n lem-half n with suc n div 2 | suc n mod 2 | divmod-sound 2 (suc n) lem-half n | zero | r | eq = auto lem-half n | suc q | r | eq = by eq lem-half-nonzero : ∀ n → NonZero ((2 + n) div 2) lem-half-nonzero n with (2 + n) div 2 | (2 + n) mod 2 | divmod-sound 2 (2 + n) | mod-less 2 (2 + n) lem-half-nonzero n | zero | ._ | refl | lt = refute lt lem-half-nonzero n | suc q | r | _ | _ = _ lem-upper : ∀ {lo hi d} d′ {{_ : NonZero d′}} → hi ≡ suc (d + lo) → hi - (d′ + lo) ≤ d lem-upper zero {{}} lem-upper {d = d} (suc d′) refl = by (sub-leq d d′) search : ∀ {a} {P : Nat → Set a} lo hi d → hi ≡ d + lo → Acc _<_ d → (∀ n → Dec (P n)) → ¬ P lo → P hi → SearchResult! P lo hi search lo .lo 0 refl wf check !plo phi = ⊥-elim (!plo phi) search lo .(suc lo) 1 refl wf check !plo phi = here lo !plo phi (diff! 0) (diff! 0) search lo hi (suc (suc d₀)) eq (acc wf) check !plo phi = let d = suc d₀ d′ = suc d div 2 m = d′ + lo d′<d : d′ < suc d d′<d = lem-half d in case check m of λ { (yes pm) → case search lo m d′ refl (wf _ d′<d) check !plo pm of λ { (here k !pk psk lo≤k k<m) → here k !pk psk lo≤k $ k<m ⟨<⟩ by d′<d ⟨<=⟩ sym eq } ; (no !pm) → let m≤hi : m ≤ hi m≤hi = by d′<d ⟨≤⟩ diff 1 (cong suc eq) instance d′≠0 : NonZero d′ d′≠0 = lem-half-nonzero d₀ eq′ : hi ≡ hi - m + m eq′ = eraseEquality (sym (sub-less m≤hi)) in case search m hi (hi - m) eq′ (wf (hi - m) (lem-upper d′ eq)) check !pm phi of λ { (here k !pk psk m≤k k<hi) → here k !pk psk (auto ⟨≤⟩ m≤k) k<hi } } private unbang : ∀ {a} {P : Nat → Set a} {lo hi} → SearchResult! P lo hi → SearchResult P lo hi unbang (here k x x₁ x₂ x₃) = here k x x₁ x₂ x₃ binarySearch : ∀ {a} {P : Nat → Set a} lo hi → (∀ n → Dec (P n)) → SearchResult P lo hi binarySearch lo hi check with compare lo hi ... | greater lo>hi = bad-range lo>hi binarySearch lo .lo check | equal refl = case check lo of λ { (yes p) → below p ; (no !p) → none !p } binarySearch lo ._ check | less (diff! d) = let hi = suc d + lo in case check lo of λ { (yes p) → below p ; (no !p) → case check hi of λ { (yes p) → unbang $ search lo hi (suc d) refl (wfNat (suc d)) check !p p ; (no !p) → none !p } }
{ "alphanum_fraction": 0.5055108728, "avg_line_length": 35.3368421053, "ext": "agda", "hexsha": "fe90b7edede4e7958040082864356f2af1bfba9d", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "src/Numeric/Nat/BinarySearch.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_path": "src/Numeric/Nat/BinarySearch.agda", "max_line_length": 104, "max_stars_count": 111, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "src/Numeric/Nat/BinarySearch.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 1304, "size": 3357 }
-- Andreas, 2011-10-04 -- I'd like to infer the type of a even though it is irrelevant -- E.g. when pressing C-c C-. module InferIrrelevant where f : (A : Set)(g : .A → A).(a : A) → A f A g a = {!a!}
{ "alphanum_fraction": 0.605, "avg_line_length": 28.5714285714, "ext": "agda", "hexsha": "2650038bcb50825a48a65994f786aecca3bb7f01", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/interaction/InferIrrelevant.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/interaction/InferIrrelevant.agda", "max_line_length": 63, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/interaction/InferIrrelevant.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 74, "size": 200 }
{- Copyright 2019 Lisandra Silva Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -} open import Prelude open import Data.Vec.Bounded renaming ([] to Vec≤[]) open import Data.Vec renaming ( _++_ to _v++_ ; [_] to v[_] ; head to headV ; _∷ʳ_ to _v∷ʳ_ ; tail to vTail) open import Data.List open import StateMachineModel module Examples.ProducerConsumer {ℓ : Level} (Message : Set ℓ) -- Message type (Size : ℕ) -- Size of the bounded buffer where record State : Set (lsuc ℓ) where field buffer : Vec≤ Message Size -- The numSpaces ≅ Vec≤.length produced : List Message consumed : List Message open State data MyEvent : Set ℓ where produce : Message → MyEvent consume : Message → MyEvent data MyEnabled : MyEvent → State → Set ℓ where prodEnabled : ∀ {st : State} {msg} → Vec≤.length (buffer st) < Size → MyEnabled (produce msg) st consEnabled : ∀ {st : State} {msg} → 0 < Vec≤.length (buffer st) → msg ≡ headV {!!} → MyEnabled (consume msg) st MyAction : ∀ {preState : State} {event : MyEvent} → MyEnabled event preState → State MyAction {preSt} {produce m} (prodEnabled x) = record preSt { buffer = Vec≤.vec (buffer preSt) v∷ʳ m , x ; produced = produced preSt ++ [ m ] } MyAction {preSt} {consume m} enabled = record preSt { buffer = (vTail (Vec≤.vec {!!})) , {!!} ; produced = consumed preSt ++ [ m ] } initialState : State initialState = record { buffer = Vec≤[] ; produced = [] ; consumed = [] } MyStateMachine : StateMachine State MyEvent MyStateMachine = record { initial = λ state → state ≡ initialState ; enabled = MyEnabled ; action = MyAction } MyEventSet : EventSet {Event = MyEvent} MyEventSet (produce x) = ⊥ MyEventSet (consume x) = ⊤ data MyWeakFairness : EventSet → Set ℓ where wf : MyWeakFairness MyEventSet MySystem : System State MyEvent MySystem = record { stateMachine = MyStateMachine ; weakFairness = MyWeakFairness }
{ "alphanum_fraction": 0.5683673469, "avg_line_length": 27.7358490566, "ext": "agda", "hexsha": "27ae40f58b48d086e31f52c2aa943d82f8a1c829", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "lisandrasilva/agda-liveness", "max_forks_repo_path": "src/Examples/ProducerConsumer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "lisandrasilva/agda-liveness", "max_issues_repo_path": "src/Examples/ProducerConsumer.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "lisandrasilva/agda-liveness", "max_stars_repo_path": "src/Examples/ProducerConsumer.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 749, "size": 2940 }
module LecSigma where open import CS410-Prelude open import CS410-Nat open import CS410-Functor -- look in the Prelude -- talk about * -- talk about + _N>_ : Nat -> Nat -> Set m N> n = m N>= suc n Fin : Nat -> Set Fin n = Sg Nat \ m -> n N> m foo : Fin 7 foo = 5 , <> -- command-response systems _<|_ : (C : Set)(R : C -> Set) -> Set -> Set (C <| R) X = Sg C (\ c -> R c -> X) containerFunctor : (C : Set)(R : C -> Set) -> Functor (C <| R) containerFunctor C R = record { map = \ {f (c , k) -> c , (f o k)} ; mapid = \ _ -> refl ; mapcomp = \ _ _ _ -> refl } IC : Set -> Set IC = One <| \ c -> One LC : Set -> Set LC = Nat <| Fin nil : {X : Set} -> LC X nil = 0 , (\ { (m , ()) }) cons : {X : Set} -> X -> LC X -> LC X cons x (n , k) = (suc n) , (\ { (zero , p) -> x ; (suc m , p) -> k (m , p) }) {- look : {X : Set} -> IC X -> Zero look (<> , snd) = {!!} -} postulate goAway : {X : Set} -> X -- the free monad on a command-response system module FREEMONAD (C : Set)(R : C -> Set) where data Free (X : Set) : Set where ret : X -> Free X do : (C <| R) (Free X) -> Free X graft : {X Y : Set} -> Free X -> (X -> Free Y) -> Free Y graft (ret x) k = k x graft (do (c , rx)) k = do (c , (\ r -> graft (rx r) k)) graftLawHelp : {X : Set}(c : C)(rx : R c -> Free X)(r : R c) -> graft (rx r) ret == rx r graftLaw2 : {X : Set}(t : Free X) -> graft t ret == t graftLaw2 (ret x) = refl graftLaw2 (do (c , rx)) rewrite (ext (graftLawHelp c rx)) = refl graftLawHelp c rx r = graftLaw2 (rx r) freeMonad : Monad Free freeMonad = record { return = ret ; _>>=_ = graft ; law1 = \ _ _ -> refl ; law2 = graftLaw2 ; law3 = goAway } -- tree-like data -- shapes and positions
{ "alphanum_fraction": 0.4997170345, "avg_line_length": 20.3103448276, "ext": "agda", "hexsha": "9131c2419b074d8ff4d82c942c1c180ba788c6ab", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_path": "LecSigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_path": "LecSigma.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_path": "LecSigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 670, "size": 1767 }
open import Oscar.Class.Similarity open import Oscar.Class.Reflexivity open import Oscar.Class.Surjection open import Oscar.Class.Leftunit open import Oscar.Class.Smap open import Oscar.Class.Symmetrical open import Oscar.Class.Unit open import Oscar.Data.Surjcollation open import Oscar.Prelude module Oscar.Class.Smapoid where module _ {𝔵₁} {𝔛₁ : Ø 𝔵₁} {𝔵₂} {𝔛₂ : Ø 𝔵₂} {𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯) {𝔭₁} (𝔓₁ : 𝔛₂ → Ø 𝔭₁) {𝔭₂} (𝔓₂ : 𝔛₂ → Ø 𝔭₂) {𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇) {𝔭̇₁₁} (𝔓̇₁₁ : ∀ {x} → 𝔓₁ x → 𝔓₁ x → Ø 𝔭̇₁₁) {𝔭̇₂₂} (𝔓̇₂₂ : ∀ {x} → 𝔓₂ x → 𝔓₂ x → Ø 𝔭̇₂₂) {𝔭̇₁₂} (𝔓̇₁₂ : ∀ {x} → 𝔓₁ x → 𝔓₂ x → Ø 𝔭̇₁₂) where record IsSmapoid : Ø 𝔵₁ ∙̂ 𝔵₂ ∙̂ 𝔯 ∙̂ 𝔯̇ ∙̂ 𝔭₁ ∙̂ 𝔭₂ ∙̂ 𝔭̇₁₁ ∙̂ 𝔭̇₂₂ ∙̂ 𝔭̇₁₂ where constructor ∁ field ⦃ `Surjection ⦄ : Surjection.class 𝔛₁ 𝔛₂ -- ℜ 𝓂 𝓃 → 𝔓₁ (surjection 𝓂) → 𝔓₂ (surjection 𝓃) ⦃ `Smaparrow ⦄ : Smaparrow.class ℜ 𝔓₁ 𝔓₂ surjection surjection -- epfs, Smap -- 𝒫 ₁≈₁ 𝒬 → 𝒻 ◃ 𝒫 ₂≈₂ 𝒻 ◃ 𝒬 ⦃ `leftSim ⦄ : Similarity,smaparrow!.class ℜ 𝔓₁ 𝔓₂ 𝔓̇₁₁ 𝔓̇₂₂ -- fact5, Similarity, Smaparrowleftsimilarity ⦃ `𝓡eflexivity ⦄ : Reflexivity.class ℜ -- 𝒫 ₁≈₂ 𝒖 ◃ 𝒫 ⦃ `leftyunit ⦄ : ∀ {x} {p : 𝔓₁ (surjection x)} → Leftunit.class (flip (𝔓̇₁₂ {surjection x})) ε smap p module _ {𝔵₁} {𝔛₁ : Ø 𝔵₁} {𝔵₂} {𝔛₂ : Ø 𝔵₂} {𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯) {𝔭₁} (𝔓₁ : 𝔛₂ → Ø 𝔭₁) {𝔭₂} (𝔓₂ : 𝔛₂ → Ø 𝔭₂) {𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇) {𝔭̇₁₁} (𝔓̇₁₁ : ∀ {x} → 𝔓₁ x → 𝔓₁ x → Ø 𝔭̇₁₁) {𝔭̇₂₂} (𝔓̇₂₂ : ∀ {x} → 𝔓₂ x → 𝔓₂ x → Ø 𝔭̇₂₂) {𝔭̇₁₂} (𝔓̇₁₂ : ∀ {x} → 𝔓₁ x → 𝔓₂ x → Ø 𝔭̇₁₂) where record IsSmapoidR : Ø 𝔵₁ ∙̂ 𝔵₂ ∙̂ 𝔯 ∙̂ 𝔯̇ ∙̂ 𝔭₁ ∙̂ 𝔭₂ ∙̂ 𝔭̇₁₁ ∙̂ 𝔭̇₂₂ ∙̂ 𝔭̇₁₂ where constructor ∁ field ⦃ `IsSmapoid ⦄ : IsSmapoid ℜ 𝔓₁ 𝔓₂ ℜ̇ 𝔓̇₁₁ 𝔓̇₂₂ 𝔓̇₁₂ -- 𝒻 ᵣ≈ᵣ ℊ → 𝒻 ◃ 𝒫 ₂≈₂ ℊ ◃ 𝒫 ⦃ `rightSim ⦄ : Similarity,cosmaparrow!.class ℜ 𝔓₁ 𝔓₂ ℜ̇ 𝔓̇₂₂ -- fact6, Similarity, Smaparrowrightsimilarity -- TODO add these somewhere? -- fact4 needs Propergroup's Nothing -- ⦃ `Leftstar ⦄ : Leftstar.class -- left-identity-∧ needs Propergroup -- fact1 -- ⦃ `Symmetrical ⦄ : ∀ {m} → Symmetrical (surjcollation[ 𝔓 ]⟦ ℜ / 𝔓̇ ⟧ {m}) (λ { (∁ f) (∁ g) → {!f {m}!}}) -- Properties-fact1
{ "alphanum_fraction": 0.5472636816, "avg_line_length": 31.5857142857, "ext": "agda", "hexsha": "077d3d50a0aea1b9fcfcc72cdea5ade7ba7c542d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Smapoid.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Smapoid.agda", "max_line_length": 116, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Smapoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1378, "size": 2211 }
module list-test where open import bool open import list open import nat open import list-to-string open import bool-to-string open import eq test1 : 𝕃 𝔹 test1 = tt :: tt :: tt :: [] test2 : 𝕃 𝔹 test2 = ff :: ff :: [] test3 = test1 ++ test2 test-lem : test3 ≡ tt :: tt :: tt :: ff :: ff :: [] test-lem = refl test-lem2 : reverse test3 ≡ ff :: ff :: tt :: tt :: tt :: [] test-lem2 = refl test3-string = 𝕃-to-string 𝔹-to-string ", " test3 test4-even = filter is-even (1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: [])
{ "alphanum_fraction": 0.58984375, "avg_line_length": 19.6923076923, "ext": "agda", "hexsha": "3171b843d33d9e612be32cfa102d766bc60c5c3c", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "list-test.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "list-test.agda", "max_line_length": 67, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "list-test.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 181, "size": 512 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics module lib.types.Bool where {- data Bool : Type₀ where true : Bool false : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN FALSE false #-} {-# BUILTIN TRUE true #-} -} Bool = ⊤ ⊔ ⊤ pattern true = inl unit pattern false = inr unit ⊙Bool : Ptd₀ ⊙Bool = ⊙[ Bool , true ] Bool-elim : ∀ {i} {P : Bool → Type i} → P true → P false → Π Bool P Bool-elim true* false* true = true* Bool-elim true* false* false = false* Bool-rec : ∀ {i} {A : Type i} → A → A → (Bool → A) Bool-rec {A = A} = Bool-elim {P = λ _ → A} private Bool-true≠false-type : Bool → Type₀ Bool-true≠false-type true = Unit Bool-true≠false-type false = Empty abstract Bool-true≠false : true ≠ false Bool-true≠false p = transport Bool-true≠false-type p unit Bool-false≠true : false ≠ true Bool-false≠true p = transport Bool-true≠false-type (! p) unit Bool-has-dec-eq : has-dec-eq Bool Bool-has-dec-eq true true = inl idp Bool-has-dec-eq true false = inr Bool-true≠false Bool-has-dec-eq false true = inr Bool-false≠true Bool-has-dec-eq false false = inl idp Bool-is-set : is-set Bool Bool-is-set = dec-eq-is-set Bool-has-dec-eq instance Bool-level : {n : ℕ₋₂} → has-level (S (S n)) Bool Bool-level = set-has-level-SS Bool-is-set
{ "alphanum_fraction": 0.64374034, "avg_line_length": 23.1071428571, "ext": "agda", "hexsha": "01ddc93118edf9b8d4bdd509ad31ff4ff637b7ca", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Bool.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Bool.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Bool.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 452, "size": 1294 }
open import Coinduction using ( ∞ ; ♯_ ; ♭ ) open import Data.Product using ( _×_ ; _,_ ; proj₁ ) open import FRP.LTL.Time.Bound using ( Time∞ ; _≼_ ; _≺_ ; fin ; +∞ ; +∞-top ; ≼-refl ; _≼-trans_ ; ≡-impl-≽ ; ≺-impl-≼ ; ≺-impl-⋡ ; t≺+∞ ; _≼-case_ ; lt ; eq ; gt ) open import FRP.LTL.Time.Interval using ( [_⟩ ; _⊑_ ; _~_ ; _⌢_∵_ ) open import FRP.LTL.ISet.Causal using ( _⊵_ ; _∙_⊸_∙_ ; done ; inp ; out ; _/_/_ ) open import FRP.LTL.ISet.Core using ( ISet ; [_] ; _,_ ; ⟦_⟧ ; M⟦_⟧ ; splitM⟦_⟧ ; subsumM⟦_⟧ ) open import FRP.LTL.ISet.Stateless using ( _⇒_ ) open import FRP.LTL.Util using ( ⊥-elim ; ≡-relevant ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ) module FRP.LTL.ISet.Product where _∧_ : ISet → ISet → ISet A ∧ B = [ (λ i → M⟦ A ⟧ i × M⟦ B ⟧ i) , split , subsum ] where split : ∀ i j i~j → (M⟦ A ⟧ (i ⌢ j ∵ i~j) × M⟦ B ⟧ (i ⌢ j ∵ i~j)) → ((M⟦ A ⟧ i × M⟦ B ⟧ i) × (M⟦ A ⟧ j × M⟦ B ⟧ j)) split i j i~j (σ , τ) with splitM⟦ A ⟧ i j i~j σ | splitM⟦ B ⟧ i j i~j τ split i j i~j (σ , τ) | (σ₁ , σ₂) | (τ₁ , τ₂) = ((σ₁ , τ₁) , (σ₂ , τ₂)) subsum : ∀ i j → (i ⊑ j) → (M⟦ A ⟧ j × M⟦ B ⟧ j) → (M⟦ A ⟧ i × M⟦ B ⟧ i) subsum i j i⊑j (σ , τ) = (subsumM⟦ A ⟧ i j i⊑j σ , subsumM⟦ B ⟧ i j i⊑j τ) -- We could define fst and snd in terms of arr, but we define them explictly for efficiency. π₁ : ∀ {A B} t → ((A ∧ B) ∙ t ⊸ A ∙ t) π₁ {A} {B} +∞ = done refl π₁ {A} {B} (fin t) = inp ≼-refl t≺+∞ P where P : ∀ {u} .(t≺u : fin t ≺ u) → M⟦ A ∧ B ⟧ [ t≺u ⟩ → ∞ ((A ∧ B) ∙ u ⊸ A ∙ fin t) P {u} t≺u [ σ , τ ] = ♯ out t≺u σ (♯ π₁ u) fst : ∀ {A B} → ⟦ A ∧ B ⊵ A ⟧ fst = [ (λ t t∈i → π₁ (fin t)) ] π₂ : ∀ {A B} t → ((A ∧ B) ∙ t ⊸ B ∙ t) π₂ {A} {B} +∞ = done refl π₂ {A} {B} (fin t) = inp ≼-refl t≺+∞ Q where Q : ∀ {u} .(t≺u : fin t ≺ u) → M⟦ A ∧ B ⟧ [ t≺u ⟩ → ∞ ((A ∧ B) ∙ u ⊸ B ∙ fin t) Q {u} t≺u [ σ , τ ] = ♯ out t≺u τ (♯ π₂ u) snd : ∀ {A B} → ⟦ A ∧ B ⊵ B ⟧ snd = [ (λ t t∈i → π₂ (fin t)) ] -- Mediating morphism _&&_ : ∀ {A B C s t} → (A ∙ s ⊸ B ∙ t) → (A ∙ s ⊸ C ∙ t) → (A ∙ s ⊸ (B ∧ C) ∙ t) inp s≼t t≺∞ P && Q = inp s≼t t≺∞ (λ s≺u σ → ♯ (♭ (P s≺u σ) && (Q / s≺u / σ))) P && inp s≼t t≺∞ Q = inp s≼t t≺∞ (λ s≺u σ → ♯ ((P / s≺u / σ) && ♭ (Q s≺u σ))) P && done t≡∞ = done t≡∞ done t≡∞ && Q = done t≡∞ out {u} t≺u σ P && out {v} t≺v τ Q with u ≼-case v out t≺u σ P && out t≺v τ Q | lt u≺v with splitM⟦ _ ⟧ [ t≺u ⟩ [ u≺v ⟩ refl τ out t≺u σ P && out t≺v τ Q | lt u≺v | (τ₁ , τ₂) = out t≺u [ σ , τ₁ ] (♯ (♭ P && out u≺v τ₂ Q)) out t≺u σ P && out t≺v τ Q | eq u≡v with ≡-relevant u≡v out t≺u σ P && out t≺v τ Q | eq u≡v | refl = out t≺u [ σ , τ ] (♯ (♭ P && ♭ Q)) out t≺u σ P && out t≺v τ Q | gt v≺u with splitM⟦ _ ⟧ [ t≺v ⟩ [ v≺u ⟩ refl σ out t≺u σ P && out t≺v τ Q | gt v≺u | (σ₁ , σ₂) = out t≺v [ σ₁ , τ ] (♯ (out v≺u σ₂ P && ♭ Q)) _&&&_ : ∀ {A B C} → ⟦ (A ⊵ B) ⇒ (A ⊵ C) ⇒ (A ⊵ (B ∧ C)) ⟧ [ [ f ] ] &&& [ [ g ] ] = [ (λ t t∈i → f t t∈i && g t t∈i) ]
{ "alphanum_fraction": 0.4283828383, "avg_line_length": 45.9090909091, "ext": "agda", "hexsha": "565d491d6193563face20ee18a214f875c20ba3c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/ISet/Product.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/ISet/Product.agda", "max_line_length": 98, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/ISet/Product.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 1658, "size": 3030 }
module UselessAbstractPrimitive where postulate Int : Set {-# BUILTIN INTEGER Int #-} abstract primitive primIntegerPlus : Int -> Int -> Int
{ "alphanum_fraction": 0.72, "avg_line_length": 15, "ext": "agda", "hexsha": "3c01787a91956b017bf57793c06a03ddeae907dc", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/UselessAbstractPrimitive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/UselessAbstractPrimitive.agda", "max_line_length": 39, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/UselessAbstractPrimitive.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 35, "size": 150 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} -- This library is licensed under 0BSD. You can read more about it at its GitHub repository: https://github.com/Zambonifofex/lightlib module index where -- The `Light.Libary` file exports modules referencing interface files and other miscellaneous files in the library. import Light.Library -- The `Light.Implementation` file exports modules referencing files that provide an implementation for the interfaces above. import Light.Implementation -- The `Light` file can be used conveniently to use the given implementation for their appropriate interfaces. import Light -- The `Light.Implementation.Standard` file provides an implementation that uses definitions from the standard library: https://github.com/agda/agda-stdlib import Light.Implementation.Standard
{ "alphanum_fraction": 0.8030660377, "avg_line_length": 47.1111111111, "ext": "agda", "hexsha": "49e0cd7a7c3dce3b72686b4f10669b737837f99a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "other/index.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "other/index.agda", "max_line_length": 155, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "other/index.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 167, "size": 848 }
open import Everything module Test.Test7 where 𝓅rop-id : ∀ {𝔵} {𝔛 : Ø 𝔵} {𝔞} {𝔄 : 𝔛 → Ø 𝔞} {𝔟} {𝔅 : 𝔛 → Ø 𝔟} (let _∼_ = Arrow 𝔄 𝔅) {ℓ̇} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ̇} ⦃ _ : Transitivity.class _∼_ ⦄ ⦃ _ : Reflexivity.class _∼_ ⦄ ⦃ _ : Transleftidentity!.class _∼_ _∼̇_ ⦄ ⦃ _ : ∀ {x y} → Symmetry.class (_∼̇_ {x} {y}) ⦄ {m n} {ℓ} {f : m ∼ n} (P : ExtensionṖroperty ℓ (Arrow 𝔄 𝔅 m) _∼̇_) (let P₀ = π₀ (π₀ P)) → P₀ f → P₀ (ε ∙ f) 𝓅rop-id P Pf = hmap _ P Pf
{ "alphanum_fraction": 0.4550669216, "avg_line_length": 23.7727272727, "ext": "agda", "hexsha": "b98daa02b18bbccc046cd7a244165bd8b7efcf81", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/Test7.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/Test7.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/Test7.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 302, "size": 523 }
{- Types Summer School 2007 Bertinoro Aug 19 - 31, 2007 Agda Ulf Norell -} -- Now we're getting somewhere! Inductive families of datatypes. module Families where -- You can import modules defined in other files. -- More details later... -- open import Nat data Nat : Set where zero : Nat suc : Nat -> Nat _+_ : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) -- Think of an inductive family... data Vec (A : Set) : Nat -> Set where [] : Vec A zero _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n) infixr 40 _::_ -- Some simple functions head : {A : Set}{n : Nat} -> Vec A (suc n) -> A head (x :: _) = x -- no need for a [] case -- Does the definition look familiar? map : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n map f [] = [] map f (x :: xs) = f x :: map f xs infixr 40 _++_ _++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m) [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) -- Why does this type check? Let's walk through it slowly. -- When pattern matching on the first vector, n is instantiated. -- What happens if we make the lengths explicit? cat : {A : Set}(n m : Nat) -> Vec A n -> Vec A m -> Vec A (n + m) cat .zero m [] ys = ys cat .(suc n) m (_::_ {n} x xs) ys = x :: (cat n m xs ys) -- Patterns which get instantiated by pattern matching on other stuff -- get tagged by a dot. If you erase all the dotted things you get a -- well-formed linear first-order pattern. -- Inside the dot we could have arbitrary terms. For instance, data Image_∋_ {A B : Set}(f : A -> B) : B -> Set where im : (x : A) -> Image f ∋ f x inv : {A B : Set}(f : A -> B)(y : B) -> Image f ∋ y -> A inv f .(f x) (im x) = x -- Let's do some other interesting families. -- The identity type. data _==_ {A : Set} : A -> A -> Set where refl : (x : A) -> x == x subst : {A : Set}(C : A -> Set)(x y : A) -> x == y -> C x -> C y subst C .x .x (refl x) cx = cx -- Finite sets {- Fin zero - Fin (suc zero) fzero Fin 2 fzero, fsuc fzero -} data Fin : Nat -> Set where fzero : {n : Nat} -> Fin (suc n) fsuc : {n : Nat} -> Fin n -> Fin (suc n) _!_ : {A : Set}{n : Nat} -> Vec A n -> Fin n -> A [] ! () (x :: xs) ! fzero = x (x :: xs) ! fsuc i = xs ! i {- What's next? -} -- Actually, inductive families are sufficiently fun that -- you'll never get bored, but there's even more fun to be had. -- Move on to: Filter.agda
{ "alphanum_fraction": 0.535898453, "avg_line_length": 22.3097345133, "ext": "agda", "hexsha": "7f9e86f494d167ec284841c3dd98a80781194c00", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 839, "size": 2521 }
{-# OPTIONS -Wall #-} module noinfixdecl where -- warning acts on data constructors data #2 : Set where one : #2 two : #2 neg_ : #2 → #2 -- warning acts on definitions infixl 3 _⊓_ _⊔_ : #2 → #2 → #2 _⊓_ : #2 → #2 → #2 one ⊔ n = n two ⊔ n = two (neg v) ⊔ n = neg (v ⊓ neg n) one ⊓ n = one two ⊓ n = n (neg m) ⊓ n = neg (m ⊔ (neg n)) -- warning acts on postulates postulate _≤_ : #2 → #2 → Set -- warning does not act on 'closed' mixfix definitions postulate [_] : #2 → Set
{ "alphanum_fraction": 0.5496031746, "avg_line_length": 17.3793103448, "ext": "agda", "hexsha": "126b9c9a536d60ab8844d1dfb8cd7903066773a6", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/noinfixdecl.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/noinfixdecl.agda", "max_line_length": 54, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/noinfixdecl.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 206, "size": 504 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.NType2 open import lib.types.Nat open import lib.types.TLevel open import lib.types.Empty open import lib.types.Pi open import lib.types.Sigma open import lib.types.Truncation open import lib.types.Pointed open import lib.types.Group open import lib.types.LoopSpace open import lib.groups.TruncationGroup open import lib.groups.GroupProduct open import lib.groups.Homomorphisms open import lib.groups.Unit module lib.groups.HomotopyGroup where {- Higher homotopy groups -} module _ {i} where πS : (n : ℕ) (X : Ptd i) → Group i πS n X = Trunc-group (Ω^S-group-structure n X) fundamental-group : (X : Ptd i) → Group i fundamental-group X = πS 0 X {- π_(n+1) of a space is π_n of its loop space -} abstract πS-inner-iso : ∀ {i} (n : ℕ) (X : Ptd i) → πS (S n) X == πS n (⊙Ω X) πS-inner-iso n X = group-ua (record { f = Trunc-fmap (Ω^-inner-out (S n) X); pres-comp = Trunc-elim (λ _ → Π-level (λ _ → =-preserves-level _ Trunc-level)) (λ p → Trunc-elim (λ _ → =-preserves-level _ Trunc-level) (λ q → ap [_] (Ω^S-inner-out-conc^S n X p q)))} , is-equiv-Trunc 0 (Ω^-inner-out (S n) X) (Ω^-inner-is-equiv (S n) X)) {- We can shift the truncation inside the loop in the definition of π -} module _ {i} where private record Ω^STs-PreIso (m : ℕ₋₂) (n : ℕ) (k : ℕ₋₂) (X : Ptd i) : Type i where field F : fst (⊙Ω^ (S n) (⊙Trunc k X) ⊙→ ⊙Trunc m (⊙Ω^ (S n) X)) pres-comp : ∀ (p q : Ω^ (S n) (⊙Trunc k X)) → fst F (conc^S n p q) == Trunc-fmap2 (conc^S n) (fst F p) (fst F q) e : is-equiv (fst F) Ω^S-Trunc-shift-preiso : (n : ℕ) (m : ℕ₋₂) (X : Ptd i) → Ω^STs-PreIso m n (⟨ S n ⟩₋₂ +2+ m) X Ω^S-Trunc-shift-preiso O m X = record { F = (–> (Trunc=-equiv [ snd X ] [ snd X ]) , idp); pres-comp = Trunc=-∙-comm; e = snd (Trunc=-equiv [ snd X ] [ snd X ]) } Ω^S-Trunc-shift-preiso (S n) m X = let r : Ω^STs-PreIso (S m) n (⟨ S n ⟩₋₂ +2+ S m) X r = Ω^S-Trunc-shift-preiso n (S m) X H = (–> (Trunc=-equiv [ idp^ (S n) ] [ idp^ (S n) ]) , idp) G = ap^ 1 (Ω^STs-PreIso.F r) in transport (λ k → Ω^STs-PreIso m (S n) k X) (+2+-βr ⟨ S n ⟩₋₂ m) (record { F = H ⊙∘ G; pres-comp = λ p q → ap (fst H) (ap^S-conc^S 0 (Ω^STs-PreIso.F r) p q) ∙ (Trunc=-∙-comm (fst G p) (fst G q)); e = snd (Trunc=-equiv [ idp^ (S n) ] [ idp^ (S n) ] ∘e equiv-ap^ 1 (Ω^STs-PreIso.F r) (Ω^STs-PreIso.e r))}) πS-Trunc-shift-iso : (n : ℕ) (X : Ptd i) → Ω^S-group n (⊙Trunc ⟨ S n ⟩ X) Trunc-level == πS n X πS-Trunc-shift-iso n X = group-ua (group-hom (fst F) pres-comp , e) where n-eq : ∀ (n : ℕ) → ⟨ n ⟩₋₂ +2+ 0 == ⟨ n ⟩ n-eq O = idp n-eq (S n) = ap S (n-eq n) r = transport (λ k → Ω^STs-PreIso 0 n k X) (n-eq (S n)) (Ω^S-Trunc-shift-preiso n 0 X) open Ω^STs-PreIso r abstract πS-below-trunc : ∀ {i} (n : ℕ) (m : ℕ₋₂) (X : Ptd i) → (⟨ S n ⟩ ≤T m) → πS n (⊙Trunc m X) == πS n X πS-below-trunc n m X lte = πS n (⊙Trunc m X) =⟨ ! (πS-Trunc-shift-iso n (⊙Trunc m X)) ⟩ Ω^S-group n (⊙Trunc ⟨ S n ⟩ (⊙Trunc m X)) Trunc-level =⟨ lemma ⟩ Ω^S-group n (⊙Trunc ⟨ S n ⟩ X) Trunc-level =⟨ πS-Trunc-shift-iso n X ⟩ πS n X ∎ where lemma : Ω^S-group n (⊙Trunc ⟨ S n ⟩ (⊙Trunc m X)) Trunc-level == Ω^S-group n (⊙Trunc ⟨ S n ⟩ X) Trunc-level lemma = ap (uncurry $ Ω^S-group n) $ pair= (⊙ua (⊙≃-in (fuse-Trunc (fst X) ⟨ S n ⟩ m) idp) ∙ ap (λ k → ⊙Trunc k X) (minT-out-l lte)) (prop-has-all-paths-↓ has-level-is-prop) πS-above-trunc : ∀ {i} (n : ℕ) (m : ℕ₋₂) (X : Ptd i) → (m <T ⟨ S n ⟩) → πS n (⊙Trunc m X) == 0ᴳ πS-above-trunc n m X lt = πS n (⊙Trunc m X) =⟨ ! (πS-Trunc-shift-iso n (⊙Trunc m X)) ⟩ Ω^S-group n (⊙Trunc ⟨ S n ⟩ (⊙Trunc m X)) Trunc-level =⟨ contr-is-0ᴳ _ $ inhab-prop-is-contr (Group.ident (Ω^S-group n (⊙Trunc ⟨ S n ⟩ (⊙Trunc m X)) Trunc-level)) (Ω^-level-in -1 (S n) _ $ Trunc-preserves-level ⟨ S n ⟩ $ raise-level-≤T (transport (λ k → m ≤T k) (+2+-comm -1 ⟨ S n ⟩₋₂) (<T-to-≤T lt)) (Trunc-level {n = m})) ⟩ 0ᴳ ∎ πS-above-level : ∀ {i} (n : ℕ) (m : ℕ₋₂) (X : Ptd i) → (m <T ⟨ S n ⟩) → has-level m (fst X) → πS n X == 0ᴳ πS-above-level n m X lt pX = ap (πS n) (! (⊙ua (⊙≃-in (unTrunc-equiv _ pX) idp))) ∙ πS-above-trunc n m X lt {- πₙ(X × Y) == πₙ(X) × πₙ(Y) -} module _ {i j} (n : ℕ) (X : Ptd i) (Y : Ptd j) where πS-× : πS n (X ⊙× Y) == πS n X ×ᴳ πS n Y πS-× = group-ua (Trunc-group-iso f pres-comp (is-eq f g f-g g-f)) ∙ Trunc-group-× _ _ where f : Ω^ (S n) (X ⊙× Y) → Ω^ (S n) X × Ω^ (S n) Y f r = (fst (ap^ (S n) ⊙fst) r , fst (ap^ (S n) ⊙snd) r) g : Ω^ (S n) X × Ω^ (S n) Y → Ω^ (S n) (X ⊙× Y) g = fst (ap2^ (S n) (⊙idf _)) f-g : (s : Ω^ (S n) X × Ω^ (S n) Y) → f (g s) == s f-g (p , q) = pair×= (app= (ap fst (ap^-ap2^ (S n) ⊙fst (⊙idf _) ∙ ap2^-fst (S n))) (p , q)) (app= (ap fst (ap^-ap2^ (S n) ⊙snd (⊙idf _) ∙ ap2^-snd (S n))) (p , q)) g-f : (r : Ω^ (S n) (X ⊙× Y)) → g (f r) == r g-f = app= $ ap fst $ ap (λ h → h ⊙∘ ⊙diag) (ap2^-ap^ (S n) (⊙idf _) ⊙fst ⊙snd) ∙ ap2^-diag (S n) (⊙idf _ ⊙∘ pair⊙→ ⊙fst ⊙snd) ∙ ap^-idf (S n) pres-comp : (p q : Ω^ (S n) (X ⊙× Y)) → f (conc^S n p q) == (conc^S n (fst (f p)) (fst (f q)) , conc^S n (snd (f p)) (snd (f q))) pres-comp p q = pair×= (ap^S-conc^S n ⊙fst p q) (ap^S-conc^S n ⊙snd p q) module _ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} (f : fst (X ⊙→ Y)) where πS-fmap : πS n X →ᴳ πS n Y πS-fmap = Trunc-group-hom (fst (ap^ (S n) f)) (ap^S-conc^S n f)
{ "alphanum_fraction": 0.4858728557, "avg_line_length": 35.8192771084, "ext": "agda", "hexsha": "6e3d0235ef0865ae0c50584207f6d43aab1af24c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "core/lib/groups/HomotopyGroup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "core/lib/groups/HomotopyGroup.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "core/lib/groups/HomotopyGroup.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2695, "size": 5946 }
module Human.Test where open import Human.Humanity -- sum 7 -- 0 + 1 + 2 + 3 + 4 + 5 + 6 -- function sum(x) { -- var result = 0; -- for (var i = 0; i < 10; ++i) { -- result = result + i; -- } -- return result; -- } sum : Nat → Nat sum i = init 0 for i from 0 to 10 do: λ result → result + 1
{ "alphanum_fraction": 0.5063291139, "avg_line_length": 14.3636363636, "ext": "agda", "hexsha": "80806f14678bac1dcf040faf57457b31b6f71c54", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MaisaMilena/JuiceMaker", "max_forks_repo_path": "src/Human/Test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MaisaMilena/JuiceMaker", "max_issues_repo_path": "src/Human/Test.agda", "max_line_length": 35, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MaisaMilena/JuiceMaker", "max_stars_repo_path": "src/Human/Test.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z", "num_tokens": 124, "size": 316 }
------------------------------------------------------------------------ -- A small library of derived parser combinators ------------------------------------------------------------------------ module TotalParserCombinators.Lib where open import Category.Monad open import Codata.Musical.Notation open import Function.Base open import Function.Equality using (_⟶_; _⟨$⟩_) open import Function.Injection using (Injection; Injective) open import Function.Inverse using (_↔_; module Inverse) open import Data.Bool hiding (_≤?_) open import Data.Char as Char using (Char; _==_) open import Data.List as List import Data.List.Categorical open import Data.List.Membership.Propositional import Data.List.Membership.Propositional.Properties as ∈ open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_) open import Data.List.Relation.Unary.Any open import Data.Maybe hiding (_>>=_) open import Data.Nat hiding (_^_) open import Data.Product as Prod open import Data.Unit using (⊤) open import Data.Vec as Vec using (Vec; []; _∷_) import Level open import Relation.Binary open import Relation.Binary.HeterogeneousEquality as H using (_≅_) open import Relation.Binary.PropositionalEquality as P using (_≡_) import Relation.Binary.PropositionalEquality.WithK as P open import Relation.Nullary open import Relation.Nullary.Decidable private open module ListMonad = RawMonad {f = Level.zero} Data.List.Categorical.monad using () renaming (_<$>_ to _<$>′_; _⊛_ to _⊛′_; _>>=_ to _>>=′_) import TotalParserCombinators.InitialBag as I open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics as S hiding (_≅_; return; token) ------------------------------------------------------------------------ -- Kleene star -- The intended semantics of the Kleene star. infixr 5 _∷_ infix 4 _∈[_]⋆·_ data _∈[_]⋆·_ {Tok R xs} : List R → Parser Tok R xs → List Tok → Set₁ where [] : ∀ {p} → [] ∈[ p ]⋆· [] _∷_ : ∀ {x xs s₁ s₂ p} → (x∈p : x ∈ p · s₁) (xs∈p⋆ : xs ∈[ p ]⋆· s₂) → x ∷ xs ∈[ p ]⋆· s₁ ++ s₂ -- An implementation which requires that the argument parser is not -- nullable. infix 55 _⋆ _+ mutual _⋆ : ∀ {Tok R} → Parser Tok R [] → Parser Tok (List R) [ [] ] p ⋆ = return [] ∣ p + _+ : ∀ {Tok R} → Parser Tok R [] → Parser Tok (List R) [] p + = _∷_ <$> p ⊛ ♯ (p ⋆) module KleeneStar where -- The implementation is correct. sound : ∀ {Tok R xs s} {p : Parser Tok R []} → xs ∈ p ⋆ · s → xs ∈[ p ]⋆· s sound (∣-left S.return) = [] sound (∣-right ._ (<$> x∈p ⊛ xs∈p⋆)) = x∈p ∷ sound xs∈p⋆ complete : ∀ {Tok R xs s} {p : Parser Tok R []} → xs ∈[ p ]⋆· s → xs ∈ p ⋆ · s complete [] = ∣-left S.return complete (_∷_ {s₁ = []} x∈p xs∈p⋆) with I.complete x∈p ... | () complete (_∷_ {s₁ = _ ∷ _} x∈p xs∈p⋆) = ∣-right [ [] ] ([ ○ - ◌ ] <$> x∈p ⊛ complete xs∈p⋆) complete∘sound : ∀ {Tok R xs s} {p : Parser Tok R []} (xs∈ : xs ∈ p ⋆ · s) → complete (sound xs∈) ≡ xs∈ complete∘sound (∣-left S.return) = P.refl complete∘sound (∣-right ._ (_⊛_ {s₁ = _ ∷ _} (<$> x∈p) xs∈p⋆)) rewrite complete∘sound xs∈p⋆ = P.refl complete∘sound (∣-right ._ (_⊛_ {s₁ = []} (<$> x∈p) xs∈p⋆)) with I.complete x∈p ... | () sound∘complete : ∀ {Tok R xs s} {p : Parser Tok R []} (xs∈ : xs ∈[ p ]⋆· s) → sound (complete xs∈) ≡ xs∈ sound∘complete [] = P.refl sound∘complete (_∷_ {s₁ = []} x∈p xs∈p⋆) with I.complete x∈p ... | () sound∘complete (_∷_ {s₁ = _ ∷ _} x∈p xs∈p⋆) = P.cong (_∷_ x∈p) $ sound∘complete xs∈p⋆ correct : ∀ {Tok R xs s} {p : Parser Tok R []} → xs ∈ p ⋆ · s ↔ xs ∈[ p ]⋆· s correct = record { to = P.→-to-⟶ sound ; from = P.→-to-⟶ complete ; inverse-of = record { left-inverse-of = complete∘sound ; right-inverse-of = sound∘complete } } -- The definition of _⋆ is restricted to non-nullable parsers. This -- restriction cannot be removed: an unrestricted Kleene star -- operator would be incomplete because, in the present framework, a -- parser can only return a finite number of results. unrestricted-incomplete : ∀ {R Tok} → R → (f : ∀ {xs} → Parser Tok R xs → List (List R)) → (_⋆′ : ∀ {xs} (p : Parser Tok R xs) → Parser Tok (List R) (f p)) → ¬ (∀ {xs ys s} {p : Parser Tok R ys} → xs ∈[ p ]⋆· s → xs ∈ p ⋆′ · s) unrestricted-incomplete {R} x f _⋆′ complete = ∈.finite (record { to = to; injective = injective }) (f (return x)) (I.complete ∘ complete ∘ lemma) where to : P.setoid ℕ ⟶ P.setoid (List R) to = P.→-to-⟶ (flip replicate x) helper : ∀ {xs ys} → _≡_ {A = List R} (x ∷ xs) (x ∷ ys) → xs ≡ ys helper P.refl = P.refl injective : Injective to injective {zero} {zero} _ = P.refl injective {suc m} {suc n} eq = P.cong suc $ injective $ helper eq injective {zero} {suc n} () injective {suc m} {zero} () lemma : ∀ i → replicate i x ∈[ return x ]⋆· [] lemma zero = [] lemma (suc i) = S.return ∷ lemma i ------------------------------------------------------------------------ -- A combinator for recognising a string a fixed number of times infixl 55 _^_ _↑_ ^-initial : ∀ {R} → List R → (n : ℕ) → List (Vec R n) ^-initial xs zero = [ [] ] ^-initial xs (suc n) = List.map _∷_ xs ⊛′ ^-initial xs n _^_ : ∀ {Tok R xs} → Parser Tok R xs → (n : ℕ) → Parser Tok (Vec R n) (^-initial xs n) p ^ 0 = return [] p ^ suc n = _∷_ <$> p ⊛ p ^ n mutual -- A variant. -- The two functions below are not actually mutually recursive, but -- are placed in a mutual block to ensure that the constraints -- generated by the second function can be used to instantiate the -- underscores in the body of the first. ↑-initial : ∀ {R} → List R → ℕ → List (List R) ↑-initial _ _ = _ _↑_ : ∀ {Tok R xs} → Parser Tok R xs → (n : ℕ) → Parser Tok (List R) (↑-initial xs n) p ↑ n = Vec.toList <$> p ^ n -- Some lemmas relating _↑_ to _⋆. module Exactly where ↑≲⋆ : ∀ {Tok R} {p : Parser Tok R []} n → p ↑ n ≲ p ⋆ ↑≲⋆ {R = R} {p} n (<$> ∈pⁿ) = KleeneStar.complete $ helper n ∈pⁿ where helper : ∀ n {xs s} → xs ∈ p ^ n · s → Vec.toList xs ∈[ p ]⋆· s helper zero S.return = [] helper (suc n) (<$> ∈p ⊛ ∈pⁿ) = ∈p ∷ helper n ∈pⁿ ⋆≲∃↑ : ∀ {Tok R} {p : Parser Tok R []} {xs s} → xs ∈ p ⋆ · s → ∃ λ i → xs ∈ p ↑ i · s ⋆≲∃↑ {R = R} {p} ∈p⋆ with helper $ KleeneStar.sound ∈p⋆ where helper : ∀ {xs s} → xs ∈[ p ]⋆· s → ∃₂ λ i (ys : Vec R i) → xs ≡ Vec.toList ys × ys ∈ p ^ i · s helper [] = (0 , [] , P.refl , S.return) helper (∈p ∷ ∈p⋆) = Prod.map suc (λ {i} → Prod.map (_∷_ _) ( Prod.map (P.cong (_∷_ _)) (λ ∈pⁱ → [ ○ - ○ ] <$> ∈p ⊛ ∈pⁱ))) (helper ∈p⋆) ... | (i , ys , P.refl , ∈pⁱ) = (i , <$> ∈pⁱ) ------------------------------------------------------------------------ -- A parser which returns any element in a given list return⋆ : ∀ {Tok R} (xs : List R) → Parser Tok R xs return⋆ [] = fail return⋆ (x ∷ xs) = return x ∣ return⋆ xs module Return⋆ where sound : ∀ {Tok R x} {s : List Tok} (xs : List R) → x ∈ return⋆ xs · s → s ≡ [] × x ∈ xs sound [] () sound (y ∷ ys) (∣-left S.return) = (P.refl , here P.refl) sound (y ∷ ys) (∣-right .([ y ]) x∈ys) = Prod.map id there $ sound ys x∈ys complete : ∀ {Tok R x} {xs : List R} → x ∈ xs → x ∈ return⋆ {Tok} xs · [] complete (here P.refl) = ∣-left S.return complete (there x∈xs) = ∣-right [ _ ] (complete x∈xs) complete∘sound : ∀ {Tok R x} {s : List Tok} (xs : List R) (x∈xs : x ∈ return⋆ xs · s) → complete {Tok = Tok} (proj₂ $ sound xs x∈xs) ≅ x∈xs complete∘sound [] () complete∘sound (y ∷ ys) (∣-left S.return) = H.refl complete∘sound (y ∷ ys) (∣-right .([ y ]) x∈ys) with sound ys x∈ys | complete∘sound ys x∈ys complete∘sound (y ∷ ys) (∣-right .([ y ]) .(complete p)) | (P.refl , p) | H.refl = H.refl sound∘complete : ∀ {Tok R x} {xs : List R} (x∈xs : x ∈ xs) → sound {Tok = Tok} {s = []} xs (complete x∈xs) ≡ (P.refl , x∈xs) sound∘complete (here P.refl) = P.refl sound∘complete {Tok} (there {xs = xs} x∈xs) with sound {Tok = Tok} xs (complete x∈xs) | sound∘complete {Tok} {xs = xs} x∈xs sound∘complete (there x∈xs) | .(P.refl , x∈xs) | P.refl = P.refl correct : ∀ {Tok R} {xs : List R} {x s} → (s ≡ [] × x ∈ xs) ↔ x ∈ return⋆ {Tok} xs · s correct {xs = xs} {x} = record { to = P.→-to-⟶ complete′ ; from = P.→-to-⟶ $ sound xs ; inverse-of = record { left-inverse-of = sound∘complete′ ; right-inverse-of = complete′∘sound xs } } where complete′ : ∀ {Tok R x} {xs : List R} {s : List Tok} → s ≡ [] × x ∈ xs → x ∈ return⋆ xs · s complete′ (P.refl , x∈xs) = complete x∈xs sound∘complete′ : ∀ {Tok R x} {xs : List R} {s : List Tok} (p : s ≡ [] × x ∈ xs) → sound xs (complete′ p) ≡ p sound∘complete′ (P.refl , x∈xs) = sound∘complete x∈xs complete′∘sound : ∀ {Tok R x} {s : List Tok} (xs : List R) (x∈xs : x ∈ return⋆ xs · s) → complete′ (sound xs x∈xs) ≡ x∈xs complete′∘sound xs x∈ with sound xs x∈ | complete∘sound xs x∈ complete′∘sound xs .(complete x∈xs) | (P.refl , x∈xs) | H.refl = P.refl ------------------------------------------------------------------------ -- The sat parser module Sat where -- Helper functions for sat. mutual ok-bag : {R : Set} → Maybe R → List R ok-bag nothing = _ ok-bag (just _) = _ ok : {Tok R : Set} → (x : Maybe R) → Parser Tok R (ok-bag x) ok nothing = fail ok (just x) = return x ok-correct : ∀ {Tok R x s} (m : Maybe R) → (s ≡ [] × m ≡ just x) ↔ x ∈ ok {Tok} m · s ok-correct {Tok} {x = x} m = record { to = P.→-to-⟶ (to m) ; from = P.→-to-⟶ (from m) ; inverse-of = record { left-inverse-of = from∘to m ; right-inverse-of = to∘from m } } where to : ∀ {s} m → (s ≡ [] × m ≡ just x) → x ∈ ok {Tok} m · s to (just .x) (P.refl , P.refl) = S.return to nothing (P.refl , ()) from : ∀ {s} m → x ∈ ok {Tok} m · s → s ≡ [] × m ≡ just x from (just .x) S.return = (P.refl , P.refl) from nothing () from∘to : ∀ {s} m (eqs : s ≡ [] × m ≡ just x) → from m (to m eqs) ≡ eqs from∘to (just .x) (P.refl , P.refl) = P.refl from∘to nothing (P.refl , ()) to∘from : ∀ {s} m (x∈ : x ∈ ok {Tok} m · s) → to m (from m x∈) ≡ x∈ to∘from (just .x) S.return = P.refl to∘from nothing () -- sat p accepts a single token t iff p t ≡ just x for some x. The -- returned value is x. sat : ∀ {Tok R} → (Tok → Maybe R) → Parser Tok R _ sat p = token >>= (ok ∘ p) correct : ∀ {Tok R x s} (p : Tok → Maybe R) → (∃ λ t → s ≡ [ t ] × p t ≡ just x) ↔ x ∈ sat p · s correct {x = x} p = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = to∘from } } where to : ∀ {s} → (∃ λ t → s ≡ [ t ] × p t ≡ just x) → x ∈ sat p · s to (t , P.refl , p-t≡just-x) = [ ○ - ○ ] S.token >>= (Inverse.to (ok-correct (p t)) ⟨$⟩ (P.refl , p-t≡just-x)) from : ∀ {s} → x ∈ sat p · s → ∃ λ t → s ≡ [ t ] × p t ≡ just x from (S.token {x = t} >>= x∈ok-p-t) = (t , Prod.map (P.cong (_∷_ t)) id (Inverse.from (ok-correct (p t)) ⟨$⟩ x∈ok-p-t)) from∘to : ∀ {s} (eqs : ∃ λ t → s ≡ [ t ] × p t ≡ just x) → from (to eqs) ≡ eqs from∘to (t , P.refl , p-t≡just-x) = P.cong₂ (λ eq₁ eq₂ → (t , eq₁ , eq₂)) (P.≡-irrelevant _ _) (P.≡-irrelevant _ _) to∘from : ∀ {s} (x∈ : x ∈ sat p · s) → to (from x∈) ≡ x∈ to∘from (S.token {x = t} >>= x∈ok-p-t) with Inverse.from (ok-correct (p t)) ⟨$⟩ x∈ok-p-t | Inverse.right-inverse-of (ok-correct (p t)) x∈ok-p-t to∘from (S.token {x = t} >>= .(Inverse.to (ok-correct (p t)) ⟨$⟩ (P.refl , p-t≡just-x))) | (P.refl , p-t≡just-x) | P.refl = P.refl open Sat public using (sat) -- A simplified variant of sat. Does not return anything interesting. sat′ : ∀ {Tok} → (Tok → Bool) → Parser Tok ⊤ _ sat′ p = sat (boolToMaybe ∘ p) -- Accepts a single whitespace character (from a limited set of such -- characters). whitespace : Parser Char ⊤ _ whitespace = sat′ isSpace where isSpace = λ c → (c == ' ') ∨ (c == '\t') ∨ (c == '\n') ∨ (c == '\r') ------------------------------------------------------------------------ -- A parser for a given token module Token (Tok : Set) (_≟_ : Decidable (_≡_ {A = Tok})) where private p : Tok → Tok → Maybe Tok p t t′ = if ⌊ t ≟ t′ ⌋ then just t′ else nothing tok : Tok → Parser Tok Tok [] tok t = sat (p t) sound : ∀ t {t′ s} → t′ ∈ tok t · s → t ≡ t′ × s ≡ [ t′ ] sound t t′∈ with Inverse.from (Sat.correct (p t)) ⟨$⟩ t′∈ sound t t′∈ | (t″ , P.refl , p-t-t″≡just-t′) with t ≟ t″ sound t t∈ | (.t , P.refl , P.refl) | yes P.refl = (P.refl , P.refl) sound t t′∈ | (t″ , P.refl , ()) | no _ private p-lemma : ∀ t → p t t ≡ just t p-lemma t with t ≟ t ... | yes P.refl = P.refl ... | no t≢t with t≢t P.refl ... | () complete : ∀ {t} → t ∈ tok t · [ t ] complete {t} = Inverse.to (Sat.correct (p t)) ⟨$⟩ (t , P.refl , p-lemma t) η : ∀ {t} (t∈ : t ∈ tok t · [ t ]) → t∈ ≡ complete {t = t} η {t = t} t∈ = H.≅-to-≡ $ helper t∈ P.refl where helper₂ : (t∈ : t ∈ Sat.ok {Tok = Tok} (p t t) · []) → t∈ ≡ Inverse.to (Sat.ok-correct (p t t)) ⟨$⟩ (P.refl , p-lemma t) helper₂ t∈ with t ≟ t helper₂ S.return | yes P.refl = P.refl helper₂ t∈ | no t≢t with t≢t P.refl helper₂ t∈ | no t≢t | () helper : ∀ {s} (t∈ : t ∈ tok t · s) → s ≡ [ t ] → t∈ ≅ complete {t = t} helper (S.token >>= t∈) P.refl rewrite helper₂ t∈ = H.refl ------------------------------------------------------------------------ -- Map then choice -- y ∈ ⋁ f xs · s iff ∃ x ∈ xs. y ∈ f x · s. ⋁ : ∀ {Tok R₁ R₂} {f : R₁ → List R₂} → ((x : R₁) → Parser Tok R₂ (f x)) → (xs : List R₁) → Parser Tok R₂ (xs >>=′ f) ⋁ f xs = return⋆ xs >>= f module ⋁ where sound : ∀ {Tok R₁ R₂ y s} {i : R₁ → List R₂} → (f : (x : R₁) → Parser Tok R₂ (i x)) (xs : List R₁) → y ∈ ⋁ f xs · s → ∃ λ x → (x ∈ xs) × (y ∈ f x · s) sound f xs (∈ret⋆ >>= y∈fx) with Return⋆.sound xs ∈ret⋆ ... | (P.refl , x∈xs) = (_ , x∈xs , y∈fx) complete : ∀ {Tok R₁ R₂ x y s} {i : R₁ → List R₂} → (f : (x : R₁) → Parser Tok R₂ (i x)) {xs : List R₁} → x ∈ xs → y ∈ f x · s → y ∈ ⋁ f xs · s complete f x∈xs y∈fx = [ ○ - ○ ] Return⋆.complete x∈xs >>= y∈fx complete∘sound : ∀ {Tok R₁ R₂ y s} {i : R₁ → List R₂} → (f : (x : R₁) → Parser Tok R₂ (i x)) (xs : List R₁) (y∈⋁fxs : y ∈ ⋁ f xs · s) → let p = proj₂ $ sound f xs y∈⋁fxs in complete f (proj₁ p) (proj₂ p) ≡ y∈⋁fxs complete∘sound f xs (∈ret⋆ >>= y∈fx) with Return⋆.sound xs ∈ret⋆ | Inverse.right-inverse-of Return⋆.correct ∈ret⋆ complete∘sound f xs (.(Return⋆.complete x∈xs) >>= y∈fx) | (P.refl , x∈xs) | P.refl = P.refl sound∘complete : ∀ {Tok R₁ R₂ x y s} {i : R₁ → List R₂} → (f : (x : R₁) → Parser Tok R₂ (i x)) {xs : List R₁} → (x∈xs : x ∈ xs) (y∈fx : y ∈ f x · s) → sound f xs (complete f x∈xs y∈fx) ≡ (x , x∈xs , y∈fx) sound∘complete {Tok} f {xs} x∈xs y∈fx with Return⋆.sound {Tok = Tok} xs (Return⋆.complete x∈xs) | Inverse.left-inverse-of (Return⋆.correct {Tok = Tok}) (P.refl , x∈xs) ... | (P.refl , .x∈xs) | P.refl = P.refl ------------------------------------------------------------------------ -- Digits and numbers -- Digits. digit = sat (λ t → if in-range t then just (to-number t) else nothing) where in-range : Char → Bool in-range t = ⌊ Char.toℕ '0' ≤? Char.toℕ t ⌋ ∧ ⌊ Char.toℕ t ≤? Char.toℕ '9' ⌋ to-number : Char → ℕ to-number t = Char.toℕ t ∸ Char.toℕ '0' -- Numbers. number : Parser Char ℕ _ number = digit + >>= (return ∘ foldl (λ n d → 10 * n + d) 0)
{ "alphanum_fraction": 0.4789083358, "avg_line_length": 33.9134808853, "ext": "agda", "hexsha": "c73a67d76fe4835ede902dabb05f1847d6dfdfcc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalParserCombinators/Lib.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/Lib.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/Lib.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 6383, "size": 16855 }
{- Definition of various kinds of categories. This library follows the UniMath terminology, that is: Concept Ob C Hom C Univalence Precategory Type Type No Category Type Set No Univalent Category Type Set Yes The most useful notion is Category and the library is hence based on them. If one needs precategories then they can be found in Cubical.Categories.Category.Precategory -} {-# OPTIONS --safe #-} module Cubical.Categories.Category where open import Cubical.Categories.Category.Base public open import Cubical.Categories.Category.Properties public
{ "alphanum_fraction": 0.7163232964, "avg_line_length": 28.6818181818, "ext": "agda", "hexsha": "f92b528338ef30a704bf4eeba5ffe937b03332de", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Categories/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Categories/Category.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Categories/Category.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 135, "size": 631 }
{-# OPTIONS --without-K --safe #-} open import Algebra open import Relation.Unary open import Relation.Binary hiding (Decidable) module Data.FingerTree.Split.StoredPredicate {r m} (ℳ : Monoid r m) {s} {ℙ : Pred (Monoid.Carrier ℳ) s} (ℙ-resp : ℙ Respects (Monoid._≈_ ℳ)) (ℙ? : Decidable ℙ) where open Monoid ℳ renaming (Carrier to 𝓡) open import Level using (_⊔_) open import Relation.Nullary infixl 2 _≈ℙ_[_] record ⟪ℙ⟫ (x : 𝓡) : Set (s ⊔ r ⊔ m) where constructor _≈ℙ_[_] field result : Dec (ℙ x) stored : 𝓡 equiv : stored ≈ x open ⟪ℙ⟫ public ⟪ℙ?⟫ : ∀ x → ⟪ℙ⟫ x result (⟪ℙ?⟫ x) = ℙ? x stored (⟪ℙ?⟫ x) = x equiv (⟪ℙ?⟫ x) = refl
{ "alphanum_fraction": 0.6189759036, "avg_line_length": 20.1212121212, "ext": "agda", "hexsha": "74221fdc9e9f87229373438931aa2d5564d0725c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_path": "src/Data/FingerTree/Split/StoredPredicate.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-indexed-fingertree", "max_issues_repo_path": "src/Data/FingerTree/Split/StoredPredicate.agda", "max_line_length": 46, "max_stars_count": 1, "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_path": "src/Data/FingerTree/Split/StoredPredicate.agda", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "num_tokens": 287, "size": 664 }
------------------------------------------------------------------------ -- Commutative semirings with some additional structure ("almost" -- commutative rings), used by the ring solver ------------------------------------------------------------------------ module Algebra.RingSolver.AlmostCommutativeRing where open import Relation.Binary open import Algebra open import Algebra.Structures open import Algebra.FunctionProperties open import Algebra.Morphism open import Data.Function ------------------------------------------------------------------------ -- Definitions record IsAlmostCommutativeRing {A} (_≈_ : Rel A) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set where field isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# -‿pres-≈ : -_ Preserves _≈_ ⟶ _≈_ -‿*-distribˡ : ∀ x y → ((- x) * y) ≈ (- (x * y)) -‿+-comm : ∀ x y → ((- x) + (- y)) ≈ (- (x + y)) open IsCommutativeSemiring isCommutativeSemiring public record AlmostCommutativeRing : Set₁ where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field carrier : Set _≈_ : Rel carrier _+_ : Op₂ carrier _*_ : Op₂ carrier -_ : Op₁ carrier 0# : carrier 1# : carrier isAlmostCommutativeRing : IsAlmostCommutativeRing _≈_ _+_ _*_ -_ 0# 1# open IsAlmostCommutativeRing isAlmostCommutativeRing public commutativeSemiring : CommutativeSemiring commutativeSemiring = record { isCommutativeSemiring = isCommutativeSemiring } open CommutativeSemiring commutativeSemiring public using ( setoid ; +-semigroup; +-monoid; +-commutativeMonoid ; *-semigroup; *-monoid; *-commutativeMonoid ; semiring ) rawRing : RawRing rawRing = record { _≈_ = _≈_ ; _+_ = _+_ ; _*_ = _*_ ; -_ = -_ ; 0# = 0# ; 1# = 1# } ------------------------------------------------------------------------ -- Homomorphisms _-Raw-AlmostCommutative⟶_ : RawRing → AlmostCommutativeRing → Set from -Raw-AlmostCommutative⟶ to = from -RawRing⟶ rawRing to where open AlmostCommutativeRing -raw-almostCommutative⟶ : ∀ r → AlmostCommutativeRing.rawRing r -Raw-AlmostCommutative⟶ r -raw-almostCommutative⟶ r = record { ⟦_⟧ = id ; +-homo = λ _ _ → refl ; *-homo = λ _ _ → refl ; -‿homo = λ _ → refl ; 0-homo = refl ; 1-homo = refl } where open AlmostCommutativeRing r ------------------------------------------------------------------------ -- Conversions -- Commutative rings are almost commutative rings. fromCommutativeRing : CommutativeRing → AlmostCommutativeRing fromCommutativeRing cr = record { isAlmostCommutativeRing = record { isCommutativeSemiring = isCommutativeSemiring ; -‿pres-≈ = -‿pres-≈ ; -‿*-distribˡ = -‿*-distribˡ ; -‿+-comm = -‿∙-comm } } where open CommutativeRing cr import Algebra.Props.Ring as R; open R ring import Algebra.Props.AbelianGroup as AG; open AG +-abelianGroup -- Commutative semirings can be viewed as almost commutative rings by -- using identity as the "almost negation". fromCommutativeSemiring : CommutativeSemiring → AlmostCommutativeRing fromCommutativeSemiring cs = record { -_ = id ; isAlmostCommutativeRing = record { isCommutativeSemiring = isCommutativeSemiring ; -‿pres-≈ = id ; -‿*-distribˡ = λ _ _ → refl ; -‿+-comm = λ _ _ → refl } } where open CommutativeSemiring cs
{ "alphanum_fraction": 0.5453572384, "avg_line_length": 31.1416666667, "ext": "agda", "hexsha": "6e08f30d72158334e95ca4efc54d95e92bd982db", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Algebra/RingSolver/AlmostCommutativeRing.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Algebra/RingSolver/AlmostCommutativeRing.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Algebra/RingSolver/AlmostCommutativeRing.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 1098, "size": 3737 }
module Prelude.Nat.Properties where open import Prelude.Bool open import Prelude.Nat.Core open import Prelude.Equality open import Prelude.Semiring suc-inj : ∀ {n m} → suc n ≡ suc m → n ≡ m suc-inj refl = refl --- Addition --- add-zero-r : (n : Nat) → n + 0 ≡ n add-zero-r zero = refl add-zero-r (suc n) = suc $≡ add-zero-r n add-suc-r : (n m : Nat) → n + suc m ≡ suc (n + m) add-suc-r zero m = refl add-suc-r (suc n) m = suc $≡ add-suc-r n m add-commute : (a b : Nat) → a + b ≡ b + a add-commute zero b = sym (add-zero-r _) add-commute (suc a) b = suc $≡ add-commute a b ⟨≡⟩ʳ add-suc-r b _ add-assoc : (a b c : Nat) → a + (b + c) ≡ a + b + c add-assoc zero b c = refl add-assoc (suc a) b c = suc $≡ add-assoc a b c add-inj₂ : (a b c : Nat) → a + b ≡ a + c → b ≡ c add-inj₂ zero b c eq = eq add-inj₂ (suc a) b c eq = add-inj₂ a b c (suc-inj eq) add-inj₁ : (a b c : Nat) → a + c ≡ b + c → a ≡ b add-inj₁ a b c eq = add-inj₂ c a b (add-commute c a ⟨≡⟩ eq ⟨≡⟩ add-commute b c) --- Subtraction --- --- Multiplication --- mul-one-r : (x : Nat) → x * 1 ≡ x mul-one-r zero = refl mul-one-r (suc x) = suc $≡ mul-one-r x mul-zero-r : (x : Nat) → x * 0 ≡ 0 mul-zero-r zero = refl mul-zero-r (suc x) = mul-zero-r x mul-distr-r : (x y z : Nat) → (x + y) * z ≡ x * z + y * z mul-distr-r zero y z = refl mul-distr-r (suc x) y z = z +_ $≡ mul-distr-r x y z ⟨≡⟩ add-assoc z _ _ private shuffle : (a b c d : Nat) → a + b + (c + d) ≡ a + c + (b + d) shuffle a b c d = add-assoc a _ _ ʳ⟨≡⟩ a +_ $≡ (add-assoc b c d ⟨≡⟩ _+ d $≡ add-commute b c ⟨≡⟩ʳ add-assoc c b d) ⟨≡⟩ add-assoc a _ _ mul-distr-l : (x y z : Nat) → x * (y + z) ≡ x * y + x * z mul-distr-l zero y z = refl mul-distr-l (suc x) y z = y + z +_ $≡ mul-distr-l x y z ⟨≡⟩ shuffle y z (x * y) (x * z) mul-assoc : (x y z : Nat) → x * (y * z) ≡ x * y * z mul-assoc zero y z = refl mul-assoc (suc x) y z = y * z +_ $≡ mul-assoc x y z ⟨≡⟩ʳ mul-distr-r y (x * y) z mul-commute : (x y : Nat) → x * y ≡ y * x mul-commute x zero = mul-zero-r x mul-commute x (suc y) = mul-distr-l x 1 y ⟨≡⟩ _+ x * y $≡ mul-one-r x ⟨≡⟩ x +_ $≡ mul-commute x y mul-inj₁ : (x y z : Nat) {{_ : NonZero z}} → x * z ≡ y * z → x ≡ y mul-inj₁ x y zero {{}} mul-inj₁ zero zero (suc z) eq = refl mul-inj₁ zero (suc y) (suc z) () mul-inj₁ (suc x) zero (suc z) () mul-inj₁ (suc x) (suc y) (suc z) eq = suc $≡ mul-inj₁ x y (suc z) (add-inj₂ z _ _ (suc-inj eq)) mul-inj₂ : (x y z : Nat) {{_ : NonZero x}} → x * y ≡ x * z → y ≡ z mul-inj₂ x y z eq = mul-inj₁ y z x (mul-commute y x ⟨≡⟩ eq ⟨≡⟩ mul-commute x z)
{ "alphanum_fraction": 0.5229950589, "avg_line_length": 32.8875, "ext": "agda", "hexsha": "356c41f6c253821e2c4a36025ff75e85db08f15e", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Nat/Properties.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Nat/Properties.agda", "max_line_length": 98, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Nat/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 1168, "size": 2631 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Keys for AVL trees -- the original key type extended with a new -- minimum and maximum. ----------------------------------------------------------------------- {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Data.AVL.Key {a ℓ₁ ℓ₂} (strictTotalOrder : StrictTotalOrder a ℓ₁ ℓ₂) where open import Level open import Data.Empty open import Data.Unit open import Data.Product open import Relation.Binary.PropositionalEquality using (_≡_ ; refl) open import Relation.Nullary.Construct.Add.Extrema as AddExtremaToSet using (_±) open import Relation.Binary.Construct.Add.Extrema.Strict as AddExtremaToOrder using () open StrictTotalOrder strictTotalOrder renaming (Carrier to Key) ----------------------------------------------------------------------- -- Keys are augmented with new extrema (i.e. an artificial minimum and -- maximum) Key⁺ : Set a Key⁺ = Key ± open AddExtremaToSet public using ([_]; [_]-injective) renaming ( ⊥± to ⊥⁺ ; ⊤± to ⊤⁺ ) ----------------------------------------------------------------------- -- The order is extended in a corresponding manner open AddExtremaToOrder _<_ public using () renaming (_<±_ to _<⁺_ ; [_] to [_]ᴿ ; ⊥±<⊤± to ⊥⁺<⊤⁺ ; [_]<⊤± to [_]<⊤⁺ ; ⊥±<[_] to ⊥⁺<[_] ) -- A pair of ordering constraints. infix 4 _<_<_ _<_<_ : Key⁺ → Key → Key⁺ → Set (a ⊔ ℓ₂) l < x < u = l <⁺ [ x ] × [ x ] <⁺ u -- Properties ⊥⁺<[_]<⊤⁺ : ∀ k → ⊥⁺ < k < ⊤⁺ ⊥⁺<[ k ]<⊤⁺ = ⊥⁺<[ k ] , [ k ]<⊤⁺ trans⁺ : ∀ l {m u} → l <⁺ m → m <⁺ u → l <⁺ u trans⁺ l = AddExtremaToOrder.<±-trans _<_ trans
{ "alphanum_fraction": 0.518694362, "avg_line_length": 24.7794117647, "ext": "agda", "hexsha": "eb8a9f5e3e8f281019740c022ff17eb29ef80040", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Key.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Key.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Key.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 534, "size": 1685 }
open import Data.Nat ten : ℕ ten = 10
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 7.8, "ext": "agda", "hexsha": "fe431f2166cdf7f8127a6bfa80fec274235726ad", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "supeterlau/bedev", "max_forks_repo_path": "agda/nats.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "supeterlau/bedev", "max_issues_repo_path": "agda/nats.agda", "max_line_length": 20, "max_stars_count": null, "max_stars_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "supeterlau/bedev", "max_stars_repo_path": "agda/nats.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 15, "size": 39 }
module Data.Collection.Inclusion where open import Data.Collection.Equivalence open import Data.Collection.Core open import Function using (id; _∘_) open import Function.Equivalence using (equivalence) open import Level using (Level; suc; zero) open import Relation.Unary hiding (_⇒_) open import Relation.Binary open import Relation.Binary.PropositionalEquality ≋⇒⊆ : _≋_ ⇒ _⊆_ ≋⇒⊆ P≋Q ∈P = nach P≋Q ∈P ⊆-Transitive : ∀ {a ℓ} {A : Set a} → Transitive {_} {_} {Pred A ℓ} _⊆_ ⊆-Transitive P⊆Q Q⊆R = Q⊆R ∘ P⊆Q ⊆-IsPreorder : IsPreorder _≋_ _⊆_ ⊆-IsPreorder = record { isEquivalence = ≋-IsEquivalence ; reflexive = ≋⇒⊆ ; trans = ⊆-Transitive } ⊆-Preorder : Preorder _ _ _ ⊆-Preorder = record { Carrier = Pred String zero ; _≈_ = _≋_ ; _∼_ = _⊆_ ; isPreorder = ⊆-IsPreorder } ⊆-Antisymmetric : Antisymmetric _≋_ _⊆_ ⊆-Antisymmetric P⊆Q Q⊆P = equivalence P⊆Q Q⊆P ⊆-IsPartialOrder : IsPartialOrder _≋_ _⊆_ ⊆-IsPartialOrder = record { isPreorder = ⊆-IsPreorder ; antisym = ⊆-Antisymmetric } ⊆-Poset : Poset _ _ _ ⊆-Poset = record { Carrier = Pred String zero ; _≈_ = _≋_ ; _≤_ = _⊆_ ; isPartialOrder = ⊆-IsPartialOrder } -------------------------------------------------------------------------------- -- Conditional Inclusion -------------------------------------------------------------------------------- _⊆[_]_ : ∀ {a ℓ₀ ℓ₁ ℓ₂} {A : Set a} → Pred A ℓ₀ → Pred A ℓ₁ → Pred A ℓ₂ → Set _ A ⊆[ P ] B = ∀ {x} → x ∈ P → x ∈ A → x ∈ B _⊈[_]_ : ∀ {a ℓ₀ ℓ₁ ℓ₂} {A : Set a} → Pred A ℓ₀ → Pred A ℓ₁ → Pred A ℓ₂ → Set _ A ⊈[ P ] B = ∀ {x} → x ∈ P → x ∉ A → x ∉ B -- prefix version of _⊆[_]_, with the predicate being the first argument [_]⊆ : ∀ {a ℓ₀ ℓ₁ ℓ₂} {A : Set a} → Pred A ℓ₁ → Pred A ℓ₀ → Pred A ℓ₂ → Set _ [ P ]⊆ A B = A ⊆[ P ] B ≋[]⇒⊆[] : ∀ {a} {P : Pred Element a} → [ P ]≋ ⇒ [ P ]⊆ ≋[]⇒⊆[] A≋B = nach ∘ A≋B ⊆[]-Transitive : ∀ {a ℓ} {P : Pred Element a} → Transitive {_} {_} {Pred String ℓ} [ P ]⊆ ⊆[]-Transitive A⊆B B⊆C ∈P = B⊆C ∈P ∘ A⊆B ∈P ⊆[]-IsPreorder : ∀ {a} {P : Pred Element a} → IsPreorder [ P ]≋ [ P ]⊆ ⊆[]-IsPreorder = record { isEquivalence = ≋[]-IsEquivalence ; reflexive = ≋[]⇒⊆[] ; trans = ⊆[]-Transitive } ⊆[]-Preorder : ∀ {a} {P : Pred Element a} → Preorder _ _ _ ⊆[]-Preorder {_} {P} = record { Carrier = Pred String zero ; _≈_ = [ P ]≋ ; _∼_ = [ P ]⊆ ; isPreorder = ⊆[]-IsPreorder } ⊆[]-Antisymmetric : ∀ {a} {P : Pred Element a} → Antisymmetric [ P ]≋ [ P ]⊆ ⊆[]-Antisymmetric P⊆Q Q⊆P ∈P = equivalence (P⊆Q ∈P) (Q⊆P ∈P) ⊆[]-IsPartialOrder : ∀ {a} {P : Pred Element a} → IsPartialOrder [ P ]≋ [ P ]⊆ ⊆[]-IsPartialOrder = record { isPreorder = ⊆[]-IsPreorder ; antisym = ⊆[]-Antisymmetric } ⊆[]-Poset : ∀ {a} {P : Pred Element a} → Poset _ _ _ ⊆[]-Poset {_} {P} = record { Carrier = Pred String zero ; _≈_ = [ P ]≋ ; _≤_ = [ P ]⊆ ; isPartialOrder = ⊆[]-IsPartialOrder }
{ "alphanum_fraction": 0.5319727891, "avg_line_length": 28.5436893204, "ext": "agda", "hexsha": "2e3752dc3fed438710e561ba0075c5ee7992bd67", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/lambda-calculus", "max_forks_repo_path": "Data/Collection/Inclusion.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/lambda-calculus", "max_issues_repo_path": "Data/Collection/Inclusion.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/lambda-calculus", "max_stars_repo_path": "Data/Collection/Inclusion.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1298, "size": 2940 }
{-# OPTIONS --without-K #-} module well-typed-syntax-pre-interpreter where open import common public open import well-typed-syntax open import well-typed-syntax-helpers max-level : Level max-level = lsuc lzero module inner (context-pick-if' : ∀ ℓ (P : Context → Set ℓ) (Γ : Context) (dummy : P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)) (val : P Γ) → P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)) (context-pick-if-refl' : ∀ ℓ P dummy val → context-pick-if' ℓ P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’) dummy val ≡ val) where context-pick-if : ∀ {ℓ} {P : Context → Set ℓ} {Γ : Context} (dummy : P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)) (val : P Γ) → P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’) context-pick-if {P = P} dummy val = context-pick-if' _ P _ dummy val context-pick-if-refl : ∀ {ℓ P dummy val} → context-pick-if {ℓ} {P} {ε ▻ ‘Σ’ ‘Context’ ‘Typ’} dummy val ≡ val context-pick-if-refl {P = P} = context-pick-if-refl' _ P _ _ private dummy : Typ ε dummy = ‘Context’ cast-helper : ∀ {X T A} {x : Term X} → A ≡ T → Term {ε} (T ‘’ x ‘→'’ A ‘’ x) cast-helper refl = ‘λ∙’ ‘VAR₀’ cast'-proof : ∀ {T} → Term {ε} (context-pick-if {P = Typ} (W dummy) T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T ‘→'’ T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T) cast'-proof {T} = cast-helper {‘Σ’ ‘Context’ ‘Typ’} {context-pick-if {P = Typ} {ε ▻ ‘Σ’ ‘Context’ ‘Typ’} (W dummy) T} {T} (sym (context-pick-if-refl {P = Typ} {dummy = W dummy})) cast-proof : ∀ {T} → Term {ε} (T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T ‘→'’ context-pick-if {P = Typ} (W dummy) T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T) cast-proof {T} = cast-helper {‘Σ’ ‘Context’ ‘Typ’} {T} {context-pick-if {P = Typ} {ε ▻ ‘Σ’ ‘Context’ ‘Typ’} (W dummy) T} (context-pick-if-refl {P = Typ} {dummy = W dummy}) ‘idfun’ : ∀ {T} → Term {ε} (T ‘→'’ T) ‘idfun’ = ‘λ∙’ ‘VAR₀’ mutual Context⇓ : (Γ : Context) → Set (lsuc max-level) Typ⇓ : {Γ : Context} → Typ Γ → Context⇓ Γ → Set max-level Context⇓ ε = ⊤ Context⇓ (Γ ▻ T) = Σ (Context⇓ Γ) (λ Γ' → Typ⇓ T Γ') Typ⇓ (T₁ ‘’ x) Γ⇓ = Typ⇓ T₁ (Γ⇓ , Term⇓ x Γ⇓) Typ⇓ (T₂ ‘’₁ a) (Γ⇓ , A⇓) = Typ⇓ T₂ ((Γ⇓ , Term⇓ a Γ⇓) , A⇓) Typ⇓ (T₃ ‘’₂ a) ((Γ⇓ , A⇓) , B⇓) = Typ⇓ T₃ (((Γ⇓ , Term⇓ a Γ⇓) , A⇓) , B⇓) Typ⇓ (T₃ ‘’₃ a) (((Γ⇓ , A⇓) , B⇓) , C⇓) = Typ⇓ T₃ ((((Γ⇓ , Term⇓ a Γ⇓) , A⇓) , B⇓) , C⇓) Typ⇓ (W T₁) (Γ⇓ , _) = Typ⇓ T₁ Γ⇓ Typ⇓ (W1 T₂) ((Γ⇓ , A⇓) , B⇓) = Typ⇓ T₂ (Γ⇓ , B⇓) Typ⇓ (W2 T₃) (((Γ⇓ , A⇓) , B⇓) , C⇓) = Typ⇓ T₃ ((Γ⇓ , B⇓) , C⇓) Typ⇓ (T ‘→’ T₁) Γ⇓ = (T⇓ : Typ⇓ T Γ⇓) → Typ⇓ T₁ (Γ⇓ , T⇓) Typ⇓ ‘Context’ Γ⇓ = Lifted Context Typ⇓ ‘Typ’ (Γ⇓ , T⇓) = Lifted (Typ (lower T⇓)) Typ⇓ ‘Term’ (Γ⇓ , T⇓ , t⇓) = Lifted (Term (lower t⇓)) Typ⇓ (‘Σ’ T T₁) Γ⇓ = Σ (Typ⇓ T Γ⇓) (λ T⇓ → Typ⇓ T₁ (Γ⇓ , T⇓)) Term⇓ : ∀ {Γ : Context} {T : Typ Γ} → Term T → (Γ⇓ : Context⇓ Γ) → Typ⇓ T Γ⇓ Term⇓ (w t) (Γ⇓ , A⇓) = Term⇓ t Γ⇓ Term⇓ (‘λ∙’ t) Γ⇓ T⇓ = Term⇓ t (Γ⇓ , T⇓) Term⇓ (t ‘’ₐ t₁) Γ⇓ = Term⇓ t Γ⇓ (Term⇓ t₁ Γ⇓) Term⇓ ‘VAR₀’ (Γ⇓ , A⇓) = A⇓ Term⇓ (⌜ Γ ⌝c) Γ⇓ = lift Γ Term⇓ (⌜ T ⌝T) Γ⇓ = lift T Term⇓ (⌜ t ⌝t) Γ⇓ = lift t Term⇓ ‘quote-term’ Γ⇓ (lift T⇓) = lift ⌜ T⇓ ⌝t Term⇓ (‘quote-sigma’ {Γ₀} {Γ₁}) Γ⇓ (lift Γ , lift T) = lift (‘existT’ {Γ₁} ⌜ Γ ⌝c ⌜ T ⌝T) Term⇓ ‘cast’ Γ⇓ T⇓ = lift (context-pick-if {P = Typ} {lower (Σ.proj₁ T⇓)} (W dummy) (lower (Σ.proj₂ T⇓))) Term⇓ (SW t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp-weakenTyp1-VAR₀ t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp-tProd-inv t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp-weakenTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp1-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp1-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp2-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp1-substTyp-weakenTyp-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-weakenTyp-substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp2-substTyp1-substTyp-weakenTyp-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp2-substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp2-substTyp1-substTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp2-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-weakenTyp-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-substTyp-weakenTyp1-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-substTyp-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp-substTyp-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp-substTyp-weakenTyp1-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp-weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp3-substTyp2-substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp2-substTyp1-substTyp-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-substTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp2-substTyp-substTyp-weakenTyp1-weakenTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-substTyp-weakenTyp2-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (beta-under-subst t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ ‘proj₁'’ Γ⇓ (x , p) = x Term⇓ ‘proj₂'’ (Γ⇓ , (x , p)) = p Term⇓ (‘existT’ x p) Γ⇓ = Term⇓ x Γ⇓ , Term⇓ p Γ⇓ Term⇓ (f ‘‘’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘’ lower (Term⇓ x Γ⇓)) Term⇓ (f w‘‘’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘’ lower (Term⇓ x Γ⇓)) Term⇓ (f ‘‘→'’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘→'’ lower (Term⇓ x Γ⇓)) Term⇓ (f w‘‘→'’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘→'’ lower (Term⇓ x Γ⇓)) Term⇓ (w→ x) Γ⇓ A⇓ = Term⇓ x (Σ.proj₁ Γ⇓) A⇓ Term⇓ w‘‘→'’’→‘‘→'’’ Γ⇓ T⇓ = T⇓ Term⇓ ‘‘→'’’→w‘‘→'’’ Γ⇓ T⇓ = T⇓ Term⇓ ‘tApp-nd’ Γ⇓ f⇓ x⇓ = lift (SW (lower f⇓ ‘’ₐ lower x⇓)) Term⇓ ⌜←'⌝ Γ⇓ T⇓ = T⇓ Term⇓ ⌜→'⌝ Γ⇓ T⇓ = T⇓ Term⇓ (‘‘fcomp-nd’’ {A} {B} {C}) Γ⇓ g⇓ f⇓ = lift (_‘∘’_ {ε} (lower g⇓) (lower f⇓)) Term⇓ (⌜‘’⌝ {B} {A} {b}) Γ⇓ = lift (‘λ∙’ {ε} (‘VAR₀’ {ε} {_‘’_ {ε} A b})) Term⇓ (⌜‘’⌝' {B} {A} {b}) Γ⇓ = lift (‘λ∙’ {ε} (‘VAR₀’ {ε} {_‘’_ {ε} A b})) Term⇓ (‘cast-refl’ {T}) Γ⇓ = lift (cast-proof {T}) Term⇓ (‘cast-refl'’ {T}) Γ⇓ = lift (cast'-proof {T}) Term⇓ (‘s→→’ {T} {B} {b} {c} {v}) Γ⇓ = lift (‘idfun’ {_‘’_ {ε} (lower (Term⇓ b tt (Term⇓ v Γ⇓))) (lower (Term⇓ c tt (Term⇓ v Γ⇓)))}) Term⇓ (‘s←←’ {T} {B} {b} {c} {v}) Γ⇓ = lift (‘idfun’ {_‘’_ {ε} (lower (Term⇓ b tt (Term⇓ v Γ⇓))) (lower (Term⇓ c tt (Term⇓ v Γ⇓)))})
{ "alphanum_fraction": 0.4813411897, "avg_line_length": 51.2805755396, "ext": "agda", "hexsha": "8b595a714e96453efcf686669aa21f9dd0569ab9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JasonGross/lob", "max_forks_repo_path": "internal/well-typed-syntax-pre-interpreter.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JasonGross/lob", "max_issues_repo_path": "internal/well-typed-syntax-pre-interpreter.agda", "max_line_length": 136, "max_stars_count": 19, "max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JasonGross/lob", "max_stars_repo_path": "internal/well-typed-syntax-pre-interpreter.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z", "num_tokens": 3912, "size": 7128 }
-- Andreas, 2016-06-20 -- Issue #191, reported 2009-12-02 by Nisse data T (A : Set) : Set → Set1 where c₁ : {B : Set} → T A B c₂ : T A A foo : {A B C : Set} → T A (B → C) → T A B → Set₁ foo c₁ y = Set foo x y = {!y!} -- WAS: -- Perform the indicated case split. Agda will happily replace the -- last clause with two separate clauses, one for each constructor -- of T, but the resulting file is not type correct: -- Bug.agda:8,1-10,13 -- Cannot split on the constructor c₂ -- when checking the definition of foo -- In this case Agda should not modify the source file, it is -- preferable to just give an error indicating that the split cannot -- be performed. -- NOW (Agda-2.5.2): -- I'm not sure if there should be a case for the constructor c₂, -- because I get stuck when trying to solve the following unification -- problems (inferred index ≟ expected index): -- A ≟ A → C -- when checking that the expression ? has type Set₁ -- Current behavior (not splitting) is correct.
{ "alphanum_fraction": 0.6719840479, "avg_line_length": 30.3939393939, "ext": "agda", "hexsha": "8c677386669f50212cd83aa3c4ffde8cc59a436b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue191.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/interaction/Issue191.agda", "max_line_length": 69, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/interaction/Issue191.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 297, "size": 1003 }
------------------------------------------------------------------------ -- Equivalence relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Equivalence-relation {e⁺} (eq : ∀ {a p} → Equality-with-J a p e⁺) where open Derived-definitions-and-properties eq open import Prelude open import H-level eq open import H-level.Closure eq private variable a r r₁ r₂ : Level A A₁ A₂ B B₁ B₂ C : Type a R R₁ R₂ : A → B → Type r ------------------------------------------------------------------------ -- The definition -- The definition of "equivalence relation". record Is-equivalence-relation {A : Type a} (R : A → A → Type r) : Type (a ⊔ r) where field reflexive : ∀ {x} → R x x symmetric : ∀ {x y} → R x y → R y x transitive : ∀ {x y z} → R x y → R y z → R x z ------------------------------------------------------------------------ -- Some examples of equivalence relations/equivalence relation -- transformers -- A trivial binary relation. Trivial : A → B → Type r Trivial _ _ = ↑ _ ⊤ -- Homogeneous instances of Trivial are equivalence relations. Trivial-is-equivalence-relation : Is-equivalence-relation (Trivial {A = A} {r = r}) Trivial-is-equivalence-relation = _ -- Trivial is propositional. Trivial-is-propositional : {x y : A} → Is-proposition (Trivial {r = r} x y) Trivial-is-propositional = ↑-closure 1 (mono₁ 0 ⊤-contractible) -- The superscript P used in the names of the definitions in this -- section stands for "pointwise". -- Lifts binary relations from B to A → B. infix 0 _→ᴾ_ _→ᴾ_ : (A : Type a) → (B → C → Type r) → ((A → B) → (A → C) → Type (a ⊔ r)) (_ →ᴾ R) f g = ∀ x → R (f x) (g x) -- _→ᴾ_ preserves equivalence relations. →ᴾ-preserves-Is-equivalence-relation : Is-equivalence-relation R → Is-equivalence-relation (A →ᴾ R) →ᴾ-preserves-Is-equivalence-relation R-equiv = record { reflexive = λ _ → reflexive ; symmetric = λ f∼g x → symmetric (f∼g x) ; transitive = λ f∼g g∼h x → transitive (f∼g x) (g∼h x) } where open Is-equivalence-relation R-equiv -- _→ᴾ_ preserves Is-proposition (assuming extensionality). →ᴾ-preserves-Is-proposition : {A : Type a} (R : B → C → Type r) → Extensionality a r → (∀ {x y} → Is-proposition (R x y)) → ∀ {f g} → Is-proposition ((A →ᴾ R) f g) →ᴾ-preserves-Is-proposition _ ext R-prop = Π-closure ext 1 λ _ → R-prop -- Lifts binary relations from A and B to A ⊎ B. infixr 1 _⊎ᴾ_ _⊎ᴾ_ : (A₁ → A₂ → Type r) → (B₁ → B₂ → Type r) → (A₁ ⊎ B₁ → A₂ ⊎ B₂ → Type r) (P ⊎ᴾ Q) (inj₁ x) (inj₁ y) = P x y (P ⊎ᴾ Q) (inj₂ x) (inj₂ y) = Q x y (P ⊎ᴾ Q) _ _ = ⊥ -- _⊎ᴾ_ preserves Is-equivalence-relation. ⊎ᴾ-preserves-Is-equivalence-relation : Is-equivalence-relation R₁ → Is-equivalence-relation R₂ → Is-equivalence-relation (R₁ ⊎ᴾ R₂) ⊎ᴾ-preserves-Is-equivalence-relation R₁-equiv R₂-equiv = record { reflexive = λ { {x = inj₁ _} → reflexive R₁-equiv ; {x = inj₂ _} → reflexive R₂-equiv } ; symmetric = λ { {x = inj₁ _} {y = inj₁ _} → symmetric R₁-equiv ; {x = inj₂ _} {y = inj₂ _} → symmetric R₂-equiv ; {x = inj₁ _} {y = inj₂ _} () ; {x = inj₂ _} {y = inj₁ _} () } ; transitive = λ { {x = inj₁ _} {y = inj₁ _} {z = inj₁ _} → transitive R₁-equiv ; {x = inj₂ _} {y = inj₂ _} {z = inj₂ _} → transitive R₂-equiv ; {x = inj₁ _} {y = inj₂ _} () ; {x = inj₂ _} {y = inj₁ _} () ; {y = inj₁ _} {z = inj₂ _} _ () ; {y = inj₂ _} {z = inj₁ _} _ () } } where open Is-equivalence-relation -- _⊎ᴾ_ preserves Is-proposition. ⊎ᴾ-preserves-Is-proposition : (∀ {x y} → Is-proposition (R₁ x y)) → (∀ {x y} → Is-proposition (R₂ x y)) → ∀ {x y} → Is-proposition ((R₁ ⊎ᴾ R₂) x y) ⊎ᴾ-preserves-Is-proposition = λ where R₁-prop R₂-prop {inj₁ _} {inj₁ _} → R₁-prop R₁-prop R₂-prop {inj₁ _} {inj₂ _} → ⊥-propositional R₁-prop R₂-prop {inj₂ _} {inj₁ _} → ⊥-propositional R₁-prop R₂-prop {inj₂ _} {inj₂ _} → R₂-prop -- Lifts a binary relation from A to Maybe A. Maybeᴾ : (A → B → Type r) → (Maybe A → Maybe B → Type r) Maybeᴾ R = Trivial ⊎ᴾ R -- Maybeᴾ preserves Is-equivalence-relation. Maybeᴾ-preserves-Is-equivalence-relation : Is-equivalence-relation R → Is-equivalence-relation (Maybeᴾ R) Maybeᴾ-preserves-Is-equivalence-relation = ⊎ᴾ-preserves-Is-equivalence-relation Trivial-is-equivalence-relation -- Maybeᴾ preserves Is-proposition. Maybeᴾ-preserves-Is-proposition : (∀ {x y} → Is-proposition (R x y)) → ∀ {x y} → Is-proposition (Maybeᴾ R x y) Maybeᴾ-preserves-Is-proposition = ⊎ᴾ-preserves-Is-proposition λ {x} → Trivial-is-propositional {x = x} -- Lifts binary relations from A and B to A × B. infixr 2 _×ᴾ_ _×ᴾ_ : (A₁ → B₁ → Type r₁) → (A₂ → B₂ → Type r₂) → (A₁ × A₂ → B₁ × B₂ → Type (r₁ ⊔ r₂)) (P ×ᴾ Q) (x₁ , x₂) (y₁ , y₂) = P x₁ y₁ × Q x₂ y₂ -- _×ᴾ_ preserves Is-equivalence-relation. ×ᴾ-preserves-Is-equivalence-relation : Is-equivalence-relation R₁ → Is-equivalence-relation R₂ → Is-equivalence-relation (R₁ ×ᴾ R₂) ×ᴾ-preserves-Is-equivalence-relation R₁-equiv R₂-equiv = λ where .Is-equivalence-relation.reflexive → E₁.reflexive , E₂.reflexive .Is-equivalence-relation.symmetric → Σ-map E₁.symmetric E₂.symmetric .Is-equivalence-relation.transitive → Σ-zip E₁.transitive E₂.transitive where module E₁ = Is-equivalence-relation R₁-equiv module E₂ = Is-equivalence-relation R₂-equiv -- _×ᴾ_ preserves Is-proposition. ×ᴾ-preserves-Is-proposition : (∀ {x y} → Is-proposition (R₁ x y)) → (∀ {x y} → Is-proposition (R₂ x y)) → ∀ {x y} → Is-proposition ((R₁ ×ᴾ R₂) x y) ×ᴾ-preserves-Is-proposition R₁-prop R₂-prop = ×-closure 1 R₁-prop R₂-prop
{ "alphanum_fraction": 0.5834893617, "avg_line_length": 28.5194174757, "ext": "agda", "hexsha": "7acee8c9252da690d8f3320c394ba65421a4de5f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Equivalence-relation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Equivalence-relation.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Equivalence-relation.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 2145, "size": 5875 }
module Types4Crib where open import Basics public _<=_ : Nat -> Nat -> Set ze <= y = One su x <= ze = Zero su x <= su y = x <= y cmp : (x y : Nat) -> (x <= y) + (y <= x) cmp ze y = inl <> cmp (su x) ze = inr <> cmp (su x) (su y) = cmp x y data Bnd : Set where bot : Bnd # : Nat -> Bnd top : Bnd _<B=_ : Bnd -> Bnd -> Set bot <B= _ = One # x <B= # y = x <= y _ <B= top = One _ <B= _ = Zero data T23 (l u : Bnd) : Nat -> Set where leaf : (lu : l <B= u) -> T23 l u ze node2 : forall {h} x (tlx : T23 l (# x) h)(txu : T23 (# x) u h) -> T23 l u (su h) node3 : forall {h} x y (tlx : T23 l (# x) h)(txy : T23 (# x) (# y) h)(tyu : T23 (# y) u h) -> T23 l u (su h) data Intv (l u : Bnd) : Set where intv : (x : Nat)(lx : l <B= # x)(xu : # x <B= u) -> Intv l u TooBig : Bnd -> Bnd -> Nat -> Set TooBig l u h = Sg Nat \ x -> T23 l (# x) h * T23 (# x) u h insert : forall {h l u} -> Intv l u -> T23 l u h -> TooBig l u h + T23 l u h insert (intv x lx xu) (leaf lu) = inl (x , (leaf lx , leaf xu)) insert (intv x lx xu) (node2 y tly tyu) with cmp x y insert (intv x lx xu) (node2 y tly tyu) | inl xy with insert (intv x lx xy) tly insert (intv x lx xu) (node2 y tly tyu) | inl xy | inl (z , tlz , tzu) = inr (node3 z y tlz tzu tyu) insert (intv x lx xu) (node2 y tly tyu) | inl xy | inr tly' = inr (node2 y tly' tyu) insert (intv x lx xu) (node2 y tly tyu) | inr yx with insert (intv x yx xu) tyu insert (intv x lx xu) (node2 y tly tyu) | inr yx | inl (v , tyv , tvu) = inr (node3 y v tly tyv tvu) insert (intv x lx xu) (node2 y tly tyu) | inr yx | inr tyv' = inr (node2 y tly tyv') insert (intv x lx xu) (node3 y z tly tyz tzu) with cmp x y insert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy with insert (intv x lx xy) tly insert (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) insert (intv x lx xu) (node3 y z tly tyz tzu) | inl xy | inr tly' = inr (node3 y z tly' tyz tzu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx with cmp x z insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz with insert (intv x yx xz) tyz insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz | inl (v , tyv , tvz) = inl (v , node2 y tly tyv , node2 z tvz tzu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inl xz | inr tyz' = inr (node3 y z tly tyz' tzu) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx with insert (intv x zx xu) tzu insert (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) insert (intv x lx xu) (node3 y z tly tyz tzu) | inr yx | inr zx | inr tzu' = inr (node3 y z tly tyz tzu')
{ "alphanum_fraction": 0.5698610095, "avg_line_length": 41.4242424242, "ext": "agda", "hexsha": "608ff6c6725cdf5158af6c4b56dd21cb754106bb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-06-09T05:39:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-09T05:39:02.000Z", "max_forks_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "pigworker/WhatRTypes4", "max_forks_repo_path": "Types4Crib.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "pigworker/WhatRTypes4", "max_issues_repo_path": "Types4Crib.agda", "max_line_length": 131, "max_stars_count": 11, "max_stars_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "pigworker/WhatRTypes4", "max_stars_repo_path": "Types4Crib.agda", "max_stars_repo_stars_event_max_datetime": "2019-06-09T05:38:44.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-11T09:12:25.000Z", "num_tokens": 1236, "size": 2734 }
{-# OPTIONS --safe #-} module Cubical.Algebra.AbGroup.Instances.Direct-Sum where open import Cubical.Foundations.Prelude open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Direct-Sum.Base open import Cubical.Algebra.Direct-Sum.Properties open import Cubical.Algebra.Polynomials.Multivariate.Base private variable ℓ ℓ' : Level module _ (Idx : Type ℓ) (P : Idx → Type ℓ') (AGP : (r : Idx) → AbGroupStr (P r)) where open AbGroupStr ⊕-AbGr : AbGroup (ℓ-max ℓ ℓ') fst ⊕-AbGr = ⊕ Idx P AGP 0g (snd ⊕-AbGr) = neutral _+_ (snd ⊕-AbGr) = _add_ - snd ⊕-AbGr = inv Idx P AGP isAbGroup (snd ⊕-AbGr) = makeIsAbGroup trunc addAssoc addRid (rinv Idx P AGP) addComm
{ "alphanum_fraction": 0.7074235808, "avg_line_length": 26.4230769231, "ext": "agda", "hexsha": "42c4d24bfb64076f9e1bd809781723fecc5fecfd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/AbGroup/Instances/Direct-Sum.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/AbGroup/Instances/Direct-Sum.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/AbGroup/Instances/Direct-Sum.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 245, "size": 687 }
-- Testing the version option when used without type-check the file. -- -- N.B. It is necessary to change the Issue1244b.out file when using -- different versions of Agda.
{ "alphanum_fraction": 0.75, "avg_line_length": 34.4, "ext": "agda", "hexsha": "3aceaaa3c00648935ab9f214236f9d7da74a9f13", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue1244b.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue1244b.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1244b.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 40, "size": 172 }
-- Andreas, 2019-04-30, issue #3731 -- Compiler backend: Do not look for a main function if not the main module. open import Agda.Builtin.Nat module Issue3731 where module M where module main where record R : Set where field main : Nat data Main : Set where main : Main module N where data main : Set where module O where record main : Set where module P where postulate main : Nat module Q where abstract main : Nat main = 1 main : Nat main = 0
{ "alphanum_fraction": 0.6747474747, "avg_line_length": 14.5588235294, "ext": "agda", "hexsha": "cb2bed9957160994358c22a6c78b52b44e81085d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue3731.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue3731.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3731.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 146, "size": 495 }
module Function.Multi.Functions where open import Data import Data.Option.Functions as Option open import Data.Tuple renaming (curry to curry₁ ; uncurry to uncurry₁) using (_⨯_ ; _,_) open import Data.Tuple.Raise import Data.Tuple.Raiseᵣ.Functions as Raise open import Data.Tuple.RaiseTypeᵣ open import Data.Tuple.RaiseTypeᵣ.Functions open import Function.Multi open import Functional using (_→ᶠ_ ; id ; _∘_ ; _∘ᵢₙₛₜ_ ; _⦗_⦘_) renaming (const to const₁ ; apply to apply₁ ; swap to swap₁ ; _$_ to _$₁_) open import Logic import Lvl import Lvl.MultiFunctions as Lvl open import Numeral.Finite open import Numeral.Finite.Bound open import Numeral.Natural open import Syntax.Function open import Syntax.Number open import Type private variable ℓ ℓ₁ ℓ₂ ℓ₃ : Lvl.Level private variable n n₁ n₂ : ℕ private variable ℓ𝓈 ℓ𝓈₁ ℓ𝓈₂ : Lvl.Level ^ n private variable A B C : Type{ℓ} private variable As Bs Cs : Types{n}(ℓ𝓈) -- TODO: Make all n, n₁, n₂ explicit. Find a way to do this while having generalized variables -- TODO: Some of these functions can be generalised to arbitrary categories instead of using the function type (_→_). This makes it possible to skip the specialized variants for different parameter types (e.g. compose and composeᵢₙₛₜ) -- A constant function of many variables. -- Lifts a value to being a number of nested functions. -- Examples: -- const(x) _ _ _ ... = x -- const(x) -- = (const₁ ∘ const₁ ∘ const₁ ∘ ...)(x) -- = (_ ↦ (_ ↦ (_ ↦ x))) -- = (_ ↦ _ ↦ _ ↦ x) const : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → B → (As ⇉ B) const(0) = id const(1) = const₁ const(𝐒(𝐒(n))) = const₁ ∘ const(𝐒(n)) -- A projection function of many variables. -- Returns one of the specified arguments. -- Examples: -- proj(2)(0) x y = x -- proj(2)(1) x y = y -- proj(3)(0) x y z = x -- proj(3)(1) x y z = y -- proj(3)(2) x y z = z -- proj(4)(0) x y z w = x -- proj(4)(1) x y z w = y -- proj(4)(2) x y z w = z -- proj(4)(3) x y z w = w proj : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (i : 𝕟(n)) → (As ⇉ index i As) proj(1) 𝟎 x = x proj(𝐒(𝐒(n))) 𝟎 x = const(𝐒(n)) x proj(𝐒(𝐒(n))) (𝐒(i)) _ = proj(𝐒(n)) i -- Applies a function on the return value of a multivariate function. -- Composes the first argument and the last function of the second argument. -- Can also be seen as lifting the function type to the structure of (As ⇉_). -- Examples: -- f ∘ᵣ g = (((f ∘_) ∘_) ∘_) .. -- ((((f ∘ᵣ g) x₁) x₂) x₃) .. = f((((g x₁) x₂) x₃) ..) -- (f ∘ᵣ g) x₁ x₂ x₃ .. = f(g x₁ x₂ x₃ ..) -- Note: This can be used to specify the `map` function of a functor (As ⇉_). compose : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ₁}{B : Type{ℓ₁}}{ℓ₂}{C : Type{ℓ₂}} → (B → C) → (As ⇉ B) → (As ⇉ C) compose(0) = id compose(1) = _∘_ compose(𝐒(𝐒(n))) f = compose(𝐒(n)) f ∘_ _∘ᵣ_ : ∀{As : Types{n}(ℓ𝓈)}{B : Type{ℓ₁}}{C : Type{ℓ₂}} → (B → C) → (As ⇉ B) → (As ⇉ C) _∘ᵣ_ {n = n} = compose(n) composeᵢₙₛₜ : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ₁}{B : Type{ℓ₁}}{ℓ₂}{C : Type{ℓ₂}} → (B → C) → (As ⇉ᵢₙₛₜ B) → (As ⇉ᵢₙₛₜ C) composeᵢₙₛₜ(0) = id composeᵢₙₛₜ(1) f g = f(g) composeᵢₙₛₜ(𝐒(𝐒(n))) f g = composeᵢₙₛₜ(𝐒(n)) f g -- Puts the second function on every argument of the first function. -- Example: -- (f on g) x₁ x₂ x₃ .. = f (g x₁) (g x₂) (g x₃) .. composeOnEvery : (n : ℕ) → ∀{ℓ₁}{A : Type{ℓ₁}}{ℓ₂}{B : Type{ℓ₂}}{ℓ₃}{C : Type{ℓ₃}} → (repeat n B ⇉ C) → (A → B) → (repeat n A ⇉ C) composeOnEvery 0 = const₁ composeOnEvery 1 = _∘_ composeOnEvery (𝐒(𝐒(n))) f g x = composeOnEvery(𝐒(n)) (f(g(x))) g _on_ : ∀{A : Type{ℓ₁}}{B : Type{ℓ₂}}{C : Type{ℓ₃}} → (repeat n B ⇉ C) → (A → B) → (repeat n A ⇉ C) _on_ {n = n} = composeOnEvery(n) applyTwice : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (As ⇉ As ⇉ B) → (As ⇉ B) applyTwice(0) = id applyTwice(1) f(x) = f(x)(x) applyTwice(𝐒(𝐒(n))) f(x) = applyTwice(𝐒(n)) ((_$₁ x) ∘ᵣ (f(x))) swap : (n₁ n₂ : ℕ) → ∀{ℓ𝓈₁}{As : Types{n₁}(ℓ𝓈₁)}{ℓ𝓈₂}{Bs : Types{n₂}(ℓ𝓈₂)}{ℓ}{C : Type{ℓ}} → (As ⇉ Bs ⇉ C) → (Bs ⇉ As ⇉ C) swap(n₁)(0) = id swap(n₁)(1) f b = (_$₁ b) ∘ᵣ f swap(n₁)(𝐒(𝐒(n₂))) f b = swap(n₁)(𝐒(n₂)) ((_$₁ b) ∘ᵣ f) -- Lifts a function/operator pointwise. -- A generalized variant of `(_∘ᵣ_)` that allows the left function to have multiple arguments. -- Example: -- (f ∘ₗ g₁ g₂ g₃ ...) x₁ x₂ x₃ ... = f (g₁ x₁ x₂ x₃ ...) (g₂ x₁ x₂ x₃ ...) (g₃ x₁ x₂ x₃ ...) ... -- (f ∘ₗ g) x₁ x₂ x₃ ... = (f ∘ᵣ g) x₁ x₂ x₃ ... -- pointwise(1)(2) (_+_) = (f ↦ g ↦ x ↦ f(x) + g(x)) pointwise : (n₁ n₂ : ℕ) → ∀{ℓ𝓈₁}{As : Types{n₁}(ℓ𝓈₁)}{ℓ𝓈₂}{Bs : Types{n₂}(ℓ𝓈₂)}{ℓ}{C : Type{ℓ}} → (Bs ⇉ C) → (map (As ⇉_) Bs) ⇉ (As ⇉ C) pointwise(n₁)(0) = const(n₁) pointwise(n₁)(1) = compose(n₁) pointwise(n₁)(𝐒(𝐒(n₂))) {As = As}{Bs = B , Bs}{C = C} f g = p{n = 𝐒(n₂)} (pointwise(n₁)(𝐒(n₂))) (f ∘ᵣ g) where p : ∀{Ts : Types{n}(ℓ𝓈)} → ((Bs ⇉ C) → (Ts ⇉ As ⇉ C)) → ((As ⇉ Bs ⇉ C) → (Ts ⇉ As ⇉ C)) -- TODO: Is it possible to simplify this helper function? p{n = n}{Ts = Ts} f g = compose(n) (applyTwice(n₁)) (swap(n₁)(n) (compose(n₁) f g)) _∘ₗ : ∀{As : Types{n₁}(ℓ𝓈₁)}{Bs : Types{n₂}(ℓ𝓈₂)}{C : Type{ℓ}} → (Bs ⇉ C) → (map (As ⇉_) Bs) ⇉ (As ⇉ C) _∘ₗ {n₁ = n₁}{n₂ = n₂} = pointwise(n₁)(n₂) -- Converts a function using a tuple to represent its arguments to a curried function (nested function types). -- Example: -- curry((x,y,z,...) ↦ φ) = (x ↦ y ↦ z ↦ ... ↦ φ) -- curry(0) = id : (A₁ → B) → (A₁ → B) -- curry(1) = curry₁ : ((A₁ ⨯ A₂) → B) → (A₁ → A₂ → B) -- curry(2) = curry₁ ∘ curry₁ : ((A₁ ⨯ A₂ ⨯ A₃) → B) → (A₁ → A₂ → A₃ → B) -- curry(3) = curry₁ ∘ curry₁ ∘ curry₁ : ((A₁ ⨯ A₂ ⨯ A₃ ⨯ A₄) → B) → (A₁ → A₂ → A₃ → A₄ → B) -- Note: If there is a nested uncurry and curry, one can often use (_∘ᵣ_) instead (I think?). curry : (n : ℕ) → ∀{ℓ𝓈}{As : Types{𝐒(n)}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (reduceᵣ(_⨯_) As → B) → (As ⇉ B) curry(𝟎) = id curry(𝐒(n)) f x = curry(n) (f ∘ (x ,_)) -- Converts a curried function (nested function types) to a function using a tuple to represent its arguments. -- Example: -- uncurry(x ↦ y ↦ z ↦ ... ↦ φ) = ((x,y,z,...) ↦ φ) uncurry : (n : ℕ) → ∀{ℓ𝓈}{As : Types{𝐒(n)}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (As ⇉ B) → (reduceᵣ(_⨯_) As → B) uncurry(𝟎) = id uncurry(𝐒(n)) f (x , xs) = uncurry(n) (f(x)) xs -- Applies a tuple as arguments to a multivariate function. -- Example: -- apply(x,y,z,...) (x ↦ y ↦ z ↦ ... ↦ φ) = φ applyTuple : (n : ℕ) → ∀{ℓ𝓈}{As : Types{𝐒(n)}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (reduceᵣ(_⨯_) As) → (As ⇉ B) → B applyTuple(n) = swap₁(uncurry(n)) -- Applies an argument to a specific position in the arguments of an argument list of a multivariate function. -- Examples: -- applyAt 0 (x ↦ y ↦ ... ↦ f(x,y)) a = (y ↦ ... ↦ f(a,y)) -- applyAt 1 (x ↦ y ↦ ... ↦ f(x,y)) b = (x ↦ ... ↦ f(x,b)) -- applyAt 0 (x ↦ y ↦ z ↦ ... ↦ f(x,y,z)) a = (y ↦ z ↦ ... ↦ f(a,y,z)) -- applyAt 1 (x ↦ y ↦ z ↦ ... ↦ f(x,y,z)) b = (x ↦ z ↦ ... ↦ f(x,b,z)) -- applyAt 2 (x ↦ y ↦ z ↦ ... ↦ f(x,y,z)) c = (x ↦ y ↦ ... ↦ f(x,y,c)) applyAt : (n : ℕ) → ∀{ℓ𝓈}{As : Types{𝐒(n)}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (i : 𝕟(𝐒(n))) → (index i As) → (As ⇉ B) → (without i As ⇉ B) applyAt(0) 𝟎 xi f = f xi applyAt(1) 𝟎 xi f x = f xi x applyAt(1) (𝐒(𝟎)) xi f x = f x xi applyAt(𝐒(𝐒(n))) 𝟎 xi f xs = f xi xs applyAt(𝐒(𝐒(n))) (𝐒(i)) xi f x = applyAt(𝐒(n)) i xi (f(x)) -- Puts the second and each succeeding functions on the respective arguments of the first function. -- Applies each argument `xₙ` on the inner function `gₙ`, and then apply the value of these as the arguments to an outer function `f`. -- This is similiar to (_on_) but uses different functions for every argument and each argument is applied to its respective function instead. -- Example: -- (onMany(n) f g₁ g₂ g₃ ...) x₁ x₂ x₃ ... = f (g₁ x₁) (g₂ x₂) (g₃ x₃) ... -- TODO: Try to get rid of the curry/uncurry by using (_∘ᵣ_) onEach : (n : ℕ) → ∀{ℓ𝓈₁}{As : Types{n}(ℓ𝓈₁)}{ℓ𝓈₂}{Bs : Types{n}(ℓ𝓈₂)}{C : Type{ℓ}} → (Bs ⇉ C) → (As ⦗ map₂(_→ᶠ_) ⦘ Bs) ⇉ (As ⇉ C) onEach(0) = id onEach(1) = _∘_ onEach(𝐒(𝐒(n))) f g = curry(n) (gs ↦ x ↦ uncurry(n) (onEach(𝐒(n)) (f(g(x)))) gs) -- Note: One of the parts of being an "applicative functor". The other being `const` liftedApply : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ₁}{B : Type{ℓ₁}}{ℓ₂}{C : Type{ℓ₂}} → (As ⇉ (B → C)) → ((As ⇉ B) → (As ⇉ C)) liftedApply(0) = id liftedApply(1) f g x = f x (g x) liftedApply(𝐒(𝐒(n))) f g x = liftedApply(𝐒(n)) (f(x)) (g(x)) lifted-[,] : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ₁}{B : Type{ℓ₁}}{ℓ₂}{C : Type{ℓ₂}} → (As ⇉ B) → (As ⇉ C) → (As ⇉ (B ⨯ C)) lifted-[,](n) f g = liftedApply(n) ((swap₁ _,_) ∘ᵣ g) f -- TODO: How to implement something like this --(F(x) ▫ F(y)) ▫ F(x . y) --_aryᵣFromBinaryOperator_ : (n : ℕ) → ∀{X : Type{ℓ₁}}{Y : Type{ℓ₂}} → (_▫_ : X → Y → X) → -- _aryᵣFromBinaryOperator_ : (n : ℕ) → ∀{F}{_○_} → (_▫_ : ∀{x y} → F(x) → F(y) → F(x ○ y)) → -- _aryᵣFromBinaryOperator_ : (n : ℕ) → ∀{F} → (_▫_ : ∀{x y z} → F(x)(y) → F(y)(z) → F(x)(z)) → -- CategoricalOperator₊ : ℕ → {Obj : Type{ℓ₁}} → (Obj → Obj → Type{ℓ₂}) → Type -- CategoricalOperator₊(0) F = ∀{x₁ x₂} → F(x₁)(x₂) → F(x₁)(x₂) -- CategoricalOperator₊(1) F = ∀{x₁ x₂ x₃} → F(x₂)(x₃) → F(x₁)(x₂) → F(x₁)(x₃) -- CategoricalOperator₊(𝐒(𝐒(n))) F = {!!} -- Nested binary type relations that associate to the right. -- Used to define n-ary binary relations that accepts any types. -- Example: -- binaryTypeRelator₊(4)(_▫_) A B C D = A ▫ (B ▫ (C ▫ D)) -- TODO: It is possible to generalize the levels binaryTypeRelator₊ : (n : ℕ) → (∀{ℓ₁ ℓ₂} → Type{ℓ₁} → Type{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}) → (∀{ℓ} → Type{ℓ}) → ∀{ℓ𝓈} → TypesOfTypes{n}(ℓ𝓈) ⇉ Type{Lvl.⨆(ℓ𝓈)} binaryTypeRelator₊(0) (_▫_) id = id binaryTypeRelator₊(1) (_▫_) _ A = A binaryTypeRelator₊(𝐒(𝐒(n))) (_▫_) id A = compose(𝐒(n)) (A ▫_) (binaryTypeRelator₊(𝐒(n)) (_▫_) id) -- Nested quantifiers over multiple values. -- Used to define nested universal and existential quantifications. -- Example: -- quantifier₊(3) □(P) = □(x ↦ □(y ↦ □(z ↦ P(x)(y)(z)))) quantifier₊ : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (∀{ℓ₁ ℓ₂}{T : Type{ℓ₁}} → (T → Stmt{ℓ₂}) → Stmt{ℓ₁ Lvl.⊔ ℓ₂}) → (As ⇉ Stmt{ℓ}) → Stmt{ℓ Lvl.⊔ (Lvl.⨆(ℓ𝓈))} quantifier₊(0) □(P) = P quantifier₊(1) □(P) = □(P) quantifier₊(𝐒(𝐒(n))) □(P) = □(x ↦ quantifier₊(𝐒(n)) □(P(x))) quantifier₊ᵢₘₚₗ : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (∀{ℓ₁ ℓ₂}{T : Type{ℓ₁}} → (T → Stmt{ℓ₂}) → Stmt{ℓ₁ Lvl.⊔ ℓ₂}) → (As ⇉ᵢₘₚₗ Stmt{ℓ}) → Stmt{ℓ Lvl.⊔ (Lvl.⨆(ℓ𝓈))} quantifier₊ᵢₘₚₗ(0) □(P) = P quantifier₊ᵢₘₚₗ(1) □(P) = □(x ↦ P{x}) quantifier₊ᵢₘₚₗ(𝐒(𝐒(n))) □(P) = □(x ↦ quantifier₊ᵢₘₚₗ(𝐒(n)) □(P{x})) quantifier₊ᵢₙₛₜ : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (∀{ℓ₁ ℓ₂}{T : Type{ℓ₁}} → (T → Stmt{ℓ₂}) → Stmt{ℓ₁ Lvl.⊔ ℓ₂}) → (As ⇉ᵢₙₛₜ Stmt{ℓ}) → Stmt{ℓ Lvl.⊔ (Lvl.⨆(ℓ𝓈))} quantifier₊ᵢₙₛₜ(0) □(P) = P quantifier₊ᵢₙₛₜ(1) □(P) = □(x ↦ P ⦃ x ⦄) quantifier₊ᵢₙₛₜ(𝐒(𝐒(n))) □(P) = □(x ↦ quantifier₊ᵢₙₛₜ(𝐒(n)) □(P ⦃ x ⦄)) quantify : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (As ⇉ Stmt{ℓ}) → Stmt{ℓ Lvl.⊔ (Lvl.⨆(ℓ𝓈))} quantify(n) P = quantifier₊(n) (Pred ↦ (∀(x) → Pred(x))) P quantifyᵢₘₚₗ : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (As ⇉ᵢₘₚₗ Stmt{ℓ}) → Stmt{ℓ Lvl.⊔ (Lvl.⨆(ℓ𝓈))} quantifyᵢₘₚₗ(n) P = quantifier₊ᵢₘₚₗ(n) (Pred ↦ (∀{x} → Pred(x))) P quantifyᵢₙₛₜ : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (As ⇉ᵢₙₛₜ Stmt{ℓ}) → Stmt{ℓ Lvl.⊔ (Lvl.⨆(ℓ𝓈))} quantifyᵢₙₛₜ(n) P = quantifier₊ᵢₙₛₜ(n) (Pred ↦ (∀ ⦃ x ⦄ → Pred(x))) P quantifierSpecific : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (∀{i} → (index i As → Stmt{ℓ}) → Stmt{ℓ}) → (As ⇉ Stmt{ℓ}) → Stmt{ℓ} quantifierSpecific(0) □(P) = P quantifierSpecific(1) □(P) = □{𝟎}(P) quantifierSpecific(𝐒(𝐒(n))) □(P) = □{𝟎}(x ↦ quantifierSpecific(𝐒(n)) (\{i} → □{𝐒(i)})(P(x))) {- TODO: MOre general levels quantifierSpecific : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (∀{i} → (index i As → Stmt{Raise.index i ℓ𝓈}) → Stmt{ℓ}) → (As ⇉ Stmt{Lvl.⨆(ℓ𝓈)}) → Stmt{(Raise.head₀ ℓ𝓈) Option.or ℓ} quantifierSpecific(0) □(P) = {!!} quantifierSpecific(1) □(P) = □{𝟎}(P) quantifierSpecific(𝐒(𝐒(n))) □(P) = □{𝟎}(x ↦ {!quantifierSpecific(𝐒(n)) (\{i} → □{𝐒(i)})(P(x))!}) -} expl-to-impl : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (As ⇉ B) → (As ⇉ᵢₘₚₗ B) expl-to-impl 0 f = f expl-to-impl 1 f{x} = f(x) expl-to-impl (𝐒(𝐒(n))) f{x} = expl-to-impl(𝐒(n)) (f(x)) expl-to-inst : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (As ⇉ B) → (As ⇉ᵢₙₛₜ B) expl-to-inst 0 f = f expl-to-inst 1 f ⦃ x ⦄ = f(x) expl-to-inst (𝐒(𝐒(n))) f ⦃ x ⦄ = expl-to-inst(𝐒(n)) (f(x)) impl-to-expl : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (As ⇉ᵢₘₚₗ B) → (As ⇉ B) impl-to-expl 0 f = f impl-to-expl 1 f(x) = f{x} impl-to-expl (𝐒(𝐒(n))) f(x) = impl-to-expl(𝐒(n)) (f{x}) inst-to-expl : (n : ℕ) → ∀{ℓ𝓈}{As : Types{n}(ℓ𝓈)}{ℓ}{B : Type{ℓ}} → (As ⇉ᵢₙₛₜ B) → (As ⇉ B) inst-to-expl 0 f = f inst-to-expl 1 f(x) = f ⦃ x ⦄ inst-to-expl (𝐒(𝐒(n))) f(x) = inst-to-expl(𝐒(n)) (f ⦃ x ⦄)
{ "alphanum_fraction": 0.5305100182, "avg_line_length": 51.874015748, "ext": "agda", "hexsha": "efe7c7112426dac2b0d3b367c5a262e4d534e8b5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Function/Multi/Functions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Function/Multi/Functions.agda", "max_line_length": 234, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Function/Multi/Functions.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 6600, "size": 13176 }
open import Mockingbird.Forest using (Forest) -- Gödel's Forest module Mockingbird.Problems.Chapter17 {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Empty using (⊥-elim) open import Data.Product using (_×_; _,_; proj₁; proj₂; ∃-syntax) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Function using (_$_; _⇔_; Equivalence; mk⇔) open import Function.Equivalence.Reasoning renaming (begin_ to ⇔-begin_; _∎ to _⇔-∎) open import Level using (_⊔_) open import Relation.Binary using (_Respects_) open import Relation.Nullary using (¬_) open import Relation.Unary using (Pred; _∈_) open Forest forest open import Mockingbird.Problems.Chapter15 forest using (⇔-¬; ⇔-↯) record HasMate {s} (Sings : Pred Bird s) : Set (s ⊔ b) where field _′ : Bird → Bird isMate : ∀ {x} y → Sings (x ′ ∙ y) ⇔ (¬ Sings (x ∙ y)) open HasMate ⦃ ... ⦄ record HasAssociate {s} (Sings : Pred Bird s) : Set (s ⊔ b) where field _* : Bird → Bird isAssociate : ∀ {x} y → Sings (x * ∙ y) ⇔ Sings (x ∙ (y ∙ y)) open HasAssociate ⦃ ... ⦄ weakLEM : ∀ {a} (A : Set a) → ¬ ¬ (A ⊎ ¬ A) weakLEM A ¬[A⊎¬A] = let ¬A : ¬ A ¬A a = ¬[A⊎¬A] (inj₁ a) A⊎¬A : A ⊎ ¬ A A⊎¬A = inj₂ ¬A in ¬[A⊎¬A] A⊎¬A module _ {n s} (IsNightingale : Pred Bird n) (Sings : Pred Bird s) (𝒩 : Bird) (respects : Sings Respects _≈_) (LEM : ∀ x → Sings x ⊎ (¬ Sings x)) (C₁ : ∀ {x} → IsNightingale x → Sings x) ⦃ C₂ : HasMate Sings ⦄ ⦃ C₃ : HasAssociate Sings ⦄ (C₄ : ∀ x → Sings (𝒩 ∙ x) ⇔ IsNightingale x) where private doubleNegation : ∀ x → ¬ ¬ Sings x → Sings x doubleNegation x ¬¬x-sings with LEM x ... | inj₁ x-sings = x-sings ... | inj₂ ¬x-sings = ⊥-elim $ ¬¬x-sings ¬x-sings doubleNegation-⇔ : ∀ x → (¬ ¬ Sings x) ⇔ Sings x doubleNegation-⇔ x = mk⇔ (doubleNegation x) (λ x-sings ¬x-sings → ¬x-sings x-sings) problem₁ : ∃[ 𝒢 ] (Sings 𝒢 × ¬ IsNightingale 𝒢) problem₁ = (𝒢 , conclusion) where 𝒩′ = 𝒩 ′ 𝒩′* = 𝒩′ * 𝒢 = 𝒩′* ∙ 𝒩′* 𝒢-sings⇔¬𝒩𝒢-sings : Sings 𝒢 ⇔ (¬ Sings (𝒩 ∙ 𝒢)) 𝒢-sings⇔¬𝒩𝒢-sings = ⇔-begin Sings 𝒢 ⇔⟨⟩ Sings (𝒩′* ∙ 𝒩′*) ⇔⟨ isAssociate 𝒩′* ⟩ Sings (𝒩′ ∙ (𝒩′* ∙ 𝒩′*)) ⇔⟨⟩ Sings (𝒩′ ∙ 𝒢) ⇔⟨ isMate 𝒢 ⟩ (¬ Sings (𝒩 ∙ 𝒢)) ⇔-∎ ¬𝒢-sings⇔𝒢-isNightingale : (¬ Sings 𝒢) ⇔ IsNightingale 𝒢 ¬𝒢-sings⇔𝒢-isNightingale = ⇔-begin ¬ Sings 𝒢 ⇔⟨ ⇔-¬ 𝒢-sings⇔¬𝒩𝒢-sings ⟩ ¬ ¬ Sings (𝒩 ∙ 𝒢) ⇔⟨ doubleNegation-⇔ $ 𝒩 ∙ 𝒢 ⟩ Sings (𝒩 ∙ 𝒢) ⇔⟨ C₄ 𝒢 ⟩ IsNightingale 𝒢 ⇔-∎ 𝒢-sings⇔¬𝒢-isNightingale : Sings 𝒢 ⇔ (¬ IsNightingale 𝒢) 𝒢-sings⇔¬𝒢-isNightingale = ⇔-begin Sings 𝒢 ⇔˘⟨ doubleNegation-⇔ 𝒢 ⟩ ¬ ¬ Sings 𝒢 ⇔⟨ ⇔-¬ ¬𝒢-sings⇔𝒢-isNightingale ⟩ (¬ IsNightingale 𝒢) ⇔-∎ conclusion : Sings 𝒢 × ¬ IsNightingale 𝒢 conclusion with LEM 𝒢 ... | inj₁ 𝒢-sings = (𝒢-sings , Equivalence.f 𝒢-sings⇔¬𝒢-isNightingale 𝒢-sings) ... | inj₂ ¬𝒢-sings = ⊥-elim $ ¬𝒢-sings $ C₁ $ Equivalence.f ¬𝒢-sings⇔𝒢-isNightingale ¬𝒢-sings problem₂ : ∃[ 𝒢 ] (Sings 𝒢 × ¬ IsNightingale 𝒢) problem₂ = (𝒢 , conclusion) where 𝒩* = 𝒩 * 𝒩*′ = 𝒩* ′ 𝒢 = 𝒩*′ ∙ 𝒩*′ -- Note: this proof (and the definition of 𝒢) is the only difference to -- the proof of problem 1. 𝒢-sings⇔¬𝒩𝒢-sings : Sings 𝒢 ⇔ (¬ Sings (𝒩 ∙ 𝒢)) 𝒢-sings⇔¬𝒩𝒢-sings = ⇔-begin Sings 𝒢 ⇔⟨⟩ Sings (𝒩*′ ∙ 𝒩*′) ⇔⟨ isMate 𝒩*′ ⟩ ¬ Sings (𝒩* ∙ 𝒩*′) ⇔⟨ ⇔-¬ $ isAssociate 𝒩*′ ⟩ ¬ Sings (𝒩 ∙ (𝒩*′ ∙ 𝒩*′)) ⇔⟨⟩ (¬ Sings (𝒩 ∙ 𝒢)) ⇔-∎ ¬𝒢-sings⇔𝒢-isNightingale : (¬ Sings 𝒢) ⇔ IsNightingale 𝒢 ¬𝒢-sings⇔𝒢-isNightingale = ⇔-begin ¬ Sings 𝒢 ⇔⟨ ⇔-¬ 𝒢-sings⇔¬𝒩𝒢-sings ⟩ ¬ ¬ Sings (𝒩 ∙ 𝒢) ⇔⟨ doubleNegation-⇔ $ 𝒩 ∙ 𝒢 ⟩ Sings (𝒩 ∙ 𝒢) ⇔⟨ C₄ 𝒢 ⟩ IsNightingale 𝒢 ⇔-∎ 𝒢-sings⇔¬𝒢-isNightingale : Sings 𝒢 ⇔ (¬ IsNightingale 𝒢) 𝒢-sings⇔¬𝒢-isNightingale = ⇔-begin Sings 𝒢 ⇔˘⟨ doubleNegation-⇔ 𝒢 ⟩ ¬ ¬ Sings 𝒢 ⇔⟨ ⇔-¬ ¬𝒢-sings⇔𝒢-isNightingale ⟩ (¬ IsNightingale 𝒢) ⇔-∎ conclusion : Sings 𝒢 × ¬ IsNightingale 𝒢 conclusion with LEM 𝒢 ... | inj₁ 𝒢-sings = (𝒢-sings , Equivalence.f 𝒢-sings⇔¬𝒢-isNightingale 𝒢-sings) ... | inj₂ ¬𝒢-sings = ⊥-elim $ ¬𝒢-sings $ C₁ $ Equivalence.f ¬𝒢-sings⇔𝒢-isNightingale ¬𝒢-sings _Represents_ : ∀ {r} → (A : Bird) → (𝒮 : Pred Bird r) → Set (b ⊔ s ⊔ r) A Represents 𝒮 = ∀ x → Sings (A ∙ x) ⇔ x ∈ 𝒮 IsSociety : ∀ {r} → (𝒮 : Pred Bird r) → Set (b ⊔ s ⊔ r) IsSociety 𝒮 = ∃[ A ] A Represents 𝒮 _ : IsSociety IsNightingale _ = (𝒩 , C₄) problem₃ : ¬ IsSociety Sings problem₃ 𝒮@(A , A-represents) = let A′ = A ′ A′* = A′ * 𝒮ᶜ : IsSociety λ x → ¬ Sings x 𝒮ᶜ = ( A′ , λ x → ⇔-begin Sings (A′ ∙ x) ⇔⟨ isMate x ⟩ ¬ Sings (A ∙ x) ⇔⟨ ⇔-¬ $ A-represents x ⟩ (¬ Sings x) ⇔-∎ ) A′*A′*-sings⇔¬A′*A′*-sings : Sings (A′* ∙ A′*) ⇔ (¬ Sings (A′* ∙ A′*)) A′*A′*-sings⇔¬A′*A′*-sings = ⇔-begin Sings (A′* ∙ A′*) ⇔⟨ isAssociate A′* ⟩ Sings (A′ ∙ (A′* ∙ A′*)) ⇔⟨ proj₂ 𝒮ᶜ (A′* ∙ A′*) ⟩ (¬ Sings (A′* ∙ A′*)) ⇔-∎ in ⇔-↯ A′*A′*-sings⇔¬A′*A′*-sings
{ "alphanum_fraction": 0.4959469418, "avg_line_length": 34.5732484076, "ext": "agda", "hexsha": "3a7aea3377fb137af69bd86948c12ae71ffd0dba", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Problems/Chapter17.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Problems/Chapter17.agda", "max_line_length": 100, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Problems/Chapter17.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 2692, "size": 5428 }
------------------------------------------------------------------------ -- A definitional interpreter ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Lambda.Delay-monad.Interpreter where open import Equality.Propositional open import Prelude open import Prelude.Size open import Maybe equality-with-J open import Monad equality-with-J open import Vec.Function equality-with-J open import Delay-monad open import Delay-monad.Bisimilarity open import Delay-monad.Monad open import Lambda.Syntax hiding ([_]) open Closure Tm ------------------------------------------------------------------------ -- An interpreter monad -- The interpreter monad. M : ∀ {ℓ} → Size → Type ℓ → Type ℓ M i = MaybeT (λ A → Delay A i) -- A variant of the interpreter monad. M′ : ∀ {ℓ} → Size → Type ℓ → Type ℓ M′ i = MaybeT (λ A → Delay′ A i) -- A lifted variant of later. laterM : ∀ {i a} {A : Type a} → M′ i A → M i A run (laterM x) = later (run x) -- A lifted variant of weak bisimilarity. infix 4 _≈M_ _≈M_ : ∀ {a} {A : Type a} → M ∞ A → M ∞ A → Type a x ≈M y = run x ≈ run y ------------------------------------------------------------------------ -- The interpreter infix 10 _∙_ mutual ⟦_⟧ : ∀ {i n} → Tm n → Env n → M i Value ⟦ con i ⟧ ρ = return (con i) ⟦ var x ⟧ ρ = return (ρ x) ⟦ ƛ t ⟧ ρ = return (ƛ t ρ) ⟦ t₁ · t₂ ⟧ ρ = ⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ _∙_ : ∀ {i} → Value → Value → M i Value con i ∙ v₂ = fail ƛ t₁ ρ ∙ v₂ = laterM (⟦ t₁ ⟧′ (cons v₂ ρ)) ⟦_⟧′ : ∀ {i n} → Tm n → Env n → M′ i Value force (run (⟦ t ⟧′ ρ)) = run (⟦ t ⟧ ρ) ------------------------------------------------------------------------ -- An example -- The semantics of Ω is the non-terminating computation never. Ω-loops : ∀ {i} → [ i ] run (⟦ Ω ⟧ nil) ∼ never Ω-loops = later λ { .force → Ω-loops }
{ "alphanum_fraction": 0.4722941481, "avg_line_length": 24.4430379747, "ext": "agda", "hexsha": "1b63bbbb83dccc2c1639f98f95dacb1df43f09ff", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Lambda/Delay-monad/Interpreter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Lambda/Delay-monad/Interpreter.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Lambda/Delay-monad/Interpreter.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 612, "size": 1931 }
{- This file contains: Properties of FreeGroupoid: - Induction principle for the FreeGroupoid on hProps - ∥freeGroupoid∥₂ is a Group - FreeGroup A ≡ ∥ FreeGroupoid A ∥₂ -} {-# OPTIONS --safe #-} module Cubical.HITs.FreeGroupoid.Properties where open import Cubical.HITs.FreeGroupoid.Base open import Cubical.HITs.FreeGroup renaming (elimProp to freeGroupElimProp) open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.BiInvertible open import Cubical.Foundations.Univalence using (ua) open import Cubical.HITs.SetTruncation renaming (rec to recTrunc) open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Monoid.Base open import Cubical.Algebra.Semigroup.Base private variable ℓ ℓ' : Level A : Type ℓ -- The induction principle for the FreeGroupoid for hProps elimProp : ∀ {B : FreeGroupoid A → Type ℓ'} → ((x : FreeGroupoid A) → isProp (B x)) → ((a : A) → B (η a)) → ((g1 g2 : FreeGroupoid A) → B g1 → B g2 → B (g1 · g2)) → (B ε) → ((g : FreeGroupoid A) → B g → B (inv g)) → (x : FreeGroupoid A) → B x elimProp {B = B} Bprop η-ind ·-ind ε-ind inv-ind = induction where induction : ∀ g → B g induction (η a) = η-ind a induction (g1 · g2) = ·-ind g1 g2 (induction g1) (induction g2) induction ε = ε-ind induction (inv g) = inv-ind g (induction g) induction (assoc g1 g2 g3 i) = path i where p1 : B g1 p1 = induction g1 p2 : B g2 p2 = induction g2 p3 : B g3 p3 = induction g3 path : PathP (λ i → B (assoc g1 g2 g3 i)) (·-ind g1 (g2 · g3) p1 (·-ind g2 g3 p2 p3)) (·-ind (g1 · g2) g3 (·-ind g1 g2 p1 p2) p3) path = isProp→PathP (λ i → Bprop (assoc g1 g2 g3 i)) (·-ind g1 (g2 · g3) p1 (·-ind g2 g3 p2 p3)) (·-ind (g1 · g2) g3 (·-ind g1 g2 p1 p2) p3) induction (idr g i) = path i where p : B g p = induction g pε : B ε pε = induction ε path : PathP (λ i → B (idr g i)) p (·-ind g ε p pε) path = isProp→PathP (λ i → Bprop (idr g i)) p (·-ind g ε p pε) induction (idl g i) = path i where p : B g p = induction g pε : B ε pε = induction ε path : PathP (λ i → B (idl g i)) p (·-ind ε g pε p) path = isProp→PathP (λ i → Bprop (idl g i)) p (·-ind ε g pε p) induction (invr g i) = path i where p : B g p = induction g pinv : B (inv g) pinv = inv-ind g p pε : B ε pε = induction ε path : PathP (λ i → B (invr g i)) (·-ind g (inv g) p pinv) pε path = isProp→PathP (λ i → Bprop (invr g i)) (·-ind g (inv g) p pinv) pε induction (invl g i) = path i where p : B g p = induction g pinv : B (inv g) pinv = inv-ind g p pε : B ε pε = induction ε path : PathP (λ i → B (invl g i)) (·-ind (inv g) g pinv p) pε path = isProp→PathP (λ i → Bprop (invl g i)) (·-ind (inv g) g pinv p) pε -- The truncation of the FreeGroupoid is a group and is equal to FreeGroup ∥freeGroupoid∥₂IsSet : isSet ∥ FreeGroupoid A ∥₂ ∥freeGroupoid∥₂IsSet = squash₂ _∣·∣₂_ : ∥ FreeGroupoid A ∥₂ → ∥ FreeGroupoid A ∥₂ → ∥ FreeGroupoid A ∥₂ _∣·∣₂_ = rec2 ∥freeGroupoid∥₂IsSet (λ g1 g2 → ∣ g1 · g2 ∣₂) ∥freeGroupoid∥₂IsSemiGroup : ∀ {ℓ}{A : Type ℓ} → IsSemigroup _∣·∣₂_ ∥freeGroupoid∥₂IsSemiGroup {A = A} = issemigroup ∥freeGroupoid∥₂IsSet |assoc∣₂ where inuctionBase : ∀ g1 g2 g3 → ∣ g1 ∣₂ ∣·∣₂ (∣ g2 ∣₂ ∣·∣₂ ∣ g3 ∣₂) ≡ (∣ g1 ∣₂ ∣·∣₂ ∣ g2 ∣₂) ∣·∣₂ ∣ g3 ∣₂ inuctionBase g1 g2 g3 = cong (λ x → ∣ x ∣₂) (assoc g1 g2 g3) Bset : ∀ x y z → isSet (x ∣·∣₂ (y ∣·∣₂ z) ≡ (x ∣·∣₂ y) ∣·∣₂ z) Bset x y z = isProp→isSet (squash₂ (x ∣·∣₂ (y ∣·∣₂ z)) ((x ∣·∣₂ y) ∣·∣₂ z)) |assoc∣₂ : (x y z : ∥ FreeGroupoid A ∥₂) → x ∣·∣₂ (y ∣·∣₂ z) ≡ (x ∣·∣₂ y) ∣·∣₂ z |assoc∣₂ = elim3 Bset inuctionBase ∣ε∣₂ : ∥ FreeGroupoid A ∥₂ ∣ε∣₂ = ∣ ε ∣₂ ∥freeGroupoid∥₂IsMonoid : IsMonoid {A = ∥ FreeGroupoid A ∥₂} ∣ε∣₂ _∣·∣₂_ ∥freeGroupoid∥₂IsMonoid = ismonoid ∥freeGroupoid∥₂IsSemiGroup (λ x → elim (λ g → isProp→isSet (squash₂ (g ∣·∣₂ ∣ε∣₂) g)) (λ g → cong (λ g' → ∣ g' ∣₂) (sym (idr g))) x) (λ x → elim (λ g → isProp→isSet (squash₂ (∣ε∣₂ ∣·∣₂ g) g)) (λ g → cong (λ g' → ∣ g' ∣₂) (sym (idl g))) x) ∣inv∣₂ : ∥ FreeGroupoid A ∥₂ → ∥ FreeGroupoid A ∥₂ ∣inv∣₂ = map inv ∥freeGroupoid∥₂IsGroup : IsGroup {G = ∥ FreeGroupoid A ∥₂} ∣ε∣₂ _∣·∣₂_ ∣inv∣₂ ∥freeGroupoid∥₂IsGroup = isgroup ∥freeGroupoid∥₂IsMonoid (λ x → elim (λ g → isProp→isSet (squash₂ (g ∣·∣₂ (∣inv∣₂ g)) ∣ε∣₂)) (λ g → cong (λ g' → ∣ g' ∣₂) (invr g)) x) (λ x → elim (λ g → isProp→isSet (squash₂ ((∣inv∣₂ g) ∣·∣₂ g) ∣ε∣₂)) (λ g → cong (λ g' → ∣ g' ∣₂) (invl g)) x) ∥freeGroupoid∥₂GroupStr : GroupStr ∥ FreeGroupoid A ∥₂ ∥freeGroupoid∥₂GroupStr = groupstr ∣ε∣₂ _∣·∣₂_ ∣inv∣₂ ∥freeGroupoid∥₂IsGroup ∥freeGroupoid∥₂Group : Type ℓ → Group ℓ ∥freeGroupoid∥₂Group A = ∥ FreeGroupoid A ∥₂ , ∥freeGroupoid∥₂GroupStr forgetfulHom : GroupHom (freeGroupGroup A) (∥freeGroupoid∥₂Group A) forgetfulHom = rec (λ a → ∣ η a ∣₂) forgetfulHom⁻¹ : GroupHom (∥freeGroupoid∥₂Group A) (freeGroupGroup A) forgetfulHom⁻¹ = invf , isHom where invf : ∥ FreeGroupoid A ∥₂ → FreeGroup A invf = recTrunc freeGroupIsSet aux where aux : FreeGroupoid A → FreeGroup A aux (η a) = η a aux (g1 · g2) = (aux g1) · (aux g2) aux ε = ε aux (inv g) = inv (aux g) aux (assoc g1 g2 g3 i) = assoc (aux g1) (aux g2) (aux g3) i aux (idr g i) = idr (aux g) i aux (idl g i) = idl (aux g) i aux (invr g i) = invr (aux g) i aux (invl g i) = invl (aux g) i isHom : IsGroupHom {A = ∥ FreeGroupoid A ∥₂} {B = FreeGroup A} ∥freeGroupoid∥₂GroupStr invf freeGroupGroupStr IsGroupHom.pres· isHom x y = elim2 (λ x y → isProp→isSet (freeGroupIsSet (invf (x ∣·∣₂ y)) ((invf x) · (invf y)))) ind x y where ind : ∀ g1 g2 → invf (∣ g1 ∣₂ ∣·∣₂ ∣ g2 ∣₂) ≡ (invf ∣ g1 ∣₂) · (invf ∣ g2 ∣₂) ind g1 g2 = refl IsGroupHom.pres1 isHom = refl IsGroupHom.presinv isHom x = elim (λ x → isProp→isSet (freeGroupIsSet (invf (∣inv∣₂ x)) (inv (invf x)))) ind x where ind : ∀ g → invf (∣inv∣₂ ∣ g ∣₂) ≡ inv (invf ∣ g ∣₂) ind g = refl freeGroupTruncIdempotentBiInvEquiv : BiInvEquiv (FreeGroup A) ∥ FreeGroupoid A ∥₂ freeGroupTruncIdempotentBiInvEquiv = biInvEquiv f invf rightInv invf leftInv where f : FreeGroup A → ∥ FreeGroupoid A ∥₂ f = fst forgetfulHom invf : ∥ FreeGroupoid A ∥₂ → FreeGroup A invf = fst forgetfulHom⁻¹ rightInv : ∀ (x : ∥ FreeGroupoid A ∥₂) → f (invf x) ≡ x rightInv x = elim (λ x → isProp→isSet (squash₂ (f (invf x)) x)) ind x where ind : ∀ (g : FreeGroupoid A) → f (invf ∣ g ∣₂) ≡ ∣ g ∣₂ ind g = elimProp Bprop η-ind ·-ind ε-ind inv-ind g where Bprop : ∀ g → isProp (f (invf ∣ g ∣₂) ≡ ∣ g ∣₂) Bprop g = squash₂ (f (invf ∣ g ∣₂)) ∣ g ∣₂ η-ind : ∀ a → f (invf ∣ η a ∣₂) ≡ ∣ η a ∣₂ η-ind a = refl ·-ind : ∀ g1 g2 → f (invf ∣ g1 ∣₂) ≡ ∣ g1 ∣₂ → f (invf ∣ g2 ∣₂) ≡ ∣ g2 ∣₂ → f (invf ∣ g1 · g2 ∣₂) ≡ ∣ g1 · g2 ∣₂ ·-ind g1 g2 ind1 ind2 = f (invf ∣ g1 · g2 ∣₂) ≡⟨ cong f (IsGroupHom.pres· (snd forgetfulHom⁻¹) ∣ g1 ∣₂ ∣ g2 ∣₂) ⟩ f ((invf ∣ g1 ∣₂) · (invf ∣ g2 ∣₂)) ≡⟨ IsGroupHom.pres· (snd forgetfulHom) (invf ∣ g1 ∣₂) (invf ∣ g2 ∣₂) ⟩ (f (invf ∣ g1 ∣₂)) ∣·∣₂ (f (invf ∣ g2 ∣₂)) ≡⟨ cong (λ x → x ∣·∣₂ (f (invf ∣ g2 ∣₂))) ind1 ⟩ ∣ g1 ∣₂ ∣·∣₂ (f (invf ∣ g2 ∣₂)) ≡⟨ cong (λ x → ∣ g1 ∣₂ ∣·∣₂ x) ind2 ⟩ ∣ g1 · g2 ∣₂ ∎ ε-ind : f (invf ∣ ε ∣₂) ≡ ∣ ε ∣₂ ε-ind = refl inv-ind : ∀ g → f (invf ∣ g ∣₂) ≡ ∣ g ∣₂ → f (invf ∣ inv g ∣₂) ≡ ∣ inv g ∣₂ inv-ind g ind = f (invf ∣ inv g ∣₂) ≡⟨ refl ⟩ f (invf (∣inv∣₂ ∣ g ∣₂)) ≡⟨ cong f (IsGroupHom.presinv (snd forgetfulHom⁻¹) ∣ g ∣₂) ⟩ f (inv (invf ∣ g ∣₂)) ≡⟨ IsGroupHom.presinv (snd forgetfulHom) (invf ∣ g ∣₂) ⟩ ∣inv∣₂ (f (invf ∣ g ∣₂)) ≡⟨ cong ∣inv∣₂ ind ⟩ ∣inv∣₂ ∣ g ∣₂ ≡⟨ refl ⟩ ∣ inv g ∣₂ ∎ leftInv : ∀ (g : FreeGroup A) → invf (f g) ≡ g leftInv g = freeGroupElimProp Bprop η-ind ·-ind ε-ind inv-ind g where Bprop : ∀ g → isProp (invf (f g) ≡ g) Bprop g = freeGroupIsSet (invf (f g)) g η-ind : ∀ a → invf (f (η a)) ≡ (η a) η-ind a = refl ·-ind : ∀ g1 g2 → invf (f g1) ≡ g1 → invf (f g2) ≡ g2 → invf (f (g1 · g2)) ≡ g1 · g2 ·-ind g1 g2 ind1 ind2 = invf (f (g1 · g2)) ≡⟨ cong invf (IsGroupHom.pres· (snd forgetfulHom) g1 g2) ⟩ invf ((f g1) ∣·∣₂ (f g2)) ≡⟨ IsGroupHom.pres· (snd forgetfulHom⁻¹) (f g1) (f g2) ⟩ (invf (f g1)) · (invf (f g2)) ≡⟨ cong (λ x → x · (invf (f g2))) ind1 ⟩ g1 · (invf (f g2)) ≡⟨ cong (λ x → g1 · x) ind2 ⟩ g1 · g2 ∎ ε-ind : invf (f ε) ≡ ε ε-ind = refl inv-ind : ∀ g → invf (f g) ≡ g → invf (f (inv g)) ≡ inv g inv-ind g ind = invf (f (inv g)) ≡⟨ cong invf (IsGroupHom.presinv (snd forgetfulHom) g) ⟩ invf (∣inv∣₂ (f g)) ≡⟨ IsGroupHom.presinv (snd forgetfulHom⁻¹) (f g) ⟩ inv (invf (f g)) ≡⟨ cong inv ind ⟩ inv g ∎ freeGroupTruncIdempotent≃ : FreeGroup A ≃ ∥ FreeGroupoid A ∥₂ freeGroupTruncIdempotent≃ = biInvEquiv→Equiv-right freeGroupTruncIdempotentBiInvEquiv freeGroupTruncIdempotent : FreeGroup A ≡ ∥ FreeGroupoid A ∥₂ freeGroupTruncIdempotent = ua freeGroupTruncIdempotent≃
{ "alphanum_fraction": 0.5573650694, "avg_line_length": 40.7617021277, "ext": "agda", "hexsha": "4093d2063af0103b043eb712c8ef9ebb82cfce50", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/FreeGroupoid/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/FreeGroupoid/Properties.agda", "max_line_length": 130, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/FreeGroupoid/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4326, "size": 9579 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} -- This is a selection of useful functions and definitions -- from the standard library that we tend to use a lot. module Util.Prelude where open import Haskell.Prelude public open import Dijkstra.All public open import Level renaming (suc to ℓ+1; zero to ℓ0; _⊔_ to _ℓ⊔_) public 1ℓ : Level 1ℓ = ℓ+1 0ℓ open import Agda.Builtin.Unit public open import Function using (_∘_; _∘′_; case_of_; _on_; _∋_) public identity = Function.id open import Data.Unit.NonEta public open import Data.Empty public -- NOTE: This function is defined to give extra documentation when discharging -- absurd cases where Agda can tell by pattern matching that `A` is not -- inhabited. For example: -- > absurd (just v ≡ nothing) case impossibleProof of λ () infix 0 absurd_case_of_ absurd_case_of_ : ∀ {ℓ₁ ℓ₂} (A : Set ℓ₁) {B : Set ℓ₂} → A → (A → ⊥) → B absurd A case x of f = ⊥-elim (f x) open import Data.Nat renaming (_≟_ to _≟ℕ_; _≤?_ to _≤?ℕ_; _≥?_ to _≥?ℕ_; compare to compareℕ; Ordering to Orderingℕ) public max = _⊔_ min = _⊓_ open import Data.Nat.Properties hiding (≡-irrelevant ; _≟_) public open import Data.List renaming (map to List-map ; filter to List-filter ; lookup to List-lookup; tabulate to List-tabulate; foldl to List-foldl) hiding (fromMaybe; [_]) public open import Data.List.Properties renaming (≡-dec to List-≡-dec; length-map to List-length-map; map-compose to List-map-compose; filter-++ to List-filter-++; length-filter to List-length-filter) using (∷-injective; length-++; map-++-commute; sum-++-commute; map-tabulate; tabulate-lookup; ++-identityʳ; ++-identityˡ) public open import Data.List.Relation.Binary.Subset.Propositional renaming (_⊆_ to _⊆List_) public open import Data.List.Relation.Unary.Any using (Any; here; there) renaming (lookup to Any-lookup; map to Any-map; satisfied to Any-satisfied ;index to Any-index; any to Any-any) public open import Data.List.Relation.Unary.Any.Properties using (¬Any[]) renaming ( map⁺ to Any-map⁺ ; map⁻ to Any-map⁻ ; concat⁺ to Any-concat⁺ ; concat⁻ to Any-concat⁻ ; ++⁻ to Any-++⁻ ; ++⁺ʳ to Any-++ʳ ; ++⁺ˡ to Any-++ˡ ; singleton⁻ to Any-singleton⁻ ; tabulate⁺ to Any-tabulate⁺ ; filter⁻ to Any-filter⁻ ) public open import Data.List.Relation.Unary.All using (All; []; _∷_) renaming (head to All-head; tail to All-tail; lookup to All-lookup; tabulate to All-tabulate; reduce to All-reduce; map to All-map) public open import Data.List.Relation.Unary.All.Properties hiding (All-map) renaming ( tabulate⁻ to All-tabulate⁻ ; tabulate⁺ to All-tabulate⁺ ; map⁺ to All-map⁺ ; map⁻ to All-map⁻ ; ++⁺ to All-++ ) public open import Data.List.Membership.Propositional using (_∈_; _∉_) public open import Data.List.Membership.Propositional.Properties renaming (∈-filter⁺ to List-∈-filter⁺; ∈-filter⁻ to List-∈-filter⁻) public open import Data.Vec using (Vec; []; _∷_) renaming (replicate to Vec-replicate; lookup to Vec-lookup ;map to Vec-map; head to Vec-head; tail to Vec-tail ;updateAt to Vec-updateAt; tabulate to Vec-tabulate ;allFin to Vec-allFin; toList to Vec-toList; fromList to Vec-fromList ;_++_ to _Vec-++_) public open import Data.Vec.Relation.Unary.All using ([]; _∷_) renaming (All to Vec-All; lookup to Vec-All-lookup) public open import Data.Vec.Properties using () renaming (updateAt-minimal to Vec-updateAt-minimal ;[]=⇒lookup to Vec-[]=⇒lookup ;lookup⇒[]= to Vec-lookup⇒[]= ;lookup∘tabulate to Vec-lookup∘tabulate ;≡-dec to Vec-≡-dec) public open import Data.List.Relation.Binary.Pointwise using (decidable-≡) public open import Data.Bool renaming (_≟_ to _≟Bool_) hiding (_≤?_; _<_; _<?_; _≤_; not) public open import Data.Maybe renaming (map to Maybe-map; maybe to Maybe-maybe; zip to Maybe-zip ; _>>=_ to _Maybe->>=_) hiding (align; alignWith; zipWith) public -- a non-dependent eliminator -- note the traditional argument order is "switched", hence the 'S' maybeS : ∀ {a b} {A : Set a} {B : Set b} → (x : Maybe A) → B → ((x : A) → B) → B maybeS {B = B} x f t = Maybe-maybe {B = const B} t f x -- A Dijkstra version of maybeS, implemented using the version in -- Dijkstra.Syntax which has traditional argument order maybeSD : ∀ {ℓ₁ ℓ₂} {M : Set ℓ₁ → Set ℓ₂} ⦃ mmd : MonadMaybeD M ⦄ → ∀ {A B : Set ℓ₁} → Maybe A → M B → (A → M B) → M B maybeSD ⦃ mmd ⦄ x y z = maybeD y z x module _ {Ev Wr St A B : Set} where maybeSMP-RWS : RWS Ev Wr St (Maybe A) → B → (A → RWS Ev Wr St B) → RWS Ev Wr St B maybeSMP-RWS x y z = maybeMP-RWS y z x open import Data.Maybe.Relation.Unary.Any renaming (Any to Maybe-Any; dec to Maybe-Any-dec) hiding (map; zip; zipWith; unzip ; unzipWith) public maybe-any-⊥ : ∀{a}{A : Set a} → Maybe-Any {A = A} (λ _ → ⊤) nothing → ⊥ maybe-any-⊥ () headMay : ∀ {A : Set} → List A → Maybe A headMay [] = nothing headMay (x ∷ _) = just x lastMay : ∀ {A : Set} → List A → Maybe A lastMay [] = nothing lastMay (x ∷ []) = just x lastMay (_ ∷ x ∷ xs) = lastMay (x ∷ xs) open import Data.Maybe.Properties using (just-injective) renaming (≡-dec to Maybe-≡-dec) public open import Data.Fin using (Fin; suc; zero; fromℕ; fromℕ< ; toℕ ; cast) renaming (_≟_ to _≟Fin_; _≤?_ to _≤?Fin_; _≤_ to _≤Fin_ ; _<_ to _<Fin_; inject₁ to Fin-inject₁; inject+ to Fin-inject+; inject≤ to Fin-inject≤) public fins : (n : ℕ) → List (Fin n) fins n = Vec-toList (Vec-allFin n) open import Data.Fin.Properties using (toℕ-injective; toℕ<n) renaming (<-cmp to Fin-<-cmp; <⇒≢ to <⇒≢Fin; suc-injective to Fin-suc-injective) public open import Relation.Binary.PropositionalEquality hiding (decSetoid) public open import Relation.Binary.HeterogeneousEquality using (_≅_) renaming (cong to ≅-cong; cong₂ to ≅-cong₂) public open import Relation.Binary public ≡-irrelevant : ∀{a}{A : Set a} → Irrelevant {a} {A} _≡_ ≡-irrelevant refl refl = refl to-witness-lemma : ∀{ℓ}{A : Set ℓ}{a : A}{f : Maybe A}(x : Is-just f) → to-witness x ≡ a → f ≡ just a to-witness-lemma (just x) refl = refl open import Relation.Nullary hiding (Irrelevant; proof) public open import Relation.Nullary.Decidable hiding (map) public open import Data.Sum renaming (map to ⊎-map; map₁ to ⊎-map₁; map₂ to ⊎-map₂) public open import Data.Sum.Properties using (inj₁-injective ; inj₂-injective) public ⊎-elimˡ : ∀ {ℓ₀ ℓ₁}{A₀ : Set ℓ₀}{A₁ : Set ℓ₁} → ¬ A₀ → A₀ ⊎ A₁ → A₁ ⊎-elimˡ ¬a = either (⊥-elim ∘ ¬a) id ⊎-elimʳ : ∀ {ℓ₀ ℓ₁}{A₀ : Set ℓ₀}{A₁ : Set ℓ₁} → ¬ A₁ → A₀ ⊎ A₁ → A₀ ⊎-elimʳ ¬a = either id (⊥-elim ∘ ¬a) open import Data.Product renaming (map to ×-map; map₂ to ×-map₂; map₁ to ×-map₁; <_,_> to split; swap to ×-swap) hiding (zip) public open import Data.Product.Properties public module _ {ℓA} {A : Set ℓA} where NoneOfKind : ∀ {ℓ} {P : A → Set ℓ} → List A → (p : (a : A) → Dec (P a)) → Set ℓA NoneOfKind xs p = List-filter p xs ≡ [] postulate -- TODO-1: Replace with or prove using library properties? Move to Lemmas? NoneOfKind⇒ : ∀ {ℓ} {P : A → Set ℓ} {Q : A → Set ℓ} {xs : List A} → (p : (a : A) → Dec (P a)) → {q : (a : A) → Dec (Q a)} → (∀ {a} → P a → Q a) -- TODO-1: Use proper notation (Relation.Unary?) → NoneOfKind xs q → NoneOfKind xs p infix 4 _<?ℕ_ _<?ℕ_ : Decidable _<_ m <?ℕ n = suc m ≤?ℕ n infix 0 if-yes_then_else_ infix 0 if-dec_then_else_ if-yes_then_else_ : ∀ {ℓA ℓB} {A : Set ℓA} {B : Set ℓB} → Dec A → (A → B) → (¬ A → B) → B if-yes (yes prf) then f else _ = f prf if-yes (no prf) then _ else g = g prf if-dec_then_else_ : ∀ {ℓA ℓB} {A : Set ℓA} {B : Set ℓB} → Dec A → B → B → B if-dec x then f else g = if-yes x then const f else const g open import Relation.Nullary.Negation using (contradiction; contraposition) public open import Relation.Binary using (Setoid; IsPreorder) public open import Relation.Unary using (_∪_) public open import Relation.Unary.Properties using (_∪?_) public -- Injectivity for a function of two potentially different types (A and B) via functions to a -- common type (C). Injective' : ∀ {b c d e}{B : Set b}{C : Set c}{D : Set d} → (hB : B → D) → (hC : C → D) → (_≈_ : B → C → Set e) → Set _ Injective' {C = C} hB hC _≈_ = ∀ {b c} → hB b ≡ hC c → b ≈ c Injective : ∀ {c d e}{C : Set c}{D : Set d} → (h : C → D) → (_≈_ : Rel C e) → Set _ Injective h _≈_ = Injective' h h _≈_ Injective-≡ : ∀ {c d}{C : Set c}{D : Set d} → (h : C → D) → Set _ Injective-≡ h = Injective h _≡_ Injective-int : ∀{a b c d e}{A : Set a}{B : Set b}{C : Set c}{D : Set d} → (_≈_ : A → B → Set e) → (h : C → D) → (f₁ : A → C) → (f₂ : B → C) → Set (a ℓ⊔ b ℓ⊔ d ℓ⊔ e) Injective-int _≈_ h f₁ f₂ = ∀ {a₁} {b₁} → h (f₁ a₁) ≡ h (f₂ b₁) → a₁ ≈ b₁ NonInjective : ∀{a b c}{A : Set a}{B : Set b} → (_≈_ : Rel A c) → (A → B) → Set (a ℓ⊔ b ℓ⊔ c) NonInjective {A = A} _≈_ f = Σ (A × A) (λ { (x₁ , x₂) → ¬ (x₁ ≈ x₂) × f x₁ ≡ f x₂ }) NonInjective-≡ : ∀{a b}{A : Set a}{B : Set b} → (A → B) → Set (a ℓ⊔ b) NonInjective-≡ = NonInjective _≡_ NonInjective-≡-preds : ∀{a b}{A : Set a}{B : Set b}{ℓ₁ ℓ₂ : Level} → (A → Set ℓ₁) → (A → Set ℓ₂) → (A → B) → Set (a ℓ⊔ b ℓ⊔ ℓ₁ ℓ⊔ ℓ₂) NonInjective-≡-preds Pred1 Pred2 f = Σ (NonInjective _≡_ f) λ { ((a₀ , a₁) , _ , _) → Pred1 a₀ × Pred2 a₁ } NonInjective-≡-pred : ∀{a b}{A : Set a}{B : Set b}{ℓ : Level} → (P : A → Set ℓ) → (A → B) → Set (a ℓ⊔ b ℓ⊔ ℓ) NonInjective-≡-pred Pred = NonInjective-≡-preds Pred Pred NonInjective-∘ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → {f : A → B}(g : B → C) → NonInjective-≡ f → NonInjective-≡ (g ∘ f) NonInjective-∘ g ((x0 , x1) , (x0≢x1 , fx0≡fx1)) = ((x0 , x1) , x0≢x1 , (cong g fx0≡fx1)) -------------------------------------------- -- Handy fmap and bind for specific types -- _<M$>_ : ∀{a b}{A : Set a}{B : Set b} → (f : A → B) → Maybe A → Maybe B _<M$>_ = Maybe-map <M$>-univ : ∀{a b}{A : Set a}{B : Set b} → (f : A → B)(x : Maybe A) → {y : B} → f <M$> x ≡ just y → ∃[ x' ] (x ≡ just x' × f x' ≡ y) <M$>-univ f (just x) refl = x , (refl , refl) maybe-lift : {A : Set} → {mx : Maybe A}{x : A} → (P : A → Set) → P x → mx ≡ just x → Maybe-maybe {B = const Set} P ⊥ mx maybe-lift {mx = just .x} {x} P px refl = px <M$>-nothing : ∀ {a b}{A : Set a}{B : Set b}(f : A → B) → f <M$> nothing ≡ nothing <M$>-nothing _ = refl _<⊎$>_ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → (A → B) → C ⊎ A → C ⊎ B f <⊎$> (inj₁ hb) = inj₁ hb f <⊎$> (inj₂ x) = inj₂ (f x) _⊎⟫=_ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → C ⊎ A → (A → C ⊎ B) → C ⊎ B (inj₁ x) ⊎⟫= _ = inj₁ x (inj₂ a) ⊎⟫= f = f a -- a non-dependent eliminator -- note the traditional argument order is "switched", hence the 'S' eitherS : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} (x : Either A B) → ((x : A) → C) → ((x : B) → C) → C eitherS eab fa fb = case eab of λ where (Left a) → fa a (Right b) → fb b -- A Dijkstra version of eitherS, implemented using the version in -- Dijkstra.Syntax which has traditional argument order eitherSD : ∀ {ℓ₁ ℓ₂ ℓ₃} {M : Set ℓ₁ → Set ℓ₂} ⦃ med : MonadEitherD M ⦄ → ∀ {EL : Set ℓ₁ → Set ℓ₁ → Set ℓ₃} ⦃ _ : EitherLike EL ⦄ → ∀ {E A B : Set ℓ₁} → EL E A → (E → M B) → (A → M B) → M B eitherSD ⦃ med ⦄ ⦃ el ⦄ x y z = eitherD y z x open import Data.String as String hiding (_==_ ; _≟_ ; concat) check : Bool → List String → Either String Unit check b t = if b then inj₂ unit else inj₁ (String.intersperse "; " t) toWitnessT : ∀{ℓ}{P : Set ℓ}{d : Dec P} → ⌊ d ⌋ ≡ true → P toWitnessT {d = yes proof} _ = proof toWitnessF : ∀{ℓ}{P : Set ℓ}{d : Dec P} → ⌊ d ⌋ ≡ false → ¬ P toWitnessF{d = no proof} _ = proof Any-satisfied-∈ : ∀{a ℓ}{A : Set a}{P : A → Set ℓ}{xs : List A} → Any P xs → Σ A (λ x → P x × x ∈ xs) Any-satisfied-∈ (here px) = _ , (px , here refl) Any-satisfied-∈ (there p) = let (a , px , prf) = Any-satisfied-∈ p in (a , px , there prf) f-sum : ∀{a}{A : Set a} → (A → ℕ) → List A → ℕ f-sum f = sum ∘ List-map f maybeSMP : ∀ {ℓ} {A B : Set} {m : Set → Set ℓ} ⦃ _ : Monad m ⦄ → m (Maybe A) → B → (A → m B) → m B maybeSMP ma b f = do x ← ma case x of λ where nothing → pure b (just j) → f j open import LibraBFT.Base.Util public -- Like a Haskell list-comprehension for ℕ : [ n | n <- [from .. to] ] fromToList : ℕ → ℕ → List ℕ fromToList from to with from ≤′? to ... | no ¬pr = [] ... | yes pr = fromToList-le from to pr [] where fromToList-le : ∀ (from to : ℕ) (klel : from ≤′ to) (acc : List ℕ) → List ℕ fromToList-le from ._ ≤′-refl acc = from ∷ acc fromToList-le from (suc to) (≤′-step klel) acc = fromToList-le from to klel (suc to ∷ acc) _ : fromToList 1 1 ≡ 1 ∷ [] _ = refl _ : fromToList 1 2 ≡ 1 ∷ 2 ∷ [] _ = refl _ : fromToList 2 1 ≡ [] _ = refl
{ "alphanum_fraction": 0.5409012728, "avg_line_length": 32.8846153846, "ext": "agda", "hexsha": "3b1c8ae4977ee2a91a7793294ce7cb66df75daa6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/Util/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/Util/Prelude.agda", "max_line_length": 164, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/Util/Prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5385, "size": 14535 }
module Data.List.Primitive where -- In Agda 2.2.10 and below, there's no FFI binding for the stdlib -- List type, so we have to roll our own. This will change. data #List (X : Set) : Set where [] : #List X _∷_ : X → #List X → #List X {-# COMPILED_DATA #List [] [] (:) #-}
{ "alphanum_fraction": 0.6223021583, "avg_line_length": 27.8, "ext": "agda", "hexsha": "5184caa4c6e27d88598f30563cb73613cb6758e6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:40:14.000Z", "max_forks_repo_head_hexsha": "84d51967e20bf248e9f73af37f52972922ffc77c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-data-bindings", "max_forks_repo_path": "src/Data/List/Primitive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "84d51967e20bf248e9f73af37f52972922ffc77c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-data-bindings", "max_issues_repo_path": "src/Data/List/Primitive.agda", "max_line_length": 66, "max_stars_count": 2, "max_stars_repo_head_hexsha": "84d51967e20bf248e9f73af37f52972922ffc77c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-data-bindings", "max_stars_repo_path": "src/Data/List/Primitive.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T13:51:16.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-02T23:17:59.000Z", "num_tokens": 94, "size": 278 }
{-# OPTIONS --safe --experimental-lossy-unification #-} -- This file could be proven using the file Sn -- However the proofs are easier than in Sn -- And so kept for pedagologic reasons module Cubical.ZCohomology.CohomologyRings.S1 where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Transport open import Cubical.Foundations.HLevels open import Cubical.Data.Unit open import Cubical.Data.Nat renaming (_+_ to _+n_ ; _·_ to _·n_ ; snotz to nsnotz) open import Cubical.Data.Int open import Cubical.Data.Vec open import Cubical.Data.FinData open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Instances.Int renaming (ℤGroup to ℤG) open import Cubical.Algebra.DirectSum.Base open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.QuotientRing open import Cubical.Algebra.Polynomials.Multivariate.Base renaming (base to baseP) open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤCommRing to ℤCR) open import Cubical.Algebra.CommRing.Instances.MultivariatePoly open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-Quotient open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-notationZ open import Cubical.HITs.Truncation open import Cubical.HITs.SetQuotients as SQ renaming (_/_ to _/sq_) open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.HITs.Sn open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.RingStructure.CupProduct open import Cubical.ZCohomology.RingStructure.CohomologyRing open import Cubical.ZCohomology.Groups.Sn open Iso module Equiv-S1-Properties where ----------------------------------------------------------------------------- -- Definitions open CommRingStr (snd ℤCR) using () renaming ( 0r to 0ℤ ; 1r to 1ℤ ; _+_ to _+ℤ_ ; -_ to -ℤ_ ; _·_ to _·ℤ_ ; +Assoc to +ℤAssoc ; +Identity to +ℤIdentity ; +Lid to +ℤLid ; +Rid to +ℤRid ; +Inv to +ℤInv ; +Linv to +ℤLinv ; +Rinv to +ℤRinv ; +Comm to +ℤComm ; ·Assoc to ·ℤAssoc ; ·Identity to ·ℤIdentity ; ·Lid to ·ℤLid ; ·Rid to ·ℤRid ; ·Rdist+ to ·ℤRdist+ ; ·Ldist+ to ·ℤLdist+ ; is-set to isSetℤ ) open RingStr (snd (H*R (S₊ 1))) using () renaming ( 0r to 0H* ; 1r to 1H* ; _+_ to _+H*_ ; -_ to -H*_ ; _·_ to _cup_ ; +Assoc to +H*Assoc ; +Identity to +H*Identity ; +Lid to +H*Lid ; +Rid to +H*Rid ; +Inv to +H*Inv ; +Linv to +H*Linv ; +Rinv to +H*Rinv ; +Comm to +H*Comm ; ·Assoc to ·H*Assoc ; ·Identity to ·H*Identity ; ·Lid to ·H*Lid ; ·Rid to ·H*Rid ; ·Rdist+ to ·H*Rdist+ ; ·Ldist+ to ·H*Ldist+ ; is-set to isSetH* ) open CommRingStr (snd ℤ[X]) using () renaming ( 0r to 0Pℤ ; 1r to 1Pℤ ; _+_ to _+Pℤ_ ; -_ to -Pℤ_ ; _·_ to _·Pℤ_ ; +Assoc to +PℤAssoc ; +Identity to +PℤIdentity ; +Lid to +PℤLid ; +Rid to +PℤRid ; +Inv to +PℤInv ; +Linv to +PℤLinv ; +Rinv to +PℤRinv ; +Comm to +PℤComm ; ·Assoc to ·PℤAssoc ; ·Identity to ·PℤIdentity ; ·Lid to ·PℤLid ; ·Rid to ·PℤRid ; ·Comm to ·PℤComm ; ·Rdist+ to ·PℤRdist+ ; ·Ldist+ to ·PℤLdist+ ; is-set to isSetPℤ ) open CommRingStr (snd ℤ[X]/X²) using () renaming ( 0r to 0PℤI ; 1r to 1PℤI ; _+_ to _+PℤI_ ; -_ to -PℤI_ ; _·_ to _·PℤI_ ; +Assoc to +PℤIAssoc ; +Identity to +PℤIIdentity ; +Lid to +PℤILid ; +Rid to +PℤIRid ; +Inv to +PℤIInv ; +Linv to +PℤILinv ; +Rinv to +PℤIRinv ; +Comm to +PℤIComm ; ·Assoc to ·PℤIAssoc ; ·Identity to ·PℤIIdentity ; ·Lid to ·PℤILid ; ·Rid to ·PℤIRid ; ·Rdist+ to ·PℤIRdist+ ; ·Ldist+ to ·PℤILdist+ ; is-set to isSetPℤI ) ----------------------------------------------------------------------------- -- Direct Sens on ℤ[x] ℤ[x]→H*-S¹ : ℤ[x] → H* (S₊ 1) ℤ[x]→H*-S¹ = Poly-Rec-Set.f _ _ _ isSetH* 0H* base-trad _+H*_ +H*Assoc +H*Rid +H*Comm base-neutral-eq base-add-eq where e : _ e = Hᵐ-Sⁿ base-trad : _ base-trad (zero ∷ []) a = base 0 (inv (fst (Hᵐ-Sⁿ 0 1)) a) base-trad (one ∷ []) a = base 1 (inv (fst (Hᵐ-Sⁿ 1 1)) a) base-trad (suc (suc n) ∷ []) a = 0H* base-neutral-eq : _ base-neutral-eq (zero ∷ []) = cong (base 0) (IsGroupHom.pres1 (snd (invGroupIso (Hᵐ-Sⁿ 0 1)))) ∙ base-neutral _ base-neutral-eq (one ∷ []) = cong (base 1) (IsGroupHom.pres1 (snd (invGroupIso (Hᵐ-Sⁿ 1 1)))) ∙ base-neutral _ base-neutral-eq (suc (suc n) ∷ []) = refl base-add-eq : _ base-add-eq (zero ∷ []) a b = (base-add _ _ _) ∙ (cong (base 0) (sym (IsGroupHom.pres· (snd (invGroupIso (Hᵐ-Sⁿ 0 1))) a b))) base-add-eq (one ∷ []) a b = (base-add _ _ _) ∙ (cong (base 1) (sym (IsGroupHom.pres· (snd (invGroupIso (Hᵐ-Sⁿ 1 1))) a b))) base-add-eq (suc (suc n) ∷ []) a b = +H*Rid _ ----------------------------------------------------------------------------- -- Morphism on ℤ[x] ℤ[x]→H*-S¹-pres1Pℤ : ℤ[x]→H*-S¹ (1Pℤ) ≡ 1H* ℤ[x]→H*-S¹-pres1Pℤ = refl ℤ[x]→H*-S¹-pres+ : (x y : ℤ[x]) → ℤ[x]→H*-S¹ (x +Pℤ y) ≡ ℤ[x]→H*-S¹ x +H* ℤ[x]→H*-S¹ y ℤ[x]→H*-S¹-pres+ x y = refl -- cup product on H⁰ → H⁰ → H⁰ T0 : (z : ℤ) → coHom 0 (S₊ 1) T0 = λ z → inv (fst (Hᵐ-Sⁿ 0 1)) z T0g : IsGroupHom (ℤG .snd) (fst (invGroupIso (Hᵐ-Sⁿ 0 1)) .fun) (coHomGr 0 (S₊ (suc 0)) .snd) T0g = snd (invGroupIso (Hᵐ-Sⁿ 0 1)) -- idea : control of the unfolding + simplification of T0 on the left pres·-base-case-00 : (a : ℤ) → (b : ℤ) → T0 (a ·ℤ b) ≡ (T0 a) ⌣ (T0 b) pres·-base-case-00 (pos zero) b = (IsGroupHom.pres1 T0g) pres·-base-case-00 (pos (suc n)) b = ((IsGroupHom.pres· T0g b (pos n ·ℤ b))) ∙ (cong (λ X → (T0 b) +ₕ X) (pres·-base-case-00 (pos n) b)) pres·-base-case-00 (negsuc zero) b = IsGroupHom.presinv T0g b pres·-base-case-00 (negsuc (suc n)) b = cong T0 (+ℤComm (-ℤ b) (negsuc n ·ℤ b)) -- ·ℤ and ·₀ are defined asymetrically ! ∙ IsGroupHom.pres· T0g (negsuc n ·ℤ b) (-ℤ b) ∙ cong₂ _+ₕ_ (pres·-base-case-00 (negsuc n) b) (IsGroupHom.presinv T0g b) -- cup product on H⁰ → H¹ → H¹ T1 : (z : ℤ) → coHom 1 (S₊ 1) T1 = λ z → inv (fst (Hᵐ-Sⁿ 1 1)) z -- idea : control of the unfolding + simplification of T0 on the left T1g : IsGroupHom (ℤG .snd) (fst (invGroupIso (Hᵐ-Sⁿ 1 1)) .fun) (coHomGr 1 (S₊ 1) .snd) T1g = snd (invGroupIso (Hᵐ-Sⁿ 1 1)) pres·-base-case-01 : (a : ℤ) → (b : ℤ) → T1 (a ·ℤ b) ≡ (T0 a) ⌣ (T1 b) pres·-base-case-01 (pos zero) b = (IsGroupHom.pres1 T1g) pres·-base-case-01 (pos (suc n)) b = ((IsGroupHom.pres· T1g b (pos n ·ℤ b))) ∙ (cong (λ X → (T1 b) +ₕ X) (pres·-base-case-01 (pos n) b)) pres·-base-case-01 (negsuc zero) b = IsGroupHom.presinv T1g b pres·-base-case-01 (negsuc (suc n)) b = cong T1 (+ℤComm (-ℤ b) (negsuc n ·ℤ b)) -- ·ℤ and ·₀ are defined asymetrically ! ∙ IsGroupHom.pres· T1g (negsuc n ·ℤ b) (-ℤ b) ∙ cong₂ _+ₕ_ (pres·-base-case-01 (negsuc n) b) (IsGroupHom.presinv T1g b) -- Nice packaging of the proof pres·-base-case-int : (n : ℕ) → (a : ℤ) → (m : ℕ) → (b : ℤ) → ℤ[x]→H*-S¹ (baseP (n ∷ []) a ·Pℤ baseP (m ∷ []) b) ≡ ℤ[x]→H*-S¹ (baseP (n ∷ []) a) cup ℤ[x]→H*-S¹ (baseP (m ∷ []) b) pres·-base-case-int zero a zero b = cong (base 0) (pres·-base-case-00 a b) pres·-base-case-int zero a one b = cong (base 1) (pres·-base-case-01 a b) pres·-base-case-int zero a (suc (suc m)) b = refl pres·-base-case-int one a zero b = cong ℤ[x]→H*-S¹ (·PℤComm (baseP (1 ∷ []) a) (baseP (zero ∷ []) b)) ∙ pres·-base-case-int 0 b 1 a ∙ gradCommRing (S₊ 1) 0 1 (inv (fst (Hᵐ-Sⁿ 0 1)) b) (inv (fst (Hᵐ-Sⁿ 1 1)) a) pres·-base-case-int one a one b = sym (base-neutral 2) ∙ cong (base 2) (isOfHLevelRetractFromIso 1 (fst (Hⁿ-Sᵐ≅0 1 0 nsnotz)) isPropUnit _ _) pres·-base-case-int one a (suc (suc m)) b = refl pres·-base-case-int (suc (suc n)) a m b = refl pres·-base-case-vec : (v : Vec ℕ 1) → (a : ℤ) → (v' : Vec ℕ 1) → (b : ℤ) → ℤ[x]→H*-S¹ (baseP v a ·Pℤ baseP v' b) ≡ ℤ[x]→H*-S¹ (baseP v a) cup ℤ[x]→H*-S¹ (baseP v' b) pres·-base-case-vec (n ∷ []) a (m ∷ []) b = pres·-base-case-int n a m b -- proof of the morphism ℤ[x]→H*-S¹-pres· : (x y : ℤ[x]) → ℤ[x]→H*-S¹ (x ·Pℤ y) ≡ ℤ[x]→H*-S¹ x cup ℤ[x]→H*-S¹ y ℤ[x]→H*-S¹-pres· = Poly-Ind-Prop.f _ _ _ (λ x p q i y j → isSetH* _ _ (p y) (q y) i j) (λ y → refl) base-case λ {U V} ind-U ind-V y → cong₂ _+H*_ (ind-U y) (ind-V y) where base-case : _ base-case (n ∷ []) a = Poly-Ind-Prop.f _ _ _ (λ _ → isSetH* _ _) (sym (RingTheory.0RightAnnihilates (H*R (S₊ 1)) _)) (λ v' b → pres·-base-case-vec (n ∷ []) a v' b) λ {U V} ind-U ind-V → (cong₂ _+H*_ ind-U ind-V) ∙ sym (·H*Rdist+ _ _ _) ----------------------------------------------------------------------------- -- Function on ℤ[x]/x + morphism ℤ[x]→H*-S¹-cancelX : (k : Fin 1) → ℤ[x]→H*-S¹ (<X²> k) ≡ 0H* ℤ[x]→H*-S¹-cancelX zero = refl ℤ[X]→H*-S¹ : RingHom (CommRing→Ring ℤ[X]) (H*R (S₊ 1)) fst ℤ[X]→H*-S¹ = ℤ[x]→H*-S¹ snd ℤ[X]→H*-S¹ = makeIsRingHom ℤ[x]→H*-S¹-pres1Pℤ ℤ[x]→H*-S¹-pres+ ℤ[x]→H*-S¹-pres· ℤ[X]/X²→H*R-S¹ : RingHom (CommRing→Ring ℤ[X]/X²) (H*R (S₊ 1)) ℤ[X]/X²→H*R-S¹ = Quotient-FGideal-CommRing-Ring.f ℤ[X] (H*R (S₊ 1)) ℤ[X]→H*-S¹ <X²> ℤ[x]→H*-S¹-cancelX ℤ[x]/x²→H*-S¹ : ℤ[x]/x² → H* (S₊ 1) ℤ[x]/x²→H*-S¹ = fst ℤ[X]/X²→H*R-S¹ ----------------------------------------------------------------------------- -- Converse Sens on ℤ[X] + ℤ[x]/x H*-S¹→ℤ[x] : H* (S₊ 1) → ℤ[x] H*-S¹→ℤ[x] = DS-Rec-Set.f _ _ _ _ isSetPℤ 0Pℤ base-trad _+Pℤ_ +PℤAssoc +PℤRid +PℤComm base-neutral-eq base-add-eq where base-trad : _ base-trad zero a = baseP (0 ∷ []) (fun (fst (Hᵐ-Sⁿ 0 1)) a) base-trad one a = baseP (1 ∷ []) (fun (fst (Hᵐ-Sⁿ 1 1)) a) base-trad (suc (suc n)) a = 0Pℤ base-neutral-eq : _ base-neutral-eq zero = cong (baseP (0 ∷ [])) (IsGroupHom.pres1 (snd (Hᵐ-Sⁿ 0 1))) ∙ base-0P _ base-neutral-eq one = cong (baseP (1 ∷ [])) (IsGroupHom.pres1 (snd (Hᵐ-Sⁿ 1 1))) ∙ base-0P _ base-neutral-eq (suc (suc n)) = refl base-add-eq : _ base-add-eq zero a b = (base-poly+ _ _ _) ∙ (cong (baseP (0 ∷ [])) (sym (IsGroupHom.pres· (snd (Hᵐ-Sⁿ 0 1)) a b))) base-add-eq one a b = (base-poly+ _ _ _) ∙ (cong (baseP (1 ∷ [])) (sym (IsGroupHom.pres· (snd (Hᵐ-Sⁿ 1 1)) a b))) base-add-eq (suc (suc n)) a b = +PℤRid _ H*-S¹→ℤ[x]-pres+ : (x y : H* (S₊ 1)) → H*-S¹→ℤ[x] ( x +H* y) ≡ H*-S¹→ℤ[x] x +Pℤ H*-S¹→ℤ[x] y H*-S¹→ℤ[x]-pres+ x y = refl H*-S¹→ℤ[x]/x² : H* (S₊ 1) → ℤ[x]/x² H*-S¹→ℤ[x]/x² = [_] ∘ H*-S¹→ℤ[x] H*-S¹→ℤ[x]/x²-pres+ : (x y : H* (S₊ 1)) → H*-S¹→ℤ[x]/x² (x +H* y) ≡ (H*-S¹→ℤ[x]/x² x) +PℤI (H*-S¹→ℤ[x]/x² y) H*-S¹→ℤ[x]/x²-pres+ x y = refl ----------------------------------------------------------------------------- -- Section e-sect : (x : H* (S₊ 1)) → ℤ[x]/x²→H*-S¹ (H*-S¹→ℤ[x]/x² x) ≡ x e-sect = DS-Ind-Prop.f _ _ _ _ (λ _ → isSetH* _ _) refl base-case λ {U V} ind-U ind-V → cong₂ _+H*_ ind-U ind-V where base-case : _ base-case zero a = cong (base 0) (leftInv (fst (Hᵐ-Sⁿ 0 1)) a) base-case one a = cong (base 1) (leftInv (fst (Hᵐ-Sⁿ 1 1)) a) base-case (suc (suc n)) a = (sym (base-neutral (suc (suc n)))) ∙ cong (base (suc (suc n))) (isOfHLevelRetractFromIso 1 (fst (Hⁿ-Sᵐ≅0 (suc n) 0 nsnotz)) isPropUnit _ _) ----------------------------------------------------------------------------- -- Retraction e-retr : (x : ℤ[x]/x²) → H*-S¹→ℤ[x]/x² (ℤ[x]/x²→H*-S¹ x) ≡ x e-retr = SQ.elimProp (λ _ → isSetPℤI _ _) (Poly-Ind-Prop.f _ _ _ (λ _ → isSetPℤI _ _) refl base-case λ {U V} ind-U ind-V → cong₂ _+PℤI_ ind-U ind-V) where base-case : _ base-case (zero ∷ []) a = cong [_] (cong (baseP (0 ∷ [])) (rightInv (fst (Hᵐ-Sⁿ 0 1)) a)) base-case (one ∷ []) a = cong [_] (cong (baseP (1 ∷ [])) (rightInv (fst (Hᵐ-Sⁿ 1 1)) a)) base-case (suc (suc n) ∷ []) a = eq/ 0Pℤ (baseP (suc (suc n) ∷ []) a) ∣ ((λ x → baseP (n ∷ []) (-ℤ a)) , helper) ∣₁ where helper : _ helper = (+PℤLid _) ∙ cong₂ baseP (cong (λ X → X ∷ []) (sym (+-comm n 2))) (sym (·ℤRid _)) ∙ (sym (+PℤRid _)) ----------------------------------------------------------------------------- -- Computation of the Cohomology Ring module _ where open Equiv-S1-Properties S¹-CohomologyRing : RingEquiv (CommRing→Ring ℤ[X]/X²) (H*R (S₊ 1)) fst S¹-CohomologyRing = isoToEquiv is where is : Iso ℤ[x]/x² (H* (S₊ 1)) fun is = ℤ[x]/x²→H*-S¹ inv is = H*-S¹→ℤ[x]/x² rightInv is = e-sect leftInv is = e-retr snd S¹-CohomologyRing = snd ℤ[X]/X²→H*R-S¹ CohomologyRing-S¹ : RingEquiv (H*R (S₊ 1)) (CommRing→Ring ℤ[X]/X²) CohomologyRing-S¹ = RingEquivs.invEquivRing S¹-CohomologyRing
{ "alphanum_fraction": 0.4776918501, "avg_line_length": 40.344, "ext": "agda", "hexsha": "e6f4db3c63300407e9568ac1ae62971f8b700daa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xekoukou/cubical", "max_forks_repo_path": "Cubical/ZCohomology/CohomologyRings/S1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "xekoukou/cubical", "max_issues_repo_path": "Cubical/ZCohomology/CohomologyRings/S1.agda", "max_line_length": 147, "max_stars_count": null, "max_stars_repo_head_hexsha": "b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xekoukou/cubical", "max_stars_repo_path": "Cubical/ZCohomology/CohomologyRings/S1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5883, "size": 15129 }
{-# OPTIONS --type-in-type --no-termination-check --no-positivity-check #-} module IMDesc where --******************************************** -- Prelude --******************************************** -- Some preliminary stuffs, to avoid relying on the stdlib --**************** -- Sigma and friends --**************** data Sigma (A : Set)(B : A -> Set) : Set where _,_ : (x : A)(y : B x) -> Sigma A B _*_ : (A B : Set) -> Set A * B = Sigma A \_ -> B fst : {A : Set}{B : A -> Set} -> Sigma A B -> A fst (a , _) = a snd : {A : Set}{B : A -> Set} (p : Sigma A B) -> B (fst p) snd (a , b) = b data Zero : Set where record One : Set where --**************** -- Sum and friends --**************** data _+_ (A B : Set) : Set where l : A -> A + B r : B -> A + B --**************** -- Prop --**************** data EProp : Set where Trivial : EProp Prf : EProp -> Set Prf _ = {! !} --**************** -- Enum --**************** data EnumU : Set where data EnumT (E : EnumU) : Set where Branches : (E : EnumU) -> (P : EnumT E -> Set) -> Set Branches _ _ = {! !} switch : (E : EnumU) -> (e : EnumT E) -> (P : EnumT E -> Set) -> Branches E P -> P e switch = {! !} --******************************************** -- IMDesc --******************************************** --**************** -- Code --**************** data IDesc (I : Set) : Set where iat : (i : I) -> IDesc I ipi : (S : Set)(T : S -> IDesc I) -> IDesc I isigma : (S : Set)(T : S -> IDesc I) -> IDesc I iprf : (Q : EProp) -> IDesc I iprod : (D : IDesc I)(D : IDesc I) -> IDesc I ifsigma : (E : EnumU)(f : Branches E (\ _ -> IDesc I)) -> IDesc I --**************** -- Interpretation --**************** desc : (I : Set)(D : IDesc I)(P : I -> Set) -> Set desc I (iat i) P = P i desc I (ipi S T) P = (s : S) -> desc I (T s) P desc I (isigma S T) P = Sigma S (\ s -> desc I (T s) P) desc I (iprf q) P = Prf q desc I (iprod D D') P = Sigma (desc I D P) (\ _ -> desc I D' P) desc I (ifsigma E B) P = Sigma (EnumT E) (\ e -> desc I (switch E e (\ _ -> IDesc I) B) P) --**************** -- Curried and uncurried interpretations --**************** curryD : (I : Set)(D : IDesc I)(P : I -> Set)(R : desc I D P -> Set) -> Set curryD I (iat i) P R = (x : P i) -> R x curryD I (ipi S T) P R = (f : (s : S) -> desc I (T s) P) -> R f curryD I (isigma S T) P R = (s : S) -> curryD I (T s) P (\ d -> R (s , d)) curryD I (iprf Q) P R = (x : Prf Q) -> R x curryD I (iprod D D') P R = curryD I D P (\ d -> curryD I D' P (\ d' -> R (d , d'))) curryD I (ifsigma E B) P R = Branches E (\e -> curryD I (switch E e (\_ -> IDesc I) B) P (\d -> R (e , d))) uncurryD : (I : Set)(D : IDesc I)(P : I -> Set)(R : desc I D P -> Set) -> curryD I D P R -> (xs : desc I D P) -> R xs uncurryD I (iat i) P R f xs = f xs uncurryD I (ipi S T) P R F f = F f uncurryD I (isigma S T) P R f (s , d) = uncurryD I (T s) P (\d -> R (s , d)) (f s) d uncurryD I (iprf Q) P R f q = f q uncurryD I (iprod D D') P R f (d , d') = uncurryD I D' P ((\ d' → R (d , d'))) (uncurryD I D P ((\ x → curryD I D' P (\ d0 → R (x , d0)))) f d) d' uncurryD I (ifsigma E B) P R br (e , d) = uncurryD I (switch E e (\ _ -> IDesc I) B) P (\ d -> R ( e , d )) (switch E e ( \ e -> R ( e , d)) br) d --**************** -- Everywhere --**************** box : (I : Set)(D : IDesc I)(P : I -> Set) -> desc I D P -> IDesc (Sigma I P) box I (iat i) P x = iat (i , x) box I (ipi S T) P f = ipi S (\ s -> box I (T s) P (f s)) box I (isigma S T) P (s , d) = box I (T s) P d box I (iprf Q) P q = iprf Trivial box I (iprod D D') P (d , d') = iprod (box I D P d) (box I D' P d') box I (ifsigma E B) P (e , d) = box I (switch E e (\ _ -> IDesc I) B) P d mapbox : (I : Set)(D : IDesc I)(Z : I -> Set)(P : Sigma I Z -> Set) -> ((x : Sigma I Z) -> P x) -> ( d : desc I D Z) -> desc (Sigma I Z) (box I D Z d) P mapbox = {!!} --**************** -- Fix-point --**************** data IMu (I : Set)(D : I -> IDesc I)(i : I) : Set where Con : desc I (D i) (\ j -> IMu I D j) -> IMu I D i --**************** -- Induction, curried --**************** inductionC : (I : Set)(D : I -> IDesc I)(i : I)(v : IMu I D i) (P : Sigma I (IMu I D) -> Set) (m : (i : I) -> curryD I (D i) (IMu I D) (\xs -> curryD (Sigma I (IMu I D)) (box I (D i) (IMu I D) xs) P (\ _ -> P (i , Con xs)))) -> P ( i , v ) inductionC I D i (Con x) P m = let t = uncurryD I (D i) (IMu I D) (\xs -> curryD (Sigma I (IMu I D)) (box I (D i) (IMu I D) xs) P (\ _ -> P (i , Con xs))) (m i) x in uncurryD (Sigma I (IMu I D)) ( box I (D i) (IMu I D) x) P (\ _ -> P ( i , Con x)) t (mapbox I ( D i) ( IMu I D) P ind x) where ind : (x' : Sigma I (IMu I D)) -> P x' ind ( i , x) = inductionC I D i x P m
{ "alphanum_fraction": 0.3777818314, "avg_line_length": 29.4731182796, "ext": "agda", "hexsha": "f241905418cc6bdad4f94f8104d8686da5485127", "lang": "Agda", "max_forks_count": 12, "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mietek/epigram", "max_forks_repo_path": "models/IMDesc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mietek/epigram", "max_issues_repo_path": "models/IMDesc.agda", "max_line_length": 110, "max_stars_count": 48, "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mietek/epigram", "max_stars_repo_path": "models/IMDesc.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "num_tokens": 1907, "size": 5482 }
module Lib.Fin where open import Lib.Nat open import Lib.Bool open import Lib.Id data Fin : Nat -> Set where zero : {n : Nat} -> Fin (suc n) suc : {n : Nat} -> Fin n -> Fin (suc n) fromNat : (n : Nat) -> Fin (suc n) fromNat zero = zero fromNat (suc n) = suc (fromNat n) toNat : {n : Nat} -> Fin n -> Nat toNat zero = zero toNat (suc n) = suc (toNat n) weaken : {n : Nat} -> Fin n -> Fin (suc n) weaken zero = zero weaken (suc n) = suc (weaken n) lem-toNat-weaken : forall {n} (i : Fin n) -> toNat i ≡ toNat (weaken i) lem-toNat-weaken zero = refl lem-toNat-weaken (suc i) with toNat i | lem-toNat-weaken i ... | .(toNat (weaken i)) | refl = refl lem-toNat-fromNat : (n : Nat) -> toNat (fromNat n) ≡ n lem-toNat-fromNat zero = refl lem-toNat-fromNat (suc n) with toNat (fromNat n) | lem-toNat-fromNat n ... | .n | refl = refl finEq : {n : Nat} -> Fin n -> Fin n -> Bool finEq zero zero = true finEq zero (suc _) = false finEq (suc _) zero = false finEq (suc i) (suc j) = finEq i j -- A view telling you if a given element is the maximal one. data MaxView {n : Nat} : Fin (suc n) -> Set where theMax : MaxView (fromNat n) notMax : (i : Fin n) -> MaxView (weaken i) maxView : {n : Nat}(i : Fin (suc n)) -> MaxView i maxView {zero} zero = theMax maxView {zero} (suc ()) maxView {suc n} zero = notMax zero maxView {suc n} (suc i) with maxView i maxView {suc n} (suc .(fromNat n)) | theMax = theMax maxView {suc n} (suc .(weaken i)) | notMax i = notMax (suc i) -- The non zero view data NonEmptyView : {n : Nat} -> Fin n -> Set where ne : {n : Nat}{i : Fin (suc n)} -> NonEmptyView i nonEmpty : {n : Nat}(i : Fin n) -> NonEmptyView i nonEmpty zero = ne nonEmpty (suc _) = ne -- The thinning view thin : {n : Nat} -> Fin (suc n) -> Fin n -> Fin (suc n) thin zero j = suc j thin (suc i) zero = zero thin (suc i) (suc j) = suc (thin i j) data EqView : {n : Nat} -> Fin n -> Fin n -> Set where equal : {n : Nat}{i : Fin n} -> EqView i i notequal : {n : Nat}{i : Fin (suc n)}(j : Fin n) -> EqView i (thin i j) compare : {n : Nat}(i j : Fin n) -> EqView i j compare zero zero = equal compare zero (suc j) = notequal j compare (suc i) zero with nonEmpty i ... | ne = notequal zero compare (suc i) (suc j) with compare i j compare (suc i) (suc .i) | equal = equal compare (suc i) (suc .(thin i j)) | notequal j = notequal (suc j)
{ "alphanum_fraction": 0.5903861956, "avg_line_length": 30.425, "ext": "agda", "hexsha": "f83c36e385fd814f198e8aa1b4fdac6f15255b7e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 916, "size": 2434 }
------------------------------------------------------------------------ -- Integer division ------------------------------------------------------------------------ module Data.Nat.DivMod where open import Data.Nat open import Data.Nat.Properties open SemiringSolver open import Data.Fin as Fin using (Fin; zero; suc; toℕ; fromℕ) import Data.Fin.Props as Fin open import Induction.Nat open import Relation.Nullary.Decidable open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Data.Function ------------------------------------------------------------------------ -- Some boring lemmas private lem₁ : ∀ m k → _ lem₁ m k = cong suc $ begin m ≡⟨ Fin.inject+-lemma m k ⟩ toℕ (Fin.inject+ k (fromℕ m)) ≡⟨ solve 1 (λ x → x := x :+ con 0) refl _ ⟩ toℕ (Fin.inject+ k (fromℕ m)) + 0 ∎ lem₂ : ∀ n → _ lem₂ = solve 1 (λ n → con 1 :+ n := con 1 :+ (n :+ con 0)) refl lem₃ : ∀ n k q r eq → _ lem₃ n k q r eq = begin suc n + k ≡⟨ solve 2 (λ n k → con 1 :+ n :+ k := n :+ (con 1 :+ k)) refl n k ⟩ n + suc k ≡⟨ cong (_+_ n) eq ⟩ n + (toℕ r + q * n) ≡⟨ solve 3 (λ n r q → n :+ (r :+ q :* n) := r :+ (con 1 :+ q) :* n) refl n (toℕ r) q ⟩ toℕ r + suc q * n ∎ ------------------------------------------------------------------------ -- Division -- A specification of integer division. data DivMod : ℕ → ℕ → Set where result : {divisor : ℕ} (q : ℕ) (r : Fin divisor) → DivMod (toℕ r + q * divisor) divisor -- Sometimes the following type is more usable; functions in indices -- can be inconvenient. data DivMod' (dividend divisor : ℕ) : Set where result : (q : ℕ) (r : Fin divisor) (eq : dividend ≡ toℕ r + q * divisor) → DivMod' dividend divisor -- Integer division with remainder. -- Note that Induction.Nat.<-rec is used to ensure termination of -- division. The run-time complexity of this implementation of integer -- division should be linear in the size of the dividend, assuming -- that well-founded recursion and the equality type are optimised -- properly (see "Inductive Families Need Not Store Their Indices" -- (Brady, McBride, McKinna, TYPES 2003)). _divMod'_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → DivMod' dividend divisor _divMod'_ m n {≢0} = <-rec Pred dm m n {≢0} where Pred : ℕ → Set Pred dividend = (divisor : ℕ) {≢0 : False (divisor ≟ 0)} → DivMod' dividend divisor 1+_ : ∀ {k n} → DivMod' (suc k) n → DivMod' (suc n + k) n 1+_ {k} {n} (result q r eq) = result (1 + q) r (lem₃ n k q r eq) dm : (dividend : ℕ) → <-Rec Pred dividend → Pred dividend dm m rec zero {≢0 = ()} dm zero rec (suc n) = result 0 zero refl dm (suc m) rec (suc n) with compare m n dm (suc m) rec (suc .(suc m + k)) | less .m k = result 0 r (lem₁ m k) where r = suc (Fin.inject+ k (fromℕ m)) dm (suc m) rec (suc .m) | equal .m = result 1 zero (lem₂ m) dm (suc .(suc n + k)) rec (suc n) | greater .n k = 1+ rec (suc k) le (suc n) where le = s≤′s (s≤′s (n≤′m+n n k)) -- A variant. _divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → DivMod dividend divisor _divMod_ m n {≢0} with _divMod'_ m n {≢0} .(toℕ r + q * n) divMod n | result q r refl = result q r -- Integer division. _div_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ _div_ m n {≢0} with _divMod_ m n {≢0} .(toℕ r + q * n) div n | result q r = q -- The remainder after integer division. _mod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → Fin divisor _mod_ m n {≢0} with _divMod_ m n {≢0} .(toℕ r + q * n) mod n | result q r = r
{ "alphanum_fraction": 0.5192056441, "avg_line_length": 33.2782608696, "ext": "agda", "hexsha": "a1dbdc530ebbf77cfa5024e96aab9426f9e037b5", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/Nat/DivMod.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/Nat/DivMod.agda", "max_line_length": 79, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/Nat/DivMod.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 1273, "size": 3827 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} -- {-# OPTIONS --without-K #-} -- [1] Hofmann, Martin and Thomas Streicher (1998). “The groupoid -- interpretation on type theory”. In: Twenty-five Years of -- Constructive Type Theory. Ed. by Giovanni Sambin and Jan -- M. Smith. Oxford University Press. Chap. 6. module UIP where data Id (A : Set)(x : A) : A → Set where refl : Id A x x K : (A : Set)(x : A)(P : Id A x x → Set) → P refl → (p : Id A x x ) → P p K A x P pr refl = pr -- From [1, p. 88]. UIP : (A : Set)(a a' : A)(p p' : Id A a a') → Id (Id A a a') p p' UIP A a .a refl refl = refl
{ "alphanum_fraction": 0.5450704225, "avg_line_length": 32.2727272727, "ext": "agda", "hexsha": "3d32f6bab19db8eec9a46596bca0241e299fd7b2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/k-axiom/UIP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/k-axiom/UIP.agda", "max_line_length": 73, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/k-axiom/UIP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 230, "size": 710 }
-- Jesper, 2019-05-20: When checking confluence of two rewrite rules, -- we disable all reductions during unification of the left-hand -- sides. However, we should not disable reductions at the type-level, -- as shown by this (non-confluent) example. {-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite data Unit : Set where unit : Unit A : Unit → Set A unit = ⊤ postulate a b : (u : Unit) → A u f : (u : Unit) → A u → Bool f-a : (u : Unit) → f u (a u) ≡ true f-b : (u : Unit) → f u (b u) ≡ false {-# REWRITE f-a #-} {-# REWRITE f-b #-} cong-f : (u : Unit) (x y : A u) → x ≡ y → f u x ≡ f u y cong-f u x y refl = refl boom : true ≡ false boom = cong-f unit (a unit) (b unit) refl
{ "alphanum_fraction": 0.6420798065, "avg_line_length": 25.84375, "ext": "agda", "hexsha": "02c78b54d1f8f92f5181d9b8245f6f11845f7111", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/ConfluenceTypeLevelReduction.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Fail/ConfluenceTypeLevelReduction.agda", "max_line_length": 70, "max_stars_count": 2, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/ConfluenceTypeLevelReduction.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 275, "size": 827 }
module UniDB.Morph.Weaken where open import UniDB.Spec -------------------------------------------------------------------------------- data Weaken : MOR where weaken : {γ : Dom} (δ : Dom) → Weaken γ (γ ∪ δ) instance iLkWeaken : {T : STX} {{vrT : Vr T}} → Lk T Weaken lk {{iLkWeaken}} (weaken δ) i = vr (wk δ i) iWkmWeaken : Wkm Weaken wkm {{iWkmWeaken}} = weaken iIdmWeaken : Idm Weaken idm {{iIdmWeaken}} γ = weaken 0 iWkWeaken : {γ₁ : Dom} → Wk (Weaken γ₁) wk₁ {{iWkWeaken}} (weaken δ) = weaken (suc δ) wk {{iWkWeaken}} zero x = x wk {{iWkWeaken}} (suc δ) x = wk₁ (wk δ x) wk-zero {{iWkWeaken}} x = refl wk-suc {{iWkWeaken}} δ x = refl iLkWkmWeaken : {T : STX} {{vrT : Vr T}} → LkWkm T Weaken lk-wkm {{iLkWkmWeaken}} δ i = refl iCompWeaken : Comp Weaken _⊙_ {{iCompWeaken}} ξ (weaken δ) = wk δ ξ wk₁-comp : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Weaken γ₁ γ₂) (ξ₂ : Weaken γ₂ γ₃) → wk₁ (ξ₁ ⊙ ξ₂) ≡ ξ₁ ⊙ wk₁ ξ₂ wk₁-comp ξ₁ (weaken δ) = refl wk-comp : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Weaken γ₁ γ₂) (ξ₂ : Weaken γ₂ γ₃) (δ : Dom) → wk δ (ξ₁ ⊙ ξ₂) ≡ ξ₁ ⊙ wk δ ξ₂ wk-comp ξ₁ ξ₂ zero = refl wk-comp ξ₁ ξ₂ (suc δ) = trans (cong wk₁ (wk-comp ξ₁ ξ₂ δ)) (wk₁-comp ξ₁ (wk δ ξ₂)) module _ (T : STX) {{vrT : Vr T}} where lk-wk₁-weaken : {{wkT : Wk T}} {{wkVrT : WkVr T}} {γ₁ γ₂ : Dom} (ξ : Weaken γ₁ γ₂) (i : Ix γ₁) → lk {T} {Weaken} (wk₁ ξ) i ≡ wk₁ (lk {T} {Weaken} ξ i) lk-wk₁-weaken (weaken δ) i = sym (wk₁-vr {T} (wk δ i)) lk-wk-weaken : {{wkT : Wk T}} {{wkVrT : WkVr T}} {γ₁ γ₂ : Dom} (δ : Dom) (ξ : Weaken γ₁ γ₂) (i : Ix γ₁) → lk {T} {Weaken} (wk δ ξ) i ≡ wk δ (lk {T} {Weaken} ξ i) lk-wk-weaken zero ξ i = sym (wk-zero (lk {T} {Weaken} ξ i)) lk-wk-weaken (suc δ) ξ i = trans (lk-wk₁-weaken (wk δ ξ) i) (trans (cong wk₁ (lk-wk-weaken δ ξ i)) (sym (wk-suc {T} δ (lk {T} {Weaken} ξ i))) ) instance iLkRenWeaken : {T : STX} {{vrT : Vr T}} → LkRen T Weaken lk-ren {{iLkRenWeaken}} (weaken δ) i = refl iLkRenCompWeaken : {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{wkVrT : WkVr T}} → LkRenComp T Weaken lk-ren-comp {{iLkRenCompWeaken {T}}} ξ₁ (weaken δ) i = begin lk {T} {Weaken} (wk δ ξ₁) i ≡⟨ lk-wk-weaken T δ ξ₁ i ⟩ wk δ (lk {T} {Weaken} ξ₁ i) ≡⟨ cong (wk δ) (lk-ren {T} {Weaken} ξ₁ i) ⟩ wk δ (vr {T} (lk {Ix} {Weaken} ξ₁ i)) ≡⟨ wk-vr {T} δ (lk {Ix} {Weaken} ξ₁ i) ⟩ vr {T} (wk δ (lk {Ix} {Weaken} ξ₁ i)) ∎ iCompIdmWeaken : CompIdm Weaken ⊙-idm {{iCompIdmWeaken}} ξ = refl idm-⊙ {{iCompIdmWeaken}} (weaken zero) = refl idm-⊙ {{iCompIdmWeaken}} (weaken (suc δ)) = cong wk₁ (idm-⊙ {Weaken} (weaken δ)) iCompAssocWeaken : CompAssoc Weaken ⊙-assoc {{iCompAssocWeaken}} ξ₁ ξ₂ (weaken δ) = sym (wk-comp ξ₁ ξ₂ δ) --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5212691771, "avg_line_length": 33.3488372093, "ext": "agda", "hexsha": "e58ce0380684a38960713e3b523ccb718ac90abc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_path": "UniDB/Morph/Weaken.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "skeuchel/unidb-agda", "max_issues_repo_path": "UniDB/Morph/Weaken.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_path": "UniDB/Morph/Weaken.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1346, "size": 2868 }
-- Jesper, 2017-01-23: when instantiating a variable during unification, -- we should check that the type of the variable is equal to the type -- of the equation (and not just a subtype of it). See Issue 2407. open import Agda.Builtin.Equality open import Agda.Builtin.Size data D : Size → Set where J= : ∀ {ℓ} {s : Size} (x₀ : D s) → (P : (x : D s) → _≡_ {A = D s} x₀ x → Set ℓ) → P x₀ refl → (x : D s) (e : _≡_ {A = D s} x₀ x) → P x e J= _ P p _ refl = p J< : ∀ {ℓ} {s : Size} {s' : Size< s} (x₀ : D s) → (P : (x : D s) → _≡_ {A = D s} x₀ x → Set ℓ) → P x₀ refl → (x : D s') (e : _≡_ {A = D s} x₀ x) → P x e J< _ P p _ refl = p J> : ∀ {ℓ} {s : Size} {s' : Size< s} (x₀ : D s') → (P : (x : D s) → _≡_ {A = D s} x₀ x → Set ℓ) → P x₀ refl → (x : D s) (e : _≡_ {A = D s} x₀ x) → P x e J> _ P p _ refl = p J~ : ∀ {ℓ} {s : Size} {s' s'' : Size< s} (x₀ : D s') → (P : (x : D s) → _≡_ {A = D s} x₀ x → Set ℓ) → P x₀ refl → (x : D s'') (e : _≡_ {A = D s} x₀ x) → P x e J~ _ P p _ refl = p
{ "alphanum_fraction": 0.4768015795, "avg_line_length": 33.7666666667, "ext": "agda", "hexsha": "ef66911af05ddfee0a79f2a577a352c7611d8603", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/UnificationAndSubtyping.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/UnificationAndSubtyping.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/UnificationAndSubtyping.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 488, "size": 1013 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? open import AISEC.Utils open import Data.Real as ℝ using (ℝ) open import Data.List module MyTestModule where f : Tensor ℝ (1 ∷ []) → Tensor ℝ (1 ∷ []) f = evaluate record { databasePath = DATABASE_PATH ; networkUUID = NETWORK_UUID } monotonic : ∀ (x1 : Tensor ℝ (1 ∷ [])) → ∀ (x2 : Tensor ℝ (1 ∷ [])) → let y1 = f (x1) y2 = f (x2) in x1 0 ℝ.≤ x2 0 → y1 0 ℝ.≤ y2 0 monotonic = checkProperty record { databasePath = DATABASE_PATH ; propertyUUID = ???? }
{ "alphanum_fraction": 0.6359516616, "avg_line_length": 26.48, "ext": "agda", "hexsha": "c123451546ec194051e793d550920b1310ef6e4d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7cdd7734fe0d50cc7d5a3b3c6bdddba778cfe6df", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Yiergot/vehicle", "max_forks_repo_path": "examples/network/monotonicity/monotonicity-output.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cdd7734fe0d50cc7d5a3b3c6bdddba778cfe6df", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "Yiergot/vehicle", "max_issues_repo_path": "examples/network/monotonicity/monotonicity-output.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "7cdd7734fe0d50cc7d5a3b3c6bdddba778cfe6df", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "Yiergot/vehicle", "max_stars_repo_path": "examples/network/monotonicity/monotonicity-output.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 232, "size": 662 }
module Numeral.Natural.Oper.Proofs.Structure where open import Logic.Predicate open import Numeral.Natural open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Operator.Monoid instance [+]-monoid : Monoid(_+_) Monoid.identity-existence [+]-monoid = [∃]-intro(𝟎) instance [⋅]-monoid : Monoid(_⋅_) Monoid.identity-existence [⋅]-monoid = [∃]-intro(𝐒(𝟎))
{ "alphanum_fraction": 0.7612903226, "avg_line_length": 25.8333333333, "ext": "agda", "hexsha": "5f87d0afe73a895e0119c41f310ef8a2a7e1af2c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Oper/Proofs/Structure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Oper/Proofs/Structure.agda", "max_line_length": 56, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Oper/Proofs/Structure.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 146, "size": 465 }
{-# OPTIONS --without-K #-} module Computability.Function where open import Computability.Prelude import Function variable l₀ l₁ : Level Injective : {A : Set l₀}{B : Set l₁} → (A → B) → Set _ Injective = Function.Injective _≡_ _≡_ Surjective : {A : Set l₀}{B : Set l₁} → (A → B) → Set _ Surjective {A = A} {B = B} = Function.Surjective {A = A} {B = B} _≡_ _≡_ Bijective : {A : Set l₀}{B : Set l₁} → (A → B) → Set _ Bijective = Function.Bijective _≡_ _≡_
{ "alphanum_fraction": 0.6290672451, "avg_line_length": 25.6111111111, "ext": "agda", "hexsha": "e05e4ede036213ad08609aeebf068482037d83b1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jesyspa/computability-in-agda", "max_forks_repo_path": "Computability/Function.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jesyspa/computability-in-agda", "max_issues_repo_path": "Computability/Function.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jesyspa/computability-in-agda", "max_stars_repo_path": "Computability/Function.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-30T11:15:51.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-19T15:51:22.000Z", "num_tokens": 171, "size": 461 }
{-# OPTIONS --safe #-} module Cubical.HITs.FreeGroup where open import Cubical.HITs.FreeGroup.Base public open import Cubical.HITs.FreeGroup.Properties public
{ "alphanum_fraction": 0.7950310559, "avg_line_length": 23, "ext": "agda", "hexsha": "65ec2892bcd0d156bf72f11c37fa3654f9167214", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/FreeGroup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/FreeGroup.agda", "max_line_length": 52, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/FreeGroup.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 39, "size": 161 }
mutual data ℕμ : Set where zero : ℕμ succ : ℕμ → ℕμ delay : ℕν → ℕμ record ℕν : Set where coinductive field step : ℕμ open ℕν public mutual data _≤μ_ : ℕμ → ℕμ → Set where -- Standard part of the order le₀ : (y : ℕμ) → zero ≤μ y leₛ : {x y : ℕμ} → x ≤μ y → succ x ≤μ succ y -- We can have finite delays on the left and on the right... le-stepₗ : {m : ℕν} {y : ℕμ} → step m ≤μ y → delay m ≤μ y le-stepᵣ : {x : ℕμ} {n : ℕν} → x ≤μ step n → x ≤μ delay n -- or an abritrary sequence of delays on both sides. le-step : {m n : ℕν} → m ≤ n → delay m ≤μ delay n record _≤_ (m n : ℕν) : Set where coinductive field step≤ : (step m) ≤μ (step m) open _≤_ public ≤μ-refl : (x : ℕμ) → x ≤μ x ≤-refl : (m : ℕν) → m ≤ m step≤ (≤-refl m) = ≤μ-refl (step m) ≤μ-refl zero = le₀ zero ≤μ-refl (succ x) = leₛ (≤μ-refl x) ≤μ-refl (delay x) = le-step (≤-refl x)
{ "alphanum_fraction": 0.5420765027, "avg_line_length": 24.0789473684, "ext": "agda", "hexsha": "fd3b152962b458588fb88adf32a930790014ae1b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "TypeTheory/Partial.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "TypeTheory/Partial.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "TypeTheory/Partial.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 396, "size": 915 }
module Issue329b where abstract infixl 0 D Undeclared data D : Set where
{ "alphanum_fraction": 0.746835443, "avg_line_length": 11.2857142857, "ext": "agda", "hexsha": "0dde1de65ec7cbbb68beaab71131c3d3d77f6634", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue329b.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue329b.agda", "max_line_length": 23, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/Issue329b.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 26, "size": 79 }
{-# OPTIONS --without-K --safe #-} open import Level hiding (zero) open import Relation.Binary module SDG.Extra.OrderedAlgebra.Structures {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where open import Algebra.Structures open import Algebra.FunctionProperties record IsOrderedCommutativeRing (_<_ : Rel A ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where field isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1# <-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_ <-+ : ∀ (a b c) → a < b → (a + c) < (b + c) <-* : ∀ (a b) → 0# < a → 0# < b → 0# < (a * b) open IsCommutativeRing isCommutativeRing public --using (zero) open IsStrictTotalOrder <-isStrictTotalOrder public
{ "alphanum_fraction": 0.625, "avg_line_length": 28, "ext": "agda", "hexsha": "414838d16aa68b2f56100aaacc56b62b5bba0a47", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6814e6f0baffff35efe14ef70d469343cd9b3ba0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wrrnhttn/agda-sdg", "max_forks_repo_path": "SDG/Extra/OrderedAlgebra/Structures.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "6814e6f0baffff35efe14ef70d469343cd9b3ba0", "max_issues_repo_issues_event_max_datetime": "2019-09-18T15:47:49.000Z", "max_issues_repo_issues_event_min_datetime": "2019-07-18T20:00:23.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wrrnhttn/agda-sdg", "max_issues_repo_path": "SDG/Extra/OrderedAlgebra/Structures.agda", "max_line_length": 82, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6814e6f0baffff35efe14ef70d469343cd9b3ba0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wrrnhttn/agda-sdg", "max_stars_repo_path": "SDG/Extra/OrderedAlgebra/Structures.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-13T09:36:38.000Z", "max_stars_repo_stars_event_min_datetime": "2020-11-13T09:36:38.000Z", "num_tokens": 261, "size": 728 }
{-# OPTIONS --no-termination-check #-} module PiPath where open import Level open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ -- Universe of types -- The type < v > is the singleton type containing the one value v. We can -- construct values of this type using (singleton v' proof) where the proof -- asserts that v is propositionally equal to v. data <_> {a : Level} {A : Set a} (x : A) : Set a where singleton : (y : A) → y ≡ x → < x > -- The types of Pi include 0, 1, +, * as usual but data B : Set where ZERO : B ONE : B PLUS : B → B → B TIMES : B → B → B RECIP : B → (B → B) → B ⟦_⟧ : B → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS b₁ b₂ ⟧ = ⟦ b₁ ⟧ ⊎ ⟦ b₂ ⟧ ⟦ TIMES b₁ b₂ ⟧ = ⟦ b₁ ⟧ × ⟦ b₂ ⟧ ⟦ RECIP b ⟧ = (v : ⟦ b ⟧) → ⊤ ------------------------------------------------------------------------------ -- syntax and types of combinators ⟷ refers to eval -- eval refers to evalB -- evalB refers to eval and reverse -- reverse refers to reverse' -- reverse' refers to reverse -- syntax and types of combinators data _⟷_ : B → B → Set₁ where unite₊ : {b : B} → PLUS ZERO b ⟷ b uniti₊ : {b : B} → b ⟷ PLUS ZERO b swap₊ : {b₁ b₂ : B} → PLUS b₁ b₂ ⟷ PLUS b₂ b₁ assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃ assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃) unite⋆ : { b : B } → TIMES ONE b ⟷ b uniti⋆ : { b : B } → b ⟷ TIMES ONE b swap⋆ : {b₁ b₂ : B} → TIMES b₁ b₂ ⟷ TIMES b₂ b₁ assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃ assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃) id⟷ : {b : B } → b ⟷ b op : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁) _◎_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃) _⊕_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄) _⊗_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄) ε : {b₁ : B} → TIMES b₁ (TIMES b₁ (RECIP b₁)) ⟷ b₁ -- Semantics mutual eval : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₁ ⟧ → ⟦ b₂ ⟧ eval unite₊ (inj₁ ()) eval unite₊ (inj₂ v) = v eval uniti₊ v = inj₂ v eval swap₊ (inj₁ x) = inj₂ x eval swap₊ (inj₂ y) = inj₁ y eval assocl₊ (inj₁ x) = inj₁ (inj₁ x) eval assocl₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x) eval assocl₊ (inj₂ (inj₂ x)) = inj₂ x eval assocr₊ (inj₁ (inj₁ x)) = inj₁ x eval assocr₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y) eval assocr₊ (inj₂ y) = inj₂ (inj₂ y) eval unite⋆ (tt , x) = x eval uniti⋆ v = ( tt , v) eval swap⋆ (v₁ , v₂) = (v₂ , v₁) eval assocl⋆ (x , (y , z)) = ((x , y), z) eval assocr⋆ ((x , y), z) = (x , (y , z)) eval id⟷ v = v eval (op c) v = evalB c v eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v) eval (c₁ ⊕ c₂) (inj₁ x) = inj₁ (eval c₁ x) eval (c₁ ⊕ c₂) (inj₂ y) = inj₂ (eval c₂ y) eval (c₁ ⊗ c₂) (x , y) = (eval c₁ x , eval c₂ y) eval ε (x , y , z) = x evalB : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₂ ⟧ → ⟦ b₁ ⟧ evalB uniti₊ (inj₁ ()) evalB uniti₊ (inj₂ v) = v evalB unite₊ v = inj₂ v evalB swap₊ (inj₁ x) = inj₂ x evalB swap₊ (inj₂ y) = inj₁ y evalB assocr₊ (inj₁ x) = inj₁ (inj₁ x) evalB assocr₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x) evalB assocr₊ (inj₂ (inj₂ x)) = inj₂ x evalB assocl₊ (inj₁ (inj₁ x)) = inj₁ x evalB assocl₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y) evalB assocl₊ (inj₂ y) = inj₂ (inj₂ y) evalB uniti⋆ (tt , x) = x evalB unite⋆ v = ( tt , v) evalB swap⋆ (v₁ , v₂) = (v₂ , v₁) evalB assocr⋆ (x , (y , z)) = ((x , y), z) evalB assocl⋆ ((x , y), z) = (x , (y , z)) evalB id⟷ v = v evalB (op c) v = eval c v evalB (c₁ ◎ c₂) v = evalB c₁ (evalB c₂ v) evalB (c₁ ⊕ c₂) (inj₁ x) = inj₁ (evalB c₁ x) evalB (c₁ ⊕ c₂) (inj₂ y) = inj₂ (evalB c₂ y) evalB (c₁ ⊗ c₂) (x , y) = (evalB c₁ x , evalB c₂ y) evalB ε x = x , x , (λ _ → tt) -- reversibility mutual reverse : {b₁ b₂ : B} (c : b₁ ⟷ b₂) → (v : ⟦ b₁ ⟧) → v ≡ evalB c (eval c v) reverse unite₊ (inj₁ ()) reverse unite₊ (inj₂ y) = refl reverse uniti₊ v = refl reverse swap₊ (inj₁ x) = refl reverse swap₊ (inj₂ y) = refl reverse assocl₊ (inj₁ x) = refl reverse assocl₊ (inj₂ (inj₁ x)) = refl reverse assocl₊ (inj₂ (inj₂ y)) = refl reverse assocr₊ (inj₁ (inj₁ x)) = refl reverse assocr₊ (inj₁ (inj₂ y)) = refl reverse assocr₊ (inj₂ y) = refl reverse unite⋆ v = refl reverse uniti⋆ v = refl reverse swap⋆ v = refl reverse assocl⋆ v = refl reverse assocr⋆ v = refl reverse id⟷ v = refl reverse (op c) v = reverse' c v reverse (c ◎ c₁) v = trans (reverse c v) (cong (evalB c) (reverse c₁ (eval c v))) reverse (c ⊕ _) (inj₁ x) = cong inj₁ (reverse c x) reverse (_ ⊕ c) (inj₂ y) = cong inj₂ (reverse c y) reverse (c₁ ⊗ c₂) (x , y) = cong₂ _,_ (reverse c₁ x) (reverse c₂ y) reverse ε (x , y , z) = {!!} reverse' : {b₁ b₂ : B} (c : b₁ ⟷ b₂) → (w : ⟦ b₂ ⟧) → w ≡ eval c (evalB c w) reverse' unite₊ w = refl reverse' uniti₊ (inj₁ ()) reverse' uniti₊ (inj₂ y) = refl reverse' swap₊ (inj₁ x) = refl reverse' swap₊ (inj₂ y) = refl reverse' assocl₊ (inj₁ (inj₁ x)) = refl reverse' assocl₊ (inj₁ (inj₂ y)) = refl reverse' assocl₊ (inj₂ y) = refl reverse' assocr₊ (inj₁ x) = refl reverse' assocr₊ (inj₂ (inj₁ x)) = refl reverse' assocr₊ (inj₂ (inj₂ y)) = refl reverse' unite⋆ w = refl reverse' uniti⋆ w = refl reverse' swap⋆ w = refl reverse' assocl⋆ w = refl reverse' assocr⋆ w = refl reverse' id⟷ w = refl reverse' (op c) w = reverse c w reverse' (c ◎ c₁) w = trans (reverse' c₁ w) (cong (eval c₁) (reverse' c (evalB c₁ w))) reverse' (c ⊕ _) (inj₁ x) = cong inj₁ (reverse' c x) reverse' (_ ⊕ c) (inj₂ y) = cong inj₂ (reverse' c y) reverse' (c₁ ⊗ c₂) (x , y) = cong₂ _,_ (reverse' c₁ x) (reverse' c₂ y) reverse' ε _ = refl ------------------------------------------------------------------------------ -- Proofs of reversibility {- -- they are properly inverse of each other -- easy direction η∘ε : {b : B} (v : ⟦ b ⟧) → eval {b} (η ◎ ε) v ≡ v η∘ε _ = refl -- hard direction. ε∘η : {b : B} (v : ⟦ b ⟧) → { w : Σ < v > (λ _ → < v > → ⊤) } → (eval {DTIMES b (leftIdemp {b}) } {_} (ε ◎ η) (v , w)) ≡ (v , w) ε∘η {b} v {(singleton .v refl , r )} = cong f {v , v , (singleton v refl)} refl where f : Σ ⟦ b ⟧ (λ x → Σ ⟦ b ⟧ (λ y → < v >)) → Σ ⟦ b ⟧ (λ z → Σ < z > (λ x → < z > → ⊤ )) f (_ , (_ , j)) = (v , j , r) ------------------------------------------------------------------------------ -- Examples -- Now need to write some actual programs... makeFunc : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → b₁ ⟷ DTIMES b₁ (λ x → TIMES (SING (eval c x)) (RECIP x)) makeFunc c = η ◎ slide (λ {_} → (lift c refl) ⊗ id⟷) -} ------------------------------------------------------------------------------ ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4971106413, "avg_line_length": 35.2985074627, "ext": "agda", "hexsha": "38c8ea832bc83baf3ec010119ef3d9bad1cde15f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "agda/PiPath.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "agda/PiPath.agda", "max_line_length": 79, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "agda/PiPath.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3124, "size": 7095 }