Search is not available for this dataset
text
string
meta
dict
module Extensions.Vec where open import Data.Product hiding (map; zip) open import Data.Nat open import Data.Fin open import Data.Vec open import Data.Product hiding (map) open import Relation.Binary.PropositionalEquality hiding ([_]) open import Data.List as L using () open import Data.List.Properties open import Relation.Binary.HeterogeneousEquality as H using () open ≡-Reasoning public private module HR = H.≅-Reasoning []=-functional : ∀ {a n} {A : Set a} (l : Vec A n) i → ∀ {x y : A} → l [ i ]= x → l [ i ]= y → x ≡ y []=-functional .(_ ∷ _) _ here here = refl []=-functional .(_ ∷ _) .(suc _) (there p) (there q) = []=-functional _ _ p q lookup⋆map : ∀ {a b : Set} {n} (v : Vec a n) (f : a → b) x → f (lookup x v) ≡ lookup x (map f v) lookup⋆map [] f () lookup⋆map (x ∷ xs) f zero = refl lookup⋆map (x ∷ xs) f (suc y) = lookup⋆map xs f y strong-lookup : ∀ {a} {A : Set a} {n} → (v : Vec A n) → (i : Fin n) → ∃ λ x → v [ i ]= x strong-lookup (x ∷ v) zero = x , here strong-lookup (x ∷ v) (suc i) with strong-lookup v i ... | y , p = y , there p ∷⋆map : ∀ {a b : Set} {n} (f : a → b) (x : a) (xs : Vec a n) → map f (x ∷ xs) ≡ f x ∷ (map f xs) ∷⋆map f x [] = refl ∷⋆map f x (y ∷ xs) = cong (_∷_ (f x)) (∷⋆map f y xs) -- TODO replace with []=↔lookup ∈⟶index : ∀ {A : Set} {n} {v : Vec A n} {a : A} → a ∈ v → ∃ λ i → lookup i v ≡ a ∈⟶index here = zero , refl ∈⟶index (there e) with ∈⟶index e ∈⟶index (there e) | i , lookup-i≡a = suc i , lookup-i≡a ∈⋆map : ∀ {A B : Set} {n} {v : Vec A n} {a} → a ∈ v → (f : A → B) → (f a) ∈ (map f v) ∈⋆map here f = here ∈⋆map (there a∈v) f = there (∈⋆map a∈v f) ∷-cong : ∀ {l n n'} {A : Set l} {x : A} {xs : Vec A n} {xs' : Vec A n'} → n ≡ n' → xs H.≅ xs' → x ∷ xs H.≅ x ∷ xs' ∷-cong refl H.refl = H.refl fromList-map : ∀ {l} {A B : Set l} (f : A → B) (xs : L.List A) → (fromList ((L.map f xs))) H.≅ (map f (fromList xs)) fromList-map f L.[] = H.refl fromList-map f (x L.∷ xs) = ∷-cong (length-map _ xs) (fromList-map f xs) length-toList : ∀ {A : Set } {n} (v : Vec A n) → L.length (toList v) ≡ n length-toList [] = refl length-toList (x ∷ v) = cong suc (length-toList v) length-map-toList : ∀ {A B : Set} {n} {f : A → B} (v : Vec A n) → L.length (L.map f (toList v)) ≡ n length-map-toList {n = n} {f} v = begin L.length (L.map f (toList v)) ≡⟨ length-map f (toList v) ⟩ L.length (toList v) ≡⟨ length-toList v ⟩ n ∎ lookup-≔ : ∀ {n k} {A : Set k} (v : Vec A n) i (a : A) → lookup i (v [ i ]≔ a) ≡ a lookup-≔ (x ∷ v) zero a = refl lookup-≔ (x ∷ v) (suc i) a = lookup-≔ v i a infixl 4 _⊑_ data _⊑_ {a} {A : Set a} : ∀ {n m} → Vec A n -> Vec A m -> Set where [] : ∀ {n} {xs : Vec A n} → [] ⊑ xs _∷_ : ∀ {n m} x {xs : Vec A n} {ys : Vec A m} -> xs ⊑ ys -> (x ∷ xs) ⊑ (x ∷ ys) infixl 4 _⊒_ _⊒_ : ∀ {a} {A : Set a} {n m} → Vec A n -> Vec A m -> Set xs ⊒ ys = ys ⊑ xs open import Relation.Binary.Core using (Reflexive; Transitive) ⊑-refl : ∀ {a n} {A : Set a} → Reflexive (_⊑_ {A = A} {n = n}) ⊑-refl {x = []} = [] ⊑-refl {x = x ∷ xs} = x ∷ ⊑-refl ⊑-trans : ∀ {a n m k} {A : Set a} {xs : Vec A n} {ys : Vec A m} {zs : Vec A k} → xs ⊑ ys → ys ⊑ zs → xs ⊑ zs ⊑-trans [] [] = [] ⊑-trans [] (x ∷ b) = [] ⊑-trans (x ∷ xs) (.x ∷ ys) = x ∷ (⊑-trans xs ys) ∷ʳ-⊒ : ∀ {a} {A : Set a} (x : A) {n} (xs : Vec A n) → xs ∷ʳ x ⊒ xs ∷ʳ-⊒ x [] = [] ∷ʳ-⊒ x (x₁ ∷ Σ₁) = x₁ ∷ (∷ʳ-⊒ x Σ₁) xs⊒ys-length : ∀ {a n m} {A : Set a} {xs : Vec A n} {ys : Vec A m} → xs ⊒ ys → n ≥ m xs⊒ys-length [] = z≤n xs⊒ys-length (x ∷ p) = s≤s (xs⊒ys-length p) xs⊒ys[i] : ∀ {a n m} {A : Set a} {xs : Vec A n} {ys : Vec A m} {i y} → xs [ i ]= y → (p : ys ⊒ xs) → ys [ inject≤ i (xs⊒ys-length p) ]= y xs⊒ys[i] here (x ∷ q) = here xs⊒ys[i] (there p) (x ∷ q) = there (xs⊒ys[i] p q) ∷ʳ[length] : ∀ {a n} {A : Set a} (l : Vec A n) x → ∃ λ i → (l ∷ʳ x) [ i ]= x ∷ʳ[length] [] _ = , here ∷ʳ[length] (x ∷ Σ) y with ∷ʳ[length] Σ y ∷ʳ[length] (x ∷ Σ₁) y | i , p = (suc i) , there p -- Moar All properties open import Data.Vec.All all-lookup' : ∀ {a p} {A : Set a} {P : A → Set p} {k} {xs : Vec A k} {i x} → xs [ i ]= x → All P xs → P x all-lookup' here (px ∷ _) = px all-lookup' (there p) (_ ∷ xs) = all-lookup' p xs -- proof matters; update a particular witness of a property _All[_]≔_ : ∀ {a p} {A : Set a} {P : A → Set p} {k} {xs : Vec A k} {i x} → All P xs → xs [ i ]= x → P x → All P xs [] All[ () ]≔ px (px ∷ xs) All[ here ]≔ px' = px' ∷ xs (px ∷ xs) All[ there i ]≔ px' = px ∷ (xs All[ i ]≔ px') _all-∷ʳ_ : ∀ {a n p} {A : Set a} {l : Vec A n} {x} {P : A → Set p} → All P l → P x → All P (l ∷ʳ x) _all-∷ʳ_ [] q = q ∷ [] _all-∷ʳ_ (px ∷ p) q = px ∷ (p all-∷ʳ q)
{ "alphanum_fraction": 0.4914067473, "avg_line_length": 35.7045454545, "ext": "agda", "hexsha": "91a704851e01e67377029bd4dcdfd4da0aa8d68e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Extensions/Vec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Extensions/Vec.agda", "max_line_length": 99, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Extensions/Vec.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 2222, "size": 4713 }
module _ where open import Agda.Primitive open import Agda.Builtin.Equality open import Agda.Builtin.Sigma record Category {o h} : Set (lsuc (o ⊔ h)) where no-eta-equality constructor con field Obj : Set o Hom : Obj → Obj → Set h field id : ∀ {X : Obj} → Hom X X comp : ∀ {X Y Z} → Hom Y Z → Hom X Y → Hom X Z id-left : ∀ {X Y} (f : Hom X Y) → comp id f ≡ f open Category postulate isSet : ∀ {l} → (X : Set l) → Set l hSets : (o : Level) → Category hSets o .Obj = Σ (Set o) isSet hSets o .Hom (A , _) (B , _) = A → B hSets o .id = \ x → x hSets o .comp f g = \ x → f (g x) hSets o .id-left f = refl
{ "alphanum_fraction": 0.5275362319, "avg_line_length": 22.2580645161, "ext": "agda", "hexsha": "bae417e1b953b266ebf1557848180b8b9b4d7079", "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/Issue2968.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/Issue2968.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/Issue2968.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": 251, "size": 690 }
-- Andreas, 2015-09-07 Issue reported by identicalsnowflake data D : Set1 where field A : Set -- WAS: Internal error (on master) -- NOW: -- Illegal declaration in data type definition -- field A : Set -- when scope checking the declaration -- data D where -- field A : Set
{ "alphanum_fraction": 0.6701030928, "avg_line_length": 19.4, "ext": "agda", "hexsha": "ba62070079fa0fd1152edc647480e54702aebcec", "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/Issue1639.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/Issue1639.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/Issue1639.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": 80, "size": 291 }
module Issue175b where data _≡_ {A : Set}(x : A) : A → Set where refl : x ≡ x data Bool : Set where true : Bool false : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN TRUE true #-} {-# BUILTIN FALSE false #-} postulate ℝ : Set {-# BUILTIN FLOAT ℝ #-} primitive -- ℝ functions primFloatMinus : ℝ -> ℝ -> ℝ primFloatNumericalLess : ℝ -> ℝ -> Bool _<_ : ℝ -> ℝ -> Bool a < b = primFloatNumericalLess a b data _≤_ : ℝ -> ℝ -> Set where ≤_ : {x y : ℝ} -> (x < y) ≡ true -> x ≤ y --absolute value [|_|] : ℝ -> ℝ [| a |] with (a < 0.0) [| a |] | true = primFloatMinus 0.0 a [| a |] | false = a --error variable ε : ℝ ε = 1.0e-5 -- two floating point numbers can be said to be equal if their -- difference is less than the given error variable postulate reflℝ : {a b : ℝ} -> [| primFloatMinus a b |] ≤ ε -> a ≡ b test : 1.0 ≡ 1.0000001 test = reflℝ (≤ refl)
{ "alphanum_fraction": 0.576, "avg_line_length": 19.4444444444, "ext": "agda", "hexsha": "14c4b02a1d159e73fad1d18d11421a61eb02f604", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue175b.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue175b.agda", "max_line_length": 62, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue175b.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": 323, "size": 875 }
module Nom where open import Basics open import Pr data Nom : Set where Ze : Nom Su : Nom -> Nom Pu : Nom -> Nom _NomQ_ : Nom -> Nom -> Pr Ze NomQ Ze = tt Ze NomQ (Su y) = ff Ze NomQ (Pu y) = ff (Su x) NomQ Ze = ff (Su x) NomQ (Su y) = x eq y (Su x) NomQ (Pu y) = ff (Pu x) NomQ Ze = ff (Pu x) NomQ (Su y) = ff (Pu x) NomQ (Pu y) = x eq y nomQ : {x y : Nom} -> [| (x eq y) => (x NomQ y) |] nomQ {Ze} refl = _ nomQ {Su x} refl = refl nomQ {Pu x} refl = refl nomEq : (x y : Nom) -> Decision (x eq y) nomEq Ze Ze = yes refl nomEq Ze (Su y) = no nomQ nomEq Ze (Pu y) = no nomQ nomEq (Su x) Ze = no nomQ nomEq (Su x) (Su y) with nomEq x y nomEq (Su x) (Su .x) | yes refl = yes refl nomEq (Su x) (Su y) | no p = no (p o nomQ) nomEq (Su x) (Pu y) = no nomQ nomEq (Pu x) Ze = no nomQ nomEq (Pu x) (Su y) = no nomQ nomEq (Pu x) (Pu y) with nomEq x y nomEq (Pu x) (Pu .x) | yes refl = yes refl nomEq (Pu x) (Pu y) | no p = no (p o nomQ) data Nat : Set where ze : Nat su : Nat -> Nat pfog : Nom -> Nat pfog Ze = ze pfog (Su x) = pfog x pfog (Pu x) = su (pfog x) NatGE : Nat -> Nat -> Bool NatGE ze _ = false NatGE (su _) ze = true NatGE (su x) (su y) = NatGE x y _>_ : Nat -> Nat -> Pr x > y = So (NatGE x y) _>?_ : (x y : Nat) -> Decision (x > y) x >? y = so (NatGE x y) _P>_ : Nom -> Nom -> Pr x P> y = pfog x > pfog y _S+_ : Nat -> Nom -> Nom ze S+ y = y su x S+ y = Su (x S+ y) PSlem : (n : Nat)(x : Nom) -> Id (pfog (n S+ x)) (pfog x) PSlem ze x = refl PSlem (su n) x = PSlem n x Plem : (x y : Nom) -> [| x P> y |] -> [| Pu x P> y |] Plem _ Ze p = _ Plem x (Su y) p = Plem x y p Plem Ze (Pu y) () Plem (Su x) (Pu y) p = Plem x (Pu y) p Plem (Pu x) (Pu y) p = Plem x y p asym : (x : Nom) -> [| ∼ (x P> x) |] asym Ze () asym (Su x) p = asym x p asym (Pu x) p = asym x p record Nominal (X : Set) : Set1 where field Everywhere : Pow Nom -> Pow X everywhere : (P Q : Pow Nom) -> [| P ==> Q |] -> [| Everywhere P ==> Everywhere Q |]
{ "alphanum_fraction": 0.5285497726, "avg_line_length": 21.9888888889, "ext": "agda", "hexsha": "eb133c05cd6e22940a43f71a741330e007659a85", "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": "benchmark/Syntacticosmos/Nom.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": "benchmark/Syntacticosmos/Nom.agda", "max_line_length": 57, "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": "benchmark/Syntacticosmos/Nom.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": 858, "size": 1979 }
module Issue4954.M (_ : Set₁) where
{ "alphanum_fraction": 0.7222222222, "avg_line_length": 18, "ext": "agda", "hexsha": "4e03ae395ccecdfa095613589acb93c0891693b9", "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/Issue4954/M.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/Issue4954/M.agda", "max_line_length": 35, "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/Issue4954/M.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": 12, "size": 36 }
{- Definition of function fixpoint and Kraus' lemma -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Functions.Fixpoint where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Path private variable ℓ : Level A : Type ℓ Fixpoint : (A → A) → Type _ Fixpoint {A = A} f = Σ A (λ x → f x ≡ x) fixpoint : {f : A → A} → Fixpoint f → A fixpoint = fst fixpointPath : {f : A → A} → (p : Fixpoint f) → f (fixpoint p) ≡ fixpoint p fixpointPath = snd -- Kraus' lemma -- a version not using cubical features can be found at -- https://www.cs.bham.ac.uk/~mhe/GeneralizedHedberg/html/GeneralizedHedberg.html#21576 2-Constant→isPropFixpoint : (f : A → A) → 2-Constant f → isProp (Fixpoint f) 2-Constant→isPropFixpoint f fconst (x , p) (y , q) i = s i , t i where noose : ∀ x y → f x ≡ f y noose x y = sym (fconst x x) ∙ fconst x y -- the main idea is that for any path p, cong f p does not depend on p -- but only on its endpoints and the structure of 2-Constant f KrausInsight : ∀ {x y} → (p : x ≡ y) → noose x y ≡ cong f p KrausInsight {x} = J (λ y p → noose x y ≡ cong f p) (lCancel (fconst x x)) -- Need to solve for a path s : x ≡ y, such that: -- transport (λ i → cong f s i ≡ s i) p ≡ q s : x ≡ y s = sym p ∙∙ noose x y ∙∙ q t' : PathP (λ i → noose x y i ≡ s i) p q t' i j = doubleCompPath-filler (sym p) (noose x y) q j i t : PathP (λ i → cong f s i ≡ s i) p q t = subst (λ kraus → PathP (λ i → kraus i ≡ s i) p q) (KrausInsight s) t'
{ "alphanum_fraction": 0.635, "avg_line_length": 35.5555555556, "ext": "agda", "hexsha": "e6c3eac08db1d0c4a94964b22e04510e770e3b78", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Functions/Fixpoint.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Functions/Fixpoint.agda", "max_line_length": 87, "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/Functions/Fixpoint.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 609, "size": 1600 }
-- Andreas, 2015-08-27 use imported rewrite rule {-# OPTIONS --rewriting #-} open import Common.Nat open import Common.Equality open import Issue1550 x+0+0+0 : ∀{x} → ((x + 0) + 0) + 0 ≡ x x+0+0+0 = refl
{ "alphanum_fraction": 0.6394230769, "avg_line_length": 17.3333333333, "ext": "agda", "hexsha": "dfd92ce8de03c666fd6e7fe0219df134eb406795", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue1550a.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/Issue1550a.agda", "max_line_length": 48, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue1550a.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": 79, "size": 208 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Fin.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Data.Empty open import Cubical.Data.Nat open import Cubical.Data.Nat.Order open import Cubical.Data.Sum open import Cubical.Relation.Nullary -- Finite types. -- -- Currently it is most convenient to define these as a subtype of the -- natural numbers, because indexed inductive definitions don't behave -- well with cubical Agda. This definition also has some more general -- attractive properties, of course, such as easy conversion back to -- ℕ. Fin : ℕ → Type₀ Fin n = Σ[ k ∈ ℕ ] k < n private variable ℓ : Level k : ℕ fzero : Fin (suc k) fzero = (0 , suc-≤-suc zero-≤) -- It is easy, using this representation, to take the successor of a -- number as a number in the next largest finite type. fsuc : Fin k → Fin (suc k) fsuc (k , l) = (suc k , suc-≤-suc l) -- Conversion back to ℕ is trivial... toℕ : Fin k → ℕ toℕ = fst -- ... and injective. toℕ-injective : ∀{fj fk : Fin k} → toℕ fj ≡ toℕ fk → fj ≡ fk toℕ-injective {fj = fj} {fk} = ΣProp≡ (λ _ → m≤n-isProp) -- A case analysis helper for induction. fsplit : ∀(fj : Fin (suc k)) → (fzero ≡ fj) ⊎ (Σ[ fk ∈ Fin k ] fsuc fk ≡ fj) fsplit (0 , k<sn) = inl (toℕ-injective refl) fsplit (suc k , k<sn) = inr ((k , pred-≤-pred k<sn) , toℕ-injective refl) -- Fin 0 is empty ¬Fin0 : ¬ Fin 0 ¬Fin0 (k , k<0) = ¬-<-zero k<0 -- The full inductive family eliminator for finite types. finduction : ∀(P : ∀{k} → Fin k → Type ℓ) → (∀{k} → P {suc k} fzero) → (∀{k} {fn : Fin k} → P fn → P (fsuc fn)) → {k : ℕ} → (fn : Fin k) → P fn finduction P fz fs {zero} = ⊥-elim ∘ ¬Fin0 finduction P fz fs {suc k} fj = case fsplit fj return (λ _ → P fj) of λ { (inl p) → subst P p fz ; (inr (fk , p)) → subst P p (fs (finduction P fz fs fk)) }
{ "alphanum_fraction": 0.6415192508, "avg_line_length": 27.0704225352, "ext": "agda", "hexsha": "cba6530c118a0c35d3931962b11b4bb485d87717", "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": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/Fin/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "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": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/Fin/Base.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/Fin/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 690, "size": 1922 }
module IO.File where open import Base open import IO {-# IMPORT System.IO #-} FilePath = String data IOMode : Set where readMode : IOMode writeMode : IOMode appendMode : IOMode readWriteMode : IOMode {-# COMPILED_DATA IOMode ReadMode WriteMode AppendMode ReadWriteMode #-} canRead : IOMode -> Bool canRead readMode = true canRead writeMode = false canRead appendMode = false canRead readWriteMode = true canWrite : IOMode -> Bool canWrite readMode = false canWrite writeMode = true canWrite appendMode = true canWrite readWriteMode = true CanRead : IOMode -> Set CanRead m = IsTrue (canRead m) CanWrite : IOMode -> Set CanWrite m = IsTrue (canWrite m) postulate Handle : Set private postulate hs-openFile : FilePath -> IOMode -> IO Handle hs-hClose : Handle -> IO Unit hs-hGetChar : Handle -> IO Char hs-hGetLine : Handle -> IO String hs-hGetContents : Handle -> IO String hs-hPutStr : Handle -> String -> IO Unit {-# COMPILED hs-openFile openFile #-} {-# COMPILED hs-hClose hClose #-} {-# COMPILED hs-hGetChar hGetChar #-} {-# COMPILED hs-hGetLine hGetLine #-} {-# COMPILED hs-hGetContents hGetContents #-} {-# COMPILED hs-hPutStr hPutStr #-} Handles = List (Handle × IOMode) abstract -- The FileIO monad. Records the list of open handles before and after -- a computation. The open handles after the computation may depend on -- the computed value. data FileIO (A : Set)(hs₁ : Handles)(hs₂ : A -> Handles) : Set where fileIO : IO A -> FileIO A hs₁ hs₂ private abstract unFileIO : forall {A hs f} -> FileIO A hs f -> IO A unFileIO (fileIO io) = io FileIO₋ : Set -> Handles -> Handles -> Set FileIO₋ A hs₁ hs₂ = FileIO A hs₁ (\_ -> hs₂) abstract openFile : {hs : Handles} -> FilePath -> (m : IOMode) -> FileIO Handle hs (\h -> (h , m) :: hs) openFile file mode = fileIO (hs-openFile file mode) infix 30 _∈_ data _∈_ {A : Set}(x : A) : List A -> Set where hd : forall {xs} -> x ∈ x :: xs tl : forall {y xs} -> x ∈ xs -> x ∈ y :: xs delete : {A : Set}{x : A}(xs : List A) -> x ∈ xs -> List A delete [] () delete (x :: xs) hd = xs delete (x :: xs) (tl p) = x :: delete xs p abstract hClose : {hs : Handles}{m : IOMode}(h : Handle)(p : (h , m) ∈ hs) -> FileIO₋ Unit hs (delete hs p) hClose h _ = fileIO (hs-hClose h) hGetLine : {hs : Handles}{m : IOMode}{isRead : CanRead m}(h : Handle) (p : (h , m) ∈ hs) -> FileIO₋ String hs hs hGetLine h _ = fileIO (hs-hGetLine h) hGetContents : {hs : Handles}{m : IOMode}{isRead : CanRead m}(h : Handle) (p : (h , m) ∈ hs) -> FileIO₋ String hs (delete hs p) hGetContents h _ = fileIO (hs-hGetContents h) abstract -- You can only run file computations that don't leave any open -- handles. runFileIO : {A : Set} -> FileIO₋ A [] [] -> IO A runFileIO (fileIO m) = m abstract _>>=_ : forall {A B hs f g} -> FileIO A hs f -> ((x : A) -> FileIO B (f x) g) -> FileIO B hs g fileIO m >>= k = fileIO (bindIO m \x -> unFileIO (k x)) return : forall {A hs} -> A -> FileIO₋ A hs hs return x = fileIO (returnIO x)
{ "alphanum_fraction": 0.6167721519, "avg_line_length": 27.2413793103, "ext": "agda", "hexsha": "a98a771c8721fd5c430595dbc06de93e0e6c0d31", "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/fileIO/IO/File.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/fileIO/IO/File.agda", "max_line_length": 75, "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/fileIO/IO/File.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": 1036, "size": 3160 }
{-# OPTIONS --without-K #-} module Data.ByteString.Primitive.Int where open import Agda.Builtin.Nat using (Nat) {-# FOREIGN GHC import qualified Data.Int #-} postulate Int : Set Int64 : Set IntToℕ : Int → Nat ℕToInt : Nat → Int int64Toℕ : Int64 → Nat ℕToInt64 : Nat → Int64 {-# COMPILE GHC Int = type (Prelude.Int) #-} {-# COMPILE GHC Int64 = type (Data.Int.Int64) #-} {-# COMPILE GHC IntToℕ = (Prelude.fromIntegral) #-} {-# COMPILE GHC ℕToInt = (Prelude.fromIntegral) #-} {-# COMPILE GHC int64Toℕ = (Prelude.fromIntegral) #-} {-# COMPILE GHC ℕToInt64 = (Prelude.fromIntegral) #-}
{ "alphanum_fraction": 0.6661073826, "avg_line_length": 28.380952381, "ext": "agda", "hexsha": "b66624e409f1a3004348581b417b1535c19060e7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/bytes-agda", "max_forks_repo_path": "src/Data/ByteString/Primitive/Int.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "semenov-vladyslav/bytes-agda", "max_issues_repo_path": "src/Data/ByteString/Primitive/Int.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/bytes-agda", "max_stars_repo_path": "src/Data/ByteString/Primitive/Int.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 178, "size": 596 }
-- Andreas, 2016-09-13, issue #2177, reported by Andres -- -- Check me with -v check.ranges:100 postulate A : Set -- Was an internal error when loading Agda.Primitive -- (because of range outside the current file).
{ "alphanum_fraction": 0.7188940092, "avg_line_length": 24.1111111111, "ext": "agda", "hexsha": "5c9959bd42430eca26bfd595ba1aca928e9e6487", "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/Issue2177.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/Issue2177.agda", "max_line_length": 55, "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/Issue2177.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": 217 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.Equivalence2 open import lib.Function2 open import lib.NType2 open import lib.types.Group open import lib.types.Pi open import lib.types.Subtype open import lib.types.Truncation open import lib.groups.Homomorphism open import lib.groups.SubgroupProp module lib.groups.Isomorphism where GroupStructureIso : ∀ {i j} {GEl : Type i} {HEl : Type j} (GS : GroupStructure GEl) (HS : GroupStructure HEl) → Type (lmax i j) GroupStructureIso GS HS = Σ (GroupStructureHom GS HS) (λ φ → is-equiv (GroupStructureHom.f φ)) infix 30 _≃ᴳˢ_ -- [ˢ] for structures _≃ᴳˢ_ = GroupStructureIso GroupIso : ∀ {i j} (G : Group i) (H : Group j) → Type (lmax i j) GroupIso G H = Σ (G →ᴳ H) (λ φ → is-equiv (GroupHom.f φ)) infix 30 _≃ᴳ_ _≃ᴳ_ = GroupIso ≃ᴳˢ-to-≃ᴳ : ∀ {i j} {G : Group i} {H : Group j} → (Group.group-struct G ≃ᴳˢ Group.group-struct H) → (G ≃ᴳ H) ≃ᴳˢ-to-≃ᴳ (φ , φ-is-equiv) = →ᴳˢ-to-→ᴳ φ , φ-is-equiv ≃-to-≃ᴳ : ∀ {i j} {G : Group i} {H : Group j} (e : Group.El G ≃ Group.El H) → preserves-comp (Group.comp G) (Group.comp H) (–> e) → G ≃ᴳ H ≃-to-≃ᴳ (f , f-is-equiv) pres-comp = group-hom f pres-comp , f-is-equiv ≃-to-≃ᴳˢ : ∀ {i j} {GEl : Type i} {HEl : Type j} {GS : GroupStructure GEl} {HS : GroupStructure HEl} (e : GEl ≃ HEl) → preserves-comp (GroupStructure.comp GS) (GroupStructure.comp HS) (–> e) → GS ≃ᴳˢ HS ≃-to-≃ᴳˢ (f , f-is-equiv) pres-comp = group-structure-hom f pres-comp , f-is-equiv private inverse-preserves-comp : ∀ {i j} {A : Type i} {B : Type j} (A-comp : A → A → A) (B-comp : B → B → B) {f : A → B} (f-ie : is-equiv f) → preserves-comp A-comp B-comp f → preserves-comp B-comp A-comp (is-equiv.g f-ie) inverse-preserves-comp Ac Bc ie pc b₁ b₂ = let open is-equiv ie in ap2 (λ w₁ w₂ → g (Bc w₁ w₂)) (! (f-g b₁)) (! (f-g b₂)) ∙ ! (ap g (pc (g b₁) (g b₂))) ∙ g-f (Ac (g b₁) (g b₂)) module GroupStructureIso {i j} {GEl : Type i} {HEl : Type j} {GS : GroupStructure GEl} {HS : GroupStructure HEl} (iso : GroupStructureIso GS HS) where f-shom : GS →ᴳˢ HS f-shom = fst iso open GroupStructureHom {GS = GS} {HS = HS} f-shom public f-is-equiv : is-equiv f f-is-equiv = snd iso open is-equiv f-is-equiv public f-equiv : GEl ≃ HEl f-equiv = f , f-is-equiv g-shom : HS →ᴳˢ GS g-shom = group-structure-hom g (inverse-preserves-comp (GroupStructure.comp GS) (GroupStructure.comp HS) f-is-equiv pres-comp) g-is-equiv : is-equiv g g-is-equiv = is-equiv-inverse f-is-equiv g-equiv : HEl ≃ GEl g-equiv = g , g-is-equiv module GroupIso {i j} {G : Group i} {H : Group j} (iso : GroupIso G H) where f-hom : G →ᴳ H f-hom = fst iso open GroupHom {G = G} {H = H} f-hom public f-is-equiv : is-equiv f f-is-equiv = snd iso open is-equiv f-is-equiv public f-equiv : Group.El G ≃ Group.El H f-equiv = f , f-is-equiv g-hom : H →ᴳ G g-hom = group-hom g (inverse-preserves-comp (Group.comp G) (Group.comp H) f-is-equiv pres-comp) g-is-equiv : is-equiv g g-is-equiv = is-equiv-inverse f-is-equiv g-equiv : Group.El H ≃ Group.El G g-equiv = g , g-is-equiv idiso : ∀ {i} (G : Group i) → (G ≃ᴳ G) idiso G = idhom G , idf-is-equiv _ idsiso : ∀ {i} {GEl : Type i} (GS : GroupStructure GEl) → (GS ≃ᴳˢ GS) idsiso GS = idshom GS , idf-is-equiv _ {- equality of isomomorphisms -} abstract group-hom=-to-iso= : ∀ {i j} {G : Group i} {H : Group j} {φ ψ : G ≃ᴳ H} → GroupIso.f-hom φ == GroupIso.f-hom ψ → φ == ψ group-hom=-to-iso= = Subtype=-out (is-equiv-prop ∘sub GroupHom.f) group-iso= : ∀ {i j} {G : Group i} {H : Group j} {φ ψ : G ≃ᴳ H} → GroupIso.f φ == GroupIso.f ψ → φ == ψ group-iso= {H = H} p = group-hom=-to-iso= $ group-hom= p {- compositions -} infixr 80 _∘eᴳˢ_ _∘eᴳ_ _∘eᴳˢ_ : ∀ {i j k} {GEl : Type i} {HEl : Type j} {KEl : Type k} {GS : GroupStructure GEl} {HS : GroupStructure HEl} {KS : GroupStructure KEl} → HS ≃ᴳˢ KS → GS ≃ᴳˢ HS → GS ≃ᴳˢ KS (φ₂ , ie₂) ∘eᴳˢ (φ₁ , ie₁) = (φ₂ ∘ᴳˢ φ₁ , ie₂ ∘ise ie₁) _∘eᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} → H ≃ᴳ K → G ≃ᴳ H → G ≃ᴳ K (φ₂ , ie₂) ∘eᴳ (φ₁ , ie₁) = (φ₂ ∘ᴳ φ₁ , ie₂ ∘ise ie₁) infixr 10 _≃ᴳˢ⟨_⟩_ _≃ᴳ⟨_⟩_ infix 15 _≃ᴳˢ∎ _≃ᴳ∎ _≃ᴳˢ⟨_⟩_ : ∀ {i j k} {GEl : Type i} {HEl : Type j} {KEl : Type k} (GS : GroupStructure GEl) {HS : GroupStructure HEl} {KS : GroupStructure KEl} → GS ≃ᴳˢ HS → HS ≃ᴳˢ KS → GS ≃ᴳˢ KS GS ≃ᴳˢ⟨ e₁ ⟩ e₂ = e₂ ∘eᴳˢ e₁ _≃ᴳ⟨_⟩_ : ∀ {i j k} (G : Group i) {H : Group j} {K : Group k} → G ≃ᴳ H → H ≃ᴳ K → G ≃ᴳ K G ≃ᴳ⟨ e₁ ⟩ e₂ = e₂ ∘eᴳ e₁ _≃ᴳˢ∎ : ∀ {i} {GEl : Type i} (GS : GroupStructure GEl) → (GS ≃ᴳˢ GS) _≃ᴳˢ∎ = idsiso _≃ᴳ∎ : ∀ {i} (G : Group i) → (G ≃ᴳ G) _≃ᴳ∎ = idiso infixl 120 _⁻¹ᴳˢ _⁻¹ᴳ _⁻¹ᴳˢ : ∀ {i j} {GEl : Type i} {HEl : Type j} {GS : GroupStructure GEl} {HS : GroupStructure HEl} → GS ≃ᴳˢ HS → HS ≃ᴳˢ GS _⁻¹ᴳˢ {GS = GS} {HS} (φ , ie) = GroupStructureIso.g-shom (φ , ie) , is-equiv-inverse ie _⁻¹ᴳ : ∀ {i j} {G : Group i} {H : Group j} → G ≃ᴳ H → H ≃ᴳ G _⁻¹ᴳ {G = G} {H = H} (φ , ie) = GroupIso.g-hom (φ , ie) , is-equiv-inverse ie {- mimicking notations for equivalences -} –>ᴳ : ∀ {i j} {G : Group i} {H : Group j} → (G ≃ᴳ H) → (G →ᴳ H) –>ᴳ = GroupIso.f-hom <–ᴳ : ∀ {i j} {G : Group i} {H : Group j} → (G ≃ᴳ H) → (H →ᴳ G) <–ᴳ = GroupIso.g-hom {- univalence -} module _ {i} {G H : Group i} (iso : GroupIso G H) where private module G = Group G module H = Group H open module φ = GroupIso {G = G} {H = H} iso El= = ua f-equiv private ap3-lemma : ∀ {i j k l} {C : Type i} {D : C → Type j} {E : C → Type k} {F : Type l} {c₁ c₂ : C} {d₁ : D c₁} {d₂ : D c₂} {e₁ : E c₁} {e₂ : E c₂} (f : (c : C) → D c → E c → F) (p : c₁ == c₂) → (d₁ == d₂ [ D ↓ p ]) → (e₁ == e₂ [ E ↓ p ]) → (f c₁ d₁ e₁ == f c₂ d₂ e₂) ap3-lemma f idp idp idp = idp ap3-lemma-El : ∀ {i} {G H : Group i} (p : Group.El G == Group.El H) (q : Group.El-level G == Group.El-level H [ _ ↓ p ]) (r : Group.group-struct G == Group.group-struct H [ _ ↓ p ]) → ap Group.El (ap3-lemma (λ a b c → group a {{b}} c) p q r) == p ap3-lemma-El idp idp idp = idp {- a homomorphism which is an equivalence gives a path between groups -} abstract uaᴳ : G == H uaᴳ = ap3-lemma (λ a b c → group a {{b}} c) El= prop-has-all-paths-↓ (↓-group-structure= El= ident= inv= comp=) where ident= : G.ident == H.ident [ (λ C → C) ↓ El= ] ident= = ↓-idf-ua-in _ pres-ident inv= : G.inv == H.inv [ (λ C → C → C) ↓ El= ] inv= = ↓-→-from-transp $ λ= λ a → transport (λ C → C) El= (G.inv a) =⟨ to-transp (↓-idf-ua-in _ idp) ⟩ f (G.inv a) =⟨ pres-inv a ⟩ H.inv (f a) =⟨ ap H.inv (! (to-transp (↓-idf-ua-in _ idp))) ⟩ H.inv (transport (λ C → C) El= a) =∎ comp=' : (a : G.El) → G.comp a == H.comp (f a) [ (λ C → C → C) ↓ El= ] comp=' a = ↓-→-from-transp $ λ= λ b → transport (λ C → C) El= (G.comp a b) =⟨ to-transp (↓-idf-ua-in _ idp) ⟩ f (G.comp a b) =⟨ pres-comp a b ⟩ H.comp (f a) (f b) =⟨ ! (to-transp (↓-idf-ua-in _ idp)) |in-ctx (λ w → H.comp (f a) w) ⟩ H.comp (f a) (transport (λ C → C) El= b) =∎ comp= : G.comp == H.comp [ (λ C → C → C → C) ↓ El= ] comp= = ↓-→-from-transp $ λ= λ a → transport (λ C → C → C) El= (G.comp a) =⟨ to-transp (comp=' a) ⟩ H.comp (f a) =⟨ ! (to-transp (↓-idf-ua-in _ idp)) |in-ctx (λ w → H.comp w) ⟩ H.comp (transport (λ C → C) El= a) =∎ -- XXX This stretches the naming convention a little bit. El=-β : ap Group.El uaᴳ == El= El=-β = ap3-lemma-El El= _ _ {- homomorphism from equality of groups -} abstract transp-El-pres-comp : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → preserves-comp (Group.comp (B a₁)) (Group.comp (B a₂)) (transport (Group.El ∘ B) p) transp-El-pres-comp B idp g₁ g₂ = idp transp!-El-pres-comp : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → preserves-comp (Group.comp (B a₂)) (Group.comp (B a₁)) (transport! (Group.El ∘ B) p) transp!-El-pres-comp B idp h₁ h₂ = idp transportᴳ : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → (B a₁ →ᴳ B a₂) transportᴳ B p = record {f = transport (Group.El ∘ B) p; pres-comp = transp-El-pres-comp B p} transport!ᴳ : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → (B a₂ →ᴳ B a₁) transport!ᴳ B p = record {f = transport! (Group.El ∘ B) p; pres-comp = transp!-El-pres-comp B p} abstract transpᴳ-is-iso : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → is-equiv (GroupHom.f (transportᴳ B p)) transpᴳ-is-iso B idp = idf-is-equiv _ transp!ᴳ-is-iso : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → is-equiv (GroupHom.f (transport!ᴳ B p)) transp!ᴳ-is-iso B idp = idf-is-equiv _ transportᴳ-iso : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → B a₁ ≃ᴳ B a₂ transportᴳ-iso B p = transportᴳ B p , transpᴳ-is-iso B p transport!ᴳ-iso : ∀ {i j} {A : Type i} (B : A → Group j) {a₁ a₂ : A} (p : a₁ == a₂) → B a₂ ≃ᴳ B a₁ transport!ᴳ-iso B p = transport!ᴳ B p , transp!ᴳ-is-iso B p coeᴳ : ∀ {i} {G H : Group i} → G == H → (G →ᴳ H) coeᴳ = transportᴳ (idf _) coe!ᴳ : ∀ {i} {G H : Group i} → G == H → (H →ᴳ G) coe!ᴳ = transport!ᴳ (idf _) coeᴳ-iso : ∀ {i} {G H : Group i} → G == H → G ≃ᴳ H coeᴳ-iso = transportᴳ-iso (idf _) coe!ᴳ-iso : ∀ {i} {G H : Group i} → G == H → H ≃ᴳ G coe!ᴳ-iso = transport!ᴳ-iso (idf _) abstract coeᴳ-β : ∀ {i} {G H : Group i} (iso : G ≃ᴳ H) → coeᴳ (uaᴳ iso) == GroupIso.f-hom iso coeᴳ-β iso = group-hom= $ ap coe (El=-β iso) ∙ λ= (coe-β (GroupIso.f-equiv iso)) -- triviality iso-preserves-trivial : ∀ {i j} {G : Group i} {H : Group j} → G ≃ᴳ H → is-trivialᴳ G → is-trivialᴳ H iso-preserves-trivial iso G-is-trivial h = ! (GroupIso.f-g iso h) ∙ ap (GroupIso.f iso) (G-is-trivial _) ∙ GroupIso.pres-ident iso iso-preserves'-trivial : ∀ {i j} {G : Group i} {H : Group j} → G ≃ᴳ H → is-trivialᴳ H → is-trivialᴳ G iso-preserves'-trivial iso H-is-trivial g = ! (GroupIso.g-f iso g) ∙ ap (GroupIso.g iso) (H-is-trivial _) ∙ GroupHom.pres-ident (GroupIso.g-hom iso) -- a surjective and injective homomorphism is an isomorphism module _ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) (surj : is-surjᴳ φ) (inj : is-injᴳ φ) where private module G = Group G module H = Group H module φ = GroupHom φ abstract instance image-prop : (h : H.El) → is-prop (hfiber φ.f h) image-prop h = all-paths-is-prop λ {(g₁ , p₁) (g₂ , p₂) → pair= (inj g₁ g₂ (p₁ ∙ ! p₂)) prop-has-all-paths-↓} surjᴳ-and-injᴳ-is-equiv : is-equiv φ.f surjᴳ-and-injᴳ-is-equiv = contr-map-is-equiv (λ h → let (g₁ , p₁) = Trunc-rec (idf _) (surj h) in has-level-in ((g₁ , p₁) , (λ {(g₂ , p₂) → pair= (inj g₁ g₂ (p₁ ∙ ! p₂)) prop-has-all-paths-↓}))) surjᴳ-and-injᴳ-iso : G ≃ᴳ H surjᴳ-and-injᴳ-iso = φ , surjᴳ-and-injᴳ-is-equiv -- isomorphisms preserve abelianess. module _ {i} {G H : Group i} (iso : G ≃ᴳ H) (G-abelian : is-abelian G) where private module G = Group G module H = Group H open GroupIso iso abstract iso-preserves-abelian : is-abelian H iso-preserves-abelian h₁ h₂ = H.comp h₁ h₂ =⟨ ap2 H.comp (! $ f-g h₁) (! $ f-g h₂) ⟩ H.comp (f (g h₁)) (f (g h₂)) =⟨ ! $ pres-comp (g h₁) (g h₂) ⟩ f (G.comp (g h₁) (g h₂)) =⟨ G-abelian (g h₁) (g h₂) |in-ctx f ⟩ f (G.comp (g h₂) (g h₁)) =⟨ pres-comp (g h₂) (g h₁) ⟩ H.comp (f (g h₂)) (f (g h₁)) =⟨ ap2 H.comp (f-g h₂) (f-g h₁) ⟩ H.comp h₂ h₁ =∎ pre∘ᴳ-iso : ∀ {i j k} {G : Group i} {H : Group j} (K : AbGroup k) → (G ≃ᴳ H) → (hom-group H K ≃ᴳ hom-group G K) pre∘ᴳ-iso K iso = ≃-to-≃ᴳ (equiv to from to-from from-to) to-pres-comp where to = GroupHom.f (pre∘ᴳ-hom K (–>ᴳ iso)) to-pres-comp = GroupHom.pres-comp (pre∘ᴳ-hom K (–>ᴳ iso)) from = GroupHom.f (pre∘ᴳ-hom K (<–ᴳ iso)) abstract to-from : ∀ φ → to (from φ) == φ to-from φ = group-hom= $ λ= λ g → ap (GroupHom.f φ) (GroupIso.g-f iso g) from-to : ∀ φ → from (to φ) == φ from-to φ = group-hom= $ λ= λ h → ap (GroupHom.f φ) (GroupIso.f-g iso h) post∘ᴳ-iso : ∀ {i j k} (G : Group i) (H : AbGroup j) (K : AbGroup k) → (AbGroup.grp H ≃ᴳ AbGroup.grp K) → (hom-group G H ≃ᴳ hom-group G K) post∘ᴳ-iso G H K iso = ≃-to-≃ᴳ (equiv to from to-from from-to) to-pres-comp where to = GroupHom.f (post∘ᴳ-hom G H K (–>ᴳ iso)) to-pres-comp = GroupHom.pres-comp (post∘ᴳ-hom G H K(–>ᴳ iso)) from = GroupHom.f (post∘ᴳ-hom G K H (<–ᴳ iso)) abstract to-from : ∀ φ → to (from φ) == φ to-from φ = group-hom= $ λ= λ g → GroupIso.f-g iso (GroupHom.f φ g) from-to : ∀ φ → from (to φ) == φ from-to φ = group-hom= $ λ= λ h → GroupIso.g-f iso (GroupHom.f φ h)
{ "alphanum_fraction": 0.5447801147, "avg_line_length": 34.0494791667, "ext": "agda", "hexsha": "49e864fd14fd6fb88a450696c42d6dfed93a2546", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/groups/Isomorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/groups/Isomorphism.agda", "max_line_length": 128, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/groups/Isomorphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5818, "size": 13075 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Exactness open import cohomology.FunctionOver {- Splitting Lemma - Right Split Assume an exact sequence: φ ψ 0 → G → H → K where H is abelian. If ψ has a right inverse χ, then H == G × K. Over this path φ becomes the natural injection and ψ the natural projection. The only non-private terms are [iso], [φ-over-iso], and [ψ-over-iso]. -} module cohomology.SplitExactRight {i} {L G H K : Group i} (H-abelian : is-abelian H) (φ : G →ᴳ H) (ψ : H →ᴳ K) where private module G = Group G module H = Group H module K = Group K module φ = GroupHom φ module ψ = GroupHom ψ module SplitExactRight (ex : is-exact-seq (L ⟨ cst-hom ⟩→ G ⟨ φ ⟩→ H ⟨ ψ ⟩→ K ⊣|)) (χ : K →ᴳ H) (χ-rinv : (k : K.El) → ψ.f (GroupHom.f χ k) == k) where private module χ = GroupHom χ {- H == Ker ψ × Im χ -} ker-part : H →ᴳ Ker ψ ker-part = ker-hom ψ (comp-hom H-abelian (idhom H) (inv-hom H H-abelian ∘ᴳ (χ ∘ᴳ ψ))) (λ h → ψ.f (H.comp h (H.inv (χ.f (ψ.f h)))) =⟨ ψ.pres-comp h (H.inv (χ.f (ψ.f h))) ⟩ K.comp (ψ.f h) (ψ.f (H.inv (χ.f (ψ.f h)))) =⟨ ! (χ.pres-inv (ψ.f h)) |in-ctx (λ w → K.comp (ψ.f h) (ψ.f w)) ⟩ K.comp (ψ.f h) (ψ.f (χ.f (K.inv (ψ.f h)))) =⟨ χ-rinv (K.inv (ψ.f h)) |in-ctx (λ w → K.comp (ψ.f h) w) ⟩ K.comp (ψ.f h) (K.inv (ψ.f h)) =⟨ K.invr (ψ.f h) ⟩ K.ident ∎) ker-part-kerψ : (h : H.El) (p : ψ.f h == K.ident) → GroupHom.f ker-part h == (h , p) ker-part-kerψ h p = pair= (H.comp h (H.inv (χ.f (ψ.f h))) =⟨ p |in-ctx (λ w → H.comp h (H.inv (χ.f w))) ⟩ H.comp h (H.inv (χ.f K.ident)) =⟨ χ.pres-ident |in-ctx (λ w → H.comp h (H.inv w)) ⟩ H.comp h (H.inv H.ident) =⟨ group-inv-ident H |in-ctx H.comp h ⟩ H.comp h H.ident =⟨ H.unitr h ⟩ h ∎) (prop-has-all-paths-↓ (K.El-level _ _)) ker-part-imχ : (h : H.El) → Trunc -1 (Σ K.El (λ k → χ.f k == h)) → GroupHom.f ker-part h == Group.ident (Ker ψ) ker-part-imχ h = Trunc-rec (Group.El-level (Ker ψ) _ _) $ (λ {(k , p) → pair= (H.comp h (H.inv (χ.f (ψ.f h))) =⟨ ! p |in-ctx (λ w → H.comp w (H.inv (χ.f (ψ.f w)))) ⟩ H.comp (χ.f k) (H.inv (χ.f (ψ.f (χ.f k)))) =⟨ χ-rinv k |in-ctx (λ w → H.comp (χ.f k) (H.inv (χ.f w))) ⟩ H.comp (χ.f k) (H.inv (χ.f k)) =⟨ H.invr (χ.f k) ⟩ H.ident ∎) (prop-has-all-paths-↓ (K.El-level _ _))}) im-part : H →ᴳ Im χ im-part = im-in-hom χ ∘ᴳ ψ im-part-kerψ : (h : H.El) → ψ.f h == K.ident → GroupHom.f im-part h == Group.ident (Im χ) im-part-kerψ h p = pair= (ap χ.f p ∙ χ.pres-ident) (prop-has-all-paths-↓ Trunc-level) im-part-imχ : (h : H.El) (s : Trunc -1 (Σ K.El (λ k → χ.f k == h))) → GroupHom.f im-part h == (h , s) im-part-imχ h s = pair= (Trunc-rec (Group.El-level H _ _) (λ {(k , p) → χ.f (ψ.f h) =⟨ ! p |in-ctx (χ.f ∘ ψ.f) ⟩ χ.f (ψ.f (χ.f k)) =⟨ χ-rinv k |in-ctx χ.f ⟩ χ.f k =⟨ p ⟩ h ∎}) s) (prop-has-all-paths-↓ Trunc-level) decomp : H →ᴳ Ker ψ ×ᴳ Im χ decomp = ×ᴳ-hom-in ker-part im-part decomp-is-equiv : is-equiv (GroupHom.f decomp) decomp-is-equiv = is-eq _ dinv decomp-dinv dinv-decomp where dinv : Group.El (Ker ψ ×ᴳ Im χ) → H.El dinv ((h₁ , _) , (h₂ , _)) = H.comp h₁ h₂ decomp-dinv : ∀ s → GroupHom.f decomp (dinv s) == s decomp-dinv ((h₁ , kr) , (h₂ , im)) = pair×= (GroupHom.f ker-part (H.comp h₁ h₂) =⟨ GroupHom.pres-comp ker-part h₁ h₂ ⟩ Group.comp (Ker ψ) (GroupHom.f ker-part h₁) (GroupHom.f ker-part h₂) =⟨ ker-part-kerψ h₁ kr |in-ctx (λ w → Group.comp (Ker ψ) w (GroupHom.f ker-part h₂)) ⟩ Group.comp (Ker ψ) (h₁ , kr) (GroupHom.f ker-part h₂) =⟨ ker-part-imχ h₂ im |in-ctx (λ w → Group.comp (Ker ψ) (h₁ , kr) w) ⟩ Group.comp (Ker ψ) (h₁ , kr) (Group.ident (Ker ψ)) =⟨ Group.unitr (Ker ψ) (h₁ , kr) ⟩ (h₁ , kr) ∎) (GroupHom.f im-part (H.comp h₁ h₂) =⟨ GroupHom.pres-comp im-part h₁ h₂ ⟩ Group.comp (Im χ) (GroupHom.f im-part h₁) (GroupHom.f im-part h₂) =⟨ im-part-kerψ h₁ kr |in-ctx (λ w → Group.comp (Im χ) w (GroupHom.f im-part h₂)) ⟩ Group.comp (Im χ) (Group.ident (Im χ)) (GroupHom.f im-part h₂) =⟨ im-part-imχ h₂ im |in-ctx (λ w → Group.comp (Im χ) (Group.ident (Im χ)) w) ⟩ Group.comp (Im χ) (Group.ident (Im χ)) (h₂ , im) =⟨ Group.unitl (Im χ) (h₂ , im) ⟩ (h₂ , im) ∎) dinv-decomp : ∀ h → dinv (GroupHom.f decomp h) == h dinv-decomp h = H.comp (H.comp h (H.inv (χ.f (ψ.f h)))) (χ.f (ψ.f h)) =⟨ H.assoc h (H.inv (χ.f (ψ.f h))) (χ.f (ψ.f h)) ⟩ H.comp h (H.comp (H.inv (χ.f (ψ.f h))) (χ.f (ψ.f h))) =⟨ H.invl (χ.f (ψ.f h)) |in-ctx H.comp h ⟩ H.comp h H.ident =⟨ H.unitr h ⟩ h ∎ decomp-equiv : H.El ≃ Group.El (Ker ψ ×ᴳ Im χ) decomp-equiv = (_ , decomp-is-equiv) decomp-iso : H == Ker ψ ×ᴳ Im χ decomp-iso = group-ua (decomp , decomp-is-equiv) {- G == Ker ψ -} ker-in-φ : G →ᴳ Ker ψ ker-in-φ = ker-hom ψ φ (λ g → itok (exact-get ex 1) (φ.f g) [ g , idp ]) ker-in-φ-is-equiv : is-equiv (GroupHom.f ker-in-φ) ker-in-φ-is-equiv = surj-inj-is-equiv ker-in-φ inj surj where inj = zero-kernel-injective ker-in-φ (λ g p → Trunc-rec (G.El-level _ _) (λ {(_ , q) → ! q}) (ktoi (exact-get ex 0) g (ap fst p))) surj = λ {(h , p) → Trunc-fmap (λ {(g , q) → (g , pair= q (prop-has-all-paths-↓ (K.El-level _ _)))}) (ktoi (exact-get ex 1) h p)} G-iso-Kerψ : G == Ker ψ G-iso-Kerψ = group-ua (ker-in-φ , ker-in-φ-is-equiv) {- K == Im χ -} im-in-χ-is-equiv : is-equiv (GroupHom.f (im-in-hom χ)) im-in-χ-is-equiv = surj-inj-is-equiv (im-in-hom χ) inj (im-in-surj χ) where inj = zero-kernel-injective (im-in-hom χ) (λ k p → ! (χ-rinv k) ∙ ap ψ.f (ap fst p) ∙ ψ.pres-ident) K-iso-Imχ : K == Im χ K-iso-Imχ = group-ua (im-in-hom χ , im-in-χ-is-equiv) {- H == G ×ᴳ K -} iso : H == G ×ᴳ K iso = decomp-iso ∙ ap2 _×ᴳ_ (! G-iso-Kerψ) (! K-iso-Imχ) private decomp-φ = ×ᴳ-hom-in ker-in-φ (cst-hom {G = G} {H = Im χ}) ψ-dinv = ψ ∘ᴳ ×ᴳ-sum-hom H-abelian (ker-inj ψ) (im-inj χ) φ-over-decomp : φ == decomp-φ [ (λ J → G →ᴳ J) ↓ decomp-iso ] φ-over-decomp = codomain-over-iso $ codomain-over-equiv φ.f _ ▹ lemma where lemma : GroupHom.f decomp ∘ φ.f == GroupHom.f decomp-φ lemma = λ= (λ g → pair×= (ker-part-kerψ (φ.f g) (itok (exact-get ex 1) (φ.f g) [ g , idp ])) (im-part-kerψ (φ.f g) (itok (exact-get ex 1) (φ.f g) [ g , idp ]))) ψ-over-decomp : ψ == ψ-dinv [ (λ J → J →ᴳ K) ↓ decomp-iso ] ψ-over-decomp = domain-over-iso $ domain!-over-equiv ψ.f _ id-over-G-iso : idhom _ == ker-in-φ [ (λ J → G →ᴳ J) ↓ G-iso-Kerψ ] id-over-G-iso = codomain-over-iso $ codomain-over-equiv (idf _) _ φ-over-G-iso : φ == ker-inj ψ [ (λ J → J →ᴳ H) ↓ G-iso-Kerψ ] φ-over-G-iso = domain-over-iso $ domain-over-equiv (GroupHom.f (ker-inj ψ)) _ ψ|imχ-over-K-iso : idhom K == ψ ∘ᴳ im-inj χ [ (λ J → J →ᴳ K) ↓ K-iso-Imχ ] ψ|imχ-over-K-iso = domain-over-iso $ domain!-over-equiv (idf _) _ ▹ lemma where lemma : <– (_ , im-in-χ-is-equiv) == ψ.f ∘ GroupHom.f (im-inj χ) lemma = λ= (λ {(h , s) → Trunc-elim {P = λ s' → <– (_ , im-in-χ-is-equiv) (h , s') == ψ.f h} (λ _ → K.El-level _ _) (λ {(k , p) → ! (χ-rinv k) ∙ ap ψ.f p}) s}) φ-over-G-K-isos : decomp-φ == ×ᴳ-inl [ (λ J → G →ᴳ J) ↓ ap2 _×ᴳ_ (! G-iso-Kerψ) (! K-iso-Imχ) ] φ-over-G-K-isos = ↓-ap2-in _ _×ᴳ_ $ transport (λ q → decomp-φ == ×ᴳ-inl [ (λ {(J₁ , J₂) → G →ᴳ J₁ ×ᴳ J₂}) ↓ q ]) (! (pair×=-split-l (! G-iso-Kerψ) (! K-iso-Imχ))) (l ∙ᵈ r) where l : decomp-φ == ×ᴳ-hom-in (idhom G) (cst-hom {G = G} {H = Im χ}) [ (λ {(J₁ , J₂) → G →ᴳ J₁ ×ᴳ J₂}) ↓ ap (λ J → J , Im χ) (! G-iso-Kerψ) ] l = ↓-ap-in _ (λ J → J , Im χ) (ap↓ (λ θ → ×ᴳ-hom-in θ (cst-hom {G = G} {H = Im χ})) (!ᵈ id-over-G-iso)) r : ×ᴳ-hom-in (idhom G) (cst-hom {H = Im χ}) == ×ᴳ-inl [ (λ {(J₁ , J₂) → G →ᴳ J₁ ×ᴳ J₂}) ↓ ap (λ J → G , J) (! K-iso-Imχ) ] r = ↓-ap-in _ (λ J → G , J) (apd (λ J → ×ᴳ-hom-in (idhom G) (cst-hom {G = G} {H = J})) (! K-iso-Imχ)) ψ-over-G-K-isos : ψ-dinv == ×ᴳ-snd {G = G} [ (λ J → J →ᴳ K) ↓ ap2 _×ᴳ_ (! G-iso-Kerψ) (! K-iso-Imχ) ] ψ-over-G-K-isos = ↓-ap2-in _ _×ᴳ_ $ transport (λ q → ψ-dinv == (×ᴳ-snd {G = G}) [ (λ {(J₁ , J₂) → J₁ ×ᴳ J₂ →ᴳ K}) ↓ q ]) (! (pair×=-split-l (! G-iso-Kerψ) (! K-iso-Imχ))) (l ∙ᵈ (m ◃ r)) where l : ψ-dinv == ψ ∘ᴳ ×ᴳ-sum-hom H-abelian φ (im-inj χ) [ (λ {(J₁ , J₂) → J₁ ×ᴳ J₂ →ᴳ K}) ↓ ap (λ J → J , Im χ) (! G-iso-Kerψ) ] l = ↓-ap-in _ (λ J → J , Im χ) (ap↓ (λ θ → ψ ∘ᴳ ×ᴳ-sum-hom H-abelian θ (im-inj χ)) (!ᵈ φ-over-G-iso)) m : ψ ∘ᴳ ×ᴳ-sum-hom H-abelian φ (im-inj χ) == (ψ ∘ᴳ im-inj χ) ∘ᴳ ×ᴳ-snd {G = G} m = hom= _ _ $ λ= $ (λ {(g , (h , _)) → ψ.f (H.comp (φ.f g) h) =⟨ ψ.pres-comp (φ.f g) h ⟩ K.comp (ψ.f (φ.f g)) (ψ.f h) =⟨ itok (exact-get ex 1) (φ.f g) [ g , idp ] |in-ctx (λ w → K.comp w (ψ.f h)) ⟩ K.comp K.ident (ψ.f h) =⟨ K.unitl (ψ.f h) ⟩ ψ.f h ∎}) r : (ψ ∘ᴳ im-inj χ) ∘ᴳ ×ᴳ-snd {G = G} == ×ᴳ-snd {G = G} [ (λ {(J₁ , J₂) → J₁ ×ᴳ J₂ →ᴳ K}) ↓ (ap (λ J → G , J) (! K-iso-Imχ)) ] r = ↓-ap-in _ (λ J → G , J) (ap↓ (λ θ → θ ∘ᴳ ×ᴳ-snd {G = G}) (!ᵈ ψ|imχ-over-K-iso)) φ-over-iso : φ == ×ᴳ-inl [ (λ J → G →ᴳ J) ↓ iso ] φ-over-iso = φ-over-decomp ∙ᵈ φ-over-G-K-isos ψ-over-iso : ψ == (×ᴳ-snd {G = G}) [ (λ J → J →ᴳ K) ↓ iso ] ψ-over-iso = ψ-over-decomp ∙ᵈ ψ-over-G-K-isos
{ "alphanum_fraction": 0.4653398058, "avg_line_length": 36.917562724, "ext": "agda", "hexsha": "5cab59c7b4901639e3efbdb60269cd1cf22a8af3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/SplitExactRight.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/SplitExactRight.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/SplitExactRight.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4530, "size": 10300 }
open import Oscar.Prelude open import Oscar.Class.Symmetry open import Oscar.Class.Symmetrical import Oscar.Data.Proposequality module Oscar.Class.Symmetrical.Symmetry where module _ {𝔬} {𝔒 : Ø 𝔬} {ℓ} {_∼_ : 𝔒 → 𝔒 → Ø ℓ} ⦃ _ : Symmetry.class _∼_ ⦄ where instance Symmetrical𝓢ymmetry : Symmetrical _∼_ (λ x∼y y∼x → x∼y → y∼x) Symmetrical𝓢ymmetry .𝓢ymmetrical.symmetrical _ _ = symmetry
{ "alphanum_fraction": 0.6980676329, "avg_line_length": 21.7894736842, "ext": "agda", "hexsha": "018866b9818becc3dc626aa9a9f476b01d04e9dc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 161, "size": 414 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some properties imply others ------------------------------------------------------------------------ module Relation.Binary.Consequences where open import Relation.Binary.Core hiding (refl) open import Relation.Nullary open import Relation.Binary.PropositionalEquality.Core open import Function open import Data.Sum open import Data.Product open import Data.Empty -- Some of the definitions can be found in the following module: open import Relation.Binary.Consequences.Core public trans∧irr⟶asym : ∀ {a ℓ₁ ℓ₂} {A : Set a} → {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Reflexive _≈_ → Transitive _<_ → Irreflexive _≈_ _<_ → Asymmetric _<_ trans∧irr⟶asym refl trans irrefl = λ x<y y<x → irrefl refl (trans x<y y<x) irr∧antisym⟶asym : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Irreflexive _≈_ _<_ → Antisymmetric _≈_ _<_ → Asymmetric _<_ irr∧antisym⟶asym irrefl antisym = λ x<y y<x → irrefl (antisym x<y y<x) x<y asym⟶antisym : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Asymmetric _<_ → Antisymmetric _≈_ _<_ asym⟶antisym asym x<y y<x = ⊥-elim (asym x<y y<x) asym⟶irr : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → _<_ Respects₂ _≈_ → Symmetric _≈_ → Asymmetric _<_ → Irreflexive _≈_ _<_ asym⟶irr {_<_ = _<_} resp sym asym {x} {y} x≈y x<y = asym x<y y<x where y<y : y < y y<y = proj₂ resp x≈y x<y y<x : y < x y<x = proj₁ resp (sym x≈y) y<y total⟶refl : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_∼_ : Rel A ℓ₂} → _∼_ Respects₂ _≈_ → Symmetric _≈_ → Total _∼_ → _≈_ ⇒ _∼_ total⟶refl {_≈_ = _≈_} {_∼_ = _∼_} resp sym total = refl where refl : _≈_ ⇒ _∼_ refl {x} {y} x≈y with total x y ... | inj₁ x∼y = x∼y ... | inj₂ y∼x = proj₁ resp x≈y (proj₂ resp (sym x≈y) y∼x) total+dec⟶dec : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_≤_ : Rel A ℓ₂} → _≈_ ⇒ _≤_ → Antisymmetric _≈_ _≤_ → Total _≤_ → Decidable _≈_ → Decidable _≤_ total+dec⟶dec {_≈_ = _≈_} {_≤_ = _≤_} refl antisym total _≟_ = dec where dec : Decidable _≤_ dec x y with total x y ... | inj₁ x≤y = yes x≤y ... | inj₂ y≤x with x ≟ y ... | yes x≈y = yes (refl x≈y) ... | no ¬x≈y = no (λ x≤y → ¬x≈y (antisym x≤y y≤x)) tri⟶asym : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Trichotomous _≈_ _<_ → Asymmetric _<_ tri⟶asym tri {x} {y} x<y x>y with tri x y ... | tri< _ _ x≯y = x≯y x>y ... | tri≈ _ _ x≯y = x≯y x>y ... | tri> x≮y _ _ = x≮y x<y tri⟶irr : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → _<_ Respects₂ _≈_ → Symmetric _≈_ → Trichotomous _≈_ _<_ → Irreflexive _≈_ _<_ tri⟶irr resp sym tri = asym⟶irr resp sym (tri⟶asym tri) tri⟶dec≈ : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Trichotomous _≈_ _<_ → Decidable _≈_ tri⟶dec≈ compare x y with compare x y ... | tri< _ x≉y _ = no x≉y ... | tri≈ _ x≈y _ = yes x≈y ... | tri> _ x≉y _ = no x≉y tri⟶dec< : ∀ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Trichotomous _≈_ _<_ → Decidable _<_ tri⟶dec< compare x y with compare x y ... | tri< x<y _ _ = yes x<y ... | tri≈ x≮y _ _ = no x≮y ... | tri> x≮y _ _ = no x≮y map-NonEmpty : ∀ {a b p q} {A : Set a} {B : Set b} {P : REL A B p} {Q : REL A B q} → P ⇒ Q → NonEmpty P → NonEmpty Q map-NonEmpty f x = nonEmpty (f (NonEmpty.proof x))
{ "alphanum_fraction": 0.5427830596, "avg_line_length": 31.8440366972, "ext": "agda", "hexsha": "0f36c7bfc31e80326e5b963bd897ce193e36b735", "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/Binary/Consequences.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/Binary/Consequences.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/Binary/Consequences.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": 1597, "size": 3471 }
{-# OPTIONS --safe #-} module Cubical.Algebra.RingSolver.Examples where open import Cubical.Foundations.Prelude open import Cubical.Data.Int.Base hiding (_+_ ; _·_ ; _-_) open import Cubical.Data.List open import Cubical.Algebra.CommRing open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level module Test (R : CommRing ℓ) where open CommRingStr (snd R) _ : 0r ≡ 0r _ = solve R _ : 1r · (1r + 0r) ≡ (1r · 0r) + 1r _ = solve R _ : 1r · 0r + (1r - 1r) ≡ 0r - 0r _ = solve R _ : (x : fst R) → x ≡ x _ = solve R _ : (x y : fst R) → x ≡ x _ = solve R _ : (x y : fst R) → x + y ≡ y + x _ = solve R _ : (x y : fst R) → (x + y) · (x - y) ≡ x · x - y · y _ = solve R {- A bigger example, copied from the other example files: -} _ : (x y z : (fst R)) → (x + y) · (x + y) · (x + y) · (x + y) ≡ x · x · x · x + (fromℤ R 4) · x · x · x · y + (fromℤ R 6) · x · x · y · y + (fromℤ R 4) · x · y · y · y + y · y · y · y _ = solve R {- Examples that used to fail (see #513): -} _ : (x : (fst R)) → x · 0r ≡ 0r _ = solve R _ : (x y z : (fst R)) → x · (y - z) ≡ x · y - x · z _ = solve R {- Keep in mind, that the solver can lead to wrong error locations. For example, the commented code below tries to solve an equation that does not hold, with the result of an error at the wrong location. _ : (x y : (fst R)) → x ≡ y _ = solve R -} module TestInPlaceSolving (R : CommRing ℓ) where open CommRingStr (snd R) testWithOneVariabl : (x : fst R) → x + 0r ≡ 0r + x testWithOneVariabl x = solveInPlace R (x ∷ []) testEquationalReasoning : (x : fst R) → x + 0r ≡ 0r + x testEquationalReasoning x = x + 0r ≡⟨solveIn R withVars (x ∷ []) ⟩ 0r + x ∎ testWithTwoVariables : (x y : fst R) → x + y ≡ y + x testWithTwoVariables x y = x + y ≡⟨solveIn R withVars (x ∷ y ∷ []) ⟩ y + x ∎ {- So far, solving during equational reasoning has a serious restriction: The solver identifies variables by deBruijn indices and the variables appearing in the equations to solve need to have indices 0,...,n. This entails that in the following code, the order of 'p' and 'x' cannot be switched. -} testEquationalReasoning' : (p : (y : fst R) → 0r + y ≡ 1r) (x : fst R) → x + 0r ≡ 1r testEquationalReasoning' p x = x + 0r ≡⟨solveIn R withVars (x ∷ []) ⟩ 0r + x ≡⟨ p x ⟩ 1r ∎
{ "alphanum_fraction": 0.5349107836, "avg_line_length": 26.306122449, "ext": "agda", "hexsha": "b4e0116c92e92fac86fb925f991b8bca6d754ae4", "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": "b1d105aeeab1ba9888394c6a919b99a476390b7b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ecavallo/cubical", "max_forks_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b1d105aeeab1ba9888394c6a919b99a476390b7b", "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": "ecavallo/cubical", "max_issues_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_line_length": 91, "max_stars_count": 1, "max_stars_repo_head_hexsha": "b1d105aeeab1ba9888394c6a919b99a476390b7b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ecavallo/cubical", "max_stars_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-20T11:56:18.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-20T11:56:18.000Z", "num_tokens": 979, "size": 2578 }
------------------------------------------------------------------------ -- Kuratowski finite subsets ------------------------------------------------------------------------ -- Based on Frumin, Geuvers, Gondelman and van der Weide's "Finite -- Sets in Homotopy Type Theory". {-# OPTIONS --cubical --safe #-} import Equality.Path as P module Finite-subset.Kuratowski {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection equality-with-J using (_↔_) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) import Finite-subset.Listed eq as L open import Function-universe equality-with-J hiding (id; _∘_) open import H-level equality-with-J open import H-level.Truncation.Propositional eq as Trunc using (∥_∥; _∥⊎∥_) open import Monad equality-with-J as M using (Raw-monad; Monad) private variable a b p : Level A B : Type a P : A → Type p f g : (x : A) → P x l x y z : A m n : ℕ ------------------------------------------------------------------------ -- Kuratowski finite subsets -- Kuratowski finite subsets of a given type. infixr 5 _∪_ data Finite-subset-of (A : Type a) : Type a where ∅ : Finite-subset-of A singleton : A → Finite-subset-of A _∪_ : Finite-subset-of A → Finite-subset-of A → Finite-subset-of A ∅∪ᴾ : ∅ ∪ x P.≡ x idem-sᴾ : singleton x ∪ singleton x P.≡ singleton x assocᴾ : x ∪ (y ∪ z) P.≡ (x ∪ y) ∪ z commᴾ : x ∪ y P.≡ y ∪ x is-setᴾ : P.Is-set (Finite-subset-of A) -- Variants of some of the constructors. ∅∪ : ∅ ∪ x ≡ x ∅∪ = _↔_.from ≡↔≡ ∅∪ᴾ idem-s : singleton x ∪ singleton x ≡ singleton x idem-s = _↔_.from ≡↔≡ idem-sᴾ assoc : x ∪ (y ∪ z) ≡ (x ∪ y) ∪ z assoc = _↔_.from ≡↔≡ assocᴾ comm : x ∪ y ≡ y ∪ x comm = _↔_.from ≡↔≡ commᴾ is-set : Is-set (Finite-subset-of A) is-set = _↔_.from (H-level↔H-level 2) is-setᴾ -- ∅ is a right identity for _∪_. ∪∅ : x ∪ ∅ ≡ x ∪∅ {x = x} = x ∪ ∅ ≡⟨ comm ⟩ ∅ ∪ x ≡⟨ ∅∪ ⟩∎ x ∎ ------------------------------------------------------------------------ -- Eliminators -- A dependent eliminator, expressed using paths. record Elimᴾ {A : Type a} (P : Finite-subset-of A → Type p) : Type (a ⊔ p) where field ∅ʳ : P ∅ singletonʳ : ∀ x → P (singleton x) ∪ʳ : P x → P y → P (x ∪ y) ∅∪ʳ : (p : P x) → P.[ (λ i → P (∅∪ᴾ {x = x} i)) ] ∪ʳ ∅ʳ p ≡ p idem-sʳ : ∀ x → P.[ (λ i → P (idem-sᴾ {x = x} i)) ] ∪ʳ (singletonʳ x) (singletonʳ x) ≡ singletonʳ x assocʳ : (p : P x) (q : P y) (r : P z) → P.[ (λ i → P (assocᴾ {x = x} {y = y} {z = z} i)) ] ∪ʳ p (∪ʳ q r) ≡ ∪ʳ (∪ʳ p q) r commʳ : (p : P x) (q : P y) → P.[ (λ i → P (commᴾ {x = x} {y = y} i)) ] ∪ʳ p q ≡ ∪ʳ q p is-setʳ : ∀ x → P.Is-set (P x) open Elimᴾ public elimᴾ : Elimᴾ P → (x : Finite-subset-of A) → P x elimᴾ {A = A} {P = P} e = helper where module E = Elimᴾ e helper : (x : Finite-subset-of A) → P x helper ∅ = E.∅ʳ helper (singleton x) = E.singletonʳ x helper (x ∪ y) = E.∪ʳ (helper x) (helper y) helper (∅∪ᴾ {x = x} i) = E.∅∪ʳ (helper x) i helper (idem-sᴾ i) = E.idem-sʳ _ i helper (assocᴾ {x = x} {y = y} {z = z} i) = E.assocʳ (helper x) (helper y) (helper z) i helper (commᴾ {x = x} {y = y} i) = E.commʳ (helper x) (helper y) i helper (is-setᴾ x y i j) = P.heterogeneous-UIP E.is-setʳ (is-setᴾ x y) (λ i → helper (x i)) (λ i → helper (y i)) i j -- A non-dependent eliminator, expressed using paths. record Recᴾ (A : Type a) (B : Type b) : Type (a ⊔ b) where field ∅ʳ : B singletonʳ : A → B ∪ʳ : Finite-subset-of A → Finite-subset-of A → B → B → B ∅∪ʳ : ∀ x p → ∪ʳ ∅ x ∅ʳ p P.≡ p idem-sʳ : ∀ x → ∪ʳ (singleton x) (singleton x) (singletonʳ x) (singletonʳ x) P.≡ singletonʳ x assocʳ : ∀ p q r → ∪ʳ x (y ∪ z) p (∪ʳ y z q r) P.≡ ∪ʳ (x ∪ y) z (∪ʳ x y p q) r commʳ : ∀ p q → ∪ʳ x y p q P.≡ ∪ʳ y x q p is-setʳ : P.Is-set B open Recᴾ public recᴾ : Recᴾ A B → Finite-subset-of A → B recᴾ r = elimᴾ e where module R = Recᴾ r e : Elimᴾ _ e .∅ʳ = R.∅ʳ e .singletonʳ = R.singletonʳ e .∪ʳ {x = x} {y = y} = R.∪ʳ x y e .∅∪ʳ {x = x} = R.∅∪ʳ x e .idem-sʳ = R.idem-sʳ e .assocʳ = R.assocʳ e .commʳ = R.commʳ e .is-setʳ _ = R.is-setʳ -- A dependent eliminator, expressed using equality. record Elim {A : Type a} (P : Finite-subset-of A → Type p) : Type (a ⊔ p) where field ∅ʳ : P ∅ singletonʳ : ∀ x → P (singleton x) ∪ʳ : P x → P y → P (x ∪ y) ∅∪ʳ : (p : P x) → subst P (∅∪ {x = x}) (∪ʳ ∅ʳ p) ≡ p idem-sʳ : ∀ x → subst P (idem-s {x = x}) (∪ʳ (singletonʳ x) (singletonʳ x)) ≡ singletonʳ x assocʳ : (p : P x) (q : P y) (r : P z) → subst P (assoc {x = x} {y = y} {z = z}) (∪ʳ p (∪ʳ q r)) ≡ ∪ʳ (∪ʳ p q) r commʳ : (p : P x) (q : P y) → subst P (comm {x = x} {y = y}) (∪ʳ p q) ≡ ∪ʳ q p is-setʳ : ∀ x → Is-set (P x) open Elim public elim : Elim P → (x : Finite-subset-of A) → P x elim e = elimᴾ e′ where module E = Elim e e′ : Elimᴾ _ e′ .∅ʳ = E.∅ʳ e′ .singletonʳ = E.singletonʳ e′ .∪ʳ = E.∪ʳ e′ .∅∪ʳ p = subst≡→[]≡ (E.∅∪ʳ p) e′ .idem-sʳ x = subst≡→[]≡ (E.idem-sʳ x) e′ .assocʳ p q r = subst≡→[]≡ (E.assocʳ p q r) e′ .commʳ p q = subst≡→[]≡ (E.commʳ p q) e′ .is-setʳ x = _↔_.to (H-level↔H-level 2) (E.is-setʳ x) -- A non-dependent eliminator, expressed using equality. record Rec (A : Type a) (B : Type b) : Type (a ⊔ b) where field ∅ʳ : B singletonʳ : A → B ∪ʳ : Finite-subset-of A → Finite-subset-of A → B → B → B ∅∪ʳ : ∀ x p → ∪ʳ ∅ x ∅ʳ p ≡ p idem-sʳ : ∀ x → ∪ʳ (singleton x) (singleton x) (singletonʳ x) (singletonʳ x) ≡ singletonʳ x assocʳ : ∀ p q r → ∪ʳ x (y ∪ z) p (∪ʳ y z q r) ≡ ∪ʳ (x ∪ y) z (∪ʳ x y p q) r commʳ : ∀ p q → ∪ʳ x y p q ≡ ∪ʳ y x q p is-setʳ : Is-set B open Rec public rec : Rec A B → Finite-subset-of A → B rec r = recᴾ r′ where module R = Rec r r′ : Recᴾ _ _ r′ .∅ʳ = R.∅ʳ r′ .singletonʳ = R.singletonʳ r′ .∪ʳ = R.∪ʳ r′ .∅∪ʳ x p = _↔_.to ≡↔≡ (R.∅∪ʳ x p) r′ .idem-sʳ x = _↔_.to ≡↔≡ (R.idem-sʳ x) r′ .assocʳ p q r = _↔_.to ≡↔≡ (R.assocʳ p q r) r′ .commʳ p q = _↔_.to ≡↔≡ (R.commʳ p q) r′ .is-setʳ = _↔_.to (H-level↔H-level 2) R.is-setʳ -- A dependent eliminator for propositions. record Elim-prop {A : Type a} (P : Finite-subset-of A → Type p) : Type (a ⊔ p) where field ∅ʳ : P ∅ singletonʳ : ∀ x → P (singleton x) ∪ʳ : P x → P y → P (x ∪ y) is-propositionʳ : ∀ x → Is-proposition (P x) open Elim-prop public elim-prop : Elim-prop P → (x : Finite-subset-of A) → P x elim-prop e = elim e′ where module E = Elim-prop e e′ : Elim _ e′ .∅ʳ = E.∅ʳ e′ .singletonʳ = E.singletonʳ e′ .∪ʳ = E.∪ʳ e′ .∅∪ʳ _ = E.is-propositionʳ _ _ _ e′ .idem-sʳ _ = E.is-propositionʳ _ _ _ e′ .assocʳ _ _ _ = E.is-propositionʳ _ _ _ e′ .commʳ _ _ = E.is-propositionʳ _ _ _ e′ .is-setʳ _ = mono₁ 1 (E.is-propositionʳ _) -- A non-dependent eliminator for propositions. record Rec-prop (A : Type a) (B : Type b) : Type (a ⊔ b) where field ∅ʳ : B singletonʳ : A → B ∪ʳ : Finite-subset-of A → Finite-subset-of A → B → B → B is-propositionʳ : Is-proposition B open Rec-prop public rec-prop : Rec-prop A B → Finite-subset-of A → B rec-prop r = elim-prop e where module R = Rec-prop r e : Elim-prop _ e .∅ʳ = R.∅ʳ e .singletonʳ = R.singletonʳ e .∪ʳ {x = x} {y = y} = R.∪ʳ x y e .is-propositionʳ _ = R.is-propositionʳ ------------------------------------------------------------------------ -- Definitions related to listed finite subsets private -- Some definitions used in the implementation of Listed≃Kuratowski -- below. to : L.Finite-subset-of A → Finite-subset-of A to L.[] = ∅ to (x L.∷ y) = singleton x ∪ to y to (L.dropᴾ {x = x} {y = y} i) = (singleton x ∪ (singleton x ∪ to y) P.≡⟨ assocᴾ ⟩ (singleton x ∪ singleton x) ∪ to y P.≡⟨ P.cong (_∪ to y) idem-sᴾ ⟩∎ singleton x ∪ to y ∎) i to (L.swapᴾ {x = x} {y = y} {z = z} i) = (singleton x ∪ (singleton y ∪ to z) P.≡⟨ assocᴾ ⟩ (singleton x ∪ singleton y) ∪ to z P.≡⟨ P.cong (_∪ to z) commᴾ ⟩ (singleton y ∪ singleton x) ∪ to z P.≡⟨ P.sym assocᴾ ⟩∎ singleton y ∪ (singleton x ∪ to z) ∎) i to (L.is-setᴾ x y i j) = is-setᴾ (λ i → to (x i)) (λ i → to (y i)) i j to-∪ : (x : L.Finite-subset-of A) → to (x L.∪ y) ≡ to x ∪ to y to-∪ {y = y} = L.elim-prop e where e : L.Elim-prop _ e .L.is-propositionʳ _ = is-set e .L.[]ʳ = to y ≡⟨ sym ∅∪ ⟩∎ ∅ ∪ to y ∎ e .L.∷ʳ {y = z} x hyp = singleton x ∪ to (z L.∪ y) ≡⟨ cong (singleton x ∪_) hyp ⟩ singleton x ∪ (to z ∪ to y) ≡⟨ assoc ⟩∎ (singleton x ∪ to z) ∪ to y ∎ -- Listed finite subsets are equivalent to Kuratowski finite subsets. Listed≃Kuratowski : L.Finite-subset-of A ≃ Finite-subset-of A Listed≃Kuratowski {A = A} = from-bijection (record { surjection = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to∘from } ; left-inverse-of = from∘to }) where from : Finite-subset-of A → L.Finite-subset-of A from ∅ = L.[] from (singleton x) = x L.∷ L.[] from (x ∪ y) = from x L.∪ from y from (∅∪ᴾ {x = x} _) = from x from (idem-sᴾ {x = x} i) = L.dropᴾ {x = x} {y = L.[]} i from (assocᴾ {x = x} {y = y} {z = z} i) = _↔_.to ≡↔≡ (L.assoc {y = from y} {z = from z} (from x)) i from (commᴾ {x = x} {y = y} i) = _↔_.to ≡↔≡ (L.comm {y = from y} (from x)) i from (is-setᴾ x y i j) = L.is-setᴾ (λ i → from (x i)) (λ i → from (y i)) i j to∘from : ∀ x → to (from x) ≡ x to∘from = elim-prop e where e : Elim-prop _ e .is-propositionʳ _ = is-set e .∅ʳ = refl _ e .singletonʳ _ = ∪∅ e .∪ʳ {x = x} {y = y} hyp₁ hyp₂ = to (from x L.∪ from y) ≡⟨ to-∪ (from x) ⟩ to (from x) ∪ to (from y) ≡⟨ cong₂ _∪_ hyp₁ hyp₂ ⟩∎ x ∪ y ∎ from∘to : ∀ x → from (to x) ≡ x from∘to = L.elim-prop e where e : L.Elim-prop _ e .L.is-propositionʳ _ = L.is-set e .L.[]ʳ = refl _ e .L.∷ʳ {y = y} x hyp = x L.∷ from (to y) ≡⟨ cong (x L.∷_) hyp ⟩∎ x L.∷ y ∎ -- The forward direction of Listed≃Kuratowski is homomorphic with -- respect to L._∪_/_∪_. to-Listed≃Kuratowski-∪ : (x : L.Finite-subset-of A) → _≃_.to Listed≃Kuratowski (x L.∪ y) ≡ _≃_.to Listed≃Kuratowski x ∪ _≃_.to Listed≃Kuratowski y to-Listed≃Kuratowski-∪ = to-∪ -- The other direction of Listed≃Kuratowski is definitionally -- homomorphic with respect to _∪_/L._∪_. _ : _≃_.from Listed≃Kuratowski (x ∪ y) ≡ _≃_.from Listed≃Kuratowski x L.∪ _≃_.from Listed≃Kuratowski y _ = refl _ -- A list-like dependent eliminator for Finite-subset-of, for -- propositions. record List-elim-prop {A : Type a} (P : Finite-subset-of A → Type p) : Type (a ⊔ p) where field []ʳ : P ∅ ∷ʳ : ∀ x → P y → P (singleton x ∪ y) is-propositionʳ : ∀ x → Is-proposition (P x) open List-elim-prop public list-elim-prop : List-elim-prop P → (x : Finite-subset-of A) → P x list-elim-prop {P = P} l x = subst P (_≃_.right-inverse-of Listed≃Kuratowski x) (L.elim-prop e (_≃_.from Listed≃Kuratowski x)) where module E = List-elim-prop l e : L.Elim-prop (P ∘ _≃_.to Listed≃Kuratowski) e .L.[]ʳ = E.[]ʳ e .L.∷ʳ x = E.∷ʳ x e .L.is-propositionʳ _ = E.is-propositionʳ _ -- A list-like non-dependent eliminator for Finite-subset-of, -- expressed using paths. record List-recᴾ (A : Type a) (B : Type b) : Type (a ⊔ b) where field []ʳ : B ∷ʳ : A → Finite-subset-of A → B → B dropʳ : ∀ x y p → ∷ʳ x (singleton x ∪ y) (∷ʳ x y p) P.≡ ∷ʳ x y p swapʳ : ∀ x y z p → ∷ʳ x (singleton y ∪ z) (∷ʳ y z p) P.≡ ∷ʳ y (singleton x ∪ z) (∷ʳ x z p) is-setʳ : P.Is-set B open List-recᴾ public list-recᴾ : List-recᴾ A B → Finite-subset-of A → B list-recᴾ l = L.recᴾ r ∘ _≃_.from Listed≃Kuratowski where module E = List-recᴾ l r : L.Recᴾ _ _ r .L.[]ʳ = E.[]ʳ r .L.∷ʳ x y = E.∷ʳ x (_≃_.to Listed≃Kuratowski y) r .L.dropʳ x y = E.dropʳ x (_≃_.to Listed≃Kuratowski y) r .L.swapʳ x y z = E.swapʳ x y (_≃_.to Listed≃Kuratowski z) r .L.is-setʳ = E.is-setʳ -- Unit tests documenting some of the computational behaviour of -- list-recᴾ. _ : list-recᴾ l ∅ ≡ l .[]ʳ _ = refl _ _ : list-recᴾ l (singleton x) ≡ l .∷ʳ x ∅ (l .[]ʳ) _ = refl _ _ : let y′ = _≃_.to Listed≃Kuratowski (_≃_.from Listed≃Kuratowski y) in list-recᴾ l (singleton x ∪ y) ≡ l .∷ʳ x y′ (list-recᴾ l y) _ = refl _ -- A list-like non-dependent eliminator for Finite-subset-of, -- expressed using equality. record List-rec (A : Type a) (B : Type b) : Type (a ⊔ b) where field []ʳ : B ∷ʳ : A → Finite-subset-of A → B → B dropʳ : ∀ x y p → ∷ʳ x (singleton x ∪ y) (∷ʳ x y p) ≡ ∷ʳ x y p swapʳ : ∀ x y z p → ∷ʳ x (singleton y ∪ z) (∷ʳ y z p) ≡ ∷ʳ y (singleton x ∪ z) (∷ʳ x z p) is-setʳ : Is-set B open List-rec public list-rec : List-rec A B → Finite-subset-of A → B list-rec l = list-recᴾ l′ where module R = List-rec l l′ : List-recᴾ _ _ l′ .[]ʳ = R.[]ʳ l′ .∷ʳ = R.∷ʳ l′ .dropʳ x y p = _↔_.to ≡↔≡ (R.dropʳ x y p) l′ .swapʳ x y z p = _↔_.to ≡↔≡ (R.swapʳ x y z p) l′ .is-setʳ = _↔_.to (H-level↔H-level 2) R.is-setʳ -- Unit tests documenting some of the computational behaviour of -- list-rec. _ : list-rec l ∅ ≡ l .[]ʳ _ = refl _ _ : list-rec l (singleton x) ≡ l .∷ʳ x ∅ (l .[]ʳ) _ = refl _ _ : let y′ = _≃_.to Listed≃Kuratowski (_≃_.from Listed≃Kuratowski y) in list-rec l (singleton x ∪ y) ≡ l .∷ʳ x y′ (list-rec l y) _ = refl _ ------------------------------------------------------------------------ -- Membership -- Membership. infix 4 _∈_ _∈_ : {A : Type a} → A → Finite-subset-of A → Type a x ∈ y = x L.∈ _≃_.from Listed≃Kuratowski y -- Membership is propositional. ∈-propositional : ∀ y → Is-proposition (x ∈ y) ∈-propositional _ = L.∈-propositional -- A lemma characterising ∅. ∈∅≃ : (x ∈ ∅) ≃ ⊥₀ ∈∅≃ = L.∈[]≃ -- A lemma characterising singleton. ∈singleton≃ : (x ∈ singleton y) ≃ ∥ x ≡ y ∥ ∈singleton≃ = L.∈singleton≃ -- If x is a member of y, then x is a member of y ∪ z. ∈→∈∪ˡ : ∀ y z → x ∈ y → x ∈ y ∪ z ∈→∈∪ˡ {x = x} y z = x ∈ y ↔⟨⟩ x L.∈ _≃_.from Listed≃Kuratowski y ↝⟨ L.∈→∈∪ˡ ⟩ x L.∈ _≃_.from Listed≃Kuratowski y L.∪ _≃_.from Listed≃Kuratowski z ↔⟨⟩ x L.∈ _≃_.from Listed≃Kuratowski (y ∪ z) ↔⟨⟩ x ∈ y ∪ z □ -- If x is a member of z, then x is a member of y ∪ z. ∈→∈∪ʳ : ∀ y z → x ∈ z → x ∈ y ∪ z ∈→∈∪ʳ {x = x} y z = x ∈ z ↔⟨⟩ x L.∈ _≃_.from Listed≃Kuratowski z ↝⟨ L.∈→∈∪ʳ (_≃_.from Listed≃Kuratowski y) ⟩ x L.∈ _≃_.from Listed≃Kuratowski y L.∪ _≃_.from Listed≃Kuratowski z ↔⟨⟩ x ∈ y ∪ z □ -- Membership of a union of two subsets can be expressed in terms of -- membership of the subsets. ∈∪≃ : ∀ y z → (x ∈ y ∪ z) ≃ (x ∈ y ∥⊎∥ x ∈ z) ∈∪≃ {x = x} y z = x ∈ y ∪ z ↔⟨⟩ x L.∈ _≃_.from Listed≃Kuratowski y L.∪ _≃_.from Listed≃Kuratowski z ↝⟨ L.∈∪≃ ⟩ x L.∈ _≃_.from Listed≃Kuratowski y ∥⊎∥ x L.∈ _≃_.from Listed≃Kuratowski z ↔⟨⟩ x ∈ y ∥⊎∥ x ∈ z □ -- If truncated equality is decidable, then membership is also -- decidable. member? : ((x y : A) → Dec ∥ x ≡ y ∥) → (x : A) (y : Finite-subset-of A) → Dec (x ∈ y) member? equal? x = L.member? equal? x ∘ _≃_.from Listed≃Kuratowski -- Subsets. _⊆_ : {A : Type a} → Finite-subset-of A → Finite-subset-of A → Type a x ⊆ y = ∀ z → z ∈ x → z ∈ y -- The subset property can be expressed using _∪_ and _≡_. ⊆≃∪≡ : (x ⊆ y) ≃ (x ∪ y ≡ y) ⊆≃∪≡ {x = x} {y = y} = x ⊆ y ↝⟨ L.⊆≃∪≡ (_≃_.from Listed≃Kuratowski x) ⟩ _≃_.from Listed≃Kuratowski x L.∪ _≃_.from Listed≃Kuratowski y ≡ _≃_.from Listed≃Kuratowski y ↔⟨⟩ _≃_.from Listed≃Kuratowski (x ∪ y) ≡ _≃_.from Listed≃Kuratowski y ↝⟨ Eq.≃-≡ (inverse Listed≃Kuratowski) ⟩□ x ∪ y ≡ y □ -- Extensionality. extensionality : (x ≡ y) ≃ (∀ z → z ∈ x ⇔ z ∈ y) extensionality {x = x} {y = y} = x ≡ y ↝⟨ inverse $ Eq.≃-≡ (inverse Listed≃Kuratowski) ⟩ _≃_.from Listed≃Kuratowski x ≡ _≃_.from Listed≃Kuratowski y ↝⟨ L.extensionality ⟩□ (∀ z → z ∈ x ⇔ z ∈ y) □ ------------------------------------------------------------------------ -- A law -- Union is idempotent. idem : x ∪ x ≡ x idem {x = x} = _≃_.from extensionality λ y → y ∈ x ∪ x ↔⟨ ∈∪≃ x x ⟩ y ∈ x ∥⊎∥ y ∈ x ↔⟨ Trunc.idempotent ⟩ ∥ y ∈ x ∥ ↔⟨ Trunc.∥∥↔ (∈-propositional x) ⟩□ y ∈ x □ ------------------------------------------------------------------------ -- Some operations -- A map function. map : (A → B) → Finite-subset-of A → Finite-subset-of B map f = recᴾ r where r : Recᴾ _ _ r .∅ʳ = ∅ r .singletonʳ x = singleton (f x) r .∪ʳ _ _ = _∪_ r .∅∪ʳ _ _ = ∅∪ᴾ r .idem-sʳ _ = idem-sᴾ r .assocʳ _ _ _ = assocᴾ r .commʳ _ _ = commᴾ r .is-setʳ = is-setᴾ -- A filter function. filter : (A → Bool) → Finite-subset-of A → Finite-subset-of A filter p = rec r where r : Rec _ _ r .∅ʳ = ∅ r .singletonʳ x = if p x then singleton x else ∅ r .∪ʳ _ _ = _∪_ r .∅∪ʳ _ _ = ∅∪ r .idem-sʳ _ = idem r .assocʳ _ _ _ = assoc r .commʳ _ _ = comm r .is-setʳ = is-set -- Join. join : Finite-subset-of (Finite-subset-of A) → Finite-subset-of A join = rec r where r : Rec _ _ r .∅ʳ = ∅ r .singletonʳ = id r .∪ʳ _ _ = _∪_ r .∅∪ʳ _ _ = ∅∪ r .idem-sʳ _ = idem r .assocʳ _ _ _ = assoc r .commʳ _ _ = comm r .is-setʳ = is-set -- A universe-polymorphic variant of bind. infixl 5 _>>=′_ _>>=′_ : Finite-subset-of A → (A → Finite-subset-of B) → Finite-subset-of B x >>=′ f = join (map f x) -- Bind distributes from the right over union. _ : (x ∪ y) >>=′ f ≡ (x >>=′ f) ∪ (y >>=′ f) _ = refl _ -- Bind distributes from the left over union. >>=-left-distributive : ∀ x → (x >>=′ λ x → f x ∪ g x) ≡ (x >>=′ f) ∪ (x >>=′ g) >>=-left-distributive {f = f} {g = g} = elim-prop e where e : Elim-prop _ e .∅ʳ = ∅ ≡⟨ sym idem ⟩∎ ∅ ∪ ∅ ∎ e .singletonʳ _ = refl _ e .is-propositionʳ _ = is-set e .∪ʳ {x = x} {y = y} hyp₁ hyp₂ = (x ∪ y) >>=′ (λ x → f x ∪ g x) ≡⟨⟩ (x >>=′ λ x → f x ∪ g x) ∪ (y >>=′ λ x → f x ∪ g x) ≡⟨ cong₂ _∪_ hyp₁ hyp₂ ⟩ ((x >>=′ f) ∪ (x >>=′ g)) ∪ ((y >>=′ f) ∪ (y >>=′ g)) ≡⟨ sym assoc ⟩ (x >>=′ f) ∪ ((x >>=′ g) ∪ ((y >>=′ f) ∪ (y >>=′ g))) ≡⟨ cong ((x >>=′ f) ∪_) assoc ⟩ (x >>=′ f) ∪ (((x >>=′ g) ∪ (y >>=′ f)) ∪ (y >>=′ g)) ≡⟨ cong (((x >>=′ f) ∪_) ∘ (_∪ (y >>=′ g))) comm ⟩ (x >>=′ f) ∪ (((y >>=′ f) ∪ (x >>=′ g)) ∪ (y >>=′ g)) ≡⟨ cong ((x >>=′ f) ∪_) (sym assoc) ⟩ (x >>=′ f) ∪ ((y >>=′ f) ∪ ((x >>=′ g) ∪ (y >>=′ g))) ≡⟨ assoc ⟩ ((x >>=′ f) ∪ (y >>=′ f)) ∪ ((x >>=′ g) ∪ (y >>=′ g)) ≡⟨⟩ ((x ∪ y) >>=′ f) ∪ ((x ∪ y) >>=′ g) ∎ -- Monad laws. _ : singleton x >>=′ f ≡ f x _ = refl _ >>=-singleton : x >>=′ singleton ≡ x >>=-singleton = elim-prop e _ where e : Elim-prop (λ x → x >>=′ singleton ≡ x) e .∅ʳ = refl _ e .singletonʳ _ = refl _ e .is-propositionʳ _ = is-set e .∪ʳ {x = x} {y = y} hyp₁ hyp₂ = (x ∪ y) >>=′ singleton ≡⟨⟩ (x >>=′ singleton) ∪ (y >>=′ singleton) ≡⟨ cong₂ _∪_ hyp₁ hyp₂ ⟩∎ x ∪ y ∎ >>=-assoc : ∀ x → x >>=′ (λ x → f x >>=′ g) ≡ x >>=′ f >>=′ g >>=-assoc {f = f} {g = g} = elim-prop e where e : Elim-prop _ e .∅ʳ = refl _ e .singletonʳ _ = refl _ e .is-propositionʳ _ = is-set e .∪ʳ {x = x} {y = y} hyp₁ hyp₂ = (x ∪ y) >>=′ (λ x → f x >>=′ g) ≡⟨⟩ (x >>=′ λ x → f x >>=′ g) ∪ (y >>=′ λ x → f x >>=′ g) ≡⟨ cong₂ _∪_ hyp₁ hyp₂ ⟩ (x >>=′ f >>=′ g) ∪ (y >>=′ f >>=′ g) ≡⟨⟩ (x ∪ y) >>=′ f >>=′ g ∎ -- A monad instance. instance raw-monad : Raw-monad {d = a} Finite-subset-of raw-monad .M.return = singleton raw-monad .M._>>=_ = _>>=′_ monad : Monad {d = a} Finite-subset-of monad .M.Monad.raw-monad = raw-monad monad .M.Monad.left-identity _ _ = refl _ monad .M.Monad.right-identity _ = >>=-singleton monad .M.Monad.associativity x _ _ = >>=-assoc x ------------------------------------------------------------------------ -- Size -- Size. infix 4 ∣_∣≡_ ∣_∣≡_ : {A : Type a} → Finite-subset-of A → ℕ → Type a ∣ x ∣≡ n = L.∣ _≃_.from Listed≃Kuratowski x ∣≡ n -- The size predicate is propositional. ∣∣≡-propositional : (x : Finite-subset-of A) → Is-proposition (∣ x ∣≡ n) ∣∣≡-propositional = L.∣∣≡-propositional ∘ _≃_.from Listed≃Kuratowski -- Unit tests documenting some of the computational behaviour of -- ∣_∣≡_. _ : (∣ ∅ {A = A} ∣≡ n) ≡ ↑ _ (n ≡ 0) _ = refl _ _ : ∀ {A : Type a} {x : A} {y} → (∣ singleton x ∪ y ∣≡ zero) ≡ (x ∈ y × ∣ y ∣≡ zero ⊎ ⊥) _ = refl _ _ : (∣ singleton x ∪ y ∣≡ suc n) ≡ (x ∈ y × ∣ y ∣≡ suc n ⊎ ¬ x ∈ y × ∣ y ∣≡ n) _ = refl _ -- The size predicate is functional. ∣∣≡-functional : (x : Finite-subset-of A) → ∣ x ∣≡ m → ∣ x ∣≡ n → m ≡ n ∣∣≡-functional = L.∣∣≡-functional ∘ _≃_.from Listed≃Kuratowski -- If truncated equality is decidable, then one can compute the size -- of a finite subset. size : ((x y : A) → Dec ∥ x ≡ y ∥) → (x : Finite-subset-of A) → ∃ λ n → ∣ x ∣≡ n size equal? = L.size equal? ∘ _≃_.from Listed≃Kuratowski
{ "alphanum_fraction": 0.4558053846, "avg_line_length": 30.5409207161, "ext": "agda", "hexsha": "0e1af70fc12820388e59a4a026d8f4cad4d8f449", "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/Finite-subset/Kuratowski.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/Finite-subset/Kuratowski.agda", "max_line_length": 114, "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/Finite-subset/Kuratowski.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": 9853, "size": 23883 }
data ⊤ : Set where tt : ⊤ data Identity (t : Set) : Set where MkIdentity : t → Identity t let-example : Identity ⊤ let-example = let x = tt in MkIdentity x -- Parse error do-example : Identity ⊤ do-example = do MkIdentity tt where x : ⊤ x = tt
{ "alphanum_fraction": 0.598540146, "avg_line_length": 14.4210526316, "ext": "agda", "hexsha": "bbba817fd08f476f6b655ff30951f8163b39867e", "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/Issue3046.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/Issue3046.agda", "max_line_length": 38, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3046.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": 91, "size": 274 }
{-# OPTIONS --cubical --safe --guardedness #-} module Data.PolyP where open import Data.PolyP.RecursionSchemes public open import Data.PolyP.Universe public open import Data.PolyP.Composition public open import Data.PolyP.Types public open import Data.PolyP.Currying public
{ "alphanum_fraction": 0.8043478261, "avg_line_length": 27.6, "ext": "agda", "hexsha": "d11eb8b81cf384ae34c64b65f925297ed90da28a", "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/PolyP.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/PolyP.agda", "max_line_length": 46, "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/PolyP.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": 71, "size": 276 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Category.Monoidal module Categories.Category.Monoidal.Symmetric {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where open import Level open import Data.Product using (Σ; _,_) open import Categories.Functor.Bifunctor open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.Morphism C open import Categories.Category.Monoidal.Braided M open Category C open Commutation private variable X Y Z : Obj -- symmetric monoidal category -- commutative braided monoidal category record Symmetric : Set (levelOfTerm M) where field braided : Braided module braided = Braided braided open braided public private B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X B {X} {Y} = braiding.⇒.η (X , Y) field commutative : B {X} {Y} ∘ B {Y} {X} ≈ id braided-iso : X ⊗₀ Y ≅ Y ⊗₀ X braided-iso = record { from = B ; to = B ; iso = record { isoˡ = commutative ; isoʳ = commutative } }
{ "alphanum_fraction": 0.6746411483, "avg_line_length": 21.3265306122, "ext": "agda", "hexsha": "e5ee344bf09bb1849975f2f5358bc8330714bb1f", "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": "89d163f72caa7deeac9413f27bc1b4ed7f9e025b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-categories", "max_forks_repo_path": "Categories/Category/Monoidal/Symmetric.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "89d163f72caa7deeac9413f27bc1b4ed7f9e025b", "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-categories", "max_issues_repo_path": "Categories/Category/Monoidal/Symmetric.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "89d163f72caa7deeac9413f27bc1b4ed7f9e025b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-categories", "max_stars_repo_path": "Categories/Category/Monoidal/Symmetric.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 328, "size": 1045 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The type for booleans and some operations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Bool.Base where open import Data.Unit.Base using (⊤) open import Data.Empty open import Level using (Level) private variable a : Level A : Set a ------------------------------------------------------------------------ -- The boolean type open import Agda.Builtin.Bool public ------------------------------------------------------------------------ -- Relations infix 4 _≤_ _<_ data _≤_ : Bool → Bool → Set where f≤t : false ≤ true b≤b : ∀ {b} → b ≤ b data _<_ : Bool → Bool → Set where f<t : false < true ------------------------------------------------------------------------ -- Boolean operations infixr 6 _∧_ infixr 5 _∨_ _xor_ not : Bool → Bool not true = false not false = true _∧_ : 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 ------------------------------------------------------------------------ -- Other operations infix 0 if_then_else_ if_then_else_ : Bool → A → A → A if true then t else f = t if false then t else f = f -- A function mapping true to an inhabited type and false to an empty -- type. T : Bool → Set T true = ⊤ T false = ⊥
{ "alphanum_fraction": 0.4510067114, "avg_line_length": 19.8666666667, "ext": "agda", "hexsha": "ee641de78fa6e7492a72186effb413788b00b83d", "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/Bool/Base.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/Bool/Base.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/Bool/Base.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": 365, "size": 1490 }
-- {-# OPTIONS --verbose tc.conv.term:40 #-} -- {-# OPTIONS --verbose tc.conv.level:40 #-} -- {-# OPTIONS --verbose tc.conv.atom:50 #-} -- {-# OPTIONS --verbose tc.conv.elim:50 #-} module Issue680-NeutralLevels where open import Common.Level postulate N : Set A : N → Set B : Set level' : B → Level lac : ∀ {n} → A n → B I : Level → Level → Set refl : ∀ {l : Level} → I l l Top : Set top : Top data Test : Set where mkTest : (n : N) → (tel : A n) → Test test : Test → Top test (mkTest n tel) = top where test′ : I (lsuc (level' (lac tel))) (lsuc (level' (lac tel))) test′ = refl
{ "alphanum_fraction": 0.5110782866, "avg_line_length": 23.3448275862, "ext": "agda", "hexsha": "4cee9293890d051d30dbc061751429d7a0f51acb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/Issue680-NeutralLevels.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/Issue680-NeutralLevels.agda", "max_line_length": 65, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/Issue680-NeutralLevels.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": 209, "size": 677 }
module Stack where open import Prelude public -- Stacks, or snoc-lists. data Stack (X : Set) : Set where ∅ : Stack X _,_ : Stack X → X → Stack X -- Stack membership, or de Bruijn indices. module _ {X : Set} where infix 3 _∈_ data _∈_ (A : X) : Stack X → Set where top : ∀ {Γ} → A ∈ Γ , A pop : ∀ {Γ B} → A ∈ Γ → A ∈ Γ , B ⌊_⌋∈ : ∀ {Γ A} → A ∈ Γ → Nat ⌊ top ⌋∈ = zero ⌊ pop i ⌋∈ = suc ⌊ i ⌋∈ i₀ : ∀ {Γ A} → A ∈ Γ , A i₀ = top i₁ : ∀ {Γ A B} → A ∈ Γ , A , B i₁ = pop i₀ i₂ : ∀ {Γ A B C} → A ∈ Γ , A , B , C i₂ = pop i₁ -- Stack inclusion, or order-preserving embeddings. module _ {X : Set} where infix 3 _⊆_ data _⊆_ : Stack X → Stack X → Set where bot : ∀ {Γ} → ∅ ⊆ Γ skip : ∀ {Γ Γ′ A} → Γ ⊆ Γ′ → Γ ⊆ Γ′ , A keep : ∀ {Γ Γ′ A} → Γ ⊆ Γ′ → Γ , A ⊆ Γ′ , A refl⊆ : ∀ {Γ} → Γ ⊆ Γ refl⊆ {∅} = bot refl⊆ {Γ , A} = keep refl⊆ trans⊆ : ∀ {Γ Γ′ Γ″} → Γ ⊆ Γ′ → Γ′ ⊆ Γ″ → Γ ⊆ Γ″ trans⊆ bot η′ = bot trans⊆ η (skip η′) = skip (trans⊆ η η′) trans⊆ (skip η) (keep η′) = skip (trans⊆ η η′) trans⊆ (keep η) (keep η′) = keep (trans⊆ η η′) weak⊆ : ∀ {Γ A} → Γ ⊆ Γ , A weak⊆ = skip refl⊆ -- Monotonicity of stack membership with respect to stack inclusion. module _ {X : Set} where mono∈ : ∀ {Γ Γ′ : Stack X} {A} → Γ ⊆ Γ′ → A ∈ Γ → A ∈ Γ′ mono∈ bot () mono∈ (skip η) i = pop (mono∈ η i) mono∈ (keep η) top = top mono∈ (keep η) (pop i) = pop (mono∈ η i) -- Pairs of stacks. infixl 4 _⁏_ record Stack² (X Y : Set) : Set where constructor _⁏_ field π₁ : Stack X π₂ : Stack Y open Stack² public -- Stack pair inclusion. module _ {X Y : Set} where infix 3 _⊆²_ _⊆²_ : Stack² X Y → Stack² X Y → Set Γ ⁏ Δ ⊆² Γ′ ⁏ Δ′ = Γ ⊆ Γ′ ∧ Δ ⊆ Δ′ refl⊆² : ∀ {Γ Δ} → Γ ⁏ Δ ⊆² Γ ⁏ Δ refl⊆² = refl⊆ , refl⊆ trans⊆² : ∀ {Γ Γ′ Γ″ Δ Δ′ Δ″} → Γ ⁏ Δ ⊆² Γ′ ⁏ Δ′ → Γ′ ⁏ Δ′ ⊆² Γ″ ⁏ Δ″ → Γ ⁏ Δ ⊆² Γ″ ⁏ Δ″ trans⊆² (η , ρ) (η′ , ρ′) = trans⊆ η η′ , trans⊆ ρ ρ′
{ "alphanum_fraction": 0.4691109995, "avg_line_length": 21.6413043478, "ext": "agda", "hexsha": "28b5fea58fcca6b618a58d2c7d739b3f5eb4665e", "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": "accc6c57390c435728d568ae590a02b2776b8891", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/imla2017", "max_forks_repo_path": "src/Stack.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/imla2017", "max_issues_repo_path": "src/Stack.agda", "max_line_length": 90, "max_stars_count": 17, "max_stars_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/imla2017", "max_stars_repo_path": "src/Stack.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-17T13:02:58.000Z", "max_stars_repo_stars_event_min_datetime": "2017-02-27T05:04:55.000Z", "num_tokens": 1005, "size": 1991 }
{-# OPTIONS --safe --without-K #-} module JVM.Prelude where open import Level public hiding (zero) renaming (suc to sucℓ) open import Function public using (case_of_; _∘_; id; const) open import Data.List using (List; _∷_; []; [_]) public open import Data.Unit using (⊤; tt) public open import Data.Nat using (ℕ; suc; zero; _+_) public open import Data.Sum using (inj₁; inj₂) renaming (_⊎_ to _⊕_)public open import Data.Product public hiding (map; zip) open import Relation.Unary hiding (_∈_; Empty) public open import Relation.Binary.PropositionalEquality hiding ([_]) public open import Relation.Ternary.Core public open import Relation.Ternary.Structures public
{ "alphanum_fraction": 0.752238806, "avg_line_length": 37.2222222222, "ext": "agda", "hexsha": "f8e575d8089da31dd19101aecf0b1ca26852f4f4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/JVM/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "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": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/JVM/Prelude.agda", "max_line_length": 69, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/JVM/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z", "num_tokens": 183, "size": 670 }
module Coverage where infixr 40 _::_ data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A data D : Set where c1 : D -> D c2 : D c3 : D -> D -> D -> D c4 : D -> D -> D f : D -> D -> D -> D -> List D f (c3 a (c1 b) (c1 c2)) (c1 (c1 c)) d (c1 (c1 (c1 e))) = a :: b :: c :: d :: e :: [] f (c3 (c4 c2 a) (c1 b) (c1 c)) d (c1 (c1 e)) (c1 (c1 (c1 f))) = a :: b :: c :: d :: e :: f :: [] f a b (c1 c) (c3 d (c1 e) (c1 f)) = a :: b :: c :: d :: e :: f :: [] f (c3 (c4 a c2) b (c1 c)) (c1 d) (c1 (c1 (c1 e))) (c1 (c1 (c1 f))) = a :: b :: c :: d :: e :: f :: [] -- f (c3 a (c1 b) c) (c1 (c1 (c1 d))) (c1 (c1 (c1 e))) f = a :: b :: c :: d :: e :: f :: [] -- f a b (c1 (c1 c)) (c1 (c1 (c1 c2))) = a :: b :: c :: [] f a b c d = a :: b :: c :: d :: []
{ "alphanum_fraction": 0.3651612903, "avg_line_length": 33.6956521739, "ext": "agda", "hexsha": "bc00f588a0c86f47d77c28c66ef70945a57a9103", "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": "benchmark/misc/Coverage.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": "benchmark/misc/Coverage.agda", "max_line_length": 101, "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": "benchmark/misc/Coverage.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": 391, "size": 775 }
open import Data.Product using ( proj₁ ; proj₂ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; sym ; cong ) open import Relation.Unary using ( _⊆_ ) open import Web.Semantic.DL.ABox using ( ABox ; ⟨ABox⟩ ; Assertions ) open import Web.Semantic.DL.ABox.Interp using ( ⌊_⌋ ; ind ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; bnodes ; _,_ ) open import Web.Semantic.DL.Category.Object using ( Object ; IN ; fin ; iface ) open import Web.Semantic.DL.Category.Morphism using ( impl ; _≣_ ; _⊑_ ; _,_ ) open import Web.Semantic.DL.Category.Composition using ( _∙_ ) open import Web.Semantic.DL.Category.Properties.Composition.Lemmas using ( compose-left ; compose-right ; compose-resp-⊨a ) open import Web.Semantic.DL.Category.Wiring using ( wiring ; wires-≈ ; wires-≈⁻¹ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.DL.TBox.Interp using ( Δ ; _⊨_≈_ ; ≈-refl ; ≈-refl′ ; ≈-trans ) open import Web.Semantic.Util using ( _∘_ ; False ; elim ; _⊕_⊕_ ; inode ; bnode ; enode ) module Web.Semantic.DL.Category.Properties.Composition.RespectsWiring {Σ : Signature} {S T : TBox Σ} where compose-resp-wiring : ∀ (A B C : Object S T) → (f : IN B → IN A) → (f✓ : Assertions (⟨ABox⟩ f (iface B)) ⊆ Assertions (iface A)) → (g : IN C → IN B) → (g✓ : Assertions (⟨ABox⟩ g (iface C)) ⊆ Assertions (iface B)) → (h : IN C → IN A) → (h✓ : Assertions (⟨ABox⟩ h (iface C)) ⊆ Assertions (iface A)) → (∀ x → f (g x) ≡ h x) → (wiring A B f f✓ ∙ wiring B C g g✓ ≣ wiring A C h h✓) compose-resp-wiring A B C f f✓ g g✓ h h✓ fg≡h = (LHS⊑RHS , RHS⊑LHS) where LHS⊑RHS : wiring A B f f✓ ∙ wiring B C g g✓ ⊑ wiring A C h h✓ LHS⊑RHS I I⊨STA I⊨F = (elim , I⊨RHS) where lemma : ∀ x → ⌊ I ⌋ ⊨ ind I (inode (h x)) ≈ ind I (enode x) lemma x = ≈-trans ⌊ I ⌋ (≈-refl′ ⌊ I ⌋ (cong (ind I ∘ inode) (sym (fg≡h x)))) (≈-trans ⌊ I ⌋ (wires-≈ f (proj₂ (fin B) (g x)) (compose-left (wiring A B f f✓) (wiring B C g g✓) I I⊨F)) (wires-≈ g (proj₂ (fin C) x) (compose-right (wiring A B f f✓) (wiring B C g g✓) I I⊨F))) I⊨RHS : bnodes I elim ⊨a impl (wiring A C h h✓) I⊨RHS = wires-≈⁻¹ h lemma (proj₁ (fin C)) RHS⊑LHS : wiring A C h h✓ ⊑ wiring A B f f✓ ∙ wiring B C g g✓ RHS⊑LHS I I⊨STA I⊨F = (i , I⊨LHS) where i : (False ⊕ IN B ⊕ False) → Δ ⌊ I ⌋ i (inode ()) i (bnode y) = ind I (inode (f y)) i (enode ()) lemma : ∀ x → ⌊ I ⌋ ⊨ ind I (inode (f (g x))) ≈ ind I (enode x) lemma x = ≈-trans ⌊ I ⌋ (≈-refl′ ⌊ I ⌋ (cong (ind I ∘ inode) (fg≡h x))) (wires-≈ h (proj₂ (fin C) x) I⊨F) I⊨LHS : bnodes I i ⊨a impl (wiring A B f f✓ ∙ wiring B C g g✓) I⊨LHS = compose-resp-⊨a (wiring A B f f✓) (wiring B C g g✓) (bnodes I i) (wires-≈⁻¹ f (λ x → ≈-refl ⌊ I ⌋) (proj₁ (fin B))) (wires-≈⁻¹ g lemma (proj₁ (fin C)))
{ "alphanum_fraction": 0.5801086219, "avg_line_length": 43.3235294118, "ext": "agda", "hexsha": "18486bc200479d8da5769c7bd1616519d0f1bd7d", "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/Properties/Composition/RespectsWiring.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/Properties/Composition/RespectsWiring.agda", "max_line_length": 79, "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/Properties/Composition/RespectsWiring.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": 1289, "size": 2946 }
---------------------------------------------------------------------- -- Copyright: 2013, Jan Stolarek, Lodz University of Technology -- -- -- -- License: See LICENSE file in root of the repo -- -- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps -- -- -- -- Basic implementation of weight-biased leftist heap. No proofs -- -- and no dependent types. Uses a single-pass merging algorithm. -- -- -- -- Now we will modify our implementation by turning a two-pass -- -- merging algorithm into a single-pass one. We will do this by -- -- inlining makeT into merge. See [Single-pass merging algorithm] -- -- for a detailed description of new algorithm. Since merge -- -- function will be the only thing that changes we will not repeat -- -- singleton, findMin and deleteMin functions - they are exactly -- -- same as they were in case of two-pass merging algorithm. All -- -- data declaration also remain the same. We will focus our -- -- attention only on merging. -- ---------------------------------------------------------------------- {-# OPTIONS --sized-types #-} module SinglePassMerge.NoProofs where open import Basics.Nat open import Basics hiding (_≥_) open import Sized data Heap : {i : Size} → Set where empty : {i : Size} → Heap {↑ i} node : {i : Size} → Priority → Rank → Heap {i} → Heap {i} → Heap {↑ i} -- Note [Single-pass merging algorithm] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- New single-pass merging algorithm is a straightfowrward derivation -- from two-pass merge. We obtain this new algorithm by inlining calls -- to makeT. This means that merge creates a new node instead of -- delegating this task to makeT. The consequence of this is that -- merge has two more cases now (a total of six). Base cases remain -- unchanged (we use the same notation as in [Two-pass merging -- algorithm]: -- -- a) h1 is empty - return h2 -- -- b) h2 is empty - return h1 -- -- There are two more cases in the inductive part of merge definition: -- -- c) priority p1 is higher than p2 AND rank of l1 is not smaller -- than rank of r1 + h2 - p1 becomes the root, l1 becomes the -- left child and result of merging r1 with h2 becomes the right -- child child. -- -- p1 -- / \ -- / \ -- l1 r1+h2 -- -- d) priority p1 is higher than p2 AND rank of r1 + h2 is not -- smaller than rank of l1 - p1 becomes the root, result of -- merging r1 with h2 becomes the left child and l1 becomes the -- right child child. -- -- p1 -- / \ -- / \ -- r1+h2 l1 -- -- e) priority p2 is higher than p1 AND rank of l2 is not smaller -- rank of r2 + h1 - p2 becomes the root, l2 becomes the left -- child and result of merging r2 with h1 becomes the right -- child child. -- -- p2 -- / \ -- / \ -- l2 r2+h1 -- -- f) priority p2 is higher than p1 AND rank of r2 + h1 is not -- smaller than rank of l2 - p2 becomes the root, result of -- merging r2 with h1 becomes the left child and l2 becomes the -- right child child. -- -- p2 -- / \ -- / \ -- r2+h1 l2 -- We still use a helper function to get rank of a node rank : Heap → Nat rank empty = zero rank (node _ r _ _) = r -- Note [Compacting merge] -- ~~~~~~~~~~~~~~~~~~~~~~~ -- -- To make implementation of merge slighty shorter we check which -- priority is higher and at the same time we compute relation between -- ranks of new possible subtrees (l1, r1 + h2 and l2, r2 + h1). -- Depending on result of comparing p1 with p2 we will only need to -- know one of this relations: -- -- 1) if priority p1 is higher than p2 then we need to know whether -- l1 ≥ r1 + h2 -- -- 2) if priority p2 is higher than p1 then we need to know whether -- l2 ≥ r2 + h1 -- -- Computing these relations at once allows us to reduce code -- verbosity at the price of doing some extra computations. In a -- practical application we would most likely prefer performance over -- code readibility, but I believe that for demonstration purposes it -- is better to have shorter code. merge : {i j : Size} → Heap {i} → Heap {j} → Heap merge empty h2 = h2 -- See [Single-pass merging algorithm] merge h1 empty = h1 merge (node p1 w1 l1 r1) (node p2 w2 l2 r2) with p1 < p2 -- See [Compacting merge] | rank l1 ≥ rank r1 + w2 | rank l2 ≥ rank r2 + w1 merge (node p1 w1 l1 r1) (node p2 w2 l2 r2) | true | true | _ = node p1 (w1 + w2) l1 (merge r1 (node p2 w2 l2 r2)) merge (node p1 w1 l1 r1) (node p2 w2 l2 r2) | true | false | _ = node p1 (w1 + w2) (merge r1 (node p2 w2 l2 r2)) l1 merge (node p1 w1 l1 r1) (node p2 w2 l2 r2) | false | _ | true = node p2 (w1 + w2) l2 (merge r2 (node p1 w1 l1 r1)) merge (node p1 w1 l1 r1) (node p2 w2 l2 r2) | false | _ | false = node p2 (w1 + w2) (merge r2 (node p1 w1 l1 r1)) l2
{ "alphanum_fraction": 0.5699168556, "avg_line_length": 40.7076923077, "ext": "agda", "hexsha": "f482da2f8c37208acf91080fec289c835eb1a6b5", "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": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_forks_repo_path": "src/SinglePassMerge/NoProofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "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": "jstolarek/dep-typed-wbl-heaps", "max_issues_repo_path": "src/SinglePassMerge/NoProofs.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_stars_repo_path": "src/SinglePassMerge/NoProofs.agda", "max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z", "num_tokens": 1433, "size": 5292 }
{-# OPTIONS --without-K --safe #-} module Definition.Typed.Consequences.NeTypeEq where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Injectivity open import Definition.Typed.Consequences.Substitution open import Tools.Product import Tools.PropositionalEquality as PE -- Helper function for the same variable instance of a context have equal types. varTypeEq′ : ∀ {n R T Γ} → n ∷ R ∈ Γ → n ∷ T ∈ Γ → R PE.≡ T varTypeEq′ here here = PE.refl varTypeEq′ (there n∷R) (there n∷T) rewrite varTypeEq′ n∷R n∷T = PE.refl -- The same variable instance of a context have equal types. varTypeEq : ∀ {x A B Γ} → Γ ⊢ A → Γ ⊢ B → x ∷ A ∈ Γ → x ∷ B ∈ Γ → Γ ⊢ A ≡ B varTypeEq A B x∷A x∷B rewrite varTypeEq′ x∷A x∷B = refl A -- The same neutral term have equal types. neTypeEq : ∀ {t A B Γ} → Neutral t → Γ ⊢ t ∷ A → Γ ⊢ t ∷ B → Γ ⊢ A ≡ B neTypeEq (var x) (var x₁ x₂) (var x₃ x₄) = varTypeEq (syntacticTerm (var x₃ x₂)) (syntacticTerm (var x₃ x₄)) x₂ x₄ neTypeEq (∘ₙ neT) (t∷A ∘ⱼ t∷A₁) (t∷B ∘ⱼ t∷B₁) with neTypeEq neT t∷A t∷B ... | q = let w = proj₂ (injectivity q) in substTypeEq w (refl t∷A₁) neTypeEq (natrecₙ neT) (natrecⱼ x t∷A t∷A₁ t∷A₂) (natrecⱼ x₁ t∷B t∷B₁ t∷B₂) = refl (substType x₁ t∷B₂) neTypeEq x (conv t∷A x₁) t∷B = let q = neTypeEq x t∷A t∷B in trans (sym x₁) q neTypeEq x t∷A (conv t∷B x₃) = let q = neTypeEq x t∷A t∷B in trans q x₃
{ "alphanum_fraction": 0.6434668418, "avg_line_length": 41.1621621622, "ext": "agda", "hexsha": "30526c6a3c2a469d2d990cffbdf8032961997fbb", "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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/NeTypeEq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "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/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/NeTypeEq.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/NeTypeEq.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 612, "size": 1523 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.Bouquet open import homotopy.DisjointlyPointedSet open import cohomology.Theory module cohomology.DisjointlyPointedSet {i} (OT : OrdinaryTheory i) where open OrdinaryTheory OT open import cohomology.Bouquet OT module _ (X : Ptd i) (X-is-set : is-set (de⊙ X)) (X-sep : is-separable X) (ac : has-choice 0 (de⊙ X) i) where C-set : C 0 X ≃ᴳ Πᴳ (MinusPoint X) (λ _ → C2 0) C-set = C-Bouquet-diag 0 (MinusPoint X) (MinusPoint-has-choice X-sep ac) ∘eᴳ C-emap 0 (Bouquet-⊙equiv-X X-sep) module _ {n : ℤ} (n≠0 : n ≠ 0) (X : Ptd i) (X-is-set : is-set (de⊙ X)) (X-sep : is-separable X) (ac : has-choice 0 (de⊙ X) i) where abstract C-set-≠-is-trivial : is-trivialᴳ (C n X) C-set-≠-is-trivial = iso-preserves'-trivial (C-emap n (Bouquet-⊙equiv-X X-sep)) (C-Bouquet-≠-is-trivial n (MinusPoint X) 0 n≠0 (MinusPoint-has-choice X-sep ac))
{ "alphanum_fraction": 0.6302349336, "avg_line_length": 32.6333333333, "ext": "agda", "hexsha": "af02bce1308d0c09c318e2de40088f5229d08cd5", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_line_length": 88, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/DisjointlyPointedSet.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": 390, "size": 979 }
module tests.Forcing3 where open import Prelude.Nat -- {- open import Prelude.IO open import Prelude.Product open import Prelude.Unit -- -} data _**_ (A B : Set) : Set where _,_ : A -> B -> A ** B data P {A B : Set} : A ** B -> Set where _,_ : (x : A)(y : B) -> P (x , y) data Q {A : Set} : A ** A -> Set where [_] : (x : A) -> Q (x , x) test : let t : Set t = (Nat ** Nat) ** Nat in (q : t ** t) -> Q q -> Nat test ._ [ ( Z , Z ) , Z ] = Z test ._ [ ( Z , S l) , m ] = S l + m test ._ [ ( S Z , Z) , m ] = S m test ._ [ ( S Z , S l) , m ] = S Z + m + l test ._ [ ( S (S n) , l) , m ] = S (S n) + m + l test ._ [ ( n , l ) , m ] = m -- {- main : IO Unit main = let tTyp : Set tTyp = (Nat ** Nat) ** Nat t0 : tTyp t0 = (0 , 0) , 0 t1 : tTyp t1 = ( 0 , 1 ) , 2 t2 : tTyp t2 = ( 1 , 0 ) , 3 t3 : tTyp t3 = ( 1 , 4 ) , 5 t4 : tTyp t4 = ( 3 , 2 ) , 10 t5 : tTyp t5 = ( 0 , 0 ) , 4 pn : tTyp -> IO Unit pn t = printNat (test (t , t) [ t ]) in pn t0 ,, -- 0 pn t1 ,, -- 3 pn t2 ,, -- 4 pn t3 ,, -- 9 pn t4 ,, -- 15 pn t5 ,, -- 4 return unit -- -}
{ "alphanum_fraction": 0.3470149254, "avg_line_length": 23.9285714286, "ext": "agda", "hexsha": "14d3caa7239066f21c5f4646e0fd4717e50e6ffb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "test/epic/tests/Forcing3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "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": "larrytheliquid/agda", "max_issues_repo_path": "test/epic/tests/Forcing3.agda", "max_line_length": 51, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/epic/tests/Forcing3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 534, "size": 1340 }
module Structure.Relator where import Lvl open import Functional using (_∘₂_) open import Functional.Dependent open import Lang.Instance open import Logic open import Logic.Propositional open import Structure.Setoid open import Structure.Relator.Names open import Structure.Relator.Properties open import Syntax.Function open import Type -- TODO: It seems possible to define UnaryRelator as a special case of Function, so let's do that private variable ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ ℓₗ₄ : Lvl.Level module Names where module _ {A : Type{ℓₒ}} ⦃ _ : Equiv{ℓₗ₁}(A) ⦄ (P : A → Stmt{ℓₗ₂}) where Substitution₁ = ∀{x y : A} → (x ≡ y) → P(x) → P(y) module _ {A : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₗ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₗ₂}(B) ⦄ (_▫_ : A → B → Stmt{ℓₗ₃}) where Substitution₂ = ∀{x₁ y₁ : A}{x₂ y₂ : B} → (x₁ ≡ y₁) → (x₂ ≡ y₂) → (x₁ ▫ x₂) → (y₁ ▫ y₂) module _ {A : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₗ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₗ₂}(B) ⦄ {C : Type{ℓₒ₃}} ⦃ _ : Equiv{ℓₗ₃}(C) ⦄ (_▫_▫_ : A → B → C → Stmt{ℓₗ₄}) where Substitution₃ = ∀{x₁ y₁ : A}{x₂ y₂ : B}{x₃ y₃ : C} → (x₁ ≡ y₁) → (x₂ ≡ y₂) → (x₃ ≡ y₃) → (x₁ ▫ x₂ ▫ x₃) → (y₁ ▫ y₂ ▫ y₃) -- The unary relator `P` "(behaves like)/is a relator" in the context of `_≡_` from the Equiv instance. module _ {A : Type{ℓₒ}} ⦃ _ : Equiv{ℓₗ₁}(A) ⦄ (P : A → Stmt{ℓₗ₂}) where record UnaryRelator : Stmt{ℓₒ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where constructor intro field substitution : Names.Substitution₁(P) substitution-sym : ∀{x y : A} → (x ≡ y) → P(x) ← P(y) substitution-sym = substitution ∘ Structure.Relator.Properties.symmetry(_≡_) substitution-equivalence : ∀{x y : A} → (x ≡ y) → (P(x) ↔ P(y)) substitution-equivalence xy = [↔]-intro (substitution-sym xy) (substitution xy) substitute₁ₗ = inst-fn UnaryRelator.substitution-sym substitute₁ᵣ = inst-fn UnaryRelator.substitution substitute₁ₗᵣ = inst-fn UnaryRelator.substitution-equivalence substitute₁ = substitute₁ᵣ unaryRelator = resolve UnaryRelator -- The binary relator `_▫_` "(behaves like)/is a relator" in the context of `_≡_` from the Equiv instance. module _ {A : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₗ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₗ₂}(B) ⦄ (_▫_ : A → B → Stmt{ℓₗ₃}) where open Structure.Relator.Properties record BinaryRelator : Stmt{ℓₒ₁ Lvl.⊔ ℓₒ₂ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃} where constructor intro field substitution : Names.Substitution₂(_▫_) left : ∀{x} → UnaryRelator(_▫ x) left = intro(\p → substitution p (reflexivity(_≡_))) right : ∀{x} → UnaryRelator(x ▫_) right = intro(\p → substitution (reflexivity(_≡_)) p) substitutionₗ = \{a x y} → UnaryRelator.substitution(left {a}) {x}{y} substitutionᵣ = \{a x y} → UnaryRelator.substitution(right{a}) {x}{y} substitution-sym : ∀{x₁ y₁ : A}{x₂ y₂ : B} → (x₁ ≡ y₁) → (x₂ ≡ y₂) → ((x₁ ▫ x₂) ← (y₁ ▫ y₂)) substitution-sym xy1 xy2 = substitution (Structure.Relator.Properties.symmetry(_≡_) xy1) (Structure.Relator.Properties.symmetry(_≡_) xy2) substitution-equivalence : ∀{x₁ y₁ : A}{x₂ y₂ : B} → (x₁ ≡ y₁) → (x₂ ≡ y₂) → ((x₁ ▫ x₂) ↔ (y₁ ▫ y₂)) substitution-equivalence xy1 xy2 = [↔]-intro (substitution-sym xy1 xy2) (substitution xy1 xy2) substitute₂ = inst-fn BinaryRelator.substitution substitute₂ₗ = inst-fn BinaryRelator.substitutionₗ substitute₂ᵣ = inst-fn BinaryRelator.substitutionᵣ substitute₂ₗᵣ = inst-fn BinaryRelator.substitution-equivalence binaryRelator = resolve BinaryRelator module _ {A : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₗ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₗ₂}(B) ⦄ {C : Type{ℓₒ₃}} ⦃ _ : Equiv{ℓₗ₃}(C) ⦄ (_▫_▫_ : A → B → C → Stmt{ℓₗ₄}) where open Structure.Relator.Properties record TrinaryRelator : Stmt{ℓₒ₁ Lvl.⊔ ℓₒ₂ Lvl.⊔ ℓₒ₃ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂ Lvl.⊔ ℓₗ₃ Lvl.⊔ ℓₗ₄} where constructor intro field substitution : Names.Substitution₃(_▫_▫_) unary₁ : ∀{y z} → UnaryRelator(_▫ y ▫ z) unary₁ = intro(\p → substitution p (reflexivity(_≡_)) (reflexivity(_≡_))) unary₂ : ∀{x z} → UnaryRelator(x ▫_▫ z) unary₂ = intro(\p → substitution (reflexivity(_≡_)) p (reflexivity(_≡_))) unary₃ : ∀{x y} → UnaryRelator(x ▫ y ▫_) unary₃ = intro(\p → substitution (reflexivity(_≡_)) (reflexivity(_≡_)) p) binary₁₂ : ∀{z} → BinaryRelator(_▫_▫ z) binary₁₂ = intro(\p q → substitution p q (reflexivity(_≡_))) binary₁₃ : ∀{y} → BinaryRelator(_▫ y ▫_) binary₁₃ = intro(\p q → substitution p (reflexivity(_≡_)) q) binary₂₃ : ∀{x} → BinaryRelator(x ▫_▫_) binary₂₃ = intro(\p q → substitution (reflexivity(_≡_)) p q) substitution-unary₁ = \{a b x y} → UnaryRelator.substitution(unary₁ {a}{b}) {x}{y} substitution-unary₂ = \{a b x y} → UnaryRelator.substitution(unary₂ {a}{b}) {x}{y} substitution-unary₃ = \{a b x y} → UnaryRelator.substitution(unary₃ {a}{b}) {x}{y} substitution-binary₁₂ = \{a x₁ x₂ y₁ y₂} → BinaryRelator.substitution(binary₁₂ {a}) {x₁}{x₂}{y₁}{y₂} substitution-binary₁₃ = \{a x₁ x₂ y₁ y₂} → BinaryRelator.substitution(binary₁₃ {a}) {x₁}{x₂}{y₁}{y₂} substitution-binary₂₃ = \{a x₁ x₂ y₁ y₂} → BinaryRelator.substitution(binary₂₃ {a}) {x₁}{x₂}{y₁}{y₂} substitute₃ = inst-fn TrinaryRelator.substitution substitute₃-unary₁ = inst-fn TrinaryRelator.substitution-unary₁ substitute₃-unary₂ = inst-fn TrinaryRelator.substitution-unary₂ substitute₃-unary₃ = inst-fn TrinaryRelator.substitution-unary₃ substitute₃-binary₁₂ = inst-fn TrinaryRelator.substitution-binary₁₂ substitute₃-binary₁₃ = inst-fn TrinaryRelator.substitution-binary₁₃ substitute₃-binary₂₃ = inst-fn TrinaryRelator.substitution-binary₂₃ trinaryRelator = resolve TrinaryRelator
{ "alphanum_fraction": 0.6631616468, "avg_line_length": 55.0098039216, "ext": "agda", "hexsha": "fb0651903caa0db4f8c81582593324d595354821", "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/Relator.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/Relator.agda", "max_line_length": 162, "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/Relator.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": 2368, "size": 5611 }
module IID-Proof-Test where open import LF open import Identity open import IID open import IIDr open import DefinitionalEquality open import IID-Proof-Setup η : {I : Set}(γ : OPg I)(U : I -> Set) -> Args γ U -> Args γ U η (ι i) U _ = ★ η (σ A γ) U a = < a₀ | η (γ a₀) U a₁ > where a₀ = π₀ a a₁ = π₁ a η (δ A i γ) U a = < a₀ | η γ U a₁ > where a₀ = π₀ a a₁ = π₁ a r←→gArgs-equal : {I : Set}(γ : OPg I)(U : I -> Set) (i : I)(a : Args (ε γ i) U) -> _==_ {I × \i -> Args (ε γ i) U} < index γ U (r→gArgs γ U i a) | g→rArgs γ U (r→gArgs γ U i a) > < i | a > r←→gArgs-equal {I} (ι i) U j < p | ★ > = elim== i (\k q -> _==_ {I × \k -> Args (ε (ι i) k) U} < i | < refl | ★ > > < k | < q | ★ > > ) refl j p r←→gArgs-equal {I} (σ A γ) U j < a | b > = cong f ih where ih = r←→gArgs-equal (γ a) U j b f : (I × \i -> Args (ε (γ a) i) U) -> (I × \i -> Args (ε (σ A γ) i) U) f < k | q > = < k | < a | q > > r←→gArgs-equal {I} (δ H i γ) U j < g | b > = cong f ih where ih = r←→gArgs-equal γ U j b f : (I × \k -> Args (ε γ k) U) -> (I × \k -> Args (ε (δ H i γ) k) U) f < k | q > = < k | < g | q > > {- r←→gArgs-subst-identity' : {I : Set}(γ : OPg I) -> (\(U : I -> Set)(C : (i : I) -> rArgs (ε γ) U i -> Set) (a : Args γ U)(h : C (index γ U (r→gArgs γ U (index γ U (η γ U a)) (g→rArgs γ U (η γ U a)))) (g→rArgs γ U (r→gArgs γ U (index γ U (η γ U a)) (g→rArgs γ U (η γ U a)))) ) -> r←→gArgs-subst γ U C (index γ U (η γ U a)) (g→rArgs γ U (η γ U a)) h ) ==¹ (\(U : I -> Set)(C : (i : I) -> rArgs (ε γ) U i -> Set) (a : Args γ U)(h : C (index γ U (r→gArgs γ U (index γ U (η γ U a)) (g→rArgs γ U (η γ U a)))) (g→rArgs γ U (r→gArgs γ U (index γ U (η γ U a)) (g→rArgs γ U (η γ U a)))) ) -> h ) r←→gArgs-subst-identity' (ι i) = refl¹ r←→gArgs-subst-identity' (σ A γ) = ? r←→gArgs-subst-identity' (δ A i γ) = subst¹ (\ ∙ -> f ∙ ==¹ f (\U C a h -> h)) (r←→gArgs-subst-identity' γ) ? where ih = r←→gArgs-subst-identity' γ f = \g U C a h -> g U (\i c -> C i < π₀ a | c >) (π₁ a) h -}
{ "alphanum_fraction": 0.4525512637, "avg_line_length": 32.765625, "ext": "agda", "hexsha": "2a5d335fdfc032160cc30defcf967f90c352fb38", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/iird/IID-Proof-Test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "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": "larrytheliquid/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/iird/IID-Proof-Test.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/iird/IID-Proof-Test.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 984, "size": 2097 }
module Nat where data Nat : Set where zero : Nat suc : Nat -> Nat
{ "alphanum_fraction": 0.6081081081, "avg_line_length": 9.25, "ext": "agda", "hexsha": "c1b27f0a4c3f2c9f21fc17bea7cd6b300675f44d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Nat.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/Nat.agda", "max_line_length": 20, "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/Nat.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": 24, "size": 74 }
{-# OPTIONS --allow-unsolved-metas #-} module StateSizedIO.GUI.BaseStateDependent where open import Size renaming (Size to AgdaSize) open import NativeIO open import Function open import Agda.Primitive open import Level using (_⊔_) renaming (suc to lsuc) open import Data.Product open import Relation.Binary.PropositionalEquality record IOInterfaceˢ {γ ρ μ} : Set (lsuc (γ ⊔ ρ ⊔ μ )) where field Stateˢ : Set γ Commandˢ : Stateˢ → Set ρ Responseˢ : (s : Stateˢ) → Commandˢ s → Set μ nextˢ : (s : Stateˢ) → (c : Commandˢ s) → Responseˢ s c → Stateˢ open IOInterfaceˢ public module _ {γ ρ μ}(i : IOInterfaceˢ {γ} {ρ} {μ} ) (let S = Stateˢ i) (let C = Commandˢ i) (let R = Responseˢ i) (let next = nextˢ i) where mutual record IOˢ {α} (i : AgdaSize) (A : S → Set α) (s : S) : Set (lsuc (α ⊔ γ ⊔ ρ ⊔ μ )) where coinductive constructor delay field forceˢ : {j : Size< i} → IOˢ' j A s data IOˢ' {α} (i : AgdaSize) (A : S → Set α) : S → Set (lsuc (α ⊔ γ ⊔ ρ ⊔ μ )) where doˢ' : {s : S} → (c : C s) → (f : (r : R s c) → IOˢ i A (next s c r) ) → IOˢ' i A s returnˢ' : {s : S} → (a : A s) → IOˢ' i A s data IOˢ+ {α} (i : AgdaSize) (A : S → Set α ) : S → Set (lsuc (α ⊔ γ ⊔ ρ ⊔ μ )) where doˢ' : {s : S} → (c : C s) (f : (r : R s c) → IOˢ i A (next s c r)) → IOˢ+ i A s IOₚˢ : ∀{α}(i : AgdaSize)(A : Set α)(t t' : S) → Set (lsuc (α ⊔ γ ⊔ ρ ⊔ μ )) IOₚˢ i A t t' = IOˢ i (λ s → s ≡ t' × A) t IOₚˢ' : ∀{α}(i : AgdaSize)(A : Set α)(t t' : S) → Set (lsuc (α ⊔ γ ⊔ ρ ⊔ μ )) IOₚˢ' i A t t' = IOˢ' i (λ s → s ≡ t' × A) t IOₚsemiˢ : ∀{i}{α}{β}{A : Set α }{B : S → Set β}{t : S} (t' : A → S) → Set (lsuc α ⊔ (lsuc μ ⊔ (lsuc ρ ⊔ lsuc γ))) IOₚsemiˢ{i}{α}{β}{A}{B}{t} t' = IOˢ i (λ s → Σ[ a ∈ A ] (s ≡ t' a)) t {- Add also this later: IO A t t' where t' : A -> S Programs which start in t end with an a : A and a state t' a IO A t t' = IO (lambda s.Sigma a : A. s = t' a) t >== : (p : IO A t t') (f : (a : A) -> IO B (t' a) ) -> IO B a -} open IOˢ public module _ {α γ ρ μ}{I : IOInterfaceˢ {γ} {ρ} {μ}} (let S = Stateˢ I) (let C = Commandˢ I) (let R = Responseˢ I) (let next = nextˢ I) where returnˢ : ∀{i}{A : S → Set α} {s : S} (a : A s) → IOˢ I i A s forceˢ (returnˢ a) = returnˢ' a doˢ : ∀{i}{A : S → Set α}{s : S} (c : C s) (f : (r : R s c) → IOˢ I i A (next s c r)) → IOˢ I i A s forceˢ (doˢ c f) = doˢ' c f module _ {α β γ ρ μ}{I : IOInterfaceˢ {γ} {ρ} {μ}} (let S = Stateˢ I) (let C = Commandˢ I) (let R = Responseˢ I) (let next = nextˢ I) where mutual -- TODO: check that next state is honored fmapˢ : ∀ {i} → {A : S → Set α}{B : S → Set β} (f : (s : S)(a : A s) → B s) {s : S} (p : (IOˢ I i A s)) → IOˢ I i B s fmapˢ f {s} p .forceˢ = fmapˢ' f {s} (p .forceˢ) fmapˢ' : ∀ {i} → {A : S → Set α}{B : S → Set β} (f : (s : S)(a : A s) → B s) {s : S} (p : (IOˢ' I i A s)) → IOˢ' I i B s fmapˢ' f {s} (doˢ' c g) = doˢ' c (λ r → fmapˢ f (g r)) fmapˢ' f {s} (returnˢ' a) = returnˢ' (f s a) module _ {α γ ρ μ}{I : IOInterfaceˢ {γ} {ρ} {μ}} (let S = Stateˢ I) (let C = Commandˢ I) (let R = Responseˢ I) (let next = nextˢ I) where delayˢ : ∀ {i}{A : S → Set α}{s : S} → IOˢ' I i A s → IOˢ I (↑ i) A s delayˢ p .forceˢ = p module _ {γ ρ μ}{I : IOInterfaceˢ {γ} {ρ} {μ}} (let S = Stateˢ I) (let C = Commandˢ I) (let R = Responseˢ I) (let next = nextˢ I) where mutual _>>=ˢ'_ : ∀{i α β}{A : S → Set α}{B : S → Set β}{t : S} (m : IOˢ' I i A t) (f : (s : S)(a : A s) → IOˢ I (↑ i) B s) → IOˢ' I i B t doˢ' c f >>=ˢ' k = doˢ' c λ x → f x >>=ˢ k _>>=ˢ'_ {_} {_} {_} {_} {_} {t} (returnˢ' a) f = f t a .forceˢ _>>=ˢ_ : ∀{i α β}{A : S → Set α}{B : S → Set β}{t : S} (m : IOˢ I i A t) (k : (s : S)(a : A s) → IOˢ I i B s) → IOˢ I i B t forceˢ (m >>=ˢ k) = (forceˢ m) >>=ˢ' k _>>=ₚˢ'_ : ∀{i}{α}{β}{A : Set α }{B : S → Set β}{t t' : S} (p : IOˢ' I i (λ s → s ≡ t' × A) t) (f : (a : A) → IOˢ I (↑ i) B t') → IOˢ' {γ} {ρ} {μ} I i B t _>>=ₚˢ'_ {i} {α} {β} p f = p >>=ˢ' (λ s → λ {(refl , a) → f a}) _>>=ₚˢ_ : ∀{i}{α}{β}{A : Set α }{B : S → Set β}{t t' : S} (p : IOˢ I i (λ s → s ≡ t' × A) t) (f : (a : A) → IOˢ I (↑ i) B t') → IOˢ I i B t _>>=ₚˢ_ {i} {α} {β} p f = p >>=ˢ (λ s → λ {(refl , a) → f a}) _>>=ₚsemiˢ_ : ∀{i}{α}{β}{A : Set α }{B : S → Set β}{t : S} {t' : A → S} -- IOs starts in t, returns a, and ends in a state t' a: (p : IOˢ I i (λ s → Σ[ a ∈ A ] (s ≡ t' a)) t) (f : (a : A) → IOˢ I (↑ i) B (t' a)) → IOˢ I i B t _>>=ₚsemiˢ_ {i} {α} {β}{A}{B}{t}{t'} p f = p >>=ˢ f' module aux where f' : (s : Stateˢ I) → Σ[ a ∈ A ] (s ≡ t' a) → IOˢ I i B s f' .(t' a) (a , refl) = f a module _ {γ ρ}{I : IOInterfaceˢ {γ} {ρ} {lzero}} (let S = Stateˢ I) (let C = Commandˢ I) (let R = Responseˢ I) (let next = nextˢ I) where {-# NON_TERMINATING #-} translateIOˢ : ∀{A : Set }{s : S} → (translateLocal : (s : S) → (c : C s) → NativeIO (R s c)) → IOˢ I ∞ (λ s → A) s → NativeIO A translateIOˢ {A} {s} translateLocal p = case (forceˢ p {_}) of λ{ (doˢ' {.s} c f) → (translateLocal s c) native>>= λ r → translateIOˢ translateLocal (f r) ; (returnˢ' a) → nativeReturn a }
{ "alphanum_fraction": 0.4127868852, "avg_line_length": 35.0574712644, "ext": "agda", "hexsha": "c41131f3e8508e06ad460f1a67c9cdc78be05eed", "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": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "src/StateSizedIO/GUI/BaseStateDependent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "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": "stephanadls/state-dependent-gui", "max_issues_repo_path": "src/StateSizedIO/GUI/BaseStateDependent.agda", "max_line_length": 96, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "src/StateSizedIO/GUI/BaseStateDependent.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 2657, "size": 6100 }
{-# OPTIONS --cubical --safe #-} module Control.Monad.Levels.Definition where open import Prelude open import Data.Bag data Levels (A : Type a) : Type a where _∷_ : ⟅ A ⟆ → Levels A → Levels A [] : Levels A trail : [] ∷ [] ≡ [] trunc : isSet (Levels A)
{ "alphanum_fraction": 0.6127819549, "avg_line_length": 19, "ext": "agda", "hexsha": "2d7aa2b9aa6ce0e1d2775a44f746c0ee511a803a", "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": "Control/Monad/Levels/Definition.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": "Control/Monad/Levels/Definition.agda", "max_line_length": 44, "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": "Control/Monad/Levels/Definition.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": 85, "size": 266 }
module Issue474 where open import Common.Level postulate a b c : Level A : Set a B : Set b C : Set c data Foo : Set (lsuc lzero ⊔ (a ⊔ (b ⊔ c))) where foo : (Set → A → B) → Foo
{ "alphanum_fraction": 0.5759162304, "avg_line_length": 13.6428571429, "ext": "agda", "hexsha": "ee3ee60e39aed5cc7dea7ae0e9fef6cfd3b97691", "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/Issue474.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/Issue474.agda", "max_line_length": 49, "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/Issue474.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": 75, "size": 191 }
{-# OPTIONS --without-K --safe #-} -- A cartesian functor preserves products (of cartesian categories) module Categories.Functor.Cartesian where open import Level open import Categories.Category.Cartesian.Structure open import Categories.Functor using (Functor; _∘F_) open import Categories.Functor.Properties import Categories.Object.Product as P import Categories.Object.Terminal as ⊤ import Categories.Morphism as M import Categories.Morphism.Reasoning as MR private variable o ℓ e o′ ℓ′ e′ : Level record IsCartesianF (C : CartesianCategory o ℓ e) (D : CartesianCategory o′ ℓ′ e′) (F : Functor (CartesianCategory.U C) (CartesianCategory.U D)) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where private module C = CartesianCategory C module D = CartesianCategory D open P D.U open ⊤ D.U open M D.U open Functor F field F-resp-⊤ : IsTerminal (F₀ C.⊤) F-resp-× : ∀ {A B} → IsProduct {P = F₀ (A C.× B)} (F₁ C.π₁) (F₁ C.π₂) module F-resp-⊤ = IsTerminal F-resp-⊤ module F-resp-× {A B} = IsProduct (F-resp-× {A} {B}) F-prod : ∀ A B → Product (F₀ A) (F₀ B) F-prod _ _ = IsProduct⇒Product F-resp-× module F-prod A B = Product (F-prod A B) F-resp-⟨⟩ : ∀ {A B X} → (f : X C.⇒ A) (g : X C.⇒ B) → D.⟨ F₁ C.π₁ , F₁ C.π₂ ⟩ D.∘ F₁ C.⟨ f , g ⟩ D.≈ D.⟨ F₁ f , F₁ g ⟩ F-resp-⟨⟩ f g = begin D.⟨ F₁ C.π₁ , F₁ C.π₂ ⟩ D.∘ F₁ C.⟨ f , g ⟩ ≈⟨ D.⟨⟩∘ ⟩ D.⟨ F₁ C.π₁ D.∘ F₁ C.⟨ f , g ⟩ , F₁ C.π₂ D.∘ F₁ C.⟨ f , g ⟩ ⟩ ≈⟨ D.⟨⟩-cong₂ ([ F ]-resp-∘ C.project₁) ([ F ]-resp-∘ C.project₂) ⟩ D.⟨ F₁ f , F₁ g ⟩ ∎ where open D.HomReasoning ⊤-iso : F₀ C.⊤ ≅ D.⊤ ⊤-iso = ⊤.up-to-iso D.U (record { ⊤-is-terminal = F-resp-⊤ }) D.terminal module ⊤-iso = _≅_ ⊤-iso ×-iso : ∀ A B → F₀ (A C.× B) ≅ F₀ A D.× F₀ B ×-iso A B = record { from = D.⟨ F₁ C.π₁ , F₁ C.π₂ ⟩ ; to = F-resp-×.⟨ D.π₁ , D.π₂ ⟩ ; iso = record { isoˡ = begin F-resp-×.⟨ D.π₁ , D.π₂ ⟩ D.∘ D.⟨ F₁ C.π₁ , F₁ C.π₂ ⟩ ≈⟨ [ F-prod A B ]⟨⟩∘ ⟩ F-resp-×.⟨ D.π₁ D.∘ _ , D.π₂ D.∘ _ ⟩ ≈⟨ F-prod.⟨⟩-cong₂ A B D.project₁ D.project₂ ⟩ F-resp-×.⟨ F₁ C.π₁ , F₁ C.π₂ ⟩ ≈⟨ F-prod.η A B ⟩ D.id ∎ ; isoʳ = begin D.⟨ F₁ C.π₁ , F₁ C.π₂ ⟩ D.∘ F-resp-×.⟨ D.π₁ , D.π₂ ⟩ ≈⟨ D.⟨⟩∘ ⟩ D.⟨ F₁ C.π₁ D.∘ _ , F₁ C.π₂ D.∘ _ ⟩ ≈⟨ D.⟨⟩-cong₂ (F-prod.project₁ A B) (F-prod.project₂ A B) ⟩ D.⟨ D.π₁ , D.π₂ ⟩ ≈⟨ D.η ⟩ D.id ∎ } } where open D.HomReasoning module ×-iso A B = _≅_ (×-iso A B) F-resp-⟨⟩′ : ∀ {A B X} → (f : X C.⇒ A) (g : X C.⇒ B) → F₁ C.⟨ f , g ⟩ D.≈ F-resp-×.⟨ F₁ f , F₁ g ⟩ F-resp-⟨⟩′ f g = begin F₁ C.⟨ f , g ⟩ ≈⟨ switch-fromtoˡ (×-iso _ _) (F-resp-⟨⟩ f g) ⟩ ×-iso.to _ _ D.∘ D.⟨ F₁ f , F₁ g ⟩ ≈⟨ ([ F-prod _ _ ]⟨⟩∘ ○ F-prod.⟨⟩-cong₂ _ _ D.project₁ D.project₂) ⟩ F-resp-×.⟨ F₁ f , F₁ g ⟩ ∎ where open MR D.U open D.HomReasoning record CartesianF (C : CartesianCategory o ℓ e) (D : CartesianCategory o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where private module C = CartesianCategory C module D = CartesianCategory D field F : Functor C.U D.U isCartesian : IsCartesianF C D F open Functor F public open IsCartesianF isCartesian public
{ "alphanum_fraction": 0.4951093211, "avg_line_length": 36.5894736842, "ext": "agda", "hexsha": "6ffcf6a08c2336ec3bae291649fa4d97fec6d94d", "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": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Cartesian.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "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": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Cartesian.agda", "max_line_length": 133, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Cartesian.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": 1555, "size": 3476 }
module Text.Greek.Bible where open import Data.Nat open import Data.List open import Data.String open import Text.Greek.Script data Word : Set where word : (List Token) → String → Word
{ "alphanum_fraction": 0.7619047619, "avg_line_length": 18.9, "ext": "agda", "hexsha": "0bd01c9eea94a2fa87cc7db884a1d2eba3349bcd", "lang": "Agda", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z", "max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "scott-fleischman/GreekGrammar", "max_forks_repo_path": "agda/Text/Greek/Bible.agda", "max_issues_count": 13, "max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "scott-fleischman/GreekGrammar", "max_issues_repo_path": "agda/Text/Greek/Bible.agda", "max_line_length": 37, "max_stars_count": 44, "max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "scott-fleischman/GreekGrammar", "max_stars_repo_path": "agda/Text/Greek/Bible.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z", "num_tokens": 49, "size": 189 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Setoids.Setoids open import Groups.Definition open import Groups.Lemmas open import Groups.Homomorphisms.Definition open import Groups.QuotientGroup.Definition open import Groups.Homomorphisms.Lemmas open import Groups.Actions.Definition open import Sets.EquivalenceRelations module Groups.SymmetricGroups.Lemmas where trivialAction : {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_·_ : A → A → A} {B : Set n} (G : Group S _·_) (X : Setoid {n} {p} B) → GroupAction G X trivialAction G X = record { action = λ _ x → x ; actionWellDefined1 = λ _ → reflexive ; actionWellDefined2 = λ wd1 → wd1 ; identityAction = reflexive ; associativeAction = reflexive } where open Setoid X renaming (eq to setoidEq) open Equivalence (Setoid.eq X) leftRegularAction : {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_·_ : A → A → A} (G : Group S _·_) → GroupAction G S GroupAction.action (leftRegularAction {_·_ = _·_} G) g h = g · h where open Group G GroupAction.actionWellDefined1 (leftRegularAction {S = S} G) eq1 = +WellDefined eq1 reflexive where open Group G open Setoid S renaming (eq to setoidEq) open Equivalence setoidEq GroupAction.actionWellDefined2 (leftRegularAction {S = S} G) {g} {x} {y} eq1 = +WellDefined reflexive eq1 where open Group G open Setoid S open Equivalence eq GroupAction.identityAction (leftRegularAction G) = identLeft where open Group G GroupAction.associativeAction (leftRegularAction {S = S} G) = symmetric +Associative where open Group G open Setoid S open Equivalence eq conjugationAction : {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_·_ : A → A → A} → (G : Group S _·_) → GroupAction G S conjugationAction {S = S} {_·_ = _·_} G = record { action = λ g h → (g · h) · (inverse g) ; actionWellDefined1 = λ gh → +WellDefined (+WellDefined gh reflexive) (inverseWellDefined G gh) ; actionWellDefined2 = λ x~y → +WellDefined (+WellDefined reflexive x~y) reflexive ; identityAction = transitive (+WellDefined reflexive (invIdent G)) (transitive identRight identLeft) ; associativeAction = λ {x} {g} {h} → transitive (+WellDefined reflexive (invContravariant G)) (transitive +Associative (+WellDefined (transitive (symmetric +Associative) (transitive (symmetric (+Associative)) (+WellDefined reflexive +Associative))) reflexive)) } where open Group G open Setoid S open Equivalence eq conjugationNormalSubgroupAction : {m n o p : _} {A : Set m} {B : Set o} {S : Setoid {m} {n} A} {T : Setoid {o} {p} B} {_·A_ : A → A → A} {_·B_ : B → B → B} → (G : Group S _·A_) → (H : Group T _·B_) → {underF : A → B} (f : GroupHom G H underF) → GroupAction G (quotientGroupSetoid G f) GroupAction.action (conjugationNormalSubgroupAction {_·A_ = _·A_} G H {f} fHom) a b = a ·A (b ·A (Group.inverse G a)) GroupAction.actionWellDefined1 (conjugationNormalSubgroupAction {S = S} {T = T} {_·A_ = _·A_} G H {f} fHom) {g} {h} {x} g~h = ans where open Group G open Setoid T open Equivalence eq ans : f ((g ·A (x ·A (inverse g))) ·A inverse (h ·A (x ·A inverse h))) ∼ Group.0G H ans = transitive (GroupHom.wellDefined fHom (transferToRight'' G (Group.+WellDefined G g~h (Group.+WellDefined G (Equivalence.reflexive (Setoid.eq S)) (inverseWellDefined G g~h))))) (imageOfIdentityIsIdentity fHom) GroupAction.actionWellDefined2 (conjugationNormalSubgroupAction {S = S} {T = T} {_·A_ = _·A_} {_·B_ = _·B_} G H {f} fHom) {g} {x} {y} x~y = ans where open Group G open Setoid T open Equivalence (Setoid.eq S) open Equivalence (Setoid.eq T) renaming (transitive to transitiveH ; symmetric to symmetricH ; reflexive to reflexiveH) input : f (x ·A inverse y) ∼ Group.0G H input = x~y p1 : Setoid._∼_ S ((g ·A (x ·A inverse g)) ·A inverse (g ·A (y ·A inverse g))) ((g ·A (x ·A inverse g)) ·A (inverse (y ·A (inverse g)) ·A inverse g)) p1 = Group.+WellDefined G reflexive (invContravariant G) p2 : Setoid._∼_ S ((g ·A (x ·A inverse g)) ·A (inverse (y ·A (inverse g)) ·A inverse g)) ((g ·A (x ·A inverse g)) ·A ((inverse (inverse g) ·A inverse y) ·A inverse g)) p2 = Group.+WellDefined G reflexive (Group.+WellDefined G (invContravariant G) reflexive) p3 : Setoid._∼_ S ((g ·A (x ·A inverse g)) ·A ((inverse (inverse g) ·A inverse y) ·A inverse g)) (g ·A (((x ·A inverse g) ·A (inverse (inverse g) ·A inverse y)) ·A inverse g)) p3 = symmetric (transitive (+WellDefined reflexive (symmetric +Associative)) +Associative) p4 : Setoid._∼_ S (g ·A (((x ·A inverse g) ·A (inverse (inverse g) ·A inverse y)) ·A inverse g)) (g ·A ((x ·A ((inverse g ·A inverse (inverse g)) ·A inverse y)) ·A inverse g)) p4 = Group.+WellDefined G reflexive (Group.+WellDefined G (symmetric (transitive (+WellDefined reflexive (symmetric +Associative)) +Associative)) reflexive) p5 : Setoid._∼_ S (g ·A ((x ·A ((inverse g ·A inverse (inverse g)) ·A inverse y)) ·A inverse g)) (g ·A ((x ·A (0G ·A inverse y)) ·A inverse g)) p5 = Group.+WellDefined G reflexive (Group.+WellDefined G (Group.+WellDefined G reflexive (Group.+WellDefined G invRight reflexive)) reflexive) p6 : Setoid._∼_ S (g ·A ((x ·A (0G ·A inverse y)) ·A inverse g)) (g ·A ((x ·A inverse y) ·A inverse g)) p6 = Group.+WellDefined G reflexive (Group.+WellDefined G (Group.+WellDefined G reflexive identLeft) reflexive) intermediate : Setoid._∼_ S ((g ·A (x ·A inverse g)) ·A inverse (g ·A (y ·A inverse g))) (g ·A ((x ·A inverse y) ·A inverse g)) intermediate = transitive p1 (transitive p2 (transitive p3 (transitive p4 (transitive p5 p6)))) p7 : f ((g ·A (x ·A inverse g)) ·A inverse (g ·A (y ·A inverse g))) ∼ f (g ·A ((x ·A inverse y) ·A inverse g)) p7 = GroupHom.wellDefined fHom intermediate p8 : f (g ·A ((x ·A inverse y) ·A inverse g)) ∼ (f g) ·B (f ((x ·A inverse y) ·A inverse g)) p8 = GroupHom.groupHom fHom p9 : (f g) ·B (f ((x ·A inverse y) ·A inverse g)) ∼ (f g) ·B (f (x ·A inverse y) ·B f (inverse g)) p9 = Group.+WellDefined H reflexiveH (GroupHom.groupHom fHom) p10 : (f g) ·B (f (x ·A inverse y) ·B f (inverse g)) ∼ (f g) ·B (Group.0G H ·B f (inverse g)) p10 = Group.+WellDefined H reflexiveH (Group.+WellDefined H input reflexiveH) p11 : (f g) ·B (Group.0G H ·B f (inverse g)) ∼ (f g) ·B (f (inverse g)) p11 = Group.+WellDefined H reflexiveH (Group.identLeft H) p12 : (f g) ·B (f (inverse g)) ∼ f (g ·A (inverse g)) p12 = symmetricH (GroupHom.groupHom fHom) intermediate2 : f ((g ·A (x ·A inverse g)) ·A inverse (g ·A (y ·A inverse g))) ∼ (f (g ·A (inverse g))) intermediate2 = transitiveH p7 (transitiveH p8 (transitiveH p9 (transitiveH p10 (transitiveH p11 p12)))) ans : f ((g ·A (x ·A inverse g)) ·A inverse (g ·A (y ·A inverse g))) ∼ Group.0G H ans = transitiveH intermediate2 (transitiveH (GroupHom.wellDefined fHom invRight) (imageOfIdentityIsIdentity fHom)) GroupAction.identityAction (conjugationNormalSubgroupAction {S = S} {T = T} {_·A_ = _·A_} G H {f} fHom) {x} = ans where open Group G open Setoid S open Setoid T renaming (_∼_ to _∼T_) open Equivalence (Setoid.eq T) i : Setoid._∼_ S (x ·A inverse 0G) x i = Equivalence.transitive (Setoid.eq S) (+WellDefined (Equivalence.reflexive (Setoid.eq S)) (invIdent G)) identRight h : 0G ·A (x ·A inverse 0G) ∼ x h = Equivalence.transitive (Setoid.eq S) identLeft i g : ((0G ·A (x ·A inverse 0G)) ·A inverse x) ∼ 0G g = transferToRight'' G h ans : f ((0G ·A (x ·A inverse 0G)) ·A Group.inverse G x) ∼T Group.0G H ans = transitive (GroupHom.wellDefined fHom g) (imageOfIdentityIsIdentity fHom) GroupAction.associativeAction (conjugationNormalSubgroupAction {S = S} {T = T} {_·A_ = _·A_} G H {f} fHom) {x} {g} {h} = ans where open Group G open Setoid T renaming (_∼_ to _∼T_) open Setoid S renaming (_∼_ to _∼S_) open Equivalence (Setoid.eq T) renaming (transitive to transitiveH) open Equivalence (Setoid.eq S) renaming (transitive to transitiveG ; symmetric to symmetricG ; reflexive to reflexiveG) ans : f (((g ·A h) ·A (x ·A inverse (g ·A h))) ·A inverse ((g ·A ((h ·A (x ·A inverse h)) ·A inverse g)))) ∼T Group.0G H ans = transitiveH (GroupHom.wellDefined fHom (transferToRight'' G (transitiveG (symmetricG +Associative) (Group.+WellDefined G reflexiveG (transitiveG (+WellDefined reflexiveG (transitiveG (+WellDefined reflexiveG (invContravariant G)) +Associative)) +Associative))))) (imageOfIdentityIsIdentity fHom)
{ "alphanum_fraction": 0.6611842105, "avg_line_length": 70.9333333333, "ext": "agda", "hexsha": "1ce845593e3ec3bb26039ecf3b14153bd0997cf1", "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/SymmetricGroups/Lemmas.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/SymmetricGroups/Lemmas.agda", "max_line_length": 636, "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/SymmetricGroups/Lemmas.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": 2964, "size": 8512 }
{-# OPTIONS --type-in-type #-} module Primitive where infixr 2 _,_ record Σ (A : Set)(B : A → Set) : Set where constructor _,_ field fst : A snd : B fst open Σ data ⊤ : Set where tt : ⊤ ∃ : {A : Set}(B : A → Set) → Set ∃ B = Σ _ B infix 10 _≡_ data _≡_ {A : Set}(a : A) : {B : Set} → B → Set where refl : a ≡ a trans : ∀ {A B C}{a : A}{b : B}{c : C} → a ≡ b → b ≡ c → a ≡ c trans refl p = p sym : ∀ {A B}{a : A}{b : B} → a ≡ b → b ≡ a sym refl = refl resp : ∀ {A}{B : A → Set}{a a' : A} → (f : (a : A) → B a) → a ≡ a' → f a ≡ f a' resp f refl = refl Cat : Set Cat = ∃ λ (Obj : Set) → ∃ λ (Hom : Obj → Obj → Set) → ∃ λ (id : ∀ X → Hom X X) → ∃ λ (_○_ : ∀ {X Y Z} → Hom Y Z → Hom X Y → Hom X Z) → ∃ λ (idl : ∀ {X Y}{f : Hom X Y} → id Y ○ f ≡ f) → ∃ λ (idr : ∀ {X Y}{f : Hom X Y} → f ○ id X ≡ f) → ∃ λ (assoc : ∀ {W X Y Z}{f : Hom W X}{g : Hom X Y}{h : Hom Y Z} → (h ○ g) ○ f ≡ h ○ (g ○ f)) → ⊤ Obj : (C : Cat) → Set Obj C = fst C Hom : (C : Cat) → Obj C → Obj C → Set Hom C = fst (snd C) id : (C : Cat) → ∀ X → Hom C X X id C = fst (snd (snd C)) comp : (C : Cat) → ∀ {X Y Z} → Hom C Y Z → Hom C X Y → Hom C X Z comp C = fst (snd (snd (snd C))) idl : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C (id C Y) f ≡ f idl C = fst (snd (snd (snd (snd C)))) idr : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C f (id C X) ≡ f idr C = fst (snd (snd (snd (snd (snd C))))) assoc : (C : Cat) → ∀ {W X Y Z}{f : Hom C W X}{g : Hom C X Y}{h : Hom C Y Z} → comp C (comp C h g) f ≡ comp C h (comp C g f) assoc C = fst (snd (snd (snd (snd (snd (snd C)))))) {- record Functor (C D : Cat) : Set where field Fun : Obj C → Obj D map : ∀ {X Y} → (Hom C X Y) → Hom D (Fun X) (Fun Y) mapid : ∀ {X} → map (id C X) ≡ id D (Fun X) map○ : ∀ {X Y Z}{f : Hom C X Y}{g : Hom C Y Z} → map (_○_ C g f) ≡ _○_ D (map g) (map f) open Functor idF : ∀ C → Functor C C idF C = record {Fun = \x → x; map = \x → x; mapid = refl; map○ = refl} _•_ : ∀ {C D E} → Functor D E → Functor C D → Functor C E F • G = record {Fun = \X → Fun F (Fun G X); map = \f → map F (map G f); mapid = trans (resp (\x → map F x) (mapid G)) (mapid F); map○ = trans (resp (\x → map F x) (map○ G)) (map○ F)} record Nat {C D : Cat} (F G : Functor C D) : Set where field η : (X : Obj C) → Hom D (Fun F X) (Fun G X) law : {X Y : Obj C}{f : Hom C X Y} → _○_ D (η Y) (map F f) ≡ _○_ D (map G f) (η X) open Nat _▪_ : ∀ {C D : Cat}{F G H : Functor C D} → Nat G H → Nat F G → Nat F H _▪_ {D = D} A B = record { η = \X → _○_ D (η A X) (η B X); law = \{X}{Y} → trans (assoc D) (trans (resp (\f → _○_ D (η A Y) f) (law B)) (trans (sym (assoc D)) (trans (resp (\g → _○_ D g (η B X)) (law A)) (assoc D)))) } -}
{ "alphanum_fraction": 0.4231686542, "avg_line_length": 27.6886792453, "ext": "agda", "hexsha": "3330130fcf91ba62b2a67b9eb91de61758426137", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "benchmark/categories/Primitive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "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": "larrytheliquid/agda", "max_issues_repo_path": "benchmark/categories/Primitive.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "benchmark/categories/Primitive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1271, "size": 2935 }
module Categories.Equalizer where
{ "alphanum_fraction": 0.8823529412, "avg_line_length": 17, "ext": "agda", "hexsha": "edd2d362b045d0e02cff2562b13495fa4d8eb9b7", "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/Equalizer.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/Equalizer.agda", "max_line_length": 33, "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/Equalizer.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": 6, "size": 34 }
open import Data.List open import Data.Nat using (ℕ; zero; suc) open import Data.Product open import Data.Bool open import Function using (id; _∘_) open import Algebra open import Level using (Level; _⊔_) module test where variable a b c ℓ c₂ ℓ₂ : Level A : Set a B : Set b C : Set c m n o p : ℕ -- Vector representation module Vector where -- Inductive definition of a vector data Vector (A : Set a) : (n : ℕ) → Set a where [] : Vector A zero _::_ : A → Vector A n → Vector A (suc n) infixr 5 _::_ vecLength : Vector A n → ℕ vecLength {n = n} v = n headV : Vector A (suc n) → A headV (x :: _) = x tailV : Vector A (suc n) → Vector A n tailV (_ :: xs) = xs -- Matrices are defined as vector of vectors Matrix : (A : Set a) → (m n : ℕ) → Set a Matrix A m n = Vector (Vector A m) n matLength : Matrix A m n → ℕ × ℕ matLength {m = m} {n = n} mat = m , n -- Some examples v1 : Vector ℕ 4 v1 = 1 :: 3 :: 4 :: 5 :: [] m1 : Matrix ℕ 2 2 m1 = (1 :: 2 :: []) :: (3 :: 4 :: []) :: [] -- Some standard functions for working with vectors zipV : (A → B → C) → (Vector A n → Vector B n → Vector C n) zipV f [] [] = [] zipV f (x :: xs) (y :: ys) = f x y :: zipV f xs ys mapV : (A → B) → Vector A n → Vector B n mapV f [] = [] mapV f (x :: v) = f x :: mapV f v replicateV : A → Vector A n replicateV {n = zero} x = [] replicateV {n = suc n} x = x :: replicateV x transpose : Matrix A m n → Matrix A n m transpose [] = replicateV [] transpose (x :: xs) = ((zipV _::_) x) (transpose xs) -- Pointwise equality on vectors (lifting _∼_ from elements to vectors) data EqV {A : Set a} (_∼_ : A → A → Set c) : ∀ {m n} (xs : Vector A m) (ys : Vector A n) → Set (a ⊔ c) where eq-[] : EqV _∼_ [] [] eq-:: : ∀ {m n x y} {xs : Vector A m} {ys : Vector A n} (x∼y : x ∼ y) (xs∼ys : EqV _∼_ xs ys) → EqV _∼_ (x :: xs) (y :: ys) -- Operations module Operations (R : Ring c ℓ) where open Ring R open Vector infixr 6 _+v_ infixr 7 _◁_ _◁ₘ_ _x_ _⊗_ _*m_ sumV : Vector Carrier n → Carrier sumV {n = zero} v = 0# sumV {n = suc n} (x :: xs) = x + sumV {n} xs 0v : Vector Carrier n 0v = replicateV 0# 0m : Matrix Carrier m n 0m = replicateV 0v -- Vector addition _+v_ : Vector Carrier n → Vector Carrier n → Vector Carrier n _+v_ = zipV _+_ -- Scale vector _◁_ : Carrier → Vector Carrier n → Vector Carrier n c ◁ v = mapV (c *_) v -- Dot product _•_ : Vector Carrier n → Vector Carrier n → Carrier u • v = sumV (zipV _*_ u v) -- Cross _x_ : Vector Carrier 3 → Vector Carrier 3 → Vector Carrier 3 (v1 :: v2 :: v3 :: []) x (u1 :: u2 :: u3 :: []) = (v2 * u3 + -(v3 * u2) :: v3 * u1 + -(v1 * u3) :: v1 * u2 + -(v2 * u1) :: []) -- Outer product _⊗_ : Vector Carrier m → Vector Carrier n → Matrix Carrier n m _⊗_ [] ys = [] _⊗_ (x :: xs) ys = mapV (x *_) ys :: xs ⊗ ys -- Scale matrix _◁ₘ_ : Carrier → Matrix Carrier m n → Matrix Carrier m n c ◁ₘ m = mapV (c ◁_) m -- Add matrix/matrix _+m_ : Matrix Carrier m n → Matrix Carrier m n → Matrix Carrier m n _+m_ = zipV _+v_ -- Mul matrix/vector _*mv_ : Matrix Carrier n m → Vector Carrier n → Vector Carrier m [] *mv m = 0v m *mv v = mapV (_• v) m -- Mul matrix/matrix _*m_ : {m n o : ℕ} → Matrix Carrier m n → Matrix Carrier m o → Matrix Carrier n o _ *m [] = 0m m1 *m m2 = mapV (m1 *mv_) m2 Sign = Carrier altSumVHelp : Sign → Vector Carrier n → Carrier altSumVHelp s [] = 0# altSumVHelp s (x :: xs) = s * x + altSumVHelp (- s) xs altSumV : Vector Carrier n → Carrier altSumV = altSumVHelp 1# -- alternating sum: multiply every second term by minus one -- submatricesStep : Matrix Carrier m (suc (suc n)) → Vector (Matrix Carrier m (suc n)) (suc (suc n)) submatricesStep : Matrix Carrier (suc (suc m)) n → Vector (Matrix Carrier (suc m) n) (suc (suc m)) -- submatrices : Matrix Carrier m (suc n) → Vector (Matrix Carrier m n) (suc n) submatrices : Matrix Carrier (suc m) n → Vector (Matrix Carrier m n) (suc m) submatrices {ℕ.zero} {n} ma = replicateV [] :: [] submatrices {suc m} {n} ma = submatricesStep ma submatricesStep ma with mapV headV ma | mapV tailV ma submatricesStep ma | heads | tails with submatrices tails submatricesStep ma | heads | tails | rec = tails :: mapV (zipV _::_ heads) rec -- Determinant det : Matrix Carrier m m → Carrier det [] = 1# det (v :: m) = altSumV (zipV _*_ v (mapV det (submatrices m))) module Property (a11 a12 a21 a22 : Carrier) where m22 : Matrix Carrier 2 2 m22 = (a11 :: a12 :: []) :: (a21 :: a22 :: []) :: [] test : Carrier test = det m22 -- Equality on our vectors is a lifted version of the -- underlying equality of the ring of components. _=v_ : Vector Carrier n → Vector Carrier m → Set (c ⊔ ℓ) _=v_ = EqV _≈_ -- The equality type is basically just a vector of equality -- proofs between pairs of corresponding elements. -- Left and right proof of identity with vector addition vectorAddIdentityˡ : ∀ {n} (v1 : Vector Carrier n) → (0v +v v1) =v v1 vectorAddIdentityˡ [] = eq-[] vectorAddIdentityˡ (x1 :: v1) = eq-::(+-identityˡ x1) (vectorAddIdentityˡ v1) vectorAddIdentityʳ : ∀ {n} (v1 : Vector Carrier n) → (v1 +v 0v) =v v1 vectorAddIdentityʳ [] = eq-[] vectorAddIdentityʳ (x1 :: v1) = eq-::(+-identityʳ x1) (vectorAddIdentityʳ v1) -- Vector addition is commutative (statement, and inductive proof) vectorAddComm : ∀ {n} (v1 v2 : Vector Carrier n) → (v1 +v v2) =v (v2 +v v1) vectorAddComm [] [] = eq-[] vectorAddComm (x1 :: v1) (x2 :: v2) = eq-:: (+-comm x1 x2) (vectorAddComm v1 v2) -- Vector addition is associative (statement, and inductive proof) vectorAddAssoc : ∀ {n} (v1 v2 v3 : Vector Carrier n) → ((v1 +v v2) +v v3) =v (v1 +v (v2 +v v3)) vectorAddAssoc [] [] [] = eq-[] vectorAddAssoc (x1 :: v1) (x2 :: v2) (x3 :: v3) = eq-:: (+-assoc x1 x2 x3) (vectorAddAssoc v1 v2 v3) dotComm : ∀ {n} (v1 v2 : Vector Carrier n) → (v1 • v2) ≈ (v2 • v1) dotComm [] v2 = refl dotComm (v1 :: vs) v2 = {!!} --hmmm module Morphism (G : Group c ℓ) (H : Group c₂ ℓ₂) where open Group G renaming (_∙_ to _*m_; ε to 0m) open Group H renaming (_∙_ to _*_; ε to 0#) -- show the determinant is a homomorphism
{ "alphanum_fraction": 0.5005366246, "avg_line_length": 35.1603773585, "ext": "agda", "hexsha": "9e5553c7d11bbd18d2aa102a38d855480bc44c6b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-02-02T18:02:43.000Z", "max_forks_repo_forks_event_min_datetime": "2022-02-02T18:02:43.000Z", "max_forks_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "DSLsofMath/BScProj2021", "max_forks_repo_path": "agda/test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "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": "DSLsofMath/BScProj2021", "max_issues_repo_path": "agda/test.agda", "max_line_length": 109, "max_stars_count": 2, "max_stars_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "DSLsofMath/BScProj2021", "max_stars_repo_path": "agda/test.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-10T22:46:54.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-27T11:56:35.000Z", "num_tokens": 2397, "size": 7454 }
module slots.imports where open import Data.Nat public using (ℕ ; zero ; suc ; _+_ ; _*_) open import Data.Fin public using (Fin ; zero ; suc ; #_) open import Data.List public using (List ; [] ; _∷_) open import Data.Vec public using (Vec ; [] ; _∷_) open import Data.Product public using (_×_ ; _,_ ; proj₁ ; proj₂) open import Function public using (const ; _∘_ ; _$_ ; case_of_) open import Relation.Nullary public using (Dec ; yes ; no) open import Relation.Binary.PropositionalEquality public using (_≡_ ; refl) module N = Data.Nat module F = Data.Fin module L = Data.List module V = Data.Vec module P = Data.Product
{ "alphanum_fraction": 0.7088, "avg_line_length": 36.7647058824, "ext": "agda", "hexsha": "bcde3326d6fb8bdacd1d0a231af25555cadd382c", "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": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/slots-agda", "max_forks_repo_path": "src/slots/imports.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "semenov-vladyslav/slots-agda", "max_issues_repo_path": "src/slots/imports.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/slots-agda", "max_stars_repo_path": "src/slots/imports.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 176, "size": 625 }
{-# OPTIONS --rewriting --without-K #-} open import Agda.Primitive open import Prelude import GSeTT.Rules import GSeTT.Typed-Syntax import Globular-TT.Syntax import Globular-TT.Rules {- Decidability of type cheking for the type theory for globular sets -} module Globular-TT.Dec-Type-Checking {l} (index : Set l) (rule : index → GSeTT.Typed-Syntax.Ctx × (Globular-TT.Syntax.Pre-Ty index)) (assumption : Globular-TT.Rules.well-founded index rule) (eqdec-index : eqdec index) where open import Globular-TT.Syntax index open import Globular-TT.Eqdec-syntax index eqdec-index open import Globular-TT.Rules index rule open import Globular-TT.CwF-Structure index rule dec-∈ : ∀ (n : ℕ) (A : Pre-Ty) (Γ : Pre-Ctx) → dec (n # A ∈ Γ) dec-∈ n A ⊘ = inr λ{()} dec-∈ n A (Γ ∙ x # B) with dec-∈ n A Γ ... | inl n∈Γ = inl (inl n∈Γ) ... | inr n∉Γ with eqdecℕ n x | eqdec-Ty A B ... | inl idp | inl idp = inl (inr (idp , idp)) ... | inr n≠x | _ = inr λ{(inl n∈Γ) → n∉Γ n∈Γ; (inr (idp , idp)) → n≠x idp} ... | inl idp | inr A≠B_ = inr λ{(inl n∈Γ) → n∉Γ n∈Γ; (inr (_ , A=B)) → A≠B A=B} {- Decidability in the fragment of the theory with only globular contexts -} -- termination is really tricky, and involves reasonning both on depth and dimension at the same time ! dec-G⊢T : ∀ (Γ : GSeTT.Typed-Syntax.Ctx) n A → dim A ≤ n → dec (GPre-Ctx (fst Γ) ⊢T A) dec-G⊢t : ∀ (Γ : GSeTT.Typed-Syntax.Ctx) n d A t → dim A ≤ n → depth t ≤ d → dec (GPre-Ctx (fst Γ) ⊢t t # A) dec-G⊢S : ∀ (Δ Γ : GSeTT.Typed-Syntax.Ctx) n d γ → dimC (GPre-Ctx (fst Γ)) ≤ n → depthS γ ≤ d → dec (GPre-Ctx (fst Δ) ⊢S γ > GPre-Ctx (fst Γ)) dec-G⊢T Γ _ ∗ _ = inl (ob (GCtx _ (snd Γ))) dec-G⊢T Γ (S n) (⇒ A t u) (S≤ i) with dec-G⊢T Γ n A i | dec-G⊢t Γ n _ A t i (n≤n _) | dec-G⊢t Γ n _ A u i (n≤n _) ... | inl Γ⊢A | inl Γ⊢t:A | inl Γ⊢u:A = inl (ar Γ⊢A Γ⊢t:A Γ⊢u:A) ... | inr Γ⊬A | _ | _ = inr λ{(ar Γ⊢A _ _) → Γ⊬A Γ⊢A} ... | inl _ | inr Γ⊬t:A | _ = inr λ{(ar _ Γ⊢t:A _) → Γ⊬t:A Γ⊢t:A} ... | inl _ | inl _ | inr Γ⊬u:A = inr λ{(ar _ _ Γ⊢u:A) → Γ⊬u:A Γ⊢u:A} dec-G⊢t Γ n _ A (Var x) _ (0≤ _) with dec-∈ x A (GPre-Ctx (fst Γ)) ... | inl x∈Γ = inl (var (GCtx _ (snd Γ)) x∈Γ) ... | inr x∉Γ = inr λ {(var _ x∈Γ) → x∉Γ x∈Γ} dec-G⊢t Γ n (S d) A (Tm-constructor i γ) dimA≤n (S≤ dγ≤d) with eqdec-Ty A (Ti i [ γ ]Pre-Ty ) ... | inr A≠Ti = inr λ{(tm _ _ idp) → A≠Ti idp} ... | inl idp with dec-G⊢T (fst (rule i)) n (Ti i) (=-≤ (dim[] _ _ ^) dimA≤n) ... | inr Ci⊬Ti = inr λ t → Ci⊬Ti (Γ⊢tm→Ci⊢Ti t) ... | inl Ci⊢Ti with dec-G⊢S Γ (fst (rule i)) n d γ (≤T (≤-= (assumption i Ci⊢Ti) (dim[] _ _ ^)) dimA≤n) -- dim Ci ≤ dim A dγ≤d -- depth γ ≤ d ... | inr Γ⊬γ = inr λ t → Γ⊬γ (Γ⊢tm→Γ⊢γ t) ... | inl Γ⊢γ = inl (tm Ci⊢Ti Γ⊢γ idp) dec-G⊢S Δ (nil , _) _ _ <> (0≤ _) _ = inl (es (GCtx _ (snd Δ))) dec-G⊢S Δ ((Γ :: _) , _) _ _ <> _ _ = inr λ {()} dec-G⊢S Δ (nil , _) _ _ < γ , x ↦ t > _ _ = inr λ {()} dec-G⊢S Δ ((Γ :: (y , A)) , Γ+⊢@(GSeTT.Rules.cc Γ⊢ Γ⊢A idp)) n d < γ , x ↦ t > dimΓ+≤n dγ+≤d with dec-G⊢S Δ (Γ , Γ⊢) n d γ (≤T (n≤max (dimC (GPre-Ctx Γ)) (dim (GPre-Ty A))) dimΓ+≤n) -- dim Γ ≤ n (≤T (n≤max (depthS γ) (depth t)) dγ+≤d) -- depth γ ≤ d | dec-G⊢t Δ n d ((GPre-Ty A) [ γ ]Pre-Ty) t ((≤T (=-≤ (dim[] _ _) (m≤max (dimC (GPre-Ctx Γ)) (dim (GPre-Ty A)))) dimΓ+≤n)) -- dim A[γ] ≤ n (≤T (m≤max (depthS γ) (depth t)) dγ+≤d) -- depth t ≤ d | eqdecℕ y x ... | inl Δ⊢γ:Γ | inl Δ⊢t | inl idp = inl (sc Δ⊢γ:Γ (GCtx _ Γ+⊢) Δ⊢t idp) ... | inr Δ⊬γ:Γ | _ | _ = inr λ {(sc Δ⊢γ:Γ _ _ idp) → Δ⊬γ:Γ Δ⊢γ:Γ} ... | inl _ | inr Δ⊬t | _ = inr λ {(sc _ _ Δ⊢t idp) → Δ⊬t Δ⊢t} ... | inl _ | inl _ | inr n≠x = inr λ {(sc _ _ _ idp) → n≠x idp} {- Decidability of judgments for contexts, types, terms and substitution towards a glaobular context -} dec-⊢C : ∀ Γ → dec (Γ ⊢C) dec-⊢T : ∀ Γ A → dec (Γ ⊢T A) dec-⊢t : ∀ Γ A t → dec (Γ ⊢t t # A) dec-⊢S:G : ∀ Δ (Γ : GSeTT.Typed-Syntax.Ctx) γ → dec (Δ ⊢S γ > GPre-Ctx (fst Γ)) dec-⊢T Γ ∗ with dec-⊢C Γ ... | inl Γ⊢ = inl (ob Γ⊢) ... | inr Γ⊬ = inr λ {(ob Γ⊢) → Γ⊬ Γ⊢} dec-⊢T Γ (⇒ A t u) with dec-⊢T Γ A | dec-⊢t Γ A t | dec-⊢t Γ A u ... | inl Γ⊢A | inl Γ⊢t:A | inl Γ⊢u:A = inl (ar Γ⊢A Γ⊢t:A Γ⊢u:A) ... | inr Γ⊬A | _ | _ = inr λ {(ar Γ⊢A _ _) → Γ⊬A Γ⊢A} ... | inl _ | inr Γ⊬t:A | _ = inr λ {(ar _ Γ⊢t:A _) → Γ⊬t:A Γ⊢t:A} ... | inl _ | inl _ | inr Γ⊬u:A = inr λ {(ar _ _ Γ⊢u:A) → Γ⊬u:A Γ⊢u:A} dec-⊢t Γ A (Var x) with dec-⊢C Γ | dec-∈ x A Γ ... | inl Γ⊢ | inl x∈Γ = inl (var Γ⊢ x∈Γ) ... | inr Γ⊬ | _ = inr λ {(var Γ⊢ _) → Γ⊬ Γ⊢} ... | inl _ | inr x∉Γ = inr λ {(var _ x∈Γ) → x∉Γ x∈Γ} dec-⊢t Γ A (Tm-constructor i γ) with eqdec-Ty A (Ti i [ γ ]Pre-Ty) ... | inr A≠Ti = inr λ{(tm _ _ idp) → A≠Ti idp} ... | inl idp with dec-G⊢T (fst (rule i)) _ (Ti i) (n≤n _) | dec-⊢S:G Γ (fst (rule i)) γ ... | inl Ci⊢Ti | inl Γ⊢γ = inl (tm Ci⊢Ti Γ⊢γ idp) ... | inr Ci⊬Ti | _ = inr λ t → Ci⊬Ti (Γ⊢tm→Ci⊢Ti t) ... | inl _ | inr Γ⊬γ = inr λ t → Γ⊬γ (Γ⊢tm→Γ⊢γ t) dec-⊢C ⊘ = inl ec dec-⊢C (Γ ∙ n # A) with dec-⊢C Γ | dec-⊢T Γ A | eqdecℕ n (C-length Γ) ... | inl Γ⊢ | inl Γ⊢A | inl idp = inl (cc Γ⊢ Γ⊢A idp) ... | inr Γ⊬ | _ | _ = inr λ {(cc Γ⊢ _ idp) → Γ⊬ Γ⊢} ... | inl _ | inr Γ⊬A | _ = inr λ {(cc _ Γ⊢A idp) → Γ⊬A Γ⊢A} ... | inl _ | inl _ | inr n≠l = inr λ {(cc _ _ idp) → n≠l idp} dec-⊢S:G Δ (nil , _) <> with (dec-⊢C Δ) ... | inl Δ⊢ = inl (es Δ⊢) ... | inr Δ⊬ = inr λ{(es Δ⊢) → Δ⊬ Δ⊢} dec-⊢S:G Δ (nil , _) < γ , x ↦ x₁ > = inr λ{()} dec-⊢S:G Δ ((Γ :: _) , _) <> = inr λ{()} dec-⊢S:G Δ ((Γ :: (v , A)) , Γ+⊢@(GSeTT.Rules.cc Γ⊢ Γ⊢A idp)) < γ , x ↦ t > with dec-⊢S:G Δ (Γ , Γ⊢) γ | dec-⊢t Δ ((GPre-Ty A) [ γ ]Pre-Ty) t | eqdecℕ x (length Γ) ... | inl Δ⊢γ | inl Δ⊢t | inl idp = inl (sc Δ⊢γ (GCtx _ Γ+⊢) Δ⊢t idp) ... | inr Δ⊬γ | _ | _ = inr λ{(sc Δ⊢γ _ _ idp) → Δ⊬γ Δ⊢γ} ... | inl _ | inr Δ⊬t | _ = inr λ{(sc _ _ Δ⊢t idp) → Δ⊬t Δ⊢t} ... | inl _ | inl _ | inr x≠x = inr λ{(sc _ _ _ idp) → x≠x idp} {- Decidability of substitution -} dec-⊢S : ∀ Δ Γ γ → dec (Δ ⊢S γ > Γ) dec-⊢S Δ ⊘ <> with (dec-⊢C Δ) ... | inl Δ⊢ = inl (es Δ⊢) ... | inr Δ⊬ = inr λ{(es Δ⊢) → Δ⊬ Δ⊢} dec-⊢S Δ ⊘ < γ , x ↦ x₁ > = inr λ{()} dec-⊢S Δ (Γ ∙ _ # _) <> = inr λ{()} dec-⊢S Δ (Γ ∙ v # A) < γ , x ↦ t > with dec-⊢S Δ Γ γ | dec-⊢C (Γ ∙ v # A) | dec-⊢t Δ (A [ γ ]Pre-Ty) t | eqdecℕ x v ... | inl Δ⊢γ | inl Γ+⊢ | inl Δ⊢t | inl idp = inl (sc Δ⊢γ Γ+⊢ Δ⊢t idp) ... | inr Δ⊬γ | _ | _ | _ = inr λ{(sc Δ⊢γ _ _ idp) → Δ⊬γ Δ⊢γ} ... | inl _ | inr Γ+⊬ | _ | _ = inr λ{(sc _ Γ⊢ _ idp) → Γ+⊬ Γ⊢} ... | inl _ | inl _ | inr Δ⊬t | _ = inr λ{(sc _ _ Δ⊢t idp) → Δ⊬t Δ⊢t} ... | inl _ | inl _ | inl _ | inr x≠x = inr λ{(sc _ _ _ idp) → x≠x idp}
{ "alphanum_fraction": 0.3448021108, "avg_line_length": 70.1851851852, "ext": "agda", "hexsha": "1ada383eb52dd269dc675f02a3598ba2040b6143", "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": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "Globular-TT/Dec-Type-Checking.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "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": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "Globular-TT/Dec-Type-Checking.agda", "max_line_length": 196, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "Globular-TT/Dec-Type-Checking.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3858, "size": 9475 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.List where open import Cubical.Data.List.Base public open import Cubical.Data.List.Properties public
{ "alphanum_fraction": 0.7430167598, "avg_line_length": 29.8333333333, "ext": "agda", "hexsha": "f2423de0556eeb8031c217d922d10c8a56c5323e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/List.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/List.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 40, "size": 179 }
-- Andreas, 2017-12-04, Re: issue #2862, reported by m0davis, -- Make sure there is similar problem with functions. open import Agda.Builtin.Equality data Bool : Set where true false : Bool module N where val : Bool -- Should fail module M where open N val = true val≡true : val ≡ true val≡true = refl open N val = false data ⊥ : Set where ¬val≡true : val ≡ true → ⊥ ¬val≡true () -- val≡true : val ≡ true -- val≡true = Z.va val true boom : ⊥ boom = ¬val≡true Z.val≡true
{ "alphanum_fraction": 0.6524390244, "avg_line_length": 15.8709677419, "ext": "agda", "hexsha": "a8ee57fc3dfd35f98198849f37197ed929148cdd", "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/Issue2862fun1.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/Issue2862fun1.agda", "max_line_length": 61, "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/Issue2862fun1.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": 175, "size": 492 }
{-# OPTIONS --without-K --safe #-} module Definition.Typed.Consequences.Inequality where open import Definition.Untyped hiding (U≢ne; ℕ≢ne; B≢ne; U≢B; ℕ≢B) open import Definition.Typed open import Definition.Typed.EqRelInstance open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Fundamental.Reducibility open import Definition.Typed.Consequences.Syntactic open import Tools.Product open import Tools.Empty A≢B : ∀ {A B Γ} (_⊩′⟨_⟩A_ _⊩′⟨_⟩B_ : Con Term → TypeLevel → Term → Set) (A-intr : ∀ {l} → Γ ⊩′⟨ l ⟩A A → Γ ⊩⟨ l ⟩ A) (B-intr : ∀ {l} → Γ ⊩′⟨ l ⟩B B → Γ ⊩⟨ l ⟩ B) (A-elim : ∀ {l} → Γ ⊩⟨ l ⟩ A → ∃ λ l′ → Γ ⊩′⟨ l′ ⟩A A) (B-elim : ∀ {l} → Γ ⊩⟨ l ⟩ B → ∃ λ l′ → Γ ⊩′⟨ l′ ⟩B B) (A≢B′ : ∀ {l l′} ([A] : Γ ⊩′⟨ l ⟩A A) ([B] : Γ ⊩′⟨ l′ ⟩B B) → ShapeView Γ l l′ A B (A-intr [A]) (B-intr [B]) → ⊥) → Γ ⊢ A ≡ B → ⊥ A≢B {A} {B} _ _ A-intr B-intr A-elim B-elim A≢B′ A≡B with reducibleEq A≡B A≢B {A} {B} _ _ A-intr B-intr A-elim B-elim A≢B′ A≡B | [A] , [B] , [A≡B] = let _ , [A]′ = A-elim ([A]) _ , [B]′ = B-elim ([B]) [A≡B]′ = irrelevanceEq [A] (A-intr [A]′) [A≡B] in A≢B′ [A]′ [B]′ (goodCases (A-intr [A]′) (B-intr [B]′) [A≡B]′) U≢ℕ′ : ∀ {Γ B l l′} ([U] : Γ ⊩′⟨ l ⟩U) ([ℕ] : Γ ⊩ℕ B) → ShapeView Γ l l′ _ _ (Uᵣ [U]) (ℕᵣ [ℕ]) → ⊥ U≢ℕ′ a b () U≢ℕ-red : ∀ {B Γ} → Γ ⊢ B ⇒* ℕ → Γ ⊢ U ≡ B → ⊥ U≢ℕ-red D = A≢B (λ Γ l A → Γ ⊩′⟨ l ⟩U) (λ Γ l B → Γ ⊩ℕ B) Uᵣ ℕᵣ (λ x → extractMaybeEmb (U-elim x)) (λ x → extractMaybeEmb (ℕ-elim′ D x)) U≢ℕ′ -- U and ℕ cannot be judgmentally equal. U≢ℕ : ∀ {Γ} → Γ ⊢ U ≡ ℕ → ⊥ U≢ℕ U≡ℕ = let _ , ⊢ℕ = syntacticEq U≡ℕ in U≢ℕ-red (id ⊢ℕ) U≡ℕ -- U and Empty U≢Empty′ : ∀ {Γ B l l′} ([U] : Γ ⊩′⟨ l ⟩U) ([Empty] : Γ ⊩Empty B) → ShapeView Γ l l′ _ _ (Uᵣ [U]) (Emptyᵣ [Empty]) → ⊥ U≢Empty′ a b () U≢Empty-red : ∀ {B Γ} → Γ ⊢ B ⇒* Empty → Γ ⊢ U ≡ B → ⊥ U≢Empty-red D = A≢B (λ Γ l A → Γ ⊩′⟨ l ⟩U) (λ Γ l B → Γ ⊩Empty B) Uᵣ Emptyᵣ (λ x → extractMaybeEmb (U-elim x)) (λ x → extractMaybeEmb (Empty-elim′ D x)) U≢Empty′ U≢Emptyⱼ : ∀ {Γ} → Γ ⊢ U ≡ Empty → ⊥ U≢Emptyⱼ U≡Empty = let _ , ⊢Empty = syntacticEq U≡Empty in U≢Empty-red (id ⊢Empty) U≡Empty -- U and Unit U≢Unit′ : ∀ {Γ B l l′} ([U] : Γ ⊩′⟨ l ⟩U) ([Unit] : Γ ⊩Unit B) → ShapeView Γ l l′ _ _ (Uᵣ [U]) (Unitᵣ [Unit]) → ⊥ U≢Unit′ a b () U≢Unit-red : ∀ {B Γ} → Γ ⊢ B ⇒* Unit → Γ ⊢ U ≡ B → ⊥ U≢Unit-red D = A≢B (λ Γ l A → Γ ⊩′⟨ l ⟩U) (λ Γ l B → Γ ⊩Unit B) Uᵣ Unitᵣ (λ x → extractMaybeEmb (U-elim x)) (λ x → extractMaybeEmb (Unit-elim′ D x)) U≢Unit′ U≢Unitⱼ : ∀ {Γ} → Γ ⊢ U ≡ Unit → ⊥ U≢Unitⱼ U≡Unit = let _ , ⊢Unit = syntacticEq U≡Unit in U≢Unit-red (id ⊢Unit) U≡Unit -- ℕ and Empty ℕ≢Empty′ : ∀ {Γ B l l'} ([ℕ] : Γ ⊩ℕ ℕ) ([Empty] : Γ ⊩Empty B) → ShapeView Γ l l' _ _ (ℕᵣ [ℕ]) (Emptyᵣ [Empty]) → ⊥ ℕ≢Empty′ a b () ℕ≢Empty-red : ∀ {B Γ} → Γ ⊢ B ⇒* Empty → Γ ⊢ ℕ ≡ B → ⊥ ℕ≢Empty-red D = A≢B (λ Γ l A → Γ ⊩ℕ A) (λ Γ l B → Γ ⊩Empty B) ℕᵣ Emptyᵣ (λ x → extractMaybeEmb (ℕ-elim x)) (λ x → extractMaybeEmb (Empty-elim′ D x)) ℕ≢Empty′ ℕ≢Emptyⱼ : ∀ {Γ} → Γ ⊢ ℕ ≡ Empty → ⊥ ℕ≢Emptyⱼ ℕ≡Empty = let _ , ⊢Empty = syntacticEq ℕ≡Empty in ℕ≢Empty-red (id ⊢Empty) ℕ≡Empty -- ℕ and Unit ℕ≢Unit′ : ∀ {Γ B l l'} ([ℕ] : Γ ⊩ℕ ℕ) ([Unit] : Γ ⊩Unit B) → ShapeView Γ l l' _ _ (ℕᵣ [ℕ]) (Unitᵣ [Unit]) → ⊥ ℕ≢Unit′ a b () ℕ≢Unit-red : ∀ {B Γ} → Γ ⊢ B ⇒* Unit → Γ ⊢ ℕ ≡ B → ⊥ ℕ≢Unit-red D = A≢B (λ Γ l A → Γ ⊩ℕ A) (λ Γ l B → Γ ⊩Unit B) ℕᵣ Unitᵣ (λ x → extractMaybeEmb (ℕ-elim x)) (λ x → extractMaybeEmb (Unit-elim′ D x)) ℕ≢Unit′ ℕ≢Unitⱼ : ∀ {Γ} → Γ ⊢ ℕ ≡ Unit → ⊥ ℕ≢Unitⱼ ℕ≡Unit = let _ , ⊢Unit = syntacticEq ℕ≡Unit in ℕ≢Unit-red (id ⊢Unit) ℕ≡Unit -- Empty and Unit Empty≢Unit′ : ∀ {Γ B l l'} ([Empty] : Γ ⊩Empty Empty) ([Unit] : Γ ⊩Unit B) → ShapeView Γ l l' _ _ (Emptyᵣ [Empty]) (Unitᵣ [Unit]) → ⊥ Empty≢Unit′ a b () Empty≢Unit-red : ∀ {B Γ} → Γ ⊢ B ⇒* Unit → Γ ⊢ Empty ≡ B → ⊥ Empty≢Unit-red D = A≢B (λ Γ l A → Γ ⊩Empty A) (λ Γ l B → Γ ⊩Unit B) Emptyᵣ Unitᵣ (λ x → extractMaybeEmb (Empty-elim x)) (λ x → extractMaybeEmb (Unit-elim′ D x)) Empty≢Unit′ Empty≢Unitⱼ : ∀ {Γ} → Γ ⊢ Empty ≡ Unit → ⊥ Empty≢Unitⱼ Empty≡Unit = let _ , ⊢Unit = syntacticEq Empty≡Unit in Empty≢Unit-red (id ⊢Unit) Empty≡Unit -- Universe and binding types U≢B′ : ∀ {B Γ l l′} W ([U] : Γ ⊩′⟨ l ⟩U) ([W] : Γ ⊩′⟨ l′ ⟩B⟨ W ⟩ B) → ShapeView Γ l l′ _ _ (Uᵣ [U]) (Bᵣ W [W]) → ⊥ U≢B′ W a b () U≢B-red : ∀ {B F G Γ} W → Γ ⊢ B ⇒* ⟦ W ⟧ F ▹ G → Γ ⊢ U ≡ B → ⊥ U≢B-red W D = A≢B (λ Γ l A → Γ ⊩′⟨ l ⟩U) (λ Γ l A → Γ ⊩′⟨ l ⟩B⟨ W ⟩ A) Uᵣ (Bᵣ W) (λ x → extractMaybeEmb (U-elim x)) (λ x → extractMaybeEmb (B-elim′ W D x)) (U≢B′ W) -- U and Π F ▹ G for any F and G cannot be judgmentally equal. U≢B : ∀ {F G Γ} W → Γ ⊢ U ≡ ⟦ W ⟧ F ▹ G → ⊥ U≢B W U≡W = let _ , ⊢W = syntacticEq U≡W in U≢B-red W (id ⊢W) U≡W U≢Π : ∀ {F G Γ} → _ U≢Π {F} {G} {Γ} = U≢B {F} {G} {Γ} BΠ U≢Σ : ∀ {F G Γ} → _ U≢Σ {F} {G} {Γ} = U≢B {F} {G} {Γ} BΣ U≢ne′ : ∀ {K Γ l l′} ([U] : Γ ⊩′⟨ l ⟩U) ([K] : Γ ⊩ne K) → ShapeView Γ l l′ _ _ (Uᵣ [U]) (ne [K]) → ⊥ U≢ne′ a b () U≢ne-red : ∀ {B K Γ} → Γ ⊢ B ⇒* K → Neutral K → Γ ⊢ U ≡ B → ⊥ U≢ne-red D neK = A≢B (λ Γ l A → Γ ⊩′⟨ l ⟩U) (λ Γ l B → Γ ⊩ne B) Uᵣ ne (λ x → extractMaybeEmb (U-elim x)) (λ x → extractMaybeEmb (ne-elim′ D neK x)) U≢ne′ -- U and K for any neutral K cannot be judgmentally equal. U≢ne : ∀ {K Γ} → Neutral K → Γ ⊢ U ≡ K → ⊥ U≢ne neK U≡K = let _ , ⊢K = syntacticEq U≡K in U≢ne-red (id ⊢K) neK U≡K ℕ≢B′ : ∀ {A B Γ l l′} W ([ℕ] : Γ ⊩ℕ A) ([W] : Γ ⊩′⟨ l′ ⟩B⟨ W ⟩ B) → ShapeView Γ l l′ _ _ (ℕᵣ [ℕ]) (Bᵣ W [W]) → ⊥ ℕ≢B′ W a b () ℕ≢B-red : ∀ {A B F G Γ} W → Γ ⊢ A ⇒* ℕ → Γ ⊢ B ⇒* ⟦ W ⟧ F ▹ G → Γ ⊢ A ≡ B → ⊥ ℕ≢B-red W D D′ = A≢B (λ Γ l A → Γ ⊩ℕ A) (λ Γ l A → Γ ⊩′⟨ l ⟩B⟨ W ⟩ A) ℕᵣ (Bᵣ W) (λ x → extractMaybeEmb (ℕ-elim′ D x)) (λ x → extractMaybeEmb (B-elim′ W D′ x)) (ℕ≢B′ W) -- ℕ and B F ▹ G for any F and G cannot be judgmentally equal. ℕ≢B : ∀ {F G Γ} W → Γ ⊢ ℕ ≡ ⟦ W ⟧ F ▹ G → ⊥ ℕ≢B W ℕ≡W = let ⊢ℕ , ⊢W = syntacticEq ℕ≡W in ℕ≢B-red W (id ⊢ℕ) (id ⊢W) ℕ≡W ℕ≢Π : ∀ {F G Γ} → _ ℕ≢Π {F} {G} {Γ} = ℕ≢B {F} {G} {Γ} BΠ ℕ≢Σ : ∀ {F G Γ} → _ ℕ≢Σ {F} {G} {Γ} = ℕ≢B {F} {G} {Γ} BΣ -- Empty and Π Empty≢B′ : ∀ {A B Γ l l′} W ([Empty] : Γ ⊩Empty A) ([W] : Γ ⊩′⟨ l′ ⟩B⟨ W ⟩ B) → ShapeView Γ l l′ _ _ (Emptyᵣ [Empty]) (Bᵣ W [W]) → ⊥ Empty≢B′ W a b () Empty≢B-red : ∀ {A B F G Γ} W → Γ ⊢ A ⇒* Empty → Γ ⊢ B ⇒* ⟦ W ⟧ F ▹ G → Γ ⊢ A ≡ B → ⊥ Empty≢B-red W D D′ = A≢B (λ Γ l A → Γ ⊩Empty A) (λ Γ l A → Γ ⊩′⟨ l ⟩B⟨ W ⟩ A) Emptyᵣ (Bᵣ W) (λ x → extractMaybeEmb (Empty-elim′ D x)) (λ x → extractMaybeEmb (B-elim′ W D′ x)) (Empty≢B′ W) Empty≢Bⱼ : ∀ {F G Γ} W → Γ ⊢ Empty ≡ ⟦ W ⟧ F ▹ G → ⊥ Empty≢Bⱼ W Empty≡W = let ⊢Empty , ⊢W = syntacticEq Empty≡W in Empty≢B-red W (id ⊢Empty) (id ⊢W) Empty≡W Empty≢Πⱼ : ∀ {F G Γ} → _ Empty≢Πⱼ {F} {G} {Γ} = Empty≢Bⱼ {F} {G} {Γ} BΠ Empty≢Σⱼ : ∀ {F G Γ} → _ Empty≢Σⱼ {F} {G} {Γ} = Empty≢Bⱼ {F} {G} {Γ} BΣ -- Unit and Π Unit≢B′ : ∀ {A B Γ l l′} W ([Unit] : Γ ⊩Unit A) ([W] : Γ ⊩′⟨ l′ ⟩B⟨ W ⟩ B) → ShapeView Γ l l′ _ _ (Unitᵣ [Unit]) (Bᵣ W [W]) → ⊥ Unit≢B′ W a b () Unit≢B-red : ∀ {A B F G Γ} W → Γ ⊢ A ⇒* Unit → Γ ⊢ B ⇒* ⟦ W ⟧ F ▹ G → Γ ⊢ A ≡ B → ⊥ Unit≢B-red W D D′ = A≢B (λ Γ l A → Γ ⊩Unit A) (λ Γ l A → Γ ⊩′⟨ l ⟩B⟨ W ⟩ A) Unitᵣ (Bᵣ W) (λ x → extractMaybeEmb (Unit-elim′ D x)) (λ x → extractMaybeEmb (B-elim′ W D′ x)) (Unit≢B′ W) Unit≢Bⱼ : ∀ {F G Γ} W → Γ ⊢ Unit ≡ ⟦ W ⟧ F ▹ G → ⊥ Unit≢Bⱼ W Unit≡W = let ⊢Unit , ⊢W = syntacticEq Unit≡W in Unit≢B-red W (id ⊢Unit) (id ⊢W) Unit≡W Unit≢Πⱼ : ∀ {F G Γ} → _ Unit≢Πⱼ {F} {G} {Γ} = Unit≢Bⱼ {F} {G} {Γ} BΠ Unit≢Σⱼ : ∀ {F G Γ} → _ Unit≢Σⱼ {F} {G} {Γ} = Unit≢Bⱼ {F} {G} {Γ} BΣ ℕ≢ne′ : ∀ {A K Γ l l′} ([ℕ] : Γ ⊩ℕ A) ([K] : Γ ⊩ne K) → ShapeView Γ l l′ _ _ (ℕᵣ [ℕ]) (ne [K]) → ⊥ ℕ≢ne′ a b () ℕ≢ne-red : ∀ {A B K Γ} → Γ ⊢ A ⇒* ℕ → Γ ⊢ B ⇒* K → Neutral K → Γ ⊢ A ≡ B → ⊥ ℕ≢ne-red D D′ neK = A≢B (λ Γ l A → Γ ⊩ℕ A) (λ Γ l B → Γ ⊩ne B) ℕᵣ ne (λ x → extractMaybeEmb (ℕ-elim′ D x)) (λ x → extractMaybeEmb (ne-elim′ D′ neK x)) ℕ≢ne′ -- ℕ and K for any neutral K cannot be judgmentally equal. ℕ≢ne : ∀ {K Γ} → Neutral K → Γ ⊢ ℕ ≡ K → ⊥ ℕ≢ne neK ℕ≡K = let ⊢ℕ , ⊢K = syntacticEq ℕ≡K in ℕ≢ne-red (id ⊢ℕ) (id ⊢K) neK ℕ≡K -- Empty and neutral Empty≢ne′ : ∀ {A K Γ l l′} ([Empty] : Γ ⊩Empty A) ([K] : Γ ⊩ne K) → ShapeView Γ l l′ _ _ (Emptyᵣ [Empty]) (ne [K]) → ⊥ Empty≢ne′ a b () Empty≢ne-red : ∀ {A B K Γ} → Γ ⊢ A ⇒* Empty → Γ ⊢ B ⇒* K → Neutral K → Γ ⊢ A ≡ B → ⊥ Empty≢ne-red D D′ neK = A≢B (λ Γ l A → Γ ⊩Empty A) (λ Γ l B → Γ ⊩ne B) Emptyᵣ ne (λ x → extractMaybeEmb (Empty-elim′ D x)) (λ x → extractMaybeEmb (ne-elim′ D′ neK x)) Empty≢ne′ Empty≢neⱼ : ∀ {K Γ} → Neutral K → Γ ⊢ Empty ≡ K → ⊥ Empty≢neⱼ neK Empty≡K = let ⊢Empty , ⊢K = syntacticEq Empty≡K in Empty≢ne-red (id ⊢Empty) (id ⊢K) neK Empty≡K -- Unit and neutral Unit≢ne′ : ∀ {A K Γ l l′} ([Unit] : Γ ⊩Unit A) ([K] : Γ ⊩ne K) → ShapeView Γ l l′ _ _ (Unitᵣ [Unit]) (ne [K]) → ⊥ Unit≢ne′ a b () Unit≢ne-red : ∀ {A B K Γ} → Γ ⊢ A ⇒* Unit → Γ ⊢ B ⇒* K → Neutral K → Γ ⊢ A ≡ B → ⊥ Unit≢ne-red D D′ neK = A≢B (λ Γ l A → Γ ⊩Unit A) (λ Γ l B → Γ ⊩ne B) Unitᵣ ne (λ x → extractMaybeEmb (Unit-elim′ D x)) (λ x → extractMaybeEmb (ne-elim′ D′ neK x)) Unit≢ne′ Unit≢neⱼ : ∀ {K Γ} → Neutral K → Γ ⊢ Unit ≡ K → ⊥ Unit≢neⱼ neK Unit≡K = let ⊢Unit , ⊢K = syntacticEq Unit≡K in Unit≢ne-red (id ⊢Unit) (id ⊢K) neK Unit≡K B≢ne′ : ∀ {A K Γ l l′} W ([W] : Γ ⊩′⟨ l ⟩B⟨ W ⟩ A) ([K] : Γ ⊩ne K) → ShapeView Γ l l′ _ _ (Bᵣ W [W]) (ne [K]) → ⊥ B≢ne′ W a b () B≢ne-red : ∀ {A B F G K Γ} W → Γ ⊢ A ⇒* ⟦ W ⟧ F ▹ G → Γ ⊢ B ⇒* K → Neutral K → Γ ⊢ A ≡ B → ⊥ B≢ne-red W D D′ neK = A≢B (λ Γ l A → Γ ⊩′⟨ l ⟩B⟨ W ⟩ A) (λ Γ l B → Γ ⊩ne B) (Bᵣ W) ne (λ x → extractMaybeEmb (B-elim′ W D x)) (λ x → extractMaybeEmb (ne-elim′ D′ neK x)) (B≢ne′ W) -- ⟦ W ⟧ F ▹ G and K for any W, F, G and neutral K cannot be judgmentally equal. B≢ne : ∀ {F G K Γ} W → Neutral K → Γ ⊢ ⟦ W ⟧ F ▹ G ≡ K → ⊥ B≢ne W neK W≡K = let ⊢W , ⊢K = syntacticEq W≡K in B≢ne-red W (id ⊢W) (id ⊢K) neK W≡K Π≢ne : ∀ {F G K Γ} → _ Π≢ne {F} {G} {K} {Γ} = B≢ne {F} {G} {K} {Γ} BΠ Σ≢ne : ∀ {F G K Γ} → _ Σ≢ne {F} {G} {K} {Γ} = B≢ne {F} {G} {K} {Γ} BΣ -- Π and Σ Π≢Σ′ : ∀ {A B Γ l l′} ([A] : Γ ⊩′⟨ l ⟩B⟨ BΠ ⟩ A) ([B] : Γ ⊩′⟨ l′ ⟩B⟨ BΣ ⟩ B) → ShapeView Γ l l′ _ _ (Bᵣ BΠ [A]) (Bᵣ BΣ [B]) → ⊥ Π≢Σ′ a b () Π≢Σ-red : ∀ {A B F G H E Γ} → Γ ⊢ A ⇒* Π F ▹ G → Γ ⊢ B ⇒* Σ H ▹ E → Γ ⊢ A ≡ B → ⊥ Π≢Σ-red D D′ = A≢B (λ Γ l A → Γ ⊩′⟨ l ⟩B⟨ BΠ ⟩ A) (λ Γ l A → Γ ⊩′⟨ l ⟩B⟨ BΣ ⟩ A) (Bᵣ BΠ) (Bᵣ BΣ) (λ x → extractMaybeEmb (B-elim′ BΠ D x)) (λ x → extractMaybeEmb (B-elim′ BΣ D′ x)) Π≢Σ′ Π≢Σ : ∀ {Γ F G H E} → Γ ⊢ Π F ▹ G ≡ Σ H ▹ E → ⊥ Π≢Σ Π≡Σ = let ⊢Π , ⊢Σ = syntacticEq Π≡Σ in Π≢Σ-red (id ⊢Π) (id ⊢Σ) Π≡Σ
{ "alphanum_fraction": 0.4342454395, "avg_line_length": 33.781512605, "ext": "agda", "hexsha": "cd23d5b7d4e26d3dac1d59995c6cf7383b26e416", "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": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/Inequality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "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": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/Inequality.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/Inequality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6155, "size": 12060 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} module LibraBFT.Impl.Base.Types where open import LibraBFT.Prelude open import LibraBFT.Hash NodeId : Set NodeId = ℕ _≟NodeId_ : (n1 n2 : NodeId) → Dec (n1 ≡ n2) _≟NodeId_ = _≟ℕ_ UID : Set UID = Hash _≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁) _≟UID_ = _≟Hash_
{ "alphanum_fraction": 0.6864244742, "avg_line_length": 23.7727272727, "ext": "agda", "hexsha": "fb2eeb0535466434b913d3ba7d796f8360cc86bc", "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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Impl/Base/Types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Impl/Base/Types.agda", "max_line_length": 111, "max_stars_count": null, "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": "LibraBFT/Impl/Base/Types.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 190, "size": 523 }
module Category.FAM where open import Level open import Relation.Binary.PropositionalEquality open import Function using (_∘_; id; _∘′_) ------------------------------------------------------------------------ -- Functors record IsFunctor {ℓ} (F : Set ℓ → Set ℓ) (_<$>_ : ∀ {A B} → (A → B) → F A → F B) : Set (suc ℓ) where field identity : {A : Set ℓ} (a : F A) → id <$> a ≡ a homo : ∀ {A B C} (f : B → C) (g : A → B) (a : F A) → (f ∘ g) <$> a ≡ f <$> (g <$> a) record Functor {ℓ} (F : Set ℓ → Set ℓ) : Set (suc ℓ) where infixl 4 _<$>_ _<$_ field _<$>_ : ∀ {A B} → (A → B) → F A → F B isFunctor : IsFunctor F _<$>_ -- An textual synonym of _<$>_ fmap : ∀ {A B} → (A → B) → F A → F B fmap = _<$>_ -- Replace all locations in the input with the same value. -- The default definition is fmap . const, but this may be overridden with a -- more efficient version. _<$_ : ∀ {A B} → A → F B → F A x <$ y = Function.const x <$> y open IsFunctor isFunctor public -- open Functor {{...}} public ------------------------------------------------------------------------ -- Applicatives (not indexed) record IsApplicative {ℓ} (F : Set ℓ → Set ℓ) (pure : {A : Set ℓ} → A → F A) (_⊛_ : {A B : Set ℓ} → (F (A → B)) → F A → F B) : Set (suc ℓ) where field identity : {A : Set ℓ} (x : F A) → pure id ⊛ x ≡ x compose : {A B C : Set ℓ} (f : F (B → C)) (g : F (A → B)) → (x : F A) → ((pure _∘′_ ⊛ f) ⊛ g) ⊛ x ≡ f ⊛ (g ⊛ x) homo : ∀ {A B} (f : A → B) (x : A) → pure f ⊛ pure x ≡ pure (f x) interchange : ∀ {A B} (f : F (A → B)) (x : A) → f ⊛ pure x ≡ pure (λ f → f x) ⊛ f record Applicative {ℓ} (F : Set ℓ → Set ℓ) : Set (suc ℓ) where infixl 4 _⊛_ _<⊛_ _⊛>_ infix 4 _⊗_ field pure : {A : Set ℓ} → A → F A _⊛_ : {A B : Set ℓ} → (F (A → B)) → F A → F B isApplicative : IsApplicative F pure _⊛_ open IsApplicative isApplicative public _<⊛_ : ∀ {A B} → F A → F B → F A x <⊛ y = x _⊛>_ : ∀ {A B} → F A → F B → F B x ⊛> y = y functor : Functor F functor = record { _<$>_ = λ f x → pure f ⊛ x ; isFunctor = record { identity = App.identity ; homo = λ {A} {B} {C} f g x → begin pure (f ∘ g) ⊛ x ≡⟨ cong (λ w → _⊛_ w x) (sym (App.homo (λ g → (f ∘ g)) g)) ⟩ (pure ((λ g → (f ∘ g))) ⊛ pure g) ⊛ x ≡⟨ cong (λ w → (w ⊛ pure g) ⊛ x) (sym (App.homo (λ f → _∘_ f) f)) ⟩ ((pure (λ f → _∘_ f) ⊛ pure f) ⊛ pure g) ⊛ x ≡⟨ App.compose (pure f) (pure g) x ⟩ pure f ⊛ (pure g ⊛ x) ∎ } } where open ≡-Reasoning module App = IsApplicative isApplicative instance ApplicativeFunctor : Functor F ApplicativeFunctor = functor open import Data.Product open Functor {{...}} _⊗_ : ∀ {A B} → F A → F B → F (A × B) x ⊗ y = _,_ <$> x ⊛ y zipWith : ∀ {A B C} → (A → B → C) → F A → F B → F C zipWith f x y = f <$> x ⊛ y -- open Applicative {{...}} public ---------------------------------------------------------------------- -- Monad record IsMonad {ℓ} (M : Set ℓ → Set ℓ) (return : {A : Set ℓ} → A → M A) (_>>=_ : {A B : Set ℓ} → M A → (A → M B) → M B) : Set (suc ℓ) where field left-identity : {A B : Set ℓ} (x : A) (fs : A → M B) → return x >>= fs ≡ fs x right-identity : {A : Set ℓ} (xs : M A) → xs >>= return ≡ xs assoc : {A B C : Set ℓ} (x : M A) (fs : A → M B) (g : B → M C) → (x >>= fs) >>= g ≡ (x >>= λ x' → fs x' >>= g) temp : {A B : Set ℓ} (x : A) (fs : M (A → B)) → (fs >>= λ f → return x >>= (return ∘ f)) ≡ (fs >>= λ f → (return ∘ f) x) record Monad {ℓ} (M : Set ℓ → Set ℓ) : Set (suc ℓ) where infixl 1 _>>=_ _>>_ _>=>_ infixr 1 _=<<_ _<=<_ field return : {A : Set ℓ} → A → M A _>>=_ : {A B : Set ℓ} → M A → (A → M B) → M B isMonad : IsMonad M return _>>=_ _>>_ : ∀ {A B} → M A → M B → M B m₁ >> m₂ = m₁ >>= λ _ → m₂ _=<<_ : ∀ {A B} → (A → M B) → M A → M B f =<< c = c >>= f _>=>_ : ∀ {A : Set ℓ} {B C} → (A → M B) → (B → M C) → (A → M C) f >=> g = _=<<_ g ∘ f _<=<_ : ∀ {A : Set ℓ} {B C} → (B → M C) → (A → M B) → (A → M C) g <=< f = f >=> g join : ∀ {A} → M (M A) → M A join m = m >>= id congruence : ∀ {A B : Set ℓ} (fs : M A) (g h : A → M B) → (∀ f → g f ≡ h f) → (fs >>= g) ≡ (fs >>= h) congruence fs g h prop = begin (fs >>= g) ≡⟨ sym (right-identity (fs >>= g)) ⟩ (fs >>= g >>= return) ≡⟨ assoc fs g return ⟩ (fs >>= (λ f → g f >>= return)) ≡⟨ cong (λ w → fs >>= (λ f → w f >>= return)) {! !} ⟩ (fs >>= (λ f → h f >>= return)) ≡⟨ sym (assoc fs h return) ⟩ (fs >>= h >>= return) ≡⟨ right-identity (fs >>= h) ⟩ (fs >>= h) ∎ where open ≡-Reasoning open IsMonad isMonad -- (fs >>= (λ f → return x >>= return ∘ f)) -- (fs >>= (λ f → (return ∘ f) x)) applicative : Applicative M applicative = record { pure = return ; _⊛_ = λ fs xs → fs >>= λ f → xs >>= return ∘′ f ; isApplicative = record { identity = λ xs → begin (return id >>= λ f → xs >>= λ x → return (f x)) ≡⟨ Mon.left-identity id (λ f → xs >>= λ x → return (f x)) ⟩ (xs >>= λ x → return (id x)) ≡⟨ refl ⟩ (xs >>= λ x → return x) ≡⟨ refl ⟩ (xs >>= return) ≡⟨ Mon.right-identity xs ⟩ xs ∎ -- { identity = λ xs → begin -- (do -- f ← (return id) -- x ← xs -- (return (f x))) -- ≡⟨ Mon.left-identity id (λ f → do -- x ← xs -- (return (f x))) -- ⟩ -- (do -- x ← xs -- return (id x)) -- ≡⟨ refl ⟩ -- (do -- x ← xs -- return x) -- ≡⟨ Mon.right-identity xs ⟩ -- xs -- ∎ -- left-identity : {A B : Set ℓ} (x : A) (f : A → M B) → return x >>= f ≡ f x -- right-identity : {A : Set ℓ} (xs : M A) → xs >>= return ≡ xs -- → (x >>= f) >>= g ≡ (x >>= λ x' → f x' >>= g) ; compose = λ fs gs xs → begin (return _∘′_ >>= (λ flip → fs >>= return ∘′ flip) >>= (λ f → gs >>= return ∘′ f) >>= (λ f → xs >>= return ∘′ f)) ≡⟨ cong (λ w → w >>= (λ f → gs >>= return ∘′ f) >>= (λ f → xs >>= return ∘′ f)) (Mon.left-identity _∘′_ (λ flip → fs >>= return ∘′ flip)) ⟩ (fs >>= return ∘′ _∘′_ >>= (λ f → gs >>= return ∘′ f) >>= (λ f → xs >>= return ∘′ f)) ≡⟨ Mon.assoc (fs >>= return ∘′ _∘′_) (λ f → gs >>= return ∘′ f) (λ f → xs >>= return ∘′ f) ⟩ ((fs >>= return ∘′ _∘′_) >>= (λ h → gs >>= return ∘′ h >>= λ f → xs >>= return ∘′ f)) ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ cong (λ w → fs >>= λ r → {! !}) {! !} ⟩ (fs >>= (λ f → (gs >>= λ g → xs >>= return ∘′ g) >>= return ∘′ f)) ∎ ; homo = λ f x → begin (return f >>= λ f' → return x >>= return ∘ f') ≡⟨ Mon.left-identity f (λ f' → return x >>= return ∘ f') ⟩ (return x >>= return ∘ f) ≡⟨ Mon.left-identity x (return ∘ f) ⟩ return (f x) ∎ -- left-identity : return x >>= f ≡ f x -- right-identity : xs >>= return ≡ xs -- assoc : (x >>= f) >>= g ≡ (x >>= λ x' → f x' >>= g) ; interchange = λ fs x → begin (fs >>= (λ f → return x >>= return ∘ f)) ≡⟨ congruence fs (λ f → return x >>= return ∘ f) (λ f → (return ∘ f) x) (λ f → Mon.left-identity x (return ∘ f)) ⟩ (fs >>= (λ f → (return ∘ f) x)) ≡⟨ sym (Mon.left-identity (λ f → f x) (λ f' → fs >>= (λ f → return (f' f)))) ⟩ (return (λ f → f x) >>= (λ f' → fs >>= (λ f → return (f' f)))) ∎ } } -- -- ≡⟨ sym (Mon.right-identity (fs >>= (λ f → return x >>= return ∘ f))) ⟩ -- -- (fs >>= (λ f → return x >>= return ∘ f) >>= return) -- -- ≡⟨ Mon.assoc fs (λ f → return x >>= return ∘ f) return ⟩ -- -- (fs >>= (λ f → return x >>= return ∘ f >>= return)) -- -- ≡⟨ cong (λ w → fs >>= λ f → w f >>= return) {! !} ⟩ -- ≡⟨ cong (λ w → w >>= (λ f → return x >>= return ∘ f)) (sym (Mon.right-identity fs)) ⟩ -- (fs >>= return >>= (λ f → return x >>= return ∘ f)) -- ≡⟨ Mon.assoc fs return (λ f → return x >>= return ∘ f) ⟩ -- (fs >>= λ f → return f >>= λ f → return x >>= return ∘ f) -- ≡⟨ cong (λ w → fs >>= λ f → w f) {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- (fs >>= (λ f → (return ∘ f) x >>= return)) -- ≡⟨ sym (Mon.assoc fs (λ f → return (f x)) return) ⟩ -- ((fs >>= λ f → (return ∘ f) x) >>= return) -- ≡⟨ Mon.right-identity (fs >>= λ f → return (f x)) ⟩ where open ≡-Reasoning open Applicative applicative module Mon = IsMonad isMonad -- -- lemma : {A B : Set ℓ} (x : A) → (λ f → return x >>= return ∘′ f) ≡ (λ f → return (f x)) -- lemma x = begin -- (λ f → return x >>= return ∘′ f) -- ≡⟨ cong (λ w f → w) (Mon.left-identity x (λ f → {! !})) ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- (λ f → return (f x)) -- ∎ -- begin -- (return x >>= return ∘′ f) -- ≡⟨ Mon.left-identity x (return ∘′ f) ⟩ -- return (f x) -- ∎ -- lemma : {A B : Set ℓ} (x : A) (f : A → M B) → (return x >>= return ∘′ f) ≡ return (f x) -- lemma x f = begin -- (return x >>= return ∘′ f) -- ≡⟨ Mon.left-identity x (return ∘′ f) ⟩ -- return (f x) -- ∎ -- -- rawIApplicative : RawIApplicative M -- rawIApplicative = record -- { pure = return -- ; _⊛_ = λ f x → f >>= λ f' → x >>= λ x' → return (f' x') -- }
{ "alphanum_fraction": 0.3400584019, "avg_line_length": 36.8110749186, "ext": "agda", "hexsha": "ee3a83c3347587aed30cc0db48a24965cb44319d", "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": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/FAM", "max_forks_repo_path": "src/Category/FAM.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435", "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/FAM", "max_issues_repo_path": "src/Category/FAM.agda", "max_line_length": 130, "max_stars_count": null, "max_stars_repo_head_hexsha": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/FAM", "max_stars_repo_path": "src/Category/FAM.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3921, "size": 11301 }
-- Andreas, 2020-06-21, issue #4768 -- Problem was: @0 appearing in "Not a finite domain" message. open import Agda.Builtin.Bool open import Agda.Primitive.Cubical f : (i : I) → IsOne i → Set f i (i0 = i1) = Bool -- EXPECTED: -- Not a finite domain: IsOne i -- when checking that the pattern (i0 = i1) has type IsOne i
{ "alphanum_fraction": 0.6801242236, "avg_line_length": 24.7692307692, "ext": "agda", "hexsha": "bf3faef673fd963dc2f2319dd8e63011365dc5b8", "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/Issue4768.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/Issue4768.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/Issue4768.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": 109, "size": 322 }
module ClashingImport where X = TODO--Can't-make-this-happen! postulate A : Set import Imports.A open Imports.A
{ "alphanum_fraction": 0.75, "avg_line_length": 11.6, "ext": "agda", "hexsha": "b1733bcf9e9a5dcd587aa95d7918a1e3edc5879f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/ClashingImport.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/ClashingImport.agda", "max_line_length": 33, "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/fail/ClashingImport.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": 31, "size": 116 }
{-# OPTIONS --safe #-} module Cubical.Algebra.MonoidSolver.CommSolver where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Data.FinData open import Cubical.Data.Nat using (ℕ; _+_; iter) open import Cubical.Data.Vec open import Cubical.Algebra.CommMonoid open import Cubical.Algebra.MonoidSolver.MonoidExpression private variable ℓ : Level module Eval (M : CommMonoid ℓ) where open CommMonoidStr (snd M) open CommMonoidTheory M Env : ℕ → Type ℓ Env n = Vec ⟨ M ⟩ n -- evaluation of an expression (without normalization) ⟦_⟧ : ∀{n} → Expr ⟨ M ⟩ n → Env n → ⟨ M ⟩ ⟦ ε⊗ ⟧ v = ε ⟦ ∣ i ⟧ v = lookup i v ⟦ e₁ ⊗ e₂ ⟧ v = ⟦ e₁ ⟧ v · ⟦ e₂ ⟧ v -- a normalform is a vector of multiplicities, counting the occurances of each variable in an expression NormalForm : ℕ → Type _ NormalForm n = Vec ℕ n _⊞_ : {n : ℕ} → NormalForm n → NormalForm n → NormalForm n x ⊞ y = zipWith _+_ x y emptyForm : {n : ℕ} → NormalForm n emptyForm = replicate 0 -- e[ i ] is the i-th unit vector e[_] : {n : ℕ} → Fin n → NormalForm n e[ Fin.zero ] = 1 ∷ emptyForm e[ (Fin.suc j) ] = 0 ∷ e[ j ] -- normalization of an expression normalize : {n : ℕ} → Expr ⟨ M ⟩ n → NormalForm n normalize (∣ i) = e[ i ] normalize ε⊗ = emptyForm normalize (e₁ ⊗ e₂) = (normalize e₁) ⊞ (normalize e₂) -- evaluation of normalform eval : {n : ℕ} → NormalForm n → Env n → ⟨ M ⟩ eval [] v = ε eval (x ∷ xs) (v ∷ vs) = iter x (λ w → v · w) (eval xs vs) -- some calculations emptyFormEvaluatesToε : {n : ℕ} (v : Env n) → eval emptyForm v ≡ ε emptyFormEvaluatesToε [] = refl emptyFormEvaluatesToε (v ∷ vs) = emptyFormEvaluatesToε vs UnitVecEvaluatesToVar : ∀{n} (i : Fin n) (v : Env n) → eval e[ i ] v ≡ lookup i v UnitVecEvaluatesToVar zero (v ∷ vs) = v · eval emptyForm vs ≡⟨ cong₂ _·_ refl (emptyFormEvaluatesToε vs) ⟩ v · ε ≡⟨ ·IdR _ ⟩ v ∎ UnitVecEvaluatesToVar (suc i) (v ∷ vs) = UnitVecEvaluatesToVar i vs evalIsHom : ∀ {n} (x y : NormalForm n) (v : Env n) → eval (x ⊞ y) v ≡ (eval x v) · (eval y v) evalIsHom [] [] v = sym (·IdL _) evalIsHom (x ∷ xs) (y ∷ ys) (v ∷ vs) = lemma x y (evalIsHom xs ys vs) where lemma : ∀ x y {a b c}(p : a ≡ b · c) → iter (x + y) (v ·_) a ≡ iter x (v ·_) b · iter y (v ·_) c lemma 0 0 p = p lemma 0 (ℕ.suc y) p = (cong₂ _·_ refl (lemma 0 y p)) ∙ commAssocl _ _ _ lemma (ℕ.suc x) y p = (cong₂ _·_ refl (lemma x y p)) ∙ ·Assoc _ _ _ module EqualityToNormalform (M : CommMonoid ℓ) where open Eval M open CommMonoidStr (snd M) -- proof that evaluation of an expression is invariant under normalization isEqualToNormalform : {n : ℕ} → (e : Expr ⟨ M ⟩ n) → (v : Env n) → eval (normalize e) v ≡ ⟦ e ⟧ v isEqualToNormalform ε⊗ v = emptyFormEvaluatesToε v isEqualToNormalform (∣ i) v = UnitVecEvaluatesToVar i v isEqualToNormalform (e₁ ⊗ e₂) v = eval ((normalize e₁) ⊞ (normalize e₂)) v ≡⟨ evalIsHom (normalize e₁) (normalize e₂) v ⟩ (eval (normalize e₁) v) · (eval (normalize e₂) v) ≡⟨ cong₂ _·_ (isEqualToNormalform e₁ v) (isEqualToNormalform e₂ v) ⟩ ⟦ e₁ ⟧ v · ⟦ e₂ ⟧ v ∎ solve : {n : ℕ} → (e₁ e₂ : Expr ⟨ M ⟩ n) → (v : Env n) → (p : eval (normalize e₁) v ≡ eval (normalize e₂) v) → ⟦ e₁ ⟧ v ≡ ⟦ e₂ ⟧ v solve e₁ e₂ v p = ⟦ e₁ ⟧ v ≡⟨ sym (isEqualToNormalform e₁ v) ⟩ eval (normalize e₁) v ≡⟨ p ⟩ eval (normalize e₂) v ≡⟨ isEqualToNormalform e₂ v ⟩ ⟦ e₂ ⟧ v ∎ solve : (M : CommMonoid ℓ) {n : ℕ} (e₁ e₂ : Expr ⟨ M ⟩ n) (v : Eval.Env M n) (p : Eval.eval M (Eval.normalize M e₁) v ≡ Eval.eval M (Eval.normalize M e₂) v) → _ solve M = EqualityToNormalform.solve M
{ "alphanum_fraction": 0.5687910976, "avg_line_length": 34.0862068966, "ext": "agda", "hexsha": "0fdace6c66d14d1d55030d15cc0974dacc51e9e8", "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/MonoidSolver/CommSolver.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/MonoidSolver/CommSolver.agda", "max_line_length": 122, "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/MonoidSolver/CommSolver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1480, "size": 3954 }
------------------------------------------------------------------------ -- The cubical identity type ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Equality.Id where open import Equality import Equality.Path as P open import Prelude import Agda.Builtin.Cubical.Id as Id ------------------------------------------------------------------------ -- Equality infix 4 _≡_ _≡_ : ∀ {a} {A : Type a} → A → A → Type a _≡_ = Id.Id refl : ∀ {a} {A : Type a} {x : A} → x ≡ x refl = Id.conid P.1̲ P.refl ------------------------------------------------------------------------ -- Various derived definitions and properties reflexive-relation : ∀ ℓ → Reflexive-relation ℓ Reflexive-relation._≡_ (reflexive-relation _) = _≡_ Reflexive-relation.refl (reflexive-relation _) = λ _ → refl equality-with-J₀ : ∀ {a p} → Equality-with-J₀ a p reflexive-relation Equality-with-J₀.elim equality-with-J₀ = λ P r → Id.primIdJ (λ _ → P) (r _) Equality-with-J₀.elim-refl equality-with-J₀ = λ _ _ → refl equivalence-relation⁺ : ∀ ℓ → Equivalence-relation⁺ ℓ equivalence-relation⁺ _ = J₀⇒Equivalence-relation⁺ equality-with-J₀ equality-with-paths : ∀ {a p} → P.Equality-with-paths a p equivalence-relation⁺ equality-with-paths = P.Equality-with-J₀⇒Equality-with-paths equality-with-J₀ open P.Derived-definitions-and-properties equality-with-paths public hiding (_≡_; refl; reflexive-relation; equality-with-J₀) open import Equality.Path.Isomorphisms equality-with-paths public
{ "alphanum_fraction": 0.5601996257, "avg_line_length": 32.06, "ext": "agda", "hexsha": "985f847397b0f90ddff871e24676d9ccf2f8bb1e", "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/Equality/Id.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/Equality/Id.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Equality/Id.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": 419, "size": 1603 }
-- Andreas, 2012-02-24 example by Ramana Kumar {-# OPTIONS --sized-types #-} -- {-# OPTIONS --show-implicit -v tc.size.solve:20 -v tc.conv.size:15 #-} module SizeInconsistentMeta4 where open import Data.Nat using (ℕ;zero;suc) renaming (_<_ to _N<_) open import Data.Product using (_,_;_×_) open import Data.List using (List) open import Relation.Binary using (Rel;_Respects₂_;Transitive;IsEquivalence) open import Relation.Binary.Product.StrictLex using (×-Lex;×-transitive) open import Relation.Binary.List.StrictLex using (Lex-<) renaming (transitive to Lex<-trans) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) import Level open import Size using (Size;↑_) -- keeping the definition of Vec for the positivity check infixr 5 _∷_ data Vec {a} (A : Set a) : ℕ → Set a where [] : Vec A zero _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) {- produces different error data Lex-< {A : _} (_≈_ _<_ : Rel A Level.zero) : Rel (List A) Level.zero where postulate Lex<-trans : ∀ {P _≈_ _<_} → IsEquivalence _≈_ → _<_ Respects₂ _≈_ → Transitive _<_ → Transitive (Lex-< _≈_ _<_) -} postulate N<-trans : Transitive _N<_ -- Vec : ∀ {a} (A : Set a) → ℕ → Set a Vec→List : ∀ {a n} {A : Set a} → Vec A n → List A data Type : {z : Size} → Set where TyApp : {z : Size} (n : ℕ) → (as : Vec (Type {z}) n) → Type {↑ z} infix 4 _<_ data _<_ : {z : Size} → Rel (Type {z}) Level.zero where TyApp<TyApp : ∀ {z} {n₁} {as₁} {n₂} {as₂} → ×-Lex _≡_ _N<_ (Lex-< _≡_ (_<_ {z})) (n₁ , Vec→List as₁) (n₂ , Vec→List as₂) → _<_ {↑ z} (TyApp n₁ as₁) (TyApp n₂ as₂) <-trans : {z : Size} → Transitive (_<_ {z}) <-trans (TyApp<TyApp p) (TyApp<TyApp q) = TyApp<TyApp (×-transitive PropEq.isEquivalence (PropEq.resp₂ _N<_) N<-trans {_≤₂_ = Lex-< _≡_ _<_ } (Lex<-trans PropEq.isEquivalence (PropEq.resp₂ _<_) <-trans) p q)
{ "alphanum_fraction": 0.6347080878, "avg_line_length": 40.5869565217, "ext": "agda", "hexsha": "db18b0e246607895e9db18791e76b467ec911545", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/LibSucceed/SizeInconsistentMeta4.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/LibSucceed/SizeInconsistentMeta4.agda", "max_line_length": 207, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/LibSucceed/SizeInconsistentMeta4.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": 682, "size": 1867 }
-- Andreas, 2013-12-28 -- Reported by jesper.cockx, Dec 20, 2013 -- WAS: In the following example, there is an unsolved instance -- argument, but no part of the code is highlighted. typeof : ∀ {{T : Set}} → T → Set typeof {{T}} x = T test : {A : Set} {B : Set} (y : A) → typeof y test y = y -- Should solve the instance argument, no constraint should remain.
{ "alphanum_fraction": 0.6510989011, "avg_line_length": 26, "ext": "agda", "hexsha": "80832d01b4d254fc3acc545f14dd3f60327986b2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue1003.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/Issue1003.agda", "max_line_length": 67, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/Issue1003.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 115, "size": 364 }
{-# OPTIONS --without-K --exact-split --safe #-} module 07-finite-sets where import 06-universes open 06-universes public -------------------------------------------------------------------------------- {- Section 7.1 The congruence relations -} {- Definition 7.1.1 -} -- We introduce the divisibility relation. -- div-ℕ : ℕ → ℕ → UU lzero div-ℕ m n = Σ ℕ (λ k → Id (mul-ℕ k m) n) {- Proposition 7.1.2 -} {- In the following three constructions we show that if any two of the three numbers x, y, and x + y, is divisible by d, then so is the third. -} div-add-ℕ : (d x y : ℕ) → div-ℕ d x → div-ℕ d y → div-ℕ d (add-ℕ x y) div-add-ℕ d x y (pair n p) (pair m q) = pair ( add-ℕ n m) ( ( right-distributive-mul-add-ℕ n m d) ∙ ( ap-add-ℕ p q)) div-left-summand-ℕ : (d x y : ℕ) → div-ℕ d y → div-ℕ d (add-ℕ x y) → div-ℕ d x div-left-summand-ℕ zero-ℕ x y (pair m q) (pair n p) = pair zero-ℕ ( ( inv (right-zero-law-mul-ℕ n)) ∙ ( p ∙ (ap (add-ℕ x) ((inv q) ∙ (right-zero-law-mul-ℕ m))))) div-left-summand-ℕ (succ-ℕ d) x y (pair m q) (pair n p) = pair ( dist-ℕ m n) ( is-injective-add-ℕ (mul-ℕ m (succ-ℕ d)) (mul-ℕ (dist-ℕ m n) (succ-ℕ d)) x ( ( inv ( ( right-distributive-mul-add-ℕ m (dist-ℕ m n) (succ-ℕ d)) ∙ ( commutative-add-ℕ ( mul-ℕ m (succ-ℕ d)) ( mul-ℕ (dist-ℕ m n) (succ-ℕ d))))) ∙ ( ( ap ( mul-ℕ' (succ-ℕ d)) ( leq-dist-ℕ m n ( leq-leq-mul-ℕ' m n d ( concatenate-eq-leq-eq-ℕ q ( leq-add-ℕ' y x) ( inv p))))) ∙ ( p ∙ (ap (add-ℕ x) (inv q)))))) div-right-summand-ℕ : (d x y : ℕ) → div-ℕ d x → div-ℕ d (add-ℕ x y) → div-ℕ d y div-right-summand-ℕ d x y H1 H2 = div-left-summand-ℕ d y x H1 (tr (div-ℕ d) (commutative-add-ℕ x y) H2) {- Definition 7.1.3 -} {- We define the congruence relation on ℕ and we do some bureaucracy that will help us in calculations involving the congruence relations. -} cong-ℕ : ℕ → ℕ → ℕ → UU lzero cong-ℕ k x y = div-ℕ k (dist-ℕ x y) _≡_mod_ : ℕ → ℕ → ℕ → UU lzero x ≡ y mod k = cong-ℕ k x y concatenate-eq-cong-eq-ℕ : (k : ℕ) {x1 x2 x3 x4 : ℕ} → Id x1 x2 → cong-ℕ k x2 x3 → Id x3 x4 → cong-ℕ k x1 x4 concatenate-eq-cong-eq-ℕ k refl H refl = H concatenate-eq-cong-ℕ : (k : ℕ) {x1 x2 x3 : ℕ} → Id x1 x2 → cong-ℕ k x2 x3 → cong-ℕ k x1 x3 concatenate-eq-cong-ℕ k refl H = H concatenate-cong-eq-ℕ : (k : ℕ) {x1 x2 x3 : ℕ} → cong-ℕ k x1 x2 → Id x2 x3 → cong-ℕ k x1 x3 concatenate-cong-eq-ℕ k H refl = H {- Proposition 7.1.4 -} -- We show that cong-ℕ is an equivalence relation. reflexive-cong-ℕ : (k x : ℕ) → cong-ℕ k x x reflexive-cong-ℕ k x = pair zero-ℕ ((left-zero-law-mul-ℕ (succ-ℕ k)) ∙ (dist-eq-ℕ x x refl)) cong-identification-ℕ : (k : ℕ) {x y : ℕ} → Id x y → cong-ℕ k x y cong-identification-ℕ k {x} refl = reflexive-cong-ℕ k x symmetric-cong-ℕ : (k x y : ℕ) → cong-ℕ k x y → cong-ℕ k y x symmetric-cong-ℕ k x y (pair d p) = pair d (p ∙ (symmetric-dist-ℕ x y)) {- Before we show that cong-ℕ is transitive, we give some lemmas that will help us showing that cong is an equivalence relation. They are basically bureaucracy, manipulating already known facts. -} -- Three elements can be ordered in 6 possible ways cases-order-three-elements-ℕ : (x y z : ℕ) → UU lzero cases-order-three-elements-ℕ x y z = coprod ( coprod ((leq-ℕ x y) × (leq-ℕ y z)) ((leq-ℕ x z) × (leq-ℕ z y))) ( coprod ( coprod ((leq-ℕ y z) × (leq-ℕ z x)) ((leq-ℕ y x) × (leq-ℕ x z))) ( coprod ((leq-ℕ z x) × (leq-ℕ x y)) ((leq-ℕ z y) × (leq-ℕ y x)))) order-three-elements-ℕ : (x y z : ℕ) → cases-order-three-elements-ℕ x y z order-three-elements-ℕ zero-ℕ zero-ℕ zero-ℕ = inl (inl (pair star star)) order-three-elements-ℕ zero-ℕ zero-ℕ (succ-ℕ z) = inl (inl (pair star star)) order-three-elements-ℕ zero-ℕ (succ-ℕ y) zero-ℕ = inl (inr (pair star star)) order-three-elements-ℕ zero-ℕ (succ-ℕ y) (succ-ℕ z) = inl (functor-coprod (pair star) (pair star) (decide-leq-ℕ y z)) order-three-elements-ℕ (succ-ℕ x) zero-ℕ zero-ℕ = inr (inl (inl (pair star star))) order-three-elements-ℕ (succ-ℕ x) zero-ℕ (succ-ℕ z) = inr (inl (functor-coprod (pair star) (pair star) (decide-leq-ℕ z x))) order-three-elements-ℕ (succ-ℕ x) (succ-ℕ y) zero-ℕ = inr (inr (functor-coprod (pair star) (pair star) (decide-leq-ℕ x y))) order-three-elements-ℕ (succ-ℕ x) (succ-ℕ y) (succ-ℕ z) = order-three-elements-ℕ x y z {- We show that the distances of any three elements always add up, when they are added up in the right way :) -} cases-dist-ℕ : (x y z : ℕ) → UU lzero cases-dist-ℕ x y z = coprod ( Id (add-ℕ (dist-ℕ x y) (dist-ℕ y z)) (dist-ℕ x z)) ( coprod ( Id (add-ℕ (dist-ℕ y z) (dist-ℕ x z)) (dist-ℕ x y)) ( Id (add-ℕ (dist-ℕ x z) (dist-ℕ x y)) (dist-ℕ y z))) is-total-dist-ℕ : (x y z : ℕ) → cases-dist-ℕ x y z is-total-dist-ℕ x y z with order-three-elements-ℕ x y z is-total-dist-ℕ x y z | inl (inl (pair H1 H2)) = inl (triangle-equality-dist-ℕ x y z H1 H2) is-total-dist-ℕ x y z | inl (inr (pair H1 H2)) = inr ( inl ( ( commutative-add-ℕ (dist-ℕ y z) (dist-ℕ x z)) ∙ ( ( ap (add-ℕ (dist-ℕ x z)) (symmetric-dist-ℕ y z)) ∙ ( triangle-equality-dist-ℕ x z y H1 H2)))) is-total-dist-ℕ x y z | inr (inl (inl (pair H1 H2))) = inr ( inl ( ( ap (add-ℕ (dist-ℕ y z)) (symmetric-dist-ℕ x z)) ∙ ( ( triangle-equality-dist-ℕ y z x H1 H2) ∙ ( symmetric-dist-ℕ y x)))) is-total-dist-ℕ x y z | inr (inl (inr (pair H1 H2))) = inr ( inr ( ( ap (add-ℕ (dist-ℕ x z)) (symmetric-dist-ℕ x y)) ∙ ( ( commutative-add-ℕ (dist-ℕ x z) (dist-ℕ y x)) ∙ ( triangle-equality-dist-ℕ y x z H1 H2)))) is-total-dist-ℕ x y z | inr (inr (inl (pair H1 H2))) = inr ( inr ( ( ap (add-ℕ' (dist-ℕ x y)) (symmetric-dist-ℕ x z)) ∙ ( ( triangle-equality-dist-ℕ z x y H1 H2) ∙ ( symmetric-dist-ℕ z y)))) is-total-dist-ℕ x y z | inr (inr (inr (pair H1 H2))) = inl ( ( ap-add-ℕ (symmetric-dist-ℕ x y) (symmetric-dist-ℕ y z)) ∙ ( ( commutative-add-ℕ (dist-ℕ y x) (dist-ℕ z y)) ∙ ( ( triangle-equality-dist-ℕ z y x H1 H2) ∙ ( symmetric-dist-ℕ z x)))) -- Finally, we show that cong-ℕ is transitive. transitive-cong-ℕ : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k y z → cong-ℕ k x z transitive-cong-ℕ k x y z d e with is-total-dist-ℕ x y z transitive-cong-ℕ k x y z d e | inl α = tr (div-ℕ k) α (div-add-ℕ k (dist-ℕ x y) (dist-ℕ y z) d e) transitive-cong-ℕ k x y z d e | inr (inl α) = div-right-summand-ℕ k (dist-ℕ y z) (dist-ℕ x z) e (tr (div-ℕ k) (inv α) d) transitive-cong-ℕ k x y z d e | inr (inr α) = div-left-summand-ℕ k (dist-ℕ x z) (dist-ℕ x y) d (tr (div-ℕ k) (inv α) e) concatenate-cong-eq-cong-ℕ : {k x1 x2 x3 x4 : ℕ} → cong-ℕ k x1 x2 → Id x2 x3 → cong-ℕ k x3 x4 → cong-ℕ k x1 x4 concatenate-cong-eq-cong-ℕ {k} {x} {y} {.y} {z} H refl K = transitive-cong-ℕ k x y z H K concatenate-eq-cong-eq-cong-eq-ℕ : (k : ℕ) {x1 x2 x3 x4 x5 x6 : ℕ} → Id x1 x2 → cong-ℕ k x2 x3 → Id x3 x4 → cong-ℕ k x4 x5 → Id x5 x6 → cong-ℕ k x1 x6 concatenate-eq-cong-eq-cong-eq-ℕ k {x} {.x} {y} {.y} {z} {.z} refl H refl K refl = transitive-cong-ℕ k x y z H K {- Remark 7.1.6 (this is also Exercise 7.2) -} -- We show that cong-ℕ one-ℕ is the indiscrete equivalence relation -- div-one-ℕ : (x : ℕ) → div-ℕ one-ℕ x div-one-ℕ x = pair x (right-unit-law-mul-ℕ x) is-indiscrete-cong-one-ℕ : (x y : ℕ) → cong-ℕ one-ℕ x y is-indiscrete-cong-one-ℕ x y = div-one-ℕ (dist-ℕ x y) -- We show that the congruence relation modulo 0 is discrete div-zero-ℕ : (k : ℕ) → div-ℕ k zero-ℕ div-zero-ℕ k = pair zero-ℕ (left-zero-law-mul-ℕ k) is-discrete-cong-zero-ℕ : (x y : ℕ) → cong-ℕ zero-ℕ x y → Id x y is-discrete-cong-zero-ℕ x y (pair k p) = eq-dist-ℕ x y ((inv (right-zero-law-mul-ℕ k)) ∙ p) -- We show that d | 1 if and only if d = 1. -- We show that 0 | x if and only if x = 0. -- We show that zero-ℕ is congruent to n modulo n. cong-zero-ℕ : (k : ℕ) → cong-ℕ k k zero-ℕ cong-zero-ℕ k = pair one-ℕ ((left-unit-law-mul-ℕ k) ∙ (inv (right-zero-law-dist-ℕ k))) cong-zero-ℕ' : (k : ℕ) → cong-ℕ k zero-ℕ k cong-zero-ℕ' k = symmetric-cong-ℕ k k zero-ℕ (cong-zero-ℕ k) -------------------------------------------------------------------------------- {- Section 7.2 The finite types -} {- Definition 7.2.1 -} -- We introduce the finite types as a family indexed by ℕ. Fin : ℕ → UU lzero Fin zero-ℕ = empty Fin (succ-ℕ k) = coprod (Fin k) unit inl-Fin : (k : ℕ) → Fin k → Fin (succ-ℕ k) inl-Fin k = inl neg-one-Fin : {k : ℕ} → Fin (succ-ℕ k) neg-one-Fin {k} = inr star {- Definition 7.2.4 -} -- We define the inclusion of Fin k into ℕ. nat-Fin : {k : ℕ} → Fin k → ℕ nat-Fin {succ-ℕ k} (inl x) = nat-Fin x nat-Fin {succ-ℕ k} (inr x) = k {- Lemma 7.2.5 -} -- We show that nat-Fin is bounded strict-upper-bound-nat-Fin : {k : ℕ} (x : Fin k) → le-ℕ (nat-Fin x) k strict-upper-bound-nat-Fin {succ-ℕ k} (inl x) = transitive-le-ℕ ( nat-Fin x) ( k) ( succ-ℕ k) ( strict-upper-bound-nat-Fin x) ( succ-le-ℕ k) strict-upper-bound-nat-Fin {succ-ℕ k} (inr star) = succ-le-ℕ k -- We also give a non-strict upper bound for convenience upper-bound-nat-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → leq-ℕ (nat-Fin x) k upper-bound-nat-Fin {zero-ℕ} (inr star) = star upper-bound-nat-Fin {succ-ℕ k} (inl x) = preserves-leq-succ-ℕ (nat-Fin x) k (upper-bound-nat-Fin x) upper-bound-nat-Fin {succ-ℕ k} (inr star) = reflexive-leq-ℕ (succ-ℕ k) {- Proposition 7.2.6 -} -- We show that nat-Fin is an injective function neq-le-ℕ : {x y : ℕ} → le-ℕ x y → ¬ (Id x y) neq-le-ℕ {zero-ℕ} {succ-ℕ y} H = Peano-8 y neq-le-ℕ {succ-ℕ x} {succ-ℕ y} H p = neq-le-ℕ H (is-injective-succ-ℕ x y p) is-injective-nat-Fin : {k : ℕ} {x y : Fin k} → Id (nat-Fin x) (nat-Fin y) → Id x y is-injective-nat-Fin {succ-ℕ k} {inl x} {inl y} p = ap inl (is-injective-nat-Fin p) is-injective-nat-Fin {succ-ℕ k} {inl x} {inr star} p = ex-falso (neq-le-ℕ (strict-upper-bound-nat-Fin x) p) is-injective-nat-Fin {succ-ℕ k} {inr star} {inl y} p = ex-falso (neq-le-ℕ (strict-upper-bound-nat-Fin y) (inv p)) is-injective-nat-Fin {succ-ℕ k} {inr star} {inr star} p = refl {- Definition 7.2.7 -} -- We define the zero element of Fin k. zero-Fin : {k : ℕ} → Fin (succ-ℕ k) zero-Fin {zero-ℕ} = inr star zero-Fin {succ-ℕ k} = inl zero-Fin -- We define a function skip-zero-Fin in order to define succ-Fin. skip-zero-Fin : {k : ℕ} → Fin k → Fin (succ-ℕ k) skip-zero-Fin {succ-ℕ k} (inl x) = inl (skip-zero-Fin x) skip-zero-Fin {succ-ℕ k} (inr star) = inr star -- We define the successor function on Fin k. succ-Fin : {k : ℕ} → Fin k → Fin k succ-Fin {succ-ℕ k} (inl x) = skip-zero-Fin x succ-Fin {succ-ℕ k} (inr star) = zero-Fin {- Definition 7.2.8 -} -- We define the negative two element of Fin k. neg-two-Fin : {k : ℕ} → Fin (succ-ℕ k) neg-two-Fin {zero-ℕ} = inr star neg-two-Fin {succ-ℕ k} = inl (inr star) -- We define a function skip-neg-two-Fin in order to define pred-Fin. skip-neg-two-Fin : {k : ℕ} → Fin k → Fin (succ-ℕ k) skip-neg-two-Fin {succ-ℕ k} (inl x) = inl (inl x) skip-neg-two-Fin {succ-ℕ k} (inr x) = neg-one-Fin {succ-ℕ k} -- We define the predecessor function on Fin k. pred-Fin : {k : ℕ} → Fin k → Fin k pred-Fin {succ-ℕ k} (inl x) = skip-neg-two-Fin (pred-Fin x) pred-Fin {succ-ℕ k} (inr x) = neg-two-Fin {- Definition 7.2.9 -} -- We define the modulo function mod-succ-ℕ : (k : ℕ) → ℕ → Fin (succ-ℕ k) mod-succ-ℕ k zero-ℕ = zero-Fin mod-succ-ℕ k (succ-ℕ n) = succ-Fin (mod-succ-ℕ k n) mod-two-ℕ : ℕ → Fin two-ℕ mod-two-ℕ = mod-succ-ℕ one-ℕ mod-three-ℕ : ℕ → Fin three-ℕ mod-three-ℕ = mod-succ-ℕ two-ℕ {- Lemma 7.2.10 -} successor-law-mod-succ-ℕ : (k x : ℕ) → leq-ℕ x k → Id (mod-succ-ℕ (succ-ℕ k) x) (inl (mod-succ-ℕ k x)) successor-law-mod-succ-ℕ k zero-ℕ star = refl successor-law-mod-succ-ℕ (succ-ℕ k) (succ-ℕ x) p = ( ( ap succ-Fin ( successor-law-mod-succ-ℕ (succ-ℕ k) x ( preserves-leq-succ-ℕ x k p))) ∙ ( ap succ-Fin (ap inl (successor-law-mod-succ-ℕ k x p)))) ∙ ( ap inl (ap succ-Fin (inv (successor-law-mod-succ-ℕ k x p)))) {- Corollary 7.2.11 -} neg-one-law-mod-succ-ℕ : (k : ℕ) → Id (mod-succ-ℕ k k) neg-one-Fin neg-one-law-mod-succ-ℕ zero-ℕ = refl neg-one-law-mod-succ-ℕ (succ-ℕ k) = ap succ-Fin ( ( successor-law-mod-succ-ℕ k k (reflexive-leq-ℕ k)) ∙ ( ap inl (neg-one-law-mod-succ-ℕ k))) base-case-is-periodic-mod-succ-ℕ : (k : ℕ) → Id (mod-succ-ℕ k (succ-ℕ k)) zero-Fin base-case-is-periodic-mod-succ-ℕ zero-ℕ = refl base-case-is-periodic-mod-succ-ℕ (succ-ℕ k) = ap succ-Fin (neg-one-law-mod-succ-ℕ (succ-ℕ k)) {- Theorem 7.2.12 -} -- Now we show that Fin (succ-ℕ k) is a retract of ℕ issec-nat-Fin : (k : ℕ) (x : Fin (succ-ℕ k)) → Id (mod-succ-ℕ k (nat-Fin x)) x issec-nat-Fin zero-ℕ (inr star) = refl issec-nat-Fin (succ-ℕ k) (inl x) = ( successor-law-mod-succ-ℕ k (nat-Fin x) (upper-bound-nat-Fin x)) ∙ ( ap inl (issec-nat-Fin k x)) issec-nat-Fin (succ-ℕ k) (inr star) = neg-one-law-mod-succ-ℕ (succ-ℕ k) -------------------------------------------------------------------------------- {- Section 7.3 The effectiveness theorem of modular arithmetic -} {- Lemma 7.3.1 -} -- We prove three things to help calculating with nat-Fin. nat-zero-Fin : {k : ℕ} → Id (nat-Fin (zero-Fin {k})) zero-ℕ nat-zero-Fin {zero-ℕ} = refl nat-zero-Fin {succ-ℕ k} = nat-zero-Fin {k} nat-skip-zero-Fin : {k : ℕ} (x : Fin k) → Id (nat-Fin (skip-zero-Fin x)) (succ-ℕ (nat-Fin x)) nat-skip-zero-Fin {succ-ℕ k} (inl x) = nat-skip-zero-Fin x nat-skip-zero-Fin {succ-ℕ k} (inr star) = refl cong-nat-succ-Fin : (k : ℕ) (x : Fin k) → cong-ℕ k (nat-Fin (succ-Fin x)) (succ-ℕ (nat-Fin x)) cong-nat-succ-Fin (succ-ℕ k) (inl x) = cong-identification-ℕ ( succ-ℕ k) { nat-Fin (succ-Fin (inl x))} { succ-ℕ (nat-Fin x)} ( nat-skip-zero-Fin x) cong-nat-succ-Fin (succ-ℕ k) (inr star) = concatenate-eq-cong-ℕ ( succ-ℕ k) { nat-Fin {succ-ℕ k} zero-Fin} { zero-ℕ} { succ-ℕ k} ( nat-zero-Fin {k}) ( cong-zero-ℕ' (succ-ℕ k)) {- Corollary 7.3.2 -} -- We show that (nat-Fin (mod-succ-ℕ n x)) is congruent to x modulo n+1. -- cong-nat-mod-succ-ℕ : (k x : ℕ) → cong-ℕ (succ-ℕ k) (nat-Fin (mod-succ-ℕ k x)) x cong-nat-mod-succ-ℕ k zero-ℕ = cong-identification-ℕ (succ-ℕ k) (nat-zero-Fin {k}) cong-nat-mod-succ-ℕ k (succ-ℕ x) = transitive-cong-ℕ ( succ-ℕ k) ( nat-Fin (mod-succ-ℕ k (succ-ℕ x))) ( succ-ℕ (nat-Fin (mod-succ-ℕ k x))) ( succ-ℕ x) ( cong-nat-succ-Fin (succ-ℕ k) (mod-succ-ℕ k x) ) ( cong-nat-mod-succ-ℕ k x) {- Proposition 7.3.4 -} contradiction-leq-ℕ : (x y : ℕ) → leq-ℕ x y → leq-ℕ (succ-ℕ y) x → empty contradiction-leq-ℕ (succ-ℕ x) (succ-ℕ y) H K = contradiction-leq-ℕ x y H K eq-zero-div-ℕ : (d x : ℕ) → leq-ℕ x d → div-ℕ (succ-ℕ d) x → Id x zero-ℕ eq-zero-div-ℕ d zero-ℕ H D = refl eq-zero-div-ℕ d (succ-ℕ x) H (pair (succ-ℕ k) p) = ex-falso ( contradiction-leq-ℕ d x ( concatenate-eq-leq-eq-ℕ { x1 = succ-ℕ d} { x2 = succ-ℕ d} { x3 = succ-ℕ (add-ℕ (mul-ℕ k (succ-ℕ d)) d)} { x4 = succ-ℕ x} ( refl) ( leq-add-ℕ' d (mul-ℕ k (succ-ℕ d))) ( p)) H) {- Theorem 7.3.5 -} {- We show that if mod-succ-ℕ k x = mod-succ-ℕ k y, then x and y must be congruent modulo succ-ℕ n. This is the forward direction of the theorm. -} cong-eq-ℕ : (k x y : ℕ) → Id (mod-succ-ℕ k x) (mod-succ-ℕ k y) → cong-ℕ (succ-ℕ k) x y cong-eq-ℕ k x y p = concatenate-cong-eq-cong-ℕ {succ-ℕ k} {x} ( symmetric-cong-ℕ (succ-ℕ k) (nat-Fin (mod-succ-ℕ k x)) x ( cong-nat-mod-succ-ℕ k x)) ( ap nat-Fin p) ( cong-nat-mod-succ-ℕ k y) eq-cong-nat-Fin : (k : ℕ) (x y : Fin k) → cong-ℕ k (nat-Fin x) (nat-Fin y) → Id x y eq-cong-nat-Fin (succ-ℕ k) x y H = is-injective-nat-Fin ( eq-dist-ℕ ( nat-Fin x) ( nat-Fin y) ( inv ( eq-zero-div-ℕ k ( dist-ℕ (nat-Fin x) (nat-Fin y)) ( upper-bound-dist-ℕ k ( nat-Fin x) ( nat-Fin y) ( upper-bound-nat-Fin x) ( upper-bound-nat-Fin y)) ( H)))) eq-cong-ℕ : (k x y : ℕ) → cong-ℕ (succ-ℕ k) x y → Id (mod-succ-ℕ k x) (mod-succ-ℕ k y) eq-cong-ℕ k x y H = eq-cong-nat-Fin ( succ-ℕ k) ( mod-succ-ℕ k x) ( mod-succ-ℕ k y) ( transitive-cong-ℕ ( succ-ℕ k) ( nat-Fin (mod-succ-ℕ k x)) ( x) ( nat-Fin (mod-succ-ℕ k y)) ( cong-nat-mod-succ-ℕ k x) ( transitive-cong-ℕ (succ-ℕ k) x y (nat-Fin (mod-succ-ℕ k y)) H ( symmetric-cong-ℕ (succ-ℕ k) (nat-Fin (mod-succ-ℕ k y)) y ( cong-nat-mod-succ-ℕ k y)))) -------------------------------------------------------------------------------- {- Section 7.4 The cyclic group structure on the finite types -} {- Definition 7.4.1 -} -- Addition on finite sets -- add-Fin : {k : ℕ} → Fin k → Fin k → Fin k add-Fin {succ-ℕ k} x y = mod-succ-ℕ k (add-ℕ (nat-Fin x) (nat-Fin y)) add-Fin' : {k : ℕ} → Fin k → Fin k → Fin k add-Fin' x y = add-Fin y x -- We define an action on paths of add-Fin on the two arguments at once. ap-add-Fin : {k : ℕ} {x y x' y' : Fin k} → Id x x' → Id y y' → Id (add-Fin x y) (add-Fin x' y') ap-add-Fin refl refl = refl -- The negative of an element of Fin k -- neg-Fin : {k : ℕ} → Fin k → Fin k neg-Fin {succ-ℕ k} x = mod-succ-ℕ k (dist-ℕ (nat-Fin x) (succ-ℕ k)) {- Remark 7.4.2 -} cong-nat-zero-Fin : {k : ℕ} → cong-ℕ (succ-ℕ k) (nat-Fin (zero-Fin {k})) zero-ℕ cong-nat-zero-Fin {k} = cong-nat-mod-succ-ℕ k zero-ℕ cong-add-Fin : {k : ℕ} (x y : Fin k) → cong-ℕ k (nat-Fin (add-Fin x y)) (add-ℕ (nat-Fin x) (nat-Fin y)) cong-add-Fin {succ-ℕ k} x y = cong-nat-mod-succ-ℕ k (add-ℕ (nat-Fin x) (nat-Fin y)) cong-neg-Fin : {k : ℕ} (x : Fin k) → cong-ℕ k (nat-Fin (neg-Fin x)) (dist-ℕ (nat-Fin x) k) cong-neg-Fin {succ-ℕ k} x = cong-nat-mod-succ-ℕ k (dist-ℕ (nat-Fin x) (succ-ℕ k)) {- Proposition 7.4.3 -} -- We show that congruence is translation invariant -- translation-invariant-cong-ℕ : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (add-ℕ z x) (add-ℕ z y) translation-invariant-cong-ℕ k x y z (pair d p) = pair d (p ∙ inv (translation-invariant-dist-ℕ z x y)) translation-invariant-cong-ℕ' : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (add-ℕ x z) (add-ℕ y z) translation-invariant-cong-ℕ' k x y z H = concatenate-eq-cong-eq-ℕ k ( commutative-add-ℕ x z) ( translation-invariant-cong-ℕ k x y z H) ( commutative-add-ℕ z y) step-invariant-cong-ℕ : (k x y : ℕ) → cong-ℕ k x y → cong-ℕ k (succ-ℕ x) (succ-ℕ y) step-invariant-cong-ℕ k x y = translation-invariant-cong-ℕ' k x y one-ℕ -- We show that addition respects the congruence relation -- congruence-add-ℕ : (k : ℕ) {x y x' y' : ℕ} → cong-ℕ k x x' → cong-ℕ k y y' → cong-ℕ k (add-ℕ x y) (add-ℕ x' y') congruence-add-ℕ k {x} {y} {x'} {y'} H K = transitive-cong-ℕ k (add-ℕ x y) (add-ℕ x y') (add-ℕ x' y') ( translation-invariant-cong-ℕ k y y' x K) ( translation-invariant-cong-ℕ' k x x' y' H) {- Theorem 7.4.4 -} -- We show that addition is commutative -- commutative-add-Fin : {k : ℕ} (x y : Fin k) → Id (add-Fin x y) (add-Fin y x) commutative-add-Fin {succ-ℕ k} x y = ap (mod-succ-ℕ k) (commutative-add-ℕ (nat-Fin x) (nat-Fin y)) -- We show that addition is associative -- associative-add-Fin : {k : ℕ} (x y z : Fin k) → Id (add-Fin (add-Fin x y) z) (add-Fin x (add-Fin y z)) associative-add-Fin {succ-ℕ k} x y z = eq-cong-ℕ k ( add-ℕ (nat-Fin (add-Fin x y)) (nat-Fin z)) ( add-ℕ (nat-Fin x) (nat-Fin (add-Fin y z))) ( concatenate-cong-eq-cong-ℕ { x1 = add-ℕ (nat-Fin (add-Fin x y)) (nat-Fin z)} { x2 = add-ℕ (add-ℕ (nat-Fin x) (nat-Fin y)) (nat-Fin z)} { x3 = add-ℕ (nat-Fin x) (add-ℕ (nat-Fin y) (nat-Fin z))} { x4 = add-ℕ (nat-Fin x) (nat-Fin (add-Fin y z))} ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin (add-Fin x y)} { y = nat-Fin z} { x' = add-ℕ (nat-Fin x) (nat-Fin y)} { y' = nat-Fin z} ( cong-add-Fin x y) ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin z))) ( associative-add-ℕ (nat-Fin x) (nat-Fin y) (nat-Fin z)) ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin x} { y = add-ℕ (nat-Fin y) (nat-Fin z)} { x' = nat-Fin x} { y' = nat-Fin (add-Fin y z)} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x)) ( symmetric-cong-ℕ ( succ-ℕ k) ( nat-Fin (add-Fin y z)) ( add-ℕ (nat-Fin y) (nat-Fin z)) ( cong-add-Fin y z)))) -- We show that addition satisfies the right unit law -- right-unit-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin x zero-Fin) x right-unit-law-add-Fin {k} x = ( eq-cong-ℕ k ( add-ℕ (nat-Fin x) (nat-Fin {succ-ℕ k} zero-Fin)) ( add-ℕ (nat-Fin x) zero-ℕ) ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin {succ-ℕ k} x} { y = nat-Fin {succ-ℕ k} zero-Fin} { x' = nat-Fin x} { y' = zero-ℕ} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin {succ-ℕ k} x)) ( cong-nat-zero-Fin {k}))) ∙ ( issec-nat-Fin k x) left-unit-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin zero-Fin x) x left-unit-law-add-Fin {k} x = ( commutative-add-Fin zero-Fin x) ∙ ( right-unit-law-add-Fin x) -- We show that addition satisfies the left inverse law -- left-inverse-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin (neg-Fin x) x) zero-Fin left-inverse-law-add-Fin {k} x = eq-cong-ℕ k (add-ℕ (nat-Fin (neg-Fin x)) (nat-Fin x)) zero-ℕ ( concatenate-cong-eq-cong-ℕ { succ-ℕ k} { x1 = add-ℕ (nat-Fin (neg-Fin x)) (nat-Fin x)} { x2 = add-ℕ (dist-ℕ (nat-Fin x) (succ-ℕ k)) (nat-Fin x)} { x3 = succ-ℕ k} { x4 = zero-ℕ} ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin (neg-Fin x)} { y = nat-Fin x} ( cong-neg-Fin x) ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x))) ( ( ap ( add-ℕ (dist-ℕ (nat-Fin x) (succ-ℕ k))) ( inv (left-zero-law-dist-ℕ (nat-Fin x)))) ∙ ( ( commutative-add-ℕ ( dist-ℕ (nat-Fin x) (succ-ℕ k)) ( dist-ℕ zero-ℕ (nat-Fin x))) ∙ ( triangle-equality-dist-ℕ zero-ℕ (nat-Fin x) (succ-ℕ k) star ( preserves-leq-succ-ℕ (nat-Fin x) k (upper-bound-nat-Fin x))))) ( symmetric-cong-ℕ ( succ-ℕ k) ( zero-ℕ) ( succ-ℕ k) ( cong-zero-ℕ (succ-ℕ k)))) right-inverse-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin x (neg-Fin x)) zero-Fin right-inverse-law-add-Fin x = ( commutative-add-Fin x (neg-Fin x)) ∙ (left-inverse-law-add-Fin x) -------------------------------------------------------------------------------- {- Exercises -} {- Exercise 7.1 -} -- See Proposition 7.1.2 {- Exercise 7.2 -} {- Exercise 7.3 -} {- Exercise 7.4 -} {- Exercise 7.5 -} {- Exercise 7.6 -} {- Exercise 7.7 -} pred-zero-Fin : {k : ℕ} → Id (pred-Fin {succ-ℕ k} zero-Fin) neg-one-Fin pred-zero-Fin {zero-ℕ} = refl pred-zero-Fin {succ-ℕ k} = ap skip-neg-two-Fin (pred-zero-Fin {k}) succ-skip-neg-two-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (succ-Fin (skip-neg-two-Fin x)) (inl (succ-Fin x)) succ-skip-neg-two-Fin {zero-ℕ} (inr star) = refl succ-skip-neg-two-Fin {succ-ℕ k} (inl x) = refl succ-skip-neg-two-Fin {succ-ℕ k} (inr star) = refl succ-pred-Fin : {k : ℕ} (x : Fin k) → Id (succ-Fin (pred-Fin x)) x succ-pred-Fin {succ-ℕ zero-ℕ} (inr star) = refl succ-pred-Fin {succ-ℕ (succ-ℕ k)} (inl x) = succ-skip-neg-two-Fin (pred-Fin x) ∙ ap inl (succ-pred-Fin x) succ-pred-Fin {succ-ℕ (succ-ℕ k)} (inr star) = refl pred-succ-Fin : {k : ℕ} (x : Fin k) → Id (pred-Fin (succ-Fin x)) x pred-succ-Fin {succ-ℕ zero-ℕ} (inr star) = refl pred-succ-Fin {succ-ℕ (succ-ℕ k)} (inl (inl x)) = ap skip-neg-two-Fin (pred-succ-Fin (inl x)) pred-succ-Fin {succ-ℕ (succ-ℕ k)} (inl (inr star)) = refl pred-succ-Fin {succ-ℕ (succ-ℕ k)} (inr star) = pred-zero-Fin {- Exercise 7.8 -} {- Exercise 7.9 -} reverse-Fin : {k : ℕ} → Fin k → Fin k reverse-Fin {succ-ℕ k} (inl x) = skip-zero-Fin (reverse-Fin x) reverse-Fin {succ-ℕ k} (inr x) = zero-Fin reverse-skip-zero-Fin : {k : ℕ} (x : Fin k) → Id (reverse-Fin (skip-zero-Fin x)) (inl-Fin k (reverse-Fin x)) reverse-skip-zero-Fin {succ-ℕ k} (inl x) = ap skip-zero-Fin (reverse-skip-zero-Fin x) reverse-skip-zero-Fin {succ-ℕ k} (inr star) = refl reverse-neg-one-Fin : {k : ℕ} → Id (reverse-Fin (neg-one-Fin {k})) (zero-Fin {k}) reverse-neg-one-Fin {k} = refl reverse-zero-Fin : {k : ℕ} → Id (reverse-Fin (zero-Fin {k})) (neg-one-Fin {k}) reverse-zero-Fin {zero-ℕ} = refl reverse-zero-Fin {succ-ℕ k} = ap skip-zero-Fin (reverse-zero-Fin {k}) reverse-reverse-Fin : {k : ℕ} (x : Fin k) → Id (reverse-Fin (reverse-Fin x)) x reverse-reverse-Fin {succ-ℕ k} (inl x) = ( reverse-skip-zero-Fin (reverse-Fin x)) ∙ ( ap inl (reverse-reverse-Fin x)) reverse-reverse-Fin {succ-ℕ k} (inr star) = reverse-zero-Fin {- Exercise 7.10 -} -- We show that congruence is invariant under scalar multiplication -- scalar-invariant-cong-ℕ : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (mul-ℕ z x) (mul-ℕ z y) scalar-invariant-cong-ℕ k x y z (pair d p) = pair ( mul-ℕ z d) ( ( associative-mul-ℕ z d k) ∙ ( ( ap (mul-ℕ z) p) ∙ ( inv (linear-dist-ℕ x y z)))) scalar-invariant-cong-ℕ' : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (mul-ℕ x z) (mul-ℕ y z) scalar-invariant-cong-ℕ' k x y z H = concatenate-eq-cong-eq-ℕ k ( commutative-mul-ℕ x z) ( scalar-invariant-cong-ℕ k x y z H) ( commutative-mul-ℕ z y) -- We show that multiplication respects the congruence relation -- congruence-mul-ℕ : (k : ℕ) {x y x' y' : ℕ} → cong-ℕ k x x' → cong-ℕ k y y' → cong-ℕ k (mul-ℕ x y) (mul-ℕ x' y') congruence-mul-ℕ k {x} {y} {x'} {y'} H K = transitive-cong-ℕ k (mul-ℕ x y) (mul-ℕ x y') (mul-ℕ x' y') ( scalar-invariant-cong-ℕ k y y' x K) ( scalar-invariant-cong-ℕ' k x x' y' H) {- We define the multiplication on the types Fin k. -} mul-Fin : {k : ℕ} → Fin k → Fin k → Fin k mul-Fin {succ-ℕ k} x y = mod-succ-ℕ k (mul-ℕ (nat-Fin x) (nat-Fin y)) ap-mul-Fin : {k : ℕ} {x y x' y' : Fin k} → Id x x' → Id y y' → Id (mul-Fin x y) (mul-Fin x' y') ap-mul-Fin refl refl = refl cong-mul-Fin : {k : ℕ} (x y : Fin k) → cong-ℕ k (nat-Fin (mul-Fin x y)) (mul-ℕ (nat-Fin x) (nat-Fin y)) cong-mul-Fin {succ-ℕ k} x y = cong-nat-mod-succ-ℕ k (mul-ℕ (nat-Fin x) (nat-Fin y)) associative-mul-Fin : {k : ℕ} (x y z : Fin k) → Id (mul-Fin (mul-Fin x y) z) (mul-Fin x (mul-Fin y z)) associative-mul-Fin {succ-ℕ k} x y z = eq-cong-ℕ k ( mul-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin z)) ( mul-ℕ (nat-Fin x) (nat-Fin (mul-Fin y z))) ( concatenate-cong-eq-cong-ℕ { x1 = mul-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin z)} { x2 = mul-ℕ (mul-ℕ (nat-Fin x) (nat-Fin y)) (nat-Fin z)} { x3 = mul-ℕ (nat-Fin x) (mul-ℕ (nat-Fin y) (nat-Fin z))} { x4 = mul-ℕ (nat-Fin x) (nat-Fin (mul-Fin y z))} ( congruence-mul-ℕ ( succ-ℕ k) { x = nat-Fin (mul-Fin x y)} { y = nat-Fin z} ( cong-mul-Fin x y) ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin z))) ( associative-mul-ℕ (nat-Fin x) (nat-Fin y) (nat-Fin z)) ( symmetric-cong-ℕ ( succ-ℕ k) ( mul-ℕ (nat-Fin x) (nat-Fin (mul-Fin y z))) ( mul-ℕ (nat-Fin x) (mul-ℕ (nat-Fin y) (nat-Fin z))) ( congruence-mul-ℕ ( succ-ℕ k) { x = nat-Fin x} { y = nat-Fin (mul-Fin y z)} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x)) ( cong-mul-Fin y z)))) commutative-mul-Fin : {k : ℕ} (x y : Fin k) → Id (mul-Fin x y) (mul-Fin y x) commutative-mul-Fin {succ-ℕ k} x y = eq-cong-ℕ k ( mul-ℕ (nat-Fin x) (nat-Fin y)) ( mul-ℕ (nat-Fin y) (nat-Fin x)) ( cong-identification-ℕ ( succ-ℕ k) ( commutative-mul-ℕ (nat-Fin x) (nat-Fin y))) one-Fin : {k : ℕ} → Fin (succ-ℕ k) one-Fin {k} = mod-succ-ℕ k one-ℕ nat-one-Fin : {k : ℕ} → Id (nat-Fin (one-Fin {succ-ℕ k})) one-ℕ nat-one-Fin {zero-ℕ} = refl nat-one-Fin {succ-ℕ k} = nat-one-Fin {k} left-unit-law-mul-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (mul-Fin one-Fin x) x left-unit-law-mul-Fin {zero-ℕ} (inr star) = refl left-unit-law-mul-Fin {succ-ℕ k} x = ( eq-cong-ℕ (succ-ℕ k) ( mul-ℕ (nat-Fin (one-Fin {succ-ℕ k})) (nat-Fin x)) ( nat-Fin x) ( cong-identification-ℕ ( succ-ℕ (succ-ℕ k)) ( ( ap ( mul-ℕ' (nat-Fin x)) ( nat-one-Fin {k})) ∙ ( left-unit-law-mul-ℕ (nat-Fin x))))) ∙ ( issec-nat-Fin (succ-ℕ k) x) right-unit-law-mul-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (mul-Fin x one-Fin) x right-unit-law-mul-Fin x = ( commutative-mul-Fin x one-Fin) ∙ ( left-unit-law-mul-Fin x) left-distributive-mul-add-Fin : {k : ℕ} (x y z : Fin k) → Id (mul-Fin x (add-Fin y z)) (add-Fin (mul-Fin x y) (mul-Fin x z)) left-distributive-mul-add-Fin {succ-ℕ k} x y z = eq-cong-ℕ k ( mul-ℕ (nat-Fin x) (nat-Fin (add-Fin y z))) ( add-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin (mul-Fin x z))) ( concatenate-cong-eq-cong-ℕ { k = succ-ℕ k} { x1 = mul-ℕ ( nat-Fin x) (nat-Fin (add-Fin y z))} { x2 = mul-ℕ ( nat-Fin x) (add-ℕ (nat-Fin y) (nat-Fin z))} { x3 = add-ℕ ( mul-ℕ (nat-Fin x) (nat-Fin y)) ( mul-ℕ (nat-Fin x) (nat-Fin z))} { x4 = add-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin (mul-Fin x z))} ( congruence-mul-ℕ ( succ-ℕ k) { x = nat-Fin x} { y = nat-Fin (add-Fin y z)} { x' = nat-Fin x} { y' = add-ℕ (nat-Fin y) (nat-Fin z)} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x)) ( cong-add-Fin y z)) ( left-distributive-mul-add-ℕ (nat-Fin x) (nat-Fin y) (nat-Fin z)) ( symmetric-cong-ℕ (succ-ℕ k) ( add-ℕ ( nat-Fin (mul-Fin x y)) ( nat-Fin (mul-Fin x z))) ( add-ℕ ( mul-ℕ (nat-Fin x) (nat-Fin y)) ( mul-ℕ (nat-Fin x) (nat-Fin z))) ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin (mul-Fin x y)} { y = nat-Fin (mul-Fin x z)} { x' = mul-ℕ (nat-Fin x) (nat-Fin y)} { y' = mul-ℕ (nat-Fin x) (nat-Fin z)} ( cong-mul-Fin x y) ( cong-mul-Fin x z)))) right-distributive-mul-add-Fin : {k : ℕ} (x y z : Fin k) → Id (mul-Fin (add-Fin x y) z) (add-Fin (mul-Fin x z) (mul-Fin y z)) right-distributive-mul-add-Fin {k} x y z = ( commutative-mul-Fin (add-Fin x y) z) ∙ ( ( left-distributive-mul-add-Fin z x y) ∙ ( ap-add-Fin (commutative-mul-Fin z x) (commutative-mul-Fin z y))) {- Exercise 7.11 -} {- Exercise 7.12 -} -- We introduce the observational equality on finite sets. Eq-Fin : (k : ℕ) → Fin k → Fin k → UU lzero Eq-Fin (succ-ℕ k) (inl x) (inl y) = Eq-Fin k x y Eq-Fin (succ-ℕ k) (inl x) (inr y) = empty Eq-Fin (succ-ℕ k) (inr x) (inl y) = empty Eq-Fin (succ-ℕ k) (inr x) (inr y) = unit -- Exercise 7.12 (a) refl-Eq-Fin : {k : ℕ} (x : Fin k) → Eq-Fin k x x refl-Eq-Fin {succ-ℕ k} (inl x) = refl-Eq-Fin x refl-Eq-Fin {succ-ℕ k} (inr x) = star Eq-Fin-eq : {k : ℕ} {x y : Fin k} → Id x y → Eq-Fin k x y Eq-Fin-eq {k} refl = refl-Eq-Fin {k} _ eq-Eq-Fin : {k : ℕ} {x y : Fin k} → Eq-Fin k x y → Id x y eq-Eq-Fin {succ-ℕ k} {inl x} {inl y} e = ap inl (eq-Eq-Fin e) eq-Eq-Fin {succ-ℕ k} {inr star} {inr star} star = refl -- Exercise 7.12 (b) is-injective-inl-Fin : {k : ℕ} {x y : Fin k} → Id (inl-Fin k x) (inl-Fin k y) → Id x y is-injective-inl-Fin p = eq-Eq-Fin (Eq-Fin-eq p) -- Exercise 7.12 (c) neq-zero-succ-Fin : {k : ℕ} {x : Fin k} → ¬ (Id (succ-Fin (inl-Fin k x)) zero-Fin) neq-zero-succ-Fin {succ-ℕ k} {inl x} p = neq-zero-succ-Fin (is-injective-inl-Fin p) neq-zero-succ-Fin {succ-ℕ k} {inr star} p = Eq-Fin-eq {succ-ℕ (succ-ℕ k)} {inr star} {zero-Fin} p -- Exercise 7.12 (d) is-injective-skip-zero-Fin : {k : ℕ} {x y : Fin k} → Id (skip-zero-Fin x) (skip-zero-Fin y) → Id x y is-injective-skip-zero-Fin {succ-ℕ k} {inl x} {inl y} p = ap inl (is-injective-skip-zero-Fin (is-injective-inl-Fin p)) is-injective-skip-zero-Fin {succ-ℕ k} {inl x} {inr star} p = ex-falso (Eq-Fin-eq p) is-injective-skip-zero-Fin {succ-ℕ k} {inr star} {inl y} p = ex-falso (Eq-Fin-eq p) is-injective-skip-zero-Fin {succ-ℕ k} {inr star} {inr star} p = refl is-injective-succ-Fin : {k : ℕ} {x y : Fin k} → Id (succ-Fin x) (succ-Fin y) → Id x y is-injective-succ-Fin {succ-ℕ k} {inl x} {inl y} p = ap inl (is-injective-skip-zero-Fin {k} {x} {y} p) is-injective-succ-Fin {succ-ℕ k} {inl x} {inr star} p = ex-falso (neq-zero-succ-Fin {succ-ℕ k} {inl x} (ap inl p)) is-injective-succ-Fin {succ-ℕ k} {inr star} {inl y} p = ex-falso (neq-zero-succ-Fin {succ-ℕ k} {inl y} (ap inl (inv p))) is-injective-succ-Fin {succ-ℕ k} {inr star} {inr star} p = refl -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- {- Section 7.2 Decidability -} {- Definition 7.2.1 -} is-decidable : {l : Level} (A : UU l) → UU l is-decidable A = coprod A (¬ A) {- Example 7.2.2 -} is-decidable-unit : is-decidable unit is-decidable-unit = inl star is-decidable-empty : is-decidable empty is-decidable-empty = inr id {- Definition 7.2.3 -} {- We say that a type has decidable equality if we can decide whether x = y holds for any x, y : A. -} has-decidable-equality : {l : Level} (A : UU l) → UU l has-decidable-equality A = (x y : A) → is-decidable (Id x y) {- Lemma 7.2.5 -} is-decidable-iff : {l1 l2 : Level} {A : UU l1} {B : UU l2} → (A → B) → (B → A) → is-decidable A → is-decidable B is-decidable-iff f g = functor-coprod f (functor-neg g) {- Proposition 7.2.6 -} {- The type ℕ is an example of a type with decidable equality. -} is-decidable-Eq-ℕ : (m n : ℕ) → is-decidable (Eq-ℕ m n) is-decidable-Eq-ℕ zero-ℕ zero-ℕ = inl star is-decidable-Eq-ℕ zero-ℕ (succ-ℕ n) = inr id is-decidable-Eq-ℕ (succ-ℕ m) zero-ℕ = inr id is-decidable-Eq-ℕ (succ-ℕ m) (succ-ℕ n) = is-decidable-Eq-ℕ m n has-decidable-equality-ℕ : has-decidable-equality ℕ has-decidable-equality-ℕ x y = is-decidable-iff (eq-Eq-ℕ x y) Eq-ℕ-eq (is-decidable-Eq-ℕ x y) {- Proposition 7.2.9 -} {- We show that Fin k has decidable equality, for each n : ℕ. -} is-decidable-Eq-Fin : (k : ℕ) (x y : Fin k) → is-decidable (Eq-Fin k x y) is-decidable-Eq-Fin (succ-ℕ k) (inl x) (inl y) = is-decidable-Eq-Fin k x y is-decidable-Eq-Fin (succ-ℕ k) (inl x) (inr y) = inr id is-decidable-Eq-Fin (succ-ℕ k) (inr x) (inl y) = inr id is-decidable-Eq-Fin (succ-ℕ k) (inr x) (inr y) = inl star is-decidable-eq-Fin : (k : ℕ) (x y : Fin k) → is-decidable (Id x y) is-decidable-eq-Fin k x y = functor-coprod eq-Eq-Fin (functor-neg Eq-Fin-eq) (is-decidable-Eq-Fin k x y) {- Section 7.3 Definitions by case analysis -} {- We define an alternative definition of the predecessor function with manual with-abstraction. -} cases-pred-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) (d : is-decidable (Eq-Fin (succ-ℕ k) x zero-Fin)) → Fin (succ-ℕ k) cases-pred-Fin-2 {zero-ℕ} (inr star) d = zero-Fin cases-pred-Fin-2 {succ-ℕ k} (inl x) (inl e) = neg-one-Fin cases-pred-Fin-2 {succ-ℕ k} (inl x) (inr f) = inl (cases-pred-Fin-2 {k} x (inr f)) cases-pred-Fin-2 {succ-ℕ k} (inr star) (inr f) = inl neg-one-Fin pred-Fin-2 : {k : ℕ} → Fin k → Fin k pred-Fin-2 {succ-ℕ k} x = cases-pred-Fin-2 {k} x (is-decidable-Eq-Fin (succ-ℕ k) x zero-Fin) {- We give a solution to the exercise for the alternative definition of the predecessor function, using with-abstraction. -} pred-zero-Fin-2 : {k : ℕ} → Id (pred-Fin-2 {succ-ℕ k} zero-Fin) neg-one-Fin pred-zero-Fin-2 {k} with is-decidable-Eq-Fin (succ-ℕ k) zero-Fin zero-Fin pred-zero-Fin-2 {zero-ℕ} | d = refl pred-zero-Fin-2 {succ-ℕ k} | inl e = refl pred-zero-Fin-2 {succ-ℕ k} | inr f = ex-falso (f (refl-Eq-Fin {succ-ℕ k} zero-Fin)) cases-succ-pred-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) (d : is-decidable (Eq-Fin (succ-ℕ k) x zero-Fin)) → Id (succ-Fin (cases-pred-Fin-2 x d)) x cases-succ-pred-Fin-2 {zero-ℕ} (inr star) d = refl cases-succ-pred-Fin-2 {succ-ℕ k} (inl x) (inl e) = inv (eq-Eq-Fin e) cases-succ-pred-Fin-2 {succ-ℕ zero-ℕ} (inl (inr x)) (inr f) = ex-falso (f star) cases-succ-pred-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inl x)) (inr f) = ap inl (cases-succ-pred-Fin-2 (inl x) (inr f)) cases-succ-pred-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inr star)) (inr f) = refl cases-succ-pred-Fin-2 {succ-ℕ k} (inr star) (inr f) = refl succ-pred-Fin-2 : {k : ℕ} (x : Fin k) → Id (succ-Fin (pred-Fin-2 x)) x succ-pred-Fin-2 {succ-ℕ k} x = cases-succ-pred-Fin-2 x (is-decidable-Eq-Fin (succ-ℕ k) x zero-Fin) pred-inl-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) (f : ¬ (Eq-Fin (succ-ℕ k) x zero-Fin)) → Id (pred-Fin-2 (inl x)) (inl (pred-Fin-2 x)) pred-inl-Fin-2 {k} x f with is-decidable-Eq-Fin (succ-ℕ k) x zero-Fin ... | inl e = ex-falso (f e) ... | inr f' = refl nEq-zero-succ-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → ¬ (Eq-Fin (succ-ℕ (succ-ℕ k)) (succ-Fin (inl x)) zero-Fin) nEq-zero-succ-Fin {succ-ℕ k} (inl (inl x)) e = nEq-zero-succ-Fin (inl x) e nEq-zero-succ-Fin {succ-ℕ k} (inl (inr star)) () nEq-zero-succ-Fin {succ-ℕ k} (inr star) () pred-succ-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (pred-Fin-2 (succ-Fin x)) x pred-succ-Fin-2 {zero-ℕ} (inr star) = refl pred-succ-Fin-2 {succ-ℕ zero-ℕ} (inl (inr star)) = refl pred-succ-Fin-2 {succ-ℕ zero-ℕ} (inr star) = refl pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inl (inl x))) = ( pred-inl-Fin-2 (inl (succ-Fin (inl x))) (nEq-zero-succ-Fin (inl x))) ∙ ( ( ap inl (pred-inl-Fin-2 (succ-Fin (inl x)) (nEq-zero-succ-Fin (inl x)))) ∙ ( ap (inl ∘ inl) (pred-succ-Fin-2 (inl x)))) pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inl (inr star))) = refl pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inr star)) = refl pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inr star) = pred-zero-Fin-2 -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- dist-ℤ : ℤ → ℤ → ℕ dist-ℤ (inl x) (inl y) = dist-ℕ x y dist-ℤ (inl x) (inr (inl star)) = succ-ℕ x dist-ℤ (inl x) (inr (inr y)) = succ-ℕ (succ-ℕ (add-ℕ x y)) dist-ℤ (inr (inl star)) (inl y) = succ-ℕ y dist-ℤ (inr (inr x)) (inl y) = succ-ℕ (succ-ℕ (add-ℕ x y)) dist-ℤ (inr (inl star)) (inr (inl star)) = zero-ℕ dist-ℤ (inr (inl star)) (inr (inr y)) = succ-ℕ y dist-ℤ (inr (inr x)) (inr (inl star)) = succ-ℕ x dist-ℤ (inr (inr x)) (inr (inr y)) = dist-ℕ x y dist-ℤ' : ℤ → ℤ → ℕ dist-ℤ' x y = dist-ℤ y x ap-dist-ℤ : {x y x' y' : ℤ} → Id x x' → Id y y' → Id (dist-ℤ x y) (dist-ℤ x' y') ap-dist-ℤ refl refl = refl eq-dist-ℤ : (x y : ℤ) → Id zero-ℕ (dist-ℤ x y) → Id x y eq-dist-ℤ (inl x) (inl y) p = ap inl (eq-dist-ℕ x y p) eq-dist-ℤ (inl x) (inr (inl star)) p = ex-falso (Peano-8 x p) eq-dist-ℤ (inr (inl star)) (inl y) p = ex-falso (Peano-8 y p) eq-dist-ℤ (inr (inl star)) (inr (inl star)) p = refl eq-dist-ℤ (inr (inl star)) (inr (inr y)) p = ex-falso (Peano-8 y p) eq-dist-ℤ (inr (inr x)) (inr (inl star)) p = ex-falso (Peano-8 x p) eq-dist-ℤ (inr (inr x)) (inr (inr y)) p = ap (inr ∘ inr) (eq-dist-ℕ x y p) dist-eq-ℤ' : (x : ℤ) → Id zero-ℕ (dist-ℤ x x) dist-eq-ℤ' (inl x) = dist-eq-ℕ' x dist-eq-ℤ' (inr (inl star)) = refl dist-eq-ℤ' (inr (inr x)) = dist-eq-ℕ' x dist-eq-ℤ : (x y : ℤ) → Id x y → Id zero-ℕ (dist-ℤ x y) dist-eq-ℤ x .x refl = dist-eq-ℤ' x {- The distance function on ℤ is symmetric. -} symmetric-dist-ℤ : (x y : ℤ) → Id (dist-ℤ x y) (dist-ℤ y x) symmetric-dist-ℤ (inl x) (inl y) = symmetric-dist-ℕ x y symmetric-dist-ℤ (inl x) (inr (inl star)) = refl symmetric-dist-ℤ (inl x) (inr (inr y)) = ap (succ-ℕ ∘ succ-ℕ) (commutative-add-ℕ x y) symmetric-dist-ℤ (inr (inl star)) (inl y) = refl symmetric-dist-ℤ (inr (inr x)) (inl y) = ap (succ-ℕ ∘ succ-ℕ) (commutative-add-ℕ x y) symmetric-dist-ℤ (inr (inl star)) (inr (inl star)) = refl symmetric-dist-ℤ (inr (inl star)) (inr (inr y)) = refl symmetric-dist-ℤ (inr (inr x)) (inr (inl star)) = refl symmetric-dist-ℤ (inr (inr x)) (inr (inr y)) = symmetric-dist-ℕ x y -- We compute the distance from zero -- left-zero-law-dist-ℤ : (x : ℤ) → Id (dist-ℤ zero-ℤ x) (abs-ℤ x) left-zero-law-dist-ℤ (inl x) = refl left-zero-law-dist-ℤ (inr (inl star)) = refl left-zero-law-dist-ℤ (inr (inr x)) = refl right-zero-law-dist-ℤ : (x : ℤ) → Id (dist-ℤ x zero-ℤ) (abs-ℤ x) right-zero-law-dist-ℤ (inl x) = refl right-zero-law-dist-ℤ (inr (inl star)) = refl right-zero-law-dist-ℤ (inr (inr x)) = refl -- We prove the triangle inequality -- {- triangle-inequality-dist-ℤ : (x y z : ℤ) → leq-ℕ (dist-ℤ x y) (add-ℕ (dist-ℤ x z) (dist-ℤ z y)) triangle-inequality-dist-ℤ (inl x) (inl y) (inl z) = triangle-inequality-dist-ℕ x y z triangle-inequality-dist-ℤ (inl x) (inl y) (inr (inl star)) = triangle-inequality-dist-ℕ (succ-ℕ x) (succ-ℕ y) zero-ℕ triangle-inequality-dist-ℤ (inl x) (inl y) (inr (inr z)) = {!!} triangle-inequality-dist-ℤ (inl x) (inr y) (inl z) = {!!} triangle-inequality-dist-ℤ (inl x) (inr y) (inr z) = {!!} triangle-inequality-dist-ℤ (inr x) (inl y) (inl z) = {!!} triangle-inequality-dist-ℤ (inr x) (inl y) (inr z) = {!!} triangle-inequality-dist-ℤ (inr x) (inr y) (inl z) = {!!} triangle-inequality-dist-ℤ (inr x) (inr y) (inr z) = {!!} -} {- triangle-inequality-dist-ℕ : (m n k : ℕ) → leq-ℕ (dist-ℕ m n) (add-ℕ (dist-ℕ m k) (dist-ℕ k n)) triangle-inequality-dist-ℕ zero-ℕ zero-ℕ zero-ℕ = star triangle-inequality-dist-ℕ zero-ℕ zero-ℕ (succ-ℕ k) = star triangle-inequality-dist-ℕ zero-ℕ (succ-ℕ n) zero-ℕ = tr ( leq-ℕ (succ-ℕ n)) ( inv (left-unit-law-add-ℕ (succ-ℕ n))) ( reflexive-leq-ℕ (succ-ℕ n)) triangle-inequality-dist-ℕ zero-ℕ (succ-ℕ n) (succ-ℕ k) = concatenate-eq-leq-eq-ℕ ( inv (ap succ-ℕ (left-zero-law-dist-ℕ n))) ( triangle-inequality-dist-ℕ zero-ℕ n k) ( ( ap (succ-ℕ ∘ (add-ℕ' (dist-ℕ k n))) (left-zero-law-dist-ℕ k)) ∙ ( inv (left-successor-law-add-ℕ k (dist-ℕ k n)))) triangle-inequality-dist-ℕ (succ-ℕ m) zero-ℕ zero-ℕ = reflexive-leq-ℕ (succ-ℕ m) triangle-inequality-dist-ℕ (succ-ℕ m) zero-ℕ (succ-ℕ k) = concatenate-eq-leq-eq-ℕ ( inv (ap succ-ℕ (right-zero-law-dist-ℕ m))) ( triangle-inequality-dist-ℕ m zero-ℕ k) ( ap (succ-ℕ ∘ (add-ℕ (dist-ℕ m k))) (right-zero-law-dist-ℕ k)) triangle-inequality-dist-ℕ (succ-ℕ m) (succ-ℕ n) zero-ℕ = concatenate-leq-eq-ℕ ( dist-ℕ m n) ( transitive-leq-ℕ ( dist-ℕ m n) ( succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))) ( succ-ℕ (succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)))) ( transitive-leq-ℕ ( dist-ℕ m n) ( add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)) ( succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))) ( triangle-inequality-dist-ℕ m n zero-ℕ) ( succ-leq-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)))) ( succ-leq-ℕ (succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))))) ( ( ap (succ-ℕ ∘ succ-ℕ) ( ap-add-ℕ (right-zero-law-dist-ℕ m) (left-zero-law-dist-ℕ n))) ∙ ( inv (left-successor-law-add-ℕ m (succ-ℕ n)))) triangle-inequality-dist-ℕ (succ-ℕ m) (succ-ℕ n) (succ-ℕ k) = triangle-inequality-dist-ℕ m n k -- We show that dist-ℕ x y is a solution to a simple equation. leq-dist-ℕ : (x y : ℕ) → leq-ℕ x y → Id (add-ℕ x (dist-ℕ x y)) y leq-dist-ℕ zero-ℕ zero-ℕ H = refl leq-dist-ℕ zero-ℕ (succ-ℕ y) star = left-unit-law-add-ℕ (succ-ℕ y) leq-dist-ℕ (succ-ℕ x) (succ-ℕ y) H = ( left-successor-law-add-ℕ x (dist-ℕ x y)) ∙ ( ap succ-ℕ (leq-dist-ℕ x y H)) rewrite-left-add-dist-ℕ : (x y z : ℕ) → Id (add-ℕ x y) z → Id x (dist-ℕ y z) rewrite-left-add-dist-ℕ zero-ℕ zero-ℕ .zero-ℕ refl = refl rewrite-left-add-dist-ℕ zero-ℕ (succ-ℕ y) .(succ-ℕ (add-ℕ zero-ℕ y)) refl = ( dist-eq-ℕ' y) ∙ ( inv (ap (dist-ℕ (succ-ℕ y)) (left-unit-law-add-ℕ (succ-ℕ y)))) rewrite-left-add-dist-ℕ (succ-ℕ x) zero-ℕ .(succ-ℕ x) refl = refl rewrite-left-add-dist-ℕ (succ-ℕ x) (succ-ℕ y) .(succ-ℕ (add-ℕ (succ-ℕ x) y)) refl = rewrite-left-add-dist-ℕ (succ-ℕ x) y (add-ℕ (succ-ℕ x) y) refl rewrite-left-dist-add-ℕ : (x y z : ℕ) → leq-ℕ y z → Id x (dist-ℕ y z) → Id (add-ℕ x y) z rewrite-left-dist-add-ℕ .(dist-ℕ y z) y z H refl = ( commutative-add-ℕ (dist-ℕ y z) y) ∙ ( leq-dist-ℕ y z H) rewrite-right-add-dist-ℕ : (x y z : ℕ) → Id (add-ℕ x y) z → Id y (dist-ℕ x z) rewrite-right-add-dist-ℕ x y z p = rewrite-left-add-dist-ℕ y x z (commutative-add-ℕ y x ∙ p) rewrite-right-dist-add-ℕ : (x y z : ℕ) → leq-ℕ x z → Id y (dist-ℕ x z) → Id (add-ℕ x y) z rewrite-right-dist-add-ℕ x .(dist-ℕ x z) z H refl = leq-dist-ℕ x z H -- We show that dist-ℕ is translation invariant translation-invariant-dist-ℕ : (k m n : ℕ) → Id (dist-ℕ (add-ℕ k m) (add-ℕ k n)) (dist-ℕ m n) translation-invariant-dist-ℕ zero-ℕ m n = ap-dist-ℕ (left-unit-law-add-ℕ m) (left-unit-law-add-ℕ n) translation-invariant-dist-ℕ (succ-ℕ k) m n = ( ap-dist-ℕ (left-successor-law-add-ℕ k m) (left-successor-law-add-ℕ k n)) ∙ ( translation-invariant-dist-ℕ k m n) -- We show that dist-ℕ is linear with respect to scalar multiplication linear-dist-ℕ : (m n k : ℕ) → Id (dist-ℕ (mul-ℕ k m) (mul-ℕ k n)) (mul-ℕ k (dist-ℕ m n)) linear-dist-ℕ zero-ℕ zero-ℕ zero-ℕ = refl linear-dist-ℕ zero-ℕ zero-ℕ (succ-ℕ k) = linear-dist-ℕ zero-ℕ zero-ℕ k linear-dist-ℕ zero-ℕ (succ-ℕ n) zero-ℕ = refl linear-dist-ℕ zero-ℕ (succ-ℕ n) (succ-ℕ k) = ap (dist-ℕ' (mul-ℕ (succ-ℕ k) (succ-ℕ n))) (right-zero-law-mul-ℕ (succ-ℕ k)) linear-dist-ℕ (succ-ℕ m) zero-ℕ zero-ℕ = refl linear-dist-ℕ (succ-ℕ m) zero-ℕ (succ-ℕ k) = ap (dist-ℕ (mul-ℕ (succ-ℕ k) (succ-ℕ m))) (right-zero-law-mul-ℕ (succ-ℕ k)) linear-dist-ℕ (succ-ℕ m) (succ-ℕ n) zero-ℕ = refl linear-dist-ℕ (succ-ℕ m) (succ-ℕ n) (succ-ℕ k) = ( ap-dist-ℕ ( right-successor-law-mul-ℕ (succ-ℕ k) m) ( right-successor-law-mul-ℕ (succ-ℕ k) n)) ∙ ( ( translation-invariant-dist-ℕ ( succ-ℕ k) ( mul-ℕ (succ-ℕ k) m) ( mul-ℕ (succ-ℕ k) n)) ∙ ( linear-dist-ℕ m n (succ-ℕ k))) -}
{ "alphanum_fraction": 0.5635619683, "avg_line_length": 33.2153075823, "ext": "agda", "hexsha": "0e0c75ef5cc8ddf159320baf6f11e9abfd963ed4", "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": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "tmoux/HoTT-Intro", "max_forks_repo_path": "Agda/07-finite-sets.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "22023fd35023cb6804424ce12cd10d252b80fd29", "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": "tmoux/HoTT-Intro", "max_issues_repo_path": "Agda/07-finite-sets.agda", "max_line_length": 82, "max_stars_count": 333, "max_stars_repo_head_hexsha": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "tmoux/HoTT-Intro", "max_stars_repo_path": "Agda/07-finite-sets.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": 20274, "size": 46435 }
-- Andreas, 2019-03-18, AIM XXIX, issue #3631 reported by rrose1 -- Performance regression in 2.5.4 due to new sort handling {-# OPTIONS --no-universe-polymorphism #-} -- needed for the performance problem -- {-# OPTIONS -v 10 -v tc.cc:15 -v tc.cc.type:60 -v tc.cover:100 #-} -- {-# OPTIONS -v tc.cc.type:80 #-} module _ where module M (X : Set) (x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 : X) (x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 : X) (x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 : X) where f : X f = x0 -- Should check quickly.
{ "alphanum_fraction": 0.6081560284, "avg_line_length": 26.8571428571, "ext": "agda", "hexsha": "560e0eb0681f2407a69f25b429c62f55f24b29f8", "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/Issue3631.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/Issue3631.agda", "max_line_length": 81, "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/Issue3631.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": 218, "size": 564 }
module Source.Examples where open import Source.Size open import Source.Size.Substitution.Theory open import Source.Term open import Source.Type open import Util.Prelude import Source.Size.Substitution.Canonical as SC {- liftℕ : ∀ n < ⋆. ∀ m < n. Nat m → Nat n liftℕ ≔ Λ n < ⋆. Λ m < n. λ i : Nat m. caseNat[Nat n] m i zero n (Λ k < m. λ i′ : Nat k. suc n k i′) -} liftNat : ∀ {Δ} → Term Δ liftNat = Λₛ ⋆ , Λₛ v0 , Λ (Nat v0) , caseNat (Nat v1) v0 (var 0) (zero v1) (Λₛ v0 , Λ (Nat v0) , suc v2 v0 (var 0)) liftNat⊢ : ∀ {Δ Γ} → Δ , Γ ⊢ liftNat ∶ Π ⋆ , Π v0 , Nat v0 ⇒ Nat v1 liftNat⊢ = absₛ (absₛ (abs (caseNat (<-trans (var refl) (var refl)) (var zero) (zero (var refl)) (absₛ (abs (suc (var refl) (<-trans (var refl) (var refl)) (var zero))) refl) refl)) refl) refl {- half : ∀ n < ⋆. Nat n → Nat n half ≔ λ n < ⋆. fix[Nat ∙ → Nat ∙] (Λ n < ⋆. λ rec : (∀ m < n. Nat m → Nat m). λ i : Nat n. caseNat[Nat n] n i (zero n) (Λ m < n. λ i′ : Nat m. caseNat[Nat n] m i′ (zero n) (Λ k < m. λ i″ : Nat k. suc n k (rec k i″)))) n -} half : ∀ {Δ} → Term Δ half = Λₛ ⋆ , fix (Nat v0 ⇒ Nat v0) (Λₛ ⋆ , Λ (Π v0 , Nat v0 ⇒ Nat v0) , Λ Nat v0 , caseNat (Nat v0) v0 (var 0) (zero v0) (Λₛ v0 , Λ (Nat v0) , caseNat (Nat v1) v0 (var 0) (zero v1) (Λₛ v0 , Λ (Nat v0) , suc v2 v0 (var 3 ·ₛ v0 · var 0)))) v0 half⊢ : ∀ {Δ Γ} → Δ , Γ ⊢ half ∶ Π ⋆ , Nat v0 ⇒ Nat v0 half⊢ = absₛ (fix (var refl) (absₛ (abs (abs (caseNat (var refl) (var zero) (zero (var refl)) (absₛ (abs (caseNat (<-trans (var refl) (var refl)) (var zero) (zero (var refl)) (absₛ (abs (suc (var refl) (<-trans (var refl) (var refl)) (app (appₛ (<-trans (var refl) (var refl)) (var (suc (suc (suc zero)))) refl) (var zero)))) refl) refl)) refl) refl))) refl) refl refl) refl {- suc∞ : Nat ∞ → Nat ∞ suc∞ ≔ λ i : Nat ∞. caseNat[Nat ∞] ∞ i (suc ∞ 0 (zero 0)) (Λ m < ∞. λ i′ : Nat m. suc ∞ (↑ m) (suc (↑ m) m i′)) -} suc∞ : ∀ {Δ} → Term Δ suc∞ = Λ (Nat ∞) , caseNat (Nat ∞) ∞ (var 0) (suc ∞ zero (zero zero)) (Λₛ ∞ , Λ (Nat v0) , suc ∞ (suc v0) (suc (suc v0) v0 (var 0))) suc∞⊢ : ∀ {Δ Γ} → Δ , Γ ⊢ suc∞ ∶ Nat ∞ ⇒ Nat ∞ suc∞⊢ = abs (caseNat <suc (var zero) (suc <suc zero<∞ (zero (<-trans zero<∞ <suc))) (absₛ (abs (suc <suc (suc<∞ (var refl)) (suc (<-trans (suc<∞ (var refl)) <suc) <suc (var zero)))) refl) refl) {- plus : ∀ n < ⋆. Nat n → Nat ∞ → Nat ∞ plus ≔ Λ n < ⋆. fix[Nat ∙ → Nat ∞ → Nat ∞] (Λ n < ⋆. λ rec : (∀ m < n. Nat m → Nat ∞ → Nat ∞). λ i : Nat n. λ j : Nat ∞. caseNat[Nat ∞] n i j (Λ m < n. λ i′ : Nat m. suc∞ (rec m i′ j))) n -} plus : ∀ {Δ} → Term Δ plus = Λₛ ⋆ , fix (Nat v0 ⇒ Nat ∞ ⇒ Nat ∞) (Λₛ ⋆ , Λ (Π v0 , Nat v0 ⇒ Nat ∞ ⇒ Nat ∞) , Λ (Nat v0) , Λ (Nat ∞) , caseNat (Nat ∞) v0 (var 1) (var 0) (Λₛ v0 , Λ (Nat v0) , suc∞ · (var 3 ·ₛ v0 · var 0 · var 1))) v0 plus⊢ : ∀ {Δ Γ} → Δ , Γ ⊢ plus ∶ Π ⋆ , Nat v0 ⇒ Nat ∞ ⇒ Nat ∞ plus⊢ = absₛ (fix (var refl) (absₛ (abs (abs (abs (caseNat (var refl) (var (suc zero)) (var zero) (absₛ (abs (app suc∞⊢ (app (app (appₛ (var refl) (var (suc (suc (suc zero)))) refl) (var zero)) (var (suc zero))))) refl) refl)))) refl) refl refl) refl {- zeros : ∀ n < ⋆. Stream n zeros ≔ Λ n < ⋆. fix[Stream ∙] (Λ n < ⋆. λ rec : (∀ m < n. Stream m). cons (zero ∞) n rec) n -} zeros : ∀ {Δ} → Term Δ zeros = Λₛ ⋆ , fix (Stream v0) (Λₛ ⋆ , Λ (Π v0 , Stream v0) , cons (zero ∞) v0 (var 0)) v0 zeros⊢ : ∀ {Δ Γ} → Δ , Γ ⊢ zeros ∶ Π ⋆ , Stream v0 zeros⊢ = absₛ (fix (var refl) (absₛ (abs (cons (var refl) (zero <suc) (var zero))) refl) refl refl) refl {- map : (Nat ∞ → Nat ∞) → ∀ n < ⋆. Stream n → Stream n map ≔ λ f : Nat ∞ → Nat ∞. Λ n < ⋆. fix[Stream ∙ → Stream ∙] (Λ n < ⋆. λ rec : (∀ m < n. Stream m → Stream m). λ xs : Stream n. cons (f (head n xs)) n (Λ m < n. rec m (tail n xs m))) n -} map : ∀ {Δ} → Term Δ map = Λ (Nat ∞ ⇒ Nat ∞) , Λₛ ⋆ , fix (Stream v0 ⇒ Stream v0) (Λₛ ⋆ , Λ (Π v0 , Stream v0 ⇒ Stream v0) , Λ Stream v0 , cons (var 2 · head v0 (var 0)) v0 (Λₛ v0 , var 1 ·ₛ v0 · tail v1 (var 0) v0)) v0 map⊢ : ∀ {Δ Γ} → Δ , Γ ⊢ map ∶ (Nat ∞ ⇒ Nat ∞) ⇒ (Π ⋆ , Stream v0 ⇒ Stream v0) map⊢ = abs (absₛ (fix (var refl) (absₛ (abs (abs (cons (var refl) (app (var (suc (suc zero))) (head (var refl) (var zero))) (absₛ (app (appₛ (var refl) (var (suc zero)) refl) (tail (var refl) (var refl) (var zero))) refl)))) refl) refl refl) refl)
{ "alphanum_fraction": 0.3862306368, "avg_line_length": 25.5947136564, "ext": "agda", "hexsha": "511e5e4daae69a918def426dcb0606d62fd84ab2", "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": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_path": "src/Source/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "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": "JLimperg/msc-thesis-code", "max_issues_repo_path": "src/Source/Examples.agda", "max_line_length": 78, "max_stars_count": 5, "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_path": "src/Source/Examples.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "num_tokens": 2294, "size": 5810 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Fundamental.Reducibility {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.LogicalRelation open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Reducibility open import Definition.LogicalRelation.Fundamental open import Tools.Product -- Well-formed types are reducible. reducible : ∀ {A Γ} → Γ ⊢ A → Γ ⊩⟨ ¹ ⟩ A reducible A = let [Γ] , [A] = fundamental A in reducibleᵛ [Γ] [A] -- Well-formed equality is reducible. reducibleEq : ∀ {A B Γ} → Γ ⊢ A ≡ B → ∃₂ λ [A] ([B] : Γ ⊩⟨ ¹ ⟩ B) → Γ ⊩⟨ ¹ ⟩ A ≡ B / [A] reducibleEq {A} {B} A≡B = let [Γ] , [A] , [B] , [A≡B] = fundamentalEq A≡B in reducibleᵛ [Γ] [A] , reducibleᵛ [Γ] [B] , reducibleEqᵛ {A} {B} [Γ] [A] [A≡B] -- Well-formed terms are reducible. reducibleTerm : ∀ {t A Γ} → Γ ⊢ t ∷ A → ∃ λ [A] → Γ ⊩⟨ ¹ ⟩ t ∷ A / [A] reducibleTerm {t} {A} ⊢t = let [Γ] , [A] , [t] = fundamentalTerm ⊢t in reducibleᵛ [Γ] [A] , reducibleTermᵛ {t} {A} [Γ] [A] [t] -- Well-formed term equality is reducible. reducibleEqTerm : ∀ {t u A Γ} → Γ ⊢ t ≡ u ∷ A → ∃ λ [A] → Γ ⊩⟨ ¹ ⟩ t ≡ u ∷ A / [A] reducibleEqTerm {t} {u} {A} t≡u = let [Γ] , modelsTermEq [A] [t] [u] [t≡u] = fundamentalTermEq t≡u in reducibleᵛ [Γ] [A] , reducibleEqTermᵛ {t} {u} {A} [Γ] [A] [t≡u]
{ "alphanum_fraction": 0.6130114017, "avg_line_length": 34.6744186047, "ext": "agda", "hexsha": "b8439af7902035abe497c83ced92f4f230f3968e", "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": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Fundamental/Reducibility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "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": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Fundamental/Reducibility.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Fundamental/Reducibility.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 626, "size": 1491 }
module MLib.Prelude.DFS.ViaNat where open import MLib.Prelude open import MLib.Prelude.Finite open FE using (_⇨_; cong) open import Data.Digit using (fromDigits; toDigits; Digit) module _ {c p} (A-finiteSet : FiniteSet c p) where module A = FiniteSet A-finiteSet open A using () renaming (Carrier to A) open LeftInverse open Nat using (_^_; _+_; _*_) private fromBool : Bool → Digit 2 fromBool false = Fin.zero fromBool true = Fin.suc Fin.zero toBool : Digit 2 → Bool toBool Fin.zero = false toBool (Fin.suc Fin.zero) = true toBool (Fin.suc (Fin.suc ())) toBool-fromBool : ∀ b → toBool (fromBool b) ≡ b toBool-fromBool false = ≡.refl toBool-fromBool true = ≡.refl -- fromBinary : (n : ℕ) → List Bool → ℕ -- fromBinary n [] = 0 -- an empty table represents an empty binary string -- fromBinary n (x ∷ xs) = Fin.toℕ x + n * from-n-ary n xs -- -- -- div-rem m i = "i % m" , "i / m" -- div-rem : ∀ n → ℕ → Fin n × ℕ -- div-rem n k = {!!} -- to-n-ary : (n : ℕ) → ℕ → List (Fin n) -- to-n-ary n k = -- let r , d = div-rem n k -- rs = to-n-ary d -- in {!!} -- -- r ∷ rs -- Goal: fromDigits -- (List.tabulate (λ x → fromBool (.i ⟨$⟩ (from A.ontoFin ⟨$⟩ x)))) -- ≡ -- fromDigits -- (List.tabulate (λ x → fromBool (.j ⟨$⟩ (from A.ontoFin ⟨$⟩ x)))) lookupOrElse : ∀ {n} {a} {A : Set a} → A → Fin n → List A → A lookupOrElse z _ [] = z lookupOrElse _ Fin.zero (x ∷ xs) = x lookupOrElse z (Fin.suc n) (x ∷ xs) = lookupOrElse z n xs lookupOrElse-toList : ∀ {n} {a} {A : Set a} {z : A} (i : Fin n) (t : Table A n) → lookupOrElse z i (Table.toList t) ≡ Table.lookup t i lookupOrElse-toList Fin.zero t = ≡.refl lookupOrElse-toList (Fin.suc i) = lookupOrElse-toList i ∘ Table.tail *2-absurd : ∀ m n → m * 2 ≡ suc (n * 2) → ⊥ *2-absurd zero zero () *2-absurd zero (suc n) () *2-absurd (suc m) zero () *2-absurd (suc m) (suc n) = *2-absurd m n ∘ Nat.suc-injective ∘ Nat.suc-injective *2-injective : ∀ m n → m * 2 ≡ n * 2 → m ≡ n *2-injective zero zero _ = ≡.refl *2-injective zero (suc n) () *2-injective (suc m) zero () *2-injective (suc m) (suc n) = ≡.cong suc ∘ *2-injective m n ∘ Nat.suc-injective ∘ Nat.suc-injective 01-+-*2 : (i j : Fin 2) (m n : ℕ) → Fin.toℕ i + m * 2 ≡ Fin.toℕ j + n * 2 → m ≡ n 01-+-*2 Fin.zero Fin.zero = *2-injective 01-+-*2 Fin.zero (Fin.suc Fin.zero) m n = ⊥-elim ∘ *2-absurd m n 01-+-*2 Fin.zero (Fin.suc (Fin.suc ())) m n 01-+-*2 (Fin.suc Fin.zero) Fin.zero m n = ⊥-elim ∘ *2-absurd n m ∘ ≡.sym 01-+-*2 (Fin.suc (Fin.suc ())) Fin.zero m n 01-+-*2 (Fin.suc Fin.zero) (Fin.suc Fin.zero) m n = *2-injective m n ∘ Nat.suc-injective 01-+-*2 (Fin.suc Fin.zero) (Fin.suc (Fin.suc ())) m n 01-+-*2 (Fin.suc (Fin.suc ())) (Fin.suc Fin.zero) m n 01-+-*2 (Fin.suc (Fin.suc ())) (Fin.suc (Fin.suc j)) m n +-injective₂ : ∀ m n o → o + m ≡ o + n → m ≡ n +-injective₂ m n zero = id +-injective₂ m n (suc o) = +-injective₂ m n o ∘ Nat.suc-injective +-injective₁ : ∀ m n o → m + o ≡ n + o → m ≡ n +-injective₁ m n o p = +-injective₂ m n o (≡.trans (Nat.+-comm o m) (≡.trans p (Nat.+-comm n o))) lookupOrElse-fromDigits : ∀ {n} (i : Fin n) (xs ys : List (Fin 2)) → fromDigits xs ≡ fromDigits ys → lookupOrElse Fin.zero i xs ≡ lookupOrElse Fin.zero i ys lookupOrElse-fromDigits i [] [] p = ≡.refl lookupOrElse-fromDigits Fin.zero [] (Fin.zero ∷ ys) p = ≡.refl lookupOrElse-fromDigits Fin.zero [] (Fin.suc y ∷ ys) () lookupOrElse-fromDigits (Fin.suc i) [] (Fin.zero ∷ ys) p = lookupOrElse-fromDigits i [] ys (*2-injective 0 _ p) lookupOrElse-fromDigits (Fin.suc i) [] (Fin.suc y ∷ ys) () lookupOrElse-fromDigits Fin.zero (Fin.zero ∷ xs) [] p = ≡.refl lookupOrElse-fromDigits Fin.zero (Fin.suc x ∷ xs) [] () lookupOrElse-fromDigits {Nat.suc n} Fin.zero (x ∷ xs) (y ∷ ys) p = let q = 01-+-*2 x y (fromDigits xs) (fromDigits ys) p p′ = ≡.subst (λ fdys → Fin.toℕ x + fromDigits xs * 2 ≡ Fin.toℕ y + fdys) (≡.cong₂ _*_ (≡.sym q) ≡.refl) p p′′ = +-injective₁ (Fin.toℕ x) (Fin.toℕ y) _ p′ in Fin.toℕ-injective p′′ lookupOrElse-fromDigits (Fin.suc i) (Fin.zero ∷ xs) [] p = lookupOrElse-fromDigits i xs [] (*2-injective _ _ p) lookupOrElse-fromDigits (Fin.suc i) (Fin.suc x ∷ xs) [] () lookupOrElse-fromDigits (Fin.suc i) (x ∷ xs) (y ∷ ys) p = lookupOrElse-fromDigits i xs ys (01-+-*2 x y (fromDigits xs) (fromDigits ys) p) toDigits-fromDigits : ∀ {n} (i : Fin n) xs → lookupOrElse Fin.zero i (proj₁ (toDigits 2 (fromDigits xs))) ≡ lookupOrElse Fin.zero i xs toDigits-fromDigits i xs with toDigits 2 (fromDigits xs) toDigits-fromDigits i xs | ds , p = lookupOrElse-fromDigits i ds xs p asNat : LeftInverse (FiniteSet.setoid A-finiteSet ⇨ ≡.setoid Bool) (≡.setoid ℕ) _⟨$⟩_ (to asNat) f = fromDigits (Table.toList (Table.map (fromBool ∘ (f ⟨$⟩_)) A.enumₜ)) cong (to asNat) {f} p = ≡.cong fromDigits {x = Table.toList (Table.map (fromBool ∘ (f ⟨$⟩_)) A.enumₜ)} (List.tabulate-cong λ x → ≡.cong fromBool (p A.refl)) _⟨$⟩_ (_⟨$⟩_ (from asNat) n) x = toBool (lookupOrElse Fin.zero (A.toIx x) (proj₁ (toDigits 2 n))) cong (_⟨$⟩_ (from asNat) n) {x} {y} = ≡.cong (λ i → toBool (lookupOrElse Fin.zero i (proj₁ (toDigits 2 n)))) ∘ cong (to A.ontoFin) cong (from asNat) {n} ≡.refl = cong (_⟨$⟩_ (from asNat) n) left-inverse-of asNat f {x} {y} p = begin toBool (lookupOrElse Fin.zero (A.toIx x) (proj₁ (toDigits 2 (fromDigits (Table.toList (Table.map (fromBool ∘ (f ⟨$⟩_)) A.enumₜ)))))) ≡⟨ ≡.cong toBool (toDigits-fromDigits (A.toIx x) (Table.toList (Table.map (fromBool ∘ (f ⟨$⟩_)) A.enumₜ))) ⟩ toBool (lookupOrElse Fin.zero (A.toIx x) (Table.toList (Table.map (fromBool ∘ (f ⟨$⟩_)) A.enumₜ))) ≡⟨ ≡.cong toBool (lookupOrElse-toList (A.toIx x) _) ⟩ toBool (Table.lookup (Table.map (fromBool ∘ (f ⟨$⟩_)) A.enumₜ) (A.toIx x)) ≡⟨⟩ toBool (fromBool (f ⟨$⟩ (from A.ontoFin ⟨$⟩ (to A.ontoFin ⟨$⟩ x)))) ≡⟨ toBool-fromBool _ ⟩ f ⟨$⟩ (from A.ontoFin ⟨$⟩ (to A.ontoFin ⟨$⟩ x)) ≡⟨ cong f (left-inverse-of A.ontoFin x) ⟩ f ⟨$⟩ x ≡⟨ cong f p ⟩ f ⟨$⟩ y ∎ where open ≡.Reasoning
{ "alphanum_fraction": 0.5786543662, "avg_line_length": 46.5703703704, "ext": "agda", "hexsha": "9f97128cd9364805e14030a539b58c833deffd84", "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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_path": "src/MLib/DFS/ViaNat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "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": "bch29/agda-matrices", "max_issues_repo_path": "src/MLib/DFS/ViaNat.agda", "max_line_length": 160, "max_stars_count": null, "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_path": "src/MLib/DFS/ViaNat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2454, "size": 6287 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Implications of nullary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Nullary.Implication where open import Data.Bool.Base open import Data.Empty open import Function.Base open import Relation.Nullary open import Level private variable p q : Level P : Set p Q : Set q ------------------------------------------------------------------------ -- Some properties which are preserved by _→_. infixr 2 _→-reflects_ _→-dec_ _→-reflects_ : ∀ {bp bq} → Reflects P bp → Reflects Q bq → Reflects (P → Q) (not bp ∨ bq) ofʸ p →-reflects ofʸ q = ofʸ (const q) ofʸ p →-reflects ofⁿ ¬q = ofⁿ (¬q ∘ (_$ p)) ofⁿ ¬p →-reflects _ = ofʸ (⊥-elim ∘ ¬p) _→-dec_ : Dec P → Dec Q → Dec (P → Q) does (p? →-dec q?) = not (does p?) ∨ does q? proof (p? →-dec q?) = proof p? →-reflects proof q?
{ "alphanum_fraction": 0.481844946, "avg_line_length": 27.5405405405, "ext": "agda", "hexsha": "cdf257c78d5d697ee1b3ec3dbac29d7f1cd4bc0d", "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/Relation/Nullary/Implication.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/Relation/Nullary/Implication.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/Relation/Nullary/Implication.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": 287, "size": 1019 }
{-# OPTIONS --cubical --safe #-} module Data.Binary.PerformanceTests.Subtraction where open import Prelude open import Data.Binary.Definition open import Data.Binary.Addition using (_+_) open import Data.Binary.Subtraction using (_-_) open import Data.Binary.Multiplication using (_*_) sub-r : 𝔹 → 𝔹 → ℕ → 𝔹 sub-r a x zero = a sub-r a x (suc n) = sub-r a x n - x sub-l : 𝔹 → 𝔹 → ℕ → 𝔹 sub-l a x zero = a sub-l a x (suc n) = sub-r (a - x) x n one-thousand : 𝔹 one-thousand = 2ᵇ 1ᵇ 1ᵇ 2ᵇ 1ᵇ 2ᵇ 2ᵇ 2ᵇ 2ᵇ 0ᵇ f : 𝔹 f = one-thousand * one-thousand * one-thousand n : ℕ n = 99999 -- The actual performance test (uncomment and time how long it takes to type-check) -- _ : sub-l f one-thousand n ≡ sub-r f one-thousand n -- _ = refl
{ "alphanum_fraction": 0.6716621253, "avg_line_length": 23.6774193548, "ext": "agda", "hexsha": "ef21c2c508abe678f9827cd3508abee15219b136", "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/PerformanceTests/Subtraction.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/PerformanceTests/Subtraction.agda", "max_line_length": 83, "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/PerformanceTests/Subtraction.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": 287, "size": 734 }
------------------------------------------------------------------------------ -- Common definitions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Common.DefinitionsATP where open import Common.FOL.FOL using ( ¬_ ; D ) open import Common.FOL.Relation.Binary.PropositionalEquality using ( _≡_ ) infix 4 _≢_ ------------------------------------------------------------------------------ -- Inequality. _≢_ : D → D → Set x ≢ y = ¬ x ≡ y {-# ATP definition _≢_ #-}
{ "alphanum_fraction": 0.3864306785, "avg_line_length": 30.8181818182, "ext": "agda", "hexsha": "fcc3a15143c0436e33584cfb63e3bda3c3581d6b", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/Common/DefinitionsATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/Common/DefinitionsATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/Common/DefinitionsATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 126, "size": 678 }
------------------------------------------------------------------------ -- Convenient syntax for "equational reasoning" using a indexed preorder ------------------------------------------------------------------------ open import Relation.Binary.Indexed.Extra module Relation.Binary.Indexed.PreorderReasoning {𝒾} {I : Set 𝒾} {𝒸 ℓ₁ ℓ₂} (P : Preorder I 𝒸 ℓ₁ ℓ₂) where open Preorder P infix 4 _IsRelatedTo_ infix 1 begin_ infix 3 _∎ infixr 2 _∼⟨_⟩_ _≈⟨_⟩_ _≈⟨⟩_ data _IsRelatedTo_ {i j : I} (x : Carrier i) (y : Carrier j) : Set ℓ₂ where relTo : (x∼y : x ∼ y) → x IsRelatedTo y begin_ : ∀ {i j : I} {x : Carrier i} {y : Carrier j} → x IsRelatedTo y → x ∼ y begin relTo x∼y = x∼y _∼⟨_⟩_ : ∀ {i j k : I} → (x : Carrier i) → {y : Carrier j} {z : Carrier k} → x ∼ y → y IsRelatedTo z → x IsRelatedTo z _ ∼⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z) _≈⟨_⟩_ : ∀ {i j k : I} → (x : Carrier i) → {y : Carrier j} {z : Carrier k} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z _ ≈⟨ x≈y ⟩ relTo y∼z = relTo (trans (reflexive x≈y) y∼z) _≈⟨⟩_ : ∀ {i j : I} → (x : Carrier i) → {y : Carrier j} → x IsRelatedTo y → x IsRelatedTo y _ ≈⟨⟩ x∼y = x∼y _∎ : ∀ {i : I} (x : Carrier i) → x IsRelatedTo x _∎ _ = relTo refl
{ "alphanum_fraction": 0.5146341463, "avg_line_length": 32.3684210526, "ext": "agda", "hexsha": "6c224d058cf659cc9a0005aa9b3cf8f4d6a15a7a", "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": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/categories", "max_forks_repo_path": "src/Relation/Binary/Indexed/PreorderReasoning.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "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/categories", "max_issues_repo_path": "src/Relation/Binary/Indexed/PreorderReasoning.agda", "max_line_length": 105, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/categories", "max_stars_repo_path": "src/Relation/Binary/Indexed/PreorderReasoning.agda", "max_stars_repo_stars_event_max_datetime": "2018-01-04T23:19:30.000Z", "max_stars_repo_stars_event_min_datetime": "2018-01-04T23:19:30.000Z", "num_tokens": 510, "size": 1230 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Rings.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Rings.IntegralDomains.Definition open import Rings.IntegralDomains.Lemmas open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Fields.FieldOfFractions.Setoid {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where record fieldOfFractionsSet : Set (a ⊔ b) where field num : A denom : A .denomNonzero : (Setoid._∼_ S denom (Ring.0R R) → False) fieldOfFractionsSetoid : Setoid fieldOfFractionsSet Setoid._∼_ fieldOfFractionsSetoid (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 }) = Setoid._∼_ S (a * d) (b * c) Equivalence.reflexive (Setoid.eq fieldOfFractionsSetoid) {record { num = a ; denom = b ; denomNonzero = b!=0 }} = Ring.*Commutative R Equivalence.symmetric (Setoid.eq fieldOfFractionsSetoid) {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} ad=bc = transitive (Ring.*Commutative R) (transitive (symmetric ad=bc) (Ring.*Commutative R)) where open Equivalence (Setoid.eq S) Equivalence.transitive (Setoid.eq fieldOfFractionsSetoid) {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} {record { num = e ; denom = f ; denomNonzero = f!=0 }} ad=bc cf=de = p5 where open Setoid S open Ring R open Equivalence eq p : (a * d) * f ∼ (b * c) * f p = Ring.*WellDefined R ad=bc reflexive p2 : (a * f) * d ∼ b * (d * e) p2 = transitive (transitive (symmetric *Associative) (transitive (*WellDefined reflexive *Commutative) *Associative)) (transitive p (transitive (symmetric *Associative) (*WellDefined reflexive cf=de))) p3 : (a * f) * d ∼ (b * e) * d p3 = transitive p2 (transitive (*WellDefined reflexive *Commutative) *Associative) p4 : ((d ∼ 0R) → False) → ((a * f) ∼ (b * e)) p4 = cancelIntDom I (transitive *Commutative (transitive p3 *Commutative)) p5 : (a * f) ∼ (b * e) p5 = p4 λ t → exFalso (d!=0 t)
{ "alphanum_fraction": 0.6523681859, "avg_line_length": 54.5853658537, "ext": "agda", "hexsha": "fd670c6985f95fedf712bbbc341f0d34610c3cea", "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": "Fields/FieldOfFractions/Setoid.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": "Fields/FieldOfFractions/Setoid.agda", "max_line_length": 260, "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": "Fields/FieldOfFractions/Setoid.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": 774, "size": 2238 }
open import Mockingbird.Forest using (Forest) -- Curry’s Lively Bird Forest module Mockingbird.Problems.Chapter14 {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Product using (_×_; _,_; ∃-syntax; proj₁; proj₂) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Function using (_$_; _⇔_; Equivalence; mk⇔) open import Level using (_⊔_) open import Relation.Binary using (_Respects_) open import Relation.Nullary using (¬_) open import Relation.Unary using (Pred) open import Mockingbird.Forest.Birds forest import Mockingbird.Problems.Chapter09 forest as Chapter₉ open Forest forest module _ {s} (Sings : Pred Bird s) (respects : Sings Respects _≈_) -- This law of excluded middle is not stated in the problem as one of -- the laws, but in the solution given in the book, it is used. (LEM : ∀ x → Sings x ⊎ ¬ Sings x) (P : Bird) where module _ (law₁ : ∀ {x y} → Sings y → Sings (P ∙ x ∙ y)) (law₂ : ∀ {x y} → ¬ (Sings x) → Sings (P ∙ x ∙ y)) (law₃ : ∀ {x y} → Sings x → Sings (P ∙ x ∙ y) → Sings y) (law₄ : ∀ x → ∃[ y ] Sings y ⇔ Sings (P ∙ y ∙ x)) where problem₁ : ∀ x → Sings x problem₁ x = law₃ (proj₂ (law₄-⇐ x) Pyx-sings) Pyx-sings where -- If y sings on all days on which x sings, then Pxy sings on all days. lemma-Pxy : ∀ y x → (Sings y → Sings x) → Sings (P ∙ y ∙ x) lemma-Pxy y x y-sings⇒x-sings with LEM y ... | inj₁ y-sings = law₁ (y-sings⇒x-sings y-sings) ... | inj₂ ¬y-sings = law₂ ¬y-sings law₄-⇒ : ∀ x → ∃[ y ] (Sings y → Sings (P ∙ y ∙ x)) law₄-⇒ x = let (y , p) = law₄ x in (y , Equivalence.f p) law₄-⇐ : ∀ x → ∃[ y ] (Sings (P ∙ y ∙ x) → Sings y) law₄-⇐ x = let (y , p) = law₄ x in (y , Equivalence.g p) y = proj₁ $ law₄ x y-sings⇒x-sings : Sings y → Sings x y-sings⇒x-sings y-sings = law₃ y-sings $ proj₂ (law₄-⇒ x) y-sings Pyx-sings : Sings (P ∙ y ∙ x) Pyx-sings = lemma-Pxy y x y-sings⇒x-sings module _ (law₁ : ∀ {x y} → Sings y → Sings (P ∙ x ∙ y)) (law₂ : ∀ {x y} → ¬ Sings (x) → Sings (P ∙ x ∙ y)) (law₃ : ∀ {x y} → Sings x → Sings (P ∙ x ∙ y) → Sings y) ⦃ _ : HasCardinal ⦄ ⦃ _ : HasLark ⦄ where problem₂ : ∀ x → Sings x problem₂ = problem₁ law₁ law₂ law₃ $ λ x → let -- There exists a bird of which CPx is fond. (y , isFond) = Chapter₉.problem₂₅ (C ∙ P ∙ x) Pyx≈y : P ∙ y ∙ x ≈ y Pyx≈y = begin P ∙ y ∙ x ≈˘⟨ isCardinal P x y ⟩ C ∙ P ∙ x ∙ y ≈⟨ isFond ⟩ y ∎ law₄ : Sings y ⇔ Sings (P ∙ y ∙ x) law₄ = mk⇔ (respects (sym Pyx≈y)) (respects Pyx≈y) in (y , law₄) module _ (law₁ : ∀ {x y} → Sings y → Sings (P ∙ x ∙ y)) (law₂ : ∀ {x y} → ¬ Sings (x) → Sings (P ∙ x ∙ y)) (law₃ : ∀ {x y} → Sings x → Sings (P ∙ x ∙ y) → Sings y) where problem₃ : ∃[ A ] (∀ x y z → A ∙ x ∙ y ∙ z ≈ x ∙ (z ∙ z) ∙ y) → ∀ x → Sings x problem₃ (A , Axyz≈x[zz]y) = problem₁ law₁ law₂ law₃ $ λ x → let y = A ∙ P ∙ x ∙ (A ∙ P ∙ x) y≈Pyx : y ≈ P ∙ y ∙ x y≈Pyx = begin y ≈⟨⟩ A ∙ P ∙ x ∙ (A ∙ P ∙ x) ≈⟨ Axyz≈x[zz]y P x (A ∙ P ∙ x) ⟩ P ∙ (A ∙ P ∙ x ∙ (A ∙ P ∙ x)) ∙ x ≈⟨⟩ (P ∙ y ∙ x ∎) law₄ : Sings y ⇔ Sings (P ∙ y ∙ x) law₄ = mk⇔ (respects y≈Pyx) (respects (sym y≈Pyx)) in (y , law₄) -- -- TODO: bonus exercises
{ "alphanum_fraction": 0.4835345774, "avg_line_length": 37.1836734694, "ext": "agda", "hexsha": "e933a6fe9318657d5de9b3420cb90ac7c11fef81", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Problems/Chapter14.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Problems/Chapter14.agda", "max_line_length": 81, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Problems/Chapter14.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": 1482, "size": 3644 }
open import Nat open import Prelude open import core open import lemmas-gcomplete module lemmas-complete where lem-comp-pair1 : ∀{d1 d2} → ⟨ d1 , d2 ⟩ dcomplete → d1 dcomplete lem-comp-pair1 (DCPair h _) = h lem-comp-pair2 : ∀{d1 d2} → ⟨ d1 , d2 ⟩ dcomplete → d2 dcomplete lem-comp-pair2 (DCPair _ h) = h lem-comp-prod1 : ∀{τ1 τ2} → τ1 ⊗ τ2 tcomplete → τ1 tcomplete lem-comp-prod1 (TCProd h _) = h lem-comp-prod2 : ∀{τ1 τ2} → τ1 ⊗ τ2 tcomplete → τ2 tcomplete lem-comp-prod2 (TCProd _ h) = h -- no term is both complete and indeterminate lem-ind-comp : ∀{d} → d dcomplete → d indet → ⊥ lem-ind-comp DCVar () lem-ind-comp DCConst () lem-ind-comp (DCLam comp x₁) () lem-ind-comp (DCAp comp comp₁) (IAp x ind x₁) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastArr x₂ ind) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastGroundHole x₂ ind) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastHoleGround x₂ ind x₃) = lem-ind-comp comp ind lem-ind-comp (DCCast dc x x₁) (ICastProd x₂ ind) = lem-ind-comp dc ind lem-ind-comp (DCFst d) (IFst ind x x₁) = lem-ind-comp d ind lem-ind-comp (DCSnd d) (ISnd ind x x₁) = lem-ind-comp d ind lem-ind-comp (DCPair d d₁) (IPair1 ind x) = lem-ind-comp d ind lem-ind-comp (DCPair d d₁) (IPair2 x ind) = lem-ind-comp d₁ ind -- complete types that are consistent are equal complete-consistency : ∀{τ1 τ2} → τ1 ~ τ2 → τ1 tcomplete → τ2 tcomplete → τ1 == τ2 complete-consistency TCRefl TCBase comp2 = refl complete-consistency TCRefl (TCArr comp1 comp2) comp3 = refl complete-consistency TCHole1 comp1 () complete-consistency TCHole2 () comp2 complete-consistency (TCArr consis consis₁) (TCArr comp1 comp2) (TCArr comp3 comp4) with complete-consistency consis comp1 comp3 | complete-consistency consis₁ comp2 comp4 ... | refl | refl = refl complete-consistency TCRefl (TCProd tc' tc'') = λ _ → refl complete-consistency (TCProd tc tc') (TCProd tc1 tc2) (TCProd tc3 tc4) with complete-consistency tc tc1 tc3 | complete-consistency tc' tc2 tc4 ... | refl | refl = refl -- a well typed complete term is assigned a complete type complete-ta : ∀{Γ Δ d τ} → (Γ gcomplete) → (Δ , Γ ⊢ d :: τ) → d dcomplete → τ tcomplete complete-ta gc TAConst comp = TCBase complete-ta gc (TAVar x₁) DCVar = gc _ _ x₁ complete-ta gc (TALam a wt) (DCLam comp x₁) = TCArr x₁ (complete-ta (gcomp-extend gc x₁ a ) wt comp) complete-ta gc (TAAp wt wt₁) (DCAp comp comp₁) with complete-ta gc wt comp complete-ta gc (TAAp wt wt₁) (DCAp comp comp₁) | TCArr qq qq₁ = qq₁ complete-ta gc (TAEHole x x₁) () complete-ta gc (TANEHole x wt x₁) () complete-ta gc (TACast wt x) (DCCast comp x₁ x₂) = x₂ complete-ta gc (TAFailedCast wt x x₁ x₂) () complete-ta gc (TAFst wt) (DCFst comp) = lem-comp-prod1 (complete-ta gc wt comp) complete-ta gc (TASnd wt) (DCSnd comp) = lem-comp-prod2 (complete-ta gc wt comp) complete-ta gc (TAPair ta ta₁) (DCPair comp comp₁) = TCProd (complete-ta gc ta comp) (complete-ta gc ta₁ comp₁) -- a well typed term synthesizes a complete type comp-synth : ∀{Γ e τ} → Γ gcomplete → e ecomplete → Γ ⊢ e => τ → τ tcomplete comp-synth gc ec SConst = TCBase comp-synth gc (ECAsc x ec) (SAsc x₁) = x comp-synth gc ec (SVar x) = gc _ _ x comp-synth gc (ECAp ec ec₁) (SAp _ wt MAHole x₁) with comp-synth gc ec wt ... | () comp-synth gc (ECAp ec ec₁) (SAp _ wt MAArr x₁) with comp-synth gc ec wt comp-synth gc (ECAp ec ec₁) (SAp _ wt MAArr x₁) | TCArr qq qq₁ = qq₁ comp-synth gc () SEHole comp-synth gc () (SNEHole _ wt) comp-synth gc (ECLam2 ec x₁) (SLam x₂ wt) = TCArr x₁ (comp-synth (gcomp-extend gc x₁ x₂) ec wt) comp-synth gc (ECFst ec) (SFst wt MPHole) = comp-synth gc ec wt comp-synth gc (ECFst ec) (SFst wt MPProd) = lem-comp-prod1 (comp-synth gc ec wt) comp-synth gc (ECSnd ec) (SSnd wt MPHole) = comp-synth gc ec wt comp-synth gc (ECSnd ec) (SSnd wt MPProd) = lem-comp-prod2 (comp-synth gc ec wt) comp-synth gc (ECPair ec ec₁) (SPair x wt wt₁) = TCProd (comp-synth gc ec wt) (comp-synth gc ec₁ wt₁) -- complete boxed values are just values lem-comp-boxed-val : {Δ : hctx} {d : iexp} {τ : typ} {Γ : tctx} → Δ , Γ ⊢ d :: τ → d dcomplete → d boxedval → d val lem-comp-boxed-val wt comp (BVVal VConst) = VConst lem-comp-boxed-val wt comp (BVVal VLam) = VLam lem-comp-boxed-val wt comp (BVVal (VPair x x₁)) = VPair x x₁ lem-comp-boxed-val (TAPair wt wt₁) (DCPair comp comp₁) (BVPair bv bv₁) = VPair (lem-comp-boxed-val wt comp bv) (lem-comp-boxed-val wt₁ comp₁ bv₁) lem-comp-boxed-val (TACast wt x₃) (DCCast comp x₁ x₂) (BVArrCast x bv) = abort (x (complete-consistency x₃ x₁ x₂)) lem-comp-boxed-val (TACast wt x₁) (DCCast comp x₂ x₃) (BVProdCast x bv) = abort (x (complete-consistency x₁ x₂ x₃)) lem-comp-boxed-val (TACast wt x₁) (DCCast comp x₂ ()) (BVHoleCast x bv)
{ "alphanum_fraction": 0.6326257411, "avg_line_length": 50.7669902913, "ext": "agda", "hexsha": "c8691e6a7901ffcacef193b73e35f5ba0bc48f4a", "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": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda", "max_forks_repo_path": "lemmas-complete.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazel-palette-agda", "max_issues_repo_path": "lemmas-complete.agda", "max_line_length": 117, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazel-palette-agda", "max_stars_repo_path": "lemmas-complete.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z", "num_tokens": 1868, "size": 5229 }
-- Andreas, 2015-12-12, report by Ulf, 2015-12-09 {-# OPTIONS -v tc.with.40 #-} open import Common.Equality open import Common.Bool T : Bool → Set T true = Bool T false = true ≡ false foo : (a b : Bool) → a ≡ b → T a → T b foo a b eq x rewrite eq = x data _≅_ {A : Set} (x : A) : {B : Set} → B → Set where refl : x ≅ x -- Intended new rewrite refl-rewrite : ∀ a (eq : a ≡ a) (t : T a) → foo a a eq t ≡ t refl-rewrite a eq t with eq refl-rewrite a eq t | refl = refl test : ∀ a (eq : a ≡ a) (t : T a) → foo a a eq t ≡ t test a eq t rewrite eq = refl -- FAILS, this is the original issue report -- Error: -- foo a a eq t | a | eq != t of type T a -- when checking that the expression refl has type foo a a eq t ≡ t -- test a refl t = refl -- WORKS, of course -- Non-reflexive rewrite works : ∀ a b (eq : a ≡ b) (t : T a) → foo a b eq t ≅ t works a b eq t rewrite eq = refl -- Manual desugaring of old-style rewrite works as well old-rewrite : ∀ a (eq : a ≡ a) (t : T a) → foo a a eq t ≡ t old-rewrite a eq t with a | eq old-rewrite a eq t | _ | refl = refl
{ "alphanum_fraction": 0.59494855, "avg_line_length": 28.1315789474, "ext": "agda", "hexsha": "eda47efa3cc8ac4d7b38770bdc44c30fea98ea3a", "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/Issue1740.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/Issue1740.agda", "max_line_length": 74, "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/Issue1740.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": 402, "size": 1069 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary open import Cubical.Algebra.Magma module Cubical.Algebra.Magma.Construct.Quotient {c ℓ} (M : Magma c) {R : Rel ⟨ M ⟩ ℓ} (isEq : IsEquivalence R) (closed : Congruent₂ R (Magma._•_ M)) where open import Cubical.Algebra.Properties open import Cubical.HITs.SetQuotients open Magma M open IsEquivalence isEq Carrier/R = Carrier / R _•ᴿ_ : Op₂ Carrier/R _•ᴿ_ = rec2 squash/ (λ x y → [ x • y ]) (λ _ _ _ eq → eq/ _ _ (cong₂⇒rcong R reflexive _•_ closed eq)) (λ _ _ _ eq → eq/ _ _ (cong₂⇒lcong R reflexive _•_ closed eq)) M/R-isMagma : IsMagma Carrier/R _•ᴿ_ M/R-isMagma = record { is-set = squash/ } M/R : Magma (ℓ-max c ℓ) M/R = record { isMagma = M/R-isMagma }
{ "alphanum_fraction": 0.6177474403, "avg_line_length": 32.5555555556, "ext": "agda", "hexsha": "4f304fed8d3c161e6198666c49415f66dd0b0c76", "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/Algebra/Magma/Construct/Quotient.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/Algebra/Magma/Construct/Quotient.agda", "max_line_length": 110, "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/Algebra/Magma/Construct/Quotient.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 295, "size": 879 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Rationals.QuoQ.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Data.Nat as ℕ using (discreteℕ) open import Cubical.Data.NatPlusOne open import Cubical.Data.Sigma open import Cubical.HITs.Ints.QuoInt open import Cubical.HITs.SetQuotients as SetQuotient using ([_]; eq/; discreteSetQuotients) renaming (_/_ to _//_) public open import Cubical.Relation.Nullary open import Cubical.Relation.Binary.Base ℕ₊₁→ℤ : ℕ₊₁ → ℤ ℕ₊₁→ℤ n = pos (ℕ₊₁→ℕ n) private ℕ₊₁→ℤ-hom : ∀ m n → ℕ₊₁→ℤ (m ·₊₁ n) ≡ ℕ₊₁→ℤ m · ℕ₊₁→ℤ n ℕ₊₁→ℤ-hom _ _ = refl -- ℚ as a set quotient of ℤ × ℕ₊₁ (as in the HoTT book) _∼_ : ℤ × ℕ₊₁ → ℤ × ℕ₊₁ → Type₀ (a , b) ∼ (c , d) = a · ℕ₊₁→ℤ d ≡ c · ℕ₊₁→ℤ b ℚ : Type₀ ℚ = (ℤ × ℕ₊₁) // _∼_ isSetℚ : isSet ℚ isSetℚ = SetQuotient.squash/ [_/_] : ℤ → ℕ₊₁ → ℚ [ a / b ] = [ a , b ] isEquivRel∼ : isEquivRel _∼_ isEquivRel.reflexive isEquivRel∼ (a , b) = refl isEquivRel.symmetric isEquivRel∼ (a , b) (c , d) = sym isEquivRel.transitive isEquivRel∼ (a , b) (c , d) (e , f) p q = ·-injʳ _ _ _ r where r = (a · ℕ₊₁→ℤ f) · ℕ₊₁→ℤ d ≡[ i ]⟨ ·-comm a (ℕ₊₁→ℤ f) i · ℕ₊₁→ℤ d ⟩ (ℕ₊₁→ℤ f · a) · ℕ₊₁→ℤ d ≡⟨ sym (·-assoc (ℕ₊₁→ℤ f) a (ℕ₊₁→ℤ d)) ⟩ ℕ₊₁→ℤ f · (a · ℕ₊₁→ℤ d) ≡[ i ]⟨ ℕ₊₁→ℤ f · p i ⟩ ℕ₊₁→ℤ f · (c · ℕ₊₁→ℤ b) ≡⟨ ·-assoc (ℕ₊₁→ℤ f) c (ℕ₊₁→ℤ b) ⟩ (ℕ₊₁→ℤ f · c) · ℕ₊₁→ℤ b ≡[ i ]⟨ ·-comm (ℕ₊₁→ℤ f) c i · ℕ₊₁→ℤ b ⟩ (c · ℕ₊₁→ℤ f) · ℕ₊₁→ℤ b ≡[ i ]⟨ q i · ℕ₊₁→ℤ b ⟩ (e · ℕ₊₁→ℤ d) · ℕ₊₁→ℤ b ≡⟨ sym (·-assoc e (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b)) ⟩ e · (ℕ₊₁→ℤ d · ℕ₊₁→ℤ b) ≡[ i ]⟨ e · ·-comm (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b) i ⟩ e · (ℕ₊₁→ℤ b · ℕ₊₁→ℤ d) ≡⟨ ·-assoc e (ℕ₊₁→ℤ b) (ℕ₊₁→ℤ d) ⟩ (e · ℕ₊₁→ℤ b) · ℕ₊₁→ℤ d ∎ eq/⁻¹ : ∀ x y → Path ℚ [ x ] [ y ] → x ∼ y eq/⁻¹ = SetQuotient.effective (λ _ _ → isSetℤ _ _) isEquivRel∼ discreteℚ : Discrete ℚ discreteℚ = discreteSetQuotients (discreteΣ discreteℤ (λ _ → subst Discrete 1+Path discreteℕ)) (λ _ _ → isSetℤ _ _) isEquivRel∼ (λ _ _ → discreteℤ _ _) -- Natural number and negative integer literals for ℚ open import Cubical.Data.Nat.Literals public instance fromNatℚ : HasFromNat ℚ fromNatℚ = record { Constraint = λ _ → Unit ; fromNat = λ n → [ pos n / 1 ] } instance fromNegℚ : HasFromNeg ℚ fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → [ neg n / 1 ] }
{ "alphanum_fraction": 0.5530455829, "avg_line_length": 32.1948051948, "ext": "agda", "hexsha": "52dbe194f0d7de6c045733c2998466f751ec5387", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/HITs/Rationals/QuoQ/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/HITs/Rationals/QuoQ/Base.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/HITs/Rationals/QuoQ/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1267, "size": 2479 }
module Functors.FullyFaithful where open import Library open import Categories open import Functors open import Naturals hiding (Iso) open import Isomorphism open Cat open Fun FullyFaithful : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} (F : Fun C D) → Set (a ⊔ b ⊔ d) FullyFaithful {C = C}{D = D} F = ∀ (X Y : Obj C) → Iso (Hom D (OMap F X) (OMap F Y)) (Hom C X Y) Full : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} (F : Fun C D) → Set _ Full {C = C}{D = D} F = ∀ {X Y}(h : Hom D (OMap F X) (OMap F Y)) → Σ (Hom C X Y) \ f -> HMap F f ≅ h Faithful : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} (F : Fun C D) → Set _ Faithful {C = C}{D = D} F = ∀{X Y}{f g : Hom C X Y} → HMap F f ≅ HMap F g → f ≅ g
{ "alphanum_fraction": 0.5066137566, "avg_line_length": 30.24, "ext": "agda", "hexsha": "55cfff93f981599e804b0e66f2d26550408e7df4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "Functors/FullyFaithful.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "Functors/FullyFaithful.agda", "max_line_length": 81, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "Functors/FullyFaithful.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 314, "size": 756 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Vehicle.Data.Tensor open import Data.Rational as ℚ using (ℚ) open import Data.Fin as Fin using (Fin; #_) open import Data.List module increasing-temp-output where postulate f : Tensor ℚ (1 ∷ []) → Tensor ℚ (1 ∷ []) abstract increasing : ∀ (x : ℚ) → x ℚ.≤ f (x ∷ []) (# 0) increasing = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" }
{ "alphanum_fraction": 0.6702453988, "avg_line_length": 27.1666666667, "ext": "agda", "hexsha": "0489ce1a17fc9fccdcaea5560f1fc707293baee9", "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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "test/Test/Compile/Golden/increasing/increasing-output.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vehicle-lang/vehicle", "max_issues_repo_path": "test/Test/Compile/Golden/increasing/increasing-output.agda", "max_line_length": 71, "max_stars_count": 9, "max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vehicle-lang/vehicle", "max_stars_repo_path": "test/Test/Compile/Golden/increasing/increasing-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z", "num_tokens": 197, "size": 652 }
module AgdaCheatSheet where open import Level using (Level) open import Data.Nat open import Data.Bool hiding (_<?_) open import Data.List using (List; []; _∷_; length) -- https://alhassy.github.io/AgdaCheatSheet/CheatSheet.pdf {- ------------------------------------------------------------------------------ -- dependent function A function whose RESULT type depends on the VALUE of the argument. -- given value of type A -- return result of type B a (a : A) → B a E.g., generic identity -- input -- the type of X -- value of type X -- output a function X → X -} id0 : (X : Set) → X → X id0 X x = x id1 id2 id3 : (X : Set) → X → X id1 X = λ x → x id2 = λ X x → x id3 = λ (X : Set) (x : X) → x -- call it sad : ℕ sad = id0 ℕ 3 {- ------------------------------------------------------------------------------ -- implicits In above, type arg can be inferred. Use curly braces to mark arg as implicit. -} id : {X : Set} → X → X id x = x -- call it nice : ℕ nice = id 3 -- call with explicit implicit explicit : ℕ explicit = id {ℕ} 3 -- call with explicit inferred implicit explicit’ : ℕ explicit’ = id0 _ 3 {- ------------------------------------------------------------------------------ -- specifying arguments {x : _} {y : _} (z : _) → · · · ≈ ∀ {x y} z → · · · (a1 : A) → (a2 : A) → (b : B) → · · · ≈ (a1 a2 : A) (b : B) → · · · ------------------------------------------------------------------------------ -- dependent datatypes -- data -- name -- arguments -- type of the datatype -- constructors and their types -} data Vec {ℓ : Level} (A : Set ℓ) : ℕ → Set ℓ where [] : Vec A 0 _::_ : {n : ℕ} → A → Vec A n → Vec A (1 + n) {- For a given A, type of Vec A is N → Set. Means Vec A is a FAMILY of types indexed by natural numbers: - For each n, there is a TYPE Vec A n. Vec is - parametrised by A (and ℓ) - indexed by n A is type of elements n is length only way to Vec A 0 is via [] only way to Vec A (1 + n) is via _::_ enables safe head (since empty impossible) -} head : {A : Set} {n : ℕ} → Vec A (1 + n) → A head (x :: xs) = x {- ------------------------------------------------------------------------------ -- universes ℓ arg says Vec is universe polymorphic - can vectors of numbers and also vectors of types Levels are essentially natural numbers: - constructurs - lzero - lsuc - _t_ : max of two levels NO UNIVERSE OF ALL UNIVERSES: - Set n has type Set n+1 for any n - the type (n : Level) → Set n - is not itself typeable — i.e., is not in Set ℓ for any ℓ — Agda errors saying it is a value of Set ω ------------------------------------------------------------------------------ -- functions defined by pattern matching ALL cases must terminate : so recursive calls must be made on structurally smaller arg -} infixr 40 _++_ _++_ : {A : Set} {n m : ℕ} → Vec A n → Vec A m → Vec A (n + m) [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) {- Append type encodes property : length of catenation is sum of args lengths - Different types can have the same constructor names. - Mixifx operators can be written prefix by having all underscores mentioned; e.g., - In def, if an arg is not needed, use _ (wildcard pattern) ------------------------------------------------------------------------------ -- Curry-Howard Correspondence — Propositions as Types Logic Programming Example Use in Programming ================================================================================ proof / proposition element / type “p is a proof of P” ≈ “p is of type P” true singleton type return type of side-effect only methods false empty type return type for non-terminating methods ⇒ function type → methods with an input and output type ∧ product type × simple records of data and methods ∨ sum type + enumerations or tagged unions ∀ dependent function type Π return type varies according to input value ∃ dependent product type Σ record fields depend on each other’s values natural deduction type system ensuring only “meaningful” programs hypothesis free variable global variables, closures modus ponens function application executing methods on arguments ⇒ -introduction λ-abstraction parameters acting as local variables to method definitions induction; elimination rules Structural recursion for-loops are precisely N-induction Signature, term Syntax; interface, record type, class Algebra, Interpretation Semantics; implementation, instance, object Free Theory Data structure Inference rule Algebraic datatype constructor Monoid Untyped programming / composition Category Typed programming / composition ------------------------------------------------------------------------------ -- equality example of propositions-as-types : definition of identity relation (the least reflexive relation) -} data _≡_ {A : Set} : A → A → Set where refl : {x : A} → x ≡ x {- states that refl {x} - is a proof of l ≡ r - whenever l and r simplify to x - by definition chasing only Use it to prove Leibniz’s substitutivity rule, “equals for equals”: -} subst : {A : Set} {P : A → Set} {l r : A} → l ≡ r -- must be of the form refl {x} for some canonical form x → P l -- if l and r are both x, then P l and P r are the same type → P r -- matching on proof l ≡ r gave infor about the rest of the program’s type subst refl it = it ------------------------------------------------------------------------------ -- modules - namespace management -------------------------------------------------- -- SIMPLE MODULES module M where N : Set N = ℕ private x : ℕ x = 3 y : N y = x + 1 -- using it - public names accessible by qualification or by opening them locally or globally use0 : M.N use0 = M.y use1 : ℕ use1 = y where open M {- if open, then causes y in M' to duplicate open M use2 : ℕ use2 = y -} -------------------------------------------------- -- PARAMETERISED MODULES : by arbitrarily many values and types (but not by other modules) module M’ (x : ℕ) where y : ℕ y = x + 1 -- names are functions --exposed : (x : ℕ) → ℕ --exposed = M’.y -- TODO compile error -- using it use’0 : ℕ use’0 = M’.y 3 module M” = M’ 3 use” : ℕ use” = M”.y use’1 : ℕ use’1 = y where open M’ 3 {- “Using Them”: - names in parameterised modules are are treated as functions - can instantiate some parameters and name the resulting module - can still open them as usual -------------------------------------------------- -- ANONYMOUS MODULES -- named-then-immediately-opened modules module _ {A : Set} {a : A} · · · ≈ module T {A : Set} {a : A} · · · open T -- use-case : to approximate the informal phrase -- “for any A : Set and a : A, we have · · · ” -- so common that variable keyword was introduced -- Names in · · · are functions of only those variable-s they actually mention. variable A : Set a : A -------------------------------------------------- -- opening, using, hiding, renaming open M hiding (n0; ...; nk) : treat ni as private open M using (n0; ...; nk) : treat only ni as public open M renaming (n0 to m0; ...; nk to mk) : use names mi instead of ni import X.Y.Z : Use the definitions of module Z which lives in file ./X/Y/Z.agda. open M public : Treat the contents of M as if it is the public contents of the current module Splitting a program over several files improves type checking performance, since only need to type check files influenced by the change. ------------------------------------------------------------------------------ -- records : record ≈ module + data with one constructor -} record PointedSet : Set1 where constructor MkIt {- optional -} field Carrier : Set point : Carrier {- like a module, so can add derived definitions -} blind : {A : Set} → A → Carrier blind = λ a → point -- construct without named constructor ex0 : PointedSet ex0 = record {Carrier = ℕ; point = 3} -- construct with named constructor ex1 : PointedSet ex1 = MkIt ℕ 3 open PointedSet ex2 : PointedSet Carrier ex2 = ℕ point ex2 = 3 {- Start with ex2 = ?, then in the hole enter C-c C-c RET to obtain the co-pattern setup. Two tuples are the same when they have the same components. Likewise a record is defined by its projections, whence co-patterns. If you’re using many local definitions, you likely want to use co-patterns. To enable projection of the fields from a record, each record type comes with a module of the same name. This module is parameterised by an element of the record type and contains projection functions for the fields. -} useR0 : ℕ useR0 = PointedSet.point ex0 {- use¹ : ℕ use¹ = point where open PointedSet ex0 -- TODO compile error -} open PointedSet use² : ℕ use² = blind ex0 true -- pattern match on records use³ : (P : PointedSet) → Carrier P use³ record {Carrier = C; point = x} = x use4 : (P : PointedSet) → Carrier P use4 (MkIt C x) = x {- ------------------------------------------------------------------------------ -- TODO Interacting with the real world —Compilation, Haskell, and IO ------------------------------------------------------------------------------ -- absurd patterns When no constructor are matchable - match the pattern () - provide no right hand side (since no way to could provide an arg to the function) E.g., numbers smaller than a given natural number -} {- Fin n ∼= numbers i with i < n -} data Fin : ℕ → Set where fzero : {n : ℕ} → Fin (suc n) -- smaller than suc n for any n fsuc : {n : ℕ} → Fin n → Fin (suc n) -- if i smaller than n then fsuc i is smaller than suc n. {- for each n, the type Fin n contains n elements - Fin 2 has elements fsuc fzero and fzero - Fin 0 has no elements safe indexing function -} _!!_ : {A : Set} {n : ℕ} → Vec A n → Fin n → A [] !! () -- n is necessarily 0, but no way to make an element of type Fin 0 -- so use absurd pattern (x :: xs) !! fzero = x (x :: xs) !! fsuc i = xs !! i -- Logically “anything follows from false” becomes the following program: data False : Set where magic : {Anything-you-want : Set} → False → Anything-you-want magic () {- do magic x = ? then case split on x yields the program ------------------------------------------------------------------------------ -- isTrue pattern : passing around explicit proof objects -- when not possible/easy to capture a desired precondition in types -} -- An empty record has only one value: record {} -} record True : Set where isTrue : Bool → Set isTrue true = True isTrue false = False _<0_ : ℕ → ℕ → Bool _ <0 zero = false zero <0 suc y = true suc x <0 suc y = x <0 y find : {A : Set} (xs : List A) (i : ℕ) → isTrue (i <0 length xs) → A find [] i () find (x ∷ xs) zero pf = x find (x ∷ xs) (suc i) pf = find xs i pf head’ : {A : Set} (xs : List A) → isTrue (0 <0 length xs) → A head’ [] () head’ (x ∷ xs) _ = x -- Unlike the _!!_ definition -- rather than there being no index into the empty list -- there is no proof that a natural number i is smaller than 0 {- ------------------------------------------------------------------------------ Mechanically Moving from Bool to Set —Avoiding “Boolean Blindness” proposition represented as type whose elements denote proofs Why use? - awkward to request an index be “in bounds” in the find method, - easier to encode this using Fin - likewise, head’ is more elegant type when the non-empty precondition is part of the datatype definition, as in head. recipe : from Boolean functions to inductive datatype families 1. Write the Boolean function. 2. Throw away all the cases with right side false. 3. Every case that has right side true corresponds to a new nullary constructor. 4. Every case that has n recursive calls corresponds to an n-ary constructor. following these steps for _<0_: -} data _<1_ : ℕ → ℕ → Set where z< : {y : ℕ} → zero <1 y s< : {x y : ℕ} → x <1 y → suc x <1 suc y {- then prove - soundness : constructed values correspond to Boolean-true statements ensured by the second step in recipe - completeness : true things correspond to terms formed from constructors. -} completeness : {x y : ℕ} → isTrue (x <0 y) → x <1 y completeness {x} {zero} () completeness {zero} {suc y} p = z< completeness {suc x} {suc y} p = s< (completeness p) {- begin with completeness {x} {y} p = ? then want case on p but that requires evaluating x <0 y which requires we know the shapes of x and y. shape of proofs usually mimics the shape of definitions they use ------------------------------------------------------------------------------ record Payload (A : Set) : Set field pPayload : [a] record BlockType (A : Set) : Set = Proposal (Payload a) Author | NilBlock | Genesis record LastVoteInfo fields lviLiDigest :: HashValue lviRound :: Round lviIsTimeout :: Bool -}
{ "alphanum_fraction": 0.5665900837, "avg_line_length": 27.8206185567, "ext": "agda", "hexsha": "b00e1d1efc8922e848ce00b6d5a5a516cc3467be", "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/AgdaCheatSheet.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/AgdaCheatSheet.agda", "max_line_length": 98, "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/AgdaCheatSheet.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": 3472, "size": 13493 }
module Issue1486 where open import Common.Prelude postulate QName : Set {-# BUILTIN QNAME QName #-} primitive primShowQName : QName -> String main : IO Unit main = putStrLn (primShowQName (quote main))
{ "alphanum_fraction": 0.7333333333, "avg_line_length": 15, "ext": "agda", "hexsha": "315a1c1c6f7105c302271def83d0a8d8858534d6", "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/Compiler/simple/Issue1486.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/Compiler/simple/Issue1486.agda", "max_line_length": 44, "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/Compiler/simple/Issue1486.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": 56, "size": 210 }
-- Andreas, 2014-10-05, issue reported by Stevan Andjelkovic {-# OPTIONS --cubical-compatible #-} postulate IO : Set → Set record ⊤ : Set where constructor tt record Container : Set₁ where field Shape : Set Position : Shape → Set open Container public data W (A : Set) (B : A → Set) : Set where sup : (x : A) (f : B x → W A B) → W A B postulate Ω : Container p : ∀ {s} → Position Ω s mutual bad : W (Shape Ω) (Position Ω) → IO ⊤ bad (sup c k) = helper c k helper : (s : Shape Ω) → (Position Ω s → W (Shape Ω) (Position Ω)) → IO ⊤ helper _ k = bad (k p) -- should pass termination check
{ "alphanum_fraction": 0.6012759171, "avg_line_length": 19, "ext": "agda", "hexsha": "54fab05fea421c4b6de7bd8c529638fd443b80cf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/Issue1292.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/Issue1292.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/Issue1292.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 224, "size": 627 }
open import Coinduction using ( ∞ ) open import Data.ByteString using ( ByteString ; strict ; lazy ) open import Data.String using ( String ) module System.IO.Primitive where infixl 1 _>>=_ -- The Unit type and its sole inhabitant postulate Unit : Set unit : Unit {-# COMPILED_TYPE Unit () #-} {-# COMPILED unit () #-} -- The IO type and its primitives -- TODO: Make these universe-polymorphic once the compiler supports it postulate IO : Set → Set return : {A : Set} → A → (IO A) _>>=_ : {A B : Set} → (IO A) → (A → (IO B)) → (IO B) inf : {A : Set} → ∞(IO A) → (IO A) {-# BUILTIN IO IO #-} {-# COMPILED_TYPE IO IO #-} {-# COMPILED return (\ _ a -> return a) #-} {-# COMPILED _>>=_ (\ _ _ a f -> a >>= f) #-} -- {-# COMPILED inf (\ _ a -> a) #-} -- The commitment primitives postulate commit : IO Unit onCommit : (IO Unit) → (IO Unit) {-# IMPORT System.IO.AgdaFFI #-} {-# COMPILED commit System.IO.AgdaFFI.commit #-} {-# COMPILED onCommit System.IO.AgdaFFI.onCommit #-} -- The low-level binary handle primitives. -- TODO: Should the string etc. functions be built on top of -- the binary functions, or should we link directly to the Haskell -- string functions? -- TODO: Think about append and read-write modes. postulate HandleR : Set stdin : HandleR hOpenR : String → (IO HandleR) hGetLazy : HandleR → (IO (ByteString lazy)) hGetStrict : HandleR → (IO (ByteString strict)) hCloseR : HandleR → (IO Unit) {-# IMPORT System.IO #-} {-# COMPILED_TYPE HandleR System.IO.Handle #-} {-# COMPILED stdin System.IO.stdin #-} {-# COMPILED hOpenR System.IO.AgdaFFI.hOpen System.IO.ReadMode #-} {-# COMPILED hGetStrict System.IO.AgdaFFI.hGetStrict #-} {-# COMPILED hGetLazy System.IO.AgdaFFI.hGetLazy #-} {-# COMPILED hCloseR System.IO.AgdaFFI.hClose #-} postulate HandleW : Set stdout : HandleW stderr : HandleW hOpenW : String → (IO HandleW) hPutLazy : HandleW → (ByteString lazy) → (IO Unit) hPutStrict : HandleW → (ByteString strict) → (IO Unit) hCloseW : HandleW → (IO Unit) {-# COMPILED_TYPE HandleW System.IO.Handle #-} {-# COMPILED stdout System.IO.stdout #-} {-# COMPILED stderr System.IO.stderr #-} {-# COMPILED hOpenW System.IO.AgdaFFI.hOpen System.IO.WriteMode #-} {-# COMPILED hPutStrict System.IO.AgdaFFI.hPutStrict #-} {-# COMPILED hPutLazy System.IO.AgdaFFI.hPutLazy #-} {-# COMPILED hCloseW System.IO.AgdaFFI.hClose #-}
{ "alphanum_fraction": 0.6676458246, "avg_line_length": 29.7875, "ext": "agda", "hexsha": "9242cf4a19e3ec4b67037475dcd2ccaab9563d48", "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": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Primitive.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/Primitive.agda", "max_line_length": 70, "max_stars_count": null, "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/Primitive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 701, "size": 2383 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Base definitions for the left-biased universe-sensitive functor and -- monad instances for These. -- -- To minimize the universe level of the RawFunctor, we require that -- elements of B are "lifted" to a copy of B at a higher universe level -- (a ⊔ b). -- See the Data.Product.Categorical.Examples for how this is done in a -- Product-based similar setting. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Level module Data.These.Categorical.Left.Base {a} (A : Set a) (b : Level) where open import Data.These open import Category.Functor open import Category.Applicative open import Category.Monad open import Function Theseₗ : Set (a ⊔ b) → Set (a ⊔ b) Theseₗ B = These A B functor : RawFunctor Theseₗ functor = record { _<$>_ = map₂ } ------------------------------------------------------------------------ -- Get access to other monadic functions module _ {F} (App : RawApplicative {a ⊔ b} F) where open RawApplicative App sequenceA : ∀ {A} → Theseₗ (F A) → F (Theseₗ A) sequenceA (this a) = pure (this a) sequenceA (that b) = that <$> b sequenceA (these a b) = these a <$> b mapA : ∀ {A B} → (A → F B) → Theseₗ A → F (Theseₗ B) mapA f = sequenceA ∘ map₂ f forA : ∀ {A B} → Theseₗ A → (A → F B) → F (Theseₗ B) forA = flip mapA module _ {M} (Mon : RawMonad {a ⊔ b} M) where private App = RawMonad.rawIApplicative Mon sequenceM : ∀ {A} → Theseₗ (M A) → M (Theseₗ A) sequenceM = sequenceA App mapM : ∀ {A B} → (A → M B) → Theseₗ A → M (Theseₗ B) mapM = mapA App forM : ∀ {A B} → Theseₗ A → (A → M B) → M (Theseₗ B) forM = forA App
{ "alphanum_fraction": 0.564479638, "avg_line_length": 28.5161290323, "ext": "agda", "hexsha": "f7b2633d01edcae9a34bad5098a76db7e60ef036", "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/These/Categorical/Left/Base.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/These/Categorical/Left/Base.agda", "max_line_length": 73, "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/These/Categorical/Left/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 535, "size": 1768 }
open import Data.Sum open import Data.Fin open import Data.Maybe open import Signature module MixedTest (Σ : Sig) (D : Set) where -- Δ : Sig -- Δ = record { ∥_∥ = D ; ar = λ x → Fin 1 } mutual data Term : Set where cons : ⟪ Σ ⟫ (Term ⊎ CoTerm) → Term record CoTerm : Set where coinductive field destr : D → Maybe (Term ⊎ CoTerm) open CoTerm public
{ "alphanum_fraction": 0.6368563686, "avg_line_length": 18.45, "ext": "agda", "hexsha": "9f4a82057b9a432b14996cdb66e8cdd1767f2edd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "LP/MixedTest.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "LP/MixedTest.agda", "max_line_length": 44, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "LP/MixedTest.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 125, "size": 369 }
{-# OPTIONS --safe --cubical #-} module Erased-cubical.Cubical-again where open import Agda.Builtin.Cubical.Path open import Erased-cubical.Erased public -- Code defined using --erased-cubical can be imported and used by -- regular Cubical Agda code. _ : {A : Set} → A → ∥ A ∥ _ = ∣_∣ -- The constructor trivialᶜ is defined in a module that uses --cubical -- and re-exported from a module that uses --erased-cubical. Because -- the current module uses --cubical it is fine to use trivialᶜ in a -- non-erased setting. _ : {A : Set} (x y : ∥ A ∥ᶜ) → x ≡ y _ = trivialᶜ
{ "alphanum_fraction": 0.6916376307, "avg_line_length": 26.0909090909, "ext": "agda", "hexsha": "c64aef2136856799c87cefc2f39d9db7410d465e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Erased-cubical/Cubical-again.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "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": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Erased-cubical/Cubical-again.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Erased-cubical/Cubical-again.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 193, "size": 574 }
-- 2015-05-05 Bad error message _=R_ : Rel → Rel → Set R =R S : (R ⊆ S) × (S ⊆ R) -- here is a typo, : instead of = ldom : Rel → Pred ldom R a = ∃ λ b → R a b -- More than one matching type signature for left hand side ldom R a -- it could belong to any of: ldom R
{ "alphanum_fraction": 0.6044776119, "avg_line_length": 24.3636363636, "ext": "agda", "hexsha": "8724555ba8075b494d6965f77dc69cc07c2361d7", "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/Issue1499.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/Issue1499.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1499.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": 99, "size": 268 }
module Data.Finitude.FinType where open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Data.Nat as ℕ open import Data.Fin as Fin using (Fin; #_) open import Data.Finitude open import Function.Equality using (_⟨$⟩_) open import Function.Injection as Inj using (Injective) open import Function.Inverse as Inv using (Inverse) open import Data.Vec open import Data.Vec.Membership.Propositional open import Data.Vec.Membership.Propositional.Properties open import Data.Vec.Membership.Propositional.Distinct as Distinct using (Distinct) record FinType {a} (A : Set a) : Set a where field size : ℕ finitude : Finitude (P.setoid A) size open import Data.Vec.Properties index : A → Fin size index = Inverse.to finitude ⟨$⟩_ index-injective : ∀ {x y} → index x ≡ index y → x ≡ y index-injective = Inverse.injective finitude enum : Fin size → A enum = Inverse.from finitude ⟨$⟩_ enum-injective : ∀ {i j} → enum i ≡ enum j → i ≡ j enum-injective = Inverse.injective (Inv.sym finitude) elems : Vec A size elems = tabulate enum elems-distinct : Distinct elems elems-distinct = Distinct.tabulate (Inverse.injection (Inv.sym finitude)) _∈elems : ∀ x → x ∈ elems x ∈elems rewrite P.sym (Inverse.left-inverse-of finitude x) = ∈-tabulate⁺ enum (index x) open FinType ⦃ ... ⦄ using (index ; _∈elems) size : ∀ {a} (A : Set a) ⦃ fin : FinType A ⦄ → ℕ size A {{ fin }} = FinType.size fin elems : ∀ {a} (A : Set a) ⦃ fin : FinType A ⦄ → Vec A (size A) elems A {{ fin }} = FinType.elems fin instance open import Data.Bool open import Data.Unit open import Data.Empty empty : FinType ⊥ empty = record { size = 0 ; finitude = record { to = P.→-to-⟶ λ() ; from = P.→-to-⟶ λ() ; inverse-of = record { left-inverse-of = λ () ; right-inverse-of = λ () } } } unit : FinType ⊤ unit = record { size = 1 ; finitude = record { to = P.→-to-⟶ λ _ → Fin.zero ; from = P.→-to-⟶ λ _ → tt ; inverse-of = record { left-inverse-of = λ _ → P.refl ; right-inverse-of = λ { Fin.zero → P.refl ; (Fin.suc ()) } } } } bool : FinType Bool bool = record { size = 2 ; finitude = record { to = P.→-to-⟶ λ { false → # 0 ; true → # 1 } ; from = P.→-to-⟶ λ { Fin.zero → false ; (Fin.suc Fin.zero) → true ; (Fin.suc (Fin.suc ())) } ; inverse-of = record { left-inverse-of = λ { false → P.refl ; true → P.refl } ; right-inverse-of = λ { Fin.zero → P.refl ; (Fin.suc Fin.zero) → P.refl ; (Fin.suc (Fin.suc ())) } } } } private bools : Vec Bool _ bools = elems Bool example : bools ≡ false ∷ true ∷ [] example = P.refl
{ "alphanum_fraction": 0.5679012346, "avg_line_length": 29.7551020408, "ext": "agda", "hexsha": "b68b39b18c7d82d0d9fc7feca2b378cbe346a60a", "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": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_path": "src/Data/Finitude/FinType.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tizmd/agda-finitary", "max_issues_repo_path": "src/Data/Finitude/FinType.agda", "max_line_length": 109, "max_stars_count": null, "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_path": "src/Data/Finitude/FinType.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 895, "size": 2916 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.types.Group open import lib.types.Bool open import lib.types.Nat open import lib.types.Pi open import lib.types.Sigma open import lib.groups.Homomorphisms open import lib.groups.Lift open import lib.groups.Unit module lib.groups.GroupProduct where {- binary product -} ×-group-struct : ∀ {i j} {A : Type i} {B : Type j} (GS : GroupStructure A) (HS : GroupStructure B) → GroupStructure (A × B) ×-group-struct GS HS = record { ident = (ident GS , ident HS); inv = λ {(g , h) → (inv GS g , inv HS h)}; comp = λ {(g₁ , h₁) (g₂ , h₂) → (comp GS g₁ g₂ , comp HS h₁ h₂)}; unitl = λ {(g , h) → pair×= (unitl GS g) (unitl HS h)}; unitr = λ {(g , h) → pair×= (unitr GS g) (unitr HS h)}; assoc = λ {(g₁ , h₁) (g₂ , h₂) (g₃ , h₃) → pair×= (assoc GS g₁ g₂ g₃) (assoc HS h₁ h₂ h₃)}; invl = λ {(g , h) → pair×= (invl GS g) (invl HS h)}; invr = λ {(g , h) → pair×= (invr GS g) (invr HS h)}} where open GroupStructure _×ᴳ_ : ∀ {i j} → Group i → Group j → Group (lmax i j) _×ᴳ_ (group A A-level A-struct) (group B B-level B-struct) = group (A × B) (×-level A-level B-level) (×-group-struct A-struct B-struct) {- general product -} Π-group-struct : ∀ {i j} {I : Type i} {A : I → Type j} (FS : (i : I) → GroupStructure (A i)) → GroupStructure (Π I A) Π-group-struct FS = record { ident = ident ∘ FS; inv = λ f i → inv (FS i) (f i); comp = λ f g i → comp (FS i) (f i) (g i); unitl = λ f → (λ= (λ i → unitl (FS i) (f i))); unitr = λ f → (λ= (λ i → unitr (FS i) (f i))); assoc = λ f g h → (λ= (λ i → assoc (FS i) (f i) (g i) (h i))); invl = λ f → (λ= (λ i → invl (FS i) (f i))); invr = λ f → (λ= (λ i → invr (FS i) (f i)))} where open GroupStructure Πᴳ : ∀ {i j} (I : Type i) (F : I → Group j) → Group (lmax i j) Πᴳ I F = group (Π I (El ∘ F)) (Π-level (λ i → El-level (F i))) (Π-group-struct (group-struct ∘ F)) where open Group {- the product of abelian groups is abelian -} ×ᴳ-abelian : ∀ {i j} {G : Group i} {H : Group j} → is-abelian G → is-abelian H → is-abelian (G ×ᴳ H) ×ᴳ-abelian aG aH (g₁ , h₁) (g₂ , h₂) = pair×= (aG g₁ g₂) (aH h₁ h₂) Πᴳ-abelian : ∀ {i j} {I : Type i} {F : I → Group j} → (∀ i → is-abelian (F i)) → is-abelian (Πᴳ I F) Πᴳ-abelian aF f₁ f₂ = λ= (λ i → aF i (f₁ i) (f₂ i)) {- defining a homomorphism into a binary product -} ×ᴳ-hom-in : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} → (G →ᴳ H) → (G →ᴳ K) → (G →ᴳ H ×ᴳ K) ×ᴳ-hom-in (group-hom h h-comp) (group-hom k k-comp) = record { f = λ x → (h x , k x); pres-comp = λ x y → pair×= (h-comp x y) (k-comp x y)} {- projection homomorphisms -} ×ᴳ-fst : ∀ {i j} {G : Group i} {H : Group j} → (G ×ᴳ H →ᴳ G) ×ᴳ-fst = record {f = fst; pres-comp = λ _ _ → idp} ×ᴳ-snd : ∀ {i j} {G : Group i} {H : Group j} → (G ×ᴳ H →ᴳ H) ×ᴳ-snd = record {f = snd; pres-comp = λ _ _ → idp} Πᴳ-proj : ∀ {i j} {I : Type i} {F : I → Group j} (i : I) → (Πᴳ I F →ᴳ F i) Πᴳ-proj i = record { f = λ f → f i; pres-comp = λ _ _ → idp} {- injection homomorphisms -} module _ {i j} {G : Group i} {H : Group j} where ×ᴳ-inl : G →ᴳ G ×ᴳ H ×ᴳ-inl = ×ᴳ-hom-in (idhom G) cst-hom ×ᴳ-inr : H →ᴳ G ×ᴳ H ×ᴳ-inr = ×ᴳ-hom-in (cst-hom {H = G}) (idhom H) ×ᴳ-diag : ∀ {i} {G : Group i} → (G →ᴳ G ×ᴳ G) ×ᴳ-diag = ×ᴳ-hom-in (idhom _) (idhom _) {- when G is abelian, we can define a map H×K → G as a sum of maps - H → G and K → G (that is, the product behaves as a sum) -} module _ {i j k} {G : Group i} {H : Group j} {K : Group k} (G-abelian : is-abelian G) where private module G = Group G module H = Group H module K = Group K lemma : (g₁ g₂ g₃ g₄ : G.El) → G.comp (G.comp g₁ g₂) (G.comp g₃ g₄) == G.comp (G.comp g₁ g₃) (G.comp g₂ g₄) lemma g₁ g₂ g₃ g₄ = (g₁ □ g₂) □ (g₃ □ g₄) =⟨ G.assoc g₁ g₂ (g₃ □ g₄) ⟩ g₁ □ (g₂ □ (g₃ □ g₄)) =⟨ G-abelian g₃ g₄ |in-ctx (λ w → g₁ □ (g₂ □ w)) ⟩ g₁ □ (g₂ □ (g₄ □ g₃)) =⟨ ! (G.assoc g₂ g₄ g₃) |in-ctx (λ w → g₁ □ w) ⟩ g₁ □ ((g₂ □ g₄) □ g₃) =⟨ G-abelian (g₂ □ g₄) g₃ |in-ctx (λ w → g₁ □ w) ⟩ g₁ □ (g₃ □ (g₂ □ g₄)) =⟨ ! (G.assoc g₁ g₃ (g₂ □ g₄)) ⟩ (g₁ □ g₃) □ (g₂ □ g₄) ∎ where _□_ = G.comp ×ᴳ-sum-hom : (H →ᴳ G) → (K →ᴳ G) → (H ×ᴳ K →ᴳ G) ×ᴳ-sum-hom φ ψ = record { f = λ {(h , k) → G.comp (φ.f h) (ψ.f k)}; pres-comp = λ {(h₁ , k₁) (h₂ , k₂) → G.comp (φ.f (H.comp h₁ h₂)) (ψ.f (K.comp k₁ k₂)) =⟨ φ.pres-comp h₁ h₂ |in-ctx (λ w → G.comp w (ψ.f (K.comp k₁ k₂))) ⟩ G.comp (G.comp (φ.f h₁) (φ.f h₂)) (ψ.f (K.comp k₁ k₂)) =⟨ ψ.pres-comp k₁ k₂ |in-ctx (λ w → G.comp (G.comp (φ.f h₁) (φ.f h₂)) w) ⟩ G.comp (G.comp (φ.f h₁) (φ.f h₂)) (G.comp (ψ.f k₁) (ψ.f k₂)) =⟨ lemma (φ.f h₁) (φ.f h₂) (ψ.f k₁) (ψ.f k₂) ⟩ G.comp (G.comp (φ.f h₁) (ψ.f k₁)) (G.comp (φ.f h₂) (ψ.f k₂)) ∎}} where module φ = GroupHom φ module ψ = GroupHom ψ abstract ×ᴳ-sum-hom-η : ∀ {i j} (G : Group i) (H : Group j) (aGH : is-abelian (G ×ᴳ H)) → idhom (G ×ᴳ H) == ×ᴳ-sum-hom aGH (×ᴳ-inl {G = G}) (×ᴳ-inr {G = G}) ×ᴳ-sum-hom-η G H aGH = hom= _ _ $ λ= $ λ {(g , h) → ! (pair×= (Group.unitr G g) (Group.unitl H h))} ∘-×ᴳ-sum-hom : ∀ {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l} (aK : is-abelian K) (aL : is-abelian L) (φ : K →ᴳ L) (ψ : G →ᴳ K) (χ : H →ᴳ K) → ×ᴳ-sum-hom aL (φ ∘ᴳ ψ) (φ ∘ᴳ χ) == φ ∘ᴳ (×ᴳ-sum-hom aK ψ χ) ∘-×ᴳ-sum-hom aK aL φ ψ χ = hom= _ _ $ λ= $ λ {(g , h) → ! (GroupHom.pres-comp φ (GroupHom.f ψ g) (GroupHom.f χ h))} {- define a homomorphism G₁ × G₂ → H₁ × H₂ from homomorphisms - G₁ → H₁ and G₂ → H₂ -} ×ᴳ-parallel-hom : ∀ {i j k l} {G₁ : Group i} {G₂ : Group j} {H₁ : Group k} {H₂ : Group l} → (G₁ →ᴳ H₁) → (G₂ →ᴳ H₂) → (G₁ ×ᴳ G₂ →ᴳ H₁ ×ᴳ H₂) ×ᴳ-parallel-hom φ ψ = record { f = λ {(h₁ , h₂) → (φ.f h₁ , ψ.f h₂)}; pres-comp = λ {(h₁ , h₂) (h₁' , h₂') → pair×= (φ.pres-comp h₁ h₁') (ψ.pres-comp h₂ h₂')}} where module φ = GroupHom φ module ψ = GroupHom ψ {- 0ᴳ is a unit for product -} ×ᴳ-unit-l : ∀ {i} {G : Group i} → 0ᴳ {i} ×ᴳ G == G ×ᴳ-unit-l = group-ua (×ᴳ-snd {G = 0ᴳ} , is-eq snd (λ g → (lift unit , g)) (λ _ → idp) (λ _ → idp)) ×ᴳ-unit-r : ∀ {i} {G : Group i} → G ×ᴳ 0ᴳ {i} == G ×ᴳ-unit-r = group-ua (×ᴳ-fst , (is-eq fst (λ g → (g , lift unit)) (λ _ → idp) (λ _ → idp))) {- A product Πᴳ indexed by Bool is the same as a binary product -} module _ {i} (Pick : Lift {j = i} Bool → Group i) where Πᴳ-Bool-is-×ᴳ : Πᴳ (Lift Bool) Pick == (Pick (lift true)) ×ᴳ (Pick (lift false)) Πᴳ-Bool-is-×ᴳ = group-ua (φ , e) where φ = ×ᴳ-hom-in (Πᴳ-proj {F = Pick} (lift true)) (Πᴳ-proj {F = Pick} (lift false)) e : is-equiv (GroupHom.f φ) e = is-eq _ (λ {(g , h) → λ {(lift true) → g; (lift false) → h}}) (λ _ → idp) (λ _ → λ= (λ {(lift true) → idp; (lift false) → idp})) {- Commutativity of ×ᴳ -} ×ᴳ-comm : ∀ {i j} (H : Group i) (K : Group j) → H ×ᴳ K ≃ᴳ K ×ᴳ H ×ᴳ-comm H K = (record { f = λ {(h , k) → (k , h)}; pres-comp = λ _ _ → idp} , snd (equiv _ (λ {(k , h) → (h , k)}) (λ _ → idp) (λ _ → idp))) {- Associativity of ×ᴳ -} ×ᴳ-assoc : ∀ {i j k} (G : Group i) (H : Group j) (K : Group k) → ((G ×ᴳ H) ×ᴳ K) == (G ×ᴳ (H ×ᴳ K)) ×ᴳ-assoc G H K = group-ua (record { f = λ {((g , h) , k) → (g , (h , k))}; pres-comp = λ _ _ → idp} , snd (equiv _ (λ {(g , (h , k)) → ((g , h) , k)}) (λ _ → idp) (λ _ → idp))) module _ {i} where _^ᴳ_ : Group i → ℕ → Group i H ^ᴳ O = 0ᴳ H ^ᴳ (S n) = H ×ᴳ (H ^ᴳ n) ^ᴳ-sum : (H : Group i) (m n : ℕ) → (H ^ᴳ m) ×ᴳ (H ^ᴳ n) == H ^ᴳ (m + n) ^ᴳ-sum H O n = ×ᴳ-unit-l {G = H ^ᴳ n} ^ᴳ-sum H (S m) n = ×ᴳ-assoc H (H ^ᴳ m) (H ^ᴳ n) ∙ ap (λ K → H ×ᴳ K) (^ᴳ-sum H m n)
{ "alphanum_fraction": 0.4915514593, "avg_line_length": 35.1891891892, "ext": "agda", "hexsha": "5182611b57d76b254163117dbd4db38beddd34e7", "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": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "lib/groups/GroupProduct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "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": "danbornside/HoTT-Agda", "max_issues_repo_path": "lib/groups/GroupProduct.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "lib/groups/GroupProduct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3835, "size": 7812 }
postulate f : {A B : Set₁} (C : Set) → C → C module _ (A B C : Set) where test : Set test = {!!}
{ "alphanum_fraction": 0.4857142857, "avg_line_length": 13.125, "ext": "agda", "hexsha": "375171c91e16645cca6160393f9e7476af0202c8", "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/Issue952.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/Issue952.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue952.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": 45, "size": 105 }
module _ where module A where infix 2 c infix 1 d syntax c x = x ↑ syntax d x y = x ↓ y data D : Set where ● : D c : D → D d : D → D → D module B where syntax d x y = x ↓ y data D : Set where d : D → D → D open A open B rejected : A.D rejected = ● ↑ ↓ ●
{ "alphanum_fraction": 0.4983050847, "avg_line_length": 10.5357142857, "ext": "agda", "hexsha": "a2c3ec2a7f288a35a511e49fc62bbdc2f9d5e57f", "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/Issue1436-5.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/Issue1436-5.agda", "max_line_length": 22, "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/Issue1436-5.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": 115, "size": 295 }
{-# NON_TERMINATING #-} mutual data D : Set where c : T₁ → D T₁ : Set T₁ = T₂ T₂ : Set T₂ = T₁ → D
{ "alphanum_fraction": 0.4871794872, "avg_line_length": 9, "ext": "agda", "hexsha": "53c3d37d9d719158c670f5fc284f2d96d4e85f0a", "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/BadInductionRecursion5.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/BadInductionRecursion5.agda", "max_line_length": 23, "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/BadInductionRecursion5.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": 51, "size": 117 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Polynomials.Multivariate.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat renaming (_+_ to _+n_) open import Cubical.Data.Vec open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing private variable ℓ ℓ' : Level module _ (A' : CommRing ℓ) where private A = fst A' open CommRingStr (snd A') ----------------------------------------------------------------------------- -- Definition data Poly (n : ℕ) : Type ℓ where -- elements 0P : Poly n base : (v : Vec ℕ n) → (a : A) → Poly n _poly+_ : (P : Poly n) → (Q : Poly n) → Poly n -- AbGroup eq poly+Assoc : (P Q R : Poly n) → P poly+ (Q poly+ R) ≡ (P poly+ Q) poly+ R poly+IdR : (P : Poly n) → P poly+ 0P ≡ P poly+Comm : (P Q : Poly n) → P poly+ Q ≡ Q poly+ P -- Base eq base-0P : (v : Vec ℕ n) → base v 0r ≡ 0P base-poly+ : (v : Vec ℕ n) → (a b : A) → (base v a) poly+ (base v b) ≡ base v (a + b) -- Set Trunc trunc : isSet(Poly n) ----------------------------------------------------------------------------- -- Induction and Recursion module _ (A' : CommRing ℓ) where private A = fst A' open CommRingStr (snd A') module Poly-Ind-Set -- types (n : ℕ) (F : (P : Poly A' n) → Type ℓ') (issd : (P : Poly A' n) → isSet (F P)) -- elements (0P* : F 0P) (base* : (v : Vec ℕ n) → (a : A) → F (base v a)) (_poly+*_ : {P Q : Poly A' n} → (PS : F P) → (QS : F Q) → F (P poly+ Q)) -- AbGroup eq (poly+Assoc* : {P Q R : Poly A' n} → (PS : F P) → (QS : F Q) → (RS : F R) → PathP (λ i → F (poly+Assoc P Q R i)) (PS poly+* (QS poly+* RS)) ((PS poly+* QS) poly+* RS)) (poly+IdR* : {P : Poly A' n} → (PS : F P) → PathP (λ i → F (poly+IdR P i)) (PS poly+* 0P*) PS) (poly+Comm* : {P Q : Poly A' n} → (PS : F P) → (QS : F Q) → PathP (λ i → F (poly+Comm P Q i)) (PS poly+* QS) (QS poly+* PS)) -- Base eq (base-0P* : (v : Vec ℕ n) → PathP (λ i → F (base-0P v i)) (base* v 0r) 0P*) (base-poly+* : (v : Vec ℕ n) → (a b : A) → PathP (λ i → F (base-poly+ v a b i)) ((base* v a) poly+* (base* v b)) (base* v (a + b))) where f : (P : Poly A' n) → F P f 0P = 0P* f (base v a) = base* v a f (P poly+ Q) = (f P) poly+* (f Q) f (poly+Assoc P Q R i) = poly+Assoc* (f P) (f Q) (f R) i f (poly+IdR P i) = poly+IdR* (f P) i f (poly+Comm P Q i) = poly+Comm* (f P) (f Q) i f (base-0P v i) = base-0P* v i f (base-poly+ v a b i) = base-poly+* v a b i f (trunc P Q p q i j) = isOfHLevel→isOfHLevelDep 2 issd (f P) (f Q) (cong f p) (cong f q) (trunc P Q p q) i j module Poly-Rec-Set -- types (n : ℕ) (B : Type ℓ') (iss : isSet B) -- elements (0P* : B) (base* : (v : Vec ℕ n) → (a : A) → B) (_poly+*_ : B → B → B) -- AbGroup eq (poly+Assoc* : (PS QS RS : B) → (PS poly+* (QS poly+* RS)) ≡ ((PS poly+* QS) poly+* RS)) (poly+IdR* : (PS : B) → (PS poly+* 0P*) ≡ PS) (poly+Comm* : (PS QS : B) → (PS poly+* QS) ≡ (QS poly+* PS)) -- Base eq (base-0P* : (v : Vec ℕ n) → (base* v 0r) ≡ 0P*) (base-poly+* : (v : Vec ℕ n) → (a b : A) → ((base* v a) poly+* (base* v b)) ≡ (base* v (a + b))) where f : Poly A' n → B f = Poly-Ind-Set.f n (λ _ → B) (λ _ → iss) 0P* base* _poly+*_ poly+Assoc* poly+IdR* poly+Comm* base-0P* base-poly+* module Poly-Ind-Prop -- types (n : ℕ) (F : (P : Poly A' n) → Type ℓ') (ispd : (P : Poly A' n) → isProp (F P)) -- elements (0P* : F 0P) (base* : (v : Vec ℕ n) → (a : A) → F (base v a)) (_poly+*_ : {P Q : Poly A' n} → (PS : F P) → (QS : F Q) → F (P poly+ Q)) where f : (P : Poly A' n) → F P f = Poly-Ind-Set.f n F (λ P → isProp→isSet (ispd P)) 0P* base* _poly+*_ (λ {P Q R} PS QS RQ → toPathP (ispd _ (transport (λ i → F (poly+Assoc P Q R i)) _) _)) (λ {P} PS → toPathP (ispd _ (transport (λ i → F (poly+IdR P i)) _) _)) (λ {P Q} PS QS → toPathP (ispd _ (transport (λ i → F (poly+Comm P Q i)) _) _)) (λ v → toPathP (ispd _ (transport (λ i → F (base-0P v i)) _) _)) (λ v a b → toPathP (ispd _ (transport (λ i → F (base-poly+ v a b i)) _) _)) module Poly-Rec-Prop -- types (n : ℕ) (B : Type ℓ') (isp : isProp B) -- elements (0P* : B) (base* : (v : Vec ℕ n) → (a : A) → B) (_poly+*_ : B → B → B) where f : Poly A' n → B f = Poly-Ind-Prop.f n (λ _ → B) (λ _ → isp) 0P* base* _poly+*_
{ "alphanum_fraction": 0.4532601815, "avg_line_length": 34.8455882353, "ext": "agda", "hexsha": "b22849d2fbaef9ed2424e00747a5d46efa059474", "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": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/cubical", "max_forks_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "guilhermehas/cubical", "max_issues_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Base.agda", "max_line_length": 119, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/cubical", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Multivariate/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 1939, "size": 4739 }
------------------------------------------------------------------------ -- The syntax of, and a type system for, the untyped λ-calculus with -- constants ------------------------------------------------------------------------ module Lambda.Syntax where open import Codata.Musical.Notation open import Data.Nat open import Data.Fin hiding (_≤?_) open import Data.Vec open import Relation.Nullary.Decidable ------------------------------------------------------------------------ -- Terms -- Variables are represented using de Bruijn indices. infixl 9 _·_ data Tm (n : ℕ) : Set where con : (i : ℕ) → Tm n var : (x : Fin n) → Tm n ƛ : (t : Tm (suc n)) → Tm n _·_ : (t₁ t₂ : Tm n) → Tm n -- Convenient helper. vr : ∀ m {n} {m<n : True (suc m ≤? n)} → Tm n vr _ {m<n = m<n} = var (#_ _ {m<n = m<n}) ------------------------------------------------------------------------ -- Values, potentially with free variables module WHNF where data Value (n : ℕ) : Set where con : (i : ℕ) → Value n ƛ : (t : Tm (suc n)) → Value n ⌜_⌝ : ∀ {n} → Value n → Tm n ⌜ con i ⌝ = con i ⌜ ƛ t ⌝ = ƛ t ------------------------------------------------------------------------ -- Closure-based definition of values -- Environments and values. Defined in a module parametrised on the -- type of terms. module Closure (Tm : ℕ → Set) where mutual -- Environments. Env : ℕ → Set Env n = Vec Value n -- Values. Lambdas are represented using closures, so values do -- not contain any free variables. data Value : Set where con : (i : ℕ) → Value ƛ : ∀ {n} (t : Tm (suc n)) (ρ : Env n) → Value ------------------------------------------------------------------------ -- Type system (following Leroy and Grall) -- Recursive, simple types, defined coinductively. infixr 8 _⇾_ data Ty : Set where nat : Ty _⇾_ : (σ τ : ∞ Ty) → Ty -- Contexts. Ctxt : ℕ → Set Ctxt n = Vec Ty n -- Type system. infix 4 _⊢_∈_ data _⊢_∈_ {n} (Γ : Ctxt n) : Tm n → Ty → Set where con : ∀ {i} → Γ ⊢ con i ∈ nat var : ∀ {x} → Γ ⊢ var x ∈ lookup Γ x ƛ : ∀ {t σ τ} (t∈ : ♭ σ ∷ Γ ⊢ t ∈ ♭ τ) → Γ ⊢ ƛ t ∈ σ ⇾ τ _·_ : ∀ {t₁ t₂ σ τ} (t₁∈ : Γ ⊢ t₁ ∈ σ ⇾ τ) (t₂∈ : Γ ⊢ t₂ ∈ ♭ σ) → Γ ⊢ t₁ · t₂ ∈ ♭ τ ------------------------------------------------------------------------ -- Example -- A non-terminating term. ω : Tm 0 ω = ƛ (vr 0 · vr 0) Ω : Tm 0 Ω = ω · ω -- Ω is well-typed. Ω-well-typed : (τ : Ty) → [] ⊢ Ω ∈ τ Ω-well-typed τ = _·_ {σ = ♯ σ} {τ = ♯ τ} (ƛ (var · var)) (ƛ (var · var)) where σ = ♯ σ ⇾ ♯ τ -- A call-by-value fix-point combinator. Z : Tm 0 Z = ƛ (t · t) where t = ƛ (vr 1 · ƛ (vr 1 · vr 1 · vr 0)) -- This combinator is also well-typed. fix-well-typed : ∀ {σ τ} → [] ⊢ Z ∈ ♯ (♯ (σ ⇾ τ) ⇾ ♯ (σ ⇾ τ)) ⇾ ♯ (σ ⇾ τ) fix-well-typed = ƛ (_·_ {σ = υ} {τ = ♯ _} (ƛ (var · ƛ (var · var · var))) (ƛ (var · ƛ (var · var · var)))) where υ : ∞ Ty υ = ♯ (υ ⇾ ♯ _)
{ "alphanum_fraction": 0.4373522459, "avg_line_length": 22.9534883721, "ext": "agda", "hexsha": "7c01c767383c44ce70d11d36c1501e79c8054043", "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": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "Lambda/Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "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/codata", "max_issues_repo_path": "Lambda/Syntax.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "Lambda/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 1078, "size": 2961 }
{-# OPTIONS --rewriting #-} open import Agda.Builtin.Equality postulate _↦_ : ∀ {a} {A : Set a} → A → A → Set {-# BUILTIN REWRITE _↦_ #-} postulate T : (Set → Set → Set) → Set T₀ : Set module _ (F : Set → Set) where postulate rew : T (λ X Y → F X) ↦ T₀ {-# REWRITE rew #-} test : T (λ X Y → F X) ≡ T₀ test = refl
{ "alphanum_fraction": 0.5375375375, "avg_line_length": 16.65, "ext": "agda", "hexsha": "9cc9f1c8e80ec802109108ade3c202c42275ca60", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/HORewritingInParametrizedModule.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/HORewritingInParametrizedModule.agda", "max_line_length": 47, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/HORewritingInParametrizedModule.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": 131, "size": 333 }
module Oscar.Class.TermSubstitution.Internal {𝔣} (FunctionName : Set 𝔣) where open import Oscar.Data.Term.Core FunctionName open import Oscar.Data.Nat.Core open import Oscar.Data.Fin.Core open import Oscar.Data.Vec.Core open import Oscar.Data.Equality.Core open import Oscar.Data.Product.Core open import Oscar.Function open import Oscar.Level _⊸_ : (m n : ℕ) → Set 𝔣 m ⊸ n = Fin m → Term n ⊸-Property : {ℓ : Level} → ℕ → Set (lsuc ℓ ⊔ 𝔣) ⊸-Property {ℓ} m = ∀ {n} → m ⊸ n → Set ℓ _≐_ : {m n : ℕ} → m ⊸ n → m ⊸ n → Set 𝔣 f ≐ g = ∀ x → f x ≡ g x ⊸-Extensional : {ℓ : Level} {m : ℕ} → ⊸-Property {ℓ} m → Set (ℓ ⊔ 𝔣) ⊸-Extensional P = ∀ {m f g} → f ≐ g → P {m} f → P g ⊸-ExtentionalProperty : {ℓ : Level} → ℕ → Set (lsuc ℓ ⊔ 𝔣) ⊸-ExtentionalProperty {ℓ} m = Σ (⊸-Property {ℓ} m) ⊸-Extensional mutual _◃Term_ : ∀ {m n} → (f : m ⊸ n) → Term m → Term n f ◃Term i x = f x f ◃Term leaf = leaf f ◃Term (s fork t) = (f ◃Term s) fork (f ◃Term t) f ◃Term (function fn ts) = function fn (f ◃VecTerm ts) where _◃VecTerm_ : ∀ {N m n} → m ⊸ n → Vec (Term m) N → Vec (Term n) N f ◃VecTerm [] = [] f ◃VecTerm (t ∷ ts) = f ◃Term t ∷ f ◃VecTerm ts _◇_ : ∀ {l m n} → m ⊸ n → l ⊸ m → l ⊸ n _◇_ f g = (f ◃Term_) ∘ g record Substitution {a} (A : ℕ → Set a) : Set (a ⊔ 𝔣) where field _◃_ : ∀ {m n} → m ⊸ n → A m → A n ◃-extentionality : ∀ {m n} {f g : m ⊸ n} → f ≐ g → (t : A m) → f ◃ t ≡ g ◃ t ◃-identity : ∀ {n} → (t : A n) → i ◃ t ≡ t field ◃-associativity : ∀ {l m n} → {f : m ⊸ n} {g : _} (t : A l) → (f ◇ g) ◃ t ≡ f ◃ (g ◃ t) ⊸-Unifies : ∀ {m} (s t : A m) → ⊸-Property m ⊸-Unifies s t f = f ◃ s ≡ f ◃ t open Substitution ⦃ … ⦄ public {-# DISPLAY Substitution._◃_ _ = _◃_ #-}
{ "alphanum_fraction": 0.5347749854, "avg_line_length": 29.5, "ext": "agda", "hexsha": "463f66a2d97dc6de6f247a33a2ecec5a70a4a355", "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-2/Oscar/Class/termsubinternal.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-2/Oscar/Class/termsubinternal.agda", "max_line_length": 91, "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-2/Oscar/Class/termsubinternal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 805, "size": 1711 }
module vector where open import bool open import eq open import list open import list-to-string open import nat open import nat-thms open import product open import string ---------------------------------------------------------------------- -- datatypes ---------------------------------------------------------------------- data 𝕍 {ℓ} (A : Set ℓ) : ℕ → Set ℓ where [] : 𝕍 A 0 _::_ : {n : ℕ} → A → 𝕍 A n → 𝕍 A (suc n) vector = 𝕍 ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- infixr 6 _::_ _++𝕍_ ---------------------------------------------------------------------- -- operations ---------------------------------------------------------------------- [_]𝕍 : ∀ {ℓ} {A : Set ℓ} → A → 𝕍 A 1 [ x ]𝕍 = x :: [] _++𝕍_ : ∀ {ℓ} {A : Set ℓ}{n m : ℕ} → 𝕍 A n → 𝕍 A m → 𝕍 A (n + m) [] ++𝕍 ys = ys (x :: xs) ++𝕍 ys = x :: xs ++𝕍 ys head𝕍 : ∀ {ℓ} {A : Set ℓ}{n : ℕ} → 𝕍 A (suc n) → A head𝕍 (x :: _) = x tail𝕍 : ∀ {ℓ} {A : Set ℓ}{n : ℕ} → 𝕍 A n → 𝕍 A (pred n) tail𝕍 [] = [] tail𝕍 (_ :: xs) = xs map𝕍 : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'}{n : ℕ} → (A → B) → 𝕍 A n → 𝕍 B n map𝕍 f [] = [] map𝕍 f (x :: xs) = f x :: map𝕍 f xs concat𝕍 : ∀{ℓ}{A : Set ℓ}{n m : ℕ} → 𝕍 (𝕍 A n) m → 𝕍 A (m * n) concat𝕍 [] = [] concat𝕍 (x :: xs) = x ++𝕍 (concat𝕍 xs) nth𝕍 : ∀ {ℓ} {A : Set ℓ}{m : ℕ} → (n : ℕ) → n < m ≡ tt → 𝕍 A m → A nth𝕍 0 _ (x :: _) = x nth𝕍 (suc n) p (_ :: xs) = nth𝕍 n p xs nth𝕍 (suc n) () [] nth𝕍 0 () [] repeat𝕍 : ∀ {ℓ} {A : Set ℓ} → (a : A)(n : ℕ) → 𝕍 A n repeat𝕍 a 0 = [] repeat𝕍 a (suc n) = a :: (repeat𝕍 a n) foldl𝕍 : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → B → (B → A → B) → {n : ℕ} → 𝕍 A n → 𝕍 B n foldl𝕍 b _f_ [] = [] foldl𝕍 b _f_ (x :: xs) = let r = (b f x) in r :: (foldl𝕍 r _f_ xs) zipWith𝕍 : ∀ {ℓ ℓ' ℓ''} {A : Set ℓ}{B : Set ℓ'}{C : Set ℓ''} → (A → B → C) → {n : ℕ} → 𝕍 A n → 𝕍 B n → 𝕍 C n zipWith𝕍 f [] [] = [] zipWith𝕍 _f_ (x :: xs) (y :: ys) = (x f y) :: (zipWith𝕍 _f_ xs ys) -- helper function for all𝕍 allh𝕍 : ∀ {ℓ} {A : Set ℓ}{n : ℕ}(p : ℕ → A → 𝔹) → 𝕍 A n → ℕ → 𝔹 allh𝕍 p [] n = tt allh𝕍 p (x :: xs) n = p n x && allh𝕍 p xs (suc n) -- given a predicate p which takes in an index and the element of -- the given 𝕍 at that index, return tt iff the predicate -- returns true for all indices (and their elements). all𝕍 : ∀ {ℓ} {A : Set ℓ}{n : ℕ}(p : ℕ → A → 𝔹) → 𝕍 A n → 𝔹 all𝕍 p v = allh𝕍 p v 0 𝕍-to-𝕃 : ∀ {ℓ} {A : Set ℓ}{n : ℕ} → 𝕍 A n → 𝕃 A 𝕍-to-𝕃 [] = [] 𝕍-to-𝕃 (x :: xs) = x :: (𝕍-to-𝕃 xs) 𝕃-to-𝕍 : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → Σ ℕ (λ n → 𝕍 A n) 𝕃-to-𝕍 [] = (0 , []) 𝕃-to-𝕍 (x :: xs) with 𝕃-to-𝕍 xs ... | (n , v) = (suc n , x :: v) {- turn the given 𝕍 into a string by calling f on each element, and separating the elements with the given separator string -} 𝕍-to-string : ∀ {ℓ} {A : Set ℓ}{n : ℕ} → (f : A → string) → (separator : string) → 𝕍 A n → string 𝕍-to-string f sep v = 𝕃-to-string f sep (𝕍-to-𝕃 v)
{ "alphanum_fraction": 0.4140493077, "avg_line_length": 30.2142857143, "ext": "agda", "hexsha": "95621451e0a71d47e4f513e13e4d4e7a46d12bb9", "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": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "vector.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "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": "heades/AUGL", "max_issues_repo_path": "vector.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "vector.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1358, "size": 2961 }
open import Function using (_∘_) open import Data.Fin as Fin using (Fin; toℕ) open import Data.Nat as Nat using (ℕ; suc; zero) open import Data.Nat.Show using () renaming (show to showℕ) open import Data.String open import Data.Vec using (Vec; []; _∷_) open import Relation.Nullary using (Dec; yes; no) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl) module Unification.Show (Sym : ℕ → Set) (showSym : ∀ {k} (s : Sym k) → String) (decEqSym : ∀ {k} (f g : Sym k) → Dec (f ≡ g)) where import Unification module UI = Unification Sym decEqSym open UI hiding (_++_) showFin : ∀ {n} → Fin n → String showFin {n} x = (showℕ (toℕ x)) ++ "/" ++ (showℕ n) mutual showTerm : ∀ {n} → Term n → String showTerm (var x) = "?" ++ showFin x showTerm (con {zero} s []) = showSym s showTerm (con {suc k} s ts) = showSym s ++ "(" ++ showTermArgs ts ++ ")" showTermArgs : ∀ {n k} → Vec (Term n) k → String showTermArgs [] = "" showTermArgs (t ∷ []) = showTerm t showTermArgs (t₁ ∷ t₂ ∷ ts) = showTerm t₁ ++ " , " ++ showTermArgs (t₂ ∷ ts) showSubst : ∀ {m n} → Subst m n → String showSubst s = "{" ++ showSubst' s ++ "}" where showFor : ∀ {n} (x : Fin (suc n)) (t : Term n) → String showFor x t = "?" ++ showFin x ++ " → " ++ showTerm t showSubst' : ∀ {m n} → Subst m n → String showSubst' nil = "" showSubst' (snoc nil t x) = "?" ++ showFin x ++ " → " ++ showTerm t showSubst' (snoc (snoc s t₂ x₂) t₁ x₁) = showFor x₁ t₁ ++ " , " ++ showSubst' (snoc s t₂ x₂)
{ "alphanum_fraction": 0.5717884131, "avg_line_length": 35.2888888889, "ext": "agda", "hexsha": "3a40c3d9466c604a78a27f1798839aeded541ef3", "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": "5fc229e7eb6925dd3ea8e5d8e8bfbff4500c5614", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/FirstOrderUnificationInAgda", "max_forks_repo_path": "Unification/Show.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5fc229e7eb6925dd3ea8e5d8e8bfbff4500c5614", "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/FirstOrderUnificationInAgda", "max_issues_repo_path": "Unification/Show.agda", "max_line_length": 80, "max_stars_count": 3, "max_stars_repo_head_hexsha": "5fc229e7eb6925dd3ea8e5d8e8bfbff4500c5614", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/FirstOrderUnificationInAgda", "max_stars_repo_path": "Unification/Show.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-06T21:58:31.000Z", "max_stars_repo_stars_event_min_datetime": "2017-07-27T22:15:32.000Z", "num_tokens": 565, "size": 1588 }
-- Andreas, 2017-08-25, issue #1611. -- Fixed by Jesper Cockx as #2621. open import Common.Prelude data D : Bool → Set where dt : D true df : D false Works : ∀{b} → D b → Set Works dt = Bool Works df = Bool Fails : ∀{b : Bool} → D _ → Set Fails dt = Bool Fails df = Bool -- WAS: -- false != true of type Bool -- when checking that the pattern df has type D true -- SHOULD BE: -- Don't know whether to split on dt -- NOW: -- I'm not sure if there should be a case for the constructor dt, -- because I get stuck when trying to solve the following unification -- problems (inferred index ≟ expected index): -- true ≟ _9 -- when checking that the pattern dt has type D _9
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 21.9677419355, "ext": "agda", "hexsha": "5807f1e612c335f5d19f20564143c6bd15729b9a", "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/Issue1611.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/Issue1611.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1611.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": 205, "size": 681 }
import Issue2447.M import Issue2447.Parse-error
{ "alphanum_fraction": 0.8541666667, "avg_line_length": 16, "ext": "agda", "hexsha": "441253b372476792cc80d829d7761c8c4309f161", "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/Issue2447c.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/Issue2447c.agda", "max_line_length": 28, "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/Issue2447c.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": 13, "size": 48 }
{-# OPTIONS --cubical --safe #-} module Relation.Nullary.Decidable where open import Level open import Data.Bool open import Data.Empty open import Function.Biconditional Reflects : Type a → Bool → Type a Reflects A true = A Reflects A false = ¬ A record Dec {a} (A : Type a) : Type a where constructor _because_ field does : Bool why : Reflects A does open Dec public pattern yes p = true because p pattern no ¬p = false because ¬p map-reflects : (A → B) → (¬ A → ¬ B) → ∀ {d} → Reflects A d → Reflects B d map-reflects {A = A} {B = B} to fro {d = d} = bool {P = λ d → Reflects A d → Reflects B d} fro to d map-dec : (A → B) → (¬ A → ¬ B) → Dec A → Dec B map-dec to fro dec .does = dec .does map-dec to fro dec .why = map-reflects to fro (dec .why) iff-dec : (A ↔ B) → Dec A → Dec B iff-dec (to iff fro) = map-dec to (λ ¬y x → ¬y (fro x)) infixr 1 dec dec : (A → B) → (¬ A → B) → Dec A → B dec {A = A} {B = B} on-yes on-no d = bool {P = λ d → Reflects A d → B} on-no on-yes (d .does) (d .why) syntax dec (λ yv → ye) (λ nv → ne) dc = ∣ dc ∣yes yv ⇒ ye ∣no nv ⇒ ne T? : (b : Bool) → Dec (T b) T? b .does = b T? false .why () T? true .why = _
{ "alphanum_fraction": 0.5851788756, "avg_line_length": 26.6818181818, "ext": "agda", "hexsha": "81ddcd9d50678fe751e4566e8eef8418c2742013", "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": "Relation/Nullary/Decidable.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": "Relation/Nullary/Decidable.agda", "max_line_length": 102, "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": "Relation/Nullary/Decidable.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": 451, "size": 1174 }
module Problem3 where open import Problem1 open import Problem2 data Fin : Nat -> Set where fzero : {n : Nat} -> Fin (suc n) fsuc : {n : Nat} -> Fin n -> Fin (suc n) data False : Set where -- 3.1 empty : Fin zero -> False empty () -- 3.2 _!_ : {A : Set}{n : Nat} -> Vec A n -> Fin n -> A ε ! () (x ► xs) ! fzero = x (x ► xs) ! fsuc i = xs ! i -- 3.3 -- The simply typed composition would do here, but the more -- dependent version is more interesting. -- _∘_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C _∘_ : {A B : Set}{C : B -> Set}(f : (x : B) -> C x) (g : A -> B)(x : A) -> C (g x) (f ∘ g) x = f (g x) tabulate : {A : Set}{n : Nat} -> (Fin n -> A) -> Vec A n tabulate {n = zero } f = ε tabulate {n = suc n} f = f fzero ► tabulate (f ∘ fsuc)
{ "alphanum_fraction": 0.5012787724, "avg_line_length": 20.5789473684, "ext": "agda", "hexsha": "9fc78185cc7e29371f7a84eeef404b2c68692444", "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/SummerSchool07/Solutions/Problem3.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/SummerSchool07/Solutions/Problem3.agda", "max_line_length": 59, "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/SummerSchool07/Solutions/Problem3.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": 310, "size": 782 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Category.Monoidal module Categories.Category.Monoidal.Symmetric {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where open import Level open import Data.Product using (Σ; _,_) open import Categories.Functor.Bifunctor open import Categories.Functor.Properties open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) open import Categories.Morphism C open import Categories.Morphism.Properties C open import Categories.Category.Monoidal.Braided M open Category C open Commutation private variable X Y Z : Obj -- symmetric monoidal category -- commutative braided monoidal category -- -- the reason why we define symmetric categories via braided monoidal categories could -- be not obvious, but it is the right definition: it requires again a redundant -- hexagon proof which allows achieves definitional equality of the opposite. record Symmetric : Set (levelOfTerm M) where field braided : Braided module braided = Braided braided open braided public private B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X B {X} {Y} = braiding.⇒.η (X , Y) field commutative : B {X} {Y} ∘ B {Y} {X} ≈ id braided-iso : X ⊗₀ Y ≅ Y ⊗₀ X braided-iso = record { from = B ; to = B ; iso = record { isoˡ = commutative ; isoʳ = commutative } } module braided-iso {X Y} = _≅_ (braided-iso {X} {Y}) private record Symmetric′ : Set (levelOfTerm M) where open Monoidal M field braiding : NaturalIsomorphism ⊗ (flip-bifunctor ⊗) module braiding = NaturalIsomorphism braiding private B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X B {X} {Y} = braiding.⇒.η (X , Y) field commutative : B {X} {Y} ∘ B {Y} {X} ≈ id hexagon : [ (X ⊗₀ Y) ⊗₀ Z ⇒ Y ⊗₀ Z ⊗₀ X ]⟨ B ⊗₁ id ⇒⟨ (Y ⊗₀ X) ⊗₀ Z ⟩ associator.from ⇒⟨ Y ⊗₀ X ⊗₀ Z ⟩ id ⊗₁ B ≈ associator.from ⇒⟨ X ⊗₀ Y ⊗₀ Z ⟩ B ⇒⟨ (Y ⊗₀ Z) ⊗₀ X ⟩ associator.from ⟩ braided-iso : X ⊗₀ Y ≅ Y ⊗₀ X braided-iso = record { from = B ; to = B ; iso = record { isoˡ = commutative ; isoʳ = commutative } } module braided-iso {X Y} = _≅_ (braided-iso {X} {Y}) -- we don't define [Symmetric] from [Braided] because we want to avoid asking -- [hexagon₂], which can readily be proven using the [hexagon] and [commutative]. braided : Braided braided = record { braiding = braiding ; hexagon₁ = hexagon ; hexagon₂ = λ {X Y Z} → Iso-≈ hexagon (Iso-∘ (Iso-∘ ([ -⊗ Y ]-resp-Iso braided-iso.iso) associator.iso) ([ X ⊗- ]-resp-Iso braided-iso.iso)) (Iso-∘ (Iso-∘ associator.iso braided-iso.iso) associator.iso) } symmetricHelper : Symmetric′ → Symmetric symmetricHelper S = record { braided = braided ; commutative = commutative } where open Symmetric′ S
{ "alphanum_fraction": 0.5625191073, "avg_line_length": 28.4434782609, "ext": "agda", "hexsha": "1eec886a840b27e77fec8ef6de42632bfafdf811", "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/Monoidal/Symmetric.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/Monoidal/Symmetric.agda", "max_line_length": 97, "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/Monoidal/Symmetric.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1015, "size": 3271 }
{-# OPTIONS --without-K #-} module hw1 where open import Level using (_⊔_) open import Function using (id) open import Data.Nat using (ℕ; suc; _+_; _*_) open import Data.Empty using (⊥) open import Data.Sum using (_⊎_; inj₁; inj₂) import Level infix 4 _≡_ recℕ : ∀ {ℓ} → (C : Set ℓ) → C → (ℕ → C → C) → ℕ → C recℕ C z f 0 = z recℕ C z f (suc n) = f n (recℕ C z f n) indℕ : ∀ {ℓ} → (C : ℕ → Set ℓ) → C 0 → ((n : ℕ) → C n → C (suc n)) → (n : ℕ) → C n indℕ C z f 0 = z indℕ C z f (suc n) = f n (indℕ C z f n) ------------------------------------------------------------------------------ data _≡_ {ℓ} {A : Set ℓ} : (x y : A) → Set ℓ where refl : (x : A) → x ≡ x rec≡ : {A : Set} → (R : A → A → Set) {reflexiveR : {a : A} → R a a} → ({x y : A} (p : x ≡ y) → R x y) rec≡ R {reflR} (refl y) = reflR {y} subst : ∀ {ℓ} {A : Set ℓ} {C : A → Set ℓ} → ({x y : A} (p : x ≡ y) → C x → C y) subst (refl x) = id ------------------------------------------------------------------------------ -- Exercise 1.1 -- show h ∘ (g ∘ f) = (h ∘ g) ∘ f ------------------------------------------------------------------------------ _∘_ : {A B C : Set} → (f : B → C) → (g : A → B) → A → C f ∘ g = (λ a → f (g a)) compose≡ : {A B C D : Set} → (f : A → B) → (g : B → C) → (h : C → D) → h ∘ (g ∘ f) ≡ (h ∘ g) ∘ f compose≡ = λ f g h → refl (λ a → (h (g (f a)))) ------------------------------------------------------------------------------ -- Exercise 1.2 -- Derive the recursion principle for products recA×B -- using only the projections, and verify that the definitional -- equalities are valid. Do the same for Σ-types. ------------------------------------------------------------------------------ --------------------------------------------------- -- Product Types data _×_ {ℓ₁ ℓ₂} (A : Set ℓ₁) (B : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where pair : A → B → A × B fst : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} {B : Set ℓ₂} → A × B → A fst (pair a _) = a snd : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} {B : Set ℓ₂} -> A × B -> B snd (pair _ b) = b rec× : ∀ {ℓ} {A B : Set ℓ} → (C : Set ℓ) → (A → B → C) → A × B → C rec× c f = λ p -> (f (fst p) (snd p)) fstofab≡a : ∀ {A B : Set} (a : A) → (b : B) → fst (pair a b) ≡ a fstofab≡a {A} {B} = λ a b → refl a sndofab≡b : ∀ {A B : Set} (a : A) → (b : B) → snd (pair a b) ≡ b sndofab≡b {A} {B} = λ a b → refl b uniq× : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} {B : Set ℓ₂} (p : A × B) → (pair (fst p) (snd p)) ≡ p uniq× (pair a b) = refl (pair a b) rec×g≡g : ∀ {A B C : Set} (g : A → B → C) (a : A) → (b : B) → rec× C g (pair a b) ≡ g a b rec×g≡g {A} {B} {C} = λ g a b → refl (g a b) recfst : ∀ (A B : Set) → fst {B = B} ≡ rec× A (λ a b → a) recfst A B = refl fst --------------------------------------------------- -- Sigma Types data Σ {ℓ₁ ℓ₂} (A : Set ℓ₁) (B : A → Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where dpair : (a : A) → (B a) → Σ A B dfst : ∀ {A : Set} {B : A → Set} → Σ A B → A dfst (dpair a _) = a dsnd : ∀ {A : Set} {B : A → Set} → (p : Σ A B) → (B (dfst p)) dsnd (dpair _ b) = b dfstofab≡a : ∀ {A : Set} {B : A → Set} (a : A) (b : B a) → dfst {B = B} (dpair a b) ≡ a dfstofab≡a {A} {B} = λ a b → refl a dsndofab≡a : ∀ {A : Set} {B : A → Set} (a : A) (b : B a) → dsnd {B = B} (dpair a b) ≡ b dsndofab≡a {A} {B} = λ a b → refl b uniqΣ : ∀ {A : Set} {B : A → Set} (p : Σ A B) → (dpair (dfst p) (dsnd p)) ≡ p uniqΣ (dpair a b) = refl (dpair a b) ------------------------------------------------------------------------------ -- Exercise 1.3 -- Derive the induction principle for products indA×B, -- using only the projections and the propositional uniqueness -- principle uniqA×B. Verify that the definitional equalities are -- valid. Generalize uniqA×B to Σ-types, and do the same for Σ-types. ------------------------------------------------------------------------------ ind× : ∀ {ℓ} {A : Set ℓ} {B : Set ℓ} → (C : (A × B) → Set ℓ) → ((a : A) (b : B) → (C (pair a b))) → (p : (A × B)) → (C p) ind× = λ C f → λ p → subst {C = C} (uniq× p) (f (fst p) (snd p)) indΣ' : ∀ {A : Set} {B : A → Set} → (C : Σ A B → Set) → ((a : A) → (b : B a) → C (dpair a b)) → (p : Σ A B) → C p indΣ' C g s = subst {C = C} (uniqΣ s) (g (dfst s) (dsnd s)) ------------------------------------------------------------------------------ --- Exercise 1.4 Given the function iter, derive a function having the --- type of the recursor recN. Show that the defining equations of the --- recursor hold propositionally for this function, using the --- induction principle for Nats. ------------------------------------------------------------------------------ iter : ∀ {ℓ} {C : Set ℓ} → C → (C → C) → ℕ → C iter c₀ c₊ 0 = c₀ iter c₀ c₊ (suc n) = c₊ (iter c₀ c₊ n) recℕ' : ∀ {ℓ} → (C : Set ℓ) → C → (ℕ → C → C) → ℕ → C recℕ' C c₀ f n = snd (iter (pair 0 c₀) (λ nc → (pair (suc (fst nc)) (f (fst nc) (snd nc)))) n) -- quick def and sanity check of fact via recℕ fact = recℕ ℕ 1 (λ n nfact → (suc n) * nfact) fact1 : fact 0 ≡ 1 fact1 = refl 1 fact5 : fact 5 ≡ 120 fact5 = refl 120 -- quick def and sanity check of fact via recℕ' fact' = recℕ' ℕ 1 (λ n nfact → (suc n) * nfact) fact'1 : fact' 0 ≡ 1 fact'1 = refl 1 fact'5 : fact' 5 ≡ 120 fact'5 = refl 120 cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y} → x ≡ y → f x ≡ f y cong f (refl y) = refl (f y) -- this _is_ valid but I haven't done enough Agda -- to see how to prove this. I proved it in the Coq HoTT library... -- https://github.com/andmkent/HoTT/blob/5f9faf5ef4ea21db249d6ad45bcee0adf97f8f9d/contrib/HoTTBookExercises.v#L124 postulate punt1 : ∀ {ℓ} (C : Set ℓ) → (c₀ : C) → (f : (ℕ → C → C)) → (n : ℕ) → recℕ C c₀ f (suc n) ≡ recℕ' C c₀ f (suc n) recℕ≡recℕ' : ∀ {ℓ} (C : Set ℓ) → (c₀ : C) → (f : (ℕ → C → C)) → ((n : ℕ) → recℕ C c₀ f n ≡ recℕ' C c₀ f n) recℕ≡recℕ' {ℓ} C c₀ f n = indℕ {ℓ = ℓ} (λ n → (((recℕ {ℓ = ℓ} C c₀ f) n) ≡ ((recℕ' {ℓ = ℓ} C c₀ f) n))) (refl c₀) (λ n IH → (punt1 C c₀ f n)) n ------------------------------------------------------------------------------ --- Exercise 1.5 Show that if we define A + B Σ(x:2) rec2(U, A, B, --- x), then we can give a definition of indA+B for which the --- definitional equalities stated in §1.7 hold. ------------------------------------------------------------------------------ data 𝟚 : Set where true : 𝟚 false : 𝟚 rec𝟚 : ∀ {ℓ} → {C : Set ℓ} → C → C → 𝟚 → C rec𝟚 th el false = el rec𝟚 th el true = th if_then_else_ : ∀ {ℓ} {C : Set ℓ} → 𝟚 → C → C → C if b then X else Y = rec𝟚 X Y b ind𝟚 : ∀ {ℓ} → {C : 𝟚 → Set ℓ} → C true → C false → (b : 𝟚) → C b ind𝟚 th el false = el ind𝟚 th el true = th bsum : ∀ (A : Set) → (B : Set) → Set bsum A B = Σ 𝟚 (rec𝟚 A B) injbs1 : ∀ (A : Set) → (B : Set) → A → bsum A B injbs1 A B a = dpair true a injbs2 : ∀ (A : Set) → (B : Set) → B → bsum A B injbs2 A B b = dpair false b recΣ : ∀ {ℓ₁ ℓ₂ ℓ₃} → {A : Set ℓ₁} {B : A → Set ℓ₂} → (C : Set ℓ₃) → ((a : A) → B a → C) → Σ A B → C recΣ C g (dpair a b) = g a b indΣ : ∀ {ℓ₁ ℓ₂ ℓ₃} → {A : Set ℓ₁} {B : A → Set ℓ₂} → (C : Σ A B → Set ℓ₃) → ((a : A) → (b : B a) → C (dpair a b)) → (p : Σ A B) → C p indΣ C g (dpair a b) = g a b indbsum : (A : Set) (B : Set) (C : (bsum A B → Set)) → ((a : A) → (C (injbs1 A B a))) → ((b : B) → (C (injbs2 A B b))) → (a+b : bsum A B) → (C a+b) indbsum A B C ca cb = indΣ C (ind𝟚 ca cb) -- where ind𝟚's C = (λ b → (t : rec𝟚 A B b) → C (dpair b t)) indbs1 : ∀ {A B : Set} (P : (bsum A B) → Set) → (fa : (a : A) → P (injbs1 A B a)) → (fb : (b : B) → P (injbs2 A B b)) → (a : A) → indbsum A B P fa fb (injbs1 A B a) ≡ fa a indbs1 P fa fb x = refl (fa x) indbs2 : ∀ {A B : Set} (P : (bsum A B) → Set) → (fa : (a : A) → P (injbs1 A B a)) → (fb : (b : B) → P (injbs2 A B b)) → (b : B) → indbsum A B P fa fb (injbs2 A B b) ≡ fb b indbs2 P fa fb x = refl (fb x) rec⊎ : ∀ {ℓ₁ ℓ₂ ℓ₃} → {A : Set ℓ₁} {B : Set ℓ₂} → (C : Set ℓ₃) → (A → C) → (B → C) → (A ⊎ B → C) rec⊎ C f g (inj₁ a) = f a rec⊎ C f g (inj₂ b) = g b ------------------------------------------------------------------------------ --- Exercise 1.10 -- Show that the Ackermann function ack : ℕ → ℕ → ℕ is definable using -- only recℕ satisfying the following equations: -- ack(0, m) = succ(m) -> ack(0) = suc -- ack(succ(n), 0) = ack(n, 1) -> ack (suc n) = -- ack(succ(n), succ(m)) = ack(n, ack(succ(n), m)). ack : ℕ → ℕ → ℕ ack = recℕ (ℕ → ℕ) suc (λ n ackn → recℕ ℕ (ackn 1) (λ m res → (ackn res))) acktest00 : ack 0 0 ≡ 1 acktest00 = refl 1 acktest01 : ack 0 1 ≡ 2 acktest01 = refl 2 acktest10 : ack 1 0 ≡ 2 acktest10 = refl 2 acktest11 : ack 1 1 ≡ 3 acktest11 = refl 3 acktest22 : ack 2 2 ≡ 7 acktest22 = refl 7 ------------------------------------------------------------------------------ --- Exercise 1.11 -- Show that for any type A, we have ¬¬¬A → ¬A. ¬ : Set → Set ¬ P = P → ⊥ ex11 : ∀ (P : Set) → ¬ (¬ (¬ P)) → ¬ P ex11 P = λ nnnP → λ P → nnnP (λ nP → nP P) ------------------------------------------------------------------------------ -- Exercise 1.12 -- Using the propositions as types interpretation, derive the following tautologies. -- (i) If A, then (if B then A). -- (ii) If A, then not (not A). -- (iii) If (not A or not B), then not (A and B). ex12i : ∀ (A : Set) → A → (Set → A) ex12i = λ A a _ → a ex12ii : ∀ (A : Set) → A → (¬ (¬ A)) ex12ii = λ A a → λ nA → nA a ex12iii : ∀ (A B : Set) → (¬ (A ⊎ B)) → (¬ (A × B)) ex12iii = λ A B → λ nAorB → λ AandB → nAorB (inj₁ (fst AandB)) ------------------------------------------------------------------------------ -- Exercise 1.13 -- Using propositions-as-types, derive the double negation of the principle of ex- -- cluded middle, i.e. prove not (not (P or not P)). ex13 : ∀ (P : Set) → (¬ (¬ (P ⊎ (¬ P)))) ex13 = λ P nPorPnot → nPorPnot (inj₂ (λ P → nPorPnot (inj₁ P))) ------------------------------------------------------------------------------ -- Exercise 1.16 -- Show that addition of natural numbers is commutative. ex16 : ∀ (a b c : ℕ) → a + (b + c) ≡ (a + b) + c ex16 = indℕ (λ a → (b c : ℕ) → a + (b + c) ≡ a + b + c) (λ b c → refl (b + c)) (λ n IHn b c → cong suc (IHn b c))
{ "alphanum_fraction": 0.3959683225, "avg_line_length": 29.474801061, "ext": "agda", "hexsha": "e1b640d7174c2df0588dae3ed5260719015d37b2", "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": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andmkent/misc-HoTT", "max_forks_repo_path": "hw1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "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": "andmkent/misc-HoTT", "max_issues_repo_path": "hw1.agda", "max_line_length": 114, "max_stars_count": 1, "max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andmkent/misc-HoTT", "max_stars_repo_path": "hw1.agda", "max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z", "num_tokens": 4308, "size": 11112 }
module Data.Either.Equiv.Id where import Lvl open import Data open import Data.Either as Either open import Data.Either.Equiv open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Setoid open import Structure.Function.Domain open import Type private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level private variable A B : Type{ℓ} module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where instance Left-injectivity : Injective(Left{A = A}{B = B}) Injective.proof Left-injectivity [≡]-intro = [≡]-intro instance Right-injectivity : Injective(Right{A = A}{B = B}) Injective.proof Right-injectivity [≡]-intro = [≡]-intro instance Either-Id-extensionality : Extensionality{A = A}{B = B} [≡]-equiv Either-Id-extensionality = intro \()
{ "alphanum_fraction": 0.710723192, "avg_line_length": 28.6428571429, "ext": "agda", "hexsha": "f2248ea74e56fcb44ea14f12906226514adf43b2", "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": "Data/Either/Equiv/Id.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": "Data/Either/Equiv/Id.agda", "max_line_length": 70, "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": "Data/Either/Equiv/Id.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": 266, "size": 802 }
{-# OPTIONS --universe-polymorphism #-} module SetInf where id : ∀ {A} → A → A id x = x
{ "alphanum_fraction": 0.5888888889, "avg_line_length": 12.8571428571, "ext": "agda", "hexsha": "2378e3234f8a18c77063c5783478f910e6011553", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/interaction/SetInf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/interaction/SetInf.agda", "max_line_length": 39, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/interaction/SetInf.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": 30, "size": 90 }