Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --cubical-compatible #-} -- Issue raised by Martin Escardo 2012-12-13 -- on the Agda list "no longer type checks" module WithoutKDisjointSum where open import Common.Equality data ⊥ : Set where data _⊎_ (A B : Set) : Set where inl : A → A ⊎ B inr : B → A ⊎ B distinct : {A B : Set} (a : A) (b : B) → inl a ≡ inr b → ⊥ distinct a b ()
{ "alphanum_fraction": 0.6242937853, "avg_line_length": 22.125, "ext": "agda", "hexsha": "9aad5ba84d664535f8ca53e35bd0c6f0c906d8f8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/WithoutKDisjointSum.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/WithoutKDisjointSum.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/WithoutKDisjointSum.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 129, "size": 354 }
{-# OPTIONS --without-K --rewriting #-} open import PathInduction using (Type; _==_; idp; Square; !; _∙_; Coh; path-induction) module ExPathInduction {i} where {-<excoh>-} coh : {A : Type i} {a : A} → Coh ({b : A} (p : a == b) {d : A} {s : d == b} {c : A} {r : b == c} {f : A} {u : f == c} {e : A} {t : e == c} {w : f == e} (ν : Square w idp t u) {v : d == e} (α : Square v s t r) {vw : d == f} (vw= : vw == v ∙ ! w) → Square (p ∙ ! s) p vw (r ∙ ! u)) coh = path-induction {-</>-}
{ "alphanum_fraction": 0.3820033956, "avg_line_length": 29.45, "ext": "agda", "hexsha": "1e1d60e8f2af70b0b80f70ae0909908f74476641", "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": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guillaumebrunerie/JamesConstruction", "max_forks_repo_path": "ExPathInduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "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": "guillaumebrunerie/JamesConstruction", "max_issues_repo_path": "ExPathInduction.agda", "max_line_length": 86, "max_stars_count": 5, "max_stars_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guillaumebrunerie/JamesConstruction", "max_stars_repo_path": "ExPathInduction.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-16T22:10:16.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-07T04:34:52.000Z", "num_tokens": 221, "size": 589 }
module exec-tc.empty where
{ "alphanum_fraction": 0.8148148148, "avg_line_length": 13.5, "ext": "agda", "hexsha": "2a8463b91d9f52dabc7d48484a67b78206096e3b", "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/exec-tc/empty.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/exec-tc/empty.agda", "max_line_length": 26, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/exec-tc/empty.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": 7, "size": 27 }
open import Prelude hiding (subst; module Fin) module Implicits.Substitutions.Lemmas.MetaType where open import Implicits.Syntax.Type open import Implicits.Syntax.Term hiding (var) open import Implicits.Syntax.Context open import Implicits.WellTyped open import Implicits.Substitutions open import Data.Vec hiding ([_]) open import Data.Fin as Fin using () open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Vec.Properties open import Data.Nat.Properties.Simple open import Extensions.Substitution open import Relation.Binary.HeterogeneousEquality as H using () private module HR = H.≅-Reasoning module MetaTypeTypeLemmas where open MetaTypeTypeSubst hiding (_/✶_) open import Implicits.Syntax.MetaType open import Data.Star private module V = VarLemmas module _ {m : ℕ} where MT : ℕ → Set MT = MetaType m open MetaTypeApp hiding (_/_) module _ {T₁ T₂} {lift₁ : MetaLift T₁} {lift₂ : MetaLift T₂} where open Lifted {m} lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_) open Lifted {m} lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_) /✶-↑✶ : ∀ {n n'} (ρs₁ : Subs (T₁ m) n n') (ρs₂ : Subs (T₂ m) n n') → (∀ k x → (simpl (tvar x)) /✶₁ ρs₁ ↑✶₁ k ≡ (simpl (tvar x)) /✶₂ ρs₂ ↑✶₂ k) → ∀ k t → t /✶₁ ρs₁ ↑✶₁ k ≡ t /✶₂ ρs₂ ↑✶₂ k /✶-↑✶ ρs₁ ρs₂ hyp k (a ⇒ b) = begin (a ⇒ b) /✶₁ ρs₁ ↑✶₁ k ≡⟨ ⇒-/✶-↑✶ lift₁ k ρs₁ ⟩ ((a /✶₁ ρs₁ ↑✶₁ k) ⇒ (b /✶₁ ρs₁ ↑✶₁ k)) ≡⟨ cong₂ _⇒_ (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩ (a /✶₂ ρs₂ ↑✶₂ k) ⇒ (b /✶₂ ρs₂ ↑✶₂ k) ≡⟨ sym (⇒-/✶-↑✶ lift₂ k ρs₂) ⟩ (a ⇒ b) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (∀' t) = begin (∀' t) /✶₁ ρs₁ ↑✶₁ k ≡⟨ ∀'-/✶-↑✶ lift₁ k ρs₁ ⟩ ∀' (t /✶₁ ρs₁ ↑✶₁ (suc k)) ≡⟨ cong ∀' (/✶-↑✶ ρs₁ ρs₂ hyp (suc k) t) ⟩ ∀' (t /✶₂ ρs₂ ↑✶₂ (suc k)) ≡⟨ sym $ ∀'-/✶-↑✶ lift₂ k ρs₂ ⟩ (∀' t) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tvar c)) = hyp k c /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (mvar x)) = begin (simpl (mvar x)) /✶₁ ρs₁ ↑✶₁ k ≡⟨ mvar-/✶-↑✶ lift₁ k ρs₁ ⟩ (simpl (mvar x)) ≡⟨ sym $ mvar-/✶-↑✶ lift₂ k ρs₂ ⟩ (simpl (mvar x)) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (a →' b)) = begin (simpl (a →' b)) /✶₁ ρs₁ ↑✶₁ k ≡⟨ →'-/✶-↑✶ lift₁ k ρs₁ ⟩ simpl ((a /✶₁ ρs₁ ↑✶₁ k) →' (b /✶₁ ρs₁ ↑✶₁ k)) ≡⟨ cong₂ (λ a b → simpl (a →' b)) (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩ simpl ((a /✶₂ ρs₂ ↑✶₂ k) →' (b /✶₂ ρs₂ ↑✶₂ k)) ≡⟨ sym (→'-/✶-↑✶ lift₂ k ρs₂) ⟩ (simpl (a →' b)) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tc c)) = begin (simpl (tc c)) /✶₁ ρs₁ ↑✶₁ k ≡⟨ tc-/✶-↑✶ lift₁ k ρs₁ ⟩ (simpl (tc c)) ≡⟨ sym $ tc-/✶-↑✶ lift₂ k ρs₂ ⟩ (simpl (tc c)) /✶₂ ρs₂ ↑✶₂ k ∎ lemmas₃ : Lemmas₃ (MetaType m) lemmas₃ = record { lemmas₂ = record { lemmas₁ = record { lemmas₀ = record { simple = simple } ; weaken-var = λ {_ x} → begin (simpl (tvar x)) /Var V.wk ≡⟨ refl ⟩ (simpl (tvar (lookup x V.wk))) ≡⟨ cong (λ x → simpl (tvar x)) (V.lookup-wk x) ⟩ (simpl (tvar (suc x))) ∎ } ; application = Subst.application subst ; var-/ = refl } ; /✶-↑✶ = /✶-↑✶ } private module L₃ = Lemmas₃ lemmas₃ lemmas₅ : Lemmas₅ (MetaType m) lemmas₅ = record { lemmas₄ = record { lemmas₃ = lemmas₃ ; /-wk = λ {_ t} → begin t / wk ≡⟨ /✶-↑✶ (ε ▻ wk) (ε ▻ V.wk) (λ k x → begin (simpl (tvar x)) / wk ↑⋆ k ≡⟨ L₃.var-/-wk-↑⋆ k x ⟩ (simpl (tvar (Fin.lift k suc x))) ≡⟨ cong (λ x → (simpl (tvar x))) (sym (V.var-/-wk-↑⋆ k x)) ⟩ (simpl (tvar (lookup x (V._↑⋆_ V.wk k)))) ≡⟨ refl ⟩ (simpl (tvar x)) /Var V._↑⋆_ V.wk k ∎) zero t ⟩ t /Var V.wk ≡⟨ refl ⟩ weaken t ∎ } } open Lemmas₅ lemmas₅ public hiding (lemmas₃) module MetaTypeMetaLemmas where open MetaTypeMetaSubst using (module Lifted; MetaLift) open import Implicits.Syntax.MetaType open import Data.Star as Star hiding (map) open import Data.Star.Properties private module V = VarLemmas module MetaTypeAppLemmas {T} (l : MetaLift T) where open Lifted l →'-/✶-↑✶ : ∀ k {ν n n' a b} (ρs : Subs (flip T ν) n n') → (simpl (a →' b)) /✶ ρs ↑✶ k ≡ simpl ((a /✶ ρs ↑✶ k) →' (b /✶ ρs ↑✶ k)) →'-/✶-↑✶ k ε = refl →'-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (→'-/✶-↑✶ k ρs) refl ⇒-/✶-↑✶ : ∀ k {ν n n' a b} (ρs : Subs (flip T ν) n n') → (a ⇒ b) /✶ ρs ↑✶ k ≡ (a /✶ ρs ↑✶ k) ⇒ (b /✶ ρs ↑✶ k) ⇒-/✶-↑✶ k ε = refl ⇒-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (⇒-/✶-↑✶ k ρs) refl tc-/✶-↑✶ : ∀ k {ν c n n'} (ρs : Subs (flip T ν) n n') → (simpl (tc c)) /✶ ρs ↑✶ k ≡ simpl (tc c) tc-/✶-↑✶ k ε = refl tc-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (tc-/✶-↑✶ k ρs) refl tvar-/✶-↑✶ : ∀ k {ν n n' c} (ρs : Subs (flip T ν) n n') → (simpl (tvar c)) /✶ ρs ↑✶ k ≡ simpl (tvar c) tvar-/✶-↑✶ k ε = refl tvar-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (tvar-/✶-↑✶ k ρs) refl tpweaken-subs : ∀ {ν n n'} (ρs : Subs (flip T ν) n n') → Subs (flip T (suc ν)) n n' tpweaken-subs ρs = Star.map (λ x → x ↑tp) ρs comm-↑-↑tp : ∀ {ν n n'} (s : Sub (flip T ν) n n') → (s ↑) ↑tp ≡ (s ↑tp) ↑ comm-↑-↑tp s = begin (s ↑) ↑tp ≡⟨ refl ⟩ map tpweaken (var zero ∷ map weaken s) ≡⟨ refl ⟩ (tpweaken (var zero)) ∷ (map tpweaken (map weaken s)) ≡⟨ cong₂ (λ x xs → x ∷ xs) (tpweaken-var zero) (sym $ map-∘ tpweaken weaken s) ⟩ (var zero) ∷ (map (tpweaken ∘ weaken) s) ≡⟨ cong (λ u → var zero ∷ u) (sym $ map-cong comm-weaken-tpweaken s) ⟩ (var zero) ∷ (map (weaken ∘ tpweaken) s) ≡⟨ cong (λ u → (var zero) ∷ u) (map-∘ weaken tpweaken s) ⟩ (s ↑tp) ↑ ∎ comm-↑⋆-↑tp : ∀ k {ν n n'} (s : Sub (flip T ν) n n') → (s ↑⋆ k) ↑tp ≡ (s ↑tp) ↑⋆ k comm-↑⋆-↑tp zero s = refl comm-↑⋆-↑tp (suc k) s = begin ((s ↑⋆ k) ↑) ↑tp ≡⟨ comm-↑-↑tp (s ↑⋆ k) ⟩ ((s ↑⋆ k) ↑tp) ↑ ≡⟨ cong _↑ (comm-↑⋆-↑tp k s) ⟩ (s ↑tp) ↑⋆ (suc k) ∎ comm-tpweaken-↑✶ : ∀ k {ν n n'} (ρs : Subs (flip T ν) n n') → (tpweaken-subs ρs) ↑✶ k ≡ tpweaken-subs (ρs ↑✶ k) comm-tpweaken-↑✶ k ρs = begin (tpweaken-subs ρs) ↑✶ k ≡⟨ refl ⟩ Star.gmap (_+_ k) (λ ρ → ρ ↑⋆ k) (Star.map _↑tp ρs) ≡⟨ gmap-∘ (_+_ k) (λ ρ₁ → ρ₁ ↑⋆ k) Prelude.id _↑tp ρs ⟩ Star.gmap (_+_ k) (λ ρ → (ρ ↑tp) ↑⋆ k) ρs ≡⟨ gmap-cong (_+_ k) (λ ρ₁ → _↑tp ρ₁ ↑⋆ k) (λ ρ₁ → _↑tp (ρ₁ ↑⋆ k)) (λ s → sym $ comm-↑⋆-↑tp k s) ρs ⟩ Star.gmap (_+_ k) (λ ρ → (ρ ↑⋆ k) ↑tp) ρs ≡⟨ sym $ gmap-∘ Prelude.id _↑tp (_+_ k) (λ ρ₁ → ρ₁ ↑⋆ k) ρs ⟩ Star.map _↑tp (Star.gmap (_+_ k) (λ ρ → ρ ↑⋆ k) ρs) ≡⟨ refl ⟩ tpweaken-subs (ρs ↑✶ k) ∎ ∀'-/✶-↑✶ : ∀ k {ν n n' a} (ρs : Subs (flip T ν) n n') → (∀' a) /✶ ρs ↑✶ k ≡ ∀' (a /✶ (tpweaken-subs ρs) ↑✶ k) ∀'-/✶-↑✶ k {a = a} ε = refl ∀'-/✶-↑✶ k {a = a} (x ◅ ρs) = begin (∀' a) /✶ (x ◅ ρs) ↑✶ k ≡⟨ cong (flip _/_ (x ↑⋆ k)) (∀'-/✶-↑✶ k ρs) ⟩ (∀' (a /✶ (tpweaken-subs ρs) ↑✶ k)) / (x ↑⋆ k) ≡⟨ cong (λ u → ∀' (a /✶ u / _↑tp (x ↑⋆ k))) (comm-tpweaken-↑✶ k ρs) ⟩ ∀' (a /✶ (tpweaken-subs ((x ◅ ρs) ↑✶ k))) ≡⟨ sym $ cong (λ u → ∀' (a /✶ u)) (comm-tpweaken-↑✶ k (x ◅ ρs)) ⟩ ∀' (a /✶ (tpweaken-subs (x ◅ ρs)) ↑✶ k) ∎ module _ where open MetaTypeTypeSubst using () renaming (weaken to mtt-weaken) private module MTT = MetaTypeTypeSubst {-}↑tp-mtt-weaken : ∀ {ν m n} x (s : Sub (flip T ν) m n) → (mtt-weaken x) / (s ↑tp) ≡ mtt-weaken (x / s)-} postulate ↑tp-mtt-weaken : ∀ {ν m n } k x (s : Sub (flip T ν) m n) → (x MTT./Var VarSubst.wk VarSubst.↑⋆ k) / (Prelude.subst (λ ν → Sub (flip T ν) m n) (sym $ +-suc k ν) (s ↑tp⋆ (suc k))) ≡ (x / (s ↑tp⋆ k)) MTT./Var VarSubst.wk VarSubst.↑⋆ k {- ↑tp-mtt-weaken k (a ⇒ b) s = cong₂ _⇒_ (↑tp-mtt-weaken k a s) (↑tp-mtt-weaken k b s) ↑tp-mtt-weaken {ν} {m} {n} k (∀' x) s = begin (∀' (x MTT./Var VarSubst.wk VarSubst.↑⋆ (suc k))) / (Prelude.subst (λ ν → Sub (flip T ν) m n) (sym $ +-suc k ν) (s ↑tp⋆ (suc k))) ≡⟨ refl ⟩ ∀' ((x MTT./Var VarSubst.wk VarSubst.↑⋆ (suc k)) / (Prelude.subst (λ ν → Sub (flip T ν) m n) (cong suc (sym $ +-suc k ν)) (s ↑tp⋆ (suc (suc k))))) ≡⟨ cong ∀' (↑tp-mtt-weaken (suc k) {!!} {!!}) ⟩ (∀' ((x / (s ↑tp⋆ (suc k))) MTT./Var VarSubst.wk VarSubst.↑⋆ (suc k))) ≡⟨ refl ⟩ (∀' (x / (s ↑tp⋆ (suc k)))) MTT./Var VarSubst.wk VarSubst.↑⋆ k ≡⟨ refl ⟩ (∀' x / s ↑tp⋆ k) MTT./Var VarSubst.wk VarSubst.↑⋆ k ∎ ↑tp-mtt-weaken k (simpl (tvar x)) s = refl ↑tp-mtt-weaken k (simpl (mvar x)) s = {!!} ↑tp-mtt-weaken k (simpl (a →' b)) s = cong₂ (λ u v → simpl (u →' v)) (↑tp-mtt-weaken k a s) (↑tp-mtt-weaken k b s) ↑tp-mtt-weaken k (simpl (tc x)) s = refl -} tpweaken-subs-var : ∀ {ν n n'} x (ρs : Subs (flip T ν) n n') → (simpl (mvar x)) /✶ (tpweaken-subs ρs) ≡ mtt-weaken ((simpl (mvar x)) /✶ ρs) tpweaken-subs-var x ε = refl tpweaken-subs-var x (s ◅ ρs) = begin (simpl (mvar x)) /✶ (Star.map _↑tp (s ◅ ρs)) ≡⟨ refl ⟩ (simpl (mvar x)) /✶ (tpweaken-subs ρs) / (s ↑tp) ≡⟨ cong (flip _/_ (_↑tp s)) (tpweaken-subs-var x ρs) ⟩ (mtt-weaken ((simpl (mvar x)) /✶ ρs)) / (s ↑tp) ≡⟨ ↑tp-mtt-weaken zero (simpl (mvar x) /✶ ρs) s ⟩ mtt-weaken ((simpl (mvar x)) /✶ (s ◅ ρs)) ∎ module _ {T₁ T₂} {lift₁ : MetaLift T₁} {lift₂ : MetaLift T₂} where open MetaTypeTypeSubst using () renaming (weaken to mtt-weaken) open Lifted lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_; _↑tp to _↑tp₁) open Lifted lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_; _↑tp to _↑tp₂) open MetaTypeAppLemmas weaken-hyp : ∀ {ν n n'} (ρs₁ : Subs (flip T₁ ν) n n') (ρs₂ : Subs (flip T₂ ν) n n') → (∀ k x → (simpl (mvar x)) /✶₁ ρs₁ ↑✶₁ k ≡ (simpl (mvar x)) /✶₂ ρs₂ ↑✶₂ k) → (∀ k x → (simpl (mvar x)) /✶₁ (tpweaken-subs lift₁ ρs₁) ↑✶₁ k ≡ (simpl (mvar x)) /✶₂ (tpweaken-subs lift₂ ρs₂) ↑✶₂ k) weaken-hyp ρs₁ ρs₂ hyp k x = begin simpl (mvar x) /✶₁ (tpweaken-subs lift₁ ρs₁) ↑✶₁ k ≡⟨ cong (λ u → simpl (mvar x) /✶₁ u) (comm-tpweaken-↑✶ lift₁ k ρs₁) ⟩ simpl (mvar x) /✶₁ tpweaken-subs lift₁ (ρs₁ ↑✶₁ k) ≡⟨ tpweaken-subs-var lift₁ x (ρs₁ ↑✶₁ k) ⟩ mtt-weaken (simpl (mvar x) /✶₁ (ρs₁ ↑✶₁ k)) ≡⟨ cong mtt-weaken (hyp k x) ⟩ mtt-weaken (simpl (mvar x) /✶₂ (ρs₂ ↑✶₂ k)) ≡⟨ sym $ tpweaken-subs-var lift₂ x (ρs₂ ↑✶₂ k) ⟩ simpl (mvar x) /✶₂ tpweaken-subs lift₂ (ρs₂ ↑✶₂ k) ≡⟨ cong (λ u → simpl (mvar x) /✶₂ u) (sym $ comm-tpweaken-↑✶ lift₂ k ρs₂) ⟩ simpl (mvar x) /✶₂ (tpweaken-subs lift₂ ρs₂) ↑✶₂ k ∎ /✶-↑✶ : ∀ {ν n n'} (ρs₁ : Subs (flip T₁ ν) n n') (ρs₂ : Subs (flip T₂ ν) n n') → (∀ k x → (simpl (mvar x)) /✶₁ ρs₁ ↑✶₁ k ≡ (simpl (mvar x)) /✶₂ ρs₂ ↑✶₂ k) → ∀ k t → t /✶₁ ρs₁ ↑✶₁ k ≡ t /✶₂ ρs₂ ↑✶₂ k /✶-↑✶ ρs₁ ρs₂ hyp k (a ⇒ b) = begin (a ⇒ b) /✶₁ ρs₁ ↑✶₁ k ≡⟨ ⇒-/✶-↑✶ lift₁ k ρs₁ ⟩ ((a /✶₁ ρs₁ ↑✶₁ k) ⇒ (b /✶₁ ρs₁ ↑✶₁ k)) ≡⟨ cong₂ _⇒_ (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩ (a /✶₂ ρs₂ ↑✶₂ k) ⇒ (b /✶₂ ρs₂ ↑✶₂ k) ≡⟨ sym (⇒-/✶-↑✶ lift₂ k ρs₂) ⟩ (a ⇒ b) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (∀' t) = begin (∀' t) /✶₁ ρs₁ ↑✶₁ k ≡⟨ ∀'-/✶-↑✶ lift₁ k ρs₁ ⟩ (∀' (t /✶₁ (tpweaken-subs lift₁ ρs₁) ↑✶₁ k)) ≡⟨ cong ∀' (/✶-↑✶ (tpweaken-subs lift₁ ρs₁) (tpweaken-subs lift₂ ρs₂) (weaken-hyp ρs₁ ρs₂ hyp) k t ) ⟩ (∀' (t /✶₂ (tpweaken-subs lift₂ ρs₂) ↑✶₂ k)) ≡⟨ sym $ ∀'-/✶-↑✶ lift₂ k ρs₂ ⟩ (∀' t) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (mvar c)) = hyp k c /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tvar x)) = begin (simpl (tvar x)) /✶₁ ρs₁ ↑✶₁ k ≡⟨ tvar-/✶-↑✶ lift₁ k ρs₁ ⟩ (simpl (tvar x)) ≡⟨ sym $ tvar-/✶-↑✶ lift₂ k ρs₂ ⟩ (simpl (tvar x)) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (a →' b)) = begin (simpl (a →' b)) /✶₁ ρs₁ ↑✶₁ k ≡⟨ →'-/✶-↑✶ lift₁ k ρs₁ ⟩ simpl ((a /✶₁ ρs₁ ↑✶₁ k) →' (b /✶₁ ρs₁ ↑✶₁ k)) ≡⟨ cong₂ (λ a b → simpl (a →' b)) (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩ simpl ((a /✶₂ ρs₂ ↑✶₂ k) →' (b /✶₂ ρs₂ ↑✶₂ k)) ≡⟨ sym (→'-/✶-↑✶ lift₂ k ρs₂) ⟩ (simpl (a →' b)) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tc c)) = begin (simpl (tc c)) /✶₁ ρs₁ ↑✶₁ k ≡⟨ tc-/✶-↑✶ lift₁ k ρs₁ ⟩ (simpl (tc c)) ≡⟨ sym $ tc-/✶-↑✶ lift₂ k ρs₂ ⟩ (simpl (tc c)) /✶₂ ρs₂ ↑✶₂ k ∎ module _ {ν : ℕ} where open MetaTypeMetaSubst MT : ℕ → Set MT = flip MetaType ν lemmas₃ : Lemmas₃ (flip MetaType ν) lemmas₃ = record { lemmas₂ = record { lemmas₁ = record { lemmas₀ = record { simple = simple } ; weaken-var = λ {_ x} → begin (simpl (mvar x)) /Var V.wk ≡⟨ refl ⟩ (simpl (mvar (lookup x V.wk))) ≡⟨ cong (λ x → simpl (mvar x)) (V.lookup-wk x) ⟩ (simpl (mvar (suc x))) ∎ } ; application = Subst.application subst ; var-/ = refl } ; /✶-↑✶ = /✶-↑✶ } private module L₃ = Lemmas₃ lemmas₃ lemmas₅ : Lemmas₅ (flip MetaType ν) lemmas₅ = record { lemmas₄ = record { lemmas₃ = lemmas₃ ; /-wk = λ {_ t} → begin t / wk ≡⟨ /✶-↑✶ (ε ▻ wk) (ε ▻ V.wk) (λ k x → begin (simpl (mvar x)) / wk ↑⋆ k ≡⟨ L₃.var-/-wk-↑⋆ k x ⟩ (simpl (mvar (Fin.lift k suc x))) ≡⟨ cong (λ x → (simpl (mvar x))) (sym (V.var-/-wk-↑⋆ k x)) ⟩ (simpl (mvar (lookup x (V._↑⋆_ V.wk k)))) ≡⟨ refl ⟩ (simpl (mvar x)) /Var V._↑⋆_ V.wk k ∎) zero t ⟩ t /Var V.wk ≡⟨ refl ⟩ weaken t ∎ } } open Lemmas₅ lemmas₅ public hiding (lemmas₃) open MetaTypeMetaSubst using (open-meta-k; open-meta; _↑⋆tp_; _↑tp; _◁m; _◁m₁) us↑-⊙-sub-u≡u∷us : ∀ {ν m} (u : MetaType zero ν) (us : Sub (flip MetaType ν) m zero) → us ↑ ⊙ sub u ≡ u ∷ us us↑-⊙-sub-u≡u∷us {ν} {m} u us = cong (λ v → u ∷ v) map-weaken-⊙-sub open-mvar : ∀ {ν m} (x : Fin m) → open-meta {ν = ν} (simpl (mvar x)) ≡ simpl (mvar (suc x)) open-mvar x = weaken-var open-tvar-suc : ∀ {ν m} (x : Fin m) → open-meta {ν} (simpl (tvar (suc x))) ≡ simpl (tvar x) open-tvar-suc x = MetaTypeTypeLemmas.suc-/-sub {t = (simpl (tvar x))} open import Implicits.Substitutions.Type as TS using () open import Implicits.Substitutions.Lemmas.Type as TSLemmas using () private module MTT = MetaTypeTypeSubst
{ "alphanum_fraction": 0.4299630086, "avg_line_length": 42.0207253886, "ext": "agda", "hexsha": "0660a8cfdfc52b6dfd4d319ed0887d574624a828", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Substitutions/Lemmas/MetaType.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Substitutions/Lemmas/MetaType.agda", "max_line_length": 141, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Substitutions/Lemmas/MetaType.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": 7554, "size": 16220 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Setoids.Setoids open import Setoids.Functions.Definition open import Sets.EquivalenceRelations module Setoids.Functions.Extension where ExtensionallyEqual : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {f g : A → B} (fWd : WellDefined S T f) (gWd : WellDefined S T g) → Set (a ⊔ d) ExtensionallyEqual {A = A} {T = T} {f = f} {g = g} fWD gWD = (∀ {x : A} → Setoid._∼_ T (f x) (g x)) extensionallyEqualReflexive : {a b c d : _} {A : Set a} {B : Set b} (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f : A → B) (fWD1 fWD2 : WellDefined S T f) → ExtensionallyEqual {S = S} {T} fWD1 fWD2 extensionallyEqualReflexive S T f fWD1 _ = Equivalence.reflexive (Setoid.eq T) extensionallyEqualSymmetric : {a b c d : _} {A : Set a} {B : Set b} (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f g : A → B) (fWD : WellDefined S T f) (gWD : WellDefined S T g) → ExtensionallyEqual {S = S} {T = T} fWD gWD → ExtensionallyEqual {S = S} {T} gWD fWD extensionallyEqualSymmetric S T f g fWD gWD pr = Equivalence.symmetric (Setoid.eq T) pr extensionallyEqualTransitive : {a b c d : _} {A : Set a} {B : Set b} (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f g h : A → B) (fWD : WellDefined S T f) (gWD : WellDefined S T g) (hWD : WellDefined S T h) → ExtensionallyEqual {S = S} {T} fWD gWD → ExtensionallyEqual {S = S} {T} gWD hWD → ExtensionallyEqual {S = S} {T} fWD hWD extensionallyEqualTransitive S T f g h fWD gWD hWD pr1 pr2 = Equivalence.transitive (Setoid.eq T) pr1 pr2
{ "alphanum_fraction": 0.6397285626, "avg_line_length": 77.1904761905, "ext": "agda", "hexsha": "49fd828ed96a317251cf8799a76a5abd216ca989", "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": "Setoids/Functions/Extension.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": "Setoids/Functions/Extension.agda", "max_line_length": 331, "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": "Setoids/Functions/Extension.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": 639, "size": 1621 }
{-# OPTIONS --without-K --safe #-} open import Level using (Level) open import Data.Nat using (ℕ) renaming (_+_ to _+ᴺ_) open import Data.Vec using (Vec; _++_; take; drop; replicate; map; foldr) open import Data.Vec.Properties open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Function using (id) open import FLA.Algebra.Structures open import FLA.Algebra.Properties.Field open import FLA.Algebra.LinearMap open import FLA.Algebra.LinearAlgebra open import FLA.Algebra.LinearAlgebra.Properties open import FLA.Data.Vec.Properties module FLA.Algebra.LinearAlgebra.Matrix where private variable ℓ : Level A : Set ℓ m n p q : ℕ ------------------------------------------------------------------------------- -- M constructor and values -- ------------------------------------------------------------------------------- data Mat_×_ {A : Set ℓ} ⦃ F : Field A ⦄ (m n : ℕ) : Set ℓ where ⟦_,_,_⟧ : (M : n ⊸ m ) → (Mᵀ : m ⊸ n ) → (p : (x : Vec A m) → (y : Vec A n) → ⟨ x , M ·ˡᵐ y ⟩ ≡ ⟨ y , Mᵀ ·ˡᵐ x ⟩ ) → Mat m × n module _ ⦃ F : Field A ⦄ where _ᵀ : Mat m × n → Mat n × m ⟦ f , a , p ⟧ ᵀ = ⟦ a , f , (λ x y → sym (p y x)) ⟧ _·ᴹₗ_ : Mat m × n → Vec A n → Vec A m ⟦ f , _ , _ ⟧ ·ᴹₗ x = f ·ˡᵐ x _·ᴹᵣ_ : Vec A m → Mat m × n → Vec A n x ·ᴹᵣ ⟦ _ , a , _ ⟧ = a ·ˡᵐ x infixr 20 _·ᴹᵣ_ infixr 21 _·ᴹₗ_ infixl 25 _ᵀ module _ ⦃ F : Field A ⦄ where open Field F open _⊸_ _+ᴹ_ : Mat m × n → Mat m × n → Mat m × n ⟦ M₁ , M₁ᵀ , p₁ ⟧ +ᴹ ⟦ M₂ , M₂ᵀ , p₂ ⟧ = ⟦ M₁ +ˡᵐ M₂ , M₁ᵀ +ˡᵐ M₂ᵀ , ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ p₁ p₂ ⟧ where ⟨⟩-proof : (M₁ M₂ : n ⊸ m) (M₁ᵀ M₂ᵀ : m ⊸ n) → (M₁-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M₁ ·ˡᵐ y ⟩ ≡ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ ) → (M₂-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M₂ ·ˡᵐ y ⟩ ≡ ⟨ y , M₂ᵀ ·ˡᵐ x ⟩ ) → (x : Vec A m) (y : Vec A n) → ⟨ x , (M₁ +ˡᵐ M₂) ·ˡᵐ y ⟩ ≡ ⟨ y , (M₁ᵀ +ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ M₁-proof M₂-proof x y = begin ⟨ x , (M₁ +ˡᵐ M₂) ·ˡᵐ y ⟩ ≡⟨⟩ ⟨ x , M₁ ·ˡᵐ y +ⱽ M₂ ·ˡᵐ y ⟩ ≡⟨ ⟨x,y+z⟩≡⟨x,y⟩+⟨x,z⟩ x (M₁ ·ˡᵐ y) (M₂ ·ˡᵐ y) ⟩ ⟨ x , M₁ ·ˡᵐ y ⟩ + ⟨ x , M₂ ·ˡᵐ y ⟩ ≡⟨ cong₂ _+_ (M₁-proof x y) (M₂-proof x y) ⟩ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + ⟨ y , M₂ᵀ ·ˡᵐ x ⟩ ≡⟨ sym (⟨x,y+z⟩≡⟨x,y⟩+⟨x,z⟩ y (M₁ᵀ ·ˡᵐ x) (M₂ᵀ ·ˡᵐ x)) ⟩ ⟨ y , (M₁ᵀ +ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ∎ _-ᴹ_ : Mat m × n → Mat m × n → Mat m × n ⟦ M₁ , M₁ᵀ , p₁ ⟧ -ᴹ ⟦ M₂ , M₂ᵀ , p₂ ⟧ = ⟦ M₁ -ˡᵐ M₂ , M₁ᵀ -ˡᵐ M₂ᵀ , ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ p₁ p₂ ⟧ where ⟨⟩-proof : (M₁ M₂ : n ⊸ m) (M₁ᵀ M₂ᵀ : m ⊸ n) → (M₁-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M₁ ·ˡᵐ y ⟩ ≡ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ ) → (M₂-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M₂ ·ˡᵐ y ⟩ ≡ ⟨ y , M₂ᵀ ·ˡᵐ x ⟩ ) → (x : Vec A m) (y : Vec A n) → ⟨ x , (M₁ -ˡᵐ M₂) ·ˡᵐ y ⟩ ≡ ⟨ y , (M₁ᵀ -ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ M₁-proof M₂-proof x y = begin ⟨ x , (M₁ -ˡᵐ M₂) ·ˡᵐ y ⟩ ≡⟨⟩ ⟨ x , M₁ ·ˡᵐ y -ⱽ M₂ ·ˡᵐ y ⟩ ≡⟨ cong (λ a → ⟨ x , M₁ ·ˡᵐ y +ⱽ a ⟩) (-ⱽ≡-1ᶠ∘ⱽ (M₂ ·ˡᵐ y)) ⟩ ⟨ x , M₁ ·ˡᵐ y +ⱽ (- 1ᶠ) ∘ⱽ M₂ ·ˡᵐ y ⟩ ≡⟨ ⟨x,y+z⟩≡⟨x,y⟩+⟨x,z⟩ x (M₁ ·ˡᵐ y) ((- 1ᶠ) ∘ⱽ M₂ ·ˡᵐ y) ⟩ ⟨ x , M₁ ·ˡᵐ y ⟩ + ⟨ x , (- 1ᶠ) ∘ⱽ M₂ ·ˡᵐ y ⟩ ≡⟨ cong (λ a → ⟨ x , M₁ ·ˡᵐ y ⟩ + ⟨ x , a ⟩ ) (sym (f[c*v]≡c*f[v] M₂ (- 1ᶠ) y)) ⟩ ⟨ x , M₁ ·ˡᵐ y ⟩ + ⟨ x , (M₂ ·ˡᵐ ((- 1ᶠ) ∘ⱽ y)) ⟩ ≡⟨ cong₂ _+_ (M₁-proof x y) (M₂-proof x ((- 1ᶠ) ∘ⱽ y)) ⟩ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + ⟨ (- 1ᶠ) ∘ⱽ y , M₂ᵀ ·ˡᵐ x ⟩ ≡⟨⟩ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + sum ( ((- 1ᶠ) ∘ⱽ y) *ⱽ M₂ᵀ ·ˡᵐ x ) ≡⟨ cong (λ a → ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + sum a) (sym (∘ⱽ*ⱽ-assoc (- 1ᶠ) y (M₂ᵀ ·ˡᵐ x))) ⟩ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + sum ((- 1ᶠ) ∘ⱽ (y *ⱽ M₂ᵀ ·ˡᵐ x)) ≡⟨ cong (λ a → ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + sum a) (sym (*ⱽ∘ⱽ≡∘ⱽ*ⱽ (- 1ᶠ) y (M₂ᵀ ·ˡᵐ x))) ⟩ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + sum (y *ⱽ ((- 1ᶠ) ∘ⱽ M₂ᵀ ·ˡᵐ x)) ≡⟨⟩ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ + ⟨ y , (- 1ᶠ) ∘ⱽ M₂ᵀ ·ˡᵐ x ⟩ ≡˘⟨ ⟨x,y+z⟩≡⟨x,y⟩+⟨x,z⟩ y (M₁ᵀ ·ˡᵐ x) ((- 1ᶠ) ∘ⱽ M₂ᵀ ·ˡᵐ x) ⟩ ⟨ y , M₁ᵀ ·ˡᵐ x +ⱽ (- 1ᶠ) ∘ⱽ M₂ᵀ ·ˡᵐ x ⟩ ≡˘⟨ cong (λ a → ⟨ y , M₁ᵀ ·ˡᵐ x +ⱽ a ⟩) (-ⱽ≡-1ᶠ∘ⱽ (M₂ᵀ ·ˡᵐ x)) ⟩ ⟨ y , (M₁ᵀ -ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ∎ _*ᴹ_ : Mat m × n → Mat n × p → Mat m × p ⟦ M₁ , M₁ᵀ , p₁ ⟧ *ᴹ ⟦ M₂ , M₂ᵀ , p₂ ⟧ = ⟦ M₁ *ˡᵐ M₂ , M₂ᵀ *ˡᵐ M₁ᵀ , ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ p₁ p₂ ⟧ where ⟨⟩-proof : (M₁ : n ⊸ m) (M₂ : p ⊸ n) (M₁ᵀ : m ⊸ n) (M₂ᵀ : n ⊸ p) → (M₁-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M₁ ·ˡᵐ y ⟩ ≡ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ ) → (M₂-⟨⟩-proof : (x : Vec A n) (y : Vec A p) → ⟨ x , M₂ ·ˡᵐ y ⟩ ≡ ⟨ y , M₂ᵀ ·ˡᵐ x ⟩ ) → (x : Vec A m) (y : Vec A p) → ⟨ x , (M₁ *ˡᵐ M₂) ·ˡᵐ y ⟩ ≡ ⟨ y , (M₂ᵀ *ˡᵐ M₁ᵀ) ·ˡᵐ x ⟩ ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ M₁-proof M₂-proof x y = begin ⟨ x , (M₁ *ˡᵐ M₂) ·ˡᵐ y ⟩ ≡⟨⟩ ⟨ x , M₁ ·ˡᵐ M₂ ·ˡᵐ y ⟩ ≡⟨ M₁-proof x (M₂ ·ˡᵐ y) ⟩ ⟨ M₂ ·ˡᵐ y , M₁ᵀ ·ˡᵐ x ⟩ ≡⟨ ⟨⟩-comm (M₂ ·ˡᵐ y) (M₁ᵀ ·ˡᵐ x) ⟩ ⟨ M₁ᵀ ·ˡᵐ x , M₂ ·ˡᵐ y ⟩ ≡⟨ M₂-proof (M₁ᵀ ·ˡᵐ x) y ⟩ ⟨ y , (M₂ᵀ *ˡᵐ M₁ᵀ) ·ˡᵐ x ⟩ ∎ _|ᴹ_ : Mat m × n → Mat m × p → Mat m × (n +ᴺ p) ⟦ M₁ , M₁ᵀ , p₁ ⟧ |ᴹ ⟦ M₂ , M₂ᵀ , p₂ ⟧ = ⟦ M₁ |ˡᵐ M₂ , M₁ᵀ —ˡᵐ M₂ᵀ , ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ p₁ p₂ ⟧ where ⟨⟩-proof : {m n p : ℕ} → (M₁ : n ⊸ m) (M₂ : p ⊸ m) (M₁ᵀ : m ⊸ n) (M₂ᵀ : m ⊸ p) → (M₁-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M₁ ·ˡᵐ y ⟩ ≡ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ ) → (M₂-⟨⟩-proof : (x : Vec A m) (y : Vec A p) → ⟨ x , M₂ ·ˡᵐ y ⟩ ≡ ⟨ y , M₂ᵀ ·ˡᵐ x ⟩ ) → (x : Vec A m) (y : Vec A (n +ᴺ p)) → ⟨ x , (M₁ |ˡᵐ M₂) ·ˡᵐ y ⟩ ≡ ⟨ y , (M₁ᵀ —ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ⟨⟩-proof {m} {n} {p} M₁ M₂ M₁ᵀ M₂ᵀ M₁-proof M₂-proof x y = begin ⟨ x , (M₁ |ˡᵐ M₂) ·ˡᵐ y ⟩ ≡⟨⟩ ⟨ x , M₁ ·ˡᵐ take n y +ⱽ M₂ ·ˡᵐ drop n y ⟩ ≡⟨ ⟨x,y+z⟩≡⟨x,y⟩+⟨x,z⟩ x (M₁ ·ˡᵐ take n y) (M₂ ·ˡᵐ drop n y) ⟩ ⟨ x , M₁ ·ˡᵐ take n y ⟩ + ⟨ x , M₂ ·ˡᵐ drop n y ⟩ ≡⟨ cong₂ _+_ (M₁-proof x (take n y)) (M₂-proof x (drop n y)) ⟩ ⟨ take n y , M₁ᵀ ·ˡᵐ x ⟩ + ⟨ drop n y , M₂ᵀ ·ˡᵐ x ⟩ ≡⟨ ⟨a,b⟩+⟨c,d⟩≡⟨a++c,b++d⟩ (take n y) (M₁ᵀ ·ˡᵐ x) (drop n y) (M₂ᵀ ·ˡᵐ x) ⟩ ⟨ take n y ++ drop n y , M₁ᵀ ·ˡᵐ x ++ M₂ᵀ ·ˡᵐ x ⟩ ≡⟨ cong (λ a → ⟨ a , M₁ᵀ ·ˡᵐ x ++ M₂ᵀ ·ˡᵐ x ⟩) (take-drop-id n y) ⟩ ⟨ y , M₁ᵀ ·ˡᵐ x ++ M₂ᵀ ·ˡᵐ x ⟩ ≡⟨⟩ ⟨ y , (M₁ᵀ —ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ∎ _—ᴹ_ : Mat m × p → Mat n × p → Mat (m +ᴺ n) × p M —ᴹ N = (M ᵀ |ᴹ N ᵀ) ᵀ -- Block diagonal matrix _/ᴹ_ : Mat m × n → Mat p × q → Mat (m +ᴺ p) × (n +ᴺ q) ⟦ M₁ , M₁ᵀ , p₁ ⟧ /ᴹ ⟦ M₂ , M₂ᵀ , p₂ ⟧ = ⟦ M₁ /ˡᵐ M₂ , M₁ᵀ /ˡᵐ M₂ᵀ , ⟨⟩-proof M₁ M₂ M₁ᵀ M₂ᵀ p₁ p₂ ⟧ where ⟨⟩-proof : {m n p q : ℕ} → (M₁ : n ⊸ m) (M₂ : q ⊸ p) (M₁ᵀ : m ⊸ n) (M₂ᵀ : p ⊸ q) → (M₁-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M₁ ·ˡᵐ y ⟩ ≡ ⟨ y , M₁ᵀ ·ˡᵐ x ⟩ ) → (M₂-⟨⟩-proof : (x : Vec A p) (y : Vec A q) → ⟨ x , M₂ ·ˡᵐ y ⟩ ≡ ⟨ y , M₂ᵀ ·ˡᵐ x ⟩ ) → (x : Vec A (m +ᴺ p)) (y : Vec A (n +ᴺ q)) → ⟨ x , (M₁ /ˡᵐ M₂) ·ˡᵐ y ⟩ ≡ ⟨ y , (M₁ᵀ /ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ⟨⟩-proof {m} {n} {p} M₁ M₂ M₁ᵀ M₂ᵀ M₁-proof M₂-proof x y = begin ⟨ x , (M₁ /ˡᵐ M₂) ·ˡᵐ y ⟩ ≡⟨⟩ ⟨ x , M₁ ·ˡᵐ take n y ++ M₂ ·ˡᵐ drop n y ⟩ ≡⟨ cong (λ x → ⟨ x , M₁ ·ˡᵐ take n y ++ M₂ ·ˡᵐ drop n y ⟩) (sym (take-drop-id m x)) ⟩ ⟨ take m x ++ drop m x , M₁ ·ˡᵐ (take n y) ++ M₂ ·ˡᵐ drop n y ⟩ ≡⟨ ⟨a++b,c++d⟩≡⟨a,c⟩+⟨b,d⟩ (take m x) (drop m x) (M₁ ·ˡᵐ (take n y)) (M₂ ·ˡᵐ drop n y) ⟩ ⟨ take m x , M₁ ·ˡᵐ (take n y) ⟩ + ⟨ drop m x , M₂ ·ˡᵐ drop n y ⟩ ≡⟨ cong₂ _+_ (M₁-proof (take m x) (take n y)) (M₂-proof (drop m x) (drop n y)) ⟩ ⟨ take n y , M₁ᵀ ·ˡᵐ take m x ⟩ + ⟨ drop n y , M₂ᵀ ·ˡᵐ drop m x ⟩ ≡⟨ ⟨a,b⟩+⟨c,d⟩≡⟨a++c,b++d⟩ (take n y) (M₁ᵀ ·ˡᵐ take m x) (drop n y) (M₂ᵀ ·ˡᵐ drop m x) ⟩ ⟨ take n y ++ drop n y , M₁ᵀ ·ˡᵐ take m x ++ M₂ᵀ ·ˡᵐ drop m x ⟩ ≡⟨ cong (λ y → ⟨ y , M₁ᵀ ·ˡᵐ take m x ++ M₂ᵀ ·ˡᵐ drop m x ⟩) (take-drop-id n y) ⟩ ⟨ y , M₁ᵀ ·ˡᵐ (take m x) ++ M₂ᵀ ·ˡᵐ (drop m x) ⟩ ≡⟨⟩ ⟨ y , (M₁ᵀ /ˡᵐ M₂ᵀ) ·ˡᵐ x ⟩ ∎ -- Multiply by a constant _∘ᴹ_ : A → Mat m × n → Mat m × n c ∘ᴹ ⟦ M , Mᵀ , p ⟧ = ⟦ c ∘ˡᵐ M , c ∘ˡᵐ Mᵀ , ⟨⟩-proof M Mᵀ c p ⟧ where ⟨⟩-proof : {m n : ℕ} (M : n ⊸ m) (Mᵀ : m ⊸ n) (c : A) → (M-⟨⟩-proof : (x : Vec A m) (y : Vec A n) → ⟨ x , M ·ˡᵐ y ⟩ ≡ ⟨ y , Mᵀ ·ˡᵐ x ⟩ ) → (x : Vec A m) (y : Vec A n) → ⟨ x , (c ∘ˡᵐ M) ·ˡᵐ y ⟩ ≡ ⟨ y , (c ∘ˡᵐ Mᵀ) ·ˡᵐ x ⟩ ⟨⟩-proof {m} {n} M Mᵀ c M-⟨⟩-proof x y = begin ⟨ x , (c ∘ˡᵐ M) ·ˡᵐ y ⟩ ≡⟨⟩ ⟨ x , c ∘ⱽ (M ·ˡᵐ y) ⟩ ≡⟨ cong (λ z → ⟨ x , z ⟩) (sym (f[c*v]≡c*f[v] M c y)) ⟩ ⟨ x , M ·ˡᵐ (c ∘ⱽ y) ⟩ ≡⟨ M-⟨⟩-proof x ((c ∘ⱽ y)) ⟩ ⟨ c ∘ⱽ y , Mᵀ ·ˡᵐ x ⟩ ≡⟨ ⟨⟩-comm (c ∘ⱽ y) (Mᵀ ·ˡᵐ x) ⟩ ⟨ Mᵀ ·ˡᵐ x , c ∘ⱽ y ⟩ ≡⟨ cong sum (trans (*ⱽ∘ⱽ≡∘ⱽ*ⱽ c (Mᵀ ·ˡᵐ x) y) (∘ⱽ*ⱽ-assoc c (Mᵀ ·ˡᵐ x) y)) ⟩ ⟨ (c ∘ˡᵐ Mᵀ) ·ˡᵐ x , y ⟩ ≡⟨ ⟨⟩-comm ((c ∘ˡᵐ Mᵀ) ·ˡᵐ x) y ⟩ ⟨ y , (c ∘ˡᵐ Mᵀ) ·ˡᵐ x ⟩ ∎ infixl 2 _—ᴹ_ infixl 3 _|ᴹ_ infixl 4 _/ᴹ_ infixl 6 _+ᴹ_ infixl 6 _-ᴹ_ infixl 7 _*ᴹ_ infixl 10 _∘ᴹ_ -- Matrix Free Operators ------------------------------------------------------ module _ ⦃ F : Field A ⦄ where open Field F I : Mat n × n I = ⟦ idₗₘ , idₗₘ , id-transpose ⟧ where id-transpose : (x y : Vec A n) → ⟨ x , id y ⟩ ≡ ⟨ y , id x ⟩ id-transpose x y rewrite zipWith-comm (*-comm) x y = refl diag : Vec A n → Mat n × n diag d = ⟦ diagₗₘ d , diagₗₘ d , diag-transpose d ⟧ where diag-transpose : (d : Vec A n) → (x y : Vec A n) → ⟨ x , diagₗₘ d ·ˡᵐ y ⟩ ≡ ⟨ y , diagₗₘ d ·ˡᵐ x ⟩ diag-transpose d x y = begin ⟨ x , diagₗₘ d ·ˡᵐ y ⟩ ≡⟨⟩ sum (x *ⱽ (d *ⱽ y)) ≡⟨ cong (sum) (*ⱽ-comm x (d *ⱽ y)) ⟩ sum ((d *ⱽ y) *ⱽ x) ≡⟨ cong (λ dy → sum (dy *ⱽ x)) (*ⱽ-comm d y) ⟩ sum ((y *ⱽ d) *ⱽ x) ≡⟨ cong sum (*ⱽ-assoc y d x) ⟩ sum (y *ⱽ (d *ⱽ x)) ≡⟨⟩ ⟨ y , diagₗₘ d ·ˡᵐ x ⟩ ∎ 1ᴹ : Mat m × n 1ᴹ = ⟦ 1ₗₘ , 1ₗₘ , 1ₗₘ-transpose ⟧ where zip-rep = zipWith-replicate₂ 1ₗₘ-transpose : (x : Vec A m) (y : Vec A n) → ⟨ x , 1ₗₘ ·ˡᵐ y ⟩ ≡ ⟨ y , 1ₗₘ ·ˡᵐ x ⟩ 1ₗₘ-transpose x y = begin ⟨ x , 1ₗₘ ·ˡᵐ y ⟩ ≡⟨⟩ sum (x *ⱽ replicate (sum y)) ≡⟨ cong sum (zip-rep _*_ x (sum y)) ⟩ sum (map (_* sum y) x) ≡⟨ cong sum (map-*c-≡c∘ⱽ (sum y) x) ⟩ sum (sum y ∘ⱽ x) ≡⟨ sum[c∘ⱽv]≡c*sum[v] (sum y) x ⟩ sum y * sum x ≡⟨ *-comm (sum y) (sum x) ⟩ sum x * sum y ≡˘⟨ sum[c∘ⱽv]≡c*sum[v] (sum x) y ⟩ sum (sum x ∘ⱽ y) ≡˘⟨ cong sum (map-*c-≡c∘ⱽ (sum x) y) ⟩ sum (map (_* sum x) y) ≡˘⟨ cong sum (zip-rep _*_ y (sum x)) ⟩ sum (y *ⱽ replicate (sum x)) ≡⟨⟩ ⟨ y , 1ₗₘ ·ˡᵐ x ⟩ ∎ 0ᴹ : Mat m × n 0ᴹ = ⟦ 0ₗₘ , 0ₗₘ , 0ₗₘ-transpose ⟧ where 0ₗₘ-transpose : (x : Vec A m) (y : Vec A n) → ⟨ x , 0ₗₘ ·ˡᵐ y ⟩ ≡ ⟨ y , 0ₗₘ ·ˡᵐ x ⟩ 0ₗₘ-transpose {m = m} {n = n} x y = begin ⟨ x , 0ₗₘ ·ˡᵐ y ⟩ ≡⟨⟩ sum (x *ⱽ replicate 0ᶠ) ≡⟨ cong sum (v*ⱽ0ᶠⱽ≡0ᶠⱽ x) ⟩ sum (replicate {n = m} 0ᶠ) ≡⟨ sum[0ᶠⱽ]≡0ᶠ {n = m} ⟩ 0ᶠ ≡˘⟨ sum[0ᶠⱽ]≡0ᶠ {n = n} ⟩ sum (replicate {n = n} 0ᶠ) ≡˘⟨ cong sum (v*ⱽ0ᶠⱽ≡0ᶠⱽ y) ⟩ sum (y *ⱽ replicate {n = n} 0ᶠ) ≡⟨⟩ ⟨ y , 0ₗₘ ·ˡᵐ x ⟩ ∎
{ "alphanum_fraction": 0.3592445173, "avg_line_length": 39.4246153846, "ext": "agda", "hexsha": "9bc23e429446db850ca84c1f77a6cdd77f7e83f3", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_path": "src/FLA/Algebra/LinearAlgebra/Matrix.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_path": "src/FLA/Algebra/LinearAlgebra/Matrix.agda", "max_line_length": 79, "max_stars_count": 21, "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_path": "src/FLA/Algebra/LinearAlgebra/Matrix.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "num_tokens": 7349, "size": 12813 }
{-# OPTIONS --without-K --safe #-} -- Any category can be made into a trivial restriction category module Categories.Category.Restriction.Construction.Trivial where open import Level using (Level) open import Categories.Category.Core using (Category) open import Categories.Category.Restriction using (Restriction) open import Categories.Morphism.Reasoning.Core using (id-comm-sym) private variable o ℓ e : Level Trivial : (C : Category o ℓ e) → Restriction C Trivial C = record { _↓ = λ _ → id ; pidʳ = identityʳ ; ↓-comm = Equiv.refl ; ↓-denestʳ = Equiv.sym identity² ; ↓-skew-comm = id-comm-sym C ; ↓-cong = λ _ → Equiv.refl } where open Category C
{ "alphanum_fraction": 0.7092511013, "avg_line_length": 25.2222222222, "ext": "agda", "hexsha": "1e2955d7e51f659cfa8a842b35c6c6c81c96b3fe", "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/Restriction/Construction/Trivial.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/Restriction/Construction/Trivial.agda", "max_line_length": 66, "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/Restriction/Construction/Trivial.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": 193, "size": 681 }
-- basic stuff: core definitions, etc open import statics-core open import statics-checks open import judgemental-erase open import moveerase open import examples -- first wave theorems open import sensibility open import aasubsume-min open import determinism -- second wave theorems (checksums) open import reachability open import constructability
{ "alphanum_fraction": 0.8267045455, "avg_line_length": 22, "ext": "agda", "hexsha": "72508ef6332ba0246b197dec3acd165a92c6383e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "statics-all.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "statics-all.agda", "max_line_length": 37, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "statics-all.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 83, "size": 352 }
{-# OPTIONS --cubical #-} module Multidimensional.Data.Dir.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Empty open import Cubical.Relation.Nullary open import Multidimensional.Data.Dir.Base ¬↓≡↑ : ¬ ↓ ≡ ↑ ¬↓≡↑ eq = subst (caseDir Dir ⊥) eq ↓ ¬↑≡↓ : ¬ ↑ ≡ ↓ ¬↑≡↓ eq = subst (caseDir ⊥ Dir) eq ↓
{ "alphanum_fraction": 0.6853333333, "avg_line_length": 18.75, "ext": "agda", "hexsha": "7825e907f08ea74cd46fd95dab6a8957f6c6c55e", "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": "55709dd950e319c4a105ace33ddaf8b955354add", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_forks_repo_path": "Multidimensional/Data/Dir/Properties.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_issues_repo_issues_event_max_datetime": "2019-07-02T16:24:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-19T20:40:07.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_issues_repo_path": "Multidimensional/Data/Dir/Properties.agda", "max_line_length": 49, "max_stars_count": null, "max_stars_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_stars_repo_path": "Multidimensional/Data/Dir/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 120, "size": 375 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Coproduct where -- Coproduct of categories. Need to pull out some of the combinators. -- Coproduct of Groupoid as well. open import Level open import Data.Sum open import Data.Empty open import Relation.Binary using (Rel) open import Function using (_$_) open import Categories.Category open import Categories.Category.Groupoid using (IsGroupoid) import Categories.Morphism as Morphism private variable o ℓ e o′ ℓ′ e′ : Level private _⊞_ : {a b c d r s : Level} {A : Set a} {B : Set b} {C : Set c} {D : Set d} (R : A → B → Set r) (S : C → D → Set s) → (A ⊎ C) → (B ⊎ D) → Set (r ⊔ s) _⊞_ {r = r} {s = s} R S = λ { (inj₁ x) (inj₁ x₁) → Lift (r ⊔ s) (R x x₁) ; (inj₁ x) (inj₂ y) → Lift (r ⊔ s) ⊥ ; (inj₂ y₁) (inj₁ x) → Lift (r ⊔ s) ⊥ ; (inj₂ y₁) (inj₂ y) → Lift (r ⊔ s) (S y₁ y) } _⊞Rel_ : {a b c d r s u v : Level} {A : Set a} {B : Set b} {C : Set c} {D : Set d} {R : A → B → Set r} {S : C → D → Set s} → ({a₁ : A} {b₁ : B} → Rel (R a₁ b₁) u) → ({c₁ : C} {d₁ : D} → Rel (S c₁ d₁) v) → ({x : A ⊎ C} {y : B ⊎ D} → Rel (_⊞_ R S x y) (u ⊔ v)) _⊞Rel_ {u = u} {v = v} R₁ R₂ {inj₁ x} {inj₁ x₁} p q = Lift (u ⊔ v) (R₁ (lower p) (lower q)) (R₁ ⊞Rel R₂) {inj₁ x} {inj₂ y} () () (R₁ ⊞Rel R₂) {inj₂ y₁} {inj₁ x} () () _⊞Rel_ {u = u} {v = v} R₁ R₂ {inj₂ y₁} {inj₂ y} p q = Lift (u ⊔ v) (R₂ (lower p) (lower q)) Coproduct : (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′) Coproduct C D = record { Obj = C.Obj ⊎ D.Obj ; _⇒_ = C._⇒_ ⊞ D._⇒_ ; _≈_ = C._≈_ ⊞Rel D._≈_ ; id = λ { {inj₁ _} → lift C.id ; {inj₂ _} → lift D.id } ; _∘_ = λ { {inj₁ x} {inj₁ x₁} {inj₁ x₂} → λ { (lift p) (lift q) → lift (p C.∘ q) } ; {inj₁ x} {inj₁ x₁} {inj₂ y} → λ () ; {inj₁ x} {inj₂ y} {inj₁ x₁} → λ () ; {inj₁ x} {inj₂ y} {inj₂ y₁} → λ _ () ; {inj₂ y} {inj₁ x} {inj₁ x₁} → λ _ () ; {inj₂ y} {inj₁ x} {inj₂ y₁} → λ () ; {inj₂ y} {inj₂ y₁} {inj₁ x} → λ () ; {inj₂ y} {inj₂ y₁} {inj₂ y₂} → λ { (lift p) (lift q) → lift (p D.∘ q) } } ; assoc = λ { {inj₁ x} {inj₁ x₁} {inj₁ x₂} {inj₁ x₃} → lift C.assoc ; {inj₂ y} {inj₂ y₁} {inj₂ y₂} {inj₂ y₃} → lift D.assoc} ; sym-assoc = λ { {inj₁ x} {inj₁ x₁} {inj₁ x₂} {inj₁ x₃} → lift C.sym-assoc ; {inj₂ y} {inj₂ y₁} {inj₂ y₂} {inj₂ y₃} → lift D.sym-assoc} ; identityˡ = λ { {inj₁ x} {inj₁ x₁} → lift C.identityˡ ; {inj₂ y} {inj₂ y₁} → lift D.identityˡ } ; identityʳ = λ { {inj₁ x} {inj₁ x₁} → lift C.identityʳ ; {inj₂ y} {inj₂ y₁} → lift D.identityʳ} ; identity² = λ { {inj₁ x} → lift C.identity² ; {inj₂ y} → lift D.identity² } ; equiv = λ { {inj₁ x} {inj₁ x₁} → record { refl = lift C.Equiv.refl ; sym = λ { (lift p) → lift $ C.Equiv.sym p } ; trans = λ { (lift p) (lift q) → lift $ C.Equiv.trans p q } } ; {inj₁ x} {inj₂ y} → record { refl = λ { {()} } ; sym = λ { {()} } ; trans = λ { {()} } } ; {inj₂ y} {inj₁ x} → record { refl = λ { {()} } ; sym = λ { {()} } ; trans = λ { {()} } } ; {inj₂ y} {inj₂ y₁} → record { refl = lift D.Equiv.refl ; sym = λ { (lift p) → lift $ D.Equiv.sym p } ; trans = λ { (lift p) (lift q) → lift $ D.Equiv.trans p q } } } ; ∘-resp-≈ = λ { {inj₁ x} {inj₁ x₁} {inj₁ x₂} → λ { (lift f≈h) (lift g≈i) → lift $ C.∘-resp-≈ f≈h g≈i } ; {inj₂ y} {inj₂ y₁} {inj₂ y₂} → λ { (lift f≈h) (lift g≈i) → lift $ D.∘-resp-≈ f≈h g≈i } } } where module C = Category C module D = Category D IsGroupoid-⊎ : {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → IsGroupoid C → IsGroupoid D → IsGroupoid (Coproduct C D) IsGroupoid-⊎ G₁ G₂ = record { _⁻¹ = λ { {inj₁ x} {inj₁ x₁} (lift f) → lift $ IsGroupoid._⁻¹ G₁ f ; {inj₂ y} {inj₂ y₁} (lift f) → lift $ IsGroupoid._⁻¹ G₂ f } ; iso = λ { {inj₁ x} {inj₁ x₁} {lift f} → record { isoˡ = lift $ Iso.isoˡ i₁ ; isoʳ = lift $ Iso.isoʳ i₁ } ; {inj₂ y} {inj₂ y₁} {lift f} → record { isoˡ = lift $ Iso.isoˡ i₂ ; isoʳ = lift $ Iso.isoʳ i₂ } } } where open Morphism i₁ = IsGroupoid.iso G₁ i₂ = IsGroupoid.iso G₂
{ "alphanum_fraction": 0.46401766, "avg_line_length": 43.9805825243, "ext": "agda", "hexsha": "d8a3eccee851474a2eba601d38398eb4665f19cc", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/Coproduct.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Construction/Coproduct.agda", "max_line_length": 118, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Construction/Coproduct.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": 1991, "size": 4530 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.EilenbergMacLane open import cohomology.Theory open import cohomology.SpectrumModel open import cohomology.WithCoefficients module cohomology.EMModel where module _ {i} (G : Group i) (G-abelian : is-abelian G) where open EMExplicit G G-abelian using (⊙EM; EM-level; EM-conn; spectrum) private E : (n : ℤ) → Ptd i E O = ⊙EM O E (pos m) = ⊙EM (S m) E (neg m) = ⊙Lift ⊙Unit E-spectrum : (n : ℤ) → ⊙Ω (E (succ n)) == E n E-spectrum O = spectrum O E-spectrum (pos n) = spectrum (S n) E-spectrum (neg O) = ⊙ua (equiv (λ _ → _) (λ _ → idp) (λ _ → idp) (prop-has-all-paths (EM-level _ _ _) _)) idp E-spectrum (neg (S n)) = ⊙ua (equiv (λ _ → _) (λ _ → idp) (λ _ → idp) (prop-has-all-paths (Lift-level Unit-is-set _ _) _)) idp EM-Cohomology : CohomologyTheory i EM-Cohomology = spectrum-cohomology E E-spectrum open CohomologyTheory EM-Cohomology EM-dimension : (n : ℤ) → n ≠ O → C n (⊙Sphere O) == 0ᴳ EM-dimension O neq = ⊥-rec (neq idp) EM-dimension (pos n) _ = contr-is-0ᴳ _ $ connected-at-level-is-contr (Trunc-level {n = ⟨0⟩}) (Trunc-preserves-conn ⟨0⟩ (transport (λ B → is-connected ⟨0⟩ B) (! (Bool⊙→-path _)) (path-conn (connected-≤T (⟨⟩-monotone-≤ (≤-ap-S (O≤ n))) (EM-conn (S n)))))) EM-dimension (neg O) _ = contr-is-0ᴳ _ $ Trunc-preserves-level ⟨0⟩ $ ⊙→-level $ inhab-prop-is-contr idp (EM-level O _ _) EM-dimension (neg (S n)) _ = contr-is-0ᴳ _ $ Trunc-preserves-level ⟨0⟩ $ ⊙→-level $ Lift-level Unit-is-prop _ _ EM-Ordinary : OrdinaryTheory i EM-Ordinary = ordinary-theory EM-Cohomology EM-dimension
{ "alphanum_fraction": 0.5799442897, "avg_line_length": 31.4912280702, "ext": "agda", "hexsha": "73391ce051c0775667b8a5a4c0dc136d06251307", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "cohomology/EMModel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "cohomology/EMModel.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "cohomology/EMModel.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 657, "size": 1795 }
import Lvl open import Type module Structure.Logic.Constructive.NaturalDeduction {ℓₗ} {Formula : Type{ℓₗ}} {ℓₘₗ} (Proof : Formula → Type{ℓₘₗ}) where open import Functional module Propositional where -- Rules of bottom record Bottom(⊥ : Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where field elim : ∀{X} → Proof(⊥) → Proof(X) -- Rules of top record Top(⊤ : Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where field intro : Proof(⊤) -- Rules of conjunction record Conjunction(_∧_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where field intro : ∀{X Y} → Proof(X) → Proof(Y) → Proof(X ∧ Y) elimₗ : ∀{X Y} → Proof(X ∧ Y) → Proof(X) elimᵣ : ∀{X Y} → Proof(X ∧ Y) → Proof(Y) redundancyₗ : ∀{X} → Proof(X ∧ X) ← Proof(X) redundancyₗ x = intro x x redundancyᵣ : ∀{X} → Proof(X ∧ X) → Proof(X) redundancyᵣ = elimₗ transitivity : ∀{X Y Z} → Proof(X ∧ Y) → Proof(Y ∧ Z) → Proof(X ∧ Z) transitivity xy yz = intro(elimₗ xy) (elimᵣ yz) commutativity : ∀{X Y} → Proof(X ∧ Y) → Proof(Y ∧ X) commutativity xy = intro(elimᵣ xy) (elimₗ xy) associativityₗ : ∀{X Y Z} → Proof((X ∧ Y) ∧ Z) ← Proof(X ∧ (Y ∧ Z)) associativityₗ xyz = intro (intro (elimₗ xyz) (elimₗ(elimᵣ xyz))) (elimᵣ(elimᵣ xyz)) associativityᵣ : ∀{X Y Z} → Proof((X ∧ Y) ∧ Z) → Proof(X ∧ (Y ∧ Z)) associativityᵣ xyz = intro (elimₗ(elimₗ xyz)) (intro (elimᵣ(elimₗ xyz)) (elimᵣ xyz)) -- Rules of implication record Implication(_⟶_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where field intro : ∀{X Y} → (Proof(X) → Proof(Y)) → Proof(X ⟶ Y) elim : ∀{X Y} → Proof(X ⟶ Y) → Proof(X) → Proof(Y) reflexivity : ∀{X} → Proof(X ⟶ X) reflexivity = intro id transitivity : ∀{X Y Z} → Proof(X ⟶ Y) → Proof(Y ⟶ Z) → Proof(X ⟶ Z) transitivity xy yz = intro((elim yz) ∘ (elim xy)) -- Rules of reversed implication record Consequence(_⟵_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where field intro : ∀{X Y} → (Proof(X) → Proof(Y)) → Proof(Y ⟵ X) elim : ∀{X Y} → Proof(Y ⟵ X) → Proof(X) → Proof(Y) reflexivity : ∀{X} → Proof(X ⟵ X) reflexivity = intro id transitivity : ∀{X Y Z} → Proof(X ⟵ Y) → Proof(Y ⟵ Z) → Proof(X ⟵ Z) transitivity xy yz = intro((elim xy) ∘ (elim yz)) -- Rules of equivalence record Equivalence(_⟷_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where field intro : ∀{X Y} → (Proof(X) ← Proof(Y)) → (Proof(X) → Proof(Y)) → Proof(X ⟷ Y) elimₗ : ∀{X Y} → Proof(X ⟷ Y) → Proof(Y) → Proof(X) elimᵣ : ∀{X Y} → Proof(X ⟷ Y) → Proof(X) → Proof(Y) reflexivity : ∀{X} → Proof(X ⟷ X) reflexivity = intro id id commutativity : ∀{X Y} → Proof(X ⟷ Y) → Proof(Y ⟷ X) commutativity xy = intro(elimᵣ xy) (elimₗ xy) transitivity : ∀{X Y Z} → Proof(X ⟷ Y) → Proof(Y ⟷ Z) → Proof(X ⟷ Z) transitivity xy yz = intro ((elimₗ xy) ∘ (elimₗ yz)) ((elimᵣ yz) ∘ (elimᵣ xy)) -- Rules of disjunction record Disjunction(_∨_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where field introₗ : ∀{X Y} → Proof(X) → Proof(X ∨ Y) introᵣ : ∀{X Y} → Proof(Y) → Proof(X ∨ Y) elim : ∀{X Y Z} → (Proof(X) → Proof(Z)) → (Proof(Y) → Proof(Z)) → Proof(X ∨ Y) → Proof(Z) redundancyₗ : ∀{X} → Proof(X ∨ X) ← Proof(X) redundancyₗ = introₗ redundancyᵣ : ∀{X} → Proof(X ∨ X) → Proof(X) redundancyᵣ = elim id id commutativity : ∀{X Y} → Proof(X ∨ Y) → Proof(Y ∨ X) commutativity = elim(introᵣ)(introₗ) associativityₗ : ∀{X Y Z} → Proof((X ∨ Y) ∨ Z) ← Proof(X ∨ (Y ∨ Z)) associativityₗ = elim(introₗ ∘ introₗ) (elim (introₗ ∘ introᵣ) (introᵣ)) associativityᵣ : ∀{X Y Z} → Proof((X ∨ Y) ∨ Z) → Proof(X ∨ (Y ∨ Z)) associativityᵣ = elim(elim (introₗ) (introᵣ ∘ introₗ)) (introᵣ ∘ introᵣ) -- Rules of negation record Negation(¬_ : Formula → Formula) {⊥} ⦃ _ : Bottom(⊥) ⦄ : Type{ℓₘₗ Lvl.⊔ ℓₗ} where open Bottom ⦃ ... ⦄ field intro : ∀{X} → (Proof(X) → Proof(⊥)) → Proof(¬ X) elim : ∀{X} → Proof(¬ X) → Proof(X) → Proof(⊥) record Signature : Type{ℓₗ} where infixl 1005 _∧_ infixl 1000 _⟶_ infixl 1000 _⟵_ infixl 1000 _⟷_ infixl 1004 _∨_ infixl 1010 ¬_ field ⊥ : Formula ⊤ : Formula _∧_ : Formula → Formula → Formula _⟶_ : Formula → Formula → Formula _⟷_ : Formula → Formula → Formula _∨_ : Formula → Formula → Formula ¬_ : Formula → Formula _⟵_ : Formula → Formula → Formula _⟵_ = swap _⟶_ -- A theory of constructive propositional logic expressed using natural deduction rules record Theory ⦃ sign : Signature ⦄ : Type{ℓₘₗ Lvl.⊔ ℓₗ} where open Signature(sign) field instance ⦃ bottom ⦄ : Bottom(⊥) instance ⦃ top ⦄ : Top(⊤) instance ⦃ conjunction ⦄ : Conjunction(_∧_) instance ⦃ disjunction ⦄ : Disjunction(_∨_) instance ⦃ implication ⦄ : Implication(_⟶_) instance ⦃ consequence ⦄ : Consequence(_⟵_) instance ⦃ equivalence ⦄ : Equivalence(_⟷_) instance ⦃ negation ⦄ : Negation(¬_) ⦃ bottom ⦄ module [⊥] = Bottom (bottom) module [⊤] = Top (top) module [∧] = Conjunction (conjunction) module [∨] = Disjunction (disjunction) module [→] = Implication (implication) module [←] = Consequence (consequence) module [↔] = Equivalence (equivalence) module [¬] = Negation (negation) module Domained {ℓₒ} (Domain : Type{ℓₒ}) where module Predicate where record UniversalQuantification(∀ₗ : (Domain → Formula) → Formula) : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where field intro : ∀{P : Domain → Formula} → (∀{x : Domain} → Proof(P(x))) → Proof(∀ₗ P) elim : ∀{P : Domain → Formula} → Proof(∀ₗ P) → (∀{x : Domain} → Proof(P(x))) record ExistentialQuantification(∃ₗ : (Domain → Formula) → Formula) : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where field intro : ∀{P : Domain → Formula}{a} → Proof(P(a)) → Proof(∃ₗ P) elim : ∀{P : Domain → Formula}{Z : Formula} → (∀{x : Domain} → Proof(P(x)) → Proof(Z)) → Proof(∃ₗ P) → Proof(Z) -- These allows the creation of new symbols which points to something which exists and is unique. -- TODO: Does this make this theory have no models? For functions, the functions in the meta-theory here (Agda-functions) represent computable things, and all unique existances are not computable. Normally in set theory, one could interpret every (f(x) = y)-formula as ((x,y) ∈ f), so normally it probably works out in the end of the day? record ExistentialWitness(∃ₗ : (Domain → Formula) → Formula) : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where field [∃]-witness : ∀{P : Domain → Formula} → ⦃ _ : Proof(∃ₗ P) ⦄ → Domain [∃]-proof : ∀{P : Domain → Formula} → ⦃ p : Proof(∃ₗ P) ⦄ → Proof(P([∃]-witness{P} ⦃ p ⦄)) record Signature : Type{ℓₗ Lvl.⊔ ℓₒ} where field ∀ₗ : (Domain → Formula) → Formula ∃ₗ : (Domain → Formula) → Formula NonEmptyDomain = ∀{P} → Proof(P) → Proof(∃ₗ(const P)) -- A theory of constructive predicate/(first-order) logic expressed using natural deduction rules record Theory ⦃ sign : Signature ⦄ : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where open Signature(sign) field instance ⦃ universalQuantification ⦄ : UniversalQuantification(∀ₗ) instance ⦃ existentialQuantification ⦄ : ExistentialQuantification(∃ₗ) module [∀] = UniversalQuantification (universalQuantification) module [∃] = ExistentialQuantification (existentialQuantification) module NonEmptyDomain ⦃ nonEmptyDomain : NonEmptyDomain ⦄ where [∀]-redundancyₗ : ∀{φ} → Proof(∀ₗ(const φ)) ← Proof(φ) [∀]-redundancyₗ (proof) = [∀].intro(\{_} → proof) [∀]-redundancyᵣ : ∀{φ} → Proof(∀ₗ(const φ)) → Proof(φ) [∀]-redundancyᵣ (proof) = [∃].elim(\{x} → _ ↦ [∀].elim(proof){x}) (nonEmptyDomain proof) [∃]-redundancyₗ : ∀{φ} → Proof(∃ₗ(const φ)) ← Proof(φ) [∃]-redundancyₗ (proof) = [∃].elim(\{x} → _ ↦ [∃].intro{_}{x}(proof)) (nonEmptyDomain proof) [∃]-redundancyᵣ : ∀{φ} → Proof(∃ₗ(const φ)) → Proof(φ) [∃]-redundancyᵣ = [∃].elim(\{_} → id) module Equality where -- Rules of equality record Equality(_≡_ : Domain → Domain → Formula) : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where field intro : ∀{x} → Proof(x ≡ x) elimᵣ : ∀{P : Domain → Formula}{a b} → Proof(a ≡ b) → Proof(P(a)) → Proof(P(b)) symmetry : ∀{a b} → Proof(a ≡ b) → Proof(b ≡ a) symmetry{a} (proof) = elimᵣ{x ↦ x ≡ a} (proof) (intro{a}) elimₗ : ∀{P : Domain → Formula}{a b} → Proof(a ≡ b) → Proof(P(a)) ← Proof(P(b)) elimₗ (proof) (pb) = elimᵣ (symmetry proof) (pb) transitivity : ∀{a b c} → Proof(a ≡ b) → Proof(b ≡ c) → Proof(a ≡ c) transitivity (ab) (bc) = elimᵣ bc ab record Signature : Type{ℓₗ Lvl.⊔ ℓₒ} where infixl 2000 _≡_ field _≡_ : Domain → Domain → Formula module PropositionallyDerivedSignature ⦃ propositional : Propositional.Signature ⦄ ⦃ sign : Signature ⦄ where open Propositional.Signature(propositional) open Signature(sign) _≢_ : Domain → Domain → Formula _≢_ a b = ¬(_≡_ a b) record Theory ⦃ sign : Signature ⦄ : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where open Signature(sign) field instance ⦃ equality ⦄ : Equality(_≡_) module [≡] = Equality(equality) module Uniqueness ⦃ propositionalSign : Propositional.Signature ⦄ ⦃ predicateSign : Predicate.Signature ⦄ ⦃ equalitySign : Equality.Signature ⦄ where open Propositional.Signature(propositionalSign) open Predicate.Signature(predicateSign) open Equality.Signature(equalitySign) module Signature where -- Definition of uniqueness of a property. -- This means that there is at most one element that satisfies this property. -- This is similiar to "Injective" for functions, but this is for statements. Unique : (Domain → Formula) → Formula Unique(P) = ∀ₗ(x ↦ ∀ₗ(y ↦ (P(x) ∧ P(y)) ⟶ (x ≡ y))) -- Definition of existence of an unique element satisfying a property. -- This means that there is one and only one element that satisfies this property. ∃ₗ! : (Domain → Formula) → Formula ∃ₗ! P = ((∃ₗ P) ∧ Unique(P)) module _ ⦃ propositional : Propositional.Theory ⦄ ⦃ predicate : Predicate.Theory ⦄ ⦃ equality : Equality.Theory ⦄ where open Signature open Propositional.Theory(propositional) open Predicate.Theory(predicate) open Equality.Theory(equality) module WitnessTheory ⦃ existentialWitness : Predicate.ExistentialWitness(∃ₗ) ⦄ where open Predicate.ExistentialWitness(existentialWitness) [∃!]-witness : ∀{P : Domain → Formula} → ⦃ _ : Proof(∃ₗ! P) ⦄ → Domain [∃!]-witness{P} ⦃ proof ⦄ = [∃]-witness{P} ⦃ [∧].elimₗ proof ⦄ [∃!]-proof : ∀{P : Domain → Formula} → ⦃ p : Proof(∃ₗ! P) ⦄ → Proof(P([∃!]-witness{P} ⦃ p ⦄)) [∃!]-proof{P} ⦃ proof ⦄ = [∃]-proof{P} ⦃ [∧].elimₗ proof ⦄ [∃!]-unique : ∀{P : Domain → Formula} → ⦃ p : Proof(∃ₗ! P) ⦄ → Proof(∀ₗ(x ↦ P(x) ⟶ (x ≡ [∃!]-witness{P} ⦃ p ⦄))) [∃!]-unique{P} ⦃ proof ⦄ = ([∀].intro(\{x} → ([→].intro(px ↦ ([→].elim ([∀].elim([∀].elim([∧].elimᵣ proof) {x}) {[∃!]-witness{P} ⦃ proof ⦄}) ([∧].intro (px) ([∃!]-proof{P} ⦃ proof ⦄) ) ) )) )) module _ {ℓₒ} (Domain : Type{ℓₒ}) where record ConstructiveLogicSignature : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where open Domained(Domain) field instance ⦃ propositionalSignature ⦄ : Propositional.Signature instance ⦃ predicateSignature ⦄ : Predicate.Signature instance ⦃ equalitySignature ⦄ : Equality.Signature open Propositional.Signature(propositionalSignature) public open Predicate.Signature(predicateSignature) public open Equality.Signature(equalitySignature) public open Equality.PropositionallyDerivedSignature ⦃ propositionalSignature ⦄ ⦃ equalitySignature ⦄ public open Uniqueness.Signature ⦃ propositionalSignature ⦄ ⦃ predicateSignature ⦄ ⦃ equalitySignature ⦄ public record ConstructiveLogic : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where open Domained(Domain) field instance ⦃ constructiveLogicSignature ⦄ : ConstructiveLogicSignature open ConstructiveLogicSignature public field instance ⦃ propositionalTheory ⦄ : Propositional.Theory instance ⦃ predicateTheory ⦄ : Predicate.Theory instance ⦃ equalityTheory ⦄ : Equality.Theory open Propositional.Theory(propositionalTheory) public open Predicate.Theory(predicateTheory) public open Equality.Theory(equalityTheory) public module MultiSorted {ℓₒ} {Sorts : Type{ℓₒ}} (Domain : Sorts → Type{ℓₒ}) where module Predicate where record UniversalQuantification(∀ₗ : ∀{Sort} → (Domain(Sort) → Formula) → Formula) : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where field intro : ∀{Sort}{P : Domain(Sort) → Formula} → (∀{x : Domain(Sort)} → Proof(P(x))) → Proof(∀ₗ P) elim : ∀{Sort}{P : Domain(Sort) → Formula} → Proof(∀ₗ P) → (∀{x : Domain(Sort)} → Proof(P(x))) record ExistentialQuantification(∃ₗ : ∀{Sort} → (Domain(Sort) → Formula) → Formula) : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where field intro : ∀{Sort}{P : Domain(Sort) → Formula}{a} → Proof(P(a)) → Proof(∃ₗ P) elim : ∀{Sort}{P : Domain(Sort) → Formula}{Z : Formula} → (∀{x : Domain(Sort)} → Proof(P(x)) → Proof(Z)) → Proof(∃ₗ P) → Proof(Z) record Signature : Type{ℓₗ Lvl.⊔ ℓₒ} where field ∀ₗ : ∀{Sort} → (Domain(Sort) → Formula) → Formula ∃ₗ : ∀{Sort} → (Domain(Sort) → Formula) → Formula -- A theory of constructive predicate/(first-order) multi-sorted logic expressed using natural deduction rules record Theory ⦃ sign : Signature ⦄ : Type{ℓₘₗ Lvl.⊔ (ℓₗ Lvl.⊔ ℓₒ)} where open Signature(sign) field instance ⦃ universalQuantification ⦄ : UniversalQuantification(∀ₗ) instance ⦃ existentialQuantification ⦄ : ExistentialQuantification(∃ₗ) module [∀] = UniversalQuantification (universalQuantification) module [∃] = ExistentialQuantification (existentialQuantification)
{ "alphanum_fraction": 0.5940669723, "avg_line_length": 41.1257142857, "ext": "agda", "hexsha": "77e3bf9cdfd5bf927888afe2ba005ca556b50b8a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Structure/Logic/Constructive/NaturalDeduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/Logic/Constructive/NaturalDeduction.agda", "max_line_length": 342, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Structure/Logic/Constructive/NaturalDeduction.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": 5281, "size": 14394 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.Equivalence2 open import lib.Function2 open import lib.NType2 open import lib.types.Coproduct open import lib.types.Fin open import lib.types.Group open import lib.types.Int open import lib.types.Nat open import lib.types.Pi open import lib.types.Subtype open import lib.types.Truncation open import lib.groups.SubgroupProp module lib.groups.Homomorphism where {- Group homomorphisms. -} preserves-comp : ∀ {i j} {A : Type i} {B : Type j} (A-comp : A → A → A) (B-comp : B → B → B) (f : A → B) → Type (lmax i j) preserves-comp Ac Bc f = ∀ a₁ a₂ → f (Ac a₁ a₂) == Bc (f a₁) (f a₂) preserves-comp-prop : ∀ {i j} {A : Type i} {B : Type j} {{_ : is-set B}} (A-comp : A → A → A) (B-comp : B → B → B) → SubtypeProp (A → B) (lmax i j) preserves-comp-prop Ac Bc = preserves-comp Ac Bc , ⟨⟩ abstract ∼-preserves-preserves-comp : ∀ {i j} {A : Type i} {B : Type j} (A-comp : A → A → A) (B-comp : B → B → B) {f₀ f₁ : A → B} → f₀ ∼ f₁ → preserves-comp A-comp B-comp f₀ → preserves-comp A-comp B-comp f₁ ∼-preserves-preserves-comp Ac Bc {f₀ = f₀} {f₁} f₀∼f₁ f₀-pc a₁ a₂ = ! (f₀∼f₁ (Ac a₁ a₂)) ∙ f₀-pc a₁ a₂ ∙ ap2 Bc (f₀∼f₁ a₁) (f₀∼f₁ a₂) record GroupStructureHom {i j} {GEl : Type i} {HEl : Type j} (GS : GroupStructure GEl) (HS : GroupStructure HEl) : Type (lmax i j) where constructor group-structure-hom private module G = GroupStructure GS module H = GroupStructure HS field f : GEl → HEl pres-comp : preserves-comp G.comp H.comp f abstract pres-ident : f G.ident == H.ident pres-ident = H.cancel-l (f G.ident) $ H.comp (f G.ident) (f G.ident) =⟨ ! (pres-comp G.ident G.ident) ⟩ f (G.comp G.ident G.ident) =⟨ ap f (G.unit-l G.ident) ⟩ f G.ident =⟨ ! (H.unit-r (f G.ident)) ⟩ H.comp (f G.ident) H.ident =∎ pres-inv : ∀ g → f (G.inv g) == H.inv (f g) pres-inv g = ! $ H.inv-unique-l _ _ $ H.comp (f (G.inv g)) (f g) =⟨ ! (pres-comp (G.inv g) g) ⟩ f (G.comp (G.inv g) g) =⟨ ap f (G.inv-l g) ⟩ f G.ident =⟨ pres-ident ⟩ H.ident =∎ pres-exp : ∀ g i → f (G.exp g i) == H.exp (f g) i pres-exp g (pos O) = pres-ident pres-exp g (pos (S O)) = idp pres-exp g (pos (S (S n))) = pres-comp g (G.exp g (pos (S n))) ∙ ap (H.comp (f g)) (pres-exp g (pos (S n))) pres-exp g (negsucc O) = pres-inv g pres-exp g (negsucc (S n)) = pres-comp (G.inv g) (G.exp g (negsucc n)) ∙ ap2 H.comp (pres-inv g) (pres-exp g (negsucc n)) pres-conj : ∀ g h → f (G.conj g h) == H.conj (f g) (f h) pres-conj g h = pres-comp (G.comp g h) (G.inv g) ∙ ap2 H.comp (pres-comp g h) (pres-inv g) pres-diff : ∀ g h → f (G.diff g h) == H.diff (f g) (f h) pres-diff g h = pres-comp g (G.inv h) ∙ ap (H.comp (f g)) (pres-inv h) pres-sum : ∀ {I : ℕ} (g : Fin I → GEl) → f (G.sum g) == H.sum (f ∘ g) pres-sum {I = O} _ = pres-ident pres-sum {I = S I} g = pres-comp (G.sum (g ∘ Fin-S)) (g (_ , ltS)) ∙ ap (λ h → H.comp h (f (g (_ , ltS)))) (pres-sum (g ∘ Fin-S)) pres-subsum-r : ∀ {k l} {I : ℕ} {A : Type k} {B : Type l} → (p : Fin I → Coprod A B) (g : B → GEl) → f (G.subsum-r p g) == H.subsum-r p (f ∘ g) pres-subsum-r p g = pres-sum (Coprod-rec (λ _ → G.ident) g ∘ p) ∙ ap H.sum (λ= λ x → Coprod-rec-post∘ f (λ _ → G.ident) g (p x) ∙ ap (λ h → Coprod-rec h (f ∘ g) (p x)) (λ= λ _ → pres-ident)) ⊙f : ⊙[ GEl , G.ident ] ⊙→ ⊙[ HEl , H.ident ] ⊙f = f , pres-ident infix 0 _→ᴳˢ_ -- [ˢ] for structures _→ᴳˢ_ = GroupStructureHom record GroupHom {i j} (G : Group i) (H : Group j) : Type (lmax i j) where constructor group-hom private module G = Group G module H = Group H field f : G.El → H.El pres-comp : ∀ g₁ g₂ → f (G.comp g₁ g₂) == H.comp (f g₁) (f g₂) open GroupStructureHom {GS = G.group-struct} {HS = H.group-struct} record {f = f ; pres-comp = pres-comp} hiding (f ; pres-comp) public infix 0 _→ᴳ_ _→ᴳ_ = GroupHom →ᴳˢ-to-→ᴳ : ∀ {i j} {G : Group i} {H : Group j} → (Group.group-struct G →ᴳˢ Group.group-struct H) → (G →ᴳ H) →ᴳˢ-to-→ᴳ (group-structure-hom f pres-comp) = group-hom f pres-comp idhom : ∀ {i} (G : Group i) → (G →ᴳ G) idhom G = group-hom (idf _) (λ _ _ → idp) idshom : ∀ {i} {GEl : Type i} (GS : GroupStructure GEl) → (GS →ᴳˢ GS) idshom GS = group-structure-hom (idf _) (λ _ _ → idp) {- constant (zero) homomorphism -} module _ where cst-hom : ∀ {i j} {G : Group i} {H : Group j} → (G →ᴳ H) cst-hom {H = H} = group-hom (cst (Group.ident H)) (λ _ _ → ! (Group.unit-l H _)) {- negation is a homomorphism in an abelian gruop -} inv-hom : ∀ {i} (G : AbGroup i) → GroupHom (AbGroup.grp G) (AbGroup.grp G) inv-hom G = group-hom G.inv inv-pres-comp where module G = AbGroup G abstract inv-pres-comp : (g₁ g₂ : G.El) → G.inv (G.comp g₁ g₂) == G.comp (G.inv g₁) (G.inv g₂) inv-pres-comp g₁ g₂ = G.inv-comp g₁ g₂ ∙ G.comm (G.inv g₂) (G.inv g₁) {- equality of homomorphisms -} abstract group-hom= : ∀ {i j} {G : Group i} {H : Group j} {φ ψ : G →ᴳ H} → GroupHom.f φ == GroupHom.f ψ → φ == ψ group-hom= {G = G} {H = H} p = ap (uncurry group-hom) $ Subtype=-out (preserves-comp-prop (Group.comp G) (Group.comp H)) p group-hom=-↓ : ∀ {i j k} {A : Type i} {G : A → Group j} {H : A → Group k} {x y : A} {p : x == y} {φ : G x →ᴳ H x} {ψ : G y →ᴳ H y} → GroupHom.f φ == GroupHom.f ψ [ (λ a → Group.El (G a) → Group.El (H a)) ↓ p ] → φ == ψ [ (λ a → G a →ᴳ H a) ↓ p ] group-hom=-↓ {p = idp} = group-hom= abstract instance GroupHom-level : ∀ {i j} {G : Group i} {H : Group j} → is-set (G →ᴳ H) GroupHom-level {G = G} {H = H} = equiv-preserves-level (equiv (uncurry group-hom) (λ x → GroupHom.f x , GroupHom.pres-comp x) (λ _ → idp) (λ _ → idp)) {{Subtype-level (preserves-comp-prop (Group.comp G) (Group.comp H))}} infixr 80 _∘ᴳˢ_ _∘ᴳ_ abstract ∘ᴳˢ-pres-comp : ∀ {i j k} {GEl : Type i} {HEl : Type j} {KEl : Type k} {GS : GroupStructure GEl} {HS : GroupStructure HEl} {KS : GroupStructure KEl} (ψ : HS →ᴳˢ KS) (φ : GS →ᴳˢ HS) → preserves-comp (GroupStructure.comp GS) (GroupStructure.comp KS) (GroupStructureHom.f ψ ∘ GroupStructureHom.f φ) ∘ᴳˢ-pres-comp ψ φ g₁ g₂ = ap (GroupStructureHom.f ψ) (GroupStructureHom.pres-comp φ g₁ g₂) ∙ GroupStructureHom.pres-comp ψ (GroupStructureHom.f φ g₁) (GroupStructureHom.f φ g₂) ∘ᴳ-pres-comp : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} (ψ : H →ᴳ K) (φ : G →ᴳ H) → preserves-comp (Group.comp G) (Group.comp K) (GroupHom.f ψ ∘ GroupHom.f φ) ∘ᴳ-pres-comp ψ φ g₁ g₂ = ap (GroupHom.f ψ) (GroupHom.pres-comp φ g₁ g₂) ∙ GroupHom.pres-comp ψ (GroupHom.f φ g₁) (GroupHom.f φ g₂) _∘ᴳˢ_ : ∀ {i j k} {GEl : Type i} {HEl : Type j} {KEl : Type k} {GS : GroupStructure GEl} {HS : GroupStructure HEl} {KS : GroupStructure KEl} → (HS →ᴳˢ KS) → (GS →ᴳˢ HS) → (GS →ᴳˢ KS) ψ ∘ᴳˢ φ = group-structure-hom (GroupStructureHom.f ψ ∘ GroupStructureHom.f φ) (∘ᴳˢ-pres-comp ψ φ) _∘ᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} → (H →ᴳ K) → (G →ᴳ H) → (G →ᴳ K) ψ ∘ᴳ φ = group-hom (GroupHom.f ψ ∘ GroupHom.f φ) (∘ᴳ-pres-comp ψ φ) {- algebraic properties -} ∘ᴳ-unit-r : ∀ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) → φ ∘ᴳ idhom G == φ ∘ᴳ-unit-r φ = group-hom= idp ∘ᴳ-unit-l : ∀ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) → idhom H ∘ᴳ φ == φ ∘ᴳ-unit-l φ = group-hom= idp ∘ᴳ-assoc : ∀ {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l} (χ : K →ᴳ L) (ψ : H →ᴳ K) (φ : G →ᴳ H) → (χ ∘ᴳ ψ) ∘ᴳ φ == χ ∘ᴳ ψ ∘ᴳ φ ∘ᴳ-assoc χ ψ φ = group-hom= idp is-injᴳ : ∀ {i j} {G : Group i} {H : Group j} → (G →ᴳ H) → Type (lmax i j) is-injᴳ hom = is-inj (GroupHom.f hom) is-surjᴳ : ∀ {i j} {G : Group i} {H : Group j} → (G →ᴳ H) → Type (lmax i j) is-surjᴳ hom = is-surj (GroupHom.f hom) {- subgroups -} infix 80 _∘subᴳ_ _∘subᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} → SubgroupProp H k → (G →ᴳ H) → SubgroupProp G k _∘subᴳ_ {k = k} {G = G} P φ = record {M} where module G = Group G module P = SubgroupProp P module φ = GroupHom φ module M where prop : G.El → Type k prop = P.prop ∘ φ.f abstract ident : prop G.ident ident = transport! P.prop φ.pres-ident P.ident diff : {g₁ g₂ : G.El} → prop g₁ → prop g₂ → prop (G.diff g₁ g₂) diff {g₁} {g₂} pφg₁ pφg₂ = transport! P.prop (φ.pres-diff g₁ g₂) (P.diff pφg₁ pφg₂) infix 80 _∘nsubᴳ_ _∘nsubᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} → NormalSubgroupProp H k → (G →ᴳ H) → NormalSubgroupProp G k _∘nsubᴳ_ {G = G} {H} P φ = P.propᴳ ∘subᴳ φ , P-φ-is-normal where module P = NormalSubgroupProp P module φ = GroupHom φ abstract P-φ-is-normal : is-normal (P.propᴳ ∘subᴳ φ) P-φ-is-normal g₁ {g₂} pφg₂ = transport! P.prop (φ.pres-conj g₁ g₂) (P.conj (φ.f g₁) pφg₂) {- kernels and images -} module _ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where private module G = Group G module H = Group H module φ = GroupHom φ ker-propᴳ : SubgroupProp G j ker-propᴳ = record {M} where module M where prop : G.El → Type j prop g = φ.f g == H.ident abstract ident : prop G.ident ident = φ.pres-ident diff : {g₁ g₂ : G.El} → prop g₁ → prop g₂ → prop (G.diff g₁ g₂) diff {g₁} {g₂} p₁ p₂ = φ.pres-diff g₁ g₂ ∙ ap2 H.diff p₁ p₂ ∙ H.inv-r H.ident -- 'n' for 'normal' ker-npropᴳ : NormalSubgroupProp G j ker-npropᴳ = ker-propᴳ , ker-is-normal where abstract ker-is-normal : is-normal ker-propᴳ ker-is-normal g₁ {g₂} pg₂ = φ.pres-conj g₁ g₂ ∙ ap (H.conj (φ.f g₁)) pg₂ ∙ H.conj-ident-r (φ.f g₁) im-propᴳ : SubgroupProp H (lmax i j) im-propᴳ = record {M} where module M where prop : H.El → Type (lmax i j) prop h = Trunc -1 (hfiber φ.f h) level : (h : H.El) → is-prop (prop h) level h = Trunc-level abstract ident : prop H.ident ident = [ G.ident , φ.pres-ident ] diff : {h₁ h₂ : H.El} → prop h₁ → prop h₂ → prop (H.diff h₁ h₂) diff = Trunc-fmap2 λ {(g₁ , p₁) (g₂ , p₂) → G.diff g₁ g₂ , φ.pres-diff g₁ g₂ ∙ ap2 H.diff p₁ p₂} im-npropᴳ : is-abelian H → NormalSubgroupProp H (lmax i j) im-npropᴳ H-is-abelian = sub-abelian-normal H-is-abelian im-propᴳ has-trivial-kerᴳ : Type (lmax i j) has-trivial-kerᴳ = is-trivial-propᴳ ker-propᴳ abstract -- any homomorphism with trivial kernel is injective has-trivial-ker-is-injᴳ : has-trivial-kerᴳ → is-injᴳ φ has-trivial-ker-is-injᴳ tk g₁ g₂ p = G.zero-diff-same g₁ g₂ $ tk (G.diff g₁ g₂) $ φ.pres-diff g₁ g₂ ∙ ap (λ h → H.diff h (φ.f g₂)) p ∙ H.inv-r (φ.f g₂) ker-cst-hom-is-full : ∀ {i j} (G : Group i) (H : Group j) → is-fullᴳ (ker-propᴳ (cst-hom {G = G} {H})) ker-cst-hom-is-full G H g = idp {- exactness -} module _ {i j k} {G : Group i} {H : Group j} {K : Group k} (φ : G →ᴳ H) (ψ : H →ᴳ K) where private module G = Group G module H = Group H module K = Group K module φ = GroupHom φ module ψ = GroupHom ψ record is-exact : Type (lmax k (lmax j i)) where field im-sub-ker : im-propᴳ φ ⊆ᴳ ker-propᴳ ψ ker-sub-im : ker-propᴳ ψ ⊆ᴳ im-propᴳ φ open is-exact public abstract {- an equivalent version of is-exact-ktoi -} im-sub-ker-in : is-fullᴳ (ker-propᴳ (ψ ∘ᴳ φ)) → im-propᴳ φ ⊆ᴳ ker-propᴳ ψ im-sub-ker-in r h = Trunc-rec (λ {(g , p) → ap ψ.f (! p) ∙ r g}) im-sub-ker-out : im-propᴳ φ ⊆ᴳ ker-propᴳ ψ → is-fullᴳ (ker-propᴳ (ψ ∘ᴳ φ)) im-sub-ker-out s g = s (φ.f g) [ g , idp ] {- homomorphisms into an abelian group can be composed with - the group operation and form a group -} module _ {i j} (G : Group i) (H : AbGroup j) where private module G = Group G module H = AbGroup H hom-comp : (G →ᴳ H.grp) → (G →ᴳ H.grp) → (G →ᴳ H.grp) hom-comp φ ψ = group-hom (λ g → H.comp (φ.f g) (ψ.f g)) hom-comp-pres-comp where module φ = GroupHom φ module ψ = GroupHom ψ abstract hom-comp-pres-comp : ∀ g₁ g₂ → H.comp (φ.f (G.comp g₁ g₂)) (ψ.f (G.comp g₁ g₂)) == H.comp (H.comp (φ.f g₁) (ψ.f g₁)) (H.comp (φ.f g₂) (ψ.f g₂)) hom-comp-pres-comp g₁ g₂ = H.comp (φ.f (G.comp g₁ g₂)) (ψ.f (G.comp g₁ g₂)) =⟨ ap2 H.comp (φ.pres-comp g₁ g₂) (ψ.pres-comp g₁ g₂) ⟩ H.comp (H.comp (φ.f g₁) (φ.f g₂)) (H.comp (ψ.f g₁) (ψ.f g₂)) =⟨ H.interchange (φ.f g₁) (φ.f g₂) (ψ.f g₁) (ψ.f g₂) ⟩ H.comp (H.comp (φ.f g₁) (ψ.f g₁)) (H.comp (φ.f g₂) (ψ.f g₂)) =∎ hom-group-structure : GroupStructure (G →ᴳ H.grp) hom-group-structure = record {M} where module M where ident : G →ᴳ H.grp ident = cst-hom comp : (G →ᴳ H.grp) → (G →ᴳ H.grp) → (G →ᴳ H.grp) comp = hom-comp inv : (G →ᴳ H.grp) → (G →ᴳ H.grp) inv φ = inv-hom H ∘ᴳ φ abstract unit-l : ∀ φ → comp ident φ == φ unit-l φ = group-hom= $ λ= λ _ → H.unit-l _ assoc : ∀ φ ψ ξ → comp (comp φ ψ) ξ == comp φ (comp ψ ξ) assoc φ ψ ξ = group-hom= $ λ= λ _ → H.assoc _ _ _ inv-l : ∀ φ → comp (inv φ) φ == ident inv-l φ = group-hom= $ λ= λ _ → H.inv-l _ hom-group : Group (lmax i j) hom-group = group (G →ᴳ H.grp) hom-group-structure abstract hom-group-is-abelian : is-abelian hom-group hom-group-is-abelian φ ψ = group-hom= $ λ= λ g → H.comm _ _ hom-abgroup : AbGroup (lmax i j) hom-abgroup = hom-group , hom-group-is-abelian module _ {i j} {G : Group i} {H : AbGroup j} where app-hom : Group.El G → hom-group G H →ᴳ AbGroup.grp H app-hom g = group-hom (λ φ → GroupHom.f φ g) lemma where abstract lemma = λ φ ψ → idp appᴳ = app-hom pre∘ᴳ-hom : ∀ {i j k} {G : Group i} {H : Group j} (K : AbGroup k) → (G →ᴳ H) → (hom-group H K →ᴳ hom-group G K) pre∘ᴳ-hom K φ = record { f = _∘ᴳ φ ; pres-comp = lemma} where abstract lemma = λ _ _ → group-hom= idp post∘ᴳ-hom : ∀ {i j k} (G : Group i) (H : AbGroup j) (K : AbGroup k) → (AbGroup.grp H →ᴳ AbGroup.grp K) → (hom-group G H →ᴳ hom-group G K) post∘ᴳ-hom G H K φ = record { f = φ ∘ᴳ_ ; pres-comp = lemma} where abstract lemma = λ _ _ → group-hom= $ λ= λ _ → GroupHom.pres-comp φ _ _
{ "alphanum_fraction": 0.5580438119, "avg_line_length": 34.9609756098, "ext": "agda", "hexsha": "ee7f0d77878f63c193f840a21d931a874cea0fd7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/groups/Homomorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/groups/Homomorphism.agda", "max_line_length": 125, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/groups/Homomorphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5995, "size": 14334 }
module Formalization where module Introduction where open import Data.Product using (Σ; Σ-syntax; _×_; _,_; proj₁; proj₂) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong) data Iso (A B : Set): Set where iso : (f : A → B) → (g : B → A) → (((x : A) → (g (f x)) ≡ x) × ((y : B) → (f (g y)) ≡ y)) → Iso A B open import Function using (_∘_) -- NB: This says every [total] relation can be refined to a function. -- Kind of ew... -- The Hott Book notes that though the system is strong enough to sufficiently -- dilute the consequences of AC, the law of the excluded middle is inconsistent with Univalence -- because it acts like a "Hilbertian Choice Operator" [p 9]. axiom-of-choice : {A : Set} → {B : A → Set} → {R : (a : A) → B a → Set} → (∀ (x : A) → Σ[ y ∈ B x ](R x y)) -- If for every x : A, ∃ a y : B x s.t. R x y → Σ[ f ∈ ((x : A) → B x) ](∀ (x : A) → (R x (f x))) -- then ∃ f : A → B s.t. ∀ x : A we have R (x, f(x)) axiom-of-choice g = proj₁ ∘ g , proj₂ ∘ g module Chapter where -- Simple Polymorphic Functions -- ---------------------------- id : ∀{a}{A : Set a} → A → A id x = x swap : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → (A → B → C) → (B → A → C) swap g = λ b a → g a b -- Product Types -- ------------- -- To specify a type (a la Martin Löf's TT) we need: -- ∘ Formation Rules ("We can form f : A → B when A : Type and B : Type") -- ∘ Introduction Rules (Constructors) -- ∘ Elimination Rules (How to use the type's elements) -- ∘ Computation Rules (How Elimination Rules act on constructors) -- OPTIONAL -- ∘ Uniqueness Principle (Every element of the type is {uniquely} determined by the result of applying Elimination Rules) -- Formation and Introduction of Pairs is given in Data.Product, so here's an Eliminator {- Need function extensionality here, but I'm too lazy to postulate it right now. elimₓ-β : {A B C : Set} → (f : (A × B) → C) → (g : (A → B → C)) → (x : A)(y : B) → (f (x , y) ≡ g x y) elimₓ-β = λ f g x y → refl -} -- The projection functons also count as eliminators, but are too specific on occaision -- so we introduce the recursor for product types. recₓ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → (A → B → C) → (A × B) → C recₓ g (a , b) = g a b -- Then define the projection functions in terms of it. pr₁ : ∀{a b}{A : Set a}{B : Set b} → (A × B) → A pr₁ = recₓ λ a → λ b → a pr₂ : ∀{a b}{A : Set a}{B : Set b} → (A × B) → B pr₂ = recₓ λ a → λ b → b -- The Unit Type also has a recursor: open import Data.Unit rec₁ : ∀{c}{C : Set c} → C → ⊤ → C rec₁ c ⋆ = c -- For dependent functions over the product type, we must first generalize the recursor recₓ-general : ∀{a b c}{A : Set a}{B : Set b}{C : (A × B) → Set c} → (x : A × B) → (g : (a : A) → (b : B) → C (a , b)) → C x recₓ-general = λ x g → g (pr₁ x) (pr₂ x) -- Now we can prove the propositional uniqueness principle uppt : ∀{a b}{A : Set a}{B : Set b} → (x : A × B) → ((pr₁ x) , (pr₂ x) ≡ x) uppt x = refl -- And compute the following equality: reflₓ : ∀{a b}{A : Set a}{B : Set b} → (x : A)(y : B) -- ∀ x, y → ((pr₁ (x , y)) , (pr₂ (x , y)) ≡ (x , y)) -- Forming from forming then eliminating is the same as forming reflₓ x y = refl -- Now the induction function for product types; indₓ : ∀{a b c}{A : Set a}{B : Set b}{C : (A × B) → Set c} → ((x : A) → (y : B) -- ∀ x , y → C (x , y)) -- and a property that holds for the product (x , y) → (x : A × B) → C x -- ∀ products x, C holds indₓ g (a , b) = g a b -- And for the unit type ind₁ : {C : ⊤ → Set} → C tt → (x : ⊤) → C x ind₁ c ⋆ = c -- "Induction enables us to prove the propositional uniqueness principle for 1, which asserts that its -- only inhabitant is ⋆. That is, we can construct" upun : (x : ⊤) → x ≡ tt upun x = refl -- The uniqueness of unit can also be asserted by induction upun-ind : (x : ⊤) → x ≡ tt upun-ind x = ind₁ {C = λ x → x ≡ tt} refl x -- Sigma (Dependent Pair) Types -- ---------------------------- -- We'll use the Σ in the Agda Stdlib (because of the cool syntax). -- -- For a constant type B rather than a B indexed by x : A, dependent pairs -- and just cartesian products. With that in mind, the recursor for dependent -- pairs looks much the same as the one for the cartesian product recₚ : ∀{a b c}{A : Set a}{B : A → Set b}{C : Set c} → ((x : A) → B x → C) -- It suffices to define the dependent function g such that → Σ[ x ∈ A ](B x) → C -- ∀ Σ(x : A)B x, C holds. recₚ g (a , b) = g a b -- Here's Induction indₚ : ∀{a b c}{A : Set a}{B : A → Set b}{C : Σ[ x ∈ A ](B x) → Set c} → ((x : A)(y : B x) -- ∀ x , y → C (x , y)) -- and a property that holds for the pair (x , y) → (p : Σ[ x ∈ A ](B x)) → C p -- ∀ pairs x, C holds indₚ g (a , b) = g a b -- NB: Read Π as "forall" and Σ as "exists" record Magma (A : Set) : Set where field mop : A → A → A open Magma {{...}} public record PointedMagma (A : Set) : Set where field mbasepoint : A pmop : (A → A → A) pointedMagmaIsMagma : Magma A pointedMagmaIsMagma = record { mop = pmop } open PointedMagma {{...}} public -- Coproducts open import Data.Sum rec₊ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → (A → C) → (B → C) → A ⊎ B → C rec₊ g₀ g₁ (inj₁ x) = g₀ x rec₊ g₀ g₁ (inj₂ y) = g₁ y -- Oh look, ⊥ open import Data.Empty -- Any definition of the recursor would means proving 'ex falso quodlibet'. -- Let's try not to do that... rec₀ : ∀{c}{C : Set c} → ⊥ → C rec₀ () ind₊ : ∀{a b c}{A : Set a}{B : Set b}{C : (A ⊎ B) → Set c} → ((x : A) → C (inj₁ x)) → ((y : B) → C (inj₂ y)) → (x : A ⊎ B) → C x ind₊ g₀ g₁ (inj₁ x) = g₀ x ind₊ g₀ g₁ (inj₂ y) = g₁ y ind₀ : ∀{c}{C : ⊥ → Set c} → (z : ⊥) → C z ind₀ () -- The type of booleans open import Data.Bool rec₂ : ∀{c}{C : Set c} → C → C → Bool → C rec₂ c₀ c₁ true = c₁ rec₂ c₀ c₁ false = c₀ ind₂ : ∀{c}{C : Bool → Set c} → C false → C true → (x : Bool) → C x ind₂ c₀ c₁ true = c₁ ind₂ c₀ c₁ false = c₀ dec₂ : (x : Bool) → (x ≡ false) ⊎ (x ≡ true) dec₂ x = ind₂ {C = λ x → (x ≡ false) ⊎ (x ≡ true)} (inj₁ refl) (inj₂ refl) x -- The type of Natural Numbers open import Data.Nat double : ℕ → ℕ double zero = zero double (suc n) = suc (suc (double n)) add : ℕ → ℕ → ℕ add zero n = n add (suc m) n = suc (add m n) recₙ : ∀{c}{C : Set c} → C → (ℕ → C → C) → ℕ → C recₙ c₀ cₛ zero = c₀ recₙ c₀ cₛ (suc n) = cₛ n (recₙ c₀ cₛ n) double-recₙ : ℕ → ℕ double-recₙ = recₙ 0 (λ n y → suc (suc y)) add-recₙ : ℕ → ℕ → ℕ add-recₙ = recₙ {C = ℕ → ℕ} (λ n → n) (λ n → λ g m → suc (g m)) indₙ : {C : ℕ → Set} → C 0 → ((n : ℕ) → C n → C (suc n)) → (n : ℕ) → C n indₙ c₀ cₛ zero = c₀ indₙ c₀ cₛ (suc n) = cₛ n (indₙ c₀ cₛ n) assoc : (i j k : ℕ) → i + (j + k) ≡ (i + j) + k assoc = indₙ {C = λ i → (j k : ℕ) → i + (j + k) ≡ (i + j) + k} assoc₀ assocₛ where assoc₀ : (j k : ℕ) → 0 + (j + k) ≡ (0 + j) + k assoc₀ j k = refl assocₛ : (i : ℕ) → ((j k : ℕ) → i + (j + k) ≡ (i + j) + k) → (j k : ℕ) → (suc i) + (j + k) ≡ ((suc i) + j) + k assocₛ _ i j k = cong suc (i j k) -- Propositions As Types {- ¬_ : {A : Set} → A → ⊥ ¬ x = () -} -- Path Induction open import Level ind₌ : ∀ {i} {A : Set i} → (C : (x y : A) → (x ≡ y) → Set i) → ((x : A) → C x x refl) → {x y : A} → (p : x ≡ y) → C x y p ind₌ C c {x}{y} p rewrite p = c y based-ind₌ : ∀ {i} {A : Set i}{a : A} → (C : (x : A) → (a ≡ x) → Set i) → C a refl → {x : A} → (p : a ≡ x) → C x p based-ind₌ C c p rewrite p = c {- ind₌-β : ∀ {i} {A : Set i} → (C : (x y : A) → (x ≡ y) → Set i) → (c : (x : A) → C x x refl) → (x : A) → (C' : (y : A) → (x ≡ y) → Set i) → (c' : C' x refl) → (y : A) → (p : x ≡ y) → ind₌ C c p <-> based-ind₌ C' c' p ind₌-β {i} {A} C c x C' c' y p = ? where D : (x y : A) → (x ≡ y) → Set i D x y p = (C : (z : A) → (x ≡ z) → Set i) → C x refl → C y p d : (x : A) → D x x refl d = λ x₁ → λ C → (c : C x refl) → c -}
{ "alphanum_fraction": 0.523436513, "avg_line_length": 29.7556390977, "ext": "agda", "hexsha": "e33a710e085257d244dadb044bc0baa8e257620a", "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": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_path": "Chapter1/Formalization.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "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": "CodaFi/HoTT-Exercises", "max_issues_repo_path": "Chapter1/Formalization.agda", "max_line_length": 124, "max_stars_count": null, "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_path": "Chapter1/Formalization.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3249, "size": 7915 }
------------------------------------------------------------------------ -- Properties of homogeneous binary relations ------------------------------------------------------------------------ -- This file contains some core definitions which are reexported by -- Relation.Binary or Relation.Binary.PropositionalEquality. module Relation.Binary.Core where open import Data.Product open import Data.Sum open import Data.Function open import Relation.Nullary.Core ------------------------------------------------------------------------ -- Homogeneous binary relations Rel : Set → Set₁ Rel a = a → a → Set ------------------------------------------------------------------------ -- Simple properties of binary relations infixr 4 _⇒_ _=[_]⇒_ -- Implication/containment. Could also be written ⊆. _⇒_ : ∀ {a} → Rel a → Rel a → Set P ⇒ Q = ∀ {i j} → P i j → Q i j -- Generalised implication. If P ≡ Q it can be read as "f preserves -- P". _=[_]⇒_ : ∀ {a b} → Rel a → (a → b) → Rel b → Set P =[ f ]⇒ Q = P ⇒ (Q on₁ f) -- A synonym, along with a binary variant. _Preserves_⟶_ : ∀ {a₁ a₂} → (a₁ → a₂) → Rel a₁ → Rel a₂ → Set f Preserves P ⟶ Q = P =[ f ]⇒ Q _Preserves₂_⟶_⟶_ : ∀ {a₁ a₂ a₃} → (a₁ → a₂ → a₃) → Rel a₁ → Rel a₂ → Rel a₃ → Set _+_ Preserves₂ P ⟶ Q ⟶ R = ∀ {x y u v} → P x y → Q u v → R (x + u) (y + v) -- Reflexivity of _∼_ can be expressed as _≈_ ⇒ _∼_, for some -- underlying equality _≈_. However, the following variant is often -- easier to use. Reflexive : {a : Set} → (_∼_ : Rel a) → Set Reflexive _∼_ = ∀ {x} → x ∼ x -- Irreflexivity is defined using an underlying equality. Irreflexive : {a : Set} → (_≈_ _<_ : Rel a) → Set Irreflexive _≈_ _<_ = ∀ {x y} → x ≈ y → ¬ (x < y) -- Generalised symmetry. Sym : ∀ {a} → Rel a → Rel a → Set Sym P Q = P ⇒ flip₁ Q Symmetric : {a : Set} → Rel a → Set Symmetric _∼_ = Sym _∼_ _∼_ -- Generalised transitivity. Trans : ∀ {a} → Rel a → Rel a → Rel a → Set Trans P Q R = ∀ {i j k} → P i j → Q j k → R i k Transitive : {a : Set} → Rel a → Set Transitive _∼_ = Trans _∼_ _∼_ _∼_ Antisymmetric : {a : Set} → (_≈_ _≤_ : Rel a) → Set Antisymmetric _≈_ _≤_ = ∀ {x y} → x ≤ y → y ≤ x → x ≈ y Asymmetric : {a : Set} → (_<_ : Rel a) → Set Asymmetric _<_ = ∀ {x y} → x < y → ¬ (y < x) _Respects_ : {a : Set} → (a → Set) → Rel a → Set P Respects _∼_ = ∀ {x y} → x ∼ y → P x → P y _Respects₂_ : {a : Set} → Rel a → Rel a → Set P Respects₂ _∼_ = (∀ {x} → P x Respects _∼_) × (∀ {y} → flip₁ P y Respects _∼_) Substitutive : {a : Set} → Rel a → Set₁ Substitutive _∼_ = ∀ P → P Respects _∼_ Congruential : ({a : Set} → Rel a) → Set₁ Congruential ∼ = ∀ {a b} → (f : a → b) → f Preserves ∼ ⟶ ∼ Congruential₂ : ({a : Set} → Rel a) → Set₁ Congruential₂ ∼ = ∀ {a b c} → (f : a → b → c) → f Preserves₂ ∼ ⟶ ∼ ⟶ ∼ Decidable : {a : Set} → Rel a → Set Decidable _∼_ = ∀ x y → Dec (x ∼ y) Total : {a : Set} → Rel a → Set Total _∼_ = ∀ x y → (x ∼ y) ⊎ (y ∼ x) data Tri (A B C : Set) : Set where tri< : ( a : A) (¬b : ¬ B) (¬c : ¬ C) → Tri A B C tri≈ : (¬a : ¬ A) ( b : B) (¬c : ¬ C) → Tri A B C tri> : (¬a : ¬ A) (¬b : ¬ B) ( c : C) → Tri A B C Trichotomous : {a : Set} → Rel a → Rel a → Set Trichotomous _≈_ _<_ = ∀ x y → Tri (x < y) (x ≈ y) (x > y) where _>_ = flip₁ _<_ record NonEmpty {I : Set} (T : Rel I) : Set where field i : I j : I proof : T i j nonEmpty : ∀ {I} {T : Rel I} {i j} → T i j → NonEmpty T nonEmpty p = record { i = _; j = _; proof = p } ------------------------------------------------------------------------ -- Propositional equality -- This dummy module is used to avoid shadowing of the field named -- refl defined in IsEquivalence below. The module is opened publicly -- at the end of this file. private module Dummy where infix 4 _≡_ _≢_ data _≡_ {a : Set} (x : a) : a → Set where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} -- Nonequality. _≢_ : {a : Set} → a → a → Set x ≢ y = ¬ x ≡ y ------------------------------------------------------------------------ -- Equivalence relations -- The preorders of this library are defined in terms of an underlying -- equivalence relation, and hence equivalence relations are not -- defined in terms of preorders. record IsEquivalence {a : Set} (_≈_ : Rel a) : Set where field refl : Reflexive _≈_ sym : Symmetric _≈_ trans : Transitive _≈_ reflexive : Dummy._≡_ ⇒ _≈_ reflexive Dummy.refl = refl open Dummy public
{ "alphanum_fraction": 0.5133809099, "avg_line_length": 27.509202454, "ext": "agda", "hexsha": "14079419f605046cefb0f8b7264c84130b3f04f2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/Core.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/Core.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/Core.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": 1609, "size": 4484 }
{-# OPTIONS --safe #-} {- This is inspired by/copied from: https://github.com/agda/agda-stdlib/blob/master/src/Tactic/MonoidSolver.agda Boilerplate code for calling the ring solver is constructed automatically with agda's reflection features. -} module Cubical.Algebra.NatSolver.Reflection where open import Cubical.Foundations.Prelude hiding (Type) open import Cubical.Functions.Logic open import Agda.Builtin.Reflection hiding (Type) open import Agda.Builtin.String open import Cubical.Reflection.Base open import Cubical.Data.Maybe open import Cubical.Data.Sigma open import Cubical.Data.List open import Cubical.Data.Nat.Literals open import Cubical.Data.Nat open import Cubical.Data.FinData using () renaming (zero to fzero; suc to fsuc) open import Cubical.Data.Bool open import Cubical.Data.Bool.SwitchStatement open import Cubical.Data.Vec using (Vec) renaming ([] to emptyVec; _∷_ to _∷vec_) public open import Cubical.Algebra.NatSolver.NatExpression open import Cubical.Algebra.NatSolver.Solver open EqualityToNormalform renaming (solve to natSolve) private variable ℓ : Level _==_ = primQNameEquality {-# INLINE _==_ #-} record VarInfo : Type ℓ-zero where field varName : String varType : Arg Term index : ℕ {- `getLastTwoArgsOf` maps a term 'def n (z₁ ∷ … ∷ zₙ ∷ x ∷ y ∷ [])' to the pair '(x,y)' non-visible arguments are ignored. -} getLastTwoArgsOf : Name → Term → Maybe (Term × Term) getLastTwoArgsOf n' (def n xs) = if n == n' then go xs else nothing where go : List (Arg Term) → Maybe (Term × Term) go (varg x ∷ varg y ∷ []) = just (x , y) go (x ∷ xs) = go xs go _ = nothing getLastTwoArgsOf n' _ = nothing {- `getArgs` maps a term 'x ≡ y' to the pair '(x,y)' -} getArgs : Term → Maybe (Term × Term) getArgs = getLastTwoArgsOf (quote PathP) firstVisibleArg : List (Arg Term) → Maybe Term firstVisibleArg [] = nothing firstVisibleArg (varg x ∷ l) = just x firstVisibleArg (x ∷ l) = firstVisibleArg l {- If the solver needs to be applied during equational reasoning, the right hand side of the equation to solve cannot be given to the solver directly. The folllowing function extracts this term y from a more complex expression as in: x ≡⟨ solve ... ⟩ (y ≡⟨ ... ⟩ z ∎) -} getRhs : Term → Maybe Term getRhs reasoningToTheRight@(def n xs) = if n == (quote _∎) then firstVisibleArg xs else (if n == (quote _≡⟨_⟩_) then firstVisibleArg xs else nothing) getRhs _ = nothing private solverCallAsTerm : Arg Term → Term → Term → Term solverCallAsTerm varList lhs rhs = def (quote natSolve) (varg lhs ∷ varg rhs ∷ varList ∷ varg (def (quote refl) []) ∷ []) solverCallWithLambdas : ℕ → List VarInfo → Term → Term → Term solverCallWithLambdas n varInfos lhs rhs = encloseWithIteratedLambda (map VarInfo.varName varInfos) (solverCallAsTerm (variableList (rev varInfos)) lhs rhs) where encloseWithIteratedLambda : List String → Term → Term encloseWithIteratedLambda (varName ∷ xs) t = lam visible (abs varName (encloseWithIteratedLambda xs t)) encloseWithIteratedLambda [] t = t variableList : List VarInfo → Arg Term variableList [] = varg (con (quote emptyVec) []) variableList (varInfo ∷ varInfos) = varg (con (quote _∷vec_) (varg (var (VarInfo.index varInfo) []) ∷ (variableList varInfos) ∷ [])) solverCallByVarIndices : ℕ → List ℕ → Term → Term → Term → Term solverCallByVarIndices n varIndices R lhs rhs = solverCallAsTerm (variableList (rev varIndices)) lhs rhs where variableList : List ℕ → Arg Term variableList [] = varg (con (quote emptyVec) []) variableList (varIndex ∷ varIndices) = varg (con (quote _∷vec_) (varg (var (varIndex) []) ∷ (variableList varIndices) ∷ [])) module pr {n : ℕ} where 0' : Expr n 0' = K 0 1' : Expr n 1' = K 1 module _ where open pr `0` : List (Arg Term) → Term `0` [] = def (quote 0') [] `0` (varg fstcring ∷ xs) = `0` xs `0` (harg _ ∷ xs) = `0` xs `0` _ = unknown `1` : List (Arg Term) → Term `1` [] = def (quote 1') [] `1` (varg fstcring ∷ xs) = `1` xs `1` (harg _ ∷ xs) = `1` xs `1` _ = unknown mutual `_·_` : List (Arg Term) → Term `_·_` (harg _ ∷ xs) = `_·_` xs `_·_` (varg x ∷ varg y ∷ []) = con (quote _·'_) (varg (buildExpression x) ∷ varg (buildExpression y) ∷ []) `_·_` _ = unknown `_+_` : List (Arg Term) → Term `_+_` (harg _ ∷ xs) = `_+_` xs `_+_` (varg x ∷ varg y ∷ []) = con (quote _+'_) (varg (buildExpression x) ∷ varg (buildExpression y) ∷ []) `_+_` _ = unknown K' : List (Arg Term) → Term K' xs = con (quote K) xs finiteNumberAsTerm : ℕ → Term finiteNumberAsTerm ℕ.zero = con (quote fzero) [] finiteNumberAsTerm (ℕ.suc n) = con (quote fsuc) (varg (finiteNumberAsTerm n) ∷ []) buildExpression : Term → Term buildExpression (var index _) = con (quote ∣) (varg (finiteNumberAsTerm index) ∷ []) buildExpression t@(lit n) = K' (varg t ∷ []) buildExpression t@(def n xs) = switch (n ==_) cases case (quote _·_) ⇒ `_·_` xs break case (quote _+_) ⇒ `_+_` xs break default⇒ (K' xs) buildExpression t@(con n xs) = switch (n ==_) cases case (quote _·_) ⇒ `_·_` xs break case (quote _+_) ⇒ `_+_` xs break default⇒ (K' xs) buildExpression t = unknown toAlgebraExpression : Maybe (Term × Term) → Maybe (Term × Term) toAlgebraExpression nothing = nothing toAlgebraExpression (just (lhs , rhs)) = just (buildExpression lhs , buildExpression rhs) private adjustDeBruijnIndex : (n : ℕ) → Term → Term adjustDeBruijnIndex n (var k args) = var (k + n) args adjustDeBruijnIndex n _ = unknown extractVarIndices : Maybe (List Term) → Maybe (List ℕ) extractVarIndices (just ((var index _) ∷ l)) with extractVarIndices (just l) ... | just indices = just (index ∷ indices) ... | nothing = nothing extractVarIndices (just []) = just [] extractVarIndices _ = nothing getVarsAndEquation : Term → Maybe (List VarInfo × Term) getVarsAndEquation t = let (rawVars , equationTerm) = extractVars t maybeVars = addIndices (length rawVars) rawVars in map-Maybe (_, equationTerm) maybeVars where extractVars : Term → List (String × Arg Term) × Term extractVars (pi argType (abs varName t)) with extractVars t ... | xs , equation = (varName , argType) ∷ xs , equation extractVars equation = [] , equation addIndices : ℕ → List (String × Arg Term) → Maybe (List VarInfo) addIndices ℕ.zero [] = just [] addIndices (ℕ.suc countVar) ((varName , argType) ∷ list) = map-Maybe (λ varList → record { varName = varName ; varType = argType ; index = countVar } ∷ varList) (addIndices countVar list) addIndices _ _ = nothing toListOfTerms : Term → Maybe (List Term) toListOfTerms (con c []) = if (c == (quote [])) then just [] else nothing toListOfTerms (con c (varg t ∷ varg s ∷ args)) with toListOfTerms s ... | just terms = if (c == (quote _∷_)) then just (t ∷ terms) else nothing ... | nothing = nothing toListOfTerms (con c (harg t ∷ args)) = toListOfTerms (con c args) toListOfTerms _ = nothing solve-macro : Term → TC Unit solve-macro hole = do hole′ ← inferType hole >>= normalise just (varInfos , equation) ← returnTC (getVarsAndEquation hole′) where nothing → typeError (strErr "Something went wrong when getting the variable names in " ∷ termErr hole′ ∷ []) just (lhs , rhs) ← returnTC (toAlgebraExpression (getArgs equation)) where nothing → typeError( strErr "Error while trying to build ASTs for the equation " ∷ termErr equation ∷ []) let solution = solverCallWithLambdas (length varInfos) varInfos lhs rhs unify hole solution macro solve : Term → TC _ solve = solve-macro
{ "alphanum_fraction": 0.6113552678, "avg_line_length": 33.4087301587, "ext": "agda", "hexsha": "86b26eefa8a75f000339ca6d2014a15b5fe71f03", "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": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Algebra/NatSolver/Reflection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "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": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Algebra/NatSolver/Reflection.agda", "max_line_length": 109, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Algebra/NatSolver/Reflection.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 2520, "size": 8419 }
{-# OPTIONS --exact-split #-} module Issue1383 where data Bool : Set where true false : Bool xor : Bool → Bool → Bool xor = \ { true true -> false ; false false -> false ; {-# CATCHALL #-} _ _ -> true }
{ "alphanum_fraction": 0.5080645161, "avg_line_length": 20.6666666667, "ext": "agda", "hexsha": "127cb1435e528310bf3be317fce0ffd83094544e", "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/Issue1383.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/Issue1383.agda", "max_line_length": 32, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue1383.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 65, "size": 248 }
open import Function using (id) renaming (_∘′_ to _∘_) open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Control.Monad module Control.Monad.Error (E : Set) where -- The Error monad. data Error (A : Set) : Set where fail : (e : E) → Error A return : (a : A) → Error A -- The following are axiliary definitions for the constructor of errorIsMonad. module Local where -- Bind. _>>=_ : ∀ {A B} (m : Error A) (k : A → Error B) → Error B fail e >>= k = fail e return a >>= k = k a bind = _>>=_ -- Laws of bind. beta : ∀ {A B} (k : A → Error B) (a : A) → return a >>= k ≡ k a beta k a = refl eta : ∀ {A} (m : Error A) → m >>= return ≡ m eta (fail e) = refl eta (return a) = refl assoc : ∀ {A B C} (m : Error A) {k : A → Error B} {l : B → Error C} → (m >>= k) >>= l ≡ m >>= λ a → (k a >>= l) assoc (fail e) = refl assoc (return a) = refl open Local public -- The monad instance of Error. errorIsMonad : IsMonad Error errorIsMonad = record { ops = record { return = return ; _>>=_ = bind } ; laws = record { bind-β = beta ; bind-η = eta ; bind-assoc = assoc } }
{ "alphanum_fraction": 0.5470441299, "avg_line_length": 20.3559322034, "ext": "agda", "hexsha": "5698651c1de635ec6d2ad48e2728c37f5b32a9fd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_path": "src/Control/Monad/Error.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andreasabel/cubical", "max_issues_repo_path": "src/Control/Monad/Error.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_path": "src/Control/Monad/Error.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 423, "size": 1201 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Ints.QuoInt.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.HITs.Ints.QuoInt.Base renaming (_+ℤ_ to _+_) open import Cubical.Data.Nat hiding (+-comm; +-zero; _+_) +-pos-0 : ∀ a → pos 0 + a ≡ a +-pos-0 (pos zero) = refl +-pos-0 (pos (suc n)) = cong sucℤ (+-pos-0 (pos n)) +-pos-0 (neg zero) = posneg +-pos-0 (neg (suc n)) = cong predℤ (+-pos-0 (neg n)) +-pos-0 (posneg i) j = posneg (i ∧ j) +-neg-0 : ∀ a → neg 0 + a ≡ a +-neg-0 (neg zero) = refl +-neg-0 (neg (suc n)) = cong predℤ (+-neg-0 (neg n)) +-neg-0 (pos zero) = sym posneg +-neg-0 (pos (suc n)) = cong sucℤ (+-neg-0 (pos n)) +-neg-0 (posneg i) j = posneg (i ∨ ~ j) +-pos-suc : ∀ a b → sucℤ (pos b + a) ≡ (pos (suc b) + a) +-pos-suc (pos zero) b = refl +-pos-suc (pos (suc n)) b = cong sucℤ (+-pos-suc (pos n) b) +-pos-suc (neg zero) b = refl +-pos-suc (posneg i) b = refl +-pos-suc (neg (suc n)) b = sucPredℤ (pos b + neg n) ∙∙ sym (predSucℤ (pos b + neg n)) ∙∙ cong predℤ (+-pos-suc (neg n) b) -- the following hcomp does not termination-check: -- hcomp (λ j → λ -- { (i = i0) → sucPredℤ (pos b + neg n) (~ j) -- ; (i = i1) → {!predℤ ((+-pos-suc (neg n) b) j)!} -- }) (predSucℤ (pos b + neg n) (~ i)) +-neg-pred : ∀ a b → predℤ (neg b + a) ≡ (neg (suc b) + a) +-neg-pred (pos zero) b = refl +-neg-pred (neg zero) b = refl +-neg-pred (neg (suc n)) b = cong predℤ (+-neg-pred (neg n) b) +-neg-pred (posneg i) b = refl +-neg-pred (pos (suc n)) b = predSucℤ (neg b + pos n) ∙∙ sym (sucPredℤ (neg b + pos n)) ∙∙ cong sucℤ (+-neg-pred (pos n) b) +-comm : ∀ a b → a + b ≡ b + a +-comm a (pos zero) = sym (+-pos-0 a) +-comm a (neg zero) = sym (+-neg-0 a) +-comm a (pos (suc b)) = cong sucℤ (+-comm a (pos b)) ∙ +-pos-suc a b +-comm a (neg (suc b)) = cong predℤ (+-comm a (neg b)) ∙ +-neg-pred a b +-comm a (posneg i) = lemma a i where -- get some help from: -- https://www.codewars.com/kata/reviews/5c878e3ef1abb10001e32eb1/groups/5cca3f9e840f4b0001d8ac98 lemma : ∀ a → (λ i → (a + posneg i) ≡ (posneg i + a)) [ sym (+-pos-0 a) ≡ sym (+-neg-0 a) ] lemma (pos zero) i j = posneg (i ∧ j) lemma (pos (suc n)) i = cong sucℤ (lemma (pos n) i) lemma (neg zero) i j = posneg (i ∨ ~ j) lemma (neg (suc n)) i = cong predℤ (lemma (neg n) i) lemma (posneg i) j k = posneg ((i ∧ ~ k) ∨ (i ∧ j) ∨ (j ∧ k))
{ "alphanum_fraction": 0.5635113269, "avg_line_length": 35.8260869565, "ext": "agda", "hexsha": "96ddcf8fac7b0740347c6cf2f82bc8880e5b7e45", "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/HITs/Ints/QuoInt/Properties.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/HITs/Ints/QuoInt/Properties.agda", "max_line_length": 99, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/HITs/Ints/QuoInt/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 1074, "size": 2472 }
------------------------------------------------------------------------------ -- Totality properties for Forest ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Mirror.Forest.TotalityATP where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.List open import FOTC.Program.Mirror.Type ------------------------------------------------------------------------------ ++-Forest : ∀ {xs ys} → Forest xs → Forest ys → Forest (xs ++ ys) ++-Forest {ys = ys} fnil Fys = prf where postulate prf : Forest ([] ++ ys) {-# ATP prove prf #-} ++-Forest {ys = ys} (fcons {x} {xs} Tx Fxs) Fys = prf (++-Forest Fxs Fys) where postulate prf : Forest (xs ++ ys) → Forest ((x ∷ xs) ++ ys) {-# ATP prove prf #-} -- We don't use a combined proof, because it is necessary to erase a -- proof term which we don't know how to erase. map-Forest : ∀ {xs} f → (∀ {x} → Tree x → Tree (f · x)) → Forest xs → Forest (map f xs) map-Forest f fTree fnil = subst Forest (sym (map-[] f)) fnil map-Forest f fTree (fcons {x} {xs} Tx Fxs) = subst Forest (sym (map-∷ f x xs)) (fcons (fTree Tx) (map-Forest f fTree Fxs)) rev-Forest : ∀ {xs ys} → Forest xs → Forest ys → Forest (rev xs ys) rev-Forest {ys = ys} fnil Fys = prf where postulate prf : Forest (rev [] ys) {-# ATP prove prf #-} rev-Forest {ys = ys} (fcons {x} {xs} Tx Fxs) Fys = prf (rev-Forest Fxs (fcons Tx Fys)) where postulate prf : Forest (rev xs (x ∷ ys)) → Forest (rev (x ∷ xs) ys) {-# ATP prove prf #-} postulate reverse-Forest : ∀ {xs} → Forest xs → Forest (reverse xs) {-# ATP prove reverse-Forest rev-Forest #-}
{ "alphanum_fraction": 0.5054887611, "avg_line_length": 38.26, "ext": "agda", "hexsha": "f79980ba3ed801d2b176ffe0136e5b7a07d406fb", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/Mirror/Forest/TotalityATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/Mirror/Forest/TotalityATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/Mirror/Forest/TotalityATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 529, "size": 1913 }
{-# OPTIONS --safe --no-qualified-instances #-} module CF.Contexts.Lexical where open import Level open import Data.Unit open import Data.Product open import Data.String using (String) open import Data.List open import Data.List.Properties as LP open import Data.List.Relation.Binary.Sublist.Propositional.Properties open import Relation.Unary hiding (_⊢_; _⊆_; _∈_) open import Relation.Unary.PredicateTransformer using (Pt) open import Relation.Binary.Structures open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import CF.Types open import Data.List.Relation.Binary.Permutation.Propositional open import Data.List.Relation.Binary.Sublist.Propositional Ctx : Set Ctx = List Ty _⍮_ : Ctx → List Ty → Ctx Γ ⍮ Δ = Γ ++ Δ variable K K₁ K₂ K₃ K₄ : Ctx Δ Δ₁ Δ₂ : List Ty module CoDeBruijn where open import Relation.Ternary.Construct.List.Overlapping Ty public instance list-empty : ∀ {a} {A : Set a} → Emptiness {A = List A} [] list-empty = record {} Vars : Ctx → Pred Ctx 0ℓ Vars Γ = Own Γ Closed : ∀ {ℓ} → Pred Ctx ℓ → Set ℓ Closed P = P ε data _∼[_]_ : Ctx → Ctx → Ctx → Set where intros : ∀ {Γ Δ Δ′ Γ′} → Δ′ ⊆ Δ → Γ′ ≡ Γ ++ Δ′ → Γ ∼[ Δ ] Γ′ open import Relation.Ternary.Monad.Possibly open Possibly _∼[_]_ public using (possibly; ◇; module ◇-GradedMonad; module ◇-Zip; _∼_; pack) renaming ( ◇[_] to _⊢_) ∼-all : K ∼[ Δ ] (K ⍮ Δ) ∼-all = intros ⊆-refl refl ∼-none : K ∼[ Δ ] K ∼-none {Γ} {Δ} = intros (minimum Δ) (sym (++-identityʳ Γ)) ∼-refl : K ∼[ ε ] K ∼-refl = ∼-none ∼-trans : K₁ ∼ K₂ → K₂ ∼ K₃ → K₁ ∼ K₃ ∼-trans {K₁} (Δ₁ , intros {Δ′ = Δ₁′} p refl) (Δ₂ , intros {Δ′ = Δ₂′} q refl) = -, intros ⊆-refl (LP.++-assoc _ Δ₁′ Δ₂′) ∼-isPreorder : IsPreorder _≡_ _∼_ IsPreorder.isEquivalence ∼-isPreorder = isEquivalence IsPreorder.reflexive ∼-isPreorder refl = -, ∼-refl IsPreorder.trans ∼-isPreorder = ∼-trans -- frame preserving ∼-fp : K₁ ∼ K₂ → (di₁ : K₃ ◆ K₁) → ∃ λ (di₂ : K₃ ◆ K₂) → whole di₁ ∼ whole di₂ ∼-fp (_ , intros ext refl) (_ , σ₁) = (-, ∙-disjointᵣᵣ σ₁) , _ , intros ⊆-refl refl open ◇-Monad _∼[_]_ ∼-isPreorder ∼-fp public -- specialized version of graded join because I'm lazy ∼-goin : ∀ {p} {P : Pred Ctx p} → ∀[ Δ₁ ⊢ (Δ₂ ⊢ P) ⇒ (Δ₁ ++ Δ₂) ⊢ P ] ∼-goin (Possibly.possibly (intros {Γ} {Δ′ = Δ₁} r₁ refl) (Possibly.possibly (intros r₂ refl) px)) = possibly (intros (++⁺ r₁ r₂) (++-assoc Γ Δ₁ _ )) px module _ where open import Relation.Ternary.Construct.List.Overlapping Ty as Ov abstract ∼-pull : Δ₁ Ov.⊗ Δ₂ ≣ Δ → K₁ ∙ K₃ ≣ K → K₁ ∼[ Δ₁ ] K₂ → K₃ ∼[ Δ₂ ] K₄ → ∃ λ K' → K₂ ∙ K₄ ≣ K' × K ∼[ Δ ] K' ∼-pull δ σ₁ (intros p refl) (intros q refl) with _ , δ′ , r ← Ov.⊆-⊗ p q δ = -, ∙-parallel σ₁ δ′ , intros r refl open ◇-Zip ∼-pull public renaming (◇-zip to ⊢-zip) binders : ∀ {Γ} → ε[ Γ ⊢ Vars Γ ] binders = Possibly.possibly ∼-all refl Var : Ty → Pred Ctx 0ℓ Var a = Vars [ a ] pattern vars = refl module DeBruijn where open import Data.List.Membership.Propositional Var : Ty → Pred Ctx 0ℓ Var a Γ = a ∈ Γ _⊢_ : ∀ {ℓ} → List Ty → Pt Ctx ℓ Δ ⊢ P = λ Γ → P (Γ ⍮ Δ) -- ◇′ : Pt Ctx 0ℓ -- ◇′ P = ⋃[ as ∶ _ ] as ⊢ P open CoDeBruijn public
{ "alphanum_fraction": 0.6050101952, "avg_line_length": 27.685483871, "ext": "agda", "hexsha": "a919c1cb6dd595dfab1e970228a6b06fe1d20cde", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/CF/Contexts/Lexical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/CF/Contexts/Lexical.agda", "max_line_length": 85, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/CF/Contexts/Lexical.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z", "num_tokens": 1379, "size": 3433 }
------------------------------------------------------------------------ -- The Maybe type ------------------------------------------------------------------------ -- The definitions in this file are reexported by Data.Maybe. module Data.Maybe.Core where data Maybe (A : Set) : Set where just : (x : A) → Maybe A nothing : Maybe A {-# COMPILED_DATA Maybe Maybe Just Nothing #-}
{ "alphanum_fraction": 0.4226804124, "avg_line_length": 29.8461538462, "ext": "agda", "hexsha": "e8f979e0bd2de6ffc223ff8d5503a4a6dc4502b8", "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/Maybe/Core.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/Maybe/Core.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/Maybe/Core.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": 69, "size": 388 }
module Structure.Categorical.Proofs where open import Data open import Functional open import Logic.Propositional import Lvl open import Structure.Setoid open import Structure.Categorical.Properties import Structure.Relator.Names as Names open import Structure.Relator.Properties open import Type private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓₘ ℓₑ : Lvl.Level private variable Obj A B : Type{ℓ} private variable _▫_ : Obj → Obj → Type{ℓ} private variable f : A → B empty-morphism : ∀{ℓₘ ℓ} → Empty{ℓ} → Empty{ℓ} → Type{ℓₘ} empty-morphism{ℓₘ}{ℓ} = empty{T = Empty{ℓ} → Type{ℓₘ}} empty-id : Names.Reflexivity(empty-morphism{ℓₘ}{ℓ}) empty-id {x = ()} empty-comp : Names.SwappedTransitivity(empty-morphism{ℓₘ}{ℓ}) empty-comp {x = ()} empty-inv : Names.Symmetry(empty-morphism{ℓₘ}{ℓ}) empty-inv {x = ()} module _ ⦃ empty-equiv : ∀{x y} → Equiv{ℓₑ}(empty-morphism{ℓₘ}{ℓ} x y) ⦄ where instance empty-associativity : Morphism.Associativity{Morphism = empty-morphism} ⦃ empty-equiv ⦄ empty-comp empty-associativity = Morphism.intro \{} instance empty-identityₗ : Morphism.Identityₗ{Morphism = empty-morphism} ⦃ empty-equiv ⦄ empty-comp empty-id empty-identityₗ = Morphism.intro \{} instance empty-identityᵣ : Morphism.Identityᵣ{Morphism = empty-morphism} ⦃ empty-equiv ⦄ empty-comp empty-id empty-identityᵣ = Morphism.intro \{} empty-identity : Morphism.Identity empty-comp empty-id empty-identity = [∧]-intro empty-identityₗ empty-identityᵣ instance empty-inverterₗ : Polymorphism.Inverterₗ {Morphism = empty-morphism} ⦃ empty-equiv ⦄ empty-comp empty-id empty-inv empty-inverterₗ = Polymorphism.intro \{} instance empty-inverterᵣ : Polymorphism.Inverterᵣ {Morphism = empty-morphism} ⦃ empty-equiv ⦄ empty-comp empty-id empty-inv empty-inverterᵣ = Polymorphism.intro \{} empty-inverter : Polymorphism.Inverter empty-comp empty-id empty-inv empty-inverter = [∧]-intro empty-inverterₗ empty-inverterᵣ single-morphism : ∀{ℓₘ ℓ} → Unit{ℓ} → Unit{ℓ} → Type{ℓₘ} single-morphism <> <> = Unit single-id : Names.Reflexivity(single-morphism{ℓₘ}{ℓ}) single-id = <> single-comp : Names.SwappedTransitivity(single-morphism{ℓₘ}{ℓ}) single-comp <> <> = <> single-inv : Names.Symmetry(single-morphism{ℓₘ}{ℓ}) single-inv <> = <> module _ ⦃ single-equiv : ∀{x y} → Equiv{ℓₑ}(single-morphism{ℓₘ}{ℓ} x y) ⦄ where instance single-associativity : Morphism.Associativity{Morphism = single-morphism{ℓₘ}{ℓ₁}} ⦃ single-equiv ⦄ (single-comp{ℓ = ℓ₂}) Morphism.Associativity.proof single-associativity {<>}{<>}{<>}{<>}{<>}{<>}{<>} = Reflexivity.proof(Equiv.reflexivity (single-equiv {<>}{<>})) instance single-identityₗ : Morphism.Identityₗ{Morphism = single-morphism{ℓₘ}{ℓ₁}} ⦃ single-equiv ⦄ (single-comp{ℓ = ℓ₂}) (single-id{ℓ = ℓ₃}) Morphism.Identityₗ.proof single-identityₗ {<>}{<>}{<>} = Reflexivity.proof(Equiv.reflexivity (single-equiv {<>}{<>})) instance single-identityᵣ : Morphism.Identityᵣ{Morphism = single-morphism{ℓₘ}{ℓ₁}} ⦃ single-equiv ⦄ (single-comp{ℓ = ℓ₂}) (single-id{ℓ = ℓ₃}) Morphism.Identityᵣ.proof single-identityᵣ {<>}{<>}{<>} = Reflexivity.proof(Equiv.reflexivity (single-equiv {<>}{<>})) single-identity : Morphism.Identity{Morphism = single-morphism{ℓₘ}{ℓ₁}} (single-comp{ℓ = ℓ₂}) (single-id{ℓ = ℓ₃}) single-identity{ℓ₁}{ℓ₂}{ℓ₃} = [∧]-intro (single-identityₗ{ℓ₁}{ℓ₂}{ℓ₃}) (single-identityᵣ{ℓ₁}{ℓ₂}{ℓ₃}) instance single-inverterₗ : Polymorphism.Inverterₗ {Morphism = single-morphism{ℓₘ}{ℓ₁}} ⦃ single-equiv ⦄ (single-comp{ℓ = ℓ₂}) (single-id{ℓ = ℓ₃}) (single-inv{ℓ = ℓ₄}) Polymorphism.Inverterₗ.proof single-inverterₗ {<>}{<>}{<>} = Reflexivity.proof(Equiv.reflexivity (single-equiv {<>}{<>})) instance single-inverterᵣ : Polymorphism.Inverterᵣ {Morphism = single-morphism{ℓₘ}{ℓ₁}} ⦃ single-equiv ⦄ (single-comp{ℓ = ℓ₂}) (single-id{ℓ = ℓ₃}) (single-inv{ℓ = ℓ₄}) Polymorphism.Inverterᵣ.proof single-inverterᵣ {<>}{<>}{<>} = Reflexivity.proof(Equiv.reflexivity (single-equiv {<>}{<>})) single-inverter : Polymorphism.Inverter {Morphism = single-morphism{ℓₘ}{ℓ₁}} ⦃ single-equiv ⦄ (single-comp{ℓ = ℓ₂}) (single-id{ℓ = ℓ₃}) (single-inv{ℓ = ℓ₄}) single-inverter{ℓ₁}{ℓ₂}{ℓ₃}{ℓ₄} = [∧]-intro (single-inverterₗ{ℓ₁}{ℓ₂}{ℓ₃}{ℓ₄}) (single-inverterᵣ{ℓ₁}{ℓ₂}{ℓ₃}{ℓ₄}) module _ {Morphism : B → B → Type{ℓₘ}} ⦃ morphism-equiv : ∀{x y} → Equiv{ℓₑ}(Morphism x y) ⦄ (f : A → B) where module _ {comp : Names.SwappedTransitivity(Morphism)} where on₂-associativity : Morphism.Associativity{Morphism = Morphism} ⦃ morphism-equiv ⦄ comp → Morphism.Associativity{Morphism = Morphism on₂ f} comp Morphism.Associativity.proof (on₂-associativity p) = Morphism.Associativity.proof p module _ {id : Names.Reflexivity(Morphism)} where on₂-identityₗ : Morphism.Identityₗ{Morphism = Morphism} ⦃ morphism-equiv ⦄ comp id → Morphism.Identityₗ{Morphism = Morphism on₂ f} comp id Morphism.Identityₗ.proof (on₂-identityₗ p) = Morphism.Identityₗ.proof p on₂-identityᵣ : Morphism.Identityᵣ{Morphism = Morphism} ⦃ morphism-equiv ⦄ comp id → Morphism.Identityᵣ{Morphism = Morphism on₂ f} comp id Morphism.Identityᵣ.proof (on₂-identityᵣ p) = Morphism.Identityᵣ.proof p on₂-identity : Morphism.Identity{Morphism = Morphism} ⦃ morphism-equiv ⦄ comp id → Morphism.Identity{Morphism = Morphism on₂ f} comp id on₂-identity ([∧]-intro l r) = [∧]-intro (on₂-identityₗ l) (on₂-identityᵣ r) module _ {inv : Names.Symmetry(Morphism)} where on₂-inverterₗ : Polymorphism.Inverterₗ {Morphism = Morphism} ⦃ morphism-equiv ⦄ comp id inv → Polymorphism.Inverterₗ {Morphism = Morphism on₂ f} comp id inv Polymorphism.Inverterₗ.proof (on₂-inverterₗ p) = Polymorphism.Inverterₗ.proof p on₂-inverterᵣ : Polymorphism.Inverterᵣ {Morphism = Morphism} ⦃ morphism-equiv ⦄ comp id inv → Polymorphism.Inverterᵣ {Morphism = Morphism on₂ f} comp id inv Polymorphism.Inverterᵣ.proof (on₂-inverterᵣ p) = Polymorphism.Inverterᵣ.proof p on₂-inverter : Polymorphism.Inverter{Morphism = Morphism} ⦃ morphism-equiv ⦄ comp id inv → Polymorphism.Inverter{Morphism = Morphism on₂ f} comp id inv on₂-inverter ([∧]-intro l r) = [∧]-intro (on₂-inverterₗ l) (on₂-inverterᵣ r)
{ "alphanum_fraction": 0.7001766501, "avg_line_length": 51.8916666667, "ext": "agda", "hexsha": "148173474682af919183eda62b2b4e5bcc2d957e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Categorical/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": "Structure/Categorical/Proofs.agda", "max_line_length": 164, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Categorical/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": 2284, "size": 6227 }
module Lvl.Proofs where open import Data.Tuple as Tuple using () open import Logic.Predicate open import Lvl open import Structure.Setoid open import Structure.Function.Domain open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Type private variable ℓ ℓ₁ ℓ₂ ℓₑ : Lvl.Level private variable T : Type{ℓ} instance LvlUp-equiv : ⦃ equiv : Equiv{ℓₑ}(T) ⦄ → Equiv(Lvl.Up{ℓ}(T)) Equiv._≡_ (LvlUp-equiv {ℓ = ℓ}) (up x) (up y) = Lvl.Up{ℓ}(x ≡ y) Up.obj (Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence LvlUp-equiv))) = reflexivity(_≡_) Up.obj (Symmetry.proof (Equivalence.symmetry (Equiv.equivalence LvlUp-equiv)) (up p)) = symmetry(_≡_) p Up.obj (Transitivity.proof (Equivalence.transitivity (Equiv.equivalence LvlUp-equiv)) (up p) (up q)) = transitivity(_≡_) p q instance LvlUpObj-bijective : ⦃ equiv : Equiv{ℓₑ}(T) ⦄ → Bijective(Lvl.Up.obj{ℓ}{T = T}) Up.obj (∃.witness (Tuple.left (Bijective.proof LvlUpObj-bijective {y}))) = y ∃.proof (Tuple.left (Bijective.proof LvlUpObj-bijective)) = reflexivity(_≡_) Up.obj (Tuple.right (Bijective.proof LvlUpObj-bijective) p q) = transitivity(_≡_) p (symmetry(_≡_) q)
{ "alphanum_fraction": 0.7254237288, "avg_line_length": 43.7037037037, "ext": "agda", "hexsha": "253b4591f71649345259dbfb1b658ca24a374dbe", "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": "Lvl/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": "Lvl/Proofs.agda", "max_line_length": 126, "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": "Lvl/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": 411, "size": 1180 }
------------------------------------------------------------------------ -- Simple kinding of Fω with interval kinds ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module FOmegaInt.Kinding.Simple where open import Data.Context.WellFormed open import Data.Fin using (Fin; zero; suc) open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Fin.Substitution.ExtraLemmas open import Data.Fin.Substitution.Typed open import Data.List as List using ([]; _∷_; _∷ʳ_; map) open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Product as Prod using (∃; _,_; _×_) open import Data.Vec as Vec using ([]; _∷_) import Data.Vec.Properties as VecProps open import Function using (_∘_) import Level open import Relation.Binary.PropositionalEquality as PropEq using (refl; _≡_) open import Relation.Nullary.Negation open import FOmegaInt.Syntax open import FOmegaInt.Syntax.SingleVariableSubstitution open import FOmegaInt.Syntax.HereditarySubstitution open import FOmegaInt.Syntax.Normalization ------------------------------------------------------------------------ -- Simple kinding derivations. -- -- TODO: explain the point of this and how "simple" kinding differs -- from "canonical" kinding. module Kinding where open SimpleCtx open Syntax infix 4 _⊢Var_∈_ _⊢_kds _⊢Nf_∈_ _⊢Ne_∈_ _⊢_∋∙_∈_ _⊢_wfs -- Simple kinding of variables. data _⊢Var_∈_ {n} (Γ : Ctx n) : Fin n → SKind → Set where ∈-var : ∀ {k} x → lookup Γ x ≡ kd k → Γ ⊢Var x ∈ k mutual -- Simplified well-formedness of kinds: a variant of -- well-formedness for η-long β-normal kinds based on simple -- kinding. data _⊢_kds {n} (Γ : Ctx n) : Kind Elim n → Set where kds-⋯ : ∀ {a b} → Γ ⊢Nf a ∈ ★ → Γ ⊢Nf b ∈ ★ → Γ ⊢ a ⋯ b kds kds-Π : ∀ {j k} → Γ ⊢ j kds → kd ⌊ j ⌋ ∷ Γ ⊢ k kds → Γ ⊢ Π j k kds -- Simple kinding of η-long β-normal types. data _⊢Nf_∈_ {n} (Γ : Ctx n) : Elim n → SKind → Set where ∈-⊥-f : Γ ⊢Nf ⊥∙ ∈ ★ ∈-⊤-f : Γ ⊢Nf ⊤∙ ∈ ★ ∈-∀-f : ∀ {k a} → Γ ⊢ k kds → kd ⌊ k ⌋ ∷ Γ ⊢Nf a ∈ ★ → Γ ⊢Nf ∀∙ k a ∈ ★ ∈-→-f : ∀ {a b} → Γ ⊢Nf a ∈ ★ → Γ ⊢Nf b ∈ ★ → Γ ⊢Nf a ⇒∙ b ∈ ★ ∈-Π-i : ∀ {j a k} → Γ ⊢ j kds → kd ⌊ j ⌋ ∷ Γ ⊢Nf a ∈ k → Γ ⊢Nf Λ∙ j a ∈ ⌊ j ⌋ ⇒ k ∈-ne : ∀ {a} → Γ ⊢Ne a ∈ ★ → Γ ⊢Nf a ∈ ★ -- Simple kinding of neutral types. data _⊢Ne_∈_ {n} (Γ : Ctx n) : Elim n → SKind → Set where ∈-∙ : ∀ {x j k} {as : Spine n} → Γ ⊢Var x ∈ j → Γ ⊢ j ∋∙ as ∈ k → Γ ⊢Ne var x ∙ as ∈ k -- Simple spine kinding. data _⊢_∋∙_∈_ {n} (Γ : Ctx n) : SKind → Spine n → SKind → Set where ∈-[] : ∀ {k} → Γ ⊢ k ∋∙ [] ∈ k ∈-∷ : ∀ {a as j k l} → Γ ⊢Nf a ∈ j → Γ ⊢ k ∋∙ as ∈ l → Γ ⊢ j ⇒ k ∋∙ a ∷ as ∈ l open ContextConversions using (⌊_⌋Ctx) -- Simple well-formedness of ascriptions data _⊢_wfs {n} (Γ : Ctx n) : ElimAsc n → Set where wfs-kd : ∀ {a} → Γ ⊢ a kds → Γ ⊢ kd a wfs wfs-tp : ∀ {a} → Γ ⊢Nf a ∈ ★ → Γ ⊢ tp a wfs -- Simply well-formed contexts and context extensions. module SimplyWfCtx = ContextFormation (λ Γ a → ⌊ Γ ⌋Ctx ⊢ a wfs) open SimplyWfCtx public using () renaming (_wf to _ctxs; _⊢_wfExt to _⊢_exts) open Syntax open SimpleCtx open Kinding open PropEq -- An admissible kinding rule for spine concatenation. ∈-++ : ∀ {n} {Γ : Ctx n} {as bs j k l} → Γ ⊢ j ∋∙ as ∈ k → Γ ⊢ k ∋∙ bs ∈ l → Γ ⊢ j ∋∙ as List.++ bs ∈ l ∈-++ ∈-[] k∋as∈l = k∋as∈l ∈-++ (∈-∷ b∈j₁ j₂∋as∈k) k∋as∈l = ∈-∷ b∈j₁ (∈-++ j₂∋as∈k k∋as∈l) -- An admissible kinding rule for appending a normal form to a spine. ∈-∷ʳ : ∀ {n} {Γ : Ctx n} {as a j k l} → Γ ⊢ j ∋∙ as ∈ k ⇒ l → Γ ⊢Nf a ∈ k → Γ ⊢ j ∋∙ as ∷ʳ a ∈ l ∈-∷ʳ j∋as∈k⇒k a∈k = ∈-++ j∋as∈k⇒k (∈-∷ a∈k ∈-[]) -- An admissible kinding rule for post-application to neutral types. Ne∈-Π-e : ∀ {n} {Γ : Ctx n} {a b j k} → Γ ⊢Ne a ∈ j ⇒ k → Γ ⊢Nf b ∈ j → Γ ⊢Ne a ⌜·⌝ b ∈ k Ne∈-Π-e (∈-∙ x∈j j∋as∈k) b∈k = ∈-∙ x∈j (∈-∷ʳ j∋as∈k b∈k) -- An inversion lemma for _⊢_wf. wfs-kd-inv : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ kd k wfs → Γ ⊢ k kds wfs-kd-inv (wfs-kd k-kds) = k-kds -- An inversion lemma for type operators. Nf∈-⇒-inv : ∀ {n} {Γ : Ctx n} {a k₁ k₂} → Γ ⊢Nf a ∈ k₁ ⇒ k₂ → ∃ λ j → ∃ λ b → Γ ⊢ j kds × kd k₁ ∷ Γ ⊢Nf b ∈ k₂ × ⌊ j ⌋ ≡ k₁ × a ≡ Λ∙ j b Nf∈-⇒-inv (∈-Π-i j-kds b∈k₂) = _ , _ , j-kds , b∈k₂ , refl , refl ---------------------------------------------------------------------- -- Well-kinded substitutions (i.e. substitution lemmas) in canonical -- types -- Well-kinded variable substitutions (renamings). module KindedRenaming where open ⊤-WellFormed SimpleCtx.weakenOps typedVarSubst : TypedVarSubst SAsc Level.zero typedVarSubst = record { _⊢_wf = _⊢_wf ; typeExtension = SimpleCtx.weakenOps ; typeVarApplication = record { _/_ = λ k _ → k } ; /-wk = refl ; id-vanishes = λ _ → refl ; /-⊙ = λ _ → refl ; wf-wf = λ _ → ctx-wf _ } open TypedVarSubst typedVarSubst public hiding (∈-weaken) renaming (_⊢Var_∈_ to _⊢Var′_∈_; lookup to ∈-lookup) open Substitution hiding (subst; _/Var_) renaming (_Elim/Var_ to _/Var_) open RenamingCommutes using (Kind[∈⌊⌋]-/Var) open PropEq open ≡-Reasoning -- A helper. ∈-↑′ : ∀ {m n} {Δ : Ctx n} {Γ : Ctx m} {k ρ} → Δ ⊢/Var ρ ∈ Γ → kd ⌊ k Kind′/Var ρ ⌋ ∷ Δ ⊢/Var ρ VarSubst.↑ ∈ kd ⌊ k ⌋ ∷ Γ ∈-↑′ {Δ = Δ} {_} {k} ρ∈Γ = subst (λ j → kd j ∷ Δ ⊢/Var _ ∈ _) (sym (⌊⌋-Kind′/Var k)) (∈-↑ _ ρ∈Γ) -- Convert between well-kindedness judgments for variables. Var∈′-Var∈ : ∀ {n} {Γ : Ctx n} {x a k} → a ≡ kd k → Γ ⊢Var′ x ∈ a → Γ ⊢Var x ∈ k Var∈′-Var∈ Γ[x]≡kd-k (∈-var x Γ-ctx) = ∈-var x Γ[x]≡kd-k -- Renamings preserve synthesized kinds of variables. Var∈-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {x k ρ} → Γ ⊢Var x ∈ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢Var Vec.lookup ρ x ∈ k Var∈-/Var (∈-var x Γ[x]≡kd-k) ρ∈Γ = Var∈′-Var∈ Γ[x]≡kd-k (∈-lookup ρ∈Γ x) mutual -- Renamings preserve well-formedness of kinds. kds-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {k ρ} → Γ ⊢ k kds → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ k Kind′/Var ρ kds kds-/Var (kds-⋯ a∈★ b∈★) ρ∈Γ = kds-⋯ (Nf∈-/Var a∈★ ρ∈Γ) (Nf∈-/Var b∈★ ρ∈Γ) kds-/Var (kds-Π j-kds k-kds) ρ∈Γ = kds-Π (kds-/Var j-kds ρ∈Γ) (kds-/Var k-kds (∈-↑′ ρ∈Γ)) -- Renamings preserve synthesized kinds of normal types. Nf∈-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a k ρ} → Γ ⊢Nf a ∈ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢Nf a /Var ρ ∈ k Nf∈-/Var ∈-⊥-f ρ∈Γ = ∈-⊥-f Nf∈-/Var ∈-⊤-f ρ∈Γ = ∈-⊤-f Nf∈-/Var (∈-∀-f k-kds a∈★) ρ∈Γ = ∈-∀-f (kds-/Var k-kds ρ∈Γ) (Nf∈-/Var a∈★ (∈-↑′ ρ∈Γ)) Nf∈-/Var (∈-→-f a∈★ b∈★) ρ∈Γ = ∈-→-f (Nf∈-/Var a∈★ ρ∈Γ) (Nf∈-/Var b∈★ ρ∈Γ) Nf∈-/Var (∈-Π-i {j} {a} {k} j-kds a∈k) ρ∈Γ = subst (λ l → _ ⊢Nf Λ∙ j a /Var _ ∈ l ⇒ k) (⌊⌋-Kind′/Var j) (∈-Π-i (kds-/Var j-kds ρ∈Γ) (Nf∈-/Var a∈k (∈-↑′ ρ∈Γ))) Nf∈-/Var (∈-ne a∈★) ρ∈Γ = ∈-ne (Ne∈-/Var a∈★ ρ∈Γ) -- Renamings preserve synthesized kinds of neutral types. Ne∈-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a k ρ} → Γ ⊢Ne a ∈ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢Ne a /Var ρ ∈ k Ne∈-/Var (∈-∙ x∈j k∈as∈l) ρ∈Γ = ∈-∙ (Var∈-/Var x∈j ρ∈Γ) (Sp∈-/Var k∈as∈l ρ∈Γ) Sp∈-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {as j k ρ} → Γ ⊢ j ∋∙ as ∈ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ j ∋∙ as //Var ρ ∈ k Sp∈-/Var ∈-[] ρ∈Γ = ∈-[] Sp∈-/Var (∈-∷ a∈j k[a]∈as∈l) ρ∈Γ = ∈-∷ (Nf∈-/Var a∈j ρ∈Γ) (Sp∈-/Var k[a]∈as∈l ρ∈Γ) -- Renamings preserve well-formedness of ascriptions. wfs-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a ρ} → Γ ⊢ a wfs → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ a ElimAsc/Var ρ wfs wfs-/Var (wfs-kd k-kds) ρ∈Γ = wfs-kd (kds-/Var k-kds ρ∈Γ) wfs-/Var (wfs-tp a∈★) ρ∈Γ = wfs-tp (Nf∈-/Var a∈★ ρ∈Γ) -- Weakening preserves simple well-formedness of kinds. kds-weaken : ∀ {n} {Γ : Ctx n} {k a} → Γ ⊢ k kds → a ∷ Γ ⊢ weakenKind′ k kds kds-weaken k-kds = kds-/Var k-kds (∈-wk _) kds-weaken⋆ : ∀ {m n} (Δ : CtxExt m n) {Γ : Ctx m} {k} → Γ ⊢ k kds → Δ ++ Γ ⊢ weakenKind′⋆ n k kds kds-weaken⋆ [] k-kds = k-kds kds-weaken⋆ (_ ∷ Δ′) k-kds = kds-weaken (kds-weaken⋆ Δ′ k-kds) -- Weakening preserves kinding of normal forms. Nf∈-weaken : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢Nf b ∈ k → (a ∷ Γ) ⊢Nf weakenElim b ∈ k Nf∈-weaken b∈k = Nf∈-/Var b∈k (∈-wk _) Nf∈-weaken⋆ : ∀ {m n} (Δ : CtxExt m n) {Γ : Ctx m} {a k} → Γ ⊢Nf a ∈ k → Δ ++ Γ ⊢Nf weakenElim⋆ n a ∈ k Nf∈-weaken⋆ [] a∈k = a∈k Nf∈-weaken⋆ (_ ∷ Δ′) a∈k = Nf∈-weaken (Nf∈-weaken⋆ Δ′ a∈k) -- Weakening preserves kinding of neutral forms. Ne∈-weaken : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢Ne b ∈ k → (a ∷ Γ) ⊢Ne weakenElim b ∈ k Ne∈-weaken b∈k = Ne∈-/Var b∈k (∈-wk _) -- Weakening preserves spine kinding. Sp∈-weaken : ∀ {n} {Γ : Ctx n} {a bs j k} → Γ ⊢ j ∋∙ bs ∈ k → (a ∷ Γ) ⊢ j ∋∙ weakenSpine bs ∈ k Sp∈-weaken j∋bs∈k = Sp∈-/Var j∋bs∈k (∈-wk _) -- Weakening preserves simple well-formedness of ascriptions. wfs-weaken : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ b wfs → a ∷ Γ ⊢ weakenElimAsc b wfs wfs-weaken b-wfs = wfs-/Var b-wfs (∈-wk _) -- Operations on simply well-formed contexts that require weakening of -- well-formedness judgments. module WfsCtxOps where open SimplyWfCtx open ContextConversions using (⌊_⌋Ctx) open KindedRenaming using (wfs-weaken) wfsWeakenOps : WellFormedWeakenOps ElimCtx.weakenOps wfsWeakenOps = record { wf-weaken = λ _ → wfs-weaken } private module W = WellFormedWeakenOps wfsWeakenOps open W public hiding (wf-weaken) -- Lookup the kind of a type variable in a well-formed context. lookup-kd : ∀ {m} {Γ : ElimCtx.Ctx m} {a} x → Γ ctxs → ElimCtx.lookup Γ x ≡ kd a → ⌊ Γ ⌋Ctx ⊢ a kds lookup-kd x Γ-ctxs Γ[x]≡kd-a = wfs-kd-inv (subst (_ ⊢_wfs) Γ[x]≡kd-a (W.lookup Γ-ctxs x)) module KindedHereditarySubstitution where open Data.Fin using (zero; raise; lift) open Substitution hiding (subst; sub; _↑; _↑⋆_) open KindedRenaming using (_⊢/Var_∈_; Nf∈-/Var; Nf∈-weaken⋆; ∈-wk) open RenamingCommutes using (wk-/⟨⟩-↑⋆; /Var-wk-↑⋆-hsub-vanishes) open PropEq open ≡-Reasoning private module V = VarSubst infix 4 _⊢/⟨_⟩_∈_ _⊢?⟨_⟩_∈_ -- Simply well-kinded hereditary substitions and lookup results. data _⊢/⟨_⟩_∈_ : ∀ {m n} → Ctx n → SKind → SVSub m n → Ctx m → Set where ∈-hsub : ∀ {n} {Γ : Ctx n} {k a} → Γ ⊢Nf a ∈ k → Γ ⊢/⟨ k ⟩ sub a ∈ kd k ∷ Γ ∈-H↑ : ∀ {m n Δ k Γ} {σ : SVSub m n} {a} → Δ ⊢/⟨ k ⟩ σ ∈ Γ → a ∷ Δ ⊢/⟨ k ⟩ σ ↑ ∈ a ∷ Γ data _⊢?⟨_⟩_∈_ {n} (Γ : Ctx n) (k : SKind) : SVRes n → SAsc n → Set where ∈-hit : ∀ {a} → Γ ⊢Nf a ∈ k → Γ ⊢?⟨ k ⟩ hit a ∈ kd k ∈-miss : ∀ y {a} → lookup Γ y ≡ a → Γ ⊢?⟨ k ⟩ miss y ∈ a -- A variant of `∈-H↑' that applies `σ' in the target context ∈-H↑′ : ∀ {m n Δ k Γ} {σ : SVSub m n} {j} → Δ ⊢/⟨ k ⟩ σ ∈ Γ → kd ⌊ j Kind/⟨ k ⟩ σ ⌋ ∷ Δ ⊢/⟨ k ⟩ σ ↑ ∈ kd ⌊ j ⌋ ∷ Γ ∈-H↑′ σ∈Γ = subst (λ k → kd k ∷ _ ⊢/⟨ _ ⟩ _ ↑ ∈ kd _ ∷ _) (sym (⌊⌋-Kind/⟨⟩ _)) (∈-H↑ σ∈Γ) -- Lift a kinded hereditary substitution over multiple additional -- variables. ∈-H↑⋆ : ∀ {m n i} (E : CtxExt m i) {Δ k Γ} {σ : SVSub m n} → Δ ⊢/⟨ k ⟩ σ ∈ Γ → re-idx E ++ Δ ⊢/⟨ k ⟩ σ ↑⋆ i ∈ E ++ Γ ∈-H↑⋆ [] σ∈Γ = σ∈Γ ∈-H↑⋆ (a ∷ E) σ∈Γ = ∈-H↑ (∈-H↑⋆ E σ∈Γ) -- Renamings preserve well-kinded SV results. ?∈-/Var : ∀ {m n Γ k Δ r a} {ρ : Sub Fin m n} → Γ ⊢?⟨ k ⟩ r ∈ a → Δ ⊢/Var ρ ∈ Γ → Δ ⊢?⟨ k ⟩ r ?/Var ρ ∈ a ?∈-/Var (∈-hit a∈k) ρ∈Γ = ∈-hit (Nf∈-/Var a∈k ρ∈Γ) ?∈-/Var {Γ = Γ} {k} {Δ} (∈-miss y refl) ρ∈Γ = helper refl (TV.lookup ρ∈Γ y) where module TV = TypedVarSubst KindedRenaming.typedVarSubst helper : ∀ {x a} → a ≡ lookup Γ y → Δ TV.⊢Var x ∈ a → Δ ⊢?⟨ k ⟩ miss x ∈ lookup Γ y helper Δ[x]≡Γ[y] (TV.∈-var x _) = ∈-miss x Δ[x]≡Γ[y] ?∈-weaken : ∀ {n} {Γ : Ctx n} {k r a b} → Γ ⊢?⟨ k ⟩ r ∈ a → (b ∷ Γ) ⊢?⟨ k ⟩ weakenSVRes r ∈ a ?∈-weaken r∈a = ?∈-/Var r∈a (∈-wk _) -- Look up a variable in a well-kinded hereditary substitution. lookup-/⟨⟩∈ : ∀ {m n Δ k Γ} {σ : SVSub m n} → Δ ⊢/⟨ k ⟩ σ ∈ Γ → (x : Fin m) → Δ ⊢?⟨ k ⟩ lookupSV σ x ∈ lookup Γ x lookup-/⟨⟩∈ (∈-hsub a∈k) zero = ∈-hit a∈k lookup-/⟨⟩∈ {Γ = kd k ∷ Γ} (∈-hsub a∈k) (suc x) = ∈-miss x (cong (λ Γ → Vec.lookup Γ x) (sym (VecProps.map-id (toVec Γ)))) lookup-/⟨⟩∈ (∈-H↑ σ∈Γ) zero = ∈-miss zero refl lookup-/⟨⟩∈ (∈-H↑ {Δ = Δ} {_} {Γ} {σ} σ∈Γ) (suc x) = ?∈-weaken (subst (λ as → Δ ⊢?⟨ _ ⟩ lookupSV σ x ∈ Vec.lookup as x) (sym (VecProps.map-id (toVec Γ))) (lookup-/⟨⟩∈ σ∈Γ x)) -- Lookup a hit in a well-kinded hereditary substitution. -- -- NOTE. Since `j ≡ k', we could have formulated this lemma -- differently. In particular, given the premise `Γ ⊢Var x ∈ j', it -- would have been more intuitive for the kinding judgment in the -- conclusion to use the shape `j' rather than `k' (preserving the -- kind of the variable, as usual for substitution lemmas). -- However, it is important that the shape `k' of the normal type -- returned by this function is syntactically equal to the shape -- annotation of the hereditary substitution `Δ ⊢/⟨ k ⟩ σ ∈ Γ' -- because it serves as the termination measure for the (hereditary) -- substitution lemmas below. lookup-/⟨⟩∈-Hit : ∀ {m n Δ k} {σ : SVSub m n} {Γ x j a} → Δ ⊢/⟨ k ⟩ σ ∈ Γ → Γ ⊢Var x ∈ j → Hit σ x a → Δ ⊢Nf a ∈ k × j ≡ k lookup-/⟨⟩∈-Hit σ∈Γ (∈-var {j} x Γ[x]≡kd-j) hitP = let a∈k , Γ[x]≡kd-k = helper (lookup-Hit hitP) (lookup-/⟨⟩∈ σ∈Γ x) in a∈k , kd-inj′ (trans (sym Γ[x]≡kd-j) Γ[x]≡kd-k) where helper : ∀ {n} {Δ : Ctx n} {r a b k} → r ≡ hit a → Δ ⊢?⟨ k ⟩ r ∈ b → Δ ⊢Nf a ∈ k × b ≡ kd k helper refl (∈-hit a∈k) = a∈k , refl lookup-/⟨⟩∈-Miss : ∀ {m n Δ k} {σ : SVSub m n} {Γ x y j} → Δ ⊢/⟨ k ⟩ σ ∈ Γ → Γ ⊢Var x ∈ j → Miss σ x y → lookup Δ y ≡ lookup Γ x lookup-/⟨⟩∈-Miss σ∈Γ (∈-var {j} x Γ[x]≡kd-j) missP = helper (lookup-Miss missP) (lookup-/⟨⟩∈ σ∈Γ x) where helper : ∀ {n} {Δ : Ctx n} {r y b k} → r ≡ miss y → Δ ⊢?⟨ k ⟩ r ∈ b → lookup Δ y ≡ b helper refl (∈-miss y Δ[y]≡b) = Δ[y]≡b open KindSimpLemmas simpLemmasKind′ -- TODO: explain why this terminates. mutual -- Hereditary substitutions preserve simple well-formedness and -- kinding (of kinds, normal types and spines). kds-/⟨⟩ : ∀ {m n Γ k Δ} {σ : SVSub m n} {j} → Γ ⊢ j kds → Δ ⊢/⟨ k ⟩ σ ∈ Γ → Δ ⊢ j Kind/⟨ k ⟩ σ kds kds-/⟨⟩ (kds-⋯ a∈★ b∈★) σ∈Γ = kds-⋯ (Nf∈-/⟨⟩ a∈★ σ∈Γ) (Nf∈-/⟨⟩ b∈★ σ∈Γ) kds-/⟨⟩ (kds-Π j-kds k-kds) σ∈Γ = kds-Π (kds-/⟨⟩ j-kds σ∈Γ) (kds-/⟨⟩ k-kds (∈-H↑′ σ∈Γ)) Nf∈-/⟨⟩ : ∀ {m n Γ k Δ} {σ : SVSub m n} {a j} → Γ ⊢Nf a ∈ j → Δ ⊢/⟨ k ⟩ σ ∈ Γ → Δ ⊢Nf a /⟨ k ⟩ σ ∈ j Nf∈-/⟨⟩ ∈-⊥-f σ∈Γ = ∈-⊥-f Nf∈-/⟨⟩ ∈-⊤-f σ∈Γ = ∈-⊤-f Nf∈-/⟨⟩ (∈-∀-f k-kds a∈★) σ∈Γ = ∈-∀-f (kds-/⟨⟩ k-kds σ∈Γ) (Nf∈-/⟨⟩ a∈★ (∈-H↑′ σ∈Γ)) Nf∈-/⟨⟩ (∈-→-f a∈★ b∈★) σ∈Γ = ∈-→-f (Nf∈-/⟨⟩ a∈★ σ∈Γ) (Nf∈-/⟨⟩ b∈★ σ∈Γ) Nf∈-/⟨⟩ (∈-Π-i {j} {a} {k} j-kds a∈k) σ∈Γ = subst (λ l → _ ⊢Nf Λ∙ j a /⟨ _ ⟩ _ ∈ l ⇒ k) (⌊⌋-Kind/⟨⟩ j) (∈-Π-i (kds-/⟨⟩ j-kds σ∈Γ) (Nf∈-/⟨⟩ a∈k (∈-H↑′ σ∈Γ))) Nf∈-/⟨⟩ (∈-ne a∈★) σ∈Γ = Ne∈-/⟨⟩ a∈★ σ∈Γ Sp∈-/⟨⟩ : ∀ {m n Γ k Δ} {σ : SVSub m n} {as j₁ j₂} → Γ ⊢ j₁ ∋∙ as ∈ j₂ → Δ ⊢/⟨ k ⟩ σ ∈ Γ → Δ ⊢ j₁ ∋∙ as //⟨ k ⟩ σ ∈ j₂ Sp∈-/⟨⟩ ∈-[] σ∈Γ = ∈-[] Sp∈-/⟨⟩ (∈-∷ a∈j₁ j₂[a]∈as∈j₃) σ∈Γ = ∈-∷ (Nf∈-/⟨⟩ a∈j₁ σ∈Γ) (Sp∈-/⟨⟩ j₂[a]∈as∈j₃ σ∈Γ) -- Hereditary substitutions preserve the shapes of neutral types -- (but not neutrality itself). Ne∈-/⟨⟩ : ∀ {m n Γ k Δ} {σ : SVSub m n} {a} → Γ ⊢Ne a ∈ ★ → Δ ⊢/⟨ k ⟩ σ ∈ Γ → Δ ⊢Nf a /⟨ k ⟩ σ ∈ ★ Ne∈-/⟨⟩ (∈-∙ (∈-var x Γ[x]≡kd-j) j∈as∈l) σ∈Γ = ?⟨⟩∈-?∙∙ (subst (_ ⊢?⟨ _ ⟩ _ ∈_) Γ[x]≡kd-j (lookup-/⟨⟩∈ σ∈Γ x)) (Sp∈-/⟨⟩ j∈as∈l σ∈Γ) -- Applications in simple kinding are admissible. ?⟨⟩∈-?∙∙ : ∀ {n} {Γ : Ctx n} {r as k j} → Γ ⊢?⟨ k ⟩ r ∈ kd j → Γ ⊢ j ∋∙ as ∈ ★ → Γ ⊢Nf r ?∙∙⟨ k ⟩ as ∈ ★ ?⟨⟩∈-?∙∙ (∈-hit a∈j) j∋as∈★ = Nf∈-∙∙ a∈j j∋as∈★ ?⟨⟩∈-?∙∙ (∈-miss y Γ[y]≡kd-j) j∋as∈★ = ∈-ne (∈-∙ (∈-var y Γ[y]≡kd-j) j∋as∈★) Nf∈-∙∙ : ∀ {n} {Γ : Ctx n} {a as j k} → Γ ⊢Nf a ∈ j → Γ ⊢ j ∋∙ as ∈ k → Γ ⊢Nf a ∙∙⟨ j ⟩ as ∈ k Nf∈-∙∙ a∈j ∈-[] = a∈j Nf∈-∙∙ a∈j⇒k (∈-∷ b∈j k∋as∈l) = Nf∈-∙∙ (Nf∈-Π-e a∈j⇒k b∈j) k∋as∈l Nf∈-Π-e : ∀ {n} {Γ : Ctx n} {a b j k} → Γ ⊢Nf a ∈ j ⇒ k → Γ ⊢Nf b ∈ j → Γ ⊢Nf a ⌜·⌝⟨ j ⇒ k ⟩ b ∈ k Nf∈-Π-e (∈-Π-i j-kds a∈k) b∈⌊j⌋ = Nf∈-/⟨⟩ a∈k (∈-hsub b∈⌊j⌋) -- Concatenation of simply well-formed spines results in application. Nf∈-++-∙∙⟨⟩ : ∀ {n} {Γ : Ctx n} {a bs cs j k l} → Γ ⊢Nf a ∈ j → Γ ⊢ j ∋∙ bs ∈ k → Γ ⊢ k ∋∙ cs ∈ l → a ∙∙⟨ j ⟩ (bs List.++ cs) ≡ a ∙∙⟨ j ⟩ bs ∙∙⟨ k ⟩ cs Nf∈-++-∙∙⟨⟩ a∈j ∈-[] k∋cs∈l = refl Nf∈-++-∙∙⟨⟩ a∈j₁⇒j₂ (∈-∷ b∈j₁ j₂[b]∋bs∈k) k∋cs∈l = Nf∈-++-∙∙⟨⟩ (Nf∈-Π-e a∈j₁⇒j₂ b∈j₁) j₂[b]∋bs∈k k∋cs∈l -- Another admissible kinding rule for applications. Nf∈-Π-e′ : ∀ {n} {Γ : Ctx n} {a b j k} → Γ ⊢Nf a ∈ j ⇒ k → Γ ⊢Nf b ∈ j → Γ ⊢Nf a ↓⌜·⌝ b ∈ k Nf∈-Π-e′ (∈-Π-i j-kds a∈k) b∈⌊j⌋ = Nf∈-/⟨⟩ a∈k (∈-hsub b∈⌊j⌋) mutual -- Simply well-kinded hereditary substitutions in simply -- well-formed kinds and simply well-kinded types commute. -- -- NOTE: this is a variant of the `sub-commutes' lemma from -- Data.Fin.Substitution.Lemmas adapted to hereditary -- substitutions. kds-[]-/⟨⟩-↑⋆ : ∀ {i m n} (E : CtxExt (suc m) i) {Γ Δ} {j b k l} {σ : SVSub m n} → E ++ kd k ∷ Γ ⊢ j kds → Γ ⊢Nf b ∈ k → Δ ⊢/⟨ l ⟩ σ ∈ Γ → j Kind/⟨ k ⟩ (sub b ↑⋆ i) Kind/⟨ l ⟩ σ ↑⋆ i ≡ j Kind/⟨ l ⟩ (σ ↑) ↑⋆ i Kind/⟨ k ⟩ sub (b /⟨ l ⟩ σ) ↑⋆ i kds-[]-/⟨⟩-↑⋆ E (kds-⋯ a∈★ b∈★) c∈k σ∈Γ = cong₂ _⋯_ (Nf∈-[]-/⟨⟩-↑⋆ E a∈★ c∈k σ∈Γ) (Nf∈-[]-/⟨⟩-↑⋆ E b∈★ c∈k σ∈Γ) kds-[]-/⟨⟩-↑⋆ E (kds-Π j-kds k-kds) b∈k σ∈Γ = cong₂ Π (kds-[]-/⟨⟩-↑⋆ E j-kds b∈k σ∈Γ) (kds-[]-/⟨⟩-↑⋆ (_ ∷ E) k-kds b∈k σ∈Γ) Nf∈-[]-/⟨⟩-↑⋆ : ∀ {i m n} (E : CtxExt (suc m) i) {Γ Δ} {a b j k l} {σ : SVSub m n} → E ++ kd k ∷ Γ ⊢Nf a ∈ j → Γ ⊢Nf b ∈ k → Δ ⊢/⟨ l ⟩ σ ∈ Γ → a /⟨ k ⟩ (sub b ↑⋆ i) /⟨ l ⟩ σ ↑⋆ i ≡ a /⟨ l ⟩ (σ ↑) ↑⋆ i /⟨ k ⟩ sub (b /⟨ l ⟩ σ) ↑⋆ i Nf∈-[]-/⟨⟩-↑⋆ E ∈-⊥-f b∈k σ∈Γ = refl Nf∈-[]-/⟨⟩-↑⋆ E ∈-⊤-f b∈k σ∈Γ = refl Nf∈-[]-/⟨⟩-↑⋆ E (∈-∀-f k-kds a∈★) b∈k σ∈Γ = cong (_∙ []) (cong₂ Π (kds-[]-/⟨⟩-↑⋆ E k-kds b∈k σ∈Γ) (Nf∈-[]-/⟨⟩-↑⋆ (_ ∷ E) a∈★ b∈k σ∈Γ)) Nf∈-[]-/⟨⟩-↑⋆ E (∈-→-f a∈★ b∈★) c∈k σ∈Γ = cong (_∙ []) (cong₂ _⇒_ (Nf∈-[]-/⟨⟩-↑⋆ E a∈★ c∈k σ∈Γ) (Nf∈-[]-/⟨⟩-↑⋆ E b∈★ c∈k σ∈Γ)) Nf∈-[]-/⟨⟩-↑⋆ E (∈-Π-i j-kds a∈l) b∈k σ∈Γ = cong (_∙ []) (cong₂ Λ (kds-[]-/⟨⟩-↑⋆ E j-kds b∈k σ∈Γ) (Nf∈-[]-/⟨⟩-↑⋆ (_ ∷ E) a∈l b∈k σ∈Γ)) Nf∈-[]-/⟨⟩-↑⋆ E (∈-ne a∈★) b∈k σ∈Γ = Ne∈-[]-/⟨⟩-↑⋆ E a∈★ b∈k σ∈Γ Ne∈-[]-/⟨⟩-↑⋆ : ∀ {i m n} (E : CtxExt (suc m) i) {Γ Δ} {a b j k l} {σ : SVSub m n} → E ++ kd k ∷ Γ ⊢Ne a ∈ j → Γ ⊢Nf b ∈ k → Δ ⊢/⟨ l ⟩ σ ∈ Γ → a /⟨ k ⟩ (sub b ↑⋆ i) /⟨ l ⟩ σ ↑⋆ i ≡ a /⟨ l ⟩ (σ ↑) ↑⋆ i /⟨ k ⟩ sub (b /⟨ l ⟩ σ) ↑⋆ i Ne∈-[]-/⟨⟩-↑⋆ {i} E {b = b} (∈-∙ (∈-var x _) j∋as∈l) b∈k σ∈Γ with hit? (sub b ↑⋆ i) x Ne∈-[]-/⟨⟩-↑⋆ {i} E {_} {_} {var x ∙ as} {b} {_} {k} {l} {σ} (∈-∙ (∈-var x Γ[x]=kd-j) j∋as∈l) b∈k σ∈Γ | hit a hitP = let σ₁′ = sub b ↑⋆ i σ₂′ = sub (b /⟨ l ⟩ σ) ↑⋆ i as₁ = as //⟨ k ⟩ σ₁′ as₂ = as //⟨ l ⟩ ((σ ↑) ↑⋆ i) [b/i]∈E++k∷Γ = ∈-H↑⋆ E (∈-hsub b∈k) _ , j≡k = lookup-/⟨⟩∈-Hit [b/i]∈E++k∷Γ (∈-var x Γ[x]=kd-j) hitP k∋as∈l = subst (_ ⊢_∋∙ as ∈ _) j≡k j∋as∈l σ↑⋆i∈E++Γ = ∈-H↑⋆ (re-idx E) σ∈Γ in begin lookupSV σ₁′ x ?∙∙⟨ k ⟩ as₁ /⟨ l ⟩ σ ↑⋆ i ≡⟨ cong (λ r → r ?∙∙⟨ k ⟩ as₁ /⟨ l ⟩ _) (trans (lookup-Hit hitP) (cong hit (Hit-sub-↑⋆₂ i hitP))) ⟩ weakenElim⋆ i b ∙∙⟨ k ⟩ as₁ /⟨ l ⟩ σ ↑⋆ i ≡⟨ Nf∈-∙∙-/⟨⟩ (Nf∈-weaken⋆ (re-idx E) b∈k) (Sp∈-/⟨⟩ k∋as∈l [b/i]∈E++k∷Γ) σ↑⋆i∈E++Γ ⟩ (weakenElim⋆ i b /⟨ l ⟩ σ ↑⋆ i) ∙∙⟨ k ⟩ (as₁ //⟨ l ⟩ σ ↑⋆ i) ≡⟨ cong₂ (_∙∙⟨ k ⟩_) (sym (weaken⋆-/⟨⟩-↑⋆ i b)) (Sp∈-[]-/⟨⟩-↑⋆ E j∋as∈l b∈k σ∈Γ) ⟩ weakenElim⋆ i (b /⟨ l ⟩ σ) ∙∙⟨ k ⟩ (as₂ //⟨ k ⟩ σ₂′) ≡˘⟨ cong (_?∙∙⟨ k ⟩ (as₂ //⟨ k ⟩ σ₂′)) (lookup-Hit (Hit-sub-↑⋆ i)) ⟩ lookupSV σ₂′ (raise i zero) ?∙∙⟨ k ⟩ (as₂ //⟨ k ⟩ σ₂′) ≡⟨⟩ miss (raise i zero) ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ≡˘⟨ cong (λ r → r ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′) (lookup-Miss (Miss-↑⋆ i under)) ⟩ lookupSV ((σ ↑) ↑⋆ i) (raise i zero) ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ≡˘⟨ cong (λ y → lookupSV ((σ ↑) ↑⋆ i) y ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′) (Hit-sub-↑⋆₁ i hitP) ⟩ lookupSV ((σ ↑) ↑⋆ i) x ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ∎ Ne∈-[]-/⟨⟩-↑⋆ {i} E {_} {_} {var x ∙ as} {b} {_} {k} {l} {σ} (∈-∙ (∈-var x Γ[x]=kd-j) j∋as∈l) b∈k σ∈Γ | miss y missP-[a/i] with hit? (σ ↑⋆ i) y ... | hit a hitP = let σ₁′ = sub b ↑⋆ i σ₂′ = sub (b /⟨ l ⟩ σ) ↑⋆ i as₁ = as //⟨ k ⟩ σ₁′ as₂ = as //⟨ l ⟩ ((σ ↑) ↑⋆ i) hitP-σ↑↑⋆ = Hit-↑-↑⋆ i hitP σ₂′∈E++Γ = ∈-H↑⋆ (re-idx E) (∈-hsub (Nf∈-/⟨⟩ b∈k σ∈Γ)) σ∈E++k∷Γ = ∈-H↑⋆ E (∈-H↑ σ∈Γ) x≡i+1+y = Miss-sub-↑⋆′ i y missP-[a/i] i+1+y∈j = subst (_ ⊢Var_∈ _) x≡i+1+y (∈-var x Γ[x]=kd-j) a∈l , j≡l = lookup-/⟨⟩∈-Hit σ∈E++k∷Γ i+1+y∈j hitP-σ↑↑⋆ l∋as₂∈l = subst (_ ⊢_∋∙ as₂ ∈ _) j≡l (Sp∈-/⟨⟩ j∋as∈l σ∈E++k∷Γ) in begin lookupSV σ₁′ x ?∙∙⟨ k ⟩ as₁ /⟨ l ⟩ σ ↑⋆ i ≡⟨ cong (λ r → r ?∙∙⟨ k ⟩ as₁ /⟨ l ⟩ σ ↑⋆ i) (lookup-Miss missP-[a/i]) ⟩ var y ∙ as₁ /⟨ l ⟩ σ ↑⋆ i ≡⟨⟩ lookupSV (σ ↑⋆ i) y ?∙∙⟨ l ⟩ (as₁ //⟨ l ⟩ σ ↑⋆ i) ≡⟨ cong₂ (_?∙∙⟨ l ⟩_) (lookup-Hit hitP) (Sp∈-[]-/⟨⟩-↑⋆ E j∋as∈l b∈k σ∈Γ) ⟩ a ∙∙⟨ l ⟩ (as₂ //⟨ k ⟩ σ₂′) ≡˘⟨ cong (_∙∙⟨ l ⟩ (as₂ //⟨ k ⟩ σ₂′)) (/Var-wk-↑⋆-hsub-vanishes i a) ⟩ (a Elim/Var V.wk V.↑⋆ i /⟨ k ⟩ σ₂′) ∙∙⟨ l ⟩ (as₂ //⟨ k ⟩ σ₂′) ≡˘⟨ Nf∈-∙∙-/⟨⟩ a∈l l∋as₂∈l σ₂′∈E++Γ ⟩ (a Elim/Var V.wk V.↑⋆ i) ∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ≡˘⟨ cong (λ r → r ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′) (lookup-Hit hitP-σ↑↑⋆) ⟩ lookupSV ((σ ↑) ↑⋆ i) (lift i suc y) ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ≡˘⟨ cong (λ z → lookupSV ((σ ↑) ↑⋆ i) z ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′) x≡i+1+y ⟩ lookupSV ((σ ↑) ↑⋆ i) x ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ∎ ... | miss z missP = let σ₁′ = sub b ↑⋆ i σ₂′ = sub (b /⟨ l ⟩ σ) ↑⋆ i as₁ = as //⟨ k ⟩ σ₁′ as₂ = as //⟨ l ⟩ ((σ ↑) ↑⋆ i) missP-σ↑↑⋆ = Miss-↑-↑⋆ i missP x≡i+1+y = Miss-sub-↑⋆′ i y missP-[a/i] in begin lookupSV σ₁′ x ?∙∙⟨ k ⟩ as₁ /⟨ l ⟩ σ ↑⋆ i ≡⟨ cong (λ r → r ?∙∙⟨ k ⟩ as₁ /⟨ l ⟩ σ ↑⋆ i) (lookup-Miss missP-[a/i]) ⟩ var y ∙ as₁ /⟨ l ⟩ σ ↑⋆ i ≡⟨⟩ lookupSV (σ ↑⋆ i) y ?∙∙⟨ l ⟩ (as₁ //⟨ l ⟩ σ ↑⋆ i) ≡⟨ cong₂ (_?∙∙⟨ l ⟩_) (lookup-Miss missP) (Sp∈-[]-/⟨⟩-↑⋆ E j∋as∈l b∈k σ∈Γ) ⟩ var z ∙ (as₂ //⟨ k ⟩ σ₂′) ≡˘⟨ cong (_?∙∙⟨ k ⟩ (as₂ //⟨ k ⟩ σ₂′)) (lookup-Miss (Miss-sub-↑⋆ i z)) ⟩ lookupSV σ₂′ (lift i suc z) ?∙∙⟨ k ⟩ (as₂ //⟨ k ⟩ σ₂′) ≡⟨⟩ var (lift i suc z) ∙ as₂ /⟨ k ⟩ σ₂′ ≡˘⟨ cong (λ r → r ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′) (lookup-Miss missP-σ↑↑⋆) ⟩ lookupSV ((σ ↑) ↑⋆ i) (lift i suc y) ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ≡˘⟨ cong (λ z → lookupSV ((σ ↑) ↑⋆ i) z ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′) x≡i+1+y ⟩ lookupSV ((σ ↑) ↑⋆ i) x ?∙∙⟨ l ⟩ as₂ /⟨ k ⟩ σ₂′ ∎ Sp∈-[]-/⟨⟩-↑⋆ : ∀ {i m n} (E : CtxExt (suc m) i) {Γ Δ} {as b j₁ j₂ k l} {σ : SVSub m n} → E ++ kd k ∷ Γ ⊢ j₁ ∋∙ as ∈ j₂ → Γ ⊢Nf b ∈ k → Δ ⊢/⟨ l ⟩ σ ∈ Γ → as //⟨ k ⟩ (sub b ↑⋆ i) //⟨ l ⟩ σ ↑⋆ i ≡ as //⟨ l ⟩ (σ ↑) ↑⋆ i //⟨ k ⟩ sub (b /⟨ l ⟩ σ) ↑⋆ i Sp∈-[]-/⟨⟩-↑⋆ E ∈-[] b∈k σ∈Γ = refl Sp∈-[]-/⟨⟩-↑⋆ E (∈-∷ a∈j₁ j₂∋as∈j₃) b∈k σ∈Γ = cong₂ _∷_ (Nf∈-[]-/⟨⟩-↑⋆ E a∈j₁ b∈k σ∈Γ) (Sp∈-[]-/⟨⟩-↑⋆ E j₂∋as∈j₃ b∈k σ∈Γ) -- Reducing applications commute with hereditary substitution. Nf∈-∙∙-/⟨⟩ : ∀ {l m n Γ Δ} {σ : SVSub m n} {a as j k} → Γ ⊢Nf a ∈ j → Γ ⊢ j ∋∙ as ∈ k → Δ ⊢/⟨ l ⟩ σ ∈ Γ → a ∙∙⟨ j ⟩ as /⟨ l ⟩ σ ≡ (a /⟨ l ⟩ σ) ∙∙⟨ j ⟩ (as //⟨ l ⟩ σ) Nf∈-∙∙-/⟨⟩ a∈j ∈-[] σ∈Γ = refl Nf∈-∙∙-/⟨⟩ {l} {σ = σ} {a} {b ∷ bs} {j ⇒ k} a∈j⇒k (∈-∷ b∈j k∋bs∈l) σ∈Γ = begin a ⌜·⌝⟨ j ⇒ k ⟩ b ∙∙⟨ k ⟩ bs /⟨ l ⟩ σ ≡⟨ Nf∈-∙∙-/⟨⟩ (Nf∈-Π-e a∈j⇒k b∈j) k∋bs∈l σ∈Γ ⟩ (a ⌜·⌝⟨ j ⇒ k ⟩ b /⟨ l ⟩ σ) ∙∙⟨ _ ⟩ (bs //⟨ l ⟩ σ) ≡⟨ cong (_∙∙⟨ k ⟩ (bs //⟨ l ⟩ σ)) (Nf∈-Π-e-/⟨⟩ a∈j⇒k b∈j σ∈Γ) ⟩ (a /⟨ l ⟩ σ) ⌜·⌝⟨ j ⇒ k ⟩ (b /⟨ l ⟩ σ) ∙∙⟨ k ⟩ (bs //⟨ l ⟩ σ) ∎ Nf∈-Π-e-/⟨⟩ : ∀ {l m n Γ Δ} {σ : SVSub m n} {a b j k} → Γ ⊢Nf a ∈ j ⇒ k → Γ ⊢Nf b ∈ j → Δ ⊢/⟨ l ⟩ σ ∈ Γ → a ⌜·⌝⟨ j ⇒ k ⟩ b /⟨ l ⟩ σ ≡ (a /⟨ l ⟩ σ) ⌜·⌝⟨ j ⇒ k ⟩ (b /⟨ l ⟩ σ) Nf∈-Π-e-/⟨⟩ (∈-Π-i j-kds a∈k) b∈⌊j⌋ σ∈Γ = Nf∈-[]-/⟨⟩-↑⋆ [] a∈k b∈⌊j⌋ σ∈Γ -- Potentially reducing applications commute with hereditary -- substitution. Nf∈-Π-e-/⟨⟩′ : ∀ {l m n Γ Δ} {σ : SVSub m n} {a b j k} → Γ ⊢Nf a ∈ j ⇒ k → Γ ⊢Nf b ∈ j → Δ ⊢/⟨ l ⟩ σ ∈ Γ → a ↓⌜·⌝ b /⟨ l ⟩ σ ≡ (a /⟨ l ⟩ σ) ↓⌜·⌝ (b /⟨ l ⟩ σ) Nf∈-Π-e-/⟨⟩′ {l} {σ = σ} {_} {b} (∈-Π-i {j} {a} j-kds a∈k) b∈⌊j⌋ σ∈Γ = begin (a [ b ∈ ⌊ j ⌋ ]) /⟨ l ⟩ σ ≡⟨ Nf∈-[]-/⟨⟩-↑⋆ [] a∈k b∈⌊j⌋ σ∈Γ ⟩ (a /⟨ l ⟩ σ ↑) [ b /⟨ l ⟩ σ ∈ ⌊ j ⌋ ] ≡⟨ cong ((a /⟨ l ⟩ σ ↑) [ b /⟨ l ⟩ σ ∈_]) (sym (⌊⌋-Kind/⟨⟩ j)) ⟩ (a /⟨ l ⟩ σ ↑) [ b /⟨ l ⟩ σ ∈ ⌊ j Kind/⟨ l ⟩ σ ⌋ ] ∎
{ "alphanum_fraction": 0.4216123114, "avg_line_length": 43.0064412238, "ext": "agda", "hexsha": "e0dd295e2dd048ef2490536a330c08eed86a40d4", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z", "max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/FOmegaInt/Kinding/Simple.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z", "max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/FOmegaInt/Kinding/Simple.agda", "max_line_length": 81, "max_stars_count": 12, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/FOmegaInt/Kinding/Simple.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z", "max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z", "num_tokens": 14362, "size": 26707 }
module UselessPrivatePragma where postulate Char : Set private {-# BUILTIN CHAR Char #-}
{ "alphanum_fraction": 0.7419354839, "avg_line_length": 13.2857142857, "ext": "agda", "hexsha": "a625ce81d93ec296eff8964ac38eb95445a9412a", "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/UselessPrivatePragma.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/UselessPrivatePragma.agda", "max_line_length": 33, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/UselessPrivatePragma.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 23, "size": 93 }
-- Andreas, 2016-09-22, issue #2183, issue reported by Ulf open import Agda.Builtin.Nat open import Agda.Builtin.Equality module _ (n : Nat) where foo : (m : Nat) → n ≡ m → Nat foo m refl = {!m!} -- Splitting on m fails currently, as it internally is .n -- We may be doing something about this in the future.
{ "alphanum_fraction": 0.6813880126, "avg_line_length": 24.3846153846, "ext": "agda", "hexsha": "60656c4d49ee21831d5546e3113a3dd46054759c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/interaction/Issue2183.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pthariensflame/agda", "max_issues_repo_path": "test/interaction/Issue2183.agda", "max_line_length": 58, "max_stars_count": 3, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/interaction/Issue2183.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": 101, "size": 317 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.MaybeEmbed {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Tools.Product -- Any level can be embedded into the highest level (validity variant). maybeEmbᵛ : ∀ {l A Γ} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ A / [Γ] → Γ ⊩ᵛ⟨ ¹ ⟩ A / [Γ] maybeEmbᵛ {⁰} [Γ] [A] ⊢Δ [σ] = let [σA] = proj₁ ([A] ⊢Δ [σ]) [σA]′ = maybeEmb (proj₁ ([A] ⊢Δ [σ])) in [σA]′ , (λ [σ′] [σ≡σ′] → irrelevanceEq [σA] [σA]′ (proj₂ ([A] ⊢Δ [σ]) [σ′] [σ≡σ′])) maybeEmbᵛ {¹} [Γ] [A] = [A] -- The lowest level can be embedded in any level (validity variant). maybeEmbₛ′ : ∀ {l A Γ} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ ⁰ ⟩ A / [Γ] → Γ ⊩ᵛ⟨ l ⟩ A / [Γ] maybeEmbₛ′ {⁰} [Γ] [A] = [A] maybeEmbₛ′ {¹} [Γ] [A] ⊢Δ [σ] = let [σA] = proj₁ ([A] ⊢Δ [σ]) [σA]′ = maybeEmb′ (proj₁ ([A] ⊢Δ [σ])) in [σA]′ , (λ [σ′] [σ≡σ′] → irrelevanceEq [σA] [σA]′ (proj₂ ([A] ⊢Δ [σ]) [σ′] [σ≡σ′]))
{ "alphanum_fraction": 0.5530364372, "avg_line_length": 31.6666666667, "ext": "agda", "hexsha": "c3eee16849a132790b4c65ce18616d33c3e97eb5", "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/Substitution/MaybeEmbed.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/Substitution/MaybeEmbed.agda", "max_line_length": 84, "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/Substitution/MaybeEmbed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 536, "size": 1235 }
F : Set → Set F A = A → A {-# POLARITY F ++ #-}
{ "alphanum_fraction": 0.4081632653, "avg_line_length": 9.8, "ext": "agda", "hexsha": "62834e6c38fdcb5c969ac2537f0d7c41a84837ca", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Fail/Polarity-pragma-in-safe-mode.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pthariensflame/agda", "max_issues_repo_path": "test/Fail/Polarity-pragma-in-safe-mode.agda", "max_line_length": 21, "max_stars_count": null, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Fail/Polarity-pragma-in-safe-mode.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 20, "size": 49 }
module Common.SumProperties where open import Function as Fun open import Data.Sum as Sum open import Relation.Binary.PropositionalEquality as PE hiding ([_]) open ≡-Reasoning copair-elimˡ : {A B C : Set} {f : A → C} {g : B → C} (x : A) → ([ f , g ]′ ) (inj₁ x) ≡ f x copair-elimˡ x = refl copair-elimʳ : {A B C : Set} {f : A → C} {g : B → C} (x : B) → ([ f , g ]′ ) (inj₂ x) ≡ g x copair-elimʳ x = refl copair-sum-map-merge : {A A' B B' C : Set} {f₁ : A → A'} {f₂ : B → B'} {g₁ : A' → C} {g₂ : B' → C} (x : A ⊎ B) → ([ g₁ , g₂ ]′ ∘ Sum.map f₁ f₂) x ≡ [ g₁ ∘ f₁ , g₂ ∘ f₂ ]′ x copair-sum-map-merge (inj₁ x) = refl copair-sum-map-merge (inj₂ y) = refl copair-cong : {A B C : Set} {f f' : A → C} {g : B → C} (p : (x : A) → f x ≡ f' x) → (x : A ⊎ B) → [ f , g ]′ x ≡ [ f' , g ]′ x copair-cong {A} {B} {C} {f} {f'} {g} p (inj₁ x) = begin ([ f , g ]′ (inj₁ x)) ≡⟨ refl ⟩ f x ≡⟨ p x ⟩ f' x ≡⟨ refl ⟩ [ f' , g ]′ (inj₁ x) ∎ copair-cong p (inj₂ y) = refl copair-distr : {A B C D : Set} {f : A → C} {g : B → C} {h : C → D} (x : A ⊎ B) → [ h ∘ f , h ∘ g ]′ x ≡ (h ∘ [ f , g ]′) x copair-distr (inj₁ x) = refl copair-distr (inj₂ y) = refl
{ "alphanum_fraction": 0.4210128496, "avg_line_length": 30.0681818182, "ext": "agda", "hexsha": "237bc90c8807ba958ed8d5a29390b7c2318c4d8b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "TypeTheory/Common/SumProperties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "TypeTheory/Common/SumProperties.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "TypeTheory/Common/SumProperties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 594, "size": 1323 }
module bags where open import Data.PropFormula.Syntax 4 open import Data.PropFormula.SyntaxExperiment 4 public open import Data.Fin using (suc; zero; #_) open import Relation.Binary.PropositionalEquality using (_≡_) p : PropFormula p = Var (# 0) q : PropFormula q = Var (# 1) pq : PropFormula pq = p ∧ q qp : PropFormula qp = q ∧ p listpq : List PropFormula listpq = toList pq listqp : List PropFormula listqp = toList qp
{ "alphanum_fraction": 0.7342657343, "avg_line_length": 17.16, "ext": "agda", "hexsha": "9ad63527cd27cfc0bcec3ae29d8be5f1469bafcc", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_path": "test/bags.agda", "max_issues_count": 18, "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_path": "test/bags.agda", "max_line_length": 61, "max_stars_count": 13, "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_path": "test/bags.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "num_tokens": 126, "size": 429 }
module seven where open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Naturals using (ℕ; zero; suc) seven : ℕ seven = suc (suc (suc (suc (suc (suc (suc zero)))))) _ : seven ≡ 7 _ = refl
{ "alphanum_fraction": 0.6926605505, "avg_line_length": 19.8181818182, "ext": "agda", "hexsha": "3b4c33277a623b52f38bd958b5136a2f1933a11b", "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/naturals/seven.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/naturals/seven.agda", "max_line_length": 67, "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/naturals/seven.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": 72, "size": 218 }
{-# OPTIONS --safe #-} module Definition.Conversion.Universe 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.Reduction open import Definition.Conversion.Lift import Tools.PropositionalEquality as PE -- Algorithmic equality of terms in WHNF of type U are equal as types. univConv↓ : ∀ {A B r Γ l} → Γ ⊢ A [conv↓] B ∷ Univ r l ^ next l → Γ ⊢ A [conv↓] B ^ [ r , ι l ] univConv↓ X = univ X -- Algorithmic equality of terms of type U are equal as types. univConv↑ : ∀ {A B r Γ l} → Γ ⊢ A [conv↑] B ∷ Univ r l ^ next l → Γ ⊢ A [conv↑] B ^ [ r , ι l ] univConv↑ ([↑]ₜ B₁ t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) rewrite PE.sym (whnfRed* D Uₙ) = reductionConv↑ (univ* d) (univ* d′) whnft′ whnfu′ (liftConv (univConv↓ t<>u))
{ "alphanum_fraction": 0.661987041, "avg_line_length": 30.8666666667, "ext": "agda", "hexsha": "c5f39499950be1880e6ec46dcf408900c6c1a64b", "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/Conversion/Universe.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/Conversion/Universe.agda", "max_line_length": 79, "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/Conversion/Universe.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": 300, "size": 926 }
module SizedIO.IOGraphicsLib where {-# FOREIGN GHC import qualified Graphics.SOE #-} {-# FOREIGN GHC import qualified Graphics.Rendering.OpenGL #-} {-# FOREIGN GHC import qualified GHC.Int #-} {-# FOREIGN GHC import qualified Foreign.C.Types #-} open import Data.Bool.Base open import Data.Char.Base open import Data.Nat.Base hiding (_+_) open import Data.List.Base as L open import Data.Integer.Base open import Data.Product open import Data.Maybe.Base open import Size renaming (Size to AgdaSize) open import SizedIO.Base open import NativeIO open import NativeInt AgdaPoint = (ℤ × ℤ) postulate Window : Set -- {-# COMPILED_TYPE Window Graphics.SOE.Window #-} postulate Size : Set -- {-# COMPILED_TYPE Size Graphics.SOE.Size #-} postulate size : ℤ → ℤ → Size -- {-# COMPILED size (\ x y -> ( (fromInteger x) :: Int, (fromInteger y) :: Int) :: Graphics.SOE.Size) #-} postulate Point : Set -- {-# COMPILED_TYPE Point Graphics.SOE.Point #-} postulate nativePoint : ℤ → ℤ → Point -- {-# COMPILED nativePoint (\ x y -> (fromInteger x, fromInteger y)::Graphics.SOE.Point) #-} postulate nativeProj1Point : Point → ℤ postulate nativeProj2Point : Point → ℤ -- {-# COMPILED nativeProj1Point (\(x, y) -> toInteger x) #-} -- {-# COMPILED nativeProj2Point (\(x, y) -> toInteger y) #-} {- toNativePoint : Point → NativePoint toNativePoint (x , y) = nativePoint x y -} data Event : Set where Key : Char → Bool → Event Button : Point → Bool → Bool → Event MouseMove : Point → Event Resize : Event Closed : Event -- {-# COMPILED_DATA Event Graphics.SOE.Event Graphics.SOE.Key Graphics.SOE.Button Graphics.SOE.MouseMove Graphics.SOE.Resize Graphics.SOE.Closed #-} postulate nativeMaybeGetWindowEvent : Window → NativeIO (Maybe Event) -- {-# COMPILED nativeMaybeGetWindowEvent Graphics.SOE.maybeGetWindowEvent #-} postulate nativeGetWindowEvent : Window → NativeIO (Event) -- {-# COMPILED nativeGetWindowEvent Graphics.SOE.getWindowEvent #-} postulate Graphic : Set -- {-# COMPILED_TYPE Graphic Graphics.SOE.Graphic #-} postulate nativeDrawInWindow : Window → Graphic → NativeIO Unit -- {-# COMPILED nativeDrawInWindow Graphics.SOE.drawInWindow #-} postulate Word32 : Set -- {-# COMPILED_TYPE Word32 Graphics.SOE.Word32 #-} postulate text : Point → String → Graphic -- {-# COMPILED text (\ p s -> Graphics.SOE.text p (Data.Text.unpack s)) #-} data RedrawMode : Set where -- (removed from lib where: DoubleBuffered : RedrawMode, Unbuffered : RedrawMode) -- {-# COMPILED_DATA RedrawMode Graphics.SOE.RedrawMode #-} postulate nativeDrawGraphic : RedrawMode -- {-# COMPILED nativeDrawGraphic Graphics.SOE.drawGraphic #-} postulate nativeDrawBufferedGraphic : RedrawMode -- {-# COMPILED nativeDrawBufferedGraphic Graphics.SOE.drawBufferedGraphic #-} postulate nativeOpenWindow : String → Size → NativeIO Window -- {-# COMPILED nativeOpenWindow (\ s -> Graphics.SOE.openWindow (Data.Text.unpack s)) #-} postulate nativeOpenWindowEx : String → (Maybe Point) → (Maybe Size) → RedrawMode → (Maybe Word32) → NativeIO Window -- {-# COMPILED nativeOpenWindowEx (\s -> Graphics.SOE.openWindowEx (Data.Text.unpack s)) #-} nativeOpenWindowExNat : String → (Maybe Point) → ℕ → ℕ → RedrawMode → (Maybe Word32) → NativeIO Window nativeOpenWindowExNat s p n1 n2 a b = nativeOpenWindowEx s p (just (size (+ n1) (+ n2))) a b postulate nativeCloseWindow : Window → NativeIO Unit -- {-# COMPILED nativeCloseWindow Graphics.SOE.closeWindow #-} postulate nativeRunGraphics : NativeIO Unit → NativeIO Unit -- {-# COMPILED nativeRunGraphics Graphics.SOE.runGraphics #-} postulate word32ToInteger : Word32 → ℤ -- {-# COMPILED word32ToInteger (\w -> toInteger (Graphics.SOE.word32ToInt w)) #-} postulate nativeTimeGetTime : NativeIO Word32 -- {-# COMPILED nativeTimeGetTime Graphics.SOE.timeGetTime #-} data Color : Set where black : Color blue : Color green : Color cyan : Color red : Color magenta : Color yellow : Color white : Color -- {-# COMPILED_DATA Color Graphics.SOE.Color Graphics.SOE.Black Graphics.SOE.Blue Graphics.SOE.Green Graphics.SOE.Cyan Graphics.SOE.Red Graphics.SOE.Magenta Graphics.SOE.Yellow Graphics.SOE.White #-} postulate withColor : Color → Graphic → Graphic -- {-# COMPILED withColor Graphics.SOE.withColor #-} postulate polygon : List Point → Graphic -- {-# COMPILED polygon Graphics.SOE.polygon #-} {- polygon : List Point → Graphic polygon l = nativePolygon (L.map toNativePoint l) -} data GraphicsCommands : Set where closeWindow : Window → GraphicsCommands maybeGetWindowEvent : Window → GraphicsCommands getWindowEvent : Window → GraphicsCommands openWindowNotEx : String → Size → GraphicsCommands openWindow : String → (Maybe Point) → ℕ → ℕ → RedrawMode → (Maybe Word32) → GraphicsCommands timeGetTime : GraphicsCommands drawInWindow : Window → Graphic → GraphicsCommands print : String → GraphicsCommands GraphicsResponses : GraphicsCommands → Set GraphicsResponses (maybeGetWindowEvent w) = Maybe Event GraphicsResponses (getWindowEvent w) = Event GraphicsResponses (closeWindow w) = Unit GraphicsResponses (openWindowNotEx s s') = Window GraphicsResponses (openWindow s n1 n2 s' r w) = Window GraphicsResponses timeGetTime = Word32 GraphicsResponses _ = Unit GraphicsInterface : IOInterface Command GraphicsInterface = GraphicsCommands Response GraphicsInterface = GraphicsResponses IOGraphics : AgdaSize → Set → Set IOGraphics i = IO GraphicsInterface i IOGraphics+ : AgdaSize → Set → Set IOGraphics+ i = IO+ GraphicsInterface i translateIOGraphicsLocal : (c : GraphicsCommands) → NativeIO (GraphicsResponses c) translateIOGraphicsLocal (maybeGetWindowEvent w) = nativeMaybeGetWindowEvent w translateIOGraphicsLocal (getWindowEvent w) = nativeGetWindowEvent w translateIOGraphicsLocal (closeWindow w) = nativeCloseWindow w translateIOGraphicsLocal (openWindowNotEx str size) = nativeOpenWindow str size translateIOGraphicsLocal (openWindow str point n1 n2 mode word) = nativeOpenWindowExNat str point n1 n2 mode word translateIOGraphicsLocal timeGetTime = nativeTimeGetTime translateIOGraphicsLocal (drawInWindow w g) = nativeDrawInWindow w g translateIOGraphicsLocal (print s) = nativePutStrLn s translateIOGraphics : {A : Set} → IOGraphics ∞ A → NativeIO A translateIOGraphics = translateIO translateIOGraphicsLocal
{ "alphanum_fraction": 0.7205525197, "avg_line_length": 33.9587628866, "ext": "agda", "hexsha": "4e5a138fde6740e352c8207b77e1059e371861ad", "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/SizedIO/IOGraphicsLib.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/SizedIO/IOGraphicsLib.agda", "max_line_length": 201, "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/SizedIO/IOGraphicsLib.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": 1673, "size": 6588 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use the -- Relation.Binary.Reasoning.PartialOrder module directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.PartialOrderReasoning {p₁ p₂ p₃} (P : Poset p₁ p₂ p₃) where open import Relation.Binary.Reasoning.PartialOrder P public
{ "alphanum_fraction": 0.5269461078, "avg_line_length": 31.3125, "ext": "agda", "hexsha": "271afa0707575d0b00593052cc0fc4e5a2132164", "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/Relation/Binary/PartialOrderReasoning.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/Relation/Binary/PartialOrderReasoning.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/Relation/Binary/PartialOrderReasoning.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 95, "size": 501 }
module Category.Profunctor.Star where open import Agda.Primitive using (_⊔_) open import Category.Functor using (RawFunctor ; module RawFunctor) open import Category.Functor.Lawful open import Category.Applicative using (RawApplicative; module RawApplicative) open import Data.Product using (_,_) open import Data.Sum using (inj₁; inj₂) open import Category.Profunctor open import Category.Strong open import Category.Choice open import Relation.Binary.PropositionalEquality using (refl) open import Axiom.Extensionality.Propositional using (Extensionality) Star : ∀ {l₁ l₂ l₃} (F : Set l₂ → Set l₃) (A : Set l₁) (B : Set l₂) → Set (l₁ ⊔ l₃) Star F A B = (A → F B) starProfunctor : ∀ {l₁ l₂} {F : Set l₁ → Set l₂} → RawFunctor F → ProfunctorImp (Star F) starProfunctor f = record { dimap = λ f h g z → h <$> (g (f z)) ; lmap = λ f g z → g (f z) ; rmap = λ h g z → h <$> (g z) } where open RawFunctor f starLawfulProfunctor : ∀ {l₁ l₂} {F : Set l₁ → Set l₂} {Func : RawFunctor F} → Extensionality l₁ l₂ → LawfulFunctorImp Func → LawfulProfunctorImp (starProfunctor Func) starLawfulProfunctor ext f = record { lmapId = refl ; rmapId = ext (λ _ → <$>-identity) ; dimapLmapRmap = refl } where open LawfulFunctor f starStrong : ∀ {l₁ l₂} {F : Set l₁ → Set l₂} → RawFunctor F → StrongImp (Star F) starStrong f = record { first' = λ { f → λ { (x , z) → (_, z) <$> f x } } ; second' = λ { f → λ { (z , x) → (z ,_) <$> f x } } ; isProfunctor = starProfunctor f } where open RawFunctor f starChoice : ∀ {l} {F : Set l → Set l} → RawApplicative F → ChoiceImp (Star F) starChoice f = record { left' = λ { f → λ { (inj₁ x) → inj₁ <$> f x ; (inj₂ z) → pure (inj₂ z) } } ; right' = λ { f → λ { (inj₁ z) → pure (inj₁ z) ; (inj₂ x) → inj₂ <$> f x } } ; isProfunctor = starProfunctor rawFunctor } where open RawApplicative f
{ "alphanum_fraction": 0.6515885837, "avg_line_length": 41.2666666667, "ext": "agda", "hexsha": "c650c4d736405f642f8c6324fd1acd1afd69e92a", "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": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crisoagf/agda-optics", "max_forks_repo_path": "src/Category/Profunctor/Star.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "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": "crisoagf/agda-optics", "max_issues_repo_path": "src/Category/Profunctor/Star.agda", "max_line_length": 168, "max_stars_count": null, "max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crisoagf/agda-optics", "max_stars_repo_path": "src/Category/Profunctor/Star.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 669, "size": 1857 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.cubical.Square open import lib.types.Bool open import lib.types.Cofiber open import lib.types.Lift open import lib.types.Paths open import lib.types.Pointed open import lib.types.PushoutFmap open import lib.types.Sigma open import lib.types.Span open import lib.types.Suspension open import lib.types.Wedge module lib.types.BigWedge where module _ {i j} {A : Type i} where {- the function for cofiber -} bigwedge-f : (X : A → Ptd j) → A → Σ A (de⊙ ∘ X) bigwedge-f X a = a , pt (X a) bigwedge-span : (A → Ptd j) → Span bigwedge-span X = cofiber-span (bigwedge-f X) BigWedge : (A → Ptd j) → Type (lmax i j) BigWedge X = Cofiber (bigwedge-f X) bwbase : {X : A → Ptd j} → BigWedge X bwbase = cfbase bwin : {X : A → Ptd j} → (a : A) → de⊙ (X a) → BigWedge X bwin = curry cfcod ⊙BigWedge : (A → Ptd j) → Ptd (lmax i j) ⊙BigWedge X = ⊙[ BigWedge X , bwbase ] bwglue : {X : A → Ptd j} → (a : A) → bwbase {X} == bwin a (pt (X a)) bwglue = cfglue ⊙bwin : {X : A → Ptd j} → (a : A) → X a ⊙→ ⊙BigWedge X ⊙bwin a = (bwin a , ! (bwglue a)) module BigWedgeElim {X : A → Ptd j} {k} {P : BigWedge X → Type k} (base* : P bwbase) (in* : (a : A) (x : de⊙ (X a)) → P (bwin a x)) (glue* : (a : A) → base* == in* a (pt (X a)) [ P ↓ bwglue a ]) = CofiberElim {f = bigwedge-f X} {P = P} base* (uncurry in*) glue* BigWedge-elim = BigWedgeElim.f module BigWedgeRec {X : A → Ptd j} {k} {C : Type k} (base* : C) (in* : (a : A) → de⊙ (X a) → C) (glue* : (a : A) → base* == in* a (pt (X a))) = CofiberRec {f = bigwedge-f X} {C = C} base* (uncurry in*) glue* module _ {i j₀ j₁} {A : Type i} {X₀ : A → Ptd j₀} {X₁ : A → Ptd j₁} (Xeq : ∀ a → X₀ a ⊙≃ X₁ a) where bigwedge-span-emap-r : SpanEquiv (cofiber-span (bigwedge-f X₀)) (cofiber-span (bigwedge-f X₁)) bigwedge-span-emap-r = span-map (idf _) (Σ-fmap-r λ a → fst (⊙–> (Xeq a))) (idf _) (comm-sqr λ _ → idp) (comm-sqr λ a → pair= idp (⊙–>-pt (Xeq a))) , idf-is-equiv _ , Σ-isemap-r (λ a → snd (Xeq a)) , idf-is-equiv _ BigWedge-emap-r : BigWedge X₀ ≃ BigWedge X₁ BigWedge-emap-r = Pushout-emap bigwedge-span-emap-r ⊙BigWedge-emap-r : ⊙BigWedge X₀ ⊙≃ ⊙BigWedge X₁ ⊙BigWedge-emap-r = ≃-to-⊙≃ BigWedge-emap-r idp module _ {i₀ i₁ j} {A₀ : Type i₀} {A₁ : Type i₁} (X : A₁ → Ptd j) (Aeq : A₀ ≃ A₁) where bigwedge-span-emap-l : SpanEquiv (cofiber-span (bigwedge-f (X ∘ –> Aeq))) (cofiber-span (bigwedge-f X)) bigwedge-span-emap-l = span-map (idf _) (Σ-fmap-l (de⊙ ∘ X) (–> Aeq)) (–> Aeq) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp) , idf-is-equiv _ , Σ-isemap-l (de⊙ ∘ X) (snd Aeq) , snd Aeq BigWedge-emap-l : BigWedge (X ∘ –> Aeq) ≃ BigWedge X BigWedge-emap-l = Pushout-emap bigwedge-span-emap-l ⊙BigWedge-emap-l : ⊙BigWedge (X ∘ –> Aeq) ⊙≃ ⊙BigWedge X ⊙BigWedge-emap-l = ≃-to-⊙≃ BigWedge-emap-l idp module _ {i} {A : Type i} (X : A → Ptd i) where extract-glue-from-BigWedge-is-const : ∀ bw → extract-glue {s = bigwedge-span X} bw == north extract-glue-from-BigWedge-is-const = BigWedge-elim idp (λ x y → ! (merid x)) (↓-='-from-square ∘ λ x → ExtractGlue.glue-β x ∙v⊡ tr-square (merid x) ⊡v∙ ! (ap-cst north (cfglue x))) {- A BigWedge indexed by Bool is just a binary Wedge -} module _ {i} (Pick : Bool → Ptd i) where BigWedge-Bool-equiv-Wedge : BigWedge Pick ≃ Wedge (Pick true) (Pick false) BigWedge-Bool-equiv-Wedge = equiv f g f-g g-f where module F = BigWedgeRec {X = Pick} {C = Wedge (Pick true) (Pick false)} (winl (pt (Pick true))) (λ {true → winl; false → winr}) (λ {true → idp; false → wglue}) module G = WedgeRec {X = Pick true} {Y = Pick false} {C = BigWedge Pick} (bwin true) (bwin false) (! (bwglue true) ∙ bwglue false) f = F.f g = G.f abstract f-g : ∀ w → f (g w) == w f-g = Wedge-elim (λ _ → idp) (λ _ → idp) (↓-∘=idf-in' f g $ ap f (ap g wglue) =⟨ ap (ap f) G.glue-β ⟩ ap f (! (bwglue true) ∙ bwglue false) =⟨ ap-∙ f (! (bwglue true)) (bwglue false) ⟩ ap f (! (bwglue true)) ∙ ap f (bwglue false) =⟨ ap-! f (bwglue true) |in-ctx (λ w → w ∙ ap f (bwglue false)) ⟩ ! (ap f (bwglue true)) ∙ ap f (bwglue false) =⟨ F.glue-β true |in-ctx (λ w → ! w ∙ ap f (bwglue false)) ⟩ ap f (bwglue false) =⟨ F.glue-β false ⟩ wglue =∎) g-f : ∀ bw → g (f bw) == bw g-f = BigWedge-elim (! (bwglue true)) (λ {true → λ _ → idp; false → λ _ → idp}) (λ {true → ↓-∘=idf-from-square g f $ ap (ap g) (F.glue-β true) ∙v⊡ bl-square (bwglue true); false → ↓-∘=idf-from-square g f $ (ap (ap g) (F.glue-β false) ∙ G.glue-β) ∙v⊡ lt-square (! (bwglue true)) ⊡h vid-square})
{ "alphanum_fraction": 0.5424509411, "avg_line_length": 33.7432432432, "ext": "agda", "hexsha": "8fdb3fcb9ad15f22c2f04754a6ec463f9af4f3cb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "core/lib/types/BigWedge.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "core/lib/types/BigWedge.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "core/lib/types/BigWedge.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2069, "size": 4994 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Indexed containers aka interaction structures aka polynomial -- functors. The notation and presentation here is closest to that of -- Hancock and Hyvernat in "Programming interfaces and basic topology" -- (2006/9). -- ------------------------------------------------------------------------ module Data.Container.Indexed where open import Level open import Function renaming (id to ⟨id⟩; _∘_ to _⟨∘⟩_) open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using (_↔_; module Inverse) open import Data.Product as Prod hiding (map) open import Relation.Unary using (Pred; _⊆_) open import Relation.Binary as B using (Preorder; module Preorder) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≗_; refl) open import Relation.Binary.HeterogeneousEquality as H using (_≅_; refl) open import Relation.Binary.Indexed open import Data.W.Indexed open import Data.M.Indexed ------------------------------------------------------------------------ -- The type and its semantics ("extension"). open import Data.Container.Indexed.Core public open Container public -- Abbreviation for the commonly used level one version of indexed -- containers. _▷_ : Set → Set → Set₁ I ▷ O = Container I O zero zero -- The least and greatest fixpoint. μ ν : ∀ {o c r} {O : Set o} → Container O O c r → Pred O _ μ = W ν = M -- Equality, parametrised on an underlying relation. Eq : ∀ {i o c r ℓ} {I : Set i} {O : Set o} (C : Container I O c r) (X Y : Pred I ℓ) → REL X Y ℓ → REL (⟦ C ⟧ X) (⟦ C ⟧ Y) _ Eq C _ _ _≈_ {o₁} {o₂} (c , k) (c′ , k′) = o₁ ≡ o₂ × c ≅ c′ × (∀ r r′ → r ≅ r′ → k r ≈ k′ r′) private -- Note that, if propositional equality were extensional, then Eq _≅_ -- and _≅_ would coincide. Eq⇒≅ : ∀ {i o c r ℓ} {I : Set i} {O : Set o} {C : Container I O c r} {X : Pred I ℓ} {o₁ o₂ : O} {xs : ⟦ C ⟧ X o₁} {ys : ⟦ C ⟧ X o₂} → H.Extensionality r ℓ → Eq C X X (λ x₁ x₂ → x₁ ≅ x₂) xs ys → xs ≅ ys Eq⇒≅ {xs = c , k} {.c , k′} ext (refl , refl , k≈k′) = H.cong (_,_ c) (ext (λ _ → refl) (λ r → k≈k′ r r refl)) setoid : ∀ {i o c r} {I : Set i} {O : Set o} → Container I O c r → Setoid I (c ⊔ r) _ → Setoid O _ _ setoid C X = record { Carrier = ⟦ C ⟧ X.Carrier ; _≈_ = _≈_ ; isEquivalence = record { refl = refl , refl , λ { r .r refl → X.refl } ; sym = sym ; trans = λ { {_} {i = xs} {ys} {zs} → trans {_} {i = xs} {ys} {zs} } } } where module X = Setoid X _≈_ : Rel (⟦ C ⟧ X.Carrier) _ _≈_ = Eq C X.Carrier X.Carrier X._≈_ sym : Symmetric (⟦ C ⟧ X.Carrier) _≈_ sym {_} {._} {_ , _} {._ , _} (refl , refl , k) = refl , refl , λ { r .r refl → X.sym (k r r refl) } trans : Transitive (⟦ C ⟧ X.Carrier) _≈_ trans {._} {_} {._} {_ , _} {._ , _} {._ , _} (refl , refl , k) (refl , refl , k′) = refl , refl , λ { r .r refl → X.trans (k r r refl) (k′ r r refl) } ------------------------------------------------------------------------ -- Functoriality -- Indexed containers are functors. map : ∀ {i o c r ℓ₁ ℓ₂} {I : Set i} {O : Set o} (C : Container I O c r) {X : Pred I ℓ₁} {Y : Pred I ℓ₂} → X ⊆ Y → ⟦ C ⟧ X ⊆ ⟦ C ⟧ Y map _ f = Prod.map ⟨id⟩ (λ g → f ⟨∘⟩ g) module Map where identity : ∀ {i o c r} {I : Set i} {O : Set o} (C : Container I O c r) (X : Setoid I _ _) → let module X = Setoid X in ∀ {o} {xs : ⟦ C ⟧ X.Carrier o} → Eq C X.Carrier X.Carrier X._≈_ xs (map C {X.Carrier} ⟨id⟩ xs) identity C X = Setoid.refl (setoid C X) composition : ∀ {i o c r ℓ₁ ℓ₂} {I : Set i} {O : Set o} (C : Container I O c r) {X : Pred I ℓ₁} {Y : Pred I ℓ₂} (Z : Setoid I _ _) → let module Z = Setoid Z in {f : Y ⊆ Z.Carrier} {g : X ⊆ Y} {o : O} {xs : ⟦ C ⟧ X o} → Eq C Z.Carrier Z.Carrier Z._≈_ (map C {Y} f (map C {X} g xs)) (map C {X} (f ⟨∘⟩ g) xs) composition C Z = Setoid.refl (setoid C Z) ------------------------------------------------------------------------ -- Container morphisms module _ {i₁ i₂ o₁ o₂} {I₁ : Set i₁} {I₂ : Set i₂} {O₁ : Set o₁} {O₂ : Set o₂} where -- General container morphism. record ContainerMorphism {c₁ c₂ r₁ r₂ ℓ₁ ℓ₂} (C₁ : Container I₁ O₁ c₁ r₁) (C₂ : Container I₂ O₂ c₂ r₂) (f : I₁ → I₂) (g : O₁ → O₂) (_∼_ : B.Rel I₂ ℓ₁) (_≈_ : B.REL (Set r₂) (Set r₁) ℓ₂) (_·_ : ∀ {A B} → A ≈ B → A → B) : Set (i₁ ⊔ i₂ ⊔ o₁ ⊔ o₂ ⊔ c₁ ⊔ c₂ ⊔ r₁ ⊔ r₂ ⊔ ℓ₁ ⊔ ℓ₂) where field command : Command C₁ ⊆ Command C₂ ⟨∘⟩ g response : ∀ {o} {c₁ : Command C₁ o} → Response C₂ (command c₁) ≈ Response C₁ c₁ coherent : ∀ {o} {c₁ : Command C₁ o} {r₂ : Response C₂ (command c₁)} → f (next C₁ c₁ (response · r₂)) ∼ next C₂ (command c₁) r₂ open ContainerMorphism public -- Plain container morphism. _⇒[_/_]_ : ∀ {c₁ c₂ r₁ r₂} → Container I₁ O₁ c₁ r₁ → (I₁ → I₂) → (O₁ → O₂) → Container I₂ O₂ c₂ r₂ → Set _ C₁ ⇒[ f / g ] C₂ = ContainerMorphism C₁ C₂ f g _≡_ (λ R₂ R₁ → R₂ → R₁) _$_ -- Linear container morphism. _⊸[_/_]_ : ∀ {c₁ c₂ r₁ r₂} → Container I₁ O₁ c₁ r₁ → (I₁ → I₂) → (O₁ → O₂) → Container I₂ O₂ c₂ r₂ → Set _ C₁ ⊸[ f / g ] C₂ = ContainerMorphism C₁ C₂ f g _≡_ _↔_ (λ r₂↔r₁ r₂ → Inverse.to r₂↔r₁ ⟨$⟩ r₂) -- Cartesian container morphism. _⇒C[_/_]_ : ∀ {c₁ c₂ r} → Container I₁ O₁ c₁ r → (I₁ → I₂) → (O₁ → O₂) → Container I₂ O₂ c₂ r → Set _ C₁ ⇒C[ f / g ] C₂ = ContainerMorphism C₁ C₂ f g _≡_ (λ R₂ R₁ → R₂ ≡ R₁) (λ r₂≡r₁ r₂ → P.subst ⟨id⟩ r₂≡r₁ r₂) -- Degenerate cases where no reindexing is performed. module _ {i o c r} {I : Set i} {O : Set o} where _⇒_ : B.Rel (Container I O c r) _ C₁ ⇒ C₂ = C₁ ⇒[ ⟨id⟩ / ⟨id⟩ ] C₂ _⊸_ : B.Rel (Container I O c r) _ C₁ ⊸ C₂ = C₁ ⊸[ ⟨id⟩ / ⟨id⟩ ] C₂ _⇒C_ : B.Rel (Container I O c r) _ C₁ ⇒C C₂ = C₁ ⇒C[ ⟨id⟩ / ⟨id⟩ ] C₂ ------------------------------------------------------------------------ -- Plain morphisms -- Interpretation of _⇒_. ⟪_⟫ : ∀ {i o c r ℓ} {I : Set i} {O : Set o} {C₁ C₂ : Container I O c r} → C₁ ⇒ C₂ → (X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X ⟪ m ⟫ X (c , k) = command m c , λ r₂ → P.subst X (coherent m) (k (response m r₂)) module PlainMorphism {i o c r} {I : Set i} {O : Set o} where -- Naturality. Natural : ∀ {ℓ} {C₁ C₂ : Container I O c r} → ((X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X) → Set _ Natural {C₁ = C₁} {C₂} m = ∀ {X} Y → let module Y = Setoid Y in (f : X ⊆ Y.Carrier) → ∀ {o} (xs : ⟦ C₁ ⟧ X o) → Eq C₂ Y.Carrier Y.Carrier Y._≈_ (m Y.Carrier $ map C₁ {X} f xs) (map C₂ {X} f $ m X xs) -- Natural transformations. NT : ∀ {ℓ} (C₁ C₂ : Container I O c r) → Set _ NT {ℓ} C₁ C₂ = ∃ λ (m : (X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X) → Natural m -- Container morphisms are natural. natural : ∀ {ℓ} (C₁ C₂ : Container I O c r) (m : C₁ ⇒ C₂) → Natural {ℓ} ⟪ m ⟫ natural _ _ m {X} Y f _ = refl , refl , λ { r .r refl → lemma (coherent m) } where module Y = Setoid Y lemma : ∀ {i j} (eq : i ≡ j) {x} → P.subst Y.Carrier eq (f x) Y.≈ f (P.subst X eq x) lemma refl = Y.refl -- In fact, all natural functions of the right type are container -- morphisms. complete : ∀ {C₁ C₂ : Container I O c r} (nt : NT C₁ C₂) → ∃ λ m → (X : Setoid I _ _) → let module X = Setoid X in ∀ {o} (xs : ⟦ C₁ ⟧ X.Carrier o) → Eq C₂ X.Carrier X.Carrier X._≈_ (proj₁ nt X.Carrier xs) (⟪ m ⟫ X.Carrier {o} xs) complete {C₁} {C₂} (nt , nat) = m , (λ X xs → nat X (λ { (r , eq) → P.subst (Setoid.Carrier X) eq (proj₂ xs r) }) (proj₁ xs , (λ r → r , refl))) where m : C₁ ⇒ C₂ m = record { command = λ c₁ → proj₁ (lemma c₁) ; response = λ {_} {c₁} r₂ → proj₁ (proj₂ (lemma c₁) r₂) ; coherent = λ {_} {c₁} {r₂} → proj₂ (proj₂ (lemma c₁) r₂) } where lemma : ∀ {o} (c₁ : Command C₁ o) → Σ[ c₂ ∈ Command C₂ o ] ((r₂ : Response C₂ c₂) → Σ[ r₁ ∈ Response C₁ c₁ ] next C₁ c₁ r₁ ≡ next C₂ c₂ r₂) lemma c₁ = nt (λ i → Σ[ r₁ ∈ Response C₁ c₁ ] next C₁ c₁ r₁ ≡ i) (c₁ , λ r₁ → r₁ , refl) -- Identity. id : (C : Container I O c r) → C ⇒ C id _ = record { command = ⟨id⟩ ; response = ⟨id⟩ ; coherent = refl } -- Composition. infixr 9 _∘_ _∘_ : {C₁ C₂ C₃ : Container I O c r} → C₂ ⇒ C₃ → C₁ ⇒ C₂ → C₁ ⇒ C₃ f ∘ g = record { command = command f ⟨∘⟩ command g ; response = response g ⟨∘⟩ response f ; coherent = coherent g ⟨ P.trans ⟩ coherent f } -- Identity and composition commute with ⟪_⟫. id-correct : ∀ {ℓ} {C : Container I O c r} → ∀ {X : Pred I ℓ} {o} → ⟪ id C ⟫ X {o} ≗ ⟨id⟩ id-correct _ = refl ∘-correct : {C₁ C₂ C₃ : Container I O c r} (f : C₂ ⇒ C₃) (g : C₁ ⇒ C₂) (X : Setoid I (c ⊔ r) _) → let module X = Setoid X in ∀ {o} {xs : ⟦ C₁ ⟧ X.Carrier o} → Eq C₃ X.Carrier X.Carrier X._≈_ (⟪ f ∘ g ⟫ X.Carrier xs) (⟪ f ⟫ X.Carrier (⟪ g ⟫ X.Carrier xs)) ∘-correct f g X = refl , refl , λ { r .r refl → lemma (coherent g) (coherent f) } where module X = Setoid X lemma : ∀ {i j k} (eq₁ : i ≡ j) (eq₂ : j ≡ k) {x} → P.subst X.Carrier (P.trans eq₁ eq₂) x X.≈ P.subst X.Carrier eq₂ (P.subst X.Carrier eq₁ x) lemma refl refl = X.refl ------------------------------------------------------------------------ -- Linear container morphisms module LinearMorphism {i o c r} {I : Set i} {O : Set o} {C₁ C₂ : Container I O c r} (m : C₁ ⊸ C₂) where morphism : C₁ ⇒ C₂ morphism = record { command = command m ; response = _⟨$⟩_ (Inverse.to (response m)) ; coherent = coherent m } ⟪_⟫⊸ : ∀ {ℓ} (X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X ⟪_⟫⊸ = ⟪ morphism ⟫ open LinearMorphism public using (⟪_⟫⊸) ------------------------------------------------------------------------ -- Cartesian morphisms module CartesianMorphism {i o c r} {I : Set i} {O : Set o} {C₁ C₂ : Container I O c r} (m : C₁ ⇒C C₂) where morphism : C₁ ⇒ C₂ morphism = record { command = command m ; response = P.subst ⟨id⟩ (response m) ; coherent = coherent m } ⟪_⟫C : ∀ {ℓ} (X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X ⟪_⟫C = ⟪ morphism ⟫ open CartesianMorphism public using (⟪_⟫C) ------------------------------------------------------------------------ -- All and any -- □ and ◇ are defined in the core module. module _ {i o c r ℓ₁ ℓ₂} {I : Set i} {O : Set o} (C : Container I O c r) {X : Pred I ℓ₁} {P Q : Pred (Σ I X) ℓ₂} where -- All. □-map : P ⊆ Q → □ C P ⊆ □ C Q □-map P⊆Q = _⟨∘⟩_ P⊆Q -- Any. ◇-map : P ⊆ Q → ◇ C P ⊆ ◇ C Q ◇-map P⊆Q = Prod.map ⟨id⟩ P⊆Q -- Membership. infix 4 _∈_ _∈_ : ∀ {i o c r ℓ} {I : Set i} {O : Set o} {C : Container I O c r} {X : Pred I (i ⊔ ℓ)} → REL X (⟦ C ⟧ X) _ _∈_ {C = C} {X} x xs = ◇ C {X = X} (_≅_ x) (, xs)
{ "alphanum_fraction": 0.4762278636, "avg_line_length": 32.5653409091, "ext": "agda", "hexsha": "cd1ab1955d90a1114ceebf2e326a431f1dc01c20", "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/Data/Container/Indexed.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/Data/Container/Indexed.agda", "max_line_length": 79, "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/Data/Container/Indexed.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": 4412, "size": 11463 }
-- Andreas, 2017-02-13, issue #2456 reported by identicalsnowflake -- Introduced by fix for #1698 record Class (t : Set) : Set where postulate t : Set instance Class t -- Should give error, but not internal error.
{ "alphanum_fraction": 0.7117117117, "avg_line_length": 18.5, "ext": "agda", "hexsha": "2443107b10ea9809bf8b7def57474524368b1ccf", "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/Issue2456.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/Issue2456.agda", "max_line_length": 66, "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/Issue2456.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": 64, "size": 222 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Indexed containers core ------------------------------------------------------------------------ module Data.Container.Indexed.Core where open import Level open import Data.Product open import Relation.Unary infix 5 _◃_/_ record Container {i o} (I : Set i) (O : Set o) (c r : Level) : Set (i ⊔ o ⊔ suc c ⊔ suc r) where constructor _◃_/_ field Command : (o : O) → Set c Response : ∀ {o} → Command o → Set r next : ∀ {o} (c : Command o) → Response c → I -- The semantics ("extension") of an indexed container. ⟦_⟧ : ∀ {i o c r ℓ} {I : Set i} {O : Set o} → Container I O c r → Pred I ℓ → Pred O _ ⟦ C ◃ R / n ⟧ X o = Σ[ c ∈ C o ] ((r : R c) → X (n c r)) ------------------------------------------------------------------------ -- All and any module _ {i o c r ℓ} {I : Set i} {O : Set o} (C : Container I O c r) {X : Pred I ℓ} where -- All. □ : ∀ {ℓ′} → Pred (Σ I X) ℓ′ → Pred (Σ O (⟦ C ⟧ X)) _ □ P (_ , _ , k) = ∀ r → P (_ , k r) -- Any. ◇ : ∀ {ℓ′} → Pred (Σ I X) ℓ′ → Pred (Σ O (⟦ C ⟧ X)) _ ◇ P (_ , _ , k) = ∃ λ r → P (_ , k r)
{ "alphanum_fraction": 0.4051155116, "avg_line_length": 27.5454545455, "ext": "agda", "hexsha": "e6b1585919f889adf9a87a1c4ad18cca69b25d68", "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/Data/Container/Indexed/Core.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/Data/Container/Indexed/Core.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/Data/Container/Indexed/Core.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": 409, "size": 1212 }
-- Andreas, 2018-10-15, issue #3264 reported by Guillaume Brunerie -- Refine should not say "cannot refine" just because of a termination error. f : Set → Set f A = {!f!} -- C-c C-r -- EXPECTED ANSWER: -- -- ?1 : Set -- ———— Errors ———————————————————————————————————————————————— -- Termination checking failed for the following functions: -- f -- Problematic calls: -- f (?1 (A = A)) -- when checking that the expression f ? has type Set
{ "alphanum_fraction": 0.578125, "avg_line_length": 26.3529411765, "ext": "agda", "hexsha": "19dee97ed338800ee5c360a55418773c431cf8d5", "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/Issue3264.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/Issue3264.agda", "max_line_length": 77, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue3264.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": 126, "size": 448 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Conversion of < to ≤, along with a number of properties ------------------------------------------------------------------------ -- Possible TODO: Prove that a conversion ≤ → < → ≤ returns a -- relation equivalent to the original one (and similarly for -- < → ≤ → <). open import Relation.Binary module Relation.Binary.StrictToNonStrict {a ℓ₁ ℓ₂} {A : Set a} (_≈_ : Rel A ℓ₁) (_<_ : Rel A ℓ₂) where open import Relation.Nullary open import Relation.Binary.Consequences open import Function open import Data.Product open import Data.Sum open import Data.Empty ------------------------------------------------------------------------ -- Conversion -- _<_ can be turned into _≤_ as follows: _≤_ : Rel A _ x ≤ y = (x < y) ⊎ (x ≈ y) ------------------------------------------------------------------------ -- The converted relations have certain properties -- (if the original relations have certain other properties) reflexive : _≈_ ⇒ _≤_ reflexive = inj₂ antisym : IsEquivalence _≈_ → Transitive _<_ → Irreflexive _≈_ _<_ → Antisymmetric _≈_ _≤_ antisym eq trans irrefl = as where module Eq = IsEquivalence eq as : Antisymmetric _≈_ _≤_ as (inj₂ x≈y) _ = x≈y as (inj₁ _) (inj₂ y≈x) = Eq.sym y≈x as (inj₁ x<y) (inj₁ y<x) = ⊥-elim (trans∧irr⟶asym {_≈_ = _≈_} Eq.refl trans irrefl x<y y<x) trans : IsEquivalence _≈_ → _<_ Respects₂ _≈_ → Transitive _<_ → Transitive _≤_ trans eq <-resp-≈ <-trans = tr where module Eq = IsEquivalence eq tr : Transitive _≤_ tr (inj₁ x<y) (inj₁ y<z) = inj₁ $ <-trans x<y y<z tr (inj₁ x<y) (inj₂ y≈z) = inj₁ $ proj₁ <-resp-≈ y≈z x<y tr (inj₂ x≈y) (inj₁ y<z) = inj₁ $ proj₂ <-resp-≈ (Eq.sym x≈y) y<z tr (inj₂ x≈y) (inj₂ y≈z) = inj₂ $ Eq.trans x≈y y≈z ≤-resp-≈ : IsEquivalence _≈_ → _<_ Respects₂ _≈_ → _≤_ Respects₂ _≈_ ≤-resp-≈ eq <-resp-≈ = ((λ {_ _ _} → resp₁) , (λ {_ _ _} → resp₂)) where module Eq = IsEquivalence eq resp₁ : ∀ {x y' y} → y' ≈ y → x ≤ y' → x ≤ y resp₁ y'≈y (inj₁ x<y') = inj₁ (proj₁ <-resp-≈ y'≈y x<y') resp₁ y'≈y (inj₂ x≈y') = inj₂ (Eq.trans x≈y' y'≈y) resp₂ : ∀ {y x' x} → x' ≈ x → x' ≤ y → x ≤ y resp₂ x'≈x (inj₁ x'<y) = inj₁ (proj₂ <-resp-≈ x'≈x x'<y) resp₂ x'≈x (inj₂ x'≈y) = inj₂ (Eq.trans (Eq.sym x'≈x) x'≈y) total : Trichotomous _≈_ _<_ → Total _≤_ total <-tri x y with <-tri x y ... | tri< x<y x≉y x≯y = inj₁ (inj₁ x<y) ... | tri≈ x≮y x≈y x≯y = inj₁ (inj₂ x≈y) ... | tri> x≮y x≉y x>y = inj₂ (inj₁ x>y) decidable : Decidable _≈_ → Decidable _<_ → Decidable _≤_ decidable ≈-dec <-dec x y with ≈-dec x y | <-dec x y ... | yes x≈y | _ = yes (inj₂ x≈y) ... | no x≉y | yes x<y = yes (inj₁ x<y) ... | no x≉y | no x≮y = no helper where helper : x ≤ y → ⊥ helper (inj₁ x<y) = x≮y x<y helper (inj₂ x≈y) = x≉y x≈y decidable' : Trichotomous _≈_ _<_ → Decidable _≤_ decidable' compare x y with compare x y ... | tri< x<y _ _ = yes (inj₁ x<y) ... | tri≈ _ x≈y _ = yes (inj₂ x≈y) ... | tri> x≮y x≉y _ = no helper where helper : x ≤ y → ⊥ helper (inj₁ x<y) = x≮y x<y helper (inj₂ x≈y) = x≉y x≈y
{ "alphanum_fraction": 0.5261519303, "avg_line_length": 30.8846153846, "ext": "agda", "hexsha": "85434fdcf388404262c64bc5c5e2f7b2251b5305", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/StrictToNonStrict.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/StrictToNonStrict.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/StrictToNonStrict.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": 1311, "size": 3212 }
module Prelude.Fin where open import Prelude.Nat open import Prelude.Equality open import Prelude.Decidable open import Prelude.Ord open import Prelude.Bool open import Prelude.Function open import Prelude.Number open import Prelude.Nat.Properties using (suc-inj) data Fin : Nat → Set where zero : ∀ {n} → Fin (suc n) suc : ∀ {n} (i : Fin n) → Fin (suc n) finToNat : ∀ {@erased n} → Fin n → Nat finToNat zero = zero finToNat (suc i) = suc (finToNat i) finToNat-inj : ∀ {@erased n} {i j : Fin n} → finToNat i ≡ finToNat j → i ≡ j finToNat-inj {i = zero } {zero } p = refl finToNat-inj {i = zero } {suc j} () finToNat-inj {i = suc i} {zero } () finToNat-inj {i = suc i} {suc j} p rewrite finToNat-inj (suc-inj p) = refl natToFin : ∀ {n} (m : Nat) {{m<n : IsTrue (lessNat m n)}} → Fin n natToFin {zero } _ {{}} natToFin {suc n} zero = zero natToFin {suc n} (suc m) = suc (natToFin m) instance NumberFin : ∀ {n} → Number (Fin n) Number.Constraint (NumberFin {n}) k = IsTrue (lessNat k n) fromNat {{NumberFin}} = natToFin --- Equality --- fsuc-inj : ∀ {@erased n} {i j : Fin n} → Fin.suc i ≡ suc j → i ≡ j fsuc-inj refl = refl private eqFin : ∀ {@erased n} (i j : Fin n) → Dec (i ≡ j) eqFin zero zero = yes refl eqFin zero (suc j) = no λ () eqFin (suc i) zero = no λ () eqFin (suc i) (suc j) with eqFin i j eqFin (suc i) (suc .i) | yes refl = yes refl eqFin (suc i) (suc j) | no neq = no λ eq → neq (fsuc-inj eq) instance EqFin : ∀ {n} → Eq (Fin n) _==_ {{EqFin}} = eqFin --- Ord --- instance OrdFin : ∀ {n} → Ord (Fin n) OrdFin = OrdBy finToNat-inj OrdLawsFin : ∀ {n} → Ord/Laws (Fin n) OrdLawsFin = OrdLawsBy finToNat-inj
{ "alphanum_fraction": 0.6083627797, "avg_line_length": 26.9523809524, "ext": "agda", "hexsha": "657d7566dba652024ce9c87319177f4e191b1127", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Fin.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Fin.agda", "max_line_length": 76, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Fin.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 665, "size": 1698 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Limit where open import Level open import Data.Product using (Σ; _,_; Σ-syntax; uncurry; proj₂) open import Categories.Support.PropositionalEquality open import Categories.Category open import Categories.Functor using (Functor; module Functor) open import Categories.Cones open import Categories.Object.Terminal as T using (Terminal; module Terminal) import Categories.Morphisms as Mor open import Categories.Cone using (module Cone; module ConeOver) module LimitsOf {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where private module L = Terminal open Category C open Category J using () renaming (Obj to Dot) open Functor F open Mor C using (_≅_; _≡ⁱ_) open Mor (Cones F) using () renaming (_≅_ to _⇿_; _≡ⁱ_ to _≜ⁱ_) open Category (Cones F) using () renaming (Obj to Cone; _≡_ to _≜₁_; _∘_ to _▵_; _⇒_ to _⇾_; id to id▵) open ConeOver F using (_≜_; ≜-refl; ≜-sym; ≜-trans; heterogenize; homogenize; ConeUnder; tether; untether; _≜′_) renaming (module _≜_ to ≜; module _≜′_ to ≜′) open Heterogeneous C -- Isomorphic to an terminal object, but worth keeping distinct in case we change its definition record Limit : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field terminal : Terminal (Cones F) private module terminal = Terminal terminal module Fl = Float F {- vertex : Obj vertex = Cone.N terminal.⊤ proj : ∀ j → vertex ⇒ F₀ j proj = Cone.ψ terminal.⊤ proj-cone : Cone proj-cone = terminal.⊤ -} open terminal public using () renaming (⊤ to proj-cone) open Cone proj-cone public using () renaming (N to vertex; ψ to proj) rep-cone : (K : Cone) → (K ⇾ proj-cone) rep-cone K = terminal.! {K} rep : (K : Cone) → (Cone.N K ⇒ vertex) rep K = ConeMorphism.f (terminal.! {K}) unrep : ∀ {X} → (X ⇒ vertex) → Cone unrep f = record { N = domain f ; ψ = λ j → proj j ∘ f ; commute = λ l → Equiv.trans (Equiv.sym assoc) (∘-resp-≡ˡ (commute l)) } where open Cone proj-cone conify : ∀ {X} (f : X ⇒ vertex) → (unrep f ⇾ proj-cone) conify f = record { f = f; commute = Equiv.refl } unrep-cone : ∀ {K : Cone} → (K ⇾ proj-cone) → Cone unrep-cone κ = unrep (ConeMorphism.f κ) commute-cone : ∀ {K : Cone} → unrep-cone (rep-cone K) ≜ K commute-cone {K} = record { N-≣ = ≣-refl ; ψ-≡ = λ j → ≡⇒∼ (Equiv.sym (ConeMorphism.commute (rep-cone K))) } .commute : ∀ K j → proj j ∘ rep K ≡ Cone.ψ K j commute K = λ j → Equiv.sym (ConeMorphism.commute (rep-cone K)) private domain▵ : ∀ {X Y} → X ⇾ Y → Cone domain▵ {X} _ = X .universal-cone : ∀ {K : Cone} {i : K ⇾ proj-cone} → unrep-cone i ≜ K → Cones F [ rep-cone K ≡ i ] universal-cone {K} {i} pf = terminal.!-unique i .universal : ∀ {K : Cone} {i : Cone.N K ⇒ vertex} → unrep i ≜ K → rep K ≡ i universal {K} {i} pf = terminal.!-unique (Fl.floatʳ (heterogenize (homogenize pf ≣-refl)) (conify i)) -- complicated, isn't it? but it's necessary in order to make the float -- compute enough for the !-unique to typecheck. by replacing the -- N-≣ in pf with ≣-refl we can make it happen! g-η-cone₀ : ∀ {K} {κ : K ⇾ proj-cone} → K ≜ unrep-cone κ g-η-cone₀ {K} {κ} = record { N-≣ = ≣-refl; ψ-≡ = λ j → ≡⇒∼ (ConeMorphism.commute κ) } .g-η-cone : ∀ {K} {κ : K ⇾ proj-cone} → rep-cone (unrep-cone κ) ≜₁ Fl.floatʳ (g-η-cone₀ {κ = κ}) κ g-η-cone {κ = κ} = terminal.!-unique (Fl.floatʳ (g-η-cone₀ {κ = κ}) κ) .g-η : ∀ {X} {f : X ⇒ vertex} → rep (unrep f) ≡ f g-η {f = f} = terminal.!-unique (conify f) .η-cone : Cones F [ rep-cone proj-cone ≡ Category.id (Cones F) ] η-cone = terminal.⊤-id (rep-cone proj-cone) .η : rep proj-cone ≡ id η = η-cone .rep-cone-cong : ∀ {K₁ K₂} (K₁≜K₂ : K₁ ≜ K₂) → Cones F [ Fl.floatʳ K₁≜K₂ (rep-cone K₁) ≡ rep-cone K₂ ] rep-cone-cong {K₁} {K₂} K₁≜K₂ = Equiv.sym (terminal.!-unique (Fl.floatʳ K₁≜K₂ (rep-cone K₁))) .rep-cong′ : ∀ {N} {K₁ K₂ : ConeUnder N} → K₁ ≜′ K₂ → rep (untether K₁) ≡ rep (untether K₂) rep-cong′ {N} {K₁} {K₂} K₁≜′K₂ = Equiv.sym (terminal.!-unique (Fl.floatʳ (heterogenize K₁≜′K₂) (rep-cone (untether K₁)))) rep-cong : ∀ {K₁ K₂} → K₁ ≜ K₂ → rep K₁ ∼ rep K₂ rep-cong K₁≜K₂ = ≡⇒∼ʳ (≜.N-≣ K₁≜K₂) (rep-cone-cong K₁≜K₂) .rep-cone∘ : ∀ {K K′} {q : K′ ⇾ K} → Cones F [ Cones F [ rep-cone K ∘ q ] ≡ rep-cone K′ ] rep-cone∘ {K} {q = q} = Equiv.sym (terminal.!-unique (rep-cone K ▵ q)) .rep∘ : ∀ {K K′} {q : K′ ⇾ K} → rep K ∘ ConeMorphism.f q ≡ rep K′ rep∘ {K} {K′} {q} = rep-cone∘ {K} {K′} {q} .rep-cone-self-id : rep-cone proj-cone ≜₁ id▵ rep-cone-self-id = terminal.!-unique id▵ .rep-self-id : rep proj-cone ≡ id rep-self-id = terminal.!-unique id▵ open Limit -- Properties -- -- These are a little different from the raw ones for Terminal since they -- deal with isomorphisms in C instead of in Cones F. -- First, a lemma: open import Categories.Square -- do these lemmas belong in Cones? isos-lift-to-cones : ∀ (κ : Cone) {v : Obj} → Cone.N κ ≅ v → Σ[ κ′ ∈ Cone ] κ ⇿ κ′ isos-lift-to-cones κ {v} κ≅v = record { N = v ; ψ = λ X → (Cone.ψ κ X) ∘ g ; commute = λ f' → pullˡ (Cone.commute κ f') } , record { f = record { f = f; commute = Equiv.sym (cancelRight isoˡ) } ; g = record { f = g; commute = Equiv.refl } ; iso = record { isoˡ = isoˡ; isoʳ = isoʳ } } where open Mor._≅_ κ≅v open GlueSquares C isos-lower-from-cones : ∀ {κ₁ κ₂ : Cone} → κ₁ ⇿ κ₂ → Cone.N κ₁ ≅ Cone.N κ₂ isos-lower-from-cones κ₁⇿κ₂ = record { f = ConeMorphism.f f ; g = ConeMorphism.f g ; iso = record { isoˡ = isoˡ; isoʳ = isoʳ } } where open Mor._≅_ κ₁⇿κ₂ ≜ⁱ⇒≡ⁱ : ∀ {κ₁ κ₂} {i₁ i₂ : κ₁ ⇿ κ₂} → i₁ ≜ⁱ i₂ → isos-lower-from-cones i₁ ≡ⁱ isos-lower-from-cones i₂ ≜ⁱ⇒≡ⁱ pf = record { f-≡ = f-≡; g-≡ = g-≡ } where open Mor._≡ⁱ_ pf up-to-iso-cone : (L₁ L₂ : Limit) → proj-cone L₁ ⇿ proj-cone L₂ up-to-iso-cone L₁ L₂ = T.up-to-iso (Cones F) (terminal L₁) (terminal L₂) up-to-iso : (L₁ L₂ : Limit) → vertex L₁ ≅ vertex L₂ up-to-iso L₁ L₂ = isos-lower-from-cones (up-to-iso-cone L₁ L₂) transport-by-iso-cone : (L : Limit) {κ : Cone} → proj-cone L ⇿ κ → Limit transport-by-iso-cone L L⇿κ = record { terminal = T.transport-by-iso (Cones F) (terminal L) L⇿κ } transport-by-iso : (L : Limit) {v : Obj} → vertex L ≅ v → Limit transport-by-iso L L≅v = transport-by-iso-cone L (proj₂ p) where p = isos-lift-to-cones (proj-cone L) L≅v .up-to-iso-cone-unique : ∀ L L′ → (i : proj-cone L ⇿ proj-cone L′) → up-to-iso-cone L L′ ≜ⁱ i up-to-iso-cone-unique L L′ i = T.up-to-iso-unique (Cones F) (terminal L) (terminal L′) i -- XXX probably not true -- what is? only the above? -- .up-to-iso-unique : ∀ L L′ → (i : vertex L ≅ vertex L′) → up-to-iso L L′ ≡ⁱ i -- up-to-iso-unique L L′ i = ≜ⁱ⇒≡ⁱ {!up-to-iso-unique-cone L L′ !} .up-to-iso-cone-invˡ : ∀ {L κ} {i : proj-cone L ⇿ κ} → up-to-iso-cone L (transport-by-iso-cone L i) ≜ⁱ i up-to-iso-cone-invˡ {L} {i = i} = up-to-iso-cone-unique L (transport-by-iso-cone L i) i .up-to-iso-invˡ : ∀ {L X} {i : vertex L ≅ X} → up-to-iso L (transport-by-iso L i) ≡ⁱ i up-to-iso-invˡ {L₁} {i = i} = ≜ⁱ⇒≡ⁱ (up-to-iso-cone-invˡ {L₁} {i = proj₂ (isos-lift-to-cones (proj-cone L₁) i)}) up-to-iso-cone-invʳ : ∀ {L L′} → proj-cone (transport-by-iso-cone L (up-to-iso-cone L L′)) ≜ proj-cone L′ up-to-iso-cone-invʳ {L} {L′} = ≜-refl up-to-iso-invʳ : ∀ {L L′} → vertex (transport-by-iso L (up-to-iso L L′)) ≣ vertex L′ up-to-iso-invʳ {t} {t′} = ≣-refl
{ "alphanum_fraction": 0.5785475148, "avg_line_length": 37.1578947368, "ext": "agda", "hexsha": "9d910ec164f13aa26608545492f59d2182da2d93", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Limit.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Limit.agda", "max_line_length": 160, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Limit.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 3203, "size": 7766 }
open import Data.Maybe open import Data.Product hiding (Σ) open import Axiom.Extensionality.Propositional open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary open import Relation.Nullary.Negation open import EffectAnnotations open import Types module AEff where -- ARITY ASSIGNMENT TO SIGNATURES OF SIGNALS, INTERRUPTS, AND BASE CONSTANTS postulate payload : Σₛ → GType -- payload type assignment for signal and interrupt names postulate Σ-base : Set -- set of base constants postulate ar-base : Σ-base → BType -- arity assignment to base constants -- SNOC LISTS FOR MODELLING CONTEXTS infixl 30 _∷_ data SnocList (A : Set) : Set where [] : SnocList A _∷_ : SnocList A → A → SnocList A -- CONTEXTS AND VARIABLES IN THEM (I.E., DE BRUIJN INDICES) Ctx = SnocList VType data _∈_ (X : VType) : Ctx → Set where Hd : {Γ : Ctx} → X ∈ (Γ ∷ X) Tl : {Γ : Ctx} {Y : VType} → X ∈ Γ → X ∈ (Γ ∷ Y) -- DERIVATIONS OF WELL-TYPED TERMS mutual data _⊢V⦂_ (Γ : Ctx) : VType → Set where `_ : {X : VType} → X ∈ Γ → ------------- Γ ⊢V⦂ X ``_ : (c : Σ-base) → -------------- Γ ⊢V⦂ ``(ar-base c) ƛ : {X : VType} {C : CType} → Γ ∷ X ⊢M⦂ C → ------------- Γ ⊢V⦂ X ⇒ C ⟨_⟩ : {X : VType} → Γ ⊢V⦂ X → ------------- Γ ⊢V⦂ ⟨ X ⟩ infix 40 _·_ data _⊢M⦂_ (Γ : Ctx) : CType → Set where return : {X : VType} {o : O} {i : I} → Γ ⊢V⦂ X → ----------------- Γ ⊢M⦂ X ! (o , i) let=_`in_ : {X Y : VType} {o : O} {i : I} → Γ ⊢M⦂ X ! (o , i) → Γ ∷ X ⊢M⦂ Y ! (o , i) → ----------------------- Γ ⊢M⦂ Y ! (o , i) letrec_`in_ : {X : VType} {C D : CType} → Γ ∷ (X ⇒ C) ∷ X ⊢M⦂ C → Γ ∷ (X ⇒ C) ⊢M⦂ D → ----------------------- Γ ⊢M⦂ D _·_ : {X : VType} {C : CType} → Γ ⊢V⦂ X ⇒ C → Γ ⊢V⦂ X → ------------- Γ ⊢M⦂ C ↑ : {X : VType} {o : O} {i : I} → (op : Σₛ) → op ∈ₒ o → Γ ⊢V⦂ ``(payload op) → Γ ⊢M⦂ X ! (o , i) → ---------------------- Γ ⊢M⦂ X ! (o , i) ↓ : {X : VType} {o : O} {i : I} (op : Σₛ) → Γ ⊢V⦂ ``(payload op) → Γ ⊢M⦂ X ! (o , i) → ---------------------- Γ ⊢M⦂ X ! op ↓ₑ (o , i) promise_∣_↦_`in_ : {X Y : VType} {o o' : O} {i i' : I} → (op : Σₛ) → lkpᵢ op i ≡ just (o' , i') → Γ ∷ ``(payload op) ⊢M⦂ ⟨ X ⟩ ! (o' , i') → Γ ∷ ⟨ X ⟩ ⊢M⦂ Y ! (o , i) → ------------------------------------------ Γ ⊢M⦂ Y ! (o , i) await_until_ : {X : VType} {C : CType} → Γ ⊢V⦂ ⟨ X ⟩ → Γ ∷ X ⊢M⦂ C → -------------- Γ ⊢M⦂ C coerce : {X : VType} {o o' : O} {i i' : I} → o ⊑ₒ o' → i ⊑ᵢ i' → Γ ⊢M⦂ X ! (o , i) → ------------------- Γ ⊢M⦂ X ! (o' , i') -- DERIVATIONS OF WELL-TYPED PROCESSES infix 10 _⊢P⦂_ data _⊢P⦂_ (Γ : Ctx) : {o : O} → PType o → Set where run : {X : VType} {o : O} {i : I} → Γ ⊢M⦂ X ! (o , i) → ------------------- Γ ⊢P⦂ X ‼ o , i _∥_ : {o o' : O} {PP : PType o} → {QQ : PType o'} → Γ ⊢P⦂ PP → Γ ⊢P⦂ QQ → -------------- Γ ⊢P⦂ (PP ∥ QQ) ↑ : {o : O} → {PP : PType o} (op : Σₛ) → op ∈ₒ o → Γ ⊢V⦂ ``(payload op) → Γ ⊢P⦂ PP → ---------------------- Γ ⊢P⦂ PP ↓ : {o : O} {PP : PType o} (op : Σₛ) → Γ ⊢V⦂ ``(payload op) → Γ ⊢P⦂ PP → ---------------------- Γ ⊢P⦂ op ↓ₚ PP
{ "alphanum_fraction": 0.2751515152, "avg_line_length": 27.1978021978, "ext": "agda", "hexsha": "d5e9dc772d59d3c82208742f0d47969cb1ef7acb", "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": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danelahman/aeff-agda", "max_forks_repo_path": "AEff.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "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": "danelahman/aeff-agda", "max_issues_repo_path": "AEff.agda", "max_line_length": 92, "max_stars_count": 4, "max_stars_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danelahman/aeff-agda", "max_stars_repo_path": "AEff.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-22T22:48:48.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-17T00:15:00.000Z", "num_tokens": 1541, "size": 4950 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.HSpace module homotopy.EM1HSpace where module EM₁HSpace {i} (G : AbGroup i) where private module G = AbGroup G mult-loop : (g : G.El) (x : EM₁ G.grp) → x == x mult-loop g = EM₁-elim {P = λ x → x == x} (emloop g) loop' (λ _ _ → set-↓-has-all-paths-↓) where abstract loop' : (g' : G.El) → emloop' G.grp g == emloop g [ (λ x → x == x) ↓ emloop g' ] loop' g' = ↓-idf=idf-in' $ emloop g ∙ emloop g' =⟨ ! (emloop-comp' G.grp g g') ⟩ emloop (G.comp g g') =⟨ ap (emloop' G.grp) (G.comm g g') ⟩ emloop (G.comp g' g) =⟨ emloop-comp' G.grp g' g ⟩ emloop g' ∙ emloop g =⟨ ∙=∙' (emloop g') (emloop g) ⟩ emloop g' ∙' emloop g ∎ mult-hom : GroupHom G.grp (Ω^S-group 0 ⊙[ (EM₁ G.grp → EM₁ G.grp) , (λ x → x) ]) mult-hom = record {f = f; pres-comp = pres-comp} where f = λ g → λ= (mult-loop g) pres-comp = λ g₁ g₂ → ap λ= (λ= (EM₁-elim {P = λ x → mult-loop (G.comp g₁ g₂) x == mult-loop g₁ x ∙ mult-loop g₂ x} (emloop-comp g₁ g₂) (λ _ → prop-has-all-paths-↓) (λ _ _ → set-↓-has-all-paths-↓))) ∙ ! (∙-λ= _ _) mult : EM₁ G.grp → EM₁ G.grp → EM₁ G.grp mult = EM₁-rec {C = EM₁ G.grp → EM₁ G.grp} (λ x → x) mult-hom H-⊙EM₁ : HSpaceStructure (⊙EM₁ G.grp) H-⊙EM₁ = from-alt-h-space $ record { μ = mult; unit-l = unit-l; unit-r = unit-r; coh = coh } where unit-l : (x : EM₁ G.grp) → mult embase x == x unit-l = EM₁-elim {P = λ x → mult embase x == x} idp (λ g → ↓-app=idf-in $ ∙'-unit-l (emloop g) ∙ (! (ap-idf (emloop g))) ∙ ! (∙-unit-r (ap (mult embase) (emloop g)))) (λ _ _ → set-↓-has-all-paths-↓) unit-r : (x : EM₁ G.grp) → mult x embase == x unit-r = EM₁-elim {P = λ x → mult x embase == x} idp (λ g → ↓-app=idf-in $ idp ∙' emloop g =⟨ ∙'-unit-l (emloop g) ⟩ emloop g =⟨ ! (app=-β (mult-loop g) embase) ⟩ app= (λ= (mult-loop g)) embase =⟨ ! (EM₁Rec.emloop-β {C = EM₁ G.grp → EM₁ G.grp} (λ x → x) mult-hom g) |in-ctx (λ w → app= w embase) ⟩ app= (ap mult (emloop g)) embase =⟨ ∘-ap (λ f → f embase) mult (emloop g) ⟩ ap (λ z → mult z embase) (emloop g) =⟨ ! (∙-unit-r (ap (λ z → mult z embase) (emloop g))) ⟩ ap (λ z → mult z embase) (emloop g) ∙ idp ∎) (λ _ _ → set-↓-has-all-paths-↓) coh : unit-l embase == unit-r embase coh = idp open HSpaceStructure H-⊙EM₁
{ "alphanum_fraction": 0.4751587598, "avg_line_length": 32.2530120482, "ext": "agda", "hexsha": "b9df313dcef79828146d42b2556b1029eeac8339", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/EM1HSpace.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1068, "size": 2677 }
module Sigma.Renaming.Vec where open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Fin as Fin using (Fin; zero; suc) open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) open import Data.Vec as V using (Vec; []; _∷_; map; _[_]≔_) renaming (head to headᵥ; tail to tailᵥ; lookup to lookupᵥ; insert to insertᵥ; remove to removeᵥ; updateAt to updateAtᵥ) open import Data.HVec as HV using (HVec; []; _∷_) renaming (head to headₕ; tail to tailₕ; lookup to lookupₕ; insert to insertₕ; remove to removeₕ; updateAt to updateAtₕ) open import Function as Fun using (_∘_) open import Sigma.Renaming.Base as R using (Ren) renaming (id to idᵣ; ↑ to ↑ᵣ; _⇑ to _⇑ᵣ) open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl; sym; trans; cong; cong₂; cong-app; subst) open Eq.≡-Reasoning -- ------------------------------------------------------------------------ -- Vectored Renaming Shape -- A renaming ρ : 𝕀ᵐ → 𝕀ⁿ is defined by a *shape*, denoted m ↦ n. -- -- Similarly, a vectored renaming ρs = [ρ₁ ; ...; ρₖ] : [𝕀ᵐ₁ → 𝕀ⁿ₁, ...; 𝕀ᵐₖ → 𝕀ⁿₖ] -- is defined by a vector of renaming shapes, denoted [m₁ ↦ n₁; ...; mₖ ↦ nₖ] module Shape where open import Data.Vec using (lookup; replicate; _[_]%=_; _[_]≔_) -- TODO: Implement shape for renaming? Shape : ℕ → Set Shape n = Vec (ℕ × ℕ) n -- ------------------------------------------- pattern _↦_ m n = ⟨ m , n ⟩ shape : ∀ { n } → Shape n → Fin n → ℕ × ℕ shape = lookup dom : ∀ { n } → Shape n → Fin n → ℕ dom s = proj₁ ∘ (shape s) rng : ∀ { n } → Shape n → Fin n → ℕ rng s = proj₂ ∘ (shape s) -- ------------------------------------------- id : ∀ { m } → ℕ → Shape m id n = replicate (n ↦ n) ↑ : ∀ { m } → ℕ → Fin m → Shape m ↑ n i = id n [ i ]≔ n ↦ (1 + n) -- TODO: This may become a pain, used a hack to use := instead of -- %= infix 10 _⇑_ _⇑_ : ∀ { n } → Shape n → Fin n → Shape n s ⇑ i = s [ i ]≔ ⇑ (lookup s i) where ⇑ : ℕ × ℕ → ℕ × ℕ ⇑ (m ↦ n) = (1 + m) ↦ (1 + n) open Shape using (Shape; _↦_) renaming (id to idₛ; ↑ to ↑ₛ; _⇑_ to _⇑ₛ_) -- TODO: Move this when implementing shapes on renamings? -- IDEA: Call it an interpretation of a shape -- use the nice brackets ;) ⦅_⦆ : ℕ × ℕ → Set ⦅ m ↦ n ⦆ = Ren m n -- ------------------------------------------------------------------------ -- Vectored Renaming -- A vectored renaming ρs = [ρ₁ ; ...; ρₖ] : [𝕀ᵐ₁ → 𝕀ⁿ₁, ...; 𝕀ᵐₖ → 𝕀ⁿₖ] -- defined by it's shape: [m₁ ↦ n₁; ...; mₖ ↦ nₖ] -- It is implemented as a hetrogenous vector. VRen : ∀ n → Shape n → Set VRen n shape = HVec n (map ⦅_⦆ shape) length : ∀ { n S } → VRen n S → ℕ length { n = n } _ = n shape : ∀ { n S } → VRen n S → Shape n shape { S = shape } _ = shape -- ------------------------------------------------------------------------ -- Basic operations (ported from HVec) -- Anonymous module containing properties about -- Data.Vec's map composed w/ other operations module _ { ℓ₁ ℓ₂ } { A : Set ℓ₁ } { B : Set ℓ₂ } where open import Data.Vec using (head; tail; insert; remove) private variable m n k : ℕ open import Data.Vec.Properties using (lookup-map; map-[]≔) public unfold-map : (f : A → B) (x : A) (xs : Vec A n) → map f (x ∷ xs) ≡ f x ∷ map f xs unfold-map f x [] = refl unfold-map f x (_ ∷ xs) = refl unfold-remove : (x : A) (xs : Vec A (1 + n)) (i : Fin (1 + n)) → remove (x ∷ xs) (suc i) ≡ x ∷ remove xs i unfold-remove x (_ ∷ xs) zero = refl unfold-remove x (y ∷ xs) (suc i) = refl head-map : (f : A → B) (xs : Vec A (1 + n)) → head (map f xs) ≡ f (head xs) head-map f (x ∷ xs) = refl tail-map : (f : A → B) (xs : Vec A (1 + n)) → tail (map f xs) ≡ map f (tail xs) tail-map f (x ∷ xs) = refl insert-map : (f : A → B) (x : A) (xs : Vec A n) (i : Fin (1 + n)) → insert (map f xs) i (f x) ≡ map f (insert xs i x) insert-map f x xs zero = refl insert-map f x (_ ∷ xs) (suc i) rewrite insert-map f x xs i = refl remove-map : (f : A → B) (xs : Vec A (1 + n)) (i : Fin (1 + n)) → remove (map f xs) i ≡ map f (remove xs i) remove-map f (_ ∷ xs) zero = refl remove-map f (x ∷ y ∷ xs) (suc i) rewrite remove-map f (y ∷ xs) i = refl module _ where private variable m n k : ℕ S : Shape m head : VRen (1 + m) S → ⦅ headᵥ S ⦆ head ρs rewrite sym (head-map ⦅_⦆ (shape ρs)) = headₕ ρs tail : VRen (1 + m) S → VRen m (tailᵥ S) tail ρs rewrite sym (tail-map ⦅_⦆ (shape ρs)) = tailₕ ρs lookup : VRen m S → (i : Fin m) → ⦅ lookupᵥ S i ⦆ lookup ρs i rewrite sym (lookup-map i ⦅_⦆ (shape ρs)) = lookupₕ ρs i insert : VRen m S → (i : Fin (1 + m)) → Ren n k → VRen (1 + m) (insertᵥ S i (n ↦ k)) insert { n = n } { k = k } ρs i ρ rewrite sym (insert-map ⦅_⦆ (n ↦ k) (shape ρs) i) = insertₕ ρs i ρ remove : VRen (1 + m) S → (i : Fin (1 + m)) → VRen m (removeᵥ S i) remove ρs i rewrite sym (remove-map ⦅_⦆ (shape ρs) i) = removeₕ ρs i updateAt : (i : Fin m) → (⦅ lookupᵥ S i ⦆ → Ren n k) → VRen m S → VRen m (S [ i ]≔ n ↦ k) updateAt { n = n } { k = k } i f ρs rewrite map-[]≔ ⦅_⦆ (shape ρs) i { x = n ↦ k } = updateAtₕ i f' ρs where f' : lookupᵥ (map ⦅_⦆ (shape ρs)) i → Ren n k f' rewrite lookup-map i ⦅_⦆ (shape ρs) = f infixl 6 _[_]$=_ _[_]$=_ : VRen m S → (i : Fin m) → (⦅ lookupᵥ S i ⦆ → Ren n k) → VRen m (S [ i ]≔ n ↦ k) ρs [ i ]$= f = updateAt i f ρs infixl 6 _[_]&=_ _[_]&=_ : VRen m S → (i : Fin m) → Ren n k → VRen m (S [ i ]≔ n ↦ k) ρs [ i ]&= ρ = ρs [ i ]$= Fun.const ρ -- ------------------------------------------------------------------------ -- Primitives id : ∀ m { n } → VRen m (idₛ n) id zero = [] id (suc m) = idᵣ ∷ id m ↑ : ∀ m { n } → (i : Fin m) → VRen m (↑ₛ n i) ↑ m i = (id m) [ i ]&= ↑ᵣ _⇑_ : ∀ { n S } → VRen n S → (i : Fin n) → VRen n (S ⇑ₛ i) ρs ⇑ i = ρs [ i ]$= (_⇑ᵣ) -- ------------------------------------------------------------------------
{ "alphanum_fraction": 0.5024382041, "avg_line_length": 31.3, "ext": "agda", "hexsha": "27b42ba1e2b74dde677979cbf89311540f61a7cc", "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": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-sigma", "max_forks_repo_path": "src/Sigma/Renaming/Vec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "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-sigma", "max_issues_repo_path": "src/Sigma/Renaming/Vec.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-sigma", "max_stars_repo_path": "src/Sigma/Renaming/Vec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2394, "size": 5947 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Issue3a where module A where postulate D : Set _≡_ : D → D → Set a b : D postulate p : a ≡ b open A {-# ATP axiom p #-} postulate foo : a ≡ b {-# ATP prove foo #-}
{ "alphanum_fraction": 0.4986449864, "avg_line_length": 17.5714285714, "ext": "agda", "hexsha": "94ae2aa17601c68ad60fe31476e3e9a27841000d", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/Issue3a.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/Issue3a.agda", "max_line_length": 42, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/Issue3a.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 104, "size": 369 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Magma.MorphismProperties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Univalence open import Cubical.Foundations.SIP open import Cubical.Foundations.Function using (_∘_; id) open import Cubical.Foundations.GroupoidLaws open import Cubical.Functions.Embedding open import Cubical.Data.Sigma open import Cubical.Data.Prod using (isPropProd) open import Cubical.Algebra open import Cubical.Algebra.Properties open import Cubical.Algebra.Magma.Morphism open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Structures.Record open import Cubical.Relation.Binary.Reasoning.Equality open Iso private variable ℓ ℓ′ ℓ′′ : Level L : Magma ℓ M : Magma ℓ′ N : Magma ℓ′′ isPropIsMagmaHom : ∀ (M : Magma ℓ) (N : Magma ℓ′) f → isProp (IsMagmaHom M N f) isPropIsMagmaHom M N f = isPropHomomorphic₂ (Magma.is-set N) f (Magma._•_ M) (Magma._•_ N) isSetMagmaHom : isSet (M ⟶ᴴ N) isSetMagmaHom {M = M} {N = N} = isOfHLevelRespectEquiv 2 equiv (isSetΣ (isSetΠ λ _ → is-set N) (λ f → isProp→isSet (isPropIsMagmaHom M N f))) where open Magma equiv : (Σ[ g ∈ (⟨ M ⟩ → ⟨ N ⟩) ] IsMagmaHom M N g) ≃ MagmaHom M N equiv = isoToEquiv (iso (λ (g , m) → magmahom g m) (λ (magmahom g m) → g , m) (λ _ → refl) λ _ → refl) isMagmaHomComp : {f : ⟨ L ⟩ → ⟨ M ⟩} {g : ⟨ M ⟩ → ⟨ N ⟩} → IsMagmaHom L M f → IsMagmaHom M N g → IsMagmaHom L N (g ∘ f) isMagmaHomComp {g = g} fHom gHom _ _ = cong g (fHom _ _) ∙ gHom _ _ private isMagmaHomComp′ : (f : L ⟶ᴴ M) (g : M ⟶ᴴ N) → IsMagmaHom L N (MagmaHom.fun g ∘ MagmaHom.fun f) isMagmaHomComp′ (magmahom f fHom) (magmahom g gHom) _ _ = cong g (fHom _ _) ∙ gHom _ _ compMagmaHom : (L ⟶ᴴ M) → (M ⟶ᴴ N) → (L ⟶ᴴ N) compMagmaHom f g = magmahom _ (isMagmaHomComp′ f g) compMagmaEquiv : L ≃ᴴ M → M ≃ᴴ N → L ≃ᴴ N compMagmaEquiv f g = magmaequiv (compEquiv f.eq g.eq) (isMagmaHomComp′ f.hom g.hom) where module f = MagmaEquiv f module g = MagmaEquiv g isMagmaHomId : (M : Magma ℓ) → IsMagmaHom M M id isMagmaHomId M _ _ = refl idMagmaHom : (M : Magma ℓ) → (M ⟶ᴴ M) idMagmaHom M = record { fun = id ; isHom = isMagmaHomId M } idMagmaEquiv : (M : Magma ℓ) → M ≃ᴴ M idMagmaEquiv M = record { eq = idEquiv ⟨ M ⟩ ; isHom = isMagmaHomId M } -- Isomorphism inversion isMagmaHomInv : (eqv : M ≃ᴴ N) → IsMagmaHom N M (invEq (MagmaEquiv.eq eqv)) isMagmaHomInv {M = M} {N = N} (magmaequiv eq isHom) x y = isInj-f _ _ ( f (f⁻¹ (x •ᴺ y)) ≡⟨ retEq eq _ ⟩ x •ᴺ y ≡˘⟨ cong₂ _•ᴺ_ (retEq eq x) (retEq eq y) ⟩ f (f⁻¹ x) •ᴺ f (f⁻¹ y) ≡˘⟨ isHom (f⁻¹ x) (f⁻¹ y) ⟩ f (f⁻¹ x •ᴹ f⁻¹ y) ∎) where _•ᴹ_ = Magma._•_ M _•ᴺ_ = Magma._•_ N f = equivFun eq f⁻¹ = invEq eq isInj-f : (x y : ⟨ M ⟩) → f x ≡ f y → x ≡ y isInj-f x y = invEq (_ , isEquiv→isEmbedding (eq .snd) x y) invMagmaHom : M ≃ᴴ N → (N ⟶ᴴ M) invMagmaHom eq = record { isHom = isMagmaHomInv eq } invMagmaEquiv : (M ≃ᴴ N) → (N ≃ᴴ M) invMagmaEquiv eq = record { eq = invEquiv (MagmaEquiv.eq eq) ; isHom = isMagmaHomInv eq } magmaHomEq : {f g : M ⟶ᴴ N} → (MagmaHom.fun f ≡ MagmaHom.fun g) → f ≡ g magmaHomEq {M = M} {N = N} {magmahom f fm} {magmahom g gm} p i = magmahom (p i) (p-hom i) where p-hom : PathP (λ i → IsMagmaHom M N (p i)) fm gm p-hom = toPathP (isPropIsMagmaHom M N _ _ _) magmaEquivEq : {f g : M ≃ᴴ N} → (MagmaEquiv.eq f ≡ MagmaEquiv.eq g) → f ≡ g magmaEquivEq {M = M} {N = N} {magmaequiv f fm} {magmaequiv g gm} p i = magmaequiv (p i) (p-hom i) where p-hom : PathP (λ i → IsMagmaHom M N (p i .fst)) fm gm p-hom = toPathP (isPropIsMagmaHom M N _ _ _) module MagmaΣTheory {ℓ} where RawMagmaStructure : Type ℓ → Type ℓ RawMagmaStructure A = A → A → A RawMagmaEquivStr = AutoEquivStr RawMagmaStructure rawMagmaUnivalentStr : UnivalentStr _ RawMagmaEquivStr rawMagmaUnivalentStr = autoUnivalentStr RawMagmaStructure MagmaAxioms : (A : Type ℓ) → RawMagmaStructure A → Type ℓ MagmaAxioms A _•_ = isSet A MagmaStructure : Type ℓ → Type ℓ MagmaStructure = AxiomsStructure RawMagmaStructure MagmaAxioms MagmaΣ : Type (ℓ-suc ℓ) MagmaΣ = TypeWithStr ℓ MagmaStructure isPropMagmaAxioms : (A : Type ℓ) (_•_ : RawMagmaStructure A) → isProp (MagmaAxioms A _•_) isPropMagmaAxioms _ _ = isPropIsSet MagmaEquivStr : StrEquiv MagmaStructure ℓ MagmaEquivStr = AxiomsEquivStr RawMagmaEquivStr MagmaAxioms MagmaAxiomsIsoIsMagma : {A : Type ℓ} (_•_ : RawMagmaStructure A) → Iso (MagmaAxioms A _•_) (IsMagma A _•_) fun (MagmaAxiomsIsoIsMagma s) x = ismagma x inv (MagmaAxiomsIsoIsMagma s) (ismagma x) = x rightInv (MagmaAxiomsIsoIsMagma s) _ = refl leftInv (MagmaAxiomsIsoIsMagma s) _ = refl MagmaAxioms≡IsMagma : {A : Type ℓ} (_•_ : RawMagmaStructure A) → MagmaAxioms A _•_ ≡ IsMagma A _•_ MagmaAxioms≡IsMagma s = isoToPath (MagmaAxiomsIsoIsMagma s) Magma→MagmaΣ : Magma ℓ → MagmaΣ Magma→MagmaΣ (mkmagma A _•_ isMagma) = A , _•_ , MagmaAxiomsIsoIsMagma _ .inv isMagma MagmaΣ→Magma : MagmaΣ → Magma ℓ MagmaΣ→Magma (A , _•_ , isMagma•) = mkmagma A _•_ (MagmaAxiomsIsoIsMagma _ .fun isMagma•) MagmaIsoMagmaΣ : Iso (Magma ℓ) MagmaΣ MagmaIsoMagmaΣ = iso Magma→MagmaΣ MagmaΣ→Magma (λ _ → refl) (λ _ → refl) magmaUnivalentStr : UnivalentStr MagmaStructure MagmaEquivStr magmaUnivalentStr = axiomsUnivalentStr _ isPropMagmaAxioms rawMagmaUnivalentStr MagmaΣPath : (M N : MagmaΣ) → (M ≃[ MagmaEquivStr ] N) ≃ (M ≡ N) MagmaΣPath = SIP magmaUnivalentStr MagmaEquivΣ : (M N : Magma ℓ) → Type ℓ MagmaEquivΣ M N = Magma→MagmaΣ M ≃[ MagmaEquivStr ] Magma→MagmaΣ N MagmaIsoΣPath : {M N : Magma ℓ} → Iso (MagmaEquiv M N) (MagmaEquivΣ M N) fun MagmaIsoΣPath (magmaequiv e h) = (e , h) inv MagmaIsoΣPath (e , h) = magmaequiv e h rightInv MagmaIsoΣPath _ = refl leftInv MagmaIsoΣPath _ = refl MagmaPath : (M N : Magma ℓ) → (MagmaEquiv M N) ≃ (M ≡ N) MagmaPath M N = MagmaEquiv M N ≃⟨ isoToEquiv MagmaIsoΣPath ⟩ MagmaEquivΣ M N ≃⟨ MagmaΣPath _ _ ⟩ Magma→MagmaΣ M ≡ Magma→MagmaΣ N ≃⟨ isoToEquiv (invIso (congIso MagmaIsoMagmaΣ)) ⟩ M ≡ N ■ RawMagmaΣ : Type (ℓ-suc ℓ) RawMagmaΣ = TypeWithStr ℓ RawMagmaStructure Magma→RawMagmaΣ : Magma ℓ → RawMagmaΣ Magma→RawMagmaΣ M = (⟨ M ⟩ , Magma._•_ M) InducedMagma : (M : Magma ℓ) (N : RawMagmaΣ) (e : ⟨ M ⟩ ≃ ⟨ N ⟩) → RawMagmaEquivStr (Magma→RawMagmaΣ M) N e → Magma ℓ InducedMagma M N e r = MagmaΣ→Magma (inducedStructure rawMagmaUnivalentStr (Magma→MagmaΣ M) N (e , r)) InducedMagmaPath : (M : Magma ℓ) (N : RawMagmaΣ) (e : ⟨ M ⟩ ≃ ⟨ N ⟩) (E : RawMagmaEquivStr (Magma→RawMagmaΣ M) N e) → M ≡ InducedMagma M N e E InducedMagmaPath M N e E = MagmaPath M (InducedMagma M N e E) .fst (magmaequiv e E) open MagmaΣTheory public using (InducedMagma; InducedMagmaPath) MagmaPath : (M ≃ᴴ N) ≃ (M ≡ N) MagmaPath = MagmaΣTheory.MagmaPath _ _ open Magma uaMagma : M ≃ᴴ N → M ≡ N uaMagma = equivFun MagmaPath carac-uaMagma : {M N : Magma ℓ} (f : M ≃ᴴ N) → cong Carrier (uaMagma f) ≡ ua (MagmaEquiv.eq f) carac-uaMagma (magmaequiv f m) = (refl ∙∙ ua f ∙∙ refl) ≡˘⟨ rUnit (ua f) ⟩ ua f ∎ Magma≡ : (M N : Magma ℓ) → ( Σ[ p ∈ ⟨ M ⟩ ≡ ⟨ N ⟩ ] Σ[ q ∈ PathP (λ i → p i → p i → p i) (_•_ M) (_•_ N) ] PathP (λ i → IsMagma (p i) (q i)) (isMagma M) (isMagma N)) ≃ (M ≡ N) Magma≡ M N = isoToEquiv (iso (λ (p , q , r) i → mkmagma (p i) (q i) (r i)) (λ p → cong Carrier p , cong _•_ p , cong isMagma p) (λ _ → refl) (λ _ → refl)) caracMagma≡ : (p q : M ≡ N) → cong Carrier p ≡ cong Carrier q → p ≡ q caracMagma≡ {M = M} {N = N} p q t = cong (Magma≡ M N .fst) (Σ≡Prop (λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set N) _ _) λ _ → isOfHLevelPathP 1 (λ { (ismagma x) (ismagma y) → cong ismagma (isPropIsSet x y) }) _ _) t) uaMagmaId : (M : Magma ℓ) → uaMagma (idMagmaEquiv M) ≡ refl uaMagmaId M = caracMagma≡ _ _ (carac-uaMagma (idMagmaEquiv M) ∙ uaIdEquiv) uaCompMagmaEquiv : {L M N : Magma ℓ} (f : L ≃ᴴ M) (g : M ≃ᴴ N) → uaMagma (compMagmaEquiv f g) ≡ uaMagma f ∙ uaMagma g uaCompMagmaEquiv f g = caracMagma≡ _ _ ( cong Carrier (uaMagma (compMagmaEquiv f g)) ≡⟨ carac-uaMagma (compMagmaEquiv f g) ⟩ ua (eq (compMagmaEquiv f g)) ≡⟨ uaCompEquiv _ _ ⟩ ua (eq f) ∙ ua (eq g) ≡⟨ cong (_∙ ua (eq g)) (sym (carac-uaMagma f)) ⟩ cong Carrier (uaMagma f) ∙ ua (eq g) ≡⟨ cong (cong Carrier (uaMagma f) ∙_) (sym (carac-uaMagma g)) ⟩ cong Carrier (uaMagma f) ∙ cong Carrier (uaMagma g) ≡⟨ sym (cong-∙ Carrier (uaMagma f) (uaMagma g)) ⟩ cong Carrier (uaMagma f ∙ uaMagma g) ∎) where open MagmaEquiv
{ "alphanum_fraction": 0.621068505, "avg_line_length": 35.7076923077, "ext": "agda", "hexsha": "523bedea1f509a50cc239b76a4b76c60ae95976c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Magma/MorphismProperties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Magma/MorphismProperties.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Magma/MorphismProperties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3959, "size": 9284 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.TruncatedHIT open import Sets.Quotient module Sets.QuotientUP {i j} (A : Set i) ⦃ A-set : is-set A ⦄ (R : A → A → Set j) ⦃ R-prop : (x y : A) → is-prop (R x y) ⦄ where -- [X →→ Y ~ R] is the set of functions [X → Y] respecting the relation [R] _→→_~_ : ∀ {i j k} (X : Set i) ⦃ X-set : is-set X ⦄ (Y : Set j) ⦃ Y-set : is-set Y ⦄ (R : X → X → Set k) ⦃ R-prop : (x x' : X) → is-prop (R x x')⦄ → Set _ X →→ Y ~ R = Σ (X → Y) (λ f → (x x' : X) → (R x x' → f x ≡ f x')) module UP {k} (B : Set k) (B-set : is-set B) where factor : ((A →→ B ~ R) → (A / R → B)) factor (f , p) = /-rec-nondep A R B f p B-set extend : ((A / R → B) → (A →→ B ~ R)) extend f = ((f ◯ proj A R) , (λ x x' p₁ → ap f (eq A R x x' p₁))) extend-factor : (f : A →→ B ~ R) → extend (factor f) ≡ f extend-factor (f , p) = ap (λ x → f , x) (funext (λ x → funext (λ x' → funext (λ p₁ → π₁ (B-set _ _ _ _))))) factor-extend : (f : A / R → B) → factor (extend f) ≡ f factor-extend f = funext (/-rec A R (λ x → factor (extend f) x ≡ f x) (λ x → refl) (λ x y _ → π₁ (B-set _ _ _ _)) (λ x → truncated-is-truncated-S _ (B-set _ _)))
{ "alphanum_fraction": 0.4511450382, "avg_line_length": 34.4736842105, "ext": "agda", "hexsha": "97db760c9385a8babc18b04a09f753b5985863c9", "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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Sets/QuotientUP.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "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": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Sets/QuotientUP.agda", "max_line_length": 75, "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": "old/Sets/QuotientUP.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": 535, "size": 1310 }
module Issue1168 where id : {A : Set} → A → A id {A = A} a = a
{ "alphanum_fraction": 0.53125, "avg_line_length": 12.8, "ext": "agda", "hexsha": "c757cd254a50a642ef0a76dba21e607cadac36e5", "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/api/Issue1168.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/api/Issue1168.agda", "max_line_length": 22, "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/api/Issue1168.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 28, "size": 64 }
module Compilation.Encode.Core where open import Context open import Type.Core open import Compilation.Data open import Function open import Data.List.Base as List {- Note [Compilation] We compile data descriptions to System Fωμ in two steps: 1. Lambda-bind a) a tag to distinguish between the data types from the family b) a variable for each of the data types from the family then apply the tag to all of the data types after Scott-encoding them in order to be able to choose one particular data type from the family later. This way we get a valid System Fωμ type, but it's not a legal pattern functor yet, as it binds one tag and `n` variables responsible for recursion and we need to have only one variable responsible for recursion and one tag in order to be able to feed a type function to `μ` and actually tie the knot. Thus the next step is 2. Instantiate all the variables responsible for recursion using a single variable applied to distinct tags. This way we transform `1` (tag) + `n` (recursion) variables into `1` (recursion) + `1` (tag) variables, i.e. just two variables of right kinds, thus the result can be passed to `μ`. We can now look at the `ProdTree`/`Tree` example. After the first step (which is performed by the `encodeDataN` function, which calls `scottEncode` internally) we get the following type (I'll save you from the De Bruijn reverse Turing test and use the Agda notation instead, but note that this is still a System Fωμ type): > prodTreeTreeReprN = > λ (tag : (Set -> Set -> Set) -> (Set -> Set) -> Set) > (prodTree : Set -> Set -> Set) (tree : Set -> Set) -> > ∀ (R : Set) -> -- Binding the result variable. > tag -- Choosing between the two data types. > (λ A B -- The two types that `ProdTree` binds. > -> (tree (∀ Q -> (A -> B -> Q) -> Q) -> R) -- Case over the `Prod` constructor. > -> R) > (λ A -- The type that `Tree` binds. > -> (A -> R) -- Case over the `Leaf` constructor. > -> (prodTree A A -> R) -- Case over the `Fork` constructor. > -> R) Here we lambda-bind `prodTree` and `tree` directly, Scott-encode the definition of the data types and use `tag` in order to choose between the two data types. At the next step we instantiate `prodTree` and `tree` (`instantiations` computes the instantiations) using a single `rec` (`packEncodedDataN` does this): > prodTreeTreeRepr1 = > λ (rec : ((Set -> Set -> Set) -> (Set -> Set) -> Set) -> Set) > (tag : (Set -> Set -> Set) -> (Set -> Set) -> Set) -> > prodTreeTreeReptN > tag > (λ A B -> rec λ prodTree tree -> prodTree A B) > (λ A -> rec λ prodTree tree -> tree A) It only remains to take the fixed point of this pattern functor: > prodTreeTree = λ tag -> μ prodTreeTreeRepr1 tag And that's it, `prodTreeTree` is a valid System Fωμ type that encodes the `ProdTree`/`Tree` family. -} {- Note [Data description denotations] Once we compile a data description to a System Fωμ type, we could already take the denotation of the latter, but then we'd just get an Agda type that encodes the whole family of mutually recursive data types, while what we really want is getting all the separate data types, not the whole family at once. Hence rather than take the denotation directly, we first instantiate the resulting System Fωμ type using the tags that the data types from the family correspond to. I.e. we call `instantiations` once again, get an environment of System Fωμ types and take denotations of those. The result then is an environment of Agda types, each of which represents a data type from the original family of data types. We only need to extract them from the environment. Unfortunately, Agda lacks top-level matches, so we do it like this: > ProdTreeTree′ = Encoded.⟦ prodTreeTree ⟧ᵈ > > ProdTree′ : Set -> Set -> Set > ProdTree′ with ProdTreeTree′ > ... | ∅ ▷ PT′ ▷ T′ = PT′ > > Tree′ : Set -> Set > Tree′ with ProdTreeTree′ > ... | ∅ ▷ PT′ ▷ T′ = T′ -} -- | Get the kind of tags from the context of a data description. -- -- > dataConToTagKind (ε ▻ (σ¹₁ ▻ … ▻ σ¹ₙ₁) ▻ … ▻ (σ¹ₘ ▻ … ▻ σᵐₙₘ)) τ = -- > (σ¹₁ ⇒ᵏ … ⇒ᵏ σ¹ₙ₁ ⇒ᵏ ⋆) ⇒ᵏ … ⇒ᵏ (σ¹₁ ⇒ᵏ … ⇒ᵏ σᵐₙₘ ⇒ᵏ ⋆) ⇒ᵏ τ dataConToTagKind : Con Conᵏ -> Kind -> Kind dataConToTagKind = conToKindBy $ λ Θ -> conToKind Θ ⋆ -- | Scott-encode a single data type. The type variable (denoted as `ρ`) that represents -- the result is assumed to be in scope, because we Scott-encode a bunch of data types -- at the same time and hence the resulting type variable has to be bound outside of all of them, -- which is why we keep it implicit while encoding a single data type. -- -- > scottEncode (ε ▻ α₁ ▻ … ▻ αₙ) [(β¹₁ ⇒ᶜ … ⇒ᶜ β¹ₙ₁ ⇒ᶜ endᶜ) , … , (βᵐ₁ ⇒ᶜ … ⇒ᶜ βᵐₙₘ ⇒ᶜ endᶜ)] = -- > λ α₁ … αₙ → (β¹₁ ⇒ … ⇒ β¹ₙ₁ ⇒ ρ) ⇒ … ⇒ (βᵐ₁ ⇒ … ⇒ βᵐₙₘ ⇒ ρ) ⇒ ρ scottEncode : ∀ {Ξ} Θ -> List (Cons (Ξ ▻▻ Θ)) -> Ξ ▻ ⋆ ⊢ᵗ conToKind Θ ⋆ scottEncode Θ = Lamⁿ' Θ ∘ foldr (λ ξ γ -> consToType (renᶜ (keepⁿ Θ topᵒ) ξ) ρ ⇒ γ) ρ where ρ = renᵗ (extʳ Θ) $ Var vz -- | Encode a `Data` description as an n-ary type function. -- -- > encodeDataN (PackData [data¹ , … , dataᵐ]) = -- > λ tag δ¹ … δᵐ → tag (scott data¹) … (scott dataᵐ) -- -- (`δᵢ` is the name of `dataᵢ` that is potentially used internally in any `dataⱼ`, -- because the data types are allowed to be mutually recursive). encodeDataN : ∀ {Ξ Θs} -> Data Ξ Θs -> Ξ ⊢ᵗ dataConToTagKind Θs ⋆ ⇒ᵏ dataConToTagKind Θs ⋆ encodeDataN {Ξ} {Θs} (PackData datas) = Lam_ ∘′ Lamⁿ Θs ∘′ π ⋆ $′ applyᵗⁿ Θs (Var ∘ vsⁿ $ mapᶜ _ Θs ▻ ⋆) (mapˢ (λ {Θ} -> renᵗ (keepⁿ (mapᶜ _ Θs ▻ ⋆) topᵒ) ∘ scottEncode Θ) datas) -- | Compute all instantiations of a thing of kind `dataConToTagKind Θs ⋆ ⇒ᵏ ⋆`, which is either -- the first variable that a packed pattern functor binds (i.e. the one responsible for recursion) -- or the final data type representing a family of mutually recursive data types. -- "Instantiations" then are particular data types from a family of mutually recursive data types -- (or represent them if we're are inside a pattern functor). -- For example, the instantiations of `treeForest` are `tree` and `forest`, i.e. precisely those -- data types that form the family. -- -- > instantiations ψ -- > = ∅ -- > ▷ (λ α¹₁ … α¹ₙ₁ → ψ λ β¹ … βᵐ → β¹ α¹₁ … α¹ₙ₁) -- > ▷ … -- > ▷ (λ αᵐ₁ … αᵐₙₘ → ψ λ β¹ … βᵐ → βᵐ αᵐ₁ … αᵐₙₘ) instantiations : ∀ {Θs Ξ} -> Ξ ⊢ᵗ dataConToTagKind Θs ⋆ ⇒ᵏ ⋆ -> Seq (λ Θ -> Ξ ⊢ᵗ conToKind Θ ⋆) Θs instantiations {ε} ψ = ø instantiations {Θs ▻ Θ} ψ = instantiations {Θs} (Lam_ $ shiftᵗ ψ ∙ Lamⁿ (Θs ▻ Θ) (applyᵗⁿ Θs (Var (vsⁿ (mapᶜ _ (Θs ▻ Θ)))) (mapˢ shiftᵗ subVars))) ▶ Lamⁿ' Θ (shiftᵗⁿ Θ ψ ∙ Lamⁿ (Θs ▻ Θ) (applyᵗⁿ Θ (Var vz) (mapˢ (shiftᵗⁿ (mapᶜ _ $ Θs ▻ Θ)) subVars'))) -- | Pack an encoded family of mutually recursive data types as an 1-ary pattern functor. -- The encoded family is of this form (see `encodeDataN`): -- -- > φ : ((σ¹₁ ⇒ᵏ … ⇒ᵏ σ¹ₙ₁ ⇒ᵏ ⋆) ⇒ᵏ … ⇒ᵏ (σᵐ₁ ⇒ᵏ … ⇒ᵏ σᵐₙₘ ⇒ᵏ ⋆) ⇒ᵏ ⋆) -- > ⇒ᵏ (σ¹₁ ⇒ᵏ … ⇒ᵏ σ¹ₙ₁ ⇒ᵏ ⋆) ⇒ᵏ … ⇒ᵏ (σᵐ₁ ⇒ᵏ … ⇒ᵏ σᵐₙₘ ⇒ᵏ ⋆) ⇒ᵏ ⋆ -- > φ = λ tag δ¹ … δᵐ → <body> -- -- Where `tag` is a tag and `δʲ` is a variable that stands for a data type from the family. -- -- The definition of `packEncodedDataN` then is -- -- > packEncodedDataN _ φ = -- > λ rec tag → φ tag -- > (λ α¹₁ … α¹ₙ₁ → rec λ ψ¹ … ψᵐ → ψ¹ α¹₁ … α¹ₙ₁) -- > … -- > (λ αᵐ₁ … αᵐₙₘ → rec λ ψ¹ … ψᵐ → ψᵐ αᵐ₁ … αᵐₙₘ) -- -- where `αʲᵢ` is a parameter of a data type and `λ ψ¹ … ψᵐ → ψʲ αʲ₁ … αʲᵢ` is the tag of -- the data type. That is, we put parameters of data types into their corresponding tags. -- -- So we instantiate each data type argument of `φ` as `rec` applied to an appropriate tag. This -- way we represent all of the data types using just a single `rec` applied to different tags. packEncodedDataN : ∀ {Ξ} Θs -> Ξ ⊢ᵗ dataConToTagKind Θs ⋆ ⇒ᵏ dataConToTagKind Θs ⋆ -> Ξ ⊢ᵗ (dataConToTagKind Θs ⋆ ⇒ᵏ ⋆) ⇒ᵏ dataConToTagKind Θs ⋆ ⇒ᵏ ⋆ packEncodedDataN Θs φ = Lam_ ∘′ Lam_ ∘′ applyᵗⁿ Θs (shiftᵗⁿ (ε ▻ _ ▻ _) φ ∙ Var vz) ∘′ instantiations $ Var (vs vz) -- | Encode a `Data` as a 1-ary pattern functor. encodeData1 : ∀ {Ξ Θs} -> Data Ξ Θs -> Ξ ⊢ᵗ (dataConToTagKind Θs ⋆ ⇒ᵏ ⋆) ⇒ᵏ dataConToTagKind Θs ⋆ ⇒ᵏ ⋆ encodeData1 {Θs = Θs} = packEncodedDataN Θs ∘ encodeDataN -- | Compile a `Data` to System Fωμ. compileData : ∀ {Ξ Θs} -> Data Ξ Θs -> Ξ ⊢ᵗ dataConToTagKind Θs ⋆ ⇒ᵏ ⋆ compileData d = Lam μ (shiftᵗ $ encodeData1 d) (Var vz) compileDatas : ∀ {Ξ Θs} -> Data Ξ Θs -> Seq (λ Θ -> Ξ ⊢ᵗ conToKind Θ ⋆) Θs compileDatas = instantiations ∘ compileData -- | Return the denotations of all the data types from a family of mutually recursive data types -- encoded as a `Data`. ⟦_⟧ᵈ : ∀ {Θs} -> Data ε Θs -> Seq (λ Θ -> ⟦ conToKind Θ ⋆ ⟧ᵏ) Θs ⟦_⟧ᵈ = mapˢ ⟦_⟧ᵗ ∘ compileDatas module Unused where constructorTypes : ∀ {Θs Ξ} -> Data Ξ Θs -> Con (Star (Ξ ▻▻ mapᶜ (λ Θᵢ -> conToKind Θᵢ ⋆) Θs)) constructorTypes {Θs} {Ξ} (PackData constructors) = joinᶜ ∘′ eraseˢ $′ mapElˢ consesToCon constructors where consesToCon : ∀ {Θ} -> Θ ∈ Θs -> List (Cons (Ξ ▻▻ mapᶜ (λ Θᵢ -> conToKind Θᵢ ⋆) Θs ▻▻ Θ)) -> Con (Star (Ξ ▻▻ mapᶜ (λ Θᵢ -> conToKind Θᵢ ⋆) Θs)) consesToCon {Θ} v = listToCon ∘ List.map (λ ξ -> πⁿ' Θ $ consToType ξ ρ) where ρ = applyᵗⁿ Θ (Var ∘ renᵛ (skipⁿ Θ extˡ) $ mapᵛ v) subVars' constructorFullTypes : ∀ {Θs Ξ} -> Data Ξ Θs -> Con (Star Ξ) constructorFullTypes δ = mapᶜ (instᵗⁿ $ compileDatas δ) $ constructorTypes δ
{ "alphanum_fraction": 0.6253182605, "avg_line_length": 48.3694581281, "ext": "agda", "hexsha": "807d7531715012ebda1c1846e38e4d1eeb5e060b", "lang": "Agda", "max_forks_count": 399, "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_path": "papers/unraveling-recursion/code/src/Compilation/Encode/Core.agda", "max_issues_count": 2493, "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_path": "papers/unraveling-recursion/code/src/Compilation/Encode/Core.agda", "max_line_length": 100, "max_stars_count": 1299, "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_path": "papers/unraveling-recursion/code/src/Compilation/Encode/Core.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "num_tokens": 3752, "size": 9819 }
module Issue1760e where -- Skipping a single record definition in a private block. private {-# NO_POSITIVITY_CHECK #-} record U : Set where field ap : U → U
{ "alphanum_fraction": 0.7048192771, "avg_line_length": 20.75, "ext": "agda", "hexsha": "ea74c4e2980e40040df49b3ec4f9203e8bd2bb2a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue1760e.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue1760e.agda", "max_line_length": 58, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue1760e.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": 44, "size": 166 }
{-# OPTIONS --safe #-} module STLC.Typing where open import STLC.Syntax open import Data.Nat using (ℕ) open import Data.Fin using (Fin) renaming (zero to fzero; suc to fsuc) open import Data.Product using (∃-syntax; _,_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; subst) open import Relation.Nullary using (Dec; yes; no; ¬_) private variable m n : ℕ v : Fin n Γ : Ctx n A B : Type a b f x p : Term n data _∋_⦂_ : Ctx n → Fin n → Type → Set where vzero : (Γ ,- A) ∋ fzero ⦂ A vsuc : (Γ ∋ v ⦂ A) → (Γ ,- B) ∋ fsuc v ⦂ A lookup : (Γ : Ctx n) → (v : Fin n) → Γ ∋ v ⦂ find Γ v lookup (Γ ,- A) fzero = vzero lookup (Γ ,- B) (fsuc v) = vsuc (lookup Γ v) data _⊢_⦂_ : Ctx n → Term n → Type → Set where ty-abs : (Γ ,- A) ⊢ b ⦂ B → Γ ⊢ abs A b ⦂ (A ⇒ B) ty-app : Γ ⊢ f ⦂ (A ⇒ B) → Γ ⊢ x ⦂ A → Γ ⊢ app f x ⦂ B ty-var : Γ ∋ v ⦂ A → Γ ⊢ var v ⦂ A ty-⋆ : Γ ⊢ ⋆ ⦂ unit ty-pair : Γ ⊢ a ⦂ A → Γ ⊢ b ⦂ B → Γ ⊢ pair a b ⦂ (A ×' B) ty-projₗ : Γ ⊢ p ⦂ (A ×' B) → Γ ⊢ projₗ p ⦂ A ty-projᵣ : Γ ⊢ p ⦂ (A ×' B) → Γ ⊢ projᵣ p ⦂ B principal-var : (Γ ∋ v ⦂ A) → (Γ ∋ v ⦂ B) → A ≡ B principal-var vzero vzero = refl principal-var (vsuc u) (vsuc v) rewrite principal-var u v = refl principal : Γ ⊢ x ⦂ A → Γ ⊢ x ⦂ B → A ≡ B principal (ty-abs {A = A} body₁) (ty-abs {A = (.A)} body₂) = cong (λ B → A ⇒ B) (principal body₁ body₂) principal (ty-app f x) (ty-app g y) with principal f g ... | refl = refl principal (ty-var u) (ty-var v) rewrite principal-var u v = refl principal ty-⋆ ty-⋆ = refl principal (ty-pair a₁ b₁) (ty-pair a₂ b₂) rewrite principal a₁ a₂ | principal b₁ b₂ = refl principal (ty-projₗ p₁) (ty-projₗ p₂) with principal p₁ p₂ ... | refl = refl principal (ty-projᵣ p₁) (ty-projᵣ p₂) with principal p₁ p₂ ... | refl = refl ill-typed-fun : (Γ ⊢ f ⦂ A) → ¬ (∃[ B ] ∃[ C ] (A ≡ B ⇒ C)) → ¬ (∃[ T ] (Γ ⊢ app f x ⦂ T)) ill-typed-fun f-ill-typed ineq (_ , ty-app {A = A} {B = B} f-typing _) with principal f-ill-typed f-typing ... | eq = ineq (A , B , eq) ill-typed-pairₗ : (Γ ⊢ p ⦂ A) → ¬ (∃[ B ] ∃[ C ] (A ≡ B ×' C)) → ¬ (∃[ T ] (Γ ⊢ projₗ p ⦂ T)) ill-typed-pairₗ pair-ill-typed ineq (_ , ty-projₗ {A = A} {B = B} pair-typing) with principal pair-ill-typed pair-typing ... | eq = ineq (A , B , eq) ill-typed-pairᵣ : (Γ ⊢ p ⦂ A) → ¬ (∃[ B ] ∃[ C ] (A ≡ B ×' C)) → ¬ (∃[ T ] (Γ ⊢ projᵣ p ⦂ T)) ill-typed-pairᵣ pair-ill-typed ineq (_ , ty-projᵣ {A = A} {B = B} pair-typing) with principal pair-ill-typed pair-typing ... | eq = ineq (A , B , eq) typecheck : (Γ : Ctx n) → (t : Term n) → Dec (∃[ T ] (Γ ⊢ t ⦂ T)) typecheck Γ (var v) = yes (find Γ v , ty-var (lookup Γ v)) typecheck Γ (abs A t) with typecheck (Γ ,- A) t ... | yes (B , well-typed) = yes (A ⇒ B , ty-abs well-typed) ... | no ill-typed = no λ { (ty , ty-abs {B = B} ty-body) → ill-typed ((B , ty-body)) } typecheck Γ (app f x) with typecheck Γ f | typecheck Γ x ... | yes (_ ×' _ , f-wrong-typing) | _ = no (ill-typed-fun f-wrong-typing λ ()) ... | yes (unit , f-wrong-typing) | _ = no (ill-typed-fun f-wrong-typing λ ()) ... | yes (_ ⇒ _ , _) | no ill-typed = no λ { (_ , ty-app {A = A} _ x) → ill-typed (A , x)} ... | no ill-typed | _ = no λ { (_ , ty-app {A = A} {B = B} f _) → ill-typed (A ⇒ B , f)} ... | yes (A ⇒ B , f-typing) | yes (A' , x-typing) with A' =?= A ... | yes eq = yes (B , ty-app f-typing (subst (λ A → Γ ⊢ x ⦂ A) eq x-typing)) ... | no neq = no (helper neq) where helper : ¬ A' ≡ A → ¬ (∃[ B ] (Γ ⊢ app f x ⦂ B)) helper neq (B'' , ty-app {A = A''} f'' x'') with principal f-typing f'' | principal x-typing x'' ... | refl | refl = neq refl typecheck _ ⋆ = yes (unit , ty-⋆) typecheck Γ (pair l r) with typecheck Γ l | typecheck Γ r ... | yes (A , l-typing) | yes (B , r-typing) = yes (A ×' B , ty-pair l-typing r-typing) ... | yes _ | no ill-typed = no λ { (A ×' B , ty-pair _ r) → ill-typed (B , r) } ... | no ill-typed | _ = no λ { (A ×' B , ty-pair l _) → ill-typed (A , l)} typecheck Γ (projₗ p) with typecheck Γ p ... | yes (A ×' _ , typing) = yes (A , ty-projₗ typing) ... | yes (_ ⇒ _ , typing) = no (ill-typed-pairₗ typing λ ()) ... | yes (unit , typing) = no (ill-typed-pairₗ typing λ ()) ... | no ill-typed = no λ { (_ , ty-projₗ {A = A} {B = B} p) → ill-typed ((A ×' B) , p) } typecheck Γ (projᵣ p) with typecheck Γ p ... | yes (_ ×' B , typing) = yes (B , ty-projᵣ typing) ... | yes (_ ⇒ _ , typing) = no (ill-typed-pairᵣ typing λ ()) ... | yes (unit , typing) = no (ill-typed-pairᵣ typing λ ()) ... | no ill-typed = no λ { (_ , ty-projᵣ {A = A} {B = B} p) → ill-typed ((A ×' B) , p) }
{ "alphanum_fraction": 0.5296665223, "avg_line_length": 41.6036036036, "ext": "agda", "hexsha": "81c6c3f359d96fb566c0337cc9560b734e730e0e", "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": "59bc9648f326b7359801fb31ff6f957a166876fc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TrulyNonstrict/STLC", "max_forks_repo_path": "STLC/Typing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc", "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": "TrulyNonstrict/STLC", "max_issues_repo_path": "STLC/Typing.agda", "max_line_length": 90, "max_stars_count": 1, "max_stars_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TypesLogicsCats/STLC", "max_stars_repo_path": "STLC/Typing.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-16T23:53:48.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-16T23:53:48.000Z", "num_tokens": 1990, "size": 4618 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommMonoid.CommMonoidProd where open import Cubical.Foundations.HLevels open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Algebra.Monoid open import Cubical.Algebra.Semigroup open import Cubical.Algebra.CommMonoid.Base open CommMonoidStr open IsCommMonoid hiding (rid ; lid) open IsMonoid hiding (rid ; lid) open IsSemigroup private variable ℓ ℓ' : Level CommMonoidProd : CommMonoid ℓ → CommMonoid ℓ' → CommMonoid (ℓ-max ℓ ℓ') CommMonoidProd M N = makeCommMonoid ε× _·×_ is-set× assoc× rid× comm× where ε× : (fst M) × (fst N) ε× = (ε (snd M)) , (ε (snd N)) _·×_ : (fst M) × (fst N) → (fst M) × (fst N) → (fst M) × (fst N) (x₁ , x₂) ·× (y₁ , y₂) = (_·_ (snd M) x₁ y₁) , (_·_ (snd N) x₂ y₂) is-set× : isSet ((fst M) × (fst N)) is-set× = isSet× (is-set (snd M)) (is-set (snd N)) assoc× : ∀ x y z → x ·× (y ·× z) ≡ (x ·× y) ·× z assoc× _ _ _ = cong₂ (_,_) (assoc (snd M) _ _ _) (assoc (snd N) _ _ _) rid× : ∀ x → x ·× ε× ≡ x rid× _ = cong₂ (_,_) (rid (snd M) _) (rid (snd N) _) comm× : ∀ x y → x ·× y ≡ y ·× x comm× _ _ = cong₂ (_,_) (comm (snd M) _ _) (comm (snd N) _ _)
{ "alphanum_fraction": 0.5990016639, "avg_line_length": 26.7111111111, "ext": "agda", "hexsha": "c6e11fc4939477edb678725d1a6ed3ff8beaa632", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/cubical", "max_forks_repo_path": "Cubical/Algebra/CommMonoid/CommMonoidProd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "guilhermehas/cubical", "max_issues_repo_path": "Cubical/Algebra/CommMonoid/CommMonoidProd.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/cubical", "max_stars_repo_path": "Cubical/Algebra/CommMonoid/CommMonoidProd.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": 476, "size": 1202 }
-- Andreas, 2014-10-05, code by Jesper Cockx {-# OPTIONS --cubical-compatible --guardedness #-} open import Common.Coinduction open import Common.Equality data False : Set where data Pandora : Set where C : ∞ False → Pandora postulate ext : (False → Pandora) → (Pandora → False) → False ≡ Pandora f : False → Pandora f () g : Pandora → False g (C x) = ♭ x foo : False ≡ Pandora foo = ext f g -- should be rejected loop : (A : Set) → A ≡ Pandora → A loop .Pandora refl = C (♯ (loop False foo)) absurd : False absurd = loop False foo
{ "alphanum_fraction": 0.6575091575, "avg_line_length": 17.6129032258, "ext": "agda", "hexsha": "b4dab4c2bafdc9100ab4899b1abcc7637b9ba976", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Fail/Issue1023-22.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Fail/Issue1023-22.agda", "max_line_length": 63, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Fail/Issue1023-22.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 173, "size": 546 }
{-# OPTIONS --without-K #-} module Truncation_Level_Criteria where open import lib.Basics hiding (_⊔_) open import lib.NType2 open import lib.types.Nat hiding (_+_) open import lib.types.Pi open import lib.types.Sigma open import lib.types.Unit open import lib.types.Empty open import lib.types.TLevel open import Preliminaries open import Pointed -- Chapter 3: Truncation Level Criteria -- Chapter 3.1: Hedberg's Theorem Revisited -- Proposition 3.1.1 is below. -- Definition 3.1.2 const : ∀{i j} {X : Type i} {Y : Type j} → (f : X → Y) → Type (i ⊔ j) const {X = X} f = (x₁ x₂ : X) → (f x₁) == (f x₂) coll : ∀{i} → Type i → Type i coll X = Σ (X → X) const pathColl : ∀ {i} → Type i → Type i pathColl X = (x₁ x₂ : X) → coll (x₁ == x₂) -- Lemma 3.1.3 discr→pathColl : ∀ {i} {X : Type i} → has-dec-eq X → pathColl X discr→pathColl dec x₁ x₂ with (dec x₁ x₂) discr→pathColl dec x₁ x₂ | inl p = (λ _ → p) , (λ _ _ → idp) discr→pathColl dec x₁ x₂ | inr np = idf _ , λ p → Empty-elim (np p) -- Lemma 3.1.4 pathColl→isSet : ∀ {i} {X : Type i} → pathColl X → is-set X pathColl→isSet {X = X} pc x₁ x₂ = all-paths-is-prop paths-equal where claim : (y₁ y₂ : X) → (p : y₁ == y₂) → p == ! (fst (pc _ _) idp) ∙ fst (pc _ _) p claim x₁ .x₁ idp = ! (!-inv-l (fst (pc x₁ x₁) idp)) paths-equal : (p₁ p₂ : x₁ == x₂) → p₁ == p₂ paths-equal p₁ p₂ = p₁ =⟨ claim _ _ p₁ ⟩ ! (fst (pc _ _) idp) ∙ fst (pc _ _) p₁ =⟨ ap (λ q → (! (fst (pc x₁ x₁) idp)) ∙ q) (snd (pc _ _) p₁ p₂) ⟩ -- whiskering ! (fst (pc _ _) idp) ∙ fst (pc _ _) p₂ =⟨ ! (claim _ _ p₂) ⟩ p₂ ∎ -- Proposition 3.1.1 hedberg : ∀ {i} {X : Type i} → has-dec-eq X → is-set X hedberg = pathColl→isSet ∘ discr→pathColl -- Definition 3.1.5 stable : ∀ {i} → Type i → Type i stable X = ¬ (¬ X) → X separated : ∀ {i} → Type i → Type i separated X = (x₁ x₂ : X) → stable (x₁ == x₂) -- Proposition 3.1.6 sep→set : ∀ {i} {X : Type i} → (separated X) → is-set X sep→set {X = X} sep = pathColl→isSet isPc where isPc : pathColl X isPc x₁ x₂ = f , c where f : x₁ == x₂ → x₁ == x₂ f = (sep x₁ x₂) ∘ (λ p np → np p) c : const f c p₁ p₂ = f p₁ =⟨ idp ⟩ (sep x₁ x₂) (λ np → np p₁) =⟨ ap (sep x₁ x₂) (λ= λ np → Empty-elim {P = λ _ → np p₁ == np p₂} (np p₁)) ⟩ (sep x₁ x₂) (λ np → np p₂) =⟨ idp ⟩ f p₂ ∎ -- Lemma 3.1.7 -- first: definition of 'reflexive propositional relation that implies identity' rel-ref-id : ∀ {i} → Type i → Type (lsucc i) rel-ref-id {i} X = Σ (X → X → Type i) λ R → ((x : X) → R x x) × ((x₁ x₂ : X) → (R x₁ x₂) → x₁ == x₂) × ((x₁ x₂ : X) → is-prop (R x₁ x₂)) -- the actual Lemma 3.1.7 module lem317 {i : _} (X : Type i) (Rrip : rel-ref-id X) where R : X → X → Type i R = fst Rrip ref : (x : X) → R x x ref = fst (snd (Rrip)) -- fst (fst (snd Rrip)) ii : (x₁ x₂ : X) → (R x₁ x₂) → x₁ == x₂ ii = fst (snd (snd (Rrip))) -- snd (fst (snd Rrip)) pr : (x₁ x₂ : X) → is-prop (R x₁ x₂) pr = snd (snd (snd Rrip)) f : (x₁ x₂ : X) → x₁ == x₂ → R x₁ x₂ f x₁ .x₁ idp = ref x₁ id↔R : (x₁ x₂ : X) → (x₁ == x₂) ↔ R x₁ x₂ id↔R x₁ x₂ = f _ _ , ii _ _ pc : pathColl X pc x₁ x₂ = ii _ _ ∘ f _ _ , λ p₁ p₂ → ap (ii x₁ x₂) (prop-has-all-paths (pr x₁ x₂) _ _) isSet : is-set X isSet = pathColl→isSet pc open wtrunc -- Definition 3.1.9 splitSup : ∀ {i} → (X : Type i) → Type i splitSup X = ∣∣ X ∣∣ → X hSeparated : ∀ {i} → (X : Type i) → Type i hSeparated X = (x₁ x₂ : X) → splitSup (x₁ == x₂) -- Proposition 3.1.10 -- we show "2->1", "1->3", "3->2" as in the thesis. -- for the last part, we show "1->4" and "4->3 set-characterisations : ∀ {i} → (X : Type i) → (pathColl X → is-set X) × (is-set X → rel-ref-id X) × (rel-ref-id X → pathColl X) × (is-set X → hSeparated X) × (hSeparated X → rel-ref-id X) set-characterisations X = pathColl→isSet , (λ ss → _==_ , (λ _ → idp) , (λ _ _ p → p) , ss) , (lem317.pc X) , (λ ss x₁ x₂ → tr-rec (ss x₁ x₂) (λ p → p)) , (λ hsep → ((λ x₁ x₂ → ∣∣ x₁ == x₂ ∣∣) , (λ _ → ∣ idp ∣) , hsep , λ _ _ → tr-is-prop)) -- The rest of this section is only a replication of the arguments that we have given so far (for that reason, the proofs are not given in the article). -- They do not directly follow from the propositions that we have proved before, but they directly imply them. -- Of course, replication of arguments is not a good style for a formalization - -- we chose this "disadvantageous" order purely as we believe it led to a better presentation in the article. -- Lemma 3.1.11 pathColl→isSet-local : ∀ {i} {X : Type i} → {x₀ : X} → ((y : X) → coll (x₀ == y)) → (y : X) → is-prop (x₀ == y) pathColl→isSet-local {X = X} {x₀} pc y = all-paths-is-prop paths-equal where claim : (y : X) → (p : x₀ == y) → p == ! (fst (pc _) idp) ∙ fst (pc _) p claim .x₀ idp = ! (!-inv-l (fst (pc _) idp)) paths-equal : (p₁ p₂ : x₀ == y) → p₁ == p₂ paths-equal p₁ p₂ = p₁ =⟨ claim _ p₁ ⟩ ! (fst (pc _) idp) ∙ fst (pc _) p₁ =⟨ ap (λ q → (! (fst (pc x₀) idp)) ∙ q) (snd (pc y) p₁ p₂) ⟩ -- whiskering ! (fst (pc _) idp) ∙ fst (pc _) p₂ =⟨ ! (claim _ p₂) ⟩ p₂ ∎ -- Proposition 3.11.12 hedberg-local : ∀ {i} {X : Type i} → {x₀ : X} → ((y : X) → Coprod (x₀ == y) (¬(x₀ == y))) → (y : X) → is-prop (x₀ == y) hedberg-local {X = X} {x₀ = x₀} dec = pathColl→isSet-local local-pathColl where local-pathColl : (y : X) → coll (x₀ == y) local-pathColl y with (dec y) local-pathColl y₁ | inl p = (λ _ → p) , (λ _ _ → idp) local-pathColl y₁ | inr np = idf _ , (λ p → Empty-elim (np p)) -- Lemma 3.1.13. This needs function extensionality. sep→set-local : ∀ {i} {X : Type i} {x₀ : X} → ((y : X) → stable (x₀ == y)) → (y : X) → is-prop (x₀ == y) sep→set-local {X = X} {x₀ = x₀} sep = pathColl→isSet-local is-pathColl where is-pathColl : (y : X) → coll (x₀ == y) is-pathColl y = f , c where f : x₀ == y → x₀ == y f = (sep y) ∘ (λ p np → np p) c : const f c p₁ p₂ = f p₁ =⟨ idp ⟩ (sep _) (λ np → np p₁) =⟨ ap (sep y) (λ= (λ np → prop-has-all-paths Empty-is-prop _ _)) ⟩ (sep _) (λ np → np p₂) =⟨ idp ⟩ f p₂ ∎ -- Chapter 3.2: Generalisations to Higher Levels -- first: some lemmata. -- If A -> B -> A is the identity, then -- a₁ == a₂ → s a₁ == s a₂ → r(s a₁) == r(s a₂) -- is also the identity in an appropriate sense retract-path-retract : ∀ {i j} {A : Type i} {B : Type j} → (s : A → B) → (r : B → A) → (s-r : (a : A) → r (s a) == a) → (a₁ a₂ : A) → (p : a₁ == a₂) → ! (s-r a₁) ∙ (ap r (ap s p)) ∙ (s-r a₂) == p retract-path-retract s r s-r a₁ .a₁ idp = !-inv-l (s-r a₁) -- retracts of n-types are n-truncated retract-is-truncated : ∀ {n : ℕ₋₂} {i j} {A : Type i} {B : Type j} → (has-level n B) → (s : A → B) → (r : B → A) → ((a : A) → r (s a) == a) → has-level n A retract-is-truncated {⟨-2⟩} h s r s-r = inhab-prop-is-contr (r (fst h)) (all-paths-is-prop (λ a₁ a₂ → a₁ =⟨ ! (s-r a₁) ⟩ r(s(a₁)) =⟨ ap r (contr-has-all-paths h _ _) ⟩ r(s(a₂)) =⟨ s-r a₂ ⟩ a₂ ∎ )) retract-is-truncated {S n} h s r s-r a₁ a₂ = retract-is-truncated {n} {A = a₁ == a₂} {B = s a₁ == s a₂} (h (s a₁) (s a₂)) (ap s) (λ p → ! (s-r a₁) ∙ (ap r p) ∙ (s-r a₂)) (retract-path-retract s r s-r a₁ a₂) -- this is essentially one direction of a local version of the lemma which says that -- a type is n-truncated iff its loop spaces are (n-1)-truncated trunclevel-aux₁ : ∀ {i} {X : Type i} {x₀ : X} → (n : ℕ) → ((x : X) → has-level (n -2) (x₀ == x)) → is-contr (fst ((Ω ^ n) (X , x₀))) trunclevel-aux₁ {x₀ = x₀} O h = x₀ , λ x → fst (h x) trunclevel-aux₁ {X = X} {x₀ = x₀} (S n) h = trunclevel-aux₁ n (h x₀ idp) -- the other direction... trunclevel-aux₂ : ∀ {i} {X : Type i} {x₀ : X} → (n : ℕ) → is-contr (fst ((Ω ^ n) (X , x₀))) → ((x : X) → has-level (n -2) (x₀ == x)) trunclevel-aux₂ {X = X} {x₀ = x₀} O h = λ x → inhab-prop-is-contr (contr-has-all-paths h x₀ x) (contr-is-prop (contr-is-prop h x₀ x)) trunclevel-aux₂ {X = X} {x₀ = x₀} (S n) h .x₀ idp = trunclevel-aux₂ n h -- Theorem 3.2.1 -- in the thesis, we write "let n ≥ -1 be a number". -- As we do not want to introduce a type of number that are at least -1, -- we use ℕ. -- To make up for this, we reduce n everywhere by 1. module GLHA {i : ULevel} {X : Type i} {x₀ : X} {n : ℕ} where Ω-contr : Type i -- loop-contr = is-contr (fst ((Ω ^ (n + 1)) (X , x₀))) Ω-contr = is-contr (fst ((Ω ^ n) (X , x₀))) locally-truncated : Type i -- locally-truncated = (x : X) → has-level (n -1) (x₀ == x) locally-truncated = (x : X) → has-level (n -2) (x₀ == x) tr-rel-id : Type (lsucc i) tr-rel-id = Σ (X → Type i) λ Q → -- ((x : X) → has-level (n -1) (Q x)) ((x : X) → has-level (n -2) (Q x)) × (Q x₀) × ((x : X) → Q x → x₀ == x) tr-rel-id→locally-truncated : tr-rel-id → locally-truncated tr-rel-id→locally-truncated (Q , h , q₀ , ii) = λ x → retract-is-truncated {n = n -2} {A = x₀ == x} {B = Q x} (h x) s r r-s where r : {x : X} → (Q x) → (x₀ == x) r {x} q = ! (ii x₀ q₀) ∙ (ii x q) s : {x : X} → (x₀ == x) → Q x s idp = q₀ r-s : {x : X} → (p : x₀ == x) → r (s p) == p r-s idp = !-inv-l (ii x₀ q₀) locally-truncated→Ω-contr : locally-truncated → Ω-contr locally-truncated→Ω-contr loctr = trunclevel-aux₁ n loctr -- trunclevel-aux n loctr Ω-contr→tr-rel-id : Ω-contr → tr-rel-id Ω-contr→tr-rel-id h = (λ x → x₀ == x) , (trunclevel-aux₂ n h) , idp , (λ x p → p) module with-higher-truncs where -- for convenience, we import truncations from the library. open import lib.types.Truncation -- fourth item in Theorem 3.2.1 id-stable : Type i id-stable = (x : X) → Trunc (n -2) (x₀ == x) → x₀ == x -- it is very easy to see that (4) and (2) are logically equivalent. -- 2 ⇒ 4 tr-rel-id→id-stable : tr-rel-id → id-stable tr-rel-id→id-stable (Q , h , q₀ , ii) = λ x → (ii x) ∘ (Trunc-rec (h x) (λ p → transport _ p q₀)) -- 4 ⇒ 2 id-stable→tr-rel-id : id-stable → tr-rel-id id-stable→tr-rel-id idst = (λ x → Trunc (n -2) (x₀ == x)) , (λ _ → Trunc-level) , [ idp ] , idst
{ "alphanum_fraction": 0.5084476804, "avg_line_length": 37.8551236749, "ext": "agda", "hexsha": "fed98e74191e3c8708cdd17573abb23018eae0a3", "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/thesis/Truncation_Level_Criteria.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/thesis/Truncation_Level_Criteria.agda", "max_line_length": 152, "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/thesis/Truncation_Level_Criteria.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": 4299, "size": 10713 }
open import MJ.Types import MJ.Classtable.Core as Core module MJ.Syntax.Typed {c}(Ct : Core.Classtable c) where open import Prelude open import Data.Maybe as Maybe using (Maybe; just; nothing) open import Data.Vec as Vec open import Data.Star as Star open import Data.List hiding (null) open import Data.List.Relation.Unary.All open import Data.List.Membership.Propositional open import Data.List.Properties.Extra as List+ open import Relation.Binary.PropositionalEquality open import Relation.Nullary.Decidable open import Data.String open Core c open Classtable Ct open import MJ.Classtable.Membership Ct open import MJ.LexicalScope c NativeBinOp = ℕ → ℕ → ℕ {- Expressions are indexed by a lexical context and a type. MJ has n-ary calls for which we use All to express that an expression (of the right type) is expected for every formal argument of the method signature. In this nameless representation AccMember type is used to identify accessible fields and methods on a particular class. Here we exploit that AccMember is defined via a decision procedure: Agda will be able to infer the membership proofs if they exist. -} data Expr (Γ : Ctx) : Ty c → Set where -- irreducible expressions unit : Expr Γ void null : ∀ {C} → Expr Γ (ref C) num : ℕ → Expr Γ int -- storeless expressions var : ∀ {a} → Var Γ a → Expr Γ a iop : NativeBinOp → (l r : Expr Γ int) → Expr Γ int upcast : ∀ {c c'} → Σ ⊢ c <: c' → Expr Γ (ref c) → Expr Γ (ref c') -- storeful new : ∀ C → All (Expr Γ) (Class.constr (Σ C)) → Expr Γ (ref C) call : ∀ {cid} → Expr Γ (ref cid) → ∀ m {as}{b}{acc : AccMember cid METHOD m (as , b)} → All (Expr Γ) as → Expr Γ b get : ∀ {cid} → Expr Γ (ref cid) → ∀ f {ty}{acc : AccMember cid FIELD f ty} → Expr Γ ty mutual {- Like Java, MJ distinguishes expressions from statements. We index the well-typed statement type Stmt with both an input and output context to capture that the constructor for declaration of locals loc adds to the lexical environment. We can interpret the type Stmt as a binary relation on contexts of which we can take the reflexive, transitive closure (Star) to obtain a datatype for sequenced statements: The type r represent the (possibly early) return type of a block of statements. -} infixl 20 if_then_else_ data Stmt (I : Ctx)(r : Ty c) : (O : Ctx) → Set where loc : ∀ a → Stmt I r (I +local a) asgn : ∀ {a} → Var I a → Expr I a → Stmt I r I set : ∀ {C} → Expr I (ref C) → ∀ f {a}{acc : AccMember C FIELD f a} → Expr I a → Stmt I r I run : ∀ {a} → Expr I a → Stmt I r I ret : Expr I r → Stmt I r I raise : Stmt I r I try_catch_ : ∀ {O O'} → Stmt I r O → Stmt I r O' → Stmt I r I while_run_ : ∀ {O} → Expr I int → Stmt I r O → Stmt I r I block : ∀ {O} → Stmts I r O → Stmt I r I if_then_else_ : ∀ {a} → Expr I int → Stmt I r a → Stmt I r a → Stmt I r a Stmts : Ctx → Ty c → Ctx → Set Stmts I r O = Star (λ I' O' → Stmt I' r O') I O
{ "alphanum_fraction": 0.649578196, "avg_line_length": 38.049382716, "ext": "agda", "hexsha": "6efb62945a8dc8a21f8f2014052c264724f48049", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/MJ/Syntax/Typed.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/MJ/Syntax/Typed.agda", "max_line_length": 102, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/MJ/Syntax/Typed.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 925, "size": 3082 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.FinData.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Data.Nat open import Cubical.Data.Bool.Base open import Cubical.Relation.Nullary private variable ℓ : Level A B : Type ℓ data Fin : ℕ → Type₀ where zero : {n : ℕ} → Fin (suc n) suc : {n : ℕ} (i : Fin n) → Fin (suc n) toℕ : ∀ {n} → Fin n → ℕ toℕ zero = 0 toℕ (suc i) = suc (toℕ i) fromℕ : (n : ℕ) → Fin (suc n) fromℕ zero = zero fromℕ (suc n) = suc (fromℕ n) ¬Fin0 : ¬ Fin 0 ¬Fin0 () _==_ : ∀ {n} → Fin n → Fin n → Bool zero == zero = true zero == suc _ = false suc _ == zero = false suc m == suc n = m == n foldrFin : ∀ {n} → (A → B → B) → B → (Fin n → A) → B foldrFin {n = zero} _ b _ = b foldrFin {n = suc n} f b l = f (l zero) (foldrFin f b (l ∘ suc))
{ "alphanum_fraction": 0.5897727273, "avg_line_length": 22.5641025641, "ext": "agda", "hexsha": "40c54b4b3a8160a7b4dc4160bc8e08e2ca7094c2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Data/FinData/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Data/FinData/Base.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Data/FinData/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 350, "size": 880 }
------------------------------------------------------------------------------ -- Propositional logic theorems ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOL.PropositionalLogic.TheoremsI where -- The theorems below are valid on intuitionistic logic and with an -- empty domain. open import FOL.Base hiding ( D≢∅ ; pem ) ------------------------------------------------------------------------------ -- Boolean laws →-transposition : {P Q : Set} → (P → Q) → ¬ Q → ¬ P →-transposition p→q ¬q p = ¬q (p→q p) ∧∨-dist : {P Q R : Set} → P ∧ (Q ∨ R) ↔ P ∧ Q ∨ P ∧ R ∧∨-dist {P} {Q} {R} = l→r , r→l where l→r : P ∧ (Q ∨ R) → P ∧ Q ∨ P ∧ R l→r (p , inj₁ q) = inj₁ (p , q) l→r (p , inj₂ r) = inj₂ (p , r) r→l : P ∧ Q ∨ P ∧ R → P ∧ (Q ∨ R) r→l (inj₁ (p , q)) = p , inj₁ q r→l (inj₂ (p , r)) = p , inj₂ r ∧∨-dist' : {P Q R : Set} → P ∧ (Q ∨ R) ⇔ P ∧ Q ∨ P ∧ R ∧∨-dist' {P} {Q} {R} = l⇒r , r⇒l where l→r : P ∧ (Q ∨ R) → P ∧ Q ∨ P ∧ R l→r (p , inj₁ q) = inj₁ (p , q) l→r (p , inj₂ r) = inj₂ (p , r) l⇒r : P ∧ (Q ∨ R) ⇒ P ∧ Q ∨ P ∧ R l⇒r = fun l→r r→l : P ∧ Q ∨ P ∧ R → P ∧ (Q ∨ R) r→l (inj₁ (p , q)) = p , inj₁ q r→l (inj₂ (p , r)) = p , inj₂ r -- TODO (21 February 2015). In r⇒l we needed parenthesis in the -- antecedent, but they aren't needed in r→l. That is, the fixity of -- _⇒_ should be the same than the fixity of _→_. r⇒l : (P ∧ Q ∨ P ∧ R) ⇒ P ∧ (Q ∨ R) r⇒l = fun r→l DM : {P Q : Set} → ¬ (P ∨ Q) ↔ ¬ P ∧ ¬ Q DM {P} {Q} = l→r , r→l where l→r : ¬ (P ∨ Q) → ¬ P ∧ ¬ Q l→r h = (λ p → h (inj₁ p)) , (λ q → h (inj₂ q)) r→l : ¬ P ∧ ¬ Q → ¬ (P ∨ Q) r→l (¬p , ¬q) p∨q = case ¬p ¬q p∨q -- The principle of the excluded middle implies the double negation -- elimination pem→¬¬-elim : ∀ {P} → (P ∨ ¬ P) → ¬ ¬ P → P pem→¬¬-elim (inj₁ p) _ = p pem→¬¬-elim (inj₂ ¬p) h = ⊥-elim (h ¬p)
{ "alphanum_fraction": 0.4138604197, "avg_line_length": 30.5820895522, "ext": "agda", "hexsha": "e4f31be330af625946da19571ad42154c2c83bc9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOL/PropositionalLogic/TheoremsI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOL/PropositionalLogic/TheoremsI.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOL/PropositionalLogic/TheoremsI.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 875, "size": 2049 }
{-# OPTIONS --without-K #-} -- I've been spinning my wheels quite a bit on this proof. -- I've chatted with several people and feel confident my -- functions are properly defined, but I'm really struggling -- to see how to prove they are quasi-inverses (it has been a little -- reassuring, no one I have talked to has correctly defined -- the functions initially, hah). -- At the moment I'm not sure if I'm just missing something obvious in -- the proof, or if I'm simply going about the proof wrong. I've -- begun focusing on the eckmann-hilton proof and plan to return to this -- after that is done. module Circle where open import Level using (_⊔_) open import Data.Product using (Σ; _,_) open import Function renaming (_∘_ to _○_) --open import Relation.Binary.PropositionalEquality renaming (_≡_ to _≡_; refl to Eqrefl) --open import Relation.Binary.EqReasoning infixr 8 _∘_ -- path composition infix 4 _≡_ -- propositional equality infix 4 _∼_ -- homotopy between two functions infix 4 _≃_ -- type of equivalences -- macros from tzaikin for equational rewriting over non-standard ≡ infixr 4 _≡⟨_⟩_ infix 4 _∎ ------------------------------------------------------------------------------ -- A few HoTT primitives data _≡_ {ℓ} {A : Set ℓ} : (a b : A) → Set ℓ where refl : (a : A) → (a ≡ a) pathInd : ∀ {u ℓ} → {A : Set u} → (C : {x y : A} → x ≡ y → Set ℓ) → (c : (x : A) → C (refl x)) → ({x y : A} (p : x ≡ y) → C p) pathInd C c (refl x) = c x -- inverse paths ! : ∀ {u} → {A : Set u} {x y : A} → (x ≡ y) → (y ≡ x) ! = pathInd (λ {x} {y} _ → y ≡ x) refl -- path composition _∘_ : ∀ {u} → {A : Set u} → {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z) _∘_ {u} {A} {x} {y} {z} p q = pathInd {u} (λ {x} {y} p → ((z : A) → (q : y ≡ z) → (x ≡ z))) (λ x z q → pathInd (λ {x} {z} _ → x ≡ z) refl {x} {z} q) {x} {y} p z q -- Handy "macros" (from tzaikin) _∎ : {A : Set} → (p : A) → p ≡ p p ∎ = refl p _≡⟨_⟩_ : {A : Set} → {q r : A} → (p : A) → p ≡ q → q ≡ r → p ≡ r p ≡⟨ α ⟩ β = α ∘ β -- (x ≡ y) ≡ ((x ≡ y) ∘ (refl y)) unitTransR : {A : Set} {x y : A} → (p : x ≡ y) → (p ≡ (p ∘ refl y)) unitTransR {A} {x} {y} p = pathInd (λ {x} {y} p → p ≡ (p ∘ (refl y))) (λ x → refl (refl x)) {x} {y} p -- (x ≡ y) ≡ ((refl x) ∘ (x ≡ y)) unitTransL : {A : Set} {x y : A} → (p : x ≡ y) → (p ≡ refl x ∘ p) unitTransL {A} {x} {y} p = pathInd (λ {x} {y} p → p ≡ (refl x) ∘ p) (λ x → refl (refl x)) {x} {y} p -- !(x ≡ y) ∘ (x ≡ y) ≡ (refl y) invTransL : {A : Set} {x y : A} → (p : x ≡ y) → (! p ∘ p ≡ refl y) invTransL {A} {x} {y} p = pathInd (λ {x} {y} p → ! p ∘ p ≡ refl y) (λ x → refl (refl x)) {x} {y} p -- (x ≡ y) ∘ !(x ≡ y) ≡ (refl x) invTransR : ∀ {ℓ} {A : Set ℓ} {x y : A} → (p : x ≡ y) → (p ∘ ! p ≡ refl x) invTransR {ℓ} {A} {x} {y} p = pathInd (λ {x} {y} p → p ∘ ! p ≡ refl x) (λ x → refl (refl x)) {x} {y} p -- !!(x ≡ y) ≡ (x ≡ y) invId : {A : Set} {x y : A} → (p : x ≡ y) → (! (! p) ≡ p) invId {A} {x} {y} p = pathInd (λ {x} {y} p → ! (! p) ≡ p) (λ x → refl (refl x)) {x} {y} p -- (x ≡ y) and (y ≡ z) ⇒ (x ≡ z) assocP : {A : Set} {x y z w : A} → (p : x ≡ y) → (q : y ≡ z) → (r : z ≡ w) → (p ∘ (q ∘ r) ≡ (p ∘ q) ∘ r) assocP {A} {x} {y} {z} {w} p q r = pathInd (λ {x} {y} p → (z : A) → (w : A) → (q : y ≡ z) → (r : z ≡ w) → p ∘ (q ∘ r) ≡ (p ∘ q) ∘ r) (λ x z w q r → pathInd (λ {x} {z} q → (w : A) → (r : z ≡ w) → (refl x) ∘ (q ∘ r) ≡ ((refl x) ∘ q) ∘ r) (λ x w r → pathInd (λ {x} {w} r → (refl x) ∘ ((refl x) ∘ r) ≡ ((refl x) ∘ (refl x)) ∘ r) (λ x → (refl (refl x))) {x} {w} r) {x} {z} q w r) {x} {y} p z w q r -- !(p ∘ q) ≡ !q ∘ !p invComp : {A : Set} {x y z : A} → (p : x ≡ y) → (q : y ≡ z) → ! (p ∘ q) ≡ ! q ∘ ! p invComp {A} {x} {y} {z} p q = pathInd (λ {x} {y} p → (z : A) → (q : y ≡ z) → ! (p ∘ q) ≡ ! q ∘ ! p) (λ x z q → pathInd (λ {x} {z} q → ! (refl x ∘ q) ≡ ! q ∘ ! (refl x)) (λ x → refl (refl x)) {x} {z} q) {x} {y} p z q -- (x ≡ y) ⇒ (f x) ≡ (f y) ap : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {x y : A} → (f : A → B) → (x ≡ y) → (f x ≡ f y) ap {ℓ} {ℓ'} {A} {B} {x} {y} f p = pathInd (λ {x} {y} p → f x ≡ f y) (λ x → refl (f x)) {x} {y} p -- sort of -- p:(x ≡ y) ⇒ q:(y ≡ z) ⇒ (((f x) ≡ (f z)) ≡ (((f x) ≡ (f y)) ∘ ((f y) ≡ (f z)))) apfTrans : ∀ {u} → {A B : Set u} {x y z : A} → (f : A → B) → (p : x ≡ y) → (q : y ≡ z) → ap f (p ∘ q) ≡ (ap f p) ∘ (ap f q) apfTrans {u} {A} {B} {x} {y} {z} f p q = pathInd {u} (λ {x} {y} p → (z : A) → (q : y ≡ z) → ap f (p ∘ q) ≡ (ap f p) ∘ (ap f q)) (λ x z q → pathInd {u} (λ {x} {z} q → ap f (refl x ∘ q) ≡ (ap f (refl x)) ∘ (ap f q)) (λ x → refl (refl (f x))) {x} {z} q) {x} {y} p z q -- ap f (! p) ≡ ! (ap f p) apfInv : ∀ {u} → {A B : Set u} {x y : A} → (f : A → B) → (p : x ≡ y) → ap f (! p) ≡ ! (ap f p) apfInv {u} {A} {B} {x} {y} f p = pathInd {u} (λ {x} {y} p → ap f (! p) ≡ ! (ap f p)) (λ x → refl (ap f (refl x))) {x} {y} p -- ap g (ap f p) ≡ ap (g ○ f) p apfComp : {A B C : Set} {x y : A} → (f : A → B) → (g : B → C) → (p : x ≡ y) → ap g (ap f p) ≡ ap (g ○ f) p apfComp {A} {B} {C} {x} {y} f g p = pathInd (λ {x} {y} p → ap g (ap f p) ≡ ap (g ○ f) p) (λ x → refl (ap g (ap f (refl x)))) {x} {y} p -- ap id p ≡ p apfId : {A : Set} {x y : A} → (p : x ≡ y) → ap id p ≡ p apfId {A} {x} {y} p = pathInd (λ {x} {y} p → ap id p ≡ p) (λ x → refl (refl x)) {x} {y} p -- (x ≡ y) → P x → P y transport : ∀ {ℓ ℓ'} → {A : Set ℓ} {x y : A} → (P : A → Set ℓ') → (p : x ≡ y) → P x → P y transport {ℓ} {ℓ'} {A} {x} {y} P p = pathInd -- on p (λ {x} {y} p → (P x → P y)) (λ _ → id) {x} {y} p -- dependent ap apd : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : A → Set ℓ'} {x y : A} → (f : (a : A) → B a) → (p : x ≡ y) → (transport B p (f x) ≡ f y) apd {ℓ} {ℓ'} {A} {B} {x} {y} f p = pathInd (λ {x} {y} p → transport B p (f x) ≡ f y) (λ x → refl (f x)) {x} {y} p -- Homotopies and equivalences _∼_ : ∀ {ℓ ℓ'} → {A : Set ℓ} {P : A → Set ℓ'} → (f g : (x : A) → P x) → Set (ℓ ⊔ ℓ') _∼_ {ℓ} {ℓ'} {A} {P} f g = (x : A) → f x ≡ g x record qinv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where constructor mkqinv field g : B → A α : (f ○ g) ∼ id β : (g ○ f) ∼ id record isequiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where constructor mkisequiv field g : B → A α : (f ○ g) ∼ id h : B → A β : (h ○ f) ∼ id equiv₁ : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {f : A → B} → qinv f → isequiv f equiv₁ (mkqinv qg qα qβ) = mkisequiv qg qα qg qβ _≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A ≃ B = Σ (A → B) isequiv postulate univalence : {A B : Set} → (A ≡ B) ≃ (A ≃ B) ------------------------------------------------------------------------------ -- Exercise: let's show that the following two definitions of the -- circle are "the same" module Circle1 where private data S¹* : Set where base* : S¹* S¹ : Set S¹ = S¹* base : S¹ base = base* postulate loop : base ≡ base recS¹ : {C : Set} → (cbase : C) → (cloop : cbase ≡ cbase) → S¹ → C recS¹ cbase cloop base* = cbase postulate βrecS¹ : {C : Set} → (cbase : C) → (cloop : cbase ≡ cbase) → ap (recS¹ cbase cloop) loop ≡ cloop indS¹ : {C : S¹ → Set} → (cbase : C base) → (cloop : transport C loop cbase ≡ cbase) → (circle : S¹) → C circle indS¹ cbase cloop base* = cbase postulate βindS¹ : {C : S¹ → Set} → (cbase : C base) → (cloop : transport C loop cbase ≡ cbase) → apd (indS¹ {C} cbase cloop) loop ≡ cloop open Circle1 public module Circle2 where private data S¹'* : Set where south* : S¹'* north* : S¹'* S¹' : Set S¹' = S¹'* south : S¹' south = south* north : S¹' north = north* postulate east : south ≡ north west : south ≡ north recS¹' : {C : Set} → (csouth cnorth : C) → (ceast cwest : csouth ≡ cnorth) → S¹' → C recS¹' csouth cnorth ceast cwest south* = csouth recS¹' csouth cnorth ceast cwest north* = cnorth postulate βreceastS¹' : {C : Set} → (csouth cnorth : C) → (ceast cwest : csouth ≡ cnorth) → ap (recS¹' csouth cnorth ceast cwest) east ≡ ceast βrecwestS¹' : {C : Set} → (csouth cnorth : C) → (ceast cwest : csouth ≡ cnorth) → ap (recS¹' csouth cnorth ceast cwest) west ≡ cwest indS¹' : {C : S¹' → Set} → (csouth : C south) → (cnorth : C north) → (ceast : transport C east csouth ≡ cnorth) → (cwest : transport C west csouth ≡ cnorth) → (circle : S¹') → C circle indS¹' csouth cnorth ceast cwest south* = csouth indS¹' csouth cnorth ceast cwest north* = cnorth postulate βindeastS¹' : {C : S¹' → Set} → (csouth : C south) → (cnorth : C north) → (ceast : transport C east csouth ≡ cnorth) → (cwest : transport C west csouth ≡ cnorth) → apd (indS¹' {C} csouth cnorth ceast cwest) east ≡ ceast βindwestS¹' : {C : S¹' → Set} → (csouth : C south) → (cnorth : C north) → (ceast : transport C east csouth ≡ cnorth) → (cwest : transport C west csouth ≡ cnorth) → apd (indS¹' {C} csouth cnorth ceast cwest) west ≡ cwest open Circle2 public Smap : S¹ → S¹' Smap s = recS¹ south (west ∘ (! east)) s S'map : S¹' → S¹ S'map s = recS¹' {C = S¹} base base (refl base) loop s S'toS≡id : S¹' -> Set S'toS≡id = (λ s' → (Smap ○ S'map) s' ≡ id s') StoS'≡id : S¹ -> Set StoS'≡id = (λ s → (S'map ○ Smap) s ≡ id s) Sqinv : qinv Smap Sqinv = mkqinv S'map -- P(s') = (Smap ○ S'map) s' ≡ id s' (indS¹' {C = S'toS≡id} (refl south) (transport S'toS≡id east (refl south)) ((refl (transport S'toS≡id east (refl south)))) -- I've spent several hours exploring how I might -- prove this and I'm completely lost. -- I must be missing something obvious or I'm going about this -- totally wrong =\ (transport S'toS≡id west (refl south) ≡⟨ {!!} ⟩ transport S'toS≡id east (refl south) ∎)) -- P(s) = (S'map ○ Smap) s ≡ id s (indS¹ {C = (λ s → (S'map ○ Smap) s ≡ id s)} -- P (refl base) -- P(base) -- P() (transport StoS'≡id loop (refl base) ≡⟨ {!!} ⟩ -- needs Thm 2.11.3, transportId refl base ∎)) -- ap E x≡y where E is a context allows you to rewrite sequiv : S¹ ≃ S¹' -- any E[x] to E[y] sequiv = (Smap , equiv₁ Sqinv) spath : S¹ ≡ S¹' spath with univalence ... | (_ , eq) = isequiv.g eq sequiv ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4416659171, "avg_line_length": 29.6453333333, "ext": "agda", "hexsha": "cffaed8b27f31493249151bbc7a4b453a116ae66", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andmkent/misc-HoTT", "max_forks_repo_path": "Circle.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andmkent/misc-HoTT", "max_issues_repo_path": "Circle.agda", "max_line_length": 96, "max_stars_count": 1, "max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andmkent/misc-HoTT", "max_stars_repo_path": "Circle.agda", "max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z", "num_tokens": 4929, "size": 11117 }
{-# OPTIONS --safe #-} module Definition.Typed.Weakening where open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed import Tools.PropositionalEquality as PE -- Weakening type data _∷_⊆_ : Wk → Con Term → Con Term → Set where id : ∀ {Γ} → id ∷ Γ ⊆ Γ step : ∀ {Γ Δ A r ρ} → ρ ∷ Δ ⊆ Γ → step ρ ∷ Δ ∙ A ^ r ⊆ Γ lift : ∀ {Γ Δ A r ρ} → ρ ∷ Δ ⊆ Γ → lift ρ ∷ Δ ∙ U.wk ρ A ^ r ⊆ Γ ∙ A ^ r -- -- Weakening composition _•ₜ_ : ∀ {ρ ρ′ Γ Δ Δ′} → ρ ∷ Γ ⊆ Δ → ρ′ ∷ Δ ⊆ Δ′ → ρ • ρ′ ∷ Γ ⊆ Δ′ id •ₜ η′ = η′ step η •ₜ η′ = step (η •ₜ η′) lift η •ₜ id = lift η lift η •ₜ step η′ = step (η •ₜ η′) _•ₜ_ {lift ρ} {lift ρ′} {Δ′ = Δ′ ∙ A ^ rA} (lift η) (lift η′) = PE.subst (λ x → lift (ρ • ρ′) ∷ x ⊆ Δ′ ∙ A ^ rA) (PE.cong₂ (λ x y → x ∙ y ^ rA) PE.refl (PE.sym (wk-comp ρ ρ′ A))) (lift (η •ₜ η′)) -- Weakening of judgements wkIndex : ∀ {Γ Δ n A r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρn = wkVar ρ n in ⊢ Δ → n ∷ A ^ r ∈ Γ → ρn ∷ ρA ^ r ∈ Δ wkIndex id ⊢Δ i = PE.subst (λ x → _ ∷ x ^ _ ∈ _) (PE.sym (wk-id _)) i wkIndex (step ρ) (⊢Δ ∙ A) i = PE.subst (λ x → _ ∷ x ^ _ ∈ _) (wk1-wk _ _) (there (wkIndex ρ ⊢Δ i)) wkIndex (lift ρ) (⊢Δ ∙ A) (there i) = PE.subst (λ x → _ ∷ x ^ _ ∈ _) (wk1-wk≡lift-wk1 _ _) (there (wkIndex ρ ⊢Δ i)) wkIndex (lift ρ) ⊢Δ here = let G = _ n = _ in PE.subst (λ x → n ∷ x ^ _ ∈ G) (wk1-wk≡lift-wk1 _ _) here mutual wk : ∀ {Γ Δ A r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A in ⊢ Δ → Γ ⊢ A ^ r → Δ ⊢ ρA ^ r wk ρ ⊢Δ (Uⱼ ⊢Γ) = Uⱼ ⊢Δ wk ρ ⊢Δ (univ A) = univ (wkTerm ρ ⊢Δ A) wkTerm : ∀ {Γ Δ A t r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρt = U.wk ρ t in ⊢ Δ → Γ ⊢ t ∷ A ^ r → Δ ⊢ ρt ∷ ρA ^ r wkTerm ρ ⊢Δ (univ <l ⊢Γ) = univ <l ⊢Δ wkTerm ρ ⊢Δ (ℕⱼ ⊢Γ) = ℕⱼ ⊢Δ wkTerm ρ ⊢Δ (Emptyⱼ ⊢Γ) = Emptyⱼ ⊢Δ wkTerm ρ ⊢Δ (Πⱼ <l ▹ <l' ▹ F ▹ G) = let ρF = wkTerm ρ ⊢Δ F in Πⱼ <l ▹ <l' ▹ ρF ▹ (wkTerm (lift ρ) (⊢Δ ∙ univ ρF) G) wkTerm ρ ⊢Δ (∃ⱼ F ▹ G) = let ρF = wkTerm ρ ⊢Δ F in ∃ⱼ ρF ▹ (wkTerm (lift ρ) (⊢Δ ∙ univ ρF) G) wkTerm ρ ⊢Δ (var ⊢Γ x) = var ⊢Δ (wkIndex ρ ⊢Δ x) wkTerm ρ ⊢Δ (lamⱼ <l <l' F t) = let ρF = wk ρ ⊢Δ F in lamⱼ <l <l' ρF (wkTerm (lift ρ) (⊢Δ ∙ ρF) t) wkTerm ρ ⊢Δ (_∘ⱼ_ {G = G} g a) = PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (PE.sym (wk-β G)) (wkTerm ρ ⊢Δ g ∘ⱼ wkTerm ρ ⊢Δ a) wkTerm ρ ⊢Δ (⦅_,_,_,_⦆ⱼ {G = GG} F G t u ) = let ρF = wk ρ ⊢Δ F in ⦅ wk ρ ⊢Δ F , wk (lift ρ) (⊢Δ ∙ ρF) G , wkTerm ρ ⊢Δ t , PE.subst (λ X → _ ⊢ _ ∷ X ^ [ % , _ ]) (wk-β GG) (wkTerm ρ ⊢Δ u) ⦆ⱼ wkTerm ρ ⊢Δ (fstⱼ F G t) = let ρF = wkTerm ρ ⊢Δ F in let ρG = (wkTerm (lift ρ) (⊢Δ ∙ univ ρF) G) in fstⱼ ρF ρG (wkTerm ρ ⊢Δ t) wkTerm ρ ⊢Δ (sndⱼ {G = G} F Gⱼ t) = let ρF = wkTerm ρ ⊢Δ F in let ρG = (wkTerm (lift ρ) (⊢Δ ∙ univ ρF) Gⱼ) in PE.subst (λ X → _ ⊢ _ ∷ X ^ [ % , _ ]) (PE.sym (wk-β G)) (sndⱼ ρF ρG (wkTerm ρ ⊢Δ t)) wkTerm ρ ⊢Δ (zeroⱼ ⊢Γ) = zeroⱼ ⊢Δ wkTerm ρ ⊢Δ (sucⱼ n) = sucⱼ (wkTerm ρ ⊢Δ n) wkTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (natrecⱼ {G = G} {rG = rG} {lG = lG} {s = s} ⊢G ⊢z ⊢s ⊢n) = PE.subst (λ x → _ ⊢ natrec _ _ _ _ _ ∷ x ^ _) (PE.sym (wk-β G)) (natrecⱼ (wk (lift [ρ]) (⊢Δ ∙ univ (ℕⱼ ⊢Δ)) ⊢G) (PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (wk-β G) (wkTerm [ρ] ⊢Δ ⊢z)) (PE.subst (λ x → Δ ⊢ U.wk ρ s ∷ x ^ [ rG , ι lG ]) (wk-β-natrec ρ G rG lG) (wkTerm [ρ] ⊢Δ ⊢s)) (wkTerm [ρ] ⊢Δ ⊢n)) wkTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (Emptyrecⱼ {A = A} {e = e} ⊢A ⊢e) = (Emptyrecⱼ (wk [ρ] ⊢Δ ⊢A) (wkTerm [ρ] ⊢Δ ⊢e)) wkTerm ρ ⊢Δ (Idⱼ A t u) = Idⱼ (wkTerm ρ ⊢Δ A) (wkTerm ρ ⊢Δ t) (wkTerm ρ ⊢Δ u) wkTerm ρ ⊢Δ (Idreflⱼ t) = Idreflⱼ (wkTerm ρ ⊢Δ t) wkTerm ρ ⊢Δ (transpⱼ {P = P} A Pⱼ t s u e) = let ρA = wk ρ ⊢Δ A in let ρP = wk (lift ρ) (⊢Δ ∙ ρA) Pⱼ in let ρt = wkTerm ρ ⊢Δ t in let ρs = PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (wk-β P) (wkTerm ρ ⊢Δ s) in let ρu = wkTerm ρ ⊢Δ u in let ρe = wkTerm ρ ⊢Δ e in PE.subst (λ x → _ ⊢ transp _ _ _ _ _ _ ∷ x ^ _) (PE.sym (wk-β P)) (transpⱼ ρA ρP ρt ρs ρu ρe) wkTerm ρ ⊢Δ (castⱼ A B e t) = castⱼ (wkTerm ρ ⊢Δ A) (wkTerm ρ ⊢Δ B) (wkTerm ρ ⊢Δ e) (wkTerm ρ ⊢Δ t) wkTerm ρ ⊢Δ (castreflⱼ A t) = castreflⱼ (wkTerm ρ ⊢Δ A) (wkTerm ρ ⊢Δ t) wkTerm ρ ⊢Δ (conv t A≡B) = conv (wkTerm ρ ⊢Δ t) (wkEq ρ ⊢Δ A≡B) wkEq : ∀ {Γ Δ A B r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρB = U.wk ρ B in ⊢ Δ → Γ ⊢ A ≡ B ^ r → Δ ⊢ ρA ≡ ρB ^ r wkEq ρ ⊢Δ (univ A≡B) = univ (wkEqTerm ρ ⊢Δ A≡B) wkEq ρ ⊢Δ (refl A) = refl (wk ρ ⊢Δ A) wkEq ρ ⊢Δ (sym A≡B) = sym (wkEq ρ ⊢Δ A≡B) wkEq ρ ⊢Δ (trans A≡B B≡C) = trans (wkEq ρ ⊢Δ A≡B) (wkEq ρ ⊢Δ B≡C) wkEqTerm : ∀ {Γ Δ A t u r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρt = U.wk ρ t ρu = U.wk ρ u in ⊢ Δ → Γ ⊢ t ≡ u ∷ A ^ r → Δ ⊢ ρt ≡ ρu ∷ ρA ^ r wkEqTerm ρ ⊢Δ (refl t) = refl (wkTerm ρ ⊢Δ t) wkEqTerm ρ ⊢Δ (sym t≡u) = sym (wkEqTerm ρ ⊢Δ t≡u) wkEqTerm ρ ⊢Δ (trans t≡u u≡r) = trans (wkEqTerm ρ ⊢Δ t≡u) (wkEqTerm ρ ⊢Δ u≡r) wkEqTerm ρ ⊢Δ (conv t≡u A≡B) = conv (wkEqTerm ρ ⊢Δ t≡u) (wkEq ρ ⊢Δ A≡B) wkEqTerm ρ ⊢Δ (Π-cong <l <l' F F≡H G≡E) = let ρF = wk ρ ⊢Δ F in Π-cong <l <l' ρF (wkEqTerm ρ ⊢Δ F≡H) (wkEqTerm (lift ρ) (⊢Δ ∙ ρF) G≡E) wkEqTerm ρ ⊢Δ (∃-cong F F≡H G≡E) = let ρF = wk ρ ⊢Δ F in ∃-cong ρF (wkEqTerm ρ ⊢Δ F≡H) (wkEqTerm (lift ρ) (⊢Δ ∙ ρF) G≡E) wkEqTerm ρ ⊢Δ (app-cong {G = G} f≡g a≡b) = PE.subst (λ x → _ ⊢ _ ≡ _ ∷ x ^ _) (PE.sym (wk-β G)) (app-cong (wkEqTerm ρ ⊢Δ f≡g) (wkEqTerm ρ ⊢Δ a≡b)) wkEqTerm ρ ⊢Δ (β-red {a = a} {t = t} {G = G} l< l<' F ⊢t ⊢a) = let ρF = wk ρ ⊢Δ F in PE.subst (λ x → _ ⊢ _ ≡ _ ∷ x ^ _) (PE.sym (wk-β G)) (PE.subst (λ x → _ ⊢ U.wk _ ((lam _ ▹ t ^ _) ∘ a ^ _) ≡ x ∷ _ ^ _) (PE.sym (wk-β t)) (β-red l< l<' ρF (wkTerm (lift ρ) (⊢Δ ∙ ρF) ⊢t) (wkTerm ρ ⊢Δ ⊢a))) wkEqTerm ρ ⊢Δ (η-eq lF lG F f g f0≡g0) = let ρF = wk ρ ⊢Δ F in η-eq lF lG ρF (wkTerm ρ ⊢Δ f) (wkTerm ρ ⊢Δ g) (PE.subst (λ t → _ ⊢ t ∘ _ ^ _ ≡ _ ∷ _ ^ _) (PE.sym (wk1-wk≡lift-wk1 _ _)) (PE.subst (λ t → _ ⊢ _ ≡ t ∘ _ ^ _ ∷ _ ^ _) (PE.sym (wk1-wk≡lift-wk1 _ _)) (wkEqTerm (lift ρ) (⊢Δ ∙ ρF) f0≡g0))) wkEqTerm ρ ⊢Δ (suc-cong m≡n) = suc-cong (wkEqTerm ρ ⊢Δ m≡n) wkEqTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (natrec-cong {s = s} {s′ = s′} {F = F} {l = l} F≡F′ z≡z′ s≡s′ n≡n′) = PE.subst (λ x → Δ ⊢ natrec _ _ _ _ _ ≡ _ ∷ x ^ _) (PE.sym (wk-β F)) (natrec-cong (wkEq (lift [ρ]) (⊢Δ ∙ univ (ℕⱼ ⊢Δ)) F≡F′) (PE.subst (λ x → Δ ⊢ _ ≡ _ ∷ x ^ _) (wk-β F) (wkEqTerm [ρ] ⊢Δ z≡z′)) (PE.subst (λ x → Δ ⊢ U.wk ρ s ≡ U.wk ρ s′ ∷ x ^ [ ! , ι l ]) (wk-β-natrec _ F ! l) (wkEqTerm [ρ] ⊢Δ s≡s′)) (wkEqTerm [ρ] ⊢Δ n≡n′)) wkEqTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (natrec-zero {z} {s} {F} {l = l} ⊢F ⊢z ⊢s) = PE.subst (λ x → Δ ⊢ natrec _ (U.wk (lift _) F) _ _ _ ≡ _ ∷ x ^ _) (PE.sym (wk-β F)) (natrec-zero (wk (lift [ρ]) (⊢Δ ∙ univ (ℕⱼ ⊢Δ)) ⊢F) (PE.subst (λ x → Δ ⊢ U.wk ρ z ∷ x ^ _) (wk-β F) (wkTerm [ρ] ⊢Δ ⊢z)) (PE.subst (λ x → Δ ⊢ U.wk ρ s ∷ x ^ [ ! , ι l ]) (wk-β-natrec _ F ! l) (wkTerm [ρ] ⊢Δ ⊢s))) wkEqTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (natrec-suc {n} {z} {s} {F} {l = l} ⊢n ⊢F ⊢z ⊢s) = PE.subst (λ x → Δ ⊢ natrec _ (U.wk (lift _) F) _ _ _ ≡ _ ∘ (natrec _ _ _ _ _) ^ _ ∷ x ^ _) (PE.sym (wk-β F)) (natrec-suc (wkTerm [ρ] ⊢Δ ⊢n) (wk (lift [ρ]) (⊢Δ ∙ univ (ℕⱼ ⊢Δ)) ⊢F) (PE.subst (λ x → Δ ⊢ U.wk ρ z ∷ x ^ _) (wk-β F) (wkTerm [ρ] ⊢Δ ⊢z)) (PE.subst (λ x → Δ ⊢ U.wk ρ s ∷ x ^ [ ! , ι l ]) (wk-β-natrec _ F ! l) (wkTerm [ρ] ⊢Δ ⊢s))) wkEqTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (Emptyrec-cong {A = A} {A' = A'} {e = e} {e' = e'} A≡A' ⊢e ⊢e') = Emptyrec-cong (wkEq [ρ] ⊢Δ A≡A') (wkTerm [ρ] ⊢Δ ⊢e) (wkTerm [ρ] ⊢Δ ⊢e') wkEqTerm [ρ] ⊢Δ (proof-irrelevance t u) = proof-irrelevance (wkTerm [ρ] ⊢Δ t) (wkTerm [ρ] ⊢Δ u) wkEqTerm ρ ⊢Δ (Id-cong A t u) = Id-cong (wkEqTerm ρ ⊢Δ A) (wkEqTerm ρ ⊢Δ t) (wkEqTerm ρ ⊢Δ u) wkEqTerm {ρ = ρ} [ρ] ⊢Δ (Id-Π {rA = rA} {t = t} {u = u} <l <l' Aⱼ Bⱼ tⱼ uⱼ) = let ρA = wkTerm [ρ] ⊢Δ Aⱼ in let ρB = wkTerm (lift [ρ]) (⊢Δ ∙ univ ρA) Bⱼ in let ρt = wkTerm [ρ] ⊢Δ tⱼ in let ρu = wkTerm [ρ] ⊢Δ uⱼ in PE.subst (λ x → _ ⊢ Id _ (U.wk ρ t) _ ≡ Π _ ^ _ ° _ ▹ Id _ (x ∘ _ ^ _) _ ° _ ° _ ∷ _ ^ [ ! , _ ]) (wk1-wk≡lift-wk1 ρ t) (PE.subst (λ x → _ ⊢ Id _ _ (U.wk ρ u) ≡ Π _ ^ _ ° _ ▹ Id _ _ (x ∘ _ ^ _) ° _ ° _ ∷ _ ^ [ ! , _ ]) (wk1-wk≡lift-wk1 ρ u) (Id-Π <l <l' ρA ρB ρt ρu)) wkEqTerm ρ ⊢Δ (Id-ℕ-00 ⊢Γ) = Id-ℕ-00 ⊢Δ wkEqTerm ρ ⊢Δ (Id-ℕ-SS m n) = Id-ℕ-SS (wkTerm ρ ⊢Δ m) (wkTerm ρ ⊢Δ n) wkEqTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (Id-U-ΠΠ {A = A} {A' = A'} {rA = rA} {B = B} {B' = B'} Aⱼ Bⱼ A'ⱼ B'ⱼ) = let ρA = wkTerm [ρ] ⊢Δ Aⱼ in let ρA' = wkTerm [ρ] ⊢Δ A'ⱼ in let ρB = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA)) Bⱼ in let ρB' = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA')) B'ⱼ in let l = ⁰ in let l' = ¹ in let pred = λ A1 A1' A2' B1 B1' → Δ ⊢ U.wk ρ (Id (U l) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° l) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° l)) ≡ ∃ U.wk ρ (Id (Univ rA l) A A') ▹ (Π A1' ^ rA ° ⁰ ▹ Id (U l) (B1 [ cast l A2' A1 (Idsym (Univ rA l) A1 A2' (var 1)) (var 0) ]↑) B1' ° l' ° l') ∷ SProp l' ^ [ ! , next l' ] in let j1 : pred (wk1 (wk1 (U.wk ρ A))) (wk1 (U.wk ρ A')) (wk1 (wk1 (U.wk ρ A'))) (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B')) j1 = Id-U-ΠΠ ρA ρB ρA' ρB' in let j2 = PE.subst (λ x → pred (wk1 (wk1 (U.wk ρ A))) x (wk1 (wk1 (U.wk ρ A'))) (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B'))) (wk1-wk≡lift-wk1 ρ A') j1 in let j3 = PE.subst (λ x → pred x (U.wk (lift ρ) (wk1 A')) (wk1 (wk1 (U.wk ρ A'))) (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B'))) (wk1wk1-wk≡liftlift-wk1 ρ A) j2 in let j4 = PE.subst (λ x → pred (U.wk (lift (lift ρ)) (wk1 (wk1 A))) (U.wk (lift ρ) (wk1 A')) x (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B'))) (wk1wk1-wk≡liftlift-wk1 ρ A') j3 in let j5 = PE.subst (λ x → pred (U.wk (lift (lift ρ)) (wk1 (wk1 A))) (U.wk (lift ρ) (wk1 A')) (U.wk (lift (lift ρ)) (wk1 (wk1 A'))) x (wk1d (U.wk (lift ρ) B'))) (wk1d-wk≡lift-wk1d ρ B) j4 in let j6 = PE.subst (λ x → pred (U.wk (lift (lift ρ)) (wk1 (wk1 A))) (U.wk (lift ρ) (wk1 A')) (U.wk (lift (lift ρ)) (wk1 (wk1 A'))) (U.wk (lift (lift ρ)) (wk1d B)) x) (wk1d-wk≡lift-wk1d ρ B') j5 in let j7 = PE.subst (λ x → Δ ⊢ U.wk ρ (Id (U l) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° l) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° l)) ≡ ∃ U.wk ρ (Id (Univ rA l) A A') ▹ (Π U.wk (lift ρ) (wk1 A') ^ rA ° ⁰ ▹ Id (U l) (U.wk (lift (lift ρ)) (wk1d B) [ (cast l (U.wk (lift (lift ρ)) (wk1 (wk1 A'))) (U.wk (lift (lift ρ)) (wk1 (wk1 A))) x (var 0)) ]↑) (U.wk (lift (lift ρ)) (wk1d B')) ° l' ° l') ∷ SProp l' ^ [ ! , next l' ]) (PE.sym (wk-Idsym (lift (lift ρ)) (Univ rA l) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1))) j6 in PE.subst (λ x → Δ ⊢ U.wk ρ (Id (U l) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° l) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° l)) ≡ ∃ U.wk ρ (Id (Univ rA l) A A') ▹ (Π U.wk (lift ρ) (wk1 A') ^ rA ° ⁰ ▹ Id (U l) x (U.wk (lift (lift ρ)) (wk1d B')) ° l' ° l') ∷ SProp l' ^ [ ! , _ ]) (PE.sym (wk-β↑ {ρ = lift ρ} {a = cast l (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA l) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0)} (wk1d B))) j7 wkEqTerm ρ ⊢Δ (Id-U-ℕℕ ⊢Γ) = Id-U-ℕℕ ⊢Δ wkEqTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (Id-SProp {A = A} {B = B} Aⱼ Bⱼ) = let ρA = wkTerm [ρ] ⊢Δ Aⱼ ρB = wkTerm [ρ] ⊢Δ Bⱼ l = ⁰ l' = ¹ in PE.subst (λ x → _ ⊢ Id (SProp l) (U.wk ρ A) _ ≡ ∃ (Π U.wk ρ A ^ % ° ⁰ ▹ _ ° ⁰ ° l') ▹ (Π _ ^ % ° ⁰ ▹ x ° _ ° l') ∷ _ ^ [ ! , _ ]) (wk1d-wk≡lift-wk1d ρ (wk1 A)) (PE.subst (λ x → _ ⊢ Id (SProp l) (U.wk ρ A) _ ≡ ∃ (Π U.wk ρ A ^ % ° ⁰ ▹ _ ° ⁰ ° l') ▹ (Π _ ^ % ° ⁰ ▹ U.wk (lift (step id)) x ° _ ° l') ∷ _ ^ [ ! , _ ]) (wk1-wk≡lift-wk1 ρ A) (PE.subst (λ x → _ ⊢ Id (SProp l) (U.wk ρ A) (U.wk ρ B) ≡ ∃ (Π U.wk ρ A ^ % ° ⁰ ▹ x ° ⁰ ° l') ▹ (Π x ^ % ° ⁰ ▹ _ ° ⁰ ° l') ∷ SProp ¹ ^ [ ! , _ ]) (wk1-wk≡lift-wk1 ρ B) (Id-SProp {A = U.wk ρ A} {B = U.wk ρ B} ρA ρB))) wkEqTerm ρ ⊢Δ (Id-ℕ-0S n) = Id-ℕ-0S (wkTerm ρ ⊢Δ n) wkEqTerm ρ ⊢Δ (Id-ℕ-S0 n) = Id-ℕ-S0 (wkTerm ρ ⊢Δ n) wkEqTerm ρ ⊢Δ (Id-U-ℕΠ A B) = let ρA = wkTerm ρ ⊢Δ A in let ρB = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) B in Id-U-ℕΠ ρA ρB wkEqTerm ρ ⊢Δ (Id-U-Πℕ A B) = let ρA = wkTerm ρ ⊢Δ A in let ρB = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) B in Id-U-Πℕ ρA ρB wkEqTerm ρ ⊢Δ (Id-U-ΠΠ!% eq A B A' B') = let ρA = wkTerm ρ ⊢Δ A ρB = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) B ρA' = wkTerm ρ ⊢Δ A' ρB' = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA')) B' in Id-U-ΠΠ!% eq ρA ρB ρA' ρB' wkEqTerm ρ ⊢Δ (cast-cong A B t e e') = cast-cong (wkEqTerm ρ ⊢Δ A) (wkEqTerm ρ ⊢Δ B) (wkEqTerm ρ ⊢Δ t) (wkTerm ρ ⊢Δ e) (wkTerm ρ ⊢Δ e') wkEqTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (cast-Π {A = A} {A' = A'} {rA = rA} {B = B} {B' = B'} {e = e} {f = f} Aⱼ Bⱼ A'ⱼ B'ⱼ eⱼ fⱼ) = let l = ⁰ in let lA = ⁰ in let lB = ⁰ in let ρA = wkTerm [ρ] ⊢Δ Aⱼ in let ρA' = wkTerm [ρ] ⊢Δ A'ⱼ in let ρB = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA)) Bⱼ in let ρB' = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA')) B'ⱼ in let ρe = wkTerm [ρ] ⊢Δ eⱼ in let ρf = wkTerm [ρ] ⊢Δ fⱼ in let pred = λ A1 A1' e1 f1 → Δ ⊢ U.wk ρ (cast l (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) e f) ≡ (lam (U.wk ρ A') ▹ (let a = cast l A1' A1 (Idsym (Univ rA l) A1 A1' (fst e1)) (var 0) in cast l ((U.wk (lift ρ) B) [ a ]↑) (U.wk (lift ρ) B') ((snd e1) ∘ (var 0) ^ ¹) (f1 ∘ a ^ l)) ^ l) ∷ U.wk ρ (Π A' ^ rA ° lA ▹ B' ° lB ° l) ^ [ ! , _ ] in let j0 : pred (wk1 (U.wk ρ A)) (wk1 (U.wk ρ A')) (wk1 (U.wk ρ e)) (wk1 (U.wk ρ f)) j0 = cast-Π ρA ρB ρA' ρB' ρe ρf in let j1 = PE.subst (λ x → pred x (wk1 (U.wk ρ A')) (wk1 (U.wk ρ e)) (wk1 (U.wk ρ f))) (wk1-wk≡lift-wk1 ρ A) j0 in let j2 = PE.subst (λ x → pred (U.wk (lift ρ) (wk1 A)) x (wk1 (U.wk ρ e)) (wk1 (U.wk ρ f))) (wk1-wk≡lift-wk1 ρ A') j1 in let j3 = PE.subst (λ x → pred (U.wk (lift ρ) (wk1 A)) (U.wk (lift ρ) (wk1 A')) x (wk1 (U.wk ρ f))) (wk1-wk≡lift-wk1 ρ e) j2 in let j4 = PE.subst (λ x → pred (U.wk (lift ρ) (wk1 A)) (U.wk (lift ρ) (wk1 A')) (U.wk (lift ρ) (wk1 e)) x) (wk1-wk≡lift-wk1 ρ f) j3 in let j5 = PE.subst (λ x → Δ ⊢ U.wk ρ (cast l (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) e f) ≡ (lam (U.wk ρ A') ▹ (let a = cast l (U.wk (lift ρ) (wk1 A')) (U.wk (lift ρ) (wk1 A)) x (var 0) in cast l ((U.wk (lift ρ) B) [ a ]↑) (U.wk (lift ρ) B') ((snd (U.wk (lift ρ) (wk1 e))) ∘ (var 0) ^ ¹) ((U.wk (lift ρ) (wk1 f)) ∘ a ^ l)) ^ l) ∷ U.wk ρ (Π A' ^ rA ° lA ▹ B' ° lB ° l) ^ [ ! , ι l ]) (PE.sym (wk-Idsym (lift ρ) (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e)))) j4 in PE.subst (λ x → Δ ⊢ U.wk ρ (cast l (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) e f) ≡ (lam (U.wk ρ A') ▹ (let a = U.wk (lift ρ) (cast l (wk1 A') (wk1 A) (Idsym (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0)) in cast l x (U.wk (lift ρ) B') ((snd (U.wk (lift ρ) (wk1 e))) ∘ (var 0) ^ ¹) ((U.wk (lift ρ) (wk1 f)) ∘ a ^ l)) ^ l) ∷ U.wk ρ (Π A' ^ rA ° lA ▹ B' ° lB ° l) ^ [ ! , ι l ]) (PE.sym (wk-β↑ {ρ = ρ} {a = (cast l (wk1 A') (wk1 A) (Idsym (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0))} B)) j5 wkEqTerm ρ ⊢Δ (cast-ℕ-0 e) = cast-ℕ-0 (wkTerm ρ ⊢Δ e) wkEqTerm ρ ⊢Δ (cast-ℕ-S e n) = cast-ℕ-S (wkTerm ρ ⊢Δ e) (wkTerm ρ ⊢Δ n) mutual wkRed : ∀ {Γ Δ A B r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρB = U.wk ρ B in ⊢ Δ → Γ ⊢ A ⇒ B ^ r → Δ ⊢ ρA ⇒ ρB ^ r wkRed ρ ⊢Δ (univ A⇒B) = univ (wkRedTerm ρ ⊢Δ A⇒B) wkRedTerm : ∀ {Γ Δ A l t u ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρt = U.wk ρ t ρu = U.wk ρ u in ⊢ Δ → Γ ⊢ t ⇒ u ∷ A ^ l → Δ ⊢ ρt ⇒ ρu ∷ ρA ^ l wkRedTerm ρ ⊢Δ (conv t⇒u A≡B) = conv (wkRedTerm ρ ⊢Δ t⇒u) (wkEq ρ ⊢Δ A≡B) wkRedTerm ρ ⊢Δ (app-subst {B = B} t⇒u a) = PE.subst (λ x → _ ⊢ _ ⇒ _ ∷ x ^ _) (PE.sym (wk-β B)) (app-subst (wkRedTerm ρ ⊢Δ t⇒u) (wkTerm ρ ⊢Δ a)) wkRedTerm ρ ⊢Δ (β-red {A} {B} {lF} {lG} {a} {t} l< l<' ⊢A ⊢t ⊢a) = let ⊢ρA = wk ρ ⊢Δ ⊢A in PE.subst (λ x → _ ⊢ _ ⇒ _ ∷ x ^ _) (PE.sym (wk-β B)) (PE.subst (λ x → _ ⊢ U.wk _ ((lam _ ▹ t ^ _) ∘ a ^ _) ⇒ x ∷ _ ^ _) (PE.sym (wk-β t)) (β-red l< l<' ⊢ρA (wkTerm (lift ρ) (⊢Δ ∙ ⊢ρA) ⊢t) (wkTerm ρ ⊢Δ ⊢a))) wkRedTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (natrec-subst {s = s} {F = F} {l = l} ⊢F ⊢z ⊢s n⇒n′) = PE.subst (λ x → _ ⊢ natrec _ _ _ _ _ ⇒ _ ∷ x ^ _) (PE.sym (wk-β F)) (natrec-subst (wk (lift [ρ]) (⊢Δ ∙ univ (ℕⱼ ⊢Δ)) ⊢F) (PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (wk-β F) (wkTerm [ρ] ⊢Δ ⊢z)) (PE.subst (λ x → Δ ⊢ U.wk ρ s ∷ x ^ [ ! , ι l ]) (wk-β-natrec _ F ! l) (wkTerm [ρ] ⊢Δ ⊢s)) (wkRedTerm [ρ] ⊢Δ n⇒n′)) wkRedTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (natrec-zero {s = s} {F = F} {l = l} ⊢F ⊢z ⊢s) = PE.subst (λ x → _ ⊢ natrec _ (U.wk (lift ρ) F) _ _ _ ⇒ _ ∷ x ^ _) (PE.sym (wk-β F)) (natrec-zero (wk (lift [ρ]) (⊢Δ ∙ univ (ℕⱼ ⊢Δ)) ⊢F) (PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (wk-β F) (wkTerm [ρ] ⊢Δ ⊢z)) (PE.subst (λ x → Δ ⊢ U.wk ρ s ∷ x ^ [ ! , ι l ]) (wk-β-natrec ρ F ! l) (wkTerm [ρ] ⊢Δ ⊢s))) wkRedTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (natrec-suc {s = s} {F = F} {l = l} ⊢n ⊢F ⊢z ⊢s) = PE.subst (λ x → _ ⊢ natrec _ _ _ _ _ ⇒ _ ∘ natrec _ _ _ _ _ ^ _ ∷ x ^ _) (PE.sym (wk-β F)) (natrec-suc (wkTerm [ρ] ⊢Δ ⊢n) (wk (lift [ρ]) (⊢Δ ∙ univ (ℕⱼ ⊢Δ)) ⊢F) (PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (wk-β F) (wkTerm [ρ] ⊢Δ ⊢z)) (PE.subst (λ x → Δ ⊢ U.wk ρ s ∷ x ^ [ ! , ι l ]) (wk-β-natrec ρ F ! l) (wkTerm [ρ] ⊢Δ ⊢s))) wkRedTerm ρ ⊢Δ (Id-subst A t u) = Id-subst (wkRedTerm ρ ⊢Δ A) (wkTerm ρ ⊢Δ t) (wkTerm ρ ⊢Δ u) wkRedTerm ρ ⊢Δ (Id-ℕ-subst m n) = Id-ℕ-subst (wkRedTerm ρ ⊢Δ m) (wkTerm ρ ⊢Δ n) wkRedTerm ρ ⊢Δ (Id-ℕ-0-subst n) = Id-ℕ-0-subst (wkRedTerm ρ ⊢Δ n) wkRedTerm ρ ⊢Δ (Id-ℕ-S-subst m n) = Id-ℕ-S-subst (wkTerm ρ ⊢Δ m) (wkRedTerm ρ ⊢Δ n) wkRedTerm ρ ⊢Δ (Id-U-subst A B) = Id-U-subst (wkRedTerm ρ ⊢Δ A) (wkTerm ρ ⊢Δ B) wkRedTerm ρ ⊢Δ (Id-U-ℕ-subst B) = Id-U-ℕ-subst (wkRedTerm ρ ⊢Δ B) wkRedTerm ρ ⊢Δ (Id-U-Π-subst A P B) = let ρA = wkTerm ρ ⊢Δ A in Id-U-Π-subst ρA (wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) P) (wkRedTerm ρ ⊢Δ B) wkRedTerm {ρ = ρ} [ρ] ⊢Δ (Id-Π {t = t} {u = u} <l <l' Aⱼ Bⱼ tⱼ uⱼ) = let ρA = wkTerm [ρ] ⊢Δ Aⱼ in let ρB = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA)) Bⱼ in let ρt = wkTerm [ρ] ⊢Δ tⱼ in let ρu = wkTerm [ρ] ⊢Δ uⱼ in PE.subst (λ x → _ ⊢ Id _ (U.wk ρ t) _ ⇒ Π _ ^ _ ° _ ▹ Id _ (x ∘ _ ^ _) _ ° _ ° _ ∷ _ ^ _) (wk1-wk≡lift-wk1 ρ t) (PE.subst (λ x → _ ⊢ Id _ _ (U.wk ρ u) ⇒ Π _ ^ _ ° _ ▹ Id _ _ (x ∘ _ ^ _) ° _ ° _ ∷ _ ^ _) (wk1-wk≡lift-wk1 ρ u) (Id-Π <l <l' ρA ρB ρt ρu)) wkRedTerm ρ ⊢Δ (Id-ℕ-00 ⊢Γ) = Id-ℕ-00 ⊢Δ wkRedTerm ρ ⊢Δ (Id-ℕ-SS m n) = Id-ℕ-SS (wkTerm ρ ⊢Δ m) (wkTerm ρ ⊢Δ n) wkRedTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (Id-U-ΠΠ {A = A} {A' = A'} {rA = rA} {B = B} {B' = B'} Aⱼ Bⱼ A'ⱼ B'ⱼ) = let l = ⁰ in let l' = ¹ in let ρA = wkTerm [ρ] ⊢Δ Aⱼ in let ρA' = wkTerm [ρ] ⊢Δ A'ⱼ in let ρB = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA)) Bⱼ in let ρB' = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA')) B'ⱼ in let pred = λ A1 A1' A2' B1 B1' → Δ ⊢ U.wk ρ (Id (U l) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° l) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° l)) ⇒ ∃ U.wk ρ (Id (Univ rA l) A A') ▹ (Π A1' ^ rA ° ⁰ ▹ Id (U l) (B1 [ cast l A2' A1 (Idsym (Univ rA l) A1 A2' (var 1)) (var 0) ]↑) B1' ° l' ° l') ∷ SProp l' ^ next l' in let j1 : pred (wk1 (wk1 (U.wk ρ A))) (wk1 (U.wk ρ A')) (wk1 (wk1 (U.wk ρ A'))) (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B')) j1 = Id-U-ΠΠ ρA ρB ρA' ρB' in let j2 = PE.subst (λ x → pred (wk1 (wk1 (U.wk ρ A))) x (wk1 (wk1 (U.wk ρ A'))) (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B'))) (wk1-wk≡lift-wk1 ρ A') j1 in let j3 = PE.subst (λ x → pred x (U.wk (lift ρ) (wk1 A')) (wk1 (wk1 (U.wk ρ A'))) (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B'))) (wk1wk1-wk≡liftlift-wk1 ρ A) j2 in let j4 = PE.subst (λ x → pred (U.wk (lift (lift ρ)) (wk1 (wk1 A))) (U.wk (lift ρ) (wk1 A')) x (wk1d (U.wk (lift ρ) B)) (wk1d (U.wk (lift ρ) B'))) (wk1wk1-wk≡liftlift-wk1 ρ A') j3 in let j5 = PE.subst (λ x → pred (U.wk (lift (lift ρ)) (wk1 (wk1 A))) (U.wk (lift ρ) (wk1 A')) (U.wk (lift (lift ρ)) (wk1 (wk1 A'))) x (wk1d (U.wk (lift ρ) B'))) (wk1d-wk≡lift-wk1d ρ B) j4 in let j6 = PE.subst (λ x → pred (U.wk (lift (lift ρ)) (wk1 (wk1 A))) (U.wk (lift ρ) (wk1 A')) (U.wk (lift (lift ρ)) (wk1 (wk1 A'))) (U.wk (lift (lift ρ)) (wk1d B)) x) (wk1d-wk≡lift-wk1d ρ B') j5 in let j7 = PE.subst (λ x → Δ ⊢ U.wk ρ (Id (U l) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° l) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° l)) ⇒ ∃ U.wk ρ (Id (Univ rA l) A A') ▹ (Π U.wk (lift ρ) (wk1 A') ^ rA ° ⁰ ▹ Id (U l) (U.wk (lift (lift ρ)) (wk1d B) [ (cast l (U.wk (lift (lift ρ)) (wk1 (wk1 A'))) (U.wk (lift (lift ρ)) (wk1 (wk1 A))) x (var 0)) ]↑) (U.wk (lift (lift ρ)) (wk1d B')) ° l' ° l') ∷ SProp l' ^ next l') (PE.sym (wk-Idsym (lift (lift ρ)) (Univ rA l) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1))) j6 in PE.subst (λ x → Δ ⊢ U.wk ρ (Id (U l) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° l) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° l)) ⇒ ∃ U.wk ρ (Id (Univ rA l) A A') ▹ (Π U.wk (lift ρ) (wk1 A') ^ rA ° ⁰ ▹ Id (U l) x (U.wk (lift (lift ρ)) (wk1d B')) ° l' ° l') ∷ SProp l' ^ next l') (PE.sym (wk-β↑ {ρ = lift ρ} {a = cast l (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA l) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0)} (wk1d B))) j7 wkRedTerm ρ ⊢Δ (Id-U-ℕℕ ⊢Γ) = Id-U-ℕℕ ⊢Δ wkRedTerm {ρ = ρ} [ρ] ⊢Δ (Id-SProp {A = A} {B = B} Aⱼ Bⱼ) = let ρA = wkTerm [ρ] ⊢Δ Aⱼ ρB = wkTerm [ρ] ⊢Δ Bⱼ l = ⁰ l' = ¹ in PE.subst (λ x → _ ⊢ Id (SProp l) (U.wk ρ A) _ ⇒ ∃ (Π U.wk ρ A ^ % ° ⁰ ▹ _ ° ⁰ ° _) ▹ (Π _ ^ % ° ⁰ ▹ x ° _ ° _) ∷ _ ^ _) (wk1d-wk≡lift-wk1d ρ (wk1 A)) (PE.subst (λ x → _ ⊢ Id (SProp l) (U.wk ρ A) _ ⇒ ∃ (Π U.wk ρ A ^ % ° ⁰ ▹ _ ° ⁰ ° _) ▹ (Π _ ^ % ° ⁰ ▹ U.wk (lift (step id)) x ° _ ° _) ∷ _ ^ _ ) (wk1-wk≡lift-wk1 ρ A) (PE.subst (λ x → _ ⊢ Id (SProp l) (U.wk ρ A) (U.wk ρ B) ⇒ ∃ (Π U.wk ρ A ^ % ° ⁰ ▹ x ° ⁰ ° _) ▹ (Π x ^ % ° ⁰ ▹ _ ° ⁰ ° _) ∷ SProp ¹ ^ _ ) (wk1-wk≡lift-wk1 ρ B) (Id-SProp {A = U.wk ρ A} {B = U.wk ρ B} ρA ρB))) wkRedTerm ρ ⊢Δ (Id-ℕ-0S n) = Id-ℕ-0S (wkTerm ρ ⊢Δ n) wkRedTerm ρ ⊢Δ (Id-ℕ-S0 n) = Id-ℕ-S0 (wkTerm ρ ⊢Δ n) wkRedTerm ρ ⊢Δ (Id-U-ℕΠ A B) = let ρA = wkTerm ρ ⊢Δ A in let ρB = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) B in Id-U-ℕΠ ρA ρB wkRedTerm ρ ⊢Δ (Id-U-Πℕ A B) = let ρA = wkTerm ρ ⊢Δ A in let ρB = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) B in Id-U-Πℕ ρA ρB wkRedTerm ρ ⊢Δ (Id-U-ΠΠ!% eq A B A' B') = let ρA = wkTerm ρ ⊢Δ A ρB = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) B ρA' = wkTerm ρ ⊢Δ A' ρB' = wkTerm (lift ρ) (⊢Δ ∙ (univ ρA')) B' in Id-U-ΠΠ!% eq ρA ρB ρA' ρB' wkRedTerm ρ ⊢Δ (cast-subst A B e t) = cast-subst (wkRedTerm ρ ⊢Δ A) (wkTerm ρ ⊢Δ B) (wkTerm ρ ⊢Δ e) (wkTerm ρ ⊢Δ t) wkRedTerm ρ ⊢Δ (cast-ℕ-subst B e t) = cast-ℕ-subst (wkRedTerm ρ ⊢Δ B) (wkTerm ρ ⊢Δ e) (wkTerm ρ ⊢Δ t) wkRedTerm ρ ⊢Δ (cast-Π-subst A P B e t) = let ρA = wkTerm ρ ⊢Δ A in cast-Π-subst ρA (wkTerm (lift ρ) (⊢Δ ∙ (univ ρA)) P) (wkRedTerm ρ ⊢Δ B) (wkTerm ρ ⊢Δ e) (wkTerm ρ ⊢Δ t) wkRedTerm {Δ = Δ} {ρ = ρ} [ρ] ⊢Δ (cast-Π {A = A} {A' = A'} {rA = rA} {B = B} {B' = B'} {e = e} {f = f} Aⱼ Bⱼ A'ⱼ B'ⱼ eⱼ fⱼ) = let l = ⁰ in let lA = ⁰ in let lB = ⁰ in let ρA = wkTerm [ρ] ⊢Δ Aⱼ in let ρA' = wkTerm [ρ] ⊢Δ A'ⱼ in let ρB = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA)) Bⱼ in let ρB' = wkTerm (lift [ρ]) (⊢Δ ∙ (univ ρA')) B'ⱼ in let ρe = wkTerm [ρ] ⊢Δ eⱼ in let ρf = wkTerm [ρ] ⊢Δ fⱼ in let pred = λ A1 A1' e1 f1 → Δ ⊢ U.wk ρ (cast l (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) e f) ⇒ (lam (U.wk ρ A') ▹ (let a = cast l A1' A1 (Idsym (Univ rA l) A1 A1' (fst e1)) (var 0) in cast l ((U.wk (lift ρ) B) [ a ]↑) (U.wk (lift ρ) B') ((snd e1) ∘ (var 0) ^ ¹) (f1 ∘ a ^ l)) ^ l) ∷ U.wk ρ (Π A' ^ rA ° lA ▹ B' ° lB ° l) ^ _ in let j0 : pred (wk1 (U.wk ρ A)) (wk1 (U.wk ρ A')) (wk1 (U.wk ρ e)) (wk1 (U.wk ρ f)) j0 = cast-Π ρA ρB ρA' ρB' ρe ρf in let j1 = PE.subst (λ x → pred x (wk1 (U.wk ρ A')) (wk1 (U.wk ρ e)) (wk1 (U.wk ρ f))) (wk1-wk≡lift-wk1 ρ A) j0 in let j2 = PE.subst (λ x → pred (U.wk (lift ρ) (wk1 A)) x (wk1 (U.wk ρ e)) (wk1 (U.wk ρ f))) (wk1-wk≡lift-wk1 ρ A') j1 in let j3 = PE.subst (λ x → pred (U.wk (lift ρ) (wk1 A)) (U.wk (lift ρ) (wk1 A')) x (wk1 (U.wk ρ f))) (wk1-wk≡lift-wk1 ρ e) j2 in let j4 = PE.subst (λ x → pred (U.wk (lift ρ) (wk1 A)) (U.wk (lift ρ) (wk1 A')) (U.wk (lift ρ) (wk1 e)) x) (wk1-wk≡lift-wk1 ρ f) j3 in let j5 = PE.subst (λ x → Δ ⊢ U.wk ρ (cast l (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) e f) ⇒ (lam (U.wk ρ A') ▹ (let a = cast l (U.wk (lift ρ) (wk1 A')) (U.wk (lift ρ) (wk1 A)) x (var 0) in cast l ((U.wk (lift ρ) B) [ a ]↑) (U.wk (lift ρ) B') ((snd (U.wk (lift ρ) (wk1 e))) ∘ (var 0) ^ ¹) ((U.wk (lift ρ) (wk1 f)) ∘ a ^ l)) ^ l) ∷ U.wk ρ (Π A' ^ rA ° lA ▹ B' ° lB ° l) ^ ι l) (PE.sym (wk-Idsym (lift ρ) (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e)))) j4 in PE.subst (λ x → Δ ⊢ U.wk ρ (cast l (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) e f) ⇒ (lam (U.wk ρ A') ▹ (let a = U.wk (lift ρ) (cast l (wk1 A') (wk1 A) (Idsym (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0)) in cast l x (U.wk (lift ρ) B') ((snd (U.wk (lift ρ) (wk1 e))) ∘ (var 0) ^ ¹) ((U.wk (lift ρ) (wk1 f)) ∘ a ^ l)) ^ l) ∷ U.wk ρ (Π A' ^ rA ° lA ▹ B' ° lB ° l) ^ ι l) (PE.sym (wk-β↑ {ρ = ρ} {a = (cast l (wk1 A') (wk1 A) (Idsym (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0))} B)) j5 wkRedTerm ρ ⊢Δ (cast-ℕ-0 e) = cast-ℕ-0 (wkTerm ρ ⊢Δ e) wkRedTerm ρ ⊢Δ (cast-ℕ-S e n) = cast-ℕ-S (wkTerm ρ ⊢Δ e) (wkTerm ρ ⊢Δ n) wkRedTerm ρ ⊢Δ (cast-ℕ-cong e n) = cast-ℕ-cong (wkTerm ρ ⊢Δ e) (wkRedTerm ρ ⊢Δ n) wkRed* : ∀ {Γ Δ A B r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρB = U.wk ρ B in ⊢ Δ → Γ ⊢ A ⇒* B ^ r → Δ ⊢ ρA ⇒* ρB ^ r wkRed* ρ ⊢Δ (id A) = id (wk ρ ⊢Δ A) wkRed* ρ ⊢Δ (A⇒A′ ⇨ A′⇒*B) = wkRed ρ ⊢Δ A⇒A′ ⇨ wkRed* ρ ⊢Δ A′⇒*B wkRed*Term : ∀ {Γ Δ A l t u ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρt = U.wk ρ t ρu = U.wk ρ u in ⊢ Δ → Γ ⊢ t ⇒* u ∷ A ^ l → Δ ⊢ ρt ⇒* ρu ∷ ρA ^ l wkRed*Term ρ ⊢Δ (id t) = id (wkTerm ρ ⊢Δ t) wkRed*Term ρ ⊢Δ (t⇒t′ ⇨ t′⇒*u) = wkRedTerm ρ ⊢Δ t⇒t′ ⇨ wkRed*Term ρ ⊢Δ t′⇒*u wkRed:*: : ∀ {Γ Δ A B r ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρB = U.wk ρ B in ⊢ Δ → Γ ⊢ A :⇒*: B ^ r → Δ ⊢ ρA :⇒*: ρB ^ r wkRed:*: ρ ⊢Δ [[ ⊢A , ⊢B , D ]] = [[ wk ρ ⊢Δ ⊢A , wk ρ ⊢Δ ⊢B , wkRed* ρ ⊢Δ D ]] wkRed:*:Term : ∀ {Γ Δ A l t u ρ} → ρ ∷ Δ ⊆ Γ → let ρA = U.wk ρ A ρt = U.wk ρ t ρu = U.wk ρ u in ⊢ Δ → Γ ⊢ t :⇒*: u ∷ A ^ l → Δ ⊢ ρt :⇒*: ρu ∷ ρA ^ l wkRed:*:Term ρ ⊢Δ [[ ⊢t , ⊢u , d ]] = [[ wkTerm ρ ⊢Δ ⊢t , wkTerm ρ ⊢Δ ⊢u , wkRed*Term ρ ⊢Δ d ]]
{ "alphanum_fraction": 0.424544517, "avg_line_length": 63.5152838428, "ext": "agda", "hexsha": "57fbc059fb8dd56fc39c273f8dd89d264fed30e5", "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/Typed/Weakening.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/Typed/Weakening.agda", "max_line_length": 525, "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/Typed/Weakening.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": 16119, "size": 29090 }
{-# OPTIONS --safe #-} module Tools.Function where -- Identity function idᶠ : {A : Set} → A → A idᶠ x = x -- Function composition (simply typed variant) _∘ᶠ_ : {A B C : Set} → (B → C) → (A → B) → A → C _∘ᶠ_ f g a = f (g a)
{ "alphanum_fraction": 0.5575221239, "avg_line_length": 18.8333333333, "ext": "agda", "hexsha": "9dfab7e81d19e85e0b8206bf12eac511ace7d9b1", "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": "Tools/Function.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": "Tools/Function.agda", "max_line_length": 48, "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": "Tools/Function.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": 94, "size": 226 }
{-# OPTIONS --without-K --safe #-} module Function.Reasoning where open import Level infixr 2 _⟨⟩⇒_ ⟨∙⟩⇒-syntax ⟨∙⟩⇒-syntax : ∀ (A : Type a) → (B → C) → (A → B) → A → C ⟨∙⟩⇒-syntax _ f g x = f (g x) syntax ⟨∙⟩⇒-syntax A f g = A ⟨ g ⟩⇒ f _⟨⟩⇒_ : ∀ (A : Type a) → (A → B) → A → B _ ⟨⟩⇒ f = f infix 2.5 _⇒∎ _⇒∎ : (A : Type a) → A → A _⇒∎ _ x = x infixr 1.5 [_]⇒_ [_]⇒_ : A → (A → B) → B [ x ]⇒ f = f x -- infix 2.5 _⇒[_] -- _⇒[_] : (A : Type a) → A → A -- _ ⇒[ x ] = x
{ "alphanum_fraction": 0.4294736842, "avg_line_length": 16.9642857143, "ext": "agda", "hexsha": "22d694b9633a3da5a503439f497916890553fbb2", "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": "Function/Reasoning.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": "Function/Reasoning.agda", "max_line_length": 56, "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": "Function/Reasoning.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": 281, "size": 475 }
-- Andreas, 2016-04-13 display forms do not work for projection patterns -- {-# OPTIONS -v tc.display:100 #-} postulate B : Set module M (A : Set) where record R : Set where field f : A open M B test : R test = {!!} -- C-c C-c RET split on result here -- Is: -- M.R.f test = ? -- -- Expected: -- R.f test = ?
{ "alphanum_fraction": 0.5882352941, "avg_line_length": 15.380952381, "ext": "agda", "hexsha": "8dda439865dc543616bb7588fa351f381debd323", "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/Issue1932.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/Issue1932.agda", "max_line_length": 72, "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/Issue1932.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": 103, "size": 323 }
module Arithmetic where data ℕ : Set where zero : ℕ succ : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + b = b (succ a) + b = succ (a + b) -- ℕ + ℕ = succ (succ ℕ)) _*_ : ℕ → ℕ → ℕ zero * b = zero (succ a) * b = a + b * a
{ "alphanum_fraction": 0.4180327869, "avg_line_length": 15.25, "ext": "agda", "hexsha": "66edb106b94b242fd862048d46a5e50abf479e1c", "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": "cf10911d8f8c4dcc0ced16f39f7f8d4588bd84ff", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "haskellcamargo/agda-arithmetic-operations", "max_forks_repo_path": "Arithmetic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cf10911d8f8c4dcc0ced16f39f7f8d4588bd84ff", "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": "haskellcamargo/agda-arithmetic-operations", "max_issues_repo_path": "Arithmetic.agda", "max_line_length": 29, "max_stars_count": null, "max_stars_repo_head_hexsha": "cf10911d8f8c4dcc0ced16f39f7f8d4588bd84ff", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "haskellcamargo/agda-arithmetic-operations", "max_stars_repo_path": "Arithmetic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 100, "size": 244 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.CofiberSequence open import cohomology.Exactness open import cohomology.FunctionOver open import cohomology.Theory open import cohomology.ProductRepr open import cohomology.WedgeCofiber {- Finite additivity is provable (and in a stronger form) without using - the additivity axiom. We have Cⁿ(X ∨ Y) == Cⁿ(X) × Cⁿ(Y) - and over this path - ∙ Cⁿ(winl) corresponds to fst : Cⁿ(X) × Cⁿ(Y) → Cⁿ(X), - ∙ Cⁿ(winr) corresponds to snd : Cⁿ(X) × Cⁿ(Y) → Cⁿ(Y), - ∙ Cⁿ(Wedge-rec winl* winr* wglue*) : Cⁿ(Z) → Cⁿ(X ∨ Y) corresponds to Cⁿ(winl*) × Cⁿ(winr*). - ∙ Cⁿ(f) : Cⁿ(X ∨ Y) → Cⁿ(Z) corresponds to Cⁿ(projl ∘ f) + Cⁿ(projr ∘ f) : Cⁿ(X) × Cⁿ(Y) → Cⁿ(Z) -} module cohomology.Wedge {i} (CT : CohomologyTheory i) where module CWedge (n : ℤ) (X Y : Ptd i) where open WedgeCofiber X Y open CohomologyTheory CT open import cohomology.Functor CT private βl : CF-hom n ⊙winl ∘ᴳ CF-hom n (⊙projl X Y) == idhom _ βl = ! (CF-comp n (⊙projl X Y) ⊙winl) ∙ CF-ident n βr : CF-hom n ⊙winr ∘ᴳ CF-hom n (⊙projr X Y) == idhom _ βr = ! (CF-comp n (⊙projr X Y) ⊙winr) ∙ ap (CF-hom n) ⊙projr-winr ∙ CF-ident n where ⊙projr-winr : ⊙projr X Y ⊙∘ ⊙winr == ⊙idf _ ⊙projr-winr = ⊙λ= (λ _ → idp) $ ∙-unit-r _ ∙ ap-! (projr X Y) wglue ∙ ap ! (Projr.glue-β X Y) open ProductRepr (CF-hom n (⊙projl X Y)) (CF-hom n (⊙projr X Y)) (CF-hom n ⊙winl) (CF-hom n ⊙winr) (app= (ap GroupHom.f βl)) (app= (ap GroupHom.f βr)) (transport (λ {(_ , g) → is-exact (CF-hom n g) (CF-hom n ⊙winr)}) (pair= CofWinr.⊙path CofWinr.cfcod-over) (C-exact n ⊙winr)) (transport (λ {(_ , g) → is-exact (CF-hom n g) (CF-hom n ⊙winl)}) (pair= CofWinl.⊙path CofWinl.cfcod-over) (C-exact n ⊙winl)) public ⊙wedge-rec-over : {Z : Ptd i} (winl* : fst (X ⊙→ Z)) (winr* : fst (Y ⊙→ Z)) → CF-hom n (⊙wedge-rec winl* winr*) == ×ᴳ-hom-in (CF-hom n winl*) (CF-hom n (winr*)) [ (λ K → C n Z →ᴳ K) ↓ path ] ⊙wedge-rec-over winl* winr* = codomain-over-iso $ codomain-over-equiv (CF n R.⊙f) _ ▹ ap2 (λ f g z → (f z , g z)) (ap GroupHom.f $ ! (CF-comp n R.⊙f ⊙winl) ∙ ap (CF-hom n) R.⊙winl-β) (ap GroupHom.f $ ! (CF-comp n R.⊙f ⊙winr) ∙ ap (CF-hom n) R.⊙winr-β) where module R = ⊙WedgeRec winl* winr* wedge-hom-η : {Z : Ptd i} (φ : C n (⊙Wedge X Y) →ᴳ C n Z) → φ == ×ᴳ-sum-hom (C-abelian n _) (φ ∘ᴳ CF-hom n (⊙projl X Y)) (φ ∘ᴳ CF-hom n (⊙projr X Y)) [ (λ G → G →ᴳ C n Z) ↓ path ] wedge-hom-η φ = lemma (C-abelian n _) (C-abelian n _) inl-over inr-over where lemma : {G H K L : Group i} (aG : is-abelian G) (aL : is-abelian L) {p : G == H ×ᴳ K} {φ : H →ᴳ G} {ψ : K →ᴳ G} {χ : G →ᴳ L} → φ == ×ᴳ-inl [ (λ J → H →ᴳ J) ↓ p ] → ψ == ×ᴳ-inr {G = H} [ (λ J → K →ᴳ J) ↓ p ] → χ == ×ᴳ-sum-hom aL (χ ∘ᴳ φ) (χ ∘ᴳ ψ) [ (λ J → J →ᴳ L) ↓ p ] lemma {H = H} {K = K} aG aL {p = idp} {χ = χ} idp idp = ap (λ α → χ ∘ᴳ α) (×ᴳ-sum-hom-η H K aG) ∙ ! (∘-×ᴳ-sum-hom aG aL χ (×ᴳ-inl {G = H}) (×ᴳ-inr {G = H})) wedge-in-over : {Z : Ptd i} (f : fst (Z ⊙→ ⊙Wedge X Y)) → CF-hom n f == ×ᴳ-sum-hom (C-abelian n _) (CF-hom n (⊙projl X Y ⊙∘ f)) (CF-hom n (⊙projr X Y ⊙∘ f)) [ (λ G → G →ᴳ C n Z) ↓ path ] wedge-in-over f = wedge-hom-η (CF-hom n f) ▹ ap2 (×ᴳ-sum-hom (C-abelian n _)) (! (CF-comp n (⊙projl X Y) f)) (! (CF-comp n (⊙projr X Y) f))
{ "alphanum_fraction": 0.5097931034, "avg_line_length": 36.25, "ext": "agda", "hexsha": "08e2081441ad0f0ec27cee924f5b5715f6a6507d", "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": "cohomology/Wedge.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": "cohomology/Wedge.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "cohomology/Wedge.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": 1695, "size": 3625 }
module Model where open import Data.Product open import Data.Char open import Data.String open import Data.Container.Indexed open import IO.Primitive open import Signature postulate Model : Set initialModel : Model moveModel : Dir → Model → Model setMode : Mode → Model → Model getPrompt : Model → Prompt addCharToBuffer : Char → Model → Model getBuffer : Model → String setCurrentFeed : Model → Feed → Model getCurrentFeedsUrl : Model → String searchModel : String → Model → Model searchNextModel : String → Model → Model addFeedToModel : String → Model → Model cmdToResp : ∀ {m} (c : Command Hårss m) → Model → IO (Response Hårss c) cmdToResp (moveP d) m = return _ cmdToResp (promptP p) m = return _ cmdToResp (putCharP c) m = return _ cmdToResp doneP m = return (getBuffer m , getPrompt m) cmdToResp fetchP m = fetchUrl (getCurrentFeedsUrl m) where postulate fetchUrl : String → IO Feed cmdToResp searchNextP m = return (getBuffer m)
{ "alphanum_fraction": 0.6704438149, "avg_line_length": 29.4166666667, "ext": "agda", "hexsha": "f4277cc5748cfd9d29fcb739fd8725eded80171c", "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": "f767dbfbd82ce667b7cea667c4da76fe97f761eb", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "stevana/haarss", "max_forks_repo_path": "prototype/command-response/Model.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f767dbfbd82ce667b7cea667c4da76fe97f761eb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "stevana/haarss", "max_issues_repo_path": "prototype/command-response/Model.agda", "max_line_length": 71, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f767dbfbd82ce667b7cea667c4da76fe97f761eb", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "stevana/haarss", "max_stars_repo_path": "prototype/command-response/Model.agda", "max_stars_repo_stars_event_max_datetime": "2015-07-30T11:43:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T11:43:26.000Z", "num_tokens": 294, "size": 1059 }
{-# OPTIONS --without-K #-} module sets.fin where open import sets.fin.core public -- open import sets.fin.properties public -- open import sets.fin.ordering public -- open import sets.fin.universe public
{ "alphanum_fraction": 0.7487922705, "avg_line_length": 25.875, "ext": "agda", "hexsha": "790de06042bc84d867372a66db4d99d206989249", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "sets/fin.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "sets/fin.agda", "max_line_length": 41, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "sets/fin.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 45, "size": 207 }
import Lvl open import Structure.Category open import Structure.Setoid open import Type -- TODO: Deprecate this file and use Relator.Equals.Category instead module Structure.Category.Morphism.IdTransport where import Functional.Dependent as Fn import Function.Equals open Function.Equals.Dependent open import Logic open import Logic.Propositional open import Logic.Predicate open import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_) open import Relator.Equals.Proofs import Structure.Categorical.Names as Names open import Structure.Category.Functor open import Structure.Categorical.Properties open import Structure.Function open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Syntax.Transitivity module _ {ℓₒ ℓₘ ℓₑ : Lvl.Level} (cat : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}) where open CategoryObject(cat) open Category(category) using (_∘_ ; id ; identityₗ ; identityᵣ) open Category.ArrowNotation(category) open Morphism.OperModule ⦃ morphism-equiv ⦄ (\{x} → _∘_ {x}) open Morphism.IdModule ⦃ morphism-equiv ⦄ (\{x} → _∘_ {x})(id) private variable a b c : Object -- Essentially the identity morphism masquerading as a morphism between two arbitrary but identical objects. transport : (a ≡ₑ b) → (a ⟶ b) transport = sub₂(_≡ₑ_)(_⟶_) ⦃ [≡]-sub-of-reflexive ⦃ intro id ⦄ ⦄ transport-function : Function ⦃ [≡]-equiv ⦄ ⦃ morphism-equiv ⦄ (transport {a = a}{b = b}) Function.congruence transport-function xy = sub₂(_≡ₑ_)(_≡_) ⦃ [≡]-sub-of-reflexive ⦃ Equiv.reflexivity(morphism-equiv) ⦄ ⦄ ([≡]-with(transport) xy) transport-of-reflexivity : (transport(reflexivity(_≡ₑ_)) ≡ id{a}) transport-of-reflexivity = reflexivity(_≡_) ⦃ Equiv.reflexivity morphism-equiv ⦄ -- transport-of-symmetry : ∀{ab : (a ≡ₑ b)}{ba : (b ≡ₑ a)} → (transitivity(_≡ₑ_) ab ba ≡ reflexivity(_≡ₑ_)) → (transport(symmetry(_≡ₑ_) ab) ≡ transport ba) transport-of-transitivity : ∀{ab : (a ≡ₑ b)}{bc : (b ≡ₑ c)} → (transport(transitivity(_≡ₑ_) ab bc) ≡ transport(bc) ∘ transport(ab)) transport-of-transitivity {ab = [≡]-intro} {bc = [≡]-intro} = symmetry(_≡_) ⦃ Equiv.symmetry morphism-equiv ⦄ (Morphism.identityₗ(_∘_)(id)) [∘]-on-transport-inverseₗ : ∀{ab : (a ≡ₑ b)} → ((transport (symmetry(_≡ₑ_) ab)) ∘ (transport ab) ≡ id) [∘]-on-transport-inverseₗ {ab = [≡]-intro} = Morphism.identityₗ(_∘_)(id) instance transport-inverseₗ : ∀{ab : (a ≡ₑ b)} → Inverseₗ(transport ab) (transport(symmetry(_≡ₑ_) ab)) transport-inverseₗ {ab = ab} = Morphism.intro ([∘]-on-transport-inverseₗ {ab = ab}) [∘]-on-transport-inverseᵣ : ∀{ab : (a ≡ₑ b)} → ((transport ab) ∘ (transport (symmetry(_≡ₑ_) ab)) ≡ id) [∘]-on-transport-inverseᵣ {ab = [≡]-intro} = Morphism.identityᵣ(_∘_)(id) instance transport-inverseᵣ : ∀{ab : (a ≡ₑ b)} → Inverseᵣ(transport ab) (transport(symmetry(_≡ₑ_) ab)) transport-inverseᵣ {ab = ab} = Morphism.intro ([∘]-on-transport-inverseᵣ {ab = ab}) instance transport-isomorphism : ∀{ab : (a ≡ₑ b)} → Isomorphism(transport ab) transport-isomorphism {ab = ab} = [∃]-intro (transport(symmetry(_≡_) ab)) ⦃ [∧]-intro (transport-inverseₗ {ab = ab}) (transport-inverseᵣ {ab = ab}) ⦄ transport-congruence-symmetry-involution : ∀{ab : (a ≡ₑ b)} → ((transport Fn.∘ symmetry(_≡ₑ_) Fn.∘ symmetry(_≡ₑ_)) ab ≡ transport ab) transport-congruence-symmetry-involution {ab = [≡]-intro} = reflexivity(_≡_) ⦃ Equiv.reflexivity morphism-equiv ⦄ module _ {ℓₒₗ ℓₘₗ ℓₑₗ ℓₒᵣ ℓₘᵣ ℓₑᵣ : Lvl.Level} {catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ}} {catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ}} where open CategoryObject open Category using (_∘_ ; id ; identityₗ ; identityᵣ) open Category.ArrowNotation private open module Equivᵣ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv(catᵣ){x}{y} ⦄) using () transport-of-congruenced-functor : (([∃]-intro F ⦃ intro map ⦄) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ) → ∀{a b : Object(catₗ)}{ab : (a ≡ₑ b)} → (transport(catᵣ)(congruence₁ F ab) ≡ map(transport(catₗ)(ab))) transport-of-congruenced-functor ([∃]-intro F functor@⦃ intro map ⦄) {ab = [≡]-intro} = transport catᵣ (congruence₁ F [≡]-intro) 🝖[ _≡_ ]-[] transport catᵣ [≡]-intro 🝖[ _≡_ ]-[] id(category(catᵣ)) 🝖[ _≡_ ]-[ Functor.id-preserving functor ]-sym map(id(category(catₗ))) 🝖[ _≡_ ]-[] map(transport catₗ [≡]-intro) 🝖-end -- transport-of-congruenced-bifunctor : ∀{ab : (a ≡ₑ b)}{[∃]-intro F : Bifunctor} → (F(transport(ab)(cd)) ≡ transport(congruence₂ F ab cd))
{ "alphanum_fraction": 0.6650570676, "avg_line_length": 47.9578947368, "ext": "agda", "hexsha": "f5d3ee566a64066a123dffc61601f67b34135300", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Category/Morphism/IdTransport.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Category/Morphism/IdTransport.agda", "max_line_length": 191, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Category/Morphism/IdTransport.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": 1732, "size": 4556 }
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Bool open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite module _ where data Unit : Set where unit : Unit sym : {A : Set} {x y : A} → x ≡ y → y ≡ x sym refl = refl subst : {A : Set} (P : A → Set) {x y : A} → x ≡ y → P x → P y subst P refl p = p module _ (p : false ≡ true) where block : {A : Set} → Unit → A → A block unit x = x r : ∀ u → block u false ≡ true r unit = p {-# REWRITE r #-} r′ : ∀ u → block u false ≡ true r′ u = refl lazy : false ≡ true lazy = r′ unit T : Bool → Set T true = Bool T false = Bool → Bool module _ (p : false ≡ true) where bool : (Bool → Bool) → Bool bool = subst T (lazy p) fun : Bool → (Bool → Bool) fun = subst T (sym (lazy p)) omega : Bool → Bool omega = λ x → fun x x loop : Bool loop = omega (bool omega) -- omega = λ p x → x x -- loop = λ p → <BLACKHOLE>
{ "alphanum_fraction": 0.5652173913, "avg_line_length": 17.462962963, "ext": "agda", "hexsha": "08be2c4e8fba3db09a48efca453ba7d6d8004ec8", "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/Issue1445-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/Issue1445-2.agda", "max_line_length": 61, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1445-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": 341, "size": 943 }
module Lemmachine.Default.Proofs where open import Lemmachine import Lemmachine.Default import Lemmachine.Lemmas open import Lemmachine.Default.Lemmas open Lemmachine.Lemmas Lemmachine.Default.resource open import Relation.Binary.PropositionalEquality open import Data.Empty open import Data.Maybe open import Data.Product hiding (map) open import Data.Function using (const) open import Data.List.Any methodNotAllowed : ∀ r → method r ∉ allowedMethods r → resolveStatus r ≡ MethodNotAllowed methodNotAllowed r p with methodAlwaysKnown r | methodIsntAllowed r p ... | p₂ | p₃ rewrite p₂ | p₃ = refl optionsOK : ∀ r → method r ∈ allowedMethods r → method r ≡ OPTIONS → resolveStatus r ≡ OK optionsOK r p p₂ with methodAlwaysKnown r | methodIsAllowed r p ... | p₃ | p₄ rewrite p₃ | p₄ | p₂ = refl
{ "alphanum_fraction": 0.7327080891, "avg_line_length": 35.5416666667, "ext": "agda", "hexsha": "15e7acb5cd310c8620f882f8ed350ea29b599101", "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": "src/Lemmachine/Default/Proofs.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": "src/Lemmachine/Default/Proofs.agda", "max_line_length": 69, "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": "src/Lemmachine/Default/Proofs.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": 217, "size": 853 }
open import Common.Prelude ⟨_⟩_ : Bool → Bool → Bool ⟨ _ ⟩_ = λ b → b
{ "alphanum_fraction": 0.5915492958, "avg_line_length": 14.2, "ext": "agda", "hexsha": "5e3a2aa49ae0ca7bd705722c9d6214f6d34fdfb6", "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/Sections-9.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/Sections-9.agda", "max_line_length": 26, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Sections-9.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": 30, "size": 71 }
-- Andreas, 2017-12-16, issue #2870 -- Nicer error for non-printable character in lexer. postulate beforeHyphen­afterHyphen : Set -- Expected something like: -- Lexical error (unprintable character)
{ "alphanum_fraction": 0.7536945813, "avg_line_length": 22.5555555556, "ext": "agda", "hexsha": "154be524646f9cf7fc2cd2ef61fc73e560c0f575", "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/Issue2870.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/Issue2870.agda", "max_line_length": 52, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue2870.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": 57, "size": 203 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Setoids.Setoids open import Rings.Definition open import Sets.EquivalenceRelations open import Rings.IntegralDomains.Definition module Rings.Primes.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where open import Rings.Divisible.Definition R open import Rings.IntegralDomains.Lemmas intDom open import Rings.Ideals.Definition R open import Rings.Primes.Definition intDom open import Rings.Ideals.Prime.Definition {R = R} open import Rings.Irreducibles.Definition intDom open Ring R open Setoid S open Equivalence eq primeImpliesPrimeIdeal : {a : A} → Prime a → PrimeIdeal (generatedIdeal a) primeImpliesPrimeIdeal {a} record { isPrime = isPrime ; nonzero = nonzero ; nonunit = nonunit } = record { isPrime = λ {r} {s} → isPrime r s ; notContained = 1R ; notContainedIsNotContained = bad } where bad : a ∣ 1R → False bad (c , ac=1) = nonunit (c , ac=1) primeIdealImpliesPrime : {a : A} → ((a ∼ 0R) → False) → PrimeIdeal (generatedIdeal a) → Prime a Prime.isPrime (primeIdealImpliesPrime {a} a!=0 record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) r s a|rs aNot|r = isPrime a|rs aNot|r Prime.nonzero (primeIdealImpliesPrime {a} a!=0 record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) = a!=0 Prime.nonunit (primeIdealImpliesPrime {a} a!=0 record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) (c , ac=1) = notContainedIsNotContained ((c * notContained) , transitive *Associative (transitive (*WellDefined ac=1 reflexive) identIsIdent)) primeIsIrreducible : {a : A} → Prime a → Irreducible a Irreducible.nonzero (primeIsIrreducible {a} prime) = Prime.nonzero prime Irreducible.nonunit (primeIsIrreducible {a} prime) = Prime.nonunit prime Irreducible.irreducible (primeIsIrreducible {a} prime) x y xy=a xNonunit = underlying pr , yUnit where a|xy : a ∣ (x * y) a|xy = 1R , transitive *Commutative (transitive identIsIdent (symmetric xy=a)) a|yFalse : (a ∣ y) → False a|yFalse (c , ac=y) = xNonunit (c , transitive *Commutative t) where s : (a * (c * x)) ∼ a s = transitive *Associative (transitive (*WellDefined ac=y reflexive) (transitive *Commutative xy=a)) t : (c * x) ∼ 1R t = cancelIntDom {a} {c * x} {1R} (transitive s (symmetric (transitive *Commutative identIsIdent))) (Prime.nonzero prime) pr : Sg A (λ c → (a * c) ∼ x) pr = Prime.isPrime prime y x (divisibleWellDefined reflexive *Commutative a|xy) a|yFalse yUnit : (y * underlying pr) ∼ 1R yUnit with pr ... | c , ac=x = transitive *Commutative (cancelIntDom {a} {c * y} {1R} (transitive *Associative (transitive (*WellDefined ac=x reflexive) (transitive xy=a (symmetric (transitive *Commutative identIsIdent))))) (Prime.nonzero prime))
{ "alphanum_fraction": 0.7125532612, "avg_line_length": 58.6730769231, "ext": "agda", "hexsha": "8857d35f792bdf128eb0ed83fb908309d8f65ac2", "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/Primes/Lemmas.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Rings/Primes/Lemmas.agda", "max_line_length": 307, "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/Primes/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 957, "size": 3051 }
{-# OPTIONS --without-K --safe #-} open import Level open import Categories.Category open import Categories.Monad module Categories.Monad.Morphism {o ℓ e} {C D : Category o ℓ e} where open import Categories.NaturalTransformation open import Categories.Functor open NaturalTransformation -- monad morphism in the sense of the nLab -- https://ncatlab.org/nlab/show/monad#the_bicategory_of_monads -- between generic monads t : a -> a & s : b -> b record Monad⇒ (M : Monad C) (N : Monad D) : Set (o ⊔ ℓ ⊔ e) where private module M = Monad M module N = Monad N open module D = Category D using (_∘_; _≈_) field X : Functor C D α : NaturalTransformation (N.F ∘F X) (X ∘F M.F) module X = Functor X module α = NaturalTransformation α field unit-comp : ∀ {U} → α.η U ∘ (N.η.η (X.₀ U)) ≈ X.₁ (M.η.η U) mult-comp : ∀ {U} → α.η U ∘ (N.μ.η (X.₀ U)) ≈ X.₁ (M.μ.η U) ∘ α.η (M.F.₀ U) ∘ N.F.₁ (α.η U) -- monad morphism in a different sense: -- monads are on the same category, X is the identity record Monad⇒-id (M N : Monad C) : Set (o ⊔ ℓ ⊔ e) where private module M = Monad M module N = Monad N field α : NaturalTransformation N.F M.F module α = NaturalTransformation α open module C = Category C using (_∘_; _≈_) field unit-comp : ∀ {U} → α.η U ∘ N.η.η U ≈ M.η.η U mult-comp : ∀ {U} → α.η U ∘ (N.μ.η U) ≈ M.μ.η U ∘ α.η (M.F.₀ U) ∘ N.F.₁ (α.η U) -- monad 2-cell in the sense of https://ncatlab.org/nlab/show/monad#the_bicategory_of_monads record Monad²⇒ {M : Monad C} {N : Monad D} (Γ Δ : Monad⇒ M N) : Set (o ⊔ ℓ ⊔ e) where private module M = Monad M module N = Monad N module Γ = Monad⇒ Γ module Δ = Monad⇒ Δ field m : NaturalTransformation Γ.X Δ.X module m = NaturalTransformation m open module D = Category D using (_∘_; _≈_) field comm : ∀ {U} → Δ.α.η U ∘ N.F.₁ (m.η U) ≈ m.η (M.F.₀ U) ∘ Γ.α.η U
{ "alphanum_fraction": 0.6137316562, "avg_line_length": 26.5, "ext": "agda", "hexsha": "72bb06a9c6d30a0383dcfa8636db2d4717238724", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Monad/Morphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Monad/Morphism.agda", "max_line_length": 95, "max_stars_count": 5, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Monad/Morphism.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "num_tokens": 727, "size": 1908 }
module Issue679a where data ty : Set where _`→_ : ty → ty → ty ⟦_⟧ : ty → Set ⟦ A `→ B ⟧ = ⟦ A ⟧ → ⟦ B ⟧ eq : ∀ (σ : ty) (a b : ⟦ σ ⟧) → Set eq (A `→ B) f g = ∀ {a : ⟦ A ⟧} → eq B (f a) (g a) eq-sym : ∀ σ {f g} (h : eq σ f g) → eq σ g f eq-sym (A `→ B) h with B ... | B' = {!!}
{ "alphanum_fraction": 0.3908450704, "avg_line_length": 18.9333333333, "ext": "agda", "hexsha": "ae4bce086beeaf698e8cfb05e3508a9d3309a2ad", "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/Issue679a.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/Issue679a.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue679a.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": 151, "size": 284 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Coinductive vectors ------------------------------------------------------------------------ {-# OPTIONS --without-K --guardedness --sized-types #-} module Codata.Musical.Covec where open import Codata.Musical.Notation open import Codata.Musical.Conat as Coℕ using (Coℕ; zero; suc; _+_) open import Codata.Musical.Cofin using (Cofin; zero; suc) open import Codata.Musical.Colist as Colist using (Colist; []; _∷_) open import Data.Nat.Base using (ℕ; zero; suc) open import Data.Vec using (Vec; []; _∷_) open import Data.Product using (_,_) open import Function using (_∋_) open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- The type infixr 5 _∷_ data Covec {a} (A : Set a) : Coℕ → Set a where [] : Covec A zero _∷_ : ∀ {n} (x : A) (xs : ∞ (Covec A (♭ n))) → Covec A (suc n) module _ {a} {A : Set a} where ∷-injectiveˡ : ∀ {a b} {n} {as bs} → (Covec A (suc n) ∋ a ∷ as) ≡ b ∷ bs → a ≡ b ∷-injectiveˡ P.refl = P.refl ∷-injectiveʳ : ∀ {a b} {n} {as bs} → (Covec A (suc n) ∋ a ∷ as) ≡ b ∷ bs → as ≡ bs ∷-injectiveʳ P.refl = P.refl ------------------------------------------------------------------------ -- Some operations map : ∀ {a b} {A : Set a} {B : Set b} {n} → (A → B) → Covec A n → Covec B n map f [] = [] map f (x ∷ xs) = f x ∷ ♯ map f (♭ xs) module _ {a} {A : Set a} where fromVec : ∀ {n} → Vec A n → Covec A (Coℕ.fromℕ n) fromVec [] = [] fromVec (x ∷ xs) = x ∷ ♯ fromVec xs fromColist : (xs : Colist A) → Covec A (Colist.length xs) fromColist [] = [] fromColist (x ∷ xs) = x ∷ ♯ fromColist (♭ xs) take : ∀ m {n} → Covec A (m + n) → Covec A m take zero xs = [] take (suc n) (x ∷ xs) = x ∷ ♯ take (♭ n) (♭ xs) drop : ∀ m {n} → Covec A (Coℕ.fromℕ m + n) → Covec A n drop zero xs = xs drop (suc n) (x ∷ xs) = drop n (♭ xs) replicate : ∀ n → A → Covec A n replicate zero x = [] replicate (suc n) x = x ∷ ♯ replicate (♭ n) x lookup : ∀ {n} → Cofin n → Covec A n → A lookup zero (x ∷ xs) = x lookup (suc n) (x ∷ xs) = lookup n (♭ xs) infixr 5 _++_ _++_ : ∀ {m n} → Covec A m → Covec A n → Covec A (m + n) [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ ♯ (♭ xs ++ ys) [_] : A → Covec A (suc (♯ zero)) [ x ] = x ∷ ♯ [] ------------------------------------------------------------------------ -- Equality and other relations -- xs ≈ ys means that xs and ys are equal. infix 4 _≈_ data _≈_ : ∀ {n} (xs ys : Covec A n) → Set a where [] : [] ≈ [] _∷_ : ∀ {n} x {xs ys} (xs≈ : ∞ (♭ xs ≈ ♭ ys)) → _≈_ {n = suc n} (x ∷ xs) (x ∷ ys) -- x ∈ xs means that x is a member of xs. infix 4 _∈_ data _∈_ : ∀ {n} → A → Covec A n → Set a where here : ∀ {n x } {xs} → _∈_ {n = suc n} x (x ∷ xs) there : ∀ {n x y} {xs} (x∈xs : x ∈ ♭ xs) → _∈_ {n = suc n} x (y ∷ xs) -- xs ⊑ ys means that xs is a prefix of ys. infix 4 _⊑_ data _⊑_ : ∀ {m n} → Covec A m → Covec A n → Set a where [] : ∀ {n} {ys : Covec A n} → [] ⊑ ys _∷_ : ∀ {m n} x {xs ys} (p : ∞ (♭ xs ⊑ ♭ ys)) → _⊑_ {m = suc m} {suc n} (x ∷ xs) (x ∷ ys) ------------------------------------------------------------------------ -- Some proofs setoid : ∀ {a} → Set a → Coℕ → Setoid _ _ setoid A n = record { Carrier = Covec A n ; _≈_ = _≈_ ; isEquivalence = record { refl = refl ; sym = sym ; trans = trans } } where refl : ∀ {n} → Reflexive (_≈_ {n = n}) refl {x = []} = [] refl {x = x ∷ xs} = x ∷ ♯ refl sym : ∀ {n} → Symmetric (_≈_ {A = A} {n}) sym [] = [] sym (x ∷ xs≈) = x ∷ ♯ sym (♭ xs≈) trans : ∀ {n} → Transitive (_≈_ {A = A} {n}) trans [] [] = [] trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈) poset : ∀ {a} → Set a → Coℕ → Poset _ _ _ poset A n = record { Carrier = Covec A n ; _≈_ = _≈_ ; _≤_ = _⊑_ ; isPartialOrder = record { isPreorder = record { isEquivalence = Setoid.isEquivalence (setoid A n) ; reflexive = reflexive ; trans = trans } ; antisym = antisym } } where reflexive : ∀ {n} → _≈_ {n = n} ⇒ _⊑_ reflexive [] = [] reflexive (x ∷ xs≈) = x ∷ ♯ reflexive (♭ xs≈) trans : ∀ {n} → Transitive (_⊑_ {n = n}) trans [] _ = [] trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈) tail : ∀ {n x y xs ys} → _∷_ {n = n} x xs ⊑ _∷_ {n = n} y ys → ♭ xs ⊑ ♭ ys tail (_ ∷ p) = ♭ p antisym : ∀ {n} → Antisymmetric (_≈_ {n = n}) _⊑_ antisym [] [] = [] antisym (x ∷ p₁) p₂ = x ∷ ♯ antisym (♭ p₁) (tail p₂) map-cong : ∀ {a b} {A : Set a} {B : Set b} {n} (f : A → B) → _≈_ {n = n} =[ map f ]⇒ _≈_ map-cong f [] = [] map-cong f (x ∷ xs≈) = f x ∷ ♯ map-cong f (♭ xs≈) take-⊑ : ∀ {a} {A : Set a} m {n} (xs : Covec A (m + n)) → take m xs ⊑ xs take-⊑ zero xs = [] take-⊑ (suc n) (x ∷ xs) = x ∷ ♯ take-⊑ (♭ n) (♭ xs) ------------------------------------------------------------------------ -- Legacy import Codata.Covec as C open import Codata.Thunk import Size module _ {a} {A : Set a} where fromMusical : ∀ {i n} → Covec A n → C.Covec A i (Coℕ.fromMusical n) fromMusical [] = C.[] fromMusical (x ∷ xs) = x C.∷ λ where .force → fromMusical (♭ xs) toMusical : ∀ {n} → C.Covec A Size.∞ n → Covec A (Coℕ.toMusical n) toMusical C.[] = [] toMusical (x C.∷ xs) = x ∷ ♯ toMusical (xs .force)
{ "alphanum_fraction": 0.4438302425, "avg_line_length": 29.5157894737, "ext": "agda", "hexsha": "52efad9a42f317f46d66fe5a0b435b5702dc001b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/Musical/Covec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/Musical/Covec.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/Musical/Covec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2244, "size": 5608 }
open import FRP.JS.Behaviour using ( Beh ; map ; [_] ) open import FRP.JS.DOM using ( DOM ; text ; _++_ ) open import FRP.JS.RSet using ( ⟦_⟧ ) open import FRP.JS.Maybe using ( Maybe ; just ; nothing ) open import FRP.JS.String using ( String ) open import FRP.JS.Geolocation using ( geolocation ) open import FRP.JS.Geolocation.Coords using ( Coords ; toString ) module FRP.JS.Demo.Geolocation where show : Maybe Coords → String show nothing = "unknown" show (just coords) = toString coords main : ∀ {w} → ⟦ Beh (DOM w) ⟧ main = text ["Current location: "] ++ text (map show geolocation) ++ text ["."]
{ "alphanum_fraction": 0.6763754045, "avg_line_length": 32.5263157895, "ext": "agda", "hexsha": "19a8a25724487f2160f1a039e860666c860c1c68", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "demo/agda/FRP/JS/Demo/Geolocation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "demo/agda/FRP/JS/Demo/Geolocation.agda", "max_line_length": 65, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "demo/agda/FRP/JS/Demo/Geolocation.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 183, "size": 618 }
{-# OPTIONS --rewriting #-} module _ where open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite open import Agda.Builtin.Bool data D (A : Set) : Set where con : (a : A) → D A pr : ∀ {A} → D A → A pr (con a) = a postulate f : D Bool → Bool prf : pr ≡ f {-# REWRITE prf #-}
{ "alphanum_fraction": 0.6209150327, "avg_line_length": 16.1052631579, "ext": "agda", "hexsha": "40fe2ec31aebf646c551ad6ff106246e93ec6ec7", "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/Issue4994.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/Issue4994.agda", "max_line_length": 41, "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/Issue4994.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": 108, "size": 306 }
{- This file proves the monotonicity of potential function over reductions. CorrectBinding is required in order to guarantee that SI and SC introduced by the loop never accidentally capture signals in the loop body. canₖ-monotonic : ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ k → k ∈ Canₖ r' θ → k ∈ Canₖ r θ canₛ-monotonic : ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ S' → Signal.unwrap S' ∈ Canₛ r' θ → Signal.unwrap S' ∈ Canₛ r θ canₛₕ-monotonic : ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ s' → SharedVar.unwrap s' ∈ Canₛₕ r' θ → SharedVar.unwrap s' ∈ Canₛₕ r θ In addition to the main lemmas, there are various random small propositions dealing with the computatin of the calculation of Can in the loop body (the big ρ-θ-emit-present term introduced by the loop-unroll rule). -} module can-function-preserve where open import sn-calculus open import utility open import Esterel.Lang open import Esterel.Lang.Binding open import Esterel.Lang.Properties open import Esterel.Lang.CanFunction open import Esterel.Lang.CanFunction.Properties open import Esterel.Context using (EvaluationContext1 ; EvaluationContext ; _⟦_⟧e ; _≐_⟦_⟧e) open import Esterel.Context.Properties using (unplug ; Erefl) open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) 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 Data.Bool using (Bool ; true ; false ; if_then_else_) open import Data.Empty using (⊥ ; ⊥-elim) open import Data.List using (List ; [] ; _∷_ ; _++_ ; map ; concatMap ; foldr) open import Data.List.Any using (Any ; any ; here ; there) open import Data.List.Any.Properties using (++⁻) renaming (++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ) open import Data.Maybe using (Maybe ; just ; nothing) open import Data.Nat using (ℕ ; zero ; suc ; _≟_ ; _+_) open import Data.Product using (Σ ; proj₁ ; proj₂ ; ∃ ; _,_ ; _,′_ ; _×_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Function using (_∘_ ; _∋_ ; id) open import Relation.Nullary using (¬_ ; Dec ; yes ; no) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary.PropositionalEquality using (_≡_ ; _≢_ ; refl ; trans ; sym ; cong ; subst ; inspect ; Reveal_·_is_ ; [_] ; module ≡-Reasoning) open EvaluationContext1 open _≐_⟦_⟧e open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM open ListSet Data.Nat._≟_ using (set-subtract ; set-subtract-[] ; set-subtract-split ; set-subtract-merge ; set-subtract-notin ; set-subtract-[a]≡set-remove ; set-remove-mono-∈ ; set-remove-removed ; set-remove-not-removed) canₛ-present-lemma : ∀ S p q θ → ∀ S' → Signal.unwrap S' ∈ Canₛ (present S ∣⇒ p ∣⇒ q) θ → Signal.unwrap S' ∈ Canₛ p θ ⊎ Signal.unwrap S' ∈ Canₛ q θ canₛ-present-lemma S p q θ S' S'∈can-present with Env.Sig∈ S θ canₛ-present-lemma S p q θ S' S'∈can-present | yes S∈ with Env.sig-stats {S} θ S∈ ... | Signal.present = inj₁ S'∈can-present ... | Signal.absent = inj₂ S'∈can-present ... | Signal.unknown = ++⁻ (Canₛ p θ) S'∈can-present canₛ-present-lemma S p q θ S' S'∈can-present | no S∉ = ++⁻ (Canₛ p θ) S'∈can-present canₛₕ-present-lemma : ∀ S p q θ → Canₛₕ p θ ≡ [] → Canₛₕ q θ ≡ [] → Canₛₕ (present S ∣⇒ p ∣⇒ q) θ ≡ [] canₛₕ-present-lemma S p q θ can-p≡[] can-q≡[] with Env.Sig∈ S θ canₛₕ-present-lemma S p q θ can-p≡[] can-q≡[] | yes S∈ with Env.sig-stats {S} θ S∈ ... | Signal.present = can-p≡[] ... | Signal.absent = can-q≡[] ... | Signal.unknown rewrite can-p≡[] | can-q≡[] = refl canₛₕ-present-lemma S p q θ can-p≡[] can-q≡[] | no S∉ rewrite can-p≡[] | can-q≡[] = refl canₖ-monotonic : ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ k → k ∈ Canₖ r' θ → k ∈ Canₖ r θ canₛ-monotonic : ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ S' → Signal.unwrap S' ∈ Canₛ r' θ → Signal.unwrap S' ∈ Canₛ r θ canₛₕ-monotonic : ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ s' → SharedVar.unwrap s' ∈ Canₛₕ r' θ → SharedVar.unwrap s' ∈ Canₛₕ r θ canθₖ-monotonic : ∀ sigs S' → ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ k → k ∈ Canθₖ sigs S' r' θ → k ∈ Canθₖ sigs S' r θ canθₛ-monotonic : ∀ sigs S'' → ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ S' → Signal.unwrap S' ∈ Canθₛ sigs S'' r' θ → Signal.unwrap S' ∈ Canθₛ sigs S'' r θ canθₛₕ-monotonic : ∀ sigs S' → ∀ {BV FV} θ r r' → CorrectBinding r BV FV → r sn⟶₁ r' → ∀ s' → SharedVar.unwrap s' ∈ Canθₛₕ sigs S' r' θ → SharedVar.unwrap s' ∈ Canθₛₕ sigs S' r θ canθₖ-monotonic [] S' cb red = canₖ-monotonic cb red canθₖ-monotonic (nothing ∷ sigs) S' = canθₖ-monotonic sigs (suc S') canθₖ-monotonic (just Signal.present ∷ sigs) S' θ = canθₖ-monotonic sigs (suc S') (θ ← _) canθₖ-monotonic (just Signal.absent ∷ sigs) S' θ = canθₖ-monotonic sigs (suc S') (θ ← _) canθₖ-monotonic (just Signal.unknown ∷ sigs) S' θ r r' cb red with any (_≟_ S') (Canθₛ sigs (suc S') r (θ ← ([S]-env (S' ₛ)))) | any (_≟_ S') (Canθₛ sigs (suc S') r' (θ ← ([S]-env (S' ₛ)))) ... | yes S'∈Canr | yes S'∈Canr' = canθₖ-monotonic sigs (suc S') (θ ← [S]-env (S' ₛ)) r r' cb red ... | no S'∉Canr | no S'∉Canr' = canθₖ-monotonic sigs (suc S') (θ ← [S]-env-absent (S' ₛ)) r r' cb red ... | no S'∉Canr | yes S'∈Canr' = ⊥-elim (S'∉Canr (canθₛ-monotonic sigs (suc S') (θ ← [S]-env (S' ₛ)) r r' cb red (S' ₛ) S'∈Canr')) ... | yes S'∈Canr | no S'∉Canr' with (canθₖ-monotonic sigs (suc S') (θ ← [S]-env-absent (S' ₛ)) r r' cb red) ... | rec rewrite sym (Env.sig-set-clobber-single-as-← (S' ₛ) Signal.absent Signal.unknown θ (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ)) = λ k k∈ → canθₖ-set-sig-monotonic sigs (suc S') r (S' ₛ) (θ ← [S]-env (S' ₛ)) (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ) Signal.absent (Env.sig-stats-1map-right-← (S' ₛ) Signal.unknown θ (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ)) (n∉map-suc-n-+ S' (SigM.Dom' sigs)) k (rec k k∈) canθₛ-monotonic [] S' cb red = canₛ-monotonic cb red canθₛ-monotonic (nothing ∷ sigs) S' = canθₛ-monotonic sigs (suc S') canθₛ-monotonic (just Signal.present ∷ sigs) S' θ = canθₛ-monotonic sigs (suc S') (θ ← _) canθₛ-monotonic (just Signal.absent ∷ sigs) S' θ = canθₛ-monotonic sigs (suc S') (θ ← _) canθₛ-monotonic (just Signal.unknown ∷ sigs) S' θ r r' cb red with any (_≟_ S') (Canθₛ sigs (suc S') r (θ ← ([S]-env (S' ₛ)))) | any (_≟_ S') (Canθₛ sigs (suc S') r' (θ ← ([S]-env (S' ₛ)))) ... | yes S'∈Canr | yes S'∈Canr' = canθₛ-monotonic sigs (suc S') (θ ← [S]-env (S' ₛ)) r r' cb red ... | no S'∉Canr | no S'∉Canr' = canθₛ-monotonic sigs (suc S') (θ ← [S]-env-absent (S' ₛ)) r r' cb red ... | no S'∉Canr | yes S'∈Canr' = ⊥-elim (S'∉Canr (canθₛ-monotonic sigs (suc S') (θ ← [S]-env (S' ₛ)) r r' cb red (S' ₛ) S'∈Canr')) ... | yes S'∈Canr | no S'∉Canr' with (canθₛ-monotonic sigs (suc S') (θ ← [S]-env-absent (S' ₛ)) r r' cb red) ... | rec rewrite sym (Env.sig-set-clobber-single-as-← (S' ₛ) Signal.absent Signal.unknown θ (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ)) = λ k k∈ → canθₛ-set-sig-monotonic sigs (suc S') r (S' ₛ) (θ ← [S]-env (S' ₛ)) (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ) Signal.absent (Env.sig-stats-1map-right-← (S' ₛ) Signal.unknown θ (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ)) (n∉map-suc-n-+ S' (SigM.Dom' sigs)) (Signal.unwrap k) (rec k k∈) canθₛₕ-monotonic [] S' cb red = canₛₕ-monotonic cb red canθₛₕ-monotonic (nothing ∷ sigs) S' = canθₛₕ-monotonic sigs (suc S') canθₛₕ-monotonic (just Signal.present ∷ sigs) S' θ = canθₛₕ-monotonic sigs (suc S') (θ ← _) canθₛₕ-monotonic (just Signal.absent ∷ sigs) S' θ = canθₛₕ-monotonic sigs (suc S') (θ ← _) canθₛₕ-monotonic (just Signal.unknown ∷ sigs) S' θ r r' cb red with any (_≟_ S') (Canθₛ sigs (suc S') r (θ ← ([S]-env (S' ₛ)))) | any (_≟_ S') (Canθₛ sigs (suc S') r' (θ ← ([S]-env (S' ₛ)))) ... | yes S'∈Canr | yes S'∈Canr' = canθₛₕ-monotonic sigs (suc S') (θ ← [S]-env (S' ₛ)) r r' cb red ... | no S'∉Canr | no S'∉Canr' = canθₛₕ-monotonic sigs (suc S') (θ ← [S]-env-absent (S' ₛ)) r r' cb red ... | no S'∉Canr | yes S'∈Canr' = ⊥-elim (S'∉Canr (canθₛ-monotonic sigs (suc S') (θ ← [S]-env (S' ₛ)) r r' cb red (S' ₛ) S'∈Canr')) ... | yes S'∈Canr | no S'∉Canr' with (canθₛₕ-monotonic sigs (suc S') (θ ← [S]-env-absent (S' ₛ)) r r' cb red) ... | rec rewrite sym (Env.sig-set-clobber-single-as-← (S' ₛ) Signal.absent Signal.unknown θ (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ)) = λ k k∈ → canθₛₕ-set-sig-monotonic sigs (suc S') r (S' ₛ) (θ ← [S]-env (S' ₛ)) (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ) Signal.absent (Env.sig-stats-1map-right-← (S' ₛ) Signal.unknown θ (Env.sig-∈-single-right-← (S' ₛ) Signal.unknown θ)) (n∉map-suc-n-+ S' (SigM.Dom' sigs)) (SharedVar.unwrap k) (rec k k∈) canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-right hnothin q/done) k k∈can-r'-θ = any-map⁺² {xs = Code.nothin ∷ []} (λ k' → map (Code._⊔_ k') (Canₖ q θ)) (here refl) (any-map⁺ (Code._⊔_ Code.nothin) k∈can-r'-θ) canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-right (hexit n) (dhalted hnothin)) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-right (hexit n) (dhalted (hexit m))) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-right (hexit n) (dpaused q/paused)) k k∈can-r'-θ rewrite canₖ-paused θ q/paused = k∈can-r'-θ canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-left (dhalted hnothin) q/halted) k k∈can-r'-θ = any-map⁺² {xs = Code.nothin ∷ []} (λ k' → map (Code._⊔_ k') (Canₖ q θ)) (here refl) (any-map⁺ (Code._⊔_ Code.nothin) k∈can-r'-θ) canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-left (dhalted (hexit n)) hnothin) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-left (dhalted (hexit n)) (hexit m)) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-left (dpaused p/paused) hnothin) k k∈can-r'-θ rewrite canₖ-paused θ p/paused = k∈can-r'-θ canₖ-monotonic θ (p ∥ q) _ cb (rpar-done-left (dpaused p/paused) (hexit m)) k k∈can-r'-θ rewrite canₖ-paused θ p/paused = k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (ris-present {S = S} {p = p} {E = E} S∈ θ'S≡present r≐E⟦present⟧) k k∈can-r'-θ rewrite canθ-is-present (Env.sig θ') S∈ θ r≐E⟦present⟧ θ'S≡present = k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (ris-absent {S = S} S∈ θ'S≡absent r≐E⟦present⟧) k k∈can-r'-θ rewrite canθ-is-absent (Env.sig θ') S∈ θ r≐E⟦present⟧ θ'S≡absent = k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (remit {S = S} {E = E} S∈ θ'S≢absent r≐E⟦emit⟧) k k∈can-r'-θ = canθₖ-emit θ' S∈ θ r≐E⟦emit⟧ θ'S≢absent ((canθₛ-membership (Env.sig θ') 0 r θ S (λ θ* → canₛ-capture-emit-signal θ* r≐E⟦emit⟧))) k k∈can-r'-θ canₖ-monotonic θ (loop r) r' cb rloop-unroll k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ .(nothin >> r') r' cb rseq-done k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ .(exit _ >> _) .(exit _) cb rseq-exit k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ .(loopˢ (exit _) _) .(exit _) cb rloopˢ-exit k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (suspend r S) .r cb (rsuspend-done r/halted) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (trap r) .nothin cb (rtrap-done hnothin) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (trap r) .nothin cb (rtrap-done (hexit zero)) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (trap r) .(exit n) cb (rtrap-done (hexit (suc n))) k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (signl S r) r' cb rraise-signal k k∈can-r'-θ = k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rraise-shared {s = s} {e = e} {p = p} {E = E} e' r≐E⟦shared⟧) k k∈can-r'-θ rewrite sym (unplug r≐E⟦shared⟧) | sym (canθₖ-raise-lemma{A = WAIT} (Env.sig θ') 0 θ E (tshared (δ e') s e p)) = k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rset-shared-value-old {s = s} {e = e} {E = E} e' s∈ θ's≡old r≐E⟦s⇐e⟧) k k∈can-r'-θ rewrite canθ-shr-var-irr (Env.sig (Env.set-shr {s} θ' s∈ SharedVar.new (δ e'))) 0 r θ θ refl | sym (unplug r≐E⟦s⇐e⟧) = canθₖ-term-nothin-lemma (Env.sig (Env.set-shr {s} θ' s∈ SharedVar.new (δ e'))) 0 θ E (tset-shr s e) k k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rset-shared-value-new {s = s} {e = e} {E = E} e' s∈ θ's≡new r≐E⟦s⇐e⟧) k k∈can-r'-θ rewrite canθ-shr-var-irr (Env.sig (Env.set-shr {s} θ' s∈ SharedVar.new (Env.shr-vals {s} θ' s∈ + δ e'))) 0 r θ θ refl | sym (unplug r≐E⟦s⇐e⟧) = canθₖ-term-nothin-lemma (Env.sig (Env.set-shr {s} θ' s∈ SharedVar.new (Env.shr-vals {s} θ' s∈ + δ e'))) 0 θ E (tset-shr s e) k k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rraise-var {x = x} {p = p} {e = e} {E = E} e' r≐E⟦var⟧) k k∈can-r'-θ rewrite sym (unplug r≐E⟦var⟧) | (canθₖ-raise-lemma (Env.sig θ') 0 θ E (tvar (δ e') x e p)) = k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rset-var {x = x} {e = e} {E = E} x∈ e' r≐E⟦x≔e⟧) k k∈can-r'-θ rewrite canθ-shr-var-irr (Env.sig (Env.set-var {x} θ' x∈ (δ e'))) 0 r θ θ refl | sym (unplug r≐E⟦x≔e⟧) = canθₖ-term-nothin-lemma (Env.sig (Env.set-var {x} θ' x∈ (δ e'))) 0 θ E (tset-var x e) k k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rif-false {p = p} {q = q} {x = x} {E = E} x∈ θ'x≡zero r≐E⟦if⟧) k k∈can-r'-θ rewrite sym (unplug r≐E⟦if⟧) = canθₖ-if-false-lemma (Env.sig θ' ) 0 x p q θ E k k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rif-true {p = p} {q = q} {x = x} {E = E} x∈ θ'x≡suc r≐E⟦if⟧) k k∈can-r'-θ rewrite sym (unplug r≐E⟦if⟧) = canθₖ-if-true-lemma (Env.sig θ') 0 x p q θ E k k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rabsence {S = S} S∈ θ'S≡unknown S∉can-r-θ') k k∈can-r'-θ rewrite Env.sig-switch-right S Signal.absent θ θ' S∈ (Env.sig-←-monoʳ S θ' θ S∈) = canθₖ-set-sig-monotonic-absence-lemma (Env.sig θ') 0 r S θ S∈ θ'S≡unknown k k∈can-r'-θ where θ←θ' = θ ← θ' S∈Domθ←θ' = Env.sig-←-monoʳ S θ' θ S∈ ⟨θ←θ'⟩S≡θ'S = Env.sig-stats-←-right-irr' S θ θ' S∈ S∈Domθ←θ' canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (rreadyness {s = s} s∈ θ's≡old⊎θ's≡new s∉can-r-θ') k k∈can-r'-θ rewrite can-shr-var-irr r (θ ← θ') (θ ← Env.set-shr {s} θ' s∈ SharedVar.ready (Env.shr-vals {s} θ' s∈)) refl = k∈can-r'-θ canₖ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb@(CBρ cb') (rmerge {θ₁ = .θ'} {θ₂ = θ''} {p = rin} {E = E} r≐E⟦ρθ''·rin⟧) k k∈can-r'-θ = canθₖ-mergeˡ (Env.sig θ') θ cb' r≐E⟦ρθ''·rin⟧ k k∈can-r'-θ canₛ-monotonic θ (p ∥ q) _ cb (rpar-done-right p/halted q/done) S' S'∈can-r'-θ rewrite canₛ-done θ (value-max-done (dhalted p/halted) q/done (inj₁ p/halted)) with S'∈can-r'-θ ... | () canₛ-monotonic θ (p ∥ q) _ cb (rpar-done-left p/done q/halted) S' S'∈can-r'-θ rewrite canₛ-done θ (value-max-done p/done (dhalted q/halted) (inj₂ q/halted)) with S'∈can-r'-θ ... | () canₛ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (ris-present {S = S} S∈ θ'S≡present r≐E⟦present⟧) S' S'∈can-r'-θ rewrite canθ-is-present (Env.sig θ') S∈ θ r≐E⟦present⟧ θ'S≡present = S'∈can-r'-θ canₛ-monotonic θ (ρ⟨ θ' , A ⟩· r) r' cb (ris-absent {S = S} S∈ θ'S≡absent r≐E⟦absent⟧) S' S'∈can-r'-θ rewrite canθ-is-absent (Env.sig θ') S∈ θ r≐E⟦absent⟧ θ'S≡absent = S'∈can-r'-θ canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (remit {S = S} {E = E} S∈ θ'S≢absent r≐E⟦emit⟧) S' S'∈can-ρθ''·r'-θ with set-subtract-merge {xs = Canθₛ (Env.sig (Env.set-sig {S} θ' S∈ Signal.present)) 0 r' θ} {ys = proj₁ (Dom θ'')} S'∈can-ρθ''·r'-θ ... | S'∈can-r'-θ←θ'' , S'∉Domθ'' with set-subtract-split {ys = proj₁ (Dom θ')} (canθₛ-emit θ' S∈ θ r≐E⟦emit⟧ θ'S≢absent (canθₛ-membership (Env.sig θ') 0 r θ S (λ θ* → canₛ-capture-emit-signal θ* r≐E⟦emit⟧)) S' S'∈can-r'-θ←θ'') ... | inj₁ S'∈can-r-θ←θ'-θ' = S'∈can-r-θ←θ'-θ' ... | inj₂ S'∈Domθ' = ⊥-elim (S'∉Domθ'' (Env.sig-set-mono' {S'} {S} {θ'} {Signal.present} {S∈} S'∈Domθ')) canₛ-monotonic θ (loop r) r' cb rloop-unroll S' S'∈can-r'-θ = S'∈can-r'-θ canₛ-monotonic θ .(nothin >> r') r' cb rseq-done S' S'∈can-r'-θ = S'∈can-r'-θ canₛ-monotonic θ .(exit _ >> _) .(exit _) cb rseq-exit S' S'∈can-r'-θ = S'∈can-r'-θ canₛ-monotonic θ .(loopˢ (exit _) _) .(exit _) cb rloopˢ-exit S' S'∈can-r'-θ = S'∈can-r'-θ canₛ-monotonic θ (suspend r S) .r cb (rsuspend-done r/halted) S' S'∈can-r'-θ rewrite canₛ-done θ (dhalted r/halted) with S'∈can-r'-θ ... | () canₛ-monotonic θ (trap r) r' cb (rtrap-done r/halted) S' S'∈can-r'-θ rewrite canₛ-done θ (dhalted (↓-well-behaved _ r/halted)) with S'∈can-r'-θ ... | () canₛ-monotonic θ (signl S r) r' cb rraise-signal S' S'∈can-r'-θ rewrite SigMap.keys-1map S Signal.unknown | set-subtract-[a]≡set-remove (Canθₛ (Env.sig ([S]-env S)) 0 r θ) (Signal.unwrap S) = S'∈can-r'-θ canₛ-monotonic θ (ρ⟨ θ' , A ⟩· r) (ρ⟨ .θ' , .A ⟩· r') cb (rraise-shared {s = s} {e = e} {p = p} {E = E} e' r≐E⟦shared⟧) S' S'∈can-ρθ'·r'-θ rewrite sym (unplug r≐E⟦shared⟧) | sym (canθₛ-raise-lemma{A = WAIT} (Env.sig θ') 0 θ E (tshared (δ e') s e p)) = S'∈can-ρθ'·r'-θ canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (rset-shared-value-old{s = s}{e = e}{E = E} e' s∈ θ's≡old r≐E⟦s⇐e⟧) S' S'∈can-ρθ''·r'-θ with set-subtract-merge{xs = Canθₛ (Env.sig θ'') 0 r' θ}{ys = proj₁ (Dom θ'')} S'∈can-ρθ''·r'-θ ... | S'∈can-r'-θ←θ'' , S'∉Domθ'' with set-subtract-split {xs = Canθₛ (Env.sig θ') 0 r θ} {ys = proj₁ (Dom θ')} {z = Signal.unwrap S'} (subst (λ x → _ ∈ Canθₛ (Env.sig θ') 0 x θ) (unplug r≐E⟦s⇐e⟧) (canθₛ-term-nothin-lemma (Env.sig θ'') 0 θ E (tset-shr s e) (Signal.unwrap S') S'∈can-r'-θ←θ'' ) ) ... | inj₁ S'∈can-r-θ←θ'-θ' = S'∈can-r-θ←θ'-θ' -- θ' and θ'' differ only by shared var Dom ... | inj₂ S'∈Domθ' = ⊥-elim (S'∉Domθ'' S'∈Domθ') canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (rset-shared-value-new{s = s}{e = e}{E = E} e' s∈ θ's≡new r≐E⟦s⇐e⟧) S' S'∈can-ρθ''·r'-θ with set-subtract-merge{xs = Canθₛ (Env.sig θ'') 0 r' θ}{ys = proj₁ (Dom θ'')} S'∈can-ρθ''·r'-θ ... | S'∈can-r'-θ←θ'' , S'∉Domθ'' with set-subtract-split {xs = Canθₛ (Env.sig θ') 0 r θ} {ys = proj₁ (Dom θ')} {z = Signal.unwrap S'} (subst (λ x → _ ∈ Canθₛ (Env.sig θ') 0 x θ) (unplug r≐E⟦s⇐e⟧) (canθₛ-term-nothin-lemma (Env.sig θ'') 0 θ E (tset-shr s e) (Signal.unwrap S') S'∈can-r'-θ←θ'' )) ... | inj₁ S'∈can-r-θ←θ'-θ' = S'∈can-r-θ←θ'-θ' ... | inj₂ S'∈Domθ' = ⊥-elim (S'∉Domθ'' S'∈Domθ') canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .θ' , .A' ⟩· r') cb (rraise-var {x = x} {p = p} {e = e} {E = E} e' r≐E⟦var⟧) S' S'∈can-ρθ'·r'-θ rewrite sym (canθₛ-raise-lemma{A = WAIT} (Env.sig θ') 0 θ E (tvar (δ e') x e p)) | (unplug r≐E⟦var⟧) = S'∈can-ρθ'·r'-θ canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (rset-var {x = x} {e = e} {E = E} x∈ e' r≐E⟦x≔e⟧) S' S'∈can-ρθ''·r'-θ with set-subtract-merge {xs = Canθₛ (Env.sig θ'') 0 r' θ}{ys = proj₁ (Dom θ'')} S'∈can-ρθ''·r'-θ ... | S'∈can-r'-θ←θ'' , S'∉Domθ'' with set-subtract-split {xs = Canθₛ (Env.sig θ') 0 r θ} {ys = proj₁ (Dom θ')}{z = Signal.unwrap S'} ( (subst (λ x → _ ∈ Canθₛ (Env.sig θ') 0 x θ) (unplug r≐E⟦x≔e⟧) (canθₛ-term-nothin-lemma (Env.sig θ'') 0 θ E (tset-var x e) (Signal.unwrap S') S'∈can-r'-θ←θ'' )) ) ... | inj₁ S'∈can-r-θ←θ'-θ' = S'∈can-r-θ←θ'-θ' -- θ' and θ'' differ only by seq var Dom ... | inj₂ S'∈Domθ' = ⊥-elim (S'∉Domθ'' S'∈Domθ') canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .θ' , .A' ⟩· r') cb (rif-false {p = p} {q = q} {x = x} {E = E} x∈ θ'x≡zero r≐E⟦if⟧) S' S'∈can-ρθ'·r'-θ with set-subtract-merge{xs = (proj₁ (Canθ (Env.sig θ') 0 r' θ))} {ys = proj₁ (Dom θ')}{z = (Signal.unwrap S')} S'∈can-ρθ'·r'-θ ... | S'∈can-r'-θ←θ' , S'∉Domθ' rewrite sym (unplug r≐E⟦if⟧) = set-subtract-notin (canθₛ-if-false-lemma (Env.sig θ') 0 x p q θ E (Signal.unwrap S') S'∈can-r'-θ←θ') S'∉Domθ' canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .θ' , .A' ⟩· r') cb (rif-true {p = p} {q = q} {x = x} {E = E} x∈ θ'x≡suc r≐E⟦if⟧) S' S'∈can-ρθ'·r'-θ with set-subtract-merge{xs = (proj₁ (Canθ (Env.sig θ') 0 r' θ))} {ys = proj₁ (Dom θ')}{z = (Signal.unwrap S')} S'∈can-ρθ'·r'-θ ... | S'∈can-r'-θ←θ' , S'∉Domθ' rewrite sym (unplug r≐E⟦if⟧) = set-subtract-notin (canθₛ-if-true-lemma (Env.sig θ') 0 x p q θ E (Signal.unwrap S') S'∈can-r'-θ←θ') S'∉Domθ' canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· .r) cb (rabsence {S = S} S∈ θ'S≡unknown S∉can-r-θ') S' S'∈can-ρθ''·r-θ rewrite Env.sig-switch-right S Signal.absent θ θ' S∈ (Env.sig-←-monoʳ S θ' θ S∈) with set-subtract-merge{xs = Canθₛ (Env.sig θ'') 0 r θ } {ys = proj₁ (Dom θ'')} S'∈can-ρθ''·r-θ ... | S'∈can-r-θ←θ'' , S'∉Domθ'' with set-subtract-split{xs = (Canθₛ (Env.sig θ') 0 r θ)}{ys = fst (Dom θ')} (canθₛ-set-sig-monotonic-absence-lemma (Env.sig θ') 0 r S θ S∈ θ'S≡unknown (Signal.unwrap S') S'∈can-r-θ←θ'') where θ←θ' = θ ← θ' S∈Domθ←θ' = Env.sig-←-monoʳ S θ' θ S∈ ⟨θ←θ'⟩S≡θ'S = Env.sig-stats-←-right-irr' S θ θ' S∈ S∈Domθ←θ' ... | inj₁ S'∈can-r-θ←θ'-θ' = S'∈can-r-θ←θ'-θ' ... | inj₂ S'∈Domθ' = ⊥-elim (S'∉Domθ'' (Env.sig-set-mono' {S'} {S} {θ'} {Signal.absent} {S∈} S'∈Domθ')) canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) r' cb (rreadyness {s = s} s∈ θ's≡old⊎θ's≡new s∉can-r-θ') S' S'∈can-r'-θ = S'∈can-r'-θ canₛ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .(θ' ← θ'') , .(A-max A' _) ⟩· r') cb@(CBρ cb') (rmerge {θ₁ = .θ'} {θ₂ = θ''} {p = rin} {E = E} r≐E⟦ρθ''·rin⟧) S' S'∈can-ρθ'←θ''·r'-θ with set-subtract-merge {xs = Canθₛ (Env.sig (θ' ← θ'')) 0 r' θ} {ys = proj₁ (Dom (θ' ← θ''))} S'∈can-ρθ'←θ''·r'-θ ... | S'∈can-r'-θ←θ'←θ'' , S'∉Domθ'←θ'' = set-subtract-notin (canθₛ-mergeˡ (Env.sig θ') θ cb' r≐E⟦ρθ''·rin⟧ S' (S'∉Domθ'←θ'' ∘ Env.sig-←-monoʳ S' θ'' θ') S'∈can-r'-θ←θ'←θ'') (S'∉Domθ'←θ'' ∘ Env.sig-←-monoˡ S' θ' θ'') canₛₕ-monotonic θ (p ∥ q) _ cb (rpar-done-right p/halted q/done) s' s'∈can-r'-θ rewrite canₛₕ-done θ (value-max-done (dhalted p/halted) q/done (inj₁ p/halted)) with s'∈can-r'-θ ... | () canₛₕ-monotonic θ (p ∥ q) _ cb (rpar-done-left p/done q/halted) s' s'∈can-r'-θ rewrite canₛₕ-done θ (value-max-done p/done (dhalted q/halted) (inj₂ q/halted)) with s'∈can-r'-θ ... | () canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) r' cb (ris-present {S = S} S∈ θ'S≡present r≐E⟦present⟧) s' s'∈can-r'-θ rewrite canθ-is-present (Env.sig θ') S∈ θ r≐E⟦present⟧ θ'S≡present = s'∈can-r'-θ canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) r' cb (ris-absent {S = S} S∈ θ'S≡absent r≐E⟦present⟧) s' s'∈can-r'-θ rewrite canθ-is-absent (Env.sig θ') S∈ θ r≐E⟦present⟧ θ'S≡absent = s'∈can-r'-θ canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (remit {S = S} {E = E} S∈ θ'S≢absent r≐E⟦emit⟧) s' s'∈can-ρθ''·r'-θ with set-subtract-merge {xs = Canθₛₕ (Env.sig (Env.set-sig {S} θ' S∈ Signal.present)) 0 r' θ} {ys = proj₁ (proj₂ (Dom θ''))} s'∈can-ρθ''·r'-θ ... | s'∈can-r'-θ←θ'' , s'∉Domθ'' with set-subtract-split {ys = proj₁ (proj₂ (Dom θ'))} (canθₛₕ-emit θ' S∈ θ r≐E⟦emit⟧ θ'S≢absent (canθₛ-membership (Env.sig θ') 0 r θ S (λ θ* → canₛ-capture-emit-signal θ* r≐E⟦emit⟧)) s' s'∈can-r'-θ←θ'') ... | inj₁ s'∈can-r-θ←θ'-θ' = s'∈can-r-θ←θ'-θ' ... | inj₂ s'∈Domθ' = ⊥-elim (s'∉Domθ'' s'∈Domθ') -- θ' and θ'' differ only by sig canₛₕ-monotonic θ (loop r) r' cb rloop-unroll s' s'∈can-r'-θ = s'∈can-r'-θ canₛₕ-monotonic θ .(nothin >> r') r' cb rseq-done s' s'∈can-r'-θ = s'∈can-r'-θ canₛₕ-monotonic θ .(exit _ >> _) .(exit _) cb rseq-exit s' s'∈can-r'-θ = s'∈can-r'-θ canₛₕ-monotonic θ .(loopˢ (exit _) _) .(exit _) cb rloopˢ-exit s' s'∈can-r'-θ = s'∈can-r'-θ canₛₕ-monotonic θ (suspend r S) .r cb (rsuspend-done r/halted) s' s'∈can-r'-θ rewrite canₛₕ-done θ (dhalted r/halted) with s'∈can-r'-θ ... | () canₛₕ-monotonic θ (trap r) r' cb (rtrap-done r/halted) s' s'∈can-r'-θ rewrite canₛₕ-done θ (dhalted (↓-well-behaved _ r/halted)) with s'∈can-r'-θ ... | () canₛₕ-monotonic θ (signl S r) r' cb rraise-signal s' s'∈can-r'-θ rewrite set-subtract-[] (Canθₛₕ (Env.sig ([S]-env S)) 0 r θ) = s'∈can-r'-θ canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .θ' , .A' ⟩· r') cb (rraise-shared {s = s} {e = e} {p = p} {E = E} e' r≐E⟦shared⟧) s' s'∈can-ρθ'·r'-θ with set-subtract-merge {ys = proj₁ (proj₂ (Dom θ'))} s'∈can-ρθ'·r'-θ ... | s'∈can-r'-θ←θ' , s'∉Domθ' = set-subtract-notin (canθₛₕ-subset (Env.sig θ') 0 (E ⟦ ρ⟨ [s,δe]-env s (δ e') , WAIT ⟩· p ⟧e) r θ (λ θ* S* → canₛ-raise θ* (tshared (δ e') s e p) r≐E⟦shared⟧ S*) (λ θ* s* → canₛₕ-raise θ* (tshared (δ e') s e p) r≐E⟦shared⟧ s*) s' s'∈can-r'-θ←θ') s'∉Domθ' canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (rset-shared-value-old {s = s} {e = e} {E = E} e' s∈ θ's≡old r≐E⟦s⇐e⟧) s' s'∈can-ρθ''·r'-θ with set-subtract-merge {ys = proj₁ (proj₂ (Dom θ''))} s'∈can-ρθ''·r'-θ ... | s'∈can-r'-θ←θ'' , s'∉Domθ'' with set-subtract-split {ys = proj₁ (proj₂ (Dom θ'))} (canθₛₕ-subset (Env.sig θ') 0 (E ⟦ nothin ⟧e) r θ (λ θ* S* → canₛ-term-nothin θ* θ* refl (tset-shr s e) r≐E⟦s⇐e⟧ S*) (λ θ* s* → canₛₕ-term-nothin θ* θ* refl (tset-shr s e) r≐E⟦s⇐e⟧ s*) s' s'∈can-r'-θ←θ'') ... | inj₁ s'∈can-r-θ←θ'-θ' = s'∈can-r-θ←θ'-θ' ... | inj₂ s'∈Domθ' = ⊥-elim (s'∉Domθ'' (Env.shr-set-mono' {s'} {s} {θ'} {SharedVar.new} {δ e'} {s∈} s'∈Domθ')) canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (rset-shared-value-new {s = s} {e = e} {E = E} e' s∈ θ's≡new r≐E⟦s⇐e⟧) s' s'∈can-ρθ''·r'-θ with set-subtract-merge {ys = proj₁ (proj₂ (Dom θ''))} s'∈can-ρθ''·r'-θ ... | s'∈can-r'-θ←θ'' , s'∉Domθ'' with set-subtract-split {ys = proj₁ (proj₂ (Dom θ'))} (canθₛₕ-subset (Env.sig θ') 0 (E ⟦ nothin ⟧e) r θ (λ θ* S* → canₛ-term-nothin θ* θ* refl (tset-shr s e) r≐E⟦s⇐e⟧ S*) (λ θ* s* → canₛₕ-term-nothin θ* θ* refl (tset-shr s e) r≐E⟦s⇐e⟧ s*) s' s'∈can-r'-θ←θ'') ... | inj₁ s'∈can-r-θ←θ'-θ' = s'∈can-r-θ←θ'-θ' ... | inj₂ s'∈Domθ' = ⊥-elim (s'∉Domθ'' (Env.shr-set-mono' {s'} {s} {θ'} {SharedVar.new} {Env.shr-vals {s} θ' s∈ + δ e'} {s∈} s'∈Domθ')) canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .θ' , .A' ⟩· r') cb (rraise-var {x = x} {p = p} {e = e} {E = E} e' r≐E⟦var⟧) s' s'∈can-ρθ'·r'-θ with set-subtract-merge {ys = proj₁ (proj₂ (Dom θ'))} s'∈can-ρθ'·r'-θ ... | s'∈can-r'-θ←θ' , s'∉Domθ' = set-subtract-notin (canθₛₕ-subset (Env.sig θ') 0 (E ⟦ ρ⟨ [x,δe]-env x (δ e') , WAIT ⟩· p ⟧e) r θ (λ θ* S* → canₛ-raise θ* (tvar (δ e') x e p) r≐E⟦var⟧ S*) (λ θ* s* → canₛₕ-raise θ* (tvar (δ e') x e p) r≐E⟦var⟧ s*) s' s'∈can-r'-θ←θ') s'∉Domθ' canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· r') cb (rset-var {x = x} {e = e} {E = E} x∈ e' r≐E⟦x≔e⟧) s' s'∈can-ρθ''·r'-θ with set-subtract-merge {ys = proj₁ (proj₂ (Dom θ''))} s'∈can-ρθ''·r'-θ ... | s'∈can-r'-θ←θ'' , s'∉Domθ'' with set-subtract-split {ys = proj₁ (proj₂ (Dom θ'))} (canθₛₕ-subset (Env.sig θ') 0 (E ⟦ nothin ⟧e) r θ (λ θ* S* → canₛ-term-nothin θ* θ* refl (tset-var x e) r≐E⟦x≔e⟧ S*) (λ θ* s* → canₛₕ-term-nothin θ* θ* refl (tset-var x e) r≐E⟦x≔e⟧ s*) s' s'∈can-r'-θ←θ'') ... | inj₁ s'∈can-r-θ←θ'-θ' = s'∈can-r-θ←θ'-θ' -- θ' and θ'' differ only by seq var Dom ... | inj₂ s'∈Domθ' = ⊥-elim (s'∉Domθ'' s'∈Domθ') canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .θ' , .A' ⟩· r') cb (rif-false {p = p} {q = q} {x = x} {E = E} x∈ θ'x≡zero r≐E⟦if⟧) s' s'∈can-ρθ'·r'-θ with set-subtract-merge{xs = (thd (Canθ (Env.sig θ') 0 r' θ))} {ys = snd (Dom θ')}{z = (SharedVar.unwrap s')} s'∈can-ρθ'·r'-θ ... | s'∈can-r'-θ←θ' , s'∉Domθ' rewrite sym (unplug r≐E⟦if⟧) = set-subtract-notin (canθₛₕ-if-false-lemma (Env.sig θ' ) 0 x p q θ E (SharedVar.unwrap s') s'∈can-r'-θ←θ' ) s'∉Domθ' canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .θ' , .A' ⟩· r') cb (rif-true {p = p} {q = q} {x = x} {E = E} x∈ θ'x≡suc r≐E⟦if⟧) s' s'∈can-ρθ'·r'-θ with set-subtract-merge{xs = (thd (Canθ (Env.sig θ') 0 r' θ))} {ys = snd (Dom θ')}{z = (SharedVar.unwrap s')} s'∈can-ρθ'·r'-θ ... | s'∈can-r'-θ←θ' , s'∉Domθ' rewrite sym (unplug r≐E⟦if⟧) = set-subtract-notin (canθₛₕ-if-true-lemma (Env.sig θ' ) 0 x p q θ E (SharedVar.unwrap s') s'∈can-r'-θ←θ' ) s'∉Domθ' canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ θ'' , A'' ⟩· .r) cb (rabsence {S = S} S∈ θ'S≡unknown S∉can-r-θ') s' s'∈can-ρθ''·r-θ rewrite Env.sig-switch-right S Signal.absent θ θ' S∈ (Env.sig-←-monoʳ S θ' θ S∈) with set-subtract-merge {xs = Canθₛₕ (Env.sig θ'') 0 r θ }{ys = proj₁ (proj₂ (Dom θ''))} s'∈can-ρθ''·r-θ ... | s'∈can-r-θ←θ'' , s'∉Domθ'' with set-subtract-split (canθₛₕ-set-sig-monotonic-absence-lemma (Env.sig θ') 0 r S θ S∈ θ'S≡unknown (SharedVar.unwrap s') s'∈can-r-θ←θ'') where θ←θ' = θ ← θ' S∈Domθ←θ' = Env.sig-←-monoʳ S θ' θ S∈ ⟨θ←θ'⟩S≡θ'S = Env.sig-stats-←-right-irr' S θ θ' S∈ S∈Domθ←θ' ... | inj₁ s'∈can-r-θ←θ'-θ' = s'∈can-r-θ←θ'-θ' ... | inj₂ s'∈Domθ' = ⊥-elim (s'∉Domθ'' s'∈Domθ') -- θ' and θ'' differ only by sig canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) r' cb (rreadyness {s = s} s∈ θ's≡old⊎θ's≡new s∉can-r-θ') s' s'∈can-r'-θ rewrite cong (proj₁ ∘ proj₂) (Env.shr-set-dom-eq s SharedVar.ready (Env.shr-vals {s} θ' s∈) θ' s∈) | can-shr-var-irr r (θ ← θ') (θ ← Env.set-shr {s} θ' s∈ SharedVar.ready (Env.shr-vals {s} θ' s∈)) refl = s'∈can-r'-θ canₛₕ-monotonic θ (ρ⟨ θ' , A' ⟩· r) (ρ⟨ .(θ' ← θ'') , .(A-max A' _) ⟩· r') cb@(CBρ cb') (rmerge {θ₁ = .θ'} {θ₂ = θ''} {p = rin} {E = E} r≐E⟦ρθ''·rin⟧) s' s'∈can-ρθ'←θ''·r'-θ with set-subtract-merge {xs = Canθₛₕ (Env.sig (θ' ← θ'')) 0 r' θ} {ys = proj₁ (proj₂ (Dom (θ' ← θ'')))} s'∈can-ρθ'←θ''·r'-θ -- rewrite Env.←-assoc θ θ' θ'' ... | s'∈can-r'-θ←θ'←θ'' , s'∉Domθ'←θ'' = set-subtract-notin (canθₛₕ-mergeˡ (Env.sig θ') θ cb' r≐E⟦ρθ''·rin⟧ s' (s'∉Domθ'←θ'' ∘ Env.shr-←-monoʳ s' θ'' θ') s'∈can-r'-θ←θ'←θ'') (s'∉Domθ'←θ'' ∘ Env.shr-←-monoˡ s' θ' θ'') infix 4 _⊑₃_ _⊑₃_ : SigSet.ST × CodeSet.ST × ShrSet.ST -> SigSet.ST × CodeSet.ST × ShrSet.ST -> Set _⊑₃_ (Ss , ks , ss) (Ss' , ks' , ss') = ((∀ S → (Signal.unwrap S) ∈ Ss → (Signal.unwrap S) ∈ Ss') × (∀ k → k ∈ ks → k ∈ ks') × (∀ s → (SharedVar.unwrap s) ∈ ss → (SharedVar.unwrap s) ∈ ss')) can-antimonotonic : ∀ θ p q → CB p → p sn⟶₁ q → Can q θ ⊑₃ Can p θ can-antimonotonic θ r r' CBr rsn⟶₁r' = (canₛ-monotonic θ r r' CBr rsn⟶₁r' ,′ canₖ-monotonic θ r r' CBr rsn⟶₁r' ,′ canₛₕ-monotonic θ r r' CBr rsn⟶₁r')
{ "alphanum_fraction": 0.5409065262, "avg_line_length": 46.1011560694, "ext": "agda", "hexsha": "0a6a865996f0359dccf677f30c4887e44bf133df", "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/can-function-preserve.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/can-function-preserve.agda", "max_line_length": 144, "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/can-function-preserve.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": 16064, "size": 31902 }
module Lib.Eq where open import Lib.Prelude as P hiding (String) open import Lib.Nat renaming (_==_ to _=Nat=_) open import Lib.Fin open import Lib.List open import Lib.Bool -- Wrapper type, used to ensure that El is constructor-headed. record String : Set where constructor string field unString : P.String -- Codes for types supporting equality data EqU : Set where nat : EqU bool : EqU string : EqU unit : EqU fin : Nat -> EqU list : EqU -> EqU pair : EqU -> EqU -> EqU El : EqU -> Set El nat = Nat El bool = Bool El string = String El unit = Unit El (fin n) = Fin n El (list u) = List (El u) El (pair u v) = El u × El v primitive primStringEquality : P.String -> P.String -> Bool infix 30 _==_ _==_ : {u : EqU} -> El u -> El u -> Bool _==_ {nat} n m = n =Nat= m _==_ {fin n} i j = finEq i j _==_ {bool} false y = not y _==_ {bool} true y = y _==_ {string} (string x) (string y) = primStringEquality x y _==_ {unit} _ _ = true _==_ {list u} [] [] = true _==_ {list u} (x :: xs) (y :: ys) = x == y && xs == ys _==_ {list u} _ _ = false _==_ {pair u v} (x₁ , y₁) (x₂ , y₂) = x₁ == x₂ && y₁ == y₂
{ "alphanum_fraction": 0.5174772036, "avg_line_length": 25.8039215686, "ext": "agda", "hexsha": "90df297661d963d4c8d3c6989f635104ccfa31f7", "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/simple-lib/Lib/Eq.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/simple-lib/Lib/Eq.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/simple-lib/Lib/Eq.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": 455, "size": 1316 }
------------------------------------------------------------------------ -- Strict ω-continuous functions ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Partiality-algebra.Strict-omega-continuous where open import Equality.Propositional.Cubical open import Prelude hiding (⊥) open import Bijection equality-with-J using (_↔_) import Equivalence equality-with-J as Eq open import Function-universe equality-with-J hiding (_∘_) open import H-level.Closure equality-with-J open import Monad equality-with-J open import Partiality-algebra as PA open import Partiality-algebra.Monotone open import Partiality-algebra.Omega-continuous -- Definition of strict ω-continuous functions. record [_⟶_]⊥ {a₁ p₁ q₁} {A₁ : Type a₁} (P₁ : Partiality-algebra p₁ q₁ A₁) {a₂ p₂ q₂} {A₂ : Type a₂} (P₂ : Partiality-algebra p₂ q₂ A₂) : Type (p₁ ⊔ p₂ ⊔ q₁ ⊔ q₂) where private module P₁ = Partiality-algebra P₁ module P₂ = Partiality-algebra P₂ field ω-continuous-function : [ P₁ ⟶ P₂ ] open [_⟶_] ω-continuous-function public field strict : function P₁.never ≡ P₂.never open [_⟶_]⊥ -- Identity. id⊥ : ∀ {a p q} {A : Type a} {P : Partiality-algebra p q A} → [ P ⟶ P ]⊥ ω-continuous-function id⊥ = idω strict id⊥ = refl -- Composition. infixr 40 _∘⊥_ _∘⊥_ : ∀ {a₁ p₁ q₁} {A₁ : Type a₁} {P₁ : Partiality-algebra p₁ q₁ A₁} {a₂ p₂ q₂} {A₂ : Type a₂} {P₂ : Partiality-algebra p₂ q₂ A₂} {a₃ p₃ q₃} {A₃ : Type a₃} {P₃ : Partiality-algebra p₃ q₃ A₃} → [ P₂ ⟶ P₃ ]⊥ → [ P₁ ⟶ P₂ ]⊥ → [ P₁ ⟶ P₃ ]⊥ ω-continuous-function (f ∘⊥ g) = ω-continuous-function f ∘ω ω-continuous-function g strict (_∘⊥_ {P₁ = P₁} {P₂ = P₂} {P₃ = P₃} f g) = function f (function g P₁.never) ≡⟨ cong (function f) (strict g) ⟩ function f P₂.never ≡⟨ strict f ⟩∎ P₃.never ∎ where module P₁ = Partiality-algebra P₁ module P₂ = Partiality-algebra P₂ module P₃ = Partiality-algebra P₃ -- Equality characterisation lemma for strict ω-continuous functions. equality-characterisation-strict : ∀ {a₁ p₁ q₁} {A₁ : Type a₁} {P₁ : Partiality-algebra p₁ q₁ A₁} {a₂ p₂ q₂} {A₂ : Type a₂} {P₂ : Partiality-algebra p₂ q₂ A₂} {f g : [ P₁ ⟶ P₂ ]⊥} → (∀ x → function f x ≡ function g x) ↔ f ≡ g equality-characterisation-strict {P₁ = P₁} {P₂ = P₂} {f} {g} = (∀ x → function f x ≡ function g x) ↝⟨ equality-characterisation-continuous ⟩ ω-continuous-function f ≡ ω-continuous-function g ↝⟨ ignore-propositional-component P₂.T-is-set ⟩ _↔_.to rearrange f ≡ _↔_.to rearrange g ↔⟨ Eq.≃-≡ (Eq.↔⇒≃ rearrange) ⟩□ f ≡ g □ where module P₁ = Partiality-algebra P₁ module P₂ = Partiality-algebra P₂ rearrange : [ P₁ ⟶ P₂ ]⊥ ↔ ∃ λ (h : [ P₁ ⟶ P₂ ]) → [_⟶_].function h P₁.never ≡ P₂.never rearrange = record { surjection = record { logical-equivalence = record { to = λ f → ω-continuous-function f , strict f ; from = uncurry λ f c → record { ω-continuous-function = f ; strict = c } } ; right-inverse-of = λ _ → refl } ; left-inverse-of = λ _ → refl } where open Partiality-algebra -- Composition is associative. ∘⊥-assoc : ∀ {a₁ p₁ q₁} {A₁ : Type a₁} {P₁ : Partiality-algebra p₁ q₁ A₁} {a₂ p₂ q₂} {A₂ : Type a₂} {P₂ : Partiality-algebra p₂ q₂ A₂} {a₃ p₃ q₃} {A₃ : Type a₃} {P₃ : Partiality-algebra p₃ q₃ A₃} {a₄ p₄ q₄} {A₄ : Type a₄} {P₄ : Partiality-algebra p₄ q₄ A₄} (f : [ P₃ ⟶ P₄ ]⊥) (g : [ P₂ ⟶ P₃ ]⊥) (h : [ P₁ ⟶ P₂ ]⊥) → f ∘⊥ (g ∘⊥ h) ≡ (f ∘⊥ g) ∘⊥ h ∘⊥-assoc _ _ _ = _↔_.to equality-characterisation-strict λ _ → refl
{ "alphanum_fraction": 0.5668822768, "avg_line_length": 33.3189655172, "ext": "agda", "hexsha": "ef46cedfd60c37744cd17b29207dbc74712ffe4c", "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": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Partiality-algebra/Strict-omega-continuous.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Partiality-algebra/Strict-omega-continuous.agda", "max_line_length": 100, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Partiality-algebra/Strict-omega-continuous.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 1449, "size": 3865 }
open import FRP.LTL.Time using ( Time ; _,_ ) open import FRP.LTL.Time.Bound using ( Time∞ ; _≼_ ; _≺_ ; fin ; +∞ ; +∞-top ; t≺+∞ ; ≼-refl ; _≼-trans_ ; ≡-impl-≼ ; ≺-impl-≼ ; _≺-trans_ ; _≺-transʳ_ ; ≺-impl-⋡ ; t≺t+1 ) open import FRP.LTL.Util using ( irrelevant ; ⊥-elim ) open import Relation.Unary using ( _∈_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ) module FRP.LTL.Time.Interval where infixr 2 _⊑_ _~_ infixr 4 _,_ _⌢_∵_ -- Semi-open intervals, with possibly infinite bounds -- Previous versions of Interval used ≼ rather than ≺ -- (that is, empty intervals were supported) but -- MSet has been written to avoid requiring empty intervals. data Interval : Set where [_⟩ : ∀ {s t} → .(s ≺ t) → Interval lb : Interval → Time∞ lb ([_⟩ {s} {t} s≺t) = s ub : Interval → Time∞ ub ([_⟩ {s} {t} s≺t) = t .lb≺ub : ∀ i → (lb i ≺ ub i) lb≺ub [ s≺t ⟩ = irrelevant s≺t -- Semantics of intervals data Int∞ (i : Interval) (t : Time∞) : Set where _,_ : .(lb i ≼ t) → .(t ≺ ub i) → (t ∈ Int∞ i) Int : Interval → Time → Set Int i t = fin t ∈ Int∞ i .lb≼ : ∀ {t i} → (t ∈ Int i) → (lb i ≼ fin t) lb≼ (s≼t , t≺u) = irrelevant s≼t .≺ub : ∀ {t i} → (t ∈ Int i) → (fin t ≺ ub i) ≺ub (s≼t , t≺u) = irrelevant t≺u -- Ordering on intervals data _⊑_ (i j : Interval) : Set where _,_ : .(lb j ≼ lb i) → .(ub i ≼ ub j) → (i ⊑ j) ⊑-refl : ∀ {i} → (i ⊑ i) ⊑-refl = (≼-refl , ≼-refl) _⊑-trans_ : ∀ {i j k} → (i ⊑ j) → (j ⊑ k) → (i ⊑ k) (sj≼si , ui≼uj) ⊑-trans (sk≼sj , uj≼uk) = (sk≼sj ≼-trans sj≼si , ui≼uj ≼-trans uj≼uk) .⊑-impl-≼ : ∀ {i j} → (i ⊑ j) → (ub i ≼ ub j) ⊑-impl-≼ (lj≼li , ui≼uj) = irrelevant ui≼uj .⊑-impl-≽ : ∀ {i j} → (i ⊑ j) → (lb j ≼ lb i) ⊑-impl-≽ (lj≼li , ui≼uj) = irrelevant lj≼li -- When do two intervals abut? _~_ : Interval → Interval → Set i ~ j = ub i ≡ lb j -- Concatenation of intervals _⌢_∵_ : ∀ i j → (i ~ j) → Interval i ⌢ j ∵ i~j = [ lb≺ub i ≺-trans ≡-impl-≼ i~j ≺-transʳ lb≺ub j ⟩ ⌢-inj₁ : ∀ i j i~j → (i ⊑ (i ⌢ j ∵ i~j)) ⌢-inj₁ [ s≺t ⟩ [ t≺u ⟩ refl = (≼-refl , ≺-impl-≼ t≺u) ⌢-inj₂ : ∀ i j i~j → (j ⊑ (i ⌢ j ∵ i~j)) ⌢-inj₂ [ s≺t ⟩ [ t≺u ⟩ refl = (≺-impl-≼ s≺t , ≼-refl) -- Up-closure of a time ↑ : Time → Interval ↑ t = [ t≺+∞ {t} ⟩ -- Singleton interval sing : Time → Interval sing t = [ t≺t+1 {t} ⟩
{ "alphanum_fraction": 0.5323426573, "avg_line_length": 26, "ext": "agda", "hexsha": "7914e4de7abcc6836bc7fe5d51882f5113f63d06", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/Time/Interval.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/Time/Interval.agda", "max_line_length": 76, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/Time/Interval.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 1134, "size": 2288 }
------------------------------------------------------------------------ -- Laws related to _>>=_ ------------------------------------------------------------------------ module TotalParserCombinators.Laws.Monad where open import Algebra open import Category.Monad open import Codata.Musical.Notation open import Data.List open import Data.List.Categorical using () renaming (module MonadProperties to ListMonad) import Data.List.Relation.Binary.BagAndSetEquality as BSEq open import Function open import Level private module BagMonoid {k} {A : Set} = CommutativeMonoid (BSEq.commutativeMonoid k A) open RawMonad {f = zero} Data.List.Categorical.monad using () renaming (_>>=_ to _>>=′_) open import TotalParserCombinators.Derivative open import TotalParserCombinators.Congruence as Eq hiding (return; fail) renaming (_∣_ to _∣′_) import TotalParserCombinators.Laws.AdditiveMonoid as AdditiveMonoid open import TotalParserCombinators.Laws.Derivative as Derivative open import TotalParserCombinators.Laws.ReturnStar as Return⋆ open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser ------------------------------------------------------------------------ -- _>>=_, return, _∣_ and fail form a monad with a zero and a plus -- If the laws below are combined with the additive monoid laws this -- means that we have something which resembles an idempotent semiring -- (if we restrict ourselves to language equivalence). -- The zero laws are proved elsewhere. open Derivative public using () renaming (left-zero->>= to left-zero; right-zero->>= to right-zero) left-distributive : ∀ {Tok R₁ R₂ xs} {f g : R₁ → List R₂} (p₁ : Parser Tok R₁ xs) (p₂ : (x : R₁) → Parser Tok R₂ (f x)) (p₃ : (x : R₁) → Parser Tok R₂ (g x)) → p₁ >>= (λ x → p₂ x ∣ p₃ x) ≅P p₁ >>= p₂ ∣ p₁ >>= p₃ left-distributive {xs = xs} {f} {g} p₁ p₂ p₃ = BSEq.>>=-left-distributive xs {f = f} ∷ λ t → ♯ ( D t (p₁ >>= (λ x → p₂ x ∣ p₃ x)) ≅⟨ D->>= p₁ (λ x → p₂ x ∣ p₃ x) ⟩ D t p₁ >>= (λ x → p₂ x ∣ p₃ x) ∣ return⋆ xs >>= (λ x → D t (p₂ x) ∣ D t (p₃ x)) ≅⟨ left-distributive (D t p₁) p₂ p₃ ∣′ left-distributive (return⋆ xs) (λ x → D t (p₂ x)) (λ x → D t (p₃ x)) ⟩ (D t p₁ >>= p₂ ∣ D t p₁ >>= p₃) ∣ (return⋆ xs >>= (λ x → D t (p₂ x)) ∣ return⋆ xs >>= (λ x → D t (p₃ x))) ≅⟨ AdditiveMonoid.swap (D t p₁ >>= p₂) (D t p₁ >>= p₃) (return⋆ xs >>= (λ x → D t (p₂ x))) (return⋆ xs >>= (λ x → D t (p₃ x))) ⟩ (D t p₁ >>= p₂ ∣ return⋆ xs >>= (λ x → D t (p₂ x))) ∣ (D t p₁ >>= p₃ ∣ return⋆ xs >>= (λ x → D t (p₃ x))) ≅⟨ sym (D->>= p₁ p₂ ∣′ D->>= p₁ p₃) ⟩ D t (p₁ >>= p₂) ∣ D t (p₁ >>= p₃) ∎) right-distributive : ∀ {Tok R₁ R₂ xs₁ xs₂} {f : R₁ → List R₂} (p₁ : Parser Tok R₁ xs₁) (p₂ : Parser Tok R₁ xs₂) (p₃ : (x : R₁) → Parser Tok R₂ (f x)) → (p₁ ∣ p₂) >>= p₃ ≅P p₁ >>= p₃ ∣ p₂ >>= p₃ right-distributive {xs₁ = xs₁} {xs₂} {f} p₁ p₂ p₃ = BagMonoid.reflexive (ListMonad.right-distributive xs₁ xs₂ f) ∷ λ t → ♯ ( D t ((p₁ ∣ p₂) >>= p₃) ≅⟨ D->>= (p₁ ∣ p₂) p₃ ⟩ (D t p₁ ∣ D t p₂) >>= p₃ ∣ return⋆ (xs₁ ++ xs₂) >>= (λ x → D t (p₃ x)) ≅⟨ ((D t p₁ ∣ D t p₂) >>= p₃ ∎) ∣′ [ ○ - ○ - ○ - ○ ] Return⋆.distrib-∣ xs₁ xs₂ >>= (λ x → D t (p₃ x) ∎) ⟩ (D t p₁ ∣ D t p₂) >>= p₃ ∣ (return⋆ xs₁ ∣ return⋆ xs₂) >>= (λ x → D t (p₃ x)) ≅⟨ right-distributive (D t p₁) (D t p₂) p₃ ∣′ right-distributive (return⋆ xs₁) (return⋆ xs₂) (λ x → D t (p₃ x)) ⟩ ((D t p₁ >>= p₃) ∣ (D t p₂ >>= p₃)) ∣ (return⋆ xs₁ >>= (λ x → D t (p₃ x)) ∣ return⋆ xs₂ >>= (λ x → D t (p₃ x))) ≅⟨ AdditiveMonoid.swap (D t p₁ >>= p₃) (D t p₂ >>= p₃) (return⋆ xs₁ >>= (λ x → D t (p₃ x))) (return⋆ xs₂ >>= (λ x → D t (p₃ x))) ⟩ (D t p₁ >>= p₃ ∣ return⋆ xs₁ >>= (λ x → D t (p₃ x))) ∣ (D t p₂ >>= p₃ ∣ return⋆ xs₂ >>= (λ x → D t (p₃ x))) ≅⟨ sym (D->>= p₁ p₃ ∣′ D->>= p₂ p₃) ⟩ D t (p₁ >>= p₃) ∣ D t (p₂ >>= p₃) ∎) left-identity : ∀ {Tok R₁ R₂} {f : R₁ → List R₂} (x : R₁) (p : (x : R₁) → Parser Tok R₂ (f x)) → return x >>= p ≅P p x left-identity {f = f} x p = BagMonoid.reflexive (ListMonad.left-identity x f) ∷ λ t → ♯ ( D t (return x >>= p) ≅⟨ D->>= (return x) p ⟩ fail >>= p ∣ return⋆ [ x ] >>= (λ x → D t (p x)) ≅⟨ left-zero p ∣′ [ ○ - ○ - ○ - ○ ] AdditiveMonoid.right-identity (return x) >>= (λ x → D t (p x) ∎) ⟩ fail ∣ return x >>= (λ x → D t (p x)) ≅⟨ AdditiveMonoid.left-identity (return x >>= (λ x → D t (p x))) ⟩ return x >>= (λ x → D t (p x)) ≅⟨ left-identity x (λ x → D t (p x)) ⟩ D t (p x) ∎) right-identity : ∀ {Tok R xs} (p : Parser Tok R xs) → p >>= return ≅P p right-identity {xs = xs} p = BagMonoid.reflexive (ListMonad.right-identity xs) ∷ λ t → ♯ ( D t (p >>= return) ≅⟨ D->>= p return ⟩ D t p >>= return ∣ return⋆ xs >>= (λ _ → fail) ≅⟨ right-identity (D t p) ∣′ right-zero (return⋆ xs) ⟩ D t p ∣ fail ≅⟨ AdditiveMonoid.right-identity (D t p) ⟩ D t p ∎) associative : ∀ {Tok R₁ R₂ R₃ xs} {f : R₁ → List R₂} {g : R₂ → List R₃} (p₁ : Parser Tok R₁ xs) (p₂ : (x : R₁) → Parser Tok R₂ (f x)) (p₃ : (x : R₂) → Parser Tok R₃ (g x)) → p₁ >>= (λ x → p₂ x >>= p₃) ≅P p₁ >>= p₂ >>= p₃ associative {xs = xs} {f} {g} p₁ p₂ p₃ = BagMonoid.reflexive (ListMonad.associative xs f g) ∷ λ t → ♯ ( D t (p₁ >>= λ x → p₂ x >>= p₃) ≅⟨ D->>= p₁ (λ x → p₂ x >>= p₃) ⟩ D t p₁ >>= (λ x → p₂ x >>= p₃) ∣ return⋆ xs >>= (λ x → D t (p₂ x >>= p₃)) ≅⟨ associative (D t p₁) p₂ p₃ ∣′ [ ○ - ○ - ○ - ○ ] return⋆ xs ∎ >>= (λ x → D->>= (p₂ x) p₃) ⟩ D t p₁ >>= p₂ >>= p₃ ∣ return⋆ xs >>= (λ x → D t (p₂ x) >>= p₃ ∣ return⋆ (f x) >>= λ x → D t (p₃ x)) ≅⟨ (D t p₁ >>= p₂ >>= p₃ ∎) ∣′ left-distributive (return⋆ xs) (λ x → D t (p₂ x) >>= p₃) (λ x → return⋆ (f x) >>= (λ x → D t (p₃ x))) ⟩ D t p₁ >>= p₂ >>= p₃ ∣ (return⋆ xs >>= (λ x → D t (p₂ x) >>= p₃) ∣ return⋆ xs >>= (λ x → return⋆ (f x) >>= λ x → D t (p₃ x))) ≅⟨ (D t p₁ >>= p₂ >>= p₃ ∎) ∣′ (associative (return⋆ xs) (λ x → D t (p₂ x)) p₃ ∣′ associative (return⋆ xs) (return⋆ ∘ f) (λ x → D t (p₃ x))) ⟩ D t p₁ >>= p₂ >>= p₃ ∣ (return⋆ xs >>= (λ x → D t (p₂ x)) >>= p₃ ∣ return⋆ xs >>= (return⋆ ∘ f) >>= λ x → D t (p₃ x)) ≅⟨ sym $ AdditiveMonoid.associative (D t p₁ >>= p₂ >>= p₃) (return⋆ xs >>= (λ x → D t (p₂ x)) >>= p₃) (return⋆ xs >>= (return⋆ ∘ f) >>= (λ x → D t (p₃ x))) ⟩ D t p₁ >>= p₂ >>= p₃ ∣ return⋆ xs >>= (λ x → D t (p₂ x)) >>= p₃ ∣ return⋆ xs >>= (return⋆ ∘ f) >>= (λ x → D t (p₃ x)) ≅⟨ sym (right-distributive (D t p₁ >>= p₂) (return⋆ xs >>= (λ x → D t (p₂ x))) p₃) ∣′ [ ○ - ○ - ○ - ○ ] sym (Return⋆.distrib->>= xs f) >>= (λ x → D t (p₃ x) ∎) ⟩ (D t p₁ >>= p₂ ∣ return⋆ xs >>= (λ x → D t (p₂ x))) >>= p₃ ∣ return⋆ (xs >>=′ f) >>= (λ x → D t (p₃ x)) ≅⟨ [ ○ - ○ - ○ - ○ ] sym (D->>= p₁ p₂) >>= (λ x → p₃ x ∎) ∣′ (return⋆ (xs >>=′ f) >>= (λ x → D t (p₃ x)) ∎) ⟩ D t (p₁ >>= p₂) >>= p₃ ∣ return⋆ (xs >>=′ f) >>= (λ x → D t (p₃ x)) ≅⟨ sym $ D->>= (p₁ >>= p₂) p₃ ⟩ D t (p₁ >>= p₂ >>= p₃) ∎)
{ "alphanum_fraction": 0.3491075982, "avg_line_length": 59.0662650602, "ext": "agda", "hexsha": "4c918f7bef70e728c552a93f130f86c487035e7f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalParserCombinators/Laws/Monad.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/Laws/Monad.agda", "max_line_length": 132, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/Laws/Monad.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 3270, "size": 9805 }
{-# OPTIONS --cubical --no-import-sorts #-} module MoreAlgebra where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) private variable ℓ ℓ' ℓ'' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Relation.Binary.Base open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` open import Cubical.Foundations.Logic renaming (¬_ to ¬ᵖ_; inl to inlᵖ; inr to inrᵖ) open import Utils hPropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) hPropRel A B ℓ' = A → B → hProp ℓ' module Definitions where -- NOTE: one needs these "all-lowercase constructors" to make use of copatterns _Preserves_⟶_ : ∀{Aℓ Bℓ ℓ ℓ'} {A : Type Aℓ} {B : Type Bℓ} → (A → B) → Rel A A ℓ → Rel B B ℓ' → Set _ f Preserves P ⟶ Q = ∀{x y} → P x y → Q (f x) (f y) _Reflects_⟶_ : ∀{Aℓ Bℓ ℓ ℓ'} {A : Type Aℓ} {B : Type Bℓ} → (A → B) → Rel A A ℓ → Rel B B ℓ' → Set _ f Reflects P ⟶ Q = ∀{x y} → Q (f x) (f y) → P x y -- https://en.wikipedia.org/wiki/Complete_partial_order -- A partially ordered set is a directed-complete partial order (dcpo) if each of its directed subsets has a supremum. -- A subset of a partial order is directed if it is non-empty and every pair of elements has an upper bound in the subset. -- In the literature, dcpos sometimes also appear under the label up-complete poset. -- https://ncatlab.org/nlab/show/dcpo -- A DCPO, or directed-complete partial order, is a poset with all directed joins. -- Often a DCPO is required to have a bottom element ⊥\bot; then it is called a pointed DCPO or a CPO (but this term is ambiguous). -- In this chapter we develop the theory of directed-complete partial orders (dcpo), namely -- partially ordered sets in which only certain joins are required to exist. -- -- ... -- -- 3.1 Dcpos -- -- We start by defining partial orders. By a binary relation R on a set X , we mean a map X → X → HProp, as in Definition 2.7.1. -- We can specify which universe the binary relation lands in by saying that R is HPropᵢ-valued or is a relation in universe i if R : X → X → HPropᵢ. -- -- Definition 3.1.1. A binary relation R on a set X is -- -- 1. reflexive if (∀ x : X) R x x; -- 2. irreflexive if (∀ x : X) ¬ R x x; -- 3. symmetric if (∀ x, y : X) R x y ⇒ R y x; -- 4. antisymmetric if (∀ x, y : X) R x y ⇒ R y x ⇒ x = y; -- 5. transitive if (∀ x, y, z : X) R x y ⇒ R y z ⇒ R x z; -- 6. cotransitive if (∀ x, y, z : X) R x y ⇒ (R x z) ∨ (R z y). -- -- Remark 3.1.2. Cotransitivity is also known as weak linearity [91, Definition 11.2.7] or the approximate splitting principle [84]. -- -- Definition 3.1.3. -- -- A preorder, denoted by ≤, is a reflexive transitive relation. -- A partial order is an antisymmetric preorder. -- Definition 4.1.4. -- - An apartness relation, denoted by #, is an irreflexive symmetric cotransitive relation. -- - A strict partial order, denoted by <, is an irreflexive transitive cotransitive relation. IsIrrefl : {ℓ ℓ' : Level} {A : Type ℓ} → (R : Rel A A ℓ') → Type (ℓ-max ℓ ℓ') IsIrrefl {A = A} R = (a : A) → ¬(R a a) IsCotrans : {ℓ ℓ' : Level} {A : Type ℓ} → (R : Rel A A ℓ') → Type (ℓ-max ℓ ℓ') IsCotrans {A = A} R = (a b : A) → R a b → (∀(x : A) → (R a x) ⊎ (R x b)) -- NOTE: see Cubical.Algebra.Poset IsSymᵖ : {ℓ ℓ' : Level} {A : Type ℓ} → (R : hPropRel A A ℓ') → Type (ℓ-max ℓ ℓ') IsSymᵖ {A = A} R = (a b : A) → [ R a b ] → [ R b a ] IsIrreflᵖ : {ℓ ℓ' : Level} {A : Type ℓ} → (R : hPropRel A A ℓ') → Type (ℓ-max ℓ ℓ') IsIrreflᵖ {A = A} R = (a : A) → [ ¬ᵖ(R a a) ] IsCotransᵖ : {ℓ ℓ' : Level} {A : Type ℓ} → (R : hPropRel A A ℓ') → Type (ℓ-max ℓ ℓ') IsCotransᵖ {A = A} R = (a b : A) → [ R a b ] → (∀(x : A) → [ (R a x) ⊔ (R x b) ]) {- NOTE: formulating the properties on witnesses with `[_]` is similar to the previous Propositions-as-types formalism but it is not the way to proceed with hProps the idea is, to produce an hProp again e.g. from `Cubical.Algebra.Poset` isTransitive : {A : Type ℓ₀} → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) isTransitive {ℓ₀ = ℓ₀} {ℓ₁ = ℓ₁} {A = X} _⊑_ = φ , φ-prop where φ : Type (ℓ-max ℓ₀ ℓ₁) φ = ((x y z : X) → [ x ⊑ y ⇒ y ⊑ z ⇒ x ⊑ z ]) φ-prop : isProp φ φ-prop = isPropΠ3 λ x y z → snd (x ⊑ y ⇒ y ⊑ z ⇒ x ⊑ z) -} IsTransᵖ : {ℓ ℓ' : Level} {A : Type ℓ} → (R : hPropRel A A ℓ') → Type (ℓ-max ℓ ℓ') IsTransᵖ {A = A} R = (a b c : A) → [ R a b ] → [ R b c ] → [ R a c ] -- NOTE: this is starting with a lower-case, because `hProp (ℓ-max ℓ ℓ')` is not a type but an element isTransᵖ : {ℓ ℓ' : Level} {A : Type ℓ} → (R : hPropRel A A ℓ') → hProp (ℓ-max ℓ ℓ') isTransᵖ {ℓ} {ℓ'} {A = A} R = φ , φ-prop where φ : Type (ℓ-max ℓ ℓ') φ = (a b c : A) → [ R a b ⇒ R b c ⇒ R a c ] φ-prop : isProp φ φ-prop = isPropΠ3 λ a b c → snd (R a b ⇒ R b c ⇒ R a c) isIrreflᵖ : {ℓ ℓ' : Level} {A : Type ℓ} → (R : hPropRel A A ℓ') → hProp (ℓ-max ℓ ℓ') isIrreflᵖ {ℓ} {ℓ'} {A = A} R = φ , φ-prop where φ : Type (ℓ-max ℓ ℓ') φ = (a : A) → [ ¬ᵖ (R a a) ] φ-prop : isProp φ φ-prop = isPropΠ λ a → snd (¬ᵖ (R a a)) isCotransᵖ : {ℓ ℓ' : Level} {A : Type ℓ} → (R : hPropRel A A ℓ') → hProp (ℓ-max ℓ ℓ') isCotransᵖ {ℓ} {ℓ'} {A = A} R = φ , φ-prop where φ : Type (ℓ-max ℓ ℓ') φ = (a b : A) → [ R a b ⇒ (∀[ x ∶ A ] (R a x) ⊔ (R x b)) ] φ-prop : isProp φ φ-prop = isPropΠ2 λ a b → snd (R a b ⇒ (∀[ x ∶ A ] (R a x) ⊔ (R x b))) record IsApartnessRel {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') : Type (ℓ-max ℓ ℓ') where field isIrrefl : IsIrrefl R isSym : BinaryRelation.isSym R isCotrans : IsCotrans R record IsApartnessRelᵖ {ℓ ℓ' : Level} {A : Type ℓ} (R : hPropRel A A ℓ') : Type (ℓ-max ℓ ℓ') where field isIrrefl : IsIrreflᵖ R isSym : IsSymᵖ R isCotrans : IsCotransᵖ R record IsStrictPartialOrder {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') : Type (ℓ-max ℓ ℓ') where constructor isstrictpartialorder field isIrrefl : IsIrrefl R isTrans : BinaryRelation.isTrans R isCotrans : IsCotrans R record IsStrictPartialOrderᵖ {ℓ ℓ' : Level} {A : Type ℓ} (R : hPropRel A A ℓ') : Type (ℓ-max ℓ ℓ') where constructor isstrictpartialorderᵖ field isIrrefl : IsIrreflᵖ R isTrans : IsTransᵖ R isCotrans : IsCotransᵖ R {- NOTE: here again, the previous-way-interpretation would be to put witnesses into the struct with `[_]` but with hProps, we would have `isStrictPartialOrder : hProp` and use `[ isStrictPartialOrder ]` as the witness type with hProps we would need to make heavy use of `Cubical.Foundations.HLevels` isProp×, isProp×2, isProp×3 to show the record's `isProp` do we have pathes on records? in order to use `isProp` on records? yes, with record constructors -} record [IsStrictPartialOrder] {ℓ ℓ' : Level} {A : Type ℓ} (R : hPropRel A A ℓ') : Type (ℓ-max ℓ ℓ') where constructor isstrictpartialorderᵖ field isIrrefl : [ isIrreflᵖ R ] isTrans : [ isTransᵖ R ] isCotrans : [ isCotransᵖ R ] isStrictParialOrder : {ℓ ℓ' : Level} {A : Type ℓ} (R : hPropRel A A ℓ') → hProp (ℓ-max ℓ ℓ') isStrictParialOrder R = [IsStrictPartialOrder] R , φ-prop where φ-prop : isProp ([IsStrictPartialOrder] R) φ-prop (isstrictpartialorderᵖ isIrrefl₀ isTrans₀ isCotrans₀) (isstrictpartialorderᵖ isIrrefl₁ isTrans₁ isCotrans₁) = λ i → isstrictpartialorderᵖ (isProp[] (isIrreflᵖ R) isIrrefl₀ isIrrefl₁ i) (isProp[] (isTransᵖ R) isTrans₀ isTrans₁ i) (isProp[] (isCotransᵖ R) isCotrans₀ isCotrans₁ i) record IsPreorder {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') : Type (ℓ-max ℓ ℓ') where constructor ispreorder field isRefl : BinaryRelation.isRefl R isTrans : BinaryRelation.isTrans R -- NOTE: there is already -- isAntisym : {A : Type ℓ₀} → isSet A → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) -- in Cubical.Algebra.Poset. Can we use this? -- import Cubical.Algebra.Poset IsAntisym : {ℓ ℓ' : Level} {A : Type ℓ} → (R : Rel A A ℓ') → Type (ℓ-max ℓ ℓ') IsAntisym {A = A} R = ∀ a b → R a b → R b a → a ≡ b record IsPartialOrder {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') : Type (ℓ-max ℓ ℓ') where constructor ispartialorder field isRefl : BinaryRelation.isRefl R isAntisym : IsAntisym R isTrans : BinaryRelation.isTrans R _#'_ : ∀{X : Type ℓ} {_<_ : Rel X X ℓ'} → Rel X X ℓ' _#'_ {_<_ = _<_} x y = (x < y) ⊎ (y < x) _≤'_ : ∀{X : Type ℓ} {_<_ : Rel X X ℓ'} → Rel X X ℓ' _≤'_ {_<_ = _<_} x y = ¬ (y < x) -- NOTE: there is `Properties` and `Consequences` -- the difference somehow is, that we do want to open `Consequences` directly -- but we do not want to open `Properties` directly, because it might have a name clash -- e.g. there is `Properties.Group` which clashes with `Cubical.Algebra.Group.Group` when opening `Properties` -- but it is totally fine to open `Properties.Group` directly because it does not export a `Group` -- TODO: check whether this matches the wording of the (old) standard library module Consequences where open Definitions -- Lemma 4.1.7. -- Given a strict partial order < on a set X: -- 1. we have an apartness relation defined by -- x # y := (x < y) ∨ (y < x), and #'-isApartnessRel : ∀{X : Type ℓ} {_<_ : Rel X X ℓ'} → (isSPO : IsStrictPartialOrder _<_) → IsApartnessRel (_#'_ {_<_ = _<_}) #'-isApartnessRel {X = X} {_<_ = _<_} isSPO = let (isstrictpartialorder <-irrefl <-trans <-cotrans) = isSPO in λ where .IsApartnessRel.isIrrefl a (inl a<a) → <-irrefl _ a<a .IsApartnessRel.isIrrefl a (inr a<a) → <-irrefl _ a<a .IsApartnessRel.isSym a b p → ⊎-swap p .IsApartnessRel.isCotrans a b (inl a<b) x → case (<-cotrans _ _ a<b x) of λ where -- case x of f = f x (inl a<x) → inl (inl a<x) (inr x<b) → inr (inl x<b) .IsApartnessRel.isCotrans a b (inr b<a) x → case (<-cotrans _ _ b<a x) of λ where (inl b<x) → inr (inr b<x) (inr x<a) → inl (inr x<a) -- variant without copatterns: "just" move the `λ where` "into" the record #'-isApartnessRel' : ∀{X : Type ℓ} {_<_ : Rel X X ℓ'} → {IsStrictPartialOrder _<_} → IsApartnessRel (_#'_ {_<_ = _<_}) #'-isApartnessRel' {X = X} {_<_ = _<_} {isSPO} = let (isstrictpartialorder <-irrefl <-trans <-cotrans) = isSPO in record { isIrrefl = λ where a (inl a<a) → <-irrefl _ a<a a (inr a<a) → <-irrefl _ a<a ; isSym = λ where a b p → ⊎-swap p ; isCotrans = λ where a b (inl a<b) x → case (<-cotrans _ _ a<b x) of λ where (inl a<x) → inl (inl a<x) (inr x<b) → inr (inl x<b) a b (inr b<a) x → case (<-cotrans _ _ b<a x) of λ where (inl b<x) → inr (inr b<x) (inr x<a) → inl (inr x<a) } -- 2. we have a preorder defined by -- x ≤ y := ¬(y < x). ≤-isPreorder' : ∀{X : Type ℓ} {_<_ : Rel X X ℓ'} → {IsStrictPartialOrder _<_} → IsPreorder (_≤'_ {_<_ = _<_}) ≤-isPreorder' {X = X} {_<_ = _<_} {isSPO} = let (isstrictpartialorder <-irrefl <-trans <-cotrans) = isSPO in λ where .IsPreorder.isRefl → <-irrefl .IsPreorder.isTrans a b c ¬b<a ¬c<b c<a → case (<-cotrans _ _ c<a b) of λ where (inl c<b) → ¬c<b c<b (inr b<a) → ¬b<a b<a module _ {X : Type ℓ} (_<_ : Rel X X ℓ') (isSPO : IsStrictPartialOrder _<_) (<-isProp : ∀ x y → isProp (x < y)) (let _#_ = _#'_ {_<_ = _<_}) (let (isstrictpartialorder <-irrefl <-trans <-cotrans) = isSPO) where -- open IsStrictPartialOrder isSPO #-from-<-isProp : ∀ x y → isProp (x # y) #-from-<-isProp x y (inl x<y₁) (inl x<y₂) = cong inl (<-isProp x y x<y₁ x<y₂) -- NOTE: ⊥-elim could not resolve the level here and needed some hint on `A` #-from-<-isProp x y (inl x<y ) (inr y<x ) = ⊥-elim {A = λ _ → inl x<y ≡ inr y<x} (<-irrefl y (<-trans y x y y<x x<y)) #-from-<-isProp x y (inr y<x ) (inl x<y ) = ⊥-elim {A = λ _ → inr y<x ≡ inl x<y} (<-irrefl y (<-trans y x y y<x x<y)) #-from-<-isProp x y (inr y<x₁) (inr y<x₂) = cong inr (<-isProp y x y<x₁ y<x₂) module Properties where module _ where open import Cubical.Algebra.Group -- import Cubical.Algebra.Group.Properties module GroupProperties (G : Group {ℓ}) where open Group G private simplR = GroupLemmas.simplR G invUniqueL : {g h : Carrier} → g + h ≡ 0g → g ≡ - h invUniqueL {g} {h} p = simplR h (p ∙ sym (invl h)) -- ported from `Algebra.Properties.Group` right-helper : ∀ x y → y ≡ - x + (x + y) right-helper x y = ( y ≡⟨ sym (snd (identity y)) ⟩ 0g + y ≡⟨ cong₂ _+_ (sym (snd (inverse x))) refl ⟩ ((- x) + x) + y ≡⟨ sym (assoc (- x) x y) ⟩ (- x) + (x + y) ∎) -- alternative: -- follows from uniqueness of - -- (a + -a) ≡ 0 -- ∃! b . a + b = 0 -- show that a is an additive inverse of - a then it must be THE additive inverse of - a and has to be called - - a which is a by uniqueness -involutive : ∀ x → - - x ≡ x -involutive x = ( (- (- x)) ≡⟨ sym (fst (identity _)) ⟩ (- (- x)) + 0g ≡⟨ cong₂ _+_ refl (sym (snd (inverse _))) ⟩ (- (- x)) + (- x + x) ≡⟨ sym (right-helper (- x) x) ⟩ x ∎) module _ where open import Cubical.Algebra.Ring module RingProperties (R : Ring {ℓ}) where open Ring R open Cubical.Algebra.Ring.Theory R -- NOTE: a few facts about rings that might be collected from elsewhere a+b-b≡a : ∀ a b → a ≡ (a + b) - b a+b-b≡a a b = let P = sym (fst (+-inv b)) Q = sym (fst (+-identity a)) R = transport (λ i → a ≡ a + P i) Q S = transport (λ i → a ≡ (+-assoc a b (- b)) i ) R in S -- NOTE: this is called `simplL` and `simplL` in `Cubical.Algebra.Group.Properties.GroupLemmas` +-preserves-≡ : ∀{a b} → ∀ c → a ≡ b → a + c ≡ b + c +-preserves-≡ c a≡b i = a≡b i + c +-preserves-≡-l : ∀{a b} → ∀ c → a ≡ b → c + a ≡ c + b +-preserves-≡-l c a≡b i = c + a≡b i a+b≡0→a≡-b : ∀{a b} → a + b ≡ 0r → a ≡ - b a+b≡0→a≡-b {a} {b} a+b≡0 = transport (λ i → let RHS = snd (+-identity (- b)) LHS₁ : a + (b + - b) ≡ a + 0r LHS₁ = +-preserves-≡-l a (fst (+-inv b)) LHS₂ : (a + b) - b ≡ a LHS₂ = transport (λ j → (+-assoc a b (- b)) j ≡ fst (+-identity a) j) LHS₁ in LHS₂ i ≡ RHS i ) (+-preserves-≡ (- b) a+b≡0) -- NOTE: there is already -- -commutesWithRight-· : (x y : R) → x · (- y) ≡ - (x · y) a·-b≡-a·b : ∀ a b → a · (- b) ≡ - (a · b) a·-b≡-a·b a b = let P : a · 0r ≡ 0r P = 0-rightNullifies a Q : a · (- b + b) ≡ 0r Q = transport (λ i → a · snd (+-inv b) (~ i) ≡ 0r) P R : a · (- b) + a · b ≡ 0r R = transport (λ i → ·-rdist-+ a (- b) b i ≡ 0r) Q in a+b≡0→a≡-b R a·b-a·c≡a·[b-c] : ∀ a b c → a · b - (a · c) ≡ a · (b - c) a·b-a·c≡a·[b-c] a b c = let P : a · b + a · (- c) ≡ a · (b + - c) P = sym (·-rdist-+ a b (- c)) Q : a · b - a · c ≡ a · (b + - c) Q = transport (λ i → a · b + a·-b≡-a·b a c i ≡ a · (b + - c) ) P in Q -- exports module Group = GroupProperties module Ring = RingProperties
{ "alphanum_fraction": 0.5406089803, "avg_line_length": 43.7594594595, "ext": "agda", "hexsha": "e354936abe4d91062b7915d1b4c9910bbd5a5233", "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/MoreAlgebra.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/MoreAlgebra.agda", "max_line_length": 151, "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/MoreAlgebra.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": 6312, "size": 16191 }
open import Coinduction using ( ♯_ ) open import Data.Maybe using ( Maybe ; just ; nothing ; maybe ) open import Data.Nat using ( ℕ ; _+_ ) open import Data.Integer using ( ℤ ; +_ ; _⊖_ ) open import System.IO.Transducers using ( inp ; out ; done ; _⇒_ ; Inp_⇒_ ; C⟦_⟧ ; _⟨¿⟩_ ) open import System.IO.Transducers.Trace using ( [] ; _∷_ ) open import System.IO.Transducers.Session using ( ⟨_⟩ ; _&_ ; ¡ ; ¿ ) open import System.IO.Transducers.Stateful using ( loop ) module System.IO.Examples.Transducers where add : ⟨ ℕ ⟩ & ⟨ ℕ ⟩ ⇒ ⟨ ℕ ⟩ add = inp (♯ λ x → inp (♯ λ y → out (x + y) done)) -- runAdd == 8 ∷ [] runAdd = C⟦ add ⟧ ( 3 ∷ 5 ∷ [] ) nat? : ¡ ⟨ ℤ ⟩ ⇒ ¿ ⟨ ℕ ⟩ & ¡ ⟨ ℤ ⟩ nat? = inp (♯ rest) where rest : Inp ¡ ⟨ ℤ ⟩ ⇒ ¿ ⟨ ℕ ⟩ & ¡ ⟨ ℤ ⟩ rest nothing = out nothing (out nothing done) rest (just (+ n)) = out (just n) done rest (just x) = out nothing (out (just x) done) -- runNat? == ( just 5 ∷ just (+ 7) ∷ just (0 ⊖ 3) ∷ just (+ 8) ∷ nothing ∷ []) runNat? = C⟦ nat? ⟧ ( just (+ 5) ∷ just (+ 7) ∷ just (0 ⊖ 3) ∷ just (+ 8) ∷ nothing ∷ []) nat! : ¡ ⟨ ℤ ⟩ ⇒ ¡ ⟨ ℕ ⟩ & ¡ ⟨ ℤ ⟩ nat! = loop {⟨ ℕ ⟩} nat? -- runNat! == ( just 5 ∷ just 7 ∷ nothing ∷ just (0 ⊖ 3) ∷ just (+ 8) ∷ nothing ∷ []) runNat! = C⟦ nat! ⟧ ( just (+ 5) ∷ just (+ 7) ∷ just (0 ⊖ 3) ∷ just (+ 8) ∷ nothing ∷ [])
{ "alphanum_fraction": 0.5245398773, "avg_line_length": 39.5151515152, "ext": "agda", "hexsha": "9d471d53cbe56967b95a7a5fa9cbd650e1f54c1c", "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/Examples/Transducers.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/Examples/Transducers.agda", "max_line_length": 90, "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/Examples/Transducers.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": 537, "size": 1304 }
module Structure.Operator.Field where import Lvl open import Logic open import Logic.Propositional open import Structure.Setoid open import Structure.Operator.Properties open import Structure.Operator.Ring open import Type record Field {ℓ ℓₑ} {T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_+_ : T → T → T) (_⋅_ : T → T → T) : Stmt{ℓ Lvl.⊔ ℓₑ} where field ⦃ divisionRing ⦄ : DivisionRing(_+_)(_⋅_) ⦃ [⋅]-commutativity ⦄ : Commutativity(_⋅_) open DivisionRing(divisionRing) public field -- Note: This excludes the trivial ring and is unprovable from the other field axioms, and models where this is true are always "trivial/singleton rings". ⦃ distinct-identities ⦄ : DistinctIdentities record FieldObject {ℓ ℓₑ} : Stmt{Lvl.𝐒(ℓ Lvl.⊔ ℓₑ)} where constructor intro field {T} : Type{ℓ} ⦃ equiv ⦄ : Equiv{ℓₑ}(T) _+_ : T → T → T _⋅_ : T → T → T ⦃ structure ⦄ : Field(_+_)(_⋅_) open Field(structure) public
{ "alphanum_fraction": 0.664921466, "avg_line_length": 30.8064516129, "ext": "agda", "hexsha": "af0bd9c62da276a5ad43e84450f0e46ee14723f1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Field.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Field.agda", "max_line_length": 159, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Field.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": 356, "size": 955 }
{-# OPTIONS --without-K --safe #-} -- Bundled version of a Cartesian Category module Categories.Category.Cartesian.Bundle where open import Level open import Categories.Category.Core using (Category) open import Categories.Category.Cartesian using (Cartesian) open import Categories.Category.Cartesian.Monoidal using (module CartesianMonoidal) open import Categories.Category.Monoidal using (MonoidalCategory) record CartesianCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field U : Category o ℓ e -- U for underlying cartesian : Cartesian U open Category U public open Cartesian cartesian public monoidalCategory : MonoidalCategory o ℓ e monoidalCategory = record { U = U ; monoidal = CartesianMonoidal.monoidal cartesian }
{ "alphanum_fraction": 0.7432258065, "avg_line_length": 29.8076923077, "ext": "agda", "hexsha": "38ed2e84eb287722a86f03b1e6feb7c4359e5281", "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/Cartesian/Bundle.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/Cartesian/Bundle.agda", "max_line_length": 83, "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/Cartesian/Bundle.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": 177, "size": 775 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Weakening {{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; wkEq; wkTerm; wkEqTerm) open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Tools.Product import Tools.PropositionalEquality as PE -- Weakening of neutrals in WHNF wkTermNe : ∀ {ρ Γ Δ k A} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩neNf k ∷ A → Δ ⊩neNf U.wk ρ k ∷ U.wk ρ A wkTermNe {ρ} [ρ] ⊢Δ (neNfₜ neK ⊢k k≡k) = neNfₜ (wkNeutral ρ neK) (T.wkTerm [ρ] ⊢Δ ⊢k) (~-wk [ρ] ⊢Δ k≡k) wkEqTermNe : ∀ {ρ Γ Δ k k′ A} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩neNf k ≡ k′ ∷ A → Δ ⊩neNf U.wk ρ k ≡ U.wk ρ k′ ∷ U.wk ρ A wkEqTermNe {ρ} [ρ] ⊢Δ (neNfₜ₌ neK neM k≡m) = neNfₜ₌ (wkNeutral ρ neK) (wkNeutral ρ neM) (~-wk [ρ] ⊢Δ k≡m) -- Weakening of reducible natural numbers mutual wkTermℕ : ∀ {ρ Γ Δ n} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩ℕ n ∷ℕ → Δ ⊩ℕ U.wk ρ n ∷ℕ wkTermℕ {ρ} [ρ] ⊢Δ (ℕₜ n d n≡n prop) = ℕₜ (U.wk ρ n) (wkRed:*:Term [ρ] ⊢Δ d) (≅ₜ-wk [ρ] ⊢Δ n≡n) (wkNatural-prop [ρ] ⊢Δ prop) wkNatural-prop : ∀ {ρ Γ Δ n} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Natural-prop Γ n → Natural-prop Δ (U.wk ρ n) wkNatural-prop ρ ⊢Δ (sucᵣ n) = sucᵣ (wkTermℕ ρ ⊢Δ n) wkNatural-prop ρ ⊢Δ zeroᵣ = zeroᵣ wkNatural-prop ρ ⊢Δ (ne nf) = ne (wkTermNe ρ ⊢Δ nf) mutual wkEqTermℕ : ∀ {ρ Γ Δ t u} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩ℕ t ≡ u ∷ℕ → Δ ⊩ℕ U.wk ρ t ≡ U.wk ρ u ∷ℕ wkEqTermℕ {ρ} [ρ] ⊢Δ (ℕₜ₌ k k′ d d′ t≡u prop) = ℕₜ₌ (U.wk ρ k) (U.wk ρ k′) (wkRed:*:Term [ρ] ⊢Δ d) (wkRed:*:Term [ρ] ⊢Δ d′) (≅ₜ-wk [ρ] ⊢Δ t≡u) (wk[Natural]-prop [ρ] ⊢Δ prop) wk[Natural]-prop : ∀ {ρ Γ Δ n n′} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → [Natural]-prop Γ n n′ → [Natural]-prop Δ (U.wk ρ n) (U.wk ρ n′) wk[Natural]-prop ρ ⊢Δ (sucᵣ [n≡n′]) = sucᵣ (wkEqTermℕ ρ ⊢Δ [n≡n′]) wk[Natural]-prop ρ ⊢Δ zeroᵣ = zeroᵣ wk[Natural]-prop ρ ⊢Δ (ne x) = ne (wkEqTermNe ρ ⊢Δ x) -- Empty wkTermEmpty : ∀ {ρ Γ Δ n} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩Empty n ∷Empty → Δ ⊩Empty U.wk ρ n ∷Empty wkTermEmpty {ρ} [ρ] ⊢Δ (Emptyₜ n d n≡n (ne prop)) = Emptyₜ (U.wk ρ n) (wkRed:*:Term [ρ] ⊢Δ d) (≅ₜ-wk [ρ] ⊢Δ n≡n) (ne (wkTermNe [ρ] ⊢Δ prop)) wk[Empty]-prop : ∀ {ρ Γ Δ n n′} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → [Empty]-prop Γ n n′ → [Empty]-prop Δ (U.wk ρ n) (U.wk ρ n′) wk[Empty]-prop ρ ⊢Δ (ne x) = ne (wkEqTermNe ρ ⊢Δ x) wkEqTermEmpty : ∀ {ρ Γ Δ t u} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩Empty t ≡ u ∷Empty → Δ ⊩Empty U.wk ρ t ≡ U.wk ρ u ∷Empty wkEqTermEmpty {ρ} [ρ] ⊢Δ (Emptyₜ₌ k k′ d d′ t≡u prop) = Emptyₜ₌ (U.wk ρ k) (U.wk ρ k′) (wkRed:*:Term [ρ] ⊢Δ d) (wkRed:*:Term [ρ] ⊢Δ d′) (≅ₜ-wk [ρ] ⊢Δ t≡u) (wk[Empty]-prop [ρ] ⊢Δ prop) -- Unit wkTermUnit : ∀ {ρ Γ Δ n} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩Unit n ∷Unit → Δ ⊩Unit U.wk ρ n ∷Unit wkTermUnit {ρ} [ρ] ⊢Δ (Unitₜ n d prop) = Unitₜ (U.wk ρ n) (wkRed:*:Term [ρ] ⊢Δ d) (wkWhnf ρ prop) wkEqTermUnit : ∀ {ρ Γ Δ t u} → ρ ∷ Δ ⊆ Γ → (⊢Δ : ⊢ Δ) → Γ ⊩Unit t ≡ u ∷Unit → Δ ⊩Unit U.wk ρ t ≡ U.wk ρ u ∷Unit wkEqTermUnit {ρ} [ρ] ⊢Δ (Unitₜ₌ ⊢t ⊢u) = Unitₜ₌ (T.wkTerm [ρ] ⊢Δ ⊢t) (T.wkTerm [ρ] ⊢Δ ⊢u) -- Weakening of the logical relation wk : ∀ {ρ Γ Δ A l} → ρ ∷ Δ ⊆ Γ → ⊢ Δ → Γ ⊩⟨ l ⟩ A → Δ ⊩⟨ l ⟩ U.wk ρ A wk ρ ⊢Δ (Uᵣ′ l′ l< ⊢Γ) = Uᵣ′ l′ l< ⊢Δ wk ρ ⊢Δ (ℕᵣ D) = ℕᵣ (wkRed:*: ρ ⊢Δ D) wk ρ ⊢Δ (Emptyᵣ D) = Emptyᵣ (wkRed:*: ρ ⊢Δ D) wk ρ ⊢Δ (Unitᵣ D) = Unitᵣ (wkRed:*: ρ ⊢Δ D) wk {ρ} [ρ] ⊢Δ (ne′ K D neK K≡K) = ne′ (U.wk ρ K) (wkRed:*: [ρ] ⊢Δ D) (wkNeutral ρ neK) (~-wk [ρ] ⊢Δ K≡K) wk {ρ} {Γ} {Δ} {A} {l} [ρ] ⊢Δ (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢ρF = T.wk [ρ] ⊢Δ ⊢F [F]′ : ∀ {ρ ρ′ E} ([ρ] : ρ ∷ E ⊆ Δ) ([ρ′] : ρ′ ∷ Δ ⊆ Γ) (⊢E : ⊢ E) → E ⊩⟨ l ⟩ U.wk ρ (U.wk ρ′ F) [F]′ {ρ} {ρ′} [ρ] [ρ′] ⊢E = irrelevance′ (PE.sym (wk-comp ρ ρ′ F)) ([F] ([ρ] •ₜ [ρ′]) ⊢E) [a]′ : ∀ {ρ ρ′ E a} ([ρ] : ρ ∷ E ⊆ Δ) ([ρ′] : ρ′ ∷ Δ ⊆ Γ) (⊢E : ⊢ E) ([a] : E ⊩⟨ l ⟩ a ∷ U.wk ρ (U.wk ρ′ F) / [F]′ [ρ] [ρ′] ⊢E) → E ⊩⟨ l ⟩ a ∷ U.wk (ρ • ρ′) F / [F] ([ρ] •ₜ [ρ′]) ⊢E [a]′ {ρ} {ρ′} [ρ] [ρ′] ⊢E [a] = irrelevanceTerm′ (wk-comp ρ ρ′ F) ([F]′ [ρ] [ρ′] ⊢E) ([F] ([ρ] •ₜ [ρ′]) ⊢E) [a] [G]′ : ∀ {ρ ρ′ E a} ([ρ] : ρ ∷ E ⊆ Δ) ([ρ′] : ρ′ ∷ Δ ⊆ Γ) (⊢E : ⊢ E) ([a] : E ⊩⟨ l ⟩ a ∷ U.wk ρ (U.wk ρ′ F) / [F]′ [ρ] [ρ′] ⊢E) → E ⊩⟨ l ⟩ U.wk (lift (ρ • ρ′)) G [ a ] [G]′ η η′ ⊢E [a] = [G] (η •ₜ η′) ⊢E ([a]′ η η′ ⊢E [a]) in Πᵣ′ (U.wk ρ F) (U.wk (lift ρ) G) (T.wkRed:*: [ρ] ⊢Δ D) ⊢ρF (T.wk (lift [ρ]) (⊢Δ ∙ ⊢ρF) ⊢G) (≅-wk [ρ] ⊢Δ A≡A) (λ {ρ₁} [ρ₁] ⊢Δ₁ → irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] → irrelevance′ (wk-comp-subst ρ₁ ρ G) ([G]′ [ρ₁] [ρ] ⊢Δ₁ [a])) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] [b] [a≡b] → let [a≡b]′ = irrelevanceEqTerm′ (wk-comp ρ₁ ρ F) ([F]′ [ρ₁] [ρ] ⊢Δ₁) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁) [a≡b] in irrelevanceEq″ (wk-comp-subst ρ₁ ρ G) (wk-comp-subst ρ₁ ρ G) ([G]′ [ρ₁] [ρ] ⊢Δ₁ [a]) (irrelevance′ (wk-comp-subst ρ₁ ρ G) ([G]′ [ρ₁] [ρ] ⊢Δ₁ [a])) (G-ext ([ρ₁] •ₜ [ρ]) ⊢Δ₁ ([a]′ [ρ₁] [ρ] ⊢Δ₁ [a]) ([a]′ [ρ₁] [ρ] ⊢Δ₁ [b]) [a≡b]′)) wk {ρ} {Γ} {Δ} {A} {l} [ρ] ⊢Δ (Σᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢ρF = T.wk [ρ] ⊢Δ ⊢F [F]′ : ∀ {ρ ρ′ E} ([ρ] : ρ ∷ E ⊆ Δ) ([ρ′] : ρ′ ∷ Δ ⊆ Γ) (⊢E : ⊢ E) → E ⊩⟨ l ⟩ U.wk ρ (U.wk ρ′ F) [F]′ {ρ} {ρ′} [ρ] [ρ′] ⊢E = irrelevance′ (PE.sym (wk-comp ρ ρ′ F)) ([F] ([ρ] •ₜ [ρ′]) ⊢E) [a]′ : ∀ {ρ ρ′ E a} ([ρ] : ρ ∷ E ⊆ Δ) ([ρ′] : ρ′ ∷ Δ ⊆ Γ) (⊢E : ⊢ E) ([a] : E ⊩⟨ l ⟩ a ∷ U.wk ρ (U.wk ρ′ F) / [F]′ [ρ] [ρ′] ⊢E) → E ⊩⟨ l ⟩ a ∷ U.wk (ρ • ρ′) F / [F] ([ρ] •ₜ [ρ′]) ⊢E [a]′ {ρ} {ρ′} [ρ] [ρ′] ⊢E [a] = irrelevanceTerm′ (wk-comp ρ ρ′ F) ([F]′ [ρ] [ρ′] ⊢E) ([F] ([ρ] •ₜ [ρ′]) ⊢E) [a] [G]′ : ∀ {ρ ρ′ E a} ([ρ] : ρ ∷ E ⊆ Δ) ([ρ′] : ρ′ ∷ Δ ⊆ Γ) (⊢E : ⊢ E) ([a] : E ⊩⟨ l ⟩ a ∷ U.wk ρ (U.wk ρ′ F) / [F]′ [ρ] [ρ′] ⊢E) → E ⊩⟨ l ⟩ U.wk (lift (ρ • ρ′)) G [ a ] [G]′ η η′ ⊢E [a] = [G] (η •ₜ η′) ⊢E ([a]′ η η′ ⊢E [a]) in Σᵣ′ (U.wk ρ F) (U.wk (lift ρ) G) (T.wkRed:*: [ρ] ⊢Δ D) ⊢ρF (T.wk (lift [ρ]) (⊢Δ ∙ ⊢ρF) ⊢G) (≅-wk [ρ] ⊢Δ A≡A) (λ {ρ₁} [ρ₁] ⊢Δ₁ → irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] → irrelevance′ (wk-comp-subst ρ₁ ρ G) ([G]′ [ρ₁] [ρ] ⊢Δ₁ [a])) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] [b] [a≡b] → let [a≡b]′ = irrelevanceEqTerm′ (wk-comp ρ₁ ρ F) ([F]′ [ρ₁] [ρ] ⊢Δ₁) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁) [a≡b] in irrelevanceEq″ (wk-comp-subst ρ₁ ρ G) (wk-comp-subst ρ₁ ρ G) ([G]′ [ρ₁] [ρ] ⊢Δ₁ [a]) (irrelevance′ (wk-comp-subst ρ₁ ρ G) ([G]′ [ρ₁] [ρ] ⊢Δ₁ [a])) (G-ext ([ρ₁] •ₜ [ρ]) ⊢Δ₁ ([a]′ [ρ₁] [ρ] ⊢Δ₁ [a]) ([a]′ [ρ₁] [ρ] ⊢Δ₁ [b]) [a≡b]′)) wk ρ ⊢Δ (emb 0<1 x) = emb 0<1 (wk ρ ⊢Δ x) wkEq : ∀ {ρ Γ Δ A B l} → ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / [A] → Δ ⊩⟨ l ⟩ U.wk ρ A ≡ U.wk ρ B / wk [ρ] ⊢Δ [A] wkEq ρ ⊢Δ (Uᵣ′ _ _ _) PE.refl = PE.refl wkEq ρ ⊢Δ (ℕᵣ D) A≡B = wkRed* ρ ⊢Δ A≡B wkEq ρ ⊢Δ (Emptyᵣ D) A≡B = wkRed* ρ ⊢Δ A≡B wkEq ρ ⊢Δ (Unitᵣ D) A≡B = wkRed* ρ ⊢Δ A≡B wkEq {ρ} [ρ] ⊢Δ (ne′ _ _ _ _) (ne₌ M D′ neM K≡M) = ne₌ (U.wk ρ M) (wkRed:*: [ρ] ⊢Δ D′) (wkNeutral ρ neM) (~-wk [ρ] ⊢Δ K≡M) wkEq {ρ} [ρ] ⊢Δ (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = B₌ (U.wk ρ F′) (U.wk (lift ρ) G′) (T.wkRed* [ρ] ⊢Δ D′) (≅-wk [ρ] ⊢Δ A≡B) (λ {ρ₁} [ρ₁] ⊢Δ₁ → irrelevanceEq″ (PE.sym (wk-comp ρ₁ ρ F)) (PE.sym (wk-comp ρ₁ ρ F′)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁) (irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) ([F≡F′] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] → let [a]′ = irrelevanceTerm′ (wk-comp ρ₁ ρ F) (irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁) [a] in irrelevanceEq″ (wk-comp-subst ρ₁ ρ G) (wk-comp-subst ρ₁ ρ G′) ([G] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′) (irrelevance′ (wk-comp-subst ρ₁ ρ G) ([G] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′)) ([G≡G′] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′)) wkEq {ρ} [ρ] ⊢Δ (Σᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = B₌ (U.wk ρ F′) (U.wk (lift ρ) G′) (T.wkRed* [ρ] ⊢Δ D′) (≅-wk [ρ] ⊢Δ A≡B) (λ {ρ₁} [ρ₁] ⊢Δ₁ → irrelevanceEq″ (PE.sym (wk-comp ρ₁ ρ F)) (PE.sym (wk-comp ρ₁ ρ F′)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁) (irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) ([F≡F′] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] → let [a]′ = irrelevanceTerm′ (wk-comp ρ₁ ρ F) (irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁)) ([F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁) [a] in irrelevanceEq″ (wk-comp-subst ρ₁ ρ G) (wk-comp-subst ρ₁ ρ G′) ([G] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′) (irrelevance′ (wk-comp-subst ρ₁ ρ G) ([G] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′)) ([G≡G′] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′)) wkEq ρ ⊢Δ (emb 0<1 x) A≡B = wkEq ρ ⊢Δ x A≡B wkTerm : ∀ {ρ Γ Δ A t l} ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ∷ A / [A] → Δ ⊩⟨ l ⟩ U.wk ρ t ∷ U.wk ρ A / wk [ρ] ⊢Δ [A] wkTerm {ρ} [ρ] ⊢Δ (Uᵣ′ .⁰ 0<1 ⊢Γ) (Uₜ A d typeA A≡A [t]) = Uₜ (U.wk ρ A) (wkRed:*:Term [ρ] ⊢Δ d) (wkType ρ typeA) (≅ₜ-wk [ρ] ⊢Δ A≡A) (wk [ρ] ⊢Δ [t]) wkTerm ρ ⊢Δ (ℕᵣ D) [t] = wkTermℕ ρ ⊢Δ [t] wkTerm ρ ⊢Δ (Emptyᵣ D) [t] = wkTermEmpty ρ ⊢Δ [t] wkTerm ρ ⊢Δ (Unitᵣ D) [t] = wkTermUnit ρ ⊢Δ [t] wkTerm {ρ} [ρ] ⊢Δ (ne′ K D neK K≡K) (neₜ k d nf) = neₜ (U.wk ρ k) (wkRed:*:Term [ρ] ⊢Δ d) (wkTermNe [ρ] ⊢Δ nf) wkTerm {ρ} [ρ] ⊢Δ (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f d funcF f≡f [f] [f]₁) = Πₜ (U.wk ρ f) (wkRed:*:Term [ρ] ⊢Δ d) (wkFunction ρ funcF) (≅ₜ-wk [ρ] ⊢Δ f≡f) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] [b] [a≡b] → let F-compEq = wk-comp ρ₁ ρ F G-compEq = wk-comp-subst ρ₁ ρ G [F]₁ = [F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [F]₂ = irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) [F]₁ [a]′ = irrelevanceTerm′ F-compEq [F]₂ [F]₁ [a] [b]′ = irrelevanceTerm′ F-compEq [F]₂ [F]₁ [b] [G]₁ = [G] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′ [G]₂ = irrelevance′ G-compEq [G]₁ [a≡b]′ = irrelevanceEqTerm′ F-compEq [F]₂ [F]₁ [a≡b] in irrelevanceEqTerm″ (PE.cong (λ x → x ∘ _) (PE.sym (wk-comp ρ₁ ρ _))) (PE.cong (λ x → x ∘ _) (PE.sym (wk-comp ρ₁ ρ _))) G-compEq [G]₁ [G]₂ ([f] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′ [b]′ [a≡b]′)) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] → let [F]₁ = [F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [F]₂ = irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) [F]₁ [a]′ = irrelevanceTerm′ (wk-comp ρ₁ ρ F) [F]₂ [F]₁ [a] [G]₁ = [G] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′ [G]₂ = irrelevance′ (wk-comp-subst ρ₁ ρ G) [G]₁ in irrelevanceTerm″ (wk-comp-subst ρ₁ ρ G) (PE.cong (λ x → x ∘ _) (PE.sym (wk-comp ρ₁ ρ _))) [G]₁ [G]₂ ([f]₁ ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′)) wkTerm {ρ} [ρ] ⊢Δ [A]@(Σᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Σₜ p d pProd p≅p [fst] [snd]) = let [ρF] = irrelevance′ (PE.sym (wk-comp id ρ F)) ([F] [ρ] (wf (T.wk [ρ] ⊢Δ ⊢F))) [ρfst] = wkTerm [ρ] ⊢Δ ([F] id (wf ⊢F)) [fst] [ρfst]′ = (irrelevanceTerm′ (PE.begin U.wk ρ (U.wk id F) PE.≡⟨ PE.cong (U.wk ρ) (wk-id F) ⟩ U.wk ρ F PE.≡⟨ PE.sym (wk-id (U.wk ρ F)) ⟩ U.wk id (U.wk ρ F) PE.∎) (wk [ρ] ⊢Δ ([F] id (wf ⊢F))) [ρF] [ρfst]) [ρsnd] = wkTerm [ρ] ⊢Δ ([G] id (wf ⊢F) [fst]) [snd] [ρG]′ = (irrelevance′ (wk-comp-subst id ρ G) ([G] [ρ] (wf (T.wk [ρ] ⊢Δ ⊢F)) (irrelevanceTerm′ (wk-comp id ρ F) [ρF] ([F] [ρ] (wf (T.wk [ρ] ⊢Δ ⊢F))) [ρfst]′))) [ρsnd]′ = irrelevanceTerm′ (PE.begin U.wk ρ (U.wk (lift id) G [ fst p ]) PE.≡⟨ PE.cong (λ x → U.wk ρ (x [ fst p ])) (wk-lift-id G) ⟩ U.wk ρ (G [ fst p ]) PE.≡⟨ wk-β G ⟩ (U.wk (lift ρ) G) [ fst (U.wk ρ p) ] PE.≡⟨ PE.cong (λ x → x [ fst (U.wk ρ p) ]) (PE.sym (wk-lift-id (U.wk (lift ρ) G))) ⟩ (U.wk (lift id) (U.wk (lift ρ) G)) [ fst (U.wk ρ p) ] PE.∎) (wk [ρ] ⊢Δ ([G] id (wf ⊢F) [fst])) [ρG]′ [ρsnd] in Σₜ (U.wk ρ p) (wkRed:*:Term [ρ] ⊢Δ d) (wkProduct ρ pProd) (≅ₜ-wk [ρ] ⊢Δ p≅p) [ρfst]′ [ρsnd]′ wkTerm ρ ⊢Δ (emb 0<1 x) t = wkTerm ρ ⊢Δ x t wkEqTerm : ∀ {ρ Γ Δ A t u l} ([ρ] : ρ ∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] → Δ ⊩⟨ l ⟩ U.wk ρ t ≡ U.wk ρ u ∷ U.wk ρ A / wk [ρ] ⊢Δ [A] wkEqTerm {ρ} [ρ] ⊢Δ (Uᵣ′ .⁰ 0<1 ⊢Γ) (Uₜ₌ A B d d′ typeA typeB A≡B [t] [u] [t≡u]) = Uₜ₌ (U.wk ρ A) (U.wk ρ B) (wkRed:*:Term [ρ] ⊢Δ d) (wkRed:*:Term [ρ] ⊢Δ d′) (wkType ρ typeA) (wkType ρ typeB) (≅ₜ-wk [ρ] ⊢Δ A≡B) (wk [ρ] ⊢Δ [t]) (wk [ρ] ⊢Δ [u]) (wkEq [ρ] ⊢Δ [t] [t≡u]) wkEqTerm ρ ⊢Δ (ℕᵣ D) [t≡u] = wkEqTermℕ ρ ⊢Δ [t≡u] wkEqTerm ρ ⊢Δ (Emptyᵣ D) [t≡u] = wkEqTermEmpty ρ ⊢Δ [t≡u] wkEqTerm ρ ⊢Δ (Unitᵣ D) [t≡u] = wkEqTermUnit ρ ⊢Δ [t≡u] wkEqTerm {ρ} [ρ] ⊢Δ (ne′ K D neK K≡K) (neₜ₌ k m d d′ nf) = neₜ₌ (U.wk ρ k) (U.wk ρ m) (wkRed:*:Term [ρ] ⊢Δ d) (wkRed:*:Term [ρ] ⊢Δ d′) (wkEqTermNe [ρ] ⊢Δ nf) wkEqTerm {ρ} [ρ] ⊢Δ (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ₌ f g d d′ funcF funcG f≡g [t] [u] [f≡g]) = let [A] = Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext in Πₜ₌ (U.wk ρ f) (U.wk ρ g) (wkRed:*:Term [ρ] ⊢Δ d) (wkRed:*:Term [ρ] ⊢Δ d′) (wkFunction ρ funcF) (wkFunction ρ funcG) (≅ₜ-wk [ρ] ⊢Δ f≡g) (wkTerm [ρ] ⊢Δ [A] [t]) (wkTerm [ρ] ⊢Δ [A] [u]) (λ {ρ₁} [ρ₁] ⊢Δ₁ [a] → let [F]₁ = [F] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [F]₂ = irrelevance′ (PE.sym (wk-comp ρ₁ ρ F)) [F]₁ [a]′ = irrelevanceTerm′ (wk-comp ρ₁ ρ F) [F]₂ [F]₁ [a] [G]₁ = [G] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′ [G]₂ = irrelevance′ (wk-comp-subst ρ₁ ρ G) [G]₁ in irrelevanceEqTerm″ (PE.cong (λ y → y ∘ _) (PE.sym (wk-comp ρ₁ ρ _))) (PE.cong (λ y → y ∘ _) (PE.sym (wk-comp ρ₁ ρ _))) (wk-comp-subst ρ₁ ρ G) [G]₁ [G]₂ ([f≡g] ([ρ₁] •ₜ [ρ]) ⊢Δ₁ [a]′)) wkEqTerm {ρ} [ρ] ⊢Δ [A]@(Σᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Σₜ₌ p r d d′ pProd rProd p≅r [t] [u] [fstp] [fstr] [fst≡] [snd≡]) = let [A] = Σᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext ⊢Γ = wf ⊢F ρidF≡idρF = PE.begin U.wk ρ (U.wk id F) PE.≡⟨ PE.cong (U.wk ρ) (wk-id F) ⟩ U.wk ρ F PE.≡⟨ PE.sym (wk-id (U.wk ρ F)) ⟩ U.wk id (U.wk ρ F) PE.∎ [ρF] = irrelevance′ (PE.sym (wk-comp id ρ F)) ([F] [ρ] (wf (T.wk [ρ] ⊢Δ ⊢F))) [ρfstp] = wkTerm [ρ] ⊢Δ ([F] id ⊢Γ) [fstp] [ρfstp]′ = irrelevanceTerm′ ρidF≡idρF (wk [ρ] ⊢Δ ([F] id ⊢Γ)) [ρF] [ρfstp] [ρfstr] = wkTerm [ρ] ⊢Δ ([F] id ⊢Γ) [fstr] [ρfstr]′ = irrelevanceTerm′ ρidF≡idρF (wk [ρ] ⊢Δ ([F] id ⊢Γ)) [ρF] [ρfstr] [ρfst≡] = wkEqTerm [ρ] ⊢Δ ([F] id ⊢Γ) [fst≡] [ρfst≡]′ = irrelevanceEqTerm′ ρidF≡idρF (wk [ρ] ⊢Δ ([F] id ⊢Γ)) [ρF] [ρfst≡] [ρsnd≡] = wkEqTerm [ρ] ⊢Δ ([G] id ⊢Γ [fstp]) [snd≡] [ρG]′ = (irrelevance′ (wk-comp-subst id ρ G) ([G] [ρ] (wf (T.wk [ρ] ⊢Δ ⊢F)) (irrelevanceTerm′ (wk-comp id ρ F) [ρF] ([F] [ρ] (wf (T.wk [ρ] ⊢Δ ⊢F))) [ρfstp]′))) [ρsnd≡]′ = irrelevanceEqTerm′ (PE.begin U.wk ρ (U.wk (lift id) G [ fst p ]) PE.≡⟨ PE.cong (λ x → U.wk ρ (x [ fst p ])) (wk-lift-id G) ⟩ U.wk ρ (G [ fst p ]) PE.≡⟨ wk-β G ⟩ (U.wk (lift ρ) G) [ fst (U.wk ρ p) ] PE.≡⟨ PE.cong (λ x → x [ fst (U.wk ρ p) ]) (PE.sym (wk-lift-id (U.wk (lift ρ) G))) ⟩ (U.wk (lift id) (U.wk (lift ρ) G)) [ fst (U.wk ρ p) ] PE.∎) (wk [ρ] ⊢Δ ([G] id (wf ⊢F) [fstp])) [ρG]′ [ρsnd≡] in Σₜ₌ (U.wk ρ p) (U.wk ρ r) (wkRed:*:Term [ρ] ⊢Δ d) (wkRed:*:Term [ρ] ⊢Δ d′) (wkProduct ρ pProd) (wkProduct ρ rProd) (≅ₜ-wk [ρ] ⊢Δ p≅r) (wkTerm [ρ] ⊢Δ [A] [t]) (wkTerm [ρ] ⊢Δ [A] [u]) [ρfstp]′ [ρfstr]′ [ρfst≡]′ [ρsnd≡]′ wkEqTerm ρ ⊢Δ (emb 0<1 x) t≡u = wkEqTerm ρ ⊢Δ x t≡u
{ "alphanum_fraction": 0.359954482, "avg_line_length": 48.5753768844, "ext": "agda", "hexsha": "fe532f3f0b073427751287f9437af3cbae157ce8", "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/Weakening.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/Weakening.agda", "max_line_length": 102, "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/Weakening.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 9552, "size": 19333 }
module FlexInterpreter where data Ty : Set where nat : Ty arr : Ty -> Ty -> Ty data Exp : Ty -> Set where zero : Exp nat suc : Exp (arr nat nat) pred : Exp (arr nat nat) app : {a b : Ty} -> Exp (arr a b) -> Exp a -> Exp b data Nat : Set where zero : Nat suc : Nat -> Nat Sem : Ty -> Set Sem nat = Nat Sem (arr a b) = Sem a -> Sem b eval : {a : Ty} -> Exp a -> Sem a eval zero = zero eval suc = suc eval pred zero = zero eval pred (suc n) = n eval (app f e) = eval f (eval e)
{ "alphanum_fraction": 0.568, "avg_line_length": 18.5185185185, "ext": "agda", "hexsha": "f46b7a2b81db5c1f6372e86d6d214c9ff82695a2", "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": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "test/features/FlexInterpreter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "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": "dagit/agda", "max_issues_repo_path": "test/features/FlexInterpreter.agda", "max_line_length": 54, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dagit/agda", "max_stars_repo_path": "test/features/FlexInterpreter.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 179, "size": 500 }
-- Ordinals as defined in the HoTT book. {-# OPTIONS --without-K --safe #-} module Ordinal.HoTT where open import Data.Empty using (⊥) open import Data.Unit using (⊤) open import Induction.WellFounded using (Acc ; acc ; WellFounded) open import Level using (Level ; _⊔_ ; 0ℓ) renaming (suc to lsuc) open import Relation.Binary using (Rel ; IsEquivalence ; Transitive) private variable α β γ ρ ε : Level A B C : Set α record _↔_ (A : Set α) (B : Set β) : Set (α ⊔ β) where field forth : A → B back : B → A open _↔_ public IsExtensional : ∀ {α} {A : Set α} (_≈_ : Rel A ε) (_<_ : Rel A ρ) → Set (α ⊔ ε ⊔ ρ) IsExtensional _≈_ _<_ = ∀ {a b} → (∀ c → (c < a) ↔ (c < b)) → a ≈ b record IsOrdinal (A : Set α) ε ρ : Set (α ⊔ lsuc (ε ⊔ ρ)) where field _≈_ : Rel A ε ≈-equiv : IsEquivalence _≈_ _<_ : Rel A ρ <-wf : WellFounded _<_ <-ext : IsExtensional _≈_ _<_ <-trans : Transitive _<_ open IsEquivalence ≈-equiv public using () renaming ( refl to ≈-refl ; sym to ≈-sym ; trans to ≈-trans) open IsOrdinal public record Ordinal α ε ρ : Set (lsuc (α ⊔ ε ⊔ ρ)) where field _↓ : Set α isOrdinal : IsOrdinal _↓ ε ρ open Ordinal public zero : Ordinal 0ℓ 0ℓ 0ℓ zero = record { _↓ = ⊤ ; isOrdinal = record { _≈_ = λ _ _ → ⊤ ; ≈-equiv = _ ; _<_ = λ _ _ → ⊥ ; <-wf = λ _ → acc λ y () ; <-ext = _ ; <-trans = λ() } }
{ "alphanum_fraction": 0.5644820296, "avg_line_length": 20.8676470588, "ext": "agda", "hexsha": "86025d0dccc730b841a70e564bd012ec173515d7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_path": "src/Ordinal/HoTT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JLimperg/msc-thesis-code", "max_issues_repo_path": "src/Ordinal/HoTT.agda", "max_line_length": 83, "max_stars_count": 5, "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_path": "src/Ordinal/HoTT.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "num_tokens": 551, "size": 1419 }
module Part2_Agda_in_a_Nutshell where {- https://serokell.io/blog/agda-in-nutshell Danya Rogozin Monday, November 26th, 2018 Theorem proving in Agda based on a constructive logical framework. Dependently typed programming and theorem proving in Agda. Example use of Agda in the formalisation of algebra. ------------------------------------------------------------------------------ General dependently typed : based on variant of Martin-Löf type theory. Martin-Löf is constructive, so Agda doesn’t have default features for writing classical (in contrast to HOL or Isabelle). Agda : proof-assistant based on propositions-as-types. ------------------------------------------------------------------------------ Types in Agda datatypes introduced via GADTs -} data Writers : Set where Wilde Shelley Byron Sartre Camus : Writers data Literature : Set where DorianGrey Alastor ChildeHarold LaNausée L’Étranger : Literature data ℕ : Set where zero : ℕ suc : ℕ → ℕ {- Parameterized and indexed datatypes see: https://agda.readthedocs.io/en/latest/language/data-types.html#indexed-datatypes parameterized datatype - depends on parameter that should remain the same in the types of constructors -} data List (A : Set) : Set where Nil : List A Cons : A → List A → List A -- can have indexes that could differ from constructor to constructor -- Vec is parameterized by A and indexed by ℕ. data Vec (A : Set) : ℕ → Set where Nil : Vec A zero -- n is an implicit argument of the constructor. -- Cons is an example of a dependent function. Cons : {n : ℕ} → A → Vec A n → Vec A (suc n) -- defines types of finite cardinality -- Fin is a datatype indexed by a natural number. data Fin : ℕ → Set where -- zero reflects an empty set which is an element of any finite set zero : {n : ℕ} → Fin (suc n) -- suc applies the finite set i and yields a new finite set, larger than i on one element. suc : {n : ℕ} → Fin n → Fin (suc n) -- Vec and Fin in Agda are examples of dependent types, -- types that depend on values (e.g., natural numbers), not only on types. ------------------------------------------------------------------------------ -- Functions bookToWriter : Literature → Writers bookToWriter DorianGrey = Wilde bookToWriter Alastor = Shelley bookToWriter ChildeHarold = Byron bookToWriter LaNausée = Sartre bookToWriter L’Étranger = Camus -- A dependent function is a function that -- takes a term a of type A and -- returns some result of type B, where a may appear in B -- Here types A and B are explicit arguments. const₁ : (A B : Set) → A → B → A const₁ A B x y = x -- may take them implicitly: const₂ : {A B : Set} → A → B → A const₂ x y = x data Ireland : Set where Dublin : Ireland data England : Set where London : England data France : Set where Paris : France WriterToCountry : Writers → Set WriterToCountry Wilde = Ireland WriterToCountry Shelley = England WriterToCountry Byron = England WriterToCountry Sartre = France WriterToCountry Camus = France WriterToCity : (w : Writers) → WriterToCountry w WriterToCity Wilde = Dublin WriterToCity Shelley = London WriterToCity Byron = London WriterToCity Sartre = Paris WriterToCity Camus = Paris {- WriterToCity is a dependent function, because the type of the result depends on the argument. The type of a dependent function is called a Π-type. Generally, given function P: A → Set, then Π-type is a type of the function that assigns to every term t : A some object of type P t. In Agda : (t : A) → P t for some {A : Set} {P : A → Set} in context. Logically Π-type encodes intuitionistic universal quantifier. P is a predicate and some function of a type (t : A) → P t is a proof that for each t : A the property P has established. ------------------------------------------------------------------------------ Dependent pairs : Σ-type inductive predicate on two lists: -} data IsReverse {A : Set} : (xs ys : List A) → Set where ReverseNil : IsReverse [] [] ReverseCons : (x : A) (xs ys : List A) → IsReverse xs ys → IsReverse (x ∷ xs) (ys ++ [ x ]) {- IsReverse xs ys denotes that the list ys is equal to reversed xs. IsReverse is a datatype parameterized over a type A and indexed over two lists of elements of type A. prove theorem : for all list xs there exists list ys such that ys is a reversed list xs, i.e., produce a dependent pair, where the first projection of this pair is some list ys and the second one is a proof that ys is reversed list xs. Use the dependent pair type to prove existence: -} theoremReverse₁ : {A : Set} (xs : List A) → Σ (List A) (λ ys → IsReverse xs ys) theoremReverse₁ [] = [] , ReverseNil theoremReverse₁ (z ∷ zs) = let ys = proj₁ (theoremReverse₁ zs) in let ysProof = proj₂ (theoremReverse₁ zs) in ys ++ [ x ] , ReverseCons z zs ys ysProof {- Read the theoremReverse₁ signature as let A be type and xs be a list with elements of the type A, then there exists list ys, such that ys is the reversed list xs. proved by induction on xs and build ys for every case. Base case: if xs is empty, then we present an empty list as the desired list ys and ReverseNil is a proof that ys is equal to reversed list xs, because both of them are empty. Inductive step : xs is a non-empty List zs is smaller than z :: zs, so apply induction hypothesis to zs and show that :: preserves the desired property using the ReverseCons constructor. Generally, Σ-type is defined in Agda: -} record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where constructor _,_ field fst : A snd : B fst -- apply B to arg from first field {- Defined for arbitrary universes (see below). logical point of view : Σ A B there exists some element of a type A, such that this element satisfies property B i.e. Σ-type encodes constructive existential quantifier. To prove the existence of some object with desired property constructively, present the particular object and prove that object satisfies the property. ------------------------------------------------------------------------------ Universes Hierarchy of types : initiated by Bertrand Russell. Basic types (e.g., Nat, Bool) have a type called Set (i.e., Set₁) Universe polymorphism enables defining functions that can be called on types of arbitrary levels. E.g., -} s : {A B C : Set} → (A → B → C) → (A → B) → A → C s f g x = f x (g x) -- indicate that types A, B, C are types of arbitrary level a: s₁ : {a : Level} {A B C : Set a} → (A → B → C) → (A → B) → A → C s₁ f g x = f x (g x) -- generalize s further, because A, B and C in s₁ belong to the same level above, -- but these types may generally belong to different levels : s₂ : {a b c : Level} {A : Set a} {B : Set b} {C : Set c} → (A → B → C) → (A → B) → A → C s₂ f g x = f x (g x) -- most general version of s : a universe polymorphic dependent function S : {a b c : Level} {A : Set a} {B : A → Set b} {C : (x : A) → B x → Set c} → (f : (x : A) → (y : B x) → C x y) → (g : (x : A) → B x) → (x : A) → C x (g x) S f g x = f x (g x) ------------------------------------------------------------------------------ -- Records record Person : Set where field name : String country : String age : Int ------------------------------------------------------------------------------ -- Typeclasses are introduced in Agda as records. E.g., record Functor {a} (F : Set a → Set a) : Set (suc a) where field fmap : ∀ {A B} → (A → B) → F A → F B -- Instances may be declared either -- by constructing a record explicitly: instance ListFunctor₁ : Functor List ListFunctor₁ = record { fmap = map } -- or by using copatterns: instance ListFunctor₂ : Functor List fmap {{ListFunctor₂}} = map ------------------------------------------------------------------------------ -- Propositional equality -- The identity type is a datatype that reflects equality of terms in predicate logic. data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x -- examples using propositional equality: -- proof of distributivity of natural number multiplication over addition *-+-distr : ∀ a b c → (b + c) * a ≡ b * a + c * a *-+-distr a zero c = refl *-+-distr a (suc b) c = begin (suc b + c) * a ≡⟨ refl ⟩ a + (b + c) * a ≡⟨ cong (_+_ a) (*-+-distr a b c) ⟩ a + (b * a + c * a) ≡⟨ sym (+-assoc a (b * a) (c * a)) ⟩ suc b * a + c * a ∎ -- Proved by induction on b. -- When b equals zero, the equality holds trivially. -- Otherwise, equality is proved using the induction hypothesis. {- ------------------------------------------------------------------------------ Algebraic example A ring is an algebraic system ⟨R, +, ⋅, −, 0⟩ , where R is a non-empty set, 0 ∈ R, +, ⋅ are binary operations on R and − is a unary operation on R such that: 1. ∀a,b,c ∈ R, (a+b)+c=a+(b+c); 2. ∀a,b ∈ R, a+b=b+a; 3. ∀a ∈ R, −a + a = 0; 4. ∀a ∈ R, a + 0 = a; 5. ∀a,b,c ∈ R, (a+b)⋅c=(a⋅c)+(b⋅c); 6. ∀a,b,c ∈ R, a⋅(b+c)=(a⋅b)+(a⋅c). -} record Ring (R : Set) : Set₁ where constructor mkRing infixr 7 _·_ infixr 6 _+_ field θ : R -_ : R → R _+_ : R → R → R _·_ : R → R → R +-assoc : (a b c : R) → (a + b) + c ≡ a + (b + c) +-commute : (a b : R) → a + b ≡ b + a +-inv₁ : (a : R) → - a + a ≡ θ +-θ : (a : R) → a + θ ≡ a ·-distr-right : (a b c : R) → (a + b) · c ≡ (a · c) + (b · c) ·-distr-left : (a b c : R) → a · (b + c) ≡ (a · b) + (a · c) open Ring {{...}} public
{ "alphanum_fraction": 0.5987794787, "avg_line_length": 31.28802589, "ext": "agda", "hexsha": "a361115046bf251aa33a9515522f0969206c0987", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/paper/2018-11-danya-rogozin-serokell-constructive-and-non-cons-proofs-in-agda/src/Part2_Agda_in_a_Nutshell.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/paper/2018-11-danya-rogozin-serokell-constructive-and-non-cons-proofs-in-agda/src/Part2_Agda_in_a_Nutshell.agda", "max_line_length": 103, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/paper/2018-11-danya-rogozin-serokell-constructive-and-non-cons-proofs-in-agda/src/Part2_Agda_in_a_Nutshell.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 2790, "size": 9668 }
open import Agda.Primitive variable ℓ : Level A : Set ℓ postulate w/e : ∀ {a} {A : Set a} → A Sub : {a : Level} (A : Set a) → (Set → A) → Set hcomp-equivFillerSub : Sub A (λ { _ → w/e {_} {_} })
{ "alphanum_fraction": 0.5263157895, "avg_line_length": 16.0769230769, "ext": "agda", "hexsha": "53a208c1ecb43b3d8b98c68d26b2329a8b9d7c3d", "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/Issue5007-easteregg.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/Issue5007-easteregg.agda", "max_line_length": 54, "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/Issue5007-easteregg.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 87, "size": 209 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Sn where open import Cubical.HITs.Sn.Base public open import Cubical.HITs.Sn.Properties public
{ "alphanum_fraction": 0.7604790419, "avg_line_length": 27.8333333333, "ext": "agda", "hexsha": "51c5313e64522d9c31a15701ee0822d6b4ef985c", "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/Sn.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/Sn.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/HITs/Sn.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 45, "size": 167 }
module Luau.Run where open import Agda.Builtin.Equality using (_≡_; refl) open import Luau.Heap using (Heap; ∅) open import Luau.Syntax using (Block; return; _∙_; done) open import Luau.OpSem using (_⊢_⟶*_⊣_; refl; step) open import Luau.Value using (val) open import Properties.Step using (stepᴮ; step; return; done; error) open import Luau.RuntimeError using (RuntimeErrorᴮ) data RunResult {a} (H : Heap a) (B : Block a) : Set where return : ∀ V {B′ H′} → (H ⊢ B ⟶* (return (val V) ∙ B′) ⊣ H′) → RunResult H B done : ∀ {H′} → (H ⊢ B ⟶* done ⊣ H′) → RunResult H B error : ∀ {B′ H′} → (RuntimeErrorᴮ H′ B′) → (H ⊢ B ⟶* B′ ⊣ H′) → RunResult H B {-# TERMINATING #-} run′ : ∀ {a} H B → RunResult {a} H B run′ H B with stepᴮ H B run′ H B | step H′ B′ D with run′ H′ B′ run′ H B | step H′ B′ D | return V D′ = return V (step D D′) run′ H B | step H′ B′ D | done D′ = done (step D D′) run′ H B | step H′ B′ D | error E D′ = error E (step D D′) run′ H _ | return V refl = return V refl run′ H _ | done refl = done refl run′ H B | error E = error E refl run : ∀ {a} B → RunResult {a} ∅ B run = run′ ∅
{ "alphanum_fraction": 0.6014492754, "avg_line_length": 38.0689655172, "ext": "agda", "hexsha": "d84f75de4a64d99816bc5154179fe552a7bf5591", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Luau/Run.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Luau/Run.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Luau/Run.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 440, "size": 1104 }
{-# OPTIONS --without-K #-} -- Definition of Pi with fractionals module PiFrac2 where -- From the standard library: open import Data.Empty using (⊥) open import Data.Unit using (⊤; tt) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_; _,_; proj₁; proj₂) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂) -- The basic types we add: open import Singleton infix 80 ●_ 𝟙/●_ infixr 70 _×ᵤ_ infixr 60 _+ᵤ_ infixr 50 _⊚_ ------------------------------------------------------------------------------ -- Pi with fractionals -- The following are all mutually dependent: data 𝕌 : Set -- 𝕌niverse of types ⟦_⟧ : (A : 𝕌) → Set -- denotation of types data _⟷_ : 𝕌 → 𝕌 → Set -- type equivalences eval : {A B : 𝕌} → (A ⟷ B) → ⟦ A ⟧ → ⟦ B ⟧ -- evaluating an equivalence data 𝕌 where 𝟘 : 𝕌 𝟙 : 𝕌 _+ᵤ_ : 𝕌 → 𝕌 → 𝕌 _×ᵤ_ : 𝕌 → 𝕌 → 𝕌 ●_ : {A : 𝕌} → ⟦ A ⟧ → 𝕌 𝟙/●_ : {A : 𝕌} → ⟦ A ⟧ → 𝕌 ⟦ 𝟘 ⟧ = ⊥ ⟦ 𝟙 ⟧ = ⊤ ⟦ t₁ +ᵤ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ t₁ ×ᵤ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ⟦ ● v ⟧ = Singleton _ v ⟦ 𝟙/● v ⟧ = Recip _ v data _⟷_ where unite₊l : {t : 𝕌} → 𝟘 +ᵤ t ⟷ t uniti₊l : {t : 𝕌} → t ⟷ 𝟘 +ᵤ t unite₊r : {t : 𝕌} → t +ᵤ 𝟘 ⟷ t uniti₊r : {t : 𝕌} → t ⟷ t +ᵤ 𝟘 swap₊ : {t₁ t₂ : 𝕌} → t₁ +ᵤ t₂ ⟷ t₂ +ᵤ t₁ assocl₊ : {t₁ t₂ t₃ : 𝕌} → t₁ +ᵤ (t₂ +ᵤ t₃) ⟷ (t₁ +ᵤ t₂) +ᵤ t₃ assocr₊ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤ t₂) +ᵤ t₃ ⟷ t₁ +ᵤ (t₂ +ᵤ t₃) unite⋆l : {t : 𝕌} → 𝟙 ×ᵤ t ⟷ t uniti⋆l : {t : 𝕌} → t ⟷ 𝟙 ×ᵤ t unite⋆r : {t : 𝕌} → t ×ᵤ 𝟙 ⟷ t uniti⋆r : {t : 𝕌} → t ⟷ t ×ᵤ 𝟙 swap⋆ : {t₁ t₂ : 𝕌} → t₁ ×ᵤ t₂ ⟷ t₂ ×ᵤ t₁ assocl⋆ : {t₁ t₂ t₃ : 𝕌} → t₁ ×ᵤ (t₂ ×ᵤ t₃) ⟷ (t₁ ×ᵤ t₂) ×ᵤ t₃ assocr⋆ : {t₁ t₂ t₃ : 𝕌} → (t₁ ×ᵤ t₂) ×ᵤ t₃ ⟷ t₁ ×ᵤ (t₂ ×ᵤ t₃) absorbr : {t : 𝕌} → 𝟘 ×ᵤ t ⟷ 𝟘 absorbl : {t : 𝕌} → t ×ᵤ 𝟘 ⟷ 𝟘 factorzr : {t : 𝕌} → 𝟘 ⟷ t ×ᵤ 𝟘 factorzl : {t : 𝕌} → 𝟘 ⟷ 𝟘 ×ᵤ t dist : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤ t₂) ×ᵤ t₃ ⟷ (t₁ ×ᵤ t₃) +ᵤ (t₂ ×ᵤ t₃) factor : {t₁ t₂ t₃ : 𝕌} → (t₁ ×ᵤ t₃) +ᵤ (t₂ ×ᵤ t₃) ⟷ (t₁ +ᵤ t₂) ×ᵤ t₃ distl : {t₁ t₂ t₃ : 𝕌} → t₁ ×ᵤ (t₂ +ᵤ t₃) ⟷ (t₁ ×ᵤ t₂) +ᵤ (t₁ ×ᵤ t₃) factorl : {t₁ t₂ t₃ : 𝕌 } → (t₁ ×ᵤ t₂) +ᵤ (t₁ ×ᵤ t₃) ⟷ t₁ ×ᵤ (t₂ +ᵤ t₃) id⟷ : {t : 𝕌} → t ⟷ t _⊚_ : {t₁ t₂ t₃ : 𝕌} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) _⊕_ : {t₁ t₂ t₃ t₄ : 𝕌} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (t₁ +ᵤ t₂ ⟷ t₃ +ᵤ t₄) _⊗_ : {t₁ t₂ t₃ t₄ : 𝕌} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (t₁ ×ᵤ t₂ ⟷ t₃ ×ᵤ t₄) -- new operations on Singleton {-- lift : {t₁ t₂ : 𝕌} → {v₁ : ⟦ t₁ ⟧} → (c : t₁ ⟷ t₂) → ((● v₁) ⟷ (● (eval c v₁))) tensorl : {t₁ t₂ : 𝕌} {v₁ : ⟦ t₁ ⟧} {v₂ : ⟦ t₂ ⟧} → ●_ {A = t₁ ×ᵤ t₂} (v₁ , v₂) ⟷ ● v₁ ×ᵤ ● v₂ tensorr : {t₁ t₂ : 𝕌} {v₁ : ⟦ t₁ ⟧} {v₂ : ⟦ t₂ ⟧} → ● v₁ ×ᵤ ● v₂ ⟷ ●_ {A = t₁ ×ᵤ t₂} (v₁ , v₂) plusll : {t₁ t₂ : 𝕌} {v : ⟦ t₁ ⟧} → ●_ {A = t₁ +ᵤ t₂} (inj₁ v) ⟷ ● v pluslr : {t₁ t₂ : 𝕌} {v : ⟦ t₁ ⟧} → ● v ⟷ ●_ {A = t₁ +ᵤ t₂} (inj₁ v) plusrl : {t₁ t₂ : 𝕌} {v : ⟦ t₂ ⟧} → ●_ {A = t₁ +ᵤ t₂} (inj₂ v) ⟷ ● v plusrr : {t₁ t₂ : 𝕌} {v : ⟦ t₂ ⟧} → ● v ⟷ ●_ {A = t₁ +ᵤ t₂} (inj₂ v) fracl : {t₁ t₂ : 𝕌} {v₁ : ⟦ t₁ ⟧} {v₂ : ⟦ t₂ ⟧} → 𝟙/●_ {A = t₁ ×ᵤ t₂} (v₁ , v₂) ⟷ 𝟙/● v₁ ×ᵤ 𝟙/● v₂ fracr : {t₁ t₂ : 𝕌} {v₁ : ⟦ t₁ ⟧} {v₂ : ⟦ t₂ ⟧} → 𝟙/● v₁ ×ᵤ 𝟙/● v₂ ⟷ 𝟙/●_ {A = t₁ ×ᵤ t₂} (v₁ , v₂) --} -- fractionals η : {t : 𝕌} → (v : ⟦ t ⟧) → 𝟙 ⟷ ● v ×ᵤ 𝟙/● v ε : {t : 𝕌} → (v : ⟦ t ⟧) → ● v ×ᵤ 𝟙/● v ⟷ 𝟙 -- double lift prop eq {-- ll : ∀ {t : 𝕌} {v : ⟦ t ⟧} {w : ⟦ ● v ⟧} → ●_ {A = ● v} w ⟷ ● v == : ∀ {t₁ t₂ : 𝕌} {v : ⟦ t₁ ⟧} {w w' : ⟦ t₂ ⟧} → (● v ⟷ ● w) → (w ≡ w') → (● v ⟷ ● w') --} eval unite₊l (inj₂ v) = v eval uniti₊l v = inj₂ v eval unite₊r (inj₁ v) = v eval uniti₊r v = inj₁ v eval swap₊ (inj₁ v) = inj₂ v eval swap₊ (inj₂ v) = inj₁ v eval assocl₊ (inj₁ v) = inj₁ (inj₁ v) eval assocl₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v) eval assocl₊ (inj₂ (inj₂ v)) = inj₂ v eval assocr₊ (inj₁ (inj₁ v)) = inj₁ v eval assocr₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v) eval assocr₊ (inj₂ v) = inj₂ (inj₂ v) eval unite⋆l (tt , v) = v eval uniti⋆l v = (tt , v) eval unite⋆r (v , tt) = v eval uniti⋆r v = (v , tt) eval swap⋆ (v₁ , v₂) = (v₂ , v₁) eval assocl⋆ (v₁ , (v₂ , v₃)) = ((v₁ , v₂) , v₃) eval assocr⋆ ((v₁ , v₂) , v₃) = (v₁ , (v₂ , v₃)) eval absorbl () eval absorbr () eval factorzl () eval factorzr () eval dist (inj₁ v₁ , v₃) = inj₁ (v₁ , v₃) eval dist (inj₂ v₂ , v₃) = inj₂ (v₂ , v₃) eval factor (inj₁ (v₁ , v₃)) = (inj₁ v₁ , v₃) eval factor (inj₂ (v₂ , v₃)) = (inj₂ v₂ , v₃) eval distl (v , inj₁ v₁) = inj₁ (v , v₁) eval distl (v , inj₂ v₂) = inj₂ (v , v₂) eval factorl (inj₁ (v , v₁)) = (v , inj₁ v₁) eval factorl (inj₂ (v , v₂)) = (v , inj₂ v₂) eval id⟷ v = v eval (c₁ ⊚ c₂) v = eval c₂ (eval c₁ v) eval (c₁ ⊕ c₂) (inj₁ v) = inj₁ (eval c₁ v) eval (c₁ ⊕ c₂) (inj₂ v) = inj₂ (eval c₂ v) eval (c₁ ⊗ c₂) (v₁ , v₂) = (eval c₁ v₁ , eval c₂ v₂) {-- eval (lift c) (w , v≡w) = eval c w , cong (eval c) v≡w eval tensorl ((w₁ , w₂) , vp≡wp) = (w₁ , cong proj₁ vp≡wp) , (w₂ , cong proj₂ vp≡wp) eval tensorr ((w₁ , p₁) , (w₂ , p₂)) = (w₁ , w₂) , cong₂ _,_ p₁ p₂ --} eval (η v) tt = (v , refl) , λ _ → tt eval (ε v) (p , f) = f p {-- eval (plusll {v = .w₁}) (inj₁ w₁ , refl) = w₁ , refl eval pluslr (v₁ , refl) = inj₁ v₁ , refl eval (plusrl {v = .w₂}) (inj₂ w₂ , refl) = w₂ , refl eval plusrr (v₂ , refl) = inj₂ v₂ , refl eval (fracl {v₁ = v₁} {v₂ = v₂}) f = (λ _ → f ((v₁ , v₂) , refl)) , (λ _ → f ((v₁ , v₂) , refl)) eval fracr (f₁ , f₂) ((w₁ , w₂) , refl) = let _ = f₁ (w₁ , refl) ; _ = f₂ (w₂ , refl) in tt eval (ll {t} {v} {.w}) (w , refl) = v , refl eval (== c eq) s₁ = let (w₂ , p) = eval c s₁ in w₂ , trans (sym eq) p --} -- monad/comonad pair {-- focus : {t : 𝕌} → (v : ⟦ t ⟧) → Singleton ⟦ t ⟧ v focus v = (v , refl) unfocus : {t : 𝕌} {v : ⟦ t ⟧} → Singleton ⟦ t ⟧ v → ⟦ t ⟧ unfocus (v , refl) = v open import Data.Empty using (⊥) open import Data.Unit using (⊤; tt) open import Data.Sum using (_⊎_; inj₁; inj₂; [_,_]′) open import Data.Product using (_×_; _,_; proj₁; proj₂) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; subst) ------------------------------------------------------------------------------ -- Useful for examples infixr 2 _⟷⟨_⟩_ infix 3 _□ _⟷⟨_⟩_ : (t₁ : 𝕌) {t₂ : 𝕌} {t₃ : 𝕌} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) _ ⟷⟨ α ⟩ β = α ⊚ β _□ : (t : 𝕌) → {t : 𝕌} → (t ⟷ t) _□ t = id⟷ ------------------------------------------------------------------------------ 𝔹 : 𝕌 𝔹 = 𝟙 +ᵤ 𝟙 𝔹² : 𝕌 𝔹² = 𝔹 ×ᵤ 𝔹 𝔽 𝕋 : ⟦ 𝔹 ⟧ 𝔽 = inj₁ tt 𝕋 = inj₂ tt not : ⟦ 𝔹 ⟧ → ⟦ 𝔹 ⟧ not (inj₁ tt) = inj₂ tt not (inj₂ tt) = inj₁ tt -- this version might look more contrived that the fully expanded -- one via pattern matching, but it generalizes better. controlled : ∀ {A} → (⟦ A ⟧ → ⟦ A ⟧) → ⟦ 𝔹 ⟧ × ⟦ A ⟧ → ⟦ 𝔹 ⟧ × ⟦ A ⟧ controlled f (b , a) = (b , [ (λ _ → a) , (λ _ → f a) ]′ b) -- controlled f (inj₁ tt , a) = (inj₁ tt , a ) -- controlled f (inj₂ tt , a) = (inj₂ tt , f a) ------------------------------------------------------------------------------ -- Examples zigzag : ∀ b → ●_ {𝔹} b ⟷ ● b zigzag b = uniti⋆l ⊚ -- ONE * POINTED TWO (η b ⊗ id⟷) ⊚ -- (POINTED TWO * RECIP TWO) * POINTED TWO assocr⋆ ⊚ -- POINTED TWO * (RECIP TWO * POINTED TWO) (id⟷ ⊗ swap⋆) ⊚ -- POINTED TWO * (POINTED TWO * RECIP TWO) (id⟷ ⊗ ε b) ⊚ -- POINTED TWO * ONE unite⋆r test1 = eval (zigzag 𝔽) (𝔽 , refl) -- (⇑ #f refl) -- test2 = eval (zigzag 𝔽) (𝕋 , refl) -- typechecks if given proof #f=#t -- test3 = eval (zigzag 𝕋) (𝔽 , refl) -- typechecks if given proof #f=#t test4 = eval (zigzag 𝕋) (𝕋 , refl) -- (⇑ #t refl) zigzagU : ⟦ 𝔹 ⟧ → ⟦ 𝔹 ⟧ zigzagU b = unfocus (eval (zigzag b) (focus b)) -- Conventional PI examples NOT : 𝔹 ⟷ 𝔹 NOT = swap₊ NEG1 NEG2 NEG3 NEG4 NEG5 : 𝔹 ⟷ 𝔹 NEG1 = swap₊ NEG2 = id⟷ ⊚ NOT NEG3 = NOT ⊚ NOT ⊚ NOT NEG4 = NOT ⊚ id⟷ NEG5 = uniti⋆l ⊚ swap⋆ ⊚ (NOT ⊗ id⟷) ⊚ swap⋆ ⊚ unite⋆l NEG6 = uniti⋆r ⊚ (NOT ⊗ id⟷) ⊚ unite⋆r -- same as above, but shorter CNOT : 𝔹² ⟷ 𝔹² CNOT = 𝔹 ×ᵤ 𝔹 ⟷⟨ id⟷ ⟩ (x +ᵤ y) ×ᵤ 𝔹 ⟷⟨ dist ⟩ (x ×ᵤ 𝔹) +ᵤ (y ×ᵤ 𝔹) ⟷⟨ id⟷ ⊕ (id⟷ ⊗ NOT) ⟩ (x ×ᵤ 𝔹) +ᵤ (y ×ᵤ 𝔹) ⟷⟨ factor ⟩ (x +ᵤ y) ×ᵤ 𝔹 ⟷⟨ id⟷ ⟩ 𝔹 ×ᵤ 𝔹 □ where x = 𝟙; y = 𝟙 TOFFOLI : 𝔹 ×ᵤ 𝔹² ⟷ 𝔹 ×ᵤ 𝔹² TOFFOLI = 𝔹 ×ᵤ 𝔹² ⟷⟨ id⟷ ⟩ (x +ᵤ y) ×ᵤ 𝔹² ⟷⟨ dist ⟩ (x ×ᵤ 𝔹²) +ᵤ (y ×ᵤ 𝔹²) ⟷⟨ id⟷ ⊕ (id⟷ ⊗ CNOT) ⟩ (x ×ᵤ 𝔹²) +ᵤ (y ×ᵤ 𝔹²) ⟷⟨ factor ⟩ (x +ᵤ y) ×ᵤ 𝔹² ⟷⟨ id⟷ ⟩ 𝔹 ×ᵤ 𝔹² □ where x = 𝟙; y = 𝟙 PERES : (𝔹 ×ᵤ 𝔹) ×ᵤ 𝔹 ⟷ (𝔹 ×ᵤ 𝔹) ×ᵤ 𝔹 PERES = (id⟷ ⊗ NOT) ⊚ assocr⋆ ⊚ (id⟷ ⊗ swap⋆) ⊚ TOFFOLI ⊚ (id⟷ ⊗ (NOT ⊗ id⟷)) ⊚ TOFFOLI ⊚ (id⟷ ⊗ swap⋆) ⊚ (id⟷ ⊗ (NOT ⊗ id⟷)) ⊚ TOFFOLI ⊚ (id⟷ ⊗ (NOT ⊗ id⟷)) ⊚ assocl⋆ SWAP12 SWAP23 SWAP13 ROTL ROTR : 𝟙 +ᵤ 𝟙 +ᵤ 𝟙 ⟷ 𝟙 +ᵤ 𝟙 +ᵤ 𝟙 SWAP12 = assocl₊ ⊚ (swap₊ ⊕ id⟷) ⊚ assocr₊ SWAP23 = id⟷ ⊕ swap₊ SWAP13 = SWAP23 ⊚ SWAP12 ⊚ SWAP23 ROTR = SWAP12 ⊚ SWAP23 ROTL = SWAP13 ⊚ SWAP23 t3 : ∀ {b₁ b₂} → ● (𝔽 , (b₁ , b₂)) ⟷ ● (𝔽 , (b₁ , b₂)) t3 = lift TOFFOLI {-- The following do not typecheck. Good t4 : ● (𝔹 ×ᵤ 𝔹²) [ 𝕋 , (𝔽 , 𝔽) ] ⟷ ● (𝔹 ×ᵤ 𝔹²) [ 𝕋 , (𝔽 , 𝕋) ] t4 = lift TOFFOLI t5 : ∀ {b₁ b₂} → ● (𝔹 ×ᵤ 𝔹²) [ b₁ , (𝔽 , b₂) ] ⟷ ● (𝔹 ×ᵤ 𝔹²) [ b₁ , (𝔽 , b₂) ] t5 = lift TOFFOLI --} t6 : ∀ {b} → ● (𝕋 , (𝕋 , b)) ⟷ ● (𝕋 , (𝕋 , eval NOT b)) t6 = lift TOFFOLI -- Ancilla examples from literature -- Fig. 2 in Ricercar CONTROLLED : {A : 𝕌} → (A ⟷ A) → 𝔹 ×ᵤ A ⟷ 𝔹 ×ᵤ A CONTROLLED c = dist ⊚ (id⟷ ⊕ (id⟷ ⊗ c)) ⊚ factor fig2a : 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 ⟷ 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 fig2a = CONTROLLED (CONTROLLED (CONTROLLED NOT)) -- first write the circuit with the additional ancilla fig2b' : ((𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹) ×ᵤ 𝔹) ⟷ ((𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹) ×ᵤ 𝔹) fig2b' = (swap⋆ ⊗ id⟷) ⊚ assocr⋆ ⊚ (swap⋆ ⊗ id⟷) ⊚ assocr⋆ ⊚ (id⟷ ⊗ CONTROLLED (CONTROLLED NOT)) -- first ccnot ⊚ assocl⋆ ⊚ (swap⋆ ⊗ id⟷) ⊚ assocl⋆ ⊚ (swap⋆ ⊗ id⟷) -- move it back ⊚ (assocl⋆ ⊗ id⟷) ⊚ assocr⋆ ⊚ (id⟷ ⊗ swap⋆) ⊚ (id⟷ ⊗ CONTROLLED (CONTROLLED NOT)) -- second ccnot ⊚ (id⟷ ⊗ swap⋆) ⊚ assocl⋆ ⊚ (assocr⋆ ⊗ id⟷) -- move it back ⊚ (swap⋆ ⊗ id⟷) ⊚ assocr⋆ ⊚ (swap⋆ ⊗ id⟷) ⊚ assocr⋆ ⊚ (id⟷ ⊗ CONTROLLED (CONTROLLED NOT)) -- third ccnot ⊚ assocl⋆ ⊚ (swap⋆ ⊗ id⟷) ⊚ assocl⋆ ⊚ (swap⋆ ⊗ id⟷) -- move it back -- then prove a theorem that specifies its semantics fig2b'≡ : (a b c d : ⟦ 𝔹 ⟧) → proj₂ (eval fig2b' ((a , b , c , d) , 𝔽)) ≡ 𝔽 fig2b'≡ a (inj₁ tt) c d = refl fig2b'≡ (inj₁ tt) (inj₂ tt) c d = refl fig2b'≡ (inj₂ tt) (inj₂ tt) c d = refl -- generalize above? Method: -- for 'dist' to evaluate, need to split on b first -- in first case, split on e (same reason) -- in second case, split on a (same reason) -- split on e -- split on e foo : (a b c d e : ⟦ 𝔹 ⟧) → proj₂ (eval fig2b' ((a , b , c , d) , e)) ≡ e foo a (inj₁ x) c d (inj₁ x₁) = refl foo a (inj₁ x) c d (inj₂ y) = refl foo (inj₁ x) (inj₂ y) c d (inj₁ x₁) = refl foo (inj₁ x) (inj₂ y) c d (inj₂ y₁) = refl foo (inj₂ y₁) (inj₂ y) c d (inj₁ x) = refl foo (inj₂ y₁) (inj₂ y) c d (inj₂ y₂) = refl postulate -- boring... tensor4 : ∀ {a b c d e} → (●_ {𝔹} a ×ᵤ ●_ {𝔹} b ×ᵤ ●_ {𝔹} c ×ᵤ ●_ {𝔹} d) ×ᵤ ●_ {𝔹} e ⟷ ●_ {(𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹) ×ᵤ 𝔹} ((a , b , c , d) , e) itensor4 : ∀ {a b c d e} → ●_ {(𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹 ×ᵤ 𝔹) ×ᵤ 𝔹} ((a , b , c , d) , e) ⟷ (● a ×ᵤ ● b ×ᵤ ● c ×ᵤ ● d) ×ᵤ ● e -- now lift it fig2b : ∀ {a b c d e} → let ((x , y , z , w) , u) = eval fig2b' ((a , b , c , d) , e) in ● a ×ᵤ ● b ×ᵤ ● c ×ᵤ ● d ⟷ ● x ×ᵤ ● y ×ᵤ ● z ×ᵤ ● w fig2b {a} {b} {c} {d} {e} = let ((x , y , z , w) , u) = eval fig2b' ((a , b , c , d) , e) in uniti⋆r ⊚ -- (●𝔹[a] × ●𝔹[b] × ●𝔹[c] × ●𝔹[d]) × ●𝟙[e] (id⟷ ⊗ η e) ⊚ -- (●𝔹[a] × ●𝔹[b] × ●𝔹[c] × ●𝔹[d]) × (●𝔹[e] x ●1/𝔹[e]) assocl⋆ ⊚ -- ((●𝔹[a] × ●𝔹[b] × ●𝔹[c] × ●𝔹[d]) × ●𝔹[e) x ●1/𝔹[e] (tensor4 ⊗ id⟷) ⊚ -- ● ((𝔹 × 𝔹 × 𝔹 × 𝔹) × 𝔹) [ (a,b,c,d),e ] x ●1/𝔹[e] (lift fig2b' ⊗ id⟷) ⊚ -- ● ((𝔹 × 𝔹 × 𝔹 × 𝔹) × 𝔹) [ (x,y,z,w),e ] x ●1/𝔹[e] (((== id⟷ (cong (λ H → ((x , y , z , w)) , H) (foo a b c d e))) ⊗ id⟷)) ⊚ -- ● ((𝔹 × 𝔹 × 𝔹 × 𝔹) × 𝔹) [ (x,y,z,w),e ] x ●1/𝔹[e] (itensor4 ⊗ id⟷) ⊚ -- ((●𝔹[x] × ●𝔹[y] × ●𝔹[z] × ●𝔹[w]) × ●𝔹[e]) x ●1/𝔹[e] assocr⋆ ⊚ (id⟷ ⊗ ε e) ⊚ unite⋆r -- This is mostly to show that == is really 'subst' in hiding. fig2b₂ : ∀ {a b c d e} → let ((x , y , z , w) , u) = eval fig2b' ((a , b , c , d) , e) in ● a ×ᵤ ● b ×ᵤ ● c ×ᵤ ● d ⟷ ● x ×ᵤ ● y ×ᵤ ● z ×ᵤ ● w fig2b₂ {a} {b} {c} {d} {e} = let ((x , y , z , w) , u) = eval fig2b' ((a , b , c , d) , e) in uniti⋆r ⊚ -- (●𝔹[a] × ●𝔹[b] × ●𝔹[c] × ●𝔹[d]) × ●𝟙[e] (id⟷ ⊗ η e) ⊚ -- (●𝔹[a] × ●𝔹[b] × ●𝔹[c] × ●𝔹[d]) × (●𝔹[e] x ●1/𝔹[e]) assocl⋆ ⊚ -- ((●𝔹[a] × ●𝔹[b] × ●𝔹[c] × ●𝔹[d]) × ●𝔹[e) x ●1/𝔹[e] (tensor4 ⊗ id⟷) ⊚ -- ● ((𝔹 × 𝔹 × 𝔹 × 𝔹) × 𝔹) [ (a,b,c,d),e ] x ●1/𝔹[e] (lift fig2b' ⊗ id⟷) ⊚ -- ● ((𝔹 × 𝔹 × 𝔹 × 𝔹) × 𝔹) [ (x,y,z,w),e ] x ●1/𝔹[e] (itensor4 ⊗ id⟷) ⊚ -- ((●𝔹[x] × ●𝔹[y] × ●𝔹[z] × ●𝔹[w]) × ●𝔹[e]) x ●1/𝔹[e] assocr⋆ ⊚ (id⟷ ⊗ (subst (λ ee → ● ee ×ᵤ 𝟙/● e ⟷ 𝟙) (sym (foo a b c d e)) (ε e))) ⊚ unite⋆r open import Data.Empty using (⊥) open import Data.Unit using (⊤; tt) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; subst; module ≡-Reasoning) open import Data.Product using (Σ; _,_; proj₁; proj₂) open import Relation.Binary.PropositionalEquality using (_≡_; subst) ------------------------------------------------------------------ dual : {A B : 𝕌} → (f : A ⟷ B) → (v : ⟦ A ⟧ ) → (𝟙/● (eval f v) ⟷ 𝟙/● v) dual f v = uniti⋆l ⊚ (η v ⊗ id⟷) ⊚ ((lift f ⊗ id⟷) ⊗ id⟷) ⊚ assocr⋆ ⊚ (id⟷ ⊗ swap⋆) ⊚ assocl⋆ ⊚ (ε (eval f v) ⊗ id⟷) ⊚ unite⋆l -- name, coname name : {A B : 𝕌} → (f : A ⟷ B) → (v : ⟦ A ⟧ ) → 𝟙 ⟷ ● (eval f v) ×ᵤ 𝟙/● v name f v = η v ⊚ (lift f ⊗ id⟷) coname : {A B : 𝕌} → (f : A ⟷ B) → (v : ⟦ A ⟧ ) → ● v ×ᵤ 𝟙/● (eval f v) ⟷ 𝟙 coname f v = (lift f ⊗ id⟷) ⊚ ε (eval f v) -- and 'trace' reveals something neat: we can't choose just any random 'a' and 'c' -- to start with, but we need that make a coherence choice of a and c !! trace : {A B C : 𝕌} (a : ⟦ A ⟧ ) → (f : A ×ᵤ C ⟷ B ×ᵤ C) → (coh : Σ ⟦ C ⟧ (λ c → proj₂ (eval f (a , c)) ≡ c)) → ● a ⟷ ● (proj₁ (eval f (a , proj₁ coh))) trace {A} {B} {C} a f (c , choice) = uniti⋆r ⊚ -- A ×ᵤ 1 (id⟷ ⊗ η c) ⊚ -- A ×ᵤ (C ×ᵤ 1/C) assocl⋆ ⊚ -- (A ×ᵤ C) ×ᵤ 1/C (tensorr ⊗ id⟷) ⊚ -- bring in the ● (lift f ⊗ id⟷) ⊚ -- (B ×ᵤ C) ×ᵤ 1/C (tensorl ⊗ id⟷) ⊚ -- bring out the ● assocr⋆ ⊚ -- B ×ᵤ (C ×ᵤ 1/C) (id⟷ ⊗ (subst fixer choice id⟷ ⊚ ε c)) ⊚ -- B ×ᵤ 1 unite⋆r where fixer : ⟦ C ⟧ → Set fixer d = (● (proj₂ (eval f (a , c))) ×ᵤ 𝟙/● d) ⟷ (● d ×ᵤ 𝟙/● d) ------------------------------------------------------------------ -- Example in Sec. 4.3 from Abramsky's paper -- http://www.cs.ox.ac.uk/files/341/calco05.pdf q : {A1 A2 A3 A4 B1 B2 B3 B4 : 𝕌} → (f1 : A1 ⟷ B2) → (f2 : A2 ⟷ B4) → (f3 : A3 ⟷ B3) → (f4 : A4 ⟷ B1) → A1 ×ᵤ (A2 ×ᵤ (A3 ×ᵤ A4)) ⟷ B1 ×ᵤ (B2 ×ᵤ (B3 ×ᵤ B4)) q {A1} {A2} {A3} {A4} {B1} {B2} {B3} {B4} f1 f2 f3 f4 = (A1 ×ᵤ A2 ×ᵤ A3 ×ᵤ A4) ⟷⟨ f1 ⊗ (f2 ⊗ (f3 ⊗ f4)) ⟩ (B2 ×ᵤ B4 ×ᵤ B3 ×ᵤ B1) ⟷⟨ assocl⋆ ⟩ (B2 ×ᵤ B4) ×ᵤ (B3 ×ᵤ B1) ⟷⟨ swap⋆ ⟩ (B3 ×ᵤ B1) ×ᵤ (B2 ×ᵤ B4) ⟷⟨ swap⋆ ⊗ id⟷ ⟩ (B1 ×ᵤ B3) ×ᵤ (B2 ×ᵤ B4) ⟷⟨ assocr⋆ ⊚ (id⟷ ⊗ assocl⋆) ⟩ B1 ×ᵤ ((B3 ×ᵤ B2) ×ᵤ B4) ⟷⟨ id⟷ ⊗ ((swap⋆ ⊗ id⟷) ⊚ assocr⋆) ⟩ B1 ×ᵤ (B2 ×ᵤ (B3 ×ᵤ B4)) □ q' : {A1 U2 U3 U4 B1 : 𝕌} → (f1 : A1 ⟷ U2) → (f2 : U2 ⟷ U4) → (f3 : U3 ⟷ U3) → (f4 : U4 ⟷ B1) → (v : ⟦ A1 ⟧) (u3 : ⟦ U3 ⟧) → (u3-fix : eval f3 u3 ≡ u3) → let u2 = eval f1 v in let u4 = eval f2 u2 in ● v ⟷ ● (proj₁ (eval (q f1 f2 f3 f4) (v , u2 , u3 , u4))) q' f1 f2 f3 f4 v u3 u3fix = trace v (q f1 f2 f3 f4) (( u2 , ( u3 , u4 ) ), cong₂ _,_ refl (cong₂ _,_ u3fix refl)) where u2 = eval f1 v u3′ = eval f3 u3 u4 = eval f2 u2 -- The point is that q' acts in a very particular way: q'-closed-form : {A1 U2 U3 U4 B1 : 𝕌} → (f1 : A1 ⟷ U2) → (f2 : U2 ⟷ U4) → (f3 : U3 ⟷ U3) → (f4 : U4 ⟷ B1) → (u3 : ⟦ U3 ⟧) (u3-fix : eval f3 u3 ≡ u3) → (v : ⟦ A1 ⟧) → proj₁ (eval (q' f1 f2 f3 f4 v u3 u3-fix) (v , refl)) ≡ eval (f1 ⊚ f2 ⊚ f4) v q'-closed-form f1 f2 f3 f4 u3 u3fix v = refl --------------------------------------------------------------------------------- -- I think the examples below are 'obsolete', in the sense that the one above -- is more faithful to the original, and more general too. Delete? p : {A1 A2 A3 A4 : 𝕌} → (A1 ×ᵤ A2) ×ᵤ (A3 ×ᵤ A4) ⟷ (A2 ×ᵤ A4) ×ᵤ (A3 ×ᵤ A1) p = (swap⋆ ⊗ swap⋆) ⊚ assocr⋆ ⊚ (id⟷ ⊗ assocl⋆) ⊚ (id⟷ ⊗ (swap⋆ ⊗ id⟷)) ⊚ (id⟷ ⊗ assocr⋆) ⊚ assocl⋆ ⊚ (id⟷ ⊗ swap⋆) p' : {A1 A2 A3 A4 : 𝕌} → ((A1 ×ᵤ A2) ×ᵤ A4) ×ᵤ A3 ⟷ ((A2 ×ᵤ A4) ×ᵤ A1) ×ᵤ A3 p' = assocr⋆ ⊚ (id⟷ ⊗ swap⋆) ⊚ p ⊚ (id⟷ ⊗ swap⋆) ⊚ assocl⋆ p2 : 𝔹 ×ᵤ (𝔹 ×ᵤ (𝔹 ×ᵤ 𝔹)) ⟷ 𝔹 ×ᵤ (𝔹 ×ᵤ (𝔹 ×ᵤ 𝔹)) p2 = assocl⋆ ⊚ (swap⋆ ⊗ swap⋆) ⊚ assocr⋆ ⊚ (id⟷ ⊗ assocl⋆) ⊚ (id⟷ ⊗ (swap⋆ ⊗ id⟷)) ⊚ (id⟷ ⊗ assocr⋆) ⊚ assocl⋆ ⊚ (id⟷ ⊗ swap⋆) ⊚ assocr⋆ p2' : (v : ⟦ 𝔹 ⟧) → ● v ⟷ ● (proj₁ (proj₁ (eval p ((v , v) , (v , v))))) p2' v = trace v p2 ((v , (v , v)) , refl) --------------------------------------------------------------------------------- -- Examples inspired by compact closed categories and fractional numbers. -- Intuition: -- 1/A x B is a space transformer; takes A space and returns B space -- denote space transformers as A ⊸ B -- Best we can do: -- we need Singletons, so |a ⊸ b| is 1 component of a function. _⊸_ : {A : 𝕌} → (a : ⟦ A ⟧) → {B : 𝕌} → (b : ⟦ B ⟧) → 𝕌 _⊸_ {A} a {B} b = 𝟙/● a ×ᵤ ● b id⊸ : {A : 𝕌} {a : ⟦ A ⟧} → (a ⊸ a) ⟷ 𝟙 id⊸ {A} {a} = (𝟙/● a ×ᵤ ● a) ⟷⟨ swap⋆ ⟩ (● a ×ᵤ 𝟙/● a) ⟷⟨ ε a ⟩ 𝟙 □ comp⊸ : {A B C : 𝕌} {a : ⟦ A ⟧} {b : ⟦ B ⟧} {c : ⟦ C ⟧} → (a ⊸ b) ×ᵤ (b ⊸ c) ⟷ (a ⊸ c) comp⊸ {A} {B} {C} {a} {b} {c} = (𝟙/● a ×ᵤ ● b) ×ᵤ (𝟙/● b ×ᵤ ● c) ⟷⟨ assocr⋆ ⟩ 𝟙/● a ×ᵤ (● b ×ᵤ (𝟙/● b ×ᵤ ● c)) ⟷⟨ id⟷ ⊗ assocl⋆ ⟩ 𝟙/● a ×ᵤ (● b ×ᵤ 𝟙/● b) ×ᵤ ● c ⟷⟨ id⟷ ⊗ (ε b ⊗ id⟷) ⟩ 𝟙/● a ×ᵤ (𝟙 ×ᵤ ● c) ⟷⟨ id⟷ ⊗ unite⋆l ⟩ 𝟙/● a ×ᵤ ● c □ app : {A B : 𝕌} {a : ⟦ A ⟧} {b : ⟦ B ⟧} → (a ⊸ b) ×ᵤ ● a ⟷ ● b app {A} {B} {a} {b} = (𝟙/● a ×ᵤ ● b) ×ᵤ ● a ⟷⟨ swap⋆ ⊗ id⟷ ⟩ (● b ×ᵤ 𝟙/● a) ×ᵤ ● a ⟷⟨ assocr⋆ ⊚ (id⟷ ⊗ (swap⋆ ⊚ ε a)) ⟩ ● b ×ᵤ 𝟙 ⟷⟨ unite⋆r ⟩ ● b □ -- B/A × D/C ⟷ B × D / A × C dist×/ : {A B C D : 𝕌} {a : ⟦ A ⟧} {b : ⟦ B ⟧} {c : ⟦ C ⟧} {d : ⟦ D ⟧} → (a ⊸ b) ×ᵤ (c ⊸ d) ⟷ ((a , c) ⊸ (b , d)) dist×/ {A} {B} {C} {D} {a} {b} {c} {d} = (𝟙/● a ×ᵤ ● b) ×ᵤ (𝟙/● c ×ᵤ ● d) ⟷⟨ assocr⋆ ⊚ (id⟷ ⊗ assocl⋆) ⟩ (𝟙/● a ×ᵤ (● b ×ᵤ 𝟙/● c) ×ᵤ ● d) ⟷⟨ id⟷ ⊗ (swap⋆ ⊗ id⟷) ⟩ (𝟙/● a ×ᵤ (𝟙/● c ×ᵤ ● b) ×ᵤ ● d) ⟷⟨ (id⟷ ⊗ assocr⋆) ⊚ assocl⋆ ⟩ (𝟙/● a ×ᵤ 𝟙/● c) ×ᵤ (● b ×ᵤ ● d) ⟷⟨ fracr ⊗ tensorr ⟩ (𝟙/●_ {A ×ᵤ C} (a , c)) ×ᵤ (●_ {B ×ᵤ D} (b , d)) □ -- 1/A x 1/B <-> 1 / (A x B) rev× : {A B : 𝕌} {a : ⟦ A ⟧} {b : ⟦ B ⟧} → (a ⊸ tt) ×ᵤ (b ⊸ tt) ⟷ ((a , b) ⊸ tt) rev× {A} {B} {a} {b} = (𝟙/● a ×ᵤ ● tt) ×ᵤ (𝟙/● b ×ᵤ ● tt) ⟷⟨ dist×/ ⟩ (𝟙/● (a , b) ×ᵤ ● (tt , tt)) ⟷⟨ id⟷ ⊗ lift unite⋆l ⟩ (𝟙/●_ {A ×ᵤ B} (a , b) ×ᵤ ● tt) □ {-- trivial : ● 𝟙 [ tt ] ⟷ 𝟙 trivial = {!!} --} -- (A <-> B) -> (1/A <-> 1/B) --rev : {A B : 𝕌} {a : ⟦ A ⟧} {b : ⟦ B ⟧} -- → ● A [ a ] ⟷ ● B [ b ] → (b ⊸ tt) ⟷ (a ⊸ tt) -- (𝟙/● A [ a ] ×ᵤ ● 𝟙 [ tt ]) ⟷⟨ {!!} ⟩ -- (𝟙/● B [ b ] ×ᵤ ● 𝟙 [ tt ]) □ rev : {A B : 𝕌} {a : ⟦ A ⟧} → (f : A ⟷ B) → (𝟙/● (eval f a) ⟷ 𝟙/● a) rev {A} {B} {a} f = dual f a -- A <-> 1 / (1/A) revrev : {A : 𝕌} {a : ⟦ A ⟧} {a⋆ : ⟦ 𝟙/● a ⟧} → ● a ⟷ 𝟙/● a⋆ revrev {A} {a} {a⋆} = ● a ⟷⟨ uniti⋆r ⟩ ● a ×ᵤ 𝟙 ⟷⟨ {!id⟷ ⊗ η a⋆!} ⟩ ● a ×ᵤ (𝟙/● a ×ᵤ 𝟙/● a⋆) ⟷⟨ {!!} ⟩ 𝟙/● a⋆ □ -- this is strange -- A/C + B/C <-> (A + B) / C -- factor+/l : {A B C : 𝕌} {a : ⟦ A ⟧} {b : ⟦ B ⟧} {c : ⟦ C ⟧} -- → (c ⊸ a) +ᵤ (c ⊸ b) ⟷ (_⊸_ {C} c {A +ᵤ B} (inj₁ a)) -- factor+/l {A} {B} {C} {a} {b} {c} = -- (𝟙/● C [ c ] ×ᵤ ● A [ a ] +ᵤ 𝟙/● C [ c ] ×ᵤ ● B [ b ]) ⟷⟨ factorl ⟩ -- (𝟙/● C [ c ] ×ᵤ (● A [ a ] +ᵤ ● B [ b ])) ⟷⟨ id⟷ ⊗ {!!} ⟩ -- (𝟙/● C [ c ] ×ᵤ ● A +ᵤ B [ inj₁ a ]) □ -- same issue here with the + -- A/B + C/D <-> (A x D + B x C) / (B x D) -- SAT solver Sec. 5 from https://www.cs.indiana.edu/~sabry/papers/rational.pdf -- can we do this? -- curry⊸ : {A B C : 𝕌} {a : ⟦ A ⟧} {b : ⟦ B ⟧} {c : ⟦ C ⟧} -- → (● A [ a ] ×ᵤ (b ⊸ c)) ⟷ (a ⊸ {!!}) -- what do we put here? -- curry⊸ {A} {B} {C} {a} {b} {c} = {!!} ------------------------------------------------------------------------------ --}
{ "alphanum_fraction": 0.4144852071, "avg_line_length": 32.4003067485, "ext": "agda", "hexsha": "378932a3b97425038717a8786075fbb38692be01", "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": "fracGC/PiFrac2.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": "fracGC/PiFrac2.agda", "max_line_length": 96, "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": "fracGC/PiFrac2.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": 12304, "size": 21125 }
{-# OPTIONS --cubical --safe #-} module Analysis where open import Data.List using (List; []; _∷_; map) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Harmony open import Music open import Note open import Pitch -- test of analysis accompF : List Pitch accompF = f 4 ∷ a 4 ∷ c 5 ∷ [] xx = pitchClassListToSet (map pitchToClass accompF) --yy = showPitchClassSet xx zz : xx ≡ IV-maj zz = refl
{ "alphanum_fraction": 0.703196347, "avg_line_length": 18.25, "ext": "agda", "hexsha": "dfb48363f18780b1dc698f7a2ece994f17e96416", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "agda/Analysis.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "agda/Analysis.agda", "max_line_length": 67, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "agda/Analysis.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 129, "size": 438 }
open import Everything {- open import Oscar.Prelude open import Oscar.Class.HasEquivalence open import Oscar.Class.Symmetrical open import Oscar.Data.Term open import Oscar.Data.Substitunction open import Oscar.Data.Surjcollation open import Oscar.Data.Surjextenscollation open import Oscar.Data.Proposequality import Oscar.Class.HasEquivalence.ExtensionṖroperty import Oscar.Class.HasEquivalence.Ṗroperty import Oscar.Class.Symmetrical.ExtensionalUnifies import Oscar.Class.Symmetrical.Unifies import Oscar.Property.Setoid.Proposequality -- FIXME see _∼⁰_ below; comment this out to observe confusing error messages import Oscar.Property.Functor.SubstitunctionExtensionTerm import Oscar.Class.Surjection.⋆ -} module Test.SymmetricalSubstitunction {𝔭} (𝔓 : Ø 𝔭) (ℓ : Ł) where open Term 𝔓 using () renaming ( Term to 𝑩; Terms to 𝑩') open Substitunction 𝔓 using () renaming ( Substitunction to 𝑪) infix 18 _∼⁰_ _∼⁰_ = ≡-surjcollation⟦ 𝑪 ⟧ -- ≡-Unifies₀⟦ 𝑪 ⟧ -- FIXME gives a confusing error message -- _∼⁰_ = ≡-SymUnifies₀⟦ 𝑪 ⟧ -- FIXME gives a more useful error message open Surjextenscollation 𝑪 _≡̇_ renaming (_⟹_ to _∼¹_) fact1⋆ : ∀ {𝓃} (𝓈 𝓉 : 𝑩 𝓃) → 𝓈 ∼⁰ 𝓉 ≈ 𝓉 ∼⁰ 𝓈 fact1⋆ 𝓈 𝓉 = symmetrical 𝓈 𝓉 -- fact1⋆ 𝓈 𝓉 = symmetrical ⦃ r = Oscar.Class.Symmetrical.Unifies.𝓢ymmetricalUnifies₀ ⦃ ! ⦄ ⦃ ! ⦄ ⦃ Oscar.Property.Setoid.Proposequality.𝓢ymmetryProposequality ⦄ ⦄ 𝓈 𝓉 -- FIXME I wish Agda would tell us that this is how the instances were resolved fact1⋆s : ∀ {N 𝓃} (𝓈 𝓉 : 𝑩' N 𝓃) → 𝓈 ∼⁰ 𝓉 ≈ 𝓉 ∼⁰ 𝓈 fact1⋆s 𝓈 𝓉 = symmetrical 𝓈 𝓉 fact1 : ∀ {𝓃} (𝓈 𝓉 : 𝑩 𝓃) → 𝓈 ∼¹ 𝓉 ≈ 𝓉 ∼¹ 𝓈 fact1 𝓈 𝓉 = symmetrical 𝓈 𝓉 fact1s : ∀ {N 𝓃} (𝓈 𝓉 : 𝑩' N 𝓃) → 𝓈 ∼¹ 𝓉 ≈ 𝓉 ∼¹ 𝓈 fact1s 𝓈 𝓉 = symmetrical 𝓈 𝓉
{ "alphanum_fraction": 0.7130484988, "avg_line_length": 36.8510638298, "ext": "agda", "hexsha": "cb97bdeaf8356b7b980a769a243a1b4d0801f371", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/SymmetricalSubstitunction.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/SymmetricalSubstitunction.agda", "max_line_length": 249, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/SymmetricalSubstitunction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 752, "size": 1732 }
{-# OPTIONS --no-universe-polymorphism #-} open import Data.Product hiding (map) open import Relation.Binary.Core open import Function open import Data.List open import Data.Unit using (⊤) open import Data.Empty open import Equivalence module BagEquality where infixr 5 _⊕_ data _⊕_ (A B : Set) : Set where inj₁ : A → A ⊕ B inj₂ : B → A ⊕ B uninhabited : {A : Set} → (A → ⊥) → A ↔ ⊥ uninhabited pf = record {to = pf; from = ⊥-elim; from-to = λ a → ⊥-elim (pf a); to-from = λ false → ⊥-elim false} Any : {A : Set} → (A → Set) → List A → Set Any P [] = ⊥ Any P (x ∷ xs) = P x ⊕ Any P xs infix 6 _∈_ _∈_ : {A : Set} → A → List A → Set z ∈ xs = Any (λ y → z ≡ y) xs infixr 4 _≈_ _≈_ : {A : Set} → List A → List A → Set xs ≈ ys = ∀ z → z ∈ xs ↔ z ∈ ys infix 10 _>>=_ _>>=_ : {A B : Set} → List A → (A → List B) → List B xs >>= f = concat (map f xs) ⊕-left-identity : {A : Set} → ⊥ ⊕ A ↔ A ⊕-left-identity {A} = record { to = to' ; from = inj₂ ; from-to = from-to' ; to-from = λ a → refl } where to' : ⊥ ⊕ A → A to' (inj₁ b) = ⊥-elim b to' (inj₂ a) = a from-to' : (s : ⊥ ⊕ A) → inj₂ (to' s) ≡ s from-to' (inj₁ b) = ⊥-elim b from-to' (inj₂ a) = refl ⊕-assoc : {A B C : Set} → A ⊕ (B ⊕ C) ↔ (A ⊕ B) ⊕ C ⊕-assoc {A} {B} {C} = record {to = to' ; from = from' ; from-to = from-to' ; to-from = to-from' } where to' : A ⊕ (B ⊕ C) → (A ⊕ B) ⊕ C to' (inj₁ a) = inj₁ (inj₁ a) to' (inj₂ (inj₁ b)) = inj₁ (inj₂ b) to' (inj₂ (inj₂ c)) = inj₂ c from' : (A ⊕ B) ⊕ C → A ⊕ (B ⊕ C) from' (inj₁ (inj₁ a)) = inj₁ a from' (inj₁ (inj₂ b)) = inj₂ (inj₁ b) from' (inj₂ c) = inj₂ (inj₂ c) from-to' : (x : A ⊕ (B ⊕ C)) → from' (to' x) ≡ x from-to' (inj₁ _) = refl from-to' (inj₂ (inj₁ _)) = refl from-to' (inj₂ (inj₂ _)) = refl to-from' : (y : (A ⊕ B) ⊕ C) → to' (from' y) ≡ y to-from' (inj₁ (inj₁ _)) = refl to-from' (inj₁ (inj₂ _)) = refl to-from' (inj₂ _) = refl ⊕-comm : {A B : Set} → A ⊕ B ↔ B ⊕ A ⊕-comm {A} {B} = record {to = to' ; from = from' ; from-to = from-to' ; to-from = to-from' } where to' : A ⊕ B → B ⊕ A to' (inj₁ a) = inj₂ a to' (inj₂ b) = inj₁ b from' : B ⊕ A → A ⊕ B from' (inj₁ b) = inj₂ b from' (inj₂ a) = inj₁ a from-to' : (x : A ⊕ B) → from' (to' x) ≡ x from-to' (inj₁ _) = refl from-to' (inj₂ _) = refl to-from' : (x : B ⊕ A) → to' (from' x) ≡ x to-from' (inj₁ _) = refl to-from' (inj₂ _) = refl ⊕-cong : {A₁ A₂ B₁ B₂ : Set} → A₁ ↔ A₂ → B₁ ↔ B₂ → A₁ ⊕ B₁ ↔ A₂ ⊕ B₂ ⊕-cong {A₁} {A₂} {B₁} {B₂} A↔ B↔ = record { to = to'; from = from'; from-to = from-to'; to-from = to-from' } where to' : A₁ ⊕ B₁ → A₂ ⊕ B₂ to' (inj₁ a) = inj₁ (_↔_.to A↔ a) to' (inj₂ b) = inj₂ (_↔_.to B↔ b) from' : A₂ ⊕ B₂ → A₁ ⊕ B₁ from' (inj₁ a) = inj₁ (_↔_.from A↔ a) from' (inj₂ b) = inj₂ (_↔_.from B↔ b) from-to' : (x : A₁ ⊕ B₁) → from' (to' x) ≡ x from-to' (inj₁ a) = _↔_.from-to A↔ a under inj₁ from-to' (inj₂ b) = _↔_.from-to B↔ b under inj₂ to-from' : (x : A₂ ⊕ B₂) → to' (from' x) ≡ x to-from' (inj₁ a) = _↔_.to-from A↔ a under inj₁ to-from' (inj₂ b) = _↔_.to-from B↔ b under inj₂ ×-cong : {A₁ A₂ B₁ B₂ : Set} → A₁ ↔ A₂ → B₁ ↔ B₂ → (A₁ × B₁) ↔ (A₂ × B₂) ×-cong {A₁} {A₂} {B₁} {B₂} A↔ B↔ = record { to = to'; from = from'; from-to = from-to'; to-from = to-from' } where to' : A₁ × B₁ → A₂ × B₂ to' (a , b) = (_↔_.to A↔ a , _↔_.to B↔ b) from' : A₂ × B₂ → A₁ × B₁ from' (a , b) = (_↔_.from A↔ a , _↔_.from B↔ b) pairEq : {A B : Set} {x y : A} {u v : B} → x ≡ y → u ≡ v → (x , u) ≡ (y , v) pairEq refl refl = refl from-to' : (x : A₁ × B₁) → from' (to' x) ≡ x from-to' (a , b) = pairEq (_↔_.from-to A↔ a) (_↔_.from-to B↔ b) to-from' : (y : A₂ × B₂) → to' (from' y) ≡ y to-from' (a , b) = pairEq (_↔_.to-from A↔ a) (_↔_.to-from B↔ b) Any-++ : {A : Set} (P : A → Set) (xs ys : List A) → Any P (xs ++ ys) ↔ Any P xs ⊕ Any P ys Any-++ P [] ys = Any P ys ↔⟨ ↔sym ⊕-left-identity ⟩ ⊥ ⊕ Any P ys □↔ Any-++ P (x ∷ xs) ys = P x ⊕ Any P (xs ++ ys) ↔⟨ ⊕-cong (P x □↔) (Any-++ P xs ys) ⟩ P x ⊕ (Any P xs ⊕ Any P ys) ↔⟨ ⊕-assoc ⟩ (P x ⊕ Any P xs) ⊕ Any P ys □↔ -- ++-assoc : {A : Set} (xs ys zs : List A) → ((xs ++ ys) ++ zs) ≡ (xs ++ (ys ++ zs)) ++-comm : {A : Set} (xs ys : List A) → xs ++ ys ≈ ys ++ xs ++-comm xs ys z = z ∈ (xs ++ ys) ↔⟨ Any-++ (z ≡_ ) xs ys ⟩ z ∈ xs ⊕ z ∈ ys ↔⟨ ⊕-comm ⟩ z ∈ ys ⊕ z ∈ xs ↔⟨ ↔sym (Any-++ (z ≡_ ) ys xs ) ⟩ z ∈ (ys ++ xs) □↔ Any-concat : {A : Set} (P : A → Set) → (xss : List (List A)) → Any P (concat xss) ↔ Any (Any P) xss Any-concat P [] = ⊥ □↔ Any-concat P (xs ∷ xss) = Any P (xs ++ concat xss) ↔⟨ Any-++ P xs (concat xss) ⟩ Any P xs ⊕ Any P (concat xss) ↔⟨ ⊕-cong (Any P xs □↔) (Any-concat P xss) ⟩ Any P xs ⊕ Any (Any P) xss □↔ Any-map : {A B : Set} (P : B → Set) → (f : A → B) → (xs : List A) → Any P (map f xs) ↔ Any (P ∘ f) xs Any-map P f [] = ⊥ □↔ Any-map P f (x ∷ xs) = P (f x) ⊕ Any P (map f xs) ↔⟨ ⊕-cong (P (f x) □↔) (Any-map P f xs) ⟩ (P ∘ f) x ⊕ Any (P ∘ f) xs □↔ Any->>= : {A B : Set} (P : B → Set) → (xs : List A) → (f : A → List B) → Any P (xs >>= f) ↔ Any (Any P ∘ f) xs Any->>= P xs f = Any P (concat (map f xs)) ↔⟨ Any-concat P (map f xs) ⟩ Any (Any P) (map f xs) ↔⟨ Any-map (Any P) f xs ⟩ Any (Any P ∘ f) xs □↔ Any-∈ : {A : Set} {P : A → Set} {xs : List A} → Any P xs ↔ (∃ λ z → P z × z ∈ xs) Any-∈ {A} {P} {[]} = ⊥ ↔⟨ (↔sym ∘ uninhabited) (⊥-elim ∘ proj₂ ∘ proj₂) ⟩ (∃ λ z → P z × z ∈ []) □↔ Any-∈ {A} {P} {x ∷ xs} = record {to = to' ; from = from' ; from-to = from-to' ; to-from = to-from' } where to' : P x ⊕ Any P xs → ∃ (λ z → P z × z ∈ (x ∷ xs)) to' (inj₁ px) = x , (px , (inj₁ refl)) to' (inj₂ any) = (proj₁ recEx) , ( (proj₁ ∘ proj₂) recEx , (inj₂ (proj₂ (proj₂ recEx))) ) where recEx = _↔_.to Any-∈ any from' : ∃ (λ z → P z × z ∈ (x ∷ xs)) → P x ⊕ Any P xs from' ex = from'' (proj₁ ex) (proj₁ (proj₂ ex)) (proj₂ (proj₂ ex)) where from'' : (z : A) → P z → z ∈ (x ∷ xs) → P x ⊕ Any P xs from'' .x px (inj₁ refl) = inj₁ px from'' z pz (inj₂ z∈xs) = inj₂ recAny where recAny = _↔_.from (Any-∈ {P = P}) (z , (pz , z∈xs)) from-to' : (pf : P x ⊕ Any P xs) → from' (to' pf) ≡ pf from-to' (inj₁ px) = refl from-to' (inj₂ any) = _↔_.from-to Any-∈ any under inj₂ to-from' : (ex : ∃ (λ z → P z × z ∈ (x ∷ xs))) → to' (from' ex) ≡ ex to-from' ex = to-from'' (proj₁ ex) (proj₁ (proj₂ ex)) (proj₂ (proj₂ ex)) where to-from'' : (z : A) → (pz : P z) → (z∈xxs : z ∈ (x ∷ xs)) → to' (from' ( z , ( pz , z∈xxs ))) ≡ ( z , ( pz , z∈xxs )) to-from'' .x px (inj₁ refl) = refl to-from'' z pz (inj₂ z∈xs) = _↔_.to-from (Any-∈ {P = P}) (z , ( pz , z∈xs ) ) under (λ ex → ((proj₁ ex) , ( (proj₁ ∘ proj₂) ex , (inj₂ (proj₂ (proj₂ ex)))))) ∃-cong : {A : Set} {P Q : A → Set} → (∀ x → P x ↔ Q x) → (∃ λ x → P x) ↔ (∃ λ x → Q x) ∃-cong p = record {to = λ ex → proj₁ ex , _↔_.to (p (proj₁ ex)) (proj₂ ex); from = λ ex → proj₁ ex , _↔_.from (p (proj₁ ex)) (proj₂ ex); from-to = λ ex → _↔_.from-to (p (proj₁ ex)) (proj₂ ex) under λ pf → (proj₁ ex) , pf; to-from = λ ex → _↔_.to-from (p (proj₁ ex)) (proj₂ ex) under λ pf → (proj₁ ex) , pf } Any-cong : {A : Set} (P Q : A → Set) → (xs ys : List A) → (∀ x → P x ↔ Q x) → xs ≈ ys → Any P xs ↔ Any Q ys Any-cong P Q xs ys p eq = Any P xs ↔⟨ Any-∈ ⟩ (∃ λ z → P z × z ∈ xs) ↔⟨ ∃-cong (λ x → ×-cong (p x) (eq x)) ⟩ (∃ λ z → Q z × z ∈ ys) ↔⟨ ↔sym Any-∈ ⟩ Any Q ys □↔ All-cong : {A : Set} {P Q : A → Set} → {xs ys : List A} → (∀ x → P x ↔ Q x) → xs ≈ ys → (∀ x → x ∈ xs → P x) ⇔ (∀ y → y ∈ ys → Q y) All-cong {P} {Q} {xs} {ys} p eq = record {to = λ P∀x y y∈ys → _↔_.to (p y) (P∀x y (_↔_.from (eq y) y∈ys)); from = λ Q∀y x x∈xs → _↔_.from (p x) (Q∀y x (_↔_.to (eq x) x∈xs))}
{ "alphanum_fraction": 0.3003887189, "avg_line_length": 50.1701244813, "ext": "agda", "hexsha": "33b53bfd9c67ca6d5dd50499a1915729c52c1e81", "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": "99bd3a5e772563153d78f61c1bbca48d7809ff48", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "NAMEhzj/Divide-and-Conquer-in-Agda", "max_forks_repo_path": "BagEquality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "99bd3a5e772563153d78f61c1bbca48d7809ff48", "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": "NAMEhzj/Divide-and-Conquer-in-Agda", "max_issues_repo_path": "BagEquality.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "99bd3a5e772563153d78f61c1bbca48d7809ff48", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "NAMEhzj/Divide-and-Conquer-in-Agda", "max_stars_repo_path": "BagEquality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3931, "size": 12091 }