Search is not available for this dataset
text
string
meta
dict
module Nat where open import Prelude open import Star Nat : Set Nat = Star One _ _ zero : Nat zero = ε suc : Nat -> Nat suc n = _ • n infixl 50 _+_ _-_ infixl 60 _*_ _+_ : Nat -> Nat -> Nat _+_ = _++_ _*_ : Nat -> Nat -> Nat x * y = bind id (\ _ -> y) x _-_ : Nat -> Nat -> Nat n - ε = n ε - m = ε (_ • n) - (_ • m) = n - m test : Nat test = suc (suc zero) * suc (suc zero)
{ "alphanum_fraction": 0.4975490196, "avg_line_length": 12.75, "ext": "agda", "hexsha": "c929e730dfcddaad970f9657882cbd72b99e751e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/AIM6/Path/Nat.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/AIM6/Path/Nat.agda", "max_line_length": 38, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/AIM6/Path/Nat.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": 158, "size": 408 }
data N : Set where Z : N suc : N -> N
{ "alphanum_fraction": 0.4761904762, "avg_line_length": 10.5, "ext": "agda", "hexsha": "075f59875b6fe544b09e583ccb7f300d4ac1e9b0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-27T16:25:18.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-27T16:25:18.000Z", "max_forks_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hjorthjort/IdrisToAgda", "max_forks_repo_path": "agdaData.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_issues_repo_issues_event_max_datetime": "2019-11-28T17:52:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-11-28T17:52:42.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hjorthjort/IdrisToAgda", "max_issues_repo_path": "agdaData.agda", "max_line_length": 18, "max_stars_count": 2, "max_stars_repo_head_hexsha": "a5f65e28cc9fdfefde49e7d8cf84486601b9e7b1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hjorthjort/IdrisToAgda", "max_stars_repo_path": "agdaData.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-29T20:42:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-16T23:22:50.000Z", "num_tokens": 18, "size": 42 }
open import Prelude module RW.Data.RTrie.Decl where open import RW.Language.RTerm public open import RW.Language.RTermIdx public open import RW.Data.PMap (RTermᵢ ⊥) as IdxMap data Rule : Set where Gr : ℕ → Rule Tr : ℕ → ℕ → Rule Fr : ℕ → Name → Rule mutual Cell : Set Cell = IdxMap.to RTrie default -- Map from indexes to tries, × List (ℕ × List Rule) -- Binding symbols, data RTrie : Set where Fork : List Cell → RTrie Leaf : List Rule → RTrie BTrieEmpty : RTrie BTrieEmpty = Fork $ []
{ "alphanum_fraction": 0.6144366197, "avg_line_length": 22.72, "ext": "agda", "hexsha": "c6b54e1c6047ec4165ab10befd70d480009db8a1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/Data/RTrie/Decl.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/Data/RTrie/Decl.agda", "max_line_length": 68, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/Data/RTrie/Decl.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 169, "size": 568 }
{-# OPTIONS --without-K #-} module TypeEquivCat where -- We will define a rig category whose objects are types and whose -- morphisms are type equivalences; and where the equivalence of -- morphisms ≋ is extensional open import Level renaming (zero to lzero; suc to lsuc) open import Data.Empty using (⊥) open import Data.Unit using (⊤) open import Data.Sum using (_⊎_) open import Data.Product using (_,_; _×_; uncurry) open import Data.Fin using (Fin; zero; suc) -- needed for distributivity import Relation.Binary.PropositionalEquality as P using (sym) open import Categories.Category using (Category) open import Categories.Groupoid using (Groupoid) open import Categories.Monoidal using (Monoidal) open import Categories.Monoidal.Helpers using (module MonoidalHelperFunctors) open import Categories.Bifunctor using (Bifunctor) open import Categories.NaturalIsomorphism using (NaturalIsomorphism) open import Categories.Monoidal.Braided using (Braided) open import Categories.Monoidal.Symmetric using (Symmetric) open import Categories.RigCategory using (RigCategory; module BimonoidalHelperFunctors) open import Equiv using (_≃_; id≃; sym≃; _●_; _⊎≃_; _×≃_) open import EquivEquiv using (_≋_; eq; id≋; sym≋; trans≋; ●-assoc; _◎_; linv≋; rinv≋; lid≋; rid≋; flip-sym≋) -- list all explicitly, but these are all equivalences open import TypeEquiv using (unite₊equiv; uniti₊equiv; unite₊′equiv; uniti₊′equiv; assocr₊equiv; assocl₊equiv; unite⋆equiv; uniti⋆equiv; unite⋆′equiv; uniti⋆′equiv; assocr⋆equiv; assocl⋆equiv; swap₊equiv; swap⋆equiv; distequiv; factorequiv; distlequiv; factorlequiv; distzequiv; factorzequiv; distzrequiv; factorzrequiv) open import TypeEquivEquiv -- need them all! -- convenience one two : Fin 3 one = suc zero two = suc (suc zero) ------------------------------------------------------------------------------ -- We show that types with type equivalences are a commutative rig -- groupoid -- First it is a category TypeEquivCat : Category (lsuc lzero) lzero lzero TypeEquivCat = record { Obj = Set ; _⇒_ = _≃_ ; _≡_ = _≋_ ; id = id≃ ; _∘_ = _●_ ; assoc = λ { {f = f} {g} {h} → ●-assoc {f = f} {g} {h} } ; identityˡ = lid≋ ; identityʳ = rid≋ ; equiv = record { refl = id≋ ; sym = sym≋ ; trans = trans≋ } ; ∘-resp-≡ = _◎_ } -- The category has inverses and hence a groupoid TypeEquivGroupoid : Groupoid TypeEquivCat TypeEquivGroupoid = record { _⁻¹ = sym≃ ; iso = λ { {f = A≃B} → record { isoˡ = linv≋ A≃B ; isoʳ = rinv≋ A≃B } } } -- The additive structure is monoidal ⊎-bifunctor : Bifunctor TypeEquivCat TypeEquivCat TypeEquivCat ⊎-bifunctor = record { F₀ = uncurry _⊎_ ; F₁ = uncurry _⊎≃_ ; identity = [id,id]≋id ; homomorphism = ⊎●≋●⊎ ; F-resp-≡ = uncurry _⊎≋_ } module ⊎h = MonoidalHelperFunctors TypeEquivCat ⊎-bifunctor ⊥ 0⊎x≡x : NaturalIsomorphism ⊎h.id⊗x ⊎h.x 0⊎x≡x = record { F⇒G = record { η = λ X → unite₊equiv {X zero} ; commute = λ f → unite₊-nat {f = f zero} } ; F⇐G = record { η = λ X → uniti₊equiv {X zero} ; commute = λ f → uniti₊-nat {f = f zero} } ; iso = λ _ → record { isoˡ = linv≋ unite₊equiv ; isoʳ = rinv≋ unite₊equiv } } x⊎0≡x : NaturalIsomorphism ⊎h.x⊗id ⊎h.x x⊎0≡x = record { F⇒G = record { η = λ X → unite₊′equiv {X zero} ; commute = λ f → unite₊′-nat {f = f zero} } ; F⇐G = record { η = λ X → uniti₊′equiv {X zero} ; commute = λ f → uniti₊′-nat {f = f zero} } ; iso = λ X → record { isoˡ = linv≋ unite₊′equiv ; isoʳ = rinv≋ unite₊′equiv } } [x⊎y]⊎z≡x⊎[y⊎z] : NaturalIsomorphism ⊎h.[x⊗y]⊗z ⊎h.x⊗[y⊗z] [x⊎y]⊎z≡x⊎[y⊎z] = record { F⇒G = record { η = λ X → assocr₊equiv {X zero} {X one} {X two} ; commute = λ f → assocr₊-nat {f₀ = f zero} {f one} {f two} } ; F⇐G = record { η = λ X → assocl₊equiv {X zero} {X one} {X two} ; commute = λ f → assocl₊-nat {f₀ = f zero} {f one} {f two} } ; iso = λ X → record { isoˡ = linv≋ assocr₊equiv ; isoʳ = rinv≋ assocr₊equiv } } CPM⊎ : Monoidal TypeEquivCat CPM⊎ = record { ⊗ = ⊎-bifunctor ; id = ⊥ ; identityˡ = 0⊎x≡x ; identityʳ = x⊎0≡x ; assoc = [x⊎y]⊎z≡x⊎[y⊎z] ; triangle = unite-assocr₊-coh ; pentagon = assocr₊-coh } -- The multiplicative structure is also monoidal ×-bifunctor : Bifunctor TypeEquivCat TypeEquivCat TypeEquivCat ×-bifunctor = record { F₀ = uncurry _×_ ; F₁ = uncurry _×≃_ ; identity = id×id≋id -- the following would have unresolved metas without the extra precision ; homomorphism = λ { {f = (f , g)} {h , i} → ×●≋●× {f = f} {g} {h} {i}} ; F-resp-≡ = uncurry _×≋_ } module ×h = MonoidalHelperFunctors TypeEquivCat ×-bifunctor ⊤ 1×y≡y : NaturalIsomorphism ×h.id⊗x ×h.x 1×y≡y = record { F⇒G = record { η = λ X → unite⋆equiv {X zero} ; commute = λ f → unite⋆-nat {f = f zero} } ; F⇐G = record { η = λ X → uniti⋆equiv {X zero} ; commute = λ f → uniti⋆-nat {f = f zero} } ; iso = λ X → record { isoˡ = linv≋ unite⋆equiv ; isoʳ = rinv≋ unite⋆equiv } } y×1≡y : NaturalIsomorphism ×h.x⊗id ×h.x y×1≡y = record { F⇒G = record { η = λ X → unite⋆′equiv {X zero} ; commute = λ f → unite⋆′-nat {f = f zero} } ; F⇐G = record { η = λ X → uniti⋆′equiv {X zero} ; commute = λ f → uniti⋆′-nat {f = f zero} } ; iso = λ X → record { isoˡ = linv≋ unite⋆′equiv ; isoʳ = rinv≋ unite⋆′equiv } } [x×y]×z≡x×[y×z] : NaturalIsomorphism ×h.[x⊗y]⊗z ×h.x⊗[y⊗z] [x×y]×z≡x×[y×z] = record { F⇒G = record { η = λ X → assocr⋆equiv {X zero} {X one} {X two} ; commute = λ f → assocr⋆-nat {f₀ = f zero} {f one} {f two}} ; F⇐G = record { η = λ X → assocl⋆equiv {X zero} {X one} {X two} ; commute = λ f → assocl⋆-nat {f₀ = f zero} {f one} {f two}} ; iso = λ X → record { isoˡ = linv≋ assocr⋆equiv ; isoʳ = rinv≋ assocr⋆equiv } } CPM× : Monoidal TypeEquivCat CPM× = record { ⊗ = ×-bifunctor ; id = ⊤ ; identityˡ = 1×y≡y ; identityʳ = y×1≡y ; assoc = [x×y]×z≡x×[y×z] ; triangle = unite-assocr⋆-coh ; pentagon = assocr⋆-coh } -- The monoidal structures are symmetric x⊎y≈y⊎x : NaturalIsomorphism ⊎h.x⊗y ⊎h.y⊗x x⊎y≈y⊎x = record { F⇒G = record { η = λ X → swap₊equiv {X zero} {X (suc zero)} ; commute = λ f → swap₊-nat {f = f zero} {f (suc zero)} } ; F⇐G = record { η = λ X → sym≃ (swap₊equiv {X zero} {X (suc zero)}) ; commute = λ f → swap₊-nat {f = f (suc zero)} {f zero} } ; iso = λ X → record { isoˡ = linv≋ swap₊equiv ; isoʳ = rinv≋ swap₊equiv } } BM⊎ : Braided CPM⊎ BM⊎ = record { braid = x⊎y≈y⊎x ; unit-coh = unite₊l-coh ; hexagon₁ = assocr₊-swap₊-coh ; hexagon₂ = assocl₊-swap₊-coh } x×y≈y×x : NaturalIsomorphism ×h.x⊗y ×h.y⊗x x×y≈y×x = record { F⇒G = record { η = λ X → swap⋆equiv ; commute = λ _ → swap⋆-nat } ; F⇐G = record { η = λ X → sym≃ swap⋆equiv ; commute = λ f → swap⋆-nat } ; iso = λ X → record { isoˡ = linv≋ swap⋆equiv ; isoʳ = rinv≋ swap⋆equiv } } BM× : Braided CPM× BM× = record { braid = x×y≈y×x ; unit-coh = unite⋆l-coh ; hexagon₁ = assocr⋆-swap⋆-coh ; hexagon₂ = assocl⋆-swap⋆-coh } SBM⊎ : Symmetric BM⊎ SBM⊎ = record { symmetry = linv≋ swap₊equiv } SBM× : Symmetric BM× SBM× = record { symmetry = linv≋ swap⋆equiv } -- And finally the multiplicative structure distributes over the -- additive one module r = BimonoidalHelperFunctors BM⊎ BM× x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] : NaturalIsomorphism r.x⊗[y⊕z] r.[x⊗y]⊕[x⊗z] x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] = record { F⇒G = record { η = λ X → distlequiv {X zero} {X one} {X two} ; commute = λ f → distl-nat {f = f zero} {f one} {f two} } ; F⇐G = record { η = λ X → factorlequiv {X zero} {X one} {X two} ; commute = λ f → factorl-nat {f = f zero} {f one} {f two} } ; iso = λ X → record { isoˡ = linv≋ distlequiv ; isoʳ = rinv≋ distlequiv } } [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] : NaturalIsomorphism r.[x⊕y]⊗z r.[x⊗z]⊕[y⊗z] [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] = record { F⇒G = record { η = λ X → distequiv ; commute = λ f → dist-nat } ; F⇐G = record { η = λ X → factorequiv ; commute = λ f → factor-nat } ; iso = λ X → record { isoˡ = linv≋ distequiv ; isoʳ = rinv≋ distequiv } } x⊗0≡0 : NaturalIsomorphism r.x⊗0 r.0↑ x⊗0≡0 = record { F⇒G = record { η = λ X → distzrequiv {X zero} ; commute = λ f → distzr-nat {f = f zero} } ; F⇐G = record { η = λ X → factorzrequiv {X zero} ; commute = λ f → factorzr-nat {f = f zero} } ; iso = λ X → record { isoˡ = linv≋ distzrequiv ; isoʳ = rinv≋ distzrequiv } } 0⊗x≡0 : NaturalIsomorphism r.0⊗x r.0↑ 0⊗x≡0 = record { F⇒G = record { η = λ X → distzequiv {X zero} ; commute = λ f → distz-nat {f = f zero} } ; F⇐G = record { η = λ X → factorzequiv {X zero} ; commute = λ f → factorz-nat {f = f zero} } ; iso = λ X → record { isoˡ = linv≋ (distzequiv {X zero}) ; isoʳ = rinv≋ distzequiv } } TERig : RigCategory SBM⊎ SBM× TERig = record -- new combinators { distribₗ = x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] ; distribᵣ = [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] ; annₗ = 0⊗x≡0 ; annᵣ = x⊗0≡0 -- derived identities which are ``coherent'' in that the -- two natural programs, using the new combinators and -- the underlying ones of the symmetric bimonoidal groupoid -- are in fact to be identified. ; laplazaI = λ {X} → A×[B⊎C]≃[A×C]⊎[A×B] {X zero} {X one} {X two} ; laplazaII = λ {X} → [A⊎B]×C≃[C×A]⊎[C×B] {X zero} {X one} {X two} ; laplazaIV = λ {X} → [A⊎B⊎C]×D≃[A×D⊎B×D]⊎C×D {X zero} {X (suc zero)} {X (suc (suc zero))} {X (suc (suc (suc zero)))} ; laplazaVI = λ {X} → A×B×[C⊎D]≃[A×B]×C⊎[A×B]×D {X zero} {X (suc zero)} {X (suc (suc zero))} {X (suc (suc (suc zero)))} ; laplazaIX = λ {X} → [A⊎B]×[C⊎D]≃[[A×C⊎B×C]⊎A×D]⊎B×D {X zero} {X (suc zero)} {X (suc (suc zero))} {X (suc (suc (suc zero)))} ; laplazaX = 0×0≃0 ; laplazaXI = λ {X} → 0×[A⊎B]≃0 {X zero} {X (suc zero)} ; laplazaXIII = 0×1≃0 ; laplazaXV = λ {X} → A×0≃0 {X zero} ; laplazaXVI = λ {X} → 0×A×B≃0 {X zero} {X (suc zero)} ; laplazaXVII = λ {X} → A×0×B≃0 {X zero} {X (suc zero)} ; laplazaXIX = λ {X} → A×[0+B]≃A×B {X zero} {X (suc zero)} ; laplazaXXIII = λ {X} → 1×[A⊎B]≃A⊎B {X zero} {X (suc zero)} } -- Notes from Laplaza, 72 -- All of 2, 9, 10, 15 -- one of each of {1,3}, {4,5}, {6,7}, {9, 12},{13,,14}, -- {19,20,21,22}, {23,24} -- two-of-three of {16,17,18} -- -- for natural isos -- α : A × (B × C) → (A × B) × C -- γ : A × B → B × A -- λ : U × A → A (so that U is 1) -- ρ : A × U → A -- λ* : N × A → N (so that N is 0) -- ρ* : A × n → N -- and ' versions for ⊕ -- as well as natural monomorphisms -- δ : A × (B ⊎ C) → (A × B) ⊎ (A × C) -- δ# : (A ⊎ B) × C → (A × C) ⊎ (B × C) ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5325868253, "avg_line_length": 28.7934508816, "ext": "agda", "hexsha": "42e331719a44e6531917ad56c5d493e942475249", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/TypeEquivCat.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/TypeEquivCat.agda", "max_line_length": 80, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/TypeEquivCat.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": 5055, "size": 11431 }
module _ where data X : Set where data R (x : X) : Set where module SUListSepElemTypes where module M2 (Elem : Set) where data InclWith : Set where module M1 where module InclZip1 (R : X → Set) where open M2 X public module InclZipUnion (Y : Set) where module SepElemTypes = SUListSepElemTypes module Zip⊆ = SepElemTypes.M1.InclZip1 R module Zip⊆∪ = Zip⊆.InclZipUnion X
{ "alphanum_fraction": 0.6957605985, "avg_line_length": 19.0952380952, "ext": "agda", "hexsha": "ac930c33bb0f68c37c8b3cfacb0224e58f93aad6", "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/Issue1701e.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/Issue1701e.agda", "max_line_length": 41, "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/Issue1701e.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": 138, "size": 401 }
open import Everything module Test.Test5 {𝔵} {𝔛 : Ø 𝔵} {𝔞} {𝔒₁ : 𝔛 → Ø 𝔞} {𝔟} {𝔒₂ : 𝔛 → Ø 𝔟} {ℓ} {ℓ̇} (_↦_ : ∀ {x} → 𝔒₂ x → 𝔒₂ x → Ø ℓ̇) ⦃ _ : [ExtensibleType] _↦_ ⦄ ⦃ _ : Smap!.class (Arrow 𝔒₁ 𝔒₂) (Extension 𝔒₂) ⦄ ⦃ _ : Surjextensionality!.class (Arrow 𝔒₁ 𝔒₂) (Pointwise _↦_) (Extension 𝔒₂) (Pointwise _↦_) ⦄ -- ⦃ _ : [𝓢urjectivity] (Arrow 𝔒₁ 𝔒₂) (Extension $ ArrowExtensionṖroperty ℓ 𝔒₁ 𝔒₂ _↦_) ⦄ where test[∙] : ∀ {x y} → ArrowExtensionṖroperty ℓ 𝔒₁ 𝔒₂ _↦_ x → Arrow 𝔒₁ 𝔒₂ x y → ArrowExtensionṖroperty ℓ 𝔒₁ 𝔒₂ _↦_ y test[∙] P f = f ◃ P
{ "alphanum_fraction": 0.5757042254, "avg_line_length": 33.4117647059, "ext": "agda", "hexsha": "c50ffa5cd957bd24dae5e6d58f6dbd39d08d4d60", "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/Test5.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/Test5.agda", "max_line_length": 117, "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/Test5.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 346, "size": 568 }
module Div2 where record True : Set where data False : Set where data Nat : Set where zero : Nat suc : Nat -> Nat NonZero : Nat -> Set NonZero zero = False NonZero (suc _) = True divHelp : Nat -> Nat -> Nat -> Nat divHelp zero zero c = suc zero divHelp zero (suc y) c = zero divHelp (suc x) zero c = suc (divHelp x c c) divHelp (suc x) (suc y) c = divHelp x y c div : (x y : Nat) -> {p : NonZero y} -> Nat div x zero {} div zero (suc y) = zero div (suc x) (suc y) = divHelp (suc x) (suc y) y n1 = suc zero n2 = suc n1 n3 = suc n2 n4 = suc n3 n5 = suc n4 n6 = suc n5 n7 = suc n6 n8 = suc n7 n9 = suc n8 n10 = suc n9 n11 = suc n10 n12 = suc n11 test1 : Nat test1 = div n12 n7
{ "alphanum_fraction": 0.593006993, "avg_line_length": 16.6279069767, "ext": "agda", "hexsha": "cd2224be080cfed5fb524d6ecabf83b3a8b3ec86", "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/Div2.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/Div2.agda", "max_line_length": 47, "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/Div2.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": 299, "size": 715 }
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness #-} module Agda.Builtin.IO where postulate IO : ∀ {a} → Set a → Set a {-# BUILTIN IO IO #-} {-# FOREIGN GHC type AgdaIO a b = IO b #-} {-# COMPILE GHC IO = type AgdaIO #-}
{ "alphanum_fraction": 0.6083333333, "avg_line_length": 24, "ext": "agda", "hexsha": "b9309adf477cc4051dbd8d2fa20aee3c1a43235e", "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": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/IO.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/IO.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/IO.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 70, "size": 240 }
open import Oscar.Prelude module Oscar.Class.Pure where module _ {𝔬 𝔣} (𝔉 : Ø 𝔬 → Ø 𝔣) where 𝓹ure = ∀ {𝔒 : Ø 𝔬} → 𝔒 → 𝔉 𝔒 record 𝓟ure : Ø 𝔣 ∙̂ ↑̂ 𝔬 where field pure : 𝓹ure open 𝓟ure ⦃ … ⦄ public
{ "alphanum_fraction": 0.570754717, "avg_line_length": 15.1428571429, "ext": "agda", "hexsha": "ad2fd123812882ef050956109e1c446d11f4f0f0", "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/Pure.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/Pure.agda", "max_line_length": 33, "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/Pure.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 119, "size": 212 }
record R₁ : Set₁ where field A : Set open R₁ ⦃ … ⦄ record R₂ : Set₁ where field ⦃ r₁ ⦄ : R₁ B : Set B = A
{ "alphanum_fraction": 0.5079365079, "avg_line_length": 9, "ext": "agda", "hexsha": "7c44bf48fd8a932a3a0cb9d1bca78815351aea8a", "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/Issue2320.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/Issue2320.agda", "max_line_length": 22, "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/Issue2320.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": 62, "size": 126 }
module Data.Bindings.Everything where import Data.ByteString import Data.ByteString.Primitive import Data.ByteString.UTF8 import Data.ByteString.UTF8.Primitive import Data.Char.Classifier import Data.Char.Classifier.Primitive import Data.List.Primitive import Data.Maybe.Primitive import Data.Natural import Data.Natural.Primitive import Data.Strict import Data.Strict.Primitive import Data.Word import Data.Word.Primitive
{ "alphanum_fraction": 0.858490566, "avg_line_length": 24.9411764706, "ext": "agda", "hexsha": "6632436b822e7f5f3b988b15b9ce2bdd59b0de38", "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/Bindings/Everything.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/Bindings/Everything.agda", "max_line_length": 37, "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/Bindings/Everything.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": 91, "size": 424 }
------------------------------------------------------------------------ -- Suspensions ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- The beginning of this module follows the HoTT book rather closely. -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining suspensions uses path equality, but -- the supplied notion of equality is used for many other things. import Equality.Path as P module Suspension {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection equality-with-J as Bijection using (_↔_) open import Embedding equality-with-J as Embedding using (Embedding) open import Equality.Decision-procedures equality-with-J open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J using (_≃_) open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import Injection equality-with-J using (_↣_) open import Interval eq as Interval using (Interval; [0]; [1]; 0≡1) import Nat equality-with-J as Nat open import Pointed-type equality-with-J using (Pointed-type; _→ᴮ_; Ω) open import Surjection equality-with-J using (_↠_) private variable a b ℓ ℓ₁ ℓ₂ p : Level A B : Type a C : Pointed-type a x y : A f g : A → B n : ℕ -- Suspensions. data Susp (A : Type a) : Type a where north south : Susp A meridianᴾ : A → north P.≡ south -- Meridians. meridian : A → _≡_ {A = Susp A} north south meridian = _↔_.from ≡↔≡ ∘ meridianᴾ -- A dependent eliminator, expressed using paths. elimᴾ : (P : Susp A → Type p) (n : P north) (s : P south) → (∀ x → P.[ (λ i → P (meridianᴾ x i)) ] n ≡ s) → (x : Susp A) → P x elimᴾ _ n s n≡s = λ where north → n south → s (meridianᴾ x i) → n≡s x i -- A non-dependent eliminator, expressed using paths. recᴾ : (n s : B) → (A → n P.≡ s) → Susp A → B recᴾ = elimᴾ _ -- A dependent eliminator. module Elim (P : Susp A → Type p) (n : P north) (s : P south) (n≡s : ∀ x → subst P (meridian x) n ≡ s) where elim : ∀ x → P x elim = elimᴾ P n s (subst≡→[]≡ ∘ n≡s) -- "Computation" rule for meridians. elim-meridian : dcong elim (meridian x) ≡ n≡s x elim-meridian = dcong-subst≡→[]≡ (refl _) open Elim public -- A non-dependent eliminator. module Rec {B : Type b} (n s : B) (n≡s : A → n ≡ s) where rec : Susp A → B rec = recᴾ n s (_↔_.to ≡↔≡ ∘ n≡s) rec-meridian : cong rec (meridian x) ≡ n≡s x rec-meridian = cong-≡↔≡ (refl _) open Rec public -- The universal property of suspensions. universal-property : (Susp A → B) ↔ (∃ λ (n : B) → ∃ λ (s : B) → A → n ≡ s) universal-property = record { surjection = record { logical-equivalence = record { to = λ f → f north , f south , cong f ∘ meridian ; from = λ { (n , s , f) → rec n s f } } ; right-inverse-of = λ { (n , s , f) → n , s , cong (rec n s f) ∘ meridian ≡⟨ cong (λ f → n , s , f) $ ⟨ext⟩ (λ _ → rec-meridian n s f) ⟩∎ n , s , f ∎ } } ; left-inverse-of = λ f → let module R = Rec (f north) (f south) (cong f ∘ meridian) in R.rec ≡⟨ ⟨ext⟩ $ elim _ (refl _) (refl _) (λ x → subst (λ x → R.rec x ≡ f x) (meridian x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym $ cong R.rec (meridian x)) (trans (refl _) (cong f (meridian x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) R.rec-meridian (trans-reflˡ _) ⟩ trans (sym $ cong f (meridian x)) (cong f (meridian x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) ⟩∎ f ∎ } -- Based maps from suspensions of pointed types (using north as the -- point) are isomorphic to based maps to loop spaces. Susp→ᴮ↔ : (Susp A , north) →ᴮ C ↔ (A , x) →ᴮ Ω C Susp→ᴮ↔ {A = A} {C = B , y} {x = x} = (Susp A , north) →ᴮ (B , y) ↔⟨⟩ (∃ λ (f : Susp A → B) → f north ≡ y) ↝⟨ Σ-cong universal-property (λ _ → F.id) ⟩ (∃ λ (f : ∃ λ n → ∃ λ s → A → n ≡ s) → proj₁ f ≡ y) ↝⟨ inverse Σ-assoc ⟩ (∃ λ n → (∃ λ s → A → n ≡ s) × n ≡ y) ↝⟨ (∃-cong λ _ → inverse Σ-assoc) ⟩ (∃ λ n → ∃ λ s → (A → n ≡ s) × n ≡ y) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ×-comm) ⟩ (∃ λ n → ∃ λ s → n ≡ y × (A → n ≡ s)) ↝⟨ (∃-cong λ _ → ∃-comm) ⟩ (∃ λ n → n ≡ y × ∃ λ s → A → n ≡ s) ↝⟨ Σ-assoc ⟩ (∃ λ (p : ∃ λ n → n ≡ y) → ∃ λ s → A → proj₁ p ≡ s) ↝⟨ drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $ singleton-contractible _ ⟩ (∃ λ s → A → y ≡ s) ↝⟨ (∃-cong λ _ → inverse $ drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _) ⟩ (∃ λ s → ∃ λ (f : A → y ≡ s) → ∃ λ (eq : y ≡ s) → f x ≡ eq) ↝⟨ (∃-cong λ _ → ∃-comm) ⟩ (∃ λ s → ∃ λ (eq : y ≡ s) → ∃ λ (f : A → y ≡ s) → f x ≡ eq) ↝⟨ Σ-assoc ⟩ (∃ λ (p : ∃ λ s → y ≡ s) → ∃ λ (f : A → y ≡ proj₁ p) → f x ≡ proj₂ p) ↝⟨ drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _ ⟩ (∃ λ (f : A → y ≡ y) → f x ≡ refl y) ↔⟨⟩ (A , x) →ᴮ (Ω (B , y)) □ -- The type of booleans can be expressed as a suspension. Bool↔Susp-⊥ : Bool ↔ Susp (⊥ {ℓ = ℓ}) Bool↔Susp-⊥ = record { surjection = record { logical-equivalence = record { to = if_then north else south ; from = rec true false (λ ()) } ; right-inverse-of = elim _ (refl _) (refl _) (λ ()) } ; left-inverse-of = λ where true → refl _ false → refl _ } private -- A lemma used in some proofs below. subst-in-terms-of-trans-and-cong′ : {x≡y : x ≡ y} {fgx≡x : f (g x) ≡ x} → subst (λ z → f (g z) ≡ z) x≡y fgx≡x ≡ trans (sym (cong f (cong g x≡y))) (trans fgx≡x x≡y) subst-in-terms-of-trans-and-cong′ {f = f} {g = g} {x≡y = x≡y} {fgx≡x = fgx≡x} = subst (λ z → f (g z) ≡ z) x≡y fgx≡x ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (f ∘ g) x≡y)) (trans fgx≡x (cong id x≡y)) ≡⟨ sym $ cong₂ (λ p q → trans (sym p) (trans fgx≡x q)) (cong-∘ _ _ _) (cong-id _) ⟩∎ trans (sym (cong f (cong g x≡y))) (trans fgx≡x x≡y) ∎ -- The remainder of this module is not based on the HoTT book. -- The interval can be expressed as a suspension. Interval↔Susp-⊤ : Interval ↔ Susp ⊤ Interval↔Susp-⊤ = record { surjection = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = elim _ (refl _) (refl _) (λ _ → subst (λ x → to (from x) ≡ x) (meridian tt) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong′ ⟩ trans (sym (cong to (cong from (meridian tt)))) (trans (refl _) (meridian tt)) ≡⟨ cong₂ (λ p q → trans (sym (cong to p)) q) (rec-meridian _ _ _) (trans-reflˡ _) ⟩ trans (sym (cong to 0≡1)) (meridian tt) ≡⟨ cong (λ p → trans (sym p) (meridian tt)) $ Interval.rec-0≡1 _ _ _ ⟩ trans (sym (meridian tt)) (meridian tt) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) } ; left-inverse-of = Interval.elim _ (refl _) (refl _) (subst (λ x → from (to x) ≡ x) 0≡1 (refl _) ≡⟨ subst-in-terms-of-trans-and-cong′ ⟩ trans (sym (cong from (cong to 0≡1))) (trans (refl _) 0≡1) ≡⟨ cong₂ (λ p q → trans (sym (cong from p)) q) (Interval.rec-0≡1 _ _ _) (trans-reflˡ _) ⟩ trans (sym (cong from (meridian tt))) 0≡1 ≡⟨ cong (λ p → trans (sym p) 0≡1) $ rec-meridian _ _ _ ⟩ trans (sym 0≡1) 0≡1 ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) } where to = Interval.rec north south (meridian tt) from = rec [0] [1] λ _ → 0≡1 -- A map function. map : (A → B) → Susp A → Susp B map A→B = rec north south (meridian ∘ A→B) private -- A helper function used to implement cong-↠ and cong-↔. map∘map : (∀ x → f (g x) ≡ x) → ∀ x → map f (map g x) ≡ x map∘map {f = f} {g = g} hyp = elim _ (refl _) (refl _) (λ x → subst (λ x → map f (map g x) ≡ x) (meridian x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong′ ⟩ trans (sym $ cong (map f) $ cong (map g) (meridian x)) (trans (refl _) (meridian x)) ≡⟨ cong₂ (λ p q → trans (sym $ cong (map f) p) q) (rec-meridian _ _ _) (trans-reflˡ _) ⟩ trans (sym $ cong (map f) $ meridian (g x)) (meridian x) ≡⟨ cong (λ p → trans (sym p) (meridian x)) $ rec-meridian _ _ _ ⟩ trans (sym $ meridian (f (g x))) (meridian x) ≡⟨ cong (λ y → trans (sym $ meridian y) (meridian x)) $ hyp x ⟩ trans (sym $ meridian x) (meridian x) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- Some preservation lemmas. cong-⇔ : A ⇔ B → Susp A ⇔ Susp B cong-⇔ A⇔B = record { to = map (_⇔_.to A⇔B) ; from = map (_⇔_.from A⇔B) } cong-↠ : A ↠ B → Susp A ↠ Susp B cong-↠ A↠B = record { logical-equivalence = cong-⇔ (_↠_.logical-equivalence A↠B) ; right-inverse-of = map∘map (_↠_.right-inverse-of A↠B) } cong-↔ : A ↔ B → Susp A ↔ Susp B cong-↔ A↔B = record { surjection = cong-↠ (_↔_.surjection A↔B) ; left-inverse-of = map∘map (_↔_.left-inverse-of A↔B) } cong-≃ : A ≃ B → Susp A ≃ Susp B cong-≃ = from-isomorphism ∘ cong-↔ ∘ from-isomorphism private -- Lemmas used to implement ¬-cong-↣ and ¬-cong-Embedding. ⊥↣⊤ : ⊥ {ℓ = ℓ₁} ↣ ↑ ℓ₂ ⊤ ⊥↣⊤ = record { to = λ () ; injective = λ {} } ¬Susp⊥↣Susp⊤ : ¬ (Susp (⊥ {ℓ = ℓ₁}) ↣ Susp (↑ ℓ₂ ⊤)) ¬Susp⊥↣Susp⊤ = Susp ⊥ ↣ Susp (↑ _ ⊤) ↝⟨ (λ f → from-isomorphism (cong-↔ Bijection.↑↔) F.∘ f F.∘ from-isomorphism (cong-↔ ⊥↔⊥)) ⟩ Susp ⊥₀ ↣ Susp ⊤ ↝⟨ (λ f → from-isomorphism (inverse Interval↔Susp-⊤) F.∘ f F.∘ from-isomorphism Bool↔Susp-⊥) ⟩ Bool ↣ Interval ↝⟨ (λ inj → _↣_.to inj , _↣_.injective inj) ⟩ (∃ λ (f : Bool → Interval) → f true ≡ f false → true ≡ false) ↝⟨ Σ-map id (λ f → f (mono₁ 0 Interval.interval-contractible _ _)) ⟩ (Bool → Interval) × true ≡ false ↝⟨ proj₂ ⟩ true ≡ false ↝⟨ Bool.true≢false ⟩□ ⊥ □ -- Some negative preservation results. ¬-cong-↣ : ¬ (∀ {A : Type a} {B : Type b} → A ↣ B → Susp A ↣ Susp B) ¬-cong-↣ {a = a} {b = b} = (∀ {A B} → A ↣ B → Susp A ↣ Susp B) ↝⟨ (λ hyp → hyp) ⟩ (⊥ ↣ ↑ _ ⊤ → Susp ⊥ ↣ Susp (↑ _ ⊤)) ↝⟨ _$ ⊥↣⊤ ⟩ Susp ⊥ ↣ Susp (↑ _ ⊤) ↝⟨ ¬Susp⊥↣Susp⊤ ⟩□ ⊥ □ ¬-cong-Embedding : ¬ (∀ {A : Type a} {B : Type b} → Embedding A B → Embedding (Susp A) (Susp B)) ¬-cong-Embedding = (∀ {A B} → Embedding A B → Embedding (Susp A) (Susp B)) ↝⟨ (λ hyp → hyp) ⟩ (Embedding ⊥ (↑ _ ⊤) → Embedding (Susp ⊥) (Susp (↑ _ ⊤))) ↝⟨ _$ Emb-⊥-⊤ ⟩ Embedding (Susp ⊥) (Susp (↑ _ ⊤)) ↝⟨ Embedding.injection ⟩ Susp ⊥ ↣ Susp (↑ _ ⊤) ↝⟨ ¬Susp⊥↣Susp⊤ ⟩□ ⊥ □ where Emb-⊥-⊤ : Embedding ⊥ (↑ _ ⊤) Emb-⊥-⊤ = _↔_.to (Embedding.↣↔Embedding ext (mono₁ 1 ⊥-propositional) (mono (Nat.zero≤ 2) (↑-closure 0 ⊤-contractible))) ⊥↣⊤
{ "alphanum_fraction": 0.4391118572, "avg_line_length": 38.2099125364, "ext": "agda", "hexsha": "4a1e283ee4af22e47551bd091adb988d2e4d5e50", "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/Suspension.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/Suspension.agda", "max_line_length": 148, "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/Suspension.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": 4645, "size": 13106 }
open import Agda.Primitive using (lzero; lsuc; _⊔_) import SecondOrder.Arity import SecondOrder.MContext import SecondOrder.Signature module SecondOrder.Metavariable {ℓ} {𝔸 : SecondOrder.Arity.Arity} (Σ : SecondOrder.Signature.Signature ℓ 𝔸) where open SecondOrder.Signature.Signature Σ open SecondOrder.MContext VContext sort public
{ "alphanum_fraction": 0.7885714286, "avg_line_length": 21.875, "ext": "agda", "hexsha": "8e7af91e1c9d899b65f80317c090e49eabde9548", "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/SecondOrder/Metavariable.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/SecondOrder/Metavariable.agda", "max_line_length": 51, "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/SecondOrder/Metavariable.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": 106, "size": 350 }
module BTree.Equality {A : Set} where open import BTree {A} data _≃_ : BTree → BTree → Set where ≃lf : leaf ≃ leaf ≃nd : {l r l' r' : BTree} (x x' : A) → l ≃ r → l ≃ l' → l' ≃ r' → node x l r ≃ node x' l' r'
{ "alphanum_fraction": 0.3544303797, "avg_line_length": 24.3076923077, "ext": "agda", "hexsha": "b47fb79c2964c190529b26bc2f6725cecc3cb61b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BTree/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BTree/Equality.agda", "max_line_length": 48, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BTree/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 110, "size": 316 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} -- This module contains definitions of properties of only the behavior of the -- handlers, nothing concerning the system state. open import LibraBFT.Base.Types open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Concrete.Records open import LibraBFT.Impl.Consensus.ConsensusTypes.Block as Block open import LibraBFT.Impl.Consensus.EpochManagerTypes import LibraBFT.Impl.Handle as Handle open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochDep open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.ByteString open import Util.KVMap as Map open import Util.Lemmas open import Util.PKCS open import Util.Prelude open import LibraBFT.ImplShared.Util.HashCollisions Handle.InitHandler.initAndHandlers open import LibraBFT.Abstract.Types.EpochConfig UID NodeId open ParamsWithInitAndHandlers Handle.InitHandler.initAndHandlers open import Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms Handle.InitHandler.initAndHandlers PeerCanSignForPK PeerCanSignForPK-stable module LibraBFT.Impl.Properties.Util where module Meta where getLastVoteEpoch : SafetyData → Epoch getLastVoteEpoch sd = (Maybe-maybe{B = const Epoch} (_^∙ vEpoch) (sd ^∙ sdEpoch)) ∘ (_^∙ sdLastVote) $ sd -- getLastVoteEpoch rm = (maybe{B = const Epoch} (_^∙ vEpoch) (rm ^∙ pssSafetyData-rm ∙ sdEpoch)) ∘ (_^∙ pssSafetyData-rm ∙ sdLastVote) $ rm getLastVoteRound : SafetyData → Round getLastVoteRound = (Maybe-maybe{B = const Round} (_^∙ vRound) 0) ∘ (_^∙ sdLastVote) -- getLastVoteRound = maybe{B = const Round} (_^∙ vRound) 0 ∘ (_^∙ pssSafetyData-rm ∙ sdLastVote) subst-getLastVoteRound : ∀ {sd1 sd2} → sd1 ≡ sd2 → getLastVoteRound sd1 ≡ getLastVoteRound sd2 subst-getLastVoteRound refl = refl module OutputProps where module _ (outs : List Output) where None : Set None = outs ≡ [] NoVotes = NoneOfKind outs isSendVote? NoProposals = NoneOfKind outs isBroadcastProposal? NoSyncInfos = NoneOfKind outs isBroadcastSyncInfo? NoMsgs = NoneOfKind outs isOutputMsg? NoErrors = NoneOfKind outs isLogErr? NoMsgs⇒× : NoMsgs → NoProposals × NoVotes × NoSyncInfos proj₁ (NoMsgs⇒× noMsgs) = filter-∪?-[]₁ outs isBroadcastProposal? _ noMsgs proj₁ (proj₂ (NoMsgs⇒× noMsgs)) = filter-∪?-[]₂ outs _ isSendVote? (filter-∪?-[]₂ outs _ _ noMsgs) proj₂ (proj₂ (NoMsgs⇒× noMsgs)) = filter-∪?-[]₁ outs isBroadcastSyncInfo? _ (filter-∪?-[]₂ outs _ _ noMsgs) NoMsgs⇒NoProposals : NoMsgs → NoProposals NoMsgs⇒NoProposals = proj₁ ∘ NoMsgs⇒× NoMsgs⇒NoVotes : NoMsgs → NoVotes NoMsgs⇒NoVotes = proj₁ ∘ proj₂ ∘ NoMsgs⇒× OneVote : VoteMsg → List Author → Set OneVote vm pids = List-filter isSendVote? outs ≡ (SendVote vm pids ∷ []) ++-NoMsgs = λ xs ys → ++-NoneOfKind xs ys isOutputMsg? ++-NoVotes = λ xs ys → ++-NoneOfKind xs ys isSendVote? ++-NoProposals = λ xs ys → ++-NoneOfKind xs ys isBroadcastProposal? ++-NoVotes-OneVote : ∀ xs ys {vm} {pids} → NoVotes xs → OneVote ys vm pids → OneVote (xs ++ ys) vm pids ++-NoVotes-OneVote xs ys nv ov rewrite List-filter-++ isSendVote? xs ys | nv = ov ++-OneVote-NoVotes : ∀ xs {vm pids} ys → OneVote xs vm pids → NoVotes ys → OneVote (xs ++ ys) vm pids ++-OneVote-NoVotes xs ys ov nv rewrite List-filter-++ isSendVote? xs ys | nv | ov = refl module BlockProps (b : Block) where ∈BlockTree_ : BlockTree → Set ∈BlockTree bt = ∃[ eb ] (btGetBlock (b ^∙ bId) bt ≡ just eb) ∈BlockStore_ : BlockStore → Set ∈BlockStore bs = ∈BlockTree (bs ^∙ bsInner) ∈RoundManager_ : RoundManager → Set ∈RoundManager rm = ∈BlockStore (rm ^∙ lBlockStore) module QCProps where data _∈BlockTree_ (qc : QuorumCert) (bt : BlockTree) : Set where inHQC : qc ≡ bt ^∙ btHighestQuorumCert → qc ∈BlockTree bt inHCC : qc ≡ bt ^∙ btHighestCommitCert → qc ∈BlockTree bt _∈RoundManager_ : (qc : QuorumCert) (rm : RoundManager) → Set qc ∈RoundManager rm = qc ∈BlockTree (rm ^∙ lBlockStore ∙ bsInner) ∈Post⇒∈PreOr' : ∀ {A : Set} (_QC∈_ : QuorumCert → A → Set) (Q : QuorumCert → Set) (pre post : A) → Set ∈Post⇒∈PreOr' _QC∈_ Q pre post = ∀ qc → qc QC∈ post → qc QC∈ pre ⊎ Q qc ∈Post⇒∈PreOr'-∙ : ∀ {A B : Set} → (l : Lens A B) → (_QC∈B_ : QuorumCert → B → Set) → (_QC∈A_ : QuorumCert → A → Set) → (∀ {q st} → q QC∈B (st ^∙ l) → q QC∈A st) → (∀ {q st} → q QC∈A st → q QC∈B (st ^∙ l)) → (Q : QuorumCert → Set) → (pre post : A) → ∈Post⇒∈PreOr' _QC∈B_ Q (pre ^∙ l) (post ^∙ l) → ∈Post⇒∈PreOr' _QC∈A_ Q pre post ∈Post⇒∈PreOr'-∙ l _QC∈B_ _QC∈A_ prfBA prfAB Q pre post QCB qc qc∈Apost = ⊎-map₁ prfBA (QCB qc (prfAB qc∈Apost)) ∈Post⇒∈PreOr-∙-BT-RM : _ ∈Post⇒∈PreOr-∙-BT-RM = ∈Post⇒∈PreOr'-∙ lBlockTree _∈BlockTree_ _∈RoundManager_ id id ∈Post⇒∈PreOrBT : (Q : QuorumCert → Set) (pre post : BlockTree) → Set ∈Post⇒∈PreOrBT = ∈Post⇒∈PreOr' _∈BlockTree_ ∈BlockTree-upd-hqc : ∀ {bt1 bt2} → {Q : QuorumCert → Set} → bt1 ≡L bt2 at btHighestCommitCert → Q (bt2 ^∙ btHighestQuorumCert) → ∈Post⇒∈PreOrBT Q bt1 bt2 ∈BlockTree-upd-hqc refl Q _ (inHQC refl) = inj₂ Q ∈BlockTree-upd-hqc refl _ _ (inHCC refl) = inj₁ (inHCC refl) ∈BlockTree-upd-hcc : ∀ {bt1 bt2} → {Q : QuorumCert → Set} → bt1 ≡L bt2 at btHighestQuorumCert → Q (bt2 ^∙ btHighestCommitCert) → ∈Post⇒∈PreOrBT Q bt1 bt2 ∈BlockTree-upd-hcc refl _ _ (inHQC refl) = inj₁ (inHQC refl) ∈BlockTree-upd-hcc refl Q _ (inHCC refl) = inj₂ Q ∈Post⇒∈PreOr : (Q : QuorumCert → Set) (pre post : RoundManager) → Set ∈Post⇒∈PreOr = ∈Post⇒∈PreOr' _∈RoundManager_ ∈Post⇒∈PreOr'-refl : ∀ {A : Set} → (_QC∈_ : QuorumCert → A → Set) (Q : QuorumCert → Set) → ∀ {pre : A} → ∈Post⇒∈PreOr' _QC∈_ Q pre pre ∈Post⇒∈PreOr'-refl _ _ _ = inj₁ ∈Post⇒∈PreOrBT-QCs≡ : ∀ {bt1 bt2} → (Q : QuorumCert → Set) → bt1 ≡L bt2 at btHighestCommitCert → bt1 ≡L bt2 at btHighestQuorumCert → ∈Post⇒∈PreOrBT Q bt1 bt2 ∈Post⇒∈PreOrBT-QCs≡ Q refl refl _ (inHQC refl) = inj₁ (inHQC refl) ∈Post⇒∈PreOrBT-QCs≡ Q refl refl _ (inHCC refl) = inj₁ (inHCC refl) ∈Post⇒∈PreOr'-trans : ∀ {A : Set} → (_QC∈_ : QuorumCert → A → Set) (Q : QuorumCert → Set) → ∀ {pre int post : A} → ∈Post⇒∈PreOr' _QC∈_ Q pre int → ∈Post⇒∈PreOr' _QC∈_ Q int post → ∈Post⇒∈PreOr' _QC∈_ Q pre post ∈Post⇒∈PreOr'-trans _QC∈_ Q pre→int int→post qc qc∈post with int→post qc qc∈post ... | Right y = Right y ... | Left x with pre→int qc x ... | Right y = Right y ... | Left x₁ = Left x₁ ∈Post⇒∈PreOrBT-trans : ∀ (Q : QuorumCert → Set) {pre int post} → ∈Post⇒∈PreOrBT Q pre int → ∈Post⇒∈PreOrBT Q int post → ∈Post⇒∈PreOrBT Q pre post ∈Post⇒∈PreOrBT-trans = ∈Post⇒∈PreOr'-trans _∈BlockTree_ -- TODO-1: Factor out a property about a single output: -- λ out → ∃₂ λ qc nm → qc QC∈NM nm × nm Msg∈Out out OutputQc∈RoundManager : List Output → RoundManager → Set OutputQc∈RoundManager outs rm = All (λ out → ∀ qc nm → qc QC∈NM nm → nm Msg∈Out out → qc ∈RoundManager rm) outs ¬OutputQc : List Output → Set ¬OutputQc outs = All (λ out → ∀ qc nm → qc QC∈NM nm → nm Msg∈Out out → ⊥) outs ++-OutputQc∈RoundManager : ∀ {rm outs₁ outs₂} → OutputQc∈RoundManager outs₁ rm → OutputQc∈RoundManager outs₂ rm → OutputQc∈RoundManager (outs₁ ++ outs₂) rm ++-OutputQc∈RoundManager = All-++ ++-¬OutputQc : ∀ {outs₁ outs₂} → ¬OutputQc outs₁ → ¬OutputQc outs₂ → ¬OutputQc (outs₁ ++ outs₂) ++-¬OutputQc = All-++ NoMsgs⇒¬OutputQc : ∀ outs → OutputProps.NoMsgs outs → ¬OutputQc outs NoMsgs⇒¬OutputQc outs noMsgs = All-map help (noneOfKind⇒All¬ outs _ noMsgs) where help : ∀ {out : Output} → ¬ IsOutputMsg out → ∀ qc nm → qc QC∈NM nm → nm Msg∈Out out → ⊥ help ¬msg qc .(P _) qc∈m inBP = ¬msg (Left tt) help ¬msg qc .(V _) qc∈m inSV = ¬msg (Right (Right tt)) ¬OutputQc⇒OutputQc∈RoundManager : ∀ outs rm → ¬OutputQc outs → OutputQc∈RoundManager outs rm ¬OutputQc⇒OutputQc∈RoundManager outs rm noOutQcs = All-map (λ ¬outqc qc nm qc∈nm nm∈out → ⊥-elim (¬outqc qc nm qc∈nm nm∈out)) noOutQcs NoMsgs⇒OutputQc∈RoundManager : ∀ outs rm → OutputProps.NoMsgs outs → OutputQc∈RoundManager outs rm NoMsgs⇒OutputQc∈RoundManager outs rm noMsgs = ¬OutputQc⇒OutputQc∈RoundManager outs rm (NoMsgs⇒¬OutputQc outs noMsgs) SigForVote∈Rm-SentB4 : Vote → PK → QuorumCert → RoundManager → SentMessages → Set SigForVote∈Rm-SentB4 v pk qc rm pool = qc ∈RoundManager rm → WithVerSig pk v → ∀ {vs : Author × Signature} → let (pid , sig) = vs in vs ∈ qcVotes qc → rebuildVote qc vs ≈Vote v → ¬(∈BootstrapInfo-impl fakeBootstrapInfo sig) → MsgWithSig∈ pk sig pool SigsForVotes∈Rm-SentB4 : SentMessages → RoundManager → Set SigsForVotes∈Rm-SentB4 pool rm = ∀ {qc v pk} → SigForVote∈Rm-SentB4 v pk qc rm pool ++-SigsForVote∈Rm-SentB4 : ∀ {pool rm} → (msgs : SentMessages) → SigsForVotes∈Rm-SentB4 pool rm → SigsForVotes∈Rm-SentB4 (msgs ++ pool) rm ++-SigsForVote∈Rm-SentB4{pool} msgs sfvb4 qc∈rm sig vs∈qc rbld≈v ¬bootstrap = MsgWithSig∈-++ʳ{ms = msgs} (sfvb4 qc∈rm sig vs∈qc rbld≈v ¬bootstrap) module Invariants where ------------ properties for BlockTree validity -- The property that a block tree `bt` has only valid QCs with respect to epoch config `𝓔` AllValidQCs : (𝓔 : EpochConfig) (bt : BlockTree) → Set AllValidQCs 𝓔 bt = (hash : HashValue) → Maybe-maybe (WithEC.MetaIsValidQC 𝓔) ⊤ (lookup hash (bt ^∙ btIdToQuorumCert)) AllValidBlocks : BlockTree → Set AllValidBlocks bt = ∀ {bid eb} → btGetBlock bid bt ≡ just eb → BlockId-correct (eb ^∙ ebBlock) × BlockHash≡ (eb ^∙ ebBlock) bid ------------ types for and definitions of invariants for BlockTree, BlockStore, SafetyData, SafetyRules record ECinfo : Set where constructor mkECinfo field ecVV : ValidatorVerifier ecEP : Epoch open ECinfo WithECinfo : Set → Set WithECinfo A = A × ECinfo BlockTree-EC = WithECinfo BlockTree BlockStore-EC = WithECinfo BlockStore module _ (btEC : BlockTree-EC) where private bt = proj₁ btEC eci = proj₂ btEC vv = ecVV eci ep = ecEP eci record BlockTreeInv : Set where constructor mkBlockTreeInv field allValidQCs : (vvC : ValidatorVerifier-correct $ vv) → AllValidQCs (α-EC-VV (vv , vvC) ep) bt allValidBlocks : AllValidBlocks bt open BlockTreeInv module _ (bsEC : BlockStore-EC) where private bs = proj₁ bsEC eci = proj₂ bsEC record BlockStoreInv : Set where constructor mkBlockStoreInv field blockTreeValid : BlockTreeInv (bs ^∙ bsInner , eci) open BlockStoreInv module _ (sd : SafetyData) where -- SafetyRules invariants record SafetyDataInv : Set where constructor mkSafetyDataInv field lvEpoch≡ : Meta.getLastVoteEpoch sd ≡ sd ^∙ sdEpoch lvRound≤ : Meta.getLastVoteRound sd ≤ sd ^∙ sdLastVotedRound open SafetyDataInv subst-SafetyDataInv : ∀ {sd1 sd2} → sd1 ^∙ sdLastVote ≡ sd2 ^∙ sdLastVote → sd1 ^∙ sdEpoch ≡ sd2 ^∙ sdEpoch → sd1 ^∙ sdLastVotedRound ≡ sd2 ^∙ sdLastVotedRound → SafetyDataInv sd1 → SafetyDataInv sd2 subst-SafetyDataInv refl refl refl (mkSafetyDataInv lvEpoch≡₁ lvRound≤₁) = mkSafetyDataInv lvEpoch≡₁ lvRound≤₁ module _ (sr : SafetyRules) where -- SafetyRules invariants record SafetyRulesInv : Set where constructor mkSafetyRulesInv field sdInv : SafetyDataInv (sr ^∙ srPersistentStorage ∙ pssSafetyData) open SafetyRulesInv ------------ types for and definition of RoundManagerInv EpochsMatch : RoundManager → Set EpochsMatch rm = rm ^∙ rmEpochState ∙ esEpoch ≡ rm ^∙ pssSafetyData-rm ∙ sdEpoch rm→ECinfo : RoundManager → ECinfo rm→ECinfo rm = mkECinfo (rm ^∙ rmEpochState ∙ esVerifier) (rm ^∙ rmEpoch) rm→BlockTree-EC : RoundManager → BlockTree-EC rm→BlockTree-EC rm = (rm ^∙ lBlockStore ∙ bsInner , rm→ECinfo rm) rm→BlockStore-EC : RoundManager → BlockStore-EC rm→BlockStore-EC rm = (rm ^∙ lBlockStore , rm→ECinfo rm) -- NOTE: This will be proved by induction on reachable states using the -- property that peer handlers preserve invariants. That is to say, many of -- these cannot be proven as a post-condition of the peer handler: one can -- only prove of the handler that if the invariant holds for the prestate, -- then it holds for the poststate. record RoundManagerInv (rm : RoundManager) : Set where constructor mkRoundManagerInv field rmCorrect : ValidatorVerifier-correct (rm ^∙ rmValidatorVerifer) rmEpochsMatch : EpochsMatch rm rmBlockStoreInv : BlockStoreInv (rm→BlockStore-EC rm) rmSafetyRulesInv : SafetyRulesInv (rm ^∙ lSafetyRules) open RoundManagerInv -- This is just the beginning of the invariant for EpochManager, collecting properties we already -- expect to be required even though the top-level peer state is RoundManager for now (in future, -- when we prove properties related to epoch change, the peers state will become EpochManager). record EpochManagerInv (em : EpochManager) : Set where constructor mkEpochManagerInv field -- SafetyRule properties emiSRI : ∀ {sr} → em ^∙ emSafetyRulesManager ∙ srmInternalSafetyRules ≡ SRWLocal sr → SafetyRulesInv sr × sr ^∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ nothing open EpochManagerInv hash≡⇒≈Block : ∀ {b1 b2 : Block} → BlockId-correct b1 → BlockId-correct b2 → BlockHash≡ b1 (b2 ^∙ bId) → b1 ≈Block b2 hash≡⇒≈Block {b1} {b2} refl refl hashb1≡idb2 with hashBD-inj hashb1≡idb2 ...| bdInj = sameBlockData⇒≈ {b1} {b2} hashb1≡idb2 bdInj module Reqs (b : Block) (bt : BlockTree) where -- TODO: State and use assumptions about hash collisions. The following is one example that will -- likely need to be refined. NoHC1 = ∀ {eb} → btGetBlock (b ^∙ bId) bt ≡ just eb → BlockId-correct b → (eb ^∙ ebBlock) ≈Block b -- TODO: probably don't need this generality, consider moving into Handle.Properties (only place -- it is used so far), then we could streamline as rmi is required only to avoid cyclic lookups module _ {st} (reach : ReachableSystemState st) {pm : ProposalMsg} {sndr : NodeId} (nm∈pool : (sndr , P pm) ∈ msgPool st) (pid : NodeId) (ini : initialised st pid ≡ initd) where open PerReachableState reach private rm = peerStates st pid bt = rm ^∙ lBlockTree b = pm ^∙ pmProposal nohc : RoundManagerInv rm → rm ^∙ lBlockTree ≡ bt → BlockId-correct b → Reqs.NoHC1 b bt nohc rmi refl refl {eb} jeb refl with allValidBlocks (blockTreeValid (rmBlockStoreInv rmi)) jeb ...| bidCorr , bid with (blockData-bsl (b ^∙ bBlockData)) ≟-BSL (blockData-bsl (eb ^∙ ebBlock ∙ bBlockData)) ...| yes bsls≡ = hash≡⇒≈Block {eb ^∙ ebBlock} {b} bidCorr refl bid ...| no neq rewrite sym bid = ⊥-elim (meta-no-collision-in-sys (msgRmHC (inP nm∈pool (inPM inB)) ini (inRM (inBS jeb inB)) (sym bid) neq)) -- Valid blocks have IDs computed by the hash of their BlockData -- These are passed as module parameters through the proofs ValidBlock = Σ Block BlockId-correct vbBlock : ValidBlock → Block vbBlock = proj₁ vbValid : (vb : ValidBlock) → BlockId-correct (vbBlock vb) vbValid = proj₂ ------------ Preserves and related definitions and utilities Preserves : ∀ {ℓ} {A : Set} → (P : A → Set ℓ) (pre post : A) → Set ℓ Preserves Pred pre post = Pred pre → Pred post PreservesL : ∀ {ℓ} {A B : Set} → (P : A → Set ℓ) (l : Lens A B) → (b₁ b₂ : B) → Set ℓ PreservesL Pred l b₁ b₂ = ∀ a → Preserves Pred (a & l ∙~ b₁) (a & l ∙~ b₂) reflPreserves : ∀ {ℓ} {A : Set} (P : A → Set ℓ) → Reflexive (Preserves P) reflPreserves Pred = id reflPreservesRoundManagerInv : Reflexive (Preserves RoundManagerInv) reflPreservesRoundManagerInv = reflPreserves RoundManagerInv transPreserves : ∀ {ℓ} {A : Set} (P : A → Set ℓ) → Transitive (Preserves P) transPreserves Pred p₁ p₂ = p₂ ∘ p₁ transPreservesL : ∀ {ℓ} {A B : Set} → (P : A → Set ℓ) (l : Lens A B) → {b₁ b₂ b₃ : B} → PreservesL P l b₁ b₂ → PreservesL P l b₂ b₃ → PreservesL P l b₁ b₃ transPreservesL Pred l p₁ p₂ a = transPreserves Pred (p₁ a) (p₂ a) transPreservesRoundManagerInv : Transitive (Preserves RoundManagerInv) transPreservesRoundManagerInv = transPreserves RoundManagerInv BSInv⇒BTInv-pres : ∀ {eci} {pre post : BlockStore} → Preserves BlockStoreInv (pre , eci) (post , eci) → Preserves BlockTreeInv (pre ^∙ bsInner , eci) (post ^∙ bsInner , eci) BSInv⇒BTInv-pres presBS btiPre = BlockStoreInv.blockTreeValid (presBS $ mkBlockStoreInv btiPre) mkPreservesSafetyRulesInv : ∀ {pre post} → Preserves SafetyDataInv (pre ^∙ srPersistentStorage ∙ pssSafetyData) (post ^∙ srPersistentStorage ∙ pssSafetyData) → Preserves SafetyRulesInv pre post mkPreservesSafetyRulesInv lvP (mkSafetyRulesInv lv) = mkSafetyRulesInv (lvP lv) mkPreservesRoundManagerInv : ∀ {pre post} → Preserves ValidatorVerifier-correct (pre ^∙ rmValidatorVerifer) (post ^∙ rmValidatorVerifer) → Preserves EpochsMatch pre post → Preserves BlockStoreInv (rm→BlockStore-EC pre) (rm→BlockStore-EC post) → Preserves SafetyRulesInv (pre ^∙ rmSafetyRules) (post ^∙ rmSafetyRules) → Preserves RoundManagerInv pre post mkPreservesRoundManagerInv rmP emP bsP srP (mkRoundManagerInv rmCorrect epochsMatch bsInv srInv) = mkRoundManagerInv (rmP rmCorrect) (emP epochsMatch) (bsP bsInv) (srP srInv) module InitProofDefs where open Invariants -- RoundManager properties _IsNormalRoundManagerOf_ : RoundManager → EpochManager → Set _IsNormalRoundManagerOf_ rm em = em ^∙ emProcessor ≡ just (RoundProcessorNormal rm) IsNormalRoundManagerOf-inj : ∀ {em} {rm1} {rm2} → rm1 IsNormalRoundManagerOf em → rm2 IsNormalRoundManagerOf em → rm1 ≡ rm2 IsNormalRoundManagerOf-inj refl refl = refl InitSdLV≡ : RoundManager → Maybe Vote → Set InitSdLV≡ rm mv = rm ^∙ rmSafetyRules ∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ mv InitSigs∈bs : RoundManager → Set InitSigs∈bs rm = ∀ {bsi vs qc} → vs ∈ qcVotes qc → qc QCProps.∈RoundManager rm → ∈BootstrapInfo-impl bsi (proj₂ vs) -- Message properties -- During epoch initialisation, no messages are sent -- EXCEPT the leader of Round 1 SENDS a ProposalMsg during initialization. -- Rust/Haskell impls do not include signatures in the genesis QC's LIWS. -- The initial proposal for (Epoch N) (Round 1) is built on a QC with empty signatures. InitIsInitPM' : NetworkMsg → Set InitIsInitPM' m = ∃[ pm ] ( m ≡ P pm × ∀ {vs qc} → vs ∈ qcVotes qc → qc QC∈NM m → ⊥) InitIsInitPM : List (Action NetworkMsg) → Set InitIsInitPM acts = ∀ {m} → send m ∈ acts → InitIsInitPM' m record InitContractOk (mv : Maybe Vote) (rm : RoundManager) (outs : List Output) : Set where constructor mkInitContractOk field rmInv : RoundManagerInv rm sdLV≡ : InitSdLV≡ rm mv sigs∈bs : InitSigs∈bs rm isInitPM : InitIsInitPM (outputsToActions {State = rm} outs) open InitContractOk EMInitCond : Maybe Vote → EpochManager × List Output → Set EMInitCond mv (em , outs) = ∃[ rm ] ( rm IsNormalRoundManagerOf em × InitContractOk mv rm outs ) InitContract : Maybe Vote → EitherD-Post ErrLog (EpochManager × List Output) InitContract _ (Left x) = ⊤ InitContract mv (Right em×outs) = EMInitCond mv em×outs module RoundManagerTransProps where -- Relations between the pre/poststate which may or may not hold, depending on -- the particular peer handler invoked -- - The epoch is unchanged NoEpochChange : (pre post : RoundManager) → Set NoEpochChange pre post = pre ≡L post at rmEpoch reflNoEpochChange : Reflexive NoEpochChange reflNoEpochChange = refl transNoEpochChange : Transitive NoEpochChange transNoEpochChange = trans NoSafetyDataChange : (pre post : RoundManager) → Set NoSafetyDataChange pre post = pre ≡L post at pssSafetyData-rm reflNoSafetyDataChange : Reflexive NoSafetyDataChange reflNoSafetyDataChange = refl transNoSafetyDataChange : Transitive NoSafetyDataChange transNoSafetyDataChange = trans -- - state changes from generating or not generating a vote LastVoteIs : RoundManager → Vote → Set LastVoteIs rm v = just v ≡ rm ^∙ pssSafetyData-rm ∙ sdLastVote module _ (pre post : RoundManager) (vote : Vote) where record VoteOldGenerated : Set where constructor mkVoteOldGenerated field -- NOTE: The implementation maintains an invariant that the round -- associated with `sdLastVote` (if the vote exists) is less than or -- equal to the field `sdLastVotedRound`. lvr≡ : pre ≡L post at pssSafetyData-rm ∙ sdLastVotedRound lv≡ : pre ≡L post at pssSafetyData-rm ∙ sdLastVote record VoteNewGenerated : Set where constructor mkVoteNewGenerated field lvr< : pre [ _<_ ]L post at pssSafetyData-rm ∙ sdLastVotedRound lvr≡ : vote ^∙ vRound ≡ post ^∙ pssSafetyData-rm ∙ sdLastVotedRound -- NOTE: This is saying that /state changes/ associated to generating a vote -- have occurred, not that the generated vote has been sent. record VoteGenerated : Set where constructor mkVoteGenerated field lv≡v : LastVoteIs post vote voteSrc : VoteOldGenerated ⊎ VoteNewGenerated isVoteNewGenerated : VoteGenerated → Bool isVoteNewGenerated = isRight ∘ VoteGenerated.voteSrc reflVoteOldGenerated : ∀ {v} → Reflexive (λ pre post → VoteOldGenerated pre post v) reflVoteOldGenerated = mkVoteOldGenerated refl refl VoteGeneratedNotSaved : (pre post : RoundManager) → Set VoteGeneratedNotSaved pre post = ∃[ v ] VoteGenerated pre post v module _ (pre post : RoundManager) where -- In -- `LibraBFT.Impl.Consensus.SafetyRules.SafetyRules.agda::contructAndSignVoteM`, -- it is possible for us to update the field `pssSafetyData-rm ∙ sdLastVotedRound` -- without actually returning a vote. Therefore, the most we can say after -- returing from this function is that this field in the poststate is greater -- than or equal to the value it started at in the prestate. -- -- However, it is also possible to return a vote *without* updating the last -- voted round. Many functions in `LibraBFT.Impl.Consensus.RoundManager` neither -- return a vote nor update the last voted round, and the lemma -- `pseudotransVoteSent` in those cases -- but is unprovable if we do not -- distinguish the cases where the last voted round cannot be increased. -- Therefore, it is convenient to track in the type of `NoVoteSent`, with the -- parameter `lvr≡?`, which case we are dealing with record VoteNotGenerated (lvr≡? : Bool) : Set where constructor mkVoteNotGenerated field lv≡ : pre ≡L post at pssSafetyData-rm ∙ sdLastVote lvr≤ : pre [ if lvr≡? then _≡_ else _<_ ]L post at pssSafetyData-rm ∙ sdLastVotedRound reflVoteNotGenerated : Reflexive (λ pre post → VoteNotGenerated pre post true) reflVoteNotGenerated = mkVoteNotGenerated refl refl transVoteNotGenerated : ∀ {s₁ s₂ s₃ lvr≡?₁ lvr≡?₂} → VoteNotGenerated s₁ s₂ lvr≡?₁ → VoteNotGenerated s₂ s₃ lvr≡?₂ → VoteNotGenerated s₁ s₃ (lvr≡?₁ ∧ lvr≡?₂) transVoteNotGenerated {lvr≡?₁ = false} {false} (mkVoteNotGenerated lv≡ lvr≤) (mkVoteNotGenerated lv≡₁ lvr≤₁) = mkVoteNotGenerated (trans lv≡ lv≡₁) (<-trans lvr≤ lvr≤₁) transVoteNotGenerated {lvr≡?₁ = false} {true} (mkVoteNotGenerated lv≡ lvr≤) (mkVoteNotGenerated lv≡₁ lvr≤₁) = mkVoteNotGenerated (trans lv≡ lv≡₁) (≤-trans lvr≤ (≡⇒≤ lvr≤₁)) transVoteNotGenerated {lvr≡?₁ = true} {false} (mkVoteNotGenerated lv≡ lvr≤) (mkVoteNotGenerated lv≡₁ lvr≤₁) = mkVoteNotGenerated (trans lv≡ lv≡₁) (≤-trans (s≤s (≡⇒≤ lvr≤)) lvr≤₁) transVoteNotGenerated {lvr≡?₁ = true} {true} (mkVoteNotGenerated lv≡ lvr≤) (mkVoteNotGenerated lv≡₁ lvr≤₁) = mkVoteNotGenerated (trans lv≡ lv≡₁) (trans lvr≤ lvr≤₁) glue-VoteGenerated-VoteNotGenerated : ∀ {s₁ s₂ s₃ v} → VoteGenerated s₁ s₂ v → VoteNotGenerated s₂ s₃ true → VoteGenerated s₁ s₃ v glue-VoteGenerated-VoteNotGenerated (mkVoteGenerated lv≡v (inj₁ (mkVoteOldGenerated lvr≡₁ lv≡₁))) (mkVoteNotGenerated lv≡ lvr≤) = mkVoteGenerated (trans lv≡v lv≡) (inj₁ (mkVoteOldGenerated (trans lvr≡₁ lvr≤) (trans lv≡₁ lv≡))) glue-VoteGenerated-VoteNotGenerated (mkVoteGenerated lv≡v (inj₂ (mkVoteNewGenerated lvr< lvr≡))) (mkVoteNotGenerated lv≡ lvr≤) = mkVoteGenerated ((trans lv≡v lv≡)) (inj₂ (mkVoteNewGenerated (≤-trans lvr< (≡⇒≤ lvr≤)) (trans lvr≡ lvr≤))) glue-VoteNotGenerated-VoteGenerated : ∀ {s₁ s₂ s₃ v} → VoteNotGenerated s₁ s₂ true → VoteGenerated s₂ s₃ v → VoteGenerated s₁ s₃ v glue-VoteNotGenerated-VoteGenerated (mkVoteNotGenerated lv≡ lvr≤) (mkVoteGenerated lv≡v (inj₁ (mkVoteOldGenerated lvr≡₁ lv≡₁))) = mkVoteGenerated lv≡v (inj₁ (mkVoteOldGenerated (trans lvr≤ lvr≡₁) (trans lv≡ lv≡₁))) glue-VoteNotGenerated-VoteGenerated (mkVoteNotGenerated lv≡ lvr≤) (mkVoteGenerated lv≡v (inj₂ (mkVoteNewGenerated lvr<₁ lvr≡₁))) = mkVoteGenerated lv≡v (inj₂ (mkVoteNewGenerated (≤-trans (s≤s (≡⇒≤ lvr≤)) lvr<₁) lvr≡₁)) glue-VoteNotGenerated-VoteGeneratedNotSaved : ∀ {s₁ s₂ s₃} → VoteNotGenerated s₁ s₂ true → VoteGeneratedNotSaved s₂ s₃ → VoteGeneratedNotSaved s₁ s₃ glue-VoteNotGenerated-VoteGeneratedNotSaved vng (v , vg) = v , glue-VoteNotGenerated-VoteGenerated vng vg -- Properties for voting module Voting where open Invariants VoteEpochIs : (vote : Vote) (e : Epoch) → Set VoteEpochIs vote e = vote ^∙ vEpoch ≡ e VoteRoundIs : (vote : Vote) (r : Round) → Set VoteRoundIs vote r = vote ^∙ vRound ≡ r record VoteMadeFromBlock (vote : Vote) (block : Block) : Set where constructor mkVoteMadeFromBlock field epoch≡ : vote ^∙ vEpoch ≡ block ^∙ bEpoch round≡ : vote ^∙ vRound ≡ block ^∙ bRound proposedId≡ : vote ^∙ vProposedId ≡ block ^∙ bId VoteMadeFromBlock⇒VoteEpochRoundIs : ∀ {v b} → VoteMadeFromBlock v b → VoteEpochIs v (b ^∙ bEpoch) × VoteRoundIs v (b ^∙ bRound) VoteMadeFromBlock⇒VoteEpochRoundIs (mkVoteMadeFromBlock epoch≡ round≡ proposedID) = epoch≡ , round≡ VoteTriggeredByBlock : (vote : Vote) (block : Block) (new? : Bool) → Set VoteTriggeredByBlock vote block true = VoteMadeFromBlock vote block VoteTriggeredByBlock vote block false = VoteRoundIs vote (block ^∙ bRound) record VoteGeneratedCorrect (pre post : RoundManager) (vote : Vote) (block : Block) : Set where constructor mkVoteGeneratedCorrect field state : RoundManagerTransProps.VoteGenerated pre post vote voteNew? = RoundManagerTransProps.isVoteNewGenerated pre post vote state field blockTriggered : VoteTriggeredByBlock vote block voteNew? substVoteGeneratedCorrect : ∀ {pre post vote} (block₁ block₂ : Block) → block₁ ≈Block block₂ → VoteGeneratedCorrect pre post vote block₁ → VoteGeneratedCorrect pre post vote block₂ substVoteGeneratedCorrect block₁ block₂ bd≡ (mkVoteGeneratedCorrect state blockTriggered) with state ...| RoundManagerTransProps.mkVoteGenerated lv≡v voteSrc with voteSrc ...| Left vog rewrite bd≡ = mkVoteGeneratedCorrect (RoundManagerTransProps.mkVoteGenerated lv≡v (Left vog)) blockTriggered ...| Right vng with blockTriggered ...| mkVoteMadeFromBlock epoch≡ round≡ proposedID rewrite bd≡ = mkVoteGeneratedCorrect (RoundManagerTransProps.mkVoteGenerated lv≡v (Right vng)) (mkVoteMadeFromBlock epoch≡ round≡ proposedID) record VoteGeneratedUnsavedCorrect (pre post : RoundManager) (block : Block) : Set where constructor mkVoteGeneratedUnsavedCorrect field vote : Vote voteGenCorrect : VoteGeneratedCorrect pre post vote block glue-VoteGeneratedCorrect-VoteNotGenerated : ∀ {s₁ s₂ s₃ vote block} → VoteGeneratedCorrect s₁ s₂ vote block → RoundManagerTransProps.VoteNotGenerated s₂ s₃ true → VoteGeneratedCorrect s₁ s₃ vote block glue-VoteGeneratedCorrect-VoteNotGenerated vgc@(mkVoteGeneratedCorrect vg@(RoundManagerTransProps.mkVoteGenerated lv≡v (inj₁ oldVG)) blockTriggered) vng = mkVoteGeneratedCorrect (RoundManagerTransProps.glue-VoteGenerated-VoteNotGenerated vg vng) blockTriggered glue-VoteGeneratedCorrect-VoteNotGenerated vgc@(mkVoteGeneratedCorrect vg@(RoundManagerTransProps.mkVoteGenerated lv≡v (inj₂ newVG)) blockTriggered) vng = mkVoteGeneratedCorrect (RoundManagerTransProps.glue-VoteGenerated-VoteNotGenerated vg vng) blockTriggered glue-VoteNotGenerated-VoteGeneratedCorrect : ∀ {s₁ s₂ s₃ vote block} → RoundManagerTransProps.VoteNotGenerated s₁ s₂ true → VoteGeneratedCorrect s₂ s₃ vote block → VoteGeneratedCorrect s₁ s₃ vote block glue-VoteNotGenerated-VoteGeneratedCorrect vng (mkVoteGeneratedCorrect vg@(RoundManagerTransProps.mkVoteGenerated lv≡v (inj₁ oldVG)) blockTriggered) = mkVoteGeneratedCorrect (RoundManagerTransProps.glue-VoteNotGenerated-VoteGenerated vng vg) blockTriggered glue-VoteNotGenerated-VoteGeneratedCorrect vng (mkVoteGeneratedCorrect vg@(RoundManagerTransProps.mkVoteGenerated lv≡v (inj₂ newVG)) blockTriggered) = mkVoteGeneratedCorrect (RoundManagerTransProps.glue-VoteNotGenerated-VoteGenerated vng vg) blockTriggered glue-VoteNotGenerated-VoteGeneratedUnsavedCorrect : ∀ {s₁ s₂ s₃ block} → RoundManagerTransProps.VoteNotGenerated s₁ s₂ true → VoteGeneratedUnsavedCorrect s₂ s₃ block → VoteGeneratedUnsavedCorrect s₁ s₃ block glue-VoteNotGenerated-VoteGeneratedUnsavedCorrect vng (mkVoteGeneratedUnsavedCorrect vote voteGenCorrect) = mkVoteGeneratedUnsavedCorrect vote (glue-VoteNotGenerated-VoteGeneratedCorrect vng voteGenCorrect) -- The handler correctly voted (including state updates) on `block`, assuming -- the safety data epoch matches the block epoch. record VoteSentCorrect (pre post : RoundManager) (outs : List Output) (block : Block) : Set where constructor mkVoteSentCorrect field vm : VoteMsg pid : Author voteMsgOuts : OutputProps.OneVote outs vm (pid ∷ []) vgCorrect : VoteGeneratedCorrect pre post (vm ^∙ vmVote) block open VoteGeneratedCorrect vgCorrect -- The handler correctly did not vote on `block` record VoteUnsentCorrect (pre post : RoundManager) (outs : List Output) (block : Block) (lvr≡? : Bool) : Set where constructor mkVoteUnsentCorrect field noVoteMsgOuts : OutputProps.NoVotes outs nvg⊎vgusc : RoundManagerTransProps.VoteNotGenerated pre post lvr≡? ⊎ VoteGeneratedUnsavedCorrect pre post block glue-VoteNotGenerated-VoteUnsentCorrect : ∀ {s₁ s₂ s₃ outs₁ outs₂ block lvr≡?} → RoundManagerTransProps.VoteNotGenerated s₁ s₂ true → OutputProps.NoVotes outs₁ → VoteUnsentCorrect s₂ s₃ outs₂ block lvr≡? → VoteUnsentCorrect s₁ s₃ (outs₁ ++ outs₂) block lvr≡? glue-VoteNotGenerated-VoteUnsentCorrect{outs₁ = outs₁} vng₁ nvo (mkVoteUnsentCorrect noVoteMsgOuts (inj₁ vng₂)) = mkVoteUnsentCorrect (OutputProps.++-NoVotes outs₁ _ nvo noVoteMsgOuts) (inj₁ (RoundManagerTransProps.transVoteNotGenerated vng₁ vng₂)) glue-VoteNotGenerated-VoteUnsentCorrect{outs₁ = outs₁} vng₁ nvo (mkVoteUnsentCorrect noVoteMsgOuts (inj₂ vgus)) = mkVoteUnsentCorrect ((OutputProps.++-NoVotes outs₁ _ nvo noVoteMsgOuts)) (inj₂ (glue-VoteNotGenerated-VoteGeneratedUnsavedCorrect vng₁ vgus)) -- The handler correctly attempted to vote on `block`, assuming the safety -- data epoch matches the block epoch. VoteAttemptCorrect : (pre post : RoundManager) (outs : List Output) (block : Block) → Set VoteAttemptCorrect pre post outs block = (∃[ lvr≡? ] VoteUnsentCorrect pre post outs block lvr≡?) ⊎ VoteSentCorrect pre post outs block -- The voting process ended before `pssSafetyData-rm` could be updated voteAttemptBailed : ∀ {rm block} outs → OutputProps.NoVotes outs → VoteAttemptCorrect rm rm outs block voteAttemptBailed outs noVotesOuts = inj₁ (true , mkVoteUnsentCorrect noVotesOuts (inj₁ RoundManagerTransProps.reflVoteNotGenerated)) glue-VoteNotGenerated-VoteAttemptCorrect : ∀ {s₁ s₂ s₃ outs₁ outs₂ block} → RoundManagerTransProps.VoteNotGenerated s₁ s₂ true → OutputProps.NoVotes outs₁ → VoteAttemptCorrect s₂ s₃ outs₂ block → VoteAttemptCorrect s₁ s₃ (outs₁ ++ outs₂) block glue-VoteNotGenerated-VoteAttemptCorrect{outs₁ = outs₁} vng nvo (inj₁ (lvr≡? , vusCorrect)) = inj₁ (lvr≡? , glue-VoteNotGenerated-VoteUnsentCorrect{outs₁ = outs₁} vng nvo vusCorrect) glue-VoteNotGenerated-VoteAttemptCorrect{outs₁ = outs₁} vng nvo (inj₂ (mkVoteSentCorrect vm pid voteMsgOuts vgCorrect)) = inj₂ (mkVoteSentCorrect vm pid (OutputProps.++-NoVotes-OneVote outs₁ _ nvo voteMsgOuts) (glue-VoteNotGenerated-VoteGeneratedCorrect vng vgCorrect)) VoteAttemptEpochReq : ∀ {pre post outs block} → VoteAttemptCorrect pre post outs block → Set VoteAttemptEpochReq (inj₁ (_ , mkVoteUnsentCorrect _ (inj₁ _))) = ⊤ VoteAttemptEpochReq{pre}{block = block} (inj₁ (_ , mkVoteUnsentCorrect _ (inj₂ _))) = pre ^∙ pssSafetyData-rm ∙ sdEpoch ≡ (block ^∙ bEpoch) VoteAttemptEpochReq{pre}{block = block} (inj₂ _) = pre ^∙ pssSafetyData-rm ∙ sdEpoch ≡ (block ^∙ bEpoch) voteAttemptEpochReq! : ∀ {pre post outs block} → (vac : VoteAttemptCorrect pre post outs block) → pre ^∙ pssSafetyData-rm ∙ sdEpoch ≡ block ^∙ bEpoch → VoteAttemptEpochReq vac voteAttemptEpochReq! (inj₁ (_ , mkVoteUnsentCorrect _ (inj₁ _))) eq = tt voteAttemptEpochReq! (inj₁ (_ , mkVoteUnsentCorrect _ (inj₂ _))) eq = eq voteAttemptEpochReq! (inj₂ _) eq = eq record VoteAttemptCorrectWithEpochReq (pre post : RoundManager) (outs : List Output) (block : Block) : Set where constructor mkVoteAttemptCorrectWithEpochReq field voteAttempt : VoteAttemptCorrect pre post outs block sdEpoch≡? : VoteAttemptEpochReq voteAttempt voteAttemptCorrectAndSent⇒voteSentCorrect : ∀ {pre post outs block vm} → send (V vm) ∈ outputsToActions{pre} outs → VoteAttemptCorrectWithEpochReq pre post outs block → VoteSentCorrect pre post outs block voteAttemptCorrectAndSent⇒voteSentCorrect{pre}{outs = outs} vm∈outs (mkVoteAttemptCorrectWithEpochReq (Left (_ , mkVoteUnsentCorrect noVoteMsgOuts _)) _) = ⊥-elim (sendVote∉actions{outs}{st = pre} (sym noVoteMsgOuts) vm∈outs) voteAttemptCorrectAndSent⇒voteSentCorrect{pre}{outs = outs}{vm = vm} vm∈outs (mkVoteAttemptCorrectWithEpochReq (Right vsc) _) = vsc
{ "alphanum_fraction": 0.6674340502, "avg_line_length": 45.4145141451, "ext": "agda", "hexsha": "053ac88813632e7fdce3b665cb97eaffc806b9a4", "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/LibraBFT/Impl/Properties/Util.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/LibraBFT/Impl/Properties/Util.agda", "max_line_length": 157, "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/LibraBFT/Impl/Properties/Util.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11823, "size": 36922 }
module UselessPrivateImport2 where private open import Common.Issue481ParametrizedModule Set
{ "alphanum_fraction": 0.875, "avg_line_length": 19.2, "ext": "agda", "hexsha": "053ea4b411e0574448138713c4b7995d55f2538b", "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/UselessPrivateImport2.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/UselessPrivateImport2.agda", "max_line_length": 51, "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/UselessPrivateImport2.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": 23, "size": 96 }
module ATPRepeteadConjecture where -- This error is detected by TypeChecking.Monad.Signature. postulate D : Set _≡_ : D → D → Set p : ∀ d e → d ≡ e -- The conjecture foo is rejected because it is repetead. postulate foo : ∀ d e → d ≡ e {-# ATP prove foo #-} {-# ATP prove foo p #-}
{ "alphanum_fraction": 0.6372881356, "avg_line_length": 21.0714285714, "ext": "agda", "hexsha": "add326a2fcf64cfb76d89fccc7b06b28d25b2577", "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/fail/ATPRepeteadConjecture.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/fail/ATPRepeteadConjecture.agda", "max_line_length": 58, "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/fail/ATPRepeteadConjecture.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": 93, "size": 295 }
{-# OPTIONS --allow-exec #-} open import Agda.Builtin.FromNat open import Data.Bool.Base using (T; Bool; if_then_else_) open import Data.String using (String; _++_; lines) open import Data.Nat.Base using (ℕ) open import Data.Fin using (Fin) import Data.Fin.Literals as Fin import Data.Nat.Literals as Nat open import Data.Vec.Base using (Vec) open import Data.Float.Base using (Float; _≤ᵇ_) open import Data.List.Base using (List; []; _∷_) open import Data.Unit.Base using (⊤; tt) open import Relation.Nullary using (does) open import Relation.Binary.Core using (Rel) open import Reflection.Argument open import Reflection.Term open import Reflection.External open import Reflection.TypeChecking.Monad open import Reflection.TypeChecking.Monad.Syntax open import Reflection.Show using (showTerm) open import Vehicle.Utils module Vehicle where ------------------------------------------------------------------------ -- Metadata ------------------------------------------------------------------------ VEHICLE_COMMAND : String VEHICLE_COMMAND = "vehicle" ------------------------------------------------------------------------ -- Execution ------------------------------------------------------------------------ record EvaluateArgs : Set where field projectFile : String networkUUID : String evaluateCmd : EvaluateArgs → CmdSpec evaluateCmd args = cmdSpec VEHICLE_COMMAND ( "evaluate" ∷ ("--databaseFile=" ++ projectFile) ∷ networkUUID ∷ []) "" where open EvaluateArgs args -- TODO postulate evaluate : EvaluateArgs → ∀ {a b} {A : Set a} {B : Set b} → A → B ------------------------------------------------------------------------ -- Checking ------------------------------------------------------------------------ record CheckArgs : Set where field projectFile : String propertyUUID : String checkCmd : CheckArgs → CmdSpec checkCmd checkArgs = cmdSpec VEHICLE_COMMAND ( "check" ∷ ("--databaseFile=" ++ projectFile) ∷ ("--property=" ++ propertyUUID) ∷ []) "" where open CheckArgs checkArgs checkSuccessful : String → Bool checkSuccessful output = "Valid" ⊆ output postulate valid : ∀ {a} {A : Set a} → A `valid : Term `valid = def (quote valid) (hArg unknown ∷ []) checkPropertyMacro : CheckArgs → Term → TC ⊤ checkPropertyMacro args hole = do goal ← inferType hole -- (showTerm goal) output ← runCmdTC (checkCmd args) if checkSuccessful output then unify hole `valid else typeError (strErr ("Error: " ++ output) ∷ []) macro checkProperty : CheckArgs → Term → TC ⊤ checkProperty = checkPropertyMacro ------------------------------------------------------------------------ -- Other ------------------------------------------------------------------------ instance finNumber : ∀ {n} -> Number (Fin n) finNumber {n} = Fin.number n natNumber : Number ℕ natNumber = Nat.number ze : Fin 5 ze = 0
{ "alphanum_fraction": 0.5611338798, "avg_line_length": 26.8623853211, "ext": "agda", "hexsha": "361fb0adc2fcc7b38115ad458211bfa6f1dd240b", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-11-16T14:30:47.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-15T15:22:31.000Z", "max_forks_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "wenkokke/vehicle", "max_forks_repo_path": "src/agda/Vehicle.agda", "max_issues_count": 53, "max_issues_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_issues_repo_issues_event_max_datetime": "2021-12-15T22:42:01.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-16T07:26:42.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "wenkokke/vehicle", "max_issues_repo_path": "src/agda/Vehicle.agda", "max_line_length": 72, "max_stars_count": 11, "max_stars_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "wenkokke/vehicle", "max_stars_repo_path": "src/agda/Vehicle.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T01:35:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-24T05:55:15.000Z", "num_tokens": 648, "size": 2928 }
{-# OPTIONS --without-K #-} module Types where import Level open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary -- data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ U∼ : U → Set₁ U∼ u = Rel ⟦ u ⟧ (Level.zero) record Typ : Set₁ where field carr : U auto : U∼ carr BOOL : U BOOL = PLUS ONE ONE FALSE TRUE : ⟦ BOOL ⟧ FALSE = inj₁ tt TRUE = inj₂ tt data ONE∼ : U∼ ONE where id : ONE∼ tt tt data BOOL∼ : U∼ BOOL where idff : BOOL∼ FALSE FALSE idft : BOOL∼ FALSE TRUE idtf : BOOL∼ TRUE FALSE idtt : BOOL∼ TRUE TRUE -- {-- Then < Bool , ~* > is essentially < Unit , ~= > Now we need to define what it means to say < U1, ~1> + < U2, ~2 > etc. and then what it means for two types to be equivalent etc. etc. etc. --}
{ "alphanum_fraction": 0.5726055613, "avg_line_length": 16.4576271186, "ext": "agda", "hexsha": "7ebaae9dd02bbb5afe8ab2a29386d487ebf46b9b", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/2D/Types.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/2D/Types.agda", "max_line_length": 70, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/2D/Types.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": 372, "size": 971 }
{-# OPTIONS --without-K #-} module Pi1Examples where open import PiU using (U; ONE) open import PiLevel0 using (_⟷_; _◎_; _⊗_; id⟷; swap₊; unite⋆l; unite⋆r; swap⋆; uniti⋆l; uniti⋆r) open import Pi0Examples using (BOOL) open import PiLevel1 using (_⇔_; id⇔; trans⇔; _⊡_; assoc◎l; swapl⋆⇔; assoc◎r; linv◎l; idl◎l; idr◎l; unitil⋆⇔l) ------------------------------------------------------------------------------ -- Better syntax for writing 2paths infix 2 _▤ infixr 2 _⇔⟨_⟩_ _⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃) _ ⇔⟨ α ⟩ β = trans⇔ α β _▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c) _▤ c = id⇔ ------------------------------------------------------------------------------ -- a nice example of 2 paths neg₁ neg₂ neg₃ neg₄ neg₅ : BOOL ⟷ BOOL neg₁ = swap₊ neg₂ = id⟷ ◎ swap₊ neg₃ = swap₊ ◎ swap₊ ◎ swap₊ neg₄ = swap₊ ◎ id⟷ neg₅ = uniti⋆l ◎ swap⋆ ◎ (swap₊ ⊗ id⟷) ◎ swap⋆ ◎ unite⋆l neg₆ = uniti⋆r ◎ (swap₊ {ONE} {ONE} ⊗ id⟷) ◎ unite⋆r negEx : neg₅ ⇔ neg₁ negEx = uniti⋆l ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆l))) ⇔⟨ id⇔ ⊡ assoc◎l ⟩ uniti⋆l ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆l)) ⇔⟨ id⇔ ⊡ (swapl⋆⇔ ⊡ id⇔) ⟩ uniti⋆l ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆l)) ⇔⟨ id⇔ ⊡ assoc◎r ⟩ uniti⋆l ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆l))) ⇔⟨ id⇔ ⊡ (id⇔ ⊡ assoc◎l) ⟩ uniti⋆l ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆l)) ⇔⟨ id⇔ ⊡ (id⇔ ⊡ (linv◎l ⊡ id⇔)) ⟩ uniti⋆l ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆l)) ⇔⟨ id⇔ ⊡ (id⇔ ⊡ idl◎l) ⟩ uniti⋆l ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆l) ⇔⟨ assoc◎l ⟩ (uniti⋆l ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆l ⇔⟨ unitil⋆⇔l ⊡ id⇔ ⟩ (swap₊ ◎ uniti⋆l) ◎ unite⋆l ⇔⟨ assoc◎r ⟩ swap₊ ◎ (uniti⋆l ◎ unite⋆l) ⇔⟨ id⇔ ⊡ linv◎l ⟩ swap₊ ◎ id⟷ ⇔⟨ idr◎l ⟩ swap₊ ▤ ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.400885391, "avg_line_length": 32.2698412698, "ext": "agda", "hexsha": "523d41f1eff9aedecab7f74a570e42d566908370", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Pi1Examples.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Pi1Examples.agda", "max_line_length": 78, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Pi1Examples.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": 1101, "size": 2033 }
module FamilyPattern where data _==_ {A : Set}(x : A) : A -> Set where refl : x == x postulate C : {A : Set} -> A -> Set -- We can't solve unify x = y since the type is a meta variable. subst : {A : Set}{x y : A} -> x == y -> C y -> C x subst refl cx = cx -- subst {A} refl cx = cx -- works -- subst {x = x} .{x} refl cx = cx -- works
{ "alphanum_fraction": 0.5270655271, "avg_line_length": 23.4, "ext": "agda", "hexsha": "c4f29572ec642c806fe4eabcd5062ef15bffb7f0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/bugs/FamilyPattern.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/bugs/FamilyPattern.agda", "max_line_length": 64, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/bugs/FamilyPattern.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": 123, "size": 351 }
open import Level hiding ( suc ; zero ) open import Algebra module sym3n where open import Symmetric open import Data.Unit open import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_) open import Function open import Data.Nat hiding (_⊔_) -- using (ℕ; suc; zero) open import Relation.Nullary open import Data.Empty open import Data.Product open import Gutil open import Putil open import Solvable using (solvable) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Data.Fin open import Data.Fin.Permutation hiding (_∘ₚ_) infixr 200 _∘ₚ_ _∘ₚ_ = Data.Fin.Permutation._∘ₚ_ sym3solvable : solvable (Symmetric 3) solvable.dervied-length sym3solvable = 2 solvable.end sym3solvable x d = solved1 x d where open import Data.List using ( List ; [] ; _∷_ ) open Solvable (Symmetric 3) open import FLutil open import Data.List.Fresh hiding ([_]) open import Relation.Nary using (⌊_⌋) p0id : FL→perm ((# 0) :: ((# 0) :: ((# 0 ) :: f0))) =p= pid p0id = pleq _ _ refl open import Data.List.Fresh.Relation.Unary.Any open import FLComm stage3FList : CommFListN 3 2 ≡ cons (zero :: zero :: zero :: f0) [] (Level.lift tt) stage3FList = refl solved1 : (x : Permutation 3 3) → deriving 2 x → x =p= pid solved1 x dr = CommSolved 3 x ( CommFListN 3 2 ) stage3FList p0id solved2 where solved2 : Any (perm→FL x ≡_) ( CommFListN 3 2 ) solved2 = CommStage→ 3 2 x dr
{ "alphanum_fraction": 0.6974500345, "avg_line_length": 27.9038461538, "ext": "agda", "hexsha": "ef6192515c9400199d5c3935555a7bc70e83662b", "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": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_path": "src/sym3n.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "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": "shinji-kono/Galois", "max_issues_repo_path": "src/sym3n.agda", "max_line_length": 86, "max_stars_count": 1, "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_path": "src/sym3n.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "num_tokens": 482, "size": 1451 }
{-# OPTIONS --cubical-compatible #-} module WithoutK-PatternMatchingLambdas2 where -- Equality defined with two indices. data _≡_ {A : Set} : A → A → Set where refl : ∀ x → x ≡ x -- The --cubical-compatible option works with pattern matching lambdas. K : (A : Set) (x : A) (P : x ≡ x → Set) → P (refl x) → (p : x ≡ x ) → P p K = λ { A .x P pr (refl x) → pr }
{ "alphanum_fraction": 0.5945205479, "avg_line_length": 30.4166666667, "ext": "agda", "hexsha": "39d9c884e82badb77a535bca2a2e4dd2be835e34", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Fail/WithoutK-PatternMatchingLambdas2.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Fail/WithoutK-PatternMatchingLambdas2.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Fail/WithoutK-PatternMatchingLambdas2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 131, "size": 365 }
module Sized.Parrot where open import Data.Product open import Data.String.Base open import SizedIO.IOObject open import SizedIO.Base open import SizedIO.Console hiding (main) open import SizedIO.ConsoleObject open import NativeIO open import Sized.SimpleCell hiding (program; main) open import Size record Wrap A : Set where constructor wrap field unwrap : A parrotI = cellJ (Wrap String) ParrotC : (i : Size) → Set ParrotC i = ConsoleObject i parrotI -- but reusing cellC from SimpleCell, as interface is ident! -- class Parrot implements Cell { -- Cell cell; -- Parrot (Cell c) { cell = c; } -- public String get() { -- return "(" + cell.get() + ") is what parrot got"; -- } -- public void put (String s) { -- cell.put("parrot puts (" + s + ")"); -- } -- } -- parrotP is constructor for the consoleObject for interface (cellI String) parrotP : ∀{i} (c : CellC i) → ParrotC i (method (parrotP c) get) = method c get >>= λ { (s , c') → return (wrap ("(" ++ s ++ ") is what parrot got") , parrotP c' ) } (method (parrotP c) (put (wrap s))) = method c (put ("parrot puts (" ++ s ++ ")")) >>= λ { (_ , c') → return (_ , parrotP c') } -- public static void main (String[] args) { -- Parrot c = new Parrot(new SimpleCell("Start")); -- System.out.println(c.get()); -- c.put(args[1]); -- System.out.println(c.get()); -- } -- } program : String → IOConsole ∞ Unit program arg = let c₀ = parrotP (cellP "Start") in method c₀ get >>= λ{ (wrap s , c₁) → exec1 (putStrLn s) >> method c₁ (put (wrap arg)) >>= λ{ (_ , c₂) → method c₂ get >>= λ{ (wrap s' , c₃) → exec1 (putStrLn s') }}} main : NativeIO Unit main = translateIOConsole (program "hello") -- -}
{ "alphanum_fraction": 0.5927374302, "avg_line_length": 24.5205479452, "ext": "agda", "hexsha": "c2536213f778fdf88bb3910f39e7fca3897b3eab", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/Sized/Parrot.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "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/ooAgda", "max_issues_repo_path": "examples/Sized/Parrot.agda", "max_line_length": 76, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/Sized/Parrot.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 537, "size": 1790 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.FinWedge where module _ {i} {I} (X : Fin I → Ptd i) where {- the function for cofiber -} finwedge-f : Fin I → Σ (Fin I) (de⊙ ∘ X) finwedge-f = bigwedge-f X FinWedge : Type i FinWedge = BigWedge X ⊙FinWedge : Ptd i ⊙FinWedge = ⊙BigWedge X module _ {i} {I} {X : Fin I → Ptd i} where fwbase : FinWedge X fwbase = bwbase fwin : (<I : Fin I) → de⊙ (X <I) → FinWedge X fwin = bwin ⊙fwin : (<I : Fin I) → X <I ⊙→ ⊙FinWedge X ⊙fwin = ⊙bwin fwglue : (<I : Fin I) → fwbase == fwin <I (pt (X <I)) fwglue = cfglue module _ {i} {I} {X : Ptd i} where ⊙fwproj-in : Fin I → Fin I → X ⊙→ X ⊙fwproj-in = ⊙bwproj-in Fin-has-dec-eq module FinWedgeProj (<I : Fin I) = BigWedgeProj Fin-has-dec-eq {X = X} <I fwproj : Fin I → FinWedge (λ _ → X) → de⊙ X fwproj = FinWedgeProj.f ⊙fwproj : Fin I → ⊙FinWedge (λ _ → X) ⊙→ X ⊙fwproj <I = fwproj <I , idp fwproj-fwin-diag : (<I : Fin I) → fwproj <I ∘ fwin <I ∼ idf (de⊙ X) fwproj-fwin-diag <I = bwproj-bwin-diag Fin-has-dec-eq <I fwproj-fwin-≠ : ∀ {<I <I'} → <I ≠ <I' → fwproj <I ∘ fwin <I' ∼ cst (pt X) fwproj-fwin-≠ = bwproj-bwin-≠ Fin-has-dec-eq module _ {i₀ i₁} {I} {X₀ : Fin I → Ptd i₀} {X₁ : Fin I → Ptd i₁} (Xeq : ∀ <I → X₀ <I ⊙≃ X₁ <I) where finwedge-span-emap-r : SpanEquiv (cofiber-span (finwedge-f X₀)) (cofiber-span (finwedge-f X₁)) finwedge-span-emap-r = bigwedge-span-emap-r Xeq FinWedge-emap-r : FinWedge X₀ ≃ FinWedge X₁ FinWedge-emap-r = BigWedge-emap-r Xeq ⊙FinWedge-emap-r : ⊙FinWedge X₀ ⊙≃ ⊙FinWedge X₁ ⊙FinWedge-emap-r = ⊙BigWedge-emap-r Xeq module _ {i j} {I} {X : Ptd i} (<I : Fin I) where abstract fwproj-FinWedge-emap-r-lift : fwproj {X = ⊙Lift {j = j} X} <I ∘ –> (FinWedge-emap-r (λ _ → ⊙lift-equiv {j = j})) ∼ lift {j = j} ∘ fwproj {X = X} <I fwproj-FinWedge-emap-r-lift = bwproj-BigWedge-emap-r-lift Fin-has-dec-eq <I
{ "alphanum_fraction": 0.5837173579, "avg_line_length": 27.9, "ext": "agda", "hexsha": "b0cb8ec0c027645d195166d89ed88e698381702b", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/FinWedge.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/FinWedge.agda", "max_line_length": 96, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/FinWedge.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 898, "size": 1953 }
open import FRP.JS.RSet using ( RSet ; ⟦_⟧ ; _⇒_ ) open import FRP.JS.Time using ( Time ) module FRP.JS.Product where -- We define _∧_ directly, rather than as λ t → (A t × B t) -- in order to make _∧_ invertable. (If we used the obvious defn, -- (A ∧ B) would only be invertable if A and B were invertable. infixr 2 _∧_ infixr 4 _,_ data _∧_ (A B : RSet) (t : Time) : Set where _,_ : A t → B t → (A ∧ B) t proj₁ : ∀ {A B} → ⟦ A ∧ B ⇒ A ⟧ proj₁ (a , b) = a proj₂ : ∀ {A B} → ⟦ A ∧ B ⇒ B ⟧ proj₂ (a , b) = b swap : ∀ {A B} → ⟦ A ∧ B ⇒ B ∧ A ⟧ swap (a , b) = (b , a)
{ "alphanum_fraction": 0.547826087, "avg_line_length": 23.9583333333, "ext": "agda", "hexsha": "fc515d8770cbdd144f71b359fa7afc8303977d51", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Product.agda", "max_line_length": 65, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Product.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 251, "size": 575 }
{-# OPTIONS --type-in-type #-} -- yes, there will be some cheating in this lecture module Lec4 where open import Lec1Done open import Lec2Done open import Lec3Done -- the identity functor (the identity action on objects and arrows) ID : {C : Category} -> C => C ID = id~> where open Category CATEGORY -- composition of functors (composition of actions on objects and arrows) _>F>_ : {C D E : Category} -> (C => D) -> (D => E) -> (C => E) F >F> G = F >~> G where open Category CATEGORY -- EXAMPLES data Maybe (X : Set) : Set where yes : (x : X) -> Maybe X no : Maybe X {-# COMPILE GHC Maybe = data Maybe (Just | Nothing) #-} maybe : {X Y : Set} -> (X -> Y) -> Maybe X -> Maybe Y maybe f (yes x) = yes (f x) maybe f no = no MAYBE : SET => SET MAYBE = record { F-Obj = Maybe ; F-map = maybe ; F-map-id~> = extensionality \ { (yes x) -> refl (yes x) ; no -> refl no } -- extensionality \ { (yes x) -> refl (yes x) ; no -> refl no } ; F-map->~> = \ f g -> extensionality \ { (yes x) -> refl (yes (g (f x))) ; no -> refl no } } module MAYBE-CAT where open Category SET open _=>_ MAYBE {- unMaybe : {T : Set} -> Maybe T -> T unMaybe (yes t) = t unMaybe no = {!!} -} joinMaybe : {T : Set} -> Maybe (Maybe T) -> Maybe T joinMaybe (yes mt) = mt joinMaybe no = no MAYBE-CAT : Category MAYBE-CAT = record { Obj = Set ; _~>_ = \ S T -> S -> Maybe T ; id~> = yes ; _>~>_ = \ f g -> f >> (F-map g >> joinMaybe) ; law-id~>>~> = \ f -> refl f ; law->~>id~> = \ f -> extensionality \ x -> help f x ; law->~>>~> = \ f g h -> extensionality \ x -> yelp f g h x } where help : forall {S T} (f : S -> Maybe T) (x : S) -> joinMaybe (maybe yes (f x)) == f x help f x with f x help f x | yes y = refl (yes y) help f x | no = refl no yelp : forall {Q R S T} (f : Q -> Maybe R) (g : R -> Maybe S)(h : S -> Maybe T) (x : Q) -> joinMaybe (maybe h (joinMaybe (maybe g (f x)))) == joinMaybe (maybe (\ y → joinMaybe (maybe h (g y))) (f x)) yelp f g h x with f x yelp f g h x | yes y = refl (joinMaybe (maybe h (g y))) yelp f g h x | no = refl no open MAYBE-CAT module NATURAL-TRANSFORMATION {C D : Category} where open Category open _=>_ record _~~>_ (F G : C => D) : Set where field -- one operation xf : {X : Obj C} -> _~>_ D (F-Obj F X) (F-Obj G X) -- one law naturality : {X Y : Obj C}(f : _~>_ C X Y) -> _>~>_ D (F-map F f) (xf {Y}) == _>~>_ D (xf {X}) (F-map G f) module FUNCTOR-CP {C D E : Category} where open _=>_ open Category _>=>_ : C => D -> D => E -> C => E F-Obj (F >=> G) = F-Obj F >> F-Obj G F-map (F >=> G) = F-map F >> F-map G F-map-id~> (F >=> G) = F-map G (F-map F (id~> C)) =[ refl (F-map G) =$= F-map-id~> F >= F-map G (id~> D) =[ F-map-id~> G >= id~> E [QED] F-map->~> (F >=> G) f g = F-map G (F-map F (_>~>_ C f g)) =[ refl (F-map G) =$= F-map->~> F f g >= F-map G (_>~>_ D (F-map F f) (F-map F g)) =[ F-map->~> G (F-map F f) (F-map F g) >= _>~>_ E (F-map G (F-map F f)) (F-map G (F-map F g)) [QED] open FUNCTOR-CP open NATURAL-TRANSFORMATION public open _~~>_ public UNIT-MAYBE : ID ~~> MAYBE xf UNIT-MAYBE = yes naturality UNIT-MAYBE f = refl _ MULT-MAYBE : (MAYBE >=> MAYBE) ~~> MAYBE MULT-MAYBE = record { xf = joinMaybe ; naturality = \ f -> extensionality \ { (yes x) → refl (maybe f x) ; no → refl no } } module MONAD {C : Category}(M : C => C) where open Category C open _=>_ M record Monad : Set where field unit : ID ~~> M mult : (M >=> M) ~~> M unitMult : {X : Obj} -> (xf unit >~> xf mult) == id~> {F-Obj X} multUnit : {X : Obj} -> (F-map (xf unit) >~> xf mult) == id~> {F-Obj X} multMult : {X : Obj} -> (xf mult >~> xf mult) == (F-map (xf mult) >~> xf mult {X}) KLEISLI : Category KLEISLI = record { Obj = Obj ; _~>_ = \ S T -> S ~> F-Obj T ; id~> = xf unit ; _>~>_ = \ f g -> f >~> F-map g >~> xf mult ; law-id~>>~> = \ f -> xf unit >~> F-map f >~> xf mult =< law->~>>~> _ _ _ ]= (xf unit >~> F-map f) >~> xf mult =< refl (_>~> xf mult) =$= naturality unit f ]= (f >~> xf unit) >~> xf mult =[ law->~>>~> _ _ _ >= f >~> (xf unit >~> xf mult) =[ refl (f >~>_) =$= unitMult >= f >~> id~> =[ law->~>id~> f >= f [QED] ; law->~>id~> = \ f -> f >~> (F-map (xf unit) >~> xf mult) =[ refl (f >~>_) =$= multUnit >= f >~> id~> =[ law->~>id~> f >= f [QED] ; law->~>>~> = \ f g h -> (f >~> F-map g >~> xf mult) >~> F-map h >~> xf mult =[ law->~>>~> _ _ _ >= f >~> (F-map g >~> xf mult) >~> (F-map h >~> xf mult) =[ refl (\ x -> _ >~> x) =$= law->~>>~> _ _ _ >= f >~> F-map g >~> xf mult >~> F-map h >~> xf mult =< refl (\ x -> _ >~> _ >~> x) =$= assocn (naturality mult _) ]= f >~> F-map g >~> F-map (F-map h) >~> xf mult >~> xf mult =[ refl (\ x -> _ >~> _ >~> _ >~> x) =$= multMult >= f >~> F-map g >~> F-map (F-map h) >~> F-map (xf mult) >~> xf mult =< refl (\ x -> _ >~> _ >~> x) =$= law->~>>~> _ _ _ ]= f >~> F-map g >~> (F-map (F-map h) >~> F-map (xf mult)) >~> xf mult =< refl (\ x -> _ >~> _ >~> x >~> _) =$= F-map->~> _ _ ]= f >~> F-map g >~> F-map (F-map h >~> xf mult) >~> xf mult =< refl (\ x -> _ >~> x) =$= law->~>>~> _ _ _ ]= f >~> (F-map g >~> F-map (F-map h >~> xf mult)) >~> xf mult =< refl (\ x -> _ >~> x >~> _) =$= F-map->~> _ _ ]= f >~> F-map (g >~> F-map h >~> xf mult) >~> xf mult [QED] } open MONAD public MAYBE-Monad : Monad MAYBE MAYBE-Monad = record { unit = UNIT-MAYBE ; mult = MULT-MAYBE ; unitMult = refl _ ; multUnit = extensionality \ { (yes x) -> refl _ ; no -> refl _ } ; multMult = extensionality \ { (yes mmx) -> refl _ ; no -> refl _ } } data List (X : Set) : Set where [] : List X _,-_ : (x : X)(xs : List X) -> List X {-# COMPILE GHC List = data [] ([] | (:)) #-} list : {X Y : Set} -> (X -> Y) -> List X -> List Y list f [] = [] list f (x ,- xs) = f x ,- list f xs LIST : SET => SET LIST = record { F-Obj = List ; F-map = list ; F-map-id~> = extensionality listId ; F-map->~> = \ f g -> extensionality (listCp f g) } where open Category SET listId : {T : Set}(xs : List T) -> list id xs == xs listId [] = refl [] listId (x ,- xs) = refl (_,-_ x) =$= listId xs listCp : {R S T : Set} (f : R -> S) (g : S -> T) (xs : List R) → list (f >~> g) xs == (list f >~> list g) xs listCp f g [] = refl [] listCp f g (x ,- xs) = refl (_,-_ (g (f x))) =$= listCp f g xs data Two : Set where tt ff : Two {- BUILTIN BOOL Two -} {- BUILTIN FALSE ff -} {- BUILTIN TRUE tt -} {-# COMPILE GHC Two = data Bool (True | False) #-} data BitProcess (X : Set) : Set where -- in what way is X used? stop : (x : X) -> BitProcess X -- stop with value x send : (b : Two)(k : BitProcess X) -> BitProcess X -- send b, continue as k recv : (kt kf : BitProcess X) -> BitProcess X -- receive bit, continue as -- kt if tt, kf if ff {-(-} send1 : (b : Two) -> BitProcess One send1 b = send b (stop <>) {-)-} {-(-} recv1 : BitProcess Two recv1 = recv (stop tt) (stop ff) {-)-} {-(-} bpRun : forall {X} -> BitProcess X -- a process to run -> List Two -- a list of bits waiting to be input -> List Two -- the list of bits output * Maybe -- and, if we don't run out of input ( X -- the resulting value * List Two -- and the unused input ) bpRun (stop x) bs = [] , yes (x , bs) bpRun (send b px) bs = let os , mz = bpRun px bs in (b ,- os) , mz bpRun (recv pxt pxf) [] = [] , no bpRun (recv pxt pxf) (tt ,- bs) = bpRun pxt bs bpRun (recv pxt pxf) (ff ,- bs) = bpRun pxf bs {-)-} example = bpRun recv1 (tt ,- []) bitProcess : {X Y : Set} -> (X -> Y) -> BitProcess X -> BitProcess Y bitProcess f (stop x) = stop (f x) bitProcess f (send b k) = send b (bitProcess f k) bitProcess f (recv kt kf) = recv (bitProcess f kt) (bitProcess f kf) BITPROCESS : SET => SET -- actions on *values* lift to processes BITPROCESS = record { F-Obj = BitProcess ; F-map = bitProcess ; F-map-id~> = extensionality helpId ; F-map->~> = \ f g -> extensionality (helpCp f g) } where open Category SET helpId : {T : Set} (p : BitProcess T) -> bitProcess id p == p helpId (stop x) = refl (stop x) helpId (send b k) rewrite helpId k = refl (send b k) helpId (recv kt kf) rewrite helpId kt | helpId kf = refl (recv kt kf) helpCp : {R S T : Set} (f : R -> S)(g : S -> T) (p : BitProcess R) -> bitProcess (f >~> g) p == (bitProcess f >~> bitProcess g) p helpCp f g (stop x) = refl (stop (g (f x))) helpCp f g (send b k) rewrite helpCp f g k = refl (send b (bitProcess g (bitProcess f k))) helpCp f g (recv kt kf) rewrite helpCp f g kt | helpCp f g kf = refl (recv (bitProcess g (bitProcess f kt)) (bitProcess g (bitProcess f kf))) {-(-} UNIT-BP : ID ~~> BITPROCESS UNIT-BP = record { xf = stop ; naturality = \ f -> refl _ } {-)-} join-BP : {X : Set} -> BitProcess (BitProcess X) -> BitProcess X join-BP (stop px) = px join-BP (send b ppx) = send b (join-BP ppx) join-BP (recv ppxt ppxf) = recv (join-BP ppxt) (join-BP ppxf) {-(-} MULT-BP : (BITPROCESS >=> BITPROCESS) ~~> BITPROCESS MULT-BP = record { xf = join-BP ; naturality = \ f -> extensionality (help f ) } where help : ∀ {X Y} (f : X → Y) (x : BitProcess (BitProcess X)) → join-BP (bitProcess (bitProcess f) x) == bitProcess f (join-BP x) help f (stop x) = refl (bitProcess f x) help f (send b p) rewrite help f p = refl (send b (bitProcess f (join-BP p))) help f (recv pt pf) rewrite help f pf | help f pt = refl (recv (bitProcess f (join-BP pt)) (bitProcess f (join-BP pf))) {-)-} {-(-} BITPROCESS-Monad : Monad BITPROCESS BITPROCESS-Monad = record { unit = UNIT-BP ; mult = MULT-BP ; unitMult = refl id ; multUnit = extensionality help ; multMult = extensionality yelp } where help : ∀ {X} (x : BitProcess X) → join-BP (bitProcess stop x) == x help (stop x) = refl (stop x) help (send b p) rewrite help p = refl (send b p) help (recv pt pf) rewrite help pt | help pf = refl (recv pt pf) yelp : ∀ {X} (x : BitProcess (BitProcess (BitProcess X))) → join-BP (join-BP x) == join-BP (bitProcess join-BP x) yelp (stop x) = refl _ yelp (send b p) rewrite yelp p = refl _ yelp (recv pt pf) rewrite yelp pt | yelp pf = refl _ {-)-} module BIND {F : SET => SET}(M : Monad F) where open _=>_ F public open Monad M public open Category KLEISLI public {-(-} _>>=_ : {S T : Set} -> F-Obj S -> (S -> F-Obj T) -> F-Obj T fs >>= k = (id >~> k) fs {-)-} open BIND BITPROCESS-Monad bpEcho : BitProcess One bpEcho = recv1 >>= \ b -> send1 b BP-SEM : Set -> Set BP-SEM X = List Two -- a list of bits waiting to be input -> List Two -- the list of bits output * Maybe -- and, if we don't run out of input ( X -- the resulting value * List Two -- and the unused input ) record _**_ (S T : Set) : Set where constructor _,_ field outl : S outr : T open _**_ {-# COMPILE GHC _**_ = data (,) ((,)) #-} infixr 4 _**_ _,_ postulate -- Haskell has a monad for doing IO, which we use at the top level IO : Set -> Set mainLoop : {S : Set} -> S -> (S -> Two -> (List Two ** Maybe S)) -> IO One mainOutIn : {S : Set} -> S -> (S -> (List Two ** Maybe (Two -> S))) -> IO One {-# BUILTIN IO IO #-} {-# COMPILE GHC IO = type IO #-} {-# COMPILE GHC mainLoop = (\ _ -> Lec4HS.mainLoop) #-} {-# COMPILE GHC mainOutIn = (\ _ -> Lec4HS.mainOutIn) #-} {-# FOREIGN GHC import qualified Lec4HS #-} STATE : Set STATE = Two -> BitProcess One step : STATE -> Two -> (List Two ** Maybe STATE) step s b = go (s b) where go : BitProcess One → List Two ** Maybe (Two → BitProcess One) go (stop <>) = [] , no go (send b p) with go p ... | bs , ms = (b ,- bs) , ms go (recv pt pf) = [] , yes \ { tt → pt ; ff → pf } myState : STATE myState tt = bpEcho >>= \ _ -> bpEcho myState ff = bpEcho {- main : IO One main = mainLoop myState step -} example2 = bpRun (myState ff) (tt ,- ff ,- []) outIn : BitProcess One -> List Two ** Maybe (Two -> BitProcess One) outIn (stop <>) = [] , no outIn (send b p) with outIn p ... | os , mk = (b ,- os) , mk outIn (recv pt pf) = [] , yes \ { tt → pt ; ff → pf } main : IO One main = mainOutIn (send1 ff >>= \ _ -> bpEcho >>= \ _ -> bpEcho) outIn _-:>_ : {I : Set} -> (I -> Set) -> (I -> Set) -> (I -> Set) (S -:> T) i = S i -> T i [_] : {I : Set} -> (I -> Set) -> Set [ P ] = forall i -> P i -- [_] {I} P = (i : I) -> P i _->SET : Set -> Category I ->SET = record { Obj = I -> Set -- I-indexed sets ; _~>_ = \ S T -> [ S -:> T ] -- index-respecting functions ; id~> = \ i -> id -- the identity at every index ; _>~>_ = \ f g i -> f i >> g i -- composition at every index ; law-id~>>~> = refl -- and the laws are very boring ; law->~>id~> = refl ; law->~>>~> = \ f g h -> refl _ } All : {X : Set} -> (X -> Set) -> (List X -> Set) All P [] = One All P (x ,- xs) = P x * All P xs example3 : All (Vec Two) (1 ,- 2 ,- 3 ,- []) example3 = (tt ,- []) , (tt ,- ff ,- []) , (tt ,- ff ,- tt ,- []) , <> record _|>_ (I O : Set) : Set where field Cuts : O -> Set -- given o : O, how may we cut it? inners : {o : O} -> Cuts o -> List I -- given how we cut it, what are -- the shapes of its pieces? -- Let us have some examples right away! copy : Nat -> List One copy zero = [] copy (suc n) = <> ,- copy n VecCut : One |> Nat -- cut numbers into boring pieces VecCut = record { Cuts = \ n -> One -- there is one way to cut n ; inners = \ {n} _ -> copy n -- and you get n pieces } -- Here's a less boring example. You can cut a number into *two* pieces -- by finding two numbers that add to it. NatCut : Nat |> Nat NatCut = record { Cuts = \ mn -> Sg Nat \ m -> Sg Nat \ n -> (m +N n) == mn ; inners = \ { (m , n , _) -> m ,- n ,- [] } } -- The point is that we can make data structures that record how we -- built an O-shaped thing from I-shaped pieces. record Cutting {I O}(C : I |> O)(P : I -> Set)(o : O) : Set where constructor _8><_ -- "scissors" open _|>_ C field cut : Cuts o -- we decide how to cut o pieces : All P (inners cut) -- then we give all the pieces. infixr 3 _8><_ example4 : Cutting NatCut (Vec Two) 5 example4 = (3 , 2 , refl 5) 8>< ((tt ,- tt ,- tt ,- []) , (ff ,- ff ,- []) , <>) data Interior {I}(C : I |> I)(T : I -> Set)(i : I) : Set where -- either... tile : T i -> Interior C T i -- we have a tile that fits, or... <_> : Cutting C (Interior C T) i -> -- ...we cut, then tile the pieces. Interior C T i MayC : One |> One MayC = record { Cuts = \ _ -> One ; inners = \ _ -> [] } Maybe' : Set -> Set Maybe' X = Interior MayC (\ _ -> X) <> yes' : {X : Set} -> X -> Maybe' X yes' x = tile x no' : {X : Set} -> Maybe' X no' = < <> 8>< <> > BPC : One |> One BPC = record { Cuts = \ _ -> Two + One ; inners = \ { (inl x) → <> ,- [] ; (inr x) → <> ,- <> ,- [] } } data Type : Set where nat two : Type Val : Type -> Set Val nat = Nat Val two = Two data Op : Type -> Set where val : {T : Type} -> Val T -> Op T add : Op nat if : {T : Type} -> Op T Syntax : Type |> Type _|>_.Cuts Syntax T = Op T _|>_.inners Syntax {T} (val x) = [] _|>_.inners Syntax {.nat} add = nat ,- nat ,- [] _|>_.inners Syntax {T} if = two ,- T ,- T ,- [] eval : {T : Type}{X : Type -> Set} -> Interior Syntax X T -> ({T : Type} -> X T -> Val T) -> Val T eval (tile x) g = g x eval < val v 8>< <> > g = v eval < add 8>< e1 , e2 , <> > g = eval e1 g +N eval e2 g eval < if 8>< e1 , e2 , e3 , <> > g with eval e1 g eval < if 8>< e1 , e2 , e3 , <> > g | tt = eval e2 g eval < if 8>< e1 , e2 , e3 , <> > g | ff = eval e3 g
{ "alphanum_fraction": 0.4783621644, "avg_line_length": 31.2732240437, "ext": "agda", "hexsha": "31bab9ded5314949c629f47299cf3f70319f6a3e", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec4.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec4.agda", "max_line_length": 93, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec4.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 5982, "size": 17169 }
------------------------------------------------------------------------ -- Code for converting Vec n A → B to and from n-ary functions ------------------------------------------------------------------------ module Data.Vec.N-ary where open import Data.Nat open import Data.Vec open import Data.Function open import Relation.Binary open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- N-ary functions N-ary : ℕ → Set → Set → Set N-ary zero A B = B N-ary (suc n) A B = A → N-ary n A B ------------------------------------------------------------------------ -- Conversion curryⁿ : ∀ {n A B} → (Vec A n → B) → N-ary n A B curryⁿ {zero} f = f [] curryⁿ {suc n} f = λ x → curryⁿ (f ∘ _∷_ x) _$ⁿ_ : ∀ {n A B} → N-ary n A B → (Vec A n → B) f $ⁿ [] = f f $ⁿ (x ∷ xs) = f x $ⁿ xs ------------------------------------------------------------------------ -- N-ary function equality Eq : ∀ {A B} n → Rel B → (f g : N-ary n A B) → Set Eq zero _∼_ f g = f ∼ g Eq (suc n) _∼_ f g = ∀ x → Eq n _∼_ (f x) (g x) -- A variant where all the arguments are implicit (hidden). Eqʰ : ∀ {A B} n → Rel B → (f g : N-ary n A B) → Set Eqʰ zero _∼_ f g = f ∼ g Eqʰ (suc n) _∼_ f g = ∀ {x} → Eqʰ n _∼_ (f x) (g x) ------------------------------------------------------------------------ -- Some lemmas -- The functions curryⁿ and _$ⁿ_ are inverses. left-inverse : ∀ {n A B} (f : Vec A n → B) → ∀ xs → curryⁿ f $ⁿ xs ≡ f xs left-inverse f [] = refl left-inverse f (x ∷ xs) = left-inverse (f ∘ _∷_ x) xs right-inverse : ∀ {A B} n (f : N-ary n A B) → Eq n _≡_ (curryⁿ (_$ⁿ_ {n} f)) f right-inverse zero f = refl right-inverse (suc n) f = λ x → right-inverse n (f x) -- Conversion preserves equality. curryⁿ-pres : ∀ {n A B _∼_} (f g : Vec A n → B) → (∀ xs → f xs ∼ g xs) → Eq n _∼_ (curryⁿ f) (curryⁿ g) curryⁿ-pres {zero} f g hyp = hyp [] curryⁿ-pres {suc n} f g hyp = λ x → curryⁿ-pres (f ∘ _∷_ x) (g ∘ _∷_ x) (λ xs → hyp (x ∷ xs)) curryⁿ-pres⁻¹ : ∀ {n A B _∼_} (f g : Vec A n → B) → Eq n _∼_ (curryⁿ f) (curryⁿ g) → ∀ xs → f xs ∼ g xs curryⁿ-pres⁻¹ f g hyp [] = hyp curryⁿ-pres⁻¹ f g hyp (x ∷ xs) = curryⁿ-pres⁻¹ (f ∘ _∷_ x) (g ∘ _∷_ x) (hyp x) xs appⁿ-pres : ∀ {n A B _∼_} (f g : N-ary n A B) → Eq n _∼_ f g → (xs : Vec A n) → (f $ⁿ xs) ∼ (g $ⁿ xs) appⁿ-pres f g hyp [] = hyp appⁿ-pres f g hyp (x ∷ xs) = appⁿ-pres (f x) (g x) (hyp x) xs appⁿ-pres⁻¹ : ∀ {n A B _∼_} (f g : N-ary n A B) → ((xs : Vec A n) → (f $ⁿ xs) ∼ (g $ⁿ xs)) → Eq n _∼_ f g appⁿ-pres⁻¹ {zero} f g hyp = hyp [] appⁿ-pres⁻¹ {suc n} f g hyp = λ x → appⁿ-pres⁻¹ (f x) (g x) (λ xs → hyp (x ∷ xs)) -- Eq and Eqʰ are equivalent. Eq-to-Eqʰ : ∀ {A B} n {_∼_ : Rel B} {f g : N-ary n A B} → Eq n _∼_ f g → Eqʰ n _∼_ f g Eq-to-Eqʰ zero eq = eq Eq-to-Eqʰ (suc n) eq = Eq-to-Eqʰ n (eq _) Eqʰ-to-Eq : ∀ {A B} n {_∼_ : Rel B} {f g : N-ary n A B} → Eqʰ n _∼_ f g → Eq n _∼_ f g Eqʰ-to-Eq zero eq = eq Eqʰ-to-Eq (suc n) eq = λ _ → Eqʰ-to-Eq n eq
{ "alphanum_fraction": 0.4362437186, "avg_line_length": 32.1616161616, "ext": "agda", "hexsha": "d4734d612b2f638df646610b23a00a49e4d7bd81", "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/Vec/N-ary.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/Vec/N-ary.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/Data/Vec/N-ary.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": 3184 }
{-# OPTIONS --without-K #-} module CauchyProofsS where -- Proofs about permutations defined in module Cauchy (multiplicative2) open import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; subst; subst₂; cong; cong₂; setoid; proof-irrelevance; module ≡-Reasoning) open import Relation.Binary.PropositionalEquality.TrustMe using (trustMe) open import Relation.Nullary using (Dec; yes; no; ¬_) open import Data.Nat.Properties using (m≤m+n; n≤m+n; n≤1+n; cancel-+-left; cancel-*-right; strictTotalOrder; cancel-*-right-≤; ≰⇒>; ¬i+1+j≤i; 1+n≰n; ≤⇒pred≤) open import Data.Nat.Properties.Simple using (+-right-identity; +-suc; +-assoc; +-comm; *-assoc; *-comm; *-right-zero; distribʳ-*-+; +-*-suc) open import Data.Nat.DivMod using (DivMod; result; _divMod_; _div_; _mod_) open import Relation.Binary using (Rel; Decidable; Setoid; StrictTotalOrder; IsStrictTotalOrder; tri<; tri≈; tri>) open import Relation.Binary.Core using (Transitive; _⇒_) open import Data.String using (String) renaming (_++_ to _++S_) open import Data.Nat.Show using (show) open import Data.Bool using (Bool; false; true; _∨_) open import Data.Nat using (ℕ; suc; _+_; _∸_; _*_; _<_; _≮_; _≤_; _≰_; _≥_; z≤n; s≤s; _≟_; _≤?_; ≤-pred; module ≤-Reasoning) open import Data.Fin using (Fin; zero; suc; toℕ; fromℕ; fromℕ≤; _ℕ-_; _≺_; reduce≥; raise; inject+; inject₁; inject≤; _≻toℕ_; #_) renaming (_+_ to _F+_) open import Data.Fin.Properties using (bounded; inject+-lemma; to-from; toℕ-injective; inject≤-lemma; toℕ-fromℕ≤; fromℕ≤-toℕ) open import Data.Vec.Properties using (lookup∘tabulate; tabulate∘lookup; lookup-allFin; tabulate-∘; tabulate-allFin; allFin-map; lookup-++-inject+; lookup-++-≥; module UsingVectorEquality) open import Data.Product using (Σ; swap) open import Data.List using (List; []; _∷_; _∷ʳ_; foldl; replicate; reverse; downFrom; concatMap; gfilter; initLast; InitLast; _∷ʳ'_) renaming (_++_ to _++L_; map to mapL; concat to concatL; zip to zipL) open import Data.List.NonEmpty using (List⁺; [_]; _∷⁺_; head; last; _⁺++_) renaming (toList to nonEmptyListtoList; _∷ʳ_ to _n∷ʳ_; tail to ntail) open import Data.List.Any using (Any; here; there; any; module Membership) open import Data.Maybe using (Maybe; nothing; just; maybe′) open import Data.Vec using (Vec; tabulate; []; _∷_; tail; lookup; zip; zipWith; splitAt; _[_]≔_; allFin; toList) renaming (_++_ to _++V_; map to mapV; concat to concatV) open import Function using (id; _∘_; _$_; _∋_) open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit using (⊤; tt) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_; _,_; proj₁; proj₂) open import DivModUtils using (mod-lemma) open import Proofs open import Cauchy open import Perm open import CauchyProofs open import CauchyProofsT ------------------------------------------------------------------------------ -- Main lemma swap⋆idemp subst-allFin : ∀ {m n} → (eq : m ≡ n) → subst Cauchy eq (allFin m) ≡ allFin n subst-allFin refl = refl concat-simplify : {A : Set} → (m n : ℕ) → (f : Fin (suc m) → Vec A (suc n)) → concatV (mapV f (allFin (suc m))) ≡ f zero ++V concatV (mapV (f ∘ suc) (allFin m)) concat-simplify m n f = begin (concatV (mapV f (allFin (suc m))) ≡⟨ cong (λ x → concatV (mapV f x)) (allFin-map m) ⟩ concatV (mapV f (zero ∷ mapV suc (allFin m))) ≡⟨ refl ⟩ concatV (f zero ∷ mapV f (mapV suc (allFin m))) ≡⟨ cong (λ x → concatV (f zero ∷ x)) (sym (map-∘ f suc (allFin m))) ⟩ f zero ++V concatV (mapV (λ a → f (suc a)) (allFin m)) ∎) where open ≡-Reasoning concat-simplify-inject : {A : Set} → (m n : ℕ) (i : Fin (suc (suc n))) → (f : Fin (suc (suc m)) → Vec A (suc (suc n))) → lookup (inject+ (suc m * suc (suc n)) i) (concatV (mapV f (allFin (suc (suc m))))) ≡ lookup i (f zero) concat-simplify-inject m n i f = begin (lookup (inject+ (suc m * suc (suc n)) i) (concatV (mapV f (allFin (suc (suc m))))) ≡⟨ cong (lookup (inject+ (suc m * suc (suc n)) i)) (concat-simplify (suc m) (suc n) f) ⟩ lookup (inject+ (suc m * suc (suc n)) i) (f zero ++V concatV (mapV (λ a → f (suc a)) (allFin (suc m)))) ≡⟨ lookup-++-inject+ (f zero) (concatV (mapV (λ a → f (suc a)) (allFin (suc m)))) i ⟩ lookup i (f zero) ∎) where open ≡-Reasoning concat-simplify-raise : {A : Set} → (m n : ℕ) (i : Fin (suc m * suc (suc n))) → (f : Fin (suc (suc m)) → Vec A (suc (suc n))) → lookup (raise (suc (suc n)) i) (concatV (mapV f (allFin (suc (suc m))))) ≡ lookup i (concatV (mapV (λ a → f (suc a)) (allFin (suc m)))) concat-simplify-raise m n i f = begin (lookup (raise (suc (suc n)) i) (concatV (mapV f (allFin (suc (suc m))))) ≡⟨ cong (lookup (raise (suc (suc n)) i)) (concat-simplify (suc m) (suc n) f) ⟩ lookup (raise (suc (suc n)) i) (f zero ++V concatV (mapV (λ a → f (suc a)) (allFin (suc m)))) ≡⟨ lookup-++-raise (f zero) (concatV (mapV (λ a → f (suc a)) (allFin (suc m)))) i ⟩ lookup i (concatV (mapV (λ a → f (suc a)) (allFin (suc m)))) ∎) where open ≡-Reasoning lookup-subst-1 : ∀ {m m'} (i : Fin m') (xs : Vec (Fin m) m) (eq : m ≡ m') (eq' : m' ≡ m) (irr : sym eq ≡ eq') → lookup i (subst (λ s → Vec (Fin s) s) eq xs) ≡ subst Fin eq (lookup (subst Fin eq' i) xs) lookup-subst-1 i xs refl .refl refl = refl subst-inject-mod : ∀ {n m m'} → (eq : suc (suc m) ≡ suc (suc m')) → subst Fin eq (inject≤ (n mod (suc m)) (i≤si (suc m))) ≡ inject≤ (n mod (suc m')) (i≤si (suc m')) subst-inject-mod refl = refl cmp = IsStrictTotalOrder.compare (StrictTotalOrder.isStrictTotalOrder strictTotalOrder) max-b-d : (m n : ℕ) → (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) → (p= : suc (toℕ b * suc (suc n) + toℕ d) ≡ suc (suc m) * suc (suc n)) → (toℕ b ≡ suc m × toℕ d ≡ suc n) max-b-d m n b d p= with cmp (toℕ b) (suc m) | cmp (toℕ d) (suc n) max-b-d m n b d p= | tri< a ¬b ¬c | tri< a₁ ¬b₁ ¬c₁ = ⊥-elim (1+n≰n contra) where contra = begin (1 + suc (toℕ b * suc (suc n) + toℕ d) ≡⟨ cong suc (sym (+-suc (toℕ b * suc (suc n)) (toℕ d))) ⟩ 1 + (toℕ b * suc (suc n) + suc (toℕ d)) ≡⟨ sym (+-suc (toℕ b * suc (suc n)) (suc (toℕ d))) ⟩ toℕ b * suc (suc n) + suc (suc (toℕ d)) ≤⟨ cong+l≤ (s≤s a₁) (toℕ b * suc (suc n)) ⟩ toℕ b * suc (suc n) + suc (suc n) ≡⟨ +-comm (toℕ b * suc (suc n)) (suc (suc n)) ⟩ suc (toℕ b) * suc (suc n) ≤⟨ cong*r≤ (≰⇒> ¬c) (suc (suc n)) ⟩ suc (suc m) * suc (suc n) ≡⟨ sym p= ⟩ suc (toℕ b * suc (suc n) + toℕ d) ∎) where open ≤-Reasoning max-b-d m n b d p= | tri< a ¬b= ¬c | tri≈ ¬a d= ¬c₁ = ⊥-elim (¬b= (cancel-+-left 1 (cancel-*-right (suc (toℕ b)) (suc (suc m)) {suc n} contra))) where contra : suc (toℕ b) * suc (suc n) ≡ suc (suc m) * suc (suc n) contra = begin (suc (toℕ b) * suc (suc n) ≡⟨ refl ⟩ suc (suc n) + toℕ b * suc (suc n) ≡⟨ +-comm (suc (suc n)) (toℕ b * suc (suc n)) ⟩ toℕ b * suc (suc n) + suc (suc n) ≡⟨ +-suc (toℕ b * suc (suc n)) (suc n) ⟩ suc (toℕ b * suc (suc n) + suc n) ≡⟨ cong (λ x → suc (toℕ b * suc (suc n) + x)) (sym d=) ⟩ suc (toℕ b * suc (suc n) + toℕ d) ≡⟨ p= ⟩ suc (suc m) * suc (suc n) ∎) where open ≡-Reasoning max-b-d m n b d p= | tri< a ¬b ¬c | tri> ¬a ¬b₁ c = ⊥-elim (1+n≰n (trans≤ (bounded d) c)) max-b-d m n b d p= | tri≈ ¬a b= ¬c | tri< a ¬d= ¬c₁ = ⊥-elim (¬d= (cancel-+-left 1 (cancel-+-left (suc m * suc (suc n)) contra))) where contra : suc m * suc (suc n) + suc (toℕ d) ≡ suc m * suc (suc n) + suc (suc n) contra = begin (suc m * suc (suc n) + suc (toℕ d) ≡⟨ cong (λ x → x * suc (suc n) + suc (toℕ d)) (sym b=) ⟩ toℕ b * suc (suc n) + suc (toℕ d) ≡⟨ +-suc (toℕ b * suc (suc n)) (toℕ d) ⟩ suc (toℕ b * suc (suc n) + toℕ d) ≡⟨ p= ⟩ suc (suc m) * suc (suc n) ≡⟨ +-comm (suc (suc n)) (suc m * suc (suc n)) ⟩ suc m * suc (suc n) + suc (suc n) ∎) where open ≡-Reasoning max-b-d m n b d p= | tri≈ ¬a b₁ ¬c | tri≈ ¬a₁ b₂ ¬c₁ = (b₁ , b₂) max-b-d m n b d p= | tri≈ ¬a b₁ ¬c | tri> ¬a₁ ¬b c = ⊥-elim (1+n≰n (trans≤ (bounded d) c)) max-b-d m n b d p= | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = ⊥-elim (1+n≰n (trans≤ (bounded b) c)) max-b-d m n b d p= | tri> ¬a ¬b c | tri≈ ¬a₁ b₁ ¬c = ⊥-elim (1+n≰n (trans≤ (bounded b) c)) max-b-d m n b d p= | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = ⊥-elim (1+n≰n (trans≤ (bounded d) c₁)) subst-fin : (a b : ℕ) → (eq : suc a ≡ suc b) → subst Fin eq (fromℕ a) ≡ fromℕ b subst-fin a .a refl = refl lookup-fromℕ-allFin : {A : Set} → (n : ℕ) → (f : Fin (suc n) → A) → lookup (fromℕ n) (tabulate {suc n} f) ≡ f (fromℕ n) lookup-fromℕ-allFin 0 f = refl lookup-fromℕ-allFin (suc n) f = lookup-fromℕ-allFin n (f ∘ suc) fin=1 : (m n : ℕ) → fromℕ (suc m + suc n * suc (suc m)) ≡ fromℕ (suc (m + suc (suc (m + n * suc (suc m))))) fin=1 m n = toℕ-injective p where p = begin (toℕ (fromℕ (suc m + suc n * suc (suc m))) ≡⟨ to-from (suc m + suc n * suc (suc m)) ⟩ suc m + suc n * suc (suc m) ≡⟨ refl ⟩ suc (m + suc (suc (m + n * suc (suc m)))) ≡⟨ sym (to-from (suc (m + suc (suc (m + n * suc (suc m)))))) ⟩ toℕ (fromℕ (suc (m + suc (suc (m + n * suc (suc m)))))) ∎) where open ≡-Reasoning concat-map-map-tabulate : (m n : ℕ) → (f : Fin m × Fin n → Fin (m * n)) → concatV (mapV (λ b → mapV (λ d → f (b , d)) (allFin n)) (allFin m)) ≡ tabulate (λ k → f (fin-project m n k)) concat-map-map-tabulate m n f = begin (concatV (mapV (λ b → mapV (λ d → f (b , d)) (allFin n)) (allFin m)) ≡⟨ cong concatV (sym (tabulate-∘ (λ b → mapV (λ d → f (b , d)) (allFin n)) id)) ⟩ concatV (tabulate (λ b → mapV (λ d → f (b , d)) (allFin n))) ≡⟨ cong concatV (finext (λ b → sym (tabulate-∘ (λ d → f (b , d)) id))) ⟩ concatV (tabulate (λ b → tabulate (λ d → f (b , d)))) ≡⟨ tabulate-concat f ⟩ tabulate (λ k → f (fin-project m n k)) ∎) where open ≡-Reasoning fin-project-2 : (n m : ℕ) → fin-project (suc (suc n)) (suc (suc m)) (fromℕ (suc m + suc n * suc (suc m))) ≡ (fromℕ (suc n) , fromℕ (suc m)) fin-project-2 n m with toℕ (fromℕ (suc m + suc n * suc (suc m))) divMod (suc (suc m)) fin-project-2 n m | result q r k≡r+q*sn with suc (suc n) ≤? q fin-project-2 n m | result q r k≡r+q*sn | yes p = ⊥-elim (absurd (suc n) (suc m) q r (fromℕ (suc m + suc n * suc (suc m))) k≡r+q*sn p) fin-project-2 n m | result q r k≡r+q*sn | no ¬p = let (b= , d=) = max-b-d n m (fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p)))) r pr in cong₂ _,_ (toℕ-injective (trans b= (sym (to-from (suc n))))) (toℕ-injective (trans d= (sym (to-from (suc m))))) where pr : suc (toℕ (fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p)))) * suc (suc m) + toℕ r) ≡ suc (suc n) * suc (suc m) pr = begin (_ -- agda bug? -- replacing _ by the actual term: -- suc (toℕ (fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p)))) * suc (suc m) + toℕ r) -- gives an occurs check error ≡⟨ cong (λ x → suc (x * suc (suc m) + toℕ r)) (toℕ-fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p)))) ⟩ suc (q * suc (suc m) + toℕ r) ≡⟨ cong suc (+-comm (q * suc (suc m)) (toℕ r)) ⟩ suc (toℕ r + q * suc (suc m)) ≡⟨ cong suc (sym k≡r+q*sn) ⟩ suc (suc (toℕ (fromℕ (m + suc (suc (m + n * suc (suc m))))))) ≡⟨ cong (λ x → suc (suc x)) (to-from (m + suc (suc (m + n * suc (suc m))))) ⟩ suc (suc n) * suc (suc m) ∎) where open ≡-Reasoning -- index (b,d) in matrix becomes (d,b) in transpose -- And yes, it is obvious: -- (b*n+d)*m = b*n*m + d*m -- expand -- = b*(n*m -1) + b*1 + d*m -- add 0 = b*1 - b*1 -- = b + d*m -- modulus num-lem : (m n : ℕ) → (b : Fin (suc (suc m))) → (d : Fin (suc (suc n))) → (((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) ≡ (toℕ d * suc (suc m) + toℕ b) + toℕ b * suc (m + suc n * suc (suc m)) num-lem m n b d = begin (((toℕ b * suc (suc n)) + toℕ d) * suc (suc m) ≡⟨ distribʳ-*-+ (suc (suc m)) (toℕ b * suc (suc n)) (toℕ d) ⟩ (toℕ b * suc (suc n)) * suc (suc m) + toℕ d * suc (suc m) ≡⟨ cong (λ x → x + toℕ d * suc (suc m)) (trans (*-assoc (toℕ b) (suc (suc n)) (suc (suc m))) (*-comm (toℕ b) (suc (suc n) * suc (suc m)))) ⟩ (suc (suc n) * suc (suc m)) * toℕ b + toℕ d * suc (suc m) ≡⟨ refl ⟩ suc (suc m + suc n * suc (suc m)) * toℕ b + toℕ d * suc (suc m) ≡⟨ refl ⟩ (toℕ b + (suc m + suc n * suc (suc m)) * toℕ b) + toℕ d * suc (suc m) ≡⟨ cong (λ x → x + toℕ d * suc (suc m)) (+-comm (toℕ b) ((suc m + suc n * suc (suc m)) * toℕ b)) ⟩ ((suc m + suc n * suc (suc m)) * toℕ b + toℕ b) + toℕ d * suc (suc m) ≡⟨ +-assoc ((suc m + suc n * suc (suc m)) * toℕ b) (toℕ b) (toℕ d * suc (suc m)) ⟩ (suc m + suc n * suc (suc m)) * toℕ b + (toℕ b + toℕ d * suc (suc m)) ≡⟨ cong₂ _+_ (*-comm (suc m + suc n * suc (suc m)) (toℕ b)) (+-comm (toℕ b) (toℕ d * suc (suc m))) ⟩ toℕ b * (suc m + suc n * suc (suc m)) + (toℕ d * suc (suc m) + toℕ b) ≡⟨ +-comm (toℕ b * (suc m + suc n * suc (suc m))) (toℕ d * suc (suc m) + toℕ b) ⟩ (toℕ d * suc (suc m) + toℕ b) + toℕ b * (suc m + suc n * suc (suc m)) ∎) where open ≡-Reasoning mod-lem : (m n : ℕ) → (b : Fin (suc (suc m))) → (d : Fin (suc (suc n))) → (leq : suc (toℕ d * suc (suc m) + toℕ b) ≤ suc m + suc n * suc (suc m)) → ((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod (suc m + suc n * suc (suc m))) ≡ inject≤ (fromℕ (toℕ d * suc (suc m) + toℕ b)) leq mod-lem m n b d leq = begin (((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod (suc m + suc n * suc (suc m))) ≡⟨ cong (λ x → x mod (suc m + suc n * suc (suc m))) (num-lem m n b d) ⟩ (((toℕ d * suc (suc m) + toℕ b) + (toℕ b * (suc m + suc n * suc (suc m)))) mod (suc m + suc n * suc (suc m))) ≡⟨ cong (λ x → ((x + (toℕ b * (suc m + suc n * suc (suc m)))) mod (suc m + suc n * suc (suc m)))) (trans (sym (to-from (toℕ d * suc (suc m) + toℕ b))) (sym (inject≤-lemma (fromℕ (toℕ d * suc (suc m) + toℕ b)) leq) )) ⟩ (((toℕ (inject≤ (fromℕ (toℕ d * suc (suc m) + toℕ b)) leq)) + (toℕ b * (suc m + suc n * suc (suc m)))) mod (suc m + suc n * suc (suc m))) ≡⟨ mod-lemma (toℕ b) (m + suc n * suc (suc m)) (inject≤ (fromℕ (toℕ d * suc (suc m) + toℕ b)) leq) ⟩ inject≤ (fromℕ (toℕ d * suc (suc m) + toℕ b)) leq ∎) where open ≡-Reasoning not-max-b-d : (m n : ℕ) (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) (p≠ : ¬ suc (toℕ b * suc (suc n) + toℕ d) ≡ suc (suc m) * suc (suc n)) → suc (toℕ b * suc (suc n) + toℕ d) ≤ suc n + suc m * suc (suc n) not-max-b-d m n b d p≠ with cmp (suc (toℕ b * suc (suc n) + toℕ d)) (suc (suc m) * suc (suc n)) ... | tri< a ¬b ¬c = ≤-pred a ... | tri≈ ¬a b≡ ¬c = ⊥-elim (p≠ b≡) ... | tri> ¬a ¬b c = ⊥-elim (1+n≰n contra) where contra = begin (suc (suc (suc m) * suc (suc n)) ≤⟨ c ⟩ suc (toℕ b * suc (suc n) + toℕ d) ≡⟨ sym (+-suc (toℕ b * suc (suc n)) (toℕ d)) ⟩ toℕ b * suc (suc n) + suc (toℕ d) ≤⟨ cong+l≤ (bounded d) (toℕ b * suc (suc n)) ⟩ toℕ b * suc (suc n) + suc (suc n) ≤⟨ cong+r≤ (cong*r≤ (bounded' (suc m) b) (suc (suc n))) (suc (suc n)) ⟩ suc m * suc (suc n) + suc (suc n) ≡⟨ +-comm (suc m * suc (suc n)) (suc (suc n)) ⟩ suc (suc m) * suc (suc n) ∎) where open ≤-Reasoning not-max-b-d' : (m n : ℕ) (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) (p≠ : ¬ suc (toℕ b * suc (suc n) + toℕ d) ≡ suc (suc m) * suc (suc n)) → (¬ suc (toℕ d * suc (suc m) + toℕ b) ≡ suc (suc n) * suc (suc m)) not-max-b-d' m n b d p≠ with (suc (toℕ d * suc (suc m) + toℕ b)) ≟ (suc (suc n) * suc (suc m)) ... | no ¬w = ¬w ... | yes w = let (d≡sn , b≡sm) = max-b-d n m d b w in ⊥-elim (p≠ (contra b≡sm d≡sn)) where contra : (b≡sm : toℕ b ≡ suc m) (d≡sn : toℕ d ≡ suc n) → suc (toℕ b * suc (suc n) + toℕ d) ≡ suc (suc m) * suc (suc n) contra b≡sm d≡sn = begin (suc (toℕ b * suc (suc n) + toℕ d) ≡⟨ cong₂ (λ x y → suc (x * suc (suc n) + y)) b≡sm d≡sn ⟩ suc (suc m * suc (suc n) + suc n) ≡⟨ sym (+-suc (suc m * suc (suc n)) (suc n)) ⟩ suc m * suc (suc n) + suc (suc n) ≡⟨ +-comm (suc m * suc (suc n)) (suc (suc n)) ⟩ suc (suc m) * suc (suc n) ∎) where open ≡-Reasoning inject-mod : (m n : ℕ) (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) (leq : suc (toℕ b * suc (suc n) + toℕ d) ≤ suc n + suc m * suc (suc n)) → inject≤ (((toℕ d * suc (suc m) + toℕ b) * suc (suc n)) mod (suc n + suc m * suc (suc n))) (i≤si (suc n + suc m * suc (suc n))) ≡ inject≤ (fromℕ (toℕ b * suc (suc n) + toℕ d)) (i*n+k≤m*n b d) inject-mod m n b d leq = begin (inject≤ (((toℕ d * suc (suc m) + toℕ b) * suc (suc n)) mod (suc n + suc m * suc (suc n))) (i≤si (suc n + suc m * suc (suc n))) ≡⟨ cong₂D! inject≤ (sym (mod-lem n m d b leq)) (≤-proof-irrelevance (subst (λ _ → suc n + suc m * suc (suc n) ≤ suc (suc n + suc m * suc (suc n))) (sym (mod-lem n m d b leq)) (i≤si (suc n + suc m * suc (suc n)))) (i≤si (suc n + suc m * suc (suc n)))) ⟩ inject≤ (inject≤ (fromℕ (toℕ b * suc (suc n) + toℕ d)) leq) (i≤si (suc n + suc m * suc (suc n))) ≡⟨ toℕ-injective (trans (inject≤-lemma (inject≤ (fromℕ (toℕ b * suc (suc n) + toℕ d)) leq) (i≤si (suc n + suc m * suc (suc n)))) (trans (inject≤-lemma (fromℕ (toℕ b * suc (suc n) + toℕ d)) leq) (sym (inject≤-lemma (fromℕ (toℕ b * suc (suc n) + toℕ d)) (i*n+k≤m*n b d))))) ⟩ inject≤ (fromℕ (toℕ b * suc (suc n) + toℕ d)) (i*n+k≤m*n b d) ∎) where open ≡-Reasoning fin-project-3 : (m n : ℕ) (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) → (p≠ : ¬ suc (toℕ d * suc (suc m) + toℕ b) ≡ suc (suc n) * suc (suc m)) → fin-project (suc (suc n)) (suc (suc m)) (inject≤ ((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod (suc m + suc n * suc (suc m))) (i≤si (suc m + suc n * suc (suc m)))) ≡ (d , b) fin-project-3 m n b d p≠ with (toℕ (inject≤ ((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod (suc m + suc n * suc (suc m))) (i≤si (suc m + suc n * suc (suc m))))) divMod (suc (suc m)) fin-project-3 m n b d p≠ | result q r k≡r+q*sn with suc (suc n) ≤? q fin-project-3 m n b d p≠ | result q r k≡r+q*sn | yes p = ⊥-elim (absurd (suc n) (suc m) q r (inject≤ ((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod (suc m + suc n * suc (suc m))) (i≤si (suc m + suc n * suc (suc m)))) k≡r+q*sn p) fin-project-3 m n b d p≠ | result q r k≡r+q*sn | no ¬p = let (r≡b , q≡d) = addMul-lemma′ q (toℕ d) (suc m) r b (sym simplified) in cong₂ _,_ (toℕ-injective (trans (toℕ-fromℕ≤ (s≤s (≤-pred (≰⇒> ¬p)))) q≡d)) r≡b where simplified : toℕ d * suc (suc m) + toℕ b ≡ q * suc (suc m) + toℕ r simplified = begin (toℕ d * suc (suc m) + toℕ b ≡⟨ sym (to-from (toℕ d * suc (suc m) + toℕ b)) ⟩ toℕ (fromℕ (toℕ d * suc (suc m) + toℕ b)) ≡⟨ sym (inject≤-lemma (fromℕ (toℕ d * suc (suc m) + toℕ b)) (i*n+k≤m*n d b)) ⟩ toℕ (inject≤ (fromℕ (toℕ d * suc (suc m) + toℕ b)) (i*n+k≤m*n d b)) ≡⟨ cong toℕ (sym (inject-mod n m d b (not-max-b-d n m d b p≠))) ⟩ toℕ (inject≤ ((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod (suc m + suc n * suc (suc m))) (i≤si (suc m + suc n * suc (suc m)))) ≡⟨ k≡r+q*sn ⟩ toℕ r + q * suc (suc m) ≡⟨ +-comm (toℕ r) (q * suc (suc m)) ⟩ q * suc (suc m) + toℕ r ∎) where open ≡-Reasoning transpose2 : (m n : ℕ) (i : Fin (m * n)) → let fin-result b d dec dec' = fin-divMod m n i fin-result bt dt dect dec't = fin-divMod n m (subst Fin (*-comm m n) (transposeIndex m n b d)) in toℕ (transposeIndex n m bt dt) ≡ toℕ i transpose2 m n i = let fin-result b d dec dec' = fin-divMod m n i fin-result bt dt dect dec't = fin-divMod n m (subst Fin (*-comm m n) (transposeIndex m n b d)) (dbt≡ , bdt≡) = fin-addMul-lemma n m d bt b dt pr in fpr where pr = let fin-result b d dec dec' = fin-divMod m n i fin-result bt dt dect dec't = fin-divMod n m (subst Fin (*-comm m n) (transposeIndex m n b d)) in begin (toℕ d * m + toℕ b ≡⟨ sym (to-from _) ⟩ toℕ (fromℕ (toℕ d * m + toℕ b)) ≡⟨ sym (inject≤-lemma _ _) ⟩ toℕ (transposeIndex m n b d) ≡⟨ sym (toℕ-fin (m * n) (n * m) (*-comm m n) (transposeIndex m n b d)) ⟩ toℕ (subst Fin (*-comm m n) (transposeIndex m n b d)) ≡⟨ dect ⟩ toℕ dt + toℕ bt * m ≡⟨ +-comm (toℕ dt) (toℕ bt * m) ⟩ toℕ bt * m + toℕ dt ∎) where open ≡-Reasoning fpr = let fin-result b d dec dec' = fin-divMod m n i fin-result bt dt dect dec't = fin-divMod n m (subst Fin (*-comm m n) (transposeIndex m n b d)) (dbt≡ , bdt≡) = fin-addMul-lemma n m d bt b dt pr in begin (toℕ (transposeIndex n m bt dt) ≡⟨ inject≤-lemma _ _ ⟩ toℕ (fromℕ (toℕ dt * n + toℕ bt)) ≡⟨ to-from _ ⟩ toℕ dt * n + toℕ bt ≡⟨ cong₂ (λ x y → toℕ x * n + toℕ y) (sym bdt≡) (sym dbt≡) ⟩ toℕ b * n + toℕ d ≡⟨ +-comm (toℕ b * n) (toℕ d) ⟩ toℕ d + toℕ b * n ≡⟨ sym dec ⟩ toℕ i ∎) where open ≡-Reasoning lookup-transpose : (m n : ℕ) (i : Fin (m * n)) → lookup (lookup i (concatV (mapV (λ b → mapV (λ d → transposeIndex m n b d) (allFin n)) (allFin m)))) (subst Cauchy (*-comm n m) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n)))) ≡ i lookup-transpose m n i = let fin-result b d dec dec' = fin-divMod m n i fin-result bt dt dect dect' = fin-divMod n m (subst Fin (*-comm m n) (transposeIndex m n b d)) in begin (lookup (lookup i (concatV (mapV (λ b → mapV (λ d → transposeIndex m n b d) (allFin n)) (allFin m)))) (subst Cauchy (*-comm n m) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n)))) ≡⟨ cong (λ x → lookup x (subst Cauchy (*-comm n m) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n))))) (trans (lookup-2d m n i (allFin m) (allFin n) (λ {(b , d) → transposeIndex m n b d})) (cong₂ (transposeIndex m n) (lookup-allFin b) (lookup-allFin d))) ⟩ lookup (transposeIndex m n b d) (subst Cauchy (*-comm n m) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n)))) ≡⟨ lookup-subst-1 (transposeIndex m n b d) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n))) (*-comm n m) (*-comm m n) (proof-irrelevance (sym (*-comm n m)) (*-comm m n)) ⟩ subst Fin (*-comm n m) (lookup (subst Fin (*-comm m n) (transposeIndex m n b d)) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n)))) ≡⟨ cong (λ x → subst Fin (*-comm n m) x) (trans (lookup-2d n m (subst Fin (*-comm m n) (transposeIndex m n b d)) (allFin n) (allFin m) (λ {(d , b) → transposeIndex n m d b})) (cong₂ (transposeIndex n m) (lookup-allFin bt) (lookup-allFin dt))) ⟩ subst Fin (*-comm n m) (transposeIndex n m bt dt) ≡⟨ toℕ-injective (trans (toℕ-fin (n * m) (m * n) (*-comm n m) (transposeIndex n m bt dt)) (transpose2 m n i)) ⟩ i ∎) where open ≡-Reasoning swap⋆idemp : (m n : ℕ) → scompcauchy (swap⋆cauchy m n) (subst Cauchy (*-comm n m) (swap⋆cauchy n m)) ≡ allFin (m * n) swap⋆idemp m n = begin (scompcauchy (concatV (mapV (λ b → mapV (λ d → transposeIndex m n b d) (allFin n)) (allFin m))) (subst Cauchy (*-comm n m) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n)))) ≡⟨ refl ⟩ tabulate (λ i → lookup (lookup i (concatV (mapV (λ b → mapV (λ d → transposeIndex m n b d) (allFin n)) (allFin m)))) (subst Cauchy (*-comm n m) (concatV (mapV (λ d → mapV (λ b → transposeIndex n m d b) (allFin m)) (allFin n))))) ≡⟨ finext (lookup-transpose m n) ⟩ allFin (m * n) ∎) where open ≡-Reasoning ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.445013963, "avg_line_length": 44.4795597484, "ext": "agda", "hexsha": "c0978cc55c21119003d460a41836d4cbfae7ec25", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Obsolete/CauchyProofsS.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Obsolete/CauchyProofsS.agda", "max_line_length": 88, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Obsolete/CauchyProofsS.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": 10999, "size": 28289 }
-- Andreas, 2017-07-28, issue 1077 open import Issue1077 foz = foo baz = bar -- WAS: bar not in scope -- NOW: import fails because module Issue1077 is rejected
{ "alphanum_fraction": 0.7134146341, "avg_line_length": 14.9090909091, "ext": "agda", "hexsha": "d577bda6f3e4ae6f296385b1c89040ed6f479133", "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/Issue1077Main.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/Issue1077Main.agda", "max_line_length": 57, "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/Issue1077Main.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 52, "size": 164 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.Nat.Order where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Sigma open import Cubical.Data.Sum as ⊎ open import Cubical.Data.Nat.Base open import Cubical.Data.Nat.Properties open import Cubical.Induction.WellFounded open import Cubical.Relation.Nullary infix 4 _≤_ _<_ _≤_ : ℕ → ℕ → Type₀ m ≤ n = Σ[ k ∈ ℕ ] k + m ≡ n _<_ : ℕ → ℕ → Type₀ m < n = suc m ≤ n data Trichotomy (m n : ℕ) : Type₀ where lt : m < n → Trichotomy m n eq : m ≡ n → Trichotomy m n gt : n < m → Trichotomy m n private variable k l m n : ℕ private witness-prop : ∀ j → isProp (j + m ≡ n) witness-prop {m} {n} j = isSetℕ (j + m) n m≤n-isProp : isProp (m ≤ n) m≤n-isProp {m} {n} (k , p) (l , q) = Σ≡Prop witness-prop lemma where lemma : k ≡ l lemma = inj-+m (p ∙ (sym q)) zero-≤ : 0 ≤ n zero-≤ {n} = n , +-zero n suc-≤-suc : m ≤ n → suc m ≤ suc n suc-≤-suc (k , p) = k , (+-suc k _) ∙ (cong suc p) ≤-+k : m ≤ n → m + k ≤ n + k ≤-+k {m} {k = k} (i , p) = i , +-assoc i m k ∙ cong (_+ k) p ≤-k+ : m ≤ n → k + m ≤ k + n ≤-k+ {m} {n} {k} = subst (_≤ k + n) (+-comm m k) ∘ subst (m + k ≤_) (+-comm n k) ∘ ≤-+k pred-≤-pred : suc m ≤ suc n → m ≤ n pred-≤-pred (k , p) = k , injSuc ((sym (+-suc k _)) ∙ p) ≤-refl : m ≤ m ≤-refl = 0 , refl ≤-suc : m ≤ n → m ≤ suc n ≤-suc (k , p) = suc k , cong suc p ≤-predℕ : predℕ n ≤ n ≤-predℕ {zero} = ≤-refl ≤-predℕ {suc n} = ≤-suc ≤-refl ≤-trans : k ≤ m → m ≤ n → k ≤ n ≤-trans {k} {m} {n} (i , p) (j , q) = i + j , l2 ∙ (l1 ∙ q) where l1 : j + i + k ≡ j + m l1 = (sym (+-assoc j i k)) ∙ (cong (j +_) p) l2 : i + j + k ≡ j + i + k l2 = cong (_+ k) (+-comm i j) ≤-antisym : m ≤ n → n ≤ m → m ≡ n ≤-antisym {m} (i , p) (j , q) = (cong (_+ m) l3) ∙ p where l1 : j + i + m ≡ m l1 = (sym (+-assoc j i m)) ∙ ((cong (j +_) p) ∙ q) l2 : j + i ≡ 0 l2 = m+n≡n→m≡0 l1 l3 : 0 ≡ i l3 = sym (snd (m+n≡0→m≡0×n≡0 l2)) ≤-k+-cancel : k + m ≤ k + n → m ≤ n ≤-k+-cancel {k} {m} (l , p) = l , inj-m+ (sub k m ∙ p) where sub : ∀ k m → k + (l + m) ≡ l + (k + m) sub k m = +-assoc k l m ∙ cong (_+ m) (+-comm k l) ∙ sym (+-assoc l k m) ≤-+k-cancel : m + k ≤ n + k → m ≤ n ≤-+k-cancel {m} {k} {n} (l , p) = l , cancelled where cancelled : l + m ≡ n cancelled = inj-+m (sym (+-assoc l m k) ∙ p) ≤-·k : m ≤ n → m · k ≤ n · k ≤-·k {m} {n} {k} (d , r) = d · k , reason where reason : d · k + m · k ≡ n · k reason = d · k + m · k ≡⟨ ·-distribʳ d m k ⟩ (d + m) · k ≡⟨ cong (_· k) r ⟩ n · k ∎ <-k+-cancel : k + m < k + n → m < n <-k+-cancel {k} {m} {n} = ≤-k+-cancel ∘ subst (_≤ k + n) (sym (+-suc k m)) ¬-<-zero : ¬ m < 0 ¬-<-zero (k , p) = snotz ((sym (+-suc k _)) ∙ p) ¬m<m : ¬ m < m ¬m<m {m} = ¬-<-zero ∘ ≤-+k-cancel {k = m} ≤0→≡0 : n ≤ 0 → n ≡ 0 ≤0→≡0 {zero} ineq = refl ≤0→≡0 {suc n} ineq = ⊥.rec (¬-<-zero ineq) predℕ-≤-predℕ : m ≤ n → (predℕ m) ≤ (predℕ n) predℕ-≤-predℕ {zero} {zero} ineq = ≤-refl predℕ-≤-predℕ {zero} {suc n} ineq = zero-≤ predℕ-≤-predℕ {suc m} {zero} ineq = ⊥.rec (¬-<-zero ineq) predℕ-≤-predℕ {suc m} {suc n} ineq = pred-≤-pred ineq ¬m+n<m : ¬ m + n < m ¬m+n<m {m} {n} = ¬-<-zero ∘ <-k+-cancel ∘ subst (m + n <_) (sym (+-zero m)) <-weaken : m < n → m ≤ n <-weaken (k , p) = suc k , sym (+-suc k _) ∙ p ≤<-trans : l ≤ m → m < n → l < n ≤<-trans p = ≤-trans (suc-≤-suc p) <≤-trans : l < m → m ≤ n → l < n <≤-trans = ≤-trans <-trans : l < m → m < n → l < n <-trans p = ≤<-trans (<-weaken p) <-asym : m < n → ¬ n ≤ m <-asym m<n = ¬m<m ∘ <≤-trans m<n <-+k : m < n → m + k < n + k <-+k p = ≤-+k p <-k+ : m < n → k + m < k + n <-k+ {m} {n} {k} p = subst (λ km → km ≤ k + n) (+-suc k m) (≤-k+ p) <-·sk : m < n → m · suc k < n · suc k <-·sk {m} {n} {k} (d , r) = (d · suc k + k) , reason where reason : (d · suc k + k) + suc (m · suc k) ≡ n · suc k reason = (d · suc k + k) + suc (m · suc k) ≡⟨ sym (+-assoc (d · suc k) k _) ⟩ d · suc k + (k + suc (m · suc k)) ≡[ i ]⟨ d · suc k + +-suc k (m · suc k) i ⟩ d · suc k + suc m · suc k ≡⟨ ·-distribʳ d (suc m) (suc k) ⟩ (d + suc m) · suc k ≡⟨ cong (_· suc k) r ⟩ n · suc k ∎ ≤-∸-+-cancel : m ≤ n → (n ∸ m) + m ≡ n ≤-∸-+-cancel {zero} {n} _ = +-zero _ ≤-∸-+-cancel {suc m} {zero} m≤n = ⊥.rec (¬-<-zero m≤n) ≤-∸-+-cancel {suc m} {suc n} m+1≤n+1 = +-suc _ _ ∙ cong suc (≤-∸-+-cancel (pred-≤-pred m+1≤n+1)) left-≤-max : m ≤ max m n left-≤-max {zero} {n} = zero-≤ left-≤-max {suc m} {zero} = ≤-refl left-≤-max {suc m} {suc n} = suc-≤-suc left-≤-max right-≤-max : n ≤ max m n right-≤-max {zero} {m} = zero-≤ right-≤-max {suc n} {zero} = ≤-refl right-≤-max {suc n} {suc m} = suc-≤-suc right-≤-max min-≤-left : min m n ≤ m min-≤-left {zero} {n} = ≤-refl min-≤-left {suc m} {zero} = zero-≤ min-≤-left {suc m} {suc n} = suc-≤-suc min-≤-left min-≤-right : min m n ≤ n min-≤-right {zero} {n} = zero-≤ min-≤-right {suc m} {zero} = ≤-refl min-≤-right {suc m} {suc n} = suc-≤-suc min-≤-right Trichotomy-suc : Trichotomy m n → Trichotomy (suc m) (suc n) Trichotomy-suc (lt m<n) = lt (suc-≤-suc m<n) Trichotomy-suc (eq m=n) = eq (cong suc m=n) Trichotomy-suc (gt n<m) = gt (suc-≤-suc n<m) _≟_ : ∀ m n → Trichotomy m n zero ≟ zero = eq refl zero ≟ suc n = lt (n , +-comm n 1) suc m ≟ zero = gt (m , +-comm m 1) suc m ≟ suc n = Trichotomy-suc (m ≟ n) <-split : m < suc n → (m < n) ⊎ (m ≡ n) <-split {n = zero} = inr ∘ snd ∘ m+n≡0→m≡0×n≡0 ∘ snd ∘ pred-≤-pred <-split {zero} {suc n} = λ _ → inl (suc-≤-suc zero-≤) <-split {suc m} {suc n} = ⊎.map suc-≤-suc (cong suc) ∘ <-split ∘ pred-≤-pred private acc-suc : Acc _<_ n → Acc _<_ (suc n) acc-suc a = acc λ y y<sn → case <-split y<sn of λ { (inl y<n) → access a y y<n ; (inr y≡n) → subst _ (sym y≡n) a } <-wellfounded : WellFounded _<_ <-wellfounded zero = acc λ _ → ⊥.rec ∘ ¬-<-zero <-wellfounded (suc n) = acc-suc (<-wellfounded n) <→≢ : n < m → ¬ n ≡ m <→≢ {n} {m} p q = ¬m<m (subst (_< m) q p) module _ (b₀ : ℕ) (P : ℕ → Type₀) (base : ∀ n → n < suc b₀ → P n) (step : ∀ n → P n → P (suc b₀ + n)) where open WFI (<-wellfounded) private dichotomy : ∀ b n → (n < b) ⊎ (Σ[ m ∈ ℕ ] n ≡ b + m) dichotomy b n = case n ≟ b return (λ _ → (n < b) ⊎ (Σ[ m ∈ ℕ ] n ≡ b + m)) of λ { (lt o) → inl o ; (eq p) → inr (0 , p ∙ sym (+-zero b)) ; (gt (m , p)) → inr (suc m , sym p ∙ +-suc m b ∙ +-comm (suc m) b) } dichotomy<≡ : ∀ b n → (n<b : n < b) → dichotomy b n ≡ inl n<b dichotomy<≡ b n n<b = case dichotomy b n return (λ d → d ≡ inl n<b) of λ { (inl x) → cong inl (m≤n-isProp x n<b) ; (inr (m , p)) → ⊥.rec (<-asym n<b (m , sym (p ∙ +-comm b m))) } dichotomy+≡ : ∀ b m n → (p : n ≡ b + m) → dichotomy b n ≡ inr (m , p) dichotomy+≡ b m n p = case dichotomy b n return (λ d → d ≡ inr (m , p)) of λ { (inl n<b) → ⊥.rec (<-asym n<b (m , +-comm m b ∙ sym p)) ; (inr (m' , q)) → cong inr (Σ≡Prop (λ x → isSetℕ n (b + x)) (inj-m+ {m = b} (sym q ∙ p))) } b = suc b₀ lemma₁ : ∀{x y z} → x ≡ suc z + y → y < x lemma₁ {y = y} {z} p = z , +-suc z y ∙ sym p subStep : (n : ℕ) → (∀ m → m < n → P m) → (n < b) ⊎ (Σ[ m ∈ ℕ ] n ≡ b + m) → P n subStep n _ (inl l) = base n l subStep n rec (inr (m , p)) = transport (cong P (sym p)) (step m (rec m (lemma₁ p))) wfStep : (n : ℕ) → (∀ m → m < n → P m) → P n wfStep n rec = subStep n rec (dichotomy b n) wfStepLemma₀ : ∀ n (n<b : n < b) rec → wfStep n rec ≡ base n n<b wfStepLemma₀ n n<b rec = cong (subStep n rec) (dichotomy<≡ b n n<b) wfStepLemma₁ : ∀ n rec → wfStep (b + n) rec ≡ step n (rec n (lemma₁ refl)) wfStepLemma₁ n rec = cong (subStep (b + n) rec) (dichotomy+≡ b n (b + n) refl) ∙ transportRefl _ +induction : ∀ n → P n +induction = induction wfStep +inductionBase : ∀ n → (l : n < b) → +induction n ≡ base n l +inductionBase n l = induction-compute wfStep n ∙ wfStepLemma₀ n l _ +inductionStep : ∀ n → +induction (b + n) ≡ step n (+induction n) +inductionStep n = induction-compute wfStep (b + n) ∙ wfStepLemma₁ n _ module <-Reasoning where -- TODO: would it be better to mirror the way it is done in the agda-stdlib? infixr 2 _<⟨_⟩_ _≤<⟨_⟩_ _≤⟨_⟩_ _<≤⟨_⟩_ _≡<⟨_⟩_ _≡≤⟨_⟩_ _<≡⟨_⟩_ _≤≡⟨_⟩_ _<⟨_⟩_ : ∀ k → k < n → n < m → k < m _ <⟨ p ⟩ q = <-trans p q _≤<⟨_⟩_ : ∀ k → k ≤ n → n < m → k < m _ ≤<⟨ p ⟩ q = ≤<-trans p q _≤⟨_⟩_ : ∀ k → k ≤ n → n ≤ m → k ≤ m _ ≤⟨ p ⟩ q = ≤-trans p q _<≤⟨_⟩_ : ∀ k → k < n → n ≤ m → k < m _ <≤⟨ p ⟩ q = <≤-trans p q _≡≤⟨_⟩_ : ∀ k → k ≡ l → l ≤ m → k ≤ m _ ≡≤⟨ p ⟩ q = subst (λ k → k ≤ _) (sym p) q _≡<⟨_⟩_ : ∀ k → k ≡ l → l < m → k < m _ ≡<⟨ p ⟩ q = _ ≡≤⟨ cong suc p ⟩ q _≤≡⟨_⟩_ : ∀ k → k ≤ l → l ≡ m → k ≤ m _ ≤≡⟨ p ⟩ q = subst (λ l → _ ≤ l) q p _<≡⟨_⟩_ : ∀ k → k < l → l ≡ m → k < m _ <≡⟨ p ⟩ q = _ ≤≡⟨ p ⟩ q
{ "alphanum_fraction": 0.4672239331, "avg_line_length": 29.2347266881, "ext": "agda", "hexsha": "e3444d8048660972f01aba1c7f931658a6e4c928", "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": "60226aacd7b386aef95d43a0c29c4eec996348a8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/cubical", "max_forks_repo_path": "Cubical/Data/Nat/Order.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8", "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": "L-TChen/cubical", "max_issues_repo_path": "Cubical/Data/Nat/Order.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/cubical", "max_stars_repo_path": "Cubical/Data/Nat/Order.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4521, "size": 9092 }
module O where open import Data.Product open import Function renaming (_∘_ to _○_) open import Circle ------------------------------------------------------------------------------ -- Abstract interpretation: -- natural numbers with paths equating all even numbers in one -- connected component and all odd numbers in another connected -- component -- module with 0,1,2,3,4 ... this is the concrete domain data N : Set where Zero : N One : N Two : N Three : N Four : N recN : (C : Set) → C → C → C → C → C → N → C recN C c0 c1 c2 c3 c4 Zero = c0 recN C c0 c1 c2 c3 c4 One = c1 recN C c0 c1 c2 c3 c4 Two = c2 recN C c0 c1 c2 c3 c4 Three = c3 recN C c0 c1 c2 c3 c4 Four = c4 -- module for the abstract domain {even, odd} except that we don't define it -- this way: we simply add paths between the even elements and paths between -- the odd elements module Parity where private data N* : Set where Zero* : N* One* : N* Two* : N* Three* : N* Four* : N* NA : Set NA = N* zero : NA zero = Zero* one : NA one = One* two : NA two = Two* three : NA three = Three* four : NA four = Four* postulate even02 : Zero* ≡ Two* even04 : Zero* ≡ Four* odd13 : One* ≡ Three* recNA : (C : Set) → (c0 c1 c2 c3 c4 : C) → (ceven02 : c0 ≡ c2) → (ceven04 : c0 ≡ c4) → (codd13 : c1 ≡ c3) → NA → C recNA C c0 c1 c2 c3 c4 _ _ _ Zero* = c0 recNA C c0 c1 c2 c3 c4 _ _ _ One* = c1 recNA C c0 c1 c2 c3 c4 _ _ _ Two* = c2 recNA C c0 c1 c2 c3 c4 _ _ _ Three* = c3 recNA C c0 c1 c2 c3 c4 _ _ _ Four* = c4 open Parity -- Now we define functions back and forth abs : N → NA abs = recN NA zero one two three four con : NA → N con = recNA N Two Three Two Three Two (refl Two) (refl Two) (refl Three) -- Computations on N and NA can be related -- Concrete computation incN : N → N incN Zero = One incN One = Two incN Two = Three incN Three = Four incN Four = Zero -- we can apply an operation in the abstract domain and report the -- approximate result absF : (N → N) → (NA → NA) absF f = abs ○ f ○ con approx : (N → N) → (N → N) approx f n = con ((absF f) (abs n)) test0 : approx incN Zero ≡ Three test0 = refl Three test1 : approx incN One ≡ Two test1 = refl Two test2 : approx incN Two ≡ Three test2 = refl Three test3 : approx incN Three ≡ Two test3 = refl Two test4 : approx incN Four ≡ Three test4 = refl Three ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5505873437, "avg_line_length": 21.631147541, "ext": "agda", "hexsha": "a85c30fa9a2712cb42e5dd80c8d6c3c58928b07e", "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": "OBT/O.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": "OBT/O.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": "OBT/O.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": 881, "size": 2639 }
{-# OPTIONS --prop #-} {-# TERMINATING #-} makeloop : {P : Prop} → P → P makeloop p = makeloop p postulate A : Set B C : A → Prop record AB : Set where no-eta-equality -- the problem goes away if this is left out constructor _,_ field a : A b : B a open AB public -- -- Same problem if replacing the no-eta record by a datatype -- data AB : Set where -- _,_ : (a : A) → B a → AB -- a : AB → A -- a (x , y) = x -- b : (z : AB) → B (a z) -- b (x , y) = y record ABC : Set where constructor _,_ field ab : AB c : C (a ab) -- the problem goes away if this field is left out open ABC public f : AB → ABC f ab = (a ab , makeloop (b ab)) , {!!} postulate P : ABC → Prop g : (ab : AB) → P (f ab) works : (ab : AB) → P (f ab) works ab = g ab loops : (ab : AB) → P (f ab) loops ab = g _ -- WAS: Agda loops while typechecking @loops@ -- SHOULD: succeed (with unsolved metas)
{ "alphanum_fraction": 0.5612691466, "avg_line_length": 17.9215686275, "ext": "agda", "hexsha": "a9c1a3b5aec68878487262818032e08d62bbb3f9", "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/Issue4118.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/Issue4118.agda", "max_line_length": 68, "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/Issue4118.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": 324, "size": 914 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.SuspAdjointLoop open import groups.ToOmega open import cohomology.Theory {- A spectrum (family (Eₙ | n : ℤ) such that ΩEₙ₊₁ = Eₙ) - gives rise to a cohomology theory C with Cⁿ(S⁰) = π₁(Eₙ₊₁). -} module cohomology.SpectrumModel {i} (E : ℤ → Ptd i) (spectrum : (n : ℤ) → ⊙Ω (E (succ n)) ⊙≃ E n) where module SpectrumModel where {- Definition of cohomology group C -} module _ (n : ℤ) (X : Ptd i) where C : Group i C = Trunc-⊙→Ω-group X (E (succ n)) {- convenient abbreviations -} CEl = Group.El C ⊙CEl = Group.⊙El C Cid = Group.ident C {- before truncation -} uCEl = X ⊙→ ⊙Ω (E (succ n)) {- Cⁿ(X) is an abelian group -} C-is-abelian : (n : ℤ) (X : Ptd i) → is-abelian (C n X) C-is-abelian n X = iso-preserves-abelian (Trunc-⊙→Ω-group-emap-codom X (spectrum (succ n))) $ Trunc-group-abelian (⊙→Ω-group-structure _ _) $ λ {(f , fpt) (g , gpt) → ⊙λ=' (λ x → Ω^2-∙-comm (f x) (g x)) (pt-lemma fpt gpt)} where pt-lemma : ∀ {i} {A : Type i} {x : A} {p q : idp {a = x} == idp {a = x}} (α : p == idp) (β : q == idp) → ⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt α β) idp == ⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt β α) idp [ _== idp ↓ Ω^2-∙-comm p q ] pt-lemma idp idp = idp {- C-fmap, the functorial action of C: - contravariant functor from pointed spaces to abelian groups -} module _ (n : ℤ) {X Y : Ptd i} where C-fmap : X ⊙→ Y → (C n Y →ᴳ C n X) C-fmap f = Trunc-⊙→Ω-group-fmap-dom f (E (succ n)) CEl-fmap : X ⊙→ Y → CEl n Y → CEl n X CEl-fmap F = GroupHom.f (C-fmap F) ⊙CEl-fmap : X ⊙→ Y → ⊙CEl n Y ⊙→ ⊙CEl n X ⊙CEl-fmap F = GroupHom.⊙f (C-fmap F) {- C-fmap is a functor from pointed spaces to abelian groups -} module _ (n : ℤ) {X : Ptd i} where C-fmap-idf : ∀ x → CEl-fmap n {X} {X} (⊙idf X) x == x C-fmap-idf x = ap (λ h → GroupHom.f h x) (Trunc-⊙→Ω-group-fmap-dom-idf (E (succ n))) C-fmap-∘ : {Y Z : Ptd i} (g : Y ⊙→ Z) (f : X ⊙→ Y) → ∀ x → CEl-fmap n (g ⊙∘ f) x == CEl-fmap n f (CEl-fmap n g x) C-fmap-∘ g f x = ap (λ h → GroupHom.f h x) (Trunc-⊙→Ω-group-fmap-dom-∘ g f (E (succ n))) -- Eilenberg-Steenrod Axioms {- Susp Axiom -} private C-Susp' : {E₁ E₀ : Ptd i} (iso : ⊙Ω E₁ ⊙≃ E₀) (X : Ptd i) → Trunc-⊙→Ω-group (⊙Susp X) E₁ ≃ᴳ Trunc-⊙→Ω-group X E₀ C-Susp' {E₁ = E₁} iso X = Trunc-⊙→Ω-group-emap-codom X iso ∘eᴳ Trunc-⊙→Ω-iso-Trunc-⊙→Ω X E₁ -- This can be further simplified C-Susp-fmap' : {E₁ E₀ : Ptd i} (iso : ⊙Ω E₁ ⊙≃ E₀) {X Y : Ptd i} (f : X ⊙→ Y) → CommSquareᴳ (Trunc-⊙→Ω-group-fmap-dom (⊙Susp-fmap f) E₁) (Trunc-⊙→Ω-group-fmap-dom f E₀) (fst (C-Susp' iso Y)) (fst (C-Susp' iso X)) C-Susp-fmap' {E₁} {E₀} iso {X} {Y} f = comm-sqrᴳ λ x → GroupHom.f (Trunc-⊙→Ω-group-fmap-codom X (fst iso)) (GroupIso.f (Trunc-⊙→Ω-iso-Trunc-⊙→Ω X E₁) (GroupHom.f (Trunc-⊙→Ω-group-fmap-dom (⊙Susp-fmap f) E₁) x)) =⟨ Trunc-⊙→Ω-iso-Trunc-⊙→Ω-nat-dom f E₁ |in-ctx (λ h → GroupHom.f h x) |in-ctx GroupHom.f (Trunc-⊙→Ω-group-fmap-codom X (fst iso)) ⟩ GroupHom.f (Trunc-⊙→Ω-group-fmap-codom X (fst iso)) (GroupHom.f (Trunc-⊙→Ω-group-fmap-dom f (⊙Ω E₁)) (GroupIso.f (Trunc-⊙→Ω-iso-Trunc-⊙→Ω Y E₁) x)) =⟨ ! $ Trunc-⊙→Ω-group-fmap-nat f (fst iso) |in-ctx GroupHom.f |in-ctx (λ h → h (GroupIso.f (Trunc-⊙→Ω-iso-Trunc-⊙→Ω Y E₁) x)) ⟩ GroupHom.f (Trunc-⊙→Ω-group-fmap-dom f E₀) (GroupHom.f (Trunc-⊙→Ω-group-fmap-codom Y (fst iso)) (GroupIso.f (Trunc-⊙→Ω-iso-Trunc-⊙→Ω Y E₁) x)) =∎ C-Susp : (n : ℤ) (X : Ptd i) → C (succ n) (⊙Susp X) ≃ᴳ C n X C-Susp n X = C-Susp' (spectrum (succ n)) X C-Susp-fmap : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) → CommSquareᴳ (C-fmap (succ n) (⊙Susp-fmap f)) (C-fmap n f) (fst (C-Susp n Y)) (fst (C-Susp n X)) C-Susp-fmap n f = C-Susp-fmap' (spectrum (succ n)) f {- Non-truncated Exactness Axiom -} module _ (n : ℤ) {X Y : Ptd i} where {- precomposing [⊙cfcod' f] and then [f] gives [0] -} im-sub-ker-lemma : (f : X ⊙→ Y) (g : uCEl n (⊙Cofiber f)) → (g ⊙∘ ⊙cfcod' f) ⊙∘ f == ⊙cst im-sub-ker-lemma (f , fpt) (g , gpt) = ⊙λ=' (λ x → ap g (! (cfglue' f x)) ∙ gpt) (↓-idf=cst-in (ap (g ∘ cfcod) fpt ∙ ap g (ap cfcod (! fpt) ∙ ! (cfglue (pt X))) ∙ gpt =⟨ lemma cfcod g fpt (! (cfglue (pt X))) gpt ⟩ ap g (! (cfglue (pt X))) ∙ gpt =⟨ ! (∙-unit-r _) ⟩ (ap g (! (cfglue (pt X))) ∙ gpt) ∙ idp ∎)) where lemma : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} {a₁ a₂ : A} {b : B} {c : C} (f : A → B) (g : B → C) (p : a₁ == a₂) (q : f a₁ == b) (r : g b == c) → ap (g ∘ f) p ∙ ap g (ap f (! p) ∙ q) ∙ r == ap g q ∙ r lemma f g idp idp idp = idp {- if g ⊙∘ f is constant then g factors as h ⊙∘ ⊙cfcod' f -} ker-sub-im-lemma : (f : X ⊙→ Y) (g : uCEl n Y) → g ⊙∘ f == ⊙cst → Σ (uCEl n (⊙Cofiber f)) (λ h → h ⊙∘ ⊙cfcod' f == g) ker-sub-im-lemma (f , fpt) (h , hpt) p = ((g , ! q ∙ hpt) , pair= idp (! (∙-assoc q (! q) hpt) ∙ ap (_∙ hpt) (!-inv-r q))) where g : Cofiber f → Ω (E (succ n)) g = CofiberRec.f idp h (! ∘ app= (ap fst p)) q : h (pt Y) == g (cfbase' f) q = ap g (snd (⊙cfcod' (f , fpt))) {- Truncated Exactness Axiom -} module _ (n : ℤ) {X Y : Ptd i} where abstract C-im-sub-ker : (f : X ⊙→ Y) → im-propᴳ (C-fmap n (⊙cfcod' f)) ⊆ᴳ ker-propᴳ (C-fmap n f) C-im-sub-ker f = im-sub-ker-in (C-fmap n (⊙cfcod' f)) (C-fmap n f) $ Trunc-elim (ap [_] ∘ im-sub-ker-lemma n f) abstract C-ker-sub-im : (f : X ⊙→ Y) → ker-propᴳ (C-fmap n f) ⊆ᴳ im-propᴳ (C-fmap n (⊙cfcod' f)) C-ker-sub-im f = Trunc-elim {{λ _ → Π-level (λ _ → raise-level _ Trunc-level)}} (λ h tp → Trunc-rec (lemma h) (–> (Trunc=-equiv _ _) tp)) where lemma : (h : uCEl n Y) → h ⊙∘ f == ⊙cst → Trunc -1 (Σ (CEl n (⊙Cofiber f)) (λ tk → fst (⊙CEl-fmap n (⊙cfcod' f)) tk == [ h ])) lemma h p = [ [ fst wit ] , ap [_] (snd wit) ] where wit : Σ (uCEl n (⊙Cofiber f)) (λ k → k ⊙∘ ⊙cfcod' f == h) wit = ker-sub-im-lemma n f h p C-exact : (f : X ⊙→ Y) → is-exact (C-fmap n (⊙cfcod' f)) (C-fmap n f) C-exact f = record {im-sub-ker = C-im-sub-ker f; ker-sub-im = C-ker-sub-im f} {- Additivity Axiom -} module _ (n : ℤ) {A : Type i} (X : A → Ptd i) (ac : has-choice 0 A i) where into : CEl n (⊙BigWedge X) → Trunc 0 (Π A (uCEl n ∘ X)) into = Trunc-rec (λ H → [ (λ a → H ⊙∘ ⊙bwin a) ]) module Out' (K : Π A (uCEl n ∘ X)) = BigWedgeRec idp (fst ∘ K) (! ∘ snd ∘ K) out : Trunc 0 (Π A (uCEl n ∘ X)) → CEl n (⊙BigWedge X) out = Trunc-rec (λ K → [ Out'.f K , idp ]) into-out : ∀ y → into (out y) == y into-out = Trunc-elim (λ K → ap [_] (λ= (λ a → pair= idp $ ap (Out'.f K) (! (bwglue a)) ∙ idp =⟨ ∙-unit-r _ ⟩ ap (Out'.f K) (! (bwglue a)) =⟨ ap-! (Out'.f K) (bwglue a) ⟩ ! (ap (Out'.f K) (bwglue a)) =⟨ ap ! (Out'.glue-β K a) ⟩ ! (! (snd (K a))) =⟨ !-! (snd (K a)) ⟩ snd (K a) ∎))) out-into : ∀ x → out (into x) == x out-into = Trunc-elim {P = λ tH → out (into tH) == tH} (λ {(h , hpt) → ap [_] $ ⊙λ=' (out-into-fst (h , hpt)) (↓-idf=cst-in (! (!-inv-l hpt)))}) where lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a₁ a₂ : A} {b : B} (p : a₁ == a₂) (q : f a₁ == b) → ! q ∙ ap f p == ! (ap f (! p) ∙ q) lemma f idp idp = idp out-into-fst : (H : ⊙BigWedge X ⊙→ ⊙Ω (E (succ n))) → ∀ w → Out'.f (λ a → H ⊙∘ ⊙bwin a) w == fst H w out-into-fst (h , hpt) = BigWedge-elim (! hpt) (λ _ _ → idp) (λ a → ↓-='-in' $ ! hpt ∙ ap h (bwglue a) =⟨ lemma h (bwglue a) hpt ⟩ ! (ap h (! (bwglue a)) ∙ hpt) =⟨ ! (Out'.glue-β (λ a → (h , hpt) ⊙∘ ⊙bwin a) a) ⟩ ap (Out'.f (λ a → (h , hpt) ⊙∘ ⊙bwin a)) (bwglue a) ∎) abstract C-additive-is-equiv : is-equiv (GroupHom.f (Πᴳ-fanout (C-fmap n ∘ ⊙bwin {X = X}))) C-additive-is-equiv = transport is-equiv (λ= $ Trunc-elim (λ _ → idp)) ((ac (uCEl n ∘ X)) ∘ise (is-eq into out into-out out-into)) open SpectrumModel spectrum-cohomology : CohomologyTheory i spectrum-cohomology = record { C = C; C-fmap = C-fmap; C-fmap-idf = C-fmap-idf; C-fmap-∘ = C-fmap-∘; C-is-abelian = C-is-abelian; C-Susp = C-Susp; C-Susp-fmap = C-Susp-fmap; C-exact = C-exact; C-additive-is-equiv = C-additive-is-equiv} spectrum-C-S⁰ : (n : ℤ) → C n (⊙Lift ⊙S⁰) ≃ᴳ πS 0 (E (succ n)) spectrum-C-S⁰ n = Trunc-⊙Bool→Ω-iso-π₁ (E (succ n)) ∘eᴳ Trunc-⊙→Ω-group-emap-dom ⊙lift-equiv (E (succ n))
{ "alphanum_fraction": 0.4769416146, "avg_line_length": 36.6626506024, "ext": "agda", "hexsha": "78f5db8d65c788ee8281d51979d361eab7a03de2", "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": "theorems/cohomology/SpectrumModel.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": "theorems/cohomology/SpectrumModel.agda", "max_line_length": 105, "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": "theorems/cohomology/SpectrumModel.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4185, "size": 9129 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Automatic solvers for equations over naturals ------------------------------------------------------------------------ -- See README.Nat for examples of how to use this solver {-# OPTIONS --without-K --safe #-} module Data.Nat.Solver where import Algebra.Solver.Ring.Simple as Solver import Algebra.Solver.Ring.AlmostCommutativeRing as ACR open import Data.Nat using (_≟_) open import Data.Nat.Properties ------------------------------------------------------------------------ -- A module for automatically solving propositional equivalences -- containing _+_ and _*_ module +-*-Solver = Solver (ACR.fromCommutativeSemiring *-+-commutativeSemiring) _≟_
{ "alphanum_fraction": 0.5480519481, "avg_line_length": 32.0833333333, "ext": "agda", "hexsha": "70d500552a3adf2fa4c2243af3db1e6ae2486f47", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/Solver.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/Nat/Solver.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/Solver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 145, "size": 770 }
module PreludeAll where import PreludeBool public import PreludeNat import PreludeShow open PreludeBool open PreludeNat open PreludeShow
{ "alphanum_fraction": 0.8832116788, "avg_line_length": 17.125, "ext": "agda", "hexsha": "16c3cdd7b1d5a35abf0cbc7f30d16e87514d528c", "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/outdated-and-incorrect/Alonzo/PreludeAll.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/Alonzo/PreludeAll.agda", "max_line_length": 25, "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/Alonzo/PreludeAll.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": 29, "size": 137 }
open import Agda.Builtin.Equality postulate X : Set rigid0 : ((@0 x : X) → X) → X mutual H : ((@ω x : X) → X) → X H f = rigid0 _ testω : (f : (@0 x : X) → X) → H (\ (@ω x) → f x) ≡ rigid0 (\ (@0 x) → f x) testω f = refl
{ "alphanum_fraction": 0.4638297872, "avg_line_length": 18.0769230769, "ext": "agda", "hexsha": "328c46bc595d90356b1d557df36442e17c9bb1e5", "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/Issue4390erasure.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/Issue4390erasure.agda", "max_line_length": 77, "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/Issue4390erasure.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": 107, "size": 235 }
------------------------------------------------------------------------ -- Small prelude ------------------------------------------------------------------------ module Prelude where infixl 6 _+_ infixr 5 _∷_ _++_ infixr 3 _∨_ infix 2 ¬_ ------------------------------------------------------------------------ -- Some "logic" data ⊥ : Set where ¬_ : Set -> Set ¬ a = a -> ⊥ ------------------------------------------------------------------------ -- Maybe and Dec data Maybe (a : Set) : Set where just : a -> Maybe a nothing : Maybe a data Dec (a : Set) : Set where yes : a -> Dec a no : ¬ a -> Dec a ------------------------------------------------------------------------ -- Lists data [_] (a : Set) : Set where [] : [ a ] _∷_ : a -> [ a ] -> [ a ] _++_ : forall {a} -> [ a ] -> [ a ] -> [ a ] [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) ------------------------------------------------------------------------ -- Natural numbers data ℕ : Set where zero : ℕ suc : ℕ -> ℕ _+_ : ℕ -> ℕ -> ℕ zero + n = n suc m + n = suc (m + n) {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-} {-# BUILTIN NATPLUS _+_ #-} ------------------------------------------------------------------------ -- Booleans data Bool : Set where true : Bool false : Bool _∨_ : Bool -> Bool -> Bool true ∨ _ = true false ∨ b = b
{ "alphanum_fraction": 0.3061516452, "avg_line_length": 20.5588235294, "ext": "agda", "hexsha": "852853bb07f57c66a289c7a3f10c0398df7a280b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "examples/AIM6/RegExp/talk/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "examples/AIM6/RegExp/talk/Prelude.agda", "max_line_length": 72, "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/AIM6/RegExp/talk/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 359, "size": 1398 }
-- Functors from one category into another module Control.Category.Functor where open import Level using (suc; _⊔_) open import Relation.Binary.PropositionalEquality open import Control.Category open Category using () renaming (Obj to obj; Hom to hom) -- Operations of a functor. -- Module T-FunctorOps C D F provides notation A ⇒ A' for homset C(A,A') -- and notation B ⇉ B' for homset D(B,B') and the type T-map for the -- functorial action. module T-FunctorOps {co ch ce} (C : Category co ch ce) {δo dh de} (D : Category δo dh de) (F : obj C → obj D) where open HomSet (hom C) using (_⇒_) open HomSet (hom D) using () renaming (_⇒_ to _⇉_) -- Type of the map function. T-map = ∀ {A B} → (A ⇒ B) → F A ⇉ F B -- Record FunctorOps C D F can be instantiated to define the functorial action -- map of F. record FunctorOps {co ch ce} (C : Category co ch ce) {δo dh de} (D : Category δo dh de) (F : obj C → obj D) : Set (co ⊔ ch ⊔ ce ⊔ δo ⊔ dh ⊔ de) where open T-FunctorOps C D F -- The functorial action (map function). field map : T-map -- Laws of a functor. -- Module T-FunctorLaws ops provides notation... module T-FunctorLaws {co ch ce} {C : Category co ch ce} {δo dh de} {D : Category δo dh de} {F : obj C → obj D} (ops : FunctorOps C D F) where open FunctorOps ops public open Category C using (_⇒_) renaming (Obj to ObjC; id to idC; _∘_ to _∘C_) open Category D using (_≈_) renaming (Obj to ObjD; _⇒_ to _⇉_; id to idD; _∘_ to _∘D_) -- First functor law: identity T-map-id = ∀ {A} → map (idC {A = A}) ≈ idD -- Second functor law: composition. T-map-∘ = ∀ {A B C} (f : A ⇒ B) {g : B ⇒ C} → map (g ∘C f) ≈ (map g ∘D map f) record FunctorLaws {co ch ce} {C : Category co ch ce} {δo dh de} {D : Category δo dh de} {F : obj C → obj D} (ops : FunctorOps C D F) : Set ((co ⊔ ch ⊔ ce ⊔ δo ⊔ dh ⊔ de)) where open T-FunctorLaws ops field map-id : T-map-id map-∘ : T-map-∘ -- Functoriality. record IsFunctor {co ch ce} {C : Category co ch ce} {δo dh de} {D : Category δo dh de} (F : obj C → obj D) : Set (co ⊔ ch ⊔ ce ⊔ δo ⊔ dh ⊔ de) where field ops : FunctorOps C D F laws : FunctorLaws ops open FunctorOps ops public open FunctorLaws laws public -- -}
{ "alphanum_fraction": 0.6115451389, "avg_line_length": 24, "ext": "agda", "hexsha": "2ad16cb55709b1ae46808915966facb1d3928b14", "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": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_path": "src/Control/Category/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "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": "andreasabel/cubical", "max_issues_repo_path": "src/Control/Category/Functor.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_path": "src/Control/Category/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 832, "size": 2304 }
{-# OPTIONS --without-K --safe #-} module Dodo.Binary.Trichotomous where -- Stdlib imports import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; _≢_; refl; cong; subst; subst₂) renaming (sym to ≡-sym) open import Level using (Level) open import Function using (flip; _∘_; _∘₂_) open import Data.Empty using (⊥-elim) open import Data.Product using (_,_) open import Relation.Unary using (Pred) open import Relation.Binary using (Rel; Irreflexive; Trichotomous; Tri; tri<; tri≈; tri>) open import Relation.Binary.Construct.Closure.Transitive using ([_]) -- Local imports open import Dodo.Unary.Equality open import Dodo.Binary.Equality open import Dodo.Binary.Immediate open import Dodo.Binary.Filter -- # Definitions tri-immˡ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {R : Rel A ℓ₂} → Trichotomous _≈_ R → {x y z : A} → immediate R x z → immediate R y z --------------------------------- → x ≈ y tri-immˡ triR {x} {y} {z} (Rxz , ¬∃y) (Ryz , ¬∃x) with triR x y ... | tri< Rxy x≢y ¬Ryx = ⊥-elim (¬∃y (y , Rxy , [ Ryz ])) ... | tri≈ ¬Rxy x≡y ¬Ryx = x≡y ... | tri> ¬Rxy x≢y Ryx = ⊥-elim (¬∃x (x , Ryx , [ Rxz ])) tri-immʳ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {R : Rel A ℓ₂} → Trichotomous _≈_ R → {x y z : A} → immediate R x y → immediate R x z --------------------------------- → y ≈ z tri-immʳ triR {x} {y} {z} (Rxy , ¬∃z) (Rxz , ¬∃y) with triR y z ... | tri< Ryz y≢z ¬Rzy = ⊥-elim (¬∃y (y , Rxy , [ Ryz ])) ... | tri≈ ¬Ryz y≡z ¬Rzy = y≡z ... | tri> ¬Ryz y≢z Rzy = ⊥-elim (¬∃z (z , Rxz , [ Rzy ])) tri-irreflexive : {a ℓ₁ ℓ₂ : Level} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Trichotomous _≈_ _<_ -------------------- → Irreflexive _≈_ _<_ tri-irreflexive triR {x} {y} x≈y x<y with triR x y ... | tri< x<y x≉y x≯y = x≉y x≈y ... | tri≈ x≮y x≈y x≯y = x≮y x<y ... | tri> x≮y x≉y x>y = x≉y x≈y tri-flip : ∀ {a ℓ : Level} {A : Set a} {R : Rel A ℓ} → {x y : A} → Tri (R x y) (x ≡ y) (R y x) ------------------------------------- → Tri (flip R x y) (x ≡ y) (flip R y x) tri-flip (tri< Rxy x≢y ¬Ryx) = tri> ¬Ryx x≢y Rxy tri-flip (tri≈ ¬Rxy x≡y ¬Ryx) = tri≈ ¬Ryx x≡y ¬Rxy tri-flip (tri> ¬Rxy x≢y Ryx) = tri< Ryx x≢y ¬Rxy trichotomous-flip : ∀ {a ℓ : Level} {A : Set a} {R : Rel A ℓ} → Trichotomous _≡_ R ------------------------- → Trichotomous _≡_ (flip R) trichotomous-flip {R = R} triR = tri-flip {R = R} ∘₂ triR
{ "alphanum_fraction": 0.5408205553, "avg_line_length": 33.985915493, "ext": "agda", "hexsha": "028ddec51d216bf7d3bee175e1677daf87e37fdc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Binary/Trichotomous.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Binary/Trichotomous.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Binary/Trichotomous.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1062, "size": 2413 }
open import Data.Bool using (Bool; true; false; _∧_; _∨_; T) open import Data.Bool.Properties using (∨-identityˡ; ∨-zeroˡ) open import Data.List using (List; []; _∷_; any; map; foldl) open import Data.List.Relation.Unary.Any using (Any; here; there; lookup; satisfied) open import Data.Product as Prod using (∃; _,_; proj₁; proj₂) open import Data.Unit using (⊤; tt) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; subst; sym; trans; module ≡-Reasoning) open import Relation.Binary.PropositionalEquality as P open ≡-Reasoning using (begin_; _≡⟨⟩_; _≡⟨_⟩_; _∎) open import Data.Nat using (ℕ; zero; suc) ≡→T : ∀ {b : Bool} → b ≡ true → T b ≡→T refl = tt any-val : ∀ {a} {A : Set a} (f) (ns : List A) → any f ns ≡ true → Any (λ x → T (f x)) ns any-val f (n ∷ ns) any-f-⟨n∷ns⟩≡true with f n | P.inspect f n ... | true | P.[ fn≡t ] = here (≡→T fn≡t) ... | false | _ = there (any-val f ns any-f-⟨n∷ns⟩≡true) get-val : ∀ {a} {A : Set a} {f} (ns : List A) → any f ns ≡ true → A get-val {_} {_} {f} ns any≡true = lookup {xs = ns} (any-val f ns any≡true) get-prop : ∀ {a} {A : Set a} {f} (ns : List A) → any f ns ≡ true → ∃ (λ x → T (f x)) get-prop {_} {_} {f} ns any≡true = satisfied {xs = ns} (any-val f ns any≡true) is-not-zero : ℕ → Bool is-not-zero zero = false is-not-zero _ = true eg1 : any is-not-zero (0 ∷ 0 ∷ 3 ∷ []) ≡ true eg1 = refl --proj₁ (get-prop {f = λ x → x} (true ∷ false ∷ []) _) --proj₁ (get-prop {f = is-not-zero} (0 ∷ 0 ∷ 3 ∷ []) refl) --data Singleton {a} {A : Set a} (x : A) : Set a where -- _with≡_ : (y : A) → x ≡ y → Singleton x -- --inspect : ∀ {a} {A : Set a} (x : A) → Singleton x --inspect x = x with≡ refl any-val' : ∀ {a} {A : Set a} (f : A → Bool) (ns : List A) → any f ns ≡ true → (∃ λ x → T (f x)) any-val' f [] () any-val' f (n ∷ ns) anyfnns≡true with f n | P.inspect f n ... | true | P.[ fn≡t ] = n , ≡→T fn≡t ... | false | P.[ fn≡f ] = any-val' f ns anyfnns≡true -- where -- anyfns≡true = -- begin -- any f ns ≡⟨ sym (∨-identityˡ (any f ns)) ⟩ -- false ∨ any f ns ≡⟨ cong (_∨ any f ns) (sym ?) ⟩ -- f n ∨ any f ns ≡⟨ anyfnns≡true ⟩ -- true -- ∎
{ "alphanum_fraction": 0.5318584071, "avg_line_length": 34.7692307692, "ext": "agda", "hexsha": "88c6955c76890f7148024d44cb596fee089caae7", "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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "helq/old_code", "max_forks_repo_path": "proglangs-learning/Agda/general-exercises/lifting-bool-to-property.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "helq/old_code", "max_issues_repo_path": "proglangs-learning/Agda/general-exercises/lifting-bool-to-property.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "helq/old_code", "max_stars_repo_path": "proglangs-learning/Agda/general-exercises/lifting-bool-to-property.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 906, "size": 2260 }
------------------------------------------------------------------------------ -- Well-founded relation on lists based on their length ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.List.WF-Relation.LT-Length where open import FOTC.Base open import FOTC.Data.List open import FOTC.Data.Nat.Inequalities ------------------------------------------------------------------------------ -- Well-founded relation on lists based on their length. LTL : D → D → Set LTL xs ys = length xs < length ys
{ "alphanum_fraction": 0.437150838, "avg_line_length": 35.8, "ext": "agda", "hexsha": "422a148c5218e4b64a08bc1f62537a29e1b042c9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Length.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Length.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Length.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": 122, "size": 716 }
------------------------------------------------------------------------ -- Forcing of parsers (can be used for inspection/debugging purposes) ------------------------------------------------------------------------ {-# OPTIONS --termination-depth=2 #-} module TotalParserCombinators.Force where open import Codata.Musical.Notation import Data.List.Categorical as ListMonad open import Data.Maybe hiding (_>>=_) open import Data.Nat open import Function import Relation.Binary.PropositionalEquality as P open import TotalParserCombinators.Congruence open import TotalParserCombinators.Laws open import TotalParserCombinators.Parser -- force n p returns p, but with the first n layers of delay -- constructors removed. force : ∀ {Tok R xs} → ℕ → Parser Tok R xs → Parser Tok R xs force zero p = p force n (return x) = return x force n fail = fail force n token = token force n (p₁ ∣ p₂) = force n p₁ ∣ force n p₂ force n (f <$> p) = f <$> force n p force n (nonempty p) = nonempty (force n p) force n (cast xs₁≈xs₂ p) = cast xs₁≈xs₂ (force n p) force (suc n) (p₁ ⊛ p₂) with forced? p₁ | forced? p₂ ... | just xs | nothing = force (suc n) p₁ ⊛ force n (♭ p₂) ... | just xs | just fs = force (suc n) p₁ ⊛ force (suc n) p₂ ... | nothing | nothing = force n (♭ p₁) ⊛ force n (♭ p₂) ... | nothing | just fs = P.subst (Parser _ _) (ListMonad.Applicative.right-zero fs) $ force n (♭ p₁) ⊛ force (suc n) p₂ force (suc n) (p₁ >>= p₂) with forced? p₁ | forced?′ p₂ ... | just f | nothing = force (suc n) p₁ >>= λ x → force n (♭ (p₂ x)) ... | just f | just xs = force (suc n) p₁ >>= λ x → force (suc n) (p₂ x) ... | nothing | nothing = force n (♭ p₁) >>= λ x → force n (♭ (p₂ x)) ... | nothing | just xs = P.subst (Parser _ _) (ListMonad.MonadProperties.right-zero xs) $ force n (♭ p₁) >>= λ x → force (suc n) (p₂ x) -- force preserves the semantics of its argument. correct : ∀ {Tok R xs} (n : ℕ) (p : Parser Tok R xs) → force n p ≅P p correct zero p = p ∎ correct (suc n) (return x) = return x ∎ correct (suc n) fail = fail ∎ correct (suc n) token = token ∎ correct (suc n) (p₁ ∣ p₂) = correct (suc n) p₁ ∣ correct (suc n) p₂ correct (suc n) (f <$> p) = (λ _ → P.refl) <$> correct (suc n) p correct (suc n) (nonempty p) = nonempty (correct (suc n) p) correct (suc n) (cast xs₁≈xs₂ p) = cast (correct (suc n) p) correct (suc n) (p₁ ⊛ p₂) with forced? p₁ | forced? p₂ ... | just xs | nothing = [ ○ - ○ - ○ - ◌ ] correct (suc n) p₁ ⊛ correct n (♭ p₂) ... | just xs | just fs = [ ○ - ○ - ○ - ○ ] correct (suc n) p₁ ⊛ correct (suc n) p₂ ... | nothing | nothing = [ ○ - ◌ - ○ - ◌ ] correct n (♭ p₁) ⊛ correct n (♭ p₂) ... | nothing | just fs = P.subst (Parser _ _) lemma forced ≅⟨ Subst.correct lemma ⟩ forced ≅⟨ [ ○ - ◌ - ○ - ○ ] correct n (♭ p₁) ⊛ correct (suc n) p₂ ⟩ p₁ ⊛ p₂ ∎ where lemma = ListMonad.Applicative.right-zero fs forced = force n (♭ p₁) ⊛ force (suc n) p₂ correct (suc n) (p₁ >>= p₂) with forced? p₁ | forced?′ p₂ ... | just f | nothing = [ ○ - ○ - ○ - ◌ ] correct (suc n) p₁ >>= λ x → correct n (♭ (p₂ x)) ... | just f | just xs = [ ○ - ○ - ○ - ○ ] correct (suc n) p₁ >>= λ x → correct (suc n) (p₂ x) ... | nothing | nothing = [ ○ - ◌ - ○ - ◌ ] correct n (♭ p₁) >>= λ x → correct n (♭ (p₂ x)) ... | nothing | just xs = P.subst (Parser _ _) lemma forced ≅⟨ Subst.correct lemma ⟩ forced ≅⟨ [ ○ - ◌ - ○ - ○ ] correct n (♭ p₁) >>= (λ x → correct (suc n) (p₂ x)) ⟩ p₁ >>= p₂ ∎ where forced = force n (♭ p₁) >>= λ x → force (suc n) (p₂ x) lemma = ListMonad.MonadProperties.right-zero xs
{ "alphanum_fraction": 0.5056490083, "avg_line_length": 49.7875, "ext": "agda", "hexsha": "e4afda8aa1e11df94fbe866364ee47c6c20286ce", "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/Force.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/Force.agda", "max_line_length": 111, "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/Force.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": 1373, "size": 3983 }
-- Christian Sattler, 2017-08-05 -- Nullary extended lambdas are useful in the interaction mode -- for case splitting on the result inside an expression. module NullaryExtendedLambda where f : {A : Set} → A → A f a = λ { → a } g : {A : Set} → A → A g a = λ where → a
{ "alphanum_fraction": 0.6605166052, "avg_line_length": 22.5833333333, "ext": "agda", "hexsha": "ef112434b8f4a4fe5bd44754a4d35dd01f406eda", "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/NullaryExtendedLambda.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/NullaryExtendedLambda.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/NullaryExtendedLambda.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": 87, "size": 271 }
module binio where open import Data.Word8 import Data.ByteString as BS import Data.ByteString.IO as BSIO open import Data.Fin using (Fin; toℕ) open import Data.Vec using (Vec; toList; tabulate) open import Data.List using (List) open import Data.Colist using (Colist; fromList) open import Agda.Builtin.Nat using (Nat; zero; suc; _<_) open import IO open import Coinduction using (♯_) {- instance finN<N : {n : Nat} {f : Fin n} → IsTrue (toℕ f < n) finN<N {.(suc _)} {Fin.zero} = itis finN<N {.(suc _)} {Fin.suc f} = finN<N {_} {f} fin256 : Fin 256 → Word8 fin256 f = fromNat (toℕ f) {{finN<N {256} {f}}} b256 : Colist Word8 b256 = fromList (toList (tabulate {256} fin256)) -} fin256 : Fin 256 → Word8 fin256 f = primWord8fromNat (toℕ f) b256 : List Word8 b256 = toList (tabulate {256} fin256) b256′ : Colist Word8 b256′ = fromList b256 -- main = run (writeBinaryFile "256.bin" b256) -- main = run (♯ readBinaryFile "256.bin" >>= λ x → ♯ writeBinaryFile "256'.bin" x) -- main = run (readFile "256.bin") main = run (BSIO.writeBinaryFile′ "256.bin" b256) -- main = run (BS.IO.writeBinaryFile′ "256'.bin" b256′) -- main = run (BS.IO.writeBinaryFile′ "256.bin" b256 >> BS.IO.writeBinaryFile′ "256'.bin" b256′)
{ "alphanum_fraction": 0.6753883892, "avg_line_length": 27.1777777778, "ext": "agda", "hexsha": "c8ef428de838b3c7ec83a66c9cb5412f641e0b50", "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": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/bytes-agda", "max_forks_repo_path": "app/binio.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "semenov-vladyslav/bytes-agda", "max_issues_repo_path": "app/binio.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/bytes-agda", "max_stars_repo_path": "app/binio.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 431, "size": 1223 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Comma where open import Data.Product using (_×_; ∃; _,_; proj₁; proj₂; zip; map) open import Level open import Relation.Binary using (Rel) open import Categories.Category.Instance.One open import Categories.Category using (Category; _[_,_]; _[_∘_]) open import Categories.Functor using (Functor) open import Categories.Functor.Construction.Constant using (const!) import Categories.Morphism.Reasoning as MR private variable o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃ : Level -- things go odd with generalized variables for A B C, use anonymous module instead module _ {A : Category o₁ ℓ₁ e₁} {B : Category o₂ ℓ₂ e₂} {C : Category o₃ ℓ₃ e₃} where private module C = Category C module A = Category A module B = Category B record CommaObj (T : Functor A C) (S : Functor B C) : Set (o₁ ⊔ o₂ ⊔ ℓ₃) where open Category open Functor T renaming (F₀ to T₀) open Functor S renaming (F₀ to S₀) field {α} : Obj A {β} : Obj B f : C [ T₀ α , S₀ β ] record Comma⇒ {T : Functor A C} {S : Functor B C} (X₁ X₂ : CommaObj T S) : Set (ℓ₁ ⊔ ℓ₂ ⊔ e₃) where open CommaObj X₁ renaming (α to α₁; β to β₁; f to f₁) open CommaObj X₂ renaming (α to α₂; β to β₂; f to f₂) open Functor T renaming (F₁ to T₁) open Functor S renaming (F₁ to S₁) field g : A [ α₁ , α₂ ] h : B [ β₁ , β₂ ] commute : C.CommutativeSquare f₁ (T₁ g) (S₁ h) f₂ Comma : Functor A C → Functor B C → Category _ _ _ Comma T S = record { Obj = CommaObj T S ; _⇒_ = Comma⇒ ; _≈_ = λ a₁ a₂ → g a₁ A.≈ g a₂ × h a₁ B.≈ h a₂ ; _∘_ = _∘′_ ; id = record { g = A.id ; h = B.id ; commute = id-comm } ; assoc = A.assoc , B.assoc ; sym-assoc = A.sym-assoc , B.sym-assoc ; identityˡ = A.identityˡ , B.identityˡ ; identityʳ = A.identityʳ , B.identityʳ ; identity² = A.identity² , B.identity² ; equiv = record { refl = A.Equiv.refl , B.Equiv.refl ; sym = map A.Equiv.sym B.Equiv.sym ; trans = zip A.Equiv.trans B.Equiv.trans } ; ∘-resp-≈ = zip A.∘-resp-≈ B.∘-resp-≈ } module Comma where module T = Functor T module S = Functor S open T using () renaming (F₀ to T₀; F₁ to T₁) open S using () renaming (F₀ to S₀; F₁ to S₁) open Comma⇒ id-comm : {E : CommaObj T S} → let open CommaObj E in (S₁ B.id C.∘ f) C.≈ f C.∘ T₁ A.id id-comm {E} = begin (S₁ B.id C.∘ f) ≈⟨ S.identity ⟩∘⟨refl ⟩ C.id C.∘ f ≈⟨ id-comm-sym ⟩ f C.∘ C.id ≈˘⟨ refl⟩∘⟨ T.identity ⟩ f C.∘ T₁ A.id ∎ where open C.HomReasoning open CommaObj E open MR C _∘′_ : ∀ {X₁ X₂ X₃} → Comma⇒ X₂ X₃ → Comma⇒ X₁ X₂ → Comma⇒ X₁ X₃ _∘′_ {X₁} {X₂} {X₃} a₁ a₂ = record { g = A [ g₁ ∘ g₂ ] ; h = B [ h₁ ∘ h₂ ] ; commute = begin S₁ (h₁ B.∘ h₂) C.∘ f₁ ≈⟨ S.homomorphism ⟩∘⟨refl ○ C.assoc ⟩ S₁ h₁ C.∘ (S₁ h₂ C.∘ f₁) ≈⟨ refl⟩∘⟨ commutes₂ ⟩ S₁ h₁ C.∘ (f₂ C.∘ T₁ g₂) ≈˘⟨ C.assoc ⟩ (S₁ h₁ C.∘ f₂) C.∘ T₁ g₂ ≈⟨ commutes₁ ⟩∘⟨refl ⟩ (f₃ C.∘ T₁ g₁) C.∘ T₁ g₂ ≈⟨ C.assoc ○ refl⟩∘⟨ ⟺ T.homomorphism ⟩ f₃ C.∘ T₁ (g₁ A.∘ g₂) ∎ } where open C.HomReasoning open Comma⇒ a₁ renaming (g to g₁; h to h₁; commute to commutes₁) open Comma⇒ a₂ renaming (g to g₂; h to h₂; commute to commutes₂) open CommaObj X₁ renaming (α to α₁; β to β₁; f to f₁) open CommaObj X₂ renaming (α to α₂; β to β₂; f to f₂) open CommaObj X₃ renaming (α to α₃; β to β₃; f to f₃) infix 4 _↓_ _↓_ : (S : Functor A C) (T : Functor B C) → Category _ _ _ S ↓ T = Comma S T Dom : (T : Functor A C) → (S : Functor B C) → Functor (Comma T S) A Dom T S = record { F₀ = CommaObj.α ; F₁ = Comma⇒.g ; identity = refl ; homomorphism = refl ; F-resp-≈ = proj₁ } where open Comma T S open A.Equiv Cod : (T : Functor A C) → (S : Functor B C) → Functor (Comma T S) B Cod T S = record { F₀ = CommaObj.β ; F₁ = Comma⇒.h ; identity = refl ; homomorphism = refl ; F-resp-≈ = proj₂ } where open Comma T S open B.Equiv module _ {C : Category o₁ ℓ₁ e₁} {D : Category o₂ ℓ₂ e₂} where private module C = Category C infix 4 _↙_ _↘_ _↙_ : (X : C.Obj) (T : Functor D C) → Category _ _ _ X ↙ T = const! X ↓ T _↘_ : (S : Functor D C) (X : C.Obj) → Category _ _ _ S ↘ X = S ↓ const! X
{ "alphanum_fraction": 0.5450010844, "avg_line_length": 32.7021276596, "ext": "agda", "hexsha": "30069030edb3e4e23261c838f804afadc7666242", "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": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Category/Construction/Comma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "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": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Category/Construction/Comma.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Category/Construction/Comma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1874, "size": 4611 }
module Lib.Maybe where data Maybe (A : Set) : Set where nothing : Maybe A just : A -> Maybe A {-# COMPILED_DATA Maybe Maybe Nothing Just #-}
{ "alphanum_fraction": 0.6447368421, "avg_line_length": 15.2, "ext": "agda", "hexsha": "1a4fb508e80332c3195be2b67d53abf31ca3c48c", "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/simple-lib/Lib/Maybe.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/Maybe.agda", "max_line_length": 46, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "examples/simple-lib/Lib/Maybe.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": 42, "size": 152 }
-- A memoised implementation of the Fibonacci sequence, following -- Hinze's "Memo functions, polytypically!". module Issue2918 where open import Agda.Builtin.IO open import Agda.Builtin.Nat renaming (Nat to ℕ) open import Agda.Builtin.Size open import Agda.Builtin.Unit record _×_ (A B : Set) : Set where constructor _,_ field proj₁ : A proj₂ : B open _×_ public mutual data Nat (i : Size) : Set where zero : Nat i suc : Nat′ i → Nat i data Nat′ (i : Size) : Set where [_] : {j : Size< i} → Nat j → Nat′ i mutual ℕ→Nat : ℕ → Nat ∞ ℕ→Nat zero = zero ℕ→Nat (suc n) = suc (ℕ→Nat′ n) ℕ→Nat′ : ℕ → Nat′ ∞ ℕ→Nat′ n = [ ℕ→Nat n ] mutual Nat′[_]→ : Size → Set → Set Nat′[ i ]→ A = A × Nat′[ i ]→′ A record Nat′[_]→′ (i : Size) (A : Set) : Set where coinductive field force : {j : Size< i} → Nat′[ j ]→ A open Nat′[_]→′ public tabulate : ∀ {i} {A : Set} → (Nat′ i → A) → Nat′[ i ]→′ A force (tabulate f) = f [ zero ] , tabulate (λ n → f [ suc n ]) lookup : ∀ {i} {A : Set} → Nat′[ i ]→′ A → Nat′ i → A lookup t [ zero ] = proj₁ (force t) lookup t [ suc n ] = lookup (proj₂ (force t)) n memo-fix : {A : Set} → (∀ {i} → (Nat′ i → A) → (Nat i → A)) → ∀ {i} → Nat′ i → A memo-fix f = wrapper λ { [ n ] → f (lookup (tabulate (memo-fix f))) n } where wrapper : ∀ {i} {A : Set} → (Nat′ i → A) → (Nat′ i → A) wrapper f [ n ] = f [ n ] fib-step : ∀ {i} → (Nat′ i → ℕ) → (Nat i → ℕ) fib-step fib zero = 0 fib-step fib (suc [ zero ]) = 1 fib-step fib (suc [ suc n ]) = fib n + fib [ suc n ] fib : ℕ → ℕ fib n = memo-fix fib-step [ ℕ→Nat n ] postulate crash-after-ten-seconds : ℕ → IO ⊤ {-# FOREIGN GHC import qualified Control.Exception import qualified System.Timeout crashAfterTenSeconds c = do r <- System.Timeout.timeout (10 * 10^6) (Control.Exception.evaluate c) case r of Nothing -> error "The computation timed out" Just _ -> return () #-} {-# COMPILE GHC crash-after-ten-seconds = crashAfterTenSeconds #-} main : IO ⊤ main = crash-after-ten-seconds (fib 300)
{ "alphanum_fraction": 0.5555555556, "avg_line_length": 22.8387096774, "ext": "agda", "hexsha": "a01f8262bef18a8364c9200e12475c734d1f74d5", "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/Compiler/simple/Issue2918.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/Compiler/simple/Issue2918.agda", "max_line_length": 66, "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/Compiler/simple/Issue2918.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": 761, "size": 2124 }
{-# OPTIONS --cubical #-} module leibniz where open import Cubical.Data.Equality open import Cubical.Foundations.Function using (_∘_) module Martin-Löf {ℓ} {A : Set ℓ} where reflexive≡ : {a : A} → a ≡p a reflexive≡ = reflp symmetric≡ : {a b : A} → a ≡p b → b ≡p a symmetric≡ reflp = reflp transitive≡ : {a b c : A} → a ≡p b → b ≡p c → a ≡p c transitive≡ reflp reflp = reflp open Martin-Löf public ext : ∀ {ℓ ℓ′} {A : Set ℓ} {B : A → Set ℓ′} {f g : (a : A) → B a} → (∀ (a : A) → f a ≡p g a) → f ≡p g ext p = ctop (funExt (ptoc ∘ p)) module Leibniz {A : Set} where _≐_ : (a b : A) → Set₁ a ≐ b = (P : A → Set) → P a → P b reflexive≐ : {a : A} → a ≐ a reflexive≐ P Pa = Pa transitive≐ : {a b c : A} → a ≐ b → b ≐ c → a ≐ c transitive≐ a≐b b≐c P Pa = b≐c P (a≐b P Pa) symmetric≐ : {a b : A} → a ≐ b → b ≐ a symmetric≐ {a} {b} a≐b P = Qb where Q : A → Set Q c = P c → P a Qa : Q a Qa = reflexive≐ P Qb : Q b Qb = a≐b Q Qa open Leibniz T : Set → Set₁ T A = ∀ (X : Set) → (A → X) → X module WarmUp (A : Set) where postulate paramT : (t : T A) → (X X′ : Set) (R : X → X′ → Set) → (k : A → X) (k′ : A → X′) (kR : (a : A) → R (k a) (k′ a)) → R (t X k) (t X′ k′) i : A → T A i a X k = k a id : A → A id a = a j : T A → A j t = t A id ji : (a : A) → (j (i a) ≡p a) ji a = reflp ijₑₓₜ : (t : T A) (X : Set) (k : A → X) → (i (j t) X k ≡p t X k) ijₑₓₜ t X k = paramT t A X R id k (λ a → reflp) where R : A → X → Set R a x = k a ≡p x ij : (t : T A) → (i (j t) ≡p t) ij t = ext (λ X → ext (λ k → ijₑₓₜ t X k)) module MainResult (A : Set) where postulate param≐ : {a b : A} (a≐b : a ≐ b) → (P P′ : A → Set) → (R : (c : A) → P c → P′ c → Set) → (Pa : P a) (P′a : P′ a) → R a Pa P′a → R b (a≐b P Pa) (a≐b P′ P′a) i : {a b : A} (a≡b : a ≡p b) → a ≐ b i reflp P Pa = Pa j : {a b : A} → a ≐ b → a ≡p b j {a} {b} a≐b = Qb where Q : A → Set Q c = a ≡p c Qa : Q a Qa = reflexive≡ Qb : Q b Qb = a≐b Q Qa ji : {a b : A} (a≡b : a ≡p b) → j (i a≡b) ≡p a≡b ji reflp = reflp ijₑₓₜ : {a b : A} (a≐b : a ≐ b) → (P : A → Set) (Pa : P a) → i (j a≐b) P Pa ≡p a≐b P Pa ijₑₓₜ {a} a≐b P Pa = param≐ a≐b Q P R reflp Pa reflp where Q : A → Set Q c = a ≡p c R : (c : A) (Qc : Q c) (Pc : P c) → Set R c Qc Pc = i Qc P Pa ≡p Pc ij : {a b : A} (a≐b : a ≐ b) → i (j a≐b) ≡p a≐b ij a≐b = ext (λ P → ext (ijₑₓₜ a≐b P))
{ "alphanum_fraction": 0.4194540561, "avg_line_length": 22.4224137931, "ext": "agda", "hexsha": "495867af44997eb175065d8474a903d8d1a54477", "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": "e1104012d85d2072318656f6c6d31acff75c9460", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/Equality", "max_forks_repo_path": "leibniz.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e1104012d85d2072318656f6c6d31acff75c9460", "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": "guilhermehas/Equality", "max_issues_repo_path": "leibniz.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e1104012d85d2072318656f6c6d31acff75c9460", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/Equality", "max_stars_repo_path": "leibniz.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-01T06:04:21.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-01T06:04:21.000Z", "num_tokens": 1333, "size": 2601 }
import cedille-options module to-string (options : cedille-options.options) where open import lib open import cedille-types open import constants open import syntax-util open import ctxt open import rename open import general-util data expr-side : Set where left : expr-side right : expr-side neither : expr-side not-left : expr-side → 𝔹 not-left left = ff not-left _ = tt not-right : expr-side → 𝔹 not-right right = ff not-right _ = tt no-parens : {ed : exprd} → {ed' : exprd} → ⟦ ed ⟧ → ⟦ ed' ⟧ → expr-side → 𝔹 no-parens {_} {TERM} _ (IotaPair pi t t' og pi') lr = tt no-parens {_} {TYPE} _ (TpEq _ t t' _) lr = tt no-parens {_} {TERM} _ (Beta pi ot ot') lr = tt no-parens {_} {TERM} _ (Phi pi eq t t' pi') right = tt no-parens {_} {TERM} _ (Phi pi eq t t' pi') neither = tt no-parens {_} {TERM} _ (Rho _ _ _ _ _ _) right = tt no-parens {_} {TERM} _ (Chi _ _ _) right = tt no-parens {_} {TERM} _ (Delta _ _ _) right = tt no-parens {_} {TERM} _ (Let _ _ _) lr = tt no-parens {_} {TERM} _ (Lam _ _ _ _ _ _) lr = tt no-parens {_} {TERM} _ (Mu _ _ _ _ _ _ _) lr = tt no-parens {_} {TERM} _ (Mu' _ _ _ _ _ _) lr = tt no-parens {_} {TYPE} _ (TpLambda _ _ _ _ _) lr = tt no-parens {_} {TYPE} _ (Abs _ _ _ _ _ _) lr = tt no-parens {_} {KIND} _ (KndPi _ _ _ _ _) lr = tt no-parens {_} {TYPE} _ (Iota _ _ _ _ _) lr = tt no-parens {_} {LIFTINGTYPE} _ (LiftPi _ _ _ _) lr = tt no-parens{TERM} (App t me t') p lr = is-term-level-app p && not-right lr no-parens{TERM} (AppTp t T) p lr = is-term-level-app p && not-right lr no-parens{TERM} (Beta pi ot ot') p lr = tt no-parens{TERM} (Chi pi mT t) p lr = ff no-parens{TERM} (Delta pi mT t) p lr = ff no-parens{TERM} (Epsilon pi lr' m t) p lr = is-eq-op p no-parens{TERM} (Hole pi) p lr = tt no-parens{TERM} (IotaPair pi t t' og pi') p lr = tt no-parens{TERM} (IotaProj t n pi) p lr = tt no-parens{TERM} (Lam pi l' pi' x oc t) p lr = ff no-parens{TERM} (Let pi dtT t) p lr = ff no-parens{TERM} (Open _ _ _) p lr = tt no-parens{TERM} (Parens pi t pi') p lr = tt no-parens{TERM} (Phi pi eq t t' pi') p lr = ff no-parens{TERM} (Rho pi op on eq og t) p lr = ff no-parens{TERM} (Sigma pi t) p lr = is-eq-op p no-parens{TERM} (Theta pi theta t lts) p lr = ff no-parens{TERM} (Var pi x) p lr = tt no-parens{TERM} (Mu _ _ _ _ _ _ _) p lr = tt no-parens{TERM} (Mu' _ _ _ _ _ _) p lr = tt no-parens{TYPE} (Abs pi b pi' x Tk T) p lr = is-arrow p && not-left lr no-parens{TYPE} (Iota pi pi' x oT T) p lr = ff no-parens{TYPE} (Lft pi pi' x t lT) p lr = ff no-parens{TYPE} (NoSpans T pi) p lr = tt no-parens{TYPE} (TpApp T T') p lr = is-arrow p || (is-type-level-app p && not-right lr) no-parens{TYPE} (TpAppt T t) p lr = is-arrow p || (is-type-level-app p && not-right lr) no-parens{TYPE} (TpArrow T a T') p lr = is-arrow p && not-left lr no-parens{TYPE} (TpEq _ t t' _) p lr = tt no-parens{TYPE} (TpHole pi) p lr = tt no-parens{TYPE} (TpLambda pi pi' x Tk T) p lr = ff no-parens{TYPE} (TpParens pi T pi') p lr = tt no-parens{TYPE} (TpVar pi x) p lr = tt no-parens{TYPE} (TpLet _ _ _) _ _ = ff no-parens{KIND} (KndArrow k k') p lr = is-arrow p && not-left lr no-parens{KIND} (KndParens pi k pi') p lr = tt no-parens{KIND} (KndPi pi pi' x Tk k) p lr = is-arrow p && not-left lr no-parens{KIND} (KndTpArrow T k) p lr = is-arrow p && not-left lr no-parens{KIND} (KndVar pi x as) p lr = tt no-parens{KIND} (Star pi) p lr = tt no-parens{LIFTINGTYPE} (LiftArrow lT lT') p lr = is-arrow p && not-left lr no-parens{LIFTINGTYPE} (LiftParens pi lT pi') p lr = tt no-parens{LIFTINGTYPE} (LiftPi pi x T lT) p lr = is-arrow p && not-left lr no-parens{LIFTINGTYPE} (LiftStar pi) p lr = tt no-parens{LIFTINGTYPE} (LiftTpArrow T lT) p lr = is-arrow p && not-left lr no-parens{TK} _ _ _ = tt no-parens{QUALIF} _ _ _ = tt no-parens{ARG} _ _ _ = tt pattern ced-ops-drop-spine = cedille-options.options.mk-options _ _ _ _ ff _ ff pattern ced-ops-conv-arr = cedille-options.options.mk-options _ _ _ _ _ _ ff pattern ced-ops-conv-abs = cedille-options.options.mk-options _ _ _ _ _ _ tt drop-spine : cedille-options.options → {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧ drop-spine ced-ops-drop-spine = h where drop-mod-args : ctxt → maybeErased → spineApp → spineApp drop-mod-args Γ me (v , as) = let qv = unqual-all (ctxt-get-qualif Γ) v in qv , maybe-else' (maybe-if (~ v =string qv) ≫maybe ctxt-qualif-args-length Γ me qv) as (λ n → reverse (drop n (reverse as))) h : {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧ h {TERM} Γ t = maybe-else' (term-to-spapp t) t (spapp-term ∘ drop-mod-args Γ Erased) h {TYPE} Γ T = maybe-else' (type-to-spapp T) T (spapp-type ∘ drop-mod-args Γ NotErased) h Γ x = x drop-spine ops Γ x = x to-string-rewrite : {ed : exprd} → ctxt → cedille-options.options → ⟦ ed ⟧ → Σi exprd ⟦_⟧ to-string-rewrite{TERM} Γ ops (Parens _ t _) = to-string-rewrite Γ ops t to-string-rewrite{TYPE} Γ ops (TpParens _ T _) = to-string-rewrite Γ ops T to-string-rewrite{KIND} Γ ops (KndParens _ k _) = to-string-rewrite Γ ops k to-string-rewrite{LIFTINGTYPE} Γ ops (LiftParens _ lT _) = to-string-rewrite Γ ops lT to-string-rewrite{TK} Γ ops (Tkt T) = to-string-rewrite Γ ops T to-string-rewrite{TK} Γ ops (Tkk k) = to-string-rewrite Γ ops k to-string-rewrite{TYPE} Γ ced-ops-conv-arr (Abs _ me _ ignored-var (Tkt T) T') = , TpArrow T me T' to-string-rewrite{KIND} Γ ced-ops-conv-arr (KndPi _ _ ignored-var (Tkt T) k) = , KndTpArrow T k to-string-rewrite{KIND} Γ ced-ops-conv-arr (KndPi _ _ ignored-var (Tkk k) k') = , KndArrow k k' to-string-rewrite{LIFTINGTYPE} Γ ced-ops-conv-arr (LiftPi _ ignored-var T lT) = , LiftTpArrow T lT to-string-rewrite{TYPE} Γ ced-ops-conv-abs (TpArrow T me T') = , Abs posinfo-gen me posinfo-gen ignored-var (Tkt T) T' to-string-rewrite{KIND} Γ ced-ops-conv-abs (KndTpArrow T k) = , KndPi posinfo-gen posinfo-gen ignored-var (Tkt T) k to-string-rewrite{KIND} Γ ced-ops-conv-abs (KndArrow k k') = , KndPi posinfo-gen posinfo-gen ignored-var (Tkk k) k' to-string-rewrite{LIFTINGTYPE} Γ ced-ops-conv-abs (LiftTpArrow T lT) = , LiftPi posinfo-gen ignored-var T lT to-string-rewrite{TERM} Γ ops (Sigma pi (Sigma pi' t)) = to-string-rewrite Γ ops t to-string-rewrite Γ ops x = , drop-spine ops Γ x ------------------------------- strM : Set strM = ∀ {ed} → rope → ℕ → 𝕃 tag → ctxt → maybe ⟦ ed ⟧ → expr-side → rope × ℕ × 𝕃 tag to-stringh : {ed : exprd} → ⟦ ed ⟧ → strM strM-Γ : (ctxt → strM) → strM strM-Γ f s n ts Γ = f Γ s n ts Γ infixr 4 _≫str_ _≫str_ : strM → strM → strM (m ≫str m') s n ts Γ pe lr with m s n ts Γ pe lr (m ≫str m') s n ts Γ pe lr | s' , n' , ts' = m' s' n' ts' Γ pe lr strAdd : string → strM strAdd s s' n ts Γ pe lr = s' ⊹⊹ [[ s ]] , n + string-length s , ts strΓ' : defScope → var → strM → strM strΓ' ds v m s n ts Γ@(mk-ctxt (fn , mn , ps , q) syms i symb-occs d) pe = let gl = ds iff globalScope v' = if gl then (mn # v) else v in m s n ts (mk-ctxt (fn , mn , ps , qualif-insert-params q v' (unqual-local v) (if gl then ps else ParamsNil)) syms (trie-insert i v' (var-decl , ("missing" , "missing"))) symb-occs d) pe strΓ : var → strM → strM strΓ x m s n ts Γ = m s n ts (ctxt-var-decl x Γ) ctxt-get-file-id : ctxt → (filename : string) → ℕ ctxt-get-file-id (mk-ctxt mod (syms , mn-fn , mn-ps , ids , id) is os _) = trie-lookup-else 0 ids make-loc-tag : ctxt → (filename start-to end-to : string) → (start-from end-from : ℕ) → tag make-loc-tag Γ fn s e = make-tag "loc" (("fn" , [[ ℕ-to-string (ctxt-get-file-id Γ fn) ]]) :: ("s" , [[ s ]]) :: ("e" , [[ e ]]) :: []) var-loc-tag : ctxt → location → var → (start-from end-from : ℕ) → 𝕃 tag var-loc-tag Γ ("missing" , "missing") x start end = [] var-loc-tag Γ (fn , pos) x start end = [ make-loc-tag Γ fn pos (posinfo-plus-str pos (unqual-local x)) start end ] var-tags : ctxt → qvar → var → ℕ → ℕ → 𝕃 tag var-tags Γ qv uqv s e with qv =string (qualif-var Γ uqv) ...| tt = var-loc-tag Γ (ctxt-var-location Γ qv) uqv s e ...| ff = make-tag "shadowed" [] s e :: var-loc-tag Γ (ctxt-var-location Γ qv) uqv s e strVar : var → strM strVar v s n ts Γ pe lr = let uqv = unqual-local $ unqual-all (ctxt-get-qualif Γ) v uqv' = if cedille-options.options.show-qualified-vars options then v else uqv n' = n + (string-length uqv') in s ⊹⊹ [[ uqv' ]] , n' , var-tags Γ (qualif-var Γ v) uqv n n' ++ ts -- Only necessary to unqual-local because of module parameters strBvar : var → (class body : strM) → strM strBvar v cm bm = strAdd (unqual-local v) ≫str cm ≫str strΓ v bm strMetaVar : var → span-location → strM strMetaVar x (fn , pi , pi') s n ts Γ pe lr = let n' = n + string-length x in s ⊹⊹ [[ x ]] , n' , make-loc-tag Γ fn pi pi' n n' :: ts strEmpty : strM strEmpty s n ts Γ pe lr = s , n , ts {-# TERMINATING #-} term-to-stringh : term → strM type-to-stringh : type → strM kind-to-stringh : kind → strM liftingType-to-stringh : liftingType → strM tk-to-stringh : tk → strM constructors-to-string : dataConsts → strM params-to-string : params → strM params-to-string' : strM → params → strM file-to-string : start → strM cmds-to-string : cmds → strM → strM cmd-to-string : cmd → strM → strM optTerm-to-string : optTerm → string → string → strM optClass-to-string : optClass → strM optGuide-to-string : optGuide → strM optNums-to-string : optNums → strM optType-to-string : optType → strM maybeCheckType-to-string : optType → strM lterms-to-string : lterms → strM arg-to-string : arg → strM args-to-string : args → strM binder-to-string : maybeErased → string opacity-to-string : opacity → string maybeErased-to-string : maybeErased → string lam-to-string : maybeErased → string leftRight-to-string : leftRight → string vars-to-string : vars → strM nums-to-string : nums → strM theta-to-string : theta → strM arrowtype-to-string : maybeErased → string maybeMinus-to-string : maybeMinus → string optPlus-to-string : optPlus → string optPublic-to-string : optPublic → string optAs-to-string : optAs → strM to-string-ed : {ed : exprd} → ⟦ ed ⟧ → strM to-string-ed{TERM} = term-to-stringh to-string-ed{TYPE} = type-to-stringh to-string-ed{KIND} = kind-to-stringh to-string-ed{LIFTINGTYPE} = liftingType-to-stringh to-string-ed{TK} = tk-to-stringh to-string-ed{ARG} = arg-to-string to-string-ed{QUALIF} q = strEmpty to-stringh' : {ed : exprd} → expr-side → ⟦ ed ⟧ → strM to-stringh' {ed} lr t {ed'} s n ts Γ mp lr' = elim-Σi (to-string-rewrite Γ options t) λ t' → parens-unless (~ isJust (mp ≫=maybe λ pe → maybe-if (~ no-parens t' pe lr))) (to-string-ed t') s n ts Γ (just t') lr where parens-unless : 𝔹 → strM → strM parens-unless p s = if p then s else (strAdd "(" ≫str s ≫str strAdd ")") to-stringl : {ed : exprd} → ⟦ ed ⟧ → strM to-stringr : {ed : exprd} → ⟦ ed ⟧ → strM to-stringl = to-stringh' left to-stringr = to-stringh' right to-stringh = to-stringh' neither constructors-to-string DataNull = strEmpty constructors-to-string (DataCons (DataConst _ x t) ds) = strAdd " | " ≫str strAdd x ≫str strAdd " : " ≫str type-to-stringh t ≫str constructors-to-string ds tk-to-stringh (Tkt T) = to-stringh T tk-to-stringh (Tkk k) = to-stringh k term-to-stringh (App t me t') = to-stringl t ≫str strAdd (" " ^ maybeErased-to-string me) ≫str to-stringr t' term-to-stringh (AppTp t T) = to-stringl t ≫str strAdd " · " ≫str to-stringr T term-to-stringh (Beta pi ot ot') = strAdd "β" ≫str optTerm-to-string ot " < " " >" ≫str optTerm-to-string ot' " { " " }" term-to-stringh (Chi pi mT t) = strAdd "χ" ≫str optType-to-string mT ≫str strAdd " - " ≫str to-stringr t term-to-stringh (Delta pi mT t) = strAdd "δ" ≫str optType-to-string mT ≫str strAdd " - " ≫str to-stringr t term-to-stringh (Epsilon pi lr m t) = strAdd "ε" ≫str strAdd (leftRight-to-string lr) ≫str strAdd (maybeMinus-to-string m) ≫str to-stringh t term-to-stringh (Hole pi) = strAdd "●" term-to-stringh (IotaPair pi t t' og pi') = strAdd "[ " ≫str to-stringh t ≫str strAdd " , " ≫str to-stringh t' ≫str optGuide-to-string og ≫str strAdd " ]" term-to-stringh (IotaProj t n pi) = to-stringh t ≫str strAdd ("." ^ n) term-to-stringh (Lam pi l pi' x oc t) = strAdd (lam-to-string l) ≫str strAdd " " ≫str strBvar x (optClass-to-string oc) (strAdd " . " ≫str to-stringr t) term-to-stringh (Let pi dtT t) with dtT ...| DefTerm pi' x m t' = strAdd "[ " ≫str strBvar x (maybeCheckType-to-string m ≫str strAdd " = " ≫str to-stringh t' ≫str strAdd " ] - ") (to-stringh t) ...| DefType pi' x k t' = strAdd "[ " ≫str strBvar x (strAdd " ◂ " ≫str to-stringh k ≫str strAdd " = " ≫str to-stringh t' ≫str strAdd " ] - ") (to-stringh t) term-to-stringh (Open pi x t) = strAdd "open " ≫str strVar x ≫str strAdd " - " ≫str to-stringh t term-to-stringh (Parens pi t pi') = to-stringh t term-to-stringh (Phi pi eq t t' pi') = strAdd "φ " ≫str to-stringl eq ≫str strAdd " - " ≫str to-stringh t ≫str strAdd " {" ≫str to-stringr t' ≫str strAdd "}" term-to-stringh (Rho pi op on eq og t) = strAdd "ρ" ≫str strAdd (optPlus-to-string op) ≫str optNums-to-string on ≫str strAdd " " ≫str to-stringl eq ≫str optGuide-to-string og ≫str strAdd " - " ≫str to-stringr t term-to-stringh (Sigma pi t) = strAdd "ς " ≫str to-stringh t term-to-stringh (Theta pi theta t lts) = theta-to-string theta ≫str to-stringh t ≫str lterms-to-string lts term-to-stringh (Var pi x) = strVar x term-to-stringh (Mu pi x t ot pi' cs pi'') = strAdd "μ " ≫str strBvar x (strAdd " . " ≫str to-stringh t) strEmpty ≫str optType-to-string ot ≫str strAdd "TODO" term-to-stringh (Mu' pi t ot pi' cs pi'') = strAdd "μ' " ≫str to-stringh t ≫str strAdd " . " ≫str optType-to-string ot ≫str strAdd "TODO" type-to-stringh (Abs pi b pi' x Tk T) = strAdd (binder-to-string b ^ " ") ≫str strBvar x (strAdd " : " ≫str tk-to-stringh Tk ≫str strAdd " . ") (to-stringh T) type-to-stringh (Iota pi pi' x T T') = strAdd "ι " ≫str strBvar x (strAdd " : " ≫str to-stringh T ≫str strAdd " . ") (to-stringh T') type-to-stringh (Lft pi pi' x t lT) = strAdd "↑ " ≫str strBvar x (strAdd " . ") (to-stringh t) ≫str strAdd " : " ≫str to-stringh lT type-to-stringh (NoSpans T pi) = to-string-ed T type-to-stringh (TpApp T T') = to-stringl T ≫str strAdd " · " ≫str to-stringr T' type-to-stringh (TpAppt T t) = to-stringl T ≫str strAdd " " ≫str to-stringr t type-to-stringh (TpArrow T a T') = to-stringl T ≫str strAdd (arrowtype-to-string a) ≫str to-stringr T' type-to-stringh (TpEq _ t t' _) = strAdd "{ " ≫str to-stringh (erase-term t) ≫str strAdd " ≃ " ≫str to-stringh (erase-term t') ≫str strAdd " }" type-to-stringh (TpHole pi) = strAdd "●" type-to-stringh (TpLambda pi pi' x Tk T) = strAdd "λ " ≫str strBvar x (strAdd " : " ≫str tk-to-stringh Tk ≫str strAdd " . ") (to-stringr T) type-to-stringh (TpParens pi T pi') = to-stringh T type-to-stringh (TpVar pi x) = strVar x type-to-stringh (TpLet pi dtT t) with dtT ...| DefTerm pi' x m t' = strAdd "[ " ≫str strBvar x (maybeCheckType-to-string m ≫str strAdd " = " ≫str to-stringh t' ≫str strAdd " ] - ") (to-stringh t) ...| DefType pi' x k t' = strAdd "[ " ≫str strBvar x (strAdd " ◂ " ≫str to-stringh k ≫str strAdd " = " ≫str to-stringh t' ≫str strAdd " ] - ") (to-stringh t) kind-to-stringh (KndArrow k k') = to-stringl k ≫str strAdd " ➔ " ≫str to-stringr k' kind-to-stringh (KndParens pi k pi') = to-stringh k kind-to-stringh (KndPi pi pi' x Tk k) = strAdd "Π " ≫str strBvar x (strAdd " : " ≫str tk-to-stringh Tk ≫str strAdd " . ") (to-stringh k) kind-to-stringh (KndTpArrow T k) = to-stringl T ≫str strAdd " ➔ " ≫str to-stringr k kind-to-stringh (KndVar pi x as) = strVar x ≫str args-to-string as kind-to-stringh (Star pi) = strAdd "★" liftingType-to-stringh (LiftArrow lT lT') = to-stringl lT ≫str strAdd " ➔↑ " ≫str to-stringr lT' liftingType-to-stringh (LiftParens pi lT pi') = strAdd "(" ≫str to-string-ed lT ≫str strAdd ")" liftingType-to-stringh (LiftPi pi x T lT) = strAdd "Π↑ " ≫str strBvar x (strAdd " : " ≫str to-stringh T ≫str strAdd " . ") (to-stringh lT) liftingType-to-stringh (LiftStar pi) = strAdd "☆" liftingType-to-stringh (LiftTpArrow T lT) = to-stringl T ≫str strAdd " ➔↑ " ≫str to-stringr lT optTerm-to-string NoTerm c1 c2 = strEmpty optTerm-to-string (SomeTerm t _) c1 c2 = strAdd c1 ≫str to-stringh (erase-term t) ≫str strAdd c2 optClass-to-string NoClass = strEmpty optClass-to-string (SomeClass Tk) = strAdd " : " ≫str tk-to-stringh Tk optGuide-to-string NoGuide = strEmpty optGuide-to-string (Guide pi v T) = strAdd " @ " ≫str strBvar v (strAdd " . ") (to-stringh T) optType-to-string NoType = strEmpty optType-to-string (SomeType T) = strAdd " " ≫str to-stringh T maybeCheckType-to-string NoType = strEmpty maybeCheckType-to-string (SomeType T) = strAdd " ◂ " ≫str to-stringh T lterms-to-string (LtermsCons m t ts) = strAdd (" " ^ maybeErased-to-string m) ≫str to-stringh t ≫str lterms-to-string ts lterms-to-string (LtermsNil _) = strEmpty arg-to-string (TermArg me t) = strAdd (maybeErased-to-string me) ≫str to-stringh t arg-to-string (TypeArg T) = strAdd "· " ≫str to-stringh T args-to-string (ArgsCons t ts) = strAdd " " ≫str arg-to-string t ≫str args-to-string ts args-to-string ArgsNil = strEmpty binder-to-string All = "∀" binder-to-string Pi = "Π" opacity-to-string OpacOpaque = "opaque " opacity-to-string OpacTrans = "" maybeErased-to-string Erased = "-" maybeErased-to-string NotErased = "" lam-to-string Erased = "Λ" lam-to-string NotErased = "λ" leftRight-to-string Left = "l" leftRight-to-string Right = "r" leftRight-to-string Both = "" vars-to-string (VarsStart v) = strVar v vars-to-string (VarsNext v vs) = strVar v ≫str strAdd " " ≫str vars-to-string vs theta-to-string Abstract = strAdd "θ " theta-to-string AbstractEq = strAdd "θ+ " theta-to-string (AbstractVars vs) = strAdd "θ<" ≫str vars-to-string vs ≫str strAdd "> " nums-to-string (NumsStart n) = strAdd n nums-to-string (NumsNext n ns) = strAdd n ≫str strAdd " " ≫str nums-to-string ns optNums-to-string NoNums = strEmpty optNums-to-string (SomeNums ns) = strAdd "<" ≫str nums-to-string ns ≫str strAdd ">" arrowtype-to-string NotErased = " ➔ " arrowtype-to-string Erased = " ➾ " maybeMinus-to-string EpsHnf = "" maybeMinus-to-string EpsHanf = "-" optPlus-to-string RhoPlain = "" optPlus-to-string RhoPlus = "+" optPublic-to-string NotPublic = "" optPublic-to-string IsPublic = "public " optAs-to-string NoOptAs = strEmpty optAs-to-string (SomeOptAs _ x) = strAdd " as " ≫str strAdd x braceL : maybeErased → string braceL Erased = "{" braceL NotErased = "(" braceR : maybeErased → string braceR Erased = "}" braceR NotErased = ")" param-to-string : decl → strM → strM param-to-string (Decl _ pi me v atk _) f = strAdd (braceL me) ≫str strAdd (unqual-local v) ≫str strAdd " : " ≫str tk-to-stringh atk ≫str strAdd (braceR me) ≫str strΓ' localScope v f params-to-string' f ParamsNil = f params-to-string' f (ParamsCons p ParamsNil) = param-to-string p f params-to-string' f (ParamsCons p ps) = param-to-string p (strAdd " " ≫str params-to-string' f ps) params-to-string = params-to-string' strEmpty file-to-string (File _ is _ _ mn ps cs _) = cmds-to-string (imps-to-cmds is) (strAdd "module " ≫str strAdd mn ≫str strAdd " " ≫str params-to-string' (strAdd "." ≫str strAdd "\n" ≫str cmds-to-string cs strEmpty) ps) cmds-to-string CmdsStart f = f cmds-to-string (CmdsNext c cs) f = strAdd "\n" ≫str cmd-to-string c (strAdd "\n" ≫str cmds-to-string cs f) cmd-to-string (DefTermOrType op (DefTerm pi x mcT t) _) f = strM-Γ λ Γ → let ps = ctxt-get-current-params Γ in strAdd (opacity-to-string op) ≫str strAdd x ≫str maybeCheckType-to-string (case mcT of λ where NoType → NoType (SomeType T) → SomeType (abs-expand-type ps T)) ≫str strAdd " = " ≫str to-stringh (lam-expand-term ps t) ≫str strAdd " ." ≫str strΓ' globalScope x f cmd-to-string (DefTermOrType op (DefType pi x k T) _) f = strM-Γ λ Γ → let ps = ctxt-get-current-params Γ in strAdd (opacity-to-string op) ≫str strAdd x ≫str strAdd " ◂ " ≫str to-stringh (abs-expand-kind ps k) ≫str strAdd " = " ≫str to-stringh (lam-expand-type ps T) ≫str strAdd " ." ≫str strΓ' globalScope x f cmd-to-string (DefKind pi x ps k _) f = strM-Γ λ Γ → let ps' = ctxt-get-current-params Γ in strAdd x ≫str params-to-string (append-params ps' ps) ≫str strAdd " = " ≫str to-stringh k ≫str strAdd " ." ≫str strΓ' globalScope x f cmd-to-string (ImportCmd (Import _ op _ fn oa as _)) f = strAdd "import " ≫str strAdd (optPublic-to-string op) ≫str strAdd fn ≫str optAs-to-string oa ≫str args-to-string as ≫str strAdd " ." ≫str f cmd-to-string (DefDatatype (Datatype pi pix x ps k cs pi') pi'') f = strAdd "data " ≫str strAdd x ≫str strAdd " " ≫str params-to-string ps ≫str strAdd " : " ≫str kind-to-stringh k ≫str strAdd " = " ≫str constructors-to-string cs ≫str strΓ' globalScope x f strRun : ctxt → strM → rope strRun Γ m = fst (m {TERM} [[]] 0 [] Γ nothing neither) strRunTag : (name : string) → ctxt → strM → tagged-val strRunTag name Γ m with m {TERM} [[]] 0 [] Γ nothing neither ...| s , n , ts = name , s , ts to-string-tag : {ed : exprd} → string → ctxt → ⟦ ed ⟧ → tagged-val to-string-tag name Γ t = strRunTag name Γ (to-stringh (if cedille-options.options.erase-types options then erase t else t)) to-string : {ed : exprd} → ctxt → ⟦ ed ⟧ → rope to-string Γ t = strRun Γ (to-stringh t) tk-to-string : ctxt → tk → rope tk-to-string Γ atk = strRun Γ (tk-to-stringh atk) params-to-string-tag : string → ctxt → params → tagged-val params-to-string-tag name Γ ps = strRunTag name Γ (params-to-string ps)
{ "alphanum_fraction": 0.6523619118, "avg_line_length": 44.9958158996, "ext": "agda", "hexsha": "cb29732e715d0246f8e59474d528f1e12c231f2d", "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": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xoltar/cedille", "max_forks_repo_path": "src/to-string.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "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": "xoltar/cedille", "max_issues_repo_path": "src/to-string.agda", "max_line_length": 210, "max_stars_count": null, "max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xoltar/cedille", "max_stars_repo_path": "src/to-string.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8021, "size": 21508 }
{-# OPTIONS --without-K --safe #-} open import Polynomial.Parameters module Polynomial.Homomorphism.Semantics {c r₁ r₂ r₃} (homo : Homomorphism c r₁ r₂ r₃) where open import Data.Product using (_,_) open import Data.List using ([]) open import Data.Vec as Vec using (Vec) open import Data.Fin using (Fin) open import Function open import Polynomial.Homomorphism.Lemmas homo open import Polynomial.NormalForm homo open Homomorphism homo open import Polynomial.Reasoning ring open import Polynomial.Exponentiation rawRing κ-hom : ∀ {n} → (x : Raw.Carrier) → (Ρ : Vec Carrier n) → ⟦ κ x ⟧ Ρ ≈ ⟦ x ⟧ᵣ κ-hom x _ = refl ι-hom : ∀ {n} → (i : Fin n) → (Ρ : Vec Carrier n) → ⟦ ι i ⟧ Ρ ≈ Vec.lookup Ρ i ι-hom i Ρ′ = let (ρ , Ρ) = drop-1 (Fin⇒≤ i) Ρ′ in begin ⟦ (κ Raw.1# Δ 1 ∷↓ []) Π↓ Fin⇒≤ i ⟧ Ρ′ ≈⟨ Π↓-hom (κ Raw.1# Δ 1 ∷↓ []) (Fin⇒≤ i) Ρ′ ⟩ Σ?⟦ κ Raw.1# Δ 1 ∷↓ [] ⟧ (ρ , Ρ) ≈⟨ ∷↓-hom-s (κ Raw.1#) 0 [] ρ Ρ ⟩ ρ * ⟦ κ Raw.1# ⟧ Ρ ≈⟨ *≫ 1-homo ⟩ ρ * 1# ≈⟨ *-identityʳ ρ ⟩ ρ ≡⟨ drop-1⇒lookup i Ρ′ ⟩ Vec.lookup Ρ′ i ∎
{ "alphanum_fraction": 0.5670009116, "avg_line_length": 22.8541666667, "ext": "agda", "hexsha": "c6b88686bf9b0672ca99cf9e09dcf2f1d5b32d35", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Polynomial/Homomorphism/Semantics.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Polynomial/Homomorphism/Semantics.agda", "max_line_length": 78, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Polynomial/Homomorphism/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 488, "size": 1097 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Subset.Setoid.Properties directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Subset.Setoid.Properties where open import Data.List.Relation.Binary.Subset.Setoid.Properties public
{ "alphanum_fraction": 0.5200892857, "avg_line_length": 34.4615384615, "ext": "agda", "hexsha": "e2a5a42626521dab4a4f4aeedae78d04e8c50484", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Subset/Setoid/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Subset/Setoid/Properties.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Subset/Setoid/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 69, "size": 448 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.TLevel open import lib.types.Group open import lib.types.LoopSpace open import lib.groups.Homomorphism open import lib.groups.Isomorphism module lib.groups.LoopSpace where {- A loop space is a pregroup, and a group if it has the right level -} module _ {i} (n : ℕ) (X : Ptd i) where Ω^S-group-structure : GroupStructure (Ω^ (S n) X) Ω^S-group-structure = record { ident = idp^ (S n); inv = Ω^S-! n; comp = Ω^S-∙ n; unit-l = Ω^S-∙-unit-l n; assoc = Ω^S-∙-assoc n; inv-l = Ω^S-!-inv-l n } Ω^S-group : has-level ⟨ S n ⟩ (de⊙ X) → Group i Ω^S-group pX = group (Ω^ (S n) X) (Ω^-level 0 (S n) X $ transport (λ t → has-level t (de⊙ X)) (! (+2+0 ⟨ S n ⟩₋₂)) pX) Ω^S-group-structure module _ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} where Ω^S-group-structure-fmap : X ⊙→ Y → GroupStructureHom (Ω^S-group-structure n X) (Ω^S-group-structure n Y) Ω^S-group-structure-fmap F = group-structure-hom (Ω^-fmap (S n) F) (Ω^S-fmap-∙ n F) Ω^S-group-structure-isemap : {F : X ⊙→ Y} → is-equiv (fst F) → is-equiv (GroupStructureHom.f (Ω^S-group-structure-fmap F)) Ω^S-group-structure-isemap {F} F-is-equiv = Ω^-isemap (S n) F F-is-equiv Ω^S-group-structure-emap : X ⊙≃ Y → Ω^S-group-structure n X ≃ᴳˢ Ω^S-group-structure n Y Ω^S-group-structure-emap (F , F-is-equiv) = Ω^S-group-structure-fmap F , Ω^S-group-structure-isemap F-is-equiv module _ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} (X-level : has-level ⟨ S n ⟩ (de⊙ X)) (Y-level : has-level ⟨ S n ⟩ (de⊙ Y)) where Ω^S-group-fmap : X ⊙→ Y → Ω^S-group n X X-level →ᴳ Ω^S-group n Y Y-level Ω^S-group-fmap = →ᴳˢ-to-→ᴳ ∘ Ω^S-group-structure-fmap n Ω^S-group-emap : X ⊙≃ Y → Ω^S-group n X X-level ≃ᴳ Ω^S-group n Y Y-level Ω^S-group-emap = ≃ᴳˢ-to-≃ᴳ ∘ Ω^S-group-structure-emap n
{ "alphanum_fraction": 0.605179704, "avg_line_length": 33.7857142857, "ext": "agda", "hexsha": "5d85023bbb2df73ad20d5f8dc5eaec84357f9dc2", "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": "core/lib/groups/LoopSpace.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": "core/lib/groups/LoopSpace.agda", "max_line_length": 85, "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": "core/lib/groups/LoopSpace.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 810, "size": 1892 }
open import Nat open import Prelude open import List open import contexts open import core open import lemmas-general open import preservation module eval-checks where eval-unicity : ∀{⛽ Δ Σ' Γ E e τ r r' K K'} → Δ , Σ' , Γ ⊢ E → Δ , Σ' , Γ ⊢ e :: τ → E ⊢ e ⌊ ⛽ ⌋⇒ r ⊣ K → E ⊢ e ⌊ ⛽ ⌋⇒ r' ⊣ K' → r == r' ∧ K == K' xc-unicity : ∀{Δ Σ' r1 r2 τ K K'} → Δ , Σ' ⊢ r1 ·: τ → Δ , Σ' ⊢ r2 ·: τ → Constraints⦃ r1 , r2 ⦄:= K → Constraints⦃ r1 , r2 ⦄:= K' → K == K' eval-unicity Γ⊢E (TAFix _) EFix EFix = refl , refl eval-unicity Γ⊢E (TAVar _) (EVar h) (EVar h') = ctxunicity h h' , refl eval-unicity Γ⊢E (TAApp _ ta-f ta-arg) (EAppFix f1 form eval-f eval-arg eval) (EAppFix f2 form' eval-f' eval-arg' eval') rewrite form | form' with eval-unicity Γ⊢E ta-f eval-f eval-f' | eval-unicity Γ⊢E ta-arg eval-arg eval-arg' ... | refl , refl | refl , refl with preservation Γ⊢E ta-f eval-f ... | TAFix Γ'⊢Ef (TAFix ta-ef) rewrite Fuel-depletion-unicity f1 f2 with eval-unicity (EnvInd (EnvInd Γ'⊢Ef (preservation Γ⊢E ta-f eval-f)) (preservation Γ⊢E ta-arg eval-arg)) ta-ef eval eval' ... | refl , refl = refl , refl eval-unicity Γ⊢E TAUnit EUnit EUnit = refl , refl eval-unicity Γ⊢E (TAApp x ta-e ta-e₁) (EAppFix x₁ form eval eval₁ eval₂) (EAppUnfinished eval' nf eval'') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl rewrite form = abort (nf refl) eval-unicity Γ⊢E (TAApp x ta-e ta-e₁) (EAppUnfinished eval nf eval₁) (EAppFix x₂ form eval' eval'' eval''') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl rewrite form = abort (nf refl) eval-unicity Γ⊢E (TAApp x ta-f ta-arg) (EAppUnfinished eval-f x₁ eval-arg) (EAppUnfinished eval-f' x₂ eval-arg') with eval-unicity Γ⊢E ta-f eval-f eval-f' | eval-unicity Γ⊢E ta-arg eval-arg eval-arg' ... | refl , refl | refl , refl = refl , refl eval-unicity Γ⊢E (TAPair x ta-e1 ta-e2) (EPair eval1 eval2) (EPair eval1' eval2') with eval-unicity Γ⊢E ta-e1 eval1 eval1' | eval-unicity Γ⊢E ta-e2 eval2 eval2' ... | refl , refl | refl , refl = refl , refl eval-unicity Γ⊢E (TAFst ta-e) (EFst eval) (EFst eval') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = refl , refl eval-unicity Γ⊢E (TAFst ta-e) (EFst eval) (EFstUnfinished eval' np) with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = abort (np refl) eval-unicity Γ⊢E (TAFst ta-e) (EFstUnfinished eval np) (EFst eval') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = abort (np refl) eval-unicity Γ⊢E (TAFst ta-e) (EFstUnfinished eval x) (EFstUnfinished eval' x₁) with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = refl , refl eval-unicity Γ⊢E (TASnd ta-e) (ESnd eval) (ESnd eval') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = refl , refl eval-unicity Γ⊢E (TASnd ta-e) (ESnd eval) (ESndUnfinished eval' np) with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = abort (np refl) eval-unicity Γ⊢E (TASnd ta-e) (ESndUnfinished eval np) (ESnd eval') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = abort (np refl) eval-unicity Γ⊢E (TASnd ta-e) (ESndUnfinished eval x) (ESndUnfinished eval' x₁) with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = refl , refl eval-unicity Γ⊢E (TACtor x x₁ ta-e) (ECtor eval) (ECtor eval') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = refl , refl eval-unicity Γ⊢E (TACase d∈σ' ta-e x₁ ta-rules) (EMatch f1 form eval-e eval-ec) (EMatch f2 form' eval'-e eval'-ec) with eval-unicity Γ⊢E ta-e eval-e eval'-e ... | refl , refl with ctxunicity form form' ... | refl with ta-rules form ... | _ , _ , _ , c∈cctx , ta-ec with preservation Γ⊢E ta-e eval-e ... | TACtor d∈'σ' c∈'cctx ta-r' rewrite ctxunicity d∈σ' d∈'σ' | ctxunicity c∈cctx c∈'cctx | Fuel-depletion-unicity f1 f2 with eval-unicity (EnvInd Γ⊢E ta-r') ta-ec eval-ec eval'-ec ... | refl , refl = refl , refl eval-unicity Γ⊢E (TACase x ta-e x₁ x₂) (EMatch x₃ x₄ eval eval₁) (EMatchUnfinished eval' nc) with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = abort (nc refl) eval-unicity Γ⊢E (TACase x ta-e x₁ x₂) (EMatchUnfinished eval nc) (EMatch x₄ x₅ eval' eval'') with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = abort (nc refl) eval-unicity Γ⊢E (TACase x ta-e x₁ x₂) (EMatchUnfinished eval x₃) (EMatchUnfinished eval' x₄) with eval-unicity Γ⊢E ta-e eval eval' ... | refl , refl = refl , refl eval-unicity Γ⊢E (TAHole x) EHole EHole = refl , refl eval-unicity Γ⊢E (TAAsrt x ta-e1 ta-e2) (EAsrt eval1 eval2 xc) (EAsrt eval1' eval2' xc') with eval-unicity Γ⊢E ta-e1 eval1 eval1' | eval-unicity Γ⊢E ta-e2 eval2 eval2' ... | refl , refl | refl , refl rewrite xc-unicity (preservation Γ⊢E ta-e1 eval1) (preservation Γ⊢E ta-e2 eval2) xc xc' = refl , refl xc-unicity ta1 ta2 RCRefl RCRefl = refl xc-unicity ta1 ta2 RCRefl (RCPair x rc2 rc3) = abort (x refl) xc-unicity ta1 ta2 RCRefl (RCCtor x rc2) = abort (x refl) xc-unicity ta1 ta2 RCRefl (RCVal1 x x₁ x₂ x₃) = abort (x refl) xc-unicity ta1 ta2 RCRefl (RCVal2 x x₁ x₂ x₃) = abort (x refl) xc-unicity ta1 ta2 (RCPair x rc1 rc2) RCRefl = abort (x refl) xc-unicity (TAPair ta1 ta2) (TAPair ta3 ta4) (RCPair x rc1 rc2) (RCPair x₁ rc3 rc4) rewrite xc-unicity ta1 ta3 rc1 rc3 | xc-unicity ta2 ta4 rc2 rc4 = refl xc-unicity ta1 ta2 (RCPair x rc1 rc2) (RCVal1 x₁ (Inl x₂) x₃ x₄) = abort (x₂ refl) xc-unicity ta1 ta2 (RCPair x rc1 rc2) (RCVal1 x₁ (Inr x₂) x₃ x₄) = abort (x₂ refl) xc-unicity ta1 ta2 (RCPair x rc1 rc2) (RCVal2 x₁ (Inl x₂) x₃ x₄) = abort (x₂ refl) xc-unicity ta1 ta2 (RCPair x rc1 rc2) (RCVal2 x₁ (Inr x₂) x₃ x₄) = abort (x₂ refl) xc-unicity ta1 ta2 (RCCtor x rc1) RCRefl = abort (x refl) xc-unicity (TACtor d∈σ' c∈cctx ta1) (TACtor d∈'σ' c∈'cctx ta2) (RCCtor x rc1) (RCCtor x₁ rc2) rewrite ctxunicity d∈σ' d∈'σ' | ctxunicity c∈cctx c∈'cctx = xc-unicity ta1 ta2 rc1 rc2 xc-unicity ta1 ta2 (RCCtor x rc1) (RCVal1 x₁ x₂ (Inl x₃) x₄) = abort (x₃ refl) xc-unicity ta1 ta2 (RCCtor x rc1) (RCVal1 x₁ x₂ (Inr x₃) x₄) = abort (x₃ refl) xc-unicity ta1 ta2 (RCCtor x rc1) (RCVal2 x₁ x₂ (Inl x₃) x₄) = abort (x₃ refl) xc-unicity ta1 ta2 (RCCtor x rc1) (RCVal2 x₁ x₂ (Inr x₃) x₄) = abort (x₃ refl) xc-unicity ta1 ta2 (RCVal1 x x₁ x₂ x₃) RCRefl = abort (x refl) xc-unicity ta1 ta2 (RCVal1 x (Inl x₁) x₂ x₃) (RCPair x₄ rc2 rc3) = abort (x₁ refl) xc-unicity ta1 ta2 (RCVal1 x (Inr x₁) x₂ x₃) (RCPair x₄ rc2 rc3) = abort (x₁ refl) xc-unicity ta1 ta2 (RCVal1 x _ (Inl x₁) x₃) (RCCtor x₄ rc2) = abort (x₁ refl) xc-unicity ta1 ta2 (RCVal1 x _ (Inr x₁) x₃) (RCCtor x₄ rc2) = abort (x₁ refl) xc-unicity ta1 ta2 (RCVal1 x x₁ x₂ x₃) (RCVal1 x₄ x₅ x₆ x₇) rewrite Coerce-unicity x₃ x₇ = refl xc-unicity TAUnit TAUnit (RCVal1 x x₁ x₂ x₃) (RCVal2 x₄ x₅ x₆ x₇) = abort (x₄ refl) xc-unicity (TAPair ta1 ta2) (TAPair ta3 ta4) (RCVal1 x (Inl x₂) _ x₃) (RCVal2 x₄ x₅ x₆ x₇) = abort (x₂ refl) xc-unicity (TAPair ta1 ta2) (TAPair ta3 ta4) (RCVal1 x (Inr x₂) _ x₃) (RCVal2 x₄ x₅ x₆ x₇) = abort (x₂ refl) xc-unicity (TACtor x₈ x₉ ta1) (TACtor x₁₀ x₁₁ ta2) (RCVal1 x x₁ (Inl h) x₃) (RCVal2 x₄ x₅ x₆ x₇) = abort (h refl) xc-unicity (TACtor x₈ x₉ ta1) (TACtor x₁₀ x₁₁ ta2) (RCVal1 x x₁ (Inr h) x₃) (RCVal2 x₄ x₅ x₆ x₇) = abort (h refl) xc-unicity ta1 ta2 (RCVal2 x x₁ x₂ x₃) RCRefl = abort (x refl) xc-unicity ta1 ta2 (RCVal2 x (Inl x₁) x₂ x₃) (RCPair x₄ rc2 rc3) = abort (x₁ refl) xc-unicity ta1 ta2 (RCVal2 x (Inr x₁) x₂ x₃) (RCPair x₄ rc2 rc3) = abort (x₁ refl) xc-unicity ta1 ta2 (RCVal2 x x₁ (Inl x₂) x₃) (RCCtor x₄ rc2) = abort (x₂ refl) xc-unicity ta1 ta2 (RCVal2 x x₁ (Inr x₂) x₃) (RCCtor x₄ rc2) = abort (x₂ refl) xc-unicity TAUnit TAUnit (RCVal2 x x₁ x₂ x₃) (RCVal1 x₄ x₅ x₆ x₇) = abort (x refl) xc-unicity (TAPair ta1 ta2) (TAPair ta3 ta4) (RCVal2 x (Inl h) x₂ x₃) (RCVal1 x₄ x₅ x₆ x₇) = abort (h refl) xc-unicity (TAPair ta1 ta2) (TAPair ta3 ta4) (RCVal2 x (Inr h) x₂ x₃) (RCVal1 x₄ x₅ x₆ x₇) = abort (h refl) xc-unicity (TACtor x₈ x₉ ta1) (TACtor x₁₀ x₁₁ ta2) (RCVal2 x x₁ (Inl h) x₃) (RCVal1 x₄ x₅ x₆ x₇) = abort (h refl) xc-unicity (TACtor x₈ x₉ ta1) (TACtor x₁₀ x₁₁ ta2) (RCVal2 x x₁ (Inr h) x₃) (RCVal1 x₄ x₅ x₆ x₇) = abort (h refl) xc-unicity ta1 ta2 (RCVal2 x x₁ x₂ x₃) (RCVal2 x₄ x₅ x₆ x₇) rewrite Coerce-unicity x₃ x₇ = refl -- useful in practice, since threading type-checks around everywhere can be a pain -- note that this does not prove unicity of constraints, which isn't true for poorly-typed terms untyped-eval-unicity : ∀{⛽ E e r r' K K'} → E ⊢ e ⌊ ⛽ ⌋⇒ r ⊣ K → E ⊢ e ⌊ ⛽ ⌋⇒ r' ⊣ K' → r == r' untyped-eval-unicity EFix EFix = refl untyped-eval-unicity (EVar h) (EVar h') = ctxunicity h h' untyped-eval-unicity (EAppFix f1 form eval-f eval-arg eval) (EAppFix f2 form' eval-f' eval-arg' eval') rewrite form | form' with untyped-eval-unicity eval-f eval-f' | untyped-eval-unicity eval-arg eval-arg' ... | refl | refl rewrite Fuel-depletion-unicity f1 f2 | untyped-eval-unicity eval eval' = refl untyped-eval-unicity EUnit EUnit = refl untyped-eval-unicity (EAppFix x₁ form eval eval₁ eval₂) (EAppUnfinished eval' nf eval'') rewrite untyped-eval-unicity eval eval' | form = abort (nf refl) untyped-eval-unicity (EAppUnfinished eval nf eval₁) (EAppFix x₂ form eval' eval'' eval''') rewrite untyped-eval-unicity eval eval' | form = abort (nf refl) untyped-eval-unicity (EAppUnfinished eval-f x₁ eval-arg) (EAppUnfinished eval-f' x₂ eval-arg') rewrite untyped-eval-unicity eval-f eval-f' | untyped-eval-unicity eval-arg eval-arg' = refl untyped-eval-unicity (EPair eval1 eval2) (EPair eval1' eval2') rewrite untyped-eval-unicity eval1 eval1' | untyped-eval-unicity eval2 eval2' = refl untyped-eval-unicity (EFst eval) (EFst eval') with untyped-eval-unicity eval eval' ... | refl = refl untyped-eval-unicity (EFst eval) (EFstUnfinished eval' np) with untyped-eval-unicity eval eval' ... | refl = abort (np refl) untyped-eval-unicity (EFstUnfinished eval np) (EFst eval') with untyped-eval-unicity eval eval' ... | refl = abort (np refl) untyped-eval-unicity (EFstUnfinished eval x) (EFstUnfinished eval' x₁) with untyped-eval-unicity eval eval' ... | refl = refl untyped-eval-unicity (ESnd eval) (ESnd eval') with untyped-eval-unicity eval eval' ... | refl = refl untyped-eval-unicity (ESnd eval) (ESndUnfinished eval' np) with untyped-eval-unicity eval eval' ... | refl = abort (np refl) untyped-eval-unicity (ESndUnfinished eval np) (ESnd eval') with untyped-eval-unicity eval eval' ... | refl = abort (np refl) untyped-eval-unicity (ESndUnfinished eval x) (ESndUnfinished eval' x₁) with untyped-eval-unicity eval eval' ... | refl = refl untyped-eval-unicity (ECtor eval) (ECtor eval') with untyped-eval-unicity eval eval' ... | refl = refl untyped-eval-unicity (EMatch f1 form eval-e eval-ec) (EMatch f2 form' eval'-e eval'-ec) with untyped-eval-unicity eval-e eval'-e ... | refl with ctxunicity form form' ... | refl rewrite Fuel-depletion-unicity f1 f2 with untyped-eval-unicity eval-ec eval'-ec ... | refl = refl untyped-eval-unicity (EMatch x₃ x₄ eval eval₁) (EMatchUnfinished eval' nc) with untyped-eval-unicity eval eval' ... | refl = abort (nc refl) untyped-eval-unicity (EMatchUnfinished eval nc) (EMatch x₄ x₅ eval' eval'') with untyped-eval-unicity eval eval' ... | refl = abort (nc refl) untyped-eval-unicity (EMatchUnfinished eval x₃) (EMatchUnfinished eval' x₄) with untyped-eval-unicity eval eval' ... | refl = refl untyped-eval-unicity EHole EHole = refl untyped-eval-unicity (EAsrt eval1 eval2 xc) (EAsrt eval1' eval2' xc') with untyped-eval-unicity eval1 eval1' | untyped-eval-unicity eval2 eval2' ... | refl | refl = refl
{ "alphanum_fraction": 0.6430976431, "avg_line_length": 52.4870689655, "ext": "agda", "hexsha": "7c214579c8bbfabc4b51aab519b603d77fce3b46", "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": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnat-myth-", "max_forks_repo_path": "eval-checks.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnat-myth-", "max_issues_repo_path": "eval-checks.agda", "max_line_length": 128, "max_stars_count": 1, "max_stars_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnat-myth-", "max_stars_repo_path": "eval-checks.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-19T23:42:31.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-19T23:42:31.000Z", "num_tokens": 5110, "size": 12177 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.CommAlgebra.Localisation where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.SIP open import Cubical.Foundations.Powerset open import Cubical.Data.Sigma open import Cubical.Reflection.StrictEquiv open import Cubical.Structures.Axioms open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.CommRing.Base open import Cubical.Algebra.CommRing.Properties open import Cubical.Algebra.CommRing.Localisation.Base open import Cubical.Algebra.CommRing.Localisation.UniversalProperty open import Cubical.Algebra.Ring open import Cubical.Algebra.Algebra open import Cubical.Algebra.CommAlgebra.Base open import Cubical.Algebra.CommAlgebra.Properties open import Cubical.HITs.SetQuotients as SQ open import Cubical.HITs.PropositionalTruncation as PT private variable ℓ ℓ′ : Level module AlgLoc (R' : CommRing ℓ) (S' : ℙ (fst R')) (SMultClosedSubset : isMultClosedSubset R' S') where open isMultClosedSubset private R = fst R' open CommAlgebraStr open IsAlgebraHom open CommRingStr (snd R') renaming (_+_ to _+r_ ; _·_ to _·r_ ; ·Rid to ·rRid) open RingTheory (CommRing→Ring R') open CommRingTheory R' open Loc R' S' SMultClosedSubset open S⁻¹RUniversalProp R' S' SMultClosedSubset open CommAlgChar R' S⁻¹RAsCommAlg : CommAlgebra R' ℓ S⁻¹RAsCommAlg = toCommAlg (S⁻¹RAsCommRing , /1AsCommRingHom) hasLocAlgUniversalProp : (A : CommAlgebra R' ℓ) → (∀ s → s ∈ S' → _⋆_ (snd A) s (1a (snd A)) ∈ (CommAlgebra→CommRing A) ˣ) → Type (ℓ-suc ℓ) hasLocAlgUniversalProp A _ = (B : CommAlgebra R' ℓ) → (∀ s → s ∈ S' → _⋆_ (snd B) s (1a (snd B)) ∈ (CommAlgebra→CommRing B) ˣ) → isContr (CommAlgebraHom A B) S⋆1⊆S⁻¹Rˣ : ∀ s → s ∈ S' → _⋆_ (snd S⁻¹RAsCommAlg) s (1a (snd S⁻¹RAsCommAlg)) ∈ S⁻¹Rˣ S⋆1⊆S⁻¹Rˣ s s∈S' = subst-∈ S⁻¹Rˣ (cong [_] (≡-× (sym (·rRid s)) (Σ≡Prop (λ x → S' x .snd) (sym (·rRid _))))) (S/1⊆S⁻¹Rˣ s s∈S') S⁻¹RHasAlgUniversalProp : hasLocAlgUniversalProp S⁻¹RAsCommAlg S⋆1⊆S⁻¹Rˣ S⁻¹RHasAlgUniversalProp B' S⋆1⊆Bˣ = χᴬ , χᴬuniqueness where B = fromCommAlg B' .fst φ = fromCommAlg B' .snd open CommRingStr (snd B) renaming (_·_ to _·b_ ; 1r to 1b ; ·Lid to ·bLid) χ : CommRingHom S⁻¹RAsCommRing B χ = S⁻¹RHasUniversalProp B φ S⋆1⊆Bˣ .fst .fst χcomp : ∀ r → fst χ (r /1) ≡ fst φ r χcomp = funExt⁻ (S⁻¹RHasUniversalProp B φ S⋆1⊆Bˣ .fst .snd) χᴬ : CommAlgebraHom S⁻¹RAsCommAlg B' fst χᴬ = fst χ pres0 (snd χᴬ) = IsRingHom.pres0 (snd χ) pres1 (snd χᴬ) = IsRingHom.pres1 (snd χ) pres+ (snd χᴬ) = IsRingHom.pres+ (snd χ) pres· (snd χᴬ) = IsRingHom.pres· (snd χ) pres- (snd χᴬ) = IsRingHom.pres- (snd χ) pres⋆ (snd χᴬ) r x = path where path : fst χ ((r /1) ·ₗ x) ≡ _⋆_ (snd B') r (fst χ x) path = fst χ ((r /1) ·ₗ x) ≡⟨ IsRingHom.pres· (snd χ) _ _ ⟩ fst χ (r /1) ·b fst χ x ≡⟨ cong (_·b fst χ x) (χcomp r) ⟩ fst φ r ·b fst χ x ≡⟨ refl ⟩ _⋆_ (snd B') r 1b ·b fst χ x ≡⟨ ⋆-lassoc (snd B') _ _ _ ⟩ _⋆_ (snd B') r (1b ·b fst χ x) ≡⟨ cong (_⋆_ (snd B') r) (·bLid _) ⟩ _⋆_ (snd B') r (fst χ x) ∎ χᴬuniqueness : (ψ : CommAlgebraHom S⁻¹RAsCommAlg B') → χᴬ ≡ ψ χᴬuniqueness ψ = Σ≡Prop (λ _ → isPropIsAlgebraHom _ _ _ _) (cong (fst ∘ fst) (χuniqueness (ψ' , funExt ψ'r/1≡φr))) where χuniqueness = S⁻¹RHasUniversalProp B φ S⋆1⊆Bˣ .snd ψ' : CommRingHom S⁻¹RAsCommRing B fst ψ' = fst ψ IsRingHom.pres0 (snd ψ') = pres0 (snd ψ) IsRingHom.pres1 (snd ψ') = pres1 (snd ψ) IsRingHom.pres+ (snd ψ') = pres+ (snd ψ) IsRingHom.pres· (snd ψ') = pres· (snd ψ) IsRingHom.pres- (snd ψ') = pres- (snd ψ) ψ'r/1≡φr : ∀ r → fst ψ (r /1) ≡ fst φ r ψ'r/1≡φr r = fst ψ (r /1) ≡⟨ cong (fst ψ) (sym (·ₗ-rid _)) ⟩ fst ψ (_⋆_ (snd S⁻¹RAsCommAlg) r (1a (snd S⁻¹RAsCommAlg))) ≡⟨ pres⋆ (snd ψ) _ _ ⟩ _⋆_ (snd B') r (fst ψ (1a (snd S⁻¹RAsCommAlg))) ≡⟨ cong (_⋆_ (snd B') r) (pres1 (snd ψ)) ⟩ _⋆_ (snd B') r 1b ∎ -- an immediate corollary: isContrHomS⁻¹RS⁻¹R : isContr (CommAlgebraHom S⁻¹RAsCommAlg S⁻¹RAsCommAlg) isContrHomS⁻¹RS⁻¹R = S⁻¹RHasAlgUniversalProp S⁻¹RAsCommAlg S⋆1⊆S⁻¹Rˣ module AlgLocTwoSubsets (R' : CommRing ℓ) (S₁ : ℙ (fst R')) (S₁MultClosedSubset : isMultClosedSubset R' S₁) (S₂ : ℙ (fst R')) (S₂MultClosedSubset : isMultClosedSubset R' S₂) where open isMultClosedSubset open CommRingStr (snd R') hiding (is-set) open RingTheory (CommRing→Ring R') open Loc R' S₁ S₁MultClosedSubset renaming (S⁻¹R to S₁⁻¹R ; S⁻¹RAsCommRing to S₁⁻¹RAsCommRing) open Loc R' S₂ S₂MultClosedSubset renaming (S⁻¹R to S₂⁻¹R ; S⁻¹RAsCommRing to S₂⁻¹RAsCommRing) open AlgLoc R' S₁ S₁MultClosedSubset renaming ( S⁻¹RAsCommAlg to S₁⁻¹RAsCommAlg ; S⋆1⊆S⁻¹Rˣ to S₁⋆1⊆S₁⁻¹Rˣ ; S⁻¹RHasAlgUniversalProp to S₁⁻¹RHasAlgUniversalProp ; isContrHomS⁻¹RS⁻¹R to isContrHomS₁⁻¹RS₁⁻¹R) open AlgLoc R' S₂ S₂MultClosedSubset renaming ( S⁻¹RAsCommAlg to S₂⁻¹RAsCommAlg ; S⋆1⊆S⁻¹Rˣ to S₂⋆1⊆S₂⁻¹Rˣ ; S⁻¹RHasAlgUniversalProp to S₂⁻¹RHasAlgUniversalProp ; isContrHomS⁻¹RS⁻¹R to isContrHomS₂⁻¹RS₂⁻¹R) open IsAlgebraHom open CommAlgebraStr ⦃...⦄ private R = fst R' S₁⁻¹Rˣ = S₁⁻¹RAsCommRing ˣ S₂⁻¹Rˣ = S₂⁻¹RAsCommRing ˣ instance _ = snd S₁⁻¹RAsCommAlg _ = snd S₂⁻¹RAsCommAlg isContrS₁⁻¹R≡S₂⁻¹R : (∀ s₁ → s₁ ∈ S₁ → s₁ ⋆ 1a ∈ S₂⁻¹Rˣ) → (∀ s₂ → s₂ ∈ S₂ → s₂ ⋆ 1a ∈ S₁⁻¹Rˣ) → isContr (S₁⁻¹RAsCommAlg ≡ S₂⁻¹RAsCommAlg) isContrS₁⁻¹R≡S₂⁻¹R S₁⊆S₂⁻¹Rˣ S₂⊆S₁⁻¹Rˣ = isOfHLevelRetractFromIso 0 (equivToIso (invEquiv (CommAlgebraPath _ _ _))) isContrS₁⁻¹R≅S₂⁻¹R where χ₁ : CommAlgebraHom S₁⁻¹RAsCommAlg S₂⁻¹RAsCommAlg χ₁ = S₁⁻¹RHasAlgUniversalProp S₂⁻¹RAsCommAlg S₁⊆S₂⁻¹Rˣ .fst χ₂ : CommAlgebraHom S₂⁻¹RAsCommAlg S₁⁻¹RAsCommAlg χ₂ = S₂⁻¹RHasAlgUniversalProp S₁⁻¹RAsCommAlg S₂⊆S₁⁻¹Rˣ .fst χ₁∘χ₂≡id : χ₁ ∘a χ₂ ≡ idAlgHom χ₁∘χ₂≡id = isContr→isProp isContrHomS₂⁻¹RS₂⁻¹R _ _ χ₂∘χ₁≡id : χ₂ ∘a χ₁ ≡ idAlgHom χ₂∘χ₁≡id = isContr→isProp isContrHomS₁⁻¹RS₁⁻¹R _ _ IsoS₁⁻¹RS₂⁻¹R : Iso S₁⁻¹R S₂⁻¹R Iso.fun IsoS₁⁻¹RS₂⁻¹R = fst χ₁ Iso.inv IsoS₁⁻¹RS₂⁻¹R = fst χ₂ Iso.rightInv IsoS₁⁻¹RS₂⁻¹R = funExt⁻ (cong fst χ₁∘χ₂≡id) Iso.leftInv IsoS₁⁻¹RS₂⁻¹R = funExt⁻ (cong fst χ₂∘χ₁≡id) isContrS₁⁻¹R≅S₂⁻¹R : isContr (CommAlgebraEquiv S₁⁻¹RAsCommAlg S₂⁻¹RAsCommAlg) isContrS₁⁻¹R≅S₂⁻¹R = center , uniqueness where center : CommAlgebraEquiv S₁⁻¹RAsCommAlg S₂⁻¹RAsCommAlg fst center = isoToEquiv IsoS₁⁻¹RS₂⁻¹R pres0 (snd center) = pres0 (snd χ₁) pres1 (snd center) = pres1 (snd χ₁) pres+ (snd center) = pres+ (snd χ₁) pres· (snd center) = pres· (snd χ₁) pres- (snd center) = pres- (snd χ₁) pres⋆ (snd center) = pres⋆ (snd χ₁) uniqueness : (φ : CommAlgebraEquiv S₁⁻¹RAsCommAlg S₂⁻¹RAsCommAlg) → center ≡ φ uniqueness φ = Σ≡Prop (λ _ → isPropIsAlgebraHom _ _ _ _) (equivEq (cong fst (S₁⁻¹RHasAlgUniversalProp S₂⁻¹RAsCommAlg S₁⊆S₂⁻¹Rˣ .snd (AlgebraEquiv→AlgebraHom φ)))) isPropS₁⁻¹R≡S₂⁻¹R : isProp (S₁⁻¹RAsCommAlg ≡ S₂⁻¹RAsCommAlg) isPropS₁⁻¹R≡S₂⁻¹R S₁⁻¹R≡S₂⁻¹R = isContr→isProp (isContrS₁⁻¹R≡S₂⁻¹R S₁⊆S₂⁻¹Rˣ S₂⊆S₁⁻¹Rˣ) S₁⁻¹R≡S₂⁻¹R where S₁⊆S₂⁻¹Rˣ : ∀ s₁ → s₁ ∈ S₁ → s₁ ⋆ 1a ∈ S₂⁻¹Rˣ S₁⊆S₂⁻¹Rˣ s₁ s₁∈S₁ = transport (λ i → _⋆_ ⦃ S₁⁻¹R≡S₂⁻¹R i .snd ⦄ s₁ (1a ⦃ S₁⁻¹R≡S₂⁻¹R i .snd ⦄) ∈ (CommAlgebra→CommRing (S₁⁻¹R≡S₂⁻¹R i)) ˣ) (S₁⋆1⊆S₁⁻¹Rˣ s₁ s₁∈S₁) S₂⊆S₁⁻¹Rˣ : ∀ s₂ → s₂ ∈ S₂ → s₂ ⋆ 1a ∈ S₁⁻¹Rˣ S₂⊆S₁⁻¹Rˣ s₂ s₂∈S₂ = transport (λ i → _⋆_ ⦃ (sym S₁⁻¹R≡S₂⁻¹R) i .snd ⦄ s₂ (1a ⦃ (sym S₁⁻¹R≡S₂⁻¹R) i .snd ⦄) ∈ (CommAlgebra→CommRing ((sym S₁⁻¹R≡S₂⁻¹R) i)) ˣ) (S₂⋆1⊆S₂⁻¹Rˣ s₂ s₂∈S₂)
{ "alphanum_fraction": 0.6072752549, "avg_line_length": 39.5963302752, "ext": "agda", "hexsha": "a0d9ecaab474f10660b3b714584589b226bebbe1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/Localisation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lpw25/cubical", "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/Localisation.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Localisation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3976, "size": 8632 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The identity function ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Function.Construct.Composition where open import Data.Product using (_,_) open import Function open import Level open import Relation.Binary private variable a b c ℓ₁ ℓ₂ ℓ₃ : Level A : Set a B : Set b C : Set c ------------------------------------------------------------------------ -- Properties module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) (≈₃ : Rel C ℓ₃) {f : A → B} {g : B → C} where congruent : Congruent ≈₁ ≈₂ f → Congruent ≈₂ ≈₃ g → Congruent ≈₁ ≈₃ (g ∘ f) congruent f-cong g-cong = g-cong ∘ f-cong injective : Injective ≈₁ ≈₂ f → Injective ≈₂ ≈₃ g → Injective ≈₁ ≈₃ (g ∘ f) injective f-inj g-inj = f-inj ∘ g-inj surjective : Transitive ≈₃ → Congruent ≈₂ ≈₃ g → Surjective ≈₁ ≈₂ f → Surjective ≈₂ ≈₃ g → Surjective ≈₁ ≈₃ (g ∘ f) surjective trans g-cong f-sur g-sur x with g-sur x ... | y , fy≈x with f-sur y ... | z , fz≈y = z , trans (g-cong fz≈y) fy≈x bijective : Transitive ≈₃ → Congruent ≈₂ ≈₃ g → Bijective ≈₁ ≈₂ f → Bijective ≈₂ ≈₃ g → Bijective ≈₁ ≈₃ (g ∘ f) bijective trans g-cong (f-inj , f-sur) (g-inj , g-sur) = injective f-inj g-inj , surjective trans g-cong f-sur g-sur module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) (≈₃ : Rel C ℓ₃) (f : A → B) {f⁻¹ : B → A} {g : B → C} (g⁻¹ : C → B) where inverseˡ : Transitive ≈₃ → Congruent ≈₂ ≈₃ g → Inverseˡ ≈₁ ≈₂ f f⁻¹ → Inverseˡ ≈₂ ≈₃ g g⁻¹ → Inverseˡ ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹) inverseˡ trn g-cong f-inv g-inv x = trn (g-cong (f-inv _)) (g-inv x) inverseʳ : Transitive ≈₁ → Congruent ≈₂ ≈₁ f⁻¹ → Inverseʳ ≈₁ ≈₂ f f⁻¹ → Inverseʳ ≈₂ ≈₃ g g⁻¹ → Inverseʳ ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹) inverseʳ trn f⁻¹-cong f-inv g-inv x = trn (f⁻¹-cong (g-inv _)) (f-inv x) inverseᵇ : Transitive ≈₁ → Transitive ≈₃ → Congruent ≈₂ ≈₃ g → Congruent ≈₂ ≈₁ f⁻¹ → Inverseᵇ ≈₁ ≈₂ f f⁻¹ → Inverseᵇ ≈₂ ≈₃ g g⁻¹ → Inverseᵇ ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹) inverseᵇ trn₁ trn₃ g-cong f⁻¹-cong (f-invˡ , f-invʳ) (g-invˡ , g-invʳ) = inverseˡ trn₃ g-cong f-invˡ g-invˡ , inverseʳ trn₁ f⁻¹-cong f-invʳ g-invʳ ------------------------------------------------------------------------ -- Structures module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {≈₃ : Rel C ℓ₃} {f : A → B} {g : B → C} where isCongruent : IsCongruent ≈₁ ≈₂ f → IsCongruent ≈₂ ≈₃ g → IsCongruent ≈₁ ≈₃ (g ∘ f) isCongruent f-cong g-cong = record { cong = G.cong ∘ F.cong ; isEquivalence₁ = F.isEquivalence₁ ; isEquivalence₂ = G.isEquivalence₂ } where module F = IsCongruent f-cong; module G = IsCongruent g-cong isInjection : IsInjection ≈₁ ≈₂ f → IsInjection ≈₂ ≈₃ g → IsInjection ≈₁ ≈₃ (g ∘ f) isInjection f-inj g-inj = record { isCongruent = isCongruent F.isCongruent G.isCongruent ; injective = injective ≈₁ ≈₂ ≈₃ F.injective G.injective } where module F = IsInjection f-inj; module G = IsInjection g-inj isSurjection : IsSurjection ≈₁ ≈₂ f → IsSurjection ≈₂ ≈₃ g → IsSurjection ≈₁ ≈₃ (g ∘ f) isSurjection f-surj g-surj = record { isCongruent = isCongruent F.isCongruent G.isCongruent ; surjective = surjective ≈₁ ≈₂ ≈₃ G.Eq₂.trans G.cong F.surjective G.surjective } where module F = IsSurjection f-surj; module G = IsSurjection g-surj isBijection : IsBijection ≈₁ ≈₂ f → IsBijection ≈₂ ≈₃ g → IsBijection ≈₁ ≈₃ (g ∘ f) isBijection f-bij g-bij = record { isInjection = isInjection F.isInjection G.isInjection ; surjective = surjective ≈₁ ≈₂ ≈₃ G.Eq₂.trans G.cong F.surjective G.surjective } where module F = IsBijection f-bij; module G = IsBijection g-bij module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {≈₃ : Rel C ℓ₃} {f : A → B} {g : B → C} {f⁻¹ : B → A} {g⁻¹ : C → B} where isLeftInverse : IsLeftInverse ≈₁ ≈₂ f f⁻¹ → IsLeftInverse ≈₂ ≈₃ g g⁻¹ → IsLeftInverse ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹) isLeftInverse f-invˡ g-invˡ = record { isCongruent = isCongruent F.isCongruent G.isCongruent ; cong₂ = congruent ≈₃ ≈₂ ≈₁ G.cong₂ F.cong₂ ; inverseˡ = inverseˡ ≈₁ ≈₂ ≈₃ f _ G.Eq₂.trans G.cong₁ F.inverseˡ G.inverseˡ } where module F = IsLeftInverse f-invˡ; module G = IsLeftInverse g-invˡ isRightInverse : IsRightInverse ≈₁ ≈₂ f f⁻¹ → IsRightInverse ≈₂ ≈₃ g g⁻¹ → IsRightInverse ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹) isRightInverse f-invʳ g-invʳ = record { isCongruent = isCongruent F.isCongruent G.isCongruent ; cong₂ = congruent ≈₃ ≈₂ ≈₁ G.cong₂ F.cong₂ ; inverseʳ = inverseʳ ≈₁ ≈₂ ≈₃ _ g⁻¹ F.Eq₁.trans F.cong₂ F.inverseʳ G.inverseʳ } where module F = IsRightInverse f-invʳ; module G = IsRightInverse g-invʳ isInverse : IsInverse ≈₁ ≈₂ f f⁻¹ → IsInverse ≈₂ ≈₃ g g⁻¹ → IsInverse ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹) isInverse f-inv g-inv = record { isLeftInverse = isLeftInverse F.isLeftInverse G.isLeftInverse ; inverseʳ = inverseʳ ≈₁ ≈₂ ≈₃ _ g⁻¹ F.Eq₁.trans F.cong₂ F.inverseʳ G.inverseʳ } where module F = IsInverse f-inv; module G = IsInverse g-inv ------------------------------------------------------------------------ -- Setoid bundles module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} {T : Setoid c ℓ₃} where open Setoid renaming (_≈_ to ≈) injection : Injection R S → Injection S T → Injection R T injection inj₁ inj₂ = record { f = G.f ∘ F.f ; cong = congruent (≈ R) (≈ S) (≈ T) F.cong G.cong ; injective = injective (≈ R) (≈ S) (≈ T) F.injective G.injective } where module F = Injection inj₁; module G = Injection inj₂ surjection : Surjection R S → Surjection S T → Surjection R T surjection surj₁ surj₂ = record { f = G.f ∘ F.f ; cong = congruent (≈ R) (≈ S) (≈ T) F.cong G.cong ; surjective = surjective (≈ R) (≈ S) (≈ T) G.Eq₂.trans G.cong F.surjective G.surjective } where module F = Surjection surj₁; module G = Surjection surj₂ bijection : Bijection R S → Bijection S T → Bijection R T bijection bij₁ bij₂ = record { f = G.f ∘ F.f ; cong = congruent (≈ R) (≈ S) (≈ T) F.cong G.cong ; bijective = bijective (≈ R) (≈ S) (≈ T) (trans T) G.cong F.bijective G.bijective } where module F = Bijection bij₁; module G = Bijection bij₂ equivalence : Equivalence R S → Equivalence S T → Equivalence R T equivalence equiv₁ equiv₂ = record { f = G.f ∘ F.f ; g = F.g ∘ G.g ; cong₁ = congruent (≈ R) (≈ S) (≈ T) F.cong₁ G.cong₁ ; cong₂ = congruent (≈ T) (≈ S) (≈ R) G.cong₂ F.cong₂ } where module F = Equivalence equiv₁; module G = Equivalence equiv₂ leftInverse : LeftInverse R S → LeftInverse S T → LeftInverse R T leftInverse invˡ₁ invˡ₂ = record { f = G.f ∘ F.f ; g = F.g ∘ G.g ; cong₁ = congruent (≈ R) (≈ S) (≈ T) F.cong₁ G.cong₁ ; cong₂ = congruent (≈ T) (≈ S) (≈ R) G.cong₂ F.cong₂ ; inverseˡ = inverseˡ (≈ R) (≈ S) (≈ T) F.f _ (trans T) G.cong₁ F.inverseˡ G.inverseˡ } where module F = LeftInverse invˡ₁; module G = LeftInverse invˡ₂ rightInverse : RightInverse R S → RightInverse S T → RightInverse R T rightInverse invʳ₁ invʳ₂ = record { f = G.f ∘ F.f ; g = F.g ∘ G.g ; cong₁ = congruent (≈ R) (≈ S) (≈ T) F.cong₁ G.cong₁ ; cong₂ = congruent (≈ T) (≈ S) (≈ R) G.cong₂ F.cong₂ ; inverseʳ = inverseʳ (≈ R) (≈ S) (≈ T) _ G.g (trans R) F.cong₂ F.inverseʳ G.inverseʳ } where module F = RightInverse invʳ₁; module G = RightInverse invʳ₂ inverse : Inverse R S → Inverse S T → Inverse R T inverse inv₁ inv₂ = record { f = G.f ∘ F.f ; f⁻¹ = F.f⁻¹ ∘ G.f⁻¹ ; cong₁ = congruent (≈ R) (≈ S) (≈ T) F.cong₁ G.cong₁ ; cong₂ = congruent (≈ T) (≈ S) (≈ R) G.cong₂ F.cong₂ ; inverse = inverseᵇ (≈ R) (≈ S) (≈ T) _ G.f⁻¹ (trans R) (trans T) G.cong₁ F.cong₂ F.inverse G.inverse } where module F = Inverse inv₁; module G = Inverse inv₂ ------------------------------------------------------------------------ -- Propositional bundles infix 8 _∘-↣_ _∘-↠_ _∘-⤖_ _∘-⇔_ _∘-↩_ _∘-↪_ _∘-↔_ _∘-↣_ : A ↣ B → B ↣ C → A ↣ C _∘-↣_ = injection _∘-↠_ : A ↠ B → B ↠ C → A ↠ C _∘-↠_ = surjection _∘-⤖_ : A ⤖ B → B ⤖ C → A ⤖ C _∘-⤖_ = bijection _∘-⇔_ : A ⇔ B → B ⇔ C → A ⇔ C _∘-⇔_ = equivalence _∘-↩_ : A ↩ B → B ↩ C → A ↩ C _∘-↩_ = leftInverse _∘-↪_ : A ↪ B → B ↪ C → A ↪ C _∘-↪_ = rightInverse _∘-↔_ : A ↔ B → B ↔ C → A ↔ C _∘-↔_ = inverse
{ "alphanum_fraction": 0.5419318182, "avg_line_length": 39.4618834081, "ext": "agda", "hexsha": "ae8cbd09b78876a0d3ae4f112ca5a8a6f9276c51", "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/Function/Construct/Composition.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/Function/Construct/Composition.agda", "max_line_length": 106, "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/Function/Construct/Composition.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": 3670, "size": 8800 }
{-# OPTIONS --cubical --no-import-sorts #-} module MorePropAlgebra.Bundles where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) private variable ℓ ℓ' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_ open import Cubical.Foundations.Logic open import MoreLogic.Definitions open import Utils open import MorePropAlgebra.Structures -- taken from the cubical standard library and adapted to hProps: -- Semigroup -- Monoid -- Group -- AbGroup -- Ring -- CommRing record Semigroup : Type (ℓ-suc ℓ) where constructor semigroup field Carrier : Type ℓ _·_ : Carrier → Carrier → Carrier is-Semigroup : IsSemigroup _·_ infixl 7 _·_ open IsSemigroup is-Semigroup public record Monoid : Type (ℓ-suc ℓ) where constructor monoid field Carrier : Type ℓ ε : Carrier _·_ : Carrier → Carrier → Carrier is-Monoid : IsMonoid ε _·_ infixl 7 _·_ open IsMonoid is-Monoid public record Group : Type (ℓ-suc ℓ) where constructor group field Carrier : Type ℓ 0g : Carrier _+_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier is-Group : IsGroup 0g _+_ -_ infix 8 -_ infixr 7 _+_ open IsGroup is-Group public record AbGroup : Type (ℓ-suc ℓ) where constructor abgroup field Carrier : Type ℓ 0g : Carrier _+_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier is-AbGroup : IsAbGroup 0g _+_ -_ infix 8 -_ infixl 7 _+_ open IsAbGroup is-AbGroup public record Ring : Type (ℓ-suc ℓ) where constructor ring field Carrier : Type ℓ 0r : Carrier 1r : Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier is-Ring : IsRing 0r 1r _+_ _·_ -_ infix 8 -_ infixl 7 _·_ infixl 6 _+_ open IsRing is-Ring public record CommRing : Type (ℓ-suc ℓ) where constructor commring field Carrier : Type ℓ 0r : Carrier 1r : Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier is-CommRing : IsCommRing 0r 1r _+_ _·_ -_ infix 8 -_ infixl 7 _·_ infixl 6 _+_ open IsCommRing is-CommRing public record ClassicalField : Type (ℓ-suc ℓ) where field Carrier : Type ℓ 0f : Carrier 1f : Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _⁻¹ : (x : Carrier) → {{ ! ¬ᵗ(x ≡ 0f) }} → Carrier -- WARNING: we do not have `_⁻¹` as an assuption is-ClassicalField : [ isClassicalField 0f 1f _+_ _·_ -_ _⁻¹ ] infix 9 _⁻¹ infix 8 -_ infixl 7 _·_ infixl 6 _+_ open IsClassicalField is-ClassicalField public record ConstructiveField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor constructivefield field Carrier : Type ℓ 0f : Carrier 1f : Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _#_ : hPropRel Carrier Carrier ℓ' is-ConstructiveField : [ isConstructiveField 0f 1f _+_ _·_ -_ _#_ ] infixl 7 _·_ infix 6 -_ infixl 5 _+_ infixl 4 _#_ open IsConstructiveField is-ConstructiveField public record Lattice : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor lattice field Carrier : Type ℓ _≤_ : hPropRel Carrier Carrier ℓ' min max : Carrier → Carrier → Carrier is-Lattice : [ isLattice _≤_ min max ] infixl 4 _≤_ open IsLattice is-Lattice public record AlmostPartiallyOrderedField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor almostpartiallyorderedfield field Carrier : Type ℓ 0f 1f : Carrier _+_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _·_ : Carrier → Carrier → Carrier min max : Carrier → Carrier → Carrier _<_ : hPropRel Carrier Carrier ℓ' field is-AlmostPartiallyOrderedField : [ isAlmostPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ -} ] -- defines `_≤_` and `_#_` infixl 7 _·_ infix 6 -_ infixl 5 _+_ infixl 4 _<_ open IsAlmostPartiallyOrderedField is-AlmostPartiallyOrderedField public record PartiallyOrderedField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor partiallyorderedfield field Carrier : Type ℓ 0f 1f : Carrier _+_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _·_ : Carrier → Carrier → Carrier min max : Carrier → Carrier → Carrier _<_ : hPropRel Carrier Carrier ℓ' field is-PartiallyOrderedField : [ isPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max ] -- defines `_≤_` and `_#_` infixl 7 _·_ infix 6 -_ infixl 5 _+_ infixl 4 _<_ open IsPartiallyOrderedField is-PartiallyOrderedField public -- abstract -- -- NOTE: there might be some reason not to "do" (or "open") all the theory of a record within that record -- +-preserves-< : ∀ a b x → a < b → a + x < b + x -- +-preserves-< a b x a<b = ( -- a < b ⇒⟨ transport (λ i → sym (fst (+-identity a)) i < sym (fst (+-identity b)) i) ⟩ -- a + 0f < b + 0f ⇒⟨ transport (λ i → a + sym (+-rinv x) i < b + sym (+-rinv x) i) ⟩ -- a + (x - x) < b + (x - x) ⇒⟨ transport (λ i → +-assoc a x (- x) i < +-assoc b x (- x) i) ⟩ -- (a + x) - x < (b + x) - x ⇒⟨ +-<-extensional (- x) (a + x) (- x) (b + x) ⟩ -- (a + x < b + x) ⊎ (- x < - x) ⇒⟨ (λ{ (inl a+x<b+x) → a+x<b+x -- somehow ⊥-elim needs a hint in the next line -- ; (inr -x<-x ) → ⊥-elim {A = λ _ → (a + x < b + x)} (<-irrefl (- x) -x<-x) }) ⟩ -- a + x < b + x ◼) a<b -- -- ≤-isPreorder : IsPreorder _≤_ -- ≤-isPreorder = ≤-isPreorder' {_<_ = _<_} {<-isStrictPartialOrder}
{ "alphanum_fraction": 0.5929439175, "avg_line_length": 27.9488372093, "ext": "agda", "hexsha": "fc106ce38fe4dadfe6059ec9a239badeff251b27", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MorePropAlgebra/Bundles.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MorePropAlgebra/Bundles.agda", "max_line_length": 136, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MorePropAlgebra/Bundles.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 2105, "size": 6009 }
-- Andreas, 2018-11-23, 2019-07-22, issue #3353 -- -- Preserved names of named arguments under case splitting. -- {-# OPTIONS -v tc.lhs:40 #-} -- {-# OPTIONS -v interaction.case:60 -v reify:30 #-} open import Agda.Builtin.Nat test : {m n : Nat} → Nat test {m} {n = n} = {!n!} -- C-c C-c -- Splitting on n gives: -- test {m} {zero} = {!!} -- test {m} {suc n} = {!!} -- Expected: -- test {m} {n = zero} = {!!} -- test {m} {n = suc n} = {!!} data Vec (A : Set) : Nat → Set where _∷_ : ∀{n} (x : A) (xs : Vec A n) → Vec A (suc n) foo : ∀{A n} → Vec A n → Vec A n foo (_∷_ {n = n} x xs) = {!n!} -- C-c C-c -- Expected: -- foo (_∷_ {n = suc n} x xs) = {!!}
{ "alphanum_fraction": 0.5007541478, "avg_line_length": 22.8620689655, "ext": "agda", "hexsha": "357c59b16c9c35221ec6aeff8f40579dc60dbad2", "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/Issue3353.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/Issue3353.agda", "max_line_length": 59, "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/Issue3353.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": 272, "size": 663 }
-- mathematical integers; see int.agda for imported machine integers from Haskell. module integer where open import bool open import bool-thms2 open import eq open import nat open import nat-thms open import product open import product-thms open import sum open import unit ℤ-pos-t : ℕ → Set ℤ-pos-t 0 = ⊤ ℤ-pos-t (suc _) = 𝔹 {- In mkℤ n a, the argument a tells whether the integer is positive or negative, if n is nonzero. If n is zero, then a is just triv : ⊤, so there is a unique integer value for 0. -} data ℤ : Set where mkℤ : (n : ℕ) → ℤ-pos-t n → ℤ 0ℤ : ℤ 0ℤ = mkℤ 0 triv 1ℤ : ℤ 1ℤ = mkℤ 1 tt -1ℤ : ℤ -1ℤ = mkℤ 1 ff abs-val : ℤ → ℕ abs-val (mkℤ n _) = n is-evenℤ : ℤ → 𝔹 is-evenℤ (mkℤ n _) = is-even n is-oddℤ : ℤ → 𝔹 is-oddℤ (mkℤ n _) = is-odd n {- subtract the second natural number from the first, returning an integer. This is mostly a helper for _+ℤ_ -} diffℤ : ℕ → ℕ → ℤ diffℤ n m with ℕ-trichotomy n m diffℤ n m | inj₁ p with <∸suc{m}{n} p -- n < m diffℤ n m | inj₁ p | x , _ = mkℤ (suc x) ff diffℤ n m | inj₂ (inj₁ p) = mkℤ 0 triv -- n = m diffℤ n m | inj₂ (inj₂ p) with <∸suc{n}{m} p diffℤ n m | inj₂ (inj₂ p) | x , _ = mkℤ (suc x) tt -- m < n _+ℤ_ : ℤ → ℤ → ℤ (mkℤ 0 _) +ℤ x = x x +ℤ (mkℤ 0 _) = x (mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) with p1 xor p2 (mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | ff = mkℤ (suc n + suc m) p1 (mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | tt = if p1 imp p2 then diffℤ m n else diffℤ n m test-+ℤ1 : (mkℤ 2 ff) +ℤ (mkℤ 4 tt) ≡ (mkℤ 2 tt) test-+ℤ1 = refl test-+ℤ2 : (mkℤ 2 tt) +ℤ (mkℤ 4 ff) ≡ (mkℤ 2 ff) test-+ℤ2 = refl _≤ℤ_ : ℤ → ℤ → 𝔹 (mkℤ 0 triv) ≤ℤ (mkℤ 0 triv) = tt (mkℤ 0 triv) ≤ℤ (mkℤ (suc _) pos) = pos (mkℤ (suc _) pos) ≤ℤ (mkℤ 0 triv) = ~ pos (mkℤ (suc x) pos1) ≤ℤ (mkℤ (suc y) pos2) with pos1 xor pos2 (mkℤ (suc x) pos1) ≤ℤ (mkℤ (suc y) pos2) | tt = pos1 imp pos2 (mkℤ (suc x) pos1) ≤ℤ (mkℤ (suc y) pos2) | ff = if pos1 then x ≤ y else y ≤ x ≤ℤ-antisymm : ∀(x y : ℤ) → x ≤ℤ y ≡ tt → y ≤ℤ x ≡ tt → x ≡ y ≤ℤ-antisymm (mkℤ zero triv) (mkℤ zero triv) p q = refl ≤ℤ-antisymm (mkℤ zero triv) (mkℤ (suc y) pos2) p q rewrite p with q ≤ℤ-antisymm (mkℤ zero triv) (mkℤ (suc y) pos2) p q | () ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ zero triv) p q rewrite q with p ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ zero triv) p q | () ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q with keep (pos1 xor pos2) ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | tt , rp rewrite rp | xor-comm pos1 pos2 | rp with imp-antisymm{pos1} p q ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | tt , rp | pp rewrite pp | xor-anti-idem pos2 with rp ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | tt , rp | pp | () ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | ff , rp rewrite rp | xor-comm pos1 pos2 | rp | xor-≡{pos2}rp with pos1 ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | ff , rp | tt rewrite ≤-antisym{x} p q = refl ≤ℤ-antisymm (mkℤ (suc x) pos1) (mkℤ (suc y) pos2) p q | ff , rp | ff rewrite ≤-antisym{y} p q = refl
{ "alphanum_fraction": 0.598679868, "avg_line_length": 35.2325581395, "ext": "agda", "hexsha": "24b8630d5b930a67e5128584a927627d8841247f", "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": "integer.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": "integer.agda", "max_line_length": 129, "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": "integer.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": 1522, "size": 3030 }
{-# OPTIONS --rewriting --prop --confluence-check #-} open import Agda.Primitive open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite open import Agda.Builtin.Sigma open import Agda.Builtin.Unit open import Data.Vec.Base open import Data.Bool open import Data.Sum variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level {- Axiomatisation of ExTT -} postulate raise : (A : Set ℓ) → A -- we now state rewrite rules for raise postulate raise-Pi : (A : Set ℓ) (B : A → Set ℓ₁) → raise ((a : A) → B a) ≡ λ a → raise (B a) {-# REWRITE raise-Pi #-} postulate raise-Sigma : (A : Set ℓ) (B : A → Set ℓ₁) → raise (Σ A B) ≡ (raise A , raise (B (raise A))) {-# REWRITE raise-Sigma #-} nat-rec : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (n : Nat) → P n nat-rec P P0 PS zero = P0 nat-rec P P0 PS (suc n) = PS n (nat-rec P P0 PS n) postulate raise-nat-rec : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → nat-rec P P0 PS (raise Nat) ≡ raise (P (raise Nat)) {-# REWRITE raise-nat-rec #-} postulate catch-nat : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → (n : Nat) → P n postulate catch-nat-zero : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → catch-nat P P0 PS Praise 0 ≡ P0 postulate catch-nat-suc : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → (n : Nat) → catch-nat P P0 PS Praise (suc n) ≡ PS n (catch-nat P P0 PS Praise n) postulate catch-nat-raise : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → catch-nat P P0 PS Praise (raise Nat) ≡ Praise {-# REWRITE catch-nat-zero #-} {-# REWRITE catch-nat-suc #-} {-# REWRITE catch-nat-raise #-} record Unk ℓ : Set (lsuc ℓ) where constructor box field type : Set ℓ elem : type postulate raise-Unk : ∀ ℓ → raise (Unk ℓ) ≡ box (raise (Set ℓ)) (raise _) {-# REWRITE raise-Unk #-}
{ "alphanum_fraction": 0.5425812116, "avg_line_length": 32.0845070423, "ext": "agda", "hexsha": "c2b923af194b56e7dbda99101998847720c54cc8", "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": "77e54713836af48f5f8091373ae888feadc3d077", "max_forks_repo_licenses": [ "WTFPL" ], "max_forks_repo_name": "kyoDralliam/exceptional-tt", "max_forks_repo_path": "agda-rr/ett-rr.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "77e54713836af48f5f8091373ae888feadc3d077", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "WTFPL" ], "max_issues_repo_name": "kyoDralliam/exceptional-tt", "max_issues_repo_path": "agda-rr/ett-rr.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "77e54713836af48f5f8091373ae888feadc3d077", "max_stars_repo_licenses": [ "WTFPL" ], "max_stars_repo_name": "kyoDralliam/exceptional-tt", "max_stars_repo_path": "agda-rr/ett-rr.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 816, "size": 2278 }
module m-types where -- Basic definitions import container.core -- Construction of M-types as limits import container.m.from-nat -- M-types via Agda coinduction import container.m.core
{ "alphanum_fraction": 0.7819148936, "avg_line_length": 17.0909090909, "ext": "agda", "hexsha": "114f191b4b5983771bff621b8e6c15d10636f523", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "m-types.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "m-types.agda", "max_line_length": 36, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "m-types.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 43, "size": 188 }
module Data.Vec.Any.Membership.Propositional.Properties where open import Algebra open import Data.Vec as Vec open import Data.Vec.Any open import Data.Vec.Any.Membership.Propositional open import Data.Vec.Any.Properties import Data.Vec.Any.Membership.Properties as Membershipᵖ open import Function open import Function.Inverse as Inv using (_↔_) import Function.Related as Related open import Function.Related.TypeIsomorphisms open import Relation.Binary.PropositionalEquality as P import Relation.Binary.Sigma.Pointwise as Σ open import Relation.Unary using (_⟨×⟩_) open import Data.Product private module ×⊎ {k ℓ} = CommutativeSemiring (×⊎-CommutativeSemiring k ℓ) -- map module _ {a b} {A : Set a} {B : Set b} {f : A → B} where ∈′-map⁺ : ∀ {n x}{xs : Vec A n} → x ∈′ xs → f x ∈′ Vec.map f xs ∈′-map⁺ = Membershipᵖ.∈′-map⁺ (P.setoid _) (P.setoid _) (P.cong f) ∈′-map⁻ : ∀ {n y}{xs : Vec A n} → y ∈′ Vec.map f xs → ∃ λ x → x ∈′ xs × y ≡ f x ∈′-map⁻ = Membershipᵖ.∈′-map⁻ (P.setoid _) (P.setoid _) map-∈′↔ : ∀ {n y}{xs : Vec A n} → (∃ λ x → x ∈′ xs × y ≡ f x) ↔ y ∈′ Vec.map f xs map-∈′↔ {n}{y}{xs} = (∃ λ x → x ∈′ xs × y ≡ f x) ↔⟨ Any↔ ⟩ Any (λ x → y ≡ f x) xs ↔⟨ map↔ ⟩ y ∈′ Vec.map f xs ∎ where open Related.EquationalReasoning
{ "alphanum_fraction": 0.6306027821, "avg_line_length": 32.35, "ext": "agda", "hexsha": "def8beb0d3af3c2344973483f7234d7c03224db4", "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": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-vector-any", "max_forks_repo_path": "src/Data/Vec/Any/Membership/Propositional/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "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": "tizmd/agda-vector-any", "max_issues_repo_path": "src/Data/Vec/Any/Membership/Propositional/Properties.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-vector-any", "max_stars_repo_path": "src/Data/Vec/Any/Membership/Propositional/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 486, "size": 1294 }
{-# OPTIONS --cubical #-} module _ where module _ where open import Agda.Primitive.Cubical public postulate Path' : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ {-# BUILTIN PATH Path' #-} {-# BUILTIN PATHP PathP #-} infix 4 _≡_ _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ _≡_ {A = A} = PathP (λ _ → A) Path = _≡_ refl : ∀ {a} {A : Set a} {x : A} → x ≡ x refl {x = x} = \ _ → x -- Here there's no solution for H, pattern unification will try -- H := \ i -> b, but the equality constraints from -- H : Path b a should rule out that assignment. testPath : ∀ {A : Set} {b a : A} (let H : Path b a; H = _) → ∀ i → H i ≡ b testPath i = refl
{ "alphanum_fraction": 0.5047233468, "avg_line_length": 25.5517241379, "ext": "agda", "hexsha": "1b85f19a4da045bd7fa0949cf4dd114973be94b3", "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/Fail/Issue2650.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/Fail/Issue2650.agda", "max_line_length": 74, "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/Fail/Issue2650.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": 294, "size": 741 }
module Generic.Test.ReadData where open import Generic.Main data D {α β} (A : Set α) (B : ℕ -> Set β) : ∀ {n} -> B n -> List ℕ -> Set (α ⊔ β) where c₁ : ∀ {n} (y : B n) xs -> A -> D A B y xs c₂ : ∀ {y : B 0} -> (∀ {n} (y : B n) {{xs}} -> D A B y xs) -> .(List A) -> D A B y [] -- No longer works: Failed to solve the following constraints: Has bigger sort: Setω -- D′ : TypeOf D D′ : ∀ {α β} -> (A : Set α) -> (B : ℕ -> Set β) -> ∀ {n} -> B n -> List ℕ -> Set (α ⊔ β) D′ = readData D unquoteDecl foldD = deriveFoldTo foldD (quote D) inj : ∀ {α β} {A : Set α} {B : ℕ -> Set β} {n xs} {y : B n} -> D A B y xs -> D′ A B y xs inj = gcoerce foldD outj : ∀ {α β} {A : Set α} {B : ℕ -> Set β} {n xs} {y : B n} -> D′ A B y xs -> D A B y xs outj d = guncoerce d pattern c₁′ {n} y xs x = #₀ (relv n , relv y , relv xs , relv x , lrefl) pattern c₂′ {y} r ys = !#₁ (relv y , r , irrv ys , lrefl) inj′ : ∀ {α β} {A : Set α} {B : ℕ -> Set β} {n xs} {y : B n} -> D A B y xs -> D′ A B y xs inj′ (c₁ y xs x) = c₁′ y xs x inj′ (c₂ r ys) = c₂′ (λ y -> inj′ (r y)) ys outj′ : ∀ {α β} {A : Set α} {B : ℕ -> Set β} {n xs} {y : B n} -> D′ A B y xs -> D A B y xs outj′ (c₁′ y xs x) = c₁ y xs x outj′ (c₂′ r ys) = c₂ (λ y -> outj′ (r y)) ys
{ "alphanum_fraction": 0.4765372168, "avg_line_length": 38.625, "ext": "agda", "hexsha": "c1fe5e77062963fc51ab92ef8dcede9aefe3684a", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Test/ReadData.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Test/ReadData.agda", "max_line_length": 90, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Test/ReadData.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 572, "size": 1236 }
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite postulate A : Set a b : A f : (X : Set) → X → A g : (X : Set) → X rewf₁ : f (A → A) (λ _ → a) ≡ a rewf₂ : (X : Set) → f X (g X) ≡ b rewg : (x : A) → g (A → A) x ≡ a test = f (A → A) (λ x → g (A → A) x) {-# REWRITE rewf₁ rewg #-} foo : test ≡ a foo = refl {-# REWRITE rewf₂ #-} bar : test ≡ b bar = refl fails : a ≡ b fails = refl
{ "alphanum_fraction": 0.5209205021, "avg_line_length": 14.9375, "ext": "agda", "hexsha": "b08eb9b79cdd66e9d350888c749900ccff372394", "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/Issue3810b.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/Issue3810b.agda", "max_line_length": 46, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue3810b.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": 201, "size": 478 }
open import Data.Nat open import Data.List as List hiding (null) open import Data.List.Membership.Propositional open import Data.List.Relation.Unary.Any open import Data.List.Relation.Unary.All open import Data.List.Prefix open import Data.Integer open import Data.Product -- This file contains the definition of values for the definitional -- interpreter for MJ using scopes and frames, described in Section 5 -- of the paper. module MJSF.Values (k : ℕ) where open import MJSF.Syntax k open import ScopesFrames.ScopesFrames k Ty module ValuesG (g : Graph) where open SyntaxG g open UsesGraph g public open import Common.Weakening ------------ -- VALUES -- ------------ -- The values used in our interpreter at run time are either: -- -- * object references `ref`, represented in terms of a frame scoped -- by a class scope; -- -- * null values (`ref` typed); -- -- * an integer number literal (`int` typed); or -- -- * `void` (`void typed -- note that there is no expression syntax -- for producing a `void` value directly, but method bodies still -- return `void`; we regard `void` as a unit type) data Val : VTy → List Scope → Set where ref : ∀ {s s' Σ} → s <: s' → Frame s Σ → Val (ref s') Σ null : ∀ {s Σ} → Val (ref s) Σ num : ∀ {Σ} → ℤ → Val int Σ void : ∀ {Σ} → Val void Σ -- There are three kinds of values stored in frame slots at run -- time, corresponding to each of the three kinds of declarations -- defined in `MJSF.Syntax`: -- -- * values, as defined above; -- -- * methods, where a method records a "self" frame `Frame s Σ` and -- a well-typed method definition `Meth s ts rt`, such that the -- scope of the method corresponds to the "self"; and -- -- * classes which record a well-typed class definition and a -- witness that the class has a finite inheritance chain, both -- used for initializing new object instances, as well as a frame -- pointer to the root frame (class table). data Valᵗ : Ty → List Scope → Set where vᵗ : ∀ {t Σ} → Val t Σ → Valᵗ (vᵗ t) Σ mᵗ : ∀ {s ts rt Σ} → (self : Frame s Σ) → (body : Meth s ts rt) → Valᵗ (mᵗ ts rt) Σ cᵗ : ∀ {sʳ s s' Σ} → (class-def : Class sʳ s) → (ic : Inherits s s') → (root : Frame sʳ Σ) → Valᵗ (cᵗ sʳ s) Σ --------------- -- WEAKENING -- --------------- -- We define notions of weakening for each of the values summarized above: val-weaken : ∀ {t Σ Σ'} → Σ ⊑ Σ' → Val t Σ → Val t Σ' val-weaken ext (num i) = num i val-weaken ext (ref i f) = ref i (wk ext f) val-weaken ext null = null val-weaken ext void = void instance val-weakenable : ∀ {t} → Weakenable (Val t) val-weakenable = record { wk = val-weaken } valᵗ-weaken : ∀ {t Σ Σ'} → Σ ⊑ Σ' → Valᵗ t Σ → Valᵗ t Σ' valᵗ-weaken ext (vᵗ v) = vᵗ (val-weaken ext v) valᵗ-weaken ext (mᵗ f m) = mᵗ (wk ext f) m valᵗ-weaken ext (cᵗ c ic f) = cᵗ c ic (wk ext f) -- And pass these to the scope graph definition: open UsesVal Valᵗ valᵗ-weaken renaming (getFrame to getFrame') -------------- -- COERCION -- -------------- -- Our definition of sub-typing gives rise to a notion of sub-type -- coercion, defined below. Coercions essentially traverse the -- inheritance links of the frame hierarchy for an object instance, -- as described in the paper. upcastRef : ∀ {t t' Σ} → t <: t' → Val (ref t) Σ → Val (ref t') Σ upcastRef i (ref i' f) = ref (concatₚ i' i) f upcastRef i null = null
{ "alphanum_fraction": 0.6217058657, "avg_line_length": 32.9813084112, "ext": "agda", "hexsha": "6f6a8740306779b0285318b7c020d05a3755ebd0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/MJSF/Values.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/MJSF/Values.agda", "max_line_length": 113, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/MJSF/Values.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 1166, "size": 3529 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} ------------------------------------------------------------------------------ import LibraBFT.Impl.Consensus.SafetyRules.PersistentSafetyStorage as PersistentSafetyStorage import LibraBFT.Impl.Consensus.SafetyRules.SafetyRules as SafetyRules open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.PKCS open import Util.Prelude ------------------------------------------------------------------------------ module LibraBFT.Impl.Consensus.SafetyRules.SafetyRulesManager where storage : SafetyRulesConfig -> Author -> SK → Either ErrLog PersistentSafetyStorage storage config obmMe obmSK = do pure $ PersistentSafetyStorage.new -- internalStorage obmMe (config ^∙ srcObmGenesisWaypoint) obmSK newLocal : PersistentSafetyStorage → Bool → Either ErrLog SafetyRulesManager new : SafetyRulesConfig → Author → SK → Either ErrLog SafetyRulesManager new config obmMe obmSK = do storage0 ← storage config obmMe obmSK let exportConsensusKey = config ^∙ srcExportConsensusKey case config ^∙ srcService of λ where SRSLocal → newLocal storage0 exportConsensusKey newLocal storage0 exportConsensusKey = do safetyRules ← SafetyRules.new storage0 exportConsensusKey pure (mkSafetyRulesManager (SRWLocal safetyRules)) client : SafetyRulesManager → SafetyRules client self = case self ^∙ srmInternalSafetyRules of λ where (SRWLocal safetyRules) → safetyRules
{ "alphanum_fraction": 0.700814901, "avg_line_length": 38.1777777778, "ext": "agda", "hexsha": "51dfa7019caeca9f7ec3b235ef1541bb9645d2eb", "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/LibraBFT/Impl/Consensus/SafetyRules/SafetyRulesManager.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/LibraBFT/Impl/Consensus/SafetyRules/SafetyRulesManager.agda", "max_line_length": 111, "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/LibraBFT/Impl/Consensus/SafetyRules/SafetyRulesManager.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 407, "size": 1718 }
open import Type module Graph.Walk.Functions {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where import Lvl open import Graph{ℓ₁}{ℓ₂}(V) open import Graph.Properties open import Graph.Walk{ℓ₁}{ℓ₂}{V} open import Numeral.Natural open import Syntax.Function open import Type.Dependent open import Type.Dependent.Functions module _ {_⟶_ : Graph} where edge : ∀{a b} → (a ⟶ b) → (Walk(_⟶_) a b) edge e = prepend e at join : ∀{a b c} → (a ⟶ b) → (b ⟶ c) → (Walk(_⟶_) a c) join e₁ e₂ = prepend e₁ (edge e₂) _++_ : ∀{a b c} → Walk(_⟶_) a b → Walk(_⟶_) b c → Walk(_⟶_) a c at ++ w₂ = w₂ prepend e₁ w₁ ++ w₂ = prepend e₁ (w₁ ++ w₂) postpend : ∀{a b c} → (Walk(_⟶_) a b) → (b ⟶ c) → (Walk(_⟶_) a c) postpend at e₂ = edge e₂ postpend (prepend e₁ w) e₂ = prepend e₁ (postpend w e₂) reverse : ⦃ Undirected(_⟶_) ⦄ → ∀{a b} → Walk(_⟶_) a b → Walk(_⟶_) b a reverse at = at reverse (prepend e w) = postpend (reverse w) (undirected-reverse(_⟶_) e) prelop : ∀{a c} → (Walk(_⟶_) a c) → Σ(_)(b ↦ Walk(_⟶_) b c) prelop at = intro _ at prelop (prepend e w) = intro _ w postlop : ∀{a c} → (Walk(_⟶_) a c) → Σ(_)(b ↦ Walk(_⟶_) a b) postlop at = intro _ at postlop (prepend e at) = intro _ at postlop (prepend e₁ (prepend e₂ w)) = [Σ]-applyᵣ (postlop(prepend e₂ w)) (prepend e₁) length : ∀{a b} → (Walk(_⟶_) a b) → ℕ length at = 𝟎 length (prepend _ w) = 𝐒(length w)
{ "alphanum_fraction": 0.5557065217, "avg_line_length": 32.7111111111, "ext": "agda", "hexsha": "822329698503b06a8bbb7410d793aa4389e5341e", "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": "Graph/Walk/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": "Graph/Walk/Functions.agda", "max_line_length": 87, "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": "Graph/Walk/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": 595, "size": 1472 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.HSpace renaming (HSpaceStructure to HSS) import homotopy.WedgeExtension as WedgeExt module homotopy.Pi2HSusp where module Pi2HSusp {i} {X : Ptd i} (gA : has-level 1 (de⊙ X)) (cA : is-connected 0 (de⊙ X)) (H-X : HSS X) where {- TODO this belongs somewhere else, but where? -} private Type=-ext : ∀ {i} {A B : Type i} (p q : A == B) → ((x : A) → coe p x == coe q x) → p == q Type=-ext p q α = ! (ua-η p) ∙ ap ua (Subtype=-out is-equiv-prop (λ= α)) ∙ ua-η q open HSS H-X open ConnectedHSpace cA H-X private A = de⊙ X e = pt X P : Susp A → Type i P x = Trunc 1 (north == x) module Codes = SuspRec A A (λ a → ua (μ-e-r-equiv a)) Codes : Susp A → Type i Codes = Codes.f Codes-level : (x : Susp A) → has-level 1 (Codes x) Codes-level = Susp-elim gA gA (λ _ → prop-has-all-paths-↓ has-level-is-prop) encode₀ : {x : Susp A} → (north == x) → Codes x encode₀ α = transport Codes α e encode : {x : Susp A} → P x → Codes x encode {x} = Trunc-rec (Codes-level x) encode₀ decode' : A → P north decode' a = [ (merid a ∙ ! (merid e)) ] abstract transport-Codes-mer : (a a' : A) → transport Codes (merid a) a' == μ a a' transport-Codes-mer a a' = coe (ap Codes (merid a)) a' =⟨ Codes.merid-β a |in-ctx (λ w → coe w a') ⟩ coe (ua (μ-e-r-equiv a)) a' =⟨ coe-β (μ-e-r-equiv a) a' ⟩ μ a a' ∎ transport-Codes-mer-e-! : (a : A) → transport Codes (! (merid e)) a == a transport-Codes-mer-e-! a = coe (ap Codes (! (merid e))) a =⟨ ap-! Codes (merid e) |in-ctx (λ w → coe w a) ⟩ coe (! (ap Codes (merid e))) a =⟨ Codes.merid-β e |in-ctx (λ w → coe (! w) a) ⟩ coe (! (ua (μ-e-r-equiv e))) a =⟨ Type=-ext (ua (μ-e-r-equiv e)) idp (λ x → coe-β _ x ∙ μ-e-l x) |in-ctx (λ w → coe (! w) a) ⟩ coe (! idp) a ∎ abstract encode-decode' : (a : A) → encode (decode' a) == a encode-decode' a = transport Codes (merid a ∙ ! (merid e)) e =⟨ transp-∙ {B = Codes} (merid a) (! (merid e)) e ⟩ transport Codes (! (merid e)) (transport Codes (merid a) e) =⟨ transport-Codes-mer a e ∙ μ-e-r a |in-ctx (λ w → transport Codes (! (merid e)) w) ⟩ transport Codes (! (merid e)) a =⟨ transport-Codes-mer-e-! a ⟩ a ∎ abstract homomorphism : (a a' : A) → Path {A = Trunc 1 (north == south)} [ merid (μ a a' ) ] [ merid a' ∙ ! (merid e) ∙ merid a ] homomorphism = WedgeExt.ext args where args : WedgeExt.args {a₀ = e} {b₀ = e} args = record {m = -1; n = -1; cA = cA; cB = cA; P = λ a a' → (_ , Trunc-level {n = 1} _ _); f = λ a → ap [_] $ merid (μ a e) =⟨ ap merid (μ-e-r a) ⟩ merid a =⟨ ap (λ w → w ∙ merid a) (! (!-inv-r (merid e))) ∙ ∙-assoc (merid e) (! (merid e)) (merid a) ⟩ merid e ∙ ! (merid e) ∙ merid a ∎; g = λ a' → ap [_] $ merid (μ e a') =⟨ ap merid (μ-e-l a') ⟩ merid a' =⟨ ! (∙-unit-r (merid a')) ∙ ap (λ w → merid a' ∙ w) (! (!-inv-l (merid e))) ⟩ merid a' ∙ ! (merid e) ∙ merid e ∎ ; p = ap (λ {(p₁ , p₂) → ap [_] $ merid (μ e e) =⟨ p₁ ⟩ merid e =⟨ p₂ ⟩ merid e ∙ ! (merid e) ∙ merid e ∎}) (pair×= (ap (λ x → ap merid x) (! μ-coh)) (coh (merid e)))} where coh : {B : Type i} {b b' : B} (p : b == b') → ap (λ w → w ∙ p) (! (!-inv-r p)) ∙ ∙-assoc p (! p) p == ! (∙-unit-r p) ∙ ap (λ w → p ∙ w) (! (!-inv-l p)) coh idp = idp decode : {x : Susp A} → Codes x → P x decode {x} = Susp-elim {P = λ x → Codes x → P x} decode' (λ a → [ merid a ]) (λ a → ↓-→-from-transp (λ= $ STS a)) x where abstract STS : (a a' : A) → transport P (merid a) (decode' a') == [ merid (transport Codes (merid a) a') ] STS a a' = transport P (merid a) [ merid a' ∙ ! (merid e) ] =⟨ transport-Trunc (north ==_) (merid a) _ ⟩ [ transport (north ==_) (merid a) (merid a' ∙ ! (merid e)) ] =⟨ ap [_] (transp-cst=idf {A = Susp A} (merid a) _) ⟩ [ (merid a' ∙ ! (merid e)) ∙ merid a ] =⟨ ap [_] (∙-assoc (merid a') (! (merid e)) (merid a)) ⟩ [ merid a' ∙ ! (merid e) ∙ merid a ] =⟨ ! (homomorphism a a') ⟩ [ merid (μ a a') ] =⟨ ap ([_] ∘ merid) (! (transport-Codes-mer a a')) ⟩ [ merid (transport Codes (merid a) a') ] ∎ abstract decode-encode : {x : Susp A} (tα : P x) → decode {x} (encode {x} tα) == tα decode-encode {x} = Trunc-elim {P = λ tα → decode {x} (encode {x} tα) == tα} (λ _ → =-preserves-level Trunc-level) (J (λ y p → decode {y} (encode {y} [ p ]) == [ p ]) (ap [_] (!-inv-r (merid e)))) main-lemma-eq : Trunc 1 (north' A == north) ≃ A main-lemma-eq = equiv encode decode' encode-decode' decode-encode ⊙main-lemma : ⊙Trunc 1 (⊙Ω (⊙Susp X)) ⊙≃ X ⊙main-lemma = ≃-to-⊙≃ main-lemma-eq idp abstract main-lemma-iso : Ω^S-group 0 (⊙Trunc 1 (⊙Ω (⊙Susp X))) Trunc-level ≃ᴳ Ω^S-group 0 (⊙Trunc 1 X) Trunc-level main-lemma-iso = (record {f = f; pres-comp = pres-comp} , ie) where h : ⊙Trunc 1 (⊙Ω (⊙Susp X)) ⊙→ ⊙Trunc 1 X h = (λ x → [ encode x ]) , idp f : Ω (⊙Trunc 1 (⊙Ω (⊙Susp X))) → Ω (⊙Trunc 1 X) f = Ω-fmap h pres-comp : (p q : Ω^ 1 (⊙Trunc 1 (⊙Ω (⊙Susp X)))) → f (Ω^S-∙ 0 p q) == Ω^S-∙ 0 (f p) (f q) pres-comp = Ω^S-fmap-∙ 0 h ie : is-equiv f ie = Ω^-isemap 1 h (snd $ ((unTrunc-equiv A gA)⁻¹ ∘e main-lemma-eq)) abstract π₂-Susp : πS 1 (⊙Susp X) ≃ᴳ πS 0 X π₂-Susp = πS 1 (⊙Susp X) ≃ᴳ⟨ πS-Ω-split-iso 0 (⊙Susp X) ⟩ πS 0 (⊙Ω (⊙Susp X)) ≃ᴳ⟨ Ω^S-group-Trunc-fuse-diag-iso 0 (⊙Ω (⊙Susp X)) ⁻¹ᴳ ⟩ Ω^S-group 0 (⊙Trunc 1 (⊙Ω (⊙Susp X))) Trunc-level ≃ᴳ⟨ main-lemma-iso ⟩ Ω^S-group 0 (⊙Trunc 1 X) Trunc-level ≃ᴳ⟨ Ω^S-group-Trunc-fuse-diag-iso 0 X ⟩ πS 0 X ≃ᴳ∎
{ "alphanum_fraction": 0.4594000314, "avg_line_length": 34.6032608696, "ext": "agda", "hexsha": "7fbd10235c85e77fa655cf28a75254c91eca8ca8", "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/homotopy/Pi2HSusp.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/homotopy/Pi2HSusp.agda", "max_line_length": 74, "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/homotopy/Pi2HSusp.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2651, "size": 6367 }
module Issue1076 where {-# OPTIONS --no-coverage-check #-} -- WAS: Parse error -- NOW: -- OPTIONS pragma only allowed at beginning of file, before top module -- declaration -- when checking the pragma OPTIONS --no-coverage-check
{ "alphanum_fraction": 0.724137931, "avg_line_length": 21.0909090909, "ext": "agda", "hexsha": "466f0ab53bdf0896e9667776a86159da5f976295", "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/Issue1076.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/Issue1076.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/fail/Issue1076.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 52, "size": 232 }
-- Andreas, 2012-07-31, issue reported by Nicolas Pouillard -- {-# OPTIONS -v tc:100 -v term:100 #-} -- {-# OPTIONS -v tc.def.alias:20 #-} -- {-# OPTIONS -v tc:0 -v term:0 #-} module Issue655 where -- import Common.Level -- this should not be necessary module TypeAliases where postulate A : Set B = A → A module Ex0 where postulate f : ∀ {A : Set} → A → A yellow = f boring : ∀ {A : Set} → A → A boring = f boring' = λ {A} → f {A} module Ex1 where postulate A : Set f : ∀ {x : A} → A yellow = f boring : ∀ {x : A} → A boring {x} = f {x} boring' = λ {x} → f {x} module Ex2 where postulate A : Set f : ∀ {B : Set} (x : B) {y : A} → A a : A yellow = f a boring : ∀ {y : A} → A boring {y} = f a {y} boring' = λ {y} → f a {y} -- no longer yellow...
{ "alphanum_fraction": 0.5352644836, "avg_line_length": 15.2692307692, "ext": "agda", "hexsha": "85e46dbd3689ecfabf2875070036aaae31add27c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/Issue655.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/Issue655.agda", "max_line_length": 59, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/Issue655.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": 296, "size": 794 }
module Human.Nat where open import Human.Bool data Nat : Set where zero : Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat #-} infix 4 _==_ _<_ infixl 6 _+_ _-_ infixl 7 _*_ -- add theses guys on infixl 7: _div_ _%_ _+_ : Nat → Nat → Nat zero + m = m suc n + m = suc (n + m) {-# BUILTIN NATPLUS _+_ #-} _-_ : Nat → Nat → Nat n - zero = n zero - suc m = zero suc n - suc m = n - m {-# BUILTIN NATMINUS _-_ #-} _*_ : Nat → Nat → Nat zero * m = zero suc n * m = m + n * m {-# BUILTIN NATTIMES _*_ #-} _==_ : Nat → Nat → Bool zero == zero = true suc n == suc m = n == m _ == _ = false {-# BUILTIN NATEQUALS _==_ #-} _<_ : Nat → Nat → Bool _ < zero = false zero < suc _ = true suc n < suc m = n < m {-# BUILTIN NATLESS _<_ #-} div-helper : (k m n j : Nat) → Nat div-helper k m zero j = k div-helper k m (suc n) zero = div-helper (suc k) m n m div-helper k m (suc n) (suc j) = div-helper k m n j {-# BUILTIN NATDIVSUCAUX div-helper #-} mod-helper : (k m n j : Nat) → Nat mod-helper k m zero j = k mod-helper k m (suc n) zero = mod-helper 0 m n m mod-helper k m (suc n) (suc j) = mod-helper (suc k) m n j {-# BUILTIN NATMODSUCAUX mod-helper #-}
{ "alphanum_fraction": 0.5509868421, "avg_line_length": 19.6129032258, "ext": "agda", "hexsha": "217ce689042fb6ba6ffc8fde87a5b16c8970f432", "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/Nat.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/Nat.agda", "max_line_length": 57, "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/Nat.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": 460, "size": 1216 }
module Univalence where ------------------------------------------------------------------------------ -- Basic utilities open import LeqLemmas open import FinNatLemmas open import FiniteFunctions open import VectorLemmas -- only _!!_ and lookupassoc are needed open import Proofs -- Proofs is a wrapper over all the basic utilities -- The only thing imported from now on is Proofs ------------------------------------------------------------------------------ -- Structures (Definitions) -- We use (and extend) the package Categories. open import Categories.Category open import Categories.Groupoid open import Categories.Monoidal open import Categories.Monoidal.Helpers open import Categories.Functor open import Categories.Bifunctor open import Categories.NaturalIsomorphism open import Categories.Monoidal.Braided open import Categories.Monoidal.Symmetric open import Categories.RigCategory open import Categories.Bicategory ------------------------------------------------------------------------------ -- General -- -- We have three representations of types: Agda types, Pi types, and -- Fin types. We have three equivalence relations between types: -- extensional equivalences, Pi combinators, and Vec -- permutations. Each type representation suggests a natural choice -- for the equivalence relation: -- -- Agda_Type <===== extensional equivalence =====> Agda_Type -- Pi_Type <===== Pi combinator =====> Pi_Type -- Fin_Type <===== Vec permutation =====> Fin_Type -- -- ------------------------------------------------------------------------------ -- Equivalences open import Equiv -- Defines extensional equality of functions ∼; quasi-inverses; and -- then equivalences ≃ between spaces open import EquivEquiv -- Defines an extensional equivalence relation to be used to equate -- equivalences so we can talk about equivalences up to equivalence ------------------------------------------------------------------------------ -- Equivalences between Agda types (extensional type isomorphisms) open import TypeEquiv -- Proves that types and type equivalences form a commutative semiring -- in the Algebra sense open import TypeEquivEquiv -- All the equivalences between (type) equivalences open import Data.Sum.Properties -- Proves simple properties about type equivalences such as: -- uniti₊ (unite₊ x) ≡ x open import Data.SumProd.Properties -- Proves simple properties about type equivalences such as: -- distzr x ≡ distz (swap⋆ x) open import TypeEquivCat -- Proves that types and type equivalences form a symmetric rig -- groupoid up to extensional equality of equivalences ------------------------------------------------------------------------------ -- Equivalences between Pi types (combinators) -- -- Because Pi does not rely on extensionality it is easy to iterate -- equivalences up and down. The following shows levels -2, -1, 0, and -- 1. open import PiU -- First we introduce a univere U of finite types open import PiLevelm2 open import Pim2Cat -- A trivial relation on finite types is to identify all the types; -- this makes U a contractible (-2)-type, i.e., a singleton. -- -- The Pi types with the trivial relation that identifies all the -- types form a trivial symmetric rig groupoid up to propositional -- equality. -- -- A (-1)-type is either empty or a singleton. The previous setup at -- level -2 collapsed U to a singleton and hence also makes U a -- (-1)-type open import PiLevel0 open import Pi0Cat -- If the relation on finite types is modeled after type isomorphisms -- and all isomorphisms of the same type are equated, we collapse U to -- the set of natural numbers which makes it a 0-type. (We do not -- distinguish 'id' and 'not'.) open import Pi0Examples -- Pi0 is interesting as a programming language for reversible -- circuits. This module has a few examples. open import PiLevel1 open import Pi1Cat -- If the relation on finite types is modeled after type isomorphisms -- and only the isomorphisms corresponding to the coherence conditions -- of rig categories are equated, we make U a 1-type. (We do -- distinguish 'id' and 'not'.) The higher-level equality on the -- 2-morphisms is trivial, i.e., all two level morphisms are -- equated. This should yield a weak 2-category (i.e., a bicategory). open import Pi1Examples -- Pi1 is interesting as a programming language for reversible -- circuits that has its own optimizer. This module has a few -- examples. open import PiEquiv -- Each pi combinator is an equivalence -- How to make U a 2-type, 3-type, etc. ??? ------------------------------------------------------------------------------ -- Equivalences between Fin types (permutations) -- -- A finite type is a set Fin n for some n. It is possible to directly -- write permutations between finite types but this is extremely -- tedious especially if we want to prove that we have enough -- structure to model a symmetric rig groupoid. What we will do -- instead is to derive these permutations from equivalences as -- illustrated by the digram below: -- -- Fin m <—-Equivalence-—> Fin n -- || -- || Univalence -- || -- Fin m <—-Permutation-—> Fin n -- -- The vertical line is evocative of the univalence postulate: it is -- an equivalence between equivalences and concrete identifications -- expressed as permutations. It is relatively easy to establish the -- symmetric rig groupoid structure in the top line and then -- automatically transport it to the bottom line. open import ConcretePermutation -- Defines a permutation of a finite set 'Fin m' using two vectors of -- the form Vec (Fin m) m. The first occurrence of m bounds the values -- in the vector and the second bounds the length of the vector. In -- general, a permutation 'Vec (Fin m) n' can be viewed as a function -- that maps indices in 'Fin n' to values in 'Fin m'. To guarantee -- that each value in Fin m occurs exactly once in the vector, the -- representation of permutations includes two proofs that the -- composition of the two vectors is the identity permutation (in both -- directions). A crucial property of such permutations is that they -- can be compared for equality using just ≡ which is elaborated on in -- the module. -- -- Ultimately we want to prove that finite sets and permutations form -- a symmetric rig groupoid. Although it is possible to prove this -- directly, it is extremely tedious. We will instead develop all the -- infrastructure using equivalences on finite sets and transport it -- using a specialized instance of 'univalence'. open import FinEquivPlusTimes open import FinEquivTypeEquiv -- Defines the top line. We prove various equivalences between -- Fin types like: -- Fin (m + n) ≃ Fin m ⊎ Fin n -- and -- Fin (m * n) ≃ Fin m × Fin n -- We make sure we have enough equivalences to model a commutative -- semiring. -- open import FinEquivEquivPlus -- open import FinEquivEquivTimes -- open import FinEquivEquivPlusTimes -- open import FinEquivCat -- Establishes that finite types and equivalences for a symmetric rig -- groupoid. This is the structure we want to transport to permutations. open import SEquivSCPermEquiv -- An instance of univalence that allows us to transport all the -- structure from FinEquivCat to permutations -- open import CPermCat -- Establishes that CPerm m n is a symmetric rig category by -- transporting the structure from FinEquivCat using univalence -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Wavefront ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Composes previously defined equivalences to establish things like: -- FiniteType (A ⊎ B) (m + n) ≃ FiniteType (B ⊎ A) (n + m) -- FiniteTpyeEquivCat -- show that Finite types and equivalences for a symmetric rig groupoid -- define Permutation -- should be simple definition -- define EquivPerm -- big thm -- define EquivPermTransport -- might be just an application of thm to derive the symmetric rig -- structure on permutations -- Finding a good representation of permutations is tricky. -- We can compose equivalences from FinEquiv and TypeEquiv to get -- equivalences that correspond to permutations on finite sets, e.g., -- Fin (m + n) ≃ Fin m ⊎ Fin n ≃ Fin n ⊎ Fin m ≃ Fin (n + m) -- At this point these permutations are represented as extensional -- functions. In FinVec, we represent these extensional functions -- using the one-line notation of permutations represented in Agda as -- the type 'Vec (Fin m) n' (which we abbreviate as 'FinVec m n'). -- The setup allows us to directly extract one-line permutations from -- the equivalences. For example, the one-line notation for: -- FinVec ((m + n) + o) (m + (n + o)) -- is extracted using 'tabulate' of the equivalence between: -- Fin ((m + n) + o) and Fin (m + (n + o)) -- The fact that we have equivalences for the entire commutative -- semiring axioms means that we also easily define the one-line -- notation for composing permutations: -- FinVec m₁ m₂ → FinVec n₁ n₂ → FinVec (m₁ + n₁) (m₂ + n₂) -- FinVec m₁ m₂ → FinVec n₁ n₂ → FinVec (m₁ * n₁) (m₂ * n₂) -- What remains now is to explicitly include proofs that the one-line -- notation has an inverse and that the two compositions yield the -- identity permutation. This is one in ConcretePermutation and -- consists mostly of making explicit the proofs that are implicit in -- FinEquiv and FinVec. -- open import FinEquiv -- Establishes that Fin m ≃ Fin n is a commutative semiring -- open import ConcretePermutation -- Establishes that CPerm m n is a commutative semiring (including -- symmetry now) -- open import ConcretePermutationProperties -- Establishes properties of concrete permutations that are necessary -- to show that it is symmetric rig category -- open import CPermCat -- Establishes that CPerm m n is a symmetric rig category -- FiniteType ??? -- SCEquivSCPermEquiv ??? -- We have so far presented each instance separately. Now we focus on -- relating the different type representations. -- -- Now we want to relate Pi-types and type equivalences. The punchline -- would be that TypeEquivCat is isomorphic to Pi1Cat. But the setup -- for Pi1Cat allows us to keep going up and down the levels unlike -- the setup for TypeEquivCat which has extensional equivalence -- hardwired and can't be generalized to level 2. -- Are they really really necessary as a stepping stone to prove the -- correspondence between TypeEquivCat and Pi1Cat ??? -- Equivalences between finite sets (enumerations and permutations); -- Equivalences between setoids; Equivalences between equivalences; -- Unfinished files; Unused files -- open import EnumEquiv -- equivalence between A and Fin m is an enumeration of A -- open import SetoidEquiv -- do a version of EquivSetoid specialized for finite sets that -- include an enumeration just like quasi-inverses include one -- particular function to specify the equivalence; must really be done -- in conjection with SEquivSCPermEquiv so let's wait until -- dependencies satisfied... -- open import SEquivSCPermEquiv -- open import PiPerm -- open import PiEquiv -- open import SkFinSetCategory -- open import Pim1Cat -- open import LeftCancellation -- Proves that ((⊤ ⊎ A) ≃ (⊤ ⊎ B)) → A ≃ B -- open import RepresPerm -- open import Groupoid -- should be subsumed by Categories.Groupoid -- Old proofs -- open import SubstLemmas -- open import PathLemmas ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.6954760879, "avg_line_length": 36.4937106918, "ext": "agda", "hexsha": "727c019acf4bb20355cf4a08f2a9d95785f4848e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Univalence.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Univalence.agda", "max_line_length": 78, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Univalence.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": 2696, "size": 11605 }
module Numeral.Finite where import Lvl open import Syntax.Number open import Data.Boolean.Stmt open import Functional open import Numeral.Natural.Oper.Comparisons open import Numeral.Natural hiding (𝐏) open import Type -- A structure corresponding to a finite set of natural numbers (0,..,n−1). -- Specifically an upper bounded set of natural numbers, and the boundary is strictly lesser than the parameter. -- Positive integers including zero less than a specified integer (0≤_<n). -- Or represented using a set: {(i∊ℕ). 0≤i<n}. -- The structure works in the following way: -- • 𝟎 can be constructed for any non-zero upper bound (n). -- • 𝐒 can be constructed from only a smaller upper bounded 𝕟. -- Example: A 𝕟 constructed through 𝐒{3} can only be the following: -- 0 ≡ 𝟎{3} -- 1 ≡ 𝐒{3} (𝟎{2}) -- 2 ≡ 𝐒{3} (𝐒{2} (𝟎{1})) -- 3 ≡ 𝐒{3} (𝐒{2} (𝐒{1} (𝟎{0}))) -- because there is nothing that could fill the blank in (𝐒{3} (𝐒{2} (𝐒{1} (𝐒{0} (_))))). -- The smallest upper bound that can be is 0 (from using ℕ and its definition). -- This limits how many successors (𝐒) that can "fit". data 𝕟 : ℕ → Type{Lvl.𝟎} where 𝟎 : ∀{n} → 𝕟(ℕ.𝐒(n)) -- Zero 𝐒 : ∀{n} → 𝕟(n) → 𝕟(ℕ.𝐒(n)) -- Successor function {-# INJECTIVE 𝕟 #-} 𝕟₌ = 𝕟 ∘ 𝐒 bound : ∀{n} → 𝕟(n) → ℕ bound{n} _ = n minimum : ∀{n} → 𝕟(ℕ.𝐒(n)) minimum{_} = 𝟎 maximum : ∀{n} → 𝕟(ℕ.𝐒(n)) maximum{𝟎} = 𝟎 maximum{𝐒(n)} = 𝐒(maximum{n}) 𝕟-to-ℕ : ∀{n} → 𝕟(n) → ℕ 𝕟-to-ℕ {ℕ.𝟎} () 𝕟-to-ℕ {ℕ.𝐒(_)} (𝟎) = ℕ.𝟎 𝕟-to-ℕ {ℕ.𝐒(_)} (𝐒(n)) = ℕ.𝐒(𝕟-to-ℕ (n)) ℕ-to-𝕟 : (x : ℕ) → ∀{n} → . ⦃ _ : IsTrue(x <? n) ⦄ → 𝕟(n) ℕ-to-𝕟 (ℕ.𝟎) {ℕ.𝟎} ⦃ ⦄ ℕ-to-𝕟 (ℕ.𝐒(x)) {ℕ.𝟎} ⦃ ⦄ ℕ-to-𝕟 (ℕ.𝟎) {ℕ.𝐒(_)} ⦃ _ ⦄ = 𝟎 ℕ-to-𝕟 (ℕ.𝐒(x)) {ℕ.𝐒(n)} ⦃ p ⦄ = 𝐒(ℕ-to-𝕟 (x) {n} ⦃ p ⦄) instance 𝕟-from-ℕ : ∀{N} → Numeral(𝕟(N)) Numeral.restriction-ℓ ( 𝕟-from-ℕ {N} ) = Lvl.𝟎 Numeral.restriction ( 𝕟-from-ℕ {N} ) (n) = IsTrue(n <? N) num ⦃ 𝕟-from-ℕ {N} ⦄ (n) ⦃ proof ⦄ = ℕ-to-𝕟 (n) {N} ⦃ proof ⦄
{ "alphanum_fraction": 0.5615615616, "avg_line_length": 33.8644067797, "ext": "agda", "hexsha": "0250fb2136f816e1dd73bf00e998105faf584ebd", "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/Finite.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/Finite.agda", "max_line_length": 112, "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/Finite.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": 1006, "size": 1998 }
module Monads.StateT where open import Class.Monad open import Class.Functor open import Class.MonadTrans open import Class.Monad.State open import Class.Monad.Writer open import Data.Product open import Data.Unit.Polymorphic open import Function open import Level private variable a : Level S : Set a StateT : (Set a → Set a) → Set a → Set a → Set (a) StateT M S A = S → M (A × S) module _ {M : Set a → Set a} {{_ : Monad M}} {S} where instance StateT-Monad : Monad (StateT M S) StateT-Monad = record { _>>=_ = helper ; return = λ a → λ s → return (a , s) } where helper : ∀ {A B} → StateT M S A → (A → StateT M S B) → StateT M S B helper x f = λ s → do (a' , s') ← x s f a' s' StateT-MonadState : MonadState (StateT M S) S MonadState.get StateT-MonadState s = return (s , s) MonadState.put StateT-MonadState s = λ s' → return (tt , s) instance StateT-MonadTrans : MonadTrans (λ M → StateT M S) StateT-MonadTrans = record { embed = λ x s → (_, s) <$> x } StateT-MonadWriter : ∀ {M W} {{_ : Monad M}} {{_ : MonadWriter M W}} → MonadWriter (StateT M S) W StateT-MonadWriter = record { tell = λ w s → tell w >>= λ _ → return (tt , s) ; listen = λ x s → listen (x s) >>= λ { ((a , s') , w) → return ((a , w) , s') } ; pass = λ x s → x s >>= λ { (x' , s') → pass (return x') >>= λ a → return (a , s') } }
{ "alphanum_fraction": 0.5778251599, "avg_line_length": 30.5869565217, "ext": "agda", "hexsha": "a08bbc5afaae60cc6bce3a0d22b1f99a8eb9c58d", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Monads/StateT.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Monads/StateT.agda", "max_line_length": 91, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Monads/StateT.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 482, "size": 1407 }
------------------------------------------------------------------------------ -- Test the consistency of GroupTheory.Base ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- In the module GroupTheory.Base we declare Agda postulates as FOL -- axioms. We test if it is possible to prove an unprovable theorem -- from these axioms. module GroupTheory.Base.Consistency.Axioms where open import GroupTheory.Base ------------------------------------------------------------------------------ postulate impossible : (d e : G) → d ≡ e {-# ATP prove impossible #-}
{ "alphanum_fraction": 0.4522875817, "avg_line_length": 34.7727272727, "ext": "agda", "hexsha": "1d7f2cfb5c99a798a37ee2d65aa63298db1d097d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/GroupTheory/Base/Consistency/Axioms.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/GroupTheory/Base/Consistency/Axioms.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/GroupTheory/Base/Consistency/Axioms.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": 126, "size": 765 }
{- This file contains: - Properties of groupoid truncations -} {-# OPTIONS --cubical --safe #-} module Cubical.HITs.GroupoidTruncation.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.GroupoidTruncation.Base rec : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (gB : isGroupoid B) → (A → B) → (∥ A ∥₁ → B) rec gB f ∣ x ∣₁ = f x rec gB f (squash₁ x y p q r s i j k) = gB _ _ _ _ (λ m n → rec gB f (r m n)) (λ m n → rec gB f (s m n)) i j k elim : ∀ {ℓ ℓ'} {A : Type ℓ} {B : ∥ A ∥₁ → Type ℓ'} (bG : (x : ∥ A ∥₁) → isGroupoid (B x)) (f : (x : A) → B ∣ x ∣₁) (x : ∥ A ∥₁) → B x elim bG f (∣ x ∣₁) = f x elim bG f (squash₁ x y p q r s i j k) = isOfHLevel→isOfHLevelDep 3 bG _ _ _ _ (λ j k → elim bG f (r j k)) (λ j k → elim bG f (s j k)) (squash₁ x y p q r s) i j k
{ "alphanum_fraction": 0.5604651163, "avg_line_length": 26.875, "ext": "agda", "hexsha": "0845d1822434b6ca8a62f6421d11227b04bfd796", "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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/HITs/GroupoidTruncation/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "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": "borsiemir/cubical", "max_issues_repo_path": "Cubical/HITs/GroupoidTruncation/Properties.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/HITs/GroupoidTruncation/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 380, "size": 860 }
{-# OPTIONS --safe #-} module Cubical.Data.Nat.Divisibility where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Data.Sigma open import Cubical.Data.Sum open import Cubical.Data.Empty as ⊥ open import Cubical.HITs.PropositionalTruncation as PropTrunc open import Cubical.Data.Nat.Base open import Cubical.Data.Nat.Properties open import Cubical.Data.Nat.Order open import Cubical.Relation.Nullary private variable l m n : ℕ _∣_ : ℕ → ℕ → Type₀ m ∣ n = ∃[ c ∈ ℕ ] c · m ≡ n isProp∣ : isProp (m ∣ n) isProp∣ = squash prediv : ℕ → ℕ → Type₀ prediv m n = Σ[ c ∈ ℕ ] c · m ≡ n -- an alternate definition of m ∣ n that doesn't use truncation _∣'_ : ℕ → ℕ → Type₀ zero ∣' n = zero ≡ n suc m ∣' n = Σ[ c ∈ ℕ ] c · suc m ≡ n isProp∣' : isProp (m ∣' n) isProp∣' {zero} {n} = isSetℕ _ _ isProp∣' {suc m} {n} (c₁ , p₁) (c₂ , p₂) = Σ≡Prop (λ _ → isSetℕ _ _) (inj-·sm {c₁} {m} {c₂} (p₁ ∙ sym p₂)) ∣≃∣' : (m ∣ n) ≃ (m ∣' n) ∣≃∣' {zero} = propBiimpl→Equiv isProp∣ isProp∣' (PropTrunc.rec (isSetℕ _ _) λ { (c , p) → 0≡m·0 c ∙ p }) (λ p → ∣ zero , p ∣) ∣≃∣' {suc m} = propTruncIdempotent≃ isProp∣' ∣-untrunc : m ∣ n → Σ[ c ∈ ℕ ] c · m ≡ n ∣-untrunc {zero} p = zero , equivFun ∣≃∣' p ∣-untrunc {suc m} = equivFun ∣≃∣' -- basic properties of ∣ ∣-refl : m ≡ n → m ∣ n ∣-refl p = ∣ 1 , +-zero _ ∙ p ∣ ∣-trans : l ∣ m → m ∣ n → l ∣ n ∣-trans = PropTrunc.map2 λ { (c₁ , p) (c₂ , q) → (c₂ · c₁ , sym (·-assoc c₂ c₁ _) ∙ cong (c₂ ·_) p ∙ q) } ∣-left : ∀ k → m ∣ (m · k) ∣-left k = ∣ k , ·-comm k _ ∣ ∣-right : ∀ k → m ∣ (k · m) ∣-right k = ∣ k , refl ∣ ∣-cancelʳ : ∀ k → (m · suc k) ∣ (n · suc k) → m ∣ n ∣-cancelʳ k = PropTrunc.map λ { (c , p) → (c , inj-·sm (sym (·-assoc c _ (suc k)) ∙ p)) } ∣-multʳ : ∀ k → m ∣ n → (m · k) ∣ (n · k) ∣-multʳ k = PropTrunc.map λ { (c , p) → (c , ·-assoc c _ k ∙ cong (_· k) p) } ∣-zeroˡ : zero ∣ m → zero ≡ m ∣-zeroˡ = equivFun ∣≃∣' ∣-zeroʳ : ∀ m → m ∣ zero ∣-zeroʳ m = ∣ zero , refl ∣ ∣-oneˡ : ∀ m → 1 ∣ m ∣-oneˡ m = ∣ m , ·-identityʳ m ∣ -- if n > 0, then the constant c (s.t. c · m ≡ n) is also > 0 ∣s-untrunc : m ∣ suc n → Σ[ c ∈ ℕ ] (suc c) · m ≡ suc n ∣s-untrunc ∣p∣ with ∣-untrunc ∣p∣ ... | (zero , p) = ⊥.rec (znots p) ... | (suc c , p) = (c , p) m∣sn→m≤sn : m ∣ suc n → m ≤ suc n m∣sn→m≤sn {m} {n} = f ∘ ∣s-untrunc where f : Σ[ c ∈ ℕ ] (suc c) · m ≡ suc n → Σ[ c ∈ ℕ ] c + m ≡ suc n f (c , p) = (c · m) , (+-comm (c · m) m ∙ p) m∣n→m≤n : {m n : ℕ} → ¬ n ≡ 0 → m ∣ n → m ≤ n m∣n→m≤n {m = m} {n = n} p q = let n≡sd = suc-predℕ _ p m≤sd = m∣sn→m≤sn (subst (λ a → m ∣ a) n≡sd q) in subst (λ a → m ≤ a) (sym n≡sd) m≤sd m∣sn→z<m : m ∣ suc n → zero < m m∣sn→z<m {zero} p = ⊥.rec (znots (∣-zeroˡ p)) m∣sn→z<m {suc m} p = suc-≤-suc zero-≤ antisym∣ : ∀ {m n} → m ∣ n → n ∣ m → m ≡ n antisym∣ {zero} {n} z∣n _ = ∣-zeroˡ z∣n antisym∣ {m} {zero} _ z∣m = sym (∣-zeroˡ z∣m) antisym∣ {suc m} {suc n} p q = ≤-antisym (m∣sn→m≤sn p) (m∣sn→m≤sn q) -- Inequality for strict divisibility stDivIneq : ¬ m ≡ 0 → ¬ m ∣ n → l ∣ m → l ∣ n → l < m stDivIneq {m = 0} p = ⊥.rec (p refl) stDivIneq {n = 0} _ q = ⊥.rec (q (∣-zeroʳ _)) stDivIneq {m = suc m} {n = n} {l = l} _ q h h' = case (≤-split (m∣sn→m≤sn h)) return (λ _ → l < suc m) of λ { (inl r) → r ; (inr r) → ⊥.rec (q (subst (λ a → a ∣ n) r h')) }
{ "alphanum_fraction": 0.5133750711, "avg_line_length": 28.112, "ext": "agda", "hexsha": "89d251740c50c04c4a2bf2911338dae99825eab0", "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/Data/Nat/Divisibility.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/Data/Nat/Divisibility.agda", "max_line_length": 86, "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/Data/Nat/Divisibility.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1763, "size": 3514 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.DStructures.Meta.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Data.Sigma open import Cubical.Relation.Binary open import Cubical.DStructures.Base private variable ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓA' ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓC ℓ≅C ℓ≅ᴰ ℓ≅ᴰ' ℓX ℓ≅X ℓD ℓ≅D : Level -- the total space of a DURGS is a URGS 𝒮ᴰ→𝒮 : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) → URGStr (Σ A B) (ℓ-max ℓ≅A ℓ≅B) 𝒮ᴰ→𝒮 {A = A} 𝒮-A {B = B} 𝒮ᴰ-B = make-𝒮 {_≅_ = _≅Σ_} ρΣ contrTotalΣ where open URGStr 𝒮-A open URGStrᴰ 𝒮ᴰ-B -- in the context of a fixed point (a , b) module _ ((a , b) : Σ A B) where -- the graph relation on the total space _≅Σ_ = λ ((a' , b') : Σ A B) → Σ[ e ∈ a ≅ a' ] (b ≅ᴰ⟨ e ⟩ b') -- reflexivity for that relation ρΣ = ρ a , ρᴰ b -- contractability of the corresponding total space contrTotalA : isContr (Σ[ a' ∈ A ] (a ≅ a')) contrTotalA = isUnivalent→contrRelSingl _≅_ ρ uni a contrTotalB : isContr (Σ[ b' ∈ B a ] (b ≅ᴰ⟨ ρ a ⟩ b')) contrTotalB = isUnivalent→contrRelSingl (_≅ᴰ⟨ ρ a ⟩_) ρᴰ uniᴰ b contrTotalΣ = isContrRespectEquiv (relSinglAt (_≅ᴰ⟨ ρ a ⟩_) b ≃⟨ idEquiv (relSinglAt (_≅ᴰ⟨ ρ a ⟩_) b) ⟩ Σ[ b' ∈ B a ] (b ≅ᴰ⟨ ρ a ⟩ b') -- ≃⟨ invEquiv (Σ-contractFst contrTotalA') ⟩ ≃⟨ invEquiv (Σ-contractFst-recenter contrTotalA (a , ρ a)) ⟩ Σ[ (a' , e) ∈ (Σ[ a' ∈ A ] (a ≅ a')) ] Σ[ b' ∈ B a' ] (b ≅ᴰ⟨ e ⟩ b') ≃⟨ Σ-assoc-≃ ⟩ Σ[ a' ∈ A ] Σ[ e ∈ (a ≅ a') ] Σ[ b' ∈ B a' ] (b ≅ᴰ⟨ e ⟩ b') ≃⟨ Σ-cong-equiv-snd (λ a' → invEquiv Σ-assoc-≃) ⟩ Σ[ a' ∈ A ] Σ[ (e , b') ∈ (a ≅ a') × B a' ] (b ≅ᴰ⟨ e ⟩ b') ≃⟨ Σ-cong-equiv-snd (λ a' → Σ-cong-equiv-fst Σ-swap-≃) ⟩ Σ[ a' ∈ A ] Σ[ (b' , e) ∈ (B a' × (a ≅ a')) ] (b ≅ᴰ⟨ e ⟩ b') ≃⟨ Σ-cong-equiv-snd (λ a' → Σ-assoc-≃) ⟩ Σ[ a' ∈ A ] Σ[ b' ∈ B a' ] Σ[ e ∈ (a ≅ a') ] (b ≅ᴰ⟨ e ⟩ b') ≃⟨ invEquiv Σ-assoc-≃ ⟩ Σ[ (a' , b') ∈ Σ A B ] Σ[ e ∈ (a ≅ a') ] (b ≅ᴰ⟨ e ⟩ b') ■) contrTotalB -- integral notation like in the disp cats paper ∫⟨_⟩_ : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) → URGStr (Σ A B) (ℓ-max ℓ≅A ℓ≅B) ∫⟨_⟩_ 𝒮-A {B} DispStrB .URGStr._≅_ = 𝒮ᴰ→𝒮 𝒮-A DispStrB .URGStr._≅_ ∫⟨_⟩_ 𝒮-A {B} DispStrB .URGStr.ρ = 𝒮ᴰ→𝒮 𝒮-A DispStrB .URGStr.ρ ∫⟨_⟩_ 𝒮-A {B} DispStrB .URGStr.uni = 𝒮ᴰ→𝒮 𝒮-A DispStrB .URGStr.uni -- transport URG structures along an equivalence 𝒮-transport : {A : Type ℓA} {A' : Type ℓA'} (e : A ≃ A') (StrA : URGStr A ℓ≅A) → URGStr A' ℓ≅A 𝒮-transport {A = A} {A' = A'} e StrA = make-𝒮 {_≅_ = λ a a' → e- a ≅ e- a'} (λ a → ρ (e- a)) λ a → isContrRespectEquiv (Σ[ x ∈ A ] e- a ≅ x ≃⟨ Σ-cong-equiv-snd (λ x → pathToEquiv (cong (e- a ≅_) (sym (Iso.leftInv (equivToIso e) x)))) ⟩ Σ[ x ∈ A ] e- a ≅ e- (e* x) ≃⟨ Σ-cong-equiv-fst e ⟩ Σ[ a' ∈ A' ] e- a ≅ e- a' ■) (𝒮→cTS StrA (e- a)) where open URGStr StrA e⁻¹ = invEquiv e e- = equivFun e⁻¹ e* = equivFun e -- obtain a path from a relation 𝒮-≅→≡ : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {a a' : A} (p : URGStr._≅_ 𝒮-A a a') → a ≡ a' 𝒮-≅→≡ 𝒮-A {a} {a'} p = equivFun (invEquiv (isUnivalent→isUnivalent' _≅_ ρ uni a a')) p where open URGStr 𝒮-A -- context: structure on A, B and C displayed over A -- then B can be lifted to be displayed over ∫⟨ 𝒮-A ⟩ 𝒮ᴰ-C VerticalLift-𝒮ᴰ : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {C : A → Type ℓC} (𝒮ᴰ-C : URGStrᴰ 𝒮-A C ℓ≅C) → URGStrᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-C) (λ (a , _) → B a) ℓ≅B VerticalLift-𝒮ᴰ {ℓ≅B = ℓ≅B} 𝒮-A {B = B} 𝒮ᴰ-B 𝒮ᴰ-C = urgstrᴰ (λ b (pA , _) b' → b ≅ᴰ⟨ pA ⟩ b') ρᴰ uniᴰ where open URGStrᴰ 𝒮ᴰ-B VerticalLift2-𝒮ᴰ : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {X : A → Type ℓX} (𝒮ᴰ-X : URGStrᴰ 𝒮-A X ℓ≅X) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {C : Σ A B → Type ℓC} (𝒮ᴰ-C : URGStrᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) C ℓ≅C) → URGStrᴰ (∫⟨ ∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B ⟩ 𝒮ᴰ-C) (λ ((a , b) , c) → X a) ℓ≅X VerticalLift2-𝒮ᴰ 𝒮-A 𝒮ᴰ-X 𝒮ᴰ-B 𝒮ᴰ-C = VerticalLift-𝒮ᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) (VerticalLift-𝒮ᴰ 𝒮-A 𝒮ᴰ-X 𝒮ᴰ-B) 𝒮ᴰ-C -- context: 𝒮-A on A, 𝒮ᴰ-B / A, 𝒮ᴰ-C / ∫⟨𝒮-A⟩ 𝒮ᴰ-B -- then 𝒮ᴰ-C can be rebased to 𝒮-A splitTotal-𝒮ᴰ : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {C : Σ A B → Type ℓC} (𝒮ᴰ-C : URGStrᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) C ℓ≅C) → URGStrᴰ 𝒮-A (λ a → Σ[ b ∈ B a ] C (a , b)) (ℓ-max ℓ≅B ℓ≅C) splitTotal-𝒮ᴰ {A = A} 𝒮-A {B} 𝒮ᴰ-B {C} 𝒮ᴰ-C = make-𝒮ᴰ (λ (b , c) eA (b' , c') → Σ[ eB ∈ b B≅ᴰ⟨ eA ⟩ b' ] c ≅ᴰ⟨ eA , eB ⟩ c') (λ (b , c) → Bρᴰ b , ρᴰ c) q where open URGStrᴰ 𝒮ᴰ-C open URGStr 𝒮-A _B≅ᴰ⟨_⟩_ = URGStrᴰ._≅ᴰ⟨_⟩_ 𝒮ᴰ-B Bρᴰ = URGStrᴰ.ρᴰ 𝒮ᴰ-B Buniᴰ = URGStrᴰ.uniᴰ 𝒮ᴰ-B module _ (a : A) (b : B a) where abstract contrTotalB : isContr (Σ[ b' ∈ B a ] b B≅ᴰ⟨ ρ a ⟩ b') contrTotalB = isUnivalent→contrRelSingl (_B≅ᴰ⟨ ρ a ⟩_) Bρᴰ Buniᴰ b contrTotalC : (c : C (a , b)) → isContr (Σ[ c' ∈ C (a , b) ] c ≅ᴰ⟨ ρ a , Bρᴰ b ⟩ c') contrTotalC = isUnivalent→contrRelSingl (λ c₁ c₂ → c₁ ≅ᴰ⟨ ρ a , Bρᴰ b ⟩ c₂) ρᴰ uniᴰ abstract q = λ a (b , c) → isContrRespectEquiv (Σ[ c' ∈ C (a , b) ] c ≅ᴰ⟨ ρ a , Bρᴰ b ⟩ c' ≃⟨ invEquiv (Σ-contractFst-recenter (contrTotalB a b) (b , Bρᴰ b)) ⟩ Σ[ (b' , eB) ∈ Σ[ b' ∈ B a ] b B≅ᴰ⟨ ρ a ⟩ b' ] (Σ[ c' ∈ C (a , b') ] (c ≅ᴰ⟨ ρ a , eB ⟩ c')) ≃⟨ compEquiv Σ-assoc-≃ (compEquiv (Σ-cong-equiv-snd (λ b' → compEquiv (invEquiv Σ-assoc-≃) (compEquiv (Σ-cong-equiv-fst Σ-swap-≃) Σ-assoc-≃))) (invEquiv Σ-assoc-≃)) ⟩ Σ[ (b' , c') ∈ Σ[ b' ∈ B a ] C (a , b') ] (Σ[ eB ∈ b B≅ᴰ⟨ ρ a ⟩ b' ] (c ≅ᴰ⟨ ρ a , eB ⟩ c')) ■) (contrTotalC a b c) -- pullback in the (∞,1)-topos of DURGs, -- combine two DURGs over the same URG to one combine-𝒮ᴰ : {A : Type ℓA} {𝒮-A : URGStr A ℓ≅A} {B : A → Type ℓB} {C : A → Type ℓC} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) (𝒮ᴰ-C : URGStrᴰ 𝒮-A C ℓ≅C) → URGStrᴰ 𝒮-A (λ a → B a × C a) (ℓ-max ℓ≅B ℓ≅C) combine-𝒮ᴰ {𝒮-A = 𝒮-A} 𝒮ᴰ-B 𝒮ᴰ-C = splitTotal-𝒮ᴰ 𝒮-A 𝒮ᴰ-B (VerticalLift-𝒮ᴰ 𝒮-A 𝒮ᴰ-C 𝒮ᴰ-B) -- old stuff, not sure if relevant -- extract the relational family from a DURG SplitTotal-𝒮ᴰ→RelFamily : {ℓ≅A ℓ≅B ℓ≅C : Level} {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {C : Σ A B → Type ℓC} (𝒮ᴰ-C : URGStrᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) C ℓ≅C) → Σ[ _≅_ ∈ Rel A A ℓ≅A ] ({a a' : A} ((b , c) : Σ[ b ∈ B a ] C (a , b)) (e : a ≅ a') ((b' , c') : (Σ[ b' ∈ B a' ] C (a' , b'))) → Type (ℓ-max ℓ≅B ℓ≅C)) SplitTotal-𝒮ᴰ→RelFamily 𝒮-A {B = B} 𝒮ᴰ-B {C = C} 𝒮ᴰ-C .fst = _≅_ where open URGStr 𝒮-A SplitTotal-𝒮ᴰ→RelFamily 𝒮-A {B = B} 𝒮ᴰ-B {C = C} 𝒮ᴰ-C .snd (b , c) e (b' , c') = Σ[ eB ∈ b B≅ᴰ⟨ e ⟩ b' ] (c ≅ᴰ⟨ e , eB ⟩ c') where open URGStr 𝒮-A _B≅ᴰ⟨_⟩_ = URGStrᴰ._≅ᴰ⟨_⟩_ 𝒮ᴰ-B open URGStrᴰ 𝒮ᴰ-C SplitTotal-𝒮ᴰ→RelFamily' : {ℓ≅A ℓ≅B ℓ≅C : Level} {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) {C : Σ A B → Type ℓC} (𝒮ᴰ-C : URGStrᴰ (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) C ℓ≅C) → RelFamily A (ℓ-max ℓB ℓC) (ℓ-max ℓ≅B ℓ≅C) SplitTotal-𝒮ᴰ→RelFamily' 𝒮-A {B = B} 𝒮ᴰ-B {C = C} 𝒮ᴰ-C .fst a = Σ[ b ∈ B a ] C (a , b) SplitTotal-𝒮ᴰ→RelFamily' 𝒮-A {B = B} 𝒮ᴰ-B {C = C} 𝒮ᴰ-C .snd {a = a} (b , c) (b' , c') = Σ[ p ∈ b B≅ᴰ⟨ ρ a ⟩ b' ] (c C≅ᴰ⟨ ρ a , p ⟩ c') where open URGStr 𝒮-A _B≅ᴰ⟨_⟩_ = URGStrᴰ._≅ᴰ⟨_⟩_ 𝒮ᴰ-B _C≅ᴰ⟨_⟩_ = URGStrᴰ._≅ᴰ⟨_⟩_ 𝒮ᴰ-C -- combine two structures 𝒮-B and 𝒮-C over 𝒮-A to a structure 𝒮-B × 𝒮-C over A, direct proof combine'-𝒮ᴰ : {A : Type ℓA} {𝒮-A : URGStr A ℓ≅A} {B : A → Type ℓB} {C : A → Type ℓC} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B) (𝒮ᴰ-C : URGStrᴰ 𝒮-A C ℓ≅C) → URGStrᴰ 𝒮-A (λ a → B a × C a) (ℓ-max ℓ≅B ℓ≅C) combine'-𝒮ᴰ {ℓ≅B = ℓ≅B} {ℓ≅C = ℓ≅C} {A = A} {𝒮-A = 𝒮-A} {B = B} {C = C} 𝒮ᴰ-B 𝒮ᴰ-C = make-𝒮ᴰ -- equality in the combined structure is defined componentwise (λ (b , c) p (b' , c') → b B≅ᴰ⟨ p ⟩ b' × c C≅ᴰ⟨ p ⟩ c') -- reflexivity follows from B and C reflexivity (λ (b , c) → Bρᴰ b , Cρᴰ c) -- so does univalence contrTot where ρ = URGStr.ρ 𝒮-A _B≅ᴰ⟨_⟩_ = URGStrᴰ._≅ᴰ⟨_⟩_ 𝒮ᴰ-B _C≅ᴰ⟨_⟩_ = URGStrᴰ._≅ᴰ⟨_⟩_ 𝒮ᴰ-C Bρᴰ = URGStrᴰ.ρᴰ 𝒮ᴰ-B Cρᴰ = URGStrᴰ.ρᴰ 𝒮ᴰ-C Buniᴰ = URGStrᴰ.uniᴰ 𝒮ᴰ-B Cuniᴰ = URGStrᴰ.uniᴰ 𝒮ᴰ-C contrTot : (a : A) ((b , c) : B a × C a) → isContr (Σ[ (b' , c') ∈ B a × C a ] (b B≅ᴰ⟨ ρ a ⟩ b' × c C≅ᴰ⟨ ρ a ⟩ c') ) contrTot = λ (a : A) ((b , c) : B a × C a) → isContrRespectEquiv (Σ[ b' ∈ B a ] (b B≅ᴰ⟨ ρ a ⟩ b') ≃⟨ invEquiv (Σ-contractSnd (λ _ → isUnivalent→contrRelSingl (_C≅ᴰ⟨ ρ a ⟩_) Cρᴰ Cuniᴰ c)) ⟩ (Σ[ b' ∈ B a ] (b B≅ᴰ⟨ ρ a ⟩ b')) × (Σ[ c' ∈ C a ] (c C≅ᴰ⟨ ρ a ⟩ c')) ≃⟨ Σ-assoc-≃ ⟩ (Σ[ b' ∈ B a ] Σ[ _ ∈ b B≅ᴰ⟨ ρ a ⟩ b' ] Σ[ c' ∈ C a ] (c C≅ᴰ⟨ ρ a ⟩ c')) ≃⟨ Σ-cong-equiv-snd (λ b' → compEquiv (invEquiv Σ-assoc-≃) (compEquiv (Σ-cong-equiv-fst Σ-swap-≃) Σ-assoc-≃)) ⟩ (Σ[ b' ∈ B a ] Σ[ c' ∈ C a ] Σ[ _ ∈ b B≅ᴰ⟨ ρ a ⟩ b' ] (c C≅ᴰ⟨ ρ a ⟩ c')) ≃⟨ invEquiv Σ-assoc-≃ ⟩ (Σ[ (b' , c') ∈ B a × C a ] (b B≅ᴰ⟨ ρ a ⟩ b' × c C≅ᴰ⟨ ρ a ⟩ c') ) ■) (isUnivalent→contrRelSingl (_B≅ᴰ⟨ ρ a ⟩_) Bρᴰ Buniᴰ b)
{ "alphanum_fraction": 0.4003187117, "avg_line_length": 47.692, "ext": "agda", "hexsha": "476ba2ad54ba452691d1bd4435290d8e7a1b79b9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/DStructures/Meta/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/DStructures/Meta/Properties.agda", "max_line_length": 157, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/DStructures/Meta/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5839, "size": 11923 }
{-# OPTIONS --cubical --safe #-} module Cubical.Structures.Pointed where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.Path open import Cubical.Foundations.Pointed.Base open import Cubical.Foundations.SIP renaming (SNS-PathP to SNS) private variable ℓ : Level -- Pointed types with SNS pointed-structure : Type ℓ → Type ℓ pointed-structure X = X pointed-iso : StrIso pointed-structure ℓ pointed-iso A B f = equivFun f (pt A) ≡ pt B pointed-is-SNS : SNS {ℓ} pointed-structure pointed-iso pointed-is-SNS f = invEquiv (ua-ungluePath-Equiv f) pointed-SIP : (A B : Pointed ℓ) → A ≃[ pointed-iso ] B ≃ (A ≡ B) pointed-SIP = SIP pointed-structure pointed-iso pointed-is-SNS pointed-sip : (A B : Pointed ℓ) → A ≃[ pointed-iso ] B → (A ≡ B) pointed-sip A B = equivFun (pointed-SIP A B) -- ≡ λ (e , p) i → ua e i , ua-gluePath e p i
{ "alphanum_fraction": 0.725708502, "avg_line_length": 29.0588235294, "ext": "agda", "hexsha": "24f5cb8be7b8b5a02702a9fc4e14917a1b658ce1", "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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Structures/Pointed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "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": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Structures/Pointed.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Structures/Pointed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 330, "size": 988 }
{-# OPTIONS --without-K --safe #-} -------------------------------------------------------------------------------- -- Simple implementation of sets of ℕ. -------------------------------------------------------------------------------- {-# OPTIONS --without-K --safe #-} module Data.Nat.Table where open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.List as List using (List; _∷_; []) open import Function Table : Set Table = List ℕ para : ∀ {a b} {A : Set a} {B : Set b} → (A → List A → B → B) → B → List A → B para f b [] = b para f b (x ∷ xs) = f x xs (para f b xs) insert : ℕ → Table → Table insert x xs = para (go zero) (_∷ []) xs x where go : ℕ → ℕ → Table → (ℕ → Table) → ℕ → Table go k zero xs g zero = k ∷ xs go k zero xs g (suc i) = k ∷ g i go k (suc x) xs g zero = k ∷ x ∷ xs go k (suc x) xs g (suc i) = go (suc k) x xs g i open import Data.Maybe as Maybe using (Maybe; just; nothing) member : ℕ → Table → Maybe ℕ member x xs = List.foldr go (const (const nothing)) xs x 0 where go : ℕ → (ℕ → ℕ → Maybe ℕ) → ℕ → ℕ → Maybe ℕ go zero ys zero k = just k go zero ys (suc x) k = ys x (suc k) go (suc y) ys zero _ = nothing go (suc y) ys (suc x) k = go y ys x k fromList : List ℕ → Table fromList = List.foldr insert [] toList : Table → List ℕ toList = tail′ ∘ List.map ℕ.pred ∘ List.scanl (λ x y → suc (y ℕ.+ x)) 0 where tail′ : List ℕ → List ℕ tail′ [] = [] tail′ (_ ∷ xs) = xs private open import Relation.Binary.PropositionalEquality example₁ : fromList (4 ∷ 3 ∷ 1 ∷ 0 ∷ 2 ∷ []) ≡ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) example₁ = refl example₂ : member 3 (fromList (4 ∷ 3 ∷ 1 ∷ 0 ∷ 2 ∷ [])) ≡ just 3 example₂ = refl example₃ : toList (fromList (4 ∷ 3 ∷ 1 ∷ 0 ∷ 2 ∷ [])) ≡ (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ []) example₃ = refl
{ "alphanum_fraction": 0.5055370986, "avg_line_length": 29.1290322581, "ext": "agda", "hexsha": "9a6c4e934adf4480572f8425c84cdd601ae2ba32", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Data/Nat/Table.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Data/Nat/Table.agda", "max_line_length": 82, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Data/Nat/Table.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 662, "size": 1806 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} {-# OPTIONS --allow-unsolved-metas #-} module Light.Implementation.Relation.Decidable where open import Light.Variable.Levels open import Light.Variable.Sets open import Light.Library.Relation.Decidable using (Library ; Dependencies) open import Light.Library.Data.Empty as Empty using (Empty) open import Light.Library.Data.Unit as Unit using (Unit ; unit) open import Light.Library.Data.Both as Both using (Both) import Light.Library.Data.Product as Product open import Light.Library.Data.These as These using (These) import Light.Implementation.Data.Empty import Light.Implementation.Data.Unit import Light.Implementation.Data.Product import Light.Implementation.Data.These import Light.Package instance dependencies : Dependencies dependencies = record {} instance library : Library dependencies library = record { Implementation ; to‐witness = λ ⦃ a ⦄ → Implementation.to‐witness a ; to‐false‐witness = λ ⦃ a ⦄ → Implementation.to‐false‐witness a ; from‐witness = λ ⦃ a ⦄ → Implementation.from‐witness a ; from‐false‐witness = λ ⦃ a ⦄ → Implementation.from‐false‐witness a } where module Implementation where open import Light.Implementation.Relation.Sets using (base) public data Decidable (𝕒 : Set ℓ) : Set ℓ where yes : 𝕒 → Decidable 𝕒 no : (𝕒 → Empty) → Decidable 𝕒 module Style where true : Decidable Unit true = yes unit false : Decidable Empty false = no λ a → a ¬_ : Decidable 𝕒 → Decidable (𝕒 → Empty) ¬ yes a = no λ f → f a ¬ no a = yes a _∧_ : ∀ {𝕒 : Set aℓ} {𝕓 : Set bℓ} (a? : Decidable 𝕒) (b? : Decidable 𝕓) → Decidable (Both 𝕒 𝕓) yes a ∧ yes b = yes (Both.both a b) no f ∧ _ = no λ both → f (Both.first both) _ ∧ no f = no λ both → f (Both.second both) _∨_ : ∀ {𝕒 : Set aℓ} {𝕓 : Set bℓ} (a? : Decidable 𝕒) (b? : Decidable 𝕓) → Decidable (These 𝕒 𝕓) no af ∨ no bf = no {!!} yes a ∨ yes b = yes (These.these a b) yes a ∨ no _ = yes (These.this a) no _ ∨ yes b = yes (These.that b) _⇢_ : ∀ {𝕒 : Set aℓ} {𝕓 : Set bℓ} (a? : Decidable 𝕒) (b? : Decidable 𝕓) → Decidable (𝕒 → 𝕓) _ ⇢ yes b = yes λ _ → b no af ⇢ _ = yes λ a → Empty.eliminate (af a) yes a ⇢ no bf = no λ f → bf (f a) True False : Decidable 𝕒 → Set True (yes _) = Unit True (no _) = Empty False a? = True (¬ a?) style = record { Style } if′_then_else_ : Decidable 𝕒 → 𝕓 → 𝕓 → 𝕓 if′ yes _ then a else _ = a if′ no _ then _ else a = a if_then_else_ : ∀ (a : Decidable 𝕒) → (∀ ⦃ witness : 𝕒 ⦄ → 𝕓) → (∀ ⦃ witness : 𝕒 → Empty ⦄ → 𝕓) → 𝕓 if yes w then a else _ = a ⦃ witness = w ⦄ if no w then _ else a = a ⦃ witness = w ⦄ to‐witness : ∀ {a? : Decidable 𝕒} → Style.True a? → 𝕒 to‐false‐witness : ∀ {a? : Decidable 𝕒} → Style.False a? → 𝕒 → Empty from‐witness : ∀ {a? : Decidable 𝕒} → 𝕒 → Style.True a? from‐false‐witness : ∀ {a? : Decidable 𝕒} → (𝕒 → Empty) → Style.False a? to‐witness {a? = yes a} _ = a to‐false‐witness {a? = no f} _ = f from‐witness {a? = yes a} _ = _ from‐witness {a? = no f} w = f w from‐false‐witness {a? = no f} _ = _ from‐false‐witness {a? = yes a} w = w a
{ "alphanum_fraction": 0.4860240964, "avg_line_length": 41.5, "ext": "agda", "hexsha": "dbd5754fba7833bd08a7fa92d8cb1a86e05a0962", "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": "Light/Implementation/Relation/Decidable.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": "Light/Implementation/Relation/Decidable.agda", "max_line_length": 113, "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": "Light/Implementation/Relation/Decidable.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": 1186, "size": 4150 }
------------------------------------------------------------------------------ -- Properties of the inequalities of unary numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.UnaryNumbers.Inequalities.PropertiesATP where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.PropertiesATP open import FOTC.Data.Nat.PropertiesATP open import FOTC.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ postulate x<x+1 : ∀ {n} → N n → n < n + 1' {-# ATP prove x<x+1 x<Sx +-comm #-} postulate x<x+11 : ∀ {n} → N n → n < n + 11' {-# ATP prove x<x+11 x<x+Sy #-}
{ "alphanum_fraction": 0.481277533, "avg_line_length": 34.9230769231, "ext": "agda", "hexsha": "6bd828a1adf4e51121bc3354cd744eb5a990bcef", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/UnaryNumbers/Inequalities/PropertiesATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/UnaryNumbers/Inequalities/PropertiesATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/UnaryNumbers/Inequalities/PropertiesATP.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": 201, "size": 908 }
data Nat : Set where O : Nat S : Nat → Nat syntax S x = suc x test : Nat → Nat test _ = suc O syntax lim (λ n → m) = limit n at m data lim (f : Nat → Nat) : Set where syntax foo (λ _ → n) = const-foo n postulate foo : (Nat → Nat) → Nat
{ "alphanum_fraction": 0.5702811245, "avg_line_length": 13.1052631579, "ext": "agda", "hexsha": "5dec026cdc9701186e14ff3604abc5654914557e", "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/Issue758b.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/Issue758b.agda", "max_line_length": 36, "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/Issue758b.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": 93, "size": 249 }
{-# OPTIONS --type-in-type --no-pattern-matching #-} open import Spire.DarkwingDuck.Primitive open import Spire.DarkwingDuck.Derived module Spire.DarkwingDuck.Examples where ---------------------------------------------------------------------- NatN : String NatN = "Nat" NatE : Enum NatE = "zero" ∷ "suc" ∷ [] NatP : Tel NatP = Emp NatI : Indices NatP NatI = indices NatP Emp NatC : Constrs NatE NatP NatI NatC = constrs NatE NatP NatI (End tt , Rec tt (End tt) , tt) Nat : Former NatP NatI Nat = Form NatN NatE NatP NatI NatC zero : Inj NatN NatE NatP NatI NatC here zero = inj NatN NatE NatP NatI NatC here suc : Inj NatN NatE NatP NatI NatC (there here) suc = inj NatN NatE NatP NatI NatC (there here) elimNat : Elim NatN NatE NatP NatI NatC elimNat = elim NatN NatE NatP NatI NatC ---------------------------------------------------------------------- VecN : String VecN = "Vec" VecE : Enum VecE = "nil" ∷ "cons" ∷ [] VecP : Tel VecP = Ext Set λ _ → Emp VecI : Indices VecP VecI = indices VecP λ A → Ext Nat λ _ → Emp VecC : Constrs VecE VecP VecI VecC = constrs VecE VecP VecI λ A → End (zero , tt) , Arg Nat (λ n → Arg A λ _ → Rec (n , tt) (End (suc n , tt))) , tt Vec : Former VecP VecI Vec = Form VecN VecE VecP VecI VecC nil : Inj VecN VecE VecP VecI VecC here nil = inj VecN VecE VecP VecI VecC here cons : Inj VecN VecE VecP VecI VecC (there here) cons = inj VecN VecE VecP VecI VecC (there here) elimVec : Elim VecN VecE VecP VecI VecC elimVec = elim VecN VecE VecP VecI VecC ---------------------------------------------------------------------- add : Nat → Nat → Nat add = elimNat (λ n → Nat → Nat) (λ n → n) (λ m ih n → suc (ih n)) mult : Nat → Nat → Nat mult = elimNat (λ n → Nat → Nat) (λ n → zero) (λ m ih n → add n (ih n)) append : (A : Set) (m n : Nat) (xs : Vec A m) (ys : Vec A n) → Vec A (add m n) append A m n = elimVec A (λ m xs → (ys : Vec A n) → Vec A (add m n)) (λ ys → ys) (λ m' x xs ih ys → cons A (add m' n) x (ih ys)) m concat : (A : Set) (m n : Nat) (xss : Vec (Vec A m) n) → Vec A (mult n m) concat A m n = elimVec (Vec A m) (λ n xss → Vec A (mult n m)) (nil A) (λ m' xs xss ih → append A m (mult m' m) xs ih) n ---------------------------------------------------------------------- one : Nat one = suc zero two : Nat two = suc one three : Nat three = suc two [1,2] : Vec Nat two [1,2] = cons Nat one one (cons Nat zero two (nil Nat)) [3] : Vec Nat one [3] = cons Nat zero three (nil Nat) [1,2,3] : Vec Nat three [1,2,3] = cons Nat two one (cons Nat one two (cons Nat zero three (nil Nat))) test-append : [1,2,3] ≡ append Nat two one [1,2] [3] test-append = refl ----------------------------------------------------------------------
{ "alphanum_fraction": 0.5448577681, "avg_line_length": 22.85, "ext": "agda", "hexsha": "08b55174e9e2de6cee9c557669e69dd5fcd0c304", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "spire/spire", "max_forks_repo_path": "formalization/agda/Spire/DarkwingDuck/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "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": "spire/spire", "max_issues_repo_path": "formalization/agda/Spire/DarkwingDuck/Examples.agda", "max_line_length": 78, "max_stars_count": 43, "max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "spire/spire", "max_stars_repo_path": "formalization/agda/Spire/DarkwingDuck/Examples.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z", "num_tokens": 934, "size": 2742 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.FinSet.Binary.Small.Base where open import Cubical.Foundations.Equiv open import Cubical.Foundations.Prelude open import Cubical.Foundations.Univalence open import Cubical.Data.Bool hiding (isSetBool) data Binary : Type₀ El : Binary → Type₀ data Binary where ℕ₂ : Binary un : ∀ x y → El x ≃ El y → x ≡ y El ℕ₂ = Bool El (un _ _ e i) = ua e i
{ "alphanum_fraction": 0.7146226415, "avg_line_length": 20.1904761905, "ext": "agda", "hexsha": "8cbabbde2ca179d1bc24d3692d97cb2de5b83115", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/FinSet/Binary/Small/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/FinSet/Binary/Small/Base.agda", "max_line_length": 50, "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/FinSet/Binary/Small/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 129, "size": 424 }
------------------------------------------------------------------------ -- Examples ------------------------------------------------------------------------ module RecursiveDescent.InductiveWithFix.Examples where open import Data.List open import Data.Nat import Data.Char as C import Data.String as S open C using (Char) open S using (String) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Utilities open import RecursiveDescent.Index open import RecursiveDescent.InductiveWithFix open import RecursiveDescent.InductiveWithFix.Lib open Token C.decSetoid -- A function used to simplify the examples a little. _∈?_/_ : forall {nt i r} -> String -> Parser Char nt i r -> Grammar Char nt -> List r s ∈? p / g = parse-complete p g (S.toList s) module Ex₁ where -- e ∷= 0 + e | 0 data Nonterminal : ParserType₁ where e : Nonterminal _ Char grammar : Grammar Char Nonterminal grammar e = sym '0' ⊛> sym '+' ⊛> ! e ∣ sym '0' ex₁ : "0+0" ∈? (! e) / grammar ≡ '0' ∷ [] ex₁ = refl module Ex₂ where -- e ∷= f + e | f -- f ∷= 0 | 0 * f | ( e ) data Nonterminal : ParserType₁ where expr : Nonterminal _ Char factor : Nonterminal _ Char grammar : Grammar Char Nonterminal grammar expr = ! factor ⊛> sym '+' ⊛> ! expr ∣ ! factor grammar factor = sym '0' ∣ sym '0' ⊛> sym '*' ⊛> ! factor ∣ sym '(' ⊛> ! expr <⊛ sym ')' ex₁ : "(0*)" ∈? (! expr) / grammar ≡ [] ex₁ = refl ex₂ : "0*(0+0)" ∈? (! expr) / grammar ≡ '0' ∷ [] ex₂ = refl {- module Ex₃ where -- This is not allowed: -- e ∷= f + e | f -- f ∷= 0 | f * 0 | ( e ) data Nonterminal : ParserType₁ where expr : Nonterminal _ Char factor : Nonterminal _ Char grammar : Grammar Char Nonterminal grammar expr = ! factor ⊛> sym '+' ⊛> ! expr ∣ ! factor grammar factor = sym '0' ∣ ! factor ⊛> sym '*' ⊛> sym '0' ∣ sym '(' ⊛> ! expr <⊛ sym ')' -} module Ex₄ where -- The language aⁿbⁿcⁿ, which is not context free. -- The non-terminal top returns the number of 'a' characters parsed. data NT : ParserType₁ where top : NT _ ℕ -- top ∷= aⁿbⁿcⁿ as : ℕ -> NT _ ℕ -- as n ∷= aˡ⁺¹bⁿ⁺ˡ⁺¹cⁿ⁺ˡ⁺¹ bcs : Char -> ℕ -> NT _ ℕ -- bcs x n ∷= xⁿ⁺¹ grammar : Grammar Char NT grammar top = return 0 ∣ ! as zero grammar (as n) = suc <$ sym 'a' ⊛ ( ! as (suc n) ∣ _+_ <$> ! bcs 'b' n ⊛ ! bcs 'c' n ) grammar (bcs c zero) = sym c ⊛> return 0 grammar (bcs c (suc n)) = sym c ⊛> ! bcs c n ex₁ : "aaabbbccc" ∈? (! top) / grammar ≡ 3 ∷ [] ex₁ = refl ex₂ : "aaabbccc" ∈? (! top) / grammar ≡ [] ex₂ = refl module Ex₅ where -- A grammar making use of a parameterised parser from the library. data NT : ParserType₁ where a : NT _ Char as : NT _ ℕ grammar : Grammar Char NT grammar a = sym 'a' grammar as = length <$> ! a ⋆ ex₁ : "aaaaa" ∈? (! as) / grammar ≡ 5 ∷ [] ex₁ = refl module Ex₆ where -- A grammar which uses the chain₁ combinator. data NT : ParserType₁ where op : NT _ (ℕ -> ℕ -> ℕ) expr : Assoc -> NT _ ℕ grammar : Grammar Char NT grammar op = _+_ <$ sym '+' ∣ _*_ <$ sym '*' ∣ _∸_ <$ sym '∸' grammar (expr a) = chain₁ a number (! op) ex₁ : "12345" ∈? number / grammar ≡ 12345 ∷ [] ex₁ = refl ex₂ : "1+5*2∸3" ∈? (! expr left) / grammar ≡ 9 ∷ [] ex₂ = refl ex₃ : "1+5*2∸3" ∈? (! expr right) / grammar ≡ 1 ∷ [] ex₃ = refl module Ex₇ where -- A proper expression example. data NT : ParserType₁ where expr : NT _ ℕ term : NT _ ℕ factor : NT _ ℕ addOp : NT _ (ℕ -> ℕ -> ℕ) mulOp : NT _ (ℕ -> ℕ -> ℕ) grammar : Grammar Char NT grammar expr = chain₁ left (! term) (! addOp) grammar term = chain₁ left (! factor) (! mulOp) grammar factor = sym '(' ⊛> ! expr <⊛ sym ')' ∣ number grammar addOp = _+_ <$ sym '+' ∣ _∸_ <$ sym '∸' grammar mulOp = _*_ <$ sym '*' ex₁ : "1+5*2∸3" ∈? (! expr) / grammar ≡ 8 ∷ [] ex₁ = refl ex₂ : "1+5*(2∸3)" ∈? (! expr) / grammar ≡ 1 ∷ [] ex₂ = refl
{ "alphanum_fraction": 0.5055350554, "avg_line_length": 25.2093023256, "ext": "agda", "hexsha": "87af31b7bba24370de78617bd6c237c8f8fa397c", "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": "misc/RecursiveDescent/InductiveWithFix/Examples.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/RecursiveDescent/InductiveWithFix/Examples.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/RecursiveDescent/InductiveWithFix/Examples.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 1470, "size": 4336 }
module Logic.Leibniz where -- Leibniz equality _≡_ : {A : Set} -> A -> A -> Set1 x ≡ y = (P : _ -> Set) -> P x -> P y ≡-refl : {A : Set}(x : A) -> x ≡ x ≡-refl x P px = px ≡-sym : {A : Set}(x y : A) -> x ≡ y -> y ≡ x ≡-sym x y xy P py = xy (\z -> P z -> P x) (\px -> px) py ≡-trans : {A : Set}(x y z : A) -> x ≡ y -> y ≡ z -> x ≡ z ≡-trans x y z xy yz P px = yz P (xy P px) ≡-subst : {A : Set}(P : A -> Set)(x y : A) -> x ≡ y -> P x -> P y ≡-subst P _ _ xy = xy P
{ "alphanum_fraction": 0.4203821656, "avg_line_length": 23.55, "ext": "agda", "hexsha": "f997267f7a77265f75c2f70a4036485f167e3775", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Leibniz.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Leibniz.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Leibniz.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": 236, "size": 471 }
------------------------------------------------------------------------ -- One form of induction for natural numbers ------------------------------------------------------------------------ -- I want universe polymorphism. module Induction1.Nat where open import Data.Nat import Induction1.WellFounded as WF ------------------------------------------------------------------------ -- Complete induction based on <′ open WF _<′_ using (Acc; acc) allAcc : ∀ n → Acc n allAcc n = acc (helper n) where helper : ∀ n m → m <′ n → Acc m helper zero _ () helper (suc n) .n ≤′-refl = acc (helper n) helper (suc n) m (≤′-step m<′n) = helper n m m<′n open WF _<′_ public using () renaming (WfRec to <-Rec) open WF.All _<′_ allAcc public renaming ( wfRec-builder to <-rec-builder ; wfRec to <-rec )
{ "alphanum_fraction": 0.4601664685, "avg_line_length": 28.0333333333, "ext": "agda", "hexsha": "15846f13010cfe1136a4bd9b364b55f60e34010a", "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/Induction1/Nat.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/Induction1/Nat.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/Induction1/Nat.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": 208, "size": 841 }
-- Checks that UHC FFI calls using non-magic datatypes work module UHC-FFI where data Nat : Set where Zero : Nat Suc : Nat -> Nat {-# COMPILE UHC Nat = data UHC.Agda.Builtins.Nat (Zero | Suc) #-} {-# FOREIGN UHC __IMPORT__ Data.Char #-} open import Common.IO open import Common.Unit open import Common.String open import Common.Char postulate toLower : Char -> Char {-# COMPILE UHC toLower = Data.Char.toLower #-} main : IO Unit main = putStr (charToStr (toLower 'A'))
{ "alphanum_fraction": 0.7041666667, "avg_line_length": 20.8695652174, "ext": "agda", "hexsha": "b6c480971e21a4d9ae0fffacdb1124bfd827c5f6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:39:14.000Z", "max_forks_repo_head_hexsha": "e40569fe401cd73cf80be2356e455ab95a4c9498", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-uhc", "max_forks_repo_path": "test/Compiler/simple/UHC-FFI.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "e40569fe401cd73cf80be2356e455ab95a4c9498", "max_issues_repo_issues_event_max_datetime": "2017-02-24T19:38:17.000Z", "max_issues_repo_issues_event_min_datetime": "2017-02-24T19:27:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-uhc", "max_issues_repo_path": "test/Compiler/simple/UHC-FFI.agda", "max_line_length": 65, "max_stars_count": 4, "max_stars_repo_head_hexsha": "e40569fe401cd73cf80be2356e455ab95a4c9498", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-uhc", "max_stars_repo_path": "test/Compiler/simple/UHC-FFI.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-23T04:56:23.000Z", "max_stars_repo_stars_event_min_datetime": "2017-02-24T16:53:22.000Z", "num_tokens": 135, "size": 480 }
-- Andreas, 2014-06-27, issue raised by fsfbugs -- {-# OPTIONS -v interaction.give:10 -v tc:20 -v tc.conv.sort:30 #-} open import Common.Level record R (p r : Level) : Set (lsuc (p ⊔ r)) where field P : Set p _~_ : P -> P -> Set r f : (p p' : P) -> {!p ~ p'!} -- Give (p ~ p') here! -- PROBLEM WAS: -- When issuing C-c C-SPC, Agda complains -- Set (r ⊔ p) != Set (suc r ⊔ suc p) -- even though removing the hole manually (by removing '{!' and '!}') -- gives a well-typed definition. -- REASON WAS: -- Conversion.leqSort produced equality rather than subtyping constraint -- upon postponement: -- does (f : (p p' : P) → ?0 p r P _~_ p p') → f -- of sort Setω -- fit in Set (lsuc r ⊔ lsuc p) ? -- adding constraint [0] dLub (Set p) -- (λ p → dLub (Set p) (λ p' → Set (_4 p r P _~_ p p'))) -- == Set (lsuc r ⊔ lsuc p) -- WORKS NOW
{ "alphanum_fraction": 0.5402425579, "avg_line_length": 30.2333333333, "ext": "agda", "hexsha": "72ee7ec89a42e69719090a66d041e9f0c4922f97", "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/Issue1205.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/Issue1205.agda", "max_line_length": 78, "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/Issue1205.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": 318, "size": 907 }
module Unify-revised-correct where --open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Prelude.Function postulate Nat : Set Term : Nat → Set _~>_ : Nat → Nat → Set -- Fin → Term _=>_ : Nat → Nat → Set -- Fin → Fin ε : ∀ {m n} → m ~> n ▹ : ∀ {m n} -> m => n -> m ~> n _◃_ : ∀ {m n} → m ~> n → Term m → Term n _≐_ : {m n : Nat} → (m ~> n) → (m ~> n) → Set ◃ext : ∀ {m n} {f g : m ~> n} → f ≐ g → ∀ t → f ◃ t ≡ g ◃ t _◇_ : ∀ {l m n : Nat} → m ~> n → l ~> m → l ~> n _◆_ : ∀ {l m n : Nat} → m ~> n → l => m → l ~> n ≐-cong : ∀ {m n o} {f : m ~> n} {g} (h : _ ~> o) → f ≐ g → (h ◇ f) ≐ (h ◇ g) ≐-sym : ∀ {m n} {f : m ~> n} {g} → f ≐ g → g ≐ f subFact1 : ∀ {n} → (t : Term n) → ε ◃ t ≡ t subFact2 : ∀ {l m n} → (f : m ~> n) (g : _) (t : Term l) → (f ◇ g) ◃ t ≡ f ◃ (g ◃ t) subFact3 : ∀ {l m n} (f : m ~> n) (r : l => m) -> f ◇ ▹ r ≡ f ◆ r open import Prelude.Equality ◃ext' : ∀ {m n o} {f : m ~> n}{g : m ~> o}{h} -> f ≐ (h ◇ g) -> ∀ t -> f ◃ t ≡ h ◃ (g ◃ t) ◃ext' p t = trans (◃ext p t) (subFact2 _ _ t)
{ "alphanum_fraction": 0.4011299435, "avg_line_length": 34.2580645161, "ext": "agda", "hexsha": "cf51e326dd8d483ea381ca5109f5f9f4c682944a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/Unify-revised-correct.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/Unify-revised-correct.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/Unify-revised-correct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 531, "size": 1062 }
open import Oscar.Prelude open import Oscar.Class open import Oscar.Class.HasEquivalence open import Oscar.Class.Reflexivity open import Oscar.Class.Symmetry open import Oscar.Class.Transitivity open import Oscar.Class.IsEquivalence open import Oscar.Data.ProductIndexEquivalence import Oscar.Data.Constraint module Oscar.Property.Setoid.ProductIndexEquivalence where module _ {𝔬} {𝔒 : Ø 𝔬} {𝔭} {𝔓 : 𝔒 → Ø 𝔭} {ℓ} ⦃ _ : HasEquivalence 𝔒 ℓ ⦄ where instance 𝓡eflexivityExtensionṖropertyEquivalence : Reflexivity.class ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧ 𝓡eflexivityExtensionṖropertyEquivalence .⋆ .π₀ = reflexivity 𝓢ymmetryExtensionṖropertyEquivalence : Symmetry.class ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧ 𝓢ymmetryExtensionṖropertyEquivalence .⋆ (∁ P≈Q) .π₀ = symmetry P≈Q 𝓣ransitivityExtensionṖropertyEquivalence : Transitivity.class ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧ 𝓣ransitivityExtensionṖropertyEquivalence .⋆ (∁ P≈Q) (∁ Q≈R) .π₀ = transitivity P≈Q Q≈R IsEquivalenceExtensionṖroperty : IsEquivalence ProductIndexEquivalence⟦ 𝔒 / 𝔓 ⟧ IsEquivalenceExtensionṖroperty = ∁
{ "alphanum_fraction": 0.7792792793, "avg_line_length": 38.275862069, "ext": "agda", "hexsha": "6f659a85b9db1705abac3116533e7da678f9fc1d", "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/Property/Setoid/ProductIndexEquivalence.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/Property/Setoid/ProductIndexEquivalence.agda", "max_line_length": 99, "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/Property/Setoid/ProductIndexEquivalence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 383, "size": 1110 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Impl.Consensus.EpochManagerTypes open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Dijkstra.EitherD import LibraBFT.Impl.Properties.Util as Util open import LibraBFT.Prelude open import Optics.All module LibraBFT.Impl.Handle.InitProperties where module initHandlerSpec (pid : Author) (bsi : BootstrapInfo) where import LibraBFT.Yasm.Types as LYT record ContractOk (rm : RoundManager) (acts : List (LYT.Action NetworkMsg)) : Set where constructor mkContractOk field rmInv : Util.Invariants.RoundManagerInv rm sigs∈bs : ∀ {vs qc} → vs ∈ qcVotes qc → qc Util.QCProps.∈RoundManager rm → ∈BootstrapInfo-impl bsi (proj₂ vs) -- During epoch initialisation, no messages are sent -- EXCEPT the leader of Round 1 SENDS a ProposalMsg during initialization. -- Rust/Haskell impls do not include signatures in the genesis QC's LIWS. -- The initial proposal for (Epoch N) (Round 1) is built on a QC with empty signatures. isInitPM : ∀ {m} → LYT.send m ∈ acts → ∃[ pm ] ( m ≡ P pm × ∀ {vs qc} → vs ∈ qcVotes qc → qc QC∈NM m → ⊥) sdLVNothing : rm ^∙ rmSafetyRules ∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ nothing Contract : Maybe (RoundManager × List (LYT.Action NetworkMsg)) → Set Contract nothing = ⊤ Contract (just (rm , acts)) = ContractOk rm acts import LibraBFT.Impl.Handle as Handle open Handle.InitHandler postulate contract : ∀ {x} → initHandler pid bsi ≡ x → Contract x -- contract = EitherD-contract {!!} Contract contract'
{ "alphanum_fraction": 0.6320447136, "avg_line_length": 37.6666666667, "ext": "agda", "hexsha": "37fea119c1eb7de4bf2d50dd705999ec5bc6ae9a", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2022-02-18T01:04:32.000Z", "max_forks_repo_forks_event_min_datetime": "2020-12-16T19:43:52.000Z", "max_forks_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "oracle/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Impl/Handle/InitProperties.agda", "max_issues_count": 72, "max_issues_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_issues_repo_issues_event_max_datetime": "2022-03-25T05:36:11.000Z", "max_issues_repo_issues_event_min_datetime": "2021-02-04T05:04:33.000Z", "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "oracle/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Impl/Handle/InitProperties.agda", "max_line_length": 111, "max_stars_count": 4, "max_stars_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "oracle/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Impl/Handle/InitProperties.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-18T19:24:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-16T19:43:41.000Z", "num_tokens": 562, "size": 2147 }
module Basic where open import Level open import Data.Product open import Relation.Binary open Setoid renaming (_≈_ to eqSetoid) module Map where record Map {c₀ c₀′ ℓ ℓ′ : Level} (A : Setoid c₀ ℓ) (B : Setoid c₀′ ℓ′) : Set (suc (c₀ ⊔ ℓ ⊔ c₀′ ⊔ ℓ′)) where field mapping : Carrier A → Carrier B preserveEq : {x y : Carrier A} → (eqSetoid A x y) → eqSetoid B (mapping x) (mapping y) open Map public equality : {c₀ ℓ : Level} {A B : Setoid c₀ ℓ} (f g : Map A B) → Set _ equality {A = A} {B = B} f g = ∀(x : Carrier A) → eqSetoid B (mapping f x) (mapping g x) compose : {c₀ ℓ : Level} {A B C : Setoid c₀ ℓ} (f : Map B C) (g : Map A B) → Map A C compose {C = C} f g = record { mapping = λ x → mapping f (mapping g x); preserveEq = λ x₁ → (preserveEq f (preserveEq g x₁)) } identity : {c₀ ℓ : Level} {A : Setoid c₀ ℓ} → Map A A identity = record { mapping = λ x → x ; preserveEq = λ x₁ → x₁ } subst : ∀{c₀ ℓ} {A B : Setoid c₀ ℓ} {f g : Map A B} (a : Carrier A) → equality f g → eqSetoid B (mapping f a) (mapping g a) subst a eq = eq a LiftSetoid : ∀ {a b ℓ ℓ′} (A : Setoid a ℓ) → Setoid (a ⊔ b) (ℓ ⊔ ℓ′) LiftSetoid {a} {b} {ℓ} {ℓ′} A = record { Carrier = Lift {a} {b} (Carrier A) ; _≈_ = λ x x₁ → Lift {ℓ} {ℓ′} (eqSetoid A (lower x) (lower x₁)) ; isEquivalence = record { refl = lift (refl A) ; sym = λ x → lift (sym A (lower x)) ; trans = λ x x₁ → lift (trans A (lower x) (lower x₁)) } } liftMap : {c₀ c₀′ d ℓ ℓ′ ℓ″ : Level} {A : Setoid c₀ ℓ} {B : Setoid c₀′ ℓ′} → (f : Map.Map A B) → Map.Map (LiftSetoid {_} {c₀ ⊔ d} {_} {ℓ ⊔ ℓ″} A) (LiftSetoid {_} {c₀′ ⊔ d} {_} {ℓ′ ⊔ ℓ″} B) liftMap f = record { mapping = λ x → lift (Map.mapping f (lower x)) ; preserveEq = λ x≈y → lift (Map.preserveEq f (lower x≈y)) } lowerMap : {c₀ c₀′ d ℓ ℓ′ ℓ″ : Level} {A : Setoid c₀ ℓ} {B : Setoid c₀′ ℓ′} → (f : Map.Map (LiftSetoid {_} {c₀ ⊔ d} {_} {ℓ ⊔ ℓ″} A) (LiftSetoid {_} {c₀′ ⊔ d} {_} {ℓ′ ⊔ ℓ″} B)) → Map.Map A B lowerMap f = record { mapping = λ x → lower (Map.mapping f (lift x)) ; preserveEq = λ x≈y → lower (Map.preserveEq f (lift x≈y)) }
{ "alphanum_fraction": 0.5611613517, "avg_line_length": 42.8775510204, "ext": "agda", "hexsha": "51a454bae89aaebad7ea6c7c6078aed47be1c7e8", "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": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "myuon/agda-cate", "max_forks_repo_path": "src/Basic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "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": "myuon/agda-cate", "max_issues_repo_path": "src/Basic.agda", "max_line_length": 189, "max_stars_count": 2, "max_stars_repo_head_hexsha": "59004994acdbc65fb4f8abf0baa1777a8dbe758e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "myuon/agda-cate", "max_stars_repo_path": "src/Basic.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-02T07:30:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-28T04:59:31.000Z", "num_tokens": 903, "size": 2101 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory open import groups.ExactSequence open import groups.Exactness open import groups.HomSequence open import groups.KernelImageUniqueFactorization import cw.cohomology.GridPtdMap as GPM open import cw.CW module cw.cohomology.HigherCohomologyGroupsOnDiag {i} (OT : OrdinaryTheory i) {n} (⊙skel : ⊙Skeleton {i} (S (S n))) (ac : ⊙has-cells-with-choice 0 ⊙skel i) where private n≤SSn : n ≤ S (S n) n≤SSn = lteSR lteS ⊙skel₋₁ = ⊙cw-init ⊙skel ac₋₁ = ⊙init-has-cells-with-choice ⊙skel ac ⊙skel₋₂ = ⊙cw-take n≤SSn ⊙skel ac₋₂ = ⊙take-has-cells-with-choice n≤SSn ⊙skel ac open OrdinaryTheory OT open import cw.cohomology.Descending OT open import cw.cohomology.WedgeOfCells OT open import cw.cohomology.HigherCoboundary OT ⊙skel open import cw.cohomology.HigherCoboundaryGrid OT ⊙skel ac {- Coker ≃ C(X₂/X₀) ≃ C(X) ^ | | C(X₁/X₀) WoC WoC := Wedges of Cells -} private C-apex : Group i C-apex = C (ℕ-to-ℤ (S (S n))) (⊙Cofiber (⊙cw-incl-tail n≤SSn ⊙skel)) open import cohomology.LongExactSequence cohomology-theory (ℕ-to-ℤ (S n)) (⊙cw-incl-tail n≤SSn ⊙skel) C-apex-iso-C-cw : C-apex ≃ᴳ C (ℕ-to-ℤ (S (S n))) ⊙⟦ ⊙skel ⟧ C-apex-iso-C-cw = Exact2.G-trivial-and-L-trivial-implies-H-iso-K (exact-seq-index 1 C-cofiber-exact-seq) (exact-seq-index 2 C-cofiber-exact-seq) (C-cw-at-higher ⊙skel₋₂ ltS ac₋₂) (C-cw-at-higher ⊙skel₋₂ (ltSR ltS) ac₋₂) open import groups.KernelImage (cst-hom {H = Lift-group {j = i} Unit-group}) cw-co∂-last (CXₙ/Xₙ₋₁-is-abelian ⊙skel (ℕ-to-ℤ (S (S n)))) open import groups.KernelCstImage (Lift-group {j = i} Unit-group) cw-co∂-last (CXₙ/Xₙ₋₁-is-abelian ⊙skel (ℕ-to-ℤ (S (S n)))) C-cw-iso-ker/im : C (ℕ-to-ℤ (S (S n))) ⊙⟦ ⊙skel ⟧ ≃ᴳ Ker/Im C-cw-iso-ker/im = (C-apex-iso-C-cw ∘eᴳ Coker-cw-co∂-last ∘eᴳ Ker-cst-quot-Im) ⁻¹ᴳ
{ "alphanum_fraction": 0.6512820513, "avg_line_length": 29.5454545455, "ext": "agda", "hexsha": "c5699424064ae764646e525fe6ffe22214328478", "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/HigherCohomologyGroupsOnDiag.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/HigherCohomologyGroupsOnDiag.agda", "max_line_length": 88, "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/HigherCohomologyGroupsOnDiag.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 841, "size": 1950 }
module BasicIPC.Metatheory.ClosedHilbert-TarskiGluedClosedImplicit where open import BasicIPC.Syntax.ClosedHilbert public open import BasicIPC.Semantics.TarskiGluedClosedImplicit public open ImplicitSyntax (⊢_) public -- Completeness with respect to a particular model. module _ {{_ : Model}} where reify : ∀ {A} → ⊩ A → ⊢ A reify {α P} s = syn s reify {A ▻ B} s = syn s reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s)) reify {⊤} s = unit -- Additional useful equipment. module _ {{_ : Model}} where ⟪K⟫ : ∀ {A B} → ⊩ A → ⊩ B ▻ A ⟪K⟫ a = app ck (reify a) ⅋ K a ⟪S⟫′ : ∀ {A B C} → ⊩ A ▻ B ▻ C → ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ s₁ = app cs (reify s₁) ⅋ λ s₂ → app (app cs (reify s₁)) (reify s₂) ⅋ ⟪S⟫ s₁ s₂ _⟪,⟫′_ : ∀ {A B} → ⊩ A → ⊩ B ▻ A ∧ B _⟪,⟫′_ a = app cpair (reify a) ⅋ _,_ a -- Soundness with respect to all models, or evaluation, for closed terms only. eval₀ : ∀ {A} → ⊢ A → ⊨ A eval₀ (app t u) = eval₀ t ⟪$⟫ eval₀ u eval₀ ci = ci ⅋ I eval₀ ck = ck ⅋ ⟪K⟫ eval₀ cs = cs ⅋ ⟪S⟫′ eval₀ cpair = cpair ⅋ _⟪,⟫′_ eval₀ cfst = cfst ⅋ π₁ eval₀ csnd = csnd ⅋ π₂ eval₀ unit = ∙ -- Correctness of evaluation with respect to conversion. eval₀✓ : ∀ {{_ : Model}} {A} {t t′ : ⊢ A} → t ⋙ t′ → eval₀ t ≡ eval₀ t′ eval₀✓ refl⋙ = refl eval₀✓ (trans⋙ p q) = trans (eval₀✓ p) (eval₀✓ q) eval₀✓ (sym⋙ p) = sym (eval₀✓ p) eval₀✓ (congapp⋙ p q) = cong² _⟪$⟫_ (eval₀✓ p) (eval₀✓ q) eval₀✓ (congi⋙ p) = cong I (eval₀✓ p) eval₀✓ (congk⋙ p q) = cong² K (eval₀✓ p) (eval₀✓ q) eval₀✓ (congs⋙ p q r) = cong³ ⟪S⟫ (eval₀✓ p) (eval₀✓ q) (eval₀✓ r) eval₀✓ (congpair⋙ p q) = cong² _,_ (eval₀✓ p) (eval₀✓ q) eval₀✓ (congfst⋙ p) = cong π₁ (eval₀✓ p) eval₀✓ (congsnd⋙ p) = cong π₂ (eval₀✓ p) eval₀✓ beta▻ₖ⋙ = refl eval₀✓ beta▻ₛ⋙ = refl eval₀✓ beta∧₁⋙ = refl eval₀✓ beta∧₂⋙ = refl eval₀✓ eta∧⋙ = refl eval₀✓ eta⊤⋙ = refl -- The canonical model. private instance canon : Model canon = record { ⊩ᵅ_ = λ P → ⊢ α P } -- Completeness with respect to all models, or quotation, for closed terms only. quot₀ : ∀ {A} → ⊨ A → ⊢ A quot₀ s = reify s -- Normalisation by evaluation, for closed terms only. norm₀ : ∀ {A} → ⊢ A → ⊢ A norm₀ = quot₀ ∘ eval₀ -- Correctness of normalisation with respect to conversion. norm₀✓ : ∀ {{_ : Model}} {A} {t t′ : ⊢ A} → t ⋙ t′ → norm₀ t ≡ norm₀ t′ norm₀✓ p = cong reify (eval₀✓ p)
{ "alphanum_fraction": 0.5533199195, "avg_line_length": 26.7204301075, "ext": "agda", "hexsha": "22a14df9b2241300df87b0aa413bf54fd41bc47b", "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/Metatheory/ClosedHilbert-TarskiGluedClosedImplicit.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/Metatheory/ClosedHilbert-TarskiGluedClosedImplicit.agda", "max_line_length": 80, "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/Metatheory/ClosedHilbert-TarskiGluedClosedImplicit.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": 1131, "size": 2485 }
module resugar where open import cedille-types open import general-util open import syntax-util open import type-util {-# TERMINATING #-} resugar : ∀ {ed} → ⟦ ed ⟧ → ⟦ ed ⟧' resugar-tk : tpkd → ex-tk resugar {TERM} (App t t') = ExApp (resugar t) ff (resugar t') resugar {TERM} (AppE t tT) = either-else' tT (ExApp (resugar t) tt ∘ resugar) (ExAppTp (resugar t) ∘ resugar) resugar {TERM} (Beta t t') = ExBeta pi-gen (just (PosTm (resugar t) pi-gen)) (just (PosTm (resugar t') pi-gen)) resugar {TERM} (Delta b? T t) = ExDelta pi-gen (just (resugar T)) (resugar t) resugar {TERM} (Hole pi) = ExHole pi resugar {TERM} (IotaPair t₁ t₂ x Tₓ) = ExIotaPair pi-gen (resugar t₁) (resugar t₂) (just (ExGuide pi-gen x (resugar Tₓ))) pi-gen resugar {TERM} (IotaProj t n) = ExIotaProj (resugar t) (if n iff ι1 then "1" else "2") pi-gen resugar {TERM} (Lam me x tk? t) = ExLam pi-gen me pi-gen x (maybe-map resugar-tk tk?) (resugar t) resugar {TERM} (LetTm me x T? t t') = ExLet pi-gen me (ExDefTerm pi-gen x (maybe-map resugar T?) (resugar t)) (resugar t') resugar {TERM} (LetTp x k T t) = ExLet pi-gen tt (ExDefType pi-gen x (resugar k) (resugar T)) (resugar t) resugar {TERM} (Phi t₌ t₁ t₂) = ExPhi pi-gen (resugar t₌) (resugar t₁) (resugar t₂) pi-gen resugar {TERM} (Rho t₌ x Tₓ t) = ExRho pi-gen ff nothing (resugar t₌) (just (ExGuide pi-gen x (resugar Tₓ))) (resugar t) resugar {TERM} (Sigma t) = ExSigma pi-gen (resugar t) resugar {TERM} (Mu μ t Tₘ? f~ ms) = ExMu pi-gen (either-else' μ (λ t → ExIsMu' (resugar <$> t)) (ExIsMu pi-gen)) (resugar t) (maybe-map resugar Tₘ?) pi-gen (map (λ {(Case x cas t _) → ExCase pi-gen x (map (λ {(CaseArg me x tk?) → let me' = case (me , tk?) of uncurry λ where ff _ → ExCaseArgTm tt (just (Tkk _)) → ExCaseArgTp tt _ → ExCaseArgEr in ExCaseArg me' pi-gen x}) cas) (resugar t)}) ms) pi-gen resugar {TERM} (Var x) = ExVar pi-gen x resugar {TYPE} (TpAbs me x tk T) = ExTpAbs pi-gen me pi-gen x (resugar-tk tk) (resugar T) resugar {TYPE} (TpApp T tT) = either-else' tT (ExTpAppt (resugar T) ∘ resugar) (ExTpApp (resugar T) ∘ resugar) resugar {TYPE} (TpEq t₁ t₂) = ExTpEq pi-gen (resugar t₁) (resugar t₂) pi-gen resugar {TYPE} (TpHole pi) = ExTpHole pi resugar {TYPE} (TpIota x T₁ T₂) = ExTpIota pi-gen pi-gen x (resugar T₁) (resugar T₂) resugar {TYPE} (TpLam x tk T) = ExTpLam pi-gen pi-gen x (resugar-tk tk) (resugar T) resugar {TYPE} (TpVar x) = ExTpVar pi-gen x resugar {KIND} (KdAbs x tk k) = ExKdAbs pi-gen pi-gen x (resugar-tk tk) (resugar k) resugar {KIND} (KdHole pi) = ExKdHole pi resugar {KIND} KdStar = ExKdStar pi-gen resugar-tk = either-else (ExTkt ∘ resugar) (ExTkk ∘ resugar)
{ "alphanum_fraction": 0.6292700467, "avg_line_length": 35.6538461538, "ext": "agda", "hexsha": "482e446de4b37cbe4e9ff20d18958db62b99b5f7", "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": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zmthy/cedille", "max_forks_repo_path": "src/resugar.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "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": "zmthy/cedille", "max_issues_repo_path": "src/resugar.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zmthy/cedille", "max_stars_repo_path": "src/resugar.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1102, "size": 2781 }
open import Prelude module Implicits.Resolution.GenericFinite.Algorithm.Completeness where open import Induction.WellFounded open import Induction.Nat open import Data.Fin.Substitution open import Data.Nat.Base using (_<′_) open import Data.Maybe as Maybe open import Data.Nat hiding (_<_) open import Data.Nat.Properties open import Relation.Binary using (module DecTotalOrder) open DecTotalOrder decTotalOrder using () renaming (refl to ≤-refl; trans to ≤-trans) open import Data.Unit open import Implicits.Syntax open import Implicits.Syntax.Type.Unification open import Implicits.Syntax.Type.Unification.Lemmas as mgu hiding (complete) open import Implicits.Substitutions open import Implicits.Substitutions.Lemmas open import Implicits.Resolution.GenericFinite.Resolution open import Implicits.Resolution.GenericFinite.Algorithm open import Implicits.Resolution.GenericFinite.TerminationCondition open import Implicits.Resolution.Termination open import Extensions.Bool as Bool private module M = MetaTypeMetaSubst module ResolutionComplete (cond : TerminationCondition) where open TerminationCondition cond open ResolutionAlgorithm cond open ResolutionRules cond open Lemmas lemx : ∀ {ν m} {Δ : ICtx ν} {Φ} r c τ (u : M.MetaSub MetaType ν m zero) → Δ , Φ ⊢ from-meta (r M./ u M.↑tp) tp[/tp c ] ↓ τ → Δ , Φ ⊢ from-meta (open-meta r M./ (to-meta c ∷ u)) ↓ τ lemx r c τ u p = {!!} mutual match'-complete : ∀ {ν m} (Δ : ICtx ν) (Φ : TCtx) τ (r : MetaType m ν) → (Φ↓ : T-Acc Φ) → (m↓ : m<-Acc r) → (∃ λ u → Δ , Φ ⊢ from-meta (r M./ u) ↓ τ) → Is-just (match' Δ Φ τ r Φ↓ m↓) match'-complete Δ Φ τ (a ⇒ b) f (acc g) (proj₁ , i-iabs x y b↓τ) with match' Δ Φ τ b f (g _ (b-m<-a⇒b a b)) | match'-complete Δ Φ τ b f (g _ (b-m<-a⇒b a b)) (, b↓τ) match'-complete Δ Φ τ (a ⇒ b) f (acc g) (u , i-iabs x y b↓τ) | nothing | () match'-complete Δ Φ τ (a ⇒ b) f (acc g) (u , i-iabs x₁ y b↓τ) | just u' | just px with (step Φ Δ (from-meta (a M./ u)) (from-meta (b M./ u)) τ) <? Φ match'-complete Δ Φ τ (a ⇒ b) f (acc g) (u , i-iabs x₁ y b↓τ) | just u' | just px | yes p = {!!} match'-complete Δ Φ τ (a ⇒ b) f (acc g) (u , i-iabs x₁ y b↓τ) | just u' | just px | no ¬p = {!¬p!} -- match'-complete Δ Φ τ (a ⇒ b) (acc f) (acc g) | just u | yes Φ< -- with resolve' Δ (step Φ Δ (from-meta (a M./ u)) (from-meta (b M./ u)) τ) -- (from-meta (a M./ u)) (f _ Φ<) -- match'-complete Δ Φ τ (a ⇒ b) (acc f) (acc g) | just u | yes Φ< | true = just u -- match'-complete Δ Φ τ (a ⇒ b) (acc f) (acc g) | just u | yes Φ< | false = nothing -- match'-complete Δ Φ τ (a ⇒ b) (acc f) (acc g) | just u | no φ> = nothing match'-complete Δ Φ τ (∀' r) Φ↓ (acc m↓) (u , i-tabs b open-r↓τ) with match' Δ Φ τ (open-meta r) Φ↓ (m↓ _ (open-meta-a-m<-∀'a r)) | match'-complete Δ Φ τ (open-meta r) Φ↓ (m↓ _ (open-meta-a-m<-∀'a r)) (, lemx r b τ u open-r↓τ) match'-complete Δ Φ τ (∀' r) Φ↓ (acc m↓) (u , i-tabs b open-r↓τ) | just x | just px = just tt match'-complete Δ Φ τ (∀' r) Φ↓ (acc m↓) (u , i-tabs b open-r↓τ) | nothing | () match'-complete Δ Φ .(tvar x) (simpl (tvar x)) Φ↓ m↓ (u , i-simp .(tvar x)) = mgu.complete (simpl (tvar x)) (tvar x) u refl match'-complete Δ Φ τ (simpl (mvar x)) Φ↓ m↓ (u , proj₂) = let (u' , u'-uni) = mvar-unifiable x τ in mgu.complete (simpl (mvar x)) τ u' u'-uni match'-complete Δ Φ ._ (simpl (a →' b)) Φ↓ m↓ (u , i-simp ._) = mgu.complete (simpl (a →' b)) _ u refl match'-complete Δ Φ .(tc x) (simpl (tc x)) Φ↓ m↓ (u , ResolutionRules.i-simp .(tc x)) = mgu.complete (simpl (tc x)) _ u refl match-complete : ∀ {ν} (Δ : ICtx ν) (Φ : TCtx) → (τ : SimpleType ν) → (r : Type ν) → (Φ↓ : T-Acc Φ) → Δ , Φ ⊢ r ↓ τ → Is-true (match Δ Φ τ r Φ↓) match-complete Δ Φ τ r Φ↓ p with match' Δ Φ τ (to-meta {zero} r) Φ↓ (m<-well-founded _) | match'-complete Δ Φ τ (to-meta {zero} r) Φ↓ (m<-well-founded _) ([] , subst (λ z → Δ , Φ ⊢ z ↓ τ) (sym $ from-to-meta-/-vanishes) p) match-complete Δ Φ τ r Φ↓ p | just x | just px = true tt match-complete Δ Φ τ r Φ↓ p | nothing | () match1st-complete : ∀ {ν} (Δ : ICtx ν) (Φ : TCtx) (ρs : ICtx ν) → (τ : SimpleType ν) → (Φ↓ : T-Acc Φ) → (∃ λ r → r List.∈ ρs × Δ , Φ ⊢ r ↓ τ) → Is-true (match1st Δ Φ ρs τ Φ↓) match1st-complete Δ Φ List.[] τ Φ↓ (_ , () , _) match1st-complete Δ Φ (x List.∷ ρs) τ Φ↓ (.x , here refl , r↓τ) with match Δ Φ τ x Φ↓ | match-complete Δ Φ τ x Φ↓ r↓τ match1st-complete Δ Φ (x List.∷ ρs) τ Φ↓ (.x , here refl , r↓τ) | true | true _ = true tt match1st-complete Δ Φ (x List.∷ ρs) τ Φ↓ (.x , here refl , r↓τ) | false | () match1st-complete Δ Φ (x List.∷ ρs) τ Φ↓ (proj₁ , there p , r↓τ) with match Δ Φ τ x Φ↓ match1st-complete Δ Φ (x List.∷ ρs) τ Φ↓ (r , there r∈ρs , r↓τ) | true = true tt match1st-complete Δ Φ (x List.∷ ρs) τ Φ↓ (r , there r∈ρs , r↓τ) | false = match1st-complete Δ Φ ρs τ Φ↓ (r , r∈ρs , r↓τ) complete' : ∀ {ν} (Δ : ICtx ν) Φ {r} → (Φ↓ : T-Acc Φ) → Δ , Φ ⊢ᵣ r → Is-true (resolve' Δ Φ r Φ↓) complete' Δ Φ Φ↓ (r-simp x∈Δ x↓τ) = match1st-complete Δ Φ Δ _ Φ↓ (_ , x∈Δ , x↓τ) complete' Δ Φ Φ↓ (r-iabs ρ₁ p) = complete' (ρ₁ List.∷ Δ) Φ Φ↓ p complete' Δ Φ Φ↓ (r-tabs p) = complete' (ictx-weaken Δ) Φ Φ↓ p complete : ∀ {ν} (Δ : ICtx ν) Φ {r} → (Φ↓ : T-Acc Φ) → Δ , Φ ⊢ᵣ r → Is-true (resolve Δ Φ r) complete Δ Φ Φ↓ p = complete' Δ Φ (wf-< _) p
{ "alphanum_fraction": 0.5512042973, "avg_line_length": 51.0707964602, "ext": "agda", "hexsha": "bf5022ecfb410b5b7f9e76d7d3fd4e49af277323", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/GenericFinite/Algorithm/Completeness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/GenericFinite/Algorithm/Completeness.agda", "max_line_length": 102, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/GenericFinite/Algorithm/Completeness.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 2251, "size": 5771 }
------------------------------------------------------------------------ -- A well-typed representation of a dependently typed language ------------------------------------------------------------------------ -- The code is parametrised by an arbitrary (small, unindexed) -- universe. import Level open import Data.Universe module README.DependentlyTyped.Term (Uni₀ : Universe Level.zero Level.zero) where open import Data.Product as Prod renaming (curry to c; uncurry to uc) open import Data.Unit open import Data.Universe.Indexed import deBruijn.Context open import Function hiding (_∋_) renaming (const to k) open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- Wrapper types -- Used to make El "constructor-headed", which in turn makes Agda -- infer more types for us. record U₀ : Set where field a : Universe.U Uni₀ record El₀ (a : U₀) : Set where field El : Universe.El Uni₀ (U₀.a a) ------------------------------------------------------------------------ -- An indexed universe -- A type which represents the "spine" of a universe code (or type). data Spine : Set where ⋆ el : Spine π : (sp₁ sp₂ : Spine) → Spine -- The universe contains the universe above and is closed under -- Π-types. -- -- The universe could be defined using induction-recursion, but the -- following recursive definition has the advantage that more things -- are definitionally equal. Previously I used induction-recursion, -- and then I proved π-fst-snd (below) using the assumption of -- extensionality of functions, and I used a cast in the definition of -- README.DependentlyTyped.NBE.Value.řeflect. -- -- TODO: Find out if the use of spines is compatible with large -- elimination. mutual U : Spine → Set U ⋆ = ⊤ U el = U₀ U (π sp₁ sp₂) = Σ (U sp₁) λ a → El a → U sp₂ El : ∀ {sp} → U sp → Set El {⋆} _ = U₀ El {el} a = El₀ a El {π sp₁ sp₂} (a , b) = (x : El a) → El (b x) Uni : IndexedUniverse _ _ _ Uni = record { I = Spine; U = U; El = El } -- Some synonyms/specialisations. U-⋆ : U ⋆ U-⋆ = _ U-el : U₀ → U el U-el = id U-π : ∀ {sp₁} {sp₂} (a : U sp₁) → (El a → U sp₂) → U (π sp₁ sp₂) U-π = _,_ ------------------------------------------------------------------------ -- Contexts and variables -- We get these for free. open deBruijn.Context Uni public renaming (_·_ to _⊙_; ·-cong to ⊙-cong) -- Some abbreviations. IType-π : ∀ {Γ} (σ : Type Γ) (τ : Type (Γ ▻ σ)) → IType Γ (π (index σ) (index τ)) IType-π σ τ = k U-π ˢ indexed-type σ ˢ c (indexed-type τ) Type-π : ∀ {Γ} (σ : Type Γ) → Type (Γ ▻ σ) → Type Γ Type-π σ τ = -, IType-π σ τ ------------------------------------------------------------------------ -- Projections -- Types with π-spines can be split up into a first and a second part. ifst : ∀ {Γ sp₁ sp₂} → IType Γ (π sp₁ sp₂) → IType Γ sp₁ ifst σ γ = proj₁ (σ γ) fst : ∀ {Γ sp₁ sp₂} → IType Γ (π sp₁ sp₂) → Type Γ fst σ = -, ifst σ isnd : ∀ {Γ sp₁ sp₂} (σ : IType Γ (π sp₁ sp₂)) → IType (Γ ▻ fst σ) sp₂ isnd σ (γ , v) = proj₂ (σ γ) v snd : ∀ {Γ sp₁ sp₂} (σ : IType Γ (π sp₁ sp₂)) → Type (Γ ▻ fst σ) snd σ = -, isnd σ -- The split is correct. π-fst-snd : ∀ {Γ sp₁ sp₂} (σ : IType Γ (π sp₁ sp₂)) → σ ≡ IType-π (fst σ) (snd σ) π-fst-snd σ = P.refl ------------------------------------------------------------------------ -- Well-typed terms mutual infixl 9 _·_ infix 3 _⊢_ -- Terms. data _⊢_ (Γ : Ctxt) : Type Γ → Set where var : ∀ {σ} (x : Γ ∋ σ) → Γ ⊢ σ ƛ : ∀ {σ τ} (t : Γ ▻ σ ⊢ τ) → Γ ⊢ Type-π σ τ _·_ : ∀ {sp₁ sp₂ σ} (t₁ : Γ ⊢ π sp₁ sp₂ , σ) (t₂ : Γ ⊢ fst σ) → Γ ⊢ snd σ /̂ ŝub ⟦ t₂ ⟧ -- Semantics of terms. ⟦_⟧ : ∀ {Γ σ} → Γ ⊢ σ → Value Γ σ ⟦ var x ⟧ γ = lookup x γ ⟦ ƛ t ⟧ γ = λ v → ⟦ t ⟧ (γ , v) ⟦ t₁ · t₂ ⟧ γ = (⟦ t₁ ⟧ γ) (⟦ t₂ ⟧ γ) -- Terms are "term-like". Tm : Term-like _ Tm = record { _⊢_ = _⊢_; ⟦_⟧ = ⟦_⟧ } open Term-like Tm public hiding (_⊢_; ⟦_⟧) ------------------------------------------------------------------------ -- Syntactic contexts and types -- Syntactic types. infix 3 _⊢_type data _⊢_type (Γ : Ctxt) : Type Γ → Set where ⋆ : Γ ⊢ -, k U-⋆ type el : (t : Γ ⊢ -, k U-⋆) → Γ ⊢ -, k U-el ˢ ⟦ t ⟧ type π : ∀ {sp₁ sp₂ σ τ} (σ′ : Γ ⊢ sp₁ , σ type) (τ′ : Γ ▻ (-, σ) ⊢ sp₂ , τ type) → Γ ⊢ -, k U-π ˢ σ ˢ c τ type -- Syntactic contexts. infixl 5 _▻_ infix 3 _ctxt data _ctxt : Ctxt → Set where ε : ε ctxt _▻_ : ∀ {Γ σ} (Γ′ : Γ ctxt) (σ′ : Γ ⊢ σ type) → Γ ▻ σ ctxt -- Semantics of types. ⟦_⟧type : ∀ {Γ σ} → Γ ⊢ σ type → Type Γ ⟦_⟧type {σ = σ} _ = σ -- We can project out the first and second components of a syntactic -- Π-type. fst′ : ∀ {Γ sp₁ sp₂} {σ : IType Γ (π sp₁ sp₂)} → Γ ⊢ -, σ type → Γ ⊢ fst σ type fst′ (π σ′ τ′) = σ′ snd′ : ∀ {Γ sp₁ sp₂} {σ : IType Γ (π sp₁ sp₂)} → Γ ⊢ -, σ type → Γ ▻ fst σ ⊢ snd σ type snd′ (π σ′ τ′) = τ′ ------------------------------------------------------------------------ -- Examples -- The polymorphic identity function. identity : ∀ {Γ} → Γ ⊢ ⟦ π ⋆ (π (el (var zero)) (el (var (suc zero)))) ⟧type identity = ƛ {σ = ⟦ ⋆ ⟧type} (ƛ {σ = ⟦ el (var zero) ⟧type} (var zero)) -- The polymorphic identity function, with the type written in a less -- compact way. identity′ : ∀ {Γ} → Γ ⊢ -, k U-π ˢ k U-⋆ ˢ c (k U-π ˢ (k U-el ˢ ⟦ var zero ⟧) ˢ c (k U-el ˢ ⟦ var (suc zero) ⟧)) identity′ = ƛ {σ = ⟦ ⋆ ⟧type} (ƛ {σ = ⟦ el (var zero) ⟧type} (var zero)) -- The polymorphic identity function applied to some variables from -- the context. identity· : ∀ {Γ} → Γ ▻ ⟦ ⋆ ⟧type ▻ ⟦ el (var zero) ⟧type ⊢ ⟦ el (var (suc zero)) ⟧type identity· = ƛ {σ = ⟦ ⋆ ⟧type} (ƛ {σ = ⟦ el (var zero) ⟧type} (var zero)) · var (suc zero) · var zero ------------------------------------------------------------------------ -- Equality -- Syntactic type telescopes. record [type] : Set where constructor [_] field {Γ} : Ctxt {σ} : Type Γ σ′ : Γ ⊢ σ type -- Equality of syntactic types. infix 4 _≅-type_ _≅-type_ : ∀ {Γ₁ σ₁} (σ′₁ : Γ₁ ⊢ σ₁ type) {Γ₂ σ₂} (σ′₂ : Γ₂ ⊢ σ₂ type) → Set σ′₁ ≅-type σ′₂ = _≡_ {A = [type]} [ σ′₁ ] [ σ′₂ ] -- If the indices are equal, then _≅-type_ coincides with _≡_. ≅-type-⇒-≡ : ∀ {Γ σ} {σ′₁ σ′₂ : Γ ⊢ σ type} → σ′₁ ≅-type σ′₂ → σ′₁ ≡ σ′₂ ≅-type-⇒-≡ P.refl = P.refl -- Certain uses of substitutivity can be removed. drop-subst-⊢-type : ∀ {a} {A : Set a} {x₁ x₂ : A} {Γ} (f : A → Type Γ) {σ′} (eq : x₁ ≡ x₂) → P.subst (λ x → Γ ⊢ f x type) eq σ′ ≅-type σ′ drop-subst-⊢-type f P.refl = P.refl -- Some congruence lemmas. IType-π-cong : ∀ {Γ₁ σ₁} {τ₁ : Type (Γ₁ ▻ σ₁)} {Γ₂ σ₂} {τ₂ : Type (Γ₂ ▻ σ₂)} → τ₁ ≅-Type τ₂ → IType-π σ₁ τ₁ ≅-IType IType-π σ₂ τ₂ IType-π-cong P.refl = P.refl Type-π-cong : ∀ {Γ₁ σ₁} {τ₁ : Type (Γ₁ ▻ σ₁)} {Γ₂ σ₂} {τ₂ : Type (Γ₂ ▻ σ₂)} → τ₁ ≅-Type τ₂ → Type-π σ₁ τ₁ ≅-Type Type-π σ₂ τ₂ Type-π-cong P.refl = P.refl ifst-cong : ∀ {Γ₁ sp₁₁ sp₂₁} {σ₁ : IType Γ₁ (π sp₁₁ sp₂₁)} {Γ₂ sp₁₂ sp₂₂} {σ₂ : IType Γ₂ (π sp₁₂ sp₂₂)} → σ₁ ≅-IType σ₂ → ifst σ₁ ≅-IType ifst σ₂ ifst-cong P.refl = P.refl fst-cong : ∀ {Γ₁ sp₁₁ sp₂₁} {σ₁ : IType Γ₁ (π sp₁₁ sp₂₁)} {Γ₂ sp₁₂ sp₂₂} {σ₂ : IType Γ₂ (π sp₁₂ sp₂₂)} → σ₁ ≅-IType σ₂ → fst σ₁ ≅-Type fst σ₂ fst-cong P.refl = P.refl isnd-cong : ∀ {Γ₁ sp₁₁ sp₂₁} {σ₁ : IType Γ₁ (π sp₁₁ sp₂₁)} {Γ₂ sp₁₂ sp₂₂} {σ₂ : IType Γ₂ (π sp₁₂ sp₂₂)} → σ₁ ≅-IType σ₂ → isnd σ₁ ≅-IType isnd σ₂ isnd-cong P.refl = P.refl snd-cong : ∀ {Γ₁ sp₁₁ sp₂₁} {σ₁ : IType Γ₁ (π sp₁₁ sp₂₁)} {Γ₂ sp₁₂ sp₂₂} {σ₂ : IType Γ₂ (π sp₁₂ sp₂₂)} → σ₁ ≅-IType σ₂ → snd σ₁ ≅-Type snd σ₂ snd-cong P.refl = P.refl -- Note that _ˢ_ and curry are the semantic counterparts of -- application and abstraction. ˢ-cong : ∀ {Γ₁ sp₁₁ sp₂₁ σ₁} {v₁ : Value Γ₁ (fst σ₁)} {f₁ : Value Γ₁ (π sp₁₁ sp₂₁ , σ₁)} {Γ₂ sp₁₂ sp₂₂ σ₂} {v₂ : Value Γ₂ (fst σ₂)} {f₂ : Value Γ₂ (π sp₁₂ sp₂₂ , σ₂)} → f₁ ≅-Value f₂ → v₁ ≅-Value v₂ → f₁ ˢ v₁ ≅-Value f₂ ˢ v₂ ˢ-cong P.refl P.refl = P.refl curry-cong : ∀ {Γ₁ σ₁ τ₁} {v₁ : Value (Γ₁ ▻ σ₁) τ₁} {Γ₂ σ₂ τ₂} {v₂ : Value (Γ₂ ▻ σ₂) τ₂} → v₁ ≅-Value v₂ → c v₁ ≅-Value c v₂ curry-cong P.refl = P.refl uncurry-cong : ∀ {Γ₁ sp₁₁ sp₂₁ σ₁} {v₁ : Value Γ₁ (π sp₁₁ sp₂₁ , σ₁)} {Γ₂ sp₁₂ sp₂₂ σ₂} {v₂ : Value Γ₂ (π sp₁₂ sp₂₂ , σ₂)} → v₁ ≅-Value v₂ → _≅-Value_ {σ₁ = snd σ₁} (uc v₁) {σ₂ = snd σ₂} (uc v₂) uncurry-cong P.refl = P.refl ⋆-cong : {Γ₁ Γ₂ : Ctxt} → Γ₁ ≅-Ctxt Γ₂ → ⋆ {Γ = Γ₁} ≅-type ⋆ {Γ = Γ₂} ⋆-cong P.refl = P.refl el-cong : ∀ {Γ₁} {t₁ : Γ₁ ⊢ -, k U-⋆} {Γ₂} {t₂ : Γ₂ ⊢ -, k U-⋆} → t₁ ≅-⊢ t₂ → el t₁ ≅-type el t₂ el-cong P.refl = P.refl π-cong : ∀ {Γ₁ σ₁ τ₁} {σ′₁ : Γ₁ ⊢ σ₁ type} {τ′₁ : Γ₁ ▻ σ₁ ⊢ τ₁ type} {Γ₂ σ₂ τ₂} {σ′₂ : Γ₂ ⊢ σ₂ type} {τ′₂ : Γ₂ ▻ σ₂ ⊢ τ₂ type} → σ′₁ ≅-type σ′₂ → τ′₁ ≅-type τ′₂ → π σ′₁ τ′₁ ≅-type π σ′₂ τ′₂ π-cong P.refl P.refl = P.refl var-cong : ∀ {Γ₁ σ₁} {x₁ : Γ₁ ∋ σ₁} {Γ₂ σ₂} {x₂ : Γ₂ ∋ σ₂} → x₁ ≅-∋ x₂ → var x₁ ≅-⊢ var x₂ var-cong P.refl = P.refl ƛ-cong : ∀ {Γ₁ σ₁ τ₁} {t₁ : Γ₁ ▻ σ₁ ⊢ τ₁} {Γ₂ σ₂ τ₂} {t₂ : Γ₂ ▻ σ₂ ⊢ τ₂} → t₁ ≅-⊢ t₂ → ƛ t₁ ≅-⊢ ƛ t₂ ƛ-cong P.refl = P.refl ·-cong : ∀ {Γ₁ sp₁₁ sp₂₁ σ₁} {t₁₁ : Γ₁ ⊢ π sp₁₁ sp₂₁ , σ₁} {t₂₁ : Γ₁ ⊢ fst σ₁} {Γ₂ sp₁₂ sp₂₂ σ₂} {t₁₂ : Γ₂ ⊢ π sp₁₂ sp₂₂ , σ₂} {t₂₂ : Γ₂ ⊢ fst σ₂} → t₁₁ ≅-⊢ t₁₂ → t₂₁ ≅-⊢ t₂₂ → t₁₁ · t₂₁ ≅-⊢ t₁₂ · t₂₂ ·-cong P.refl P.refl = P.refl
{ "alphanum_fraction": 0.497696796, "avg_line_length": 28.7323529412, "ext": "agda", "hexsha": "f5e4e5b88b4c167344faaefc1555801365a4a895", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_path": "README/DependentlyTyped/Term.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/dependently-typed-syntax", "max_issues_repo_path": "README/DependentlyTyped/Term.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_path": "README/DependentlyTyped/Term.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "num_tokens": 4141, "size": 9769 }