Search is not available for this dataset
text
string
meta
dict
-- Product of type-many categories {-# OPTIONS --safe #-} module Cubical.Categories.Constructions.Product where open import Cubical.Categories.Category.Base open import Cubical.Categories.Functor.Base open import Cubical.Foundations.HLevels open import Cubical.Foundations.Prelude private variable ℓA ℓC ℓC' : Level open Category ΠC : (A : Type ℓA) → (catC : A → Category ℓC ℓC') → Category (ℓ-max ℓA ℓC) (ℓ-max ℓA ℓC') ob (ΠC A catC) = (a : A) → ob (catC a) Hom[_,_] (ΠC A catC) c c' = (a : A) → catC a [ c a , c' a ] id (ΠC A catC) a = id (catC a) _⋆_ (ΠC A catC) g f a = g a ⋆⟨ catC a ⟩ f a ⋆IdL (ΠC A catC) f = funExt λ a → ⋆IdL (catC a) (f a) ⋆IdR (ΠC A catC) f = funExt λ a → ⋆IdR (catC a) (f a) ⋆Assoc (ΠC A catC) h g f = funExt λ a → ⋆Assoc (catC a) (h a) (g a) (f a) isSetHom (ΠC A catC) = isSetΠ (λ a → isSetHom (catC a))
{ "alphanum_fraction": 0.6346381969, "avg_line_length": 32.4230769231, "ext": "agda", "hexsha": "e249fe2ae5b9e24de8ec0967f0be7352d9bf1166", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Categories/Constructions/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Categories/Constructions/Product.agda", "max_line_length": 89, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Categories/Constructions/Product.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 374, "size": 843 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Category.Properties where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Categories.Category.Base hiding (isSetHom) open Precategory private variable ℓ ℓ' : Level module _ {C : Precategory ℓ ℓ'} ⦃ isC : isCategory C ⦄ where open isCategory isC -- isSet where your allowed to compare paths where one side is only -- equal up to path. Is there a generalization of this? isSetHomP1 : ∀ {x y : C .ob} {n : C [ x , y ]} → isOfHLevelDep 1 (λ m → m ≡ n) isSetHomP1 {x = x} {y} {n} = isOfHLevel→isOfHLevelDep 1 (λ m → isSetHom m n) -- isSet where the arrows can be between non-definitionally equal obs isSetHomP2l : ∀ {y : C .ob} → isOfHLevelDep 2 (λ x → C [ x , y ]) isSetHomP2l = isOfHLevel→isOfHLevelDep 2 (λ a → isSetHom {x = a}) isSetHomP2r : ∀ {x : C .ob} → isOfHLevelDep 2 (λ y → C [ x , y ]) isSetHomP2r = isOfHLevel→isOfHLevelDep 2 (λ a → isSetHom {y = a}) -- opposite of opposite is definitionally equal to itself involutiveOp : ∀ {C : Precategory ℓ ℓ'} → (C ^op) ^op ≡ C involutiveOp = refl module _ {C : Precategory ℓ ℓ'} where -- Other useful operations on categories -- whisker the parallel morphisms g and g' with f lPrecatWhisker : {x y z : C .ob} (f : C [ x , y ]) (g g' : C [ y , z ]) (p : g ≡ g') → f ⋆⟨ C ⟩ g ≡ f ⋆⟨ C ⟩ g' lPrecatWhisker f _ _ p = cong (_⋆_ C f) p rPrecatWhisker : {x y z : C .ob} (f f' : C [ x , y ]) (g : C [ y , z ]) (p : f ≡ f') → f ⋆⟨ C ⟩ g ≡ f' ⋆⟨ C ⟩ g rPrecatWhisker _ _ g p = cong (λ v → v ⋆⟨ C ⟩ g) p -- working with equal objects idP : ∀ {x x'} {p : x ≡ x'} → C [ x , x' ] idP {x = x} {x'} {p} = subst (λ v → C [ x , v ]) p (C .id x) -- heterogeneous seq seqP : ∀ {x y y' z} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y' , z ]) → C [ x , z ] seqP {x = x} {_} {_} {z} {p} f g = f ⋆⟨ C ⟩ (subst (λ a → C [ a , z ]) (sym p) g) -- also heterogeneous seq, but substituting on the left seqP' : ∀ {x y y' z} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y' , z ]) → C [ x , z ] seqP' {x = x} {_} {_} {z} {p} f g = subst (λ a → C [ x , a ]) p f ⋆⟨ C ⟩ g -- show that they're equal seqP≡seqP' : ∀ {x y y' z} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y' , z ]) → seqP {p = p} f g ≡ seqP' {p = p} f g seqP≡seqP' {x = x} {z = z} {p = p} f g i = (toPathP {A = λ i' → C [ x , p i' ]} {f} refl i) ⋆⟨ C ⟩ (toPathP {A = λ i' → C [ p (~ i') , z ]} {x = g} (sym refl) (~ i)) -- seqP is equal to normal seq when y ≡ y' seqP≡seq : ∀ {x y z} → (f : C [ x , y ]) (g : C [ y , z ]) → seqP {p = refl} f g ≡ f ⋆⟨ C ⟩ g seqP≡seq {y = y} {z} f g i = f ⋆⟨ C ⟩ toPathP {A = λ _ → C [ y , z ]} {x = g} refl (~ i) -- whiskering with heterogenous seq -- (maybe should let z be heterogeneous too) lPrecatWhiskerP : {x y z y' : C .ob} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y , z ]) (g' : C [ y' , z ]) → (r : PathP (λ i → C [ p i , z ]) g g') → f ⋆⟨ C ⟩ g ≡ seqP {p = p} f g' lPrecatWhiskerP f g g' r = cong (λ v → f ⋆⟨ C ⟩ v) (sym (fromPathP (symP r))) rPrecatWhiskerP : {x y' y z : C .ob} {p : y' ≡ y} → (f' : C [ x , y' ]) (f : C [ x , y ]) (g : C [ y , z ]) → (r : PathP (λ i → C [ x , p i ]) f' f) → f ⋆⟨ C ⟩ g ≡ seqP' {p = p} f' g rPrecatWhiskerP f' f g r = cong (λ v → v ⋆⟨ C ⟩ g) (sym (fromPathP r))
{ "alphanum_fraction": 0.4817477876, "avg_line_length": 38.4680851064, "ext": "agda", "hexsha": "d4d0575f79cde2f25fca3dc344337e0a4a1acef0", "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/Categories/Category/Properties.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/Categories/Category/Properties.agda", "max_line_length": 113, "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/Categories/Category/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1540, "size": 3616 }
module Assume where postulate assume : ∀ {a} {A : Set a} → A
{ "alphanum_fraction": 0.619047619, "avg_line_length": 15.75, "ext": "agda", "hexsha": "b0d4d04597451d66353e10086de07da48775b108", "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": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "cspollard/reals", "max_forks_repo_path": "src/Assume.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "cspollard/reals", "max_issues_repo_path": "src/Assume.agda", "max_line_length": 32, "max_stars_count": null, "max_stars_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "cspollard/reals", "max_stars_repo_path": "src/Assume.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 22, "size": 63 }
{-# OPTIONS --sized-types #-} module BinTree where open import Data.Nat open import Data.List open import Data.List.Properties open import Size data Bin {T : Set} {i : Size} : Set where Leaf : Bin {T} {i} Node : T → Bin {T} {i} → Bin {T} {i} → Bin {T} {i} data Rose {T : Set} {i : Size} : Set where Empty : Rose {T} {i} R : T → List (Rose {T} {i}) → Rose {T} {i} BinListToBin : {T : Set} → List (Bin {T}) → Bin {T} BinListToBin [] = Leaf BinListToBin (Leaf ∷ bs) = BinListToBin bs BinListToBin (Node x b b₁ ∷ bs) = Node x b (BinListToBin bs) Seperate : {T : Set} → Bin {T} → List (Bin {T}) Seperate Leaf = [] Seperate (Node x b b₁) = Node x b Leaf ∷ Seperate b₁ RoseToBin : {i : Size} → {T : Set} → Rose {T} {∞} → Bin {T} {∞} RoseToBin Empty = Leaf RoseToBin (R x x₁) = Node x (BinListToBin (map RoseToBin x₁)) Leaf BinToRose : {T : Set} → Bin {T} → Rose {T} BinToRose Leaf = Empty BinToRose (Node x b b₁) = R x (map BinToRose (Seperate b₁))
{ "alphanum_fraction": 0.6091954023, "avg_line_length": 29, "ext": "agda", "hexsha": "496f0d257fc2caddbbaf53313ffd0fcbcebbac80", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_path": "Agda/BinTree.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "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": "Brethland/LEARNING-STUFF", "max_issues_repo_path": "Agda/BinTree.agda", "max_line_length": 66, "max_stars_count": 2, "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_path": "Agda/BinTree.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "num_tokens": 370, "size": 957 }
{-# OPTIONS --without-K --safe #-} open import Algebra.Structures.Bundles.Field module Algebra.Structures.Field.Utils {k ℓ} (K : Field k ℓ) where open Field K hiding (zero) open import Data.Fin import Data.Nat as Nat private K' : Set k K' = Carrier δ : ∀ {n p} -> Fin n -> Fin p -> K' δ zero zero = 1# δ (suc i) zero = 0# δ zero (suc j) = 0# δ (suc i) (suc j) = δ i j δ-comm : ∀ {n p} (i : Fin n) (j : Fin p) -> δ i j ≈ δ j i δ-comm zero zero = refl δ-comm (suc i) zero = refl δ-comm zero (suc j) = refl δ-comm (suc i) (suc j) = δ-comm i j δ-cancelˡ : ∀ {n p} (j : Fin p) -> δ {Nat.suc n} zero (suc j) ≈ 0# δ-cancelˡ zero = refl δ-cancelˡ (suc j) = refl δ-cancelʳ : ∀ {n p} (i : Fin n) -> δ {p = Nat.suc p} (suc i) zero ≈ 0# δ-cancelʳ {n} {p} i = trans (δ-comm (suc i) (zero {Nat.suc p})) (δ-cancelˡ {p} {n} i)
{ "alphanum_fraction": 0.5712560386, "avg_line_length": 23, "ext": "agda", "hexsha": "725bba59b62dbd23240415edcd113cefc38a1016", "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": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_path": "src/Algebra/Structures/Field/Utils.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "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": "felko/linear-algebra", "max_issues_repo_path": "src/Algebra/Structures/Field/Utils.agda", "max_line_length": 85, "max_stars_count": 15, "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_path": "src/Algebra/Structures/Field/Utils.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "num_tokens": 348, "size": 828 }
module Data.Num.Bij where open import Data.List hiding ([_]) open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_) import Level -------------------------------------------------------------------------------- -- Bijective Numeration -- -- A numeral system which has a unique representation for every non-negative -- interger -- http://en.wikipedia.org/wiki/Bijective_numeration -------------------------------------------------------------------------------- -- zeroless binary number infixl 7 _*B_ infixl 6 _+B_ data DigitB : Set where one : DigitB two : DigitB Bij : Set Bij = List DigitB incrB : Bij → Bij incrB [] = one ∷ [] incrB (one ∷ a) = two ∷ a incrB (two ∷ a) = one ∷ incrB a -- addition _+B_ : Bij → Bij → Bij [] +B b = b a +B [] = a (one ∷ as) +B (one ∷ bs) = two ∷ as +B bs (one ∷ as) +B (two ∷ bs) = one ∷ incrB (as +B bs) (two ∷ as) +B (one ∷ bs) = one ∷ incrB (as +B bs) (two ∷ as) +B (two ∷ bs) = two ∷ incrB (as +B bs) -- arithmetic shift *2_ : Bij → Bij *2 [] = [] *2 (one ∷ as) = two ∷ *2 as *2 (two ∷ as) = two ∷ incrB (*2 as) -- multiplication _*B_ : Bij → Bij → Bij [] *B b = [] (one ∷ as) *B b = b +B (*2 (as *B b)) (two ∷ as) *B b = b +B b +B (*2 (as *B b)) -------------------------------------------------------------------------------- -- Ordering -------------------------------------------------------------------------------- infix 4 _≤-digitB_ _≤B_ _<B_ data _≤-digitB_ : Rel DigitB Level.zero where 1≤1 : one ≤-digitB one 1≤2 : one ≤-digitB two 2≤2 : two ≤-digitB two data _≤B_ : Rel Bij Level.zero where []≤all : ∀ {n} → [] ≤B n ≤here : ∀ {as bs a b} -- compare the least digit → {a≤b : a ≤-digitB b} → {as≡bs : as ≡ bs} → a ∷ as ≤B b ∷ bs ≤there : ∀ {as bs a b} → (as<bs : incrB as ≤B bs) -- compare the rest digits → a ∷ as ≤B b ∷ bs _<B_ : Rel Bij Level.zero a <B b = incrB a ≤B b {- decr : Bij → Bij decr [] = [] decr (one ∷ a) = a decr (two ∷ a) = one ∷ a _-_ : Bij → Bij → Bij [] - bs = [] as - [] = as (one ∷ as) - (one ∷ bs) = as - bs (one ∷ as) - (two ∷ bs) = one ∷ decr (as - bs) (two ∷ as) - (one ∷ bs) = one ∷ as - bs (two ∷ as) - (two ∷ bs) = as - bs -} -------------------------------------------------------------------------------- -- typeclass for converting data types to Bij -- http://people.cs.kuleuven.be/~dominique.devriese/agda-instance-arguments/icfp001-Devriese.pdf record Conversion (t : Set) : Set where constructor conversion field [_] : t → Bij !_! : Bij → t -- split morphism -- !_! is a section of [_] -- [_] is a retraction of !_! -- [!!]-id : ∀ n → [ ! n ! ] ≡ n [_] : ∀ {t} → {{convT : Conversion t}} → t → Bij [_] {{convT}} = Conversion.[ convT ] !_! : ∀ {t} → {{convT : Conversion t}} → Bij → t !_! {{convT}} = Conversion.! convT ! --[!!]-id : ∀ {t} → {{convT : Conversion t}} → (n : Bij) → [ ! n ! ] ≡ n --[!!]-id {{convT}} = Conversion.[!!]-id convT -- alias, more meaningful than the forgettable [_] and !_! (replace them some day) toBij = [_] fromBij = !_!
{ "alphanum_fraction": 0.4555281038, "avg_line_length": 26.325203252, "ext": "agda", "hexsha": "3fe37079ecc72a0ddfb7963fbe463b555f8c60a6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/Data/Num/Bij.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/Data/Num/Bij.agda", "max_line_length": 97, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/Data/Num/Bij.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 1090, "size": 3238 }
{-# OPTIONS --without-K #-} module NTypes.HedbergsTheorem where open import GroupoidStructure open import NTypes open import NTypes.Negation open import PathOperations open import Transport open import Types stable : ∀ {a} → Set a → Set a stable A = ¬ ¬ A → A dec : ∀ {a} → Set a → Set a dec A = A ⊎ ¬ A dec→stable : ∀ {a} {A : Set a} → dec A → stable A dec→stable {A = A} = case (λ _ → stable A) (λ a _ → a) (λ ¬a ¬¬a → 0-elim (¬¬a ¬a)) dec-eq : ∀ {a} → Set a → Set a dec-eq A = (x y : A) → dec (x ≡ y) stable-eq : ∀ {a} → Set a → Set a stable-eq A = (x y : A) → stable (x ≡ y) dec-eq→stable-eq : ∀ {a} {A : Set a} → dec-eq A → stable-eq A dec-eq→stable-eq dec x y = dec→stable (dec x y) -- Lemma 2.9.6 from HoTT book. lemma : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} {x y : A} (p : x ≡ y) (f : B x → C x) (g : B y → C y) → tr _ p f ≡ g → (b : B x) → tr _ p (f b) ≡ g (tr _ p b) lemma {B = B} {C = C} = J (λ x y p → (f : B x → C x) (g : B y → C y) → tr _ p f ≡ g → (b : B x) → tr _ p (f b) ≡ g (tr _ p b)) (λ _ _ _ → happly) _ _ stable-eq→set : ∀ {a} {A : Set a} → stable-eq A → isSet A stable-eq→set {A = A} h _ _ p q = J (λ x y p → (q : x ≡ y) → q ≡ p) K _ _ q p where K : (x : A) (p : x ≡ x) → p ≡ refl K x p = id·p _ ⁻¹ · ap (λ z → z · p) (p⁻¹·p (h x x r)) ⁻¹ · p·q·r (h x x r ⁻¹) (h x x r) p ⁻¹ · ap (λ z → h x x r ⁻¹ · z) ( tr-post x p (h x x r) ⁻¹ · lemma p (h x x) (h x x) (apd (h x) p) r · ap (h x x) (¬-isProp (tr (λ v → ¬ ¬ (x ≡ v)) p r) r) ) · p⁻¹·p (h x x r) where -- Choice of r doesn't matter. r : ¬ ¬ (x ≡ x) r c = c refl
{ "alphanum_fraction": 0.4627403846, "avg_line_length": 26.8387096774, "ext": "agda", "hexsha": "f8e064b61a7a6443ec3b1de45f5652126a692a4a", "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": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_path": "src/NTypes/HedbergsTheorem.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "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": "vituscze/HoTT-lectures", "max_issues_repo_path": "src/NTypes/HedbergsTheorem.agda", "max_line_length": 61, "max_stars_count": null, "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_path": "src/NTypes/HedbergsTheorem.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 777, "size": 1664 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Polynomials.Multivariate.EquivCarac.AB-An[X]Bn[X] where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.HLevels open import Cubical.Data.Nat using (ℕ ; zero ; suc) open import Cubical.Data.Vec open import Cubical.Data.Vec.OperationsNat open import Cubical.Data.Sigma open import Cubical.Algebra.DirectSum.DirectSumHIT.Base open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly private variable ℓ : Level ----------------------------------------------------------------------------- -- Lift open IsRingHom open CommRingStr module _ (A'@(A , Astr) : CommRing ℓ) (B'@(B , Bstr) : CommRing ℓ) (n : ℕ) where private PA = PolyCommRing A' n PB = PolyCommRing B' n makeCommRingHomPoly : (f : CommRingHom A' B') → CommRingHom (PolyCommRing A' n) (PolyCommRing B' n) fst (makeCommRingHomPoly (f , fstr)) = DS-Rec-Set.f _ _ _ _ trunc (0r (snd PB)) (λ v a → base v (f a)) (_+_ (snd PB)) (+Assoc (snd PB)) (+IdR (snd PB)) (+Comm (snd PB)) (λ v → (cong (base v) (pres0 fstr)) ∙ (base-neutral v)) (λ v a b → (base-add v (f a) (f b)) ∙ (cong (base v) (sym (pres+ fstr a b)))) snd (makeCommRingHomPoly (f , fstr)) = makeIsRingHom (cong (base (replicate zero)) (pres1 fstr)) (λ _ _ → refl) (DS-Ind-Prop.f _ _ _ _ (λ _ → isPropΠ λ _ → trunc _ _) (λ _ → refl) (λ v a → DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) refl (λ v' b → cong (base (v +n-vec v')) (pres· fstr a b)) (λ {U V} ind-U ind-V → cong₂ (_+_ (snd PB)) ind-U ind-V)) λ {U V} ind-U ind-V Q → cong₂ (_+_ (snd PB)) (ind-U Q) (ind-V Q)) ----------------------------------------------------------------------------- -- Lift preserve equivalence module _ (A'@(A , Astr) : CommRing ℓ) (B'@(B , Bstr) : CommRing ℓ) (n : ℕ) where private PA = PolyCommRing A' n PB = PolyCommRing B' n open Iso open RingEquivs lift-equiv-poly : (e : CommRingEquiv A' B') → CommRingEquiv (PolyCommRing A' n) (PolyCommRing B' n) fst (lift-equiv-poly (e , fstr)) = isoToEquiv is where f = fst e g = invEq e gstr : IsRingHom (snd (CommRing→Ring B')) g (snd (CommRing→Ring A')) gstr = isRingHomInv (e , fstr) is : Iso (fst PA) (fst PB) fun is = fst (makeCommRingHomPoly A' B' n (f , fstr)) inv is = fst (makeCommRingHomPoly B' A' n (g , gstr)) rightInv is = DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) refl (λ v a → cong (base v) (secEq e a)) λ {U V} ind-U ind-V → cong₂ (_+_ (snd PB)) ind-U ind-V leftInv is = DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) refl (λ v a → cong (base v) (retEq e a)) λ {U V} ind-U ind-V → cong₂ (_+_ (snd PA)) ind-U ind-V snd (lift-equiv-poly (e , fstr)) = snd (makeCommRingHomPoly A' B' n ((fst e) , fstr))
{ "alphanum_fraction": 0.4672774869, "avg_line_length": 39.381443299, "ext": "agda", "hexsha": "de02b8254c9ada7abb07ee07888f0534b79ec075", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/AB-An[X]Bn[X].agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/AB-An[X]Bn[X].agda", "max_line_length": 126, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/EquivCarac/AB-An[X]Bn[X].agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1043, "size": 3820 }
module Imports.Issue5357-D where A : Set₁ A = Set₁
{ "alphanum_fraction": 0.7450980392, "avg_line_length": 12.75, "ext": "agda", "hexsha": "405b997861ebbc555d6a9d2740c409d9087238bc", "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/Imports/Issue5357-BadD.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/Imports/Issue5357-BadD.agda", "max_line_length": 32, "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/Imports/Issue5357-BadD.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": 19, "size": 51 }
{-# OPTIONS --rewriting #-} data _≅_ {ℓ} {A : Set ℓ} (x : A) : {B : Set ℓ} → B → Set where refl : x ≅ x {-# BUILTIN REWRITE _≅_ #-}
{ "alphanum_fraction": 0.4852941176, "avg_line_length": 19.4285714286, "ext": "agda", "hexsha": "d373c456256e2c897bb123c24017c6e4a328f91f", "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/Issue1990.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/Issue1990.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/Fail/Issue1990.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": 59, "size": 136 }
-- Andreas, 2011-04-07 module IrrelevantTelescopeRecord where record Wrap .(A : Set) : Set where field out : A -- cannot use A, because it is declared irrelevant
{ "alphanum_fraction": 0.7117647059, "avg_line_length": 18.8888888889, "ext": "agda", "hexsha": "c8d39c5297308aff9c83399da668b9ee9bd2c29d", "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/IrrelevantTelescopeRecord.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/IrrelevantTelescopeRecord.agda", "max_line_length": 50, "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/IrrelevantTelescopeRecord.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": 50, "size": 170 }
{-# BUILTIN STRING String #-} record ⊤ : Set where constructor tt data Bool : Set where true false : Bool nonEmpty : String → Set nonEmpty "" = Bool nonEmpty _ = ⊤ foo : ∀ s → nonEmpty s → Bool foo "" true = true foo "" false = false foo s p = false
{ "alphanum_fraction": 0.6188679245, "avg_line_length": 15.5882352941, "ext": "agda", "hexsha": "1bebe3370622d3d32b5b65ba3d1c0c23d7e9a1e1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue708.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue708.agda", "max_line_length": 29, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue708.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z", "num_tokens": 82, "size": 265 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Functor.Representable where open import Level open import Categories.Category open import Categories.Agda open import Categories.Functor using (Functor) open import Categories.Functor.Hom open import Categories.NaturalIsomorphism record Representable {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ suc ℓ ⊔ suc e) where open Category C open Hom C field F : Functor C (ISetoids ℓ e) -- should this be a parameter to the record? A : Obj Iso : NaturalIsomorphism F Hom[ A ,-]
{ "alphanum_fraction": 0.7371323529, "avg_line_length": 28.6315789474, "ext": "agda", "hexsha": "c98e44c16176f83f3e0374f28b4362be570b2f02", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Functor/Representable.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Functor/Representable.agda", "max_line_length": 81, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Functor/Representable.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 151, "size": 544 }
-- Define the integers as a HIT by identifying +0 and -0 {-# OPTIONS --cubical --safe #-} module Cubical.HITs.Ints.QuoInt.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Transport open import Cubical.Foundations.Isomorphism open import Cubical.Data.Int hiding (abs; sgn) open import Cubical.Data.Nat data ℤ : Type₀ where pos : (n : ℕ) → ℤ neg : (n : ℕ) → ℤ posneg : pos 0 ≡ neg 0 recℤ : ∀ {l} {A : Type l} → (pos' neg' : ℕ → A) → pos' 0 ≡ neg' 0 → ℤ → A recℤ pos' neg' eq (pos m) = pos' m recℤ pos' neg' eq (neg m) = neg' m recℤ pos' neg' eq (posneg i) = eq i indℤ : ∀ {l} (P : ℤ → Type l) → (pos' : ∀ n → P (pos n)) → (neg' : ∀ n → P (neg n)) → (λ i → P (posneg i)) [ pos' 0 ≡ neg' 0 ] → ∀ z → P z indℤ P pos' neg' eq (pos n) = pos' n indℤ P pos' neg' eq (neg n) = neg' n indℤ P pos' neg' eq (posneg i) = eq i Int→ℤ : Int → ℤ Int→ℤ (pos n) = pos n Int→ℤ (negsuc n) = neg (suc n) ℤ→Int : ℤ → Int ℤ→Int (pos n) = pos n ℤ→Int (neg zero) = pos 0 ℤ→Int (neg (suc n)) = negsuc n ℤ→Int (posneg _) = pos 0 ℤ→Int→ℤ : ∀ (n : ℤ) → Int→ℤ (ℤ→Int n) ≡ n ℤ→Int→ℤ (pos n) _ = pos n ℤ→Int→ℤ (neg zero) i = posneg i ℤ→Int→ℤ (neg (suc n)) _ = neg (suc n) ℤ→Int→ℤ (posneg j) i = posneg (j ∧ i) Int→ℤ→Int : ∀ (n : Int) → ℤ→Int (Int→ℤ n) ≡ n Int→ℤ→Int (pos n) _ = pos n Int→ℤ→Int (negsuc n) _ = negsuc n Int≡ℤ : Int ≡ ℤ Int≡ℤ = isoToPath (iso Int→ℤ ℤ→Int ℤ→Int→ℤ Int→ℤ→Int) isSetℤ : isSet ℤ isSetℤ = subst isSet Int≡ℤ isSetInt sucℤ : ℤ → ℤ sucℤ (pos n) = pos (suc n) sucℤ (neg zero) = pos 1 sucℤ (neg (suc n)) = neg n sucℤ (posneg _) = pos 1 predℤ : ℤ → ℤ predℤ (pos zero) = neg 1 predℤ (pos (suc n)) = pos n predℤ (neg n) = neg (suc n) predℤ (posneg _) = neg 1 sucPredℤ : ∀ n → sucℤ (predℤ n) ≡ n sucPredℤ (pos zero) = sym posneg sucPredℤ (pos (suc _)) = refl sucPredℤ (neg _) = refl sucPredℤ (posneg i) j = posneg (i ∨ ~ j) predSucℤ : ∀ n → predℤ (sucℤ n) ≡ n predSucℤ (pos _) = refl predSucℤ (neg zero) = posneg predSucℤ (neg (suc _)) = refl predSucℤ (posneg i) j = posneg (i ∧ j) _+ℤ_ : ℤ → ℤ → ℤ m +ℤ (pos (suc n)) = sucℤ (m +ℤ pos n) m +ℤ (neg (suc n)) = predℤ (m +ℤ neg n) m +ℤ _ = m sucPathℤ : ℤ ≡ ℤ sucPathℤ = isoToPath (iso sucℤ predℤ sucPredℤ predSucℤ) -- We do the same trick as in Cubical.Data.Int to prove that addition -- is an equivalence addEqℤ : ℕ → ℤ ≡ ℤ addEqℤ zero = refl addEqℤ (suc n) = addEqℤ n ∙ sucPathℤ predPathℤ : ℤ ≡ ℤ predPathℤ = isoToPath (iso predℤ sucℤ predSucℤ sucPredℤ) subEqℤ : ℕ → ℤ ≡ ℤ subEqℤ zero = refl subEqℤ (suc n) = subEqℤ n ∙ predPathℤ addℤ : ℤ → ℤ → ℤ addℤ m (pos n) = transport (addEqℤ n) m addℤ m (neg n) = transport (subEqℤ n) m addℤ m (posneg _) = m isEquivAddℤ : (m : ℤ) → isEquiv (λ n → addℤ n m) isEquivAddℤ (pos n) = isEquivTransport (addEqℤ n) isEquivAddℤ (neg n) = isEquivTransport (subEqℤ n) isEquivAddℤ (posneg _) = isEquivTransport refl addℤ≡+ℤ : addℤ ≡ _+ℤ_ addℤ≡+ℤ i m (pos (suc n)) = sucℤ (addℤ≡+ℤ i m (pos n)) addℤ≡+ℤ i m (neg (suc n)) = predℤ (addℤ≡+ℤ i m (neg n)) addℤ≡+ℤ i m (pos zero) = m addℤ≡+ℤ i m (neg zero) = m addℤ≡+ℤ _ m (posneg _) = m isEquiv+ℤ : (m : ℤ) → isEquiv (λ n → n +ℤ m) isEquiv+ℤ = subst (λ _+_ → (m : ℤ) → isEquiv (λ n → n + m)) addℤ≡+ℤ isEquivAddℤ data Sign : Type₀ where pos neg : Sign sign : ℤ → Sign sign (pos n) = pos sign (neg 0) = pos sign (neg (suc n)) = neg sign (posneg i) = pos abs : ℤ → ℕ abs (pos n) = n abs (neg n) = n abs (posneg i) = 0 signed : Sign → ℕ → ℤ signed Sign.pos n = pos n signed Sign.neg n = neg n signed-inv : ∀ z → signed (sign z) (abs z) ≡ z signed-inv (pos n) = refl signed-inv (neg zero) = posneg signed-inv (neg (suc n)) = refl signed-inv (posneg i) = \ j → posneg (i ∧ j) {- The square for signed-inv (posneg i) posneg i ---------------------> ^ ^ | | pos 0 | | posneg j | | | | | | ----------------------> = pos 0 = signed Sign.pos 0 signed (sign (posneg i)) (abs (posneg i)) -} -- * Multiplication _*S_ : Sign → Sign → Sign pos *S neg = neg neg *S pos = neg _ *S _ = pos _*ℤ_ : ℤ → ℤ → ℤ m *ℤ n = signed (sign m *S sign n) (abs m * abs n)
{ "alphanum_fraction": 0.5412782956, "avg_line_length": 24.8950276243, "ext": "agda", "hexsha": "ddf68dbf6b748a48a8cbe3eb820f239614a745c7", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/HITs/Ints/QuoInt/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/HITs/Ints/QuoInt/Base.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/HITs/Ints/QuoInt/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2021, "size": 4506 }
module examplesPaperJFP.exampleFinFun where open import examplesPaperJFP.finn open import Data.Nat toℕ : ∀ {n} → Fin n → ℕ toℕ zero = 0 toℕ (suc n) = suc (toℕ n) mutual _+e_ : ∀ {n m} → Even n → Even m → Even (n + m) 0p +e p = p sucp p +e q = sucp (p +o q) _+o_ : ∀ {n m} → Odd n → Even m → Odd (n + m) sucp p +o q = sucp (p +e q)
{ "alphanum_fraction": 0.5064267352, "avg_line_length": 21.6111111111, "ext": "agda", "hexsha": "0addd7142d7627cf261d0c576f42c94abd85bdbf", "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/examplesPaperJFP/exampleFinFun.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/examplesPaperJFP/exampleFinFun.agda", "max_line_length": 56, "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/examplesPaperJFP/exampleFinFun.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": 189, "size": 389 }
module Singleton where open import Data.List using (List ; [] ; _∷_) open import Data.List.All using (All ; [] ; _∷_) open import Membership using (_∈_; _⊆_ ; _∷_ ; []) [_]ˡ : ∀{a}{A : Set a} → A → List A [ a ]ˡ = a ∷ [] [_]ᵃ : ∀{a p} {A : Set a} {P : A → Set p} {x : A} → P x → All P (x ∷ []) [ p ]ᵃ = p ∷ [] [_]ᵐ : ∀{a} {A : Set a} {x : A} {ys : List A} → (x ∈ ys) → ((x ∷ []) ⊆ ys) [ p ]ᵐ = p ∷ []
{ "alphanum_fraction": 0.4393203883, "avg_line_length": 22.8888888889, "ext": "agda", "hexsha": "2e01160c069c86937ad3a6cd271a5119ced83604", "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": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Zalastax/singly-typed-actors", "max_forks_repo_path": "src/Singleton.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Zalastax/singly-typed-actors", "max_issues_repo_path": "src/Singleton.agda", "max_line_length": 75, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Zalastax/thesis", "max_stars_repo_path": "src/Singleton.agda", "max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z", "num_tokens": 196, "size": 412 }
-- Coalgebraic strength over an endofunctor module SOAS.Coalgebraic.Strength {T : Set} where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core {T} open import SOAS.Abstract.Hom {T} import SOAS.Abstract.Coalgebra {T} as →□ ; open →□.Sorted open import SOAS.Coalgebraic.Map private variable Γ Δ Θ : Ctx α : T -- Pointed coalgebraic strength for a family endofunctor record Strength (Fᶠ : Functor 𝔽amiliesₛ 𝔽amiliesₛ) : Set₁ where open Functor Fᶠ open Coalgₚ field -- Strength transformation that lifts a 𝒫-substitution over an endofunctor F₀ str : {𝒫 : Familyₛ}(𝒫ᴮ : Coalgₚ 𝒫)(𝒳 : Familyₛ) → F₀ 〖 𝒫 , 𝒳 〗 ⇾̣ 〖 𝒫 , F₀ 𝒳 〗 -- Naturality conditions for the two components str-nat₁ : {𝒫 𝒬 𝒳 : Familyₛ}{𝒫ᴮ : Coalgₚ 𝒫}{𝒬ᴮ : Coalgₚ 𝒬} → {f : 𝒬 ⇾̣ 𝒫} (fᴮ⇒ : Coalgₚ⇒ 𝒬ᴮ 𝒫ᴮ f) → (h : F₀ 〖 𝒫 , 𝒳 〗 α Γ) (σ : Γ ~[ 𝒬 ]↝ Δ) → str 𝒫ᴮ 𝒳 h (f ∘ σ) ≡ str 𝒬ᴮ 𝒳 (F₁ (λ{ h′ ς → h′ (λ v → f (ς v))}) h) σ str-nat₂ : {𝒫 𝒳 𝒴 : Familyₛ}{𝒫ᴮ : Coalgₚ 𝒫} → (f : 𝒳 ⇾̣ 𝒴)(h : F₀ 〖 𝒫 , 𝒳 〗 α Γ)(σ : Γ ~[ 𝒫 ]↝ Δ) → str 𝒫ᴮ 𝒴 (F₁ (λ{ h′ ς → f (h′ ς)}) h) σ ≡ F₁ f (str 𝒫ᴮ 𝒳 h σ) -- Unit law str-unit : (𝒳 : Familyₛ)(h : F₀ 〖 ℐ , 𝒳 〗 α Γ) → str ℐᴮ 𝒳 h id ≡ F₁ (i 𝒳) h -- Associativity law for a particular pointed coalgebraic map f str-assoc : (𝒳 : Familyₛ){𝒫 𝒬 ℛ : Familyₛ} {𝒫ᴮ : Coalgₚ 𝒫} {𝒬ᴮ : Coalgₚ 𝒬} {ℛᴮ : Coalgₚ ℛ} {f : 𝒫 ⇾̣ 〖 𝒬 , ℛ 〗} (fᶜ : Coalgebraic 𝒫ᴮ 𝒬ᴮ ℛᴮ f) (open Coalgebraic fᶜ) (h : F₀ 〖 ℛ , 𝒳 〗 α Γ)(σ : Γ ~[ 𝒫 ]↝ Δ)(ς : Δ ~[ 𝒬 ]↝ Θ) → str ℛᴮ 𝒳 h (λ v → f (σ v) ς) ≡ str 𝒬ᴮ 𝒳 (str 〖𝒫,𝒴〗ᴮ 〖 𝒬 , 𝒳 〗 (F₁ (L 𝒬 ℛ 𝒳) h) (f ∘ σ)) ς module _ (𝒳 {𝒫 𝒬 ℛ} : Familyₛ) where -- Precompose an internal hom by a parametrised map precomp : (f : 𝒫 ⇾̣ 〖 𝒬 , ℛ 〗) → 〖 ℛ , 𝒳 〗 ⇾̣ 〖 𝒫 , 〖 𝒬 , 𝒳 〗 〗 precomp f h σ ς = h (λ v → f (σ v) ς) -- Corollary: strength distributes over pointed coalgebraic maps str-dist : {𝒫ᴮ : Coalgₚ 𝒫} {𝒬ᴮ : Coalgₚ 𝒬} {ℛᴮ : Coalgₚ ℛ} {f : 𝒫 ⇾̣ 〖 𝒬 , ℛ 〗} (fᶜ : Coalgebraic 𝒫ᴮ 𝒬ᴮ ℛᴮ f) (h : F₀ 〖 ℛ , 𝒳 〗 α Γ)(σ : Γ ~[ 𝒫 ]↝ Δ)(ς : Δ ~[ 𝒬 ]↝ Θ) → str ℛᴮ 𝒳 h (λ v → f (σ v) ς) ≡ str 𝒬ᴮ 𝒳 (str 𝒫ᴮ 〖 𝒬 , 𝒳 〗 (F₁ (precomp f) h) σ) ς str-dist {𝒫ᴮ = 𝒫ᴮ} {𝒬ᴮ} {ℛᴮ} {f} fᶜ h σ ς = begin str ℛᴮ 𝒳 h (λ v → f (σ v) ς) ≡⟨ str-assoc 𝒳 fᶜ h σ ς ⟩ str 𝒬ᴮ 𝒳 (str 〖𝒫,𝒴〗ᴮ 〖 𝒬 , 𝒳 〗 (F₁ (L 𝒬 ℛ 𝒳) h) (f ∘ σ)) ς ≡⟨ cong (λ - → str 𝒬ᴮ 𝒳 - ς) (str-nat₁ fᴮ⇒ (F₁ (L 𝒬 ℛ 𝒳) h) σ) ⟩ str 𝒬ᴮ 𝒳 (str 𝒫ᴮ 〖 𝒬 , 𝒳 〗 (F₁ 〖 f , 〖 𝒬 , 𝒳 〗 〗ₗ (F₁ (L 𝒬 ℛ 𝒳) h)) σ) ς ≡˘⟨ cong (λ - → str 𝒬ᴮ 𝒳 (str 𝒫ᴮ 〖 𝒬 , 𝒳 〗 - σ) ς) homomorphism ⟩ str 𝒬ᴮ 𝒳 (str 𝒫ᴮ 〖 𝒬 , 𝒳 〗 (F₁ (precomp f) h) σ) ς ∎ where open ≡-Reasoning open Coalgebraic fᶜ renaming (ᴮ⇒ to fᴮ⇒)
{ "alphanum_fraction": 0.4826551034, "avg_line_length": 35.6904761905, "ext": "agda", "hexsha": "dcb907ecd92c2056250e5f430ae2cee52b44204e", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Coalgebraic/Strength.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Coalgebraic/Strength.agda", "max_line_length": 81, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Coalgebraic/Strength.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 1777, "size": 2998 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Functor.Core where open import Level private variable o ℓ e o′ ℓ′ e′ : Level record Functor (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where eta-equality private module C = Category C private module D = Category D field F₀ : C.Obj → D.Obj F₁ : ∀ {A B} (f : C [ A , B ]) → D [ F₀ A , F₀ B ] identity : ∀ {A} → D [ F₁ (C.id {A}) ≈ D.id ] homomorphism : ∀ {X Y Z} {f : C [ X , Y ]} {g : C [ Y , Z ]} → D [ F₁ (C [ g ∘ f ]) ≈ D [ F₁ g ∘ F₁ f ] ] F-resp-≈ : ∀ {A B} {f g : C [ A , B ]} → C [ f ≈ g ] → D [ F₁ f ≈ F₁ g ] -- nice shorthands ₀ = F₀ ₁ = F₁ op : Functor C.op D.op op = record { F₀ = F₀ ; F₁ = F₁ ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = F-resp-≈ }
{ "alphanum_fraction": 0.4673097535, "avg_line_length": 23.9230769231, "ext": "agda", "hexsha": "361098fcb579588cd835d2ac13d65e6e614474c2", "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": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "laMudri/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "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": "laMudri/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Core.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "laMudri/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 376, "size": 933 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Bundles module Properties.ConstructiveField {ℓ ℓ'} (F : ConstructiveField {ℓ} {ℓ'}) 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.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` open import Function.Base using (it) -- instance search open import MoreLogic open MoreLogic.Reasoning import MoreAlgebra -- Lemma 4.1.6. -- For a constructive field (F, 0, 1, +, ·, #), the following hold. -- 1. 1 # 0. -- 2. Addition + is #-compatible in the sense that for all x, y, z : F -- x # y ⇔ x + z # y + z. -- 3. Multiplication · is #-extensional in the sense that for all w, x, y, z : F -- w · x # y · z ⇒ w # y ∨ x # z. open ConstructiveField F open import Cubical.Structures.Ring R = (makeRing 0f 1f _+_ _·_ -_ is-set +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+) open Cubical.Structures.Ring.Theory R open MoreAlgebra.Properties.Ring R -- Lemma 4.1.6.1 1f#0f : 1f # 0f 1f#0f with ·-identity 1f 1f#0f | 1·1≡1 , _ = fst (·-inv-back _ _ 1·1≡1) -- Lemma 4.1.6.2 -- For #-compatibility of +, suppose x # y, that is, (x +z) −z # (y +z) −z. -- Then #-extensionality gives (x + z # y + z) ∨ (−z # −z), where the latter case is excluded by irreflexivity of #. +-#-compatible : ∀(x y z : Carrier) → x # y → x + z # y + z +-#-compatible x y z x#y with let P = transport (λ i → a+b-b≡a x z i # a+b-b≡a y z i ) x#y in +-#-extensional _ _ _ _ P ... | inl x+z#y+z = x+z#y+z ... | inr -z#-z = ⊥-elim (#-irrefl _ -z#-z) -- The other direction is similar. +-#-compatible-inv : ∀(x y z : Carrier) → x + z # y + z → x # y +-#-compatible-inv _ _ _ x+z#y+z with +-#-extensional _ _ _ _ x+z#y+z ... | inl x#y = x#y ... | inr z#z = ⊥-elim (#-irrefl _ z#z) -- Lemma 4.1.6.3 ·-#-extensional-case1 : ∀(w x y z : Carrier) → w · x # y · z → w · x # w · z → x # z ·-#-extensional-case1 w x y z w·x#y·z w·x#w·z = let instance -- this allows to use ⁻¹ᶠ without an instance argument w·[z-x]#0f = ( w · x # w · z ⇒⟨ +-#-compatible _ _ (- (w · x)) ⟩ w · x - w · x # w · z - w · x ⇒⟨ transport (λ i → (fst (+-inv (w · x)) i) # a·b-a·c≡a·[b-c] w z x i) ⟩ 0f # w · (z - x) ⇒⟨ #-sym _ _ ⟩ w · (z - x) # 0f ◼) w·x#w·z in ( w · (z - x) # 0f ⇒⟨ (λ _ → ·-rinv (w · (z - x)) it ) ⟩ -- NOTE: "plugging in" the instance did not work, ∴ `it` w · (z - x) · (w · (z - x)) ⁻¹ᶠ ≡ 1f ⇒⟨ transport (λ i → ·-comm w (z - x) i · (w · (z - x)) ⁻¹ᶠ ≡ 1f) ⟩ (z - x) · w · (w · (z - x)) ⁻¹ᶠ ≡ 1f ⇒⟨ transport (λ i → ·-assoc (z - x) w ((w · (z - x)) ⁻¹ᶠ) (~ i) ≡ 1f) ⟩ (z - x) · (w · (w · (z - x)) ⁻¹ᶠ) ≡ 1f ⇒⟨ fst ∘ (·-inv-back _ _) ⟩ z - x # 0f ⇒⟨ +-#-compatible _ _ x ⟩ (z - x) + x # 0f + x ⇒⟨ transport (λ i → +-assoc z (- x) x (~ i) # snd (+-identity x) i) ⟩ z + (- x + x) # x ⇒⟨ transport (λ i → z + snd (+-inv x) i # x) ⟩ z + 0f # x ⇒⟨ transport (λ i → fst (+-identity z) i # x) ⟩ z # x ⇒⟨ #-sym _ _ ⟩ x # z ◼) it -- conceptually we would plug `w·[z-x]#0f` in, but this breaks the very first step ·-#-extensional : ∀(w x y z : Carrier) → w · x # y · z → (w # y) ⊎ (x # z) ·-#-extensional w x y z w·x#y·z with #-cotrans _ _ w·x#y·z (w · z) ... | inl w·x#w·z = inr (·-#-extensional-case1 w x y z w·x#y·z w·x#w·z) -- first case ... | inr w·z#y·z = let z·w≡z·y = (transport (λ i → ·-comm w z i # ·-comm y z i) w·z#y·z) in inl (·-#-extensional-case1 _ _ _ _ z·w≡z·y z·w≡z·y) -- second case reduced to first case
{ "alphanum_fraction": 0.4946236559, "avg_line_length": 47.0344827586, "ext": "agda", "hexsha": "9be9ac540dc52e2a1f978121027930c9dba34b59", "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/Properties/ConstructiveField.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/Properties/ConstructiveField.agda", "max_line_length": 145, "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/Properties/ConstructiveField.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": 1713, "size": 4092 }
{-# OPTIONS --without-K #-} module sets.bool where open import sets.empty using (⊥) open import sets.unit using (⊤) open import decidable using (Dec; yes; no) open import equality.core using (_≡_; refl) open import level using (Level) infixr 6 _∧_ infixr 5 _∨_ _xor_ infix 0 if_then_else_ data Bool : Set where true false : Bool not : Bool → Bool not true = false not false = true T : Bool → Set T true = ⊤ T false = ⊥ if_then_else_ : {a : Level} {A : Set a} → Bool → A → A → A if true then t else f = t if false then t else f = f _∧_ : Bool → Bool → Bool true ∧ b = b false ∧ b = false _∨_ : Bool → Bool → Bool true ∨ b = true false ∨ b = b _xor_ : Bool → Bool → Bool true xor b = not b false xor b = b _≟_ : (a b : Bool) → Dec (a ≡ b) true ≟ true = yes refl false ≟ false = yes refl true ≟ false = no λ () false ≟ true = no λ ()
{ "alphanum_fraction": 0.6061643836, "avg_line_length": 18.6382978723, "ext": "agda", "hexsha": "9a1b5459e2707c54360ea125a1f026ea3d839391", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/bool.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/bool.agda", "max_line_length": 58, "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": "sets/bool.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": 316, "size": 876 }
open import Relation.Binary.Core module BBHeap.Everything {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import BBHeap.Complete.Base _≤_ open import BBHeap.Drop _≤_ tot≤ trans≤ open import BBHeap.DropLast _≤_ open import BBHeap.Heap _≤_ open import BBHeap.Height.Convert _≤_ tot≤ open import BBHeap.Height.Log _≤_ tot≤ open import BBHeap.Last
{ "alphanum_fraction": 0.6506849315, "avg_line_length": 29.2, "ext": "agda", "hexsha": "9132c3e5841473fa666f0353fd2dcd0640881da7", "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/BBHeap/Everything.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/BBHeap/Everything.agda", "max_line_length": 49, "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/BBHeap/Everything.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": 134, "size": 438 }
------------------------------------------------------------------------ -- The Agda standard library -- -- List-related properties ------------------------------------------------------------------------ -- Note that the lemmas below could be generalised to work with other -- equalities than _≡_. {-# OPTIONS --without-K --safe #-} module Data.List.Properties where open import Algebra.Bundles open import Algebra.Definitions as AlgebraicDefinitions using (Involutive) import Algebra.Structures as AlgebraicStructures open import Data.Bool.Base using (Bool; false; true; not; if_then_else_) open import Data.Fin.Base using (Fin; zero; suc; cast; toℕ; inject₁) open import Data.List.Base as List open import Data.List.Relation.Unary.All using (All; []; _∷_) open import Data.List.Relation.Unary.Any using (Any; here; there) open import Data.Maybe.Base using (Maybe; just; nothing) open import Data.Nat.Base open import Data.Nat.Properties open import Data.Product as Prod hiding (map; zip) open import Data.Sum.Base using (_⊎_; inj₁; inj₂) open import Data.These.Base as These using (These; this; that; these) open import Function open import Level using (Level) open import Relation.Binary as B using (DecidableEquality) import Relation.Binary.Reasoning.Setoid as EqR open import Relation.Binary.PropositionalEquality as P hiding ([_]) open import Relation.Binary as B using (Rel) open import Relation.Nullary.Reflects using (invert) open import Relation.Nullary using (¬_; Dec; does; _because_; yes; no) open import Relation.Nullary.Negation using (contradiction; ¬?) open import Relation.Nullary.Decidable as Decidable using (isYes; map′; ⌊_⌋) open import Relation.Nullary.Product using (_×-dec_) open import Relation.Unary using (Pred; Decidable; ∁) open import Relation.Unary.Properties using (∁?) open ≡-Reasoning private variable a b c d e p : Level A : Set a B : Set b C : Set c D : Set d E : Set e ----------------------------------------------------------------------- -- _∷_ module _ {x y : A} {xs ys : List A} where ∷-injective : x ∷ xs ≡ y List.∷ ys → x ≡ y × xs ≡ ys ∷-injective refl = (refl , refl) ∷-injectiveˡ : x ∷ xs ≡ y List.∷ ys → x ≡ y ∷-injectiveˡ refl = refl ∷-injectiveʳ : x ∷ xs ≡ y List.∷ ys → xs ≡ ys ∷-injectiveʳ refl = refl ∷-dec : Dec (x ≡ y) → Dec (xs ≡ ys) → Dec (x List.∷ xs ≡ y ∷ ys) ∷-dec x≟y xs≟ys = Decidable.map′ (uncurry (cong₂ _∷_)) ∷-injective (x≟y ×-dec xs≟ys) ≡-dec : DecidableEquality A → DecidableEquality (List A) ≡-dec _≟_ [] [] = yes refl ≡-dec _≟_ (x ∷ xs) [] = no λ() ≡-dec _≟_ [] (y ∷ ys) = no λ() ≡-dec _≟_ (x ∷ xs) (y ∷ ys) = ∷-dec (x ≟ y) (≡-dec _≟_ xs ys) ------------------------------------------------------------------------ -- map map-id : map id ≗ id {A = List A} map-id [] = refl map-id (x ∷ xs) = cong (x ∷_) (map-id xs) map-id₂ : ∀ {f : A → A} {xs} → All (λ x → f x ≡ x) xs → map f xs ≡ xs map-id₂ [] = refl map-id₂ (fx≡x ∷ pxs) = cong₂ _∷_ fx≡x (map-id₂ pxs) map-++-commute : ∀ (f : A → B) xs ys → map f (xs ++ ys) ≡ map f xs ++ map f ys map-++-commute f [] ys = refl map-++-commute f (x ∷ xs) ys = cong (f x ∷_) (map-++-commute f xs ys) map-cong : ∀ {f g : A → B} → f ≗ g → map f ≗ map g map-cong f≗g [] = refl map-cong f≗g (x ∷ xs) = cong₂ _∷_ (f≗g x) (map-cong f≗g xs) map-cong₂ : ∀ {f g : A → B} {xs} → All (λ x → f x ≡ g x) xs → map f xs ≡ map g xs map-cong₂ [] = refl map-cong₂ (fx≡gx ∷ fxs≡gxs) = cong₂ _∷_ fx≡gx (map-cong₂ fxs≡gxs) length-map : ∀ (f : A → B) xs → length (map f xs) ≡ length xs length-map f [] = refl length-map f (x ∷ xs) = cong suc (length-map f xs) map-compose : {g : B → C} {f : A → B} → map (g ∘ f) ≗ map g ∘ map f map-compose [] = refl map-compose (x ∷ xs) = cong (_ ∷_) (map-compose xs) ------------------------------------------------------------------------ -- mapMaybe mapMaybe-just : (xs : List A) → mapMaybe just xs ≡ xs mapMaybe-just [] = refl mapMaybe-just (x ∷ xs) = cong (x ∷_) (mapMaybe-just xs) mapMaybe-nothing : (xs : List A) → mapMaybe {B = A} (λ _ → nothing) xs ≡ [] mapMaybe-nothing [] = refl mapMaybe-nothing (x ∷ xs) = mapMaybe-nothing xs module _ (f : A → Maybe B) where mapMaybe-concatMap : mapMaybe f ≗ concatMap (fromMaybe ∘ f) mapMaybe-concatMap [] = refl mapMaybe-concatMap (x ∷ xs) with f x ... | just y = cong (y ∷_) (mapMaybe-concatMap xs) ... | nothing = mapMaybe-concatMap xs length-mapMaybe : ∀ xs → length (mapMaybe f xs) ≤ length xs length-mapMaybe [] = z≤n length-mapMaybe (x ∷ xs) with f x ... | just y = s≤s (length-mapMaybe xs) ... | nothing = ≤-step (length-mapMaybe xs) ------------------------------------------------------------------------ -- _++_ length-++ : ∀ (xs : List A) {ys} → length (xs ++ ys) ≡ length xs + length ys length-++ [] = refl length-++ (x ∷ xs) = cong suc (length-++ xs) module _ {A : Set a} where open AlgebraicDefinitions {A = List A} _≡_ open AlgebraicStructures {A = List A} _≡_ ++-assoc : Associative _++_ ++-assoc [] ys zs = refl ++-assoc (x ∷ xs) ys zs = cong (x ∷_) (++-assoc xs ys zs) ++-identityˡ : LeftIdentity [] _++_ ++-identityˡ xs = refl ++-identityʳ : RightIdentity [] _++_ ++-identityʳ [] = refl ++-identityʳ (x ∷ xs) = cong (x ∷_) (++-identityʳ xs) ++-identity : Identity [] _++_ ++-identity = ++-identityˡ , ++-identityʳ ++-identityʳ-unique : ∀ (xs : List A) {ys} → xs ≡ xs ++ ys → ys ≡ [] ++-identityʳ-unique [] refl = refl ++-identityʳ-unique (x ∷ xs) eq = ++-identityʳ-unique xs (proj₂ (∷-injective eq)) ++-identityˡ-unique : ∀ {xs} (ys : List A) → xs ≡ ys ++ xs → ys ≡ [] ++-identityˡ-unique [] _ = refl ++-identityˡ-unique {xs = x ∷ xs} (y ∷ ys) eq with ++-identityˡ-unique (ys ++ [ x ]) (begin xs ≡⟨ proj₂ (∷-injective eq) ⟩ ys ++ x ∷ xs ≡⟨ sym (++-assoc ys [ x ] xs) ⟩ (ys ++ [ x ]) ++ xs ∎) ++-identityˡ-unique {xs = x ∷ xs} (y ∷ [] ) eq | () ++-identityˡ-unique {xs = x ∷ xs} (y ∷ _ ∷ _) eq | () ++-cancelˡ : ∀ xs {ys zs : List A} → xs ++ ys ≡ xs ++ zs → ys ≡ zs ++-cancelˡ [] ys≡zs = ys≡zs ++-cancelˡ (x ∷ xs) x∷xs++ys≡x∷xs++zs = ++-cancelˡ xs (∷-injectiveʳ x∷xs++ys≡x∷xs++zs) ++-cancelʳ : ∀ {xs : List A} ys zs → ys ++ xs ≡ zs ++ xs → ys ≡ zs ++-cancelʳ {_} [] [] _ = refl ++-cancelʳ {xs} [] (z ∷ zs) eq = contradiction (trans (cong length eq) (length-++ (z ∷ zs))) (m≢1+n+m (length xs)) ++-cancelʳ {xs} (y ∷ ys) [] eq = contradiction (trans (sym (length-++ (y ∷ ys))) (cong length eq)) (m≢1+n+m (length xs) ∘ sym) ++-cancelʳ {_} (y ∷ ys) (z ∷ zs) eq = cong₂ _∷_ (∷-injectiveˡ eq) (++-cancelʳ ys zs (∷-injectiveʳ eq)) ++-cancel : Cancellative _++_ ++-cancel = ++-cancelˡ , ++-cancelʳ ++-conicalˡ : ∀ (xs ys : List A) → xs ++ ys ≡ [] → xs ≡ [] ++-conicalˡ [] _ refl = refl ++-conicalʳ : ∀ (xs ys : List A) → xs ++ ys ≡ [] → ys ≡ [] ++-conicalʳ [] _ refl = refl ++-conical : Conical [] _++_ ++-conical = ++-conicalˡ , ++-conicalʳ ++-isMagma : IsMagma _++_ ++-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = cong₂ _++_ } ++-isSemigroup : IsSemigroup _++_ ++-isSemigroup = record { isMagma = ++-isMagma ; assoc = ++-assoc } ++-isMonoid : IsMonoid _++_ [] ++-isMonoid = record { isSemigroup = ++-isSemigroup ; identity = ++-identity } module _ (A : Set a) where ++-semigroup : Semigroup a a ++-semigroup = record { Carrier = List A ; isSemigroup = ++-isSemigroup } ++-monoid : Monoid a a ++-monoid = record { Carrier = List A ; isMonoid = ++-isMonoid } ------------------------------------------------------------------------ -- alignWith module _ {f g : These A B → C} where alignWith-cong : f ≗ g → ∀ as → alignWith f as ≗ alignWith g as alignWith-cong f≗g [] bs = map-cong (f≗g ∘ that) bs alignWith-cong f≗g as@(_ ∷ _) [] = map-cong (f≗g ∘ this) as alignWith-cong f≗g (a ∷ as) (b ∷ bs) = cong₂ _∷_ (f≗g (these a b)) (alignWith-cong f≗g as bs) length-alignWith : ∀ xs ys → length (alignWith f xs ys) ≡ length xs ⊔ length ys length-alignWith [] ys = length-map (f ∘′ that) ys length-alignWith xs@(_ ∷ _) [] = length-map (f ∘′ this) xs length-alignWith (x ∷ xs) (y ∷ ys) = cong suc (length-alignWith xs ys) alignWith-map : (g : D → A) (h : E → B) → ∀ xs ys → alignWith f (map g xs) (map h ys) ≡ alignWith (f ∘′ These.map g h) xs ys alignWith-map g h [] ys = sym (map-compose ys) alignWith-map g h xs@(_ ∷ _) [] = sym (map-compose xs) alignWith-map g h (x ∷ xs) (y ∷ ys) = cong₂ _∷_ refl (alignWith-map g h xs ys) map-alignWith : ∀ (g : C → D) → ∀ xs ys → map g (alignWith f xs ys) ≡ alignWith (g ∘′ f) xs ys map-alignWith g [] ys = sym (map-compose ys) map-alignWith g xs@(_ ∷ _) [] = sym (map-compose xs) map-alignWith g (x ∷ xs) (y ∷ ys) = cong₂ _∷_ refl (map-alignWith g xs ys) ------------------------------------------------------------------------ -- zipWith module _ (f : A → A → B) where zipWith-comm : (∀ x y → f x y ≡ f y x) → ∀ xs ys → zipWith f xs ys ≡ zipWith f ys xs zipWith-comm f-comm [] [] = refl zipWith-comm f-comm [] (x ∷ ys) = refl zipWith-comm f-comm (x ∷ xs) [] = refl zipWith-comm f-comm (x ∷ xs) (y ∷ ys) = cong₂ _∷_ (f-comm x y) (zipWith-comm f-comm xs ys) module _ (f : A → B → C) where zipWith-identityˡ : ∀ xs → zipWith f [] xs ≡ [] zipWith-identityˡ [] = refl zipWith-identityˡ (x ∷ xs) = refl zipWith-identityʳ : ∀ xs → zipWith f xs [] ≡ [] zipWith-identityʳ [] = refl zipWith-identityʳ (x ∷ xs) = refl length-zipWith : ∀ xs ys → length (zipWith f xs ys) ≡ length xs ⊓ length ys length-zipWith [] [] = refl length-zipWith [] (y ∷ ys) = refl length-zipWith (x ∷ xs) [] = refl length-zipWith (x ∷ xs) (y ∷ ys) = cong suc (length-zipWith xs ys) zipWith-map : ∀ {d e} {D : Set d} {E : Set e} (g : D → A) (h : E → B) → ∀ xs ys → zipWith f (map g xs) (map h ys) ≡ zipWith (λ x y → f (g x) (h y)) xs ys zipWith-map g h [] [] = refl zipWith-map g h [] (y ∷ ys) = refl zipWith-map g h (x ∷ xs) [] = refl zipWith-map g h (x ∷ xs) (y ∷ ys) = cong₂ _∷_ refl (zipWith-map g h xs ys) map-zipWith : ∀ {d} {D : Set d} (g : C → D) → ∀ xs ys → map g (zipWith f xs ys) ≡ zipWith (λ x y → g (f x y)) xs ys map-zipWith g [] [] = refl map-zipWith g [] (y ∷ ys) = refl map-zipWith g (x ∷ xs) [] = refl map-zipWith g (x ∷ xs) (y ∷ ys) = cong₂ _∷_ refl (map-zipWith g xs ys) ------------------------------------------------------------------------ -- unalignWith unalignWith-this : unalignWith ((A → These A B) ∋ this) ≗ (_, []) unalignWith-this [] = refl unalignWith-this (a ∷ as) = cong (Prod.map₁ (a ∷_)) (unalignWith-this as) unalignWith-that : unalignWith ((B → These A B) ∋ that) ≗ ([] ,_) unalignWith-that [] = refl unalignWith-that (b ∷ bs) = cong (Prod.map₂ (b ∷_)) (unalignWith-that bs) module _ {f g : C → These A B} where unalignWith-cong : f ≗ g → unalignWith f ≗ unalignWith g unalignWith-cong f≗g [] = refl unalignWith-cong f≗g (c ∷ cs) with f c | g c | f≗g c ... | this a | ._ | refl = cong (Prod.map₁ (a ∷_)) (unalignWith-cong f≗g cs) ... | that b | ._ | refl = cong (Prod.map₂ (b ∷_)) (unalignWith-cong f≗g cs) ... | these a b | ._ | refl = cong (Prod.map (a ∷_) (b ∷_)) (unalignWith-cong f≗g cs) module _ (f : C → These A B) where unalignWith-map : (g : D → C) → ∀ ds → unalignWith f (map g ds) ≡ unalignWith (f ∘′ g) ds unalignWith-map g [] = refl unalignWith-map g (d ∷ ds) with f (g d) ... | this a = cong (Prod.map₁ (a ∷_)) (unalignWith-map g ds) ... | that b = cong (Prod.map₂ (b ∷_)) (unalignWith-map g ds) ... | these a b = cong (Prod.map (a ∷_) (b ∷_)) (unalignWith-map g ds) map-unalignWith : (g : A → D) (h : B → E) → Prod.map (map g) (map h) ∘′ unalignWith f ≗ unalignWith (These.map g h ∘′ f) map-unalignWith g h [] = refl map-unalignWith g h (c ∷ cs) with f c ... | this a = cong (Prod.map₁ (g a ∷_)) (map-unalignWith g h cs) ... | that b = cong (Prod.map₂ (h b ∷_)) (map-unalignWith g h cs) ... | these a b = cong (Prod.map (g a ∷_) (h b ∷_)) (map-unalignWith g h cs) unalignWith-alignWith : (g : These A B → C) → f ∘′ g ≗ id → ∀ as bs → unalignWith f (alignWith g as bs) ≡ (as , bs) unalignWith-alignWith g g∘f≗id [] bs = begin unalignWith f (map (g ∘′ that) bs) ≡⟨ unalignWith-map (g ∘′ that) bs ⟩ unalignWith (f ∘′ g ∘′ that) bs ≡⟨ unalignWith-cong (g∘f≗id ∘ that) bs ⟩ unalignWith that bs ≡⟨ unalignWith-that bs ⟩ [] , bs ∎ unalignWith-alignWith g g∘f≗id as@(_ ∷ _) [] = begin unalignWith f (map (g ∘′ this) as) ≡⟨ unalignWith-map (g ∘′ this) as ⟩ unalignWith (f ∘′ g ∘′ this) as ≡⟨ unalignWith-cong (g∘f≗id ∘ this) as ⟩ unalignWith this as ≡⟨ unalignWith-this as ⟩ as , [] ∎ unalignWith-alignWith g g∘f≗id (a ∷ as) (b ∷ bs) rewrite g∘f≗id (these a b) = cong (Prod.map (a ∷_) (b ∷_)) (unalignWith-alignWith g g∘f≗id as bs) ------------------------------------------------------------------------ -- unzipWith module _ (f : A → B × C) where length-unzipWith₁ : ∀ xys → length (proj₁ (unzipWith f xys)) ≡ length xys length-unzipWith₁ [] = refl length-unzipWith₁ (x ∷ xys) = cong suc (length-unzipWith₁ xys) length-unzipWith₂ : ∀ xys → length (proj₂ (unzipWith f xys)) ≡ length xys length-unzipWith₂ [] = refl length-unzipWith₂ (x ∷ xys) = cong suc (length-unzipWith₂ xys) zipWith-unzipWith : (g : B → C → A) → uncurry′ g ∘ f ≗ id → uncurry′ (zipWith g) ∘ (unzipWith f) ≗ id zipWith-unzipWith g f∘g≗id [] = refl zipWith-unzipWith g f∘g≗id (x ∷ xs) = cong₂ _∷_ (f∘g≗id x) (zipWith-unzipWith g f∘g≗id xs) ------------------------------------------------------------------------ -- foldr foldr-universal : ∀ (h : List A → B) f e → (h [] ≡ e) → (∀ x xs → h (x ∷ xs) ≡ f x (h xs)) → h ≗ foldr f e foldr-universal h f e base step [] = base foldr-universal h f e base step (x ∷ xs) = begin h (x ∷ xs) ≡⟨ step x xs ⟩ f x (h xs) ≡⟨ cong (f x) (foldr-universal h f e base step xs) ⟩ f x (foldr f e xs) ∎ foldr-cong : ∀ {f g : A → B → B} {d e : B} → (∀ x y → f x y ≡ g x y) → d ≡ e → foldr f d ≗ foldr g e foldr-cong f≗g refl [] = refl foldr-cong f≗g d≡e (x ∷ xs) rewrite foldr-cong f≗g d≡e xs = f≗g x _ foldr-fusion : ∀ (h : B → C) {f : A → B → B} {g : A → C → C} (e : B) → (∀ x y → h (f x y) ≡ g x (h y)) → h ∘ foldr f e ≗ foldr g (h e) foldr-fusion h {f} {g} e fuse = foldr-universal (h ∘ foldr f e) g (h e) refl (λ x xs → fuse x (foldr f e xs)) id-is-foldr : id {A = List A} ≗ foldr _∷_ [] id-is-foldr = foldr-universal id _∷_ [] refl (λ _ _ → refl) ++-is-foldr : (xs ys : List A) → xs ++ ys ≡ foldr _∷_ ys xs ++-is-foldr xs ys = begin xs ++ ys ≡⟨ cong (_++ ys) (id-is-foldr xs) ⟩ foldr _∷_ [] xs ++ ys ≡⟨ foldr-fusion (_++ ys) [] (λ _ _ → refl) xs ⟩ foldr _∷_ ([] ++ ys) xs ≡⟨⟩ foldr _∷_ ys xs ∎ foldr-++ : ∀ (f : A → B → B) x ys zs → foldr f x (ys ++ zs) ≡ foldr f (foldr f x zs) ys foldr-++ f x [] zs = refl foldr-++ f x (y ∷ ys) zs = cong (f y) (foldr-++ f x ys zs) map-is-foldr : {f : A → B} → map f ≗ foldr (λ x ys → f x ∷ ys) [] map-is-foldr {f = f} xs = begin map f xs ≡⟨ cong (map f) (id-is-foldr xs) ⟩ map f (foldr _∷_ [] xs) ≡⟨ foldr-fusion (map f) [] (λ _ _ → refl) xs ⟩ foldr (λ x ys → f x ∷ ys) [] xs ∎ foldr-∷ʳ : ∀ (f : A → B → B) x y ys → foldr f x (ys ∷ʳ y) ≡ foldr f (f y x) ys foldr-∷ʳ f x y [] = refl foldr-∷ʳ f x y (z ∷ ys) = cong (f z) (foldr-∷ʳ f x y ys) -- Interaction with predicates module _ {P : Pred A p} {f : A → A → A} where foldr-forcesᵇ : (∀ x y → P (f x y) → P x × P y) → ∀ e xs → P (foldr f e xs) → All P xs foldr-forcesᵇ _ _ [] _ = [] foldr-forcesᵇ forces _ (x ∷ xs) Pfold with forces _ _ Pfold ... | (px , pfxs) = px ∷ foldr-forcesᵇ forces _ xs pfxs foldr-preservesᵇ : (∀ {x y} → P x → P y → P (f x y)) → ∀ {e xs} → P e → All P xs → P (foldr f e xs) foldr-preservesᵇ _ Pe [] = Pe foldr-preservesᵇ pres Pe (px ∷ pxs) = pres px (foldr-preservesᵇ pres Pe pxs) foldr-preservesʳ : (∀ x {y} → P y → P (f x y)) → ∀ {e} → P e → ∀ xs → P (foldr f e xs) foldr-preservesʳ pres Pe [] = Pe foldr-preservesʳ pres Pe (_ ∷ xs) = pres _ (foldr-preservesʳ pres Pe xs) foldr-preservesᵒ : (∀ x y → P x ⊎ P y → P (f x y)) → ∀ e xs → P e ⊎ Any P xs → P (foldr f e xs) foldr-preservesᵒ pres e [] (inj₁ Pe) = Pe foldr-preservesᵒ pres e (x ∷ xs) (inj₁ Pe) = pres _ _ (inj₂ (foldr-preservesᵒ pres e xs (inj₁ Pe))) foldr-preservesᵒ pres e (x ∷ xs) (inj₂ (here px)) = pres _ _ (inj₁ px) foldr-preservesᵒ pres e (x ∷ xs) (inj₂ (there pxs)) = pres _ _ (inj₂ (foldr-preservesᵒ pres e xs (inj₂ pxs))) ------------------------------------------------------------------------ -- foldl foldl-++ : ∀ (f : A → B → A) x ys zs → foldl f x (ys ++ zs) ≡ foldl f (foldl f x ys) zs foldl-++ f x [] zs = refl foldl-++ f x (y ∷ ys) zs = foldl-++ f (f x y) ys zs foldl-∷ʳ : ∀ (f : A → B → A) x y ys → foldl f x (ys ∷ʳ y) ≡ f (foldl f x ys) y foldl-∷ʳ f x y [] = refl foldl-∷ʳ f x y (z ∷ ys) = foldl-∷ʳ f (f x z) y ys ------------------------------------------------------------------------ -- concat concat-map : ∀ {f : A → B} → concat ∘ map (map f) ≗ map f ∘ concat concat-map {f = f} xss = begin concat (map (map f) xss) ≡⟨ cong concat (map-is-foldr xss) ⟩ concat (foldr (λ xs → map f xs ∷_) [] xss) ≡⟨ foldr-fusion concat [] (λ _ _ → refl) xss ⟩ foldr (λ ys → map f ys ++_) [] xss ≡⟨ sym (foldr-fusion (map f) [] (map-++-commute f) xss) ⟩ map f (concat xss) ∎ ------------------------------------------------------------------------ -- sum sum-++-commute : ∀ xs ys → sum (xs ++ ys) ≡ sum xs + sum ys sum-++-commute [] ys = refl sum-++-commute (x ∷ xs) ys = begin x + sum (xs ++ ys) ≡⟨ cong (x +_) (sum-++-commute xs ys) ⟩ x + (sum xs + sum ys) ≡⟨ sym (+-assoc x _ _) ⟩ (x + sum xs) + sum ys ∎ ------------------------------------------------------------------------ -- replicate length-replicate : ∀ n {x : A} → length (replicate n x) ≡ n length-replicate zero = refl length-replicate (suc n) = cong suc (length-replicate n) ------------------------------------------------------------------------ -- scanr scanr-defn : ∀ (f : A → B → B) (e : B) → scanr f e ≗ map (foldr f e) ∘ tails scanr-defn f e [] = refl scanr-defn f e (x ∷ []) = refl scanr-defn f e (x ∷ y ∷ xs) with scanr f e (y ∷ xs) | scanr-defn f e (y ∷ xs) ... | [] | () ... | z ∷ zs | eq with ∷-injective eq ... | z≡fy⦇f⦈xs , _ = cong₂ (λ z → f x z ∷_) z≡fy⦇f⦈xs eq ------------------------------------------------------------------------ -- scanl scanl-defn : ∀ (f : A → B → A) (e : A) → scanl f e ≗ map (foldl f e) ∘ inits scanl-defn f e [] = refl scanl-defn f e (x ∷ xs) = cong (e ∷_) (begin scanl f (f e x) xs ≡⟨ scanl-defn f (f e x) xs ⟩ map (foldl f (f e x)) (inits xs) ≡⟨ refl ⟩ map (foldl f e ∘ (x ∷_)) (inits xs) ≡⟨ map-compose (inits xs) ⟩ map (foldl f e) (map (x ∷_) (inits xs)) ∎) ------------------------------------------------------------------------ -- applyUpTo length-applyUpTo : ∀ (f : ℕ → A) n → length (applyUpTo f n) ≡ n length-applyUpTo f zero = refl length-applyUpTo f (suc n) = cong suc (length-applyUpTo (f ∘ suc) n) lookup-applyUpTo : ∀ (f : ℕ → A) n i → lookup (applyUpTo f n) i ≡ f (toℕ i) lookup-applyUpTo f (suc n) zero = refl lookup-applyUpTo f (suc n) (suc i) = lookup-applyUpTo (f ∘ suc) n i ------------------------------------------------------------------------ -- applyUpTo module _ (f : ℕ → A) where length-applyDownFrom : ∀ n → length (applyDownFrom f n) ≡ n length-applyDownFrom zero = refl length-applyDownFrom (suc n) = cong suc (length-applyDownFrom n) lookup-applyDownFrom : ∀ n i → lookup (applyDownFrom f n) i ≡ f (n ∸ (suc (toℕ i))) lookup-applyDownFrom (suc n) zero = refl lookup-applyDownFrom (suc n) (suc i) = lookup-applyDownFrom n i ------------------------------------------------------------------------ -- upTo length-upTo : ∀ n → length (upTo n) ≡ n length-upTo = length-applyUpTo id lookup-upTo : ∀ n i → lookup (upTo n) i ≡ toℕ i lookup-upTo = lookup-applyUpTo id ------------------------------------------------------------------------ -- downFrom length-downFrom : ∀ n → length (downFrom n) ≡ n length-downFrom = length-applyDownFrom id lookup-downFrom : ∀ n i → lookup (downFrom n) i ≡ n ∸ (suc (toℕ i)) lookup-downFrom = lookup-applyDownFrom id ------------------------------------------------------------------------ -- tabulate tabulate-cong : ∀ {n} {f g : Fin n → A} → f ≗ g → tabulate f ≡ tabulate g tabulate-cong {n = zero} p = refl tabulate-cong {n = suc n} p = cong₂ _∷_ (p zero) (tabulate-cong (p ∘ suc)) tabulate-lookup : ∀ (xs : List A) → tabulate (lookup xs) ≡ xs tabulate-lookup [] = refl tabulate-lookup (x ∷ xs) = cong (_ ∷_) (tabulate-lookup xs) length-tabulate : ∀ {n} → (f : Fin n → A) → length (tabulate f) ≡ n length-tabulate {n = zero} f = refl length-tabulate {n = suc n} f = cong suc (length-tabulate (λ z → f (suc z))) lookup-tabulate : ∀ {n} → (f : Fin n → A) → ∀ i → let i′ = cast (sym (length-tabulate f)) i in lookup (tabulate f) i′ ≡ f i lookup-tabulate f zero = refl lookup-tabulate f (suc i) = lookup-tabulate (f ∘ suc) i map-tabulate : ∀ {n} (g : Fin n → A) (f : A → B) → map f (tabulate g) ≡ tabulate (f ∘ g) map-tabulate {n = zero} g f = refl map-tabulate {n = suc n} g f = cong (_ ∷_) (map-tabulate (g ∘ suc) f) ------------------------------------------------------------------------ -- _[_]%=_ length-%= : ∀ xs k (f : A → A) → length (xs [ k ]%= f) ≡ length xs length-%= (x ∷ xs) zero f = refl length-%= (x ∷ xs) (suc k) f = cong suc (length-%= xs k f) ------------------------------------------------------------------------ -- _[_]∷=_ length-∷= : ∀ xs k (v : A) → length (xs [ k ]∷= v) ≡ length xs length-∷= xs k v = length-%= xs k (const v) map-∷= : ∀ xs k (v : A) (f : A → B) → let eq = sym (length-map f xs) in map f (xs [ k ]∷= v) ≡ map f xs [ cast eq k ]∷= f v map-∷= (x ∷ xs) zero v f = refl map-∷= (x ∷ xs) (suc k) v f = cong (f x ∷_) (map-∷= xs k v f) ------------------------------------------------------------------------ -- _─_ length-─ : ∀ (xs : List A) k → length (xs ─ k) ≡ pred (length xs) length-─ (x ∷ xs) zero = refl length-─ (x ∷ y ∷ xs) (suc k) = cong suc (length-─ (y ∷ xs) k) map-─ : ∀ xs k (f : A → B) → let eq = sym (length-map f xs) in map f (xs ─ k) ≡ map f xs ─ cast eq k map-─ (x ∷ xs) zero f = refl map-─ (x ∷ xs) (suc k) f = cong (f x ∷_) (map-─ xs k f) ------------------------------------------------------------------------ -- take length-take : ∀ n (xs : List A) → length (take n xs) ≡ n ⊓ (length xs) length-take zero xs = refl length-take (suc n) [] = refl length-take (suc n) (x ∷ xs) = cong suc (length-take n xs) ------------------------------------------------------------------------ -- drop length-drop : ∀ n (xs : List A) → length (drop n xs) ≡ length xs ∸ n length-drop zero xs = refl length-drop (suc n) [] = refl length-drop (suc n) (x ∷ xs) = length-drop n xs take++drop : ∀ n (xs : List A) → take n xs ++ drop n xs ≡ xs take++drop zero xs = refl take++drop (suc n) [] = refl take++drop (suc n) (x ∷ xs) = cong (x ∷_) (take++drop n xs) ------------------------------------------------------------------------ -- splitAt splitAt-defn : ∀ n → splitAt {A = A} n ≗ < take n , drop n > splitAt-defn zero xs = refl splitAt-defn (suc n) [] = refl splitAt-defn (suc n) (x ∷ xs) with splitAt n xs | splitAt-defn n xs ... | (ys , zs) | ih = cong (Prod.map (x ∷_) id) ih ------------------------------------------------------------------------ -- takeWhile, dropWhile, and span module _ {P : Pred A p} (P? : Decidable P) where takeWhile++dropWhile : ∀ xs → takeWhile P? xs ++ dropWhile P? xs ≡ xs takeWhile++dropWhile [] = refl takeWhile++dropWhile (x ∷ xs) with does (P? x) ... | true = cong (x ∷_) (takeWhile++dropWhile xs) ... | false = refl span-defn : span P? ≗ < takeWhile P? , dropWhile P? > span-defn [] = refl span-defn (x ∷ xs) with does (P? x) ... | true = cong (Prod.map (x ∷_) id) (span-defn xs) ... | false = refl ------------------------------------------------------------------------ -- filter module _ {P : Pred A p} (P? : Decidable P) where length-filter : ∀ xs → length (filter P? xs) ≤ length xs length-filter [] = z≤n length-filter (x ∷ xs) with does (P? x) ... | false = ≤-step (length-filter xs) ... | true = s≤s (length-filter xs) filter-all : ∀ {xs} → All P xs → filter P? xs ≡ xs filter-all {[]} [] = refl filter-all {x ∷ xs} (px ∷ pxs) with P? x ... | no ¬px = contradiction px ¬px ... | true because _ = cong (x ∷_) (filter-all pxs) filter-notAll : ∀ xs → Any (∁ P) xs → length (filter P? xs) < length xs filter-notAll (x ∷ xs) (here ¬px) with P? x ... | false because _ = s≤s (length-filter xs) ... | yes px = contradiction px ¬px filter-notAll (x ∷ xs) (there any) with does (P? x) ... | false = ≤-step (filter-notAll xs any) ... | true = s≤s (filter-notAll xs any) filter-some : ∀ {xs} → Any P xs → 0 < length (filter P? xs) filter-some {x ∷ xs} (here px) with P? x ... | true because _ = s≤s z≤n ... | no ¬px = contradiction px ¬px filter-some {x ∷ xs} (there pxs) with does (P? x) ... | true = ≤-step (filter-some pxs) ... | false = filter-some pxs filter-none : ∀ {xs} → All (∁ P) xs → filter P? xs ≡ [] filter-none {[]} [] = refl filter-none {x ∷ xs} (¬px ∷ ¬pxs) with P? x ... | false because _ = filter-none ¬pxs ... | yes px = contradiction px ¬px filter-complete : ∀ {xs} → length (filter P? xs) ≡ length xs → filter P? xs ≡ xs filter-complete {[]} eq = refl filter-complete {x ∷ xs} eq with does (P? x) ... | false = contradiction eq (<⇒≢ (s≤s (length-filter xs))) ... | true = cong (x ∷_) (filter-complete (suc-injective eq)) filter-accept : ∀ {x xs} → P x → filter P? (x ∷ xs) ≡ x ∷ (filter P? xs) filter-accept {x} Px with P? x ... | true because _ = refl ... | no ¬Px = contradiction Px ¬Px filter-reject : ∀ {x xs} → ¬ P x → filter P? (x ∷ xs) ≡ filter P? xs filter-reject {x} ¬Px with P? x ... | yes Px = contradiction Px ¬Px ... | false because _ = refl filter-idem : filter P? ∘ filter P? ≗ filter P? filter-idem [] = refl filter-idem (x ∷ xs) with does (P? x) | inspect does (P? x) ... | false | _ = filter-idem xs ... | true | P.[ eq ] rewrite eq = cong (x ∷_) (filter-idem xs) filter-++ : ∀ xs ys → filter P? (xs ++ ys) ≡ filter P? xs ++ filter P? ys filter-++ [] ys = refl filter-++ (x ∷ xs) ys with does (P? x) ... | true = cong (x ∷_) (filter-++ xs ys) ... | false = filter-++ xs ys ------------------------------------------------------------------------ -- derun and deduplicate module _ {R : Rel A p} (R? : B.Decidable R) where length-derun : ∀ xs → length (derun R? xs) ≤ length xs length-derun [] = ≤-refl length-derun (x ∷ []) = ≤-refl length-derun (x ∷ y ∷ xs) with does (R? x y) | length-derun (y ∷ xs) ... | true | r = ≤-step r ... | false | r = s≤s r length-deduplicate : ∀ xs → length (deduplicate R? xs) ≤ length xs length-deduplicate [] = z≤n length-deduplicate (x ∷ xs) = ≤-begin 1 + length (filter (¬? ∘ R? x) r) ≤⟨ s≤s (length-filter (¬? ∘ R? x) r) ⟩ 1 + length r ≤⟨ s≤s (length-deduplicate xs) ⟩ 1 + length xs ≤-∎ where open ≤-Reasoning renaming (begin_ to ≤-begin_; _∎ to _≤-∎) r = deduplicate R? xs derun-reject : ∀ {x y} xs → R x y → derun R? (x ∷ y ∷ xs) ≡ derun R? (y ∷ xs) derun-reject {x} {y} xs Rxy with R? x y ... | yes _ = refl ... | no ¬Rxy = contradiction Rxy ¬Rxy derun-accept : ∀ {x y} xs → ¬ R x y → derun R? (x ∷ y ∷ xs) ≡ x ∷ derun R? (y ∷ xs) derun-accept {x} {y} xs ¬Rxy with R? x y ... | yes Rxy = contradiction Rxy ¬Rxy ... | no _ = refl ------------------------------------------------------------------------ -- partition module _ {P : Pred A p} (P? : Decidable P) where partition-defn : partition P? ≗ < filter P? , filter (∁? P?) > partition-defn [] = refl partition-defn (x ∷ xs) with does (P? x) ... | true = cong (Prod.map (x ∷_) id) (partition-defn xs) ... | false = cong (Prod.map id (x ∷_)) (partition-defn xs) ------------------------------------------------------------------------ -- _ʳ++_ ʳ++-defn : ∀ (xs : List A) {ys} → xs ʳ++ ys ≡ reverse xs ++ ys ʳ++-defn [] = refl ʳ++-defn (x ∷ xs) {ys} = begin (x ∷ xs) ʳ++ ys ≡⟨⟩ xs ʳ++ x ∷ ys ≡⟨⟩ xs ʳ++ [ x ] ++ ys ≡⟨ ʳ++-defn xs ⟩ reverse xs ++ [ x ] ++ ys ≡⟨ sym (++-assoc (reverse xs) _ _) ⟩ (reverse xs ++ [ x ]) ++ ys ≡⟨ cong (_++ ys) (sym (ʳ++-defn xs)) ⟩ (xs ʳ++ [ x ]) ++ ys ≡⟨⟩ reverse (x ∷ xs) ++ ys ∎ -- Reverse-append of append is reverse-append after reverse-append. ʳ++-++ : ∀ (xs {ys zs} : List A) → (xs ++ ys) ʳ++ zs ≡ ys ʳ++ xs ʳ++ zs ʳ++-++ [] = refl ʳ++-++ (x ∷ xs) {ys} {zs} = begin (x ∷ xs ++ ys) ʳ++ zs ≡⟨⟩ (xs ++ ys) ʳ++ x ∷ zs ≡⟨ ʳ++-++ xs ⟩ ys ʳ++ xs ʳ++ x ∷ zs ≡⟨⟩ ys ʳ++ (x ∷ xs) ʳ++ zs ∎ -- Reverse-append of reverse-append is commuted reverse-append after append. ʳ++-ʳ++ : ∀ (xs {ys zs} : List A) → (xs ʳ++ ys) ʳ++ zs ≡ ys ʳ++ xs ++ zs ʳ++-ʳ++ [] = refl ʳ++-ʳ++ (x ∷ xs) {ys} {zs} = begin ((x ∷ xs) ʳ++ ys) ʳ++ zs ≡⟨⟩ (xs ʳ++ x ∷ ys) ʳ++ zs ≡⟨ ʳ++-ʳ++ xs ⟩ (x ∷ ys) ʳ++ xs ++ zs ≡⟨⟩ ys ʳ++ (x ∷ xs) ++ zs ∎ -- Length of reverse-append length-ʳ++ : ∀ (xs {ys} : List A) → length (xs ʳ++ ys) ≡ length xs + length ys length-ʳ++ [] = refl length-ʳ++ (x ∷ xs) {ys} = begin length ((x ∷ xs) ʳ++ ys) ≡⟨⟩ length (xs ʳ++ x ∷ ys) ≡⟨ length-ʳ++ xs ⟩ length xs + length (x ∷ ys) ≡⟨ +-suc _ _ ⟩ length (x ∷ xs) + length ys ∎ -- map distributes over reverse-append. map-ʳ++ : (f : A → B) (xs {ys} : List A) → map f (xs ʳ++ ys) ≡ map f xs ʳ++ map f ys map-ʳ++ f [] = refl map-ʳ++ f (x ∷ xs) {ys} = begin map f ((x ∷ xs) ʳ++ ys) ≡⟨⟩ map f (xs ʳ++ x ∷ ys) ≡⟨ map-ʳ++ f xs ⟩ map f xs ʳ++ map f (x ∷ ys) ≡⟨⟩ map f xs ʳ++ f x ∷ map f ys ≡⟨⟩ (f x ∷ map f xs) ʳ++ map f ys ≡⟨⟩ map f (x ∷ xs) ʳ++ map f ys ∎ -- A foldr after a reverse is a foldl. foldr-ʳ++ : ∀ (f : A → B → B) b xs {ys} → foldr f b (xs ʳ++ ys) ≡ foldl (flip f) (foldr f b ys) xs foldr-ʳ++ f b [] {_} = refl foldr-ʳ++ f b (x ∷ xs) {ys} = begin foldr f b ((x ∷ xs) ʳ++ ys) ≡⟨⟩ foldr f b (xs ʳ++ x ∷ ys) ≡⟨ foldr-ʳ++ f b xs ⟩ foldl (flip f) (foldr f b (x ∷ ys)) xs ≡⟨⟩ foldl (flip f) (f x (foldr f b ys)) xs ≡⟨⟩ foldl (flip f) (foldr f b ys) (x ∷ xs) ∎ -- A foldl after a reverse is a foldr. foldl-ʳ++ : ∀ (f : B → A → B) b xs {ys} → foldl f b (xs ʳ++ ys) ≡ foldl f (foldr (flip f) b xs) ys foldl-ʳ++ f b [] {_} = refl foldl-ʳ++ f b (x ∷ xs) {ys} = begin foldl f b ((x ∷ xs) ʳ++ ys) ≡⟨⟩ foldl f b (xs ʳ++ x ∷ ys) ≡⟨ foldl-ʳ++ f b xs ⟩ foldl f (foldr (flip f) b xs) (x ∷ ys) ≡⟨⟩ foldl f (f (foldr (flip f) b xs) x) ys ≡⟨⟩ foldl f (foldr (flip f) b (x ∷ xs)) ys ∎ ------------------------------------------------------------------------ -- reverse -- reverse of cons is snoc of reverse. unfold-reverse : ∀ (x : A) xs → reverse (x ∷ xs) ≡ reverse xs ∷ʳ x unfold-reverse x xs = ʳ++-defn xs -- reverse is an involution with respect to append. reverse-++-commute : (xs ys : List A) → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs reverse-++-commute xs ys = begin reverse (xs ++ ys) ≡⟨⟩ (xs ++ ys) ʳ++ [] ≡⟨ ʳ++-++ xs ⟩ ys ʳ++ xs ʳ++ [] ≡⟨⟩ ys ʳ++ reverse xs ≡⟨ ʳ++-defn ys ⟩ reverse ys ++ reverse xs ∎ -- reverse is involutive. reverse-involutive : Involutive {A = List A} _≡_ reverse reverse-involutive xs = begin reverse (reverse xs) ≡⟨⟩ (xs ʳ++ []) ʳ++ [] ≡⟨ ʳ++-ʳ++ xs ⟩ [] ʳ++ xs ++ [] ≡⟨⟩ xs ++ [] ≡⟨ ++-identityʳ xs ⟩ xs ∎ -- reverse preserves length. length-reverse : ∀ (xs : List A) → length (reverse xs) ≡ length xs length-reverse xs = begin length (reverse xs) ≡⟨⟩ length (xs ʳ++ []) ≡⟨ length-ʳ++ xs ⟩ length xs + 0 ≡⟨ +-identityʳ _ ⟩ length xs ∎ reverse-map-commute : (f : A → B) → map f ∘ reverse ≗ reverse ∘ map f reverse-map-commute f xs = begin map f (reverse xs) ≡⟨⟩ map f (xs ʳ++ []) ≡⟨ map-ʳ++ f xs ⟩ map f xs ʳ++ [] ≡⟨⟩ reverse (map f xs) ∎ reverse-foldr : ∀ (f : A → B → B) b → foldr f b ∘ reverse ≗ foldl (flip f) b reverse-foldr f b xs = foldr-ʳ++ f b xs reverse-foldl : ∀ (f : B → A → B) b xs → foldl f b (reverse xs) ≡ foldr (flip f) b xs reverse-foldl f b xs = foldl-ʳ++ f b xs ------------------------------------------------------------------------ -- _∷ʳ_ module _ {x y : A} where ∷ʳ-injective : ∀ xs ys → xs ∷ʳ x ≡ ys ∷ʳ y → xs ≡ ys × x ≡ y ∷ʳ-injective [] [] refl = (refl , refl) ∷ʳ-injective (x ∷ xs) (y ∷ ys) eq with ∷-injective eq ... | refl , eq′ = Prod.map (cong (x ∷_)) id (∷ʳ-injective xs ys eq′) ∷ʳ-injective [] (_ ∷ _ ∷ _) () ∷ʳ-injective (_ ∷ _ ∷ _) [] () ∷ʳ-injectiveˡ : ∀ (xs ys : List A) → xs ∷ʳ x ≡ ys ∷ʳ y → xs ≡ ys ∷ʳ-injectiveˡ xs ys eq = proj₁ (∷ʳ-injective xs ys eq) ∷ʳ-injectiveʳ : ∀ (xs ys : List A) → xs ∷ʳ x ≡ ys ∷ʳ y → x ≡ y ∷ʳ-injectiveʳ xs ys eq = proj₂ (∷ʳ-injective xs ys eq) ------------------------------------------------------------------------ -- DEPRECATED ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.15 gfilter-just = mapMaybe-just {-# WARNING_ON_USAGE gfilter-just "Warning: gfilter-just was deprecated in v0.15. Please use mapMaybe-just instead." #-} gfilter-nothing = mapMaybe-nothing {-# WARNING_ON_USAGE gfilter-nothing "Warning: gfilter-nothing was deprecated in v0.15. Please use mapMaybe-nothing instead." #-} gfilter-concatMap = mapMaybe-concatMap {-# WARNING_ON_USAGE gfilter-concatMap "Warning: gfilter-concatMap was deprecated in v0.15. Please use mapMaybe-concatMap instead." #-} length-gfilter = length-mapMaybe {-# WARNING_ON_USAGE length-gfilter "Warning: length-gfilter was deprecated in v0.15. Please use length-mapMaybe instead." #-} right-identity-unique = ++-identityʳ-unique {-# WARNING_ON_USAGE right-identity-unique "Warning: right-identity-unique was deprecated in v0.15. Please use ++-identityʳ-unique instead." #-} left-identity-unique = ++-identityˡ-unique {-# WARNING_ON_USAGE left-identity-unique "Warning: left-identity-unique was deprecated in v0.15. Please use ++-identityˡ-unique instead." #-} -- Version 0.16 module _ (p : A → Bool) where boolTakeWhile++boolDropWhile : ∀ xs → boolTakeWhile p xs ++ boolDropWhile p xs ≡ xs boolTakeWhile++boolDropWhile [] = refl boolTakeWhile++boolDropWhile (x ∷ xs) with p x ... | true = cong (x ∷_) (boolTakeWhile++boolDropWhile xs) ... | false = refl {-# WARNING_ON_USAGE boolTakeWhile++boolDropWhile "Warning: boolTakeWhile and boolDropWhile were deprecated in v0.16. Please use takeWhile and dropWhile instead." #-} boolSpan-defn : boolSpan p ≗ < boolTakeWhile p , boolDropWhile p > boolSpan-defn [] = refl boolSpan-defn (x ∷ xs) with p x ... | true = cong (Prod.map (x ∷_) id) (boolSpan-defn xs) ... | false = refl {-# WARNING_ON_USAGE boolSpan-defn "Warning: boolSpan, boolTakeWhile and boolDropWhile were deprecated in v0.16. Please use span, takeWhile and dropWhile instead." #-} length-boolFilter : ∀ xs → length (boolFilter p xs) ≤ length xs length-boolFilter xs = length-mapMaybe (λ x → if p x then just x else nothing) xs {-# WARNING_ON_USAGE length-boolFilter "Warning: boolFilter was deprecated in v0.16. Please use filter instead." #-} boolPartition-defn : boolPartition p ≗ < boolFilter p , boolFilter (not ∘ p) > boolPartition-defn [] = refl boolPartition-defn (x ∷ xs) with p x ... | true = cong (Prod.map (x ∷_) id) (boolPartition-defn xs) ... | false = cong (Prod.map id (x ∷_)) (boolPartition-defn xs) {-# WARNING_ON_USAGE boolPartition-defn "Warning: boolPartition and boolFilter were deprecated in v0.16. Please use partition and filter instead." #-} module _ (P : A → Set p) (P? : Decidable P) where boolFilter-filters : ∀ xs → All P (boolFilter (isYes ∘ P?) xs) boolFilter-filters [] = [] boolFilter-filters (x ∷ xs) with P? x ... | true because [px] = invert [px] ∷ boolFilter-filters xs ... | false because _ = boolFilter-filters xs {-# WARNING_ON_USAGE boolFilter-filters "Warning: boolFilter was deprecated in v0.16. Please use filter instead." #-} -- Version 0.17 idIsFold = id-is-foldr {-# WARNING_ON_USAGE idIsFold "Warning: idIsFold was deprecated in v0.17. Please use id-is-foldr instead." #-} ++IsFold = ++-is-foldr {-# WARNING_ON_USAGE ++IsFold "Warning: ++IsFold was deprecated in v0.17. Please use ++-is-foldr instead." #-} mapIsFold = map-is-foldr {-# WARNING_ON_USAGE mapIsFold "Warning: mapIsFold was deprecated in v0.17. Please use map-is-foldr instead." #-}
{ "alphanum_fraction": 0.50012791, "avg_line_length": 36.8426013195, "ext": "agda", "hexsha": "121515af7fd8dd0ff65a48c72007fa6d08d43022", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Properties.agda", "max_line_length": 102, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Properties.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": 14383, "size": 39090 }
{-# OPTIONS --cubical --safe #-} module Cardinality.Finite.ManifestEnumerable.Isomorphism where open import Prelude import Cardinality.Finite.ManifestEnumerable.Container as ℒ import Cardinality.Finite.ManifestEnumerable.Inductive as 𝕃 open import Container.List.Isomorphism open import Data.Fin open import HITs.PropositionalTruncation.Sugar open import Data.List using (_∷_; []) open import HITs.PropositionalTruncation open import Cardinality.Finite.SplitEnumerable.Isomorphism open import Data.Sigma.Properties 𝕃⇔ℒ⟨ℰ⟩ : 𝕃.ℰ A ⇔ ℒ.ℰ A 𝕃⇔ℒ⟨ℰ⟩ .fun (sup , cov) = 𝕃→ℒ sup , cov 𝕃⇔ℒ⟨ℰ⟩ .inv (sup , cov) = ℒ→𝕃 sup , λ x → ∈ℒ⇒∈𝕃 x sup ∥$∥ cov x 𝕃⇔ℒ⟨ℰ⟩ .rightInv (sup , cov) = ΣProp≡ (λ xs x y i t → squash (x t) (y t) i) (𝕃⇔ℒ .rightInv sup) 𝕃⇔ℒ⟨ℰ⟩ .leftInv (sup , cov) = ΣProp≡ (λ xs x y i t → squash (x t) (y t) i) (𝕃⇔ℒ .leftInv sup)
{ "alphanum_fraction": 0.7124105012, "avg_line_length": 36.4347826087, "ext": "agda", "hexsha": "91690f030368a555c223818fee2bfda559ec8da5", "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": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Cardinality/Finite/ManifestEnumerable/Isomorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Cardinality/Finite/ManifestEnumerable/Isomorphism.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Cardinality/Finite/ManifestEnumerable/Isomorphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 354, "size": 838 }
data Tree : Set where leaf : Tree _∣_ : Tree → Tree → Tree {-# FOREIGN GHC data Tree = Leaf | Tree :| Tree #-} {-# COMPILE GHC Tree = data Tree (Leaf | (:|)) #-}
{ "alphanum_fraction": 0.5562130178, "avg_line_length": 18.7777777778, "ext": "agda", "hexsha": "a9bc5374ef5d850eb89356a4bec17382c3bb4cc3", "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/GHCInfixConstructor.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/GHCInfixConstructor.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/GHCInfixConstructor.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": 169 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Finite sets ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin where open import Relation.Nullary.Decidable.Core open import Data.Nat.Base using (suc) import Data.Nat.Properties as ℕₚ ------------------------------------------------------------------------ -- Publicly re-export the contents of the base module open import Data.Fin.Base public ------------------------------------------------------------------------ -- Publicly re-export queries open import Data.Fin.Properties public using (_≟_; _≤?_; _<?_) -- # m = "m". infix 10 #_ #_ : ∀ m {n} {m<n : True (suc m ℕₚ.≤? n)} → Fin n #_ _ {m<n = m<n} = fromℕ< (toWitness m<n)
{ "alphanum_fraction": 0.4275274056, "avg_line_length": 25.65625, "ext": "agda", "hexsha": "ec7a28d4de8104c4d4a8bc08678e57561ede01e6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Fin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Fin.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Fin.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": 178, "size": 821 }
{-# OPTIONS --without-K --safe #-} module Definition.Conversion.Universe where open import Definition.Untyped hiding (_∷_) open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.Conversion open import Definition.Conversion.Reduction open import Definition.Conversion.Lift open import Tools.Nat import Tools.PropositionalEquality as PE private variable n : Nat Γ : Con Term n -- Algorithmic equality of terms in WHNF of type U are equal as types. univConv↓ : ∀ {A B} → Γ ⊢ A [conv↓] B ∷ U → Γ ⊢ A [conv↓] B univConv↓ (ne-ins t u () x) univConv↓ (univ x x₁ x₂) = x₂ -- Algorithmic equality of terms of type U are equal as types. univConv↑ : ∀ {A B} → Γ ⊢ A [conv↑] B ∷ U → Γ ⊢ A [conv↑] B univConv↑ ([↑]ₜ B₁ t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) rewrite PE.sym (whnfRed* D Uₙ) = reductionConv↑ (univ* d) (univ* d′) (liftConv (univConv↓ t<>u))
{ "alphanum_fraction": 0.6721479959, "avg_line_length": 27.8, "ext": "agda", "hexsha": "16a79440cb32cbacdfb969a37bff39588e7391db", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z", "max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z", "max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "fhlkfy/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/Universe.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "fhlkfy/logrel-mltt", "max_issues_repo_path": "Definition/Conversion/Universe.agda", "max_line_length": 70, "max_stars_count": 30, "max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "fhlkfy/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/Universe.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z", "num_tokens": 311, "size": 973 }
------------------------------------------------------------------------ -- Morphisms between algebraic structures ------------------------------------------------------------------------ module Algebra.Morphism where open import Relation.Binary open import Algebra open import Algebra.FunctionProperties open import Data.Function ------------------------------------------------------------------------ -- Basic definitions module Definitions (From To : Set) (_≈_ : Rel To) where Morphism : Set Morphism = From → To Homomorphic₀ : Morphism → From → To → Set Homomorphic₀ ⟦_⟧ ∙ ∘ = ⟦ ∙ ⟧ ≈ ∘ Homomorphic₁ : Morphism → Fun₁ From → Op₁ To → Set Homomorphic₁ ⟦_⟧ ∙_ ∘_ = ∀ x → ⟦ ∙ x ⟧ ≈ ∘ ⟦ x ⟧ Homomorphic₂ : Morphism → Fun₂ From → Op₂ To → Set Homomorphic₂ ⟦_⟧ _∙_ _∘_ = ∀ x y → ⟦ x ∙ y ⟧ ≈ (⟦ x ⟧ ∘ ⟦ y ⟧) ------------------------------------------------------------------------ -- Some specific morphisms -- Other morphisms could of course be defined. record _-RawRing⟶_ (From To : RawRing) : Set where open RawRing open Definitions (carrier From) (carrier To) (_≈_ To) field ⟦_⟧ : Morphism +-homo : Homomorphic₂ ⟦_⟧ (_+_ From) (_+_ To) *-homo : Homomorphic₂ ⟦_⟧ (_*_ From) (_*_ To) -‿homo : Homomorphic₁ ⟦_⟧ (-_ From) (-_ To) 0-homo : Homomorphic₀ ⟦_⟧ (0# From) (0# To) 1-homo : Homomorphic₀ ⟦_⟧ (1# From) (1# To) _-Ring⟶_ : Ring → Ring → Set From -Ring⟶ To = rawRing From -RawRing⟶ rawRing To where open Ring
{ "alphanum_fraction": 0.5040431267, "avg_line_length": 30.9166666667, "ext": "agda", "hexsha": "77dd6f2b583c6aa0000af2a592fad38d68d12173", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Algebra/Morphism.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Algebra/Morphism.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Algebra/Morphism.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": 463, "size": 1484 }
{-# OPTIONS --type-in-type #-} -- yes, there will be some cheating in this lecture module Lec3Done where open import Lec1Done open import Lec2Done postulate extensionality : {S : Set}{T : S -> Set} {f g : (x : S) -> T x} -> ((x : S) -> f x == g x) -> f == g imp : {S : Set}{T : S -> Set}(f : (x : S) -> T x){x : S} -> T x imp f {x} = f x extensionality' : {S : Set}{T : S -> Set} {f g : {x : S} -> T x} -> ((x : S) -> f {x} == g {x}) -> _==_ {forall {x : S} -> T x} f g extensionality' {f = f}{g = g} q = refl imp =$= extensionality {f = \ x -> f {x}}{g = \ x -> g {x}} q _[QED] : {X : Set}(x : X) -> x == x x [QED] = refl x _=[_>=_ : {X : Set}(x : X){y z : X} -> x == y -> y == z -> x == z x =[ refl .x >= q = q _=<_]=_ : {X : Set}(x : X){y z : X} -> y == x -> y == z -> x == z x =< refl .x ]= q = q infixr 1 _=[_>=_ _=<_]=_ infixr 2 _[QED] record Category : Set where field -- two types of thing Obj : Set -- "objects" _~>_ : Obj -> Obj -> Set -- "arrows" or "morphisms" -- or "homomorphisms" -- two operations id~> : {T : Obj} -> T ~> T _>~>_ : {R S T : Obj} -> R ~> S -> S ~> T -> R ~> T -- three laws law-id~>>~> : {S T : Obj} (f : S ~> T) -> (id~> >~> f) == f law->~>id~> : {S T : Obj} (f : S ~> T) -> (f >~> id~>) == f law->~>>~> : {Q R S T : Obj} (f : Q ~> R)(g : R ~> S)(h : S ~> T) -> ((f >~> g) >~> h) == (f >~> (g >~> h)) assocn : {Q R R' S T : Obj} {f : Q ~> R} {g : R ~> S} {f' : Q ~> R'}{g' : R' ~> S} {h : S ~> T} -> (f >~> g) == (f' >~> g') -> (f >~> g >~> h) == (f' >~> g' >~> h) assocn {f = f} {g = g} {f' = f'} {g' = g'} {h = h} q = f >~> g >~> h =< law->~>>~> _ _ _ ]= (f >~> g) >~> h =[ refl _>~>_ =$= q =$= refl h >= (f' >~> g') >~> h =[ law->~>>~> _ _ _ >= f' >~> g' >~> h [QED] infixr 3 _>~>_ -- Sets and functions are the classic example of a category. SET : Category SET = record { Obj = Set ; _~>_ = \ S T -> S -> T ; id~> = id ; _>~>_ = _>>_ ; law-id~>>~> = \ f -> refl f ; law->~>id~> = \ f -> refl f ; law->~>>~> = \ f g h -> refl (f >> (g >> h)) } -- A PREORDER is a category where there is at most one arrow between -- any two objects. (So arrows are unique.) NAT->= : Category unique->= : (m n : Nat)(p q : m >= n) -> p == q unique->= m zero p q = refl <> unique->= zero (suc n) () q unique->= (suc m) (suc n) p q = unique->= m n p q NAT->= = record { Obj = Nat ; _~>_ = _>=_ ; id~> = \ {n} -> refl->= n ; _>~>_ = \ {m}{n}{p} m>=n n>=p -> trans->= m n p m>=n n>=p ; law-id~>>~> = \ {m}{n} m>=n -> unique->= m n _ _ ; law->~>id~> = \ {m}{n} m>=n -> unique->= m n _ _ ; law->~>>~> = \ {m}{n}{p}{q} m>n n>=p p>=q -> unique->= m q _ _ } where -- A MONOID is a category with Obj = One. -- The values in the monoid are the *arrows*. ONE-Nat : Category ONE-Nat = record { Obj = One ; _~>_ = \ _ _ -> Nat ; id~> = 0 ; _>~>_ = _+N_ ; law-id~>>~> = \ n -> zero-+N n ; law->~>id~> = \ n -> +N-zero n ; law->~>>~> = \ m n p -> assocLR-+N m n p } eqUnique : {X : Set}{x y : X}(p q : x == y) -> p == q eqUnique (refl x) (refl .x) = refl (refl x) -- A DISCRETE category is one where the only arrows are the identities. DISCRETE : (X : Set) -> Category DISCRETE X = record { Obj = X ; _~>_ = _==_ ; id~> = refl _ ; _>~>_ = \ { {x} (refl .x) (refl .x) -> refl x } ; law-id~>>~> = \ _ -> eqUnique _ _ ; law->~>id~> = \ _ -> eqUnique _ _ ; law->~>>~> = \ _ _ _ -> eqUnique _ _ } module FUNCTOR where open Category record _=>_ (C D : Category) : Set where -- "Functor from C to D" field -- two actions F-Obj : Obj C -> Obj D F-map : {S T : Obj C} -> _~>_ C S T -> _~>_ D (F-Obj S) (F-Obj T) -- two laws F-map-id~> : {T : Obj C} -> F-map (id~> C {T}) == id~> D {F-Obj T} F-map->~> : {R S T : Obj C}(f : _~>_ C R S)(g : _~>_ C S T) -> F-map (_>~>_ C f g) == _>~>_ D (F-map f) (F-map g) open FUNCTOR public postulate homework : {A : Set} -> A VEC : Nat -> SET => SET VEC n = record { F-Obj = \ X -> Vec X n ; F-map = homework ; F-map-id~> = homework ; F-map->~> = homework } VTAKE : Set -> NAT->= => SET VTAKE X = record { F-Obj = Vec X ; F-map = \ {m}{n} m>=n xs -> vTake m n m>=n xs ; F-map-id~> = \ {n} -> extensionality \ xs -> vTakeIdFact n xs ; F-map->~> = \ {m}{n}{p} m>=n n>=p -> extensionality \ xs -> vTakeCpFact m n p m>=n n>=p xs } ADD : Nat -> NAT->= => NAT->= ADD d = record { F-Obj = (d +N_) ; F-map = \ {m}{n} -> help d m n ; F-map-id~> = \ {n} -> unique->= (d +N n) (d +N n) _ _ ; F-map->~> = \ {m}{n}{p} x y -> unique->= (d +N m) (d +N p) _ _ } where help : (d m n : Nat) -> m >= n -> (d +N m) >= (d +N n) help zero m n m>=n = m>=n help (suc d) m n m>=n = help d m n m>=n Thing : {C D : Category}(F G : C => D) -> Set Thing {C}{D} (record { F-Obj = F-Obj ; F-map = F-map ; F-map-id~> = F-map-id~> ; F-map->~> = F-map->~> }) (record { F-Obj = G-Obj ; F-map = G-map ; F-map-id~> = G-map-id~> ; F-map->~> = G-map->~> }) = Sg (F-Obj == G-Obj) \ { (refl _) -> Sg (_==_ {forall {S T : Category.Obj C} → (C Category.~> S) T → (D Category.~> F-Obj S) (F-Obj T)} F-map G-map) \ { (refl _) -> _==_ {forall {T : Category.Obj C} → F-map (Category.id~> C {T}) == Category.id~> D} F-map-id~> G-map-id~> * _==_ {forall {R S T : Category.Obj C} (f : (C Category.~> R) S) (g : (C Category.~> S) T) → F-map ((C Category.>~> f) g) == (D Category.>~> F-map f) (F-map g)} F-map->~> G-map->~> }} Lemma : {C D : Category}{F G : C => D} -> Thing F G -> F == G Lemma (refl _ , (refl _ , (refl _ , refl _))) = refl _ CATEGORY : Category CATEGORY = record { Obj = Category ; _~>_ = _=>_ ; id~> = record { F-Obj = \ X -> X ; F-map = \ a -> a ; F-map-id~> = refl _ ; F-map->~> = \ _ _ -> refl _ } ; _>~>_ = \ {R}{S}{T} F G -> record { F-Obj = F-Obj F >> F-Obj G ; F-map = F-map F >> F-map G ; F-map-id~> = F-map G (F-map F (Category.id~> R)) =[ refl (F-map G) =$= F-map-id~> F >= F-map G (Category.id~> S) =[ F-map-id~> G >= Category.id~> T [QED] ; F-map->~> = \ f g -> F-map G (F-map F (Category._>~>_ R f g)) =[ refl (F-map G) =$= F-map->~> F f g >= F-map G (Category._>~>_ S (F-map F f) (F-map F g)) =[ F-map->~> G (F-map F f) (F-map F g) >= Category._>~>_ T (F-map G (F-map F f)) (F-map G (F-map F g)) [QED] } ; law-id~>>~> = \ F -> Lemma ((refl _) , ((refl _) , (extensionality' (\ x -> eqUnique _ _) , extensionality' (\ x -> extensionality' \ y -> extensionality' \ z -> extensionality \ f -> extensionality \ g -> eqUnique _ _)))) ; law->~>id~> = \ F -> Lemma ((refl _) , ((refl _) , (extensionality' (\ x -> eqUnique _ _) , extensionality' (\ x -> extensionality' \ y -> extensionality' \ z -> extensionality \ f -> extensionality \ g -> eqUnique _ _)))) ; law->~>>~> = \ F G H -> Lemma ((refl _) , ((refl _) , (extensionality' (\ x -> eqUnique _ _) , extensionality' (\ x -> extensionality' \ y -> extensionality' \ z -> extensionality \ f -> extensionality \ g -> eqUnique _ _)))) } where open _=>_
{ "alphanum_fraction": 0.3548817061, "avg_line_length": 35.8685258964, "ext": "agda", "hexsha": "52b8d95462a20ebd0b6b67ac8e30023cde93173e", "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/Lec3Done.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/Lec3Done.agda", "max_line_length": 83, "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/Lec3Done.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": 3110, "size": 9003 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.CommAlgebra.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.Equiv.HalfAdjoint open import Cubical.Foundations.SIP 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 open import Cubical.Algebra.Ring open import Cubical.Algebra.Algebra open import Cubical.Algebra.CommAlgebra.Base private variable ℓ ℓ′ : Level -- An R-algebra is the same as a CommRing A with a CommRingHom φ : R → A module CommAlgChar (R : CommRing ℓ) where open Iso open IsRingHom open CommRingTheory CommRingWithHom : Type (ℓ-suc ℓ) CommRingWithHom = Σ[ A ∈ CommRing ℓ ] CommRingHom R A toCommAlg : CommRingWithHom → CommAlgebra R ℓ toCommAlg (A , φ , φIsHom) = ⟨ A ⟩ , ACommAlgStr where open CommRingStr (snd A) ACommAlgStr : CommAlgebraStr R ⟨ A ⟩ CommAlgebraStr.0a ACommAlgStr = 0r CommAlgebraStr.1a ACommAlgStr = 1r CommAlgebraStr._+_ ACommAlgStr = _+_ CommAlgebraStr._·_ ACommAlgStr = _·_ CommAlgebraStr.- ACommAlgStr = -_ CommAlgebraStr._⋆_ ACommAlgStr r a = (φ r) · a CommAlgebraStr.isCommAlgebra ACommAlgStr = makeIsCommAlgebra is-set +Assoc +Rid +Rinv +Comm ·Assoc ·Lid ·Ldist+ ·Comm (λ _ _ x → cong (λ y → y · x) (pres· φIsHom _ _) ∙ sym (·Assoc _ _ _)) (λ _ _ x → cong (λ y → y · x) (pres+ φIsHom _ _) ∙ ·Ldist+ _ _ _) (λ _ _ _ → ·Rdist+ _ _ _) (λ x → cong (λ y → y · x) (pres1 φIsHom) ∙ ·Lid x) (λ _ _ _ → sym (·Assoc _ _ _)) fromCommAlg : CommAlgebra R ℓ → CommRingWithHom fromCommAlg A = (CommAlgebra→CommRing A) , φ , φIsHom where open CommRingStr (snd R) renaming (_·_ to _·r_) hiding (·Lid) open CommAlgebraStr (snd A) open AlgebraTheory (CommRing→Ring R) (CommAlgebra→Algebra A) φ : ⟨ R ⟩ → ⟨ A ⟩ φ r = r ⋆ 1a φIsHom : IsRingHom (CommRing→Ring R .snd) φ (CommRing→Ring (CommAlgebra→CommRing A) .snd) φIsHom = makeIsRingHom (⋆-lid _) (λ _ _ → ⋆-ldist _ _ _) λ x y → cong (λ a → (x ·r y) ⋆ a) (sym (·Lid _)) ∙ ⋆Dist· _ _ _ _ CommRingWithHomRoundTrip : (Aφ : CommRingWithHom) → fromCommAlg (toCommAlg Aφ) ≡ Aφ CommRingWithHomRoundTrip (A , φ) = ΣPathP (APath , φPathP) where open CommRingStr -- note that the proofs of the axioms might differ! APath : fst (fromCommAlg (toCommAlg (A , φ))) ≡ A fst (APath i) = ⟨ A ⟩ 0r (snd (APath i)) = 0r (snd A) 1r (snd (APath i)) = 1r (snd A) _+_ (snd (APath i)) = _+_ (snd A) _·_ (snd (APath i)) = _·_ (snd A) -_ (snd (APath i)) = -_ (snd A) isCommRing (snd (APath i)) = isProp→PathP (λ i → isPropIsCommRing _ _ _ _ _ ) (isCommRing (snd (fst (fromCommAlg (toCommAlg (A , φ)))))) (isCommRing (snd A)) i -- this only works because fst (APath i) = fst A definitionally! φPathP : PathP (λ i → CommRingHom R (APath i)) (snd (fromCommAlg (toCommAlg (A , φ)))) φ φPathP = RingHomPathP _ _ _ _ _ _ λ i x → ·Rid (snd A) (fst φ x) i CommAlgRoundTrip : (A : CommAlgebra R ℓ) → toCommAlg (fromCommAlg A) ≡ A CommAlgRoundTrip A = ΣPathP (refl , AlgStrPathP) where open CommAlgebraStr ⦃...⦄ instance _ = snd A AlgStrPathP : PathP (λ i → CommAlgebraStr R ⟨ A ⟩) (snd (toCommAlg (fromCommAlg A))) (snd A) CommAlgebraStr.0a (AlgStrPathP i) = 0a CommAlgebraStr.1a (AlgStrPathP i) = 1a CommAlgebraStr._+_ (AlgStrPathP i) = _+_ CommAlgebraStr._·_ (AlgStrPathP i) = _·_ CommAlgebraStr.-_ (AlgStrPathP i) = -_ CommAlgebraStr._⋆_ (AlgStrPathP i) r x = (⋆-lassoc r 1a x ∙ cong (r ⋆_) (·Lid x)) i CommAlgebraStr.isCommAlgebra (AlgStrPathP i) = isProp→PathP (λ i → isPropIsCommAlgebra _ _ _ _ _ _ (CommAlgebraStr._⋆_ (AlgStrPathP i))) (CommAlgebraStr.isCommAlgebra (snd (toCommAlg (fromCommAlg A)))) isCommAlgebra i CommAlgIso : Iso (CommAlgebra R ℓ) CommRingWithHom fun CommAlgIso = fromCommAlg inv CommAlgIso = toCommAlg rightInv CommAlgIso = CommRingWithHomRoundTrip leftInv CommAlgIso = CommAlgRoundTrip
{ "alphanum_fraction": 0.6892117171, "avg_line_length": 36.8333333333, "ext": "agda", "hexsha": "cfa46fbc1557b2702a658311c433326e6995d932", "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/Properties.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/Properties.agda", "max_line_length": 94, "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/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1595, "size": 4199 }
module Krivine (Atom Const : Set) where open import Data.Nat open import Data.Sum open import Data.Vec as Vec using (Vec; _∷_; []) data Type : Set where atom : Atom → Type _⇒_ : Type → Type → Type Basis : ℕ → Set Basis = Vec Type data Var : ∀ {n} → Basis n → Type → Set where vzero : ∀ {n} {Γ : Basis n} {τ} → Var (τ ∷ Γ) τ vsuc : ∀ {n} {Γ : Basis n} {σ τ} → Var Γ τ → Var (σ ∷ Γ) τ data Term (Σ : Const → Type) {n} (Γ : Basis n) : Type → Set where app : ∀ {σ τ} → Term Σ Γ (σ ⇒ τ) → Term Σ Γ σ → Term Σ Γ τ lam : ∀ {σ τ} → Term Σ (σ ∷ Γ) τ → Term Σ Γ (σ ⇒ τ) var : ∀ {τ} → Var Γ τ → Term Σ Γ τ mutual data Subst (A : ∀ {n} (Γ : Basis n) → Type → Set) : ∀ {n₁} (Γ₁ : Basis n₁) {n₂} (Γ₂ : Basis n₂) → Set where comp : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {n₃} {Γ₃ : Basis n₃} → Subst A Γ₁ Γ₂ → Subst A Γ₂ Γ₃ → Subst A Γ₁ Γ₃ cons : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {τ} → A Γ₂ τ → Subst A Γ₁ Γ₂ → Subst A (τ ∷ Γ₁) Γ₂ id : ∀ {n} {Γ : Basis n} → Subst A Γ Γ lift : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {τ} → Subst A Γ₁ Γ₂ → Subst A (τ ∷ Γ₁) (τ ∷ Γ₂) shift : ∀ {n} {Γ : Basis n} {τ} → Subst A Γ (τ ∷ Γ) data Thunk (A : ∀ {n} (Γ : Basis n) → Type → Set) {n} (Γ : Basis n) τ : Set where thunk : ∀ {n'} {Γ' : Basis n'} → A Γ' τ → Subst (Thunk A) Γ' Γ → Thunk A Γ τ lookup : ∀ {A : ∀ {n} (Γ : Basis n) → Type → Set} → (∀ {n} {Γ : Basis n} {σ} → Var Γ σ → Thunk A Γ σ) → (∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {τ} → Thunk A Γ₁ τ → Subst (Thunk A) Γ₁ Γ₂ → Thunk A Γ₂ τ) → ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {τ} → Var Γ₁ τ → Subst (Thunk A) Γ₁ Γ₂ → Thunk A Γ₂ τ lookup {A} box under = lookup' where lookup' : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {τ} → Var Γ₁ τ → Subst (Thunk A) Γ₁ Γ₂ → Thunk A Γ₂ τ lookup' v (comp ρ σ) = under (lookup' v ρ) σ lookup' vzero (cons x _) = x lookup' (vsuc v) (cons _ σ) = lookup' v σ lookup' v id = box v lookup' vzero (lift _) = box vzero lookup' (vsuc v) (lift σ) = under (lookup' v σ) shift lookup' v shift = box (vsuc v) boxvar : ∀ {Σ : Const → Type} {n} {Γ : Basis n} {τ} → Var Γ τ → Thunk (Term Σ) Γ τ boxvar v = thunk (var v) id close : ∀ {Σ : Const → Type} {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {τ} → Thunk (Term Σ) Γ₁ τ → Subst (Thunk (Term Σ)) Γ₁ Γ₂ → Thunk (Term Σ) Γ₂ τ close (thunk t ρ) σ = thunk t (comp ρ σ) mutual subst : ∀ {Σ : Const → Type} {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {τ} → Term Σ Γ₁ τ → Subst (Thunk (Term Σ)) Γ₁ Γ₂ → Term Σ Γ₂ τ subst (app s t) σ = app (subst s σ) (subst t σ) subst (lam t) σ = lam (subst t (lift σ)) subst (var v) id = var v subst (var v) σ = force (lookup boxvar close v σ) force : ∀ {Σ : Const → Type} {n} {Γ : Basis n} {τ} → Thunk (Term Σ) Γ τ → Term Σ Γ τ force (thunk t ρ) = subst t ρ data Context (A : ∀ {n} (Γ : Basis n) → Type → Set) : ∀ {n₁} (Γ₁ : Basis n₁) {n₂} (Γ₂ : Basis n₂) → Type → Type → Set where app₁ : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {ρ σ τ} → Context A Γ₁ Γ₂ σ τ → A Γ₁ ρ → Context A Γ₁ Γ₂ (ρ ⇒ σ) τ app₂ : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {ρ σ τ} → A Γ₁ (ρ ⇒ σ) → Context A Γ₁ Γ₂ σ τ → Context A Γ₁ Γ₂ ρ τ lam₁ : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {ρ σ τ} → Context A Γ₁ Γ₂ (ρ ⇒ σ) τ → Context A (ρ ∷ Γ₁) Γ₂ σ τ top : ∀ {n} {Γ : Basis n} {τ} → Context A Γ Γ τ τ foldctx : ∀ {A : ∀ {n} (Γ : Basis n) → Type → Set} {Σ : Const → Type} {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {σ τ} → (∀ {n} {Γ : Basis n} {ρ} → A Γ ρ → Term Σ Γ ρ) → Term Σ Γ₁ σ → Context A Γ₁ Γ₂ σ τ → Term Σ Γ₂ τ foldctx f z (app₁ ctx y) = foldctx f (app z (f y)) ctx foldctx f z (app₂ x ctx) = foldctx f (app (f x) z) ctx foldctx f z (lam₁ ctx) = foldctx f (lam z) ctx foldctx _ z top = z data Head (Σ : Const → Type) {n} (Γ : Basis n) : Type → Set where var : ∀ {τ} → Var Γ τ → Head Σ Γ τ data Spine (Σ : Const → Type) (A : (∀ {n} (Γ : Basis n) → Type → Set) → ∀ {n} (Γ : Basis n) → Type → Set) {n} (Γ : Basis n) τ : Set where spine : ∀ {n'} {Γ' : Basis n'} {σ} → Head Σ Γ' σ → Context (A (Term Σ)) Γ' Γ σ τ → Spine Σ A Γ τ eval : ∀ {Σ : Const → Type} {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {σ τ} → Thunk (Term Σ) Γ₁ σ → Context (Thunk (Term Σ)) Γ₁ Γ₂ σ τ → Spine Σ Thunk Γ₂ τ eval (thunk (app s t) σ) ctx = eval (thunk s σ) (app₁ ctx (thunk t σ)) eval (thunk (lam t) σ) (app₁ ctx x) = eval (thunk t (cons x σ)) ctx eval (thunk (lam t) σ) ctx = eval (thunk t (lift σ)) (lam₁ ctx) eval (thunk (var v) id) ctx = spine (var v) ctx eval (thunk (var v) σ) ctx = eval (lookup boxvar close v σ) ctx data Subst' (A : ∀ {n} (Γ : Basis n) → Type → Set) : ∀ {n₁} (Γ₁ : Basis n₁) {n₂} (Γ₂ : Basis n₂) → Set where comp : ∀ {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} {n₃} {Γ₃ : Basis n₃} → Subst A Γ₁ Γ₂ → Subst' A Γ₂ Γ₃ → Subst' A Γ₁ Γ₃ id : ∀ {n} {Γ : Basis n} → Subst' A Γ Γ data Thunk' (A : ∀ {n} (Γ : Basis n) → Type → Set) {n} (Γ : Basis n) τ : Set where thunk : ∀ {n'} {Γ' : Basis n'} → A Γ' τ → Subst' (Thunk' A) Γ' Γ → Thunk' A Γ τ data Machine (Σ : Const → Type) {n} (Γ : Basis n) τ : Set where machine : ∀ {n'} {Γ' : Basis n'} {σ} → Thunk' (Term Σ) Γ' σ → Context (Thunk' (Term Σ)) Γ' Γ σ τ → Machine Σ Γ τ coerce : ∀ {A : ∀ {n} (Γ : Basis n) → Type → Set} {n₁} {Γ₁ : Basis n₁} {n₂} {Γ₂ : Basis n₂} → Subst' A Γ₁ Γ₂ → Subst A Γ₁ Γ₂ coerce (comp ρ σ) = comp ρ (coerce σ) coerce id = id step : ∀ {Σ : Const → Type} {n} {Γ : Basis n} {τ} → Machine Σ Γ τ → Spine Σ Thunk' Γ τ ⊎ Machine Σ Γ τ step (machine (thunk (var v) (comp shift σ)) ctx) = inj₂ (machine (thunk (var (vsuc v)) σ) ctx) step (machine (thunk (var vzero) (comp (cons (thunk u π) _) σ)) ctx) = inj₂ (machine (thunk u (comp (coerce π) σ)) ctx) step (machine (thunk (var vzero) (comp (lift _) σ)) ctx) = inj₂ (machine (thunk (var vzero) σ) ctx) step (machine (thunk (var (vsuc v)) (comp (cons (thunk _ _) ρ) σ)) ctx) = inj₂ (machine (thunk (var v) (comp ρ σ)) ctx) step (machine (thunk (var (vsuc v)) (comp (lift ρ) σ)) ctx) = inj₂ (machine (thunk (var v) (comp ρ (comp shift σ))) ctx) step (machine (thunk t (comp (comp π ρ) σ)) ctx) = inj₂ (machine (thunk t (comp π (comp ρ σ))) ctx) step (machine (thunk t (comp id σ)) ctx) = inj₂ (machine (thunk t σ) ctx) step (machine (thunk t σ) (app₂ (thunk s ρ) ctx)) = inj₂ (machine (thunk s ρ) (app₁ ctx (thunk t σ))) step (machine (thunk (app s (var v)) σ) ctx) = inj₂ (machine (thunk (var v) σ) (app₂ (thunk s σ) ctx)) step (machine (thunk (app s t) σ) ctx) = inj₂ (machine (thunk s σ) (app₁ ctx (thunk t σ))) step (machine (thunk (lam t) σ) (app₁ ctx x)) = inj₂ (machine (thunk t (comp (cons x (coerce σ)) id)) ctx) step (machine (thunk (lam t) σ) ctx) = inj₂ (machine (thunk t (comp (lift (coerce σ)) id)) (lam₁ ctx)) step (machine (thunk (var v) id) ctx) = inj₁ (spine (var v) ctx) reduce : ∀ {Σ : Const → Type} {n} {Γ : Basis n} {τ} → Machine Σ Γ τ → Spine Σ Thunk' Γ τ reduce m with step m ... | inj₁ x = x ... | inj₂ m' = reduce m'
{ "alphanum_fraction": 0.4793190416, "avg_line_length": 61, "ext": "agda", "hexsha": "a99c87ea36792756e94ba739caefb9d2ddc57840", "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": "46b3960841fd45d7db9e92906c3c2be562df0385", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cls/strong-krivine", "max_forks_repo_path": "Krivine.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "46b3960841fd45d7db9e92906c3c2be562df0385", "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": "cls/strong-krivine", "max_issues_repo_path": "Krivine.agda", "max_line_length": 161, "max_stars_count": 5, "max_stars_repo_head_hexsha": "46b3960841fd45d7db9e92906c3c2be562df0385", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cls/strong-krivine", "max_stars_repo_path": "Krivine.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-13T23:05:34.000Z", "max_stars_repo_stars_event_min_datetime": "2017-01-31T07:10:06.000Z", "num_tokens": 3255, "size": 7930 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Sets.EquivalenceRelations open import Functions.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_; Setω) open import Setoids.Setoids open import Groups.Definition open import LogicalFormulae open import Orders.WellFounded.Definition open import Numbers.Naturals.Semiring open import Groups.Lemmas module Groups.FreeProduct.Definition {i : _} {I : Set i} (decidableIndex : (x y : I) → ((x ≡ y) || ((x ≡ y) → False))) {a b : _} {A : I → Set a} {S : (i : I) → Setoid {a} {b} (A i)} {_+_ : (i : I) → (A i) → (A i) → A i} (decidableGroups : (i : I) → (x y : A i) → ((Setoid._∼_ (S i) x y)) || ((Setoid._∼_ (S i) x y) → False)) (G : (i : I) → Group (S i) (_+_ i)) where data ReducedSequenceBeginningWith : I → Set (a ⊔ b ⊔ i) where ofEmpty : (i : I) → (g : A i) → .(nonZero : (Setoid._∼_ (S i) g (Group.0G (G i))) → False) → ReducedSequenceBeginningWith i prependLetter : (i : I) → (g : A i) → .(nonZero : Setoid._∼_ (S i) g (Group.0G (G i)) → False) → {j : I} → ReducedSequenceBeginningWith j → ((i ≡ j) → False) → ReducedSequenceBeginningWith i data ReducedSequence : Set (a ⊔ b ⊔ i) where empty : ReducedSequence nonempty : (i : I) → ReducedSequenceBeginningWith i → ReducedSequence injection : {i : I} (x : A i) .(nonzero : (Setoid._∼_ (S i) x (Group.0G (G i))) → False) → ReducedSequence injection {i} x nonzero = nonempty i (ofEmpty i x nonzero)
{ "alphanum_fraction": 0.6363636364, "avg_line_length": 57.64, "ext": "agda", "hexsha": "2cb88e4a68c2519792f7bb427aabc8a08170e640", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/FreeProduct/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/FreeProduct/Definition.agda", "max_line_length": 366, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/FreeProduct/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 521, "size": 1441 }
open import Data.Product using ( _,_ ) open import Web.Semantic.DL.ABox using ( ε ) open import Web.Semantic.DL.Category.Object using ( Object ; _,_ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.Util using ( False ; False∈Fin ) module Web.Semantic.DL.Category.Unit {Σ : Signature} where I : ∀ {S T : TBox Σ} → Object S T I = (False , False∈Fin , ε)
{ "alphanum_fraction": 0.7146118721, "avg_line_length": 36.5, "ext": "agda", "hexsha": "8c621225dd64201ce4480842b012a669a18ca454", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Unit.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Unit.agda", "max_line_length": 66, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Category/Unit.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 131, "size": 438 }
-- Andreas, 2016-07-29 issue #707, comment of 2012-10-31 data Bool : Set where true false : Bool mutual data D : Bool → Set where c d : D ? fixIx : (b : Bool) → D b → D b fixIx true c = c fixIx false d = d -- Works, but maybe questionable. -- The _ is duplicated into two different internal metas.
{ "alphanum_fraction": 0.6392405063, "avg_line_length": 19.75, "ext": "agda", "hexsha": "ffeb53704ea1b20562e9a7d642daf40e8b9b551b", "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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Fail/Issue707-data.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "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": "pthariensflame/agda", "max_issues_repo_path": "test/Fail/Issue707-data.agda", "max_line_length": 57, "max_stars_count": 3, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Fail/Issue707-data.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": 104, "size": 316 }
{-# OPTIONS --without-K --safe #-} module TypeTheory.HoTT.Relation.Nullary.Negation.Properties where -- agda-stdlib open import Axiom.Extensionality.Propositional open import Level renaming (zero to lzero) open import Relation.Nullary -- agda-misc open import TypeTheory.HoTT.Base open import TypeTheory.HoTT.Data.Empty.Properties open import TypeTheory.HoTT.Function.Properties private variable a b : Level A : Set a B : Set b module _ {a} {A : Set a} where isProp-¬ : Extensionality a lzero → isProp (¬ A) isProp-¬ ext = isProp-→ ext isProp-⊥
{ "alphanum_fraction": 0.7323943662, "avg_line_length": 23.6666666667, "ext": "agda", "hexsha": "af96a46989378a0724d90d0b44697ca172afbe9f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "TypeTheory/HoTT/Relation/Nullary/Negation/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "TypeTheory/HoTT/Relation/Nullary/Negation/Properties.agda", "max_line_length": 65, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "TypeTheory/HoTT/Relation/Nullary/Negation/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 166, "size": 568 }
module Function.Inverse where open import Data.Tuple as Tuple using (_⨯_ ; _,_) import Lvl open import Logic open import Logic.Propositional open import Logic.Predicate open import Functional open import Function.Equals open import Function.Equals.Proofs open import Function.Inverseₗ open import Function.Inverseᵣ open import Structure.Setoid open import Structure.Setoid.Uniqueness open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Domain.Proofs open import Structure.Operator open import Structure.Relator.Properties open import Syntax.Transitivity open import Type module _ {ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂} {A : Type{ℓ₁}} ⦃ eqA : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓ₂}} ⦃ eqB : Equiv{ℓₑ₂}(B) ⦄ where private variable f : A → B -- The inverse function of a bijective function f. inv : (f : A → B) → ⦃ inver : Invertible(f) ⦄ → (B → A) inv(f) ⦃ inver ⦄ = [∃]-witness inver module _ {f : A → B} ⦃ inver : Invertible(f) ⦄ where inv-inverse : Inverse(f)(inv f) inv-inverse = [∧]-elimᵣ([∃]-proof inver) inv-inverseₗ : Inverseₗ(f)(inv f) inv-inverseₗ = [∧]-elimₗ inv-inverse inv-inverseᵣ : Inverseᵣ(f)(inv f) inv-inverseᵣ = [∧]-elimᵣ inv-inverse inv-function : Function(inv f) inv-function = [∧]-elimₗ([∃]-proof inver) inv-surjective : Surjective(inv f) inv-surjective = inverse-surjective ⦃ inver = [∧]-elimᵣ([∃]-proof inver) ⦄ module _ ⦃ func : Function(f) ⦄ where inv-injective : Injective(inv f) inv-injective = inverse-injective ⦃ inver = [∧]-elimᵣ([∃]-proof inver) ⦄ inv-bijective : Bijective(inv f) inv-bijective = inverse-bijective ⦃ inver = [∧]-elimᵣ([∃]-proof inver) ⦄ {- module _ {f : A → B} ⦃ inver : Invertible(f) ⦄ ⦃ inv-func : Function(inv f) ⦄ where inv-sides-equality : (invₗ(f) ⊜ invᵣ(f)) inv-sides-equality = invₗ(f) 🝖[ _⊜_ ]-[] invₗ(f) ∘ id 🝖[ _⊜_ ]-[ [⊜][∘]-binaryOperator-raw {f₁ = invₗ(f)} ⦃ func₂ = {!!} ⦄ (reflexivity(_⊜_)) (intro(inverseᵣ(f)(invᵣ f) ⦃ inv-inverseᵣ ⦄)) ]-sym invₗ(f) ∘ (f ∘ invᵣ(f)) 🝖[ _⊜_ ]-[] (invₗ(f) ∘ f) ∘ invᵣ(f) 🝖[ _⊜_ ]-[ {!!} ] id ∘ invᵣ(f) 🝖[ _⊜_ ]-[] invᵣ(f) 🝖-end -- congruence₂ᵣ(_∘_)(invₗ(f)) ? -- x₁ ≡ x₂ -- inv f(y₁) ≡ inv f(y₂) --f(x₁) ≡ f(x₂) --invᵣ f(f(x₁)) ≡ invᵣ f(f(x₂)) --invᵣ f(f(x₁)) -} {- -- inv is a left inverse function to a bijective f. inv-inverseₗ : Inverseₗ(f)(inv f) inv-inverseₗ = invᵣ-inverseₗ ⦃ inj = {!invertibleₗ-to-injective!} ⦄ -- [∃!]-existence-eq-any (bijective(f)) (reflexivity(_≡_)) inv-injective : Injective(inv f) inv-injective = {!invᵣ-injective!}-} {- -- inv(f) is surjective when f is bijective. inv-surjective : Surjective(inv(f)) Surjective.proof(inv-surjective) {x} = [∃]-intro(f(x)) ⦃ inv-inverseₗ ⦄ inv-unique-inverseᵣ : ∀{f⁻¹} → (f ∘ f⁻¹ ⊜ id) → (f⁻¹ ⊜ inv(f)) inv-unique-inverseᵣ = invᵣ-unique-inverseᵣ ⦃ surj = bijective-to-surjective(f) ⦄ ⦃ inj = bijective-to-injective(f) ⦄ inv-unique-inverseₗ : ∀{f⁻¹} → ⦃ _ : Function(f⁻¹) ⦄ → (f⁻¹ ∘ f ⊜ id) → (f⁻¹ ⊜ inv(f)) inv-unique-inverseₗ = invᵣ-unique-inverseₗ ⦃ surj = bijective-to-surjective(f) ⦄ -- inv(f) is a function when f is a function. inv-function : Function(inv(f)) inv-function = invᵣ-function ⦃ surj = bijective-to-surjective(f) ⦄ ⦃ inj = bijective-to-injective(f) ⦄ module _ ⦃ func : Function(f) ⦄ where -- inv(f) is injective when f is a function and is bijective. inv-injective : Injective(inv f) inv-injective = invᵣ-injective ⦃ surj = bijective-to-surjective(f) ⦄ -- inv(f) is bijective when f is a function and is bijective. inv-bijective : Bijective(inv(f)) inv-bijective = injective-surjective-to-bijective(inv(f)) ⦃ inv-injective ⦄ ⦃ inv-surjective ⦄ -}
{ "alphanum_fraction": 0.6150875386, "avg_line_length": 32.0991735537, "ext": "agda", "hexsha": "a946bc744a0e6ff254349135ab7ba308453da77d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Function/Inverse.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Function/Inverse.agda", "max_line_length": 169, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Function/Inverse.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": 1512, "size": 3884 }
module Luau.Value where open import Luau.Addr using (Addr) open import Luau.Syntax using (Block; Expr; nil; addr; function⟨_⟩_end) open import Luau.Var using (Var) data Value : Set where nil : Value addr : Addr → Value val : Value → Expr val nil = nil val (addr a) = addr a
{ "alphanum_fraction": 0.6996466431, "avg_line_length": 17.6875, "ext": "agda", "hexsha": "855e663e23be4087d908af15dd0a8823b483b52a", "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": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FreakingBarbarians/luau", "max_forks_repo_path": "prototyping/Luau/Value.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "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": "FreakingBarbarians/luau", "max_issues_repo_path": "prototyping/Luau/Value.agda", "max_line_length": 71, "max_stars_count": 1, "max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FreakingBarbarians/luau", "max_stars_repo_path": "prototyping/Luau/Value.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z", "num_tokens": 85, "size": 283 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary.Raw.Construct.Constant where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels using (hProp) open import Cubical.Relation.Binary.Raw ------------------------------------------------------------------------ -- Definition Const : ∀ {a b c} {A : Type a} {B : Type b} → Type c → RawREL A B c Const I = λ _ _ → I ------------------------------------------------------------------------ -- Properties module _ {a c} {A : Type a} {C : Type c} where reflexive : C → Reflexive {A = A} (Const C) reflexive c = c symmetric : Symmetric {A = A} (Const C) symmetric c = c transitive : Transitive {A = A} (Const C) transitive c d = c isPartialEquivalence : IsPartialEquivalence {A = A} (Const C) isPartialEquivalence = record { symmetric = λ {x} {y} → symmetric {x} {y} ; transitive = λ {x} {y} {z} → transitive {x} {y} {z} } partialEquivalence : PartialEquivalence A c partialEquivalence = record { isPartialEquivalence = isPartialEquivalence } isEquivalence : C → IsEquivalence {A = A} (Const C) isEquivalence c = record { isPartialEquivalence = isPartialEquivalence ; reflexive = λ {x} → reflexive c {x} } equivalence : C → Equivalence A c equivalence x = record { isEquivalence = isEquivalence x }
{ "alphanum_fraction": 0.5998583569, "avg_line_length": 30.0425531915, "ext": "agda", "hexsha": "baa85a4d64338997dd7c5602e408093c621cddbc", "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": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Relation/Binary/Raw/Construct/Constant.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "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": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Relation/Binary/Raw/Construct/Constant.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Relation/Binary/Raw/Construct/Constant.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 391, "size": 1412 }
{-# OPTIONS --allow-unsolved-metas #-} module MGU-revised where --open import Agda.Builtin.Nat using () renaming (Nat to ℕ) open import Agda.Primitive open import Agda.Builtin.Equality open import Prelude.Product using (Σ; _,_; fst; snd; _×_; curry; uncurry) open import Prelude.Equality using (eqReasoningStep; _∎; sym; trans; cong) open import Prelude.Function using (_∘_) open import Prelude.Empty using (⊥) open import Prelude.Sum using (left; right) renaming (Either to _⊎_) open import Prelude.Maybe using (Maybe; just; nothing) private ∃ : ∀ {a b} {A : Set a} (B : A → Set b) → Set (a ⊔ b) ∃ = Σ _ open import Prelude using (_$_) open import Relation.Binary open import Prolegomenon import Relation.Binary.Indexed as I open import Algebra mcbrideMonoidTransformer : MonoidTransformer lzero lzero lzero lzero Setoid.Carrier (MonoidTransformer.base mcbrideMonoidTransformer) = {!!} Setoid._≈_ (MonoidTransformer.base mcbrideMonoidTransformer) = {!!} Setoid.isEquivalence (MonoidTransformer.base mcbrideMonoidTransformer) = {!!} Monoid.Carrier (MonoidTransformer.exponent mcbrideMonoidTransformer) = {!!} Monoid._≈_ (MonoidTransformer.exponent mcbrideMonoidTransformer) = {!!} Monoid._∙_ (MonoidTransformer.exponent mcbrideMonoidTransformer) = {!!} Monoid.ε (MonoidTransformer.exponent mcbrideMonoidTransformer) = {!!} Monoid.isMonoid (MonoidTransformer.exponent mcbrideMonoidTransformer) = {!!} MonoidTransformer._◃_ mcbrideMonoidTransformer = {!!} MonoidTransformer.isMonoidTransformer mcbrideMonoidTransformer = {!!} record Unificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where field monoidTransformer : MonoidTransformer ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ open module MT = MonoidTransformer monoidTransformer public {- open MonoidTransformer monoidTransformer public renaming (_≈ˢ_ to _=ᵗ_ ;Carrierˢ to T ;Carrierᵐ to S ;_≈ᵐ_ to _=ˢ_) -} Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ) Property {ℓ} = E.Carrier → Set ℓ Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ) Nothing P = ∀ s → P s → ⊥ IsUnifier : (t₁ t₂ : B.Carrier) → Property IsUnifier t₁ t₂ s = s ◃ t₁ B.≈ s ◃ t₂ field unify : (t₁ t₂ : B.Carrier) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (IsUnifier t₁ t₂) record MostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where --infix 4 _≠ᵗ_ field unificationoid : Unificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ open Unificationoid unificationoid public _≤_ : (s₋ : E.Carrier) (s₊ : E.Carrier) → Set (ℓˢ ⊔ ℓ⁼ˢ) _≤_ s₋ s₊ = ∃ λ s → s E.∙ s₊ E.≈ s₋ _≠ᵗ_ : B.Carrier → B.Carrier → Set ℓ⁼ᵗ _≠ᵗ_ t₁ t₂ = t₁ B.≈ t₂ → ⊥ {- _<_ : (s₋ : E.Carrier) (s₊ : E.Carrier) → Set (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ) _<_ s₋ s₊ = s₋ ≤ s₊ × (∀ t → (s₊ ◃ t) ≠ᵗ t → (s₋ ◃ t) ≠ᵗ t) × ∃ λ t → (s₋ ◃ t) ≠ᵗ t × (s₊ ◃ t) B.≈ t --the set of T that are changed by a applying substitution is strictly less with s₊ than with s₋. That is, s₋ makes more changes than s₊. --that is, if s₊ makes a change to t then so does s₋, but there is some t s.t. s₋ makes a change but s₊ does not -} MostGenerally : ∀ {ℓ} (P : Property {ℓ}) → Property MostGenerally P s₊ = P s₊ × ∀ s₋ → P s₋ → s₋ ≤ s₊ field isMguIfUnifier : (t₁ t₂ : B.Carrier) → (ru : ∃ λ s → unify t₁ t₂ ≡ right s) → Prelude.case ru of (λ {((u , _) , _) → MostGenerally (IsUnifier t₁ t₂) u}) mgu : (t₁ t₂ : B.Carrier) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (MostGenerally $ IsUnifier t₁ t₂) mgu t₁ t₂ with unify t₁ t₂ | Prelude.graphAt (unify t₁) t₂ mgu t₁ t₂ | left x | ef = left x mgu t₁ t₂ | right x | Prelude.ingraph eq with isMguIfUnifier t₁ t₂ (x , eq) mgu t₁ t₂ | right (fst₁ , snd₁) | (Prelude.ingraph eq) | dfsd = right (fst₁ , dfsd) record PairMostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where field mostGeneralUnificationoid : MostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ open MostGeneralUnificationoid mostGeneralUnificationoid public field separateExponents : E.Carrier → E.Carrier × E.Carrier IsPairUnifier : (t₁ t₂ : B.Carrier) → Property IsPairUnifier t₁ t₂ u = let (s₁ , s₂) = separateExponents u in s₁ ◃ t₁ B.≈ s₂ ◃ t₂ field pair-mgu : (t₁ t₂ : B.Carrier) → Nothing (IsPairUnifier t₁ t₂) ⊎ ∃ (MostGenerally (IsPairUnifier t₁ t₂)) record MakePairFromRegular ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where field mostGeneralUnificationoid : MostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ open MostGeneralUnificationoid mostGeneralUnificationoid public field left-exponent : E.Carrier → E.Carrier right-exponent : E.Carrier → E.Carrier left-base : B.Carrier → B.Carrier right-base : B.Carrier → B.Carrier exponent-to-base : ∀ {s t₁ t₂} → left-exponent s ◃ t₁ B.≈ right-exponent s ◃ t₂ → s ◃ left-base t₁ B.≈ s ◃ right-base t₂ base-to-exponent : ∀ {s t₁ t₂} → s ◃ left-base t₁ B.≈ s ◃ right-base t₂ → left-exponent s ◃ t₁ B.≈ right-exponent s ◃ t₂ pairMostGeneralUnificationoid : PairMostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ PairMostGeneralUnificationoid.mostGeneralUnificationoid pairMostGeneralUnificationoid = mostGeneralUnificationoid PairMostGeneralUnificationoid.separateExponents pairMostGeneralUnificationoid x = left-exponent x , right-exponent x PairMostGeneralUnificationoid.pair-mgu pairMostGeneralUnificationoid t₁ t₂ with mgu (left-base t₁) (right-base t₂) PairMostGeneralUnificationoid.pair-mgu pairMostGeneralUnificationoid t₁ t₂ | left notunifier = left (λ s x → notunifier s (exponent-to-base x)) PairMostGeneralUnificationoid.pair-mgu pairMostGeneralUnificationoid t₁ t₂ | right (s , x-base , unified-correct) = right (s , base-to-exponent x-base , (λ s₋ x-exponent → unified-correct s₋ (exponent-to-base x-exponent))) --(s , base-to-exponent x , (λ s₋ x₁ → s₋ , {!snd (snd₁ s x)!})) -- -- open import Algebra -- -- record PairUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where -- -- field -- -- monoidTransformer : MonoidTransformer ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ -- -- open module MT = MonoidTransformer monoidTransformer public -- renaming (module E to Exponent) -- -- {- -- -- open MonoidTransformer monoidTransformer public renaming -- -- (_≈ˢ_ to _=ᵗ_ -- -- ;Carrierˢ to T -- -- ;Carrierᵐ to S -- -- ;_≈ᵐ_ to _=ˢ_) -- -- -} -- -- Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ) -- -- Property {ℓ} = E.Carrier × E.Carrier → Set ℓ -- -- Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ) -- -- Nothing P = ∀ u → P u → ⊥ -- -- IsUnifier : ∀ t₁ t₂ → Property -- -- IsUnifier t₁ t₂ u = let (s₁ , s₂) = u in s₁ ◃ t₁ B.≈ s₂ ◃ t₂ -- -- field -- -- unify : ∀ t₁ t₂ -- -- → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (IsUnifier t₁ t₂) -- -- module MakePairUnificationoidFromUnificationoid where -- -- postulate -- -- ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Level -- -- unificationoid : Unificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ -- -- open Unificationoid unificationoid -- -- pairUnificationoid : PairUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ -- -- PairUnificationoid.monoidTransformer pairUnificationoid = monoidTransformer -- -- PairUnificationoid.unify pairUnificationoid t₁ t₂ with unify t₁ t₂ -- -- PairUnificationoid.unify pairUnificationoid t₁ t₂ | left x = left (λ {(s₁ , s₂) x₁ → x {!!} {!x₁!}}) -- -- PairUnificationoid.unify pairUnificationoid t₁ t₂ | right (s₁ , snd₁) = {!!} -- -- {- -- -- s ◃ swap ◃ t₁ = s ◃ t₂ -- -- swap ∙ swap = ε -- -- want: x , y s.t. x ◃ t₁ = x ◃ t₂ -- -- easy: x = s ∙ swap, y = s -- -- harder: -- -- s₁ ◃ t₁ = s₂ ◃ t₂ -- -- want: x s.t. x ◃ t₁ = x ◃ t₂ -- -- -} -- -- -- record Isomorphic {a} {A : Set a} {ℓᵃ} {_=ᵃ_ : A → A → Set ℓᵃ} (isEquivalenceᵃ : IsEquivalence _=ᵃ_) {b} {B : Set b} {ℓᵇ} {_=ᵇ_ : B → B → Set ℓᵇ} (isEquivalenceᵇ : IsEquivalence _=ᵇ_) : Set (a ⊔ ℓᵃ ⊔ b ⊔ ℓᵇ) where -- -- -- field -- -- -- toA : B → A -- -- -- toB : A → B -- -- -- rtA : (x : A) → toA (toB x) =ᵃ x -- -- -- rtB : (x : B) → toB (toA x) =ᵇ x -- -- -- isoA : (x₁ x₂ : A) → x₁ =ᵃ x₂ → toB x₁ =ᵇ toB x₂ -- -- -- isoB : (x₁ x₂ : B) → x₁ =ᵇ x₂ → toA x₁ =ᵃ toA x₂ -- -- -- record Splittable ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where -- -- -- field -- -- -- mostGeneralUnificationoid : MostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ -- -- -- open MostGeneralUnificationoid mostGeneralUnificationoid public -- -- -- S-independent : (t₁ t₂ : T) → Set (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ) -- -- -- S-independent t₁ t₂ = ∀ t₁s s → s ◃ t₁ =ᵗ t₁s → MostGenerally (λ s → s ◃ t₁ =ᵗ t₁s) s → s ◃ t₂ =ᵗ t₂ -- -- -- S-Invertable : Property -- -- -- S-Invertable s = s ∙ s =ˢ ε -- -- -- Swapifies : (t₁ t₂ : T) → Property -- -- -- Swapifies t₁ t₂ s = s ◃ t₁ =ᵗ t₂ × s ◃ t₂ =ᵗ t₁ -- -- -- UnifiesOnLeft : (t₁ t₂ : T) → Property -- -- -- UnifiesOnLeft t₁ t₂ s = s ◃ t₁ =ᵗ t₂ -- -- -- RelativeIdentity : T → Property -- -- -- RelativeIdentity t s = s ◃ t =ᵗ t -- -- -- field -- -- -- make-S-independent : -- -- -- (t₁ t₂ : T) → -- -- -- ∃ λ swap₁ → S-Invertable swap₁ × -- -- -- ∃ λ t₁′ → MostGenerally (Swapifies t₁ t₁′) swap₁ × -- -- -- ∃ λ s₁ → MostGenerally (UnifiesOnLeft t₁ t₁′) s₁ × -- -- -- RelativeIdentity t₂ s₁ -- -- -- Tᵢ : Prelude.List Prelude.Nat → Set -- -- -- toTᵢ : T → ∃ Tᵢ -- -- -- pairUnification : PairMostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ -- -- -- PairMostGeneralUnificationoid.monoidTransformer pairUnification = monoidTransformer -- -- -- PairMostGeneralUnificationoid.mgu pairUnification t₁ t₂ with make-S-independent t₁ t₂ -- -- -- PairMostGeneralUnificationoid.mgu pairUnification t₁ t₂ | (swap₁ , swap₁∙swap₁=ε , t₁′ , ((swap₁◃t₁=t₁′ , swap₁◃t₁′=t₁) , mgswap) , slip₁ , (slip₁◃t₁=t₁′ , mgleft) , slip₁◃t₂=t₂) with mgu t₁′ t₂ -- -- -- -- … | (left NoT₁T₂) = -- -- -- PairMostGeneralUnificationoid.mgu pairUnification t₁ t₂ | (swap₁ , swap₁∙swap₁=ε , t₁′ , ((swap₁◃t₁=t₁′ , swap₁◃t₁′=t₁) , mgswap) , slip₁ , (slip₁◃t₁=t₁′ , mgleft) , slip₁◃t₂=t₂) | (left NoT₁T₂) = -- -- -- left -- -- -- λ {(s₁ , s₂) s₁◃t₁=s₂◃t₂ → -- -- -- {!let (s₁′ , s₂′ , s₁′◃t₁=s₂′◃t₂ , s₁′∙swap₁◃t₂=swap₁◃t₂ , s₂′∙swap₁∙s₂′◃t₂=swap₁∙s₂′◃t₂) = helper!}} -- -- -- {- -- -- -- NoT₁T₂ (slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ∙ swap₁) -- -- -- (let t₁′▹s₂=t₁′ : {!!} -- s₂ ◃ t₁′ =ᵗ t₁′ -- -- -- t₁′▹s₂=t₁′ = {!!} in {!!})} -- -- -- -} -- -- -- -- ? s₂ (s₁ ◃ t₁) (symˢ t₁▹s₁=t₂▹s₂ , (λ s₁₋ t₂▹s₁₋=t₁▹s₁ → {!!} , {!!})) in {!!})}) -- mgur s₂ (t₁ ▹ s₁) (symˢ t₁▹s₁=t₂▹s₂ , ?) -- -- -- PairMostGeneralUnificationoid.mgu pairUnification t₁ t₂ | (swap₁ , swap₁∙swap₁=ε , t₁′ , ((swap₁◃t₁=t₁′ , swap₁◃t₁′=t₁) , mgswap) , slip₁ , (slip₁◃t₁=t₁′ , mgleft) , slip₁◃t₂=t₂) | (right (s , s◃t₁′=s◃t₂ , mgur)) = right $ (s ∙ slip₁ , s) , {!!} , (λ {(s₁′ , s₂′) s₁′◃t₁=s₂′◃t₂ → {!!}}) -- -- -- {- -- -- -- goal -- -- -- slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ∙ swap₁ ◃ t₁′ =ᵗ slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ∙ swap₁ ◃ t₂ -- -- -- by slip₁◃t₁=t₁′ -- -- -- slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ∙ swap₁ ∙ slip₁ ◃ t₁ =ᵗ slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ∙ swap₁ ◃ t₂ -- -- -- conjecture: swap₁ ∙ slip₁ ◃ t₁ = t₁ -- -- -- conjecture: s₁ ∙ swap₁ ◃ t₂ = swap₁ ◃ t₂ -- -- -- slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ◃ t₁ =ᵗ slip₁ ∙ s₂ ∙ swap₁ ∙ swap₁ ◃ t₂ -- -- -- by swap₁∙swap₁=ε -- -- -- slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ◃ t₁ =ᵗ slip₁ ∙ s₂ ◃ t₂ -- -- -- by s₁◃t₁=s₂◃t₂ -- -- -- slip₁ ∙ s₂ ∙ swap₁ ∙ s₂ ◃ t₂ =ᵗ slip₁ ∙ s₂ ◃ t₂ -- -- -- conjecture: s₂ ∙ swap₁ ∙ s₂ ◃ t₂ = swap₁ ∙ s₂ ◃ t₂ -- -- -- slip₁ ∙ swap₁ ∙ s₂ ◃ t₂ =ᵗ slip₁ ∙ s₂ ◃ t₂ -- -- -- conjecture: swap₁ ∙ s₂ ◃ t₂ = slip₁ ∙ s₂ ◃ t₂ -- -- -- slip₁ ∙ slip₁ ∙ s₂ ◃ t₂ =ᵗ slip₁ ∙ s₂ ◃ t₂ -- -- -- conjecture: slip₁ ∙ slip₁ = slip₁ -- -- -- slip₁ ∙ s₂ ◃ t₂ =ᵗ slip₁ ∙ s₂ ◃ t₂ -- -- -- goal : ?0 ◃ t₁′ = ?0 ◃ t₂ -- -- -- e.g. -- -- -- f(x,g(y),z) = f(g(y),x,h(z)) -- -- -- s₁ = x → g(y) , z → h(z) ; s₂ = x → g(y) -- -- -- s = x → a ; y → b ; z → c -- -- -- t₁′ = f(a,g(b),c) -- -- -- S = a → g(y) , x → g(b) , c → h(z) -- -- -- s⁻¹ = a → x , b → y , c → z -- -- -- s₁ ∙ s⁻¹ = a → g(y) , b → y , c → h(z) -- -- -- s₂ ∙ s₁ ∙ s⁻¹ = a → g(y) , b → y , c → h(z) , x → g(y) -- -- -- S = s ∙ s₂ ∙ s₁ ∙ s⁻¹ = a → g(b) , b → b , c → h(c) , x → g(b) , y → b , z → c -- -- -- t₁′ ▹ S = f(g(b),g(b),h(c)) -- -- -- t₂ ▹ S = f(g(b),g(b),h(c)) -- -- -- f(x,g(y),z) = f(g(y),x,h(z)) -- -- -- s₁ = x → g(x) , y → x , z → h(z) ; s₂ = y → x , x → g(x) -- -- -- s = x → a ; y → b ; z → c -- -- -- t₁′ = f(a,g(b),c) -- -- -- s⁻¹ = a → x , b → y , c → z -- -- -- s₁ ∙ s⁻¹ = a → g(x) , b → x , c → h(z) , x → g(x) , y → x , z → h(z) -- -- -- s₂ ∙ s₁ ∙ s⁻¹ = a → g(g(x)) , b → g(x) , c → h(z) , x → g(g(x)) , y → g(x) , z → h(z) -- -- -- s ∙ s₂ ∙ s₁ ∙ s⁻¹ = a → g(g(a)) , b → g(a) , c → h(c) , x → g(g(a)) , y → g(a) , z → h(c) -- -- -- s⁻¹ = a → x , b → y , c → z -- -- -- s₁ ∙ s⁻¹ = a → g(x) , b → x , c → h(z) , x → g(x) , y → x , z → h(z) -- -- -- s ∙ s₁ ∙ s⁻¹ = a → g(a) , b → a , c → h(c) , x → g(a) , y → a , z → h(c) -- -- -- s₁′ = a → g(a) , b → a , c → h(c) -- -- -- s₂′ = y → a , x → g(a) , z → c -- -- -- let swap₁ = x → a , y → b , z → c , a → x , b → y , c → z -- take variables common to t₁ and t₂, and swap them for variables outside of either (and outside of s₁ or s₂?) -- -- -- s₁ ∙ swap₁ = x → a , y → b , z → c , a → g(x) , b → x , c → h(z) -- -- -- s₁′ = swap₁ ∙ s₁ ∙ swap₁ = a → g(a) , b → a , c → h(c) -- -- -- s₁′ = swap₁ ∙ s₁ ∙ swap₁ -- -- -- let slip₁ = x → a , y → b , z → c -- -- -- let s₂′ = slip₁ ∙ s₂ = y → a , x → g(a) , z → c -- -- -- s₂′ ∙ s₁′ = a → g(a) , b → a , c → h(c) , y → a , x → g(a) , z → c -- -- -- slip₁ ∙ s₂ ∙ swap₁ ∙ s₁ ∙ swap₁ -- -- -- f(g(g(a)),g(g(a)),h(c)) = f(g(g(a)),g(g(a)),h(h(c))) -- -- -- f(x,g(y),z) = f(g(y),x,h(z)) -- -- -- -} -- -- -- {- -- -- -- … | (t₁' , s-independent , s , t₁'= , s⁻¹ , t₁=) with mgu t₁' t₂ -- -- -- … | (left NoT₁T₂) = left $ λ {(s₁ , s₂) t₁▹s₁=t₂▹s₂ → NoT₁T₂ {!≈ˢ-over-▹-⟶-≈ᵐ!} {!isMonoidTransformer!}} -- -- -- … | (right x) = right {!!} -- -- -- -} -- -- -- {- -- -- -- suppose t₁ ▹ s₁ = t₂ ▹ s₂ -- -- -- given: -- -- -- t₁' ▹ * ≠ t₂ ▹ * -- -- -- t₁ = t₁' ▹ s -- -- -- try s = the most general such -- -- -- t₁ = t₁' ▹ s⁻¹ -- -- -- t₁' = t₁ ▹ s -- -- -- t₁ ▹ s₁ = t₂ ▹ s₂ -- -- -- s ∙ s⁻¹ = ε -- -- -- t₁' ▹ s⁻¹ ▹ s₁ = t₂ ▹ s₂ -- -- -- finx x = s₁ -- -- -- t₁ ▹ x = t₂ ▹ s⁻¹ ▹ x -- -- -- t₁' ▹ x = t₂ ▹ x -- -- -- t₁ ▹ s ▹ x = t₂ ▹ x -- -- -- t₁ ▹ s ▹ x = t₂ ▹ s⁻¹ ▹ s ▹ x -- -- -- -} -- -- -- data STerm (A : Set) : Set where -- -- -- ι : A → STerm A -- -- -- _fork_ : STerm A → STerm A → STerm A -- -- -- leaf : STerm A -- -- -- sub : {V : Set} → (V → Maybe (STerm V)) → STerm V → STerm V -- -- -- sub σ (ι x) with σ x -- -- -- sub σ (ι x) | nothing = ι x -- -- -- sub σ (ι x) | just x₁ = x₁ -- -- -- sub σ (t fork t₁) = sub σ t fork sub σ t₁ -- -- -- sub σ leaf = leaf -- -- -- {- -- -- -- Sᵢ : List (V × T) → S -- -- -- Tᵢ : List V → T -- -- -- indexS : S → ∃ Sᵢ -- -- -- indexT : T → ∃ Tᵢ -- -- -- _▹ᵢ_ : {vs : List V} {vts : List (V × T)} → Tᵢ vs → Sᵢ vts → ∃ λ -- -- -- (t : T) (s : S) → t ▹ s -- -- -- (V → T) → T → T -- -- -- getTermIndexedByAVariable : (v : V) (t : T) → T → T -- -- -- getTermFromIndexedTerm : -- -- -- v ∈ variables s → t ▹ s -- -- -- -} -- -- -- record IsSeparableInto {sx s x} (SX : Set sx) (S : Set s) (X : Set x) : Set (s ⊔ x ⊔ sx) where -- -- -- field -- -- -- separate : SX → S × X -- -- -- combine : S × X → SX -- -- -- iso : ∀ sx → combine (separate sx) ≡ sx -- -- -- record IsSeparableInto₂ {sx s x} (SX : Set sx) (X : Set x) (S : X → Set s) : Set (s ⊔ x ⊔ sx) where -- -- -- field -- -- -- separate : SX → Σ X S -- -- -- combine : Σ X S → SX -- -- -- iso : ∀ sx → combine (separate sx) ≡ sx -- -- -- record Separableoid sx s x : Set (lsuc (sx ⊔ s ⊔ x)) where -- -- -- field -- -- -- SX : Set sx -- -- -- S : Set s -- -- -- X : Set x -- -- -- separable : IsSeparableInto SX S X -- -- -- -- record FreeVariableoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ℓᵛ ℓ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where -- -- -- -- field -- -- -- -- monoidTransformer : MonoidTransformer ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ -- -- -- -- open MonoidTransformer monoidTransformer public renaming -- -- -- -- (_≈ˢ_ to _=ᵗ_ -- -- -- -- ;Carrierˢ to T -- -- -- -- ;Carrierᵐ to S -- -- -- -- ;_≈ᵐ_ to _=ˢ_) -- -- -- -- field -- -- -- -- termVariableoid : Setoid ℓᵛ ℓ⁼ᵛ -- -- -- -- termStructureoid : -- -- -- -- open Setoid Variable public using () renaming -- -- -- -- (Carrier to V -- -- -- -- ;_≈_ to _=ᵛ_) -- -- -- -- field -- -- -- -- termVariables : Term → Pred Variable ℓᵛ
{ "alphanum_fraction": 0.5218143838, "avg_line_length": 41.2684729064, "ext": "agda", "hexsha": "910136dd0223b4b1a556b4c95ed340b4505ec67f", "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/MGU-revised.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/MGU-revised.agda", "max_line_length": 297, "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/MGU-revised.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7564, "size": 16755 }
open import Prelude open import Nat open import core open import contexts open import weakening open import exchange open import lemmas-disjointness open import binders-disjoint-checks module lemmas-subst-ta where -- this is what makes the binders-unique assumption below good enough: it -- tells us that we can pick fresh variables mutual binders-envfresh : ∀{Δ Γ Γ' y σ} → Δ , Γ ⊢ σ :s: Γ' → y # Γ → unbound-in-σ y σ → binders-unique-σ σ → envfresh y σ binders-envfresh {Γ' = Γ'} {y = y} (STAId x) apt unbound unique with ctxindirect Γ' y binders-envfresh {Γ' = Γ'} {y = y} (STAId x₁) apt unbound unique | Inl x = abort (somenotnone (! (x₁ y (π1 x) (π2 x)) · apt)) binders-envfresh (STAId x₁) apt unbound unique | Inr x = EFId x binders-envfresh {Γ = Γ} {y = y} (STASubst {y = z} subst x₁) apt (UBσSubst x₂ unbound neq) (BUσSubst zz x₃ x₄) = EFSubst (binders-fresh {y = y} x₁ zz x₂ apt) (binders-envfresh subst (apart-extend1 Γ neq apt) unbound x₃) neq binders-fresh : ∀{ Δ Γ d2 τ y} → Δ , Γ ⊢ d2 :: τ → binders-unique d2 → unbound-in y d2 → Γ y == None → fresh y d2 binders-fresh TAConst BUHole UBConst apt = FConst binders-fresh {y = y} (TAVar {x = x} x₁) BUVar UBVar apt with natEQ y x binders-fresh (TAVar x₂) BUVar UBVar apt | Inl refl = abort (somenotnone (! x₂ · apt)) binders-fresh (TAVar x₂) BUVar UBVar apt | Inr x₁ = FVar x₁ binders-fresh {y = y} (TALam {x = x} x₁ wt) bu2 ub apt with natEQ y x binders-fresh (TALam x₂ wt) bu2 (UBLam2 x₁ ub) apt | Inl refl = abort (x₁ refl) binders-fresh {Γ = Γ} (TALam {x = x} x₂ wt) (BULam bu2 x₃) (UBLam2 x₄ ub) apt | Inr x₁ = FLam x₁ (binders-fresh wt bu2 ub (apart-extend1 Γ x₄ apt)) binders-fresh (TAAp wt wt₁) (BUAp bu2 bu3 x) (UBAp ub ub₁) apt = FAp (binders-fresh wt bu2 ub apt) (binders-fresh wt₁ bu3 ub₁ apt) binders-fresh (TAEHole x₁ x₂) (BUEHole x) (UBHole x₃) apt = FHole (binders-envfresh x₂ apt x₃ x ) binders-fresh (TANEHole x₁ wt x₂) (BUNEHole bu2 x) (UBNEHole x₃ ub) apt = FNEHole (binders-envfresh x₂ apt x₃ x) (binders-fresh wt bu2 ub apt) binders-fresh (TACast wt x₁) (BUCast bu2) (UBCast ub) apt = FCast (binders-fresh wt bu2 ub apt) binders-fresh (TAFailedCast wt x x₁ x₂) (BUFailedCast bu2) (UBFailedCast ub) apt = FFailedCast (binders-fresh wt bu2 ub apt) -- the substition lemma for preservation lem-subst : ∀{Δ Γ x τ1 d1 τ d2 } → x # Γ → binders-disjoint d1 d2 → binders-unique d2 → Δ , Γ ,, (x , τ1) ⊢ d1 :: τ → Δ , Γ ⊢ d2 :: τ1 → Δ , Γ ⊢ [ d2 / x ] d1 :: τ lem-subst apt bd bu2 TAConst wt2 = TAConst lem-subst {x = x} apt bd bu2 (TAVar {x = x'} x₂) wt2 with natEQ x' x lem-subst {Γ = Γ} apt bd bu2 (TAVar x₃) wt2 | Inl refl with lem-apart-union-eq {Γ = Γ} apt x₃ lem-subst apt bd bu2 (TAVar x₃) wt2 | Inl refl | refl = wt2 lem-subst {Γ = Γ} apt bd bu2 (TAVar x₃) wt2 | Inr x₂ = TAVar (lem-neq-union-eq {Γ = Γ} x₂ x₃) lem-subst {Δ = Δ} {Γ = Γ} {x = x} {d2 = d2} x#Γ (BDLam bd bd') bu2 (TALam {x = y} {τ1 = τ1} {d = d} {τ2 = τ2} x₂ wt1) wt2 with lem-union-none {Γ = Γ} x₂ ... | x≠y , y#Γ with natEQ y x ... | Inl eq = abort (x≠y (! eq)) ... | Inr _ = TALam y#Γ (lem-subst {Δ = Δ} {Γ = Γ ,, (y , τ1)} {x = x} {d1 = d} (apart-extend1 Γ x≠y x#Γ) bd bu2 (exchange-ta-Γ {Γ = Γ} x≠y wt1) (weaken-ta (binders-fresh wt2 bu2 bd' y#Γ) wt2)) lem-subst apt (BDAp bd bd₁) bu3 (TAAp wt1 wt2) wt3 = TAAp (lem-subst apt bd bu3 wt1 wt3) (lem-subst apt bd₁ bu3 wt2 wt3) lem-subst apt bd bu2 (TAEHole inΔ sub) wt2 = TAEHole inΔ (STASubst sub wt2) lem-subst apt (BDNEHole x₁ bd) bu2 (TANEHole x₃ wt1 x₄) wt2 = TANEHole x₃ (lem-subst apt bd bu2 wt1 wt2) (STASubst x₄ wt2) lem-subst apt (BDCast bd) bu2 (TACast wt1 x₁) wt2 = TACast (lem-subst apt bd bu2 wt1 wt2) x₁ lem-subst apt (BDFailedCast bd) bu2 (TAFailedCast wt1 x₁ x₂ x₃) wt2 = TAFailedCast (lem-subst apt bd bu2 wt1 wt2) x₁ x₂ x₃
{ "alphanum_fraction": 0.5623312331, "avg_line_length": 68.3692307692, "ext": "agda", "hexsha": "c4753d7ac204b2d7920f39e299550d336cea2eed", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_path": "lemmas-subst-ta.agda", "max_issues_count": 54, "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_path": "lemmas-subst-ta.agda", "max_line_length": 153, "max_stars_count": 16, "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_path": "lemmas-subst-ta.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "num_tokens": 1711, "size": 4444 }
open import OutsideIn.Prelude open import OutsideIn.X module OutsideIn(x : X) where open X (x) public open import OutsideIn.Prelude public open import Data.Vec public hiding ([_]) import OutsideIn.Constraints as C import OutsideIn.TypeSchema as TS import OutsideIn.Expressions as E import OutsideIn.Environments as V import OutsideIn.TopLevel as TL import OutsideIn.Inference as I open E (x) public open TL(x) public open TS(x) public open I (x) public open V (x) public open C (x)
{ "alphanum_fraction": 0.7426900585, "avg_line_length": 27, "ext": "agda", "hexsha": "2a66259659304bf675bc9388b1277cbbdb85194c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "liamoc/outside-in", "max_forks_repo_path": "OutsideIn.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "liamoc/outside-in", "max_issues_repo_path": "OutsideIn.agda", "max_line_length": 43, "max_stars_count": 2, "max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "liamoc/outside-in", "max_stars_repo_path": "OutsideIn.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z", "num_tokens": 148, "size": 513 }
{-# OPTIONS --cubical --postfix-projections --safe #-} module Karatsuba where open import Prelude open import Data.List open import Data.List.Syntax open import TreeFold open import Data.Integer import Data.Nat as ℕ open import Literals.Number open import Data.Integer.Literals Diff : Type a → Type a Diff A = List A → List A ⌈⌉ : Diff A ⌈⌉ = id ⌈_⌉ : A → Diff A ⌈_⌉ = _∷_ ⌊_⌋ : Diff A → List A ⌊ xs ⌋ = xs [] record K (A : Type a) : Type a where constructor k field sh lo hi : Diff A out : List A open K infixl 6 _⊕_ _⊝_ _⊕_ : List ℤ → List ℤ → List ℤ [] ⊕ ys = ys xs ⊕ [] = xs (x ∷ xs) ⊕ (y ∷ ys) = (x + y) ∷ (xs ⊕ ys) _⍟_ : List ℤ → List ℤ → List (K ℤ) [] ⍟ ys = map (λ y → k ⌈ 0 ⌉ ⌈⌉ ⌈ y ⌉ []) ys xs ⍟ [] = map (λ x → k ⌈ 0 ⌉ ⌈ x ⌉ ⌈⌉ []) xs (x ∷ xs) ⍟ (y ∷ ys) = k ⌈ 0 ⌉ ⌈ x ⌉ ⌈ y ⌉ [ x * y ] ∷ xs ⍟ ys _⊝_ : List ℤ → List ℤ → List ℤ xs ⊝ ys = xs ⊕ map negate ys -- The first parameter in these functions is just used for termination checking. mutual infixl 7 ⟨_⟩_⊛_ ⟨_⟩_⊛_ : ℕ → List ℤ → List ℤ → List ℤ ⟨ n ⟩ [] ⊛ _ = [] ⟨ n ⟩ _ ⊛ [] = [] ⟨ n ⟩ (x ∷ []) ⊛ ys = map (x *_) ys ⟨ n ⟩ xs ⊛ (y ∷ []) = map (y *_) xs ⟨ n ⟩ xs ⊛ ys = maybe [] out (treeFoldMay ⟨ n ⟩_◆_ (xs ⍟ ys)) ⟨_⟩_◆_ : ℕ → K ℤ → K ℤ → K ℤ (⟨ _ ⟩ xs ◆ ys ) .sh = xs .sh ∘ ys .sh (⟨ _ ⟩ xs ◆ ys ) .lo = xs .lo ∘ ys .lo (⟨ _ ⟩ xs ◆ ys ) .hi = xs .hi ∘ ys .hi (⟨ zero ⟩ _ ◆ _ ) .out = [] -- should not happen (⟨ suc t ⟩ k p x₀ y₀ z₀ ◆ k _ x₁ y₁ z₂) .out = let z₁ = ⟨ t ⟩ (⌊ x₀ ⌋ ⊕ ⌊ x₁ ⌋) ⊛ (⌊ y₀ ⌋ ⊕ ⌊ y₁ ⌋) in p (p z₂ ⊕ z₁ ⊝ (z₀ ⊕ z₂)) ⊕ z₀ _⊛_ : List ℤ → List ℤ → List ℤ xs ⊛ ys = ⟨ length xs ℕ.+ length ys ⟩ xs ⊛ ys _ : [ 2 , 5 ] ⊛ [ 1 , 1 ] ≡ [ 2 , 7 , 5 ] _ = refl
{ "alphanum_fraction": 0.437994723, "avg_line_length": 24.9342105263, "ext": "agda", "hexsha": "b40f22d25ead8c103a190dd21f7a09c52683d459", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Karatsuba.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Karatsuba.agda", "max_line_length": 80, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Karatsuba.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 910, "size": 1895 }
open import Level using (Level; suc; zero; _⊔_) open import Algebra.Structures open import Algebra.FunctionProperties as FunctionProperties using (Op₁; Op₂) open import Relation.Binary -- Definition of an ordered monoid, which adds the law that ∙ must -- preserve the partial order ≤ (or, equivalently, that an ordering x -- ≤ y must allow for the substitution of y for x in a more complex -- ordering) to an existing monoid and partial order. module Algebra.OrderedMonoid where record IsOrderedMonoid {a ℓ₁ ℓ₂} {A : Set a} (≈ : Rel A ℓ₁) (≤ : Rel A ℓ₂) (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isMonoid : IsMonoid ≈ ∙ ε isPartialOrder : IsPartialOrder ≈ ≤ compatibility : ∙ Preserves₂ ≤ ⟶ ≤ ⟶ ≤ open IsMonoid isMonoid public hiding (isEquivalence) open IsPartialOrder isPartialOrder public renaming (refl to ≤-refl; trans to ≤-trans; reflexive to ≤-reflexive) record OrderedMonoid c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infixl 7 _∙_ infix 4 _≈_ infix 4 _≤_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ _≤_ : Rel Carrier ℓ₂ _∙_ : Op₂ Carrier ε : Carrier isOrderedMonoid : IsOrderedMonoid _≈_ _≤_ _∙_ ε open IsOrderedMonoid isOrderedMonoid public substitutivity : ∀ {x y z w} → x ≤ y → z ∙ x ∙ w ≤ z ∙ y ∙ w substitutivity x≤y = compatibility (compatibility ≤-refl x≤y) ≤-refl
{ "alphanum_fraction": 0.6480055983, "avg_line_length": 36.641025641, "ext": "agda", "hexsha": "aacdd6b1e7e0b1e6ca0ae64e74421f76faa97cb3", "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": "2cc4f28f23cc369d2582ad065739cabfa46ce799", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/agda-pregroup", "max_forks_repo_path": "Algebra/OrderedMonoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2cc4f28f23cc369d2582ad065739cabfa46ce799", "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": "wenkokke/agda-pregroup", "max_issues_repo_path": "Algebra/OrderedMonoid.agda", "max_line_length": 120, "max_stars_count": 1, "max_stars_repo_head_hexsha": "2cc4f28f23cc369d2582ad065739cabfa46ce799", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/agda-pregroup", "max_stars_repo_path": "Algebra/OrderedMonoid.agda", "max_stars_repo_stars_event_max_datetime": "2017-03-02T01:23:52.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-02T01:23:52.000Z", "num_tokens": 490, "size": 1429 }
module Tools where import PolyDepPrelude -- import Sigma -- import And open PolyDepPrelude using(Datoid; Bool; true; false; _&&_; Nat; True; Taut; unit) liftAnd : (a : Bool)(b : Bool)(ta : True a)(tb : True b) -> True (a && b) liftAnd (true) (true) ta tb = unit liftAnd (true) (false) ta () -- empty liftAnd (false) _ () _ -- empty {- sigmaCond (D:Datoid) (B:D.Elem -> Set) (C:Set) (ifTrue:(b:D.Elem) -> B b -> B b -> C) (ifFalse:C) (x:Sigma D.Elem B) (y:Sigma D.Elem B) : C = case x of { (si a pa) -> case y of { (si b pb) -> let caseOn (e:Bool)(cast:True e -> B a -> B b) : C = case e of { (false) -> ifFalse; (true) -> ifTrue b (cast tt@_ pa) pb;} in caseOn (D.eq a b) (D.subst B);};} -- trueAnd = \a b -> (LogicBool.spec_and a b).snd trueAnd (a:Bool)(b:Bool)(p:And (True a) (True b)) : True (a && b) = case p of { (Pair a' b') -> case a of { (true) -> case b of { (true) -> tt@_; (false) -> b';}; (false) -> a';};} splitAnd (a:Bool)(b:Bool)(p:True (_&&_ a b)) : Times (True a) (True b) = case a of { (true) -> case b of { (true) -> struct { fst = tt@_; snd = tt@_;}; (false) -> case p of { };}; (false) -> case p of { };} trueSigma (D:Set)(f:D -> Bool)(s:Sigma D (\(d:D) -> True (f d))) : True (f (si1 D (\(d:D) -> True (f d)) s)) = case s of { (si a b) -> b;} Maybe (A:Set) : Set = data Nothing | Just (a:A) mapMaybe (|A,|B:Set)(f:A -> B)(x:Maybe A) : Maybe B = case x of { (Nothing) -> Nothing@_; (Just a) -> Just@_ (f a);} maybe (|A,|B:Set)(e:B)(f:A -> B) : Maybe A -> B = \x -> case x of { (Nothing) -> e; (Just a) -> f a;} open SET use List, Absurd, Unit, Either, mapEither, Times, mapTimes, id, uncur, elimEither elimList (|A:Set) (C:List A -> Type) (n:C nil@_) (c:(a:A) -> (as:List A) -> C as -> C (con@_ a as)) (as:List A) : C as = case as of { (nil) -> n; (con x xs) -> c x xs (elimList C n c xs);} -- Common generalization of sum and product of a list of sets -- (represented as a decoding function f and a list of codes) O (A:Set)(E:Set)(Op:Set -> Set -> Set)(f:A -> Set) : List A -> Set = elimList (\as -> Set) E (\a -> \as -> Op (f a)) -- The corresponding map function! (Takes a nullary and a binary -- functor as arguments.) mapO (|A,|E:Set) (|Op:Set -> Set -> Set) (mapE:E -> E) (mapOp:(A1,B1,A2,B2:Set) |-> (f1:A1 -> B1) -> (f2:A2 -> B2) -> Op A1 A2 -> Op B1 B2) (X:A -> Set) (Y:A -> Set) (f:(a:A) -> X a -> Y a) : (as:List A) -> O A E Op X as -> O A E Op Y as = elimList (\(as:List A) -> O A E Op X as -> O A E Op Y as) mapE (\a -> \as -> mapOp (f a)) mapAbsurd : Absurd -> Absurd = id eqAbsurd : Absurd -> Absurd -> Bool = \h -> \h' -> case h of { } -- the name of OPlus and OTimes indicate the symbols they should be -- shown as in algebra: a big ring (a big "O") with the operator + -- or x in -- Disjoint sum over a list of codes OPlus (A:Set) : (A -> Set) -> List A -> Set = O A Absurd Either -- corresponding map function mapOPlus (|A:Set)(X:A -> Set)(Y:A -> Set)(f:(a:A) -> X a -> Y a) : (as:List A) -> OPlus A X as -> OPlus A Y as = mapO id mapEither X Y f -- Cartesian product over a list of codes OTimes (A:Set) : (A -> Set) -> List A -> Set = O A Unit Times -- corresponding map mapOTimes (|A:Set)(X:A -> Set)(Y:A -> Set)(f:(a:A) -> X a -> Y a) : (as:List A) -> OTimes A X as -> OTimes A Y as = mapO id mapTimes X Y f sizeOPlus (|A:Set) (f:A -> Set) (n:(a:A) -> f a -> Nat) (as:List A) (t:OPlus A f as) : Nat = case as of { (nil) -> case t of { }; (con a as) -> case t of { (inl x) -> n a x; (inr y) -> sizeOPlus f n as y;};} triv (x:Absurd) : Set = case x of { } trivT (x:Absurd) : Type = case x of { } sizeOTimes (|A:Set) (f:A -> Set) (z:Nat) (n:(a:A) -> f a -> Nat) (as:List A) (t:OTimes A f as) : Nat = case as of { (nil) -> case t of { (tt) -> z;}; (con a as) -> uncur (+) (mapTimes (n a) (sizeOTimes f z n as) t);} eqUnit (x:Unit)(y:Unit) : Bool = true@_ eqTimes (|A1,|A2,|B1,|B2:Set) (eq1:A1 -> B1 -> Bool) (eq2:A2 -> B2 -> Bool) : Times A1 A2 -> Times B1 B2 -> Bool = \x -> \y -> _&&_ (eq1 x.fst y.fst) (eq2 x.snd y.snd) EqFam (A:Set)(f:A -> Set)(g:A -> Set) : Set = (a:A) -> f a -> g a -> Bool eqOTimes (A:Set)(f:A -> Set)(g:A -> Set)(eq:EqFam A f g) : EqFam (List A) (OTimes A f) (OTimes A g) = elimList (\as -> (OTimes A f as -> OTimes A g as -> Bool)) eqUnit (\a -> \as -> eqTimes (eq a)) eqEither (|A1,|A2,|B1,|B2:Set) (eq1:A1 -> B1 -> Bool) (eq2:A2 -> B2 -> Bool) : Either A1 A2 -> Either B1 B2 -> Bool = \x -> \y -> case x of { (inl x') -> case y of { (inl x0) -> eq1 x' x0; (inr y') -> false@_;}; (inr y') -> case y of { (inl x') -> false@_; (inr y0) -> eq2 y' y0;};} eqOPlus (A:Set)(f:A -> Set)(g:A -> Set)(eq:EqFam A f g) : EqFam (List A) (OPlus A f) (OPlus A g) = elimList (\(as:List A) -> OPlus A f as -> OPlus A g as -> Bool) eqAbsurd (\a -> \as -> eqEither (eq a)) Fam (I:Set)(X:I -> Set) : Type = (i:I) -> X i -> Set eitherSet (A:Set)(B:Set)(f:A -> Set)(g:B -> Set)(x:Either A B) : Set = case x of { (inl x') -> f x'; (inr y) -> g y;} famOPlus (A:Set)(G:A -> Set) : Fam A G -> Fam (List A) (OPlus A G) = \(f:Fam A G) -> elimList (\(as:List A) -> OPlus A G as -> Set) triv (\(a:A) -> \(as:List A) -> eitherSet (G a) (OPlus A G as) (f a)) bothSet (A:Set)(B:Set)(f:A -> Set)(g:B -> Set)(x:Times A B) : Set = Times (f x.fst) (g x.snd) famOTimes (A:Set)(G:A -> Set) : Fam A G -> Fam (List A) (OTimes A G) = \(f:Fam A G) -> elimList (\(as:List A) -> OTimes A G as -> Set) (\(u:OTimes A G nil@_) -> Unit) (\(a:A) -> \(as:List A) -> bothSet (G a) (OTimes A G as) (f a)) FAM (I:Set)(X:I -> Set)(Y:(i:I) -> X i -> Set) : Type = (i:I) -> (x:X i) -> Y i x eitherFAM (A:Set) (A2:Set) (G:A -> Set) (G2:A2 -> Set) (H:Fam A G) (H2:Fam A2 G2) (a:A) (a2:A2) (f:(x:G a) -> H a x) (f2:(x2:G2 a2) -> H2 a2 x2) (x:Either (G a) (G2 a2)) : eitherSet (G a) (G2 a2) (H a) (H2 a2) x = case x of { (inl y) -> f y; (inr y2) -> f2 y2;} FAMOPlus (A:Set)(G:A -> Set)(H:Fam A G) : FAM A G H -> FAM (List A) (OPlus A G) (famOPlus A G H) = \(f:FAM A G H) -> elimList (\(as:List A) -> (x:OPlus A G as) -> famOPlus A G H as x) (\(x:OPlus A G nil@_) -> whenZero (famOPlus A G H nil@_ x) x) (\(a:A) -> \(as:List A) -> eitherFAM A (List A) G (OPlus A G) H (famOPlus A G H) a as (f a)) bothFAM (A:Set) (A2:Set) (G:A -> Set) (G2:A2 -> Set) (H:Fam A G) (H2:Fam A2 G2) (a:A) (a2:A2) (f:(x:G a) -> H a x) (f2:(x2:G2 a2) -> H2 a2 x2) (x:Times (G a) (G2 a2)) : bothSet (G a) (G2 a2) (H a) (H2 a2) x = struct { fst = f x.fst; snd = f2 x.snd;} FAMOTimes (A:Set)(G:A -> Set)(H:Fam A G) : FAM A G H -> FAM (List A) (OTimes A G) (famOTimes A G H) = \(f:FAM A G H) -> elimList (\(as:List A) -> (x:OTimes A G as) -> famOTimes A G H as x) (\(x:OTimes A G nil@_) -> x) (\(a:A) -> \(as:List A) -> bothFAM A (List A) G (OTimes A G) H (famOTimes A G H) a as (f a)) -} {- Size (A:Set) : Type = A -> Nat size_OPlus (A:Set) (f:A -> Set) (size_f:(a:A) -> f a -> Nat) (as:List A) : OPlus f as -> Nat = \(x:OPlus f as) -> ? size_OPlus (A:Set) (f:A -> Set) (size_f:(a:A) -> Size (f a)) (as:List A) : Size (OPlus f as) = \(x:OPlus f as) -> -} {- Alfa unfoldgoals off brief on hidetypeannots off wide nd hiding on var "mapMaybe" hide 2 var "sigmaCond" hide 3 var "maybe" hide 2 var "O" hide 1 var "OTimes" hide 1 var "OPlus" hide 1 var "mapOPlus" hide 3 var "id" hide 1 var "mapOTimes" hide 3 var "mapO" hide 3 var "mapOp" hide 4 var "uncur" hide 3 var "mapTimes" hide 4 var "sizeOTimes" hide 2 var "sizeOPlus" hide 2 var "eqTimes" hide 4 var "OTimesEq" hide 3 var "elimList" hide 1 var "eqOTimes" hide 3 var "eqEither" hide 4 var "eqOPlus" hide 3 var "eitherSet" hide 2 var "bothSet" hide 2 var "famOPlus" hide 2 var "famOTimes" hide 2 var "helper4" hide 4 var "eitherFAM" hide 4 var "FAMOTimes" hide 3 var "FAMOPlus" hide 3 #-}
{ "alphanum_fraction": 0.4682170543, "avg_line_length": 30.1, "ext": "agda", "hexsha": "f851daae74007e47915c25b1a5148fbf3367c8d7", "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/AIM5/PolyDep/Tools.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/AIM5/PolyDep/Tools.agda", "max_line_length": 85, "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/AIM5/PolyDep/Tools.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": 3508, "size": 9030 }
{-# OPTIONS --without-K #-} module Leftovers.TraverseTerm where open import Data.List -- We only need the writer monad, but as far as I can tell -- it's not in the Agda stdlib open import Category.Monad.State open import Reflection using (Term ; Meta ; Name ; Arg) import Leftovers.Everywhere open import Relation.Binary.PropositionalEquality open import Data.Product open import Data.Nat open import Data.Maybe open import Data.String LCxt : Set LCxt = List (String × Arg Term) record LeafInfoMaker (A : Set) : Set where field onVar : LCxt → ℕ → Maybe A onMeta : LCxt → Meta → Maybe A onCon : LCxt → Name → Maybe A onDef : LCxt → Name → Maybe A collectFromSubterms : ∀ {A : Set} → LeafInfoMaker A → Term → List A collectFromSubterms {A} f t = proj₂ (stateResult []) where open RawMonadState (StateMonadState (List A)) open import Leftovers.Everywhere (StateMonad (List A)) toAction : ∀ {X : Set} → (LCxt → X → Maybe A) → Action X toAction f cxt x with f (Cxt.context cxt) x ... | nothing = return x ... | just fx = do modify (fx ∷_) return x stateResult : State (List A) Term stateResult = everywhere (record { onVar = toAction (LeafInfoMaker.onVar f) ; onMeta = toAction (LeafInfoMaker.onMeta f) ; onCon = toAction (LeafInfoMaker.onCon f) ; onDef = toAction (LeafInfoMaker.onDef f) }) (λ Γ x → return x) t
{ "alphanum_fraction": 0.6606018195, "avg_line_length": 27.4807692308, "ext": "agda", "hexsha": "03a10492932a1594f61de8f3ed029dae8fdcd9ea", "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": "01b60b405009feaada181af175f019ceb89e42b2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "JoeyEremondi/AgdaLeftovers", "max_forks_repo_path": "src/Leftovers/TraverseTerm.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "01b60b405009feaada181af175f019ceb89e42b2", "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": "JoeyEremondi/AgdaLeftovers", "max_issues_repo_path": "src/Leftovers/TraverseTerm.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "01b60b405009feaada181af175f019ceb89e42b2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "JoeyEremondi/AgdaLeftovers", "max_stars_repo_path": "src/Leftovers/TraverseTerm.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 411, "size": 1429 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category using (Category) open import Categories.Category.Monoidal using (Monoidal) open import Categories.Category.Monoidal.Closed using (Closed) module Categories.Category.Monoidal.Closed.IsClosed.L {o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (Cl : Closed M) where open import Data.Product using (_,_) open import Function using (_$_) renaming (_∘_ to _∙_) open import Function.Equality as Π using (Π) open import Categories.Morphism.Reasoning C using (pull-last; pull-first; pullˡ; pushˡ; center; center⁻¹; pullʳ) open import Categories.Functor using (Functor) open import Categories.Functor.Bifunctor.Properties open Closed Cl open Category C open HomReasoning private module ℱ = Functor α⇒ = associator.from α⇐ = associator.to module ⊗ = Functor ⊗ open Π.Π open adjoint renaming (unit to η; counit to ε; Ladjunct to 𝕃; Ladjunct-comm′ to 𝕃-comm′; Ladjunct-resp-≈ to 𝕃-resp-≈) L : (X Y Z : Obj) → [ Y , Z ]₀ ⇒ [ [ X , Y ]₀ , [ X , Z ]₀ ]₀ L X Y Z = 𝕃 (𝕃 (ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ α⇒)) private [g]₁ : {W Z Z′ : Obj} {g : Z ⇒ Z′} → [ W , Z ]₀ ⇒ [ W , Z′ ]₀ [g]₁ {g = g} = [ id , g ]₁ push-α⇒-right : {X Y Z Z′ : Obj} {g : Z ⇒ Z′} → (ε.η Z′ ∘ (id ⊗₁ ε.η {X} Y) ∘ α⇒) ∘ ([g]₁ ⊗₁ id) ⊗₁ id ≈ (g ∘ ε.η Z) ∘ (id ⊗₁ ε.η Y) ∘ α⇒ push-α⇒-right {X} {Y} {Z} {Z′} {g} = begin (ε.η Z′ ∘ (id ⊗₁ ε.η {X} Y) ∘ α⇒) ∘ ([g]₁ ⊗₁ id) ⊗₁ id ≈⟨ pull-last assoc-commute-from ⟩ ε.η Z′ ∘ (id ⊗₁ ε.η {X} Y) ∘ ([g]₁ ⊗₁ (id ⊗₁ id)) ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ℱ.F-resp-≈ ⊗ (refl , ⊗.identity) ⟩∘⟨refl ⟩ ε.η Z′ ∘ (id ⊗₁ ε.η Y) ∘ [g]₁ ⊗₁ id ∘ α⇒ ≈⟨ refl⟩∘⟨ pullˡ [ ⊗ ]-commute ⟩ ε.η Z′ ∘ ([g]₁ ⊗₁ id ∘ (id ⊗₁ ε.η Y)) ∘ α⇒ ≈⟨ pull-first (ε.commute g) ⟩ (g ∘ ε.η Z) ∘ (id ⊗₁ ε.η Y) ∘ α⇒ ∎ L-g-swap : {X Y Z Z′ : Obj} {g : Z ⇒ Z′} → L X Y Z′ ∘ [ id , g ]₁ ≈ [ [ id , id ]₁ , [ id , g ]₁ ]₁ ∘ L X Y Z L-g-swap {X} {Y} {Z} {Z′} {g} = begin L X Y Z′ ∘ [g]₁ ≈˘⟨ 𝕃-comm′ ⟩ 𝕃 (𝕃 (ε.η Z′ ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ∘ [g]₁ ⊗₁ id) ≈˘⟨ 𝕃-resp-≈ 𝕃-comm′ ⟩ 𝕃 (𝕃 $ (ε.η Z′ ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ∘ ([g]₁ ⊗₁ id) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ push-α⇒-right ⟩ 𝕃 (𝕃 $ (g ∘ ε.η Z) ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ≈⟨ 𝕃-resp-≈ $ pushˡ $ X-resp-≈ assoc ○ ℱ.homomorphism [ X ,-] ⟩ 𝕃 ([ id , g ]₁ ∘ 𝕃 (ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ α⇒)) ≈⟨ pushˡ (ℱ.homomorphism [ XY ,-]) ⟩ [ id , [g]₁ ]₁ ∘ L X Y Z ≈˘⟨ [-,-].F-resp-≈ ([-,-].identity , refl) ⟩∘⟨refl ⟩ [ [ id , id ]₁ , [g]₁ ]₁ ∘ L X Y Z ∎ where XY = [ X , Y ]₀ X-resp-≈ = ℱ.F-resp-≈ [ X ,-] L-f-swap : {X Y Y′ Z : Obj} {f : Y′ ⇒ Y} → L X Y′ Z ∘ [ f , id ]₁ ≈ [ [ id , f ]₁ , [ id , id ]₁ ]₁ ∘ L X Y Z L-f-swap {X} {Y} {Y′} {Z} {f} = begin L X Y′ Z ∘ [fˡ]₁ ≈˘⟨ 𝕃-comm′ ⟩ 𝕃 (𝕃 inner-L ∘ [fˡ]₁ ⊗₁ id) ≈˘⟨ 𝕃-resp-≈ 𝕃-comm′ ⟩ 𝕃 (𝕃 (inner-L ∘ ([fˡ]₁ ⊗₁ id) ⊗₁ id)) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ fˡ⇒fʳ ⟩ 𝕃 (𝕃 $ inner-L ∘ (id ⊗₁ [fʳ]₁) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ ∘-resp-≈ˡ $ ℱ.homomorphism [ X ,-] ⟩ 𝕃 (([ id , inner-L ]₁ ∘ [ id , (id ⊗₁ [fʳ]₁) ⊗₁ id ]₁) ∘ η.η (YZ ⊗₀ XY′)) ≈⟨ 𝕃-resp-≈ $ pullʳ (⟺ (η.commute _)) ○ (⟺ assoc) ⟩ 𝕃 (𝕃 inner-L ∘ id ⊗₁ [fʳ]₁) ≈⟨ ℱ.homomorphism [ XY′ ,-] ⟩∘⟨refl ⟩ ([ id , 𝕃 inner-L ]₁ ∘ [ id , id ⊗₁ [fʳ]₁ ]₁) ∘ η.η YZ ≈⟨ pullʳ (mate.commute₁ [fʳ]₁) ⟩ [ id , 𝕃 inner-L ]₁ ∘ [ [fʳ]₁ , id ]₁ ∘ η.η YZ ≈⟨ pullˡ [ [-,-] ]-commute ○ assoc ○ ∘-resp-≈ˡ ([-,-].F-resp-≈ (refl , ⟺ [-,-].identity)) ⟩ [ [fʳ]₁ , [ id , id ]₁ ]₁ ∘ L X Y Z ∎ where XY′ = [ X , Y′ ]₀ YZ = [ Y , Z ]₀ [fʳ]₁ : ∀ {W} → [ W , Y′ ]₀ ⇒ [ W , Y ]₀ [fʳ]₁ = [ id , f ]₁ [fˡ]₁ : ∀ {W} → [ Y , W ]₀ ⇒ [ Y′ , W ]₀ [fˡ]₁ = [ f , id ]₁ inner-L : ∀ {W} → ([ W , Z ]₀ ⊗₀ [ X , W ]₀) ⊗₀ X ⇒ Z inner-L {W} = ε.η Z ∘ id ⊗₁ ε.η {X} W ∘ α⇒ fˡ⇒fʳ : inner-L {Y′} ∘ ([fˡ]₁ ⊗₁ id) ⊗₁ id ≈ inner-L {Y} ∘ (id ⊗₁ [fʳ]₁) ⊗₁ id fˡ⇒fʳ = begin inner-L ∘ ([fˡ]₁ ⊗₁ id) ⊗₁ id ≈⟨ pull-last assoc-commute-from ⟩ ε.η Z ∘ (id ⊗₁ ε.η Y′) ∘ [fˡ]₁ ⊗₁ id ⊗₁ id ∘ α⇒ ≈⟨ ∘-resp-≈ʳ $ pullˡ (∘-resp-≈ʳ (ℱ.F-resp-≈ ⊗ (refl , ⊗.identity)) ○ [ ⊗ ]-commute) ⟩ ε.η Z ∘ ([fˡ]₁ ⊗₁ id ∘ id ⊗₁ ε.η Y′) ∘ α⇒ ≈⟨ pull-first (mate.commute₂ f) ⟩ (ε.η Z ∘ id ⊗₁ f) ∘ id ⊗₁ ε.η Y′ ∘ α⇒ ≈⟨ center $ ⟺ (ℱ.homomorphism (YZ ⊗-)) ⟩ ε.η Z ∘ id ⊗₁ (f ∘ ε.η Y′) ∘ α⇒ ≈⟨ ∘-resp-≈ʳ $ ∘-resp-≈ˡ $ ℱ.F-resp-≈ (YZ ⊗-) $ ⟺ (ε.commute f) ⟩ ε.η Z ∘ id ⊗₁ (ε.η Y ∘ [fʳ]₁ ⊗₁ id) ∘ α⇒ ≈⟨ ∘-resp-≈ʳ $ ∘-resp-≈ˡ $ ℱ.homomorphism (YZ ⊗-) ⟩ ε.η Z ∘ (id ⊗₁ ε.η Y ∘ id ⊗₁ [fʳ]₁ ⊗₁ id) ∘ α⇒ ≈⟨ (center⁻¹ refl (⟺ assoc-commute-from)) ○ pullˡ assoc ⟩ inner-L ∘ (id ⊗₁ [fʳ]₁) ⊗₁ id ∎
{ "alphanum_fraction": 0.4179873217, "avg_line_length": 53.7021276596, "ext": "agda", "hexsha": "38fc06798144a2be7529dfa347509dcbc1cc5592", "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/Monoidal/Closed/IsClosed/L.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/Monoidal/Closed/IsClosed/L.agda", "max_line_length": 149, "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/Monoidal/Closed/IsClosed/L.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2682, "size": 5048 }
-- Andreas, 2011-10-02 module IrrelevantLambdasDoNotNeedDotsAlways where bla : ((.Set → Set1) → Set1) -> Set1 bla f = f (λ x → Set) -- here, the lambda does not need a dot, like in (λ .x → Set) -- because the dot from the function space can be taken over
{ "alphanum_fraction": 0.6875, "avg_line_length": 32, "ext": "agda", "hexsha": "d4213223ffe6fd359f856f7778f453635f4061c2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/IrrelevantLambdasDoNotNeedDotsAlways.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/IrrelevantLambdasDoNotNeedDotsAlways.agda", "max_line_length": 61, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/IrrelevantLambdasDoNotNeedDotsAlways.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": 84, "size": 256 }
open import Data.Empty using ( ⊥ ) open import Data.Nat using ( ℕ ; zero ; suc ; _+_ ; _≤_ ; z≤n ; s≤s ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; cong ) open import Relation.Binary.PropositionalEquality.TrustMe using ( trustMe ) open import Relation.Nullary using ( ¬_ ) module FRP.LTL.Util where infixr 5 _trans_ _∋_ -- Irrelevant projections postulate .irrelevant : ∀ {A : Set} → .A → A -- Irrelevant ≡ can be promoted to relevant ≡ ≡-relevant : ∀ {A : Set} {a b : A} → .(a ≡ b) → (a ≡ b) ≡-relevant a≡b = trustMe -- A version of ⊥-elim which takes an irrelevant argument ⊥-elim : {A : Set} → .⊥ → A ⊥-elim () -- An infix variant of trans _trans_ : ∀ {X : Set} {x y z : X} → (x ≡ y) → (y ≡ z) → (x ≡ z) refl trans refl = refl -- Help the type inference engine out by being explicit about X. _∋_ : (X : Set) → X → X X ∋ x = x -- Lemmas about addition on ℕ -- These are from Data.Nat.Properties, -- included here to avoid having to load all of Data.Nat.Properties' dependencies. m+1+n≡1+m+n : ∀ m n → m + suc n ≡ suc (m + n) m+1+n≡1+m+n zero n = refl m+1+n≡1+m+n (suc m) n = cong suc (m+1+n≡1+m+n m n) +-comm : ∀ m n → (m + n ≡ n + m) +-comm zero zero = refl +-comm zero (suc n) = cong suc (+-comm zero n) +-comm (suc m) n = (cong suc (+-comm m n)) trans (sym (m+1+n≡1+m+n n m)) +-assoc : ∀ l m n → ((l + m) + n ≡ l + (m + n)) +-assoc zero m n = refl +-assoc (suc l) m n = cong suc (+-assoc l m n) m+n≡0-impl-m≡0 : ∀ m n → (m + n ≡ 0) → (m ≡ 0) m+n≡0-impl-m≡0 zero n m+n≡0 = refl m+n≡0-impl-m≡0 (suc m) n () 1+n≰n : ∀ n → ¬(suc n ≤ n) 1+n≰n zero () 1+n≰n (suc n) (s≤s m≤n) = 1+n≰n n m≤n ≤0-impl-≡0 : ∀ {n} → (n ≤ 0) → (n ≡ 0) ≤0-impl-≡0 z≤n = refl
{ "alphanum_fraction": 0.564665127, "avg_line_length": 27.4920634921, "ext": "agda", "hexsha": "00d816bb840fc7b7b056ad7e2983b71a097f6f39", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/Util.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/Util.agda", "max_line_length": 83, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/Util.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 728, "size": 1732 }
open import Coinduction using ( ♭ ) open import Data.Empty using ( ⊥-elim ) open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ ) open import System.IO.Transducers.Lazy using ( _⇒_ ; inp ; out ; done ; ⟦_⟧ ; _≃_ ; out' ; out* ; _⟫_ ;_[&]_ ; unit₁ ; unit₂ ; assoc ; assoc⁻¹ ; swap'' ; swap' ; swap ) open import System.IO.Transducers.Reflective using ( Reflective ) open import System.IO.Transducers.Strict using ( Strict ) open import System.IO.Transducers.Session using ( I ; Σ ; IsΣ ; _&_ ) open import System.IO.Transducers.Trace using ( Trace ; _✓ ; _≤_ ; [] ; _∷_ ; revApp ) open import System.IO.Transducers.Properties.Lemmas using ( ✓? ; I-✓ ; I-η ; ⟦⟧-resp-✓ ; ⟦⟧-refl-✓ ; ⟦⟧-resp-[] ) open import System.IO.Transducers.Properties.Category using ( ⟦done⟧ ; _⟦⟫⟧_ ; ⟫-≃-⟦⟫⟧ ; done-semantics ) open import System.IO.Transducers.Properties.Monoidal using ( _++_ ; front ; back ; _⟦[&]⟧_ ; ⟦unit₁⟧ ; ⟦unit₂⟧ ; ⟦assoc⟧ ; ⟦assoc⁻¹⟧ ; ++-cong ; ++-β₁ ; ++-β₂ ; ++-β₂-[] ; ++-η ; back≡[] ; back-resp-[] ; ++-resp-[] ; ++-refl-✓₁ ; ++-refl-✓₂ ; front-refl-✓ ; back-refl-✓ ; ++-resp-✓ ; front-resp-✓ ; ⟦[&]⟧-++ ; ⟦assoc⟧-++ ; ⟦assoc⁻¹⟧-++ ; [&]-≃-⟦[&]⟧ ; [&]-semantics ; assoc-semantics ; assoc⁻¹-semantics ; unit₁-semantics ; unit₂-semantics ; unit₂⁻¹-semantics ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; sym ; refl ; trans ; cong ; cong₂ ) open import Relation.Nullary using ( Dec ; yes ; no ) module System.IO.Transducers.Properties.LaxBraided where open Relation.Binary.PropositionalEquality.≡-Reasoning -- Semantics of out* ⟦out*⟧ : ∀ {S T U} → (T ≤ U) → (Trace S → Trace T) → (Trace S → Trace U) ⟦out*⟧ cs f as = revApp cs (f as) out*-semantics : ∀ {S T U} (cs : T ≤ U) (P : S ⇒ T) → ⟦ out* cs P ⟧ ≃ ⟦out*⟧ cs ⟦ P ⟧ out*-semantics [] P as = refl out*-semantics (_∷_ {Σ V F} c cs) P as = out*-semantics cs (out c P) as out*-semantics (_∷_ {I} () cs) P as -- Semantics of swap ⟦swap''⟧ : ∀ {T U} → (I ≤ U) → (Trace T) → (Trace (T & U)) ⟦swap''⟧ cs as = as ++ revApp cs [] ⟦swap'⟧ : ∀ {S T U} → (S ≤ U) → (Trace (S & T)) → (Trace (T & U)) ⟦swap'⟧ {S} cs as = back {S} as ++ revApp cs (front {S} as) ⟦swap⟧ : ∀ {S T} → (Trace (S & T) → Trace (T & S)) ⟦swap⟧ {S} as = back {S} as ++ front {S} as swap''-semantics : ∀ {T U} cs → ⟦ swap'' {T} {U} cs ⟧ ≃ ⟦swap''⟧ cs swap''-semantics {I} cs [] = out*-semantics cs done [] swap''-semantics {Σ W G} cs [] = refl swap''-semantics {Σ W G} cs (a ∷ as) = cong (_∷_ a) (swap''-semantics cs as) swap''-semantics {I} cs (() ∷ as) swap'-semantics : ∀ {S T isΣ U} cs → ⟦ swap' {S} {T} {isΣ} {U} cs ⟧ ≃ ⟦swap'⟧ cs swap'-semantics {I} cs as = swap''-semantics cs as swap'-semantics {Σ V F} {Σ W G} cs [] = refl swap'-semantics {Σ V F} {Σ W G} cs (a ∷ as) = swap'-semantics (a ∷ cs) as swap'-semantics {Σ V F} {I} {} cs as swap-semantics : ∀ {S T} → ⟦ swap {S} {T} ⟧ ≃ ⟦swap⟧ {S} {T} swap-semantics {I} as = unit₂⁻¹-semantics as swap-semantics {Σ V F} {I} as = cong₂ _++_ (sym (I-η (back {Σ V F} as))) (unit₂-semantics as) swap-semantics {Σ V F} {Σ W G} as = swap'-semantics {Σ V F} [] as -- Swap reflects completion ⟦swap⟧-refl-✓ : ∀ {S T} as → (⟦swap⟧ {S} {T} as ✓) → (as ✓) ⟦swap⟧-refl-✓ {S} {I} as ✓bs = front-refl-✓ {S} as (++-refl-✓₂ {I} {S} {back {S} as} ✓bs) ⟦swap⟧-refl-✓ {S} {Σ W G} as ✓bs = back-refl-✓ {S} as (++-refl-✓₁ {Σ W G} ✓bs) -- Swap plays nicely with concatenation ⟦swap⟧-++ : ∀ {S T} (as : Trace S) (bs : Trace T) → (as ✓ ⊎ bs ≡ []) → ⟦swap⟧ {S} {T} (as ++ bs) ≡ bs ++ as ⟦swap⟧-++ as bs ✓as/bs≡[] with ✓? as ⟦swap⟧-++ as bs ✓as/bs≡[] | yes ✓as = cong₂ _++_ (++-β₂ ✓as bs) (++-β₁ as bs) ⟦swap⟧-++ as bs (inj₁ ✓as) | no ¬✓as = cong₂ _++_ (++-β₂ ✓as bs) (++-β₁ as bs) ⟦swap⟧-++ as bs (inj₂ bs≡[]) | no ¬✓as = cong₂ _++_ (trans (++-β₂-[] ¬✓as bs) (sym bs≡[])) (++-β₁ as bs) -- Swap is natural when f respects completion, and g reflects completion and is strict ⟦swap⟧-natural : ∀ {S T U V} → (f : Trace S → Trace T) → (g : Trace U → Trace V) → (∀ as → (as ✓) → (f as ✓)) → (∀ as → ((g as ✓)) → (as ✓)) → (g [] ≡ []) → (f ⟦[&]⟧ g ⟦⟫⟧ ⟦swap⟧ {T} {V}) ≃ (⟦swap⟧ {S} {U} ⟦⟫⟧ g ⟦[&]⟧ f) ⟦swap⟧-natural {S} {T} {U} {V} f g f-resp-✓ g-refl-✓ g-resp-[] as = begin ⟦swap⟧ {T} {V} (f as₁ ++ g as₂) ≡⟨ ⟦swap⟧-++ (f as₁) (g as₂) ✓fas₁/gas₂≡[] ⟩ g as₂ ++ f as₁ ≡⟨ sym (⟦[&]⟧-++ g f g-refl-✓ as₂ as₁) ⟩ (g ⟦[&]⟧ f) (as₂ ++ as₁) ∎ where as₁ = front {S} as as₂ = back {S} as ✓fas₁/gas₂≡[] : f as₁ ✓ ⊎ g as₂ ≡ [] ✓fas₁/gas₂≡[] with ✓? as₁ ✓fas₁/gas₂≡[] | yes ✓as₁ = inj₁ (f-resp-✓ as₁ ✓as₁) ✓fas₁/gas₂≡[] | no ¬✓as₁ = inj₂ (trans (cong g (back≡[] ¬✓as₁)) g-resp-[]) swap-natural : ∀ {S T U V} (P : S ⇒ T) {Q : U ⇒ V} → (Reflective Q) → (Strict Q) → ⟦ P [&] Q ⟫ swap {T} {V} ⟧ ≃ ⟦ swap {S} {U} ⟫ Q [&] P ⟧ swap-natural {S} {T} {U} {V} P {Q} ⟳Q #Q as = begin ⟦ P [&] Q ⟫ swap {T} {V} ⟧ as ≡⟨ ⟫-≃-⟦⟫⟧ ([&]-semantics P Q) (swap-semantics {T} {V}) as ⟩ (⟦ P ⟧ ⟦[&]⟧ ⟦ Q ⟧ ⟦⟫⟧ ⟦swap⟧ {T} {V}) as ≡⟨ ⟦swap⟧-natural ⟦ P ⟧ ⟦ Q ⟧ (⟦⟧-resp-✓ P) (⟦⟧-refl-✓ ⟳Q) (⟦⟧-resp-[] #Q) as ⟩ (⟦swap⟧ {S} {U} ⟦⟫⟧ ⟦ Q ⟧ ⟦[&]⟧ ⟦ P ⟧) as ≡⟨ sym (⟫-≃-⟦⟫⟧ (swap-semantics {S} {U}) ([&]-semantics Q P) as) ⟩ ⟦ swap {S} {U} ⟫ Q [&] P ⟧ as ∎ -- Coherence of swap with units ⟦swap⟧-⟦unit₁⟧ : ∀ {S} → ⟦swap⟧ {S} {I} ⟦⟫⟧ ⟦unit₁⟧ ≃ ⟦unit₂⟧ ⟦swap⟧-⟦unit₁⟧ {S} as = cong₂ _++_ (I-η (back {S} as)) refl swap-unit₁ : ∀ {S} → ⟦ swap {S} {I} ⟫ unit₁ ⟧ ≃ ⟦ unit₂ ⟧ swap-unit₁ {S} as = begin ⟦ swap {S} {I} ⟫ unit₁ ⟧ as ≡⟨ ⟫-≃-⟦⟫⟧ (swap-semantics {S}) unit₁-semantics as ⟩ (⟦swap⟧ {S} {I} ⟦⟫⟧ ⟦unit₁⟧) as ≡⟨ ⟦swap⟧-⟦unit₁⟧ as ⟩ ⟦unit₂⟧ as ≡⟨ sym (unit₂-semantics as) ⟩ ⟦ unit₂ ⟧ as ∎ ⟦swap⟧-⟦unit₂⟧ : ∀ {S} → ⟦swap⟧ {I} {S} ⟦⟫⟧ ⟦unit₂⟧ ≃ ⟦unit₁⟧ ⟦swap⟧-⟦unit₂⟧ as = ++-β₁ as [] swap-unit₂ : ∀ {S} → ⟦ swap {I} {S} ⟫ unit₂ ⟧ ≃ ⟦ unit₁ ⟧ swap-unit₂ {S} as = begin ⟦ swap {I} {S} ⟫ unit₂ ⟧ as ≡⟨ ⟫-≃-⟦⟫⟧ (swap-semantics {I}) (unit₂-semantics {S}) as ⟩ (⟦swap⟧ {I} {S} ⟦⟫⟧ ⟦unit₂⟧) as ≡⟨ ⟦swap⟧-⟦unit₂⟧ as ⟩ ⟦unit₁⟧ as ≡⟨ sym (unit₁-semantics as) ⟩ ⟦ unit₁ ⟧ as ∎ -- Coherence of swap with associators ⟦swap⟧-⟦assoc⟧ : ∀ {S T U} → ⟦assoc⟧ {S} {T} {U} ⟦⟫⟧ ⟦swap⟧ {S & T} {U} ⟦⟫⟧ ⟦assoc⟧ {U} {S} {T} ≃ ⟦done⟧ {S} ⟦[&]⟧ ⟦swap⟧ {T} {U} ⟦⟫⟧ ⟦assoc⟧ {S} {U} {T} ⟦⟫⟧ ⟦swap⟧ {S} {U} ⟦[&]⟧ ⟦done⟧ {T} ⟦swap⟧-⟦assoc⟧ {S} {T} {U} as = begin ⟦assoc⟧ {U} {S} {T} (⟦swap⟧ {S & T} {U} ((as₁ ++ as₂) ++ as₃)) ≡⟨ cong (⟦assoc⟧ {U} {S} {T}) (⟦swap⟧-++ (as₁ ++ as₂) as₃ ✓as₁₂/as₃≡[]) ⟩ ⟦assoc⟧ {U} {S} {T} (as₃ ++ as₁ ++ as₂) ≡⟨ ⟦assoc⟧-++ as₃ as₁ as₂ ⟩ (as₃ ++ as₁) ++ as₂ ≡⟨ cong₂ _++_ (sym (⟦swap⟧-++ as₁ as₃ ✓as₁/as₃≡[])) refl ⟩ ⟦swap⟧ {S} {U} (as₁ ++ as₃) ++ as₂ ≡⟨ (sym (⟦[&]⟧-++ (⟦swap⟧ {S} {U}) ⟦done⟧ (⟦swap⟧-refl-✓ {S} {U}) (as₁ ++ as₃) as₂)) ⟩ (⟦swap⟧ {S} {U} ⟦[&]⟧ ⟦done⟧ {T}) ((as₁ ++ as₃) ++ as₂) ≡⟨ cong (⟦swap⟧ {S} {U} ⟦[&]⟧ ⟦done⟧ {T}) (sym (⟦assoc⟧-++ as₁ as₃ as₂)) ⟩ (⟦swap⟧ {S} {U} ⟦[&]⟧ ⟦done⟧ {T}) (⟦assoc⟧ {S} {U} {T} (as₁ ++ as₃ ++ as₂)) ∎ where as₁ = front {S} as as₂ = front {T} (back {S} as) as₃ = back {T} (back {S} as) ✓as₁₂/as₃≡[] : as₁ ++ as₂ ✓ ⊎ as₃ ≡ [] ✓as₁₂/as₃≡[] with ✓? as₁ | ✓? as₂ ✓as₁₂/as₃≡[] | yes ✓as₁ | yes ✓as₂ = inj₁ (++-resp-✓ ✓as₁ ✓as₂) ✓as₁₂/as₃≡[] | _ | no ¬✓as₂ = inj₂ (back≡[] ¬✓as₂) ✓as₁₂/as₃≡[] | no ¬✓as₁ | _ = inj₂ (back-resp-[] {T} (back≡[] ¬✓as₁)) ✓as₁/as₃≡[] : as₁ ✓ ⊎ as₃ ≡ [] ✓as₁/as₃≡[] with ✓? as₁ ✓as₁/as₃≡[] | yes ✓as₁ = inj₁ ✓as₁ ✓as₁/as₃≡[] | no ¬✓as₁ = inj₂ (back-resp-[] {T} (back≡[] ¬✓as₁)) swap-assoc : ∀ {S T U} → ⟦ assoc {S} {T} {U} ⟫ swap {S & T} {U} ⟫ assoc {U} {S} {T} ⟧ ≃ ⟦ done {S} [&] swap {T} {U} ⟫ assoc {S} {U} {T} ⟫ swap {S} {U} [&] done {T} ⟧ swap-assoc {S} {T} {U} as = begin ⟦ assoc {S} {T} {U} ⟫ swap {S & T} {U} ⟫ assoc {U} {S} {T} ⟧ as ≡⟨ ⟫-≃-⟦⟫⟧ (assoc-semantics {S} {T} {U}) (⟫-≃-⟦⟫⟧ (swap-semantics {S & T} {U}) (assoc-semantics {U} {S} {T})) as ⟩ (⟦assoc⟧ {S} {T} {U} ⟦⟫⟧ ⟦swap⟧ {S & T} {U} ⟦⟫⟧ ⟦assoc⟧ {U} {S} {T}) as ≡⟨ ⟦swap⟧-⟦assoc⟧ {S} {T} {U} as ⟩ (⟦done⟧ {S} ⟦[&]⟧ ⟦swap⟧ {T} {U} ⟦⟫⟧ ⟦assoc⟧ {S} {U} {T} ⟦⟫⟧ ⟦swap⟧ {S} {U} ⟦[&]⟧ ⟦done⟧ {T}) as ≡⟨ sym (⟫-≃-⟦⟫⟧ ([&]-≃-⟦[&]⟧ {P = done} (done-semantics {S}) (swap-semantics {T} {U})) (⟫-≃-⟦⟫⟧ (assoc-semantics {S} {U} {T}) ([&]-≃-⟦[&]⟧ {Q = done} (swap-semantics {S} {U}) (done-semantics {T}))) as) ⟩ ⟦ done {S} [&] swap {T} {U} ⟫ assoc {S} {U} {T} ⟫ swap {S} {U} [&] done {T} ⟧ as ∎ ⟦swap⟧-⟦assoc⁻¹⟧ : ∀ {S T U} → ⟦assoc⁻¹⟧ {S} {T} {U} ⟦⟫⟧ ⟦swap⟧ {S} {T & U} ⟦⟫⟧ ⟦assoc⁻¹⟧ {T} {U} {S} ≃ ⟦swap⟧ {S} {T} ⟦[&]⟧ ⟦done⟧ {U} ⟦⟫⟧ ⟦assoc⁻¹⟧ {T} {S} {U} ⟦⟫⟧ ⟦done⟧ {T} ⟦[&]⟧ ⟦swap⟧ {S} {U} ⟦swap⟧-⟦assoc⁻¹⟧ {S} {T} {U} as = begin ⟦assoc⁻¹⟧ {T} {U} {S} (⟦swap⟧ {S} {T & U} (as₁ ++ as₂ ++ as₃)) ≡⟨ cong (⟦assoc⁻¹⟧ {T} {U} {S}) (⟦swap⟧-++ as₁ (as₂ ++ as₃) ✓as₁/as₂₃≡[]) ⟩ ⟦assoc⁻¹⟧ {T} {U} {S} ((as₂ ++ as₃) ++ as₁) ≡⟨ ⟦assoc⁻¹⟧-++ as₂ as₃ as₁ ⟩ as₂ ++ as₃ ++ as₁ ≡⟨ cong (_++_ as₂) (sym (⟦swap⟧-++ as₁ as₃ ✓as₁/as₃≡[])) ⟩ as₂ ++ ⟦swap⟧ {S} {U} (as₁ ++ as₃) ≡⟨ sym (⟦[&]⟧-++ (⟦done⟧ {T}) (⟦swap⟧ {S} {U}) (λ cs → λ ✓cs → ✓cs) as₂ (as₁ ++ as₃)) ⟩ (⟦done⟧ {T} ⟦[&]⟧ ⟦swap⟧ {S} {U}) (as₂ ++ as₁ ++ as₃) ≡⟨ cong (⟦done⟧ {T} ⟦[&]⟧ ⟦swap⟧ {S} {U}) (sym (⟦assoc⁻¹⟧-++ as₂ as₁ as₃)) ⟩ (⟦done⟧ {T} ⟦[&]⟧ ⟦swap⟧ {S} {U}) (⟦assoc⁻¹⟧ {T} {S} {U} ((as₂ ++ as₁) ++ as₃)) ∎ where as₁ = front {S} (front {S & T} as) as₂ = back {S} (front {S & T} as) as₃ = back {S & T} as ✓as₁/as₂₃≡[] : as₁ ✓ ⊎ as₂ ++ as₃ ≡ [] ✓as₁/as₂₃≡[] with ✓? as₁ ✓as₁/as₂₃≡[] | yes ✓as₁ = inj₁ ✓as₁ ✓as₁/as₂₃≡[] | no ¬✓as₁ = inj₂ (++-resp-[] (back≡[] ¬✓as₁) (back≡[] (λ ✓as₁₂ → ¬✓as₁ (front-resp-✓ ✓as₁₂)))) ✓as₁/as₃≡[] : as₁ ✓ ⊎ as₃ ≡ [] ✓as₁/as₃≡[] with ✓? as₁ ✓as₁/as₃≡[] | yes ✓as₁ = inj₁ ✓as₁ ✓as₁/as₃≡[] | no ¬✓as₁ = inj₂ (back≡[] (λ ✓as₁₂ → ¬✓as₁ (front-resp-✓ ✓as₁₂))) swap-assoc⁻¹ : ∀ {S T U} → ⟦ assoc⁻¹ {S} {T} {U} ⟫ swap {S} {T & U} ⟫ assoc⁻¹ {T} {U} {S} ⟧ ≃ ⟦ swap {S} {T} [&] done {U} ⟫ assoc⁻¹ {T} {S} {U} ⟫ done {T} [&] swap {S} {U} ⟧ swap-assoc⁻¹ {S} {T} {U} as = begin ⟦ assoc⁻¹ {S} {T} {U} ⟫ swap {S} {T & U} ⟫ assoc⁻¹ {T} {U} {S} ⟧ as ≡⟨ ⟫-≃-⟦⟫⟧ (assoc⁻¹-semantics {S} {T} {U}) (⟫-≃-⟦⟫⟧ (swap-semantics {S} {T & U}) (assoc⁻¹-semantics {T} {U} {S})) as ⟩ (⟦assoc⁻¹⟧ {S} {T} {U} ⟦⟫⟧ ⟦swap⟧ {S} {T & U} ⟦⟫⟧ ⟦assoc⁻¹⟧ {T} {U} {S}) as ≡⟨ ⟦swap⟧-⟦assoc⁻¹⟧ {S} {T} {U} as ⟩ (⟦swap⟧ {S} {T} ⟦[&]⟧ ⟦done⟧ {U} ⟦⟫⟧ ⟦assoc⁻¹⟧ {T} {S} {U} ⟦⟫⟧ ⟦done⟧ {T} ⟦[&]⟧ ⟦swap⟧ {S} {U}) as ≡⟨ sym (⟫-≃-⟦⟫⟧ ([&]-≃-⟦[&]⟧ {Q = done} (swap-semantics {S} {T}) (done-semantics {U})) (⟫-≃-⟦⟫⟧ (assoc⁻¹-semantics {T} {S} {U}) ([&]-≃-⟦[&]⟧ {P = done} (done-semantics {T}) (swap-semantics {S} {U}))) as) ⟩ ⟦ swap {S} {T} [&] done {U} ⟫ assoc⁻¹ {T} {S} {U} ⟫ done {T} [&] swap {S} {U} ⟧ as ∎
{ "alphanum_fraction": 0.4574555404, "avg_line_length": 42.83203125, "ext": "agda", "hexsha": "44960cebb2e6d605f7766408eae6c45c87563f87", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Transducers/Properties/LaxBraided.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "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": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Transducers/Properties/LaxBraided.agda", "max_line_length": 110, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Transducers/Properties/LaxBraided.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 6121, "size": 10965 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) module Number.Inclusions where open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Relation.Binary.Base -- Rel -- open import Data.Nat.Base using (ℕ) renaming (_≤_ to _≤ₙ_) open import Cubical.Data.Nat using (ℕ; zero; suc) renaming (_+_ to _+ₙ_) open import Cubical.Data.Nat.Order renaming (zero-≤ to z≤n; suc-≤-suc to s≤s; _≤_ to _≤ₙ_; _<_ to _<ₙ_) open import Cubical.Data.Unit.Base -- Unit open import Cubical.Data.Empty -- ⊥ open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` open import Cubical.Data.Maybe.Base -- open import Number.Structures ℝℓ ℝℓ' open import Number.Bundles -- Finₖ ℕ ℤ ℚ ℚ₀⁺ ℚ⁺ ℝ ℝ₀⁺ ℝ⁺ record IsRLatticeInclusion {ℓ ℓ' ℓₚ ℓₚ'} (F : RLattice {ℓ} {ℓₚ}) (G : RLattice {ℓ'} {ℓₚ'}) (f : (RLattice.Carrier F) → (RLattice.Carrier G)) : Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℓₚ ℓₚ')) where private module F = RLattice F module G = RLattice G field -- injectivity? might follow from preserves-#? reflects-≡ : ∀ x y → f x ≡ f y → x ≡ y -- lattice preserves-< : ∀ x y → x F.< y → f x G.< f y preserves-≤ : ∀ x y → x F.≤ y → f x G.≤ f y preserves-# : ∀ x y → x F.# y → f x G.# f y reflects-< : ∀ x y → f x G.< f y → x F.< y reflects-≤ : ∀ x y → f x G.≤ f y → x F.≤ y reflects-# : ∀ x y → f x G.# f y → x F.# y preserves-min : ∀ x y → f (F.min x y) ≡ G.min (f x) (f y) preserves-max : ∀ x y → f (F.max x y) ≡ G.max (f x) (f y) -- ℕ ℤ ℚ ℚ₀⁺ ℚ⁺ ℝ ℝ₀⁺ ℝ⁺ -- ring without additive inverse record IsROrderedCommSemiringInclusion {ℓ ℓ' ℓₚ ℓₚ'} (F : ROrderedCommSemiring {ℓ} {ℓₚ}) (G : ROrderedCommSemiring {ℓ'} {ℓₚ'}) (f : (ROrderedCommSemiring.Carrier F) → (ROrderedCommSemiring.Carrier G)) : Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℓₚ ℓₚ')) where private module F = ROrderedCommSemiring F module G = ROrderedCommSemiring G field isRLatticeInclusion : IsRLatticeInclusion (record {F}) (record {G}) f preserves-0 : f F.0f ≡ G.0f preserves-1 : f F.1f ≡ G.1f preserves-+ : ∀ x y → f (x F.+ y) ≡ f x G.+ f y preserves-· : ∀ x y → f (x F.· y) ≡ f x G.· f y open IsRLatticeInclusion isRLatticeInclusion public preserves-#0 : ∀ x → x F.# F.0f → f x G.# G.0f preserves-0≤ : ∀ x → F.0f F.≤ x → G.0f G.≤ f x preserves-0< : ∀ x → F.0f F.< x → G.0f G.< f x preserves-<0 : ∀ x → x F.< F.0f → f x G.< G.0f preserves-≤0 : ∀ x → x F.≤ F.0f → f x G.≤ G.0f preserves-#0 x q = transport (λ i → f x G.# preserves-0 i) (preserves-# _ _ q) preserves-0≤ x q = transport (λ i → preserves-0 i G.≤ f x) (preserves-≤ _ _ q) preserves-0< x q = transport (λ i → preserves-0 i G.< f x) (preserves-< _ _ q) preserves-<0 x q = transport (λ i → f x G.< preserves-0 i) (preserves-< _ _ q) preserves-≤0 x q = transport (λ i → f x G.≤ preserves-0 i) (preserves-≤ _ _ q) -- ℤ ℚ ℝ record IsROrderedCommRingInclusion {ℓ ℓ' ℓₚ ℓₚ'} (F : ROrderedCommRing {ℓ} {ℓₚ}) (G : ROrderedCommRing {ℓ'} {ℓₚ'}) (f : (ROrderedCommRing.Carrier F) → (ROrderedCommRing.Carrier G)) : Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℓₚ ℓₚ')) where private module F = ROrderedCommRing F module G = ROrderedCommRing G field isROrderedCommSemiringInclusion : IsROrderedCommSemiringInclusion (record {F}) (record {G}) f preserves- : ∀ x → f ( F.- x) ≡ G.- (f x) open IsROrderedCommSemiringInclusion isROrderedCommSemiringInclusion public -- ℚ ℝ record IsROrderedFieldInclusion {ℓ ℓ' ℓₚ ℓₚ'} (F : ROrderedField {ℓ} {ℓₚ}) (G : ROrderedField {ℓ'} {ℓₚ'}) (f : (ROrderedField.Carrier F) → (ROrderedField.Carrier G)) : Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℓₚ ℓₚ')) where private module F = ROrderedField F module G = ROrderedField G field isROrderedCommRingInclusion : IsROrderedCommRingInclusion (record {F}) (record {G}) f preserves-⁻¹ : ∀ x → (p : x F.# F.0f) → (q : f x G.# G.0f) → f (F._⁻¹ x {{p}}) ≡ G._⁻¹ (f x) {{q}} open IsROrderedCommRingInclusion isROrderedCommRingInclusion public -- ℚ ℝ ℂ record IsRFieldInclusion {ℓ ℓ' ℓₚ ℓₚ'} (F : RField {ℓ} {ℓₚ}) (G : RField {ℓ'} {ℓₚ'}) (f : (RField.Carrier F) → (RField.Carrier G)) : Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℓₚ ℓₚ')) where private module F = RField F module G = RField G field -- CommSemiringInclusion preserves-0 : f F.0f ≡ G.0f preserves-1 : f F.1f ≡ G.1f preserves-+ : ∀ x y → f (x F.+ y) ≡ f x G.+ f y preserves-· : ∀ x y → f (x F.· y) ≡ f x G.· f y -- other reflects-≡ : ∀ x y → f x ≡ f y → x ≡ y preserves-# : ∀ x y → x F.# y → f x G.# f y reflects-# : ∀ x y → f x G.# f y → x F.# y -- TODO: properties preserves-#0 : ∀ x → x F.# F.0f → f x G.# G.0f preserves-#0 x q = transport (λ i → f x G.# preserves-0 i) (preserves-# _ _ q) -- ℕ ℤ ℚ ℝ ℂ record IsRCommSemiringInclusion {ℓ ℓ' ℓₚ ℓₚ'} (F : RCommSemiring {ℓ} {ℓₚ}) (G : RCommSemiring {ℓ'} {ℓₚ'}) (f : (RCommSemiring.Carrier F) → (RCommSemiring.Carrier G)) : Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℓₚ ℓₚ')) where private module F = RCommSemiring F module G = RCommSemiring G field -- CommSemiringInclusion preserves-0 : f F.0f ≡ G.0f preserves-1 : f F.1f ≡ G.1f preserves-+ : ∀ x y → f (x F.+ y) ≡ f x G.+ f y preserves-· : ∀ x y → f (x F.· y) ≡ f x G.· f y -- other reflects-≡ : ∀ x y → f x ≡ f y → x ≡ y preserves-# : ∀ x y → x F.# y → f x G.# f y reflects-# : ∀ x y → f x G.# f y → x F.# y -- TODO: properties -- ℤ ℚ ℝ ℂ record IsRCommRingInclusion {ℓ ℓ' ℓₚ ℓₚ'} (F : RCommRing {ℓ} {ℓₚ}) (G : RCommRing {ℓ'} {ℓₚ'}) (f : (RCommRing.Carrier F) → (RCommRing.Carrier G)) : Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℓₚ ℓₚ')) where private module F = RCommRing F module G = RCommRing G field -- CommSemiringInclusion preserves-0 : f F.0f ≡ G.0f preserves-1 : f F.1f ≡ G.1f preserves-+ : ∀ x y → f (x F.+ y) ≡ f x G.+ f y preserves-· : ∀ x y → f (x F.· y) ≡ f x G.· f y -- other reflects-≡ : ∀ x y → f x ≡ f y → x ≡ y preserves-# : ∀ x y → x F.# y → f x G.# f y reflects-# : ∀ x y → f x G.# f y → x F.# y -- TODO: properties
{ "alphanum_fraction": 0.5580808081, "avg_line_length": 39.6, "ext": "agda", "hexsha": "f1835b3e835511e273626e707ff37c8a5bf88ad2", "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/Number/Inclusions.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/Number/Inclusions.agda", "max_line_length": 118, "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/Number/Inclusions.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": 2919, "size": 6732 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommAlgebra.Kernel where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Algebra.CommRing.Base open import Cubical.Algebra.CommRing.Ideal using (Ideal→CommIdeal) open import Cubical.Algebra.Ring.Kernel using () renaming (kernelIdeal to ringKernel) open import Cubical.Algebra.CommAlgebra.Base open import Cubical.Algebra.CommAlgebra.Properties open import Cubical.Algebra.CommAlgebra.Ideal private variable ℓ : Level module _ {R : CommRing ℓ} (A B : CommAlgebra R ℓ) (ϕ : CommAlgebraHom A B) where kernel : IdealsIn A kernel = Ideal→CommIdeal (ringKernel (CommAlgebraHom→RingHom {A = A} {B = B} ϕ))
{ "alphanum_fraction": 0.7788732394, "avg_line_length": 32.2727272727, "ext": "agda", "hexsha": "41d8e9af969fbdb0eda589a66a99977f41e52837", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/Kernel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/Kernel.agda", "max_line_length": 85, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Kernel.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 202, "size": 710 }
module Prelude.Ord.Reasoning where open import Prelude.Equality open import Prelude.Ord open import Prelude.Function module _ {a} {A : Set a} {{OrdA : Ord/Laws A}} where private lt/leq-trans : ∀ {x y z : A} → x < y → y ≤ z → x < z lt/leq-trans x<y y≤z = case leq-to-lteq {A = A} y≤z of λ where (less y<z) → less-trans {A = A} x<y y<z (equal refl) → x<y leq/lt-trans : ∀ {x y z : A} → x ≤ y → y < z → x < z leq/lt-trans x≤y y<z = case leq-to-lteq {A = A} x≤y of λ where (less x<y) → less-trans {A = A} x<y y<z (equal refl) → y<z data _≲_ (x y : A) : Set a where strict : x < y → x ≲ y nonstrict : x ≤ y → x ≲ y module _ {x y : A} where OrdProof : x ≲ y → Set a OrdProof (strict _) = x < y OrdProof (nonstrict _) = x ≤ y infix -1 ordProof_ ordProof_ : (p : x ≲ y) → OrdProof p ordProof strict p = p ordProof nonstrict p = p infixr 0 eqOrdStep ltOrdStep leqOrdStep infix 1 _∎Ord syntax eqOrdStep x q p = x ≡[ p ] q eqOrdStep : ∀ (x : A) {y z} → y ≲ z → x ≡ y → x ≲ z x ≡[ x=y ] strict y<z = strict (case x=y of λ where refl → y<z) x ≡[ x=y ] nonstrict y≤z = nonstrict (case x=y of λ where refl → y≤z) -- ^ Note: don't match on the proof here, we need to decide strict vs nonstrict for neutral proofs syntax eqOrdStepʳ x q p = x ≡[ p ]ʳ q eqOrdStepʳ : ∀ (x : A) {y z} → y ≲ z → y ≡ x → x ≲ z x ≡[ y=x ]ʳ strict y<z = strict (case y=x of λ where refl → y<z) x ≡[ y=x ]ʳ nonstrict y≤z = nonstrict (case y=x of λ where refl → y≤z) syntax ltOrdStep x q p = x <[ p ] q ltOrdStep : ∀ (x : A) {y z} → y ≲ z → x < y → x ≲ z x <[ x<y ] strict y<z = strict (less-trans {A = A} x<y y<z) x <[ x<y ] nonstrict y≤z = strict (lt/leq-trans x<y y≤z) syntax leqOrdStep x q p = x ≤[ p ] q leqOrdStep : ∀ (x : A) {y z} → y ≲ z → x ≤ y → x ≲ z x ≤[ x≤y ] strict y<z = strict (leq/lt-trans x≤y y<z) x ≤[ x≤y ] nonstrict y≤z = nonstrict (leq-trans {A = A} x≤y y≤z) _∎Ord : ∀ (x : A) → x ≲ x x ∎Ord = nonstrict (eq-to-leq {A = A} refl)
{ "alphanum_fraction": 0.5282929149, "avg_line_length": 33.380952381, "ext": "agda", "hexsha": "379c23c8e15be16bab00e7019fc1a0665cbdab36", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Ord/Reasoning.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Ord/Reasoning.agda", "max_line_length": 102, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Ord/Reasoning.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 906, "size": 2103 }
module ModuleInfix where open import Data.List using (List; _∷_; []) open import Data.Bool using (Bool; true; false) module Sort(A : Set)(_≤_ : A → A → Bool)(_⊝_ : A → A → A)(zero : A) where infix 1 _≤_ infix 2 _⊝_ insert : A → List A → List A insert x [] = x ∷ [] insert x (y ∷ ys) with zero ≤ (y ⊝ x) insert x (y ∷ ys) | true = x ∷ y ∷ ys insert x (y ∷ ys) | false = y ∷ insert x ys sort : List A → List A sort [] = [] sort (x ∷ xs) = insert x (sort xs)
{ "alphanum_fraction": 0.5384615385, "avg_line_length": 24.7, "ext": "agda", "hexsha": "0ea6ffe55196230d4ca832575f7bbc308561ea25", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/ModuleInfix.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/ModuleInfix.agda", "max_line_length": 73, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/ModuleInfix.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 191, "size": 494 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} module Optics.All where open import Optics.Functorial public open import Optics.Reflection public
{ "alphanum_fraction": 0.7842565598, "avg_line_length": 38.1111111111, "ext": "agda", "hexsha": "a6c555559d03d8adbd290a887b0f9c69f9e45c50", "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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "Optics/All.agda", "max_issues_count": 72, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "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": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "Optics/All.agda", "max_line_length": 111, "max_stars_count": 4, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "Optics/All.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": 86, "size": 343 }
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; subst; cong) open import Syntax import Renaming -- Substitutions module Substitution where module _ {𝕊 : Signature} where open Expression 𝕊 open Renaming open Equality infix 5 _∥_→ˢ_ -- the set of substitutions _∥_→ˢ_ : MShape → VShape → VShape → Set 𝕄 ∥ γ →ˢ δ = var γ → ExprTm 𝕄 δ -- equality of substitutions infix 4 _≈ˢ_ _≈ˢ_ : ∀ {𝕄} {γ δ} (σ : 𝕄 ∥ γ →ˢ δ) (σ : 𝕄 ∥ γ →ˢ δ) → Set σ ≈ˢ τ = ∀ x → σ x ≈ τ x -- equality is an equivalence relation ≈ˢ-refl : ∀ {𝕄} {γ δ} {σ : 𝕄 ∥ γ →ˢ δ} → σ ≈ˢ σ ≈ˢ-refl x = ≈-refl ≈ˢ-sym : ∀ {𝕄} {γ δ} {σ τ : 𝕄 ∥ γ →ˢ δ} → σ ≈ˢ τ → τ ≈ˢ σ ≈ˢ-sym ξ x = ≈-sym (ξ x) ≈ˢ-trans : ∀ {𝕄} {γ δ} {σ τ χ : 𝕄 ∥ γ →ˢ δ} → σ ≈ˢ τ → τ ≈ˢ χ → σ ≈ˢ χ ≈ˢ-trans ζ ξ x = ≈-trans (ζ x) (ξ x) -- identity substitution 𝟙ˢ : ∀ {𝕄} {γ} → 𝕄 ∥ γ →ˢ γ 𝟙ˢ = expr-var -- inclusions inlˢ : ∀ {𝕄} {γ δ} → 𝕄 ∥ γ →ˢ γ ⊕ δ inlˢ x = expr-var (var-left x) inrˢ : ∀ {𝕄} {γ δ} → 𝕄 ∥ δ →ˢ γ ⊕ δ inrˢ x = expr-var (var-right x) -- join of substitutions [_,_]ˢ : ∀ {𝕄} {γ δ η} → (𝕄 ∥ γ →ˢ η) → (𝕄 ∥ δ →ˢ η) → (𝕄 ∥ γ ⊕ δ →ˢ η) [ ξ , σ ]ˢ (var-left x) = ξ x [ ξ , σ ]ˢ (var-right y) = σ y -- join respect equality [,]ˢ-resp-≈ˢ : ∀ {𝕄} {γ δ η} {ρ₁ ρ₂ : 𝕄 ∥ γ →ˢ η} {τ₁ τ₂ : 𝕄 ∥ δ →ˢ η} → ρ₁ ≈ˢ ρ₂ → τ₁ ≈ˢ τ₂ → [ ρ₁ , τ₁ ]ˢ ≈ˢ [ ρ₂ , τ₂ ]ˢ [,]ˢ-resp-≈ˢ ζ ξ (var-left x) = ζ x [,]ˢ-resp-≈ˢ ζ ξ (var-right y) = ξ y -- substutution extension ⇑ˢ : ∀ {𝕄} {γ δ η} → (𝕄 ∥ γ →ˢ δ) → (𝕄 ∥ γ ⊕ η →ˢ δ ⊕ η) ⇑ˢ σ (var-left x) = [ var-left ]ʳ σ x ⇑ˢ σ (var-right y) = expr-var (var-right y) -- extension preserves equality ⇑ˢ-resp-≈ˢ : ∀ {𝕄} {γ δ η} {σ τ : 𝕄 ∥ γ →ˢ δ} → σ ≈ˢ τ → ⇑ˢ {η = η} σ ≈ˢ ⇑ˢ τ ⇑ˢ-resp-≈ˢ ξ (var-left x) = []ʳ-resp-≈ var-left (ξ x) ⇑ˢ-resp-≈ˢ ξ (var-right y) = ≈-refl -- extension preserves identity ⇑ˢ-𝟙ˢ : ∀ {𝕄} {γ δ} → ⇑ˢ 𝟙ˢ ≈ˢ 𝟙ˢ {𝕄 = 𝕄} {γ = γ ⊕ δ} ⇑ˢ-𝟙ˢ (var-left x) = ≈-refl ⇑ˢ-𝟙ˢ (var-right x) = ≈-refl -- action of a substitution infix 5 [_]ˢ_ [_]ˢ_ : ∀ {cl 𝕄} {γ δ} → (𝕄 ∥ γ →ˢ δ) → Expr cl 𝕄 γ → Expr cl 𝕄 δ [ σ ]ˢ (expr-var x) = σ x [ σ ]ˢ (expr-symb S es) = expr-symb S (λ i → [ ⇑ˢ σ ]ˢ es i) [ σ ]ˢ (expr-meta M ts) = expr-meta M (λ i → [ σ ]ˢ ts i ) [ σ ]ˢ expr-eqty = expr-eqty [ σ ]ˢ expr-eqtm = expr-eqtm -- the action respects equality []ˢ-resp-≈ : ∀ {cl 𝕄} {γ δ} (σ : 𝕄 ∥ γ →ˢ δ) {t u : Expr cl 𝕄 γ} → t ≈ u → [ σ ]ˢ t ≈ [ σ ]ˢ u []ˢ-resp-≈ σ (≈-≡ ξ) = ≈-≡ (cong ([ σ ]ˢ_) ξ) []ˢ-resp-≈ σ (≈-symb ξ) = ≈-symb (λ i → []ˢ-resp-≈ (⇑ˢ σ) (ξ i)) []ˢ-resp-≈ σ (≈-meta ξ) = ≈-meta (λ i → []ˢ-resp-≈ σ (ξ i)) []ˢ-resp-≈ˢ : ∀ {cl 𝕄} {γ δ} {σ τ : 𝕄 ∥ γ →ˢ δ} → σ ≈ˢ τ → ∀ (t : Expr cl 𝕄 γ) → [ σ ]ˢ t ≈ [ τ ]ˢ t []ˢ-resp-≈ˢ ξ (expr-var x) = ξ x []ˢ-resp-≈ˢ ξ (expr-symb S es) = ≈-symb (λ i → []ˢ-resp-≈ˢ (⇑ˢ-resp-≈ˢ ξ) (es i)) []ˢ-resp-≈ˢ ξ (expr-meta M ts) = ≈-meta (λ i → []ˢ-resp-≈ˢ ξ (ts i)) []ˢ-resp-≈ˢ ξ expr-eqty = ≈-eqty []ˢ-resp-≈ˢ ξ expr-eqtm = ≈-eqtm []ˢ-resp-≈ˢ-≈ : ∀ {cl 𝕄} {γ δ} {σ τ : 𝕄 ∥ γ →ˢ δ} {t u : Expr cl 𝕄 γ} → σ ≈ˢ τ → t ≈ u → [ σ ]ˢ t ≈ [ τ ]ˢ u []ˢ-resp-≈ˢ-≈ {τ = τ} {t = t} ζ ξ = ≈-trans ([]ˢ-resp-≈ˢ ζ t) ([]ˢ-resp-≈ τ ξ) -- composition of substitutions infixl 7 _∘ˢ_ _∘ˢ_ : ∀ {𝕄} {γ δ η} → (𝕄 ∥ δ →ˢ η) → (𝕄 ∥ γ →ˢ δ) → (𝕄 ∥ γ →ˢ η) (ξ ∘ˢ σ) x = [ ξ ]ˢ (σ x) -- sum of substitutions infixl 8 _⊕ˢ_ _⊕ˢ_ : ∀ {𝕄} {γ δ η χ} → (𝕄 ∥ γ →ˢ δ) → (𝕄 ∥ η →ˢ χ) → (𝕄 ∥ γ ⊕ η →ˢ δ ⊕ χ) σ ⊕ˢ τ = [ inlˢ ∘ˢ σ , inrˢ ∘ˢ τ ]ˢ -- composition of renaming and substitition infixr 7 _ʳ∘ˢ_ _ʳ∘ˢ_ : ∀ {𝕄} {γ δ η} → (δ →ʳ η) → (𝕄 ∥ γ →ˢ δ) → (𝕄 ∥ γ →ˢ η) (ρ ʳ∘ˢ σ) x = [ ρ ]ʳ σ x infixl 7 _ˢ∘ʳ_ _ˢ∘ʳ_ : ∀ {𝕄} {γ δ η} → (𝕄 ∥ δ →ˢ η) → (γ →ʳ δ) → (𝕄 ∥ γ →ˢ η) (σ ˢ∘ʳ ρ) x = σ (ρ x) -- extension commutes with the composition of renaming and substitution ⇑ˢ-resp-ʳ∘ˢ : ∀ {𝕄} {γ δ η θ} {ρ : δ →ʳ η} → {σ : 𝕄 ∥ γ →ˢ δ} → ⇑ˢ {η = θ} (ρ ʳ∘ˢ σ) ≈ˢ ⇑ʳ ρ ʳ∘ˢ ⇑ˢ σ ⇑ˢ-resp-ʳ∘ˢ {σ = σ} (var-left x) = ≈-trans (≈-sym ([∘ʳ] (σ x))) (≈-trans ([]ʳ-resp-≡ʳ (σ x) ≡ʳ-refl) ([∘ʳ] (σ x))) ⇑ˢ-resp-ʳ∘ˢ (var-right y) = ≈-refl ⇑ˢ-resp-ˢ∘ʳ : ∀ {𝕄} {β γ δ η} {ρ : β →ʳ γ} {σ : 𝕄 ∥ γ →ˢ δ} → ⇑ˢ {η = η} (σ ˢ∘ʳ ρ) ≈ˢ ⇑ˢ σ ˢ∘ʳ ⇑ʳ ρ ⇑ˢ-resp-ˢ∘ʳ (var-left x) = ≈-refl ⇑ˢ-resp-ˢ∘ʳ (var-right y) = ≈-refl ⇑ˢ-ʳ∘ˢ : ∀ {𝕄} {β γ δ η} {σ : 𝕄 ∥ β →ˢ γ} {ρ : γ →ʳ δ} → ⇑ˢ {η = η} (ρ ʳ∘ˢ σ) ≈ˢ ⇑ʳ ρ ʳ∘ˢ ⇑ˢ σ ⇑ˢ-ʳ∘ˢ (var-left x) = ≈-trans (≈-trans (≈-sym ([∘ʳ] _)) ([]ʳ-resp-≡ʳ _ λ x → refl)) ([∘ʳ] _) ⇑ˢ-ʳ∘ˢ (var-right x) = ≈-refl -- action of a composition of a renaming and a substitition [ˢ∘ʳ] : ∀ {𝕄 cl} {γ δ η} → {σ : 𝕄 ∥ δ →ˢ η} → {ρ : γ →ʳ δ} (t : Expr cl 𝕄 γ) → [ σ ˢ∘ʳ ρ ]ˢ t ≈ [ σ ]ˢ [ ρ ]ʳ t [ˢ∘ʳ] (expr-var x) = ≈-refl [ˢ∘ʳ] (expr-symb S es) = ≈-symb (λ i → ≈-trans ([]ˢ-resp-≈ˢ ⇑ˢ-resp-ˢ∘ʳ (es i)) ([ˢ∘ʳ] (es i))) [ˢ∘ʳ] (expr-meta M ts) = ≈-meta (λ i → [ˢ∘ʳ] (ts i)) [ˢ∘ʳ] expr-eqty = ≈-eqty [ˢ∘ʳ] expr-eqtm = ≈-eqtm [ʳ∘ˢ] : ∀ {𝕄 cl} {γ δ η} → {σ : 𝕄 ∥ γ →ˢ δ} → {ρ : δ →ʳ η} (t : Expr cl 𝕄 γ) → [ ρ ʳ∘ˢ σ ]ˢ t ≈ [ ρ ]ʳ ([ σ ]ˢ t) [ʳ∘ˢ] (expr-var x) = ≈-refl [ʳ∘ˢ] (expr-symb S es) = ≈-symb (λ i → ≈-trans ([]ˢ-resp-≈ˢ ⇑ˢ-ʳ∘ˢ (es i)) ([ʳ∘ˢ] (es i))) [ʳ∘ˢ] (expr-meta M ts) = ≈-meta (λ i → [ʳ∘ˢ] (ts i)) [ʳ∘ˢ] expr-eqty = ≈-eqty [ʳ∘ˢ] expr-eqtm = ≈-eqtm -- composition commutes with extensions ⇑ˢ-resp-∘ˢ : ∀ {𝕄} {β γ δ η} {σ : 𝕄 ∥ β →ˢ γ} {τ : 𝕄 ∥ γ →ˢ δ} → ⇑ˢ {η = η} (τ ∘ˢ σ) ≈ˢ ⇑ˢ τ ∘ˢ ⇑ˢ σ ⇑ˢ-resp-∘ˢ {σ = σ} (var-left x) = ≈-trans (≈-trans (≈-sym ([ʳ∘ˢ] (σ x))) ([]ˢ-resp-≈ˢ (λ x₁ → ≈-refl) (σ x))) ([ˢ∘ʳ] (σ x)) ⇑ˢ-resp-∘ˢ (var-right y) = ≈-refl -- action of substitutions is functorial [𝟙ˢ] : ∀ {cl 𝕄 γ} (t : Expr cl 𝕄 γ) → [ 𝟙ˢ ]ˢ t ≈ t [𝟙ˢ] (expr-var x) = ≈-refl [𝟙ˢ] (expr-symb S es) = ≈-symb (λ i → ≈-trans ([]ˢ-resp-≈ˢ ⇑ˢ-𝟙ˢ (es i)) ([𝟙ˢ] (es i))) [𝟙ˢ] (expr-meta M ts) = ≈-meta (λ i → [𝟙ˢ] (ts i)) [𝟙ˢ] expr-eqty = ≈-eqty [𝟙ˢ] expr-eqtm = ≈-eqtm [∘ˢ] : ∀ {cl 𝕄} {γ δ η} {σ : 𝕄 ∥ γ →ˢ δ} {τ : 𝕄 ∥ δ →ˢ η} (t : Expr cl 𝕄 γ) → [ τ ∘ˢ σ ]ˢ t ≈ [ τ ]ˢ [ σ ]ˢ t [∘ˢ] (expr-var x) = ≈-refl [∘ˢ] (expr-symb S es) = ≈-symb (λ i → ≈-trans ([]ˢ-resp-≈ˢ ⇑ˢ-resp-∘ˢ (es i)) ([∘ˢ] (es i))) [∘ˢ] (expr-meta M ts) = ≈-meta (λ i → [∘ˢ] (ts i)) [∘ˢ] expr-eqty = ≈-eqty [∘ˢ] expr-eqtm = ≈-eqtm []ˢ-id : ∀ {cl 𝕄 γ} {σ : 𝕄 ∥ γ →ˢ γ} {t : Expr cl 𝕄 γ} → σ ≈ˢ 𝟙ˢ → [ σ ]ˢ t ≈ t []ˢ-id {t = t} ξ = ≈-trans ([]ˢ-resp-≈ˢ ξ t) ([𝟙ˢ] t) []ˢ-𝟘-initial : ∀ {cl 𝕄 γ} {σ : 𝕄 ∥ γ →ˢ 𝟘} (t : Expr cl 𝕄 𝟘) → [ σ ]ˢ [ 𝟘-initial ]ʳ t ≈ t []ˢ-𝟘-initial (expr-symb S es) = ≈-symb (λ i → ≈-trans (≈-sym ([ˢ∘ʳ] (es i))) ([]ˢ-id (λ {(var-right x) → ≈-refl}))) []ˢ-𝟘-initial (expr-meta M ts) = ≈-meta (λ i → []ˢ-𝟘-initial (ts i)) []ˢ-𝟘-initial expr-eqty = ≈-eqty []ˢ-𝟘-initial expr-eqtm = ≈-eqtm infix 5 _%_∥_→ˢ_ _%_∥_→ˢ_ : ∀ (𝕊 : Signature) → MShape → VShape → VShape → Set _%_∥_→ˢ_ 𝕊 = _∥_→ˢ_ {𝕊 = 𝕊}
{ "alphanum_fraction": 0.4369281952, "avg_line_length": 34.8502415459, "ext": "agda", "hexsha": "8e72bf3666e1b497ce1603f4abb26c47fd6e99a7", "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": "9b634d284a0ec5108c68489575194cd573f38908", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_forks_repo_path": "src/Substitution.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "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": "andrejbauer/dependent-type-theory-syntax", "max_issues_repo_path": "src/Substitution.agda", "max_line_length": 127, "max_stars_count": 7, "max_stars_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_stars_repo_path": "src/Substitution.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-14T01:48:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T11:14:42.000Z", "num_tokens": 4490, "size": 7214 }
{-# OPTIONS --without-K #-} -- -- This module defines/proves some basic functions/theorem using only -- the induction principle of the equality types the way they are done -- in the HoTT book. The functions defined/theorems proved in this -- module is often exposed in a better way from the main equality -- module, the word better means simpler definitions/proofs. This -- module is thus not meant for use in "production" hott. -- module hott.core.equality.induction-proofs where open import hott.core -- The symmetry of ≡ defined in terms of the induction principle sym : ∀{ℓ} {A : Type ℓ} {x y : A} → x ≡ y → y ≡ x sym {ℓ} {A} = induction≡ D d where D : {u v : A} → u ≡ v → Type ℓ D {u} {v} _ = v ≡ u d : {u : A} → D {u} refl d = refl -- The transitivity of ≡. trans : ∀{ℓ} {A : Type ℓ} {x y z : A} → x ≡ y → y ≡ z → x ≡ z trans {ℓ} {A} xEy = induction≡ D d xEy where D : {u v : A} → u ≡ v → Type ℓ D {u} {v} _ = {w : A} → v ≡ w → u ≡ w d : {u : A} → D {u} refl d uEw = uEw symIsInv : ∀{ℓ} {A : Type ℓ} {x y : A} → (p : x ≡ y) → sym p ≡ p ⁻¹ symIsInv refl = refl
{ "alphanum_fraction": 0.5759717314, "avg_line_length": 28.3, "ext": "agda", "hexsha": "840e6ae7a9eca9122c521aa240006e4c816ece17", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/core/equality/induction-proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/core/equality/induction-proofs.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/core/equality/induction-proofs.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 421, "size": 1132 }
{-# OPTIONS --without-K --exact-split #-} module rational-numbers where import integers open integers public -------------------------------------------------------------------------------- {- We introduce the type of non-zero integers. -} ℤ\0 : UU lzero ℤ\0 = Σ ℤ (λ k → ¬ (Id zero-ℤ k)) int-ℤ\0 : ℤ\0 → ℤ int-ℤ\0 = pr1 {- We first show that multiplication by a non-zero integer is an injective function. -} mul-ℤ-ℤ\0 : ℤ → ℤ\0 → ℤ mul-ℤ-ℤ\0 x y = mul-ℤ x (int-ℤ\0 y) mul-ℤ\0 : ℤ\0 → ℤ\0 → ℤ\0 mul-ℤ\0 (pair x Hx) (pair y Hy) = pair (mul-ℤ x y) (neq-zero-mul-ℤ x y Hx Hy) postulate is-emb-mul-ℤ-ℤ\0 : (y : ℤ\0) → is-emb (λ x → mul-ℤ-ℤ\0 x y) is-injective-mul-ℤ-ℤ\0 : (y : ℤ\0) (x1 x2 : ℤ) → Id (mul-ℤ-ℤ\0 x1 y) (mul-ℤ-ℤ\0 x2 y) → Id x1 x2 is-injective-mul-ℤ-ℤ\0 y x1 x2 = inv-is-equiv (is-emb-mul-ℤ-ℤ\0 y x1 x2) -------------------------------------------------------------------------------- {- We introduce the prerational numbers. -} ℚ' : UU lzero ℚ' = ℤ × ℤ\0 -------------------------------------------------------------------------------- {- We introduce the equivalence relation on the prerational numbers that will define the rational numbers. -} equiv-ℚ' : ℚ' → ℚ' → UU lzero equiv-ℚ' (pair x1 x2) (pair y1 y2) = Id (mul-ℤ-ℤ\0 x1 y2) (mul-ℤ-ℤ\0 y1 x2) refl-equiv-ℚ' : (x : ℚ') → equiv-ℚ' x x refl-equiv-ℚ' (pair x1 x2) = refl symmetric-equiv-ℚ' : (x y : ℚ') → equiv-ℚ' x y → equiv-ℚ' y x symmetric-equiv-ℚ' (pair x1 x2) (pair y1 y2) = inv transitive-equiv-ℚ' : (x y z : ℚ') → equiv-ℚ' x y → equiv-ℚ' y z → equiv-ℚ' x z transitive-equiv-ℚ' (pair x1 x2) (pair y1 y2) (pair z1 z2) p q = is-injective-mul-ℤ-ℤ\0 y2 ( mul-ℤ-ℤ\0 x1 z2) ( mul-ℤ-ℤ\0 z1 x2) ( ( associative-mul-ℤ x1 (int-ℤ\0 z2) (int-ℤ\0 y2)) ∙ ( ( ap ( mul-ℤ x1) ( commutative-mul-ℤ (int-ℤ\0 z2) (int-ℤ\0 y2))) ∙ ( ( inv (associative-mul-ℤ x1 (int-ℤ\0 y2) (int-ℤ\0 z2))) ∙ ( ( ap ( λ t → mul-ℤ t (int-ℤ\0 z2)) ( p ∙ (commutative-mul-ℤ y1 (int-ℤ\0 x2)))) ∙ ( ( associative-mul-ℤ (int-ℤ\0 x2) y1 (int-ℤ\0 z2)) ∙ ( ( ap (mul-ℤ (int-ℤ\0 x2)) q) ∙ ( ( inv (associative-mul-ℤ (int-ℤ\0 x2) z1 (int-ℤ\0 y2))) ∙ ( ap ( λ t → mul-ℤ-ℤ\0 t y2) ( commutative-mul-ℤ (int-ℤ\0 x2) z1))))))))) -------------------------------------------------------------------------------- {- We define addition on the prerational numbers. -} add-ℚ' : ℚ' → ℚ' → ℚ' add-ℚ' (pair x1 x2) (pair y1 y2) = pair (add-ℤ (mul-ℤ-ℤ\0 x1 y2) (mul-ℤ-ℤ\0 y1 x2)) (mul-ℤ\0 x2 y2) equiv-add-ℚ' : (x y x' y' : ℚ') → equiv-ℚ' x x' → equiv-ℚ' y y' → equiv-ℚ' (add-ℚ' x y) (add-ℚ' x' y') equiv-add-ℚ' ( pair x1 (pair x2 Hx)) ( pair y1 (pair y2 Hy)) ( pair x1' (pair x2' Hx')) ( pair y1' (pair y2' Hy')) e f = ( right-distributive-mul-add-ℤ ( mul-ℤ x1 y2) ( mul-ℤ y1 x2) ( mul-ℤ x2' y2')) ∙ ( ( ap-add-ℤ ( ( interchange-2-3-mul-ℤ {x1}) ∙ ( ( ap (λ t → mul-ℤ t (mul-ℤ y2 y2')) e) ∙ ( move-four-mul-ℤ {x1'}))) ( ( move-five-mul-ℤ {y1}) ∙ ( ( ap (mul-ℤ (mul-ℤ x2 x2')) f) ∙ ( interchange-1-3-mul-ℤ {x2} {x2'} {y1'})))) ∙ ( inv ( right-distributive-mul-add-ℤ ( mul-ℤ x1' y2') ( mul-ℤ y1' x2') ( mul-ℤ x2 y2)))) -------------------------------------------------------------------------------- {- We define multiplication on the prerational numbers. -} mul-ℚ' : ℚ' → ℚ' → ℚ' mul-ℚ' (pair x1 x2) (pair y1 y2) = pair (mul-ℤ x1 y1) (mul-ℤ\0 x2 y2) ap-mul-ℤ : {a b a' b' : ℤ} → Id a a' → Id b b' → Id (mul-ℤ a b) (mul-ℤ a' b') ap-mul-ℤ refl refl = refl equiv-mul-ℚ' : (x y x' y' : ℚ') → equiv-ℚ' x x' → equiv-ℚ' y y' → equiv-ℚ' (mul-ℚ' x y) (mul-ℚ' x' y') equiv-mul-ℚ' ( pair x1 (pair x2 Hx)) ( pair y1 (pair y2 Hy)) ( pair x1' (pair x2' Hx')) ( pair y1' (pair y2' Hy')) e f = ( interchange-2-3-mul-ℤ {x1} {y1} {x2'}) ∙ ( ( ap-mul-ℤ e f) ∙ ( interchange-2-3-mul-ℤ {x1'}))
{ "alphanum_fraction": 0.4654699576, "avg_line_length": 30.3863636364, "ext": "agda", "hexsha": "f093bcada185b0b0763c10dbaff2d2f28569c3d4", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/rational-numbers.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/rational-numbers.agda", "max_line_length": 80, "max_stars_count": 333, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/rational-numbers.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 1822, "size": 4011 }
-- Christian Sattler, 2013-12-31 -- Testing eta-expansion of bound record metavars, as implemented by Andreas. module Issue376-2 where {- A simple example. -} module example-0 {A B : Set} where record Prod : Set where constructor _,_ field fst : A snd : B module _ (F : (Prod → Set) → Set) where q : (∀ f → F f) → (∀ f → F f) q h _ = h (λ {(a , b) → _}) {- A more complex, real-life-based example: the dependent generalization of (A × B) × (C × D) ≃ (A × C) × (B × D). -} module example-1 where record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field fst : A snd : B fst postulate _≃_ : (A B : Set) → Set Σ-interchange-Type = (A : Set) (B C : A → Set) (D : (a : A) → B a → C a → Set) → Σ (Σ A B) (λ {(a , b) → Σ (C a) (λ c → D a b c)}) ≃ Σ (Σ A C) (λ {(a , c) → Σ (B a) (λ b → D a b c)}) postulate Σ-interchange : Σ-interchange-Type {- Can the implicit arguments to Σ-interchange be inferred from the global type? -} Σ-interchange' : Σ-interchange-Type Σ-interchange' A B C D = Σ-interchange _ _ _ _
{ "alphanum_fraction": 0.5501792115, "avg_line_length": 27.2195121951, "ext": "agda", "hexsha": "d4178d87d9e4986b9286af2d65830dc11c69519d", "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/Issue376-2.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/Issue376-2.agda", "max_line_length": 77, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue376-2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 412, "size": 1116 }
module _ where module M where data D : Set where c : D private pattern c′ = c open M x : D x = c′
{ "alphanum_fraction": 0.5517241379, "avg_line_length": 7.25, "ext": "agda", "hexsha": "81ccc717c7ccefa83c780132fbb85211a26e4bb5", "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/Issue4121-1.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/Issue4121-1.agda", "max_line_length": 20, "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/Issue4121-1.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": 42, "size": 116 }
open import Nat open import Prelude open import dynamics-core module lemmas-progress-checks where -- boxed values don't have an instruction transition boxedval-not-trans : ∀{d d'} → d boxedval → d →> d' → ⊥ boxedval-not-trans (BVVal VNum) () boxedval-not-trans (BVVal VLam) () boxedval-not-trans (BVArrCast x bv) (ITCastID) = x refl boxedval-not-trans (BVHoleCast () bv) (ITCastID) boxedval-not-trans (BVHoleCast () bv) (ITCastSucceed x₁) boxedval-not-trans (BVHoleCast GArrHole bv) (ITGround (MGArr x)) = x refl boxedval-not-trans (BVHoleCast x a) (ITExpand ()) boxedval-not-trans (BVHoleCast x x₁) (ITCastFail x₂ () x₄) boxedval-not-trans (BVVal (VInl x)) () boxedval-not-trans (BVVal (VInr x)) () boxedval-not-trans (BVSumCast x x₁) ITCastID = x refl boxedval-not-trans (BVHoleCast GSumHole x₁) (ITGround (MGSum x₂)) = x₂ refl boxedval-not-trans (BVInl bv) () boxedval-not-trans (BVInr bv) () boxedval-not-trans (BVPair bv bv₁) () boxedval-not-trans (BVProdCast x bv) ITCastID = x refl boxedval-not-trans (BVHoleCast GProdHole bv) (ITGround (MGProd x)) = x refl -- indets don't have an instruction transition indet-not-trans : ∀{d d'} → d indet → d →> d' → ⊥ indet-not-trans IEHole () indet-not-trans (INEHole x) () indet-not-trans (IAp x₁ () x₂) (ITLam) indet-not-trans (IAp x (ICastArr x₁ ind) x₂) ITApCast = x _ _ _ _ _ refl indet-not-trans (ICastArr x ind) (ITCastID) = x refl indet-not-trans (ICastGroundHole () ind) (ITCastID) indet-not-trans (ICastGroundHole x ind) (ITCastSucceed ()) indet-not-trans (ICastGroundHole GArrHole ind) (ITGround (MGArr x)) = x refl indet-not-trans (ICastHoleGround x ind ()) (ITCastID) indet-not-trans (ICastHoleGround x ind x₁) (ITCastSucceed x₂) = x _ _ refl indet-not-trans (ICastHoleGround x ind GArrHole) (ITExpand (MGArr x₂)) = x₂ refl indet-not-trans (ICastGroundHole x a) (ITExpand ()) indet-not-trans (ICastHoleGround x a x₁) (ITGround ()) indet-not-trans (ICastGroundHole x x₁) (ITCastFail x₂ () x₄) indet-not-trans (ICastHoleGround x x₁ x₂) (ITCastFail x₃ x₄ x₅) = x _ _ refl indet-not-trans (IFailedCast x x₁ x₂ x₃) () indet-not-trans (IPlus1 () x₁) (ITPlus x₂) indet-not-trans (IPlus2 x ()) (ITPlus x₂) indet-not-trans (ICase x x₂ x₃ (IInl x₄)) ITCaseInl = x _ _ refl indet-not-trans (ICase x x₂ x₃ (IInr x₄)) ITCaseInr = x₂ _ _ refl indet-not-trans (ICase x x₂ x₃ (ICastSum x₁ x₄)) ITCaseCast = x₃ _ _ _ _ _ refl indet-not-trans (ICastSum x x₂) ITCastID = x refl indet-not-trans (ICastGroundHole GSumHole x₂) (ITGround (MGSum x₁)) = x₁ refl indet-not-trans (ICastGroundHole GProdHole ind) (ITGround (MGProd x)) = x refl indet-not-trans (ICastHoleGround x x₂ GSumHole) (ITExpand (MGSum x₁)) = x₁ refl indet-not-trans (ICastHoleGround x ind GProdHole) (ITExpand (MGProd x₁)) = x₁ refl indet-not-trans (IInl ind) () indet-not-trans (IInr ind) () indet-not-trans (IPair1 ind x) () indet-not-trans (IPair2 x ind) () indet-not-trans (IFst x x₁ ind) ITFstPair = x _ _ refl indet-not-trans (IFst x x₁ ind) ITFstCast = x₁ _ _ _ _ _ refl indet-not-trans (ISnd x x₁ ind) ITSndPair = x _ _ refl indet-not-trans (ISnd x x₁ ind) ITSndCast = x₁ _ _ _ _ _ refl indet-not-trans (ICastProd x ind) ITCastID = x refl indet-not-trans (ICastGroundHole GNum ind) (ITGround ()) indet-not-trans (ICastHoleGround x ind GNum) (ITExpand ()) -- finals don't have an instruction transition final-not-trans : ∀{d d'} → d final → d →> d' → ⊥ final-not-trans (FBoxedVal x) = boxedval-not-trans x final-not-trans (FIndet x) = indet-not-trans x -- finals cast from a ground are still final final-gnd-cast : ∀{ d τ } → d final → τ ground → (d ⟨ τ ⇒ ⦇-⦈ ⟩) final final-gnd-cast (FBoxedVal x) gnd = FBoxedVal (BVHoleCast gnd x) final-gnd-cast (FIndet x) gnd = FIndet (ICastGroundHole gnd x) -- if an expression results from filling a hole in an evaluation context, -- the hole-filler must have been final final-sub-final : ∀{d ε x} → d final → d == ε ⟦ x ⟧ → x final final-sub-final x FHOuter = x final-sub-final (FBoxedVal (BVVal ())) (FHPlus1 eps) final-sub-final (FBoxedVal (BVVal ())) (FHPlus2 eps) final-sub-final (FBoxedVal (BVVal ())) (FHAp1 eps) final-sub-final (FBoxedVal (BVVal ())) (FHAp2 eps) final-sub-final (FBoxedVal (BVVal ())) (FHNEHole eps) final-sub-final (FBoxedVal (BVVal ())) (FHCast eps) final-sub-final (FBoxedVal (BVVal ())) (FHFailedCast y) final-sub-final (FBoxedVal (BVArrCast x₁ x₂)) (FHCast eps) = final-sub-final (FBoxedVal x₂) eps final-sub-final (FBoxedVal (BVHoleCast x₁ x₂)) (FHCast eps) = final-sub-final (FBoxedVal x₂) eps final-sub-final (FIndet (IPlus1 x x₁)) (FHPlus1 eps) = final-sub-final (FIndet x) eps final-sub-final (FIndet (IPlus2 x x₁)) (FHPlus1 eps) = final-sub-final x eps final-sub-final (FIndet (IPlus1 x x₁)) (FHPlus2 eps) = final-sub-final x₁ eps final-sub-final (FIndet (IPlus2 x x₁)) (FHPlus2 eps) = final-sub-final (FIndet x₁) eps final-sub-final (FIndet (IAp x₁ x₂ x₃)) (FHAp1 eps) = final-sub-final (FIndet x₂) eps final-sub-final (FIndet (IAp x₁ x₂ x₃)) (FHAp2 eps) = final-sub-final x₃ eps final-sub-final (FIndet (INEHole x₁)) (FHNEHole eps) = final-sub-final x₁ eps final-sub-final (FIndet (ICastArr x₁ x₂)) (FHCast eps) = final-sub-final (FIndet x₂) eps final-sub-final (FIndet (ICastGroundHole x₁ x₂)) (FHCast eps) = final-sub-final (FIndet x₂) eps final-sub-final (FIndet (ICastHoleGround x₁ x₂ x₃)) (FHCast eps) = final-sub-final (FIndet x₂) eps final-sub-final (FIndet (IFailedCast x₁ x₂ x₃ x₄)) (FHFailedCast y) = final-sub-final x₁ y final-sub-final (FBoxedVal (BVVal ())) (FHCase eps) final-sub-final (FBoxedVal (BVSumCast x x₁)) (FHCast eps) = final-sub-final (FBoxedVal x₁) eps final-sub-final (FIndet (ICase x x₁ x₂ x₃)) (FHCase eps) = final-sub-final (FIndet x₃) eps final-sub-final (FIndet (ICastSum x x₁)) (FHCast eps) = final-sub-final (FIndet x₁) eps final-sub-final (FBoxedVal (BVVal (VInl x))) (FHInl eps) = final-sub-final (FBoxedVal (BVVal x)) eps final-sub-final (FBoxedVal (BVInl x)) (FHInl eps) = final-sub-final (FBoxedVal x) eps final-sub-final (FIndet (IInl x)) (FHInl eps) = final-sub-final (FIndet x) eps final-sub-final (FBoxedVal (BVVal (VInr x))) (FHInr eps) = final-sub-final (FBoxedVal (BVVal x)) eps final-sub-final (FBoxedVal (BVInr x)) (FHInr eps) = final-sub-final (FBoxedVal x) eps final-sub-final (FBoxedVal (BVProdCast x x₁)) (FHCast eps) = final-sub-final (FBoxedVal x₁) eps final-sub-final (FIndet (IInr x)) (FHInr eps) = final-sub-final (FIndet x) eps final-sub-final (FBoxedVal (BVVal ())) (FHFst eps) final-sub-final (FBoxedVal (BVVal ())) (FHSnd eps) final-sub-final (FBoxedVal (BVVal (VPair x x₁))) (FHPair1 eps) = final-sub-final (FBoxedVal (BVVal x)) eps final-sub-final (FBoxedVal (BVPair x x₁)) (FHPair1 eps) = final-sub-final (FBoxedVal x) eps final-sub-final (FBoxedVal (BVVal (VPair x x₁))) (FHPair2 eps) = final-sub-final (FBoxedVal (BVVal x₁)) eps final-sub-final (FBoxedVal (BVPair x x₁)) (FHPair2 eps) = final-sub-final (FBoxedVal x₁) eps final-sub-final (FIndet (IFst x x₁ x₂)) (FHFst eps) = final-sub-final (FIndet x₂) eps final-sub-final (FIndet (ISnd x x₁ x₂)) (FHSnd eps) = final-sub-final (FIndet x₂) eps final-sub-final (FIndet (IPair1 x x₁)) (FHPair1 eps) = final-sub-final (FIndet x) eps final-sub-final (FIndet (IPair2 x x₁)) (FHPair1 eps) = final-sub-final x eps final-sub-final (FIndet (IPair1 x x₁)) (FHPair2 eps) = final-sub-final x₁ eps final-sub-final (FIndet (IPair2 x x₁)) (FHPair2 eps) = final-sub-final (FIndet x₁) eps final-sub-final (FIndet (ICastProd x x₁)) (FHCast eps) = final-sub-final (FIndet x₁) eps final-sub-not-trans : ∀{d d' d'' ε} → d final → d == ε ⟦ d' ⟧ → d' →> d'' → ⊥ final-sub-not-trans f sub step = final-not-trans (final-sub-final f sub) step
{ "alphanum_fraction": 0.6899402264, "avg_line_length": 62.4047619048, "ext": "agda", "hexsha": "9caf1adb193f244e8d49d4b1ade8b2233f4b9ebd", "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": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "lemmas-progress-checks.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "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/hazelnut-agda", "max_issues_repo_path": "lemmas-progress-checks.agda", "max_line_length": 109, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "lemmas-progress-checks.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2971, "size": 7863 }
module Structure.Category.Functor where open import Functional using (_on₂_) open import Lang.Instance import Lvl open import Logic.Predicate open import Structure.Category open import Structure.Function open import Structure.Function.Multi import Structure.Relator.Names as Names open import Structure.Setoid open import Syntax.Function open import Type private variable ℓ ℓₒ ℓₘ ℓₗₒ ℓₗₘ ℓᵣₒ ℓᵣₘ ℓₑ ℓₗₑ ℓᵣₑ : Lvl.Level private variable Obj Objₗ Objᵣ : Type{ℓ} private variable Morphism Morphismₗ Morphismᵣ : Objₗ → Objᵣ → Type{ℓ} module _ ⦃ morphism-equivₗ : ∀{x y : Objₗ} → Equiv{ℓₗₑ}(Morphismₗ x y) ⦄ ⦃ morphism-equivᵣ : ∀{x y : Objᵣ} → Equiv{ℓᵣₑ}(Morphismᵣ x y) ⦄ (Categoryₗ : Category(Morphismₗ)) (Categoryᵣ : Category(Morphismᵣ)) where -- A covariant functor. -- A mapping which transforms objects and morphisms from one category to another while "preserving" the categorical structure. -- A homomorphism between categories. -- In the context of equivalence relations instead of categories, this is the "function"/"congruence" property of the function `F`. record Functor (F : Objₗ → Objᵣ) : Type{Lvl.of(Type.of(Categoryₗ)) Lvl.⊔ Lvl.of(Type.of(Categoryᵣ))} where constructor intro open Category ⦃ … ⦄ open Category.ArrowNotation ⦃ … ⦄ private instance _ = Categoryₗ private instance _ = Categoryᵣ field -- Morphs/Transforms morphisms from the left category to the right category. -- ∀{x y : Objₗ} → (x ⟶ y) → (F(x) ⟶ F(y)) map : Names.Subrelation(_⟶_) ((_⟶_) on₂ F) field ⦃ map-function ⦄ : ∀{x y} → Function(map{x}{y}) ⦃ op-preserving ⦄ : ∀{x y z : Objₗ}{f : y ⟶ z}{g : x ⟶ y} → (map(f ∘ g) ≡ map(f) ∘ map(g)) ⦃ id-preserving ⦄ : ∀{x : Objₗ} → Names.Preserving₀(map{x})(id)(id) --(map(id {x = x}) ≡ id) open import Structure.Categorical.Properties open import Structure.Function.Domain Faithful = ∀{x y} → Injective (map{x}{y}) -- TODO: F also? Not sure Full = ∀{x y} → Surjective(map{x}{y}) FullyFaithful = ∀{x y} → Bijective (map{x}{y}) -- TODO: Conservative = ∀{x y : Objₗ}{f : x ⟶ y} → Morphism.Isomorphism(\{x} → _∘_ {x = x})(\{x} → id{x = x})(map f) → Morphism.Isomorphism(\{x} → _∘_ {x = x})(id)(f) module _ ⦃ morphism-equiv : ∀{x y : Obj} → Equiv{ℓₑ}(Morphism x y) ⦄ (Category : Category(Morphism)) where Endofunctor = Functor(Category)(Category) module Endofunctor = Functor{Categoryₗ = Category}{Categoryᵣ = Category} _→ᶠᵘⁿᶜᵗᵒʳ_ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ} → CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ} → Type catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ = ∃(Functor (CategoryObject.category(catₗ)) ((CategoryObject.category(catᵣ)))) ⟲ᶠᵘⁿᶜᵗᵒʳ_ : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ} → Type ⟲ᶠᵘⁿᶜᵗᵒʳ cat = cat →ᶠᵘⁿᶜᵗᵒʳ cat
{ "alphanum_fraction": 0.6642494561, "avg_line_length": 40.5588235294, "ext": "agda", "hexsha": "31be1320022b8c0c497e2391167f5d0e5264c62b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Category/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Category/Functor.agda", "max_line_length": 171, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Category/Functor.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": 1108, "size": 2758 }
-- exercises-03-wednesday.agda open import mylib {- Part 1 : Recursion via patterns Define the following functions using pattern matching and structural recursion on the natural numbers. -} -- Define a function even that determines wether its input is even. even : ℕ → Bool {- even zero = true even (suc n) = ! even n -} even zero = true even (suc zero) = false even (suc (suc n)) = even n -- Define a function sum that sums the numbers from 0 until n-1 sum : ℕ → ℕ sum 0 = 0 sum (suc n) = n + sum n -- Define a function max that calculates the maximum of 2 numbers max : ℕ → ℕ → ℕ max zero n = n max (suc m) zero = suc m max (suc m) (suc n) = suc (max m n) -- Define a function fib which calculates the nth item of the -- Fibonacci sequence: 1,1,2,3,5,8,13 -- (each number is the sum of the two previous ones). fib : ℕ → ℕ fib zero = 1 fib (suc zero) = 1 fib (suc (suc n)) = fib n + fib (suc n) -- Define a function eq that determines wether two numbers are equal. eq : ℕ → ℕ → Bool eq zero zero = true eq zero (suc m) = false eq (suc n) zero = false eq (suc n) (suc m) = eq n m -- Define a function rem such that rem m n returns the remainder -- when dividing m by suc n (this way we avoid division by 0). rem : ℕ → ℕ → ℕ rem zero n = zero rem (suc m) n = if eq (rem m n) n then 0 else suc (rem m n) -- Define a function div such that div m n returns the result -- of dividing m by suc n (ignoring the remainder) div : ℕ → ℕ → ℕ div zero n = zero div (suc m) n = if eq (rem m n) n then suc (div m n) else div m n {- Part 2 : Iterator and recursor Define all the functions of part 1 but this time only use the iterator Itℕ. That is NO PATTERNMATCHING (not even in lambdas) and NO RECURSION. Naming convention if the function in part 1 is called f then call it f-i if you only use the iterator. Test the functions with at least the same test cases. Hint: you may want to derive the recursor first (from the iterator): Rℕ : M → (ℕ → M → M) → ℕ → M where the method can access the current number. Using pattern matching the recursor can be defined as follows: Rℕ z s zero = z Rℕ z s (suc n) = s n (Rℕ z s n) -} Itℕ : M → (M → M) → ℕ → M Itℕ z s zero = z Itℕ z s (suc n) = s (Itℕ z s n) even-i : ℕ → Bool even-i = Itℕ true (λ even-n → ! even-n) {- sum : ℕ → ℕ sum 0 = 0 sum (suc n) = n + sum n -} sum-i-aux : ℕ → ℕ × ℕ -- sum-i-aux n = (n , sum n) sum-i-aux = Itℕ (0 , 0) λ n-sum-n → (suc (proj₁ n-sum-n)) , ((proj₁ n-sum-n) + (proj₂ n-sum-n)) sum-i : ℕ → ℕ sum-i n = proj₂ (sum-i-aux n) {- fib : ℕ → ℕ fib zero = 1 fib (suc zero) = 1 fib (suc (suc n)) = fib n + fib (suc n) fib-i-aux : ℕ → ℕ × ℕ = fib-i-aux n = fib n , fib (suc n) -}
{ "alphanum_fraction": 0.6350851221, "avg_line_length": 25.7333333333, "ext": "agda", "hexsha": "a7a3c3a9c1b06c80d0a1aeafe824e6786ecf33d8", "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": "f328e596d98a7d052b34144447dd14de0f57e534", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FoxySeta/mgs-2021", "max_forks_repo_path": "Type Theory/exercises-03-wednesday.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z", "max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "FoxySeta/mgs-2021", "max_issues_repo_path": "Type Theory/exercises-03-wednesday.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FoxySeta/mgs-2021", "max_stars_repo_path": "Type Theory/exercises-03-wednesday.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 959, "size": 2702 }
{- Agda file from the exercise session(s). -} {-# OPTIONS --without-K #-} open import Agda.Primitive {- Two inductive implementations of the Martin-Löf identity type aka equality type aka identification type aka path type. -} data _≡_ {A : Set} (a : A) : A → Set where refl : a ≡ a infixr 10 _≡_ -- explcit data _≡'_ {A : Set} : A → A → Set where refl : (a : A) → a ≡' a -- variables can be used later and are understood as Pi-quantified. variable A B C : Set -- sym' for ≡' sym' : {a b : A} → a ≡' b → b ≡' a sym' {a = x} {.x} (refl .x) = refl x -- sym for ≡ sym : {a b : A} → a ≡ b → b ≡ a sym refl = refl _⁻¹ = sym symsym : {a b : A} → (p : a ≡ b) → sym (sym p) ≡ p symsym refl = refl ap : (f : A → B) → {a b : A} → a ≡ b → f a ≡ f b ap f {a} {.a} refl = refl _∘_ : {A B C : Set} → (g : B → C) → (f : A → B) → A → C g ∘ f = λ x → g (f x) infixl 26 _∘_ ap-g∘f : (f : A → B) (g : B → C) {a b : A} (p : a ≡ b) → ap (g ∘ f) p ≡ (ap g ∘ ap f) p ap-g∘f f g refl = refl trans : {a b c : A} → a ≡ b → b ≡ c → a ≡ c trans refl q = q _∙_ = trans infixr 30 _∙_ sym-refl : {a b : A} → (p : a ≡ b) → (p ⁻¹) ∙ p ≡ refl sym-refl refl = refl trans2 : {a b c : A} -> a ≡ b -> b ≡ c -> a ≡ c trans2 p refl = p trans-trans2 : {a b c : A} -> (p : a ≡ b) -> (q : b ≡ c) -> trans p q ≡ trans2 p q trans-trans2 {a = x} {b = .x} {c = .x} refl refl = refl trans3 : {a b c : A} -> a ≡ b -> b ≡ c -> a ≡ c trans3 refl refl = refl trans-trans3 : {a b c : A} -> (p : a ≡ b) -> (q : b ≡ c) -> trans p q ≡ trans3 p q trans-trans3 {a = x} {b = .x} {c = .x} refl refl = refl test : {a c : A} → (q : a ≡ c) → trans refl q ≡ q test q = refl test2 : {a c : A} → (q : a ≡ c) → trans2 q refl ≡ q test2 q = refl test3 : {a c : A} → (q : a ≡ c) → trans3 refl q ≡ q test3 refl = refl {- In test3 above, we have to pattern match (path induct) on q! What if we cannot, as in test4 : {a : A} → (q : a ≡ a) → trans3 refl q ≡ q ? -} -- solution: test4 : {a : A} → (q : a ≡ a) → trans3 refl q ≡ q test4 q = test3 q -- We can only pattern match on q if we remove the --without-K option: uip : {a b : A} → (p q : a ≡ b) → p ≡ q uip {a = x} {b = .x} refl q = {!q!} -- implementation of the J eliminator (aka path induction) module _ (C : (a b : A) → a ≡ b → Set) where J-elim : (d : (a : A) → C a a refl) → (a b : A) → (p : a ≡ b) → C a b p J-elim d a .a refl = d a -- implementation of the Paulin-Mohring version of J (based bath induction) module _ (a₀ : A) (C : (b : A) → a₀ ≡ b → Set) where J-elim-PM : (d : C a₀ refl) → (b : A) → (p : a₀ ≡ b) → C b p J-elim-PM d b refl = d -- this is "Axiom K" (which is disabled in the options) module _ (a₀ : A) (C : a₀ ≡ a₀ → Set) where K : (d : C refl) → (p : a₀ ≡ a₀) → C p K d p = {!p!} -- Caveat: -- judgmental equality in Agda: = but on paper: ≡ -- path type in Agda: ≡ but on paper: = record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field fst : A snd : B fst open Σ public infixr 4 _,_ _×_ : (A B : Set) → Set A × B = Σ A (λ _ → B) {- Exercise 5 For a given function f : A -> B, a *pointwise left inverse* is a function g : B -> A such that (a : A) -> g (f a) = a. Show: If f has a pointwise left inverse then, for all a,b : A, the function ap_f {a} {b} has a pointwise left inverse. (Does the other direction hold as well?) Solution of the easy part: -} has-ptw-left-inv : {A B : Set} → (f : A → B) → Set has-ptw-left-inv {A} {B} f = Σ (B → A) λ g → (a : A) → g (f a) ≡ a ptw-left-inv-ap : {A B : Set} → (f : A → B) → has-ptw-left-inv f → {a₁ a₂ : A} → has-ptw-left-inv (ap f {a₁} {a₂}) ptw-left-inv-ap f (g , g∘f) {a₁} {a₂} = (λ q → (g∘f a₁ ⁻¹) ∙ ap g {f a₁} {f a₂} q ∙ g∘f a₂) , λ {refl → sym-refl (g∘f a₁) } {- Exercise 6: a1 a2 : A, b1 b2 : B (a1 , b1) ≡ (a2 , b2) is equivalent to (a1 = a2) × (b1 = b2). Exercise 7: eqv2iso : isEqv(f) -> isIso(f) [easy] iso2eqv : isIso(f) -> isEqv(f) [hard] -} module _ (A B : Set) (g : B → A) (a b : B) where lemma : (pair1 pair2 : Σ A λ x → x ≡ g a) → pair1 ≡ pair2 lemma (.(g a) , refl) (.(g a) , refl) = refl wrong : (pair1 pair2 : Σ A λ x → g a ≡ g b) → pair1 ≡ pair2 wrong (x1 , p1) (x2 , p2) = {!p1!} split-equality : {x y : A × B} → x ≡ y → (fst x ≡ fst y) × (snd x ≡ snd y) split-equality = {!!} combine-equalities : {x y : A × B} → (fst x ≡ fst y) × (snd x ≡ snd y) → x ≡ y combine-equalities = {!!}
{ "alphanum_fraction": 0.4974641676, "avg_line_length": 24.781420765, "ext": "agda", "hexsha": "9fc55a7140fc88c34132227b51fafd1d5690c867", "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": "f328e596d98a7d052b34144447dd14de0f57e534", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FoxySeta/mgs-2021", "max_forks_repo_path": "Homotopy Type Theory/exercises.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z", "max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "FoxySeta/mgs-2021", "max_issues_repo_path": "Homotopy Type Theory/exercises.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FoxySeta/mgs-2021", "max_stars_repo_path": "Homotopy Type Theory/exercises.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1977, "size": 4535 }
module par-swap.dpg-pot where open import Data.Empty open import Data.Product open import Data.Sum open import Data.Bool open import Data.List using ([] ; [_] ; _∷_ ; List ; _++_) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym) open import Data.Maybe using () open import Data.List.Any using (here ; there) open import Data.List.Any.Properties using ( ++-comm ; ++⁻ ; ++⁺ˡ ; ++⁺ʳ ) open import Data.Nat as Nat using (ℕ) open import par-swap open import par-swap.properties open import Esterel.Lang.CanFunction open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Lang.CanFunction.Plug open import Esterel.Environment as Env open import Esterel.Context open import utility open import sn-calculus open import context-properties -- get view, E-views open import sn-calculus-props open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ) open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) canₛ-par : ∀ r₁ r₂ -> ∀ (θ : Env) (S : ℕ) → S ∈ Canₛ (r₂ ∥ r₁) θ → S ∈ Canₛ (r₁ ∥ r₂) θ canₛ-par r₁ r₂ θ S S∈r₂∥r₁ = ++-comm (proj₁ (Can r₂ θ)) (proj₁ (Can r₁ θ)) S∈r₂∥r₁ canₖ-par : ∀ r₁ r₂ -> ∀ (θ : Env) (k : Code) → k ∈ Canₖ (r₂ ∥ r₁) θ → k ∈ Canₖ (r₁ ∥ r₂) θ canₖ-par = \ {r₁ r₂ θ S S∈r₂∥r₁ -> thing S (proj₁ (proj₂ (Can r₁ θ))) (proj₁ (proj₂ (Can r₂ θ))) S∈r₂∥r₁} where simplify-foldr++-[] : ∀ (l2 : List Code) -> (Data.List.foldr{A = (List Code)} _++_ [] (Data.List.map (λ (k : Code) → []) l2)) ≡ [] simplify-foldr++-[] [] = refl simplify-foldr++-[] (x ∷ l2) = simplify-foldr++-[] l2 whatevs-left : ∀ S (whatevs : Code -> Code) l1 l2 -> Data.List.Any.Any (_≡_ S) (Data.List.foldr _++_ [] (Data.List.map (λ k → Data.List.map (Code._⊔_ k) l2) l1)) -> Data.List.Any.Any (_≡_ S) (Data.List.foldr _++_ [] (Data.List.map (λ k → (whatevs k) ∷ Data.List.map (Code._⊔_ k) l2) l1)) whatevs-left S whatevs [] l2 () whatevs-left S whatevs (x ∷ l1) l2 blob with ++⁻ (Data.List.map (Code._⊔_ x) l2) blob ... | inj₁ y = there (++⁺ˡ y) ... | inj₂ y with whatevs-left S whatevs l1 l2 y ... | R = there (++⁺ʳ (Data.List.map (Code._⊔_ x) l2) R) whatevs-right : ∀ S (whatevs : Code -> List Code) x l1 -> Data.List.Any.Any (_≡_ S) (Data.List.map (Code._⊔_ x) l1) -> Data.List.Any.Any (_≡_ S) (Data.List.foldr _++_ [] (Data.List.map (λ k → (k Code.⊔ x) ∷ whatevs k) l1)) whatevs-right S whatevs x [] blob = blob whatevs-right S whatevs x (x₁ ∷ l1) (here px) rewrite px = here (Code.⊔-comm x x₁) whatevs-right S whatevs x (x₁ ∷ l1) (there blob) = there (++⁺ʳ (whatevs x₁) (whatevs-right S whatevs x l1 blob)) thing : ∀ S l1 l2 -> Data.List.Any.Any (_≡_ S) (Data.List.foldr _++_ [] (Data.List.map (λ k → Data.List.map (Code._⊔_ k) l1) l2)) -> Data.List.Any.Any (_≡_ S) (Data.List.foldr _++_ [] (Data.List.map (λ k → Data.List.map (Code._⊔_ k) l2) l1)) thing S l1 [] blob rewrite simplify-foldr++-[] l1 = blob thing S l1 (x ∷ l2) blob with ++⁻ (Data.List.map (Code._⊔_ x) l1) blob thing S l1 (x ∷ l2) _ | inj₁ y = whatevs-right S (λ { k → Data.List.map (Code._⊔_ k) l2 }) x l1 y thing S l1 (x ∷ l2) _ | inj₂ y = whatevs-left S (\ { k -> (k Code.⊔ x)}) l1 l2 (thing S l1 l2 y) canₛₕ-par : ∀ r₁ r₂ -> ∀ (θ : Env) → Canₛₕ (r₂ ∥ r₁) θ ⊆¹ Canₛₕ (r₁ ∥ r₂) θ canₛₕ-par r₁ r₂ θ S S∈r₂∥r₁ = ++-comm (proj₂ (proj₂ (Can r₂ θ))) (proj₂ (proj₂ (Can r₁ θ))) S∈r₂∥r₁ canθₛ-C-par : ∀ sigs S'' -> ∀ {C p r₁ r₂} -> p ≐ C ⟦ r₁ ∥ r₂ ⟧c -> ∀ {θ} S' -> S' ∉ Canθₛ sigs S'' p θ -> S' ∉ Canθₛ sigs S'' (C ⟦ r₂ ∥ r₁ ⟧c) θ canθₛ-C-par sigs S'' {C} {p} {r₁} {r₂} pC {θ} S' S'∉Canθₛ[p] S'∈Canθₛ[C⟦r₂∥r₁⟧c] with canθₛ-plug S'' sigs C (r₁ ∥ r₂) (r₂ ∥ r₁) (canₛ-par r₁ r₂) (canₖ-par r₁ r₂) θ S' ... | r₂r₁->r₁r₂ rewrite sym (unplugc pC) = S'∉Canθₛ[p] (r₂r₁->r₁r₂ S'∈Canθₛ[C⟦r₂∥r₁⟧c]) canθₛₕ-C-par : ∀ sigs S' -> ∀ {C p r₁ r₂} -> p ≐ C ⟦ r₁ ∥ r₂ ⟧c -> ∀ {θ} s' -> s' ∉ Canθₛₕ sigs S' p θ -> s' ∉ Canθₛₕ sigs S' (C ⟦ r₂ ∥ r₁ ⟧c) θ canθₛₕ-C-par sigs S' {C} {p} {r₁} {r₂} pC {θ} s' s'∉Canθₛₕ[p] s'∈Canθₛₕ[C⟦r₂∥r₁⟧c] with canθₛₕ-plug S' sigs C (r₁ ∥ r₂) (r₂ ∥ r₁) (canₛₕ-par r₁ r₂) (canₖ-par r₁ r₂) (canₛ-par r₁ r₂) θ s' ... | r₂r₁->r₁r₂ rewrite sym (unplugc pC) = s'∉Canθₛₕ[p] (r₂r₁->r₁r₂ s'∈Canθₛₕ[C⟦r₂∥r₁⟧c]) DPG-pot-view : ∀ {C r₁ r₂ p q θ θ' A A'} -> p ≐ C ⟦ r₁ ∥ r₂ ⟧c -> (psn⟶₁q : ρ⟨ θ , A ⟩· p sn⟶₁ ρ⟨ θ' , A' ⟩· q) -> (p≡q : p ≡ q) -> (A≡A' : A ≡ A') -> ->pot-view psn⟶₁q p≡q A≡A' -> Σ[ dd′ ∈ Term × Term ] (ρ⟨ θ , A ⟩· C ⟦ r₂ ∥ r₁ ⟧c sn⟶ (proj₂ dd′)) × ((proj₂ dd′) sn⟶* (proj₁ dd′)) × ((ρ⟨ θ' , A' ⟩· q) ∥R* (proj₁ dd′)) DPG-pot-view pC (ris-present S∈ x x₁) p≡q A≡A' () DPG-pot-view pC (ris-absent S∈ x x₁) p≡q A≡A' () DPG-pot-view pC (remit S∈ ¬S≡a x) p≡q A≡A' () DPG-pot-view pC (rraise-shared e' x) p≡q A≡A' () DPG-pot-view pC (rset-shared-value-old e' s∈ x x₁) p≡q A≡A' () DPG-pot-view pC (rset-shared-value-new e' s∈ x x₁) p≡q A≡A' () DPG-pot-view pC (rraise-var e' x₁) p≡q A≡A' () DPG-pot-view pC (rset-var x∈ e' x₁) p≡q A≡A' () DPG-pot-view pC (rif-false x∈ x₁ x₂) p≡q A≡A' () DPG-pot-view pC (rif-true x∈ x₁ x₂) p≡q A≡A' () DPG-pot-view pC (rabsence{θ}{_}{S} S∈ x x₁) .refl .refl (vabsence .S .S∈ .x .x₁) = _ , rcontext [] dchole (rabsence{θ}{_}{S} S∈ x (canθₛ-C-par (sig θ) 0 pC (Signal.unwrap S) x₁)) , rrefl , Context1-∥R* (cenv _ _) (∥Rn (∥Rstep pC) ∥R0) DPG-pot-view pC (rreadyness{θ}{_}{s} s∈ x x₁) .refl .refl (vreadyness .s .s∈ .x .x₁) = _ , rcontext [] dchole (rreadyness{s = s} s∈ x (canθₛₕ-C-par (sig θ) 0 pC (SharedVar.unwrap s) x₁)) , rrefl , Context1-∥R* (cenv _ _) (∥Rn (∥Rstep pC) ∥R0) DPG-pot-view pC (rmerge x) p≡q A≡A' ()
{ "alphanum_fraction": 0.5636694817, "avg_line_length": 32.8206521739, "ext": "agda", "hexsha": "103a873656a066d756994221ed57155022748f09", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/par-swap/dpg-pot.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "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": "florence/esterel-calculus", "max_issues_repo_path": "agda/par-swap/dpg-pot.agda", "max_line_length": 90, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/par-swap/dpg-pot.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 2855, "size": 6039 }
module Pi.NoRepeat where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality open import Pi.Syntax open import Pi.Opsem open import Pi.AuxLemmas import RevNoRepeat -- Forward deterministic deterministic : ∀ {st st₁ st₂} → st ↦ st₁ → st ↦ st₂ → st₁ ≡ st₂ deterministic (↦₁ {b = b₁}) (↦₁ {b = b₂}) with base-is-prop _ b₁ b₂ ... | refl = refl deterministic ↦₂ ↦₂ = refl deterministic ↦₃ ↦₃ = refl deterministic ↦₄ ↦₄ = refl deterministic ↦₅ ↦₅ = refl deterministic ↦₆ ↦₆ = refl deterministic ↦₇ ↦₇ = refl deterministic ↦₈ ↦₈ = refl deterministic ↦₉ ↦₉ = refl deterministic ↦₁₀ ↦₁₀ = refl deterministic ↦₁₁ ↦₁₁ = refl deterministic ↦₁₂ ↦₁₂ = refl -- Backward deterministic deterministicᵣₑᵥ : ∀ {st st₁ st₂} → st₁ ↦ st → st₂ ↦ st → st₁ ≡ st₂ deterministicᵣₑᵥ {[ c ∣ _ ∣ κ ]} {⟨ c ∣ v ∣ κ ⟩} {⟨ c' ∣ v' ∣ κ' ⟩} ↦₁ r with Lemma₁ r ... | refl , refl with Lemma₂ r deterministicᵣₑᵥ {[ unite₊l ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ y ∣ κ ⟩} {⟨ _ ∣ inj₂ y ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ uniti₊l ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {⟨ _ ∣ v ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ swap₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₁ x ∣ κ ⟩} {⟨ _ ∣ inj₁ x ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ swap₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ y ∣ κ ⟩} {⟨ _ ∣ inj₂ y ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₁ x ∣ κ ⟩} {⟨ _ ∣ inj₁ x ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₁ x ∣ κ ⟩} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩} ↦₁ () | refl , refl | refl , refl deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₁ x ∣ κ ⟩} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩} ↦₁ () | refl , refl | refl , refl deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩} {⟨ _ ∣ inj₂ (inj₁ y) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩} {⟨ _ ∣ inj₂ (inj₂ z) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ z ∣ κ ⟩} {⟨ _ ∣ inj₁ (inj₁ x) ∣ κ ⟩} ↦₁ () | refl , refl | refl , refl deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ z ∣ κ ⟩} {⟨ _ ∣ inj₁ (inj₂ y) ∣ κ ⟩} ↦₁ () | refl , refl | refl , refl deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ z ∣ κ ⟩} {⟨ _ ∣ inj₂ z ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ unite⋆l ∣ _ ∣ κ ]} {⟨ _ ∣ (tt , v) ∣ κ ⟩} {⟨ _ ∣ (tt , v) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ uniti⋆l ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {⟨ _ ∣ v ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ swap⋆ ∣ _ ∣ κ ]} {⟨ _ ∣ (x , y) ∣ κ ⟩} {⟨ _ ∣ (x , y) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocl⋆ ∣ _ ∣ κ ]} {⟨ _ ∣ (x , (y , z)) ∣ κ ⟩} {⟨ _ ∣ (x , (y , z)) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ assocr⋆ ∣ _ ∣ κ ]} {⟨ _ ∣ ((x , y) , z) ∣ κ ⟩} {⟨ _ ∣ ((x , y) , z) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ dist ∣ _ ∣ κ ]} {⟨ _ ∣ (inj₁ x , z) ∣ κ ⟩} {⟨ _ ∣ (inj₁ x , z) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ dist ∣ _ ∣ κ ]} {⟨ _ ∣ (inj₂ y , z) ∣ κ ⟩} {⟨ _ ∣ (inj₂ y , z) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ factor ∣ _ ∣ κ ]} {⟨ _ ∣ inj₁ (x , z) ∣ κ ⟩} {⟨ _ ∣ inj₁ (x , z) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ factor ∣ _ ∣ κ ]} {⟨ _ ∣ inj₂ (y , z) ∣ κ ⟩} {⟨ _ ∣ inj₂ (y , z) ∣ κ ⟩} ↦₁ ↦₁ | refl , refl | refl , refl = refl deterministicᵣₑᵥ {[ unite₊l ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ uniti₊l ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ swap₊ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ assocl₊ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ assocr₊ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ unite⋆l ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ uniti⋆l ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ swap⋆ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ assocl⋆ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ assocr⋆ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ dist ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ factor ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} ↦₁ () deterministicᵣₑᵥ {[ id↔ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} (↦₁ {b = ()}) deterministicᵣₑᵥ {[ c₁ ⨾ c₂ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} (↦₁ {b = ()}) deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} (↦₁ {b = ()}) deterministicᵣₑᵥ {[ c₁ ⊗ c₂ ∣ _ ∣ κ ]} {⟨ _ ∣ v ∣ κ ⟩} {[ c' ∣ v' ∣ κ' ]} (↦₁ {b = ()}) deterministicᵣₑᵥ ↦₂ ↦₂ = refl deterministicᵣₑᵥ ↦₃ ↦₃ = refl deterministicᵣₑᵥ ↦₄ ↦₄ = refl deterministicᵣₑᵥ ↦₅ ↦₅ = refl deterministicᵣₑᵥ ↦₆ ↦₆ = refl deterministicᵣₑᵥ ↦₇ ↦₇ = refl deterministicᵣₑᵥ ↦₈ ↦₈ = refl deterministicᵣₑᵥ ↦₉ ↦₉ = refl deterministicᵣₑᵥ ↦₁₀ ↦₁₀ = refl deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₁ v ∣ κ ]} {_} {⟨ c₁' ⊕ c₂' ∣ v' ∣ κ' ⟩} ↦₁₁ r with Lemma₁ r ... | refl , refl with Lemma₂ r ... | refl , refl with Lemma₃ r ... | inj₂ refl with Lemma₄ r ... | inj₁ () ... | inj₂ () deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₁ v ∣ κ ]} {[ c₁ ∣ v ∣ ☐⊕ c₂ • κ ]} {[ c₁ ∣ v ∣ ☐⊕ c₂ • κ ]} ↦₁₁ ↦₁₁ = refl deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₂ y ∣ κ ]} {[ c₂ ∣ y ∣ c₁ ⊕☐• κ ]} {⟨ c ∣ x ∣ x₁ ⟩} ↦₁₂ r with Lemma₁ r ... | refl , refl with Lemma₂ r ... | refl , refl with Lemma₃ r ... | inj₂ refl with Lemma₄ r ... | inj₂ () deterministicᵣₑᵥ {[ c₁ ⊕ c₂ ∣ inj₂ y ∣ κ ]} {[ c₂ ∣ y ∣ c₁ ⊕☐• κ ]} {[ c₂ ∣ y ∣ (c₁ ⊕☐• κ) ]} ↦₁₂ ↦₁₂ = refl -- Non-repeating Lemma open RevNoRepeat (record { State = State ; _↦_ = _↦_ ; deterministic = deterministic ; deterministicᵣₑᵥ = deterministicᵣₑᵥ }) public
{ "alphanum_fraction": 0.4781416603, "avg_line_length": 66.3131313131, "ext": "agda", "hexsha": "0fd416dd4835797291f184fbf25a6681a43c8d0c", "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": "Pi/NoRepeat.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": "Pi/NoRepeat.agda", "max_line_length": 136, "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": "Pi/NoRepeat.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": 3914, "size": 6565 }
module examplesPaperJFP.BasicIO where open import Data.Maybe hiding ( _>>=_ ) open import Data.Sum renaming (inj₁ to left; inj₂ to right; [_,_]′ to either) open import Function open import examplesPaperJFP.NativeIOSafe open import examplesPaperJFP.triangleRightOperator module _ where -- for indentation record IOInterface : Set₁ where field Command : Set Response : (c : Command) → Set open IOInterface public module _ {C : Set} {R : C → Set} (let I = record { Command = C; Response = R } ) where module Postulated {I : IOInterface} (let C = Command I) (let R = Response I) where postulate IO : (I : IOInterface) (A : Set) → Set exec : ∀{A} (c : C) (f : R c → IO I A) → IO I A return : ∀{A} (a : A) → IO I A _>>=_ : ∀{A B} (m : IO I A) (k : A → IO I B) → IO I B mutual record IO I A : Set where coinductive constructor delay field force : IO′ I A data IO′ I A : Set where exec′ : (c : Command I) (f : Response I c → IO I A) → IO′ I A return′ : (a : A) → IO′ I A open IO public delay′ : ∀{I A} → IO′ I A → IO I A force (delay′ x) = x module _ {I : IOInterface} (let C = Command I) (let R = Response I) where -- module _ {I : IOInterface} (let record { Command = C; Response = R } = I) where -- module _ {I : IOInterface} (let ioInterface C R = I) where exec : ∀{A} (c : C) (f : R c → IO I A) → IO I A force (exec c f) = exec′ c f return : ∀{A} (a : A) → IO I A force (return a) = return′ a infixl 2 _>>=_ _>>=_ : ∀{A B} (m : IO I A) (k : A → IO I B) → IO I B force (m >>= k) with force m ... | exec′ c f = exec′ c λ x → f x >>= k ... | return′ a = force (k a) module _ {I : IOInterface} (let C = Command I) (let R = Response I) where {-# NON_TERMINATING #-} translateIO : ∀ {A} (tr : (c : C) → NativeIO (R c)) → IO I A → NativeIO A translateIO tr m = force m ▹ λ { (exec′ c f) → (tr c) native>>= λ r → translateIO tr (f r) ; (return′ a) → nativeReturn a } -- Recursion -- trampoline provides a generic form of loop (generalizing while/repeat). -- Starting at state s : S, step function f is iterated until it returns -- a result in A. module _ (I : IOInterface)(let C = Command I) (let R = Response I) where data IO+ (A : Set) : Set where exec′ : (c : C) (f : R c → IO I A) → IO+ A module _ {I : IOInterface}(let C = Command I) (let R = Response I) where fromIO+′ : ∀{A} → IO+ I A → IO′ I A fromIO+′ (exec′ c f) = exec′ c f fromIO+ : ∀{A} → IO+ I A → IO I A force (fromIO+ (exec′ c f)) = exec′ c f _>>=+′_ : ∀{A B} (m : IO+ I A) (k : A → IO I B) → IO′ I B exec′ c f >>=+′ k = exec′ c λ x → f x >>= k _>>=+_ : ∀{A B} (m : IO+ I A) (k : A → IO I B) → IO I B force (m >>=+ k) = m >>=+′ k mutual _>>+_ : ∀{A B} (m : IO I (A ⊎ B)) (k : A → IO I B) → IO I B force (m >>+ k) = force m >>+′ k _>>+′_ : ∀{A B} (m : IO′ I (A ⊎ B)) (k : A → IO I B) → IO′ I B exec′ c f >>+′ k = exec′ c λ x → f x >>+ k return′ (left a) >>+′ k = force (k a) return′ (right b) >>+′ k = return′ b -- loop {-# TERMINATING #-} trampoline : ∀{A S} (f : S → IO+ I (S ⊎ A)) (s : S) → IO I A force (trampoline f s) = case (f s) of \ { (exec′ c k) → exec′ c λ r → k r >>+ trampoline f } -- simple infinite loop {-# TERMINATING #-} forever : ∀{A B} → IO+ I A → IO I B force (forever (exec′ c f)) = exec′ c λ r → f r >>= λ _ → forever (exec′ c f) whenJust : {A : Set} → Maybe A → (A → IO I Unit) → IO I Unit whenJust nothing k = return _ whenJust (just a) k = k a main : NativeIO Unit main = nativePutStrLn "Hello, world!"
{ "alphanum_fraction": 0.5038839979, "avg_line_length": 30.171875, "ext": "agda", "hexsha": "df81469c4ebaf5ff47d733345f6b7d09f7d03506", "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/examplesPaperJFP/BasicIO.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/examplesPaperJFP/BasicIO.agda", "max_line_length": 82, "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/examplesPaperJFP/BasicIO.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": 1435, "size": 3862 }
module _ where data Nat : Set where zero : Nat suc : Nat → Nat data L : Nat → Set where nil : L zero cons : ∀ n → L n → L (suc n) pattern one = cons .zero nil
{ "alphanum_fraction": 0.5813953488, "avg_line_length": 13.2307692308, "ext": "agda", "hexsha": "faadab36c7e0483d08213a6ef93ad348e5c51ce1", "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/NoDotInPatSyn.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/NoDotInPatSyn.agda", "max_line_length": 30, "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/NoDotInPatSyn.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 61, "size": 172 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Integer division ------------------------------------------------------------------------ module Data.Nat.DM where open import Data.Fin as Fin using (Fin; toℕ) import Data.Fin.Properties as FinP open import Data.Nat as Nat open import Data.Nat.Properties as NatP open import Data.Nat.Properties.Simple open import Relation.Nullary.Decidable open import Relation.Binary.PropositionalEquality as P using (_≡_) import Relation.Binary.PropositionalEquality.TrustMe as TrustMe using (erase) open NatP.SemiringSolver open P.≡-Reasoning open Nat.≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≡⟨_⟩′_) infixl 7 _div_ _mod_ _divMod_ -- Integer division. private div-helper : ℕ → ℕ → ℕ → ℕ → ℕ div-helper acc s zero n = acc div-helper acc s (suc d) zero = div-helper (suc acc) s d s div-helper acc s (suc d) (suc n) = div-helper acc s d n -- {-# BUILTIN NATDIVSUCAUX div-helper #-} _div_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ (d div 0) {} (d div suc s) = div-helper 0 s d s -- The remainder after integer division. private mod-helper : ℕ → ℕ → ℕ → ℕ → ℕ mod-helper acc s zero n = acc mod-helper acc s (suc d) zero = mod-helper zero s d s mod-helper acc s (suc d) (suc n) = mod-helper (suc acc) s d n -- {-# BUILTIN NATMODSUCAUX mod-helper #-} -- The remainder is not too large. mod-lemma : (acc d n : ℕ) → let s = acc + n in mod-helper acc s d n ≤ s mod-lemma acc zero n = start acc ≤⟨ m≤m+n acc n ⟩ acc + n □ mod-lemma acc (suc d) zero = start mod-helper zero (acc + 0) d (acc + 0) ≤⟨ mod-lemma zero d (acc + 0) ⟩ acc + 0 □ mod-lemma acc (suc d) (suc n) = P.subst (λ x → mod-helper (suc acc) x d n ≤ x) (P.sym (+-suc acc n)) (mod-lemma (suc acc) d n) _mod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → Fin divisor (d mod 0) {} (d mod suc s) = Fin.fromℕ≤″ (mod-helper 0 s d s) (Nat.erase (≤⇒≤″ (s≤s (mod-lemma 0 d s)))) -- Integer division with remainder. private -- The quotient and remainder are related to the dividend and -- divisor in the right way. division-lemma : (mod-acc div-acc d n : ℕ) → let s = mod-acc + n in mod-acc + div-acc * suc s + d ≡ mod-helper mod-acc s d n + div-helper div-acc s d n * suc s division-lemma mod-acc div-acc zero n = begin mod-acc + div-acc * suc s + zero ≡⟨ +-right-identity _ ⟩ mod-acc + div-acc * suc s ∎ where s = mod-acc + n division-lemma mod-acc div-acc (suc d) zero = begin mod-acc + div-acc * suc s + suc d ≡⟨ solve 3 (λ mod-acc div-acc d → let s = mod-acc :+ con 0 in mod-acc :+ div-acc :* (con 1 :+ s) :+ (con 1 :+ d) := (con 1 :+ div-acc) :* (con 1 :+ s) :+ d) P.refl mod-acc div-acc d ⟩ suc div-acc * suc s + d ≡⟨ division-lemma zero (suc div-acc) d s ⟩ mod-helper zero s d s + div-helper (suc div-acc) s d s * suc s ≡⟨⟩ mod-helper mod-acc s (suc d) zero + div-helper div-acc s (suc d) zero * suc s ∎ where s = mod-acc + 0 division-lemma mod-acc div-acc (suc d) (suc n) = begin mod-acc + div-acc * suc s + suc d ≡⟨ solve 4 (λ mod-acc div-acc n d → mod-acc :+ div-acc :* (con 1 :+ (mod-acc :+ (con 1 :+ n))) :+ (con 1 :+ d) := con 1 :+ mod-acc :+ div-acc :* (con 2 :+ mod-acc :+ n) :+ d) P.refl mod-acc div-acc n d ⟩ suc mod-acc + div-acc * suc s′ + d ≡⟨ division-lemma (suc mod-acc) div-acc d n ⟩ mod-helper (suc mod-acc) s′ d n + div-helper div-acc s′ d n * suc s′ ≡⟨ P.cong (λ s → mod-helper (suc mod-acc) s d n + div-helper div-acc s d n * suc s) (P.sym (+-suc mod-acc n)) ⟩ mod-helper (suc mod-acc) s d n + div-helper div-acc s d n * suc s ≡⟨⟩ mod-helper mod-acc s (suc d) (suc n) + div-helper div-acc s (suc d) (suc n) * suc s ∎ where s = mod-acc + suc n s′ = suc mod-acc + n -- A specification of integer division. record DivMod (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} : Set where constructor result field quotient : ℕ remainder : Fin divisor property : dividend ≡ toℕ remainder + quotient * divisor div-eq : _div_ dividend divisor {≢0} ≡ quotient mod-eq : _mod_ dividend divisor {≢0} ≡ remainder _divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → DivMod dividend divisor {≢0} (d divMod 0) {} (d divMod suc s) = result (d div suc s) (d mod suc s) (TrustMe.erase (begin d ≡⟨ division-lemma 0 0 d s ⟩ mod-helper 0 s d s + div-helper 0 s d s * suc s ≡⟨ P.cong₂ _+_ (P.sym (FinP.toℕ-fromℕ≤ lemma)) P.refl ⟩ toℕ (Fin.fromℕ≤ lemma) + div-helper 0 s d s * suc s ≡⟨ P.cong (λ n → toℕ n + div-helper 0 s d s * suc s) (FinP.fromℕ≤≡fromℕ≤″ lemma _) ⟩ toℕ (Fin.fromℕ≤″ _ lemma′) + div-helper 0 s d s * suc s ∎)) _≡_.refl _≡_.refl where lemma = s≤s (mod-lemma 0 d s) lemma′ = Nat.erase (≤⇒≤″ lemma)
{ "alphanum_fraction": 0.4636083644, "avg_line_length": 34.6573033708, "ext": "agda", "hexsha": "ea73779e00ce8a31d3024fed9d1b932a82707134", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "Data/Nat/DM.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "Data/Nat/DM.agda", "max_line_length": 144, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "Data/Nat/DM.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 1930, "size": 6169 }
{-# OPTIONS --without-K #-} {- Our goal in this file is to observe some structure possessed by the universes of types, reflexive graphs, type families, and so on. Somewhat more precisely, we develop an imperfect structure of internal model of type theory, with enough ingredients to get some type theoretic developments off the ground. We begin with the basic structure of type dependency, with operations for context extension, weakening, substitution, and identity morphisms (the `variable rule'). Once this structure is implemented, we introduce the structure of usual type constructors Σ, Π, Id, the unit type, and ℕ. The reason this is an `imperfect' notion of model structure is that in our internal model structure, we have identifications in the role of judgmental equalities. This leads to the usual coherence problem, which we do not attempt to solve. As we said before, our goal is merely to postulate enough equalities so that we can introduce and work with the type constructors. We then proceed to develop some examples. -} module models where import Lecture15 open Lecture15 public Contexts : ( l : Level) → UU (lsuc l) Contexts l = UU l Families : { l1 : Level} (l2 : Level) (ctx : Contexts l1) → UU (l1 ⊔ (lsuc l2)) Families l2 ctx = ctx → UU l2 Terms : { l1 l2 : Level} (l3 : Level) ( ctx : Contexts l1) (fam : Families l2 ctx) → UU (l1 ⊔ (l2 ⊔ (lsuc l3))) Terms l3 ctx fam = (Γ : ctx) → (fam Γ) → UU l3 Context-Extensions : { l1 l2 : Level} ( ctx : Contexts l1) (fam : Families l2 ctx) → UU (l1 ⊔ l2) Context-Extensions ctx fam = (Γ : ctx) → (fam Γ) → ctx Family-Extensions : { l1 l2 : Level} ( ctx : Contexts l1) (fam : Families l2 ctx) ( ctx-ext : Context-Extensions ctx fam) → UU (l1 ⊔ l2) Family-Extensions ctx fam ctx-ext = ( Γ : ctx) → (A : fam Γ) → (fam (ctx-ext Γ A)) → fam Γ Model-Base : ( l1 l2 l3 : Level) → UU (lsuc l1 ⊔ (lsuc l2 ⊔ lsuc l3)) Model-Base l1 l2 l3 = Σ ( Contexts l1) ( λ ctx → Σ (Families l2 ctx) ( λ fam → Σ (Terms l3 ctx fam) ( λ tm → Σ (Context-Extensions ctx fam) (Family-Extensions ctx fam)))) Hom-Model-Base : { l1 l2 l3 l1' l2' l3' : Level} → Model-Base l1 l2 l3 → Model-Base l1' l2' l3' → UU _ Hom-Model-Base ( pair ctx (pair fam (pair tm (pair ctx-ext fam-ext)))) ( pair ctx' (pair fam' (pair tm' (pair ctx-ext' fam-ext')))) = Σ ( ctx → ctx') ( λ h-ctx → Σ ((Γ : ctx) → (fam Γ) → (fam' (h-ctx Γ))) ( λ h-fam → Σ ((Γ : ctx) (A : fam Γ) → (tm Γ A) → tm' (h-ctx Γ) (h-fam Γ A)) ( λ h-tm → Σ ( (Γ : ctx) (A : fam Γ) → Id ( h-ctx (ctx-ext Γ A)) ( ctx-ext' (h-ctx Γ) (h-fam Γ A))) ( λ h-ctx-ext → (Γ : ctx) (A : fam Γ) (B : fam (ctx-ext Γ A)) → Id ( h-fam Γ (fam-ext Γ A B)) ( fam-ext' ( h-ctx Γ) ( h-fam Γ A) ( tr fam' (h-ctx-ext Γ A) (h-fam (ctx-ext Γ A) B))))))) Assoc-Ctx-ext : { l1 l2 l3 : Level} (M : Model-Base l1 l2 l3) → UU (l1 ⊔ l2) Assoc-Ctx-ext (pair ctx (pair fam (pair tm (pair ctx-ext fam-ext)))) = ( Γ : ctx) (A : fam Γ) (B : fam (ctx-ext Γ A)) → Id (ctx-ext (ctx-ext Γ A) B) (ctx-ext Γ (fam-ext Γ A B)) Slice-Model-Base : { l1 l2 l3 : Level} (M : Model-Base l1 l2 l3) ( assoc : Assoc-Ctx-ext M) → ( Γ : pr1 M) → Model-Base l2 l2 l3 Slice-Model-Base ( pair ctx (pair fam (pair tm (pair ctx-ext fam-ext)))) assoc Γ = pair (fam Γ) ( pair (λ A → fam (ctx-ext Γ A)) ( pair (λ A B → tm (ctx-ext Γ A) B) ( pair (fam-ext Γ) ( λ A B C → fam-ext (ctx-ext Γ A) B (tr fam (inv (assoc Γ A B)) C))))) Empty-context : { l1 l2 l3 : Level} (M : Model-Base l1 l2 l3) → UU l1 Empty-context M = pr1 M Axiom-Empty-Context : { l1 l2 l3 : Level} (M : Model-Base l1 l2 l3) (empty-ctx : Empty-context M) → UU (l1 ⊔ l2) Axiom-Empty-Context ( pair ctx (pair fam (pair tm (pair ctx-ext fam-ext)))) empty-ctx = is-equiv (ctx-ext empty-ctx)
{ "alphanum_fraction": 0.5832308827, "avg_line_length": 36.3125, "ext": "agda", "hexsha": "223fbfdcba334d12f3a82c758436fd12c121b6f2", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "tadejpetric/HoTT-Intro", "max_forks_repo_path": "Agda/models.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "tadejpetric/HoTT-Intro", "max_issues_repo_path": "Agda/models.agda", "max_line_length": 78, "max_stars_count": 333, "max_stars_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "tadejpetric/HoTT-Intro", "max_stars_repo_path": "Agda/models.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 1410, "size": 4067 }
-- An ATP local hint can be only a postulate, function or a data -- constructor. -- This error is detected by Syntax.Translation.ConcreteToAbstract. module ATPBadLocalHint3 where postulate D : Set _≡_ : D → D → Set zero : D succ : D → D data N : D → Set where zN : N zero sN : ∀ {n} → N n → N (succ n) refl : ∀ n → N n → n ≡ n refl n Nn = prf where postulate prf : n ≡ n {-# ATP prove prf Nn #-}
{ "alphanum_fraction": 0.5804988662, "avg_line_length": 19.1739130435, "ext": "agda", "hexsha": "52d244cbeca51f2af18ff7086cd58ba2c1bce9ca", "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/ATPBadLocalHint3.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/ATPBadLocalHint3.agda", "max_line_length": 67, "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/ATPBadLocalHint3.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": 156, "size": 441 }
------------------------------------------------------------------------ -- The reader monad transformer ------------------------------------------------------------------------ -- The interface is based on that used by the "mtl" package on -- Hackage. {-# OPTIONS --without-K --safe #-} open import Equality module Monad.Reader {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open import Prelude open Derived-definitions-and-properties eq open import Monad eq -- The reader monad transformer, defined using a wrapper type to make -- instance resolution easier. record ReaderT {s} (S : Type s) (M : Type s → Type s) (A : Type s) : Type s where constructor wrap field run : S → M A open ReaderT public instance -- ReaderT is a "raw monad" transformer. raw-monad-transformer : ∀ {s} {S : Type s} → Raw-monad-transformer (ReaderT S) run (Raw-monad.return (Raw-monad-transformer.transform raw-monad-transformer) x) = λ _ → return x run (Raw-monad._>>=_ (Raw-monad-transformer.transform raw-monad-transformer) x f) = λ s → run x s >>= λ x → run (f x) s run (Raw-monad-transformer.liftʳ raw-monad-transformer m) = λ _ → m transform : ∀ {s} {S : Type s} {M} ⦃ is-raw-monad : Raw-monad M ⦄ → Raw-monad (ReaderT S M) transform = Raw-monad-transformer.transform raw-monad-transformer -- ReaderT is a monad transformer (assuming extensionality). monad-transformer : ∀ {s} {S : Type s} → Extensionality s s → Monad-transformer (ReaderT S) Monad.raw-monad (Monad-transformer.transform (monad-transformer _)) = Raw-monad-transformer.transform raw-monad-transformer Monad.left-identity (Monad-transformer.transform (monad-transformer ext)) x f = cong wrap (apply-ext ext λ s → (return x >>= λ x → run (f x) s) ≡⟨ left-identity _ _ ⟩∎ run (f x) s ∎) Monad.right-identity (Monad-transformer.transform (monad-transformer ext)) x = cong wrap (apply-ext ext λ s → run x s >>= return ≡⟨ right-identity _ ⟩∎ run x s ∎) Monad.associativity (Monad-transformer.transform (monad-transformer ext)) x f g = cong wrap (apply-ext ext λ s → (run x s >>= λ x → run (f x) s >>= λ x → run (g x) s) ≡⟨ associativity _ _ _ ⟩∎ ((run x s >>= λ x → run (f x) s) >>= λ x → run (g x) s) ∎) Monad-transformer.liftᵐ (monad-transformer _) = liftʳ Monad-transformer.lift-return (monad-transformer ext) x = cong wrap (apply-ext ext λ _ → return x ∎) Monad-transformer.lift->>= (monad-transformer ext) x f = cong wrap (apply-ext ext λ _ → x >>= f ∎) -- Returns the "state". ask : ∀ {s} {S : Type s} {M} ⦃ is-monad : Raw-monad M ⦄ → ReaderT S M S run ask = return -- Modifies the "state" in a given computation. local : ∀ {s} {S : Type s} {M A} ⦃ is-monad : Raw-monad M ⦄ → (S → S) → ReaderT S M A → ReaderT S M A run (local f m) = run m ∘ f
{ "alphanum_fraction": 0.5733464309, "avg_line_length": 30.2376237624, "ext": "agda", "hexsha": "6095dd129257091271cd76e8e5d36e2b1014b2f7", "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/Monad/Reader.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/Monad/Reader.agda", "max_line_length": 86, "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/Monad/Reader.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": 896, "size": 3054 }
open import Agda.Builtin.Equality open import Agda.Primitive record R a : Set (lsuc a) where field P : {A : Set a} → A → A → Set a r : ∀ ℓ → R ℓ R.P (r _) = _≡_ postulate cong : ∀ {a b} {A : Set a} {B : Set b} {x y : A} (f : A → B) → R.P (r a) x y → R.P (r b) (f x) (f y) magic : ∀ {a} {A : Set a} {x y : A} (z : A) → y ≡ z → x ≡ z record Raw-monad {f : Level → Level} (M : ∀ {ℓ} → Set ℓ → Set (f ℓ)) ℓ₁ ℓ₂ : Set (f ℓ₁ ⊔ f ℓ₂ ⊔ lsuc (ℓ₁ ⊔ ℓ₂)) where infixl 5 _>>=_ field return : {A : Set ℓ₁} → A → M A _>>=_ : {A : Set ℓ₁} {B : Set ℓ₂} → M A → (A → M B) → M B module Raw-monad⁺ {f : Level → Level} {M : ∀ {ℓ} → Set ℓ → Set (f ℓ)} (m : ∀ {ℓ₁ ℓ₂} → Raw-monad M ℓ₁ ℓ₂) where private module M′ {ℓ₁ ℓ₂} = Raw-monad (m {ℓ₁ = ℓ₁} {ℓ₂ = ℓ₂}) open M′ public using (_>>=_) return : ∀ {a} {A : Set a} → A → M A return = M′.return {ℓ₂ = lzero} open Raw-monad⁺ ⦃ … ⦄ public record Monad⁻ {f : Level → Level} (M : ∀ {ℓ} → Set ℓ → Set (f ℓ)) ⦃ raw-monad : ∀ {ℓ₁ ℓ₂} → Raw-monad M ℓ₁ ℓ₂ ⦄ ℓ₁ ℓ₂ ℓ₃ : Set (f ℓ₁ ⊔ f ℓ₂ ⊔ f ℓ₃ ⊔ lsuc (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃)) where field associativity : {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃} → (x : M A) (f : A → M B) (g : B → M C) → x >>= (λ x → f x >>= g) ≡ x >>= f >>= g module Monad⁻⁺ {f : Level → Level} {M : ∀ {ℓ} → Set ℓ → Set (f ℓ)} ⦃ raw-monad : ∀ {ℓ₁ ℓ₂} → Raw-monad M ℓ₁ ℓ₂ ⦄ (m : ∀ {ℓ₁ ℓ₂ ℓ₃} → Monad⁻ M ℓ₁ ℓ₂ ℓ₃) where private module M′ {ℓ₁ ℓ₂ ℓ₃} = Monad⁻ (m {ℓ₁ = ℓ₁} {ℓ₂ = ℓ₂} {ℓ₃ = ℓ₃}) open M′ public open Monad⁻⁺ ⦃ … ⦄ public data Maybe {a} (A : Set a) : Set a where nothing : Maybe A just : A → Maybe A postulate maybe : ∀ {a b} {A : Set a} {B : Maybe A → Set b} → ((x : A) → B (just x)) → B nothing → (x : Maybe A) → B x record MaybeT {ℓ} (f : Level → Level) (M : Set ℓ → Set (f ℓ)) (A : Set ℓ) : Set (f ℓ) where constructor wrap field run : M (Maybe A) open MaybeT instance transformʳ : ∀ {ℓ₁ ℓ₂} {f : Level → Level} {M : ∀ {ℓ} → Set ℓ → Set (f ℓ)} → ⦃ raw-monad : ∀ {ℓ₁ ℓ₂} → Raw-monad M ℓ₁ ℓ₂ ⦄ → Raw-monad (MaybeT f M) ℓ₁ ℓ₂ run (Raw-monad.return transformʳ x) = return (just x) run (Raw-monad._>>=_ transformʳ x f) = run x >>= maybe (λ x → run (f x)) (return nothing) transformᵐ : {f : Level → Level} {M : ∀ {ℓ} → Set ℓ → Set (f ℓ)} ⦃ raw-monad : ∀ {ℓ₁ ℓ₂} → Raw-monad M ℓ₁ ℓ₂ ⦄ ⦃ monad : ∀ {ℓ₁ ℓ₂ ℓ₃} → Monad⁻ M ℓ₁ ℓ₂ ℓ₃ ⦄ → Monad⁻ (MaybeT f M) lzero lzero lzero Monad⁻.associativity transformᵐ x f g = cong wrap ( magic ((run x >>= maybe (λ x → run (f x)) (return nothing)) >>= maybe (λ x → run (g x)) (return nothing)) (associativity _ _ _)) -- WAS: rejected in 2.6.0 with -- No instance of type Raw-monad _M_345 ℓ₁ ℓ₂ was found in scope. -- Should succeed.
{ "alphanum_fraction": 0.4826057299, "avg_line_length": 27.1481481481, "ext": "agda", "hexsha": "2025ad04931cf9f85ca11af138615d8c51347e8e", "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/Issue4066.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/Issue4066.agda", "max_line_length": 67, "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/Issue4066.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": 1358, "size": 2932 }
module Categories.2-Category.Categories where open import Level open import Data.Product open import Categories.Category open import Categories.2-Category open import Categories.Functor using (module Functor) renaming (id to idF; _∘_ to _∘F_) open import Categories.Functor.Constant open import Categories.FunctorCategory open import Categories.Bifunctor using (Bifunctor) open import Categories.NaturalTransformation open import Categories.Product using (Product) Categories : ∀ o ℓ e → 2-Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) (o ⊔ e) Categories o ℓ e = record { Obj = Category o ℓ e ; _⇒_ = Functors ; id = λ {A} → Constant {D = Functors A A} idF ; —∘— = my-∘ ; assoc = {!!} ; identityˡ = λ {A B} η → Heterogeneous.≡⇒∼ {C = Functors A B} {f = proj₂ η ∘₁ id} {proj₂ η} (Category.identityʳ B) ; identityʳ = λ {A B f g} η → Heterogeneous.≡⇒∼ {_} {_} {_} {C = Functors A B} {proj₁ f} {proj₁ g} {f = record { η = λ X → Category._∘_ B (Functor.F₁ (proj₁ g) (Category.id A)) (NaturalTransformation.η (proj₁ η) X); commute = λ {a} {b} h → let open Category.HomReasoning B in begin B [ B [ Functor.F₁ (proj₁ g) (Category.id A) ∘ NaturalTransformation.η (proj₁ η) b ] ∘ {!.Categories.NaturalTransformation.Core.F.F₁ (proj₁ f) (proj₁ g) h!} ] ↓⟨ {!!} ⟩ B [ Functor.F₁ {!!} {!!} ∘ B [ Functor.F₁ (proj₁ g) (Category.id A) ∘ NaturalTransformation.η (proj₁ η) a ] ] ∎ } } {proj₁ {_} {_} {_} {_} η} (Category.Equiv.trans B (Category.∘-resp-≡ˡ B (Functor.identity (proj₁ g))) (Category.identityˡ B)) } where my-∘ : {A B C : Category o ℓ e} → Bifunctor (Functors B C) (Functors A B) (Functors A C) my-∘ {A} {B} {C} = record { F₀ = uncurry′ _∘F_ ; F₁ = uncurry′ _∘₀_ ; identity = λ {Fs} → Category.Equiv.trans C (Category.identityʳ C) (Functor.identity (proj₁ Fs)) ; homomorphism = λ {_ _ _ f g} → Category.Equiv.sym C (interchange {α = proj₁ g} {proj₂ g} {proj₁ f} {proj₂ f}) ; F-resp-≡ = λ {_ _ f g} → my-resp {f = f} {g} } where PF = Product (Functors B C) (Functors A B) .my-resp : ∀ {F G} {f g : PF [ F , G ]} → PF [ f ≡ g ] → Functors A C [ uncurry′ _∘₀_ f ≡ uncurry _∘₀_ g ] my-resp {f = f₁ , f₂} {g₁ , g₂} (f₁≡g₁ , f₂≡g₂) = ∘₀-resp-≡ {f = f₁} {g₁} {f₂} {g₂} f₁≡g₁ f₂≡g₂
{ "alphanum_fraction": 0.4943181818, "avg_line_length": 58.6666666667, "ext": "agda", "hexsha": "cf3bc5cb5e3497645ad09ea5dc8c604fad020c47", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/2-Category/Categories.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/2-Category/Categories.agda", "max_line_length": 178, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/2-Category/Categories.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 917, "size": 2816 }
module Data.Num where open import Data.List using (List; []; _∷_; foldr) open import Data.Nat open ≤-Reasoning open import Data.Nat.Etc open import Data.Nat.DivMod open import Data.Nat.DivMod.Properties using (div-mono) open import Data.Nat.Properties using (m≤m+n; n≤m+n;_+-mono_; pred-mono; ∸-mono; ≰⇒>; n∸n≡0; +-∸-assoc; m+n∸n≡m) open import Data.Nat.Properties.Simple using (+-right-identity; +-suc; +-assoc; +-comm; distribʳ-*-+) open import Data.Fin.Properties using (bounded) open import Data.Fin using (Fin; fromℕ≤; inject≤; #_) renaming (toℕ to F→N; fromℕ to N→F; zero to Fz; suc to Fs) open import Data.Product open import Data.Maybe open import Induction.Nat using (rec; Rec) import Level open import Function open import Data.Unit using (tt) open import Relation.Nullary open import Relation.Nullary.Decidable using (True; False; toWitness; toWitnessFalse; fromWitness; fromWitnessFalse) open import Relation.Nullary.Negation using (contradiction; contraposition) open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; sym; trans; inspect) open PropEq.≡-Reasoning renaming (begin_ to beginEq_; _≡⟨_⟩_ to _≡Eq⟨_⟩_; _∎ to _∎Eq) -- Surjective (ℕm): -- base = 1, digits = {m ... (m + n) - 1}, m ≥ 1, n ≥ m -- base > 1, digits = {m ... (m + n) - 1}, m ≥ 0, n ≥ max base (base × m) -- Bijective: -- base ≥ 1, digits = {1 .. base} -- -- Digits: -- Digit m n represents a Digit ranging from m to (m + n - 1) -- e.g. Digit 2 0 2 = {0, 1} for ordinary binary number -- Digit 2 1 2 = {1, 2} for zeroless binary number -- Digit 2 0 3 = {0, 1, 2} for redundant binary number -- data Digit : (base from range : ℕ) → Set where -- unary digit: {0, 1 .. n-1} U0 : ∀ {n} → Fin n → {2≤n : True (2 ≤? n)} -- i.e. must have digit '1' → Digit 1 0 n -- unary digit: {m .. m+n-1} U1 : ∀ {m n} → Fin n → {m≤n : True (suc m ≤? n)} → Digit 1 (suc m) n -- k-adic digit: {m .. m+n-1} D : ∀ {b m n} → Fin n → let base = suc (suc b) in {b≤n : True (base ≤? n)} → {bm≤n : True ((base * m) ≤? n)} → Digit base m n -- without offset, {0 .. n-1} D→F : ∀ {b m n} → Digit b m n → Fin n D→F (U0 x) = x D→F (U1 x) = x D→F (D x) = x -- with offset, {m .. m+n-1} D→N : ∀ {b m n} → Digit b m n → ℕ D→N {m = m} d = m + F→N (D→F d) -- infix 4 _D≤_ -- _D<_ _≥′_ _>′_ -- data _D≤_ {b m n} (x : Digit b m n) : (y : Digit b m n) → Set where -- D≤-refl : x D≤ x -- D≤-step : ∀ {y} (xD≤y : x D≤ y) → x D≤ -- ≤′-step : ∀ {n} (m≤′n : m ≤′ n) → m ≤′ suc n private -- alias ℕ-isDecTotalOrder = DecTotalOrder.isDecTotalOrder decTotalOrder ℕ-isTotalOrder = IsDecTotalOrder.isTotalOrder ℕ-isDecTotalOrder ℕ-isPartialOrder = IsTotalOrder.isPartialOrder ℕ-isTotalOrder ℕ-isPreorder = IsPartialOrder.isPreorder ℕ-isPartialOrder ≤-refl = IsPreorder.reflexive ℕ-isPreorder ≤-antisym = IsPartialOrder.antisym ℕ-isPartialOrder ≤-total = IsTotalOrder.total ℕ-isTotalOrder -- helper function for adding two 'Fin n' with offset 'm' -- (m + x) + (m + y) - m = m + x + y D+sum : ∀ {n} (m : ℕ) → (x y : Fin n) → ℕ D+sum m x y = m + (F→N x) + (F→N y) maxpress-pred : ℕ → Set maxpress-pred _ = ℕ → ℕ maxpress-rec-struct : (x : ℕ) → Rec Level.zero maxpress-pred x → (bound : ℕ) → ℕ maxpress-rec-struct zero p bound = 0 maxpress-rec-struct (suc x) p bound with bound ≤? suc (p bound) maxpress-rec-struct (suc x) p bound | yes q = suc (p bound) ∸ bound maxpress-rec-struct (suc x) p bound | no ¬q = suc (p bound) -- if x ≥ bound, then substract bound from x, until x < bound maxpress : (x bound : ℕ) → ℕ maxpress = rec maxpress-pred maxpress-rec-struct maxpressed<bound : (x bound : ℕ) → (≢0 : False (bound ≟ 0)) → maxpress x bound < bound maxpressed<bound zero zero () maxpressed<bound zero (suc bound) ≢0 = s≤s z≤n maxpressed<bound (suc x) zero () maxpressed<bound (suc x) (suc bound) ≢0 with suc bound ≤? suc (maxpress x (suc bound)) maxpressed<bound (suc x) (suc bound) ≢0 | yes p = begin suc (maxpress x (suc bound) ∸ bound) ≤⟨ ≤-refl (sym (+-∸-assoc 1 p)) ⟩ suc (maxpress x (suc bound)) ∸ bound ≤⟨ ∸-mono {suc (maxpress x (suc bound))} {suc bound} {bound} {bound} (maxpressed<bound x (suc bound) tt) (≤-refl refl) ⟩ suc bound ∸ bound ≤⟨ ≤-refl (m+n∸n≡m 1 bound) ⟩ suc zero ≤⟨ s≤s z≤n ⟩ suc bound ∎ maxpressed<bound (suc x) (suc bound) ≢0 | no ¬p = ≰⇒> ¬p maxpress′ : (x bound : ℕ) → (≢0 : False (bound ≟ 0)) → Fin bound maxpress′ x bound ≢0 = fromℕ≤ {maxpress x bound} (maxpressed<bound x bound ≢0) _D+_ : ∀ {b m n} → Digit b m n → Digit b m n → Digit b m n _D+_ {zero} () () _D+_ {suc zero} x _ = x _D+_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) = D (maxpress′ (D+sum m x y) n n≢0) {b≤n} {bm≤n} where n≢0 = fromWitnessFalse $ >⇒≢ $ begin suc zero ≤⟨ s≤s z≤n ⟩ suc (suc b) ≤⟨ toWitness b≤n ⟩ n ∎ -- 2 ≤ base -- ⇒ max * 2 ≤ max * base -- ⇒ max * 2 / base ≤ max {- _D⊕_ : ∀ {b m n} → Digit b m n → Digit b m n → Maybe (Digit b m n) _D⊕_ (U0 x) y = just y _D⊕_ (U1 x) y = just y _D⊕_ {suc (suc b)} {m} {n} (D x) (D y) with suc (D+sum m x y) ≤? n _D⊕_ {suc (suc b)} {m} {n} (D x) (D y) | yes p = nothing _D⊕_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) | no ¬p with D+sum m x y divMod (suc (suc b)) | inspect (λ w → _divMod_ (D+sum m x y) (suc (suc b)) {≢0 = w}) tt _D⊕_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) | no ¬p | result quotient remainder property | PropEq.[ eq ] = let base = suc (suc b) sum = D+sum m x y quotient<n = begin suc quotient ≤⟨ div-mono base tt {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ n ∎ in just (D (fromℕ≤ {quotient} quotient<n) {b≤n} {bm≤n}) -} {- let base = suc (suc b) sum = D+sum m x y result quotient remainder property = _divMod_ sum base {tt} quotient<n = begin DivMod.quotient (sum divMod {! base !}) ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ n ∎ in just (D (fromℕ≤ {quotient} quotient<n) {b≤n} {bm≤n}) -} {- begin {! !} <⟨ {! !} ⟩ {! !} <⟨ {! !} ⟩ {! !} ∎ begin {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ∎ beginEq {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ∎Eq -} data System : (base from range : ℕ) → Set where Sys : ∀ {b m n} → List (Digit (suc b) m n) → System (suc b) m n {- _S+_ : ∀ {b m n} → System b m n → System b m n → System b m n Sys [] S+ Sys ys = Sys ys Sys xs S+ Sys [] = Sys xs Sys (x ∷ xs) S+ Sys (y ∷ ys) = {! x !} S→N : ∀ {b m n} → System b m n → ℕ S→N {zero} () S→N {suc b} (Sys list) = foldr (shift-then-add (suc b)) 0 list where shift-then-add : ∀ {m n} → (b : ℕ) → Digit b m n → ℕ → ℕ shift-then-add b x acc = (D→N x) + (acc * b) -} -- -- Example -- private one : Digit 2 1 2 one = D Fz two : Digit 2 1 2 two = D (Fs Fz) u0 : Digit 1 0 2 u0 = U0 Fz u1 : Digit 1 1 1 u1 = U1 Fz a0 : Digit 3 0 4 a0 = D Fz a1 : Digit 3 0 4 a1 = D (Fs Fz) a2 : Digit 3 0 4 a2 = D (Fs (Fs Fz)) a3 : Digit 3 0 4 a3 = D (Fs (Fs (Fs Fz))) a : System 2 1 2 a = Sys (one ∷ two ∷ two ∷ [])
{ "alphanum_fraction": 0.4854095145, "avg_line_length": 30.3197026022, "ext": "agda", "hexsha": "35d0191060b48fa96dc95ee2edbe1eb7c418e202", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/Data/Num.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/Data/Num.agda", "max_line_length": 164, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/Data/Num.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 3246, "size": 8156 }
-- Various small test cases that failed at some point or another -- during the development of the parameter refinement feature. module _ where open import Agda.Primitive open import Agda.Builtin.Nat hiding (_<_) open import Agda.Builtin.Bool open import Agda.Builtin.Equality open import Agda.Builtin.List [_≡_] : ∀ {a} {A : Set a} (x y : A) → x ≡ y → A [ x ≡ y ] refl = x pattern ! = refl module CoPatterns where record R : Set where field b : Nat open R sharp : Nat → R sharp n = f n where f : Nat → R b (f m) = m r₁ : (n : Nat) → R b (r₁ n) = n module _ (n : Nat) where r : R b r = n record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field fst : A snd : B fst open Σ public data T : Nat → Set where zero : T zero suc : ∀ {n} → T n → T (suc n) module _ (A : Set) where ex : Σ Nat T fst ex = suc zero snd ex = suc zero module SimpleWith where module P (A : Set) where f : Nat → Nat f zero = 0 f (suc n) with n f (suc n) | z = z module MergeSort where data Vec (A : Set) : Nat → Set where [] : Vec A zero _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n) module Sort (A : Set) where merge : ∀ {n} → Vec A n → Vec A zero merge [] = [] merge (x ∷ xs) = merge xs module LetPatternBinding where record Wrap : Set where constructor wrap field wrapped : Nat fails : Wrap → Nat fails w = let wrap n = w in n record _×_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where constructor _,_ field fst : A snd : B module _ (A B : Set) where const : A → B → A const x _ = x plus : A × B → A plus p = let a , b = p in const a b module RefineStuff where module _ (x y : Nat) where foo : x ≡ suc y → Nat foo refl = y bar : (x y : Nat) → x ≡ y → Nat bar x y refl = y test : foo 2 1 refl ≡ 1 test = refl module Projections where module _ (X : Set) where record ∃ (a : Set) : Set where field witness : a f : ∃ X → X f r = ∃.witness r module Delay where data Vec (A : Set) : Nat → Set where _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n) data Unit : Set where unit : Unit record DNat : Set₁ where field D : Set force : D → Nat open DNat nonNil : ∀ {n} → Vec Unit n → Nat nonNil (i ∷ is) = suc (force f i) where f : DNat D f = Unit force f unit = zero module Folds where foldr : {A B : Set} → (A → B → B) → B → List A → B foldr f z [] = z foldr f z (x ∷ xs) = f x (foldr f z xs) foldl : {A B : Set} → (B → A → B) → B → List A → B foldl f z [] = z foldl f z (x ∷ xs) = foldl f (f z x) xs module FoldAssoc {A : Set}(_∙_ : A → A → A) (assoc : ∀ x y z → ((x ∙ y) ∙ z) ≡ (x ∙ (y ∙ z))) where smashr = foldr _∙_ smashl = foldl _∙_ postulate foldl-plus : ∀ z₁ z₂ xs → smashl (z₁ ∙ z₂) xs ≡ (z₁ ∙ smashl z₂ xs) foldr=foldl : ∀ ∅ → (∀ x → (∅ ∙ x) ≡ (x ∙ ∅)) → ∀ xs → Set foldr=foldl ∅ id [] = Nat foldr=foldl ∅ id (x ∷ xs) rewrite id x | foldl-plus x ∅ xs = Nat module With where data Vec (A : Set) : Nat → Set where [] : Vec A 0 _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n) idV : ∀ {A n} → Vec A n → Vec A n idV [] = [] idV (x ∷ xs) = x ∷ idV xs len : ∀ {A n} → Vec A n → Nat len {n = n} _ = n module _ (n : Nat) (xs : Vec Nat n) where f : Vec Nat n → Nat f [] = 0 f (x ∷ ys) with idV ys f (x ∷ ys) | [] = [ n ≡ 1 ] ! f (x ∷ ys) | z ∷ zs = [ n ≡ suc (suc (len zs)) ] ! module NestedWith where data Vec (A : Set) : Nat → Set where [] : Vec A 0 cons : ∀ n → A → Vec A n → Vec A (suc n) module _ (X Y : Set) where f : ∀ n → Vec Nat n → Nat f _ [] = 0 f .(suc m) (cons m x xs) with x f n (cons m x xs) | 0 = [ n ≡ suc m ] ! f n (cons m x xs) | y with xs f n (cons m x xs) | y | [] = [ n ≡ 1 ] ! f n (cons m x xs) | z | cons k y ys = [ n ≡ suc (suc k) ] ! module LetCase where record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B case_of_ : {A B : Set} → A → (A → B) → B case x of f = f x g : Nat × Nat → Nat g p = let a , b = p in case b of λ where zero → a (suc b) → a f : Nat × (Nat × Nat) → Nat f p = let a , q = p b , c = q in a + b + c module _ {a} {A : Set a} where h : List A → Nat → Nat → Nat h [] = λ _ _ → 0 h (x ∷ xs) = let ys = xs in λ n → λ where m → h ys n m
{ "alphanum_fraction": 0.4792380137, "avg_line_length": 20.6725663717, "ext": "agda", "hexsha": "e07ba9618b8c89d71f16948bd9277f9ce9a9493e", "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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Succeed/RefineParamsBugs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "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": "pthariensflame/agda", "max_issues_repo_path": "test/Succeed/RefineParamsBugs.agda", "max_line_length": 73, "max_stars_count": 3, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Succeed/RefineParamsBugs.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": 1809, "size": 4672 }
------------------------------------------------------------------------ -- Indexed applicative functors ------------------------------------------------------------------------ -- Note that currently the applicative functor laws are not included -- here. module Category.Applicative.Indexed where open import Data.Function open import Data.Product open import Category.Functor IFun : Set → Set₁ IFun I = I → I → Set → Set record RawIApplicative {I : Set} (F : IFun I) : Set₁ where infixl 4 _⊛_ _<⊛_ _⊛>_ infix 4 _⊗_ field pure : ∀ {i A} → A → F i i A _⊛_ : ∀ {i j k A B} → F i j (A → B) → F j k A → F i k B rawFunctor : ∀ {i j} → RawFunctor (F i j) rawFunctor = record { _<$>_ = λ g x → pure g ⊛ x } private open module RF {i j : I} = RawFunctor (rawFunctor {i = i} {j = j}) public _<⊛_ : ∀ {i j k A B} → F i j A → F j k B → F i k A x <⊛ y = const <$> x ⊛ y _⊛>_ : ∀ {i j k A B} → F i j A → F j k B → F i k B x ⊛> y = flip const <$> x ⊛ y _⊗_ : ∀ {i j k A B} → F i j A → F j k B → F i k (A × B) x ⊗ y = (_,_) <$> x ⊛ y
{ "alphanum_fraction": 0.4567788899, "avg_line_length": 25.5581395349, "ext": "agda", "hexsha": "ba21606725126670a2d8eacc4992bda2531c2a5c", "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/Category/Applicative/Indexed.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/Category/Applicative/Indexed.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/Category/Applicative/Indexed.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": 401, "size": 1099 }
-- Andreas, 2017-08-24, issue #2253 -- -- Better error message for matching on abstract constructor. -- {-# OPTIONS -v tc.lhs.split:30 #-} -- {-# OPTIONS -v tc.lhs:30 #-} -- {-# OPTIONS -v tc.lhs.flex:60 #-} abstract data B : Set where x : B data C : Set where c : B → C f : C → C f (c x) = c x -- WAS: -- -- Not in scope: -- AbstractPatternShadowsConstructor.B.x -- (did you mean 'x'?) -- when checking that the pattern c x has type C -- Expected: -- -- Cannot split on abstract data type B -- when checking that the pattern x has type B
{ "alphanum_fraction": 0.6135957066, "avg_line_length": 18.6333333333, "ext": "agda", "hexsha": "7ca4cdca84232603cd1af2addb20962547ef88a8", "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/Issue2253.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/Issue2253.agda", "max_line_length": 61, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue2253.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": 172, "size": 559 }
{-# OPTIONS --without-K --safe #-} -- Actually, we're cheating (for expediency); this is -- Symmetric Rig, not just Rig. open import Categories.Category module Categories.Category.RigCategory {o ℓ e} (C : Category o ℓ e) where open import Level open import Data.Fin renaming (zero to 0F; suc to sucF) open import Data.Product using (_,_) open import Categories.Functor renaming (id to idF) open import Categories.Category.Monoidal open import Categories.Category.Monoidal.Braided open import Categories.Category.Monoidal.Symmetric open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.NaturalTransformation using (_∘ᵥ_; _∘ₕ_; _∘ˡ_; _∘ʳ_; NaturalTransformation) open import Categories.Morphism C -- Should probably split out Distributive Category out and make this be 'over' that. record RigCategory {M⊎ M× : Monoidal C} (S⊎ : Symmetric M⊎) (S× : Symmetric M×) : Set (o ⊔ ℓ ⊔ e) where private module C = Category C open C hiding (_≈_) open Commutation module M⊎ = Monoidal M⊎ module M× = Monoidal M× module S⊎ = Symmetric S⊎ module S× = Symmetric S× open M⊎ renaming (_⊗₀_ to _⊕₀_; _⊗₁_ to _⊕₁_) open M× private 0C : C.Obj 0C = M⊎.unit 1C : C.Obj 1C = M×.unit private B⊗ : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X B⊗ {X} {Y} = S×.braiding.⇒.η (X , Y) B⊕ : ∀ {X Y} → X ⊕₀ Y ⇒ Y ⊕₀ X B⊕ {X} {Y} = S⊎.braiding.⇒.η (X , Y) field annₗ : ∀ {X} → 0C ⊗₀ X ≅ 0C annᵣ : ∀ {X} → X ⊗₀ 0C ≅ 0C distribₗ : ∀ {X Y Z} → X ⊗₀ (Y ⊕₀ Z) ≅ (X ⊗₀ Y) ⊕₀ (X ⊗₀ Z) distribᵣ : ∀ {X Y Z} → (X ⊕₀ Y) ⊗₀ Z ≅ (X ⊗₀ Z) ⊕₀ (Y ⊗₀ Z) private λ* : ∀ {X} → 0C ⊗₀ X ⇒ 0C λ* {X} = _≅_.from (annₗ {X}) ρ* : ∀ {X} → X ⊗₀ 0C ⇒ 0C ρ* {X} = _≅_.from (annᵣ {X}) module dl {X} {Y} {Z} = _≅_ (distribₗ {X} {Y} {Z}) module dr {X} {Y} {Z} = _≅_ (distribᵣ {X} {Y} {Z}) ⊗λ⇒ = M×.unitorˡ.from ⊗λ⇐ = M×.unitorˡ.to ⊗ρ⇒ = M×.unitorʳ.from ⊗ρ⇐ = M×.unitorʳ.to ⊗α⇒ = M×.associator.from ⊗α⇐ = M×.associator.to ⊕λ⇒ = M⊎.unitorˡ.from ⊕λ⇐ = M⊎.unitorˡ.to ⊕ρ⇒ = M⊎.unitorʳ.from ⊕ρ⇐ = M⊎.unitorʳ.to ⊕α⇒ = M⊎.associator.from ⊕α⇐ = M⊎.associator.to -- need II, IX, X, XV -- choose I, IV, VI, XI, XIII, XIX, XXIII and (XVI, XVII) field laplazaI : ∀ {A B C} → [ A ⊗₀ (B ⊕₀ C) ⇒ (A ⊗₀ C) ⊕₀ (A ⊗₀ B) ]⟨ dl.from ⇒⟨ (A ⊗₀ B) ⊕₀ (A ⊗₀ C) ⟩ B⊕ ≈ C.id ⊗₁ B⊕ ⇒⟨ A ⊗₀ (C ⊕₀ B) ⟩ dl.from ⟩ laplazaII : ∀ {A B C} → [ (A ⊕₀ B) ⊗₀ C ⇒ (C ⊗₀ A) ⊕₀ (C ⊗₀ B) ]⟨ B⊗ ⇒⟨ C ⊗₀ (A ⊕₀ B) ⟩ dl.from ≈ dr.from ⇒⟨ (A ⊗₀ C) ⊕₀ (B ⊗₀ C) ⟩ B⊗ ⊕₁ B⊗ ⟩ laplazaIV : {A B C D : Obj} → [ (A ⊕₀ B ⊕₀ C) ⊗₀ D ⇒ ((A ⊗₀ D) ⊕₀ (B ⊗₀ D)) ⊕₀ (C ⊗₀ D) ]⟨ dr.from ⇒⟨ (A ⊗₀ D) ⊕₀ ((B ⊕₀ C) ⊗₀ D) ⟩ C.id ⊕₁ dr.from ⇒⟨ (A ⊗₀ D) ⊕₀ ((B ⊗₀ D) ⊕₀ (C ⊗₀ D)) ⟩ ⊕α⇐ ≈ ⊕α⇐ ⊗₁ C.id ⇒⟨ ((A ⊕₀ B) ⊕₀ C) ⊗₀ D ⟩ dr.from ⇒⟨ ((A ⊕₀ B) ⊗₀ D) ⊕₀ (C ⊗₀ D) ⟩ dr.from ⊕₁ C.id ⟩ laplazaVI : {A B C D : Obj} → [ A ⊗₀ B ⊗₀ (C ⊕₀ D) ⇒ ((A ⊗₀ B) ⊗₀ C) ⊕₀ ((A ⊗₀ B) ⊗₀ D) ]⟨ C.id ⊗₁ dl.from ⇒⟨ A ⊗₀ ((B ⊗₀ C) ⊕₀ (B ⊗₀ D)) ⟩ dl.from ⇒⟨ (A ⊗₀ B ⊗₀ C) ⊕₀ (A ⊗₀ B ⊗₀ D) ⟩ ⊗α⇐ ⊕₁ ⊗α⇐ ≈ ⊗α⇐ ⇒⟨ (A ⊗₀ B) ⊗₀ (C ⊕₀ D) ⟩ dl.from ⟩ laplazaIX : ∀ {A B C D} → [ (A ⊕₀ B) ⊗₀ (C ⊕₀ D) ⇒ (((A ⊗₀ C) ⊕₀ (B ⊗₀ C)) ⊕₀ (A ⊗₀ D)) ⊕₀ (B ⊗₀ D) ]⟨ dr.from ⇒⟨ (A ⊗₀ (C ⊕₀ D)) ⊕₀ (B ⊗₀ (C ⊕₀ D)) ⟩ dl.from ⊕₁ dl.from ⇒⟨ ((A ⊗₀ C) ⊕₀ (A ⊗₀ D)) ⊕₀ ((B ⊗₀ C) ⊕₀ (B ⊗₀ D)) ⟩ ⊕α⇐ ⇒⟨ (((A ⊗₀ C) ⊕₀ (A ⊗₀ D)) ⊕₀ (B ⊗₀ C)) ⊕₀ (B ⊗₀ D) ⟩ ⊕α⇒ ⊕₁ C.id ⇒⟨ ((A ⊗₀ C) ⊕₀ ((A ⊗₀ D) ⊕₀ (B ⊗₀ C))) ⊕₀ (B ⊗₀ D) ⟩ (C.id ⊕₁ B⊕) ⊕₁ C.id ⇒⟨ ((A ⊗₀ C) ⊕₀ ((B ⊗₀ C) ⊕₀ (A ⊗₀ D))) ⊕₀ (B ⊗₀ D) ⟩ ⊕α⇐ ⊕₁ C.id ≈ dl.from ⇒⟨ ((A ⊕₀ B) ⊗₀ C) ⊕₀ ((A ⊕₀ B) ⊗₀ D) ⟩ dr.from ⊕₁ dr.from ⇒⟨ ((A ⊗₀ C) ⊕₀ (B ⊗₀ C)) ⊕₀ ((A ⊗₀ D) ⊕₀ (B ⊗₀ D)) ⟩ ⊕α⇐ ⟩ laplazaX : [ 0C ⊗₀ 0C ⇒ 0C ]⟨ λ* ≈ ρ* ⟩ laplazaXI : ∀ {A B} → [ 0C ⊗₀ (A ⊕₀ B) ⇒ 0C ]⟨ dl.from ⇒⟨ (0C ⊗₀ A) ⊕₀ (0C ⊗₀ B) ⟩ λ* ⊕₁ λ* ⇒⟨ 0C ⊕₀ 0C ⟩ ⊕λ⇒ ≈ λ* ⟩ laplazaXIII : [ 0C ⊗₀ 1C ⇒ 0C ]⟨ ⊗ρ⇒ ≈ λ* ⟩ laplazaXV : ∀ {A : Obj} → [ A ⊗₀ 0C ⇒ 0C ]⟨ ρ* ≈ B⊗ ⇒⟨ 0C ⊗₀ A ⟩ λ* ⟩ laplazaXVI : ∀ {A B} → [ 0C ⊗₀ (A ⊗₀ B) ⇒ 0C ]⟨ ⊗α⇐ ⇒⟨ (0C ⊗₀ A) ⊗₀ B ⟩ λ* ⊗₁ C.id ⇒⟨ 0C ⊗₀ B ⟩ λ* ≈ λ* ⟩ laplazaXVII : ∀ {A B} → [ A ⊗₀ (0C ⊗₀ B) ⇒ 0C ]⟨ ⊗α⇐ ⇒⟨ (A ⊗₀ 0C) ⊗₀ B ⟩ ρ* ⊗₁ C.id ⇒⟨ 0C ⊗₀ B ⟩ λ* ≈ C.id ⊗₁ λ* ⇒⟨ A ⊗₀ 0C ⟩ ρ* ⟩ laplazaXIX : ∀ {A B} → [ A ⊗₀ (0C ⊕₀ B) ⇒ A ⊗₀ B ]⟨ dl.from ⇒⟨ (A ⊗₀ 0C) ⊕₀ (A ⊗₀ B) ⟩ ρ* ⊕₁ C.id ⇒⟨ 0C ⊕₀ (A ⊗₀ B) ⟩ ⊕λ⇒ ≈ C.id ⊗₁ ⊕λ⇒ ⟩ laplazaXXIII : ∀ {A B} → [ 1C ⊗₀ (A ⊕₀ B) ⇒ (A ⊕₀ B) ]⟨ ⊗λ⇒ ≈ dl.from ⇒⟨ (1C ⊗₀ A) ⊕₀ (1C ⊗₀ B) ⟩ ⊗λ⇒ ⊕₁ ⊗λ⇒ ⟩
{ "alphanum_fraction": 0.4030680729, "avg_line_length": 30.4970760234, "ext": "agda", "hexsha": "b8137caf1b7655ea21a8cc00819fe741c519de25", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/RigCategory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/RigCategory.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/RigCategory.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2849, "size": 5215 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.QuotientRing where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.Powerset open import Cubical.Data.Nat open import Cubical.Data.FinData open import Cubical.HITs.SetQuotients using ([_]; squash/; elimProp2) open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.Kernel open import Cubical.Algebra.Ring import Cubical.Algebra.Ring.QuotientRing as Ring private variable ℓ ℓ' : Level _/_ : (R : CommRing ℓ) → (I : IdealsIn R) → CommRing ℓ R / I = fst asRing , commringstr _ _ _ _ _ (iscommring (RingStr.isRing (snd asRing)) (elimProp2 (λ _ _ → squash/ _ _) commEq)) where asRing = (CommRing→Ring R) Ring./ (CommIdeal→Ideal I) _·/_ : fst asRing → fst asRing → fst asRing _·/_ = RingStr._·_ (snd asRing) commEq : (x y : fst R) → ([ x ] ·/ [ y ]) ≡ ([ y ] ·/ [ x ]) commEq x y i = [ CommRingStr.·Comm (snd R) x y i ] [_]/ : {R : CommRing ℓ} {I : IdealsIn R} → (a : fst R) → fst (R / I) [ a ]/ = [ a ] module Quotient-FGideal-CommRing-Ring (A : CommRing ℓ) (B : Ring ℓ') (g : RingHom (CommRing→Ring A) B) {n : ℕ} (v : FinVec ⟨ A ⟩ n) (gnull : (k : Fin n) → g $ v k ≡ RingStr.0r (snd B)) where open RingStr (snd B) using (0r) zeroOnGeneratedIdeal : (x : ⟨ A ⟩) → x ∈ fst (generatedIdeal A v) → g $ x ≡ 0r zeroOnGeneratedIdeal x x∈FGIdeal = PT.elim (λ _ → isSetRing B (g $ x) 0r) (λ {(α , isLC) → subst _ (sym isLC) (cancelLinearCombination A B g _ α v gnull)}) x∈FGIdeal inducedHom : RingHom (CommRing→Ring (A / (generatedIdeal _ v))) B inducedHom = Ring.UniversalProperty.inducedHom (CommRing→Ring A) (CommIdeal→Ideal ideal) g zeroOnGeneratedIdeal where ideal = generatedIdeal A v module Quotient-FGideal-CommRing-CommRing (A : CommRing ℓ) (B : CommRing ℓ') (g : CommRingHom A B) {n : ℕ} (v : FinVec ⟨ A ⟩ n) (gnull : (k : Fin n) → g $ v k ≡ CommRingStr.0r (snd B)) where inducedHom : CommRingHom (A / (generatedIdeal _ v)) B inducedHom = Quotient-FGideal-CommRing-Ring.inducedHom A (CommRing→Ring B) g v gnull quotientHom : (R : CommRing ℓ) → (I : IdealsIn R) → CommRingHom R (R / I) quotientHom R I = Ring.quotientHom (CommRing→Ring R) (CommIdeal→Ideal I) module _ {R : CommRing ℓ} (I : IdealsIn R) where private π = quotientHom R I kernel≡I : kernelIdeal R (R / I) π ≡ I kernel≡I = cong Ideal→CommIdeal (Ring.kernel≡I (CommIdeal→Ideal I))
{ "alphanum_fraction": 0.6390101892, "avg_line_length": 31.5862068966, "ext": "agda", "hexsha": "36cd1e4be24cf407b66ed0cab5290d2f018e9bb3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_line_length": 113, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/QuotientRing.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 954, "size": 2748 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Increment where open import Data.Binary.Definition open import Strict inc : 𝔹 → 𝔹 inc 0ᵇ = 1ᵇ 0ᵇ inc (1ᵇ xs) = 2ᵇ xs inc (2ᵇ xs) = 1ᵇ inc xs
{ "alphanum_fraction": 0.6600985222, "avg_line_length": 16.9166666667, "ext": "agda", "hexsha": "f812d86bb25592d723e9995158fc15278e6aa8a8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Binary/Increment.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Binary/Increment.agda", "max_line_length": 34, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Binary/Increment.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 88, "size": 203 }
module Agda.Builtin.Strict where open import Agda.Builtin.Equality primitive primForce : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) → (∀ x → B x) → B x primForceLemma : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) (f : ∀ x → B x) → primForce x f ≡ f x
{ "alphanum_fraction": 0.5340909091, "avg_line_length": 29.3333333333, "ext": "agda", "hexsha": "6b299de70265e6168af574376204fe26902266b8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Strict.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Strict.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Strict.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 109, "size": 264 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Pointwise lifting of binary relations to sigma types ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.Relation.Binary.Pointwise.Dependent where open import Data.Product as Prod open import Level open import Function open import Relation.Binary as B using (_⇒_; Setoid; IsEquivalence) open import Relation.Binary.Indexed.Heterogeneous as I using (IREL; IRel; IndexedSetoid; IsIndexedEquivalence) open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- Pointwise lifting infixr 4 _,_ record POINTWISE {a₁ a₂ b₁ b₂ ℓ₁ ℓ₂} {A₁ : Set a₁} (B₁ : A₁ → Set b₁) {A₂ : Set a₂} (B₂ : A₂ → Set b₂) (_R₁_ : B.REL A₁ A₂ ℓ₁) (_R₂_ : IREL B₁ B₂ ℓ₂) (xy₁ : Σ A₁ B₁) (xy₂ : Σ A₂ B₂) : Set (a₁ ⊔ a₂ ⊔ b₁ ⊔ b₂ ⊔ ℓ₁ ⊔ ℓ₂) where constructor _,_ field proj₁ : (proj₁ xy₁) R₁ (proj₁ xy₂) proj₂ : (proj₂ xy₁) R₂ (proj₂ xy₂) open POINTWISE public Pointwise : ∀ {a b ℓ₁ ℓ₂} {A : Set a} (B : A → Set b) (_R₁_ : B.Rel A ℓ₁) (_R₂_ : IRel B ℓ₂) → B.Rel (Σ A B) _ Pointwise B = POINTWISE B B ------------------------------------------------------------------------ -- Pointwise preserves many relational properties module _ {a b ℓ₁ ℓ₂} {A : Set a} {B : A → Set b} {R : B.Rel A ℓ₁} {S : IRel B ℓ₂} where private R×S = Pointwise B R S refl : B.Reflexive R → I.Reflexive B S → B.Reflexive R×S refl refl₁ refl₂ = (refl₁ , refl₂) symmetric : B.Symmetric R → I.Symmetric B S → B.Symmetric R×S symmetric sym₁ sym₂ (x₁Rx₂ , y₁Ry₂) = (sym₁ x₁Rx₂ , sym₂ y₁Ry₂) transitive : B.Transitive R → I.Transitive B S → B.Transitive R×S transitive trans₁ trans₂ (x₁Rx₂ , y₁Ry₂) (x₂Rx₃ , y₂Ry₃) = (trans₁ x₁Rx₂ x₂Rx₃ , trans₂ y₁Ry₂ y₂Ry₃) isEquivalence : IsEquivalence R → IsIndexedEquivalence B S → IsEquivalence R×S isEquivalence eq₁ eq₂ = record { refl = refl Eq.refl IEq.refl ; sym = symmetric Eq.sym IEq.sym ; trans = transitive Eq.trans IEq.trans } where module Eq = IsEquivalence eq₁ module IEq = IsIndexedEquivalence eq₂ module _ {a b ℓ₁ ℓ₂} where setoid : (A : Setoid a ℓ₁) → IndexedSetoid (Setoid.Carrier A) b ℓ₂ → Setoid _ _ setoid s₁ s₂ = record { isEquivalence = isEquivalence Eq.isEquivalence IEq.isEquivalence } where module Eq = Setoid s₁ module IEq = IndexedSetoid s₂ ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.15 Rel = Pointwise {-# WARNING_ON_USAGE Rel "Warning: Rel was deprecated in v0.15. Please use Pointwise instead." #-} -- Version 0.15 REL = POINTWISE {-# WARNING_ON_USAGE REL "Warning: REL was deprecated in v1.0. Please use POINTWISE instead." #-}
{ "alphanum_fraction": 0.5572279712, "avg_line_length": 30.9611650485, "ext": "agda", "hexsha": "95bda87ed8be9eed2fb37e55e17b951a89877010", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/Dependent.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/Product/Relation/Binary/Pointwise/Dependent.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/Dependent.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": 973, "size": 3189 }
open import Mockingbird.Forest using (Forest) module Mockingbird.Forest.Extensionality {b ℓ} (forest : Forest {b} {ℓ}) where open import Algebra using (RightCongruent) open import Relation.Binary using (Rel; IsEquivalence; Setoid) open import Level using (_⊔_) open Forest forest -- TODO: if the arguments to the predicates is{Mockingbird,Thrush,Cardinal,...} -- are made implicit, then x can be implicit too. Similar : Rel Bird (b ⊔ ℓ) Similar A₁ A₂ = ∀ x → A₁ ∙ x ≈ A₂ ∙ x infix 4 _≋_ _≋_ = Similar -- A forest is called extensional if similarity implies equality. IsExtensional : Set (b ⊔ ℓ) IsExtensional = ∀ {A₁ A₂} → A₁ ≋ A₂ → A₁ ≈ A₂ -- A record to be used as an instance argument. record Extensional : Set (b ⊔ ℓ) where field ext : IsExtensional open Extensional ⦃ ... ⦄ public ext′ : ⦃ _ : Extensional ⦄ → ∀ {A₁ A₂} → (∀ {x} → A₁ ∙ x ≈ A₂ ∙ x) → A₁ ≈ A₂ ext′ A₁≋A₂ = ext λ _ → A₁≋A₂ -- Similarity is an equivalence relation. ≋-isEquivalence : IsEquivalence _≋_ ≋-isEquivalence = record { refl = λ _ → refl ; sym = λ x≋y z → sym (x≋y z) ; trans = λ x≋y y≋z w → trans (x≋y w) (y≋z w) } ≋-congʳ : RightCongruent _≋_ _∙_ ≋-congʳ {w} {x} {y} x≋y = λ _ → congʳ (x≋y w)
{ "alphanum_fraction": 0.6532999165, "avg_line_length": 27.8372093023, "ext": "agda", "hexsha": "f083a16eb484e1c6f5f98b7bcb056260aa09c85d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Forest/Extensionality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Forest/Extensionality.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Forest/Extensionality.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 468, "size": 1197 }
-- 2012-02-13 Andreas: testing correct polarity of data types -- sized types are the only source of subtyping, I think... -- {-# OPTIONS -v tc.polarity.set:10 #-} -- {-# OPTIONS -v tc.size.solve:20 #-} {-# OPTIONS --show-implicit #-} {-# OPTIONS --sized-types #-} module DataPolarity where open import Common.Size data Nat : {size : Size} -> Set where zero : {size : Size} -> Nat {↑ size} suc : {size : Size} -> Nat {size} -> Nat {↑ size} data Pair (A : Set) : Set where _,_ : A -> A -> Pair A split : {i : Size} → Nat {i} → Pair (Nat {i}) split zero = zero , zero split (suc n) with split n ... | (l , r) = suc r , l -- this should work, due to the monotonicity of Pair -- without subtyping, Agda would complain about i != ↑ i MyPair : Nat → Set → Set MyPair zero A = Pair A MyPair (suc n) A = MyPair n A -- polarity should be preserved by functions mysplit : {i : Size} → (n : Nat {i}) → MyPair (suc zero) (Nat {i}) mysplit zero = zero , zero mysplit (suc n) with mysplit n ... | (l , r) = suc r , l -- it should also work in modules module M (s : Set1) where data P (A : Set) : Set where _,_ : A -> A -> P A sp : {i : Size} → (n : Nat {i}) → P (Nat {i}) sp zero = zero , zero sp (suc n) with sp n ... | (l , r) = suc r , l -- open import Common.Prelude postulate A : Set data Color : Set where red : Color black : Color data Bounds : Set where leftOf : Bounds → Bounds rightOf : Bounds → Bounds -- works not: data Tree' (β : Bounds) : {i : Size} -> Color → (Nat {∞}) → Set where lf : ∀ {i} → Tree' β {↑ i} black zero nr : ∀ {i n}(a : A) -- → .(a is β) → Tree' (leftOf β) {i} black n → Tree' (rightOf β) {i} black n → Tree' β {↑ i} red n nb : ∀ {i c n}(a : A) -- → .(a is β) → Tree' (leftOf β) {i} c n → Tree' (rightOf β) {i} black n → Tree' β {↑ i} black (suc n) -- works: data Tr (A : Set) : {i : Size} -> Color → Set where lf : ∀ {i} → Tr A {↑ i} black nr : ∀ {i}(a : A) → Tr A {i} black → Tr A {i} black → Tr A {↑ i} red nb : ∀ {i c}(a : A) → Tr A {i} c → Tr A {i} black → Tr A {↑ i} black
{ "alphanum_fraction": 0.5443338075, "avg_line_length": 25.7195121951, "ext": "agda", "hexsha": "ce8a34414eeaeaff36a3faeb1ee230abbfb7e433", "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/DataPolarity.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/DataPolarity.agda", "max_line_length": 69, "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/DataPolarity.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": 769, "size": 2109 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Bool open import lib.types.FunctionSeq open import lib.types.Pointed open import lib.types.Suspension.Core open import lib.types.Suspension.Iterated open import lib.types.Suspension.Trunc open import lib.types.TLevel open import lib.types.Truncation module lib.types.Suspension.IteratedTrunc where module _ {i} (A : Type i) (m : ℕ₋₂) where Susp^-Trunc-swap : ∀ (n : ℕ) → Susp^ n (Trunc m A) → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A) Susp^-Trunc-swap O = idf _ Susp^-Trunc-swap (S n) = Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) ∘ Susp-fmap (Susp^-Trunc-swap n) private to : ∀ n → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n (Trunc m A)) → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A) to n = Trunc-rec {{Trunc-level}} (Susp^-Trunc-swap n) from : ∀ n → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A) → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n (Trunc m A)) from n = Trunc-fmap (Susp^-fmap n [_]) abstract from-Susp^-Trunc-swap : ∀ n → from n ∘ Susp^-Trunc-swap n ∼ [_] from-Susp^-Trunc-swap O = Trunc-elim {P = λ s → from 0 (Susp^-Trunc-swap 0 s) == [ s ]} {{λ s → =-preserves-level Trunc-level}} (λ a → idp) from-Susp^-Trunc-swap (S n) x = (from (S n) $ Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) $ Susp-fmap (Susp^-Trunc-swap n) x) =⟨ ! $ Susp-Trunc-swap-natural (Susp^-fmap n [_]) (⟨ n ⟩₋₂ +2+ m) $ Susp-fmap (Susp^-Trunc-swap n) x ⟩ (Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) $ Susp-fmap (Trunc-fmap (Susp^-fmap n [_])) $ Susp-fmap (Susp^-Trunc-swap n) x) =⟨ ap (Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m)) $ ! $ Susp-fmap-∘ (Trunc-fmap (Susp^-fmap n [_])) (Susp^-Trunc-swap n) x ⟩ (Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) $ Susp-fmap (from n ∘ Susp^-Trunc-swap n) x) =⟨ ap (Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m)) $ ap (λ f → Susp-fmap f x) (λ= (from-Susp^-Trunc-swap n)) ⟩ Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) (Susp-fmap [_] x) =⟨ Susp-Trunc-swap-Susp-fmap-trunc (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) x ⟩ [ x ] =∎ from-to : ∀ n → from n ∘ to n ∼ idf _ from-to n = Trunc-elim {P = λ t → from n (to n t) == t} {{λ t → =-preserves-level Trunc-level}} (from-Susp^-Trunc-swap n) Susp^-Trunc-swap-Susp^-fmap-trunc : ∀ n → Susp^-Trunc-swap n ∘ Susp^-fmap n [_] ∼ [_] Susp^-Trunc-swap-Susp^-fmap-trunc 0 s = idp Susp^-Trunc-swap-Susp^-fmap-trunc (S n) s = (Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) $ Susp-fmap (Susp^-Trunc-swap n) $ Susp^-fmap (S n) [_] s) =⟨ ap (Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m)) $ ! $ Susp-fmap-∘ (Susp^-Trunc-swap n) (Susp^-fmap n [_]) s ⟩ (Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) $ Susp-fmap (Susp^-Trunc-swap n ∘ Susp^-fmap n [_]) s) =⟨ ap (Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m)) $ app= (ap Susp-fmap (λ= (Susp^-Trunc-swap-Susp^-fmap-trunc n))) s ⟩ Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) (Susp-fmap [_] s) =⟨ Susp-Trunc-swap-Susp-fmap-trunc (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) s ⟩ [ s ] =∎ to-from : ∀ n → to n ∘ from n ∼ idf _ to-from n = Trunc-elim {{λ t → =-preserves-level Trunc-level}} (Susp^-Trunc-swap-Susp^-fmap-trunc n) Susp^-Trunc-equiv : ∀ (n : ℕ) → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n (Trunc m A)) ≃ Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A) Susp^-Trunc-equiv n = equiv (to n) (from n) (to-from n) (from-to n) module _ {i} (X : Ptd i) (m : ℕ₋₂) where Susp^-Trunc-swap-pt : ∀ (n : ℕ) → Susp^-Trunc-swap (de⊙ X) m n (pt (⊙Susp^ n (⊙Trunc m X))) == pt (⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X)) Susp^-Trunc-swap-pt O = idp Susp^-Trunc-swap-pt (S n) = idp ⊙Susp^-Trunc-swap : ∀ (n : ℕ) → ⊙Susp^ n (⊙Trunc m X) ⊙→ ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X) ⊙Susp^-Trunc-swap n = Susp^-Trunc-swap (de⊙ X) m n , Susp^-Trunc-swap-pt n ⊙Susp^-⊙Trunc-equiv : ∀ (n : ℕ) → ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n (⊙Trunc m X)) ⊙≃ ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X) ⊙Susp^-⊙Trunc-equiv n = ⊙to , snd (Susp^-Trunc-equiv (de⊙ X) m n) where ⊙to : ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n (⊙Trunc m X)) ⊙→ ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X) ⊙to = ⊙Trunc-rec {{Trunc-level}} (⊙Susp^-Trunc-swap n) module _ {i} {X Y : Ptd i} (f : X ⊙→ Y) (m : ℕ₋₂) where ⊙Susp^-Trunc-swap-natural : ∀ (n : ℕ) → ⊙Susp^-Trunc-swap Y m n ◃⊙∘ ⊙Susp^-fmap n (⊙Trunc-fmap f) ◃⊙idf =⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙∘ ⊙Susp^-Trunc-swap X m n ◃⊙idf ⊙Susp^-Trunc-swap-natural O = =⊙∘-in (⊙λ= (⊙∘-unit-l _)) ⊙Susp^-Trunc-swap-natural (S n) = ⊙Susp^-Trunc-swap Y m (S n) ◃⊙∘ ⊙Susp^-fmap (S n) (⊙Trunc-fmap f) ◃⊙idf =⊙∘⟨ 0 & 1 & ⊙expand $ ⊙Susp-Trunc-swap (Susp^ n (de⊙ Y)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ Y) m n) ◃⊙idf ⟩ ⊙Susp-Trunc-swap (Susp^ n (de⊙ Y)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ Y) m n) ◃⊙∘ ⊙Susp^-fmap (S n) (⊙Trunc-fmap f) ◃⊙idf =⊙∘⟨ 1 & 2 & ⊙Susp-fmap-seq-=⊙∘ $ de⊙-seq-=⊙∘ $ ⊙Susp^-Trunc-swap-natural n ⟩ ⊙Susp-Trunc-swap (Susp^ n (de⊙ Y)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-fmap (Trunc-fmap (Susp^-fmap n (fst f))) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf =⊙∘⟨ 0 & 2 & =⊙∘-in {gs = ⊙Trunc-fmap (⊙Susp-fmap (Susp^-fmap n (fst f))) ◃⊙∘ ⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙idf} $ ⊙Susp-Trunc-swap-natural (Susp^-fmap n (fst f)) (⟨ n ⟩₋₂ +2+ m) ⟩ ⊙Trunc-fmap (⊙Susp-fmap (Susp^-fmap n (fst f))) ◃⊙∘ ⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf =⊙∘⟨ 1 & 2 & ⊙contract ⟩ ⊙Trunc-fmap (⊙Susp^-fmap (S n) f) ◃⊙∘ ⊙Susp^-Trunc-swap X m (S n) ◃⊙idf ∎⊙∘ ⊙Susp^-⊙Trunc-equiv-natural : ∀ (n : ℕ) → ⊙–> (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙idf =⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙∘ ⊙–> (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf ⊙Susp^-⊙Trunc-equiv-natural n = =⊙∘-in $ ⊙–> (⊙Susp^-⊙Trunc-equiv Y m n) ⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) =⟨ ⊙Trunc-rec-⊙Trunc-fmap {{Trunc-level}} (⊙Susp^-Trunc-swap Y m n) (⊙Susp^-fmap n (⊙Trunc-fmap f)) ⟩ ⊙Trunc-rec {{Trunc-level}} (⊙Susp^-Trunc-swap Y m n ⊙∘ ⊙Susp^-fmap n (⊙Trunc-fmap f)) =⟨ ap (⊙Trunc-rec {{Trunc-level}}) $ =⊙∘-out $ ⊙Susp^-Trunc-swap-natural n ⟩ ⊙Trunc-rec {{Trunc-level}} (⊙Trunc-fmap (⊙Susp^-fmap n f) ⊙∘ ⊙Susp^-Trunc-swap X m n) =⟨ ⊙Trunc-rec-post-⊙∘ {{Trunc-level}} {{Trunc-level}} (⊙Trunc-fmap (⊙Susp^-fmap n f)) (⊙Susp^-Trunc-swap X m n) ⟩ ⊙Trunc-fmap (⊙Susp^-fmap n f) ⊙∘ ⊙–> (⊙Susp^-⊙Trunc-equiv X m n) =∎ ⊙Susp^-⊙Trunc-equiv-natural' : ∀ (n : ℕ) → ⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙idf =⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙∘ ⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf ⊙Susp^-⊙Trunc-equiv-natural' n = ⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙idf =⊙∘⟨ 2 & 0 & !⊙∘ $ ⊙<–-inv-r-=⊙∘ (⊙Susp^-⊙Trunc-equiv X m n) ⟩ ⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙∘ ⊙–> (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙∘ ⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙Susp^-⊙Trunc-equiv-natural n ⟩ ⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘ ⊙–> (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙∘ ⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf =⊙∘⟨ 0 & 2 & ⊙<–-inv-l-=⊙∘ (⊙Susp^-⊙Trunc-equiv Y m n) ⟩ ⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙∘ ⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf ∎⊙∘
{ "alphanum_fraction": 0.4891398784, "avg_line_length": 42.8563829787, "ext": "agda", "hexsha": "1cf1eeb474ab642b7bbe0caf050eee112b3ccf39", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Suspension/IteratedTrunc.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Suspension/IteratedTrunc.agda", "max_line_length": 96, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Suspension/IteratedTrunc.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": 4099, "size": 8057 }
{-# OPTIONS --no-sized-types --no-guardedness #-} module Agda.Builtin.TrustMe where open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Erase private postulate unsafePrimTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y primTrustMe = primEraseEquality unsafePrimTrustMe {-# DISPLAY primEraseEquality unsafePrimTrustMe = primTrustMe #-}
{ "alphanum_fraction": 0.7034313725, "avg_line_length": 27.2, "ext": "agda", "hexsha": "5a91830b27439ff2e50b33912b7bbe70627a8608", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda", "max_line_length": 65, "max_stars_count": 2, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 130, "size": 408 }
{-# OPTIONS --safe #-} module Cubical.Data.NatPlusOne.MoreNats.AssocNat.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat open import Cubical.Data.NatPlusOne.MoreNats.AssocNat.Base open import Cubical.Data.NatPlusOne renaming (ℕ₊₁ to Nat; one to one'; _+₁_ to _+₁'_) Nat→ℕ₊₁ : Nat → ℕ₊₁ Nat→ℕ₊₁ one' = 1 Nat→ℕ₊₁ (2+ n) = 1 +₁ Nat→ℕ₊₁ (1+ n) ℕ₊₁→Nat : ℕ₊₁ → Nat ℕ₊₁→Nat one = 1 ℕ₊₁→Nat (a +₁ b) = ℕ₊₁→Nat a +₁' ℕ₊₁→Nat b ℕ₊₁→Nat (assoc a b c i) = +₁-assoc (ℕ₊₁→Nat a) (ℕ₊₁→Nat b) (ℕ₊₁→Nat c) i ℕ₊₁→Nat (trunc m n p q i j) = 1+ (isSetℕ _ _ (λ k → -1+ (ℕ₊₁→Nat (p k))) (λ k → -1+ (ℕ₊₁→Nat (q k))) i j) ℕ₊₁→Nat→ℕ₊₁ : ∀ n → ℕ₊₁→Nat (Nat→ℕ₊₁ n) ≡ n ℕ₊₁→Nat→ℕ₊₁ one' = refl ℕ₊₁→Nat→ℕ₊₁ (2+ n) = cong (1+_ ∘ suc ∘ -1+_) (ℕ₊₁→Nat→ℕ₊₁ (1+ n)) private Nat→ℕ₊₁-+ : ∀ a b → Nat→ℕ₊₁ (a +₁' b) ≡ Nat→ℕ₊₁ a +₁ Nat→ℕ₊₁ b Nat→ℕ₊₁-+ one' b = refl Nat→ℕ₊₁-+ (2+ a) b = cong (one +₁_) (Nat→ℕ₊₁-+ (1+ a) b) ∙ assoc one (Nat→ℕ₊₁ (1+ a)) (Nat→ℕ₊₁ b) Nat→ℕ₊₁→Nat : ∀ n → Nat→ℕ₊₁ (ℕ₊₁→Nat n) ≡ n Nat→ℕ₊₁→Nat = ElimProp.f (trunc _ _) (λ i → one) λ {a} {b} m n → Nat→ℕ₊₁-+ (ℕ₊₁→Nat a) (ℕ₊₁→Nat b) ∙ (λ i → m i +₁ n i) ℕ₊₁≡Nat : ℕ₊₁ ≡ Nat ℕ₊₁≡Nat = isoToPath (iso ℕ₊₁→Nat Nat→ℕ₊₁ ℕ₊₁→Nat→ℕ₊₁ Nat→ℕ₊₁→Nat)
{ "alphanum_fraction": 0.5886681383, "avg_line_length": 33.975, "ext": "agda", "hexsha": "5bc7841216a3313a440cedf09b9b7e51536c68a5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/Properties.agda", "max_line_length": 85, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 776, "size": 1359 }
module UnsolvedMetas where foo = ?
{ "alphanum_fraction": 0.7105263158, "avg_line_length": 6.3333333333, "ext": "agda", "hexsha": "569538f2e5952bcb807b29c49bef8533f3aa70a0", "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/UnsolvedMetas.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/UnsolvedMetas.agda", "max_line_length": 26, "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/UnsolvedMetas.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": 11, "size": 38 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use Data.List.Relation.Unary.Any -- directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Any where open import Data.List.Relation.Unary.Any public
{ "alphanum_fraction": 0.4438502674, "avg_line_length": 28.7692307692, "ext": "agda", "hexsha": "796e12266213f3dbec92f1eeb732c500f51108ff", "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/Any.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/Any.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/Any.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 57, "size": 374 }
module TypeTheory.Nat.AnotherMono.Structure where open import Level renaming (zero to lzero; suc to lsuc) open import Data.Empty using (⊥) open import Data.Product using (Σ; _×_; _,_) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (¬_) record Nat : Set₁ where field N : Set zero : N suc : N → N ind : (P : N → Set) → P zero → (∀ k → P k → P (suc k)) → ∀ n → P n ind-zero : ∀ P P-zero P-suc → ind P P-zero P-suc zero ≡ P-zero ind-suc : ∀ P P-zero P-suc n → ind P P-zero P-suc (suc n) ≡ P-suc n (ind P P-zero P-suc n) s≢z : ∀ {n} → suc n ≢ zero 0N : N 0N = zero 1N : N 1N = suc zero z≢s : ∀ {n} → zero ≢ suc n z≢s = ≢-sym s≢z rec : {A : Set} → A → (A → A) → N → A rec {A} z s = ind (λ _ → A) z (λ _ → s) rec-zero : ∀ {A} (z : A) s → rec z s zero ≡ z rec-zero z s = ind-zero _ _ _ rec-suc : ∀ {A} (z : A) s n → rec z s (suc n) ≡ s (rec z s n) rec-suc z s n = ind-suc _ _ _ _ infixl 6 _+_ infixl 7 _*_ infix 4 _≤_ _<_ _≥_ _>_ _≰_ -- Arithematic -- Addition _+_ : N → N → N m + n = rec n suc m -- Multiplication _*_ : N → N → N m * n = rec zero (n +_) m -- Order _≤_ : Rel N lzero m ≤ n = Σ N λ o → o + m ≡ n _<_ : Rel N lzero m < n = suc m ≤ n _≥_ : Rel N lzero m ≥ n = n ≤ m _>_ : Rel N lzero m > n = n < m _≰_ : Rel N lzero m ≰ n = ¬ m ≤ n _≮_ : Rel N lzero m ≮ n = ¬ m < n _≱_ : Rel N lzero m ≱ n = ¬ m ≥ n _≯_ : Rel N lzero m ≯ n = ¬ m > n
{ "alphanum_fraction": 0.4968905473, "avg_line_length": 21.1578947368, "ext": "agda", "hexsha": "1d3f9c06705a8cdfcd32c04fe78d0186e20c4f79", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "TypeTheory/Nat/AnotherMono/Structure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "TypeTheory/Nat/AnotherMono/Structure.agda", "max_line_length": 75, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "TypeTheory/Nat/AnotherMono/Structure.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 690, "size": 1608 }
module Main where import univ import cwf import help import proofs
{ "alphanum_fraction": 0.8, "avg_line_length": 7.7777777778, "ext": "agda", "hexsha": "9d26fcfc838730e74abc40b17549f2c877ca2972", "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/univ/Main.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/univ/Main.agda", "max_line_length": 17, "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/univ/Main.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": 19, "size": 70 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Unary relations ------------------------------------------------------------------------ module Relation.Unary where open import Data.Empty open import Function open import Data.Unit hiding (setoid) open import Data.Product open import Data.Sum open import Level open import Relation.Nullary open import Relation.Binary using (Setoid; IsEquivalence) ------------------------------------------------------------------------ -- Unary relations Pred : ∀ {a} → Set a → (ℓ : Level) → Set (a ⊔ suc ℓ) Pred A ℓ = A → Set ℓ ------------------------------------------------------------------------ -- Unary relations can be seen as sets -- I.e., they can be seen as subsets of the universe of discourse. module _ {a} {A : Set a} -- The universe of discourse. where -- Set membership. infix 4 _∈_ _∉_ _∈_ : ∀ {ℓ} → A → Pred A ℓ → Set _ x ∈ P = P x _∉_ : ∀ {ℓ} → A → Pred A ℓ → Set _ x ∉ P = ¬ x ∈ P -- The empty set. ∅ : Pred A zero ∅ = λ _ → ⊥ -- The property of being empty. Empty : ∀ {ℓ} → Pred A ℓ → Set _ Empty P = ∀ x → x ∉ P ∅-Empty : Empty ∅ ∅-Empty x () -- The universe, i.e. the subset containing all elements in A. U : Pred A zero U = λ _ → ⊤ -- The property of being universal. Universal : ∀ {ℓ} → Pred A ℓ → Set _ Universal P = ∀ x → x ∈ P U-Universal : Universal U U-Universal = λ _ → _ -- Set complement. ∁ : ∀ {ℓ} → Pred A ℓ → Pred A ℓ ∁ P = λ x → x ∉ P ∁∅-Universal : Universal (∁ ∅) ∁∅-Universal = λ x x∈∅ → x∈∅ ∁U-Empty : Empty (∁ U) ∁U-Empty = λ x x∈∁U → x∈∁U _ -- P ⊆ Q means that P is a subset of Q. _⊆′_ is a variant of _⊆_. infix 4 _⊆_ _⊇_ _⊆′_ _⊇′_ _⊆_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _ P ⊆ Q = ∀ {x} → x ∈ P → x ∈ Q _⊆′_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _ P ⊆′ Q = ∀ x → x ∈ P → x ∈ Q _⊇_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _ Q ⊇ P = P ⊆ Q _⊇′_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _ Q ⊇′ P = P ⊆′ Q ∅-⊆ : ∀ {ℓ} → (P : Pred A ℓ) → ∅ ⊆ P ∅-⊆ P () ⊆-U : ∀ {ℓ} → (P : Pred A ℓ) → P ⊆ U ⊆-U P _ = _ -- Positive version of non-disjointness, dual to inclusion. infix 4 _≬_ _≬_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _ P ≬ Q = ∃ λ x → x ∈ P × x ∈ Q -- Set union. infixr 6 _∪_ _∪_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Pred A _ P ∪ Q = λ x → x ∈ P ⊎ x ∈ Q -- Set intersection. infixr 7 _∩_ _∩_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Pred A _ P ∩ Q = λ x → x ∈ P × x ∈ Q -- Implication. infixl 8 _⇒_ _⇒_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Pred A _ P ⇒ Q = λ x → x ∈ P → x ∈ Q -- Infinitary union and intersection. infix 9 ⋃ ⋂ ⋃ : ∀ {ℓ i} (I : Set i) → (I → Pred A ℓ) → Pred A _ ⋃ I P = λ x → Σ[ i ∈ I ] P i x syntax ⋃ I (λ i → P) = ⋃[ i ∶ I ] P ⋂ : ∀ {ℓ i} (I : Set i) → (I → Pred A ℓ) → Pred A _ ⋂ I P = λ x → (i : I) → P i x syntax ⋂ I (λ i → P) = ⋂[ i ∶ I ] P ------------------------------------------------------------------------ -- Unary relation combinators infixr 2 _⟨×⟩_ infixr 2 _⟨⊙⟩_ infixr 1 _⟨⊎⟩_ infixr 0 _⟨→⟩_ infixl 9 _⟨·⟩_ infixr 9 _⟨∘⟩_ infixr 2 _//_ _\\_ _⟨×⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} → Pred A ℓ₁ → Pred B ℓ₂ → Pred (A × B) _ (P ⟨×⟩ Q) (x , y) = x ∈ P × y ∈ Q _⟨⊙⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} → Pred A ℓ₁ → Pred B ℓ₂ → Pred (A × B) _ (P ⟨⊙⟩ Q) (x , y) = x ∈ P ⊎ y ∈ Q _⟨⊎⟩_ : ∀ {a b ℓ} {A : Set a} {B : Set b} → Pred A ℓ → Pred B ℓ → Pred (A ⊎ B) _ P ⟨⊎⟩ Q = [ P , Q ] _⟨→⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} → Pred A ℓ₁ → Pred B ℓ₂ → Pred (A → B) _ (P ⟨→⟩ Q) f = P ⊆ Q ∘ f _⟨·⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} (P : Pred A ℓ₁) (Q : Pred B ℓ₂) → (P ⟨×⟩ (P ⟨→⟩ Q)) ⊆ Q ∘ uncurry (flip _$_) (P ⟨·⟩ Q) (p , f) = f p -- Converse. _~ : ∀ {a b ℓ} {A : Set a} {B : Set b} → Pred (A × B) ℓ → Pred (B × A) ℓ P ~ = P ∘ swap -- Composition. _⟨∘⟩_ : ∀ {a b c ℓ₁ ℓ₂} {A : Set a} {B : Set b} {C : Set c} → Pred (A × B) ℓ₁ → Pred (B × C) ℓ₂ → Pred (A × C) _ (P ⟨∘⟩ Q) (x , z) = ∃ λ y → (x , y) ∈ P × (y , z) ∈ Q -- Post and pre-division. _//_ : ∀ {a b c ℓ₁ ℓ₂} {A : Set a} {B : Set b} {C : Set c} → Pred (A × C) ℓ₁ → Pred (B × C) ℓ₂ → Pred (A × B) _ (P // Q) (x , y) = Q ∘ _,_ y ⊆ P ∘ _,_ x _\\_ : ∀ {a b c ℓ₁ ℓ₂} {A : Set a} {B : Set b} {C : Set c} → Pred (A × C) ℓ₁ → Pred (A × B) ℓ₂ → Pred (B × C) _ P \\ Q = (P ~ // Q ~) ~ ------------------------------------------------------------------------ -- Properties of unary relations Decidable : ∀ {a ℓ} {A : Set a} (P : Pred A ℓ) → Set _ Decidable P = ∀ x → Dec (P x)
{ "alphanum_fraction": 0.4257762654, "avg_line_length": 23.2772277228, "ext": "agda", "hexsha": "03aa8e3fb48c5468326ef3ac5d9e9759de2bd571", "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": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Unary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Unary.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Unary.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 2099, "size": 4702 }
------------------------------------------------------------------------ -- Lenses defined in terms of a getter, equivalences between the -- getter's "preimages", and a coherence property ------------------------------------------------------------------------ {-# OPTIONS --cubical --safe #-} import Equality.Path as P module Lens.Non-dependent.Equivalent-preimages {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude renaming (_∘_ to _⊚_) open import Bijection equality-with-J as B using (_↔_) open import Equality.Path.Isomorphisms eq hiding (univ) open import Equivalence equality-with-J as Eq using (_≃_; Is-equivalence) open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional eq as PT using (∥_∥; ∣_∣) open import Preimage equality-with-J using (_⁻¹_) open import Surjection equality-with-J using (_↠_) open import Univalence-axiom equality-with-J open import Lens.Non-dependent eq import Lens.Non-dependent.Higher eq as Higher import Lens.Non-dependent.Traditional eq as Traditional private variable ℓ : Level A B C : Set ℓ a b c z : A ------------------------------------------------------------------------ -- The lens type family -- Lenses defined in terms of a getter, equivalences between the -- getter's "preimages", and a coherence property. -- -- This definition is based on a suggestion from Andrea Vezzosi. Note -- that the fields and some derived properties correspond to things -- discussed by Paolo Capriotti in the context of his higher lenses -- (http://homotopytypetheory.org/2014/04/29/higher-lenses/). record Lens (A : Set a) (B : Set b) : Set (a ⊔ b) where no-eta-equality pattern constructor lens field -- A getter. get : A → B -- A function from one "preimage" of get to another. get⁻¹-const : (b₁ b₂ : B) → get ⁻¹ b₁ → get ⁻¹ b₂ -- This function is an equivalence. get⁻¹-const-equivalence : (b₁ b₂ : B) → Is-equivalence (get⁻¹-const b₁ b₂) -- A coherence property. get⁻¹-const-∘ : (b₁ b₂ b₃ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₂ b₃ (get⁻¹-const b₁ b₂ p) ≡ get⁻¹-const b₁ b₃ p -- All the getter's "preimages" are equivalent. get⁻¹-constant : (b₁ b₂ : B) → get ⁻¹ b₁ ≃ get ⁻¹ b₂ get⁻¹-constant b₁ b₂ = Eq.⟨ _ , get⁻¹-const-equivalence b₁ b₂ ⟩ -- The inverse of get⁻¹-const. get⁻¹-const⁻¹ : (b₁ b₂ : B) → get ⁻¹ b₂ → get ⁻¹ b₁ get⁻¹-const⁻¹ b₁ b₂ = _≃_.from (get⁻¹-constant b₁ b₂) -- Some derived coherence properties. get⁻¹-const-id : (b : B) (p : get ⁻¹ b) → get⁻¹-const b b p ≡ p get⁻¹-const-id b p = get⁻¹-const b b p ≡⟨ sym $ _≃_.left-inverse-of (get⁻¹-constant _ _) _ ⟩ get⁻¹-const⁻¹ b b (get⁻¹-const b b (get⁻¹-const b b p)) ≡⟨ cong (get⁻¹-const⁻¹ b b) $ get⁻¹-const-∘ _ _ _ _ ⟩ get⁻¹-const⁻¹ b b (get⁻¹-const b b p) ≡⟨ _≃_.left-inverse-of (get⁻¹-constant _ _) _ ⟩∎ p ∎ get⁻¹-const-inverse : (b₁ b₂ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₁ b₂ p ≡ get⁻¹-const⁻¹ b₂ b₁ p get⁻¹-const-inverse b₁ b₂ p = sym $ _≃_.to-from (get⁻¹-constant _ _) ( get⁻¹-const b₂ b₁ (get⁻¹-const b₁ b₂ p) ≡⟨ get⁻¹-const-∘ _ _ _ _ ⟩ get⁻¹-const b₁ b₁ p ≡⟨ get⁻¹-const-id _ _ ⟩∎ p ∎) -- A setter. set : A → B → A set a b = $⟨ a , refl _ ⟩ get ⁻¹ get a ↝⟨ get⁻¹-const (get a) b ⟩ get ⁻¹ b ↝⟨ proj₁ ⟩□ A □ -- The lens laws can be proved. get-set : ∀ a b → get (set a b) ≡ b get-set a b = get (proj₁ (get⁻¹-const (get a) b (a , refl _))) ≡⟨ proj₂ (get⁻¹-const (get a) b (a , refl _)) ⟩∎ b ∎ set-get : ∀ a → set a (get a) ≡ a set-get a = proj₁ (get⁻¹-const (get a) (get a) (a , refl _)) ≡⟨ cong proj₁ $ get⁻¹-const-id _ _ ⟩∎ a ∎ set-set : ∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂ set-set a b₁ b₂ = proj₁ (get⁻¹-const (get (set a b₁)) b₂ (set a b₁ , refl _)) ≡⟨ elim¹ (λ {b} eq → proj₁ (get⁻¹-const (get (set a b₁)) b₂ (set a b₁ , refl _)) ≡ proj₁ (get⁻¹-const b b₂ (set a b₁ , eq))) (refl _) (get-set a b₁) ⟩ proj₁ (get⁻¹-const b₁ b₂ (set a b₁ , get-set a b₁)) ≡⟨⟩ proj₁ (get⁻¹-const b₁ b₂ (get⁻¹-const (get a) b₁ (a , refl _))) ≡⟨ cong proj₁ $ get⁻¹-const-∘ _ _ _ _ ⟩∎ proj₁ (get⁻¹-const (get a) b₂ (a , refl _)) ∎ -- A traditional lens. traditional-lens : Traditional.Lens A B traditional-lens = record { get = get ; set = set ; get-set = get-set ; set-get = set-get ; set-set = set-set } instance -- The lenses defined above have getters and setters. has-getter-and-setter : Has-getter-and-setter (Lens {a = a} {b = b}) has-getter-and-setter = record { get = Lens.get ; set = Lens.set } -- The record type above is equivalent to a nested Σ-type. Lens-as-Σ : Lens A B ≃ ∃ λ (get : A → B) → ∃ λ (get⁻¹-const : (b₁ b₂ : B) → get ⁻¹ b₁ → get ⁻¹ b₂) → ((b₁ b₂ : B) → Is-equivalence (get⁻¹-const b₁ b₂)) × ((b₁ b₂ b₃ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₂ b₃ (get⁻¹-const b₁ b₂ p) ≡ get⁻¹-const b₁ b₃ p) Lens-as-Σ = Eq.↔→≃ (λ l → get l , get⁻¹-const l , get⁻¹-const-equivalence l , get⁻¹-const-∘ l) (λ (g , c , c-e , c-∘) → record { get = g ; get⁻¹-const = c ; get⁻¹-const-equivalence = c-e ; get⁻¹-const-∘ = c-∘ }) refl (λ { (lens _ _ _ _) → refl _ }) where open Lens -- A variant of Lens-as-Σ. Lens-as-Σ′ : Lens A B ≃ ∃ λ (get : A → B) → ∃ λ (get⁻¹-constant : (b₁ b₂ : B) → get ⁻¹ b₁ ≃ get ⁻¹ b₂) → let get⁻¹-const : ∀ _ _ → _ get⁻¹-const = λ b₁ b₂ → _≃_.to (get⁻¹-constant b₁ b₂) in (b₁ b₂ b₃ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₂ b₃ (get⁻¹-const b₁ b₂ p) ≡ get⁻¹-const b₁ b₃ p Lens-as-Σ′ {A = A} {B = B} = Lens A B ↝⟨ Lens-as-Σ ⟩ (∃ λ (get : A → B) → ∃ λ (get⁻¹-const : (b₁ b₂ : B) → get ⁻¹ b₁ → get ⁻¹ b₂) → ((b₁ b₂ : B) → Is-equivalence (get⁻¹-const b₁ b₂)) × ((b₁ b₂ b₃ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₂ b₃ (get⁻¹-const b₁ b₂ p) ≡ get⁻¹-const b₁ b₃ p)) ↔⟨ (∃-cong λ _ → Σ-assoc) ⟩ (∃ λ (get : A → B) → ∃ λ ((get⁻¹-const , _) : ∃ λ (get⁻¹-const : (b₁ b₂ : B) → get ⁻¹ b₁ → get ⁻¹ b₂) → (b₁ b₂ : B) → Is-equivalence (get⁻¹-const b₁ b₂)) → (b₁ b₂ b₃ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₂ b₃ (get⁻¹-const b₁ b₂ p) ≡ get⁻¹-const b₁ b₃ p) ↝⟨ (∃-cong λ _ → Σ-cong-contra (ΠΣ-comm F.∘ ∀-cong ext (λ _ → ΠΣ-comm)) λ _ → F.id) ⟩ (∃ λ (get : A → B) → ∃ λ (f : (b₁ b₂ : B) → ∃ λ (get⁻¹-const : get ⁻¹ b₁ → get ⁻¹ b₂) → Is-equivalence get⁻¹-const) → let get⁻¹-const : ∀ _ _ → _ get⁻¹-const = λ b₁ b₂ → proj₁ (f b₁ b₂) in (b₁ b₂ b₃ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₂ b₃ (get⁻¹-const b₁ b₂ p) ≡ get⁻¹-const b₁ b₃ p) ↝⟨ (∃-cong λ _ → Σ-cong-contra (∀-cong ext λ _ → ∀-cong ext λ _ → Eq.≃-as-Σ) λ _ → F.id) ⟩□ (∃ λ (get : A → B) → ∃ λ (get⁻¹-constant : (b₁ b₂ : B) → get ⁻¹ b₁ ≃ get ⁻¹ b₂) → let get⁻¹-const : ∀ _ _ → _ get⁻¹-const = λ b₁ b₂ → _≃_.to (get⁻¹-constant b₁ b₂) in (b₁ b₂ b₃ : B) (p : get ⁻¹ b₁) → get⁻¹-const b₂ b₃ (get⁻¹-const b₁ b₂ p) ≡ get⁻¹-const b₁ b₃ p) □ ------------------------------------------------------------------------ -- Some results related to h-levels -- If the domain of a lens is inhabited and has h-level n, -- then the codomain also has h-level n. h-level-respects-lens-from-inhabited : ∀ n → Lens A B → A → H-level n A → H-level n B h-level-respects-lens-from-inhabited {A = A} {B = B} n l a = H-level n A ↝⟨ H-level.respects-surjection surj n ⟩□ H-level n B □ where open Lens l surj : A ↠ B surj = record { logical-equivalence = record { to = get ; from = set a } ; right-inverse-of = λ b → get (set a b) ≡⟨ get-set a b ⟩∎ b ∎ } -- If A and B have h-level n given the assumption that the other type -- is inhabited, then Lens A B has h-level n. lens-preserves-h-level : ∀ n → (B → H-level n A) → (A → H-level n B) → H-level n (Lens A B) lens-preserves-h-level {B = B} {A = A} n hA hB = H-level-cong _ n (inverse Lens-as-Σ′) $ Σ-closure n (Π-closure ext n λ a → hB a) λ _ → Σ-closure n (Π-closure ext n λ b → Π-closure ext n λ _ → Eq.h-level-closure ext n (⁻¹-closure (hA b) hB) (⁻¹-closure (hA b) hB)) λ _ → (Π-closure ext n λ b → Π-closure ext n λ _ → Π-closure ext n λ _ → Π-closure ext n λ _ → ⇒≡ n (⁻¹-closure (hA b) hB)) where ⁻¹-closure : {f : A → B} {x : B} → H-level n A → (A → H-level n B) → H-level n (f ⁻¹ x) ⁻¹-closure hA hB = Σ-closure n hA λ a → ⇒≡ n (hB a) -- If A has positive h-level n, then Lens A B also has h-level n. lens-preserves-h-level-of-domain : ∀ n → H-level (1 + n) A → H-level (1 + n) (Lens A B) lens-preserves-h-level-of-domain n hA = [inhabited⇒+]⇒+ n λ l → lens-preserves-h-level (1 + n) (λ _ → hA) λ a → h-level-respects-lens-from-inhabited _ l a hA ------------------------------------------------------------------------ -- Some equality characterisation lemmas -- An equality characterisation lemma. equality-characterisation : let open Lens in {A : Set a} {B : Set b} {l₁ l₂ : Lens A B} → (l₁ ≡ l₂) ≃ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (gc : ∀ b₁ b₂ p → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ b₂ p ≡ get⁻¹-const l₂ b₁ b₂ p) → subst (λ (get , gc) → ∀ b₁ b₂ b₃ (p : get ⁻¹ b₁) → gc b₂ b₃ (gc b₁ b₂ p) ≡ gc b₁ b₃ p) (Σ-≡,≡→≡ (⟨ext⟩ g) (⟨ext⟩ λ b₁ → ⟨ext⟩ λ b₂ → ⟨ext⟩ λ p → gc b₁ b₂ p)) (get⁻¹-const-∘ l₁) ≡ get⁻¹-const-∘ l₂) equality-characterisation {l₁ = l₁} {l₂ = l₂} = l₁ ≡ l₂ ↝⟨ inverse $ Eq.≃-≡ (lemma₁ F.∘ Lens-as-Σ) ⟩ ( ((get l₁ , get⁻¹-const l₁) , get⁻¹-const-∘ l₁) , get⁻¹-const-equivalence l₁ ) ≡ ( ((get l₂ , get⁻¹-const l₂) , get⁻¹-const-∘ l₂) , get⁻¹-const-equivalence l₂ ) ↔⟨ inverse $ ignore-propositional-component (Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Eq.propositional ext _) ⟩ ((get l₁ , get⁻¹-const l₁) , get⁻¹-const-∘ l₁) ≡ ((get l₂ , get⁻¹-const l₂) , get⁻¹-const-∘ l₂) ↔⟨ inverse B.Σ-≡,≡↔≡ ⟩ (∃ λ (p : (get l₁ , get⁻¹-const l₁) ≡ (get l₂ , get⁻¹-const l₂)) → subst (λ (get , gc) → ∀ b₁ b₂ b₃ (p : get ⁻¹ b₁) → gc b₂ b₃ (gc b₁ b₂ p) ≡ gc b₁ b₃ p) p (get⁻¹-const-∘ l₁) ≡ get⁻¹-const-∘ l₂) ↝⟨ (Σ-cong-contra B.Σ-≡,≡↔≡ λ _ → F.id) ⟩ (∃ λ (p : ∃ λ (g : get l₁ ≡ get l₂) → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) g (get⁻¹-const l₁) ≡ get⁻¹-const l₂) → subst (λ (get , gc) → ∀ b₁ b₂ b₃ (p : get ⁻¹ b₁) → gc b₂ b₃ (gc b₁ b₂ p) ≡ gc b₁ b₃ p) (uncurry Σ-≡,≡→≡ p) (get⁻¹-const-∘ l₁) ≡ get⁻¹-const-∘ l₂) ↔⟨ inverse Σ-assoc ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (gc : subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) g (get⁻¹-const l₁) ≡ get⁻¹-const l₂) → subst (λ (get , gc) → ∀ b₁ b₂ b₃ (p : get ⁻¹ b₁) → gc b₂ b₃ (gc b₁ b₂ p) ≡ gc b₁ b₃ p) (Σ-≡,≡→≡ g gc) (get⁻¹-const-∘ l₁) ≡ get⁻¹-const-∘ l₂) ↝⟨ (Σ-cong-contra (Eq.extensionality-isomorphism bad-ext) λ _ → F.id) ⟩ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (gc : subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) ≡ get⁻¹-const l₂) → subst (λ (get , gc) → ∀ b₁ b₂ b₃ (p : get ⁻¹ b₁) → gc b₂ b₃ (gc b₁ b₂ p) ≡ gc b₁ b₃ p) (Σ-≡,≡→≡ (⟨ext⟩ g) gc) (get⁻¹-const-∘ l₁) ≡ get⁻¹-const-∘ l₂) ↝⟨ (∃-cong λ _ → Σ-cong-contra (inverse $ lemma₂ _) λ _ → F.id) ⟩□ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (gc : ∀ b₁ b₂ p → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ b₂ p ≡ get⁻¹-const l₂ b₁ b₂ p) → subst (λ (get , gc) → ∀ b₁ b₂ b₃ (p : get ⁻¹ b₁) → gc b₂ b₃ (gc b₁ b₂ p) ≡ gc b₁ b₃ p) (Σ-≡,≡→≡ (⟨ext⟩ g) (⟨ext⟩ λ b₁ → ⟨ext⟩ λ b₂ → ⟨ext⟩ λ p → gc b₁ b₂ p)) (get⁻¹-const-∘ l₁) ≡ get⁻¹-const-∘ l₂) □ where open Lens lemma₁ : {P : A → Set ℓ} {Q R : (x : A) → P x → Set ℓ} → (∃ λ (x : A) → ∃ λ (y : P x) → Q x y × R x y) ≃ (∃ λ (((x , y) , _) : Σ (Σ A P) (uncurry R)) → Q x y) lemma₁ {A = A} {P = P} {Q = Q} {R = R} = (∃ λ (x : A) → ∃ λ (y : P x) → Q x y × R x y) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ×-comm) ⟩ (∃ λ (x : A) → ∃ λ (y : P x) → R x y × Q x y) ↔⟨ (∃-cong λ _ → Σ-assoc) ⟩ (∃ λ (x : A) → ∃ λ ((y , _) : ∃ λ (y : P x) → R x y) → Q x y) ↔⟨ Σ-assoc ⟩ (∃ λ ((x , y , _) : ∃ λ (x : A) → ∃ λ (y : P x) → R x y) → Q x y) ↝⟨ (Σ-cong Σ-assoc λ _ → F.id) ⟩□ (∃ λ (((x , y) , _) : Σ (Σ A P) (uncurry R)) → Q x y) □ lemma₂ : (g : ∀ a → get l₁ a ≡ get l₂ a) → _ lemma₂ g = subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) ≡ get⁻¹-const l₂ ↝⟨ inverse $ Eq.extensionality-isomorphism bad-ext ⟩ (∀ b₁ → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ ≡ get⁻¹-const l₂ b₁) ↝⟨ (∀-cong ext λ _ → inverse $ Eq.extensionality-isomorphism bad-ext) ⟩ (∀ b₁ b₂ → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ b₂ ≡ get⁻¹-const l₂ b₁ b₂) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → inverse $ Eq.extensionality-isomorphism bad-ext) ⟩□ (∀ b₁ b₂ p → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ b₂ p ≡ get⁻¹-const l₂ b₁ b₂ p) □ -- An equality characterisation lemma for lenses from sets. equality-characterisation-for-sets : let open Lens in {A : Set a} {B : Set b} {l₁ l₂ : Lens A B} → Is-set A → (l₁ ≡ l₂) ≃ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∀ b₁ b₂ p → proj₁ (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p)) ≡ proj₁ (get⁻¹-const l₂ b₁ b₂ p)) equality-characterisation-for-sets {A = A} {B = B} {l₁ = l₁} {l₂ = l₂} A-set = l₁ ≡ l₂ ↝⟨ equality-characterisation ⟩ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (gc : ∀ b₁ b₂ p → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ b₂ p ≡ get⁻¹-const l₂ b₁ b₂ p) → subst (λ (get , gc) → ∀ b₁ b₂ b₃ (p : get ⁻¹ b₁) → gc b₂ b₃ (gc b₁ b₂ p) ≡ gc b₁ b₃ p) (Σ-≡,≡→≡ (⟨ext⟩ g) (⟨ext⟩ λ b₁ → ⟨ext⟩ λ b₂ → ⟨ext⟩ λ p → gc b₁ b₂ p)) (get⁻¹-const-∘ l₁) ≡ get⁻¹-const-∘ l₂) ↔⟨ (∃-cong λ _ → drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ +⇒≡ $ Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → ⁻¹-set) ⟩ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∀ b₁ b₂ p → subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ b₂ p ≡ get⁻¹-const l₂ b₁ b₂ p) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ≡⇒↝ _ $ cong (_≡ _) $ lemma₁ _ _ _ _) ⟩ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∀ b₁ b₂ p → subst (_⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p)) ≡ get⁻¹-const l₂ b₁ b₂ p) ↔⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ p → drop-⊤-right (λ _ → _⇔_.to contractible⇔↔⊤ $ +⇒≡ (B-set (proj₁ p))) F.∘ inverse B.Σ-≡,≡↔≡) ⟩ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∀ b₁ b₂ p → proj₁ (subst (_⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p))) ≡ proj₁ (get⁻¹-const l₂ b₁ b₂ p)) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ≡⇒↝ _ $ cong (_≡ _) $ lemma₂ _ _ _ _) ⟩□ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∀ b₁ b₂ p → proj₁ (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p)) ≡ proj₁ (get⁻¹-const l₂ b₁ b₂ p)) □ where open Lens B-set : A → Is-set B B-set a = h-level-respects-lens-from-inhabited 2 l₁ a A-set ⁻¹-set : Is-set (get l₂ ⁻¹ b) ⁻¹-set = Σ-closure 2 A-set λ a → mono₁ 1 (B-set a) lemma₁ : ∀ g b₁ b₂ p → _ lemma₁ g b₁ b₂ p = subst (λ get → ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁) b₁ b₂ p ≡⟨ cong (λ f → f b₂ p) $ sym $ push-subst-application (⟨ext⟩ g) (λ get b₁ → ∀ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) ⟩ subst (λ get → ∀ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁ b₁) b₂ p ≡⟨ cong (λ f → f p) $ sym $ push-subst-application (⟨ext⟩ g) (λ get b₂ → get ⁻¹ b₁ → get ⁻¹ b₂) ⟩ subst (λ get → get ⁻¹ b₁ → get ⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁ b₁ b₂) p ≡⟨ subst-→ {x₁≡x₂ = ⟨ext⟩ g} ⟩∎ subst (_⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p)) ∎ lemma₂ : ∀ g b₁ b₂ p → _ lemma₂ g b₁ b₂ p = proj₁ (subst (_⁻¹ b₂) (⟨ext⟩ g) (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p))) ≡⟨ cong proj₁ $ push-subst-pair {y≡z = ⟨ext⟩ g} _ _ ⟩ subst (λ _ → A) (⟨ext⟩ g) (proj₁ (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p))) ≡⟨ subst-const (⟨ext⟩ g) ⟩∎ proj₁ (get⁻¹-const l₁ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ g) p)) ∎ ------------------------------------------------------------------------ -- Conversions between different kinds of lenses -- Higher lenses can be converted to the ones defined above. higher→ : Higher.Lens A B → Lens A B higher→ l@(Higher.⟨ _ , _ , _ ⟩) = _≃_.from Lens-as-Σ′ ( Higher.Lens.get l , Higher.get⁻¹-constant l , Higher.get⁻¹-constant-∘ l ) -- The conversion preserves getters and setters. higher→-preserves-getters-and-setters : Preserves-getters-and-setters-→ A B higher→ higher→-preserves-getters-and-setters Higher.⟨ _ , _ , _ ⟩ = refl _ , refl _ -- A lens of the kind defined above can be converted to a higher one -- if the codomain is inhabited when it is merely inhabited. →higher : (∥ B ∥ → B) → Lens A B → Higher.Lens A B →higher {B = B} {A = A} ∥B∥→B l@(lens _ _ _ _) = record { R = ∃ λ (b : ∥ B ∥) → Lens.get l ⁻¹ (∥B∥→B b) ; equiv = A ↔⟨ (inverse $ drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _) ⟩ (∃ λ a → ∃ λ b → Lens.get l a ≡ b) ↔⟨ ∃-comm ⟩ (∃ λ b → Lens.get l ⁻¹ b) ↝⟨ (Σ-cong (inverse PT.∥∥×≃) λ _ → Lens.get⁻¹-constant l _ _) ⟩ (∃ λ ((b , _) : ∥ B ∥ × B) → Lens.get l ⁻¹ (∥B∥→B b)) ↔⟨ inverse Σ-assoc ⟩ (∃ λ (b : ∥ B ∥) → B × Lens.get l ⁻¹ (∥B∥→B b)) ↔⟨ (∃-cong λ _ → ×-comm) ⟩ (∃ λ (b : ∥ B ∥) → Lens.get l ⁻¹ (∥B∥→B b) × B) ↔⟨ Σ-assoc ⟩□ (∃ λ (b : ∥ B ∥) → Lens.get l ⁻¹ (∥B∥→B b)) × B □ ; inhabited = proj₁ } -- The conversion preserves getters and setters. →higher-preserves-getters-and-setters : {B : Set b} (∥B∥→B : ∥ B ∥ → B) → Preserves-getters-and-setters-→ A B (→higher ∥B∥→B) →higher-preserves-getters-and-setters {A = A} ∥B∥→B l@(lens _ _ _ _) = refl _ , ⟨ext⟩ λ a → ⟨ext⟩ λ b → let a′ = set a b in _≃_.to-from (Higher.Lens.equiv (→higher ∥B∥→B l)) $ cong₂ _,_ (∣ get a′ ∣ , get⁻¹-const (get a′) (∥B∥→B ∣ get a′ ∣) (a′ , refl _) ≡⟨ Σ-≡,≡→≡ (PT.truncation-is-proposition _ _) ( subst (λ b → get ⁻¹ ∥B∥→B b) (PT.truncation-is-proposition _ _) (get⁻¹-const (get a′) (∥B∥→B ∣ get a′ ∣) (a′ , refl _)) ≡⟨ elim¹ (λ {f} _ → subst (λ b → get ⁻¹ f b) (PT.truncation-is-proposition _ _) (get⁻¹-const (get a′) (f ∣ get a′ ∣) (a′ , refl _)) ≡ get⁻¹-const (get a) (f ∣ get a ∣) (a , refl _)) ( subst (λ _ → get ⁻¹ ∥B∥→B ∣ b ∣) (PT.truncation-is-proposition _ _) (get⁻¹-const (get a′) (∥B∥→B ∣ b ∣) (a′ , refl _)) ≡⟨ subst-const (PT.truncation-is-proposition _ _) ⟩ get⁻¹-const (get a′) (∥B∥→B ∣ b ∣) (a′ , refl _) ≡⟨ sym $ get⁻¹-const-∘ _ _ _ _ ⟩ get⁻¹-const (get a) (∥B∥→B ∣ b ∣) (get⁻¹-const (get a′) (get a) (a′ , refl _)) ≡⟨ cong (get⁻¹-const (get a) (∥B∥→B ∣ b ∣)) $ elim¹ (λ {b} eq → get⁻¹-const (get a′) (get a) (a′ , refl _) ≡ get⁻¹-const b (get a) (a′ , eq)) (refl _) (get-set a b) ⟩ get⁻¹-const (get a) (∥B∥→B ∣ b ∣) (get⁻¹-const b (get a) (set a b , get-set a b)) ≡⟨⟩ get⁻¹-const (get a) (∥B∥→B ∣ b ∣) (get⁻¹-const b (get a) (get⁻¹-const (get a) b (a , refl _))) ≡⟨ cong (λ p → get⁻¹-const (get a) (∥B∥→B ∣ b ∣) (get⁻¹-const b (get a) p)) $ get⁻¹-const-inverse _ _ _ ⟩ get⁻¹-const (get a) (∥B∥→B ∣ b ∣) (get⁻¹-const b (get a) (get⁻¹-const⁻¹ b (get a) (a , refl _))) ≡⟨ cong (get⁻¹-const (get a) (∥B∥→B ∣ b ∣)) $ _≃_.right-inverse-of (get⁻¹-constant _ _) _ ⟩∎ get⁻¹-const (get a) (∥B∥→B ∣ b ∣) (a , refl _) ∎) (⟨ext⟩ λ _ → cong ∥B∥→B $ PT.truncation-is-proposition _ _) ⟩∎ get⁻¹-const (get a) (∥B∥→B ∣ get a ∣) (a , refl _) ∎) ⟩∎ ∣ get a ∣ , get⁻¹-const (get a) (∥B∥→B ∣ get a ∣) (a , refl _) ∎) (get (set a b) ≡⟨ get-set a b ⟩∎ b ∎) where open Lens l -- There is a split surjection from Lens A B to Higher.Lens A B if B -- is inhabited when it is merely inhabited (assuming univalence). ↠higher : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → (∥ B ∥ → B) → Lens A B ↠ Higher.Lens A B ↠higher {A = A} {B = B} univ ∥B∥→B = record { logical-equivalence = record { to = →higher ∥B∥→B ; from = higher→ } ; right-inverse-of = λ l → Higher.lenses-equal-if-setters-equal univ _ _ (λ _ → ∥B∥→B) (set (→higher ∥B∥→B (higher→ l)) ≡⟨ proj₂ $ →higher-preserves-getters-and-setters ∥B∥→B (higher→ l) ⟩ Lens.set (higher→ l) ≡⟨ proj₂ $ higher→-preserves-getters-and-setters l ⟩∎ set l ∎) } where open Higher.Lens -- The split surjection preserves getters and setters. ↠higher-preserves-getters-and-setters : {A : Set a} {B : Set b} (univ : Univalence (a ⊔ b)) (∥B∥→B : ∥ B ∥ → B) → Preserves-getters-and-setters-⇔ A B (_↠_.logical-equivalence (↠higher univ ∥B∥→B)) ↠higher-preserves-getters-and-setters _ ∥B∥→B = →higher-preserves-getters-and-setters ∥B∥→B , higher→-preserves-getters-and-setters -- If B is inhabited when it is merely inhabited and A has positive -- h-level n, then Higher.Lens A B also has h-level n (assuming -- univalence). higher-lens-preserves-h-level-of-domain : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → (∥ B ∥ → B) → ∀ n → H-level (1 + n) A → H-level (1 + n) (Higher.Lens A B) higher-lens-preserves-h-level-of-domain {A = A} {B = B} univ ∥B∥→B n = H-level (1 + n) A ↝⟨ lens-preserves-h-level-of-domain n ⟩ H-level (1 + n) (Lens A B) ↝⟨ H-level.respects-surjection (↠higher univ ∥B∥→B) (1 + n) ⟩□ H-level (1 + n) (Higher.Lens A B) □ -- Traditional lenses that satisfy some coherence properties can be -- translated to lenses of the kind defined above. coherent→ : Block "conversion" → Traditional.Coherent-lens A B → Lens A B coherent→ ⊠ l = _≃_.from Lens-as-Σ′ ( get , (λ b₁ b₂ → Eq.↔→≃ (gg b₁ b₂) (gg b₂ b₁) (gg∘gg b₁ b₂) (gg∘gg b₂ b₁)) , (λ b₁ b₂ b₃ (a , _) → Σ-≡,≡→≡ (set (set a b₂) b₃ ≡⟨ set-set a b₂ b₃ ⟩∎ set a b₃ ∎) (subst (λ a → get a ≡ b₃) (set-set a b₂ b₃) (get-set (set a b₂) b₃) ≡⟨ subst-∘ _ _ (set-set a b₂ b₃) ⟩ subst (_≡ b₃) (cong get (set-set a b₂ b₃)) (get-set (set a b₂) b₃) ≡⟨ subst-trans-sym {y≡x = cong get (set-set a b₂ b₃)} ⟩ trans (sym (cong get (set-set a b₂ b₃))) (get-set (set a b₂) b₃) ≡⟨ get-set-set′ _ _ _ ⟩∎ get-set a b₃ ∎)) ) where open Traditional.Coherent-lens l get-set-set′ : ∀ a b₁ b₂ → trans (sym (cong get (set-set a b₁ b₂))) (get-set (set a b₁) b₂) ≡ get-set a b₂ get-set-set′ a b₁ b₂ = trans (sym (cong get (set-set a b₁ b₂))) (get-set (set a b₁) b₂) ≡⟨ cong (λ eq → trans (sym eq) (get-set _ _)) $ get-set-set _ _ _ ⟩ trans (sym (trans (get-set (set a b₁) b₂) (sym (get-set a b₂)))) (get-set (set a b₁) b₂) ≡⟨ cong (flip trans (get-set _ _)) $ sym-trans _ (sym (get-set _ _)) ⟩ trans (trans (sym (sym (get-set a b₂))) (sym (get-set (set a b₁) b₂))) (get-set (set a b₁) b₂) ≡⟨ trans-[trans-sym]- _ (get-set _ _) ⟩ sym (sym (get-set a b₂)) ≡⟨ sym-sym (get-set _ _) ⟩∎ get-set a b₂ ∎ gg : ∀ b₁ b₂ → get ⁻¹ b₁ → get ⁻¹ b₂ gg b₁ b₂ (a , _) = set a b₂ , get-set a b₂ gg∘gg : ∀ b₁ b₂ p → gg b₁ b₂ (gg b₂ b₁ p) ≡ p gg∘gg b₁ b₂ (a , get-a≡b₂) = Σ-≡,≡→≡ eq₁ (subst (λ a → get a ≡ b₂) eq₁ (get-set (set a b₁) b₂) ≡⟨ subst-∘ _ _ eq₁ ⟩ subst (_≡ b₂) (cong get eq₁) (get-set (set a b₁) b₂) ≡⟨ subst-trans-sym {y≡x = cong get eq₁} ⟩ trans (sym (cong get eq₁)) (get-set (set a b₁) b₂) ≡⟨ cong (flip trans (get-set (set a b₁) b₂)) lemma₂ ⟩ trans (trans (trans (sym (cong get (set-get a))) (cong (get ⊚ set a) get-a≡b₂)) (sym (cong get (set-set a b₁ b₂)))) (get-set (set a b₁) b₂) ≡⟨ trans-assoc _ _ (get-set (set a b₁) b₂) ⟩ trans (trans (sym (cong get (set-get a))) (cong (get ⊚ set a) get-a≡b₂)) (trans (sym (cong get (set-set a b₁ b₂))) (get-set (set a b₁) b₂)) ≡⟨ trans-assoc _ _ (trans (sym (cong get (set-set a b₁ b₂))) (get-set (set a b₁) b₂)) ⟩ trans (sym (cong get (set-get a))) (trans (cong (get ⊚ set a) get-a≡b₂) (trans (sym (cong get (set-set a b₁ b₂))) (get-set (set a b₁) b₂))) ≡⟨ cong₂ (λ p q → trans (sym p) (trans (cong (get ⊚ set a) get-a≡b₂) q)) (get-set-get _) (get-set-set′ _ _ _) ⟩ trans (sym (get-set a (get a))) (trans (cong (get ⊚ set a) get-a≡b₂) (get-set a b₂)) ≡⟨ cong (λ eq → trans (sym (eq (get a))) (trans (cong (get ⊚ set a) get-a≡b₂) (eq b₂))) $ sym $ _≃_.left-inverse-of (Eq.extensionality-isomorphism bad-ext) _ ⟩ trans (sym (ext⁻¹ (⟨ext⟩ (get-set a)) (get a))) (trans (cong (get ⊚ set a) get-a≡b₂) (ext⁻¹ (⟨ext⟩ (get-set a)) b₂)) ≡⟨ elim₁ (λ {f} gs → trans (sym (ext⁻¹ gs (get a))) (trans (cong f get-a≡b₂) (ext⁻¹ gs b₂)) ≡ get-a≡b₂) ( trans (sym (ext⁻¹ (refl id) (get a))) (trans (cong id get-a≡b₂) (ext⁻¹ (refl id) b₂)) ≡⟨ cong₂ (λ p q → trans (sym p) (trans (cong id get-a≡b₂) q)) (ext⁻¹-refl _) (ext⁻¹-refl _) ⟩ trans (sym (refl _)) (trans (cong id get-a≡b₂) (refl _)) ≡⟨ cong₂ trans sym-refl (trans-reflʳ _) ⟩ trans (refl _) (cong id get-a≡b₂) ≡⟨ trans-reflˡ (cong id get-a≡b₂) ⟩ cong id get-a≡b₂ ≡⟨ sym $ cong-id get-a≡b₂ ⟩∎ get-a≡b₂ ∎) (⟨ext⟩ (get-set a)) ⟩ get-a≡b₂ ∎) where eq₁ = set (set a b₁) b₂ ≡⟨ set-set a b₁ b₂ ⟩ set a b₂ ≡⟨ cong (set a) (sym get-a≡b₂) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎ lemma₁ = sym (cong get (cong (set a) (sym get-a≡b₂))) ≡⟨ cong sym $ cong-∘ _ _ (sym get-a≡b₂) ⟩ sym (cong (get ⊚ set a) (sym get-a≡b₂)) ≡⟨ sym $ cong-sym _ (sym get-a≡b₂) ⟩ cong (get ⊚ set a) (sym (sym get-a≡b₂)) ≡⟨ cong (cong (get ⊚ set a)) $ sym-sym get-a≡b₂ ⟩∎ cong (get ⊚ set a) get-a≡b₂ ∎ lemma₂ = sym (cong get eq₁) ≡⟨⟩ sym (cong get (trans (set-set a b₁ b₂) (trans (cong (set a) (sym get-a≡b₂)) (set-get a)))) ≡⟨ cong sym $ cong-trans _ _ (trans (cong (set a) (sym get-a≡b₂)) (set-get a)) ⟩ sym (trans (cong get (set-set a b₁ b₂)) (cong get (trans (cong (set a) (sym get-a≡b₂)) (set-get a)))) ≡⟨ cong (λ eq → sym (trans _ eq)) $ cong-trans _ _ (set-get a) ⟩ sym (trans (cong get (set-set a b₁ b₂)) (trans (cong get (cong (set a) (sym get-a≡b₂))) (cong get (set-get a)))) ≡⟨ sym-trans _ (trans (cong get (cong (set a) (sym get-a≡b₂))) (cong get (set-get a))) ⟩ trans (sym (trans (cong get (cong (set a) (sym get-a≡b₂))) (cong get (set-get a)))) (sym (cong get (set-set a b₁ b₂))) ≡⟨ cong (flip trans (sym (cong get (set-set a b₁ b₂)))) $ sym-trans _ (cong get (set-get a)) ⟩ trans (trans (sym (cong get (set-get a))) (sym (cong get (cong (set a) (sym get-a≡b₂))))) (sym (cong get (set-set a b₁ b₂))) ≡⟨ cong (λ eq → trans (trans (sym (cong get (set-get a))) eq) (sym (cong get (set-set a b₁ b₂)))) lemma₁ ⟩∎ trans (trans (sym (cong get (set-get a))) (cong (get ⊚ set a) get-a≡b₂)) (sym (cong get (set-set a b₁ b₂))) ∎ -- The conversion preserves getters and setters. coherent→-preserves-getters-and-setters : (b : Block "conversion") → Preserves-getters-and-setters-→ A B (coherent→ b) coherent→-preserves-getters-and-setters ⊠ _ = refl _ , refl _ -- If A is a set, then Traditional.Lens A B is equivalent to Lens A B. traditional≃ : Block "conversion" → Is-set A → Traditional.Lens A B ≃ Lens A B traditional≃ {A = A} {B = B} b@⊠ A-set = Eq.↔→≃ (Traditional.Lens A B ↔⟨ Traditional.≃coherent A-set ⟩ Traditional.Coherent-lens A B ↝⟨ coherent→ b ⟩□ Lens A B □) Lens.traditional-lens (λ l → _≃_.from (equality-characterisation-for-sets A-set) ( (λ _ → refl _) , (λ b₁ b₂ p@(a , _) → let l′ = traditional-lens l l″ = coherent→ b (_≃_.to (Traditional.≃coherent A-set) l′) in proj₁ (get⁻¹-const l″ b₁ b₂ (subst (_⁻¹ b₁) (sym $ ⟨ext⟩ λ _ → refl _) p)) ≡⟨ cong (λ eq → proj₁ (get⁻¹-const l″ b₁ b₂ (subst (_⁻¹ b₁) (sym eq) p))) ext-refl ⟩ proj₁ (get⁻¹-const l″ b₁ b₂ (subst (_⁻¹ b₁) (sym (refl _)) p)) ≡⟨ cong (λ eq → proj₁ (get⁻¹-const l″ b₁ b₂ (subst (_⁻¹ b₁) eq p))) sym-refl ⟩ proj₁ (get⁻¹-const l″ b₁ b₂ (subst (_⁻¹ b₁) (refl _) p)) ≡⟨ cong (proj₁ ⊚ get⁻¹-const l″ b₁ b₂) $ subst-refl _ _ ⟩ proj₁ (get⁻¹-const l″ b₁ b₂ p) ≡⟨⟩ set l (proj₁ p) b₂ ≡⟨⟩ proj₁ (get⁻¹-const l (get l a) b₂ (a , refl _)) ≡⟨ elim¹ (λ {b} eq → proj₁ (get⁻¹-const l (get l a) b₂ (a , refl _)) ≡ proj₁ (get⁻¹-const l b b₂ (a , eq))) (refl _) (proj₂ p) ⟩∎ proj₁ (get⁻¹-const l b₁ b₂ p) ∎) )) (λ _ → _↔_.from (Traditional.equality-characterisation-for-sets A-set) (refl _)) where open Lens B-set : Traditional.Lens A B → A → Is-set B B-set l a = Traditional.h-level-respects-lens-from-inhabited 2 l a A-set -- The equivalence preserves getters and setters. traditional≃-preserves-getters-and-setters : {A : Set a} (b : Block "conversion") (s : Is-set A) → Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence (traditional≃ b s)) traditional≃-preserves-getters-and-setters ⊠ _ = (λ _ → refl _ , refl _) , (λ _ → refl _ , refl _) -- If B is inhabited when it is merely inhabited, then -- Traditional.Coherent-lens A B is logically equivalent to -- Higher.Lens A B. coherent⇔higher : Block "conversion" → (∥ B ∥ → B) → Traditional.Coherent-lens A B ⇔ Higher.Lens A B coherent⇔higher {B = B} {A = A} b ∥B∥→B = record { to = Traditional.Coherent-lens A B ↝⟨ coherent→ b ⟩ Lens A B ↝⟨ →higher ∥B∥→B ⟩□ Higher.Lens A B □ ; from = Higher.Lens.coherent-lens } -- The logical equivalence preserves getters and setters. coherent⇔higher-preserves-getters-and-setters : {B : Set b} (bc : Block "conversion") (∥B∥→B : ∥ B ∥ → B) → Preserves-getters-and-setters-⇔ A B (coherent⇔higher bc ∥B∥→B) coherent⇔higher-preserves-getters-and-setters b ∥B∥→B = Preserves-getters-and-setters-→-∘ {f = →higher ∥B∥→B} {g = coherent→ b} (→higher-preserves-getters-and-setters ∥B∥→B) (coherent→-preserves-getters-and-setters b) , (λ _ → refl _ , refl _) -- If B is inhabited when it is merely inhabited, then there is a -- split surjection from Traditional.Coherent-lens A B to -- Higher.Lens A B (assuming univalence). coherent↠higher : {A : Set a} {B : Set b} → Block "conversion" → Univalence (a ⊔ b) → (∥ B ∥ → B) → Traditional.Coherent-lens A B ↠ Higher.Lens A B coherent↠higher {A = A} {B = B} b univ ∥B∥→B = record { logical-equivalence = coherent⇔higher b ∥B∥→B ; right-inverse-of = λ l → Higher.lenses-equal-if-setters-equal univ _ _ (λ _ → ∥B∥→B) $ proj₂ (proj₁ (coherent⇔higher-preserves-getters-and-setters b ∥B∥→B) _) } -- The split surjection preserves getters and setters. coherent↠higher-preserves-getters-and-setters : {A : Set a} {B : Set b} (bc : Block "conversion") (univ : Univalence (a ⊔ b)) (∥B∥→B : ∥ B ∥ → B) → Preserves-getters-and-setters-⇔ A B (_↠_.logical-equivalence (coherent↠higher bc univ ∥B∥→B)) coherent↠higher-preserves-getters-and-setters b _ ∥B∥→B = coherent⇔higher-preserves-getters-and-setters b ∥B∥→B ------------------------------------------------------------------------ -- Composition -- A lemma used to define composition. ∘⁻¹≃ : Block "∘⁻¹≃" → (f : B → C) (g : A → B) → f ⊚ g ⁻¹ z ≃ ∃ λ ((y , _) : f ⁻¹ z) → g ⁻¹ y ∘⁻¹≃ {z = z} ⊠ f g = f ⊚ g ⁻¹ z ↔⟨⟩ (∃ λ a → f (g a) ≡ z) ↔⟨ (∃-cong λ _ → ∃-intro _ _) ⟩ (∃ λ a → ∃ λ y → f y ≡ z × y ≡ g a) ↔⟨ (∃-cong λ _ → Σ-assoc) ⟩ (∃ λ a → ∃ λ ((y , _) : f ⁻¹ z) → y ≡ g a) ↔⟨ ∃-comm ⟩ (∃ λ ((y , _) : f ⁻¹ z) → ∃ λ a → y ≡ g a) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ≡-comm) ⟩ (∃ λ ((y , _) : f ⁻¹ z) → g ⁻¹ y) □ -- Composition. infixr 9 _∘_ _∘_ : Lens B C → Lens A B → Lens A C l₁@(lens _ _ _ _) ∘ l₂@(lens _ _ _ _) = block λ b → _≃_.from Lens-as-Σ′ ( get l₁ ⊚ get l₂ , (λ c₁ c₂ → get l₁ ⊚ get l₂ ⁻¹ c₁ ↝⟨ ∘⁻¹≃ b _ _ ⟩ (∃ λ ((b , _) : get l₁ ⁻¹ c₁) → get l₂ ⁻¹ b) ↝⟨ (Σ-cong (get⁻¹-constant l₁ c₁ c₂) λ p@(b , _) → get⁻¹-constant l₂ b (proj₁ (get⁻¹-const l₁ c₁ c₂ p))) ⟩ (∃ λ ((b , _) : get l₁ ⁻¹ c₂) → get l₂ ⁻¹ b) ↝⟨ inverse $ ∘⁻¹≃ b _ _ ⟩□ get l₁ ⊚ get l₂ ⁻¹ c₂ □) , (λ c₁ c₂ c₃ p → _≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₂ c₃) (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₂ c₃ p))) (_≃_.to (∘⁻¹≃ b _ _) (_≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₁ c₂) (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₁ c₂ p))) (_≃_.to (∘⁻¹≃ b _ _) p))))) ≡⟨ cong (λ x → _≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₂ c₃) (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₂ c₃ p))) x)) $ _≃_.right-inverse-of (∘⁻¹≃ b _ _) _ ⟩ _≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₂ c₃) (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₂ c₃ p))) (Σ-map (get⁻¹-const l₁ c₁ c₂) (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₁ c₂ p))) (_≃_.to (∘⁻¹≃ b _ _) p))) ≡⟨⟩ _≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₂ c₃ ⊚ get⁻¹-const l₁ c₁ c₂) (λ {p@(b , _)} → get⁻¹-const l₂ (proj₁ (get⁻¹-const l₁ c₁ c₂ p)) (proj₁ (get⁻¹-const l₁ c₂ c₃ (get⁻¹-const l₁ c₁ c₂ p))) ⊚ get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₁ c₂ p))) (_≃_.to (∘⁻¹≃ b _ _) p)) ≡⟨ cong (λ f → _≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₂ c₃ ⊚ get⁻¹-const l₁ c₁ c₂) (λ {p} → f {p}) (_≃_.to (∘⁻¹≃ b _ _) p))) $ (implicit-extensionality ext λ p → ⟨ext⟩ (get⁻¹-const-∘ l₂ _ (proj₁ (get⁻¹-const l₁ c₁ c₂ p)) _)) ⟩ _≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₂ c₃ ⊚ get⁻¹-const l₁ c₁ c₂) (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₂ c₃ (get⁻¹-const l₁ c₁ c₂ p)))) (_≃_.to (∘⁻¹≃ b _ _) p)) ≡⟨ cong (λ f → _≃_.from (∘⁻¹≃ b _ _) (Σ-map f (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (f p))) (_≃_.to (∘⁻¹≃ b _ _) p))) $ ⟨ext⟩ (get⁻¹-const-∘ l₁ _ _ _) ⟩∎ _≃_.from (∘⁻¹≃ b _ _) (Σ-map (get⁻¹-const l₁ c₁ c₃) (λ {p@(b , _)} → get⁻¹-const l₂ b (proj₁ (get⁻¹-const l₁ c₁ c₃ p))) (_≃_.to (∘⁻¹≃ b _ _) p)) ∎) ) where open Lens -- The setter of the resulting lens is defined in the "right" way. set-∘≡ : (l₁ : Lens B C) (l₂ : Lens A B) → Lens.set (l₁ ∘ l₂) a c ≡ Lens.set l₂ a (Lens.set l₁ (Lens.get l₂ a) c) set-∘≡ {a = a} {c = c} l₁@(lens _ _ _ _) l₂@(lens _ _ _ _) = proj₁ (get⁻¹-const l₂ (get l₂ a) (proj₁ (get⁻¹-const l₁ c′ c ( get l₂ a , _↔_.to (subst (λ b → get l₁ b ≡ c′ ↔ c′ ≡ c′) (refl _) F.id) (refl _)) )) (a , sym (refl _))) ≡⟨ cong₂ (λ f eq → proj₁ (get⁻¹-const l₂ _ (proj₁ (get⁻¹-const l₁ _ _ (_ , _↔_.to f (refl _)))) (_ , eq))) (subst-refl _ _) sym-refl ⟩ proj₁ (get⁻¹-const l₂ (get l₂ a) (proj₁ (get⁻¹-const l₁ c′ c (get l₂ a , refl _))) (a , refl _)) ≡⟨⟩ set l₂ a (set l₁ (get l₂ a) c) ∎ where open Lens c′ = get l₁ (get l₂ a) -- Composition for higher lenses, defined under the assumption that -- the resulting codomain is inhabited if it is merely inhabited. infix 9 ⟨_⟩_⊚_ ⟨_⟩_⊚_ : (∥ C ∥ → C) → Higher.Lens B C → Higher.Lens A B → Higher.Lens A C ⟨_⟩_⊚_ {C = C} {B = B} {A = A} ∥C∥→C = curry ( Higher.Lens B C × Higher.Lens A B ↝⟨ Σ-map higher→ higher→ ⟩ Lens B C × Lens A B ↝⟨ uncurry _∘_ ⟩ Lens A C ↝⟨ →higher ∥C∥→C ⟩□ Higher.Lens A C □) -- The setter of the resulting lens is defined in the "right" way. set-⊚≡ : ∀ ∥C∥→C (l₁ : Higher.Lens B C) (l₂ : Higher.Lens A B) → Higher.Lens.set (⟨ ∥C∥→C ⟩ l₁ ⊚ l₂) a c ≡ Higher.Lens.set l₂ a (Higher.Lens.set l₁ (Higher.Lens.get l₂ a) c) set-⊚≡ {a = a} {c = c} ∥C∥→C l₁ l₂ = set (⟨ ∥C∥→C ⟩ l₁ ⊚ l₂) a c ≡⟨ cong (λ f → f a c) $ proj₂ $ →higher-preserves-getters-and-setters ∥C∥→C (higher→ l₁ ∘ higher→ l₂) ⟩ Lens.set (higher→ l₁ ∘ higher→ l₂) a c ≡⟨ set-∘≡ (higher→ l₁) (higher→ l₂) ⟩ Lens.set (higher→ l₂) a (Lens.set (higher→ l₁) (Lens.get (higher→ l₂) a) c) ≡⟨ cong (λ f → Lens.set (higher→ l₂) a (Lens.set (higher→ l₁) (f a) c)) $ proj₁ $ higher→-preserves-getters-and-setters l₂ ⟩ Lens.set (higher→ l₂) a (Lens.set (higher→ l₁) (get l₂ a) c) ≡⟨ cong (λ f → Lens.set (higher→ l₂) a (f (get l₂ a) c)) $ proj₂ $ higher→-preserves-getters-and-setters l₁ ⟩ Lens.set (higher→ l₂) a (set l₁ (get l₂ a) c) ≡⟨ cong (λ f → f a (set l₁ (get l₂ a) c)) $ proj₂ $ higher→-preserves-getters-and-setters l₂ ⟩∎ set l₂ a (set l₁ (get l₂ a) c) ∎ where open Higher.Lens -- The implementation of composition for higher lenses given above -- matches the one in Higher when both are defined (assuming -- univalence). ⊚≡∘ : ∀ a b {A : Set (a ⊔ b ⊔ c)} {B : Set (b ⊔ c)} {C : Set c} → Univalence (a ⊔ b ⊔ c) → (∥C∥→C : ∥ C ∥ → C) → ⟨_⟩_⊚_ {B = B} {A = A} ∥C∥→C ≡ Higher.Lens-combinators.⟨ a , b ⟩_∘_ ⊚≡∘ a b {A = A} {B = B} {C = C} univ ∥C∥→C = Higher.Lens-combinators.composition≡∘ a b univ ∥C∥→C ⟨ ∥C∥→C ⟩_⊚_ (λ l₁ l₂ _ _ → set-⊚≡ ∥C∥→C l₁ l₂)
{ "alphanum_fraction": 0.3994531593, "avg_line_length": 45.099909991, "ext": "agda", "hexsha": "52b5be80acaa58d7fb5d59315704c0cad9aecee2", "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": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Saizan/dependent-lenses", "max_forks_repo_path": "src/Lens/Non-dependent/Equivalent-preimages.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "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": "Saizan/dependent-lenses", "max_issues_repo_path": "src/Lens/Non-dependent/Equivalent-preimages.agda", "max_line_length": 153, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Saizan/dependent-lenses", "max_stars_repo_path": "src/Lens/Non-dependent/Equivalent-preimages.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 17815, "size": 50106 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Join where open import Cubical.HITs.Join.Base public -- open import Cubical.HITs.Join.Properties public
{ "alphanum_fraction": 0.7547169811, "avg_line_length": 22.7142857143, "ext": "agda", "hexsha": "b949fcec822897a448cc4088e950f86d332be833", "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": "48bd72e073b11d7501342d88eede05974a616977", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/cubical", "max_forks_repo_path": "Cubical/HITs/Join.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "48bd72e073b11d7501342d88eede05974a616977", "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": "loic-p/cubical", "max_issues_repo_path": "Cubical/HITs/Join.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "48bd72e073b11d7501342d88eede05974a616977", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/cubical", "max_stars_repo_path": "Cubical/HITs/Join.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 41, "size": 159 }
-- imports open import Data.Nat as ℕ using (ℕ; suc; zero; _+_; _∸_) open import Data.Vec as Vec using (Vec; _∷_; []; tabulate; foldr) open import Data.Fin as Fin using (Fin; suc; zero) open import Function using (_∘_; const; id) open import Data.List as List using (List; _∷_; []) open import Data.Maybe using (Maybe; just; nothing) -- Without square cutoff optimization module Simple where primes : ∀ n → List (Fin n) primes zero = [] primes (suc zero) = [] primes (suc (suc zero)) = [] primes (suc (suc (suc m))) = sieve (tabulate (just ∘ suc)) where sieve : ∀ {n} → Vec (Maybe (Fin (2 + m))) n → List (Fin (3 + m)) sieve [] = [] sieve (nothing ∷ xs) = sieve xs sieve (just x ∷ xs) = suc x ∷ sieve (foldr B remove (const []) xs x) where B = λ n → ∀ {i} → Fin i → Vec (Maybe (Fin (2 + m))) n remove : ∀ {n} → Maybe (Fin (2 + m)) → B n → B (suc n) remove _ ys zero = nothing ∷ ys x remove y ys (suc z) = y ∷ ys z -- With square cutoff optimization module SquareOpt where primes : ∀ n → List (Fin n) primes zero = [] primes (suc zero) = [] primes (suc (suc zero)) = [] primes (suc (suc (suc m))) = sieve 1 m (Vec.tabulate (just ∘ Fin.suc ∘ Fin.suc)) where sieve : ∀ {n} → ℕ → ℕ → Vec (Maybe (Fin (3 + m))) n → List (Fin (3 + m)) sieve _ zero = List.mapMaybe id ∘ Vec.toList sieve _ (suc _) [] = [] sieve i (suc l) (nothing ∷ xs) = sieve (suc i) (l ∸ i ∸ i) xs sieve i (suc l) (just x ∷ xs) = x ∷ sieve (suc i) (l ∸ i ∸ i) (Vec.foldr B remove (const []) xs i) where B = λ n → ℕ → Vec (Maybe (Fin (3 + m))) n remove : ∀ {i} → Maybe (Fin (3 + m)) → B i → B (suc i) remove _ ys zero = nothing ∷ ys i remove y ys (suc j) = y ∷ ys j
{ "alphanum_fraction": 0.5342541436, "avg_line_length": 38.5106382979, "ext": "agda", "hexsha": "aa17f521e88209f8484cf153212f8f1c7e1d13bb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": [ "Info-ZIP" ], "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_path": "Task/Sieve-of-Eratosthenes/Agda/sieve-of-eratosthenes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Info-ZIP" ], "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_path": "Task/Sieve-of-Eratosthenes/Agda/sieve-of-eratosthenes.agda", "max_line_length": 103, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": [ "Info-ZIP" ], "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_path": "Task/Sieve-of-Eratosthenes/Agda/sieve-of-eratosthenes.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T13:42:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-05T13:42:20.000Z", "num_tokens": 640, "size": 1810 }
-- Andreas, 2020-09-28, issue #4950 -- Ranges for missing definitions should not include -- non-missing definitions. A B C : Set₁ -- only B should be highlighted A = Set C = Set -- The following names are declared but not accompanied by a -- definition: B -- Error range was: -- line,3-13 -- The error range should not include C nor Set₁. -- line,3-4
{ "alphanum_fraction": 0.6974789916, "avg_line_length": 19.8333333333, "ext": "agda", "hexsha": "a347f7b85e58149a67f9b38b7c016d39d952b756", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue4950.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/Issue4950.agda", "max_line_length": 60, "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/Issue4950.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": 102, "size": 357 }
{-# OPTIONS --without-K --safe #-} module Dodo.Binary.Filter where -- Stdlib imports import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; _≢_; refl; subst; cong; cong₂) renaming (sym to ≡-sym; trans to ≡-trans) open import Level using (Level; _⊔_) open import Data.Empty using (⊥) open import Data.Product using (∃-syntax; _,_) open import Relation.Unary using (Pred; _∈_) open import Relation.Binary using (Rel; Transitive) open import Relation.Binary.Construct.Closure.Transitive using (TransClosure; [_]; _∷_) -- Local imports open import Dodo.Unary.Equality open import Dodo.Unary.Unique open import Dodo.Binary.Equality open import Dodo.Binary.Transitive -- # Definitions -- | A value of type `A` with a proof that it satisfies the given predicate `P`. -- -- -- # Design Decision: Alternative to `P x` -- -- One might argue that a function could just as well take: -- > f : {x : A} → P x → ... -- -- In that case, the `with-pred` constructor adds nothing. However, crucially, -- the inhabitant of `A` is /not/ included in the type signature of `WithPred`. -- This means, a relation may be defined over elements of type `WithPred`. -- While a relation /cannot/ be defined over elements of type `P x`, because -- `x` varies. data WithPred {a ℓ : Level} {A : Set a} (P : Pred A ℓ) : Set (a ⊔ ℓ) where with-pred : (x : A) → P x → WithPred P -- | Helper for extracting element equality from an instance of `WithPred`. -- -- This is tricky to unify otherwise in larger contexts, as `Px` and `Py` have -- different /types/ when `x` and `y` are unequal. with-pred-≡ : ∀ {a ℓ : Level} {A : Set a} {P : Pred A ℓ} {x y : A} {Px : P x} {Py : P y} → with-pred x Px ≡ with-pred y Py ------------------------------- → x ≡ y with-pred-≡ refl = refl -- | Instances of `WithPred` are equal if they are defined over the same value, -- and its predicate is unique. with-pred-unique : ∀ {a ℓ : Level} {A : Set a} {P : Pred A ℓ} → UniquePred P → {x y : A} → x ≡ y → (Px : P x) (Py : P y) ------------------------------- → with-pred x Px ≡ with-pred y Py with-pred-unique uniqueP {x} refl Px Py = cong (with-pred x) (uniqueP _ Px Py) with-pred-≢ : ∀ {a ℓ : Level} {A : Set a} {P : Pred A ℓ} → UniquePred P → {x y : A} {Px : P x} {Py : P y} → with-pred x Px ≢ with-pred y Py ------------------------------- → x ≢ y with-pred-≢ uniqueP Px≢Py x≡y = Px≢Py (with-pred-unique uniqueP x≡y _ _) -- | A relation whose elements all satisfy `P`. -- -- Note that this differs from defining: -- > R ∩₂ ( P ×₂ P ) -- -- In that case, the type signature is still identical to the type signature of -- `R` (except for the universe level). However, `filter-rel` alters the type, -- which proves no other inhabitants can exist. -- -- This is in particular useful for properties that are declared over an entire -- relation (such as `Trichotomous`), while they should only hold over a subset -- of it. -- -- -- # Example -- -- For instance, consider: -- (1) > Trichotomous _≡_ (filter-rel P R) -- and -- (2) > Trichotomous _≡_ (R ∩₂ ( P ×₂ P )) -- -- Where the corresponding types are: -- > R : Rel A ℓzero -- > P : Pred A ℓzero -- -- The type of the relation in (1) is then: -- > filter-rel P R : Rel (WithPred P) ℓzero -- While the type of the relation in (2) is: -- > (R ∩₂ (P ×₂ P)) : Rel A ℓzero -- -- So, for (2), defining `Trichotomous` means that it finds an instance of -- `P` for both elements, even when no such `P x` exists; Which leads to a -- contradiction. Whereas (1) will only find the relation if `P` holds for both -- elements. -- -- Effectively, (2) implies: -- > ∀ (x : A) → P x -- -- Whereas (1) makes no such strong claims. filter-rel : ∀ {a ℓ₁ ℓ₂ : Level} {A : Set a} → (P : Pred A ℓ₁) → Rel A ℓ₂ ------------------- → Rel (WithPred P) ℓ₂ filter-rel P R (with-pred x Px) (with-pred y Py) = R x y -- | Effectively the inverse of `filter-rel`. -- -- It loses the type-level restrictions, but preserves the restrictions on -- value-level. unfilter-rel : ∀ {a ℓ₁ ℓ₂ : Level} {A : Set a} → {P : Pred A ℓ₁} → Rel (WithPred P) ℓ₂ ------------------- → Rel A (ℓ₁ ⊔ ℓ₂) unfilter-rel R x y = ∃[ Px ] ∃[ Py ] R (with-pred x Px) (with-pred y Py) -- | Helper for unwrapping the value from the `with-pred` constructor. un-with-pred : {a ℓ : Level} {A : Set a} {P : Pred A ℓ} → WithPred P ---------- → A un-with-pred (with-pred x _) = x ⁺-strip-filter : {a ℓ₁ ℓ₂ : Level} {A : Set a} → {P : Pred A ℓ₁} → {R : Rel A ℓ₂} → {x y : A} → {Px : P x} {Py : P y} → TransClosure (filter-rel P R) (with-pred x Px) (with-pred y Py) --------------------------------------------------------------- → TransClosure R x y ⁺-strip-filter [ x∼y ] = [ x∼y ] ⁺-strip-filter (_∷_ {_} {with-pred z Pz} Rxz R⁺zy) = Rxz ∷ ⁺-strip-filter R⁺zy -- | Apply a relation filter to a chain /from right to left/. -- -- This applies when a predicate `P x` is true whenever `R x y` and `P y` are true. -- Then, for any chain where `P` holds for the final element, it holds for every -- element in the chain. ⁺-filter-relˡ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} {R : Rel A ℓ₂} → (f : ∀ {x y : A} → P y → R x y → P x) → {x y : A} → (Px : P x) (Py : P y) → (R⁺xy : TransClosure R x y) --------------------------------------------------------------- → TransClosure (filter-rel P R) (with-pred x Px) (with-pred y Py) ⁺-filter-relˡ f Px Py [ Rxy ] = [ Rxy ] ⁺-filter-relˡ f Px Py ( Rxz ∷ R⁺zy ) = Rxz ∷ ⁺-filter-relˡ f (⁺-predˡ f R⁺zy Py) Py R⁺zy -- | Apply a relation filter to a chain /from left to right/. -- -- This applies when a predicate `P y` is true whenever `R x y` and `P x` are true. -- Then, for any chain where `P` holds for the first element, it holds for every -- element in the chain. ⁺-filter-relʳ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} {R : Rel A ℓ₂} → (f : ∀ {x y : A} → P x → R x y → P y) → {x y : A} → (Px : P x) (Py : P y) → (R⁺xy : TransClosure R x y) --------------------------------------------------------------- → TransClosure (filter-rel P R) (with-pred x Px) (with-pred y Py) ⁺-filter-relʳ f Px Py [ Rxy ] = [ Rxy ] ⁺-filter-relʳ f Px Py ( Rxz ∷ R⁺zy ) = Rxz ∷ ⁺-filter-relʳ f (f Px Rxz) Py R⁺zy -- # Properties module _ {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} {Q : Pred A ℓ₂} where with-pred-⊆₁ : P ⊆₁ Q → WithPred P ---------- → WithPred Q with-pred-⊆₁ P⊆Q (with-pred x Px) = with-pred x (⊆₁-apply P⊆Q Px) module _ {a ℓ₁ ℓ₂ : Level} {A : Set a} where filter-rel-⊆₂ : (R : Rel A ℓ₁) → {P : Pred A ℓ₂} ---------------------------------- → unfilter-rel (filter-rel P R) ⊆₂ R filter-rel-⊆₂ R {P} = ⊆: ⊆-proof where ⊆-proof : unfilter-rel (filter-rel P R) ⊆₂' R ⊆-proof _ _ (_ , _ , Rxy) = Rxy module _ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Rel A ℓ₃} where filter-rel-preserves-⊆₁ : P ⊆₁ Q -------------------------------------------------------------- → unfilter-rel (filter-rel P R) ⊆₂ unfilter-rel (filter-rel Q R) filter-rel-preserves-⊆₁ P₁⊆P₂ = ⊆: lemma where lemma : unfilter-rel (filter-rel P R) ⊆₂' unfilter-rel (filter-rel Q R) lemma _ _ (P₁x , P₁y , Qxy) = (⊆₁-apply P₁⊆P₂ P₁x , ⊆₁-apply P₁⊆P₂ P₁y , Qxy) -- | -- -- Note that this does /not/ hold in general for subsets of relations. -- That is, the following does /not/ hold: -- > Q ⊆₂ R → Transitive R → Transitive Q -- -- After all, if `Q x y` and `Q y z` hold, then `R x y` and `R y z` hold, -- then `R x z` holds. However, it does not mean that `Q x z` holds. trans-filter-rel-⊆₁ : P ⊆₁ Q → Transitive (filter-rel Q R) --------------------------- → Transitive (filter-rel P R) trans-filter-rel-⊆₁ P⊆Q transQR {Pi} {Pj} {Pk} Rij Rjk = let Qi = with-pred-⊆₁ P⊆Q Pi Qj = with-pred-⊆₁ P⊆Q Pj Qk = with-pred-⊆₁ P⊆Q Pk in Q⇒P {Pi} {Pk} (transQR {Qi} {Qj} {Qk} (P⇒Q {Pi} {Pj} Rij) (P⇒Q {Pj} {Pk} Rjk)) where P⇒Q : ∀ {x y : WithPred P} → filter-rel P R x y → filter-rel Q R (with-pred-⊆₁ P⊆Q x) (with-pred-⊆₁ P⊆Q y) P⇒Q {with-pred _ _} {with-pred _ _} Rxy = Rxy Q⇒P : ∀ {x y : WithPred P} → filter-rel Q R (with-pred-⊆₁ P⊆Q x) (with-pred-⊆₁ P⊆Q y) → filter-rel P R x y Q⇒P {with-pred _ _} {with-pred _ _} Rxy = Rxy module _ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {P : Pred A ℓ₁} {R : Rel A ℓ₂} {Q : Rel A ℓ₃} where filter-rel-preserved-⊆₂ : R ⊆₂ Q -------------------------------------------------------------- → unfilter-rel (filter-rel P R) ⊆₂ unfilter-rel (filter-rel P Q) filter-rel-preserved-⊆₂ R⊆Q = ⊆: lemma where lemma : unfilter-rel (filter-rel P R) ⊆₂' unfilter-rel (filter-rel P Q) lemma x y (Px , Py , Rxy) = Px , Py , ⊆₂-apply R⊆Q Rxy -- # Operations module _ {a ℓ₁ ℓ₂ : Level} {A : Set a} {R : Rel A ℓ₁} {P : Pred A ℓ₂} {x y : A} where filter-rel-dom : unfilter-rel (filter-rel P R) x y --------------------------------- → x ∈ P filter-rel-dom (Px , Py , Rxy) = Px filter-rel-codom : unfilter-rel (filter-rel P R) x y --------------------------------- → y ∈ P filter-rel-codom (Px , Py , Rxy) = Py
{ "alphanum_fraction": 0.5556399957, "avg_line_length": 34.6278195489, "ext": "agda", "hexsha": "938cb4b2047bbac767736ce033785aaebb9227aa", "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/Filter.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/Filter.agda", "max_line_length": 110, "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/Filter.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3354, "size": 9211 }
module _ where open import DeadCodePatSyn.Lib typeOf : {A : Set} → A → Set typeOf {A} _ = A -- Check that pattern synonyms count when computing dead code f : typeOf not-hidden → Set₁ f not-hidden = Set
{ "alphanum_fraction": 0.7038834951, "avg_line_length": 17.1666666667, "ext": "agda", "hexsha": "278ec2dbbb848e0810fad9923028f5a5c5532677", "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/DeadCodePatSyn.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/DeadCodePatSyn.agda", "max_line_length": 61, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/DeadCodePatSyn.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": 206 }
module Hide where record 𝔹ottom : Set₁ where field ⊥ : Set open 𝔹ottom ⦃ … ⦄ public 𝔹ottomPrelude : 𝔹ottom 𝔹ottomPrelude = record { ⊥ = P.⊥ } where open import Prelude.Empty as P instance instance𝔹ottom : 𝔹ottom instance𝔹ottom = 𝔹ottomPrelude
{ "alphanum_fraction": 0.7215686275, "avg_line_length": 17, "ext": "agda", "hexsha": "ce675e13b7f1b55f6a108b7119ba274b1b143484", "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/Hide.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/Hide.agda", "max_line_length": 40, "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/Hide.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 102, "size": 255 }
module All where import Prelude import Star import Nat import List import Vec import Elem import Fin import Modal import Lambda import Span import MapTm import Examples
{ "alphanum_fraction": 0.8352941176, "avg_line_length": 11.3333333333, "ext": "agda", "hexsha": "3d8d371cf1d54491a427382446c87e8a97f8dc11", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/AIM6/Path/All.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/AIM6/Path/All.agda", "max_line_length": 16, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/AIM6/Path/All.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": 42, "size": 170 }
-- Andreas, 2020-12-15, re PR #5020 -- Test error message "Must not specify multiple frontends" -- See respective .flags file -- Expected error: -- Must not specify multiple frontends (--interaction, --interaction-json)
{ "alphanum_fraction": 0.7297297297, "avg_line_length": 27.75, "ext": "agda", "hexsha": "0eeb700e339592853af4c1c387fd6ae464451274", "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/MultipleFrontEnds.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/MultipleFrontEnds.agda", "max_line_length": 74, "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/MultipleFrontEnds.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": 54, "size": 222 }