Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Diagram.Equalizer.Properties {o ℓ e} (C : Category o ℓ e) where open import Categories.Diagram.Equalizer C open import Categories.Morphism C open import Categories.Morphism.Reasoning C private module C = Category C open C variable X Y Z : Obj module _ {f g : X ⇒ Y} (equalizer : Equalizer f g) where open Equalizer equalizer open HomReasoning equalizer-≈⇒≈ : ∀ {h} → arr ∘ h ≈ id → f ≈ g equalizer-≈⇒≈ {h} eq = begin f ≈⟨ introʳ eq ⟩ f ∘ arr ∘ h ≈⟨ pullˡ equality ⟩ (g ∘ arr) ∘ h ≈⟨ cancelʳ eq ⟩ g ∎
{ "alphanum_fraction": 0.6226993865, "avg_line_length": 23.2857142857, "ext": "agda", "hexsha": "7943b4831f4a790f080390ddf81b24a7216d6e16", "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/Diagram/Equalizer/Properties.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/Diagram/Equalizer/Properties.agda", "max_line_length": 81, "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/Diagram/Equalizer/Properties.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": 229, "size": 652 }
-- {-# OPTIONS --sized-types --show-implicit #-} module _ where open import Common.Size data Either (A B : Set) : Set where left : A → Either A B right : B → Either A B caseEither : ∀{A B C : Set} → Either A B → (A → C) → (B → C) → C caseEither (left a) l r = l a caseEither (right b) l r = r b data Nat {i : Size} : Set where zero : Nat suc : {i' : Size< i} → Nat {i'} → Nat -- subtraction is non size increasing sub : {size : Size} → Nat {size} → Nat {∞} → Nat {size} sub zero n = zero sub (suc m) zero = suc m sub (suc m) (suc n) = sub m n -- div' m n computes ceiling(m/(n+1)) div' : {size : Size} → Nat {size} → Nat → Nat {size} div' zero n = zero div' (suc m) n = suc (div' (sub m n) n) -- one can use sized types as if they were not sized -- sizes default to ∞ add : Nat → Nat → Nat add (zero ) n = n add (suc m) n = suc (add m n) nisse : {i : Size} → Nat {i} → Nat {i} nisse zero = zero nisse (suc zero) = suc zero nisse (suc (suc n)) = suc zero -- symmetric difference -- @diff n m@ returns @left (n - m)@ if @n@ is bigger, otherwise @right (m - n)@ diff : ∀{i j} → Nat {i} → Nat {j} → Either (Nat {i}) (Nat {j}) diff zero m = right m diff (suc n) zero = left (suc n) diff (suc n) (suc m) = diff n m module Case where gcd : ∀{i j} → Nat {i} → Nat {j} → Nat gcd zero m = m gcd (suc n) zero = suc n gcd (suc n) (suc m) = caseEither (diff n m) (λ n' → gcd n' (suc m)) (λ m' → gcd (suc n) m') module With where gcd : ∀{i j} → Nat {i} → Nat {j} → Nat gcd zero m = m gcd (suc n) zero = suc n gcd (suc n) (suc m) with diff n m ... | left n' = gcd n' (suc m) ... | right m' = gcd (suc n) m' NatInfty = Nat {∞} {-# BUILTIN NATURAL NatInfty #-} -- {-# BUILTIN NATPLUS add #-} -- not accepted
{ "alphanum_fraction": 0.5338797814, "avg_line_length": 24.4, "ext": "agda", "hexsha": "fdc21dd616b081ad1e600072502c2076620baa98", "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/SizedNatNew.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/SizedNatNew.agda", "max_line_length": 80, "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/SizedNatNew.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": 706, "size": 1830 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Homomorphism proofs for exponentiation over polynomials ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Tactic.RingSolver.Core.Polynomial.Parameters module Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation {r₁ r₂ r₃ r₄} (homo : Homomorphism r₁ r₂ r₃ r₄) where open import Function open import Data.Nat.Base as ℕ using (ℕ; suc; zero; compare) open import Data.Product using (_,_; _×_; proj₁; proj₂) open import Data.List.Kleene open import Data.Vec using (Vec) import Data.Nat.Properties as ℕ-Prop import Relation.Binary.PropositionalEquality as ≡ open Homomorphism homo open import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas homo open import Tactic.RingSolver.Core.Polynomial.Base from open import Tactic.RingSolver.Core.Polynomial.Reasoning to open import Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication homo open import Tactic.RingSolver.Core.Polynomial.Semantics homo import Algebra.Operations.Ring rawRing as RawPow import Algebra.Operations.Ring (RawCoeff.rawRing from) as CoPow pow-eval-hom : ∀ x i → ⟦ x CoPow.^ i +1 ⟧ᵣ ≈ ⟦ x ⟧ᵣ RawPow.^ i +1 pow-eval-hom x ℕ.zero = refl pow-eval-hom x (suc i) = (*-homo _ x) ⟨ trans ⟩ (≪* pow-eval-hom x i) ⊡-mult-hom : ∀ {n} i (xs : Poly n) ρ → ⟦ ⊡-mult i xs ⟧ ρ ≈ ⟦ xs ⟧ ρ RawPow.^ i +1 ⊡-mult-hom ℕ.zero xs ρ = refl ⊡-mult-hom (suc i) xs ρ = ⊠-hom (⊡-mult i xs) xs ρ ⟨ trans ⟩ (≪* ⊡-mult-hom i xs ρ) ⊡-+1-hom : ∀ {n} → (xs : Poly n) → (i : ℕ) → ∀ ρ → ⟦ xs ⊡ i +1 ⟧ ρ ≈ ⟦ xs ⟧ ρ RawPow.^ i +1 ⊡-+1-hom (Κ x ⊐ i≤n) i ρ = pow-eval-hom x i ⊡-+1-hom xs@(⅀ (_ & ∹ _) ⊐ i≤n) i ρ = ⊡-mult-hom i xs ρ ⊡-+1-hom (⅀ (x ≠0 Δ j & []) ⊐ i≤n) i ρ = begin ⟦ x ⊡ i +1 Δ (j ℕ.+ i ℕ.* j) ∷↓ [] ⊐↓ i≤n ⟧ ρ ≈⟨ ⊐↓-hom (x ⊡ i +1 Δ (j ℕ.+ i ℕ.* j) ∷↓ []) i≤n ρ ⟩ ⅀?⟦ x ⊡ i +1 Δ (j ℕ.+ i ℕ.* j) ∷↓ [] ⟧ (drop-1 i≤n ρ) ≈⟨ ∷↓-hom (x ⊡ i +1) (j ℕ.+ i ℕ.* j) [] ρ′ Ρ ⟩ (ρ′ RawPow.^ (j ℕ.+ i ℕ.* j)) * (⟦ x ⊡ i +1 ⟧ Ρ) ≈⟨ *≫ (( ⊡-+1-hom x i Ρ) ) ⟩ (ρ′ RawPow.^ (j ℕ.+ i ℕ.* j)) * (⟦ x ⟧ Ρ RawPow.^ i +1) ≈⟨ rearrange j ⟩ (( ⟦ x ⟧ Ρ) *⟨ ρ′ ⟩^ j) RawPow.^ i +1 ∎ where ρ′,Ρ = drop-1 i≤n ρ ρ′ = proj₁ ρ′,Ρ Ρ = proj₂ ρ′,Ρ rearrange : ∀ j → (ρ′ RawPow.^ (j ℕ.+ i ℕ.* j)) * (⟦ x ⟧ Ρ RawPow.^ i +1)≈ (( ⟦ x ⟧ Ρ) *⟨ ρ′ ⟩^ j) RawPow.^ i +1 rearrange zero = begin (ρ′ RawPow.^ (i ℕ.* 0)) * (⟦ x ⟧ Ρ RawPow.^ i +1) ≡⟨ ≡.cong (λ k → (ρ′ RawPow.^ k) * (⟦ x ⟧ Ρ RawPow.^ i +1)) (ℕ-Prop.*-zeroʳ i) ⟩ 1# * (⟦ x ⟧ Ρ RawPow.^ i +1) ≈⟨ *-identityˡ _ ⟩ ⟦ x ⟧ Ρ RawPow.^ i +1 ∎ rearrange j@(suc j′) = begin (ρ′ RawPow.^ (j ℕ.+ i ℕ.* j)) * (⟦ x ⟧ Ρ RawPow.^ i +1) ≈⟨ ≪* sym ( pow-mult-+1 ρ′ j′ i) ⟩ ((ρ′ RawPow.^ j′ +1) RawPow.^ i +1) * (⟦ x ⟧ Ρ RawPow.^ i +1) ≈⟨ sym (pow-distrib-+1 _ (⟦ x ⟧ Ρ) i) ⟩ ((ρ′ RawPow.^ j′ +1) * ⟦ x ⟧ Ρ) RawPow.^ i +1 ∎ ⊡-hom : ∀ {n} → (xs : Poly n) → (i : ℕ) → ∀ ρ → ⟦ xs ⊡ i ⟧ ρ ≈ ⟦ xs ⟧ ρ RawPow.^ i ⊡-hom xs ℕ.zero ρ = 1-homo ⊡-hom xs (suc i) ρ = ⊡-+1-hom xs i ρ
{ "alphanum_fraction": 0.5171646535, "avg_line_length": 37.4523809524, "ext": "agda", "hexsha": "8ac6abecdecc6ed601cb132ad72dfdb366f5fc10", "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/Tactic/RingSolver/Core/Polynomial/Homomorphism/Exponentiation.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/Tactic/RingSolver/Core/Polynomial/Homomorphism/Exponentiation.agda", "max_line_length": 114, "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/Tactic/RingSolver/Core/Polynomial/Homomorphism/Exponentiation.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": 1461, "size": 3146 }
{-# OPTIONS --allow-unsolved-metas #-} open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; subst; setoid) open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap) import Function.Equality open import Relation.Binary using (Setoid) import Relation.Binary.Reasoning.Setoid as SetoidR import Categories.Category import Categories.Functor import Categories.Category.Instance.Setoids import Categories.Monad.Relative import Categories.Category.Equivalence import Categories.Category.Cocartesian import Categories.Category.Construction.Functors import Categories.Category.Product import Categories.NaturalTransformation import Categories.NaturalTransformation.NaturalIsomorphism import SecondOrder.Arity import SecondOrder.Signature import SecondOrder.Metavariable import SecondOrder.VRenaming import SecondOrder.MRenaming import SecondOrder.Term import SecondOrder.Substitution import SecondOrder.RelativeMonadMorphism import SecondOrder.Instantiation import SecondOrder.IndexedCategory import SecondOrder.RelativeKleisli module SecondOrder.Mslot {ℓ} {𝔸 : SecondOrder.Arity.Arity} (Σ : SecondOrder.Signature.Signature ℓ 𝔸) where open SecondOrder.Signature.Signature Σ open SecondOrder.Metavariable Σ open SecondOrder.Term Σ open SecondOrder.VRenaming Σ open SecondOrder.MRenaming Σ -- open SecondOrder.Substitution Σ -- open import SecondOrder.RelativeMonadMorphism -- open SecondOrder.Instantiation open Categories.Category open Categories.Functor using (Functor) open Categories.NaturalTransformation renaming (id to idNt) open Categories.NaturalTransformation.NaturalIsomorphism renaming (refl to reflNt; sym to symNt; trans to transNt) open Categories.Category.Construction.Functors open Categories.Category.Instance.Setoids open Categories.Category.Product open Function.Equality using () renaming (setoid to Π-setoid) open SecondOrder.IndexedCategory -- open import SecondOrder.RelativeKleisli MTele = MContexts VTele = VContexts -- the codomain category of the MSlots functor. It should be equivalent to the -- functor category [ MTele x VTele , < Setoid >ₛₒᵣₜ ] -- objects are functors, which are really pairs of functions, one on objects -- one on morphisms -- morphisms in this category are natural transformations module _ where open Category open NaturalTransformation open Function.Equality renaming (_∘_ to _∙_) ∘ᵥ-resp-≈ : ∀ {o l e o' l' e'} {𝒞 : Category o l e} {𝒟 : Category o' l' e'} {F G H : Functor 𝒞 𝒟} {α β : NaturalTransformation F G} {γ δ : NaturalTransformation G H} → (∀ {X : Obj 𝒞} → (𝒟 Category.≈ (η α X)) (η β X)) → (∀ {X : Obj 𝒞} → (𝒟 Category.≈ (η γ X)) (η δ X)) ------------------------------------------------------------------- → (∀ {X : Obj 𝒞} → (𝒟 Category.≈ (η (γ ∘ᵥ α) X)) (η (δ ∘ᵥ β) X)) ∘ᵥ-resp-≈ {𝒟 = 𝒟} α≈β γ≈δ {X = X} = ∘-resp-≈ 𝒟 γ≈δ α≈β MCodom : Category (lsuc ℓ) ℓ ℓ MCodom = let open Category in let open Functor in let open NaturalTransformation in let open Function.Equality using (_⟨$⟩_) renaming (cong to func-cong) in let open Category.HomReasoning in record { Obj = Functor MTele (Functors VTele (Setoids ℓ ℓ)) ; _⇒_ = NaturalTransformation ; _≈_ = λ {F} {G} α β → ∀ (ψ : Obj MTele) (Γ : Obj VTele) → (Setoids ℓ ℓ Category.≈ (η ((η α) ψ) Γ)) (η ((η β) ψ) Γ) ; id = idNt ; _∘_ = _∘ᵥ_ ; assoc = λ ψ Γ x≈y → Setoid.refl {!!} ; sym-assoc = λ ψ Γ x≈y → Setoid.refl {!!} ; identityˡ = λ {F} {G} {α} ψ Γ x≈y → Setoid.refl {!!} ; identityʳ = λ ψ Γ x → Setoid.refl {!!} ; identity² = Setoid.refl {!!} ; equiv = record { refl = Setoid.refl {!!} ; sym = Setoid.sym {!!} ; trans = Setoid.trans {!!} } ; ∘-resp-≈ = λ {F} {G} {H} {α} {β} {γ} {δ} α≈β γ≈δ ψ Γ → ∘ᵥ-resp-≈ {α = γ} {δ} {γ = α} {β} (γ≈δ _ _) (α≈β _ _) } Mslots : Functor MContexts (IndexedCategory sort (MCodom)) Mslots = let open Categories.NaturalTransformation in let open NaturalTransformation in record { F₀ = λ Θ A → record { F₀ = λ ψ → Term-Functor {Θ ,, ψ} {A} ; F₁ = λ ι → MRenaming-NT (ᵐ⇑ᵐ ι) ; identity = λ t≈s → ≈-trans (≈-trans ([]ᵐ-resp-≡ᵐ ᵐ⇑ᵐ-resp-idᵐ) [idᵐ]) t≈s ; homomorphism = λ t≈s → ≈-trans ([]ᵐ-resp-≈ t≈s) (≈-trans ([]ᵐ-resp-≡ᵐ ᵐ⇑ᵐ-resp-∘ᵐ) [∘ᵐ]) ; F-resp-≈ = λ ι≡μ t≈s → ≈-trans ([]ᵐ-resp-≈ t≈s) ([]ᵐ-resp-≡ᵐ (ᵐ⇑ᵐ-resp-≡ᵐ ι≡μ)) } ; F₁ = λ {Θ} {Θ'} ι A → record { η = λ Ψ → record { η = λ Γ → η (MRenaming-NT (⇑ᵐ ι)) Γ ; commute = commute (MRenaming-NT (⇑ᵐ ι)) ; sym-commute = sym-commute (MRenaming-NT (⇑ᵐ ι)) } ; commute = λ ι t≈s → ≈-trans ([]ᵐ-resp-≈ ([]ᵐ-resp-≈ t≈s)) ⇑-resp-+ ; sym-commute = λ ι t≈s → ≈-trans (≈-sym ⇑-resp-+) (([]ᵐ-resp-≈ ([]ᵐ-resp-≈ t≈s))) } ; identity = λ Θ ψ Γ t≈s → ≈-trans ([]ᵐ-resp-≈ t≈s) (≈-trans ([]ᵐ-resp-≡ᵐ ⇑ᵐ-resp-idᵐ) [idᵐ]) ; homomorphism = λ A ψ Γ t≈s → ≈-trans ([]ᵐ-resp-≈ t≈s) ∘ᵐ-resp-⇑-term ; F-resp-≈ = λ ι≡μ A ψ Γ t≈s → ≈-trans ([]ᵐ-resp-≈ t≈s) ([]ᵐ-resp-≡ᵐ (⇑ᵐ-resp-≡ᵐ ι≡μ)) }
{ "alphanum_fraction": 0.5885175969, "avg_line_length": 40.1857142857, "ext": "agda", "hexsha": "b1ab752fb2febb322eaf6720ae903455ff589df6", "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": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/SecondOrder/Mslot.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/SecondOrder/Mslot.agda", "max_line_length": 116, "max_stars_count": 1, "max_stars_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejbauer/formal", "max_stars_repo_path": "src/SecondOrder/Mslot.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:00.000Z", "num_tokens": 2009, "size": 5626 }
module StateSized.GUI.ShipBitMap where open import StateSizedIO.GUI.WxBindingsFFI ship : Bitmap ship = bitmap "./StateSized/GUI/ship.ico"
{ "alphanum_fraction": 0.8, "avg_line_length": 20, "ext": "agda", "hexsha": "253df446c6e0fa6c58128b7e236cf53d15a4e817", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/StateSized/GUI/ShipBitMap.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/StateSized/GUI/ShipBitMap.agda", "max_line_length": 42, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/StateSized/GUI/ShipBitMap.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 40, "size": 140 }
module NativePolyIO where open import Data.String.Base using (String) public open import Level record Unit {α} : Set α where constructor unit {-# HASKELL type AgdaUnit a = () #-} {-# COMPILED_DATA Unit AgdaUnit () #-} postulate NativeIO : ∀ {ℓ} → Set ℓ → Set ℓ nativeReturn : ∀ {a} {A : Set a} → A → NativeIO A _native>>=_ : ∀ {a b} {A : Set a} {B : Set b} → NativeIO A → (A → NativeIO B) → NativeIO B {-# COMPILED_TYPE NativeIO MAlonzo.Code.NativePolyIO.AgdaIO #-} {-# BUILTIN IO NativeIO #-} {-# HASKELL type AgdaIO a b = IO b #-} {-# COMPILED nativeReturn (\_ _ -> return :: a -> IO a) #-} {-# COMPILED _native>>=_ (\_ _ _ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-} {-# IMPORT Data.Text.IO #-} postulate nativePutStrLn : ∀ {ℓ} → String → NativeIO (Unit{ℓ}) nativeGetLine : NativeIO String {-# COMPILED nativePutStrLn (\ _ s -> Data.Text.IO.putStrLn s) #-} {-# COMPILED nativeGetLine Data.Text.IO.getLine #-}
{ "alphanum_fraction": 0.5956790123, "avg_line_length": 23.7073170732, "ext": "agda", "hexsha": "d7e2a66fb52e190ae2ef06992b182a14ef290589", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "src/NativePolyIO.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "src/NativePolyIO.agda", "max_line_length": 93, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "src/NativePolyIO.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 307, "size": 972 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Products of nullary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Nullary.Product where open import Data.Bool.Base open import Data.Product open import Function open import Level open import Relation.Nullary.Reflects open import Relation.Nullary private variable p q : Level P : Set p Q : Set q ------------------------------------------------------------------------ -- Some properties which are preserved by _×_. infixr 2 _×-reflects_ _×-dec_ _×-reflects_ : ∀ {bp bq} → Reflects P bp → Reflects Q bq → Reflects (P × Q) (bp ∧ bq) ofʸ p ×-reflects ofʸ q = ofʸ (p , q) ofʸ p ×-reflects ofⁿ ¬q = ofⁿ (¬q ∘ proj₂) ofⁿ ¬p ×-reflects _ = ofⁿ (¬p ∘ proj₁) _×-dec_ : Dec P → Dec Q → Dec (P × Q) does (p? ×-dec q?) = does p? ∧ does q? proof (p? ×-dec q?) = proof p? ×-reflects proof q?
{ "alphanum_fraction": 0.492248062, "avg_line_length": 27.1578947368, "ext": "agda", "hexsha": "f0655607636b9ead268b87ab775ba575fa6b0e93", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Relation/Nullary/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Relation/Nullary/Product.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Relation/Nullary/Product.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": 285, "size": 1032 }
module Issue512 where postulate Level : Set {-# BUILTIN LEVEL Level #-} data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} data A : Set where a b : A proof : a ≡ a proof = refl f : A → A → A f x y rewrite proof = ? -- gave error below (now complains about LEVELZERO instead of STRING) {- {- No binding for builtin thing STRING, use {-# BUILTIN STRING name #-} to bind it to 'name' when checking that the type of the generated with function (w : A) → _≡_ {"Max []"} {A} w w → (x y : A) → A is well-formed -} -}
{ "alphanum_fraction": 0.6070826307, "avg_line_length": 18.53125, "ext": "agda", "hexsha": "c5fe48d8d2c76906974f390c40b8e666838025bb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/fail/Issue512.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/fail/Issue512.agda", "max_line_length": 93, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/Issue512.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 198, "size": 593 }
module Operations.Stateful where import Data.Bool as B open import Data.Fin open import Data.Nat open import Data.Vec hiding (head; tail) open import Function open import Relation.Binary.PropositionalEquality open import Eval open import Operations.Combinatorial open import Types alternator : Closed 𝔹 → Closed (ℂ 𝔹) alternator x = reg x (lam (pair (not ∙ var zero refl) (var zero refl))) constant : ∀ {τ} → Closed τ → Closed (ℂ τ) constant x = reg x (lam (pair (var zero refl) (var zero refl)))
{ "alphanum_fraction": 0.7391304348, "avg_line_length": 26.6315789474, "ext": "agda", "hexsha": "621ea1dc54d904c86c6796f81518ea513eed0462", "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": "6f3df71dcd958c6a1d1bf4f175dc16c220d42124", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "bens/hwlc", "max_forks_repo_path": "Operations/Stateful.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6f3df71dcd958c6a1d1bf4f175dc16c220d42124", "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": "bens/hwlc", "max_issues_repo_path": "Operations/Stateful.agda", "max_line_length": 71, "max_stars_count": null, "max_stars_repo_head_hexsha": "6f3df71dcd958c6a1d1bf4f175dc16c220d42124", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "bens/hwlc", "max_stars_repo_path": "Operations/Stateful.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 139, "size": 506 }
module Categories.Initial where open import Library open import Categories open import Categories.Sets open Cat record Init {a b} (C : Cat {a}{b})(I : Obj C) : Set (a ⊔ b) where constructor init field i : ∀{X} → Hom C I X law : ∀{X}{f : Hom C I X} → i {X} ≅ f ZeroSet : Init Sets ⊥ ZeroSet = record {i = λ(); law = ext λ()}
{ "alphanum_fraction": 0.6117647059, "avg_line_length": 22.6666666667, "ext": "agda", "hexsha": "d44cda26e27790099ce1fcba3e425f5932dda4e5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "Categories/Initial.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "Categories/Initial.agda", "max_line_length": 65, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "Categories/Initial.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 115, "size": 340 }
-- Andreas, 2015-07-07 continuation of issue 665 -- Jesper, 2015-12-18 some of these don't work anymore with the new unifier, -- but a few others that weren't accepted are now. {-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.with.strip:10 #-} -- {-# OPTIONS -v tc.with.strip:60 -v tc.lhs:20 -v tc.lhs.unify:20 #-} postulate C : Set anything : C record I : Set where constructor c field {f} : C data Wrap : (i : I) → Set where wrap : ∀ {i} → Wrap i -- Test 0: first argument not given test0 : ∀ {j} → Wrap j → C test0 wrap with anything test0 wrap | z = z test0a : ∀ {j} → Wrap j → C test0a (wrap {c {x}}) with anything test0a wrap | z = z test0b : ∀ {j} → Wrap j → C test0b (wrap {c {_}}) with anything test0b wrap | z = z test0c : ∀ {j} → Wrap j → C test0c (wrap {c}) with anything test0c wrap | z = z test0d : ∀ {j} → Wrap j → C test0d (wrap {c {._}}) with anything test0d wrap | z = z test0e : ∀ {j} → Wrap j → C test0e (wrap .{c}) with anything test0e wrap | z = z test0f : ∀ {j} → Wrap j → C test0f (wrap .{c {_}}) with anything test0f wrap | z = z test00 : ∀ {j} → Wrap j → C test00 wrap with anything test00 {.c} wrap | z = z test00a : ∀ {j} → Wrap j → C test00a (wrap {c {x}}) with anything test00a {.c} wrap | z = z test00b : ∀ {j} → Wrap j → C test00b (wrap {c {_}}) with anything test00b {.c} wrap | z = z test00c : ∀ {j} → Wrap j → C test00c (wrap {c}) with anything test00c {.c} wrap | z = z test00d : ∀ {j} → Wrap j → C test00d (wrap {c {._}}) with anything test00d {.c} wrap | z = z test00e : ∀ {j} → Wrap j → C test00e (wrap .{c}) with anything test00e {.c} wrap | z = z test00f : ∀ {j} → Wrap j → C test00f (wrap .{c {_}}) with anything test00f {.c} wrap | z = z test000 : ∀ {j} → Wrap j → C test000 wrap with anything test000 .{c {_}} wrap | z = z test000a : ∀ {j} → Wrap j → C test000a (wrap {c {x}}) with anything test000a .{c {_}} wrap | z = z test000b : ∀ {j} → Wrap j → C test000b (wrap {c {_}}) with anything test000b .{c {_}} wrap | z = z test000c : ∀ {j} → Wrap j → C test000c (wrap {c}) with anything test000c .{c {_}} wrap | z = z test000d : ∀ {j} → Wrap j → C test000d (wrap {c {._}}) with anything test000d .{c {_}} wrap | z = z test000e : ∀ {j} → Wrap j → C test000e (wrap .{c}) with anything test000e .{c {_}} wrap | z = z test000f : ∀ {j} → Wrap j → C test000f (wrap .{c {_}}) with anything test000f .{c {_}} wrap | z = z -- Test 1: first argument is dot pattern test1a : ∀ {j} → Wrap j → C test1a .{c} (wrap {c {x}}) with anything test1a .{c} wrap | z = z test1b : ∀ {j} → Wrap j → C test1b .{c} (wrap {c {_}}) with anything test1b .{c} wrap | z = z test1c : ∀ {j} → Wrap j → C test1c .{c} (wrap {c}) with anything test1c .{c} wrap | z = z test11a : ∀ {j} → Wrap j → C test11a .{c} (wrap {c {x}}) with anything test11a wrap | z = z test11b : ∀ {j} → Wrap j → C test11b .{c} (wrap {c {_}}) with anything test11b wrap | z = z test11c : ∀ {j} → Wrap j → C test11c .{c} (wrap {c}) with anything test11c wrap | z = z test111a : ∀ {j} → Wrap j → C test111a (wrap {c {x}}) with anything test111a .{c} wrap | z = z test111b : ∀ {j} → Wrap j → C test111b (wrap {c {_}}) with anything test111b .{c} wrap | z = z test111c : ∀ {j} → Wrap j → C test111c (wrap {c}) with anything test111c .{c} wrap | z = z -- Test 2: First argument is record pattern test2a : ∀ {j} → Wrap j → C test2a {c} wrap with anything test2a {c} wrap | z = z test2b : ∀ {j} → Wrap j → C test2b {c} wrap with anything test2b wrap | z = z test2c : ∀ {j} → Wrap j → C test2c {c} (wrap {c}) with anything test2c {c} wrap | z = z test2d : ∀ {j} → Wrap j → C test2d {c} (wrap {c}) with anything test2d wrap | z = z test2e : ∀ {j} → Wrap j → C test2e {c} (wrap {c {._}}) with anything test2e {c} wrap | z = z test2f : ∀ {j} → Wrap j → C test2f {c} (wrap {c {._}}) with anything test2f wrap | z = z test2g : ∀ {j} → Wrap j → C test2g {c} (wrap {c {x}}) with anything test2g {c} wrap | z = z test2h : ∀ {j} → Wrap j → C test2h {c} (wrap {c {x}}) with anything test2h wrap | z = z test2i : ∀ {j} → Wrap j → C test2i {c} (wrap {c {_}}) with anything test2i {c} wrap | z = z test2j : ∀ {j} → Wrap j → C test2j {c} (wrap {c {_}}) with anything test2j wrap | z = z -- Test 3: First argument is record of dot pattern, second is record pattern test3a : ∀ {j} → Wrap j → C test3a {c {._}} wrap with anything test3a {c {._}} wrap | z = z test3b : ∀ {j} → Wrap j → C test3b {c {._}} wrap with anything test3b wrap | z = z test3c : ∀ {j} → Wrap j → C test3c {c {._}} (wrap {c}) with anything test3c {c {._}} wrap | z = z test3d : ∀ {j} → Wrap j → C test3d {c {._}} (wrap {c}) with anything test3d wrap | z = z test3e : ∀ {j} → Wrap j → C test3e {c {._}} (wrap {c {._}}) with anything test3e {c {._}} wrap | z = z test3f : ∀ {j} → Wrap j → C test3f {c {._}} (wrap {c {._}}) with anything test3f wrap | z = z test3g : ∀ {j} → Wrap j → C test3g {c {_}} (wrap {c {x}}) with anything test3g {c {_}} wrap | z = z test3h : ∀ {j} → Wrap j → C test3h {c {_}} (wrap {c {x}}) with anything test3h wrap | z = z test3i : ∀ {j} → Wrap j → C test3i {c {_}} (wrap {c {_}}) with anything test3i {c {_}} wrap | z = z test3j : ∀ {j} → Wrap j → C test3j {c {_}} (wrap {c {_}}) with anything test3j wrap | z = z
{ "alphanum_fraction": 0.5769010863, "avg_line_length": 22.9126637555, "ext": "agda", "hexsha": "3882806bb942ef9e458bb9b2e1a5e36ae05aef44", "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/Issue473-1606.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/Issue473-1606.agda", "max_line_length": 76, "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/Issue473-1606.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": 2173, "size": 5247 }
{-# OPTIONS --without-K --safe #-} open import Level open import Categories.Category using () renaming (Category to Setoid-Category) open import Categories.Category.Monoidal using (Monoidal) module Categories.Bicategory.Instance.EnrichedCats {o ℓ e} {V : Setoid-Category o ℓ e} (M : Monoidal V) (v : Level) where -- The 2-category of V-enriched categories open import Data.Product as Prod using (_,_) open import Categories.Bicategory using (Bicategory) open import Categories.Category.Construction.EnrichedFunctors M open import Categories.Enriched.Category M open import Categories.Enriched.Functor M renaming (id to idF) open import Categories.Enriched.NaturalTransformation M hiding (id) import Categories.Enriched.NaturalTransformation.NaturalIsomorphism M as NI open import Categories.Functor.Bifunctor using (Bifunctor) open import Categories.Functor.Construction.Constant using (const) open import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper) private module V = Setoid-Category V module UnderlyingReasoning {c} (C : Category c) where open Underlying C public hiding (id) open HomReasoning public open NaturalTransformation open NI.NaturalIsomorphism -- Aliases used to shorten some proof expressions module UF = UnderlyingFunctor infixr 14 _$₀_ _$₁_ _$₀_ = UF.F₀ _$₁_ = UF.F₁ -- The bicategory of V-enriched categories, functors and natural -- transformations. -- -- Note that all the equational reasoning happens in the underlying -- (ordinary) categories! EnrichedCats : Bicategory (ℓ ⊔ e ⊔ v) (ℓ ⊔ e ⊔ v) (e ⊔ v) (o ⊔ ℓ ⊔ e ⊔ suc v) EnrichedCats = record { enriched = record { Obj = Category v ; hom = EnrichedFunctors ; id = const idF ; ⊚ = ⊚ ; ⊚-assoc = λ {_ _ C D} → let module C = Underlying C module D = Underlying D open UnderlyingReasoning D in niHelper record { η = λ { ((F , G) , H) → from (NI.associator {F = F} {G} {H}) } ; η⁻¹ = λ { ((F , G) , H) → to (NI.associator {F = F} {G} {H}) } ; commute = λ { {(_ , G₁) , H₁} {(F₂ , G₂) , _} ((α , β) , γ) {X} → begin D.id ∘ (F₂ ∘F G₂) $₁ γ [ X ] ∘ F₂ $₁ β [ H₁ $₀ X ] ∘ α [ G₁ $₀ H₁ $₀ X ] ≈⟨ identityˡ ○ ⟺ assoc ⟩ ((F₂ ∘F G₂) $₁ γ [ X ] ∘ F₂ $₁ β [ H₁ $₀ X ]) ∘ α [ G₁ $₀ H₁ $₀ X ] ≈⟨ V.assoc ⟩∘⟨refl ⟩∘⟨refl ⟩ (F₂ $₁ G₂ $₁ γ [ X ] ∘ F₂ $₁ β [ H₁ $₀ X ]) ∘ α [ G₁ $₀ H₁ $₀ X ] ≈˘⟨ UF.homomorphism F₂ ⟩∘⟨refl ⟩ F₂ $₁ (G₂ $₁ γ [ X ] C.∘ β [ H₁ $₀ X ]) ∘ α [ G₁ $₀ H₁ $₀ X ] ≈˘⟨ identityʳ ⟩ (F₂ $₁ (G₂ $₁ γ [ X ] C.∘ β [ H₁ $₀ X ]) ∘ α [ G₁ $₀ H₁ $₀ X ]) ∘ D.id ∎ } ; iso = λ{ ((F , G) , H) → iso (NI.associator {F = F} {G} {H}) } } ; unitˡ = λ {A B} → let module A = Underlying A module B = Underlying B open UnderlyingReasoning B in niHelper record { η = λ _ → from NI.unitorˡ ; η⁻¹ = λ _ → to NI.unitorˡ ; commute = λ { {_ , F} {_ , G} (_ , α) {X} → begin B.id ∘ (V.id V.∘ α [ X ]) ∘ B.id ≈⟨ identityˡ ⟩ (V.id V.∘ α [ X ]) ∘ B.id ≈⟨ V.identityˡ ⟩∘⟨refl ⟩ α [ X ] ∘ B.id ∎ } ; iso = λ _ → iso NI.unitorˡ } ; unitʳ = λ {A B} → let module A = Underlying A module B = Underlying B open UnderlyingReasoning B in niHelper record { η = λ _ → from NI.unitorʳ ; η⁻¹ = λ _ → to NI.unitorʳ ; commute = λ{ {_} {G , _} (α , _) {X} → begin B.id ∘ G $₁ A.id ∘ α [ X ] ≈⟨ identityˡ ⟩ G $₁ A.id ∘ α [ X ] ≈⟨ UF.identity G ⟩∘⟨refl ⟩ B.id ∘ α [ X ] ≈⟨ identityˡ ○ ⟺ identityʳ ⟩ α [ X ] ∘ B.id ∎ } ; iso = λ _ → iso NI.unitorʳ } } ; triangle = λ {_ B C _ G} → let module B = Underlying B module C = Underlying C open UnderlyingReasoning C in begin (G $₁ B.id ∘ C.id) ∘ C.id ≈⟨ identityʳ ⟩ G $₁ B.id ∘ C.id ∎ ; pentagon = λ {_ B _ D E _ G H I} → let module B = Category B module D = Category D module E = Category E open UnderlyingReasoning E in begin (I $₁ D.id ∘ E.id) ∘ E.id ∘ (I ∘F H ∘F G) $₁ B.id ∘ E.id ≈⟨ identityʳ ⟩∘⟨ (identityˡ ○ identityʳ) ⟩ I $₁ D.id ∘ (I ∘F H ∘F G) $₁ B.id ≈⟨ UF.identity I ⟩∘⟨ UF.identity (I ∘F H ∘F G) ⟩ E.id ∘ E.id ∎ }
{ "alphanum_fraction": 0.5268207588, "avg_line_length": 36.688, "ext": "agda", "hexsha": "ea59b0a30a4098382cc887de305b20dc4f36093b", "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/Bicategory/Instance/EnrichedCats.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/Bicategory/Instance/EnrichedCats.agda", "max_line_length": 80, "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/Bicategory/Instance/EnrichedCats.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1679, "size": 4586 }
{-# 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; typeOf) 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) open import Cubical.HITs.PropositionalTruncation.Base -- ∣_∣ open import Utils open import MoreLogic.Reasoning open import MoreLogic.Definitions renaming ( _ᵗ⇒_ to infixr 0 _ᵗ⇒_ ; ∀ᵖ[∶]-syntax to infix -4 ∀ᵖ[∶]-syntax ; ∀ᵖ〚∶〛-syntax to infix -4 ∀ᵖ〚∶〛-syntax ; ∀ᵖ!〚∶〛-syntax to infix -4 ∀ᵖ!〚∶〛-syntax ; ∀〚∶〛-syntax to infix -4 ∀〚∶〛-syntax ; Σᵖ[]-syntax to infix -4 Σᵖ[]-syntax ; Σᵖ[∶]-syntax to infix -4 Σᵖ[∶]-syntax ) hiding (≡ˢ-syntax) open import MoreLogic.Properties open import MorePropAlgebra.Definitions hiding (_≤''_) open import MorePropAlgebra.Consequences open import MorePropAlgebra.Bundles module MorePropAlgebra.Booij2020 where module Chapter4 {ℓ ℓ'} (assumptions : AlmostPartiallyOrderedField {ℓ} {ℓ'}) where open import MorePropAlgebra.Properties.AlmostPartiallyOrderedField assumptions open AlmostPartiallyOrderedField assumptions renaming (Carrier to F; _-_ to _-_) -- atlernative to module telescope Item-1 = ∀[ x ] ∀[ y ] x ≤ y ⇔ ¬(y < x) -- (definition of _≤_) Item-2 = ∀[ x ] ∀[ y ] x # y ⇔ [ <-asym x y ] (x < y) ⊎ᵖ (y < x) -- (definition of _#_) Item-3 = ∀[ x ] ∀[ y ] ∀[ z ] x ≤ y ⇔ x + z ≤ y + z -- +-creates-≤ Item-4 = ∀[ x ] ∀[ y ] ∀[ z ] x < y ⇔ x + z < y + z -- +-creates-< Item-5 = ∀[ x ] ∀[ y ] 0f < x + y ⇒ (0f < x) ⊔ (0f < y) -- 0<-reflects-+ Item-6 = ∀[ x ] ∀[ y ] ∀[ z ] x < y ⇒ y ≤ z ⇒ x < z -- <-≤-trans Item-7 = ∀[ x ] ∀[ y ] ∀[ z ] x ≤ y ⇒ y < z ⇒ x < z -- ≤-<-trans Item-8 = ∀[ x ] ∀[ y ] ∀[ z ] x ≤ y ⇒ 0f ≤ z ⇒ x · z ≤ y · z -- ·-preserves-≤ Item-9 = ∀[ x ] ∀[ y ] ∀[ z ] 0f < z ⇒ (x < y ⇔ x · z < y · z) -- ·-creates-< Item-10 = 0f < 1f -- 0<1 item-1 : ∀ x y → [ x ≤ y ⇔ ¬(y < x) ]; _ = [ Item-1 ] ∋ item-1 item-2 : ∀ x y → [ x # y ⇔ [ <-asym x y ] (x < y) ⊎ᵖ (y < x) ]; _ = [ Item-2 ] ∋ item-2 item-6 : ∀ x y z → [ x < y ⇒ y ≤ z ⇒ x < z ]; _ : [ Item-6 ]; _ = item-6 item-7 : ∀ x y z → [ x ≤ y ⇒ y < z ⇒ x < z ]; _ : [ Item-7 ]; _ = item-7 -- 1. x ≤ y ⇔ ¬(y < x), item-1 _ _ .fst x≤y = x≤y -- holds definitionally item-1 _ _ .snd x≤y = x≤y -- 2. x # y ⇔ (x < y) ∨ (y < x) item-2 _ _ .fst x#y = x#y -- holds definitionally item-2 _ _ .snd [x<y]⊎[y<x] = [x<y]⊎[y<x] item-6 = <-≤-trans item-7 = ≤-<-trans module +-<-ext+·-preserves-<⇒ (+-<-ext : [ is-+-<-Extensional _+_ _<_ ]) (·-preserves-< : [ operation _·_ preserves _<_ when (λ z → 0f < z) ]) where abstract +-reflects-< : ∀ x y z → [ x + z < y + z ⇒ x < y ] +-preserves-< : ∀ x y z → [ x < y ⇒ x + z < y + z ] +-creates-< : ∀ x y z → [ x < y ⇔ x + z < y + z ]; _ : [ Item-4 ]; _ = +-creates-< +-creates-≤ : ∀ x y z → [ x ≤ y ⇔ x + z ≤ y + z ]; _ : [ Item-3 ]; _ = +-creates-≤ ·-reflects-< : ∀ x y z → [ 0f < z ⇒ (x · z < y · z ⇒ x < y ) ] ·-creates-< : ∀ x y z → [ 0f < z ⇒ ( x < y ⇔ x · z < y · z) ]; _ : [ Item-9 ]; _ = ·-creates-< ·-preserves-≤ : ∀ x y z → [ x ≤ y ⇒ 0f ≤ z ⇒ x · z ≤ y · z ]; _ : [ Item-8 ]; _ = ·-preserves-≤ 0<-reflects-+ : ∀ x y → [ 0f < x + y ⇒ (0f < x) ⊔ (0f < y) ]; _ : [ Item-5 ]; _ = 0<-reflects-+ ⁻¹-preserves-sign : ∀ z z⁻¹ → [ 0f < z ] → z · z⁻¹ ≡ 1f → [ 0f < z⁻¹ ] is-0<1 : [ 0f < 1f ] ; _ : [ Item-10 ]; _ = is-0<1 item-3 : [ Item-3 ] item-4 : [ Item-4 ] item-5 : [ Item-5 ] item-8 : [ Item-8 ] item-9 : [ Item-9 ] item-10 : [ Item-10 ] -- NOTE: just a plain copy of the previous proof +-preserves-< a b x = snd ( a < b ⇒ᵖ⟨ transport (λ i → [ sym (fst (+-identity a)) i < sym (fst (+-identity b)) i ]) ⟩ a + 0f < b + 0f ⇒ᵖ⟨ transport (λ i → [ a + sym (+-rinv x) i < b + sym (+-rinv x) i ]) ⟩ a + (x - x) < b + (x - x) ⇒ᵖ⟨ transport (λ i → [ +-assoc a x (- x) i < +-assoc b x (- x) i ]) ⟩ (a + x) - x < (b + x) - x ⇒ᵖ⟨ +-<-ext (a + x) (- x) (b + x) (- x) ⟩ (a + x < b + x) ⊔ (- x < - x) ⇒ᵖ⟨ (λ q → case q as (a + x < b + x) ⊔ (- x < - x) ⇒ a + x < b + x of λ { (inl a+x<b+x) → a+x<b+x -- somehow ⊥-elim needs a hint in the next line ; (inr -x<-x ) → ⊥-elim {A = λ _ → [ a + x < b + x ]} (<-irrefl (- x) -x<-x) }) ⟩ a + x < b + x ◼ᵖ) +-reflects-< x y z = snd ( x + z < y + z ⇒ᵖ⟨ +-preserves-< _ _ (- z) ⟩ (x + z) - z < (y + z) - z ⇒ᵖ⟨ transport (λ i → [ +-assoc x z (- z) (~ i) < +-assoc y z (- z) (~ i) ]) ⟩ x + (z - z) < y + (z - z) ⇒ᵖ⟨ transport (λ i → [ x + +-rinv z i < y + +-rinv z i ]) ⟩ x + 0f < y + 0f ⇒ᵖ⟨ transport (λ i → [ fst (+-identity x) i < fst (+-identity y) i ]) ⟩ x < y ◼ᵖ) -- 3. x ≤ y ⇔ x + z ≤ y + z, +-creates-≤ x y z .fst = snd ( -- unfold the definition x ≤ y ⇒ᵖ⟨ (λ z → z) ⟩ (y < x ⇒ ⊥) ⇒ᵖ⟨ (λ f → f ∘ (+-reflects-< y x z) ) ⟩ (y + z < x + z ⇒ ⊥) ⇒ᵖ⟨ (λ z → z) ⟩ x + z ≤ y + z ◼ᵖ) -- refold the definition +-creates-≤ x y z .snd = snd ( x + z ≤ y + z ⇒ᵖ⟨ (λ z → z) ⟩ -- unfold the definition (y + z < x + z ⇒ ⊥) ⇒ᵖ⟨ (λ f p → f (+-preserves-< y x z p)) ⟩ -- just a variant of the above (y < x ⇒ ⊥) ⇒ᵖ⟨ (λ z → z) ⟩ -- refold the definition x ≤ y ◼ᵖ) item-3 = +-creates-≤ -- 4. x < y ⇔ x + z < y + z, +-creates-< x y z .fst = +-preserves-< x y z +-creates-< x y z .snd = +-reflects-< x y z item-4 = +-creates-< -- 5. 0 < x + y ⇒ 0 < x ∨ 0 < y, 0<-reflects-+ x y = snd ( (0f < x + y) ⇒ᵖ⟨ transport (λ i → [ fst (+-identity 0f) (~ i) < x + y ]) ⟩ (0f + 0f < x + y) ⇒ᵖ⟨ +-<-ext 0f 0f x y ⟩ (0f < x) ⊔ (0f < y) ◼ᵖ) item-5 = 0<-reflects-+ -- -- 6. x < y ≤ z ⇒ x < z, -- item-6 x y z x<y y≤z = snd ( -- x < y ⇒ᵖ⟨ +-preserves-< _ _ _ ⟩ -- x + z < y + z ⇒ᵖ⟨ pathTo⇒ (λ i → x + z < +-comm y z i) ⟩ -- x + z < z + y ⇒ᵖ⟨ +-<-ext x z z y ⟩ -- (x < z) ⊔ (z < y) ⇒ᵖ⟨ (λ q → case q as (x < z) ⊔ (z < y) ⇒ (x < z) of λ -- { (inl x<z) → x<z -- ; (inr z<y) → ⊥-elim (y≤z z<y) -- }) ⟩ -- x < z ◼ᵖ) x<y -- -- -- 7. x ≤ y < z ⇒ x < z, -- item-7 x y z x≤y = snd ( -- very similar to the previous one -- y < z ⇒ᵖ⟨ +-preserves-< y z x ⟩ -- y + x < z + x ⇒ᵖ⟨ pathTo⇒ (λ i → +-comm y x i < z + x) ⟩ -- x + y < z + x ⇒ᵖ⟨ +-<-ext x y z x ⟩ -- (x < z) ⊔ (y < x) ⇒ᵖ⟨ (λ q → case q as (x < z) ⊔ (y < x) ⇒ (x < z) of λ -- { (inl x<z) → x<z -- ; (inr y<x) → ⊥-elim (x≤y y<x) -- }) ⟩ -- x < z ◼ᵖ) -- 10. 0f < 1f item-10 = is-0<1 ⁻¹-preserves-sign z z⁻¹ 0<z z·z⁻¹≡1 with snd (·-inv#0 z z⁻¹ z·z⁻¹≡1) ... | inl z⁻¹<0 = snd ( z⁻¹ < 0f ⇒ᵖ⟨ ·-preserves-< _ _ z 0<z ⟩ z⁻¹ · z < 0f · z ⇒ᵖ⟨ transport (λ i → [ (·-comm _ _ ∙ z·z⁻¹≡1) i < RingTheory'.0-leftNullifies z i ]) ⟩ 1f < 0f ⇒ᵖ⟨ <-trans _ _ _ item-10 ⟩ 0f < 0f ⇒ᵖ⟨ <-irrefl _ ⟩ ⊥ ⇒ᵖ⟨ ⊥-elim ⟩ 0f < z⁻¹ ◼ᵖ) z⁻¹<0 ... | inr 0<z⁻¹ = 0<z⁻¹ -- 8. x ≤ y ∧ 0 ≤ z ⇒ x z ≤ y z, -- For item 8, suppose x ≤ y and 0 ≤ z and yz < xz. ·-preserves-≤ x y z x≤y 0≤z y·z<x·z = let -- Then 0 < z (x − y) by (†), i = ( y · z < x · z ⇒ᵖ⟨ pathTo⇒ (λ i → ·-comm y z i < ·-comm x z i) ⟩ z · y < z · x ⇒ᵖ⟨ +-preserves-< _ _ _ ⟩ (z · y) - (z · y) < (z · x) - (z · y ) ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ (+-rinv (z · y)) ( λ i → (z · x) + sym (RingTheory'.-commutesWithRight-· z y) i )) ⟩ 0f < (z · x) + (z · (- y)) ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ refl (sym (fst (is-dist z x (- y))))) ⟩ -- [XX] 0f < z · (x - y) ◼ᵖ) .snd y·z<x·z instance z·[x-y]#0 = [ z · (x - y) # 0f ] ∋ inr i -- and so, being apart from 0, z (x − y) has a multiplicative inverse w. w = (z · (x - y)) ⁻¹ ii : 1f ≡ (z · (x - y)) · w ii = sym (·-rinv _ _) -- Hence z itself has a multiplicative inverse w (x − y), iii : 1f ≡ z · ((x - y) · w) iii = transport (λ i → 1f ≡ ·-assoc z (x - y) w (~ i)) ii instance z#0f = [ z # 0f ] ∋ fst (·-inv#0 _ _ (sym iii)) -- and so 0 < z ∨ z < 0, where the latter case contradicts the assumption 0 ≤ z, so that we have 0 < z. instance _ = [ 0f < z ] ∋ case z#0f of λ where (inl z<0) → ⊥-elim (0≤z z<0) (inr 0<z) → 0<z -- Now w (x − y) has multiplicative inverse z, so it is apart from 0, iv : [ (x - y) · w # 0f ] iv = snd (·-inv#0 _ _ (sym iii)) -- that is (0 < w (x − y)) ∨ (w (x − y) < 0). in case iv of λ where -- By (∗), from 0 < w (x − y) and yz < xz we get yzw (x − y) < xzw (x − y), so y < x, contradicting our assumption that x ≤ y. (inr 0<[x-y]·w) → ( y · z < x · z ⇒ᵖ⟨ ·-preserves-< _ _ _ 0<[x-y]·w ⟩ (y · z) · ((x - y) · w) < (x · z) · ((x - y) · w) ⇒ᵖ⟨ pathTo⇒ (λ i → (·-assoc y z ((x - y) · w)) (~ i) < (·-assoc x z ((x - y) · w)) (~ i)) ⟩ y · (z · ((x - y) · w)) < x · (z · ((x - y) · w)) ⇒ᵖ⟨ pathTo⇒ (λ i → y · (iii (~ i)) < x · (iii (~ i))) ⟩ y · 1f < x · 1f ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ (fst (·-identity y)) (fst (·-identity x))) ⟩ y < x ⇒ᵖ⟨ x≤y ⟩ ⊥ ◼ᵖ) .snd y·z<x·z -- In the latter case, from (∗) we get zw (x − y) < 0, i.e. -- 1 < 0 which contradicts item 10, so that we have 0 < w (x − y). (inl p) → ( (x - y) · w < 0f ⇒ᵖ⟨ ·-preserves-< _ _ _ it ⟩ ((x - y) · w) · z < 0f · z ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ (·-comm _ _) (RingTheory'.0-leftNullifies z)) ⟩ z · ((x - y) · w) < 0f ⇒ᵖ⟨ pathTo⇒ (λ i → iii (~ i) < 0f) ⟩ 1f < 0f ⇒ᵖ⟨ <-trans _ _ _ item-10 ⟩ 0f < 0f ⇒ᵖ⟨ <-irrefl _ ⟩ ⊥ ◼ᵖ) .snd p item-8 = ·-preserves-≤ -- 9. 0 < z ⇒ (x < y ⇔ x z < y z), ·-creates-< x y z 0<z .fst = ·-preserves-< x y z 0<z -- For the other direction of item 9, assume 0 < z and xz < yz, ·-creates-< x y z 0<z .snd x·z<y·z = let instance _ = ( x · z < y · z ⇒ᵖ⟨ +-preserves-< _ _ _ ⟩ (x · z) - (x · z) < (y · z) - (x · z) ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ (+-rinv (x · z)) refl) ⟩ 0f < (y · z) - (x · z) ◼ᵖ) .snd x·z<y·z _ = [ (y · z) - (x · z) # 0f ] ∋ inr it -- so that yz − xz has a multiplicative inverse w, w = ((y · z) - (x · z)) ⁻¹ o = ( (y · z) - ( x · z) ≡⟨ ( λ i → (y · z) + (RingTheory'.-commutesWithLeft-· x z) (~ i)) ⟩ (y · z) + ((- x) · z) ≡⟨ sym (snd (is-dist y (- x) z)) ⟩ (y - x) · z ∎) instance _ = [ (y - x) · z # 0f ] ∋ pathTo⇒ (λ i → o i # 0f) it -- and so z itself has multiplicative inverse w (y − x). instance _ = ( x · z < y · z ⇒ᵖ⟨ +-preserves-< _ _ _ ⟩ (x · z) - (x · z) < (y · z) - (x · z) ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ (+-rinv (x · z)) refl) ⟩ 0f < (y · z) - (x · z) ◼ᵖ) .snd x·z<y·z _ = [ (y · z) - (x · z) # 0f ] ∋ inr it 1≡z·[w·[y-x]] = ( 1f ≡⟨ (λ i → ·-linv ((y · z) - (x · z)) it (~ i)) ⟩ w · ((y · z) - (x · z)) ≡⟨ (λ i → w · o i) ⟩ w · ((y - x) · z) ≡⟨ (λ i → w · ·-comm (y - x) z i ) ⟩ w · (z · (y - x)) ≡⟨ (λ i → ·-assoc w z (y - x) i) ⟩ (w · z) · (y - x) ≡⟨ (λ i → ·-comm w z i · (y - x)) ⟩ (z · w) · (y - x) ≡⟨ (λ i → ·-assoc z w (y - x) (~ i)) ⟩ z · (w · (y - x)) ∎) 1≡[w·[y-x]]·z : 1f ≡ (w · (y - x)) · z 1≡[w·[y-x]]·z = transport (λ i → 1f ≡ ·-comm z (w · (y - x)) i) 1≡z·[w·[y-x]] -- Then since 0 < z and xz < yz, by (∗), we get xzw (y − x) < yzw (y − x), and hence x < y. instance _ = [ z # 0f ] ∋ inr 0<z z⁻¹ = w · (y - x) z⁻¹≡w·[y-x] : z ⁻¹ ≡ (w · (y - x)) z⁻¹≡w·[y-x] = sym ((·-linv-unique (w · (y - x)) z (sym 1≡[w·[y-x]]·z)) it) instance _ = 0<z 0<z⁻¹ : [ 0f < z ⁻¹ ] 0<z⁻¹ = ⁻¹-preserves-sign z (z ⁻¹) it (·-rinv z it) instance _ = [ 0f < w · (y - x) ] ∋ pathTo⇒ (λ i → 0f < z⁻¹≡w·[y-x] i) 0<z⁻¹ in ( x · z < y · z ⇒ᵖ⟨ ·-preserves-< _ _ z⁻¹ it ⟩ (x · z) · z⁻¹ < (y · z) · z⁻¹ ⇒ᵖ⟨ pathTo⇒ (λ i → ·-assoc x z z⁻¹ (~ i) < ·-assoc y z z⁻¹ (~ i)) ⟩ x · (z · z⁻¹) < y · (z · z⁻¹) ⇒ᵖ⟨ pathTo⇒ (λ i → x · 1≡z·[w·[y-x]] (~ i) < y · 1≡z·[w·[y-x]] (~ i)) ⟩ x · 1f < y · 1f ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ (fst (·-identity x)) (fst (·-identity y))) ⟩ x < y ◼ᵖ) .snd x·z<y·z ·-reflects-< x y z 0<z = ·-creates-< x y z 0<z .snd item-9 = ·-creates-< -- 10. 0 < 1. is-0<1 with ·-inv#0 _ _ (·-identity 1f .fst) .fst -- For item 10, since 1 has multiplicative inverse 1, it is apart from 0, hence 0 < 1 ∨ 1 < 0. ... | inl 1<0 = snd ( -- If 1 < 0 then by item 4 we have 0 < −1 and so by (∗) we get 0 < (−1) · (−1), that is, 0 < 1, so by transitivity 1 < 1, contradicting irreflexivity of <. 1f < 0f ⇒ᵖ⟨ +-preserves-< 1f 0f (- 1f) ⟩ 1f - 1f < 0f - 1f ⇒ᵖ⟨ transport (λ i → [ +-rinv 1f i < snd (+-identity (- 1f)) i ]) ⟩ 0f < - 1f ⇒ᵖ⟨ ( λ 0<-1 → ·-preserves-< 0f (- 1f) (- 1f) 0<-1 0<-1) ⟩ 0f · (- 1f) < (- 1f) · (- 1f) ⇒ᵖ⟨ pathTo⇒ (cong₂ _<_ (RingTheory'.0-leftNullifies (- 1f)) refl) ⟩ 0f < (- 1f) · (- 1f) ⇒ᵖ⟨ transport (λ i → [ 0f < RingTheory'.-commutesWithRight-· (- 1f) (1f) i ]) ⟩ 0f < -((- 1f) · 1f )⇒ᵖ⟨ transport (λ i → [ 0f < RingTheory'.-commutesWithLeft-· (- 1f) 1f (~ i) ]) ⟩ 0f < (-(- 1f))· 1f ⇒ᵖ⟨ transport (λ i → [ 0f < (Group'Properties.-involutive 1f i · 1f) ]) ⟩ 0f < 1f · 1f ⇒ᵖ⟨ transport (λ i → [ 0f < fst (·-identity 1f) i ]) ⟩ 0f < 1f ⇒ᵖ⟨ <-trans _ _ _ 1<0 ⟩ 1f < 1f ⇒ᵖ⟨ <-irrefl 1f ⟩ ⊥ ⇒ᵖ⟨ ⊥-elim ⟩ 0f < 1f ◼ᵖ) 1<0 ... | inr 0<1 = 0<1 -- Conversely, assume the 10 listed items—in particular, items 4, 5 and 9. module item459⇒ -- 4. 5. 9. ⇒ 6. (item-4 : [ Item-4 ]) -- ∀[ x ] ∀[ y ] ∀[ z ] x < y ⇔ x + z < y + z (item-5 : [ Item-5 ]) -- ∀[ x ] ∀[ y ] 0f < x + y ⇒ (0f < x) ⊔ (0f < y) (item-9 : [ Item-9 ]) -- ∀[ x ] ∀[ y ] ∀[ z ] 0f < z ⇒ (x < y ⇔ x · z < y · z) where abstract +-<-ext : ∀ x y z w → [ (x + y) < (z + w) ⇒ (x < z) ⊔ (y < w) ]; _ : [ is-+-<-Extensional _+_ _<_ ]; _ = +-<-ext ·-preserves-< : ∀ x y z → [ 0f < z ⇒ x < y ⇒ (x · z) < (y · z) ]; _ : [ operation _·_ preserves _<_ when (λ z → 0f < z) ]; _ = ·-preserves-< private item-4' : ∀ x y → [ 0f < x - y ⇒ y < x ] lemma : ∀ x y z w → (z + w) + ((- x) + (- y)) ≡ (z - x) + (w - y) item-4' x y = snd ( 0f < x - y ⇒ᵖ⟨ fst (item-4 0f (x + (- y)) y) ⟩ 0f + y < (x - y) + y ⇒ᵖ⟨ transport (λ i → [ snd (+-identity y) i < sym (+-assoc x (- y) y) i ]) ⟩ y < x + (- y + y) ⇒ᵖ⟨ transport (λ i → [ y < x + snd (+-inv y) i ]) ⟩ y < x + 0f ⇒ᵖ⟨ transport (λ i → [ y < fst (+-identity x) i ]) ⟩ y < x ◼ᵖ) lemma x y z w = ( -- NOTE: there has to be a shorter way to to this kind of calculations ... -- also I got not much introspection while creating the paths (z + w) + ((- x) + (- y)) ≡⟨ ( λ i → +-assoc z w ((- x) + (- y)) (~ i)) ⟩ (z + ( w + ((- x) + (- y)))) ≡⟨ ( λ i → z + (+-assoc w (- x) (- y) i)) ⟩ (z + ((w + (- x)) + (- y))) ≡⟨ ( λ i → z + ((+-comm w (- x) i) + (- y)) ) ⟩ (z + (((- x) + w) + (- y))) ≡⟨ ( λ i → z + (+-assoc (- x) w (- y) (~ i))) ⟩ (z + (( - x) + (w - y))) ≡⟨ ( λ i → +-assoc z (- x) (w - y) i ) ⟩ (z - x) + (w - y) ∎) -- 6. (†) -- In order to show (†), suppose x + y < z + w. -- So, by item 4, we get (x + y) − (x + y) < (z + w) − (x + y), that is, 0 < (z − x) + (w − y). -- By item 5, (0 < z − x) ∨ (0 < w − y), and so by item 4 in either case, we get x < z ∨ y < w. +-<-ext x y z w = snd ( (x + y) < (z + w) ⇒ᵖ⟨ fst (item-4 (x + y) (z + w) (- (x + y))) ⟩ (x + y) - (x + y) < (z + w) - (x + y) ⇒ᵖ⟨ transport (λ i → [ +-rinv (x + y) i < (z + w) + (-dist x y) i ]) ⟩ 0f < (z + w) + ((- x) + (- y)) ⇒ᵖ⟨ transport (λ i → [ 0f < lemma x y z w i ]) ⟩ 0f < (z - x) + (w - y) ⇒ᵖ⟨ item-5 (z - x) (w - y) ⟩ (0f < z - x) ⊔ (0f < w - y) ⇒ᵖ⟨ (λ q → case q as (0f < z - x) ⊔ (0f < w - y) ⇒ ((x < z) ⊔ (y < w)) of λ { (inl p) → inlᵖ (item-4' z x p) ; (inr p) → inrᵖ (item-4' w y p) }) ⟩ ( x < z ) ⊔ ( y < w ) ◼ᵖ) -- 6. (∗) ·-preserves-< x y z 0<z = item-9 x y z 0<z .fst
{ "alphanum_fraction": 0.3428768201, "avg_line_length": 58.5821325648, "ext": "agda", "hexsha": "8621a29377a52d438d33a352f62106416fec5ea9", "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/Booij2020.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/Booij2020.agda", "max_line_length": 163, "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/Booij2020.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": 8660, "size": 20328 }
import Lvl open import Type module Type.Singleton.Proofs {ℓ : Lvl.Level} {X : Type{ℓ}} where open import Functional open import Function.Domains open import Logic.Predicate open import Relator.Equals open import Relator.Equals.Proofs open import Type.Properties.Empty open import Type.Singleton open import Type.Properties.Singleton open import Structure.Type.Identity instance -- There is always a construction of a singleton type Singleton-existence : ∀{x : X} → Singleton(x) Singleton-existence {x} = [∃]-intro(x) ⦃ [≡]-intro ⦄ instance -- There is an unique construction of a singleton type Singleton-is-unit : ∀{x : X} → IsUnit(Singleton(x)) Singleton-is-unit {x} = intro (Singleton-existence{x}) (g{x}) where A : ∀{y x : X} → (y ≡ x) → Type{ℓ} A {y}{x} (xy-proof) = ([∃]-intro y ⦃ xy-proof ⦄ ≡ Singleton-existence{x}) f : ∀{x : X} → A{x}{x}([≡]-intro {_}{_} {x}) f{x} = [≡]-intro {_}{_} {Singleton-existence{x}} Φ : ∀{y x : X}{xy-proof : (y ≡ x)} → ([∃]-intro y ⦃ xy-proof ⦄ ≡ Singleton-existence{x}) Φ {y}{x}{xy-proof} = idElim(_≡_ {T = X}) (A)(f) {y}{x}(xy-proof) g : ∀{x : X}{σ : Singleton(x)} → (σ ≡ Singleton-existence{x}) g{x}{[∃]-intro y ⦃ proof ⦄} = Φ{y}{x}{proof}
{ "alphanum_fraction": 0.6251012146, "avg_line_length": 34.3055555556, "ext": "agda", "hexsha": "dbfe41fdc6d24c87cefefff4b6f2fd8dc65ff073", "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": "Type/Singleton/Proofs.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": "Type/Singleton/Proofs.agda", "max_line_length": 92, "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": "Type/Singleton/Proofs.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": 426, "size": 1235 }
module _ {a} {A : Set a} where open import Agda.Builtin.Equality open import Agda.Builtin.List infix 4 _⊆_ postulate _⊆_ : (xs ys : List A) → Set a ⊆-trans : ∀{xs ys zs} → xs ⊆ ys → ys ⊆ zs → xs ⊆ zs private variable xs ys zs : List A σ τ : ys ⊆ zs x y : A x≈y : x ≡ y lemma : ∀ us (ρ : us ⊆ zs) (τ' : x ∷ xs ⊆ us) (σ' : ys ⊆ us) (τ'∘ρ≡τ : ⊆-trans τ' ρ ≡ τ) (σ'∘ρ≡σ : ⊆-trans σ' ρ ≡ σ) → us ⊆ us lemma {τ = τ} {σ = σ} us ρ τ' σ' τ'∘ρ≡τ σ'∘ρ≡σ = lem {τ = τ} {σ} us ρ τ' σ' τ'∘ρ≡τ σ'∘ρ≡σ where lem : ∀ {ys zs} {τ : (x ∷ xs) ⊆ zs} {σ : ys ⊆ zs} us (ρ : us ⊆ zs) (τ' : x ∷ xs ⊆ us) (σ' : ys ⊆ us) (τ'∘ρ≡τ : ⊆-trans τ' ρ ≡ τ) (σ'∘ρ≡σ : ⊆-trans σ' ρ ≡ σ) → {!!} lem = {!!}
{ "alphanum_fraction": 0.4162303665, "avg_line_length": 23.875, "ext": "agda", "hexsha": "42f5e917c99a9ad34c20d404b7f31e19370d52f3", "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/Issue3982.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/Issue3982.agda", "max_line_length": 60, "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/Issue3982.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": 401, "size": 764 }
module B where open import A B : Set B = A
{ "alphanum_fraction": 0.6444444444, "avg_line_length": 6.4285714286, "ext": "agda", "hexsha": "443bc53c6fc698ae203ba55a44c4e87d546b909a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/relocatable/originals/B.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/relocatable/originals/B.agda", "max_line_length": 14, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/relocatable/originals/B.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": 16, "size": 45 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Nondependent heterogeneous N-ary products ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.Nary.NonDependent where ------------------------------------------------------------------------ -- Concrete examples can be found in README.Nary. This file's comments -- are more focused on the implementation details and the motivations -- behind the design decisions. ------------------------------------------------------------------------ open import Level as L using (Level; _⊔_; Lift; 0ℓ) open import Agda.Builtin.Unit open import Data.Product as Prod import Data.Product.Properties as Prodₚ open import Data.Sum.Base using (_⊎_) open import Data.Nat.Base using (ℕ; zero; suc; pred) open import Data.Fin.Base using (Fin; zero; suc) open import Function open import Relation.Nullary open import Relation.Nullary.Product using (_×-dec_) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong₂) open import Function.Nary.NonDependent.Base -- Provided n Levels and a corresponding "vector" of `n` Sets, we can build a big -- right-nested product type packing a value for each one of these Sets. -- We have two distinct but equivalent definitions: -- the first which is always ⊤-terminated -- the other which has a special case for n = 1 because we want our `(un)curryₙ` -- functions to work for user-written functions and products and they rarely are -- ⊤-terminated. Product⊤ : ∀ n {ls} → Sets n ls → Set (⨆ n ls) Product⊤ zero as = ⊤ Product⊤ (suc n) (a , as) = a × Product⊤ n as Product : ∀ n {ls} → Sets n ls → Set (⨆ n ls) Product 0 _ = ⊤ Product 1 (a , _) = a Product (suc n) (a , as) = a × Product n as -- Pointwise lifting of a relation on products Allₙ : (∀ {a} {A : Set a} → Rel A a) → ∀ n {ls} {as : Sets n ls} (l r : Product n as) → Sets n ls Allₙ R 0 l r = _ Allₙ R 1 a b = R a b , _ Allₙ R (suc n@(suc _)) (a , l) (b , r) = R a b , Allₙ R n l r Equalₙ : ∀ n {ls} {as : Sets n ls} (l r : Product n as) → Sets n ls Equalₙ = Allₙ _≡_ ------------------------------------------------------------------------ -- Generic Programs -- Once we have these type definitions, we can write generic programs -- over them. They will typically be split into two or three definitions: -- 1. action on the vector of n levels (if any) -- 2. action on the corresponding vector of n Sets -- 3. actual program, typed thank to the function defined in step 2. ------------------------------------------------------------------------ -- see Relation.Binary.PropositionalEquality for congₙ and substₙ, two -- equality-related generic programs. ------------------------------------------------------------------------ -- equivalence of Product and Product⊤ toProduct : ∀ n {ls} {as : Sets n ls} → Product⊤ n as → Product n as toProduct 0 _ = _ toProduct 1 (v , _) = v toProduct (suc (suc n)) (v , vs) = v , toProduct _ vs toProduct⊤ : ∀ n {ls} {as : Sets n ls} → Product n as → Product⊤ n as toProduct⊤ 0 _ = _ toProduct⊤ 1 v = v , _ toProduct⊤ (suc (suc n)) (v , vs) = v , toProduct⊤ _ vs ------------------------------------------------------------------------ -- (un)curry -- We start by defining `curryₙ` and `uncurryₙ` converting back and forth -- between `A₁ → ⋯ → Aₙ → B` and `(A₁ × ⋯ × Aₙ) → B` by induction on `n`. curryₙ : ∀ n {ls} {as : Sets n ls} {r} {b : Set r} → (Product n as → b) → as ⇉ b curryₙ 0 f = f _ curryₙ 1 f = f curryₙ (suc n@(suc _)) f = curryₙ n ∘′ curry f uncurryₙ : ∀ n {ls} {as : Sets n ls} {r} {b : Set r} → as ⇉ b → (Product n as → b) uncurryₙ 0 f = const f uncurryₙ 1 f = f uncurryₙ (suc n@(suc _)) f = uncurry (uncurryₙ n ∘′ f) -- Variants for Product⊤ curry⊤ₙ : ∀ n {ls} {as : Sets n ls} {r} {b : Set r} → (Product⊤ n as → b) → as ⇉ b curry⊤ₙ zero f = f _ curry⊤ₙ (suc n) f = curry⊤ₙ n ∘′ curry f uncurry⊤ₙ : ∀ n {ls} {as : Sets n ls} {r} {b : Set r} → as ⇉ b → (Product⊤ n as → b) uncurry⊤ₙ zero f = const f uncurry⊤ₙ (suc n) f = uncurry (uncurry⊤ₙ n ∘′ f) ------------------------------------------------------------------------ -- decidability Product⊤-dec : ∀ n {ls} {as : Sets n ls} → Product⊤ n (Dec <$> as) → Dec (Product⊤ n as) Product⊤-dec zero _ = yes _ Product⊤-dec (suc n) (p? , ps?) = p? ×-dec Product⊤-dec n ps? Product-dec : ∀ n {ls} {as : Sets n ls} → Product n (Dec <$> as) → Dec (Product n as) Product-dec 0 _ = yes _ Product-dec 1 p? = p? Product-dec (suc n@(suc _)) (p? , ps?) = p? ×-dec Product-dec n ps? ------------------------------------------------------------------------ -- pointwise liftings toEqualₙ : ∀ n {ls} {as : Sets n ls} {l r : Product n as} → l ≡ r → Product n (Equalₙ n l r) toEqualₙ 0 eq = _ toEqualₙ 1 eq = eq toEqualₙ (suc n@(suc _)) eq = Prod.map₂ (toEqualₙ n) (Prodₚ.,-injective eq) fromEqualₙ : ∀ n {ls} {as : Sets n ls} {l r : Product n as} → Product n (Equalₙ n l r) → l ≡ r fromEqualₙ 0 eq = refl fromEqualₙ 1 eq = eq fromEqualₙ (suc n@(suc _)) eq = uncurry (cong₂ _,_) (Prod.map₂ (fromEqualₙ n) eq) ------------------------------------------------------------------------ -- projection of the k-th component -- To know at which Set level the k-th projection out of an n-ary product -- lives, we need to extract said level, by induction on k. Levelₙ : ∀ {n} → Levels n → Fin n → Level Levelₙ (l , _) zero = l Levelₙ (_ , ls) (suc k) = Levelₙ ls k -- Once we have the Sets used in the product, we can extract the one we -- are interested in, once more by induction on k. Projₙ : ∀ {n ls} → Sets n ls → ∀ k → Set (Levelₙ ls k) Projₙ (a , _) zero = a Projₙ (_ , as) (suc k) = Projₙ as k -- Finally, provided a Product of these sets, we can extract the k-th value. -- `projₙ` takes both `n` and `k` explicitly because we expect the user will -- be using a concrete `k` (potentially manufactured using `Data.Fin`'s `#_`) -- and it will not be possible to infer `n` from it. projₙ : ∀ n {ls} {as : Sets n ls} k → Product n as → Projₙ as k projₙ 1 zero v = v projₙ (suc n@(suc _)) zero (v , _) = v projₙ (suc n@(suc _)) (suc k) (_ , vs) = projₙ n k vs projₙ 1 (suc ()) v ------------------------------------------------------------------------ -- removal of the k-th component Levelₙ⁻ : ∀ {n} → Levels n → Fin n → Levels (pred n) Levelₙ⁻ (_ , ls) zero = ls Levelₙ⁻ {suc (suc _)} (l , ls) (suc k) = l , Levelₙ⁻ ls k Levelₙ⁻ {1} _ (suc ()) Removeₙ : ∀ {n ls} → Sets n ls → ∀ k → Sets (pred n) (Levelₙ⁻ ls k) Removeₙ (_ , as) zero = as Removeₙ {suc (suc _)} (a , as) (suc k) = a , Removeₙ as k Removeₙ {1} _ (suc ()) removeₙ : ∀ n {ls} {as : Sets n ls} k → Product n as → Product (pred n) (Removeₙ as k) removeₙ (suc zero) zero _ = _ removeₙ (suc (suc _)) zero (_ , vs) = vs removeₙ (suc (suc zero)) (suc k) (v , _) = v removeₙ (suc (suc (suc _))) (suc k) (v , vs) = v , removeₙ _ k vs removeₙ (suc zero) (suc ()) _ ------------------------------------------------------------------------ -- insertion of a k-th component Levelₙ⁺ : ∀ {n} → Levels n → Fin (suc n) → Level → Levels (suc n) Levelₙ⁺ ls zero l⁺ = l⁺ , ls Levelₙ⁺ {suc _} (l , ls) (suc k) l⁺ = l , Levelₙ⁺ ls k l⁺ Levelₙ⁺ {0} _ (suc ()) Insertₙ : ∀ {n ls l⁺} → Sets n ls → ∀ k (a⁺ : Set l⁺) → Sets (suc n) (Levelₙ⁺ ls k l⁺) Insertₙ as zero a⁺ = a⁺ , as Insertₙ {suc _} (a , as) (suc k) a⁺ = a , Insertₙ as k a⁺ Insertₙ {zero} _ (suc ()) _ insertₙ : ∀ n {ls l⁺} {as : Sets n ls} {a⁺ : Set l⁺} k (v⁺ : a⁺) → Product n as → Product (suc n) (Insertₙ as k a⁺) insertₙ 0 zero v⁺ vs = v⁺ insertₙ (suc n) zero v⁺ vs = v⁺ , vs insertₙ 1 (suc k) v⁺ vs = vs , insertₙ 0 k v⁺ _ insertₙ (suc (suc n)) (suc k) v⁺ (v , vs) = v , insertₙ _ k v⁺ vs insertₙ 0 (suc ()) _ _ ------------------------------------------------------------------------ -- update of a k-th component Levelₙᵘ : ∀ {n} → Levels n → Fin n → Level → Levels n Levelₙᵘ (_ , ls) zero lᵘ = lᵘ , ls Levelₙᵘ (l , ls) (suc k) lᵘ = l , Levelₙᵘ ls k lᵘ Updateₙ : ∀ {n ls lᵘ} (as : Sets n ls) k (aᵘ : Set lᵘ) → Sets n (Levelₙᵘ ls k lᵘ) Updateₙ (_ , as) zero aᵘ = aᵘ , as Updateₙ (a , as) (suc k) aᵘ = a , Updateₙ as k aᵘ updateₙ : ∀ n {ls lᵘ} {as : Sets n ls} k {aᵘ : _ → Set lᵘ} (f : ∀ v → aᵘ v) (vs : Product n as) → Product n (Updateₙ as k (aᵘ (projₙ n k vs))) updateₙ 1 zero f v = f v updateₙ (suc (suc _)) zero f (v , vs) = f v , vs updateₙ (suc (suc _)) (suc k) f (v , vs) = v , updateₙ _ k f vs updateₙ 1 (suc ()) _ _ updateₙ′ : ∀ n {ls lᵘ} {as : Sets n ls} k {aᵘ : Set lᵘ} (f : Projₙ as k → aᵘ) → Product n as → Product n (Updateₙ as k aᵘ) updateₙ′ n k = updateₙ n k
{ "alphanum_fraction": 0.5086114101, "avg_line_length": 39.5319148936, "ext": "agda", "hexsha": "55ba2ab16c5e419f2e692ff6363a38b350497932", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Product/Nary/NonDependent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Product/Nary/NonDependent.agda", "max_line_length": 88, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Product/Nary/NonDependent.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": 3232, "size": 9290 }
module Numeral.Finite.Category where open import Functional import Lvl open import Numeral.Finite open import Numeral.Natural open import Type open import Syntax.Function -- Equality category on the type of finite natural numbers. module _ where open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Relator.Equals.Category open import Structure.Category open import Structure.Category.Categories import Structure.Category.Functor as Category open import Structure.Function open import Structure.Function.Domain import Structure.Function.Names as Names open import Structure.Groupoid open import Structure.Groupoid.Groupoids import Structure.Groupoid.Functor as Groupoid 𝕟-identityTypeGroupoid : Groupoid((_≡_) on₂ 𝕟) 𝕟-identityTypeGroupoid = on₂-groupoid identityTypeGroupoid 𝕟 -- The type constructor `𝕟` is a functor. -- This means: -- • `map: ∀(a: ℕ)(b: ℕ). (a ≡ b) → (𝕟(a) ≡ 𝕟(b))` -- • `map(reflexivity(_≡_)) ≡ reflexivity(_≡_)` -- • `transitivity(_≡_) (map p) (map q) ≡ map(transitivity(_≡_) p q)` 𝕟-functor : Groupoid.Functor(identityTypeGroupoid{T = ℕ})(𝕟-identityTypeGroupoid) id 𝕟-functor = idTransportFunctor instance 𝕟-injectivity : Injective(𝕟) 𝕟-injectivity = intro proof where proof : Names.Injective(𝕟) proof {𝟎} {𝟎} [≡]-intro = [≡]-intro proof {𝐒 a} {𝐒 .a} [≡]-intro = [≡]-with(𝐒) (proof [≡]-intro) 𝕟-inverse-functor : Groupoid.Functor(𝕟-identityTypeGroupoid)(identityTypeGroupoid{T = ℕ}) id Groupoid.Functor.map 𝕟-inverse-functor = injective(𝕟) Function.congruence (Groupoid.Functor.map-function 𝕟-inverse-functor) [≡]-intro = [≡]-intro Groupoid.Functor.op-preserving 𝕟-inverse-functor {x} {x} {x} {[≡]-intro} {[≡]-intro} = proof{x} where proof : ∀{x} → Groupoid.Functor.map 𝕟-inverse-functor (Groupoid._∘_ 𝕟-identityTypeGroupoid {x} [≡]-intro [≡]-intro) ≡ Groupoid._∘_ identityTypeGroupoid (Groupoid.Functor.map 𝕟-inverse-functor [≡]-intro) (Groupoid.Functor.map 𝕟-inverse-functor [≡]-intro) proof {𝟎} = [≡]-intro proof {𝐒 x} rewrite proof{x} rewrite Groupoid.Functor.id-preserving 𝕟-inverse-functor {x} = [≡]-intro Groupoid.Functor.id-preserving 𝕟-inverse-functor {x} = proof{x} where proof : ∀{x} → (injective(𝕟) (Groupoid.id 𝕟-identityTypeGroupoid {x}) ≡ Category.id identityTypeCategory) proof {𝟎} = [≡]-intro proof {𝐒 x} rewrite proof{x} = [≡]-intro Groupoid.Functor.inv-preserving 𝕟-inverse-functor {x} {x} {[≡]-intro} = proof where proof : ∀{x} → Groupoid.Functor.map 𝕟-inverse-functor (Groupoid.inv 𝕟-identityTypeGroupoid {x} [≡]-intro) ≡ Groupoid.inv identityTypeGroupoid (Groupoid.Functor.map 𝕟-inverse-functor [≡]-intro) proof {𝟎} = [≡]-intro proof {𝐒 x} rewrite proof{x} rewrite Groupoid.Functor.id-preserving 𝕟-inverse-functor {x} = [≡]-intro open import Function.Equals open import Numeral.Finite.Bound open import Numeral.Natural.Relation.Order.Category open import Numeral.Natural.Relation.Order.Proofs open import Numeral.Natural.Relation.Order open import Type.Category.ExtensionalFunctionsCategory open import Structure.Relator.Properties -- A functor for boundary changing of finite numeral types (𝕟). bound-functor : Category.Functor [≤]-category (on₂-category typeExtensionalFnCategory 𝕟) id Category.Functor.map bound-functor = bound-[≤] Function.congruence (Category.Functor.map-function bound-functor) [≡]-intro = reflexivity(_⊜_) Category.Functor.op-preserving bound-functor {x}{y}{z} {p}{q} = proof{x}{y}{z} {p}{q} where proof : ∀{x y z}{p : (y ≤ z)}{q : (x ≤ y)} → (bound-[≤] (transitivity(_≤_) q p) ⊜ (bound-[≤] p) ∘ (bound-[≤] q)) _⊜_.proof (proof {𝐒 x} {𝐒 y} {𝐒 z} {succ _} {succ _}) {𝟎} = [≡]-intro _⊜_.proof (proof {𝐒 x} {𝐒 y} {𝐒 z} {succ _} {succ _}) {𝐒 n} = congruence₁(𝐒) (_⊜_.proof (proof {x} {y} {z}) {n}) Category.Functor.id-preserving bound-functor {n} = proof{n} where proof : ∀{n} → (bound-[≤] (reflexivity(_≤_) {n}) ⊜ id) _⊜_.proof (proof {𝟎}) {()} _⊜_.proof (proof {𝐒 n}) {𝟎} = [≡]-intro _⊜_.proof (proof {𝐒 n}) {𝐒 x} = congruence₁(𝐒) (_⊜_.proof (proof {n}) {x})
{ "alphanum_fraction": 0.6792093356, "avg_line_length": 48.8255813953, "ext": "agda", "hexsha": "bbd8f0fa30b8eb4a7195de3e83a135ed0d06c784", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Finite/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Finite/Category.agda", "max_line_length": 257, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Finite/Category.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": 1524, "size": 4199 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Neutral {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties import Definition.Typed.Weakening as Wk open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Properties.Symmetry open import Tools.Product import Tools.PropositionalEquality as PE -- Neutral reflexive types are reducible. neu : ∀ {l Γ A} (neA : Neutral A) → Γ ⊢ A → Γ ⊢ A ~ A ∷ U → Γ ⊩⟨ l ⟩ A neu neA A A~A = ne′ _ (idRed:*: A) neA A~A -- Helper function for reducible neutral equality of a specific type of derivation. neuEq′ : ∀ {l Γ A B} ([A] : Γ ⊩⟨ l ⟩ne A) (neA : Neutral A) (neB : Neutral B) → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ~ B ∷ U → Γ ⊩⟨ l ⟩ A ≡ B / ne-intr [A] neuEq′ (noemb (ne K [ ⊢A , ⊢B , D ] neK K≡K)) neA neB A B A~B = let A≡K = whnfRed* D (ne neA) in ne₌ _ (idRed:*: B) neB (PE.subst (λ x → _ ⊢ x ~ _ ∷ _) A≡K A~B) neuEq′ (emb 0<1 x) neB A:≡:B = neuEq′ x neB A:≡:B -- Neutrally equal types are of reducible equality. neuEq : ∀ {l Γ A B} ([A] : Γ ⊩⟨ l ⟩ A) (neA : Neutral A) (neB : Neutral B) → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ~ B ∷ U → Γ ⊩⟨ l ⟩ A ≡ B / [A] neuEq [A] neA neB A B A~B = irrelevanceEq (ne-intr (ne-elim neA [A])) [A] (neuEq′ (ne-elim neA [A]) neA neB A B A~B) mutual -- Neutral reflexive terms are reducible. neuTerm : ∀ {l Γ A n} ([A] : Γ ⊩⟨ l ⟩ A) (neN : Neutral n) → Γ ⊢ n ∷ A → Γ ⊢ n ~ n ∷ A → Γ ⊩⟨ l ⟩ n ∷ A / [A] neuTerm (Uᵣ′ .⁰ 0<1 ⊢Γ) neN n n~n = Uₜ _ (idRedTerm:*: n) (ne neN) (~-to-≅ₜ n~n) (neu neN (univ n) n~n) neuTerm (ℕᵣ [ ⊢A , ⊢B , D ]) neN n n~n = let A≡ℕ = subset* D n~n′ = ~-conv n~n A≡ℕ n≡n = ~-to-≅ₜ n~n′ in ℕₜ _ (idRedTerm:*: (conv n A≡ℕ)) n≡n (ne (neNfₜ neN (conv n A≡ℕ) n~n′)) neuTerm (Emptyᵣ [ ⊢A , ⊢B , D ]) neN n n~n = let A≡Empty = subset* D n~n′ = ~-conv n~n A≡Empty n≡n = ~-to-≅ₜ n~n′ in Emptyₜ _ (idRedTerm:*: (conv n A≡Empty)) n≡n (ne (neNfₜ neN (conv n A≡Empty) n~n′)) neuTerm (Unitᵣ [ ⊢A , ⊢B , D ]) neN n n~n = let A≡Unit = subset* D n~n′ = ~-conv n~n A≡Unit in Unitₜ _ (idRedTerm:*: (conv n A≡Unit)) (ne neN) neuTerm (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) neN n n~n = let A≡K = subset* D in neₜ _ (idRedTerm:*: (conv n A≡K)) (neNfₜ neN (conv n A≡K) (~-conv n~n A≡K)) neuTerm (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in Πₜ _ (idRedTerm:*: (conv n A≡ΠFG)) (ne neN) (~-to-≅ₜ (~-conv n~n A≡ΠFG)) (λ {ρ} [ρ] ⊢Δ [a] [b] [a≡b] → let A≡ΠFG = subset* (red D) ρA≡ρΠFG = Wk.wkEq [ρ] ⊢Δ (subset* (red D)) G[a]≡G[b] = escapeEq ([G] [ρ] ⊢Δ [b]) (symEq ([G] [ρ] ⊢Δ [a]) ([G] [ρ] ⊢Δ [b]) (G-ext [ρ] ⊢Δ [a] [b] [a≡b])) a = escapeTerm ([F] [ρ] ⊢Δ) [a] b = escapeTerm ([F] [ρ] ⊢Δ) [b] a≡b = escapeTermEq ([F] [ρ] ⊢Δ) [a≡b] ρn = conv (Wk.wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG neN∘a = ∘ₙ (wkNeutral ρ neN) neN∘b = ∘ₙ (wkNeutral ρ neN) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∘a neN∘b (ρn ∘ⱼ a) (conv (ρn ∘ⱼ b) (≅-eq G[a]≡G[b])) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡b)) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = Wk.wkEq [ρ] ⊢Δ (subset* (red D)) a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) in neuTerm ([G] [ρ] ⊢Δ [a]) (∘ₙ (wkNeutral ρ neN)) (conv (Wk.wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡a)) neuTerm (Σᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN ⊢n n~n = let A≡ΣFG = subset* (red D) ⊢Γ = wf ⊢F ⊢n = conv ⊢n A≡ΣFG n~n = ~-conv n~n A≡ΣFG [F] = [F] Wk.id ⊢Γ [fst] = neuTerm [F] (fstₙ neN) (PE.subst (λ x → _ ⊢ fst _ ∷ x) (PE.sym (wk-id F)) (fstⱼ ⊢F ⊢G ⊢n)) (PE.subst (λ x → _ ⊢ _ ~ _ ∷ x) (PE.sym (wk-id F)) (~-fst ⊢F ⊢G n~n)) [Gfst] = [G] Wk.id ⊢Γ [fst] [snd] = neuTerm [Gfst] (sndₙ neN) (PE.subst (λ x → _ ⊢ snd _ ∷ x) (PE.cong (λ x → x [ fst _ ]) (PE.sym (wk-lift-id G))) (sndⱼ ⊢F ⊢G ⊢n)) (PE.subst (λ x → _ ⊢ _ ~ _ ∷ x) (PE.cong (λ x → x [ fst _ ]) (PE.sym (wk-lift-id G))) (~-snd ⊢F ⊢G n~n)) in Σₜ _ (idRedTerm:*: ⊢n) (ne neN) (~-to-≅ₜ n~n) [fst] [snd] neuTerm (emb 0<1 x) neN n = neuTerm x neN n -- Neutrally equal terms are of reducible equality. neuEqTerm : ∀ {l Γ A n n′} ([A] : Γ ⊩⟨ l ⟩ A) (neN : Neutral n) (neN′ : Neutral n′) → Γ ⊢ n ∷ A → Γ ⊢ n′ ∷ A → Γ ⊢ n ~ n′ ∷ A → Γ ⊩⟨ l ⟩ n ≡ n′ ∷ A / [A] neuEqTerm (Uᵣ′ .⁰ 0<1 ⊢Γ) neN neN′ n n′ n~n′ = let [n] = neu neN (univ n) (~-trans n~n′ (~-sym n~n′)) [n′] = neu neN′ (univ n′) (~-trans (~-sym n~n′) n~n′) in Uₜ₌ _ _ (idRedTerm:*: n) (idRedTerm:*: n′) (ne neN) (ne neN′) (~-to-≅ₜ n~n′) [n] [n′] (neuEq [n] neN neN′ (univ n) (univ n′) n~n′) neuEqTerm (ℕᵣ [ ⊢A , ⊢B , D ]) neN neN′ n n′ n~n′ = let A≡ℕ = subset* D n~n′₁ = ~-conv n~n′ A≡ℕ n≡n′ = ~-to-≅ₜ n~n′₁ in ℕₜ₌ _ _ (idRedTerm:*: (conv n A≡ℕ)) (idRedTerm:*: (conv n′ A≡ℕ)) n≡n′ (ne (neNfₜ₌ neN neN′ n~n′₁)) neuEqTerm (Emptyᵣ [ ⊢A , ⊢B , D ]) neN neN′ n n′ n~n′ = let A≡Empty = subset* D n~n′₁ = ~-conv n~n′ A≡Empty n≡n′ = ~-to-≅ₜ n~n′₁ in Emptyₜ₌ _ _ (idRedTerm:*: (conv n A≡Empty)) (idRedTerm:*: (conv n′ A≡Empty)) n≡n′ (ne (neNfₜ₌ neN neN′ n~n′₁)) neuEqTerm (Unitᵣ [ ⊢A , ⊢B , D ]) neN neN′ n n′ n~n′ = let A≡Unit = subset* D in Unitₜ₌ (conv n A≡Unit) (conv n′ A≡Unit) neuEqTerm (ne (ne K [ ⊢A , ⊢B , D ] neK K≡K)) neN neN′ n n′ n~n′ = let A≡K = subset* D in neₜ₌ _ _ (idRedTerm:*: (conv n A≡K)) (idRedTerm:*: (conv n′ A≡K)) (neNfₜ₌ neN neN′ (~-conv n~n′ A≡K)) neuEqTerm (Πᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let [ΠFG] = Πᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext A≡ΠFG = subset* D n~n′₁ = ~-conv n~n′ A≡ΠFG n≡n′ = ~-to-≅ₜ n~n′₁ n~n = ~-trans n~n′ (~-sym n~n′) n′~n′ = ~-trans (~-sym n~n′) n~n′ in Πₜ₌ _ _ (idRedTerm:*: (conv n A≡ΠFG)) (idRedTerm:*: (conv n′ A≡ΠFG)) (ne neN) (ne neN′) n≡n′ (neuTerm [ΠFG] neN n n~n) (neuTerm [ΠFG] neN′ n′ n′~n′) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = Wk.wkEq [ρ] ⊢Δ A≡ΠFG ρn = Wk.wkTerm [ρ] ⊢Δ n ρn′ = Wk.wkTerm [ρ] ⊢Δ n′ a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) neN∙a = ∘ₙ (wkNeutral ρ neN) neN′∙a′ = ∘ₙ (wkNeutral ρ neN′) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∙a neN′∙a′ (conv ρn ρA≡ρΠFG ∘ⱼ a) (conv ρn′ ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ n~n′₁) a≡a)) neuEqTerm (Σᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ ⊢n ⊢n′ n~n′ = let [ΣFG] = Σᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext A≡ΣFG = subset* D n~n = ~-trans n~n′ (~-sym n~n′) n′~n′ = ~-trans (~-sym n~n′) n~n′ ⊢Γ = wf ⊢F ⊢nΣ = conv ⊢n A≡ΣFG ⊢n′Σ = conv ⊢n′ A≡ΣFG n~n′Σ = ~-conv n~n′ A≡ΣFG n~nΣ = ~-conv n~n A≡ΣFG n′~n′Σ = ~-conv n′~n′ A≡ΣFG [F] = [F] Wk.id ⊢Γ ⊢fstnΣ = (PE.subst (λ x → _ ⊢ fst _ ∷ x) (PE.sym (wk-id F)) (fstⱼ ⊢F ⊢G ⊢nΣ)) ⊢fstn′Σ = (PE.subst (λ x → _ ⊢ fst _ ∷ x) (PE.sym (wk-id F)) (fstⱼ ⊢F ⊢G ⊢n′Σ)) [fstn] = neuTerm [F] (fstₙ neN) ⊢fstnΣ (PE.subst (λ x → _ ⊢ _ ~ _ ∷ x) (PE.sym (wk-id F)) (~-fst ⊢F ⊢G n~nΣ)) [fstn′] = neuTerm [F] (fstₙ neN′) ⊢fstn′Σ (PE.subst (λ x → _ ⊢ _ ~ _ ∷ x) (PE.sym (wk-id F)) (~-fst ⊢F ⊢G n′~n′Σ)) [fstn≡fstn′] = neuEqTerm [F] (fstₙ neN) (fstₙ neN′) ⊢fstnΣ ⊢fstn′Σ (PE.subst (λ x → _ ⊢ _ ~ _ ∷ x) (PE.sym (wk-id F)) (~-fst ⊢F ⊢G n~n′Σ)) [Gfstn] = [G] Wk.id ⊢Γ [fstn] [Gfstn′] = PE.subst (λ x → _ ⊩⟨ _ ⟩ x [ fst _ ]) (wk-lift-id G) ([G] Wk.id ⊢Γ [fstn′]) [fstn′≡fstn] = symEqTerm [F] [fstn≡fstn′] [Gfstn′≡Gfstn] = irrelevanceEq″ (PE.cong (λ x → x [ fst _ ]) (wk-lift-id G)) (PE.cong (λ x → x [ fst _ ]) (wk-lift-id G)) ([G] Wk.id ⊢Γ [fstn′]) [Gfstn′] (G-ext Wk.id ⊢Γ [fstn′] [fstn] [fstn′≡fstn]) Gfstn′≡Gfstn = ≅-eq (escapeEq [Gfstn′] [Gfstn′≡Gfstn]) [sndn≡sndn′] = neuEqTerm [Gfstn] (sndₙ neN) (sndₙ neN′) (PE.subst (λ x → _ ⊢ snd _ ∷ x) (PE.cong (λ x → x [ fst _ ]) (PE.sym (wk-lift-id G))) (sndⱼ ⊢F ⊢G ⊢nΣ)) (PE.subst (λ x → _ ⊢ snd _ ∷ x) (PE.cong (λ x → x [ fst _ ]) (PE.sym (wk-lift-id G))) (conv (sndⱼ ⊢F ⊢G ⊢n′Σ) Gfstn′≡Gfstn)) (PE.subst (λ x → _ ⊢ _ ~ _ ∷ x) (PE.cong (λ x → x [ fst _ ]) (PE.sym (wk-lift-id G))) (~-snd ⊢F ⊢G n~n′Σ)) in Σₜ₌ _ _ (idRedTerm:*: ⊢nΣ) (idRedTerm:*: ⊢n′Σ) (ne neN) (ne neN′) (~-to-≅ₜ n~n′Σ) (neuTerm [ΣFG] neN ⊢n n~n) (neuTerm [ΣFG] neN′ ⊢n′ n′~n′) [fstn] [fstn′] [fstn≡fstn′] [sndn≡sndn′] neuEqTerm (emb 0<1 x) neN neN′ n:≡:n′ = neuEqTerm x neN neN′ n:≡:n′
{ "alphanum_fraction": 0.3960352423, "avg_line_length": 43.8223938224, "ext": "agda", "hexsha": "293113a79d6ac77a984c275487a8634e93bc9f7c", "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/Neutral.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/Neutral.agda", "max_line_length": 94, "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/Neutral.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5019, "size": 11350 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Coproduct open import lib.types.Paths open import lib.types.Pointed open import lib.types.Pushout open import lib.types.PushoutFlattening open import lib.types.PushoutFmap open import lib.types.Sigma open import lib.types.Span open import lib.types.Unit -- Wedge of two pointed types is defined as a particular case of pushout module lib.types.Wedge where module _ {i j} (X : Ptd i) (Y : Ptd j) where ⊙∨-span : ⊙Span ⊙∨-span = ⊙span X Y ⊙Unit ⊙cst ⊙cst ⊙wedge-span = ⊙∨-span ∨-span : Span ∨-span = ⊙Span-to-Span ⊙∨-span wedge-span = ∨-span Wedge : Type (lmax i j) Wedge = Pushout wedge-span infix 80 _∨_ _∨_ = Wedge ⊙Wedge : Ptd (lmax i j) ⊙Wedge = ⊙Pushout ⊙wedge-span infix 80 _⊙∨_ _⊙∨_ = ⊙Wedge module _ {i j} {X : Ptd i} {Y : Ptd j} where winl : de⊙ X → X ∨ Y winl x = left x winr : de⊙ Y → X ∨ Y winr y = right y wglue : winl (pt X) == winr (pt Y) wglue = glue tt ⊙winl : X ⊙→ X ⊙∨ Y ⊙winl = (winl , idp) ⊙winr : Y ⊙→ X ⊙∨ Y ⊙winr = (winr , ! wglue) module WedgeElim {k} {P : X ∨ Y → Type k} (winl* : (x : de⊙ X) → P (winl x)) (winr* : (y : de⊙ Y) → P (winr y)) (glue* : winl* (pt X) == winr* (pt Y) [ P ↓ wglue ]) where private module M = PushoutElim winl* winr* (λ _ → glue*) f = M.f glue-β = M.glue-β unit ∨-elim = WedgeElim.f Wedge-elim = WedgeElim.f module WedgeRec {k} {C : Type k} (winl* : de⊙ X → C) (winr* : de⊙ Y → C) (glue* : winl* (pt X) == winr* (pt Y)) where private module M = PushoutRec {d = wedge-span X Y} winl* winr* (λ _ → glue*) f = M.f glue-β = M.glue-β unit ∨-rec = WedgeRec.f Wedge-rec = WedgeRec.f module ⊙WedgeRec {k} {Z : Ptd k} (g : X ⊙→ Z) (h : Y ⊙→ Z) where open WedgeRec (fst g) (fst h) (snd g ∙ ! (snd h)) public ⊙f : X ⊙∨ Y ⊙→ Z ⊙f = (f , snd g) ⊙winl-β : ⊙f ⊙∘ ⊙winl == g ⊙winl-β = idp ⊙winr-β : ⊙f ⊙∘ ⊙winr == h ⊙winr-β = ⊙λ=' (λ _ → idp) lemma where abstract lemma : snd (⊙f ⊙∘ ⊙winr) == snd h lemma = ap (_∙ snd g) (ap-! f wglue ∙ ap ! glue-β ∙ !-∙ (snd g) (! (snd h))) ∙ ∙-assoc (! (! (snd h))) (! (snd g)) (snd g) ∙ ap (! (! (snd h)) ∙_) (!-inv-l (snd g)) ∙ ∙-unit-r (! (! (snd h))) ∙ !-! (snd h) ⊙∨-rec = ⊙WedgeRec.⊙f ⊙Wedge-rec = ⊙WedgeRec.⊙f ⊙Wedge-rec-post∘ : ∀ {k l} {Z : Ptd k} {W : Ptd l} (k : Z ⊙→ W) (g : X ⊙→ Z) (h : Y ⊙→ Z) → k ⊙∘ ⊙Wedge-rec g h ⊙∼ ⊙Wedge-rec (k ⊙∘ g) (k ⊙∘ h) ⊙Wedge-rec-post∘ k g h = (Wedge-elim (λ _ → idp) (λ _ → idp) (↓-='-in' $ ⊙WedgeRec.glue-β (k ⊙∘ g) (k ⊙∘ h) ∙ lemma (fst k) (snd g) (snd h) (snd k) ∙ ! (ap (ap (fst k)) (⊙WedgeRec.glue-β g h)) ∙ ∘-ap (fst k) (fst (⊙Wedge-rec g h)) wglue)) , idp where lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y z : A} {w : B} (p : x == z) (q : y == z) (r : f z == w) → (ap f p ∙ r) ∙ ! (ap f q ∙ r) == ap f (p ∙ ! q) lemma f idp idp idp = idp ⊙∨-rec-post∘ = ⊙Wedge-rec-post∘ ⊙Wedge-rec-η : ⊙Wedge-rec ⊙winl ⊙winr == ⊙idf (X ⊙∨ Y) ⊙Wedge-rec-η = ⊙λ=' (Wedge-elim (λ _ → idp) (λ _ → idp) (↓-='-in' $ ap-idf wglue ∙ ! (!-! wglue) ∙ ! (⊙WedgeRec.glue-β ⊙winl ⊙winr))) idp ⊙∨-rec-η = ⊙Wedge-rec-η add-wglue : de⊙ (X ⊙⊔ Y) → X ∨ Y add-wglue (inl x) = winl x add-wglue (inr y) = winr y ⊙add-wglue : X ⊙⊔ Y ⊙→ X ⊙∨ Y ⊙add-wglue = add-wglue , idp module Projl = ⊙WedgeRec (⊙idf X) (⊙cst {X = Y}) module Projr = ⊙WedgeRec (⊙cst {X = X}) (⊙idf Y) projl = Projl.f projr = Projr.f ⊙projl = Projl.⊙f ⊙projr = Projr.⊙f module WedgeToProduct = ⊙WedgeRec ((_, pt Y) , idp) ((pt X ,_), idp) ∨-⊙to-× : X ⊙∨ Y ⊙→ X ⊙× Y ∨-⊙to-× = WedgeToProduct.⊙f ∨-to-× : X ∨ Y → de⊙ (X ⊙× Y) ∨-to-× = WedgeToProduct.f ∨-to-×-glue-β : ap ∨-to-× wglue == idp ∨-to-×-glue-β = WedgeToProduct.glue-β abstract ↓-∨to×=cst-in : ∀ {x y} {p p' : (pt X , pt Y) == (x , y)} → p == p' → p == p' [ (λ w → ∨-to-× w == (x , y)) ↓ wglue ] ↓-∨to×=cst-in {p' = idp} q = ↓-app=cst-in' (q ∙ ! WedgeToProduct.glue-β) ↓-∨to×=cst-out : ∀ {x y} {p p' : (pt X , pt Y) == (x , y)} → p == p' [ (λ w → ∨-to-× w == (x , y)) ↓ wglue ] → p == p' ↓-∨to×=cst-out {p' = idp} q = ↓-app=cst-out' q ∙ WedgeToProduct.glue-β ↓-∨to×=cst-β : ∀ {x y} {p p' : (pt X , pt Y) == (x , y)} (q : p == p') → ↓-∨to×=cst-out (↓-∨to×=cst-in q) == q ↓-∨to×=cst-β {p' = idp} idp = ap (_∙ WedgeToProduct.glue-β) (↓-app=cst-β' {p = wglue} (! WedgeToProduct.glue-β)) ∙ !-inv-l WedgeToProduct.glue-β ↓-∨to×=cst-η : ∀ {x y} {p p' : (pt X , pt Y) == (x , y)} (q : p == p' [ (λ w → ∨-to-× w == (x , y)) ↓ wglue ]) → ↓-∨to×=cst-in (↓-∨to×=cst-out q) == q ↓-∨to×=cst-η {p = p} {p' = idp} q = ap ↓-app=cst-in' ( ∙-assoc (↓-app=cst-out' q) WedgeToProduct.glue-β (! WedgeToProduct.glue-β) ∙ ap (↓-app=cst-out' q ∙_) (!-inv-r WedgeToProduct.glue-β) ∙ ∙-unit-r (↓-app=cst-out' q)) ∙ ↓-app=cst-η' q module Fold {i} {X : Ptd i} = ⊙WedgeRec (⊙idf X) (⊙idf X) fold = Fold.f ⊙fold = Fold.⊙f module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} (fX : X ⊙→ X') (fY : Y ⊙→ Y') where wedge-span-map : SpanMap (wedge-span X Y) (wedge-span X' Y') wedge-span-map = span-map (fst fX) (fst fY) (idf _) (comm-sqr λ _ → snd fX) (comm-sqr λ _ → snd fY) module WedgeFmap where private module M = PushoutFmap wedge-span-map f = M.f glue-β = M.glue-β unit ∨-fmap : X ∨ Y → X' ∨ Y' ∨-fmap = WedgeFmap.f ⊙∨-fmap : X ⊙∨ Y ⊙→ X' ⊙∨ Y' ⊙∨-fmap = ∨-fmap , ap winl (snd fX) Wedge-fmap = ∨-fmap ⊙Wedge-fmap = ⊙∨-fmap module _ {i₀ i₁ i₂ j₀ j₁ j₂} {X₀ : Ptd i₀} {X₁ : Ptd i₁} {X₂ : Ptd i₂} {Y₀ : Ptd j₀} {Y₁ : Ptd j₁} {Y₂ : Ptd j₂} where ∨-fmap-∘ : (gX : X₁ ⊙→ X₂) (fX : X₀ ⊙→ X₁) (gY : Y₁ ⊙→ Y₂) (fY : Y₀ ⊙→ Y₁) → ∨-fmap (gX ⊙∘ fX) (gY ⊙∘ fY) ∼ ∨-fmap gX gY ∘ ∨-fmap fX fY ∨-fmap-∘ (gX , idp) (fX , idp) (gY , idp) (fY , idp) = Pushout-fmap-∘ (wedge-span-map (gX , idp) (gY , idp)) (wedge-span-map (fX , idp) (fY , idp)) ⊙∨-fmap-∘ : (gX : X₁ ⊙→ X₂) (fX : X₀ ⊙→ X₁) (gY : Y₁ ⊙→ Y₂) (fY : Y₀ ⊙→ Y₁) → ⊙∨-fmap (gX ⊙∘ fX) (gY ⊙∘ fY) ⊙∼ ⊙∨-fmap gX gY ⊙∘ ⊙∨-fmap fX fY ⊙∨-fmap-∘ (gX , idp) (fX , idp) (gY , idp) (fY , idp) = ∨-fmap-∘ (gX , idp) (fX , idp) (gY , idp) (fY , idp) , idp Wedge-fmap-∘ = ∨-fmap-∘ ⊙Wedge-fmap-∘ = ⊙∨-fmap-∘ module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} (eqX : X ⊙≃ X') (eqY : Y ⊙≃ Y') where wedge-span-emap : SpanEquiv (wedge-span X Y) (wedge-span X' Y') wedge-span-emap = wedge-span-map (⊙–> eqX) (⊙–> eqY) , snd eqX , snd eqY , idf-is-equiv _ ∨-emap : X ∨ Y ≃ X' ∨ Y' ∨-emap = Pushout-emap wedge-span-emap ⊙∨-emap : X ⊙∨ Y ⊙≃ X' ⊙∨ Y' ⊙∨-emap = ≃-to-⊙≃ ∨-emap (ap winl (⊙–>-pt eqX)) Wedge-emap = ∨-emap ⊙Wedge-emap = ⊙∨-emap module _ {i i' j j' k} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} {Z : Ptd k} (winl* : X' ⊙→ Z) (winr* : Y' ⊙→ Z) (f : X ⊙→ X') (g : Y ⊙→ Y') where ⊙Wedge-rec-fmap : ⊙Wedge-rec winl* winr* ⊙∘ ⊙∨-fmap f g ⊙∼ ⊙Wedge-rec (winl* ⊙∘ f) (winr* ⊙∘ g) ⊙Wedge-rec-fmap = Wedge-elim (λ _ → idp) (λ _ → idp) (↓-='-in' $ ! $ lemma₀ winl* winr* f g) , lemma₁ winl* winr* f where abstract lemma₀ : ∀ {X' Y' Z} (winl* : X' ⊙→ Z) (winr* : Y' ⊙→ Z) (f : X ⊙→ X') (g : Y ⊙→ Y') → ap (⊙WedgeRec.f winl* winr* ∘ ∨-fmap f g) wglue == ap (⊙WedgeRec.f (winl* ⊙∘ f) (winr* ⊙∘ g)) wglue lemma₀ (winl* , idp) (winr* , winr*-pt) (f , idp) (g , idp) = ap (Wedge-rec winl* winr* (! winr*-pt) ∘ ∨-fmap (f , idp) (g , idp)) wglue =⟨ ap-∘ (Wedge-rec winl* winr* (! winr*-pt)) (∨-fmap (f , idp) (g , idp)) wglue ⟩ ap (Wedge-rec winl* winr* (! winr*-pt)) (ap (∨-fmap (f , idp) (g , idp)) wglue) =⟨ ap (ap (Wedge-rec winl* winr* (! winr*-pt))) $ WedgeFmap.glue-β (f , idp) (g , idp) ⟩ ap (Wedge-rec winl* winr* (! winr*-pt)) wglue =⟨ WedgeRec.glue-β winl* winr* (! winr*-pt) ⟩ ! winr*-pt =⟨ ! $ WedgeRec.glue-β (winl* ∘ f) (winr* ∘ g) (! winr*-pt) ⟩ ap (Wedge-rec (winl* ∘ f) (winr* ∘ g) (! winr*-pt)) wglue =∎ lemma₁ : ∀ {X' Z} (winl* : X' ⊙→ Z) (winr* : Y' ⊙→ Z) (f : X ⊙→ X') → snd (⊙Wedge-rec winl* winr* ⊙∘ ⊙∨-fmap f g) == snd (⊙Wedge-rec (winl* ⊙∘ f) (winr* ⊙∘ g)) lemma₁ (f , idp) _ (winl* , idp) = idp ⊙∨-rec-fmap = ⊙Wedge-rec-fmap module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} (f : X ⊙→ X') (g : Y ⊙→ Y') where ⊙projl-fmap : ⊙projl ⊙∘ ⊙∨-fmap f g ⊙∼ ⊙Wedge-rec f ⊙cst ⊙projl-fmap = Wedge-elim (λ _ → idp) (λ _ → idp) (↓-='-in' $ ! $ lemma₀ f g) , lemma₁ f g where abstract lemma₀ : ∀ {X' Y'} (f : X ⊙→ X') (g : Y ⊙→ Y') → ap (projl ∘ ∨-fmap f g) wglue == ap (⊙WedgeRec.f f ⊙cst) wglue lemma₀ (f , idp) (g , idp) = ap (projl ∘ ∨-fmap (f , idp) (g , idp)) wglue =⟨ ap-∘ projl (∨-fmap (f , idp) (g , idp)) wglue ⟩ ap projl (ap (∨-fmap (f , idp) (g , idp)) wglue) =⟨ ap (ap projl) (WedgeFmap.glue-β (f , idp) (g , idp)) ⟩ ap projl wglue =⟨ Projl.glue-β ⟩ idp =⟨ ! $ ⊙WedgeRec.glue-β (f , idp) ⊙cst ⟩ ap (⊙WedgeRec.f (f , idp) ⊙cst) wglue =∎ lemma₁ : ∀ {X' Y'} (f : X ⊙→ X') (g : Y ⊙→ Y') → snd (⊙projl ⊙∘ ⊙∨-fmap f g) == snd (⊙Wedge-rec {Y = Y} f ⊙cst) lemma₁ (f , idp) (g , idp) = idp ⊙projr-fmap : ⊙projr ⊙∘ ⊙∨-fmap f g ⊙∼ ⊙Wedge-rec ⊙cst g ⊙projr-fmap = Wedge-elim (λ _ → idp) (λ _ → idp) (↓-='-in' $ ! $ lemma₀ f g) , lemma₁ f g where abstract lemma₀ : ∀ {X' Y'} (f : X ⊙→ X') (g : Y ⊙→ Y') → ap (projr ∘ ∨-fmap f g) wglue == ap (⊙WedgeRec.f ⊙cst g) wglue lemma₀ (f , idp) (g , idp) = ap (projr ∘ ∨-fmap (f , idp) (g , idp)) wglue =⟨ ap-∘ projr (∨-fmap (f , idp) (g , idp)) wglue ⟩ ap projr (ap (∨-fmap (f , idp) (g , idp)) wglue) =⟨ ap (ap projr) (WedgeFmap.glue-β (f , idp) (g , idp)) ⟩ ap projr wglue =⟨ Projr.glue-β ⟩ idp =⟨ ! $ ⊙WedgeRec.glue-β ⊙cst (g , idp) ⟩ ap (⊙WedgeRec.f ⊙cst (g , idp)) wglue =∎ lemma₁ : ∀ {X' Y'} (f : X ⊙→ X') (g : Y ⊙→ Y') → snd (⊙projr ⊙∘ ⊙∨-fmap f g) == snd (⊙Wedge-rec {X = X} ⊙cst g) lemma₁ (f , idp) (g , idp) = idp module _ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (f : X ⊙→ Z) (g : Y ⊙→ Z) where {- favonia: This is a special case, but still proved separately to make sure it has good computational content. (Maybe this is overkilling.) -} ⊙fold-fmap : ⊙fold ⊙∘ ⊙∨-fmap f g ⊙∼ ⊙Wedge-rec f g ⊙fold-fmap = Wedge-elim (λ _ → idp) (λ _ → idp) (↓-='-in' $ ! $ lemma₀ f g) , lemma₁ f g where abstract lemma₀ : ∀ {Z} (f : X ⊙→ Z) (g : Y ⊙→ Z) → ap (⊙WedgeRec.f (⊙idf _) (⊙idf _) ∘ ∨-fmap f g) wglue == ap (⊙WedgeRec.f f g) wglue lemma₀ (f , idp) (g , g-pt) = ap (⊙WedgeRec.f (⊙idf _) (⊙idf _) ∘ ∨-fmap (f , idp) (g , g-pt)) wglue =⟨ ap-∘ (⊙WedgeRec.f (⊙idf _) (⊙idf _)) (∨-fmap (f , idp) (g , g-pt)) wglue ⟩ ap (⊙WedgeRec.f (⊙idf _) (⊙idf _)) (ap (∨-fmap (f , idp) (g , g-pt)) wglue) =⟨ ap (ap (⊙WedgeRec.f (⊙idf _) (⊙idf _))) (WedgeFmap.glue-β (f , idp) (g , g-pt)) ⟩ ap (⊙WedgeRec.f (⊙idf _) (⊙idf _)) (wglue ∙' ap winr (! g-pt)) =⟨ ap-∙' (⊙WedgeRec.f (⊙idf _) (⊙idf _)) wglue (ap winr (! g-pt)) ⟩ ap (⊙WedgeRec.f (⊙idf _) (⊙idf _)) wglue ∙' ap (⊙WedgeRec.f (⊙idf _) (⊙idf _)) (ap winr (! g-pt)) =⟨ ap2 _∙'_ (⊙WedgeRec.glue-β (⊙idf _) (⊙idf _)) ( ∘-ap (⊙WedgeRec.f (⊙idf _) (⊙idf _)) winr (! g-pt) ∙ ap-idf (! g-pt)) ⟩ idp ∙' ! g-pt =⟨ ∙'-unit-l (! g-pt) ⟩ ! g-pt =⟨ ! $ ⊙WedgeRec.glue-β (f , idp) (g , g-pt) ⟩ ap (⊙WedgeRec.f (f , idp) (g , g-pt) ) wglue =∎ lemma₁ : ∀ {Z} (f : X ⊙→ Z) (g : Y ⊙→ Z) → snd (⊙Wedge-rec (⊙idf _) (⊙idf _) ⊙∘ ⊙∨-fmap f g) == snd (⊙Wedge-rec f g) lemma₁ (f , idp) (g , g-pt) = idp module _ {i j k} (X : Ptd i) (Y : Ptd j) (Z : Ptd k) where module WedgeAssocInl = WedgeRec {C = X ∨ (Y ⊙∨ Z)} winl (winr ∘ winl) wglue module WedgeAssoc = WedgeRec {X = X ⊙∨ Y} WedgeAssocInl.f (winr ∘ winr) (wglue ∙ ap winr wglue) ∨-assoc : (X ⊙∨ Y) ∨ Z ≃ X ∨ (Y ⊙∨ Z) ∨-assoc = equiv to from to-from from-to where to : (X ⊙∨ Y) ∨ Z → X ∨ (Y ⊙∨ Z) to = WedgeAssoc.f module FromInr = WedgeRec {C = (X ⊙∨ Y) ∨ Z} (winl ∘ winr) winr (! (ap winl wglue) ∙ wglue) module From = WedgeRec {Y = Y ⊙∨ Z} (winl ∘ winl) FromInr.f (ap winl wglue) from : X ∨ (Y ⊙∨ Z) → (X ⊙∨ Y) ∨ Z from = From.f abstract to-from : ∀ x → to (from x) == x to-from = Wedge-elim (λ x → idp) (Wedge-elim (λ y → idp) (λ z → idp) $ ↓-='-in' $ ! $ ap (to ∘ FromInr.f) wglue =⟨ ap-∘ to FromInr.f wglue ⟩ ap to (ap FromInr.f wglue) =⟨ ap (ap to) FromInr.glue-β ⟩ ap to (! (ap winl wglue) ∙ wglue) =⟨ ap-∙ to (! (ap winl wglue)) wglue ⟩ ap to (! (ap winl wglue)) ∙ ap to wglue =⟨ _∙2_ (ap-! to (ap winl wglue) ∙ ap ! (∘-ap to winl wglue ∙ WedgeAssocInl.glue-β)) WedgeAssoc.glue-β ⟩ ! wglue ∙ wglue ∙ ap winr wglue =⟨ ! $ ∙-assoc (! wglue) wglue (ap winr wglue) ⟩ (! wglue ∙ wglue) ∙ ap winr wglue =⟨ ap (_∙ ap winr wglue) (!-inv-l wglue) ⟩ ap winr wglue =∎) (↓-∘=idf-in' to from (ap (ap to) From.glue-β ∙ ∘-ap to winl wglue ∙ WedgeAssocInl.glue-β)) from-to : ∀ x → from (to x) == x from-to = Wedge-elim (Wedge-elim (λ x → idp) (λ y → idp) $ ↓-='-in' $ ! $ ap-∘ from WedgeAssocInl.f wglue ∙ ap (ap from) WedgeAssocInl.glue-β ∙ From.glue-β) (λ z → idp) (↓-∘=idf-in' from to $ ap from (ap to wglue) =⟨ ap (ap from) WedgeAssoc.glue-β ⟩ ap from (wglue ∙ ap winr wglue) =⟨ ap-∙ from wglue (ap winr wglue) ⟩ ap from wglue ∙ ap from (ap winr wglue) =⟨ From.glue-β ∙2 (∘-ap from winr wglue ∙ FromInr.glue-β) ⟩ ap winl wglue ∙ ! (ap winl wglue) ∙ wglue =⟨ ! $ ∙-assoc (ap winl wglue) (! (ap winl wglue)) wglue ⟩ (ap winl wglue ∙ ! (ap winl wglue)) ∙ wglue =⟨ ap (_∙ wglue) (!-inv-r (ap winl wglue)) ⟩ wglue =∎) ⊙∨-assoc : (X ⊙∨ Y) ⊙∨ Z ⊙≃ X ⊙∨ (Y ⊙∨ Z) ⊙∨-assoc = ≃-to-⊙≃ ∨-assoc idp {- module _ {i₀ i₁ j₀ j₁ k₀ k₁} {X₀ : Ptd i₀} {Y₀ : Ptd j₀} {Z₀ : Ptd k₀} {X₁ : Ptd i₁} {Y₁ : Ptd j₁} {Z₁ : Ptd k₁} where ⊙∨-assoc-nat : ∀ (f : X₀ ⊙→ X₁) (g : Y₀ ⊙→ Y₁) (h : Z₀ ⊙→ Z₁) → ⊙–> (⊙∨-assoc X₁ Y₁ Z₁) ⊙∘ ⊙∨-fmap (⊙∨-fmap f g) h ⊙∼ ⊙∨-fmap f (⊙∨-fmap g h) ⊙∘ ⊙–> (⊙∨-assoc X₀ Y₀ Z₀) ⊙∨-assoc-nat (f , idp) (g , idp) (h , idp) = (Wedge-elim -- {P = –> (∨-assoc X₁ Y₁ Z₁) ∘ ∨-fmap (⊙∨-fmap f g) h ∼ ∨-fmap f (⊙∨-fmap g h) ∘ –> (∨-assoc X₀ Y₀ Z₀)} (Wedge-elim (λ _ → idp) (λ _ → idp) (↓-='-in' $ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp)) ∘ WedgeAssocInl.f X₀ Y₀ Z₀) wglue =⟨ ap-∘ (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) (WedgeAssocInl.f X₀ Y₀ Z₀) wglue ⟩ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) (ap (WedgeAssocInl.f X₀ Y₀ Z₀) wglue) =⟨ ap (ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp)))) (WedgeAssocInl.glue-β X₀ Y₀ Z₀) ⟩ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) wglue =⟨ WedgeFmap.glue-β (f , idp) (⊙∨-fmap (g , idp) (h , idp)) ⟩ wglue =⟨ ! $ WedgeAssocInl.glue-β X₁ Y₁ Z₁ ⟩ ap (WedgeAssocInl.f X₁ Y₁ Z₁) wglue =⟨ ! $ ap (ap (WedgeAssocInl.f X₁ Y₁ Z₁)) $ WedgeFmap.glue-β (f , idp) (g , idp) ⟩ ap (WedgeAssocInl.f X₁ Y₁ Z₁) (ap (∨-fmap (f , idp) (g , idp)) wglue) =⟨ ∘-ap (WedgeAssocInl.f X₁ Y₁ Z₁) (∨-fmap (f , idp) (g , idp)) wglue ⟩ ap (WedgeAssocInl.f X₁ Y₁ Z₁ ∘ ∨-fmap (f , idp) (g , idp)) wglue =∎)) (λ _ → idp) (↓-='-in' $ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp)) ∘ WedgeAssoc.f X₀ Y₀ Z₀) wglue =⟨ ap-∘ (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) (WedgeAssoc.f X₀ Y₀ Z₀) wglue ⟩ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) (ap (WedgeAssoc.f X₀ Y₀ Z₀) wglue) =⟨ ap (ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp)))) (WedgeAssoc.glue-β X₀ Y₀ Z₀) ⟩ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) (wglue ∙ ap winr wglue) =⟨ ap-∙ (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) wglue (ap winr wglue) ⟩ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) wglue ∙ ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) (ap winr wglue) =⟨ ap2 _∙_ (WedgeFmap.glue-β (f , idp) (⊙∨-fmap (g , idp) (h , idp))) ( ∘-ap (∨-fmap (f , idp) (⊙∨-fmap (g , idp) (h , idp))) winr wglue ∙ ap-∘ winr (∨-fmap (g , idp) (h , idp)) wglue ∙ ap (ap winr) (WedgeFmap.glue-β (g , idp) (h , idp))) ⟩ wglue ∙ ap winr wglue =⟨ ! $ WedgeAssoc.glue-β X₁ Y₁ Z₁ ⟩ ap (WedgeAssoc.f X₁ Y₁ Z₁) wglue =⟨ ! $ ap (ap (WedgeAssoc.f X₁ Y₁ Z₁)) $ WedgeFmap.glue-β (⊙∨-fmap (f , idp) (g , idp)) (h , idp) ⟩ ap (WedgeAssoc.f X₁ Y₁ Z₁) (ap (∨-fmap (⊙∨-fmap (f , idp) (g , idp)) (h , idp)) wglue) =⟨ ∘-ap (WedgeAssoc.f X₁ Y₁ Z₁) (∨-fmap (⊙∨-fmap (f , idp) (g , idp)) (h , idp)) wglue ⟩ ap (WedgeAssoc.f X₁ Y₁ Z₁ ∘ ∨-fmap (⊙∨-fmap (f , idp) (g , idp)) (h , idp)) wglue =∎)) , idp -} module _ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (f : X ⊙→ W) (g : Y ⊙→ W) (h : Z ⊙→ W) where ⊙Wedge-rec-assoc : ⊙Wedge-rec (⊙Wedge-rec f g) h ⊙∼ ⊙Wedge-rec f (⊙Wedge-rec g h) ⊙∘ ⊙–> (⊙∨-assoc X Y Z) ⊙Wedge-rec-assoc = (Wedge-elim (Wedge-elim (λ x → idp) (λ y → idp) (↓-='-in' $ ap-∘ (⊙WedgeRec.f f (⊙Wedge-rec g h)) (WedgeAssocInl.f X Y Z) wglue ∙ ap (ap (⊙WedgeRec.f f (⊙Wedge-rec g h))) (WedgeAssocInl.glue-β X Y Z) ∙ ⊙WedgeRec.glue-β f (⊙Wedge-rec g h) ∙ ! (⊙WedgeRec.glue-β f g))) (λ z → idp) (↓-='-in' $ ap-∘ (⊙WedgeRec.f f (⊙Wedge-rec g h)) (WedgeAssoc.f X Y Z) wglue ∙ ap (ap (⊙WedgeRec.f f (⊙Wedge-rec g h))) (WedgeAssoc.glue-β X Y Z) ∙ ap-∙ (⊙WedgeRec.f f (⊙Wedge-rec g h)) wglue (ap winr wglue) ∙ _∙2_ (⊙WedgeRec.glue-β f (⊙Wedge-rec g h)) ( ∘-ap (⊙WedgeRec.f f (⊙Wedge-rec g h)) winr wglue ∙ ⊙WedgeRec.glue-β g h) ∙ ∙-assoc (snd f) (! (snd g)) (snd g ∙ ! (snd h)) ∙ ap (snd f ∙_) (! $ ∙-assoc (! (snd g)) (snd g) (! (snd h))) ∙ ap (λ p → snd f ∙ p ∙ ! (snd h)) (!-inv-l (snd g)) ∙ ! (⊙WedgeRec.glue-β (⊙Wedge-rec f g) h))) , idp ⊙∨-rec-assoc = ⊙Wedge-rec-assoc
{ "alphanum_fraction": 0.4484688168, "avg_line_length": 37.4438095238, "ext": "agda", "hexsha": "22c3ea751a6040242164aeac58b92775e89dd1fc", "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/Wedge.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/Wedge.agda", "max_line_length": 116, "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/Wedge.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": 9873, "size": 19658 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.StrictCats where -- The (large) 'strict' category of (small) categories. -- The difference here is that _≈_ is not |NaturalIsomorphism| but |_≈F_| open import Level open import Relation.Binary.PropositionalEquality using (refl) open import Categories.Category using (Category) open import Categories.Functor using (Functor; id; _∘F_) open import Categories.Functor.Equivalence private variable o ℓ e : Level Cats : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) Cats o ℓ e = record { Obj = Category o ℓ e ; _⇒_ = Functor ; _≈_ = _≡F_ ; id = id ; _∘_ = _∘F_ ; assoc = λ {_ _ _ _ F G H} → ≡F-assoc {F = F} {G} {H} ; sym-assoc = λ {_ _ _ _ F G H} → ≡F-sym-assoc {F = F} {G} {H} ; identityˡ = ≡F-identityˡ ; identityʳ = ≡F-identityʳ ; identity² = ≡F-identity² ; equiv = ≡F-equiv ; ∘-resp-≈ = ∘F-resp-≡F }
{ "alphanum_fraction": 0.6026970954, "avg_line_length": 29.2121212121, "ext": "agda", "hexsha": "6dc439972c0dd7000c33834003440cb4ed6e9d7f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/StrictCats.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/StrictCats.agda", "max_line_length": 73, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/StrictCats.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": 369, "size": 964 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Setoids.Setoids open import Rings.Definition open import Rings.Ideals.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Rings.Ideals.Prime.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} {c : _} {pred : A → Set c} (i : Ideal R pred) where record PrimeIdeal : Set (a ⊔ c) where field isPrime : {a b : A} → pred (a * b) → ((pred a) → False) → pred b notContained : A notContainedIsNotContained : (pred notContained) → False
{ "alphanum_fraction": 0.6502463054, "avg_line_length": 35.8235294118, "ext": "agda", "hexsha": "b23f247935df70bcc6f1946af93cfa17838dd05a", "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": "Rings/Ideals/Prime/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Rings/Ideals/Prime/Definition.agda", "max_line_length": 176, "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": "Rings/Ideals/Prime/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 205, "size": 609 }
-- {-# OPTIONS -v interaction:100 #-} module Issue810 where record T (A : Set) : Set where constructor mkT field unT : A introHid : {A : Set} → T A introHid = {!!} data Sg {A : Set} : A → Set where sg : (a : A) → Sg a intro : ∀ {A}{a : A} → Sg a intro = {!!} intro′ : ∀ {A}(a : A) → Sg a intro′ = {!!}
{ "alphanum_fraction": 0.5207667732, "avg_line_length": 16.4736842105, "ext": "agda", "hexsha": "33cba6adefe917f934a5c3a24483d5f9e0bc6d8b", "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/Issue810.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/Issue810.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue810.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": 124, "size": 313 }
{-# OPTIONS --without-K --safe #-} module Definition.Typed.Consequences.InverseUniv where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Consequences.Syntactic import Tools.Sum as Sum open import Tools.Sum using (_⊎_; inj₁; inj₂) open import Tools.Product open import Tools.Empty open import Tools.Nullary -- Proposition for terms if they contain a U. data UFull : Term → Set where ∃U : UFull U ∃Π₁ : ∀ {F G} → UFull F → UFull (Π F ▹ G) ∃Π₂ : ∀ {F G} → UFull G → UFull (Π F ▹ G) -- Terms cannot contain U. noU : ∀ {t A Γ} → Γ ⊢ t ∷ A → ¬ (UFull t) noU (ℕⱼ x) () noU (Πⱼ t ▹ t₁) (∃Π₁ ufull) = noU t ufull noU (Πⱼ t ▹ t₁) (∃Π₂ ufull) = noU t₁ ufull noU (var x₁ x₂) () noU (lamⱼ x t₁) () noU (t ∘ⱼ t₁) () noU (zeroⱼ x) () noU (sucⱼ t) () noU (natrecⱼ x t t₁ t₂) () noU (conv t₁ x) ufull = noU t₁ ufull -- Neutrals cannot contain U. noUNe : ∀ {A} → Neutral A → ¬ (UFull A) noUNe (var n) () noUNe (∘ₙ neA) () noUNe (natrecₙ neA) () -- Helper function where if at least one Π-type does not contain U, -- one of F and H will not contain U and one of G and E will not contain U. pilem : ∀ {F G H E} → (¬ UFull (Π F ▹ G)) ⊎ (¬ UFull (Π H ▹ E)) → (¬ UFull F) ⊎ (¬ UFull H) × (¬ UFull G) ⊎ (¬ UFull E) pilem (inj₁ x) = inj₁ (λ x₁ → x (∃Π₁ x₁)) , inj₁ (λ x₁ → x (∃Π₂ x₁)) pilem (inj₂ x) = inj₂ (λ x₁ → x (∃Π₁ x₁)) , inj₂ (λ x₁ → x (∃Π₂ x₁)) -- If type A does not contain U, then A can be a term of type U. inverseUniv : ∀ {A Γ} → ¬ (UFull A) → Γ ⊢ A → Γ ⊢ A ∷ U inverseUniv q (ℕⱼ x) = ℕⱼ x inverseUniv q (Uⱼ x) = ⊥-elim (q ∃U) inverseUniv q (Πⱼ A ▹ A₁) = Πⱼ inverseUniv (λ x → q (∃Π₁ x)) A ▹ inverseUniv (λ x → q (∃Π₂ x)) A₁ inverseUniv q (univ x) = x -- If A is a neutral type, then A can be a term of U. inverseUnivNe : ∀ {A Γ} → Neutral A → Γ ⊢ A → Γ ⊢ A ∷ U inverseUnivNe neA ⊢A = inverseUniv (noUNe neA) ⊢A -- Helper function where if at least one type does not contain U, then the -- equality of types can be an equality of term of type U. inverseUnivEq′ : ∀ {A B Γ} → (¬ (UFull A)) ⊎ (¬ (UFull B)) → Γ ⊢ A ≡ B → Γ ⊢ A ≡ B ∷ U inverseUnivEq′ q (univ x) = x inverseUnivEq′ q (refl x) = refl (inverseUniv (Sum.id q) x) inverseUnivEq′ q (sym A≡B) = sym (inverseUnivEq′ (Sum.sym q) A≡B) inverseUnivEq′ (inj₁ x) (trans A≡B A≡B₁) = let w = inverseUnivEq′ (inj₁ x) A≡B _ , _ , t = syntacticEqTerm w y = noU t in trans w (inverseUnivEq′ (inj₁ y) A≡B₁) inverseUnivEq′ (inj₂ x) (trans A≡B A≡B₁) = let w = inverseUnivEq′ (inj₂ x) A≡B₁ _ , t , _ = syntacticEqTerm w y = noU t in trans (inverseUnivEq′ (inj₂ y) A≡B) w inverseUnivEq′ q (Π-cong x A≡B A≡B₁) = let w , e = pilem q in Π-cong x (inverseUnivEq′ w A≡B) (inverseUnivEq′ e A≡B₁) -- If A is a term of U, then the equality of types is an equality of terms of type U. inverseUnivEq : ∀ {A B Γ} → Γ ⊢ A ∷ U → Γ ⊢ A ≡ B → Γ ⊢ A ≡ B ∷ U inverseUnivEq A A≡B = inverseUnivEq′ (inj₁ (noU A)) A≡B
{ "alphanum_fraction": 0.60742254, "avg_line_length": 35.3855421687, "ext": "agda", "hexsha": "25adedaecafd3cc18a9538246f818bc8e372cf55", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/InverseUniv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/InverseUniv.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/InverseUniv.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1310, "size": 2937 }
{-# OPTIONS --cubical #-} module Erased-cubical-Open-public.Cubical where -- It instantiates and exports code from -- Erased-cubical-Open-public.Erased. open import Erased-cubical-Open-public.Erased Set public
{ "alphanum_fraction": 0.7699530516, "avg_line_length": 23.6666666667, "ext": "agda", "hexsha": "ad665eab19827a4368e0063bbd2525af9b9848c7", "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": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Erased-cubical-Open-public/Cubical.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "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-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Erased-cubical-Open-public/Cubical.agda", "max_line_length": 56, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Erased-cubical-Open-public/Cubical.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 59, "size": 213 }
{- The flattening lemma for pushouts (Lemma 8.5.3 in the HoTT book) proved in a cubical style. The proof in the HoTT book (the core lying in Lemma 6.12.2, the flattening lemma for coequalizers) consists mostly of long strings of equalities about transport. This proof follows almost entirely from definitional equalities involving glue/unglue. -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Pushout.Flattening where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Data.Sigma open import Cubical.HITs.Pushout.Base module FlatteningLemma {ℓa ℓb ℓc} {A : Type ℓa} {B : Type ℓb} {C : Type ℓc} (f : A → B) (g : A → C) {ℓ} (F : B → Type ℓ) (G : C → Type ℓ) (e : ∀ a → F (f a) ≃ G (g a)) where E : Pushout f g → Type ℓ E (inl x) = F x E (inr x) = G x E (push a i) = ua (e a) i Σf : Σ[ a ∈ A ] F (f a) → Σ[ b ∈ B ] F b Σf (a , x) = (f a , x) Σg : Σ[ a ∈ A ] F (f a) → Σ[ c ∈ C ] G c Σg (a , x) = (g a , (e a) .fst x) module FlattenIso where fwd : Pushout Σf Σg → Σ (Pushout f g) E fwd (inl (b , x)) = (inl b , x) fwd (inr (c , x)) = (inr c , x) fwd (push (a , x) i) = (push a i , ua-gluePt (e a) i x) bwd : Σ (Pushout f g) E → Pushout Σf Σg bwd (inl b , x) = inl (b , x) bwd (inr c , x) = inr (c , x) bwd (push a i , x) = hcomp (λ j → λ { (i = i0) → push (a , x) (~ j) ; (i = i1) → inr (g a , x) }) (inr (g a , ua-unglue (e a) i x)) bwd-fwd : ∀ x → bwd (fwd x) ≡ x bwd-fwd (inl (b , x)) = refl bwd-fwd (inr (c , x)) = refl bwd-fwd (push (a , x) i) j = hcomp (λ k → λ { (i = i0) → push (a , ua-gluePt (e a) i0 x) (~ k) ; (i = i1) → inr (g a , ua-gluePt (e a) i1 x) ; (j = i1) → push (a , x) (i ∨ ~ k) }) (inr (g a , ua-unglue (e a) i (ua-gluePt (e a) i x))) -- Note: the (j = i1) case typechecks because of the definitional equalities: -- ua-gluePt e i0 x ≡ x , ua-gluePt e i1 x ≡ e .fst x, -- ua-unglue-glue : ua-unglue e i (ua-gluePt e i x) ≡ e .fst x -- essentially: ua-glue e (i ∨ ~ k) ∘ ua-unglue e i sq : ∀ {ℓ} {A B : Type ℓ} (e : A ≃ B) → SquareP (λ i k → ua e i → ua e (i ∨ ~ k)) {- i = i0 -} (λ k x → ua-gluePt e (~ k) x) {- i = i1 -} (λ k x → x) {- k = i0 -} (λ i x → ua-unglue e i x) {- k = i1 -} (λ i x → x) sq e i k x = ua-glue e (i ∨ ~ k) (λ { ((i ∨ ~ k) = i0) → x }) (inS (ua-unglue e i x)) -- Note: this typechecks because of the definitional equalities: -- ua-unglue e i0 x ≡ e .fst x, ua-glue e i1 _ (inS y) ≡ y, ua-unglue e i1 x ≡ x, -- ua-glue-unglue : ua-glue e i (λ { (i = i0) → x }) (inS (ua-unglue e i x)) ≡ x fwd-bwd : ∀ x → fwd (bwd x) ≡ x fwd-bwd (inl b , x) = refl fwd-bwd (inr c , x) = refl fwd-bwd (push a i , x) j = -- `fwd` (or any function) takes hcomps to comps on a constant family, so we must use a comp here comp (λ _ → Σ (Pushout f g) E) (λ k → λ { (i = i0) → push a (~ k) , ua-gluePt (e a) (~ k) x ; (i = i1) → inr (g a) , x ; (j = i1) → push a (i ∨ ~ k) , sq (e a) i k x }) (inr (g a) , ua-unglue (e a) i x) isom : Iso (Σ (Pushout f g) E) (Pushout Σf Σg) isom = iso bwd fwd bwd-fwd fwd-bwd flatten : Σ (Pushout f g) E ≃ Pushout Σf Σg flatten = isoToEquiv FlattenIso.isom
{ "alphanum_fraction": 0.5002714441, "avg_line_length": 40.0434782609, "ext": "agda", "hexsha": "0f89700caf0b6d7a4fd0c70941687a10dea04768", "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/Pushout/Flattening.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/Pushout/Flattening.agda", "max_line_length": 103, "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/Pushout/Flattening.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1508, "size": 3684 }
module Issue794a where open import Common.Prelude open import Common.MAlonzo postulate A : Set id : .A → A → A id x y = y
{ "alphanum_fraction": 0.712, "avg_line_length": 12.5, "ext": "agda", "hexsha": "d169417458750cfaf1cdebc195640492eb2aaa5b", "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/Issue794a.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/Issue794a.agda", "max_line_length": 26, "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/Issue794a.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": 41, "size": 125 }
{- Definition of vectors. Inspired by the Agda Standard Library -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Vec.Base where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat open import Cubical.Data.FinData private variable ℓ ℓ' : Level A : Type ℓ infixr 5 _∷_ data Vec (A : Type ℓ) : ℕ → Type ℓ where [] : Vec A zero _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) -- Basic functions length : ∀ {n} → Vec A n → ℕ length {n = n} _ = n head : ∀ {n} → Vec A (1 + n) → A head (x ∷ xs) = x tail : ∀ {n} → Vec A (1 + n) → Vec A n tail (x ∷ xs) = xs map : ∀ {A : Type ℓ} {B : Type ℓ'} {n} → (A → B) → Vec A n → Vec B n map f [] = [] map f (x ∷ xs) = f x ∷ map f xs replicate : ∀ {n} {A : Type ℓ} → A → Vec A n replicate {n = zero} x = [] replicate {n = suc n} x = x ∷ replicate x -- Concatenation infixr 5 _++_ _++_ : ∀ {m n} → Vec A m → Vec A n → Vec A (m + n) [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) concat : ∀ {m n} → Vec (Vec A m) n → Vec A (n · m) concat [] = [] concat (xs ∷ xss) = xs ++ concat xss lookup : ∀ {n} {A : Type ℓ} → Fin n → Vec A n → A lookup zero (x ∷ xs) = x lookup (suc i) (x ∷ xs) = lookup i xs
{ "alphanum_fraction": 0.5256723716, "avg_line_length": 21.1551724138, "ext": "agda", "hexsha": "005365dd2751e2091f9c102a630330f9c164e5b0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Vec/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Vec/Base.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Vec/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 494, "size": 1227 }
{-# OPTIONS --without-K #-} module HIT.Interval where open import PathOperations open import PathStructure.Id.Tr open import Types module I-Definition where private data #I : Set where #0 : #I #1 : #I I : Set I = #I 0ᵢ : I 0ᵢ = #0 1ᵢ : I 1ᵢ = #1 postulate seg : 0ᵢ ≡ 1ᵢ I-ind : ∀ {p} (P : I → Set p) (x₀ : P 0ᵢ) (x₁ : P 1ᵢ) (p : tr P seg x₀ ≡ x₁) → ∀ i → P i I-ind P x₀ x₁ p #0 = x₀ I-ind P x₀ x₁ p #1 = x₁ postulate I-β-i : ∀ {p} (P : I → Set p) (x₀ : P 0ᵢ) (x₁ : P 1ᵢ) (p : tr P seg x₀ ≡ x₁) → apd (I-ind P x₀ x₁ p) seg ≡ p I-rec : ∀ {p} {P : Set p} (x₀ x₁ : P) (p : x₀ ≡ x₁) (i : I) → P I-rec x₀ x₁ p #0 = x₀ I-rec x₀ x₁ p #1 = x₁ postulate I-β-r : ∀ {p} {P : Set p} (x₀ x₁ : P) (p : x₀ ≡ x₁) → ap (I-rec x₀ x₁ p) seg ≡ p open I-Definition public from-path-space : ∀ {a} {A : Set a} → (Σ A λ x → Σ A λ y → x ≡ y) → I → A from-path-space (x , y , p) = I-rec x y p to-path-space : ∀ {a} {A : Set a} → (I → A) → Σ A λ x → Σ A λ y → x ≡ y to-path-space f = f 0ᵢ , f 1ᵢ , ap f seg
{ "alphanum_fraction": 0.4709618875, "avg_line_length": 19, "ext": "agda", "hexsha": "03e3495f88bf43678951313e2dfaa03c5ad9e29d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_path": "src/HIT/Interval.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_path": "src/HIT/Interval.agda", "max_line_length": 52, "max_stars_count": null, "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_path": "src/HIT/Interval.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 550, "size": 1102 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some properties of equivalence closures. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.Construct.Closure.Equivalence.Properties where open import Data.Sum.Base using (inj₁) open import Function using (_∘′_) open import Relation.Binary.Core using (Rel) open import Relation.Binary.Construct.Closure.Equivalence open import Relation.Binary.Construct.Closure.ReflexiveTransitive as RTrans module _ {a ℓ} {A : Set a} {_⟶_ : Rel A ℓ} where private _—↠_ = Star _⟶_ _↔_ = EqClosure _⟶_ a—↠b⇒a↔b : ∀ {a b} → a —↠ b → a ↔ b a—↠b⇒a↔b = RTrans.map inj₁ a—↠b⇒b↔a : ∀ {a b} → a —↠ b → b ↔ a a—↠b⇒b↔a = symmetric _ ∘′ a—↠b⇒a↔b a—↠b&a—↠c⇒b↔c : ∀ {a b c} → a —↠ b → a —↠ c → b ↔ c a—↠b&a—↠c⇒b↔c a—↠b b—↠c = a—↠b⇒b↔a a—↠b ◅◅ a—↠b⇒a↔b b—↠c
{ "alphanum_fraction": 0.521141649, "avg_line_length": 30.5161290323, "ext": "agda", "hexsha": "d5b66ba124a9f90d5f192cd439e9b6df84116d2a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Construct/Closure/Equivalence/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Construct/Closure/Equivalence/Properties.agda", "max_line_length": 75, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Construct/Closure/Equivalence/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 373, "size": 946 }
module Bin-predicates where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; cong) open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; _+_; _*_) open import Data.Nat.Properties using (+-identityʳ; +-suc; +-assoc; +-comm) -- 2進数の表現 data Bin : Set where ⟨⟩ : Bin _O : Bin → Bin _I : Bin → Bin -- 2進数のインクリメント inc : Bin → Bin inc ⟨⟩ = ⟨⟩ I inc (b O) = b I inc (b I) = inc b O -- 自然数から2進数への変換 to : ℕ → Bin to zero = ⟨⟩ O to (suc n) = inc (to n) -- 2進数から自然数への変換 from : Bin → ℕ from ⟨⟩ = zero from (b O) = 2 * (from b) from (b I) = 2 * (from b) + 1 2*n≡n+n : ∀ (n : ℕ) → 2 * n ≡ n + n 2*n≡n+n n rewrite +-identityʳ n = refl +-suc-suc : ∀ (m n : ℕ) → (suc m) + (suc n) ≡ suc (suc (m + n)) +-suc-suc m n rewrite +-suc (suc m) n | sym (+-assoc 1 m n) = refl -- 変換の前後どちらでインクリメントしても結果は等しい from∘inc≡suc∘from : ∀ (b : Bin) → from (inc b) ≡ suc (from b) from∘inc≡suc∘from ⟨⟩ = refl from∘inc≡suc∘from (b O) rewrite +-suc (from (b O)) zero | +-identityʳ (from (b O)) = refl from∘inc≡suc∘from (b I) rewrite from∘inc≡suc∘from b | 2*n≡n+n (suc (from b)) | +-suc-suc (from b) (from b) | sym (2*n≡n+n (from b)) | +-comm 1 (2 * (from b)) = refl data One : Bin → Set where ⟨⟩I : One (⟨⟩ I) _O : ∀ {b : Bin} → One b → One (b O) _I : ∀ {b : Bin} → One b → One (b I) data Can : Bin → Set where ⟨⟩O : Can (⟨⟩ O) can : ∀ {b : Bin} → One b → Can b -- Can b -- ------------ -- Can (inc b) inc-one : ∀ {b : Bin} → One b → One (inc b) inc-one ⟨⟩I = ⟨⟩I O inc-one (ob O) = ob I inc-one (ob I) = (inc-one ob) O inc-can : ∀ {b : Bin} → Can b → Can (inc b) inc-can ⟨⟩O = can ⟨⟩I inc-can (can ⟨⟩I) = can (⟨⟩I O) inc-can (can (ob O)) = can (ob I) inc-can (can (ob I)) = can (inc-one (ob I)) -- ---------- -- Can (to n) can-ℕ : ∀ (n : ℕ) → Can (to n) can-ℕ zero = ⟨⟩O can-ℕ (suc n) = inc-can (can-ℕ n) -- Can b -- --------------- -- to (from b) ≡ b to∘from∘inc≡inc∘to∘from : ∀ (b : Bin) → to (from (inc b)) ≡ inc (to (from b)) to∘from∘inc≡inc∘to∘from ⟨⟩ = begin to (from (inc ⟨⟩)) ≡⟨⟩ to (from (⟨⟩ I)) ≡⟨⟩ to 1 ≡⟨⟩ ⟨⟩ I ≡⟨⟩ inc ⟨⟩ ≡⟨⟩ inc (to zero) ≡⟨⟩ inc (to (from ⟨⟩)) ∎ to∘from∘inc≡inc∘to∘from (b O) = begin to (from (inc (b O))) ≡⟨⟩ to (from (b I)) ≡⟨⟩ to (2 * (from b) + 1) ≡⟨⟩ to (2 * (from b) + (suc zero)) ≡⟨ cong to (+-suc (2 * (from b)) zero) ⟩ to (suc (2 * (from b) + zero)) ≡⟨ cong (λ 2*fromb → to (suc 2*fromb)) (+-identityʳ (2 * (from b))) ⟩ to (suc (2 * (from b))) ≡⟨⟩ inc (to (2 * (from b))) ≡⟨⟩ inc (to (from (b O))) ∎ to∘from∘inc≡inc∘to∘from (b I) = begin to (from (inc (b I))) ≡⟨⟩ to (from ((inc b) O)) ≡⟨⟩ to (2 * (from (inc b))) ≡⟨ cong (λ suc∘fromb → to (2 * suc∘fromb)) (from∘inc≡suc∘from b) ⟩ to (2 * (suc (from b))) ≡⟨ cong to (2*n≡n+n (suc (from b))) ⟩ to ((suc (from b)) + (suc (from b))) ≡⟨ cong to (+-suc-suc (from b) (from b)) ⟩ to (suc (suc ((from b) + (from b)))) ≡⟨ cong (λ 2*fromb → to (suc (suc 2*fromb))) (sym (2*n≡n+n (from b))) ⟩ to (suc (suc (2 * (from b)))) ≡⟨ cong (λ 2*fromb+1 → to (suc 2*fromb+1)) (+-comm 1 (2 * (from b))) ⟩ to (suc (2 * (from b) + 1)) ≡⟨⟩ to (suc (from (b I))) ≡⟨⟩ inc (to (from (b I))) ∎ to∘from : ∀ {b : Bin} → Can b → to (from b) ≡ b to∘from ⟨⟩O = begin to (from (⟨⟩ O)) ≡⟨⟩ to (2 * from ⟨⟩) ≡⟨⟩ to (2 * zero) ≡⟨⟩ to zero ≡⟨⟩ ⟨⟩ O ∎ to∘from (can ⟨⟩I) = begin to (from (⟨⟩ I)) ≡⟨⟩ to (2 * from ⟨⟩ + 1) ≡⟨⟩ to (2 * zero + 1) ≡⟨⟩ to 1 ≡⟨⟩ ⟨⟩ I ∎ to∘from {b O} (can (ob O)) = {!!} -- TODO to∘from {b I} (can (ob I)) = begin to (from (b I)) ≡⟨⟩ to (from (inc (b O))) ≡⟨ to∘from∘inc≡inc∘to∘from (b O) ⟩ inc (to (from (b O))) ≡⟨ cong inc (to∘from (can (ob O))) ⟩ inc (b O) ≡⟨⟩ b I ∎
{ "alphanum_fraction": 0.4660445827, "avg_line_length": 22.0457142857, "ext": "agda", "hexsha": "bea210efbe0a0bd5f26cbe365026d382450abaf5", "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": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_path": "part1/relations/Bin-predicates.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "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": "akiomik/plfa-solutions", "max_issues_repo_path": "part1/relations/Bin-predicates.agda", "max_line_length": 164, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/relations/Bin-predicates.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "num_tokens": 1956, "size": 3858 }
module Issue1258-2 where data Nat : Set where zero : Nat suc : Nat -> Nat data _==_ {A : Set}(x : A) : A -> Set where refl : x == x data Bool : Set where true false : Bool data Σ (A : Set) (B : A → Set) : Set where _,_ : (x : A) → B x → Σ A B _×_ : Set → Set → Set A × B = Σ A (λ _ → B) postulate f : (A : Set) -> A -> Bool record Wrap (A : Set) : Set where constructor wrap field wrapped : A data ⊥ : Set where Foo : Bool -> Set Foo true = ⊥ Foo false = ⊥ Alpha : Bool Stuck = Foo Alpha Beta : Stuck test : f (Bool × Wrap Nat) (true , wrap zero) == f (Stuck × Stuck) (Beta , Beta) Alpha = _ Beta = _ test = refl
{ "alphanum_fraction": 0.5572755418, "avg_line_length": 16.5641025641, "ext": "agda", "hexsha": "370daef6aabc4f9b245a0d06e7da0bbcedd6dbbd", "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/Issue1258-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/Issue1258-2.agda", "max_line_length": 80, "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/Issue1258-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": 242, "size": 646 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Structures for types of functions ------------------------------------------------------------------------ -- The contents of this file should usually be accessed from `Function`. {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Function.Structures {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} (_≈₁_ : Rel A ℓ₁) (_≈₂_ : Rel B ℓ₂) where open import Data.Product using (∃; _×_; _,_) open import Function.Base open import Function.Definitions open import Level using (_⊔_) ------------------------------------------------------------------------ -- Definitions record IsCongruent (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field cong : Congruent _≈₁_ _≈₂_ f isEquivalence₁ : IsEquivalence _≈₁_ isEquivalence₂ : IsEquivalence _≈₂_ module Eq₁ where setoid : Setoid a ℓ₁ setoid = record { isEquivalence = isEquivalence₁ } open Setoid setoid public module Eq₂ where setoid : Setoid b ℓ₂ setoid = record { isEquivalence = isEquivalence₂ } open Setoid setoid public record IsInjection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isCongruent : IsCongruent f injective : Injective _≈₁_ _≈₂_ f open IsCongruent isCongruent public record IsSurjection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isCongruent : IsCongruent f surjective : Surjective _≈₁_ _≈₂_ f open IsCongruent isCongruent public record IsBijection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isInjection : IsInjection f surjective : Surjective _≈₁_ _≈₂_ f open IsInjection isInjection public bijective : Bijective _≈₁_ _≈₂_ f bijective = injective , surjective isSurjection : IsSurjection f isSurjection = record { isCongruent = isCongruent ; surjective = surjective } record IsLeftInverse (f : A → B) (g : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isCongruent : IsCongruent f cong₂ : Congruent _≈₂_ _≈₁_ g inverseˡ : Inverseˡ _≈₁_ _≈₂_ f g open IsCongruent isCongruent public renaming (cong to cong₁) record IsRightInverse (f : A → B) (g : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isCongruent : IsCongruent f cong₂ : Congruent _≈₂_ _≈₁_ g inverseʳ : Inverseʳ _≈₁_ _≈₂_ f g open IsCongruent isCongruent public renaming (cong to cong₁) record IsBiEquivalence (f : A → B) (g₁ : B → A) (g₂ : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field f-isCongruent : IsCongruent f cong₂ : Congruent _≈₂_ _≈₁_ g₁ cong₃ : Congruent _≈₂_ _≈₁_ g₂ open IsCongruent f-isCongruent public renaming (cong to cong₁) record IsBiInverse (f : A → B) (g₁ : B → A) (g₂ : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field f-isCongruent : IsCongruent f cong₂ : Congruent _≈₂_ _≈₁_ g₁ inverseˡ : Inverseˡ _≈₁_ _≈₂_ f g₁ cong₃ : Congruent _≈₂_ _≈₁_ g₂ inverseʳ : Inverseʳ _≈₁_ _≈₂_ f g₂ open IsCongruent f-isCongruent public renaming (cong to cong₁) record IsInverse (f : A → B) (g : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isLeftInverse : IsLeftInverse f g inverseʳ : Inverseʳ _≈₁_ _≈₂_ f g open IsLeftInverse isLeftInverse public isRightInverse : IsRightInverse f g isRightInverse = record { isCongruent = isCongruent ; cong₂ = cong₂ ; inverseʳ = inverseʳ } inverse : Inverseᵇ _≈₁_ _≈₂_ f g inverse = inverseˡ , inverseʳ
{ "alphanum_fraction": 0.5947086969, "avg_line_length": 25.1985815603, "ext": "agda", "hexsha": "d1659aadf84e832df950b7bb2dde4df4a14d3145", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Function/Structures.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Function/Structures.agda", "max_line_length": 75, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Function/Structures.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": 1314, "size": 3553 }
-- Andreas, 2016-07-28, issue #779 record P : Set where postulate Bla : Set field F : Set -- Current error: -- Missing definition for Bla -- Expected: -- Success, or error outlawing postulate before last field.
{ "alphanum_fraction": 0.6972477064, "avg_line_length": 18.1666666667, "ext": "agda", "hexsha": "ab25e854be6051537d8df533234b2e022c061434", "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/Issue779postulate.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/Issue779postulate.agda", "max_line_length": 59, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue779postulate.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 62, "size": 218 }
{- This is a HoTT-UF core library based on cubical type theory, where the cubical machinery is hidden, using the HoTT Book terminology and notation. The point is that function extensionality, propositional truncation and univalence compute (an example is given below). For the moment, this requires the development version of Agda. -} {-# OPTIONS --cubical --exact-split --safe #-} module Cubical.Foundations.HoTT-UF where open import Cubical.Core.Primitives hiding ( _≡_ ) open import Cubical.Core.Id public open import Cubical.Foundations.Id public using ( _≡_ -- The identity type. ; refl -- Unfortunately, pattern matching on refl is not available. ; J -- Until it is, you have to use the induction principle J. ; transport -- As in the HoTT Book. ; ap ; _∙_ ; _⁻¹ ; _≡⟨_⟩_ -- Standard equational reasoning. ; _∎ ; funExt -- Function extensionality -- (can also be derived from univalence). ; Σ -- Sum type. Needed to define contractible types, equivalences ; _,_ -- and univalence. ; pr₁ -- The eta rule is available. ; pr₂ ; isProp -- The usual notions of proposition, contractible type, set. ; isContr ; isSet ; isEquiv -- A map with contractible fibers -- (Voevodsky's version of the notion). ; _≃_ -- The type of equivalences between two given types. ; EquivContr -- A formulation of univalence. ; ∥_∥ -- Propositional truncation. ; ∣_∣ -- Map into the propositional truncation. ; ∥∥-isProp -- A truncated type is a proposition. ; ∥∥-recursion -- Non-dependent elimination. ; ∥∥-induction -- Dependent elimination. ) {- Here is an illustration of how function extensionality computes. -} private data ℕ : Type₀ where zero : ℕ succ : ℕ → ℕ f g : ℕ → ℕ f n = n g zero = zero g (succ n) = succ (g n) h : (n : ℕ) → f n ≡ g n h zero = refl h (succ n) = ap succ (h n) p : f ≡ g p = funExt h five : ℕ five = succ (succ (succ (succ (succ zero)))) a : Σ ℕ (λ n → f n ≡ five) a = five , refl b : Σ ℕ (λ n → g n ≡ five) b = transport (λ - → Σ ℕ (λ n → - n ≡ five)) p a c : pr₁ b ≡ five c = refl {- If we had funExt as a postulate, then the definition of c would not type check. Moreover, the term pr₁ b would not evaluate to five, as it does with the cubical type theory implementation of funext. TODO. A similar computational example with univalence. -}
{ "alphanum_fraction": 0.5609929078, "avg_line_length": 26.8571428571, "ext": "agda", "hexsha": "51eadf7e64687bae04ead5286611318deffb8517", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Foundations/HoTT-UF.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Foundations/HoTT-UF.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Foundations/HoTT-UF.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 745, "size": 2820 }
module Logic.Relations where import Logic.Base import Data.Bool Rel : Set -> Set1 Rel A = A -> A -> Set Reflexive : {A : Set} -> Rel A -> Set Reflexive {A} _R_ = (x : A) -> x R x Symmetric : {A : Set} -> Rel A -> Set Symmetric {A} _R_ = (x y : A) -> x R y -> y R x Transitive : {A : Set} -> Rel A -> Set Transitive {A} _R_ = (x y z : A) -> x R y -> y R z -> x R z Congruent : {A : Set} -> Rel A -> Set Congruent {A} _R_ = (f : A -> A)(x y : A) -> x R y -> f x R f y Substitutive : {A : Set} -> Rel A -> Set1 Substitutive {A} _R_ = (P : A -> Set)(x y : A) -> x R y -> P x -> P y module PolyEq (_≡_ : {A : Set} -> Rel A) where Antisymmetric : {A : Set} -> Rel A -> Set Antisymmetric {A} _R_ = (x y : A) -> x R y -> y R x -> x ≡ y module MonoEq {A : Set}(_≡_ : Rel A) where Antisymmetric : Rel A -> Set Antisymmetric _R_ = (x y : A) -> x R y -> y R x -> x ≡ y open Logic.Base Total : {A : Set} -> Rel A -> Set Total {A} _R_ = (x y : A) -> (x R y) \/ (y R x) Decidable : (P : Set) -> Set Decidable P = P \/ ¬ P
{ "alphanum_fraction": 0.5145348837, "avg_line_length": 24, "ext": "agda", "hexsha": "a87a668b665b1195588a7885b36f559129963008", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/lib/Logic/Relations.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/lib/Logic/Relations.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/lib/Logic/Relations.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": 430, "size": 1032 }
{- -} -- starting from builtins -- forgot what the point of this was... module Oscar.Data6 where open import Oscar.Category.Semigroupoid open import Oscar.Category.Category open import Oscar.Category.Morphism open import Oscar.Category.Setoid open import Oscar.Function open import Agda.Builtin.Unit using () renaming (⊤ to 𝟙; tt to ∅) open import Agda.Builtin.Nat using () renaming (Nat to ℕ; zero to ∅; suc to ↑_) open import Agda.Builtin.List using () renaming (List to [_]ℕ; [] to ∅; _∷_ to _+_) open import Oscar.Level ⟦_⟧ℕ[<_↓] ⟦_⟧ℕ[_≤_↓] ⟦_⟧ℕ[↥_≤_] ⟦_⟧ℕ[↓_≤_↓] -- Fin (with a payload) data ⟦_⟧ℕ[0…_-1] {a} (A : ℕ → Set a) : ℕ → Set a where ∅ : ∀ {n} → ⟦ A ⟧ℕ[<↑ ↑ n ] _∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[ n ] → ⟦ A ⟧ℕ[<↑ ↑ n ] -- Vec (with an (optional) index) data ⟦_⟧ℕ[≤_] {a} (A : ℕ → Set a) : ℕ → Set a where ∅ : ⟦ A ⟧ℕ[ ∅ ₀] _∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[ n ₀] → ⟦ A ⟧ℕ[ ¡ n ₀] -- m ≤ n, counting down from n-1 to m data ⟦_⟧ℕ[_≤_↓] {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where ∅ : ⟦ A ⟧ℕ[ m ≤ m ↓] _∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[ m ≤ n ↓] → ⟦ A ⟧ℕ[ m ≤ ¡ n ↓] -- m ≤ n, counting up from m to n-1 data ⟦_⟧ℕ[↑_≤_] {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where ∅ : ⟦ A ⟧ℕ[↑ m ≤ m ] _∷_ : ∀ {n} → A m → ⟦ A ⟧ℕ[↑ ¡ m ≤ n ] → ⟦ A ⟧ℕ[↑ m ≤ n ] -- Inj (almost) data ⟦_⟧ℕ[↓_≤_↓] {a} (A : ℕ → ℕ → Set a) : ℕ → ℕ → Set a where ∅ : ∀ {n} → ⟦ A ⟧ℕ[↓ ∅ ≤ n ↓] _∷_ : ∀ {m n} → A m n → ⟦ A ⟧ℕ[↓ m ≤ n ↓] → ⟦ A ⟧ℕ[↓ ¡ m ≤ ¡ n ↓] ⟦_⟧ℕ[_⇒_]∞ : ∀ {a} (A : ℕ → Set a) → ℕ → ℕ → Set a ⟦ A ⟧ℕ[ m ⇒ n ]∞ = A m → A n -- Fin (with a payload) data ⟦_⟧ℕ[<_↓] {a} (A : ℕ → Set a) : ℕ → Set a where ∅ : ∀ {n} → ⟦ A ⟧[< ↑ n ↓] _∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[< n ] → ⟦ A ⟧[< ↑ n ↓] -- -- Vec (with an (optional) index) data ℕ[_]=_ {a} (A : ℕ → Set a) : ℕ → Set a where ∅ : ℕ[ A ]= ∅ _∷_ : ∀ {n} → A n → ℕ[ A ]= ↑ n → ℕ[ A ]= ↑ n ℕ=_ = ℕ[ const 𝟙 ]=_ -- m ≤ n, counting down from n-1 to m data ℕ[_]≥_<↓_ {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where ∅ : ℕ[ A ]≥ m <↓ m _∷_ : ∀ {n} → A n → ℕ[ A ]≥ m <↓ n → ℕ[ A ]≥ m <↓ ↑ n ℕ≥_<↓_ = ℕ[ const 𝟙 ]≥_<↓_ -- m ≤ n, counting up from m to n-1 data ℕ[_]≥↑_<_ {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where ∅ : ℕ[ A ]≥↑ m < m _∷_ : ∀ {n} → A m → ℕ[ A ]≥↑ ↑ m < n → ℕ[ A ]≥↑ m < n ℕ≥↑_<_ = ℕ[ const 𝟙 ]≥↑_<_ -- -- Inj (almost) -- data ⟦_⟧[↓_≤_↓] {a} (A : ⟦⟧ → ⟦⟧ → Set a) : ⟦⟧ → ⟦⟧ → Set a where -- ∅ : ∀ {n} → ⟦ A ⟧[↓ ∅ ≤ n ↓] -- _∷_ : ∀ {m n} → A m n → ⟦ A ⟧[↓ m ≤ n ↓] → ⟦ A ⟧[↓ ¡ m ≤ ¡ n ↓] -- ⟦⟧[↓_≤_↓] = ⟦ Const Const ⊤ ⟧[↓_≤_↓] -- ⟦_⟧[_⇒_]∞ : ∀ {a} (A : ⟦⟧ → Set a) → ⟦⟧ → ⟦⟧ → Set a -- ⟦ A ⟧[ m ⇒ n ]∞ = A m → A n -- --open import Oscar.Data.Equality -- --open import Oscar.Data.Equality.properties -- module _ {𝔬 𝔪 𝔮} (G : Semigroupoid 𝔬 𝔪 𝔮) where -- open Semigroupoid G -- {- -- _≋̇_ : ∀ {a} {A : ⋆ → Set a} {m n : ⋆} → (A m → A n) → (A m → A n) → Set 𝔮 -- _≋̇_ {A = A} {m = m} m→n₁ m→n₂ = {!∀ (am : A m) → m→n₁ am ≋ m→n₂ am!} -- cat2 : ∀ {a} (A : ⋆ → Set a) → Category {!!} {!!} {!!} -- Semigroupoid.⋆ (Category.semigroupoid (cat2 A)) = ⋆ -- Setoid.⋆ ((Semigroupoid.𝔐 (Category.semigroupoid (cat2 A)) Morphism.⇒ m) n) = A m → A n -- IsSetoid._≋_ (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2 A)) Morphism.⇒ m) n)) = _≡̇_ -- IsSetoid.isEquivalence (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2 A)) Morphism.⇒ m) n)) = it -- Semigroupoid._∙_ (Category.semigroupoid (cat2 A)) g f = g ∘ f -- Semigroupoid.isSemigroupoid (Category.semigroupoid (cat2 A)) = it -- Category.ε (cat2 A) = id -- Category.isCategory (cat2 A) = it -- cat2G : ∀ {a} (A : ⋆ → Set a) → ∀ ℓ ⦃ _ : ∀ {n : ⋆} → IsSetoid (A n) ℓ ⦄ → Category {!!} {!!} {!!} -- Semigroupoid.⋆ (Category.semigroupoid (cat2G A ℓ)) = ⋆ -- Setoid.⋆ ((Semigroupoid.𝔐 (Category.semigroupoid (cat2G A ℓ)) Morphism.⇒ m) n) = A m → A n -- IsSetoid._≋_ (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2G A ℓ)) Morphism.⇒ m) n)) m↦n₁ m↦n₂ = ∀ (am : A m) → m↦n₁ am ≋ m↦n₂ am -- -- ∀ (am : A m) → m↦n₁ am ≋ m↦n₂ am -- {- -- _≋̇_ : ∀ {a} {A : ⋆ → Set a} {m n : ⋆} → (A m → A n) → (A m → A n) → Set 𝔮 -- _≋̇_ {A = A} {m = m} m→n₁ m→n₂ = {!∀ (am : A m) → m→n₁ am ≋ m→n₂ am!} -- -} -- IsSetoid.isEquivalence (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2G A ℓ)) Morphism.⇒ m) n)) = {!it!} -- Semigroupoid._∙_ (Category.semigroupoid (cat2G A ℓ)) g f = g ∘ f -- Semigroupoid.isSemigroupoid (Category.semigroupoid (cat2G A ℓ)) = {!it!} -- Category.ε (cat2G A ℓ) = id -- Category.isCategory (cat2G A ℓ) = {!it!} -- -} -- infix 21 ‼_ -- pattern ‼_ ⟦A⟧ = tt ∷ ⟦A⟧ -- tricky, works for all above _∷_ constructors only because it is defined afterwards, won't work for any later-defined constructors -- open import Agda.Primitive -- open import Oscar.Data.Product -- open import Oscar.Function -- postulate -- ℓ : Level -- Term : ⟦⟧ → Set ℓ -- Step : ⟦⟧ → Set ℓ -- Fin = ⟦⟧[_] -- Inj = ⟦ Const Fin ⟧[↓_≤_↓] -- Terms = λ N n → ⟦ Const (Term n) ⟧[ N ₀] -- AList = ⟦ (λ n → Term n × Fin (¡ n)) ⟧[_≤_↓] -- Fx : ∀ {a} {A : Set a} → A → A → ∀ {b₁} (B₁ : A → Set b₁) → ∀ {b₂} (B₂ : A → Set b₂) → Set (b₁ ⊔ b₂) -- Fx m n B₁ B₂ = B₁ m → B₂ n -- Fx₁ : ∀ {a} {A : Set a} → A → ∀ {b₁} (B₁ : A → Set b₁) → ∀ {b₂} (B₂ : A → Set b₂) → Set (b₁ ⊔ b₂) -- Fx₁ n B₁ B₂ = Fx n n B₁ B₂ -- ListStep = λ n → ⟦ Step n ⟧ -- Rel : ∀ {a} {A : Set a} {b₁} (B₁ : A → Set b₁) {b₂} (B₂ : A → Set b₂) {c₁} (C₁ : A → Set c₁) {c₂} (C₂ : A → Set c₂) → Set (a ⊔ b₁ ⊔ b₂ ⊔ c₁ ⊔ c₂) -- Rel B₁ B₂ C₁ C₂ = ∀ {m n} → Fx m n B₁ B₂ → Fx m n C₁ C₂ -- Morph : ∀ {a} {A : Set a} {b₁} {b₂} (B : (A → Set b₁) × (A → Set b₂)) {c₁} {c₂} (C₂ : (A → Set c₁) × (A → Set c₂)) → Set (a ⊔ b₁ ⊔ b₂ ⊔ c₁ ⊔ c₂) -- Morph (B₁ , B₂) (C₁ , C₂) = ∀ {m n} → Fx m n B₁ B₂ → Fx m n C₁ C₂ -- -- functor mappings -- postulate -- _◃_ : Morph (Fin , Term) (Term , Term) -- _◃s_ : ∀ N → Morph (Fin , Term) (Terms N , Terms N) -- sub : ∀ {m n} → AList m n → Fx m n Fin Term -- fmapS : Morph (Term , Term) (Step , Step) -- _◃S_ : Morph (Fin , Term) (ListStep , ListStep) -- -- ? -- postulate -- _⊹_ : ∀ {n} → ⟦ Step n ⟧ → Fx₁ n Term Term -- testNat : ⟦⟧ -- testNat = ¡ ∅ -- testListNat : ⟦ ⟦⟧ ⟧ -- testListNat = ¡ ∅ ∷ ‼ ∅ ∷ ‼ ‼ ∅ ∷ ∅ ∷ ¡ ¡ ¡ ∅ ∷ ∅ -- testFin : ⟦⟧[ ¡ ¡ ∅ ] -- testFin = ‼ ∅ -- test≤↓ : ⟦⟧[ ‼ ‼ ‼ ∅ ≤ ‼ ‼ ‼ ‼ ‼ ∅ ↓] -- test≤↓ = ‼ ‼ ∅ -- ⓪ ⑴ ⑵ ⑶ : ⟦⟧ -- ⓪ = ∅ -- ⑴ = ‼ ∅ -- ⑵ = ‼ ⑴ -- ⑶ = ‼ ⑵ -- testInj : Inj ⑵ ⑶ -- testInj = ‼ ∅ ∷ ∅ ∷ ∅
{ "alphanum_fraction": 0.4716394716, "avg_line_length": 32.8316326531, "ext": "agda", "hexsha": "04a2f3e48231e2010116a3b1be625f8ce2c6c193", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data6.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data6.agda", "max_line_length": 161, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data6.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3333, "size": 6435 }
-- Currently postulates are not allowed in mutual blocks. -- This might change. module PostulateInMutual where mutual postulate A : Set postulate B : Set
{ "alphanum_fraction": 0.751552795, "avg_line_length": 16.1, "ext": "agda", "hexsha": "afe643e5f713244dd19d85ea6801890d59d865d2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/fail/PostulateInMutual.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/fail/PostulateInMutual.agda", "max_line_length": 57, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/PostulateInMutual.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 42, "size": 161 }
{-# OPTIONS --without-K --rewriting #-} module Conaturals where open import Basics open import Bool open import lib.Basics open import lib.types.Nat open import lib.types.Bool {- _is-increasing-b : (ℕ → Bool) → Type _ P is-increasing-b = (n m : ℕ) → n ≤ m → (P n) holds-b → (P m) holds-b increasing-b-is-a-prop : (P : ℕ → Bool) → (P is-increasing-b) is-a-prop increasing-b-is-a-prop P = mp (λ _ → mp (λ x → mp (λ _ → mp (λ _ → (Bool-to-Prop₀ (P x)) holds-is-a-prop )))) where mp = mapping-into-prop-is-a-prop ℕ∞-prop : SubtypeProp (ℕ → Bool) _ ℕ∞-prop = _is-increasing-b , increasing-b-is-a-prop ℕ∞ : Type₀ ℕ∞ = Subtype ℕ∞-prop -} -- I'm having trouble using coinduction =[ -- The type of conatural numbers record ℕ∞ : Type₀ where coinductive field pred∞ : ℕ∞ ⊔ ⊤ pattern go∞ x = inl x pattern stop∞ = inr unit open ℕ∞ public coO : ℕ∞ pred∞ coO = stop∞ co∞ : ℕ∞ pred∞ co∞ = go∞ co∞ suc∞ : ℕ∞ → ℕ∞ pred∞ (suc∞ x) = go∞ x ℕ-to-ℕ∞ : ℕ → ℕ∞ ℕ-to-ℕ∞ O = coO ℕ-to-ℕ∞ (S n) = suc∞ (ℕ-to-ℕ∞ n) case-pred∞_of_ : {i : ULevel} {A : Type i} (n : ℕ∞) (f : ℕ∞ ⊔ ⊤ → A) → A case-pred∞ n of f = f (pred∞ n) {- For a paradigmatic use of this function, see below: -} pred∞-is-coO : ℕ∞ → Bool pred∞-is-coO n = case-pred∞ n of (λ { (go∞ _) → false ; stop∞ → true }) case∞ : {i : ULevel} {A : Type i} (a : A) (f : ℕ∞ → A) → ℕ∞ → A case∞ a f n = case-pred∞ n of (λ { stop∞ → a ; (go∞ x) → f x }) syntax case∞ a (λ m → t) n = case∞ n of-co0→ a suc∞- m -→ t -- ℕ∞-to-ℕ→Prop : ℕ∞ → (ℕ → Bool) -- ℕ∞-to-ℕ→Prop n = case∞ n -- of-co0→ (λ _ → true ) -- suc∞- m -→ {! λ { O → false ; (S k) → ℕ∞-to-ℕ→Prop m k }!} -- previous 4 lines commented by jonas {- ℕ∞-to-ℕ→Prop n O = pred∞-is-coO n ℕ∞-to-ℕ→Prop n (S k) = {!helperS (pred∞ n) k!} where helperS : ℕ∞ ⊔ ⊤ → ℕ → Bool helperS (go∞ pn) O = {!!} helperS (go∞ pn) (S k) = {!!} helperS stop∞ k = true -}
{ "alphanum_fraction": 0.4694708277, "avg_line_length": 25.125, "ext": "agda", "hexsha": "e67b6c30c6d707ec2365084988ac910885598617", "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/Conaturals.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/Conaturals.agda", "max_line_length": 86, "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/Conaturals.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": 914, "size": 2211 }
module help where open import univ open import Base -- Prelims infixl 150 _#_ K : {A : S} -> S -> Fam A K B = fam (\_ -> B) (\_ -> refS) _#_ : {A : S}{F : Fam A} -> El (pi A F) -> (x : El A) -> El (F ! x) el < f , _ > # x = f x pFun : {A : S}{F : Fam A}(f : El (pi A F)){x y : El A}(x=y : x == y) -> f # x == pFam F x=y << f # y pFun (el < f , pf >) x=y = pf x=y p# : {A : S}{F : Fam A}{f g : El (pi A F)}{x : El A} -> f == g -> f # x == g # x p# {A}{F}{el < f , _ >}{el < g , _ >} (eq f=g) = f=g _ eqDom : {A B : S}{F : Fam A}{G : Fam B} -> pi A F =S pi B G -> B =S A eqDom (eqS < B=A , _ >) = B=A eqCod : {A B : S}{F : Fam A}{G : Fam B} -> (AF=BG : pi A F =S pi B G)(x : El A) -> F ! x =S G ! (eqDom AF=BG << x) eqCod (eqS < B=A , F=G >) = F=G distr<<# : {A B : S}{F : Fam A}{G : Fam B}(f : El (pi A F)){x : El B} (BG=AF : pi B G =S pi A F) -> (BG=AF << f) # x == eqCod BG=AF x << f # (eqDom BG=AF << x) distr<<# (el < f , pf >) {x} (eqS < A=B , G=F >) = ref eqSnd : {A : S}{F : Fam A}{x : El A}{y z : El (F ! x)} -> y == z -> _==_ {sigma A F} (el < x , y >) (el < x , z >) eqSnd {A}{F}{x}{y}{z} y=z = eq < ref , y=cz > where y=cz : y == pFam F ref << z y=cz = trans y=z (sym (castref _ _)) IsFun : {A : S}{F : Fam A}(f : (x : El A) -> El (F ! x)) -> Set IsFun {A}{F} f = {x y : El A}(p : F ! x =S F ! y)(x=y : x == y) -> f x == p << f y mkFun : {A : S}{F : Fam A}(f : (x : El A) -> El (F ! x)) -> IsFun {A}{F} f -> El (pi A F) mkFun {A}{F} f pf = el < f , (\{x}{y} x=y -> pf (pFam F x=y) x=y) > curryFam : {A : S}{F : Fam A} -> Fam (sigma A F) -> (x : El A) -> Fam (F ! x) curryFam {A}{F} G x = fam H pH where H : El (F ! x) -> S H y = G ! el < x , y > pH : Map _==_ _=S_ H pH y=z = pFam G (eq < ref , trans y=z (sym (castref _ _)) >)
{ "alphanum_fraction": 0.392513369, "avg_line_length": 30.6557377049, "ext": "agda", "hexsha": "10949891d8a9aa9a3b9d9adf462d740a5f811d7f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/univ/help.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/univ/help.agda", "max_line_length": 80, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/univ/help.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": 866, "size": 1870 }
{-# OPTIONS --without-K --safe #-} module Definition.Conversion.Transitivity where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.Conversion open import Definition.Conversion.Soundness open import Definition.Conversion.Stability open import Definition.Conversion.Whnf open import Definition.Conversion.Conversion open import Definition.Conversion.Reduction open import Definition.Conversion.Lift open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Injectivity import Definition.Typed.Consequences.Inequality as WF open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Definition.Typed.Consequences.NeTypeEq open import Definition.Typed.Consequences.SucCong open import Definition.Typed.Consequences.Inversion open import Definition.Typed.Consequences.Reduction open import Tools.Nat open import Tools.Product open import Tools.Empty import Tools.PropositionalEquality as PE mutual -- Transitivity of algorithmic equality of neutrals. trans~↑ : ∀ {t u v A B Γ} → Γ ⊢ t ~ u ↑ A → Γ ⊢ u ~ v ↑ B → Γ ⊢ t ~ v ↑ A × Γ ⊢ A ≡ B trans~↑ (var-refl x₁ x≡y) (var-refl x₂ x≡y₁) = var-refl x₁ (PE.trans x≡y x≡y₁) , neTypeEq (var _) x₁ (PE.subst (λ x → _ ⊢ var x ∷ _) (PE.sym x≡y) x₂) trans~↑ (app-cong t~u a<>b) (app-cong u~v b<>c) = let t~v , ΠFG≡ΠF′G′ = trans~↓ t~u u~v F≡F₁ , G≡G₁ = injectivity ΠFG≡ΠF′G′ a<>c = transConv↑Term F≡F₁ a<>b b<>c in app-cong t~v a<>c , substTypeEq G≡G₁ (soundnessConv↑Term a<>b) trans~↑ (fst-cong t~u) (fst-cong u~v) = let t~v , ΣFG≡ΣF′G′ = trans~↓ t~u u~v F≡F′ , _ = Σ-injectivity ΣFG≡ΣF′G′ in fst-cong t~v , F≡F′ trans~↑ (snd-cong t~u) (snd-cong u~v) = let t~v , ΣFG≡ΣF′G′ = trans~↓ t~u u~v F≡F′ , G≡G′ = Σ-injectivity ΣFG≡ΣF′G′ in snd-cong t~v , substTypeEq G≡G′ (soundness~↑ (fst-cong t~u)) trans~↑ (natrec-cong A<>B a₀<>b₀ aₛ<>bₛ t~u) (natrec-cong B<>C b₀<>c₀ bₛ<>cₛ u~v) = let ⊢Γ = wf (proj₁ (syntacticEqTerm (soundness~↓ t~u))) A≡B = soundnessConv↑ A<>B F[0]≡F₁[0] = substTypeEq A≡B (refl (zeroⱼ ⊢Γ)) ΠℕFs≡ΠℕF₁s = sucCong A≡B A<>C = transConv↑ A<>B B<>C a₀<>c₀ = transConv↑Term F[0]≡F₁[0] a₀<>b₀ b₀<>c₀ aₛ<>cₛ = transConv↑Term ΠℕFs≡ΠℕF₁s aₛ<>bₛ bₛ<>cₛ t~v , _ = trans~↓ t~u u~v in natrec-cong A<>C a₀<>c₀ aₛ<>cₛ t~v , substTypeEq A≡B (soundness~↓ t~u) trans~↑ (Emptyrec-cong A<>B t~u) (Emptyrec-cong B<>C u~v) = let A≡B = soundnessConv↑ A<>B A<>C = transConv↑ A<>B B<>C t~v , _ = trans~↓ t~u u~v in Emptyrec-cong A<>C t~v , A≡B -- Transitivity of algorithmic equality of neutrals with types in WHNF. trans~↓ : ∀ {t u v A B Γ} → Γ ⊢ t ~ u ↓ A → Γ ⊢ u ~ v ↓ B → Γ ⊢ t ~ v ↓ A × Γ ⊢ A ≡ B trans~↓ ([~] A₁ D whnfA k~l) ([~] A₂ D₁ whnfA₁ k~l₁) = let t~v , A≡B = trans~↑ k~l k~l₁ in [~] A₁ D whnfA t~v , trans (sym (subset* D)) (trans A≡B (subset* D₁)) -- Transitivity of algorithmic equality of types. transConv↑ : ∀ {A B C Γ} → Γ ⊢ A [conv↑] B → Γ ⊢ B [conv↑] C → Γ ⊢ A [conv↑] C transConv↑ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) ([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) = [↑] A′ B″ D D″ whnfA′ whnfB″ (transConv↓ A′<>B′ (PE.subst (λ x → _ ⊢ x [conv↓] B″) (whrDet* (D₁ , whnfA″) (D′ , whnfB′)) A′<>B″)) transConv↑′ : ∀ {A B C Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A [conv↑] B → Δ ⊢ B [conv↑] C → Γ ⊢ A [conv↑] C transConv↑′ Γ≡Δ aConvB bConvC = transConv↑ aConvB (stabilityConv↑ (symConEq Γ≡Δ) bConvC) -- Transitivity of algorithmic equality of types in WHNF. transConv↓ : ∀ {A B C Γ} → Γ ⊢ A [conv↓] B → Γ ⊢ B [conv↓] C → Γ ⊢ A [conv↓] C transConv↓ (U-refl x) (U-refl x₁) = U-refl x transConv↓ (ℕ-refl x) (ℕ-refl x₁) = ℕ-refl x transConv↓ (Empty-refl x) (Empty-refl x₁) = Empty-refl x transConv↓ (Unit-refl x) (Unit-refl x₁) = Unit-refl x transConv↓ (ne x) (ne x₁) = let A~C , U≡U = trans~↓ x x₁ in ne A~C transConv↓ (Π-cong x x₁ x₂) (Π-cong x₃ x₄ x₅) = Π-cong x (transConv↑ x₁ x₄) (transConv↑′ (reflConEq (wf x) ∙ soundnessConv↑ x₁) x₂ x₅) transConv↓ (Σ-cong x x₁ x₂) (Σ-cong x₃ x₄ x₅) = Σ-cong x (transConv↑ x₁ x₄) (transConv↑′ (reflConEq (wf x) ∙ soundnessConv↑ x₁) x₂ x₅) -- Refutable cases transConv↓ (U-refl x) (ne ([~] A D whnfB ())) transConv↓ (ℕ-refl x) (ne ([~] A D whnfB ())) transConv↓ (Empty-refl x) (ne ([~] A D whnfB ())) transConv↓ (Π-cong x x₁ x₂) (ne ([~] A D whnfB ())) transConv↓ (Σ-cong x x₁ x₂) (ne ([~] A D whnfB ())) transConv↓ (ne ([~] A₁ D whnfB ())) (U-refl x₁) transConv↓ (ne ([~] A₁ D whnfB ())) (ℕ-refl x₁) transConv↓ (ne ([~] A₁ D whnfB ())) (Empty-refl x₁) transConv↓ (ne ([~] A₁ D whnfB ())) (Π-cong x₁ x₂ x₃) transConv↓ (ne ([~] A₁ D whnfB ())) (Σ-cong x₁ x₂ x₃) -- Transitivity of algorithmic equality of terms. transConv↑Term : ∀ {t u v A B Γ} → Γ ⊢ A ≡ B → Γ ⊢ t [conv↑] u ∷ A → Γ ⊢ u [conv↑] v ∷ B → Γ ⊢ t [conv↑] v ∷ A transConv↑Term A≡B ([↑]ₜ B₁ t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) ([↑]ₜ B₂ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) = let B₁≡B₂ = trans (sym (subset* D)) (trans A≡B (subset* D₁)) d₁″ = conv* d″ (sym B₁≡B₂) d₁′ = conv* d′ B₁≡B₂ in [↑]ₜ B₁ t′ u″ D d d₁″ whnfB whnft′ whnfu″ (transConv↓Term B₁≡B₂ t<>u (PE.subst (λ x → _ ⊢ x [conv↓] u″ ∷ B₂) (whrDet*Term (d₁ , whnft″) (d₁′ , whnfu′)) t<>u₁)) transConv↑Term′ : ∀ {t u v A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B → Γ ⊢ t [conv↑] u ∷ A → Δ ⊢ u [conv↑] v ∷ B → Γ ⊢ t [conv↑] v ∷ A transConv↑Term′ Γ≡Δ A≡B tConvU uConvV = transConv↑Term A≡B tConvU (stabilityConv↑Term (symConEq Γ≡Δ) uConvV) -- Transitivity of algorithmic equality of terms in WHNF. transConv↓Term : ∀ {t u v A B Γ} → Γ ⊢ A ≡ B → Γ ⊢ t [conv↓] u ∷ A → Γ ⊢ u [conv↓] v ∷ B → Γ ⊢ t [conv↓] v ∷ A transConv↓Term A≡B (ℕ-ins x) (ℕ-ins x₁) = ℕ-ins (proj₁ (trans~↓ x x₁)) transConv↓Term A≡B (Empty-ins x) (Empty-ins x₁) = Empty-ins (proj₁ (trans~↓ x x₁)) transConv↓Term A≡B (Unit-ins t~u) uConvV = let _ , [t] , _ = syntacticEqTerm (soundness~↓ t~u) _ , tNe , _ = ne~↓ t~u _ , _ , [v] = syntacticEqTerm (soundnessConv↓Term uConvV) [v] = conv [v] (sym A≡B) _ , _ , vWhnf = whnfConv↓Term uConvV in η-unit [t] [v] (ne tNe) vWhnf transConv↓Term A≡B (ne-ins t u x x₁) (ne-ins t′ u′ x₂ x₃) = ne-ins t (conv u′ (sym A≡B)) x (proj₁ (trans~↓ x₁ x₃)) transConv↓Term A≡B (univ x x₁ x₂) (univ x₃ x₄ x₅) = univ x x₄ (transConv↓ x₂ x₅) transConv↓Term A≡B (zero-refl x) conv↓ = convConv↓Term (reflConEq x) (sym A≡B) ℕₙ conv↓ transConv↓Term A≡B conv↓ (zero-refl _) = conv↓ transConv↓Term A≡B (suc-cong x) (suc-cong x₁) = suc-cong (transConv↑Term A≡B x x₁) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (η-eq x₅ x₆ y₂ y₃ x₇) = let F₁≡F , G₁≡G = injectivity A≡B in η-eq x₁ (conv x₆ (sym A≡B)) y y₃ (transConv↑Term′ (reflConEq (wfEq F₁≡F) ∙ F₁≡F) G₁≡G x₃ x₇) transConv↓Term A≡B (Σ-η ⊢p ⊢r pProd rProd fstConv sndConv) (Σ-η ⊢r′ ⊢q _ qProd fstConv′ sndConv′) = let F≡ , G≡ = Σ-injectivity A≡B Gfst≡ = substTypeEq G≡ (soundnessConv↑Term fstConv) in Σ-η ⊢p (conv ⊢q (sym A≡B)) pProd qProd (transConv↑Term F≡ fstConv fstConv′) (transConv↑Term Gfst≡ sndConv sndConv′) transConv↓Term A≡B (η-unit [t] [u] tUnit uUnit) uConvV = let _ , _ , [v] = syntacticEqTerm (soundnessConv↓Term uConvV) [v] = conv [v] (sym A≡B) _ , _ , vWhnf = whnfConv↓Term uConvV in η-unit [t] [v] tUnit vWhnf -- Refutable cases transConv↓Term A≡B (ℕ-ins x) (ne-ins t u x₂ x₃) = ⊥-elim (WF.ℕ≢ne x₂ A≡B) transConv↓Term A≡B (ℕ-ins x) (univ x₂ x₃ x₄) = ⊥-elim (WF.U≢ℕ (sym A≡B)) transConv↓Term A≡B (ℕ-ins x) (Empty-ins x₁) = ⊥-elim (WF.ℕ≢Emptyⱼ A≡B) transConv↓Term A≡B (ℕ-ins x) (Unit-ins x₁) = ⊥-elim (WF.ℕ≢Unitⱼ A≡B) transConv↓Term A≡B (ℕ-ins ([~] A D whnfB ())) (suc-cong x₂) transConv↓Term A≡B (ℕ-ins x) (η-eq x₃ x₄ y y₁ x₅) = ⊥-elim (WF.ℕ≢Π A≡B) transConv↓Term A≡B (ℕ-ins x₁) (Σ-η x₂ x₃ x₄ x₅ x₆ x₇) = ⊥-elim (WF.ℕ≢Σ A≡B) transConv↓Term A≡B (ℕ-ins x) (η-unit _ _ _ _) = ⊥-elim (WF.ℕ≢Unitⱼ A≡B) transConv↓Term A≡B (Empty-ins x) (ne-ins t u x₂ x₃) = ⊥-elim (WF.Empty≢neⱼ x₂ A≡B) transConv↓Term A≡B (Empty-ins x) (univ x₂ x₃ x₄) = ⊥-elim (WF.U≢Emptyⱼ (sym A≡B)) transConv↓Term A≡B (Empty-ins x₁) (ℕ-ins x) = ⊥-elim (WF.ℕ≢Emptyⱼ (sym A≡B)) transConv↓Term A≡B (Empty-ins x₁) (Unit-ins x) = ⊥-elim (WF.Empty≢Unitⱼ A≡B) transConv↓Term A≡B (Empty-ins ([~] A D whnfB ())) (suc-cong x₂) transConv↓Term A≡B (Empty-ins x) (η-eq x₃ x₄ y y₁ x₅) = ⊥-elim (WF.Empty≢Πⱼ A≡B) transConv↓Term A≡B (Empty-ins x₁) (Σ-η x₂ x₃ x₄ x₅ x₆ x₇) = ⊥-elim (WF.Empty≢Σⱼ A≡B) transConv↓Term A≡B (Empty-ins x₁) (η-unit _ _ _ _) = ⊥-elim (WF.Empty≢Unitⱼ A≡B) transConv↓Term A≡B (ne-ins t u x x₁) (ℕ-ins x₂) = ⊥-elim (WF.ℕ≢ne x (sym A≡B)) transConv↓Term A≡B (ne-ins t u x x₁) (Empty-ins x₂) = ⊥-elim (WF.Empty≢neⱼ x (sym A≡B)) transConv↓Term A≡B (ne-ins t u x x₁) (Unit-ins x₂) = ⊥-elim (WF.Unit≢neⱼ x (sym A≡B)) transConv↓Term A≡B (ne-ins t u x x₁) (univ x₃ x₄ x₅) = ⊥-elim (WF.U≢ne x (sym A≡B)) transConv↓Term A≡B (ne-ins t u x ([~] A D whnfB ())) (suc-cong x₃) transConv↓Term A≡B (ne-ins t u x x₁) (η-eq x₄ x₅ y y₁ x₆) = ⊥-elim (WF.Π≢ne x (sym A≡B)) transConv↓Term A≡B (ne-ins t u x x₁) (Σ-η x₅ x₆ x₇ x₈ x₉ x₁₀) = ⊥-elim (WF.Σ≢ne x (sym A≡B)) transConv↓Term A≡B (ne-ins t u x x₁) (η-unit _ _ _ _) = ⊥-elim (WF.Unit≢neⱼ x (sym A≡B)) transConv↓Term A≡B (univ x x₁ x₂) (ℕ-ins x₃) = ⊥-elim (WF.U≢ℕ A≡B) transConv↓Term A≡B (univ x x₁ x₂) (Empty-ins x₃) = ⊥-elim (WF.U≢Emptyⱼ A≡B) transConv↓Term A≡B (univ x x₁ x₂) (Unit-ins x₃) = ⊥-elim (WF.U≢Unitⱼ A≡B) transConv↓Term A≡B (univ x x₁ x₂) (ne-ins t u x₃ x₄) = ⊥-elim (WF.U≢ne x₃ A≡B) transConv↓Term A≡B (univ x x₁ x₂) (suc-cong x₃) = ⊥-elim (WF.U≢ℕ A≡B) transConv↓Term A≡B (univ x x₁ x₂) (η-eq x₄ x₅ y y₁ x₆) = ⊥-elim (WF.U≢Π A≡B) transConv↓Term A≡B (univ x₁ x₂ x₃) (Σ-η x₄ x₅ x₆ x₇ x₈ x₉) = ⊥-elim (WF.U≢Σ A≡B) transConv↓Term A≡B (univ x x₁ x₂) (η-unit _ _ _ _) = ⊥-elim (WF.U≢Unitⱼ A≡B) transConv↓Term A≡B (suc-cong x) (ℕ-ins ([~] A D whnfB ())) transConv↓Term A≡B (suc-cong x) (Empty-ins ([~] A D whnfB ())) transConv↓Term A≡B (suc-cong x) (ne-ins t u x₁ ([~] A D whnfB ())) transConv↓Term A≡B (suc-cong x) (univ x₁ x₂ x₃) = ⊥-elim (WF.U≢ℕ (sym A≡B)) transConv↓Term A≡B (suc-cong x) (η-eq x₂ x₃ y y₁ x₄) = ⊥-elim (WF.ℕ≢Π A≡B) transConv↓Term A≡B (suc-cong x₁) (Σ-η x₂ x₃ x₄ x₅ x₆ x₇) = ⊥-elim (WF.ℕ≢Σ A≡B) transConv↓Term A≡B (suc-cong x) (η-unit _ _ _ _) = ⊥-elim (WF.ℕ≢Unitⱼ A≡B) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (ℕ-ins x₄) = ⊥-elim (WF.ℕ≢Π (sym A≡B)) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (Empty-ins x₄) = ⊥-elim (WF.Empty≢Πⱼ (sym A≡B)) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (Unit-ins _) = ⊥-elim (WF.Unit≢Πⱼ (sym A≡B)) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (ne-ins t u x₄ x₅) = ⊥-elim (WF.Π≢ne x₄ A≡B) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (univ x₄ x₅ x₆) = ⊥-elim (WF.U≢Π (sym A≡B)) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (suc-cong x₄) = ⊥-elim (WF.ℕ≢Π (sym A≡B)) transConv↓Term A≡B (η-eq x₂ x₃ x₄ x₅ x₆) (Σ-η x₇ x₈ x₉ x₁₀ x₁₁ x₁₂) = ⊥-elim (WF.Π≢Σ A≡B) transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (η-unit _ _ _ _) = ⊥-elim (WF.Unit≢Πⱼ (sym A≡B)) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (ℕ-ins x₇) = ⊥-elim (WF.ℕ≢Σ (sym A≡B)) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (Empty-ins x₇) = ⊥-elim (WF.Empty≢Σⱼ (sym A≡B)) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (Unit-ins x₇) = ⊥-elim (WF.Unit≢Σⱼ (sym A≡B)) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (ne-ins x₇ x₈ x₉ x₁₀) = ⊥-elim (WF.Σ≢ne x₉ A≡B) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (univ x₇ x₈ x₉) = ⊥-elim (WF.U≢Σ (sym A≡B)) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (suc-cong x₇) = ⊥-elim (WF.ℕ≢Σ (sym A≡B)) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (η-eq x₈ x₉ x₁₀ x₁₁ x₁₂) = ⊥-elim (WF.Π≢Σ (sym A≡B)) transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (η-unit x₇ x₈ x₉ x₁₀) = ⊥-elim (WF.Unit≢Σⱼ (sym A≡B)) -- Transitivity of algorithmic equality of types of the same context. transConv : ∀ {A B C Γ} → Γ ⊢ A [conv↑] B → Γ ⊢ B [conv↑] C → Γ ⊢ A [conv↑] C transConv A<>B B<>C = transConv↑ A<>B B<>C -- Transitivity of algorithmic equality of terms of the same context. transConvTerm : ∀ {t u v A Γ} → Γ ⊢ t [conv↑] u ∷ A → Γ ⊢ u [conv↑] v ∷ A → Γ ⊢ t [conv↑] v ∷ A transConvTerm t<>u u<>v = let t≡u = soundnessConv↑Term t<>u ⊢A , _ , _ = syntacticEqTerm t≡u in transConv↑Term (refl ⊢A) t<>u u<>v
{ "alphanum_fraction": 0.5510653931, "avg_line_length": 48.2624113475, "ext": "agda", "hexsha": "5eb743dd3978e5db3cebb86a56369d94a0316c86", "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/Conversion/Transitivity.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/Conversion/Transitivity.agda", "max_line_length": 98, "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/Conversion/Transitivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6493, "size": 13610 }
module Test where import Lvl {- TODO: Unsolved metas module NumAndDivisionProofs where open import Functional open import Logic.Propositional{Lvl.𝟎} open import Logic.Convenience{Lvl.𝟎} open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Divisibility open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals.Proofs{Lvl.𝟎}{Lvl.𝟎} open import Structure.Relator.Properties{Lvl.𝟎}{Lvl.𝟎} ℕ4IsEven : Even((𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎)) ℕ4IsEven = Even0 ⇒ Even𝐒 ⇒ Even𝐒 ℕ5IsOdd : Odd((𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎)) ℕ5IsOdd = Odd0 ⇒ Odd𝐒 ⇒ Odd𝐒 ℕ2Dividesℕ4 : (𝐒 ∘ 𝐒)(𝟎) ∣ (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ℕ2Dividesℕ4 = Div𝟎 ⇒ Div𝐒 ⇒ Div𝐒 ℕ6IsDividesℕ12 : (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ∣ (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ℕ6IsDividesℕ12 = Div𝟎 ⇒ Div𝐒 ⇒ Div𝐒 ℕ4IsDividesℕ12 : (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ∣ (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ℕ4IsDividesℕ12 = Div𝟎 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ℕ3IsDividesℕ12 : (𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ∣ (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ℕ3IsDividesℕ12 = Div𝟎 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ℕ2IsDividesℕ12 : (𝐒 ∘ 𝐒)(𝟎) ∣ (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ℕ2IsDividesℕ12 = Div𝟎 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ℕ1IsDividesℕ12 : 𝐒(𝟎) ∣ (𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ℕ1IsDividesℕ12 = Div𝟎 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 ⇒ Div𝐒 test22 : (2 ∣ 4) → (2 ∣ 2) test22 (Div𝐒{2} (proof)) = proof test23 : ¬(2 ∣ 3) test23 (Div𝐒{1} ()) -- TODO -- ℕ3IsDividesℕ7Remℕ1 : 3 ∣ 7 withRemainder 1 -- ℕ3IsDividesℕ7Remℕ1 = DivRem𝟎 ⇒ DivRem𝐒 ⇒ DivRem𝐒 ℕ3Eqℕ2+1 : (𝐒 ∘ 𝐒 ∘ 𝐒)(𝟎) ≡ (𝐒 ∘ 𝐒)(𝟎) + 𝐒(𝟎) ℕ3Eqℕ2+1 = reflexivity testImpl : 𝐒(𝟎) ≡ (𝟎 ⇒ 𝐒) testImpl = reflexivity fnℕ+1 : (𝟎 ≡ 𝐒(𝟎)) → (𝐒(𝟎) ≡ (𝐒 ∘ 𝐒)(𝟎)) fnℕ+1 = congruence₁(𝐒) fnℕ+3 : ∀{x} → (x ≡ 5) → (x + 3 ≡ 8) fnℕ+3 = congruence₁(x ↦ x + 3) ℕ8Eqℕ2⋅4 : 8 ≡ 2 ⋅ 4 ℕ8Eqℕ2⋅4 = reflexivity ℕ0Eqℕ0⋅4 : 0 ≡ 0 ⋅ 4 ℕ0Eqℕ0⋅4 = reflexivity testBottom : (⊥ ∧ ℕ) → ℕ testBottom = [∧]-elimᵣ -} module DataTest where open import Data open import Type{Lvl.𝟎} data Data1 : Type where data1,1 : Data1 data Data2 : Type where data2,1 : Data2 data2,2 : Data2 data Data3 : Type where data3,1 : Data3 data3,2 : Data3 data3,3 : Data3 dataTest : (Data1 ⨯ Data2 ⨯ Data3) → Data3 dataTest(x , y , z) = z -- coprimes m n = ((2*m-n,m) , (2*m+n,m) , (m+2*n,n)) -- coprimes' m n = (a1/a2,b1/b2,c1/c2) where ((a1,a2),(b1,b2),(c1,c2))=f m n -- map (\m -> map (\n -> (m,n,coprimes m n,coprimes' m n)) [1..m-1]) [1..10] -- 2 − n/m -- 2 + n/m -- 2 + m/n -- 2 − n₁/m₁ + 2 − n₂/m₂ -- 4 − n₁/m₁ − n₂/m₂ -- 4 − (m₂⋅n₁ − m₁⋅n₂)/(m₁⋅m₂) -- 4 + (m₁⋅n₂ − m₂⋅n₁)/(m₁⋅m₂) -- 2 + 2 + (m₁⋅n₂ − m₂⋅n₁)/(m₁⋅m₂) -- 2 + (2⋅m₁⋅m₂)/(m₁⋅m₂) + (m₁⋅n₂ − m₂⋅n₁)/(m₁⋅m₂) -- 2 + (2⋅m₁⋅m₂ + m₁⋅n₂ − m₂⋅n₁)/(m₁⋅m₂) -- 1 1 -- 2 3 -- 3 6 -- 4 10 -- 5 15 -- 6 21 -- 7 28 -- 8 36 -- 9 45 -- 10 55 -- n⋅(n+1)/2 = x -- n⋅(n+1) = 2⋅x -- n²+n = 2⋅x -- n = 1/2 + √(1/4+2⋅x) -- n = 1/2 + √(9⋅x/4) -- n = 1/2 + 3⋅√x/2 -- n = (1 + 3⋅√x)/2 -- permutation with sum 4: 1/3 2/2 3/1 -- curryN : {T : Set}{a : _} → ℕ → (a → T) → (a → T) -- curryN 𝟎 = id -- curryN (𝐒(n)) = Tuple.curry ∘ (curryN n) -- test : {a b b1 c : _} → (((a , b) , b1) -> c) -> a -> b -> b1 -> c -- test = curryN 2 -- test : {a b c d : Set} → (((a ⨯ b) ⨯ c) -> d) -> a -> b -> c -> d -- test = Tuple.curry ∘ Tuple.curry -- data repeatType (b : Set) : ∀{q} {a : Set q} -> a -> Set where -- simple : repeatType b (b -> b) -- complex : repeatType b (b -> (∀{c : Set} -> b -> c)) -- repeat2 : ∀{b d c} {q : repeatType c d} -> (r : repeatType b c) -> c -> b -> d -- repeat2 f x simple = f (f x) -- repeat2 f x complex = f (f x) module TestRepeatingStuff where open import Data open import Data.Tuple.Raise open import Numeral.Natural open import Type repeat' : {R : Set} → R → (R → R) → ℕ → R repeat' x _ 𝟎 = x repeat' x f (𝐒 n) = f(repeat' x f n) _⨯^_ : ∀{n} → Set n → ℕ → Set n _⨯^_ _ 𝟎 = Unit _⨯^_ type (𝐒(𝟎)) = type _⨯^_ type (𝐒(n)) = type ⨯ (type ⨯^ n) _→^_ : ∀{n} → Set n → ℕ → Set n _→^_ _ 𝟎 = Unit _→^_ type (𝐒(𝟎)) = type _→^_ type (𝐒(n)) = type → (type →^ n) repeatOp : ∀{n} → Set n → (Set n → Set n → Set n) → ℕ → Set n repeatOp type _ 𝟎 = type repeatOp type op (𝐒(n)) = op type (repeatOp type op n) _⨯^₂_ : ∀{n} → Set n → ℕ → Set n _⨯^₂_ _ 𝟎 = Unit _⨯^₂_ type (𝐒(n)) = repeatOp type (_⨯_) n testTupleRaise : (ℕ ^ 4) → ℕ ⨯ ℕ ⨯ ℕ ⨯ ℕ testTupleRaise x = x -- curryN : {n : ℕ} → ∀{T} → (T →^ n) -- not mine -- data repeatType (b : Set) : ∀{q} {a : Set q} -> a -> Set where -- simple : repeatType b (b -> b) -- complex : repeatType b (b -> (∀{c : Set} -> b -> c)) -- repeat2 : ∀{b d c} {q : repeatType c d} -> (r : repeatType b c) -> c -> b -> d -- repeat2 f x simple = f (f x) -- repeat2 f x complex = f (f x) -- module Test1 where -- F : (ℕ ⨯ ℕ) → ℕ -- F(x , y) = x + y -- f : ℕ → ℕ → ℕ -- f = (Function.Iteration.repeatᵣ 1 Tuple.curry (_∘_) id) F -- -- testf₁ : F(1 , 2) ≡ 1 + 2 -- testf₁ = [≡]-reflexivity -- -- testf₂ : f 1 2 ≡ 1 + 2 -- testf₂ = [≡]-reflexivity module Test2 where open import Functional open import Function.Iteration open import Numeral.Natural open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals.Proofs{Lvl.𝟎}{Lvl.𝟎} open import Structure.Relator.Properties{Lvl.𝟎}{Lvl.𝟎} f : ℕ f = (repeatᵣ 4 𝐒 (_∘_) id) 0 testf₁ : f ≡ 4 testf₁ = reflexivity -- f₂ : ∀{n}{A B C D : TypeN n} → (((A ⨯ B) ⨯ C) -> D) -> (A -> B -> C -> D) -- f₂ = Function.Iteration.repeatᵣ 2 id (_∘_) Tuple.curry module TestTypeAscription where open import Numeral.Natural open import Type{Lvl.𝟎} ty = 1 :of: ℕ -- ty2 = 1 :of: ⊥ -- Testing universes module TestSetUniverses {n} (Type : Set n) where postulate _→₂_ : Type → Type → Set n data TestData1 (A : Type) (B : Type) : Set n where -- data TestData2 (A : Type) (B : Type) : Type where -- Data of arbitrary type seems to not be okay data TestData3 (A : Type) (B : Type) : Set n where testConstruct1 : TestData3 A B -- testConstruct2 : A → TestData3 A B -- Because of (_→_ : (Set _) → (Set _))? -- testConstruct3 : A →₂ (TestData3 A B) testConstruct4 : (A →₂ B) → (TestData3 A B) testFn : Type → Type testFn x = x module testEqProof where open import Logic.Propositional{Lvl.𝟎} open import Numeral.Natural.Oper open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals.Proofs{Lvl.𝟎}{Lvl.𝟎} open import Structure.Operator.Properties{Lvl.𝟎} open import Structure.Relator.Properties{Lvl.𝟎}{Lvl.𝟎} open import Type{Lvl.𝟎} minSkit : ⦃ _ : Absorberₗ (_⋅_) (0) ⦄ → ⦃ _ : Identityᵣ (_+_) (0) ⦄ → ∀{x} → (1 ≡ ((0 ⋅ x) + 1) + 0) minSkit ⦃ absorb ⦄ ⦃ id ⦄ {x} = ((congruence₁(_+ 1) ((symmetry (absorb {x})) :of: (0 ≡ 0 ⋅ x)) ) :of: (1 ≡ (0 ⋅ x) + 1)) 🝖 ((symmetry id) :of: (_ ≡ ((0 ⋅ x) + 1) + 0)) module testDiv where open import Numeral.Natural.Oper open import Numeral.Natural.UnclosedOper open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals.Proofs{Lvl.𝟎}{Lvl.𝟎} open import Structure.Relator.Properties{Lvl.𝟎}{Lvl.𝟎} testDiv1 : 4 ⌈/₀⌉ 2 ≡ 2 testDiv1 = reflexivity testDiv2 : 2 ⌈/₀⌉ 2 ≡ 1 testDiv2 = reflexivity testDiv3 : 1 ⌈/₀⌉ 2 ≡ 1 testDiv3 = reflexivity -- test1 : ∀{f : ℕ → ℕ} → (f(0) ≡ 0) ∧ (∀{n : ℕ} → f(n + 1) ≡ f(n) + n + 1) → (∀{n : ℕ} → f(n) ≡ (n ⋅ (n + 1)) ⌈/₀⌉ 2) -- test1 () module testList where open import Data.List open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals.Proofs{Lvl.𝟎}{Lvl.𝟎} open import Numeral.Natural -- rev1 : (4 ⊰ 3 ⊰ 2 ⊰ 1 ⊰ ∅) → reverse(1 ⊰ 2 ⊰ 3 ⊰ 4 ⊰ ∅) -- rev1 = id len1 : length{_}{ℕ}(1 ⊰ 2 ⊰ 3 ⊰ 4 ⊰ ∅) ≡ 4 len1 = [≡]-intro testFoldᵣ : (foldᵣ{_}{_}{ℕ} (_⊰_) ∅ (1 ⊰ 2 ⊰ 3 ⊰ 4 ⊰ ∅)) ≡ (1 ⊰ 2 ⊰ 3 ⊰ 4 ⊰ ∅) testFoldᵣ = [≡]-intro testReduceOrᵣ0 : (reduceOrᵣ (_++_ {_}{ℕ}) (0 ⊰ ∅) ∅) ≡ (0 ⊰ ∅) testReduceOrᵣ0 = [≡]-intro testReduceOrᵣ1 : (reduceOrᵣ (_++_ {_}{ℕ}) (0 ⊰ ∅) ((1 ⊰ ∅) ⊰ ∅)) ≡ (1 ⊰ ∅) testReduceOrᵣ1 = [≡]-intro testReduceOrᵣ2 : (reduceOrᵣ (_++_ {_}{ℕ}) (0 ⊰ ∅) ((1 ⊰ ∅) ⊰ (2 ⊰ ∅) ⊰ (3 ⊰ ∅) ⊰ (4 ⊰ ∅) ⊰ ∅)) ≡ (1 ⊰ 2 ⊰ 3 ⊰ 4 ⊰ ∅) testReduceOrᵣ2 = [≡]-intro module testTransitivity where open import Numeral.Natural open import Structure.Relator.Properties{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals.Proofs{Lvl.𝟎}{Lvl.𝟎} open import Type test1 : (0 :of: ℕ ≡ 1) → (1 ≡ 2) → (0 ≡ 2) test1 (0≡1) (1≡2) = (0≡1) 🝖 (1≡2) -- module testPropositionalLogic where -- open import Functional -- open import Logic.Propositional{Lvl.𝟎} -- module Propositional = Logic.Classical.Propositional -- open import Type{Lvl.𝟎} -- -- symbols : ∀{T : Set(Lvl.𝟎)} → Propositional.Syntax.Symbols T (const (Set(Lvl.𝟎))) -- symbols = -- record { -- •_ = typeOf ; -- ⊤ = ⊤ ; -- ⊥ = ⊥ ; -- ¬_ = ¬_ ; -- _∧_ = _∧_ ; -- _∨_ = _∨_ ; -- _⇒_ = _→ᶠ_ ; -- _⇔_ = _↔_ -- -- _⊕_ = a ↦ b ↦ ((a ∨ b) ∧ ¬(a ∧ b)) -- } module testListSublist where open import Functional open import Numeral.Natural open import Data.List import List.Theorems open List.Theorems{Lvl.𝟎}{Lvl.𝟎} open List.Theorems.Sublist hiding (_⊑_) open import Type test1 : ([ 1 ]) ⊑ ([ 1 ] :of: List(ℕ)) test1 = use(empty) test2 : ([ 1 ⊰ 2 ]) ⊑ ([ 1 ] :of: List(ℕ)) test2 = (use ∘ skip)(empty) test3 : ([ 1 ⊰ 2 ]) ⊑ ([ 1 ⊰ 2 ] :of: List(ℕ)) test3 = (use ∘ use)(empty) test4 : ([ 1 ⊰ 10 ⊰ 2 ]) ⊑ ([ 1 ⊰ 2 ] :of: List(ℕ)) test4 = (use ∘ skip ∘ use)(empty) test5 : ([ 1 ⊰ 10 ⊰ 2 ⊰ 3 ]) ⊑ ([ 1 ⊰ 2 ⊰ 3 ] :of: List(ℕ)) test5 = (use ∘ skip ∘ use ∘ use)(empty) test6 : ([ 1 ⊰ 10 ⊰ 2 ⊰ 3 ⊰ 20 ⊰ 30 ⊰ 4 ⊰ 40 ]) ⊑ ([ 1 ⊰ 2 ⊰ 3 ⊰ 4 ] :of: List(ℕ)) test6 = (use ∘ skip ∘ use ∘ use ∘ skip ∘ skip ∘ use ∘ skip)(empty) module testPrimitiveRecursiveDefinitions where open import Data import Function.PrimitiveRecursion open Function.PrimitiveRecursion open Function.PrimitiveRecursion.OperShortcut open import Numeral.Natural import Numeral.Natural.Oper as Nat import Numeral.Natural.Function as Nat open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals.Proofs{Lvl.𝟎}{Lvl.𝟎} plus = Rec(2) (P(1)(0)) (Comp(1)(3) (Succ) (P(3)(1))) pred = Rec(1) (Zero) (P(2)(0)) monus = Comp(2)(2) (Rec(2) (P(1)(0)) (Comp(1)(3) (pred) (P(3)(1)))) (P(2)(1) , P(2)(0)) max = Comp(2)(2) (plus) (P(2)(0) , Comp(2)(2) (monus) (P(2)(1) , P(2)(0))) min = Comp(2)(2) (monus) (plus , max) iszero = Rec(1) (Comp(1)(0) (Succ) (Zero)) (Comp(0)(2) (Zero) <>) const3 = Comp(1)(0) (Succ) (Comp(1)(0) (Succ) (Comp(1)(0) (Succ) (Zero))) -- testPlus1 : evaluate plus(4 , 2) ≡ 6 -- testPlus1 = [≡]-intro -- testMonus1 : evaluate monus(4 , 0) ≡ 4 -- testMonus1 = [≡]-intro -- testMonus2 : evaluate monus(0 , 4) ≡ 0 -- testMonus2 = [≡]-intro -- testMonus3 : evaluate monus(10 , 2) ≡ 8 -- testMonus3 = [≡]-intro -- testMonus4 : evaluate monus(2 , 10) ≡ 0 -- testMonus4 = [≡]-intro -- testMin1 : evaluate min(3 , 2) ≡ Nat.min(3)(2) -- testMin1 = [≡]-intro proofPred : ∀{n} → evaluate pred(n) ≡ 𝐏(n) proofPred{𝟎} = [≡]-intro proofPred{𝐒(n)} = [≡]-intro proofPlus : ∀{a b} → evaluate plus(b , a) ≡ (a Nat.+ b) proofPlus{𝟎} {𝟎} = [≡]-intro proofPlus{𝐒(_)}{𝟎} = [≡]-intro proofPlus{a} {𝐒(b)} = congruence₁(𝐒) (proofPlus{a}{b}) is-zero : ℕ → ℕ is-zero(0) = 1 is-zero(_) = 0 proofIsZero : ∀{n} → evaluate iszero(n) ≡ is-zero(n) proofIsZero{𝟎} = [≡]-intro proofIsZero{𝐒(_)} = [≡]-intro proofMonus : ∀{a} → evaluate monus(a , 𝟎) ≡ (a Nat.−₀ 𝟎) proofMonus{𝟎} = [≡]-intro proofMonus{_} = [≡]-intro proofMax : ∀{a} → evaluate max(0 , a) ≡ Nat.max(a)(0) proofMax{𝟎} = [≡]-intro proofMax{𝐒(_)} = [≡]-intro -- proofMin : ∀{a} → evaluate min(0 , a) ≡ Nat.min(a)(0) -- proofMin{𝟎} = [≡]-intro -- proofMin{𝐒(_)} = [≡]-intro module testEq where -- testEqInstance : ∀{T} ⦃ _ : Equivalence {T} (_≡_ {T}) ⦄ → Symmetry {T} (_≡_ {T}) -- testEqInstance ⦃ eq ⦄ = Equivalence.symmetry eq -- testEqInstance2 : ∀{T} → Symmetry {T} (_≡_ {T}) -- testEqInstance2 = testEqInstance -- testSymInstance : ∀{T} ⦃ _ : Symmetry {T} (_≡_ {T}) ⦄ → Symmetry {T} (_≡_ {T}) -- testSymInstance ⦃ sym ⦄ = sym module testExistential where -- TODO -- testExists : ∀{T : Type}{f : T → Type} → (∃[ x ∈ T ] (f x)) → (∃ {T} (x ↦ f x)) -- testExists x = x module testCantor where import Boolean open Boolean import Data.Boolean.Operators open Data.Boolean.Operators.Programming open import Functional open import Logic.Propositional{Lvl.𝟎} open import Logic.Predicate{Lvl.𝟎}{Lvl.𝟎} open import Logic.DiagonalProof{Lvl.𝟎}{Lvl.𝟎} open import Numeral.Natural open import Numeral.Natural.Relation.Countable{Lvl.𝟎}{Lvl.𝟎} open import Relator.Bijection{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals {Lvl.𝟎}{Lvl.𝟎} open import Type{Lvl.𝟎} BitSequence = (ℕ → Bool) CountableBitSequences = (ℕ → BitSequence) -- ∀l∃seq∀n. l(n)(n)≠seq(n) -- There is a bit sequence that is not in the countable list of bit sequences bitSequenceCantor : (l : CountableBitSequences) → ∃{BitSequence}(seq ↦ ∀{n : ℕ} → (l(n)(n) ≢ seq(n))) bitSequenceCantor = diagonal-proof (!_) ([!]-unequality) where [!]-unequality : ∀{b : Bool} → (b ≢ ! b) [!]-unequality {𝑇} () [!]-unequality {𝐹} () -- uncountableProof : CountableBitSequences → ¬(Countable(BitSequence)) -- uncountableProof (l) ([∃]-intro(seq-to-n) ⦃ inj ⦄) = -- [∃]-elim f (bitSequenceCantor(l)) where -- postulate f : ∀{seq}{x : ℕ → Bool} → {n : ℕ} → (l n n ≢ x n) → ⊥ -- ∀{T}{seq}{n : ℕ} → (l(n)(n) ≢ seq(n)) → T -- f : ∀{_}{_}(₎ -- f{_}{n}(lnn≢seqn) = lnn≢seqn ∘ inj -- Countable: ∃(seq-to-n: (ℕ → Bool) → ℕ)∀(x₁ : ℕ → Bool)∀(x₂: ℕ → Bool). (seq-to-n(seq₁)=seq-to-n(seq₂)) → (seq₁=seq₂) module testListSets where open import Functional open import Data.List import Data.List.Relation.Membership open Data.List.Relation.Membership{Lvl.𝟎} open Data.List.Relation.Membership.[∈]-proof open import Logic.Propositional open import Type{Lvl.𝟎} -- TODO: Probably incorrectly formulated -- Example: -- (∀a. a∈{P,Q} → R) -- P → Q → R -- [∈]-list : ∀{L : List(Type)}{Out : Type} → (∀{a} → (a ∈ L) → Out) → (foldᵣ (_→ᶠ_) (Out) (L)) -- [∈]-list{∅}(f) = f ∘ [⊥]-elim ∘ [∉]-empty -- f : ∀{a} → (a ∈ ∅) → Out -- f ∘ [⊥]-elim : ⊥ → Out -- [∈]-list : ∀{L : List(Type)}{Out : Type} → (foldᵣ (_→ᶠ_) (Out) (L)) → (∀{a} → (a ∈ L) → Out) -- [∈]-list{∅} (out) (a∈∅) = out -- [∈]-list{x ⊰ l} (f) (a∈x⊰l) = [∈]-list{l} (f) module testFinite where open import Numeral.FiniteInclusive test2-0 : ℕfin(2) test2-0 = 𝟎fin test2-1 : ℕfin(2) test2-1 = 𝐒fin(𝟎fin) test2-2 : ℕfin(2) test2-2 = 𝐒fin(𝐒fin(𝟎fin)) -- test2-3 : ℕfin(2) -- test2-3 = 𝐒fin(𝐒fin(𝐒fin(𝟎fin))) -- test2-4 : ℕfin(2) -- test2-4 = 𝐒fin(𝐒fin(𝐒fin(𝐒fin(𝟎fin)))) module testResolveInstance where open import Functional open import Data.List open import Numeral.Natural open import Type data _∈_ {T : Set} (x : T) : List(T) → Set where instance 𝟎 : ∀{l} → x ∈ (x ⊰ l) 𝐒 : ∀{l}{y} → (x ∈ l) → (x ∈ (y ⊰ l)) test1 : 2 ∈ ((1 ⊰ 2 ⊰ 3 ⊰ 4 ⊰ ∅) :of: List(ℕ)) test1 = resolve(_) -- Becomes 𝐒(𝐒(𝟎)) module testPureSet where open import Logic.Propositional{Lvl.𝟎} -- TODO: Does not seem to work. Undefinable because of positivity requirement data PureSet : Set₁ where ∅ : PureSet _∪_ : PureSet → PureSet → PureSet ℘ : PureSet → PureSet -- subset : PureSet → (PureSet → Stmt) → PureSet data _∈_ (x : PureSet) : PureSet → Set₀ where empty : ⊥ → (x ∈ ∅) union : ∀{s₁ s₂} → (x ∈ s₁)∨(x ∈ s₂) → (x ∈ (s₁ ∪ s₂)) -- power : ∀{s} → (∀{y} → (y ∈ x) → (y ∈ s)) → (x ∈ ℘(s)) {- TODO: Stuck module testInstanceResolution where open import Logic.Propositional{Lvl.𝟎} open import Functional postulate A₁ : Set → Set postulate A₂ : Set instance postulate test0 : ∀{x}{y} → ⦃ _ : x ← y ⦄ → ⦃ _ : x → y ⦄ → (x ↔ y) instance postulate test1 : A₁(A₂) ← A₁(A₂) instance postulate test2 : A₁(A₂) → A₁(A₂) B = A₁(A₂) ↔ A₁(A₂) f : (B → ⊤) → ⊤ f(g) = g(resolve(B)) -} module inferAbstract where open import Functional postulate A : Set -> Set abstract -- TODO: This pattern could be a macro? See http://agda.readthedocs.io/en/v2.5.3/language/reflection.html for docs and https://github.com/asr/my-agda/blob/4ef826275053a502075e66de7a5cc77964b4291c/test/Succeed/UnquoteDef.agda for examples of macros Test = ∀{a} → A(a) → A(a) Test-elim : Test → ∀{a} → A(a) → A(a) Test-elim(x) = x instance postulate test2 : Test postulate test3 : Test → Test test4 : Test test4 = test3(infer) module testDomainRaise where open import Function.DomainRaise open import Data.List open import Numeral.Natural open import Numeral.Finite open import Numeral.Natural.Oper open import Syntax.Number open import Relator.Equals {Lvl.𝟎}{Lvl.𝟎} f : (ℕ →̂ List(ℕ))(3) f a b c = (a ⋅ 10) ⊰ (b ⋅ 100) ⊰ (c ⋅ 1000) ⊰ ∅ testApplyRepeated : applyRepeated{Lvl.𝟎}{Lvl.𝟎}{3}(f)(1) ≡ 10 ⊰ 100 ⊰ 1000 ⊰ ∅ testApplyRepeated = [≡]-intro g : 𝕟(3) → ℕ g(𝐒(𝐒(𝟎))) = 1 g(𝐒(𝟎)) = 2 g(𝟎) = 3 testApplyFn : applyFn{Lvl.𝟎}{Lvl.𝟎}{3}(f)(g) ≡ 10 ⊰ 200 ⊰ 3000 ⊰ ∅ testApplyFn = [≡]-intro testOn : _on_{Lvl.𝟎}{Lvl.𝟎}{Lvl.𝟎}{3} (𝐒) f 1 2 3 ≡ (𝐒(1) ⋅ 10) ⊰ (𝐒(2) ⋅ 100) ⊰ (𝐒(3) ⋅ 1000) ⊰ ∅ testOn = [≡]-intro testNaryL1 : naryₗ{Lvl.𝟎}{2}{List(ℕ)}(_++_) (0 ⊰ ∅) (1 ⊰ ∅) (2 ⊰ ∅) (3 ⊰ ∅) ≡ 0 ⊰ 1 ⊰ 2 ⊰ 3 ⊰ ∅ testNaryL1 = [≡]-intro testNaryL2 : naryₗ{Lvl.𝟎}{2}{ℕ}(_−₀_) (12) (5) (2) (1) ≡ ((12 −₀ 5) −₀ 2) −₀ 1 testNaryL2 = [≡]-intro -- 12−(5−(2−1)) = 8 -- (((12−5)−2)−1) = 4 testNaryR1 : naryᵣ{Lvl.𝟎}{2}{List(ℕ)}(_++_) (0 ⊰ ∅) (1 ⊰ ∅) (2 ⊰ ∅) (3 ⊰ ∅) ≡ 0 ⊰ 1 ⊰ 2 ⊰ 3 ⊰ ∅ testNaryR1 = [≡]-intro testNaryR2 : naryᵣ{Lvl.𝟎}{2}{ℕ}(_−₀_) (12) (5) (2) (1) ≡ 12 −₀ (5 −₀ (2 −₀ 1)) testNaryR2 = [≡]-intro
{ "alphanum_fraction": 0.5477592411, "avg_line_length": 30.0196399345, "ext": "agda", "hexsha": "e9bbd37530532881ab7dfdd2cf959d7d7d089198", "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/Test.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/Test.agda", "max_line_length": 258, "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/Test.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": 9122, "size": 18342 }
{-# OPTIONS --type-in-type --without-K #-} {- Semi-simplicial types: A small demonstration that the "usual approach" works if we postulate the required coherence for the functorial behaviour of the "Skeleton" functor. This coherence can be achieved in a 2-level system, where the required functor law can be shown to hold strictly. -} module nicolai.SemiSimp.SStypes where open import lib.Basics open import lib.types.Unit open import lib.types.Nat -- This is the usual lemma about equality of pairs -- (ideally, it should be imported from lib.types.Sigma ) pair== : {A : Set}{B : A → Set}{ab ab' : Σ A B} → (Σ (fst ab == fst ab') (λ α → transport B α (snd ab) == snd ab')) → ab == ab' pair== {ab = (a , b)}{ab' = (.a , .b)} ( idp , idp ) = idp -- Finite types data Fin : ℕ → Set where fz : {n : ℕ} → Fin (S n) fs : {n : ℕ} → Fin n → Fin (S n) _>fin_ : {n : ℕ} → (i j : Fin n) → Set fz >fin i = Empty fs j >fin fz = ⊤ fs j >fin fs i = j >fin i -- The category Δ₊ can be implemented such that the categorical laws -- (unit, associativity) hold strictly (see my thesis). -- Objects are natural numbers. is-increasing : {m n : ℕ} → (Fin m → Fin n) → Set is-increasing {m} {n} f = {j i : Fin m} → (j >fin i) → ((f j) >fin (f i)) -- hom-sets of Δ₊ _⇒+_ : ℕ → ℕ → Set m ⇒+ n = Σ (Fin (S m) → Fin (S n)) is-increasing -- composition: _∘+_ : {l m n : ℕ} → (m ⇒+ n) → (l ⇒+ m) → (l ⇒+ n) (g , p₂) ∘+ (f , p₁) = (λ i → g(f(i))) , (λ p → p₂ (p₁ p)) -- general lemmas (possibly in the library, should be added if they are not there) trans-ap : {A B : Set} → (f : B → A) → (F : A → Set) → {b₁ b₂ : B} → (p : b₁ == b₂) → (x : F (f b₁)) → (transport (λ b → F (f b)) p x) == (transport F (ap f p) x) trans-ap f F idp x = idp trans-λ : {A B : Set} → (F : A → B → Set) → {a₁ a₂ : A} → (f : (b : B) → F a₁ b) → (p : a₁ == a₂) → transport (λ a → (b : B) → F a b) p f == λ b → transport (λ a → F a b) p (f b) trans-λ F f idp = idp -- Semi-simplicial types -- SST j is the type of (j-1)-truncated semi-simplicial types, i.e. "Σ X₀ Σ ... Xⱼ₋₁" SST : ℕ → Set -- skeleton of a k-simplex: cells lower (!) than level j Sk : {j : ℕ} → (SST j) → (k : ℕ) → Set Skm : {j : ℕ} → (X : SST j) → {k₁ k₂ : ℕ} → (k₁ ⇒+ k₂) → Sk {j = j} X k₂ → Sk {j = j} X k₁ Skm-∘ : {j : ℕ} → (X : SST j) → {k₁ k₂ k₃ : ℕ} → (f : k₁ ⇒+ k₂) → (g : k₂ ⇒+ k₃) → (x : Sk X k₃) → Skm X (g ∘+ f) x == Skm X f (Skm X g x) -- We postulate that Skm is coherent. This is automatic if we use equality with K. -- We want to demonstrate that the "usual" construction of semi-simplicial types -- (the one that many people have tried; see Herbelin's paper) works if we can -- somehow get this coherence. -- Of course, this is not new (see e.g. Herbelin). postulate Skm-∘-coh : {j : ℕ} → (X : SST j) → {k₀ k₁ k₂ k₃ : ℕ} → (h : k₀ ⇒+ k₁) → (f : k₁ ⇒+ k₂) → (g : k₂ ⇒+ k₃) → (x : Sk X k₃) → ((Skm-∘ X h (g ∘+ f) x) ∙ (ap (Skm X h) (Skm-∘ X f g x))) == (Skm-∘ X (f ∘+ h) g x) ∙ (Skm-∘ X h f (Skm X g x)) SST O = ⊤ SST (S j) = Σ (SST j) λ X → Sk X j → Set Sk {O} ⋆ k = ⊤ Sk {S j} (X , Fibʲ) k = Σ (Sk {j} X k) λ sk → (f : j ⇒+ k) → Fibʲ (Skm X f sk) Skm {O} ⋆ f sk = ⋆ Skm {S j} (X , Fibʲ) f (x , fibs) = Skm {j} X f x , λ g → transport Fibʲ (Skm-∘ X g f x) (fibs (f ∘+ g)) Skm-∘ {O} ⊤ f g x = idp Skm-∘ {S j} (X , Fibʲ) {k₁} {k₂} {k₃} f g (x , fibs) = Skm (X , Fibʲ) (g ∘+ f) (x , fibs) =⟨ idp ⟩ Skm X (g ∘+ f) x , (λ h → transport Fibʲ (Skm-∘ X h (g ∘+ f) x) (fibs ((g ∘+ f) ∘+ h))) =⟨ pair== (Skm-∘ X f g x , idp) ⟩ Skm X f (Skm X g x) , transport (λ y → (h : j ⇒+ k₁) → Fibʲ (Skm X h y)) (Skm-∘ X f g x) (λ h → transport Fibʲ (Skm-∘ X h (g ∘+ f) x) (fibs ((g ∘+ f) ∘+ h))) =⟨ idp ⟩ Skm X f (Skm X g x) , transport (λ y → (h : j ⇒+ k₁) → Fibʲ (Skm X h y)) (Skm-∘ X f g x) (λ h → transport Fibʲ (Skm-∘ X h (g ∘+ f) x) (fibs ((g ∘+ f) ∘+ h))) =⟨ pair== (idp , trans-λ {B = j ⇒+ k₁} (λ y h → Fibʲ (Skm X h y)) (λ h → transport Fibʲ (Skm-∘ X h (g ∘+ f) x) (fibs ((g ∘+ f) ∘+ h))) (Skm-∘ X f g x)) ⟩ Skm X f (Skm X g x) , (λ (h : j ⇒+ k₁) → transport (λ y → Fibʲ (Skm X h y)) (Skm-∘ X f g x) (transport Fibʲ (Skm-∘ X h (g ∘+ f) x) (fibs ((g ∘+ f) ∘+ h)))) =⟨ pair== (idp , λ= (λ (h : j ⇒+ k₁) → trans-ap (Skm X h) Fibʲ (Skm-∘ X f g x) (transport Fibʲ (Skm-∘ X h (g ∘+ f) x) (fibs ((g ∘+ f) ∘+ h))) )) ⟩ Skm X f (Skm X g x) , (λ (h : j ⇒+ k₁) → transport Fibʲ (ap (Skm X h) (Skm-∘ X f g x)) (transport Fibʲ (Skm-∘ X h (g ∘+ f) x) (fibs ((g ∘+ f) ∘+ h)))) =⟨ pair== (idp , λ= (λ (h : j ⇒+ k₁) → ! (trans-∙ ((Skm-∘ X h (g ∘+ f) x)) ((ap (Skm X h) (Skm-∘ X f g x))) _))) ⟩ Skm X f (Skm X g x) , (λ (h : j ⇒+ k₁) → transport Fibʲ ((Skm-∘ X h (g ∘+ f) x) ∙ (ap (Skm X h) (Skm-∘ X f g x))) (fibs ((g ∘+ f) ∘+ h))) =⟨ pair== (idp , λ= (λ (h : j ⇒+ k₁) → ap (λ p → transport Fibʲ p (fibs ((g ∘+ f) ∘+ h))) (Skm-∘-coh X h f g _ ))) ⟩ -- crucial step that requires coherence! Easy with equality that has K. Skm X f (Skm X g x) , (λ (h : j ⇒+ k₁) → transport Fibʲ ((Skm-∘ X (f ∘+ h) g x) ∙ (Skm-∘ X h f (Skm X g x))) (fibs ((g ∘+ f) ∘+ h))) =⟨ pair== (idp , λ= (λ (h : j ⇒+ k₁) → trans-∙ (Skm-∘ X (f ∘+ h) g x) ((Skm-∘ X h f (Skm X g x))) (fibs ((g ∘+ f) ∘+ h))) ) ⟩ -- functoriality of transport; very simple. Uses funext. Skm X f (Skm X g x) , (λ (h : j ⇒+ k₁) → transport Fibʲ (Skm-∘ X h f (Skm X g x)) (transport Fibʲ (Skm-∘ X (f ∘+ h) g x) (fibs ((g ∘+ f) ∘+ h)))) =⟨ idp ⟩ -- nothing happening here, only formatting Skm X f (Skm X g x) , (λ h → transport Fibʲ (Skm-∘ X h f (Skm X g x)) (transport Fibʲ (Skm-∘ X (f ∘+ h) g x) (fibs ((g ∘+ f) ∘+ h)))) =⟨ idp ⟩ -- at this point, we use the strictness of Δ₊ in Agda! Skm X f (Skm X g x) , (λ h → transport Fibʲ (Skm-∘ X h f (Skm X g x)) (transport Fibʲ (Skm-∘ X (f ∘+ h) g x) (fibs (g ∘+ (f ∘+ h))))) =⟨ idp ⟩ Skm (X , Fibʲ) f (Skm X g x , λ h' → transport Fibʲ (Skm-∘ X h' g x) (fibs (g ∘+ h'))) =⟨ idp ⟩ Skm (X , Fibʲ) f (Skm (X , Fibʲ) g (x , fibs)) ∎
{ "alphanum_fraction": 0.4836052334, "avg_line_length": 39.4331210191, "ext": "agda", "hexsha": "83d50f1a60882b44192b08092031537fabed260a", "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": "nicolai/SemiSimp/SStypes.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": "nicolai/SemiSimp/SStypes.agda", "max_line_length": 190, "max_stars_count": 1, "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_path": "nicolai/SemiSimp/SStypes.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": 2887, "size": 6191 }
record R : Set₁ where field _A : Set P : Set → Set₁ P R.A = Set
{ "alphanum_fraction": 0.5633802817, "avg_line_length": 10.1428571429, "ext": "agda", "hexsha": "6a5626fb58b607eec0797c9cdf30786ca93afef8", "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/Issue2332.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/Issue2332.agda", "max_line_length": 21, "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/Issue2332.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": 29, "size": 71 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Vec.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence import Cubical.Data.Empty as ⊥ open import Cubical.Data.Nat open import Cubical.Data.Vec.Base open import Cubical.Data.FinData open import Cubical.Relation.Nullary private variable ℓ : Level A : Type ℓ -- This is really cool! -- Compare with: https://github.com/agda/agda-stdlib/blob/master/src/Data/Vec/Properties/WithK.agda#L32 ++-assoc : ∀ {m n k} (xs : Vec A m) (ys : Vec A n) (zs : Vec A k) → PathP (λ i → Vec A (+-assoc m n k (~ i))) ((xs ++ ys) ++ zs) (xs ++ ys ++ zs) ++-assoc {m = zero} [] ys zs = refl ++-assoc {m = suc m} (x ∷ xs) ys zs i = x ∷ ++-assoc xs ys zs i -- Equivalence between Fin n → A and Vec A n FinVec : (A : Type ℓ) (n : ℕ) → Type ℓ FinVec A n = Fin n → A FinVec→Vec : {n : ℕ} → FinVec A n → Vec A n FinVec→Vec {n = zero} xs = [] FinVec→Vec {n = suc _} xs = xs zero ∷ FinVec→Vec (λ x → xs (suc x)) Vec→FinVec : {n : ℕ} → Vec A n → FinVec A n Vec→FinVec xs f = lookup f xs FinVec→Vec→FinVec : {n : ℕ} (xs : FinVec A n) → Vec→FinVec (FinVec→Vec xs) ≡ xs FinVec→Vec→FinVec {n = zero} xs = funExt λ f → ⊥.rec (¬Fin0 f) FinVec→Vec→FinVec {n = suc n} xs = funExt goal where goal : (f : Fin (suc n)) → Vec→FinVec (xs zero ∷ FinVec→Vec (λ x → xs (suc x))) f ≡ xs f goal zero = refl goal (suc f) i = FinVec→Vec→FinVec (λ x → xs (suc x)) i f Vec→FinVec→Vec : {n : ℕ} (xs : Vec A n) → FinVec→Vec (Vec→FinVec xs) ≡ xs Vec→FinVec→Vec {n = zero} [] = refl Vec→FinVec→Vec {n = suc n} (x ∷ xs) i = x ∷ Vec→FinVec→Vec xs i FinVecIsoVec : (n : ℕ) → Iso (FinVec A n) (Vec A n) FinVecIsoVec n = iso FinVec→Vec Vec→FinVec Vec→FinVec→Vec FinVec→Vec→FinVec FinVec≃Vec : (n : ℕ) → FinVec A n ≃ Vec A n FinVec≃Vec n = isoToEquiv (FinVecIsoVec n) FinVec≡Vec : (n : ℕ) → FinVec A n ≡ Vec A n FinVec≡Vec n = ua (FinVec≃Vec n) isContrVec0 : isContr (Vec A 0) isContrVec0 = [] , λ { [] → refl }
{ "alphanum_fraction": 0.6276747504, "avg_line_length": 32.3538461538, "ext": "agda", "hexsha": "9f8f0d3164d3fdb118ac59060d38220d11561e3e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Vec/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/Data/Vec/Properties.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Vec/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 815, "size": 2103 }
open import Agda.Primitive using (_⊔_ ; lsuc ; Level) import Categories.Category as Category import Categories.Category.Cartesian as Cartesian open import Categories.Object.Terminal using (Terminal) open import Categories.Object.Product using (Product) open import MultiSorted.AlgebraicTheory open import MultiSorted.Substitution import MultiSorted.Product as Product import MultiSorted.Interpretation as Interpretation import MultiSorted.Model as Is-Model import MultiSorted.InterpretationCategory as InterpretationCategory module MultiSorted.ModelCategory {ℓt o ℓ e} {𝓈 ℴ} {Σ : Signature {𝓈} {ℴ}} (T : Theory ℓt Σ) {𝒞 : Category.Category o ℓ e} (cartesian-𝒞 : Cartesian.Cartesian 𝒞) where open Signature Σ open Theory T open Category.Category 𝒞 open Interpretation Σ cartesian-𝒞 open Is-Model {o = o} {ℓ = ℓ} {e = e} {Σ = Σ} T -- Useful shortcuts for levels ℓℴ : Level ℓℴ = lsuc (o ⊔ ℓ ⊔ e ⊔ 𝓈 ⊔ ℴ ⊔ ℓt) ℓ𝒽 : Level ℓ𝒽 = ℓ ⊔ o ⊔ e ⊔ 𝓈 ⊔ ℴ ℓ𝓇 : Level ℓ𝓇 = e ⊔ 𝓈 -- New definition of models (as a set, not only a property of interpretations) record Model : Set ℓℴ where field interpretation : Interpretation is-model : Is-Model.Is-Model T interpretation open Model -- Homomorphisms of models _⇒M_ : ∀ (M N : Model) → Set ℓ𝒽 _⇒M_ M N = (interpretation M) ⇒I (interpretation N) -- Equality of homomorphisms of models (the same as for the interpretations) _≈M_ : ∀ {M N : Model} → M ⇒M N → M ⇒M N → Set ℓ𝓇 _≈M_ {M} {N} ϕ ψ = let open _⇒I_ in ∀ A → (hom-morphism ϕ {A}) ≈ (hom-morphism ψ) -- The identity morphism on models id-M : (M : Model) → M ⇒M M id-M = λ M → id-I {interpretation M} -- Composition of morphisms of Models _∘M_ : ∀ {M N O : Model} → N ⇒M O → M ⇒M N → M ⇒M O _∘M_ ϕ ψ = ϕ ∘I ψ -- The category of Models of Σ in 𝒞 ℳ : Category.Category ℓℴ ℓ𝒽 ℓ𝓇 ℳ = record { Obj = Model ; _⇒_ = _⇒M_ ; _≈_ = λ {M} {N} ϕ ψ → _≈M_ {M} {N} ϕ ψ ; id = λ {M} → id-M M ; _∘_ = λ {M} {N} {O} ϕ ψ → _∘M_ {M} {N} {O} ϕ ψ ; assoc = λ A → assoc -- λ A → assoc ; sym-assoc = λ A → sym-assoc ; identityˡ = λ A → identityˡ ; identityʳ = λ A → identityʳ ; identity² = λ A → identity² ; equiv = record { refl = λ A → Equiv.refl ; sym = λ p A → Equiv.sym (p A) ; trans = λ p₁ p₂ A → Equiv.trans (p₁ A) (p₂ A) } ; ∘-resp-≈ = λ p₁ p₂ A → ∘-resp-≈ (p₁ A) (p₂ A) } -- The product of "Model proofs" module _ (M N : Model) where open Product.Producted open HomReasoning open InterpretationCategory open Cartesian.Cartesian cartesian-𝒞 open Interpretation.Interpretation open import Categories.Object.Product.Morphisms {o} {ℓ} {e} 𝒞 open Equation -- A proof that an axiom holds in a product interpretation amounts to a apir of proofs that the axiom holds in each model is-model-pairs : ∀ ε → (interp-term (interpretation M) (Equation.eq-lhs (ax-eq ε)) ⁂ interp-term (interpretation N) (Equation.eq-lhs (ax-eq ε))) ≈ (interp-term (interpretation M) (Equation.eq-rhs (ax-eq ε)) ⁂ interp-term (interpretation N) (Equation.eq-rhs (ax-eq ε))) → Interpretation.interp-term (A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N)) (Equation.eq-lhs (ax-eq ε)) ≈ Interpretation.interp-term (A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N)) (Equation.eq-rhs (ax-eq ε)) is-model-pairs ε p = begin Interpretation.interp-term (A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N)) (Equation.eq-lhs (ax-eq ε)) ≈⟨ ⟺ (Cartesian.Cartesian.unique cartesian-𝒞 (natural-π₁ Σ cartesian-𝒞 {I = interpretation M} {interpretation N} (ax-lhs ε)) (natural-π₂ Σ cartesian-𝒞 {I = interpretation M} {interpretation N} (ax-lhs ε))) ⟩ product.⟨ Interpretation.interp-term (interpretation M) (eq-lhs (ax-eq ε)) ∘ π₁ , Interpretation.interp-term (interpretation N) (eq-lhs (ax-eq ε)) ∘ π₂ ⟩ ≈⟨ ⟨⟩-cong₂ (∘-resp-≈ˡ (Is-Model.model-eq (is-model M) ε)) (∘-resp-≈ˡ (Is-Model.model-eq (is-model N) ε)) ⟩ product.⟨ Interpretation.interp-term (interpretation M) (eq-rhs (ax-eq ε)) ∘ π₁ , Interpretation.interp-term (interpretation N) (eq-rhs (ax-eq ε)) ∘ π₂ ⟩ ≈⟨ Cartesian.Cartesian.unique cartesian-𝒞 (natural-π₁ Σ cartesian-𝒞 {I = interpretation M} {interpretation N} (ax-rhs ε)) (natural-π₂ Σ cartesian-𝒞 {I = interpretation M} {interpretation N} (ax-rhs ε)) ⟩ Interpretation.interp-term (A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N)) (eq-rhs (ax-eq ε)) ∎ -- The proof that the product interpetation of two models is a model is-model-product : Is-Model (A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N)) Is-Model.model-eq is-model-product ε = begin Interpretation.interp-term (A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N)) (Equation.eq-lhs (ax-eq ε)) ≈⟨ is-model-pairs ε (⁂-cong₂ (Is-Model.model-eq (is-model M) ε) (Is-Model.model-eq (is-model N) ε)) ⟩ Interpretation.interp-term (A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N)) (Equation.eq-rhs (ax-eq ε)) ∎ -- The product of ℐ𝓃𝓉 carries over the models : the product of two models is a model module _ (M N : Model) where open Product.Producted open HomReasoning open InterpretationCategory A×B-ℳ : Model A×B-ℳ = record { interpretation = A×B-ℐ𝓃𝓉 Σ cartesian-𝒞 (interpretation M) (interpretation N) ; is-model = is-model-product M N } -- The cartesian structure of the category of models module _ {M N : Model} where import Categories.Object.Product.Core open Categories.Object.Product.Core.Product open InterpretationCategory Σ cartesian-𝒞 private UM UN : Interpretation UM = interpretation M UN = interpretation N UM×UN : Product ℐ𝓃𝓉 UM UN UM×UN = product-ℐ𝓃𝓉 product-ℳ : Product ℳ M N -- Structure A×B product-ℳ = A×B-ℳ M N π₁ product-ℳ = π₁ UM×UN π₂ product-ℳ = π₂ UM×UN ⟨_,_⟩ product-ℳ = ⟨_,_⟩ UM×UN -- Properties project₁ product-ℳ {O} {h} {i} = project₁ UM×UN {interpretation O} {h} {i} project₂ product-ℳ {O} {h} {i} = project₂ UM×UN {interpretation O} {h} {i} unique product-ℳ {O} {h} {i} {j} = unique UM×UN {interpretation O} {h} {i} {j}
{ "alphanum_fraction": 0.5227069208, "avg_line_length": 44.1638418079, "ext": "agda", "hexsha": "f00287a8400f8f3e79f8cc1e391883c30b3b6135", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/MultiSorted/ModelCategory.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/MultiSorted/ModelCategory.agda", "max_line_length": 176, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/MultiSorted/ModelCategory.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 2388, "size": 7817 }
-- Andreas, 2017-08-14, issue #2682, test case by Ulf -- WAS: CheckInternal treats abstract projections as not in scope, -- while the type checker allows them. -- Adapted solution: allow also in CheckInternal -- {-# OPTIONS -v tc.rec.proj:20 #-} -- {-# OPTIONS -v tc.deftype:25 #-} -- {-# OPTIONS -v tc:20 #-} abstract record R : Set₁ where field X : Set works : R → Set works r = R.X r test : R → Set test r = {!R.X r!} -- WAS: On give: -- Expected non-abstract record type, found R -- when checking that the expression R.X r has type Set test2 : R → Set test2 r = {! r .X !} where open R
{ "alphanum_fraction": 0.6402640264, "avg_line_length": 20.8965517241, "ext": "agda", "hexsha": "942b932b6d40f18c7bfd48e3f69372852a3c38b6", "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/Issue2682.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/Issue2682.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2682.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": 184, "size": 606 }
module CoprodMonad where open import functor open import monad data PlusT (t₁ t₂ : Set → Set) (a : Set) (p₁ : Triple t₁)(p₂ : Triple t₂) : Set where T₁ : (t₁ (PlusT t₁ t₂ a p₁ p₂)) → PlusT t₁ t₂ a p₁ p₂
{ "alphanum_fraction": 0.6523809524, "avg_line_length": 23.3333333333, "ext": "agda", "hexsha": "ea8d1a04b1e39616787c04a329d0855b8ff2e404", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "CoprodMonad.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "CoprodMonad.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "CoprodMonad.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 85, "size": 210 }
{-# OPTIONS --safe #-} module Cubical.Categories.Instances.CommRings where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.FiberedProduct open import Cubical.Algebra.CommRing.Instances.Unit open import Cubical.Categories.Category open import Cubical.Categories.Limits.Terminal open import Cubical.Categories.Limits.Pullback open Category hiding (_∘_) open CommRingHoms private variable ℓ : Level CommRingsCategory : Category (ℓ-suc ℓ) ℓ ob CommRingsCategory = CommRing _ Hom[_,_] CommRingsCategory = CommRingHom id CommRingsCategory {R} = idCommRingHom R _⋆_ CommRingsCategory {R} {S} {T} = compCommRingHom R S T ⋆IdL CommRingsCategory {R} {S} = compIdCommRingHom {R = R} {S} ⋆IdR CommRingsCategory {R} {S} = idCompCommRingHom {R = R} {S} ⋆Assoc CommRingsCategory {R} {S} {T} {U} = compAssocCommRingHom {R = R} {S} {T} {U} isSetHom CommRingsCategory = isSetRingHom _ _ TerminalCommRing : Terminal {ℓ-suc ℓ-zero} CommRingsCategory fst TerminalCommRing = UnitCommRing fst (fst (snd TerminalCommRing y)) _ = tt snd (fst (snd TerminalCommRing y)) = makeIsRingHom refl (λ _ _ → refl) (λ _ _ → refl) snd (snd TerminalCommRing y) f = RingHom≡ (funExt (λ _ → refl)) open Pullback {- A x_C B -----> A | | | | α | | V V B --------> C β -} PullbackCommRing : Pullbacks {ℓ-suc ℓ} CommRingsCategory pbOb (PullbackCommRing (cospan A C B α β)) = fiberedProduct A B C α β pbPr₁ (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₁ A B C α β pbPr₂ (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₂ A B C α β pbCommutes (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₁₂Commutes A B C α β univProp (PullbackCommRing (cospan A C B α β)) {d = D} = fiberedProductUnivProp A B C α β D
{ "alphanum_fraction": 0.6888888889, "avg_line_length": 34.8387096774, "ext": "agda", "hexsha": "1944b479cb72eb23fb4f52a312b4cd5b0cf0e9c5", "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/Categories/Instances/CommRings.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/Categories/Instances/CommRings.agda", "max_line_length": 91, "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/Categories/Instances/CommRings.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 676, "size": 2160 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.AssocList.Properties where open import Cubical.HITs.AssocList.Base as AL open import Cubical.Foundations.Everything open import Cubical.HITs.FiniteMultiset as FMS open import Cubical.Data.Nat using (ℕ; zero; suc; _+_) private variable ℓ : Level A : Type₀ multiPer : (a b : A) (m n : ℕ) (xs : AssocList A) → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs multiPer a b zero n xs = del a (⟨ b , n ⟩∷ xs) ∙ cong (λ ys → ⟨ b , n ⟩∷ ys) (sym (del a xs)) multiPer a b (suc m) zero xs = cong (λ ys → ⟨ a , suc m ⟩∷ ys) (del b xs) ∙ sym (del b (⟨ a , suc m ⟩∷ xs)) multiPer a b (suc m) (suc n) xs = ⟨ a , suc m ⟩∷ ⟨ b , suc n ⟩∷ xs ≡⟨ sym (agg a 1 m (⟨ b , suc n ⟩∷ xs)) ⟩ ⟨ a , 1 ⟩∷ ⟨ a , m ⟩∷ ⟨ b , suc n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ a , 1 ⟩∷ ys) (multiPer a b m (suc n) xs) ⟩ ⟨ a , 1 ⟩∷ ⟨ b , suc n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ cong (λ ys → ⟨ a , 1 ⟩∷ ys) (sym (agg b 1 n (⟨ a , m ⟩∷ xs))) ⟩ ⟨ a , 1 ⟩∷ ⟨ b , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ per a b (⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs) ⟩ ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ys) (multiPer b a n m xs) ⟩ ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ys) (agg a 1 m (⟨ b , n ⟩∷ xs)) ⟩ ⟨ b , 1 ⟩∷ ⟨ a , suc m ⟩∷ ⟨ b , n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ys) (multiPer a b (suc m) n xs) ⟩ ⟨ b , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , suc m ⟩∷ xs ≡⟨ agg b 1 n (⟨ a , suc m ⟩∷ xs) ⟩ ⟨ b , suc n ⟩∷ ⟨ a , suc m ⟩∷ xs ∎ -- Show that association lists and finite multisets are equivalent multi-∷ : A → ℕ → FMSet A → FMSet A multi-∷ x zero xs = xs multi-∷ x (suc n) xs = x ∷ multi-∷ x n xs multi-∷-agg : (x : A) (m n : ℕ) (b : FMSet A) → multi-∷ x m (multi-∷ x n b) ≡ multi-∷ x (m + n) b multi-∷-agg x zero n b = refl multi-∷-agg x (suc m) n b i = x ∷ (multi-∷-agg x m n b i) AL→FMS : AssocList A → FMSet A AL→FMS = AL.Rec.f FMS.trunc [] multi-∷ comm multi-∷-agg λ _ _ → refl FMS→AL : FMSet A → AssocList A FMS→AL = FMS.Rec.f AL.trunc ⟨⟩ (λ x xs → ⟨ x , 1 ⟩∷ xs) per AL→FMS∘FMS→AL≡id : section {A = AssocList A} AL→FMS FMS→AL AL→FMS∘FMS→AL≡id = FMS.ElimProp.f (FMS.trunc _ _) refl (λ x p → cong (λ ys → x ∷ ys) p) -- need a little lemma for other direction multi-∷-id : (x : A) (n : ℕ) (u : FMSet A) → FMS→AL (multi-∷ x n u) ≡ ⟨ x , n ⟩∷ FMS→AL u multi-∷-id x zero u = sym (del x (FMS→AL u)) multi-∷-id x (suc n) u = FMS→AL (multi-∷ x (suc n) u) ≡⟨ cong (λ ys → ⟨ x , 1 ⟩∷ ys) (multi-∷-id x n u) ⟩ ⟨ x , 1 ⟩∷ ⟨ x , n ⟩∷ (FMS→AL u) ≡⟨ agg x 1 n (FMS→AL u) ⟩ ⟨ x , (suc n) ⟩∷ (FMS→AL u) ∎ FMS→AL∘AL→FMS≡id : retract {A = AssocList A} AL→FMS FMS→AL FMS→AL∘AL→FMS≡id = AL.ElimProp.f (AL.trunc _ _) refl (λ x n {xs} p → (multi-∷-id x n (AL→FMS xs)) ∙ cong (λ ys → ⟨ x , n ⟩∷ ys) p) AssocList≃FMSet : AssocList A ≃ FMSet A AssocList≃FMSet = isoToEquiv (iso AL→FMS FMS→AL AL→FMS∘FMS→AL≡id FMS→AL∘AL→FMS≡id) AssocList≡FMSet : AssocList A ≡ FMSet A AssocList≡FMSet = ua AssocList≃FMSet
{ "alphanum_fraction": 0.4907737132, "avg_line_length": 39.6025641026, "ext": "agda", "hexsha": "e0f5bec1dee9bcf35beaa94cbea39571b7af64bd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/HITs/AssocList/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/HITs/AssocList/Properties.agda", "max_line_length": 130, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/HITs/AssocList/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1553, "size": 3089 }
module Agda.Builtin.FromString where open import Agda.Primitive open import Agda.Builtin.String record IsString {a} (A : Set a) : Set (lsuc a) where field Constraint : String → Set a fromString : (s : String) {{_ : Constraint s}} → A open IsString {{...}} public using (fromString) {-# BUILTIN FROMSTRING fromString #-} {-# DISPLAY IsString.fromString _ s = fromString s #-}
{ "alphanum_fraction": 0.6871794872, "avg_line_length": 24.375, "ext": "agda", "hexsha": "774a1277d3aee01d8f9bf6dbb0bd75548629833e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/FromString.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/FromString.agda", "max_line_length": 54, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/FromString.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 107, "size": 390 }
{-# OPTIONS --cubical --safe #-} module Data.Tree.Braun where open import Prelude open import Data.Nat data Bal (n : ℕ) : ℕ → ℕ → Type where one : Bal n n (1 + n * 2) two : Bal n (suc n) (2 + n * 2) data Tree {a} (A : Type a) : ℕ → Type a where leaf : Tree A 0 node : ∀ {n m r} → (bal : Bal n m r) → A → (ls : Tree A m) → (rs : Tree A n) → Tree A r private variable n : ℕ inc : A → Tree A n → Tree A (suc n) inc x leaf = node one x leaf leaf inc x (node one y ls rs) = node two x (inc y rs) ls inc x (node two y ls rs) = node one x (inc y rs) ls
{ "alphanum_fraction": 0.5594405594, "avg_line_length": 23.8333333333, "ext": "agda", "hexsha": "83469987289e8a9e2b6633b488a812f41e60361d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Tree/Braun.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Tree/Braun.agda", "max_line_length": 89, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Tree/Braun.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": 217, "size": 572 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A solver for proving that one list is a sublist of the other. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Rel; Reflexive; Decidable) module Data.List.Relation.Binary.Sublist.Heterogeneous.Solver {a r} {A : Set a} (R : Rel A r) (R-refl : Reflexive R) (R? : Decidable R) where -- Note that we only need the above two constraints to define the -- solver itself. The data structures do not depend on them. However, -- having the whole module parametrised by them means that we can -- instantiate them upon import. open import Level using (_⊔_) open import Data.Fin as Fin open import Data.Maybe as M open import Data.Nat.Base as Nat using (ℕ) open import Data.Product open import Data.Vec as Vec using (Vec ; lookup) open import Data.List hiding (lookup) open import Data.List.Properties open import Data.List.Relation.Binary.Sublist.Heterogeneous hiding (lookup) open import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties open import Function open import Relation.Binary.PropositionalEquality as P using (_≡_; _≗_; sym; cong; cong₂; subst₂) open import Relation.Nullary open P.≡-Reasoning ------------------------------------------------------------------------ -- Reified list expressions -- Basic building blocks: variables and values data Item (n : ℕ) : Set a where var : Fin n → Item n val : A → Item n -- Abstract Syntax Trees infixr 5 _<>_ data TList (n : ℕ) : Set a where It : Item n → TList n _<>_ : TList n → TList n → TList n [] : TList n -- Equivalent linearised representation RList : ∀ n → Set a RList n = List (Item n) -- Semantics ⟦_⟧I : ∀ {n} → Item n → Vec (List A) n → List A ⟦ var k ⟧I ρ = lookup ρ k ⟦ val a ⟧I ρ = [ a ] ⟦_⟧T : ∀ {n} → TList n → Vec (List A) n → List A ⟦ It it ⟧T ρ = ⟦ it ⟧I ρ ⟦ t <> u ⟧T ρ = ⟦ t ⟧T ρ ++ ⟦ u ⟧T ρ ⟦ [] ⟧T ρ = [] ⟦_⟧R : ∀ {n} → RList n → Vec (List A) n → List A ⟦ [] ⟧R ρ = [] ⟦ x ∷ xs ⟧R ρ = ⟦ x ⟧I ρ ++ ⟦ xs ⟧R ρ -- Orders data _⊆I_ {n} : (d e : Item n) → Set (a ⊔ r) where var : ∀ {k l} → k ≡ l → var k ⊆I var l val : ∀ {a b} → R a b → val a ⊆I val b _⊆T_ : ∀ {n} → (d e : TList n) → Set (a ⊔ r) d ⊆T e = ∀ ρ → Sublist R (⟦ d ⟧T ρ) (⟦ e ⟧T ρ) _⊆R_ : ∀ {n} (d e : RList n) → Set (a ⊔ r) d ⊆R e = ∀ ρ → Sublist R (⟦ d ⟧R ρ) (⟦ e ⟧R ρ) -- Flattening in a semantics-respecting manner ⟦++⟧R : ∀ {n} xs ys (ρ : Vec (List A) n) → ⟦ xs ++ ys ⟧R ρ ≡ ⟦ xs ⟧R ρ ++ ⟦ ys ⟧R ρ ⟦++⟧R [] ys ρ = P.refl ⟦++⟧R (x ∷ xs) ys ρ = begin ⟦ x ⟧I ρ ++ ⟦ xs ++ ys ⟧R ρ ≡⟨ cong (⟦ x ⟧I ρ ++_) (⟦++⟧R xs ys ρ) ⟩ ⟦ x ⟧I ρ ++ ⟦ xs ⟧R ρ ++ ⟦ ys ⟧R ρ ≡⟨ sym $ ++-assoc (⟦ x ⟧I ρ) (⟦ xs ⟧R ρ) (⟦ ys ⟧R ρ) ⟩ (⟦ x ⟧I ρ ++ ⟦ xs ⟧R ρ) ++ ⟦ ys ⟧R ρ ∎ flatten : ∀ {n} (t : TList n) → Σ[ r ∈ RList n ] ⟦ r ⟧R ≗ ⟦ t ⟧T flatten [] = [] , λ _ → P.refl flatten (It it) = it ∷ [] , λ ρ → ++-identityʳ (⟦ It it ⟧T ρ) flatten (t <> u) = let (rt , eqt) = flatten t (ru , equ) = flatten u in rt ++ ru , λ ρ → begin ⟦ rt ++ ru ⟧R ρ ≡⟨ ⟦++⟧R rt ru ρ ⟩ ⟦ rt ⟧R ρ ++ ⟦ ru ⟧R ρ ≡⟨ cong₂ _++_ (eqt ρ) (equ ρ) ⟩ ⟦ t ⟧T ρ ++ ⟦ u ⟧T ρ ≡⟨⟩ ⟦ t <> u ⟧T ρ ∎ ------------------------------------------------------------------------ -- Solver for the sublist problem -- auxiliary lemmas private keep-it : ∀ {n a b} → a ⊆I b → (xs ys : RList n) → xs ⊆R ys → (a ∷ xs) ⊆R (b ∷ ys) keep-it (var a≡b) xs ys hyp ρ = ++⁺ (reflexive R-refl (cong _ a≡b)) (hyp ρ) keep-it (val rab) xs ys hyp ρ = rab ∷ hyp ρ skip-it : ∀ {n} it (d e : RList n) → d ⊆R e → d ⊆R (it ∷ e) skip-it it d ys hyp ρ = ++ˡ (⟦ it ⟧I ρ) (hyp ρ) -- Solver for items solveI : ∀ {n} (a b : Item n) → Maybe (a ⊆I b) solveI (var k) (var l) = M.map var $ decToMaybe (k Fin.≟ l) solveI (val a) (val b) = M.map val $ decToMaybe (R? a b) solveI _ _ = nothing -- Solver for linearised expressions solveR : ∀ {n} (d e : RList n) → Maybe (d ⊆R e) -- trivial solveR [] e = just (λ ρ → minimum _) solveR d [] = nothing -- actual work solveR (a ∷ d) (b ∷ e) with solveI a b ... | just it = M.map (keep-it it d e) (solveR d e) ... | nothing = M.map (skip-it b (a ∷ d) e) (solveR (a ∷ d) e) -- Coming back to ASTs thanks to flatten solveT : ∀ {n} (t u : TList n) → Maybe (t ⊆T u) solveT t u = let (rt , eqt) = flatten t (ru , equ) = flatten u in case solveR rt ru of λ where (just hyp) → just (λ ρ → subst₂ (Sublist R) (eqt ρ) (equ ρ) (hyp ρ)) nothing → nothing -- Prover for ASTs prove : ∀ {n} (d e : TList n) → From-just (solveT d e) prove d e = from-just (solveT d e)
{ "alphanum_fraction": 0.5241437992, "avg_line_length": 30.9276315789, "ext": "agda", "hexsha": "b37096b5ef102ecdf37ad4baec5b52848b38b7cf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Heterogeneous/Solver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Heterogeneous/Solver.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Heterogeneous/Solver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1888, "size": 4701 }
open import Relation.Binary.Core module TreeSort.Everything {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import TreeSort.Impl1.Correctness.Order _≤_ tot≤ trans≤ open import TreeSort.Impl1.Correctness.Permutation _≤_ tot≤ open import TreeSort.Impl2.Correctness.Order _≤_ tot≤ trans≤ open import TreeSort.Impl2.Correctness.Permutation _≤_ tot≤
{ "alphanum_fraction": 0.6659090909, "avg_line_length": 33.8461538462, "ext": "agda", "hexsha": "c79b131aaa71c05f6f643fe1423d2837032a4c4c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/TreeSort/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/TreeSort/Everything.agda", "max_line_length": 60, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/TreeSort/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 140, "size": 440 }
------------------------------------------------------------------------ -- The reflexive transitive closures of McBride, Norell and Jansson ------------------------------------------------------------------------ -- This module could be placed under Relation.Binary. However, since -- its primary purpose is to be used for _data_ it has been placed -- under Data instead. module Data.Star where open import Relation.Binary open import Data.Function infixr 5 _◅_ -- Reflexive transitive closure. data Star {I : Set} (T : Rel I) : Rel I where ε : Reflexive (Star T) _◅_ : ∀ {i j k} (x : T i j) (xs : Star T j k) → Star T i k -- The type of _◅_ is Trans T (Star T) (Star T); I expanded -- the definition in order to be able to name the arguments (x -- and xs). -- Append/transitivity. infixr 5 _◅◅_ _◅◅_ : ∀ {I} {T : Rel I} → Transitive (Star T) ε ◅◅ ys = ys (x ◅ xs) ◅◅ ys = x ◅ (xs ◅◅ ys) -- Sometimes you want to view cons-lists as snoc-lists. Then the -- following "constructor" is handy. Note that this is _not_ snoc for -- cons-lists, it is just a synonym for cons (with a different -- argument order). infixl 5 _▻_ _▻_ : ∀ {I} {T : Rel I} {i j k} → Star T j k → T i j → Star T i k _▻_ = flip _◅_ -- A corresponding variant of append. infixr 5 _▻▻_ _▻▻_ : ∀ {I} {T : Rel I} {i j k} → Star T j k → Star T i j → Star T i k _▻▻_ = flip _◅◅_ -- A generalised variant of map which allows the index type to change. gmap : ∀ {I} {T : Rel I} {J} {U : Rel J} → (f : I → J) → T =[ f ]⇒ U → Star T =[ f ]⇒ Star U gmap f g ε = ε gmap f g (x ◅ xs) = g x ◅ gmap f g xs map : ∀ {I} {T U : Rel I} → T ⇒ U → Star T ⇒ Star U map = gmap id -- TransFlip is used to state the type signature of gfold. TransFlip : ∀ {a} → Rel a → Rel a → Rel a → Set TransFlip P Q R = ∀ {i j k} → Q j k → P i j → R i k -- A generalised variant of fold. gfold : ∀ {I J T} (f : I → J) P → Trans T (P on₁ f) (P on₁ f) → TransFlip (Star T) (P on₁ f) (P on₁ f) gfold f P _⊕_ ∅ ε = ∅ gfold f P _⊕_ ∅ (x ◅ xs) = x ⊕ gfold f P _⊕_ ∅ xs fold : ∀ {I T} (P : Rel I) → Trans T P P → Reflexive P → Star T ⇒ P fold P _⊕_ ∅ = gfold id P _⊕_ ∅ gfoldl : ∀ {I J T} (f : I → J) P → Trans (P on₁ f) T (P on₁ f) → Trans (P on₁ f) (Star T) (P on₁ f) gfoldl f P _⊕_ ∅ ε = ∅ gfoldl f P _⊕_ ∅ (x ◅ xs) = gfoldl f P _⊕_ (∅ ⊕ x) xs foldl : ∀ {I T} (P : Rel I) → Trans P T P → Reflexive P → Star T ⇒ P foldl P _⊕_ ∅ = gfoldl id P _⊕_ ∅ concat : ∀ {I} {T : Rel I} → Star (Star T) ⇒ Star T concat {T = T} = fold (Star T) _◅◅_ ε -- If the underlying relation is symmetric, then the reflexive -- transitive closure is also symmetric. revApp : ∀ {I} {T U : Rel I} → Sym T U → ∀ {i j k} → Star T j i → Star U j k → Star U i k revApp rev ε ys = ys revApp rev (x ◅ xs) ys = revApp rev xs (rev x ◅ ys) reverse : ∀ {I} {T U : Rel I} → Sym T U → Sym (Star T) (Star U) reverse rev xs = revApp rev xs ε -- Reflexive transitive closures form a (generalised) monad. -- return could also be called singleton. return : ∀ {I} {T : Rel I} → T ⇒ Star T return x = x ◅ ε -- A generalised variant of the Kleisli star (flip bind, or -- concatMap). kleisliStar : ∀ {I J} {T : Rel I} {U : Rel J} (f : I → J) → T =[ f ]⇒ Star U → Star T =[ f ]⇒ Star U kleisliStar f g = concat ∘ gmap f g _⋆ : ∀ {I} {T U : Rel I} → T ⇒ Star U → Star T ⇒ Star U _⋆ = kleisliStar id infixl 1 _>>=_ _>>=_ : ∀ {I} {T U : Rel I} {i j} → Star T i j → T ⇒ Star U → Star U i j m >>= f = (f ⋆) m -- Note that the monad-like structure above is not an indexed monad -- (as defined in Category.Monad.Indexed). If it were, then _>>=_ -- would have a type similar to -- -- ∀ {I} {T U : Rel I} {i j k} → -- Star T i j → (T i j → Star U j k) → Star U i k. -- ^^^^^ -- Note, however, that there is no scope for applying T to any indices -- in the definition used in Category.Monad.Indexed.
{ "alphanum_fraction": 0.5373692078, "avg_line_length": 29.5147058824, "ext": "agda", "hexsha": "3b5910931c7402b10a727da71e65ce024f601656", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/Star.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/Star.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/Star.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": 1504, "size": 4014 }
open import Agda.Builtin.Bool open import Agda.Builtin.Equality idTrue : ∀ b → b ≡ true → Bool idTrue b eq = {!!} -- C-c C-c b RET gives us: -- idTrue false eq = {!!} -- idTrue true eq = {!!} -- Now that we can leave `idTrue false eq` out because it's -- trivially an impossible clause, it'd be nice to only get: -- idTrue true eq = {!!} -- But we should still get an absurd clause when we explictly -- ask for it as in the following example: -- C-c C-c e RET should give use -- absurd () data Empty : Set where absurd : ∀ {a} {A : Set a} → Empty → A absurd e = {!!} -- Similarly, C-C C-c b eq RET should give us -- idTrue' false () -- idTrue' true refl = {!!} idTrue' : ∀ b → b ≡ true → Bool idTrue' b eq = {!!} -- If the demanded split leads to trivially absurd clauses but the -- function has a single clause, then we need to generate at least -- one clause. -- Therefore C-c C-c e RET should give us: -- both .true refl f = {!!} both : ∀ b → b ≡ true → b ≡ false → Bool both b e f = {!!} -- This should still be true in an already specialised context both' : ∀ (c : Bool) b → b ≡ true → b ≡ false → Bool both' false b e f = {!!} both' true b e f = {!!}
{ "alphanum_fraction": 0.6211604096, "avg_line_length": 24.4166666667, "ext": "agda", "hexsha": "a408be179e6d4df579c90e84ba1ad629cd71a2f9", "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/Issue3526.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/Issue3526.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue3526.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": 355, "size": 1172 }
{-# OPTIONS --prop --without-K --rewriting #-} module Calf.Types.List where open import Calf.Prelude open import Calf.Metalanguage open import Data.List public using (List; []; _∷_; _∷ʳ_; [_]; length; _++_) list : tp pos → tp pos list A = U (meta (List (val A)))
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 22.25, "ext": "agda", "hexsha": "4c3d5117e7c50332868b597fd72c59cec51f5c23", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Calf/Types/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "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": "jonsterling/agda-calf", "max_issues_repo_path": "src/Calf/Types/List.agda", "max_line_length": 75, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Calf/Types/List.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 81, "size": 267 }
{-# OPTIONS --rewriting --allow-unsolved-metas #-} open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite postulate I : Set A : I → Set HEq : (i0 i1 : I) → A i0 → A i1 → Set HEq-on-refl : (i : I) (a0 a1 : A i) → HEq i i a0 a1 ≡ I {-# REWRITE HEq-on-refl #-} record Con : Set where field f : I → I open Con public postulate Ty : Con → Set module M (Γ : Con) (_ : Ty Γ) where test : let aux1 : A (f Γ _) aux1 = _ aux2 : A (f Γ _) aux2 = _ in HEq _ _ aux1 aux2 test = _
{ "alphanum_fraction": 0.5427046263, "avg_line_length": 19.3793103448, "ext": "agda", "hexsha": "e38e6e2c4843dffbb98ad120ada1b472199f5eb3", "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": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue4721.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "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-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue4721.agda", "max_line_length": 57, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue4721.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": 208, "size": 562 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Code for converting Vec A n → B to and from n-ary functions ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.N-ary where open import Data.Nat.Base hiding (_⊔_) open import Data.Product as Prod open import Data.Vec open import Function open import Function.Equivalence using (_⇔_; equivalence) open import Level using (Level; _⊔_) open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Relation.Nullary.Decidable ------------------------------------------------------------------------ -- N-ary functions N-ary-level : Level → Level → ℕ → Level N-ary-level ℓ₁ ℓ₂ zero = ℓ₂ N-ary-level ℓ₁ ℓ₂ (suc n) = ℓ₁ ⊔ N-ary-level ℓ₁ ℓ₂ n N-ary : ∀ {ℓ₁ ℓ₂} (n : ℕ) → Set ℓ₁ → Set ℓ₂ → Set (N-ary-level ℓ₁ ℓ₂ n) N-ary zero A B = B N-ary (suc n) A B = A → N-ary n A B ------------------------------------------------------------------------ -- Conversion curryⁿ : ∀ {n a b} {A : Set a} {B : Set b} → (Vec A n → B) → N-ary n A B curryⁿ {zero} f = f [] curryⁿ {suc n} f = λ x → curryⁿ (f ∘ _∷_ x) _$ⁿ_ : ∀ {n a b} {A : Set a} {B : Set b} → N-ary n A B → (Vec A n → B) f $ⁿ [] = f f $ⁿ (x ∷ xs) = f x $ⁿ xs ------------------------------------------------------------------------ -- Quantifiers -- Universal quantifier. ∀ⁿ : ∀ n {a ℓ} {A : Set a} → N-ary n A (Set ℓ) → Set (N-ary-level a ℓ n) ∀ⁿ zero P = P ∀ⁿ (suc n) P = ∀ x → ∀ⁿ n (P x) -- Universal quantifier with implicit (hidden) arguments. ∀ⁿʰ : ∀ n {a ℓ} {A : Set a} → N-ary n A (Set ℓ) → Set (N-ary-level a ℓ n) ∀ⁿʰ zero P = P ∀ⁿʰ (suc n) P = ∀ {x} → ∀ⁿʰ n (P x) -- Existential quantifier. ∃ⁿ : ∀ n {a ℓ} {A : Set a} → N-ary n A (Set ℓ) → Set (N-ary-level a ℓ n) ∃ⁿ zero P = P ∃ⁿ (suc n) P = ∃ λ x → ∃ⁿ n (P x) ------------------------------------------------------------------------ -- N-ary function equality Eq : ∀ {a b c ℓ} {A : Set a} {B : Set b} {C : Set c} n → REL B C ℓ → REL (N-ary n A B) (N-ary n A C) (N-ary-level a ℓ n) Eq n _∼_ f g = ∀ⁿ n (curryⁿ {n = n} λ xs → (f $ⁿ xs) ∼ (g $ⁿ xs)) -- A variant where all the arguments are implicit (hidden). Eqʰ : ∀ {a b c ℓ} {A : Set a} {B : Set b} {C : Set c} n → REL B C ℓ → REL (N-ary n A B) (N-ary n A C) (N-ary-level a ℓ n) Eqʰ n _∼_ f g = ∀ⁿʰ n (curryⁿ {n = n} λ xs → (f $ⁿ xs) ∼ (g $ⁿ xs)) ------------------------------------------------------------------------ -- Some lemmas -- The functions curryⁿ and _$ⁿ_ are inverses. left-inverse : ∀ {n a b} {A : Set a} {B : Set b} (f : Vec A n → B) → ∀ xs → (curryⁿ f $ⁿ xs) ≡ f xs left-inverse f [] = refl left-inverse f (x ∷ xs) = left-inverse (f ∘ _∷_ x) xs right-inverse : ∀ {a b} {A : Set a} {B : Set b} n (f : N-ary n A B) → Eq n _≡_ (curryⁿ (_$ⁿ_ {n} f)) f right-inverse zero f = refl right-inverse (suc n) f = λ x → right-inverse n (f x) -- ∀ⁿ can be expressed in an "uncurried" way. uncurry-∀ⁿ : ∀ n {a ℓ} {A : Set a} {P : N-ary n A (Set ℓ)} → ∀ⁿ n P ⇔ (∀ (xs : Vec A n) → P $ⁿ xs) uncurry-∀ⁿ n {a} {ℓ} {A} = equivalence (⇒ n) (⇐ n) where ⇒ : ∀ n {P : N-ary n A (Set ℓ)} → ∀ⁿ n P → (∀ (xs : Vec A n) → P $ⁿ xs) ⇒ zero p [] = p ⇒ (suc n) p (x ∷ xs) = ⇒ n (p x) xs ⇐ : ∀ n {P : N-ary n A (Set ℓ)} → (∀ (xs : Vec A n) → P $ⁿ xs) → ∀ⁿ n P ⇐ zero p = p [] ⇐ (suc n) p = λ x → ⇐ n (p ∘ _∷_ x) -- ∃ⁿ can be expressed in an "uncurried" way. uncurry-∃ⁿ : ∀ n {a ℓ} {A : Set a} {P : N-ary n A (Set ℓ)} → ∃ⁿ n P ⇔ (∃ λ (xs : Vec A n) → P $ⁿ xs) uncurry-∃ⁿ n {a} {ℓ} {A} = equivalence (⇒ n) (⇐ n) where ⇒ : ∀ n {P : N-ary n A (Set ℓ)} → ∃ⁿ n P → (∃ λ (xs : Vec A n) → P $ⁿ xs) ⇒ zero p = ([] , p) ⇒ (suc n) (x , p) = Prod.map (_∷_ x) id (⇒ n p) ⇐ : ∀ n {P : N-ary n A (Set ℓ)} → (∃ λ (xs : Vec A n) → P $ⁿ xs) → ∃ⁿ n P ⇐ zero ([] , p) = p ⇐ (suc n) (x ∷ xs , p) = (x , ⇐ n (xs , p)) -- Conversion preserves equality. curryⁿ-cong : ∀ {n a b c ℓ} {A : Set a} {B : Set b} {C : Set c} (_∼_ : REL B C ℓ) (f : Vec A n → B) (g : Vec A n → C) → (∀ xs → f xs ∼ g xs) → Eq n _∼_ (curryⁿ f) (curryⁿ g) curryⁿ-cong {zero} _∼_ f g hyp = hyp [] curryⁿ-cong {suc n} _∼_ f g hyp = λ x → curryⁿ-cong _∼_ (f ∘ _∷_ x) (g ∘ _∷_ x) (λ xs → hyp (x ∷ xs)) curryⁿ-cong⁻¹ : ∀ {n a b c ℓ} {A : Set a} {B : Set b} {C : Set c} (_∼_ : REL B C ℓ) (f : Vec A n → B) (g : Vec A n → C) → Eq n _∼_ (curryⁿ f) (curryⁿ g) → ∀ xs → f xs ∼ g xs curryⁿ-cong⁻¹ _∼_ f g hyp [] = hyp curryⁿ-cong⁻¹ _∼_ f g hyp (x ∷ xs) = curryⁿ-cong⁻¹ _∼_ (f ∘ _∷_ x) (g ∘ _∷_ x) (hyp x) xs appⁿ-cong : ∀ {n a b c ℓ} {A : Set a} {B : Set b} {C : Set c} (_∼_ : REL B C ℓ) (f : N-ary n A B) (g : N-ary n A C) → Eq n _∼_ f g → (xs : Vec A n) → (f $ⁿ xs) ∼ (g $ⁿ xs) appⁿ-cong _∼_ f g hyp [] = hyp appⁿ-cong _∼_ f g hyp (x ∷ xs) = appⁿ-cong _∼_ (f x) (g x) (hyp x) xs appⁿ-cong⁻¹ : ∀ {n a b c ℓ} {A : Set a} {B : Set b} {C : Set c} (_∼_ : REL B C ℓ) (f : N-ary n A B) (g : N-ary n A C) → ((xs : Vec A n) → (f $ⁿ xs) ∼ (g $ⁿ xs)) → Eq n _∼_ f g appⁿ-cong⁻¹ {zero} _∼_ f g hyp = hyp [] appⁿ-cong⁻¹ {suc n} _∼_ f g hyp = λ x → appⁿ-cong⁻¹ _∼_ (f x) (g x) (λ xs → hyp (x ∷ xs)) -- Eq and Eqʰ are equivalent. Eq-to-Eqʰ : ∀ {a b c ℓ} {A : Set a} {B : Set b} {C : Set c} n (_∼_ : REL B C ℓ) {f : N-ary n A B} {g : N-ary n A C} → Eq n _∼_ f g → Eqʰ n _∼_ f g Eq-to-Eqʰ zero _∼_ eq = eq Eq-to-Eqʰ (suc n) _∼_ eq = Eq-to-Eqʰ n _∼_ (eq _) Eqʰ-to-Eq : ∀ {a b c ℓ} {A : Set a} {B : Set b} {C : Set c} n (_∼_ : REL B C ℓ) {f : N-ary n A B} {g : N-ary n A C} → Eqʰ n _∼_ f g → Eq n _∼_ f g Eqʰ-to-Eq zero _∼_ eq = eq Eqʰ-to-Eq (suc n) _∼_ eq = λ _ → Eqʰ-to-Eq n _∼_ eq
{ "alphanum_fraction": 0.4366500829, "avg_line_length": 34.6551724138, "ext": "agda", "hexsha": "d4498b29fd1334db9bef07e828a5f7847f1f6ca4", "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/Vec/N-ary.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/Vec/N-ary.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/Vec/N-ary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2680, "size": 6030 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Concrete.Obligations open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Impl.Base.Types open import LibraBFT.Impl.Consensus.Types open EpochConfig open import LibraBFT.Concrete.System open import LibraBFT.Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms PeerCanSignForPK (λ {st} {part} {pk} → PeerCanSignForPK-stable {st} {part} {pk}) -- In this module, we assume that the implementation meets its -- obligations, and use this assumption to prove that, in any reachable -- state, the implementatioon enjoys one of the per-epoch correctness -- conditions proved in Abstract.Properties. It can be extended to other -- properties later. module LibraBFT.Concrete.Properties (impl-correct : ImplObligations) (st : SystemState) (r : ReachableSystemState st) (𝓔 : EpochConfig) where open ImplObligations impl-correct open WithSPS sps-cor open PerState st r open PerEpoch 𝓔 open import LibraBFT.Abstract.Abstract UID _≟UID_ NodeId 𝓔 (ConcreteVoteEvidence 𝓔) as Abs open import LibraBFT.Concrete.Intermediate 𝓔 (ConcreteVoteEvidence 𝓔) import LibraBFT.Concrete.Obligations.VotesOnce 𝓔 (ConcreteVoteEvidence 𝓔) as VO-obl import LibraBFT.Concrete.Obligations.PreferredRound 𝓔 (ConcreteVoteEvidence 𝓔) as PR-obl open import LibraBFT.Concrete.Properties.VotesOnce as VO open import LibraBFT.Concrete.Properties.PreferredRound as PR -------------------------------------------------------------------------------------------- -- * A /ValidSysState/ is one in which both peer obligations are obeyed by honest peers * -- -------------------------------------------------------------------------------------------- record ValidSysState {ℓ}(𝓢 : IntermediateSystemState ℓ) : Set (ℓ+1 ℓ0 ℓ⊔ ℓ) where field vss-votes-once : VO-obl.Type 𝓢 vss-preferred-round : PR-obl.Type 𝓢 open ValidSysState public -- TODO-2 : This should be provided as a module parameter here, and the -- proofs provided to instantiate it should be refactored into LibraBFT.Impl. -- However, see the TODO-3 in LibraBFT.Concrete.Intermediate, which suggests -- that those proofs may change, perhaps some parts of them will remain in -- Concrete and others should be in Impl, depending on how that TODO-3 is -- addressed. There is not much point in doing said refactoring until we -- make progress on that question. validState : ValidSysState IntSystemState validState = record { vss-votes-once = VO.Proof.voo sps-cor vo₁ vo₂ st r 𝓔 ; vss-preferred-round = PR.Proof.prr sps-cor pr₁ st r 𝓔 } open IntermediateSystemState IntSystemState open All-InSys-props InSys open WithAssumptions InSys -- We can now invoke the various abstract correctness properties. Note that the arguments are -- expressed in Abstract terms (RecordChain, CommitRule). Proving the corresponding properties -- for the actual implementation will involve proving that the implementation decides to commit -- only if it has evidence of the required RecordChains and CommitRules such that the records in -- the RecordChains are all "InSys" according to the implementation's notion thereof (defined in -- Concrete.System.IntSystemState). ConcCommitsDoNotConflict : ∀{q q'} → {rc : RecordChain (Abs.Q q)} → All-InSys rc → {rc' : RecordChain (Abs.Q q')} → All-InSys rc' → {b b' : Abs.Block} → CommitRule rc b → CommitRule rc' b' → NonInjective-≡ Abs.bId ⊎ ((Abs.B b) ∈RC rc' ⊎ (Abs.B b') ∈RC rc) ConcCommitsDoNotConflict = CommitsDoNotConflict (VO-obl.proof IntSystemState (vss-votes-once validState)) (PR-obl.proof IntSystemState (vss-preferred-round validState)) module _ (∈QC⇒AllSent : Complete InSys) where ConcCommitsDoNotConflict' : ∀{q q'}{rc : RecordChain (Abs.Q q)}{rc' : RecordChain (Abs.Q q')}{b b' : Abs.Block} → InSys (Abs.Q q) → InSys (Abs.Q q') → CommitRule rc b → CommitRule rc' b' → NonInjective-≡ Abs.bId ⊎ ((Abs.B b) ∈RC rc' ⊎ (Abs.B b') ∈RC rc) ConcCommitsDoNotConflict' = CommitsDoNotConflict' (VO-obl.proof IntSystemState (vss-votes-once validState)) (PR-obl.proof IntSystemState (vss-preferred-round validState)) ∈QC⇒AllSent ConcCommitsDoNotConflict'' : ∀{o o' q q'} → {rcf : RecordChainFrom o (Abs.Q q)} → {rcf' : RecordChainFrom o' (Abs.Q q')} → {b b' : Abs.Block} → InSys (Abs.Q q) → InSys (Abs.Q q') → CommitRuleFrom rcf b → CommitRuleFrom rcf' b' → NonInjective-≡ Abs.bId ⊎ Σ (RecordChain (Abs.Q q')) ((Abs.B b) ∈RC_) ⊎ Σ (RecordChain (Abs.Q q)) ((Abs.B b') ∈RC_) ConcCommitsDoNotConflict'' = CommitsDoNotConflict'' (VO-obl.proof IntSystemState (vss-votes-once validState)) (PR-obl.proof IntSystemState (vss-preferred-round validState)) ∈QC⇒AllSent
{ "alphanum_fraction": 0.6383209698, "avg_line_length": 48.4824561404, "ext": "agda", "hexsha": "7459c6e84bcb147fb1baf1e9886408c52315ccb2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Concrete/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Concrete/Properties.agda", "max_line_length": 146, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Concrete/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1518, "size": 5527 }
module empty where ---------------------------------------------------------------------- -- datatypes ---------------------------------------------------------------------- data ⊥ : Set where ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- theorems ---------------------------------------------------------------------- ⊥-elim : ⊥ → ∀ {P : Set} → P ⊥-elim ()
{ "alphanum_fraction": 0.1180811808, "avg_line_length": 30.1111111111, "ext": "agda", "hexsha": "750dc99e3c9819be7e6633eae8dec856b40fe3c4", "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": "empty.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": "empty.agda", "max_line_length": 70, "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": "empty.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": 55, "size": 542 }
module Dave.Equality where data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x infix 4 _≡_ {-# BUILTIN EQUALITY _≡_ #-} sym : ∀ {A : Set} {x y : A} → x ≡ y → y ≡ x sym refl = refl trans : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z trans refl b = b cong : ∀ {A B : Set} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y cong f refl = refl cong₂ : ∀ {A B C : Set} (f : A → B → C) {u x : A} {v y : B} → u ≡ x → v ≡ y → f u v ≡ f x y cong₂ f refl refl = refl cong-app : ∀ {A B : Set} {f g : A → B} → f ≡ g → ∀ (x : A) → f x ≡ g x cong-app refl x = refl subst : ∀ {A : Set} {x y : A} (P : A → Set) → x ≡ y → P x → P y subst P refl px = px infix 1 begin_ infixr 2 _≡⟨⟩_ _≡⟨_⟩_ infix 3 _∎ begin_ : ∀ {A : Set} {x y : A} → x ≡ y ----- → x ≡ y begin x≡y = x≡y _≡⟨⟩_ : ∀ {A : Set} (x : A) {y : A} → x ≡ y ----- → x ≡ y x ≡⟨⟩ x≡y = x≡y _≡⟨_⟩_ : ∀ {A : Set} (x : A) {y z : A} → x ≡ y → y ≡ z ----- → x ≡ z x ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z _∎ : ∀ {A : Set} (x : A) ----- → x ≡ x x ∎ = refl
{ "alphanum_fraction": 0.3601398601, "avg_line_length": 19.0666666667, "ext": "agda", "hexsha": "91cc4b74e636b26696e0f2b336b808d0f68730d0", "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": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_path": "Dave/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "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": "DavidStahl97/formal-proofs", "max_issues_repo_path": "Dave/Equality.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_path": "Dave/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 588, "size": 1144 }
{-# OPTIONS --universe-polymorphism #-} module UniversePolymorphicIO where open import Common.Level postulate IO : ∀ {ℓ} → Set ℓ → Set ℓ {-# IMPORT UniversePolymorphicIO #-} {-# COMPILED_TYPE IO UniversePolymorphicIO.AgdaIO #-} {-# BUILTIN IO IO #-} postulate return : ∀ {a} {A : Set a} → A → IO A _>>=_ : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B postulate String : Set {-# BUILTIN STRING String #-} {-# COMPILED return (\_ _ -> return :: a -> IO a) #-} {-# COMPILED _>>=_ (\_ _ _ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-} {-# IMPORT Data.Text.IO #-} postulate Unit : Set putStrLn : String → IO Unit {-# COMPILED_TYPE Unit () #-} {-# COMPILED putStrLn Data.Text.IO.putStrLn #-} data List A : Set where [] : List A _∷_ : A → List A → List A {-# BUILTIN LIST List #-} {-# BUILTIN NIL [] #-} {-# BUILTIN CONS _∷_ #-} main = putStrLn "ok" >>= λ _ → return lzero
{ "alphanum_fraction": 0.552715655, "avg_line_length": 20.4130434783, "ext": "agda", "hexsha": "8193c91f919569d7797fa67c8ab527d7194f12a8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Compiler/simple/UniversePolymorphicIO.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/Compiler/simple/UniversePolymorphicIO.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Compiler/simple/UniversePolymorphicIO.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 299, "size": 939 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Algebra.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open import Cubical.Reflection.RecordEquiv open import Cubical.Algebra.Module open import Cubical.Algebra.Ring open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Group open import Cubical.Algebra.Monoid open Iso private variable ℓ ℓ' ℓ'' ℓ''' : Level record IsAlgebra (R : Ring ℓ) {A : Type ℓ'} (0a 1a : A) (_+_ _·_ : A → A → A) (-_ : A → A) (_⋆_ : ⟨ R ⟩ → A → A) : Type (ℓ-max ℓ ℓ') where constructor isalgebra open RingStr (snd R) using (1r) renaming (_+_ to _+r_; _·_ to _·r_) field isLeftModule : IsLeftModule R 0a _+_ -_ _⋆_ ·-isMonoid : IsMonoid 1a _·_ dist : (x y z : A) → (x · (y + z) ≡ (x · y) + (x · z)) × ((x + y) · z ≡ (x · z) + (y · z)) ⋆-lassoc : (r : ⟨ R ⟩) (x y : A) → (r ⋆ x) · y ≡ r ⋆ (x · y) ⋆-rassoc : (r : ⟨ R ⟩) (x y : A) → r ⋆ (x · y) ≡ x · (r ⋆ y) open IsLeftModule isLeftModule public isRing : IsRing _ _ _ _ _ isRing = isring (IsLeftModule.+-isAbGroup isLeftModule) ·-isMonoid dist open IsRing isRing public hiding (_-_; +Assoc; +Lid; +Linv; +Rid; +Rinv; +Comm) unquoteDecl IsAlgebraIsoΣ = declareRecordIsoΣ IsAlgebraIsoΣ (quote IsAlgebra) record AlgebraStr (R : Ring ℓ) (A : Type ℓ') : Type (ℓ-max ℓ ℓ') where constructor algebrastr field 0a : A 1a : A _+_ : A → A → A _·_ : A → A → A -_ : A → A _⋆_ : ⟨ R ⟩ → A → A isAlgebra : IsAlgebra R 0a 1a _+_ _·_ -_ _⋆_ open IsAlgebra isAlgebra public Algebra : (R : Ring ℓ) → ∀ ℓ' → Type (ℓ-max ℓ (ℓ-suc ℓ')) Algebra R ℓ' = Σ[ A ∈ Type ℓ' ] AlgebraStr R A module commonExtractors {R : Ring ℓ} where Algebra→Module : (A : Algebra R ℓ') → LeftModule R ℓ' Algebra→Module (_ , algebrastr A _ _ _ _ _ (isalgebra isLeftModule _ _ _ _)) = _ , leftmodulestr A _ _ _ isLeftModule Algebra→Ring : (A : Algebra R ℓ') → Ring ℓ' Algebra→Ring (_ , str) = _ , ringstr _ _ _ _ _ (IsAlgebra.isRing (AlgebraStr.isAlgebra str)) Algebra→AbGroup : (A : Algebra R ℓ') → AbGroup ℓ' Algebra→AbGroup A = LeftModule→AbGroup (Algebra→Module A) Algebra→Group : (A : Algebra R ℓ') → Group ℓ' Algebra→Group A = Ring→Group (Algebra→Ring A) Algebra→AddMonoid : (A : Algebra R ℓ') → Monoid ℓ' Algebra→AddMonoid A = Group→Monoid (Algebra→Group A) Algebra→MultMonoid : (A : Algebra R ℓ') → Monoid ℓ' Algebra→MultMonoid A = Ring→MultMonoid (Algebra→Ring A) isSetAlgebra : (A : Algebra R ℓ') → isSet ⟨ A ⟩ isSetAlgebra A = isSetAbGroup (Algebra→AbGroup A) open RingStr (snd R) using (1r; ·Ldist+) renaming (_+_ to _+r_; _·_ to _·s_) makeIsAlgebra : {A : Type ℓ'} {0a 1a : A} {_+_ _·_ : A → A → A} { -_ : A → A} {_⋆_ : ⟨ R ⟩ → A → A} (isSet-A : isSet A) (+-assoc : (x y z : A) → x + (y + z) ≡ (x + y) + z) (+-rid : (x : A) → x + 0a ≡ x) (+-rinv : (x : A) → x + (- x) ≡ 0a) (+-comm : (x y : A) → x + y ≡ y + x) (·-assoc : (x y z : A) → x · (y · z) ≡ (x · y) · z) (·-rid : (x : A) → x · 1a ≡ x) (·-lid : (x : A) → 1a · x ≡ x) (·-rdist-+ : (x y z : A) → x · (y + z) ≡ (x · y) + (x · z)) (·-ldist-+ : (x y z : A) → (x + y) · z ≡ (x · z) + (y · z)) (⋆-assoc : (r s : ⟨ R ⟩) (x : A) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x)) (⋆-ldist : (r s : ⟨ R ⟩) (x : A) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x)) (⋆-rdist : (r : ⟨ R ⟩) (x y : A) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y)) (⋆-lid : (x : A) → 1r ⋆ x ≡ x) (⋆-lassoc : (r : ⟨ R ⟩) (x y : A) → (r ⋆ x) · y ≡ r ⋆ (x · y)) (⋆-rassoc : (r : ⟨ R ⟩) (x y : A) → r ⋆ (x · y) ≡ x · (r ⋆ y)) → IsAlgebra R 0a 1a _+_ _·_ -_ _⋆_ makeIsAlgebra isSet-A +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+ ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid ⋆-lassoc ⋆-rassoc = isalgebra (makeIsLeftModule isSet-A +-assoc +-rid +-rinv +-comm ⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid) (makeIsMonoid isSet-A ·-assoc ·-rid ·-lid) (λ x y z → ·-rdist-+ x y z , ·-ldist-+ x y z) ⋆-lassoc ⋆-rassoc open commonExtractors public record IsAlgebraHom {R : Ring ℓ} {A : Type ℓ'} {B : Type ℓ''} (M : AlgebraStr R A) (f : A → B) (N : AlgebraStr R B) : Type (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) where -- Shorter qualified names private module M = AlgebraStr M module N = AlgebraStr N field pres0 : f M.0a ≡ N.0a pres1 : f M.1a ≡ N.1a pres+ : (x y : A) → f (x M.+ y) ≡ f x N.+ f y pres· : (x y : A) → f (x M.· y) ≡ f x N.· f y pres- : (x : A) → f (M.- x) ≡ N.- (f x) pres⋆ : (r : ⟨ R ⟩) (y : A) → f (r M.⋆ y) ≡ r N.⋆ f y unquoteDecl IsAlgebraHomIsoΣ = declareRecordIsoΣ IsAlgebraHomIsoΣ (quote IsAlgebraHom) open IsAlgebraHom AlgebraHom : {R : Ring ℓ} (M : Algebra R ℓ') (N : Algebra R ℓ'') → Type (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) AlgebraHom M N = Σ[ f ∈ (⟨ M ⟩ → ⟨ N ⟩) ] IsAlgebraHom (M .snd) f (N .snd) IsAlgebraEquiv : {R : Ring ℓ} {A : Type ℓ'} {B : Type ℓ''} (M : AlgebraStr R A) (e : A ≃ B) (N : AlgebraStr R B) → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') IsAlgebraEquiv M e N = IsAlgebraHom M (e .fst) N AlgebraEquiv : {R : Ring ℓ} (M : Algebra R ℓ') (N : Algebra R ℓ'') → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') AlgebraEquiv M N = Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] IsAlgebraEquiv (M .snd) e (N .snd) _$a_ : {R : Ring ℓ} {A : Algebra R ℓ'} {B : Algebra R ℓ''} → AlgebraHom A B → ⟨ A ⟩ → ⟨ B ⟩ f $a x = fst f x AlgebraEquiv→AlgebraHom : {R : Ring ℓ} {A : Algebra R ℓ'} {B : Algebra R ℓ''} → AlgebraEquiv A B → AlgebraHom A B AlgebraEquiv→AlgebraHom (e , eIsHom) = e .fst , eIsHom isPropIsAlgebra : (R : Ring ℓ) {A : Type ℓ'} (0a 1a : A) (_+_ _·_ : A → A → A) (-_ : A → A) (_⋆_ : ⟨ R ⟩ → A → A) → isProp (IsAlgebra R 0a 1a _+_ _·_ -_ _⋆_) isPropIsAlgebra R _ _ _ _ _ _ = let open IsLeftModule in isOfHLevelRetractFromIso 1 IsAlgebraIsoΣ (isPropΣ (isPropIsLeftModule _ _ _ _ _) (λ mo → isProp×3 (isPropIsMonoid _ _) (isPropΠ3 λ _ _ _ → isProp× (mo .is-set _ _) (mo .is-set _ _)) (isPropΠ3 λ _ _ _ → mo .is-set _ _) (isPropΠ3 λ _ _ _ → mo .is-set _ _) )) isPropIsAlgebraHom : (R : Ring ℓ) {A : Type ℓ'} {B : Type ℓ''} (AS : AlgebraStr R A) (f : A → B) (BS : AlgebraStr R B) → isProp (IsAlgebraHom AS f BS) isPropIsAlgebraHom R AS f BS = isOfHLevelRetractFromIso 1 IsAlgebraHomIsoΣ (isProp×5 (isSetAlgebra (_ , BS) _ _) (isSetAlgebra (_ , BS) _ _) (isPropΠ2 λ _ _ → isSetAlgebra (_ , BS) _ _) (isPropΠ2 λ _ _ → isSetAlgebra (_ , BS) _ _) (isPropΠ λ _ → isSetAlgebra (_ , BS) _ _) (isPropΠ2 λ _ _ → isSetAlgebra (_ , BS) _ _)) isSetAlgebraHom : {R : Ring ℓ} (M : Algebra R ℓ') (N : Algebra R ℓ'') → isSet (AlgebraHom M N) isSetAlgebraHom _ N = isSetΣ (isSetΠ (λ _ → isSetAlgebra N)) λ _ → isProp→isSet (isPropIsAlgebraHom _ _ _ _) isSetAlgebraEquiv : {R : Ring ℓ} (M N : Algebra R ℓ') → isSet (AlgebraEquiv M N) isSetAlgebraEquiv M N = isSetΣ (isOfHLevel≃ 2 (isSetAlgebra M) (isSetAlgebra N)) λ _ → isProp→isSet (isPropIsAlgebraHom _ _ _ _) AlgebraHom≡ : {R : Ring ℓ} {A B : Algebra R ℓ'} {φ ψ : AlgebraHom A B} → fst φ ≡ fst ψ → φ ≡ ψ AlgebraHom≡ = Σ≡Prop λ f → isPropIsAlgebraHom _ _ f _ 𝒮ᴰ-Algebra : (R : Ring ℓ) → DUARel (𝒮-Univ ℓ') (AlgebraStr R) (ℓ-max ℓ ℓ') 𝒮ᴰ-Algebra R = 𝒮ᴰ-Record (𝒮-Univ _) (IsAlgebraEquiv {R = R}) (fields: data[ 0a ∣ nul ∣ pres0 ] data[ 1a ∣ nul ∣ pres1 ] data[ _+_ ∣ bin ∣ pres+ ] data[ _·_ ∣ bin ∣ pres· ] data[ -_ ∣ autoDUARel _ _ ∣ pres- ] data[ _⋆_ ∣ autoDUARel _ _ ∣ pres⋆ ] prop[ isAlgebra ∣ (λ _ _ → isPropIsAlgebra _ _ _ _ _ _ _) ]) where open AlgebraStr -- faster with some sharing nul = autoDUARel (𝒮-Univ _) (λ A → A) bin = autoDUARel (𝒮-Univ _) (λ A → A → A → A) AlgebraPath : {R : Ring ℓ} (A B : Algebra R ℓ') → (AlgebraEquiv A B) ≃ (A ≡ B) AlgebraPath {R = R} = ∫ (𝒮ᴰ-Algebra R) .UARel.ua uaAlgebra : {R : Ring ℓ} {A B : Algebra R ℓ'} → AlgebraEquiv A B → A ≡ B uaAlgebra {A = A} {B = B} = equivFun (AlgebraPath A B) isGroupoidAlgebra : {R : Ring ℓ} → isGroupoid (Algebra R ℓ') isGroupoidAlgebra _ _ = isOfHLevelRespectEquiv 2 (AlgebraPath _ _) (isSetAlgebraEquiv _ _) -- Smart constructor for ring homomorphisms -- that infers the other equations from pres1, pres+, and pres· module _ {R : Ring ℓ} {A : Algebra R ℓ'} {B : Algebra R ℓ''} {f : ⟨ A ⟩ → ⟨ B ⟩} where private module A = AlgebraStr (A .snd) module B = AlgebraStr (B .snd) module _ (p1 : f A.1a ≡ B.1a) (p+ : (x y : ⟨ A ⟩) → f (x A.+ y) ≡ f x B.+ f y) (p· : (x y : ⟨ A ⟩) → f (x A.· y) ≡ f x B.· f y) (p⋆ : (r : ⟨ R ⟩) (x : ⟨ A ⟩) → f (r A.⋆ x) ≡ r B.⋆ f x) where open IsAlgebraHom private isGHom : IsGroupHom (Algebra→Group A .snd) f (Algebra→Group B .snd) isGHom = makeIsGroupHom p+ makeIsAlgebraHom : IsAlgebraHom (A .snd) f (B .snd) makeIsAlgebraHom .pres0 = isGHom .IsGroupHom.pres1 makeIsAlgebraHom .pres1 = p1 makeIsAlgebraHom .pres+ = p+ makeIsAlgebraHom .pres· = p· makeIsAlgebraHom .pres- = isGHom .IsGroupHom.presinv makeIsAlgebraHom .pres⋆ = p⋆
{ "alphanum_fraction": 0.5184935465, "avg_line_length": 38.4518518519, "ext": "agda", "hexsha": "8db230f92e551b05af4d5e5171b5fdbc0196fceb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/Algebra/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/Algebra/Base.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/Algebra/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4171, "size": 10382 }
open import Common.Prelude open import Common.Reflect module TermSplicing1 where x = unquote Set
{ "alphanum_fraction": 0.8181818182, "avg_line_length": 14.1428571429, "ext": "agda", "hexsha": "8d7416e4ff0aa42ac0df3c59137f8307b54bd0b4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/TermSplicing1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/TermSplicing1.agda", "max_line_length": 26, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/TermSplicing1.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 25, "size": 99 }
{-# OPTIONS --prop --without-K --rewriting #-} -- The basic CBPV metalanguage. open import Calf.CostMonoid module Calf.Metalanguage where open import Calf.Prelude open import Relation.Binary.PropositionalEquality open import Data.Product postulate mode : □ pos : mode neg : mode tp : mode → □ val : tp pos → □ F : tp pos → tp neg U : tp neg → tp pos -- This is equivalent to adding "thunk / force" operations. But less bureaucratic. cmp : tp neg → □ cmp X = val (U X) postulate ret : ∀ {A} → val A → cmp (F A) tbind : ∀ {A} → cmp (F A) → (val A → tp neg) → tp neg tbind_ret : ∀ {A} {X : val A → tp neg} {v : val A} → tbind (ret v) X ≡ X v {-# REWRITE tbind_ret #-} dbind : ∀ {A} (X : val A → tp neg) (e : cmp (F A)) (f : (x : val A) → cmp (X x)) → cmp (tbind e X) -- note that bind is not a special case of dbind: in general, one does not expect (tbind e (λ _ → m)) ≡ m. -- This would hold, however, in the case of a language where there are no true effects. But we don't want -- to assume that. bind : ∀ {A} X → cmp (F A) → (val A → cmp X) → cmp X bind/ret : ∀ {A X} {v : val A} {f : (x : val A) → cmp X} → bind X (ret v) f ≡ f v dbind/ret : ∀ {A} {X : val A → tp neg} {v : val A} {f : (x : val A) → cmp (X x)} → dbind X (ret v) f ≡ f v {-# REWRITE bind/ret dbind/ret #-} tbind/assoc : ∀ {A B X} {e : cmp (F A)} {f : val A → cmp (F B)} → tbind {B} (bind (F B) e f) X ≡ tbind {A} e (λ v → tbind {B} (f v) X) bind/assoc : ∀ {A B C} {e : cmp (F A)} {f1 : val A → cmp (F B)} {f2 : val B → cmp C} → bind C (bind (F B) e f1) f2 ≡ bind C e (λ v → bind C (f1 v) f2) {-# REWRITE tbind/assoc bind/assoc #-} -- dependent product Π : (A : tp pos) (X : val A → tp neg) → tp neg Π/decode : ∀ {A} {X : val A → tp neg} → val (U (Π A X)) ≡ ((x : val A) → cmp (X x)) {-# REWRITE Π/decode #-} -- mixed polarity dependent sum Σ+- : (A : tp pos) (X : val A → tp neg) → tp neg Σ+-/decode : ∀ {A} {X : val A → tp neg} → val (U (Σ+- A X)) ≡ Σ (val A) λ x → cmp (X x) {-# REWRITE Σ+-/decode #-} -- positive dependent sum Σ++ : (A : tp pos) (B : val A → tp pos) → tp pos Σ++/decode : ∀ {A} {B : val A → tp pos} → val (Σ++ A B) ≡ Σ (val A) λ x → val (B x) {-# REWRITE Σ++/decode #-} -- agda sets meta : Set → tp neg meta/out : ∀ {A} → val (U (meta A)) ≡ A {-# REWRITE meta/out #-} bind/meta : ∀ A 𝕊 𝕋 e f (g : 𝕊 → 𝕋) → g (bind {A} (meta 𝕊) e f) ≡ bind {A} (meta 𝕋) e (λ a → g(f a)) tbind/meta : ∀ A 𝕊 e f (p : 𝕊 → □) → p (bind {A} (meta 𝕊) e f) ≡ cmp (tbind {A} e (λ a → meta (p (f a)))) bind/idem : ∀ A 𝕊 e (f : val A → val A → 𝕊) → bind {A} (meta 𝕊) e (λ a → (bind {A} (meta 𝕊) e (λ a' → f a a'))) ≡ bind {A} (meta 𝕊) e (λ a → f a a)
{ "alphanum_fraction": 0.5206033848, "avg_line_length": 36.7297297297, "ext": "agda", "hexsha": "72b8ffe8cac57a34159bb90c838edd215e2514f1", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Calf/Metalanguage.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "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": "jonsterling/agda-calf", "max_issues_repo_path": "src/Calf/Metalanguage.agda", "max_line_length": 149, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Calf/Metalanguage.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 1150, "size": 2718 }
open import Mockingbird.Forest using (Forest) module Mockingbird.Forest.Combination.Vec.Base {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Fin using (Fin; zero; suc; #_) open import Data.Nat using (ℕ; zero; suc) open import Data.Nat.Properties using (_≤?_) open import Data.Vec as Vec using (Vec; _∷_) open import Data.Vec.Relation.Unary.Any using (here; there) public open import Level using (_⊔_) open import Relation.Nullary.Decidable.Core using (True) open import Relation.Unary using (Pred; _∈_) open Forest forest import Mockingbird.Forest.Combination.Base forest as Base import Mockingbird.Forest.Combination.Properties forest as Combinationₚ open import Mockingbird.Forest.Combination.Base forest using ([_]; _⟨∙⟩_∣_; _⟨∙⟩_) public open import Data.Vec.Membership.Setoid setoid using () renaming (_∈_ to _∈′_) ⟨_⟩ : ∀ {n} → Vec Bird n → Pred Bird (b ⊔ ℓ) ⟨ bs ⟩ = Base.⟨ _∈′ bs ⟩ [_]′ : ∀ {n} {bs : Vec Bird n} (i : Fin n) → Vec.lookup bs i ∈ ⟨ bs ⟩ [_]′ {suc n} {x ∷ bs} zero = [ here refl ] [_]′ {suc n} {x ∷ bs} (suc i) = Combinationₚ.⟨ _ ⟩⊆⟨ _ ⟩ there [ i ]′ [#_] : ∀ m {n} {m<n : True (suc m ≤? n)} {bs : Vec Bird n} → Vec.lookup bs (#_ m {m<n = m<n}) ∈ ⟨ bs ⟩ [# m ] = [ # m ]′
{ "alphanum_fraction": 0.6570247934, "avg_line_length": 39.0322580645, "ext": "agda", "hexsha": "c39acf3958edabfd6027262f34a4160fb5455eb4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Forest/Combination/Vec/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Forest/Combination/Vec/Base.agda", "max_line_length": 89, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Forest/Combination/Vec/Base.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 439, "size": 1210 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Injections ------------------------------------------------------------------------ module Function.Injection where open import Function as Fun using () renaming (_∘_ to _⟨∘⟩_) open import Level open import Relation.Binary open import Function.Equality as F using (_⟶_; _⟨$⟩_) renaming (_∘_ to _⟪∘⟫_) import Relation.Binary.PropositionalEquality as P -- Injective functions. Injective : ∀ {a₁ a₂ b₁ b₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} → A ⟶ B → Set _ Injective {A = A} {B} f = ∀ {x y} → f ⟨$⟩ x ≈₂ f ⟨$⟩ y → x ≈₁ y where open Setoid A renaming (_≈_ to _≈₁_) open Setoid B renaming (_≈_ to _≈₂_) -- The set of all injections between two setoids. record Injection {f₁ f₂ t₁ t₂} (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) : Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where field to : From ⟶ To injective : Injective to -- The set of all injections from one set to another. infix 3 _↣_ _↣_ : ∀ {f t} → Set f → Set t → Set _ From ↣ To = Injection (P.setoid From) (P.setoid To) -- Identity and composition. infixr 9 _∘_ id : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → Injection S S id = record { to = F.id; injective = Fun.id } _∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂} {F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} → Injection M T → Injection F M → Injection F T f ∘ g = record { to = to f ⟪∘⟫ to g ; injective = (λ {_} → injective g) ⟨∘⟩ injective f } where open Injection
{ "alphanum_fraction": 0.5344283007, "avg_line_length": 28.7818181818, "ext": "agda", "hexsha": "dfc774397ad32f666efc78bb596a2fe7320fbd8f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Function/Injection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Function/Injection.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Function/Injection.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 534, "size": 1583 }
open import Oscar.Prelude open import Oscar.Class module Oscar.Class.Quadricity where module Quadricity {𝔞} {𝔄 : Ø 𝔞} {𝔟} {𝔅 : Ø 𝔟} {ℓ} (_↦_ : 𝔅 → 𝔅 → Ø ℓ) (let infix 4 _↦_; _↦_ = _↦_) (_∧_ : 𝔅 → 𝔅 → 𝔅) (let infixr 15 _∧_; _∧_ = _∧_) (_∼_ : 𝔄 → 𝔄 → 𝔅) (let infix 18 _∼_; _∼_ = _∼_) (_⊛_ : 𝔄 → 𝔄 → 𝔄) = ℭLASS (_↦_ , _∼_ , _∧_ , _⊛_) (∀ s1 s2 t1 t2 → s1 ⊛ s2 ∼ t1 ⊛ t2 ↦ s1 ∼ t1 ∧ s2 ∼ t2) module _ {𝔞} {𝔄 : Ø 𝔞} {𝔟} {𝔅 : Ø 𝔟} {ℓ} {_↦_ : 𝔅 → 𝔅 → Ø ℓ} {_∧_ : 𝔅 → 𝔅 → 𝔅} {_∼_ : 𝔄 → 𝔄 → 𝔅} {_⊛_ : 𝔄 → 𝔄 → 𝔄} where quadricity = Quadricity.method _↦_ _∧_ _∼_ _⊛_ open import Oscar.Class.Properthing open import Oscar.Class.HasEquivalence module Properfact1 {𝔞} {𝔄 : Ø 𝔞} {𝔟} {𝔅 : Ø 𝔟} (∼ : 𝔄 → 𝔄 → 𝔅) {ℓ} ⦃ _ : Properthing ℓ 𝔅 ⦄ (⊛ : 𝔄 → 𝔄 → 𝔄) = Quadricity _≈_ _∧_ ∼ ⊛
{ "alphanum_fraction": 0.504358655, "avg_line_length": 25.09375, "ext": "agda", "hexsha": "1356adc24632fa66bdc30fd91e6f1c13f5fa65be", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Quadricity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Quadricity.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Quadricity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 499, "size": 803 }
module Data.Num.Redundant where -- Base: 2 -- Digit: { 0, 1, 2 } -- -- Numeral System which maxports efficient addition, substraction -- and arithmetic shift. open import Data.List using (List ; []; _∷_) public open import Data.Nat renaming (_+_ to _+ℕ_; _<_ to _<ℕ_) open import Data.Num.Bij open import Data.Empty open import Relation.Nullary open import Relation.Nullary.Negation using (contradiction; contraposition) open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_) import Level open PropEq.≡-Reasoning -------------------------------------------------------------------------------- -- Digits -------------------------------------------------------------------------------- data Digit : Set where zero : Digit one : Digit two : Digit -- plus _⊕_ : Digit → Digit → Digit zero ⊕ y = y x ⊕ zero = x one ⊕ one = two one ⊕ two = one two ⊕ one = one two ⊕ two = two -- minus _⊝_ : Digit → Digit → Digit zero ⊝ y = zero x ⊝ zero = x one ⊝ one = zero one ⊝ two = one two ⊝ one = one two ⊝ two = zero -- carry _⊙_ : Digit → Digit → Digit one ⊙ two = one two ⊙ one = one two ⊙ two = one _ ⊙ _ = zero -- borrow _⊘_ : Digit → Digit → Digit zero ⊘ one = one zero ⊘ two = one one ⊘ two = one _ ⊘ _ = zero -------------------------------------------------------------------------------- -- Sequence of Digits -------------------------------------------------------------------------------- Redundant : Set Redundant = List Digit -- "one-sided" incr : Digit → Redundant → Redundant incr x [] = x ∷ [] incr x (y ∷ ys) = x ⊕ y ∷ incr (x ⊙ y) ys decr : Digit → Redundant → Redundant decr x [] = [] decr x (y ∷ ys) = x ⊝ y ∷ decr (x ⊘ y) ys -- "two-sided" _+_ : Redundant → Redundant → Redundant [] + ys = ys xs + [] = xs (x ∷ xs) + (y ∷ ys) = x ⊕ y ∷ incr (x ⊙ y) (xs + ys) _─_ : Redundant → Redundant → Redundant [] ─ ys = [] xs ─ [] = xs (x ∷ xs) ─ (y ∷ ys) = x ⊝ y ∷ decr (x ⊘ y) (xs ─ ys) -- arithmetic shift >> : Redundant → Redundant >> xs = zero ∷ xs << : Redundant → Redundant << [] = [] << (x ∷ xs) = xs _>>>_ : ℕ → Redundant → Redundant zero >>> xs = xs suc n >>> xs = n >>> (>> xs) _<<<_ : ℕ → Redundant → Redundant zero <<< xs = xs suc n <<< [] = [] suc n <<< (x ∷ xs) = n <<< xs -------------------------------------------------------------------------------- -- instances of Conversion, so that we can convert Redundant to B -------------------------------------------------------------------------------- instance convRedundant : Conversion Redundant convRedundant = conversion [_]' !_!' [!!]-id' where [_]' : Redundant → Bij [ [] ]' = [] [ zero ∷ xs ]' = *2 [ xs ]' [ one ∷ xs ]' = one ∷ [ xs ]' [ two ∷ xs ]' = two ∷ [ xs ]' !_!' : Bij → Redundant ! [] !' = [] ! one ∷ xs !' = one ∷ ! xs !' ! two ∷ xs !' = two ∷ ! xs !' [!!]-id' : ∀ xs → [ ! xs !' ]' ≡ xs [!!]-id' [] = PropEq.refl [!!]-id' (one ∷ xs) = PropEq.cong (λ x → one ∷ x) ([!!]-id' xs) [!!]-id' (two ∷ xs) = PropEq.cong (λ x → two ∷ x) ([!!]-id' xs) -------------------------------------------------------------------------------- -- Equivalence relation -------------------------------------------------------------------------------- infix 4 _≈_ _≉_ data _≈_ (a b : Redundant) : Set where eq : ([a]≡[b] : [ a ] ≡ [ b ]) → a ≈ b -- the inverse of `eq` to≡ : ∀ {a b} → a ≈ b → [ a ] ≡ [ b ] to≡ (eq x) = x _≉_ : (a b : Redundant) → Set a ≉ b = a ≈ b → ⊥ -- decidable {- _≈?_ : Decidable {A = Redundant} _≈_ a ≈? b with [ a ] ≟ [ b ] a ≈? b | yes p = yes (eq p) a ≈? b | no ¬p = no (contraposition to≡ ¬p) -} -------------------------------------------------------------------------------- -- Ordering -------------------------------------------------------------------------------- infix 4 _≲_ _<_ data _≲_ : Rel Redundant Level.zero where le : ∀ {a b} ([a]≤[b] : [ a ] ≤B [ b ]) → a ≲ b -- the inverse of `le` to≤ : ∀ {a b} → a ≲ b → [ a ] ≤B [ b ] to≤ (le [a]≤B[b]) = [a]≤B[b] _<_ : Rel Redundant Level.zero a < b = incr one a ≲ b {- -- decidable _≲?_ : Decidable _≲_ a ≲? b with [ a ] ≤? [ b ] a ≲? b | yes p = yes (le p) a ≲? b | no ¬p = no (contraposition to≤ ¬p) -}
{ "alphanum_fraction": 0.4139908257, "avg_line_length": 24.9142857143, "ext": "agda", "hexsha": "17bcec9daac48b7ea35b54144e9dadaa9899397d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/Data/Num/Redundant.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/Data/Num/Redundant.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/Data/Num/Redundant.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": 1465, "size": 4360 }
module Data.Vec.Membership.Propositional.Distinct where open import Data.Vec as Vec using (Vec; []; _∷_; _++_) open import Data.Vec.Membership.Propositional open import Data.Vec.Any hiding (map; index; head; tail) open import Data.List as List using (List) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_; _≗_ ) open import Relation.Binary.HeterogeneousEquality as H using (_≅_; _≇_) import Data.List.Membership.Propositional.Distinct as ListDistinct open import Data.Product as Prod hiding (map) open import Data.Sum hiding (map) open import Data.Empty using (⊥-elim) open import Relation.Nullary open import Data.Fin as Fin open import Data.Fin.Properties using (suc-injective) open import Data.Nat as ℕ open import Function using (_∘_) open import Function.Equivalence using (_⇔_; equivalence) open import Function.Equality as F using (_⟨$⟩_) open import Function.Injection using (_↣_; Injection) data Distinct {a}{A : Set a} : ∀ {n} → Vec A n → Set a where distinct-[] : Distinct [] _distinct-∷_by_ : ∀ {n} x {xs : Vec A n} → Distinct xs → x ∉ xs → Distinct (x ∷ xs) head : ∀ {a}{A : Set a} {n} {x}{xs : Vec A n} → Distinct (x ∷ xs) → A head (x distinct-∷ _ by _) = x tail : ∀ {a}{A : Set a} {n} {x}{xs : Vec A n} → Distinct (x ∷ xs) → Distinct xs tail (_ distinct-∷ dis by _) = dis head∉tail : ∀ {a}{A : Set a} {n} {x}{xs : Vec A n} → Distinct (x ∷ xs) → x ∉ xs head∉tail (_ distinct-∷ _ by x∉xs) = x∉xs [_] : ∀{a}{A : Set a}(x : A) → Distinct Vec.[ x ] [ x ] = x distinct-∷ distinct-[] by (λ ()) {- _distinct-∷ʳ_by_ : ∀ {a}{A : Set a} {n} {xs : Vec A n} → Distinct xs → (x : A) → x ∉ xs → Distinct (xs Vec.∷ʳ x) distinct-[] distinct-∷ʳ x by x∉xs = x distinct-∷ distinct-[] by x∉xs (y distinct-∷ dxs by y∉xs) distinct-∷ʳ x by x∉yxs = y distinct-∷ dxs distinct-∷ʳ x by (x∉yxs ∘ there) by lemma y∉xs x∉yxs where lemma : ∀ {a}{A : Set a} {n} {xs : Vec A n} {x y} → y ∉ xs → x ∉ y Vec.∷ xs → y ∉ xs Vec.∷ʳ x lemma {xs = []} y∉xs x∉y∷xs (here P.refl) = x∉y∷xs (here P.refl) lemma {xs = []} y∉xs x∉y∷xs (there ()) lemma {xs = _ ∷ xs} y∉xs x∉y∷xs (here P.refl) = y∉xs (here P.refl) lemma {xs = x₁ ∷ xs}{x}{y} y∉xs x∉y∷xs (there y∈xs∷ʳx) = {!!} -} initLast : ∀ {a n} {A : Set a}{xs : Vec A (suc n)} → Distinct xs → let (ys , y , xs≡ysy) = Vec.initLast xs in Distinct ys × y ∉ ys initLast {n = zero} {xs = x ∷ []} (.x distinct-∷ distinct-[] by x∉[]) = distinct-[] , x∉[] initLast {n = suc n} {xs = x ∷ xs} (.x distinct-∷ dxs by x∉xs) with Vec.initLast xs | initLast dxs initLast {_} {suc n} {_} {x ∷ .(ys Vec.∷ʳ y)} (.x distinct-∷ dxs by x∉xs) | ys , y , P.refl | dys , y∉ys = x distinct-∷ dys by (x∉xs ∘ ∈-∷ʳ) , λ { (here P.refl) → x∉xs (∷ʳ-∈ y ys) ; ( there p) → y∉ys p } where ∈-∷ʳ : ∀ {a n} {A : Set a}{xs : Vec A n}{x y} → x ∈ xs → x ∈ xs Vec.∷ʳ y ∈-∷ʳ {xs = []} () ∈-∷ʳ {xs = x ∷ xs} (here eq) = here eq ∈-∷ʳ {xs = x ∷ xs} (there x∈xs) = there (∈-∷ʳ x∈xs) ∷ʳ-∈ : ∀ {a n} {A : Set a} x (xs : Vec A n) → x ∈ xs Vec.∷ʳ x ∷ʳ-∈ x [] = here P.refl ∷ʳ-∈ x (y ∷ xs) = there (∷ʳ-∈ x xs) private initLast₁≡init : ∀ {a n} {A : Set a}(xs : Vec A (suc n)) → proj₁ (Vec.initLast xs) ≡ Vec.init xs initLast₁≡init xs with Vec.initLast xs initLast₁≡init .(ys Vec.∷ʳ y) | ys , y , P.refl = P.refl initLast₂≡last : ∀ {a n} {A : Set a}(xs : Vec A (suc n)) → proj₁ (proj₂ (Vec.initLast xs)) ≡ Vec.last xs initLast₂≡last xs with Vec.initLast xs initLast₂≡last .(ys Vec.∷ʳ y) | ys , y , P.refl = P.refl init : ∀ {a n} {A : Set a}{xs : Vec A (suc n)} → Distinct xs → Distinct (Vec.init xs) init {xs = xs} dxs with initLast dxs ... | dys , y∉ys rewrite initLast₁≡init xs = dys last : ∀ {a n} {A : Set a}{xs : Vec A (suc n)} → Distinct xs → Vec.last xs ∉ Vec.init xs last {xs = xs} dxs with initLast dxs ... | dys , y∉ys rewrite initLast₁≡init xs | initLast₂≡last xs = y∉ys map : ∀ {a b}{A : Set a}{B : Set b} → (f : A ↣ B) → ∀ {n}{xs : Vec A n} → Distinct xs → Distinct (Vec.map (Injection.to f ⟨$⟩_) xs) map f {0}{[]} distinct-[] = distinct-[] map {A = A} f {ℕ.suc _} {x ∷ xs} (.x distinct-∷ dis by x∉xs) = fx distinct-∷ map f dis by fx∉mapfxs where fx = Injection.to f ⟨$⟩ x -- missing ∈-map⁻ : ∀{a b}{A : Set a}{B : Set b}(f : A → B){m}{xs : Vec A m}{y} → y ∈ Vec.map f xs → ∃ λ x → x ∈ xs × y ≡ f x ∈-map⁻ f {xs = []} () ∈-map⁻ f {xs = x ∷ xs} (here P.refl) = x , here P.refl , P.refl ∈-map⁻ f {xs = x ∷ xs} (there y∈mapfxs) with ∈-map⁻ _ y∈mapfxs ... | v , v∈xs , eq = v , there v∈xs , eq fx∉mapfxs : fx ∉ Vec.map (Injection.to f ⟨$⟩_) xs fx∉mapfxs fx∈mapfxs with ∈-map⁻ _ fx∈mapfxs ... | v , v∈xs , fx≡fv with Injection.injective f fx≡fv fx∉mapfxs fx∈mapfxs | v , v∈xs , fx≡fv | P.refl = x∉xs v∈xs private injection : ∀ {a b}{A : Set a}{B : Set b} {f : A → B} → (∀ {x y} → f x ≡ f y → x ≡ y) → A ↣ B Injection.to (injection {f = f} inj) = P.→-to-⟶ f Injection.injective (injection inj) = inj tabulate : ∀ {a}{A : Set a}{n} → (f : Fin n ↣ A) → Distinct (Vec.tabulate (Injection.to f ⟨$⟩_)) tabulate {n = zero} f = distinct-[] tabulate {n = suc n} f = (Injection.to f ⟨$⟩ zero) distinct-∷ tabulate (f ⟨∘⟩ injection suc-injective) by lemma where open import Function.Injection using () renaming (_∘_ to _⟨∘⟩_) open import Data.Vec.Membership.Propositional.Properties ∈-tabulateˡ : ∀ {a}{A : Set a}{n}{x}(f : Fin n → A) → x ∈ Vec.tabulate f → ∃ λ i → x ≡ f i ∈-tabulateˡ {n = zero} f () ∈-tabulateˡ {n = suc n} f (here P.refl) = _ , P.refl ∈-tabulateˡ {n = suc n} f (there x∈tabf) with ∈-tabulateˡ _ x∈tabf ... | i , eq = suc i , eq lemma : (Injection.to f ⟨$⟩ zero) ∉ Vec.tabulate ((Injection.to f ⟨$⟩_) ∘ Fin.suc) lemma p with ∈-tabulateˡ _ p lemma p | i , fi≡f0 with Injection.injective f fi≡f0 lemma p | i , fi≡f0 | () allFin : ∀ n → Distinct (Vec.allFin n) allFin n = tabulate ⟨id⟩ where open import Function.Injection using () renaming (id to ⟨id⟩) private ∈-zipˡ : ∀ {a b n}{A : Set a}{B : Set b}{xs : Vec A n}{ys : Vec B n} {x y} → (x , y) ∈ Vec.zip xs ys → x ∈ xs ∈-zipˡ {xs = []} {[]} () ∈-zipˡ {xs = x ∷ xs} {y ∷ ys} (here P.refl) = here P.refl ∈-zipˡ {xs = x ∷ xs} {y ∷ ys} (there p) = there (∈-zipˡ p) ∈-zipʳ : ∀ {a b n}{A : Set a}{B : Set b}{xs : Vec A n}{ys : Vec B n} {x y} → (x , y) ∈ Vec.zip xs ys → y ∈ ys ∈-zipʳ {xs = []} {[]} () ∈-zipʳ {xs = x ∷ xs} {y ∷ ys} (here P.refl) = here P.refl ∈-zipʳ {xs = x ∷ xs} {y ∷ ys} (there p) = there (∈-zipʳ p) zipˡ : ∀ {a b n}{A : Set a}{B : Set b}{xs : Vec A n} → Distinct xs → (ys : Vec B n) → Distinct (Vec.zip xs ys) zipˡ distinct-[] [] = distinct-[] zipˡ (x distinct-∷ dxs by x∉xs) (y ∷ ys) = (x , y) distinct-∷ zipˡ dxs ys by λ p → x∉xs (∈-zipˡ p) zipʳ : ∀ {a b n}{A : Set a}{B : Set b}(xs : Vec A n){ys : Vec B n} → Distinct ys → Distinct (Vec.zip xs ys) zipʳ [] distinct-[] = distinct-[] zipʳ (x ∷ xs) (y distinct-∷ dys by y∉ys) = (x , y) distinct-∷ zipʳ xs dys by λ p → y∉ys (∈-zipʳ p) toList : ∀ {a n}{A : Set a}{xs : Vec A n} → Distinct xs → ListDistinct.Distinct (Vec.toList xs) toList distinct-[] = ListDistinct.distinct-[] toList (x distinct-∷ dxs by x∉xs) = x ListDistinct.distinct-∷ toList dxs by λ x∈xs → x∉xs (lemma x∈xs) where import Data.List.Membership.Propositional as ListMem import Data.List.Any as ListAny lemma : ∀ {a n}{A : Set a}{x}{xs : Vec A n} → x ListMem.∈ Vec.toList xs → x ∈ xs lemma {xs = []} () lemma {xs = x ∷ xs} (ListAny.here P.refl) = here P.refl lemma {xs = x ∷ xs} (ListAny.there p) = there (lemma p) fromList : ∀ {a}{A : Set a}{xs : List A} → ListDistinct.Distinct xs → Distinct (Vec.fromList xs) fromList ListDistinct.distinct-[] = distinct-[] fromList (x ListDistinct.distinct-∷ dxs by x∉xs) = x distinct-∷ fromList dxs by λ x∈xs → x∉xs (lemma x∈xs) where import Data.List.Membership.Propositional as ListMem import Data.List.Any as ListAny lemma : ∀ {a}{A : Set a}{x}{xs : List A} → x ∈ Vec.fromList xs → x ListMem.∈ xs lemma {xs = List.[]} () lemma {xs = x List.∷ xs} (here P.refl) = ListAny.here P.refl lemma {xs = x List.∷ xs} (there p) = ListAny.there (lemma p)
{ "alphanum_fraction": 0.5546568336, "avg_line_length": 46.1923076923, "ext": "agda", "hexsha": "46f86b7a99297dfb75c19abb6e80ba7c9568374f", "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": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-distinct-disjoint", "max_forks_repo_path": "src/Data/Vec/Membership/Propositional/Distinct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tizmd/agda-distinct-disjoint", "max_issues_repo_path": "src/Data/Vec/Membership/Propositional/Distinct.agda", "max_line_length": 141, "max_stars_count": null, "max_stars_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-distinct-disjoint", "max_stars_repo_path": "src/Data/Vec/Membership/Propositional/Distinct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3489, "size": 8407 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.DiffInt.Base where open import Cubical.Foundations.Prelude open import Cubical.HITs.SetQuotients.Base open import Cubical.Data.Prod open import Cubical.Data.Nat rel : (ℕ ×Σ ℕ) → (ℕ ×Σ ℕ) → Type₀ rel (a₀ , b₀) (a₁ , b₁) = x ≡ y where x = a₀ + b₁ y = a₁ + b₀ ℤ = (ℕ ×Σ ℕ) / rel
{ "alphanum_fraction": 0.6405797101, "avg_line_length": 18.1578947368, "ext": "agda", "hexsha": "f597c5ad72477a987d62a934357c0f148605ba6d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/DiffInt/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/DiffInt/Base.agda", "max_line_length": 42, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/DiffInt/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 136, "size": 345 }
module SystemF.Substitutions where open import Prelude hiding (subst) open import SystemF.Syntax open import Data.Fin.Substitution open import Data.Star hiding (map) open import Data.Vec hiding ([_]) open import SystemF.Substitutions.Types public module TermTypeSubst where module TermTypeApp {T} (l : Lift T Type) where open Lift l hiding (var) open TypeSubst.TypeApp l renaming (_/_ to _tp/_) infixl 8 _/_ -- Apply a type substitution to a term _/_ : ∀ {ν μ n} → Term ν n → Sub T ν μ → Term μ n var x / σ = var x Λ t / σ = Λ (t / σ ↑) λ' a t / σ = λ' (a tp/ σ) (t / σ) t [ a ] / σ = (t / σ) [ a tp/ σ ] s · t / σ = (s / σ) · (t / σ) open TypeSubst using (varLift; termLift; sub) module Lifted {T} (lift : Lift T Type) {n} where application : Application (λ ν → Term ν n) T application = record { _/_ = TermTypeApp._/_ lift {n = n} } open Application application public open Lifted termLift public -- apply a type variable substitution (renaming) to a term _/Var_ : ∀ {ν μ n} → Term ν n → Sub Fin ν μ → Term μ n _/Var_ = TermTypeApp._/_ varLift -- weaken a term with an additional type variable weaken : ∀ {ν n} → Term ν n → Term (suc ν) n weaken t = t /Var VarSubst.wk infix 8 _[/_] -- shorthand for single-variable type substitutions in terms _[/_] : ∀ {ν n} → Term (suc ν) n → Type ν → Term ν n t [/ b ] = t / sub b module CtxSubst where _/_ : ∀ {ν μ n} → Ctx ν n → Sub Type ν μ → Ctx μ n Γ / σ = Γ TypeSubst.⊙ σ weaken : ∀ {ν n} → Ctx ν n → Ctx (suc ν) n weaken Γ = Γ / TypeSubst.wk -- Variable substitution (renaming) lifted to typing contexts _/Var_ : ∀ {ν m k} → Sub Fin k m → Ctx ν m → Ctx ν k σ /Var Γ = map (λ x → lookup x Γ) σ module TermTermSubst where -- Substitutions of terms in terms TermSub : (ℕ → ℕ → Set) → ℕ → ℕ → ℕ → Set TermSub T ν m n = Sub (T ν) m n record TermLift (T : ℕ → ℕ → Set) : Set where infix 10 _↑tm _↑tp field lift : ∀ {ν n} → T ν n → Term ν n _↑tm : ∀ {ν m n} → TermSub T ν m n → TermSub T ν (suc m) (suc n) _↑tp : ∀ {ν m n} → TermSub T ν m n → TermSub T (suc ν) m n module TermTermApp {T} (l : TermLift T) where open TermLift l infixl 8 _/_ -- Apply a term substitution to a term _/_ : ∀ {ν m n} → Term ν m → TermSub T ν m n → Term ν n var x / σ = lift (lookup x σ) Λ t / σ = Λ (t / (σ ↑tp)) λ' a t / σ = λ' a (t / σ ↑tm) t [ a ] / σ = (t / σ) [ a ] s · t / σ = (s / σ) · (t / σ) Fin′ : ℕ → ℕ → Set Fin′ _ m = Fin m varLift : TermLift Fin′ varLift = record { lift = var; _↑tm = VarSubst._↑; _↑tp = id } infixl 8 _/Var_ _/Var_ : ∀ {ν m n} → Term ν m → Sub Fin m n → Term ν n _/Var_ = TermTermApp._/_ varLift private module ExpandSimple {n : ℕ} where simple : Simple (Term n) simple = record { var = var; weaken = λ t → t /Var VarSubst.wk } open Simple simple public open ExpandSimple using (_↑; simple) open TermTypeSubst using () renaming (weaken to weakenTp) termLift : TermLift Term termLift = record { lift = id; _↑tm = _↑ ; _↑tp = λ ρ → map weakenTp ρ } private module ExpandSubst {ν : ℕ} where app : Application (Term ν) (Term ν) app = record { _/_ = TermTermApp._/_ termLift {ν = ν} } subst : Subst (Term ν) subst = record { simple = simple ; application = app } open Subst subst public open ExpandSubst public hiding (var; simple) infix 8 _[/_] -- Shorthand for single-variable term substitutions in terms _[/_] : ∀ {ν n} → Term ν (suc n) → Term ν n → Term ν n s [/ t ] = s / sub t open TermTermSubst public using () renaming (_/_ to _tm/tm_; _[/_] to _tm[/tm_]; weaken to tmtm-weaken) open TermTypeSubst public using () renaming (_/_ to _tm/tp_; _[/_] to _tm[/tp_]; weaken to tm-weaken) open CtxSubst public using () renaming (_/_ to _ctx/_; weaken to ctx-weaken; _/Var_ to _ctx/Var_)
{ "alphanum_fraction": 0.5794833582, "avg_line_length": 28.3521126761, "ext": "agda", "hexsha": "a141406e92c7cb9c2800d4bfb9fdb67f21dcefe8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/SystemF/Substitutions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/SystemF/Substitutions.agda", "max_line_length": 70, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/SystemF/Substitutions.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 1430, "size": 4026 }
{- Theory about isomorphisms - Definitions of [section] and [retract] - Definition of isomorphisms ([Iso]) - Any isomorphism is an equivalence ([isoToEquiv]) -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Isomorphism where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude private variable ℓ : Level -- Section and retract module _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} where section : (f : A → B) → (g : B → A) → Type ℓ' section f g = ∀ b → f (g b) ≡ b -- NB: `g` is the retraction! retract : (f : A → B) → (g : B → A) → Type ℓ retract f g = ∀ a → g (f a) ≡ a record Iso {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where constructor iso field fun : A → B inv : B → A rightInv : section fun inv leftInv : retract fun inv -- Any iso is an equivalence module _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (i : Iso A B) where open Iso i renaming ( fun to f ; inv to g ; rightInv to s ; leftInv to t) private module _ (y : B) (x0 x1 : A) (p0 : f x0 ≡ y) (p1 : f x1 ≡ y) where fill0 : I → I → A fill0 i = hfill (λ k → λ { (i = i1) → t x0 k ; (i = i0) → g y }) (inS (g (p0 (~ i)))) fill1 : I → I → A fill1 i = hfill (λ k → λ { (i = i1) → t x1 k ; (i = i0) → g y }) (inS (g (p1 (~ i)))) fill2 : I → I → A fill2 i = hfill (λ k → λ { (i = i1) → fill1 k i1 ; (i = i0) → fill0 k i1 }) (inS (g y)) p : x0 ≡ x1 p i = fill2 i i1 sq : I → I → A sq i j = hcomp (λ k → λ { (i = i1) → fill1 j (~ k) ; (i = i0) → fill0 j (~ k) ; (j = i1) → t (fill2 i i1) (~ k) ; (j = i0) → g y }) (fill2 i j) sq1 : I → I → B sq1 i j = hcomp (λ k → λ { (i = i1) → s (p1 (~ j)) k ; (i = i0) → s (p0 (~ j)) k ; (j = i1) → s (f (p i)) k ; (j = i0) → s y k }) (f (sq i j)) lemIso : (x0 , p0) ≡ (x1 , p1) lemIso i .fst = p i lemIso i .snd = λ j → sq1 i (~ j) isoToIsEquiv : isEquiv f isoToIsEquiv .equiv-proof y .fst .fst = g y isoToIsEquiv .equiv-proof y .fst .snd = s y isoToIsEquiv .equiv-proof y .snd z = lemIso y (g y) (fst z) (s y) (snd z) isoToPath : ∀ {ℓ} {A B : Type ℓ} → (Iso A B) → A ≡ B isoToPath {A = A} {B = B} f i = Glue B (λ { (i = i0) → (A , (Iso.fun f , isoToIsEquiv f)) ; (i = i1) → (B , (λ x → x) , record { equiv-proof = λ y → (y , refl) , λ z i → z .snd (~ i) , λ j → z .snd (~ i ∨ j)})})
{ "alphanum_fraction": 0.3964536634, "avg_line_length": 31.1354166667, "ext": "agda", "hexsha": "169b83ba873f49f1906787bd81f2a02e8aed4a2d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Foundations/Isomorphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1044, "size": 2989 }
module PiNF-syntax where infixr 30 _⟷_ infixr 20 _◎_ ------------------------------------------------------------------------------ -- First we define a universe of our value types data B : Set where ZERO : B ONE : B PLUS : B → B → B NEG : B → B TIMES : B → B → B RECIP : B → B ------------------------------------------------------------------------------ -- Now we define another universe for our equivalences. First the codes for -- equivalences. data _⟷_ : B → B → Set where unite₊ : { b : B } → PLUS ZERO b ⟷ b uniti₊ : { b : B } → b ⟷ PLUS ZERO b swap₊ : { b₁ b₂ : B } → PLUS b₁ b₂ ⟷ PLUS b₂ b₁ assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃ assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃) unite⋆ : { b : B } → TIMES ONE b ⟷ b uniti⋆ : { b : B } → b ⟷ TIMES ONE b swap⋆ : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷ TIMES b₂ b₁ assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃ assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃) dist : { b₁ b₂ b₃ : B } → TIMES (PLUS b₁ b₂) b₃ ⟷ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) factor : { b₁ b₂ b₃ : B } → PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷ TIMES (PLUS b₁ b₂) b₃ η₊ : { b : B } → ZERO ⟷ PLUS (NEG b) b ε₊ : { b : B } → PLUS b (NEG b) ⟷ ZERO refe⋆ : { b : B } → RECIP (RECIP b) ⟷ b refi⋆ : { b : B } → b ⟷ RECIP (RECIP b) rile⋆ : { b : B } → TIMES b (TIMES b (RECIP b)) ⟷ b rili⋆ : { b : B } → b ⟷ TIMES b (TIMES b (RECIP b)) id⟷ : { b : B } → b ⟷ b sym : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁) _◎_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃) _⊕_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄) _⊗_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄) -- adjoint : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁) adjoint unite₊ = uniti₊ adjoint uniti₊ = unite₊ adjoint swap₊ = swap₊ adjoint assocl₊ = assocr₊ adjoint assocr₊ = assocl₊ adjoint unite⋆ = uniti⋆ adjoint uniti⋆ = unite⋆ adjoint swap⋆ = swap⋆ adjoint assocl⋆ = assocr⋆ adjoint assocr⋆ = assocl⋆ adjoint dist = factor adjoint factor = dist adjoint η₊ = swap₊ ◎ ε₊ adjoint ε₊ = η₊ ◎ swap₊ adjoint refe⋆ = refi⋆ adjoint refi⋆ = refe⋆ adjoint rile⋆ = rili⋆ adjoint rili⋆ = rile⋆ adjoint id⟷ = id⟷ adjoint (sym c) = c adjoint (c₁ ◎ c₂) = adjoint c₂ ◎ adjoint c₁ adjoint (c₁ ⊕ c₂) = adjoint c₁ ⊕ adjoint c₂ adjoint (c₁ ⊗ c₂) = adjoint c₁ ⊗ adjoint c₂ -- dist' : {b₁ b₂ b₃ : B} → TIMES b₁ (PLUS b₂ b₃) ⟷ PLUS (TIMES b₁ b₂) (TIMES b₁ b₃) dist' = swap⋆ ◎ dist ◎ (swap⋆ ⊕ swap⋆) midtofront : {a b c : B} → TIMES a (TIMES b c) ⟷ TIMES b (TIMES a c) midtofront = assocl⋆ ◎ (swap⋆ ⊗ id⟷) ◎ assocr⋆ neg : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (NEG b₁ ⟷ NEG b₂) neg {b₁} {b₂} c = -- -b1 uniti₊ ◎ -- 0 + (-b1) (η₊ {b₂} ⊕ id⟷) ◎ -- (-b2 + b2) + (-b1) ((id⟷ ⊕ sym c) ⊕ id⟷) ◎ -- (-b2 + b1) + (-b1) assocr₊ ◎ -- (-b2) + (b1 + (-b1)) (id⟷ ⊕ ε₊) ◎ -- (-b2) + 0 swap₊ ◎ -- 0 + (-b2) unite₊ -- -b2 -- mul0 : {b : B} → TIMES ZERO b ⟷ ZERO mul0 = -- 0*b uniti₊ ◎ -- 0 + 0*b (η₊ ⊕ id⟷) ◎ -- (-(0*b) + 0*b) + 0*b assocr₊ ◎ -- -(0*b) + (0*b + 0*b) (id⟷ ⊕ factor) ◎ -- -(0*b) + (0+0)*b (id⟷ ⊕ (unite₊ ⊗ id⟷)) ◎ -- -(0*b) + 0*b swap₊ ◎ ε₊ -- 0 {- mul0 : {b : B} → TIMES ZERO b ⟷ ZERO mul0 {b} = ⟷-begin TIMES ZERO b ⟷⟨ uniti₊ ⟩ 0 + 0*b ⟷⟨ η₊ ⊕ id⟷ ⟩ (-(0*b) + 0*b) + 0*b ⟷⟨ assocr₊ ⟩ -(0*b) + (0*b + 0*b) ⟷⟨ id⟷ ⊕ factor ⟩ -(0*b) + (0+0)*b (id⟷ ⊕ (unite₊ ⊗ id⟷)) ◎ -- -(0*b) + 0*b swap₊ ◎ ε₊ -- 0 ∎ -} -- conType T cond = Σ[ x ∶ T ] cond x inv0 : TIMES ZERO (RECIP ZERO) ⟷ ZERO inv0 = mul0 -- recip : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (RECIP b₁ ⟷ RECIP b₂) recip {b₁} {b₂} c = -- 1/a rili⋆ {RECIP b₁} ◎ -- 1/a * (1/a * 1/1/a) (id⟷ ⊗ (id⟷ ⊗ refe⋆)) ◎ -- 1/a * (1/a * a) assocl⋆ ◎ -- (1/a * 1/a) * a (id⟷ ⊗ reciplem c) ◎ -- (1/a * 1/a) * (a * ((a * 1/b) * (b * 1/b))) assocl⋆ ◎ -- (((1/a * 1/a) * a) * ((a * 1/b) * (b * 1/b))) ((id⟷ ⊗ refi⋆ ) ⊗ id⟷) ◎ -- (((1/a *1/a) * 1/(1/a)) * ((a * 1/b) * (b * 1/b)) ((assocr⋆ ◎ rile⋆ ) ⊗ (id⟷ ⊗ ((sym c) ⊗ id⟷))) ◎ -- 1/a * ((a * 1/b) * (a * 1/b)) (id⟷ ⊗ (assocr⋆ ◎ (id⟷ ⊗ midtofront))) ◎ -- 1/a * (a * (a * (1/b * 1/b))) (assocl⋆ ◎ assocl⋆) ◎ -- ((1/a * a) * a) * (1/b * 1/b) (((swap⋆ ⊗ id⟷) ◎ swap⋆) ⊗ id⟷) ◎ -- ((a * (a * 1/a)) * (1/b * 1/b)) (rile⋆ ⊗ id⟷ ) ◎ -- a * (1/b * 1/b) ((c ◎ refi⋆ ) ⊗ id⟷) ◎ swap⋆ ◎ -- (1/b * 1/b) * 1/(1/b) assocr⋆ ◎ rile⋆ -- 1/b where reciplem : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (b₁ ⟷ (TIMES b₁ (TIMES (TIMES b₁ (RECIP b₂)) (TIMES b₂ (RECIP b₂))))) reciplem {b₁} {b₂} c = c ◎ -- b rili⋆ ◎ -- b * (b * 1/b) (rili⋆ ⊗ id⟷) ◎ -- (b * (b * 1/b)) * (b * 1/b) (((sym c) ⊗ ((sym c) ⊗ id⟷)) ⊗ id⟷) ◎ -- ((a * (a * 1/b)) * (b * 1/b)) assocr⋆ -- a * ((a * 1/b) * (b * 1/b)) ------------------------------------------------------------------------------ -- Examples BOOL : B BOOL = PLUS ONE ONE notπ : BOOL ⟷ BOOL notπ = swap₊ BOOL² : B BOOL² = TIMES BOOL BOOL BOOL³ : B BOOL³ = TIMES BOOL BOOL² ifc : { b : B } → (b ⟷ b) → (TIMES BOOL b ⟷ TIMES BOOL b) ifc c = dist ◎ ((id⟷ ⊗ c) ⊕ id⟷) ◎ factor cnot : BOOL² ⟷ BOOL² cnot = ifc notπ toffoli : BOOL³ ⟷ BOOL³ toffoli = ifc cnot ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.3929589271, "avg_line_length": 32.955801105, "ext": "agda", "hexsha": "e59f753778a299f74bd0fe1c63b7dbeed0660de0", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "agda/PiNF-syntax.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "agda/PiNF-syntax.agda", "max_line_length": 110, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "agda/PiNF-syntax.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": 2885, "size": 5965 }
module Human.Maybe where data Maybe (A : Set) : Set where just : A -> Maybe A nothing : Maybe A
{ "alphanum_fraction": 0.6346153846, "avg_line_length": 17.3333333333, "ext": "agda", "hexsha": "3a4273d9a53539c95cf384b10e868b2c4e461747", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MaisaMilena/JuiceMaker", "max_forks_repo_path": "src/Human/Maybe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MaisaMilena/JuiceMaker", "max_issues_repo_path": "src/Human/Maybe.agda", "max_line_length": 32, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MaisaMilena/JuiceMaker", "max_stars_repo_path": "src/Human/Maybe.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z", "num_tokens": 31, "size": 104 }
module Issue2575 where import Issue2575.M
{ "alphanum_fraction": 0.8372093023, "avg_line_length": 10.75, "ext": "agda", "hexsha": "d4285031e9470bb19ef49482bc170a9c7e11d10d", "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/Issue2575.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/Issue2575.agda", "max_line_length": 22, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2575.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 12, "size": 43 }
module Issue373 where data ⊤ : Set where tt : ⊤ {-# COMPILED_DATA ⊤ () () #-} data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} {-# IMPORT Imports.Nat #-} data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A {-# BUILTIN LIST List #-} {-# BUILTIN NIL [] #-} {-# BUILTIN CONS _∷_ #-} {-# COMPILED_DATA List [] [] (:) #-} postulate String : Set {-# BUILTIN STRING String #-} postulate IO : Set → Set {-# BUILTIN IO IO #-} {-# COMPILED_TYPE IO IO #-} infixl 1 _>>=_ postulate _>>=_ : ∀ {A B} → IO A → (A → IO B) → IO B {-# COMPILED _>>=_ (\_ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-} {-# IMPORT Data.Text.IO #-} postulate putStrLn : String → IO ⊤ {-# COMPILED putStrLn Data.Text.IO.putStrLn #-} f : ℕ → String f zero = "bad" f _ = "ok" -- Works: -- main = putStrLn (f (suc zero)) -- Compiles, but when the program is run we (used to) get the output -- "bad": main = putStrLn (f 1)
{ "alphanum_fraction": 0.5302564103, "avg_line_length": 15.9836065574, "ext": "agda", "hexsha": "2e50115f9c2fcefdbda5cf4334a33f06333d4557", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/interaction/Issue373.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/Issue373.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/interaction/Issue373.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 329, "size": 975 }
module BuiltinMustBeConstructor where data Nat : Set where zero : Nat one : Nat suc : Nat -> Nat suc x = x {-# BUILTIN NATURAL Nat #-} {-# BUILTIN SUC suc #-}
{ "alphanum_fraction": 0.6369047619, "avg_line_length": 12.9230769231, "ext": "agda", "hexsha": "6992df53f3837b1de51871d7c102524020037b50", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/fail/BuiltinMustBeConstructor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/fail/BuiltinMustBeConstructor.agda", "max_line_length": 37, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/BuiltinMustBeConstructor.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 53, "size": 168 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Construction.Zero where -- The Zero functor maps everything to the initial object of a -- category (when it exists). Note quite const. open import Level open import Categories.Category open import Categories.Functor using (Functor) open import Categories.Object.Initial private variable o ℓ e : Level C D : Category o ℓ e Zero : Initial D → Functor C D Zero {D = D} init = record { F₀ = λ _ → ⊥ ; F₁ = λ _ → id ; identity = Equiv.refl ; homomorphism = Equiv.sym identity² ; F-resp-≈ = λ _ → Equiv.refl } where open Initial init open Category D
{ "alphanum_fraction": 0.6880877743, "avg_line_length": 22, "ext": "agda", "hexsha": "50970f679e04c68d876953008a825628505e796f", "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/Functor/Construction/Zero.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/Functor/Construction/Zero.agda", "max_line_length": 62, "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/Functor/Construction/Zero.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": 184, "size": 638 }
{- Theory about equivalences (definitions are in Core/Glue.agda) - isEquiv is a proposition ([isPropIsEquiv]) - Any isomorphism is an equivalence ([isoToEquiv]) There are more statements about equivalences in Equiv/Properties.agda: - if f is an equivalence then (cong f) is an equivalence - if f is an equivalence then precomposition with f is an equivalence - if f is an equivalence then postcomposition with f is an equivalence -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Equiv where open import Cubical.Core.Glue open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Nat private variable ℓ ℓ' : Level A B C : Type ℓ fiber : ∀ {A : Type ℓ} {B : Type ℓ'} (f : A → B) (y : B) → Type (ℓ-max ℓ ℓ') fiber {A = A} f y = Σ[ x ∈ A ] f x ≡ y equivIsEquiv : ∀ {A : Type ℓ} {B : Type ℓ'} (e : A ≃ B) → isEquiv (equivFun e) equivIsEquiv e = snd e equivCtr : ∀ {A : Type ℓ} {B : Type ℓ'} (e : A ≃ B) (y : B) → fiber (equivFun e) y equivCtr e y = e .snd .equiv-proof y .fst equivCtrPath : ∀ {A : Type ℓ} {B : Type ℓ'} (e : A ≃ B) (y : B) → (v : fiber (equivFun e) y) → Path _ (equivCtr e y) v equivCtrPath e y = e .snd .equiv-proof y .snd -- The identity equivalence idIsEquiv : ∀ (A : Type ℓ) → isEquiv (idfun A) equiv-proof (idIsEquiv A) y = ((y , refl) , λ z i → z .snd (~ i) , λ j → z .snd (~ i ∨ j)) idEquiv : ∀ (A : Type ℓ) → A ≃ A idEquiv A = (idfun A , idIsEquiv A) -- Proof using isPropIsContr. This is slow and the direct proof below is better isPropIsEquiv' : (f : A → B) → isProp (isEquiv f) equiv-proof (isPropIsEquiv' f u0 u1 i) y = isPropIsContr (u0 .equiv-proof y) (u1 .equiv-proof y) i -- Direct proof that computes quite ok (can be optimized further if -- necessary, see: -- https://github.com/mortberg/cubicaltt/blob/pi4s3_dimclosures/examples/brunerie2.ctt#L562 isPropIsEquiv : (f : A → B) → isProp (isEquiv f) equiv-proof (isPropIsEquiv f p q i) y = let p2 = p .equiv-proof y .snd q2 = q .equiv-proof y .snd in p2 (q .equiv-proof y .fst) i , λ w j → hcomp (λ k → λ { (i = i0) → p2 w j ; (i = i1) → q2 w (j ∨ ~ k) ; (j = i0) → p2 (q2 w (~ k)) i ; (j = i1) → w }) (p2 w (i ∨ j)) equivEq : (e f : A ≃ B) → (h : e .fst ≡ f .fst) → e ≡ f equivEq e f h = λ i → (h i) , isProp→PathP isPropIsEquiv h (e .snd) (f .snd) i isoToEquiv : Iso A B → A ≃ B isoToEquiv i = _ , isoToIsEquiv i module _ (w : A ≃ B) where invEq : B → A invEq y = fst (fst (snd w .equiv-proof y)) secEq : section invEq (w .fst) secEq x = λ i → fst (snd (snd w .equiv-proof (fst w x)) (x , (λ j → fst w x)) i) retEq : retract invEq (w .fst) retEq y = λ i → snd (fst (snd w .equiv-proof y)) i equivToIso : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → A ≃ B → Iso A B equivToIso {A = A} {B = B} e = iso (e .fst) (invEq e ) (retEq e) (secEq e) invEquiv : A ≃ B → B ≃ A invEquiv f = isoToEquiv (iso (invEq f) (fst f) (secEq f) (retEq f)) invEquivIdEquiv : (A : Type ℓ) → invEquiv (idEquiv A) ≡ idEquiv A invEquivIdEquiv _ = equivEq _ _ refl compEquiv : A ≃ B → B ≃ C → A ≃ C compEquiv f g = isoToEquiv (iso (λ x → g .fst (f .fst x)) (λ x → invEq f (invEq g x)) (λ y → (cong (g .fst) (retEq f (invEq g y))) ∙ (retEq g y)) (λ y → (cong (invEq f) (secEq g (f .fst y))) ∙ (secEq f y))) compEquivIdEquiv : {A B : Type ℓ} (e : A ≃ B) → compEquiv (idEquiv A) e ≡ e compEquivIdEquiv e = equivEq _ _ refl compIso : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} → Iso A B → Iso B C → Iso A C compIso i j = equivToIso (compEquiv (isoToEquiv i) (isoToEquiv j)) LiftEquiv : {A : Type ℓ} → A ≃ Lift {i = ℓ} {j = ℓ'} A LiftEquiv = isoToEquiv (iso lift lower (λ _ → refl) (λ _ → refl)) -- module _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} where -- invEquivInvol : (f : A ≃ B) → invEquiv (invEquiv f) ≡ f -- invEquivInvol f i .fst = fst f -- invEquivInvol f i .snd = propIsEquiv (fst f) (snd (invEquiv (invEquiv f))) (snd f) i PropEquiv→Equiv : (Aprop : isProp A) (Bprop : isProp B) (f : A → B) (g : B → A) → (A ≃ B) PropEquiv→Equiv Aprop Bprop f g = isoToEquiv (iso f g (λ b → Bprop (f (g b)) b) λ a → Aprop (g (f a)) a) homotopyNatural : {f g : A → B} (H : ∀ a → f a ≡ g a) {x y : A} (p : x ≡ y) → H x ∙ cong g p ≡ cong f p ∙ H y homotopyNatural H p = homotopyNatural' H p ∙ □≡∙ _ _ where homotopyNatural' : {f g : A → B} (H : ∀ a → f a ≡ g a) {x y : A} (p : x ≡ y) → H x ∙ cong g p ≡ cong f p □ H y homotopyNatural' {f = f} {g = g} H {x} {y} p i j = hcomp (λ k → λ { (i = i0) → compPath-filler (H x) (cong g p) k j ; (i = i1) → compPath'-filler (cong f p) (H y) k j ; (j = i0) → cong f p (i ∧ (~ k)) ; (j = i1) → cong g p (i ∨ k) }) (H (p i) j) Hfa≡fHa : ∀ {A : Type ℓ} (f : A → A) → (H : ∀ a → f a ≡ a) → ∀ a → H (f a) ≡ cong f (H a) Hfa≡fHa {A = A} f H a = H (f a) ≡⟨ rUnit (H (f a)) ⟩ H (f a) ∙ refl ≡⟨ cong (_∙_ (H (f a))) (sym (rCancel (H a))) ⟩ H (f a) ∙ H a ∙ sym (H a) ≡⟨ assoc _ _ _ ⟩ (H (f a) ∙ H a) ∙ sym (H a) ≡⟨ cong (λ x → x ∙ (sym (H a))) (homotopyNatural H (H a)) ⟩ (cong f (H a) ∙ H a) ∙ sym (H a) ≡⟨ sym (assoc _ _ _) ⟩ cong f (H a) ∙ H a ∙ sym (H a) ≡⟨ cong (_∙_ (cong f (H a))) (rCancel _) ⟩ cong f (H a) ∙ refl ≡⟨ sym (rUnit _) ⟩ cong f (H a) ∎ equivPi : ∀{F : A → Set ℓ} {G : A → Set ℓ'} → ((x : A) → F x ≃ G x) → (((x : A) → F x) ≃ ((x : A) → G x)) equivPi k .fst f x = k x .fst (f x) equivPi k .snd .equiv-proof f .fst .fst x = equivCtr (k x) (f x) .fst equivPi k .snd .equiv-proof f .fst .snd i x = equivCtr (k x) (f x) .snd i equivPi k .snd .equiv-proof f .snd (g , p) i .fst x = equivCtrPath (k x) (f x) (g x , λ j → p j x) i .fst equivPi k .snd .equiv-proof f .snd (g , p) i .snd j x = equivCtrPath (k x) (f x) (g x , λ k → p k x) i .snd j
{ "alphanum_fraction": 0.5351246358, "avg_line_length": 38.6125, "ext": "agda", "hexsha": "f4df9a5e9597eb9341b95cdc7df3254758473158", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Foundations/Equiv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Foundations/Equiv.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Foundations/Equiv.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2565, "size": 6178 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Definitions used in the reflection machinery ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Reflection.Definition where open import Data.List.Base using (map) import Data.List.Properties as Listₚ import Data.Nat.Properties as ℕₚ import Data.Nat.Show as NatShow open import Data.Product using (_×_; <_,_>; uncurry) open import Data.String as String using (String; _<+>_; intersperse; braces) open import Function using (_∘′_) open import Relation.Nullary import Relation.Nullary.Decidable as Dec open import Relation.Nullary.Product using (_×-dec_) open import Relation.Binary using (DecidableEquality) open import Relation.Binary.PropositionalEquality import Reflection.Argument as Arg import Reflection.Name as Name import Reflection.Term as Term ------------------------------------------------------------------------ -- Re-exporting type publically open import Agda.Builtin.Reflection public using ( Definition ; function ; data-type ; axiom ) renaming ( record-type to record′ ; data-cons to constructor′ ; prim-fun to primitive′ ) ------------------------------------------------------------------------ -- Decidable equality function-injective : ∀ {cs cs′} → function cs ≡ function cs′ → cs ≡ cs′ function-injective refl = refl data-type-injective₁ : ∀ {pars pars′ cs cs′} → data-type pars cs ≡ data-type pars′ cs′ → pars ≡ pars′ data-type-injective₁ refl = refl data-type-injective₂ : ∀ {pars pars′ cs cs′} → data-type pars cs ≡ data-type pars′ cs′ → cs ≡ cs′ data-type-injective₂ refl = refl data-type-injective : ∀ {pars pars′ cs cs′} → data-type pars cs ≡ data-type pars′ cs′ → pars ≡ pars′ × cs ≡ cs′ data-type-injective = < data-type-injective₁ , data-type-injective₂ > record′-injective₁ : ∀ {c c′ fs fs′} → record′ c fs ≡ record′ c′ fs′ → c ≡ c′ record′-injective₁ refl = refl record′-injective₂ : ∀ {c c′ fs fs′} → record′ c fs ≡ record′ c′ fs′ → fs ≡ fs′ record′-injective₂ refl = refl record′-injective : ∀ {c c′ fs fs′} → record′ c fs ≡ record′ c′ fs′ → c ≡ c′ × fs ≡ fs′ record′-injective = < record′-injective₁ , record′-injective₂ > constructor′-injective : ∀ {c c′} → constructor′ c ≡ constructor′ c′ → c ≡ c′ constructor′-injective refl = refl _≟_ : DecidableEquality Definition function cs ≟ function cs′ = Dec.map′ (cong function) function-injective (cs Term.≟-Clauses cs′) data-type pars cs ≟ data-type pars′ cs′ = Dec.map′ (uncurry (cong₂ data-type)) data-type-injective (pars ℕₚ.≟ pars′ ×-dec Listₚ.≡-dec Name._≟_ cs cs′) record′ c fs ≟ record′ c′ fs′ = Dec.map′ (uncurry (cong₂ record′)) record′-injective (c Name.≟ c′ ×-dec Listₚ.≡-dec (Arg.≡-dec Name._≟_) fs fs′) constructor′ d ≟ constructor′ d′ = Dec.map′ (cong constructor′) constructor′-injective (d Name.≟ d′) axiom ≟ axiom = yes refl primitive′ ≟ primitive′ = yes refl -- antidiagonal function cs ≟ data-type pars cs₁ = no (λ ()) function cs ≟ record′ c fs = no (λ ()) function cs ≟ constructor′ d = no (λ ()) function cs ≟ axiom = no (λ ()) function cs ≟ primitive′ = no (λ ()) data-type pars cs ≟ function cs₁ = no (λ ()) data-type pars cs ≟ record′ c fs = no (λ ()) data-type pars cs ≟ constructor′ d = no (λ ()) data-type pars cs ≟ axiom = no (λ ()) data-type pars cs ≟ primitive′ = no (λ ()) record′ c fs ≟ function cs = no (λ ()) record′ c fs ≟ data-type pars cs = no (λ ()) record′ c fs ≟ constructor′ d = no (λ ()) record′ c fs ≟ axiom = no (λ ()) record′ c fs ≟ primitive′ = no (λ ()) constructor′ d ≟ function cs = no (λ ()) constructor′ d ≟ data-type pars cs = no (λ ()) constructor′ d ≟ record′ c fs = no (λ ()) constructor′ d ≟ axiom = no (λ ()) constructor′ d ≟ primitive′ = no (λ ()) axiom ≟ function cs = no (λ ()) axiom ≟ data-type pars cs = no (λ ()) axiom ≟ record′ c fs = no (λ ()) axiom ≟ constructor′ d = no (λ ()) axiom ≟ primitive′ = no (λ ()) primitive′ ≟ function cs = no (λ ()) primitive′ ≟ data-type pars cs = no (λ ()) primitive′ ≟ record′ c fs = no (λ ()) primitive′ ≟ constructor′ d = no (λ ()) primitive′ ≟ axiom = no (λ ())
{ "alphanum_fraction": 0.5943134535, "avg_line_length": 38.2831858407, "ext": "agda", "hexsha": "591105af40ae94e331e3e8a703eb0ec97c3f6187", "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/Definition.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/Definition.agda", "max_line_length": 111, "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/Definition.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": 1246, "size": 4326 }
{-# OPTIONS --without-K --safe #-} -- Quicksort module Experiment.Induction where -- agda-stdlib open import Level open import Data.List open import Data.Product open import Data.Nat as ℕ open import Data.Nat.Induction as Ind open import Relation.Binary as B open import Relation.Unary as U import Relation.Unary.Properties as Uₚ open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Function.Base open import Induction.WellFounded private variable a p r : Level
{ "alphanum_fraction": 0.773359841, "avg_line_length": 21.8695652174, "ext": "agda", "hexsha": "eaf4efbda5ce84ad0b4f06e912fa709185128386", "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": "Experiment/Induction.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": "Experiment/Induction.agda", "max_line_length": 66, "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": "Experiment/Induction.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": 125, "size": 503 }
module Syntacticosmos (Gnd : Set)(U : Set)(El : U -> Set) where open import Basics open import Pr open import Nom import Kind open Kind Gnd U El public import Cxt open Cxt Kind public import Loc open Loc Kind public import Term open Term Gnd U El public import Shift open Shift Gnd U El public import Eta open Eta Gnd U El public import Inst open Inst Gnd U El public import Subst open Subst Gnd U El public
{ "alphanum_fraction": 0.7707317073, "avg_line_length": 17.8260869565, "ext": "agda", "hexsha": "06eb29eddfe7b84a17a8a610df83b4aa81f2f066", "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": "benchmark/Syntacticosmos/Syntacticosmos.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": "benchmark/Syntacticosmos/Syntacticosmos.agda", "max_line_length": 63, "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": "benchmark/Syntacticosmos/Syntacticosmos.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": 124, "size": 410 }
{-# OPTIONS --safe #-} module Cubical.Algebra.MonoidSolver.Examples where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Monoid.Base open import Cubical.Algebra.CommMonoid.Base open import Cubical.Algebra.MonoidSolver.Reflection private variable ℓ : Level module ExamplesMonoid (M : Monoid ℓ) where open MonoidStr (snd M) _ : ε ≡ ε _ = solveMonoid M _ : ε · ε · ε ≡ ε _ = solveMonoid M _ : ∀ x → ε · x ≡ x _ = solveMonoid M _ : ∀ x y z → (x · y) · z ≡ x · (y · z) _ = solveMonoid M _ : ∀ x y z → z · (x · y) · ε · z ≡ z · x · (y · z) _ = solveMonoid M module ExamplesCommMonoid (M : CommMonoid ℓ) where open CommMonoidStr (snd M) _ : ε ≡ ε _ = solveCommMonoid M _ : ε · ε · ε ≡ ε _ = solveCommMonoid M _ : ∀ x → ε · x ≡ x _ = solveCommMonoid M _ : ∀ x y z → (x · z) · y ≡ x · (y · z) _ = solveCommMonoid M _ : ∀ x y → (x · y) · y · x · (x · y) ≡ x · x · x · (y · y · y) _ = solveCommMonoid M
{ "alphanum_fraction": 0.5763747454, "avg_line_length": 19.64, "ext": "agda", "hexsha": "22f266cf5df1086cda99d274685ff6a54b130af9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/MonoidSolver/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/MonoidSolver/Examples.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/MonoidSolver/Examples.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 388, "size": 982 }
-- Andreas, 2019-02-17, issue #3417 -- -- We want to see highlighting for all the warnings, -- even if the last thing is a hard error. open import Agda.Builtin.Nat reachable : Nat → Nat reachable zer = 0 reachable (suc n) = suc (reachable n) coverage : Nat → Nat coverage zero = zero Termination : Set Termination = Termination data Positivity : Set where abs : (Positivity → Nat) → Positivity Universe : Set Universe = Set -- Problem was: Termination and Positivity got no highlighting.
{ "alphanum_fraction": 0.722334004, "avg_line_length": 19.88, "ext": "agda", "hexsha": "97d1fb84f84010a8e5c116bce4784550f8ee1ae9", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/interaction/Issue3417.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/Issue3417.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/interaction/Issue3417.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": 137, "size": 497 }
{-# OPTIONS --without-K #-} open import Prelude open import GSeTT.Syntax open import GSeTT.Rules open import GSeTT.Uniqueness-Derivations module MCaTT.Desuspension where ↓GC : ∀ (Γ : Pre-Ctx) → Γ ⊢C → Pre-Ctx ↓GT : ∀ (Γ : Pre-Ctx) (A : Pre-Ty) → Γ ⊢T A → Pre-Ty ↓Gt : ∀ (Γ : Pre-Ctx) (A : Pre-Ty) (x : ℕ) → Γ ⊢t (Var x) # A → ℕ count-points : ∀ (Γ : Pre-Ctx) → ℕ ↓GC nil _ = nil ↓GC (Γ :: (x , ∗)) (cc Γ⊢ _ _) = ↓GC Γ Γ⊢ ↓GC Γ+@(Γ :: (x , A@(_ ⇒[ _ ] _))) Γ+⊢@(cc Γ⊢ Γ⊢A _) = ↓GC Γ Γ⊢ :: (↓Gt Γ+ A x (var Γ+⊢ (inr (idp , idp))) , ↓GT Γ A Γ⊢A) ↓GT Γ ∗ Γ⊢∗ = ∗ ↓GT Γ (_ ⇒[ ∗ ] _) _ = ∗ ↓GT Γ (Var x ⇒[ A@(_ ⇒[ _ ] _) ] Var y) (ar Γ⊢A Γ⊢x Γ⊢y) = Var (↓Gt Γ A x Γ⊢x) ⇒[ ↓GT Γ A Γ⊢A ] Var (↓Gt Γ A y Γ⊢y) count-points nil = 0 count-points (Γ :: (x , ∗)) = S (count-points Γ) count-points (Γ :: (x , _ ⇒[ _ ] _)) = count-points Γ -- goes to Prelude _-_ : ℕ → ℕ → ℕ n - O = n O - S m = O S n - S m = n - m Sn-m : ∀ (n m : ℕ) → m ≤ n → (S n - m) == S (n - m) Sn-m n O _ = idp Sn-m O (S m) Sm≤0 = ⊥-elim (Sn≰0 _ Sm≤0) Sn-m (S n) (S m) (S≤ m≤n) = Sn-m n m m≤n -- end of Prelude partA x₁ x₂ ↓Gt (Γ :: (y , B)) A x (var _ (inr (_ , _))) = x - (count-points Γ) ↓Gt (Γ :: (y , B)) A x (var (cc Γ⊢ _ _) (inl x∈Γ)) = ↓Gt Γ A x (var Γ⊢ x∈Γ) count-points≤length : ∀ (Γ : Pre-Ctx) → count-points Γ ≤ length Γ count-points≤length nil = 0≤ 0 count-points≤length (Γ :: (_ , ∗)) = S≤ (count-points≤length Γ) count-points≤length (Γ :: (_ , _ ⇒[ _ ] _)) = n≤m→n≤Sm (count-points≤length Γ) ↓length : ∀ (Γ : Pre-Ctx) (Γ⊢ : Γ ⊢C) → (length Γ - count-points Γ) == length (↓GC Γ Γ⊢) ↓length nil _ = idp ↓length (Γ :: (_ , ∗)) (cc Γ⊢ _ _) = ↓length Γ Γ⊢ ↓length (Γ :: (x , _ ⇒[ _ ] _)) (cc Γ⊢ _ _) = Sn-m (length Γ) (count-points Γ) (count-points≤length Γ) >> ap S (↓length Γ Γ⊢) wk↓GT : ∀ (Γ : Pre-Ctx) (B : Pre-Ty) (y : ℕ) (A : Pre-Ty) (Γ⊢A : Γ ⊢T A) (Γ+⊢A : (Γ :: (y , B)) ⊢T A) → ↓GT Γ A Γ⊢A == ↓GT (Γ :: (y , B)) A Γ+⊢A wk↓Gt : ∀ (Γ : Pre-Ctx) (B : Pre-Ty) (y : ℕ) (x : ℕ) (A : Pre-Ty) (Γ⊢x : Γ ⊢t (Var x) # A) (Γ+⊢x : (Γ :: (y , B)) ⊢t (Var x) # A) → ↓Gt Γ A x Γ⊢x == ↓Gt (Γ :: (y , B)) A x Γ+⊢x wk↓GT Γ B y ∗ Γ⊢A Γ+⊢A = idp wk↓GT Γ B y (_ ⇒[ ∗ ] _) _ _ = idp wk↓GT Γ B y (Var x ⇒[ A@(_ ⇒[ _ ] _)] Var x') (ar Γ⊢A Γ⊢x Γ⊢x') (ar Γ+⊢A Γ+⊢x Γ+⊢x') = ⇒= (wk↓GT Γ B y A Γ⊢A Γ+⊢A) (Var= (wk↓Gt Γ B y x A Γ⊢x Γ+⊢x)) (Var= (wk↓Gt Γ B y x' A Γ⊢x' Γ+⊢x')) wk↓Gt (Γ :: (z , C)) B y x A (var (cc Γ⊢ _ _) (inl x∈Γ)) (var (cc Γ+⊢ _ _) (inl (inl x∈Γ+))) = wk↓Gt Γ C z x A (var Γ⊢ x∈Γ) (var Γ+⊢ (inl (x∈Γ+))) wk↓Gt (Γ :: (.(length Γ) , C)) B .(length (Γ :: (length Γ , C))) .(length Γ) .C (var (cc Γ⊢ _ idp) (inl x∈Γ)) (var (cc _ _ idp) (inl (inr (idp , idp)))) = ⊥-elim (lΓ∉Γ Γ⊢ x∈Γ) wk↓Gt (Γ :: (z , C)) B .(length (Γ :: (z , C))) .(length (Γ :: (z , C))) .B (var (cc Γ⊢ _ _) (inl x∈Γ)) (var (cc _ _ idp) (inr (idp , idp))) = ⊥-elim (n∉Γ Γ⊢ (n≤Sn _) x∈Γ) wk↓Gt (Γ :: (.(length Γ) , C)) B .(length (Γ :: (length Γ , C))) .(length Γ) .C (var (cc Γ⊢ _ idp) (inr (idp , idp))) (var (cc _ _ idp) (inl (inl lΓ∈Γ))) = ⊥-elim (lΓ∉Γ Γ⊢ lΓ∈Γ) wk↓Gt (Γ :: (.(length Γ) , C)) B .(length (Γ :: (length Γ , C))) .(length Γ) .C (var (cc Γ⊢ _ idp) (inr (idp , idp))) (var (cc _ _ idp) (inl (inr _))) = idp wk↓Gt (Γ :: (.(length Γ) , C)) B .(length (Γ :: (length Γ , C))) .(length Γ) .C (var (cc Γ⊢ _ idp) (inr (idp , idp))) (var (cc Γ+⊢ _ idp) (inr (contra , _))) = ⊥-elim (n≠Sn _ contra) ↓⊢C : ∀ (Γ : Pre-Ctx) (Γ⊢ : Γ ⊢C) → (↓GC Γ Γ⊢) ⊢C ↓⊢T : ∀ (Γ : Pre-Ctx) (A : Pre-Ty) (A≠∗ : A ≠ ∗) (Γ⊢ : Γ ⊢C) (Γ⊢A : Γ ⊢T A) → (↓GC Γ Γ⊢) ⊢T (↓GT Γ A Γ⊢A) ↓⊢t : ∀ (Γ : Pre-Ctx) (A : Pre-Ty) (x : ℕ) (A≠∗ : A ≠ ∗) (Γ⊢ : Γ ⊢C) (Γ⊢A : Γ ⊢T A) (Γ⊢x : Γ ⊢t (Var x) # A) → (↓GC Γ Γ⊢) ⊢t Var (↓Gt Γ A x Γ⊢x) # (↓GT Γ A Γ⊢A) ↓wkt : ∀ (Γ : Pre-Ctx) (C : Pre-Ty) (y : ℕ) {A B : Pre-Ty} {t u : Pre-Tm} (Γ⊢ : Γ ⊢C) (Γ+⊢ : (Γ :: (y , C)) ⊢C) (↓Γ⊢t : ↓GC Γ Γ⊢ ⊢t t # A) → A == B → t == u → ↓GC (Γ :: (y , C)) Γ+⊢ ⊢t u # B ↓wkt Γ ∗ y {A = A} {t = t} Γ⊢ (cc Γ⊢' _ _) ↓Γ⊢t idp idp = transport {B = λ p → ↓GC Γ p ⊢t t # A} (has-all-paths-⊢C Γ⊢ Γ⊢') ↓Γ⊢t ↓wkt Γ (_ ⇒[ C ] _) y {A = A} {t = t} Γ⊢ Γ+⊢@(cc Γ⊢' _ _) ↓Γ⊢t idp idp = wkt (transport {B = λ p → ↓GC Γ p ⊢t t # A} (has-all-paths-⊢C Γ⊢ Γ⊢') ↓Γ⊢t) (↓⊢C _ Γ+⊢) ↓⊢C nil ec = ec ↓⊢C (Γ :: (x , ∗)) (cc Γ⊢ _ _) = ↓⊢C Γ Γ⊢ ↓⊢C (Γ :: (x , A@(_ ⇒[ _ ] _))) (cc Γ⊢ Γ⊢A idp) = cc (↓⊢C Γ Γ⊢) (↓⊢T Γ A (λ{()}) Γ⊢ Γ⊢A) (↓length Γ Γ⊢) ↓⊢T Γ ∗ A≠∗ Γ⊢A = ⊥-elim (A≠∗ idp) ↓⊢T Γ (_ ⇒[ ∗ ] _) A≠∗ Γ⊢ (ar Γ⊢A _ _) = ob (↓⊢C Γ Γ⊢) ↓⊢T Γ (Var x ⇒[ A@(_ ⇒[ _ ] _) ] Var y) A≠∗ Γ⊢ (ar Γ⊢A Γ⊢x Γ⊢y) = ar (↓⊢T Γ A (λ{()}) Γ⊢ Γ⊢A) (↓⊢t Γ A x (λ{()}) Γ⊢ Γ⊢A Γ⊢x) (↓⊢t Γ A y (λ{()}) Γ⊢ Γ⊢A Γ⊢y) ↓⊢t (Γ :: (y , B)) A x A≠∗ Γ+⊢@(cc Γ⊢ x₁ x₂) Γ+⊢A Γ+⊢x@(var _ (inl x∈Γ)) = let Γ⊢x = var Γ⊢ x∈Γ in let Γ⊢A = Γ⊢t:A→Γ⊢A Γ⊢x in ↓wkt Γ B y Γ⊢ Γ+⊢ (↓⊢t Γ A x A≠∗ Γ⊢ Γ⊢A Γ⊢x) (wk↓GT Γ B y A Γ⊢A Γ+⊢A) (Var= (wk↓Gt Γ B y x A Γ⊢x Γ+⊢x)) ↓⊢t Γ+@(Γ :: (x , ∗)) .∗ .x A≠∗ Γ+⊢@(cc _ _ _) Γ⊢A (var _ (inr (idp , idp))) = ⊥-elim (A≠∗ idp) ↓⊢t Γ+@(Γ :: (.(length Γ) , A@(_ ⇒[ _ ] _))) .(_ ⇒[ _ ] _) .(length Γ) A≠∗ Γ+⊢@(cc Γ⊢ Γ⊢A idp) Γ+⊢A@(ar _ _ _) (var (cc _ _ _) (inr (idp , idp))) = var (↓⊢C Γ+ Γ+⊢) (inr (idp , (wk↓GT Γ A (length Γ) A Γ⊢A Γ+⊢A ^)))
{ "alphanum_fraction": 0.4263047219, "avg_line_length": 58.1222222222, "ext": "agda", "hexsha": "c4bbcbe7e50f6b6e9dd703b62e00043172d371ac", "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": "ed45935b38d6a86fa662f561866140122ee3dcef", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ThiBen/catt-formalization", "max_forks_repo_path": "MCaTT/Desuspension.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ed45935b38d6a86fa662f561866140122ee3dcef", "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": "ThiBen/catt-formalization", "max_issues_repo_path": "MCaTT/Desuspension.agda", "max_line_length": 192, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed45935b38d6a86fa662f561866140122ee3dcef", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ThiBen/catt-formalization", "max_stars_repo_path": "MCaTT/Desuspension.agda", "max_stars_repo_stars_event_max_datetime": "2020-05-20T00:41:09.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-01T08:26:53.000Z", "num_tokens": 3249, "size": 5231 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Species.Constructions where -- Construction of basic species open import Level open import Data.Empty open import Data.Fin.Base as Fin using (Fin) open import Data.Fin.Properties using (¬Fin0) open import Data.Fin.Permutation using (↔⇒≡) open import Data.Nat.Base using (ℕ; suc; zero) open import Data.Nat.Properties using (_≟_) open import Data.Product as × using (Σ; proj₁; proj₂; _,_) open import Data.Product.Relation.Binary.Pointwise.NonDependent open import Data.Sum.Base as ⊎ using (inj₁; inj₂) open import Data.Sum.Relation.Binary.Pointwise using (_⊎ₛ_; inj₁; inj₂) open import Data.Unit.Polymorphic using (⊤; tt) open import Function.Base using () renaming (id to id→) open import Function.Equality using (_⟨$⟩_; cong; Π) renaming (id to idΠ) open import Function.Bundles using (Inverse) open import Relation.Nullary using (Dec; yes; no) import Function.Inverse as Inv open import Relation.Binary.Bundles using (Setoid) import Relation.Binary.PropositionalEquality as ≡ open import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial using (indexedSetoid) open import Categories.Category.Core using (Category) open import Categories.Category.Construction.ObjectRestriction using (ObjectRestriction) open import Categories.Category.Construction.Core using (Core) open import Categories.Category.Instance.Setoids using (Setoids) open import Categories.Category.Instance.FinSetoids using (FinSetoids; IsFiniteSetoid) open import Categories.Category.Product open import Categories.Functor.Core using (Functor) open import Categories.Functor.Construction.Constant using (const) open import Categories.Functor.Hom open import Categories.Morphism.IsoEquiv using (_≃_) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) open import Categories.Category.Species import Categories.Morphism as Mor -- Some useful preliminary definitions. Should be in stdlib module _ {o ℓ : Level} where -- the Setoid version of ⊥ ⊥-Setoid : Setoid o ℓ ⊥-Setoid = record { Carrier = Lift o ⊥ ; _≈_ = λ () ; isEquivalence = record { refl = λ { {()} } ; sym = λ { {()} } ; trans = λ { {()} } } } ⊤-Setoid : Setoid o ℓ ⊤-Setoid = record { Carrier = ⊤ ; _≈_ = λ _ _ → ⊤} ⊤-FinSetoid : Σ (Setoid o ℓ) IsFiniteSetoid ⊤-FinSetoid = ⊤-Setoid , 1 , record { f = λ _ → Fin.zero ; f⁻¹ = λ _ → tt ; cong₁ = λ _ → ≡.refl ; cong₂ = λ _ → tt ; inverse = (λ { Fin.zero → ≡.refl}) , λ _ → tt } -- We could have 4 levels, and still define Zero and One′. -- But X needs o ≡ o′ and ℓ ≡ ℓ′. And then the 'proper' definition of One makes that all the same. module _ (o : Level) where -- Setoid o ℓ is used a lot, name it too S = Setoid o o FinSet = FinSetoids o o 𝔹 = Core FinSet Sp = Species o o o o open Category Sp open Mor FinSet open _≅_ -- convenient alias: a structure is an Object of Species -- (which is of course a functor) Structure = Obj Zero : Structure Zero = const ⊥-Setoid -- One can be specified in two ways. The traditional one (which doesn't generalize as well) -- uses 'counting' directly. One′ : Structure One′ = record { F₀ = on-singleton ; F₁ = map-singleton ; identity = λ {A} x≈y → identity′ {A} x≈y -- eta expansion needed ; homomorphism = λ {X} {Y} {Z} → homomorphism′ {X} {Y} {Z} -- eta needed ; F-resp-≈ = resp } where iso⇒Inverse : (A B : Σ S IsFiniteSetoid) (A≅B : A ≅ B) → Inverse (proj₁ A) (proj₁ B) iso⇒Inverse (s , n , p) (s′ , n′ , p′) A≅B = record { f = from A≅B ⟨$⟩_ ; f⁻¹ = to A≅B ⟨$⟩_ ; cong₁ = cong (from A≅B) ; cong₂ = cong (to A≅B) ; inverse = (λ x → isoʳ A≅B (Setoid.refl s′ {x})) , λ x → isoˡ A≅B (Setoid.refl s {x}) } iso⇒≡ : {A B : Σ S IsFiniteSetoid} (A≅B : A ≅ B) → proj₁ (proj₂ A) ≡.≡ proj₁ (proj₂ B) iso⇒≡ {A@(s , n , p)} {B@(s′ , n′ , p′)} A≅B = ↔⇒≡ ( (translate p′) Inv.∘ (translate X Inv.∘ Inv.sym (translate p))) where X : Inverse (proj₁ A) (proj₁ B) X = iso⇒Inverse A B A≅B translate : {a b c d : Level} {X : Setoid a b} {Y : Setoid c d} → Inverse X Y → Inv.Inverse X Y translate I = record { to = record { _⟨$⟩_ = Inverse.f I ; cong = Inverse.cong₁ I } ; from = record { _⟨$⟩_ = Inverse.f⁻¹ I ; cong = Inverse.cong₂ I } ; inverse-of = record { left-inverse-of = Inverse.inverseʳ I ; right-inverse-of = Inverse.inverseˡ I } } -- one can do this in 3 cases structurally, but that leads to 9 cases elsewhere -- so a dispatch on size makes sense on-singleton : Σ S IsFiniteSetoid → S on-singleton (s , n , _) with n ≟ 1 ... | yes p = s ... | no ¬p = ⊥-Setoid map-singleton : {A B : Σ S IsFiniteSetoid} → A ≅ B → Π (on-singleton A) (indexedSetoid (on-singleton B)) map-singleton {s , n , p} {s′ , n′ , p′} A≅B with n ≟ 1 | n′ ≟ 1 map-singleton A≅B | yes ≡.refl | yes ≡.refl = from A≅B map-singleton A≅B | yes ≡.refl | no n′≢1 = ⊥-elim (n′≢1 (≡.sym (iso⇒≡ A≅B))) map-singleton A≅B | no n≢1 | yes n′≡1 = ⊥-elim (n≢1 (≡.trans (iso⇒≡ A≅B) n′≡1)) map-singleton A≅B | no n≢1 | no n′≢1 = idΠ identity′ : {A : Σ S IsFiniteSetoid} {x y : Setoid.Carrier (on-singleton A)} → let SA = on-singleton A in Setoid._≈_ SA x y → Setoid._≈_ SA (map-singleton {A} {A} ≅.refl ⟨$⟩ x) y identity′ {s , ℕ.suc ℕ.zero , p} x≈y = x≈y homomorphism′ : {X Y Z : Σ S IsFiniteSetoid} {f : X ≅ Y} {g : Y ≅ Z} {x y : Setoid.Carrier (on-singleton X)} → Setoid._≈_ (on-singleton X) x y → Setoid._≈_ (on-singleton Z) (map-singleton (≅.trans f g) ⟨$⟩ x) (map-singleton g ⟨$⟩ (map-singleton f ⟨$⟩ y)) homomorphism′ {f = f} {g} x≈y with iso⇒≡ f | iso⇒≡ g homomorphism′ {_ , 1 , _} {f = f} {g} x≈y | ≡.refl | ≡.refl = cong (from g) (cong (from f) x≈y) resp : {A B : Σ S IsFiniteSetoid} {f g : A ≅ B} → (_≃_ FinSet f g) → {x y : Setoid.Carrier (on-singleton A)} → Setoid._≈_ (on-singleton A) x y → Setoid._≈_ (on-singleton B) (map-singleton f ⟨$⟩ x) (map-singleton g ⟨$⟩ y) resp {_ , 1 , _} {f = f} {g} f≈g x≈y with iso⇒≡ f resp {_ , 1 , _} {f = f} {g} f≈g x≈y | ≡.refl = _≃_.from-≈ f≈g x≈y -- There is a much nicer specification. One : Structure One = Hom[ 𝔹 ][ ⊤-FinSetoid ,-] -- the 'identity' Functor isn't really, it needs to forget the proof. X : Structure X = record { F₀ = proj₁ ; F₁ = λ f → record { _⟨$⟩_ = from f ⟨$⟩_ ; cong = cong (from f) } ; identity = id→ ; homomorphism = λ { {f = f} {g} x≈y → cong (from g) (cong (from f) x≈y)} ; F-resp-≈ = _≃_.from-≈ } -- generally this should be defined elsewhere _+_ : Structure → Structure → Structure A + B = record { F₀ = λ x → A.₀ x ⊎ₛ B.₀ x ; F₁ = λ X≅Y → record { _⟨$⟩_ = ⊎.map (A.₁ X≅Y ⟨$⟩_) (B.₁ X≅Y ⟨$⟩_) ; cong = λ { (inj₁ x≈y) → inj₁ (cong (A.₁ X≅Y) x≈y ) ; (inj₂ x≈y) → inj₂ (cong (B.₁ X≅Y) x≈y)} } ; identity = λ { (inj₁ x) → inj₁ (A.identity x) ; (inj₂ x) → inj₂ (B.identity x)} ; homomorphism = λ { (inj₁ x) → inj₁ (A.homomorphism x) ; (inj₂ x) → inj₂ (B.homomorphism x) } ; F-resp-≈ = λ { f≃g (inj₁ x) → inj₁ (A.F-resp-≈ f≃g x) ; f≃g (inj₂ x) → inj₂ (B.F-resp-≈ f≃g x)} } where module A = Functor A module B = Functor B -- Hadamard product _×_ : Structure → Structure → Structure A × B = record { F₀ = λ x → ×-setoid (A.₀ x) (B.₀ x) ; F₁ = λ X≅Y → record { _⟨$⟩_ = ×.map (A.₁ X≅Y ⟨$⟩_) (B.₁ X≅Y ⟨$⟩_) ; cong = ×.map (cong (A.₁ X≅Y)) (cong (B.₁ X≅Y)) } ; identity = ×.map A.identity B.identity ; homomorphism = ×.map A.homomorphism B.homomorphism ; F-resp-≈ = λ f≈g → ×.map (A.F-resp-≈ f≈g) (B.F-resp-≈ f≈g) } where module A = Functor A module B = Functor B
{ "alphanum_fraction": 0.5890222556, "avg_line_length": 39.0146341463, "ext": "agda", "hexsha": "281f6f41ccc35e2e27898a5531f0686a2b01d7f4", "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/Species/Constructions.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/Species/Constructions.agda", "max_line_length": 120, "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/Species/Constructions.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": 3027, "size": 7998 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Proofs.Semantics where open import Relation.Binary.PropositionalEquality open import Data.Binary.Operations.Unary open import Data.Binary.Proofs.Unary open import Data.Binary.Definitions open import Data.Binary.Operations.Semantics open import Data.Nat as ℕ using (ℕ; suc; zero) open import Relation.Binary.PropositionalEquality.FasterReasoning import Data.Nat.Properties as ℕ open import Function open import Data.Nat.Reasoning 2*-distrib : ∀ x y → 2* (x ℕ.+ y) ≡ 2* x ℕ.+ 2* y 2*-distrib x y = begin 2* (x ℕ.+ y) ≡⟨⟩ (x ℕ.+ y) ℕ.+ (x ℕ.+ y) ≡⟨ ℕ.+-assoc x y (x ℕ.+ y) ⟩ x ℕ.+ (y ℕ.+ (x ℕ.+ y)) ≡⟨ x +≫ ℕ.+-comm y (x ℕ.+ y) ⟩ x ℕ.+ ((x ℕ.+ y) ℕ.+ y) ≡⟨ x +≫ ℕ.+-assoc x y y ⟩ x ℕ.+ (x ℕ.+ (y ℕ.+ y)) ≡˘⟨ ℕ.+-assoc x x _ ⟩ 2* x ℕ.+ 2* y ∎ s2*-distrib : ∀ x y → I ∷⇓ (x ℕ.+ y) ≡ suc (2* x ℕ.+ 2* y) s2*-distrib x y = cong suc (2*-distrib x y)
{ "alphanum_fraction": 0.5974440895, "avg_line_length": 27.6176470588, "ext": "agda", "hexsha": "e87772826efe9fa2c814caa567403790b2d33b84", "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/Proofs/Semantics.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/Proofs/Semantics.agda", "max_line_length": 65, "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/Proofs/Semantics.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": 378, "size": 939 }
module std-reduction where open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Context using (EvaluationContext ; EvaluationContext1 ; _⟦_⟧e ; _≐_⟦_⟧e ; Context ; Context1 ; _⟦_⟧c ; _≐_⟦_⟧c) open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; sig ; []env ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.Variable.Signal as Signal using (Signal) open import Esterel.Variable.Shared as SharedVar using (SharedVar) open import Esterel.Variable.Sequential as SeqVar using (SeqVar) open import sn-calculus using (all-ready ; [s,δe]-env ; [x,δe]-env ; δ) open import std-reduction.Base open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Relation.Nullary using (¬_) open import Relation.Binary.PropositionalEquality using (_≡_) open _≡_ open import Data.Nat using (_+_ ; zero ; suc) open import Data.List using ([]) infix 4 _⇁_ data _⇁_ : Term → Term → Set where std-par-right : ∀ {p q r E θ A} → left-most θ E → (p' : halted p) → (q' : done q) → r ≐ E ⟦ (p ∥ q) ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (value-max (dhalted p') q' (inj₁ p')) ⟧e) std-par-left : ∀ {p q r E θ A} → left-most θ E → (p' : paused p) → (q' : halted q) → r ≐ E ⟦ (p ∥ q) ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (value-max (dpaused p') (dhalted q') (inj₂ q')) ⟧e) std-is-present : ∀ {p q r E θ A} → left-most θ E → ∀ S → (S∈ : Env.isSig∈ S θ) → Env.sig-stats{S} θ S∈ ≡ Signal.present → r ≐ E ⟦ present S ∣⇒ p ∣⇒ q ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ p ⟧e) std-is-absent : ∀ {p q r E θ A} → left-most θ E → ∀ S → (S∈ : Env.isSig∈ S θ) → Env.sig-stats{S} θ S∈ ≡ Signal.absent → r ≐ E ⟦ present S ∣⇒ p ∣⇒ q ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ q ⟧e) std-emit : ∀{θ E r} → left-most θ E → ∀ S → (S∈ : (Env.isSig∈ S θ)) → (¬S≡a : ¬ (Env.sig-stats{S} θ S∈) ≡ Signal.absent) → r ≐ E ⟦ emit S ⟧e → (ρ⟨ θ , GO ⟩· r) ⇁ (ρ⟨ (Env.set-sig{S} θ S∈ Signal.present) , GO ⟩· E ⟦ nothin ⟧e) std-loop-unroll : ∀{θ E r p A} → left-most θ E → r ≐ E ⟦ loop p ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (loopˢ p p) ⟧e) std-seq-done : ∀{θ E r q A} → left-most θ E → r ≐ E ⟦ (nothin >> q) ⟧e → ρ⟨ θ , A ⟩· r ⇁ (ρ⟨ θ , A ⟩· E ⟦ q ⟧e) std-seq-exit : ∀{θ E r q n A} → left-most θ E → r ≐ E ⟦ (exit n >> q) ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (exit n) ⟧e) std-loopˢ-exit : ∀{θ E r q n A} → left-most θ E → r ≐ E ⟦ (loopˢ (exit n) q) ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (exit n) ⟧e) std-suspend-done : ∀{θ E r p S A} → left-most θ E → (p' : halted p) → r ≐ E ⟦ (suspend p S) ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ p ⟧e) std-trap-done : ∀{θ E r p A} → left-most θ E → (p' : halted p) → r ≐ E ⟦ (trap p) ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (↓ p') ⟧e) std-raise-signal : ∀{θ E r p S A} → left-most θ E → r ≐ E ⟦ (signl S p) ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (ρ⟨ (Θ SigMap.[ S ↦ Signal.unknown ] ShrMap.empty VarMap.empty) , WAIT ⟩· p) ⟧e) std-raise-shared : ∀{θ r s e p E A} → left-most θ E → (e' : all-ready e θ) → r ≐ E ⟦ shared s ≔ e in: p ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (ρ⟨ [s,δe]-env s (δ e') , WAIT ⟩· p) ⟧e) std-set-shared-value-old : ∀{θ r s e E} → left-most θ E → (e' : all-ready e θ) → (s∈ : (Env.isShr∈ s θ)) → Env.shr-stats{s} θ s∈ ≡ SharedVar.old → r ≐ E ⟦ s ⇐ e ⟧e → (ρ⟨ θ , GO ⟩· r) ⇁ (ρ⟨ (Env.set-shr{s} θ s∈ (SharedVar.new) (δ e')) , GO ⟩· E ⟦ nothin ⟧e) std-set-shared-value-new : ∀{θ r s e E} → left-most θ E → (e' : all-ready e θ) → (s∈ : (Env.isShr∈ s θ)) → Env.shr-stats{s} θ s∈ ≡ SharedVar.new → r ≐ E ⟦ s ⇐ e ⟧e → (ρ⟨ θ , GO ⟩· r) ⇁ (ρ⟨ (Env.set-shr{s} θ s∈ (SharedVar.new) (Env.shr-vals{s} θ s∈ + δ e')) , GO ⟩· E ⟦ nothin ⟧e) -- unshared state std-raise-var : ∀{θ r x p e E A} → left-most θ E → (e' : all-ready e θ) → r ≐ E ⟦ var x ≔ e in: p ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ (ρ⟨ [x,δe]-env x (δ e') , WAIT ⟩· p) ⟧e) std-set-var : ∀{θ r x e E A} → left-most θ E → (x∈ : (Env.isVar∈ x θ)) → (e' : all-ready e θ) → r ≐ E ⟦ x ≔ e ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ (Env.set-var{x} θ x∈ (δ e')) , A ⟩· E ⟦ nothin ⟧e) -- if std-if-false : ∀{θ r p q x E A} → left-most θ E → (x∈ : (Env.isVar∈ x θ)) → Env.var-vals{x} θ x∈ ≡ zero → r ≐ E ⟦ if x ∣⇒ p ∣⇒ q ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ q ⟧e) std-if-true : ∀{θ r p q x E n A} → left-most θ E → (x∈ : (Env.isVar∈ x θ)) → Env.var-vals{x} θ x∈ ≡ suc n → r ≐ E ⟦ if x ∣⇒ p ∣⇒ q ⟧e → (ρ⟨ θ , A ⟩· r) ⇁ (ρ⟨ θ , A ⟩· E ⟦ p ⟧e) std-merge : ∀{θ₁ θ₂ r p E A₁ A₂} → left-most θ₁ E → r ≐ E ⟦ ρ⟨ θ₂ , A₂ ⟩· p ⟧e → (ρ⟨ θ₁ , A₁ ⟩· r) ⇁ (ρ⟨ (θ₁ ← θ₂) , (A-max A₁ A₂) ⟩· E ⟦ p ⟧e) std-absent : ∀{θ p A} → blocked-or-done θ A p → ¬ (can-set-absent θ p ≡ []) → ρ⟨ θ , A ⟩· p ⇁ ρ⟨ (set-all-absent θ (can-set-absent θ p)) , A ⟩· p std-readyness : ∀{θ p A} → blocked-or-done θ A p → (can-set-absent θ p ≡ []) → ¬ (can-set-ready θ p ≡ []) → ρ⟨ θ , A ⟩· p ⇁ ρ⟨ (set-all-ready θ (can-set-ready θ p)) , A ⟩· p
{ "alphanum_fraction": 0.4567855143, "avg_line_length": 30.4375, "ext": "agda", "hexsha": "8161aae8295319e6d76a8f8c04041fba8e8de36a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/std-reduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/std-reduction.agda", "max_line_length": 90, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/std-reduction.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 2752, "size": 5357 }
{-# OPTIONS --without-K #-} module hott.equivalence.biinvertible where open import sum open import equality open import function.core open import function.isomorphism.core open import function.isomorphism.utils open import function.overloading open import function.extensionality open import hott.level.core open import hott.level.closure open import hott.equivalence.core open import hott.equivalence.alternative open import sets.unit module _ {i j}{X : Set i}{Y : Set j} where InvL : (X → Y) → Set _ InvL f = Σ (Y → X) λ g → (x : X) → g (f x) ≡ x InvR : (X → Y) → Set _ InvR f = Σ (Y → X) λ g → (y : Y) → f (g y) ≡ y BiInv : (X → Y) → Set _ BiInv f = InvL f × InvR f _≈₂_ : ∀ {i j} → Set i → Set j → Set _ X ≈₂ Y = Σ (X → Y) BiInv module _ {i j}{X : Set i}{Y : Set j} where ≅⇒b : X ≅ Y → X ≈₂ Y ≅⇒b f = apply f , (invert f , _≅_.iso₁ f) , (invert f , _≅_.iso₂ f) b⇒≅ : X ≈₂ Y → X ≅ Y b⇒≅ (f , (g , α) , (h , β)) = record { to = f ; from = g ; iso₁ = α ; iso₂ = λ y → sym (ap (f ∘' g) (β y)) · ap f (α (h y)) · β y } module _ (isom : X ≅ Y) where private f : X → Y f = apply isom φ : ∀ {k} (Z : Set k) → (X → Z) ≅ (Y → Z) φ Z = record { to = λ u → u ∘ invert isom ; from = λ v → v ∘ f ; iso₁ = λ u → funext λ x → ap u (_≅_.iso₁ isom x) ; iso₂ = λ v → funext λ y → ap v (_≅_.iso₂ isom y) } invl-level : contr (InvL f) invl-level = iso-level (Σ-ap-iso refl≅ λ g → sym≅ strong-funext-iso) (proj₂ (≅⇒≈ (sym≅ (φ X))) id) private ψ : ∀ {k} (Z : Set k) → (Z → X) ≅ (Z → Y) ψ Z = record { to = λ u → f ∘ u ; from = λ v → invert isom ∘ v ; iso₁ = λ u → funext λ x → _≅_.iso₁ isom (u x) ; iso₂ = λ v → funext λ y → _≅_.iso₂ isom (v y) } invr-level : contr (InvR f) invr-level = iso-level (Σ-ap-iso refl≅ λ h → sym≅ strong-funext-iso) (proj₂ (≅⇒≈ (ψ Y)) id) BiInv-level : (f : X → Y) → h 1 (BiInv f) BiInv-level f b₁ b₂ = h↑ (×-contr (invl-level isom) (invr-level isom)) b₁ b₂ where isom : X ≅ Y isom = b⇒≅ (f , b₁) b⇔≈ : (X ≈₂ Y) ≅ (X ≈ Y) b⇔≈ = record { to = λ b → ≅⇒≈ (b⇒≅ b) ; from = λ φ → (≅⇒b (≈⇒≅ φ)) ; iso₁ = λ { (f , b) → ap (λ b → f , b) (h1⇒prop (BiInv-level f) _ _) } ; iso₂ = λ { (f , e) → ap (λ e → f , e) (h1⇒prop (weak-equiv-h1 f) _ _) } }
{ "alphanum_fraction": 0.4925496689, "avg_line_length": 29.8271604938, "ext": "agda", "hexsha": "46caa7f0741e3086114a2292ce801b4f627bffca", "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/hott/equivalence/biinvertible.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/hott/equivalence/biinvertible.agda", "max_line_length": 79, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/hott/equivalence/biinvertible.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 1041, "size": 2416 }
data Nat : Set where zero : Nat suc : Nat → Nat test : ∀{N M : Nat} → Nat → Nat → Nat test L K = {!N L M!} -- Andreas, 2016-07-10, issue 2088 -- Changed behavior: -- The hidden variables N and M are made visible -- only the visible L is split.
{ "alphanum_fraction": 0.6265060241, "avg_line_length": 22.6363636364, "ext": "agda", "hexsha": "8eb86518f98fced2bde26e56837f2a7f1cdc4a0d", "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/SplitOnHidden.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/SplitOnHidden.agda", "max_line_length": 48, "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/SplitOnHidden.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": 83, "size": 249 }
-- pull in Haskell Ints module int where open import bool open import string open import list open import char open import functions open import nat postulate int : Set int0 : int int1 : int _+int_ : int → int → int _*int_ : int → int → int _-int_ : int → int → int 𝕃char-to-int : 𝕃 char → int int-to-𝕃char : int → 𝕃 char is-zero-int : int → 𝔹 {-# COMPILE GHC int = type Int #-} {-# COMPILE GHC int0 = 0 #-} {-# COMPILE GHC int1 = 1 #-} {-# COMPILE GHC _+int_ = (+) #-} {-# COMPILE GHC _*int_ = (*) #-} {-# COMPILE GHC _-int_ = (-) #-} {-# COMPILE GHC 𝕃char-to-int = \ x -> read x :: Int #-} {-# COMPILE GHC int-to-𝕃char = \ x -> show x #-} {-# COMPILE GHC is-zero-int = (==) 0 #-} string-to-int : string → int string-to-int = 𝕃char-to-int ∘ string-to-𝕃char int-to-string : int → string int-to-string = 𝕃char-to-string ∘ int-to-𝕃char int-from-nat : ℕ → int int-from-nat zero = int0 int-from-nat (suc n) = int1 +int (int-from-nat n)
{ "alphanum_fraction": 0.6079249218, "avg_line_length": 23.3902439024, "ext": "agda", "hexsha": "499439a2befe328895ad38fb29fcee8b79b6489e", "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": "int.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": "int.agda", "max_line_length": 55, "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": "int.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": 343, "size": 959 }
{-# OPTIONS --overlapping-instances #-} module Sort where open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import Data.List using (List; _∷_; []) open import Data.Variant using (Variants; inj; `_) -- instance search methods open import Data.List.Membership.Propositional.Instances using (⦃here⦄; ⦃there⦄) open import Data.List.Relation.Binary.Subset.Propositional.Instances using (⦃[]⊆xs⦄; ⦃x∈ys-xs⊆ys⇒x∷xs⊆ys⦄; ⦅_⊆_⦆) open import Data.Union.Relation.Binary.Subtype.Instances using (⦃refl⦄; ⦃generalize⦄; ⦃function⦄; ⌊_⌋) -- ---------------------------------------------------------------------- -- Example (Injections) data Sort : Set where term type : Sort _ : Variants Sort (term ∷ []) _ = ` term _-Bounds : List Sort → Set 𝒮 -Bounds = Variants Sort 𝒮 → ℕ Index : {𝒮 : List Sort} → Variants Sort 𝒮 → (𝒮 -Bounds) → Set Index 𝓈 Γ = Fin (Γ 𝓈) term-sorts : List Sort term-sorts = term ∷ type ∷ [] infix 9 #_ data Term : term-sorts -Bounds → Set where #_ : ∀ {Γ} → Index (` term) Γ → Term Γ -- ---------------------------------------------------------------------- -- Example (Subtyping) type-sorts : List Sort type-sorts = type ∷ [] infix 9 ~_ data Type : type-sorts -Bounds → Set where ~_ : ∀ {Γ} → Index (` type) Γ → Type Γ it : ∀ {a} {A : Set a} → {{A}} → A it {{x}} = x _ : ⦅ type-sorts ⊆ term-sorts ⦆ _ = it _ : term-sorts -Bounds → Set _ = ⌊ Type ⌋ infixl 7 _[_] data Term′ : term-sorts -Bounds → Set where #_ : ∀ {Γ} → Index (` term) Γ → Term′ Γ _[_] : ∀ {Γ} → Term′ Γ → ⌊ Type ⌋ Γ → Term′ Γ
{ "alphanum_fraction": 0.5630198337, "avg_line_length": 22.652173913, "ext": "agda", "hexsha": "b7f9e90a9651bbb54841228ed6da2f75ce4a0b31", "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": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-union", "max_forks_repo_path": "examples/Sort.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "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": "johnyob/agda-union", "max_issues_repo_path": "examples/Sort.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-union", "max_stars_repo_path": "examples/Sort.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 564, "size": 1563 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.IdUPiPi {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm) open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Weakening open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Properties open import Definition.LogicalRelation.Substitution.Irrelevance as S open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Introductions.Sigma open import Definition.LogicalRelation.Substitution.Introductions.Fst open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Definition.LogicalRelation.Substitution.Introductions.Lambda open import Definition.LogicalRelation.Substitution.Introductions.Application open import Definition.LogicalRelation.Substitution.Introductions.Cast open import Definition.LogicalRelation.Substitution.Introductions.Id open import Definition.LogicalRelation.Substitution.Introductions.Transp open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Definition.LogicalRelation.Substitution.MaybeEmbed open import Definition.LogicalRelation.Substitution.Escape open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Definition.LogicalRelation.Substitution.Reduction open import Definition.LogicalRelation.Substitution.Weakening open import Definition.LogicalRelation.Substitution.ProofIrrelevance open import Definition.LogicalRelation.Fundamental.Variable open import Tools.Product open import Tools.Nat import Tools.PropositionalEquality as PE lemma0 : ∀ σ A → (wk1 (wk1 (subst σ A))) PE.≡ subst (liftSubst (liftSubst σ)) (wk1 (wk1 A)) lemma0 σ A = PE.trans (PE.cong wk1 (PE.sym (Idsym-subst-lemma σ A))) (PE.sym (Idsym-subst-lemma (liftSubst σ) (wk1 A))) lemma1 : ∀ {σ rA} A A' B → wk1d (subst (liftSubst σ) B) [ cast ⁰ (wk1 (wk1 (subst σ A'))) (wk1 (wk1 (subst σ A))) (Idsym (Univ rA ⁰) (wk1 (wk1 (subst σ A))) (wk1 (wk1 (subst σ A'))) (var 1)) (var 0)]↑ PE.≡ subst (liftSubst (liftSubst σ)) (U.wk (lift (step id)) B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0)]↑) lemma1 {σ} {rA} A A' B = PE.trans (PE.cong₂ (λ X Y → X [ Y ]↑) (PE.sym (Idsym-subst-lemma-wk1d σ B)) (PE.cong₃ (λ X Y Z → cast ⁰ X Y Z (var 0)) (lemma0 σ A') (lemma0 σ A) (PE.trans (PE.cong₂ (λ X Y → Idsym (Univ rA ⁰) X Y (var 1)) (lemma0 σ A) (lemma0 σ A')) (PE.sym (subst-Idsym (liftSubst (liftSubst σ)) (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)))))) (PE.sym ((singleSubstLift↑ (liftSubst σ) (U.wk (lift (step id)) B) _))) lemma2 : ∀ {σ} B → U.wk (lift (step id)) (subst (liftSubst σ) B) PE.≡ subst (liftSubst (liftSubst σ)) (U.wk (lift (step id)) B) lemma2 B = PE.sym (Idsym-subst-lemma-wk1d _ B) Id-U-ΠΠ-resᵗᵛ : ∀ {A B A' B' rA Γ} ([Γ] : ⊩ᵛ Γ) → let l = ∞ lΠ = ⁰ [UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ]) [UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ]) Id-U-ΠΠ-res A A' B B' = (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰) (wk1d B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (wk1d B') ° ¹ ° ¹) in ([A] : Γ ⊩ᵛ⟨ l ⟩ A ^ [ rA , ι lΠ ] / [Γ]) ([A'] : Γ ⊩ᵛ⟨ l ⟩ A' ^ [ rA , ι lΠ ] / [Γ]) ([UB] : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A]) ([UB'] : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A']) ([A]ₜ : Γ ⊩ᵛ⟨ l ⟩ A ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA]) ([B]ₜ : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A] / (λ {Δ} {σ} → [UB] {Δ} {σ})) ([A']ₜ : Γ ⊩ᵛ⟨ l ⟩ A' ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA]) ([B']ₜ : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B' ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'] / (λ {Δ} {σ} → [UB'] {Δ} {σ})) → let [IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ [ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ [wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A'] [wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A] [wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ [ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']' [wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']' [wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA'] [wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA] [wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ} [wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA'] [SProp] = Uᵛ {rU = %} ∞< [ΓId] in ([var0]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 0 ∷ wk1 (wk1 A') ^ [ rA , ι ⁰ ] / [ΓIdA'] / [wwA']') ([var1]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 1 ∷ Id (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) ^ [ % , ι ¹ ] / [ΓIdA'] / [wwIdAA']) → Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ⊩ᵛ⟨ ∞ ⟩ Id-U-ΠΠ-res A A' B B' ∷ SProp ¹ ^ [ ! , ∞ ] / [ΓId] / (λ {Δ} {σ} → [SProp] {Δ} {σ}) Id-U-ΠΠ-resᵗᵛ {A} {B} {A'} {B'} {rA} {Γ} [Γ] [A] [A'] [UB] [UB'] [A]ₜ [B]ₜ [A']ₜ [B']ₜ [var0]ₜ [var1]ₜ = let l = ∞ lΠ = ⁰ [SProp] = Uᵛ {rU = %} ∞< [Γ] [UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ]) [UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ]) ⊢AΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A]ₜ ⊢Δ [σ])) ⊢A'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A']ₜ ⊢Δ [σ])) ⊢A = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A] {Δ} {σ} ⊢Δ [σ])) ⊢A' = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A'] {Δ} {σ} ⊢Δ [σ])) [ΓA] = (_∙_ {Γ} {A} [Γ] [A]) [ΓA'] = (_∙_ {Γ} {A'} [Γ] [A']) ⊢BΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B]ₜ {Δ} {σ} ⊢Δ [σ])) [A]' = univᵛ {A = A} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']' = univᵛ {A = A'} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A']ₜ [B]' = univᵛ {A = B} [ΓA] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB] {Δ} {σ}) [B]ₜ [B] = maybeEmbᵛ {A = B} [ΓA] [B]' [B']' = univᵛ {A = B'} [ΓA'] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [B']ₜ [B'] = maybeEmbᵛ {A = B'} [ΓA'] [B']' ⊢B'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB'] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B']ₜ {Δ} {σ} ⊢Δ [σ])) [liftσ] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A] [σ] [liftσ'] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A'} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A'] [σ] [ΠAB] = Πᵗᵛ {A} {B} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A] (λ {Δ} {σ} → [UB] {Δ} {σ}) [A]ₜ [B]ₜ [ΠA'B'] = Πᵗᵛ {A'} {B'} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A']ₜ [B']ₜ [IdAA']ₜ = Idᵗᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ (Uᵗᵛ [Γ]) [IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ Id-U-ΠΠ-res A A' B B' = ∃ (Id (Univ rA ⁰) A A') ▹ (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰) ((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (U.wk (lift (step id)) B') ° ¹ ° ¹) [ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [wSProp] = Uᵛ {rU = %} ∞< [ΓId] [wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ [wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A'] [wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A] [wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ [ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']' [wwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓIdA'] {Δ} {σ} [wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ} [wwUA']ᵗ = Uᵗᵛ [ΓIdA'] [ΓIdA] = _∙_ {A = wk1 A} [ΓId] [wA]' [wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA'] [wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA] [wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']' [wwA]' = wk1ᵛ {A = wk1 A} {F = wk1 A'} [ΓId] [wA']' [wA]' [wwU0A] = maybeEmbᵛ {A = Univ ! _ } [ΓIdA] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA] {Δ} {σ}) [wB'] = wk1dᵗᵛ {F = A'} {F' = Id (Univ rA ⁰) A A'} {G = B'} [Γ] [A'] [IdAA'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) [B']ₜ [wB] = wk1dᵗᵛ {F = A} {F' = Id (Univ rA ⁰) A A'} {G = B} [Γ] [A] [IdAA'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [wwU0A] {Δ} {σ}) [B]ₜ [wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA'] [wwIdA'A] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A')} {u = wk1 (wk1 A)} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA] in Πᵗᵛ {wk1 A'} {Id (U ⁰) (U.wk (lift (step id)) B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (U.wk (lift (step id)) B')} (<is≤ 0<1) (≡is≤ PE.refl) [ΓId] [wA']' (λ {Δ} {σ} → [wwU¹] {Δ} {σ} %) [wA'] (Idᵗᵛ {A = U ⁰} {t = (U.wk (lift (step id)) B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)} {u = U.wk (lift (step id)) B'} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) (subst↑STerm {F = wk1 A'} {F' = wk1 A} {G = wk1d B} {t = cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0)} [ΓId] [wA']' [wA]' (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) (λ {Δ} {σ} → [wwU0A] {Δ} {σ}) [wB] (castᵗᵛ {A = wk1 (wk1 A')} {B = wk1 (wk1 A)} {t = var 0} {e = (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1))} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA] [wwA']' [wwA]' [var0]ₜ (Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A')} {u = wk1 (wk1 A)} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA]) (IdSymᵗᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} {e = var 1} [ΓIdA'] ((λ {Δ} {σ} → [wwU¹] {Δ} {σ} !)) (λ {Δ} {σ} → [wwUA']ᵗ {Δ} {σ}) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA'] [wwIdAA'] [wwIdA'A] [var1]ₜ))) [wB'] (λ {Δ} {σ} → Uᵗᵛ [ΓIdA'] {Δ} {σ})) abstract Id-U-ΠΠᵗᵛ : ∀ {A B A' B' rA Γ} ([Γ] : ⊩ᵛ Γ) → let l = ∞ lΠ = ⁰ [UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ]) [UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ]) in ([A] : Γ ⊩ᵛ⟨ l ⟩ A ^ [ rA , ι lΠ ] / [Γ]) ([A'] : Γ ⊩ᵛ⟨ l ⟩ A' ^ [ rA , ι lΠ ] / [Γ]) ([UB] : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A]) ([UB'] : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A']) ([A]ₜ : Γ ⊩ᵛ⟨ l ⟩ A ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA]) ([B]ₜ : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A] / (λ {Δ} {σ} → [UB] {Δ} {σ})) ([A']ₜ : Γ ⊩ᵛ⟨ l ⟩ A' ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA]) ([B']ₜ : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B' ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'] / (λ {Δ} {σ} → [UB'] {Δ} {σ})) → [ Γ ⊩ᵛ⟨ l ⟩ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰)) ≡ ∃ (Id (Univ rA ⁰) A A') ▹ (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰) ((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (U.wk (lift (step id)) B') ° ¹ ° ¹) ∷ SProp ¹ ^ [ ! , next ¹ ] / [Γ] ] Id-U-ΠΠᵗᵛ {A} {B} {A'} {B'} {rA} {Γ} [Γ] [A] [A'] [UB] [UB'] [A]ₜ [B]ₜ [A']ₜ [B']ₜ = let l = ∞ lΠ = ⁰ [SProp] = Uᵛ {rU = %} ∞< [Γ] [UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ]) [UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ]) ⊢AΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A]ₜ ⊢Δ [σ])) ⊢A'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A']ₜ ⊢Δ [σ])) ⊢A = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A] {Δ} {σ} ⊢Δ [σ])) ⊢A' = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A'] {Δ} {σ} ⊢Δ [σ])) [ΓA] = (_∙_ {Γ} {A} [Γ] [A]) [ΓA'] = (_∙_ {Γ} {A'} [Γ] [A']) ⊢BΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B]ₜ {Δ} {σ} ⊢Δ [σ])) [A]' = univᵛ {A = A} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']' = univᵛ {A = A'} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A']ₜ [B]' = univᵛ {A = B} [ΓA] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB] {Δ} {σ}) [B]ₜ [B] = maybeEmbᵛ {A = B} [ΓA] [B]' [B']' = univᵛ {A = B'} [ΓA'] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [B']ₜ [B'] = maybeEmbᵛ {A = B'} [ΓA'] [B']' ⊢B'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB'] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B']ₜ {Δ} {σ} ⊢Δ [σ])) [liftσ] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A] [σ] [liftσ'] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A'} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A'] [σ] [ΠAB] = Πᵗᵛ {A} {B} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A] (λ {Δ} {σ} → [UB] {Δ} {σ}) [A]ₜ [B]ₜ [ΠA'B'] = Πᵗᵛ {A'} {B'} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A']ₜ [B']ₜ [IdAA']ₜ = Idᵗᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ (Uᵗᵛ [Γ]) [IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ Id-U-ΠΠ-res A A' B B' = ∃ (Id (Univ rA ⁰) A A') ▹ (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰) ((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (U.wk (lift (step id)) B') ° ¹ ° ¹) [ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [wSProp] = Uᵛ {rU = %} ∞< [ΓId] [wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ [wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A'] [wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A] [wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ [ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']' [wwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓIdA'] {Δ} {σ} [wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ} [ΓIdA] = _∙_ {A = wk1 A} [ΓId] [wA]' [wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA'] [wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA] [wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']' [wwA]' = wk1ᵛ {A = wk1 A} {F = wk1 A'} [ΓId] [wA']' [wA]' [wwU0A] = maybeEmbᵛ {A = Univ ! _ } [ΓIdA] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA] {Δ} {σ}) [wB'] = wk1dᵗᵛ {F = A'} {F' = Id (Univ rA ⁰) A A'} {G = B'} [Γ] [A'] [IdAA'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) [B']ₜ [wB] = wk1dᵗᵛ {F = A} {F' = Id (Univ rA ⁰) A A'} {G = B} [Γ] [A] [IdAA'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [wwU0A] {Δ} {σ}) [B]ₜ [wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA'] [wwIdA'A] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A')} {u = wk1 (wk1 A)} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA] [var0]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 0 ∷ wk1 (wk1 A') ^ [ rA , ι ⁰ ] / [ΓIdA'] / [wwA']' [var0]ₜ = proj₂ (fundamentalVar here [ΓIdA']) [var1]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 1 ∷ Id (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) ^ [ % , ι ¹ ] / [ΓIdA'] / [wwIdAA'] [var1]ₜ = let X = fundamentalVar (there here) [ΓIdA'] in S.irrelevanceTerm {A = Id (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A'))} {t = var 1} [ΓIdA'] [ΓIdA'] (proj₁ X) [wwIdAA'] (proj₂ X) [Id-U-ΠΠ-res] : Γ ⊩ᵛ⟨ ∞ ⟩ Id-U-ΠΠ-res A A' B B' ∷ SProp ¹ ^ [ ! , ∞ ] / [Γ] / [SProp] [Id-U-ΠΠ-res] = ∃ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰) ((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (U.wk (lift (step id)) B') ° ¹ ° ¹)} [Γ] [IdAA'] (λ {Δ} {σ} → [wSProp] {Δ} {σ}) [IdAA']ₜ (Id-U-ΠΠ-resᵗᵛ {A} {B} {A'} {B'} [Γ] [A] [A'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A]ₜ [B]ₜ [A']ₜ [B']ₜ [var0]ₜ [var1]ₜ) [Id-U-ΠΠ] : Γ ⊩ᵛ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰) ⇒ Id-U-ΠΠ-res A A' B B' ∷ SProp ¹ ^ ∞ / [Γ] [Id-U-ΠΠ] = λ {Δ} {σ} ⊢Δ [σ] → let Aσ = ⊢AΔ {Δ} {σ} ⊢Δ [σ] Bσ = ⊢BΔ {Δ ∙ subst σ A ^ _} {liftSubst σ} (⊢Δ ∙ ⊢A {Δ} {σ} ⊢Δ [σ]) ([liftσ] {Δ} {σ} ⊢Δ [σ]) A'σ = ⊢A'Δ {Δ} {σ} ⊢Δ [σ] B'σ = ⊢B'Δ {Δ ∙ subst σ A' ^ _} {liftSubst σ} (⊢Δ ∙ ⊢A' {Δ} {σ} ⊢Δ [σ]) ([liftσ'] {Δ} {σ} ⊢Δ [σ]) X : Δ ⊢ Id (U ⁰) (Π (subst σ A) ^ rA ° ⁰ ▹ (subst (liftSubst σ) B) ° ⁰ ° ⁰) (Π (subst σ A') ^ rA ° ⁰ ▹ (subst (liftSubst σ) B') ° ⁰ ° ⁰) ⇒ Id-U-ΠΠ-res (subst σ A) (subst σ A') (subst (liftSubst σ) B) (subst (liftSubst σ) B') ∷ SProp ¹ ^ ∞ X = Id-U-ΠΠ {Δ} {subst σ A} {subst σ A'} {rA} {subst (liftSubst σ) B} {subst (liftSubst σ) B'} Aσ Bσ A'σ B'σ in PE.subst (λ BB → Δ ⊢ Id (U ⁰) (Π (subst σ A) ^ rA ° ⁰ ▹ (subst (liftSubst σ) B) ° ⁰ ° ⁰) (Π (subst σ A') ^ rA ° ⁰ ▹ (subst (liftSubst σ) B') ° ⁰ ° ⁰) ⇒ BB ∷ SProp ¹ ^ ∞ ) (PE.cong₃ (λ X Y Z → ∃ Id (Univ rA ⁰) (subst σ A) (subst σ A') ▹ Π X ^ rA ° ⁰ ▹ Id (U ⁰) Y Z ° ¹ ° ¹) ((PE.sym (Idsym-subst-lemma σ A'))) (lemma1 A A' B) (lemma2 B')) X [id] , [eq] = redSubstTermᵛ {SProp ¹} {Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰)} {Id-U-ΠΠ-res A A' B B'} [Γ] [Id-U-ΠΠ] (λ {Δ} {σ} → [SProp] {Δ} {σ}) [Id-U-ΠΠ-res] in modelsTermEq [SProp] [id] [Id-U-ΠΠ-res] [eq]
{ "alphanum_fraction": 0.4002208247, "avg_line_length": 75.7490909091, "ext": "agda", "hexsha": "adf1903088ea88ed8968ff8744acd82741d0ba80", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdUPiPi.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "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": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdUPiPi.agda", "max_line_length": 192, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdUPiPi.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 10807, "size": 20831 }
module GUIgeneric.GUIModel where open import GUIgeneric.Prelude renaming (inj₁ to secondButton; inj₂ to firstButton; WxColor to Color) hiding (IOInterfaceˢ) open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) --; ComponentEls to Frame) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib open import StateSizedIO.writingOOsUsingIOVers4ReaderMethods open import StateSizedIO.Base open import GUIgeneric.GUIExample -- hiding (HandlerGUIObject) open IOInterfaceˢ public open import Data.Product -- How many trivial io commands such as putStrLn are ignored in the model skippedIOcmds : ℕ skippedIOcmds = 2 data MethodStarted (f : Frame) (prop : properties f) (obj : HandlerObject ∞ f) : Set where notStarted : MethodStarted f prop obj started : (m : methodsG f) (pr : IO' GuiLev1Interface ∞ StateAndGuiObj) → MethodStarted f prop obj data ModelGuiState : Set where state : (f : Frame) (prop : properties f) (obj : HandlerObject ∞ f) (m : MethodStarted f prop obj) → ModelGuiState modelGuiCommand : (s : ModelGuiState) → Set modelGuiCommand (state g prop obj notStarted) = methodsG g modelGuiCommand (state g prop obj (started m (do' c f))) = GuiLev1Response c modelGuiCommand (state g prop obj (started m (return' a))) = ⊤ -- modelGuiResponse : Set -- modelGuiResponse = ⊤ handlerReturnTypeToStateAndGuiObj : (g : Frame) (prop : properties g) (obj : HandlerObject ∞ g) (res : Σ[ r ∈ returnType g ] IOObjectˢ GuiLev1Interface handlerInterface ∞ (nextStateFrame g r)) → StateAndGuiObj handlerReturnTypeToStateAndGuiObj g prop obj (noChange , obj') = g , prop , obj' handlerReturnTypeToStateAndGuiObj g prop obj (changedAttributes prop' , obj') = g , prop' , obj' handlerReturnTypeToStateAndGuiObj g prop obj (changedGUI g' prop' , obj') = g' , prop' , obj' modelGuiNextProgramStarted : (g : Frame) (prop : properties g) (obj : HandlerObject ∞ g) (m : methodsG g) → IO GuiLev1Interface ∞ StateAndGuiObj modelGuiNextProgramStarted g prop obj m = fmap ∞ (handlerReturnTypeToStateAndGuiObj g prop obj ) (obj .method m) modelGuiNextProgramStarted' : (g : Frame) (prop : properties g) (obj : HandlerObject ∞ g) (m : methodsG g) → IO' GuiLev1Interface ∞ StateAndGuiObj modelGuiNextProgramStarted' s prop obj m = force (modelGuiNextProgramStarted s prop obj m) modelGuiNextaux : (g : Frame)(prop : properties g)(obj : HandlerObject ∞ g) (m : methodsG g)(pr : IO' GuiLev1Interface ∞ StateAndGuiObj) (skippedCms : ℕ) → ModelGuiState modelGuiNextaux g prop obj m (do' (putStrLn s) f) (suc n) = modelGuiNextaux g prop obj m (force (f _)) n modelGuiNextaux g prop obj m (do' c' f) n = state g prop obj (started m (do' c' f)) modelGuiNextaux g prop obj m (return' (gNew , propNew , objNew)) n = state gNew propNew objNew notStarted modelGuiNext : (s : ModelGuiState) (c : modelGuiCommand s) → ModelGuiState modelGuiNext (state g prop obj notStarted) m = modelGuiNextaux g prop obj m (modelGuiNextProgramStarted' g prop obj m) skippedIOcmds modelGuiNext (state g prop obj (started m (do' c' f))) c = modelGuiNextaux g prop obj m (force (f c)) skippedIOcmds modelGuiNext (state g prop obj (started m (return' (gNew , propNew , objNew)))) c = state gNew propNew objNew notStarted modelGuiInterface : IOInterfaceˢ IOStateˢ modelGuiInterface = ModelGuiState Commandˢ modelGuiInterface = modelGuiCommand Responseˢ modelGuiInterface s m = ⊤ IOnextˢ modelGuiInterface s m r = modelGuiNext s m _-gui->_ : (s s' : ModelGuiState ) → Set s -gui-> s' = IOˢindₚ modelGuiInterface ⊤ s s' data _-gui->¹_ (s : ModelGuiState ) : (s' : ModelGuiState)→ Set where step : (c : modelGuiCommand s) → s -gui->¹ modelGuiNext s c nextGui : (s : ModelGuiState)(c : modelGuiCommand s) → ModelGuiState nextGui s c = modelGuiNext s c modelToIOprog : (s : ModelGuiState) → Maybe (IO' GuiLev1Interface ∞ StateAndGuiObj) modelToIOprog (state g prop obj notStarted) = nothing modelToIOprog (state g prop obj (started s pr)) = just pr nextGuiProg : (s : ModelGuiState)(c : modelGuiCommand s) → Maybe (IO' GuiLev1Interface ∞ StateAndGuiObj) nextGuiProg s c = modelToIOprog (nextGui s c)
{ "alphanum_fraction": 0.6348547718, "avg_line_length": 39.1869918699, "ext": "agda", "hexsha": "38c116a2d7b253dbe09365e987de665dc8145e6c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "examples/GUIgeneric/GUIModel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "stephanadls/state-dependent-gui", "max_issues_repo_path": "examples/GUIgeneric/GUIModel.agda", "max_line_length": 123, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "examples/GUIgeneric/GUIModel.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 1332, "size": 4820 }
open import Coinduction using ( ∞ ; ♭ ; ♯_ ) open import Data.Bool using ( Bool ; true ; false ) open import Data.Nat using ( ℕ ; zero ; suc ) open import Data.Natural using ( Natural ; # ; % ; _+_ ) open import Data.Strict using ( Strict ; ! ) open import System.IO.Transducers.List using ( S⊆S&*T ) open import System.IO.Transducers.Lazy using ( _⇒_ ; inp ; out ; done ; out* ; _[&]_ ; _⟫_ ) open import System.IO.Transducers.Session using ( I ; Σ ; ⟨_⟩ ; _&_ ; ¿ ; * ; _&*_ ) open import System.IO.Transducers.Trace using ( [] ; _∷_ ; _≤_ ) module System.IO.Transducers.Stateful where -- We apply the usual state transformer construction -- for a premonoial category: morphisms -- from T to U with state S are just regular morphisms -- from T & S to U & S. -- We are particularly interested in the case where T is I -- and S is Bytes, since this collapses to Bytes ⇒ U & Bytes, -- that is, the type for a parser over a byte stream. -- The type Bytes ⇒ U & Bytes (or more generally * ⟨ B ⟩ ⇒ U & * ⟨ B ⟩) -- is the type of an iteratee returning U. -- Lookahead. -- Lookahead buffers up all input until some output is produced. -- If the output is (just x), then we discard the buffer, and -- continue with the process. If the output is nothing, then we -- return the buffer to the output stream and discard the process. lookahead¿' : ∀ {T S S'} → (S' ≤ S) → (S' ⇒ ¿ T & S) → (S' ⇒ ¿ T & S) lookahead¿' {T} as (inp F) = inp (♯ λ a → lookahead¿' {T} (a ∷ as) (♭ F a)) lookahead¿' {T} as (out true P) = out true P lookahead¿' {T} as (out false P) = out false (out* as done) lookahead¿' {T} as (done) = inp (♯ λ a → lookahead¿' {T} (a ∷ as) (out a done)) lookahead¿ : ∀ {T S} → (S ⇒ ¿ T & S) → (S ⇒ ¿ T & S) lookahead¿ {T} = lookahead¿' {T} [] lookahead*' : ∀ {T S S'} → (S' ≤ S) → (S' ⇒ * T & S) → (S' ⇒ * T & S) lookahead*' {T} as (inp F) = inp (♯ λ a → lookahead*' {T} (a ∷ as) (♭ F a)) lookahead*' {T} as (out true P) = out true P lookahead*' {T} as (out false P) = out false (out* as done) lookahead*' {T} as (done) = inp (♯ λ a → lookahead*' {T} (a ∷ as) (out a done)) lookahead* : ∀ {T S} → (S ⇒ * T & S) → (S ⇒ * T & S) lookahead* {T} = lookahead*' {T} [] -- Iteration structure. -- Deep breath. -- This is the trickiest bit of building a stateful transducer -- library. The idea is to turn a stateful transducer generating -- an optional U into a stateful transducer generating many Us. -- We transform the transducer P into one which runs P, then -- if P returns nothing, then loop P returns nothing and terminates, and -- if P returns (just x), then loop P finishes running P, then runs loop P again. -- For example, given a function nat? : ℤ → (Maybe ℕ) which -- such that nat? n = nothing if n < 0 and just n otherwise, -- we can define: -- loop (lookahead (inp (♯ λ n → out (nat? n) done))) : -- * ⟨ ℤ ⟩ ⇒ * ⟨ ℕ ⟩ & * ⟨ ℤ ⟩ -- This transducer will return the longest non-negative prefix -- of its input, for example on input just 2 ∷ just 5 ∷ just -3 ∷ ... -- it will produce output just 2 ∷ just 5 ∷ nothing ∷ just -3 ∷ ... mutual -- This is a remarkably obscure piece of code, given that all its doing is wiring... -- The n : ℕ parameter is the induction scheme that gets it all to pass the -- termination checker. When loop P is used properly, it is with a contracting -- P, that is one which produces stricly fewer S tokens than it consumes. -- Without the n parameter, loop P could produce infinite output if P isn't -- contracting. For example loop (out (just x) done) would just produce the stream -- (just x) ∷ (just x) ∷ ... without ever consuming any input. With the n parameter -- we keep track of how many tokens have been consumed. If we ever hit -- a loop where n==0, we just run P one last time, then terminate. -- For example, loop (out (just x) done) just produces the trace (just x) ∷ []. -- For efficiency, we also pass n around as a Natural, not just an ℕ. When we -- read input a, we add the weight of a onto n, strictly (in order to -- avoid potentially keeping a live), discard the previous ℕ and build a new ℕ. -- It would be nice to have an induction scheme for Natural. -- It would be a bit nicer to track statically which processes are contractions, -- and only allow loop P on contraction maps. -- Note that contractions come up in many contexts with treatments of recursion, -- for example in Plotkin uniformity, they're called strict maps. They're -- closely related to the notion of guarded recursion which is used in checking -- productivity of coinductive functions in Agda. -- TODO: Find a way to statically enforce contraction and non-expansion maps. -- Or alternatively, give in and allow coinductive output, -- and hence lose termination for transducers. -- TODO: Present this as a trace structure? Show that -- it has the expected properties on contracting morphisms. -- loop''' 0 P Q R is equivant to P ⟫ Q ⟫ (done ⟨&⟩ loop R) loop'''' : ∀ {T T' U S S'} → (Strict Natural) → (U ⇒ S) → (S ⇒ T' & S') → (S' ⇒ ¿ T & S') → (U ⇒ (T' &* T) & S') loop'''' {T} {T'} (! n) P Q R = loop''' {T} {T'} (% n) n P Q R loop''' : ∀ {T T' U S S'} → ℕ → Natural → (U ⇒ S) → (S ⇒ T' & S') → (S' ⇒ ¿ T & S') → (U ⇒ (T' &* T) & S') loop''' {T} {I} m n P Q R = loop' {T} m n (P ⟫ Q) R R loop''' {T} {Σ V F} {Σ W G} m n (inp P) (inp Q) R = inp (♯ λ a → loop'''' {T} {Σ V F} (! (n + W a)) (♭ P a) (inp Q) R) loop''' {T} {Σ V F} m n (out a P) (inp Q) R = loop''' {T} {Σ V F} m n P (♭ Q a) R loop''' {T} {Σ V F} {Σ W G} m n done (inp P) R = inp (♯ λ a → loop'''' {T} {Σ V F} (! (n + W a)) done (♭ P a) R) loop''' {T} {Σ V F} m n P (out b Q) R = out b (loop''' {T} {♭ F b} m n P Q R) loop''' {T} {Σ V F} {Σ W G} m n (inp P) done R = inp (♯ λ a → loop'''' {T} {Σ V F} (! (n + W a)) (♭ P a) done R) loop''' {T} {Σ V F} m n (out a P) done R = out a (loop''' {T} {♭ F a} m n P done R) loop''' {T} {Σ V F} m n done done R = inp (♯ λ a → out a (loop'''' {T} {♭ F a} (! (n + (V a))) done done R)) -- loop' 0 P Q R is equivalent to P ⟫ Q ⟫ loop R ⟨¿⟩ done loop'' : ∀ {T U S S'} → (Strict Natural) → (U ⇒ S) → (S ⇒ ¿ T & S') → (S' ⇒ ¿ T & S') → (U ⇒ * T & S') loop'' {T} (! n) P Q R = loop' {T} (% n) n P Q R loop' : ∀ {T U S S'} → ℕ → Natural → (U ⇒ S) → (S ⇒ ¿ T & S') → (S' ⇒ ¿ T & S') → (U ⇒ * T & S') loop' {T} {Σ V F} m n (inp P) (inp Q) R = inp (♯ λ a → loop'' {T} (! (n + V a)) (♭ P a) (inp Q) R) loop' {T} m n (out a P) (inp Q) R = loop' {T} m n P (♭ Q a) R loop' {T} {Σ V F} m n done (inp Q) R = inp (♯ λ a → loop'' {T} (! (n + V a)) done (♭ Q a) R) loop' {T} zero n P (out true Q) R = out true (P ⟫ Q ⟫ S⊆S&*T {T} [&] done) loop' {T} (suc m) n P (out true Q) R = out true (loop''' {T} {T} m n P Q R) loop' {T} m n P (out false Q) R = out false (P ⟫ Q) loop' {T} {Σ V F} m n (inp P) done R = inp (♯ λ a → loop'' {T} (! (n + V a)) (♭ P a) done R) loop' {T} m n (out a P) done R = loop' {T} m n P (out a done) R loop' {T} m n done done R = inp (♯ λ a → loop'' {T} (! (n + # 1)) done (out a done) R) loop : ∀ {T S} → (S ⇒ ¿ T & S) → (S ⇒ * T & S) loop {T} P = loop' {T} zero (# 0) done P P
{ "alphanum_fraction": 0.5541392728, "avg_line_length": 54.0072463768, "ext": "agda", "hexsha": "371bd65767e27d996f6c68a5c791dee5ac766c37", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Transducers/Stateful.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Transducers/Stateful.agda", "max_line_length": 128, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Transducers/Stateful.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 2625, "size": 7453 }
open import Data.Product using (_×_; _,_) open import IMP open import OperationalSemantics open import Hoare soundness : ∀{P Q : assn} {c} → ⊢[ P ] c [ Q ] → ⊨[ P ] c [ Q ] soundness Skip p Skip = p soundness Loc p Loc = p soundness (Comp r r₁) p (Comp z z₁) = soundness r₁ (soundness r p z) z₁ soundness (If r r₁) p (IfTrue x s) = soundness r (p , x) s soundness (If r r₁) p (IfFalse x s) = soundness r₁ (p , x) s soundness (While r) p (WhileFalse x₁) = p , x₁ soundness (While r) p (WhileTrue x₁ s s₁) = soundness (While r) (soundness r (p , x₁) s) s₁ soundness (Conseq x₁ r x₂) {s₁} {t} p s = x₂ t (soundness r (x₁ s₁ p) s)
{ "alphanum_fraction": 0.62403698, "avg_line_length": 36.0555555556, "ext": "agda", "hexsha": "2c1f727eb6240566b5e7bb5cfd67d23865d31bcb", "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": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "iwilare/imp-semantics", "max_forks_repo_path": "HoareSoundness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "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": "iwilare/imp-semantics", "max_issues_repo_path": "HoareSoundness.agda", "max_line_length": 91, "max_stars_count": 6, "max_stars_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iwilare/imp-semantics", "max_stars_repo_path": "HoareSoundness.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-24T22:29:44.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-08T11:54:07.000Z", "num_tokens": 255, "size": 649 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Int where open import Cubical.Data.Int.Base public open import Cubical.Data.Int.Properties public
{ "alphanum_fraction": 0.7602339181, "avg_line_length": 24.4285714286, "ext": "agda", "hexsha": "1fadb65857dec9d53d70a4440e7a73c0f5e38541", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Int.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Int.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Int.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 39, "size": 171 }
-- Andreas, 2016-06-26 issue #2066, reported by Mietek Bak -- already fixed on stable-2.5 open import Data.Nat using (ℕ ; zero ; suc ; _≟_) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_ ; _≢_ ; refl) open import Relation.Nullary using (yes ; no) data Tm : Set where var : ℕ → Tm lam : ℕ → Tm → Tm app : Tm → Tm → Tm data _∥_ (x : ℕ) : Tm → Set where var∥ : ∀ {y} → y ≢ x → x ∥ var y ≡lam∥ : ∀ {t} → x ∥ lam x t ≢lam∥ : ∀ {y t} → x ∥ t → x ∥ lam y t app∥ : ∀ {t u} → x ∥ t → x ∥ u → x ∥ app t u _∥?_ : Decidable _∥_ x ∥? var y with y ≟ x x ∥? var .x | yes refl = no (λ { (var∥ x≢x) → x≢x refl }) x ∥? var y | no y≢x = yes (var∥ y≢x) x ∥? lam y t with y ≟ x | x ∥? t x ∥? lam .x t | yes refl | _ = yes ≡lam∥ x ∥? lam y t | no y≢x | yes x∥t = yes (≢lam∥ x∥t) x ∥? lam y t | no y≢x | no x∦t = no (λ { ≡lam∥ → {!!} ; (≢lam∥ p) → {!!} }) x ∥? app t u with x ∥? t | x ∥? u x ∥? app t u | yes x∥t | yes x∥u = yes (app∥ x∥t x∥u) x ∥? app t u | no x∦t | _ = no (λ { (app∥ x∥t x∥u) → x∦t x∥t }) x ∥? app t u | _ | no x∦u = no (λ { (app∥ x∥t x∥u) → x∦u x∥u })
{ "alphanum_fraction": 0.4918032787, "avg_line_length": 36.21875, "ext": "agda", "hexsha": "25191e3f3b4440f542e68901969789ee671fb839", "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/lib-interaction/Issue2066.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/lib-interaction/Issue2066.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/lib-interaction/Issue2066.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": 591, "size": 1159 }