Search is not available for this dataset
text
string
meta
dict
module plfa-exercises.part1.Decidable where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; cong) open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; pred) open import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Relation.Nullary using (¬_) open import Relation.Nullary.Negation using () renaming (contradiction to ¬¬-intro) open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥; ⊥-elim) open import plfa.part1.Relations using (_<_; z<s; s<s) open import plfa.part1.Isomorphism using (_⇔_) open import Function.Base using (_∘_) infix 4 _≤_ data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} -------- → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n ------------- → suc m ≤ suc n _ : 2 ≤ 4 _ = s≤s (s≤s z≤n) ¬4≤2 : ¬ (4 ≤ 2) --¬4≤2 (s≤s (s≤s ())) = ? -- This causes Agda to die! TODO: Report ¬4≤2 (s≤s (s≤s ())) data Bool : Set where true : Bool false : Bool infix 4 _≤ᵇ_ _≤ᵇ_ : ℕ → ℕ → Bool zero ≤ᵇ n = true suc m ≤ᵇ zero = false suc m ≤ᵇ suc n = m ≤ᵇ n _ : (2 ≤ᵇ 4) ≡ true _ = refl _ : (5 ≤ᵇ 4) ≡ false _ = refl T : Bool → Set T true = ⊤ T false = ⊥ ≤→≤ᵇ : ∀ {m n} → (m ≤ n) → T (m ≤ᵇ n) ≤→≤ᵇ z≤n = tt ≤→≤ᵇ (s≤s m≤n) = ≤→≤ᵇ m≤n ≤ᵇ→≤ : ∀ {m n} → T (m ≤ᵇ n) → (m ≤ n) ≤ᵇ→≤ {zero} {_} tt = z≤n -- What is going on in here? Left `t` has type `T (suc m ≤ᵇ suc n)` and the right `t` has type `T (m ≤ᵇ n)` -- λ m n → T (suc m ≤ᵇ suc n) => reduces to: λ m n → T (m ≤ᵇ n) -- Ohh! Ok. It is because the third rule of `≤ᵇ` reduces `suc m ≤ᵇ suc n` to `m ≤ᵇ n` ≤ᵇ→≤ {suc m} {suc n} t = s≤s (≤ᵇ→≤ {m} {n} t) -- λ m → T (suc m ≤ᵇ zero) => reduces to: λ m → ⊥ -- which means that there are no rules for `fromᵇ {suc m} {zero}` ≤ᵇ→≤ {suc m} {zero} () proof≡computation : ∀ {m n} → (m ≤ n) ⇔ T (m ≤ᵇ n) proof≡computation {m} {n} = record { from = ≤ᵇ→≤ ; to = ≤→≤ᵇ } T→≡ : ∀ (b : Bool) → T b → b ≡ true T→≡ true tt = refl T→≡ false () --postulate -- lie : false ≡ true ≡→T : ∀ {b : Bool} → b ≡ true → T b --≡→T {false} refl = ? -- This is impossible because of refl's definition. Unification forces `b` to be `true` --≡→T {false} rewrite lie = λ refl → ? -- Even postulating a lie, it is impossible to create a bottom value ≡→T refl = tt _ : 2 ≤ 4 _ = ≤ᵇ→≤ tt ¬4≤2₂ : ¬ (4 ≤ 2) --¬4≤2₂ 4≤2 = ≤→≤ᵇ 4≤2 --¬4≤2₂ = ≤→≤ᵇ {4} {2} -- The type of `T (4 ≤ᵇ 2)` which reduces to `T false` and then `⊥` ¬4≤2₂ = ≤→≤ᵇ -- Notice how defining ≤ᵇ lifts from us the demand of computing the correct -- `evidence` (implementation) for the `proof` (function type) data Dec (A : Set) : Set where yes : A → Dec A no : ¬ A → Dec A ¬s≤z : {m : ℕ} → ¬ (suc m) ≤ zero --¬s≤z = ≤→≤ᵇ ¬s≤z () ¬s≤s : {m n : ℕ} → ¬ m ≤ n → ¬ suc m ≤ suc n ¬s≤s ¬m≤n = λ { (s≤s m≤n) → ¬m≤n m≤n } _≤?_ : (m n : ℕ) → Dec (m ≤ n) zero ≤? n = yes z≤n (suc m) ≤? zero = no ¬s≤z (suc m) ≤? (suc n) with m ≤? n ... | yes m≤n = yes (s≤s m≤n) ... | no ¬m≤n = no (¬s≤s ¬m≤n) -- `2 ≤? 4` reduces to `yes (s≤s (s≤s z≤n))` _ : Dec (2 ≤ 4) _ = 2 ≤? 4 _ = yes (s≤s (s≤s (z≤n {2}))) ⌊_⌋ : ∀ {A : Set} → Dec A → Bool ⌊ yes x ⌋ = true ⌊ no ¬x ⌋ = false _ : Bool _ = true _ = ⌊ 3 ≤? 4 ⌋ _ : ⌊ 3 ≤? 4 ⌋ ≡ true _ = refl _ : ⌊ 3 ≤? 2 ⌋ ≡ false _ = refl toWitness : ∀ {A : Set} {D : Dec A} → T ⌊ D ⌋ → A toWitness {_} {yes v} tt = v --toWitness {_} {no _} = ? -- `T ⌊ no x ⌋ → A` reduces to `⊥ → A` toWitness {_} {no _} () -- Empty because there is no value for `⊥` fromWitness : ∀ {A : Set} {D : Dec A} → A → T ⌊ D ⌋ fromWitness {_} {yes _} _ = tt fromWitness {_} {no ¬a} a = ¬a a -- with type ⊥ _ : 2 ≤ 4 --_ = toWitness {D = 2 ≤? 4} tt _ = toWitness {_} {2 ≤? 4} tt ¬4≤2₃ : ¬ (4 ≤ 2) --¬4≤2₃ = fromWitness {D = 4 ≤? 2} ¬4≤2₃ = fromWitness {_} {4 ≤? 2} ¬z<z : ¬ (zero < zero) ¬z<z () ¬s<z : ∀ {m : ℕ} → ¬ (suc m < zero) ¬s<z () _<?_ : ∀ (m n : ℕ) → Dec (m < n) zero <? zero = no ¬z<z zero <? suc n = yes z<s suc m <? zero = no ¬s<z suc m <? suc n with m <? n ... | yes m<n = yes (s<s m<n) ... | no ¬m<n = no λ{(s<s m<n) → ¬m<n m<n} _ : ⌊ 2 <? 4 ⌋ ≡ true _ = refl ¬z≡sn : ∀ {n : ℕ} → ¬ zero ≡ suc n ¬z≡sn () _≡ℕ?_ : ∀ (m n : ℕ) → Dec (m ≡ n) zero ≡ℕ? zero = yes refl zero ≡ℕ? (suc n) = no ¬z≡sn --(suc m) ≡ℕ? zero = no (λ{sn≡z → ¬z≡sn (sym sn≡z)}) --(suc m) ≡ℕ? zero = no (¬z≡sn ∘ sym) (suc m) ≡ℕ? zero = no ((λ()) ∘ sym) --The following doesn't work though --(suc m) ≡ℕ? zero with zero ≡ℕ? (suc m) --... | yes z≡sm = yes (sym z≡sm) --... | no ¬z≡sm = no (¬z≡sm ∘ sym) (suc m) ≡ℕ? (suc n) with m ≡ℕ? n ... | yes m≡n = yes (cong suc m≡n) ... | no ¬m≡n = no (¬m≡n ∘ (cong pred)) infixr 6 _×-dec_ _×-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A × B) yes x ×-dec yes y = yes ⟨ x , y ⟩ no ¬x ×-dec _ = no λ{ ⟨ x , y ⟩ → ¬x x } _ ×-dec no ¬y = no λ{ ⟨ x , y ⟩ → ¬y y } infixr 6 _⊎-dec_ _⊎-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A ⊎ B) yes x ⊎-dec _ = yes (inj₁ x) _ ⊎-dec yes y = yes (inj₂ y) no ¬x ⊎-dec no ¬y = no λ{(inj₁ x) → ¬x x; (inj₂ y) → ¬y y} ¬? : ∀ {A : Set} → Dec A → Dec (¬ A) ¬? (yes x) = no (¬¬-intro x) ¬? (no ¬x) = yes ¬x _→-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A → B) _ →-dec yes y = yes (λ _ → y) --no ¬x →-dec _ = yes ((λ()) ∘ ¬x) no ¬x →-dec _ = yes (⊥-elim ∘ ¬x) yes x →-dec no ¬y = no (λ{x→y → ¬y (x→y x)}) infixr 6 _∧_ _∧_ : Bool → Bool → Bool true ∧ true = true false ∧ _ = false _ ∧ false = false ∧-× : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ ∧ ⌊ y ⌋ ≡ ⌊ x ×-dec y ⌋ ∧-× (yes x) (yes y) = refl ∧-× (no ¬x) _ = refl ∧-× (yes x) (no ¬y) = refl _iff_ : Bool → Bool → Bool true iff true = true false iff false = true _ iff _ = false _⇔-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A ⇔ B) yes x ⇔-dec yes y = yes (record { from = λ{_ → x} ; to = λ{_ → y} }) no ¬x ⇔-dec no ¬y = yes (record { from = (λ()) ∘ ¬y ; to = (λ()) ∘ ¬x }) yes x ⇔-dec no ¬y = no (λ x⇔y → ¬y (_⇔_.to x⇔y x)) no ¬x ⇔-dec yes y = no (λ x⇔y → ¬x (_⇔_.from x⇔y y)) iff-⇔ : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ iff ⌊ y ⌋ ≡ ⌊ x ⇔-dec y ⌋ iff-⇔ (yes x) (yes y) = refl iff-⇔ (no ¬x) (no ¬y) = refl iff-⇔ (no ¬x) (yes y) = refl iff-⇔ (yes x) (no ¬y) = refl
{ "alphanum_fraction": 0.4719722091, "avg_line_length": 25.743902439, "ext": "agda", "hexsha": "59cb9f34e7e10aac67ff77cffd26bbe070da660f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "helq/old_code", "max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Decidable.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "helq/old_code", "max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Decidable.agda", "max_line_length": 110, "max_stars_count": null, "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "helq/old_code", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Decidable.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3163, "size": 6333 }
-- Andreas, 2014-08-28, reported by Jacques Carette {-# OPTIONS --cubical-compatible #-} -- {-# OPTIONS -v term:20 #-} module _ where data Bool : Set where true false : Bool data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A module Sort (A : Set) ( _≤_ : A → A → Bool) where insert : A → List A → List A insert x [] = [] insert x (y ∷ ys) with x ≤ y ... | true = x ∷ (y ∷ ys) ... | false = y ∷ insert x ys -- Should termination check. -- (Did not because while with lhss were not inlined, with-calls still were.)
{ "alphanum_fraction": 0.5873873874, "avg_line_length": 22.2, "ext": "agda", "hexsha": "be09451c2094cded122ccc24cbb43b65674711f3", "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/Issue1259.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/Issue1259.agda", "max_line_length": 77, "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/Issue1259.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 184, "size": 555 }
data _≡_ {ℓ}{A : Set ℓ} (x : A) : A → Set ℓ where refl : x ≡ x record Box (B : Set) : Set₁ where constructor box field unbox : B open Box public =box :{B : Set}{Γ₀ Γ₁ : Box B} → _≡_ {A = B} (unbox Γ₀) (unbox Γ₁) → Γ₀ ≡ Γ₁ =box {b} {box unbox} {box .unbox} refl = ? -- WAS: internal error at src/full/Agda/TypeChecking/Rules/LHS.hs:294 -- SHOULD: complain about misplaced projection pattern
{ "alphanum_fraction": 0.6157635468, "avg_line_length": 25.375, "ext": "agda", "hexsha": "f7e7fce12888503a1c7e6e110150dec2cd171f25", "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/Issue3491.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/Issue3491.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue3491.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": 164, "size": 406 }
module _ where open import Agda.Builtin.Nat hiding (_+_) import Agda.Builtin.Nat as N open import Agda.Builtin.TrustMe open import Agda.Builtin.Equality open import Agda.Builtin.Sigma data ⊥ : Set where module SimplifiedTestCase where record Fin : Set where constructor mkFin field m .p : Nat module _ (m : Nat) .(k : Nat) where w : Fin w = mkFin m k mutual X : Fin X = _ -- Worked if removing this constr₁ : Fin.m X ≡ m constr₁ = refl constr₂ : X ≡ w constr₂ = refl module OriginalTestCase where record Fin (n : Nat) : Set where constructor mkFin field m : Nat .p : Σ Nat λ k → (Nat.suc k N.+ m) ≡ n apply2 : {t₁ : Set} {t₂ : Set} {a b : t₁} → (f : t₁ → t₂) → a ≡ b → f a ≡ f b apply2 f refl = refl private lem : ∀ m → .(Σ Nat λ x → (suc (x N.+ m) ≡ 0)) → ⊥ lem _ (_ , ()) S : ∀ {n} → Fin n → Fin (suc n) S (mkFin a (k , p)) = mkFin (suc a) (suc k , primTrustMe) to : ∀ {n} → Fin n → Fin n to record { m = zero ; p = p } = record { m = zero ; p = p } to {zero} record { m = (suc m) ; p = p } with lem (suc m) p ... | () to {suc n} record { m = (suc m) ; p = (k , p) } = S (to record { m = m ; p = k , primTrustMe }) from = to iso : ∀ {n} → (x : Fin n) → from (to x) ≡ x iso {zero} record { m = m ; p = p } with lem m p ... | () iso {suc n} record { m = zero ; p = p } = refl iso {suc n} record { m = (suc m) ; p = p@(k , _) } = let w : Fin n w = mkFin m (k , primTrustMe) v : S (from (to w)) ≡ S w v = apply2 {b = _} S (iso w) in v
{ "alphanum_fraction": 0.5065096094, "avg_line_length": 22.095890411, "ext": "agda", "hexsha": "9bf2f6846f0c4af7730a9ffa2518e0a0fdc84100", "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/Issue3031.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/Issue3031.agda", "max_line_length": 97, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue3031.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 630, "size": 1613 }
{- This second-order term syntax was created from the following second-order syntax description: syntax UTLC | Λ type * : 0-ary term app : * * -> * | _$_ l20 lam : *.* -> * | ƛ_ r10 theory (ƛβ) b : *.* a : * |> app (lam (x.b[x]), a) = b[a] (ƛη) f : * |> lam (x.app (f, x)) = f (lβ) b : *.* a : * |> letd (a, x. b) = b[a] -} module UTLC.Syntax where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Metatheory.Syntax open import UTLC.Signature private variable Γ Δ Π : Ctx α : *T 𝔛 : Familyₛ -- Inductive term declaration module Λ:Terms (𝔛 : Familyₛ) where data Λ : Familyₛ where var : ℐ ⇾̣ Λ mvar : 𝔛 α Π → Sub Λ Π Γ → Λ α Γ _$_ : Λ * Γ → Λ * Γ → Λ * Γ ƛ_ : Λ * (* ∙ Γ) → Λ * Γ infixl 20 _$_ infixr 10 ƛ_ open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 Λᵃ : MetaAlg Λ Λᵃ = record { 𝑎𝑙𝑔 = λ where (appₒ ⋮ a , b) → _$_ a b (lamₒ ⋮ a) → ƛ_ a ; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) } module Λᵃ = MetaAlg Λᵃ module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where open MetaAlg 𝒜ᵃ 𝕤𝕖𝕞 : Λ ⇾̣ 𝒜 𝕊 : Sub Λ Π Γ → Π ~[ 𝒜 ]↝ Γ 𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t 𝕊 (t ◂ σ) (old v) = 𝕊 σ v 𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε) 𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v 𝕤𝕖𝕞 (_$_ a b) = 𝑎𝑙𝑔 (appₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞 (ƛ_ a) = 𝑎𝑙𝑔 (lamₒ ⋮ 𝕤𝕖𝕞 a) 𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ Λᵃ 𝒜ᵃ 𝕤𝕖𝕞 𝕤𝕖𝕞ᵃ⇒ = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t } ; ⟨𝑣𝑎𝑟⟩ = refl ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } } where open ≡-Reasoning ⟨𝑎𝑙𝑔⟩ : (t : ⅀ Λ α Γ) → 𝕤𝕖𝕞 (Λᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t) ⟨𝑎𝑙𝑔⟩ (appₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (lamₒ ⋮ _) = refl 𝕊-tab : (mε : Π ~[ Λ ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v) 𝕊-tab mε new = refl 𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v module _ (g : Λ ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ Λᵃ 𝒜ᵃ g) where open MetaAlg⇒ gᵃ⇒ 𝕤𝕖𝕞! : (t : Λ α Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕊-ix : (mε : Sub Λ Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v) 𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x 𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v 𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε)) = trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε)) 𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩ 𝕤𝕖𝕞! (_$_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (ƛ_ a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩ -- Syntax instance for the signature Λ:Syn : Syntax Λ:Syn = record { ⅀F = ⅀F ; ⅀:CS = ⅀:CompatStr ; mvarᵢ = Λ:Terms.mvar ; 𝕋:Init = λ 𝔛 → let open Λ:Terms 𝔛 in record { ⊥ = Λ ⋉ Λᵃ ; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ } ; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } } -- Instantiation of the syntax and metatheory open Syntax Λ:Syn public open Λ:Terms public open import SOAS.Families.Build public open import SOAS.Syntax.Shorthands Λᵃ public open import SOAS.Metatheory Λ:Syn public -- Derived operations letd : Λ 𝔛 * Γ → Λ 𝔛 * (* ∙ Γ) → Λ 𝔛 * Γ letd a b = (ƛ b) $ a
{ "alphanum_fraction": 0.520846494, "avg_line_length": 24.5426356589, "ext": "agda", "hexsha": "23e4ce3007eb989d68cabd25f5f05653d961174a", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/UTLC/Syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/UTLC/Syntax.agda", "max_line_length": 93, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/UTLC/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 2007, "size": 3166 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reduction {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Typed open import Definition.Typed.Properties import Definition.Typed.Weakening as Wk open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Universe open import Definition.LogicalRelation.Properties.Escape open import Tools.Product import Tools.PropositionalEquality as PE -- Weak head expansion of reducible types. redSubst* : ∀ {A B l Γ} → Γ ⊢ A ⇒* B → Γ ⊩⟨ l ⟩ B → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / [A] redSubst* D (Uᵣ′ l′ l< ⊢Γ) rewrite redU* D = Uᵣ′ l′ l< ⊢Γ , PE.refl redSubst* D (ℕᵣ [ ⊢B , ⊢ℕ , D′ ]) = let ⊢A = redFirst* D in ℕᵣ ([ ⊢A , ⊢ℕ , D ⇨* D′ ]) , D′ redSubst* D (Emptyᵣ [ ⊢B , ⊢Empty , D′ ]) = let ⊢A = redFirst* D in Emptyᵣ ([ ⊢A , ⊢Empty , D ⇨* D′ ]) , D′ redSubst* D (Unitᵣ [ ⊢B , ⊢Unit , D′ ]) = let ⊢A = redFirst* D in Unitᵣ ([ ⊢A , ⊢Unit , D ⇨* D′ ]) , D′ redSubst* D (ne′ K [ ⊢B , ⊢K , D′ ] neK K≡K) = let ⊢A = redFirst* D in (ne′ K [ ⊢A , ⊢K , D ⇨* D′ ] neK K≡K) , (ne₌ _ [ ⊢B , ⊢K , D′ ] neK K≡K) redSubst* D (Bᵣ′ W F G [ ⊢B , ⊢ΠFG , D′ ] ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢A = redFirst* D in (Bᵣ′ W F G [ ⊢A , ⊢ΠFG , D ⇨* D′ ] ⊢F ⊢G A≡A [F] [G] G-ext) , (B₌ _ _ D′ A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a]))) redSubst* D (emb 0<1 x) with redSubst* D x redSubst* D (emb 0<1 x) | y , y₁ = emb 0<1 y , y₁ -- Weak head expansion of reducible terms. redSubst*Term : ∀ {A t u l Γ} → Γ ⊢ t ⇒* u ∷ A → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ u ∷ A / [A] → Γ ⊩⟨ l ⟩ t ∷ A / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] redSubst*Term t⇒u (Uᵣ′ .⁰ 0<1 ⊢Γ) (Uₜ A [ ⊢t , ⊢u , d ] typeA A≡A [u]) = let [d] = [ ⊢t , ⊢u , d ] [d′] = [ redFirst*Term t⇒u , ⊢u , t⇒u ⇨∷* d ] q = redSubst* (univ* t⇒u) (univEq (Uᵣ′ ⁰ 0<1 ⊢Γ) (Uₜ A [d] typeA A≡A [u])) in Uₜ A [d′] typeA A≡A (proj₁ q) , Uₜ₌ A A [d′] [d] typeA typeA A≡A (proj₁ q) [u] (proj₂ q) redSubst*Term t⇒u (ℕᵣ D) (ℕₜ n [ ⊢u , ⊢n , d ] n≡n prop) = let A≡ℕ = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡ℕ t⇒u′ = conv* t⇒u A≡ℕ in ℕₜ n [ ⊢t , ⊢n , t⇒u′ ⇨∷* d ] n≡n prop , ℕₜ₌ n n [ ⊢t , ⊢n , t⇒u′ ⇨∷* d ] [ ⊢u , ⊢n , d ] n≡n (reflNatural-prop prop) redSubst*Term t⇒u (Emptyᵣ D) (Emptyₜ n [ ⊢u , ⊢n , d ] n≡n prop) = let A≡Empty = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡Empty t⇒u′ = conv* t⇒u A≡Empty in Emptyₜ n [ ⊢t , ⊢n , t⇒u′ ⇨∷* d ] n≡n prop , Emptyₜ₌ n n [ ⊢t , ⊢n , t⇒u′ ⇨∷* d ] [ ⊢u , ⊢n , d ] n≡n (reflEmpty-prop prop) redSubst*Term t⇒u (Unitᵣ D) (Unitₜ n [ ⊢u , ⊢n , d ] prop) = let A≡Unit = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡Unit t⇒u′ = conv* t⇒u A≡Unit in Unitₜ n [ ⊢t , ⊢n , t⇒u′ ⇨∷* d ] prop , Unitₜ₌ ⊢t ⊢u redSubst*Term t⇒u (ne′ K D neK K≡K) (neₜ k [ ⊢t , ⊢u , d ] (neNfₜ neK₁ ⊢k k≡k)) = let A≡K = subset* (red D) [d] = [ ⊢t , ⊢u , d ] [d′] = [ conv (redFirst*Term t⇒u) A≡K , ⊢u , conv* t⇒u A≡K ⇨∷* d ] in neₜ k [d′] (neNfₜ neK₁ ⊢k k≡k) , neₜ₌ k k [d′] [d] (neNfₜ₌ neK₁ neK₁ k≡k) redSubst*Term {A} {t} {u} {l} {Γ} t⇒u (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) [u]@(Πₜ f [d]@([ ⊢t , ⊢u , d ]) funcF f≡f [f] [f]₁) = let A≡ΠFG = subset* (red D) t⇒u′ = conv* t⇒u A≡ΠFG [d′] = [ conv (redFirst*Term t⇒u) A≡ΠFG , ⊢u , conv* t⇒u A≡ΠFG ⇨∷* d ] [u′] = Πₜ f [d′] funcF f≡f [f] [f]₁ in [u′] , Πₜ₌ f f [d′] [d] funcF funcF f≡f [u′] [u] (λ [ρ] ⊢Δ [a] → reflEqTerm ([G] [ρ] ⊢Δ [a]) ([f]₁ [ρ] ⊢Δ [a])) redSubst*Term {A} {t} {u} {l} {Γ} t⇒u (Σᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) [u]@(Σₜ p [d]@([ ⊢t , ⊢u , d ]) pProd p≅p [fst] [snd]) = let A≡ΣFG = subset* (red D) t⇒u′ = conv* t⇒u A≡ΣFG [d′] = [ conv (redFirst*Term t⇒u) A≡ΣFG , ⊢u , conv* t⇒u A≡ΣFG ⇨∷* d ] [u′] = Σₜ p [d′] pProd p≅p [fst] [snd] in [u′] , Σₜ₌ p p [d′] [d] pProd pProd p≅p [u′] [u] [fst] [fst] (reflEqTerm ([F] Wk.id (wf ⊢F)) [fst]) (reflEqTerm ([G] Wk.id (wf ⊢F) [fst]) [snd]) redSubst*Term t⇒u (emb 0<1 x) [u] = redSubst*Term t⇒u x [u] -- Weak head expansion of reducible types with single reduction step. redSubst : ∀ {A B l Γ} → Γ ⊢ A ⇒ B → Γ ⊩⟨ l ⟩ B → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / [A] redSubst A⇒B [B] = redSubst* (A⇒B ⇨ id (escape [B])) [B] -- Weak head expansion of reducible terms with single reduction step. redSubstTerm : ∀ {A t u l Γ} → Γ ⊢ t ⇒ u ∷ A → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ u ∷ A / [A] → Γ ⊩⟨ l ⟩ t ∷ A / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] redSubstTerm t⇒u [A] [u] = redSubst*Term (t⇒u ⇨ id (escapeTerm [A] [u])) [A] [u]
{ "alphanum_fraction": 0.4723210755, "avg_line_length": 40.464, "ext": "agda", "hexsha": "fe326f0e62ec9144ad25edb4802540b0a9cb8322", "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/Properties/Reduction.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/Properties/Reduction.agda", "max_line_length": 81, "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/Properties/Reduction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2696, "size": 5058 }
------------------------------------------------------------------------ -- Call-by-value (CBV) reduction in Fω with interval kinds. ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module FOmegaInt.Reduction.Cbv where open import Data.Fin.Substitution open import Data.Fin.Substitution.ExtraLemmas import Relation.Binary.Construct.Closure.Equivalence as EqClos open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (map; gmap) import Relation.Binary.PropositionalEquality as PropEq open import Relation.Binary.Reduction open import FOmegaInt.Syntax open import FOmegaInt.Reduction.Full open Syntax open Substitution using (_[_]) ---------------------------------------------------------------------- -- Call-by-value (CBV) reduction and equivalence relations -- Untyped term values with up to n free variables. data Val {n} : Term n → Set where Λ : ∀ k a → Val (Λ k a) -- type abstraction ƛ : ∀ a b → Val (ƛ a b) -- term abstraction infixl 9 _·₁_ _·₂_ _⊡_ infix 5 _→v_ -- One-step CBV reduction. data _→v_ {n} : Term n → Term n → Set where cont-· : ∀ a b {c} (v : Val c) → (ƛ a b) · c →v b [ c ] cont-⊡ : ∀ k a b → (Λ k a) ⊡ b →v a [ b ] _·₁_ : ∀ {a₁ a₂} → a₁ →v a₂ → ∀ b → a₁ · b →v a₂ · b _·₂_ : ∀ {a b₁ b₂} (v : Val a) → b₁ →v b₂ → a · b₁ →v a · b₂ _⊡_ : ∀ {a₁ a₂} → a₁ →v a₂ → ∀ b → a₁ ⊡ b →v a₂ ⊡ b reduction : Reduction Term reduction = record { _→1_ = _→v_ } -- CBV reduction and equivalence. open Reduction reduction public renaming (_→*_ to _→v*_; _↔_ to _≡v_) ---------------------------------------------------------------------- -- Simple properties of the CBV reductions/equivalence -- Inclusions. →v⇒→v* = →1⇒→* reduction →v*⇒≡v = →*⇒↔ reduction →v⇒≡v = →1⇒↔ reduction -- CBV reduction is a preorder. →v*-predorder = →*-preorder reduction -- Preorder reasoning for CBV reduction. module →v*-Reasoning = →*-Reasoning reduction -- Terms together with CBV equivalence form a setoid. ≡v-setoid = ↔-setoid reduction -- Equational reasoning for CBV equivalence. module ≡v-Reasoning = ↔-Reasoning reduction ---------------------------------------------------------------------- -- Relationships between CBV reduction and full β-reduction -- One-step CBV reduction implies one-step β-reduction. →v⇒→β : ∀ {n} {a b : Term n} → a →v b → a →β b →v⇒→β (cont-· a b c) = ⌈ cont-Tm· a b _ ⌉ →v⇒→β (cont-⊡ k a b) = ⌈ cont-⊡ k a b ⌉ →v⇒→β (a₁→a₂ ·₁ b) = →v⇒→β a₁→a₂ ·₁ b →v⇒→β (a ·₂ b₁→b₂) = _ ·₂ →v⇒→β b₁→b₂ →v⇒→β (a₁→a₂ ⊡ b) = →v⇒→β a₁→a₂ ⊡₁ b -- CBV reduction implies β-reduction. →v*⇒→β* : ∀ {n} {a b : Term n} → a →v* b → a →β* b →v*⇒→β* = map →v⇒→β -- CBV equivalence implies β-equivalence. ≡v⇒≡β : ∀ {n} {a b : Term n} → a ≡v b → a ≡β b ≡v⇒≡β = EqClos.map →v⇒→β
{ "alphanum_fraction": 0.5376044568, "avg_line_length": 32.6363636364, "ext": "agda", "hexsha": "72565aed2b064743068165f82c91e802f325c39f", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z", "max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/FOmegaInt/Reduction/Cbv.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z", "max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/FOmegaInt/Reduction/Cbv.agda", "max_line_length": 72, "max_stars_count": 12, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/FOmegaInt/Reduction/Cbv.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z", "max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z", "num_tokens": 1021, "size": 2872 }
module int-tests where open import int open import eq open import product three : ℤ three = , next next unit{pos} -two : ℤ -two = , next unit{neg} one = -two +ℤ three one-lem : one ≡ ,_ { a = nonzero pos } unit one-lem = refl six = three +ℤ three -four = -two +ℤ -two
{ "alphanum_fraction": 0.6413043478, "avg_line_length": 12.5454545455, "ext": "agda", "hexsha": "50c327ac52fdef87e03cb1ac027f1b4bea1963bb", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "cruft/int-tests.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "cruft/int-tests.agda", "max_line_length": 43, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "cruft/int-tests.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 94, "size": 276 }
module Luau.Heap where open import Agda.Builtin.Equality using (_≡_) open import FFI.Data.Maybe using (Maybe; just) open import FFI.Data.Vector using (Vector; length; snoc; empty) open import Luau.Addr using (Addr) open import Luau.Var using (Var) open import Luau.Syntax using (Block; Expr; Annotated; FunDec; nil; addr; function_is_end) data HeapValue (a : Annotated) : Set where function_is_end : FunDec a → Block a → HeapValue a Heap : Annotated → Set Heap a = Vector (HeapValue a) data _≡_⊕_↦_ {a} : Heap a → Heap a → Addr → HeapValue a → Set where defn : ∀ {H val} → ----------------------------------- (snoc H val) ≡ H ⊕ (length H) ↦ val _[_] : ∀ {a} → Heap a → Addr → Maybe (HeapValue a) _[_] = FFI.Data.Vector.lookup ∅ : ∀ {a} → Heap a ∅ = empty data AllocResult a (H : Heap a) (V : HeapValue a) : Set where ok : ∀ b H′ → (H′ ≡ H ⊕ b ↦ V) → AllocResult a H V alloc : ∀ {a} H V → AllocResult a H V alloc H V = ok (length H) (snoc H V) defn next : ∀ {a} → Heap a → Addr next = length allocated : ∀ {a} → Heap a → HeapValue a → Heap a allocated = snoc -- next-emp : (length ∅ ≡ 0) next-emp = FFI.Data.Vector.length-empty -- lookup-next : ∀ V H → (lookup (allocated H V) (next H) ≡ just V) lookup-next = FFI.Data.Vector.lookup-snoc -- lookup-next-emp : ∀ V → (lookup (allocated emp V) 0 ≡ just V) lookup-next-emp = FFI.Data.Vector.lookup-snoc-empty
{ "alphanum_fraction": 0.6293352601, "avg_line_length": 27.68, "ext": "agda", "hexsha": "12f8dab07b931fdec0a39426b4b6b3b0b398770f", "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": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Luau/Heap.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "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": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Luau/Heap.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Luau/Heap.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 462, "size": 1384 }
open import Functional hiding (Domain) import Structure.Logic.Classical.NaturalDeduction import Structure.Logic.Classical.SetTheory.ZFC module Structure.Logic.Classical.SetTheory.ZFC.BinaryRelatorSet {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) ⦃ signature : _ ⦄ where open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic) open Structure.Logic.Classical.SetTheory.ZFC.Signature {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic ⦄ {_∈_} (signature) open import Structure.Logic.Classical.SetTheory.SetBoundedQuantification ⦃ classicLogic ⦄ (_∈_) -- Like: -- (x,f(x)) = (x , y) -- f = {(x , y)} -- = {{{x},{x,y}}} -- ⋃f = {{x},{x,y}} -- ⋃²f = {x,y} lefts : Domain → Domain lefts(s) = filter(⋃(⋃ s)) (x ↦ ∃ₗ(y ↦ (x , y) ∈ s)) rights : Domain → Domain rights(s) = filter(⋃(⋃ s)) (y ↦ ∃ₗ(x ↦ (x , y) ∈ s)) leftsOfMany : Domain → Domain → Domain leftsOfMany f(S) = filter(⋃(⋃ f)) (a ↦ ∃ₛ(S)(y ↦ (a , y) ∈ f)) rightsOfMany : Domain → Domain → Domain rightsOfMany f(S) = filter(⋃(⋃ f)) (a ↦ ∃ₛ(S)(x ↦ (x , a) ∈ f)) leftsOf : Domain → Domain → Domain leftsOf f(y) = leftsOfMany f(singleton(y)) rightsOf : Domain → Domain → Domain rightsOf f(x) = rightsOfMany f(singleton(x)) -- swap : Domain → Domain -- swap(s) = filter(rights(s) ⨯ left(s)) (xy ↦ )
{ "alphanum_fraction": 0.6342161775, "avg_line_length": 37.7567567568, "ext": "agda", "hexsha": "dd807214f9bfc86abcbe44e4e52c766fa6341bbb", "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": "old/Structure/Logic/Classical/SetTheory/ZFC/BinaryRelatorSet.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": "old/Structure/Logic/Classical/SetTheory/ZFC/BinaryRelatorSet.agda", "max_line_length": 185, "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": "old/Structure/Logic/Classical/SetTheory/ZFC/BinaryRelatorSet.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": 551, "size": 1397 }
open import Data.Bool using ( Bool ; true ; false ; _∧_ ) open import Data.Product using ( _×_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ) open import Relation.Unary using ( _∈_ ) open import Web.Semantic.DL.Concept using ( Concept ; ⟨_⟩ ; ¬⟨_⟩ ; ⊤ ; ⊥ ; _⊓_ ; _⊔_ ; ∀[_]_ ; ∃⟨_⟩_ ; ≤1 ; >1 ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ; ε ; _,_ ;_⊑₁_ ; _⊑₂_ ; Dis ; Ref ; Irr ; Tra ) open import Web.Semantic.Util using ( Subset ; □ ; □-proj₁ ; □-proj₂ ) module Web.Semantic.DL.TBox.Minimizable {Σ : Signature} where data LHS : Subset (Concept Σ) where ⟨_⟩ : ∀ c → ⟨ c ⟩ ∈ LHS ⊤ : ⊤ ∈ LHS ⊥ : ⊥ ∈ LHS _⊓_ : ∀ {C D} → (C ∈ LHS) → (D ∈ LHS) → ((C ⊓ D) ∈ LHS) _⊔_ : ∀ {C D} → (C ∈ LHS) → (D ∈ LHS) → ((C ⊔ D) ∈ LHS) ∃⟨_⟩_ : ∀ R {C} → (C ∈ LHS) → ((∃⟨ R ⟩ C) ∈ LHS) data RHS : Subset (Concept Σ) where ⟨_⟩ : ∀ c → ⟨ c ⟩ ∈ RHS ⊤ : ⊤ ∈ RHS _⊓_ : ∀ {C D} → (C ∈ RHS) → (D ∈ RHS) → ((C ⊓ D) ∈ RHS) ∀[_]_ : ∀ R {C} → (C ∈ RHS) → ((∀[ R ] C) ∈ RHS) ≤1 : ∀ R → ((≤1 R) ∈ RHS) data μTBox : Subset (TBox Σ) where ε : μTBox ε _,_ : ∀ {T U} → (T ∈ μTBox) → (U ∈ μTBox) → ((T , U) ∈ μTBox) _⊑₁_ : ∀ {C D} → (C ∈ LHS) → (D ∈ RHS) → ((C ⊑₁ D) ∈ μTBox) _⊑₂_ : ∀ Q R → ((Q ⊑₂ R) ∈ μTBox) Ref : ∀ R → (Ref R ∈ μTBox) Tra : ∀ R → (Tra R ∈ μTBox) lhs? : Concept Σ → Bool lhs? ⟨ c ⟩ = true lhs? ¬⟨ c ⟩ = false lhs? ⊤ = true lhs? ⊥ = true lhs? (C ⊓ D) = lhs? C ∧ lhs? D lhs? (C ⊔ D) = lhs? C ∧ lhs? D lhs? (∀[ R ] C) = false lhs? (∃⟨ R ⟩ C) = lhs? C lhs? (≤1 R) = false lhs? (>1 R) = false lhs : ∀ C {C✓ : □(lhs? C)} → LHS C lhs ⟨ c ⟩ = ⟨ c ⟩ lhs ⊤ = ⊤ lhs ⊥ = ⊥ lhs (C ⊓ D) {C⊓D✓} = lhs C {□-proj₁ C⊓D✓} ⊓ lhs D {□-proj₂ {lhs? C} C⊓D✓} lhs (C ⊔ D) {C⊔D✓} = lhs C {□-proj₁ C⊔D✓} ⊔ lhs D {□-proj₂ {lhs? C} C⊔D✓} lhs (∃⟨ R ⟩ C) {C✓} = ∃⟨ R ⟩ (lhs C {C✓}) lhs ¬⟨ c ⟩ {} lhs (∀[ R ] C) {} lhs (≤1 R) {} lhs (>1 R) {} rhs? : Concept Σ → Bool rhs? ⟨ c ⟩ = true rhs? ¬⟨ c ⟩ = false rhs? ⊤ = true rhs? ⊥ = false rhs? (C ⊓ D) = rhs? C ∧ rhs? D rhs? (C ⊔ D) = false rhs? (∀[ R ] C) = rhs? C rhs? (∃⟨ R ⟩ C) = false rhs? (≤1 R) = true rhs? (>1 R) = false rhs : ∀ C {C✓ : □(rhs? C)} → RHS C rhs ⟨ c ⟩ = ⟨ c ⟩ rhs ⊤ = ⊤ rhs (C ⊓ D) {C⊓D✓} = rhs C {□-proj₁ C⊓D✓} ⊓ rhs D {□-proj₂ {rhs? C} C⊓D✓} rhs (∀[ R ] C) {C✓} = ∀[ R ] (rhs C {C✓}) rhs (≤1 R) = ≤1 R rhs ⊥ {} rhs ¬⟨ c ⟩ {} rhs (C ⊔ D) {} rhs (∃⟨ R ⟩ C) {} rhs (>1 R) {} μTBox? : TBox Σ → Bool μTBox? ε = true μTBox? (T , U) = μTBox? T ∧ μTBox? U μTBox? (C ⊑₁ D) = lhs? C ∧ rhs? D μTBox? (Q ⊑₂ R) = true μTBox? (Dis Q R) = false μTBox? (Ref R) = true μTBox? (Irr R) = false μTBox? (Tra R) = true μtBox : ∀ T {T✓ : □(μTBox? T)} → μTBox T μtBox ε = ε μtBox (T , U) {TU✓} = (μtBox T {□-proj₁ TU✓} , μtBox U {□-proj₂ {μTBox? T} TU✓}) μtBox (C ⊑₁ D) {C⊑D✓} = lhs C {□-proj₁ C⊑D✓} ⊑₁ rhs D {□-proj₂ {lhs? C} C⊑D✓} μtBox (Q ⊑₂ R) = Q ⊑₂ R μtBox (Ref R) = Ref R μtBox (Tra R) = Tra R μtBox (Dis Q R) {} μtBox (Irr R) {}
{ "alphanum_fraction": 0.431670282, "avg_line_length": 31.0288461538, "ext": "agda", "hexsha": "cbdc0a4377dd63906550e7b914280550364c5520", "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/TBox/Minimizable.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/TBox/Minimizable.agda", "max_line_length": 82, "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/TBox/Minimizable.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": 1645, "size": 3227 }
-- Jesper, 2018-05-17: Fixed internal error. Now the second clause is -- marked as unreachable (which is perhaps reasonable) and the first -- clause is marked as not satisfying --exact-split (which is perhaps -- unreasonable). To fix this properly, we would need to keep track of -- excluded literals for not just pattern variables but also dot -- patterns (and perhaps in other places as well). open import Agda.Builtin.Char open import Agda.Builtin.Equality test : (c : Char) → c ≡ 'a' → Set test 'a' _ = Char test .'a' refl = Char
{ "alphanum_fraction": 0.729981378, "avg_line_length": 38.3571428571, "ext": "agda", "hexsha": "7bd5cc478867a6e64e29a849f01668b58bada662", "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/Issue3065.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/Issue3065.agda", "max_line_length": 70, "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/Issue3065.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": 141, "size": 537 }
------------------------------------------------------------------------------ -- We only translate first-order definitions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} ------------------------------------------------------------------------------ postulate D : Set _≡_ : D → D → Set succ : D → D -- A higher-order definition twice : (D → D) → D → D twice f x = f (f x) {-# ATP definition twice #-} postulate twice-succ : ∀ n → twice succ n ≡ succ (succ n) {-# ATP prove twice-succ #-}
{ "alphanum_fraction": 0.3620933522, "avg_line_length": 29.4583333333, "ext": "agda", "hexsha": "d944f1e3532538d38fb8bfcc1afa00db974b3224", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Fail/Errors/HigherOrderDefinition.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Fail/Errors/HigherOrderDefinition.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Fail/Errors/HigherOrderDefinition.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 135, "size": 707 }
------------------------------------------------------------------------ -- The Agda standard library -- -- "Finite" sets indexed on coinductive "natural" numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.Cofin where open import Size open import Codata.Thunk open import Codata.Conat as Conat using (Conat; zero; suc; infinity; _ℕ<_; sℕ≤s; _ℕ≤infinity) open import Codata.Conat.Bisimilarity as Bisim using (_⊢_≲_ ; s≲s) open import Data.Nat open import Data.Fin as Fin hiding (fromℕ; fromℕ≤; toℕ) open import Function open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- The type -- Note that `Cofin infnity` is /not/ finite. Note also that this is not a -- coinductive type, but it is indexed on a coinductive type. data Cofin : Conat ∞ → Set where zero : ∀ {n} → Cofin (suc n) suc : ∀ {n} → Cofin (n .force) → Cofin (suc n) suc-injective : ∀ {n} {p q : Cofin (n .force)} → (Cofin (suc n) ∋ suc p) ≡ suc q → p ≡ q suc-injective refl = refl ------------------------------------------------------------------------ -- Some operations fromℕ< : ∀ {n k} → k ℕ< n → Cofin n fromℕ< {zero} () fromℕ< {suc n} {zero} (sℕ≤s p) = zero fromℕ< {suc n} {suc k} (sℕ≤s p) = suc (fromℕ< p) fromℕ : ℕ → Cofin infinity fromℕ k = fromℕ< (suc k ℕ≤infinity) toℕ : ∀ {n} → Cofin n → ℕ toℕ zero = zero toℕ (suc i) = suc (toℕ i) fromFin : ∀ {n} → Fin n → Cofin (Conat.fromℕ n) fromFin zero = zero fromFin (suc i) = suc (fromFin i) toFin : ∀ n → Cofin (Conat.fromℕ n) → Fin n toFin zero () toFin (suc n) zero = zero toFin (suc n) (suc i) = suc (toFin n i)
{ "alphanum_fraction": 0.5323782235, "avg_line_length": 30.6140350877, "ext": "agda", "hexsha": "3e408fb8bfdbeb29d04376ef0dfd0a1cf3c21dab", "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/Codata/Cofin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/Cofin.agda", "max_line_length": 93, "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/Codata/Cofin.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 589, "size": 1745 }
-- Andreas, 2016-11-02, issue #2290 postulate A : Set a : A F : Set → Set mutual data D : A → _ where FDa = F (D a) -- ERROR WAS: -- The sort of D cannot depend on its indices in the type A → Set _7 -- Should pass. mutual data E : (x : A) → _ where FEa = F (E a)
{ "alphanum_fraction": 0.5744680851, "avg_line_length": 14.1, "ext": "agda", "hexsha": "dbb38c7a8dfce912a9a5cb8f5d697f78ec331447", "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/Issue2290.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/Issue2290.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2290.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": 282 }
open import Agda.Primitive using (_⊔_) -- Set being type of all types (which is infinitely nested as Set₀ Set₁ etc postulate String : Set {-# BUILTIN STRING String #-} data bool : Set where tt : bool ff : bool ex₀ : bool → String ex₀ tt = "true" ex₀ ff = "false" -- parameterization over all "Sets" -- otherwise we are limited to types that ∈ Set if_then_else_ : ∀ { ℓ } { A : Set ℓ } → bool → A → A → A if tt then x else y = x if ff then x else y = y data ℕ : Set where zero : ℕ succ : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} _plus_ : ℕ → ℕ → ℕ zero plus n = n succ m plus n = succ (m plus n) ex₁ : ℕ ex₁ = 5 data [_] (A : Set) : Set where ♢ : [ A ] _,_ : A → [ A ] → [ A ] infixr 6 _,_ _++_ : ∀{ α } → [ α ] → [ α ] → [ α ] ♢ ++ ys = ys (x , xs) ++ ys = x , xs ++ ys ex₂ : [ ℕ ] ex₂ = 5 , 6 , ♢ -- why is this equivalent to --data _≡_ { α : Set } (x : α) : α → Set where -- refl : x ≡ x -- syntactical identity data _≡_ { ℓ } { α : Set ℓ} : α → α → Set ℓ where refl : ∀ { x : α } → x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} data ⊥ : Set where ex₃ : (2 plus 3) ≡ 5 ex₃ = refl -- logical negation in intutionistic logic ex₄ : 0 ≡ 1 → ⊥ ex₄ () cong : ∀ { ℓ } { A B : Set ℓ } → { a b : A } { f : A → B } → a ≡ b → f a ≡ f b cong refl = refl ex₅ : ∀ { n } → (n plus 0) ≡ n ex₅ {zero} = refl ex₅ {succ n1} = cong { f = succ } ex₅ -- rewrites and dot patterns ?? data _+_ (α : Set) (β : Set) : Set where left : α → α + β right : β → α + β ex₆ : String + ℕ ex₆ = left "foo" ex₇ : String + ℕ ex₇ = right 5 record _∨_ (α β : Set) : Set where constructor _,_ field fst : bool snd : if fst then β else α tosum : ∀ { α β } → α + β → α ∨ β tosum (left a) = ff , a tosum (right b) = tt , b unsum : ∀ { α β } → α ∨ β → α + β unsum (ff , a) = left a unsum (tt , b) = right b tosum∘unsum : ∀ { α β } → (p : α ∨ β) → (tosum (unsum p)) ≡ p tosum∘unsum (tt , b) = refl tosum∘unsum (ff , b) = refl unsum∘tosum : ∀ { α β } → (p : α + β) → (unsum (tosum p)) ≡ p unsum∘tosum (left a) = refl unsum∘tosum (right b) = refl --- Thus α + β is same as dependently typed α ∨ β. Further generalizing record Σ (I : Set) (V : I -> Set) : Set where constructor _,_ field fst : I snd : V fst --- now α ∨ β can be written as -- this is on the types, not on values or : Set → Set → Set or x y = Σ bool (λ b → if b then x else y) -- assume V does not depend on I, we get products twice : Set → Set twice x = Σ bool (λ b → x)
{ "alphanum_fraction": 0.5349022736, "avg_line_length": 19.5859375, "ext": "agda", "hexsha": "6f9920b0deb6eb8e1115350107ba0a3525ee8032", "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": "117fbb0a28ff1891e0f3e10f7259ead0de4d114a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "curriedbanana/agda-exercises", "max_forks_repo_path": "intro-to-agda/Begin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "117fbb0a28ff1891e0f3e10f7259ead0de4d114a", "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": "curriedbanana/agda-exercises", "max_issues_repo_path": "intro-to-agda/Begin.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "117fbb0a28ff1891e0f3e10f7259ead0de4d114a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "curriedbanana/agda-exercises", "max_stars_repo_path": "intro-to-agda/Begin.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1020, "size": 2507 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.Cokernel open import groups.Image import homotopy.ConstantToSetExtendsToProp as ConstExt -- A collection of useful lemmas about exactness module groups.Exactness where module Exact {i j k} {G : Group i} {H : Group j} {K : Group k} {φ : G →ᴳ H} {ψ : H →ᴳ K} (φ-ψ-is-exact : is-exact φ ψ) where private module G = Group G module H = Group H module K = Group K module φ = GroupHom φ module ψ = GroupHom ψ module E = is-exact φ-ψ-is-exact abstract φ-const-implies-ψ-is-inj : (∀ g → φ.f g == H.ident) → is-injᴳ ψ φ-const-implies-ψ-is-inj φ-is-const = has-trivial-ker-is-injᴳ ψ λ h ψh=0 → Trunc-rec (H.El-is-set _ _) (λ{(g , φg=h) → ! φg=h ∙ φ-is-const g}) (E.ker-sub-im h ψh=0) G-trivial-implies-ψ-is-inj : is-trivialᴳ G → is-injᴳ ψ G-trivial-implies-ψ-is-inj G-is-triv = φ-const-implies-ψ-is-inj λ g → ap φ.f (G-is-triv g) ∙ φ.pres-ident G-to-ker : G →ᴳ Ker.grp ψ G-to-ker = Ker.inject-lift ψ φ (λ g → E.im-sub-ker (φ.f g) [ g , idp ]) abstract φ-inj-implies-G-to-ker-is-equiv : is-injᴳ φ → is-equiv (GroupHom.f G-to-ker) φ-inj-implies-G-to-ker-is-equiv φ-is-inj = is-eq _ from to-from from-to where to : G.El → Ker.El ψ to = GroupHom.f G-to-ker module From (k : Ker.El ψ) = ConstExt {A = hfiber φ.f (fst k)} {B = G.El} G.El-is-set (λ hf → fst hf) (λ hf₁ hf₂ → φ-is-inj _ _ (snd hf₁ ∙ ! (snd hf₂))) from : Ker.El ψ → G.El from = λ k → From.ext k (uncurry E.ker-sub-im k) to-from : ∀ k → to (from k) == k to-from k = Ker.El=-out ψ $ Trunc-elim {P = λ hf → φ.f (From.ext k hf) == fst k} (λ _ → H.El-is-set _ _) (λ{(g , p) → p}) (uncurry E.ker-sub-im k) from-to : ∀ g → from (to g) == g from-to g = From.ext-is-const (to g) (uncurry E.ker-sub-im (to g)) [ g , idp ] φ-inj-implies-G-iso-ker : is-injᴳ φ → G ≃ᴳ Ker.grp ψ φ-inj-implies-G-iso-ker φ-is-inj = G-to-ker , φ-inj-implies-G-to-ker-is-equiv φ-is-inj abstract K-trivial-implies-φ-is-surj : is-trivialᴳ K → is-surjᴳ φ K-trivial-implies-φ-is-surj K-is-triv h = E.ker-sub-im h (K-is-triv (ψ.f h)) coker-to-K : (H-is-abelian : is-abelian H) → Coker φ H-is-abelian →ᴳ K coker-to-K H-is-abelian = record {M} where module M where module Cok = Coker φ H-is-abelian abstract f-rel : ∀ {h₁ h₂ : H.El} (h₁h₂⁻¹-in-im : SubgroupProp.prop (im-propᴳ φ) (H.diff h₁ h₂)) → ψ.f h₁ == ψ.f h₂ f-rel {h₁} {h₂} h₁h₂⁻¹-in-im = K.zero-diff-same _ _ $ ! (ψ.pres-diff h₁ h₂) ∙ E.im-sub-ker (H.diff h₁ h₂) h₁h₂⁻¹-in-im f : Cok.El → K.El f = SetQuot-rec K.El-is-set ψ.f f-rel abstract pres-comp : ∀ h₁ h₂ → f (Cok.comp h₁ h₂) == K.comp (f h₁) (f h₂) pres-comp = SetQuot-elim (λ _ → Π-is-set λ _ → =-preserves-set K.El-is-set) (λ h₁ → SetQuot-elim (λ _ → =-preserves-set K.El-is-set) (λ h₂ → ψ.pres-comp h₁ h₂) (λ _ → prop-has-all-paths-↓ (K.El-is-set _ _))) (λ _ → prop-has-all-paths-↓ (Π-is-prop λ _ → K.El-is-set _ _)) abstract ψ-surj-implies-coker-to-K-is-equiv : (H-is-abelian : is-abelian H) → is-surjᴳ ψ → is-equiv (GroupHom.f (coker-to-K H-is-abelian)) ψ-surj-implies-coker-to-K-is-equiv H-is-abelian ψ-is-surj = is-eq to from to-from from-to where module Cok = Coker φ H-is-abelian to : Cok.El → K.El to = GroupHom.f (coker-to-K H-is-abelian) module From (k : K.El) = ConstExt {A = hfiber ψ.f k} {B = Cok.El} Cok.El-is-set (λ hf → q[ fst hf ]) (λ{(h₁ , p₁) (h₂ , p₂) → quot-rel $ E.ker-sub-im (H.diff h₁ h₂) $ ψ.pres-diff h₁ h₂ ∙ ap2 K.diff p₁ p₂ ∙ K.inv-r k}) from : K.El → Cok.El from k = From.ext k (ψ-is-surj k) to-from : ∀ k → to (from k) == k to-from k = Trunc-elim {P = λ hf → to (From.ext k hf) == k} (λ _ → K.El-is-set _ _) (λ{(h , p) → p}) (ψ-is-surj k) from-to : ∀ c → from (to c) == c from-to = SetQuot-elim (λ _ → =-preserves-set Cok.El-is-set) (λ h → From.ext-is-const (ψ.f h) (ψ-is-surj (ψ.f h)) [ h , idp ]) (λ _ → prop-has-all-paths-↓ (Cok.El-is-set _ _)) ψ-surj-implies-coker-iso-K : (H-is-abelian : is-abelian H) → is-surjᴳ ψ → Coker φ H-is-abelian ≃ᴳ K ψ-surj-implies-coker-iso-K H-is-abelian ψ-is-surj = coker-to-K H-is-abelian , ψ-surj-implies-coker-to-K-is-equiv H-is-abelian ψ-is-surj -- right split lemma module _ (H-is-abelian : is-abelian H) (φ-inj : is-injᴳ φ) (χ : K →ᴳ H) (χ-inv-r : (k : Group.El K) → GroupHom.f (ψ ∘ᴳ χ) k == k) where {- 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. -} private module χ = GroupHom χ {- H ≃ᴳ Ker ψ × Im χ -} ker-part : H →ᴳ Ker ψ ker-part = Ker.inject-lift ψ (hom-comp H (H , H-is-abelian) (idhom H) (inv-hom (H , H-is-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)))) =⟨ χ-inv-r (K.inv (ψ.f h)) |in-ctx K.comp (ψ.f h) ⟩ K.comp (ψ.f h) (K.inv (ψ.f h)) =⟨ K.inv-r (ψ.f h) ⟩ K.ident ∎) abstract ker-part-kerψ : (ker : Ker.El ψ) → GroupHom.f ker-part (fst ker) == ker ker-part-kerψ (h , p) = Ker.El=-out ψ $ 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) =⟨ H.inv-ident |in-ctx H.comp h ⟩ H.comp h H.ident =⟨ H.unit-r h ⟩ h =∎ ker-part-imχ : (im : Im.El χ) → GroupHom.f ker-part (fst im) == Ker.ident ψ ker-part-imχ (h , s) = Trunc-rec (Ker.El-level ψ _ _) (λ {(k , p) → Ker.El=-out ψ $ 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)))) =⟨ χ-inv-r k |in-ctx (λ w → H.comp (χ.f k) (H.inv (χ.f w))) ⟩ H.comp (χ.f k) (H.inv (χ.f k)) =⟨ H.inv-r (χ.f k) ⟩ H.ident =∎}) s im-part : H →ᴳ Im χ im-part = im-lift χ ∘ᴳ ψ abstract im-part-kerψ : (ker : Ker.El ψ) → GroupHom.f im-part (fst ker) == Im.ident χ im-part-kerψ (h , p) = Im.El=-out χ (ap χ.f p ∙ χ.pres-ident) im-part-imχ : (im : Im.El χ) → GroupHom.f im-part (fst im) == im im-part-imχ (h , s) = Trunc-rec (Im.El-level χ _ _) (λ {(k , p) → Im.El=-out χ $ χ.f (ψ.f h) =⟨ ! p |in-ctx (χ.f ∘ ψ.f) ⟩ χ.f (ψ.f (χ.f k)) =⟨ χ-inv-r k |in-ctx χ.f ⟩ χ.f k =⟨ p ⟩ h =∎}) s decomp : H →ᴳ Ker ψ ×ᴳ Im χ decomp = ×ᴳ-fanout 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₂ abstract 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₂ ⟩ Ker.comp ψ (GroupHom.f ker-part h₁) (GroupHom.f ker-part h₂) =⟨ ap2 (Ker.comp ψ) (ker-part-kerψ (h₁ , kr)) (ker-part-imχ (h₂ , im)) ⟩ Ker.comp ψ (h₁ , kr) (Ker.ident ψ) =⟨ Ker.unit-r ψ (h₁ , kr) ⟩ (h₁ , kr) =∎) (GroupHom.f im-part (H.comp h₁ h₂) =⟨ GroupHom.pres-comp im-part h₁ h₂ ⟩ Im.comp χ (GroupHom.f im-part h₁) (GroupHom.f im-part h₂) =⟨ ap2 (Im.comp χ) (im-part-kerψ (h₁ , kr)) (im-part-imχ (h₂ , im)) ⟩ Im.comp χ (Im.ident χ) (h₂ , im) =⟨ Im.unit-l χ (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.inv-l (χ.f (ψ.f h)) |in-ctx H.comp h ⟩ H.comp h H.ident =⟨ H.unit-r h ⟩ h ∎ decomp-equiv : H.El ≃ Group.El (Ker ψ ×ᴳ Im χ) decomp-equiv = (_ , decomp-is-equiv) decomp-iso : H ≃ᴳ Ker ψ ×ᴳ Im χ decomp-iso = decomp , decomp-is-equiv {- K == Im χ -} K-iso-Imχ : K ≃ᴳ Im χ K-iso-Imχ = surjᴳ-and-injᴳ-iso (im-lift χ) (im-lift-is-surj χ) inj where abstract inj = has-trivial-ker-is-injᴳ (im-lift χ) (λ k p → ! (χ-inv-r k) ∙ ap ψ.f (ap fst p) ∙ ψ.pres-ident) φ-inj-and-ψ-has-rinv-split : H ≃ᴳ G ×ᴳ K φ-inj-and-ψ-has-rinv-split = ×ᴳ-emap (φ-inj-implies-G-iso-ker φ-inj ⁻¹ᴳ) (K-iso-Imχ ⁻¹ᴳ) ∘eᴳ decomp-iso abstract φ-inj-and-ψ-has-rinv-implies-φ-comm-inl : CommSquareᴳ φ ×ᴳ-inl (idhom _) (–>ᴳ φ-inj-and-ψ-has-rinv-split ) φ-inj-and-ψ-has-rinv-implies-φ-comm-inl = comm-sqrᴳ λ g → pair×= (ap (GroupIso.g (φ-inj-implies-G-iso-ker φ-inj)) (ker-part-kerψ (GroupHom.f G-to-ker g)) ∙ GroupIso.g-f (φ-inj-implies-G-iso-ker φ-inj) g) (im-sub-ker-out φ ψ E.im-sub-ker g) φ-inj-and-ψ-has-rinv-implies-ψ-comm-snd : CommSquareᴳ ψ (×ᴳ-snd {G = G}) (–>ᴳ φ-inj-and-ψ-has-rinv-split ) (idhom _) φ-inj-and-ψ-has-rinv-implies-ψ-comm-snd = comm-sqrᴳ λ h → idp abstract pre∘-is-exact : ∀ {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l} (φ : G →ᴳ H) {ψ : H →ᴳ K} {ξ : K →ᴳ L} → is-surjᴳ φ → is-exact ψ ξ → is-exact (ψ ∘ᴳ φ) ξ pre∘-is-exact φ {ψ = ψ} φ-is-surj ψ-ξ-is-exact = record { ker-sub-im = λ k → im-sub-im-∘ ψ φ φ-is-surj k ∘ ker-sub-im ψ-ξ-is-exact k; im-sub-ker = λ k → im-sub-ker ψ-ξ-is-exact k ∘ im-∘-sub-im ψ φ k} module Exact2 {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l} {φ : G →ᴳ H} {ψ : H →ᴳ K} {ξ : K →ᴳ L} (φ-ψ-is-exact : is-exact φ ψ) (ψ-ξ-is-exact : is-exact ψ ξ) where private module G = Group G module H = Group H module K = Group K module L = Group L module φ = GroupHom φ module ψ = GroupHom ψ module ξ = GroupHom ξ module E1 = is-exact φ-ψ-is-exact module E2 = is-exact ψ-ξ-is-exact {- [L] for "lemmas" -} module EL1 = Exact φ-ψ-is-exact module EL2 = Exact ψ-ξ-is-exact abstract G-trivial-and-L-trivial-implies-H-iso-K : is-trivialᴳ G → is-trivialᴳ L → H ≃ᴳ K G-trivial-and-L-trivial-implies-H-iso-K G-is-triv L-is-triv = surjᴳ-and-injᴳ-iso ψ (EL2.K-trivial-implies-φ-is-surj L-is-triv) (EL1.G-trivial-implies-ψ-is-inj G-is-triv) G-trivial-implies-H-iso-ker : is-trivialᴳ G → H ≃ᴳ Ker.grp ξ G-trivial-implies-H-iso-ker G-is-triv = EL2.φ-inj-implies-G-iso-ker $ EL1.G-trivial-implies-ψ-is-inj G-is-triv L-trivial-implies-coker-iso-K : (H-is-abelian : is-abelian H) → is-trivialᴳ L → Coker φ H-is-abelian ≃ᴳ K L-trivial-implies-coker-iso-K H-is-abelian L-is-triv = EL1.ψ-surj-implies-coker-iso-K H-is-abelian $ EL2.K-trivial-implies-φ-is-surj L-is-triv abstract equiv-preserves-exact : ∀ {i₀ i₁ j₀ j₁ l₀ l₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {K₀ : Group l₀} {K₁ : Group l₁} {φ₀ : G₀ →ᴳ H₀} {ψ₀ : H₀ →ᴳ K₀} {φ₁ : G₁ →ᴳ H₁} {ψ₁ : H₁ →ᴳ K₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {ξK : K₀ →ᴳ K₁} → CommSquareᴳ φ₀ φ₁ ξG ξH → CommSquareᴳ ψ₀ ψ₁ ξH ξK → is-equiv (GroupHom.f ξG) → is-equiv (GroupHom.f ξH) → is-equiv (GroupHom.f ξK) → is-exact φ₀ ψ₀ → is-exact φ₁ ψ₁ equiv-preserves-exact {K₀ = K₀} {K₁} {φ₀ = φ₀} {ψ₀} {φ₁} {ψ₁} {ξG} {ξH} {ξK} (comm-sqrᴳ φ□) (comm-sqrᴳ ψ□) ξG-is-equiv ξH-is-equiv ξK-is-equiv exact₀ = record { im-sub-ker = λ h₁ → Trunc-rec (SubgroupProp.level (ker-propᴳ ψ₁) h₁) (λ{(g₁ , φ₁g₁=h₁) → ψ₁.f h₁ =⟨ ap ψ₁.f $ ! $ ξH.f-g h₁ ⟩ ψ₁.f (ξH.f (ξH.g h₁)) =⟨ ! $ ψ□ (ξH.g h₁) ⟩ ξK.f (ψ₀.f (ξH.g h₁)) =⟨ ap ξK.f $ im-sub-ker exact₀ (ξH.g h₁) [ ξG.g g₁ ,_ $ φ₀.f (ξG.g g₁) =⟨ ! (ξH.g-f (φ₀.f (ξG.g g₁))) ⟩ ξH.g (ξH.f (φ₀.f (ξG.g g₁))) =⟨ ap ξH.g $ φ□ (ξG.g g₁) ∙ ap φ₁.f (ξG.f-g g₁) ∙ φ₁g₁=h₁ ⟩ ξH.g h₁ =∎ ] ⟩ ξK.f (Group.ident K₀) =⟨ ξK.pres-ident ⟩ Group.ident K₁ =∎}); ker-sub-im = λ h₁ ψ₁h₁=0 → Trunc-rec (SubgroupProp.level (im-propᴳ φ₁) h₁) (λ{(g₀ , φ₀g₀=ξH⁻¹h₁) → [ ξG.f g₀ ,_ $ φ₁.f (ξG.f g₀) =⟨ ! $ φ□ g₀ ⟩ ξH.f (φ₀.f g₀) =⟨ ap ξH.f φ₀g₀=ξH⁻¹h₁ ⟩ ξH.f (ξH.g h₁) =⟨ ξH.f-g h₁ ⟩ h₁ =∎ ]}) (ker-sub-im exact₀ (ξH.g h₁) $ ψ₀.f (ξH.g h₁) =⟨ ! $ ξK.g-f (ψ₀.f (ξH.g h₁)) ⟩ ξK.g (ξK.f (ψ₀.f (ξH.g h₁))) =⟨ ap ξK.g $ ψ□ (ξH.g h₁) ∙ ap ψ₁.f (ξH.f-g h₁) ∙ ψ₁h₁=0 ⟩ ξK.g (Group.ident K₁) =⟨ GroupHom.pres-ident ξK.g-hom ⟩ Group.ident K₀ =∎)} where module φ₀ = GroupHom φ₀ module φ₁ = GroupHom φ₁ module ψ₀ = GroupHom ψ₀ module ψ₁ = GroupHom ψ₁ module ξG = GroupIso (ξG , ξG-is-equiv) module ξH = GroupIso (ξH , ξH-is-equiv) module ξK = GroupIso (ξK , ξK-is-equiv) abstract equiv-preserves'-exact : ∀ {i₀ i₁ j₀ j₁ l₀ l₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {K₀ : Group l₀} {K₁ : Group l₁} {φ₀ : G₀ →ᴳ H₀} {ψ₀ : H₀ →ᴳ K₀} {φ₁ : G₁ →ᴳ H₁} {ψ₁ : H₁ →ᴳ K₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {ξK : K₀ →ᴳ K₁} → CommSquareᴳ φ₀ φ₁ ξG ξH → CommSquareᴳ ψ₀ ψ₁ ξH ξK → is-equiv (GroupHom.f ξG) → is-equiv (GroupHom.f ξH) → is-equiv (GroupHom.f ξK) → is-exact φ₁ ψ₁ → is-exact φ₀ ψ₀ equiv-preserves'-exact cs₀ cs₁ ξG-ise ξH-ise ξK-ise ex = equiv-preserves-exact (CommSquareᴳ-inverse-v cs₀ ξG-ise ξH-ise) (CommSquareᴳ-inverse-v cs₁ ξH-ise ξK-ise) (is-equiv-inverse ξG-ise) (is-equiv-inverse ξH-ise) (is-equiv-inverse ξK-ise) ex
{ "alphanum_fraction": 0.4979247645, "avg_line_length": 38.3308080808, "ext": "agda", "hexsha": "558abb4ef50786441ec8acdcde8d356ddaecc833", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/groups/Exactness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/groups/Exactness.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/groups/Exactness.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6423, "size": 15179 }
module Extensions.VecFirst where open import Data.Vec open import Data.Product open import Level open import Relation.Nullary open import Function using (_∘_; _$_) -- proof that an element is the first in a vector to satisfy the predicate B data First {a b} {A : Set a} (B : A → Set b) : ∀ {n} (x : A) → Vec A n → Set (a ⊔ b) where here : ∀ {n} {x : A} → (p : B x) → (v : Vec A n) → First B x (x ∷ v) there : ∀ {n x} {v : Vec A n} (x' : A) → ¬ (B x') → First B x v → First B x (x' ∷ v) -- more likable syntax for the above structure first_∈_⇔_ : ∀ {n} {A : Set} → A → Vec A n → (B : A → Set) → Set first_∈_⇔_ x v p = First p x v -- a decision procedure to find the first element in a vector that satisfies a predicate find : ∀ {n} {A : Set} (P : A → Set) → ((a : A) → Dec (P a)) → (v : Vec A n) → Dec (∃ λ e → first e ∈ v ⇔ P) find P dec [] = no (λ{ (e , ()) }) find P dec (x ∷ v) with dec x find P dec (x ∷ v) | yes px = yes (x , here px v) find P dec (x ∷ v) | no ¬px with find P dec v find P dec (x ∷ v) | no ¬px | yes firstv = yes (, there x ¬px (proj₂ firstv)) find P dec (x ∷ v) | no ¬px | no ¬firstv = no $ helper ¬px ¬firstv where helper : ¬ (P x) → ¬ (∃ λ e → First P e v) → ¬ (∃ λ e → First P e (x ∷ v)) helper ¬px ¬firstv (.x , here p .v) = ¬px p helper ¬px ¬firstv (u , there ._ _ firstv) = ¬firstv (u , firstv)
{ "alphanum_fraction": 0.5530191458, "avg_line_length": 42.4375, "ext": "agda", "hexsha": "36b25545000f38577fb2afaccd7fcb988b4be313", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Extensions/VecFirst.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Extensions/VecFirst.agda", "max_line_length": 90, "max_stars_count": 10, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Extensions/VecFirst.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 529, "size": 1358 }
{-# OPTIONS --without-K #-} module function.core where open import level -- copied from Agda's standard library infixr 9 _∘'_ infixr 0 _$_ _∘'_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) f ∘' g = λ x → f (g x) const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A const x = λ _ → x _$_ : ∀ {a b} {A : Set a} {B : A → Set b} → ((x : A) → B x) → ((x : A) → B x) f $ x = f x flip : ∀ {a b c} {A : Set a} {B : Set b} {C : A → B → Set c} → ((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y) flip f = λ y x → f x y record Composition u₁ u₂ u₃ u₁₂ u₂₃ u₁₃ : Set (lsuc (u₁ ⊔ u₂ ⊔ u₃ ⊔ u₁₂ ⊔ u₂₃ ⊔ u₁₃)) where infixl 9 _∘_ field U₁ : Set u₁ U₂ : Set u₂ U₃ : Set u₃ hom₁₂ : U₁ → U₂ → Set u₁₂ hom₂₃ : U₂ → U₃ → Set u₂₃ hom₁₃ : U₁ → U₃ → Set u₁₃ _∘_ : {X₁ : U₁}{X₂ : U₂}{X₃ : U₃} → hom₂₃ X₂ X₃ → hom₁₂ X₁ X₂ → hom₁₃ X₁ X₃ record Identity u e : Set (lsuc (u ⊔ e)) where field U : Set u endo : U → Set e id : {X : U} → endo X id- : (X : U) → endo X id- X = id {X} instance func-comp : ∀ {i j k} → Composition _ _ _ _ _ _ func-comp {i}{j}{k} = record { U₁ = Set i ; U₂ = Set j ; U₃ = Set k ; hom₁₂ = λ X Y → X → Y ; hom₂₃ = λ X Y → X → Y ; hom₁₃ = λ X Y → X → Y ; _∘_ = λ f g x → f (g x) } instance func-id : ∀ {i} → Identity _ _ func-id {i} = record { U = Set i ; endo = λ X → X → X ; id = λ x → x } module ComposeInterface {u₁ u₂ u₃ u₁₂ u₂₃ u₁₃} ⦃ comp : Composition u₁ u₂ u₃ u₁₂ u₂₃ u₁₃ ⦄ where open Composition comp public using (_∘_) open ComposeInterface public module IdentityInterface {i e} ⦃ identity : Identity i e ⦄ where open Identity identity public using (id; id-) open IdentityInterface public
{ "alphanum_fraction": 0.4815400844, "avg_line_length": 24.3076923077, "ext": "agda", "hexsha": "7c408990c513508b5a2c8e20bfd635852ab2ab0a", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/function/core.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/function/core.agda", "max_line_length": 79, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "function/core.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 858, "size": 1896 }
module _ where record Semiring (A : Set) : Set where infixl 6 _+_ field _+_ : A → A → A open Semiring {{...}} public infix 4 _≡_ postulate Ord : Set → Set Nat Bool : Set zero : Nat _≡_ : Nat → Nat → Set refl : ∀ {x} → x ≡ x to : ∀ {x} y → x ≡ y trans : {x y z : Nat} → x ≡ y → y ≡ z → x ≡ z instance ringNat′ : Semiring Nat _+N_ : Nat → Nat → Nat instance ringNat : Semiring Nat ringNat ._+_ = _+N_ bad : (a b c : Nat) → a +N b ≡ c +N a bad a b c = trans (to (a + c)) refl -- Should list the errors from testing both ringNat and ringNat′
{ "alphanum_fraction": 0.5442176871, "avg_line_length": 16.8, "ext": "agda", "hexsha": "89e68fa5e4fa025d68967ff8ee3c2ac0dcc6e8a2", "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/InstanceErrorMessageMultiple.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/InstanceErrorMessageMultiple.agda", "max_line_length": 64, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/InstanceErrorMessageMultiple.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": 239, "size": 588 }
module Itse.Checking where open import Itse.Grammar open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Data.Unit open import Data.Bool open import Data.List hiding (lookup) open import Data.Product open import Data.Maybe {- # Checking -} {- ## Context -} data Context : Set Closure : Set infixr 6 _⦂_,_ [_],_ data Context where ∅ : Context _⦂_,_ : ∀ {e} → Name e → Expr (TypeOf e) → Context → Context [_],_ : Closure → Context → Context {- ## Closure -} Closure = List (∃[ e ] (Name e × Expr e × Expr (TypeOf e))) lookup-μ : ∀ {e} → Name e → Closure → Maybe (Expr e × Expr (TypeOf e)) lookup-μ {p} ξ [] = nothing lookup-μ {p} ξ ((p , υ , α , A) ∷ μ) with ξ ≟-Name υ lookup-μ {p} ξ ((p , υ , α , A) ∷ μ) | yes refl = just (α , A) lookup-μ {p} ξ ((p , υ , α , A) ∷ μ) | no _ = lookup-μ ξ μ lookup-μ {p} ξ ((t , _) ∷ μ) = lookup-μ ξ μ lookup-μ {t} x [] = nothing lookup-μ {t} x ((p , _) ∷ μ) = lookup-μ x μ lookup-μ {t} x ((t , y , a , α) ∷ μ) with x ≟-Name y lookup-μ {t} x ((t , y , a , α) ∷ μ) | yes refl = just (a , α) lookup-μ {t} x ((t , y , a , α) ∷ μ) | no _ = lookup-μ x μ lookup : ∀ {e} → Name e → Context → Maybe (Expr e × Expr (TypeOf e)) lookup x ∅ = nothing lookup x (_ ⦂ _ , Γ) = lookup x Γ lookup x ([ μ ], Γ) = lookup-μ x μ {- ## Substitution -} infix 6 ⟦_↦_⟧_ ⟦_↦_⟧_ : ∀ {e e′} → Name e → Expr e → Expr e′ → Expr e′ ⟦_↦_⟧_ = {!!} {- ## Wellformed-ness -} infix 5 _⊢wf _⊢_ok _⊢_⦂_ data _⊢wf : Context → Set data _⊢_ok : Context → Closure → Set data _⊢_⦂_ : ∀ {e} → Context → Expr e → Expr (TypeOf e) → Set data _⊢wf where ∅⊢wf : ∅ ⊢wf judgeₚ : ∀ {Γ} {X : Kind} {ξ} → Γ ⊢wf → Γ ⊢ X ⦂ `□ₛ → ---- ξ ⦂ X , Γ ⊢wf judgeₜ : ∀ {Γ} {ξ : Type} {x : Nameₜ} → Γ ⊢wf → Γ ⊢ ξ ⦂ `●ₖ → ---- x ⦂ ξ , Γ ⊢wf closure : ∀ {Γ} {μ} → Γ ⊢wf → Γ ⊢ μ ok → [ μ ], Γ ⊢wf -- Closure = List (∃[ e ] ∃[ e≢k ] (Name e × Expr e × Expr (TypeOf e {e≢k}))) data _⊢_ok where -- type : -- Γ ⊢ μ ok → -- [ μ ], Γ ⊢ data _⊢_⦂_ where -- sorting (well-formed kinds) ●ₖ : ∀ {Γ} → Γ ⊢ `●ₖ ⦂ `□ₛ λₖₚ-intro : ∀ {Γ} {ξ} {X A} → ξ ⦂ X , Γ ⊢ A ⦂ `□ₛ → Γ ⊢ X ⦂ `□ₛ → ---- Γ ⊢ `λₖₚ[ ξ ⦂ X ] A ⦂ `□ₛ λₖₜ-intro : ∀ {Γ} {ξ} {A} {x} → x ⦂ ξ , Γ ⊢ A ⦂ `□ₛ → Γ ⊢ ξ ⦂ `●ₖ → ---- Γ ⊢ `λₖₜ[ x ⦂ ξ ] A ⦂ `□ₛ -- kinding λₚₚ-intro : ∀ {Γ} {X} {β} {ξ} → Γ ⊢ X ⦂ `□ₛ → ξ ⦂ X , Γ ⊢ β ⦂ `●ₖ → ---- Γ ⊢ `λₚₚ[ ξ ⦂ X ] β ⦂ `λₖₚ[ ξ ⦂ X ] `●ₖ λₚₜ-intro : ∀ {Γ} {ξ} {β} {x} → Γ ⊢ ξ ⦂ `●ₖ → x ⦂ ξ , Γ ⊢ β ⦂ `●ₖ → ---- Γ ⊢ `λₚₜ[ x ⦂ ξ ] β ⦂ `λₖₜ[ x ⦂ ξ ] `●ₖ λₚₚ-elim : ∀ {Γ} {A B} {ξ φ α} → Γ ⊢ φ ⦂ `λₖₚ[ ξ ⦂ A ] B → Γ ⊢ α ⦂ A → ---- Γ ⊢ φ `∙ₚₚ α ⦂ B λₚₜ-elim : ∀ {Γ} {B} {φ α} {a} {x} → Γ ⊢ φ ⦂ `λₖₜ[ x ⦂ α ] B → Γ ⊢ a ⦂ α → ---- Γ ⊢ φ `∙ₚₜ a ⦂ B -- typing λₜₚ-intro : ∀ {Γ} {X} {α} {a} {ξ} → Γ ⊢ X ⦂ `□ₛ → ξ ⦂ X , Γ ⊢ a ⦂ α → ---- Γ ⊢ `λₜₚ[ ξ ⦂ X ] a ⦂ `λₚₚ[ ξ ⦂ X ] α λₜₜ-intro : ∀ {Γ} {α ξ} {a} {x} → Γ ⊢ α ⦂ `●ₖ → x ⦂ ξ , Γ ⊢ a ⦂ α → ---- Γ ⊢ `λₜₜ[ x ⦂ ξ ] a ⦂ `λₚₜ[ x ⦂ ξ ] α λₜₚ-elim : ∀ {Γ} {A} {α β} {f} {ξ} → Γ ⊢ f ⦂ `λₚₚ[ ξ ⦂ A ] β → Γ ⊢ α ⦂ A → ---- Γ ⊢ f `∙ₜₚ α ⦂ β λₜₜ-elim : ∀ {Γ} {α β} {f a x} → Γ ⊢ f ⦂ `λₚₜ[ x ⦂ α ] β → Γ ⊢ a ⦂ α → ---- Γ ⊢ f `∙ₜₜ a ⦂ β -- "SelfGen" ι-intro : ∀ {Γ} {α} {a} {x} → Γ ⊢ a ⦂ ⟦ x ↦ a ⟧ α → Γ ⊢ `ι[ x ] α ⦂ `●ₖ → ---- Γ ⊢ a ⦂ `ι[ x ] α -- "SelfInst" ι-elim : ∀ {Γ} {α} {a} {x} → Γ ⊢ a ⦂ `ι[ x ] α → ---- Γ ⊢ a ⦂ ⟦ x ↦ a ⟧ α
{ "alphanum_fraction": 0.4005975014, "avg_line_length": 19.0777202073, "ext": "agda", "hexsha": "d170ddc7711bdb7bae18410019e46be789402e20", "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": "4ee714b707b72e4ed8373c49ee739d576aafb70a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Riib11/itse", "max_forks_repo_path": "agda/Itse/Checking.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4ee714b707b72e4ed8373c49ee739d576aafb70a", "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": "Riib11/itse", "max_issues_repo_path": "agda/Itse/Checking.agda", "max_line_length": 77, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4ee714b707b72e4ed8373c49ee739d576aafb70a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "Riib11/itse", "max_stars_repo_path": "agda/Itse/Checking.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-14T15:09:19.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-14T15:09:19.000Z", "num_tokens": 2005, "size": 3682 }
-- Andreas, 2016-01-22, issue 1790 -- Projections should be highlighted as such everywhere, -- even in the parts of a record declaration that -- make the record constructor type. record Σ A (B : A → Set) : Set where field fst : A snd : B fst -- fst should be highlighted as projection here -- Should also work under 'mutual'. mutual record IOInterface : Set₁ where constructor ioInterface field Command : Set Response : (m : Command) → Set
{ "alphanum_fraction": 0.6735966736, "avg_line_length": 26.7222222222, "ext": "agda", "hexsha": "588b6b85031bd33f53ff1cacbc50a275e9f2805a", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/interaction/Issue1790.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/interaction/Issue1790.agda", "max_line_length": 64, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/interaction/Issue1790.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": 130, "size": 481 }
{-# OPTIONS --cubical --safe #-} module Data.Tuple.Base where open import Prelude hiding (⊤; tt) open import Data.Unit.UniversePolymorphic open import Data.Fin Tuple : ∀ n → (Lift a (Fin n) → Type b) → Type b Tuple zero f = ⊤ Tuple {a = a} {b = b} (suc n) f = f (lift f0) × Tuple {a = a} {b = b} n (f ∘ lift ∘ fs ∘ lower) private variable n : ℕ u : Level U : Lift a (Fin n) → Type u ind : Tuple n U → (i : Lift a (Fin n)) → U i ind {n = suc n} (x , xs) (lift f0) = x ind {n = suc n} (x , xs) (lift (fs i)) = ind xs (lift i) tab : ((i : Lift a (Fin n)) → U i) → Tuple n U tab {n = zero} f = tt tab {n = suc n} f = f (lift f0) , tab (f ∘ lift ∘ fs ∘ lower) Π→Tuple→Π : ∀ {a n u} {U : Lift a (Fin n) → Type u} (xs : (i : Lift a (Fin n)) → U i) i → ind (tab xs) i ≡ xs i Π→Tuple→Π {n = suc n} f (lift f0) = refl Π→Tuple→Π {n = suc n} f (lift (fs i)) = Π→Tuple→Π (f ∘ lift ∘ fs ∘ lower) (lift i) Tuple→Π→Tuple : ∀ {n} {U : Lift a (Fin n) → Type u} (xs : Tuple n U) → tab (ind xs) ≡ xs Tuple→Π→Tuple {n = zero} tt = refl Tuple→Π→Tuple {n = suc n} (x , xs) i .fst = x Tuple→Π→Tuple {n = suc n} (x , xs) i .snd = Tuple→Π→Tuple xs i Tuple⇔ΠFin : ∀ {a n u} {U : Lift a (Fin n) → Type u} → Tuple n U ⇔ ((i : Lift a (Fin n)) → U i) Tuple⇔ΠFin .fun = ind Tuple⇔ΠFin .inv = tab Tuple⇔ΠFin .leftInv = Tuple→Π→Tuple Tuple⇔ΠFin .rightInv x = funExt (Π→Tuple→Π x)
{ "alphanum_fraction": 0.5461147422, "avg_line_length": 33.5853658537, "ext": "agda", "hexsha": "2a0c40c01b5927fe197c91ce7c4b5d8f64e31fff", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/Tuple/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/Tuple/Base.agda", "max_line_length": 111, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/Tuple/Base.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": 617, "size": 1377 }
import Issue2217.M {-# TERMINATING #-} A : Set A = ? a : A a = ?
{ "alphanum_fraction": 0.5147058824, "avg_line_length": 6.8, "ext": "agda", "hexsha": "291dd527628222354ea640ca14db31e1e3e84717", "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/Issue2217.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/Issue2217.agda", "max_line_length": 19, "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/Issue2217.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": 24, "size": 68 }
{-# OPTIONS --without-K #-} open import HoTT module cohomology.WithCoefficients where →Ω-group-structure : ∀ {i j} (X : Ptd i) (Y : Ptd j) → GroupStructure (fst (X ⊙→ ⊙Ω Y)) →Ω-group-structure X Y = record { ident = ⊙cst; inv = λ F → ((! ∘ fst F) , ap ! (snd F)); comp = λ F G → ⊙conc ⊙∘ ⊙×-in F G; unitl = λ G → pair= idp (unitl-lemma (snd G)); unitr = λ F → ⊙λ= (∙-unit-r ∘ fst F) (unitr-lemma (snd F)); assoc = λ F G H → ⊙λ= (λ x → ∙-assoc (fst F x) (fst G x) (fst H x)) (assoc-lemma (snd F) (snd G) (snd H)); invl = λ F → ⊙λ= (!-inv-l ∘ fst F) (invl-lemma (snd F)); invr = λ F → ⊙λ= (!-inv-r ∘ fst F) (invr-lemma (snd F))} where unitl-lemma : ∀ {i} {A : Type i} {x : A} {p : x == x} (α : p == idp) → ap (uncurry _∙_) (ap2 _,_ idp α) ∙ idp == α unitl-lemma idp = idp unitr-lemma : ∀ {i} {A : Type i} {x : A} {p : x == x} (α : p == idp) → ap (uncurry _∙_) (ap2 _,_ α idp) ∙ idp == ∙-unit-r p ∙ α unitr-lemma idp = idp assoc-lemma : ∀ {i} {A : Type i} {x : A} {p q r : x == x} (α : p == idp) (β : q == idp) (γ : r == idp) → ap (uncurry _∙_) (ap2 _,_ (ap (uncurry _∙_) (ap2 _,_ α β) ∙ idp) γ) ∙ idp == ∙-assoc p q r ∙ ap (uncurry _∙_) (ap2 _,_ α (ap (uncurry _∙_) (ap2 _,_ β γ) ∙ idp)) ∙ idp assoc-lemma idp idp idp = idp invl-lemma : ∀ {i} {A : Type i} {x : A} {p : x == x} (α : p == idp) → ap (uncurry _∙_) (ap2 _,_ (ap ! α) α) ∙ idp == !-inv-l p ∙ idp invl-lemma idp = idp invr-lemma : ∀ {i} {A : Type i} {x : A} {p : x == x} (α : p == idp) → ap (uncurry _∙_) (ap2 _,_ α (ap ! α)) ∙ idp == !-inv-r p ∙ idp invr-lemma idp = idp →Ω-group : ∀ {i j} (X : Ptd i) (Y : Ptd j) → Group (lmax i j) →Ω-group X Y = Trunc-group (→Ω-group-structure X Y) {- →Ω-group is functorial in the first argument -} →Ω-group-dom-act : ∀ {i j k} {X : Ptd i} {Y : Ptd j} (f : fst (X ⊙→ Y)) (Z : Ptd k) → (→Ω-group Y Z →ᴳ →Ω-group X Z) →Ω-group-dom-act {Y = Y} f Z = Trunc-group-hom (λ g → g ⊙∘ f) (λ g₁ g₂ → ⊙∘-assoc ⊙conc (⊙×-in g₁ g₂) f ∙ ap (λ w → ⊙conc ⊙∘ w) (⊙×-in-pre∘ g₁ g₂ f)) →Ω-group-dom-idf : ∀ {i j} {X : Ptd i} (Y : Ptd j) → →Ω-group-dom-act (⊙idf X) Y == idhom (→Ω-group X Y) →Ω-group-dom-idf Y = hom= _ _ $ λ= $ Trunc-elim (λ _ → =-preserves-level _ Trunc-level) (λ _ → idp) →Ω-group-dom-∘ : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y)) (W : Ptd l) → →Ω-group-dom-act (g ⊙∘ f) W == →Ω-group-dom-act f W ∘ᴳ →Ω-group-dom-act g W →Ω-group-dom-∘ g f W = hom= _ _ $ λ= $ Trunc-elim (λ _ → =-preserves-level _ Trunc-level) (λ h → ap [_] (! (⊙∘-assoc h g f))) {- Pointed maps out of bool -} Bool⊙→-out : ∀ {i} {X : Ptd i} → fst (⊙Lift {j = i} ⊙Bool ⊙→ X) → fst X Bool⊙→-out (h , _) = h (lift false) Bool⊙→-equiv : ∀ {i} (X : Ptd i) → fst (⊙Lift {j = i} ⊙Bool ⊙→ X) ≃ fst X Bool⊙→-equiv {i} X = equiv Bool⊙→-out g f-g g-f where g : fst X → fst (⊙Lift {j = i} ⊙Bool ⊙→ X) g x = ((λ {(lift b) → if b then snd X else x}) , idp) f-g : ∀ x → Bool⊙→-out (g x) == x f-g x = idp g-f : ∀ H → g (Bool⊙→-out H) == H g-f (h , hpt) = pair= (λ= lemma) (↓-app=cst-in $ idp =⟨ ! (!-inv-l hpt) ⟩ ! hpt ∙ hpt =⟨ ! (app=-β lemma (lift true)) |in-ctx (λ w → w ∙ hpt) ⟩ app= (λ= lemma) (lift true) ∙ hpt ∎) where lemma : ∀ b → fst (g (h (lift false))) b == h b lemma (lift true) = ! hpt lemma (lift false) = idp abstract Bool⊙→-path : ∀ {i} (X : Ptd i) → fst (⊙Lift {j = i} ⊙Bool ⊙→ X) == fst X Bool⊙→-path X = ua (Bool⊙→-equiv X) abstract Bool⊙→Ω-is-π₁ : ∀ {i} (X : Ptd i) → →Ω-group (⊙Lift {j = i} ⊙Bool) X == πS 0 X Bool⊙→Ω-is-π₁ {i} X = group-ua $ Trunc-group-iso Bool⊙→-out (λ _ _ → idp) (snd (Bool⊙→-equiv (⊙Ω X)))
{ "alphanum_fraction": 0.4777660138, "avg_line_length": 34.6605504587, "ext": "agda", "hexsha": "34ca481895438ecb71664b4a5356906950fd4882", "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/WithCoefficients.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/WithCoefficients.agda", "max_line_length": 84, "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/WithCoefficients.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1850, "size": 3778 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Support for reflection ------------------------------------------------------------------------ {-# OPTIONS --with-K #-} module Reflection where open import Data.Unit.Base using (⊤) open import Data.Bool.Base using (Bool; false; true) open import Data.List.Base using (List); open Data.List.Base.List open import Data.Nat using (ℕ) renaming (_≟_ to _≟-ℕ_) open import Data.Nat.Show renaming (show to showNat) open import Data.Float using (Float) renaming (show to showFloat) open import Data.Float.Unsafe using () renaming (_≟_ to _≟f_) open import Data.Char using (Char) renaming ( show to showChar ; _≟_ to _≟c_ ) open import Data.String using (String) renaming ( show to showString ; _≟_ to _≟s_ ) open import Data.Word using (Word64) renaming (toℕ to wordToℕ) open import Data.Word.Unsafe using () renaming (_≟_ to _≟w_) open import Data.Product open import Function open import Level open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Relation.Binary.PropositionalEquality.TrustMe open import Relation.Nullary hiding (module Dec) open import Relation.Nullary.Decidable as Dec open import Relation.Nullary.Product import Agda.Builtin.Reflection as Builtin ------------------------------------------------------------------------ -- Names -- Names. open Builtin public using (Name) -- Equality of names is decidable. infix 4 _==_ _≟-Name_ private _==_ : Name → Name → Bool _==_ = Builtin.primQNameEquality _≟-Name_ : Decidable {A = Name} _≡_ s₁ ≟-Name s₂ with s₁ == s₂ ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ -- Names can be shown. showName : Name → String showName = Builtin.primShowQName ------------------------------------------------------------------------ -- Metavariables -- Metavariables. open Builtin public using (Meta) -- Equality of metavariables is decidable. infix 4 _==-Meta_ _≟-Meta_ private _==-Meta_ : Meta → Meta → Bool _==-Meta_ = Builtin.primMetaEquality _≟-Meta_ : Decidable {A = Meta} _≡_ s₁ ≟-Meta s₂ with s₁ ==-Meta s₂ ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ -- Metas can be shown. showMeta : Meta → String showMeta = Builtin.primShowMeta ------------------------------------------------------------------------ -- Terms -- Is the argument visible (explicit), hidden (implicit), or an -- instance argument? open Builtin public using (Visibility; visible; hidden; instance′) -- Arguments can be relevant or irrelevant. open Builtin public using (Relevance; relevant; irrelevant) -- Arguments. open Builtin public renaming ( ArgInfo to Arg-info ) using ( arg-info ) visibility : Arg-info → Visibility visibility (arg-info v _) = v relevance : Arg-info → Relevance relevance (arg-info _ r) = r open Builtin public using (Arg; arg) open Builtin public using (Abs; abs) -- Literals. open Builtin public using (Literal; nat; word64; float; char; string; name; meta) -- Patterns. open Builtin public using (Pattern; con; dot; var; lit; proj; absurd) -- Terms. open Builtin public using ( Type; Term; var; con; def; lam; pat-lam; pi; lit; meta; unknown ; Sort; set ; Clause; clause; absurd-clause ) renaming ( agda-sort to sort ) Clauses = List Clause ------------------------------------------------------------------------ -- Definitions open Builtin public using ( Definition ; function ; data-type ; axiom ) renaming ( record-type to record′ ; data-cons to constructor′ ; prim-fun to primitive′ ) showLiteral : Literal → String showLiteral (nat x) = showNat x showLiteral (word64 x) = showNat (wordToℕ x) showLiteral (float x) = showFloat x showLiteral (char x) = showChar x showLiteral (string x) = showString x showLiteral (name x) = showName x showLiteral (meta x) = showMeta x ------------------------------------------------------------------------ -- Type checking monad -- Type errors open Builtin public using (ErrorPart; strErr; termErr; nameErr) -- The monad open Builtin public using ( TC; returnTC; bindTC; unify; typeError; inferType; checkType ; normalise; catchTC; getContext; extendContext; inContext ; freshName; declareDef; defineFun; getType; getDefinition ; blockOnMeta; quoteTC; unquoteTC ) newMeta : Type → TC Term newMeta = checkType unknown ------------------------------------------------------------------------ -- Term equality is decidable -- Boring helper functions. private cong₂′ : ∀ {a b c : Level} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) {x y u v} → x ≡ y × u ≡ v → f x u ≡ f y v cong₂′ f = uncurry (cong₂ f) cong₃′ : ∀ {a b c d : Level} {A : Set a} {B : Set b} {C : Set c} {D : Set d} (f : A → B → C → D) {x y u v r s} → x ≡ y × u ≡ v × r ≡ s → f x u r ≡ f y v s cong₃′ f (refl , refl , refl) = refl arg₁ : ∀ {A i i′} {x x′ : A} → arg i x ≡ arg i′ x′ → i ≡ i′ arg₁ refl = refl arg₂ : ∀ {A i i′} {x x′ : A} → arg i x ≡ arg i′ x′ → x ≡ x′ arg₂ refl = refl abs₁ : ∀ {A i i′} {x x′ : A} → abs i x ≡ abs i′ x′ → i ≡ i′ abs₁ refl = refl abs₂ : ∀ {A i i′} {x x′ : A} → abs i x ≡ abs i′ x′ → x ≡ x′ abs₂ refl = refl arg-info₁ : ∀ {v v′ r r′} → arg-info v r ≡ arg-info v′ r′ → v ≡ v′ arg-info₁ refl = refl arg-info₂ : ∀ {v v′ r r′} → arg-info v r ≡ arg-info v′ r′ → r ≡ r′ arg-info₂ refl = refl cons₁ : ∀ {a} {A : Set a} {x y} {xs ys : List A} → x ∷ xs ≡ y ∷ ys → x ≡ y cons₁ refl = refl cons₂ : ∀ {a} {A : Set a} {x y} {xs ys : List A} → x ∷ xs ≡ y ∷ ys → xs ≡ ys cons₂ refl = refl var₁ : ∀ {x x′ args args′} → Term.var x args ≡ var x′ args′ → x ≡ x′ var₁ refl = refl var₂ : ∀ {x x′ args args′} → Term.var x args ≡ var x′ args′ → args ≡ args′ var₂ refl = refl con₁ : ∀ {c c′ args args′} → Term.con c args ≡ con c′ args′ → c ≡ c′ con₁ refl = refl con₂ : ∀ {c c′ args args′} → Term.con c args ≡ con c′ args′ → args ≡ args′ con₂ refl = refl def₁ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → f ≡ f′ def₁ refl = refl def₂ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → args ≡ args′ def₂ refl = refl meta₁ : ∀ {x x′ args args′} → Term.meta x args ≡ meta x′ args′ → x ≡ x′ meta₁ refl = refl meta₂ : ∀ {x x′ args args′} → Term.meta x args ≡ meta x′ args′ → args ≡ args′ meta₂ refl = refl lam₁ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → v ≡ v′ lam₁ refl = refl lam₂ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → t ≡ t′ lam₂ refl = refl pat-lam₁ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → cs ≡ cs′ pat-lam₁ refl = refl pat-lam₂ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → args ≡ args′ pat-lam₂ refl = refl pi₁ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₁ ≡ t₁′ pi₁ refl = refl pi₂ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₂ ≡ t₂′ pi₂ refl = refl sort₁ : ∀ {x y} → sort x ≡ sort y → x ≡ y sort₁ refl = refl lit₁ : ∀ {x y} → Term.lit x ≡ lit y → x ≡ y lit₁ refl = refl pcon₁ : ∀ {c c′ args args′} → Pattern.con c args ≡ con c′ args′ → c ≡ c′ pcon₁ refl = refl pcon₂ : ∀ {c c′ args args′} → Pattern.con c args ≡ con c′ args′ → args ≡ args′ pcon₂ refl = refl pvar : ∀ {x y} → Pattern.var x ≡ var y → x ≡ y pvar refl = refl plit₁ : ∀ {x y} → Pattern.lit x ≡ lit y → x ≡ y plit₁ refl = refl pproj₁ : ∀ {x y} → proj x ≡ proj y → x ≡ y pproj₁ refl = refl set₁ : ∀ {x y} → set x ≡ set y → x ≡ y set₁ refl = refl slit₁ : ∀ {x y} → Sort.lit x ≡ lit y → x ≡ y slit₁ refl = refl nat₁ : ∀ {x y} → nat x ≡ nat y → x ≡ y nat₁ refl = refl word64₁ : ∀ {x y} → word64 x ≡ word64 y → x ≡ y word64₁ refl = refl float₁ : ∀ {x y} → float x ≡ float y → x ≡ y float₁ refl = refl char₁ : ∀ {x y} → char x ≡ char y → x ≡ y char₁ refl = refl string₁ : ∀ {x y} → string x ≡ string y → x ≡ y string₁ refl = refl name₁ : ∀ {x y} → name x ≡ name y → x ≡ y name₁ refl = refl lmeta₁ : ∀ {x y} → Literal.meta x ≡ meta y → x ≡ y lmeta₁ refl = refl clause₁ : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → ps ≡ ps′ clause₁ refl = refl clause₂ : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → b ≡ b′ clause₂ refl = refl absurd-clause₁ : ∀ {ps ps′} → absurd-clause ps ≡ absurd-clause ps′ → ps ≡ ps′ absurd-clause₁ refl = refl infix 4 _≟-Visibility_ _≟-Relevance_ _≟-Arg-info_ _≟-Lit_ _≟-AbsTerm_ _≟-AbsType_ _≟-ArgTerm_ _≟-ArgType_ _≟-ArgPattern_ _≟-Args_ _≟-Clause_ _≟-Clauses_ _≟-Pattern_ _≟-ArgPatterns_ _≟_ _≟-Sort_ _≟-Visibility_ : Decidable (_≡_ {A = Visibility}) visible ≟-Visibility visible = yes refl hidden ≟-Visibility hidden = yes refl instance′ ≟-Visibility instance′ = yes refl visible ≟-Visibility hidden = no λ() visible ≟-Visibility instance′ = no λ() hidden ≟-Visibility visible = no λ() hidden ≟-Visibility instance′ = no λ() instance′ ≟-Visibility visible = no λ() instance′ ≟-Visibility hidden = no λ() _≟-Relevance_ : Decidable (_≡_ {A = Relevance}) relevant ≟-Relevance relevant = yes refl irrelevant ≟-Relevance irrelevant = yes refl relevant ≟-Relevance irrelevant = no λ() irrelevant ≟-Relevance relevant = no λ() _≟-Arg-info_ : Decidable (_≡_ {A = Arg-info}) arg-info v r ≟-Arg-info arg-info v′ r′ = Dec.map′ (cong₂′ arg-info) < arg-info₁ , arg-info₂ > (v ≟-Visibility v′ ×-dec r ≟-Relevance r′) _≟-Lit_ : Decidable (_≡_ {A = Literal}) nat x ≟-Lit nat x₁ = Dec.map′ (cong nat) nat₁ (x ≟-ℕ x₁) nat x ≟-Lit word64 x₁ = no (λ ()) nat x ≟-Lit float x₁ = no (λ ()) nat x ≟-Lit char x₁ = no (λ ()) nat x ≟-Lit string x₁ = no (λ ()) nat x ≟-Lit name x₁ = no (λ ()) nat x ≟-Lit meta x₁ = no (λ ()) word64 x ≟-Lit word64 x₁ = Dec.map′ (cong word64) word64₁ (x ≟w x₁) word64 x ≟-Lit nat x₁ = no (λ ()) word64 x ≟-Lit float x₁ = no (λ ()) word64 x ≟-Lit char x₁ = no (λ ()) word64 x ≟-Lit string x₁ = no (λ ()) word64 x ≟-Lit name x₁ = no (λ ()) word64 x ≟-Lit meta x₁ = no (λ ()) float x ≟-Lit nat x₁ = no (λ ()) float x ≟-Lit word64 x₁ = no (λ ()) float x ≟-Lit float x₁ = Dec.map′ (cong float) float₁ (x ≟f x₁) float x ≟-Lit char x₁ = no (λ ()) float x ≟-Lit string x₁ = no (λ ()) float x ≟-Lit name x₁ = no (λ ()) float x ≟-Lit meta x₁ = no (λ ()) char x ≟-Lit nat x₁ = no (λ ()) char x ≟-Lit word64 x₁ = no (λ ()) char x ≟-Lit float x₁ = no (λ ()) char x ≟-Lit char x₁ = Dec.map′ (cong char) char₁ (x ≟c x₁) char x ≟-Lit string x₁ = no (λ ()) char x ≟-Lit name x₁ = no (λ ()) char x ≟-Lit meta x₁ = no (λ ()) string x ≟-Lit nat x₁ = no (λ ()) string x ≟-Lit word64 x₁ = no (λ ()) string x ≟-Lit float x₁ = no (λ ()) string x ≟-Lit char x₁ = no (λ ()) string x ≟-Lit string x₁ = Dec.map′ (cong string) string₁ (x ≟s x₁) string x ≟-Lit name x₁ = no (λ ()) string x ≟-Lit meta x₁ = no (λ ()) name x ≟-Lit nat x₁ = no (λ ()) name x ≟-Lit word64 x₁ = no (λ ()) name x ≟-Lit float x₁ = no (λ ()) name x ≟-Lit char x₁ = no (λ ()) name x ≟-Lit string x₁ = no (λ ()) name x ≟-Lit name x₁ = Dec.map′ (cong name) name₁ (x ≟-Name x₁) name x ≟-Lit meta x₁ = no (λ ()) meta x ≟-Lit nat x₁ = no (λ ()) meta x ≟-Lit word64 x₁ = no (λ ()) meta x ≟-Lit float x₁ = no (λ ()) meta x ≟-Lit char x₁ = no (λ ()) meta x ≟-Lit string x₁ = no (λ ()) meta x ≟-Lit name x₁ = no (λ ()) meta x ≟-Lit meta x₁ = Dec.map′ (cong meta) lmeta₁ (x ≟-Meta x₁) mutual _≟-AbsTerm_ : Decidable (_≡_ {A = Abs Term}) abs s a ≟-AbsTerm abs s′ a′ = Dec.map′ (cong₂′ abs) < abs₁ , abs₂ > (s ≟s s′ ×-dec a ≟ a′) _≟-AbsType_ : Decidable (_≡_ {A = Abs Type}) abs s a ≟-AbsType abs s′ a′ = Dec.map′ (cong₂′ abs) < abs₁ , abs₂ > (s ≟s s′ ×-dec a ≟ a′) _≟-ArgTerm_ : Decidable (_≡_ {A = Arg Term}) arg i a ≟-ArgTerm arg i′ a′ = Dec.map′ (cong₂′ arg) < arg₁ , arg₂ > (i ≟-Arg-info i′ ×-dec a ≟ a′) _≟-ArgType_ : Decidable (_≡_ {A = Arg Type}) arg i a ≟-ArgType arg i′ a′ = Dec.map′ (cong₂′ arg) < arg₁ , arg₂ > (i ≟-Arg-info i′ ×-dec a ≟ a′) _≟-ArgPattern_ : Decidable (_≡_ {A = Arg Pattern}) arg i a ≟-ArgPattern arg i′ a′ = Dec.map′ (cong₂′ arg) < arg₁ , arg₂ > (i ≟-Arg-info i′ ×-dec a ≟-Pattern a′) _≟-Args_ : Decidable (_≡_ {A = List (Arg Term)}) [] ≟-Args [] = yes refl (x ∷ xs) ≟-Args (y ∷ ys) = Dec.map′ (cong₂′ _∷_) < cons₁ , cons₂ > (x ≟-ArgTerm y ×-dec xs ≟-Args ys) [] ≟-Args (_ ∷ _) = no λ() (_ ∷ _) ≟-Args [] = no λ() _≟-Clause_ : Decidable (_≡_ {A = Clause}) clause ps b ≟-Clause clause ps′ b′ = Dec.map′ (cong₂′ clause) < clause₁ , clause₂ > (ps ≟-ArgPatterns ps′ ×-dec b ≟ b′) absurd-clause ps ≟-Clause absurd-clause ps′ = Dec.map′ (cong absurd-clause) absurd-clause₁ (ps ≟-ArgPatterns ps′) clause _ _ ≟-Clause absurd-clause _ = no λ() absurd-clause _ ≟-Clause clause _ _ = no λ() _≟-Clauses_ : Decidable (_≡_ {A = Clauses}) [] ≟-Clauses [] = yes refl (x ∷ xs) ≟-Clauses (y ∷ ys) = Dec.map′ (cong₂′ _∷_) < cons₁ , cons₂ > (x ≟-Clause y ×-dec xs ≟-Clauses ys) [] ≟-Clauses (_ ∷ _) = no λ() (_ ∷ _) ≟-Clauses [] = no λ() _≟-Pattern_ : Decidable (_≡_ {A = Pattern}) con c ps ≟-Pattern con c′ ps′ = Dec.map′ (cong₂′ con) < pcon₁ , pcon₂ > (c ≟-Name c′ ×-dec ps ≟-ArgPatterns ps′) con x x₁ ≟-Pattern dot = no (λ ()) con x x₁ ≟-Pattern var x₂ = no (λ ()) con x x₁ ≟-Pattern lit x₂ = no (λ ()) con x x₁ ≟-Pattern proj x₂ = no (λ ()) con x x₁ ≟-Pattern absurd = no (λ ()) dot ≟-Pattern con x x₁ = no (λ ()) dot ≟-Pattern dot = yes refl dot ≟-Pattern var x = no (λ ()) dot ≟-Pattern lit x = no (λ ()) dot ≟-Pattern proj x = no (λ ()) dot ≟-Pattern absurd = no (λ ()) var s ≟-Pattern con x x₁ = no (λ ()) var s ≟-Pattern dot = no (λ ()) var s ≟-Pattern var s′ = Dec.map′ (cong var) pvar (s ≟s s′) var s ≟-Pattern lit x = no (λ ()) var s ≟-Pattern proj x = no (λ ()) var s ≟-Pattern absurd = no (λ ()) lit x ≟-Pattern con x₁ x₂ = no (λ ()) lit x ≟-Pattern dot = no (λ ()) lit x ≟-Pattern var _ = no (λ ()) lit l ≟-Pattern lit l′ = Dec.map′ (cong lit) plit₁ (l ≟-Lit l′) lit x ≟-Pattern proj x₁ = no (λ ()) lit x ≟-Pattern absurd = no (λ ()) proj x ≟-Pattern con x₁ x₂ = no (λ ()) proj x ≟-Pattern dot = no (λ ()) proj x ≟-Pattern var _ = no (λ ()) proj x ≟-Pattern lit x₁ = no (λ ()) proj x ≟-Pattern proj x₁ = Dec.map′ (cong proj) pproj₁ (x ≟-Name x₁) proj x ≟-Pattern absurd = no (λ ()) absurd ≟-Pattern con x x₁ = no (λ ()) absurd ≟-Pattern dot = no (λ ()) absurd ≟-Pattern var _ = no (λ ()) absurd ≟-Pattern lit x = no (λ ()) absurd ≟-Pattern proj x = no (λ ()) absurd ≟-Pattern absurd = yes refl _≟-ArgPatterns_ : Decidable (_≡_ {A = List (Arg Pattern)}) [] ≟-ArgPatterns [] = yes refl (x ∷ xs) ≟-ArgPatterns (y ∷ ys) = Dec.map′ (cong₂′ _∷_) < cons₁ , cons₂ > (x ≟-ArgPattern y ×-dec xs ≟-ArgPatterns ys) [] ≟-ArgPatterns (_ ∷ _) = no λ() (_ ∷ _) ≟-ArgPatterns [] = no λ() _≟_ : Decidable (_≡_ {A = Term}) var x args ≟ var x′ args′ = Dec.map′ (cong₂′ var) < var₁ , var₂ > (x ≟-ℕ x′ ×-dec args ≟-Args args′) con c args ≟ con c′ args′ = Dec.map′ (cong₂′ con) < con₁ , con₂ > (c ≟-Name c′ ×-dec args ≟-Args args′) def f args ≟ def f′ args′ = Dec.map′ (cong₂′ def) < def₁ , def₂ > (f ≟-Name f′ ×-dec args ≟-Args args′) meta x args ≟ meta x′ args′ = Dec.map′ (cong₂′ meta) < meta₁ , meta₂ > (x ≟-Meta x′ ×-dec args ≟-Args args′) lam v t ≟ lam v′ t′ = Dec.map′ (cong₂′ lam) < lam₁ , lam₂ > (v ≟-Visibility v′ ×-dec t ≟-AbsTerm t′) pat-lam cs args ≟ pat-lam cs′ args′ = Dec.map′ (cong₂′ pat-lam) < pat-lam₁ , pat-lam₂ > (cs ≟-Clauses cs′ ×-dec args ≟-Args args′) pi t₁ t₂ ≟ pi t₁′ t₂′ = Dec.map′ (cong₂′ pi) < pi₁ , pi₂ > (t₁ ≟-ArgType t₁′ ×-dec t₂ ≟-AbsType t₂′) sort s ≟ sort s′ = Dec.map′ (cong sort) sort₁ (s ≟-Sort s′) lit l ≟ lit l′ = Dec.map′ (cong lit) lit₁ (l ≟-Lit l′) unknown ≟ unknown = yes refl var x args ≟ con c args′ = no λ() var x args ≟ def f args′ = no λ() var x args ≟ lam v t = no λ() var x args ≟ pi t₁ t₂ = no λ() var x args ≟ sort _ = no λ() var x args ≟ lit _ = no λ() var x args ≟ meta _ _ = no λ() var x args ≟ unknown = no λ() con c args ≟ var x args′ = no λ() con c args ≟ def f args′ = no λ() con c args ≟ lam v t = no λ() con c args ≟ pi t₁ t₂ = no λ() con c args ≟ sort _ = no λ() con c args ≟ lit _ = no λ() con c args ≟ meta _ _ = no λ() con c args ≟ unknown = no λ() def f args ≟ var x args′ = no λ() def f args ≟ con c args′ = no λ() def f args ≟ lam v t = no λ() def f args ≟ pi t₁ t₂ = no λ() def f args ≟ sort _ = no λ() def f args ≟ lit _ = no λ() def f args ≟ meta _ _ = no λ() def f args ≟ unknown = no λ() lam v t ≟ var x args = no λ() lam v t ≟ con c args = no λ() lam v t ≟ def f args = no λ() lam v t ≟ pi t₁ t₂ = no λ() lam v t ≟ sort _ = no λ() lam v t ≟ lit _ = no λ() lam v t ≟ meta _ _ = no λ() lam v t ≟ unknown = no λ() pi t₁ t₂ ≟ var x args = no λ() pi t₁ t₂ ≟ con c args = no λ() pi t₁ t₂ ≟ def f args = no λ() pi t₁ t₂ ≟ lam v t = no λ() pi t₁ t₂ ≟ sort _ = no λ() pi t₁ t₂ ≟ lit _ = no λ() pi t₁ t₂ ≟ meta _ _ = no λ() pi t₁ t₂ ≟ unknown = no λ() sort _ ≟ var x args = no λ() sort _ ≟ con c args = no λ() sort _ ≟ def f args = no λ() sort _ ≟ lam v t = no λ() sort _ ≟ pi t₁ t₂ = no λ() sort _ ≟ lit _ = no λ() sort _ ≟ meta _ _ = no λ() sort _ ≟ unknown = no λ() lit _ ≟ var x args = no λ() lit _ ≟ con c args = no λ() lit _ ≟ def f args = no λ() lit _ ≟ lam v t = no λ() lit _ ≟ pi t₁ t₂ = no λ() lit _ ≟ sort _ = no λ() lit _ ≟ meta _ _ = no λ() lit _ ≟ unknown = no λ() meta _ _ ≟ var x args = no λ() meta _ _ ≟ con c args = no λ() meta _ _ ≟ def f args = no λ() meta _ _ ≟ lam v t = no λ() meta _ _ ≟ pi t₁ t₂ = no λ() meta _ _ ≟ sort _ = no λ() meta _ _ ≟ lit _ = no λ() meta _ _ ≟ unknown = no λ() unknown ≟ var x args = no λ() unknown ≟ con c args = no λ() unknown ≟ def f args = no λ() unknown ≟ lam v t = no λ() unknown ≟ pi t₁ t₂ = no λ() unknown ≟ sort _ = no λ() unknown ≟ lit _ = no λ() unknown ≟ meta _ _ = no λ() pat-lam _ _ ≟ var x args = no λ() pat-lam _ _ ≟ con c args = no λ() pat-lam _ _ ≟ def f args = no λ() pat-lam _ _ ≟ lam v t = no λ() pat-lam _ _ ≟ pi t₁ t₂ = no λ() pat-lam _ _ ≟ sort _ = no λ() pat-lam _ _ ≟ lit _ = no λ() pat-lam _ _ ≟ meta _ _ = no λ() pat-lam _ _ ≟ unknown = no λ() var x args ≟ pat-lam _ _ = no λ() con c args ≟ pat-lam _ _ = no λ() def f args ≟ pat-lam _ _ = no λ() lam v t ≟ pat-lam _ _ = no λ() pi t₁ t₂ ≟ pat-lam _ _ = no λ() sort _ ≟ pat-lam _ _ = no λ() lit _ ≟ pat-lam _ _ = no λ() meta _ _ ≟ pat-lam _ _ = no λ() unknown ≟ pat-lam _ _ = no λ() _≟-Sort_ : Decidable (_≡_ {A = Sort}) set t ≟-Sort set t′ = Dec.map′ (cong set) set₁ (t ≟ t′) lit n ≟-Sort lit n′ = Dec.map′ (cong lit) slit₁ (n ≟-ℕ n′) unknown ≟-Sort unknown = yes refl set _ ≟-Sort lit _ = no λ() set _ ≟-Sort unknown = no λ() lit _ ≟-Sort set _ = no λ() lit _ ≟-Sort unknown = no λ() unknown ≟-Sort set _ = no λ() unknown ≟-Sort lit _ = no λ()
{ "alphanum_fraction": 0.5331630097, "avg_line_length": 33.27, "ext": "agda", "hexsha": "553165f3d250def9893aaf2db30e05a72f7b5494", "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/Reflection.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/Reflection.agda", "max_line_length": 122, "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/Reflection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7552, "size": 19962 }
{-# OPTIONS --cubical --safe #-} module Data.Empty.UniversePolymorphic where open import Prelude hiding (⊥) import Data.Empty as Monomorphic data ⊥ {ℓ} : Type ℓ where Poly⊥⇔Mono⊥ : ∀ {ℓ} → ⊥ {ℓ} ⇔ Monomorphic.⊥ Poly⊥⇔Mono⊥ .fun () Poly⊥⇔Mono⊥ .inv () Poly⊥⇔Mono⊥ .leftInv () Poly⊥⇔Mono⊥ .rightInv ()
{ "alphanum_fraction": 0.6253968254, "avg_line_length": 21, "ext": "agda", "hexsha": "11861a8b8792987f9d1c031b9f3851f62a772ef7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/Empty/UniversePolymorphic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/Empty/UniversePolymorphic.agda", "max_line_length": 43, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/Empty/UniversePolymorphic.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": 142, "size": 315 }
module Cats.Util.Reflection where open import Reflection public open import Data.List using ([]) open import Data.Unit using (⊤) open import Function using (_∘_) open import Level using (zero ; Lift) open import Cats.Util.Monad using (RawMonad ; _>>=_ ; _>>_ ; return ; mapM′) instance tcMonad : ∀ {l} → RawMonad {l} TC tcMonad = record { return = returnTC ; _>>=_ = bindTC } pattern argH x = arg (arg-info hidden relevant) x pattern argD x = arg (arg-info visible relevant) x pattern defD x = def x [] fromArg : ∀ {A} → Arg A → A fromArg (arg _ x) = x fromAbs : ∀ {A} → Abs A → A fromAbs (abs _ x) = x blockOnAnyMeta-clause : Clause → TC (Lift zero ⊤) -- This may or may not loop if there are metas in the input term that cannot be -- solved when this tactic is called. {-# TERMINATING #-} blockOnAnyMeta : Term → TC (Lift zero ⊤) blockOnAnyMeta (var x args) = mapM′ (blockOnAnyMeta ∘ fromArg) args blockOnAnyMeta (con c args) = mapM′ (blockOnAnyMeta ∘ fromArg) args blockOnAnyMeta (def f args) = mapM′ (blockOnAnyMeta ∘ fromArg) args blockOnAnyMeta (lam v t) = blockOnAnyMeta (fromAbs t) blockOnAnyMeta (pat-lam cs args) = do mapM′ blockOnAnyMeta-clause cs mapM′ (blockOnAnyMeta ∘ fromArg) args blockOnAnyMeta (pi a b) = do blockOnAnyMeta (fromArg a) blockOnAnyMeta (fromAbs b) blockOnAnyMeta (sort (set t)) = blockOnAnyMeta t blockOnAnyMeta (sort (lit n)) = return _ blockOnAnyMeta (sort unknown) = return _ blockOnAnyMeta (lit l) = return _ blockOnAnyMeta (meta x _) = blockOnMeta x blockOnAnyMeta unknown = return _ blockOnAnyMeta-clause (clause ps t) = blockOnAnyMeta t blockOnAnyMeta-clause (absurd-clause ps) = return _
{ "alphanum_fraction": 0.7025580012, "avg_line_length": 28.4915254237, "ext": "agda", "hexsha": "506bdc7fcd489f39ad12e65c999ea85e55446ae5", "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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Util/Reflection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "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": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Util/Reflection.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Util/Reflection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 533, "size": 1681 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Demos.Binary where open import Data.Nat open import Testers open import Prelude infixl 5 _1𝕓 _2𝕓 data 𝔹 : Type where 0𝕓 : 𝔹 _1𝕓 : 𝔹 → 𝔹 _2𝕓 : 𝔹 → 𝔹 ⟦_⇓⟧ : 𝔹 → ℕ ⟦ 0𝕓 ⇓⟧ = 0 ⟦ n 1𝕓 ⇓⟧ = 1 + ⟦ n ⇓⟧ * 2 ⟦ n 2𝕓 ⇓⟧ = 2 + ⟦ n ⇓⟧ * 2 inc : 𝔹 → 𝔹 inc 0𝕓 = 0𝕓 1𝕓 inc (xs 1𝕓) = xs 2𝕓 inc (xs 2𝕓) = inc xs 1𝕓 ⟦_⇑⟧ : ℕ → 𝔹 ⟦ zero ⇑⟧ = 0𝕓 ⟦ suc n ⇑⟧ = inc ⟦ n ⇑⟧ inc-suc : ∀ x → ⟦ inc x ⇓⟧ ≡ suc ⟦ x ⇓⟧ inc-suc 0𝕓 i = 1 inc-suc (x 1𝕓) i = 2 + ⟦ x ⇓⟧ * 2 inc-suc (x 2𝕓) i = suc (inc-suc x i * 2) inc-2*-1𝕓 : ∀ n → inc ⟦ n * 2 ⇑⟧ ≡ ⟦ n ⇑⟧ 1𝕓 inc-2*-1𝕓 zero i = 0𝕓 1𝕓 inc-2*-1𝕓 (suc n) i = inc (inc (inc-2*-1𝕓 n i)) 𝔹-rightInv : ∀ x → ⟦ ⟦ x ⇑⟧ ⇓⟧ ≡ x 𝔹-rightInv zero = refl 𝔹-rightInv (suc x) = inc-suc ⟦ x ⇑⟧ ; cong suc (𝔹-rightInv x) 𝔹-leftInv : ∀ x → ⟦ ⟦ x ⇓⟧ ⇑⟧ ≡ x 𝔹-leftInv 0𝕓 = refl 𝔹-leftInv (x 1𝕓) = inc-2*-1𝕓 ⟦ x ⇓⟧ ; cong _1𝕓 (𝔹-leftInv x) 𝔹-leftInv (x 2𝕓) = cong inc (inc-2*-1𝕓 ⟦ x ⇓⟧) ; cong _2𝕓 (𝔹-leftInv x) ℕ⇔𝔹 : 𝔹 ⇔ ℕ ℕ⇔𝔹 .fun = ⟦_⇓⟧ ℕ⇔𝔹 .inv = ⟦_⇑⟧ ℕ⇔𝔹 .rightInv = 𝔹-rightInv ℕ⇔𝔹 .leftInv = 𝔹-leftInv
{ "alphanum_fraction": 0.5031674208, "avg_line_length": 21.25, "ext": "agda", "hexsha": "a4de5bc9bfa4d4df21fdcaafa3e383f456b2ee58", "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": "Demos/Binary.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": "Demos/Binary.agda", "max_line_length": 71, "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": "Demos/Binary.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": 777, "size": 1105 }
-- This contains material which used to be in the Sane module, but is no -- longer used. It is not junk, so it is kept here, as we may need to -- resurrect it. module Obsolete where import Data.Fin as F -- open import Data.Empty open import Data.Unit open import Data.Unit.Core open import Data.Nat renaming (_⊔_ to _⊔ℕ_) open import Data.Sum renaming (map to _⊎→_) open import Data.Product renaming (map to _×→_) open import Data.Vec open import Function renaming (_∘_ to _○_) open import Relation.Binary.PropositionalEquality open ≡-Reasoning -- start re-splitting things up, as this is getting out of hand open import FT -- Finite Types open import VecHelpers open import NatSimple open import Eval open import Sane {- swap≡ind₀ : {n : ℕ} → ((F.suc F.zero) ∷ F.zero ∷ (vmap (λ i → F.suc (F.suc i)) (upTo n))) ≡ (swapInd F.zero (F.suc F.zero)) swap≡ind₀ {n} = ap (λ v → F.suc F.zero ∷ F.zero ∷ v) ((vmap (λ i → F.suc (F.suc i)) (upTo n)) ≡⟨ mapTab _ _ ⟩ (tabulate (id ○ (λ i → F.suc (F.suc i)))) ≡⟨ tabf∼g _ _ swapIndIdAfterOne ⟩ ((tabulate (((swapIndFn F.zero (F.suc F.zero)) ○ F.suc) ○ F.suc)) ∎)) -} {-- For reference swapmn : {lim : ℕ} → (m : F.Fin lim) → F.Fin′ m → (fromℕ lim) ⇛ (fromℕ lim) swapmn F.zero () swapmn (F.suc m) (F.zero) = swapUpTo m ◎ swapi m ◎ swapDownFrom m swapmn (F.suc m) (F.suc n) = id⇛ ⊕ swapmn m n --} {-- foldrWorks {fromℕ n ⇛ fromℕ n} {n} (λ i → fromℕ n ⇛ fromℕ n) -- I think we need to rewrite vecToComb using an indexed fold to have all -- the information here that we need for the correctness proof [Z] (λ n′ v c → (i : F.Fin n′) → {!!}) -- (evalVec {n′} v i) ≡ (evalComb c (finToVal i))) _◎_ id⇛ {!!} -- combination lemma {!!} -- base case lemma (zipWith makeSingleComb v (upTo n)) --} -- Maybe we won't end up needing these to plug in to vecToCombWorks, -- but I'm afraid we will, which means we'll have to fix them eventually. -- I'm not sure how to do this right now and I've spent too much time on -- it already when there are other, more tractable problems that need to -- be solved. If someone else wants to take a shot, be my guest. [Z] {- foldri : {A : Set} → (B : ℕ → Set) → {m : ℕ} → ({n : ℕ} → F.Fin m → A → B n → B (suc n)) → B zero → Vec A m → B m foldri {A} b {m} combine base vec = foldr b (uncurry combine) base (Data.Vec.zip (upTo _) vec) postulate foldriWorks : {A : Set} → {m : ℕ} → (B : ℕ → Set) → (P : (n : ℕ) → Vec A n → B n → Set) → (combine : {n : ℕ} → F.Fin m → A → B n → B (suc n)) → (base : B zero) → ({n : ℕ} → (i : F.Fin m) → (a : A) → (v : Vec A n) → (b : B n) → P n v b → P (suc n) (a ∷ v) (combine i a b)) → P zero [] base → (v : Vec A m) → P m v (foldri B combine base v) -} -- following definition doesn't work, or at least not obviously -- need a more straightforward definition of foldri, but none comes to mind -- help? [Z] {-- foldriWorks {A} {m} B P combine base pcombine pbase vec = foldrWorks {F.Fin m × A} B (λ n v b → P n (map proj₂ v) b) (uncurry combine) base ? -- (uncurry pcombine) pbase (Data.Vec.zip (upTo _) vec) --} -- Second argument is an accumulator -- plf′ max i acc = (i + acc) + 1 mod (max + acc) if (i + acc) <= (max + acc), (max + acc) ow -- This is the simplest way I could come up with to do this without -- using F.compare or something similar {- plf′ : {m n : ℕ} → F.Fin (suc m) → F.Fin (suc m) → F.Fin n → F.Fin (m + n) plf′ {n = zero} F.zero F.zero () plf′ {m} {suc n} F.zero F.zero acc = hetType F.zero (ap F.Fin (! (m+1+n≡1+m+n m _))) -- m mod m == 0 plf′ F.zero (F.suc i) acc = (F.suc i) +F acc -- above the threshold, so just id plf′ (F.suc {zero} ()) _ _ plf′ (F.suc {suc m} max) F.zero acc = -- we're in range, so take succ of acc hetType (inj+ {n = m} (F.suc acc)) (ap F.Fin (m+1+n≡1+m+n m _)) plf′ (F.suc {suc m} max) (F.suc i) acc = -- we don't know what to do yet, so incr acc & recur hetType (plf′ max i (F.suc acc)) (ap F.Fin ((m+1+n≡1+m+n m _))) -} -- Seems important to prove! (but not used, so commenting it out [JC]) {- shuffle : {n : ℕ} → (i : F.Fin n) → (permLeftID (F.inject₁ i) ∘̬ swapInd (F.inject₁ i) (F.suc i) ∘̬ permRightID (F.inject₁ i)) ≡ swapInd F.zero (F.suc i) shuffle {zero} () shuffle {suc n} F.zero = {!!} shuffle {suc n} (F.suc i) = {!!} -} -- helper lemmas for vecRepWorks swapElsewhere : {n : ℕ} → (x : ⟦ fromℕ n ⟧) → inj₂ (inj₂ x) ≡ (evalComb (swapi F.zero) (inj₂ (inj₂ x))) swapElsewhere x = refl -- Lemma for proving things about calls to foldr; possibly not needed. foldrWorks : {A : Set} → {m : ℕ} → (B : ℕ → Set) → (P : (n : ℕ) → Vec A n → B n → Set) → (_⊕_ : {n : ℕ} → A → B n → B (suc n)) → (base : B zero) → ({n : ℕ} → (a : A) → (v : Vec A n) → (b : B n) → P n v b → P (suc n) (a ∷ v) (a ⊕ b)) → P zero [] base → (v : Vec A m) → P m v (foldr B _⊕_ base v) foldrWorks B P combine base pcombine pbase [] = pbase foldrWorks B P combine base pcombine pbase (x ∷ v) = pcombine x v (foldr B combine base v) (foldrWorks B P combine base pcombine pbase v) -- evalComb on foldr becomes a foldl of flipped evalComb evalComb∘foldr : {n j : ℕ} → (i : ⟦ fromℕ n ⟧ ) → (c-vec : Vec (fromℕ n ⇛ fromℕ n) j) → evalComb (foldr (λ _ → fromℕ n ⇛ fromℕ n) _◎_ id⇛ c-vec) i ≡ foldl (λ _ → ⟦ fromℕ n ⟧) (λ i c → evalComb c i) i c-vec evalComb∘foldr {zero} () v evalComb∘foldr {suc _} i [] = refl -- i evalComb∘foldr {suc n} i (c ∷ cv) = evalComb∘foldr {suc n} (evalComb c i) cv -- foldl on a map: move the function in; specialize to this case. foldl∘map : {n m : ℕ} {A C : Set} (f : C → A → C) (j : C) (g : F.Fin m → F.Fin m → A) → (v : Vec (F.Fin m) m) → (z : Vec (F.Fin m) n) → foldl (λ _ → C) f j (map (λ i → g (v !! i) i) z) ≡ foldl (λ _ → C) (λ h i → i h) j (map (λ x₂ → λ w → f w (g (v !! x₂) x₂)) z) foldl∘map {zero} f j g v [] = refl -- j foldl∘map {suc n} {zero} f j g [] (() ∷ z) foldl∘map {suc n} {suc m} f j g v (x ∷ z) = foldl∘map f (f j (g (lookup x v) x)) g v z lemma3 : {n : ℕ} → (v : Vec (F.Fin n) n) → (i : F.Fin n) → (evalComb (vecToComb v) (finToVal i)) ≡ foldl (λ _ → ⟦ fromℕ n ⟧) (λ h i₁ → i₁ h) (finToVal i) (replicate (λ x₂ → evalComb (makeSingleComb (lookup x₂ v) x₂)) ⊛ tabulate (λ x → x)) lemma3 {n} v i = begin evalComb (vecToComb v) (finToVal i) ≡⟨ evalComb∘foldr (finToVal i) (map (λ i → makeSingleComb (v !! i) i) (upTo n)) ⟩ foldl (λ _ → ⟦ fromℕ n ⟧) (λ j c → evalComb c j) (finToVal i) (map (λ i → makeSingleComb (v !! i) i) (upTo n)) ≡⟨ foldl∘map (λ j c → evalComb c j) (finToVal i) makeSingleComb v (upTo n) ⟩ foldl (λ _ → ⟦ fromℕ n ⟧) (λ h i₁ → i₁ h) (finToVal i) (replicate (λ x₂ → evalComb (makeSingleComb (lookup x₂ v) x₂)) ⊛ tabulate id) ∎
{ "alphanum_fraction": 0.5242444594, "avg_line_length": 37.7918781726, "ext": "agda", "hexsha": "abc1fa9ad4c6b1fb3f374b9d446062292706775c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/OldUnivalence/Obsolete.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/OldUnivalence/Obsolete.agda", "max_line_length": 206, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/OldUnivalence/Obsolete.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 2808, "size": 7445 }
{-# OPTIONS --without-K --safe #-} module Math.NumberTheory.Summation.Nat.Properties.Lemma where -- agda-stdlib open import Data.Nat open import Data.Nat.Properties open import Data.Nat.Solver open import Relation.Binary.PropositionalEquality open import Function.Base lemma₁ : ∀ n → n * (1 + n) * (1 + 2 * n) + 6 * ((1 + n) ^ 2) ≡ (1 + n) * (2 + n) * (1 + 2 * (1 + n)) lemma₁ = solve 1 (λ n → (n :* (con 1 :+ n) :* (con 1 :+ con 2 :* n) :+ con 6 :* (con 1 :+ n) :^ 2) := (con 1 :+ n) :* (con 2 :+ n) :* (con 1 :+ con 2 :* (con 1 :+ n)) ) refl where open +-*-Solver
{ "alphanum_fraction": 0.5456081081, "avg_line_length": 31.1578947368, "ext": "agda", "hexsha": "36bb6e1570c33e66e541200c6d617f2a8565de1f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Math/NumberTheory/Summation/Nat/Properties/Lemma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Math/NumberTheory/Summation/Nat/Properties/Lemma.agda", "max_line_length": 79, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Math/NumberTheory/Summation/Nat/Properties/Lemma.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 236, "size": 592 }
open import Nat open import Prelude open import dynamics-core open import contexts open import htype-decidable open import lemmas-matching open import lemmas-consistency open import disjointness open import typed-elaboration module elaborability where mutual elaborability-synth : {Γ : tctx} {e : hexp} {τ : htyp} → holes-unique e → Γ ⊢ e => τ → Σ[ d ∈ ihexp ] Σ[ Δ ∈ hctx ] (Γ ⊢ e ⇒ τ ~> d ⊣ Δ) elaborability-synth HUNum SNum = _ , _ , ESNum elaborability-synth (HUPlus hu1 hu2 hd) (SPlus wt1 wt2) with elaborability-ana hu1 wt1 | elaborability-ana hu2 wt2 ... | _ , _ , _ , D1 | _ , _ , _ , D2 = _ , _ , ESPlus hd (elab-ana-disjoint hd D1 D2) D1 D2 elaborability-synth (HUAsc hu) (SAsc wt) with elaborability-ana hu wt ... | _ , _ , _ , D = _ , _ , ESAsc D elaborability-synth HUVar (SVar x) = _ , _ , ESVar x elaborability-synth (HULam2 hu) (SLam apt wt) with elaborability-synth hu wt ... | _ , _ , D = _ , _ , ESLam apt D elaborability-synth (HUAp hu1 hu2 hd) (SAp wt1 m wt2) with elaborability-ana hu1 (ASubsume wt1 (~sym (▸arr-consist m))) | elaborability-ana hu2 wt2 ... | _ , _ , _ , D1 | _ , _ , _ , D2 = _ , _ , ESAp hd (elab-ana-disjoint hd D1 D2) wt1 m D1 D2 elaborability-synth (HUPair hu1 hu2 hd) (SPair wt1 wt2) with elaborability-synth hu1 wt1 | elaborability-synth hu2 wt2 ... | _ , _ , D1 | _ , _ , D2 = _ , _ , ESPair hd (elab-synth-disjoint hd D1 D2) D1 D2 elaborability-synth (HUFst hu) (SFst wt m) with elaborability-ana hu (ASubsume wt (~sym (▸prod-consist m))) ... | _ , _ , _ , D = _ , _ , ESFst wt m D elaborability-synth (HUSnd hu) (SSnd wt m) with elaborability-ana hu (ASubsume wt (~sym (▸prod-consist m))) ... | _ , _ , _ , D = _ , _ , ESSnd wt m D elaborability-synth HUHole SEHole = _ , _ , ESEHole elaborability-synth (HUNEHole hu hnn) (SNEHole wt) with elaborability-synth hu wt ... | _ , _ , D = _ , _ , ESNEHole (elab-new-disjoint-synth hnn D) D elaborability-ana : {Γ : tctx} {e : hexp} {τ : htyp} → holes-unique e → Γ ⊢ e <= τ → Σ[ d ∈ ihexp ] Σ[ Δ ∈ hctx ] Σ[ τ' ∈ htyp ] (Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ) elaborability-ana {e = e} hu (ASubsume wt con) with elaborability-synth hu wt elaborability-ana {e = N x} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = e ·+ e₁} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = e ·: x} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = X x} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = ·λ x ·[ x₁ ] e} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = e ∘ e₁} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = ⟨ e , e₁ ⟩} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = fst e} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = snd e} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) wt' con elaborability-ana {e = ⦇-⦈[ u ]} hu (ASubsume wt con) | _ , _ , wt' = _ , _ , _ , EAEHole elaborability-ana {e = ⦇⌜ e ⌟⦈[ u ]} (HUNEHole hu hnn) (ASubsume (SNEHole wt) con) | _ , _ , ESNEHole apt wt' with elaborability-synth hu wt ... | _ , _ , wt'' = _ , _ , _ , EANEHole (elab-new-disjoint-synth hnn wt'') wt'' elaborability-ana (HULam1 hu) (ALam apt m wt) with elaborability-ana hu wt ... | _ , _ , _ , wt' = _ , _ , _ , EALam apt m wt' elaborability-ana (HUInl hu) (AInl m wt) with elaborability-ana hu wt ... | _ , _ , _ , wt' = _ , _ , _ , EAInl m wt' elaborability-ana (HUInr hu) (AInr m wt) with elaborability-ana hu wt ... | _ , _ , _ , wt' = _ , _ , _ , EAInr m wt' elaborability-ana (HUCase hu hu1 hu2 hd1 hd2 hd12) (ACase apt1 apt2 m wt wt1 wt2) with elaborability-synth hu wt | elaborability-ana hu1 wt1 | elaborability-ana hu2 wt2 ... | _ , _ , wt' | _ , _ , _ , wt1' | _ , _ , _ , wt2' = _ , _ , _ , EACase hd1 hd2 hd12 (elab-synth-ana-disjoint hd1 wt' wt1') (elab-synth-ana-disjoint hd2 wt' wt2') (elab-ana-disjoint hd12 wt1' wt2') apt1 apt2 wt' m wt1' wt2'
{ "alphanum_fraction": 0.528887087, "avg_line_length": 51.3854166667, "ext": "agda", "hexsha": "4c407a1aa426ab8a6ce42ba88775047a4f4e5776", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "elaborability.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "elaborability.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "elaborability.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1819, "size": 4933 }
module DFA where open import Level open import Data.Unit open import Data.List using (List; []; _∷_) open import Data.Bool using (Bool; true; false; _∧_; _∨_; T; not) open import Function open import Relation.Nullary using (Dec; yes; no; ¬_) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary open DecSetoid String : (Σ : Set) → Set String Σ = List Σ -- A deterministic finite automaton is a 5-tuple, (Q, Σ, δ, q0, F) record DFA (Q : DecSetoid zero zero) (Σ : Set): Set₁ where constructor dfa field δ : Carrier Q → Σ → Carrier Q initial : Carrier Q accepts : Carrier Q → Bool open DFA -- eats a character step : ∀ {Q Σ} → DFA Q Σ → Σ → DFA Q Σ step (dfa δ initial accept) char = dfa δ (δ initial char) accept -- eats a lot of characters steps : ∀ {Q Σ} → DFA Q Σ → String Σ → DFA Q Σ steps machine [] = machine steps machine (x ∷ xs) = steps (step machine x) xs -- a machine M is acceptable if its initial state is in the accept states acceptable : ∀ {Q Σ} → DFA Q Σ → Bool acceptable (dfa δ initial accepts) = accepts initial -------------------------------------------------------------------------------- -- language and automaton -------------------------------------------------------------------------------- open import Relation.Unary hiding (Decidable) Language : (Σ : Set) → Set _ Language Σ = Pred (String Σ) zero -- machine ⇒ language ⟦_⟧ : ∀ {P Σ} → DFA P Σ → Language Σ ⟦ machine ⟧ = λ string → T (acceptable (steps machine string)) _∈?_ : ∀ {P Σ} → (string : String Σ) → (M : DFA P Σ) → Dec (string ∈ ⟦ M ⟧) string ∈? machine with acceptable (steps machine string) string ∈? machine | false = no id string ∈? machine | true = yes tt -------------------------------------------------------------------------------- -- product and sum -------------------------------------------------------------------------------- open import Data.Product open import Relation.Binary.Product.Pointwise -- a helper function for constructing a transition function with product states product-δ : ∀ {P Q Σ} → DFA P Σ → DFA Q Σ → Carrier P × Carrier Q → Σ → Carrier P × Carrier Q product-δ A B (p , q) c = δ A p c , δ B q c -- intersection infixl 30 _∩ᴹ_ _∩ᴹ_ : ∀ {P Q Σ} → DFA P Σ → DFA Q Σ → DFA (P ×-decSetoid Q) Σ A ∩ᴹ B = dfa (product-δ A B) (initial A , initial B) (uncurry (λ p q → accepts A p ∧ accepts B q)) -- union infixl 29 _∪ᴹ_ _∪ᴹ_ : ∀ {P Q Σ} → DFA P Σ → DFA Q Σ → DFA (P ×-decSetoid Q) Σ A ∪ᴹ B = dfa (product-δ A B) (initial A , initial B) (uncurry (λ p q → accepts A p ∨ accepts B q)) -- negation infixl 31 Cᴹ_ Cᴹ_ : ∀ {P Σ} → DFA P Σ → DFA P Σ Cᴹ dfa δ initial accepts = dfa δ initial (not ∘ accepts) -------------------------------------------------------------------------------- -- concatenation -------------------------------------------------------------------------------- open import Data.Sum open import Relation.Binary.Sum open import Data.Empty module Pointwise where -- _⊎-decSetoid_ : ∀ {d₁ d₂ d₃ d₄} -- → DecSetoid d₁ d₂ -- → DecSetoid d₃ d₄ -- → DecSetoid _ _ -- _⊎-decSetoid_ {d₁} {d₂} {d₃} {d₄} s₁ s₂ = record -- { Carrier = Carrier s₁ ⊎ Carrier s₂ -- ; _≈_ = _⊎-≈_ -- ; isDecEquivalence = record -- { isEquivalence = ⊎-≈-isEquivalence -- ; _≟_ = ⊎-≈-decidable -- } -- } -- where -- -- open DecSetoid -- _⊎-≈_ : Carrier s₁ ⊎ Carrier s₂ -- → Carrier s₁ ⊎ Carrier s₂ -- → Set (d₂ ⊔ d₄) -- _⊎-≈_ (inj₁ x) (inj₁ y) = Lift {d₂} {d₄} (_≈_ s₁ x y) -- (_≈_ s₁ x y) -- _⊎-≈_ (inj₁ x) (inj₂ y) = Lift ⊥ -- _⊎-≈_ (inj₂ x) (inj₁ y) = Lift ⊥ -- _⊎-≈_ (inj₂ x) (inj₂ y) = Lift {d₄} {d₂} (_≈_ s₂ x y) -- -- open IsEquivalence -- module S₁ = IsDecEquivalence (isDecEquivalence s₁) -- module S₂ = IsDecEquivalence (isDecEquivalence s₂) -- -- ⊎-≈-refl : Reflexive _⊎-≈_ -- ⊎-≈-refl {inj₁ x} = lift (refl S₁.isEquivalence) -- ⊎-≈-refl {inj₂ y} = lift (refl S₂.isEquivalence) -- -- ⊎-≈-sym : Symmetric _⊎-≈_ -- ⊎-≈-sym {inj₁ x} {inj₁ y} (lift eq) = lift (sym S₁.isEquivalence eq) -- ⊎-≈-sym {inj₁ x} {inj₂ y} (lift ()) -- ⊎-≈-sym {inj₂ x} {inj₁ y} (lift ()) -- ⊎-≈-sym {inj₂ x} {inj₂ y} (lift eq) = lift (sym S₂.isEquivalence eq) -- -- ⊎-≈-trans : Transitive _⊎-≈_ -- ⊎-≈-trans {inj₁ x} {inj₁ y} {inj₁ z} (lift p) (lift q) = lift (trans S₁.isEquivalence p q) -- ⊎-≈-trans {inj₁ x} {inj₁ y} {inj₂ z} p (lift ()) -- ⊎-≈-trans {inj₁ x} {inj₂ y} {_} (lift ()) q -- ⊎-≈-trans {inj₂ x} {inj₁ y} {_} (lift ()) q -- ⊎-≈-trans {inj₂ x} {inj₂ y} {inj₁ z} p (lift ()) -- ⊎-≈-trans {inj₂ x} {inj₂ y} {inj₂ z} (lift p) (lift q) = lift (trans S₂.isEquivalence p q) -- -- ⊎-≈-isEquivalence : IsEquivalence _⊎-≈_ -- ⊎-≈-isEquivalence = record -- { refl = λ {x} → ⊎-≈-refl {x} -- ; sym = λ {x} {y} eq → ⊎-≈-sym {x} {y} eq -- ; trans = λ {x} {y} {z} p q → ⊎-≈-trans {x} {y} {z} p q -- } -- -- lift-dec : ∀ {a} {b} {P : Set a} → Dec P → Dec (Lift {a} {b} P) -- lift-dec (yes p) = yes (lift p) -- lift-dec (no ¬p) = no (λ p → contradiction (lower p) ¬p) -- -- ⊎-≈-decidable : Decidable _⊎-≈_ -- ⊎-≈-decidable (inj₁ x) (inj₁ y) = lift-dec (S₁._≟_ x y) -- ⊎-≈-decidable (inj₁ x) (inj₂ y) = no lower -- ⊎-≈-decidable (inj₂ x) (inj₁ y) = no lower -- ⊎-≈-decidable (inj₂ x) (inj₂ y) = lift-dec (S₂._≟_ x y) infixl 28 _++_ _++_ : ∀ {P Q Σ} → DFA P Σ → DFA Q Σ → DFA (P ⊎-decSetoid Q) Σ _++_ {P} {Q} {Σ} A B = dfa δ' (inj₁ (initial A)) accepts' where δ' : Carrier (P ⊎-decSetoid Q) → Σ → Carrier (P ⊎-decSetoid Q) δ' (inj₁ state) character with acceptable (step A character) δ' (inj₁ state) character | false = inj₁ (δ A state character) δ' (inj₁ state) character | true = inj₂ (initial B) δ' (inj₂ state) character = inj₂ (δ B state character) accepts' : Carrier (P ⊎-decSetoid Q) → Bool accepts' (inj₁ state) = false accepts' (inj₂ state) = accepts B state -- -- ++-right-identity : {P Q Σ : Set} -- -- → (A : DFA P Σ) → (B : DFA Q Σ) -- -- → Empty B -- -- → DFA (P ⊎ Q) Σ -- -------------------------------------------------------------------------------- -- Kleene closure -------------------------------------------------------------------------------- -- 1. make the initial state the accept state -- 2. wire all of the transitions that would've gone to the original accept -- states to the initial state (which is the new accept state) infixl 32 _* _* : ∀ {Q Σ} → DFA Q Σ → DFA Q Σ _* {Q} {Σ} M = dfa δ' (initial M) accepts' where δ' : Carrier Q → Σ → Carrier Q δ' state character with acceptable (step M character) δ' state character | false = δ M state character δ' state character | true = initial M open IsDecEquivalence (isDecEquivalence Q) renaming (_≟_ to _≟s_) open import Relation.Nullary.Decidable accepts' : Carrier Q → Bool accepts' state = ⌊ state ≟s initial M ⌋ -------------------------------------------------------------------------------- -- Properties -------------------------------------------------------------------------------- module Properties (Σ : Set) where open import Function.Equality using (Π) open Π open import Function.Equivalence using (_⇔_; Equivalence) open import Data.Bool.Properties as BoolProp open import Relation.Nullary.Negation -- extracting one direction of a function equivalence ⟦_⟧→ : {A B : Set} → A ⇔ B → A → B ⟦ A⇔B ⟧→ A = Equivalence.to A⇔B ⟨$⟩ A ←⟦_⟧ : {A B : Set} → A ⇔ B → B → A ←⟦ A⇔B ⟧ B = Equivalence.from A⇔B ⟨$⟩ B open import Relation.Unary.Membership (String Σ) open ⊆-Reasoning ∩-homo⇒ : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∩ᴹ B ⟧ ⊆′ ⟦ A ⟧ ∩ ⟦ B ⟧ ∩-homo⇒ A B [] = ⟦ BoolProp.T-∧ ⟧→ ∩-homo⇒ A B (x ∷ xs) = ∩-homo⇒ (step A x) (step B x) xs ∩-homo⇐ : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ⟧ ∩ ⟦ B ⟧ ⊆′ ⟦ A ∩ᴹ B ⟧ ∩-homo⇐ A B [] = ←⟦ BoolProp.T-∧ ⟧ ∩-homo⇐ A B (x ∷ xs) = ∩-homo⇐ (step A x) (step B x) xs ∩-homo : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∩ᴹ B ⟧ ≋ ⟦ A ⟧ ∩ ⟦ B ⟧ ∩-homo A B = (∩-homo⇒ A B) , (∩-homo⇐ A B) ∩-sym⇒ : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∩ᴹ B ⟧ ⊆′ ⟦ B ∩ᴹ A ⟧ ∩-sym⇒ A B xs P = xs ∈⟨ P ⟩ ⟦ A ∩ᴹ B ⟧ ⊆⟨ ∩-homo⇒ A B ⟩ ⟦ A ⟧ ∩ ⟦ B ⟧ →⟨ swap ⟩ ⟦ B ⟧ ∩ ⟦ A ⟧ ⊆⟨ ∩-homo⇐ B A ⟩ ⟦ B ∩ᴹ A ⟧ ∎ ∩-sym : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∩ᴹ B ⟧ ≋ ⟦ B ∩ᴹ A ⟧ ∩-sym A B = (∩-sym⇒ A B) , (∩-sym⇒ B A) ∪-homo⇒ : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∪ᴹ B ⟧ ⊆′ ⟦ A ⟧ ∪ ⟦ B ⟧ ∪-homo⇒ A B [] P = ⟦ BoolProp.T-∨ ⟧→ P ∪-homo⇒ A B (x ∷ xs) P = ∪-homo⇒ (step A x) (step B x) xs P ∪-homo⇐ : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ⟧ ∪ ⟦ B ⟧ ⊆′ ⟦ A ∪ᴹ B ⟧ ∪-homo⇐ A B [] P = ←⟦ BoolProp.T-∨ ⟧ P ∪-homo⇐ A B (x ∷ xs) P = ∪-homo⇐ (step A x) (step B x) xs P ∪-homo : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∪ᴹ B ⟧ ≋ ⟦ A ⟧ ∪ ⟦ B ⟧ ∪-homo A B = (∪-homo⇒ A B) , (∪-homo⇐ A B) ∪-sym⇒ : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∪ᴹ B ⟧ ⊆′ ⟦ B ∪ᴹ A ⟧ ∪-sym⇒ A B xs P = xs ∈⟨ P ⟩ ⟦ A ∪ᴹ B ⟧ ⊆⟨ ∪-homo⇒ A B ⟩ ⟦ A ⟧ ∪ ⟦ B ⟧ →⟨ ⊎-swap ⟩ ⟦ B ⟧ ∪ ⟦ A ⟧ ⊆⟨ ∪-homo⇐ B A ⟩ ⟦ B ∪ᴹ A ⟧ ∎ where ⊎-swap : ∀ {a b} {A : Set a} {B : Set b} → A ⊎ B → B ⊎ A ⊎-swap (inj₁ x) = inj₂ x ⊎-swap (inj₂ y) = inj₁ y ∪-sym : ∀ {P Q} → (A : DFA P Σ) → (B : DFA Q Σ) → ⟦ A ∪ᴹ B ⟧ ≋ ⟦ B ∪ᴹ A ⟧ ∪-sym A B = (∪-sym⇒ A B) , (∪-sym⇒ B A) T-not-¬ : {b : Bool} → T (not b) → ¬ (T b) T-not-¬ {false} P Q = Q T-not-¬ {true} P Q = P T-¬-not : {b : Bool} → ¬ (T b) → T (not b) T-¬-not {false} P = tt T-¬-not {true} P = P tt C⇒ : ∀ {P} → (M : DFA P Σ) → ∁ ⟦ M ⟧ ⊆ ⟦ Cᴹ M ⟧ C⇒ M {[]} = T-¬-not C⇒ M {x ∷ xs} = C⇒ (step M x) {xs} C⇐ : ∀ {P} → (M : DFA P Σ) → ⟦ Cᴹ M ⟧ ⊆ ∁ ⟦ M ⟧ C⇐ M {[]} = T-not-¬ C⇐ M {x ∷ xs} = C⇐ (step M x) {xs} C-∩-∅⇒ : ∀ {P} → (M : DFA P Σ) → ⟦ M ∩ᴹ Cᴹ M ⟧ ⊆ ∅ C-∩-∅⇒ M {[]} P = let Q , ¬Q = ∩-homo⇒ M (Cᴹ M) [] P in contradiction Q (C⇐ M {[]} ¬Q) C-∩-∅⇒ M {x ∷ xs} = C-∩-∅⇒ (step M x) {xs} C-∩-∅⇐ : ∀ {P} → (M : DFA P Σ) → ∅ ⊆ ⟦ M ∩ᴹ Cᴹ M ⟧ C-∩-∅⇐ M {[]} () C-∩-∅⇐ M {x ∷ xs} = C-∩-∅⇐ (step M x) {xs} C-∪-U⇒ : ∀ {P} → (M : DFA P Σ) → ⟦ M ∪ᴹ Cᴹ M ⟧ ⊆ U C-∪-U⇒ M {[]} P = tt C-∪-U⇒ M {x ∷ xs} = C-∪-U⇒ (step M x) {xs} C-∪-U⇐ : ∀ {P} → (M : DFA P Σ) → U ⊆ ⟦ M ∪ᴹ Cᴹ M ⟧ C-∪-U⇐ M {[]} P with [] ∈? M C-∪-U⇐ M {[]} P | yes p = ←⟦ T-∨ ⟧ (inj₁ p) C-∪-U⇐ M {[]} P | no ¬p = ←⟦ T-∨ {accepts M (initial M)} {not (accepts M (initial M))} ⟧ (inj₂ (T-¬-not ¬p)) C-∪-U⇐ M {x ∷ xs} = C-∪-U⇐ (step M x) {xs}
{ "alphanum_fraction": 0.4291352093, "avg_line_length": 34.587537092, "ext": "agda", "hexsha": "8dc7e4397dc8e292ec2c7d9a5cc427658242a399", "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": "063ae0ce03955b332c3edebae6b55a42209813d0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/formal-language", "max_forks_repo_path": "src/DFA.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "063ae0ce03955b332c3edebae6b55a42209813d0", "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/formal-language", "max_issues_repo_path": "src/DFA.agda", "max_line_length": 105, "max_stars_count": 9, "max_stars_repo_head_hexsha": "063ae0ce03955b332c3edebae6b55a42209813d0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/formal-language", "max_stars_repo_path": "src/DFA.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-22T12:48:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-01T11:24:15.000Z", "num_tokens": 4966, "size": 11656 }
{-# OPTIONS --safe --no-qualified-instances #-} module CF.Transform.Compile.Expressions where open import Function using (_∘_) open import Level open import Data.Unit open import Data.Bool open import Data.Product as P open import Data.List as L hiding (null; [_]) open import Data.List.Membership.Propositional open import Data.List.Membership.Propositional.Properties open import Data.List.Relation.Unary.All open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Unary hiding (_∈_) open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import Relation.Ternary.Monad open import Relation.Ternary.Construct.Bag.Properties private module Src where open import CF.Syntax.DeBruijn public open import CF.Types public open import CF.Contexts.Lexical using (module DeBruijn) public; open DeBruijn public module Tgt where open import JVM.Types public open import JVM.Model StackTy public open import JVM.Syntax.Values public open import JVM.Syntax.Instructions public open Src open Tgt open import JVM.Compiler open import CF.Transform.Compile.ToJVM -- Compilation of CF expressions compileₑₛ : ∀ {as ψ Γ} → Exps as Γ → ε[ Compiler ⟦ Γ ⟧ ψ (⟦ as ⟧ ++ ψ) Emp ] compileₑ : ∀ {a ψ Γ} → Exp a Γ → ε[ Compiler ⟦ Γ ⟧ ψ (⟦ a ⟧ ∷ ψ) Emp ] compileₑ (unit) = do code (push (bool true)) compileₑ (num x) = do code (push (num x)) compileₑ (bool b) = do code (push (bool b)) compileₑ (var' x) = do code (load ⟦ x ⟧) compileₑ (bop f e₁ e₂) = do compileₑ e₁ compileₑ e₂ compile-bop f where -- a < b compiles to (assume a and b on stack): -- -- if_icmplt l⁻ -- iconst_1 -- goto e⁻ -- l⁺: iconst_0 -- e⁺: nop -- -- Other comparisons go similar compile-comp : ∀ {Γ as} → Comparator as → ε[ Compiler Γ (as ++ ψ) (boolean ∷ ψ) Emp ] compile-comp cmp = do ↓ lfalse⁻ ∙⟨ σ ⟩ lfalse⁺ ← ✴-swap ⟨$⟩ freshLabel lfalse⁺ ← ✴-id⁻ˡ ⟨$⟩ (code (if cmp lfalse⁻) ⟨ Up _ # σ ⟩& lfalse⁺) lfalse⁺ ← ✴-id⁻ˡ ⟨$⟩ (code (push (bool false)) ⟨ Up _ # ∙-idˡ ⟩& lfalse⁺) ↓ lend⁻ ∙⟨ σ ⟩ labels ← (✴-rotateₗ ∘ ✴-assocᵣ) ⟨$⟩ (freshLabel ⟨ Up _ # ∙-idˡ ⟩& lfalse⁺) lfalse⁺ ∙⟨ σ ⟩ lend⁺ ← ✴-id⁻ˡ ⟨$⟩ (code (goto lend⁻) ⟨ _ ✴ _ # σ ⟩& labels) lend⁺ ← ✴-id⁻ˡ ⟨$⟩ (attach lfalse⁺ ⟨ Up _ # σ ⟩& lend⁺) code (push (bool true)) attach lend⁺ -- Compile comparisons and other binary operations compile-bop : ∀ {Γ a b c} → BinOp a b c → ε[ Compiler Γ (⟦ b ⟧ ∷ ⟦ a ⟧ ∷ ψ) (⟦ c ⟧ ∷ ψ) Emp ] compile-bop add = code (bop add) compile-bop sub = code (bop sub) compile-bop mul = code (bop mul) compile-bop div = code (bop div) compile-bop xor = code (bop xor) compile-bop eq = compile-comp icmpeq compile-bop ne = compile-comp icmpne compile-bop lt = compile-comp icmplt compile-bop ge = compile-comp icmpge compile-bop gt = compile-comp icmpgt compile-bop le = compile-comp icmplt compileₑ (ifthenelse c e₁ e₂) = do -- condition compileₑ c lthen+ ∙⟨ σ ⟩ ↓ lthen- ← freshLabel lthen+ ← ✴-id⁻ˡ ⟨$⟩ (code (if ne lthen-) ⟨ Up _ # ∙-comm σ ⟩& lthen+) -- else compileₑ e₂ ↓ lend- ∙⟨ σ ⟩ labels ← (✴-rotateₗ ∘ ✴-assocᵣ) ⟨$⟩ (freshLabel ⟨ Up _ # ∙-idˡ ⟩& lthen+) -- then lthen+ ∙⟨ σ ⟩ lend+ ← ✴-id⁻ˡ ⟨$⟩ (code (goto lend-) ⟨ _ ✴ _ # σ ⟩& labels) lend+ ← ✴-id⁻ˡ ⟨$⟩ (attach lthen+ ⟨ Up _ # σ ⟩& lend+) compileₑ e₁ -- label the end attach lend+ compileₑₛ [] = return refl compileₑₛ (e ∷ es) = do compileₑₛ es compileₑ e
{ "alphanum_fraction": 0.6087540279, "avg_line_length": 31.2941176471, "ext": "agda", "hexsha": "36d25c83154e393c50fcf1806b6a7a132b872fad", "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/CF/Transform/Compile/Expressions.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/CF/Transform/Compile/Expressions.agda", "max_line_length": 100, "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/CF/Transform/Compile/Expressions.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": 1344, "size": 3724 }
module _ where record _×_ (A B : Set) : Set where field fst : A snd : B open _×_ partial : ∀ {A B} → A → A × B partial x .fst = x open import Agda.Builtin.Equality theorem : ∀ {A} (x : A) → partial x .snd ≡ x theorem x = refl
{ "alphanum_fraction": 0.5743801653, "avg_line_length": 13.4444444444, "ext": "agda", "hexsha": "c16744418dde3df7fd367def891797b49f934b18", "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/Issue3012.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/Issue3012.agda", "max_line_length": 44, "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/Issue3012.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": 242 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core using (Category) open import Categories.Monad using (Monad) module Categories.Adjoint.Construction.Kleisli {o ℓ e} {C : Category o ℓ e} (M : Monad C) where open import Categories.Category.Construction.Kleisli using (Kleisli) open import Categories.Adjoint using (_⊣_) open import Categories.Functor using (Functor; _∘F_) open import Categories.Morphism using (Iso) open import Categories.Functor.Properties using ([_]-resp-square) open import Categories.NaturalTransformation.Core using (ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_) open import Categories.Morphism.Reasoning C private module C = Category C module M = Monad M open M.F open M using (module μ; module η) open C using (Obj; _⇒_; _∘_; _≈_; ∘-resp-≈ʳ; ∘-resp-≈ˡ; assoc; sym-assoc; identityˡ) open C.HomReasoning open C.Equiv Forgetful : Functor (Kleisli M) C Forgetful = record { F₀ = λ X → F₀ X ; F₁ = λ f → μ.η _ ∘ F₁ f ; identity = M.identityˡ ; homomorphism = λ {X Y Z} {f g} → begin μ.η Z ∘ F₁ ((μ.η Z ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩ μ.η Z ∘ F₁ (μ.η Z ∘ F₁ g) ∘ F₁ f ≈⟨ refl⟩∘⟨ homomorphism ⟩∘⟨refl ⟩ μ.η Z ∘ (F₁ (μ.η Z) ∘ F₁ (F₁ g)) ∘ F₁ f ≈⟨ pull-first M.assoc ⟩ (μ.η Z ∘ μ.η (F₀ Z)) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ center (μ.commute g) ⟩ μ.η Z ∘ (F₁ g ∘ μ.η Y) ∘ F₁ f ≈⟨ pull-first refl ⟩ (μ.η Z ∘ F₁ g) ∘ μ.η Y ∘ F₁ f ∎ ; F-resp-≈ = λ eq → ∘-resp-≈ʳ (F-resp-≈ eq) } Free : Functor C (Kleisli M) Free = record { F₀ = λ X → X ; F₁ = λ f → η.η _ ∘ f ; identity = C.identityʳ ; homomorphism = λ {X Y Z} {f g} → begin η.η Z ∘ g ∘ f ≈⟨ sym-assoc ○ ⟺ identityˡ ⟩ C.id ∘ (η.η Z ∘ g) ∘ f ≈˘⟨ pull-first M.identityˡ ⟩ μ.η Z ∘ (F₁ (η.η Z) ∘ η.η Z ∘ g) ∘ f ≈⟨ refl⟩∘⟨ pushʳ (η.commute g) ⟩∘⟨refl ⟩ μ.η Z ∘ ((F₁ (η.η Z) ∘ F₁ g) ∘ η.η Y) ∘ f ≈˘⟨ center (∘-resp-≈ˡ homomorphism) ⟩ (μ.η Z ∘ F₁ (η.η Z ∘ g)) ∘ η.η Y ∘ f ∎ ; F-resp-≈ = ∘-resp-≈ʳ } FF≃F : Forgetful ∘F Free ≃ M.F FF≃F = record { F⇒G = ntHelper record { η = λ X → F₁ C.id ; commute = λ {X Y} f → begin F₁ C.id ∘ μ.η Y ∘ F₁ (η.η Y ∘ f) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ homomorphism ⟩ F₁ C.id ∘ μ.η Y ∘ F₁ (η.η Y) ∘ F₁ f ≈⟨ refl⟩∘⟨ cancelˡ M.identityˡ ⟩ F₁ C.id ∘ F₁ f ≈⟨ [ M.F ]-resp-square id-comm-sym ⟩ F₁ f ∘ F₁ C.id ∎ } ; F⇐G = ntHelper record { η = λ X → F₁ C.id ; commute = λ {X Y} f → begin F₁ C.id ∘ F₁ f ≈⟨ [ M.F ]-resp-square id-comm-sym ⟩ F₁ f ∘ F₁ C.id ≈˘⟨ cancelˡ M.identityˡ ⟩∘⟨refl ⟩ (μ.η Y ∘ F₁ (η.η Y) ∘ F₁ f) ∘ F₁ C.id ≈˘⟨ ∘-resp-≈ʳ homomorphism ⟩∘⟨refl ⟩ (μ.η Y ∘ F₁ (η.η Y ∘ f)) ∘ F₁ C.id ∎ } ; iso = λ X → record { isoˡ = elimˡ identity ○ identity ; isoʳ = elimˡ identity ○ identity } } Free⊣Forgetful : Free ⊣ Forgetful Free⊣Forgetful = record { unit = ntHelper record { η = η.η ; commute = λ {X Y} f → begin η.η Y ∘ f ≈⟨ η.commute f ⟩ F₁ f ∘ η.η X ≈˘⟨ cancelˡ M.identityˡ ⟩∘⟨refl ⟩ (μ.η Y ∘ F₁ (η.η Y) ∘ F₁ f) ∘ η.η X ≈˘⟨ ∘-resp-≈ʳ homomorphism ⟩∘⟨refl ⟩ (μ.η Y ∘ F₁ (η.η Y ∘ f)) ∘ η.η X ∎ } ; counit = ntHelper record { η = λ X → F₁ C.id ; commute = λ {X Y} f → begin (μ.η Y ∘ F₁ (F₁ C.id)) ∘ η.η (F₀ Y) ∘ μ.η Y ∘ F₁ f ≈⟨ elimʳ (F-resp-≈ identity ○ identity) ⟩∘⟨refl ⟩ μ.η Y ∘ η.η (F₀ Y) ∘ μ.η Y ∘ F₁ f ≈⟨ cancelˡ M.identityʳ ⟩ μ.η Y ∘ F₁ f ≈⟨ introʳ identity ⟩ (μ.η Y ∘ F₁ f) ∘ F₁ C.id ∎ } ; zig = λ {A} → begin (μ.η A ∘ F₁ (F₁ C.id)) ∘ η.η (F₀ A) ∘ η.η A ≈⟨ elimʳ (F-resp-≈ identity ○ identity) ⟩∘⟨refl ⟩ μ.η A ∘ η.η (F₀ A) ∘ η.η A ≈⟨ cancelˡ M.identityʳ ⟩ η.η A ∎ ; zag = λ {B} → begin (μ.η B ∘ F₁ (F₁ C.id)) ∘ η.η (F₀ B) ≈⟨ elimʳ (F-resp-≈ identity ○ identity) ⟩∘⟨refl ⟩ μ.η B ∘ η.η (F₀ B) ≈⟨ M.identityʳ ⟩ C.id ∎ } module KleisliExtension where κ : {A B : Obj} → (f : A ⇒ F₀ B) → F₀ A ⇒ F₀ B κ {_} {B} f = μ.η B ∘ F₁ f f-iso⇒Klf-iso : ∀ {A B : Obj} → (f : A ⇒ F₀ B) → (g : B ⇒ F₀ A) → Iso (Kleisli M) g f → Iso C (κ f) (κ g) f-iso⇒Klf-iso {A} {B} f g (record { isoˡ = isoˡ ; isoʳ = isoʳ }) = record { isoˡ = begin (μ.η A ∘ F₁ g) ∘ μ.η B ∘ F₁ f ≈⟨ center (sym (μ.commute g)) ⟩ μ.η A ∘ (μ.η (F₀ A) ∘ F₁ (F₁ g)) ∘ F₁ f ≈⟨ assoc²'' ○ pushˡ M.sym-assoc ⟩ μ.η A ∘ F₁ (μ.η A) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ refl⟩∘⟨ sym trihom ⟩ μ.η A ∘ F₁ (μ.η A ∘ F₁ g ∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ sym-assoc ⟩ μ.η A ∘ F₁ ((μ.η A ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ isoʳ ○ M.identityˡ ⟩ C.id ∎ ; isoʳ = begin (μ.η B ∘ F₁ f) ∘ μ.η A ∘ F₁ g ≈⟨ center (sym (μ.commute f)) ⟩ μ.η B ∘ (μ.η (F₀ B) ∘ F₁ (F₁ f)) ∘ F₁ g ≈⟨ assoc²'' ○ pushˡ M.sym-assoc ⟩ μ.η B ∘ F₁ (μ.η B) ∘ F₁ (F₁ f) ∘ F₁ g ≈⟨ refl⟩∘⟨ sym trihom ⟩ μ.η B ∘ F₁ (μ.η B ∘ F₁ f ∘ g) ≈⟨ refl⟩∘⟨ F-resp-≈ sym-assoc ⟩ μ.η B ∘ F₁ ((μ.η B ∘ F₁ f) ∘ g) ≈⟨ refl⟩∘⟨ F-resp-≈ isoˡ ○ M.identityˡ ⟩ C.id ∎ } where trihom : {X Y Z W : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} {h : Z ⇒ W} → F₁ (h ∘ g ∘ f) ≈ F₁ h ∘ F₁ g ∘ F₁ f trihom {X} {Y} {Z} {W} {f} {g} {h} = begin F₁ (h ∘ g ∘ f) ≈⟨ homomorphism ⟩ F₁ h ∘ F₁ (g ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩ F₁ h ∘ F₁ g ∘ F₁ f ∎ Klf-iso⇒f-iso : ∀ {A B : Obj} → (f : A ⇒ F₀ B) → (g : B ⇒ F₀ A) → Iso C (κ f) (κ g) → Iso (Kleisli M) g f Klf-iso⇒f-iso {A} {B} f g record { isoˡ = isoˡ ; isoʳ = isoʳ } = record { isoˡ = begin (μ.η B ∘ F₁ f) ∘ g ≈⟨ introʳ M.identityʳ ⟩∘⟨refl ⟩ ((μ.η B ∘ F₁ f) ∘ (μ.η A ∘ η.η (F₀ A))) ∘ g ≈⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩ μ.η B ∘ F₁ f ∘ (μ.η A) ∘ (η.η (F₀ A) ∘ g) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ η.commute g ⟩ μ.η B ∘ F₁ f ∘ μ.η A ∘ (F₁ g ∘ η.η B) ≈˘⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩ ((μ.η B ∘ F₁ f) ∘ μ.η A ∘ F₁ g) ∘ η.η B ≈⟨ elimˡ isoʳ ⟩ η.η B ∎ ; isoʳ = begin (μ.η A ∘ F₁ g) ∘ f ≈⟨ introʳ M.identityʳ ⟩∘⟨refl ⟩ ((μ.η A ∘ F₁ g) ∘ (μ.η B ∘ η.η (F₀ B))) ∘ f ≈⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩ μ.η A ∘ F₁ g ∘ (μ.η B) ∘ (η.η (F₀ B) ∘ f) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ η.commute f ⟩ μ.η A ∘ F₁ g ∘ μ.η B ∘ (F₁ f ∘ η.η A) ≈˘⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩ ((μ.η A ∘ F₁ g) ∘ μ.η B ∘ F₁ f) ∘ η.η A ≈⟨ elimˡ isoˡ ⟩ η.η A ∎ } kl-ext-compat : ∀ {A B X : Obj} → (f : A ⇒ F₀ B) → (g : B ⇒ F₀ X) → κ ((κ g) ∘ f) ≈ κ g ∘ κ f kl-ext-compat {A} {B} {X} f g = begin μ.η X ∘ F₁ ((μ.η X ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ assoc ○ refl⟩∘⟨ trihom ⟩ μ.η X ∘ (F₁ (μ.η X) ∘ F₁ (F₁ g) ∘ F₁ f) ≈⟨ sym-assoc ⟩ (μ.η X ∘ F₁ (μ.η X)) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ M.assoc ⟩∘⟨refl ⟩ (μ.η X ∘ μ.η (F₀ X)) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ center (μ.commute g) ⟩ μ.η X ∘ (F₁ g ∘ μ.η B) ∘ F₁ f ≈⟨ sym-assoc ○ (sym-assoc ⟩∘⟨refl) ○ assoc ⟩ (μ.η X ∘ F₁ g) ∘ μ.η B ∘ F₁ f ∎ where trihom : {X Y Z W : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} {h : Z ⇒ W} → F₁ (h ∘ g ∘ f) ≈ F₁ h ∘ F₁ g ∘ F₁ f trihom {X} {Y} {Z} {W} {f} {g} {h} = begin F₁ (h ∘ g ∘ f) ≈⟨ homomorphism ⟩ F₁ h ∘ F₁ (g ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩ F₁ h ∘ F₁ g ∘ F₁ f ∎
{ "alphanum_fraction": 0.4356768886, "avg_line_length": 47.75, "ext": "agda", "hexsha": "d1d6b6e0839ef20fd77a84d9caeadca889881750", "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": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Adjoint/Construction/Kleisli.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "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": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Adjoint/Construction/Kleisli.agda", "max_line_length": 117, "max_stars_count": 5, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Adjoint/Construction/Kleisli.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "num_tokens": 4039, "size": 8022 }
module TrailingImplicits where -- see also https://lists.chalmers.se/pipermail/agda-dev/2015-January/000041.html open import Common.IO open import Common.Unit open import Common.Nat f : (m : Nat) {l : Nat} -> Nat f zero {l = l} = l f (suc y) = y main : IO Unit main = printNat (f 0 {1}) ,, putStr "\n" ,, printNat (f 30 {1})
{ "alphanum_fraction": 0.6576576577, "avg_line_length": 19.5882352941, "ext": "agda", "hexsha": "0551b3c34ec3470c56daad60302790c6f5807271", "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/TrailingImplicits.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/TrailingImplicits.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/Compiler/simple/TrailingImplicits.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": 120, "size": 333 }
open import Prelude open import Level using (Level; _⊔_; Lift) renaming (zero to lz; suc to ls) open import Data.Maybe using (Maybe; nothing; just) module RW.Utils.Monads where --------------------- -- Monad Typeclass -- --------------------- record Monad {a}(M : Set a → Set a) : Set (ls a) where infixl 1 _>>=_ field return : {A : Set a} → A → M A _>>=_ : {A B : Set a} → M A → (A → M B) → M B open Monad {{...}} mapM : ∀{a}{M : Set a → Set a}{{ m : Monad M}}{A B : Set a} → (A → M B) → List A → M (List B) mapM f [] = return [] mapM f (x ∷ la) = f x >>= (λ x' → mapM f la >>= return ∘ _∷_ x') _>>_ : ∀{a}{M : Set a → Set a}{{ m : Monad M }}{A B : Set a} → M A → M B → M B f >> g = f >>= λ _ → g -- Binds the side-effects of the second computation, -- returning the value of the first. _<>=_ : ∀{a}{M : Set a → Set a}{{ m : Monad M }}{A B : Set a} → M A → (A → M B) → M A f <>= x = f >>= λ r → x r >> return r {- _<$>_ : ∀{a}{A B : Set a}{M : Set a → Set a}{{ m : Monad M }} → (A → B) → M A → M B f <$> x = ? -} ----------------- -- Maybe Monad -- ----------------- _<$>+1_ : ∀{a}{A B : Set a} → (A → B) → Maybe A → Maybe B f <$>+1 x with x ...| nothing = nothing ...| just x' = just (f x') instance MonadMaybe : ∀{a} → Monad {a} Maybe MonadMaybe = record { return = just ; _>>=_ = λ { nothing _ → nothing ; (just x) f → f x } } ----------------- -- State Monad -- ----------------- record ST (s a : Set) : Set where field run : s → (a × s) evalST : ∀{a s} → ST s a → s → a evalST s = p1 ∘ (ST.run s) get : ∀{s} → ST s s get = record { run = λ s → (s , s) } put : ∀{s} → s → ST s Unit put s = record { run = λ _ → (unit , s) } instance MonadState : ∀{s} → Monad (ST s) MonadState = record { return = λ a → record { run = λ s → a , s } ; _>>=_ = λ x f → record { run = λ s → let y = ST.run x s in ST.run (f (p1 y)) (p2 y) } } -- Universe Polymorphic version of the state monad. record STₐ {a b}(s : Set a)(o : Set b) : Set (a ⊔ b) where field run : s → (o × s) evalSTₐ : ∀{a b}{s : Set a}{o : Set b} → STₐ s o → s → o evalSTₐ s = p1 ∘ (STₐ.run s) getₐ : ∀{a}{s : Set a} → STₐ s s getₐ = record { run = λ s → (s , s) } putₐ : ∀{a}{s : Set a} → s → STₐ s Unit putₐ s = record { run = λ _ → (unit , s) } instance MonadStateₐ : ∀{a b}{s : Set a} → Monad {a ⊔ b} (STₐ s) MonadStateₐ = record { return = λ x → record { run = λ s → x , s } ; _>>=_ = λ x f → record { run = λ s → let y = STₐ.run x s in STₐ.run (f (p1 y)) (p2 y) } } ------------- -- Fresh ℕ -- ------------- Freshℕ : Set → Set Freshℕ A = ST ℕ A runFresh : ∀{A} → Freshℕ A → A runFresh f = evalST f 0 runFresh-n : ∀{A} → Freshℕ A → ℕ → A runFresh-n = evalST inc : Freshℕ Unit inc = get >>= (put ∘ suc) ---------------- -- List Monad -- ---------------- NonDet : ∀{a} → Set a → Set a NonDet A = List A NonDetBind : ∀{a}{A B : Set a} → NonDet A → (A → NonDet B) → NonDet B NonDetBind x f = concat (map f x) NonDetRet : ∀{a}{A : Set a} → A → NonDet A NonDetRet x = x ∷ [] instance MonadNonDet : Monad {lz} NonDet MonadNonDet = record { return = NonDetRet ; _>>=_ = NonDetBind } ------------------ -- Reader Monad -- ------------------ Reader : ∀{a b} → Set a → Set b → Set (a ⊔ b) Reader R A = R → A reader-bind : ∀{a b}{R : Set a}{A B : Set b} → Reader R A → (A → Reader R B) → Reader R B reader-bind ra rb = λ r → rb (ra r) r reader-return : ∀{a b}{R : Set a}{A : Set b} → A → Reader R A reader-return a = λ _ → a reader-local : ∀{a b}{R : Set a}{A : Set b} → (R → R) → Reader R A → Reader R A reader-local f ra = ra ∘ f reader-ask : ∀{a}{R : Set a} → Reader R R reader-ask = id instance MonadReader : ∀{a b}{R : Set a} → Monad {b ⊔ a} (Reader {b = b ⊔ a} R) MonadReader = record { return = reader-return ; _>>=_ = reader-bind }
{ "alphanum_fraction": 0.4352996036, "avg_line_length": 25.081871345, "ext": "agda", "hexsha": "837ca69cddc03cd9ca8ba07f78f6abfdcef7ed81", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/Utils/Monads.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/Utils/Monads.agda", "max_line_length": 75, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/Utils/Monads.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 1584, "size": 4289 }
module FStream.FVec where ------------------------------------------------------------------------ -- Dissecting effectful streams ------------------------------------------------------------------------ open import Library open import FStream.Core open import Data.Fin infixr 5 _▻_ infix 6 ⟨_▻⋯ infix 7 _⟩ data FVec {ℓ₁ ℓ₂} (C : Container ℓ₁) (A : Set ℓ₂) : (n : ℕ) → Set (ℓ₁ ⊔ ℓ₂) where FNil : FVec C A 0 FCons : ∀ {n} → ⟦ C ⟧ (A × FVec C A n) → FVec C A (suc n) -- TODO Syntactic sugar for these as well data FVec' {ℓ₁ ℓ₂} (C : Container ℓ₁) (A : Set ℓ₂) : (n : ℕ) → Set (ℓ₁ ⊔ ℓ₂) where FNil' : FVec' C A 0 FCons' : ∀ {n} → A → ⟦ C ⟧ (FVec' C A n) → FVec' C A (suc n) _▻'_ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {n} → A → ⟦ C ⟧ (FVec' C A n) → FVec' C A (suc n) _▻'_ = FCons' fVec'ToFVec : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {n} → FVec' C A n → FVec C A n fVec'ToFVec FNil' = FNil fVec'ToFVec (FCons' a v) = FCons (fmap (λ x → a , fVec'ToFVec x) v) nest : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {n} → Vec (⟦ C ⟧ A) n → FVec C A n nest [] = FNil nest (a ∷ as) = FCons (fmap (_, nest as) a) _▻_ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {n} → ⟦ C ⟧ A → (FVec C A n) → FVec C A (suc n) a ▻ v = FCons (fmap (λ x → x , v) a) _⟩ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} → ⟦ C ⟧ A → FVec C A 1 a ⟩ = a ▻ FNil mutual vmap : ∀ {ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {B : Set ℓ₃} {n} → (f : A → B) → FVec C A n → FVec C B n vmap _ FNil = FNil vmap f (FCons x) = FCons (fmap (vmap' f) x) vmap' : ∀ {ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {B : Set ℓ₃} {n} → (f : A → B) → A × FVec C A n → B × FVec C B n vmap' f (a , v) = f a , vmap f v mutual take : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} → (n : ℕ) → FStream C A → FVec C A n take ℕ.zero as = FNil take (ℕ.suc n) as = FCons (fmap (take' n) (inF as)) take' : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} → (n : ℕ) → FStream' C A → A × FVec C A n proj₁ (take' n as) = head as proj₂ (take' n as) = take n (tail as) take'' : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} → (n : ℕ) → FStream' C A → FVec' C A n take'' zero as = FNil' take'' (suc n) as = FCons' (head as) (fmap (take'' n) (inF (tail as))) _pre⟨_▻⋯' : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {m n} → FVec' C A m → FVec' C A (suc n) → FStream' {i} C A head (FNil' pre⟨ FCons' a _ ▻⋯') = a inF (tail (FNil' pre⟨ FCons' a v ▻⋯')) = fmap (_pre⟨ (FCons' a v) ▻⋯') v head (FCons' x _ pre⟨ v' ▻⋯') = x inF (tail (FCons' _ v pre⟨ v' ▻⋯')) = fmap (_pre⟨ v' ▻⋯') v ⟨_▻⋯' : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {n : ℕ} → FVec' C A (suc n) → FStream' {i} C A ⟨ v ▻⋯' = FNil' pre⟨ v ▻⋯' mutual _pre⟨_▻⋯ : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {m n} → FVec C A m → FVec C A (suc n) → FStream {i} C A inF (FCons x pre⟨ keep ▻⋯) = fmap (_aux keep) x inF (FNil pre⟨ FCons x ▻⋯) = fmap (_aux (FCons x)) x _aux_ : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {n m : ℕ} → A × FVec C A m → FVec C A (suc n) → FStream' {i} C A head ((a , _ ) aux v) = a tail ((_ , v') aux v) = v' pre⟨ v ▻⋯ ⟨_▻⋯ : ∀ {i ℓ₁ ℓ₂} {C : Container ℓ₁} {A : Set ℓ₂} {n : ℕ} → FVec C A (suc n) → FStream {i} C A ⟨ as ▻⋯ = FNil pre⟨ as ▻⋯ data _[_]=_ {a} {A : Set a} {ℓ} {C : Container ℓ} : {n : ℕ} → FVec C A n → Fin n → ⟦ C ⟧ A → Set (a ⊔ ℓ) where here : ∀ {n} {x : ⟦ C ⟧ A} {xs : FVec C A n} → (x ▻ xs) [ zero ]= x there : ∀ {n} {k} {x y} {xs : FVec C A n} → xs [ k ]= x → (y ▻ xs) [ suc k ]= x
{ "alphanum_fraction": 0.4762040467, "avg_line_length": 35.4444444444, "ext": "agda", "hexsha": "dcae8076b53e4a0e661b2b045820e1a4c09c0624", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "zimbatm/condatis", "max_forks_repo_path": "FStream/FVec.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "zimbatm/condatis", "max_issues_repo_path": "FStream/FVec.agda", "max_line_length": 110, "max_stars_count": 1, "max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Aerate/condatis", "max_stars_repo_path": "FStream/FVec.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z", "num_tokens": 1819, "size": 3509 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Integers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Integer where import Data.Nat.Show as ℕ open import Data.Sign as Sign using (Sign) open import Data.String.Base using (String; _++_) ------------------------------------------------------------------------ -- Integers, basic types and operations open import Data.Integer.Base public ------------------------------------------------------------------------ -- Re-export queries from the properties modules open import Data.Integer.Properties public using (_≟_; _≤?_) ------------------------------------------------------------------------ -- Conversions show : ℤ → String show i = showSign (sign i) ++ ℕ.show ∣ i ∣ where showSign : Sign → String showSign Sign.- = "-" showSign Sign.+ = "" ------------------------------------------------------------------------ -- Deprecated -- Version 0.17 open import Data.Integer.Properties public using (◃-cong; drop‿+≤+; drop‿-≤-) renaming (◃-inverse to ◃-left-inverse)
{ "alphanum_fraction": 0.4291808874, "avg_line_length": 26.6363636364, "ext": "agda", "hexsha": "691db53d568fd83279416bca8621e3e2ec13daaa", "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/Integer.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/Integer.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 222, "size": 1172 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Lists.Lists open import Numbers.Naturals.Semiring open import Numbers.Naturals.Naturals open import Numbers.Naturals.Order open import Numbers.BinaryNaturals.Definition open import Semirings.Definition open import Orders.Total.Definition module Numbers.BinaryNaturals.Addition where -- Define the monoid structure, and show that it's the same as ℕ's _+Binherit_ : BinNat → BinNat → BinNat a +Binherit b = NToBinNat (binNatToN a +N binNatToN b) _+B_ : BinNat → BinNat → BinNat [] +B b = b (x :: a) +B [] = x :: a (zero :: xs) +B (y :: ys) = y :: (xs +B ys) (one :: xs) +B (zero :: ys) = one :: (xs +B ys) (one :: xs) +B (one :: ys) = zero :: incr (xs +B ys) +BCommutative : (a b : BinNat) → a +B b ≡ b +B a +BCommutative [] [] = refl +BCommutative [] (x :: b) = refl +BCommutative (x :: a) [] = refl +BCommutative (zero :: as) (zero :: bs) rewrite +BCommutative as bs = refl +BCommutative (zero :: as) (one :: bs) rewrite +BCommutative as bs = refl +BCommutative (one :: as) (zero :: bs) rewrite +BCommutative as bs = refl +BCommutative (one :: as) (one :: bs) rewrite +BCommutative as bs = refl private +BIsInherited[] : (b : BinNat) (prB : b ≡ canonical b) → [] +Binherit b ≡ [] +B b +BIsInherited[] [] prB = refl +BIsInherited[] (zero :: b) prB = t where refine : (b : BinNat) → zero :: b ≡ canonical (zero :: b) → b ≡ canonical b refine b pr with canonical b refine b pr | x :: bl = ::Inj pr t : NToBinNat (0 +N binNatToN (zero :: b)) ≡ zero :: b t with TotalOrder.totality ℕTotalOrder 0 (binNatToN b) t | inl (inl pos) = transitivity (doubleIsBitShift (binNatToN b) pos) (applyEquality (zero ::_) (transitivity (binToBin b) (equalityCommutative (refine b prB)))) t | inl (inr ()) ... | inr eq with binNatToNZero b (equalityCommutative eq) ... | u with canonical b t | inr eq | u | [] = exFalso (bad b prB) where bad : (c : BinNat) → zero :: c ≡ [] → False bad c () t | inr eq | () | x :: bl +BIsInherited[] (one :: b) prB = ans where ans : NToBinNat (binNatToN (one :: b)) ≡ one :: b ans = transitivity (binToBin (one :: b)) (equalityCommutative prB) -- Show that the monoid structure of ℕ is the same as that of BinNat +BIsInherited : (a b : BinNat) (prA : a ≡ canonical a) (prB : b ≡ canonical b) → a +Binherit b ≡ a +B b +BinheritLemma : (a : BinNat) (b : BinNat) (prA : a ≡ canonical a) (prB : b ≡ canonical b) → incr (NToBinNat ((binNatToN a +N binNatToN b) +N ((binNatToN a +N binNatToN b) +N zero))) ≡ one :: (a +B b) +BIsInherited' : (a b : BinNat) → a +Binherit b ≡ canonical (a +B b) +BinheritLemma a b prA prB with TotalOrder.totality ℕTotalOrder 0 (binNatToN a +N binNatToN b) +BinheritLemma a b prA prB | inl (inl x) rewrite doubleIsBitShift (binNatToN a +N binNatToN b) x = applyEquality (one ::_) (+BIsInherited a b prA prB) +BinheritLemma a b prA prB | inr x with sumZeroImpliesSummandsZero (equalityCommutative x) +BinheritLemma a b prA prB | inr x | fst ,, snd = ans2 where bad : b ≡ [] bad = transitivity prB (binNatToNZero b snd) bad2 : a ≡ [] bad2 = transitivity prA (binNatToNZero a fst) ans2 : incr (NToBinNat ((binNatToN a +N binNatToN b) +N ((binNatToN a +N binNatToN b) +N zero))) ≡ one :: (a +B b) ans2 rewrite bad | bad2 = refl +BIsInherited [] b _ prB = +BIsInherited[] b prB +BIsInherited (x :: a) [] prA _ = transitivity (applyEquality NToBinNat (Semiring.commutative ℕSemiring (binNatToN (x :: a)) 0)) (transitivity (binToBin (x :: a)) (equalityCommutative prA)) +BIsInherited (zero :: as) (zero :: b) prA prB with TotalOrder.totality ℕTotalOrder 0 (binNatToN as +N binNatToN b) ... | inl (inl 0<) rewrite Semiring.commutative ℕSemiring (binNatToN as) 0 | Semiring.commutative ℕSemiring (binNatToN b) 0 | Semiring.+Associative ℕSemiring (binNatToN as +N binNatToN as) (binNatToN b) (binNatToN b) | equalityCommutative (Semiring.+Associative ℕSemiring (binNatToN as) (binNatToN as) (binNatToN b)) | Semiring.commutative ℕSemiring (binNatToN as) (binNatToN b) | Semiring.+Associative ℕSemiring (binNatToN as) (binNatToN b) (binNatToN as) | equalityCommutative (Semiring.+Associative ℕSemiring (binNatToN as +N binNatToN b) (binNatToN as) (binNatToN b)) | Semiring.commutative ℕSemiring 0 ((binNatToN as +N binNatToN b) +N (binNatToN as +N binNatToN b)) | equalityCommutative (Semiring.+Associative ℕSemiring (binNatToN as +N binNatToN b) (binNatToN as +N binNatToN b) 0) = transitivity (doubleIsBitShift (binNatToN as +N binNatToN b) (identityOfIndiscernablesRight _<N_ 0< (Semiring.commutative ℕSemiring (binNatToN b) _))) (applyEquality (zero ::_) (+BIsInherited as b (canonicalDescends as prA) (canonicalDescends b prB))) +BIsInherited (zero :: as) (zero :: b) prA prB | inl (inr ()) ... | inr p with sumZeroImpliesSummandsZero {binNatToN as} (equalityCommutative p) +BIsInherited (zero :: as) (zero :: b) prA prB | inr p | as=0 ,, b=0 rewrite as=0 | b=0 = exFalso ans where bad : (b : BinNat) → (pr : b ≡ canonical b) → (pr2 : binNatToN b ≡ 0) → b ≡ [] bad b pr pr2 = transitivity pr (binNatToNZero b pr2) t : b ≡ canonical b t with canonical b t | x :: bl = ::Inj prB u : b ≡ [] u = bad b t b=0 nono : {A : Set} → {a : A} → {as : List A} → a :: as ≡ [] → False nono () ans : False ans with inspect (canonical b) ans | [] with≡ x rewrite x = nono prB ans | (x₁ :: y) with≡ x = nono (transitivity (equalityCommutative x) (transitivity (equalityCommutative t) u)) +BIsInherited (zero :: as) (one :: b) prA prB rewrite Semiring.commutative ℕSemiring (binNatToN as +N (binNatToN as +N zero)) (succ (binNatToN b +N (binNatToN b +N zero))) | Semiring.commutative ℕSemiring (binNatToN b +N (binNatToN b +N zero)) (binNatToN as +N (binNatToN as +N zero)) | equalityCommutative (Semiring.+DistributesOver* ℕSemiring 2 (binNatToN as) (binNatToN b)) = +BinheritLemma as b (canonicalDescends as prA) (canonicalDescends b prB) +BIsInherited (one :: as) (zero :: bs) prA prB rewrite equalityCommutative (Semiring.+DistributesOver* ℕSemiring 2 (binNatToN as) (binNatToN bs)) = +BinheritLemma as bs (canonicalDescends as prA) (canonicalDescends bs prB) +BIsInherited (one :: as) (one :: bs) prA prB rewrite Semiring.commutative ℕSemiring (binNatToN as +N (binNatToN as +N zero)) (succ (binNatToN bs +N (binNatToN bs +N zero))) | Semiring.commutative ℕSemiring (binNatToN bs +N (binNatToN bs +N zero)) (2 *N binNatToN as) | equalityCommutative (Semiring.+DistributesOver* ℕSemiring 2 (binNatToN as) (binNatToN bs)) | +BinheritLemma as bs (canonicalDescends as prA) (canonicalDescends bs prB) = refl +BIsInherited'[] : (b : BinNat) → [] +Binherit b ≡ canonical ([] +B b) +BIsInherited'[] [] = refl +BIsInherited'[] (zero :: b) with inspect (canonical b) +BIsInherited'[] (zero :: b) | [] with≡ pr rewrite binNatToNZero' b pr | pr = refl +BIsInherited'[] (zero :: b) | (x :: bl) with≡ pr rewrite pr = ans where contr : {a : _} {A : Set a} {l1 l2 : List A} → {x : A} → l1 ≡ [] → l1 ≡ x :: l2 → False contr {l1 = []} p1 () contr {l1 = x :: l1} () p2 ans : NToBinNat (binNatToN b +N (binNatToN b +N zero)) ≡ zero :: x :: bl ans with inspect (binNatToN b) ans | zero with≡ th rewrite th = exFalso (contr (binNatToNZero b th) pr) ans | succ th with≡ blah rewrite blah | doubleIsBitShift' th = applyEquality (zero ::_) (transitivity (equalityCommutative u) pr) where u : canonical b ≡ incr (NToBinNat th) u = transitivity (equalityCommutative (binToBin b)) (applyEquality NToBinNat blah) +BIsInherited'[] (one :: b) with inspect (binNatToN b) ... | zero with≡ pr rewrite pr = applyEquality (one ::_) (equalityCommutative (binNatToNZero b pr)) ... | (succ bl) with≡ pr = ans where u : NToBinNat (2 *N binNatToN b) ≡ zero :: canonical b u with doubleIsBitShift' bl ... | t = transitivity (identityOfIndiscernablesLeft _≡_ t (applyEquality (λ i → NToBinNat (2 *N i)) (equalityCommutative pr))) (applyEquality (zero ::_) (transitivity (applyEquality NToBinNat (equalityCommutative pr)) (binToBin b))) ans : incr (NToBinNat (binNatToN b +N (binNatToN b +N zero))) ≡ one :: canonical b ans = applyEquality incr u +BIsInherited' [] b = +BIsInherited'[] b +BIsInherited' (zero :: a) [] with inspect (binNatToN a) +BIsInherited' (zero :: a) [] | zero with≡ x rewrite x | binNatToNZero a x = refl +BIsInherited' (zero :: a) [] | succ y with≡ x rewrite x | Semiring.commutative ℕSemiring (y +N succ (y +N 0)) 0 = transitivity (doubleIsBitShift' y) (transitivity (applyEquality (λ i → (zero :: NToBinNat i)) (equalityCommutative x)) (transitivity (applyEquality (λ i → zero :: i) (binToBin a)) (canonicalAscends' {zero} a bad))) where bad : canonical a ≡ [] → False bad pr with transitivity (equalityCommutative x) (transitivity (equalityCommutative (binNatToNIsCanonical a)) (applyEquality binNatToN pr)) bad pr | () +BIsInherited' (one :: a) [] with inspect (binNatToN a) +BIsInherited' (one :: a) [] | 0 with≡ x rewrite x | binNatToNZero a x = refl +BIsInherited' (one :: a) [] | succ n with≡ x rewrite x | doubleIsBitShift' n = applyEquality incr {_} {zero :: canonical a} (transitivity {x = _} {NToBinNat (2 *N succ n)} bl (transitivity (doubleIsBitShift' n) (applyEquality (zero ::_) (transitivity (applyEquality NToBinNat (equalityCommutative x)) (binToBin a))))) where bl : incr (NToBinNat ((n +N succ (n +N 0)) +N 0)) ≡ NToBinNat (succ (n +N succ (n +N 0))) bl rewrite equalityCommutative x | Semiring.commutative ℕSemiring (n +N succ (n +N 0)) 0 = refl +BIsInherited' (zero :: as) (zero :: bs) rewrite equalityCommutative (Semiring.+DistributesOver* ℕSemiring 2 (binNatToN as) (binNatToN bs)) = ans where ans : NToBinNat (2 *N (binNatToN as +N binNatToN bs)) ≡ canonical (zero :: (as +B bs)) ans with inspect (binNatToN as +N binNatToN bs) ans | zero with≡ x with sumZeroImpliesSummandsZero {binNatToN as} x ... | as=0 ,, bs=0 rewrite as=0 | bs=0 = foo where u : canonical (as +Binherit bs) ≡ [] u rewrite as=0 | bs=0 = refl foo : [] ≡ canonical (zero :: (as +B bs)) foo = transitivity (transitivity b (applyEquality (λ i → canonical (zero :: i)) (+BIsInherited' as bs))) (canonicalAscends'' {zero} (as +B bs)) where b : [] ≡ canonical (zero :: (as +Binherit bs)) b rewrite u = refl ans | succ y with≡ x rewrite x | doubleIsBitShift' y = transitivity (applyEquality (λ i → zero :: NToBinNat i) (equalityCommutative x)) ans2 where u : 0 <N binNatToN (as +B bs) u rewrite equalityCommutative (binNatToNIsCanonical (as +B bs)) | equalityCommutative (+BIsInherited' as bs) | x | nToN (succ y) = succIsPositive y ans2 : zero :: NToBinNat (binNatToN as +N binNatToN bs) ≡ canonical (zero :: (as +B bs)) ans2 rewrite +BIsInherited' as bs = canonicalAscends (as +B bs) u +BIsInherited' (zero :: as) (one :: bs) rewrite Semiring.commutative ℕSemiring (2 *N binNatToN as) (succ (2 *N binNatToN bs)) | Semiring.commutative ℕSemiring (2 *N binNatToN bs) (2 *N binNatToN as) | equalityCommutative (Semiring.+DistributesOver* ℕSemiring 2 (binNatToN as) (binNatToN bs)) = ans2 where ans2 : incr (NToBinNat (2 *N (binNatToN as +N binNatToN bs))) ≡ one :: canonical (as +B bs) ans2 with inspect (binNatToN as +N binNatToN bs) ans2 | zero with≡ x with sumZeroImpliesSummandsZero {binNatToN as} x ans2 | zero with≡ x | as=0 ,, bs=0 rewrite as=0 | bs=0 = applyEquality (one ::_) (transitivity t (+BIsInherited' as bs)) where t : [] ≡ as +Binherit bs t rewrite as=0 | bs=0 = refl ans2 | succ y with≡ x rewrite x | doubleIsBitShift' y = applyEquality (one ::_) (transitivity (applyEquality NToBinNat (equalityCommutative x)) (+BIsInherited' as bs)) +BIsInherited' (one :: as) (zero :: bs) rewrite equalityCommutative (Semiring.+DistributesOver* ℕSemiring 2 (binNatToN as) (binNatToN bs)) = ans where ans : incr (NToBinNat (2 *N (binNatToN as +N binNatToN bs))) ≡ one :: canonical (as +B bs) ans with inspect (binNatToN as +N binNatToN bs) ans | zero with≡ x with sumZeroImpliesSummandsZero {binNatToN as} x ... | as=0 ,, bs=0 rewrite as=0 | bs=0 = applyEquality (one ::_) (transitivity t (+BIsInherited' as bs)) where t : [] ≡ NToBinNat (binNatToN as +N binNatToN bs) t rewrite as=0 | bs=0 = refl ans | succ y with≡ x rewrite x | doubleIsBitShift' y = applyEquality (one ::_) (transitivity (applyEquality NToBinNat (equalityCommutative x)) (+BIsInherited' as bs)) +BIsInherited' (one :: as) (one :: bs) rewrite Semiring.commutative ℕSemiring (2 *N binNatToN as) (succ (2 *N binNatToN bs)) | Semiring.commutative ℕSemiring (2 *N binNatToN bs) (2 *N binNatToN as) | equalityCommutative (Semiring.+DistributesOver* ℕSemiring 2 (binNatToN as) (binNatToN bs)) = ans where ans : incr (incr (NToBinNat (2 *N (binNatToN as +N binNatToN bs)))) ≡ canonical (zero :: incr (as +B bs)) ans with inspect (binNatToN as +N binNatToN bs) ... | zero with≡ x with sumZeroImpliesSummandsZero {binNatToN as} x ans | zero with≡ x | as=0 ,, bs=0 rewrite as=0 | bs=0 = bar where u' : canonical (as +Binherit bs) ≡ [] u' rewrite as=0 | bs=0 = refl u : canonical (as +B bs) ≡ [] u rewrite equalityCommutative (+BIsInherited' as bs) = transitivity (NToBinNatIsCanonical (binNatToN as +N binNatToN bs)) u' t : canonical (incr (as +B bs)) ≡ one :: [] t rewrite incrPreservesCanonical' (as +B bs) | u = refl bar : zero :: one :: [] ≡ canonical (zero :: incr (as +B bs)) bar rewrite t = refl ans | succ y with≡ x rewrite x | doubleIsBitShift' y = transitivity (applyEquality (λ i → zero :: incr (NToBinNat i)) (equalityCommutative x)) ans2 where ans2 : zero :: incr (as +Binherit bs) ≡ canonical (zero :: incr (as +B bs)) ans2 rewrite +BIsInherited' as bs | equalityCommutative (incrPreservesCanonical' (as +B bs)) | canonicalAscends' {zero} (incr (as +B bs)) (incrNonzero (as +B bs)) = refl +BIsHom : (a b : BinNat) → binNatToN (a +B b) ≡ (binNatToN a) +N (binNatToN b) +BIsHom a b = transitivity (equalityCommutative (binNatToNIsCanonical (a +B b))) (transitivity (equalityCommutative (applyEquality binNatToN (+BIsInherited' a b))) (nToN _)) sumCanonical : (a b : BinNat) → canonical a ≡ a → canonical b ≡ b → canonical (a +B b) ≡ a +B b sumCanonical a b a=a b=b = transitivity (equalityCommutative (+BIsInherited' a b)) (+BIsInherited a b (equalityCommutative a=a) (equalityCommutative b=b))
{ "alphanum_fraction": 0.6600884655, "avg_line_length": 70.6490384615, "ext": "agda", "hexsha": "a0a7c84b653976f1d841c01b66587da2827a2870", "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": "Numbers/BinaryNaturals/Addition.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": "Numbers/BinaryNaturals/Addition.agda", "max_line_length": 1043, "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": "Numbers/BinaryNaturals/Addition.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": 5194, "size": 14695 }
{-# OPTIONS --without-K --safe #-} open import Level open import Data.Quiver using (Quiver) -- The Category of (free) paths over a Quiver module Categories.Category.Construction.PathCategory {o ℓ e} (G : Quiver o ℓ e) where open import Function.Base using (_$_) open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties hiding (trans) open import Data.Quiver.Paths open import Categories.Category.Core using (Category) open Quiver G private module P = Paths G open P PathCategory : Category o (o ⊔ ℓ) (o ⊔ ℓ ⊔ e) PathCategory = record { Obj = Obj ; _⇒_ = Star _⇒_ ; _≈_ = _≈*_ ; id = ε ; _∘_ = _▻▻_ ; assoc = λ {_ _ _ _} {f g h} → sym $ ≡⇒≈* $ ◅◅-assoc f g h ; sym-assoc = λ {_ _ _ _} {f g h} → ≡⇒≈* $ ◅◅-assoc f g h ; identityˡ = λ {_ _ f} → ◅◅-identityʳ f ; identityʳ = refl ; identity² = refl ; equiv = isEquivalence ; ∘-resp-≈ = resp } where resp : ∀ {A B C} {f h : Star _⇒_ B C} {g i : Star _⇒_ A B} → f ≈* h → g ≈* i → (f ▻▻ g) ≈* (h ▻▻ i) resp eq ε = eq resp eq (eq₁ ◅ eq₂) = eq₁ ◅ (resp eq eq₂)
{ "alphanum_fraction": 0.5962680237, "avg_line_length": 29.475, "ext": "agda", "hexsha": "ed7dfe903e3b196dc324108bcb0c69181002707f", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/PathCategory.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Construction/PathCategory.agda", "max_line_length": 91, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Construction/PathCategory.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 451, "size": 1179 }
-- Andreas, 2019-02-03, issue #3541: -- Treat indices like parameters in positivity check. data Works (A : Set) : Set where nest : Works (Works A) → Works A data Foo : Set → Set where foo : ∀{A} → Foo (Foo A) → Foo A -- Should pass.
{ "alphanum_fraction": 0.6333333333, "avg_line_length": 21.8181818182, "ext": "agda", "hexsha": "b086fcc65a57d4670795fb1f3f2520cfa6f95e87", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/Succeed/Issue3541.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue3541.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue3541.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 77, "size": 240 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core open import Categories.Object.Terminal hiding (up-to-iso) module Categories.Object.NaturalNumber {o ℓ e} (𝒞 : Category o ℓ e) (𝒞-Terminal : Terminal 𝒞) where open import Level open import Categories.Morphism 𝒞 open import Categories.Morphism.Reasoning 𝒞 open Category 𝒞 open HomReasoning open Equiv open Terminal 𝒞-Terminal private variable A B C D X Y Z : Obj h i j : A ⇒ B record IsNaturalNumber (N : Obj) : Set (o ⊔ ℓ ⊔ e) where field z : ⊤ ⇒ N s : N ⇒ N universal : ∀ {A} → ⊤ ⇒ A → A ⇒ A → N ⇒ A z-commute : ∀ {A} {q : ⊤ ⇒ A} {f : A ⇒ A} → q ≈ universal q f ∘ z s-commute : ∀ {A} {q : ⊤ ⇒ A} {f : A ⇒ A} → f ∘ universal q f ≈ universal q f ∘ s unique : ∀ {A} {q : ⊤ ⇒ A} {f : A ⇒ A} {u : N ⇒ A} → q ≈ u ∘ z → f ∘ u ≈ u ∘ s → u ≈ universal q f η : universal z s ≈ id η = ⟺ (unique (⟺ identityˡ) id-comm) universal-cong : ∀ {A} → {f f′ : ⊤ ⇒ A} → {g g′ : A ⇒ A} → f ≈ f′ → g ≈ g′ → universal f g ≈ universal f′ g′ universal-cong f≈f′ g≈g′ = unique (⟺ f≈f′ ○ z-commute) (∘-resp-≈ˡ (⟺ g≈g′) ○ s-commute) record NaturalNumber : Set (o ⊔ ℓ ⊔ e) where field N : Obj isNaturalNumber : IsNaturalNumber N open IsNaturalNumber isNaturalNumber public open NaturalNumber module _ (N : NaturalNumber) (N′ : NaturalNumber) where private module N = NaturalNumber N module N′ = NaturalNumber N′ up-to-iso : N.N ≅ N′.N up-to-iso = record { from = N.universal N′.z N′.s ; to = N′.universal N.z N.s ; iso = record { isoˡ = universal-∘ N N′ ; isoʳ = universal-∘ N′ N } } where universal-∘ : ∀ (N N′ : NaturalNumber) → universal N′ (z N) (s N) ∘ universal N (z N′) (s N′) ≈ id universal-∘ N N′ = unique N (z-commute N′ ○ pushʳ (z-commute N)) (pullˡ (s-commute N′) ○ assoc ○ ∘-resp-≈ʳ (s-commute N) ○ ⟺ assoc) ○ (η N)
{ "alphanum_fraction": 0.5659197499, "avg_line_length": 29.0757575758, "ext": "agda", "hexsha": "6362992022cb42a5761147dff881505258d17675", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_line_length": 145, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 769, "size": 1919 }
-- A Beth model of normal forms open import Library module NfModelCaseTreeConv (Base : Set) where import Formulas ; open module Form = Formulas Base import Derivations; open module Der = Derivations Base -- Beth model data Cover (P : Cxt → Set) (Γ : Cxt) : Set where returnC : (p : P Γ) → Cover P Γ falseC : (t : Ne Γ False) → Cover P Γ orC : ∀{C D} (t : Ne Γ (C ∨ D)) (c : Cover P (Γ ∙ C)) (d : Cover P (Γ ∙ D)) → Cover P Γ -- Syntactic paste pasteNf : ∀{A} → Cover (Nf' A) →̇ Nf' A pasteNf (returnC p) = p pasteNf (falseC t) = falseE t pasteNf (orC t c d) = orE t (pasteNf c) (pasteNf d) -- Weakening covers: A case tree in Γ can be transported to a thinning Δ -- by weakening all the scrutinees. monC : ∀{P} → (monP : Mon P) → Mon (Cover P) monC monP τ (returnC p) = returnC (monP τ p) monC monP τ (falseC t) = falseC (monNe τ t) monC monP τ (orC t c d) = orC (monNe τ t) (monC monP (lift τ) c) (monC monP (lift τ) d) -- Monad mapC : ∀{P Q} → (P →̇ Q) → (Cover P →̇ Cover Q) mapC f (returnC p) = returnC (f p) mapC f (falseC t) = falseC t mapC f (orC t c d) = orC t (mapC f c) (mapC f d) joinC : ∀{P} → Cover (Cover P) →̇ Cover P joinC (returnC p) = p joinC (falseC t) = falseC t joinC (orC t c d) = orC t (joinC c) (joinC d) -- Version of mapC with f relativized to subcontexts of Γ mapC' : ∀{P Q Γ} → KFun P Q Γ → Cover P Γ → Cover Q Γ mapC' f (returnC p) = returnC (f id≤ p) mapC' f (falseC t) = falseC t mapC' f (orC t c d) = orC t (mapC' (λ τ → f (τ • weak id≤)) c) (mapC' (λ τ → f (τ • weak id≤)) d) Conv : (Δ₀ : Cxt) (P Q : Cxt → Set) → Set Conv Δ₀ P Q = ∀{Γ Δ} (δ : Δ ≤ Δ₀) (τ : Δ ≤ Γ) → P Γ → Q Δ convC : ∀{Δ₀} {P Q} → Conv Δ₀ P Q → Conv Δ₀ (Cover P) (Cover Q) convC {Δ₀} {P} {Q} f {Γ} {Δ} δ τ (returnC p) = returnC (f δ τ p) convC {Δ₀} {P} {Q} f {Γ} {Δ} δ τ (falseC t) = falseC (monNe τ t) convC {Δ₀} {P} {Q} f {Γ} {Δ} δ τ (orC t c d) = orC (monNe τ t) (convC {Δ₀} f (weak δ) (lift τ) c) (convC {Δ₀} f (weak δ) (lift τ) d) -- The syntactic Beth model. -- We interpret base propositions Atom P by their normal deriviations. -- ("Normal" is important; "neutral is not sufficient since we need case trees here.) -- The negative connectives True, ∧, and ⇒ are explained as usual by η-expansion -- and the meta-level connective. -- The positive connectives False and ∨ are inhabited by case trees. -- In case False, the tree has no leaves. -- In case A ∨ B, each leaf must be in the semantics of either A or B. T⟦_⟧ : (A : Form) (Γ : Cxt) → Set T⟦ Atom P ⟧ = Nf' (Atom P) T⟦ True ⟧ Γ = ⊤ T⟦ False ⟧ = Cover λ Δ → ⊥ T⟦ A ∨ B ⟧ = Cover λ Δ → T⟦ A ⟧ Δ ⊎ T⟦ B ⟧ Δ T⟦ A ∧ B ⟧ Γ = T⟦ A ⟧ Γ × T⟦ B ⟧ Γ T⟦ A ⇒ B ⟧ Γ = ∀{Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Δ → T⟦ B ⟧ Δ -- Monotonicity of the model is proven by induction on the proposition, -- using monotonicity of covers and the built-in monotonicity at implication. -- monT : ∀ A {Γ Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Γ → T⟦ A ⟧ Δ monT : ∀ A → Mon T⟦ A ⟧ monT (Atom P) = monNf monT True = _ monT False = monC λ τ () monT (A ∨ B) = monC λ τ → map-⊎ (monT A τ) (monT B τ) monT (A ∧ B) τ (a , b) = monT A τ a , monT B τ b monT (A ⇒ B) τ f σ = f (σ • τ) -- Reflection / reification, proven simultaneously by induction on the proposition. -- Reflection is η-expansion (and recursively reflection); -- at positive connections we build a case tree with a single scrutinee: the neutral -- we are reflecting. -- At implication, we need reification, which produces introductions -- and reifies the stored case trees. mutual fresh : ∀ {Γ} A → T⟦ A ⟧ (Γ ∙ A) fresh A = reflect A (hyp top) reflect : ∀ A → Ne' A →̇ T⟦ A ⟧ reflect (Atom P) t = ne t reflect True t = _ reflect False t = falseC t reflect (A ∨ B) t = orC t (returnC (inj₁ (fresh A))) (returnC (inj₂ (fresh B))) reflect (A ∧ B) t = reflect A (andE₁ t) , reflect B (andE₂ t) reflect (A ⇒ B) t τ a = reflect B (impE (monNe τ t) (reify A a)) reify : ∀ A → T⟦ A ⟧ →̇ Nf' A reify (Atom P) t = t reify True _ = trueI reify False = pasteNf ∘ mapC ⊥-elim reify (A ∨ B) = pasteNf ∘ mapC [ orI₁ ∘ reify A , orI₂ ∘ reify B ] reify (A ∧ B) (a , b) = andI (reify A a) (reify B b) reify (A ⇒ B) ⟦f⟧ = impI (reify B (⟦f⟧ (weak id≤) (fresh A))) -- Semantic paste. paste : ∀ A → Cover T⟦ A ⟧ →̇ T⟦ A ⟧ paste (Atom P) = pasteNf paste True = _ paste False = joinC paste (A ∨ B) = joinC paste (A ∧ B) = < paste A ∘ mapC proj₁ , paste B ∘ mapC proj₂ > paste (A ⇒ B) c τ a = paste B (convC (λ δ τ' f → f τ' (monT A δ a)) id≤ τ c) -- Fundamental theorem -- Extension of T⟦_⟧ to contexts G⟦_⟧ : ∀ (Γ Δ : Cxt) → Set G⟦ ε ⟧ Δ = ⊤ G⟦ Γ ∙ A ⟧ Δ = G⟦ Γ ⟧ Δ × T⟦ A ⟧ Δ -- monG : ∀{Γ Δ Φ} (τ : Φ ≤ Δ) → G⟦ Γ ⟧ Δ → G⟦ Γ ⟧ Φ monG : ∀{Γ} → Mon G⟦ Γ ⟧ monG {ε} τ _ = _ monG {Γ ∙ A} τ (γ , a) = monG τ γ , monT A τ a -- Variable case. lookup : ∀{Γ A} (x : Hyp A Γ) → G⟦ Γ ⟧ →̇ T⟦ A ⟧ lookup top = proj₂ lookup (pop x) = lookup x ∘ proj₁ -- A lemma for the orE case. orElim : ∀ A B C {Γ} → T⟦ A ∨ B ⟧ Γ → T⟦ A ⇒ C ⟧ Γ → T⟦ B ⇒ C ⟧ Γ → T⟦ C ⟧ Γ orElim A B C c g h = paste C (mapC' (λ τ → [ g τ , h τ ]) c) -- A lemma for the falseE case. -- Casts an empty cover into any semantic value (by contradiction). falseElim : ∀ C → T⟦ False ⟧ →̇ T⟦ C ⟧ falseElim C = paste C ∘ mapC ⊥-elim -- The fundamental theorem eval : ∀{A Γ} (t : Γ ⊢ A) → G⟦ Γ ⟧ →̇ T⟦ A ⟧ eval (hyp x) = lookup x eval (impI t) γ τ a = eval t (monG τ γ , a) eval (impE t u) γ = eval t γ id≤ (eval u γ) eval (andI t u) γ = eval t γ , eval u γ eval (andE₁ t) = proj₁ ∘ eval t eval (andE₂ t) = proj₂ ∘ eval t eval (orI₁ t) γ = returnC (inj₁ (eval t γ)) eval (orI₂ t) γ = returnC (inj₂ (eval t γ)) eval (orE {A = A} {B} {C} t u v) γ = orElim A B C (eval t γ) (λ τ a → eval u (monG τ γ , a)) (λ τ b → eval v (monG τ γ , b)) eval {C} (falseE t) γ = falseElim C (eval t γ) eval trueI γ = _ -- Identity environment ide : ∀ Γ → G⟦ Γ ⟧ Γ ide ε = _ ide (Γ ∙ A) = monG (weak id≤) (ide Γ) , reflect A (hyp top) -- Normalization norm : ∀{A} → Tm A →̇ Nf' A norm t = reify _ (eval t (ide _)) -- Q.E.D. -}
{ "alphanum_fraction": 0.5485923334, "avg_line_length": 31.1237623762, "ext": "agda", "hexsha": "f7837c29a6787a544f4c16505b57fcdb57b2f463", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z", "max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "andreasabel/ipl", "max_forks_repo_path": "src/NfModelCaseTreeConv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "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": "andreasabel/ipl", "max_issues_repo_path": "src/NfModelCaseTreeConv.agda", "max_line_length": 85, "max_stars_count": 19, "max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "andreasabel/ipl", "max_stars_repo_path": "src/NfModelCaseTreeConv.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z", "num_tokens": 2641, "size": 6287 }
------------------------------------------------------------------------ -- Compatibility lemmas ------------------------------------------------------------------------ open import Atom module Compatibility (atoms : χ-atoms) where open import Bag-equivalence hiding (trans) open import Equality.Propositional open import Prelude hiding (const) open import Tactic.By open import List equality-with-J using (map) open import Chi atoms open import Constants atoms open import Reasoning atoms open import Values atoms open χ-atoms atoms -- A compatibility lemma that does not hold. ¬-⇓-[←]-right : ¬ (∀ {e′ v′} e x {v} → e′ ⇓ v′ → e [ x ← v′ ] ⇓ v → e [ x ← e′ ] ⇓ v) ¬-⇓-[←]-right hyp = ¬e[x←e′]⇓v (hyp e x e′⇓v′ e[x←v′]⇓v) where x : Var x = v-x e′ v′ e v : Exp e′ = apply (lambda v-x (var v-x)) (const c-true []) v′ = const c-true [] e = lambda v-y (var v-x) v = lambda v-y (const c-true []) e′⇓v′ : e′ ⇓ v′ e′⇓v′ = apply lambda (const []) (case v-x V.≟ v-x return (λ b → if b then const c-true [] else var v-x ⇓ v′) of (λ where (yes _) → const [] (no x≢x) → ⊥-elim (x≢x refl))) lemma : ∀ v → e [ x ← v ] ≡ lambda v-y v lemma _ with v-x V.≟ v-y ... | yes x≡y = ⊥-elim (V.distinct-codes→distinct-names (λ ()) x≡y) ... | no _ with v-x V.≟ v-x ... | yes _ = refl ... | no x≢x = ⊥-elim (x≢x refl) e[x←v′]⇓v : e [ x ← v′ ] ⇓ v e[x←v′]⇓v = e [ x ← v′ ] ≡⟨ lemma _ ⟩⟶ lambda v-y v′ ⇓⟨ lambda ⟩■ v ¬e[x←e′]⇓v : ¬ e [ x ← e′ ] ⇓ v ¬e[x←e′]⇓v p with _[_←_] e x e′ | lemma e′ ¬e[x←e′]⇓v () | ._ | refl mutual -- Contexts. data Context : Type where ∙ : Context apply←_ : Context → {e : Exp} → Context apply→_ : {e : Exp} → Context → Context const : {c : Const} → Context⋆ → Context case : Context → {bs : List Br} → Context data Context⋆ : Type where here : Context → {es : List Exp} → Context⋆ there : {e : Exp} → Context⋆ → Context⋆ mutual -- Filling a context's hole (∙) with an expression. infix 6 _[_] _[_]⋆ _[_] : Context → Exp → Exp ∙ [ e ] = e apply←_ c {e = e′} [ e ] = apply (c [ e ]) e′ apply→_ {e = e′} c [ e ] = apply e′ (c [ e ]) const {c = c′} c [ e ] = const c′ (c [ e ]⋆) case c {bs = bs} [ e ] = case (c [ e ]) bs _[_]⋆ : Context⋆ → Exp → List Exp here c {es = es} [ e ]⋆ = (c [ e ]) ∷ es there {e = e′} c [ e ]⋆ = e′ ∷ (c [ e ]⋆) mutual -- If e₁ terminates with v₁ and c [ v₁ ] terminates with v₂, then -- c [ e₁ ] also terminates with v₂. []⇓ : ∀ c {e₁ v₁ v₂} → e₁ ⇓ v₁ → c [ v₁ ] ⇓ v₂ → c [ e₁ ] ⇓ v₂ []⇓ ∙ {e₁} {v₁} {v₂} p q = e₁ ⇓⟨ p ⟩ v₁ ⇓⟨ q ⟩■ v₂ []⇓ (apply← c) p (apply q r s) = apply ([]⇓ c p q) r s []⇓ (apply→ c) p (apply q r s) = apply q ([]⇓ c p r) s []⇓ (const c) p (const ps) = const ([]⇓⋆ c p ps) []⇓ (case c) p (case q r s t) = case ([]⇓ c p q) r s t []⇓⋆ : ∀ c {e v vs} → e ⇓ v → c [ v ]⋆ ⇓⋆ vs → c [ e ]⋆ ⇓⋆ vs []⇓⋆ (here c) p (q ∷ qs) = []⇓ c p q ∷ qs []⇓⋆ (there c) p (q ∷ qs) = q ∷ []⇓⋆ c p qs
{ "alphanum_fraction": 0.4447244094, "avg_line_length": 26.6806722689, "ext": "agda", "hexsha": "185f44aa68e55f43c245bf6e23a39de449883e89", "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": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/chi", "max_forks_repo_path": "src/Compatibility.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/chi", "max_issues_repo_path": "src/Compatibility.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/chi", "max_stars_repo_path": "src/Compatibility.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "num_tokens": 1370, "size": 3175 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} {-# OPTIONS --allow-unsolved-metas #-} open import Optics.All open import LibraBFT.Prelude open import LibraBFT.Hash open import LibraBFT.Lemmas open import LibraBFT.Base.KVMap open import LibraBFT.Base.PKCS open import LibraBFT.Abstract.Types open import LibraBFT.Impl.NetworkMsg open import LibraBFT.Impl.Consensus.Types open import LibraBFT.Impl.Util.Crypto open import LibraBFT.Impl.Handle sha256 sha256-cr open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Yasm.Base open import LibraBFT.Yasm.AvailableEpochs using (AvailableEpochs ; lookup'; lookup'') open import LibraBFT.Yasm.System ConcSysParms open import LibraBFT.Yasm.Properties ConcSysParms -- This module defines an abstract system state given a reachable -- concrete system state. -- An implementation must prove that, if one of its handlers sends a -- message that contains a vote and is signed by a public key pk, then -- either the vote's author is the peer executing the handler, the -- epochId is in range, the peer is a member of the epoch, and its key -- in that epoch is pk; or, a message with the same signature has been -- sent before. This is represented by StepPeerState-AllValidParts. module LibraBFT.Concrete.System (sps-corr : StepPeerState-AllValidParts) where -- Bring in 'unwind', 'ext-unforgeability' and friends open Structural sps-corr -- TODO-1: refactor this somewhere else? Maybe something like -- LibraBFT.Impl.Consensus.Types.Properties? sameHonestSig⇒sameVoteData : ∀ {v1 v2 : Vote} {pk} → Meta-Honest-PK pk → WithVerSig pk v1 → WithVerSig pk v2 → v1 ^∙ vSignature ≡ v2 ^∙ vSignature → NonInjective-≡ sha256 ⊎ v2 ^∙ vVoteData ≡ v1 ^∙ vVoteData sameHonestSig⇒sameVoteData {v1} {v2} hpk wvs1 wvs2 refl with verify-bs-inj (verified wvs1) (verified wvs2) -- The signable fields of the votes must be the same (we do not model signature collisions) ...| bs≡ -- Therefore the LedgerInfo is the same for the new vote as for the previous vote = sym <⊎$> (hashVote-inj1 {v1} {v2} (sameBS⇒sameHash bs≡)) honestVoteProps : ∀ {e st} → ReachableSystemState {e} st → ∀ {pk nm v sender} → Meta-Honest-PK pk → v ⊂Msg nm → (sender , nm) ∈ msgPool st → WithVerSig pk v → NonInjective-≡ sha256 ⊎ v ^∙ vEpoch < e honestVoteProps r hpk v⊂m m∈pool ver with honestPartValid r hpk v⊂m m∈pool ver ...| msg , valid = ⊎-map id (λ { refl → vp-epoch valid }) (sameHonestSig⇒sameVoteData hpk ver (msgSigned msg) (sym (msgSameSig msg))) -- We are now ready to define an 'AbsSystemState' view for a concrete -- reachable state. We will do so by fixing an epoch that exists in -- the system, which will enable us to define the abstract -- properties. The culminaton of this 'PerEpoch' module is seen in -- the 'ConcSysState' "function" at the bottom, which probably the -- best place to start uynderstanding this. Longer term, we will -- also need higher-level, cross-epoch properties. module PerState {e}(st : SystemState e)(r : ReachableSystemState st) where -- TODO-3: Remove this postulate when we are satisfied with the -- "hash-collision-tracking" solution. For example, when proving voo -- (in LibraBFT.LibraBFT.Concrete.Properties.VotesOnce), we -- currently use this postulate to eliminate the possibility of two -- votes that have the same signature but different VoteData -- whenever we use sameHonestSig⇒sameVoteData. To eliminate the -- postulate, we need to refine the properties we prove to enable -- the possibility of a hash collision, in which case the required -- property might not hold. However, it is not sufficient to simply -- prove that a hash collision *exists* (which is obvious, -- regardless of the LibraBFT implementation). Rather, we -- ultimately need to produce a specific hash collision and relate -- it to the data in the system, so that we can prove that the -- desired properties hold *unless* an actual hash collision is -- found by the implementation given the data in the system. In -- the meantime, we simply require that the collision identifies a -- reachable state; later "collision tracking" will require proof -- that the colliding values actually exist in that state. postulate -- temporary meta-sha256-cr : ¬ (NonInjective-≡ sha256) module PerEpoch (eid : Fin e) where open import LibraBFT.Yasm.AvailableEpochs 𝓔 : EpochConfig 𝓔 = lookup' (availEpochs st) eid open EpochConfig open import LibraBFT.Abstract.System 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) open import LibraBFT.Concrete.Records 𝓔 import LibraBFT.Abstract.Records 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) as Abs -- * Auxiliary definitions; -- TODO-1: simplify and cleanup record QcPair (q : Abs.QC) : Set where constructor mkQcPair field cqc : QuorumCert isv : IsValidQC 𝓔 cqc q≡αcqc : q ≡ α-QC (cqc , isv) open QcPair qc-α-Sent⇒ : ∀ {st q} → (Abs.Q q) α-Sent st → QcPair q qc-α-Sent⇒ (ws _ _ (qc∈NM {cqc} isv _ q≡)) = mkQcPair cqc isv q≡ record ConcBits {q α} (va∈q : α Abs.∈QC q) (qcp : QcPair q) : Set where constructor mkConcBits field as : Author × Signature as∈cqc : as ∈ qcVotes (cqc qcp) αVote≡ : Any-lookup va∈q ≡ α-Vote (cqc qcp) (isv qcp) as∈cqc open ConcBits qcp⇒concBits : ∀ {q α} → (qcp : QcPair q) → (va∈q : α Abs.∈QC q) → ConcBits va∈q qcp qcp⇒concBits qcp va∈q with All-reduce⁻ {vdq = Any-lookup va∈q} (α-Vote (cqc qcp) (isv qcp)) All-self (subst (Any-lookup va∈q ∈_) (cong Abs.qVotes (q≡αcqc qcp)) (Any-lookup-correctP va∈q)) ...| as , as∈cqc , α≡ = mkConcBits as as∈cqc α≡ -- This record is highly duplicated; but it does provide a simple way to access -- all the properties from an /honest vote/ record Vote∈QcProps {q} (qcp : QcPair q) {α} (α∈q : α Abs.∈QC q) : Set₁ where constructor mkV∈QcP field ev : ConcreteVoteEvidence 𝓔 (Abs.∈QC-Vote q α∈q) as : Author × Signature as∈qc : as ∈ qcVotes (cqc qcp) rbld : ₋cveVote ev ≈Vote rebuildVote (cqc qcp) as vote∈QcProps : ∀ {q α st} → (αSent : Abs.Q q α-Sent st) → (α∈q : α Abs.∈QC q) → Vote∈QcProps {q} (qc-α-Sent⇒ αSent) α∈q vote∈QcProps {q} {α} αSent va∈q with All-lookup (Abs.qVotes-C5 q) (Abs.∈QC-Vote-correct q va∈q) ...| ev with qc-α-Sent⇒ αSent ...| qcp with qcp⇒concBits qcp va∈q ...| mkConcBits as' as∈cqc αVote≡' = mkV∈QcP ev as' as∈cqc (voteInEvidence≈rebuiltVote {valid = isv qcp} as∈cqc ev αVote≡') -- Here we capture the idea that there exists a vote message that -- witnesses the existence of a given Abs.Vote record ∃VoteMsgFor (v : Abs.Vote) : Set where constructor mk∃VoteMsgFor field -- A message that was actually sent nm : NetworkMsg cv : Vote cv∈nm : cv ⊂Msg nm -- And contained a valid vote that, once abstracted, yeilds v. vmsgMember : Member 𝓔 vmsgSigned : WithVerSig (getPubKey 𝓔 vmsgMember) cv vmsg≈v : α-ValidVote 𝓔 cv vmsgMember ≡ v vmsgEpoch : cv ^∙ vEpoch ≡ epochId 𝓔 open ∃VoteMsgFor public record ∃VoteMsgSentFor (sm : SentMessages)(v : Abs.Vote) : Set where constructor mk∃VoteMsgSentFor field vmFor : ∃VoteMsgFor v vmSender : NodeId nmSentByAuth : (vmSender , (nm vmFor)) ∈ sm open ∃VoteMsgSentFor public ∃VoteMsgSentFor-stable : ∀ {e e'} {pre : SystemState e} {post : SystemState e'} {v} → Step pre post → ∃VoteMsgSentFor (msgPool pre) v → ∃VoteMsgSentFor (msgPool post) v ∃VoteMsgSentFor-stable theStep (mk∃VoteMsgSentFor sndr vmFor sba) = mk∃VoteMsgSentFor sndr vmFor (msgs-stable theStep sba) record ∃VoteMsgInFor (outs : List NetworkMsg)(v : Abs.Vote) : Set where constructor mk∃VoteMsgInFor field vmFor : ∃VoteMsgFor v nmInOuts : nm vmFor ∈ outs open ∃VoteMsgInFor public ∈QC⇒sent : ∀{e} {st : SystemState e} {q α} → Abs.Q q α-Sent (msgPool st) → Meta-Honest-Member 𝓔 α → (vα : α Abs.∈QC q) → ∃VoteMsgSentFor (msgPool st) (Abs.∈QC-Vote q vα) ∈QC⇒sent {e} {st} {α = α} vsent@(ws {sender} {nm} e≡ nm∈st (qc∈NM {cqc} {q} .{nm} valid cqc∈nm cqc≡)) ha va with vote∈QcProps vsent va ...| mkV∈QcP ev _ as∈qc rbld with vote∈qc as∈qc rbld cqc∈nm ...| v∈nm = mk∃VoteMsgSentFor (mk∃VoteMsgFor nm (₋cveVote ev) v∈nm (₋ivvMember (₋cveIsValidVote ev)) (₋ivvSigned (₋cveIsValidVote ev)) (₋cveIsAbs ev) (₋ivvEpoch (₋cveIsValidVote ev))) sender nm∈st -- Finally, we can define the abstract system state corresponding to the concrete state st ConcSystemState : AbsSystemState ℓ0 ConcSystemState = record { InSys = λ { r → r α-Sent (msgPool st) } ; HasBeenSent = λ { v → ∃VoteMsgSentFor (msgPool st) v } ; ∈QC⇒HasBeenSent = ∈QC⇒sent {st = st} }
{ "alphanum_fraction": 0.6321464903, "avg_line_length": 43.1140350877, "ext": "agda", "hexsha": "bbf96f177f9b8ecd26d7b058d21a66be66794f42", "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": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_forks_repo_path": "LibraBFT/Concrete/System.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "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": "lisandrasilva/bft-consensus-agda-1", "max_issues_repo_path": "LibraBFT/Concrete/System.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_stars_repo_path": "LibraBFT/Concrete/System.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3132, "size": 9830 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Morphism.Properties {o ℓ e} (𝒞 : Category o ℓ e) where open import Data.Product using (_,_; _×_) open Category 𝒞 open HomReasoning import Categories.Morphism as M open M 𝒞 open import Categories.Morphism.Reasoning 𝒞 private variable A B C D : Obj f g h i : A ⇒ B module _ (iso : Iso f g) where open Iso iso Iso-resp-≈ : f ≈ h → g ≈ i → Iso h i Iso-resp-≈ {h = h} {i = i} eq₁ eq₂ = record { isoˡ = begin i ∘ h ≈˘⟨ eq₂ ⟩∘⟨ eq₁ ⟩ g ∘ f ≈⟨ isoˡ ⟩ id ∎ ; isoʳ = begin h ∘ i ≈˘⟨ eq₁ ⟩∘⟨ eq₂ ⟩ f ∘ g ≈⟨ isoʳ ⟩ id ∎ } Iso-swap : Iso g f Iso-swap = record { isoˡ = isoʳ ; isoʳ = isoˡ } Iso⇒Mono : Mono f Iso⇒Mono h i eq = begin h ≈⟨ introˡ isoˡ ⟩ (g ∘ f) ∘ h ≈⟨ pullʳ eq ⟩ g ∘ f ∘ i ≈⟨ cancelˡ isoˡ ⟩ i ∎ Iso⇒Epi : Epi f Iso⇒Epi h i eq = begin h ≈⟨ introʳ isoʳ ⟩ h ∘ f ∘ g ≈⟨ pullˡ eq ⟩ (i ∘ f) ∘ g ≈⟨ cancelʳ isoʳ ⟩ i ∎ Iso-∘ : Iso f g → Iso h i → Iso (h ∘ f) (g ∘ i) Iso-∘ {f = f} {g = g} {h = h} {i = i} iso iso′ = record { isoˡ = begin (g ∘ i) ∘ h ∘ f ≈⟨ cancelInner (isoˡ iso′) ⟩ g ∘ f ≈⟨ isoˡ iso ⟩ id ∎ ; isoʳ = begin (h ∘ f) ∘ g ∘ i ≈⟨ cancelInner (isoʳ iso) ⟩ h ∘ i ≈⟨ isoʳ iso′ ⟩ id ∎ } where open Iso Iso-≈ : f ≈ h → Iso f g → Iso h i → g ≈ i Iso-≈ {f = f} {h = h} {g = g} {i = i} eq iso iso′ = begin g ≈⟨ introˡ (isoˡ iso′) ⟩ (i ∘ h) ∘ g ≈˘⟨ (refl ⟩∘⟨ eq) ⟩∘⟨refl ⟩ (i ∘ f) ∘ g ≈⟨ cancelʳ (isoʳ iso) ⟩ i ∎ where open Iso module _ where open _≅_ isos×≈⇒≈ : ∀ {f g : A ⇒ B} → h ≈ i → (iso₁ : A ≅ C) → (iso₂ : B ≅ D) → CommutativeSquare f (from iso₁) (from iso₂) h → CommutativeSquare g (from iso₁) (from iso₂) i → f ≈ g isos×≈⇒≈ {h = h} {i = i} {f = f} {g = g} eq iso₁ iso₂ sq₁ sq₂ = begin f ≈⟨ switch-fromtoˡ iso₂ sq₁ ⟩ to iso₂ ∘ h ∘ from iso₁ ≈⟨ refl⟩∘⟨ (eq ⟩∘⟨refl ) ⟩ to iso₂ ∘ i ∘ from iso₁ ≈˘⟨ switch-fromtoˡ iso₂ sq₂ ⟩ g ∎
{ "alphanum_fraction": 0.4632352941, "avg_line_length": 24.4494382022, "ext": "agda", "hexsha": "0b5986de697c1d0508f8b24d4ded49cc3d7faac9", "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/Morphism/Properties.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/Morphism/Properties.agda", "max_line_length": 72, "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/Morphism/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1059, "size": 2176 }
-- Andreas, 2016-07-26, issue 2215, reported by effectfully data Term : Set where abs : Term → Term Type = Term f : Type → Term f (abs b@(abs _)) = b -- WAS: Panic: Pattern match failure in AsPatterns.conPattern -- due to a missing reduce -- Should work.
{ "alphanum_fraction": 0.6755725191, "avg_line_length": 17.4666666667, "ext": "agda", "hexsha": "5cf76332728e3f849d276f9da37b82d7124563c1", "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/Issue2115.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/Issue2115.agda", "max_line_length": 61, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2115.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": 262 }
-- Andreas, 2016-10-01, issue #2231 -- The termination checker should not always see through abstract definitions. abstract data Nat : Set where zero' : Nat suc' : Nat → Nat -- abstract hides constructor nature of zero and suc. zero = zero' suc = suc' data D : Nat → Set where c1 : ∀ n → D n → D (suc n) c2 : ∀ n → D n → D n -- To see that this is terminating the termination checker has to look at the -- natural number index, which is in a dot pattern. f : ∀ n → D n → Nat f .(suc n) (c1 n d) = f n (c2 n (c2 n d)) f n (c2 .n d) = f n d -- Termination checking based on dot patterns should fail, -- since suc is abstract.
{ "alphanum_fraction": 0.6297420334, "avg_line_length": 26.36, "ext": "agda", "hexsha": "43853de0cae4f6ac6d710571383ecb4dbac973a5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue2231.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue2231.agda", "max_line_length": 78, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue2231.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": 208, "size": 659 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.Bouquet open import homotopy.FinWedge open import cohomology.Theory module cohomology.SubFinBouquet (OT : OrdinaryTheory lzero) where open OrdinaryTheory OT open import cohomology.Sphere OT open import cohomology.SubFinWedge cohomology-theory open import cohomology.Bouquet OT C-SubFinBouquet-diag : ∀ n {A B : Type₀} (B-ac : has-choice 0 B lzero) {I} (p : Fin I → Coprod A B) → C (ℕ-to-ℤ n) (⊙Bouquet B n) ≃ᴳ Πᴳ B (λ _ → C2 0) C-SubFinBouquet-diag n {B = B} B-ac p = C-Bouquet-diag n B B-ac C-FinBouquet-diag : ∀ n I → C (ℕ-to-ℤ n) (⊙FinBouquet I n) ≃ᴳ Πᴳ (Fin I) (λ _ → C2 0) C-FinBouquet-diag n I = C-SubFinBouquet-diag n {A = Empty} {B = Fin I} (Fin-has-choice 0 lzero) inr abstract C-SubFinBouquet-diag-β : ∀ n {A B : Type₀} (B-ac : has-choice 0 B lzero) {I} (p : Fin I → Coprod A B) g b → GroupIso.f (C-FinBouquet-diag n I) g b == GroupIso.f (C-Sphere-diag n) (CEl-fmap (ℕ-to-ℤ n) ⊙lower (CEl-fmap (ℕ-to-ℤ n) (⊙bwin b) g)) C-SubFinBouquet-diag-β n B-ac p g b = GroupIso.f (C-Sphere-diag n) (CEl-fmap (ℕ-to-ℤ n) (⊙bwin b) (CEl-fmap (ℕ-to-ℤ n) (⊙–> (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) g)) =⟨ ap (GroupIso.f (C-Sphere-diag n)) $ ∘-CEl-fmap (ℕ-to-ℤ n) (⊙bwin b) (⊙–> (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) g ∙ CEl-fmap-base-indep (ℕ-to-ℤ n) (λ _ → idp) g ∙ CEl-fmap-∘ (ℕ-to-ℤ n) (⊙bwin b) ⊙lower g ⟩ GroupIso.f (C-Sphere-diag n) (CEl-fmap (ℕ-to-ℤ n) ⊙lower (CEl-fmap (ℕ-to-ℤ n) (⊙bwin b) g)) =∎ C-FinBouquet-diag-β : ∀ n I g <I → GroupIso.f (C-FinBouquet-diag n I) g <I == GroupIso.f (C-Sphere-diag n) (CEl-fmap (ℕ-to-ℤ n) ⊙lower (CEl-fmap (ℕ-to-ℤ n) (⊙bwin <I) g)) C-FinBouquet-diag-β n I = C-SubFinBouquet-diag-β n {A = Empty} {B = Fin I} (Fin-has-choice 0 lzero) inr inverse-C-SubFinBouquet-diag-β : ∀ n {A B : Type₀} (B-ac : has-choice 0 B lzero) (B-dec : has-dec-eq B) {I} (p : Fin I ≃ Coprod A B) g → GroupIso.g (C-SubFinBouquet-diag n B-ac (–> p)) g == Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b)))) inverse-C-SubFinBouquet-diag-β n {B = B} B-ac B-dec p g = CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) (GroupIso.g (C-subfinite-additive-iso (ℕ-to-ℤ n) (–> p) (⊙Lift (⊙Sphere n)) B-ac) (GroupIso.g (C-Sphere-diag n) ∘ g)) =⟨ ap (CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv)))) $ inverse-C-subfinite-additive-β (ℕ-to-ℤ n) B-ac B-dec p (GroupIso.g (C-Sphere-diag n) ∘ g) ⟩ CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) (Group.subsum-r (C (ℕ-to-ℤ n) (⊙BouquetLift B n)) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b)))) =⟨ GroupHom.pres-subsum-r (C-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv)))) (–> p) $ (λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b))) ⟩ Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) (CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b)))) =⟨ ap (Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p)) (λ= λ b → ∘-CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b)) ∙ CEl-fmap-base-indep (ℕ-to-ℤ n) (bwproj-BigWedge-emap-r-lift B-dec b) (GroupIso.g (C-Sphere-diag n) (g b)) ∙ CEl-fmap-∘ (ℕ-to-ℤ n) ⊙lift (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b))) ⟩ Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b)))) =∎ inverse-C-FinBouquet-diag-β : ∀ n I g → GroupIso.g (C-FinBouquet-diag n I) g == Group.sum (C (ℕ-to-ℤ n) (⊙FinBouquet I n)) (λ <I → CEl-fmap (ℕ-to-ℤ n) (⊙fwproj <I) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g <I)))) inverse-C-FinBouquet-diag-β n I = inverse-C-SubFinBouquet-diag-β n {A = Empty} {B = Fin I} (Fin-has-choice 0 lzero) Fin-has-dec-eq (⊔₁-Empty (Fin I) ⁻¹)
{ "alphanum_fraction": 0.5416848538, "avg_line_length": 47.7291666667, "ext": "agda", "hexsha": "136e4d5579338a02ba102ba10c73d63476fce0d1", "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/SubFinBouquet.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/SubFinBouquet.agda", "max_line_length": 107, "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/SubFinBouquet.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": 2151, "size": 4582 }
open import FRP.LTL.RSet.Core using ( RSet ) open import FRP.LTL.Time using ( _+_ ) module FRP.LTL.RSet.Next where ○ : RSet → RSet ○ A t = A (t + 1)
{ "alphanum_fraction": 0.6447368421, "avg_line_length": 16.8888888889, "ext": "agda", "hexsha": "8d19cf322a8f15d3e0edd5568232d5688fd73a6d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Next.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Next.agda", "max_line_length": 44, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Next.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 57, "size": 152 }
module Issue1436-2 where module A where infixl 19 _↑_ infixl 1 _↓_ data D : Set where ● : D _↓_ _↑_ : D → D → D module B where infix -1000000 _↓_ data D : Set where _↓_ : D → D → D open A open B rejected = ● ↑ ● ↓ ● ↑ ● ↓ ● ↑ ●
{ "alphanum_fraction": 0.5094339623, "avg_line_length": 11.5217391304, "ext": "agda", "hexsha": "2ed544dcf72466a7c443b923bd2456b9cbc20065", "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/Issue1436-2.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/Issue1436-2.agda", "max_line_length": 32, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1436-2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 107, "size": 265 }
-- Andreas, 2017-05-17, issue #2574 reported by G. Allais -- This file is intentionally without module header. private postulate A : Set
{ "alphanum_fraction": 0.7304964539, "avg_line_length": 20.1428571429, "ext": "agda", "hexsha": "aaa6cd2ffc731562bd1f6596459650eb1870c369", "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/interaction/Issue2574ImportBlank.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/interaction/Issue2574ImportBlank.agda", "max_line_length": 57, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2574ImportBlank.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 40, "size": 141 }
open import Prelude open import Nat open import Agda.Primitive using (Level; lzero; lsuc) renaming (_⊔_ to lmax) module List where -- definitions data List (A : Set) : Set where [] : List A _::_ : A → List A → List A _++_ : {A : Set} → List A → List A → List A [] ++ l₂ = l₂ (h :: l₁) ++ l₂ = h :: (l₁ ++ l₂) infixl 50 _++_ ∥_∥ : {A : Set} → List A → Nat ∥ [] ∥ = Z ∥ a :: as ∥ = 1+ ∥ as ∥ _⟦_⟧ : {A : Set} → List A → Nat → Maybe A [] ⟦ i ⟧ = None (a :: as) ⟦ Z ⟧ = Some a (a :: as) ⟦ 1+ i ⟧ = as ⟦ i ⟧ map : {A B : Set} → (A → B) → List A → List B map f [] = [] map f (a :: as) = f a :: map f as foldl : {A B : Set} → (B → A → B) → B → List A → B foldl f b [] = b foldl f b (a :: as) = foldl f (f b a) as concat : {A : Set} → List (List A) → List A concat [] = [] concat (l1 :: rest) = l1 ++ (concat rest) -- if the lists aren't the same length, -- the extra elements of the longer list are ignored zip : {A B : Set} → List A → List B → List (A ∧ B) zip [] _ = [] zip (a :: as) [] = [] zip (a :: as) (b :: bs) = (a , b) :: zip as bs unzip : {A B : Set} → List (A ∧ B) → (List A ∧ List B) unzip [] = ([] , []) unzip ((a , b) :: rest) with unzip rest ... | (as , bs) = (a :: as , b :: bs) reverse : {A : Set} → List A → List A reverse [] = [] reverse (a :: as) = reverse as ++ (a :: []) -- theorems list-==-dec : {A : Set} → (l1 l2 : List A) → ((a1 a2 : A) → a1 == a2 ∨ a1 ≠ a2) → l1 == l2 ∨ l1 ≠ l2 list-==-dec [] [] A-==-dec = Inl refl list-==-dec [] (_ :: _) A-==-dec = Inr (λ ()) list-==-dec (_ :: _) [] A-==-dec = Inr (λ ()) list-==-dec (h1 :: t1) (h2 :: t2) A-==-dec with A-==-dec h1 h2 ... | Inr ne = Inr (λ where refl → ne refl) ... | Inl refl with list-==-dec t1 t2 A-==-dec ... | Inr ne = Inr (λ where refl → ne refl) ... | Inl refl = Inl refl -- if the items of two lists are equal, then the lists are equal ==-per-elem : {A : Set} → {l1 l2 : List A} → ((i : Nat) → l1 ⟦ i ⟧ == l2 ⟦ i ⟧) → l1 == l2 ==-per-elem {l1 = []} {[]} items== = refl ==-per-elem {l1 = []} {h2 :: t2} items== = abort (somenotnone (! (items== Z))) ==-per-elem {l1 = h1 :: t1} {[]} items== = abort (somenotnone (items== Z)) ==-per-elem {l1 = h1 :: t1} {h2 :: t2} items== rewrite someinj (items== Z) | ==-per-elem {l1 = t1} {t2} (λ i → items== (1+ i)) = refl -- _++_ theorems ++assc : ∀{A a1 a2 a3} → (_++_ {A} a1 a2) ++ a3 == a1 ++ (a2 ++ a3) ++assc {A} {[]} {a2} {a3} = refl ++assc {A} {x :: a1} {a2} {a3} with a1 ++ a2 ++ a3 | ++assc {A} {a1} {a2} {a3} ++assc {A} {x :: a1} {a2} {a3} | _ | refl = refl l++[]==l : {A : Set} (l : List A) → l ++ [] == l l++[]==l [] = refl l++[]==l (a :: as) rewrite l++[]==l as = refl -- ∥_∥ theorem ∥-++-comm : ∀{A a1 a2} → ∥ a1 ∥ + (∥_∥ {A} a2) == ∥ a1 ++ a2 ∥ ∥-++-comm {A} {[]} {a2} = refl ∥-++-comm {A} {a :: a1} {a2} = 1+ap (∥-++-comm {A} {a1}) -- _⟦_⟧ and ++ theorem ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a : {A : Set} {l1 l2 : List A} {a : A} → (h : ∥ l1 ∥ < ∥ l1 ++ (a :: []) ++ l2 ∥) → ((l1 ++ (a :: []) ++ l2) ⟦ ∥ l1 ∥ ⟧ == Some a) ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a {l1 = []} h = refl ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a {l1 = a1 :: l1rest} {l2} {a} h = ⦇l1++[a]++l2⦈⟦∥l1∥⟧==a {l1 = l1rest} {l2} {a} (1+n<1+m→n<m h) -- packaging of list indexing results list-index-dec : {A : Set} (l : List A) (i : Nat) → l ⟦ i ⟧ == None ∨ Σ[ a ∈ A ] (l ⟦ i ⟧ == Some a) list-index-dec l i with l ⟦ i ⟧ ... | None = Inl refl ... | Some a = Inr (a , refl) -- theorems characterizing the partiality of list indexing list-index-some : {A : Set} {l : List A} {i : Nat} → i < ∥ l ∥ → Σ[ a ∈ A ] (l ⟦ i ⟧ == Some a) list-index-some {l = []} {Z} i<∥l∥ = abort (n≮0 i<∥l∥) list-index-some {l = a :: as} {Z} i<∥l∥ = _ , refl list-index-some {l = a :: as} {1+ i} i<∥l∥ = list-index-some (1+n<1+m→n<m i<∥l∥) list-index-none : {A : Set} {l : List A} {i : Nat} → ∥ l ∥ ≤ i → l ⟦ i ⟧ == None list-index-none {l = []} i≥∥l∥ = refl list-index-none {l = a :: as} {1+ i} i≥∥l∥ = list-index-none (1+n≤1+m→n≤m i≥∥l∥) list-index-some-conv : {A : Set} {l : List A} {i : Nat} {a : A} → l ⟦ i ⟧ == Some a → i < ∥ l ∥ list-index-some-conv {l = l} {i} i≥∥l∥ with <dec ∥ l ∥ i ... | Inr (Inr i<∥l∥) = i<∥l∥ ... | Inr (Inl refl) rewrite list-index-none {l = l} {∥ l ∥} ≤refl = abort (somenotnone (! i≥∥l∥)) ... | Inl ∥l∥<i rewrite list-index-none (n<m→n≤m ∥l∥<i) = abort (somenotnone (! i≥∥l∥)) list-index-none-conv : {A : Set} {l : List A} {i : Nat} → l ⟦ i ⟧ == None → ∥ l ∥ ≤ i list-index-none-conv {l = l} {i} i≥∥l∥ with <dec ∥ l ∥ i ... | Inl ∥l∥<i = n<m→n≤m ∥l∥<i ... | Inr (Inl refl) = ≤refl ... | Inr (Inr i<∥l∥) with list-index-some i<∥l∥ ... | _ , i≱∥l∥ rewrite i≥∥l∥ = abort (somenotnone (! i≱∥l∥)) ∥l1∥==∥l2∥→l1[i]→l2[i] : {A B : Set} {la : List A} {lb : List B} {i : Nat} {a : A} → ∥ la ∥ == ∥ lb ∥ → la ⟦ i ⟧ == Some a → Σ[ b ∈ B ] (lb ⟦ i ⟧ == Some b) ∥l1∥==∥l2∥→l1[i]→l2[i] {i = i} ∥la∥==∥lb∥ la[i]==a = list-index-some (tr (λ y → i < y) ∥la∥==∥lb∥ (list-index-some-conv la[i]==a)) ∥l1∥==∥l2∥→¬l1[i]→¬l2[i] : {A B : Set} {la : List A} {lb : List B} {i : Nat} → ∥ la ∥ == ∥ lb ∥ → la ⟦ i ⟧ == None → lb ⟦ i ⟧ == None ∥l1∥==∥l2∥→¬l1[i]→¬l2[i] {i = i} ∥la∥==∥lb∥ la[i]==None = list-index-none (tr (λ y → y ≤ i) ∥la∥==∥lb∥ (list-index-none-conv la[i]==None)) -- map theorem map-++-comm : ∀{A B f a b} → map f a ++ map f b == map {A} {B} f (a ++ b) map-++-comm {a = []} = refl map-++-comm {A} {B} {f} {h :: t} {b} with map f (t ++ b) | map-++-comm {A} {B} {f} {t} {b} map-++-comm {A} {B} {f} {h :: t} {b} | _ | refl = refl -- foldl theorem foldl-++ : {A B : Set} {l1 l2 : List A} {f : B → A → B} {b0 : B} → foldl f b0 (l1 ++ l2) == foldl f (foldl f b0 l1) l2 foldl-++ {l1 = []} = refl foldl-++ {l1 = a1 :: l1rest} = foldl-++ {l1 = l1rest} -- zip/unzip theorems unzip-inv : {A B : Set} {l : List (A ∧ B)} {la : List A} {lb : List B} → unzip l == (la , lb) → l == zip la lb unzip-inv {l = []} form with form ... | refl = refl unzip-inv {l = (a' , b') :: rest} {a :: as} {b :: bs} form with unzip rest | unzip-inv {l = rest} refl | form ... | (as' , bs') | refl | refl = refl zip-inv : {A B : Set} {la : List A} {lb : List B} → ∥ la ∥ == ∥ lb ∥ → unzip (zip la lb) == (la , lb) zip-inv {la = []} {[]} len-eq = refl zip-inv {la = a :: as} {b :: bs} len-eq with unzip (zip as bs) | zip-inv (1+inj len-eq) ... | (as' , bs') | refl = refl -- reverse theorems reverse-single : {A : Set} {a : A} → reverse (a :: []) == a :: [] reverse-single = refl reverse-++ : {A : Set} {l1 l2 : List A} → reverse (l1 ++ l2) == reverse l2 ++ reverse l1 reverse-++ {l1 = []} {l2} rewrite l++[]==l (reverse l2) = refl reverse-++ {l1 = a1 :: as1} {l2} rewrite reverse-++ {l1 = as1} {l2} = ++assc {a1 = reverse l2} reverse-inv : {A : Set} {l : List A} → reverse (reverse l) == l reverse-inv {l = []} = refl reverse-inv {l = a :: as} rewrite reverse-++ {l1 = reverse as} {a :: []} | reverse-inv {l = as} = refl
{ "alphanum_fraction": 0.4070460018, "avg_line_length": 36.0319634703, "ext": "agda", "hexsha": "36060671b9ce14d3b35c88f1c4a091964ade9563", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnat-myth-", "max_forks_repo_path": "List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnat-myth-", "max_issues_repo_path": "List.agda", "max_line_length": 119, "max_stars_count": 1, "max_stars_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnat-myth-", "max_stars_repo_path": "List.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-19T23:42:31.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-19T23:42:31.000Z", "num_tokens": 3498, "size": 7891 }
{-# OPTIONS --without-K #-} open import HoTT module homotopy.3x3.PushoutPushout where -- Numbering is in row/column form -- A span^2 is a 5 × 5 table (numbered from 0 to 4) where -- * the even/even cells are types -- * the odd/even and even/odd cells are functions -- * the odd/odd cells are equalities between functions record Span^2 {i} : Type (lsucc i) where constructor span^2 field A₀₀ A₀₂ A₀₄ A₂₀ A₂₂ A₂₄ A₄₀ A₄₂ A₄₄ : Type i f₀₁ : A₀₂ → A₀₀ f₀₃ : A₀₂ → A₀₄ f₂₁ : A₂₂ → A₂₀ f₂₃ : A₂₂ → A₂₄ f₄₁ : A₄₂ → A₄₀ f₄₃ : A₄₂ → A₄₄ f₁₀ : A₂₀ → A₀₀ f₃₀ : A₂₀ → A₄₀ f₁₂ : A₂₂ → A₀₂ f₃₂ : A₂₂ → A₄₂ f₁₄ : A₂₄ → A₀₄ f₃₄ : A₂₄ → A₄₄ H₁₁ : (x : A₂₂) → f₁₀ (f₂₁ x) == f₀₁ (f₁₂ x) H₁₃ : (x : A₂₂) → f₀₃ (f₁₂ x) == f₁₄ (f₂₃ x) H₃₁ : (x : A₂₂) → f₃₀ (f₂₁ x) == f₄₁ (f₃₂ x) H₃₃ : (x : A₂₂) → f₄₃ (f₃₂ x) == f₃₄ (f₂₃ x) record SquareFunc {i} : Type (lsucc i) where constructor square field {A B₁ B₂ C} : Type i f₁ : A → B₁ f₂ : A → B₂ g₁ : B₁ → C g₂ : B₂ → C module _ {i} where square=-raw : {A A' : Type i} (eq-A : A == A') {B₁ B₁' : Type i} (eq-B₁ : B₁ == B₁') {B₂ B₂' : Type i} (eq-B₂ : B₂ == B₂') {C C' : Type i} (eq-C : C == C') {f₁ : A → B₁} {f₁' : A' → B₁'} (eq-f₁ : f₁ == f₁' [ (λ u → fst u → snd u) ↓ pair×= eq-A eq-B₁ ]) {f₂ : A → B₂} {f₂' : A' → B₂'} (eq-f₂ : f₂ == f₂' [ (λ u → fst u → snd u) ↓ pair×= eq-A eq-B₂ ]) {g₁ : B₁ → C} {g₁' : B₁' → C'} (eq-g₁ : g₁ == g₁' [ (λ u → fst u → snd u) ↓ pair×= eq-B₁ eq-C ]) {g₂ : B₂ → C} {g₂' : B₂' → C'} (eq-g₂ : g₂ == g₂' [ (λ u → fst u → snd u) ↓ pair×= eq-B₂ eq-C ]) → square f₁ f₂ g₁ g₂ == square f₁' f₂' g₁' g₂' square=-raw idp idp idp idp idp idp idp idp = idp square-thing : {A A' : Type i} (eq-A : A == A') {B₁ B₁' : Type i} (eq-B₁ : B₁ == B₁') {B₂ B₂' : Type i} (eq-B₂ : B₂ == B₂') {C C' : Type i} (eq-C : C == C') {f₁ : A → B₁} {f₁' : A' → B₁'} (eq-f₁ : f₁ == f₁' [ (λ u → fst u → snd u) ↓ pair×= eq-A eq-B₁ ]) {f₂ : A → B₂} {f₂' : A' → B₂'} (eq-f₂ : f₂ == f₂' [ (λ u → fst u → snd u) ↓ pair×= eq-A eq-B₂ ]) {g₁ : B₁ → C} {g₁' : B₁' → C'} (eq-g₁ : g₁ == g₁' [ (λ u → fst u → snd u) ↓ pair×= eq-B₁ eq-C ]) {g₂ : B₂ → C} {g₂' : B₂' → C'} (eq-g₂ : g₂ == g₂' [ (λ u → fst u → snd u) ↓ pair×= eq-B₂ eq-C ]) {a : _} {b : _} → a == b [ (λ u → ((x : SquareFunc.A u) → SquareFunc.g₂ u (SquareFunc.f₂ u x) == SquareFunc.g₁ u (SquareFunc.f₁ u x))) ↓ (square=-raw eq-A eq-B₂ eq-B₁ eq-C eq-f₂ eq-f₁ eq-g₂ eq-g₁) ] → a == b [ (λ u → ((x : SquareFunc.A u) → SquareFunc.g₁ u (SquareFunc.f₁ u x) == SquareFunc.g₂ u (SquareFunc.f₂ u x))) ↓ (square=-raw eq-A eq-B₁ eq-B₂ eq-C eq-f₁ eq-f₂ eq-g₁ eq-g₂) ] square-thing idp idp idp idp idp idp idp idp α = α span^2=-raw : {A₀₀ A₀₀' : Type i} (eq-A₀₀ : A₀₀ == A₀₀') {A₀₂ A₀₂' : Type i} (eq-A₀₂ : A₀₂ == A₀₂') {A₀₄ A₀₄' : Type i} (eq-A₀₄ : A₀₄ == A₀₄') {A₂₀ A₂₀' : Type i} (eq-A₂₀ : A₂₀ == A₂₀') {A₂₂ A₂₂' : Type i} (eq-A₂₂ : A₂₂ == A₂₂') {A₂₄ A₂₄' : Type i} (eq-A₂₄ : A₂₄ == A₂₄') {A₄₀ A₄₀' : Type i} (eq-A₄₀ : A₄₀ == A₄₀') {A₄₂ A₄₂' : Type i} (eq-A₄₂ : A₄₂ == A₄₂') {A₄₄ A₄₄' : Type i} (eq-A₄₄ : A₄₄ == A₄₄') {f₀₁ : A₀₂ → A₀₀} {f₀₁' : A₀₂' → A₀₀'} (eq-f₀₁ : f₀₁ == f₀₁' [ (λ u → fst u → snd u) ↓ pair×= eq-A₀₂ eq-A₀₀ ]) {f₀₃ : A₀₂ → A₀₄} {f₀₃' : A₀₂' → A₀₄'} (eq-f₀₃ : f₀₃ == f₀₃' [ (λ u → fst u → snd u) ↓ pair×= eq-A₀₂ eq-A₀₄ ]) {f₂₁ : A₂₂ → A₂₀} {f₂₁' : A₂₂' → A₂₀'} (eq-f₂₁ : f₂₁ == f₂₁' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₂ eq-A₂₀ ]) {f₂₃ : A₂₂ → A₂₄} {f₂₃' : A₂₂' → A₂₄'} (eq-f₂₃ : f₂₃ == f₂₃' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₂ eq-A₂₄ ]) {f₄₁ : A₄₂ → A₄₀} {f₄₁' : A₄₂' → A₄₀'} (eq-f₄₁ : f₄₁ == f₄₁' [ (λ u → fst u → snd u) ↓ pair×= eq-A₄₂ eq-A₄₀ ]) {f₄₃ : A₄₂ → A₄₄} {f₄₃' : A₄₂' → A₄₄'} (eq-f₄₃ : f₄₃ == f₄₃' [ (λ u → fst u → snd u) ↓ pair×= eq-A₄₂ eq-A₄₄ ]) {f₁₀ : A₂₀ → A₀₀} {f₁₀' : A₂₀' → A₀₀'} (eq-f₁₀ : f₁₀ == f₁₀' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₀ eq-A₀₀ ]) {f₃₀ : A₂₀ → A₄₀} {f₃₀' : A₂₀' → A₄₀'} (eq-f₃₀ : f₃₀ == f₃₀' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₀ eq-A₄₀ ]) {f₁₂ : A₂₂ → A₀₂} {f₁₂' : A₂₂' → A₀₂'} (eq-f₁₂ : f₁₂ == f₁₂' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₂ eq-A₀₂ ]) {f₃₂ : A₂₂ → A₄₂} {f₃₂' : A₂₂' → A₄₂'} (eq-f₃₂ : f₃₂ == f₃₂' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₂ eq-A₄₂ ]) {f₁₄ : A₂₄ → A₀₄} {f₁₄' : A₂₄' → A₀₄'} (eq-f₁₄ : f₁₄ == f₁₄' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₄ eq-A₀₄ ]) {f₃₄ : A₂₄ → A₄₄} {f₃₄' : A₂₄' → A₄₄'} (eq-f₃₄ : f₃₄ == f₃₄' [ (λ u → fst u → snd u) ↓ pair×= eq-A₂₄ eq-A₄₄ ]) {H₁₁ : (x : A₂₂) → f₁₀ (f₂₁ x) == f₀₁ (f₁₂ x)} {H₁₁' : (x : A₂₂') → f₁₀' (f₂₁' x) == f₀₁' (f₁₂' x)} (eq-H₁₁ : H₁₁ == H₁₁' [ (λ u → ((x : SquareFunc.A u) → SquareFunc.g₁ u (SquareFunc.f₁ u x) == SquareFunc.g₂ u (SquareFunc.f₂ u x))) ↓ square=-raw eq-A₂₂ eq-A₂₀ eq-A₀₂ eq-A₀₀ eq-f₂₁ eq-f₁₂ eq-f₁₀ eq-f₀₁ ]) {H₁₃ : (x : A₂₂) → f₀₃ (f₁₂ x) == f₁₄ (f₂₃ x)} {H₁₃' : (x : A₂₂') → f₀₃' (f₁₂' x) == f₁₄' (f₂₃' x)} (eq-H₁₃ : H₁₃ == H₁₃' [ (λ u → ((x : SquareFunc.A u) → SquareFunc.g₁ u (SquareFunc.f₁ u x) == SquareFunc.g₂ u (SquareFunc.f₂ u x))) ↓ square=-raw eq-A₂₂ eq-A₀₂ eq-A₂₄ eq-A₀₄ eq-f₁₂ eq-f₂₃ eq-f₀₃ eq-f₁₄ ]) {H₃₁ : (x : A₂₂) → f₃₀ (f₂₁ x) == f₄₁ (f₃₂ x)} {H₃₁' : (x : A₂₂') → f₃₀' (f₂₁' x) == f₄₁' (f₃₂' x)} (eq-H₃₁ : H₃₁ == H₃₁' [ (λ u → ((x : SquareFunc.A u) → SquareFunc.g₁ u (SquareFunc.f₁ u x) == SquareFunc.g₂ u (SquareFunc.f₂ u x))) ↓ square=-raw eq-A₂₂ eq-A₂₀ eq-A₄₂ eq-A₄₀ eq-f₂₁ eq-f₃₂ eq-f₃₀ eq-f₄₁ ]) {H₃₃ : (x : A₂₂) → f₄₃ (f₃₂ x) == f₃₄ (f₂₃ x)} {H₃₃' : (x : A₂₂') → f₄₃' (f₃₂' x) == f₃₄' (f₂₃' x)} (eq-H₃₃ : H₃₃ == H₃₃' [ (λ u → ((x : SquareFunc.A u) → SquareFunc.g₁ u (SquareFunc.f₁ u x) == SquareFunc.g₂ u (SquareFunc.f₂ u x))) ↓ square=-raw eq-A₂₂ eq-A₄₂ eq-A₂₄ eq-A₄₄ eq-f₃₂ eq-f₂₃ eq-f₄₃ eq-f₃₄ ]) → span^2 A₀₀ A₀₂ A₀₄ A₂₀ A₂₂ A₂₄ A₄₀ A₄₂ A₄₄ f₀₁ f₀₃ f₂₁ f₂₃ f₄₁ f₄₃ f₁₀ f₃₀ f₁₂ f₃₂ f₁₄ f₃₄ H₁₁ H₁₃ H₃₁ H₃₃ == span^2 A₀₀' A₀₂' A₀₄' A₂₀' A₂₂' A₂₄' A₄₀' A₄₂' A₄₄' f₀₁' f₀₃' f₂₁' f₂₃' f₄₁' f₄₃' f₁₀' f₃₀' f₁₂' f₃₂' f₁₄' f₃₄' H₁₁' H₁₃' H₃₁' H₃₃' span^2=-raw idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp idp = idp module M {i} (d : Span^2 {i}) where open Span^2 d A₀∙ : Type i A₀∙ = Pushout (span A₀₀ A₀₄ A₀₂ f₀₁ f₀₃) A₂∙ : Type i A₂∙ = Pushout (span A₂₀ A₂₄ A₂₂ f₂₁ f₂₃) A₄∙ : Type i A₄∙ = Pushout (span A₄₀ A₄₄ A₄₂ f₄₁ f₄₃) module F₁∙ = PushoutRec {D = A₀∙} (left ∘ f₁₀) (right ∘ f₁₄) (λ c → ap left (H₁₁ c) ∙ glue (f₁₂ c) ∙ ap right (H₁₃ c)) f₁∙ : A₂∙ → A₀∙ f₁∙ = F₁∙.f module F₃∙ = PushoutRec {D = A₄∙} (left ∘ f₃₀) (right ∘ f₃₄) (λ c → ap left (H₃₁ c) ∙ glue (f₃₂ c) ∙ ap right (H₃₃ c)) f₃∙ : A₂∙ → A₄∙ f₃∙ = F₃∙.f -- Span obtained after taking horizontal pushouts v-h-span : Span v-h-span = span A₀∙ A₄∙ A₂∙ f₁∙ f₃∙ Pushout^2 : Type i Pushout^2 = Pushout v-h-span {- Definition of [f₁∙] and [f₃∙] in ∞TT: f₁∙ : A₂∙ → A₀∙ f₁∙ (left a) = left (f₁₀ a) f₁∙ (right c) = right (f₁₄ c) ap f₁∙ (glue b) = ap left (H₁₁ c) ∙ glue (f₁₂ c) ∙ ap right (H₁₃ c) f₃∙ : A₂∙ → A₄∙ f₃∙ (left a) = left (f₃₀ a) f₃∙ (right c) = right (f₃₄ c) ap f₃∙ (glue b) = ap left (H₃₁ c) ∙ glue (f₃₂ c) ∙ ap right (H₃₃ c) -}
{ "alphanum_fraction": 0.4867129205, "avg_line_length": 48.0440251572, "ext": "agda", "hexsha": "7f2a630c8bd65a7ab3cb1c50e11c18605215e80e", "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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "homotopy/3x3/PushoutPushout.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "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": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "homotopy/3x3/PushoutPushout.agda", "max_line_length": 186, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "homotopy/3x3/PushoutPushout.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 4232, "size": 7639 }
{-# OPTIONS --without-K --safe #-} -- This module packages up all the stuff that's passed to the other -- modules in a convenient form. module Polynomial.Parameters where open import Function open import Algebra open import Relation.Unary open import Level open import Algebra.Solver.Ring.AlmostCommutativeRing open import Data.Bool using (Bool; T) -- This record stores all the stuff we need for the coefficients: -- -- * A raw ring -- * A (decidable) predicate on "zeroeness" -- -- It's used for defining the operations on the horner normal form. record RawCoeff c ℓ : Set (suc (c ⊔ ℓ)) where field coeffs : RawRing c ℓ Zero-C : RawRing.Carrier coeffs → Bool open RawRing coeffs public -- This record stores the full information we need for converting -- to the final ring. record Homomorphism c ℓ₁ ℓ₂ ℓ₃ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃)) where field coeffs : RawCoeff c ℓ₁ module Raw = RawCoeff coeffs field ring : AlmostCommutativeRing ℓ₂ ℓ₃ morphism : Raw.coeffs -Raw-AlmostCommutative⟶ ring open _-Raw-AlmostCommutative⟶_ morphism renaming (⟦_⟧ to ⟦_⟧ᵣ) public open AlmostCommutativeRing ring public field Zero-C⟶Zero-R : ∀ x → T (Raw.Zero-C x) → 0# ≈ ⟦ x ⟧ᵣ
{ "alphanum_fraction": 0.7105263158, "avg_line_length": 30.4, "ext": "agda", "hexsha": "5dad8fc42b473443ef7e6782c526cdef3d0e9717", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Polynomial/Parameters.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Polynomial/Parameters.agda", "max_line_length": 71, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Polynomial/Parameters.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 380, "size": 1216 }
module Prelude.Erased where data [erased]-is-only-for-printing : Set where [erased] : [erased]-is-only-for-printing
{ "alphanum_fraction": 0.7333333333, "avg_line_length": 20, "ext": "agda", "hexsha": "f5eac45173bd814475894d16d781c9e48477b6dd", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "src/Prelude/Erased.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_path": "src/Prelude/Erased.agda", "max_line_length": 46, "max_stars_count": 111, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "src/Prelude/Erased.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 38, "size": 120 }
module Common.ContextPair where open import Common.Context public -- Context pairs. infix 4 _⁏_ record Cx² (U V : Set) : Set where constructor _⁏_ field int : Cx U mod : Cx V open Cx² public ∅² : ∀ {U V} → Cx² U V ∅² = ∅ ⁏ ∅ -- Context inclusion. module _ {U V : Set} where infix 3 _⊆²_ _⊆²_ : Cx² U V → Cx² U V → Set Γ ⁏ Δ ⊆² Γ′ ⁏ Δ′ = Γ ⊆ Γ′ × Δ ⊆ Δ′ refl⊆² : ∀ {Π} → Π ⊆² Π refl⊆² = refl⊆ , refl⊆ trans⊆² : ∀ {Π Π′ Π″} → Π ⊆² Π′ → Π′ ⊆² Π″ → Π ⊆² Π″ trans⊆² (η , θ) (η′ , θ′) = trans⊆ η η′ , trans⊆ θ θ′ weak⊆²₁ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊆² Γ , A ⁏ Δ weak⊆²₁ = weak⊆ , refl⊆ weak⊆²₂ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊆² Γ ⁏ Δ , A weak⊆²₂ = refl⊆ , weak⊆ bot⊆² : ∀ {Π} → ∅² ⊆² Π bot⊆² = bot⊆ , bot⊆ -- Context concatenation. module _ {U V : Set} where _⧺²_ : Cx² U V → Cx² U V → Cx² U V (Γ ⁏ Δ) ⧺² (Γ′ ⁏ Δ′) = Γ ⧺ Γ′ ⁏ Δ ⧺ Δ′ weak⊆²⧺₁ : ∀ {Π} Π′ → Π ⊆² Π ⧺² Π′ weak⊆²⧺₁ (Γ′ ⁏ Δ′) = weak⊆⧺₁ Γ′ , weak⊆⧺₁ Δ′ weak⊆²⧺₂ : ∀ {Π Π′} → Π′ ⊆² Π ⧺² Π′ weak⊆²⧺₂ = weak⊆⧺₂ , weak⊆⧺₂
{ "alphanum_fraction": 0.4735812133, "avg_line_length": 18.5818181818, "ext": "agda", "hexsha": "c5644280fc3efdfb808b740e50126e163a61a726", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "Common/ContextPair.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "Common/ContextPair.agda", "max_line_length": 55, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "Common/ContextPair.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 646, "size": 1022 }
{-# OPTIONS --cubical --safe #-} module Cubical.ZCohomology.S1.S1 where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.HITs.S1 open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.HITs.SetTruncation open import Cubical.HITs.Nullification open import Cubical.Data.Int open import Cubical.Data.Nat open import Cubical.HITs.Truncation ---- H⁰(S¹) = ℤ ---- coHom0-S1 : coHom zero S¹ ≡ Int coHom0-S1 = (λ i → ∥ helpLemma i ∥₀ ) ∙ setId isSetInt where helpLemma : (S¹ → Int) ≡ Int helpLemma = isoToPath (iso fun funinv (λ _ → refl) (λ f → funExt (rinvLemma f))) where fun : (S¹ → Int) → Int fun f = f base funinv : Int → (S¹ → Int) funinv a base = a funinv a (loop i) = a rinvLemma : (f : S¹ → Int) → (x : S¹) → funinv (fun f) x ≡ f x rinvLemma f base = refl rinvLemma f (loop i) j = isSetInt (f base) (f base) (λ k → f (loop k)) refl (~ j) i ------------------------- {- TODO : give Hᵏ(S¹) for all k -}
{ "alphanum_fraction": 0.6464454976, "avg_line_length": 28.5135135135, "ext": "agda", "hexsha": "029a6eeed7dd0791c55247a5800c924afdec52e3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/ZCohomology/S1/S1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/ZCohomology/S1/S1.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/ZCohomology/S1/S1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 378, "size": 1055 }
-- Generic term traversals module Syntax.Substitution.Lemmas where open import Syntax.Types open import Syntax.Context open import Syntax.Terms open import Syntax.Substitution.Kits open import Syntax.Substitution.Instances open import Data.Sum open import Relation.Binary.PropositionalEquality as ≡ using (_≡_ ; refl ; sym ; cong ; subst) open import Function using (id ; flip ; _∘_) open ≡.≡-Reasoning -- | Lemmas from substitutions -- | Concrete instances of structural and substitution lemmas -- | can be expressed as substituting traversals on terms -- Weakening lemma weakening : ∀{Γ Δ A} -> Γ ⊆ Δ -> Γ ⊢ A -------------------- -> Δ ⊢ A weakening s = substitute (weakₛ 𝒯ermₛ s) -- Weakening lemma for computations weakening′ : ∀{Γ Δ A} -> Γ ⊆ Δ -> Γ ⊨ A -------------------- -> Δ ⊨ A weakening′ s = substitute′ (weakₛ 𝒯ermₛ s) -- Exchange lemma exchange : ∀ Γ Γ′ Γ″ {A B C} -> Γ ⌊ A ⌋ Γ′ ⌊ B ⌋ Γ″ ⊢ C ---------------------- -> Γ ⌊ B ⌋ Γ′ ⌊ A ⌋ Γ″ ⊢ C exchange Γ Γ′ Γ″ = substitute (exₛ 𝒯ermₛ Γ Γ′ Γ″) -- Contraction lemma contraction : ∀ Γ Γ′ Γ″ {A B} -> Γ ⌊ A ⌋ Γ′ ⌊ A ⌋ Γ″ ⊢ B ---------------------- -> Γ ⌊ A ⌋ Γ′ ⌊⌋ Γ″ ⊢ B contraction Γ Γ′ Γ″ = substitute (contr-lₛ 𝒯ermₛ Γ Γ′ Γ″) -- Substitution lemma substitution : ∀ Γ Γ′ {A B} -> Γ ⌊⌋ Γ′ ⊢ A -> Γ ⌊ A ⌋ Γ′ ⊢ B -------------------------------- -> Γ ⌊⌋ Γ′ ⊢ B substitution Γ Γ′ M = substitute (sub-midₛ 𝒯ermₛ Γ Γ′ M) -- Substitution lemma for computational terms substitution′ : ∀ Γ Γ′ {A B} -> Γ ⌊⌋ Γ′ ⊢ A -> Γ ⌊ A ⌋ Γ′ ⊨ B -------------------------------- -> Γ ⌊⌋ Γ′ ⊨ B substitution′ Γ Γ′ M = substitute′ (sub-midₛ 𝒯ermₛ Γ Γ′ M) -- Top substitution lemma [_/] : ∀ {Γ A B} -> Γ ⊢ A -> Γ , A ⊢ B -------------------------- -> Γ ⊢ B [_/] M = substitute (sub-topₛ 𝒯ermₛ M) -- Top substitution lemma for computational terms [_/′] : ∀ {Γ A B} -> Γ ⊢ A -> Γ , A ⊨ B -------------------------- -> Γ ⊨ B [_/′] M = substitute′ (sub-topₛ 𝒯ermₛ M) -- Top substitution of computation into a computation ⟨_/⟩ : ∀ {Γ A B} -> Γ ⊨ A now -> Γ ˢ , A now ⊨ B now ------------------------------------ -> Γ ⊨ B now ⟨ pure M /⟩ D = substitute′ (sub-topˢₛ 𝒯ermₛ M) D ⟨ letSig S InC C /⟩ D = letSig S InC ⟨ C /⟩ (substitute′ ((idₛ 𝒯erm) ⁺ 𝒯erm ↑ 𝒯erm) D) ⟨ (letEvt_In_ {Γ} E C) /⟩ D = letEvt E In ⟨ C /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ⟨ select_↦_||_↦_||both↦_ {Γ} E₁ C₁ E₂ C₂ C₃ /⟩ D = select E₁ ↦ ⟨ C₁ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) || E₂ ↦ ⟨ C₂ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D) ||both↦ ⟨ C₃ /⟩ (substitute′ ((Γ ˢˢₛ 𝒯erm) ↑ 𝒯erm) D)
{ "alphanum_fraction": 0.4138349515, "avg_line_length": 37.8850574713, "ext": "agda", "hexsha": "0508bd221cb4ddfb933f263cdbcc79d1abf4406e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/Syntax/Substitution/Lemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/Syntax/Substitution/Lemmas.agda", "max_line_length": 92, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/Syntax/Substitution/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 1108, "size": 3296 }
-- Record modules for no-eta records should not be irrelevant in -- record even if all fields are irrelevant (cc #392). open import Agda.Builtin.Equality postulate A : Set record Unit : Set where no-eta-equality postulate a : A record Irr : Set where no-eta-equality field .unit : Unit postulate a : A record Coind : Set where coinductive postulate a : A typeOf : {A : Set} → A → Set typeOf {A} _ = A checkUnit : typeOf Unit.a ≡ (Unit → A) checkUnit = refl checkIrr : typeOf Irr.a ≡ (Irr → A) checkIrr = refl checkCoind : typeOf Coind.a ≡ (Coind → A) checkCoind = refl
{ "alphanum_fraction": 0.6846543002, "avg_line_length": 17.9696969697, "ext": "agda", "hexsha": "c6a9f613f47facb8f1188d1a0c05d3153e53f433", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.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/Issue2607.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2607.agda", "max_line_length": 64, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2607.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 195, "size": 593 }
open import Data.Bool using (Bool; true; false) open import Data.Float using (Float) open import Avionics.Maybe using (Maybe; just; nothing; _>>=_; map) --open import Data.Maybe using (Maybe; just; nothing; _>>=_; map) open import Data.Nat using (ℕ) open import Function using (_∘_) open import Level using (0ℓ; _⊔_) renaming (suc to lsuc) open import Relation.Binary using (Decidable) open import Relation.Binary.Definitions using (Transitive; Trans) open import Relation.Binary.PropositionalEquality using (_≡_) open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable using (False; ⌊_⌋; True) open import Relation.Unary using (Pred; _∈_) -- stack exec -- agda -c --ghc-dont-call-ghc --no-main code.agda infix 4 _≤_ _≤ᵇ_ _≤?_ postulate ℝ : Set fromFloat : Float → Maybe ℝ toFloat : ℝ → Float 0ℝ : ℝ _≤_ : ℝ → ℝ → Set _≤?_ : (m n : ℝ) → Dec (m ≤ n) _≤ᵇ_ : ℝ → ℝ → Bool p ≤ᵇ q = ⌊ p ≤? q ⌋ postulate √_ : (x : ℝ) → .{0≤x : True (0ℝ ≤? x)} → ℝ --Subset : Set → Set _ --Subset A = Pred A 0ℓ -- --postulate -- [0,∞⟩ : Subset ℝ -- -- √_ : (x : ℝ) → .{0≤x : x ∈ [0,∞⟩} → ℝ {-# COMPILE GHC ℝ = type Double #-} -- `fromFloat` should check whether it is a valid floating point -- number {-# COMPILE GHC fromFloat = \x -> Just x #-} {-# COMPILE GHC toFloat = \x -> x #-} {-# COMPILE GHC 0ℝ = 0 #-} {-# FOREIGN GHC type UnitErase a b = () #-} {-# COMPILE GHC _≤_ = type UnitErase #-} --{-# COMPILE GHC _≤_ = \ _ _ -> () #-} {-# COMPILE GHC _≤ᵇ_ = (<=) #-} --{-# FOREIGN GHC type UnitErase erase = () #-} --{-# COMPILE GHC [0,∞⟩ = type UnitErase #-} -- TODO: Find out how to perform the `sqrt` of a value!! -- Here lies the main problem of compilation failure! {-# COMPILE GHC √_ = \x _ -> sqrt x #-} -- Agda is actually doing the right thing not accepting dubious -- translations of code into Haskell export√ : Float → Maybe Float export√ x = fromFloat x >>= sqrt >>= just ∘ toFloat where sqrt : ℝ → Maybe ℝ sqrt y with 0ℝ ≤ᵇ y ... | false = nothing ... | true = just ((√ y) {y≥0}) where postulate y≥0 : True (0ℝ ≤? y) --where postulate y≥0 : y ∈ [0,∞⟩ {-# COMPILE GHC export√ as exportSqrt #-}
{ "alphanum_fraction": 0.6112380082, "avg_line_length": 27.7088607595, "ext": "agda", "hexsha": "4c6e1e109b2ba6fa5e57a0d31749fd74dab7a917", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "helq/old_code", "max_forks_repo_path": "proglangs-learning/Agda/reals-with-restrictions/code.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "helq/old_code", "max_issues_repo_path": "proglangs-learning/Agda/reals-with-restrictions/code.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "helq/old_code", "max_stars_repo_path": "proglangs-learning/Agda/reals-with-restrictions/code.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 763, "size": 2189 }
-- Andreas, 2018-05-27, issue #3090, reported by anka-213 -- Parser should not raise internal error for invalid symbol in name {-# BUILTIN NATURAL ( #-} -- Should fail with a parse error, not internal error
{ "alphanum_fraction": 0.7224880383, "avg_line_length": 29.8571428571, "ext": "agda", "hexsha": "ed2372efa54be6e63149cf2839d58b4a871df762", "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/Issue3090-lparen.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/Issue3090-lparen.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue3090-lparen.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": 55, "size": 209 }
-------------------------------------------------------------------------------- -- This file contains functions to convert between agda terms and meta-cedille -- terms -------------------------------------------------------------------------------- module Conversion where open import Class.Monad.Except open import Data.String using (fromList; toList) open import Data.Tree open import Data.Tree.Instance open import Data.Word using (toℕ) open import Data.List using (uncons) open import CoreTheory open import Parse.TreeConvert open import Prelude open import Prelude.Strings module _ {M : Set → Set} {{_ : Monad M}} {{_ : MonadExcept M String}} where private {-# TERMINATING #-} -- findOutermostConstructor returns a list of smaller terms buildConstructorTree : Context → PureTerm → Tree PureTerm buildConstructorTree Γ t with findOutermostConstructor t ... | t' , ts = Node t' $ map (buildConstructorTree Γ) $ reverse ts extractConstrId : PureTerm → M (ℕ ⊎ Char) extractConstrId (Var-P (Bound x)) = return $ inj₁ $ toℕ x extractConstrId (Var-P (Free x)) = throwError ("Not a constructor:" <+> x) extractConstrId (Char-P c) = return $ inj₂ c {-# CATCHALL #-} extractConstrId t = throwError ("Not a variable" <+> show t) {-# TERMINATING #-} extractConstrIdTree : Tree PureTerm → M (Tree (ℕ ⊎ Char)) extractConstrIdTree (Node x y) = do x' ← extractConstrId x y' ← sequence (map extractConstrIdTree y) return $ Node x' y' record Unquote (A : Set) : Set where field conversionFunction : Tree (ℕ ⊎ Char) → Maybe A nameOfA : String unquoteConstrs : Context → PureTerm → M A unquoteConstrs Γ t = do t' ← appendIfError (extractConstrIdTree $ buildConstructorTree Γ t) ("Error while converting term" <+> show t <+> "to a tree of constructors of a" <+> nameOfA <+> "!") maybeToError (conversionFunction t') ("Error while converting to" <+> nameOfA + ". Term:" <+> show t + "\nTree:\n" + show {{Tree-Show}} t') open Unquote {{...}} public instance Unquote-Stmt : Unquote Stmt Unquote-Stmt = record { conversionFunction = toStmt ; nameOfA = "statement" } Unquote-Term : Unquote AnnTerm Unquote-Term = record { conversionFunction = toTerm ; nameOfA = "term" } Unquote-String : Unquote String Unquote-String = record { conversionFunction = toName ; nameOfA = "string" } Unquote-StringList : Unquote (List String) Unquote-StringList = record { conversionFunction = toNameList ; nameOfA = "string list" } record Quotable (A : Set) : Set₁ where field quoteToAnnTerm : A → AnnTerm quoteToPureTerm : A → PureTerm quoteToPureTerm = Erase ∘ quoteToAnnTerm open Quotable {{...}} public instance Quotable-ListChar : Quotable (List Char) Quotable-ListChar .quoteToAnnTerm [] = FreeVar "init$string$nil" Quotable-ListChar .quoteToAnnTerm (c ∷ cs) = FreeVar "init$string$cons" ⟪$⟫ Char-A c ⟪$⟫ quoteToAnnTerm cs Quotable-String : Quotable String Quotable-String .quoteToAnnTerm = quoteToAnnTerm ∘ toList Quotable-ListString : Quotable (List String) Quotable-ListString .quoteToAnnTerm [] = FreeVar "init$stringList$nil" Quotable-ListString .quoteToAnnTerm (x ∷ l) = FreeVar "init$stringList$cons" ⟪$⟫ quoteToAnnTerm x ⟪$⟫ quoteToAnnTerm l private Quotable-Index : Quotable 𝕀 Quotable-Index .quoteToAnnTerm i with uncons (toList (show i)) ... | nothing = Sort-A □ -- impossible ... | just (x , i) = FreeVar ("init$index$" + fromList [ x ] + "_index'_") ⟪$⟫ quoteIndex' i where quoteIndex' : List Char → AnnTerm quoteIndex' [] = FreeVar "init$index'$" quoteIndex' (x ∷ xs) = FreeVar ("init$index'$" + fromList [ x ] + "_index'_") ⟪$⟫ quoteIndex' xs Quotable-AnnTerm : Quotable AnnTerm Quotable-AnnTerm .quoteToAnnTerm (Var-A (Bound x)) = FreeVar "init$term$_var_" ⟪$⟫ (FreeVar "init$var$_index_" ⟪$⟫ quoteToAnnTerm x) Quotable-AnnTerm .quoteToAnnTerm (Var-A (Free x)) = FreeVar "init$term$_var_" ⟪$⟫ (FreeVar "init$var$_string_" ⟪$⟫ quoteToAnnTerm x) Quotable-AnnTerm .quoteToAnnTerm (Sort-A ⋆) = FreeVar "init$term$_sort_" ⟪$⟫ FreeVar "init$sort$=ast=" Quotable-AnnTerm .quoteToAnnTerm (Sort-A □) = FreeVar "init$term$_sort_" ⟪$⟫ FreeVar "init$sort$=sq=" Quotable-AnnTerm .quoteToAnnTerm (Const-A CharT) = FreeVar "init$term$=Kappa=_const_" ⟪$⟫ FreeVar "init$const$Char" Quotable-AnnTerm .quoteToAnnTerm (Pr1-A t) = FreeVar "init$term$=pi=^space^_term_" ⟪$⟫ quoteToAnnTerm t Quotable-AnnTerm .quoteToAnnTerm (Pr2-A t) = FreeVar "init$term$=psi=^space^_term_" ⟪$⟫ quoteToAnnTerm t Quotable-AnnTerm .quoteToAnnTerm (Beta-A t t₁) = FreeVar "init$term$=beta=^space^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Delta-A t t₁) = FreeVar "init$term$=delta=^space^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Sigma-A t) = FreeVar "init$term$=sigma=^space^_term_" ⟪$⟫ quoteToAnnTerm t Quotable-AnnTerm .quoteToAnnTerm (App-A t t₁) = FreeVar "init$term$=lsquare=^space'^_term_^space^_term_^space'^=rsquare=" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (AppE-A t t₁) = FreeVar "init$term$=langle=^space'^_term_^space^_term_^space'^=rangle=" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Rho-A t t₁ t₂) = FreeVar "init$term$=rho=^space^_term_^space^_string_^space'^=dot=^space'^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm (List Char ∋ "_") -- TODO: add a name to rho? ⟪$⟫ quoteToAnnTerm t₁ ⟪$⟫ quoteToAnnTerm t₂ Quotable-AnnTerm .quoteToAnnTerm (All-A x t t₁) = FreeVar "init$term$=forall=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm x ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Pi-A x t t₁) = FreeVar "init$term$=Pi=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm x ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Iota-A x t t₁) = FreeVar "init$term$=iota=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm x ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Lam-A x t t₁) = FreeVar "init$term$=lambda=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm x ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (LamE-A x t t₁) = FreeVar "init$term$=Lambda=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm x ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Pair-A t t₁ t₂) = FreeVar "init$term$=lbrace=^space'^_term_^space'^=comma=^space'^_term_^space^_string_^space'^=dot=^space'^_term_^space'^=rbrace=" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ ⟪$⟫ quoteToAnnTerm (List Char ∋ "_") ⟪$⟫ quoteToAnnTerm t₂ -- TODO: add a name to pair? Quotable-AnnTerm .quoteToAnnTerm (Phi-A t t₁ t₂) = FreeVar "init$term$=phi=^space^_term_^space^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ ⟪$⟫ quoteToAnnTerm t₂ Quotable-AnnTerm .quoteToAnnTerm (Eq-A t t₁) = FreeVar "init$term$=equal=^space^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (M-A t) = FreeVar "init$term$=omega=^space^_term_" ⟪$⟫ quoteToAnnTerm t Quotable-AnnTerm .quoteToAnnTerm (Mu-A t t₁) = FreeVar "init$term$=mu=^space^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Epsilon-A t) = FreeVar "init$term$=epsilon=^space^_term_" ⟪$⟫ quoteToAnnTerm t Quotable-AnnTerm .quoteToAnnTerm (Gamma-A t t₁) = FreeVar "init$term$=zeta=CatchErr^space^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-AnnTerm .quoteToAnnTerm (Ev-A x x₁) = Sort-A □ -- TODO Quotable-AnnTerm .quoteToAnnTerm (Char-A x) = FreeVar "init$term$=kappa=_char_" ⟪$⟫ Char-A x Quotable-AnnTerm .quoteToAnnTerm (CharEq-A t t₁) = FreeVar "init$term$=gamma=^space^_term_^space^_term_" ⟪$⟫ quoteToAnnTerm t ⟪$⟫ quoteToAnnTerm t₁ Quotable-PureTerm : Quotable PureTerm Quotable-PureTerm .quoteToAnnTerm t = Sort-A □ -- TODO Quotable-ListTerm : Quotable (List AnnTerm) Quotable-ListTerm .quoteToAnnTerm [] = FreeVar "init$termList$nil" Quotable-ListTerm .quoteToAnnTerm (x ∷ l) = FreeVar "init$termList$cons" ⟪$⟫ quoteToAnnTerm x ⟪$⟫ quoteToAnnTerm l Quotable-NoQuoteAnnTerm : Quotable AnnTerm Quotable-NoQuoteAnnTerm .quoteToAnnTerm t = t record ProductData (L R : Set) : Set where field lType rType : AnnTerm l : L r : R -- The type of results of executing a statement in the interpreter. This can be -- returned back to the code via embedExecutionResult MetaResult = List String × List AnnTerm instance Quotable-MetaResult : Quotable MetaResult Quotable-MetaResult .quoteToAnnTerm (fst , snd) = FreeVar "init$metaResult$pair" ⟪$⟫ quoteToAnnTerm fst ⟪$⟫ quoteToAnnTerm snd Quotable-ProductData : ∀ {L R} ⦃ _ : Quotable L ⦄ ⦃ _ : Quotable R ⦄ → Quotable (ProductData L R) Quotable-ProductData .quoteToAnnTerm pDat = let open ProductData pDat in FreeVar "init$pair" ⟪$⟫ lType ⟪$⟫ rType ⟪$⟫ quoteToAnnTerm l ⟪$⟫ quoteToAnnTerm r
{ "alphanum_fraction": 0.6760785137, "avg_line_length": 49.3626943005, "ext": "agda", "hexsha": "7184544c3b5962c9741139e57b144d88de3cf50d", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "src/Conversion.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "src/Conversion.agda", "max_line_length": 176, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "src/Conversion.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 3390, "size": 9527 }
{-# OPTIONS --cubical --safe #-} module Algebra.Construct.Free.Semilattice.Homomorphism where open import Prelude open import Algebra open import Path.Reasoning open import Algebra.Construct.Free.Semilattice.Definition open import Algebra.Construct.Free.Semilattice.Eliminators open import Algebra.Construct.Free.Semilattice.Union module _ {b} (semilattice : Semilattice b) where open Semilattice semilattice module _ (sIsSet : isSet 𝑆) (h : A → 𝑆) where μ′ : A ↘ 𝑆 [ μ′ ]-set = sIsSet [ μ′ ] x ∷ xs = h x ∙ xs [ μ′ ][] = ε [ μ′ ]-dup x xs = h x ∙ (h x ∙ xs) ≡˘⟨ assoc (h x) (h x) xs ⟩ (h x ∙ h x) ∙ xs ≡⟨ cong (_∙ xs) (idem (h x)) ⟩ h x ∙ xs ∎ [ μ′ ]-com x y xs = h x ∙ (h y ∙ xs) ≡˘⟨ assoc (h x) (h y) xs ⟩ (h x ∙ h y) ∙ xs ≡⟨ cong (_∙ xs) (comm (h x) (h y)) ⟩ (h y ∙ h x) ∙ xs ≡⟨ assoc (h y) (h x) xs ⟩ h y ∙ (h x ∙ xs) ∎ μ : 𝒦 A → 𝑆 μ = [ μ′ ]↓ ∙-hom′ : ∀ ys → xs ∈𝒦 A ⇒∥ μ xs ∙ μ ys ≡ μ (xs ∪ ys) ∥ ∥ ∙-hom′ ys ∥-prop = sIsSet _ _ ∥ ∙-hom′ ys ∥[] = ε∙ _ ∥ ∙-hom′ ys ∥ x ∷ xs ⟨ Pxs ⟩ = μ (x ∷ xs) ∙ μ ys ≡⟨⟩ (h x ∙ μ xs) ∙ μ ys ≡⟨ assoc (h x) (μ xs) (μ ys) ⟩ h x ∙ (μ xs ∙ μ ys) ≡⟨ cong (h x ∙_) Pxs ⟩ h x ∙ μ (xs ∪ ys) ≡⟨⟩ μ ((x ∷ xs) ∪ ys) ∎ ∙-hom : ∀ xs ys → μ xs ∙ μ ys ≡ μ (xs ∪ ys) ∙-hom xs ys = ∥ ∙-hom′ ys ∥⇓ xs
{ "alphanum_fraction": 0.4827586207, "avg_line_length": 30.2888888889, "ext": "agda", "hexsha": "e91d6906322d886c7c5e279fbc457cf56b58fc0b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Algebra/Construct/Free/Semilattice/Homomorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Algebra/Construct/Free/Semilattice/Homomorphism.agda", "max_line_length": 60, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Homomorphism.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": 658, "size": 1363 }
module BTA5 where open import Data.Nat hiding (_<_) open import Data.Bool open import Data.List open import Data.Nat.Properties open import Relation.Nullary ----------------- -- CLEANUP (∈) : this is surely in the standard library ----------------- -- More general purpose definitions (should also be in standard library) -- list membership infix 4 _∈_ data _∈_ {A : Set} : A → List A → Set where hd : ∀ {x xs} → x ∈ (x ∷ xs) tl : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs) data Type : Set where Int : Type Fun : Type → Type → Type data AType : Set where AInt : AType AFun : AType → AType → AType D : Type → AType -- typed annotated expressions ACtx = List AType Ctx = List Type ----------------------- -- CLEANUP (≤) : these properties are surely in the standard library ----------------------- ≤-refl : ∀ {n} → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s ≤-refl ----------------------- -- CLEANUP (≤) : these properties are surely in the standard library ----------------------- ≤-trans : ∀ {a b c} → a ≤ b → b ≤ c → a ≤ c ≤-trans z≤n q = z≤n ≤-trans (s≤s p) (s≤s q) = s≤s (≤-trans p q) ----------------------- -- CLEANUP (≤) : these properties are surely in the standard library ----------------------- ≤-suc-right : ∀ {m n} → m ≤ n → m ≤ suc n ≤-suc-right z≤n = z≤n ≤-suc-right (s≤s p) = s≤s (≤-suc-right p) ----------------------- -- CLEANUP (≤) : these properties are surely in the standard library ----------------------- ≤-suc-left : ∀ {m n} → suc m ≤ n → m ≤ n ≤-suc-left (s≤s p) = ≤-suc-right p data _↝_ : Ctx → Ctx → Set where ↝-refl : ∀ {Γ} → Γ ↝ Γ ↝-extend : ∀ {Γ Γ' τ} → Γ ↝ Γ' → Γ ↝ (τ ∷ Γ') ↝-≤ : ∀ Γ Γ' → Γ ↝ Γ' → length Γ ≤ length Γ' ↝-≤ .Γ' Γ' ↝-refl = ≤-refl ↝-≤ Γ .(τ ∷ Γ') (↝-extend {.Γ} {Γ'} {τ} Γ↝Γ') = ≤-suc-right (↝-≤ Γ Γ' Γ↝Γ') ↝-no-left : ∀ Γ τ → ¬ (τ ∷ Γ) ↝ Γ ↝-no-left Γ τ p = 1+n≰n (↝-≤ (τ ∷ Γ) Γ p) ↝-trans : ∀ {Γ Γ' Γ''} → Γ ↝ Γ' → Γ' ↝ Γ'' → Γ ↝ Γ'' ↝-trans Γ↝Γ' ↝-refl = Γ↝Γ' ↝-trans Γ↝Γ' (↝-extend Γ'↝Γ'') = ↝-extend (↝-trans Γ↝Γ' Γ'↝Γ'') lem : ∀ x y xs xs' → (x ∷ xs) ↝ xs' → xs ↝ (y ∷ xs') lem x y xs .(x ∷ xs) ↝-refl = ↝-extend (↝-extend ↝-refl) lem x y xs .(x' ∷ xs') (↝-extend {.(x ∷ xs)} {xs'} {x'} p) = ↝-extend (lem x x' xs xs' p) data _↝_↝_ : Ctx → Ctx → Ctx → Set where ↝↝-base : ∀ {Γ Γ''} → Γ ↝ Γ'' → Γ ↝ [] ↝ Γ'' ↝↝-extend : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → (τ ∷ Γ) ↝ (τ ∷ Γ') ↝ (τ ∷ Γ'') -- Typed residula expressions data Exp'' (Γ : Ctx) : Type → Set where EVar : ∀ {τ} → τ ∈ Γ → Exp'' Γ τ EInt : ℕ → Exp'' Γ Int EAdd : Exp'' Γ Int → Exp'' Γ Int -> Exp'' Γ Int ELam : ∀ {τ τ'} → Exp'' (τ ∷ Γ) τ' → Exp'' Γ (Fun τ τ') EApp : ∀ {τ τ'} → Exp'' Γ (Fun τ τ') → Exp'' Γ τ → Exp'' Γ τ' data AExp (Δ : ACtx) : AType → Set where AVar : ∀ {α} → α ∈ Δ → AExp Δ α AInt : ℕ → AExp Δ AInt AAdd : AExp Δ AInt → AExp Δ AInt → AExp Δ AInt ALam : ∀ {α₁ α₂} → AExp (α₂ ∷ Δ) α₁ → AExp Δ (AFun α₂ α₁) AApp : ∀ {α₁ α₂} → AExp Δ (AFun α₂ α₁) → AExp Δ α₂ → AExp Δ α₁ DInt : ℕ → AExp Δ (D Int) DAdd : AExp Δ (D Int) → AExp Δ (D Int) → AExp Δ (D Int) DLam : ∀ {α₁ α₂} → AExp ((D α₂) ∷ Δ) (D α₁) → AExp Δ (D (Fun α₂ α₁)) DApp : ∀ {α₁ α₂} → AExp Δ (D (Fun α₂ α₁)) → AExp Δ (D α₂) → AExp Δ (D α₁) -- -- index Γ = nesting level of dynamic definitions / dynamic environment Imp'' : Ctx → AType → Set Imp'' Γ (AInt) = ℕ Imp'' Γ (AFun α₁ α₂) = ∀ {Γ'} → Γ ↝ Γ' → (Imp'' Γ' α₁ → Imp'' Γ' α₂) Imp'' Γ (D σ) = Exp'' Γ σ -- -- index = nesting level of dynamic definitions data AEnv2 : Ctx → ACtx → Set where [] : AEnv2 [] [] consS : ∀ {Γ Δ Γ'} → Γ ↝ Γ' → (α : AType) → Imp'' Γ' α → AEnv2 Γ Δ → AEnv2 Γ' (α ∷ Δ) consD : ∀ {Γ Δ} → (σ : Type) → Exp'' (σ ∷ Γ) σ → AEnv2 Γ Δ → AEnv2 (σ ∷ Γ) (D σ ∷ Δ) elevate-var : ∀ {Γ Γ' τ} → Γ ↝ Γ' → τ ∈ Γ → τ ∈ Γ' elevate-var ↝-refl x = x elevate-var (↝-extend Γ↝Γ') x = tl (elevate-var Γ↝Γ' x) elevate-var2 : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → τ ∈ Γ → τ ∈ Γ'' elevate-var2 (↝↝-base x) x₁ = elevate-var x x₁ elevate-var2 (↝↝-extend Γ↝Γ'↝Γ'') hd = hd elevate-var2 (↝↝-extend Γ↝Γ'↝Γ'') (tl x) = tl (elevate-var2 Γ↝Γ'↝Γ'' x) elevate : ∀ {Γ Γ' Γ'' τ} → Γ ↝ Γ' ↝ Γ'' → Exp'' Γ τ → Exp'' Γ'' τ elevate Γ↝Γ'↝Γ'' (EVar x) = EVar (elevate-var2 Γ↝Γ'↝Γ'' x) elevate Γ↝Γ'↝Γ'' (EInt x) = EInt x elevate Γ↝Γ'↝Γ'' (EAdd e e₁) = EAdd (elevate Γ↝Γ'↝Γ'' e) (elevate Γ↝Γ'↝Γ'' e₁) elevate Γ↝Γ'↝Γ'' (ELam e) = ELam (elevate (↝↝-extend Γ↝Γ'↝Γ'') e) elevate Γ↝Γ'↝Γ'' (EApp e e₁) = EApp (elevate Γ↝Γ'↝Γ'' e) (elevate Γ↝Γ'↝Γ'' e₁) lift2 : ∀ {Γ Γ'} α → Γ ↝ Γ' → Imp'' Γ α → Imp'' Γ' α lift2 AInt p v = v lift2 (AFun x x₁) Γ↝Γ' v = λ Γ'↝Γ'' → v (↝-trans Γ↝Γ' Γ'↝Γ'') lift2 (D x₁) Γ↝Γ' v = elevate (↝↝-base Γ↝Γ') v lookup2 : ∀ {α Δ Γ Γ'} → Γ ↝ Γ' → AEnv2 Γ Δ → α ∈ Δ → Imp'' Γ' α lookup2 Γ↝Γ' (consS p α v env) hd = lift2 α Γ↝Γ' v lookup2 Γ↝Γ' (consS p α₁ v env) (tl x) = lookup2 (↝-trans p Γ↝Γ') env x lookup2 Γ↝Γ' (consD α v env) hd = lift2 (D α) Γ↝Γ' v lookup2 ↝-refl (consD α₁ v env) (tl x) = lookup2 (↝-extend ↝-refl) env x lookup2 (↝-extend Γ↝Γ') (consD α₁ v env) (tl x) = lookup2 (lem α₁ _ _ _ Γ↝Γ') env x pe2 : ∀ {α Δ Γ} → AExp Δ α → AEnv2 Γ Δ → Imp'' Γ α pe2 (AVar x) env = lookup2 ↝-refl env x pe2 (AInt x) env = x pe2 (AAdd e₁ e₂) env = pe2 e₁ env + pe2 e₂ env pe2 {AFun α₂ α₁} (ALam e) env = λ Γ↝Γ' → λ y → pe2 e (consS Γ↝Γ' α₂ y env) pe2 (AApp e₁ e₂) env = ((pe2 e₁ env) ↝-refl) (pe2 e₂ env) pe2 (DInt x) env = EInt x pe2 (DAdd e e₁) env = EAdd (pe2 e env) (pe2 e₁ env) pe2 {D (Fun σ₁ σ₂)} (DLam e) env = ELam (pe2 e (consD σ₁ (EVar hd) env)) -- ELam (pe2 (consS (↝-extend {τ = σ₁} ↝-refl) (D σ₁) (EVar hd) env)) works too; -- it is probably a canonical solution, but I (Lu) do not see why... pe2 (DApp e e₁) env = EApp (pe2 e env) (pe2 e₁ env) module Examples where open import Relation.Binary.PropositionalEquality x : ∀ {α Δ} → AExp (α ∷ Δ) α x = AVar hd y : ∀ {α₁ α Δ} → AExp (α₁ ∷ α ∷ Δ) α y = AVar (tl hd) z : ∀ {α₁ α₂ α Δ} → AExp (α₁ ∷ α₂ ∷ α ∷ Δ) α z = AVar (tl (tl hd)) -- Dλ y → let f = λ x → x D+ y in Dλ z → f z term1 : AExp [] (D (Fun Int (Fun Int Int))) term1 = DLam (AApp (ALam (DLam (AApp (ALam y) x))) ((ALam (DAdd x y)))) -- Dλ y → let f = λ x → (Dλ w → x D+ y) in Dλ z → f z -- Dλ y → (λ f → Dλ z → f z) (λ x → (Dλ w → x D+ y)) term2 : AExp [] (D (Fun Int (Fun Int Int))) term2 = DLam (AApp (ALam (DLam (AApp (ALam y) x))) ((ALam (DLam {α₂ = Int} (DAdd y z))))) ex-pe-term1 : pe2 term1 [] ≡ ELam (ELam (EVar hd)) ex-pe-term1 = refl ex-pe-term2 : pe2 term2 [] ≡ ELam (ELam (EVar hd)) ex-pe-term2 = refl -- end of file
{ "alphanum_fraction": 0.4943685238, "avg_line_length": 34.5025906736, "ext": "agda", "hexsha": "863f44a7e0a797753bf4c4a20a6c47f5040c1f4d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-10-15T09:01:37.000Z", "max_forks_repo_forks_event_min_datetime": "2019-10-15T09:01:37.000Z", "max_forks_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "luminousfennell/polybta", "max_forks_repo_path": "BTA5.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "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": "luminousfennell/polybta", "max_issues_repo_path": "BTA5.agda", "max_line_length": 129, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "luminousfennell/polybta", "max_stars_repo_path": "BTA5.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-15T04:35:29.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-15T04:35:29.000Z", "num_tokens": 3167, "size": 6659 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Argument relevance used in the reflection machinery ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Reflection.Argument.Relevance where open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- Re-exporting the builtins publically open import Agda.Builtin.Reflection public using (Relevance) open Relevance public ------------------------------------------------------------------------ -- Decidable equality _≟_ : DecidableEquality Relevance relevant ≟ relevant = yes refl irrelevant ≟ irrelevant = yes refl relevant ≟ irrelevant = no λ() irrelevant ≟ relevant = no λ()
{ "alphanum_fraction": 0.5158013544, "avg_line_length": 30.5517241379, "ext": "agda", "hexsha": "1897007afa4a5a47d39c68060cca5fc1a12249e6", "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/Reflection/Argument/Relevance.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/Reflection/Argument/Relevance.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/Reflection/Argument/Relevance.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": 142, "size": 886 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.Function open import lib.Equivalence open import lib.Univalence open import lib.NType open import lib.PathGroupoid {- A proof of function extensionality from the univalence axiom. -} module lib.Funext {i} {A : Type i} where -- Naive non dependent function extensionality module FunextNonDep {j} {B : Type j} {f g : A → B} (h : f ∼ g) where private equiv-comp : {B C : Type j} (e : B ≃ C) → is-equiv (λ (g : A → B) → (λ x → –> e (g x))) equiv-comp {B} e = equiv-induction (λ {B} e → is-equiv (λ (g : A → B) → (λ x → –> e (g x)))) (λ A' → snd (ide (A → A'))) e free-path-space-B : Type j free-path-space-B = Σ B (λ x → Σ B (λ y → x == y)) d : A → free-path-space-B d x = (f x , (f x , idp)) e : A → free-path-space-B e x = (f x , (g x , h x)) abstract fst-is-equiv : is-equiv (λ (y : free-path-space-B) → fst y) fst-is-equiv = is-eq fst (λ z → (z , (z , idp))) (λ _ → idp) (λ x' → ap (λ x → (_ , x)) (contr-has-all-paths _ _)) comp-fst-is-equiv : is-equiv (λ (f : A → free-path-space-B) → (λ x → fst (f x))) comp-fst-is-equiv = equiv-comp ((λ (y : free-path-space-B) → fst y), fst-is-equiv) d==e : d == e d==e = equiv-is-inj comp-fst-is-equiv _ _ idp λ=-nondep : f == g λ=-nondep = ap (λ f' x → fst (snd (f' x))) d==e open FunextNonDep using (λ=-nondep) -- Weak function extensionality (a product of contractible types is -- contractible) module WeakFunext {j} {P : A → Type j} (e : (x : A) → is-contr (P x)) where P-is-Unit : P == (λ x → Lift Unit) P-is-Unit = λ=-nondep (λ x → ua (contr-equiv-LiftUnit (e x))) abstract weak-λ= : is-contr (Π A P) weak-λ= = transport (λ Q → is-contr (Π A Q)) (! P-is-Unit) (has-level-in ((λ x → lift unit) , (λ y → λ=-nondep (λ x → idp)))) -- Naive dependent function extensionality module FunextDep {j} {P : A → Type j} {f g : Π A P} (h : f ∼ g) where open WeakFunext Q : A → Type j Q x = Σ (P x) (λ y → f x == y) abstract Q-is-contr : (x : A) → is-contr (Q x) Q-is-contr x = pathfrom-is-contr (f x) instance ΠAQ-is-contr : is-contr (Π A Q) ΠAQ-is-contr = weak-λ= Q-is-contr Q-f : Π A Q Q-f x = (f x , idp) Q-g : Π A Q Q-g x = (g x , h x) abstract Q-f==Q-g : Q-f == Q-g Q-f==Q-g = contr-has-all-paths Q-f Q-g λ= : f == g λ= = ap (λ u x → fst (u x)) Q-f==Q-g -- Strong function extensionality module StrongFunextDep {j} {P : A → Type j} where open FunextDep app= : ∀ {f g : Π A P} (p : f == g) → f ∼ g app= p x = ap (λ u → u x) p λ=-idp : (f : Π A P) → idp == λ= (λ x → idp {a = f x}) λ=-idp f = ap (ap (λ u x → fst (u x))) (contr-has-all-paths {{=-preserves-level (ΠAQ-is-contr (λ x → idp))}} idp (Q-f==Q-g (λ x → idp))) λ=-η : {f g : Π A P} (p : f == g) → p == λ= (app= p) λ=-η {f} idp = λ=-idp f app=-β : {f g : Π A P} (h : f ∼ g) (x : A) → app= (λ= h) x == h x app=-β h = app=-path (Q-f==Q-g h) where app=-path : {f : Π A P} {u v : (x : A) → Q (λ x → idp {a = f x}) x} (p : u == v) (x : A) → app= (ap (λ u x → fst (u x)) p) x == ! (snd (u x)) ∙ snd (v x) app=-path {u = u} idp x = ! (!-inv-l (snd (u x))) app=-is-equiv : {f g : Π A P} → is-equiv (app= {f = f} {g = g}) app=-is-equiv = is-eq _ λ= (λ h → λ= (app=-β h)) (! ∘ λ=-η) λ=-is-equiv : {f g : Π A P} → is-equiv (λ= {f = f} {g = g}) λ=-is-equiv = is-eq _ app= (! ∘ λ=-η) (λ h → λ= (app=-β h)) -- We only export the following module _ {j} {P : A → Type j} {f g : Π A P} where app= : f == g → f ∼ g app= p x = ap (λ u → u x) p abstract λ= : f ∼ g → f == g λ= = FunextDep.λ= app=-β : (p : f ∼ g) (x : A) → app= (λ= p) x == p x app=-β = StrongFunextDep.app=-β λ=-η : (p : f == g) → p == λ= (app= p) λ=-η = StrongFunextDep.λ=-η λ=-equiv : (f ∼ g) ≃ (f == g) λ=-equiv = (λ= , λ=-is-equiv) where abstract λ=-is-equiv : is-equiv λ= λ=-is-equiv = StrongFunextDep.λ=-is-equiv app=-equiv : (f == g) ≃ (f ∼ g) app=-equiv = (app= , app=-is-equiv) where abstract app=-is-equiv : is-equiv app= app=-is-equiv = StrongFunextDep.app=-is-equiv
{ "alphanum_fraction": 0.4775583483, "avg_line_length": 27.1707317073, "ext": "agda", "hexsha": "e7616563fffeb25dbc5719b7b19a84737fe2f29a", "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/Funext.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/Funext.agda", "max_line_length": 94, "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/Funext.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1744, "size": 4456 }
module Lec6Done where open import Lec1Done data List (X : Set) : Set where [] : List X _,-_ : X -> List X -> List X infixr 4 _,-_ -- ListF : Set -> Set -> Set -- ListF X T = One + (X * T) mkList : {X : Set} -> One + (X * List X) -> List X mkList (inl <>) = [] mkList (inr (x , xs)) = x ,- xs foldr : {X T : Set} -> ((One + (X * T)) -> T) -> List X -> T foldr alg [] = alg (inl <>) foldr alg (x ,- xs) = alg (inr (x , foldr alg xs)) ex1 = foldr mkList (1 ,- 2 ,- 3 ,- []) length : {X : Set} -> List X -> Nat length = foldr \ { (inl <>) -> zero ; (inr (x , n)) -> suc n } record CoList (X : Set) : Set where coinductive field force : One + (X * CoList X) open CoList []~ : {X : Set} -> CoList X force []~ = inl <> _,~_ : {X : Set} -> X -> CoList X -> CoList X force (x ,~ xs) = inr (x , xs) infixr 4 _,~_ unfoldr : {X S : Set} -> (S -> (One + (X * S))) -> S -> CoList X force (unfoldr coalg s) with coalg s force (unfoldr coalg s) | inl <> = inl <> force (unfoldr coalg s) | inr (x , s') = inr (x , unfoldr coalg s') ex2 = unfoldr force (1 ,~ 2 ,~ 3 ,~ []~) repeat : {X : Set} -> X -> CoList X repeat = unfoldr \ x -> inr (x , x) prefix : {X : Set} -> Nat -> CoList X -> List X prefix zero xs = [] prefix (suc n) xs with force xs prefix (suc n) xs | inl <> = [] prefix (suc n) xs | inr (x , xs') = x ,- prefix n xs' ex2' = prefix 3 ex2 record Stream (X : Set) : Set where coinductive field hdTl : X * Stream X open Stream forever : {X : Set} -> X -> Stream X fst (hdTl (forever x)) = x snd (hdTl (forever x)) = forever x unfold : {X S : Set} -> (S -> X * S) -> S -> Stream X fst (hdTl (unfold coalg s)) = fst (coalg s) snd (hdTl (unfold coalg s)) = unfold coalg (snd (coalg s))
{ "alphanum_fraction": 0.5238642898, "avg_line_length": 24.8428571429, "ext": "agda", "hexsha": "a81e60c33379366fb66e4dd5a4e41c979c4e889a", "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": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ajnavarro/language-dataset", "max_forks_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_issues_count": 91, "max_issues_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ajnavarro/language-dataset", "max_issues_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_line_length": 67, "max_stars_count": 36, "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.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": 688, "size": 1739 }
{- This file contains: - Properties of 2-groupoid truncations -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.2GroupoidTruncation.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.HITs.2GroupoidTruncation.Base private variable ℓ : Level A : Type ℓ rec : ∀ {B : Type ℓ} → is2Groupoid B → (A → B) → ∥ A ∥₄ → B rec gB f ∣ x ∣₄ = f x rec gB f (squash₄ _ _ _ _ _ _ t u i j k l) = gB _ _ _ _ _ _ (λ m n o → rec gB f (t m n o)) (λ m n o → rec gB f (u m n o)) i j k l elim : {B : ∥ A ∥₄ → Type ℓ} (bG : (x : ∥ A ∥₄) → is2Groupoid (B x)) (f : (x : A) → B ∣ x ∣₄) (x : ∥ A ∥₄) → B x elim bG f ∣ x ∣₄ = f x elim bG f (squash₄ x y p q r s u v i j k l) = isOfHLevel→isOfHLevelDep 4 bG _ _ _ _ _ _ (λ j k l → elim bG f (u j k l)) (λ j k l → elim bG f (v j k l)) (squash₄ x y p q r s u v) i j k l elim2 : {B : ∥ A ∥₄ → ∥ A ∥₄ → Type ℓ} (gB : ((x y : ∥ A ∥₄) → is2Groupoid (B x y))) (g : (a b : A) → B ∣ a ∣₄ ∣ b ∣₄) (x y : ∥ A ∥₄) → B x y elim2 gB g = elim (λ _ → is2GroupoidΠ (λ _ → gB _ _)) (λ a → elim (λ _ → gB _ _) (g a)) elim3 : {B : (x y z : ∥ A ∥₄) → Type ℓ} (gB : ((x y z : ∥ A ∥₄) → is2Groupoid (B x y z))) (g : (a b c : A) → B ∣ a ∣₄ ∣ b ∣₄ ∣ c ∣₄) (x y z : ∥ A ∥₄) → B x y z elim3 gB g = elim2 (λ _ _ → is2GroupoidΠ (λ _ → gB _ _ _)) (λ a b → elim (λ _ → gB _ _ _) (g a b)) 2GroupoidTruncIs2Groupoid : is2Groupoid ∥ A ∥₄ 2GroupoidTruncIs2Groupoid a b p q r s = squash₄ a b p q r s 2GroupoidTruncIdempotent≃ : is2Groupoid A → ∥ A ∥₄ ≃ A 2GroupoidTruncIdempotent≃ {A = A} hA = isoToEquiv f where f : Iso ∥ A ∥₄ A Iso.fun f = rec hA (idfun A) Iso.inv f x = ∣ x ∣₄ Iso.rightInv f _ = refl Iso.leftInv f = elim (λ _ → isOfHLevelSuc 4 2GroupoidTruncIs2Groupoid _ _) (λ _ → refl) 2GroupoidTruncIdempotent : is2Groupoid A → ∥ A ∥₄ ≡ A 2GroupoidTruncIdempotent hA = ua (2GroupoidTruncIdempotent≃ hA)
{ "alphanum_fraction": 0.5717529519, "avg_line_length": 31.9130434783, "ext": "agda", "hexsha": "edd391dcb605281fbbb5bb68e2acf8dc0ed50fce", "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/HITs/2GroupoidTruncation/Properties.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/HITs/2GroupoidTruncation/Properties.agda", "max_line_length": 89, "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/HITs/2GroupoidTruncation/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 989, "size": 2202 }
-- This module introduces parameterised datatypes. module DataParameterised where -- First some of our old friends. data Nat : Set where zero : Nat suc : Nat -> Nat data Bool : Set where false : Bool true : Bool -- A datatype can be parameterised over a telescope, (A : Set) in the case of -- lists. The parameters are bound in the types of the constructors. data List (A : Set) : Set where nil : List A cons : A -> List A -> List A -- When using the constructors the parameters to the datatype becomes implicit -- arguments. In this case, the types of the constructors are : -- nil : {A : Set} -> List A -- cons : {A : Set} -> A -> List A -> List A -- So, we can write --nilNat = nil {Nat} -- the type of this will be List Nat -- When pattern matching on elements of a parameterised datatype you cannot -- refer to the parameters--it wouldn't make sense to pattern match on the -- element type of the list. So you can say null : {A : Set} -> List A -> Bool null nil = true null (cons _ _) = false -- but not -- null (nil {A}) = true -- null (cons {A} _ _) = false
{ "alphanum_fraction": 0.6564748201, "avg_line_length": 24.1739130435, "ext": "agda", "hexsha": "2a1775d909d718deb571c84eb55e72f4eedd5956", "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": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/DataParameterised.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "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": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/DataParameterised.agda", "max_line_length": 78, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/DataParameterised.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 308, "size": 1112 }
------------------------------------------------------------------------------ -- Testing the translation of scheme's instances ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Instance where -- A schema -- Current translation: ∀ p q x. app(p,x) → app(q,x). postulate D : Set schema : (A B : D → Set) → ∀ {x} → A x → B x -- Using the current translation, the ATPs can prove an instance of -- the schema. postulate d : D A B : D → Set instanceC : A d → B d {-# ATP prove instanceC schema #-}
{ "alphanum_fraction": 0.4379263302, "avg_line_length": 29.32, "ext": "agda", "hexsha": "dbf281fd49a17b670d24e6aee3a68cafdd24bc3b", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/non-fol-theorems/Instance.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/non-fol-theorems/Instance.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/non-fol-theorems/Instance.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 157, "size": 733 }
{-# OPTIONS --without-K --rewriting #-} module hSet where open import lib.Basics open import lib.Funext open import lib.NType2 open import lib.types.Truncation open import lib.types.Bool open import PropT _is-a-set : {i : ULevel} (A : Type i) → Type i A is-a-set = is-set A -- To get an element a of the set A is to give a : ∈ A. ∈ : {i : ULevel} (A : hSet i) → Type i ∈ = fst set-is-a-set : {i : ULevel} (A : hSet i) → (∈ A) is-a-set set-is-a-set A = snd A -- Equality for sets, landing in Prop _==ₚ_ : {i : ULevel} {A : hSet i} → (x y : ∈ A) → PropT i _==ₚ_ {_} {A} x y = (x == y) , has-level-apply (set-is-a-set A) x y _=bool=_ : {i : ULevel} {A : Type i} {p : has-dec-eq A} → (x y : A) → Bool _=bool=_ {p = p} x y = case (p x y) where case : Dec (x == y) → Bool case (inl _) = true case (inr _) = false ∥_∥₀ : ∀ {i} (A : Type i) → Type i ∥_∥₀ = Trunc 0
{ "alphanum_fraction": 0.5256544503, "avg_line_length": 26.5277777778, "ext": "agda", "hexsha": "93445ee1d498c839d1c6edd25f2ddd4de79a84bd", "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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_path": "cohesion/david_jaz_261/hSet.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "glangmead/formalization", "max_issues_repo_path": "cohesion/david_jaz_261/hSet.agda", "max_line_length": 69, "max_stars_count": 6, "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_path": "cohesion/david_jaz_261/hSet.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "num_tokens": 376, "size": 955 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_ open import Cubical.Relation.Binary.Base open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim` open import Function.Base using (_∋_; _$_; it) open import Cubical.Foundations.Logic renaming ( inl to inlᵖ ; inr to inrᵖ ; _⇒_ to infixr 0 _⇒_ -- shifting by -6 ; _⇔_ to infixr -2 _⇔_ -- ; ∃[]-syntax to infix -4 ∃[]-syntax -- ; ∃[∶]-syntax to infix -4 ∃[∶]-syntax -- ; ∀[∶]-syntax to infix -4 ∀[∶]-syntax -- ; ∀[]-syntax to infix -4 ∀[]-syntax -- ) open import Cubical.Data.Unit.Base using (Unit) import Data.Sum import Cubical.Data.Sigma import Cubical.Algebra.CommRing import Cubical.Core.Primitives import Agda.Builtin.Cubical.Glue import Cubical.Foundations.Id open import MoreLogic.Reasoning open import MoreLogic.Definitions renaming (_ᵗ⇒_ to infixr 0 _ᵗ⇒_) open import MoreLogic.Properties open import Utils open import MorePropAlgebra.Bundles open import MorePropAlgebra.Definitions as Defs hiding (_≤''_) open import MorePropAlgebra.Consequences module MorePropAlgebra.Bridges1999 {ℓ ℓ'} (assumptions : PartiallyOrderedField {ℓ} {ℓ'}) where import MorePropAlgebra.Properties.AlmostPartiallyOrderedField -- module AlmostPartiallyOrderedField'Properties = MorePropAlgebra.Properties.AlmostPartiallyOrderedField record { PartiallyOrderedField assumptions } -- module AlmostPartiallyOrderedField' = AlmostPartiallyOrderedField record { PartiallyOrderedField assumptions } -- ( AlmostPartiallyOrderedField') = AlmostPartiallyOrderedField ∋ record { PartiallyOrderedField assumptions } -- module This = PartiallyOrderedField assumptions renaming (Carrier to F; _-_ to _-_) -- import MorePropAlgebra.Booij2020 -- -- open MorePropAlgebra.Booij2020.Chapter4 AlmostPartiallyOrderedField' public -- open MorePropAlgebra.Booij2020.Chapter4 (record { PartiallyOrderedField assumptions }) public -- open +-<-ext+·-preserves-<⇒ (PartiallyOrderedField.+-<-ext assumptions) (PartiallyOrderedField.·-preserves-< assumptions) public -- -- open AlmostPartiallyOrderedField'Properties -- using (_⁻¹; _≤''_) -- -- open MorePropAlgebra.Properties.AlmostPartiallyOrderedField (record { PartiallyOrderedField assumptions }) public -- remember opening this as the last one to omit prefixes -- open import MorePropAlgebra.Properties.PartiallyOrderedField assumptions -- open PartiallyOrderedField assumptions renaming (Carrier to F; _-_ to _-_) import MorePropAlgebra.Booij2020 open MorePropAlgebra.Booij2020.Chapter4 (record { PartiallyOrderedField assumptions }) open +-<-ext+·-preserves-<⇒ (PartiallyOrderedField.+-<-ext assumptions) (PartiallyOrderedField.·-preserves-< assumptions) -- open MorePropAlgebra.Properties.AlmostPartiallyOrderedField (record { PartiallyOrderedField assumptions }) hiding (_⁻¹) open import MorePropAlgebra.Properties.PartiallyOrderedField assumptions open PartiallyOrderedField assumptions renaming (Carrier to F; _-_ to _-_) hiding (_#_; _≤_) open AlmostPartiallyOrderedField' using (_#_; _≤_) open AlmostPartiallyOrderedField'Properties -- using (_⁻¹) -- NOTE: we are proving Bridges' properties with Booij's definition of _≤_ -- which is some form of cheating -- because we are interested in the properties, mostly -- or rather to check our definitions for "completeness" against these properties -- therefore our proofs differ from Brigdes' proofs -- and this approach does not show that from R1-* and R2-* follows Prop-* as in the paper private ≤⇒≤'' : ∀ x y → [ x ≤ y ] → [ x ≤'' y ] ≤⇒≤'' x y = ≤-⇔-≤'' x y .fst ≤''⇒≤ : ∀ x y → [ x ≤'' y ] → [ x ≤ y ] ≤''⇒≤ x y = ≤-⇔-≤'' x y .snd ≤-≡-≤'' : ∀ x y → (Liftᵖ {ℓ'} {ℓ} (x ≤ y)) ≡ (x ≤'' y) ≤-≡-≤'' x y = ⇔toPath ((≤⇒≤'' x y) ∘ (unliftᵖ (x ≤ y))) ((liftᵖ (x ≤ y)) ∘ (≤''⇒≤ x y)) is-0≡-0 : 0f ≡ - 0f is-0≡-0 = sym (+-inv 0f .snd) ∙ (+-identity (- 0f) .fst) -swaps-<ˡ : ∀ x y → [ (- x) < (- y) ⇒ y < x ] -swaps-<ˡ x y = [ - x < - y ] ⇒⟨ +-preserves-< _ _ _ ⟩ [ - x + x < - y + x ] ⇒⟨ subst (λ p → [ p < - y + x ]) (+-linv x) ⟩ [ 0f < - y + x ] ⇒⟨ subst (λ p → [ 0f < p ]) (+-comm (- y) x) ⟩ [ 0f < x - y ] ⇒⟨ +-preserves-< _ _ _ ⟩ [ 0f + y < (x - y) + y ] ⇒⟨ subst (λ p → [ p < (x - y) + y ]) (+-identity y .snd) ⟩ [ y < (x - y) + y ] ⇒⟨ subst (λ p → [ y < p ]) (sym $ +-assoc x (- y) y) ⟩ [ y < x + (- y + y) ] ⇒⟨ subst (λ p → [ y < x + p ]) (+-linv y) ⟩ [ y < x + 0f ] ⇒⟨ subst (λ p → [ y < p ]) (+-identity x .fst) ⟩ [ y < x ] ◼ -- invInvo -swaps-<ʳ : ∀ x y → [ x < y ⇒ (- y) < (- x) ] -swaps-<ʳ x y = [ x < y ] ⇒⟨ subst (λ p → [ p < y ]) (sym $ GroupLemmas'.invInvo x) ⟩ [ - - x < y ] ⇒⟨ subst (λ p → [ - - x < p ]) (sym $ GroupLemmas'.invInvo y) ⟩ [ - - x < - - y ] ⇒⟨ -swaps-<ˡ (- x) (- y) ⟩ [ - y < - x ] ◼ -swaps-< : ∀ x y → [ x < y ⇔ (- y) < (- x) ] -swaps-< x y .fst = -swaps-<ʳ x y -swaps-< x y .snd = -swaps-<ˡ y x ·-reflects-<0 : ∀ x y → [ 0f < y ] → [ x · y < 0f ] → [ x < 0f ] ·-reflects-<0 x y 0<y x·y<0 = ·-reflects-< x 0f y 0<y (subst (λ p → [ x · y < p ]) (sym $ RingTheory'.0-leftNullifies y) x·y<0) -- NOTE: Brigdes writes `x ≠ y` where we write `x # y` -- and `¬(x = y)` where we write `¬(x ≡ y)` -- Heyting field axioms R1-1 = ∀[ x ] ∀[ y ] [ is-set ] x + y ≡ˢ y + x R1-2 = ∀[ x ] ∀[ y ] ∀[ z ] [ is-set ] (x + y) + z ≡ˢ x + (y + z) R1-3 = ∀[ x ] [ is-set ] 0f + x ≡ˢ x R1-4 = ∀[ x ] [ is-set ] x + (- x) ≡ˢ 0f R1-5 = ∀[ x ] ∀[ y ] [ is-set ] x · y ≡ˢ y · x R1-6 = ∀[ x ] ∀[ y ] ∀[ z ] [ is-set ] (x · y) · z ≡ˢ x · (y · z) R1-7 = ∀[ x ] [ is-set ] 1f · x ≡ˢ x R1-8 = ∀[ x ] ∀[ p ∶ [ x # 0f ] ] [ is-set ] x · (x ⁻¹) {{p}} ≡ˢ 1f R1-9 = ∀[ x ] ∀[ y ] ∀[ z ] [ is-set ] x · (y + z) ≡ˢ x · y + x · z -- _<_ axioms R2-1 = ∀[ x ] ∀[ y ] ¬((x < y) ⊓ (y < x)) -- <-asym R2-2 = ∀[ x ] ∀[ y ] ( x < y) ⇒ (∀[ z ] (z < y) ⊔ (x < z)) -- <-cotrans R2-3 = ∀[ x ] ∀[ y ] ¬( x # y) ⇒ [ is-set ] x ≡ˢ y -- #-tight R2-4 = ∀[ x ] ∀[ y ] ( x < y) ⇒ (∀[ z ] (x + z) < (y + z)) -- +-preserves-< R2-5 = ∀[ x ] ∀[ y ] (0f < x) ⇒ (0f < y) ⇒ 0f < x · y -- ·-preserves-0< -- Special properties of _<_ -- R3-1 Axiom of Archimedes: `∀(x ∈ ℝ) → ∃[ n ∈ ℤ ] x < n` -- R3-2 The least-upper-bound principle: -- Let S be a nonempty subset of R that is bounded -- above relative to the relation ≥, such that for all real numbers α, β with α < β -- either β is an upper bound of S or else there exists s ∈ S with s > α; then S has a -- least upper bound. -- derivable properties Prop-1 = ∀[ x ] ¬(x < x) -- <-irrefl Prop-2 = ∀[ x ] x ≤ x -- ≤-refl Prop-3 = ∀[ x ] ∀[ y ] ∀[ z ] ( x < y ) ⇒ (y < z ) ⇒ x < z -- <-trans Prop-4 = ∀[ x ] ∀[ y ] ¬((x < y) ⊓ (y ≤ x)) Prop-5 = ∀[ x ] ∀[ y ] ∀[ z ] ( x ≤ y ) ⇒ (y < z ) ⇒ x < z -- ≤-<-trans Prop-6 = ∀[ x ] ∀[ y ] ∀[ z ] ( x < y ) ⇒ (y ≤ z ) ⇒ x < z -- <-≤-trans Prop-7 = ∀[ x ] ∀[ y ] (¬(x < y) ⇔ (y ≤ x)) -- definition of ≤ Prop-8 = ∀[ x ] ∀[ y ] (¬(x ≤ y) ⇔ ¬ ¬(y < x)) -- ≤ weaker than < Prop-9 = ∀[ x ] ∀[ y ] ∀[ z ] ( y ≤ z ) ⇒ (x ≤ y ) ⇒ (x ≤ z) -- ≤-trans Prop-10 = ∀[ x ] ∀[ y ] ( x ≤ y ) ⇒ (y ≤ x ) ⇒ [ is-set ] x ≡ˢ y -- ≤-antisym Prop-11 = ∀[ x ] ∀[ y ] ¬((x < y) ⊓ ([ is-set ] x ≡ˢ y)) Prop-12 = ∀[ x ] ( 0f ≤ x ) ⇒ ([ is-set ] x ≡ˢ 0f ⇔ (∀[ ε ] (0f < ε) ⇒ (x < ε))) Prop-13 = ∀[ x ] ∀[ y ] ( 0f < x + y) ⇒ (0f < x) ⊔ (0f < y) Prop-14 = ∀[ x ] ( 0f < x ) ⇒ - x < 0f -- -flips-<0 Prop-15 = ∀[ x ] ∀[ y ] ∀[ z ] ( x < y ) ⇒ (z < 0f) ⇒ y · z < x · z -- ·-preserves-< Prop-16 = ∀[ x ] ( x # 0f ) ⇒ 0f < x · x -- sqr-positive Prop-17 = 0f < 1f Prop-18 = ∀[ x ] 0f ≤ x · x -- sqr-nonnegative Prop-19 = ∀[ x ] ( 0f < x ) ⇒ (x < 1f) ⇒ x · x < x Prop-20 = ∀[ x ] ( - 1f < x ) ⇒ (x < 1f) ⇒ ¬((x < x · x) ⊓ (- x < x · x)) Prop-21 = ∀[ x ] ( 0f < x · x) ⇒ x # 0f Prop-22 = ∀[ x ] ( 0f < x ) ⇒ Σᵖ[ p ∶ x # 0f ] (0f ≤ (x ⁻¹) {{p}}) -- Prop-23 `∀ m m' n n' → 0 < n → 0 < n' → (m / n > m' / n') ⇔ (m · n' > m' · n)` -- Prop-24 `∀(n ∈ ℕ⁺) → (n ⁻¹ > 0)` -- Prop-25 `x > 0 → y ≥ 0 → ∃[ n ∈ ℤ ] n · x > y` -- Prop-26 `(x > 0) ⇒ (x ⁻¹ > 0)` -- Prop-27 `(x · y > 0) ⇒ (x ≠ 0) ⊓ (y ≠ 0)` -- Prop-28 `∀(x > 0) → ∃[ n ∈ ℕ⁺ ] x < n < x + 2` -- Prop-29 `∀ a b → a < b → ∃[ q ∈ ℚ ] a < r < b` r1-1 : ∀ x y → x + y ≡ y + x ; _ : [ R1-1 ]; _ = r1-1 r1-2 : ∀ x y z → (x + y) + z ≡ x + (y + z) ; _ : [ R1-2 ]; _ = r1-2 r1-3 : ∀ x → 0f + x ≡ x ; _ : [ R1-3 ]; _ = r1-3 r1-4 : ∀ x → x + (- x) ≡ 0f ; _ : [ R1-4 ]; _ = r1-4 r1-5 : ∀ x y → x · y ≡ y · x ; _ : [ R1-5 ]; _ = r1-5 r1-6 : ∀ x y z → (x · y) · z ≡ x · (y · z) ; _ : [ R1-6 ]; _ = r1-6 r1-7 : ∀ x → 1f · x ≡ x ; _ : [ R1-7 ]; _ = r1-7 r1-8 : ∀ x → (p : [ x # 0f ]) → x · (x ⁻¹) {{p}} ≡ 1f ; _ : [ R1-8 ]; _ = r1-8 r1-9 : ∀ x y z → x · (y + z) ≡ x · y + x · z; _ : [ R1-9 ]; _ = r1-9 r1-1 = +-comm r1-2 x y z = sym $ +-assoc x y z r1-3 x = +-identity x .snd r1-4 x = +-inv x .fst r1-5 = ·-comm r1-6 x y z = sym $ ·-assoc x y z r1-7 x = ·-identity x .snd r1-8 = ·-rinv r1-9 x y z = is-dist x y z .fst r2-1 : ∀ x y → [ ¬((x < y) ⊓ (y < x)) ]; _ : [ R2-1 ]; _ = r2-1 r2-2 : ∀ x y → [ x < y ] → ∀ z → [ (z < y) ⊔ (x < z) ]; _ : [ R2-2 ]; _ = r2-2 r2-3 : ∀ x y → [ ¬( x # y) ] → x ≡ y ; _ : [ R2-3 ]; _ = r2-3 r2-4 : ∀ x y → [ x < y ] → ∀ z → [ (x + z) < (y + z) ]; _ : [ R2-4 ]; _ = r2-4 r2-5 : ∀ x y → [ 0f < x ] → [ 0f < y ] → [ 0f < x · y ]; _ : [ R2-5 ]; _ = r2-5 r2-1 x y (x<y , y<x) = <-asym x y x<y y<x r2-2 x y x<y z = pathTo⇒ (⊔-comm (x < z) (z < y)) (<-cotrans x y x<y z) r2-3 = #-tight r2-4 x y x<y z = +-preserves-< x y z x<y r2-5 x y 0<x 0<y = subst (λ p → [ p < x · y ]) (RingTheory'.0-leftNullifies y) (·-preserves-< 0f x y 0<y 0<x) prop-1 : ∀ x → [ ¬(x < x) ]; _ : [ Prop-1 ]; _ = prop-1 prop-2 : ∀ x → [ x ≤ x ]; _ : [ Prop-2 ]; _ = prop-2 prop-3 : ∀ x y z → [ x < y ] → [ y < z ] → [ x < z ]; _ : [ Prop-3 ]; _ = prop-3 prop-4 : ∀ x y → [ ¬((x < y) ⊓ (y ≤ x)) ]; _ : [ Prop-4 ]; _ = prop-4 prop-5 : ∀ x y z → [ x ≤ y ] → [ y < z ] → [ x < z ]; _ : [ Prop-5 ]; _ = prop-5 prop-6 : ∀ x y z → [ x < y ] → [ y ≤ z ] → [ x < z ]; _ : [ Prop-6 ]; _ = prop-6 prop-7 : ∀ x y → [ (¬(x < y) ⇔ (y ≤ x))]; _ : [ Prop-7 ]; _ = prop-7 prop-8 : ∀ x y → [ ¬(x ≤ y) ⇔ ¬ ¬(y < x) ]; _ : [ Prop-8 ]; _ = prop-8 prop-9 : ∀ x y z → [ y ≤ z ] → [ x ≤ y ] → [ x ≤ z ]; _ : [ Prop-9 ]; _ = prop-9 prop-10 : ∀ x y → [ x ≤ y ] → [ y ≤ x ] → x ≡ y ; _ : [ Prop-10 ]; _ = prop-10 prop-11 : ∀ x y → ¬ᵗ ([ x < y ] × (x ≡ y)) ; _ : [ Prop-11 ]; _ = prop-11 prop-12 : ∀ x → [ 0f ≤ x ] → [ [ is-set ] x ≡ˢ 0f ⇔ (∀[ ε ] (0f < ε) ⇒ (x < ε)) ]; _ : [ Prop-12 ]; _ = prop-12 prop-13 : ∀ x y → [ 0f < x + y ] → [ (0f < x) ⊔ (0f < y) ]; _ : [ Prop-13 ]; _ = prop-13 prop-14 : ∀ x → [ 0f < x ] → [ - x < 0f ]; _ : [ Prop-14 ]; _ = prop-14 prop-14' : ∀ x → [ x < 0f ] → [ 0f < - x ] prop-15 : ∀ x y z → [ x < y ] → [ z < 0f ] → [ y · z < x · z ]; _ : [ Prop-15 ]; _ = prop-15 prop-16 : ∀ x → [ x # 0f ] → [ 0f < x · x ]; _ : [ Prop-16 ]; _ = prop-16 prop-17 : [ 0f < 1f ]; _ : [ Prop-17 ]; _ = prop-17 prop-18 : ∀ x → [ 0f ≤ x · x ]; _ : [ Prop-18 ]; _ = prop-18 prop-19 : ∀ x → [ 0f < x ] → [ x < 1f ] → [ x · x < x ]; _ : [ Prop-19 ]; _ = prop-19 prop-20 : ∀ x → [ - 1f < x ] → [ x < 1f ] → [ ¬((x < x · x) ⊓ (- x < x · x)) ]; _ : [ Prop-20 ]; _ = prop-20 prop-21 : ∀ x → [ 0f < x · x ] → [ x # 0f ]; _ : [ Prop-21 ]; _ = prop-21 prop-22 : ∀ x → [ 0f < x ] → Σ[ p ∈ [ x # 0f ] ] [ 0f ≤ (x ⁻¹) {{p}} ]; _ : [ Prop-22 ]; _ = prop-22 prop-22' : ∀ x → [ 0f < x ] → Σ[ p ∈ [ x # 0f ] ] [ 0f < (x ⁻¹) {{p}} ] prop-1 = <-irrefl prop-2 = ≤-refl prop-3 = <-trans prop-4 x y (x<y , y≤x) = y≤x x<y prop-5 = ≤-<-trans prop-6 = <-≤-trans prop-7 x y .fst = λ x → x -- holds definitionally for Booij's _≤_ prop-7 x y .snd = λ x → x prop-8 x y .fst = λ x → x -- holds definitionally for Booij's _≤_ prop-8 x y .snd = λ x → x -- holds definitionally for Booij's _≤_ prop-9 x y z y≤z x≤y = ≤-trans x y z x≤y y≤z prop-10 = ≤-antisym prop-11 x y (x<y , x≡y) = <-irrefl _ (pathTo⇒ (λ i → x≡y i < y) x<y) fst (prop-12 x 0≤x) x≡0 y 0<y = transport (λ i → [ x≡0 (~ i) < y ]) 0<y -- suppose that x < ε for all ε > 0. If x > 0, then x < x, a contradiction; so 0 ≥ x. Thus x ≥ 0 and 0 ≥ x, and therefore x = 0. -- this is just antisymmetry for different ≤s : ∀ x y → [ x ≤ y ] → [ y ≤'' x ] → x ≡ y snd (prop-12 x 0≤x) [∀ε>0∶x<ε] = let x≤0 : [ x ≤ 0f ] x≤0 0<x = <-irrefl x ([∀ε>0∶x<ε] x 0<x) in ≤-antisym x 0f x≤0 0≤x prop-13 x y 0<x+y = +-<-ext 0f 0f x y (subst (λ p → [ p < x + y ]) (sym (+-identity 0f .snd)) 0<x+y) -- -x = 0 + (-x) < x + (-x) = 0 prop-14 x = [ 0f < x ] ⇒⟨ +-preserves-< 0f x (- x) ⟩ [ 0f + (- x) < x + (- x) ] ⇒⟨ subst (λ p → [ 0f - x < p ]) (+-rinv x) ⟩ [ 0f + (- x) < 0f ] ⇒⟨ subst (λ p → [ p < 0f ]) (+-identity (- x) .snd) ⟩ [ - x < 0f ] ◼ -- -x = 0 + (-x) < x + (-x) = 0 prop-14' x = [ x < 0f ] ⇒⟨ +-preserves-< x 0f (- x) ⟩ [ x + (- x) < 0f + (- x) ] ⇒⟨ subst (λ p → [ x - x < p ]) (+-identity (- x) .snd) ⟩ [ x + (- x) < (- x) ] ⇒⟨ subst (λ p → [ p < - x ]) (+-rinv x) ⟩ [ 0f < (- x) ] ◼ -- since -z > 0 we have -- -xz = x(-z) > y(-z) = -yz -- so -xz + yz + xz > -yz + yz + xz prop-15 x y z x<y z<0 = ( [ x < y ] ⇒⟨ ·-preserves-< x y (- z) (prop-14' z z<0) ⟩ [ x · (- z) < y · (- z) ] ⇒⟨ subst (λ p → [ p < y · (- z) ]) (RingTheory'.-commutesWithRight-· x z) ⟩ [ - (x · z) < y · (- z) ] ⇒⟨ subst (λ p → [ -(x · z) < p ]) (RingTheory'.-commutesWithRight-· y z) ⟩ [ - (x · z) < - (y · z) ] ⇒⟨ -swaps-< (y · z) (x · z) .snd ⟩ [ y · z < x · z ] ◼) x<y prop-16 x (inl x<0) = ( [ x < 0f ] ⇒⟨ prop-14' x ⟩ [ 0f < - x ] ⇒⟨ ·-preserves-< 0f (- x) (- x) (prop-14' x x<0) ⟩ [ 0f · (- x) < (- x) · (- x) ] ⇒⟨ subst (λ p → [ p < (- x) · (- x) ]) (RingTheory'.0-leftNullifies (- x)) ⟩ [ 0f < (- x) · (- x) ] ⇒⟨ subst (λ p → [ 0f < p ]) (RingTheory'.-commutesWithRight-· (- x) x) ⟩ [ 0f < - ((- x) · x) ] ⇒⟨ subst (λ p → [ 0f < - p ]) (RingTheory'.-commutesWithLeft-· x x) ⟩ [ 0f < - - (x · x) ] ⇒⟨ subst (λ p → [ 0f < p ]) (GroupLemmas'.invInvo (x · x)) ⟩ [ 0f < x · x ] ◼) x<0 prop-16 x (inr 0<x) = ( [ 0f < x ] ⇒⟨ ·-preserves-< 0f x x 0<x ⟩ [ 0f · x < x · x ] ⇒⟨ subst (λ p → [ p < x · x ]) (RingTheory'.0-leftNullifies x) ⟩ [ 0f < x · x ] ◼) 0<x prop-17 = is-0<1 -- suppose x² < 0. Then ¬(x ≠ 0) by 16; so x = 0 and therefore x² = 0, a contradiction. Hence ¬(x² < 0) and therefore x² ≥ 0. prop-18 x x²<0 = let ¬x#0 = contraposition (x # 0f) (0f < x · x) (prop-16 x) (<-asym (x · x) 0f x²<0) x≡0 = r2-3 _ _ ¬x#0 x²≡0 = (λ i → x≡0 i · x≡0 i) ∙ RingTheory'.0-leftNullifies 0f in transport (λ i → [ ¬ (x²≡0 (~ i) < 0f) ] ) (<-irrefl 0f) x²<0 prop-19 x 0<x x<1 = subst (λ p → [ x · x < p ]) (·-lid x) (·-preserves-< x 1f x 0<x x<1) prop-20 x -1<x x<1 (x<x² , -x<x²) = -- Suppose that - 1 < x < 1 and that (x² > x ∧ x² > -x). let -- If x > 0, then x = x (-1) < x² < x(1) = x which contradicts our second assumption. Hence ¬(x > 0) and therefore x ≤ 0. argument1 : [ 0f < x ⇒ x · x < x ] argument1 0<x = subst (λ p → [ x · x < p ]) (·-identity x .snd) (·-preserves-< x 1f x 0<x x<1) x≤0 : [ x ≤ 0f ] x≤0 = contraposition (0f < x) (x · x < x) argument1 (<-asym _ _ x<x²) -- A similar argument shows that x ≥ 0. argument2 : [ x < 0f ⇒ x · x < - x ] argument2 x<0 = let 0<-x = subst (λ p → [ p < - x ]) (sym is-0≡-0) (-swaps-< x 0f .fst x<0) in ( [ (- 1f) · (- x) < x · (- x) ] ⇒⟨ subst (λ p → [ p < x · (- x) ]) (RingTheory'.-commutesWithLeft-· 1f (- x)) ⟩ [ -( 1f · (- x)) < x · (- x) ] ⇒⟨ subst (λ p → [ - p < x · (- x) ]) (·-identity (- x) .snd) ⟩ [ -( - x) < x · (- x) ] ⇒⟨ subst (λ p → [ - - x < p ]) (RingTheory'.-commutesWithRight-· x x) ⟩ [ -( - x) < -(x · x) ] ⇒⟨ -swaps-< (x · x) (- x) .snd ⟩ [ x · x < - x ] ◼) (·-preserves-< (- 1f) x (- x) 0<-x -1<x) 0≤x : [ 0f ≤ x ] 0≤x = contraposition (x < 0f) (x · x < - x) argument2 (<-asym _ _ -x<x²) -- whence x = 0. x≡0 = ≤-antisym x 0f x≤0 0≤x -- But in that case we have -x = x² = x, again a contradiction. x<0 = subst (λ p → [ x < p ]) (RingTheory'.0-leftNullifies 0f) (subst (λ p → [ x < p · p ]) x≡0 x<x²) -x<0 = subst (λ p → [ - x < p ]) (RingTheory'.0-leftNullifies 0f) (subst (λ p → [ - x < p · p ]) x≡0 -x<x²) 0<x = -swaps-< 0f x .snd (subst (λ p → [ - x < p ]) is-0≡-0 -x<0) in <-asym _ _ 0<x x<0 -- Either x > 0 or x² > x. prop-21 x 0<x² = case <-cotrans 0f (x · x) 0<x² x as (0f < x) ⊔ (x < x · x) ⇒ x # 0f of λ { (inl 0<x ) → inr 0<x -- In the latter case, either x² > -x or -x > x. ; (inr x<x²) → case <-cotrans x (x · x) x<x² (- x) as (x < - x) ⊔ (- x < x · x) ⇒ x # 0f of λ -- Suppose -x > x. Then x - x > x + x = 2x, so 0 > x. { (inl x<-x) → let x<0 : [ x < 0f ] x<0 = ( [ x < - x ] ⇒⟨ +-preserves-< x (- x) x ⟩ [ x + x < - x + x ] ⇒⟨ subst (λ p → [ x + x < p ]) (+-inv x .snd) ⟩ [ x + x < 0f ] ⇒⟨ subst (λ p → [ p + p < 0f ]) (sym $ ·-identity x .fst) ⟩ [ x · 1f + x · 1f < 0f ] ⇒⟨ subst (λ p → [ p < 0f ]) (sym $ is-dist x 1f 1f .fst) ⟩ [ x · (1f + 1f) < 0f ] ⇒⟨ ·-reflects-<0 x (1f + 1f) (<-trans 0f 1f (1f + 1f) is-0<1 (subst (λ p → [ p < 1f + 1f ]) (+-identity 1f .snd) (+-preserves-< 0f 1f 1f is-0<1))) ⟩ [ x < 0f ] ◼) x<-x in inl x<0 -- Thus we may assume that x² > x and x² < -x. ; (inr -x<x²) → case <-cotrans 0f 1f is-0<1 x as (0f < x) ⊔ (x < 1f) ⇒ x # 0f of λ -- then either x > 0 or 1 > x. { (inl 0<x) → inr 0<x -- In the latter case, if x > -1, then we cotradict 20; so 0 > -1 ≥ x ; (inr x<1) → let x≤-1 : [ x ≤ - 1f ] x≤-1 -1<x = prop-20 x -1<x x<1 (x<x² , -x<x²) -1<0 : [ - 1f < 0f ] -1<0 = subst (λ p → [ - 1f < p ]) (sym is-0≡-0) (-swaps-< 0f 1f .fst is-0<1) -- and therefore 0 > x. in inl $ ≤-<-trans _ _ _ x≤-1 -1<0 } } } prop-22 x 0<x = let instance _ = inr 0<x in it , <-asym _ _ (⁻¹-preserves-sign _ _ 0<x (·-rinv x it)) prop-22' x 0<x = let instance _ = inr 0<x in it , ⁻¹-preserves-sign _ _ 0<x (·-rinv x it)
{ "alphanum_fraction": 0.3946349558, "avg_line_length": 59.9337016575, "ext": "agda", "hexsha": "324ead55588d84d5cf04f10a630236d697aa9994", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MorePropAlgebra/Bridges1999.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MorePropAlgebra/Bridges1999.agda", "max_line_length": 199, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MorePropAlgebra/Bridges1999.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 8977, "size": 21696 }
------------------------------------------------------------------------ -- Convenient syntax for equational reasoning ------------------------------------------------------------------------ -- Example use: -- n*0≡0 : ∀ n → n * 0 ≡ 0 -- n*0≡0 zero = refl -- n*0≡0 (suc n) = -- begin -- suc n * 0 -- ≈⟨ byDef ⟩ -- n * 0 + 0 -- ≈⟨ n+0≡n _ ⟩ -- n * 0 -- ≈⟨ n*0≡0 n ⟩ -- 0 -- ∎ open import Relation.Binary module Relation.Binary.EqReasoning (s : Setoid) where open Setoid s import Relation.Binary.PreorderReasoning as PreR open PreR preorder public renaming ( _∼⟨_⟩_ to _≈⟨_⟩_ ; _≈⟨_⟩_ to _≡⟨_⟩_ )
{ "alphanum_fraction": 0.4014925373, "avg_line_length": 22.3333333333, "ext": "agda", "hexsha": "a121546e099b4d0ad86d20fc5de2c6eb2788274f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/EqReasoning.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/EqReasoning.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/EqReasoning.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 228, "size": 670 }
-- In this document we'll show that having `ifix :: ((k -> *) -> k -> *) -> k -> *` is enough to -- get `fix :: (k -> k) -> k` for any particular `k`. module IFixIsEnough where open import Agda.Primitive -- First, the definition of `IFix`: {-# NO_POSITIVITY_CHECK #-} data IFix {α φ} {A : Set α} (F : (A -> Set φ) -> A -> Set φ) (x : A) : Set φ where wrap : F (IFix F) x -> IFix F x -- We'll be calling `F` a pattern functor and `x` an index. open import Function -- The simplest non-trivial case of an n-ary higher-kinded `fix` is -- fix2 :: ((j -> k -> *) -> j -> k -> *) -> j -> k -> * -- So we'll start from encoding this fixed-point combinator. module FixProduct where -- In Agda it has the following signature: Fix₂ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set -- One way of getting this type is by going through type-level tuples. open import Data.Product -- Having (defined for clarity) Fixₓ : {A B : Set} -> ((A × B -> Set) -> A × B -> Set) -> A × B -> Set Fixₓ = IFix -- we can just sprinkle `curry` and `uncurry` in appropriate places and get the desired definition: ConciseFix₂ₓ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set ConciseFix₂ₓ F = curry (Fixₓ (uncurry ∘ F ∘ curry)) -- which after some expansion becomes Fix₂ {A} {B} F = λ x y -> Fixₓ (λ Rec -> uncurry (F (λ x′ y′ -> Rec (x′ , y′)))) (x , y) -- The main idea here is that since `IFix` receives onle one index, we need to somehow package the -- two indices we have (`x` and `y`) together to get a single index. And the simplest solution is -- just to make a two-element tuple out of `x` and `y`. -- However, this simple solution does not apply to vanilla System F-omega, because we do not have -- type-level tuples there. Hence some another way of packaging things together is required. module FixEncodedProduct where -- The fact that we only use tuples at the type level suggests the following encoding of them: _×̲_ : Set -> Set -> Set₁ -- Type \x\_-- to get ×̲. A ×̲ B = (A -> B -> Set) -> Set -- Which is just the usual Church encoding (okay-okay, Boehm-Berarducci encoding) _Church×_ : ∀ {ρ} -> Set -> Set -> Set (lsuc ρ) _Church×_ {ρ} A B = {R : Set ρ} -> (A -> B -> R) -> R -- with `R` (not the type of `R`, but `R` itself) instantiated to `Set`. -- Here is a combinator that allows to recurse over `A ×̲ B` just like `Fixₓ` from the above -- allowed to recurse over `A × B`: abstract -- We'll be marking some things as `abstract` just to get nice output from Agda when -- we ask it to normalize things. Fixₓ̲ : {A B : Set} -> ((A ×̲ B -> Set) -> A ×̲ B -> Set) -> A ×̲ B -> Set -- Type \_x\_-- to get ₓ̲. Fixₓ̲ = IFix -- Now we have `A ×̲ B -> Set` appearing thrice in a type signature. We can simplify this expression: -- A ×̲ B -> Set ~ (by definition) -- ((A -> B -> Set) -> Set) -> Set ~ (see below) -- A -> B -> Set -- The fact that we can go from `((A -> B -> Set) -> Set) -> Set` to `A -> B -> Set` is related to -- the fact that triple negation is equivalent to single negation in a type theory. In fact, we can -- go from any `((A -> R) -> R) -> R` to `A -> R` and vice versa as witnessed by module TripleNegation where tripleToSingle : ∀ {α ρ} {A : Set α} {R : Set ρ} -> (((A -> R) -> R) -> R) -> A -> R tripleToSingle h x = h λ f -> f x singleToTriple : ∀ {α ρ} {A : Set α} {R : Set ρ} -> (A -> R) -> ((A -> R) -> R) -> R singleToTriple f h = h f -- Here are the `curry` and `uncurry` combinators then: curryₓ̲ : ∀ {α β ρ} {A : Set α} {B : Set β} {R : Set ρ} -> (((A -> B -> R) -> R) -> R) -> A -> B -> R curryₓ̲ h x y = h λ f -> f x y abstract uncurryₓ̲ : ∀ {α β ρ} {A : Set α} {B : Set β} {R : Set ρ} -> (A -> B -> R) -> ((A -> B -> R) -> R) -> R uncurryₓ̲ f h = h f -- And the definition of `ConciseFix₂` following the same pattern as the one from the previous section: ConciseFix₂ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set ConciseFix₂ F = curryₓ̲ (Fixₓ̲ (uncurryₓ̲ ∘ F ∘ curryₓ̲)) -- Compare to the previous one: -- ConciseFix₂ₓ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set -- ConciseFix₂ₓ F = curry (Fixₓ (uncurry ∘ F ∘ curry)) -- We can now ask Agda to normalize `ConciseFix₂`. After some alpha-renaming we get NormedConciseFix₂ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set NormedConciseFix₂ {A} {B} F = λ x y -> Fixₓ̲ (λ Rec -> uncurryₓ̲ (F (λ x′ y′ -> Rec (λ On -> On x′ y′)))) (λ On -> On x y) -- which is very similar to what we had previously -- Fix₂ₓ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set -- Fix₂ₓ {A} {B} F = λ x y -> -- Fixₓ (λ Rec -> uncurry (F (λ x′ y′ -> Rec (x′ , y′)))) (x , y) -- except we now have `λ On -> On x y` instead of `(x , y)`. What is this new thing? Well: _,̲_ : {A B : Set} -> A -> B -> A ×̲ B -- Type ,\_-- to get ,̲. _,̲_ {A} {B} x y = λ (On : A -> B -> Set) -> On x y -- it's just a new way to package `x` and `y` together without ever touching tuples-as-data. Here -- we use a function in order to turn two indices into a single one. -- `λ On -> On x y` is the Church-encoded version of `(x , y)` (where `_,_` constructs data). -- Using `_,̲_` for clarity we arrive at the following: Fix₂ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set Fix₂ {A} {B} F = λ x y -> Fixₓ̲ (λ Rec -> uncurryₓ̲ (F (λ x′ y′ -> Rec (x′ ,̲ y′)))) (x ,̲ y) -- Compare again to the definition from the previous section: -- Fix₂ₓ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set -- Fix₂ₓ {A} {B} F = λ x y -> -- Fixₓ (λ Rec -> uncurry (F (λ x′ y′ -> Rec (x′ , y′)))) (x , y) -- The pattern is clearly the same. But now we do not use any type-level data, only lambda abstractions -- and function applications which we do have at the type level in System F-omega, so it all is legal -- there. module Direct where -- In this section we'll encode other higher-kinded `Fix`es in addition to `Fix₂` from -- the previous section. -- `Fix₂` with everything inlined and computed down to normal form looks like this: Fix₂ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set Fix₂ {A} {B} F = λ x y -> IFix (λ Rec Spine -> Spine (F λ x′ y′ -> Rec (λ On -> On x′ y′))) (λ On -> On x y) -- `Fix₃` is the same, just an additional argument `z` (and `z′`) is added here and there: Fix₃ : {A B C : Set} -> ((A -> B -> C -> Set) -> A -> B -> C -> Set) -> A -> B -> C -> Set Fix₃ F = λ x y z -> IFix (λ Rec Spine -> Spine (F λ x′ y′ z′ -> Rec (λ On -> On x′ y′ z′))) (λ On -> On x y z) -- Correspondingly, `Fix₁` is `Fix₂` minus `y` (and `y′`): Fix₁ : {A : Set} -> ((A -> Set) -> A -> Set) -> A -> Set Fix₁ F = λ x -> IFix (λ Rec Spine -> Spine (F λ x′ -> Rec (λ On -> On x′))) (λ On -> On x) -- But `Fix₁` has the same signature as `IFix`, so we can just define it as Fix₁′ : {A : Set} -> ((A -> Set) -> A -> Set) -> A -> Set Fix₁′ = IFix -- `Fix₀` can be defined in the same manner as `Fix₂`, except we strip off all indices and encode -- the empty tuple as `λ On -> On`. Fix₀ : (Set -> Set) -> Set Fix₀ F = IFix (λ Rec spine -> spine (F (Rec (λ On -> On)))) (λ On -> On) -- There is another way to define `Fix₀`, we can just pass a dummy argument as an index: Fix₀′′ : (Set -> Set) -> Set Fix₀′′ F = IFix (λ Rec ⊥ -> F (Rec ⊥)) ((A : Set) -> A) -- The argument is never used and is only needed, because we have to provide *some* index. -- Another way is to pass `F` itself as an index rather than some dummy argument: Fix₀′ : (Set -> Set) -> Set Fix₀′ = IFix λ Rec F -> F (Rec F) -- This is perhaps the nicest way. module Generic where -- In this section we'll define `FixBy` which generalizes all of `Fix₀`, `Fix₁`, `Fix₂`, etc. -- In -- Fix₂ : {A B : Set} -> ((A -> B -> Set) -> A -> B -> Set) -> A -> B -> Set -- Fix₂ {A} {B} F = λ x y -> -- IFix (λ Rec Spine -> Spine (F λ x′ y′ -> Rec (λ On -> On x′ y′))) (λ On -> On x y) -- we see that wherever `x` and `y` are bound, they're also packaged by `λ On -> On ...` and the -- entire thing is passed to something else. This holds for the inner -- λ x′ y′ -> Rec (λ On -> On x′ y′) -- as well as for the outer -- λ x y -> ... (λ On -> On x y) -- This pattern can be easily abstracted: FixBy : ∀ {κ φ} {K : Set κ} -> (((K -> Set φ) -> Set φ) -> K) -> (K -> K) -> K FixBy WithSpine F = WithSpine (IFix λ Rec Spine -> Spine (F (WithSpine Rec))) -- `WithSpine` encapsulates spine construction and feeds constructed spines to a continuation. -- Being equipped like that we can easily define an n-ary higher-kinded `fix` for any `n`: Fix₀ : ∀ {φ} -> (Set φ -> Set φ) -> Set φ Fix₀ = FixBy λ Cont -> Cont λ On -> On Fix₁ : ∀ {α φ} {A : Set α} -> ((A -> Set φ) -> A -> Set φ) -> A -> Set φ Fix₁ = FixBy λ Cont x -> Cont λ On -> On x Fix₂ : ∀ {α β φ} {A : Set α} {B : Set β} -> ((A -> B -> Set φ) -> A -> B -> Set φ) -> A -> B -> Set φ Fix₂ = FixBy λ Cont x y -> Cont λ On -> On x y Fix₃ : ∀ {α β γ φ} {A : Set α} {B : Set β} {C : Set γ} -> ((A -> B -> C -> Set φ) -> A -> B -> C -> Set φ) -> A -> B -> C -> Set φ Fix₃ = FixBy λ Cont x y z -> Cont λ On -> On x y z module DirectGenericSame where open import Relation.Binary.PropositionalEquality -- The 'direct' and 'generic' encodings result in literally the same code. Here are a few examples: directIsGeneric₀ : ∀ {F} -> Direct.Fix₀ F ≡ Generic.Fix₀ F directIsGeneric₀ = refl directIsGeneric₁ : ∀ {A F} {x : A} -> Direct.Fix₁ F x ≡ Generic.Fix₁ F x directIsGeneric₁ = refl directIsGeneric₂ : ∀ {A B F} {x : A} {y : B} -> Direct.Fix₂ F x y ≡ Generic.Fix₂ F x y directIsGeneric₂ = refl directIsGeneric₃ : ∀ {A B C F} {x : A} {y : B} {z : C} -> Direct.Fix₃ F x y z ≡ Generic.Fix₃ F x y z directIsGeneric₃ = refl -- Tests: module Test where open import Data.Maybe.Base open Generic module Nat where Nat : Set Nat = Fix₀ Maybe pattern zero = wrap nothing pattern suc n = wrap (just n) elimNat : {P : Nat -> Set} -> P zero -> (∀ n -> P n -> P (suc n)) -> ∀ n -> P n elimNat z f zero = z elimNat z f (suc n) = f n (elimNat z f n) module List where data ListF (R : Set -> Set) A : Set where nilF : ListF R A consF : A -> R A -> ListF R A List : Set -> Set List = Fix₁ ListF pattern [] = wrap nilF pattern _∷_ x xs = wrap (consF x xs) elimList : ∀ {A} {P : List A -> Set} -> P [] -> (∀ x xs -> P xs -> P (x ∷ xs)) -> ∀ xs -> P xs elimList z f [] = z elimList z f (x ∷ xs) = f x xs (elimList z f xs) module InterleavedList where open import Data.Unit.Base open import Data.Bool.Base open import Data.Nat.Base open import Data.Sum.Base open import Data.Product InterleavedList : Set -> Set -> Set InterleavedList = Fix₂ λ Rec A B -> ⊤ ⊎ A × B × Rec B A pattern [] = wrap (inj₁ tt) pattern cons x y ps = wrap (inj₂ (x , y , ps)) example_interleavedList : InterleavedList ℕ Bool example_interleavedList = cons 0 false ∘′ cons true 1 ∘′ cons 2 false $ [] elimInterleavedList : ∀ {A B} {P : ∀ {A B} -> InterleavedList A B -> Set} -> (∀ {A B} -> P {A} {B} []) -> (∀ {A B} x y ps -> P {A} {B} ps -> P (cons x y ps)) -> ∀ ps -> P {A} {B} ps elimInterleavedList z f [] = z elimInterleavedList z f (cons x y ps) = f x y ps (elimInterleavedList z f ps) module Unicode where -- This file uses the following unicode: -- ×̲ 0xD7 \x\_--
{ "alphanum_fraction": 0.5431467828, "avg_line_length": 36.2796352584, "ext": "agda", "hexsha": "d8fc43d8a6d0432ed72dab5c9114b08e83c91596", "lang": "Agda", "max_forks_count": 399, "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_path": "notes/fomega/mutual-type-level-recursion/IFixIsEnough.agda", "max_issues_count": 2493, "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_path": "notes/fomega/mutual-type-level-recursion/IFixIsEnough.agda", "max_line_length": 106, "max_stars_count": 1299, "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_path": "notes/fomega/mutual-type-level-recursion/IFixIsEnough.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "num_tokens": 4199, "size": 11936 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Presheaf.Properties where open import Cubical.Categories.Category open import Cubical.Categories.NaturalTransformation open import Cubical.Categories.Instances.Sets open import Cubical.Categories.Instances.Functors open import Cubical.Categories.Functor open import Cubical.Categories.Presheaf.Base open import Cubical.Categories.Equivalence open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv using (fiber) open import Cubical.Data.Sigma import Cubical.Categories.Morphism as Morphism import Cubical.Categories.Constructions.Slice as Slice import Cubical.Categories.Constructions.Elements as Elements import Cubical.Functions.Fibration as Fibration private variable ℓ ℓ' : Level e e' : Level -- (PreShv C) / F ≃ᶜ PreShv (∫ᴾ F) module _ {ℓS : Level} (C : Precategory ℓ ℓ') (F : Functor (C ^op) (SET ℓS)) where open Precategory open Functor open _≃ᶜ_ open isEquivalence open NatTrans open NatIso open Slice (PreShv C ℓS) F ⦃ isCatPreShv {C = C} ⦄ open Elements {C = C} open Fibration.ForSets -- specific case of fiber under natural transformation fibersEqIfRepsEqNatTrans : ∀ {A} (ϕ : A ⇒ F) {c x x'} {px : x ≡ x'} {a' : fiber (ϕ ⟦ c ⟧) x} {b' : fiber (ϕ ⟦ c ⟧) x'} → fst a' ≡ fst b' → PathP (λ i → fiber (ϕ ⟦ c ⟧) (px i)) a' b' fibersEqIfRepsEqNatTrans ϕ {c} {x} {x'} {px} {a , fiba} {b , fibb} p = fibersEqIfRepsEq {isSetB = snd (F ⟅ c ⟆)} (ϕ ⟦ c ⟧) p -- ======================================== -- K : Slice → PreShv -- ======================================== -- action on (slice) objects K-ob : (s : SliceCat .ob) → (PreShv (∫ᴾ F) ℓS .ob) -- we take (c , x) to the fiber in A of ϕ over x K-ob (sliceob {A} ϕ) .F-ob (c , x) = (fiber (ϕ ⟦ c ⟧) x) , isOfHLevelΣ 2 (snd (A ⟅ c ⟆)) λ _ → isSet→isGroupoid (snd (F ⟅ c ⟆)) _ _ -- for morphisms, we just apply A ⟪ h ⟫ (plus equality proof) K-ob (sliceob {A} ϕ) .F-hom {d , y} {c , x} (h , com) (b , eq) = ((A ⟪ h ⟫) b) , ((ϕ ⟦ c ⟧) ((A ⟪ h ⟫) b) ≡[ i ]⟨ (ϕ .N-hom h) i b ⟩ (F ⟪ h ⟫) ((ϕ ⟦ d ⟧) b) ≡[ i ]⟨ (F ⟪ h ⟫) (eq i) ⟩ (F ⟪ h ⟫) y ≡⟨ sym com ⟩ x ∎) -- functoriality follows from functoriality of A K-ob (sliceob {A} ϕ) .F-id {x = (c , x)} = funExt λ { (a , fibp) → fibersEqIfRepsEqNatTrans ϕ (λ i → A .F-id i a) } K-ob (sliceob {A} ϕ) .F-seq {x = (c , x)} {(d , y)} {(e , z)} (f' , eq1) (g' , eq2) = funExt λ { ( a , fibp ) → fibersEqIfRepsEqNatTrans ϕ (λ i → (A .F-seq f' g') i a) } -- action on morphisms (in this case, natural transformation) K-hom : {sA sB : SliceCat .ob} → (ε : SliceCat [ sA , sB ]) → (K-ob sA) ⇒ (K-ob sB) K-hom {sA = s1@(sliceob {A} ϕ)} {s2@(sliceob {B} ψ)} (slicehom ε com) = natTrans η-ob (λ h → funExt (η-hom h)) where P = K-ob s1 Q = K-ob s2 -- just apply the natural transformation (ε) we're given -- this ensures that we stay in the fiber over x due to the commutativity given by slicenesss η-ob : (el : (∫ᴾ F) .ob) → (fst (P ⟅ el ⟆) → fst (Q ⟅ el ⟆) ) η-ob (c , x) (a , ϕa≡x) = ((ε ⟦ c ⟧) a) , εψ≡ϕ ∙ ϕa≡x where εψ≡ϕ : (ψ ⟦ c ⟧) ((ε ⟦ c ⟧) a) ≡ (ϕ ⟦ c ⟧) a εψ≡ϕ i = ((com i) ⟦ c ⟧) a η-hom : ∀ {el1 el2} (h : (∫ᴾ F) [ el1 , el2 ]) (ae : fst (P ⟅ el2 ⟆)) → η-ob el1 ((P ⟪ h ⟫) ae) ≡ (Q ⟪ h ⟫) (η-ob el2 ae) η-hom {el1 = (c , x)} {d , y} (h , eqh) (a , eqa) = fibersEqIfRepsEqNatTrans ψ (λ i → ε .N-hom h i a) K : Functor SliceCat (PreShv (∫ᴾ F) ℓS) K .F-ob = K-ob K .F-hom = K-hom K .F-id = makeNatTransPath (funExt λ cx@(c , x) → funExt λ aeq@(a , eq) → fibersEqIfRepsEq {isSetB = snd (F ⟅ c ⟆)} _ refl) K .F-seq (slicehom α eqa) (slicehom β eqb) = makeNatTransPath (funExt λ cx@(c , x) → funExt λ aeq@(a , eq) → fibersEqIfRepsEq {isSetB = snd (F ⟅ c ⟆)} _ refl) -- ======================================== -- L : PreShv → Slice -- ======================================== -- action on objects (presheaves) L-ob : (P : PreShv (∫ᴾ F) ℓS .ob) → SliceCat .ob L-ob P = sliceob {S-ob = L-ob-ob} L-ob-hom where -- sends c to the disjoint union of all the images under P LF-ob : (c : C .ob) → (SET _) .ob LF-ob c = (Σ[ x ∈ fst (F ⟅ c ⟆) ] fst (P ⟅ c , x ⟆)) , isSetΣ (snd (F ⟅ c ⟆)) (λ x → snd (P ⟅ c , x ⟆)) -- defines a function piecewise over the fibers by applying P LF-hom : ∀ {x y} → (f : C [ y , x ]) → (SET _) [ LF-ob x , LF-ob y ] LF-hom {x = c} {d} f (x , a) = ((F ⟪ f ⟫) x) , (P ⟪ f , refl ⟫) a L-ob-ob : Functor (C ^op) (SET _) L-ob-ob .F-ob = LF-ob L-ob-ob .F-hom = LF-hom L-ob-ob .F-id {x = c} = funExt idFunExt where idFunExt : ∀ (un : fst (LF-ob c)) → (LF-hom (C .id c) un) ≡ un idFunExt (x , X) = ΣPathP (leftEq , rightEq) where leftEq : (F ⟪ C .id c ⟫) x ≡ x leftEq i = F .F-id i x rightEq : PathP (λ i → fst (P ⟅ c , leftEq i ⟆)) ((P ⟪ C .id c , refl ⟫) X) X rightEq = left ▷ right where -- the id morphism in (∫ᴾ F) ∫id = C .id c , sym (funExt⁻ (F .F-id) x ∙ refl) -- functoriality of P gives us close to what we want right : (P ⟪ ∫id ⟫) X ≡ X right i = P .F-id i X -- but need to do more work to show that (C .id c , refl) ≡ ∫id left : PathP (λ i → fst (P ⟅ c , leftEq i ⟆)) ((P ⟪ C .id c , refl ⟫) X) ((P ⟪ ∫id ⟫) X) left i = (P ⟪ ∫ᴾhomEq {F = F} (C .id c , refl) ∫id (λ i → (c , leftEq i)) refl refl i ⟫) X L-ob-ob .F-seq {x = c} {d} {e} f g = funExt seqFunEq where seqFunEq : ∀ (un : fst (LF-ob c)) → (LF-hom (g ⋆⟨ C ⟩ f) un) ≡ (LF-hom g) (LF-hom f un) seqFunEq un@(x , X) = ΣPathP (leftEq , rightEq) where -- the left component is comparing the action of F on x -- equality follows from functoriality of F -- leftEq : fst (LF-hom (g ⋆⟨ C ⟩ f) un) ≡ fst ((LF-hom g) (LF-hom f un)) leftEq : (F ⟪ g ⋆⟨ C ⟩ f ⟫) x ≡ (F ⟪ g ⟫) ((F ⟪ f ⟫) x) leftEq i = F .F-seq f g i x -- on the right, equality also follows from functoriality of P -- but it's more complicated because of heterogeneity -- since leftEq is not a definitional equality rightEq : PathP (λ i → fst (P ⟅ e , leftEq i ⟆)) ((P ⟪ g ⋆⟨ C ⟩ f , refl ⟫) X) ((P ⟪ g , refl ⟫) ((P ⟪ f , refl ⟫) X)) rightEq = left ▷ right where -- functoriality of P only gets us to this weird composition on the left right : (P ⟪ (g , refl) ⋆⟨ (∫ᴾ F) ⟩ (f , refl) ⟫) X ≡ (P ⟪ g , refl ⟫) ((P ⟪ f , refl ⟫) X) right i = P .F-seq (f , refl) (g , refl) i X -- so we need to show that this composition is actually equal to the one we want left : PathP (λ i → fst (P ⟅ e , leftEq i ⟆)) ((P ⟪ g ⋆⟨ C ⟩ f , refl ⟫) X) ((P ⟪ (g , refl) ⋆⟨ (∫ᴾ F) ⟩ (f , refl) ⟫) X) left i = (P ⟪ ∫ᴾhomEq {F = F} (g ⋆⟨ C ⟩ f , refl) ((g , refl) ⋆⟨ (∫ᴾ F) ⟩ (f , refl)) (λ i → (e , leftEq i)) refl refl i ⟫) X L-ob-hom : L-ob-ob ⇒ F L-ob-hom .N-ob c (x , _) = x L-ob-hom .N-hom f = funExt λ (x , _) → refl -- action on morphisms (aka natural transformations between presheaves) -- is essentially the identity (plus equality proofs for naturality and slice commutativity) L-hom : ∀ {P Q} → PreShv (∫ᴾ F) ℓS [ P , Q ] → SliceCat [ L-ob P , L-ob Q ] L-hom {P} {Q} η = slicehom arr com where A = S-ob (L-ob P) ϕ = S-arr (L-ob P) B = S-ob (L-ob Q) ψ = S-arr (L-ob Q) arr : A ⇒ B arr .N-ob c (x , X) = x , ((η ⟦ c , x ⟧) X) arr .N-hom {c} {d} f = funExt natu where natuType : fst (A ⟅ c ⟆) → Type _ natuType xX@(x , X) = ((F ⟪ f ⟫) x , (η ⟦ d , (F ⟪ f ⟫) x ⟧) ((P ⟪ f , refl ⟫) X)) ≡ ((F ⟪ f ⟫) x , (Q ⟪ f , refl ⟫) ((η ⟦ c , x ⟧) X)) natu : ∀ (xX : fst (A ⟅ c ⟆)) → natuType xX natu (x , X) = ΣPathP (refl , λ i → (η .N-hom (f , refl) i) X) com : arr ⋆⟨ PreShv C ℓS ⟩ ψ ≡ ϕ com = makeNatTransPath (funExt comFunExt) where comFunExt : ∀ (c : C .ob) → (arr ●ᵛ ψ) ⟦ c ⟧ ≡ ϕ ⟦ c ⟧ comFunExt c = funExt λ x → refl L : Functor (PreShv (∫ᴾ F) ℓS) SliceCat L .F-ob = L-ob L .F-hom = L-hom L .F-id {cx} = SliceHom-≡-intro' (makeNatTransPath (funExt λ c → refl)) L .F-seq {cx} {dy} P Q = SliceHom-≡-intro' (makeNatTransPath (funExt λ c → refl)) -- ======================================== -- η : 𝟙 ≅ LK -- ======================================== module _ where open Iso open Morphism renaming (isIso to isIsoC) -- the iso we need -- a type is isomorphic to the disjoint union of all its fibers typeSectionIso : ∀ {A B : Type ℓS} {isSetB : isSet B} → (ϕ : A → B) → Iso A (Σ[ b ∈ B ] fiber ϕ b) typeSectionIso ϕ .fun a = (ϕ a) , (a , refl) typeSectionIso ϕ .inv (b , (a , eq)) = a typeSectionIso {isSetB = isSetB} ϕ .rightInv (b , (a , eq)) = ΣPathP (eq , ΣPathP (refl , isOfHLevel→isOfHLevelDep 1 (λ b' → isSetB _ _) refl eq eq)) typeSectionIso ϕ .leftInv a = refl -- the natural transformation -- just applies typeSectionIso ηTrans : 𝟙⟨ SliceCat ⟩ ⇒ (L ∘F K) ηTrans .N-ob sob@(sliceob {A} ϕ) = slicehom A⇒LK comm where LKA = S-ob (L ⟅ K ⟅ sob ⟆ ⟆) ψ = S-arr (L ⟅ K ⟅ sob ⟆ ⟆) A⇒LK : A ⇒ LKA A⇒LK .N-ob c = typeSectionIso {isSetB = snd (F ⟅ c ⟆)} (ϕ ⟦ c ⟧) .fun A⇒LK .N-hom {c} {d} f = funExt homFunExt where homFunExt : (x : fst (A ⟅ c ⟆)) → (((ϕ ⟦ d ⟧) ((A ⟪ f ⟫) x)) , ((A ⟪ f ⟫) x , refl)) ≡ ((F ⟪ f ⟫) ((ϕ ⟦ c ⟧) x) , (A ⟪ f ⟫) x , _) homFunExt x = ΣPathP ((λ i → (ϕ .N-hom f i) x) , fibersEqIfRepsEqNatTrans ϕ refl) comm : (A⇒LK) ●ᵛ ψ ≡ ϕ comm = makeNatTransPath (funExt λ x → refl) ηTrans .N-hom {sliceob {A} α} {sliceob {B} β} (slicehom ϕ eq) = SliceHom-≡-intro' (makeNatTransPath (funExt (λ c → funExt λ a → natFunExt c a))) where natFunExt : ∀ (c : C .ob) (a : fst (A ⟅ c ⟆)) → ((β ⟦ c ⟧) ((ϕ ⟦ c ⟧) a) , (ϕ ⟦ c ⟧) a , _) ≡ ((α ⟦ c ⟧) a , (ϕ ⟦ c ⟧) a , _) natFunExt c a = ΣPathP ((λ i → ((eq i) ⟦ c ⟧) a) , fibersEqIfRepsEqNatTrans β refl) -- isomorphism follows from typeSectionIso ηIso : ∀ (sob : SliceCat .ob) → isIsoC {C = SliceCat} (ηTrans ⟦ sob ⟧) ηIso sob@(sliceob ϕ) = sliceIso _ _ (FUNCTORIso _ _ _ isIsoCf) where isIsoCf : ∀ (c : C .ob) → isIsoC (ηTrans .N-ob sob .S-hom ⟦ c ⟧) isIsoCf c = CatIso→isIso (Iso→CatIso (typeSectionIso {isSetB = snd (F ⟅ c ⟆)} (ϕ ⟦ c ⟧))) -- ======================================== -- ε : KL ≅ 𝟙 -- ======================================== module _ where open Iso open Morphism renaming (isIso to isIsoC) -- the iso we deserve -- says that a type family at x is isomorphic to the fiber over x of that type family packaged up typeFiberIso : ∀ {ℓ ℓ'} {A : Type ℓ} {isSetA : isSet A} {x} (B : A → Type ℓ') → Iso (B x) (fiber {A = Σ[ a ∈ A ] B a} (λ (x , _) → x) x) typeFiberIso {x = x} _ .fun b = (x , b) , refl typeFiberIso _ .inv ((a , b) , eq) = subst _ eq b typeFiberIso {isSetA = isSetA} {x = x} B .rightInv ((a , b) , eq) = fibersEqIfRepsEq {isSetB = isSetA} (λ (x , _) → x) (ΣPathP (sym eq , symP (transport-filler (λ i → B (eq i)) b))) typeFiberIso {x = x} _ .leftInv b = sym (transport-filler refl b) -- the natural isomorphism -- applies typeFiberIso (inv) εTrans : (K ∘F L) ⇒ 𝟙⟨ PreShv (∫ᴾ F) ℓS ⟩ εTrans .N-ob P = natTrans γ-ob (λ f → funExt (λ a → γ-homFunExt f a)) where KLP = K ⟅ L ⟅ P ⟆ ⟆ γ-ob : (el : (∫ᴾ F) .ob) → (fst (KLP ⟅ el ⟆) → fst (P ⟅ el ⟆) ) γ-ob el@(c , _) = typeFiberIso {isSetA = snd (F ⟅ c ⟆)} (λ x → fst (P ⟅ c , x ⟆)) .inv -- naturality -- the annoying part is all the substs γ-homFunExt : ∀ {el2 el1} → (f' : (∫ᴾ F) [ el2 , el1 ]) → (∀ (a : fst (KLP ⟅ el1 ⟆)) → γ-ob el2 ((KLP ⟪ f' ⟫) a) ≡ (P ⟪ f' ⟫) (γ-ob el1 a)) γ-homFunExt {d , y} {c , x} f'@(f , comm) a@((x' , X') , eq) i = comp (λ j → fst (P ⟅ d , eq' j ⟆)) (λ j → λ { (i = i0) → left j ; (i = i1) → right j }) ((P ⟪ f , refl ⟫) X') where -- fiber equality proof that we get from an application of KLP eq' = snd ((KLP ⟪ f' ⟫) a) -- top right of the commuting diagram -- "remove" the subst from the inside right : PathP (λ i → fst (P ⟅ d , eq' i ⟆)) ((P ⟪ f , refl ⟫) X') ((P ⟪ f , comm ⟫) (subst _ eq X')) right i = (P ⟪ f , refl≡comm i ⟫) (X'≡subst i) where refl≡comm : PathP (λ i → (eq' i) ≡ (F ⟪ f ⟫) (eq i)) refl comm refl≡comm = isOfHLevel→isOfHLevelDep 1 (λ (v , w) → snd (F ⟅ d ⟆) v ((F ⟪ f ⟫) w)) refl comm λ i → (eq' i , eq i) X'≡subst : PathP (λ i → fst (P ⟅ c , eq i ⟆)) X' (subst _ eq X') X'≡subst = transport-filler (λ i → fst (P ⟅ c , eq i ⟆)) X' -- bottom left of the commuting diagram -- "remove" the subst from the outside left : PathP (λ i → fst (P ⟅ d , eq' i ⟆)) ((P ⟪ f , refl ⟫) X') (subst (λ v → fst (P ⟅ d , v ⟆)) eq' ((P ⟪ f , refl ⟫) X')) left = transport-filler (λ i → fst (P ⟅ d , eq' i ⟆)) ((P ⟪ f , refl ⟫) X') εTrans .N-hom {P} {Q} α = makeNatTransPath (funExt λ cx → funExt λ xX' → ε-homFunExt cx xX') where KLP = K ⟅ L ⟅ P ⟆ ⟆ -- naturality of the above construction applies a similar argument as in `γ-homFunExt` ε-homFunExt : ∀ (cx@(c , x) : (∫ᴾ F) .ob) (xX'@((x' , X') , eq) : fst (KLP ⟅ cx ⟆)) → subst (λ v → fst (Q ⟅ c , v ⟆)) (snd ((K ⟪ L ⟪ α ⟫ ⟫ ⟦ cx ⟧) xX')) ((α ⟦ c , x' ⟧) X') ≡ (α ⟦ c , x ⟧) (subst _ eq X') ε-homFunExt cx@(c , x) xX'@((x' , X') , eq) i = comp (λ j → fst (Q ⟅ c , eq j ⟆)) (λ j → λ { (i = i0) → left j ; (i = i1) → right j }) ((α ⟦ c , x' ⟧) X') where eq' : x' ≡ x eq' = snd ((K ⟪ L ⟪ α ⟫ ⟫ ⟦ cx ⟧) xX') right : PathP (λ i → fst (Q ⟅ c , eq i ⟆)) ((α ⟦ c , x' ⟧) X') ((α ⟦ c , x ⟧) (subst _ eq X')) right i = (α ⟦ c , eq i ⟧) (X'≡subst i) where -- this is exactly the same as the one from before, can refactor? X'≡subst : PathP (λ i → fst (P ⟅ c , eq i ⟆)) X' (subst _ eq X') X'≡subst = transport-filler _ _ -- extracted out type since need to use in in 'left' body as well leftTy : (x' ≡ x) → Type _ leftTy eq* = PathP (λ i → fst (Q ⟅ c , eq* i ⟆)) ((α ⟦ c , x' ⟧) X') (subst (λ v → fst (Q ⟅ c , v ⟆)) eq' ((α ⟦ c , x' ⟧) X')) left : leftTy eq left = subst (λ eq* → leftTy eq*) eq'≡eq (transport-filler _ _) where eq'≡eq : eq' ≡ eq eq'≡eq = snd (F ⟅ c ⟆) _ _ eq' eq εIso : ∀ (P : PreShv (∫ᴾ F) ℓS .ob) → isIsoC {C = PreShv (∫ᴾ F) ℓS} (εTrans ⟦ P ⟧) εIso P = FUNCTORIso _ _ _ isIsoC' where isIsoC' : ∀ (cx : (∫ᴾ F) .ob) → isIsoC {C = SET _} ((εTrans ⟦ P ⟧) ⟦ cx ⟧) isIsoC' cx@(c , _) = CatIso→isIso (Iso→CatIso (invIso (typeFiberIso {isSetA = snd (F ⟅ c ⟆)} _))) -- putting it all together preshvSlice≃preshvElem : SliceCat ≃ᶜ PreShv (∫ᴾ F) ℓS preshvSlice≃preshvElem .func = K preshvSlice≃preshvElem .isEquiv .invFunc = L preshvSlice≃preshvElem .isEquiv .η .trans = ηTrans preshvSlice≃preshvElem .isEquiv .η .nIso = ηIso preshvSlice≃preshvElem .isEquiv .ε .trans = εTrans preshvSlice≃preshvElem .isEquiv .ε .nIso = εIso
{ "alphanum_fraction": 0.4555971021, "avg_line_length": 43.8871794872, "ext": "agda", "hexsha": "d296b1ced337f5bf9ca3b18f3aecf56090c77fcd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Categories/Presheaf/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Categories/Presheaf/Properties.agda", "max_line_length": 145, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Categories/Presheaf/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6594, "size": 17116 }
import Lvl open import Type module Data.IndexedList {ℓ ℓᵢ} (T : Type{ℓ}) {I : Type{ℓᵢ}} where private variable i : I record Index : Type{ℓᵢ Lvl.⊔ ℓ} where constructor intro field ∅ : I _⊰_ : T → I → I module _ ((intro ∅ᵢ _⊰ᵢ_) : Index) where data IndexedList : I → Type{ℓᵢ Lvl.⊔ ℓ} where ∅ : IndexedList(∅ᵢ) _⊰_ : (x : T) → IndexedList(i) → IndexedList(x ⊰ᵢ i) infixr 1000 _⊰_ private variable ℓₚ : Lvl.Level private variable index : Index private variable l : IndexedList i module _ (P : ∀{i} → IndexedList i → Type{ℓₚ}) where elim : P(∅) → (∀{i}(x)(l : IndexedList i) → P(l) → P(x ⊰ l)) → ((l : IndexedList i) → P(l)) elim base next ∅ = base elim base next (x ⊰ l) = next x l (elim base next l) module LongOper where pattern empty = ∅ pattern prepend elem list = elem ⊰ list pattern singleton x = x ⊰ ∅
{ "alphanum_fraction": 0.598173516, "avg_line_length": 25.7647058824, "ext": "agda", "hexsha": "ef6b6c75511a79dfadf21077fc3f3a1b3516408b", "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/IndexedList.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/IndexedList.agda", "max_line_length": 95, "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/IndexedList.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": 357, "size": 876 }
module _ where open import Common.Prelude open import Common.Reflection const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A const x _ = x id : ∀ {a} {A : Set a} → A → A id x = x first : Tactic first = give (def (quote const) []) second : Tactic second = give (def (quote const) (arg (argInfo visible relevant) (def (quote id) []) ∷ [])) number : Nat number = unquote first 6 false boolean : Bool boolean = unquote second 5 true
{ "alphanum_fraction": 0.630733945, "avg_line_length": 18.1666666667, "ext": "agda", "hexsha": "6ec51600b017c5f743845992cf907a9e13cb8e9d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/UnquoteWithArgs.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/UnquoteWithArgs.agda", "max_line_length": 91, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/UnquoteWithArgs.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": 144, "size": 436 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Presheaf where open import Categories.Category open import Categories.Functor Presheaf : ∀ {o ℓ e} {o′ ℓ′ e′} (C : Category o ℓ e) (V : Category o′ ℓ′ e′) → Set _ Presheaf C V = Functor C.op V where module C = Category C
{ "alphanum_fraction": 0.6914893617, "avg_line_length": 31.3333333333, "ext": "agda", "hexsha": "79b91380ee86cca139384093534488a8709ae449", "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/Presheaf.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/Presheaf.agda", "max_line_length": 84, "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/Presheaf.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": 91, "size": 282 }
-- Andreas, 2018-10-13, re issue #3244 -- -- Error should be raised when --no-prop and trying to use Prop -- (universe-polymorphic or not). {-# OPTIONS --no-prop #-} data False {ℓ} : Prop ℓ where -- Expected: Failure with error message
{ "alphanum_fraction": 0.6736401674, "avg_line_length": 21.7272727273, "ext": "agda", "hexsha": "d5f6cc2d6e80b2086e2f2b7d00b4f6890f78eb1d", "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/Prop-Disabled.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/Prop-Disabled.agda", "max_line_length": 63, "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/Prop-Disabled.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": 69, "size": 239 }
open import Data.Nat using (ℕ) open import Data.Vec using (Vec; []; _∷_; map) open import Dipsy.Polarity renaming (pos to +; neg to -) module Dipsy.Form (FOp : {n : ℕ} (as : Vec Polarity n) (b : Polarity) → Set) where data Form : Set where op : {n : ℕ} {as : Vec Polarity n} {b : Polarity} → FOp as b → Vec Form n → Form
{ "alphanum_fraction": 0.6167664671, "avg_line_length": 27.8333333333, "ext": "agda", "hexsha": "78d61a830567c54567d67397ea896aa22122d5af", "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": "06eec3f3325c71c81809ff19dfaf4fd43ba958ed", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/dipsy", "max_forks_repo_path": "src/Dipsy/Form.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "06eec3f3325c71c81809ff19dfaf4fd43ba958ed", "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/dipsy", "max_issues_repo_path": "src/Dipsy/Form.agda", "max_line_length": 60, "max_stars_count": 1, "max_stars_repo_head_hexsha": "06eec3f3325c71c81809ff19dfaf4fd43ba958ed", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/Dipsy", "max_stars_repo_path": "src/Dipsy/Form.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-10T13:43:29.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-10T13:43:29.000Z", "num_tokens": 120, "size": 334 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Monoidal.Structure where open import Level open import Categories.Category open import Categories.Category.Monoidal.Core open import Categories.Category.Monoidal.Braided open import Categories.Category.Monoidal.Symmetric record MonoidalCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field U : Category o ℓ e monoidal : Monoidal U module U = Category U module monoidal = Monoidal monoidal open U public open monoidal public record BraidedMonoidalCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field U : Category o ℓ e monoidal : Monoidal U braided : Braided monoidal module U = Category U module monoidal = Monoidal monoidal module braided = Braided braided monoidalCategory : MonoidalCategory o ℓ e monoidalCategory = record { U = U ; monoidal = monoidal } open U public open braided public record SymmetricMonoidalCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field U : Category o ℓ e monoidal : Monoidal U symmetric : Symmetric monoidal module U = Category U module monoidal = Monoidal monoidal module symmetric = Symmetric symmetric braidedMonoidalCategory : BraidedMonoidalCategory o ℓ e braidedMonoidalCategory = record { U = U ; monoidal = monoidal ; braided = symmetric.braided } open U public open symmetric public open BraidedMonoidalCategory braidedMonoidalCategory public using (monoidalCategory)
{ "alphanum_fraction": 0.7007822686, "avg_line_length": 25.5666666667, "ext": "agda", "hexsha": "d67e3d9758c8fe3f5a2eec2e8de72ff63e7db1fe", "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": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TOTBWF/agda-categories", "max_forks_repo_path": "src/Categories/Category/Monoidal/Structure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "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": "TOTBWF/agda-categories", "max_issues_repo_path": "src/Categories/Category/Monoidal/Structure.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TOTBWF/agda-categories", "max_stars_repo_path": "src/Categories/Category/Monoidal/Structure.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 426, "size": 1534 }
{-# OPTIONS --without-K --safe #-} open import Level -- This is really a degenerate version of Categories.Category.Instance.One -- Here SingletonSet is not given an explicit name, it is an alias for Lift o ⊤ module Categories.Category.Instance.SingletonSet where open import Data.Unit using (⊤; tt) open import Relation.Binary.PropositionalEquality using (refl) open import Categories.Category.Instance.Sets open import Categories.Category.Instance.Setoids import Categories.Object.Terminal as Term module _ {o : Level} where open Term (Sets o) SingletonSet-⊤ : Terminal SingletonSet-⊤ = record { ⊤ = Lift o ⊤ ; !-unique = λ _ → refl } module _ {c ℓ : Level} where open Term (Setoids c ℓ) SingletonSetoid-⊤ : Terminal SingletonSetoid-⊤ = record { ⊤ = record { Carrier = Lift c ⊤ ; _≈_ = λ _ _ → Lift ℓ ⊤ } }
{ "alphanum_fraction": 0.7185990338, "avg_line_length": 30.6666666667, "ext": "agda", "hexsha": "25a066421c9c676960104020d9b54d88856b3980", "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/Instance/SingletonSet.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/Instance/SingletonSet.agda", "max_line_length": 91, "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/Instance/SingletonSet.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 228, "size": 828 }
------------------------------------------------------------------------------ -- Well-founded induction on the relation LTC ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.List.WF-Relation.LT-Cons.Induction.Acc.WF-I where open import FOTC.Base open import FOTC.Data.List open import FOTC.Data.List.WF-Relation.LT-Cons open import FOTC.Data.List.WF-Relation.LT-Cons.PropertiesI open import FOTC.Data.List.WF-Relation.LT-Length open import FOTC.Data.List.WF-Relation.LT-Length.Induction.Acc.WF-I open import FOTC.Induction.WF -- Parametrized modules open module S = FOTC.Induction.WF.Subrelation {List} {LTC} LTC→LTL ------------------------------------------------------------------------------ -- The relation LTL is well-founded (using the subrelation combinator). LTC-wf : WellFounded LTC LTC-wf Lxs = well-founded LTL-wf Lxs -- Well-founded induction on the relation LTC. LTC-wfind : (A : D → Set) → (∀ {xs} → List xs → (∀ {ys} → List ys → LTC ys xs → A ys) → A xs) → ∀ {xs} → List xs → A xs LTC-wfind A = WellFoundedInduction LTC-wf
{ "alphanum_fraction": 0.5520186335, "avg_line_length": 39.0303030303, "ext": "agda", "hexsha": "18bab93b5fde75c87bb04c90c5fafe79e40b25aa", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Cons/Induction/Acc/WF-I.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Cons/Induction/Acc/WF-I.agda", "max_line_length": 79, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/List/WF-Relation/LT-Cons/Induction/Acc/WF-I.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": 321, "size": 1288 }
------------------------------------------------------------------------ -- Binary trees ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Tree {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq open import Prelude hiding (id) open import Bag-equivalence eq open import Bijection eq using (_↔_) open import Function-universe eq open import List eq ------------------------------------------------------------------------ -- Binary trees data Tree (A : Type) : Type where leaf : Tree A node : (l : Tree A) (x : A) (r : Tree A) → Tree A -- Any. AnyT : ∀ {A} → (A → Type) → (Tree A → Type) AnyT P leaf = ⊥ AnyT P (node l x r) = AnyT P l ⊎ P x ⊎ AnyT P r -- Membership. infix 4 _∈T_ _∈T_ : ∀ {A} → A → Tree A → Type x ∈T t = AnyT (_≡_ x) t -- Bag equivalence. _≈-bagT_ : ∀ {A} → Tree A → Tree A → Type t₁ ≈-bagT t₂ = ∀ x → x ∈T t₁ ↔ x ∈T t₂ ------------------------------------------------------------------------ -- Singleton -- Singleton trees. singleton : {A : Type} → A → Tree A singleton x = node leaf x leaf -- Any lemma for singleton. Any-singleton : ∀ {A : Type} (P : A → Type) {x} → AnyT P (singleton x) ↔ P x Any-singleton P {x} = AnyT P (singleton x) ↔⟨⟩ ⊥ ⊎ P x ⊎ ⊥ ↔⟨ ⊎-left-identity ⟩ P x ⊎ ⊥ ↔⟨ ⊎-right-identity ⟩ P x □ ------------------------------------------------------------------------ -- Flatten -- Inorder flattening of a tree. flatten : {A : Type} → Tree A → List A flatten leaf = [] flatten (node l x r) = flatten l ++ x ∷ flatten r -- Flatten does not add or remove any elements. flatten-lemma : {A : Type} (t : Tree A) → ∀ z → z ∈ flatten t ↔ z ∈T t flatten-lemma leaf = λ z → ⊥ □ flatten-lemma (node l x r) = λ z → z ∈ flatten l ++ x ∷ flatten r ↔⟨ Any-++ (_≡_ z) _ _ ⟩ z ∈ flatten l ⊎ z ≡ x ⊎ z ∈ flatten r ↔⟨ flatten-lemma l z ⊎-cong (z ≡ x □) ⊎-cong flatten-lemma r z ⟩ z ∈T l ⊎ z ≡ x ⊎ z ∈T r □ ------------------------------------------------------------------------ -- Bags can (perhaps) be defined as binary trees quotiented by bag -- equivalence -- Agda doesn't support quotients, so the following type is used to -- state that two quotients are isomorphic. -- -- Note that this definition may not actually make sense if the -- relations _≈A_ and _≈B_ are not /proof-irrelevant/ equivalence -- relations. record _/_↔_/_ (A : Type) (_≈A_ : A → A → Type) (B : Type) (_≈B_ : B → B → Type) : Type where field to : A → B to-resp : ∀ x y → x ≈A y → to x ≈B to y from : B → A from-resp : ∀ x y → x ≈B y → from x ≈A from y to∘from : ∀ x → to (from x) ≈B x from∘to : ∀ x → from (to x) ≈A x -- Lists quotiented by bag equivalence are isomorphic to binary trees -- quotiented by bag equivalence (assuming that one can actually -- quotient by bag equivalence, and that the definition of _/_↔_/_ -- makes sense in this case). list-bags↔tree-bags : {A : Type} → List A / _≈-bag_ ↔ Tree A / _≈-bagT_ list-bags↔tree-bags {A} = record { to = to-tree ; to-resp = λ xs ys xs≈ys z → z ∈T to-tree xs ↔⟨ to-tree-lemma xs z ⟩ z ∈ xs ↔⟨ xs≈ys z ⟩ z ∈ ys ↔⟨ inverse $ to-tree-lemma ys z ⟩ z ∈T to-tree ys □ ; from = flatten ; from-resp = λ t₁ t₂ t₁≈t₂ z → z ∈ flatten t₁ ↔⟨ flatten-lemma t₁ z ⟩ z ∈T t₁ ↔⟨ t₁≈t₂ z ⟩ z ∈T t₂ ↔⟨ inverse $ flatten-lemma t₂ z ⟩ z ∈ flatten t₂ □ ; to∘from = to∘from ; from∘to = from∘to } where to-tree : List A → Tree A to-tree = foldr (node leaf) leaf to-tree-lemma : ∀ xs z → z ∈T to-tree xs ↔ z ∈ xs to-tree-lemma [] = λ z → ⊥ □ to-tree-lemma (x ∷ xs) = λ z → ⊥ ⊎ z ≡ x ⊎ z ∈T to-tree xs ↔⟨ id ⊎-cong id ⊎-cong to-tree-lemma xs z ⟩ ⊥ ⊎ z ≡ x ⊎ z ∈ xs ↔⟨ ⊎-assoc ⟩ (⊥ ⊎ z ≡ x) ⊎ z ∈ xs ↔⟨ ⊎-left-identity ⊎-cong id ⟩ z ≡ x ⊎ z ∈ xs □ to-tree-++ : ∀ {P : A → Type} xs {ys} → AnyT P (to-tree (xs ++ ys)) ↔ AnyT P (to-tree xs) ⊎ AnyT P (to-tree ys) to-tree-++ {P} [] {ys} = AnyT P (to-tree ys) ↔⟨ inverse ⊎-left-identity ⟩ ⊥ ⊎ AnyT P (to-tree ys) □ to-tree-++ {P} (x ∷ xs) {ys} = ⊥ ⊎ P x ⊎ AnyT P (to-tree (xs ++ ys)) ↔⟨ id ⊎-cong id ⊎-cong to-tree-++ xs ⟩ ⊥ ⊎ P x ⊎ AnyT P (to-tree xs) ⊎ AnyT P (to-tree ys) ↔⟨ lemma _ _ _ _ ⟩ (⊥ ⊎ P x ⊎ AnyT P (to-tree xs)) ⊎ AnyT P (to-tree ys) □ where lemma : (A B C D : Type) → A ⊎ B ⊎ C ⊎ D ↔ (A ⊎ B ⊎ C) ⊎ D lemma A B C D = A ⊎ B ⊎ C ⊎ D ↔⟨ ⊎-assoc ⟩ (A ⊎ B) ⊎ C ⊎ D ↔⟨ ⊎-assoc ⟩ ((A ⊎ B) ⊎ C) ⊎ D ↔⟨ inverse ⊎-assoc ⊎-cong id ⟩ (A ⊎ B ⊎ C) ⊎ D □ to∘from : ∀ t → to-tree (flatten t) ≈-bagT t to∘from leaf = λ z → ⊥ □ to∘from (node l x r) = λ z → z ∈T to-tree (flatten l ++ x ∷ flatten r) ↔⟨ to-tree-++ (flatten l) ⟩ z ∈T to-tree (flatten l) ⊎ ⊥ ⊎ z ≡ x ⊎ z ∈T to-tree (flatten r) ↔⟨ to∘from l z ⊎-cong id ⊎-cong id ⊎-cong to∘from r z ⟩ z ∈T l ⊎ ⊥ ⊎ z ≡ x ⊎ z ∈T r ↔⟨ id ⊎-cong ⊎-left-identity ⟩ z ∈T l ⊎ z ≡ x ⊎ z ∈T r □ from∘to : ∀ xs → flatten (to-tree xs) ≈-bag xs from∘to [] = λ z → ⊥ □ from∘to (x ∷ xs) = λ z → z ≡ x ⊎ z ∈ flatten (to-tree xs) ↔⟨ id ⊎-cong from∘to xs z ⟩ z ≡ x ⊎ z ∈ xs □
{ "alphanum_fraction": 0.4471288515, "avg_line_length": 34.2035928144, "ext": "agda", "hexsha": "a5c17d263c7a53aedbc5a232feda7eb3962fb421", "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/Tree.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/Tree.agda", "max_line_length": 124, "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/Tree.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": 2105, "size": 5712 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.cubical.Square open import lib.types.Bool open import lib.types.Cofiber open import lib.types.Lift open import lib.types.Paths open import lib.types.Pointed open import lib.types.PushoutFmap open import lib.types.Sigma open import lib.types.Span open import lib.types.Suspension open import lib.types.Wedge module lib.types.BigWedge where module _ {i j} {A : Type i} where {- the function for cofiber -} bigwedge-f : (X : A → Ptd j) → A → Σ A (de⊙ ∘ X) bigwedge-f X a = a , pt (X a) bigwedge-span : (A → Ptd j) → Span bigwedge-span X = cofiber-span (bigwedge-f X) BigWedge : (A → Ptd j) → Type (lmax i j) BigWedge X = Cofiber (bigwedge-f X) bwbase : {X : A → Ptd j} → BigWedge X bwbase = cfbase bwin : {X : A → Ptd j} → (a : A) → de⊙ (X a) → BigWedge X bwin = curry cfcod ⊙BigWedge : (A → Ptd j) → Ptd (lmax i j) ⊙BigWedge X = ⊙[ BigWedge X , bwbase ] bwglue : {X : A → Ptd j} → (a : A) → bwbase {X} == bwin a (pt (X a)) bwglue = cfglue ⊙bwin : {X : A → Ptd j} → (a : A) → X a ⊙→ ⊙BigWedge X ⊙bwin a = (bwin a , ! (bwglue a)) module BigWedgeElim {X : A → Ptd j} {k} {P : BigWedge X → Type k} (base* : P bwbase) (in* : (a : A) (x : de⊙ (X a)) → P (bwin a x)) (glue* : (a : A) → base* == in* a (pt (X a)) [ P ↓ bwglue a ]) = CofiberElim {f = bigwedge-f X} {P = P} base* (uncurry in*) glue* BigWedge-elim = BigWedgeElim.f module BigWedgeRec {X : A → Ptd j} {k} {C : Type k} (base* : C) (in* : (a : A) → de⊙ (X a) → C) (glue* : (a : A) → base* == in* a (pt (X a))) = CofiberRec {f = bigwedge-f X} {C = C} base* (uncurry in*) glue* module _ {i j₀ j₁} {A : Type i} {X₀ : A → Ptd j₀} {X₁ : A → Ptd j₁} (Xeq : ∀ a → X₀ a ⊙≃ X₁ a) where bigwedge-span-emap-r : SpanEquiv (cofiber-span (bigwedge-f X₀)) (cofiber-span (bigwedge-f X₁)) bigwedge-span-emap-r = span-map (idf _) (Σ-fmap-r λ a → fst (⊙–> (Xeq a))) (idf _) (comm-sqr λ _ → idp) (comm-sqr λ a → pair= idp (⊙–>-pt (Xeq a))) , idf-is-equiv _ , Σ-isemap-r (λ a → snd (Xeq a)) , idf-is-equiv _ BigWedge-emap-r : BigWedge X₀ ≃ BigWedge X₁ BigWedge-emap-r = Pushout-emap bigwedge-span-emap-r ⊙BigWedge-emap-r : ⊙BigWedge X₀ ⊙≃ ⊙BigWedge X₁ ⊙BigWedge-emap-r = ≃-to-⊙≃ BigWedge-emap-r idp module _ {i₀ i₁ j} {A₀ : Type i₀} {A₁ : Type i₁} (X : A₁ → Ptd j) (Aeq : A₀ ≃ A₁) where bigwedge-span-emap-l : SpanEquiv (cofiber-span (bigwedge-f (X ∘ –> Aeq))) (cofiber-span (bigwedge-f X)) bigwedge-span-emap-l = span-map (idf _) (Σ-fmap-l (de⊙ ∘ X) (–> Aeq)) (–> Aeq) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp) , idf-is-equiv _ , Σ-isemap-l (de⊙ ∘ X) (snd Aeq) , snd Aeq BigWedge-emap-l : BigWedge (X ∘ –> Aeq) ≃ BigWedge X BigWedge-emap-l = Pushout-emap bigwedge-span-emap-l ⊙BigWedge-emap-l : ⊙BigWedge (X ∘ –> Aeq) ⊙≃ ⊙BigWedge X ⊙BigWedge-emap-l = ≃-to-⊙≃ BigWedge-emap-l idp module _ {i j} {A : Type i} (X : A → Ptd j) where extract-glue-from-BigWedge-is-const : ∀ bw → extract-glue {s = bigwedge-span X} bw == north extract-glue-from-BigWedge-is-const = BigWedge-elim idp (λ x y → ! (merid x)) (↓-='-from-square ∘ λ x → ExtractGlue.glue-β x ∙v⊡ tr-square (merid x) ⊡v∙ ! (ap-cst north (cfglue x))) {- A BigWedge indexed by Bool is just a binary Wedge -} module _ {i} (Pick : Bool → Ptd i) where BigWedge-Bool-equiv-Wedge : BigWedge Pick ≃ Wedge (Pick true) (Pick false) BigWedge-Bool-equiv-Wedge = equiv f g f-g g-f where module F = BigWedgeRec {X = Pick} {C = Wedge (Pick true) (Pick false)} (winl (pt (Pick true))) (λ {true → winl; false → winr}) (λ {true → idp; false → wglue}) module G = WedgeRec {X = Pick true} {Y = Pick false} {C = BigWedge Pick} (bwin true) (bwin false) (! (bwglue true) ∙ bwglue false) f = F.f g = G.f abstract f-g : ∀ w → f (g w) == w f-g = Wedge-elim (λ _ → idp) (λ _ → idp) (↓-∘=idf-in' f g $ ap f (ap g wglue) =⟨ ap (ap f) G.glue-β ⟩ ap f (! (bwglue true) ∙ bwglue false) =⟨ ap-∙ f (! (bwglue true)) (bwglue false) ⟩ ap f (! (bwglue true)) ∙ ap f (bwglue false) =⟨ ap-! f (bwglue true) |in-ctx (λ w → w ∙ ap f (bwglue false)) ⟩ ! (ap f (bwglue true)) ∙ ap f (bwglue false) =⟨ F.glue-β true |in-ctx (λ w → ! w ∙ ap f (bwglue false)) ⟩ ap f (bwglue false) =⟨ F.glue-β false ⟩ wglue =∎) g-f : ∀ bw → g (f bw) == bw g-f = BigWedge-elim (! (bwglue true)) (λ {true → λ _ → idp; false → λ _ → idp}) (λ {true → ↓-∘=idf-from-square g f $ ap (ap g) (F.glue-β true) ∙v⊡ bl-square (bwglue true); false → ↓-∘=idf-from-square g f $ (ap (ap g) (F.glue-β false) ∙ G.glue-β) ∙v⊡ lt-square (! (bwglue true)) ⊡h vid-square}) module _ {i j} {A : Type i} (dec : has-dec-eq A) {X : Ptd j} where {- The dependent version increases the complexity significantly and we do not need it. -} ⊙bwproj-in : A → A → X ⊙→ X ⊙bwproj-in a a' with dec a a' ... | inl _ = ⊙idf _ ... | inr _ = ⊙cst module BigWedgeProj (a : A) = BigWedgeRec {X = λ _ → X} (pt X) (λ a' → fst (⊙bwproj-in a a')) (λ a' → ! (snd (⊙bwproj-in a a'))) bwproj : A → BigWedge (λ _ → X) → de⊙ X bwproj = BigWedgeProj.f ⊙bwproj : A → ⊙BigWedge (λ _ → X) ⊙→ X ⊙bwproj a = bwproj a , idp abstract bwproj-bwin-diag : (a : A) → bwproj a ∘ bwin a ∼ idf (de⊙ X) bwproj-bwin-diag a x with dec a a ... | inl _ = idp ... | inr a≠a with a≠a idp ... | () bwproj-bwin-≠ : {a a' : A} → a ≠ a' → bwproj a ∘ bwin a' ∼ cst (pt X) bwproj-bwin-≠ {a} {a'} a≠a' x with dec a a' ... | inr _ = idp ... | inl a=a' with a≠a' a=a' ... | () module _ {i j k} {A : Type i} (dec : has-dec-eq A) {X : Ptd j} (a : A) where abstract private bwproj-BigWedge-emap-r-lift-in : ∀ a' → bwproj dec {X = ⊙Lift {j = k} X} a ∘ bwin a' ∘ lift ∼ lift {j = k} ∘ bwproj dec {X = X} a ∘ bwin a' bwproj-BigWedge-emap-r-lift-in a' with dec a a' ... | inl _ = λ _ → idp ... | inr _ = λ _ → idp bwproj-BigWedge-emap-r-lift-glue' : ∀ (a' : A) → ap (lift {j = k}) (! (snd (⊙bwproj-in dec {X = X} a a'))) == ! (snd (⊙bwproj-in dec {X = ⊙Lift {j = k} X} a a')) ∙' bwproj-BigWedge-emap-r-lift-in a' (pt X) bwproj-BigWedge-emap-r-lift-glue' a' with dec a a' ... | inl _ = idp ... | inr _ = idp bwproj-BigWedge-emap-r-lift-glue : ∀ (a' : A) → idp == bwproj-BigWedge-emap-r-lift-in a' (pt X) [ (λ x → bwproj dec {X = ⊙Lift {j = k} X} a (–> (BigWedge-emap-r (λ _ → ⊙lift-equiv {j = k})) x) == lift {j = k} (bwproj dec {X = X} a x)) ↓ bwglue a' ] bwproj-BigWedge-emap-r-lift-glue a' = ↓-='-in' $ ap (lift {j = k} ∘ bwproj dec a) (bwglue a') =⟨ ap-∘ (lift {j = k}) (bwproj dec a) (bwglue a') ⟩ ap (lift {j = k}) (ap (bwproj dec a) (bwglue a')) =⟨ ap (ap (lift {j = k})) $ BigWedgeProj.glue-β dec a a' ⟩ ap (lift {j = k}) (! (snd (⊙bwproj-in dec a a'))) =⟨ bwproj-BigWedge-emap-r-lift-glue' a' ⟩ ! (snd (⊙bwproj-in dec a a')) ∙' bwproj-BigWedge-emap-r-lift-in a' (pt X) =⟨ ap (_∙' bwproj-BigWedge-emap-r-lift-in a' (pt X)) $ ( ! $ BigWedgeProj.glue-β dec a a') ⟩ ap (bwproj dec a) (bwglue a') ∙' bwproj-BigWedge-emap-r-lift-in a' (pt X) =⟨ ap (λ p → ap (bwproj dec a) p ∙' bwproj-BigWedge-emap-r-lift-in a' (pt X)) $ (! $ PushoutFmap.glue-β (fst (bigwedge-span-emap-r (λ _ → ⊙lift-equiv {j = k}))) a') ⟩ ap (bwproj dec a) (ap (–> (BigWedge-emap-r (λ _ → ⊙lift-equiv {j = k}))) (bwglue a')) ∙' bwproj-BigWedge-emap-r-lift-in a' (pt X) =⟨ ap (_∙' bwproj-BigWedge-emap-r-lift-in a' (pt X)) $ (∘-ap (bwproj dec a) (–> (BigWedge-emap-r (λ _ → ⊙lift-equiv {j = k}))) (bwglue a')) ⟩ ap (bwproj dec a ∘ –> (BigWedge-emap-r (λ _ → ⊙lift-equiv {j = k}))) (bwglue a') ∙' bwproj-BigWedge-emap-r-lift-in a' (pt X) =∎ bwproj-BigWedge-emap-r-lift : bwproj dec {X = ⊙Lift {j = k} X} a ∘ –> (BigWedge-emap-r (λ _ → ⊙lift-equiv {j = k})) ∼ lift {j = k} ∘ bwproj dec a bwproj-BigWedge-emap-r-lift = BigWedge-elim {X = λ _ → X} idp bwproj-BigWedge-emap-r-lift-in bwproj-BigWedge-emap-r-lift-glue
{ "alphanum_fraction": 0.5228384992, "avg_line_length": 36.5191489362, "ext": "agda", "hexsha": "a65149a5ce43f8509fecf9fe5e4be74a8613e1d2", "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": "core/lib/types/BigWedge.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": "core/lib/types/BigWedge.agda", "max_line_length": 106, "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": "core/lib/types/BigWedge.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": 3623, "size": 8582 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Functor.Constant where open import Categories.Category open import Categories.Functor Constant : ∀ {o′ ℓ′ e′} {D : Category o′ ℓ′ e′} (x : Category.Obj D) → ∀ {o ℓ e} {C : Category o ℓ e} → Functor C D Constant {D = D} x = record { F₀ = λ _ → x ; F₁ = λ _ → D.id ; identity = D.Equiv.refl ; homomorphism = D.Equiv.sym D.identityˡ ; F-resp-≡ = λ _ → D.Equiv.refl } where module D = Category D
{ "alphanum_fraction": 0.4741935484, "avg_line_length": 36.4705882353, "ext": "agda", "hexsha": "775e9a26b1ad421b7afbf49c5a8861e13b8ed1ca", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Functor/Constant.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Functor/Constant.agda", "max_line_length": 115, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Functor/Constant.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": 168, "size": 620 }
{-# OPTIONS --allow-unsolved-metas #-} postulate A : Set a : A record Q .(x : A) : Set where field q : A record R : Set where field s : Q _ t : A t = Q.q s
{ "alphanum_fraction": 0.5438596491, "avg_line_length": 12.2142857143, "ext": "agda", "hexsha": "28ee3e3647cd45fe81a22047dc0bed0dc0f3bee8", "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/Issue1013.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/Issue1013.agda", "max_line_length": 38, "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/Issue1013.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": 65, "size": 171 }
module LinkedList.Properties where open import LinkedList open import Data.Nat open import Data.Nat.Properties.Simple open import Relation.Nullary.Decidable using (False) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; cong₂; trans; sym; inspect) open PropEq.≡-Reasoning incr-suc : ∀ {A x} → {xs : LinkedList A} → ⟦ incr x xs ⟧ ≡ suc ⟦ xs ⟧ incr-suc {_} {x} {xs} = refl decr-pred : ∀ {A} → {xs : LinkedList A} → (p : False (null? xs)) → ⟦ decr xs p ⟧ ≡ pred ⟦ xs ⟧ decr-pred {xs = [] } () decr-pred {xs = x ∷ xs} p = refl ++-left-indentity : ∀ {A} → {xs : LinkedList A} → [] ++ xs ≡ xs ++-left-indentity {A} {xs} = refl ++-right-indentity : ∀ {A} → {xs : LinkedList A} → [] ++ xs ≡ xs ++-right-indentity {A} {xs} = refl ⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ : ∀ {A} → (xs : LinkedList A) → (ys : LinkedList A) → ⟦ xs ++ ys ⟧ ≡ ⟦ xs ⟧ + ⟦ ys ⟧ ⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ [] ys = refl ⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ (x ∷ xs) ys = cong suc (⟦xs++ys⟧≡⟦xs⟧+⟦ys⟧ xs ys)
{ "alphanum_fraction": 0.5500963391, "avg_line_length": 32.4375, "ext": "agda", "hexsha": "e5e48ff3fdc0912f34c9bc764f6519eaedc98737", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/LinkedList/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/LinkedList/Properties.agda", "max_line_length": 94, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/LinkedList/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 418, "size": 1038 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Nat.Order.Recursive where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Data.Empty open import Cubical.Data.Unit open import Cubical.Data.Nat.Base open import Cubical.Data.Nat.Properties open import Cubical.Relation.Nullary infix 4 _≤_ _<_ _≤_ : ℕ → ℕ → Type₀ zero ≤ _ = Unit suc m ≤ zero = ⊥ suc m ≤ suc n = m ≤ n _<_ : ℕ → ℕ → Type₀ m < n = suc m ≤ n data Trichotomy (m n : ℕ) : Type₀ where lt : m < n → Trichotomy m n eq : m ≡ n → Trichotomy m n gt : n < m → Trichotomy m n private variable k l m n : ℕ m≤n-isProp : isProp (m ≤ n) m≤n-isProp {zero} = isPropUnit m≤n-isProp {suc m} {zero} = isProp⊥ m≤n-isProp {suc m} {suc n} = m≤n-isProp {m} {n} ≤-k+ : m ≤ n → k + m ≤ k + n ≤-k+ {k = zero} m≤n = m≤n ≤-k+ {k = suc k} m≤n = ≤-k+ {k = k} m≤n ≤-+k : m ≤ n → m + k ≤ n + k ≤-+k {m} {n} {k} m≤n = transport (λ i → +-comm k m i ≤ +-comm k n i) (≤-k+ {m} {n} {k} m≤n) ≤-refl : ∀ m → m ≤ m ≤-refl zero = _ ≤-refl (suc m) = ≤-refl m ≤-trans : k ≤ m → m ≤ n → k ≤ n ≤-trans {zero} _ _ = _ ≤-trans {suc k} {suc m} {suc n} = ≤-trans {k} {m} {n} ≤-antisym : m ≤ n → n ≤ m → m ≡ n ≤-antisym {zero} {zero} _ _ = refl ≤-antisym {suc m} {suc n} m≤n n≤m = cong suc (≤-antisym m≤n n≤m) ≤-k+-cancel : k + m ≤ k + n → m ≤ n ≤-k+-cancel {k = zero} m≤n = m≤n ≤-k+-cancel {k = suc k} m≤n = ≤-k+-cancel {k} m≤n ≤-+k-cancel : m + k ≤ n + k → m ≤ n ≤-+k-cancel {m} {k} {n} = ≤-k+-cancel {k} {m} {n} ∘ transport λ i → +-comm m k i ≤ +-comm n k i ¬m<m : ¬ m < m ¬m<m {suc m} = ¬m<m {m} ≤0→≡0 : n ≤ 0 → n ≡ 0 ≤0→≡0 {zero} _ = refl ¬m+n<m : ¬ m + n < m ¬m+n<m {suc m} = ¬m+n<m {m} <-weaken : m < n → m ≤ n <-weaken {zero} _ = _ <-weaken {suc m} {suc n} = <-weaken {m} Trichotomy-suc : Trichotomy m n → Trichotomy (suc m) (suc n) Trichotomy-suc (lt m<n) = lt m<n Trichotomy-suc (eq m≡n) = eq (cong suc m≡n) Trichotomy-suc (gt n<m) = gt n<m _≟_ : ∀ m n → Trichotomy m n zero ≟ zero = eq refl zero ≟ suc n = lt _ suc m ≟ zero = gt _ suc m ≟ suc n = Trichotomy-suc (m ≟ n) k≤k+n : ∀ k → k ≤ k + n k≤k+n zero = _ k≤k+n (suc k) = k≤k+n k n≤k+n : ∀ n → n ≤ k + n n≤k+n {k} n = transport (λ i → n ≤ +-comm n k i) (k≤k+n n)
{ "alphanum_fraction": 0.530711445, "avg_line_length": 23.3298969072, "ext": "agda", "hexsha": "c604f7dcf6dbedae5f623dea0cce98ec3e28e25c", "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/Data/Nat/Order/Recursive.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/Data/Nat/Order/Recursive.agda", "max_line_length": 73, "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/Data/Nat/Order/Recursive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1112, "size": 2263 }
{-# OPTIONS --show-irrelevant #-} module Control.Category.Product where open import Level using (suc; _⊔_) open import Relation.Binary hiding (_⇒_) open import Control.Category open Category using () renaming (Obj to obj; _⇒_ to _▹_⇒_) -- Pre-Product -- Given a category C and two objects A, B in C we can define a new category -- whose objects are triples of an object A×B in C that has -- morphisms fst, snd to A and B. -- We call such a triple a pre-product of A and B. -- Alternatively, it could be called a bislice. record PreProductObj {o h e} (C : Category o h e) (A B : obj C) : Set (o ⊔ h ⊔ e) where open Category C -- public field A×B : Obj fst : A×B ⇒ A snd : A×B ⇒ B -- In the following, we fix a category C and two objects A and B. module PreProduct {o h e} {C : Category o h e} {A B : obj C} where -- We use _⇒_ for C's morphisms and _∘_ for their composition. open module C = Category C using (_⇒_; _⟫_; _∘_; _≈_; ≈-refl; ≈-sym; ≈-trans; ∘-cong) -- We consider only pre-products of A and B. Obj = PreProductObj C A B open PreProductObj using () renaming (A×B to A×B◃_) -- A morphism in the category of pre-products of A and B -- from pre-product (X, f, g) to (A×B, fst, snd) -- is a morphism ⟨f,g⟩ : X ⇒ A×B such that fst ∘ ⟨f,g⟩ ≡ f -- and snd ∘ ⟨f,g⟩ ≡ g. record IsPair (P : Obj) {X} (f : X ⇒ A) (g : X ⇒ B) (⟨f,g⟩ : X ⇒ (A×B◃ P)) : Set (o ⊔ h ⊔ e) where constructor β-pair open PreProductObj P using (fst; snd) field β-fst : (fst ∘ ⟨f,g⟩) ≈ f β-snd : (snd ∘ ⟨f,g⟩) ≈ g record PreProductMorphism (O P : Obj) : Set (o ⊔ h ⊔ e) where constructor pair open PreProductObj O using () renaming (A×B to X; fst to f; snd to g) open PreProductObj P field ⟨f,g⟩ : X ⇒ A×B isPair : IsPair P f g ⟨f,g⟩ open IsPair isPair public open PreProductMorphism using (isPair) -- We write O ⇉ P for a morphism from pre-product O to pre-product P. _⇉_ = PreProductMorphism -- The identity pre-product morphism is just the identity morphism. id : ∀ {P} → P ⇉ P id = record { ⟨f,g⟩ = C.id ; isPair = record { β-fst = C.id-first ; β-snd = C.id-first } } -- The composition of pre-product morphims is just the composition in C. comp : ∀ {N O P} → N ⇉ O → O ⇉ P → N ⇉ P comp (pair o (β-pair o-fst o-snd)) (pair p (β-pair p-fst p-snd)) = record { ⟨f,g⟩ = o ⟫ p ; isPair = record { β-fst = ≈-trans (C.∘-assoc o) (≈-trans (∘-cong ≈-refl p-fst) o-fst) ; β-snd = ≈-trans (C.∘-assoc o) (≈-trans (∘-cong ≈-refl p-snd) o-snd) } } -- Thus, we have a category of PreProducts, inheriting the laws from C. PreProductHom : (O P : Obj) → Setoid _ _ PreProductHom O P = record { Carrier = PreProductMorphism O P ; _≈_ = λ h i → PreProductMorphism.⟨f,g⟩ h ≈ PreProductMorphism.⟨f,g⟩ i ; isEquivalence = record { refl = ≈-refl ; sym = ≈-sym ; trans = ≈-trans } } preProductIsCategory : IsCategory PreProductHom preProductIsCategory = record { ops = record { id = id ; _⟫_ = comp } ; laws = record { id-first = C.id-first ; id-last = C.id-last ; ∘-assoc = λ f → C.∘-assoc _ ; ∘-cong = C.∘-cong } } open PreProduct public {- record Pair {o h} {C : Category o h} {A B} (P : PreProductObj C A B) {X} (f : C ▹ X ⇒ A) (g : C ▹ X ⇒ B) : Set (h ⊔ o) where open PreProductObj P field ⟨f,g⟩ : C ▹ X ⇒ A×B isPair : IsPair P f g ⟨f,g⟩ unique : ∀ {h} → IsPair P f g h → h ≈ ⟨f,g⟩ open IsPair isPair public -- The product of A and B is the terminal object in the PreProductCategory record IsProduct {o h} {C : Category o h} {A B} (P : PreProductObj C A B) : Set (h ⊔ o) where open Category C open PreProductObj P field pairing : ∀ {X} (f : X ⇒ A) (g : X ⇒ B) → Pair P f g record Product {o h} (C : Category o h) (A B : obj C) : Set (h ⊔ o) where field preProduct : PreProductObj C A B isProduct : IsProduct preProduct open PreProductObj preProduct public open IsProduct isProduct public {- record IsProduct {o h} (C : Category o h) (A B A×B : Obj C) : Set (h ⊔ o) where open Category C field fst : A×B ⇒ A snd : A×B ⇒ B pair : ∀ {X} (f : X ⇒ A) (g : X ⇒ B) → X ⇒ A×B β-fst : ∀ {X} {f : X ⇒ A} {g : X ⇒ B} → fst ∘ pair f g ≡ f β-snd : ∀ {X} {f : X ⇒ A} {g : X ⇒ B} → fst ∘ pair f g ≡ f -} -- Category with Products HasProducts : ∀ {o h} (C : Category o h) → Set (o ⊔ h) HasProducts C = ∀ (A B : obj C) → Product C A B -}
{ "alphanum_fraction": 0.5686444348, "avg_line_length": 27.325443787, "ext": "agda", "hexsha": "d78ca81af880c65d0c9d1f62d930c74c2c6c042f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_path": "src/Control/Category/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andreasabel/cubical", "max_issues_repo_path": "src/Control/Category/Product.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_path": "src/Control/Category/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1728, "size": 4618 }
-- Andreas, 2012-05-04 module PruningNonMillerPatternFail where data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a data Nat : Set where zero : Nat suc : Nat -> Nat -- bad variable y is not in head position under lambda, so do not prune fail4 : let X : Nat -> Nat -> Nat X = _ -- λ x y → suc x Y : Nat → ((Nat → Nat) → Nat) -> Nat Y = _ -- More than one solution: -- λ x f → x -- λ x f → f (λ z → x) in (C : Set) -> (({x y : Nat} -> X x x ≡ suc (Y x (λ k → k y))) -> ({x y : Nat} -> Y x (λ k → k x) ≡ x) -> ({x y : Nat} -> X (Y x (λ k → k y)) y ≡ X x x) -> C) -> C fail4 C k = k refl refl refl -- this should not solve, since there are more than one solutions for Y
{ "alphanum_fraction": 0.4526445264, "avg_line_length": 32.52, "ext": "agda", "hexsha": "ec6024bb11a6910bfeb313bd12e1b41958c85f60", "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/PruningNonMillerPatternFail.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/PruningNonMillerPatternFail.agda", "max_line_length": 71, "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/PruningNonMillerPatternFail.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 272, "size": 813 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Operations.Unary where open import Data.Binary.Definitions open import Function inc⁺⁺ : 𝔹⁺ → 𝔹⁺ inc⁺⁺ 1ᵇ = O ∷ 1ᵇ inc⁺⁺ (O ∷ xs) = I ∷ xs inc⁺⁺ (I ∷ xs) = O ∷ inc⁺⁺ xs inc⁺ : 𝔹 → 𝔹⁺ inc⁺ 0ᵇ = 1ᵇ inc⁺ (0< x) = inc⁺⁺ x inc : 𝔹 → 𝔹 inc x = 0< inc⁺ x dec⁺⁺ : Bit → 𝔹⁺ → 𝔹⁺ dec⁺⁺ I xs = O ∷ xs dec⁺⁺ O 1ᵇ = 1ᵇ dec⁺⁺ O (x ∷ xs) = I ∷ dec⁺⁺ x xs dec⁺ : 𝔹⁺ → 𝔹 dec⁺ 1ᵇ = 0ᵇ dec⁺ (x ∷ xs) = 0< dec⁺⁺ x xs dec : 𝔹 → 𝔹 dec 0ᵇ = 0ᵇ dec (0< x) = dec⁺ x
{ "alphanum_fraction": 0.5139442231, "avg_line_length": 15.6875, "ext": "agda", "hexsha": "89b65c1f89fd71154d07655ccb5f9989aa2faa4e", "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": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_path": "Data/Binary/Operations/Unary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "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-binary", "max_issues_repo_path": "Data/Binary/Operations/Unary.agda", "max_line_length": 41, "max_stars_count": 1, "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_path": "Data/Binary/Operations/Unary.agda", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "num_tokens": 332, "size": 502 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Homotopy.Group.S3 where {- This file contains a summary of what remains for π₄S³≅ℤ/2 to be proved. See the module π₄S³ at the end of this file. -} open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Data.Nat open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.Data.Int renaming (_·_ to _·ℤ_ ; _+_ to _+ℤ_) open import Cubical.Homotopy.Group.Base open import Cubical.Homotopy.HopfInvariant.Base open import Cubical.Homotopy.HopfInvariant.Homomorphism open import Cubical.Homotopy.HopfInvariant.HopfMap open import Cubical.Homotopy.Whitehead open import Cubical.Algebra.Group.Instances.IntMod open import Cubical.Foundations.Isomorphism open import Cubical.HITs.Sn open import Cubical.HITs.SetTruncation open import Cubical.Algebra.Group renaming (ℤ to ℤGroup ; Bool to BoolGroup ; Unit to UnitGroup) open import Cubical.Algebra.Group.ZAction [_]× : ∀ {ℓ} {X : Pointed ℓ} {n m : ℕ} → π' (suc n) X × π' (suc m) X → π' (suc (n + m)) X [_]× (f , g) = [ f ∣ g ]π' -- Some type abbreviations (unproved results) π₃S²-gen : Type π₃S²-gen = gen₁-by (π'Gr 2 (S₊∙ 2)) ∣ HopfMap ∣₂ π₄S³≅ℤ/something : GroupEquiv ℤGroup (π'Gr 2 (S₊∙ 2)) → Type π₄S³≅ℤ/something eq = GroupIso (π'Gr 3 (S₊∙ 3)) (ℤ/ abs (invEq (fst eq) [ ∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂ ]×)) miniLem₁ : Type miniLem₁ = (g : ℤ) → gen₁-by ℤGroup g → (g ≡ 1) ⊎ (g ≡ -1) miniLem₂ : Type miniLem₂ = (ϕ : GroupEquiv ℤGroup ℤGroup) (g : ℤ) → (abs g ≡ abs (fst (fst ϕ) g)) -- some minor group lemmas groupLem-help : miniLem₁ → (g : ℤ) → gen₁-by ℤGroup g → (ϕ : GroupHom ℤGroup ℤGroup) → (fst ϕ g ≡ pos 1) ⊎ (fst ϕ g ≡ negsuc 0) → isEquiv (fst ϕ) groupLem-help grlem1 g gen ϕ = main (grlem1 g gen) where isEquiv- : isEquiv (-_) isEquiv- = isoToIsEquiv (iso -_ -_ -Involutive -Involutive) lem : fst ϕ (pos 1) ≡ pos 1 → fst ϕ ≡ idfun _ lem p = funExt lem2 where lem₁ : (x₁ : ℕ) → fst ϕ (pos x₁) ≡ idfun ℤ (pos x₁) lem₁ zero = IsGroupHom.pres1 (snd ϕ) lem₁ (suc zero) = p lem₁ (suc (suc n)) = IsGroupHom.pres· (snd ϕ) (pos (suc n)) 1 ∙ cong₂ _+ℤ_ (lem₁ (suc n)) p lem2 : (x₁ : ℤ) → fst ϕ x₁ ≡ idfun ℤ x₁ lem2 (pos n) = lem₁ n lem2 (negsuc zero) = IsGroupHom.presinv (snd ϕ) 1 ∙ cong (λ x → pos 0 - x) p lem2 (negsuc (suc n)) = (cong (fst ϕ) (sym (+Comm (pos 0) (negsuc (suc n)))) ∙ IsGroupHom.presinv (snd ϕ) (pos (suc (suc n)))) ∙∙ +Comm (pos 0) _ ∙∙ cong (-_) (lem₁ (suc (suc n))) lem₂ : fst ϕ (negsuc 0) ≡ pos 1 → fst ϕ ≡ -_ lem₂ p = funExt lem2 where s = IsGroupHom.presinv (snd ϕ) (negsuc 0) ∙∙ +Comm (pos 0) _ ∙∙ cong -_ p lem2 : (n : ℤ) → fst ϕ n ≡ - n lem2 (pos zero) = IsGroupHom.pres1 (snd ϕ) lem2 (pos (suc zero)) = s lem2 (pos (suc (suc n))) = IsGroupHom.pres· (snd ϕ) (pos (suc n)) 1 ∙ cong₂ _+ℤ_ (lem2 (pos (suc n))) s lem2 (negsuc zero) = p lem2 (negsuc (suc n)) = IsGroupHom.pres· (snd ϕ) (negsuc n) (negsuc 0) ∙ cong₂ _+ℤ_ (lem2 (negsuc n)) p main : (g ≡ pos 1) ⊎ (g ≡ negsuc 0) → (fst ϕ g ≡ pos 1) ⊎ (fst ϕ g ≡ negsuc 0) → isEquiv (fst ϕ) main (inl p) = J (λ g p → (fst ϕ g ≡ pos 1) ⊎ (fst ϕ g ≡ negsuc 0) → isEquiv (fst ϕ)) (λ { (inl x) → subst isEquiv (sym (lem x)) (snd (idEquiv _)) ; (inr x) → subst isEquiv (sym (lem₂ (IsGroupHom.presinv (snd ϕ) (pos 1) ∙ (cong (λ x → pos 0 - x) x)))) isEquiv- }) (sym p) main (inr p) = J (λ g p → (fst ϕ g ≡ pos 1) ⊎ (fst ϕ g ≡ negsuc 0) → isEquiv (fst ϕ)) (λ { (inl x) → subst isEquiv (sym (lem₂ x)) isEquiv- ; (inr x) → subst isEquiv (sym (lem ( IsGroupHom.presinv (snd ϕ) (negsuc 0) ∙ cong (λ x → pos 0 - x) x))) (snd (idEquiv _))}) (sym p) groupLem : {G : Group₀} → miniLem₁ → GroupEquiv ℤGroup G → (g : fst G) → gen₁-by G g → (ϕ : GroupHom G ℤGroup) → (fst ϕ g ≡ 1) ⊎ (fst ϕ g ≡ -1) → isEquiv (fst ϕ) groupLem {G = G} s = GroupEquivJ (λ G _ → (g : fst G) → gen₁-by G g → (ϕ : GroupHom G ℤGroup) → (fst ϕ g ≡ 1) ⊎ (fst ϕ g ≡ -1) → isEquiv (fst ϕ)) (groupLem-help s) -- summary module π₄S³ (mini-lem₁ : miniLem₁) (mini-lem₂ : miniLem₂) (ℤ≅π₃S² : GroupEquiv ℤGroup (π'Gr 2 (S₊∙ 2))) (gen-by-HopfMap : π₃S²-gen) (π₄S³≅ℤ/whitehead : π₄S³≅ℤ/something ℤ≅π₃S²) (hopfWhitehead : abs (HopfInvariant-π' 0 ([ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]×)) ≡ 2) where π₄S³ = π'Gr 3 (S₊∙ 3) hopfInvariantEquiv : GroupEquiv (π'Gr 2 (S₊∙ 2)) ℤGroup fst (fst hopfInvariantEquiv) = HopfInvariant-π' 0 snd (fst hopfInvariantEquiv) = groupLem mini-lem₁ ℤ≅π₃S² ∣ HopfMap ∣₂ gen-by-HopfMap (GroupHom-HopfInvariant-π' 0) (abs→⊎ _ _ HopfInvariant-HopfMap) snd hopfInvariantEquiv = snd (GroupHom-HopfInvariant-π' 0) lem : ∀ {G : Group₀} (ϕ ψ : GroupEquiv ℤGroup G) (g : fst G) → abs (invEq (fst ϕ) g) ≡ abs (invEq (fst ψ) g) lem = GroupEquivJ (λ G ϕ → (ψ : GroupEquiv ℤGroup G) (g : fst G) → abs (invEq (fst ϕ) g) ≡ abs (invEq (fst ψ) g)) λ ψ → mini-lem₂ (invGroupEquiv ψ) main : GroupIso π₄S³ (ℤ/ 2) main = subst (GroupIso π₄S³) (cong (ℤ/_) (lem ℤ≅π₃S² (invGroupEquiv (hopfInvariantEquiv)) _ ∙ hopfWhitehead)) π₄S³≅ℤ/whitehead
{ "alphanum_fraction": 0.5530612245, "avg_line_length": 32.131147541, "ext": "agda", "hexsha": "41757fc04fbf25d90f09318e92b2f2a35e17c9cb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_path": "Cubical/Homotopy/Group/S3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lpw25/cubical", "max_issues_repo_path": "Cubical/Homotopy/Group/S3.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_path": "Cubical/Homotopy/Group/S3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2447, "size": 5880 }
-- Andreas, 2021-05-06, issue #5365 -- Error message for incomplete binding in do-block. postulate _>>=_ : Set test = do x ← -- Expected: proper error like -- -- Incomplete binding x ← -- <EOF><ERROR> -- ...
{ "alphanum_fraction": 0.6338028169, "avg_line_length": 15.2142857143, "ext": "agda", "hexsha": "0b75a9804314a50b3144eae1088be671e753b767", "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/Issue5365.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/Issue5365.agda", "max_line_length": 52, "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/Issue5365.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": 65, "size": 213 }
-- Andreas, 2017-10-19, issue #2808 -- The fix of #1077 was not general enough. -- module _ where -- If this is added, we get the error about duplicate module postulate A : Set -- Accepted if this is deleted module Issue2808 where record Issue2808 : Set where -- Expected error: (at the postulate) -- Illegal declaration(s) before top-level module -- We now raise this error if the first module of the file -- has the same name as the inferred top-level module.
{ "alphanum_fraction": 0.729787234, "avg_line_length": 27.6470588235, "ext": "agda", "hexsha": "6ecc8417b87031e8cb77fa25d630967aa01fbfcf", "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/Issue2808.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/Issue2808.agda", "max_line_length": 79, "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/Issue2808.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": 120, "size": 470 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Standard evaluation for MTerm ------------------------------------------------------------------------ import Parametric.Syntax.Type as Type import Parametric.Syntax.Term as Term import Parametric.Denotation.Value as Value import Parametric.Syntax.MType as MType import Parametric.Syntax.MTerm as MTerm import Parametric.Denotation.MValue as MValue module Parametric.Denotation.MEvaluation {Base : Type.Structure} (Const : Term.Structure Base) (⟦_⟧Base : Value.Structure Base) (ValConst : MTerm.ValConstStructure Const) (CompConst : MTerm.CompConstStructure Const) (cbnToCompConst : MTerm.CbnToCompConstStructure Const CompConst) (cbvToCompConst : MTerm.CbvToCompConstStructure Const CompConst) where open Type.Structure Base open MType.Structure Base open MTerm.Structure Const ValConst CompConst cbnToCompConst cbvToCompConst open MValue.Structure Base ⟦_⟧Base open import Base.Data.DependentList open import Base.Denotation.Notation -- Extension Point: Evaluation of constants. ValStructure : Set ValStructure = ∀ {τ} → ValConst τ → ⟦ τ ⟧ CompStructure : Set CompStructure = ∀ {τ} → CompConst τ → ⟦ τ ⟧ module Structure (⟦_⟧ValBase : ValStructure) (⟦_⟧CompBase : CompStructure) where -- We provide: Evaluation of arbitrary value/computation terms. ⟦_⟧Comp : ∀ {τ Γ} → Comp Γ τ → ⟦ Γ ⟧ValContext → ⟦ τ ⟧CompType ⟦_⟧Val : ∀ {τ Γ} → Val Γ τ → ⟦ Γ ⟧ValContext → ⟦ τ ⟧ValType ⟦ vVar x ⟧Val ρ = ⟦ x ⟧ValVar ρ ⟦ vThunk x ⟧Val ρ = ⟦ x ⟧Comp ρ ⟦ vConst c ⟧Val ρ = ⟦ c ⟧ValBase ⟦ cConst c ⟧Comp ρ = ⟦ c ⟧CompBase ⟦ cForce x ⟧Comp ρ = ⟦ x ⟧Val ρ ⟦ cReturn v ⟧Comp ρ = ⟦ v ⟧Val ρ ⟦ cAbs c ⟧Comp ρ = λ x → ⟦ c ⟧Comp (x • ρ) ⟦ cApp s t ⟧Comp ρ = ⟦ s ⟧Comp ρ (⟦ t ⟧Val ρ) ⟦ c₁ into c₂ ⟧Comp ρ = ⟦ c₂ ⟧Comp (⟦ c₁ ⟧Comp ρ • ρ) meaningOfVal : ∀ {Γ τ} → Meaning (Val Γ τ) meaningOfVal = meaning ⟦_⟧Val -- Evaluation.agda also proves weaken-sound.
{ "alphanum_fraction": 0.6320662768, "avg_line_length": 31.0909090909, "ext": "agda", "hexsha": "ace3956baef2f407fe592f01ed226559f659901b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Parametric/Denotation/MEvaluation.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Parametric/Denotation/MEvaluation.agda", "max_line_length": 75, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Parametric/Denotation/MEvaluation.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 692, "size": 2052 }
{- Denotational semantics of the types in the category of temporal types. -} module Semantics.Types where open import Syntax.Types open import CategoryTheory.Instances.Reactive hiding (_+_) open import TemporalOps.Box open import TemporalOps.Diamond -- Denotation of types ⟦_⟧ₜ : Type -> τ ⟦ Unit ⟧ₜ = ⊤ ⟦ A & B ⟧ₜ = ⟦ A ⟧ₜ ⊗ ⟦ B ⟧ₜ ⟦ A + B ⟧ₜ = ⟦ A ⟧ₜ ⊕ ⟦ B ⟧ₜ ⟦ A => B ⟧ₜ = ⟦ A ⟧ₜ ⇒ ⟦ B ⟧ₜ ⟦ Event A ⟧ₜ = ◇ ⟦ A ⟧ₜ ⟦ Signal A ⟧ₜ = □ ⟦ A ⟧ₜ
{ "alphanum_fraction": 0.601750547, "avg_line_length": 25.3888888889, "ext": "agda", "hexsha": "f845d17294a547f8707f5935221d11e4c329d19f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/Semantics/Types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/Semantics/Types.agda", "max_line_length": 76, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/Semantics/Types.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 208, "size": 457 }