Search is not available for this dataset
text
string
meta
dict
module Data.Maybe.Properties.Extra {a}{A : Set a} where open import Data.Maybe open import Relation.Binary.PropositionalEquality open import Relation.Nullary nothing≢just : ∀ {a : A} → ¬ (_≡_ {A = Maybe A} nothing (just a)) nothing≢just ()
{ "alphanum_fraction": 0.7231404959, "avg_line_length": 26.8888888889, "ext": "agda", "hexsha": "2e16bfa596371cd54ad08b9e03a7b045cb0518c4", "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/Data/Maybe/Properties/Extra.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/Data/Maybe/Properties/Extra.agda", "max_line_length": 65, "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/Data/Maybe/Properties/Extra.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": 69, "size": 242 }
{-# OPTIONS --no-positivity-check #-} {-# OPTIONS --no-termination-check #-} module UniDB.Examples.Free where open import UniDB open import Function open import Relation.Binary.PropositionalEquality import Level -- Interpret a value of the morphism representation Ξ as -- a morphism between S and T. Int : (Ξ : MOR) (S T : STX) → Set Int Ξ S T = (γ₁ γ₂ : Dom) (ξ : Ξ γ₁ γ₂) → S γ₁ → T γ₂ -- Combine two types and their interpretations to an -- intepretation of an outer composition. IntPair : (Ξ Ζ : MOR) (S T U : STX) → (intΞ : Int Ξ S T) (intΖ : Int Ζ T U) → Int (Pair Ξ Ζ) S U IntPair Ξ Ζ S T U intΞ intΖ _ _ (ξ ⊗ ζ) = intΖ _ _ ζ ∘ intΞ _ _ ξ -- Predicate: The interpretation of an identity morphism is -- indeed an identity. IntIdm : (Ξ : MOR) (T : STX) {{idmΞ : Idm Ξ}} (intΞ : Int Ξ T T) → Set IntIdm Ξ T intΞ = (γ : Dom) (t : T γ) → intΞ _ _ (idm {Ξ} γ) t ≡ t -- Pointwise equality between two differently represented morphisms. _∣_⊢_≃_ : {Ξ Ζ : MOR} {S T : STX} {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} (intΞ : Int Ξ S T) (intΖ : Int Ζ S T) {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₁ γ₂) → Set intΞ ∣ intΖ ⊢ ξ ≃ ζ = ∀ s → intΞ _ _ ξ s ≡ intΖ _ _ ζ s -- Equality at arbitrary depths data _∣_⊢_≅_ {Ξ Ζ : MOR} {S T : STX} {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} (intΞ : Int Ξ S T) (intΖ : Int Ζ S T) : {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₁ γ₂) → Set where ≃-to-≅ : {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₁ γ₂) (δ : Dom) (eq≃ : (δ' : Dom) → intΞ ∣ intΖ ⊢ (ξ ↑ δ') ≃ (ζ ↑ δ')) → intΞ ∣ intΖ ⊢ (ξ ↑ δ) ≅ (ζ ↑ δ) -- ≅ can always be pushed under binders int≅-↑₁ : {Ξ Ζ : MOR} {S T : STX} {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} {intΞ : Int Ξ S T} {intΖ : Int Ζ S T} {γ₁ γ₂ : Dom} {ξ : Ξ γ₁ γ₂} {ζ : Ζ γ₁ γ₂} → intΞ ∣ intΖ ⊢ ξ ≅ ζ → intΞ ∣ intΖ ⊢ (ξ ↑₁) ≅ (ζ ↑₁) int≅-↑₁ (≃-to-≅ ξ ζ δ eq≃) rewrite sym (↑-suc ξ δ) | sym (↑-suc ζ δ) = ≃-to-≅ ξ ζ (suc δ) eq≃ int≅-↑ : {Ξ Ζ : MOR} {S T : STX} {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} {intΞ : Int Ξ S T} {intΖ : Int Ζ S T} {γ₁ γ₂ : Dom} {ξ : Ξ γ₁ γ₂} {ζ : Ζ γ₁ γ₂} → intΞ ∣ intΖ ⊢ ξ ≅ ζ → (δ : Dom) → intΞ ∣ intΖ ⊢ (ξ ↑ δ) ≅ (ζ ↑ δ) int≅-↑ {ξ = ξ} {ζ} eq zero rewrite ↑-zero ξ | ↑-zero ζ = eq int≅-↑ {ξ = ξ} {ζ} eq (suc δ) rewrite ↑-suc ξ δ | ↑-suc ζ δ = int≅-↑₁ (int≅-↑ eq δ) lk≅ : {Ξ Ζ : MOR} {S T : STX} {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} {intΞ : Int Ξ S T} {intΖ : Int Ζ S T} {γ₁ γ₂ : Dom} {ξ : Ξ γ₁ γ₂} {ζ : Ζ γ₁ γ₂} → intΞ ∣ intΖ ⊢ ξ ≅ ζ → ∀ s → intΞ _ _ ξ s ≡ intΖ _ _ ζ s lk≅ (≃-to-≅ ξ ζ δ eq≃) s = eq≃ δ s record Functor (F : STX → STX) : Set₁ where field fmap : (Ξ : MOR) (S T : STX) {{up : Up Ξ}} (intΞ : Int Ξ S T) → (γ₁ γ₂ : Dom) (ξ : Ξ γ₁ γ₂) → F S γ₁ → F T γ₂ fmap-idm : (Ξ : MOR) (T : STX) {{upΞ : Up Ξ}} {{idmΞ : Idm Ξ}} (intΞ : Int Ξ T T) (intIdmΞ : IntIdm Ξ T intΞ) (γ : Dom) (ft : F T γ) → fmap Ξ T T intΞ _ _ (idm {Ξ} γ) ft ≡ ft fmap-⊗ : (Ξ Ζ : MOR) (S T U : STX) {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} (intΞ : Int Ξ S T) (intΖ : Int Ζ T U) (γ₁ γ₂ γ₃ : Dom) (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₂ γ₃) (fs : F S γ₁) → fmap (Pair Ξ Ζ) S U (IntPair Ξ Ζ S T U intΞ intΖ) _ _ (ξ ⊗ ζ) fs ≡ fmap Ζ T U intΖ _ _ ζ (fmap Ξ S T intΞ _ _ ξ fs) fmap-≅ : (Ξ Ζ : MOR) (S T : STX) {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} (intΞ : Int Ξ S T) (intΖ : Int Ζ S T) (γ₁ γ₂ : Dom) (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₁ γ₂) → intΞ ∣ intΖ ⊢ ξ ≅ ζ → fmap Ξ S T intΞ ∣ fmap Ζ S T intΖ ⊢ ξ ≅ ζ open Functor {{...}} -------------------------------------------------------------------------------- -- Freely generated functor data Free (F : STX → STX) (V : STX) (γ : Dom) : Set where var : (i : V γ) → Free F V γ free : F (Free F V) γ → Free F V γ bind : (F : STX → STX) {{functorF : Functor F}} (V W : STX) (Ξ : MOR) {{upΞ : Up Ξ}} (intΞ : (γ₁ γ₂ : Dom) → Ξ γ₁ γ₂ → V γ₁ → Free F W γ₂) → (γ₁ γ₂ : Dom) → Free F V γ₁ → Ξ γ₁ γ₂ → Free F W γ₂ bind F V W Ξ intΞ γ₁ γ₂ (var v) ξ = intΞ γ₁ γ₂ ξ v bind F V W Ξ intΞ γ₁ γ₂ (free ffv) ξ = free (fmap {F} Ξ (Free F V) (Free F W) (λ γ₃ γ₄ ξ' x' → bind F V W Ξ intΞ γ₃ γ₄ x' ξ' ) γ₁ γ₂ ξ ffv) -------------------------------------------------------------------------------- -- Functor instance for Free F postulate ext : Extensionality Level.zero Level.zero fmap-intpair : (F : STX → STX) {{_ : Functor F}} (Ξ Ζ : MOR) (S T U : STX) {{upΞ : Up Ξ}} {{upΖ : Up Ζ}} (intΞ : Int Ξ S T) (intΖ : Int Ζ T U) → fmap {F} (Pair Ξ Ζ) S U (IntPair Ξ Ζ S T U intΞ intΖ) ≡ IntPair Ξ Ζ (F S) (F T) (F U) (fmap {F} Ξ S T intΞ) (fmap {F} Ζ T U intΖ) fmap-intpair F Ξ Ζ S T U intΞ intΖ = ext λ γ₁ → ext λ γ₃ → ext λ { (_⊗_ {._} {γ₂} ξ ζ) → ext λ fs → fmap-⊗ {F} Ξ Ζ S T U intΞ intΖ γ₁ γ₂ γ₃ ξ ζ fs } instance iFunctorFree : {F : STX → STX} {{functorF : Functor F}} → Functor (Free F) fmap {{iFunctorFree {F}}} Ξ S T intΞ _ _ ξ (var s) = var (intΞ _ _ ξ s) fmap {{iFunctorFree {F}}} Ξ S T intΞ _ _ ξ (free x) = free (fmap Ξ (Free F S) (Free F T) (fmap Ξ S T intΞ) _ _ ξ x) fmap-idm {{iFunctorFree {F}}} Ξ T intΞ intIdmΞ _ (var t) = cong var (intIdmΞ _ t) fmap-idm {{iFunctorFree {F}}} Ξ T intΞ intIdmΞ _ (free fft) = cong free (fmap-idm {F} Ξ (Free F T) (fmap Ξ T T intΞ) (fmap-idm {Free F} Ξ T intΞ intIdmΞ) _ fft) fmap-⊗ {{iFunctorFree {F}}} Ξ Ζ S T U intΞ intΖ _ _ _ ξ ζ (var i) = cong var refl fmap-⊗ {{iFunctorFree {F}}} Ξ Ζ S T U intΞ intΖ _ _ _ ξ ζ (free x) = cong free (begin fmap (Pair Ξ Ζ) (Free F S) (Free F U) (fmap (Pair Ξ Ζ) S U (IntPair Ξ Ζ S T U intΞ intΖ)) _ _ (ξ ⊗ ζ) x ≡⟨ cong (λ (int : Int (Pair Ξ Ζ) (Free F S) (Free F U)) → fmap (Pair Ξ Ζ) (Free F S) (Free F U) int _ _ (ξ ⊗ ζ) x) (fmap-intpair (Free F) Ξ Ζ S T U intΞ intΖ) ⟩ fmap (Pair Ξ Ζ) (Free F S) (Free F U) (IntPair Ξ Ζ (Free F S) (Free F T) (Free F U) (fmap Ξ S T intΞ) (fmap Ζ T U intΖ)) _ _ (ξ ⊗ ζ) x ≡⟨ fmap-⊗ {F} Ξ Ζ (Free F S) (Free F T) (Free F U) (fmap Ξ S T intΞ) (fmap Ζ T U intΖ) _ _ _ ξ ζ x ⟩ fmap Ζ (Free F T) (Free F U) (fmap Ζ T U intΖ) _ _ ζ (fmap Ξ (Free F S) (Free F T) (fmap Ξ S T intΞ) _ _ ξ x) ∎) fmap-≅ {{iFunctorFree {F}}} Ξ Ζ S T intΞ intΖ _ _ _ _ eq = {!!} -------------------------------------------------------------------------------- -- Specialiation to monads relative on Ix module _ {F : STX → STX} {{functorF : Functor F}} where instance iVrFree : Vr (Free F Ix) vr {{iVrFree}} = var vr-inj {{iVrFree}} refl = refl iApFree : Ap (Free F Ix) (Free F Ix) ap {{iApFree}} {Ξ} ξ x = bind F Ix Ix Ξ (λ _ _ → lk) _ _ x ξ iApVrFree : ApVr (Free F Ix) ap-vr {{iApVrFree}} ξ i = refl -- After proving these three properties the relative monad laws -- can be derived from the library. iApIdmFree : ApIdm (Free F Ix) (Free F Ix) ap-idm {{iApIdmFree}} {Ξ} x = {!!} iApPairFree : ApPair (Free F Ix) (Free F Ix) ap-pair {{iApPairFree}} ξ ζ x = {!!} iApRelFree : ApRel (Free F Ix) (Free F Ix) ap-rel≅ {{iApRelFree}} eq x = {!!}
{ "alphanum_fraction": 0.505417736, "avg_line_length": 39.404494382, "ext": "agda", "hexsha": "aed099c2a80c250db1310aa1525b4d21afeac4f9", "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": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_path": "UniDB/Examples/Free.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "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": "skeuchel/unidb-agda", "max_issues_repo_path": "UniDB/Examples/Free.agda", "max_line_length": 138, "max_stars_count": null, "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_path": "UniDB/Examples/Free.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3457, "size": 7014 }
{-# OPTIONS --safe #-} -- --without-K #-} open import Function using (_∘_) open import Data.Empty using (⊥-elim) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; trans; sym; cong; cong₂) open Relation.Binary.PropositionalEquality.≡-Reasoning open import Data.Product using (Σ-syntax; _,_) open import Data.Unit using (tt) open import Relation.Nullary using (yes; no) import Data.Nat as ℕ import Data.Nat.Properties as ℕₚ import Data.Fin as Fin import Data.Fin.Properties as Finₚ open ℕ using (ℕ; zero; suc) open Fin using (Fin; zero; suc) open import PiCalculus.Syntax open Scoped open import PiCalculus.Semantics module PiCalculus.Semantics.Properties where private variable n : ℕ i j : Fin n P : Scoped n lift-lower : (i : Fin (suc n)) (P : Scoped (suc n)) (uP : Unused i P) → lift i (lower i P uP) ≡ P lift-lower i 𝟘 uP = refl lift-lower i (ν P) uP rewrite lift-lower (suc i) P uP = refl lift-lower i (P ∥ Q) (uP , uQ) rewrite lift-lower i P uP | lift-lower i Q uQ = refl lift-lower i (x ⦅⦆ P) (i≢x , uP) rewrite lift-lower (suc i) P uP | Finₚ.punchIn-punchOut i≢x = refl lift-lower i (x ⟨ y ⟩ P) (i≢x , i≢y , uP) rewrite lift-lower i P uP | Finₚ.punchIn-punchOut i≢x | Finₚ.punchIn-punchOut i≢y = refl substFin-suc : (i j x : Fin n) → (suc x) [ suc i ↦ suc j ]' ≡ suc (x [ i ↦ j ]') substFin-suc i j x with i Finₚ.≟ x substFin-suc i j x | yes p = refl substFin-suc i j x | no ¬p = refl exchangeFin-suc : (i : Fin n) (x : Fin (suc n)) → suc (exchangeFin i x) ≡ exchangeFin (suc i) (suc x) exchangeFin-suc i x with Fin.inject₁ i Finₚ.≟ x exchangeFin-suc i .(Fin.inject₁ i) | yes refl = cong suc (cong suc (Finₚ.lower₁-irrelevant _ _ _)) exchangeFin-suc i x | no ¬p with (suc i) Fin.≟ x exchangeFin-suc i x | no ¬p | yes q = refl exchangeFin-suc i x | no ¬p | no ¬q = refl exchangeFin-injectˡ : (i : Fin n) → exchangeFin i (Fin.inject₁ i) ≡ suc i exchangeFin-injectˡ zero = refl exchangeFin-injectˡ (suc i) rewrite sym (exchangeFin-suc i (Fin.inject₁ i)) = cong suc (exchangeFin-injectˡ i) exchangeFin-injectʳ : (i : Fin n) → exchangeFin i (suc i) ≡ Fin.inject₁ i exchangeFin-injectʳ zero = refl exchangeFin-injectʳ (suc i) rewrite sym (exchangeFin-suc i (suc i)) = cong suc (exchangeFin-injectʳ i) exchangeFin-neq : (i j : Fin n) → i ≢ j → Fin.inject₁ i ≢ suc j → exchangeFin i (suc j) ≡ suc j exchangeFin-neq zero zero i≢j ii≢sj = ⊥-elim (i≢j refl) exchangeFin-neq zero (suc zero) i≢j ii≢sj = refl exchangeFin-neq zero (suc (suc j)) i≢j ii≢sj = refl exchangeFin-neq (suc zero) zero i≢j ii≢sj = ⊥-elim (ii≢sj refl) exchangeFin-neq (suc (suc i)) zero i≢j ii≢sj = refl exchangeFin-neq (suc i) (suc j) i≢j ii≢sj rewrite sym (exchangeFin-suc i (suc j)) = cong suc (exchangeFin-neq i j (i≢j ∘ cong suc) (ii≢sj ∘ cong suc)) exchangeFin-exchangeFin : ∀ (i : Fin n) (x : Fin (suc n)) → exchangeFin i (exchangeFin i x) ≡ x exchangeFin-exchangeFin i x with Fin.inject₁ i Fin.≟ x exchangeFin-exchangeFin i x | yes p with Fin.inject₁ i Finₚ.≟ (suc (Fin.lower₁ x (notMax i x p))) exchangeFin-exchangeFin i .(Fin.inject₁ i) | yes refl | yes q = ⊥-elim (ℕₚ.1+n≢n (begin suc (Fin.toℕ i) ≡˘⟨ cong (suc ∘ Fin.toℕ) (Finₚ.lower₁-inject₁ i) ⟩ suc (Fin.toℕ (Fin.lower₁ (Fin.inject₁ i) _)) ≡⟨ cong (suc ∘ Fin.toℕ) (Finₚ.lower₁-irrelevant _ _ _) ⟩ suc (Fin.toℕ (Fin.lower₁ (Fin.inject₁ i) _)) ≡˘⟨ cong Fin.toℕ q ⟩ Fin.toℕ (Fin.inject₁ i) ≡⟨ Finₚ.toℕ-inject₁ i ⟩ Fin.toℕ i ∎ )) exchangeFin-exchangeFin i x | yes p | no ¬q with i Finₚ.≟ Fin.lower₁ x (notMax i x p) exchangeFin-exchangeFin i x | yes p | no ¬q | yes r = p exchangeFin-exchangeFin i x | yes refl | no ¬q | no ¬r = ⊥-elim (¬r (begin i ≡˘⟨ Finₚ.lower₁-inject₁ i ⟩ Fin.lower₁ (Fin.inject₁ i) _ ≡⟨ Finₚ.lower₁-irrelevant _ _ _ ⟩ Fin.lower₁ (Fin.inject₁ i) _ ∎)) exchangeFin-exchangeFin i x | no ¬p with (suc i) Fin.≟ x exchangeFin-exchangeFin i x | no ¬p | yes q with Fin.inject₁ i Fin.≟ Fin.inject₁ i exchangeFin-exchangeFin i x | no ¬p | yes refl | yes refl = begin suc (Fin.lower₁ (Fin.inject₁ i) _) ≡⟨ cong suc (Finₚ.lower₁-irrelevant _ _ _) ⟩ suc (Fin.lower₁ (Fin.inject₁ i) _) ≡⟨ cong suc (Finₚ.lower₁-inject₁ i) ⟩ suc i ∎ exchangeFin-exchangeFin i x | no ¬p | yes q | no ¬r = ⊥-elim (¬r refl) exchangeFin-exchangeFin i x | no ¬p | no ¬q with Fin.inject₁ i Fin.≟ x exchangeFin-exchangeFin i x | no ¬p | no ¬q | yes r = ⊥-elim (¬p r) exchangeFin-exchangeFin i x | no ¬p | no ¬q | no ¬r with (suc i) Fin.≟ x exchangeFin-exchangeFin i x | no ¬p | no ¬q | no ¬r | yes s = ⊥-elim (¬q s) exchangeFin-exchangeFin i x | no ¬p | no ¬q | no ¬r | no ¬s = refl exchange-exchange : ∀ (i : Fin n) (P : Scoped (suc n)) → exchange i (exchange i P) ≡ P exchange-exchange i 𝟘 = refl exchange-exchange i (ν P) rewrite exchange-exchange (suc i) P = refl exchange-exchange i (P ∥ Q) rewrite exchange-exchange i P | exchange-exchange i Q = refl exchange-exchange i (x ⦅⦆ P) rewrite exchangeFin-exchangeFin i x | exchange-exchange (suc i) P = refl exchange-exchange i (x ⟨ y ⟩ P) rewrite exchangeFin-exchangeFin i x | exchangeFin-exchangeFin i y | exchange-exchange i P = refl
{ "alphanum_fraction": 0.6505931879, "avg_line_length": 45.8421052632, "ext": "agda", "hexsha": "5a994017041ee158c198e711a8a8201e053442a7", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-14T16:24:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-25T13:57:13.000Z", "max_forks_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/typing-linear-pi", "max_forks_repo_path": "src/PiCalculus/Semantics/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_issues_repo_issues_event_max_datetime": "2022-03-15T09:16:14.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-15T09:16:14.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "guilhermehas/typing-linear-pi", "max_issues_repo_path": "src/PiCalculus/Semantics/Properties.agda", "max_line_length": 128, "max_stars_count": 26, "max_stars_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/typing-linear-pi", "max_stars_repo_path": "src/PiCalculus/Semantics/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-14T15:18:23.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-02T23:32:11.000Z", "num_tokens": 1999, "size": 5226 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.PA.Inductive.CanonicalTerm where -- We cannot extract a canonical term from a non-intuitionistic proof. open import PA.Inductive.Base open import PA.Inductive.PropertiesI ------------------------------------------------------------------------------ -- The existential projections ∃-proj₁ : ∀ {A} → ∃ A → ℕ ∃-proj₁ (x , _) = x ∃-proj₂ : ∀ {A} → (h : ∃ A) → A (∃-proj₁ h) ∃-proj₂ (_ , Ax) = Ax ------------------------------------------------------------------------------ -- Non-intuitionistic logic theorems -- The principle of the excluded middle. postulate pem : ∀ {A} → A ∨ ¬ A -- The principle of indirect proof (proof by contradiction). ¬-elim : ∀ {A} → (¬ A → ⊥) → A ¬-elim h = case (λ a → a) (λ ¬a → ⊥-elim (h ¬a)) pem -- ∃ in terms of ∀ and ¬. ¬∃¬→∀ : {A : ℕ → Set} → ¬ (∃[ x ] ¬ A x) → ∀ {x} → A x ¬∃¬→∀ h {x} = ¬-elim (λ h₁ → h (x , h₁)) ------------------------------------------------------------------------------ -- Intuitionistic proof. proof₁ : ∃[ x ] x ≢ succ x proof₁ = succ zero , x≢Sx -- Non-intuitionistic proof. proof₂ : ∃[ x ] x ≢ succ x proof₂ = ¬-elim (λ h → x≢Sx {succ zero} (¬∃¬→∀ h)) -- We can extract a canonical term from an intuitionistic proof. canonicalTerm₁ : ∃-proj₁ proof₁ ≡ succ zero canonicalTerm₁ = refl -- We cannot extract a canonical term from a non-intuitionistic proof. -- canonicalTerm₂ : ∃-proj₁ proof₂ ≡ succ zero -- canonicalTerm₂ = {!refl!} -- Agda error: -- -- ∃-proj₁ ([ (λ a → a) , (λ ¬a → ⊥-elim (x≢Sx (¬∃¬→∀ ¬a))) ] pem) != -- succ zero of type M -- when checking that the expression refl has type -- ∃-proj₁ proof₂ ≡ succ zero
{ "alphanum_fraction": 0.5089786756, "avg_line_length": 29.7, "ext": "agda", "hexsha": "c0f42ccf99ef74505f73955cd010caaa30e3e723", "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": "notes/FOT/PA/Inductive/CanonicalTerm.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": "notes/FOT/PA/Inductive/CanonicalTerm.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": "notes/FOT/PA/Inductive/CanonicalTerm.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": 558, "size": 1782 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module CombiningProofs.ForallExistSchema where open import Common.FOL.FOL-Eq A : D → Set A x = x ≡ x ∨ x ≡ x {-# ATP definition A #-} postulate ∀→∃₁ : (∀ {x} → A x) → ∃ A {-# ATP prove ∀→∃₁ #-} postulate ∀→∃₂ : {A : D → Set} → (∀ {x} → A x) → ∃ A {-# ATP prove ∀→∃₂ #-}
{ "alphanum_fraction": 0.4988814318, "avg_line_length": 23.5263157895, "ext": "agda", "hexsha": "6470eb8fdfa124632b40b308542570bd2023ea25", "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": "notes/thesis/report/CombiningProofs/ForallExistSchema.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": "notes/thesis/report/CombiningProofs/ForallExistSchema.agda", "max_line_length": 52, "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": "notes/thesis/report/CombiningProofs/ForallExistSchema.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": 148, "size": 447 }
module prime where open import Data.Nat open import Data.Nat.Properties open import Data.Empty open import Data.Unit using (⊤ ; tt) open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Relation.Binary.Definitions open import gcd open import nat record Prime (i : ℕ ) : Set where field p>1 : i > 1 isPrime : ( j : ℕ ) → j < i → 0 < j → gcd i j ≡ 1 record NonPrime ( n : ℕ ) : Set where field factor : ℕ prime : Prime factor dividable : Dividable factor n PrimeP : ( n : ℕ ) → Dec ( Prime n ) PrimeP 0 = no (λ p → ⊥-elim ( nat-<> (Prime.p>1 p) (s≤s z≤n))) PrimeP 1 = no (λ p → ⊥-elim ( nat-≤> (Prime.p>1 p) (s≤s (≤-refl)))) PrimeP (suc (suc n)) = isPrime1 (suc (suc n)) (suc n) (s≤s (s≤s z≤n)) a<sa (λ i m<i i<n → isp0 (suc n) i (<to≤ m<i) i<n ) where isp0 : (n : ℕ) (i : ℕ) ( n<i : n ≤ i) ( i<n : i < suc n ) → gcd (suc n) i ≡ 1 isp0 n i n<i i<n with <-cmp i n ... | tri< a ¬b ¬c = ⊥-elim ( nat-≤> n<i a) ... | tri≈ ¬a refl ¬c = gcd203 i ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> c i<n ) isPrime1 : ( n m : ℕ ) → n > 1 → m < n → ( (i : ℕ) → m < i → i < n → gcd n i ≡ 1 ) → Dec ( Prime n ) isPrime1 n zero n>1 m<n lt = yes record { isPrime = λ j j<i 0<j → lt j 0<j j<i ; p>1 = n>1 } isPrime1 n (suc m) n>1 m<n lt with <-cmp (gcd n (suc m)) 1 ... | tri< a ¬b ¬c = ⊥-elim ( nat-≤> ( gcd>0 n (suc m) (<-trans (s≤s z≤n) n>1) (s≤s z≤n)) a ) ... | tri≈ ¬a b ¬c = isPrime1 n m n>1 (<-trans a<sa m<n) isp1 where -- lt : (i : ℕ) → suc m ≤ i → suc i ≤ n → gcd1 n n i i ≡ 1 isp1 : (i : ℕ) → m < i → i < n → gcd n i ≡ 1 isp1 i m<i i<n with <-cmp (suc m) i ... | tri< a ¬b ¬c = lt i a i<n ... | tri≈ ¬a m=i ¬c = subst (λ k → gcd n k ≡ 1) m=i b -- gcd n (suc m) ≡ 1 → gcd n i ≡ 1 ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> m<i c) -- suc i ≤ suc m → i < m ... | tri> ¬a ¬b c = no ( λ p → nat-≡< (sym (Prime.isPrime p (suc m) m<n (s≤s z≤n) )) c ) open import logic open _∧_ -- find prime factor data Factoring (m : ℕ ) : (n : ℕ) → Set where findFactor : (n : ℕ) → m ≤ n → ( (j : ℕ ) → m ≤ j → j < n → gcd n j ≡ 1 ) → Factoring m n skipFactor : (n : ℕ) → n < m → Factoring m n nonPrime : { n : ℕ } → 1 < n → ¬ Prime n → NonPrime n nonPrime {n} 1<n np = np1 n n np 1<n (findFactor n ≤-refl (λ j n≤j j<n → ⊥-elim (nat-≤> n≤j j<n ) )) where mg1 : (n m : ℕ )→ ( (j : ℕ ) → m < j → j < n → gcd n j ≡ 1 ) → gcd n m ≡ 1 → (j : ℕ) → m ≤ j → j < n → gcd n j ≡ 1 mg1 n m mg gcd j m<j j<n with <-cmp m j ... | tri< a ¬b ¬c = mg j a j<n ... | tri≈ ¬a refl ¬c = gcd ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> m<j c) np1 : ( n m : ℕ ) → ¬ Prime n → 1 < n → Factoring m n → NonPrime n np1 n zero np 1<n (findFactor n m≤n mg ) = ⊥-elim ( np record { isPrime = λ j lt _ → mg j z≤n lt ; p>1 = 1<n } ) -- zero < j , j < n np1 n (suc m) np 1<n (findFactor n m≤n mg) with <-cmp ( gcd n m ) 1 ... | tri< a ¬b ¬c = ⊥-elim ( nat-≤> ( gcd>0 n m (<-trans (s≤s z≤n) 1<n) 0<m ) a ) where 0<m : 0 < m 0<m with <-cmp 0 m ... | tri< a ¬b ¬c = a ... | tri≈ ¬a refl ¬c = ⊥-elim ( nat-<> a (subst (λ k → 1 < k) (sym (gcd20 n)) 1<n )) ... | tri≈ ¬a b ¬c = np1 n m np 1<n (findFactor n (≤-trans refl-≤s m≤n) (mg1 n m mg b ) ) ... | tri> ¬a ¬b c with PrimeP ( gcd n m ) ... | yes y = record { factor = gcd n m ; prime = y ; dividable = proj1 (gcd-dividable n m ) } ... | no ngcd = np2 where skip-case : NonPrime (gcd n m) → NonPrime n skip-case cc = record { factor = NonPrime.factor cc ; prime = NonPrime.prime cc ; dividable = record { factor = (Dividable.factor (proj1 (gcd-dividable n m))) * (Dividable.factor (NonPrime.dividable cc)) ; is-factor = begin Dividable.factor (proj1 (gcd-dividable n m)) * Dividable.factor (NonPrime.dividable cc) * NonPrime.factor cc + 0 ≡⟨ refl ⟩ g * d * p + 0 ≡⟨ +-comm _ 0 ⟩ g * d * p ≡⟨ *-assoc g d p ⟩ g * (d * p) ≡⟨ cong (λ k → g * k ) (+-comm 0 _) ⟩ g * (d * p + 0) ≡⟨ cong (λ k → g * k ) (Dividable.is-factor (NonPrime.dividable cc) ) ⟩ g * gcd n m ≡⟨ +-comm 0 _ ⟩ g * gcd n m + 0 ≡⟨ Dividable.is-factor (proj1 (gcd-dividable n m)) ⟩ n ∎ }} where open ≡-Reasoning g = Dividable.factor (proj1 (gcd-dividable n m)) d = Dividable.factor (NonPrime.dividable cc) p = NonPrime.factor cc np2 : NonPrime n np2 with <-cmp (gcd n m) m ... | tri< a ¬b ¬c = skip-case (np1 (gcd n m) m ngcd c (skipFactor (gcd n m) a )) ... | tri≈ ¬a b ¬c = skip-case (np1 (gcd n m) m ngcd c (subst (λ k → Factoring m k) (sym b) (findFactor m ≤-refl (λ j n≤j j<n → ⊥-elim (nat-≤> n≤j j<n) )))) ... | tri> ¬a ¬b' c with <-cmp 0 m ... | tri< a ¬b ¬c = ⊥-elim ( nat-≤> (subst (λ k → k ≤ m) (gcdsym {m} {n}) (gcd-≤ a (<-trans a m≤n))) c ) ... | tri≈ ¬a' b' ¬c = ⊥-elim ( np record { isPrime = λ j lt 0<j → mg j (subst (λ k → k < j) b' 0<j) lt ; p>1 = 1<n } ) -- suc m ≤ j np1 n zero np 1<n (skipFactor n ()) np1 n (suc m) np 1<n (skipFactor n n<m) with <-cmp m n ... | tri< a ¬b ¬c = ⊥-elim ( nat-≤> a n<m) ... | tri> ¬a ¬b c = np1 n m np 1<n (skipFactor n c) ... | tri≈ ¬a refl ¬c = np1 n m np 1<n (findFactor m ≤-refl (λ j n≤j j<n → ⊥-elim (nat-≤> n≤j j<n) )) factorial : (n : ℕ) → ℕ factorial zero = 1 factorial (suc n) = (suc n) * (factorial n) factorial-mono : (n : ℕ) → factorial n ≤ factorial (suc n) factorial-mono n = begin factorial n ≤⟨ x≤x+y ⟩ factorial n + n * factorial n ≡⟨ refl ⟩ (suc n) * factorial n ≡⟨ refl ⟩ factorial (suc n) ∎ where open ≤-Reasoning factorial≥1 : {m : ℕ} → 1 ≤ factorial m factorial≥1 {zero} = ≤-refl factorial≥1 {suc m} = begin 1 ≤⟨ s≤s z≤n ⟩ (suc m) * 1 ≤⟨ *-monoʳ-≤ (suc m) (factorial≥1 {m}) ⟩ (suc m) * factorial m ≡⟨ refl ⟩ factorial (suc m) ∎ where open ≤-Reasoning m<factorial : (m : ℕ) → m ≤ factorial m m<factorial zero = z≤n m<factorial (suc m) = begin suc m ≡⟨ cong suc (+-comm 0 _) ⟩ 1 * suc m ≡⟨ *-comm 1 _ ⟩ (suc m) * 1 ≤⟨ *-monoʳ-≤ (suc m) (factorial≥1 {m}) ⟩ (suc m) * factorial m ≡⟨ refl ⟩ factorial (suc m) ∎ where open ≤-Reasoning -- *-monoˡ-≤ (suc m) {!!} fact< : (m n : ℕ) → 0 < n → n < suc (suc m) → Dividable n ( factorial (suc m) ) fact< zero 1 0<n (s≤s (s≤s z≤n)) = record { factor = 1 ; is-factor = refl } fact< (suc m) (suc zero) 0<n n<m = record { factor = factorial (suc (suc m)) ; is-factor = begin factorial (suc (suc m)) * 1 + 0 ≡⟨ +-comm _ 0 ⟩ factorial (suc (suc m)) * 1 ≡⟨ m*1=m ⟩ (suc (suc m)) * factorial (suc m) ≡⟨ refl ⟩ factorial (suc (suc m)) ∎ } where open ≡-Reasoning fact< (suc m) (suc (suc n)) 0<n n<m with <-cmp (suc (suc n)) (suc (suc m)) ... | tri< a ¬b ¬c = record { factor = suc (suc m) * Dividable.factor fact1 ; is-factor = fact2 } where fact1 : Dividable (suc (suc n)) (factorial (suc m )) fact1 = fact< m (suc (suc n)) 0<n a d = (fact< m (suc (suc n)) 0<n a) fact2 : suc (suc m) * Dividable.factor d * suc (suc n) + 0 ≡ factorial (suc (suc m)) fact2 = begin suc (suc m) * Dividable.factor d * suc (suc n) + 0 ≡⟨ +-comm _ 0 ⟩ suc (suc m) * Dividable.factor d * suc (suc n) ≡⟨ *-assoc (suc (suc m)) (Dividable.factor d) ( suc (suc n)) ⟩ suc (suc m) * (Dividable.factor d * suc (suc n)) ≡⟨ cong (λ k → suc (suc m) * k ) ( +-comm 0 (Dividable.factor d * suc (suc n)) ) ⟩ suc (suc m) * (Dividable.factor d * suc (suc n) + 0) ≡⟨ cong (λ k → suc (suc m) * k ) (Dividable.is-factor d) ⟩ suc (suc m) * factorial (suc m) ≡⟨ refl ⟩ factorial (suc (suc m)) ∎ where open ≡-Reasoning ... | tri≈ ¬a b ¬c = record { factor = factorial (suc m) ; is-factor = begin factorial (suc m) * suc (suc n) + 0 ≡⟨ +-comm _ 0 ⟩ factorial (suc m) * suc (suc n) ≡⟨ *-comm (factorial (suc m)) (suc (suc n)) ⟩ (suc (suc n)) * factorial (suc m) ≡⟨ cong (λ k → k * factorial (suc m) ) b ⟩ (suc (suc m)) * factorial (suc m) ≡⟨ refl ⟩ factorial (suc (suc m)) ∎ } where open ≡-Reasoning ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> c n<m) f>m : {m : ℕ} → suc m < suc (factorial (suc m)) f>m {m} = begin suc (suc m) ≡⟨ cong (λ k → 1 + suc k ) (+-comm _ m) ⟩ suc (1 + 1 * m) ≡⟨ cong (λ k → suc (1 + k )) (*-comm 1 m) ⟩ suc (1 + m * 1) ≤⟨ s≤s (s≤s (*-monoʳ-≤ m (factorial≥1 {m}) )) ⟩ suc (1 + m * factorial m) ≤⟨ s≤s (+-monoˡ-≤ _ (factorial≥1 {m})) ⟩ suc (factorial m + m * factorial m) ≡⟨ refl ⟩ suc (factorial (suc m)) ∎ where open ≤-Reasoning prime-is-infinite : (max-prime : ℕ ) → ¬ ( (j : ℕ) → max-prime < j → ¬ Prime j ) prime-is-infinite zero pmax = pmax 3 (s≤s z≤n) record { isPrime = λ n lt 0<j → pif3 n lt 0<j ; p>1 = s≤s (s≤s z≤n) } where pif3 : (n : ℕ) → n < 3 → 0 < n → gcd 3 n ≡ 1 pif3 .1 (s≤s (s≤s z≤n)) _ = refl pif3 .2 (s≤s (s≤s (s≤s z≤n))) _ = refl prime-is-infinite (suc m) pmax = newPrime where prime<max : (n : ℕ ) → Prime n → n < suc (suc m) prime<max n p with <-cmp n (suc m) ... | tri< a ¬b ¬c = ≤-trans a refl-≤s ... | tri≈ ¬a refl ¬c = ≤-refl ... | tri> ¬a ¬b c = ⊥-elim ( pmax n c p ) fact : (n : ℕ) → Prime n → Dividable n ( factorial (suc m) ) fact n p = fact< m n (<-trans (s≤s z≤n) (Prime.p>1 p)) ( prime<max n p ) -- div+1 : { i k : ℕ } → k > 1 → Dividable k i → ¬ Dividable k (suc i) newPrime : ⊥ newPrime with PrimeP ( suc (factorial (suc m)) ) ... | yes p = pmax _ f>m p -- yes, we found a prime not in list ... | no np = div+1 (Prime.p>1 (NonPrime.prime p1)) (fact (NonPrime.factor p1) (NonPrime.prime p1) ) (NonPrime.dividable p1) where -- n!+1 cannot be dividable, because n! is dividable -- the factor need not be a prime, but anyway we prove that there is a prime factor in NonPrime p1 : NonPrime ( suc (factorial (suc m)) ) p1 = nonPrime (begin 2 ≤⟨ s≤s ( s≤s z≤n) ⟩ suc (suc m) ≤⟨ s≤s (m<factorial (suc m)) ⟩ suc (factorial (suc m)) ∎ ) np where open ≤-Reasoning
{ "alphanum_fraction": 0.4961119751, "avg_line_length": 53.3056994819, "ext": "agda", "hexsha": "f288587d1ae47a66c7381e37e2e82db968a81e27", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/prime.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "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": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/prime.agda", "max_line_length": 142, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/prime.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4480, "size": 10288 }
-- Andreas, 2018-12-30, issue #3480 -- Parse error should be reported close to the incomplete "module _" -- rather than at the end of the file, which is miles away. module _ {- A long comment: Per Martin-L"of ON THE MEANINGS OF THE LOGICAL CONSTANTS AND THE JUSTIFICATIONS OF THE LOGICAL LAWS Preface The following three lectures were given in the form of a short course at the meeting Teoria della Dimostrazione e Filosofia della Logica, organized in Siena, 6-9 April 1983, by the Scuola di Specializzazione in Logica Matematica of the Universit`a degli Studi di Siena. I am very grateful to Giovanni Sambin and Aldo Ursini of that school, not only for recording the lectures on tape, but, above all, for transcribing the tapes produced by the recorder: no machine could have done that work. This written version of the lectures is based on their transcription. The changes that I have been forced to make have mostly been of a stylistic nature, except at one point. In the second lecture, as I actually gave it, the order of conceptual priority between the notions of proof and immediate inference was wrong. Since I discovered my mistake later the same month as the meeting was held, I thought it better to let the written text diverge from the oral presentation rather than possibly confusing others by letting the mistake remain. The oral origin of these lectures is the source of the many redundancies of the written text. It is also my sole excuse for the lack of detailed references. First lecture When I was asked to give these lectures about a year ago, I suggested the title On the Meanings of the Logical Constants and the Justifications of the Logical Laws. So that is what I shall talk about, eventually, but, first of all, I shall have to say something about, on the one hand, the things that the logical operations operate on, which we normally call propositions and propositional functions, and, on the Nordic Journal of Philosophical Logic, Vol. 1, No. 1, pp. 11-60. cfl 1996 Scandinavian University Press. 12 per martin-l"of other hand, the things that the logical laws, by which I mean the rules of inference, operate on, which we normally call assertions. We must remember that, even if a logical inference, for instance, a conjunction introduction, is written A B A & B which is the way in which we would normally write it, it does not take us from the propositions A and B to the proposition A & B. Rather, it takes us from the affirmation of A and the affirmation of B to the affirmation of A & B, which we may make explicit, using Frege's notation, by writing it ` A ` B ` A & B instead. It is always made explicit in this way by Frege in his writings, and in Principia, for instance. Thus we have two kinds of entities here: we have the entities that the logical operations operate on, which we call propositions, and we have those that we prove and that appear as premises and conclusion of a logical inference, which we call assertions. It turns out that, in order to clarify the meanings of the logical constants and justify the logical laws, a considerable portion of the philosophical work lies already in clarifying the notion of proposition and the notion of assertion. Accordingly, a large part of my lectures will be taken up by a philosophical analysis of these two notions. Let us first look at the term proposition. It has its origin in the Gr. pri`tasij, used by Aristotle in the Prior Analytics, the third part of the Organon. It was translated, apparently by Cicero, into Lat. propositio, which has its modern counterparts in It. proposizione, Eng. proposition and Ger. Satz. In the old, traditional use of the word proposition, propositions are the things that we prove. We talk about proposition and proof, of course, in mathematics: we put up a proposition and let it be followed by its proof. In particular, the premises and conclusion of an inference were propositions in this old terminology. It was the standard use of the word up to the last century. And it is this use which is retained in mathematics, where a theorem is sometimes called a proposition, sometimes a theorem. Thus we have two words for the things that we prove, proposition and theorem. The word proposition, Gr. pri`tasij, comes from Aristotle and has dominated the logical tradition, whereas the word theorem, Gr. qey"rhma, is in Euclid, I believe, and has dominated the mathematical tradition. With Kant, something important happened, namely, that the term judgement, Ger. Urteil, came to be used instead of proposition. on the meanings of the logical constants 13 Perhaps one reason is that proposition, or a word with that stem, at least, simply does not exist in German: the corresponding German word would be Lehrsatz, or simply Satz. Be that as it may, what happened with Kant and the ensuing German philosophical tradition was that the word judgement came to replace the word proposition. Thus, in that tradition, a proof, Ger. Beweis, is always a proof of a judgement. In particular, the premises and conclusion of a logical inference are always called judgements. And it was the judgements, or the categorical judgements, rather, which were divided into affirmations and denials, whereas earlier it was the propositions which were so divided. The term judgement also has a long history. It is the Gr. krDHsij, translated into Lat. judicium, It. giudizio, Eng. judgement, and Ger. Urteil. Now, since it has as long a history as the word proposition, these two were also previously used in parallel. The traditional way of relating the notions of judgement and proposition was by saying that a proposition is the verbal expression of a judgement. This is, as far as I know, how the notions of proposition and judgement were related during the scholastic period, and it is something which is repeated in the Port Royal Logic, for instance. You still find it repeated by Brentano in this century. Now, this means that, when, in German philosophy beginning with Kant, what was previously called a proposition came to be called a judgement, the term judgement acquired a double meaning. It came to be used, on the one hand, for the act of judging, just as before, and, on the other hand, it came to be used instead of the old proposition. Of course, when you say that a proposition is the verbal expression of a judgement, you mean by judgement the act of judging, the mental act of judging in scholastic terms, and the proposition is the verbal expression by means of which you make the mental judgement public, so to say. That is, I think, how one thought about it. Thus, with Kant, the term judgement became ambiguous between the act of judging and that which is judged, or the judgement made, if you prefer. German has here the excellent expression gef"alltes Urteil, which has no good counterpart in English. judgement z ""-- - the act of judging that which is judged old tradition judgement proposition Kant Urteil(sakt) (gef"alltes) Urteil This ambiguity is not harmful, and sometimes it is even convenient, because, after all, it is a kind of ambiguity that the word judgement 14 per martin-l"of shares with other nouns of action. If you take the word proposition, for instance, it is just as ambiguous between the act of propounding and that which is propounded. Or, if you take the word affirmation, it is ambiguous between the act of affirming and that which is affirmed, and so on. It should be clear, from what I said in the beginning, that there is a difference between what we now call a proposition and a proposition in the old sense. In order to trace the emergence of the modern notion of proposition, I first have to consider the division of propositions in the old sense into affirmations and denials. Thus the propositions, or the categorical propositions, rather, were divided into affirmations and denials. (categorical) proposition z ""-- - affirmation denial And not only were the categorical propositions so divided: the very definition of a categorical proposition was that a categorical proposition is an affirmation or a denial. Correlatively, to judge was traditionally, by which I mean before Kant, defined as to combine or separate ideas in the mind, that is, to affirm or deny. Those were the traditional definitions of the notions of proposition and judgement. The notions of affirmation and denial have fortunately remained stable, like the notion of proof, and are therefore easy to use without ambiguity. Both derive from Aristotle. Affirmation is Gr. katL'fasij, Lat. affirmatio, It. affermazione, and Ger. Bejahung, whereas denial is Gr. C'pi`fasij, Lat. negatio, It. negazione, and Ger. Verneinung. In Aristotelian logic, an affirmation was defined as a proposition in which something, called the predicate, is affirmed of something else, called the subject, and a denial was defined as a proposition in which the predicate is denied of the subject. Now, this is something that we have certainly abandoned in modern logic. Neither do we take categorical judgements to have subject-predicate form, nor do we treat affirmation and denial symmetrically. It seems to have been Bolzano who took the crucial step of replacing the Aristotelian forms of judgement by the single form A is, A is true, or A holds. In this, he was followed by Brentano, who also introduced the opposite form A is not, or A is false, on the meanings of the logical constants 15 and Frege. And, through Frege's influence, the whole of modern logic has come to be based on the single form of judgement, or assertion, A is true. Once this step was taken, the question arose, What sort of thing is it that is affirmed in an affirmation and denied in a denial? that is, What sort of thing is the A here? The isolation of this concept belongs to the, if I may so call it, objectivistically oriented branch of German philosophy in the last century. By that, I mean the tradition which you may delimit by mentioning the names of, say, Bolzano, Lotze, Frege, Brentano, and the Brentano disciples Stumpf, Meinong, and Husserl, although, with Husserl, I think one should say that the split between the objectivistic and the Kantian branches of German philosophy is finally overcome. The isolation of this concept was a step which was entirely necessary for the development of modern logic. Modern logic simply would not work unless we had this concept, because it is on the things that fall under it that the logical operations operate. This new concept, which simply did not exist before the last century, was variously called. And, since it was something that one had not met before, one had difficulties with what one should call it. Among the terms that were used, I think the least committing one is Ger. Urteilsinhalt, content of a judgement, by which I mean that which is affirmed in an affirmation and denied in a denial. Bolzano, who was the first to introduce this concept, called it proposition in itself, Ger. Satz an sich. Frege also grappled with this terminological problem. In Begriffsschrift, he called it judgeable content, Ger. beurteilbarer Inhalt. Later on, corresponding to his threefold division into expression, sense, and reference, in the case of this kind of entity, what was the expression, he called sentence, Ger. Satz, what was the sense, he called thought, Ger. Gedanke, and what was the reference, he called truth value, Ger. Wahrheitswert. So the question arises, What should I choose here? Should I choose sentence, thought, or truth value? The closest possible correspondence is achieved, I think, if I choose Gedanke, that is, thought, for late Frege. This is confirmed by the fact that, in his very late logical investigations, he called the logical operations the Gedankengef"uge. Thus judgeable content is early Frege and thought is late Frege. We also have the term state of affairs, Ger. Sachverhalt, which was introduced by Stumpf and used by Wittgenstein in the Tractatus. And, finally, we have the term objective, Ger. Objektiv, which was the term used by Meinong. Maybe there were other terms as well in circulation, but these are the ones that come immediately to my mind. Now, Russell used the term proposition for this new notion, which 16 per martin-l"of has become the standard term in Anglo-Saxon philosophy and in modern logic. And, since he decided to use the word proposition in this new sense, he had to use another word for the things that we prove and that figure as premises and conclusion of a logical inference. His choice was to translate Frege's Urteil, not by judgement, as one would expect, but by assertion. And why, one may ask, did he choose the word assertion rather than translate Urteil literally by judgement? I think it was to avoid any association with Kantian philosophy, because Urteil was after all the central notion of logic as it was done in the Kantian tradition. For instance, in his transcendental logic, which forms part of the Kritik der reinen Vernunft, Kant arrives at his categories by analysing the various forms that a judgement may have. That was his clue to the discovery of all pure concepts of reason, as he called it. Thus, in Russell's hands, Frege's Urteil came to be called assertion, and the combination of Frege's Urteilsstrich, judgement stroke, and Inhaltsstrich, content stroke, came to be called the assertion sign. Observe now where we have arrived through this development, namely, at a notion of proposition which is entirely different, or different, at least, from the old one, that is, from the Gr. pri`tasij and the Lat. propositio. To repeat, the things that we prove, in particular, the premises and conclusion of a logical inference, are no longer propositions in Russell's terminology, but assertions. Conversely, the things that we combine by means of the logical operations, the connectives and the quantifiers, are not propositions in the old sense, that is, what Russell calls assertions, but what he calls propositions. And, as I said in the very beginning, the rule of conjunction introduction, for instance, really allows us to affirm A & B, having affirmed A and having affirmed B, ` A ` B ` A & B It is another matter, of course, that we may adopt conventions that allow us to suppress the assertion sign, if it becomes too tedious to write it out. Conceptually, it would nevertheless be there, whether I write it as above or A true B true A & B true as I think that I shall do in the following. So far, I have made no attempt at defining the notions of judgement, or assertion, and proposition. I have merely wanted to give a preliminary hint at the difference between the two by showing how the terminology has evolved. on the meanings of the logical constants 17 To motivate my next step, consider any of the usual inference rules of the propositional or predicate calculus. Let me take the rule of disjunction introduction this time, for some change, A A . B or, writing out the affirmation, A true A . B true Now, what do the variables A and B range over in a rule like this? That is, what are you allowed to insert into the places indicated by these variables? The standard answer to this question, by someone who has received the now current logical education, would be to say that A and B range over arbitrary formulas of the language that you are considering. Thus, if the language is first order arithmetic, say, then A and B should be arithmetical formulas. When you start thinking about this answer, you will see that there is something strange about it, namely, its language dependence. Because it is clearly irrelevant for the validity of the rule whether A and B are arithmetical formulas, corresponding to the language of first order arithmetic, or whether they contain, say, predicates defined by transfinite, or generalized, induction. The unary predicate expressing that a natural number encodes an ordinal of the constructive second number class, for instance, is certainly not expressible in first order arithmetic, and there is no reason at all why A and B should not be allowed to contain that predicate. Or, surely, for the validity of the rule, A and B might just as well be set theoretical formulas, supposing that we have given such a clear sense to them that we clearly recognize that they express propositions. Thus what is important for the validity of the rule is merely that A and B are propositions, that is, that the expressions which we insert into the places indicated by the variables A and B express propositions. It seems, then, that the deficiency of the first answer, by which I mean the answer that A and B should range over formulas, is eliminated by saying that the variables A and B should range over propositions instead of formulas. And this is entirely natural, because, after all, the notion of formula, as given by the usual inductive definition, is nothing but the formalistic substitute for the notion of proposition: when you divest a proposition in some language of all sense, what remains is the mere formula. But then, supposing we agree that the natural way out of the first difficulty is to say that A and B should range over arbitrary 18 per martin-l"of propositions, another difficulty arises, because, whereas the notion of formula is a syntactic notion, a formula being defined as an expression that can be formed by means of certain formation rules, the notion of proposition is a semantic notion, which means that the rule is no longer completely formal in the strict sense of formal logic. That a rule of inference is completely formal means precisely that there must be no semantic conditions involved in the rule: it may only put conditions on the forms of the premises and conclusion. The only way out of this second difficulty seems to be to say that, really, the rule has not one but three premises, so that, if we were to write them all out, it would read A prop B prop A true A . B true that is, from A and B being propositions and from the truth of A, we are allowed to conclude the truth of A . B. Here I am using A prop as an abbreviated way of saying that A is a proposition. Now the complete formality of the rule has been restored. Indeed, for the variables A and B, as they occur in this rule, we may substitute anything we want, and, by anything, I mean any expressions. Or, to be more precise, if we categorize the expressions, as Frege did, into complete, or saturated, expressions and incomplete, unsaturated, or functional, expressions, then we should say that we may substitute for A and B any complete expressions we want, because propositions are always expressed by complete expressions, not by functional expressions. Thus A and B now range over arbitrary complete expressions. Of course, there would be needed here an analysis of what is understood by an expression, but that is something which I shall not go into in these lectures, in the belief that it is a comparatively trivial matter, as compared with explaining the notions of proposition and judgement. An expression in the most general sense of the word is nothing but a form, that is, something that we can passively recognize as the same in its manifold occurrences and actively reproduce in many copies. But I think that I shall have to rely here upon an agreement that we have such a general notion of expression, which is formal in character, so that the rule can now count as a formal rule. Now, if we stick to our previous decision to call what we prove, in particular, the premises and conclusion of a logical inference, by the on the meanings of the logical constants 19 word judgement, or assertion, the outcome of the preceding considerations is that we are faced with a new form of judgement. After all, A prop and B prop have now become premises of the rule of disjunction introduction. Hence, if premises are always judgements, A is a proposition must count as a form of judgement. This immediately implies that the traditional definition of the act of judging as an affirming or denying and of the judgement, that is, the proposition in the terminology then used, as an affirmation or denial has to be rejected, because A prop is certainly neither an affirmation nor a denial. Or, rather, we are faced with the choice of either keeping the old definition of judgement as an affirmation or a denial, in which case we would have to invent a new term for the things that we prove and that figure as premises and conclusion of a logical inference, or else abandoning the old definition of judgement, widening it so as to make room for A is a proposition as a new form of judgement. I have chosen the latter alternative, well aware that, in so doing, I am using the word judgement in a new way. Having rejected the traditional definition of a judgement as an affirmation or a denial, by what should we replace it? How should we now delimit the notion of judgement, so that A is a proposition, A is true, and A is false all become judgements? And there are other forms of judgement as well, which we shall meet in due course. Now, the question, What is a judgement? is no small question, because the notion of judgement is just about the first of all the notions of logic, the one that has to be explained before all the others, before even the notions of proposition and truth, for instance. There is therefore an intimate relation between the answer to the question what a judgement is and the very question what logic itself is. I shall start by giving a very simple answer, which is essentially right: after some elaboration, at least, I hope that we shall have a sufficiently clear understanding of it. And the definition would simply be that, when understood as an act of judging, a judgement is nothing but an act of knowing, and, when understood as that which is judged, it is a piece or, more solemnly, an object of knowledge. judgement z ""-- - the act of judging that which is judged the act of knowing the object of knowledge Thus, first of all, we have the ambiguity of the term judgement between the act of judging and that which is judged. What I say is that an act 20 per martin-l"of of judging is essentially nothing but an act of knowing, so that to judge is the same as to know, and that what is judged is a piece, or an object, of knowledge. Unfortunately, the English language has no counterpart of Ger. eine Erkenntnis, a knowledge. This new definition of the notion of judgement, so central to logic, should be attributed in the first place to Kant, I think, although it may be difficult to find him ever explicitly saying that the act of judging is the same as the act of knowing, and that what is judged is the object of knowledge. Nevertheless, it is behind all of Kant's analysis of the notion of judgement that to judge amounts to the same as to know. It was he who broke with the traditional, Aristotelian definition of judgement as an affirmation or a denial. Explicitly, the notions of judgement and knowledge were related by Bolzano, who simply defined knowledge as evident judgement. Thus, for him, the order of priority was the reverse: knowledge was defined in terms of judgement rather than the other way round. The important thing to realize is of course that to judge and to know, and, correlatively, judgement and knowledge, are essentially the same. And, when the relation between judgement, or assertion, if you prefer, and knowledge is understood in this way, logic itself is naturally understood as the theory of knowledge, that is, of demonstrative knowledge, Aristotle's a^pista*mh C'podeiktika*. Thus logic studies, from an objective point of view, our pieces of knowledge as they are organized in demonstrative science, or, if you think about it from the act point of view, it studies our acts of judging, or knowing, and how they are interrelated. As I said a moment ago, this is only a first approximation, because it would actually have been better if I had not said that an act of judging is an act of knowing, but if I had said that it is an act of, and here there are many words that you may use, either understanding, or comprehending, or grasping, or seeing, in the metaphorical sense of the word see in which it is synonymous with understand. I would prefer this formulation, because the relation between the verb to know and the verb to understand, comprehend, grasp, or see, is given by the equation to know = to have understood, comprehended, grasped, seen, which has the converse to understand, comprehend, grasp, see = to get to know. The reason why the first answer needs elaboration is that you may use know in English both in the sense of having understood and in the sense of getting to understand. Now, the first of the preceding on the meanings of the logical constants 21 two equations brings to expression something which is deeply rooted in the Indo-European languages. For instance, Gr. oU'da, I know, is the perfect form of the verb whose present form is Gr. eO`dw, I see. Thus to know is to have seen merely by the way the verb has been formed in Greek. It is entirely similar in Latin. You have Lat. nosco, I get to know, which has present form, and Lat. novi, I know, which has perfect form. So, in these and other languages, the verb to know has present sense but perfect form. And the reason for the perfect form is that to know is to have seen. Observe also the two metaphors for the act of understanding which you seem to have in one form or the other in all European languages: the metaphor of seeing, first of all, which was so much used by the Greeks, and which we still use, for instance, when saying that we see that there are infinitely many prime numbers, and, secondly, the metaphor of grasping, which you also find in the verb to comprehend, derived as it is from Lat. prehendere, to seize. The same metaphor is found in Ger. fassen and begreifen, and I am sure that you also have it in Italian. (Chorus. Afferare!) Of course, these are two metaphors that we use for this particular act of the mind: the mental act of understanding is certainly as different from the perceptual act of seeing something as from the physical act of grasping something. Is a judgement a judgement already before it is grasped, that is, becomes known, or does it become a judgement only through our act of judging? And, in the latter case, what should we call a judgement before it has been judged, that is, has become known? For example, if you let G be the proposition that every even number is the sum of two prime numbers, and then look at G is true, is it a judgement, or is it not a judgement? Clearly, in one sense, it is, and, in another sense, it is not. It is not a judgement in the sense that it is not known, that is, that it has not been proved, or grasped. But, in another sense, it is a judgement, namely, in the sense that G is true makes perfectly good sense, because G is a proposition which we all understand, and, presumably, we understand what it means for a proposition to be true. The distinction I am hinting at is the distinction which was traditionally made between an enunciation and a proposition. Enunciation is not a word of much currency in English, but I think that its Italian counterpart has fared better. The origin is the Gr. C'pi`fansij as it appears in De Interpretatione, the second part of the Organon. It has been translated into Lat. enuntiatio, It. enunciato, and Ger. Aussage. An enunciation is what a proposition, in the old sense of the word, is before it has been proved, or become known. Thus 22 per martin-l"of it is a proposition stripped of its epistemic force. For example, in this traditional terminology, which would be fine if it were still living, G is true is a perfectly good enunciation, but it is not a proposition, not yet at least. But now that we have lost the term proposition in its old sense, having decided to use it in the sense in which it started to be used by Russell and is now used in Anglo-Saxon philosophy and modern logic, I think we must admit that we have also lost the traditional distinction between an enunciation and a proposition. Of course, we still have the option of keeping the term enunciation, but it is no longer natural. Instead, since I have decided to replace the term proposition in its old sense, as that which we prove and which may appear as premise or conclusion of a logical inference, by the term judgement, as it has been used in German philosophy from Kant and onwards, it seems better, when there is a need of making the distinction between an enunciation and a proposition, that is, between a judgement before and after it has been proved, or become known, to speak of a judgement and an evident judgement, respectively. This is a wellestablished usage in the writings of Bolzano, Brentano, and Husserl, that is, within the objectivistically oriented branch of German philosophy that I mentioned earlier. If we adopt this terminology, then we are faced with a fourfold table, which I shall end by writing up. judgement proposition evident judgement true proposition Thus, correlated with the distinction between judgement and proposition, there is the distinction between evidence of a judgement and truth of a proposition. So far, I have said very little about the notions of proposition and truth. The essence of what I have said is merely that to judge is the same as to know, so that an evident judgement is the same as a piece, or an object, of knowledge, in agreement with Bolzano's definition of knowledge as evident judgement. Tomorrow's lecture will have to be taken up by an attempt to clarify the notion of evidence and the notions of proposition and truth. Second lecture Under what condition is it right, or correct, to make a judgement, one of the form A is true, on the meanings of the logical constants 23 which is certainly the most basic form of judgement, for instance? When one is faced with this question for the first time, it is tempting to answer simply that it is right to say that A is true provided that A is true, and that it is wrong to say that A is true provided that A is not true, that is, provided that A is false. In fact, this is what Aristotle says in his definition of truth in the Metaphysics. For instance, he says that it is not because you rightly say that you are white that you are white, but because you are white that what you say is correct. But a moment's reflection shows that this first answer is simply wrong. Even if every even number is the sum of two prime numbers, it is wrong of me to say that unless I know it, that is, unless I have proved it. And it would have been wrong of me to say that every map can be coloured by four colours before the recent proof was given, that is, before I acquired that knowledge, either by understanding the proof myself, or by trusting its discoverers. So the condition for it to be right of me to affirm a proposition A, that is, to say that A is true, is not that A is true, but that I know that A is true. This is a point which has been made by Dummett and, before him, by Brentano, who introduced the apt term blind judgement for a judgement which is made by someone who does not know what he is saying, although what he says is correct in the weaker sense that someone else knows it, or, perhaps, that he himself gets to know it at some later time. When you are forced into answering a yes or no question, although you do not know the answer, and happen to give the right answer, right as seen by someone else, or by you yourself when you go home and look it up, then you make a blind judgement. Thus you err, although the teacher does not discover your error. Not to speak of the fact that the teacher erred more greatly by not giving you the option of giving the only the answer which would have been honest, namely, that you did not know. The preceding consideration does not depend on the particular form of judgement, in this case, A is true, that I happened to use as an example. Quite generally, the condition for it to be right of you to make a judgement is that you know it, or, what amounts to the same, that it is evident to you. The notion of evidence is related to the notion of knowledge by the equation evident = known. When you say that a judgement is evident, you merely express that you have understood, comprehended, grasped, or seen it, that is, that you know it, because to have understood is to know. This is reflected in the etymology of the word evident, which comes from Lat. ex, out of, from, and videre, to see, in the metaphorical sense, of course. 24 per martin-l"of There is absolutely no question of a judgement being evident in itself, independently of us and our cognitive activity. That would be just as absurd as to speak of a judgement as being known, not by somebody, you or me, but in itself. To be evident is to be evident to somebody, as inevitably as to be known is to be known by somebody. That is what Brouwer meant by saying, in Consciousness, Philosophy, and Mathematics, that there are no nonexperienced truths, a basic intuitionistic tenet. This has been puzzling, because it has been understood as referring to the truth of a proposition, and clearly there are true propositions whose truth has not been experienced, that is, propositions which can be shown to be true in the future, although they have not been proved to be true now. But what Brouwer means here is not that. He does not speak about propositions and truth: he speaks about judgements and evidence, although he uses the term truth instead of the term evidence. And what he says is then perfectly right: there is no evident judgement whose evidence has not been experienced, and experience it is what you do when you understand, comprehend, grasp, or see it. There is no evidence outside our actual or possible experience of it. The notion of evidence is by its very nature subject related, relative to the knowing subject, that is, in Kantian terminology. As I already said, when you make, or utter, a judgement under normal circumstances, you thereby express that you know it. There is no need to make this explicit by saying, I know that . . . For example, when you make a judgement of the form A is true under normal circumstances, by so doing, you already express that you know that A is true, without having to make this explicit by saying, I know that A is true, or the like. A judgement made under normal circumstances claims by itself to be evident: it carries its claim of evidence automatically with it. This is a point which was made by Wittgenstein in the Tractatus by saying that Frege's Urteilsstrich, judgement stroke, is logically quite meaningless, since it merely indicates that the proposition to which it is prefixed is held true by the author, although it would perhaps have been better to say, not that it is meaningless, but that it is superfluous, since, when you make a judgement, it is clear already from its form that you claim to know it. In speech act philosophy, this is expressed by on the meanings of the logical constants 25 saying that knowing is an illocutionary force: it is not an explicit part of what you say that you know it, but it is implicit in your saying of it. This is the case, not only with judgements, that is, acts of knowing, but also with other kinds of acts. For instance, if you say, Would she come tonight! it is clear from the form of your utterance that you express a wish. There is no need of making this explicit by saying, I wish that she would come tonight. Some languages, like Greek, use the optative mood to make it clear that an utterance expresses a wish or desire. Consider the pattern that we have arrived at now, I act z ""-- -know objectz ""-- - A is true Here the grammatical subject I refers to the subject, self, or ego, and the grammatical predicate know to the act, which in this particular case is an act of knowing, but might as well have been an act of conjecturing, doubting, wishing, fearing, etc. Thus the predicate know indicates the modality of the act, that is, the way in which the subject relates to the object, or the particular force which is involved, in this case, the epistemic force. Observe that the function of the grammatical moods, indicative, subjunctive, imperative, and optative, is to express modalities in this sense. Finally, A is true is the judgement or, in general, the object of the act, which in this case is an object of knowledge, but might have been an object of conjecture, doubt, wish, fear, etc. The closest possible correspondence between the analysis that I am giving and Frege's notation for a judgement ` A is obtained by thinking of the vertical, judgement stroke as carrying the epistemic force I know . . . and the horizontal, content stroke as expressing the affirmation . . . is true. 26 per martin-l"of Then it is the vertical stroke which is superfluous, whereas the horizontal stroke is needed to show that the judgement has the form of an affirmation. But this can hardly be read out of Frege's own account of the assertion sign: you have to read it into his text. What is a judgement before it has become evident, or known? That is, of the two, judgement and evident judgement, how is the first to be defined? The characteristic of a judgement in this sense is merely that it has been laid down what knowledge is expressed by it, that is, what you must know in order to have the right to make, or utter, it. And this is something which depends solely on the form of the judgement. For example, if we consider the two forms of judgement A is a proposition and A is true, then there is something that you must know in order to have the right to make a judgement of the first form, and there is something else which you must know, in addition, in order to have the right to make a judgement of the second form. And what you must know depends in neither case on A, but only on the form of the judgement, . . . is a proposition or . . . is true, respectively. Quite generally, I may say that a judgement in this sense, that is, a not yet known, and perhaps even unknowable, judgement, is nothing but an instance of a form of judgement, because it is for the various forms of judgement that I lay down what you must know in order to have the right to make a judgement of one of those forms. Thus, as soon as something has the form of a judgement, it is already a judgement in this sense. For example, A is a proposition is a judgement in this sense, because it has a form for which I have laid down, or rather shall lay down, what you must know in order to have the right to make a judgement of that form. I think that I may make things a bit clearer by showing again in a picture what is involved here. Let me take the first form to begin with. I evident judgement z ""-- - know judgement z ""-- -\Upsilon \Sigma \Xi \Pi \Lambda \Theta \Gamma \Delta A is a proposition expression\Delta \Delta form of judgementA on the meanings of the logical constants 27 Here is involved, first, an expression A, which should be a complete expression. Second, we have the form . . . is a proposition, which is the form of judgement. Composing these two, we arrive at A is a proposition, which is a judgement in the first sense. And then, third, we have the act in which I grasp this judgement, and through which it becomes evident. Thus it is my act of grasping which is the source of the evidence. These two together, that is, the judgement and my act of grasping it, become the evident judgement. And a similar analysis can be given of a judgement of the second form. I evident judgement z ""-- - know judgement z ""-- -\Upsilon \Sigma \Xi \Pi \Lambda \Theta \Gamma \Delta A is true proposition\Delta \Delta form of judgementA Such a judgement has the form . . . is true, but what fills the open place, or hole, in the form is not an expression any longer, but a proposition. And what is a proposition? A proposition is an expression for which the previous judgement has already been grasped, because there is no question of something being true unless you have previously grasped it as a proposition. But otherwise the picture remains the same here. Now I must consider the discussion of the notion of judgement finished and pass on to the notion of proof. Proof is a good word, because, unlike the word proposition, it has not changed its meaning. Proof apparently means the same now as it did when the Greeks discovered the notion of proof, and therefore no terminological difficulties arise. Observe that both Lat. demonstratio and the corresponding words in the modern languages, like It. dimostrazione, Eng. demonstration, and Ger. Beweis, are literal translations of Gr. C'pi`deicij, deriving as it does from Gr. deDHknumi, I show, which has the same meaning as Lat. monstrare and Ger. weisen. If you want to have a first approximation to the notion of proof, a first definition of what a proof is, the strange thing is that you cannot look it up in any modern textbook of logic, because what you get out of the standard textbooks of modern logic is the definition of what a formal proof is, at best with a careful discussion clarifying that a formal proof in the sense of this definition is not what we ordinarily call a proof in mathematics. That is, you get a formal proof defined as a finite sequence of formulas, each one of them being an immediate consequence of some of the preceding ones, where the notion of immediate consequence, in turn, is defined by saying that a formula is an 28 per martin-l"of immediate consequence of some other formulas if there is an instance of one of the figures, called rules of inference, which has the other formulas as premises and the formula itself as conclusion. Now, this is not what a real proof is. That is why you have the warning epithet formal in front of it, and do not simply say proof. What is a proof in the original sense of the word? The ordinary dictionary definition says, with slight variations, that a proof is that which establishes the truth of a statement. Thus a proof is that which makes a mathematical statement, or enunciation, into a theorem, or proposition, in the old sense of the word which is retained in mathematics. Now, remember that I have reserved the term true for true propositions, in the modern sense of the word, and that the things that we prove are, in my terminology, judgements. Moreover, to avoid terminological confusion, judgements qualify as evident rather than true. Hence, translated into the terminology that I have decided upon, the dictionary definition becomes simply, A proof is what makes a judgement evident. Accepting this, that is, that the proof of a judgement is that which makes it evident, we might just as well say that the proof of a judgement is the evidence for it. Thus proof is the same as evidence. Combining this with the outcome of the previous discussion of the notion of evidence, which was that it is the act of understanding, comprehending, grasping, or seeing a judgement which confers evidence on it, the inevitable conclusion is that the proof of a judgement is the very act of grasping it. Thus a proof is, not an object, but an act. This is what Brouwer wanted to stress by saying that a proof is a mental construction, because what is mental, or psychic, is precisely our acts, and the word construction, as used by Brouwer, is but a synonym for proof. Thus he might just as well have said that the proof of a judgement is the act of proving, or grasping, it. And the act is primarily the act as it is being performed. Only secondarily, and irrevocably, does it become the act that has been performed. As is often the case, it might have been better to start with the verb rather than the noun, in this case, with the verb to prove rather than with the noun proof. If a proof is what makes a judgement evident, then, clearly, to prove a judgement is to make it evident, or known. To prove something to yourself is simply to get to know it. And to prove something to someone else is to try to get him, or her, to know it. Hence to prove = to get to know = to understand, comprehend, grasp, or see. on the meanings of the logical constants 29 This means that prove is but another synonym for understand, comprehend, grasp, or see. And, passing to the perfect tense, to have proved = to know = to have understood, comprehended, grasped, or seen. We also speak of acquiring and possessing knowledge. To possess knowledge is the same as to have acquired it, just as to know something is the same as to have understood, comprehended, grasped, or seen it. Thus the relation between the plain verb to know and the venerable expressions to acquire and to possess knowledge is given by the two equations, to get to know = to acquire knowledge and to know = to possess knowledge. On the other hand, the verb to prove and the noun proof are related by the two similar equations, to prove = to acquire, or construct, a proof and to have proved = to possess a proof. It is now manifest, from these equations, that proof and knowledge are the same. Thus, if proof theory is construed, not in Hilbert's sense, as metamathematics, but simply as the study of proofs in the original sense of the word, then proof theory is the same as theory of knowledge, which, in turn, is the same as logic in the original sense of the word, as the study of reasoning, or proof, not as metamathematics. Remember that the proof of a judgement is the very act of knowing it. If this act is atomic, or indivisible, then the proof is said to be immediate. Otherwise, that is, if the proof consists of a whole sequence, or chain, of atomic actions, it is mediate. And, since proof and knowledge are the same, the attributes immediate and mediate apply equally well to knowledge. In logic, we are no doubt more used to saying of inferences, rather than proofs, that they are immediate or mediate, as the case may be. But that makes no difference, because inference and proof are the same. It does not matter, for instance, whether we say rules of inference or proof rules, as has become the custom in programming. And, to take another example, it does not matter whether we say that a mediate proof is a chain of immediate inferences or a chain 30 per martin-l"of of immediate proofs. The notion of formal proof that I referred to in the beginning of my discussion of the notion of proof has been arrived at by formalistically interpreting what you mean by an immediate inference, by forgetting about the difference between a judgement and a proposition, and, finally, by interpreting the notion of proposition formalistically, that is, by replacing it by the notion of formula. But a real proof is and remains what it has always been, namely, that which makes a judgement evident, or simply, the evidence for it. Thus, if we do not have the notion of evidence, we do not have the notion of proof. That is why the notion of proof has fared so badly in those branches of philosophy where the notion of evidence has fallen into disrepute. We also speak of a judgement being immediately and mediately evident, respectively. Which of the two is the case depends of course on the proof which constitutes the evidence for the judgement. If the proof is immediate, then the judgement is said to be immediately evident. And an immediately evident judgement is what we call an axiom. Thus an axiom is a judgement which is evident by itself, not by virtue of some previously proved judgements, but by itself, that is, a self-evident judgement, as one has always said. That is, always before the notion of evidence became disreputed, in which case the notion of axiom and the notion of proof simply become deflated: we cannot make sense of the notion of axiom and the notion of proof without access to the notion of evidence. If, on the other hand, the proof which constitutes the evidence for a judgement is a mediate one, so that the judgement is evident, not by itself, but only by virtue of some previously proved judgements, then the judgement is said to be mediately evident. And a mediately evident judgement is what we call a theorem, as opposed to an axiom. Thus an evident judgement, that is, a proposition in the old sense of the word which is retained in mathematics, is either an axiom or a theorem. Instead of applying the attributes immediate and mediate to proof, or knowledge, I might have chosen to speak of intuitive and discursive proof, or knowledge, respectively. That would have implied no difference of sense. The proof of an axiom can only be intuitive, which is to say that an axiom has to be grasped immediately, in a single act. The word discursive, on the other hand, comes from Lat. discurrere, to run to and fro. Thus a discursive proof is one which runs, from premises to conclusion, in several steps. It is the opposite of an intuitive proof, which brings you to the conclusion immediately, in a single step. When one says that the immediate propositions in the old sense of the word proposition, that is, the immediately evident judgements in my terminology, are unprovable, what is meant is of course only that on the meanings of the logical constants 31 they cannot be proved discursively. Their proofs have to rest intuitive. This seems to be all that I have to say about the notion of proof at the moment, so let me pass on to the next item on the agenda, the forms of judgement and their semantical explanations. The forms of judgement have to be displayed in a table, simply, and the corresponding semantical explanations have to be given, one for each of those forms. A form of judgement is essentially just what is called a category, not in the sense of category theory, but in the logical, or philosophical, sense of the word. Thus I have to say what my forms of judgement, or categories, are, and, for each one of those forms, I have to explain what you must know in order to have the right to make a judgement of that form. By the way, the forms of judgement have to be introduced in a specific order. Actually, not only the forms of judgement, but all the notions that I am undertaking to explain here have to come in a specific order. Thus, for instance, the notion of judgement has to come before the notion of proposition, and the notion of logical consequence has to be dealt with before explaining the notion of implication. There is an absolute rigidity in this order. The notion of proof, for instance, has to come precisely where I have put it here, because it is needed in some other explanations further on, where it is presupposed already. Revealing this rigid order, thereby arriving eventually at the concepts which have to be explained prior to all other concepts, turns out to be surprisingly difficult: you seem to arrive at the very first concepts last of all. I do not know what it should best be called, maybe the order of conceptual priority, one concept being conceptually prior to another concept if it has to be explained before the other concept can be explained. Let us now consider the first form of judgement, A is a proposition, or, as I shall continue to abbreviate it, A prop. What I have just displayed to you is a linguistic form, and I hope that you can recognize it. What you cannot see from the form, and which I therefore proceed to explain to you, is of course its meaning, that is, what knowledge is expressed by, or embodied in, a judgement of this form. The question that I am going to answer is, in ontological terms, What is a proposition? This is the usual Socratic way of formulating questions of this sort. Or I could ask, in more knowledge theoretical terminology, 32 per martin-l"of What is it to know a proposition? or, if you prefer, What knowledge is expressed by a judgement of the form A is a proposition? or, this may be varied endlessly, What does a judgement of the form A is a proposition mean? These various ways of posing essentially the same question reflect roughly the historical development, from a more ontological to a more knowledge theoretical way of posing, and answering, questions of this sort, finally ending up with something which is more linguistic in nature, having to do with form and meaning. Now, one particular answer to this question, however it be formulated, is that a proposition is something that is true or false, or, to use Aristotle's formulation, that has truth or falsity in it. Here we have to be careful, however, because what I am going to explain is what a proposition in the modern sense is, whereas what Aristotle explained was what an enunciation, being the translation of Gr. C'pi`fansij, is. And it was this explanation that he phrased by saying that an enunciation is something that has truth or falsity in it. What he meant by this was that it is an expression which has a form of speech such that, when you utter it, you say something, whether truly or falsely. That is certainly not how we now interpret the definition of a proposition as something which is true or false, but it is nevertheless correct that it echoes Aristotle's formulation, especially in its symmetric treatment of truth and falsity. An elaboration of the definition of a proposition as something that is true or false is to say that a proposition is a truth value, the true or the false, and hence that a declarative sentence is an expression which denotes a truth value, or is the name of a truth value. This was the explanation adopted by Frege in his later writings. If a proposition is conceived in this way, that is, simply as a truth value, then there is no difficulty in justifying the laws of the classical propositional calculus and the laws of quantification over finite, explicitly listed, domains. The trouble arises when you come to the laws for forming quantified propositions, the quantifiers not being restricted to finite domains. That is, the trouble is to make the two laws A(x) prop (8x)A(x) prop A(x) prop (9x)A(x) prop on the meanings of the logical constants 33 evident when propositions are conceived as nothing but truth values. To my mind, at least, they simply fail to be evident. And I need not be ashamed of the reference to myself in this connection: as I said in my discussion of the notion of evidence, it is by its very nature subject related. Others must make up their minds whether these laws are really evident to them when they conceive of propositions simply as truth values. Although we have had this notion of proposition and these laws for forming quantified propositions for such a long time, we still have no satisfactory explanations which serve to make them evident on this conception of the notion of proposition. It does not help to restrict the quantifiers, that is, to consider instead the laws (x 2 A) B(x) prop (8x 2 A)B(x) prop (x 2 A) B(x) prop (9x 2 A)B(x) prop unless we restrict the quantifiers so severely as to take the set A here to be a finite set, that is, to be given by a list of its elements. Then, of course, there is no trouble with these rules. But, as soon as A is the set of natural numbers, say, you have the full trouble already. Since, as I said earlier, the law of the excluded middle, indeed, all the laws of the classical propositional calculus, are doubtlessly valid on this conception of the notion of proposition, this means that the rejection of the law of excluded middle is implicitly also a rejection of the conception of a proposition as something which is true or false. Hence the rejection of this notion of proposition is something which belongs to Brouwer. On the other hand, he did not say explicitly by what it should be replaced. Not even the wellknown papers by Kolmogorov and Heyting, in which the formal laws of intuitionistic logic were formulated for the first time, contain any attempt at explaining the notion of proposition in terms of which these laws become evident. It appears only in some later papers by Heyting and Kolmogorov from the early thirties. In the first of these, written by Heyting in 1930, he suggested that we should think about a proposition as a problem, Fr. probl`eme, or expectation, Fr. attente. And, in the wellknown paper of the following year, which appeared in Erkenntnis, he used the terms expectation, Ger. Erwartung, and intention, Ger. Intention. Thus he suggested that one should think of a proposition as a problem, or as an expectation, or as an intention. And, another year later, there appeared a second paper by Kolmogorov, in which he observed that the laws of the intuitionistic propositional calculus become evident upon thinking of the propositional variables as ranging over problems, or tasks. The term he actually used was 34 per martin-l"of Ger. Aufgabe. On the other hand, he explicitly said that he did not want to equate the notion of proposition with the notion of problem and, correlatively, the notion of truth of a proposition with the notion of solvability of a problem. He merely proposed the interpretation of propositions as problems, or tasks, as an alternative interpretation, validating the laws of the intuitionistic propositional calculus. Returning now to the form of judgement A is a proposition, the semantical explanation which goes together with it is this, and here I am using the knowledge theoretical formulation, that to know a proposition, which may be replaced, if you want, by problem, expectation, or intention, you must know what counts as a verification, solution, fulfillment, or realization of it. Here verification matches with proposition, solution with problem, fulfillment with expectation as well as with intention, and realization with intention. Realization is the term introduced by Kleene, but here I am of course not using it in his sense: Kleene's realizability interpretation is a nonstandard, or nonintended, interpretation of intuitionistic logic and arithmetic. The terminology of intention and fulfillment was taken over by Heyting from Husserl, via Oskar Becker, apparently. There is a long chapter in the sixth, and last, of his Logische Untersuchungen which bears the title Bedeutungsintention und Bedeutungserf"ullung, and it is these two terms, intention and fulfillment, Ger. Erf"ullung, that Heyting applied in his analysis of the notions of proposition and truth. And he did not just take the terms from Husserl: if you observe how Husserl used these terms, you will see that they were appropriately applied by Heyting. Finally, verification seems to be the perfect term to use together with proposition, coming as it does from Lat. verus, true, and facere, to make. So to verify is to make true, and verification is the act, or process, of verifying something. For a long time, I tried to avoid using the term verification, because it immediately gives rise to discussions about how the present account of the notions of proposition and truth is related to the verificationism that was discussed so much in the thirties. But, fortunately, this is fifty years ago now, and, since we have a word which lends itself perfectly to expressing what needs to be expressed, I shall simply use it, without wanting to get into discussion about how the present semantical theory is related to the verificationism of the logical positivists. What would an example be? If you take a proposition like, The sun is shining, on the meanings of the logical constants 35 to know that proposition, you must know what counts as a verification of it, which in this case would be the direct seeing of the shining sun. Or, if you take the proposition, The temperature is 10ffi C, then it would be a direct thermometer reading. What is more interesting, of course, is what the corresponding explanations look like for the logical operations, which I shall come to in my last lecture. Coupled with the preceding explanation of what a proposition is, is the following explanation of what a truth is, that is, of what it means for a proposition to be true. Assume first that A is a proposition, and, because of the omnipresence of the epistemic force, I am really asking you to assume that you know, that is, have grasped, that A is a proposition. On that assumption, I shall explain to you what a judgement of the form A is true, or, briefly, A true, means, that is, what you must know in order to have the right to make a judgement of this form. And the explanation would be that, to know that a proposition is true, a problem is solvable, an expectation is fulfillable, or an intention is realizable, you must know how to verify, solve, fulfill, or realize it, respectively. Thus this explanation equates truth with verifiability, solvability, fulfillability, or realizability. The important point to observe here is the change from is in A is true to can in A can be verified, or A is verifiable. Thus what is expressed in terms of being in the first formulation really has the modal character of possibility. Now, as I said earlier in this lecture, to know a judgement is the same as to possess a proof of it, and to know a judgement of the particular form A is true is the same as to know how, or be able, to verify the proposition A. Thus knowledge of a judgement of this form is knowledge how in Ryle's terminology. On the other hand, to know how to do something is the same as to possess a way, or method, of doing it. This is reflected in the etymology of the word method, which is derived from Gr. metL', after, and a*di`j, way. Taking all into account, we arrive at the conclusion that a proof that a proposition A is true 36 per martin-l"of is the same as a method of verifying, solving, fulfilling, or realizing A. This is the explanation for the frequent appearance of the word method in Heyting's explanations of the meanings of the logical constants. In connection with the word method, notice the tendency of our language towards hypostatization. I can do perfectly well without the concept of method in my semantical explanations: it is quite sufficient for me to have access to the expression know how, or knowledge how. But it is in the nature of our language that, when we know how to do something, we say that we possess a method of doing it. Summing up, I have now explained the two forms of categorical judgement, A is a proposition and A is true, respectively, and they are the only forms of categorical judgement that I shall have occasion to consider. Observe that knowledge of a judgement of the second form is knowledge how, more precisely, knowledge how to verify A, whereas knowledge of a judgement of the first form is knowledge of a problem, expectation, or intention, which is knowledge what to do, simply. Here I am introducing knowledge what as a counterpart of Ryle's knowledge how. So the difference between these two kinds of knowledge is the difference between knowledge what to do and knowledge how to do it. And, of course, there can be no question of knowing how to do something before you know what it is that is to be done. The difference between the two kinds of knowledge is a categorical one, and, as you see, what Ryle calls knowledge that, namely, knowledge that a proposition is true, is equated with knowledge how on this analysis. Thus the distinction between knowledge how and knowledge that evaporates on the intuitionistic analysis of the notion of truth. Third lecture The reason why I said that the word verification may be dangerous is that the principle of verification formulated by the logical positivists in the thirties said that a proposition is meaningful if and only if it is verifiable, or that the meaning of a proposition is its method of verification. Now that is to confuse meaningfulness and truth. I have indeed used the word verifiable and the expression method of verification. But what is equated with verifiability is not the meaningfulness on the meanings of the logical constants 37 but the truth of a proposition, and what qualifies as a method of verification is a proof that a proposition is true. Thus the meaning of a proposition is not its method of verification. Rather, the meaning of a proposition is determined by what it is to verify it, or what counts as a verification of it. The next point that I want to bring up is the question, Are there propositions which are true, but which cannot be proved to be true? And it suffices to think of mathematical propositions here, like the Goldbach conjecture, the Riemann hypothesis, or Fermat's last theorem. This fundamental question was once posed to me outright by a colleague of mine in the mathematics department, which shows that even working mathematicians may find themselves puzzled by deep philosophical questions. At first sight, at least, there seem to be two possible answers to this question. One is simply, No, and the other is, Perhaps, although it is of course impossible for anybody to exhibit an example of such a proposition, because, in order to do that, he would already have to know it to be true. If you are at all puzzled by this question, it is an excellent subject of meditation, because it touches the very conflict between idealism and realism in the theory of knowledge, the first answer, No, being indicative of idealism, and the second answer, Perhaps, of realism. It should be clear, from any point of view, that the answer depends on how you interpret the three notions in terms of which the question is formulated, that is, the notion of proposition, the notion of truth, and the notion of proof. And it should already be clear, I believe, from the way in which I have explained these notions, that the question simply ceases to be a problem, and that it is the first answer which is favoured. To see this, assume first of all that A is a proposition, or problem. Then A is true is a judgement which gives rise to a new problem, namely, the problem of proving that A is true. To say that that problem is solvable is precisely the same as saying that the judgement that A is true is provable. Now, the solvability of a problem is always expressed by a judgement. Hence 38 per martin-l"of (A is true) is provable is a new judgement. What I claim is that we have the right to make this latter judgement if and only if we have the right to make the former judgement, that is, that the proof rule A is true (A is true) is provable as well as its inverse (A is true) is provable A is true are both valid. This is the sense of saying that A is true if and only if A can be proved to be true. To justify the first rule, assume that you know its premise, that is, that you have proved that A is true. But, if you have proved that A is true, then you can, or know how to, prove that A is true, which is what you need to know in order to have the right to judge the conclusion. In this step, I have relied on the principle that, if something has been done, then it can be done. To justify the second rule, assume that you know its premise, that is, that you know how to prove the judgement A is true. On that assumption, I have to explain the conclusion to you, which is to say that I have to explain how to verify the proposition A. This is how you do it. First, put your knowledge of the premise into practice. That yields as result a proof that A is true. Now, such a proof is nothing but knowledge how to verify, or a method of verifying, the proposition A. Hence, putting it, in turn, into practice, you end up with a verification of the proposition A, as required. Observe that the inference in this direction is essentially a contraction of two possibilities into one: if you know how to know how to do something, then you know how to do it. All this is very easy to say, but, if one is at all puzzled by the question whether there are unprovable truths, then it is not an easy thing to make up one's mind about. For instance, it seems, from Heyting's writings on the semantics of intuitionistic logic in the early thirties, that he had not arrived at this position at that time. The most forceful and persistent criticism of the idea of a knowledge independent, or knowledge transcendent, notion of truth has been delivered by Dummett, although it seems difficult to find him ever explicitly committing himself in his writings to the view that, if a proposition is true, then it can also be proved to be true. Prawitz seems to be leaning towards this nonrealistic principle of truth, as he calls it, in his paper Intuitionistic on the meanings of the logical constants 39 Logic: A Philosophical Challenge. And, in his book Det Os"agbara, printed in the same year, Stenlund explicitly rejects the idea of true propositions that are in principle unknowable. The Swedish proof theorists seem to be arriving at a common philosophical position. Next I have to say something about hypothetical judgements, before I proceed to the final piece, which consists of the explanations of the meanings of the logical constants and the justifications of the logical laws. So far, I have only introduced the two forms of categorical judgement A is a proposition and A is true. The only forms of judgement that I need to introduce, besides these, are forms of hypothetical judgement. Hypothetical means of course the same as under assumptions. The Gr. I'pi`qesij, hypothesis, was translated into Lat. suppositio, supposition, and they both mean the same as assumption. Now, what is the rule for making assumptions, quite generally? It is simple. Whenever you have a judgement in the sense that I am using the word, that is, a judgement in the sense of an instance of a form of judgement, then it has been laid down what you must know in order to have the right to make it. And that means that it makes perfectly good sense to assume it, which is the same as to assume that you know it, which, in turn, is the same as to assume that you have proved it. Why is it the same to assume it as to assume that you know it? Because of the constant tacit convention that the epistemic force, I know . . . , is there, even if it is not made explicit. Thus, when you assume something, what you do is that you assume that you know it, that is, that you have proved it. And, to repeat, the rule for making assumptions is simply this: whenever you have a judgement, in the sense of an instance of a form of judgement, you may assume it. That gives rise to the notion of hypothetical judgement and the notion of hypothetical proof, or proof under hypotheses. The forms of hypothetical judgement that I shall need are not so many. Many more can be introduced, and they are needed for other purposes. But what is absolutely necessary for me is to have access to the form A1 true; : : : ; An true j A prop; which says that A is a proposition under the assumptions that A1; : : : ; An are all true, and, on the other hand, the form A1 true; : : : ; An true j A true; which says that the proposition A is true under the assumptions that A1; : : : ; An are all true. Here I am using the vertical bar for the relation of logical consequence, that is, for what Gentzen expressed by means of 40 per martin-l"of the arrow ! in his sequence calculus, and for which the double arrow ) is also a common notation. It is the relation of logical consequence, which must be carefully distinguished from implication. What stands to the left of the consequence sign, we call the hypotheses, in which case what follows the consequence sign is called the thesis, or we call the judgements that precede the consequence sign the antecedents and the judgement that follows after the consequence sign the consequent. This is the terminology which Gentzen took over from the scholastics, except that, for some reason, he changed consequent into succedent and consequence into sequence, Ger. Sequenz, usually improperly rendered by sequent in English. hypothetical judgement (logical) consequence z ""-- - A1 true; : : : ; An true j A prop A1 true; : : : ; An true j A true -- -z "" -- -z "" antecedents consequent hypotheses thesis Since I am making the assumptions A1 true; : : : ; An true, I must be presupposing something here, because, surely, I cannot make those assumptions unless they are judgements. Specifically, in order for A1 true to be a judgement, A1 must be a proposition, and, in order for A2 true to be a judgement, A2 must be a proposition, but now merely under the assumption that A1 is true, . . . , and, in order for An true to be a judgement, An must be a proposition under the assumptions that A1; : : : ; An\Gamma 1 are all true. Unlike in Gentzen's sequence calculus, the order of the assumptions is important here. This is because of the generalization that something being a proposition may depend on other things being true. Thus, for the assumptions to make sense, we must presuppose A1 prop; A1 true j A2 prop; ... A1 true; : : : ; An\Gamma 1 true j An prop. Supposing this, that is, supposing that we know this, it makes perfectly good sense to assume, first, that A1 is true, second, that A2 is true, . . . , finally, that An is true, and hence A1 true; : : : ; An true j A prop on the meanings of the logical constants 41 is a perfectly good judgement whatever expression A is, that is, whatever expression you insert into the place indicated by the variable A. And why is it a good judgement? To answer that question, I must explain to you what it is to know such a judgement, that is, what constitutes knowledge, or proof, of such a judgement. Now, quite generally, a proof of a hypothetical judgement, or logical consequence, is nothing but a hypothetical proof of the thesis, or consequent, from the hypotheses, or antecedents. The notion of hypothetical proof, in turn, which is a primitive notion, is explained by saying that it is a proof which, when supplemented by proofs of the hypotheses, or antecedents, becomes a proof of the thesis, or consequent. Thus the notion of categorical proof precedes the notion of hypothetical proof, or inference, in the order of conceptual priority. Specializing this general explanation of what a proof of a hypothetical judgement is to the particular form of hypothetical judgement A1 true; : : : ; An true j A prop that we are in the process of considering, we see that the defining property of a proof A1 true \Delta \Delta \Delta An true \Delta \Delta \Delta \Delta \Delta \Delta A prop of such a judgement is that, when it is supplemented by proofs ... A1 true \Delta \Delta \Delta ... An true of the hypotheses, or antecedents, it becomes a proof ... A1 true \Delta \Delta \Delta ... An true \Delta \Delta \Delta \Delta \Delta \Delta A prop of the thesis, or consequent. Consider now a judgement of the second form A1 true; : : : ; An true j A true: For it to make good sense, that is, to be a judgement, we must know, not only 42 per martin-l"of A1 prop; A1 true j A2 prop; ... A1 true; : : : ; An\Gamma 1 true j An prop; as in the case of the previous form of judgement, but also A1 true; : : : ; An true j A prop: Otherwise, it does not make sense to ask oneself whether A is true under the assumptions A1 true, . . . , An true. As with any proof of a hypothetical judgement, the defining characteristic of a proof A1 true \Delta \Delta \Delta An true \Delta \Delta \Delta \Delta \Delta \Delta A true of a hypothetical judgement of the second form is that, when supplemented by proofs ... A1 true \Delta \Delta \Delta ... An true of the antecedents, it becomes a categorical proof ... A1 true \Delta \Delta \Delta ... An true \Delta \Delta \Delta \Delta \Delta \Delta A true of the consequent. I am sorry that I have had to be so brief in my treatment of hypothetical judgements, but what I have said is sufficient for the following, except that I need to generalize the two forms of hypothetical judgement so as to allow generality in them. Thus I need judgements which are, not only hypothetical, but also general, which means that the first form is turned into A1(x1; : : : ; xm) true; : : : ; An(x1; : : : ; xm) true jx1;:::;x m A(x1; : : : ; xm) prop and the second form into A1(x1; : : : ; xm) true; : : : ; An(x1; : : : ; xm) true jx1;:::;x m A(x1; : : : ; xm) true: Both of these forms involve a generality, indicated by subscribing the variables that are being generalized to the consequence sign, which must be carefully distinguished from, and which must be explained on the meanings of the logical constants 43 prior to, the generality which is expressed by means of the universal quantifier. It was only to avoid introducing all complications at once that I treated the case without generality first. Now, the meaning of a hypothetico-general judgement is explained by saying that, to have the right to make such a judgement, you must possess a free variable proof of the thesis, or consequent, from the hypotheses, or antecedents. And what is a free variable proof? It is a proof which remains a proof when you substitute anything you want for its free variables, that is, any expressions you want, of the same arities as those variables. Thus A1(x1; : : : ; xm) true \Delta \Delta \Delta An(x1; : : : ; xm) true \Delta \Delta \Delta \Delta \Delta \Delta A(x1; : : : ; xm) prop is a proof of a hypothetico-general judgement of the first form provided it becomes a categorical proof ... A1(a1; : : : ; am) true \Delta \Delta \Delta ... An(a1; : : : ; am) true \Delta \Delta \Delta \Delta \Delta \Delta A(a1; : : : ; am) prop when you first substitute arbitrary expressions a1; : : : ; am, of the same respective arities as the variables x1; : : : ; xm, for those variables, and then supplement it with proofs ... A1(a1; : : : ; am) true \Delta \Delta \Delta ... An(a1; : : : ; am) true of the resulting substitution instances of the antecedents. The explanation of what constitutes a proof of a hypothetico-general judgement of the second form is entirely similar. The difference between an inference and a logical consequence, or hypothetical judgement, is that an inference is a proof of a logical consequence. Thus an inference is the same as a hypothetical proof. Now, when we infer, or prove, we infer the conclusion from the premises. Thus, just as a categorical proof is said to be a proof of its conclusion, a hypothetical proof is said to be a proof, or an inference, of its conclusion from its premises. This makes it clear what is the connection as well as what is the difference between an inference with its premises and conclusion on the one hand, and a logical consequence with its antecedents and consequent on the other hand. And the difference is precisely that it is the presence of a proof of a logical consequence that 44 per martin-l"of turns its antecedents into premises and the consequent into conclusion of the proof in question. For example, if A is a proposition, then A true j ? true is a perfectly good logical consequence with A true as antecedent and ? true as consequent, but A true ? true is not an inference, not a valid inference, that is, unless A is false. In that case, only, may the conclusion ? true be inferred from the premise A true. Let us now pass on to the rules of inference, or proof rules, and their semantical explanations. I shall begin with the rules of implication. Now, since I am treating A is a proposition as a form of judgement, which is on a par with the form of judgement A is true, what we ordinarily call formation rules will count as rules of inference, but that is merely a terminological matter. So let us look at the formation rule for implication. oe-formation. A prop (A true) B prop A oe B prop This rule says, in words, that, if A is a proposition and B is a proposition provided that A is true, then A oe B is a proposition. In the second premise, I might just as well have used the notation for logical consequence A true j B prop that I introduced earlier in this lecture, because to have a proof of this logical consequence is precisely the same as to have a hypothetical proof of B prop from the assumption A true. But, for the moment, I shall use the more suggestive notation (A true) B prop in imitation of Gentzen. It does not matter, of course, which notation of the two that I employ. The meaning is in any case the same. Explanation. The rule of implication formation is a rule of immediate inference, which means that you must make the conclusion evident on the meanings of the logical constants 45 to yourself immediately, without any intervening steps, on the assumption that you know the premises. So assume that you do know the premises, that is, that you know the proposition A, which is to say that you know what counts as a verification of it, and that you know that B is a proposition under the assumption that A is true. My obligation is to explain to you what proposition A oe B is. Thus I have to explain to you what counts as a verification, or solution, of this proposition, or problem. And the explanation is that what counts as a verification of A oe B is a hypothetical proof A true. .. B true that B is true under the assumption that A is true. In the Kolmogorov interpretation, such a hypothetical proof appears as a method of solving the problem B provided that the problem A can be solved, that is, a method which together with a method of solving the problem A becomes a method of solving the problem B. The explanation of the meaning of implication, which has just been given, illustrates again the rigidity of the order of conceptual priority: the notions of hypothetical judgement, or logical consequence, and hypothetical proof have to be explained before the notion of implication, because, when you explain implication, they are already presupposed. Given the preceding explanation of the meaning of implication, it is not difficult to justify the rule of implication introduction. oe-introduction. (A true) B true A oe B true As you see, I am writing it in the standard way, although, of course, it is still presupposed that A is a proposition and that B is a proposition under the assumption that A is true. Thus you must know the premises of the formation rule and the premise of the introduction rule in order to be able to grasp its conclusion. Explanation. Again, the rule of implication introduction is a rule of immediate inference, which means that you must make the conclusion immediately evident to yourself granted that you know the premises, that is, granted that you possess a hypothetical proof that B is true from the hypothesis that A is true. By the definition of implication, such a proof is nothing but a verification of the proposition A oe B. And what is it that you must know in order to have the right to judge 46 per martin-l"of A oe B to be true? You must know how to get yourself a verification of A oe B. But, since you already possess it, you certainly know how to acquire it: just take what you already have. This is all that there is to be seen in this particular rule. Observe that its justification rests again on the principle that, if something has been done, then it can be done. Next we come to the elimination rule for implication, which I shall formulate in the standard way, as modus ponens, although, if you want all elimination rules to follow the same pattern, that is, the pattern exhibited by the rules of falsehood, disjunction, and existence elimination, there is another formulation that you should consider, and which has been considered by Schroeder-Heister. But I shall have to content myself with the standard formulation in these lectures. oe-elimination. A oe B true A true B true Here it is still assumed, of course, that A is a proposition and that B is a proposition provided that A is true. Explanation. This is a rule of immediate inference, so assume that you know the premises, that is, that you possess proofs ... A oe B true and ... A true of them, and I shall try to make the conclusion evident to you. Now, by the definitions of the notion of proof and the notion of truth, the proof of the first premise is knowledge how to verify the proposition A oe B. So put that knowledge of yours into practice. What you then end up with is a verification of A oe B, and, because of the way implication was defined, that verification is nothing but a hypothetical proof A true. .. B true that B is true from the assumption that A is true. Now take your proof of the right premise and adjoin it to the verification of A oe B. Then you get a categorical proof .. . A true. .. B true on the meanings of the logical constants 47 of the conclusion that B is true. Here, of course, I am implicitly using the principle that, if you supplement a hypothetical proof with proofs of its hypotheses, then you get a proof of its conclusion. But this is in the nature of a hypothetical proof: it is that property which makes a hypothetical proof into what it is. So now you have a proof that B is true, a proof which is knowledge how to verify B. Putting it, in turn, into practice, you end up with a verification of B. This finishes my explanation of how the proposition B is verified. In the course of my semantical explanation of the elimination rule for implication, I have performed certain transformations which are very much like an implication reduction in the sense of Prawitz. Indeed, I have explained the semantical role of this syntactical transformation. The place where it belongs in the meaning theory is precisely in the semantical explanation, or justification, of the elimination rule for implication. Similarly, the reduction rules for the other logical constants serve to explain the elimination rules associated with those constants. The key to seeing the relationship between the reduction rules and the semantical explanations of the elimination rules is this: to verify a proposition by putting a proof of yours that it is true into practice corresponds to reducing a natural deduction to introductory form and deleting the last inference. This takes for granted, as is in fact the case, that an introduction is an inference in which you conclude, from the possession of a verification of a proposition, that you know how to verify it. In particular, verifying a proposition B by means of a proof that B is true ... A oe B true ... A true B true which ends with an application of modus ponens, corresponds to reducing the proof of the left premise to introductory form (A true). .. B true A oe B true ... A true B true then performing an implication reduction in the sense of Prawitz, which yields the proof 48 per martin-l"of ... A true. .. B true as result, and finally reducing the latter proof to introductory form and deleting its last, introductory inference. This is the syntactical counterpart of the semantical explanation of the elimination rule for implication. The justifications of the remaining logical laws follow the same pattern. Let me take the rules of conjunction next. & -formation. A prop B prop A & B prop Explanation. Again, assume that you know the premises, and I shall explain the conclusion to you, that is, I shall tell you what counts as a verification of A & B. The explanation is that a verification of A & B consists of a proof that A is true and a proof that B is true, ... A true and ... B true that is, of a method of verifying A and a method of verifying B. In the Kolmogorov interpretation, A & B appears as the problem which you solve by constructing both a method of solving A and a method of solving B. & -introduction. A true B true A & B true Here the premises of the formation rule are still in force, although not made explicit, which is to say that A and B are still assumed to be propositions. Explanation. Assume that you know the premises, that is, that you possess proofs .. . A true and ... B true of them. Because of the meaning of conjunction, just explained, this means that you have verified A & B. Then you certainly can, or know how to, verify the proposition A & B, by the principle that, if something has been done, then it can be done. And this is precisely what you need to know in order to have the right to judge A & B to be true. on the meanings of the logical constants 49 If you want the elimination rule for conjunction to exhibit the same pattern as the elimination rules for falsehood, disjunction, and existence, it should be formulated differently, but, in its standard formulation, it reads as follows. & -elimination. A & B true A true A & B true B true Thus, in this formulation, there are two rules and not only one. Also, it is still presupposed, of course, that A and B are propositions. Explanation. It suffices for me to explain one of the rules, say the first, because the explanation of the other is completely analogous. To this end, assume that you know the premise, and I shall explain to you the conclusion, which is to say that I shall explain how to verify A. This is how you do it. First use your knowledge of the premise to get a verification of A & B. By the meaning of conjunction, just explained, that verification consists of a proof that A is true as well as a proof that B is true, .. . A true and ... B true Now select the first of these two proofs. By the definitions of the notions of proof and truth, that proof is knowledge how to verify A. So, putting it into practice, you end up with a verification of A. This finishes the explanations of the rules of conjunction. The next logical operation to be treated is disjunction. And, as always, the formation rule must be explained first. .-formation. A prop B prop A . B prop Explanation. To justify it, assume that you know the premises, that is, that you know what it is to verify A as well as what it is to verify B. On that assumption, I explain to you what proposition A . B is by saying that a verification of A . B is either a proof that A is true or a proof that B is true, .. . A true or ... B true Thus, in the wording of the Kolmogorov interpretation, a solution to the problem A . B is either a method of solving the problem A or a method of solving the problem B. 50 per martin-l"of .-introduction. A true A . B true B true A . B true In both of these rules, the premises of the formation rule, which say that A and B are propositions, are still in force. Explanation. Assume that you know the premise of the first rule of disjunction introduction, that is, that you have proved, or possess a proof of, the judgement that A is true. By the definition of disjunction, this proof is a verification of the proposition A . B. Hence, by the principle that, if something has been done, then it can be done, you certainly can, or know how to, verify the proposition A . B. And it is this knowledge which you express by judging the conclusion of the rule, that is, by judging the proposition A . B to be true. The explanation of the second rule of disjunction introduction is entirely similar. .-elimination. A . B true (A true) C true (B true) C true C true Here it is presupposed, not only that A and B are propositions, but also that C is a proposition provided that A . B is true. Observe that, in this formulation of the rule of disjunction elimination, C is presupposed to be a proposition, not outright, but merely on the hypothesis that A . B is true. Otherwise, it is just like the Gentzen rule. Explanation. Assume that you know, or have proved, the premises. By the definition of truth, your knowledge of the first premise is knowledge how to verify the proposition A . B. Put that knowledge of yours into practice. By the definition of disjunction, you then end up either with a proof that A is true or with a proof that B is true, ... A true or ... B true In the first case, join the proof that A is true to the proof that you already possess of the second premise, which is a hypothetical proof that C is true under the hypothesis that A is true, A true. .. C true You then get a categorical, or nonhypothetical, proof that C is true, on the meanings of the logical constants 51 ... A true. .. C true Again, by the definition of truth, this proof is knowledge how to verify the proposition C. So, putting this knowledge of yours into practice, you verify C. In the second case, join the proof that B is true, which you ended up with as a result of putting your knowledge of the first premise into practice, to the proof that you already possess of the third premise, which is a hypothetical proof that C is true under the hypothesis that B is true, B true. .. C true You then get a categorical proof that C is true, ... B true. .. C true As in the first case, by the definition of truth, this proof is knowledge how to verify the proposition C. So, putting this knowledge into practice, you verify C. This finishes my explanation how to verify the proposition C, which is precisely what you need to know in order to have the right to infer the conclusion that C is true. ?-formation. ? prop Explanation. This is an axiom, but not in its capacity of mere figure: to become an axiom, it has to be made evident. And, to make it evident, I have to explain what counts as a verification of ?. The explanation is that there is nothing that counts as a verification of the proposition ?. Under no condition is it true. Thinking of ? as a problem, as in the Kolmogorov interpretation, it is the problem which is defined to have no solution. An introduction is an inference in which you conclude that a proposition is true, or can be verified, on the ground that you have verified it, that is, that you possess a verification of it. Therefore, ? being defined by the stipulation that there is nothing that counts as a verification of it, there is no introduction rule for falsehood. 52 per martin-l"of ?-elimination. ? true C true Here, in analogy with the rule of disjunction elimination, C is presupposed to be a proposition, not outright, but merely under the assumption that ? is true. This is the only divergence from Gentzen's formulation of ex falso quodlibet. Explanation. When you infer by this rule, you undertake to verify the proposition C when you are provided with a proof that ? is true, that is, by the definition of truth, with a method of verifying ?. But this is something that you can safely undertake, because, by the definition of falsehood, there is nothing that counts as a verification of ?. Hence ? is false, that is, cannot be verified, and hence it is impossible that you ever be provided with a proof that ? is true. Observe the step here from the falsity of the proposition ? to the unprovability of the judgement that ? is true. The undertaking that you make when you infer by the rule of falsehood elimination is therefore like saying, I shall eat up my hat if you do such and such, where such and such is something of which you know, that is, are certain, that it cannot be done. Observe that the justification of the elimination rule for falsehood only rests on the knowledge that ? is false. Thus, if A is a proposition, not necessarily ?, and C is a proposition provided that A is true, then the inference A true C true is valid as soon as A is false. Choosing C to be ?, we can conclude, by implication introduction, that A oe ? is true provided that A is false. Conversely, if A oe ? is true and A is true, then, by modus ponens, ? would be true, which it is not. Hence A is false if A oe ? is true. These two facts together justify the nominal definition of ,A, the negation of A, as A oe ?, which is commonly made in intuitionistic logic. However, the fact that A is false if and only if ,A is true should not tempt one to define the notion of denial by saying that A is false means that ,A is true. on the meanings of the logical constants 53 That the proposition A is false still means that it is impossible to verify A, and this is a notion which cannot be reduced to the notions of negation, negation of propositions, that is, and truth. Denial comes before negation in the order of conceptual priority, just as logical consequence comes before implication, and the kind of generality which a judgement may have comes before universal quantification. As has been implicit in what I have just said, A is false = A is not true = A is not verifiable = A cannot be verified. Moreover, in the course of justifying the rule of falsehood elimination, I proved that ? is false, that is, that ? is not true. Now, remember that, in the very beginning of this lecture, we convinced ourselves that a proposition is true if and only if the judgement that it is true is provable. Hence, negating both members, a proposition is false if and only if the judgement that it is true cannot be proved, that is, is unprovable. Using this in one direction, we can conclude, from the already established falsity of ?, that the judgement that ? is true is unprovable. This is, if you want, an absolute consistency proof: it is a proof of consistency with respect to the unlimited notion of provability, or knowability, that pervades these lectures. And (? is true) is unprovable is the judgement which expresses the absolute consistency, if I may call it so. By my chain of explanations, I hope that I have succeeded in making it evident. The absolute consistency brings with it as a consequence the relative consistency of any system of correct, or valid, inference rules. Suppose namely that you have a certain formal system, a system of inference rules, and that you have a formal proof in that system of the judgement that ? is true. Because of the absolute consistency, that is, the unprovability of the judgement that ? is true, that formal proof, although formally correct, is no proof, not a real proof, that is. How can that come about? Since a formal proof is a chain of formally immediate inferences, that is, instances of the inference rules of the system, that can only come about as a result of there being some rule of inference which is incorrect. Thus, if you have a formal system, and you have convinced yourself of the correctness of the inference rules that belong to it, then you are sure that the judgement that ? is true cannot be proved in the system. This means that the consistency problem is really the problem of the correctness of the rules of inference, and that, at some stage or another, you cannot avoid having to convince yourself 54 per martin-l"of of their correctness. Of course if you take any old formal system, it may be that you can carry out a metamathematical consistency proof for it, but that consistency proof will rely on the intuitive correctness of the principles of reasoning that you use in that proof, which means that you are nevertheless relying on the correctness of certain forms of inference. Thus the consistency problem is really the problem of the correctness of the rules of inference that you follow, consciously or unconsciously, in your reasoning. After this digression on consistency, we must return to the semantical explanations of the rules of inference. The ones that remain are the quantifier rules. 8-formation. A(x) prop (8x)A(x) prop Explanation. The premise of this rule is a judgement which has generality in it. If I were to make it explicit, I would have to write it jx A(x) prop: It is a judgement which has generality in it, although it is free from hypotheses. And remember what it is to know such a judgement: it is to possess a free variable proof of it. Now, assume that you do know the premise of this rule, that is, that you possess a free variable proof of the judgement that A(x) is a proposition. On that assumption, I explain the conclusion to you by stipulating that a verification of the proposition (8x)A(x) consists of a free variable proof that A(x) is true, graphically, .. . A(x) true By definition, that is a proof in which the variable x may be replaced by anything you want, that is, any expression you want of the same arity as the variable x. Thus, if x is a variable ranging over complete expressions, then you must substitute a complete expression for it, and, similarly, if it ranges over incomplete expressions of some arity. In the Kolmogorov interpretation, the explanation of the meaning of the universal quantifier would be phrased by saying that (8x)A(x) expresses the problem of constructing a general method of solving the problem A(x) for arbitrary x. 8-introduction. A(x) true (8x)A(x) true on the meanings of the logical constants 55 Here the premise of the formation rule, to the effect that A(x) is a proposition for arbitrary x, is still in force. Explanation. Again, the premise of this rule is a general judgement, which would read jx A(x) true if I were to employ the systematic notation that I introduced earlier in this lecture. Now, assume that you know this, that is, assume that you possess a free variable proof of the judgement that A(x) is true. Then, by the principle that, if something has been done, then it can be done, you certainly can give such a proof, and this is precisely what you must be able, or know how, to do in order to have the right to infer the conclusion of the rule. 8-elimination. (8x)A(x) true A(a) true Here it is presupposed, of course, that A(x) is a proposition for arbitrary x. And, as you see, I have again chosen the usual formulation of the elimination rule for the universal quantifier rather than the one which is patterned upon the elimination rules for falsehood, disjunction, and existence. Explanation. First of all, observe that, because of the tacit assumption that A(x) is a proposition for arbitrary x, both (8x)A(x) and A(a) are propositions, where a is an expression of the same arity as the variable x. Now, assume that you know the premise, that is, that you know how to verify the proposition (8x)A(x), and I shall explain to you how to verify the proposition A(a). To begin with, put your knowledge of the premise into practice. That will give you a verification of (8x)A(x), which, by the definition of the universal quantifier, is a free variable proof that A(x) is true, .. . A(x) true Now, this being a free variable proof means precisely that it remains a proof whatever you substitute for x. In particular, it remains a proof when you substitute a for x so as to get ... A(a) true So now you have acquired a proof that A(a) is true. By the definitions of the notions of proof and truth, this proof is knowledge how to verify 56 per martin-l"of the proposition A(a). Thus, putting it into practice, you end up with a verification of A(a), as required. 9-formation. A(x) prop (9x)A(x) prop Explanation. Just as in the formation rule associated with the universal quantifier, the premise of this rule is really the general judgement jx A(x) prop; although I have not made the generality explicit in the formulation of the rule. Assume that you know the premise, that is, assume that you possess a free variable proof ... A(x) prop guaranteeing that A(x) is a proposition, and I shall explain to you what proposition (9x)A(x) is, that is, what counts as a verification of it. The explanation is that a verification of (9x)A(x) consists of an expression a of the same arity as the variable x and a proof ... A(a) true showing that the proposition A(a) is true. Observe that the knowledge of the premise is needed in order to guarantee that A(a) is a proposition, so that it makes sense to talk about a proof that A(a) is true. In the Kolmogorov interpretation, (9x)A(x) would be explained as the problem of finding an expression a, of the same arity as the variable x, and a method of solving the problem A(a). 9-introduction. A(a) true (9x)A(x) true Here, as usual, the premise of the formation rule is still in force, which is to say that A(x) is assumed to be a proposition for arbitrary x. Explanation. Assume that you know the premise, that is, assume that you possess a proof that A(a) is true, ... A(a) true on the meanings of the logical constants 57 By the preceding explanation of the meaning of the existential quantifier, the expression a together with this proof make up a verification of the proposition (9x)A(x). And, possessing a verification of the proposition (9x)A(x), you certainly know how to verify it, which is what you must know in order to have the right to conclude that (9x)A(x) is true. Like in my explanations of all the other introduction rules, I have here taken for granted the principle that, if something has been done, then it can be done. 9-elimination. (9x)A(x) true (A(x) true) C true C true Here it is presupposed, not only that A(x) is a proposition for arbitrary x, like in the introduction rule, but also that C is a proposition provided that the proposition (9x)A(x) is true. Explanation. First of all, in order to make it look familiar, I have written the second premise in Gentzen's notation (A(x) true) C true rather than in the notation A(x) true jx C true; but there is no difference whatever in sense. Thus the second premise is really a hypothetico-general judgement. Now, assume that you know the premises. By the definition of the notion of truth, your knowledge of the first premise is knowledge how to verify the proposition (9x)A(x). Put that knowledge of yours into practice. You then end up with a verification of the proposition (9x)A(x). By the definition of the existential quantifier, this verification consists of an expression a of the same arity as the variable x and a proof that the proposition A(a) is true, .. . A(a) true Now use your knowledge, or proof, of the second premise. Because of the meaning of a hypothetico-general judgement, this proof A(x) true. .. C true 58 per martin-l"of is a free variable proof that C is true from the hypothesis that A(x) is true. Being a free variable proof means that you may substitute anything you want, in particular, the expression a, for the variable x. You then get a hypothetical proof A(a) true. .. C true that C is true from the hypothesis that A(a) is true. Supplementing this hypothetical proof with the proof that A(a) is true that you obtained as a result of putting your knowledge of the first premise into practice, you get a proof .. . A(a) true. .. C true that C is true, and this proof is nothing but knowledge how to verify the proposition C. Thus, putting it into practice, you end up having verified the proposition C, as required. The promise of the title of these lectures, On the Meanings of the Logical Constants and the Justifications of the Logical Laws, has now been fulfilled. As you have seen, the explanations of the meanings of the logical constants are precisely the explanations belonging to the formation rules. And the justifications of the logical laws are the explanations belonging to the introduction and elimination rules, which are the rules that we normally call rules of inference. For lack of time, I have only been able to deal with the pure logic in my semantical explanations. To develop some interesting parts of mathematics, you also need axioms for ordinary inductive definitions, in particular, axioms of computation and axioms for the natural numbers. And, if you need predicates defined by transfinite, or generalized, induction, then you will have to add the appropriate formation, introduction, and elimination rules for them. I have already explained how you see the consistency of a formal system of correct inference rules, that is, the impossibility of constructing a proof .. . ? true that falsehood is true which proceeds according to those rules, not by studying metamathematically the proof figures divested of all sense, as on the meanings of the logical constants 59 was Hilbert's program, but by doing just the opposite: not divesting them of sense, but endowing them with sense. Similarly, suppose that you have a proof .. . A true that a proposition A is true which depends, neither on any assumptions, nor on any free variables. By the definition of truth and the identification of proof and knowledge, such a proof is nothing but knowledge how to verify the proposition A. And, as I remarked earlier in this lecture, verifying the proposition A by putting that knowledge into practice is the same as reducing the proof to introductory form and deleting the last, introductory inference. Moreover, the way of reducing the proof which corresponds to the semantical explanations, notably of the elimination rules, is precisely the way that I utilized for the first time in my paper on iterated inductive definitions in the Proceedings of the Second Scandinavian Logic Symposium, although merely because of its naturalness, not for any genuine semantical reasons, at that time. But no longer do we need to prove anything, that is, no longer do we need to prove metamathematically that the proof figures, divested of sense, reduce to introductory form. Instead of proving it, we endow the proof figures with sense, and then we see it! Thus the definition of convertibility, or computability, and the proof of normalization have been transposed into genuine semantical explanations which allow you to see this, just as you can see consistency semantically. And this is the point that I had intended to reach in these lectures. 60 per martin-l"of Postscript, Feb. 1996 The preceding three lectures were originally published in the Atti degli Incontri di Logica Matematica, Vol. 2, Scuola di Specializzazione in Logica Matematica, Dipartimento di Matematica, Universit`a di Siena, 1985, pp. 203-281. Since they have been difficult to obtain, and are now even out of print, they are reprinted here by kind permission of the Dipartimento di Matematica, Universit`a di Siena. Only typing errors have been corrected. The reader who wishes to follow the further development of the ideas that were brought up for the first time in these lectures is referred to the papers listed below. Per Martin-L"of (1987) Truth of a proposition, evidence of a judgement, validity of a proof. Synthese, 73, pp. 407-420. ---- (1991) A path from logic to metaphysics. In Atti del Congresso Nuovi Problemi della Logica e della Filosofia della Scienza, Viareggio, 8-13 gennaio 1990, Vol. II, pp. 141-149. CLUEB, Bologna. ---- (1994) Analytic and synthetic judgements in type theory. In Paolo Parrini (ed.), Kant and Contemporary Epistemology, pp. 87- 99. Kluwer Academic Publishers, Dordrecht/Boston/London. ---- (1995) Verificationism then and now. In W. DePauli-Schimanovich, E. K"ohler, and F. Stadler (eds.), The Foundational Debate: Complexity and Constructivity in Mathematics and Physics, pp. 187- 196. Kluwer Academic Publishers, Dordrecht/Boston/London. ---- (1996) Truth and knowability: on the principles C and K of Michael Dummett. In H. G. Dales and G. Oliveri (eds.), Truth in Mathematics. Clarendon Press, Oxford. Forthcoming. Department of Mathematics University of Stockholm Sweden -} -- record -- WORKS with this additional token
{ "alphanum_fraction": 0.782856269, "avg_line_length": 47.0444350402, "ext": "agda", "hexsha": "494b4200898f1c53c980274f781f98df2b148d7a", "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/Issue3480.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/Issue3480.agda", "max_line_length": 212, "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/Issue3480.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": 26062, "size": 111166 }
{-# OPTIONS --cubical #-} --open import Data.Nat using (ℕ; zero; suc; _+_) open import Cubical.Data.Nat using (ℕ; zero; suc; _+_) open import Cubical.Foundations.Prelude using (refl; _≡_; subst; cong; transport; transp; ℓ-zero; ℓ-suc) -- hiding (_≡⟨_⟩_) open import Cubical.Foundations.Function using (_∘_) data Captured {a} (A : Set a) : Set a where cap : A → Captured A Id : ∀ {a} {A} → Captured A → Set a Id {_} {A} (cap _) = A id : ∀ {a} {A} → (n : Captured A) → Id {a} n id (cap n) = n data ⟨Set⟩ {a} (A : Set a) : Set a where empty : ⟨Set⟩ A insert : A → ⟨Set⟩ A → ⟨Set⟩ A dup : ∀ a sa → insert a (insert a sa) ≡ insert a sa com : ∀ a b sa → insert a (insert b sa) ≡ insert b (insert a sa) rem-dup () --_in_ : A → ⟨Set⟩ A → --insert 3 (insert 3 empty) --transport (dup 3 empty)) --transport (dup {ℓ-zero} 3 empty) --insert 3 (insert 3 empty) --subst {A = insert 3 (insert 3 empty)} (dup 3 empty) --transport {ℓ-zero} {ℕ} refl --cong cap (dup 3 empty) --transport (cong (Id ∘ cap) (dup 3 empty)) (id (cap (insert 3 (insert 3 empty)))) --id (cap (insert 3 (insert 3 empty)))
{ "alphanum_fraction": 0.601455869, "avg_line_length": 29.7027027027, "ext": "agda", "hexsha": "5e950782b61c16c9e808e83f1c6e1a51f321c63a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "helq/old_code", "max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "helq/old_code", "max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "helq/old_code", "max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 422, "size": 1099 }
-- Terms using Agdas Sized Types -- module TermsSized where open import Data.Vec hiding (_++_) open import Relation.Binary.PropositionalEquality open import Data.Nat open import Data.List open import Data.List.Relation.Unary.All open import Data.Fin.Base open import Size -- Ranked alphabet: Vector of natural numbers, where vec[i] denotes the arity of symbol i RankedAlphabet : ℕ → Set RankedAlphabet n = Vec ℕ n -- Types data Type : Set where TTerm : ∀ {n} → RankedAlphabet n → Type TFun : Type → Type → Type -- Type environment Env : Set Env = List Type -- Environment lookup data _∈`_ : Type → Env → Set where here : ∀ {φ A} → A ∈` (A ∷ φ) there : ∀ {φ A A'} → A ∈` φ → A ∈` (A' ∷ φ) -- Bind a type n times on top of an environment bind : Env → (A : Type) → ℕ → Env bind φ A zero = φ bind φ A (suc n) = A ∷ (bind φ A n) -- Zero & Successor, Variables, prim. recursion, Abstraction, Application data Expr : {j : Size} → Env → Type → Set where ETerm : ∀ {j : Size} {φ n} {vec : RankedAlphabet n} {sym : Fin n} → Vec (Expr {j} φ (TTerm vec)) (Data.Vec.lookup vec sym) → Expr {↑ j} φ (TTerm vec) ETerm-Rec : ∀ {j : Size} {φ n} {vec : RankedAlphabet n} {A} → (∀ {sym : Fin n} → Expr {j} (bind φ A (Data.Vec.lookup vec sym)) A) → Expr {j} φ (TTerm vec) → Expr {↑ j} φ A Var : ∀ {φ A} → A ∈` φ → Expr {∞} φ A Abs : ∀ {φ A B} → Expr (A ∷ φ) B → Expr φ (TFun A B) App : ∀ {φ A B} → Expr φ (TFun A B) → Expr φ A → Expr φ B -- Terms data Term {n} (ra : RankedAlphabet n) : {i : Size} → Set where mk : ∀ {i} → (sym : Fin n) → Vec (Term ra {i}) (Data.Vec.lookup ra sym) → Term ra {↑ i} -- Values Value : Type → Set Value (TTerm ra) = Term ra Value (TFun A B) = Value A → Value B -- Lookup in environment of all Values access : ∀ {A φ} → A ∈` φ → All Value φ → Value A access here (px ∷ p) = px access (there x) (px ∷ p) = access x p extend : ∀ {ϕ A} → (m : ℕ) → (ϱ₁ : Vec (Value A) m) → (ϱ : All Value ϕ) → All Value (bind ϕ A m) extend 0F [] ϱ = ϱ extend (suc m) (x ∷ ϱ₁) ϱ = x ∷ extend m ϱ₁ ϱ trec : ∀ {j : Size} {a} {n} {VA : Set a} (ra : RankedAlphabet n) → ((sym : Fin n) → Vec VA (Data.Vec.lookup ra sym) → VA) → Term ra {j} → VA trec ra g (mk sym₁ subterms) = g sym₁ (Data.Vec.map (trec ra g) subterms) -- Evaluation eval : ∀ {j : Size} {ϕ A} → Expr{j} ϕ A → All Value ϕ → Value A eval (ETerm{sym = sym} x) ϱ = mk sym (Data.Vec.map (λ exp → eval exp ϱ) x) eval {j} {ϕ} {A} (ETerm-Rec{n = n}{vec = ra} exprs body) ϱ with eval body ϱ ... | term = trec {VA = Value A} ra (λ sym₁ ϱ₁ → eval {A = A} (exprs {sym₁}) (extend (Data.Vec.lookup ra sym₁) ϱ₁ ϱ)) term eval (Var x) ϱ = access x ϱ eval (Abs expr) ϱ = λ x → eval expr (x ∷ ϱ) eval (App expr expr₁) ϱ = (eval expr ϱ) (eval expr₁ ϱ) -- Example: Very tiny subset of propositional logic -- Σ = {¬, ⊤, ⊥}, α(¬) = 1, α(⊤) = 0, α(⊥) = 0 Σ : Vec ℕ 3 Σ = (1 ∷ 0 ∷ 0 ∷ []) PropLog : Type PropLog = TTerm Σ 1≤3 : 1 Data.Nat.< 3 1≤3 = s≤s (s≤s z≤n) 2≤3 : 2 Data.Nat.< 3 2≤3 = s≤s (s≤s (s≤s z≤n)) ⊤ : Expr [] PropLog ⊤ = ETerm{n = 3} {sym = fromℕ< {1} {3} 1≤3} [] ⊥ : Expr [] PropLog ⊥ = ETerm{n = 3} {sym = fromℕ< {2} {3} 2≤3} [] NegFunc : ∀ {sym : Fin 3} → Expr (bind [] PropLog (Data.Vec.lookup Σ sym)) PropLog NegFunc {zero} = Var here NegFunc {suc zero} = ⊥ NegFunc {suc (suc zero)} = ⊤ ¬⊥ : Expr [] PropLog ¬⊥ = ETerm-Rec{vec = Σ} (λ {sym} → NegFunc {sym}) (ETerm{n = 3} {sym = fromℕ< {0} {3} (s≤s z≤n)} (⊥ ∷ []) ) _ : (eval ¬⊥ []) ≡ (eval ⊤ []) _ = refl
{ "alphanum_fraction": 0.5580936266, "avg_line_length": 31.3805309735, "ext": "agda", "hexsha": "0b4e0a2244dc461a7ac8bb897f291eb3692f845a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_path": "src/sigmatypes/TermsSized.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "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": "kcaliban/ldlc", "max_issues_repo_path": "src/sigmatypes/TermsSized.agda", "max_line_length": 174, "max_stars_count": null, "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_path": "src/sigmatypes/TermsSized.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1467, "size": 3546 }
{-# OPTIONS --no-coverage-check #-} module FlexibleFunArity where data Bool : Set where true false : Bool g : Bool -> Bool -> Bool g true = \ x -> true g false true = false g false false = true T : Bool -> Set T true = Bool T false = Bool -> Bool f : (b : Bool) -> T b f true = true f false true = false f false false = true {- checking clause f false true starts with f (b : Bool) : T b splits on b f true -- no match, discard f false -- matches instantiate type f false : T false = Bool -> Bool extend clause f false (y : Bool) : Bool split on y f false true -- matches f false false -- no match, discard done -} {- coverage check starts with f (x : Bool) splits on x f true -- finds clause 1 f false NEW: remaing clauses have bigger arity, so expands to f false (y : Bool) splits on y f false true -- finds clause 2 f false false -- finds clause 3 done -}
{ "alphanum_fraction": 0.6267529666, "avg_line_length": 13.0563380282, "ext": "agda", "hexsha": "e44be10acac9c050a080805a43a0cc06e6836973", "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/FlexibleFunArity.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/FlexibleFunArity.agda", "max_line_length": 53, "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/FlexibleFunArity.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": 286, "size": 927 }
module Data.Empty.Instance where open import Class.Equality open import Class.Show open import Data.Empty instance Empty-Eq : Eq ⊥ Empty-Eq = record { _≟_ = λ x () } Empty-Show : Show ⊥ Empty-Show = record { show = λ () }
{ "alphanum_fraction": 0.669527897, "avg_line_length": 17.9230769231, "ext": "agda", "hexsha": "a0aa219969b56b6e4b859b88342728640791c303", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Data/Empty/Instance.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Data/Empty/Instance.agda", "max_line_length": 37, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Data/Empty/Instance.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 70, "size": 233 }
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; trans; cong) open Eq.≡-Reasoning open import Function using (_∘_) open import Data.Product using (_×_) using (_,_; proj₁; proj₂) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥; ⊥-elim) postulate extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) → f ≡ g β-×₁ : ∀ {A B : Set} (x : A) (y : B) → proj₁ (x , y) ≡ x β-×₁ x y = refl β-×₂ : ∀ {A B : Set} (x : A) (y : B) → proj₂ (x , y) ≡ y β-×₂ x y = refl η-× : ∀ {A B : Set} (w : A × B) → (proj₁ w , proj₂ w) ≡ w η-× (x , y) = refl uniq-× : ∀ {A B C : Set} (h : C → A × B) (v : C) → (proj₁ (h v) , proj₂ (h v)) ≡ h v uniq-× h v = η-× (h v) ⊎-elim : ∀ {A B C : Set} → (A → C) → (B → C) → (A ⊎ B → C) ⊎-elim f g (inj₁ x) = f x ⊎-elim f g (inj₂ y) = g y β-⊎₁ : ∀ {A B C : Set} (f : A → C) (g : B → C) (x : A) → ⊎-elim f g (inj₁ x) ≡ f x β-⊎₁ f g x = refl β-⊎₂ : ∀ {A B C : Set} (f : A → C) (g : B → C) (y : B) → ⊎-elim f g (inj₂ y) ≡ g y β-⊎₂ f g x = refl η-⊎ : ∀ {A B : Set} (w : A ⊎ B) → ⊎-elim inj₁ inj₂ w ≡ w η-⊎ (inj₁ x) = refl η-⊎ (inj₂ y) = refl natural-⊎ : ∀ {A B C D : Set} (f : A → C) (g : B → C) (h : C → D) (w : A ⊎ B) → ⊎-elim (h ∘ f) (h ∘ g) w ≡ (h ∘ ⊎-elim f g) w natural-⊎ f g h (inj₁ x) = refl natural-⊎ f g h (inj₂ y) = refl uniq-⊎ : ∀ {A B C : Set} (h : A ⊎ B → C) (w : A ⊎ B) → ⊎-elim (h ∘ inj₁) (h ∘ inj₂) w ≡ h w uniq-⊎ h w rewrite natural-⊎ inj₁ inj₂ h w | η-⊎ w = refl η-⊤ : ∀ (w : ⊤) → tt ≡ w η-⊤ tt = refl uniq-⊤ : ∀ {C : Set} (h : C → ⊤) (v : C) → tt ≡ h v uniq-⊤ h v = η-⊤ (h v) η-⊥ : ∀ (w : ⊥) → ⊥-elim w ≡ w η-⊥ () natural-⊥ : ∀ {C D : Set} (h : C → D) (w : ⊥) → ⊥-elim w ≡ (h ∘ ⊥-elim) w natural-⊥ h () uniq-⊥ : ∀ {C : Set} (h : ⊥ → C) (w : ⊥) → ⊥-elim w ≡ h w uniq-⊥ h w rewrite natural-⊥ h w | η-⊥ w = refl η-→ : ∀ {A B : Set} (f : A → B) → (λ{x → f x}) ≡ f η-→ {A} {B} f = extensionality η-helper where η-lhs : A → B η-lhs = λ{x → f x} η-helper : (x : A) → η-lhs x ≡ f x η-helper x = refl
{ "alphanum_fraction": 0.4520813166, "avg_line_length": 29.0985915493, "ext": "agda", "hexsha": "403d9531fc00af3307bdcab796cad292f0fc6013", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/Eta.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/Eta.agda", "max_line_length": 125, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/Eta.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 1118, "size": 2066 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Operations.Subtraction where open import Data.Binary.Definitions open import Data.Product as Product using (map₁; map₂; proj₁; proj₂; _,_; _×_) open import Data.Bool import Data.Maybe as Maybe import Data.Binary.Operations.Addition as + open import Data.Binary.Operations.Unary infixr 5 Is_∷_ O∷_ Is_∷_ : Bit → 𝔹± → 𝔹± Is s ∷ xs = 0< Maybe.maybe′ (map₂ (I ∷_)) (s , 1ᵇ) xs O∷_ : 𝔹± → 𝔹± O∷_ = Maybe.map (map₂ (O ∷_)) mutual sub₀ : 𝔹⁺ → 𝔹⁺ → 𝔹± sub₀ 1ᵇ ys = Maybe.map (I ,_) (dec⁺ ys) sub₀ (x ∷ xs) 1ᵇ = 0< (O , dec⁺⁺ x xs) sub₀ (O ∷ xs) (O ∷ ys) = O∷ sub₀ xs ys sub₀ (O ∷ xs) (I ∷ ys) = Is I ∷ sub₁ xs ys sub₀ (I ∷ xs) (O ∷ ys) = Is O ∷ sub₀ xs ys sub₀ (I ∷ xs) (I ∷ ys) = O∷ sub₀ xs ys sub₁ : 𝔹⁺ → 𝔹⁺ → 𝔹± sub₁ 1ᵇ ys = 0< (I , ys) sub₁ (O ∷ xs) (O ∷ ys) = Is I ∷ sub₁ xs ys sub₁ (O ∷ xs) (I ∷ ys) = O∷ sub₁ xs ys sub₁ (O ∷ 1ᵇ) 1ᵇ = 0ᵇ sub₁ (O ∷ x ∷ xs) 1ᵇ = 0< (O , O ∷ dec⁺⁺ x xs) sub₁ (I ∷ xs) (O ∷ ys) = O∷ sub₀ xs ys sub₁ (I ∷ xs) (I ∷ ys) = Is I ∷ sub₁ xs ys sub₁ (I ∷ 1ᵇ) 1ᵇ = 0< (O , 1ᵇ) sub₁ (I ∷ x ∷ xs) 1ᵇ = 0< (O , I ∷ dec⁺⁺ x xs) _+_ : 𝔹± → 𝔹± → 𝔹± 0ᵇ + ys = ys (0< xs) + 0ᵇ = 0< xs (0< (O , xs)) + (0< (O , ys)) = 0< (O , +.add O xs ys) (0< (O , xs)) + (0< (I , ys)) = sub₀ xs ys (0< (I , xs)) + (0< (O , ys)) = sub₀ ys xs (0< (I , xs)) + (0< (I , ys)) = 0< (I , +.add O xs ys)
{ "alphanum_fraction": 0.5118961788, "avg_line_length": 30.152173913, "ext": "agda", "hexsha": "241a0c1d489a191675758f2e03e4bb03fe53ef40", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_path": "Data/Binary/Operations/Subtraction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-binary", "max_issues_repo_path": "Data/Binary/Operations/Subtraction.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_path": "Data/Binary/Operations/Subtraction.agda", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "num_tokens": 763, "size": 1387 }
{-# OPTIONS --rewriting #-} open import Agda.Builtin.Equality postulate f : Set₁ → Set₁ module _ (A : Set) where postulate rew : f Set ≡ Set {-# BUILTIN REWRITE _≡_ #-} {-# REWRITE rew #-}
{ "alphanum_fraction": 0.6358974359, "avg_line_length": 16.25, "ext": "agda", "hexsha": "f97d31fdd7a8fd7c75d9923fb39e08eb09aa6d73", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/RewritingIgnoreUnusedParameter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/RewritingIgnoreUnusedParameter.agda", "max_line_length": 33, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/RewritingIgnoreUnusedParameter.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 60, "size": 195 }
module CwF where open import Setoid open EqChain infixr 30 _⇒_ infixl 50 _/_ _/ˢ_ infixr 45 _◄_ infixl 45 _▷_ Cxt : Set Cxt = Setoid _⇒_ : Cxt -> Cxt -> Set Γ ⇒ Δ = El (Γ ==> Δ) Type : Cxt -> Set Type Γ = Fam Γ _/_ : {Γ Δ : Cxt} -> Type Γ -> (Δ ⇒ Γ) -> Type Δ A / σ = A ○ σ lem-/id : {Γ : Cxt}{A : Type Γ} -> A / id == A lem-/id = lem-○-id Term : (Γ : Cxt) -> Type Γ -> Set Term Γ A = El (Π Γ A) _◄_ : {Γ : Cxt}{A B : Type Γ} -> B == A -> Term Γ A -> Term Γ B B=A ◄ u = eqΠ refl B=A << u _/ˢ_ : {Γ Δ : Cxt}{A : Type Γ} -> Term Γ A -> (σ : Δ ⇒ Γ) -> Term Δ (A / σ) u /ˢ σ = u ∘ σ _▷_ : (Γ : Cxt) -> Type Γ -> Cxt Γ ▷ A = Σ Γ A wk : {Γ : Cxt}(A : Type Γ) -> Γ ▷ A ⇒ Γ wk A = ƛ fst \ x y x=y -> fst-eq x=y vz : {Γ : Cxt}(A : Type Γ) -> Term (Γ ▷ A) (A / wk A) vz A = ƛ snd \ x y x=y -> snd-eq x=y ext : {Γ Δ : Cxt}(A : Type Γ)(σ : Δ ⇒ Γ)(u : Term Δ (A / σ)) -> Δ ⇒ Γ ▷ A ext A σ u = ƛ (\x -> (σ # x , u # x)) \x y x=y -> eqInΣ refl (#-cong-R σ x=y) (#-cong-R u x=y) lem-/-· : {Γ Δ Θ : Cxt}(A : Type Γ)(σ : Δ ⇒ Γ)(δ : Θ ⇒ Δ) -> A / σ · δ == A / σ / δ lem-/-· A σ δ = eqFam refl \x y x=y -> !-cong-R A (sym (cast-id' _ (#-cong-R σ (#-cong-R δ (cast-id' _ (sym x=y)))))) lem-wk-∘-ext : {Γ Δ : Cxt}(A : Type Δ)(σ : Γ ⇒ Δ)(u : Term Γ (A / σ)) -> wk A ∘ ext A σ u == σ lem-wk-∘-ext A (ƛ σ pσ) u = eqInΠ refl pσ lem-vz-/-ext : {Γ Δ : Cxt}(A : Type Δ)(σ : Γ ⇒ Δ)(u : Term Γ (A / σ)) -> vz A /ˢ (ext A σ u) == u lem-vz-/-ext A σ (ƛ u pu) = eqInΠ refl pu -- (σ , u) ∘ δ == (σ ∘ δ , u / δ) lem-ext-∘ : {Γ Δ Θ : Cxt}{A : Type Γ}(σ : Δ ⇒ Γ)(δ : Θ ⇒ Δ)(u : Term Δ (A / σ)) -> ext A σ u · δ == ext A (σ · δ) (lem-/-· A σ δ ◄ u /ˢ δ) lem-ext-∘ σ δ u = eqInΠ refl \x y x=y -> eqInΣ refl (cast-irr _ _ (#-cong-R σ (#-cong-R δ (cast-irr _ _ x=y)))) (cast-irr _ _ (#-cong-R u (#-cong-R δ (cast-irr _ _ x=y)))) <_> : {Γ : Cxt}{A : Type Γ} -> Term Γ A -> Γ ⇒ Γ ▷ A < u > = ext _ id (lem-○-id ◄ u) lift : {Γ Δ : Cxt}(A : Type Γ)(σ : Δ ⇒ Γ) -> Δ ▷ (A / σ) ⇒ Γ ▷ A lift A σ = ƛ (\x -> σ # fst x , snd x) \x y x=y -> eqInΣ refl (#-cong-R σ (fst-eq x=y)) (snd-eq x=y) curryFam : {A : Setoid}{F : Fam A} -> Fam (Σ A F) -> (x : El A) -> Fam (F ! x) curryFam G x = fam (\y -> G ! (x , y)) \z w z=w -> !-cong-R G (eqInΣ refl refl z=w) Pi : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A)) -> Type Γ Pi A B = fam (\x -> Π (A ! x) (curryFam B x)) \x y x=y -> eqΠ (!-cong-R A (sym x=y)) (eqFam (!-cong-R A (sym x=y)) \z w z=w -> !-cong-R B (eqInΣ refl x=y z=w) ) lem-Pi-/ : {Γ Δ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A))(σ : Δ ⇒ Γ) -> Pi A B / σ == Pi (A / σ) (B / lift A σ) lem-Pi-/ A B σ = eqFam refl \x y x=y -> eqΠ (Aσ-eq x=y) (eqFam (Aσ-eq x=y) \z w z=w -> !-cong-R B (eqInΣ refl (#-cong-R σ x=y) z=w) ) where Aσ-eq : forall {x y} -> x == y -> A ! σ # y == A ! σ # x Aσ-eq x=y = !-cong-R A (#-cong-R σ (sym x=y)) lam : {Γ : Cxt}{A : Type Γ}{B : Type (Γ ▷ A)} -> Term (Γ ▷ A) B -> Term Γ (Pi A B) lam {A = A} f = ƛ (\γ -> ƛ (\x -> f # (γ , x)) (prf₁ γ)) prf₂ where prf₁ : forall γ x y x=y -> _ prf₁ = \γ x y x=y -> #-cong-R f (eqInΣ refl refl x=y) prf₂ = \x y x=y -> eqInΠ (!-cong-R A (sym x=y)) \z w z=w -> #-cong-R f (eqInΣ refl x=y z=w) app : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A)) (v : Term Γ (Pi A B))(u : Term Γ A) -> Term Γ (B / < u >) app A B v u = ƛ (\γ -> prf₁ γ << v # γ # (u # γ)) prf₂ where lem : forall γ -> < u > # γ == (γ , u # γ) lem γ = eqInΣ refl refl (#-cong (lem-○-id ◄ u) u (sym (cast-id _)) refl) prf₁ : forall γ -> (B / < u >) ! γ == B ! (γ , u # γ) prf₁ γ = !-cong-R B (lem γ) prf₂ = \x y x=y -> cast-irr _ _ (#-cong (v # x) (v # y) (#-cong-R v x=y) (#-cong-R u x=y) ) lem-β : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A)) (v : Term (Γ ▷ A) B)(u : Term Γ A) -> app A B (lam v) u == v /ˢ < u > lem-β A B v u = eqInΠ refl \x y x=y -> sym (cast-id' _ (#-cong-R v (eqInΣ refl (sym x=y) (#-cong (lem-○-id ◄ u) u (sym (cast-id _)) (sym x=y))) ) ) -- The stack blows when trying to prove η. -- I'm not sure it does anymore, but I have no idea how to prove η, -- I struggled just giving the type. -- lem-η : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A)) -- (v : Term Γ (Pi A B)) → -- v == lam (app (A / wk A) (B / lift A (wk A)) (sym (lem-Pi-/ A B (wk A)) ◄ v /ˢ wk A) (vz A)) -- lem-η {Γ} A B (ƛ f pf) = -- eqInΠ =S=-refl λ γ δ γ=δ → -- proof f γ ≡ ƛ (_#_ (f γ)) (λ _ _ → #-cong-R (f γ)) by η (f γ) -- ≡ _ by eqInΠ (!-cong-R A (sym γ=δ)) (λ x y x=y → -- proof f γ # x -- ≡ (_ << (_ << f (_ << δ))) # y by {!!} -- qed) -- qed
{ "alphanum_fraction": 0.4081304085, "avg_line_length": 32.9072847682, "ext": "agda", "hexsha": "37d5842b12393648b800af3a2f2139f083449675", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "benchmark/cwf/CwF.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "benchmark/cwf/CwF.agda", "max_line_length": 103, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "benchmark/cwf/CwF.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 2266, "size": 4969 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Exactness open import cohomology.FunctionOver open import cohomology.Theory open import cohomology.CofiberSequence module cohomology.LongExactSequence {i} (CT : CohomologyTheory i) {X Y : Ptd i} (n : ℤ) (f : fst (X ⊙→ Y)) where open CohomologyTheory CT open import cohomology.Functor CT open import cohomology.BaseIndependence CT co∂ : C n X →ᴳ C (succ n) (⊙Cof f) co∂ = CF-hom (succ n) ⊙ext-glue ∘ᴳ fst ((C-Susp n X)⁻¹ᴳ) long-cofiber-seq : HomSequence _ _ long-cofiber-seq = C n Y ⟨ CF-hom n f ⟩→ C n X ⟨ co∂ ⟩→ C (succ n) (⊙Cof f) ⟨ CF-hom (succ n) (⊙cfcod f) ⟩→ C (succ n) Y ⟨ CF-hom (succ n) f ⟩→ C (succ n) X ⊣| long-cofiber-exact : is-exact-seq long-cofiber-seq long-cofiber-exact = {- apply the suspension isomorphism -} transport (λ {(r , s) → is-exact-seq s}) (pair= _ $ sequence= _ _ $ group-ua (C-Susp n Y) ∥⟨ C-Susp-↓ n f ⟩∥ group-ua (C-Susp n X) ∥⟨ ↓-over-×-in _→ᴳ_ (domain-over-iso (λ= (! ∘ ap (GroupHom.f (CF-hom _ ⊙ext-glue)) ∘ is-equiv.g-f (snd (C-Susp n X))) ◃ domain-over-equiv _ _)) idp ⟩∥ idp ∥⟨ idp ⟩∥ idp ∥⟨ idp ⟩∥ idp ∥⊣|) {- fix the function basepoints -} (transport (λ {(φ , ψ) → is-exact-seq $ _ ⟨ φ ⟩→ _ ⟨ ψ ⟩→ _ ⟨ CF-hom (succ n) (⊙cfcod f) ⟩→ _ ⟨ CF-hom (succ n) f ⟩→ _ ⊣|}) (pair×= (CF-base-indep (succ n) _ _ _) (CF-base-indep (succ n) _ _ _)) {- do the CofiberSequence transport -} (transport {A = Σ _ (λ {((U , V) , g , h) → (g (cfbase _) == snd U) × (h (snd U) == snd V)})} (λ {((_ , g , h) , (p , q)) → is-exact-seq $ _ ⟨ CF-hom (succ n) (h , q) ⟩→ _ ⟨ CF-hom (succ n) (g , p) ⟩→ _ ⟨ CF-hom (succ n) (⊙cfcod f) ⟩→ _ ⟨ CF-hom (succ n) f ⟩→ _ ⊣|}) (pair= (cofiber-sequence f) (↓-×-in (from-transp _ _ idp) (from-transp _ _ idp))) (exact-build (_ ⟨ CF-hom (succ n) (⊙cfcod³ f) ⟩→ _ ⟨ CF-hom (succ n) (⊙cfcod² f) ⟩→ _ ⟨ CF-hom (succ n) (⊙cfcod f) ⟩→ _ ⟨ CF-hom (succ n) f ⟩→ _ ⊣|) (C-exact (succ n) (⊙cfcod² f)) (C-exact (succ n) (⊙cfcod f)) (C-exact (succ n) f))))
{ "alphanum_fraction": 0.4819576939, "avg_line_length": 37.0923076923, "ext": "agda", "hexsha": "9c935d38e664045e7d1f447ef20f9b2ef12ce76b", "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/LongExactSequence.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/LongExactSequence.agda", "max_line_length": 80, "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/LongExactSequence.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": 964, "size": 2411 }
open import Prelude open import Nat open import dynamics-core open import contexts open import disjointness -- this module contains lemmas and properties about the holes-disjoint -- judgement that double check that it acts as we would expect module holes-disjoint-checks where -- these lemmas are all structurally recursive and quite -- mechanical. morally, they establish the properties about reduction -- that would be obvious / baked into Agda if holes-disjoint was defined -- as a function rather than a judgement (datatype), or if we had defined -- all the O(n^2) cases rather than relying on a little indirection to -- only have O(n) cases. that work has to go somewhwere, and we prefer -- that it goes here. ds-lem-num : ∀{e n} → holes-disjoint e (N n) ds-lem-num {N x} = HDNum ds-lem-num {e ·+ e₁} = HDPlus ds-lem-num ds-lem-num ds-lem-num {e ·: x} = HDAsc ds-lem-num ds-lem-num {X x} = HDVar ds-lem-num {·λ x e} = HDLam1 ds-lem-num ds-lem-num {·λ x ·[ x₁ ] e} = HDLam2 ds-lem-num ds-lem-num {e ∘ e₁} = HDAp ds-lem-num ds-lem-num ds-lem-num {inl e} = HDInl ds-lem-num ds-lem-num {inr e} = HDInr ds-lem-num ds-lem-num {case e x e₁ x₁ e₂} = HDCase ds-lem-num ds-lem-num ds-lem-num ds-lem-num {⟨ e , e₁ ⟩} = HDPair ds-lem-num ds-lem-num ds-lem-num {fst e} = HDFst ds-lem-num ds-lem-num {snd e} = HDSnd ds-lem-num ds-lem-num {⦇-⦈[ x ]} = HDHole HNNum ds-lem-num {⦇⌜ e ⌟⦈[ x ]} = HDNEHole HNNum ds-lem-num ds-lem-plus : ∀{e1 e2 e3} → holes-disjoint e3 e1 → holes-disjoint e3 e2 → holes-disjoint e3 (e1 ·+ e2) ds-lem-plus HDNum ν = HDNum ds-lem-plus (HDPlus hd hd₁) (HDPlus ν ν₁) = HDPlus (ds-lem-plus hd ν) (ds-lem-plus hd₁ ν₁) ds-lem-plus (HDAsc hd) (HDAsc ν) = HDAsc (ds-lem-plus hd ν) ds-lem-plus HDVar HDVar = HDVar ds-lem-plus (HDLam1 hd) (HDLam1 ν) = HDLam1 (ds-lem-plus hd ν) ds-lem-plus (HDLam2 hd) (HDLam2 ν) = HDLam2 (ds-lem-plus hd ν) ds-lem-plus (HDAp hd hd₁) (HDAp ν ν₁) = HDAp (ds-lem-plus hd ν) (ds-lem-plus hd₁ ν₁) ds-lem-plus (HDInl hd) (HDInl ν) = HDInl (ds-lem-plus hd ν) ds-lem-plus (HDInr hd) (HDInr ν) = HDInr (ds-lem-plus hd ν) ds-lem-plus (HDCase hd hd₁ hd₂) (HDCase ν ν₁ ν₂) = HDCase (ds-lem-plus hd ν) (ds-lem-plus hd₁ ν₁) (ds-lem-plus hd₂ ν₂) ds-lem-plus (HDPair hd hd₁) (HDPair ν ν₁) = HDPair (ds-lem-plus hd ν) (ds-lem-plus hd₁ ν₁) ds-lem-plus (HDFst hd) (HDFst ν) = HDFst (ds-lem-plus hd ν) ds-lem-plus (HDSnd hd) (HDSnd ν) = HDSnd (ds-lem-plus hd ν) ds-lem-plus (HDHole x) (HDHole x₁) = HDHole (HNPlus x x₁) ds-lem-plus (HDNEHole x hd) (HDNEHole x₁ ν) = HDNEHole (HNPlus x x₁) (ds-lem-plus hd ν) ds-lem-var : ∀{e x} → holes-disjoint e (X x) ds-lem-var {N x} = HDNum ds-lem-var {e ·+ e₁} = HDPlus ds-lem-var ds-lem-var ds-lem-var {e ·: x} = HDAsc ds-lem-var ds-lem-var {X x} = HDVar ds-lem-var {·λ x e} = HDLam1 ds-lem-var ds-lem-var {·λ x ·[ x₁ ] e} = HDLam2 ds-lem-var ds-lem-var {e ∘ e₁} = HDAp ds-lem-var ds-lem-var ds-lem-var {inl e} = HDInl ds-lem-var ds-lem-var {inr e} = HDInr ds-lem-var ds-lem-var {case e x e₁ x₁ e₂} = HDCase ds-lem-var ds-lem-var ds-lem-var ds-lem-var {⟨ e , e₁ ⟩} = HDPair ds-lem-var ds-lem-var ds-lem-var {fst e} = HDFst ds-lem-var ds-lem-var {snd e} = HDSnd ds-lem-var ds-lem-var {⦇-⦈[ x ]} = HDHole HNVar ds-lem-var {⦇⌜ e ⌟⦈[ x ]} = HDNEHole HNVar ds-lem-var ds-lem-asc : ∀{e1 e2 τ} → holes-disjoint e2 e1 → holes-disjoint e2 (e1 ·: τ) ds-lem-asc HDNum = HDNum ds-lem-asc (HDPlus hd hd₁) = HDPlus (ds-lem-asc hd) (ds-lem-asc hd₁) ds-lem-asc (HDAsc hd) = HDAsc (ds-lem-asc hd) ds-lem-asc HDVar = HDVar ds-lem-asc (HDLam1 hd) = HDLam1 (ds-lem-asc hd) ds-lem-asc (HDLam2 hd) = HDLam2 (ds-lem-asc hd) ds-lem-asc (HDAp hd hd₁) = HDAp (ds-lem-asc hd) (ds-lem-asc hd₁) ds-lem-asc (HDInl hd) = HDInl (ds-lem-asc hd) ds-lem-asc (HDInr hd) = HDInr (ds-lem-asc hd) ds-lem-asc (HDCase hd hd₁ hd₂) = HDCase (ds-lem-asc hd) (ds-lem-asc hd₁) (ds-lem-asc hd₂) ds-lem-asc (HDPair hd hd₁) = HDPair (ds-lem-asc hd) (ds-lem-asc hd₁) ds-lem-asc (HDFst hd) = HDFst (ds-lem-asc hd) ds-lem-asc (HDSnd hd) = HDSnd (ds-lem-asc hd) ds-lem-asc (HDHole x) = HDHole (HNAsc x) ds-lem-asc (HDNEHole x hd) = HDNEHole (HNAsc x) (ds-lem-asc hd) ds-lem-lam1 : ∀{e1 e2 x} → holes-disjoint e2 e1 → holes-disjoint e2 (·λ x e1) ds-lem-lam1 HDNum = HDNum ds-lem-lam1 (HDPlus hd hd₁) = HDPlus (ds-lem-lam1 hd) (ds-lem-lam1 hd₁) ds-lem-lam1 (HDAsc hd) = HDAsc (ds-lem-lam1 hd) ds-lem-lam1 HDVar = HDVar ds-lem-lam1 (HDLam1 hd) = HDLam1 (ds-lem-lam1 hd) ds-lem-lam1 (HDLam2 hd) = HDLam2 (ds-lem-lam1 hd) ds-lem-lam1 (HDAp hd hd₁) = HDAp (ds-lem-lam1 hd) (ds-lem-lam1 hd₁) ds-lem-lam1 (HDInl hd) = HDInl (ds-lem-lam1 hd) ds-lem-lam1 (HDInr hd) = HDInr (ds-lem-lam1 hd) ds-lem-lam1 (HDCase hd hd₁ hd₂) = HDCase (ds-lem-lam1 hd) (ds-lem-lam1 hd₁) (ds-lem-lam1 hd₂) ds-lem-lam1 (HDPair hd hd₁) = HDPair (ds-lem-lam1 hd) (ds-lem-lam1 hd₁) ds-lem-lam1 (HDFst hd) = HDFst (ds-lem-lam1 hd) ds-lem-lam1 (HDSnd hd) = HDSnd (ds-lem-lam1 hd) ds-lem-lam1 (HDHole x₁) = HDHole (HNLam1 x₁) ds-lem-lam1 (HDNEHole x₁ hd) = HDNEHole (HNLam1 x₁) (ds-lem-lam1 hd) ds-lem-lam2 : ∀{e1 e2 x τ} → holes-disjoint e2 e1 → holes-disjoint e2 (·λ x ·[ τ ] e1) ds-lem-lam2 HDNum = HDNum ds-lem-lam2 (HDPlus hd hd₁) = HDPlus (ds-lem-lam2 hd) (ds-lem-lam2 hd₁) ds-lem-lam2 (HDAsc hd) = HDAsc (ds-lem-lam2 hd) ds-lem-lam2 HDVar = HDVar ds-lem-lam2 (HDLam1 hd) = HDLam1 (ds-lem-lam2 hd) ds-lem-lam2 (HDLam2 hd) = HDLam2 (ds-lem-lam2 hd) ds-lem-lam2 (HDAp hd hd₁) = HDAp (ds-lem-lam2 hd) (ds-lem-lam2 hd₁) ds-lem-lam2 (HDInl hd) = HDInl (ds-lem-lam2 hd) ds-lem-lam2 (HDInr hd) = HDInr (ds-lem-lam2 hd) ds-lem-lam2 (HDCase hd hd₁ hd₂) = HDCase (ds-lem-lam2 hd) (ds-lem-lam2 hd₁) (ds-lem-lam2 hd₂) ds-lem-lam2 (HDPair hd hd₁) = HDPair (ds-lem-lam2 hd) (ds-lem-lam2 hd₁) ds-lem-lam2 (HDFst hd) = HDFst (ds-lem-lam2 hd) ds-lem-lam2 (HDSnd hd) = HDSnd (ds-lem-lam2 hd) ds-lem-lam2 (HDHole x₁) = HDHole (HNLam2 x₁) ds-lem-lam2 (HDNEHole x₁ hd) = HDNEHole (HNLam2 x₁) (ds-lem-lam2 hd) ds-lem-ap : ∀{e1 e2 e3} → holes-disjoint e3 e1 → holes-disjoint e3 e2 → holes-disjoint e3 (e1 ∘ e2) ds-lem-ap HDNum hd2 = HDNum ds-lem-ap (HDPlus hd1 hd2) (HDPlus hd3 hd4) = HDPlus (ds-lem-ap hd1 hd3) (ds-lem-ap hd2 hd4) ds-lem-ap (HDAsc hd1) (HDAsc hd2) = HDAsc (ds-lem-ap hd1 hd2) ds-lem-ap HDVar hd2 = HDVar ds-lem-ap (HDLam1 hd1) (HDLam1 hd2) = HDLam1 (ds-lem-ap hd1 hd2) ds-lem-ap (HDLam2 hd1) (HDLam2 hd2) = HDLam2 (ds-lem-ap hd1 hd2) ds-lem-ap (HDAp hd1 hd2) (HDAp hd3 hd4) = HDAp (ds-lem-ap hd1 hd3) (ds-lem-ap hd2 hd4) ds-lem-ap (HDInl hd) (HDInl ν) = HDInl (ds-lem-ap hd ν) ds-lem-ap (HDInr hd) (HDInr ν) = HDInr (ds-lem-ap hd ν) ds-lem-ap (HDCase hd hd₁ hd₂) (HDCase ν ν₁ ν₂) = HDCase (ds-lem-ap hd ν) (ds-lem-ap hd₁ ν₁) (ds-lem-ap hd₂ ν₂) ds-lem-ap (HDPair hd hd₁) (HDPair ν ν₁) = HDPair (ds-lem-ap hd ν) (ds-lem-ap hd₁ ν₁) ds-lem-ap (HDFst hd) (HDFst ν) = HDFst (ds-lem-ap hd ν) ds-lem-ap (HDSnd hd) (HDSnd ν) = HDSnd (ds-lem-ap hd ν) ds-lem-ap (HDHole x) (HDHole x₁) = HDHole (HNAp x x₁) ds-lem-ap (HDNEHole x hd1) (HDNEHole x₁ hd2) = HDNEHole (HNAp x x₁) (ds-lem-ap hd1 hd2) ds-lem-inl : ∀{e1 e2} → holes-disjoint e2 e1 → holes-disjoint e2 (inl e1) ds-lem-inl HDNum = HDNum ds-lem-inl (HDPlus hd hd₁) = HDPlus (ds-lem-inl hd) (ds-lem-inl hd₁) ds-lem-inl (HDAsc hd) = HDAsc (ds-lem-inl hd) ds-lem-inl HDVar = HDVar ds-lem-inl (HDLam1 hd) = HDLam1 (ds-lem-inl hd) ds-lem-inl (HDLam2 hd) = HDLam2 (ds-lem-inl hd) ds-lem-inl (HDAp hd hd₁) = HDAp (ds-lem-inl hd) (ds-lem-inl hd₁) ds-lem-inl (HDInl hd) = HDInl (ds-lem-inl hd) ds-lem-inl (HDInr hd) = HDInr (ds-lem-inl hd) ds-lem-inl (HDCase hd hd₁ hd₂) = HDCase (ds-lem-inl hd) (ds-lem-inl hd₁) (ds-lem-inl hd₂) ds-lem-inl (HDPair hd hd₁) = HDPair (ds-lem-inl hd) (ds-lem-inl hd₁) ds-lem-inl (HDFst hd) = HDFst (ds-lem-inl hd) ds-lem-inl (HDSnd hd) = HDSnd (ds-lem-inl hd) ds-lem-inl (HDHole x) = HDHole (HNInl x) ds-lem-inl (HDNEHole x hd) = HDNEHole (HNInl x) (ds-lem-inl hd) ds-lem-inr : ∀{e1 e2} → holes-disjoint e2 e1 → holes-disjoint e2 (inr e1) ds-lem-inr HDNum = HDNum ds-lem-inr (HDPlus hd hd₁) = HDPlus (ds-lem-inr hd) (ds-lem-inr hd₁) ds-lem-inr (HDAsc hd) = HDAsc (ds-lem-inr hd) ds-lem-inr HDVar = HDVar ds-lem-inr (HDLam1 hd) = HDLam1 (ds-lem-inr hd) ds-lem-inr (HDLam2 hd) = HDLam2 (ds-lem-inr hd) ds-lem-inr (HDAp hd hd₁) = HDAp (ds-lem-inr hd) (ds-lem-inr hd₁) ds-lem-inr (HDInl hd) = HDInl (ds-lem-inr hd) ds-lem-inr (HDInr hd) = HDInr (ds-lem-inr hd) ds-lem-inr (HDCase hd hd₁ hd₂) = HDCase (ds-lem-inr hd) (ds-lem-inr hd₁) (ds-lem-inr hd₂) ds-lem-inr (HDPair hd hd₁) = HDPair (ds-lem-inr hd) (ds-lem-inr hd₁) ds-lem-inr (HDFst hd) = HDFst (ds-lem-inr hd) ds-lem-inr (HDSnd hd) = HDSnd (ds-lem-inr hd) ds-lem-inr (HDHole x) = HDHole (HNInr x) ds-lem-inr (HDNEHole x hd) = HDNEHole (HNInr x) (ds-lem-inr hd) ds-lem-case : ∀{e3 e x e1 y e2} → holes-disjoint e3 e → holes-disjoint e3 e1 → holes-disjoint e3 e2 → holes-disjoint e3 (case e x e1 y e2) ds-lem-case HDNum HDNum HDNum = HDNum ds-lem-case (HDPlus hd hd₁) (HDPlus ν ν₂) (HDPlus ν₁ ν₃) = HDPlus (ds-lem-case hd ν ν₁) (ds-lem-case hd₁ ν₂ ν₃) ds-lem-case (HDAsc hd) (HDAsc ν) (HDAsc ν₁) = HDAsc (ds-lem-case hd ν ν₁) ds-lem-case HDVar HDVar HDVar = HDVar ds-lem-case (HDLam1 hd) (HDLam1 ν) (HDLam1 ν₁) = HDLam1 (ds-lem-case hd ν ν₁) ds-lem-case (HDLam2 hd) (HDLam2 ν) (HDLam2 ν₁) = HDLam2 (ds-lem-case hd ν ν₁) ds-lem-case (HDAp hd hd₁) (HDAp ν ν₁) (HDAp ν₂ ν₃) = HDAp (ds-lem-case hd ν ν₂) (ds-lem-case hd₁ ν₁ ν₃) ds-lem-case (HDInl hd) (HDInl ν) (HDInl ν₁) = HDInl (ds-lem-case hd ν ν₁) ds-lem-case (HDInr hd) (HDInr ν) (HDInr ν₁) = HDInr (ds-lem-case hd ν ν₁) ds-lem-case (HDCase hd hd₁ hd₂) (HDCase ν ν₁ ν₂) (HDCase ν₃ ν₄ ν₅) = HDCase (ds-lem-case hd ν ν₃) (ds-lem-case hd₁ ν₁ ν₄) (ds-lem-case hd₂ ν₂ ν₅) ds-lem-case (HDPair hd hd₁) (HDPair ν ν₁) (HDPair ν₂ ν₃) = HDPair (ds-lem-case hd ν ν₂) (ds-lem-case hd₁ ν₁ ν₃) ds-lem-case (HDFst hd) (HDFst ν) (HDFst ν₁) = HDFst (ds-lem-case hd ν ν₁) ds-lem-case (HDSnd hd) (HDSnd ν) (HDSnd ν₁) = HDSnd (ds-lem-case hd ν ν₁) ds-lem-case (HDHole x) (HDHole x₁) (HDHole x₂) = HDHole (HNCase x x₁ x₂) ds-lem-case (HDNEHole x hd) (HDNEHole x₁ ν) (HDNEHole x₂ ν₁) = HDNEHole (HNCase x x₁ x₂) (ds-lem-case hd ν ν₁) ds-lem-pair : ∀{e1 e2 e3} → holes-disjoint e3 e1 → holes-disjoint e3 e2 → holes-disjoint e3 ⟨ e1 , e2 ⟩ ds-lem-pair HDNum HDNum = HDNum ds-lem-pair (HDPlus hd hd₁) (HDPlus ν ν₁) = HDPlus (ds-lem-pair hd ν) (ds-lem-pair hd₁ ν₁) ds-lem-pair (HDAsc hd) (HDAsc ν) = HDAsc (ds-lem-pair hd ν) ds-lem-pair HDVar HDVar = HDVar ds-lem-pair (HDLam1 hd) (HDLam1 ν) = HDLam1 (ds-lem-pair hd ν) ds-lem-pair (HDLam2 hd) (HDLam2 ν) = HDLam2 (ds-lem-pair hd ν) ds-lem-pair (HDAp hd hd₁) (HDAp ν ν₁) = HDAp (ds-lem-pair hd ν) (ds-lem-pair hd₁ ν₁) ds-lem-pair (HDInl hd) (HDInl ν) = HDInl (ds-lem-pair hd ν) ds-lem-pair (HDInr hd) (HDInr ν) = HDInr (ds-lem-pair hd ν) ds-lem-pair (HDCase hd hd₁ hd₂) (HDCase ν ν₁ ν₂) = HDCase (ds-lem-pair hd ν) (ds-lem-pair hd₁ ν₁) (ds-lem-pair hd₂ ν₂) ds-lem-pair (HDPair hd hd₁) (HDPair ν ν₁) = HDPair (ds-lem-pair hd ν) (ds-lem-pair hd₁ ν₁) ds-lem-pair (HDFst hd) (HDFst ν) = HDFst (ds-lem-pair hd ν) ds-lem-pair (HDSnd hd) (HDSnd ν) = HDSnd (ds-lem-pair hd ν) ds-lem-pair (HDHole x) (HDHole x₁) = HDHole (HNPair x x₁) ds-lem-pair (HDNEHole x hd) (HDNEHole x₁ ν) = HDNEHole (HNPair x x₁) (ds-lem-pair hd ν) ds-lem-fst : ∀{e1 e2} → holes-disjoint e2 e1 → holes-disjoint e2 (fst e1) ds-lem-fst HDNum = HDNum ds-lem-fst (HDPlus hd hd₁) = HDPlus (ds-lem-fst hd) (ds-lem-fst hd₁) ds-lem-fst (HDAsc hd) = HDAsc (ds-lem-fst hd) ds-lem-fst HDVar = HDVar ds-lem-fst (HDLam1 hd) = HDLam1 (ds-lem-fst hd) ds-lem-fst (HDLam2 hd) = HDLam2 (ds-lem-fst hd) ds-lem-fst (HDAp hd hd₁) = HDAp (ds-lem-fst hd) (ds-lem-fst hd₁) ds-lem-fst (HDInl hd) = HDInl (ds-lem-fst hd) ds-lem-fst (HDInr hd) = HDInr (ds-lem-fst hd) ds-lem-fst (HDCase hd hd₁ hd₂) = HDCase (ds-lem-fst hd) (ds-lem-fst hd₁) (ds-lem-fst hd₂) ds-lem-fst (HDPair hd hd₁) = HDPair (ds-lem-fst hd) (ds-lem-fst hd₁) ds-lem-fst (HDFst hd) = HDFst (ds-lem-fst hd) ds-lem-fst (HDSnd hd) = HDSnd (ds-lem-fst hd) ds-lem-fst (HDHole x) = HDHole (HNFst x) ds-lem-fst (HDNEHole x hd) = HDNEHole (HNFst x) (ds-lem-fst hd) ds-lem-snd : ∀{e1 e2} → holes-disjoint e2 e1 → holes-disjoint e2 (snd e1) ds-lem-snd HDNum = HDNum ds-lem-snd (HDPlus hd hd₁) = HDPlus (ds-lem-snd hd) (ds-lem-snd hd₁) ds-lem-snd (HDAsc hd) = HDAsc (ds-lem-snd hd) ds-lem-snd HDVar = HDVar ds-lem-snd (HDLam1 hd) = HDLam1 (ds-lem-snd hd) ds-lem-snd (HDLam2 hd) = HDLam2 (ds-lem-snd hd) ds-lem-snd (HDAp hd hd₁) = HDAp (ds-lem-snd hd) (ds-lem-snd hd₁) ds-lem-snd (HDInl hd) = HDInl (ds-lem-snd hd) ds-lem-snd (HDInr hd) = HDInr (ds-lem-snd hd) ds-lem-snd (HDCase hd hd₁ hd₂) = HDCase (ds-lem-snd hd) (ds-lem-snd hd₁) (ds-lem-snd hd₂) ds-lem-snd (HDPair hd hd₁) = HDPair (ds-lem-snd hd) (ds-lem-snd hd₁) ds-lem-snd (HDFst hd) = HDFst (ds-lem-snd hd) ds-lem-snd (HDSnd hd) = HDSnd (ds-lem-snd hd) ds-lem-snd (HDHole x) = HDHole (HNSnd x) ds-lem-snd (HDNEHole x hd) = HDNEHole (HNSnd x) (ds-lem-snd hd) ds-lem-hole : ∀{e u} → hole-name-new e u → holes-disjoint e ⦇-⦈[ u ] ds-lem-hole HNNum = HDNum ds-lem-hole (HNPlus hnn hnn₁) = HDPlus (ds-lem-hole hnn) (ds-lem-hole hnn₁) ds-lem-hole (HNAsc hnn) = HDAsc (ds-lem-hole hnn) ds-lem-hole HNVar = HDVar ds-lem-hole (HNLam1 hnn) = HDLam1 (ds-lem-hole hnn) ds-lem-hole (HNLam2 hnn) = HDLam2 (ds-lem-hole hnn) ds-lem-hole (HNAp hnn hnn₁) = HDAp (ds-lem-hole hnn) (ds-lem-hole hnn₁) ds-lem-hole (HNInl hnn) = HDInl (ds-lem-hole hnn) ds-lem-hole (HNInr hnn) = HDInr (ds-lem-hole hnn) ds-lem-hole (HNCase hnn hnn₁ hnn₂) = HDCase (ds-lem-hole hnn) (ds-lem-hole hnn₁) (ds-lem-hole hnn₂) ds-lem-hole (HNPair hn hn₁) = HDPair (ds-lem-hole hn) (ds-lem-hole hn₁) ds-lem-hole (HNFst hn) = HDFst (ds-lem-hole hn) ds-lem-hole (HNSnd hn) = HDSnd (ds-lem-hole hn) ds-lem-hole (HNHole x) = HDHole (HNHole (flip x)) ds-lem-hole (HNNEHole x hnn) = HDNEHole (HNHole (flip x)) (ds-lem-hole hnn) ds-lem-nehole : ∀{e e1 u} → holes-disjoint e e1 → hole-name-new e u → holes-disjoint e ⦇⌜ e1 ⌟⦈[ u ] ds-lem-nehole HDNum ν = HDNum ds-lem-nehole (HDPlus hd hd₁) (HNPlus ν ν₁) = HDPlus (ds-lem-nehole hd ν) (ds-lem-nehole hd₁ ν₁) ds-lem-nehole (HDAsc hd) (HNAsc ν) = HDAsc (ds-lem-nehole hd ν) ds-lem-nehole HDVar ν = HDVar ds-lem-nehole (HDLam1 hd) (HNLam1 ν) = HDLam1 (ds-lem-nehole hd ν) ds-lem-nehole (HDLam2 hd) (HNLam2 ν) = HDLam2 (ds-lem-nehole hd ν) ds-lem-nehole (HDAp hd hd₁) (HNAp ν ν₁) = HDAp (ds-lem-nehole hd ν) (ds-lem-nehole hd₁ ν₁) ds-lem-nehole (HDInl hd) (HNInl ν) = HDInl (ds-lem-nehole hd ν) ds-lem-nehole (HDInr hd) (HNInr ν) = HDInr (ds-lem-nehole hd ν) ds-lem-nehole (HDCase hd hd₁ hd₂) (HNCase ν ν₁ ν₂) = HDCase (ds-lem-nehole hd ν) (ds-lem-nehole hd₁ ν₁) (ds-lem-nehole hd₂ ν₂) ds-lem-nehole (HDPair hd hd₁) (HNPair ν ν₁) = HDPair (ds-lem-nehole hd ν) (ds-lem-nehole hd₁ ν₁) ds-lem-nehole (HDFst hd) (HNFst ν) = HDFst (ds-lem-nehole hd ν) ds-lem-nehole (HDSnd hd) (HNSnd ν) = HDSnd (ds-lem-nehole hd ν) ds-lem-nehole (HDHole x) (HNHole x₁) = HDHole (HNNEHole (flip x₁) x) ds-lem-nehole (HDNEHole x hd) (HNNEHole x₁ ν) = HDNEHole (HNNEHole (flip x₁) x) (ds-lem-nehole hd ν) -- holes-disjoint is symmetric disjoint-sym : ∀{e1 e2} → holes-disjoint e1 e2 → holes-disjoint e2 e1 disjoint-sym HDNum = ds-lem-num disjoint-sym (HDPlus hd hd₁) = ds-lem-plus (disjoint-sym hd) (disjoint-sym hd₁) disjoint-sym (HDAsc hd) = ds-lem-asc (disjoint-sym hd) disjoint-sym HDVar = ds-lem-var disjoint-sym (HDLam1 hd) = ds-lem-lam1 (disjoint-sym hd) disjoint-sym (HDLam2 hd) = ds-lem-lam2 (disjoint-sym hd) disjoint-sym (HDAp hd hd₁) = ds-lem-ap (disjoint-sym hd) (disjoint-sym hd₁) disjoint-sym (HDInl hd) = ds-lem-inl (disjoint-sym hd) disjoint-sym (HDInr hd) = ds-lem-inr (disjoint-sym hd) disjoint-sym (HDCase hd hd₁ hd₂) = ds-lem-case (disjoint-sym hd) (disjoint-sym hd₁) (disjoint-sym hd₂) disjoint-sym (HDPair hd hd₁) = ds-lem-pair (disjoint-sym hd) (disjoint-sym hd₁) disjoint-sym (HDFst hd) = ds-lem-fst (disjoint-sym hd) disjoint-sym (HDSnd hd) = ds-lem-snd (disjoint-sym hd) disjoint-sym (HDHole x) = ds-lem-hole x disjoint-sym (HDNEHole x hd) = ds-lem-nehole (disjoint-sym hd) x -- note that this is false, so holes-disjoint isn't transitive -- disjoint-new : ∀{e1 e2 u} → holes-disjoint e1 e2 → hole-name-new e1 u → hole-name-new e2 u -- it's also not reflexive, because ⦇-⦈[ u ] isn't hole-disjoint with -- itself since refl : u == u; it's also not anti-reflexive, because the -- expression c *is* hole-disjoint with itself (albeit vacuously)
{ "alphanum_fraction": 0.6470726684, "avg_line_length": 56.4617940199, "ext": "agda", "hexsha": "355a971dcabf6323867a51f44a7c9c5cd7aae9f2", "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": "holes-disjoint-checks.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "holes-disjoint-checks.agda", "max_line_length": 147, "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": "holes-disjoint-checks.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7877, "size": 16995 }
{-# OPTIONS --without-K #-} open import Base module Algebra.F2NotCommutative where import Algebra.FreeGroup open Algebra.FreeGroup (bool {zero}) renaming (freegroup to F2) X : Set X = bool × bool X-is-set : is-set X X-is-set = ×-is-truncated _ bool-is-set bool-is-set pattern a = (true , true ) pattern b = (true , false) pattern c = (false , true ) pattern d = (false , false) -- [map1] and [map2] are two involutive noncommutating bijections of [X] map1 : X → X map1 a = b map1 b = a map1 c = c map1 d = d map2 : X → X map2 a = c map2 b = b map2 c = a map2 d = d act : bool {zero} → (X → X) act true = map1 act false = map2 act-involutive : (b : bool) (x : X) → (act b (act b x) ≡ x) act-involutive true a = refl act-involutive true b = refl act-involutive true c = refl act-involutive true d = refl act-involutive false a = refl act-involutive false b = refl act-involutive false c = refl act-involutive false d = refl F2-act-on-X : F2 → (X → X) F2-act-on-X = freegroup-rec-nondep (X → X) (id X) (λ b f → f ◯ act b) (λ b f → f ◯ act b) (λ b f → funext (λ x → ap f (act-involutive b x))) (λ b f → funext (λ x → ap f (act-involutive b x))) (→-is-truncated _ X-is-set) ab : F2 ab = true · (false · e) ba : F2 ba = false · (true · e) F2-non-commutative : ab ≢ ba F2-non-commutative p = bool-true≢false (base-path (happly (ap F2-act-on-X p) a))
{ "alphanum_fraction": 0.6270818248, "avg_line_length": 20.6119402985, "ext": "agda", "hexsha": "06e504ae30a3c0068b4f3bbe2e3bf7861dc19d34", "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/Algebra/F2NotCommutative.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/Algebra/F2NotCommutative.agda", "max_line_length": 72, "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/Algebra/F2NotCommutative.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": 518, "size": 1381 }
module Structure.Sets.Relator where open import Functional import Lvl open import Logic open import Logic.Propositional open import Logic.Predicate import Structure.Sets.Names as Names open import Type private variable ℓ ℓₗ ℓᵣ ℓᵣₑₗ : Lvl.Level private variable S Sₗ Sᵣ E Eₗ Eᵣ : Type{ℓ} private variable _∈ₗ_ : E → Sₗ → Stmt{ℓₗ} private variable _∈ᵣ_ : E → Sᵣ → Stmt{ℓᵣ} module _ (_∈ₗ_ : E → Sₗ → Stmt{ℓₗ}) (_∈ᵣ_ : E → Sᵣ → Stmt{ℓᵣ}) where record SetEqualityRelation (_≡_ : Sₗ → Sᵣ → Stmt{ℓᵣₑₗ}) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓᵣₑₗ} where constructor intro field membership : Names.SetEqualityMembership(_∈ₗ_)(_∈ᵣ_)(_≡_) record SubsetRelation (_⊆_ : Sₗ → Sᵣ → Stmt{ℓᵣₑₗ}) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓᵣₑₗ} where constructor intro field membership : Names.SubsetMembership(_∈ₗ_)(_∈ᵣ_)(_⊆_) module _ ⦃ eq : ∃(SetEqualityRelation(_∈ₗ_)(_∈ᵣ_){ℓᵣₑₗ}) ⦄ where open ∃(eq) using () renaming (witness to _≡_) public open SetEqualityRelation([∃]-proof eq) using () renaming (membership to [≡]-membership) public _≢_ = (¬_) ∘₂ (_≡_) module _ ⦃ subset : ∃(SubsetRelation(_∈ₗ_)(_∈ᵣ_){ℓᵣ}) ⦄ where open ∃(subset) using () renaming (witness to _⊆_) public open SubsetRelation([∃]-proof subset) using () renaming (membership to [⊆]-membership) public open Names.From-[⊆] (_⊆_) public
{ "alphanum_fraction": 0.6768465909, "avg_line_length": 40.2285714286, "ext": "agda", "hexsha": "a0bc20a02967ecfb0a705e8bb96c270f00e4d051", "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/Sets/Relator.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Sets/Relator.agda", "max_line_length": 144, "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/Sets/Relator.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 667, "size": 1408 }
------------------------------------------------------------------------ -- The Agda standard library -- -- W-types ------------------------------------------------------------------------ module Data.W where open import Level open import Relation.Nullary -- The family of W-types. data W {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where sup : (x : A) (f : B x → W A B) → W A B -- Projections. head : ∀ {a b} {A : Set a} {B : A → Set b} → W A B → A head (sup x f) = x tail : ∀ {a b} {A : Set a} {B : A → Set b} → (x : W A B) → B (head x) → W A B tail (sup x f) = f -- If B is always inhabited, then W A B is empty. inhabited⇒empty : ∀ {a b} {A : Set a} {B : A → Set b} → (∀ x → B x) → ¬ W A B inhabited⇒empty b (sup x f) = inhabited⇒empty b (f (b x))
{ "alphanum_fraction": 0.4130162703, "avg_line_length": 24.96875, "ext": "agda", "hexsha": "4d47f7b1749217bb1f56e83b4acfcc9dcbef3a7b", "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/W.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/W.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/W.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": 270, "size": 799 }
{-# OPTIONS --without-K #-} module function.isomorphism.properties where open import level open import sum open import sets.nat.core open import equality.core open import equality.calculus open import equality.reasoning open import function.fibration open import function.overloading open import function.extensionality.core open import function.extensionality.proof open import function.isomorphism.core open import function.isomorphism.coherent open import function.isomorphism.lift open import function.isomorphism.utils open import hott.equivalence.core open import hott.equivalence.alternative open import hott.level.core open import sets.unit iso-adjunction : ∀ {i j}{X : Set i}{Y : Set j} → (isom : X ≅ Y)(x : X)(y : Y) → (apply isom x ≡ y) ≅ (x ≡ invert isom y) iso-adjunction {i}{j}{X}{Y} isom x y = family-eq-iso total' (λ { (y , x) q → comm' x y q }) (y , x) where open _≅_ isom open ≅-Reasoning to-we : weak-equiv to to-we = proj₂ (≅⇒≈ isom) total' : (Σ (Y × X) λ { (y , x) → to x ≡ y }) ≅ (Σ (Y × X) λ { (y , x) → x ≡ from y}) total' = Σ-assoc-iso ·≅ ( Σ-ap-iso refl≅ λ y → contr-⊤-iso (to-we y) ·≅ sym≅ (contr-⊤-iso (singl-contr' (from y))) ) ·≅ sym≅ Σ-assoc-iso comm' : (x : X)(y : Y)(p : to x ≡ y) → proj₁ (apply total' ((y , x) , p)) ≡ (y , x) comm' x y q = ap (_,_ y) (sym (ap from q) · iso₁ x) iso≡ : ∀ {i j}{X : Set i}{Y : Set j} → (isom : X ≅ Y) → {x x' : X} → (x ≡ x') ≅ (apply isom x ≡ apply isom x') iso≡ isom {x}{x'} = trans≡-iso (_≅_.iso₁ isom x) ·≅ iso-adjunction (sym≅ isom) _ _ abstract subtype-eq : ∀ {i j k}{A : Set i}{P : A → Set j} → ((x : A) → h 1 (P x)) → {X : Set k} → (isom : X ≅ Σ A P) → {x y : X} → (proj₁ (apply isom x) ≡ proj₁ (apply isom y)) → x ≡ y subtype-eq hP isom p = iso⇒inj isom (unapΣ (p , h1⇒prop (hP _) _ _))
{ "alphanum_fraction": 0.5446032528, "avg_line_length": 31.2153846154, "ext": "agda", "hexsha": "55f09eeac338563447e93ee19a217772a49a85ee", "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": "function/isomorphism/properties.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": "function/isomorphism/properties.agda", "max_line_length": 64, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "function/isomorphism/properties.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": 731, "size": 2029 }
module Text.Greek.SBLGNT.Phlm where open import Data.List open import Text.Greek.Bible open import Text.Greek.Script open import Text.Greek.Script.Unicode ΠΡΟΣ-ΦΙΛΗΜΟΝΑ : List (Word) ΠΡΟΣ-ΦΙΛΗΜΟΝΑ = word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Phlm.1.1" ∷ word (δ ∷ έ ∷ σ ∷ μ ∷ ι ∷ ο ∷ ς ∷ []) "Phlm.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phlm.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.1" ∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ς ∷ []) "Phlm.1.1" ∷ word (ὁ ∷ []) "Phlm.1.1" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ὸ ∷ ς ∷ []) "Phlm.1.1" ∷ word (Φ ∷ ι ∷ ∙λ ∷ ή ∷ μ ∷ ο ∷ ν ∷ ι ∷ []) "Phlm.1.1" ∷ word (τ ∷ ῷ ∷ []) "Phlm.1.1" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ῷ ∷ []) "Phlm.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.1" ∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ῷ ∷ []) "Phlm.1.1" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phlm.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.2" ∷ word (Ἀ ∷ π ∷ φ ∷ ί ∷ ᾳ ∷ []) "Phlm.1.2" ∷ word (τ ∷ ῇ ∷ []) "Phlm.1.2" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ῇ ∷ []) "Phlm.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.2" ∷ word (Ἀ ∷ ρ ∷ χ ∷ ί ∷ π ∷ π ∷ ῳ ∷ []) "Phlm.1.2" ∷ word (τ ∷ ῷ ∷ []) "Phlm.1.2" ∷ word (σ ∷ υ ∷ σ ∷ τ ∷ ρ ∷ α ∷ τ ∷ ι ∷ ώ ∷ τ ∷ ῃ ∷ []) "Phlm.1.2" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phlm.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.2" ∷ word (τ ∷ ῇ ∷ []) "Phlm.1.2" ∷ word (κ ∷ α ∷ τ ∷ []) "Phlm.1.2" ∷ word (ο ∷ ἶ ∷ κ ∷ ό ∷ ν ∷ []) "Phlm.1.2" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.2" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "Phlm.1.2" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "Phlm.1.3" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phlm.1.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.3" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "Phlm.1.3" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Phlm.1.3" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phlm.1.3" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phlm.1.3" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phlm.1.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.3" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Phlm.1.3" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phlm.1.3" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.3" ∷ word (Ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῶ ∷ []) "Phlm.1.4" ∷ word (τ ∷ ῷ ∷ []) "Phlm.1.4" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Phlm.1.4" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phlm.1.4" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "Phlm.1.4" ∷ word (μ ∷ ν ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "Phlm.1.4" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.4" ∷ word (π ∷ ο ∷ ι ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phlm.1.4" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "Phlm.1.4" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phlm.1.4" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ῶ ∷ ν ∷ []) "Phlm.1.4" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phlm.1.4" ∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ω ∷ ν ∷ []) "Phlm.1.5" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.5" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phlm.1.5" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "Phlm.1.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.5" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phlm.1.5" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Phlm.1.5" ∷ word (ἣ ∷ ν ∷ []) "Phlm.1.5" ∷ word (ἔ ∷ χ ∷ ε ∷ ι ∷ ς ∷ []) "Phlm.1.5" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phlm.1.5" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phlm.1.5" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "Phlm.1.5" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ []) "Phlm.1.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.5" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phlm.1.5" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Phlm.1.5" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phlm.1.5" ∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ υ ∷ ς ∷ []) "Phlm.1.5" ∷ word (ὅ ∷ π ∷ ω ∷ ς ∷ []) "Phlm.1.6" ∷ word (ἡ ∷ []) "Phlm.1.6" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ί ∷ α ∷ []) "Phlm.1.6" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phlm.1.6" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ώ ∷ ς ∷ []) "Phlm.1.6" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.6" ∷ word (ἐ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ὴ ∷ ς ∷ []) "Phlm.1.6" ∷ word (γ ∷ έ ∷ ν ∷ η ∷ τ ∷ α ∷ ι ∷ []) "Phlm.1.6" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.6" ∷ word (ἐ ∷ π ∷ ι ∷ γ ∷ ν ∷ ώ ∷ σ ∷ ε ∷ ι ∷ []) "Phlm.1.6" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "Phlm.1.6" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ο ∷ ῦ ∷ []) "Phlm.1.6" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.6" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.6" ∷ word (ἡ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phlm.1.6" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phlm.1.6" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ό ∷ ν ∷ []) "Phlm.1.6" ∷ word (χ ∷ α ∷ ρ ∷ ὰ ∷ ν ∷ []) "Phlm.1.7" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phlm.1.7" ∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "Phlm.1.7" ∷ word (ἔ ∷ σ ∷ χ ∷ ο ∷ ν ∷ []) "Phlm.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.7" ∷ word (π ∷ α ∷ ρ ∷ ά ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "Phlm.1.7" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "Phlm.1.7" ∷ word (τ ∷ ῇ ∷ []) "Phlm.1.7" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "Phlm.1.7" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.7" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phlm.1.7" ∷ word (τ ∷ ὰ ∷ []) "Phlm.1.7" ∷ word (σ ∷ π ∷ ∙λ ∷ ά ∷ γ ∷ χ ∷ ν ∷ α ∷ []) "Phlm.1.7" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phlm.1.7" ∷ word (ἁ ∷ γ ∷ ί ∷ ω ∷ ν ∷ []) "Phlm.1.7" ∷ word (ἀ ∷ ν ∷ α ∷ π ∷ έ ∷ π ∷ α ∷ υ ∷ τ ∷ α ∷ ι ∷ []) "Phlm.1.7" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phlm.1.7" ∷ word (σ ∷ ο ∷ ῦ ∷ []) "Phlm.1.7" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ έ ∷ []) "Phlm.1.7" ∷ word (Δ ∷ ι ∷ ό ∷ []) "Phlm.1.8" ∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "Phlm.1.8" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.8" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phlm.1.8" ∷ word (π ∷ α ∷ ρ ∷ ρ ∷ η ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "Phlm.1.8" ∷ word (ἔ ∷ χ ∷ ω ∷ ν ∷ []) "Phlm.1.8" ∷ word (ἐ ∷ π ∷ ι ∷ τ ∷ ά ∷ σ ∷ σ ∷ ε ∷ ι ∷ ν ∷ []) "Phlm.1.8" ∷ word (σ ∷ ο ∷ ι ∷ []) "Phlm.1.8" ∷ word (τ ∷ ὸ ∷ []) "Phlm.1.8" ∷ word (ἀ ∷ ν ∷ ῆ ∷ κ ∷ ο ∷ ν ∷ []) "Phlm.1.8" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phlm.1.9" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phlm.1.9" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "Phlm.1.9" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phlm.1.9" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ῶ ∷ []) "Phlm.1.9" ∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ ς ∷ []) "Phlm.1.9" ∷ word (ὢ ∷ ν ∷ []) "Phlm.1.9" ∷ word (ὡ ∷ ς ∷ []) "Phlm.1.9" ∷ word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Phlm.1.9" ∷ word (π ∷ ρ ∷ ε ∷ σ ∷ β ∷ ύ ∷ τ ∷ η ∷ ς ∷ []) "Phlm.1.9" ∷ word (ν ∷ υ ∷ ν ∷ ὶ ∷ []) "Phlm.1.9" ∷ word (δ ∷ ὲ ∷ []) "Phlm.1.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.9" ∷ word (δ ∷ έ ∷ σ ∷ μ ∷ ι ∷ ο ∷ ς ∷ []) "Phlm.1.9" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.9" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phlm.1.9" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ῶ ∷ []) "Phlm.1.10" ∷ word (σ ∷ ε ∷ []) "Phlm.1.10" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Phlm.1.10" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.10" ∷ word (ἐ ∷ μ ∷ ο ∷ ῦ ∷ []) "Phlm.1.10" ∷ word (τ ∷ έ ∷ κ ∷ ν ∷ ο ∷ υ ∷ []) "Phlm.1.10" ∷ word (ὃ ∷ ν ∷ []) "Phlm.1.10" ∷ word (ἐ ∷ γ ∷ έ ∷ ν ∷ ν ∷ η ∷ σ ∷ α ∷ []) "Phlm.1.10" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.10" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phlm.1.10" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phlm.1.10" ∷ word (Ὀ ∷ ν ∷ ή ∷ σ ∷ ι ∷ μ ∷ ο ∷ ν ∷ []) "Phlm.1.10" ∷ word (τ ∷ ό ∷ ν ∷ []) "Phlm.1.11" ∷ word (π ∷ ο ∷ τ ∷ έ ∷ []) "Phlm.1.11" ∷ word (σ ∷ ο ∷ ι ∷ []) "Phlm.1.11" ∷ word (ἄ ∷ χ ∷ ρ ∷ η ∷ σ ∷ τ ∷ ο ∷ ν ∷ []) "Phlm.1.11" ∷ word (ν ∷ υ ∷ ν ∷ ὶ ∷ []) "Phlm.1.11" ∷ word (δ ∷ ὲ ∷ []) "Phlm.1.11" ∷ word (σ ∷ ο ∷ ὶ ∷ []) "Phlm.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.11" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phlm.1.11" ∷ word (ε ∷ ὔ ∷ χ ∷ ρ ∷ η ∷ σ ∷ τ ∷ ο ∷ ν ∷ []) "Phlm.1.11" ∷ word (ὃ ∷ ν ∷ []) "Phlm.1.12" ∷ word (ἀ ∷ ν ∷ έ ∷ π ∷ ε ∷ μ ∷ ψ ∷ ά ∷ []) "Phlm.1.12" ∷ word (σ ∷ ο ∷ ι ∷ []) "Phlm.1.12" ∷ word (α ∷ ὐ ∷ τ ∷ ό ∷ ν ∷ []) "Phlm.1.12" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ []) "Phlm.1.12" ∷ word (ἔ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Phlm.1.12" ∷ word (τ ∷ ὰ ∷ []) "Phlm.1.12" ∷ word (ἐ ∷ μ ∷ ὰ ∷ []) "Phlm.1.12" ∷ word (σ ∷ π ∷ ∙λ ∷ ά ∷ γ ∷ χ ∷ ν ∷ α ∷ []) "Phlm.1.12" ∷ word (ὃ ∷ ν ∷ []) "Phlm.1.13" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Phlm.1.13" ∷ word (ἐ ∷ β ∷ ο ∷ υ ∷ ∙λ ∷ ό ∷ μ ∷ η ∷ ν ∷ []) "Phlm.1.13" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phlm.1.13" ∷ word (ἐ ∷ μ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phlm.1.13" ∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ε ∷ ι ∷ ν ∷ []) "Phlm.1.13" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phlm.1.13" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phlm.1.13" ∷ word (σ ∷ ο ∷ ῦ ∷ []) "Phlm.1.13" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phlm.1.13" ∷ word (δ ∷ ι ∷ α ∷ κ ∷ ο ∷ ν ∷ ῇ ∷ []) "Phlm.1.13" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.13" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phlm.1.13" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phlm.1.13" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.13" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "Phlm.1.13" ∷ word (χ ∷ ω ∷ ρ ∷ ὶ ∷ ς ∷ []) "Phlm.1.14" ∷ word (δ ∷ ὲ ∷ []) "Phlm.1.14" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phlm.1.14" ∷ word (σ ∷ ῆ ∷ ς ∷ []) "Phlm.1.14" ∷ word (γ ∷ ν ∷ ώ ∷ μ ∷ η ∷ ς ∷ []) "Phlm.1.14" ∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ ν ∷ []) "Phlm.1.14" ∷ word (ἠ ∷ θ ∷ έ ∷ ∙λ ∷ η ∷ σ ∷ α ∷ []) "Phlm.1.14" ∷ word (π ∷ ο ∷ ι ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "Phlm.1.14" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phlm.1.14" ∷ word (μ ∷ ὴ ∷ []) "Phlm.1.14" ∷ word (ὡ ∷ ς ∷ []) "Phlm.1.14" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phlm.1.14" ∷ word (ἀ ∷ ν ∷ ά ∷ γ ∷ κ ∷ η ∷ ν ∷ []) "Phlm.1.14" ∷ word (τ ∷ ὸ ∷ []) "Phlm.1.14" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ό ∷ ν ∷ []) "Phlm.1.14" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.14" ∷ word (ᾖ ∷ []) "Phlm.1.14" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phlm.1.14" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phlm.1.14" ∷ word (ἑ ∷ κ ∷ ο ∷ ύ ∷ σ ∷ ι ∷ ο ∷ ν ∷ []) "Phlm.1.14" ∷ word (τ ∷ ά ∷ χ ∷ α ∷ []) "Phlm.1.15" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phlm.1.15" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phlm.1.15" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phlm.1.15" ∷ word (ἐ ∷ χ ∷ ω ∷ ρ ∷ ί ∷ σ ∷ θ ∷ η ∷ []) "Phlm.1.15" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phlm.1.15" ∷ word (ὥ ∷ ρ ∷ α ∷ ν ∷ []) "Phlm.1.15" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phlm.1.15" ∷ word (α ∷ ἰ ∷ ώ ∷ ν ∷ ι ∷ ο ∷ ν ∷ []) "Phlm.1.15" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phlm.1.15" ∷ word (ἀ ∷ π ∷ έ ∷ χ ∷ ῃ ∷ ς ∷ []) "Phlm.1.15" ∷ word (ο ∷ ὐ ∷ κ ∷ έ ∷ τ ∷ ι ∷ []) "Phlm.1.16" ∷ word (ὡ ∷ ς ∷ []) "Phlm.1.16" ∷ word (δ ∷ ο ∷ ῦ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phlm.1.16" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phlm.1.16" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phlm.1.16" ∷ word (δ ∷ ο ∷ ῦ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phlm.1.16" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ὸ ∷ ν ∷ []) "Phlm.1.16" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ό ∷ ν ∷ []) "Phlm.1.16" ∷ word (μ ∷ ά ∷ ∙λ ∷ ι ∷ σ ∷ τ ∷ α ∷ []) "Phlm.1.16" ∷ word (ἐ ∷ μ ∷ ο ∷ ί ∷ []) "Phlm.1.16" ∷ word (π ∷ ό ∷ σ ∷ ῳ ∷ []) "Phlm.1.16" ∷ word (δ ∷ ὲ ∷ []) "Phlm.1.16" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phlm.1.16" ∷ word (σ ∷ ο ∷ ὶ ∷ []) "Phlm.1.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.16" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.16" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ὶ ∷ []) "Phlm.1.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.16" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.16" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phlm.1.16" ∷ word (Ε ∷ ἰ ∷ []) "Phlm.1.17" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "Phlm.1.17" ∷ word (μ ∷ ε ∷ []) "Phlm.1.17" ∷ word (ἔ ∷ χ ∷ ε ∷ ι ∷ ς ∷ []) "Phlm.1.17" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ό ∷ ν ∷ []) "Phlm.1.17" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ∙λ ∷ α ∷ β ∷ ο ∷ ῦ ∷ []) "Phlm.1.17" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phlm.1.17" ∷ word (ὡ ∷ ς ∷ []) "Phlm.1.17" ∷ word (ἐ ∷ μ ∷ έ ∷ []) "Phlm.1.17" ∷ word (ε ∷ ἰ ∷ []) "Phlm.1.18" ∷ word (δ ∷ έ ∷ []) "Phlm.1.18" ∷ word (τ ∷ ι ∷ []) "Phlm.1.18" ∷ word (ἠ ∷ δ ∷ ί ∷ κ ∷ η ∷ σ ∷ έ ∷ ν ∷ []) "Phlm.1.18" ∷ word (σ ∷ ε ∷ []) "Phlm.1.18" ∷ word (ἢ ∷ []) "Phlm.1.18" ∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ε ∷ ι ∷ []) "Phlm.1.18" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phlm.1.18" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phlm.1.18" ∷ word (ἐ ∷ ∙λ ∷ ∙λ ∷ ό ∷ γ ∷ α ∷ []) "Phlm.1.18" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Phlm.1.19" ∷ word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Phlm.1.19" ∷ word (ἔ ∷ γ ∷ ρ ∷ α ∷ ψ ∷ α ∷ []) "Phlm.1.19" ∷ word (τ ∷ ῇ ∷ []) "Phlm.1.19" ∷ word (ἐ ∷ μ ∷ ῇ ∷ []) "Phlm.1.19" ∷ word (χ ∷ ε ∷ ι ∷ ρ ∷ ί ∷ []) "Phlm.1.19" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Phlm.1.19" ∷ word (ἀ ∷ π ∷ ο ∷ τ ∷ ί ∷ σ ∷ ω ∷ []) "Phlm.1.19" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phlm.1.19" ∷ word (μ ∷ ὴ ∷ []) "Phlm.1.19" ∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ []) "Phlm.1.19" ∷ word (σ ∷ ο ∷ ι ∷ []) "Phlm.1.19" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phlm.1.19" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.19" ∷ word (σ ∷ ε ∷ α ∷ υ ∷ τ ∷ ό ∷ ν ∷ []) "Phlm.1.19" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phlm.1.19" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ο ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ε ∷ ι ∷ ς ∷ []) "Phlm.1.19" ∷ word (ν ∷ α ∷ ί ∷ []) "Phlm.1.20" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ έ ∷ []) "Phlm.1.20" ∷ word (ἐ ∷ γ ∷ ώ ∷ []) "Phlm.1.20" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.20" ∷ word (ὀ ∷ ν ∷ α ∷ ί ∷ μ ∷ η ∷ ν ∷ []) "Phlm.1.20" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.20" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phlm.1.20" ∷ word (ἀ ∷ ν ∷ ά ∷ π ∷ α ∷ υ ∷ σ ∷ ό ∷ ν ∷ []) "Phlm.1.20" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phlm.1.20" ∷ word (τ ∷ ὰ ∷ []) "Phlm.1.20" ∷ word (σ ∷ π ∷ ∙λ ∷ ά ∷ γ ∷ χ ∷ ν ∷ α ∷ []) "Phlm.1.20" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.20" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phlm.1.20" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ι ∷ θ ∷ ὼ ∷ ς ∷ []) "Phlm.1.21" ∷ word (τ ∷ ῇ ∷ []) "Phlm.1.21" ∷ word (ὑ ∷ π ∷ α ∷ κ ∷ ο ∷ ῇ ∷ []) "Phlm.1.21" ∷ word (σ ∷ ο ∷ υ ∷ []) "Phlm.1.21" ∷ word (ἔ ∷ γ ∷ ρ ∷ α ∷ ψ ∷ ά ∷ []) "Phlm.1.21" ∷ word (σ ∷ ο ∷ ι ∷ []) "Phlm.1.21" ∷ word (ε ∷ ἰ ∷ δ ∷ ὼ ∷ ς ∷ []) "Phlm.1.21" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phlm.1.21" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.21" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phlm.1.21" ∷ word (ἃ ∷ []) "Phlm.1.21" ∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ []) "Phlm.1.21" ∷ word (π ∷ ο ∷ ι ∷ ή ∷ σ ∷ ε ∷ ι ∷ ς ∷ []) "Phlm.1.21" ∷ word (ἅ ∷ μ ∷ α ∷ []) "Phlm.1.22" ∷ word (δ ∷ ὲ ∷ []) "Phlm.1.22" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phlm.1.22" ∷ word (ἑ ∷ τ ∷ ο ∷ ί ∷ μ ∷ α ∷ ζ ∷ έ ∷ []) "Phlm.1.22" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phlm.1.22" ∷ word (ξ ∷ ε ∷ ν ∷ ί ∷ α ∷ ν ∷ []) "Phlm.1.22" ∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ ζ ∷ ω ∷ []) "Phlm.1.22" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phlm.1.22" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phlm.1.22" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phlm.1.22" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phlm.1.22" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ῶ ∷ ν ∷ []) "Phlm.1.22" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phlm.1.22" ∷ word (χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ θ ∷ ή ∷ σ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phlm.1.22" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phlm.1.22" ∷ word (Ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ε ∷ τ ∷ α ∷ ί ∷ []) "Phlm.1.23" ∷ word (σ ∷ ε ∷ []) "Phlm.1.23" ∷ word (Ἐ ∷ π ∷ α ∷ φ ∷ ρ ∷ ᾶ ∷ ς ∷ []) "Phlm.1.23" ∷ word (ὁ ∷ []) "Phlm.1.23" ∷ word (σ ∷ υ ∷ ν ∷ α ∷ ι ∷ χ ∷ μ ∷ ά ∷ ∙λ ∷ ω ∷ τ ∷ ό ∷ ς ∷ []) "Phlm.1.23" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phlm.1.23" ∷ word (ἐ ∷ ν ∷ []) "Phlm.1.23" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phlm.1.23" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phlm.1.23" ∷ word (Μ ∷ ᾶ ∷ ρ ∷ κ ∷ ο ∷ ς ∷ []) "Phlm.1.24" ∷ word (Ἀ ∷ ρ ∷ ί ∷ σ ∷ τ ∷ α ∷ ρ ∷ χ ∷ ο ∷ ς ∷ []) "Phlm.1.24" ∷ word (Δ ∷ η ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phlm.1.24" ∷ word (Λ ∷ ο ∷ υ ∷ κ ∷ ᾶ ∷ ς ∷ []) "Phlm.1.24" ∷ word (ο ∷ ἱ ∷ []) "Phlm.1.24" ∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ο ∷ ί ∷ []) "Phlm.1.24" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phlm.1.24" ∷ word (Ἡ ∷ []) "Phlm.1.25" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "Phlm.1.25" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.25" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Phlm.1.25" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phlm.1.25" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.25" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Phlm.1.25" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phlm.1.25" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "Phlm.1.25" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phlm.1.25" ∷ []
{ "alphanum_fraction": 0.3498205026, "avg_line_length": 43.6, "ext": "agda", "hexsha": "0f714808a30d4b5efe17a705bf576d7aa6ea922a", "lang": "Agda", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z", "max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "scott-fleischman/GreekGrammar", "max_forks_repo_path": "agda/Text/Greek/SBLGNT/Phlm.agda", "max_issues_count": 13, "max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "scott-fleischman/GreekGrammar", "max_issues_repo_path": "agda/Text/Greek/SBLGNT/Phlm.agda", "max_line_length": 78, "max_stars_count": 44, "max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "scott-fleischman/GreekGrammar", "max_stars_repo_path": "agda/Text/Greek/SBLGNT/Phlm.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z", "num_tokens": 10684, "size": 15042 }
-- {-# OPTIONS -v tc.cover:20 #-} -- Andreas, 2017-01-18, issue #2407 -- If underscores are not preserved (issue #819), -- the case split fails due to size constraints. open import Common.Size data D (i : Size) : (j : Size< ↑ i) → Set where c : ∀ (j : Size< ↑ i) (k : Size< ↑ j) → D i j → D j k → D i k split-u : ∀ i (j : Size< ↑ i) → D i j → Set split-u _ _ x = {!x!} -- split on x -- Expected: splitting on x succeeds with -- split-u _ _ (c j k x x₁) = {!!}
{ "alphanum_fraction": 0.5334685598, "avg_line_length": 22.4090909091, "ext": "agda", "hexsha": "4ac1ed730d146597a317cf36a8623d32aa129b8e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue2407-u.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue2407-u.agda", "max_line_length": 49, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2407-u.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": 173, "size": 493 }
open import Level.NP open import Type open import Relation.Binary.Logical open import Relation.Binary.PropositionalEquality module Explore.Universe.Logical (X : ★) where open import Explore.Universe.Type open import Explore.Universe X open import Explore.Core module From⟦X⟧ (⟦X⟧ : ⟦★₀⟧ X X) where -- TODO _⟦≃⟧_ : (⟦Rel⟧ ⟦★₀⟧) ₀ _≃_ _≃_ data ⟦U⟧ : ⟦★₁⟧ U U ⟦El⟧ : (⟦U⟧ ⟦→⟧ ⟦★₀⟧) El El data ⟦U⟧ where ⟦𝟘ᵁ⟧ : ⟦U⟧ 𝟘ᵁ 𝟘ᵁ ⟦𝟙ᵁ⟧ : ⟦U⟧ 𝟙ᵁ 𝟙ᵁ ⟦𝟚ᵁ⟧ : ⟦U⟧ 𝟚ᵁ 𝟚ᵁ _⟦×ᵁ⟧_ : ⟦Op₂⟧ {_} {_} {₁} ⟦U⟧ _×ᵁ_ _×ᵁ_ _⟦⊎ᵁ⟧_ : ⟦Op₂⟧ {_} {_} {₁} ⟦U⟧ _⊎ᵁ_ _⊎ᵁ_ ⟦Σᵁ⟧ : (⟨ u ∶ ⟦U⟧ ⟩⟦→⟧ (⟦El⟧ u ⟦→⟧ ⟦U⟧) ⟦→⟧ ⟦U⟧) Σᵁ Σᵁ ⟦Xᵁ⟧ : ⟦U⟧ Xᵁ Xᵁ -- ⟦≃ᵁ⟧ : (⟨ u ∶ ⟦U⟧ ⟩⟦→⟧ (⟨ A ∶ ⟦★₀⟧ ⟩⟦→⟧ ⟦El⟧ u ⟦≃⟧ A ⟦→⟧ ⟦U⟧)) ≃ᵁ ≃ᵁ ⟦El⟧ ⟦𝟘ᵁ⟧ = _≡_ ⟦El⟧ ⟦𝟙ᵁ⟧ = _≡_ ⟦El⟧ ⟦𝟚ᵁ⟧ = _≡_ ⟦El⟧ (u₀ ⟦×ᵁ⟧ u₁) = ⟦El⟧ u₀ ⟦×⟧ ⟦El⟧ u₁ ⟦El⟧ (u₀ ⟦⊎ᵁ⟧ u₁) = ⟦El⟧ u₀ ⟦⊎⟧ ⟦El⟧ u₁ ⟦El⟧ (⟦Σᵁ⟧ u f) = ⟦Σ⟧ (⟦El⟧ u) λ x → ⟦El⟧ (f x) ⟦El⟧ ⟦Xᵁ⟧ = ⟦X⟧ -- ⟦El⟧ (⟦≃ᵁ⟧ u A e) = A module From⟦Xᵉ⟧ {⟦X⟧ : ⟦★₀⟧ X X} {ℓ₀ ℓ₁} ℓᵣ {Xᵉ : Explore X} (⟦Xᵉ⟧ : ⟦Explore⟧ {ℓ₀} {ℓ₁} ℓᵣ ⟦X⟧ Xᵉ Xᵉ) where open From⟦X⟧ ⟦X⟧ public ⟦explore⟧ : ∀ {u₀ u₁} (u : ⟦U⟧ u₀ u₁) → ⟦Explore⟧ {ℓ₀} {ℓ₁} ℓᵣ (⟦El⟧ u) (explore u₀) (explore u₁) ⟦explore⟧ ⟦𝟘ᵁ⟧ = ⟦𝟘ᵉ⟧ {ℓ₀} {ℓ₁} {ℓᵣ} ⟦explore⟧ ⟦𝟙ᵁ⟧ = ⟦𝟙ᵉ⟧ {ℓ₀} {ℓ₁} {ℓᵣ} {_≡_} {refl} ⟦explore⟧ ⟦𝟚ᵁ⟧ = ⟦𝟚ᵉ⟧ {ℓ₀} {ℓ₁} {ℓᵣ} {_≡_} {refl} {refl} ⟦explore⟧ (u₀ ⟦×ᵁ⟧ u₁) = ⟦explore×⟧ {ℓ₀} {ℓ₁} {ℓᵣ} (⟦explore⟧ u₀) (⟦explore⟧ u₁) ⟦explore⟧ (u₀ ⟦⊎ᵁ⟧ u₁) = ⟦explore⊎⟧ {ℓ₀} {ℓ₁} {ℓᵣ} (⟦explore⟧ u₀) (⟦explore⟧ u₁) ⟦explore⟧ (⟦Σᵁ⟧ u f) = ⟦exploreΣ⟧ {ℓ₀} {ℓ₁} {ℓᵣ} (⟦explore⟧ u) (⟦explore⟧ ∘ f) ⟦explore⟧ ⟦Xᵁ⟧ = ⟦Xᵉ⟧ -- ⟦explore⟧ (⟦≃ᵁ⟧ u A e) = {!⟦explore-iso⟧ e!} {- ⟦U⟧-sound : ∀ {{_ : FunExt}} {x y} → ⟦U⟧ x y → x ≡ y ⟦U⟧-refl : ∀ x → ⟦U⟧ x x {- ⟦El⟧-refl : ∀ x → {!⟦El⟧ x x!} ⟦El⟧-refl = {!!} -} ⟦U⟧-sound ⟦𝟘ᵁ⟧ = refl ⟦U⟧-sound ⟦𝟙ᵁ⟧ = refl ⟦U⟧-sound ⟦𝟚ᵁ⟧ = refl ⟦U⟧-sound (u ⟦×ᵁ⟧ u₁) = ap₂ _×ᵁ_ (⟦U⟧-sound u) (⟦U⟧-sound u₁) ⟦U⟧-sound (u ⟦⊎ᵁ⟧ u₁) = ap₂ _⊎ᵁ_ (⟦U⟧-sound u) (⟦U⟧-sound u₁) ⟦U⟧-sound (⟦Σᵁ⟧ {u₀} {u₁} u {f₀} {f₁} fᵣ) = apd₂ Σᵁ (⟦U⟧-sound u) (tr-→ El (const U) (⟦U⟧-sound u) f₀ ∙ λ= (λ A → ap (λ z → z (f₀ (tr El (! ⟦U⟧-sound u) A))) (tr-const (⟦U⟧-sound u)) ∙ ⟦U⟧-sound (fᵣ {!!}))) -- (λ= (λ y → let foo = xᵣ {{!!}} {y} {!xᵣ!} in {!tr-→ El (const U) (⟦U⟧-sound u)!})) ⟦U⟧-refl 𝟘ᵁ = ⟦𝟘ᵁ⟧ ⟦U⟧-refl 𝟙ᵁ = ⟦𝟙ᵁ⟧ ⟦U⟧-refl 𝟚ᵁ = ⟦𝟚ᵁ⟧ ⟦U⟧-refl (x ×ᵁ x₁) = ⟦U⟧-refl x ⟦×ᵁ⟧ ⟦U⟧-refl x₁ ⟦U⟧-refl (x ⊎ᵁ x₁) = ⟦U⟧-refl x ⟦⊎ᵁ⟧ ⟦U⟧-refl x₁ ⟦U⟧-refl (Σᵁ x f) = ⟦Σᵁ⟧ (⟦U⟧-refl x) (λ y → {!⟦U⟧-refl ?!}) -}
{ "alphanum_fraction": 0.4454265949, "avg_line_length": 32.9367088608, "ext": "agda", "hexsha": "31670ca7b32664780b6dcdc87c801330413c1b95", "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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "experiments/Explore/Universe/Logical.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "experiments/Explore/Universe/Logical.agda", "max_line_length": 292, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "experiments/Explore/Universe/Logical.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 2063, "size": 2602 }
module Ord where data Nat : Set where Z : Nat S : Nat -> Nat data Ord : Set where z : Ord lim : (Nat -> Ord) -> Ord zp : Ord -> Ord zp z = z zp (lim f) = lim (\x -> zp (f x))
{ "alphanum_fraction": 0.5105263158, "avg_line_length": 11.875, "ext": "agda", "hexsha": "db67c85c0e9d73db8f06947d96ef1f45bad9b7d2", "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/Termination/Ord.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/Termination/Ord.agda", "max_line_length": 33, "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/Termination/Ord.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": 73, "size": 190 }
-- 2018-11-02, Jesper: -- Problem reported by Martin Escardo -- Example by Guillaume Brunerie -- C-c C-s was generating postfix projections -- even with --postfix-projections disabled. open import Agda.Builtin.Equality record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B open _×_ postulate A B : Set p : A × B eta : p ≡ ({!!} , snd p) eta = refl -- C-c C-s should fill the hole with 'fst p'.
{ "alphanum_fraction": 0.6497695853, "avg_line_length": 18.0833333333, "ext": "agda", "hexsha": "dd26612061219df1631de154ace3eb64fb6769dc", "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/Issue3356.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/Issue3356.agda", "max_line_length": 45, "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/Issue3356.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": 138, "size": 434 }
module Lib.IO where open import Lib.List open import Lib.Prelude {-# IMPORT System.Environment #-} FilePath = String postulate IO : Set -> Set getLine : IO String putStrLn : String -> IO Unit putStr : String -> IO Unit bindIO : {A B : Set} -> IO A -> (A -> IO B) -> IO B returnIO : {A : Set} -> A -> IO A getArgs : IO (List String) readFile : FilePath -> IO String writeFile : FilePath -> String -> IO Unit {-# BUILTIN IO IO #-} {-# COMPILED_TYPE IO IO #-} {-# COMPILED putStr putStr #-} {-# COMPILED putStrLn putStrLn #-} {-# COMPILED bindIO (\_ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-} {-# COMPILED returnIO (\_ -> return :: a -> IO a) #-} -- we need to throw away the type argument to return and bind -- and resolve the overloading explicitly (since Alonzo -- output is sprinkled with unsafeCoerce#). {-# COMPILED getLine getLine #-} {-# COMPILED getArgs System.Environment.getArgs #-} {-# COMPILED readFile readFile #-} {-# COMPILED writeFile writeFile #-} mapM : {A B : Set} -> (A -> IO B) -> List A -> IO (List B) mapM f [] = returnIO [] mapM f (x :: xs) = bindIO (f x) \y -> bindIO (mapM f xs) \ys -> returnIO (y :: ys) mapM₋ : {A : Set} -> (A -> IO Unit) -> List A -> IO Unit mapM₋ f xs = bindIO (mapM f xs) \_ -> returnIO unit
{ "alphanum_fraction": 0.5945945946, "avg_line_length": 30.1162790698, "ext": "agda", "hexsha": "605bbbcef32cf03f3815ae4a7082e0102455ede8", "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": "examples/simple-lib/Lib/IO.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": "examples/simple-lib/Lib/IO.agda", "max_line_length": 82, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "examples/simple-lib/Lib/IO.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 400, "size": 1295 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Nat where -- Skeleton of FinSetoid as a Category open import Level open import Data.Fin.Base using (Fin; inject+; raise; splitAt; join) open import Data.Fin.Properties open import Data.Nat.Base using (ℕ; _+_) open import Data.Sum using (inj₁; inj₂; [_,_]′) open import Data.Sum.Properties open import Relation.Binary.PropositionalEquality using (_≗_; _≡_; refl; sym; trans; cong; module ≡-Reasoning; inspect; [_]) open import Function using (id; _∘′_) open import Categories.Category.Cartesian.Bundle using (CartesianCategory) open import Categories.Category.Cocartesian using (Cocartesian) open import Categories.Category.Cocartesian.Bundle using (CocartesianCategory) open import Categories.Category.Core using (Category) open import Categories.Category.Duality using (Cocartesian⇒coCartesian) open import Categories.Object.Coproduct open import Categories.Object.Duality using (Coproduct⇒coProduct) open import Categories.Object.Product Nat : Category 0ℓ 0ℓ 0ℓ Nat = record { Obj = ℕ ; _⇒_ = λ m n → (Fin m → Fin n) ; _≈_ = _≗_ ; id = id ; _∘_ = _∘′_ ; assoc = λ _ → refl ; sym-assoc = λ _ → refl ; identityˡ = λ _ → refl ; identityʳ = λ _ → refl ; identity² = λ _ → refl ; equiv = record { refl = λ _ → refl ; sym = λ x≡y z → sym (x≡y z) ; trans = λ x≡y y≡z w → trans (x≡y w) (y≡z w) } ; ∘-resp-≈ = λ {_ _ _ f h g i} f≗h g≗i x → trans (f≗h (g x)) (cong h (g≗i x)) } -- For other uses, it is important to choose coproducts -- in theory, it should be strictly associative... but it's not, and won't be for any choice. Coprod : (m n : ℕ) → Coproduct Nat m n Coprod m n = record { A+B = m + n ; i₁ = inject+ n ; i₂ = raise m ; [_,_] = λ l r z → [ l , r ]′ (splitAt m z) ; inject₁ = λ {_ f g} x → cong [ f , g ]′ (splitAt-inject+ m n x) ; inject₂ = λ {_ f g} x → cong [ f , g ]′ (splitAt-raise m n x) ; unique = uniq } where open ≡-Reasoning uniq : {o : ℕ} {h : Fin (m + n) → Fin o} {f : Fin m → Fin o} {g : Fin n → Fin o} → h ∘′ inject+ n ≗ f → h ∘′ raise m ≗ g → (λ z → [ f , g ]′ (splitAt m z)) ≗ h uniq {_} {h} {f} {g} h≗f h≗g w = begin [ f , g ]′ (splitAt m w) ≡⟨ [,]-cong (λ x → sym (h≗f x)) (λ x → sym (h≗g x)) (splitAt m w) ⟩ [ h ∘′ inject+ n , h ∘′ raise m ]′ (splitAt m w) ≡˘⟨ [,]-∘-distr h (splitAt m w) ⟩ h ([ inject+ n , raise m ]′ (splitAt m w)) ≡⟨ cong h (join-splitAt m n w) ⟩ h w ∎ Nat-Cocartesian : Cocartesian Nat Nat-Cocartesian = record { initial = record { ⊥ = 0 ; ⊥-is-initial = record { ! = λ () ; !-unique = λ _ () } } ; coproducts = record { coproduct = λ {m} {n} → Coprod m n } } -- And Natop is what is used a lot, so record some things here too Natop : Category 0ℓ 0ℓ 0ℓ Natop = Category.op Nat Natop-Product : (m n : ℕ) → Product Natop m n Natop-Product m n = Coproduct⇒coProduct Nat (Coprod m n) Natop-Cartesian : CartesianCategory 0ℓ 0ℓ 0ℓ Natop-Cartesian = record { U = Natop ; cartesian = Cocartesian⇒coCartesian Nat Nat-Cocartesian }
{ "alphanum_fraction": 0.6, "avg_line_length": 34.4565217391, "ext": "agda", "hexsha": "f7e79176c3304514091cba31a8dc7bf7995da620", "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/Instance/Nat.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/Instance/Nat.agda", "max_line_length": 122, "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/Instance/Nat.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": 1163, "size": 3170 }
-- Path induction {-# OPTIONS --without-K --safe #-} module Experiment.PropositionalEq where open import Level renaming (zero to lzero; suc to lsuc) open import Relation.Binary.PropositionalEquality import Relation.Binary.Reasoning.Setoid as SetoidReasoning open import Relation.Binary private variable a c : Level A : Set a -- HoTT 1.12.1 -- Path induction PathInd : (C : (x y : A) → x ≡ y → Set c) → (∀ x → C x x refl) → ∀ x y (p : x ≡ y) → C x y p PathInd C c x .x refl = c x PathInd-refl : ∀ (C : (x y : A) → x ≡ y → Set c) (c : ∀ x → C x x refl) x → PathInd C c x x refl ≡ c x PathInd-refl C c x = refl -- Based path induction BasedPathInd : (a : A) (C : ∀ x → a ≡ x → Set c) → C a refl → ∀ x (p : a ≡ x) → C x p BasedPathInd a C c .a refl = c BasedPathInd-refl : ∀ (a : A) (C : ∀ x → a ≡ x → Set c) (c : C a refl) → BasedPathInd a C c a refl ≡ c BasedPathInd-refl _ _ _ = refl
{ "alphanum_fraction": 0.570239334, "avg_line_length": 27.4571428571, "ext": "agda", "hexsha": "a90df4170d02abe779522aca8b7634d003c8ef98", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Experiment/PropositionalEq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Experiment/PropositionalEq.agda", "max_line_length": 75, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Experiment/PropositionalEq.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 339, "size": 961 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Characters ------------------------------------------------------------------------ module Data.Char where open import Data.Nat using (ℕ) import Data.Nat.Properties as NatProp open import Data.Bool using (Bool; true; false) open import Relation.Nullary open import Relation.Nullary.Decidable open import Relation.Binary import Relation.Binary.On as On open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) open import Relation.Binary.PropositionalEquality.TrustMe open import Data.String.Core using (String; primShowChar) import Data.Char.Core as Core open Core public using (Char) open Core show : Char → String show = primShowChar toNat : Char → ℕ toNat = primCharToNat -- Informative equality test. _≟_ : Decidable {A = Char} _≡_ s₁ ≟ s₂ with primCharEquality s₁ s₂ ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ -- Boolean equality test. -- -- Why is the definition _==_ = primCharEquality not used? One reason -- is that the present definition can sometimes improve type -- inference, at least with the version of Agda that is current at the -- time of writing: see unit-test below. infix 4 _==_ _==_ : Char → Char → Bool c₁ == c₂ = ⌊ c₁ ≟ c₂ ⌋ private -- The following unit test does not type-check (at the time of -- writing) if _==_ is replaced by primCharEquality. data P : (Char → Bool) → Set where p : (c : Char) → P (_==_ c) unit-test : P (_==_ 'x') unit-test = p _ setoid : Setoid _ _ setoid = PropEq.setoid Char decSetoid : DecSetoid _ _ decSetoid = PropEq.decSetoid _≟_ -- An ordering induced by the toNat function. strictTotalOrder : StrictTotalOrder _ _ _ strictTotalOrder = On.strictTotalOrder NatProp.strictTotalOrder toNat
{ "alphanum_fraction": 0.6733805117, "avg_line_length": 25.8732394366, "ext": "agda", "hexsha": "41e0fcb26896c4ad368e2ae7b6dd18462eee8185", "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/Char.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/Char.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/Char.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": 474, "size": 1837 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for "equational reasoning" in multiple Setoids ------------------------------------------------------------------------ -- Example use: -- -- open import Data.Maybe -- import Relation.Binary.SetoidReasoning as SetR -- -- begin⟨ S ⟩ -- x -- ≈⟨ drop-just (begin⟨ setoid S ⟩ -- just x -- ≈⟨ justx≈mz ⟩ -- mz -- ≈⟨ mz≈justy ⟩ -- just y ∎) ⟩ -- y -- ≈⟨ y≈z ⟩ -- z ∎ open import Relation.Binary.EqReasoning as EqR using (_IsRelatedTo_) open import Relation.Binary open import Relation.Binary.Core open Setoid module Relation.Binary.SetoidReasoning where infix 1 begin⟨_⟩_ infixr 2 _≈⟨_⟩_ _≡⟨_⟩_ infix 2 _∎ begin⟨_⟩_ : ∀ {c l} (S : Setoid c l) → {x y : Carrier S} → _IsRelatedTo_ S x y → _≈_ S x y begin⟨_⟩_ S p = EqR.begin_ S p _∎ : ∀ {c l} {S : Setoid c l} → (x : Carrier S) → _IsRelatedTo_ S x x _∎ {S = S} = EqR._∎ S _≈⟨_⟩_ : ∀ {c l} {S : Setoid c l} → (x : Carrier S) → {y z : Carrier S} → _≈_ S x y → _IsRelatedTo_ S y z → _IsRelatedTo_ S x z _≈⟨_⟩_ {S = S} = EqR._≈⟨_⟩_ S _≡⟨_⟩_ : ∀ {c l} {S : Setoid c l} → (x : Carrier S) → {y z : Carrier S} → x ≡ y → _IsRelatedTo_ S y z → _IsRelatedTo_ S x z _≡⟨_⟩_ {S = S} = EqR._≡⟨_⟩_ S
{ "alphanum_fraction": 0.5014925373, "avg_line_length": 28.5106382979, "ext": "agda", "hexsha": "e3a3c9838a8186f37d663eb2f0395a1a7b078006", "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/SetoidReasoning.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/SetoidReasoning.agda", "max_line_length": 127, "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/SetoidReasoning.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": 524, "size": 1340 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.Pushout open import Homotopy.VanKampen.Guide module Homotopy.VanKampen.Code {i} (d : pushout-diag i) (l : legend i (pushout-diag.C d)) where open pushout-diag d open legend l open import Homotopy.Truncation open import Homotopy.PathTruncation -- Code from A. import Homotopy.VanKampen.SplitCode d l as SC import Homotopy.VanKampen.Code.LemmaPackA d l as C -- Code from B. Code flipped. import Homotopy.VanKampen.SplitCode (pushout-diag-flip d) l as SCF import Homotopy.VanKampen.Code.LemmaPackA (pushout-diag-flip d) l as CF P : Set i P = pushout d module _ where -- Things that can be directly re-exported -- FIXME Ideally, this should be ‵SC'. -- Somehow that doesn′t work. open import Homotopy.VanKampen.SplitCode d l public using () renaming ( code to a-code ; code-a to a-code-a ; code-b to a-code-b ; code-rec to a-code-rec ; code-rec-nondep to a-code-rec-nondep ; code-is-set to a-code-is-set ; code-a-is-set to a-code-a-is-set ; code-b-is-set to a-code-b-is-set ) module _ {a₁ : A} where open import Homotopy.VanKampen.SplitCode d l a₁ public using () renaming ( code-a-refl-refl to a-code-a-refl-refl ; code-b-refl-refl to a-code-b-refl-refl ; code-ab-swap to a-code-ab-swap ; trans-a to trans-a-code-a ; trans-ba to trans-a-code-ba ; trans-ab to trans-a-code-ab ; a⇒b to aa⇒ab ; b⇒a to ab⇒aa ) a-a : ∀ {a₁} {a₂} → a₁ ≡₀ a₂ → a-code-a a₁ a₂ a-a = SC.a _ infixl 6 a-a syntax a-a co = ⟧a co a-ba : ∀ {a₁} {a₂} n → a-code-b a₁ (g $ loc n) → f (loc n) ≡₀ a₂ → a-code-a a₁ a₂ a-ba = SC.ba _ infixl 6 a-ba syntax a-ba n co p = co ab⟦ n ⟧a p a-ab : ∀ {a₁} {b₂} n → a-code-a a₁ (f $ loc n) → g (loc n) ≡₀ b₂ → a-code-b a₁ b₂ a-ab = SC.ab _ infixl 6 a-ab syntax a-ab n co p = co aa⟦ n ⟧b p module _ where -- Things that can be directly re-exported open import Homotopy.VanKampen.SplitCode (pushout-diag-flip d) l public using () renaming ( code-a to b-code-b ; code-b to b-code-a ; code-rec to b-code-rec ; code-rec-nondep to b-code-rec-nondep ; code-a-is-set to b-code-b-is-set ; code-b-is-set to b-code-a-is-set ) b-code : B → P → Set i b-code b = SCF.code b ◯ pushout-flip module _ {b₁ : B} where open import Homotopy.VanKampen.SplitCode (pushout-diag-flip d) l b₁ public using () renaming ( code-a-refl-refl to b-code-b-refl-refl ; code-b-refl-refl to b-code-a-refl-refl ; code-ab-swap to b-code-ba-swap ; trans-a to trans-b-code-b ; trans-ba to trans-b-code-ab ; trans-ab to trans-b-code-ba ; a⇒b to bb⇒ba ; b⇒a to ba⇒bb ) b-b : ∀ {b₁} {b₂} → b₁ ≡₀ b₂ → b-code-b b₁ b₂ b-b = SCF.a _ infixl 6 b-b syntax b-b co = ⟧b co b-ab : ∀ {b₁} {b₂} n → b-code-a b₁ (f $ loc n) → g (loc n) ≡₀ b₂ → b-code-b b₁ b₂ b-ab = SCF.ba _ infixl 6 b-ab syntax b-ab c co p = co ba⟦ c ⟧b p b-ba : ∀ {b₁} {a₂} n → b-code-b b₁ (g $ loc n) → f (loc n) ≡₀ a₂ → b-code-a b₁ a₂ b-ba = SCF.ab _ infixl 6 b-ba syntax b-ba c co p = co bb⟦ c ⟧a p b-code-is-set : ∀ b₁ p₂ → is-set (b-code b₁ p₂) b-code-is-set b₁ = SCF.code-is-set b₁ ◯ pushout-flip -- Tail flipping open import Homotopy.VanKampen.Code.LemmaPackA d l public using () renaming ( aa⇒ba to aa⇒ba ; ab⇒bb to ab⇒bb ; ap⇒bp to ap⇒bp ) open import Homotopy.VanKampen.Code.LemmaPackA (pushout-diag-flip d) l public using () renaming ( aa⇒ba to bb⇒ab ; ab⇒bb to ba⇒aa ) -- Tail drifting open import Homotopy.VanKampen.Code.LemmaPackB d l public using () renaming ( trans-q-code-a to trans-q-a-code-a ; trans-!q-code-a to trans-!q-a-code-a ; trans-q-code-ba to trans-q-a-code-ba ; trans-q-code-ab to trans-q-a-code-ab ) open import Homotopy.VanKampen.Code.LemmaPackB (pushout-diag-flip d) l public using () renaming ( trans-q-code-a to trans-q-b-code-b ; trans-!q-code-a to trans-!q-b-code-b ; trans-q-code-ba to trans-q-b-code-ab ; trans-q-code-ab to trans-q-b-code-ba ) bp⇒ap : ∀ n {p} → b-code (g $ loc n) p → a-code (f $ loc n) p bp⇒ap n {p} = transport (λ x → b-code (g $ loc n) p → a-code (f $ loc n) x) (pushout-flip-flip p) (CF.ap⇒bp n {pushout-flip p}) private Laba : name → P → Set i Laba = λ n p → ∀ (co : a-code (f $ loc n) p) → bp⇒ap n {p} (ap⇒bp n {p} co) ≡ co private aba-glue-code : ∀ c {p} → Laba c p abstract aba-glue-code n {p} = pushout-rec (Laba n) (λ _ → C.aba-glue-code-a n) (λ _ → C.aba-glue-code-b n) (λ _ → funext λ _ → prop-has-all-paths (a-code-b-is-set (f $ loc n) _ _ _) _ _) p private Lbab : name → P → Set i Lbab = λ n p → ∀ (co : b-code (g $ loc n) p) → ap⇒bp n {p} (bp⇒ap n {p} co) ≡ co private bab-glue-code : ∀ n {p} → Lbab n p abstract bab-glue-code n {p} = pushout-rec (Lbab n) (λ _ → CF.aba-glue-code-b n) (λ _ → CF.aba-glue-code-a n) (λ _ → funext λ _ → prop-has-all-paths (b-code-b-is-set (g $ loc n) _ _ _) _ _) p private glue-code-loc : ∀ n p → a-code (f $ loc n) p ≃ b-code (g $ loc n) p glue-code-loc n p = ap⇒bp n {p} , iso-is-eq (ap⇒bp n {p}) (bp⇒ap n {p}) (bab-glue-code n {p}) (aba-glue-code n {p}) private TapbpTa : ∀ n₁ n₂ (r : loc n₁ ≡ loc n₂) {a} → a-code-a (f $ loc n₂) a → Set i TapbpTa n₁ n₂ r {a} co = transport (λ x → b-code-a x a) (ap g r) (aa⇒ba n₁ {a} $ transport (λ x → a-code-a x a) (! $ ap f r) co) ≡ aa⇒ba n₂ {a} co TapbpTb : ∀ n₁ n₂ (r : loc n₁ ≡ loc n₂) {b} → a-code-b (f $ loc n₂) b → Set i TapbpTb n₁ n₂ r {b} co = transport (λ x → b-code-b x b) (ap g r) (ab⇒bb n₁ {b} $ transport (λ x → a-code-b x b) (! $ ap f r) co) ≡ ab⇒bb n₂ {b} co TapbpTp : ∀ n₁ n₂ (r : loc n₁ ≡ loc n₂) {p} → a-code (f $ loc n₂) p → Set i TapbpTp n₁ n₂ r {p} co = transport (λ x → b-code x p) (ap g r) (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (! $ ap f r) co) ≡ ap⇒bp n₂ {p} co private ap⇒bp-shift-split : ∀ n₁ n₂ r → (∀ {a₂} co → TapbpTa n₁ n₂ r {a₂} co) × (∀ {b₂} co → TapbpTb n₁ n₂ r {b₂} co) abstract ap⇒bp-shift-split n₁ n₂ r = a-code-rec (f $ loc n₂) (TapbpTa n₁ n₂ r) ⦃ λ _ → ≡-is-set $ b-code-a-is-set _ _ ⦄ (TapbpTb n₁ n₂ r) ⦃ λ _ → ≡-is-set $ b-code-b-is-set _ _ ⦄ (λ {a} p → transport (λ x → b-code-a x a) (ap g r) (aa⇒ba n₁ {a} $ transport (λ x → a-code-a x a) (! $ ap f r) $ ⟧a p) ≡⟨ ap (transport (λ x → b-code-a x a) (ap g r) ◯ aa⇒ba n₁ {a}) $ trans-!q-a-code-a (ap f r) p ⟩ transport (λ x → b-code-a x a) (ap g r) (⟧b refl₀ bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p) ≡⟨ trans-q-b-code-ba (ap g r) _ _ _ ⟩ transport (λ x → b-code-b x (g $ loc n₁)) (ap g r) (⟧b refl₀) bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p ≡⟨ ap (λ x → x bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p) $ trans-q-b-code-b (ap g r) _ ⟩ ⟧b proj (! (ap g r)) ∘₀ refl₀ bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p ≡⟨ ap (λ x → ⟧b x bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p) $ refl₀-right-unit _ ⟩ ⟧b proj (! (ap g r)) bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p ≡⟨ ! $ SCF.code-a-shift (g $ loc n₂) n₁ (proj (! (ap g r))) n₂ (proj r) p ⟩ ⟧b proj (! (ap g r) ∘ ap g r) bb⟦ n₂ ⟧a p ≡⟨ ap (λ x → ⟧b proj x bb⟦ n₂ ⟧a p) $ opposite-left-inverse $ ap g r ⟩∎ aa⇒ba n₂ {a} (⟧a p) ∎) (λ {a} n {co} pco p → transport (λ x → b-code-a x a) (ap g r) (aa⇒ba n₁ {a} $ transport (λ x → a-code-a x a) (! $ ap f r) $ co ab⟦ n ⟧a p) ≡⟨ ap (transport (λ x → b-code-a x a) (ap g r) ◯ aa⇒ba n₁ {a}) $ trans-q-a-code-ba (! $ ap f r) n co p ⟩ transport (λ x → b-code-a x a) (ap g r) (ab⇒bb n₁ {g $ loc n} (transport (λ x → a-code-b x (g $ loc n)) (! $ ap f r) co) bb⟦ n ⟧a p) ≡⟨ trans-q-b-code-ba (ap g r) _ _ _ ⟩ transport (λ x → b-code-b x (g $ loc n)) (ap g r) (ab⇒bb n₁ {g $ loc n} (transport (λ x → a-code-b x (g $ loc n)) (! $ ap f r) co)) bb⟦ n ⟧a p ≡⟨ ap (λ x → x bb⟦ n ⟧a p) pco ⟩∎ ab⇒bb n₂ {g $ loc n} co bb⟦ n ⟧a p ∎) (λ {b} n {co} pco p → transport (λ x → b-code-b x b) (ap g r) (ab⇒bb n₁ {b} $ transport (λ x → a-code-b x b) (! $ ap f r) $ co aa⟦ n ⟧b p) ≡⟨ ap (transport (λ x → b-code-b x b) (ap g r) ◯ ab⇒bb n₁ {b}) $ trans-q-a-code-ab (! $ ap f r) n co p ⟩ transport (λ x → b-code-b x b) (ap g r) (aa⇒ba n₁ {f $ loc n} (transport (λ x → a-code-a x (f $ loc n)) (! $ ap f r) co) ba⟦ n ⟧b p) ≡⟨ trans-q-b-code-ab (ap g r) _ _ _ ⟩ transport (λ x → b-code-a x (f $ loc n)) (ap g r) (aa⇒ba n₁ {f $ loc n} (transport (λ x → a-code-a x (f $ loc n)) (! $ ap f r) co)) ba⟦ n ⟧b p ≡⟨ ap (λ x → x ba⟦ n ⟧b p) pco ⟩∎ aa⇒ba n₂ {f $ loc n} co ba⟦ n ⟧b p ∎) (λ _ _ → prop-has-all-paths (b-code-a-is-set _ _ _ _) _ _) (λ _ _ → prop-has-all-paths (b-code-b-is-set _ _ _ _) _ _) (λ _ _ _ _ → prop-has-all-paths (b-code-a-is-set _ _ _ _) _ _) private ap⇒bp-shift : ∀ n₁ n₂ r {p} co → TapbpTp n₁ n₂ r {p} co abstract ap⇒bp-shift n₁ n₂ r {p} co = pushout-rec (λ p → ∀ co → TapbpTp n₁ n₂ r {p} co) (λ a → π₁ (ap⇒bp-shift-split n₁ n₂ r) {a}) (λ b → π₂ (ap⇒bp-shift-split n₁ n₂ r) {b}) (λ c → funext λ _ → prop-has-all-paths (b-code-is-set (g $ loc n₂) (right $ g c) _ _) _ _) p co glue-code-eq-route : ∀ p n₁ n₂ (r : loc n₁ ≡ loc n₂) → transport (λ c → a-code (f c) p ≃ b-code (g c) p) r (glue-code-loc n₁ p) ≡ glue-code-loc n₂ p abstract glue-code-eq-route p n₁ n₂ r = equiv-eq $ funext λ co → π₁ (transport (λ c → a-code (f c) p ≃ b-code (g c) p) r (glue-code-loc n₁ p)) co ≡⟨ ap (λ x → x co) $ app-trans (λ c → a-code (f c) p ≃ b-code (g c) p) (λ c → a-code (f c) p → b-code (g c) p) (λ _ → π₁) r (glue-code-loc n₁ p) ⟩ transport (λ c → a-code (f c) p → b-code (g c) p) r (ap⇒bp n₁ {p}) co ≡⟨ trans-→ (λ c → a-code (f c) p) (λ c → b-code (g c) p) r (ap⇒bp n₁ {p}) co ⟩ transport (λ c → b-code (g c) p) r (ap⇒bp n₁ {p} $ transport (λ c → a-code (f c) p) (! r) co) ≡⟨ ap (transport (λ c → b-code (g c) p) r ◯ ap⇒bp n₁ {p}) $ ! $ trans-ap (λ x → a-code x p) f (! r) co ⟩ transport (λ c → b-code (g c) p) r (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (ap f (! r)) co) ≡⟨ ap (λ x → transport (λ c → b-code (g c) p) r $ ap⇒bp n₁ {p} $ transport (λ x → a-code x p) x co) $ ap-opposite f r ⟩ transport (λ c → b-code (g c) p) r (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (! $ ap f r) co) ≡⟨ ! $ trans-ap (λ x → b-code x p) g r _ ⟩ transport (λ x → b-code x p) (ap g r) (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (! $ ap f r) co) ≡⟨ ap⇒bp-shift n₁ n₂ r {p} co ⟩∎ ap⇒bp n₂ {p} co ∎ glue-code-eq : ∀ c p → a-code (f c) p ≃ b-code (g c) p glue-code-eq c p = visit-fiber-rec l (λ c → a-code (f c) p ≃ b-code (g c) p) ⦃ λ c → ≃-is-set (a-code-is-set (f c) p) (b-code-is-set (g c) p) ⦄ (λ n → glue-code-loc n p) (glue-code-eq-route p) c code : P → P → Set i code = pushout-rec-nondep (P → Set i) a-code b-code (λ c → funext λ p → eq-to-path $ glue-code-eq c p) open import HLevelBis abstract code-is-set : ∀ p₁ p₂ → is-set (code p₁ p₂) code-is-set = pushout-rec (λ p₁ → ∀ p₂ → is-set $ code p₁ p₂) a-code-is-set b-code-is-set (λ _ → prop-has-all-paths (Π-is-prop λ _ → is-set-is-prop) _ _) -- Useful lemma module _ {a₁ : A} where open import Homotopy.VanKampen.SplitCode d l a₁ public using () renaming ( trans-code-glue-loc to trans-a-code-glue-loc ; trans-code-!glue-loc to trans-a-code-!glue-loc ) abstract trans-b-code-glue-loc : ∀ {b₁} n₂ co → transport (b-code b₁) (glue $ loc n₂) co ≡ ba⇒bb n₂ co trans-b-code-glue-loc {b₁} n₂ co = transport (b-code b₁) (glue $ loc n₂) co ≡⟨ ! $ trans-ap (SCF.code b₁) pushout-flip (glue $ loc n₂) co ⟩ transport (SCF.code b₁) (ap pushout-flip (glue $ loc n₂)) co ≡⟨ ap (λ x → transport (SCF.code b₁) x co) $ pushout-β-glue-nondep _ right left (! ◯ glue) (loc n₂) ⟩ transport (SCF.code b₁) (! (glue $ loc n₂)) co ≡⟨ SCF.trans-code-!glue-loc b₁ n₂ co ⟩∎ ba⇒bb n₂ co ∎ abstract trans-b-code-!glue-loc : ∀ {b₁} n₂ co → transport (b-code b₁) (! (glue $ loc n₂)) co ≡ bb⇒ba n₂ co trans-b-code-!glue-loc {b₁} n₂ co = transport (b-code b₁) (! (glue $ loc n₂)) co ≡⟨ ! $ trans-ap (SCF.code b₁) pushout-flip (! (glue $ loc n₂)) co ⟩ transport (SCF.code b₁) (ap pushout-flip (! (glue $ loc n₂))) co ≡⟨ ap (λ x → transport (SCF.code b₁) x co) $ pushout-β-!glue-nondep _ right left (! ◯ glue) (loc n₂) ⟩ transport (SCF.code b₁) (! (! (glue $ loc n₂))) co ≡⟨ ap (λ x → transport (SCF.code b₁) x co) $ opposite-opposite $ glue $ loc n₂ ⟩ transport (SCF.code b₁) (glue $ loc n₂) co ≡⟨ SCF.trans-code-glue-loc b₁ n₂ co ⟩∎ bb⇒ba n₂ co ∎ abstract trans-glue-code-loc : ∀ n {p} (co : a-code (f $ loc n) p) → transport (λ x → code x p) (glue $ loc n) co ≡ ap⇒bp n {p} co trans-glue-code-loc n {p} co = transport (λ x → code x p) (glue $ loc n) co ≡⟨ ! $ trans-ap (λ f → f p) code (glue $ loc n) co ⟩ transport (λ f → f p) (ap code (glue $ loc n)) co ≡⟨ ap (λ x → transport (λ f → f p) x co) $ pushout-β-glue-nondep (P → Set i) a-code b-code (λ c → funext λ p → eq-to-path $ glue-code-eq c p) $ loc n ⟩ transport (λ f → f p) (funext λ p → eq-to-path $ glue-code-eq (loc n) p) co ≡⟨ ! $ trans-ap (λ X → X) (λ f → f p) (funext λ p → eq-to-path $ glue-code-eq (loc n) p) co ⟩ transport (λ X → X) (happly (funext λ p → eq-to-path $ glue-code-eq (loc n) p) p) co ≡⟨ ap (λ x → transport (λ X → X) (x p) co) $ happly-funext (λ p → eq-to-path $ glue-code-eq (loc n) p) ⟩ transport (λ X → X) (eq-to-path $ glue-code-eq (loc n) p) co ≡⟨ trans-id-eq-to-path (glue-code-eq (loc n) p) co ⟩ π₁ (glue-code-eq (loc n) p) co ≡⟨ ap (λ x → π₁ x co) $ visit-fiber-β-loc l (λ c → a-code (f c) p ≃ b-code (g c) p) ⦃ λ c → ≃-is-set (a-code-is-set (f c) p) (b-code-is-set (g c) p) ⦄ (λ n → glue-code-loc n p) (glue-code-eq-route p) n ⟩∎ ap⇒bp n {p} co ∎ abstract trans-!glue-code-loc : ∀ n {p} (co : b-code (g $ loc n) p) → transport (λ x → code x p) (! $ glue $ loc n) co ≡ bp⇒ap n {p} co trans-!glue-code-loc n {p} co = move!-transp-right (λ x → code x p) (glue $ loc n) co (bp⇒ap n {p} co) $ ! $ transport (λ x → code x p) (glue $ loc n) (bp⇒ap n {p} co) ≡⟨ trans-glue-code-loc n {p} (bp⇒ap n {p} co) ⟩ ap⇒bp n {p} (bp⇒ap n {p} co) ≡⟨ bab-glue-code n {p} co ⟩∎ co ∎
{ "alphanum_fraction": 0.4910302728, "avg_line_length": 39.6395061728, "ext": "agda", "hexsha": "985156c204a69bd14590fbc377a179aedd3b0825", "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/Homotopy/VanKampen/Code.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/Homotopy/VanKampen/Code.agda", "max_line_length": 112, "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/Homotopy/VanKampen/Code.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": 6498, "size": 16054 }
open import Prelude open import core module lemmas-consistency where -- type consistency is symmetric ~sym : {t1 t2 : typ} → t1 ~ t2 → t2 ~ t1 ~sym TCRefl = TCRefl ~sym TCHole1 = TCHole2 ~sym TCHole2 = TCHole1 ~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2) ~sym (TCProd h h₁) = TCProd (~sym h) (~sym h₁) -- type consistency isn't transitive not-trans : ((t1 t2 t3 : typ) → t1 ~ t2 → t2 ~ t3 → t1 ~ t3) → ⊥ not-trans t with t (b ==> b) ⦇·⦈ b TCHole1 TCHole2 ... | () -- every pair of types is either consistent or not consistent ~dec : (t1 t2 : typ) → ((t1 ~ t2) + (t1 ~̸ t2)) -- this takes care of all hole cases, so we don't consider them below ~dec _ ⦇·⦈ = Inl TCHole1 ~dec ⦇·⦈ b = Inl TCHole2 ~dec ⦇·⦈ (q ==> q₁) = Inl TCHole2 ~dec ⦇·⦈ (q ⊗ q₁) = Inl TCHole2 -- num cases ~dec b b = Inl TCRefl ~dec b (t2 ==> t3) = Inr ICBaseArr1 -- arrow cases ~dec (t1 ==> t2) b = Inr ICBaseArr2 ~dec (t1 ==> t2) (t3 ==> t4) with ~dec t1 t3 | ~dec t2 t4 ... | Inl x | Inl y = Inl (TCArr x y) ... | Inl _ | Inr y = Inr (ICArr2 y) ... | Inr x | _ = Inr (ICArr1 x) ~dec b (t2 ⊗ t3) = Inr ICBaseProd1 ~dec (t1 ==> t2) (t3 ⊗ t4) = Inr ICProdArr1 ~dec (t1 ⊗ t2) b = Inr ICBaseProd2 ~dec (t1 ⊗ t2) (t3 ==> t4) = Inr ICProdArr2 ~dec (t1 ⊗ t2) (t3 ⊗ t4) with ~dec t1 t3 | ~dec t2 t4 ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inl x | Inl x₁ = Inl (TCProd x x₁) ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inl x | Inr x₁ = Inr (ICProd2 x₁) ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inr x | Inl x₁ = Inr (ICProd1 x) ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inr x | Inr x₁ = Inr (ICProd1 x) -- no pair of types is both consistent and not consistent ~apart : {t1 t2 : typ} → (t1 ~̸ t2) → (t1 ~ t2) → ⊥ ~apart ICBaseArr1 () ~apart ICBaseArr2 () ~apart (ICArr1 x) TCRefl = ~apart x TCRefl ~apart (ICArr1 x) (TCArr y y₁) = ~apart x y ~apart (ICArr2 x) TCRefl = ~apart x TCRefl ~apart (ICArr2 x) (TCArr y y₁) = ~apart x y₁ ~apart ICBaseProd1 () ~apart ICBaseProd2 () ~apart ICProdArr1 () ~apart ICProdArr2 () ~apart (ICProd1 h) TCRefl = ~apart h TCRefl ~apart (ICProd1 h) (TCProd h₁ h₂) = ~apart h h₁ ~apart (ICProd2 h) TCRefl = ~apart h TCRefl ~apart (ICProd2 h) (TCProd h₁ h₂) = ~apart h h₂ ~apart-converse : (τ1 τ2 : typ) → (τ1 ~ τ2 → ⊥) → τ1 ~̸ τ2 ~apart-converse τ1 τ2 ne with ~dec τ1 τ2 ~apart-converse τ1 τ2 ne | Inl h = abort (ne h) ~apart-converse τ1 τ2 ne | Inr h = h ~decPair : (τ1 τ2 τ3 τ4 : typ) → ((τ1 ⊗ τ2) ~ (τ3 ⊗ τ4) → ⊥) → (τ1 ~ τ3 → ⊥) + (τ2 ~ τ4 → ⊥) ~decPair τ1 τ2 τ3 τ4 inc with ~apart-converse (τ1 ⊗ τ2) (τ3 ⊗ τ4) inc ~decPair τ1 τ2 τ3 τ4 inc | ICProd1 h = Inl (~apart h) ~decPair τ1 τ2 τ3 τ4 inc | ICProd2 h = Inr (~apart h) ~prod1 : ∀{τ1 τ2 τ3 τ4} → (τ1 ⊗ τ2) ~ (τ3 ⊗ τ4) → τ1 ~ τ3 ~prod1 TCRefl = TCRefl ~prod1 (TCProd h1 h2) = h1 ~prod2 : ∀{τ1 τ2 τ3 τ4} → (τ1 ⊗ τ2) ~ (τ3 ⊗ τ4) → τ2 ~ τ4 ~prod2 TCRefl = TCRefl ~prod2 (TCProd h1 h2) = h2
{ "alphanum_fraction": 0.5490196078, "avg_line_length": 38.5769230769, "ext": "agda", "hexsha": "08991817211a181528939fdbcd7d351cbda7c9e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda", "max_forks_repo_path": "lemmas-consistency.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazel-palette-agda", "max_issues_repo_path": "lemmas-consistency.agda", "max_line_length": 94, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazel-palette-agda", "max_stars_repo_path": "lemmas-consistency.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z", "num_tokens": 1466, "size": 3009 }
{-# OPTIONS --cubical --safe #-} module Relation.Nullary.Discrete where open import Relation.Nullary.Decidable open import Path open import Level Discrete : Type a → Type a Discrete A = (x y : A) → Dec (x ≡ y)
{ "alphanum_fraction": 0.7042253521, "avg_line_length": 19.3636363636, "ext": "agda", "hexsha": "328c3433a3e9ccc48954436fb40c71ad7f36c2c4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Relation/Nullary/Discrete.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Relation/Nullary/Discrete.agda", "max_line_length": 38, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Relation/Nullary/Discrete.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": 60, "size": 213 }
-- Andreas, 2017-10-04, issue #689, test case by stevana -- {-# OPTIONS -v tc.data:50 #-} -- {-# OPTIONS -v tc.force:100 #-} -- {-# OPTIONS -v tc.constr:50 #-} -- {-# OPTIONS -v tc.conv.sort:30 #-} -- {-# OPTIONS -v tc.conv.nat:30 #-} open import Agda.Primitive data L {a} (A : Set a) : Set a where _∷_ : A → L A → L A data S {a} {A : Set a} : L A → Set₁ where _∷_ : (x : A) → (xs : L A) → S (x ∷ xs) -- x and xs are forced! -- Should succeed without unsolved constraints. -- There was a problem in the forcing analysis which I introduced -- with apparently improper use of `noConstraints` (still do not know why) -- for the Big/Small Forced argument analysis. -- The latter one is obsolete and thus removed.
{ "alphanum_fraction": 0.625, "avg_line_length": 31.3043478261, "ext": "agda", "hexsha": "11c79cffdf90365db4d0705321aa536c8af340a2", "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/Issue689-stevana.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/Issue689-stevana.agda", "max_line_length": 74, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue689-stevana.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": 228, "size": 720 }
module Data.Num.Injection where open import Data.Num.Core open import Data.Nat hiding (compare) open import Data.Nat.Properties open import Data.Nat.Properties.Simple open import Data.Nat.Properties.Extra open import Data.Fin as Fin using (Fin; fromℕ≤; inject≤) renaming (zero to z; suc to s) open import Data.Fin.Properties using (toℕ-fromℕ≤; to-from; bounded; inject≤-lemma) renaming (toℕ-injective to Fin→ℕ-injective; _≟_ to _Fin≟_) open import Data.Fin.Properties.Extra open import Data.Sum open import Data.Product open import Data.Empty using (⊥) open import Data.Unit using (⊤; tt) open import Function open import Function.Injection open Injection -- open import Function.Equality using (_⟶_; _⟨$⟩_) open import Relation.Nullary.Decidable open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Binary open import Relation.Binary.PropositionalEquality open ≡-Reasoning open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_) open DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl) open StrictTotalOrder strictTotalOrder using (compare) data InjCond : ℕ → ℕ → ℕ → Set where Ordinary : ∀ {b d o} → (b≥d : b ≥ d) → (o≥1 : o ≥ 1) → InjCond b d o Digitless : ∀ {b d o} → (d≡0 : d ≡ 0) → InjCond b 0 o -- having no digits at all data NonInjCond : ℕ → ℕ → ℕ → Set where Redundant : ∀ {b d o} → (d>b : d > b) → NonInjCond b d o -- having to many digits WithZeros : ∀ {b d o} → (o≡0 : o ≡ 0) → (d≢0 : d ≢ 0) → NonInjCond b d 0 -- with leading zeroes data InjectionView : ℕ → ℕ → ℕ → Set where Inj : ∀ {b d o} → InjCond b d o → InjectionView b d o NonInj : ∀ {b d o} → NonInjCond b d o → InjectionView b d o injectionView : (b d o : ℕ) → InjectionView b d o injectionView b zero zero = Inj (Digitless refl) injectionView b (suc d) zero = NonInj (WithZeros refl (λ ())) injectionView b d (suc o) with d ≤? b injectionView b d (suc o) | yes p = Inj (Ordinary p (s≤s z≤n)) injectionView b d (suc o) | no ¬p = NonInj (Redundant (≰⇒> ¬p)) IsInjective : ℕ → ℕ → ℕ → Set IsInjective b d o with injectionView b d o IsInjective b d o | Inj _ = ⊤ IsInjective b d o | NonInj _ = ⊥ InjCond⇒IsInj : ∀ {b d o} → InjCond b d o → IsInjective b d o InjCond⇒IsInj {b} {d} {o} cond with injectionView b d o InjCond⇒IsInj _ | Inj _ = tt InjCond⇒IsInj (Ordinary b≥d o≥1) | NonInj (Redundant d>b) = contradiction b≥d (>⇒≰ d>b) InjCond⇒IsInj (Ordinary b≥d ()) | NonInj (WithZeros o≡0 d≢0) InjCond⇒IsInj (Digitless d≡0) | NonInj (Redundant ()) InjCond⇒IsInj (Digitless d≡0) | NonInj (WithZeros refl d≢0) = contradiction refl d≢0 -- InjCond⇒b≥1 : ∀ {b d o} → InjCond b (suc d) o → b ≥ 1 -- InjCond⇒b≥1 {zero} (bijCond b≥d: o≥1:) = contradiction b≥d: (>⇒≰ (s≤s z≤n)) -- InjCond⇒b≥1 {suc b} (bijCond b≥d: o≥1:) = s≤s z≤n -- NonInjCond⇏IsInj : ∀ {b d o} → NonInjCond b d o → ¬ IsInjective b d o NonInjCond⇏IsInj {b} {d} {o} reason claim with injectionView b d o NonInjCond⇏IsInj (Redundant d>b) claim | Inj (Ordinary b≥d o≥1) = contradiction b≥d (>⇒≰ d>b) NonInjCond⇏IsInj (Redundant ()) claim | Inj (Digitless d≡0) NonInjCond⇏IsInj (WithZeros o≡0 d≢0) claim | Inj (Ordinary b≥d ()) NonInjCond⇏IsInj (WithZeros o≡0 d≢0) claim | Inj (Digitless d≡0) = contradiction refl d≢0 NonInjCond⇏IsInj reason () | NonInj _ Digit-toℕ-injective : ∀ {d} o (x y : Fin d) → Digit-toℕ x o ≡ Digit-toℕ y o -- o + toℕ x ≡ o + toℕ y → x ≡ y Digit-toℕ-injective {_} o x y eq = Fin→ℕ-injective -- cancels `Fin.toℕ` $ cancel-+-left o -- cancels `o +` $ eq n∷-mono-strict : ∀ {b d o} (x y : Fin d) (xs ys : Num b d o) → InjCond b d o → toℕ xs < toℕ ys → toℕ (x ∷ xs) < toℕ (y ∷ ys) n∷-mono-strict {b} {_} {o} () () xs ys (Digitless d≡0) ⟦xs⟧<⟦ys⟧ n∷-mono-strict {b} {d} {o} x y xs ys (Ordinary b≥d o≥1) ⟦xs⟧<⟦ys⟧ = start suc (Digit-toℕ x o) + toℕ xs * b ≤⟨ +n-mono (toℕ xs * b) $ start suc (Digit-toℕ x o) ≈⟨ sym (+-suc o (Fin.toℕ x)) ⟩ -- push `o` to the left o + suc (Fin.toℕ x) ≤⟨ n+-mono o $ start suc (Fin.toℕ x) ≤⟨ bounded x ⟩ d ≤⟨ b≥d ⟩ b ≤⟨ n≤m+n (Fin.toℕ y) b ⟩ Fin.toℕ y + b □ ⟩ o + (Fin.toℕ y + b) ≈⟨ sym (+-assoc o (Fin.toℕ y) b) ⟩ Digit-toℕ y o + b □ ⟩ Digit-toℕ y o + b + toℕ xs * b ≈⟨ +-assoc (Digit-toℕ y o) b (toℕ xs * b) ⟩ Digit-toℕ y o + (b + toℕ xs * b) ≤⟨ n+-mono (Digit-toℕ y o) (*n-mono b ⟦xs⟧<⟦ys⟧) ⟩ -- replace `xs` with `ys` Digit-toℕ y o + toℕ ys * b □ ∷ns-mono-strict : ∀ {b d o} (x y : Fin d) (xs ys : Num b d o) → toℕ xs ≡ toℕ ys → Digit-toℕ x o < Digit-toℕ y o → toℕ (x ∷ xs) < toℕ (y ∷ ys) ∷ns-mono-strict {b} {d} {o} x y xs ys ⟦xs⟧≡⟦ys⟧ ⟦x⟧<⟦y⟧ = start suc (Digit-toℕ x o + toℕ xs * b) ≈⟨ cong (λ w → suc (Digit-toℕ x o + w * b)) ⟦xs⟧≡⟦ys⟧ ⟩ suc (Digit-toℕ x o + toℕ ys * b) ≤⟨ +n-mono (toℕ ys * b) ⟦x⟧<⟦y⟧ ⟩ Digit-toℕ y o + toℕ ys * b □ toℕ-injective-⟦x∷xs⟧>0-lemma : ∀ {b d o} → o ≥ 1 → (x : Fin d) → (xs : Num b d o) → toℕ (x ∷ xs) > 0 toℕ-injective-⟦x∷xs⟧>0-lemma {b} {d} {o} o≥1 x xs = start suc zero ≤⟨ o≥1 ⟩ o ≤⟨ m≤m+n o (Fin.toℕ x) ⟩ o + Fin.toℕ x ≤⟨ m≤m+n (o + Fin.toℕ x) (toℕ xs * b) ⟩ o + Fin.toℕ x + toℕ xs * b □ toℕ-injective : ∀ {b d o} → {isInj : IsInjective b d o} → (xs ys : Num b d o) → toℕ xs ≡ toℕ ys → xs ≡ ys toℕ-injective {b} {d} {o} xs ys eq with injectionView b d o toℕ-injective ∙ ∙ eq | Inj (Ordinary b≥d o≥1) = refl toℕ-injective ∙ (y ∷ ys) eq | Inj (Ordinary b≥d o≥1) = contradiction eq (<⇒≢ (toℕ-injective-⟦x∷xs⟧>0-lemma o≥1 y ys)) toℕ-injective (x ∷ xs) ∙ eq | Inj (Ordinary b≥d o≥1) = contradiction eq (>⇒≢ (toℕ-injective-⟦x∷xs⟧>0-lemma o≥1 x xs)) toℕ-injective {b} {zero} {o} (() ∷ xs) (y ∷ ys) eq | Inj cond toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond with compare (toℕ xs) (toℕ ys) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri< ⟦xs⟧<⟦ys⟧ _ _ = contradiction eq (<⇒≢ (n∷-mono-strict x y xs ys cond ⟦xs⟧<⟦ys⟧)) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ with compare (Digit-toℕ x o) (Digit-toℕ y o) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ | tri< ⟦x⟧<⟦y⟧ _ _ = contradiction eq (<⇒≢ (∷ns-mono-strict x y xs ys ⟦xs⟧≡⟦ys⟧ ⟦x⟧<⟦y⟧)) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ | tri≈ _ ⟦x⟧≡⟦y⟧ _ = cong₂ _∷_ (Digit-toℕ-injective o x y ⟦x⟧≡⟦y⟧) (toℕ-injective {isInj = InjCond⇒IsInj cond} xs ys ⟦xs⟧≡⟦ys⟧) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ | tri> _ _ ⟦x⟧>⟦y⟧ = contradiction eq (>⇒≢ (∷ns-mono-strict y x ys xs (sym ⟦xs⟧≡⟦ys⟧) ⟦x⟧>⟦y⟧)) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri> _ _ ⟦xs⟧>⟦ys⟧ = contradiction eq (>⇒≢ ((n∷-mono-strict y x ys xs cond ⟦xs⟧>⟦ys⟧))) toℕ-injective ∙ ∙ eq | Inj (Digitless d≡0) = refl toℕ-injective ∙ (() ∷ ys) eq | Inj (Digitless d≡0) toℕ-injective (() ∷ xs) ys eq | Inj (Digitless d≡0) toℕ-injective {isInj = ()} xs ys eq | NonInj reason InjCond⇒Injective : ∀ {b} {d} {o} → InjCond b d o → Injective (Num⟶ℕ b d o) InjCond⇒Injective condition {x} {y} = toℕ-injective {isInj = InjCond⇒IsInj condition} x y NonInjCond⇏Injective : ∀ {b} {d} {o} → NonInjCond b d o → ¬ (Injective (Num⟶ℕ b d o)) NonInjCond⇏Injective {zero} {zero} (Redundant ()) claim NonInjCond⇏Injective {zero} {suc d} {o} (Redundant d>b) claim = contradiction (claim {z ∷ ∙} {z ∷ z ∷ ∙} ⟦1∷∙⟧≡⟦1∷1∷∙⟧) (λ ()) where ⟦1∷∙⟧≡⟦1∷1∷∙⟧ : toℕ {zero} {suc d} {o} (z ∷ ∙) ≡ toℕ {zero} {suc d} {o} (z ∷ z ∷ ∙) ⟦1∷∙⟧≡⟦1∷1∷∙⟧ = cong (λ w → o + 0 + w) (sym (*-right-zero (o + 0 + 0))) NonInjCond⇏Injective {suc b} {zero} (Redundant ()) claim NonInjCond⇏Injective {suc b} {suc zero} (Redundant (s≤s ())) claim NonInjCond⇏Injective {suc b} {suc (suc d)} {o} (Redundant d>b) claim = contradiction (claim {z ∷ s z ∷ ∙} {fromℕ≤ d>b ∷ z ∷ ∙} ⟦1∷2⟧≡⟦b+1∷1⟧) (λ ()) where ⟦1∷2⟧≡⟦b+1∷1⟧ : toℕ {suc b} {suc (suc d)} {o} (z ∷ s z ∷ ∙) ≡ toℕ {suc b} {suc (suc d)} {o} (fromℕ≤ {suc b} d>b ∷ z ∷ ∙) ⟦1∷2⟧≡⟦b+1∷1⟧ = begin o + zero + (o + suc zero + zero) * suc b ≡⟨ cong (λ x → x + (o + suc zero + zero) * suc b) (+-right-identity o) ⟩ o + (o + suc zero + zero) * suc b ≡⟨ cong (λ x → o + (x + zero) * suc b) (+-suc o zero) ⟩ o + (suc (o + zero) + zero) * suc b ≡⟨ refl ⟩ o + (suc b + (o + zero + zero) * suc b) ≡⟨ sym (+-assoc o (suc b) ((o + zero + zero) * suc b)) ⟩ o + suc b + (o + zero + zero) * suc b ≡⟨ cong (λ x → o + x + (o + zero + zero) * suc b) (sym (toℕ-fromℕ≤ d>b)) ⟩ o + Fin.toℕ (fromℕ≤ d>b) + (o + zero + zero) * suc b ∎ NonInjCond⇏Injective {b} {zero} {_} (WithZeros o≡0 d≢0) claim = contradiction refl d≢0 NonInjCond⇏Injective {b} {suc d} {_} (WithZeros o≡0 d≢0) claim = contradiction (claim {z ∷ ∙} {∙} ⟦0∷∙⟧≡⟦∙⟧) (λ ()) where ⟦0∷∙⟧≡⟦∙⟧ : toℕ {b} {suc d} {0} (z ∷ ∙) ≡ toℕ {b} {suc d} {0} ∙ ⟦0∷∙⟧≡⟦∙⟧ = refl Injective? : ∀ b d o → Dec (Injective (Num⟶ℕ b d o)) Injective? b d o with injectionView b d o Injective? b d o | Inj condition = yes (InjCond⇒Injective condition) Injective? b d o | NonInj reason = no (NonInjCond⇏Injective reason) -- begin -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ∎
{ "alphanum_fraction": 0.5158838433, "avg_line_length": 42.0573770492, "ext": "agda", "hexsha": "9bec3e3e8caa41dfcea4cdd200ce3c1b16238296", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "Data/Num/Injection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "Data/Num/Injection.agda", "max_line_length": 210, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "Data/Num/Injection.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 4703, "size": 10262 }
module Lambda where open import Prelude open import Star open import Examples open import Modal -- Environments record TyAlg (ty : Set) : Set where field nat : ty _⟶_ : ty -> ty -> ty data Ty : Set where <nat> : Ty _<⟶>_ : Ty -> Ty -> Ty freeTyAlg : TyAlg Ty freeTyAlg = record { nat = <nat>; _⟶_ = _<⟶>_ } termTyAlg : TyAlg True termTyAlg = record { nat = _; _⟶_ = \_ _ -> _ } record TyArrow {ty₁ ty₂ : Set}(T₁ : TyAlg ty₁)(T₂ : TyAlg ty₂) : Set where field apply : ty₁ -> ty₂ respNat : apply (TyAlg.nat T₁) == TyAlg.nat T₂ resp⟶ : forall {τ₁ τ₂} -> apply (TyAlg._⟶_ T₁ τ₁ τ₂) == TyAlg._⟶_ T₂ (apply τ₁) (apply τ₂) _=Ty=>_ : {ty₁ ty₂ : Set}(T₁ : TyAlg ty₁)(T₂ : TyAlg ty₂) -> Set _=Ty=>_ = TyArrow !Ty : {ty : Set}{T : TyAlg ty} -> T =Ty=> termTyAlg !Ty = record { apply = ! ; respNat = refl ; resp⟶ = refl } Ctx : Set Ctx = List Ty Var : {ty : Set} -> List ty -> ty -> Set Var Γ τ = Any (_==_ τ) Γ vzero : {τ : Ty} {Γ : Ctx} -> Var (τ • Γ) τ vzero = done refl • ε vsuc : {σ τ : Ty} {Γ : Ctx} -> Var Γ τ -> Var (σ • Γ) τ vsuc v = step • v module Term {ty : Set}(T : TyAlg ty) where private open module TT = TyAlg T data Tm : List ty -> ty -> Set where var : forall {Γ τ} -> Var Γ τ -> Tm Γ τ zz : forall {Γ} -> Tm Γ nat ss : forall {Γ} -> Tm Γ (nat ⟶ nat) ƛ : forall {Γ σ τ} -> Tm (σ • Γ) τ -> Tm Γ (σ ⟶ τ) _$_ : forall {Γ σ τ} -> Tm Γ (σ ⟶ τ) -> Tm Γ σ -> Tm Γ τ module Eval where private open module TT = Term freeTyAlg ty⟦_⟧ : Ty -> Set ty⟦ <nat> ⟧ = Nat ty⟦ σ <⟶> τ ⟧ = ty⟦ σ ⟧ -> ty⟦ τ ⟧ Env : Ctx -> Set Env = All ty⟦_⟧ _[_] : forall {Γ τ} -> Env Γ -> Var Γ τ -> ty⟦ τ ⟧ ρ [ x ] with lookup x ρ ... | result _ refl v = v ⟦_⟧_ : forall {Γ τ} -> Tm Γ τ -> Env Γ -> ty⟦ τ ⟧ ⟦ var x ⟧ ρ = ρ [ x ] ⟦ zz ⟧ ρ = zero ⟦ ss ⟧ ρ = suc ⟦ ƛ t ⟧ ρ = \x -> ⟦ t ⟧ (check x • ρ) ⟦ s $ t ⟧ ρ = (⟦ s ⟧ ρ) (⟦ t ⟧ ρ) module MoreExamples where private open module TT = TyAlg freeTyAlg private open module Tm = Term freeTyAlg open Eval tm-one : Tm ε nat tm-one = ss $ zz tm-id : Tm ε (nat ⟶ nat) tm-id = ƛ (var (done refl • ε)) tm : Tm ε nat tm = tm-id $ tm-one tm-twice : Tm ε ((nat ⟶ nat) ⟶ (nat ⟶ nat)) tm-twice = ƛ (ƛ (f $ (f $ x))) where Γ : Ctx Γ = nat • (nat ⟶ nat) • ε f : Tm Γ (nat ⟶ nat) f = var (vsuc vzero) x : Tm Γ nat x = var vzero sem : {τ : Ty} -> Tm ε τ -> ty⟦ τ ⟧ sem e = ⟦ e ⟧ ε one : Nat one = sem tm twice : (Nat -> Nat) -> (Nat -> Nat) twice = sem tm-twice
{ "alphanum_fraction": 0.4954614221, "avg_line_length": 22.406779661, "ext": "agda", "hexsha": "cbb00df6757be28a5eeaec0136fa219272accdc4", "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/AIM6/Path/Lambda.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/AIM6/Path/Lambda.agda", "max_line_length": 78, "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/AIM6/Path/Lambda.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": 1115, "size": 2644 }
{-# OPTIONS --allow-unsolved-metas #-} module regex1 where open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Fin open import Data.Nat hiding ( _≟_ ) open import Data.List hiding ( any ; [_] ) -- import Data.Bool using ( Bool ; true ; false ; _∧_ ) -- open import Data.Bool using ( Bool ; true ; false ; _∧_ ; _∨_ ) open import Relation.Binary.PropositionalEquality as RBF hiding ( [_] ) open import Relation.Nullary using (¬_; Dec; yes; no) open import regex open import logic -- postulate a b c d : Set data In : Set where a : In b : In c : In d : In -- infixr 40 _&_ _||_ r1' = (< a > & < b >) & < c > --- abc r1 = < a > & < b > & < c > --- abc r0 : ¬ (r1' ≡ r1) r0 () any = < a > || < b > || < c > || < d > --- a|b|c|d r2 = ( any * ) & ( < a > & < b > & < c > ) -- .*abc r3 = ( any * ) & ( < a > & < b > & < c > & < a > & < b > & < c > ) r4 = ( < a > & < b > & < c > ) || ( < b > & < c > & < d > ) r5 = ( any * ) & ( < a > & < b > & < c > || < b > & < c > & < d > ) open import nfa -- former ++ later ≡ x split : {Σ : Set} → ((former : List Σ) → Bool) → ((later : List Σ) → Bool) → (x : List Σ ) → Bool split x y [] = x [] /\ y [] split x y (h ∷ t) = (x [] /\ y (h ∷ t)) \/ split (λ t1 → x ( h ∷ t1 )) (λ t2 → y t2 ) t -- tt1 : {Σ : Set} → ( P Q : List In → Bool ) → split P Q ( a ∷ b ∷ c ∷ [] ) -- tt1 P Q = ? {-# TERMINATING #-} repeat : {Σ : Set} → (List Σ → Bool) → List Σ → Bool repeat x [] = true repeat {Σ} x ( h ∷ t ) = split x (repeat {Σ} x) ( h ∷ t ) -- Meaning of regular expression regular-language : {Σ : Set} → Regex Σ → ((x y : Σ ) → Dec (x ≡ y)) → List Σ → Bool regular-language φ cmp _ = false regular-language ε cmp [] = true regular-language ε cmp (_ ∷ _) = false regular-language (x *) cmp = repeat ( regular-language x cmp ) regular-language (x & y) cmp = split ( λ z → regular-language x cmp z ) (λ z → regular-language y cmp z ) regular-language (x || y) cmp = λ s → ( regular-language x cmp s ) \/ ( regular-language y cmp s) regular-language < h > cmp [] = false regular-language < h > cmp (h1 ∷ [] ) with cmp h h1 ... | yes _ = true ... | no _ = false regular-language < h > _ (_ ∷ _ ∷ _) = false cmpi : (x y : In ) → Dec (x ≡ y) cmpi a a = yes refl cmpi b b = yes refl cmpi c c = yes refl cmpi d d = yes refl cmpi a b = no (λ ()) cmpi a c = no (λ ()) cmpi a d = no (λ ()) cmpi b a = no (λ ()) cmpi b c = no (λ ()) cmpi b d = no (λ ()) cmpi c a = no (λ ()) cmpi c b = no (λ ()) cmpi c d = no (λ ()) cmpi d a = no (λ ()) cmpi d b = no (λ ()) cmpi d c = no (λ ()) test-regex : regular-language r1' cmpi ( a ∷ [] ) ≡ false test-regex = refl test-regex1 : regular-language r2 cmpi ( a ∷ a ∷ b ∷ c ∷ [] ) ≡ true test-regex1 = refl test-AB→split : {Σ : Set} → {A B : List In → Bool} → split A B ( a ∷ b ∷ a ∷ [] ) ≡ ( ( A [] /\ B ( a ∷ b ∷ a ∷ [] ) ) \/ ( A ( a ∷ [] ) /\ B ( b ∷ a ∷ [] ) ) \/ ( A ( a ∷ b ∷ [] ) /\ B ( a ∷ [] ) ) \/ ( A ( a ∷ b ∷ a ∷ [] ) /\ B [] ) ) test-AB→split {_} {A} {B} = refl list-eq : {Σ : Set} → (cmpi : (s t : Σ) → Dec (s ≡ t )) → (s t : List Σ ) → Bool list-eq cmpi [] [] = true list-eq cmpi [] (x ∷ t) = false list-eq cmpi (x ∷ s) [] = false list-eq cmpi (x ∷ s) (y ∷ t) with cmpi x y ... | yes _ = list-eq cmpi s t ... | no _ = false -- split-spec-01 : {s t u : List In } → s ++ t ≡ u → split (list-eq cmpi s) (list-eq cmpi t) u ≡ true -- split-spec-01 = {!!} -- from example 1.53 1 ex53-1 : Set ex53-1 = (s : List In ) → regular-language ( (< a > *) & < b > & (< a > *) ) cmpi s ≡ true → {!!} -- contains exact one b ex53-2 : Set ex53-2 = (s : List In ) → regular-language ( (any * ) & < b > & (any *) ) cmpi s ≡ true → {!!} -- contains at lease one b evenp : {Σ : Set} → List Σ → Bool oddp : {Σ : Set} → List Σ → Bool oddp [] = false oddp (_ ∷ t) = evenp t evenp [] = true evenp (_ ∷ t) = oddp t -- from example 1.53 5 egex-even : Set egex-even = (s : List In ) → regular-language ( ( any & any ) * ) cmpi s ≡ true → evenp s ≡ true test11 = regular-language ( ( any & any ) * ) cmpi (a ∷ []) test12 = regular-language ( ( any & any ) * ) cmpi (a ∷ b ∷ []) -- proof-egex-even : egex-even -- proof-egex-even [] _ = refl -- proof-egex-even (a ∷ []) () -- proof-egex-even (b ∷ []) () -- proof-egex-even (c ∷ []) () -- proof-egex-even (x ∷ x₁ ∷ s) y = proof-egex-even s {!!} open import finiteSet iFin : FiniteSet In iFin = record { finite = finite0 ; Q←F = Q←F0 ; F←Q = F←Q0 ; finiso→ = finiso→0 ; finiso← = finiso←0 } where finite0 : ℕ finite0 = 4 Q←F0 : Fin finite0 → In Q←F0 zero = a Q←F0 (suc zero) = b Q←F0 (suc (suc zero)) = c Q←F0 (suc (suc (suc zero))) = d F←Q0 : In → Fin finite0 F←Q0 a = # 0 F←Q0 b = # 1 F←Q0 c = # 2 F←Q0 d = # 3 finiso→0 : (q : In) → Q←F0 ( F←Q0 q ) ≡ q finiso→0 a = refl finiso→0 b = refl finiso→0 c = refl finiso→0 d = refl finiso←0 : (f : Fin finite0 ) → F←Q0 ( Q←F0 f ) ≡ f finiso←0 zero = refl finiso←0 (suc zero) = refl finiso←0 (suc (suc zero)) = refl finiso←0 (suc (suc (suc zero))) = refl open import derive In iFin open import automaton ra-ex = trace (regex→automaton cmpi r2) (record { state = r2 ; is-derived = unit }) ( a ∷ b ∷ c ∷ [])
{ "alphanum_fraction": 0.4700214133, "avg_line_length": 31.3072625698, "ext": "agda", "hexsha": "e2b3962a137b0568d1dd32992f775ad3818bdc32", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/regex1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "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": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/regex1.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/regex1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2179, "size": 5604 }
------------------------------------------------------------------------ -- Labelled transition systems ------------------------------------------------------------------------ {-# OPTIONS --safe #-} module Labelled-transition-system where open import Equality.Propositional import Logical-equivalence open import Prelude open import Bijection equality-with-J using (_↔_) open import Equivalence equality-with-J using (↔⇒≃) open import Function-universe equality-with-J hiding (id; _∘_) open import Univalence-axiom equality-with-J -- Labelled transition systems were perhaps first defined by Robert M. -- Keller (https://doi.org/10.1145/360248.360251). The definition -- below is a variant with a field "is-silent", added by me. -- -- I don't know who first came up with the concept of a weak -- transition. The definitions of _⇒_, _[_]⇒_, _[_]⇒̂_ and _[_]⟶̂_ below -- are based on definitions in "Enhancements of the bisimulation proof -- method" by Pous and Sangiorgi. record LTS ℓ : Type (lsuc ℓ) where infix 4 _[_]⟶_ _⇒_ _[_]⇒_ _[_]⇒̂_ _[_]⟶̂_ field -- Processes. Proc : Type ℓ -- Labels. Label : Type ℓ -- Transitions. _[_]⟶_ : Proc → Label → Proc → Type ℓ -- Is the label silent? is-silent : Label → Bool -- Is the label silent? Silent : Label → Type Silent μ with is-silent μ ... | true = ⊤ ... | false = ⊥ -- Silence can be decided. silent? : ∀ μ → Dec (Silent μ) silent? μ with is-silent μ ... | true = yes _ ... | false = no id -- Sequences of zero or more silent transitions. data _⇒_ : Proc → Proc → Type ℓ where done : ∀ {p} → p ⇒ p step : ∀ {p q r μ} → Silent μ → p [ μ ]⟶ q → q ⇒ r → p ⇒ r -- Weak transitions (one kind). data _[_]⇒_ (p : Proc) (μ : Label) (q : Proc) : Type ℓ where steps : ∀ {p′ q′} → p ⇒ p′ → p′ [ μ ]⟶ q′ → q′ ⇒ q → p [ μ ]⇒ q -- Weak transitions (another kind). data _[_]⇒̂_ (p : Proc) (μ : Label) (q : Proc) : Type ℓ where silent : Silent μ → p ⇒ q → p [ μ ]⇒̂ q non-silent : ¬ Silent μ → p [ μ ]⇒ q → p [ μ ]⇒̂ q -- Weak transitions (yet another kind). data _[_]⟶̂_ (p : Proc) (μ : Label) : Proc → Type ℓ where done : Silent μ → p [ μ ]⟶̂ p step : ∀ {q} → p [ μ ]⟶ q → p [ μ ]⟶̂ q -- Functions that can be used to aid the instance resolution -- mechanism. infix -2 ⟶:_ ⇒:_ []⇒:_ ⇒̂:_ ⟶̂:_ ⟶:_ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⟶ q ⟶:_ = id ⇒:_ : ∀ {p q} → p ⇒ q → p ⇒ q ⇒:_ = id []⇒:_ : ∀ {p μ q} → p [ μ ]⇒ q → p [ μ ]⇒ q []⇒:_ = id ⇒̂:_ : ∀ {p μ q} → p [ μ ]⇒̂ q → p [ μ ]⇒̂ q ⇒̂:_ = id ⟶̂:_ : ∀ {p μ q} → p [ μ ]⟶̂ q → p [ μ ]⟶̂ q ⟶̂:_ = id -- An "equational" reasoning combinator that is not subsumed by the -- combinators in Equational-reasoning, because the types of the two -- main arguments and the result use three different relations. infixr -2 ⟶⇒→[]⇒ ⟶⇒→[]⇒ : ∀ p μ {q r} → p [ μ ]⟶ q → q ⇒ r → p [ μ ]⇒ r ⟶⇒→[]⇒ _ _ = steps done syntax ⟶⇒→[]⇒ p μ p⟶q q⇒r = p [ μ ]⇒⟨ p⟶q ⟩ q⇒r -- Combinators that can be used to add visible type information to -- an expression. infix -1 step-with-action step-without-action step-with-action : ∀ p μ q → p [ μ ]⟶ q → p [ μ ]⟶ q step-with-action _ _ _ p⟶q = p⟶q step-without-action : ∀ p {μ} q → p [ μ ]⟶ q → p [ μ ]⟶ q step-without-action _ _ p⟶q = p⟶q syntax step-with-action p μ q p⟶q = p [ μ ]⟶⟨ p⟶q ⟩ q syntax step-without-action p q p⟶q = p ⟶⟨ p⟶q ⟩ q -- Regular transitions can (sometimes) be turned into weak ones. ⟶→⇒ : ∀ {p μ q} → Silent μ → p [ μ ]⟶ q → p ⇒ q ⟶→⇒ s tr = step s tr done ⟶→[]⇒ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⇒ q ⟶→[]⇒ tr = steps done tr done ⟶→⇒̂ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⇒̂ q ⟶→⇒̂ {μ = μ} tr with silent? μ ... | yes s = silent s (⟶→⇒ s tr) ... | no ¬s = non-silent ¬s (⟶→[]⇒ tr) ⟶→⟶̂ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⟶̂ q ⟶→⟶̂ = step -- Several transitivity-like properties. ⇒-transitive : ∀ {p q r} → p ⇒ q → q ⇒ r → p ⇒ r ⇒-transitive done p⇒q = p⇒q ⇒-transitive (step s p⟶q q⇒r) r⇒s = step s p⟶q (⇒-transitive q⇒r r⇒s) ⇒[]⇒-transitive : ∀ {p q r μ} → p ⇒ q → q [ μ ]⇒ r → p [ μ ]⇒ r ⇒[]⇒-transitive p⇒q (steps q⇒r r⟶s s⇒t) = steps (⇒-transitive p⇒q q⇒r) r⟶s s⇒t []⇒⇒-transitive : ∀ {p q r μ} → p [ μ ]⇒ q → q ⇒ r → p [ μ ]⇒ r []⇒⇒-transitive (steps p⇒q q⟶r r⇒s) s⇒t = steps p⇒q q⟶r (⇒-transitive r⇒s s⇒t) ⇒⇒̂-transitive : ∀ {p q r μ} → p ⇒ q → q [ μ ]⇒̂ r → p [ μ ]⇒̂ r ⇒⇒̂-transitive p⇒q (silent s q⇒r) = silent s (⇒-transitive p⇒q q⇒r) ⇒⇒̂-transitive p⇒q (non-silent ¬s q⇒r) = non-silent ¬s (⇒[]⇒-transitive p⇒q q⇒r) ⇒̂⇒-transitive : ∀ {p q r μ} → p [ μ ]⇒̂ q → q ⇒ r → p [ μ ]⇒̂ r ⇒̂⇒-transitive (silent s p⇒q) q⇒r = silent s (⇒-transitive p⇒q q⇒r) ⇒̂⇒-transitive (non-silent ¬s p⇒q) q⇒r = non-silent ¬s ([]⇒⇒-transitive p⇒q q⇒r) -- More conversion functions. []⇒→⇒ : ∀ {p q μ} → Silent μ → p [ μ ]⇒ q → p ⇒ q []⇒→⇒ s (steps p⇒p′ p′⟶p″ p″⇒p‴) = ⇒-transitive p⇒p′ (step s p′⟶p″ p″⇒p‴) ⇒̂→⇒ : ∀ {p q μ} → Silent μ → p [ μ ]⇒̂ q → p ⇒ q ⇒̂→⇒ s (silent _ p⇒q) = p⇒q ⇒̂→⇒ s (non-silent ¬s _) = ⊥-elim (¬s s) ⇒→⇒̂ : ∀ {p q μ} → p [ μ ]⇒ q → p [ μ ]⇒̂ q ⇒→⇒̂ {μ = μ} tr with silent? μ ... | yes s = silent s ([]⇒→⇒ s tr) ... | no ¬s = non-silent ¬s tr ⇒̂→[]⇒ : ∀ {p q μ} → ¬ Silent μ → p [ μ ]⇒̂ q → p [ μ ]⇒ q ⇒̂→[]⇒ ¬s (silent s _) = ⊥-elim (¬s s) ⇒̂→[]⇒ _ (non-silent _ tr) = tr ⟶̂→⇒̂ : ∀ {p μ q} → p [ μ ]⟶̂ q → p [ μ ]⇒̂ q ⟶̂→⇒̂ (done s) = silent s done ⟶̂→⇒̂ (step tr) = ⟶→⇒̂ tr ⟶̂→⇒ : ∀ {p q μ} → Silent μ → p [ μ ]⟶̂ q → p ⇒ q ⟶̂→⇒ s = ⇒̂→⇒ s ∘ ⟶̂→⇒̂ -- Lemmas that can be used to show that relations are weak -- simulations of various kinds. module _ {ℓ} {_%_ _%′_ : Proc → Proc → Type ℓ} {_[_]%_ : Proc → Label → Proc → Type ℓ} (left-to-right : ∀ {p q} → p % q → ∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]% q′ × p′ %′ q′) (%′⇒% : ∀ {p q} → p %′ q → p % q) (%⇒⇒ : ∀ {p p′ μ} → Silent μ → p [ μ ]% p′ → p ⇒ p′) where is-weak⇒ : ∀ {p p′ q} → p % q → p ⇒ p′ → ∃ λ q′ → q ⇒ q′ × (p′ % q′) is-weak⇒ p%q done = _ , done , p%q is-weak⇒ p%q (step s p⟶p′ p′⇒p″) = let q′ , q%q′ , p′%′q′ = left-to-right p%q p⟶p′ q″ , q′⇒q″ , p″%q″ = is-weak⇒ (%′⇒% p′%′q′) p′⇒p″ in q″ , ⇒-transitive (%⇒⇒ s q%q′) q′⇒q″ , p″%q″ is-weak[]⇒ : ∀ {p p′ q μ} → (∀ {p p′} → p [ μ ]% p′ → p [ μ ]⇒ p′) → p % q → p [ μ ]⇒ p′ → ∃ λ q′ → q [ μ ]⇒ q′ × (p′ % q′) is-weak[]⇒ %⇒[]⇒ p%q (steps p⇒p′ p′⟶p″ p″⇒p‴) = let q′ , q⇒q′ , p′%q′ = is-weak⇒ p%q p⇒p′ q″ , q′%q″ , p″%′q″ = left-to-right p′%q′ p′⟶p″ q‴ , q″⇒q‴ , p‴%q‴ = is-weak⇒ (%′⇒% p″%′q″) p″⇒p‴ in q‴ , ⇒[]⇒-transitive q⇒q′ ([]⇒⇒-transitive (%⇒[]⇒ q′%q″) q″⇒q‴) , p‴%q‴ is-weak⇒̂ : ∀ {p p′ q μ} → (∀ {p p′} → p [ μ ]% p′ → p [ μ ]⇒̂ p′) → p % q → p [ μ ]⇒̂ p′ → ∃ λ q′ → q [ μ ]⇒̂ q′ × (p′ % q′) is-weak⇒̂ _ q%r (silent s q⇒q′) = Σ-map id (Σ-map (silent s) id) (is-weak⇒ q%r q⇒q′) is-weak⇒̂ %⇒⇒̂ q%r (non-silent ¬s q⇒q′) = Σ-map id (Σ-map ⇒→⇒̂ id) (is-weak[]⇒ (⇒̂→[]⇒ ¬s ∘ %⇒⇒̂) q%r q⇒q′) -- If no action is silent, then _[_]⇒_ is pointwise isomorphic to -- _[_]⟶_. ⟶↔⇒ : (∀ μ → ¬ Silent μ) → ∀ {p μ q} → p [ μ ]⟶ q ↔ p [ μ ]⇒ q ⟶↔⇒ ¬silent = record { surjection = record { logical-equivalence = record { to = ⟶→[]⇒ ; from = λ { (steps (step s _ _) _ _) → ⊥-elim (¬silent _ s) ; (steps _ _ (step s _ _)) → ⊥-elim (¬silent _ s) ; (steps done tr done) → tr } } ; right-inverse-of = λ { (steps (step s _ _) _ _) → ⊥-elim (¬silent _ s) ; (steps _ _ (step s _ _)) → ⊥-elim (¬silent _ s) ; (steps done tr done) → refl } } ; left-inverse-of = λ _ → refl } -- If no action is silent, then _[_]⇒̂_ is pointwise logically -- equivalent to _[_]⟶_, and in the presence of extensionality they -- are pointwise isomorphic. ⟶↔⇒̂ : ∀ {k} → Extensionality? k lzero lzero → (∀ μ → ¬ Silent μ) → ∀ {p μ q} → p [ μ ]⟶ q ↝[ k ] p [ μ ]⇒̂ q ⟶↔⇒̂ ext ¬silent = generalise-ext? ⟶⇔⇒̂ (λ ext → (λ { (silent s _) → ⊥-elim (¬silent _ s) ; (non-silent _ tr) → cong₂ non-silent (apply-ext ext (⊥-elim ∘ ¬silent _)) (_↔_.right-inverse-of (⟶↔⇒ ¬silent) tr) }) , (λ _ → refl)) ext where ⟶⇔⇒̂ = record { to = λ tr → non-silent (¬silent _) (_↔_.to (⟶↔⇒ ¬silent) tr) ; from = λ { (silent s _) → ⊥-elim (¬silent _ s) ; (non-silent _ tr) → _↔_.from (⟶↔⇒ ¬silent) tr } } -- Map-like functions. map-⇒′ : {F : Proc → Proc} → (∀ {p p′ μ} → Silent μ → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p ⇒ p′ → F p ⇒ F p′ map-⇒′ f done = done map-⇒′ f (step s p⟶p′ p′⇒p″) = step s (f s p⟶p′) (map-⇒′ f p′⇒p″) map-⇒ : {F : Proc → Proc} → (∀ {p p′ μ} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p ⇒ p′ → F p ⇒ F p′ map-⇒ f = map-⇒′ (λ _ → f) map-[]⇒′ : ∀ {μ} {F : Proc → Proc} → (∀ {p p′ μ} → Silent μ → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → (∀ {p p′} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p [ μ ]⇒ p′ → F p [ μ ]⇒ F p′ map-[]⇒′ f g (steps p⇒p′ p′⟶p″ p″⇒p‴) = steps (map-⇒′ f p⇒p′) (g p′⟶p″) (map-⇒′ f p″⇒p‴) map-[]⇒ : {F : Proc → Proc} → (∀ {p p′ μ} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′ μ} → p [ μ ]⇒ p′ → F p [ μ ]⇒ F p′ map-[]⇒ f = map-[]⇒′ (λ _ → f) f map-⇒̂′ : ∀ {μ} {F : Proc → Proc} → (∀ {p p′ μ} → Silent μ → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → (∀ {p p′} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p [ μ ]⇒̂ p′ → F p [ μ ]⇒̂ F p′ map-⇒̂′ f g (silent s p⇒p′) = silent s (map-⇒′ f p⇒p′) map-⇒̂′ f g (non-silent ¬s p⇒p′) = non-silent ¬s (map-[]⇒′ f g p⇒p′) map-⇒̂ : {F : Proc → Proc} → (∀ {p p′ μ} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′ μ} → p [ μ ]⇒̂ p′ → F p [ μ ]⇒̂ F p′ map-⇒̂ f = map-⇒̂′ (λ _ → f) f map-⟶̂ : ∀ {μ p p′} {F : Proc → Proc} → (p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → p [ μ ]⟶̂ p′ → F p [ μ ]⟶̂ F p′ map-⟶̂ f (done s) = done s map-⟶̂ f (step p⟶p′) = step (f p⟶p′) -- Zip-like functions. module _ {F : Proc → Proc → Proc} (f : ∀ {p p′ q μ} → p [ μ ]⟶ p′ → F p q [ μ ]⟶ F p′ q) (g : ∀ {p q q′ μ} → q [ μ ]⟶ q′ → F p q [ μ ]⟶ F p q′) where zip-⇒ : ∀ {p p′ q q′} → p ⇒ p′ → q ⇒ q′ → F p q ⇒ F p′ q′ zip-⇒ done done = done zip-⇒ done (step s q⟶q′ q′⇒q″) = step s (g q⟶q′) (zip-⇒ done q′⇒q″) zip-⇒ (step s p⟶p′ p′⇒p″) tr = step s (f p⟶p′) (zip-⇒ p′⇒p″ tr) zip-[]⇒ˡ′ : ∀ {p p′ q q′ μ₁ μ₃} → (∀ {p p′ q} → p [ μ₁ ]⟶ p′ → F p q [ μ₃ ]⟶ F p′ q) → p [ μ₁ ]⇒ p′ → q ⇒ q′ → F p q [ μ₃ ]⇒ F p′ q′ zip-[]⇒ˡ′ h (steps p⇒p′ p′⟶p″ p″⇒p‴) q⇒q′ = steps (zip-⇒ p⇒p′ q⇒q′) (h p′⟶p″) (zip-⇒ p″⇒p‴ done) zip-[]⇒ˡ : ∀ {p p′ q q′ μ} → p [ μ ]⇒ p′ → q ⇒ q′ → F p q [ μ ]⇒ F p′ q′ zip-[]⇒ˡ = zip-[]⇒ˡ′ f zip-[]⇒ʳ′ : ∀ {p p′ q q′ μ₂ μ₃} → (∀ {p q q′} → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p q′) → p ⇒ p′ → q [ μ₂ ]⇒ q′ → F p q [ μ₃ ]⇒ F p′ q′ zip-[]⇒ʳ′ h p⇒p′ (steps q⇒q′ q′⟶q″ q″⇒q‴) = steps (zip-⇒ p⇒p′ q⇒q′) (h q′⟶q″) (zip-⇒ done q″⇒q‴) zip-[]⇒ʳ : ∀ {p p′ q q′ μ} → p ⇒ p′ → q [ μ ]⇒ q′ → F p q [ μ ]⇒ F p′ q′ zip-[]⇒ʳ = zip-[]⇒ʳ′ g zip-[]⇒ : ∀ {μ₁ μ₂ μ₃} → (∀ {p p′ q q′} → p [ μ₁ ]⟶ p′ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p′ q′) → ∀ {p p′ q q′} → p [ μ₁ ]⇒ p′ → q [ μ₂ ]⇒ q′ → F p q [ μ₃ ]⇒ F p′ q′ zip-[]⇒ h (steps p⇒p′ p′⟶p″ p″⇒p‴) (steps q⇒q′ q′⟶q″ q″⇒q‴) = steps (zip-⇒ p⇒p′ q⇒q′) (h p′⟶p″ q′⟶q″) (zip-⇒ p″⇒p‴ q″⇒q‴) zip-⇒̂ : ∀ {μ₁ μ₂ μ₃} → (Silent μ₁ → Silent μ₂ → Silent μ₃) → (∀ {p p′ q} → p [ μ₁ ]⟶ p′ → Silent μ₂ → F p q [ μ₃ ]⟶ F p′ q) → (∀ {p q q′} → Silent μ₁ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p q′) → (∀ {p p′ q q′} → p [ μ₁ ]⟶ p′ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p′ q′) → ∀ {p p′ q q′} → p [ μ₁ ]⇒̂ p′ → q [ μ₂ ]⇒̂ q′ → F p q [ μ₃ ]⇒̂ F p′ q′ zip-⇒̂ fs hˡ hʳ h = λ where (silent s₁ tr₁) (silent s₂ tr₂) → silent (fs s₁ s₂) (zip-⇒ tr₁ tr₂) (silent s₁ tr₁) (non-silent ¬s₂ tr₂) → ⇒→⇒̂ (zip-[]⇒ʳ′ (hʳ s₁) tr₁ tr₂) (non-silent ¬s₁ tr₁) (silent s₂ tr₂) → ⇒→⇒̂ (zip-[]⇒ˡ′ (flip hˡ s₂) tr₁ tr₂) (non-silent ¬s₁ tr₁) (non-silent ¬s₂ tr₂) → ⇒→⇒̂ (zip-[]⇒ h tr₁ tr₂) zip-⟶̂ : ∀ {F : Proc → Proc → Proc} {μ₁ μ₂ μ₃} → (Silent μ₁ → Silent μ₂ → Silent μ₃) → (∀ {p p′ q} → p [ μ₁ ]⟶ p′ → Silent μ₂ → F p q [ μ₃ ]⟶ F p′ q) → (∀ {p q q′} → Silent μ₁ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p q′) → (∀ {p p′ q q′} → p [ μ₁ ]⟶ p′ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p′ q′) → ∀ {p p′ q q′} → p [ μ₁ ]⟶̂ p′ → q [ μ₂ ]⟶̂ q′ → F p q [ μ₃ ]⟶̂ F p′ q′ zip-⟶̂ s f g h (done s₁) (done s₂) = done (s s₁ s₂) zip-⟶̂ s f g h (done s₁) (step q⟶q′) = step (g s₁ q⟶q′) zip-⟶̂ s f g h (step p⟶p′) (done s₂) = step (f p⟶p′ s₂) zip-⟶̂ s f g h (step p⟶p′) (step q⟶q′) = step (h p⟶p′ q⟶q′) -- Transforms an LTS into one which uses weak transitions as -- transitions. weak : ∀ {ℓ} → LTS ℓ → LTS ℓ weak lts = record { Proc = Proc ; Label = Label ; _[_]⟶_ = _[_]⇒̂_ ; is-silent = is-silent } where open LTS lts -- If no lts action is silent, then weak lts is equal to lts (assuming -- extensionality and univalence). weak≡id : ∀ {ℓ} → Extensionality ℓ (lsuc ℓ) → Univalence ℓ → (lts : LTS ℓ) → (∀ μ → ¬ LTS.Silent lts μ) → weak lts ≡ lts weak≡id ext univ lts ¬silent = cong (λ _[_]⟶_ → record { Proc = Proc ; Label = Label ; _[_]⟶_ = _[_]⟶_ ; is-silent = is-silent }) (apply-ext ext λ p → apply-ext ext λ μ → apply-ext ext λ q → p [ μ ]⇒̂ q ≡⟨ ≃⇒≡ univ $ ↔⇒≃ $ inverse $ ⟶↔⇒̂ (lower-extensionality _ _ ext) ¬silent ⟩∎ p [ μ ]⟶ q ∎) where open LTS lts -- An LTS with no processes or labels. empty : LTS lzero empty = record { Proc = ⊥ ; Label = ⊥ ; _[_]⟶_ = λ () ; is-silent = λ () } -- An LTS with a single process, a single (non-silent) label, and a -- single transition. one-loop : LTS lzero one-loop = record { Proc = ⊤ ; Label = ⊤ ; _[_]⟶_ = λ _ _ _ → ⊤ ; is-silent = λ _ → false } -- An LTS with two distinct, but bisimilar, processes. There are -- transitions between the two processes. two-bisimilar-processes : LTS lzero two-bisimilar-processes = record { Proc = Bool ; Label = ⊤ ; _[_]⟶_ = λ _ _ _ → ⊤ ; is-silent = λ _ → false } -- A parametrised LTS for which bisimilarity is logically equivalent -- to equality. bisimilarity⇔equality : ∀ {ℓ} → Type ℓ → LTS ℓ bisimilarity⇔equality A = record { Proc = A ; Label = A ; _[_]⟶_ = λ p μ q → p ≡ μ × p ≡ q ; is-silent = λ _ → false }
{ "alphanum_fraction": 0.4261885999, "avg_line_length": 31.0775510204, "ext": "agda", "hexsha": "c66578ec344adeaed99c9874e4f33f6e74ef153b", "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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Labelled-transition-system.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "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/up-to", "max_issues_repo_path": "src/Labelled-transition-system.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Labelled-transition-system.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7735, "size": 15228 }
{- following Johnstone's book "Stone Spaces" we define semilattices to be commutative monoids such that every element is idempotent. In particular, we take every semilattice to have a neutral element that is either the maximal or minimal element depending on whether we have a join or meet semilattice. -} {-# OPTIONS --safe #-} module Cubical.Algebra.Semilattice.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.CommMonoid open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open import Cubical.Relation.Binary open import Cubical.Relation.Binary.Poset open import Cubical.Reflection.RecordEquiv open Iso private variable ℓ ℓ' : Level record IsSemilattice {A : Type ℓ} (ε : A) (_·_ : A → A → A) : Type ℓ where constructor issemilattice field isCommMonoid : IsCommMonoid ε _·_ idem : (x : A) → x · x ≡ x open IsCommMonoid isCommMonoid public unquoteDecl IsSemilatticeIsoΣ = declareRecordIsoΣ IsSemilatticeIsoΣ (quote IsSemilattice) record SemilatticeStr (A : Type ℓ) : Type ℓ where constructor semilatticestr field ε : A _·_ : A → A → A isSemilattice : IsSemilattice ε _·_ infixl 7 _·_ open IsSemilattice isSemilattice public Semilattice : ∀ ℓ → Type (ℓ-suc ℓ) Semilattice ℓ = TypeWithStr ℓ SemilatticeStr semilattice : (A : Type ℓ) (ε : A) (_·_ : A → A → A) (h : IsSemilattice ε _·_) → Semilattice ℓ semilattice A ε _·_ h = A , semilatticestr ε _·_ h -- Easier to use constructors makeIsSemilattice : {L : Type ℓ} {ε : L} {_·_ : L → L → L} (is-setL : isSet L) (assoc : (x y z : L) → x · (y · z) ≡ (x · y) · z) (rid : (x : L) → x · ε ≡ x) (lid : (x : L) → ε · x ≡ x) (comm : (x y : L) → x · y ≡ y · x) (idem : (x : L) → x · x ≡ x) → IsSemilattice ε _·_ IsSemilattice.isCommMonoid (makeIsSemilattice is-setL assoc rid lid comm idem) = makeIsCommMonoid is-setL assoc rid lid comm IsSemilattice.idem (makeIsSemilattice is-setL assoc rid lid comm idem) = idem makeSemilattice : {L : Type ℓ} (ε : L) (_·_ : L → L → L) (is-setL : isSet L) (assoc : (x y z : L) → x · (y · z) ≡ (x · y) · z) (rid : (x : L) → x · ε ≡ x) (lid : (x : L) → ε · x ≡ x) (comm : (x y : L) → x · y ≡ y · x) (idem : (x : L) → x · x ≡ x) → Semilattice ℓ makeSemilattice ε _·_ is-setL assoc rid lid comm idem = semilattice _ ε _·_ (makeIsSemilattice is-setL assoc rid lid comm idem) SemilatticeStr→MonoidStr : {A : Type ℓ} → SemilatticeStr A → MonoidStr A SemilatticeStr→MonoidStr (semilatticestr _ _ H) = monoidstr _ _ (H .IsSemilattice.isCommMonoid .IsCommMonoid.isMonoid) Semilattice→Monoid : Semilattice ℓ → Monoid ℓ Semilattice→Monoid (_ , semilatticestr _ _ H) = _ , monoidstr _ _ (H .IsSemilattice.isCommMonoid .IsCommMonoid.isMonoid) Semilattice→CommMonoid : Semilattice ℓ → CommMonoid ℓ Semilattice→CommMonoid (_ , semilatticestr _ _ H) = _ , commmonoidstr _ _ (H .IsSemilattice.isCommMonoid) SemilatticeHom : (L : Semilattice ℓ) (M : Semilattice ℓ') → Type (ℓ-max ℓ ℓ') SemilatticeHom L M = MonoidHom (Semilattice→Monoid L) (Semilattice→Monoid M) IsSemilatticeEquiv : {A : Type ℓ} {B : Type ℓ'} (M : SemilatticeStr A) (e : A ≃ B) (N : SemilatticeStr B) → Type (ℓ-max ℓ ℓ') IsSemilatticeEquiv M e N = IsMonoidHom (SemilatticeStr→MonoidStr M) (e .fst) (SemilatticeStr→MonoidStr N) SemilatticeEquiv : (M : Semilattice ℓ) (N : Semilattice ℓ') → Type (ℓ-max ℓ ℓ') SemilatticeEquiv M N = Σ[ e ∈ (M .fst ≃ N .fst) ] IsSemilatticeEquiv (M .snd) e (N .snd) isPropIsSemilattice : {L : Type ℓ} (ε : L) (_·_ : L → L → L) → isProp (IsSemilattice ε _·_) isPropIsSemilattice ε _·_ (issemilattice LL LC) (issemilattice SL SC) = λ i → issemilattice (isPropIsCommMonoid _ _ LL SL i) (isPropIdem LC SC i) where isSetL : isSet _ isSetL = LL .IsCommMonoid.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropIdem : isProp ((x : _) → x · x ≡ x) isPropIdem = isPropΠ λ _ → isSetL _ _ 𝒮ᴰ-Semilattice : DUARel (𝒮-Univ ℓ) SemilatticeStr ℓ 𝒮ᴰ-Semilattice = 𝒮ᴰ-Record (𝒮-Univ _) IsSemilatticeEquiv (fields: data[ ε ∣ autoDUARel _ _ ∣ presε ] data[ _·_ ∣ autoDUARel _ _ ∣ isHom ] prop[ isSemilattice ∣ (λ _ _ → isPropIsSemilattice _ _) ]) where open SemilatticeStr open IsMonoidHom SemilatticePath : (L K : Semilattice ℓ) → SemilatticeEquiv L K ≃ (L ≡ K) SemilatticePath = ∫ 𝒮ᴰ-Semilattice .UARel.ua -- TODO: decide if that's the right approach module JoinSemilattice (L' : Semilattice ℓ) where private L = fst L' open SemilatticeStr (snd L') renaming (_·_ to _∨l_ ; ε to 1l) open CommMonoidTheory (Semilattice→CommMonoid L') _≤_ : L → L → Type ℓ x ≤ y = x ∨l y ≡ y infix 4 _≤_ IndPoset : Poset ℓ ℓ fst IndPoset = L PosetStr._≤_ (snd IndPoset) = _≤_ IsPoset.is-set (PosetStr.isPoset (snd IndPoset)) = is-set IsPoset.is-prop-valued (PosetStr.isPoset (snd IndPoset)) = λ _ _ → is-set _ _ IsPoset.is-refl (PosetStr.isPoset (snd IndPoset)) = idem IsPoset.is-trans (PosetStr.isPoset (snd IndPoset)) = path where path : (a b c : L) → a ∨l b ≡ b → b ∨l c ≡ c → a ∨l c ≡ c path a b c a∨b≡b b∨c≡c = a ∨l c ≡⟨ cong (a ∨l_) (sym b∨c≡c) ⟩ a ∨l (b ∨l c) ≡⟨ assoc _ _ _ ⟩ (a ∨l b) ∨l c ≡⟨ cong (_∨l c) a∨b≡b ⟩ b ∨l c ≡⟨ b∨c≡c ⟩ c ∎ IsPoset.is-antisym (PosetStr.isPoset (snd IndPoset)) = λ _ _ a∨b≡b b∨a≡a → sym b∨a≡a ∙∙ comm _ _ ∙∙ a∨b≡b ∨lIsMax : ∀ x y z → x ≤ z → y ≤ z → x ∨l y ≤ z ∨lIsMax x y z x≤z y≤z = cong ((x ∨l y) ∨l_) (sym (idem z)) ∙ commAssocSwap x y z z ∙ cong₂ (_∨l_) x≤z y≤z ∙ idem z ≤-∨Pres : ∀ x y u w → x ≤ y → u ≤ w → x ∨l u ≤ y ∨l w ≤-∨Pres x y u w x≤y u≤w = commAssocSwap x u y w ∙ cong₂ (_∨l_) x≤y u≤w ≤-∨LPres : ∀ x y z → x ≤ y → z ∨l x ≤ z ∨l y ≤-∨LPres x y z x≤y = ≤-∨Pres _ _ _ _ (idem z) x≤y module MeetSemilattice (L' : Semilattice ℓ) where private L = fst L' open SemilatticeStr (snd L') renaming (_·_ to _∧l_ ; ε to 0l) open CommMonoidTheory (Semilattice→CommMonoid L') _≤_ : L → L → Type ℓ x ≤ y = x ∧l y ≡ x infix 4 _≤_ IndPoset : Poset ℓ ℓ fst IndPoset = L PosetStr._≤_ (snd IndPoset) = _≤_ IsPoset.is-set (PosetStr.isPoset (snd IndPoset)) = is-set IsPoset.is-prop-valued (PosetStr.isPoset (snd IndPoset)) = λ _ _ → is-set _ _ IsPoset.is-refl (PosetStr.isPoset (snd IndPoset)) = idem IsPoset.is-trans (PosetStr.isPoset (snd IndPoset)) = path where path : (a b c : L) → a ∧l b ≡ a → b ∧l c ≡ b → a ∧l c ≡ a path a b c a∧b≡a b∧c≡b = a ∧l c ≡⟨ cong (_∧l c) (sym a∧b≡a) ⟩ (a ∧l b) ∧l c ≡⟨ sym (assoc _ _ _) ⟩ a ∧l (b ∧l c) ≡⟨ cong (a ∧l_) b∧c≡b ⟩ a ∧l b ≡⟨ a∧b≡a ⟩ a ∎ IsPoset.is-antisym (PosetStr.isPoset (snd IndPoset)) = λ _ _ a∧b≡a b∧a≡b → sym a∧b≡a ∙∙ comm _ _ ∙∙ b∧a≡b ≤-∧LPres : ∀ x y z → x ≤ y → z ∧l x ≤ z ∧l y ≤-∧LPres x y z x≤y = commAssocSwap z x z y ∙∙ cong (_∧l (x ∧l y)) (idem z) ∙∙ cong (z ∧l_) x≤y ∧≤LCancel : ∀ x y → x ∧l y ≤ y ∧≤LCancel x y = sym (assoc _ _ _) ∙ cong (x ∧l_) (idem y) ∧≤RCancel : ∀ x y → x ∧l y ≤ x ∧≤RCancel x y = commAssocr x y x ∙ cong (_∧l y) (idem x) ∧lIsMin : ∀ x y z → z ≤ x → z ≤ y → z ≤ x ∧l y ∧lIsMin x y z z≤x z≤y = cong (_∧l (x ∧l y)) (sym (idem z)) ∙ commAssocSwap z z x y ∙ cong₂ (_∧l_) z≤x z≤y ∙ idem z
{ "alphanum_fraction": 0.5900154891, "avg_line_length": 36.8114035088, "ext": "agda", "hexsha": "008c068f8ab18cb7bc32bc9e6363e4edf7d9f2f7", "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": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dolio/cubical", "max_forks_repo_path": "Cubical/Algebra/Semilattice/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "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": "dolio/cubical", "max_issues_repo_path": "Cubical/Algebra/Semilattice/Base.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dolio/cubical", "max_stars_repo_path": "Cubical/Algebra/Semilattice/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3249, "size": 8393 }
-- Reported by Nils Anders Danielsson in Issue #3960. open import Agda.Builtin.Unit open import Agda.Primitive id : ∀ {a} (A : Set a) → A → A id _ a = a apply : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B apply = λ x f → f x postulate P : ∀ {a} {A : Set a} → A → A → Set a Q : ∀ {ℓ} → Set ℓ → Set ℓ Q A = {x y : A} → P x y postulate F : ∀ {a b} → Set a → Set b → Set (a ⊔ b) f : ∀ {a b} {A : Set a} {B : Set b} → Q A → Q (F A B) g : ∀ {a} (A : Set a) → Q A → ⊤ g A q = apply (λ {_ _} → f q) (id (Q (F A A) → ⊤) _) -- The previous error message was: -- -- Cannot instantiate the metavariable _47 to solution -- piSort _49 (λ z → Set (a ⊔ _b_54 (A = A) (q = q))) -- since it contains the variable a -- which is not in scope of the metavariable or irrelevant in the metavariable but relevant in the solution -- when checking that the expression λ {_} → f q has type -- {_ = z : _50} → P (_x_59 (A = A) (q = q)) (_y_60 (A = A) (q = q))
{ "alphanum_fraction": 0.5472689076, "avg_line_length": 28.8484848485, "ext": "agda", "hexsha": "b3f3276448cdb4c83dc70c1f72fbbf65d9411022", "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/Issue3982.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/Issue3982.agda", "max_line_length": 107, "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/Issue3982.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 378, "size": 952 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary.Raw.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function using (_∘_; _$_; flip; id) open import Cubical.Relation.Binary.Base open import Cubical.Relation.Binary.Raw.Definitions open import Cubical.Relation.Nullary.Decidable open import Cubical.Data.Maybe using (just; nothing; Dec→Maybe; map-Maybe) open import Cubical.Data.Sum.Base as Sum using (inl; inr) open import Cubical.Data.Prod.Base using (_,_) open import Cubical.Data.Empty using (⊥; isProp⊥) renaming (elim to ⊥-elim) open import Cubical.HITs.PropositionalTruncation private variable a b ℓ ℓ₁ ℓ₂ ℓ₃ p : Level A : Type a B : Type b ------------------------------------------------------------------------ -- Equality properties ≡Reflexive : Reflexive (Path A) ≡Reflexive = refl ≡Symmetric : Symmetric (Path A) ≡Symmetric = sym ≡Transitive : Transitive (Path A) ≡Transitive = _∙_ ≡Substitutive : Substitutive (Path A) ℓ ≡Substitutive P = subst P ------------------------------------------------------------------------ -- Implication properties ⇒-refl : Reflexive (_⇒_ {A = A} {B = A} {ℓ = ℓ}) ⇒-refl = id ⇒-trans : Trans (_⇒_ {A = A} {B = B} {ℓ = ℓ₁} {ℓ′ = ℓ₂}) (_⇒_ {ℓ′ = ℓ₃}) _⇒_ -- Transitive _⇒_ ⇒-trans f g x = g (f x) ------------------------------------------------------------------------ -- Substitutive properties module _ (_∼_ : RawRel A ℓ₁) (P : RawRel A p) where subst→respˡ : Substitutive _∼_ p → P Respectsˡ _∼_ subst→respˡ subst {y} x′∼x Px′y = subst (flip P y) x′∼x Px′y subst→respʳ : Substitutive _∼_ p → P Respectsʳ _∼_ subst→respʳ subst {x} y′∼y Pxy′ = subst (P x) y′∼y Pxy′ subst→resp₂ : Substitutive _∼_ p → P Respects₂ _∼_ subst→resp₂ subst = subst→respʳ subst , subst→respˡ subst module _ (_∼_ : RawRel A ℓ) (P : A → Type p) where P-resp→¬P-resp : Symmetric _∼_ → P Respects _∼_ → (¬_ ∘ P) Respects _∼_ P-resp→¬P-resp sym resp x∼y ¬Px Py = ¬Px (resp (sym x∼y) Py) Respectsʳ≡ : (_∼_ : RawRel A ℓ) → _∼_ Respectsʳ _≡_ Respectsʳ≡ _∼_ = subst→respʳ _≡_ _∼_ ≡Substitutive Respectsˡ≡ : (_∼_ : RawRel A ℓ) → _∼_ Respectsˡ _≡_ Respectsˡ≡ _∼_ = subst→respˡ _≡_ _∼_ ≡Substitutive Respects₂≡ : (_∼_ : RawRel A ℓ) → _∼_ Respects₂ _≡_ Respects₂≡ _∼_ = subst→resp₂ _≡_ _∼_ ≡Substitutive ------------------------------------------------------------------------ -- Proofs for non-strict orders module _ (_≤_ : RawRel A ℓ) where total→FromEq : Total _≤_ → FromEq _≤_ total→FromEq total {x} {y} x≡y with total x y ... | inl x∼y = x∼y ... | inr y∼x = Respectsʳ≡ _≤_ x≡y (Respectsˡ≡ _≤_ (sym x≡y) y∼x) total∧dec→dec : FromEq _≤_ → Antisymmetric _≤_ → Total _≤_ → Discrete A → Decidable _≤_ total∧dec→dec reflx antisym total _≟_ x y with total x y ... | inl x≤y = yes x≤y ... | inr y≤x = mapDec reflx (flip antisym y≤x) (x ≟ y) where mapDec : ∀ {A : Type a} {B : Type b} → (A → B) → (B → A) → Dec A → Dec B mapDec f g (yes x) = yes (f x) mapDec f g (no ¬x) = no (¬x ∘ g) ------------------------------------------------------------------------ -- Proofs for strict orders module _ (_<_ : RawRel A ℓ) where trans∧irr→asym : Transitive _<_ → Irreflexive _<_ → Asymmetric _<_ trans∧irr→asym transitive irrefl x<y y<x = irrefl (transitive x<y y<x) irr∧antisym→asym : Irreflexive _<_ → Antisymmetric _<_ → Asymmetric _<_ irr∧antisym→asym irrefl antisym x<y y<x = irrefl→tonoteq irrefl x<y (antisym x<y y<x) where irrefl→tonoteq : Irreflexive _<_ → ToNotEq _<_ irrefl→tonoteq irrefl {x} {y} x<y x≡y = irrefl (subst (λ z → x < z) (sym x≡y) x<y) asym→antisym : Asymmetric _<_ → Antisymmetric _<_ asym→antisym asym x<y y<x = ⊥-elim (asym x<y y<x) asym→irr : Asymmetric _<_ → Irreflexive _<_ asym→irr asym {x} x<x = asym x<x x<x tri→asym : Trichotomous _<_ → Asymmetric _<_ tri→asym compare {x} {y} x<y x>y with compare x y ... | tri< _ _ x≯y = x≯y x>y ... | tri≡ _ _ x≯y = x≯y x>y ... | tri> x≮y _ _ = x≮y x<y tri→irr : Trichotomous _<_ → Irreflexive _<_ tri→irr compare {x} x<x with compare x x ... | tri< _ _ x≮x = x≮x x<x ... | tri≡ _ _ x≮x = x≮x x<x ... | tri> x≮x _ _ = x≮x x<x tri→dec≡ : Trichotomous _<_ → Discrete A tri→dec≡ compare x y with compare x y ... | tri< _ x≢y _ = no x≢y ... | tri≡ _ x≡y _ = yes x≡y ... | tri> _ x≢y _ = no x≢y tri→dec< : Trichotomous _<_ → Decidable _<_ tri→dec< compare x y with compare x y ... | tri< x<y _ _ = yes x<y ... | tri≡ x≮y _ _ = no x≮y ... | tri> x≮y _ _ = no x≮y ------------------------------------------------------------------------ -- Without Loss of Generality module _ {_R_ : RawRel A ℓ₁} {Q : RawRel A ℓ₂} where wlog : Total _R_ → Symmetric Q → (∀ a b → a R b → Q a b) → ∀ a b → Q a b wlog r-total q-sym prf a b with r-total a b ... | inl aRb = prf a b aRb ... | inr bRa = q-sym (prf b a bRa) ------------------------------------------------------------------------ -- Other proofs module _ {P : RawREL A B p} where dec→weaklyDec : Decidable P → WeaklyDecidable P dec→weaklyDec dec x y = Dec→Maybe (dec x y) module _ {P : RawRel A ℓ₁} {Q : RawRel A ℓ₂} (f : P ⇒ Q) where map-Reflexive : Reflexive P → Reflexive Q map-Reflexive reflx = f reflx map-FromEq : FromEq P → FromEq Q map-FromEq fromEq p = f (fromEq p) cmap-Irreflexive : Irreflexive Q → Irreflexive P cmap-Irreflexive irrefl x≡x = irrefl (f x≡x) cmap-ToNotEq : ToNotEq Q → ToNotEq P cmap-ToNotEq toNotEq x = toNotEq (f x) module _ {P : RawREL A B ℓ₁} {Q : RawREL A B ℓ₂} (f : P ⇒ Q) where map-Universal : Universal P → Universal Q map-Universal u x y = f (u x y) map-NonEmpty : NonEmpty P → NonEmpty Q map-NonEmpty = map (λ (x , p) → (x , map (λ (y , q) → y , f q) p) ) module _ {P : RawREL A B ℓ₁} {Q : RawREL B A ℓ₂} where flip-Connex : Connex P Q → Connex Q P flip-Connex f x y = Sum.swap (f y x) module _ (_∼_ : RawRel A ℓ) where reflx→fromeq : Reflexive _∼_ → FromEq _∼_ reflx→fromeq reflx {x} = J (λ z _ → x ∼ z) reflx fromeq→reflx : FromEq _∼_ → Reflexive _∼_ fromeq→reflx fromEq = fromEq refl irrefl→tonoteq : Irreflexive _∼_ → ToNotEq _∼_ irrefl→tonoteq irrefl {x} {y} x<y x≡y = irrefl (subst (λ z → x ∼ z) (sym x≡y) x<y) tonoteq→irrefl : ToNotEq _∼_ → Irreflexive _∼_ tonoteq→irrefl toNotEq x<x = toNotEq x<x refl
{ "alphanum_fraction": 0.5736614051, "avg_line_length": 31.6764705882, "ext": "agda", "hexsha": "94c0d9efae7c517348bda395425d16f81e88caac", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Relation/Binary/Raw/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Relation/Binary/Raw/Properties.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Relation/Binary/Raw/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2603, "size": 6462 }
module examplesPaperJFP.VariableList where open import Data.Product hiding (map) open import Data.List open import NativeIO open import StateSizedIO.GUI.WxBindingsFFI open import Relation.Binary.PropositionalEquality data VarList : Set₁ where [] : VarList addVar : (A : Set) → Var A → VarList → VarList prod : VarList → Set prod [] = Unit prod (addVar A v []) = A prod (addVar A v l) = A × prod l takeVar : (l : VarList) → NativeIO (prod l) takeVar [] = nativeReturn unit takeVar (addVar A v []) = nativeTakeVar {A} v takeVar (addVar A v (addVar B v′ l)) = nativeTakeVar {A} v native>>= λ a → takeVar (addVar B v′ l) native>>= λ rest → nativeReturn ( a , rest ) putVar : (l : VarList) → prod l → NativeIO Unit putVar [] _ = nativeReturn unit putVar (addVar A v []) a = nativePutVar {A} v a putVar (addVar A v (addVar B v′ l)) (a , rest) = nativePutVar {A} v a native>>= λ _ → putVar (addVar B v′ l) rest
{ "alphanum_fraction": 0.5741935484, "avg_line_length": 29.3243243243, "ext": "agda", "hexsha": "59960ee529c756b03057ec9490531f6c28d96d17", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/examplesPaperJFP/VariableList.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/examplesPaperJFP/VariableList.agda", "max_line_length": 71, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/examplesPaperJFP/VariableList.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": 338, "size": 1085 }
{-# OPTIONS --cubical #-} module _ where open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Bool data S¹ : Set where base : S¹ loop : base ≡ base -- We cannot allow this definition as -- decideEq (loop i) base ↦ false -- but -- decideEq (loop i0) base ↦ true decideEq : ∀ (x y : S¹) → Bool decideEq base base = true decideEq (loop i) (loop j) = true decideEq x y = false
{ "alphanum_fraction": 0.6330935252, "avg_line_length": 21.9473684211, "ext": "agda", "hexsha": "24fdc9afcd11fc9a9eb53e37f68ee00e88e04c13", "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/IApplyConfluence.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/IApplyConfluence.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/IApplyConfluence.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": 139, "size": 417 }
-- Andreas, 2012-06-01, issue reported by fredrik.forsberg module Issue661 where import Common.Level data Top : Set where tt : Top mutual data Ctxt : Set1 where [] : Ctxt cons : (G : Ctxt) -> (Env G -> Set) -> Ctxt Env : Ctxt -> Set --only important that Env x doesn't reduce for x neutral Env [] = Top Env (cons G A) = Top module M (dummy : Set1) where data Uni (G : Ctxt) : Set1 where empty : Uni G sig : (A : Env G -> Set) -> Uni (cons G A) -> Uni G open M Set -- This example needs special constructor application checking -- which propagates the parameters in. c : Uni [] c = sig (\ _ -> Top) (sig (\ { tt -> Top}) empty) -- Types: -- empty : Uni _18 -- sig : (A : Env _15 → Set) → Uni (cons _15 A) → Uni _15 -- c = sig (\ _ → Top) ?2 with ?2 : Uni (cons [] (λ _ → Top)) -- ?2 := sig ?3 ?4 with -- ?3 : Env (cons [] (λ _ → Top)) → Set -- ?4 : Uni (cons (cons [] (λ _ → Top)) ?3) -- Error was: -- Type mismatch -- when checking that the pattern tt has type Env _14
{ "alphanum_fraction": 0.5759059745, "avg_line_length": 21.7234042553, "ext": "agda", "hexsha": "b024d259bb3d1f3c254e396c7f59d2b7a593ba81", "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/Issue661.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/Issue661.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue661.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": 345, "size": 1021 }
module FunSetPerBool where data Bool : Set where True : Bool False : Bool data T : Set where E : T s : Bool -> Set s True = Bool s False = T f = \ (x : s True) -> x g = f True f2 = \ (x : Bool) (y : s x) -> y h = f2 False E -- i : (xx : _) -> _ i = f2 True j : (eh : s False) -> s False j = f2 False
{ "alphanum_fraction": 0.5322580645, "avg_line_length": 14.0909090909, "ext": "agda", "hexsha": "69efe4f3fee106ed6ceb08760c0184aead0f6565", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/FunSetPerBool.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/FunSetPerBool.agda", "max_line_length": 32, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/FunSetPerBool.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 125, "size": 310 }
module Luau.Syntax.FromJSON where open import Luau.Syntax using (Block; Stat ; Expr; nil; _$_; var; function⟨_⟩_end; local_←_; function_⟨_⟩_end; return; done; _∙_) open import Agda.Builtin.List using (List; _∷_; []) open import FFI.Data.Aeson using (Value; Array; Object; object; array; string; fromString; lookup) open import FFI.Data.Bool using (true; false) open import FFI.Data.Either using (Either; Left; Right) open import FFI.Data.Maybe using (Maybe; nothing; just) open import FFI.Data.String using (String; _++_) open import FFI.Data.Vector using (head; tail; null; empty) args = fromString "args" body = fromString "body" func = fromString "func" lokal = fromString "local" list = fromString "list" name = fromString "name" type = fromString "type" values = fromString "values" vars = fromString "vars" data Lookup : Set where _,_ : String → Value → Lookup nil : Lookup lookupIn : List String → Object → Lookup lookupIn [] obj = nil lookupIn (key ∷ keys) obj with lookup (fromString key) obj lookupIn (key ∷ keys) obj | nothing = lookupIn keys obj lookupIn (key ∷ keys) obj | just value = (key , value) exprFromJSON : Value → Either String Expr exprFromObject : Object → Either String Expr statFromJSON : Value → Either String Stat statFromObject : Object → Either String Stat blockFromJSON : Value → Either String Block blockFromArray : Array → Either String Block exprFromJSON (object obj) = exprFromObject obj exprFromJSON val = Left "AstExpr not an object" exprFromObject obj with lookup type obj exprFromObject obj | just (string "AstExprCall") with lookup func obj | lookup args obj exprFromObject obj | just (string "AstExprCall") | just value | just (array arr) with head arr exprFromObject obj | just (string "AstExprCall") | just value | just (array arr) | just value2 with exprFromJSON value | exprFromJSON value2 exprFromObject obj | just (string "AstExprCall") | just value | just (array arr) | just value2 | Right fun | Right arg = Right (fun $ arg) exprFromObject obj | just (string "AstExprCall") | just value | just (array arr) | just value2 | Left err | _ = Left err exprFromObject obj | just (string "AstExprCall") | just value | just (array arr) | just value2 | _ | Left err = Left err exprFromObject obj | just (string "AstExprCall") | just value | just (array arr) | nothing = Left ("AstExprCall empty args") exprFromObject obj | just (string "AstExprCall") | just value | just _ = Left ("AstExprCall args not an array") exprFromObject obj | just (string "AstExprCall") | nothing | _ = Left ("AstExprCall missing func") exprFromObject obj | just (string "AstExprCall") | _ | nothing = Left ("AstExprCall missing args") exprFromObject obj | just (string "AstExprConstantNil") = Right nil exprFromObject obj | just (string "AstExprFunction") with lookup args obj | lookup body obj exprFromObject obj | just (string "AstExprFunction") | just (array arr) | just value with head arr | blockFromJSON value exprFromObject obj | just (string "AstExprFunction") | just (array arr) | just value | just (string x) | Right B = Right (function⟨ x ⟩ B end) exprFromObject obj | just (string "AstExprFunction") | just (array arr) | just value | just _ | Right B = Left "AstExprFunction args not a string array" exprFromObject obj | just (string "AstExprFunction") | just (array arr) | just value | nothing | Right B = Left "Unsupported AstExprFunction empty args" exprFromObject obj | just (string "AstExprFunction") | just (array arr) | just value | _ | Left err = Left err exprFromObject obj | just (string "AstExprFunction") | just _ | just _ = Left "AstExprFunction args not an array" exprFromObject obj | just (string "AstExprFunction") | nothing | _ = Left "AstExprFunction missing args" exprFromObject obj | just (string "AstExprFunction") | _ | nothing = Left "AstExprFunction missing body" exprFromObject obj | just (string "AstExprLocal") with lookup lokal obj exprFromObject obj | just (string "AstExprLocal") | just (string x) = Right (var x) exprFromObject obj | just (string "AstExprLocal") | just (_) = Left "AstExprLocal local not a string" exprFromObject obj | just (string "AstExprLocal") | nothing = Left "AstExprLocal missing local" exprFromObject obj | just (string ty) = Left ("TODO: Unsupported AstExpr " ++ ty) exprFromObject obj | just _ = Left "AstExpr type not a string" exprFromObject obj | nothing = Left "AstExpr missing type" {-# NON_TERMINATING #-} statFromJSON (object obj) = statFromObject obj statFromJSON _ = Left "AstStat not an object" statFromObject obj with lookup type obj statFromObject obj | just(string "AstStatLocal") with lookup vars obj | lookup values obj statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(array arr2) with head(arr1) | head(arr2) statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(array arr2) | just(string x) | just(value) with exprFromJSON(value) statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(array arr2) | just(string x) | just(value) | Right M = Right (local x ← M) statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(array arr2) | just(string x) | just(value) | Left err = Left err statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(array arr2) | just(string x) | nothing = Left "AstStatLocal empty values" statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(array arr2) | just(_) | _ = Left "AstStatLocal vars not a string array" statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(array arr2) | nothing | _ = Left "AstStatLocal empty vars" statFromObject obj | just(string "AstStatLocal") | just(array arr1) | just(_) = Left "AstStatLocal values not an array" statFromObject obj | just(string "AstStatLocal") | just(_) | just(_) = Left "AstStatLocal vars not an array" statFromObject obj | just(string "AstStatLocal") | just(_) | nothing = Left "AstStatLocal missing values" statFromObject obj | just(string "AstStatLocal") | nothing | _ = Left "AstStatLocal missing vars" statFromObject obj | just(string "AstStatLocalFunction") with lookup name obj | lookup func obj statFromObject obj | just(string "AstStatLocalFunction") | just (string f) | just value with exprFromJSON value statFromObject obj | just(string "AstStatLocalFunction") | just (string f) | just value | Right (function⟨ x ⟩ B end) = Right (function f ⟨ x ⟩ B end) statFromObject obj | just(string "AstStatLocalFunction") | just (string f) | just value | Left err = Left err statFromObject obj | just(string "AstStatLocalFunction") | just _ | just _ | Right _ = Left "AstStatLocalFunction func is not an AstExprFunction" statFromObject obj | just(string "AstStatLocalFunction") | just _ | just _ = Left "AstStatLocalFunction name is not a string" statFromObject obj | just(string "AstStatLocalFunction") | nothing | _ = Left "AstStatFunction missing name" statFromObject obj | just(string "AstStatLocalFunction") | _ | nothing = Left "AstStatFunction missing func" statFromObject obj | just(string "AstStatReturn") with lookup list obj statFromObject obj | just(string "AstStatReturn") | just(array arr) with head arr statFromObject obj | just(string "AstStatReturn") | just(array arr) | just value with exprFromJSON value statFromObject obj | just(string "AstStatReturn") | just(array arr) | just value | Right M = Right (return M) statFromObject obj | just(string "AstStatReturn") | just(array arr) | just value | Left err = Left err statFromObject obj | just(string "AstStatReturn") | just(array arr) | nothing = Left "AstStatReturn empty list" statFromObject obj | just(string "AstStatReturn") | just(_) = Left "AstStatReturn list not an array" statFromObject obj | just(string "AstStatReturn") | nothing = Left "AstStatReturn missing list" statFromObject obj | just (string ty) = Left ("TODO: Unsupported AstStat " ++ ty) statFromObject obj | just _ = Left "AstStat type not a string" statFromObject obj | nothing = Left "AstStat missing type" blockFromJSON (array arr) = blockFromArray arr blockFromJSON (object obj) with lookup type obj | lookup body obj blockFromJSON (object obj) | just (string "AstStatBlock") | just value = blockFromJSON value blockFromJSON (object obj) | just (string "AstStatBlock") | nothing = Left "AstStatBlock missing body" blockFromJSON (object obj) | just (string ty) | _ = Left ("Unsupported AstBlock " ++ ty) blockFromJSON (object obj) | just _ | _ = Left "AstStatBlock type not a string" blockFromJSON (object obj) | nothing | _ = Left "AstStatBlock missing type" blockFromJSON _ = Left "AstBlock not an array or AstStatBlock object" blockFromArray arr with head arr blockFromArray arr | nothing = Right done blockFromArray arr | just value with statFromJSON value blockFromArray arr | just value | Left err = Left err blockFromArray arr | just value | Right S with blockFromArray(tail arr) blockFromArray arr | just value | Right S | Left err = Left (err) blockFromArray arr | just value | Right S | Right B = Right (S ∙ B)
{ "alphanum_fraction": 0.7428983577, "avg_line_length": 71.5238095238, "ext": "agda", "hexsha": "0a4164fbcc47950e8d43b33b8749c7b4835d5b4f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FreakingBarbarians/luau", "max_forks_repo_path": "prototyping/Luau/Syntax/FromJSON.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "FreakingBarbarians/luau", "max_issues_repo_path": "prototyping/Luau/Syntax/FromJSON.agda", "max_line_length": 152, "max_stars_count": 1, "max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FreakingBarbarians/luau", "max_stars_repo_path": "prototyping/Luau/Syntax/FromJSON.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z", "num_tokens": 2388, "size": 9012 }
module BeforeSpaces where import BehindSpaces
{ "alphanum_fraction": 0.8723404255, "avg_line_length": 11.75, "ext": "agda", "hexsha": "af282b9bd5359bf60fa2995575f2ead1d52c708b", "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/BeforeSpaces.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/BeforeSpaces.agda", "max_line_length": 25, "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/BeforeSpaces.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": 9, "size": 47 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Yoneda.Continuous {o ℓ e} (C : Category o ℓ e) where open import Function.Equality using (Π) open import Relation.Binary using (Setoid) open import Categories.Category.Construction.Cones open import Categories.Category.Construction.Presheaves open import Categories.Diagram.Cone.Properties open import Categories.Diagram.Limit open import Categories.Functor open import Categories.Functor.Limits open import Categories.Functor.Hom open import Categories.Functor.Hom.Properties C open import Categories.NaturalTransformation open import Categories.Yoneda import Categories.Morphism.Reasoning as MR open Hom C open Yoneda C open Π using (_⟨$⟩_) private module C = Category C module _ {o′ ℓ′ e′} {J : Category o′ ℓ′ e′} {F : Functor J C} (L : Limit F) where private module J = Category J module F = Functor F module L = Limit L open C.HomReasoning open MR C yF = embed ∘F F ⊤ : Cone yF ⊤ = F-map-Coneˡ embed L.limit HomL : ∀ X → Limit (Hom[ X ,-] ∘F F) HomL X = hom-resp-limit X L module HomL X = Limit (HomL X) module _ {K : Cone yF} where private module K where open Cone _ K public module N = Functor N module ψ j = NaturalTransformation (ψ j) KHF : ∀ X → Cone (Hom[ X ,-] ∘F F) KHF X = record { N = K.N.₀ X ; apex = record { ψ = λ j → K.ψ.η j X ; commute = λ f eq → C.∘-resp-≈ʳ C.identityʳ ○ K.commute f eq } } ! : Cones yF [ K , ⊤ ] ! = record { arr = ntHelper record { η = λ X → Cone⇒.arr (HomL.terminal.! X {KHF X}) ; commute = λ {X Y} f {x y} eq → L.terminal.!-unique record { arr = C.id C.∘ L.rep _ C.∘ f ; commute = λ {j} → begin L.proj j C.∘ C.id C.∘ L.rep _ C.∘ f ≈⟨ refl⟩∘⟨ C.identityˡ ⟩ L.proj j C.∘ L.rep _ C.∘ f ≈⟨ pullˡ L.commute ⟩ (K.ψ.η j X ⟨$⟩ y) C.∘ f ≈˘⟨ C.identityˡ ⟩ C.id C.∘ (K.ψ.η j X ⟨$⟩ y) C.∘ f ≈˘⟨ K.ψ.commute j f eq ⟩ K.ψ.η j Y ⟨$⟩ (K.N.₁ f ⟨$⟩ x) ∎ } } ; commute = λ eq → L.commute ○ Π.cong (K.ψ.η _ _) eq } module _ (f : Cones yF [ K , ⊤ ]) where private module f where open Cone⇒ _ f public module arr = NaturalTransformation arr !-unique : Cones yF [ ! ≈ f ] !-unique {X} {x} {y} eq = L.terminal.!-unique record { arr = f.arr.η X ⟨$⟩ y ; commute = f.commute (Setoid.sym (K.N.₀ X) eq) } embed-resp-limit : Limit yF embed-resp-limit = record { terminal = record { ⊤ = ⊤ ; ⊤-is-terminal = record { ! = ! ; !-unique = !-unique } } } embed-Continous : ∀ o′ ℓ′ e′ → Continuous o′ ℓ′ e′ embed embed-Continous _ _ _ L = terminal.⊤-is-terminal where open Limit (embed-resp-limit L)
{ "alphanum_fraction": 0.5342019544, "avg_line_length": 28.9622641509, "ext": "agda", "hexsha": "1fc9415f5bb61dad60f4e3eba6ba93c66360bfcb", "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/Yoneda/Continuous.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/Yoneda/Continuous.agda", "max_line_length": 81, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Yoneda/Continuous.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": 1032, "size": 3070 }
------------------------------------------------------------------------ -- Equivalences with erased "proofs" ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Equivalence.Erased {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude as P hiding (id; [_,_]) renaming (_∘_ to _⊚_) open import Bijection eq using (_↔_) open import Equivalence eq as Eq using (_≃_; Is-equivalence) import Equivalence.Contractible-preimages eq as CP open import Equivalence.Erased.Contractible-preimages eq as ECP using (_⁻¹ᴱ_; Contractibleᴱ) import Equivalence.Half-adjoint eq as HA open import Erased.Level-1 eq as Erased hiding (module []-cong; module []-cong₁; module []-cong₂-⊔) open import Function-universe eq as F hiding (id; _∘_; inverse; from-isomorphism; step-↔; _↔⟨⟩_; _□; finally-↔; $⟨_⟩_) open import H-level eq as H-level open import H-level.Closure eq import Nat eq as Nat open import Preimage eq as Preimage using (_⁻¹_) open import Surjection eq as Surjection using (_↠_; Split-surjective) open import Tactic.Sigma-cong eq open import Univalence-axiom eq private variable a b d ℓ ℓ₁ ℓ₂ q : Level A B C D : Type a c k k′ p x y : A P Q : A → Type p f g : (x : A) → P x ------------------------------------------------------------------------ -- Some basic stuff open import Equivalence.Erased.Basics eq public private variable A≃B : A ≃ᴱ B ------------------------------------------------------------------------ -- More conversion lemmas -- In an erased context Is-equivalence and Is-equivalenceᴱ are -- pointwise equivalent. @0 Is-equivalence≃Is-equivalenceᴱ : {A : Type a} {B : Type b} {f : A → B} → Is-equivalence f ≃ Is-equivalenceᴱ f Is-equivalence≃Is-equivalenceᴱ {f = f} = (∃ λ f⁻¹ → HA.Proofs f f⁻¹) F.↔⟨ (∃-cong λ _ → F.inverse $ erased Erased↔) ⟩□ (∃ λ f⁻¹ → Erased (HA.Proofs f f⁻¹)) □ _ : _≃_.to Is-equivalence≃Is-equivalenceᴱ p ≡ Is-equivalence→Is-equivalenceᴱ p _ = refl _ @0 _ : _≃_.from Is-equivalence≃Is-equivalenceᴱ p ≡ Is-equivalenceᴱ→Is-equivalence p _ = refl _ -- In an erased context _≃_ and _≃ᴱ_ are pointwise equivalent. @0 ≃≃≃ᴱ : (A ≃ B) ≃ (A ≃ᴱ B) ≃≃≃ᴱ {A = A} {B = B} = A ≃ B F.↔⟨ Eq.≃-as-Σ ⟩ (∃ λ f → Is-equivalence f) ↝⟨ (∃-cong λ _ → Is-equivalence≃Is-equivalenceᴱ) ⟩ (∃ λ f → Is-equivalenceᴱ f) F.↔⟨ Eq.inverse ≃ᴱ-as-Σ ⟩□ A ≃ᴱ B □ _ : _≃_.to ≃≃≃ᴱ p ≡ ≃→≃ᴱ p _ = refl _ @0 _ : _≃_.from ≃≃≃ᴱ p ≡ ≃ᴱ→≃ p _ = refl _ -- A variant of F.from-isomorphism with erased type arguments. from-isomorphism : {@0 A : Type a} {@0 B : Type b} → A ↔[ k ] B → A ≃ᴱ B from-isomorphism {k = equivalence} = ≃→≃ᴱ from-isomorphism {k = bijection} = λ A↔B → let record { surjection = record { logical-equivalence = record { to = to ; from = from } } } = A↔B in ↔→≃ᴱ to from (_↔_.right-inverse-of A↔B) (_↔_.left-inverse-of A↔B) ------------------------------------------------------------------------ -- "Equational" reasoning combinators with erased type arguments infix -1 finally-≃ᴱ finally-↔ infix -1 _□ infixr -2 step-≃ᴱ step-↔ _↔⟨⟩_ infix -3 $⟨_⟩_ -- For an explanation of why step-≃ᴱ and step-↔ are defined in this -- way, see Equality.step-≡. step-≃ᴱ : (@0 A : Type a) {@0 B : Type b} {@0 C : Type c} → B ≃ᴱ C → A ≃ᴱ B → A ≃ᴱ C step-≃ᴱ _ = _∘_ syntax step-≃ᴱ A B≃ᴱC A≃ᴱB = A ≃ᴱ⟨ A≃ᴱB ⟩ B≃ᴱC step-↔ : (@0 A : Type a) {@0 B : Type b} {@0 C : Type c} → B ≃ᴱ C → A ↔[ k ] B → A ≃ᴱ C step-↔ _ B≃ᴱC A↔B = step-≃ᴱ _ B≃ᴱC (from-isomorphism A↔B) syntax step-↔ A B≃ᴱC A↔B = A ↔⟨ A↔B ⟩ B≃ᴱC _↔⟨⟩_ : (@0 A : Type a) {@0 B : Type b} → A ≃ᴱ B → A ≃ᴱ B _ ↔⟨⟩ A≃ᴱB = A≃ᴱB _□ : (@0 A : Type a) → A ≃ᴱ A A □ = id finally-≃ᴱ : (@0 A : Type a) (@0 B : Type b) → A ≃ᴱ B → A ≃ᴱ B finally-≃ᴱ _ _ A≃ᴱB = A≃ᴱB syntax finally-≃ᴱ A B A≃ᴱB = A ≃ᴱ⟨ A≃ᴱB ⟩□ B □ finally-↔ : (@0 A : Type a) (@0 B : Type b) → A ↔[ k ] B → A ≃ᴱ B finally-↔ _ _ A↔B = from-isomorphism A↔B syntax finally-↔ A B A↔B = A ↔⟨ A↔B ⟩□ B □ $⟨_⟩_ : {@0 A : Type a} {@0 B : Type b} → A → A ≃ᴱ B → B $⟨ a ⟩ A≃ᴱB = _≃ᴱ_.to A≃ᴱB a ------------------------------------------------------------------------ -- Is-equivalenceᴱ is sometimes propositional -- In an erased context Is-equivalenceᴱ f is a proposition (assuming -- extensionality). -- -- See also Is-equivalenceᴱ-propositional-for-Erased below. @0 Is-equivalenceᴱ-propositional : {A : Type a} {B : Type b} → Extensionality (a ⊔ b) (a ⊔ b) → (f : A → B) → Is-proposition (Is-equivalenceᴱ f) Is-equivalenceᴱ-propositional ext f = H-level.respects-surjection (_≃_.surjection $ Is-equivalence≃Is-equivalenceᴱ) 1 (Eq.propositional ext f) ------------------------------------------------------------------------ -- Even more conversion lemmas, and a related result -- Is-equivalenceᴱ f is logically equivalent to ECP.Is-equivalenceᴱ f. Is-equivalenceᴱ⇔Is-equivalenceᴱ-CP : {@0 A : Type a} {@0 B : Type b} {@0 f : A → B} → Is-equivalenceᴱ f ⇔ ECP.Is-equivalenceᴱ f Is-equivalenceᴱ⇔Is-equivalenceᴱ-CP {f = f} = record { to = to; from = from } where to : Is-equivalenceᴱ f → ECP.Is-equivalenceᴱ f to eq y = (proj₁₀ eq y , [ erased (proj₂ $ proj₁ eq′) ]) , [ erased (proj₂ eq′) ] where @0 eq′ : Contractibleᴱ (f ⁻¹ᴱ y) eq′ = ECP.Is-equivalence→Is-equivalenceᴱ (_⇔_.to HA.Is-equivalence⇔Is-equivalence-CP $ Is-equivalenceᴱ→Is-equivalence eq) y from : ECP.Is-equivalenceᴱ f → Is-equivalenceᴱ f from eq = proj₁₀ ⊚ proj₁₀ ⊚ eq , [ erased $ proj₂ $ Is-equivalence→Is-equivalenceᴱ $ _⇔_.from HA.Is-equivalence⇔Is-equivalence-CP $ ECP.Is-equivalenceᴱ→Is-equivalence eq ] -- Is-equivalenceᴱ f is equivalent (with erased proofs) to -- ECP.Is-equivalenceᴱ f (assuming extensionality). Is-equivalenceᴱ≃ᴱIs-equivalenceᴱ-CP : {@0 A : Type a} {@0 B : Type b} {@0 f : A → B} → @0 Extensionality (a ⊔ b) (a ⊔ b) → Is-equivalenceᴱ f ≃ᴱ ECP.Is-equivalenceᴱ f Is-equivalenceᴱ≃ᴱIs-equivalenceᴱ-CP ext = let record { to = to; from = from } = Is-equivalenceᴱ⇔Is-equivalenceᴱ-CP in ⇔→≃ᴱ (Is-equivalenceᴱ-propositional ext _) (ECP.Is-equivalenceᴱ-propositional ext _) to from -- When proving that a function is an equivalence (with erased proofs) -- one can assume that the codomain is inhabited. [inhabited→Is-equivalenceᴱ]→Is-equivalenceᴱ : {@0 A : Type a} {@0 B : Type b} {@0 f : A → B} → (B → Is-equivalenceᴱ f) → Is-equivalenceᴱ f [inhabited→Is-equivalenceᴱ]→Is-equivalenceᴱ hyp = let record { to = to; from = from } = Is-equivalenceᴱ⇔Is-equivalenceᴱ-CP in from (λ x → to (hyp x) x) ------------------------------------------------------------------------ -- Some preservation lemmas -- A variant of _×-cong_ for _≃ᴱ_. Note that all the type arguments -- are erased. infixr 2 _×-cong-≃ᴱ_ _×-cong-≃ᴱ_ : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {@0 D : Type d} → A ≃ᴱ C → B ≃ᴱ D → (A × B) ≃ᴱ (C × D) A≃ᴱC ×-cong-≃ᴱ B≃ᴱD = ↔→≃ᴱ (Σ-map (_≃ᴱ_.to A≃ᴱC) (_≃ᴱ_.to B≃ᴱD)) (Σ-map (_≃ᴱ_.from A≃ᴱC) (_≃ᴱ_.from B≃ᴱD)) (λ _ → cong₂ _,_ (_≃ᴱ_.right-inverse-of A≃ᴱC _) (_≃ᴱ_.right-inverse-of B≃ᴱD _)) (λ _ → cong₂ _,_ (_≃ᴱ_.left-inverse-of A≃ᴱC _) (_≃ᴱ_.left-inverse-of B≃ᴱD _)) -- A variant of ∃-cong for _≃ᴱ_. Note that all the type arguments are -- erased. ∃-cong-≃ᴱ : {@0 A : Type a} {@0 P : A → Type p} {@0 Q : A → Type q} → (∀ x → P x ≃ᴱ Q x) → ∃ P ≃ᴱ ∃ Q ∃-cong-≃ᴱ P≃ᴱQ = ↔→≃ᴱ (λ (x , y) → x , _≃ᴱ_.to (P≃ᴱQ x) y) (λ (x , y) → x , _≃ᴱ_.from (P≃ᴱQ x) y) (λ (x , y) → cong (x ,_) $ _≃ᴱ_.right-inverse-of (P≃ᴱQ x) y) (λ (x , y) → cong (x ,_) $ _≃ᴱ_.left-inverse-of (P≃ᴱQ x) y) -- A preservation lemma related to Σ. -- -- Note that the third argument is not marked as erased. The from -- argument of [≃]→≃ᴱ (which Agda can infer in this case, at least at -- the time of writing) is included explicitly to show where the third -- argument is used in a (potentially) non-erased context. -- -- See also Σ-cong-≃ᴱ-Erased below. Σ-cong-≃ᴱ : {@0 A : Type a} {@0 P : A → Type p} (f : A → B) (g : B → A) → (∀ x → f (g x) ≡ x) → @0 (∀ x → g (f x) ≡ x) → (∀ x → P x ≃ᴱ Q (f x)) → Σ A P ≃ᴱ Σ B Q Σ-cong-≃ᴱ {Q = Q} f g f-g g-f P≃Q = [≃]→≃ᴱ {from = λ (x , y) → g x , _≃ᴱ_.from (P≃Q (g x)) (subst Q (sym (f-g x)) y)} ([proofs] (Σ-cong (Eq.↔→≃ f g f-g g-f) (≃ᴱ→≃ ⊚ P≃Q))) -- Another preservation lemma related to Σ. -- -- See also Σ-cong-contra-≃ᴱ-Erased below. Σ-cong-contra-≃ᴱ : {@0 B : Type b} {@0 Q : B → Type q} (f : B → A) (g : A → B) → (∀ x → f (g x) ≡ x) → @0 (∀ x → g (f x) ≡ x) → (∀ x → P (f x) ≃ᴱ Q x) → Σ A P ≃ᴱ Σ B Q Σ-cong-contra-≃ᴱ f g f-g g-f P≃Q = inverse $ Σ-cong-≃ᴱ f g f-g g-f (inverse ⊚ P≃Q) -- Yet another preservation lemma related to Σ. Σ-cong-≃ᴱ′ : {@0 A : Type a} {@0 B : Type b} {@0 P : A → Type p} {@0 Q : B → Type q} (A≃ᴱB : A ≃ᴱ B) (P→Q : ∀ x → P x → Q (_≃ᴱ_.to A≃ᴱB x)) (Q→P : ∀ x → Q x → P (_≃ᴱ_.from A≃ᴱB x)) (@0 eq : ∀ x → Is-equivalence (P→Q x)) → @0 (∀ x y → Q→P x y ≡ _≃_.from Eq.⟨ P→Q (_≃ᴱ_.from A≃ᴱB x) , eq (_≃ᴱ_.from A≃ᴱB x) ⟩ (subst Q (sym (_≃ᴱ_.right-inverse-of A≃ᴱB x)) y)) → Σ A P ≃ᴱ Σ B Q Σ-cong-≃ᴱ′ {A = A} {B = B} {P = P} {Q = Q} A≃B P→Q Q→P eq hyp = [≃]→≃ᴱ ([proofs] ΣAP≃ΣBQ) where @0 ΣAP≃ΣBQ : Σ A P ≃ Σ B Q ΣAP≃ΣBQ = Eq.with-other-inverse (Σ-cong (≃ᴱ→≃ A≃B) (λ x → Eq.⟨ P→Q x , eq x ⟩)) (λ (x , y) → _≃ᴱ_.from A≃B x , Q→P x y) (λ (x , y) → cong (_ ,_) (sym (hyp x y))) -- Three preservation lemmas related to Π. -- -- See also Π-cong-≃ᴱ′-≃ᴱ, Π-cong-≃ᴱ′-≃ᴱ′, Π-cong-≃ᴱ-Erased and -- Π-cong-contra-≃ᴱ-Erased below. Π-cong-≃ᴱ : {@0 A : Type a} {B : Type b} {@0 P : A → Type p} {Q : B → Type q} → @0 Extensionality (a ⊔ b) (p ⊔ q) → (f : A → B) (g : B → A) → (∀ x → f (g x) ≡ x) → @0 (∀ x → g (f x) ≡ x) → (∀ x → P x ≃ᴱ Q (f x)) → ((x : A) → P x) ≃ᴱ ((x : B) → Q x) Π-cong-≃ᴱ {Q = Q} ext f g f-g g-f P≃Q = [≃]→≃ᴱ {to = λ h x → subst Q (f-g x) (_≃ᴱ_.to (P≃Q (g x)) (h (g x)))} ([proofs] (Π-cong ext {B₂ = Q} (Eq.↔→≃ f g f-g g-f) (≃ᴱ→≃ ⊚ P≃Q))) Π-cong-contra-≃ᴱ : {A : Type a} {@0 B : Type b} {P : A → Type p} {@0 Q : B → Type q} → @0 Extensionality (a ⊔ b) (p ⊔ q) → (f : B → A) (g : A → B) → (∀ x → f (g x) ≡ x) → @0 (∀ x → g (f x) ≡ x) → (∀ x → P (f x) ≃ᴱ Q x) → ((x : A) → P x) ≃ᴱ ((x : B) → Q x) Π-cong-contra-≃ᴱ ext f g f-g g-f P≃Q = inverse $ Π-cong-≃ᴱ ext f g f-g g-f (inverse ⊚ P≃Q) Π-cong-≃ᴱ′ : {@0 A : Type a} {@0 B : Type b} {@0 P : A → Type p} {@0 Q : B → Type q} → @0 Extensionality (a ⊔ b) (p ⊔ q) → (A≃ᴱB : A ≃ᴱ B) (P→Q : ∀ x → P (_≃ᴱ_.from A≃ᴱB x) → Q x) (Q→P : ∀ x → Q (_≃ᴱ_.to A≃ᴱB x) → P x) (@0 eq : ∀ x → Is-equivalence (Q→P x)) → @0 ((f : (x : A) → P x) (y : B) → let x = _≃ᴱ_.from A≃ᴱB y in P→Q y (f x) ≡ subst Q (_≃ᴱ_.right-inverse-of A≃ᴱB y) (_≃_.from Eq.⟨ Q→P x , eq x ⟩ (f x))) → ((x : A) → P x) ≃ᴱ ((x : B) → Q x) Π-cong-≃ᴱ′ {a = a} {p = p} {A = A} {B = B} {P = P} {Q = Q} ext A≃B P→Q Q→P eq hyp = [≃]→≃ᴱ ([proofs] ΠAP≃ΠBQ) where @0 ΠAP≃ΠBQ : ((x : A) → P x) ≃ ((x : B) → Q x) ΠAP≃ΠBQ = Eq.with-other-function (Π-cong ext (≃ᴱ→≃ A≃B) (λ x → Eq.inverse Eq.⟨ Q→P x , eq x ⟩)) (λ f x → P→Q x (f (_≃ᴱ_.from A≃B x))) (λ f → apply-ext (lower-extensionality a p ext) λ x → sym (hyp f x)) -- A variant of ∀-cong for _≃ᴱ_. ∀-cong-≃ᴱ : {@0 A : Type a} {@0 P : A → Type p} {@0 Q : A → Type q} → @0 Extensionality a (p ⊔ q) → (∀ x → P x ≃ᴱ Q x) → ((x : A) → P x) ≃ᴱ ((x : A) → Q x) ∀-cong-≃ᴱ ext P≃Q = [≃]→≃ᴱ ([proofs] (∀-cong ext (≃ᴱ→≃ ⊚ P≃Q))) -- Is-equivalenceᴱ f is equivalent (with erased proofs) to -- Is-equivalenceᴱ g if f and g are pointwise equal (assuming -- extensionality). -- -- See also Is-equivalenceᴱ-cong below. Is-equivalenceᴱ-cong-≃ᴱ : {@0 A : Type a} {@0 B : Type b} {@0 f g : A → B} → @0 Extensionality (a ⊔ b) (a ⊔ b) → @0 (∀ x → f x ≡ g x) → Is-equivalenceᴱ f ≃ᴱ Is-equivalenceᴱ g Is-equivalenceᴱ-cong-≃ᴱ ext f≡g = ∃-cong-≃ᴱ λ _ → Erased-cong-≃ᴱ (≃→≃ᴱ $ Proofs-cong ext f≡g) -- The _≃ᴱ_ operator preserves equivalences with erased proofs -- (assuming extensionality). ≃ᴱ-cong : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {@0 D : Type d} → @0 Extensionality (a ⊔ b ⊔ c ⊔ d) (a ⊔ b ⊔ c ⊔ d) → A ≃ᴱ B → C ≃ᴱ D → (A ≃ᴱ C) ≃ᴱ (B ≃ᴱ D) ≃ᴱ-cong {A = A} {B = B} {C = C} {D = D} ext A≃B C≃D = [≃]→≃ᴱ ([proofs] lemma) where @0 lemma : (A ≃ᴱ C) ≃ (B ≃ᴱ D) lemma = A ≃ᴱ C ↝⟨ F.inverse ≃≃≃ᴱ ⟩ A ≃ C ↝⟨ Eq.≃-preserves ext (≃ᴱ→≃ A≃B) (≃ᴱ→≃ C≃D) ⟩ B ≃ D ↝⟨ ≃≃≃ᴱ ⟩□ B ≃ᴱ D □ -- A variant of ↑-cong for _≃ᴱ_. ↑-cong-≃ᴱ : {@0 B : Type b} {@0 C : Type c} → B ≃ᴱ C → ↑ a B ≃ᴱ ↑ a C ↑-cong-≃ᴱ B≃ᴱC = ↔→≃ᴱ (λ (lift x) → lift (_≃ᴱ_.to B≃ᴱC x)) (λ (lift x) → lift (_≃ᴱ_.from B≃ᴱC x)) (λ _ → cong lift (_≃ᴱ_.right-inverse-of B≃ᴱC _)) (λ _ → cong lift (_≃ᴱ_.left-inverse-of B≃ᴱC _)) ------------------------------------------------------------------------ -- Variants of some lemmas from Function-universe -- A variant of drop-⊤-left-Σ. -- -- See also drop-⊤-left-Σ-≃ᴱ-Erased below. drop-⊤-left-Σ-≃ᴱ : {@0 A : Type a} {P : A → Type p} (A≃⊤ : A ≃ᴱ ⊤) → (∀ x y → P x ≃ᴱ P y) → Σ A P ≃ᴱ P (_≃ᴱ_.from A≃⊤ tt) drop-⊤-left-Σ-≃ᴱ {A = A} {P = P} A≃⊤ P≃P = Σ A P ≃ᴱ⟨ Σ-cong-≃ᴱ _ (_≃ᴱ_.from A≃⊤) refl (_≃ᴱ_.left-inverse-of A≃⊤) (λ _ → P≃P _ _) ⟩ Σ ⊤ (λ x → P (_≃ᴱ_.from A≃⊤ x)) ↔⟨ Σ-left-identity ⟩□ P (_≃ᴱ_.from A≃⊤ tt) □ -- A variant of drop-⊤-left-Π. -- -- See also drop-⊤-left-Π-≃ᴱ-Erased below. drop-⊤-left-Π-≃ᴱ : {@0 A : Type a} {P : A → Type p} → @0 Extensionality a p → (A≃⊤ : A ≃ᴱ ⊤) → (∀ x y → P x ≃ᴱ P y) → ((x : A) → P x) ≃ᴱ P (_≃ᴱ_.from A≃⊤ tt) drop-⊤-left-Π-≃ᴱ {A = A} {P = P} ext A≃⊤ P≃P = ((x : A) → P x) ≃ᴱ⟨ Π-cong-≃ᴱ ext _ (_≃ᴱ_.from A≃⊤) refl (_≃ᴱ_.left-inverse-of A≃⊤) (λ _ → P≃P _ _) ⟩ ((x : ⊤) → P (_≃ᴱ_.from A≃⊤ x)) ↔⟨ Π-left-identity ⟩□ P (_≃ᴱ_.from A≃⊤ tt) □ ------------------------------------------------------------------------ -- Lemmas relating equality between equivalences (with erased proofs) -- to equality between the forward directions of the equivalences -- In an erased context two equivalences are equal if the underlying -- functions are equal (assuming extensionality). -- -- See also to≡to→≡-Erased below. @0 to≡to→≡ : {A : Type a} {B : Type b} {p q : A ≃ᴱ B} → Extensionality (a ⊔ b) (a ⊔ b) → _≃ᴱ_.to p ≡ _≃ᴱ_.to q → p ≡ q to≡to→≡ ext p≡q = _≃_.to (Eq.≃-≡ (Eq.inverse ≃≃≃ᴱ)) (Eq.lift-equality ext p≡q) -- A variant of ≃-to-≡↔≡. @0 to≡to≃≡ : {A : Type a} {B : Type b} {p q : A ≃ᴱ B} → Extensionality (a ⊔ b) (a ⊔ b) → (∀ x → _≃ᴱ_.to p x ≡ _≃ᴱ_.to q x) ≃ (p ≡ q) to≡to≃≡ {p = p} {q = q} ext = (∀ x → _≃ᴱ_.to p x ≡ _≃ᴱ_.to q x) F.↔⟨⟩ (∀ x → _≃_.to (_≃_.from ≃≃≃ᴱ p) x ≡ _≃_.to (_≃_.from ≃≃≃ᴱ q) x) F.↔⟨ ≃-to-≡↔≡ ext ⟩ _≃_.from ≃≃≃ᴱ p ≡ _≃_.from ≃≃≃ᴱ q ↝⟨ Eq.≃-≡ (Eq.inverse ≃≃≃ᴱ) ⟩□ p ≡ q □ ------------------------------------------------------------------------ -- A variant of _≃ᴱ_ -- Half adjoint equivalences with certain erased proofs. private module Dummy where infix 4 _≃ᴱ′_ record _≃ᴱ′_ (A : Type a) (B : Type b) : Type (a ⊔ b) where field to : A → B from : B → A @0 to-from : ∀ x → to (from x) ≡ x from-to : ∀ x → from (to x) ≡ x @0 to-from-to : ∀ x → cong to (from-to x) ≡ to-from (to x) open Dummy public using (_≃ᴱ′_) hiding (module _≃ᴱ′_) -- Note that the type arguments A and B are erased. This is not the -- case for the record module Dummy._≃ᴱ′_. module _≃ᴱ′_ {@0 A : Type a} {@0 B : Type b} (A≃B : A ≃ᴱ′ B) where -- Variants of the projections. to : A → B to = let record { to = to } = A≃B in to from : B → A from = let record { from = from } = A≃B in from @0 to-from : ∀ x → to (from x) ≡ x to-from = Dummy._≃ᴱ′_.to-from A≃B from-to : ∀ x → from (to x) ≡ x from-to = let record { from-to = from-to } = A≃B in from-to @0 to-from-to : ∀ x → cong to (from-to x) ≡ to-from (to x) to-from-to = Dummy._≃ᴱ′_.to-from-to A≃B -- Half adjoint equivalences with certain erased proofs are -- equivalences with erased proofs. equivalence-with-erased-proofs : A ≃ᴱ B equivalence-with-erased-proofs = ⟨ to , (from , [ to-from , from-to , to-from-to ]) ⟩₀ -- A coherence property. @0 from-to-from : ∀ x → cong from (to-from x) ≡ from-to (from x) from-to-from = _≃ᴱ_.right-left-lemma equivalence-with-erased-proofs -- Data corresponding to the erased proofs of an equivalence with -- certain erased proofs. record Erased-proofs′ {A : Type a} {B : Type b} (to : A → B) (from : B → A) (from-to : ∀ x → from (to x) ≡ x) : Type (a ⊔ b) where field to-from : ∀ x → to (from x) ≡ x to-from-to : ∀ x → cong to (from-to x) ≡ to-from (to x) -- Extracts "erased proofs" from a regular equivalence. [proofs′] : {@0 A : Type a} {@0 B : Type b} (A≃B : A ≃ B) → Erased-proofs′ (_≃_.to A≃B) (_≃_.from A≃B) (_≃_.left-inverse-of A≃B) [proofs′] A≃B .Erased-proofs′.to-from = let record { is-equivalence = _ , to-from , _ } = A≃B in to-from [proofs′] A≃B .Erased-proofs′.to-from-to = let record { is-equivalence = _ , _ , _ , to-from-to } = A≃B in to-from-to -- Converts two functions, one proof and some erased proofs to an -- equivalence with certain erased proofs. [≃]→≃ᴱ′ : {@0 A : Type a} {@0 B : Type b} {to : A → B} {from : B → A} {from-to : ∀ x → from (to x) ≡ x} → @0 Erased-proofs′ to from from-to → A ≃ᴱ′ B [≃]→≃ᴱ′ {to = to} {from = from} {from-to = from-to} ep = λ where .Dummy._≃ᴱ′_.to → to .Dummy._≃ᴱ′_.from → from .Dummy._≃ᴱ′_.to-from → ep .Erased-proofs′.to-from .Dummy._≃ᴱ′_.from-to → from-to .Dummy._≃ᴱ′_.to-from-to → ep .Erased-proofs′.to-from-to -- A function with a quasi-inverse with one proof and one erased proof -- can be turned into an equivalence with certain erased proofs. ↔→≃ᴱ′ : {@0 A : Type a} {@0 B : Type b} (f : A → B) (g : B → A) → @0 (∀ x → f (g x) ≡ x) → (∀ x → g (f x) ≡ x) → A ≃ᴱ′ B ↔→≃ᴱ′ {A = A} {B = B} to from to-from from-to = [≃]→≃ᴱ′ ([proofs′] equiv) where @0 equiv : A ≃ B equiv = Eq.⟨ to , HA.↔→Is-equivalenceˡ (record { surjection = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to-from } ; left-inverse-of = from-to }) ⟩ -- If f is an equivalence with certain erased proofs, then there is an -- equivalence with certain erased proofs from x ≡ y to f x ≡ f y. ≡≃ᴱ′to≡to : (A≃ᴱ′B : A ≃ᴱ′ B) → (x ≡ y) ≃ᴱ′ (_≃ᴱ′_.to A≃ᴱ′B x ≡ _≃ᴱ′_.to A≃ᴱ′B y) ≡≃ᴱ′to≡to {x = x} {y = y} A≃ᴱ′B = ↔→≃ᴱ′ (_↠_.from ≡↠≡) (_↠_.to ≡↠≡) (λ eq → _↠_.from ≡↠≡ (_↠_.to ≡↠≡ eq) ≡⟨⟩ cong to (trans (sym (from-to x)) (trans (cong from eq) (from-to y))) ≡⟨ cong-trans _ _ _ ⟩ trans (cong to (sym (from-to x))) (cong to (trans (cong from eq) (from-to y))) ≡⟨ cong₂ trans (cong-sym _ _) (cong-trans _ _ _) ⟩ trans (sym (cong to (from-to x))) (trans (cong to (cong from eq)) (cong to (from-to y))) ≡⟨ cong₂ (λ p q → trans (sym p) (trans (cong to (cong from eq)) q)) (to-from-to _) (to-from-to _) ⟩ trans (sym (to-from (to x))) (trans (cong to (cong from eq)) (to-from (to y))) ≡⟨⟩ _↠_.to ≡↠≡′ (_↠_.from ≡↠≡′ eq) ≡⟨ _↠_.right-inverse-of ≡↠≡′ eq ⟩∎ eq ∎) (_↠_.right-inverse-of ≡↠≡) where open _≃ᴱ′_ A≃ᴱ′B ≡↠≡ : (to x ≡ to y) ↠ (x ≡ y) ≡↠≡ = Surjection.↠-≡ (record { logical-equivalence = record { to = from ; from = to } ; right-inverse-of = from-to }) @0 ≡↠≡′ : ∀ {x y} → (from x ≡ from y) ↠ (x ≡ y) ≡↠≡′ = Surjection.↠-≡ (record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to-from }) -- If f is an equivalence with certain erased proofs, then x ≡ y is -- equivalent (with erased proofs) to f x ≡ f y. -- -- See also to≡to≃ᴱ≡-Erased below. ≡≃ᴱto≡to : (A≃ᴱ′B : A ≃ᴱ′ B) → (x ≡ y) ≃ᴱ (_≃ᴱ′_.to A≃ᴱ′B x ≡ _≃ᴱ′_.to A≃ᴱ′B y) ≡≃ᴱto≡to = _≃ᴱ′_.equivalence-with-erased-proofs ⊚ ≡≃ᴱ′to≡to -- Two preservation lemmas related to Π. Π-cong-≃ᴱ′-≃ᴱ : {@0 A : Type a} {B : Type b} {@0 P : A → Type p} {Q : B → Type q} → @0 Extensionality (a ⊔ b) (p ⊔ q) → (B≃A : B ≃ᴱ′ A) → (∀ x → P x ≃ᴱ Q (_≃ᴱ′_.from B≃A x)) → ((x : A) → P x) ≃ᴱ ((x : B) → Q x) Π-cong-≃ᴱ′-≃ᴱ ext B≃A = Π-cong-≃ᴱ ext (_≃ᴱ′_.from B≃A) (_≃ᴱ′_.to B≃A) (_≃ᴱ′_.from-to B≃A) (_≃ᴱ′_.to-from B≃A) Π-cong-≃ᴱ′-≃ᴱ′ : {A : Type a} {@0 B : Type b} {P : A → Type p} {@0 Q : B → Type q} → Extensionality (a ⊔ b) (p ⊔ q) → (A≃B : A ≃ᴱ′ B) → (∀ x → P (_≃ᴱ′_.from A≃B x) ≃ᴱ′ Q x) → ((x : A) → P x) ≃ᴱ′ ((x : B) → Q x) Π-cong-≃ᴱ′-≃ᴱ′ {a = a} {b = b} {p = p} {q = q} {A = A} {B = B} {P = P} {Q = Q} ext A≃B P≃Q = ↔→≃ᴱ′ (λ f x → _≃ᴱ′_.to (P≃Q x) (f (_≃ᴱ′_.from A≃B x))) (λ f x → subst P (_≃ᴱ′_.from-to A≃B x) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B x)) (f (_≃ᴱ′_.to A≃B x)))) (λ f → apply-ext (lower-extensionality a p ext) λ x → _≃ᴱ′_.to (P≃Q x) (subst P (_≃ᴱ′_.from-to A≃B (_≃ᴱ′_.from A≃B x)) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))) (f (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))))) ≡⟨ cong (_≃ᴱ′_.to (P≃Q x) ⊚ flip (subst P) _) $ sym $ _≃ᴱ′_.from-to-from A≃B _ ⟩ _≃ᴱ′_.to (P≃Q x) (subst P (cong (_≃ᴱ′_.from A≃B) (_≃ᴱ′_.to-from A≃B x)) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))) (f (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))))) ≡⟨ elim¹ (λ {y} eq → _≃ᴱ′_.to (P≃Q y) (subst P (cong (_≃ᴱ′_.from A≃B) eq) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))) (f (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))))) ≡ f y) ( _≃ᴱ′_.to (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))) (subst P (cong (_≃ᴱ′_.from A≃B) (refl _)) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))) (f (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))))) ≡⟨ cong (_≃ᴱ′_.to (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x)))) $ trans (cong (flip (subst P) _) $ cong-refl _) $ subst-refl _ _ ⟩ _≃ᴱ′_.to (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x))) (f (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x)))) ≡⟨ _≃ᴱ′_.to-from (P≃Q _) _ ⟩∎ f (_≃ᴱ′_.to A≃B (_≃ᴱ′_.from A≃B x)) ∎) _ ⟩∎ f x ∎) (λ f → apply-ext (lower-extensionality b q ext) λ x → subst P (_≃ᴱ′_.from-to A≃B x) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B x)) (_≃ᴱ′_.to (P≃Q (_≃ᴱ′_.to A≃B x)) (f (_≃ᴱ′_.from A≃B (_≃ᴱ′_.to A≃B x))))) ≡⟨ elim¹ (λ {y} eq → subst P eq (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B x)) (_≃ᴱ′_.to (P≃Q (_≃ᴱ′_.to A≃B x)) (f (_≃ᴱ′_.from A≃B (_≃ᴱ′_.to A≃B x))))) ≡ f y) ( subst P (refl _) (_≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B x)) (_≃ᴱ′_.to (P≃Q (_≃ᴱ′_.to A≃B x)) (f (_≃ᴱ′_.from A≃B (_≃ᴱ′_.to A≃B x))))) ≡⟨ subst-refl _ _ ⟩ _≃ᴱ′_.from (P≃Q (_≃ᴱ′_.to A≃B x)) (_≃ᴱ′_.to (P≃Q (_≃ᴱ′_.to A≃B x)) (f (_≃ᴱ′_.from A≃B (_≃ᴱ′_.to A≃B x)))) ≡⟨ _≃ᴱ′_.from-to (P≃Q _) _ ⟩∎ f (_≃ᴱ′_.from A≃B (_≃ᴱ′_.to A≃B x)) ∎) _ ⟩∎ f x ∎) ------------------------------------------------------------------------ -- Some results related to Contractibleᴱ -- Two types that are contractible (with erased proofs) are equivalent -- (with erased proofs). Contractibleᴱ→≃ᴱ : {@0 A : Type a} {@0 B : Type b} → Contractibleᴱ A → Contractibleᴱ B → A ≃ᴱ B Contractibleᴱ→≃ᴱ (a , [ irrA ]) (b , [ irrB ]) = ↔→≃ᴱ (const b) (const a) irrB irrA -- There is a logical equivalence between Contractibleᴱ A and A ≃ᴱ ⊤. Contractibleᴱ⇔≃ᴱ⊤ : {@0 A : Type a} → Contractibleᴱ A ⇔ A ≃ᴱ ⊤ Contractibleᴱ⇔≃ᴱ⊤ = record { to = flip Contractibleᴱ→≃ᴱ Contractibleᴱ-⊤ ; from = λ A≃⊤ → ECP.Contractibleᴱ-respects-surjection (_≃ᴱ_.from A≃⊤) (λ a → tt , (_≃ᴱ_.from A≃⊤ tt ≡⟨⟩ _≃ᴱ_.from A≃⊤ (_≃ᴱ_.to A≃⊤ a) ≡⟨ _≃ᴱ_.left-inverse-of A≃⊤ _ ⟩∎ a ∎)) Contractibleᴱ-⊤ } where Contractibleᴱ-⊤ = ECP.Contractible→Contractibleᴱ ⊤-contractible -- There is an equivalence with erased proofs between Contractibleᴱ A -- and A ≃ᴱ ⊤ (assuming extensionality). Contractibleᴱ≃ᴱ≃ᴱ⊤ : {@0 A : Type a} → @0 Extensionality a a → Contractibleᴱ A ≃ᴱ (A ≃ᴱ ⊤) Contractibleᴱ≃ᴱ≃ᴱ⊤ ext = let record { to = to; from = from } = Contractibleᴱ⇔≃ᴱ⊤ in ↔→≃ᴱ to from (λ _ → to≡to→≡ ext (refl _)) (λ _ → ECP.Contractibleᴱ-propositional ext _ _) -- If an inhabited type comes with an erased proof of -- propositionality, then it is equivalent (with erased proofs) to the -- unit type. inhabited→Is-proposition→≃ᴱ⊤ : {@0 A : Type a} → A → @0 Is-proposition A → A ≃ᴱ ⊤ inhabited→Is-proposition→≃ᴱ⊤ x prop = let record { to = to } = Contractibleᴱ⇔≃ᴱ⊤ in to (ECP.inhabited→Is-proposition→Contractibleᴱ x prop) -- Contractibleᴱ commutes with _×_ (up to _≃ᴱ_, assuming -- extensionality). Contractibleᴱ-commutes-with-× : {@0 A : Type a} {@0 B : Type b} → @0 Extensionality (a ⊔ b) (a ⊔ b) → Contractibleᴱ (A × B) ≃ᴱ (Contractibleᴱ A × Contractibleᴱ B) Contractibleᴱ-commutes-with-× {A = A} {B = B} ext = [≃]→≃ᴱ ([proofs] lemma) where @0 lemma : _ lemma = Contractibleᴱ (A × B) ↝⟨ F.inverse ECP.Contractible≃Contractibleᴱ ⟩ Contractible (A × B) ↝⟨ Contractible-commutes-with-× ext ⟩ (Contractible A × Contractible B) ↝⟨ ECP.Contractible≃Contractibleᴱ ×-cong ECP.Contractible≃Contractibleᴱ ⟩□ (Contractibleᴱ A × Contractibleᴱ B) □ ------------------------------------------------------------------------ -- Groupoid laws and related properties module Groupoid where -- In an erased context the groupoid laws hold for id and _∘_. -- -- TODO: Is it possible to prove the first three results in a -- non-erased context? @0 left-identity : {A : Type a} {B : Type b} → Extensionality (a ⊔ b) (a ⊔ b) → (f : A ≃ᴱ B) → id ∘ f ≡ f left-identity ext _ = to≡to→≡ ext (refl _) @0 right-identity : {A : Type a} {B : Type b} → Extensionality (a ⊔ b) (a ⊔ b) → (f : A ≃ᴱ B) → f ∘ id ≡ f right-identity ext _ = to≡to→≡ ext (refl _) @0 associativity : {A : Type a} {D : Type d} → Extensionality (a ⊔ d) (a ⊔ d) → (f : C ≃ᴱ D) (g : B ≃ᴱ C) (h : A ≃ᴱ B) → f ∘ (g ∘ h) ≡ (f ∘ g) ∘ h associativity ext _ _ _ = to≡to→≡ ext (refl _) @0 left-inverse : {A : Type a} → Extensionality a a → (f : A ≃ᴱ B) → inverse f ∘ f ≡ id left-inverse ext f = to≡to→≡ ext $ apply-ext ext $ _≃_.left-inverse-of (≃ᴱ→≃ f) @0 right-inverse : {B : Type b} → Extensionality b b → (f : A ≃ᴱ B) → f ∘ inverse f ≡ id right-inverse ext f = to≡to→≡ ext $ apply-ext ext $ _≃_.right-inverse-of (≃ᴱ→≃ f) -- Inverse is a logical equivalence. inverse-logical-equivalence : {@0 A : Type a} {@0 B : Type b} → A ≃ᴱ B ⇔ B ≃ᴱ A inverse-logical-equivalence = record { to = inverse ; from = inverse } -- Inverse is an equivalence with erased proofs (assuming -- extensionality). inverse-equivalence : {@0 A : Type a} {@0 B : Type b} → @0 Extensionality (a ⊔ b) (a ⊔ b) → (A ≃ᴱ B) ≃ᴱ (B ≃ᴱ A) inverse-equivalence ext = ↔→≃ᴱ inverse inverse (λ _ → to≡to→≡ ext (refl _)) (λ _ → to≡to→≡ ext (refl _)) ------------------------------------------------------------------------ -- Some results that depend on univalence -- A variant of ≃⇒≡. @0 ≃ᴱ→≡ : {A B : Type a} → Univalence a → A ≃ᴱ B → A ≡ B ≃ᴱ→≡ univ = ≃⇒≡ univ ⊚ ≃ᴱ→≃ -- A variant of ≡≃≃. @0 ≡≃≃ᴱ : {A B : Type a} → Univalence a → (A ≡ B) ≃ (A ≃ᴱ B) ≡≃≃ᴱ {A = A} {B = B} univ = Eq.with-other-function (A ≡ B ↝⟨ ≡≃≃ univ ⟩ A ≃ B ↝⟨ ≃≃≃ᴱ ⟩□ A ≃ᴱ B □) (≡⇒↝ _) (elim₁ (λ eq → ≃→≃ᴱ (≡⇒≃ eq) ≡ ≡⇒↝ _ eq) (≃→≃ᴱ (≡⇒≃ (refl _)) ≡⟨ cong ≃→≃ᴱ ≡⇒≃-refl ⟩ ≃→≃ᴱ Eq.id ≡⟨⟩ id ≡⟨ sym ≡⇒↝-refl ⟩∎ ≡⇒↝ _ (refl _) ∎)) @0 _ : {univ : Univalence a} → _≃_.from (≡≃≃ᴱ {A = A} {B = B} univ) ≡ ≃ᴱ→≡ univ _ = refl _ -- A variant of ≃⇒≡-id. @0 ≃ᴱ→≡-id : {A : Type a} → Extensionality a a → (univ : Univalence a) → ≃ᴱ→≡ univ id ≡ refl A ≃ᴱ→≡-id ext univ = ≃⇒≡ univ (≃ᴱ→≃ id) ≡⟨ cong (≃⇒≡ univ) $ Eq.lift-equality ext (refl _) ⟩ ≃⇒≡ univ Eq.id ≡⟨ ≃⇒≡-id univ ⟩∎ refl _ ∎ -- A variant of ≃⇒≡-inverse. @0 ≃ᴱ→≡-inverse : Extensionality a a → (univ : Univalence a) (A≃B : A ≃ᴱ B) → ≃ᴱ→≡ univ (inverse A≃B) ≡ sym (≃ᴱ→≡ univ A≃B) ≃ᴱ→≡-inverse ext univ A≃B = ≃⇒≡ univ (≃ᴱ→≃ (inverse A≃B)) ≡⟨ cong (≃⇒≡ univ) $ Eq.lift-equality ext (refl _) ⟩ ≃⇒≡ univ (Eq.inverse (≃ᴱ→≃ A≃B)) ≡⟨ ≃⇒≡-inverse univ ext _ ⟩∎ sym (≃⇒≡ univ (≃ᴱ→≃ A≃B)) ∎ -- A variant of ≃⇒≡-∘. @0 ≃ᴱ→≡-∘ : Extensionality a a → (univ : Univalence a) (A≃B : A ≃ᴱ B) (B≃C : B ≃ᴱ C) → ≃ᴱ→≡ univ (B≃C ∘ A≃B) ≡ trans (≃ᴱ→≡ univ A≃B) (≃ᴱ→≡ univ B≃C) ≃ᴱ→≡-∘ ext univ A≃B B≃C = ≃⇒≡ univ (≃ᴱ→≃ (B≃C ∘ A≃B)) ≡⟨ cong (≃⇒≡ univ) $ Eq.lift-equality ext (refl _) ⟩ ≃⇒≡ univ (≃ᴱ→≃ B≃C Eq.∘ ≃ᴱ→≃ A≃B) ≡⟨ ≃⇒≡-∘ univ ext _ _ ⟩ trans (≃⇒≡ univ (≃ᴱ→≃ A≃B)) (≃⇒≡ univ (≃ᴱ→≃ B≃C)) ∎ -- Singletons expressed using equivalences with erased proofs instead -- of equalities are equivalent (with erased proofs) to the unit type -- (assuming extensionality and univalence). singleton-with-≃ᴱ-≃ᴱ-⊤ : ∀ a {B : Type b} → @0 Extensionality (a ⊔ b) (a ⊔ b) → @0 Univalence (a ⊔ b) → (∃ λ (A : Type (a ⊔ b)) → A ≃ᴱ B) ≃ᴱ ⊤ singleton-with-≃ᴱ-≃ᴱ-⊤ {b = b} a {B = B} ext univ = [≃]→≃ᴱ ([proofs] lemma) where @0 lemma : (∃ λ (A : Type (a ⊔ b)) → A ≃ᴱ B) ≃ ⊤ lemma = (∃ λ (A : Type (a ⊔ b)) → A ≃ᴱ B) ↝⟨ (∃-cong λ _ → F.inverse ≃≃≃ᴱ) ⟩ (∃ λ (A : Type (a ⊔ b)) → A ≃ B) F.↔⟨ singleton-with-≃-↔-⊤ {a = a} ext univ ⟩□ ⊤ □ other-singleton-with-≃ᴱ-≃ᴱ-⊤ : ∀ b {A : Type a} → @0 Extensionality (a ⊔ b) (a ⊔ b) → @0 Univalence (a ⊔ b) → (∃ λ (B : Type (a ⊔ b)) → A ≃ᴱ B) ≃ᴱ ⊤ other-singleton-with-≃ᴱ-≃ᴱ-⊤ b {A = A} ext univ = (∃ λ B → A ≃ᴱ B) ≃ᴱ⟨ (∃-cong λ _ → inverse-equivalence ext) ⟩ (∃ λ B → B ≃ᴱ A) ≃ᴱ⟨ singleton-with-≃ᴱ-≃ᴱ-⊤ b ext univ ⟩□ ⊤ □ -- Variants of the two lemmas above. singleton-with-Π-≃ᴱ-≃ᴱ-⊤ : {A : Type a} {Q : A → Type q} → @0 Extensionality a (lsuc q) → @0 Univalence q → (∃ λ (P : A → Type q) → ∀ x → P x ≃ᴱ Q x) ≃ᴱ ⊤ singleton-with-Π-≃ᴱ-≃ᴱ-⊤ {a = a} {q = q} {A = A} {Q = Q} ext univ = [≃]→≃ᴱ ([proofs] lemma) where @0 ext′ : Extensionality a q ext′ = lower-extensionality lzero _ ext @0 lemma : (∃ λ (P : A → Type q) → ∀ x → P x ≃ᴱ Q x) ≃ ⊤ lemma = (∃ λ (P : A → Type q) → ∀ x → P x ≃ᴱ Q x) ↝⟨ (∃-cong λ _ → ∀-cong ext′ λ _ → F.inverse ≃≃≃ᴱ) ⟩ (∃ λ (P : A → Type q) → ∀ x → P x ≃ Q x) F.↔⟨ singleton-with-Π-≃-≃-⊤ ext univ ⟩□ ⊤ □ other-singleton-with-Π-≃ᴱ-≃ᴱ-⊤ : {A : Type a} {P : A → Type p} → @0 Extensionality (a ⊔ p) (lsuc p) → @0 Univalence p → (∃ λ (Q : A → Type p) → ∀ x → P x ≃ᴱ Q x) ≃ᴱ ⊤ other-singleton-with-Π-≃ᴱ-≃ᴱ-⊤ {a = a} {p = p} {A = A} {P = P} ext univ = (∃ λ (Q : A → Type p) → ∀ x → P x ≃ᴱ Q x) ≃ᴱ⟨ (∃-cong λ _ → ∀-cong-≃ᴱ ext₁ λ _ → inverse-equivalence ext₂) ⟩ (∃ λ (Q : A → Type p) → ∀ x → Q x ≃ᴱ P x) ≃ᴱ⟨ singleton-with-Π-≃ᴱ-≃ᴱ-⊤ ext₃ univ ⟩□ ⊤ □ where @0 ext₁ : Extensionality a p ext₁ = lower-extensionality p _ ext @0 ext₂ : Extensionality p p ext₂ = lower-extensionality a _ ext @0 ext₃ : Extensionality a (lsuc p) ext₃ = lower-extensionality p lzero ext -- ∃ Contractibleᴱ is equivalent (with erased proofs) to the unit type -- (assuming extensionality and univalence). ∃Contractibleᴱ≃ᴱ⊤ : @0 Extensionality a a → @0 Univalence a → (∃ λ (A : Type a) → Contractibleᴱ A) ≃ᴱ ⊤ ∃Contractibleᴱ≃ᴱ⊤ ext univ = (∃ λ A → Contractibleᴱ A) ≃ᴱ⟨ (∃-cong λ _ → Contractibleᴱ≃ᴱ≃ᴱ⊤ ext) ⟩ (∃ λ A → A ≃ᴱ ⊤) ≃ᴱ⟨ singleton-with-≃ᴱ-≃ᴱ-⊤ _ ext univ ⟩□ ⊤ □ ------------------------------------------------------------------------ -- Some simplification lemmas -- Two simplification lemmas for id. right-inverse-of-id : _≃ᴱ_.right-inverse-of id x ≡ refl x right-inverse-of-id = refl _ @0 left-inverse-of-id : _≃ᴱ_.left-inverse-of id x ≡ refl x left-inverse-of-id {x = x} = left-inverse-of x ≡⟨⟩ left-inverse-of (P.id x) ≡⟨ sym $ right-left-lemma x ⟩ cong P.id (right-inverse-of x) ≡⟨ sym $ cong-id _ ⟩ right-inverse-of x ≡⟨ right-inverse-of-id ⟩∎ refl x ∎ where open _≃ᴱ_ id -- Two simplification lemmas for inverse. @0 right-inverse-of∘inverse : (A≃B : A ≃ᴱ B) → _≃ᴱ_.right-inverse-of (inverse A≃B) x ≡ _≃ᴱ_.left-inverse-of A≃B x right-inverse-of∘inverse _ = refl _ @0 left-inverse-of∘inverse : (A≃B : A ≃ᴱ B) → _≃ᴱ_.left-inverse-of (inverse A≃B) x ≡ _≃ᴱ_.right-inverse-of A≃B x left-inverse-of∘inverse {A = A} {B = B} {x = x} A≃B = subst (λ x → _≃ᴱ_.left-inverse-of (inverse A≃B) x ≡ right-inverse-of x) (right-inverse-of x) (_≃ᴱ_.left-inverse-of (inverse A≃B) (to (from x)) ≡⟨ sym $ _≃ᴱ_.right-left-lemma (inverse A≃B) (from x) ⟩ cong to (_≃ᴱ_.right-inverse-of (inverse A≃B) (from x)) ≡⟨ cong (cong to) $ right-inverse-of∘inverse A≃B ⟩ cong to (left-inverse-of (from x)) ≡⟨ left-right-lemma (from x) ⟩∎ right-inverse-of (to (from x)) ∎) where open _≃ᴱ_ A≃B -- Two simplification lemmas for subst. to-subst : {eq : x ≡ y} {f : P x ≃ᴱ Q x} → _≃ᴱ_.to (subst (λ x → P x ≃ᴱ Q x) eq f) ≡ subst (λ x → P x → Q x) eq (_≃ᴱ_.to f) to-subst {P = P} {Q = Q} {eq = eq} {f = f} = elim¹ (λ eq → _≃ᴱ_.to (subst (λ x → P x ≃ᴱ Q x) eq f) ≡ subst (λ x → P x → Q x) eq (_≃ᴱ_.to f)) (_≃ᴱ_.to (subst (λ x → P x ≃ᴱ Q x) (refl _) f) ≡⟨ cong _≃ᴱ_.to $ subst-refl _ _ ⟩ _≃ᴱ_.to f ≡⟨ sym $ subst-refl _ _ ⟩∎ subst (λ x → P x → Q x) (refl _) (_≃ᴱ_.to f) ∎) eq from-subst : {eq : x ≡ y} {f : P x ≃ᴱ Q x} → _≃ᴱ_.from (subst (λ x → P x ≃ᴱ Q x) eq f) ≡ subst (λ x → Q x → P x) eq (_≃ᴱ_.from f) from-subst {P = P} {Q = Q} {eq = eq} {f = f} = elim¹ (λ eq → _≃ᴱ_.from (subst (λ x → P x ≃ᴱ Q x) eq f) ≡ subst (λ x → Q x → P x) eq (_≃ᴱ_.from f)) (_≃ᴱ_.from (subst (λ x → P x ≃ᴱ Q x) (refl _) f) ≡⟨ cong _≃ᴱ_.from $ subst-refl _ _ ⟩ _≃ᴱ_.from f ≡⟨ sym $ subst-refl _ _ ⟩∎ subst (λ x → Q x → P x) (refl _) (_≃ᴱ_.from f) ∎) eq ------------------------------------------------------------------------ -- The two-out-of-three properties -- If f and g are equivalences with erased proofs, then g ⊚ f is also -- an equivalence with erased proofs. 12→3 : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {@0 f : A → B} {@0 g : B → C} → Is-equivalenceᴱ f → Is-equivalenceᴱ g → Is-equivalenceᴱ (g ⊚ f) 12→3 p q = proj₁₀ p ⊚ proj₁₀ q , [ _≃ᴱ_.is-equivalence (⟨ _ , q ⟩₀ ∘ ⟨ _ , p ⟩₀) .proj₂ .erased ] -- If g and g ⊚ f are equivalences with erased proofs, then f is -- also an equivalence with erased proofs. 23→1 : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {@0 f : A → B} {g : B → C} → @0 Is-equivalenceᴱ g → Is-equivalenceᴱ (g ⊚ f) → Is-equivalenceᴱ f 23→1 {f = f} {g = g} q r = let record { to = to } = Is-equivalenceᴱ-cong-⇔ λ x → _≃ᴱ_.from ⟨ g , q ⟩ (g (f x)) ≡⟨ _≃ᴱ_.left-inverse-of ⟨ g , q ⟩ (f x) ⟩∎ f x ∎ in to ( proj₁₀ r ⊚ g , [ _≃ᴱ_.is-equivalence (inverse ⟨ _ , q ⟩₀ ∘ ⟨ _ , r ⟩₀) .proj₂ .erased ] ) -- If g ⊚ f and f are equivalences with erased proofs, then g is -- also an equivalence with erased proofs. 31→2 : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {f : A → B} {@0 g : B → C} → Is-equivalenceᴱ (g ⊚ f) → @0 Is-equivalenceᴱ f → Is-equivalenceᴱ g 31→2 {f = f} {g = g} r p = let record { to = to } = Is-equivalenceᴱ-cong-⇔ λ x → g (f (_≃ᴱ_.from ⟨ f , p ⟩ x)) ≡⟨ cong g (_≃ᴱ_.right-inverse-of ⟨ f , p ⟩ x) ⟩∎ g x ∎ in to ( f ⊚ proj₁₀ r , [ _≃ᴱ_.is-equivalence (⟨ _ , r ⟩₀ ∘ inverse ⟨ _ , p ⟩₀) .proj₂ .erased ] ) -- Some consequences of the two-out-of-three properties. Is-equivalenceᴱ⇔Is-equivalenceᴱ-∘ˡ : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {f : B → C} {@0 g : A → B} → Is-equivalenceᴱ f → Is-equivalenceᴱ g ⇔ Is-equivalenceᴱ (f ⊚ g) Is-equivalenceᴱ⇔Is-equivalenceᴱ-∘ˡ f-eq = record { to = flip 12→3 f-eq ; from = 23→1 f-eq } Is-equivalenceᴱ⇔Is-equivalenceᴱ-∘ʳ : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {@0 f : B → C} {g : A → B} → Is-equivalenceᴱ g → Is-equivalenceᴱ f ⇔ Is-equivalenceᴱ (f ⊚ g) Is-equivalenceᴱ⇔Is-equivalenceᴱ-∘ʳ g-eq = record { to = 12→3 g-eq ; from = λ f∘g-eq → 31→2 f∘g-eq g-eq } Is-equivalenceᴱ≃ᴱIs-equivalenceᴱ-∘ˡ : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {f : B → C} {@0 g : A → B} → @0 Extensionality (a ⊔ b ⊔ c) (a ⊔ b ⊔ c) → Is-equivalenceᴱ f → Is-equivalenceᴱ g ≃ᴱ Is-equivalenceᴱ (f ⊚ g) Is-equivalenceᴱ≃ᴱIs-equivalenceᴱ-∘ˡ {b = b} {c = c} ext f-eq = ⇔→≃ᴱ (Is-equivalenceᴱ-propositional (lower-extensionality c c ext) _) (Is-equivalenceᴱ-propositional (lower-extensionality b b ext) _) (flip 12→3 f-eq) (23→1 f-eq) Is-equivalenceᴱ≃ᴱIs-equivalenceᴱ-∘ʳ : {@0 A : Type a} {@0 B : Type b} {@0 C : Type c} {@0 f : B → C} {g : A → B} → @0 Extensionality (a ⊔ b ⊔ c) (a ⊔ b ⊔ c) → Is-equivalenceᴱ g → Is-equivalenceᴱ f ≃ᴱ Is-equivalenceᴱ (f ⊚ g) Is-equivalenceᴱ≃ᴱIs-equivalenceᴱ-∘ʳ {a = a} {b = b} ext g-eq = ⇔→≃ᴱ (Is-equivalenceᴱ-propositional (lower-extensionality a a ext) _) (Is-equivalenceᴱ-propositional (lower-extensionality b b ext) _) (12→3 g-eq) (λ f∘g-eq → 31→2 f∘g-eq g-eq) ------------------------------------------------------------------------ -- Results that depend on an axiomatisation of []-cong (for a single -- universe level) module []-cong₁ (ax : []-cong-axiomatisation ℓ) where open Erased.[]-cong₁ ax ---------------------------------------------------------------------- -- More preservation lemmas -- Equivalences with erased proofs are in some cases preserved by Σ -- (assuming extensionality). Note the type of Q. Σ-cong-≃ᴱ-Erased : {@0 A : Type a} {@0 B : Type ℓ} {@0 P : A → Type p} {Q : @0 B → Type q} (A≃B : A ≃ᴱ B) → (∀ x → P x ≃ᴱ Q (_≃ᴱ_.to A≃B x)) → Σ A P ≃ᴱ Σ B (λ x → Q x) Σ-cong-≃ᴱ-Erased {A = A} {B = B} {P = P} {Q = Q} A≃B P≃Q = [≃]→≃ᴱ ([proofs] ΣAP≃ΣBQ) where @0 ΣAP≃ΣBQ : Σ A P ≃ Σ B (λ x → Q x) ΣAP≃ΣBQ = Eq.with-other-inverse (Σ-cong (≃ᴱ→≃ A≃B) (λ x → ≃ᴱ→≃ (P≃Q x))) (λ (x , y) → _≃ᴱ_.from A≃B x , _≃ᴱ_.from (P≃Q (_≃ᴱ_.from A≃B x)) (substᴱ Q (sym (_≃ᴱ_.right-inverse-of A≃B x)) y)) (λ (x , y) → cong (λ y → _ , _≃ᴱ_.from (P≃Q (_≃ᴱ_.from A≃B x)) y) ( subst (λ x → Q x) (sym (_≃ᴱ_.right-inverse-of A≃B x)) y ≡⟨ sym substᴱ≡subst ⟩∎ substᴱ Q (sym (_≃ᴱ_.right-inverse-of A≃B x)) y ∎)) -- A variant of Σ-cong-≃ᴱ-Erased. Σ-cong-contra-≃ᴱ-Erased : {@0 A : Type ℓ} {@0 B : Type b} {P : @0 A → Type p} {@0 Q : B → Type q} (B≃A : B ≃ᴱ A) → (∀ x → P (_≃ᴱ_.to B≃A x) ≃ᴱ Q x) → Σ A (λ x → P x) ≃ᴱ Σ B Q Σ-cong-contra-≃ᴱ-Erased {P = P} {Q = Q} B≃A P≃Q = ↔→≃ᴱ (λ (x , y) → _≃ᴱ_.from B≃A x , _≃ᴱ_.to (P≃Q (_≃ᴱ_.from B≃A x)) (substᴱ P (sym (_≃ᴱ_.right-inverse-of B≃A x)) y)) (λ (x , y) → _≃ᴱ_.to B≃A x , _≃ᴱ_.from (P≃Q x) y) (λ (x , y) → Σ-≡,≡→≡ (_≃ᴱ_.left-inverse-of B≃A x) (subst Q (_≃ᴱ_.left-inverse-of B≃A x) (_≃ᴱ_.to (P≃Q _) (substᴱ P (sym (_≃ᴱ_.right-inverse-of B≃A _)) (_≃ᴱ_.from (P≃Q x) y))) ≡⟨ cong (λ eq → subst Q (_≃ᴱ_.left-inverse-of B≃A x) (_≃ᴱ_.to (P≃Q _) eq)) substᴱ≡subst ⟩ subst Q (_≃ᴱ_.left-inverse-of B≃A x) (_≃ᴱ_.to (P≃Q _) (subst (λ x → P x) (sym (_≃ᴱ_.right-inverse-of B≃A _)) (_≃ᴱ_.from (P≃Q x) y))) ≡⟨ cong (λ eq → subst Q (_≃ᴱ_.left-inverse-of B≃A x) (_≃ᴱ_.to (P≃Q _) (subst (λ x → P x) (sym eq) _))) $ sym $ _≃ᴱ_.left-right-lemma B≃A _ ⟩ subst Q (_≃ᴱ_.left-inverse-of B≃A x) (_≃ᴱ_.to (P≃Q (_≃ᴱ_.from B≃A (_≃ᴱ_.to B≃A x))) (subst (λ x → P x) (sym (cong (_≃ᴱ_.to B≃A) (_≃ᴱ_.left-inverse-of B≃A _))) (_≃ᴱ_.from (P≃Q x) y))) ≡⟨ elim₁ (λ eq → subst Q eq (_≃ᴱ_.to (P≃Q _) (subst (λ x → P x) (sym (cong (_≃ᴱ_.to B≃A) eq)) (_≃ᴱ_.from (P≃Q x) y))) ≡ y) ( subst Q (refl _) (_≃ᴱ_.to (P≃Q x) (subst (λ x → P x) (sym (cong (_≃ᴱ_.to B≃A) (refl _))) (_≃ᴱ_.from (P≃Q x) y))) ≡⟨ subst-refl _ _ ⟩ _≃ᴱ_.to (P≃Q x) (subst (λ x → P x) (sym (cong (_≃ᴱ_.to B≃A) (refl _))) (_≃ᴱ_.from (P≃Q x) y)) ≡⟨ cong (λ eq → _≃ᴱ_.to (P≃Q _) (subst (λ x → P x) (sym eq) _)) $ cong-refl _ ⟩ _≃ᴱ_.to (P≃Q x) (subst (λ x → P x) (sym (refl _)) (_≃ᴱ_.from (P≃Q x) y)) ≡⟨ cong (λ eq → _≃ᴱ_.to (P≃Q _) (subst (λ x → P x) eq _)) sym-refl ⟩ _≃ᴱ_.to (P≃Q x) (subst (λ x → P x) (refl _) (_≃ᴱ_.from (P≃Q x) y)) ≡⟨ cong (λ eq → _≃ᴱ_.to (P≃Q _) eq) $ subst-refl _ _ ⟩ _≃ᴱ_.to (P≃Q x) (_≃ᴱ_.from (P≃Q x) y) ≡⟨ _≃ᴱ_.right-inverse-of (P≃Q x) _ ⟩∎ y ∎) (_≃ᴱ_.left-inverse-of B≃A x) ⟩∎ y ∎)) (λ (x , y) → Σ-≡,≡→≡ (_≃ᴱ_.right-inverse-of B≃A x) (subst (λ x → P x) (_≃ᴱ_.right-inverse-of B≃A x) (_≃ᴱ_.from (P≃Q _) (_≃ᴱ_.to (P≃Q _) (substᴱ P (sym (_≃ᴱ_.right-inverse-of B≃A _)) y))) ≡⟨ cong (subst (λ x → P x) (_≃ᴱ_.right-inverse-of B≃A x)) $ _≃ᴱ_.left-inverse-of (P≃Q _) _ ⟩ subst (λ x → P x) (_≃ᴱ_.right-inverse-of B≃A x) (substᴱ P (sym (_≃ᴱ_.right-inverse-of B≃A _)) y) ≡⟨ cong (subst (λ x → P x) (_≃ᴱ_.right-inverse-of B≃A x)) substᴱ≡subst ⟩ subst (λ x → P x) (_≃ᴱ_.right-inverse-of B≃A x) (subst (λ x → P x) (sym (_≃ᴱ_.right-inverse-of B≃A _)) y) ≡⟨ subst-subst-sym _ _ _ ⟩∎ y ∎)) -- Equivalences with erased proofs are in some cases preserved by Π -- (assuming extensionality). Note the type of Q. Π-cong-≃ᴱ-Erased : {@0 A : Type a} {@0 B : Type ℓ} {@0 P : A → Type p} {Q : @0 B → Type q} → @0 Extensionality (a ⊔ ℓ) (p ⊔ q) → (A≃B : A ≃ᴱ B) → (∀ x → P x ≃ᴱ Q (_≃ᴱ_.to A≃B x)) → ((x : A) → P x) ≃ᴱ ((x : B) → Q x) Π-cong-≃ᴱ-Erased {a = a} {p = p} {A = A} {B = B} {P = P} {Q = Q} ext A≃B P≃Q = [≃]→≃ᴱ ([proofs] ΠAP≃ΠBQ) where @0 ΠAP≃ΠBQ : ((x : A) → P x) ≃ ((x : B) → Q x) ΠAP≃ΠBQ = Eq.with-other-function (Π-cong ext (≃ᴱ→≃ A≃B) (λ x → ≃ᴱ→≃ (P≃Q x))) (λ f x → substᴱ Q (_≃ᴱ_.right-inverse-of A≃B x) (_≃ᴱ_.to (P≃Q (_≃ᴱ_.from A≃B x)) (f (_≃ᴱ_.from A≃B x)))) (λ f → apply-ext (lower-extensionality a p ext) λ x → subst (λ x → Q x) (_≃ᴱ_.right-inverse-of A≃B x) (_≃ᴱ_.to (P≃Q (_≃ᴱ_.from A≃B x)) (f (_≃ᴱ_.from A≃B x))) ≡⟨ sym substᴱ≡subst ⟩∎ substᴱ Q (_≃ᴱ_.right-inverse-of A≃B x) (_≃ᴱ_.to (P≃Q (_≃ᴱ_.from A≃B x)) (f (_≃ᴱ_.from A≃B x))) ∎) -- A variant of Π-cong-≃ᴱ-Erased. Π-cong-contra-≃ᴱ-Erased : {@0 A : Type ℓ} {@0 B : Type b} {P : @0 A → Type p} {@0 Q : B → Type q} → @0 Extensionality (b ⊔ ℓ) (p ⊔ q) → (B≃A : B ≃ᴱ A) → (∀ x → P (_≃ᴱ_.to B≃A x) ≃ᴱ Q x) → ((x : A) → P x) ≃ᴱ ((x : B) → Q x) Π-cong-contra-≃ᴱ-Erased {b = b} {q = q} {A = A} {B = B} {P = P} {Q = Q} ext B≃A P≃Q = [≃]→≃ᴱ ([proofs] ΠAP≃ΠBQ) where @0 ΠAP≃ΠBQ : ((x : A) → P x) ≃ ((x : B) → Q x) ΠAP≃ΠBQ = Eq.with-other-inverse (Π-cong-contra ext (≃ᴱ→≃ B≃A) (λ x → ≃ᴱ→≃ (P≃Q x))) (λ f x → substᴱ P (_≃ᴱ_.right-inverse-of B≃A x) (_≃ᴱ_.from (P≃Q (_≃ᴱ_.from B≃A x)) (f (_≃ᴱ_.from B≃A x)))) (λ f → apply-ext (lower-extensionality b q ext) λ x → subst (λ x → P x) (_≃ᴱ_.right-inverse-of B≃A x) (_≃ᴱ_.from (P≃Q (_≃ᴱ_.from B≃A x)) (f (_≃ᴱ_.from B≃A x))) ≡⟨ sym substᴱ≡subst ⟩∎ substᴱ P (_≃ᴱ_.right-inverse-of B≃A x) (_≃ᴱ_.from (P≃Q (_≃ᴱ_.from B≃A x)) (f (_≃ᴱ_.from B≃A x))) ∎) ---------------------------------------------------------------------- -- Variants of some lemmas from Function-universe -- A variant of drop-⊤-left-Σ. drop-⊤-left-Σ-≃ᴱ-Erased : {@0 A : Type ℓ} {P : @0 A → Type p} → (A≃⊤ : A ≃ᴱ ⊤) → Σ A (λ x → P x) ≃ᴱ P (_≃ᴱ_.from A≃⊤ tt) drop-⊤-left-Σ-≃ᴱ-Erased {A = A} {P = P} A≃⊤ = Σ A (λ x → P x) ≃ᴱ⟨ inverse $ Σ-cong-≃ᴱ-Erased (inverse A≃⊤) (λ _ → F.id) ⟩ Σ ⊤ (λ x → P (_≃ᴱ_.from A≃⊤ x)) ↔⟨ Σ-left-identity ⟩□ P (_≃ᴱ_.from A≃⊤ tt) □ -- A variant of drop-⊤-left-Π. drop-⊤-left-Π-≃ᴱ-Erased : {@0 A : Type ℓ} {P : @0 A → Type p} → @0 Extensionality ℓ p → (A≃⊤ : A ≃ᴱ ⊤) → ((x : A) → P x) ≃ᴱ P (_≃ᴱ_.from A≃⊤ tt) drop-⊤-left-Π-≃ᴱ-Erased {A = A} {P = P} ext A≃⊤ = ((x : A) → P x) ≃ᴱ⟨ Π-cong-contra-≃ᴱ-Erased ext (inverse A≃⊤) (λ _ → F.id) ⟩ ((x : ⊤) → P (_≃ᴱ_.from A≃⊤ x)) ↔⟨ Π-left-identity ⟩□ P (_≃ᴱ_.from A≃⊤ tt) □ ---------------------------------------------------------------------- -- A variant of a lemma proved above -- If f is an equivalence (with erased proofs) from Erased A to B, -- then x ≡ y is equivalent (with erased proofs) to f x ≡ f y. to≡to≃ᴱ≡-Erased : ∀ {@0 A : Type ℓ} {x y} (A≃B : Erased A ≃ᴱ B) → (_≃ᴱ_.to A≃B x ≡ _≃ᴱ_.to A≃B y) ≃ᴱ (x ≡ y) to≡to≃ᴱ≡-Erased {B = B} {A = A} {x = x} {y = y} A≃B = [≃]→≃ᴱ ([proofs] ≡≃≡) where @0 ≡≃≡ : (_≃ᴱ_.to A≃B x ≡ _≃ᴱ_.to A≃B y) ≃ (x ≡ y) ≡≃≡ = Eq.with-other-function (Eq.≃-≡ (≃ᴱ→≃ A≃B)) (λ eq → x ≡⟨ sym $ []-cong [ cong erased (_≃ᴱ_.left-inverse-of A≃B x) ] ⟩ _≃ᴱ_.from A≃B (_≃ᴱ_.to A≃B x) ≡⟨ cong (_≃ᴱ_.from A≃B) eq ⟩ _≃ᴱ_.from A≃B (_≃ᴱ_.to A≃B y) ≡⟨ []-cong [ cong erased (_≃ᴱ_.left-inverse-of A≃B y) ] ⟩∎ y ∎) (λ eq → let f = _≃ᴱ_.left-inverse-of A≃B in trans (sym (f x)) (trans (cong (_≃ᴱ_.from A≃B) eq) (f y)) ≡⟨ cong₂ (λ p q → trans (sym p) (trans (cong (_≃ᴱ_.from A≃B) eq) q)) (sym $ _≃_.right-inverse-of ≡≃[]≡[] _) (sym $ _≃_.right-inverse-of ≡≃[]≡[] _) ⟩∎ trans (sym ([]-cong [ cong erased (f x) ])) (trans (cong (_≃ᴱ_.from A≃B) eq) ([]-cong [ cong erased (f y) ])) ∎) ------------------------------------------------------------------------ -- Results that follow if the []-cong axioms hold for the maximum of -- two universe levels (as well as for the two universe levels) module []-cong₂-⊔ (ax₁ : []-cong-axiomatisation ℓ₁) (ax₂ : []-cong-axiomatisation ℓ₂) (ax : []-cong-axiomatisation (ℓ₁ ⊔ ℓ₂)) where open Erased-cong ax ax open Erased.[]-cong₁ ax open Erased.[]-cong₂-⊔ ax₁ ax₂ ax open []-cong₁ ax ---------------------------------------------------------------------- -- Another preservation lemma -- Is-equivalenceᴱ f is equivalent to Is-equivalenceᴱ g if f and g -- are pointwise equal (assuming extensionality). Is-equivalenceᴱ-cong : {A : Type ℓ₁} {B : Type ℓ₂} {@0 f g : A → B} → @0 Extensionality? k (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → @0 (∀ x → f x ≡ g x) → Is-equivalenceᴱ f ↝[ k ] Is-equivalenceᴱ g Is-equivalenceᴱ-cong {f = f} {g = g} ext f≡g = generalise-erased-ext? (Is-equivalenceᴱ-cong-⇔ f≡g) (λ ext → (∃ λ f⁻¹ → Erased (HA.Proofs f f⁻¹)) F.↔⟨ (∃-cong λ _ → Erased-cong-≃ (Proofs-cong ext f≡g)) ⟩□ (∃ λ f⁻¹ → Erased (HA.Proofs g f⁻¹)) □) ext ---------------------------------------------------------------------- -- More conversion lemmas -- Some equivalences relating Is-equivalenceᴱ to Is-equivalence. -- -- See also Is-equivalenceᴱ↔Is-equivalence below. Erased-Is-equivalenceᴱ≃Erased-Is-equivalence : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 f : A → B} → Erased (Is-equivalenceᴱ f) ≃ Erased (Is-equivalence f) Erased-Is-equivalenceᴱ≃Erased-Is-equivalence {f = f} = Erased (∃ λ f⁻¹ → Erased (HA.Proofs f f⁻¹)) ↝⟨ Erased-cong-≃ (∃-cong λ _ → Eq.↔⇒≃ $ erased Erased↔) ⟩□ Erased (∃ λ f⁻¹ → HA.Proofs f f⁻¹) □ Erased-Is-equivalence≃Is-equivalenceᴱ : {@0 A : Type ℓ₁} {B : Type ℓ₂} {@0 f : Erased A → B} → Erased (Is-equivalence f) ≃ Is-equivalenceᴱ f Erased-Is-equivalence≃Is-equivalenceᴱ {A = A} {B = B} {f = f} = Erased (Is-equivalence f) F.↔⟨⟩ Erased (∃ λ (f⁻¹ : B → Erased A) → HA.Proofs f f⁻¹) F.↔⟨ Erased-cong-↔ (F.inverse $ Σ-cong-id →≃→Erased) ⟩ Erased (∃ λ (f⁻¹ : B → A) → HA.Proofs f ([_]→ ⊚ f⁻¹)) F.↔⟨ Erased-Σ↔Σ ⟩ (∃ λ (f⁻¹ : Erased (B → A)) → Erased (HA.Proofs f (λ x → map (_$ x) f⁻¹))) ↝⟨ (F.Σ-cong Erased-Π↔Π λ _ → F.id) ⟩ (∃ λ (f⁻¹ : B → Erased A) → Erased (HA.Proofs f f⁻¹)) F.↔⟨⟩ Is-equivalenceᴱ f F.□ where @0 →≃→Erased : (B → A) ≃ (B → Erased A) →≃→Erased = Eq.↔→≃ (λ f x → [ f x ]) (λ f x → erased (f x)) refl refl ---------------------------------------------------------------------- -- Variants of some lemmas proved above -- Is-equivalenceᴱ f is a proposition if the domain of f is Erased A -- (assuming extensionality). Is-equivalenceᴱ-propositional-for-Erased : {@0 A : Type ℓ₁} {B : Type ℓ₂} {@0 f : Erased A → B} → @0 Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → Is-proposition (Is-equivalenceᴱ f) Is-equivalenceᴱ-propositional-for-Erased {f = f} ext = F.$⟨ H-level-Erased 1 (Eq.propositional ext _) ⟩ Is-proposition (Erased (Is-equivalence f)) ↝⟨ H-level-cong _ 1 Erased-Is-equivalence≃Is-equivalenceᴱ ⦂ (_ → _) ⟩□ Is-proposition (Is-equivalenceᴱ f) □ -- A variant of to≡to→≡ that is not defined in an erased context. -- Note that one side of the equivalence is Erased A. to≡to→≡-Erased : {@0 A : Type ℓ₁} {B : Type ℓ₂} {p q : Erased A ≃ᴱ B} → @0 Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → _≃ᴱ_.to p ≡ _≃ᴱ_.to q → p ≡ q to≡to→≡-Erased {p = ⟨ f , f-eq ⟩} {q = ⟨ g , g-eq ⟩} ext f≡g = elim (λ {f g} f≡g → ∀ f-eq g-eq → ⟨ f , f-eq ⟩ ≡ ⟨ g , g-eq ⟩) (λ f _ _ → cong ⟨ f ,_⟩ (Is-equivalenceᴱ-propositional-for-Erased ext _ _)) f≡g f-eq g-eq ---------------------------------------------------------------------- -- More lemmas -- An equivalence relating Is-equivalenceᴱ to Is-equivalence. Is-equivalenceᴱ↔Is-equivalence : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 f : A → B} → Is-equivalenceᴱ (map f) ↝[ ℓ₁ ⊔ ℓ₂ ∣ ℓ₁ ⊔ ℓ₂ ] Is-equivalence (map f) Is-equivalenceᴱ↔Is-equivalence {f = f} = generalise-ext?-prop (Is-equivalenceᴱ (map f) ↝⟨ Is-equivalenceᴱ⇔Is-equivalenceᴱ-CP ⟩ (∀ y → Contractibleᴱ (map f ⁻¹ᴱ y)) F.↔⟨⟩ (∀ y → Contractibleᴱ (∃ λ x → Erased ([ f (erased x) ] ≡ y))) ↝⟨ (∀-cong _ λ _ → ECP.[]-cong₂.Contractibleᴱ-cong ax ax _ (Eq.↔⇒≃ $ F.inverse Erased-Σ↔Σ)) ⟩ (∀ y → Contractibleᴱ (Erased (∃ λ x → [ f x ] ≡ y))) ↝⟨ (∀-cong _ λ _ → ECP.[]-cong₁.Contractibleᴱ-Erased↔Contractible-Erased ax _) ⟩ (∀ y → Contractible (Erased (∃ λ x → [ f x ] ≡ y))) ↝⟨ (∀-cong _ λ _ → H-level-cong _ 0 Erased-Σ↔Σ) ⟩ (∀ y → Contractible (∃ λ x → Erased (map f x ≡ y))) F.↔⟨⟩ (∀ y → Contractible (map f ⁻¹ᴱ y)) ↝⟨ (∀-cong _ λ _ → H-level-cong _ 0 $ ECP.[]-cong₁.⁻¹ᴱ[]↔⁻¹[] ax₂) ⟩ (∀ y → Contractible (map f ⁻¹ y)) ↝⟨ inverse-ext? Is-equivalence≃Is-equivalence-CP _ ⟩□ Is-equivalence (map f) □) (λ ext → Is-equivalenceᴱ-propositional-for-Erased ext) (λ ext → Eq.propositional ext _) -- Erased "commutes" with Is-equivalenceᴱ (assuming extensionality). Erased-Is-equivalenceᴱ↔Is-equivalenceᴱ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 f : A → B} → Erased (Is-equivalenceᴱ f) ↝[ ℓ₁ ⊔ ℓ₂ ∣ ℓ₁ ⊔ ℓ₂ ]ᴱ Is-equivalenceᴱ (map f) Erased-Is-equivalenceᴱ↔Is-equivalenceᴱ {f = f} ext = Erased (Is-equivalenceᴱ f) F.↔⟨ Erased-Is-equivalenceᴱ≃Erased-Is-equivalence ⟩ Erased (Is-equivalence f) F.↔⟨ F.inverse Erased-Erased↔Erased ⟩ Erased (Erased (Is-equivalence f)) ↝⟨ Erased-cong? Erased-Is-equivalence↔Is-equivalence ext ⟩ Erased (Is-equivalence (map f)) F.↔⟨ Erased-Is-equivalence≃Is-equivalenceᴱ ⟩□ Is-equivalenceᴱ (map f) □ ------------------------------------------------------------------------ -- Results that depend on an axiomatisation of []-cong (for all -- universe levels) module []-cong (ax : ∀ {ℓ} → []-cong-axiomatisation ℓ) where private open module BC₁ {ℓ} = []-cong₁ (ax {ℓ = ℓ}) public open module BC₂ {ℓ₁ ℓ₂} = []-cong₂-⊔ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂}) (ax {ℓ = ℓ₁ ⊔ ℓ₂}) public
{ "alphanum_fraction": 0.4495589577, "avg_line_length": 36.4845869297, "ext": "agda", "hexsha": "0bcf99ac81b46e3be72a334dedb0d5c34bf5d081", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Equivalence/Erased.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Equivalence/Erased.agda", "max_line_length": 163, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Equivalence/Erased.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 26185, "size": 59178 }
module Issue552 where data Id3 {A : Set} : A -> A -> A -> Set where refl3 : {x : A} -> Id3 x x x -- These work: ok1 : {A : Set}(a b c : A) -> Id3 a b c -> Id3 a b c ok1 ._ ._ ._ (refl3 {_}) = refl3 ok2 : {A : Set}(a b c : A) -> Id3 a b c -> Id3 a b c ok2 _ ._ ._ (refl3) = refl3 ok3 : {A : Set}(a b c : A) -> Id3 a b c -> Id3 a b c ok3 _ ._ ._ (refl3 {._}) = refl3 -- These work after the fix: bad4 : {A : Set}(a b c : A) -> Id3 a b c -> Id3 a b c bad4 ._ ._ _ (refl3 {._}) = refl3 bad3 : {A : Set}(a b c : A) -> Id3 a b c -> Id3 a b c bad3 ._ _ ._ (refl3 {._}) = refl3 -- This still doesn't work: -- bad1 : {A : Set}(a b c : A) -> Id3 a b c -> Id3 a b c -- bad1 ._ ._ ._ (refl3) = refl3
{ "alphanum_fraction": 0.4935805991, "avg_line_length": 23.3666666667, "ext": "agda", "hexsha": "faa380ae4d5c77b58369cc36623e31dbac4c3385", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue552.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue552.agda", "max_line_length": 56, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue552.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 313, "size": 701 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary.Poset where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Logic open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv renaming (_■ to _QED) open import Cubical.Foundations.SIP open import Cubical.Functions.FunExtEquiv open import Cubical.Foundations.Function open import Cubical.Core.Primitives open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Sigma.Properties open import Cubical.Structures.Axioms -- We will adopt the convention of denoting the level of the carrier -- set by ℓ₀ and the level of the relation result by ℓ₁. private variable ℓ ℓ₀ ℓ₁ ℓ₀′ ℓ₁′ ℓ₀′′ ℓ₁′′ : Level Order : (ℓ₁ : Level) → Type ℓ₀ → Type (ℓ-max ℓ₀ (ℓ-suc ℓ₁)) Order ℓ₁ A = A → A → hProp ℓ₁ isSetOrder : (ℓ₁ : Level) (A : Type ℓ₀) → isSet (Order ℓ₁ A) isSetOrder ℓ₁ A = isSetΠ2 λ _ _ → isSetHProp -- We first start by defining what it means a for a function to be -- order-preserving. The name "monotonic" is reserved for partial orders. isOrderPreserving : (M : TypeWithStr ℓ₀ (Order ℓ₁)) (N : TypeWithStr ℓ₀′ (Order ℓ₁′)) → (fst M → fst N) → Type _ isOrderPreserving (A , _⊑₀_) (B , _⊑₁_) f = (x y : A) → [ x ⊑₀ y ] → [ f x ⊑₁ f y ] isPropIsOrderPreserving : (M : TypeWithStr ℓ₀ (Order ℓ₁)) (N : TypeWithStr ℓ₀′ (Order ℓ₁′)) → (f : fst M → fst N) → isProp (isOrderPreserving M N f) isPropIsOrderPreserving M (_ , _⊑₁_) f = isPropΠ3 λ x y p → snd (f x ⊑₁ f y) -- We then define what it means for an equivalence to order-preserving which is -- nothing but the property that both directions of the equivalence are -- order-preserving. isAnOrderPreservingEqv : (M : TypeWithStr ℓ₀ (Order ℓ₁)) (N : TypeWithStr ℓ₀′ (Order ℓ₁′)) → fst M ≃ fst N → Type _ isAnOrderPreservingEqv M N e@(f , _) = isOrderPreserving M N f × isOrderPreserving N M g where g = equivFun (invEquiv e) orderUnivalentStr : SNS {ℓ} (Order ℓ₁) isAnOrderPreservingEqv orderUnivalentStr {ℓ = ℓ} {ℓ₁ = ℓ₁} {X = X} _⊑₀_ _⊑₁_ = f , record { equiv-proof = f-equiv } where f : isAnOrderPreservingEqv (X , _⊑₀_) (X , _⊑₁_) (idEquiv X) → _⊑₀_ ≡ _⊑₁_ f e@(φ , ψ) = funExt₂ λ x y → ⇔toPath (φ x y) (ψ x y) g : _⊑₀_ ≡ _⊑₁_ → isAnOrderPreservingEqv (X , _⊑₀_) (X , _⊑₁_) (idEquiv X) g p = subst (λ _⊑_ → isAnOrderPreservingEqv (X , _⊑₀_) (X , _⊑_) (idEquiv X)) p ((λ _ _ x⊑₁y → x⊑₁y) , λ _ _ x⊑₁y → x⊑₁y) ret-f-g : retract f g ret-f-g (φ , ψ) = isPropΣ (isPropIsOrderPreserving (X , _⊑₀_) (X , _⊑₁_) (idfun X)) (λ _ → isPropIsOrderPreserving (X , _⊑₁_) (X , _⊑₀_) (idfun X)) (g (f (φ , ψ))) (φ , ψ) f-equiv : (p : _⊑₀_ ≡ _⊑₁_) → isContr (fiber f p) f-equiv p = ((to , from) , eq) , NTS where to : isOrderPreserving (X , _⊑₀_) (X , _⊑₁_) (idfun _) to x y = subst (λ _⊑_ → [ x ⊑₀ y ] → [ x ⊑ y ]) p (idfun _) from : isOrderPreserving (X , _⊑₁_) (X , _⊑₀_) (idfun _) from x y = subst (λ _⊑_ → [ x ⊑ y ] → [ x ⊑₀ y ]) p (idfun _) eq : f (to , from) ≡ p eq = isSetOrder ℓ₁ X _⊑₀_ _⊑₁_ (f (to , from)) p NTS : (fib : fiber f p) → ((to , from) , eq) ≡ fib NTS ((φ , ψ) , eq) = Σ≡Prop (λ i′ → isOfHLevelSuc 2 (isSetOrder ℓ₁ X) _⊑₀_ _⊑₁_ (f i′) p) (Σ≡Prop (λ _ → isPropIsOrderPreserving (X , _⊑₁_) (X , _⊑₀_) (idfun _)) (isPropIsOrderPreserving (X , _⊑₀_) (X , _⊑₁_) (idfun _) to φ)) -- We now write down the axioms for a partial order and define posets on top of -- raw ordered structures. isReflexive : {A : Type ℓ₀} → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) isReflexive {A = X} _⊑_ = ((x : X) → [ x ⊑ x ]) , isPropΠ λ x → snd (x ⊑ x) 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) isAntisym : {A : Type ℓ₀} → isSet A → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) isAntisym {ℓ₀ = ℓ₀} {ℓ₁ = ℓ₁} {A = X} A-set _⊑_ = φ , φ-prop where φ : Type (ℓ-max ℓ₀ ℓ₁) φ = ((x y : X) → [ x ⊑ y ] → [ y ⊑ x ] → x ≡ y) φ-prop : isProp φ φ-prop = isPropΠ3 λ x y z → isPropΠ λ _ → A-set x y -- The predicate expressing that a given order satisfies the partial order -- axioms. satPosetAx : (ℓ₁ : Level) (A : Type ℓ₀) → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) satPosetAx {ℓ₀ = ℓ₀} ℓ₁ A _⊑_ = φ , φ-prop where isPartial : isSet A → hProp (ℓ-max ℓ₀ ℓ₁) isPartial A-set = isReflexive _⊑_ ⊓ isTransitive _⊑_ ⊓ isAntisym A-set _⊑_ φ = Σ[ A-set ∈ isSet A ] [ isPartial A-set ] φ-prop = isOfHLevelΣ 1 isPropIsSet (λ x → snd (isPartial x)) -- The poset structure. PosetStructure : (ℓ₁ : Level) → Type ℓ₀ → Type (ℓ-max ℓ₀ (ℓ-suc ℓ₁)) PosetStructure ℓ₁ = AxiomsStructure (Order ℓ₁) λ A _⊑_ → [ satPosetAx ℓ₁ A _⊑_ ] isSetPosetStructure : (ℓ₁ : Level) (A : Type ℓ₀) → isSet (PosetStructure ℓ₁ A) isSetPosetStructure ℓ₁ A = isSetΣ (isSetΠ2 λ _ _ → isSetHProp) λ _⊑_ → isProp→isSet (snd (satPosetAx ℓ₁ A _⊑_)) Poset : (ℓ₀ ℓ₁ : Level) → Type (ℓ-max (ℓ-suc ℓ₀) (ℓ-suc ℓ₁)) Poset ℓ₀ ℓ₁ = TypeWithStr ℓ₀ (PosetStructure ℓ₁) -- Some projections for syntactic convenience. -- Carrier set of a poset. ∣_∣ₚ : Poset ℓ₀ ℓ₁ → Type ℓ₀ ∣ X , _ ∣ₚ = X strₚ : (P : Poset ℓ₀ ℓ₁) → PosetStructure ℓ₁ ∣ P ∣ₚ strₚ (_ , s) = s rel : (P : Poset ℓ₀ ℓ₁) → ∣ P ∣ₚ → ∣ P ∣ₚ → hProp ℓ₁ rel (_ , _⊑_ , _) = _⊑_ syntax rel P x y = x ⊑[ P ] y ⊑[_]-refl : (P : Poset ℓ₀ ℓ₁) → (x : ∣ P ∣ₚ) → [ x ⊑[ P ] x ] ⊑[_]-refl (_ , _ , _ , ⊑-refl , _) = ⊑-refl ⊑[_]-trans : (P : Poset ℓ₀ ℓ₁) (x y z : ∣ P ∣ₚ) → [ x ⊑[ P ] y ] → [ y ⊑[ P ] z ] → [ x ⊑[ P ] z ] ⊑[_]-trans (_ , _ , _ , _ , ⊑-trans , _) = ⊑-trans ⊑[_]-antisym : (P : Poset ℓ₀ ℓ₁) (x y : ∣ P ∣ₚ) → [ x ⊑[ P ] y ] → [ y ⊑[ P ] x ] → x ≡ y ⊑[_]-antisym (_ , _ , _ , _ , _ , ⊑-antisym) = ⊑-antisym carrier-is-set : (P : Poset ℓ₀ ℓ₁) → isSet ∣ P ∣ₚ carrier-is-set (_ , _ , is-set , _) = is-set -- Definition of a monotonic map amounts to forgetting the partial order axioms. isMonotonic : (P : Poset ℓ₀ ℓ₁) (Q : Poset ℓ₀′ ℓ₁′) → (∣ P ∣ₚ → ∣ Q ∣ₚ) → Type _ isMonotonic (A , (_⊑₀_ , _)) (B , (_⊑₁_ , _)) = isOrderPreserving (A , _⊑₀_) (B , _⊑₁_) isPropIsMonotonic : (P : Poset ℓ₀ ℓ₁) (Q : Poset ℓ₀′ ℓ₁′) → (f : ∣ P ∣ₚ → ∣ Q ∣ₚ) → isProp (isMonotonic P Q f) isPropIsMonotonic (A , (_⊑₀_ , _)) (B , (_⊑₁_ , _)) f = isPropIsOrderPreserving (A , _⊑₀_) (B , _⊑₁_) f -- We collect the type of monotonic maps between two posets in the following -- type. _─m→_ : Poset ℓ₀ ℓ₁ → Poset ℓ₀′ ℓ₁′ → Type _ _─m→_ P Q = Σ[ f ∈ (∣ P ∣ₚ → ∣ Q ∣ₚ) ] (isMonotonic P Q f) -- The identity monotonic map and composition of monotonic maps. 𝟏m : (P : Poset ℓ₀ ℓ₁) → P ─m→ P 𝟏m P = idfun ∣ P ∣ₚ , (λ x y x⊑y → x⊑y) _∘m_ : {P : Poset ℓ₀ ℓ₁} {Q : Poset ℓ₀′ ℓ₁′} {R : Poset ℓ₀′′ ℓ₁′′} → (Q ─m→ R) → (P ─m→ Q) → (P ─m→ R) (g , pg) ∘m (f , pf) = g ∘ f , λ x y p → pg (f x) (f y) (pf x y p) forget-mono : (P : Poset ℓ₀ ℓ₁) (Q : Poset ℓ₀′ ℓ₁′) ((f , f-mono) (g , g-mono) : P ─m→ Q) → f ≡ g → (f , f-mono) ≡ (g , g-mono) forget-mono P Q (f , f-mono) (g , g-mono) = Σ≡Prop (λ f → isPropΠ3 λ x y x⊑y → snd (f x ⊑[ Q ] f y)) module PosetReasoning (P : Poset ℓ₀ ℓ₁) where _⊑⟨_⟩_ : (x : ∣ P ∣ₚ) {y z : ∣ P ∣ₚ} → [ x ⊑[ P ] y ] → [ y ⊑[ P ] z ] → [ x ⊑[ P ] z ] _ ⊑⟨ p ⟩ q = ⊑[ P ]-trans _ _ _ p q _■ : (x : ∣ P ∣ₚ) → [ x ⊑[ P ] x ] _■ = ⊑[ P ]-refl infixr 0 _⊑⟨_⟩_ infix 1 _■ -- Univalence for posets. isAMonotonicEqv : (P : Poset ℓ₀ ℓ₁) (Q : Poset ℓ₀′ ℓ₁′) → ∣ P ∣ₚ ≃ ∣ Q ∣ₚ → Type _ isAMonotonicEqv (A , (_⊑₀_ , _)) (B , (_⊑₁_ , _)) = isAnOrderPreservingEqv (A , _⊑₀_) (B , _⊑₁_) isPropIsAMonotonicEqv : (P : Poset ℓ₀ ℓ₁) (Q : Poset ℓ₀ ℓ₁′) → (eqv : ∣ P ∣ₚ ≃ ∣ Q ∣ₚ) → isProp (isAMonotonicEqv P Q eqv) isPropIsAMonotonicEqv P Q e@(f , _) = isPropΣ (isPropIsMonotonic P Q f) λ _ → isPropIsMonotonic Q P g where g = equivFun (invEquiv e) -- We denote by `_≃ₚ_` the type of monotonic poset equivalences. _≃ₚ_ : Poset ℓ₀ ℓ₁ → Poset ℓ₀ ℓ₁ → Type _ _≃ₚ_ P Q = Σ[ i ∈ ∣ P ∣ₚ ≃ ∣ Q ∣ₚ ] isAMonotonicEqv P Q i -- From this, we can already establish that posets form an SNS and prove that -- the category of posets is univalent. posetUnivalentStr : SNS {ℓ} (PosetStructure ℓ₁) isAMonotonicEqv posetUnivalentStr {ℓ₁ = ℓ₁} = UnivalentStr→SNS (PosetStructure ℓ₁) isAMonotonicEqv (axiomsUnivalentStr _ NTS (SNS→UnivalentStr isAnOrderPreservingEqv orderUnivalentStr)) where NTS : (A : Type ℓ) (_⊑_ : Order ℓ₁ A) → isProp [ satPosetAx ℓ₁ A _⊑_ ] NTS A _⊑_ = snd (satPosetAx ℓ₁ A _⊑_) poset-univ₀ : (P Q : Poset ℓ₀ ℓ₁) → (P ≃ₚ Q) ≃ (P ≡ Q) poset-univ₀ = SIP (SNS→UnivalentStr isAMonotonicEqv posetUnivalentStr) -- This result is almost what we want but it is better talk directly about poset -- _isomorphisms_ rather than equivalences. In the case when types `A` and `B` -- are sets, the type of isomorphisms between `A` and `B` is equivalent to the -- type of equivalences betwee them. -- Let us start by writing down what a poset isomorphisms is. isPosetIso : (P Q : Poset ℓ₀ ℓ₁) → (P ─m→ Q) → Type _ isPosetIso P Q (f , _) = Σ[ (g , _) ∈ (Q ─m→ P) ] section f g × retract f g isPosetIso-prop : (P Q : Poset ℓ₀ ℓ₁) (f : P ─m→ Q) → isProp (isPosetIso P Q f) isPosetIso-prop P Q (f , f-mono) (g₀ , sec₀ , ret₀) (g₁ , sec₁ , ret₁) = Σ≡Prop NTS g₀=g₁ where NTS : ((g , _) : Q ─m→ P) → isProp (section f g × retract f g) NTS (g , g-mono) = isPropΣ (isPropΠ λ x → carrier-is-set Q (f (g x)) x) λ _ → isPropΠ λ x → carrier-is-set P (g (f x)) x g₀=g₁ : g₀ ≡ g₁ g₀=g₁ = forget-mono Q P g₀ g₁ (funExt λ x → fst g₀ x ≡⟨ sym (cong (λ - → fst g₀ -) (sec₁ x)) ⟩ fst g₀ (f (fst g₁ x)) ≡⟨ ret₀ (fst g₁ x) ⟩ fst g₁ x ∎) -- We will denote by `P ≅ₚ Q` the type of isomorphisms between posets `P` and -- `Q`. _≅ₚ_ : Poset ℓ₀ ℓ₁ → Poset ℓ₀ ℓ₁ → Type _ P ≅ₚ Q = Σ[ f ∈ P ─m→ Q ] isPosetIso P Q f -- ≅ₚ is equivalent to ≃ₚ. ≃ₚ≃≅ₚ : (P Q : Poset ℓ₀ ℓ₁) → (P ≅ₚ Q) ≃ (P ≃ₚ Q) ≃ₚ≃≅ₚ P Q = isoToEquiv (iso from to ret sec) where to : P ≃ₚ Q → P ≅ₚ Q to (e@(f , _) , (f-mono , g-mono)) = (f , f-mono) , (g , g-mono) , sec-f-g , ret-f-g where is = equivToIso e g = equivFun (invEquiv e) sec-f-g : section f g sec-f-g = Iso.rightInv (equivToIso e) ret-f-g : retract f g ret-f-g = Iso.leftInv (equivToIso e) from : P ≅ₚ Q → P ≃ₚ Q from ((f , f-mono) , ((g , g-mono) , sec , ret)) = isoToEquiv is , f-mono , g-mono where is : Iso ∣ P ∣ₚ ∣ Q ∣ₚ is = iso f g sec ret sec : section to from sec (f , _) = Σ≡Prop (isPosetIso-prop P Q) refl ret : retract to from ret (e , _) = Σ≡Prop (isPropIsAMonotonicEqv P Q) (Σ≡Prop isPropIsEquiv refl) -- Once we have this equivalence, the main result is then: the type of poset -- isomorphisms between `P` and `Q` is equivalent to the type of identity proofs -- between `P` and `Q` poset-univ : (P Q : Poset ℓ₀ ℓ₁) → (P ≅ₚ Q) ≃ (P ≡ Q) poset-univ P Q = P ≅ₚ Q ≃⟨ ≃ₚ≃≅ₚ P Q ⟩ P ≃ₚ Q ≃⟨ poset-univ₀ P Q ⟩ P ≡ Q QED
{ "alphanum_fraction": 0.5565239682, "avg_line_length": 36.3447204969, "ext": "agda", "hexsha": "a4773906e4b2337d51dd89474c7b3641a4c44eda", "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": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/Relation/Binary/Poset.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "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": "knrafto/cubical", "max_issues_repo_path": "Cubical/Relation/Binary/Poset.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/Relation/Binary/Poset.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5229, "size": 11703 }
------------------------------------------------------------------------ -- A derivative operator for parsers ------------------------------------------------------------------------ -- Similar to the derivative operator in Brzozowski's "Derivatives of -- Regular Expressions". module TotalParserCombinators.Derivative where -- Definition of the derivative. open import TotalParserCombinators.Derivative.Definition public -- The derivative operator is sound and complete with respect to the -- semantics. open import TotalParserCombinators.Derivative.SoundComplete public hiding (complete′) -- A proof showing that the derivative operator does not introduce any -- unneeded ambiguity. open import TotalParserCombinators.Derivative.LeftInverse public -- A proof showing that the derivative operator does not remove any -- ambiguity. open import TotalParserCombinators.Derivative.RightInverse public hiding (sound∘complete′) -- Some corollaries. open import TotalParserCombinators.Derivative.Corollaries public
{ "alphanum_fraction": 0.6995121951, "avg_line_length": 30.1470588235, "ext": "agda", "hexsha": "07de1f6fde62398bf2ede9267b6d4484ac59542d", "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/Derivative.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/Derivative.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/Derivative.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 193, "size": 1025 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Vehicle.Data.Tensor open import Data.Integer as ℤ using (ℤ) open import Data.Rational as ℚ using (ℚ) open import Data.Bool as 𝔹 using (Bool; true; false; if_then_else_) open import Data.Fin as Fin using (#_) open import Data.List open import Relation.Nullary open import Relation.Nullary.Decidable module windController-output where private VEHICLE_PROJECT_FILE = "TODO_projectFile" InputVector : Set InputVector = Tensor ℚ (2 ∷ []) deltaV : InputVector → ℚ deltaV = evaluate record { projectFile = VEHICLE_PROJECT_FILE ; networkUUID = "TODO_networkUUID" } abs : ℚ → ℚ abs x = if ⌊ x ℚ.<? ℤ.+ 0 ℚ./ 1 ⌋ then ℚ.- x else x currentPosition : InputVector → ℚ currentPosition x = x (# 0) prevPosition : InputVector → ℚ prevPosition x = x (# 1) SafeInput : InputVector → Set SafeInput x = abs (currentPosition x) ℚ.< ℤ.+ 3 ℚ./ 1 SafeOutput : InputVector → Set SafeOutput x = abs ((deltaV x ℚ.+ (ℤ.+ 2 ℚ./ 1) ℚ.* currentPosition x) ℚ.- prevPosition x) ℚ.< ℤ.+ 2 ℚ./ 1 abstract safe : ∀ (x : Tensor ℚ (2 ∷ [])) → SafeInput x → SafeOutput x safe = checkProperty record { projectFile = VEHICLE_PROJECT_FILE ; propertyUUID = "TODO_propertyUUID" }
{ "alphanum_fraction": 0.6944639103, "avg_line_length": 26.4259259259, "ext": "agda", "hexsha": "b20e89b396cc99638941fdb45b3432d2b415f4d3", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-11-16T14:30:47.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-15T15:22:31.000Z", "max_forks_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "wenkokke/vehicle", "max_forks_repo_path": "examples/network/windController/windController-output.agda", "max_issues_count": 53, "max_issues_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_issues_repo_issues_event_max_datetime": "2021-12-15T22:42:01.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-16T07:26:42.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "wenkokke/vehicle", "max_issues_repo_path": "examples/network/windController/windController-output.agda", "max_line_length": 106, "max_stars_count": 11, "max_stars_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "wenkokke/vehicle", "max_stars_repo_path": "examples/network/windController/windController-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T01:35:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-24T05:55:15.000Z", "num_tokens": 448, "size": 1427 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Monoidal.Structure using (SymmetricMonoidalCategory) module Categories.Functor.Monoidal.Symmetric {o o′ ℓ ℓ′ e e′} (C : SymmetricMonoidalCategory o ℓ e) (D : SymmetricMonoidalCategory o′ ℓ′ e′) where open import Level open import Data.Product using (_,_) open import Categories.Functor using (Functor) open import Categories.Functor.Monoidal private module C = SymmetricMonoidalCategory C renaming (braidedMonoidalCategory to B) module D = SymmetricMonoidalCategory D renaming (braidedMonoidalCategory to B) import Categories.Functor.Monoidal.Braided C.B D.B as Braided module Lax where open Braided.Lax -- Lax symmetric monoidal functors are just lax braided monoidal -- functors between symmetric monoidal categories. record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field F : Functor C.U D.U isBraidedMonoidal : IsBraidedMonoidalFunctor F open Functor F public open IsBraidedMonoidalFunctor isBraidedMonoidal public monoidalFunctor : MonoidalFunctor C.monoidalCategory D.monoidalCategory monoidalFunctor = record { isMonoidal = isMonoidal } module Strong where open Braided.Strong -- Strong symmetric monoidal functors are just strong braided -- monoidal functors between symmetric monoidal categories. record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field F : Functor C.U D.U isBraidedMonoidal : IsBraidedMonoidalFunctor F open Functor F public open IsBraidedMonoidalFunctor isBraidedMonoidal public monoidalFunctor : StrongMonoidalFunctor C.monoidalCategory D.monoidalCategory monoidalFunctor = record { isStrongMonoidal = isStrongMonoidal }
{ "alphanum_fraction": 0.7468002226, "avg_line_length": 32.6727272727, "ext": "agda", "hexsha": "c45193fed04f21084bbd7d6d2f7a28149778050d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TOTBWF/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Monoidal/Symmetric.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "TOTBWF/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Monoidal/Symmetric.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TOTBWF/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Monoidal/Symmetric.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 502, "size": 1797 }
module Properties.Remember where open import Agda.Builtin.Equality using (_≡_; refl) data Remember {A : Set} (a : A) : Set where _,_ : ∀ b → (a ≡ b) → Remember(a) remember : ∀ {A} (a : A) → Remember(a) remember a = (a , refl)
{ "alphanum_fraction": 0.6137339056, "avg_line_length": 23.3, "ext": "agda", "hexsha": "5058d594d351d8d66b1321027d427dce4227c7e9", "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": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/Properties/Remember.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "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": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/Properties/Remember.agda", "max_line_length": 51, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/Properties/Remember.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 78, "size": 233 }
{-# OPTIONS --safe #-} module Definition.Typed where open import Definition.Untyped open import Tools.Nat using (Nat) open import Tools.Product import Tools.PropositionalEquality as PE infixl 30 _∙_ infix 30 Πⱼ_▹_▹_▹_ -- Well-typed variables data _∷_^_∈_ : (x : Nat) (A : Term) (r : TypeInfo) (Γ : Con Term) → Set where here : ∀ {Γ A r} → 0 ∷ wk1 A ^ r ∈ (Γ ∙ A ^ r ) there : ∀ {Γ A rA B rB x} (h : x ∷ A ^ rA ∈ Γ) → Nat.suc x ∷ wk1 A ^ rA ∈ (Γ ∙ B ^ rB) mutual -- Well-formed context data ⊢_ : Con Term → Set where ε : ⊢ ε _∙_ : ∀ {Γ A r} → ⊢ Γ → Γ ⊢ A ^ r → ⊢ Γ ∙ A ^ r -- Well-formed type data _⊢_^_ (Γ : Con Term) : Term → TypeInfo → Set where Uⱼ : ∀ {r} → ⊢ Γ → Γ ⊢ Univ r ¹ ^ [ ! , ∞ ] univ : ∀ {A r l} → Γ ⊢ A ∷ Univ r l ^ [ ! , next l ] → Γ ⊢ A ^ [ r , ι l ] -- Well-formed term of a type data _⊢_∷_^_ (Γ : Con Term) : Term → Term → TypeInfo → Set where univ : ∀ {r l l'} → l < l' → ⊢ Γ → Γ ⊢ (Univ r l) ∷ (Univ ! l') ^ [ ! , next l' ] ℕⱼ : ⊢ Γ → Γ ⊢ ℕ ∷ U ⁰ ^ [ ! , ι ¹ ] Emptyⱼ : ∀ {l} → ⊢ Γ → Γ ⊢ Empty l ∷ SProp l ^ [ ! , next l ] Πⱼ_▹_▹_▹_ : ∀ {F rF lF G lG r l} → lF ≤ l → lG ≤ l → Γ ⊢ F ∷ (Univ rF lF) ^ [ ! , next lF ] → Γ ∙ F ^ [ rF , ι lF ] ⊢ G ∷ (Univ r lG) ^ [ ! , next lG ] → Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° l ∷ (Univ r l) ^ [ ! , next l ] ∃ⱼ_▹_ : ∀ {F G l} → Γ ⊢ F ∷ SProp l ^ [ ! , next l ] → Γ ∙ F ^ [ % , ι l ] ⊢ G ∷ SProp l ^ [ ! , next l ] → Γ ⊢ ∃ F ▹ G ∷ SProp l ^ [ ! , next l ] var : ∀ {A rl x} → ⊢ Γ → x ∷ A ^ rl ∈ Γ → Γ ⊢ var x ∷ A ^ rl lamⱼ : ∀ {F r l rF lF G lG t} → lF ≤ l → lG ≤ l → Γ ⊢ F ^ [ rF , ι lF ] → Γ ∙ F ^ [ rF , ι lF ] ⊢ t ∷ G ^ [ r , ι lG ] → Γ ⊢ lam F ▹ t ^ l ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ r , ι l ] _∘ⱼ_ : ∀ {g a F rF lF G lG r lΠ} → Γ ⊢ g ∷ Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ [ r , ι lΠ ] → Γ ⊢ a ∷ F ^ [ rF , ι lF ] → Γ ⊢ g ∘ a ^ lΠ ∷ G [ a ] ^ [ r , ι lG ] ⦅_,_,_,_⦆ⱼ : ∀ {l F G t u} → Γ ⊢ F ^ [ % , ι l ] → Γ ∙ F ^ [ % , ι l ] ⊢ G ^ [ % , ι l ] → Γ ⊢ t ∷ F ^ [ % , ι l ] → Γ ⊢ u ∷ G [ t ] ^ [ % , ι l ] → Γ ⊢ ⦅ G , t , u ⦆ ∷ ∃ F ▹ G ^ [ % , ι l ] fstⱼ : ∀ {F G t l} → Γ ⊢ F ∷ SProp l ^ [ ! , next l ] → Γ ∙ F ^ [ % , ι l ] ⊢ G ∷ SProp l ^ [ ! , next l ] → Γ ⊢ t ∷ ∃ F ▹ G ^ [ % , ι l ] → Γ ⊢ fst t ∷ F ^ [ % , ι l ] sndⱼ : ∀ {F G t l} → Γ ⊢ F ∷ SProp l ^ [ ! , next l ] → Γ ∙ F ^ [ % , ι l ] ⊢ G ∷ SProp l ^ [ ! , next l ] → Γ ⊢ t ∷ ∃ F ▹ G ^ [ % , ι l ] → Γ ⊢ snd t ∷ G [ fst t ] ^ [ % , ι l ] zeroⱼ : ⊢ Γ → Γ ⊢ zero ∷ ℕ ^ [ ! , ι ⁰ ] sucⱼ : ∀ {n} → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ suc n ∷ ℕ ^ [ ! , ι ⁰ ] natrecⱼ : ∀ {G rG lG s z n} → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ G ^ [ rG , ι lG ] → Γ ⊢ z ∷ G [ zero ] ^ [ rG , ι lG ] → Γ ⊢ s ∷ Π ℕ ^ ! ° ⁰ ▹ (G ^ rG ° lG ▹▹ G [ suc (var Nat.zero) ]↑ ° lG ° lG) ° lG ° lG ^ [ rG , ι lG ] → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ natrec lG G z s n ∷ G [ n ] ^ [ rG , ι lG ] Emptyrecⱼ : ∀ {A l lA rA e} → Γ ⊢ A ^ [ rA , ι lA ] → Γ ⊢ e ∷ Empty l ^ [ % , ι l ] -> Γ ⊢ Emptyrec lA l A e ∷ A ^ [ rA , ι lA ] Idⱼ : ∀ {A l t u} → Γ ⊢ A ∷ U l ^ [ ! , next l ] → Γ ⊢ t ∷ A ^ [ ! , ι l ] → Γ ⊢ u ∷ A ^ [ ! , ι l ] → Γ ⊢ Id A t u ∷ SProp l ^ [ ! , next l ] Idreflⱼ : ∀ {A l t} → Γ ⊢ t ∷ A ^ [ ! , ι l ] → Γ ⊢ Idrefl A t ∷ (Id A t t) ^ [ % , ι l ] transpⱼ : ∀ {A l P t s u e} → Γ ⊢ A ^ [ ! , l ] → Γ ∙ A ^ [ ! , l ] ⊢ P ^ [ % , l ] → Γ ⊢ t ∷ A ^ [ ! , l ] → Γ ⊢ s ∷ P [ t ] ^ [ % , l ] → Γ ⊢ u ∷ A ^ [ ! , l ] → Γ ⊢ e ∷ (Id A t u) ^ [ % , l ] → Γ ⊢ transp A P t s u e ∷ P [ u ] ^ [ % , l ] castⱼ : ∀ {A B r e t} → Γ ⊢ A ∷ Univ r ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ B ∷ Univ r ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ e ∷ (Id (Univ r ⁰) A B) ^ [ % , next ⁰ ] → Γ ⊢ t ∷ A ^ [ r , ι ⁰ ] → Γ ⊢ cast ⁰ A B e t ∷ B ^ [ r , ι ⁰ ] castreflⱼ : ∀ {A t} → Γ ⊢ A ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ t ∷ A ^ [ ! , ι ⁰ ] → Γ ⊢ castrefl A t ∷ (Id A t (cast ⁰ A A (Idrefl (U ⁰) A) t)) ^ [ % , ι ⁰ ] conv : ∀ {t A B r} → Γ ⊢ t ∷ A ^ r → Γ ⊢ A ≡ B ^ r → Γ ⊢ t ∷ B ^ r -- Type equality data _⊢_≡_^_ (Γ : Con Term) : Term → Term → TypeInfo → Set where univ : ∀ {A B r l} → Γ ⊢ A ≡ B ∷ (Univ r l) ^ [ ! , next l ] → Γ ⊢ A ≡ B ^ [ r , ι l ] refl : ∀ {A r} → Γ ⊢ A ^ r → Γ ⊢ A ≡ A ^ r sym : ∀ {A B r} → Γ ⊢ A ≡ B ^ r → Γ ⊢ B ≡ A ^ r trans : ∀ {A B C r} → Γ ⊢ A ≡ B ^ r → Γ ⊢ B ≡ C ^ r → Γ ⊢ A ≡ C ^ r -- Term equality data _⊢_≡_∷_^_ (Γ : Con Term) : Term → Term → Term → TypeInfo → Set where refl : ∀ {t A l} → Γ ⊢ t ∷ A ^ [ ! , l ] → Γ ⊢ t ≡ t ∷ A ^ [ ! , l ] sym : ∀ {t u A l} → Γ ⊢ t ≡ u ∷ A ^ [ ! , l ] → Γ ⊢ u ≡ t ∷ A ^ [ ! , l ] trans : ∀ {t u v A l} → Γ ⊢ t ≡ u ∷ A ^ [ ! , l ] → Γ ⊢ u ≡ v ∷ A ^ [ ! , l ] → Γ ⊢ t ≡ v ∷ A ^ [ ! , l ] conv : ∀ {A B r t u} → Γ ⊢ t ≡ u ∷ A ^ r → Γ ⊢ A ≡ B ^ r → Γ ⊢ t ≡ u ∷ B ^ r Π-cong : ∀ {E F G H rF lF rG lG l} → lF ≤ l → lG ≤ l → Γ ⊢ F ^ [ rF , ι lF ] → Γ ⊢ F ≡ H ∷ (Univ rF lF) ^ [ ! , next lF ] → Γ ∙ F ^ [ rF , ι lF ] ⊢ G ≡ E ∷ (Univ rG lG) ^ [ ! , next lG ] → Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° l ≡ Π H ^ rF ° lF ▹ E ° lG ° l ∷ (Univ rG l) ^ [ ! , next l ] ∃-cong : ∀ {E F G H l} → Γ ⊢ F ^ [ % , ι l ] → Γ ⊢ F ≡ H ∷ SProp l ^ [ ! , next l ] → Γ ∙ F ^ [ % , ι l ] ⊢ G ≡ E ∷ SProp l ^ [ ! , next l ] → Γ ⊢ ∃ F ▹ G ≡ ∃ H ▹ E ∷ SProp l ^ [ ! , next l ] app-cong : ∀ {a b f g F G rF lF lG l} → Γ ⊢ f ≡ g ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ] → Γ ⊢ a ≡ b ∷ F ^ [ rF , ι lF ] → Γ ⊢ f ∘ a ^ l ≡ g ∘ b ^ l ∷ G [ a ] ^ [ ! , ι lG ] β-red : ∀ {a t F rF lF G lG l} → lF ≤ l → lG ≤ l → Γ ⊢ F ^ [ rF , ι lF ] → Γ ∙ F ^ [ rF , ι lF ] ⊢ t ∷ G ^ [ ! , ι lG ] → Γ ⊢ a ∷ F ^ [ rF , ι lF ] → Γ ⊢ (lam F ▹ t ^ l) ∘ a ^ l ≡ t [ a ] ∷ G [ a ] ^ [ ! , ι lG ] η-eq : ∀ {f g F rF lF lG l G} → lF ≤ l → lG ≤ l → Γ ⊢ F ^ [ rF , ι lF ] → Γ ⊢ f ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ] → Γ ⊢ g ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ] → Γ ∙ F ^ [ rF , ι lF ] ⊢ wk1 f ∘ var Nat.zero ^ l ≡ wk1 g ∘ var Nat.zero ^ l ∷ G ^ [ ! , ι lG ] → Γ ⊢ f ≡ g ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ] suc-cong : ∀ {m n} → Γ ⊢ m ≡ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ suc m ≡ suc n ∷ ℕ ^ [ ! , ι ⁰ ] natrec-cong : ∀ {z z′ s s′ n n′ F F′ l} → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F ≡ F′ ^ [ ! , ι l ] → Γ ⊢ z ≡ z′ ∷ F [ zero ] ^ [ ! , ι l ] → Γ ⊢ s ≡ s′ ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° l ▹▹ F [ suc (var Nat.zero) ]↑ ° l ° l) ° l ° l ^ [ ! , ι l ] → Γ ⊢ n ≡ n′ ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ natrec l F z s n ≡ natrec l F′ z′ s′ n′ ∷ F [ n ] ^ [ ! , ι l ] natrec-zero : ∀ {z s F l} → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F ^ [ ! , ι l ] → Γ ⊢ z ∷ F [ zero ] ^ [ ! , ι l ] → Γ ⊢ s ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° l ▹▹ F [ suc (var Nat.zero) ]↑ ° l ° l) ° l ° l ^ [ ! , ι l ] → Γ ⊢ natrec l F z s zero ≡ z ∷ F [ zero ] ^ [ ! , ι l ] natrec-suc : ∀ {n z s F l} → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F ^ [ ! , ι l ] → Γ ⊢ z ∷ F [ zero ] ^ [ ! , ι l ] → Γ ⊢ s ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° l ▹▹ F [ suc (var Nat.zero) ]↑ ° l ° l) ° l ° l ^ [ ! , ι l ] → Γ ⊢ natrec l F z s (suc n) ≡ (s ∘ n ^ l) ∘ (natrec l F z s n) ^ l ∷ F [ suc n ] ^ [ ! , ι l ] Emptyrec-cong : ∀ {A A' l lEmpty e e'} → Γ ⊢ A ≡ A' ^ [ ! , ι l ] → Γ ⊢ e ∷ Empty lEmpty ^ [ % , ι lEmpty ] → Γ ⊢ e' ∷ Empty lEmpty ^ [ % , ι lEmpty ] → Γ ⊢ Emptyrec l lEmpty A e ≡ Emptyrec l lEmpty A' e' ∷ A ^ [ ! , ι l ] proof-irrelevance : ∀ {t u A l} → Γ ⊢ t ∷ A ^ [ % , l ] → Γ ⊢ u ∷ A ^ [ % , l ] → Γ ⊢ t ≡ u ∷ A ^ [ % , l ] Id-cong : ∀ {A A' l t t' u u'} → Γ ⊢ A ≡ A' ∷ Univ ! l ^ [ ! , next l ] → Γ ⊢ t ≡ t' ∷ A ^ [ ! , ι l ] → Γ ⊢ u ≡ u' ∷ A ^ [ ! , ι l ] → Γ ⊢ Id A t u ≡ Id A' t' u' ∷ SProp l ^ [ ! , next l ] Id-Π : ∀ {A rA lA lB l B t u} → lA ≤ l → lB ≤ l → Γ ⊢ A ∷ Univ rA lA ^ [ ! , next lA ] → Γ ∙ A ^ [ rA , ι lA ] ⊢ B ∷ Univ ! lB ^ [ ! , next lB ] → Γ ⊢ t ∷ (Π A ^ rA ° lA ▹ B ° lB ° l) ^ [ ! , ι l ] → Γ ⊢ u ∷ (Π A ^ rA ° lA ▹ B ° lB ° l) ^ [ ! , ι l ] → Γ ⊢ (Id (Π A ^ rA ° lA ▹ B ° lB ° l) t u) ≡ Π A ^ rA ° lA ▹ (Id B ((wk1 t) ∘ (var 0) ^ l) ((wk1 u) ∘ (var 0) ^ l)) ° lB ° l ∷ SProp l ^ [ ! , next l ] Id-ℕ-00 : ⊢ Γ → Γ ⊢ (Id ℕ zero zero) ≡ Unit {⁰} ∷ SProp ⁰ ^ [ ! , next ⁰ ] Id-ℕ-SS : ∀ {m n} → Γ ⊢ m ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ (Id ℕ (suc m) (suc n)) ≡ (Id ℕ m n) ∷ SProp ⁰ ^ [ ! , next ⁰ ] Id-U-ΠΠ : ∀ {A A' rA B B'} → Γ ⊢ A ∷ (Univ rA ⁰) ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ A' ∷ (Univ rA ⁰) ^ [ ! , next ⁰ ] → Γ ∙ A' ^ [ rA , ι ⁰ ] ⊢ B' ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰)) ≡ ∃ (Id (Univ rA ⁰) A A') ▹ (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰) ((wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (wk (lift (step id)) B') ° ¹ ° ¹) ∷ SProp ¹ ^ [ ! , next ¹ ] Id-U-ℕℕ : ⊢ Γ → Γ ⊢ Id (U ⁰) ℕ ℕ ≡ Unit {¹} ∷ (SProp ¹) ^ [ ! , next ¹ ] Id-SProp : ∀ {A B} → Γ ⊢ A ∷ SProp ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ B ∷ SProp ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (SProp ⁰) A B ≡ (A ^ % ° ⁰ ▹▹ B ° ⁰ ° ¹) ×× (B ^ % ° ⁰ ▹▹ A ° ⁰ ° ¹) ∷ SProp ¹ ^ [ ! , next ¹ ] Id-ℕ-0S : ∀ {t} → Γ ⊢ t ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ Id ℕ zero (suc t) ≡ Empty ⁰ ∷ (SProp ⁰) ^ [ ! , next ⁰ ] Id-ℕ-S0 : ∀ {t} → Γ ⊢ t ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ Id ℕ (suc t) zero ≡ Empty ⁰ ∷ (SProp ⁰) ^ [ ! , next ⁰ ] Id-U-ℕΠ : ∀ {A rA B} → Γ ⊢ A ∷ Univ rA ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (U ⁰) ℕ (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) ≡ Empty ¹ ∷ SProp ¹ ^ [ ! , next ¹ ] Id-U-Πℕ : ∀ {A rA B} → Γ ⊢ A ∷ Univ rA ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) ℕ ≡ Empty ¹ ∷ SProp ¹ ^ [ ! , next ¹ ] Id-U-ΠΠ!% : ∀ {A rA B A' rA' B' } → rA PE.≢ rA' → Γ ⊢ A ∷ Univ rA ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ A' ∷ Univ rA' ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A' ^ [ rA' , ι ⁰ ] ⊢ B' ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA' ° ⁰ ▹ B' ° ⁰ ° ⁰) ≡ Empty ¹ ∷ SProp ¹ ^ [ ! , next ¹ ] cast-cong : ∀ {A A' B B' e e' t t'} → let l = ⁰ in Γ ⊢ A ≡ A' ∷ U l ^ [ ! , next l ] → Γ ⊢ B ≡ B' ∷ U l ^ [ ! , next l ] → Γ ⊢ t ≡ t' ∷ A ^ [ ! , ι l ] → Γ ⊢ e ∷ (Id (U ⁰) A B) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) A' B') ^ [ % , next ⁰ ] → Γ ⊢ cast l A B e t ≡ cast l A' B' e' t' ∷ B ^ [ ! , ι l ] cast-Π : ∀ {A A' rA B B' e f} → let l = ⁰ in let lA = ⁰ in let lB = ⁰ in Γ ⊢ A ∷ (Univ rA lA) ^ [ ! , next lA ] → Γ ∙ A ^ [ rA , ι lA ] ⊢ B ∷ U lB ^ [ ! , next lB ] → Γ ⊢ A' ∷ (Univ rA lA) ^ [ ! , next lA ] → Γ ∙ A' ^ [ rA , ι lA ] ⊢ B' ∷ U lB ^ [ ! , next lB ] → Γ ⊢ e ∷ Id (U l) (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) ^ [ % , next l ] → Γ ⊢ f ∷ (Π A ^ rA ° lA ▹ B ° lB ° l) ^ [ ! , ι l ] → Γ ⊢ (cast l (Π A ^ rA ° lA ▹ B ° lB ° l) (Π A' ^ rA ° lA ▹ B' ° lB ° l) e f) ≡ (lam A' ▹ (let a = cast l (wk1 A') (wk1 A) (Idsym (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) in cast l (B [ a ]↑) B' ((snd (wk1 e)) ∘ (var 0) ^ ¹) ((wk1 f) ∘ a ^ l)) ^ l) ∷ Π A' ^ rA ° lA ▹ B' ° lB ° l ^ [ ! , ι l ] cast-ℕ-0 : ∀ {e} → Γ ⊢ e ∷ Id (U ⁰) ℕ ℕ ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ ℕ ℕ e zero ≡ zero ∷ ℕ ^ [ ! , ι ⁰ ] cast-ℕ-S : ∀ {e n} → Γ ⊢ e ∷ Id (U ⁰) ℕ ℕ ^ [ % , next ⁰ ] → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ cast ⁰ ℕ ℕ e (suc n) ≡ suc (cast ⁰ ℕ ℕ e n) ∷ ℕ ^ [ ! , ι ⁰ ] mutual data _⊢_⇒_∷_^_ (Γ : Con Term) : Term → Term → Term → TypeLevel → Set where conv : ∀ {A B l t u} → Γ ⊢ t ⇒ u ∷ A ^ l → Γ ⊢ A ≡ B ^ [ ! , l ] → Γ ⊢ t ⇒ u ∷ B ^ l app-subst : ∀ {A B t u a rA lA lB l} → Γ ⊢ t ⇒ u ∷ Π A ^ rA ° lA ▹ B ° lB ° l ^ ι l → Γ ⊢ a ∷ A ^ [ rA , ι lA ] → Γ ⊢ t ∘ a ^ l ⇒ u ∘ a ^ l ∷ B [ a ] ^ ι lB β-red : ∀ {A B lA lB a t rA l} → lA ≤ l → lB ≤ l → Γ ⊢ A ^ [ rA , ι lA ] → Γ ∙ A ^ [ rA , ι lA ] ⊢ t ∷ B ^ [ ! , ι lB ] → Γ ⊢ a ∷ A ^ [ rA , ι lA ] → Γ ⊢ (lam A ▹ t ^ l) ∘ a ^ l ⇒ t [ a ] ∷ B [ a ] ^ ι lB natrec-subst : ∀ {z s n n′ F l} → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F ^ [ ! , ι l ] → Γ ⊢ z ∷ F [ zero ] ^ [ ! , ι l ] → Γ ⊢ s ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° l ▹▹ F [ suc (var Nat.zero) ]↑ ° l ° l) ° l ° l ^ [ ! , ι l ] → Γ ⊢ n ⇒ n′ ∷ ℕ ^ ι ⁰ → Γ ⊢ natrec l F z s n ⇒ natrec l F z s n′ ∷ F [ n ] ^ ι l natrec-zero : ∀ {z s F l } → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F ^ [ ! , ι l ] → Γ ⊢ z ∷ F [ zero ] ^ [ ! , ι l ] → Γ ⊢ s ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° l ▹▹ F [ suc (var Nat.zero) ]↑ ° l ° l ) ° l ° l ^ [ ! , ι l ] → Γ ⊢ natrec l F z s zero ⇒ z ∷ F [ zero ] ^ ι l natrec-suc : ∀ {n z s F l} → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F ^ [ ! , ι l ] → Γ ⊢ z ∷ F [ zero ] ^ [ ! , ι l ] → Γ ⊢ s ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° l ▹▹ F [ suc (var Nat.zero) ]↑ ° l ° l) ° l ° l ^ [ ! , ι l ] → Γ ⊢ natrec l F z s (suc n) ⇒ (s ∘ n ^ l) ∘ (natrec l F z s n) ^ l ∷ F [ suc n ] ^ ι l Id-subst : ∀ {A A' l t u} → Γ ⊢ A ⇒ A' ∷ Univ ! l ^ next l → Γ ⊢ t ∷ A ^ [ ! , ι l ] → Γ ⊢ u ∷ A ^ [ ! , ι l ] → Γ ⊢ Id A t u ⇒ Id A' t u ∷ SProp l ^ next l Id-ℕ-subst : ∀ {m m' n} → Γ ⊢ m ⇒ m' ∷ ℕ ^ ι ⁰ → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ Id ℕ m n ⇒ Id ℕ m' n ∷ SProp ⁰ ^ next ⁰ Id-ℕ-0-subst : ∀ {n n'} → Γ ⊢ n ⇒ n' ∷ ℕ ^ ι ⁰ → Γ ⊢ Id ℕ zero n ⇒ Id ℕ zero n' ∷ SProp ⁰ ^ next ⁰ Id-ℕ-S-subst : ∀ {m n n'} → Γ ⊢ m ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ n ⇒ n' ∷ ℕ ^ ι ⁰ → Γ ⊢ Id ℕ (suc m) n ⇒ Id ℕ (suc m) n' ∷ SProp ⁰ ^ next ⁰ Id-U-subst : ∀ {A A' B} → Γ ⊢ A ⇒ A' ∷ U ⁰ ^ next ⁰ → Γ ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (U ⁰ ) A B ⇒ Id (U ⁰) A' B ∷ SProp ¹ ^ next ¹ Id-U-ℕ-subst : ∀ {B B'} → Γ ⊢ B ⇒ B' ∷ U ⁰ ^ next ⁰ → Γ ⊢ Id (U ⁰) ℕ B ⇒ Id (U ⁰) ℕ B' ∷ SProp ¹ ^ next ¹ Id-U-Π-subst : ∀ {A rA P B B'} → Γ ⊢ A ∷ (Univ rA ⁰) ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ P ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ B ⇒ B' ∷ U ⁰ ^ next ⁰ → Γ ⊢ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰) B ⇒ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰) B' ∷ SProp ¹ ^ next ¹ Id-Π : ∀ {A rA lA lB l B t u} → lA ≤ l → lB ≤ l → Γ ⊢ A ∷ Univ rA lA ^ [ ! , next lA ] → Γ ∙ A ^ [ rA , ι lA ] ⊢ B ∷ Univ ! lB ^ [ ! , next lB ] → Γ ⊢ t ∷ (Π A ^ rA ° lA ▹ B ° lB ° l) ^ [ ! , ι l ] → Γ ⊢ u ∷ (Π A ^ rA ° lA ▹ B ° lB ° l) ^ [ ! , ι l ] → Γ ⊢ (Id (Π A ^ rA ° lA ▹ B ° lB ° l) t u) ⇒ Π A ^ rA ° lA ▹ (Id B ((wk1 t) ∘ (var 0) ^ l) ((wk1 u) ∘ (var 0) ^ l)) ° lB ° l ∷ SProp l ^ next l Id-ℕ-00 : ⊢ Γ → Γ ⊢ (Id ℕ zero zero) ⇒ Unit {⁰} ∷ SProp ⁰ ^ next ⁰ Id-ℕ-SS : ∀ {m n} → Γ ⊢ m ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ (Id ℕ (suc m) (suc n)) ⇒ (Id ℕ m n) ∷ SProp ⁰ ^ next ⁰ Id-U-ΠΠ : ∀ {A A' rA B B'} → Γ ⊢ A ∷ (Univ rA ⁰) ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ A' ∷ (Univ rA ⁰) ^ [ ! , next ⁰ ] → Γ ∙ A' ^ [ rA , ι ⁰ ] ⊢ B' ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰)) ⇒ ∃ (Id (Univ rA ⁰) A A') ▹ (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰) ((wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑) (wk1d B') ° ¹ ° ¹) ∷ SProp ¹ ^ next ¹ Id-U-ℕℕ : ⊢ Γ → Γ ⊢ (Id (U ⁰) ℕ ℕ) ⇒ Unit {¹} ∷ SProp ¹ ^ next ¹ Id-SProp : ∀ {A B} → Γ ⊢ A ∷ SProp ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ B ∷ SProp ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (SProp ⁰) A B ⇒ (A ^ % ° ⁰ ▹▹ B ° ⁰ ° ¹) ×× (B ^ % ° ⁰ ▹▹ A ° ⁰ ° ¹) ∷ SProp ¹ ^ next ¹ Id-ℕ-0S : ∀ {t} → Γ ⊢ t ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ Id ℕ zero (suc t) ⇒ Empty ⁰ ∷ SProp ⁰ ^ next ⁰ Id-ℕ-S0 : ∀ {t} → Γ ⊢ t ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ Id ℕ (suc t) zero ⇒ Empty ⁰ ∷ SProp ⁰ ^ next ⁰ Id-U-ℕΠ : ∀ {A rA B} → Γ ⊢ A ∷ Univ rA ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (U ⁰) ℕ (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) ⇒ Empty ¹ ∷ SProp ¹ ^ next ¹ Id-U-Πℕ : ∀ {A rA B} → Γ ⊢ A ∷ Univ rA ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) ℕ ⇒ Empty ¹ ∷ SProp ¹ ^ next ¹ Id-U-ΠΠ!% : ∀ {A rA B A' rA' B' } → rA PE.≢ rA' → Γ ⊢ A ∷ Univ rA ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A ^ [ rA , ι ⁰ ] ⊢ B ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ A' ∷ Univ rA' ⁰ ^ [ ! , next ⁰ ] → Γ ∙ A' ^ [ rA' , ι ⁰ ] ⊢ B' ∷ U ⁰ ^ [ ! , next ⁰ ] → Γ ⊢ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA' ° ⁰ ▹ B' ° ⁰ ° ⁰) ⇒ Empty ¹ ∷ SProp ¹ ^ next ¹ cast-subst : ∀ {A A' B e t} → let l = ⁰ in Γ ⊢ A ⇒ A' ∷ U l ^ next l → Γ ⊢ B ∷ U l ^ [ ! , next l ] → Γ ⊢ e ∷ Id (U l) A B ^ [ % , next l ] → Γ ⊢ t ∷ A ^ [ ! , ι l ] → Γ ⊢ cast l A B e t ⇒ cast l A' B e t ∷ B ^ ι l cast-ℕ-subst : ∀ {B B' e t} → Γ ⊢ B ⇒ B' ∷ U ⁰ ^ next ⁰ → Γ ⊢ e ∷ Id (U ⁰) ℕ B ^ [ % , next ⁰ ] → Γ ⊢ t ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ cast ⁰ ℕ B e t ⇒ cast ⁰ ℕ B' e t ∷ B ^ ι ⁰ cast-Π-subst : ∀ {A rA P B B' e t} → let l = ⁰ in let lA = ⁰ in let lP = ⁰ in Γ ⊢ A ∷ (Univ rA lA) ^ [ ! , next lA ] → Γ ∙ A ^ [ rA , ι lA ] ⊢ P ∷ U lP ^ [ ! , next lA ] → Γ ⊢ B ⇒ B' ∷ U l ^ next l → Γ ⊢ e ∷ Id (U l) (Π A ^ rA ° lA ▹ P ° lP ° l) B ^ [ % , next l ] → Γ ⊢ t ∷ (Π A ^ rA ° lA ▹ P ° lP ° l) ^ [ ! , ι l ] → Γ ⊢ cast l (Π A ^ rA ° lA ▹ P ° lP ° l) B e t ⇒ cast l (Π A ^ rA ° lA ▹ P ° lP ° l) B' e t ∷ B ^ ι l cast-Π : ∀ {A A' rA B B' e f} → let l = ⁰ in Γ ⊢ A ∷ (Univ rA l) ^ [ ! , next l ] → Γ ∙ A ^ [ rA , ι l ] ⊢ B ∷ U l ^ [ ! , next l ] → Γ ⊢ A' ∷ (Univ rA l) ^ [ ! , next l ] → Γ ∙ A' ^ [ rA , ι l ] ⊢ B' ∷ U l ^ [ ! , next l ] → Γ ⊢ e ∷ Id (U l) (Π A ^ rA ° l ▹ B ° l ° l) (Π A' ^ rA ° l ▹ B' ° l ° l) ^ [ % , next l ] → Γ ⊢ f ∷ (Π A ^ rA ° l ▹ B ° l ° l) ^ [ ! , ι l ] → Γ ⊢ (cast l (Π A ^ rA ° l ▹ B ° l ° l) (Π A' ^ rA ° l ▹ B' ° l ° l) e f) ⇒ (lam A' ▹ (let a = cast l (wk1 A') (wk1 A) (Idsym (Univ rA l) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) in cast l (B [ a ]↑) B' ((snd (wk1 e)) ∘ (var 0) ^ ¹) ((wk1 f) ∘ a ^ l)) ^ l ) ∷ Π A' ^ rA ° l ▹ B' ° l ° l ^ ι l cast-ℕ-0 : ∀ {e} → Γ ⊢ e ∷ Id (U ⁰) ℕ ℕ ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ ℕ ℕ e zero ⇒ zero ∷ ℕ ^ ι ⁰ cast-ℕ-S : ∀ {e n} → Γ ⊢ e ∷ Id (U ⁰) ℕ ℕ ^ [ % , next ⁰ ] → Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] → Γ ⊢ cast ⁰ ℕ ℕ e (suc n) ⇒ suc (cast ⁰ ℕ ℕ e n) ∷ ℕ ^ ι ⁰ cast-ℕ-cong : ∀ {e t u} → Γ ⊢ e ∷ Id (U ⁰) ℕ ℕ ^ [ % , next ⁰ ] → Γ ⊢ t ⇒ u ∷ ℕ ^ ι ⁰ → Γ ⊢ cast ⁰ ℕ ℕ e t ⇒ cast ⁰ ℕ ℕ e u ∷ ℕ ^ ι ⁰ -- Type reduction data _⊢_⇒_^_ (Γ : Con Term) : Term → Term → TypeInfo → Set where univ : ∀ {A B r l} → Γ ⊢ A ⇒ B ∷ (Univ r l) ^ next l → Γ ⊢ A ⇒ B ^ [ r , ι l ] -- Term reduction closure data _⊢_⇒*_∷_^_ (Γ : Con Term) : Term → Term → Term → TypeLevel → Set where id : ∀ {A l t} → Γ ⊢ t ∷ A ^ [ ! , l ] → Γ ⊢ t ⇒* t ∷ A ^ l _⇨_ : ∀ {A l t t′ u} → Γ ⊢ t ⇒ t′ ∷ A ^ l → Γ ⊢ t′ ⇒* u ∷ A ^ l → Γ ⊢ t ⇒* u ∷ A ^ l -- Type reduction closure data _⊢_⇒*_^_ (Γ : Con Term) : Term → Term → TypeInfo → Set where id : ∀ {A r} → Γ ⊢ A ^ r → Γ ⊢ A ⇒* A ^ r _⇨_ : ∀ {A A′ B r} → Γ ⊢ A ⇒ A′ ^ r → Γ ⊢ A′ ⇒* B ^ r → Γ ⊢ A ⇒* B ^ r -- Type reduction to whnf _⊢_↘_^_ : (Γ : Con Term) → Term → Term → TypeInfo → Set Γ ⊢ A ↘ B ^ r = Γ ⊢ A ⇒* B ^ r × Whnf B -- Term reduction to whnf _⊢_↘_∷_^_ : (Γ : Con Term) → Term → Term → Term → TypeLevel → Set Γ ⊢ t ↘ u ∷ A ^ l = Γ ⊢ t ⇒* u ∷ A ^ l × Whnf u -- Type equality with well-formed types _⊢_:≡:_^_ : (Γ : Con Term) → Term → Term → TypeInfo → Set Γ ⊢ A :≡: B ^ r = Γ ⊢ A ^ r × Γ ⊢ B ^ r × (Γ ⊢ A ≡ B ^ r) -- Term equality with well-formed terms _⊢_:≡:_∷_^_ : (Γ : Con Term) → Term → Term → Term → TypeInfo → Set Γ ⊢ t :≡: u ∷ A ^ r = Γ ⊢ t ∷ A ^ r × Γ ⊢ u ∷ A ^ r × (Γ ⊢ t ≡ u ∷ A ^ r) -- Type reduction closure with well-formed types record _⊢_:⇒*:_^_ (Γ : Con Term) (A B : Term) (r : TypeInfo) : Set where constructor [[_,_,_]] field ⊢A : Γ ⊢ A ^ r ⊢B : Γ ⊢ B ^ r D : Γ ⊢ A ⇒* B ^ r open _⊢_:⇒*:_^_ using () renaming (D to red) public -- Term reduction closure with well-formed terms record _⊢_:⇒*:_∷_^_ (Γ : Con Term) (t u A : Term) (l : TypeLevel) : Set where constructor [[_,_,_]] field ⊢t : Γ ⊢ t ∷ A ^ [ ! , l ] ⊢u : Γ ⊢ u ∷ A ^ [ ! , l ] d : Γ ⊢ t ⇒* u ∷ A ^ l open _⊢_:⇒*:_∷_^_ using () renaming (d to redₜ) public -- Well-formed substitutions. data _⊢ˢ_∷_ (Δ : Con Term) (σ : Subst) : (Γ : Con Term) → Set where id : Δ ⊢ˢ σ ∷ ε _,_ : ∀ {Γ A rA} → Δ ⊢ˢ tail σ ∷ Γ → Δ ⊢ head σ ∷ subst (tail σ) A ^ rA → Δ ⊢ˢ σ ∷ Γ ∙ A ^ rA -- Conversion of well-formed substitutions. data _⊢ˢ_≡_∷_ (Δ : Con Term) (σ σ′ : Subst) : (Γ : Con Term) → Set where id : Δ ⊢ˢ σ ≡ σ′ ∷ ε _,_ : ∀ {Γ A rA} → Δ ⊢ˢ tail σ ≡ tail σ′ ∷ Γ → Δ ⊢ head σ ≡ head σ′ ∷ subst (tail σ) A ^ rA → Δ ⊢ˢ σ ≡ σ′ ∷ Γ ∙ A ^ rA -- Note that we cannot use the well-formed substitutions. -- For that, we need to prove the fundamental theorem for substitutions. -- Some derivable rules Unitⱼ : ∀ {Γ l} (⊢Γ : ⊢ Γ) → Γ ⊢ Unit ∷ SProp l ^ [ ! , next l ] Unitⱼ ⊢Γ = Πⱼ ≡is≤ PE.refl ▹ ≡is≤ PE.refl ▹ Emptyⱼ ⊢Γ ▹ Emptyⱼ (⊢Γ ∙ univ (Emptyⱼ ⊢Γ)) typeUnit : ∀ {l} → Type (Unit {l}) typeUnit = Πₙ Ugenⱼ : ∀ {r Γ l} → ⊢ Γ → Γ ⊢ Univ r l ^ [ ! , next l ] Ugenⱼ {l = ⁰} ⊢Γ = univ (univ 0<1 ⊢Γ) Ugenⱼ {l = ¹} ⊢Γ = Uⱼ ⊢Γ
{ "alphanum_fraction": 0.2900201192, "avg_line_length": 44.8773424191, "ext": "agda", "hexsha": "9e3d8832db62e4752b0befc79ac958ab425b0559", "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.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.agda", "max_line_length": 155, "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.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": 12312, "size": 26343 }
{-# OPTIONS --sized-types #-} open import Relation.Binary.Core module BBHeap.Height.Convert {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import Bound.Lower A open import Bound.Lower.Order _≤_ open import BBHeap _≤_ open import BBHeap.Properties _≤_ open import BBHeap.Height _≤_ open import BHeap _≤_ hiding (forget) renaming (height to heightₙ) open import Data.List open import Data.Nat renaming (_≤_ to _≤ₙ_) open import Data.Nat.Properties open import Data.Sum open import Function using (_∘_) open import OList _≤_ open import Relation.Binary open import Relation.Binary.PropositionalEquality hiding (trans) open import SNat open DecTotalOrder decTotalOrder hiding (refl) data _⊳_ : {b b' : Bound} → BHeap b → BHeap b' → Set where ⊳leaf : {b b' : Bound} → lf {b} ⊳ lf {b'} ⊳left : {b b' : Bound}{x : A}{l r : BHeap (val x)}{l' : BHeap b'} (b≤x : LeB b (val x)) → l ⊳ r → l ⊳ l' → (nd b≤x l r) ⊳ l' ⊳both : {b b' : Bound}{x x' : A}{l r : BHeap (val x)}{l' r' : BHeap (val x')} (b≤x : LeB b (val x)) (b'≤x' : LeB b' (val x')) → l ⊳ r → l ⊳ l' → l ⊳ r' → (nd b≤x l r) ⊳ (nd b'≤x' l' r') lemma-≃-⊳ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ≃ r → relax l ⊳ relax r lemma-≃-⊳ ≃lf = ⊳leaf lemma-≃-⊳ (≃nd b≤x b'≤x' _ _ l≃r l'≃r' l≃l') = ⊳both b≤x b'≤x' (lemma-≃-⊳ l≃r) (lemma-≃-⊳ l≃l') (lemma-≃-⊳ (trans≃ l≃l' l'≃r')) lemma-⋗-⊳ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋗ r → relax l ⊳ relax r lemma-⋗-⊳ (⋗lf b≤x) = ⊳left b≤x ⊳leaf ⊳leaf lemma-⋗-⊳ (⋗nd b≤x b'≤x' _ _ l≃r l'≃r' l⋗l') = ⊳both b≤x b'≤x' (lemma-≃-⊳ l≃r) (lemma-⋗-⊳ l⋗l') (lemma-⋗-⊳ (lemma⋗≃ l⋗l' l'≃r')) lemma-⋙-⊳ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋙ r → relax l ⊳ relax r lemma-⋙-⊳ (⋙lf b≤x) = ⊳left b≤x ⊳leaf ⊳leaf lemma-⋙-⊳ (⋙rl b≤x b'≤x' _ l≃r l'⋘r' l⋗r') = ⊳both b≤x b'≤x' (lemma-≃-⊳ l≃r) (lemma-⋙-⊳ (lemma-⋘-⋗ l'⋘r' l⋗r')) (lemma-⋗-⊳ l⋗r') lemma-⋙-⊳ (⋙rr b≤x b'≤x' _ l≃r l'⋙r' l≃l') = ⊳both b≤x b'≤x' (lemma-≃-⊳ l≃r) (lemma-≃-⊳ l≃l') (lemma-⋙-⊳ (lemma-≃-⋙ l≃l' l'⋙r')) lemma-⋘-⊳ : {b b' : Bound}{l : BBHeap b}{r : BBHeap b'} → l ⋘ r → relax l ⊳ relax r lemma-⋘-⊳ lf⋘ = ⊳leaf lemma-⋘-⊳ (ll⋘ b≤x b'≤x' l⋘r _ l'≃r' r≃l') = ⊳both b≤x b'≤x' (lemma-⋘-⊳ l⋘r) (lemma-⋘-⊳ (lemma-⋘-≃ l⋘r r≃l')) (lemma-⋘-⊳ (lemma-⋘-≃ l⋘r (trans≃ r≃l' l'≃r'))) lemma-⋘-⊳ (lr⋘ b≤x b'≤x' l⋙r _ l'≃r' l⋗l') = ⊳both b≤x b'≤x' (lemma-⋙-⊳ l⋙r) (lemma-⋗-⊳ l⋗l') (lemma-⋗-⊳ (lemma⋗≃ l⋗l' l'≃r')) lemma-⊳-heightₙ : {b b' : Bound}{l : BHeap b}{r : BHeap b'} → l ⊳ r → heightₙ r ≤ₙ heightₙ l lemma-⊳-heightₙ ⊳leaf = z≤n lemma-⊳-heightₙ (⊳left {l = l} {r = r} b≤x l⊳r l⊳l') with total (heightₙ l) (heightₙ r) ... | inj₁ hl≤hr rewrite antisym (lemma-⊳-heightₙ l⊳r) hl≤hr = ≤-step (lemma-⊳-heightₙ l⊳l') ... | inj₂ hr≤hl = trans (lemma-⊳-heightₙ l⊳l') (≤-step (reflexive refl)) lemma-⊳-heightₙ (⊳both {l = l} {r = r} {l' = l'} {r' = r'} b≤x b'≤x' l⊳r l⊳l' l⊳r') with total (heightₙ l) (heightₙ r) | total (heightₙ l') (heightₙ r') ... | inj₁ hl≤hr | inj₁ hl'≤hr' rewrite antisym (lemma-⊳-heightₙ l⊳r) hl≤hr = s≤s (lemma-⊳-heightₙ l⊳r') ... | inj₁ hl≤hr | inj₂ hr'≤hl' rewrite antisym (lemma-⊳-heightₙ l⊳r) hl≤hr = s≤s (lemma-⊳-heightₙ l⊳l') ... | inj₂ hr≤hl | inj₁ hl'≤hr' = s≤s (lemma-⊳-heightₙ l⊳r') ... | inj₂ hr≤hl | inj₂ hr'≤hl' = s≤s (lemma-⊳-heightₙ l⊳l') theorem-height-relax : {b : Bound}(h : BBHeap b) → toNat (height h) ≡ heightₙ (relax h) theorem-height-relax leaf = refl theorem-height-relax (left {l = l} {r = r} _ l⋘r) with total (heightₙ (relax l)) (heightₙ (relax r)) ... | inj₁ hl≤hr rewrite antisym (lemma-⊳-heightₙ (lemma-⋘-⊳ l⋘r)) hl≤hr | theorem-height-relax l = refl ... | inj₂ hr≤hl rewrite theorem-height-relax l = refl theorem-height-relax (right {l = l} {r = r} _ l⋙r) with total (heightₙ (relax l)) (heightₙ (relax r)) ... | inj₁ hl≤hr rewrite antisym (lemma-⊳-heightₙ (lemma-⋙-⊳ l⋙r)) hl≤hr | theorem-height-relax l = refl ... | inj₂ hr≤hl rewrite theorem-height-relax l = refl
{ "alphanum_fraction": 0.5309117152, "avg_line_length": 50.6951219512, "ext": "agda", "hexsha": "d47ff79f0e631d062575a1750e6b25b51efc2d5a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BBHeap/Height/Convert.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Height/Convert.agda", "max_line_length": 157, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BBHeap/Height/Convert.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 2195, "size": 4157 }
{-# OPTIONS --type-in-type #-} module FusionNotes where {- Idea: doing computation at compile time instead of at runtime VTy : MTy -- value types (inductive data) CTy : MTy -- computation types (functions) MTy : MTy -- meta types (meta TT types) VTy ≤ CTy (implicit cumulativity) ^_ : VTy → MTy -- lifting ^_ : CTy → MTy <_> : A → ^A -- quote ~_ : ^A → A -- splice Nat : VTy ^Nat (has no elimination rule) Solution: Church-encodings - initial encoding: ^Nat ~ ((N : CTy) → (^N → ^N) → ^N → ^N) βη List : VTy → VTy ^(List A) ~ ((L : CTy) → (^A → ^L → ^L) → ^L → ^L) ~ ((L : CTy) → (A → L → L) → L → L) A : algebraic/inductive signature e.g. (L : Set, cons : A → L → L, nil : L) A-Alg : MTy e.g. (List A)-Alg = (L : CTy) × (cons : A → L → L) × (nil : L) U : A-Alg → CTy (underlying set functor) e.g. U (L, cons, nil) = L - initial: IChurch : Sig → MTy IChurch A = (α : A-Alg) → U α IChurch ListSig = (α : ((L : CTy) × (cons : A → L → L) × (nil : L))) → U α = ((L : CTy) → (A → L → L) → L → L) - terminal: TChurch : CoSig → MTy TChurch A = (α : A-Alg) × U α -- data List a = Nil | Cons a (List a) ListSig = (L : Set, cons : A → L → L, nil : L) -- codata List a = Nil | Cons a (List a) CoListSig = (L : Set, destruct : L → Maybe (A, L)) -- (more elegant: F-algebras, F-coalgebras) CMaybe : MTy → MTy CMaybe A = (M : MTy) → (A → M) → M → M -- Church Maybe CoList : VTy → MTy CoList A = (CL : VTy) × (next: CL → Maybe (A × CL)) × CL = (CL : VTy) × (next: CL → CMaybe (A × CL)) × CL -- high-level: we want to optimize modulo positive η-rules -- Bool : nf modulo η: exponential time -- Boolᴺ → Bool -- Compiler knows about *some* η-rules -- e.g. GHC case-commutation runtime meta runtime -- positive types --> IChurch rep --> residualize (CPS transformations) --> TChurch rep --> residualize (state machine transformation) -- Initial Church encoding: + It works on all inductive types + It's relatively easy to efficiently compile - Only folding functions (zip doesn't work for lists) "push" iterator, "internal" iterator -- Terminal encoding: + More general for streams/dataflow stuff (zip works fine) - In many cases doesn't make practical sense - For finite types it's just the same as initial encoding, but more complicated to use - Compiling state machines is pretty complicated (State : VTy) × (step : State → .....) × (seed : State) step : (A + B + C + D + E) → (A + B + C + D + E + ⊤) --> turn it to tail-recursive loop --> we have to turn lots of _+_ case splits into a *mutual* set of functions mutual f : A → B g : A → C fg : A + A → B + C fg (inj₁ a) = ... call either f or g recursively fg (inj₂ a) = ... call either f or g recursively -- job: do this transformation in reverse (not easy) "pull" stream, "external" iterator -- Example: Rust iterator: - terminal encoding - *not* abstract (does not use sigma types) (internal state leaks to the outside) -- map : (A → B) → Stream S A → Stream S B -- easy to extend with typeclass magic What I want: - constraints: only simple type theory at runtime, no closures -} -------------------------------------------------------------------------------- -- Comp/Val/Meta, 2LVLTT setting -- fold fusion, stream fusion comparison -- (external/internal, push/pull, initial/terminal, abstract/transparent) -- closure-freedom -- monadic bind -- sigma-freedom -- call-pattern spec -- stream : skip-stream or CoList? -- hybrid: affine stream + push lists + asymmetric zip -- Robinson & Lippmeier : Machine Fusion (with split optimization!) -- -- What are fusing functions? -- - Finite positive types can be mechanically CPS'd into fusing defs -- (but it is a lot weaker than full positive η!) -- - Inifite types can't -- - Auto-fusion for infinite types = supercompilation -------------------------------------------------------------------------------- open import Data.List using (_∷_; []) import Data.List as L open import Data.Nat open import Data.Product renaming (proj₁ to ₁; proj₂ to ₂) hiding (map; zip) open import Function import Data.Bool as B -------------------------------------------------------------------------------- infix 3 _==_ _==_ : ℕ → ℕ → B.Bool zero == zero = B.true zero == suc y = B.false suc x == zero = B.false suc x == suc y = x == y caseℕ : ∀ {A : Set} → ℕ → A → (ℕ → A) → A caseℕ zero z s = z caseℕ (suc n) z s = s n -- map (_+_ 3) ∘ countDown -- λ x L c n → -- fix -- (λ go n₁ → -- caseℕ n₁ (c 3 n) (λ n₂ → c (suc (suc (suc (suc n₂)))) (go n₂))) -- x module InitialList where -- Initial Church lists -------------------------------------------------------------------------------- List : Set → Set List A = (L : Set) → (A → L → L) → L → L nil : ∀ {A} → List A nil L c n = n cons : ∀ {A} → A → List A → List A cons a as L c n = c a (as L c n) -- map : ∀ {A B} → (A → B) → List A → List B -- map f [] = [] -- map f (a:as) = f a : map f as map : ∀ {A B} → (A → B) → List A → List B map f as L c n = as L (λ a bs → c (f a) bs) n -- foldr (λ a bs → c (f a) bs) n as -- {-# NON_TERMINATING #-} -- fix : ∀ {A B : Set} → ((A → B) → A → B) → A → B -- fix f a = f (fix f) a postulate fix : ∀ {A B : Set} → ((A → B) → A → B) → A → B -- countDown 5 = [5, 4, 3, 2, 1, 0] -- "push" iteration: start with a loop, inline stuff later inside countDown : ℕ → List ℕ countDown n = λ L cons nil → fix (λ go n → caseℕ n (cons zero nil) (λ n → cons (suc n) (go n))) n take : ∀ {A} → ℕ → List A → List A take n as L cons nil = as _ (λ a k n → caseℕ n nil (λ n → cons a (k n))) (λ _ → nil) n reverse : ∀ {A} → List A → List A reverse as L c n = as _ (λ a k acc → k (c a acc)) (λ acc → acc) n -- optimized by "call pattern specialization" in GHC drop : ∀ {A} → ℕ → List A → List A drop n as L cons nil = as _ (λ a k n → caseℕ n (cons a (k 0)) -- drop 0 recursive calls drop 0 until the list ends (λ n → k n)) -- recursive call drop (n - 1) (λ _ → nil) n filter : ∀ {A} → (A → B.Bool) → List A → List A filter f as L cons nil = as _ (λ a as → B.if f a then cons a as else as) nil foldl : ∀ {A B} → (B → A → B) → B → List A → B foldl f b as = as _ (λ a k b → k (f b a)) (λ b → b) b sum : List ℕ → ℕ sum = foldl _+_ 0 downList : ∀ {A} → List A → L.List A -- CPS to usual list downList as = as _ L._∷_ L.[] upList : ∀ {A} → L.List A → List A -- usual list to CPS upList as L cons nil = L.foldr cons nil as -- List is a monad bind : ∀ {A B} → List A → (A → List B) → List B bind as f L cons nil = as _ (λ a bs → f a L cons bs) nil pure : ∀ {A} → A → List A pure a L cons nil = cons a nil module GenericListFun where -- (α : A-Alg) → U A -- CPS A := (α : A-Alg) → U A -- goal: define functions in (CPS A → CPS B) -- ((α : A-Alg) → U α) → ((β : B-Alg) → U β) -- input: (f : A-Alg → B-Alg) × (∀ α. U (f α) = U α) -- output: ((β : B-Alg) → U β) → ((α : A-Alg) → U α) -- F-alg: (A : Set) × (F A → A) -- fusingFoldr : (∀ A. (F A → A) → G A → A) → (∀ A. (F A → A) → A) → (∀ A. (G A → A) → A) -- fusibleFoldr : ∀ {A B} → (∀ {L} → (B → L → L) → L → (A → L → L) × L) → List A → List B fusibleFoldr f as L cons nil = as L (f cons nil .₁) (f cons nil .₂) map' : ∀ {A B} → (A → B) → List A → List B map' f = fusibleFoldr λ cons nil → (λ a bs → cons (f a) bs) , nil filter' : ∀ {A} → (A → B.Bool) → List A → List A filter' f = fusibleFoldr (λ c n → (λ a l → B.if f a then c a l else l) , n) -- what about returning in comp types? -- List A → B → List C -- (∀ L. (A → L → L) → L → L) → B → (∀ L. (C → L → L) → L → L) -- (∀ L. (A → L → L) → L → L) → (∀ L. B → (C → L → L) → L → L) -- ( -- A → ((α : ListAlg) → U α) -- (∀ X. G X → F (A → X)) → CPS F → CPS G -- A → (∀ X. (F X → X) → X) -- ∀ X. A → (F X → X) → X -- fuse : (∀ X. (G X → X) → F X → X) → Fix F → Fix G -- fuse : (∀ X. (G X → X) → F (A → X) → (A → X)) → Fix F → A → Fix G -- -- fusing with +1 arg -- fusibleFoldr1 : ∀ {A B C : Set} -- → (∀ {L} → (C → L → L) → L → (A → (B → L) → (B → L)) × (B → L)) -- → List A → B → List C -- fusibleFoldr1 {A} {B} {C} f as b L cons nil = -- as (B → L) (f cons nil .₁) (f cons nil .₂) b -- take' : ∀ {A} → ℕ → List A → List A -- take' n as = fusibleFoldr1 (λ cons nil → (λ a k n → caseℕ n nil λ n → cons a (k n)) , λ _ → nil) as n -- fusibleFoldr11 : ∀ {A B C : Set} -- → (∀ {L} → (C → L → L) → L → (A → (B → L) → (B → L)) × (B → L)) -- → List A → B → List C -- fusibleFoldr11 {A} {B} {C} f as b L cons nil = -- as (B → L) (f cons nil .₁) (f cons nil .₂) b -- fusibleFoldr1 (λ n cons nil → (λ a l → caseℕ n nil λ n → {!cons!}) , nil) as n -- TODO: - look at fusibleUnfold -- - what if we have multiple indexed/mutual so5rts -- Streams -------------------------------------------------------------------------------- -- TODO here -- data Step a s = Stop | Yield a s Step : Set → Set → Set Step A S = (Step : Set)(stop : Step)(yield : A → S → Step) → Step record Stream (A : Set) : Set where constructor stream field State : Set next : State → Step A State seed : State open Stream public map : ∀ {A B} → (A → B) → Stream A → Stream B State (map f as) = State as next (map f as) s M stop yield = next as s _ stop λ a s → yield (f a) s seed (map f as) = seed as open import Data.Sum append : ∀ {A} → Stream A → Stream A → Stream A State (append as as') = State as ⊎ State as' -- does not compute on meta level (state *must* be runtime represented) -- 1. Let the compiler optimize by call pattern spec -- 2. Do a deeply embedded rep of state machines, write an optimizer/compiler for it on meta level -- (Robinson & Lippmeier : Machine Fusion (with split optimization!)) next (append as as') (inj₁ s ) Step stop yield = next as s _ (next as' (seed as') _ stop λ a s' → yield a (inj₂ s')) λ a s → yield a (inj₁ s) next (append as as') (inj₂ s') Step stop yield = next as' s' _ stop λ a s' → yield a (inj₂ s') seed (append as as') = inj₁ (seed as) zip : ∀ {A B} → Stream A → Stream B → Stream (A × B) State (zip as bs) = State as × State bs next (zip as bs) = {!!} -- try to make two steps seed (zip as bs) = seed as , seed bs filter : ∀ {A} → (A → B.Bool) → Stream A → Stream A State (filter f as) = State as next (filter f as) s Step stop yield = next as s _ stop λ a s → B.if f a then yield a s else {!skip s!} -- scanning forward is *tail recursive* -- where find = tailrec forward (fine, because fusible w/o loss of efficiency) -- in general, skipping over stream elements can be done in a loop -- scan forward until the next output yield (recursively) -- Rust iterators: exactly this solution -- using recursion inside stepping functions seed (filter f as) = seed as -- -- Haskell stream fusion: use Skip streams -- data Step s a = Stop | Yield a s | Skip s -- codata SkipStream a = Stop | Yield a (SkipStream a) | Skip (SkipStream a) -- Stream (Maybe a) ~ SkipStream a -- Skip is unnecessary if we have enough fusion guarantees (staging) -- binding streams? -------------------------------------------------------------------------------- -- not available in GHC -- Another paper: "Staged Stream Fusion to Completeness" -- bind can be implemented without closures if you have sigma types open import Data.Maybe bind : ∀ {A B} → Stream A → (A → Stream B) → Stream B State (bind as f) = State as × Maybe (∃ (State ∘ f)) -- (s, nothing) : computing next outer index -- (s, just s') : computing next inner index next (bind as f) = {!!} seed (bind as f) = seed as , nothing -- we don't have Σ at runtime in my lang.... -- Proposal for stream fusion -------------------------------------------------------------------------------- -- Inductive encoding for lists + coinductive encoding for "affine" streams -- streams: unfold, iterate over data structures, ranges, enumeration, filter, take, drop, zip -- inductive: full feature set -- assymmetric zip: ChurchList A → Stream B → ChurchList (A × B) -- Stream B → ChurchList A → ChurchList (A × B) -- pull : Stream A → ChurchList A -- do x ← pull $ range 0 100 -- y ← pull $ zip (enumFrom 0) (toStream xs) -- return $ x + y -- no closures, no compiler magic required -- example for Lippmeier magic: -- xs : Stream Int -- zip (map (+10) xs) xs -- nonlinear xs usage (machine is duplicated) -- map (λ x → (x + 10, x)) xs -- automatic fusion? -- map : ∀ {A B} → (A → B) → List A → List B -- map f [] = [] -- map f (a:as) = f a : map f as -- length (map f as) -- case map f as of [] -> _; _ -> ... {- map : ∀ {A B} → (A → B) → List A → List B map f as L c n = as L (λ a bs → c (f a) bs) n -} -- syntactic translation from runtime TT to 2LTT -- whenever A : VTy -- Aᴹ : (A-Alg : MTy) × (U : A-Alg → CTy) -- t : Tm Γ (A : VTy) -- tᴹ : Tm Γᴹ ((α : A-Alg) → U α) -- trueᴹ := church true -- falseᴹ := ... -- ifᴹ := .. -- interesting: usual CPS translation: *everything* incl function is CPS'd -- wrap everything in Chruch Id functor -- CId A = (Id : Set) → (A → Id) → Id -- only for finite types -- try to do it anyway: supercompilation -- restrict "foldr" to only the definitions which are fusable? -- we can't eliminate recursive results of folding -- How to define fusibleFoldr?
{ "alphanum_fraction": 0.5007915204, "avg_line_length": 30.3953974895, "ext": "agda", "hexsha": "c808a69f19d8f30dd9b2c81c9c97cdff547bca94", "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": "8876a92136e5d37f67e7a8cf52c88253ddf77d9f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AndrasKovacs/staged", "max_forks_repo_path": "notes/FusionNotes.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "8876a92136e5d37f67e7a8cf52c88253ddf77d9f", "max_issues_repo_issues_event_max_datetime": "2022-02-05T10:17:38.000Z", "max_issues_repo_issues_event_min_datetime": "2021-07-16T04:06:01.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AndrasKovacs/staged", "max_issues_repo_path": "notes/FusionNotes.agda", "max_line_length": 127, "max_stars_count": 78, "max_stars_repo_head_hexsha": "8876a92136e5d37f67e7a8cf52c88253ddf77d9f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AndrasKovacs/staged", "max_stars_repo_path": "notes/FusionNotes.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-29T20:12:54.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-22T12:51:02.000Z", "num_tokens": 4729, "size": 14529 }
module Sets.IterativeSet where import Lvl open import Logic open import Type module _ where private variable {ℓ ℓ₁ ℓ₂} : Lvl.Level -- A model of constructive set theory (CZF) by using W-types (iterative sets). -- The interpretation of Iset being a type of sets comes from the idea that the image of `elem` is a set of elements. record Iset : Type{Lvl.𝐒(ℓ)} where constructor set inductive pattern field {Index} : Type{ℓ} elem : Index → Iset{ℓ} open Iset Iset-index-induction : ∀{P : Iset{ℓ₁} → Stmt{ℓ₂}} → (∀{A : Iset{ℓ₁}} → (∀{i : Index(A)} → P(elem(A)(i))) → P(A)) → (∀{A : Iset{ℓ₁}} → P(A)) Iset-index-induction {P = P} proof {set elem} = proof{_} \{i} → Iset-index-induction{P = P} proof {elem(i)}
{ "alphanum_fraction": 0.630810093, "avg_line_length": 32.7391304348, "ext": "agda", "hexsha": "dc9924299a6d2c4aab8aa21fae49aa8d8977250f", "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": "Sets/IterativeSet.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": "Sets/IterativeSet.agda", "max_line_length": 141, "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": "Sets/IterativeSet.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 266, "size": 753 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Object.IndexedProduct {o ℓ e} (C : Category o ℓ e) where -- An indexed product is similar to a limit, but the diagram is from a Set -- (irrelevant Setoid here) rather than a category, so there are no subobjects -- involved. open Category C open Equiv open import Level open import Relation.Binary as Bi using () open import Categories.Support.Equivalence import Categories.Object.Indexed as IObj import Categories.Morphism.Indexed as IArrow -- Borrowed from Dan Doel's definition of products record IndexedProduct {c q} (B : Setoid c q) (As : IObj.Dust C B) : Set (o ⊔ ℓ ⊔ e ⊔ c ⊔ q) where module B = Setoid B open B using (_≈_) open Heterogeneous C open IObj C B open IArrow C B Cone : Obj → _ Cone apex = apex ⇒∗ As cone-setoid : Obj → Setoid _ _ cone-setoid apex = fan-setoid apex As _≜_ : ∀ {apex} → Bi.Rel (Cone apex) _ _≜_ {apex} = Setoid._≈_ (cone-setoid apex) field ∏ : Obj π : Cone ∏ -- convenience! π[_] : (x : B.Carrier) → (∏ ⇒ (As ! x)) π[_] x = π ‼ x -- ↑ XXX for some reason it won't parse as π[ x ] .π-cong : ∀ {x y} → x ≈ y → (π[ x ] ∼ π[ y ]) π-cong x≈y = cong₁ π x≈y π▹_ : ∀ {X} (f : X ⇒ ∏) → Cone X π▹_ f = _▹_ {Zs = As} π f field uncurry : ∀ {V} → Cone V → V ⇒ ∏ -- XXX fs should be implicit but call sites can't infer it -- because of eta-driven irrelevant-field dropping .commute∗ : ∀ {V} (fs : Cone V) → (π▹ uncurry fs) ≜ fs .universal : ∀ {V} (fs : Cone V) {i : V ⇒ ∏} → (∀ {x} → π[ x ] ∘ i ≡ fs ‼ x) → uncurry fs ≡ i -- convenience? .commute : ∀ {V} (fs : Cone V) {x} → (π[ x ] ∘ uncurry fs) ≡ fs ‼ x commute fs {x} = ∼⇒≡ (commute∗ fs B.refl) .universal∗ : ∀ {V} (fs : Cone V) {i : V ⇒ ∏} → ((π▹ i) ≜ fs) → uncurry fs ≡ i universal∗ fs pf = universal fs (∼⇒≡ (pf B.refl)) .g-η : ∀ {C} {f : C ⇒ ∏} → (uncurry (π▹ f) ≡ f) g-η {f = f} = universal (π▹ f) Equiv.refl .η : uncurry π ≡ Category.id C η = universal π identityʳ .uncurry-cong : ∀ {V} {fs gs : Cone V} → (∀ {x} → fs ‼ x ≡ gs ‼ x) → uncurry fs ≡ uncurry gs uncurry-cong {fs = fs} {gs} eq = universal fs (Equiv.trans (commute gs) (Equiv.sym eq)) .uncurry-cong∗ : ∀ {V} {fs gs : Cone V} → fs ≜ gs → uncurry fs ≡ uncurry gs uncurry-cong∗ {V} {fs} {gs} eq = universal∗ fs (≜-trans {π▹ uncurry gs} {gs} {fs} (commute∗ gs) (≜-sym {fs} {gs} eq)) where open Setoid (cone-setoid V) using () renaming (trans to ≜-trans; sym to ≜-sym) .uncurry∘ : ∀ {V W} (fs : Cone V) {q : W ⇒ V} → (uncurry fs) ∘ q ≡ uncurry (_▹_ {Zs = As} fs q) uncurry∘ fs {q} = Equiv.sym (universal (_▹_ {Zs = As} fs q) (Equiv.trans (Equiv.sym assoc) (∘-resp-≡ˡ (commute fs)))) {- open import Categories.Morphisms Commutative : ∀ {A B} → (p₁ : Product A B) (p₂ : Product B A) → _≅_ C (Product.A×B p₁) (Product.A×B p₂) Commutative p₁ p₂ = record { f = ⟨ π₂ , π₁ ⟩′ ; g = ⟨ π′₂ , π′₁ ⟩ ; iso = record { isoˡ = isoˡ ; isoʳ = isoʳ } } where module p₁ = Product p₁ module p₂ = Product p₂ open Product p₁ open Product p₂ renaming (A×B to B×A; π₁ to π′₁; π₂ to π′₂; ⟨_,_⟩ to ⟨_,_⟩′) idˡ : A×B ⇒ A×B idˡ = ⟨ π′₂ , π′₁ ⟩ ∘ ⟨ π₂ , π₁ ⟩′ idʳ : B×A ⇒ B×A idʳ = ⟨ π₂ , π₁ ⟩′ ∘ ⟨ π′₂ , π′₁ ⟩ .idˡ-commutes₁ : π₁ ∘ idˡ ≡ π₁ idˡ-commutes₁ = begin π₁ ∘ idˡ ↑⟨ assoc ⟩ (π₁ ∘ ⟨ π′₂ , π′₁ ⟩) ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ ∘-resp-≡ˡ p₁.commute₁ ⟩ π′₂ ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ p₂.commute₂ ⟩ π₁ ∎ where open HomReasoning .idˡ-commutes₂ : π₂ ∘ idˡ ≡ π₂ idˡ-commutes₂ = begin π₂ ∘ idˡ ↑⟨ assoc ⟩ (π₂ ∘ ⟨ π′₂ , π′₁ ⟩) ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ ∘-resp-≡ˡ p₁.commute₂ ⟩ π′₁ ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ p₂.commute₁ ⟩ π₂ ∎ where open HomReasoning .isoˡ : idˡ ≡ id isoˡ = begin idˡ ↑⟨ p₁.universal idˡ-commutes₁ idˡ-commutes₂ ⟩ ⟨ π₁ , π₂ ⟩ ↓⟨ p₁.η ⟩ id ∎ where open HomReasoning .idʳ-commutes₁ : π′₁ ∘ idʳ ≡ π′₁ idʳ-commutes₁ = begin π′₁ ∘ idʳ ↑⟨ assoc ⟩ (π′₁ ∘ ⟨ π₂ , π₁ ⟩′) ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ ∘-resp-≡ˡ p₂.commute₁ ⟩ π₂ ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ p₁.commute₂ ⟩ π′₁ ∎ where open HomReasoning .idʳ-commutes₂ : π′₂ ∘ idʳ ≡ π′₂ idʳ-commutes₂ = begin π′₂ ∘ idʳ ↑⟨ assoc ⟩ (π′₂ ∘ ⟨ π₂ , π₁ ⟩′) ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ ∘-resp-≡ˡ p₂.commute₂ ⟩ π₁ ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ p₁.commute₁ ⟩ π′₂ ∎ where open HomReasoning .isoʳ : idʳ ≡ id isoʳ = begin idʳ ↑⟨ p₂.universal idʳ-commutes₁ idʳ-commutes₂ ⟩ ⟨ π′₁ , π′₂ ⟩′ ↓⟨ p₂.η ⟩ id ∎ where open HomReasoning Associative : ∀ {X Y Z} (p₁ : Product X Y) (p₂ : Product Y Z) (p₃ : Product X (Product.A×B p₂)) (p₄ : Product (Product.A×B p₁) Z) → _≅_ C (Product.A×B p₃) (Product.A×B p₄) Associative p₁ p₂ p₃ p₄ = record { f = f ; g = g ; iso = record { isoˡ = isoˡ ; isoʳ = isoʳ } } where module p₁ = Product p₁ module p₂ = Product p₂ module p₃ = Product p₃ module p₄ = Product p₄ open Product p₁ hiding (π₁; π₂) renaming (⟨_,_⟩ to ⟨_,_⟩p₁) open Product p₂ hiding (π₁; π₂) renaming (A×B to B×C; ⟨_,_⟩ to ⟨_,_⟩p₂) open Product p₃ renaming (A×B to A×[B×C]) open Product p₄ renaming (A×B to [A×B]×C; π₁ to π′₁; π₂ to π′₂; ⟨_,_⟩ to ⟨_,_⟩′) f : A×[B×C] ⇒ [A×B]×C f = ⟨ ⟨ π₁ , p₂.π₁ ∘ π₂ ⟩p₁ , p₂.π₂ ∘ π₂ ⟩′ g : [A×B]×C ⇒ A×[B×C] g = ⟨ p₁.π₁ ∘ π′₁ , ⟨ p₁.π₂ ∘ π′₁ , π′₂ ⟩p₂ ⟩ idˡ : A×[B×C] ⇒ A×[B×C] idˡ = g ∘ f idʳ : [A×B]×C ⇒ [A×B]×C idʳ = f ∘ g .cmˡ₁ : π₁ ∘ idˡ ≡ π₁ cmˡ₁ = begin π₁ ∘ idˡ ↑⟨ assoc ⟩ (π₁ ∘ g) ∘ f ↓⟨ ∘-resp-≡ˡ p₃.commute₁ ⟩ (p₁.π₁ ∘ π′₁) ∘ f ↓⟨ assoc ⟩ p₁.π₁ ∘ (π′₁ ∘ f) ↓⟨ ∘-resp-≡ʳ p₄.commute₁ ⟩ p₁.π₁ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ↓⟨ p₁.commute₁ ⟩ p₃.π₁ ∎ where open HomReasoning .cmˡ₂₁ : p₂.π₁ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ≡ p₂.π₁ ∘ p₃.π₂ cmˡ₂₁ = begin p₂.π₁ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ↑⟨ assoc ⟩ (p₂.π₁ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂) ∘ f ↓⟨ ∘-resp-≡ˡ p₂.commute₁ ⟩ (p₁.π₂ ∘ p₄.π₁) ∘ f ↓⟨ assoc ⟩ p₁.π₂ ∘ (p₄.π₁ ∘ f) ↓⟨ ∘-resp-≡ʳ p₄.commute₁ ⟩ p₁.π₂ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ↓⟨ p₁.commute₂ ⟩ p₂.π₁ ∘ p₃.π₂ ∎ where open HomReasoning .cmˡ₂₂ : p₂.π₂ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ≡ p₂.π₂ ∘ p₃.π₂ cmˡ₂₂ = begin p₂.π₂ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ↑⟨ assoc ⟩ (p₂.π₂ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂) ∘ f ↓⟨ ∘-resp-≡ˡ p₂.commute₂ ⟩ p₄.π₂ ∘ f ↓⟨ p₄.commute₂ ⟩ p₂.π₂ ∘ p₃.π₂ ∎ where open HomReasoning .cmˡ₂ : π₂ ∘ idˡ ≡ π₂ cmˡ₂ = begin π₂ ∘ idˡ ↑⟨ assoc ⟩ (π₂ ∘ g) ∘ f ↓⟨ ∘-resp-≡ˡ p₃.commute₂ ⟩ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f ↑⟨ p₂.universal cmˡ₂₁ cmˡ₂₂ ⟩ ⟨ p₂.π₁ ∘ p₃.π₂ , p₂.π₂ ∘ p₃.π₂ ⟩p₂ ↓⟨ p₂.g-η ⟩ p₃.π₂ ∎ where open HomReasoning .isoˡ : idˡ ≡ id isoˡ = begin idˡ ↑⟨ p₃.universal cmˡ₁ cmˡ₂ ⟩ ⟨ π₁ , π₂ ⟩ ↓⟨ p₃.η ⟩ id ∎ where open HomReasoning .cmʳ₁₁ : p₁.π₁ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ≡ p₁.π₁ ∘ p₄.π₁ cmʳ₁₁ = begin p₁.π₁ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ↑⟨ assoc ⟩ (p₁.π₁ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁) ∘ g ↓⟨ ∘-resp-≡ˡ p₁.commute₁ ⟩ p₃.π₁ ∘ g ↓⟨ p₃.commute₁ ⟩ p₁.π₁ ∘ p₄.π₁ ∎ where open HomReasoning .cmʳ₁₂ : p₁.π₂ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ≡ p₁.π₂ ∘ p₄.π₁ cmʳ₁₂ = begin p₁.π₂ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ↑⟨ assoc ⟩ (p₁.π₂ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁) ∘ g ↓⟨ ∘-resp-≡ˡ p₁.commute₂ ⟩ (p₂.π₁ ∘ p₃.π₂) ∘ g ↓⟨ assoc ⟩ p₂.π₁ ∘ (p₃.π₂ ∘ g) ↓⟨ ∘-resp-≡ʳ p₃.commute₂ ⟩ p₂.π₁ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ↓⟨ p₂.commute₁ ⟩ p₁.π₂ ∘ p₄.π₁ ∎ where open HomReasoning .cmʳ₁ : π′₁ ∘ idʳ ≡ π′₁ cmʳ₁ = begin π′₁ ∘ idʳ ↑⟨ assoc ⟩ (π′₁ ∘ f) ∘ g ↓⟨ ∘-resp-≡ˡ p₄.commute₁ ⟩ ⟨ π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g ↑⟨ p₁.universal cmʳ₁₁ cmʳ₁₂ ⟩ ⟨ p₁.π₁ ∘ p₄.π₁ , p₁.π₂ ∘ p₄.π₁ ⟩p₁ ↓⟨ p₁.g-η ⟩ π′₁ ∎ where open HomReasoning .cmʳ₂ : π′₂ ∘ idʳ ≡ π′₂ cmʳ₂ = begin π′₂ ∘ idʳ ↑⟨ assoc ⟩ (π′₂ ∘ f) ∘ g ↓⟨ ∘-resp-≡ˡ p₄.commute₂ ⟩ (p₂.π₂ ∘ p₃.π₂) ∘ g ↓⟨ assoc ⟩ p₂.π₂ ∘ (p₃.π₂ ∘ g) ↓⟨ ∘-resp-≡ʳ p₃.commute₂ ⟩ p₂.π₂ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ↓⟨ p₂.commute₂ ⟩ p₄.π₂ ∎ where open HomReasoning .isoʳ : idʳ ≡ id isoʳ = begin idʳ ↑⟨ p₄.universal cmʳ₁ cmʳ₂ ⟩ ⟨ π′₁ , π′₂ ⟩′ ↓⟨ p₄.η ⟩ id ∎ where open HomReasoning -}
{ "alphanum_fraction": 0.4393660532, "avg_line_length": 26.8681318681, "ext": "agda", "hexsha": "55ffb47766cef31dac5a058f55d4bb6d11ddad1c", "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/Object/IndexedProduct.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/Object/IndexedProduct.agda", "max_line_length": 171, "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/Object/IndexedProduct.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": 4718, "size": 9780 }
{-# OPTIONS --allow-unsolved-metas #-} module LiteralSequent where open import Sequent open import IsLiteralSequent record LiteralSequent : Set where constructor ⟨_⟩ field {sequent} : Sequent isLiteralSequent : IsLiteralSequent sequent open LiteralSequent public open import OscarPrelude private module _ where pattern ⟪_,_⟫ h s = ⟨_⟩ {h} s pattern ⟪_⟫ h = (⟨_⟩ {h} _) instance EqLiteralSequent : Eq LiteralSequent Eq._==_ EqLiteralSequent ⟪ Φ₁ ⟫ ⟪ Φ₂ ⟫ with Φ₁ ≟ Φ₂ Eq._==_ EqLiteralSequent ⟨ !Φ₁ ⟩ ⟨ !Φ₂ ⟩ | yes refl with !Φ₁ ≟ !Φ₂ Eq._==_ EqLiteralSequent _ _ | yes refl | yes refl = yes refl Eq._==_ EqLiteralSequent ⟨ Φ₁ ⟩ ⟨ Φ₂ ⟩ | yes refl | no !Φ₁≢!Φ₂ = no λ {refl → !Φ₁≢!Φ₂ refl} Eq._==_ EqLiteralSequent ⟨ Φ₁ ⟩ ⟨ Φ₂ ⟩ | no Φ₁≢Φ₂ = no λ {refl → Φ₁≢Φ₂ refl} module _ where open import HasNegation open import IsLiteralFormula instance HasNegationLiteralSequent : HasNegation LiteralSequent HasNegation.~ HasNegationLiteralSequent ⟨ atomic 𝑃 τs ╱ φˢs ⟩ = ⟨ logical 𝑃 τs ╱ φˢs ⟩ HasNegation.~ HasNegationLiteralSequent ⟨ logical 𝑃 τs ╱ φˢs ⟩ = ⟨ atomic 𝑃 τs ╱ φˢs ⟩ open import 𝓐ssertion instance 𝓐ssertionLiteralSequent : 𝓐ssertion LiteralSequent 𝓐ssertionLiteralSequent = record {} open import HasSatisfaction instance HasSatisfactionLiteralSequent : HasSatisfaction LiteralSequent HasSatisfaction._⊨_ HasSatisfactionLiteralSequent I Φ = I ⊨ sequent Φ open import HasDecidableValidation instance HasDecidableValidationLiteralSequent : HasDecidableValidation LiteralSequent HasDecidableValidationLiteralSequent = {!!}
{ "alphanum_fraction": 0.7353865493, "avg_line_length": 29.462962963, "ext": "agda", "hexsha": "dfa9cfd2366dd48ecbe94752c07d238aeae6e8c8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/LiteralSequent.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/LiteralSequent.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/LiteralSequent.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 574, "size": 1591 }
{-# OPTIONS --without-K #-} module hott.truncation where open import hott.truncation.core public open import hott.truncation.const public open import hott.truncation.equality public open import hott.truncation.elim public
{ "alphanum_fraction": 0.8080357143, "avg_line_length": 24.8888888889, "ext": "agda", "hexsha": "615c4b34639ede51aeb34f00e4c66ed70a8a91d9", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/hott/truncation.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/hott/truncation.agda", "max_line_length": 43, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/hott/truncation.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 51, "size": 224 }
module Type.Size.Proofs where import Lvl open import Data open import Data.Proofs open import Functional open import Function.Equals open import Function.Inverseᵣ open import Function.Inverse open import Function.Proofs open import Logic open import Logic.IntroInstances open import Logic.Propositional open import Logic.Predicate open import Structure.Setoid open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Domain.Proofs open import Structure.Relator.Equivalence open import Structure.Relator.Ordering open import Structure.Relator.Properties open import Type import Type.Size private variable ℓ ℓ₁ ℓ₂ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ : Lvl.Level private variable T A B C : Type{ℓ} module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where open Type.Size [≼]-maximum : (_≼_ T (T → T) ⦃ [⊜]-equiv ⦄) [≼]-maximum = [∃]-intro(const) ⦃ intro(proof) ⦄ where proof : ∀{x y} → (const(x) ⊜ const(y)) → (x ≡ y) proof{x}{y} (intro fneq) = fneq{x} [≍]-reflexivity-raw : (T ≍ T) [≍]-reflexivity-raw = [∃]-intro(id) ⦃ id-bijective ⦄ [≼]-reflexivity-raw : (T ≼ T) [≼]-reflexivity-raw = [∃]-intro(id) ⦃ id-injective ⦄ [≽]-reflexivity-raw : (T ≽ T) [≽]-reflexivity-raw = [∃]-intro(id) ⦃ id-surjective ⦄ [≼]-minimum-raw : ⦃ equiv-empty : Equiv{ℓₑ₁}(Empty{ℓ}) ⦄ → (_≼_ Empty ⦃ equiv-empty ⦄ T) [≼]-minimum-raw = [∃]-intro(empty) ⦃ empty-injective ⦄ -- TODO: Impossible because there are no functions of type (T → ⊥)? -- instance -- [≽]-minimum : Weak.Properties.Maximum(_≽_ {ℓ})(Empty) -- Weak.Properties.Maximum.proof([≽]-minimum) {T} {} module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where open Type.Size [≍]-to-[≼] : (A ≍ B) → (A ≼ B) [≍]-to-[≼] ([∃]-intro(f) ⦃ f-bijective ⦄) = ([∃]-intro(f) ⦃ bijective-to-injective(f) ⦃ f-bijective ⦄ ⦄) [≍]-to-[≽] : (A ≍ B) → (A ≽ B) [≍]-to-[≽] ([∃]-intro(f) ⦃ f-bijective ⦄) = ([∃]-intro(f) ⦃ bijective-to-surjective(f) ⦃ f-bijective ⦄ ⦄) [≽]-to-[≼] : (ab@([∃]-intro f) : (A ≽ B)) → ⦃ func : Function(f) ⦄ ⦃ inv-func : Function(invᵣ-surjective f) ⦄ → (B ≼ A) [≽]-to-[≼] ([∃]-intro(f) ⦃ f-surjective ⦄) ⦃ inv-func ⦄ = [∃]-intro(invᵣ f ⦃ surjective-to-invertibleᵣ ⦄) ⦃ inverseᵣ-injective{f = f} ⦃ [∧]-elimᵣ([∃]-proof surjective-to-invertibleᵣ) ⦄ ⦄ {-[≼]-to-[≽] : (A ≼ B) → (B ≽ A) [≼]-to-[≽] ([∃]-intro(f) ⦃ f-injective ⦄) = {![∃]-intro()!} -} [≍]-symmetry-raw : (ab@([∃]-intro f) : (A ≍ B)) → ⦃ func : Function(f) ⦄ → (B ≍ A) [≍]-symmetry-raw ([∃]-intro(f) ⦃ f-bijective ⦄) = [∃]-intro(inv f ⦃ bijective-to-invertible ⦄) ⦃ inv-bijective{f = f} ⦃ inver = bijective-to-invertible ⦄ ⦄ module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄ where open Type.Size [≍]-transitivity-raw : (ab@([∃]-intro f) : (A ≍ B)) ⦃ func-f : Function(f) ⦄ → (bc@([∃]-intro g) : (B ≍ C)) ⦃ func-g : Function(g) ⦄ → (A ≍ C) [≍]-transitivity-raw ([∃]-intro(f) ⦃ f-bijective ⦄) ([∃]-intro(g) ⦃ g-bijective ⦄) = [∃]-intro(g ∘ f) ⦃ [∘]-bijective {f = g} {g = f} ⦃ g-bijective ⦄ ⦃ f-bijective ⦄ ⦄ [≼]-transitivity-raw : (A ≼ B) → (B ≼ C) → (A ≼ C) [≼]-transitivity-raw ([∃]-intro(f) ⦃ f-injective ⦄) ([∃]-intro(g) ⦃ g-injective ⦄) = [∃]-intro(g ∘ f) ⦃ [∘]-injective {f = g}{g = f} ⦃ g-injective ⦄ ⦃ f-injective ⦄ ⦄ [≽]-transitivity-raw : (A ≽ B) → (([∃]-intro g) : (B ≽ C)) ⦃ func-g : Function(g) ⦄ → (A ≽ C) [≽]-transitivity-raw ([∃]-intro(f) ⦃ f-surjective ⦄) ([∃]-intro(g) ⦃ g-surjective ⦄) = [∃]-intro(g ∘ f) ⦃ [∘]-surjective {f = g} {g = f} ⦃ g-surjective ⦄ ⦃ f-surjective ⦄ ⦄ module _ where open import Relator.Equals renaming (_≡_ to _≡ₑ_) open import Relator.Equals.Proofs private _≍_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt _≍_ A B = Type.Size._≍_ A B _≼_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt _≼_ A B = Type.Size._≼_ A B _≽_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt _≽_ A B = Type.Size._≽_ A B _≭_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt _≭_ A B = Type.Size._≭_ A B _≺_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt _≺_ A B = Type.Size._≺_ A B _≻_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt _≻_ A B = Type.Size._≻_ A B module _ {ℓ} where instance [≍]-reflexivity : Reflexivity(_≍_ {ℓ}) [≍]-reflexivity = intro [≍]-reflexivity-raw instance [≍]-symmetry : Symmetry(_≍_ {ℓ}) [≍]-symmetry = intro(f ↦ [≍]-symmetry-raw f) instance [≍]-transitivity : Transitivity(_≍_ {ℓ}) [≍]-transitivity = intro(f ↦ g ↦ [≍]-transitivity-raw f g) instance [≍]-equivalence : Equivalence(_≍_ {ℓ}) [≍]-equivalence = intro instance [≼]-reflexivity : Reflexivity(_≼_ {ℓ}) [≼]-reflexivity = intro [≼]-reflexivity-raw instance [≼]-transitivity : Transitivity(_≼_ {ℓ}) [≼]-transitivity = intro [≼]-transitivity-raw instance [≽]-reflexivity : Reflexivity(_≽_ {ℓ}) [≽]-reflexivity = intro [≽]-reflexivity-raw instance [≽]-transitivity : Transitivity(_≽_ {ℓ}) [≽]-transitivity = intro(p ↦ q ↦ [≽]-transitivity-raw p q) instance [≼]-minimum : Weak.Properties.LE.Minimum(_≼_ {ℓ})(Empty) Weak.Properties.Extremumₗ.proof [≼]-minimum = [≼]-minimum-raw -- TODO: Impossible because there are no functions of type (T → ⊥)? -- instance -- [≽]-minimum : Weak.Properties.Maximum(_≽_ {ℓ})(Empty) -- Weak.Properties.Maximum.proof([≽]-minimum) {T} {} -- TODO: Remove this and the similar one in the other module. A more general variant is defined in Relator.Equals.Proofs module _ {A : Type{ℓ}} {B : Type{ℓ}} where [≡]-to-[≍] : (A ≡ₑ B) → (A ≍ B) [≡]-to-[≍] [≡]-intro = reflexivity(_≍_)
{ "alphanum_fraction": 0.5641336334, "avg_line_length": 36.10625, "ext": "agda", "hexsha": "1c48e9d8a81ff42ddb14d3da4ccb6ca351f7ca1b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Type/Size/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Type/Size/Proofs.agda", "max_line_length": 188, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Type/Size/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": 2595, "size": 5777 }
{-# OPTIONS --without-K #-} module common where open import Agda.Primitive public using (Level; _⊔_; lzero; lsuc) infixl 1 _,_ infixl 1 _≡_ infixr 2 _∧_ infixr 2 _×_ infixl 2 _+_ data bool : Set where true : bool false : bool _∧_ : bool → bool → bool true ∧ true = true true ∧ false = false false ∧ true = false false ∧ false = false record Σ {ℓ ℓ′} (A : Set ℓ) (P : A → Set ℓ′) : Set (ℓ ⊔ ℓ′) where constructor _,_ field proj₁ : A proj₂ : P proj₁ _×_ : ∀ {ℓ ℓ′} (A : Set ℓ) (B : Set ℓ′) → Set (ℓ ⊔ ℓ′) A × B = Σ A (λ _ → B) if_then_else_ : ∀ {ℓ} {A : Set ℓ} → (b : bool) → A → A → A if true then t else f = t if false then t else f = f data Lifted {a b} (A : Set a) : Set (b ⊔ a) where lift : A → Lifted A lower : ∀ {a b A} → Lifted {a} {b} A → A lower (lift x) = x data Maybe {ℓ : Level} (A : Set ℓ) : Set ℓ where just : (x : A) → Maybe A nothing : Maybe A Maybe-elim : ∀ {ℓ ℓ′} {A : Set ℓ} (P : Maybe A → Set ℓ′) → ((x : A) → P (just x)) → P nothing → (x : Maybe A) → P x Maybe-elim P Pjust Pnothing (just x) = Pjust x Maybe-elim P Pjust Pnothing nothing = Pnothing option-map : ∀ {ℓ ℓ′} {A : Set ℓ} {B : Set ℓ′} → (A → B) → Maybe A → Maybe B option-map f (just x) = just (f x) option-map f nothing = nothing option-bind : ∀ {ℓ ℓ′} {A : Set ℓ} {B : Set ℓ′} → Maybe A → (A → Maybe B) → Maybe B option-bind (just x) f = option-map (λ x₁ → x₁) (f x) option-bind nothing f = nothing data ⊥ {ℓ : Level} : Set ℓ where ⊥-elim : {ℓ ℓ′ : Level} → ⊥ {ℓ} → {A : Set ℓ′} → A ⊥-elim () ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ T = T → ⊥ {lzero} record ⊤ {ℓ : Level} : Set ℓ where constructor tt infixr 1 _⊎_ data _⊎_ (A : Set) (B : Set) : Set where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B data _≡_ {ℓ} {A : Set ℓ} (x : A) : A → Set ℓ where refl : x ≡ x _≢_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ x ≢ y = x ≡ y → ⊥ {lzero} dec-eq-on : {A : Set} → (x : A) → (y : A) → Set dec-eq-on x y = (x ≡ y) ⊎ (x ≢ y) dec-eq : Set → Set dec-eq A = (x : A) → (y : A) → dec-eq-on x y sym : {A : Set} → {x : A} → {y : A} → x ≡ y → y ≡ x sym refl = refl trans : {A : Set} → {x y z : A} → x ≡ y → y ≡ z → x ≡ z trans refl refl = refl transport : ∀ {A : Set} {x : A} {y : A} → (P : A → Set) → x ≡ y → P x → P y transport P refl v = v transport2 : ∀ {A : Set} {B : A → Set} {x x' : A} {y : B x} {y' : B x'} → (P : (x : A) → B x → Set) → (p : x ≡ x') → transport B p y ≡ y' → P x y → P x' y' transport2 P refl = transport (P _) transport3 : ∀ {A : Set} {B : A → Set} {C : (x : A) → (y : B x) → Set} {x x' : A} {y : B x} {y' : B x'} {z : C x y} {z' : C x' y'} → (P : (x : A) → (y : B x) → C x y → Set) → (p : x ≡ x') → (q : transport B p y ≡ y') → transport2 C p q z ≡ z' → P x y z → P x' y' z' transport3 P refl = transport2 (P _) transport4 : ∀ {A : Set} {B : A → Set} {C : (x : A) → (y : B x) → Set} {D : (x : A) → (y : B x) → (z : C x y) → Set} {x x' : A} {y : B x} {y' : B x'} {z : C x y} {z' : C x' y'} {w : D x y z} {w' : D x' y' z'} → (P : (x : A) → (y : B x) → (z : C x y) → D x y z → Set) → (p : x ≡ x') → (q : transport B p y ≡ y') → (r : transport2 C p q z ≡ z') → transport3 D p q r w ≡ w' → P x y z w → P x' y' z' w' transport4 P refl = transport3 (P _) Maybe-code : {A : Set} → Maybe A → Maybe A → Set Maybe-code (just x) (just x₁) = x ≡ x₁ Maybe-code (just x) nothing = ⊥ Maybe-code nothing (just x) = ⊥ Maybe-code nothing nothing = ⊤ Maybe-encode : ∀ {A} {x y : Maybe A} → x ≡ y → Maybe-code x y Maybe-encode {A} {just x} refl = refl Maybe-encode {A} {nothing} refl = tt Maybe-decode : ∀ {A} {x y : Maybe A} → Maybe-code x y → x ≡ y Maybe-decode {A} {just .x₁} {just x₁} refl = refl Maybe-decode {A} {just x} {nothing} () Maybe-decode {A} {nothing} {just x} () Maybe-decode {A} {nothing} {nothing} tt = refl Maybe-deencode : ∀ {A} {x y : Maybe A} {p : x ≡ y} → Maybe-decode (Maybe-encode p) ≡ p Maybe-deencode {A} {just x} {.(just x)} {refl} = refl Maybe-deencode {A} {nothing} {.nothing} {refl} = refl Maybe-endecode : ∀ {A} {x y : Maybe A} (p : Maybe-code x y) → Maybe-encode {A} {x} {y} (Maybe-decode p) ≡ p Maybe-endecode {A} {just .x'} {just x'} refl = refl Maybe-endecode {A} {just x} {nothing} () Maybe-endecode {A} {nothing} {just x} () Maybe-endecode {A} {nothing} {nothing} tt = refl data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} max : ℕ → ℕ → ℕ max 0 y = y max x 0 = x max (suc x) (suc y) = suc (max x y) _+_ : ℕ → ℕ → ℕ 0 + b = b suc a + b = suc (a + b)
{ "alphanum_fraction": 0.5097337212, "avg_line_length": 28.4649681529, "ext": "agda", "hexsha": "c1d65248f3145e248d9573e81bb9f0e66fe80e0a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JasonGross/lob", "max_forks_repo_path": "internal/common.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JasonGross/lob", "max_issues_repo_path": "internal/common.agda", "max_line_length": 398, "max_stars_count": 19, "max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JasonGross/lob", "max_stars_repo_path": "internal/common.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z", "num_tokens": 2006, "size": 4469 }
{-# OPTIONS --without-K #-} module TypeEquivEquiv where open import Equiv using (refl∼; sym∼; trans∼; sym≃; _⊎≃_; id≃; _≃_; _●_; _×≃_; qinv; gg; β⊎₁; β⊎₂; β₁; β₂; cong∘l; cong∘r; cong₂∘; β×₁; β×₂) open import TypeEquiv using (unite₊equiv; uniti₊equiv; unite₊′equiv; uniti₊′equiv; assocr₊equiv; assocl₊equiv; swap₊equiv; unite⋆equiv; uniti⋆equiv; unite⋆′equiv; uniti⋆′equiv; assocr⋆equiv; assocl⋆equiv; swap⋆equiv; distlequiv; factorlequiv; distequiv; factorequiv; distzrequiv; factorzrequiv; distzequiv; factorzequiv) open import EquivEquiv open import Data.Empty using (⊥) open import Data.Unit using (⊤) open import Data.Sum using (_⊎_) open import Data.Product using (_,_; _×_; proj₁) open import Function using (_∘_) open import Data.Sum.Properties2 using (id⊎id∼id; ⊎∘∼∘⊎; _⊎∼_; unite₊-coh; uniti₊-coh; unite₊′-coh; uniti₊′-coh; assocr₊-wf; assocl₊-wf; triangle⊎-left; triangle⊎-right; pentagon⊎-right; pentagon⊎-left; swap₊-coh; unite₊-swap-coh-left; unite₊-swap-coh-right; hexagon⊎-right; hexagon⊎-left) open import Data.Product.Properties2 using (id×id∼id; ×∘∼∘×; _×∼_; unite⋆-coh; uniti⋆-coh; unite⋆′-coh; uniti⋆′-coh; assocr⋆-wf; assocl⋆-wf; triangle×-left; triangle×-right; pentagon×-right; pentagon×-left; swap⋆-coh; unite⋆-swap-coh-left; unite⋆-swap-coh-right; hexagon×-right; hexagon×-left) open import Data.SumProd.Properties -- TODO: list them -- some local abbreviations to make life nicer infixr 10 _⊙_ private _⊙_ = trans∼ !_ = sym∼ -- we define all the equivalences-between-equivalences that hold -- between type equivalences. -- TODO: quite possibly, everything here should be abstract, as -- it shouldn't be useful to look into the structure of the proofs, -- but just that they do, indeed exist. That and the proofs are in -- fact rather boring, consisting of explicit sequences of -- unveil --> delegate to lower level -> veil -- operations. ---- -- equivalences for the ⊎ structure [id,id]≋id : ∀ {A B : Set} → id≃ {A = A} ⊎≃ id≃ {A = B} ≋ id≃ [id,id]≋id = eq (β⊎₁ ⊙ id⊎id∼id) (β⊎₂ ⊙ id⊎id∼id) -- ● and ⊎≃ commute. ⊎●≋●⊎ : {A B C D E F : Set} → {f : A ≃ C} {g : B ≃ D} {h : C ≃ E} {i : D ≃ F} → (h ● f) ⊎≃ (i ● g) ≋ (h ⊎≃ i) ● (f ⊎≃ g) ⊎●≋●⊎ = eq (β⊎₁ ⊙ β₁ ⊎∼ β₁ ⊙ ⊎∘∼∘⊎ ⊙ ! cong₂∘ β⊎₁ β⊎₁ ⊙ ! β₁) (β⊎₂ ⊙ β₂ ⊎∼ β₂ ⊙ ⊎∘∼∘⊎ ⊙ ! cong₂∘ β⊎₂ β⊎₂ ⊙ ! β₂) -- ≋ has, predictably, an additive structure as well _⊎≋_ : {A B C D : Set} {f h : A ≃ B} {g i : C ≃ D} → f ≋ h → g ≋ i → f ⊎≃ g ≋ h ⊎≃ i f≋h ⊎≋ g≋i = eq (β⊎₁ ⊙ (f≡ f≋h) ⊎∼ (f≡ g≋i) ⊙ ! β⊎₁) (β⊎₂ ⊙ (g≡ f≋h) ⊎∼ (g≡ g≋i) ⊙ ! β⊎₂) where open _≋_ -- strangely, this is not needed by Rig Category. However, it -- belongs to the structure of a Monoidal Groupoid (I think! Should -- be checked), and is quite useful on its own. sym≃-distrib⊎ : ∀ {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → sym≃ (f ⊎≃ g) ≋ sym≃ f ⊎≃ sym≃ g sym≃-distrib⊎ = -- note how the proof mixes ₁ and ₂ ! eq (β⊎₂ ⊙ ! β⊎₁) (β⊎₁ ⊙ ! β⊎₂) -- Use '-nat' to signify that operation induces a -- natural transformation, and that the induced operation -- satisfies the naturality condition thus encoded unite₊-nat : ∀ {A B} {f : A ≃ B} {g : ⊥ ≃ ⊥} → unite₊equiv ● (g ⊎≃ f) ≋ f ● unite₊equiv unite₊-nat {g = g} = eq (β₁ ⊙ cong∘l (proj₁ unite₊equiv) β⊎₁ ⊙ unite₊-coh ⊙ ! β₁) (β₂ ⊙ cong∘r (gg unite₊equiv) β⊎₂ ⊙ uniti₊-coh {g = gg g} ⊙ ! β₂) uniti₊-nat : ∀ {A B} {f : A ≃ B} {g : ⊥ ≃ ⊥} → uniti₊equiv ● f ≋ (g ⊎≃ f) ● uniti₊equiv uniti₊-nat {g = g} = eq (β₁ ⊙ ! uniti₊-coh {g = proj₁ g} ⊙ ! cong∘r (proj₁ uniti₊equiv) β⊎₁ ⊙ ! β₁) (β₂ ⊙ ! unite₊-coh ⊙ ! cong∘l (gg uniti₊equiv) β⊎₂ ⊙ ! β₂) unite₊′-nat : ∀ {A B} {f : A ≃ B} {g : ⊥ ≃ ⊥} → unite₊′equiv ● (f ⊎≃ g) ≋ f ● unite₊′equiv unite₊′-nat {g = g} = eq (β₁ ⊙ cong∘l (proj₁ unite₊′equiv) β⊎₁ ⊙ unite₊′-coh ⊙ ! β₁) (β₂ ⊙ cong∘r (gg unite₊′equiv) β⊎₂ ⊙ uniti₊′-coh {g = gg g} ⊙ ! β₂) uniti₊′-nat : ∀ {A B} {f : A ≃ B} {g : ⊥ ≃ ⊥} → uniti₊′equiv ● f ≋ (f ⊎≃ g) ● uniti₊′equiv uniti₊′-nat {g = g} = eq (β₁ ⊙ ! uniti₊′-coh {g = proj₁ g} ⊙ ! cong∘r (proj₁ uniti₊′equiv) β⊎₁ ⊙ ! β₁) (β₂ ⊙ ! unite₊′-coh ⊙ ! cong∘l (gg uniti₊′equiv) β⊎₂ ⊙ ! β₂) assocr₊-nat : ∀ {A B C D E F : Set} → {f₀ : A ≃ D} {f₁ : B ≃ E} {f₂ : C ≃ F} → assocr₊equiv ● ((f₀ ⊎≃ f₁) ⊎≃ f₂) ≋ (f₀ ⊎≃ (f₁ ⊎≃ f₂)) ● assocr₊equiv assocr₊-nat {A} {B} {C} {D} {E} {F} {f₀} {f₁} {f₂} = let assocrDEF = proj₁ (assocr₊equiv {D} {E} {F}) in let assocrABC = proj₁ (assocr₊equiv {A} {B} {C}) in let assoclDEF = gg (assocr₊equiv {D} {E} {F}) in let assoclABC = gg (assocr₊equiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l assocrDEF (β⊎₁ ⊙ (β⊎₁ ⊎∼ refl∼)) ⊙ assocr₊-wf ⊙ ! cong∘r assocrABC (refl∼ ⊎∼ β⊎₁) ⊙ ! cong∘r assocrABC β⊎₁ ⊙ ! β₁) (β₂ ⊙ cong∘r assoclDEF (β⊎₂ {f = f₀ ⊎≃ f₁} {f₂}) ⊙ cong∘r assoclDEF (β⊎₂ ⊎∼ refl∼) ⊙ assocl₊-wf ⊙ ! cong∘l assoclABC (refl∼ ⊎∼ β⊎₂) ⊙ ! cong∘l assoclABC (β⊎₂ {f = f₀} {f₁ ⊎≃ f₂}) ⊙ ! β₂) assocl₊-nat : ∀ {A B C D E F : Set} → {f₀ : A ≃ D} {f₁ : B ≃ E} {f₂ : C ≃ F} → assocl₊equiv ● (f₀ ⊎≃ (f₁ ⊎≃ f₂)) ≋ ((f₀ ⊎≃ f₁) ⊎≃ f₂) ● assocl₊equiv assocl₊-nat {A} {B} {C} {D} {E} {F} {f₀} {f₁} {f₂} = let assoclDEF = proj₁ (assocl₊equiv {D} {E} {F}) in let assoclABC = proj₁ (assocl₊equiv {A} {B} {C}) in let assocrDEF = gg (assocl₊equiv {D} {E} {F}) in let assocrABC = gg (assocl₊equiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l assoclDEF β⊎₁ ⊙ cong∘l assoclDEF (refl∼ ⊎∼ β⊎₁) ⊙ ! assocl₊-wf ⊙ ! cong∘r assoclABC (β⊎₁ ⊎∼ refl∼) ⊙ ! cong∘r assoclABC β⊎₁ ⊙ ! β₁) (β₂ ⊙ cong∘r assocrDEF (β⊎₂ {f = f₀} {f₁ ⊎≃ f₂}) ⊙ cong∘r assocrDEF (refl∼ ⊎∼ β⊎₂) ⊙ ! assocr₊-wf ⊙ ! cong∘l assocrABC (β⊎₂ ⊎∼ refl∼) ⊙ ! cong∘l assocrABC (β⊎₂ {f = f₀ ⊎≃ f₁} {f₂}) ⊙ ! β₂) -- often called 'triangle' unite-assocr₊-coh : ∀ {A B : Set} → unite₊′equiv ⊎≃ id≃ ≋ (id≃ ⊎≃ unite₊equiv) ● assocr₊equiv {A} {⊥} {B} unite-assocr₊-coh = -- eq triangle⊎-right triangle⊎-left eq (β⊎₁ ⊙ triangle⊎-right ⊙ ! (β₁ ⊙ cong∘r (proj₁ assocr₊equiv) β⊎₁)) (β⊎₂ ⊙ triangle⊎-left ⊙ ! (β₂ ⊙ cong∘l (gg assocr₊equiv) β⊎₂)) -- often called 'pentagon' assocr₊-coh : ∀ {A B C D : Set} → assocr₊equiv {A} {B} {C ⊎ D} ● assocr₊equiv ≋ (id≃ ⊎≃ assocr₊equiv) ● assocr₊equiv ● (assocr₊equiv ⊎≃ id≃) assocr₊-coh = -- eq pentagon⊎-right pentagon⊎-left eq (β₁ ⊙ pentagon⊎-right ⊙ ! (β₁ ⊙ cong₂∘ β⊎₁ β₁ ⊙ cong∘l ((proj₁ id≃ ⊎→ proj₁ assocr₊equiv) ∘ proj₁ assocr₊equiv) β⊎₁)) (β₂ ⊙ pentagon⊎-left ⊙ ! (β₂ ⊙ cong₂∘ β₂ β⊎₂ ⊙ cong∘r (gg assocr₊equiv ∘ (gg id≃ ⊎→ gg assocr₊equiv)) β⊎₂)) swap₊-nat : {A B C D : Set} {f : A ≃ C} {g : B ≃ D} → swap₊equiv ● (f ⊎≃ g) ≋ (g ⊎≃ f) ● swap₊equiv swap₊-nat = eq (β₁ ⊙ cong∘l (proj₁ swap₊equiv) β⊎₁ ⊙ swap₊-coh ⊙ ! (β₁ ⊙ cong∘r (proj₁ swap₊equiv) β⊎₁)) (β₂ ⊙ cong∘r (gg swap₊equiv) β⊎₂ ⊙ sym∼ swap₊-coh ⊙ ! (β₂ ⊙ cong∘l (gg swap₊equiv) β⊎₂)) -- also called 'triangle', but better to call it 'unit coherence' unite₊l-coh : {A : Set} → unite₊equiv {A} ≋ unite₊′equiv ● swap₊equiv unite₊l-coh = eq (unite₊-swap-coh-right ⊙ ! β₁) (unite₊-swap-coh-left ⊙ ! β₂) -- often called 'hexagon' assocr₊-swap₊-coh : ∀ {A B C : Set} → assocr₊equiv {B} {C} {A} ● swap₊equiv ● assocr₊equiv {A} {B} {C} ≋ id≃ ⊎≃ swap₊equiv ● assocr₊equiv {B} {A} {C} ● swap₊equiv ⊎≃ id≃ assocr₊-swap₊-coh {A} {B} {C} = -- eq hexagon⊎-right hexagon⊎-left let assocrBCA = proj₁ (assocr₊equiv {B} {C} {A}) in let assocrABC = proj₁ (assocr₊equiv {A} {B} {C}) in let assocrBAC = proj₁ (assocr₊equiv {B} {A} {C}) in let swapAC = proj₁ id≃ ⊎→ proj₁ (swap₊equiv {A} {C}) in let assoclBCA = gg (assocr₊equiv {B} {C} {A}) in let assoclABC = gg (assocr₊equiv {A} {B} {C}) in let assoclBAC = gg (assocr₊equiv {B} {A} {C}) in let swapCA = gg id≃ ⊎→ gg (swap₊equiv {A} {C}) in eq (β₁ ⊙ cong∘l assocrBCA β₁ ⊙ hexagon⊎-right ⊙ ! (β₁ ⊙ cong₂∘ β⊎₁ β₁ ⊙ cong∘l (swapAC ∘ assocrBAC) β⊎₁)) (β₂ ⊙ cong∘r assoclBCA β₂ ⊙ hexagon⊎-left ⊙ ! (β₂ ⊙ cong₂∘ β₂ β⊎₂ ⊙ cong∘r (assoclBAC ∘ swapCA) β⊎₂)) -- and in the opposite direction assocl₊-swap₊-coh : ∀ {A B C : Set} → assocl₊equiv {A} {B} {C} ● swap₊equiv ● assocl₊equiv {B} {C} {A} ≋ swap₊equiv ⊎≃ id≃ ● assocl₊equiv {B} {A} {C} ● id≃ ⊎≃ swap₊equiv assocl₊-swap₊-coh {A} {B} {C} = -- eq hexagon⊎-left hexagon⊎-right let assoclBCA = proj₁ (assocl₊equiv {B} {C} {A}) in let assoclABC = proj₁ (assocl₊equiv {A} {B} {C}) in let assoclBAC = proj₁ (assocl₊equiv {B} {A} {C}) in let swapBA = proj₁ (swap₊equiv {B} {A}) ⊎→ proj₁ id≃ in let assocrBCA = gg (assocl₊equiv {B} {C} {A}) in let assocrABC = gg (assocl₊equiv {A} {B} {C}) in let assocrBAC = gg (assocl₊equiv {B} {A} {C}) in let swapAB = gg (swap₊equiv {B} {A}) ⊎→ proj₁ id≃ in eq (β₁ ⊙ (cong∘l assoclABC β₁ ⊙ hexagon⊎-left) ⊙ ! (β₁ ⊙ cong₂∘ β⊎₁ β₁ ⊙ cong∘l (swapBA ∘ assoclBAC) β⊎₁)) (β₂ ⊙ cong∘r assocrABC β₂ ⊙ hexagon⊎-right ⊙ ! (β₂ ⊙ cong₂∘ β₂ β⊎₂ ⊙ cong∘r (assocrBAC ∘ swapAB) β⊎₂)) -- equivalences for the × structure id×id≋id : ∀ {A B : Set} → id≃ {A = A} ×≃ id≃ {A = B} ≋ id≃ id×id≋id = eq (β×₁ ⊙ id×id∼id) (β×₂ ⊙ id×id∼id) ×●≋●× : {A B C D E F : Set} → {f : A ≃ C} {g : B ≃ D} {h : C ≃ E} {i : D ≃ F} → (h ● f) ×≃ (i ● g) ≋ (h ×≃ i) ● (f ×≃ g) ×●≋●× {f = f , qinv f⁻¹ _ _} {g , qinv g⁻¹ _ _} {h , qinv h⁻¹ _ _} {i , qinv i⁻¹ _ _} = eq (β×₁ ⊙ β₁ ×∼ β₁ ⊙ (×∘∼∘× {f = f} {g} {h} {i}) ⊙ ! cong₂∘ β×₁ β×₁ ⊙ ! β₁) (β×₂ ⊙ β₂ ×∼ β₂ ⊙ (×∘∼∘× {f = h⁻¹} {i⁻¹} {f⁻¹} {g⁻¹}) ⊙ ! cong₂∘ β×₂ β×₂ ⊙ ! β₂) _×≋_ : ∀ {A B C D : Set} {f g : A ≃ B} {h i : C ≃ D} → f ≋ g → h ≋ i → f ×≃ h ≋ g ×≃ i e₁ ×≋ e₂ = eq (β×₁ ⊙ (f≡ e₁) ×∼ (f≡ e₂) ⊙ ! β×₁) (β×₂ ⊙ (g≡ e₁) ×∼ (g≡ e₂) ⊙ ! β×₂) where open _≋_ sym≃-distrib× : ∀ {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → sym≃ (f ×≃ g) ≋ sym≃ f ×≃ sym≃ g sym≃-distrib× = -- note how the proof mixes ₁ and ₂ ! eq (β×₂ ⊙ ! β×₁) (β×₁ ⊙ ! β×₂) unite⋆-nat : ∀ {A B} {f : A ≃ B} {g : ⊤ ≃ ⊤} → unite⋆equiv ● (g ×≃ f) ≋ f ● unite⋆equiv unite⋆-nat = -- eq unite⋆-coh uniti⋆-coh eq (β₁ ⊙ cong∘l (proj₁ unite⋆equiv) β×₁ ⊙ unite⋆-coh ⊙ ! β₁) (β₂ ⊙ cong∘r (gg unite⋆equiv) β×₂ ⊙ uniti⋆-coh ⊙ ! β₂) uniti⋆-nat : ∀ {A B} {f : A ≃ B} {g : ⊤ ≃ ⊤} → uniti⋆equiv ● f ≋ (g ×≃ f) ● uniti⋆equiv uniti⋆-nat = -- flip-sym≋ unite⋆-nat eq (β₁ ⊙ ! uniti⋆-coh ⊙ ! cong∘r (proj₁ uniti⋆equiv) β×₁ ⊙ ! β₁) (β₂ ⊙ ! unite⋆-coh ⊙ ! cong∘l (gg uniti⋆equiv) β×₂ ⊙ ! β₂) unite⋆′-nat : ∀ {A B} {f : A ≃ B} {g : ⊤ ≃ ⊤} → unite⋆′equiv ● (f ×≃ g) ≋ f ● unite⋆′equiv unite⋆′-nat = -- eq unite⋆′-coh uniti⋆′-coh eq (β₁ ⊙ cong∘l (proj₁ unite⋆′equiv) β×₁ ⊙ unite⋆′-coh ⊙ ! β₁) (β₂ ⊙ cong∘r (gg unite⋆′equiv) β×₂ ⊙ uniti⋆′-coh ⊙ ! β₂) uniti⋆′-nat : ∀ {A B} {f : A ≃ B} {g : ⊤ ≃ ⊤} → uniti⋆′equiv ● f ≋ (f ×≃ g) ● uniti⋆′equiv uniti⋆′-nat = -- flip-sym≋ unite⋆′-nat eq (β₁ ⊙ ! uniti⋆′-coh ⊙ ! cong∘r (proj₁ uniti⋆′equiv) β×₁ ⊙ ! β₁) (β₂ ⊙ ! unite⋆′-coh ⊙ ! cong∘l (gg uniti⋆′equiv) β×₂ ⊙ ! β₂) assocr⋆-nat : ∀ {A B C D E F : Set} → {f₀ : A ≃ D} {f₁ : B ≃ E} {f₂ : C ≃ F} → assocr⋆equiv ● ((f₀ ×≃ f₁) ×≃ f₂) ≋ (f₀ ×≃ (f₁ ×≃ f₂)) ● assocr⋆equiv assocr⋆-nat {A} {B} {C} {D} {E} {F} {f₀} {f₁} {f₂} = -- eq assocr⋆-wf assocl⋆-wf let assocrDEF = proj₁ (assocr⋆equiv {D} {E} {F}) in let assocrABC = proj₁ (assocr⋆equiv {A} {B} {C}) in let assoclDEF = gg (assocr⋆equiv {D} {E} {F}) in let assoclABC = gg (assocr⋆equiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l assocrDEF β×₁ ⊙ cong∘l assocrDEF (β×₁ ×∼ refl∼) ⊙ assocr⋆-wf ⊙ ! cong∘r assocrABC (refl∼ ×∼ β×₁) ⊙ ! cong∘r assocrABC β×₁ ⊙ ! β₁) (β₂ ⊙ cong∘r assoclDEF (β×₂ {f = f₀ ×≃ f₁} {f₂}) ⊙ cong∘r assoclDEF (β×₂ ×∼ refl∼) ⊙ assocl⋆-wf ⊙ ! cong∘l assoclABC (refl∼ ×∼ β×₂) ⊙ ! cong∘l assoclABC (β×₂ {f = f₀} {f₁ ×≃ f₂}) ⊙ ! β₂) assocl⋆-nat : ∀ {A B C D E F : Set} → {f₀ : A ≃ D} {f₁ : B ≃ E} {f₂ : C ≃ F} → assocl⋆equiv ● (f₀ ×≃ (f₁ ×≃ f₂)) ≋ ((f₀ ×≃ f₁) ×≃ f₂) ● assocl⋆equiv assocl⋆-nat {A} {B} {C} {D} {E} {F} {f₀} {f₁} {f₂} = -- flip-sym≋ assocr⋆-nat let assoclDEF = proj₁ (assocl⋆equiv {D} {E} {F}) in let assoclABC = proj₁ (assocl⋆equiv {A} {B} {C}) in let assocrDEF = gg (assocl⋆equiv {D} {E} {F}) in let assocrABC = gg (assocl⋆equiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l assoclDEF β×₁ ⊙ cong∘l assoclDEF (refl∼ ×∼ β×₁) ⊙ ! assocl⋆-wf ⊙ ! cong∘r assoclABC (β×₁ ×∼ refl∼) ⊙ ! cong∘r assoclABC β×₁ ⊙ ! β₁) (β₂ ⊙ cong∘r assocrDEF (β×₂ {f = f₀} {f₁ ×≃ f₂}) ⊙ cong∘r assocrDEF (refl∼ ×∼ β×₂) ⊙ ! assocr⋆-wf ⊙ ! cong∘l assocrABC (β×₂ ×∼ refl∼) ⊙ ! cong∘l assocrABC (β×₂ {f = f₀ ×≃ f₁} {f₂}) ⊙ ! β₂) -- often called 'triangle' unite-assocr⋆-coh : ∀ {A B : Set} → unite⋆′equiv ×≃ id≃ ≋ (id≃ ×≃ unite⋆equiv) ● assocr⋆equiv {A} {⊤} {B} unite-assocr⋆-coh = eq (β×₁ ⊙ triangle×-right ⊙ ! (β₁ ⊙ cong∘r (proj₁ assocr⋆equiv) β×₁)) (β×₂ ⊙ triangle×-left ⊙ ! (β₂ ⊙ cong∘l (gg assocr⋆equiv) β×₂)) -- often called 'pentagon' assocr⋆-coh : ∀ {A B C D : Set} → assocr⋆equiv {A} {B} {C × D} ● assocr⋆equiv ≋ (id≃ ×≃ assocr⋆equiv) ● assocr⋆equiv ● (assocr⋆equiv ×≃ id≃) assocr⋆-coh = eq (β₁ ⊙ pentagon×-right ⊙ ! (β₁ ⊙ cong₂∘ β×₁ β₁ ⊙ cong∘l ((proj₁ id≃ ×→ proj₁ assocr⋆equiv) ∘ proj₁ assocr⋆equiv) β×₁)) (β₂ ⊙ pentagon×-left ⊙ ! (β₂ ⊙ cong₂∘ β₂ β×₂ ⊙ cong∘r (gg assocr⋆equiv ∘ (gg id≃ ×→ gg assocr⋆equiv)) β×₂)) swap⋆-nat : {A B C D : Set} {f : A ≃ C} {g : B ≃ D} → swap⋆equiv ● (f ×≃ g) ≋ (g ×≃ f) ● swap⋆equiv swap⋆-nat = eq (β₁ ⊙ cong∘l (proj₁ swap⋆equiv) β×₁ ⊙ swap⋆-coh ⊙ ! (β₁ ⊙ cong∘r (proj₁ swap⋆equiv) β×₁)) (β₂ ⊙ cong∘r (gg swap⋆equiv) β×₂ ⊙ sym∼ swap⋆-coh ⊙ ! (β₂ ⊙ cong∘l (gg swap⋆equiv) β×₂)) -- also called 'triangle', but better to call it 'unit coherence' unite⋆l-coh : {A : Set} → unite⋆equiv {A} ≋ unite⋆′equiv ● swap⋆equiv unite⋆l-coh = eq (unite⋆-swap-coh-right ⊙ ! β₁) (unite⋆-swap-coh-left ⊙ ! β₂) -- often called 'hexagon' assocr⋆-swap⋆-coh : ∀ {A B C : Set} → assocr⋆equiv {B} {C} {A} ● swap⋆equiv ● assocr⋆equiv {A} {B} {C} ≋ id≃ ×≃ swap⋆equiv ● assocr⋆equiv {B} {A} {C} ● swap⋆equiv ×≃ id≃ assocr⋆-swap⋆-coh {A} {B} {C} = let assocrBCA = proj₁ (assocr⋆equiv {B} {C} {A}) in let assocrABC = proj₁ (assocr⋆equiv {A} {B} {C}) in let assocrBAC = proj₁ (assocr⋆equiv {B} {A} {C}) in let swapAC = proj₁ id≃ ×→ proj₁ (swap⋆equiv {A} {C}) in let assoclBCA = gg (assocr⋆equiv {B} {C} {A}) in let assoclABC = gg (assocr⋆equiv {A} {B} {C}) in let assoclBAC = gg (assocr⋆equiv {B} {A} {C}) in let swapCA = gg id≃ ×→ gg (swap⋆equiv {A} {C}) in eq (β₁ ⊙ cong∘l assocrBCA β₁ ⊙ hexagon×-right ⊙ ! (β₁ ⊙ cong₂∘ β×₁ β₁ ⊙ cong∘l (swapAC ∘ assocrBAC) β×₁)) (β₂ ⊙ cong∘r assoclBCA β₂ ⊙ hexagon×-left ⊙ ! (β₂ ⊙ cong₂∘ β₂ β×₂ ⊙ cong∘r (assoclBAC ∘ swapCA) β×₂)) -- and in the opposite direction assocl⋆-swap⋆-coh : ∀ {A B C : Set} → assocl⋆equiv {A} {B} {C} ● swap⋆equiv ● assocl⋆equiv {B} {C} {A} ≋ swap⋆equiv ×≃ id≃ ● assocl⋆equiv {B} {A} {C} ● id≃ ×≃ swap⋆equiv assocl⋆-swap⋆-coh {A} {B} {C} = let assoclBCA = proj₁ (assocl⋆equiv {B} {C} {A}) in let assoclABC = proj₁ (assocl⋆equiv {A} {B} {C}) in let assoclBAC = proj₁ (assocl⋆equiv {B} {A} {C}) in let swapBA = proj₁ (swap⋆equiv {B} {A}) ×→ proj₁ id≃ in let assocrBCA = gg (assocl⋆equiv {B} {C} {A}) in let assocrABC = gg (assocl⋆equiv {A} {B} {C}) in let assocrBAC = gg (assocl⋆equiv {B} {A} {C}) in let swapAB = gg (swap⋆equiv {B} {A}) ×→ proj₁ id≃ in eq (β₁ ⊙ (cong∘l assoclABC β₁ ⊙ hexagon×-left) ⊙ ! (β₁ ⊙ cong₂∘ β×₁ β₁ ⊙ cong∘l (swapBA ∘ assoclBAC) β×₁)) (β₂ ⊙ cong∘r assocrABC β₂ ⊙ hexagon×-right ⊙ ! (β₂ ⊙ cong₂∘ β₂ β×₂ ⊙ cong∘r (assocrBAC ∘ swapAB) β×₂)) -- distributivity distl-nat : {A B C D E F : Set} → {f : A ≃ D} {g : B ≃ E} {h : C ≃ F} → distlequiv ● (f ×≃ (g ⊎≃ h)) ≋ ((f ×≃ g) ⊎≃ (f ×≃ h)) ● distlequiv distl-nat {A} {B} {C} {D} {E} {F} {f} {g} {h} = -- eq distl-coh factorl-coh let distlDEF = proj₁ (distlequiv {D} {E} {F}) in let distlABC = proj₁ (distlequiv {A} {B} {C}) in let factorlDEF = gg (distlequiv {D} {E} {F}) in let factorlABC = gg (distlequiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l distlDEF (β×₁ ⊙ (refl∼ ×∼ β⊎₁)) ⊙ distl-coh ⊙ ! (β₁ ⊙ cong∘r distlABC (β⊎₁ ⊙ (β×₁ ⊎∼ β×₁)))) -- (β₂ ⊙ cong∘r factorlDEF (β×₂ {f = f} {g ⊎≃ h} ⊙ (refl∼ ×∼ β⊎₂)) ⊙ factorl-coh ⊙ ! (β₂ ⊙ cong∘l factorlABC (β⊎₂ {f = f ×≃ g} {f ×≃ h} ⊙ (β×₂ ⊎∼ β×₂)))) factorl-nat : {A B C D E F : Set} → {f : A ≃ D} {g : B ≃ E} {h : C ≃ F} → factorlequiv ● ((f ×≃ g) ⊎≃ (f ×≃ h)) ≋ (f ×≃ (g ⊎≃ h)) ● factorlequiv factorl-nat {A} {B} {C} {D} {E} {F} {f} {g} {h} = -- flip-sym≋ distl-nat let factorlDEF = proj₁ (factorlequiv {D} {E} {F}) in let factorlABC = proj₁ (factorlequiv {A} {B} {C}) in let distlDEF = gg (factorlequiv {D} {E} {F}) in let distlABC = gg (factorlequiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l factorlDEF (β⊎₁ ⊙ (β×₁ ⊎∼ β×₁)) ⊙ sym∼ factorl-coh ⊙ ! (β₁ ⊙ cong∘r factorlABC (β×₁ ⊙ (refl∼ ×∼ β⊎₁)) )) -- (β₂ ⊙ cong∘r distlDEF (β⊎₂ {f = f ×≃ g} {f ×≃ h} ⊙ (β×₂ ⊎∼ β×₂)) ⊙ sym∼ distl-coh ⊙ ! (β₂ ⊙ cong∘l distlABC (β×₂ {f = f} {g ⊎≃ h} ⊙ (refl∼ ×∼ β⊎₂)))) dist-nat : {A B C D E F : Set} → {f : A ≃ D} {g : B ≃ E} {h : C ≃ F} → distequiv ● ((f ⊎≃ g) ×≃ h) ≋ ((f ×≃ h) ⊎≃ (g ×≃ h)) ● distequiv dist-nat {A} {B} {C} {D} {E} {F} {f} {g} {h} = -- eq dist-coh factor-coh let distDEF = proj₁ (distequiv {D} {E} {F}) in let distABC = proj₁ (distequiv {A} {B} {C}) in let factorDEF = gg (distequiv {D} {E} {F}) in let factorABC = gg (distequiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l distDEF (β×₁ ⊙ (β⊎₁ ×∼ refl∼)) ⊙ dist-coh ⊙ ! (β₁ ⊙ cong∘r distABC (β⊎₁ ⊙ (β×₁ ⊎∼ β×₁)))) -- (β₂ ⊙ cong∘r factorDEF (β×₂ {f = f ⊎≃ g} {h} ⊙ (β⊎₂ ×∼ refl∼)) ⊙ factor-coh ⊙ ! (β₂ ⊙ cong∘l factorABC (β⊎₂ {f = f ×≃ h} {g ×≃ h} ⊙ (β×₂ ⊎∼ β×₂)))) factor-nat : {A B C D E F : Set} → {f : A ≃ D} {g : B ≃ E} {h : C ≃ F} → factorequiv ● ((f ×≃ h) ⊎≃ (g ×≃ h)) ≋ ((f ⊎≃ g) ×≃ h) ● factorequiv factor-nat {A} {B} {C} {D} {E} {F} {f} {g} {h} = -- flip-sym≋ dist-nat let factorDEF = proj₁ (factorequiv {D} {E} {F}) in let factorABC = proj₁ (factorequiv {A} {B} {C}) in let distDEF = gg (factorequiv {D} {E} {F}) in let distABC = gg (factorequiv {A} {B} {C}) in eq (β₁ ⊙ cong∘l factorDEF (β⊎₁ ⊙ (β×₁ ⊎∼ β×₁)) ⊙ sym∼ factor-coh ⊙ ! (β₁ ⊙ cong∘r factorABC (β×₁ ⊙ (β⊎₁ ×∼ refl∼)) )) -- (β₂ ⊙ cong∘r distDEF (β⊎₂ {f = f ×≃ h} {g ×≃ h} ⊙ (β×₂ ⊎∼ β×₂)) ⊙ sym∼ dist-coh ⊙ ! (β₂ ⊙ cong∘l distABC (β×₂ {f = f ⊎≃ g} {h} ⊙ (β⊎₂ ×∼ refl∼)))) -- note how we don't use id≃ but an arbitrary ⊥ ≃ ⊥. -- because this law under-specifies f and g, we need to -- be explicit in our calls distzr-nat : {A B : Set} → {f : A ≃ B} → {g : ⊥ ≃ ⊥} → distzrequiv ● (f ×≃ g) ≋ g ● distzrequiv distzr-nat {f = (f , qinv h _ _)} {(_ , qinv g _ _)} = -- eq (distzr-coh {f = f}) (factorzr-coh {f = h} {g}) eq (β₁ ⊙ cong∘l (proj₁ distzrequiv) β×₁ ⊙ distzr-coh {f = f} ⊙ ! β₁) (β₂ ⊙ cong∘r (gg distzrequiv) β×₂ ⊙ factorzr-coh {f = h} {g} ⊙ ! β₂) factorzr-nat : {A B : Set} → {f : A ≃ B} → {g : ⊥ ≃ ⊥} → factorzrequiv ● g ≋ (f ×≃ g) ● factorzrequiv factorzr-nat {f = f , qinv f⁻¹ _ _} {g , _} = -- flip-sym≋ (distzr-nat {f = sym≃ f}) eq (β₁ ⊙ sym∼ (factorzr-coh {f = f} {g}) ⊙ ! (β₁ ⊙ cong∘r (proj₁ factorzrequiv) β×₁) ) -- (β₂ ⊙ sym∼ (distzr-coh {f = f⁻¹}) ⊙ ! (β₂ ⊙ cong∘l (gg factorzrequiv) β×₂)) -- same comment as above distz-nat : {A B : Set} → {f : A ≃ B} → {g : ⊥ ≃ ⊥} → distzequiv ● (g ×≃ f) ≋ g ● distzequiv distz-nat {f = (f , qinv h _ _)} {(_ , qinv g _ _)} = eq (β₁ ⊙ cong∘l (proj₁ distzequiv) β×₁ ⊙ distz-coh {f = f} ⊙ ! β₁) (β₂ ⊙ cong∘r (gg distzequiv) β×₂ ⊙ factorz-coh {f = h} {g} ⊙ ! β₂) factorz-nat : {A B : Set} → {f : A ≃ B} → {g : ⊥ ≃ ⊥} → factorzequiv ● g ≋ (g ×≃ f) ● factorzequiv factorz-nat {f = (f , qinv f⁻¹ _ _)} {g , _} = eq (β₁ ⊙ (sym∼ (factorz-coh {f = f} {g})) ⊙ ! (β₁ ⊙ cong∘r (proj₁ factorzequiv) β×₁)) (β₂ ⊙ (sym∼ (distz-coh {f = f⁻¹})) ⊙ ! (β₂ ⊙ cong∘l (gg factorzequiv) β×₂)) -- some equivalences for which there are two 'obvious' -- programs, but are in fact equivalent. Named after -- the types which are witnessed to be equivalent. A×[B⊎C]≃[A×C]⊎[A×B] : {A B C : Set} → distlequiv ● (id≃ {A = A} ×≃ swap₊equiv {B} {C}) ≋ swap₊equiv ● distlequiv A×[B⊎C]≃[A×C]⊎[A×B] = -- eq A×[B⊎C]→[A×C]⊎[A×B] [A×C]⊎[A×B]→A×[B⊎C] eq (β₁ ⊙ cong∘l (proj₁ distlequiv) β×₁ ⊙ A×[B⊎C]→[A×C]⊎[A×B] ⊙ ! β₁) (β₂ ⊙ cong∘r (gg distlequiv) β×₂ ⊙ [A×C]⊎[A×B]→A×[B⊎C] ⊙ ! β₂) [A⊎B]×C≃[C×A]⊎[C×B] : {A B C : Set} → (swap⋆equiv ⊎≃ swap⋆equiv) ● distequiv ≋ distlequiv ● swap⋆equiv {A ⊎ B} {C} [A⊎B]×C≃[C×A]⊎[C×B] = -- eq [A⊎B]×C→[C×A]⊎[C×B] [C×A]⊎[C×B]→[A⊎B]×C eq (β₁ ⊙ cong∘r (proj₁ distequiv) β⊎₁ ⊙ [A⊎B]×C→[C×A]⊎[C×B] ⊙ ! β₁) (β₂ ⊙ cong∘l (gg distequiv) β⊎₂ ⊙ [C×A]⊎[C×B]→[A⊎B]×C ⊙ ! β₂) [A⊎B⊎C]×D≃[A×D⊎B×D]⊎C×D : {A B C D : Set} → (distequiv ⊎≃ id≃) ● distequiv ● (assocl₊equiv {A} {B} {C} ×≃ id≃ {A = D}) ≋ assocl₊equiv ● (id≃ ⊎≃ distequiv) ● distequiv [A⊎B⊎C]×D≃[A×D⊎B×D]⊎C×D = -- eq [A⊎B⊎C]×D→[A×D⊎B×D]⊎C×D [A×D⊎B×D]⊎C×D→[A⊎B⊎C]×D eq (β₁ ⊙ cong₂∘ β⊎₁ (β₁ ⊙ cong∘l (proj₁ distequiv) β×₁) ⊙ [A⊎B⊎C]×D→[A×D⊎B×D]⊎C×D ⊙ ! (β₁ ⊙ cong∘l (proj₁ assocl₊equiv) (β₁ ⊙ cong∘r (proj₁ distequiv) β⊎₁))) -- (β₂ ⊙ cong₂∘ (β₂ ⊙ cong∘r (gg distequiv) β×₂) β⊎₂ ⊙ [A×D⊎B×D]⊎C×D→[A⊎B⊎C]×D ⊙ ! (β₂ ⊙ cong∘r (gg assocl₊equiv) (β₂ ⊙ cong∘l (gg distequiv) β⊎₂))) A×B×[C⊎D]≃[A×B]×C⊎[A×B]×D : {A B C D : Set} → distlequiv ● assocl⋆equiv {A} {B} {C ⊎ D} ≋ (assocl⋆equiv ⊎≃ assocl⋆equiv) ● distlequiv ● (id≃ ×≃ distlequiv) A×B×[C⊎D]≃[A×B]×C⊎[A×B]×D = eq (β₁ ⊙ A×B×[C⊎D]→[A×B]×C⊎[A×B]×D ⊙ ! (β₁ ⊙ cong₂∘ β⊎₁ (β₁ ⊙ cong∘l (proj₁ distlequiv) β×₁))) (β₂ ⊙ [A×B]×C⊎[A×B]×D→A×B×[C⊎D] ⊙ ! (β₂ ⊙ cong₂∘ (β₂ ⊙ cong∘r (gg distlequiv) β×₂) β⊎₂)) 0×0≃0 : distzequiv ≋ distzrequiv 0×0≃0 = eq 0×0→0 0→0×0 0×[A⊎B]≃0 : {A B : Set} → distzequiv ≋ unite₊equiv ● (distzequiv ⊎≃ distzequiv) ● distlequiv {⊥} {A} {B} 0×[A⊎B]≃0 = eq (0×[A⊎B]→0 ⊙ ! (β₁ ⊙ cong∘l (proj₁ unite₊equiv) (β₁ ⊙ cong∘r (proj₁ distlequiv) β⊎₁))) (0→0×[A⊎B] ⊙ ! (β₂ ⊙ cong∘r (gg unite₊equiv) (β₂ ⊙ cong∘l (gg distlequiv) β⊎₂))) 0×1≃0 : unite⋆′equiv ≋ distzequiv 0×1≃0 = eq 0×1→0 0→0×1 A×0≃0 : {A : Set} → distzrequiv {A} ≋ distzequiv ● swap⋆equiv A×0≃0 = eq (A×0→0 ⊙ ! β₁) (0→A×0 ⊙ ! β₂) 0×A×B≃0 : {A B : Set} → distzequiv ≋ distzequiv ● (distzequiv ×≃ id≃) ● assocl⋆equiv {⊥} {A} {B} 0×A×B≃0 = let distzB = proj₁ distzequiv in let factorzA = gg distzequiv in eq (0×A×B→0 ⊙ ! (β₁ ⊙ cong∘l distzB (β₁ ⊙ cong∘r (proj₁ assocl⋆equiv) β×₁))) (0→0×A×B ⊙ ! (β₂ ⊙ cong∘r factorzA (β₂ ⊙ cong∘l (gg assocl⋆equiv) β×₂))) A×0×B≃0 : {A B : Set} → distzrequiv ● (id≃ ×≃ distzequiv) ≋ distzequiv ● (distzrequiv ×≃ id≃) ● assocl⋆equiv {A} {⊥} {B} A×0×B≃0 = eq (β₁ ⊙ cong∘l (proj₁ distzrequiv) β×₁ ⊙ A×0×B→0 ⊙ ! (β₁ ⊙ cong∘l (proj₁ distzequiv) (β₁ ⊙ cong∘r (proj₁ assocl⋆equiv) β×₁))) (β₂ ⊙ cong∘r (gg distzrequiv) β×₂ ⊙ 0→A×0×B ⊙ ! (β₂ ⊙ cong∘r (gg distzequiv) (β₂ ⊙ cong∘l (gg assocl⋆equiv) β×₂))) A×[0+B]≃A×B : {A B : Set} → (id≃ {A = A} ×≃ unite₊equiv {B}) ≋ unite₊equiv ● (distzrequiv ⊎≃ id≃) ● distlequiv A×[0+B]≃A×B = eq (β×₁ ⊙ A×[0+B]→A×B ⊙ ! (β₁ ⊙ cong∘l (proj₁ unite₊equiv) (β₁ ⊙ cong∘r (proj₁ distlequiv) β⊎₁))) (β×₂ ⊙ A×B→A×[0+B] ⊙ ! (β₂ ⊙ cong∘r (gg unite₊equiv) (β₂ ⊙ cong∘l (gg distlequiv) β⊎₂))) 1×[A⊎B]≃A⊎B : {A B : Set} → unite⋆equiv ≋ (unite⋆equiv ⊎≃ unite⋆equiv) ● distlequiv {⊤} {A} {B} 1×[A⊎B]≃A⊎B = eq (1×[A⊎B]→A⊎B ⊙ ! (β₁ ⊙ cong∘r (proj₁ distlequiv) β⊎₁)) (A⊎B→1×[A⊎B] ⊙ ! (β₂ ⊙ cong∘l (gg distlequiv) β⊎₂)) [A⊎B]×[C⊎D]≃[[A×C⊎B×C]⊎A×D]⊎B×D : {A B C D : Set} → assocl₊equiv ● (distequiv ⊎≃ distequiv) ● distlequiv ≋ (assocl₊equiv ⊎≃ id≃) ● ((id≃ ⊎≃ swap₊equiv) ⊎≃ id≃) ● (assocr₊equiv ⊎≃ id≃) ● assocl₊equiv ● (distlequiv ⊎≃ distlequiv) ● distequiv {A} {B} {C ⊎ D} [A⊎B]×[C⊎D]≃[[A×C⊎B×C]⊎A×D]⊎B×D = eq (β₁ ⊙ cong∘l (proj₁ assocl₊equiv) (β₁ ⊙ cong∘r (proj₁ distlequiv) β⊎₁) ⊙ [A⊎B]×[C⊎D]→[[A×C⊎B×C]⊎A×D]⊎B×D ⊙ ! (β₁ ⊙ cong₂∘ β⊎₁ (β₁ ⊙ cong₂∘ (β⊎₁ ⊙ (β⊎₁ ⊎∼ refl∼)) (β₁ ⊙ cong₂∘ β⊎₁ (β₁ ⊙ cong∘l (proj₁ assocl₊equiv) (β₁ ⊙ cong∘r (proj₁ distequiv) β⊎₁)))))) -- (β₂ ⊙ cong∘r (gg assocl₊equiv) (β₂ ⊙ cong∘l (gg distlequiv) β⊎₂) ⊙ [[A×C⊎B×C]⊎A×D]⊎B×D→[A⊎B]×[C⊎D] ⊙ ! (β₂ ⊙ cong₂∘ (β₂ ⊙ cong₂∘ (β₂ ⊙ cong₂∘ (β₂ ⊙ cong∘r (gg assocl₊equiv) (β₂ ⊙ cong∘l (gg distequiv) β⊎₂)) β⊎₂) (β⊎₂ {f = id≃ ⊎≃ swap₊equiv} ⊙ (β⊎₂ ⊎∼ refl∼))) β⊎₂)) ------------------------------------------------------------------------------ -- also useful [g+1]●[1+f]≋g+f : {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → (g ⊎≃ id≃) ● (id≃ ⊎≃ f) ≋ g ⊎≃ f [g+1]●[1+f]≋g+f {f = f} {g} = begin ( (g ⊎≃ id≃) ● (id≃ ⊎≃ f) ≋⟨ sym≋ ⊎●≋●⊎ ⟩ (g ● id≃) ⊎≃ (id≃ ● f) ≋⟨ rid≋ ⊎≋ lid≋ ⟩ g ⊎≃ f ∎) where open ≋-Reasoning -- same proof as above, just written compactly [1+f]●[g+1]≋g+f : {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → (id≃ ⊎≃ f) ● (g ⊎≃ id≃) ≋ g ⊎≃ f [1+f]●[g+1]≋g+f = trans≋ (sym≋ ⊎●≋●⊎) (lid≋ ⊎≋ rid≋) -- put then together [g+1]●[1+f]≋[1+f]●[g+1] : {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → (g ⊎≃ id≃) ● (id≃ ⊎≃ f) ≋ (id≃ ⊎≃ f) ● (g ⊎≃ id≃) [g+1]●[1+f]≋[1+f]●[g+1] = trans≋ [g+1]●[1+f]≋g+f (sym≋ [1+f]●[g+1]≋g+f) -- [g*1]●[1*f]≋g*f : {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → (g ×≃ id≃) ● (id≃ ×≃ f) ≋ g ×≃ f [g*1]●[1*f]≋g*f {f = f} {g} = begin ( (g ×≃ id≃) ● (id≃ ×≃ f) ≋⟨ sym≋ ×●≋●× ⟩ (g ● id≃) ×≃ (id≃ ● f) ≋⟨ rid≋ ×≋ lid≋ ⟩ g ×≃ f ∎) where open ≋-Reasoning [1*f]●[g*1]≋g*f : {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → (id≃ ×≃ f) ● (g ×≃ id≃) ≋ g ×≃ f [1*f]●[g*1]≋g*f = trans≋ (sym≋ ×●≋●×) (lid≋ ×≋ rid≋) [g*1]●[1*f]≋[1*f]●[g*1] : {A B C D : Set} {f : A ≃ B} {g : C ≃ D} → (g ×≃ id≃) ● (id≃ ×≃ f) ≋ (id≃ ×≃ f) ● (g ×≃ id≃) [g*1]●[1*f]≋[1*f]●[g*1] = trans≋ [g*1]●[1*f]≋g*f (sym≋ [1*f]●[g*1]≋g*f) ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5013256571, "avg_line_length": 40.8699690402, "ext": "agda", "hexsha": "b6b230a4b291764bee38c0937d57b4175570a52b", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/TypeEquivEquiv.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/TypeEquivEquiv.agda", "max_line_length": 87, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/TypeEquivEquiv.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": 14777, "size": 26402 }
------------------------------------------------------------------------ -- ω-continuous functions ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Partiality-algebra.Omega-continuous where open import Equality.Propositional.Cubical open import Prelude open import Bijection equality-with-J using (_↔_) import Equivalence equality-with-J as Eq open import Function-universe equality-with-J open import H-level.Closure equality-with-J open import Partiality-algebra as PA open import Partiality-algebra.Monotone -- Definition of ω-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 monotone-function : [ P₁ ⟶ P₂ ]⊑ open [_⟶_]⊑ monotone-function public field ω-continuous : ∀ s → function (P₁.⨆ s) ≡ P₂.⨆ [ monotone-function $ s ]-inc open [_⟶_] -- Identity. idω : ∀ {a p q} {A : Type a} {P : Partiality-algebra p q A} → [ P ⟶ P ] monotone-function idω = id⊑ ω-continuous 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₃ ] monotone-function (f ∘ω g) = monotone-function f ∘⊑ monotone-function g ω-continuous (_∘ω_ {P₁ = P₁} {P₂ = P₂} {P₃ = P₃} f g) s = function f (function g (P₁.⨆ s)) ≡⟨ cong (function f) (ω-continuous g s) ⟩ function f (P₂.⨆ [ monotone-function g $ s ]-inc) ≡⟨ ω-continuous f _ ⟩∎ P₃.⨆ [ monotone-function f ∘⊑ monotone-function g $ s ]-inc ∎ where module P₁ = Partiality-algebra P₁ module P₂ = Partiality-algebra P₂ module P₃ = Partiality-algebra P₃ -- Equality characterisation lemma for ω-continuous functions. equality-characterisation-continuous : ∀ {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-continuous {P₁ = P₁} {P₂ = P₂} {f} {g} = (∀ x → function f x ≡ function g x) ↝⟨ equality-characterisation-monotone ⟩ monotone-function f ≡ monotone-function g ↝⟨ ignore-propositional-component (Π-closure ext 1 λ _ → 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₂ ]⊑) → ∀ s → [_⟶_]⊑.function h (P₁.⨆ s) ≡ P₂.⨆ [ h $ s ]-inc rearrange = record { surjection = record { logical-equivalence = record { to = λ f → monotone-function f , ω-continuous f ; from = uncurry λ f c → record { monotone-function = f ; ω-continuous = 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-continuous λ _ → refl
{ "alphanum_fraction": 0.549924357, "avg_line_length": 33.8974358974, "ext": "agda", "hexsha": "dfa6162f0738431ce160d67aa2689a3520554a63", "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/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/Omega-continuous.agda", "max_line_length": 104, "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/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": 1472, "size": 3966 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.Table.Relation.Binary.Equality directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Table.Relation.Equality where open import Data.Table.Relation.Binary.Equality public
{ "alphanum_fraction": 0.4813895782, "avg_line_length": 31, "ext": "agda", "hexsha": "e6cbd1c378ca0f382ed55ce94d9ff4b4ed9ca7d3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Table/Relation/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Table/Relation/Equality.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Table/Relation/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 60, "size": 403 }
module paper where open import Data.Bool using (Bool; not; _∨_; _∧_) open import Data.Nat using (ℕ) open import Data.Fin using (Fin; suc; zero) open import Data.List using (List; _++_) renaming (_∷_ to _,_; [] to ∅) open import Data.Product using (_×_; _,_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) postulate Entity : Set _⊃_ : Bool → Bool → Bool FORALL : (Entity → Bool) → Bool EXISTS : (Entity → Bool) → Bool PERSON : Entity → Bool FIND : Entity → Entity → Bool UNICORN : Entity → Bool data U : Set where S N NP : U ⟦_⟧ᵁ : U → Set ⟦ S ⟧ᵁ = Bool ⟦ N ⟧ᵁ = Entity → Bool ⟦ NP ⟧ᵁ = Entity import IntuitionisticLogic U ⟦_⟧ᵁ as IL import LinearLogic U S ⟦_⟧ᵁ as LP import LambekGrishinCalculus U S ⟦_⟧ᵁ as LG open LG open IL.Explicit using (Ctxt; _,_; ∅) open IL.Explicit.Reify TypeReify everyone : ⟦ (el NP + ⇐ el N +) ⊗ el N + ⟧ everyone = ( (λ{ (A , B) → FORALL (λ x → B x ⊃ A x) }) , PERSON ) finds : ⟦ (el NP + ⇒ el S -) ⇐ el NP + ⟧ finds = λ{ ((x , k) , y) → k (FIND y x) } some : ⟦ el NP + ⇐ el N + ⟧ some = λ{ (A , B) → EXISTS (λ x → A x ∧ B x) } unicorn : ⟦ el N + ⟧ unicorn = UNICORN sent : · (el NP + ⇐ el N +) ⊗ el N + -- everyone · ⊗ (· (el NP + ⇒ el S -) ⇐ el NP + -- finds · ⊗ (· el NP + ⇐ el N + -- some · ⊗ · el N + · -- unicorn )) ⊢[ el S - ] sent = μ (res₃ (⊗L (res₃ (μ̃* (⇐L ( μ̃ (res₄ (res₁ (res₁ (res₃ (μ̃* (⇐L ( μ̃ (res₂ (res₃ (μ̃* (⇐L (⇒L var covar) var))))) var))))))) var))))) test : ([ sent ] (everyone , finds , some , unicorn , ∅)) ≡ (λ k → FORALL (λ x₁ → PERSON x₁ ⊃ EXISTS (λ x₂ → k (FIND x₂ x₁) ∧ UNICORN x₂))) test = refl
{ "alphanum_fraction": 0.526987812, "avg_line_length": 29.7068965517, "ext": "agda", "hexsha": "06711c2c19428d1a213c0e0a220c8029f022c10f", "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": "b880cf25ed8e81b9a965ea9aad18377008d68a9f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/msla2014", "max_forks_repo_path": "src/paper.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b880cf25ed8e81b9a965ea9aad18377008d68a9f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wenkokke/msla2014", "max_issues_repo_path": "src/paper.agda", "max_line_length": 86, "max_stars_count": 5, "max_stars_repo_head_hexsha": "b880cf25ed8e81b9a965ea9aad18377008d68a9f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/msla2014", "max_stars_repo_path": "src/paper.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-29T09:07:45.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-17T23:04:39.000Z", "num_tokens": 714, "size": 1723 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Escape {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Weakening open import Definition.Typed.Properties open import Definition.LogicalRelation open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Reducible types are well-formed. escape : ∀ {l Γ A} → Γ ⊩⟨ l ⟩ A → Γ ⊢ A escape (Uᵣ′ l′ l< ⊢Γ) = Uⱼ ⊢Γ escape (ℕᵣ [ ⊢A , ⊢B , D ]) = ⊢A escape (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) = ⊢A escape (Πᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) = ⊢A escape (emb′ 0<1 [A]) = escape [A] -- Reducible type equality respect the equality relation. escapeEq : ∀ {l Γ A B} → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ B / [A] → Γ ⊢ A ≅ B escapeEq (Uᵣ′ l' l< ⊢Γ) (U₌ PE.refl) = ≅-Urefl ⊢Γ escapeEq (ℕᵣ [ ⊢A , ⊢B , D ]) (ιx (ℕ₌ D′)) = ≅-red D D′ ℕₙ ℕₙ (≅-ℕrefl (wf ⊢A)) escapeEq (ne′ K D neK K≡K) (ιx (ne₌ M D′ neM K≡M)) = ≅-red (red D) (red D′) (ne neK) (ne neM) (~-to-≅ K≡M) escapeEq (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = ≅-red (red D) D′ Πₙ Πₙ A≡B escapeEq (emb′ 0<1 A) (ιx A≡B) = escapeEq A A≡B -- Reducible terms are well-formed. escapeTerm : ∀ {l Γ A t} → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ∷ A / [A] → Γ ⊢ t ∷ A escapeTerm (Uᵣ′ l′ l< ⊢Γ) (Uₜ A [ ⊢t , ⊢u , d ] typeA A≡A [A]) = ⊢t escapeTerm (ℕᵣ D) (ιx (ℕₜ n [ ⊢t , ⊢u , d ] t≡t prop)) = conv ⊢t (sym (subset* (red D))) escapeTerm (ne′ K D neK K≡K) (ιx (neₜ k [ ⊢t , ⊢u , d ] nf)) = conv ⊢t (sym (subset* (red D))) escapeTerm (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (f , [ ⊢t , ⊢u , d ] , funcF , f≡f , [f] , [f]₁) = conv ⊢t (sym (subset* (red D))) escapeTerm (emb′ 0<1 A) (ιx t) = escapeTerm A t -- Reducible term equality respect the equality relation. escapeTermEq : ∀ {l Γ A t u} → ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A] → Γ ⊢ t ≅ u ∷ A escapeTermEq (Uᵣ′ l′ l< ⊢Γ) (Uₜ₌ A B d d′ typeA typeB A≡B [A] [B] [A≡B]) = ≅ₜ-red (id (Uⱼ ⊢Γ)) (redₜ d) (redₜ d′) Uₙ (typeWhnf typeA) (typeWhnf typeB) A≡B escapeTermEq (ℕᵣ D) (ιx (ℕₜ₌ k k′ d d′ k≡k′ prop)) = let natK , natK′ = split prop in ≅ₜ-red (red D) (redₜ d) (redₜ d′) ℕₙ (naturalWhnf natK) (naturalWhnf natK′) k≡k′ escapeTermEq (ne′ K D neK K≡K) (ιx (neₜ₌ k m d d′ (neNfₜ₌ neT neU t≡u))) = ≅ₜ-red (red D) (redₜ d) (redₜ d′) (ne neK) (ne neT) (ne neU) (~-to-≅ₜ t≡u) escapeTermEq (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) = ≅ₜ-red (red D) (redₜ d) (redₜ d′) Πₙ (functionWhnf funcF) (functionWhnf funcG) f≡g escapeTermEq (emb′ 0<1 A) (ιx t≡u) = escapeTermEq A t≡u
{ "alphanum_fraction": 0.5327955103, "avg_line_length": 40.7285714286, "ext": "agda", "hexsha": "71d571afa263d2d39326bc3953a889e38905a901", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Escape.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Escape.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Escape.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1427, "size": 2851 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Implementation.Data.Integer where -- TODO
{ "alphanum_fraction": 0.7445255474, "avg_line_length": 22.8333333333, "ext": "agda", "hexsha": "3ae1f101e99362e163aaa7a66cb3df36008710c6", "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": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Implementation/Data/Integer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "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": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Implementation/Data/Integer.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Implementation/Data/Integer.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 29, "size": 137 }
module Categories.Products where open import Library renaming (_×_ to Pair) hiding ([_]) open import Categories _×_ : ∀{l l' m m'}(C : Cat {l}{m})(D : Cat {l'}{m'}) -> Cat C × D = record { Obj = Pair (Obj C) (Obj D) ; Hom = λ {(X , X') (Y , Y') -> Pair (Hom C X Y) (Hom D X' Y')} ; iden = iden C , iden D ; comp = λ {(f , f') (g , g') -> comp C f g , comp D f' g'} ; idl = cong₂ _,_ (idl C) (idl D) ; idr = cong₂ _,_ (idr C) (idr D) ; ass = cong₂ _,_ (ass C) (ass D) } where open Cat infixr 50 _×_ record Prod {l}{m}(C : Cat {l}{m})(A : Cat.Obj C)(B : Cat.Obj C) : Set (l ⊔ m) where constructor prod open Cat C field Pr : Obj π₁ : Hom Pr A π₂ : Hom Pr B [_,_] : ∀{C} → Hom C A → Hom C B → Hom C Pr law1 : ∀{C}{f : Hom C A}{g} → comp π₁ [ f , g ] ≅ f law2 : ∀{C}{f : Hom C A}{g} → comp π₂ [ f , g ] ≅ g law3 : ∀{C}{f : Hom C A}{g : Hom C B}{h : Hom C Pr} → comp π₁ h ≅ f → comp π₂ h ≅ g → h ≅ [ f , g ]
{ "alphanum_fraction": 0.4397363465, "avg_line_length": 34.2580645161, "ext": "agda", "hexsha": "b008302d13a1496fdd759f86756e2d861e674059", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "Categories/Products.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "Categories/Products.agda", "max_line_length": 78, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "Categories/Products.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 418, "size": 1062 }
module Issue59 where data Nat : Set where zero : Nat suc : Nat → Nat -- This no longer termination checks with the -- new rules for with. bad : Nat → Nat bad n with n ... | zero = zero ... | suc m = bad m -- This shouldn't termination check. bad₂ : Nat → Nat bad₂ n with bad₂ n ... | m = m
{ "alphanum_fraction": 0.6266666667, "avg_line_length": 15.7894736842, "ext": "agda", "hexsha": "7a392c95a11369318f2a0eb900cfbc4b438f0e62", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/Issue59.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Fail/Issue59.agda", "max_line_length": 45, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/Issue59.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": 94, "size": 300 }
module Cats.Util.SetoidMorphism.Iso where open import Data.Product using (_,_ ; proj₁ ; proj₂) open import Level using (_⊔_) open import Relation.Binary using (Setoid ; IsEquivalence) open import Cats.Util.SetoidMorphism as Mor using ( _⇒_ ; arr ; resp ; _≈_ ; ≈-intro ; ≈-elim ; ≈-elim′ ; _∘_ ; ∘-resp ; id ; IsInjective ; IsSurjective) open import Cats.Util.SetoidReasoning private module S = Setoid record IsIso {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} (f : A ⇒ B) : Set (l ⊔ l≈ ⊔ l′ ⊔ l≈′) where field back : B ⇒ A forth-back : f ∘ back ≈ id back-forth : back ∘ f ≈ id open IsIso record _≅_ {l l≈} (A : Setoid l l≈) {l′ l≈′} (B : Setoid l′ l≈′) : Set (l ⊔ l≈ ⊔ l′ ⊔ l≈′) where field forth : A ⇒ B back : B ⇒ A forth-back : forth ∘ back ≈ id back-forth : back ∘ forth ≈ id open _≅_ public IsIso→≅ : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} (f : A ⇒ B) → IsIso f → A ≅ B IsIso→≅ f i = record { forth = f ; back = back i ; forth-back = forth-back i ; back-forth = back-forth i } ≅→IsIso : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} → (i : A ≅ B) → IsIso (forth i) ≅→IsIso i = record { back = back i ; forth-back = forth-back i ; back-forth = back-forth i } IsIso-resp : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} → {f g : A ⇒ B} → f ≈ g → IsIso f → IsIso g IsIso-resp {A = A} {B = B} {f} {g} f≈g i = record { back = back i ; forth-back = ≈-intro λ {x} {y} x≈y → begin⟨ B ⟩ arr g (arr (back i) x) ≈⟨ B.sym (≈-elim f≈g (resp (back i) (B.sym x≈y))) ⟩ arr f (arr (back i) y) ≈⟨ ≈-elim′ (forth-back i) ⟩ y ∎ ; back-forth = ≈-intro λ {x} {y} x≈y → begin⟨ A ⟩ arr (back i) (arr g x) ≈⟨ resp (back i) (B.sym (≈-elim f≈g (A.sym x≈y))) ⟩ arr (back i) (arr f y) ≈⟨ ≈-elim′ (back-forth i) ⟩ y ∎ } where module A = Setoid A module B = Setoid B refl : ∀ {l l≈} {A : Setoid l l≈} → A ≅ A refl = record { forth = id ; back = id ; forth-back = ≈-intro λ eq → eq ; back-forth = ≈-intro λ eq → eq } sym : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} → A ≅ B → B ≅ A sym i = record { forth = back i ; back = forth i ; forth-back = back-forth i ; back-forth = forth-back i } trans : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} → ∀ {l″ l≈″} {C : Setoid l″ l≈″} → A ≅ B → B ≅ C → A ≅ C trans {A = A} {C = C} AB BC = record { forth = forth BC ∘ forth AB ; back = back AB ∘ back BC ; forth-back = ≈-intro λ x≈y → S.trans C (resp (forth BC) (≈-elim (forth-back AB) (resp (back BC) x≈y))) (≈-elim′ (forth-back BC)) ; back-forth = ≈-intro λ x≈y → S.trans A (resp (back AB) (≈-elim (back-forth BC) (resp (forth AB) x≈y))) (≈-elim′ (back-forth AB)) } module _ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} where Injective∧Surjective→Iso : {f : A ⇒ B} → IsInjective f → IsSurjective f → IsIso f Injective∧Surjective→Iso {f} inj surj = record { back = record { arr = λ b → proj₁ (surj b) ; resp = λ {b} {c} b≈c → inj (S.trans B (S.sym B (proj₂ (surj b))) (S.trans B b≈c (proj₂ (surj c)))) } ; forth-back = ≈-intro λ {x} {y} x≈y → S.trans B (S.sym B (proj₂ (surj x))) x≈y ; back-forth = ≈-intro λ {x} {y} x≈y → inj (S.trans B (S.sym B (proj₂ (surj _))) (resp f x≈y)) } Injective∧Surjective→≅ : {f : A ⇒ B} → IsInjective f → IsSurjective f → A ≅ B Injective∧Surjective→≅ {f} inj surj = IsIso→≅ f (Injective∧Surjective→Iso inj surj) Iso→Injective : {f : A ⇒ B} → IsIso f → IsInjective f Iso→Injective {f} i {a} {b} fa≈fb = begin⟨ A ⟩ a ≈⟨ S.sym A (≈-elim′ (back-forth i)) ⟩ arr (back i) (arr f a) ≈⟨ resp (back i) fa≈fb ⟩ arr (back i) (arr f b) ≈⟨ ≈-elim′ (back-forth i) ⟩ b ∎ ≅-Injective : (i : A ≅ B) → IsInjective (forth i) ≅-Injective i = Iso→Injective (≅→IsIso i) Iso→Surjective : {f : A ⇒ B} → IsIso f → IsSurjective f Iso→Surjective i b = arr (back i) b , S.sym B (≈-elim′ (forth-back i)) ≅-Surjective : (i : A ≅ B) → IsSurjective (forth i) ≅-Surjective i = Iso→Surjective (≅→IsIso i)
{ "alphanum_fraction": 0.4948735475, "avg_line_length": 26.9263803681, "ext": "agda", "hexsha": "f56396a2c006801a645fa64ed738e5b8de916501", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Util/SetoidMorphism/Iso.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Util/SetoidMorphism/Iso.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Util/SetoidMorphism/Iso.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1918, "size": 4389 }
{- T R U N C A T I O N L E V E L S I N H O M O T O P Y T Y P E T H E O R Y ======= ELECTRONIC APPENDIX ======= NICOLAI KRAUS February 2015 -} {-# OPTIONS --without-K #-} module INDEX where -- Chapter 2 open import Preliminaries -- Parts of Chapter 2 are in a separate file: open import Pointed {- Chapter 3,4,5,6 are joint work with Martin Escardo, Thierry Coquand, Thorsten Altenkirch -} -- Chapter 3 open import Truncation_Level_Criteria -- Chapter 4 open import Anonymous_Existence_CollSplit open import Anonymous_Existence_Populatedness open import Anonymous_Existence_Comparison -- Chapter 5 open import Weakly_Constant_Functions -- Chapter 6 open import Judgmental_Computation {- Chapter 7 (joint work with Christian Sattler) has two parts. First, we construct homotopically complicated types; this development is distributed beween two files. Then, we discuss connectedness, which turns out to be very hard to formalise; we use in total five files to structure that discussion, see below. -} {- First, we have an auxiliary file which makes precise that the 'universe of n-types' behaves like an actual universe. We formalise operations for it; this is very useful as it allows a more 'principled' development. -} open import UniverseOfNTypes {- Now: Sections 1-4 of Chapter 7, where 1,2 are "hidden". They are special cases of the more general theorem that we prove in 7.4; the special cases are written out only for pedagogical reasons and are thus omitted in this formalisation. -} open import HHHUU-ComplicatedTypes {- Note that Chapter 7.5 is not formalised, even though it could have been; we omit it because it is only an alternative to the above formalisation, and actually leads to a weaker result than the one in 'HHHUU-ComplicatedTypes'. Chapter 7.6 is very hard to formalise (mostly done by Christian Sattler). Caveat: The order of the statements in the formalisation is different from the order in the thesis (it sometimes is more convenient to define multiple notions in the same module because they share argument to avoid replication of code, without them belonging together logically). First, we show (in a separate file) that the non-dependent universal property and the dependent universal property are equivalent. Contains: Definition 7.6.2, Lemma 7.6.6 -} open import Trunc.Universal -- Definition 7.6.4, Lemma 7.6.7, Corollary 7.6.8 open import Trunc.Basics -- Lemma 7.6.9, Lemma 7.6.10 -- (actually even a stronger version of Lemma 7.6.10) open import Trunc.TypeConstructors {- main part of connectedness: (link to 7.6.1,) Definition 7.6.13, Definition 7.6.11, Lemma 7.6.14, Lemma 7.6.12, Lemma 7.6.15 and Theorem 7.7.1 -} open import Trunc.Connection -- Remark 7.6.16 open import Trunc.ConnectednessAlt {- The main result of Chapter 8 is, unfortunately, meta-theoretical. It is plausible that in an implementation of a type theory with 'two levels' (one semi-internal 'strict' equality and the ordinary identity type), the complete Chapter 8 could be formalised; but at the moment, this is merely speculation. -} -- Chapter 9.2: Semi-Simplicial Types -- Proposition 9.2.1 (Δ₊ implemented with judgmental categorical laws) open import Deltaplus
{ "alphanum_fraction": 0.7249705536, "avg_line_length": 29.7894736842, "ext": "agda", "hexsha": "c83cc15371e6c2d267841a53595f2eff72c247fb", "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/INDEX.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/INDEX.agda", "max_line_length": 70, "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/INDEX.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": 945, "size": 3396 }
{-# OPTIONS --verbose tc.constr.findInScope:20 #-} module InstanceArgumentsConstraints where data Bool : Set where true false : Bool postulate A1 A2 B C : Set a1 : A1 a2 : A2 someF : A1 → C record Class (R : Bool → Set) : Set where field f : (t : Bool) → R t open Class {{...}} class1 : Class (λ _ → A1) class1 = record { f = λ _ → a1 } class2 : Class (λ _ → A2) class2 = record { f = λ _ → a2 } test : C test = someF (f true)
{ "alphanum_fraction": 0.5735607676, "avg_line_length": 18.0384615385, "ext": "agda", "hexsha": "57e185e103a1e426d5bb3770498cbbfe19940863", "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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/succeed/InstanceArgumentsConstraints.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "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": "asr/agda-kanso", "max_issues_repo_path": "test/succeed/InstanceArgumentsConstraints.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/InstanceArgumentsConstraints.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 156, "size": 469 }
{-# OPTIONS --cubical --safe #-} module Data.Bool where open import Level open import Agda.Builtin.Bool using (Bool; true; false) public open import Data.Unit open import Data.Empty bool : ∀ {ℓ} {P : Bool → Type ℓ} (f : P false) (t : P true) → (x : Bool) → P x bool f t false = f bool f t true = t not : Bool → Bool not false = true not true = false infixl 6 _or_ _or_ : Bool → Bool → Bool false or y = y true or y = true infixl 7 _and_ _and_ : Bool → Bool → Bool false and y = false true and y = y infixr 0 if_then_else_ if_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A if true then x else _ = x if false then _ else x = x T : Bool → Type₀ T true = ⊤ T false = ⊥
{ "alphanum_fraction": 0.6352941176, "avg_line_length": 18.8888888889, "ext": "agda", "hexsha": "a67435de8ee60d58b75ffe63eeccabc6282d4ac1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/Bool.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/Bool.agda", "max_line_length": 78, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/Bool.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 245, "size": 680 }
------------------------------------------------------------------------ -- Example: Left recursive expression grammar ------------------------------------------------------------------------ module TotalParserCombinators.Examples.Expression where open import Codata.Musical.Notation open import Data.Char as Char using (Char) open import Data.List open import Data.Nat open import Data.String as String using (String) open import Function open import Relation.Binary.PropositionalEquality as P using (_≡_) open import TotalParserCombinators.BreadthFirst open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser open Token Char Char._≟_ ------------------------------------------------------------------------ -- An expression grammar -- t ∷= t '+' f ∣ f -- f ∷= f '*' a ∣ a -- a ∷= '(' t ')' ∣ n -- Applicative implementation of the grammar. module Applicative where mutual term = ♯ (return (λ e₁ _ e₂ → e₁ + e₂) ⊛ term) ⊛ tok '+' ⊛ factor ∣ factor factor = ♯ (return (λ e₁ _ e₂ → e₁ * e₂) ⊛ factor) ⊛ tok '*' ⊛ atom ∣ atom atom = return (λ _ e _ → e) ⊛ tok '(' ⊛ ♯ term ⊛ tok ')' ∣ number -- Monadic implementation of the grammar. module Monadic where mutual term = factor ∣ ♯ term >>= λ e₁ → tok '+' >>= λ _ → factor >>= λ e₂ → return (e₁ + e₂) factor = atom ∣ ♯ factor >>= λ e₁ → tok '*' >>= λ _ → atom >>= λ e₂ → return (e₁ * e₂) atom = number ∣ tok '(' >>= λ _ → ♯ term >>= λ e → tok ')' >>= λ _ → return e ------------------------------------------------------------------------ -- Unit tests module Tests where test : ∀ {R xs} → Parser Char R xs → String → List R test p = parse p ∘ String.toList -- Some examples have been commented out in order to reduce -- type-checking times. -- ex₁ : test Applicative.term "1*(2+3)" ≡ [ 5 ] -- ex₁ = P.refl -- ex₂ : test Applicative.term "1*(2+3" ≡ [] -- ex₂ = P.refl ex₃ : test Monadic.term "1+2+3" ≡ [ 6 ] ex₃ = P.refl ex₄ : test Monadic.term "+32" ≡ [] ex₄ = P.refl
{ "alphanum_fraction": 0.4673018623, "avg_line_length": 25.9438202247, "ext": "agda", "hexsha": "7ad0792facd72a1ce970a1c2ac256b9bba0a9525", "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/Examples/Expression.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/Examples/Expression.agda", "max_line_length": 72, "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/Examples/Expression.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": 616, "size": 2309 }
module Tactic.Nat.Reflect where open import Prelude hiding (abs) open import Control.Monad.State open import Control.Monad.Transformer import Agda.Builtin.Nat as Builtin open import Builtin.Reflection open import Tactic.Reflection open import Tactic.Reflection.Quote open import Tactic.Reflection.Meta open import Tactic.Deriving.Quotable open import Tactic.Reflection.Equality open import Tactic.Nat.Exp R = StateT (Nat × List (Term × Nat)) TC fail : ∀ {A} → R A fail = lift (typeErrorS "reflection error") liftMaybe : ∀ {A} → Maybe A → R A liftMaybe = maybe fail pure runR : ∀ {A} → R A → TC (Maybe (A × List Term)) runR r = maybeA (second (reverse ∘ map fst ∘ snd) <$> runStateT r (0 , [])) pattern `Nat = def (quote Nat) [] infixr 1 _`->_ infix 4 _`≡_ pattern _`≡_ x y = def (quote _≡_) (_ ∷ hArg `Nat ∷ vArg x ∷ vArg y ∷ []) pattern _`->_ a b = pi (vArg a) (abs _ b) pattern _`+_ x y = def₂ (quote Builtin._+_) x y pattern _`*_ x y = def₂ (quote Builtin._*_) x y pattern `0 = con₀ (quote Nat.zero) pattern `suc n = con₁ (quote Nat.suc) n fresh : Term → R (Exp Var) fresh t = get >>= uncurry′ λ i Γ → var i <$ put (suc i , (t , i) ∷ Γ) ⟨suc⟩ : ∀ {X} → Exp X → Exp X ⟨suc⟩ (lit n) = lit (suc n) ⟨suc⟩ (lit n ⟨+⟩ e) = lit (suc n) ⟨+⟩ e ⟨suc⟩ e = lit 1 ⟨+⟩ e private forceInstance : Name → Term → R ⊤ forceInstance i v = lift $ unify v (def₀ i) forceSemiring = forceInstance (quote SemiringNat) forceNumber = forceInstance (quote NumberNat) termToExpR : Term → R (Exp Var) termToExpR (a `+ b) = ⦇ termToExpR a ⟨+⟩ termToExpR b ⦈ termToExpR (a `* b) = ⦇ termToExpR a ⟨*⟩ termToExpR b ⦈ termToExpR (def (quote Semiring._+_) (_ ∷ _ ∷ vArg i@(meta x _) ∷ vArg a ∷ vArg b ∷ [])) = do forceSemiring i ⦇ termToExpR a ⟨+⟩ termToExpR b ⦈ termToExpR (def (quote Semiring._*_) (_ ∷ _ ∷ vArg i@(meta x _) ∷ vArg a ∷ vArg b ∷ [])) = do lift $ unify i (def₀ (quote SemiringNat)) ⦇ termToExpR a ⟨*⟩ termToExpR b ⦈ termToExpR (def (quote Semiring.zro) (_ ∷ _ ∷ vArg i@(meta x _) ∷ [])) = do forceSemiring i pure (lit 0) termToExpR (def (quote Semiring.one) (_ ∷ _ ∷ vArg i@(meta x _) ∷ [])) = do forceSemiring i pure (lit 1) termToExpR (def (quote Number.fromNat) (_ ∷ _ ∷ vArg i@(meta x _) ∷ vArg a ∷ _ ∷ [])) = do forceNumber i termToExpR a termToExpR `0 = pure (lit 0) termToExpR (`suc a) = ⟨suc⟩ <$> termToExpR a termToExpR (lit (nat n)) = pure (lit n) termToExpR (meta x _) = lift (blockOnMeta x) termToExpR unknown = fail termToExpR t = do lift (ensureNoMetas t) just i ← gets (flip lookup t ∘ snd) where nothing → fresh t pure (var i) private lower : Nat → Term → R Term lower 0 = pure lower i = liftMaybe ∘ strengthen i termToEqR : Term → R (Exp Var × Exp Var) termToEqR (lhs `≡ rhs) = ⦇ termToExpR lhs , termToExpR rhs ⦈ termToEqR (def (quote _≡_) (_ ∷ hArg (meta x _) ∷ _)) = lift (blockOnMeta x) termToEqR (meta x _) = lift (blockOnMeta x) termToEqR _ = fail termToHypsR′ : Nat → Term → R (List (Exp Var × Exp Var)) termToHypsR′ i (hyp `-> a) = _∷_ <$> (termToEqR =<< lower i hyp) <*> termToHypsR′ (suc i) a termToHypsR′ _ (meta x _) = lift (blockOnMeta x) termToHypsR′ i a = [_] <$> (termToEqR =<< lower i a) termToHypsR : Term → R (List (Exp Var × Exp Var)) termToHypsR = termToHypsR′ 0 termToHyps : Term → TC (Maybe (List (Exp Var × Exp Var) × List Term)) termToHyps t = runR (termToHypsR t) termToEq : Term → TC (Maybe ((Exp Var × Exp Var) × List Term)) termToEq t = runR (termToEqR t) buildEnv : List Nat → Env Var buildEnv [] i = 0 buildEnv (x ∷ xs) zero = x buildEnv (x ∷ xs) (suc i) = buildEnv xs i defaultArg : Term → Arg Term defaultArg = arg (arg-info visible relevant) data ProofError {a} : Set a → Set (lsuc a) where bad-goal : ∀ g → ProofError g qProofError : Term → Term qProofError v = con (quote bad-goal) (defaultArg v ∷ []) implicitArg instanceArg : ∀ {A} → A → Arg A implicitArg = arg (arg-info hidden relevant) instanceArg = arg (arg-info instance′ relevant) unquoteDecl QuotableExp = deriveQuotable QuotableExp (quote Exp) stripImplicitArg : Arg Term → List (Arg Term) stripImplicitArgs : List (Arg Term) → List (Arg Term) stripImplicitAbsTerm : Abs Term → Abs Term stripImplicitArgTerm : Arg Term → Arg Term stripImplicit : Term → Term stripImplicit (var x args) = var x (stripImplicitArgs args) stripImplicit (con c args) = con c (stripImplicitArgs args) stripImplicit (def f args) = def f (stripImplicitArgs args) stripImplicit (meta x args) = meta x (stripImplicitArgs args) stripImplicit (lam v t) = lam v (stripImplicitAbsTerm t) stripImplicit (pi t₁ t₂) = pi (stripImplicitArgTerm t₁) (stripImplicitAbsTerm t₂) stripImplicit (agda-sort x) = agda-sort x stripImplicit (lit l) = lit l stripImplicit (pat-lam cs args) = pat-lam cs (stripImplicitArgs args) stripImplicit unknown = unknown stripImplicitAbsTerm (abs x v) = abs x (stripImplicit v) stripImplicitArgs [] = [] stripImplicitArgs (a ∷ as) = stripImplicitArg a ++ stripImplicitArgs as stripImplicitArgTerm (arg i x) = arg i (stripImplicit x) stripImplicitArg (arg (arg-info visible r) x) = arg (arg-info visible r) (stripImplicit x) ∷ [] stripImplicitArg (arg (arg-info hidden r) x) = [] stripImplicitArg (arg (arg-info instance′ r) x) = [] quotedEnv : List Term → Term quotedEnv ts = def (quote buildEnv) $ defaultArg (quoteList $ map stripImplicit ts) ∷ [] QED : ∀ {a} {A : Set a} {x : Maybe A} → Set QED {x = x} = IsJust x get-proof : ∀ {a} {A : Set a} (prf : Maybe A) → QED {x = prf} → A get-proof (just eq) _ = eq get-proof nothing () {-# STATIC get-proof #-} getProof : Name → Term → Term → Term getProof err t proof = def (quote get-proof) $ vArg proof ∷ vArg (def err $ vArg (stripImplicit t) ∷ []) ∷ [] failedProof : Name → Term → Term failedProof err t = def (quote get-proof) $ vArg (con (quote nothing) []) ∷ vArg (def err $ vArg (stripImplicit t) ∷ []) ∷ [] cantProve : Set → ⊤ cantProve _ = _ invalidGoal : Set → ⊤ invalidGoal _ = _
{ "alphanum_fraction": 0.6594603653, "avg_line_length": 31.2408376963, "ext": "agda", "hexsha": "cde2fe9dd1cac0be8bd428df7a8f3a265d44a7d5", "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": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Nat/Reflect.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "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": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Nat/Reflect.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Nat/Reflect.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2118, "size": 5967 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Algebra where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphism open import Cubical.Algebra.Group.MorphismProperties open import Cubical.HITs.PropositionalTruncation hiding (map) -- open import Cubical.Data.Group.Base open Iso open Group open GroupHom private variable ℓ ℓ₁ ℓ₂ ℓ₃ : Level ------- elementary properties of morphisms -------- -- (- 0) = 0 -0≡0 : ∀ {ℓ} {G : Group {ℓ}} → (- G) (0g G) ≡ (0g G) -- - 0 ≡ 0 -0≡0 {G = G} = sym (IsGroup.lid (isGroup G) _) ∙ fst (IsGroup.inverse (isGroup G) _) -- ϕ(0) ≡ 0 morph0→0 : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) (f : GroupHom G H) → fun f (0g G) ≡ 0g H morph0→0 G H f = (fun f) (0g G) ≡⟨ sym (IsGroup.rid (isGroup H) _) ⟩ (f' (0g G) H.+ 0g H) ≡⟨ (λ i → f' (0g G) H.+ invr H (f' (0g G)) (~ i)) ⟩ (f' (0g G) H.+ (f' (0g G) H.+ (H.- f' (0g G)))) ≡⟨ (Group.assoc H (f' (0g G)) (f' (0g G)) (H.- (f' (0g G)))) ⟩ ((f' (0g G) H.+ f' (0g G)) H.+ (H.- f' (0g G))) ≡⟨ sym (cong (λ x → x H.+ (H.- f' (0g G))) (sym (cong f' (IsGroup.lid (isGroup G) _)) ∙ isHom f (0g G) (0g G))) ⟩ (f' (0g G)) H.+ (H.- (f' (0g G))) ≡⟨ invr H (f' (0g G)) ⟩ 0g H ∎ where module G = Group G module H = Group H f' = fun f -- ϕ(- x) = - ϕ(x) morphMinus : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) → (ϕ : GroupHom G H) → (g : ⟨ G ⟩) → fun ϕ ((- G) g) ≡ (- H) (fun ϕ g) morphMinus G H ϕ g = f (G.- g) ≡⟨ sym (IsGroup.rid (isGroup H) (f (G.- g))) ⟩ (f (G.- g) H.+ 0g H) ≡⟨ cong (f (G.- g) H.+_) (sym (invr H (f g))) ⟩ (f (G.- g) H.+ (f g H.+ (H.- f g))) ≡⟨ Group.assoc H (f (G.- g)) (f g) (H.- f g) ⟩ ((f (G.- g) H.+ f g) H.+ (H.- f g)) ≡⟨ cong (H._+ (H.- f g)) helper ⟩ (0g H H.+ (H.- f g)) ≡⟨ IsGroup.lid (isGroup H) (H.- (f g))⟩ H.- (f g) ∎ where module G = Group G module H = Group H f = fun ϕ helper : (f (G.- g) H.+ f g) ≡ 0g H helper = sym (isHom ϕ (G.- g) g) ∙∙ cong f (invl G g) ∙∙ morph0→0 G H ϕ -- ----------- Alternative notions of isomorphisms -------------- record GroupIso {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where no-eta-equality constructor iso field map : GroupHom G H inv : ⟨ H ⟩ → ⟨ G ⟩ rightInv : section (GroupHom.fun map) inv leftInv : retract (GroupHom.fun map) inv record BijectionIso {ℓ ℓ'} (A : Group {ℓ}) (B : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor bij-iso field map' : GroupHom A B inj : isInjective A B map' surj : isSurjective A B map' -- "Very" short exact sequences -- i.e. an exact sequence A → B → C → D where A and D are trivial record vSES {ℓ ℓ' ℓ'' ℓ'''} (A : Group {ℓ}) (B : Group {ℓ'}) (leftGr : Group {ℓ''}) (rightGr : Group {ℓ'''}) : Type (ℓ-suc (ℓ-max ℓ (ℓ-max ℓ' (ℓ-max ℓ'' ℓ''')))) where constructor ses field isTrivialLeft : isProp ⟨ leftGr ⟩ isTrivialRight : isProp ⟨ rightGr ⟩ left : GroupHom leftGr A right : GroupHom B rightGr ϕ : GroupHom A B Ker-ϕ⊂Im-left : (x : ⟨ A ⟩) → isInKer A B ϕ x → isInIm leftGr A left x Ker-right⊂Im-ϕ : (x : ⟨ B ⟩) → isInKer B rightGr right x → isInIm A B ϕ x open BijectionIso open GroupIso open vSES compGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} {A : Group {ℓ₂}} → GroupIso G H → GroupIso H A → GroupIso G A map (compGroupIso iso1 iso2) = compGroupHom (map iso1) (map iso2) inv (compGroupIso iso1 iso2) = inv iso1 ∘ inv iso2 rightInv (compGroupIso iso1 iso2) a = cong (fun (map iso2)) (rightInv iso1 _) ∙ rightInv iso2 a leftInv (compGroupIso iso1 iso2) a = cong (inv iso1) (leftInv iso2 _) ∙ leftInv iso1 a isGroupHomInv' : {G : Group {ℓ}} {H : Group {ℓ₁}} (f : GroupIso G H) → isGroupHom H G (inv f) isGroupHomInv' {G = G} {H = H} f h h' = isInj-f _ _ ( f' (g (h ⋆² h')) ≡⟨ (rightInv f) _ ⟩ (h ⋆² h') ≡⟨ sym (cong₂ _⋆²_ (rightInv f h) (rightInv f h')) ⟩ (f' (g h) ⋆² f' (g h')) ≡⟨ sym (isHom (map f) _ _) ⟩ -- sym (isHom (hom f) _ _) ⟩ f' (g h ⋆¹ g h') ∎) where f' = fun (map f) _⋆¹_ = Group._+_ G _⋆²_ = Group._+_ H g = inv f -- invEq (eq f) isInj-f : (x y : ⟨ G ⟩) → f' x ≡ f' y → x ≡ y isInj-f x y p = sym (leftInv f _) ∙∙ cong g p ∙∙ leftInv f _ invGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} → GroupIso G H → GroupIso H G fun (map (invGroupIso iso1)) = inv iso1 isHom (map (invGroupIso iso1)) = isGroupHomInv' iso1 inv (invGroupIso iso1) = fun (map iso1) rightInv (invGroupIso iso1) = leftInv iso1 leftInv (invGroupIso iso1) = rightInv iso1 dirProdGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} {A : Group {ℓ₂}} {B : Group {ℓ₃}} → GroupIso G H → GroupIso A B → GroupIso (dirProd G A) (dirProd H B) fun (map (dirProdGroupIso iso1 iso2)) prod = fun (map iso1) (fst prod) , fun (map iso2) (snd prod) isHom (map (dirProdGroupIso iso1 iso2)) a b = ΣPathP (isHom (map iso1) (fst a) (fst b) , isHom (map iso2) (snd a) (snd b)) inv (dirProdGroupIso iso1 iso2) prod = (inv iso1) (fst prod) , (inv iso2) (snd prod) rightInv (dirProdGroupIso iso1 iso2) a = ΣPathP (rightInv iso1 (fst a) , (rightInv iso2 (snd a))) leftInv (dirProdGroupIso iso1 iso2) a = ΣPathP (leftInv iso1 (fst a) , (leftInv iso2 (snd a))) GrIsoToGrEquiv : {G : Group {ℓ}} {H : Group {ℓ₂}} → GroupIso G H → GroupEquiv G H GroupEquiv.eq (GrIsoToGrEquiv i) = isoToEquiv (iso (fun (map i)) (inv i) (rightInv i) (leftInv i)) GroupEquiv.isHom (GrIsoToGrEquiv i) = isHom (map i) --- Proofs that BijectionIso and vSES both induce isomorphisms --- BijectionIsoToGroupIso : {A : Group {ℓ}} {B : Group {ℓ₂}} → BijectionIso A B → GroupIso A B BijectionIsoToGroupIso {A = A} {B = B} i = grIso where module A = Group A module B = Group B f = fun (map' i) helper : (b : _) → isProp (Σ[ a ∈ ⟨ A ⟩ ] f a ≡ b) helper _ a b = Σ≡Prop (λ _ → isSetCarrier B _ _) (fst a ≡⟨ sym (IsGroup.rid (isGroup A) (fst a)) ⟩ ((fst a) A.+ 0g A) ≡⟨ cong ((fst a) A.+_) (sym (invl A (fst b))) ⟩ ((fst a) A.+ ((A.- fst b) A.+ fst b)) ≡⟨ Group.assoc A _ _ _ ⟩ (((fst a) A.+ (A.- fst b)) A.+ fst b) ≡⟨ cong (A._+ fst b) idHelper ⟩ (0g A A.+ fst b) ≡⟨ IsGroup.lid (isGroup A) (fst b) ⟩ fst b ∎) where idHelper : fst a A.+ (A.- fst b) ≡ 0g A idHelper = inj i _ (isHom (map' i) (fst a) (A.- (fst b)) ∙ (cong (f (fst a) B.+_) (morphMinus A B (map' i) (fst b)) ∙∙ cong (B._+ (B.- f (fst b))) (snd a ∙ sym (snd b)) ∙∙ invr B (f (fst b)))) grIso : GroupIso A B map grIso = map' i inv grIso b = (rec (helper b) (λ a → a) (surj i b)) .fst rightInv grIso b = (rec (helper b) (λ a → a) (surj i b)) .snd leftInv grIso b j = rec (helper (f b)) (λ a → a) (propTruncIsProp (surj i (f b)) ∣ b , refl ∣ j) .fst BijectionIsoToGroupEquiv : {A : Group {ℓ}} {B : Group {ℓ₂}} → BijectionIso A B → GroupEquiv A B BijectionIsoToGroupEquiv i = GrIsoToGrEquiv (BijectionIsoToGroupIso i) vSES→GroupIso : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Group {ℓ}} {B : Group {ℓ'}} (leftGr : Group {ℓ''}) (rightGr : Group {ℓ'''}) → vSES A B leftGr rightGr → GroupIso A B vSES→GroupIso {A = A} lGr rGr vses = BijectionIsoToGroupIso theIso where theIso : BijectionIso _ _ map' theIso = vSES.ϕ vses inj theIso a inker = rec (isSetCarrier A _ _) (λ (a , p) → sym p ∙∙ cong (fun (left vses)) (isTrivialLeft vses a _) ∙∙ morph0→0 lGr A (left vses)) (Ker-ϕ⊂Im-left vses a inker) surj theIso a = Ker-right⊂Im-ϕ vses a (isTrivialRight vses _ _) vSES→GroupEquiv : {A : Group {ℓ}} {B : Group {ℓ₁}} (leftGr : Group {ℓ₂}) (rightGr : Group {ℓ₃}) → vSES A B leftGr rightGr → GroupEquiv A B vSES→GroupEquiv {A = A} lGr rGr vses = GrIsoToGrEquiv (vSES→GroupIso lGr rGr vses) -- The trivial group is a unit. lUnitGroupIso : ∀ {ℓ} {G : Group {ℓ}} → GroupEquiv (dirProd trivialGroup G) G lUnitGroupIso = GrIsoToGrEquiv (iso (grouphom snd (λ a b → refl)) (λ g → tt , g) (λ _ → refl) λ _ → refl) rUnitGroupIso : ∀ {ℓ} {G : Group {ℓ}} → GroupEquiv (dirProd G trivialGroup) G rUnitGroupIso = GrIsoToGrEquiv (iso (grouphom fst λ _ _ → refl) (λ g → g , tt) (λ _ → refl) λ _ → refl) contrGroup≅trivialGroup : {G : Group {ℓ}} → isContr ⟨ G ⟩ → GroupEquiv G trivialGroup GroupEquiv.eq (contrGroup≅trivialGroup contr) = isContr→≃Unit contr GroupEquiv.isHom (contrGroup≅trivialGroup contr) _ _ = refl
{ "alphanum_fraction": 0.5544554455, "avg_line_length": 40.4, "ext": "agda", "hexsha": "0b2f9926d1b82b7faa7b727f9e66c1757b0b90f7", "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": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Algebra.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "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": "knrafto/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Algebra.agda", "max_line_length": 169, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Algebra.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3677, "size": 9090 }
module Relations where -- Imports import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong) open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Nat.Properties using (+-comm) -- Defining relations data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} -------- → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n ------------- → suc m ≤ suc n _ : 2 ≤ 4 _ = s≤s (s≤s z≤n) -- Implicit arguments _ : 2 ≤ 4 _ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2})) _ : 2 ≤ 4 _ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} (z≤n {n = 2})) _ : 2 ≤ 4 _ = s≤s {n = 3} (s≤s {n = 2} z≤n) -- Precedence infix 4 _≤_ -- Inversion inv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n ------------- → m ≤ n inv-s≤s (s≤s m≤n) = m≤n inv-z≤n : ∀ {m : ℕ} → m ≤ zero -------- → m ≡ zero inv-z≤n z≤n = refl -- Reflexivity (反射律) ≤-refl : ∀ {n : ℕ} ----- → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s ≤-refl -- Transitivity (推移律) ≤-trans : ∀ {m n p : ℕ} → m ≤ n → n ≤ p ----- → m ≤ p ≤-trans z≤n _ = z≤n ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p) ≤-trans′ : ∀ (m n p : ℕ) → m ≤ n → n ≤ p ----- → m ≤ p ≤-trans′ zero _ _ z≤n _ = z≤n ≤-trans′ (suc m) (suc n) (suc p) (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans′ m n p m≤n n≤p) -- Anti-symmetry (非対称律) ≤-antisym : ∀ {m n : ℕ} → m ≤ n → n ≤ m ----- → m ≡ n ≤-antisym z≤n z≤n = refl ≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m) -- Total (全順序) data Total (m n : ℕ) : Set where forward : m ≤ n --------- → Total m n flipped : n ≤ m --------- → Total m n data Total′ : ℕ → ℕ → Set where forward′ : ∀ {m n : ℕ} → m ≤ n ---------- → Total′ m n flipped′ : ∀ {m n : ℕ} → n ≤ m ---------- → Total′ m n ≤-total : ∀ (m n : ℕ) → Total m n ≤-total zero n = forward z≤n ≤-total (suc m) zero = flipped z≤n ≤-total (suc m) (suc n) with ≤-total m n ... | forward m≤n = forward (s≤s m≤n) ... | flipped n≤m = flipped (s≤s n≤m) ≤-total′ : ∀ (m n : ℕ) → Total m n ≤-total′ zero n = forward z≤n ≤-total′ (suc m) zero = flipped z≤n ≤-total′ (suc m) (suc n) = helper (≤-total′ m n) where helper : Total m n → Total (suc m) (suc n) helper (forward m≤n) = forward (s≤s m≤n) helper (flipped n≤m) = flipped (s≤s n≤m) ≤-total″ : ∀ (m n : ℕ) → Total m n ≤-total″ m zero = flipped z≤n ≤-total″ zero (suc n) = forward z≤n ≤-total″ (suc m) (suc n) with ≤-total″ m n ... | forward m≤n = forward (s≤s m≤n) ... | flipped n≤m = flipped (s≤s n≤m) -- Monotonicity (単調性) +-monoʳ-≤ : ∀ (n p q : ℕ) → p ≤ q ------------- → n + p ≤ n + q +-monoʳ-≤ zero p q p≤q = p≤q +-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q) +-monoˡ-≤ : ∀ (m n p : ℕ) → m ≤ n ------------- → m + p ≤ n + p +-monoˡ-≤ m n p m≤n rewrite +-comm m p | +-comm n p = +-monoʳ-≤ p m n m≤n +-mono-≤ : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q ------------- → m + p ≤ n + q +-mono-≤ m n p q m≤n p≤q = ≤-trans (+-monoˡ-≤ m n p m≤n) (+-monoʳ-≤ n p q p≤q) -- Strict inequality infix 4 _<_ data _<_ : ℕ → ℕ → Set where z<s : ∀ {n : ℕ} ------------ → zero < suc n s<s : ∀ {m n : ℕ} → m < n ------------- → suc m < suc n -- Even and odd data even : ℕ → Set data odd : ℕ → Set data even where zero : --------- even zero suc : ∀ {n : ℕ} → odd n ------------ → even (suc n) data odd where suc : ∀ {n : ℕ} → even n ----------- → odd (suc n) e+e≡e : ∀ {m n : ℕ} → even m → even n ------------ → even (m + n) o+e≡o : ∀ {m n : ℕ} → odd m → even n ----------- → odd (m + n) e+e≡e zero en = en e+e≡e (suc om) en = suc (o+e≡o om en) o+e≡o (suc em) en = suc (e+e≡e em en)
{ "alphanum_fraction": 0.4016044121, "avg_line_length": 18.4675925926, "ext": "agda", "hexsha": "59f856e1bc7d3033edb89817d3fd6ac3a2e863b0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_path": "part1/relations/Relations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_path": "part1/relations/Relations.agda", "max_line_length": 83, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/relations/Relations.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": 1843, "size": 3989 }
module Data.Nat.Instance where open import Agda.Builtin.Nat open import Class.Equality open import Class.Monoid open import Class.Show open import Data.Char open import Data.List open import Data.Nat renaming (_≟_ to _≟ℕ_; _+_ to _+ℕ_) open import Data.String open import Function private postulate primShowNat : ℕ -> List Char {-# COMPILE GHC primShowNat = show #-} showNat : ℕ -> String showNat = fromList ∘ primShowNat instance Eq-ℕ : Eq ℕ Eq-ℕ = record { _≟_ = _≟ℕ_ } EqB-ℕ : EqB ℕ EqB-ℕ = record { _≣_ = Agda.Builtin.Nat._==_ } ℕ-Monoid : Monoid ℕ ℕ-Monoid = record { mzero = zero ; _+_ = _+ℕ_ } Show-ℕ : Show ℕ Show-ℕ = record { show = showNat }
{ "alphanum_fraction": 0.6734397678, "avg_line_length": 19.6857142857, "ext": "agda", "hexsha": "7409f4824e897cc42ebc9756dee380dacff3a875", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Data/Nat/Instance.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Data/Nat/Instance.agda", "max_line_length": 56, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Data/Nat/Instance.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 245, "size": 689 }
open import Data.Product using ( _×_ ; _,_ ; swap ) open import Data.Sum using ( inj₁ ; inj₂ ) open import Relation.Nullary using ( ¬_ ; yes ; no ) open import Relation.Unary using ( _∈_ ) open import Web.Semantic.DL.ABox using ( ABox ; ε ; _,_ ; _∼_ ; _∈₁_ ; _∈₂_ ) open import Web.Semantic.DL.ABox.Interp using ( Interp ; ⌊_⌋ ; ind ; ind⁻¹ ; Surjective ; surj✓ ) open import Web.Semantic.DL.ABox.Interp.Morphism using ( _≲_ ; _≃_ ; _,_ ; ≲⌊_⌋ ; ≲-resp-ind ) open import Web.Semantic.DL.ABox.Interp.Meet using ( meet ; meet-lb ; meet-glb ; meet-uniq ; meet-surj ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ) open import Web.Semantic.DL.Concept using ( Concept ; ⟨_⟩ ; ¬⟨_⟩ ; ⊤ ; ⊥ ; _⊔_ ; _⊓_ ; ∀[_]_ ; ∃⟨_⟩_ ; ≤1 ; >1 ; neg ) open import Web.Semantic.DL.Concept.Model using ( _⟦_⟧₁ ; neg-sound ; neg-complete ) open import Web.Semantic.DL.Integrity.Closed using ( Mediated₀ ; Initial₀ ; sur_⊨₀_ ; _,_ ) open import Web.Semantic.DL.Integrity.Closed.Alternate using ( _⊫_∼_ ; _⊫_∈₁_ ; _⊫_∈₂_ ; _⊫t_ ; _⊫a_ ; _⊫k_ ; eq ; rel ; rev ; +atom ; -atom ; top ; inj₁ ; inj₂ ; all ; ex ; uniq ; ¬uniq ; cn ; rl ; dis ; ref ; irr ; tra ; ε ; _,_ ) open import Web.Semantic.DL.KB using ( KB ; tbox ; abox ) open import Web.Semantic.DL.KB.Model using ( _⊨_ ; Interps ; ⊨-resp-≃ ) open import Web.Semantic.DL.Role using ( Role ; ⟨_⟩ ; ⟨_⟩⁻¹ ) open import Web.Semantic.DL.Role.Model using ( _⟦_⟧₂ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ; ε ; _,_ ; _⊑₁_ ; _⊑₂_ ; Dis ; Ref ; Irr ; Tra ) open import Web.Semantic.DL.TBox.Interp using ( _⊨_≈_ ; ≈-sym ; ≈-trans ) open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-resp-≈ ; iso ) open import Web.Semantic.DL.TBox.Model using ( _⊨t_ ) open import Web.Semantic.Util using ( ExclMiddle ; ExclMiddle₁ ; smaller-excl-middle ; is! ; is✓ ; tt ; elim ) module Web.Semantic.DL.Integrity.Closed.Properties (excl-middle₁ : ExclMiddle₁) {Σ : Signature} {X : Set} where -- The two definitions of closed-world integrity coincide for surjective interpretations. -- Note that this requires excluded middle, as the alternate definition assumes a classical logic, -- for example interpreting C ⊑ D as (¬ C ⊔ D) being a tautology. min : KB Σ X → Interp Σ X min K = meet excl-middle₁ (Interps K) excl-middle : ExclMiddle excl-middle = smaller-excl-middle excl-middle₁ sound∼ : ∀ K x y → (K ⊫ x ∼ y) → (⌊ min K ⌋ ⊨ x ≈ y) sound∼ K x y (eq K⊫x∼y) = is! K⊫x∼y complete∼ : ∀ K x y → (⌊ min K ⌋ ⊨ x ≈ y) → (K ⊫ x ∼ y) complete∼ K x y x≈y = eq (is✓ x≈y) sound₂ : ∀ K R xy → (K ⊫ xy ∈₂ R) → (xy ∈ ⌊ min K ⌋ ⟦ R ⟧₂) sound₂ K ⟨ r ⟩ (x , y) (rel K⊫xy∈r) = is! K⊫xy∈r sound₂ K ⟨ r ⟩⁻¹ (x , y) (rev K⊫yx∈r) = is! K⊫yx∈r complete₂ : ∀ K R xy → (xy ∈ ⌊ min K ⌋ ⟦ R ⟧₂) → (K ⊫ xy ∈₂ R) complete₂ K ⟨ r ⟩ (x , y) xy∈⟦r⟧ = rel (is✓ xy∈⟦r⟧) complete₂ K ⟨ r ⟩⁻¹ (x , y) yx∈⟦r⟧ = rev (is✓ yx∈⟦r⟧) sound₁ : ∀ K C x → (K ⊫ x ∈₁ C) → (x ∈ ⌊ min K ⌋ ⟦ C ⟧₁) sound₁ K ⟨ c ⟩ x (+atom K⊨x∈c) = is! K⊨x∈c sound₁ K ¬⟨ c ⟩ x (-atom K⊭x∈c) = λ x∈⟦c⟧ → K⊭x∈c (is✓ x∈⟦c⟧) sound₁ K ⊤ x top = tt sound₁ K ⊥ x () sound₁ K (C ⊓ D) x (K⊫x∈C , K⊫x∈D) = (sound₁ K C x K⊫x∈C , sound₁ K D x K⊫x∈D) sound₁ K (C ⊔ D) x (inj₁ K⊫x∈C) = inj₁ (sound₁ K C x K⊫x∈C) sound₁ K (C ⊔ D) x (inj₂ K⊫x∈D) = inj₂ (sound₁ K D x K⊫x∈D) sound₁ K (∀[ R ] C) x (all K⊫x∈∀RC) = λ y xy∈⟦R⟧ → sound₁ K C y (K⊫x∈∀RC y (complete₂ K R _ xy∈⟦R⟧)) sound₁ K (∃⟨ R ⟩ C) x (ex y K⊫xy∈R K⊫y∈C) = (y , sound₂ K R _ K⊫xy∈R , sound₁ K C y K⊫y∈C) sound₁ K (≤1 R) x (uniq K⊫x∈≤1R) = λ y z xy∈⟦R⟧ xz∈⟦R⟧ → sound∼ K y z (K⊫x∈≤1R y z (complete₂ K R _ xy∈⟦R⟧) (complete₂ K R _ xz∈⟦R⟧)) sound₁ K (>1 R) x (¬uniq y z K⊫xy∈R K⊫xz∈R K⊯y∼z) = ( y , z , sound₂ K R _ K⊫xy∈R , sound₂ K R _ K⊫xz∈R , λ y≈z → K⊯y∼z (complete∼ K y z y≈z) ) complete₁ : ∀ K C x → (x ∈ ⌊ min K ⌋ ⟦ C ⟧₁) → (K ⊫ x ∈₁ C) complete₁ K ⟨ c ⟩ x x∈⟦c⟧ = +atom (is✓ x∈⟦c⟧) complete₁ K ¬⟨ c ⟩ x x∉⟦c⟧ = -atom (λ K⊫x∈c → x∉⟦c⟧ (is! K⊫x∈c)) complete₁ K ⊤ x x∈⟦C⟧ = top complete₁ K ⊥ x () complete₁ K (C ⊓ D) x (x∈⟦C⟧ , x∈⟦D⟧) = (complete₁ K C x x∈⟦C⟧ , complete₁ K D x x∈⟦D⟧) complete₁ K (C ⊔ D) x (inj₁ x∈⟦C⟧) = inj₁ (complete₁ K C x x∈⟦C⟧) complete₁ K (C ⊔ D) x (inj₂ x∈⟦D⟧) = inj₂ (complete₁ K D x x∈⟦D⟧) complete₁ K (∀[ R ] C) x x∈⟦∀RC⟧ = all (λ y K⊫xy∈R → complete₁ K C y (x∈⟦∀RC⟧ y (sound₂ K R _ K⊫xy∈R))) complete₁ K (∃⟨ R ⟩ C) x (y , xy∈⟦R⟧ , y∈⟦C⟧) = ex y (complete₂ K R (x , y) xy∈⟦R⟧) (complete₁ K C y y∈⟦C⟧) complete₁ K (≤1 R) x x∈⟦≤1R⟧ = uniq (λ y z K⊫xy∈R K⊫xz∈R → complete∼ K y z (x∈⟦≤1R⟧ y z (sound₂ K R _ K⊫xy∈R) (sound₂ K R _ K⊫xz∈R))) complete₁ K (>1 R) x (y , z , xy∈⟦R⟧ , xz∈⟦R⟧ , y≉z) = ¬uniq y z (complete₂ K R _ xy∈⟦R⟧) (complete₂ K R _ xz∈⟦R⟧) (λ K⊫y∼z → y≉z (sound∼ K y z K⊫y∼z)) ⊫-impl-min⊨ : ∀ K L → (K ⊫k L) → (min K ⊨ L) ⊫-impl-min⊨ K L (K⊫T , K⊫A) = ( J⊨T K⊫T , J⊨A K⊫A ) where J : Interp Σ X J = min K J⊨T : ∀ {T} → (K ⊫t T) → (⌊ J ⌋ ⊨t T) J⊨T ε = tt J⊨T (K⊫T , K⊫U) = (J⊨T K⊫T , J⊨T K⊫U) J⊨T (rl Q R K⊫Q⊑R) = λ {xy} xy∈⟦Q⟧ → sound₂ K R xy (K⊫Q⊑R xy (complete₂ K Q xy xy∈⟦Q⟧)) J⊨T (cn C D K⊫C⊑D) = λ {x} → lemma x (K⊫C⊑D x) where lemma : ∀ x → (K ⊫ x ∈₁ (neg C ⊔ D)) → (x ∈ ⌊ J ⌋ ⟦ C ⟧₁) → (x ∈ ⌊ J ⌋ ⟦ D ⟧₁) lemma x (inj₁ K⊫x∈¬C) x∈⟦C⟧ = elim (neg-sound ⌊ J ⌋ {x} C (sound₁ K (neg C) x K⊫x∈¬C) x∈⟦C⟧) lemma x (inj₂ K⊫x∈D) x∈⟦C⟧ = sound₁ K D x K⊫x∈D J⊨T (dis Q R K⊫DisQR) = λ {xy} xy∈⟦Q⟧ xy∈⟦R⟧ → K⊫DisQR xy (complete₂ K Q xy xy∈⟦Q⟧) (complete₂ K R xy xy∈⟦R⟧) J⊨T (ref R K⊫RefR) = λ x → sound₂ K R (x , x) (K⊫RefR x) J⊨T (irr R K⊫IrrR) = λ x xx∈⟦R⟧ → K⊫IrrR x (complete₂ K R (x , x) xx∈⟦R⟧) J⊨T (tra R K⊫TraR) = λ {x} {y} {z} xy∈⟦R⟧ yz∈⟦R⟧ → sound₂ K R (x , z) (K⊫TraR x y z (complete₂ K R (x , y) xy∈⟦R⟧) (complete₂ K R (y , z) yz∈⟦R⟧)) J⊨A : ∀ {A} → (K ⊫a A) → (J ⊨a A) J⊨A ε = tt J⊨A (K⊫A , K⊫B) = (J⊨A K⊫A , J⊨A K⊫B) J⊨A (eq x y K⊫x∼y) = sound∼ K x y K⊫x∼y J⊨A (rl (x , y) r K⊫xy∈r) = sound₂ K ⟨ r ⟩ (x , y) K⊫xy∈r J⊨A (cn x c K⊫x∈c) = sound₁ K ⟨ c ⟩ x K⊫x∈c min⊨-impl-⊫ : ∀ K L → (min K ⊨ L) → (K ⊫k L) min⊨-impl-⊫ K L (J⊨T , J⊨A) = ( K⊫T (tbox L) J⊨T , K⊫A (abox L) J⊨A ) where J : Interp Σ X J = min K K⊫T : ∀ T → (⌊ J ⌋ ⊨t T) → (K ⊫t T) K⊫T ε J⊨ε = ε K⊫T (T , U) (J⊨T , J⊨U) = (K⊫T T J⊨T , K⊫T U J⊨U) K⊫T (Q ⊑₂ R) J⊨Q⊑R = rl Q R (λ xy K⊫xy∈Q → complete₂ K R xy (J⊨Q⊑R (sound₂ K Q xy K⊫xy∈Q))) K⊫T (C ⊑₁ D) J⊨C⊑D = cn C D lemma where lemma : ∀ x → (K ⊫ x ∈₁ neg C ⊔ D) lemma x with excl-middle (x ∈ ⌊ J ⌋ ⟦ C ⟧₁) lemma x | yes x∈⟦C⟧ = inj₂ (complete₁ K D x (J⊨C⊑D x∈⟦C⟧)) lemma x | no x∉⟦C⟧ = inj₁ (complete₁ K (neg C) x (neg-complete excl-middle ⌊ J ⌋ C x∉⟦C⟧)) K⊫T (Dis Q R) J⊨DisQR = dis Q R (λ xy K⊫xy∈Q K⊫xy∈R → J⊨DisQR (sound₂ K Q xy K⊫xy∈Q) (sound₂ K R xy K⊫xy∈R)) K⊫T (Ref R) J⊨RefR = ref R (λ x → complete₂ K R (x , x) (J⊨RefR x)) K⊫T (Irr R) J⊨IrrR = irr R (λ x K⊫xx∈R → J⊨IrrR x (sound₂ K R (x , x) K⊫xx∈R)) K⊫T (Tra R) J⊨TrR = tra R (λ x y z K⊫xy∈R K⊫yz∈R → complete₂ K R (x , z) (J⊨TrR (sound₂ K R (x , y) K⊫xy∈R) (sound₂ K R (y , z) K⊫yz∈R))) K⊫A : ∀ A → (J ⊨a A) → (K ⊫a A) K⊫A ε J⊨ε = ε K⊫A (A , B) (J⊨A , J⊨B) = (K⊫A A J⊨A , K⊫A B J⊨B) K⊫A (x ∼ y) x≈y = eq x y (complete∼ K x y x≈y) K⊫A (x ∈₁ c) x∈⟦c⟧ = cn x c (complete₁ K ⟨ c ⟩ x x∈⟦c⟧) K⊫A ((x , y) ∈₂ r) xy∈⟦r⟧ = rl (x , y) r (complete₂ K ⟨ r ⟩ (x , y) xy∈⟦r⟧) min-med : ∀ (K : KB Σ X) J → (J ⊨ K) → Mediated₀ (min K) J min-med K J J⊨K = (meet-lb excl-middle₁ (Interps K) J J⊨K , meet-uniq excl-middle₁ (Interps K) J J⊨K) min-init : ∀ (K : KB Σ X) → (K ⊫k K) → (min K ∈ Initial₀ K) min-init K K⊫K = ( ⊫-impl-min⊨ K K K⊫K , min-med K) min-uniq : ∀ (I : Interp Σ X) (K : KB Σ X) → (I ∈ Surjective) → (I ∈ Initial₀ K) → (I ≃ min K) min-uniq I K I∈Surj (I⊨K , I-med) = ( iso ≲⌊ meet-glb excl-middle₁ (Interps K) I I∈Surj lemma₁ ⌋ ≲⌊ meet-lb excl-middle₁ (Interps K) I I⊨K ⌋ (λ x → ≈-sym ⌊ I ⌋ (surj✓ I∈Surj x)) (λ x → is! (lemma₂ x)) , λ x → is! (lemma₂ x)) where lemma₁ : ∀ J J⊨K → I ≲ J lemma₁ J J⊨K with I-med J J⊨K lemma₁ J J⊨K | (I≲J , I≲J-uniq) = I≲J lemma₂ : ∀ x J J⊨K → ⌊ J ⌋ ⊨ ind J (ind⁻¹ I∈Surj (ind I x)) ≈ ind J x lemma₂ x J J⊨K = ≈-trans ⌊ J ⌋ (≈-sym ⌊ J ⌋ (≲-resp-ind (lemma₁ J J⊨K) (ind⁻¹ I∈Surj (ind I x)))) (≈-trans ⌊ J ⌋ (≲-resp-≈ ≲⌊ lemma₁ J J⊨K ⌋ (≈-sym ⌊ I ⌋ (surj✓ I∈Surj (ind I x)))) (≲-resp-ind (lemma₁ J J⊨K) x)) ⊫-impl-⊨₀ : ∀ (KB₁ KB₂ : KB Σ X) → (KB₁ ⊫k KB₁) → (KB₁ ⊫k KB₂) → (sur KB₁ ⊨₀ KB₂) ⊫-impl-⊨₀ KB₁ KB₂ KB₁⊫KB₁ KB₁⊫KB₂ = ( min KB₁ , meet-surj excl-middle₁ (Interps KB₁) , min-init KB₁ KB₁⊫KB₁ , ⊫-impl-min⊨ KB₁ KB₂ KB₁⊫KB₂ ) ⊨₀-impl-⊫₁ : ∀ (KB₁ KB₂ : KB Σ X) → (sur KB₁ ⊨₀ KB₂) → (KB₁ ⊫k KB₁) ⊨₀-impl-⊫₁ KB₁ KB₂ (I , I∈Surj , (I⊨KB₁ , I-med) , I⊨KB₂) = min⊨-impl-⊫ KB₁ KB₁ (⊨-resp-≃ (min-uniq I KB₁ I∈Surj (I⊨KB₁ , I-med)) KB₁ I⊨KB₁) ⊨₀-impl-⊫₂ : ∀ (KB₁ KB₂ : KB Σ X) → (sur KB₁ ⊨₀ KB₂) → (KB₁ ⊫k KB₂) ⊨₀-impl-⊫₂ KB₁ KB₂ (I , I∈Surj , I-init , I⊨KB₂) = min⊨-impl-⊫ KB₁ KB₂ (⊨-resp-≃ (min-uniq I KB₁ I∈Surj I-init) KB₂ I⊨KB₂)
{ "alphanum_fraction": 0.5222818351, "avg_line_length": 40.4115044248, "ext": "agda", "hexsha": "27ef278b27f0557c614cb7bffde3f002be5cc325", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Integrity/Closed/Properties.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Integrity/Closed/Properties.agda", "max_line_length": 101, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Integrity/Closed/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 5345, "size": 9133 }
{-# OPTIONS --without-K --safe #-} module Fragment.Examples.CSemigroup.Types where
{ "alphanum_fraction": 0.7261904762, "avg_line_length": 21, "ext": "agda", "hexsha": "4256f0b4261205b6a6a70aa56be28837fa24b8e9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Examples/CSemigroup/Types.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Examples/CSemigroup/Types.agda", "max_line_length": 47, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Examples/CSemigroup/Types.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 18, "size": 84 }
-- This document shows how to encode GADTs using `IFix`. {-# OPTIONS --type-in-type #-} module ScottVec where -- The kind of church-encoded type-level natural numbers. Nat = (Set -> Set) -> Set -> Set zero : Nat zero = λ f z -> z suc : Nat -> Nat suc = λ n f z -> f (n f z) plus : Nat -> Nat -> Nat plus = λ n m f z -> n f (m f z) -- Our old friend. {-# NO_POSITIVITY_CHECK #-} record IFix {I : Set} (F : (I -> Set) -> I -> Set) (i : I) : Set where constructor wrap field unwrap : F (IFix F) i open IFix -- Scott-encoded vectors (a vector is a list with statically-known length). -- As usually the pattern vector of a Scott-encoded data type encodes pattern-matching. VecF : Set -> (Nat -> Set) -> Nat -> Set VecF = λ A Rec n -> (R : Nat -> Set) -- The type of the result depends on the vector's length. -> (∀ p -> A -> Rec p -> R (suc p)) -- The encoded `cons` constructor. -> R zero -- The encoded `nil` constructor. -> R n Vec : Set -> Nat -> Set Vec = λ (A : Set) -> IFix (VecF A) nil : ∀ A -> Vec A zero nil = λ A -> wrap λ R f z -> z cons : ∀ A n -> A -> Vec A n -> Vec A (suc n) cons = λ A n x xs -> wrap λ R f z -> f n x xs open import Data.Empty open import Data.Unit.Base open import Data.Nat.Base using (ℕ; _+_) -- Type-safe `head`. head : ∀ A n -> Vec A (suc n) -> A head A n xs = unwrap xs (λ p -> p (λ _ -> A) ⊤) -- `p (λ _ -> A) ⊤` returns `A` when `p` is `suc p'` for some `p'` -- and `⊤` when `p` is `zero` (λ p x xs' -> x) -- In the `cons` case `suc p (λ _ -> A) ⊤` reduces to `A`, -- hence we return the list element of type `A`. tt -- In the `nil` case `zero (λ _ -> A) ⊤` reduces to `⊤`, -- hence we return the only value of that type. {- Note [Type-safe `tail`] It's not obvious if type-safe `tail` can be implemented with this setup. This is because even though `Vec` is Scott-encoded, the type-level natural are Church-encoded (obviously we could have Scott-encoded type-level naturals in Agda just as well, but not in Zerepoch Core), which makes `pred` hard, which makes `tail` non-trivial. I did try using Scott-encoded naturals in Agda, that makes `tail` even more straightforward than `head`: tail : ∀ A n -> Vec A (suc n) -> Vec A n tail A n xs = unwrap xs (λ p -> ((B : ℕ -> Set) -> B (pred p) -> B n) -> Vec A n) (λ p x xs' coe -> coe (Vec A) xs') (λ coe -> coe (Vec A) (nil A)) (λ B x -> x) -} -- Here we pattern-match on `xs` and if it's non-empty, i.e. of type `Vec ℕ (suc p)` for some `p`, -- then we also get access to a coercion function that allows us to coerce the second list from -- `Vec ℕ n` to the same `Vec ℕ (suc p)` and call the type-safe `head` over it. -- Note that we don't even need to encode the `n ~ suc p` and `n ~ zero` equality constraints in -- the definition of `vecF` and can recover coercions along those constraints by adding the -- `Vec ℕ n -> Vec ℕ p` argument to the motive. sumHeadsOr0 : ∀ n -> Vec ℕ n -> Vec ℕ n -> ℕ sumHeadsOr0 n xs ys = unwrap xs (λ p -> (Vec ℕ n -> Vec ℕ p) -> ℕ) (λ p i _ coe -> i + head ℕ p (coe ys)) (λ _ -> 0) (λ x -> x)
{ "alphanum_fraction": 0.5648484848, "avg_line_length": 34.7368421053, "ext": "agda", "hexsha": "126624536733f1411c6ad87f0e6cdb262da08472", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-21T16:38:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-13T21:25:19.000Z", "max_forks_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "Quantum-One-DLT/zerepoch", "max_forks_repo_path": "notes/fomega/gadts/ScottVec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177", "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": "Quantum-One-DLT/zerepoch", "max_issues_repo_path": "notes/fomega/gadts/ScottVec.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "Quantum-One-DLT/zerepoch", "max_stars_repo_path": "notes/fomega/gadts/ScottVec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1037, "size": 3300 }
module EqTest where import Common.Level open import Common.Maybe open import Common.Equality data ℕ : Set where zero : ℕ suc : ℕ -> ℕ _≟_ : (x y : ℕ) -> Maybe (x ≡ y) suc m ≟ suc n with m ≟ n suc .n ≟ suc n | just refl = just refl suc m ≟ suc n | nothing = nothing zero ≟ suc _ = nothing suc m ≟ zero = nothing zero ≟ zero = just refl
{ "alphanum_fraction": 0.6094182825, "avg_line_length": 19, "ext": "agda", "hexsha": "451aa2d77ae3f240e2c96de6bd1bccd0f962cfb3", "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/EqTest.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/EqTest.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/EqTest.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": 133, "size": 361 }
-- Andreas, 2012-09-26 disable projection-likeness for recursive functions -- {-# OPTIONS -v tc.proj.like:100 #-} module ProjectionLikeRecursive where open import Common.Prelude open import Common.Equality if_then_else_ : {A : Set} → Bool → A → A → A if true then t else e = t if false then t else e = e infixr 5 _∷_ _∷′_ data Vec (n : Nat) : Set where [] : {p : n ≡ 0} → Vec n _∷_ : {m : Nat}{p : n ≡ suc m} → Nat → Vec m → Vec n null : {n : Nat} → Vec n → Bool null [] = true null xs = false -- last is considered projection-like last : (n : Nat) → Vec n → Nat -- last 0 xs = zero --restoring this line removes proj.-likeness and passes the file last n [] = zero last n (x ∷ xs) = if (null xs) then x else last _ xs -- breaks if projection-like translation is not removing the _ in the rec. call []′ : Vec zero []′ = [] {p = refl} _∷′_ : {n : Nat} → Nat → Vec n → Vec (suc n) x ∷′ xs = _∷_ {p = refl} x xs three = last 3 (1 ∷′ 2 ∷′ 3 ∷′ []′) test : three ≡ 3 test = refl -- Error: Incomplete pattern matching -- when checking that the expression refl has type three ≡ 3
{ "alphanum_fraction": 0.625, "avg_line_length": 26.5365853659, "ext": "agda", "hexsha": "4fe1ab93f732bba2cb3a427d1115468c98f61c07", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/ProjectionLikeRecursive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/ProjectionLikeRecursive.agda", "max_line_length": 85, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/ProjectionLikeRecursive.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 381, "size": 1088 }
module HasNegation where record HasNegation (A : Set) : Set where field ~ : A → A open HasNegation ⦃ … ⦄ public {-# DISPLAY HasNegation.~ _ = ~ #-}
{ "alphanum_fraction": 0.6163522013, "avg_line_length": 13.25, "ext": "agda", "hexsha": "b12f6f3ee7f2c0923e9df37e836388d211adf11e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/HasNegation.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/HasNegation.agda", "max_line_length": 35, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/HasNegation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 55, "size": 159 }
{- Stream transducers have been described in: N. Ghani, P. Hancock, and D. Pattinson, Continuous functions on final coalgebras. In Proc. CMCS 2006, Electr. Notes in Theoret. Comp. Sci., 2006. They have been modelled by mixed equi-(co)inductive sized types in A. Abel, Mixed Inductive/Coinductive Types and Strong Normalization. In APLAS 2007, LNCS 4807. Here we model them by mutual data/codata and mixed recursion/corecursion. Cf. examples/Termination/StreamProc.agda -} module StreamEating where open import Common.Coinduction -- Infinite streams. data Stream (A : Set) : Set where _∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A -- A stream processor SP A B consumes elements of A and produces -- elements of B. It can only consume a finite number of A's before -- producing a B. data SP (A B : Set) : Set where get : (f : A → SP A B) → SP A B put : (b : B) (sp : ∞ (SP A B)) → SP A B -- eat is defined by (outer) corecursion into Stream B -- and an inner recursion on SP A B eat : ∀ {A B} → SP A B → Stream A → Stream B eat (get f) (a ∷ as) = eat (f a) (♭ as) eat (put b sp) as = b ∷ (♯ eat (♭ sp) as) _∘_ : ∀ {A B C} → SP B C → SP A B → SP A C get f₁ ∘ put x sp₂ = f₁ x ∘ ♭ sp₂ put x sp₁ ∘ sp₂ = put x (♯ (♭ sp₁ ∘ sp₂)) sp₁ ∘ get f₂ = get (λ x → sp₁ ∘ f₂ x)
{ "alphanum_fraction": 0.6327769347, "avg_line_length": 29.2888888889, "ext": "agda", "hexsha": "f480f132c0244484c650ee6aa1666fc8a8c25dac", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "examples/Termination/StreamEating.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "examples/Termination/StreamEating.agda", "max_line_length": 73, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "examples/Termination/StreamEating.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": 466, "size": 1318 }
module Properties where import Properties.Contradiction import Properties.Dec import Properties.Equality import Properties.Step import Properties.Remember
{ "alphanum_fraction": 0.8782051282, "avg_line_length": 19.5, "ext": "agda", "hexsha": "1a6f92fab3c8344d89fdc6e0742fb384491a2c97", "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/Properties.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/Properties.agda", "max_line_length": 31, "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/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 28, "size": 156 }
{-# OPTIONS --enable-prop #-} data Squash {ℓ} (A : Set ℓ) : Prop ℓ where squash : A → Squash A squash-elim : ∀ {ℓ₁ ℓ₂} (A : Set ℓ₁) (P : Prop ℓ₂) → (A → P) → Squash A → P squash-elim A P f (squash x) = f x
{ "alphanum_fraction": 0.5225225225, "avg_line_length": 24.6666666667, "ext": "agda", "hexsha": "b9bd4d8e3586a17d2462245a2df6235257d8e005", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/Succeed/PropSquash.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/eagda", "max_issues_repo_path": "test/Succeed/PropSquash.agda", "max_line_length": 50, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/Succeed/PropSquash.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 95, "size": 222 }
-- Some proposition constructors. {-# OPTIONS --without-K --safe #-} module Tools.Nullary where open import Tools.Empty -- Negation. infix 3 ¬_ ¬_ : Set → Set ¬ P = P → ⊥ -- Decidable propositions. data Dec (P : Set) : Set where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P -- If A and B are logically equivalent, then so are Dec A and Dec B. map : ∀ {A B} → (A → B) → (B → A) → Dec A → Dec B map f g (yes p) = yes (f p) map f g (no ¬p) = no (λ x → ¬p (g x))
{ "alphanum_fraction": 0.5543933054, "avg_line_length": 17.7037037037, "ext": "agda", "hexsha": "14542fe88b309ceffe56ed6962ab2373924af567", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Tools/Nullary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Tools/Nullary.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Tools/Nullary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 170, "size": 478 }
------------------------------------------------------------------------ -- Finite maps with indexed keys and values, based on AVL trees ------------------------------------------------------------------------ open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Data.Product as Prod hiding (map) module Data.AVL.IndexedMap {Index : Set} {Key : Index → Set} {_≈_ _<_ : Rel (∃ Key)} (isOrderedKeySet : IsStrictTotalOrder _≈_ _<_) -- Equal keys must have equal indices. (indicesEqual : _≈_ =[ proj₁ ]⇒ _≡_) (Value : Index → Set) where import Data.AVL open import Data.Function open import Data.Maybe as Maybe open import Data.Bool open import Data.List open import Category.Functor open RawFunctor Maybe.functor -- Key/value pairs. KV : Set KV = ∃ λ i → Key i × Value i -- Conversions. private fromKV : KV → Σ (∃ Key) λ ik → Value (proj₁ ik) fromKV (i , k , v) = ((i , k) , v) toKV : Σ (∃ Key) (λ ik → Value (proj₁ ik)) → KV toKV ((i , k) , v) = (i , k , v) private Order : StrictTotalOrder Order = record { isStrictTotalOrder = isOrderedKeySet } -- The map type. private open module AVL = Data.AVL Order (λ ik → Value (proj₁ ik)) public using () renaming (Tree to Map) -- Repackaged functions. empty : Map empty = AVL.empty singleton : ∀ {i} → Key i → Value i → Map singleton k v = AVL.singleton (, k) v insert : ∀ {i} → Key i → Value i → Map → Map insert k v = AVL.insert (, k) v delete : ∀ {i} → Key i → Map → Map delete k = AVL.delete (, k) lookup : ∀ {i} → Key i → Map → Maybe (Value i) lookup k m with AVL.lookup (_ , k) m ... | nothing = nothing ... | just ((i′ , k′) , v′ , eq) with indicesEqual eq ... | refl = just v′ _∈?_ : ∀ {i} → Key i → Map → Bool _∈?_ k = AVL._∈?_ (, k) headTail : Map → Maybe (KV × Map) headTail m = Prod.map toKV id <$> AVL.headTail m initLast : Map → Maybe (Map × KV) initLast m = Prod.map id toKV <$> AVL.initLast m fromList : List KV → Map fromList = AVL.fromList ∘ map fromKV toList : Map → List KV toList = map toKV ∘ AVL.toList
{ "alphanum_fraction": 0.5745283019, "avg_line_length": 24.9411764706, "ext": "agda", "hexsha": "6ed60a2a826ebb9996be33da61ca2a0a4efdad2c", "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/AVL/IndexedMap.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/AVL/IndexedMap.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/AVL/IndexedMap.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": 629, "size": 2120 }
------------------------------------------------------------------------ -- A small prelude ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Note that parts of Agda's standard library make use of the K rule. module Prelude where ------------------------------------------------------------------------ -- Universes -- Basic type universes and universe levels. open import Agda.Primitive public renaming (Set to Type) using (Prop; Level; _⊔_; lzero; lsuc) private variable a b c ℓ p : Level @0 A A₁ A₂ B B₁ B₂ C D Whatever : Type a @0 P Q R : A → Type p -- Lifting. record ↑ ℓ (A : Type a) : Type (a ⊔ ℓ) where constructor lift field lower : A open ↑ public ------------------------------------------------------------------------ -- Strings open import Agda.Builtin.String public using (String) ------------------------------------------------------------------------ -- The unit type -- A variant of the unit type with η-equality. open import Agda.Builtin.Unit public using (⊤; tt) -- A variant without η-equality. data Unit : Type where unit : Unit -- Block s is used to block unfolding (for performance reasons). The -- string can be used to indicate what it is that is blocked. Block : String → Type Block _ = Unit pattern ⊠ = unit -- A function that can be used to locally block something. block : (Unit → A) → A block f = f ⊠ -- A function that can be used to unblock something. unblock : (b : Unit) (@0 P : Unit → Type p) → P ⊠ → P b unblock ⊠ _ p = p ------------------------------------------------------------------------ -- The empty type data ⊥ {ℓ} : Type ℓ where ⊥-elim : ⊥ {ℓ = ℓ} → Whatever ⊥-elim () -- A version of the empty type that is not universe-polymorphic. ⊥₀ : Type ⊥₀ = ⊥ -- Negation. infix 3 ¬_ ¬_ : Type ℓ → Type ℓ ¬ P = P → ⊥₀ ------------------------------------------------------------------------ -- Natural numbers open import Agda.Builtin.Nat public using (zero; suc; _+_; _*_) renaming (Nat to ℕ; _-_ to _∸_) -- Dependent eliminator. ℕ-rec : P 0 → (∀ n → P n → P (suc n)) → ∀ n → P n ℕ-rec z s zero = z ℕ-rec z s (suc n) = s n (ℕ-rec z s n) -- A non-recursive variant of ℕ-rec. ℕ-case : P 0 → (∀ n → P (suc n)) → ∀ n → P n ℕ-case z s = ℕ-rec z (λ n _ → s n) -- Exponentiation. infixr 8 _^_ _^_ : ℕ → ℕ → ℕ m ^ zero = 1 m ^ suc n = m * m ^ n -- Factorial. infix 9 _! _! : ℕ → ℕ zero ! = 1 suc n ! = suc n * n ! -- Translation from natural numbers to levels. # : ℕ → Level # zero = lzero # (suc n) = lsuc (# n) ------------------------------------------------------------------------ -- Combinators defined using only abstraction and application infixr 9 _∘_ infixl 1 _on_ infixr 0 _$_ -- The identity function. id : A → A id x = x -- Composition. _∘_ : {@0 B : A → Type b} {@0 C : {x : A} → B x → Type c} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) f ∘ g = λ x → f (g x) -- "Equational" reasoning combinators. infix -1 finally-→ infixr -2 step-→ -- For an explanation of why step-⇔ is defined in this way, see -- Equality.step-≡. step-→ : (@0 A : Type a) → (B → C) → (A → B) → A → C step-→ _ f g = f ∘ g syntax step-→ A B→C A→B = A →⟨ A→B ⟩ B→C finally-→ : (@0 A : Type a) (@0 B : Type b) → (A → B) → A → B finally-→ _ _ A→B = A→B syntax finally-→ A B A→B = A →⟨ A→B ⟩□ B □ -- Application. _$_ : {@0 B : A → Type b} → ((x : A) → B x) → ((x : A) → B x) f $ x = f x -- Constant functions. const : A → (B → A) const x = λ _ → x {-# DISPLAY const x y = x #-} -- Flips the first two arguments. flip : {@0 C : A → B → Type c} → ((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y) flip f = λ x y → f y x -- Applies the unary function to each argument and combines the -- results using the binary function. _on_ : {@0 C : B → B → Type c} → ((x y : B) → C x y) → (f : A → B) → ((x y : A) → C (f x) (f y)) _*_ on f = λ x y → f x * f y -- A term's type. Type-of : {A : Type a} → A → Type a Type-of {A = A} _ = A -- Type signatures. infix 0 type-signature type-signature : (@0 A : Type a) → A → A type-signature _ a = a syntax type-signature A a = a ⦂ A -- The it function can be used to instantiate an argument by using -- instance search. it : ⦃ _ : A ⦄ → A it ⦃ x ⦄ = x -- Case expressions (to be used with pattern-matching lambdas). infix 0 case_return_of_ case_of_ case_return_of_ : (x : A) (@0 B : A → Type b) → ((x : A) → B x) → B x case x return B of f = f x case_of_ : A → (A → B) → B case x of f = case x return _ of f ------------------------------------------------------------------------ -- Σ-types infixr 4 _,′_ infixr 2 _×_ open import Agda.Builtin.Sigma public using (Σ; _,_) hiding (module Σ) renaming (fst to proj₁; snd to proj₂) module Σ where open Agda.Builtin.Sigma.Σ public using () renaming (fst to proj₁; snd to proj₂) -- Variants of the projections with erased type arguments. proj₁₀ : {@0 B : A → Type b} → Σ A B → A proj₁₀ (x , y) = x proj₂₀ : {@0 B : A → Type b} (p : Σ A B) → B (proj₁ p) proj₂₀ (x , y) = y open Σ public using (proj₁₀; proj₂₀) -- A variant where the first argument is implicit. ∃ : {A : Type a} → (A → Type b) → Type (a ⊔ b) ∃ = Σ _ -- Binary products. _×_ : (A : Type a) (B : Type b) → Type (a ⊔ b) A × B = Σ A (const B) -- A variant of _,_ that is specialised to _×_. Use of this variant -- can make type-inference easier. _,′_ : A → B → A × B x ,′ y = x , y -- A map function. Σ-map : (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ A P → Σ B Q Σ-map f g = λ p → (f (proj₁₀ p) , g (proj₂₀ p)) -- Zip. Σ-zip : (f : A → B → C) → (∀ {x y} → P x → Q y → R (f x y)) → Σ A P → Σ B Q → Σ C R Σ-zip f g = λ p q → (f (proj₁₀ p) (proj₁₀ q) , g (proj₂₀ p) (proj₂₀ q)) -- Curry and uncurry. curry : {@0 B : A → Type b} {@0 C : Σ A B → Type c} → ((p : Σ A B) → C p) → ((x : A) (y : B x) → C (x , y)) curry f x y = f (x , y) uncurry : {@0 B : A → Type b} {@0 C : Σ A B → Type c} → ((x : A) (y : B x) → C (x , y)) → ((p : Σ A B) → C p) uncurry f (x , y) = f x y -- Swaps the two components of the pair. swap : A × B → B × A swap (x , y) = y , x ------------------------------------------------------------------------ -- W-types data W (A : Type a) (B : A → Type b) : Type (a ⊔ b) where sup : (x : A) (f : B x → W A B) → W A B -- Projections. headᵂ : {@0 B : A → Type b} → W A B → A headᵂ (sup x f) = x tailᵂ : {@0 B : A → Type b} → (x : W A B) → B (headᵂ x) → W A B tailᵂ (sup x f) = f -- If B is always inhabited, then W A B is empty. abstract inhabited⇒W-empty : {@0 B : A → Type b} → (∀ x → B x) → ¬ W A B inhabited⇒W-empty b (sup x f) = inhabited⇒W-empty b (f (b x)) ------------------------------------------------------------------------ -- Binary sums infixr 1 _⊎_ data _⊎_ (A : Type a) (B : Type b) : Type (a ⊔ b) where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B -- Eliminator for binary sums. [_,_] : {@0 C : A ⊎ B → Type c} → ((x : A) → C (inj₁ x)) → ((x : B) → C (inj₂ x)) → ((x : A ⊎ B) → C x) [ f , g ] (inj₁ x) = f x [ f , g ] (inj₂ y) = g y -- A generalisation of if-then-else. infix 5 if_then_else_ if_then_else_ : A ⊎ B → C → C → C if x then t else f = [ const t , const f ] x -- A generalisation of not. not : A ⊎ B → B ⊎ A not (inj₁ x) = inj₂ x not (inj₂ x) = inj₁ x -- A map function. ⊎-map : (A₁ → A₂) → (B₁ → B₂) → A₁ ⊎ B₁ → A₂ ⊎ B₂ ⊎-map f g = [ (λ x → inj₁ (f x)) , (λ x → inj₂ (g x)) ] -- The function from-⊎ is a safe analogue of fromJust. For an example -- of how from-⊎ can be used, see -- Quotient.equivalence-but-not-strong-equivalence. From-⊎ : {A B : Type ℓ} → A ⊎ B → Type ℓ From-⊎ {A = A} (inj₁ _) = A From-⊎ {B = B} (inj₂ _) = B from-⊎ : (x : A ⊎ B) → From-⊎ x from-⊎ (inj₁ x) = x from-⊎ (inj₂ y) = y -- A special case of binary sums: decided predicates. Dec : Type p → Type p Dec P = P ⊎ ¬ P pattern yes p = inj₁ p pattern no p = inj₂ p -- Decidable relations. Decidable : {A : Type a} {B : Type b} → (A → B → Type ℓ) → Type (a ⊔ b ⊔ ℓ) Decidable _∼_ = ∀ x y → Dec (x ∼ y) -- Exclusive or. infixr 1 _Xor_ _Xor_ : Type a → Type b → Type (a ⊔ b) A Xor B = (A × ¬ B) ⊎ (¬ A × B) -- Maybe. Maybe : Type a → Type a Maybe A = ⊤ ⊎ A pattern nothing = inj₁ tt pattern just x = inj₂ x -- The truth predicate T is only inhabited when its argument is -- inj₁ something. T : A ⊎ B → Type T b = if b then ⊤ else ⊥ ------------------------------------------------------------------------ -- Booleans -- Booleans. Bool : Type Bool = ⊤ ⊎ ⊤ pattern true = inj₁ tt pattern false = inj₂ tt -- And. infixr 6 _∧_ _∧_ : Bool → Bool → Bool b₁ ∧ b₂ = if b₁ then b₂ else false -- Or. infixr 5 _∨_ _∨_ : Bool → Bool → Bool b₁ ∨ b₂ = if b₁ then true else b₂ ------------------------------------------------------------------------ -- Lists open import Agda.Builtin.List public using (List; []; _∷_) ------------------------------------------------------------------------ -- Finite sets Fin : ℕ → Type Fin zero = ⊥ Fin (suc n) = ⊤ ⊎ Fin n pattern fzero = inj₁ tt pattern fsuc i = inj₂ i ------------------------------------------------------------------------ -- Some relation combinators -- Combines two relations into a relation on functions. _→-rel_ : {A : Type a} {C : Type c} → (A → C → Type ℓ) → (B → D → Type ℓ) → (A → B) → (C → D) → Type (a ⊔ c ⊔ ℓ) (P →-rel Q) f g = ∀ x y → P x y → Q (f x) (g y) -- Combines two relations into a relation on products. _×-rel_ : (A → C → Type ℓ) → (B → D → Type ℓ) → A × B → C × D → Type ℓ (P ×-rel Q) (x , u) (y , v) = P x y × Q u v -- Combines two relations into a relation on sums. _⊎-rel_ : (A → C → Type ℓ) → (B → D → Type ℓ) → A ⊎ B → C ⊎ D → Type ℓ (P ⊎-rel Q) (inj₁ x) (inj₁ y) = P x y (P ⊎-rel Q) (inj₁ x) (inj₂ v) = ⊥ (P ⊎-rel Q) (inj₂ u) (inj₁ y) = ⊥ (P ⊎-rel Q) (inj₂ u) (inj₂ v) = Q u v
{ "alphanum_fraction": 0.4816444933, "avg_line_length": 20.7837837838, "ext": "agda", "hexsha": "52562ea1b6afab62fa8a237799c074af9deff7f6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Prelude.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 3674, "size": 9997 }
------------------------------------------------------------------------ -- Searchable set ------------------------------------------------------------------------ -- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.127.3062&rep=rep1&type=pdf -- http://www.cs.bham.ac.uk/~mhe/papers/omniscient-2011-07-06.pdf {-# OPTIONS --without-K --safe --exact-split #-} module Constructive.Searchable where -- agda-stdlib open import Data.Bool open import Data.Empty open import Data.Product as Prod open import Data.Sum as Sum open import Function.Base open import Relation.Binary.PropositionalEquality import Function.Equivalence as Eqv -- TOOD use new function bundle -- agda-misc open import Constructive.Axiom open import Constructive.Axiom.Properties.Base open import Constructive.Axiom.Properties.Bool open import Constructive.Common open import Constructive.Combinators module SearchModule {a} {A : Set a} (searchable : Searchable-Bool A) where ε : ((A → Bool) → A) ε = proj₁ searchable ε-correct : (P : A → Bool) → P (ε P) ≡ true → (x : A) → P x ≡ true ε-correct = proj₂ searchable -- Lemma 2.1 searchable-Bool⇒lpo-Bool-Alt : ∀ {a} {A : Set a} → Searchable-Bool A → LPO-Bool-Alt A searchable-Bool⇒lpo-Bool-Alt (ε , ε-correct) P with P (ε P) | inspect P (ε P) ... | false | [ P[εP]≡false ] = inj₁ (ε P , P[εP]≡false) ... | true | [ P[εP]≡true ] = inj₂ (ε-correct P P[εP]≡true) searchable-Bool⇒inhabited : ∀ {a} {A : Set a} → Searchable-Bool A → Inhabited A searchable-Bool⇒inhabited searchable-Bool = (proj₁ searchable-Bool) λ _ → true -- Inhabited ∧ LPO-Bool-Alt => Searchable-Bool inhabited∧lpo-Bool-Alt⇒ε : ∀ {a} {A : Set a} → Inhabited A → LPO-Bool-Alt A → (A → Bool) → A inhabited∧lpo-Bool-Alt⇒ε inhabited lpo-Bool-Alt P with lpo-Bool-Alt P ... | inj₁ (x , _) = x ... | inj₂ _ = inhabited inhabited∧lpo-Bool-Alt⇒ε-correct : ∀ {a} {A : Set a} (i : Inhabited A) (lpo-Bool-Alt : LPO-Bool-Alt A) (P : A → Bool) → P ((inhabited∧lpo-Bool-Alt⇒ε i lpo-Bool-Alt) P) ≡ true → (x : A) → P x ≡ true inhabited∧lpo-Bool-Alt⇒ε-correct inhabited lpo-Bool-Alt P with lpo-Bool-Alt P ... | inj₁ (x , Px≡false) = λ Px≡true → ⊥-elim $ false≢true $ trans (sym Px≡false) Px≡true where false≢true : false ≢ true false≢true () ... | inj₂ ∀x→Px≡true = λ _ → ∀x→Px≡true inhabited∧lpo-Bool-Alt⇒searchable-Bool : ∀ {a} {A : Set a} → Inhabited A → LPO-Bool-Alt A → Searchable-Bool A inhabited∧lpo-Bool-Alt⇒searchable-Bool inhabited lpo-Bool-Alt = inhabited∧lpo-Bool-Alt⇒ε inhabited lpo-Bool-Alt , inhabited∧lpo-Bool-Alt⇒ε-correct inhabited lpo-Bool-Alt -- Searchable-Bool <=> Searchable searchable-Bool⇒searchable : ∀ {a p} {A : Set a} → Searchable-Bool A → Searchable A p searchable-Bool⇒searchable {a} {p} {A} searchable-Bool = inhabited∧lpo⇒searchable inhabited lpo where inhabited = searchable-Bool⇒inhabited searchable-Bool lpo : LPO A p lpo = lpo-Bool⇒lpo p $ lpo-Bool-Alt⇒lpo-Bool $ searchable-Bool⇒lpo-Bool-Alt searchable-Bool searchable⇒searchable-Bool : ∀ {a p} {A : Set a} → Searchable A p → Searchable-Bool A searchable⇒searchable-Bool searchable = inhabited∧lpo-Bool-Alt⇒searchable-Bool inhabited lpo-Bool-Alt where inhabited = searchable⇒inhabited searchable lpo-Bool-Alt = lpo-Bool⇒lpo-Bool-Alt $ lpo⇒lpo-Bool $ searchable⇒lpo searchable -- Lemma 2.2 module Lemma2-2 {a} {A : Set a} (searchable-Bool : Searchable-Bool A) where open SearchModule searchable-Bool module _ {P : A → Bool} where ∃x→Px≡false→P[εP]≡false : (∃ λ x → P x ≡ false) → P (ε P) ≡ false ∃x→Px≡false→P[εP]≡false e = x≢true⇒x≡false $ contraposition (ε-correct P) (∃¬P→¬∀P (Prod.map₂ x≡false⇒x≢true e)) where x≡false⇒x≢true : ∀ {x} → x ≡ false → x ≢ true x≡false⇒x≢true {false} refl () x≢true⇒x≡false : ∀ {x} → x ≢ true → x ≡ false x≢true⇒x≡false {false} neq = refl x≢true⇒x≡false {true } neq = ⊥-elim $ neq refl ∃x→Px≡false⇔P[εP]≡false : (∃ λ x → P x ≡ false) Eqv.⇔ P (ε P) ≡ false ∃x→Px≡false⇔P[εP]≡false = Eqv.equivalence ∃x→Px≡false→P[εP]≡false λ eq → ε P , eq -- E_X Exist : (A → Bool) → Bool Exist P = P (ε P) Exist[P]≡false⇔∃x→Px≡false : {P : A → Bool} → Exist P ≡ false Eqv.⇔ (∃ λ x → P x ≡ false) Exist[P]≡false⇔∃x→Px≡false = Eqv.sym ∃x→Px≡false⇔P[εP]≡false open Lemma2-2 Exhaustible : ∀ {a} → Set a → Set a Exhaustible A = Σ ((A → Bool) → Bool) λ ∀K → (P : A → Bool) → ∀K P ≡ true → ∀ x → P x ≡ true
{ "alphanum_fraction": 0.6164504069, "avg_line_length": 38.8632478632, "ext": "agda", "hexsha": "759d7765671ee8d30e6a969ad9345aaabb446f35", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Constructive/Searchable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Constructive/Searchable.agda", "max_line_length": 92, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Constructive/Searchable.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 1802, "size": 4547 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.PathGroupoid open import lib.PathOver module lib.cubical.Square where {- *--1--* | | 0 3 | | *--2--* -} data Square {i} {A : Type i} {a₀₀ : A} : {a₀₁ a₁₀ a₁₁ : A} → a₀₀ == a₀₁ → a₀₀ == a₁₀ → a₀₁ == a₁₁ → a₁₀ == a₁₁ → Type i where ids : Square idp idp idp idp hid-square : ∀ {i} {A : Type i} {a₀₀ a₀₁ : A} {p : a₀₀ == a₀₁} → Square p idp idp p hid-square {p = idp} = ids vid-square : ∀ {i} {A : Type i} {a₀₀ a₁₀ : A} {p : a₀₀ == a₁₀} → Square idp p p idp vid-square {p = idp} = ids square-to-disc : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → p₀₋ ∙ p₋₁ == p₋₀ ∙ p₁₋ square-to-disc ids = idp disc-to-square : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → p₀₋ ∙ p₋₁ == p₋₀ ∙ p₁₋ → Square p₀₋ p₋₀ p₋₁ p₁₋ disc-to-square {p₀₋ = idp} {p₋₀ = idp} {p₋₁ = idp} {p₁₋ = .idp} idp = ids square-to-disc-β : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (α : p₀₋ ∙ p₋₁ == p₋₀ ∙ p₁₋) → square-to-disc (disc-to-square {p₀₋ = p₀₋} {p₋₀ = p₋₀} α) == α square-to-disc-β {p₀₋ = idp} {p₋₀ = idp} {p₋₁ = idp} {p₁₋ = .idp} idp = idp disc-to-square-β : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → disc-to-square (square-to-disc sq) == sq disc-to-square-β ids = idp ap-square : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square (ap f p₀₋) (ap f p₋₀) (ap f p₋₁) (ap f p₁₋) ap-square f ids = ids ap-square-hid : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} {a₀ a₁ : A} {p : a₀ == a₁} → ap-square f (hid-square {p = p}) == hid-square ap-square-hid {p = idp} = idp ap-square-vid : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} {a₀ a₁ : A} {p : a₀ == a₁} → ap-square f (vid-square {p = p}) == vid-square ap-square-vid {p = idp} = idp module _ {i} {A : Type i} where horiz-degen-square : {a a' : A} {p q : a == a'} → p == q → Square p idp idp q horiz-degen-square {p = idp} α = disc-to-square α horiz-degen-path : {a a' : A} {p q : a == a'} → Square p idp idp q → p == q horiz-degen-path {p = idp} sq = square-to-disc sq horiz-degen-path-β : {a a' : A} {p q : a == a'} (α : p == q) → horiz-degen-path (horiz-degen-square α) == α horiz-degen-path-β {p = idp} α = square-to-disc-β α horiz-degen-square-β : {a a' : A} {p q : a == a'} (sq : Square p idp idp q) → horiz-degen-square (horiz-degen-path sq) == sq horiz-degen-square-β {p = idp} sq = disc-to-square-β sq vert-degen-square : {a a' : A} {p q : a == a'} → p == q → Square idp p q idp vert-degen-square {p = idp} α = disc-to-square (! α) vert-degen-path : {a a' : A} {p q : a == a'} → Square idp p q idp → p == q vert-degen-path {p = idp} sq = ! (square-to-disc sq) vert-degen-path-β : {a a' : A} {p q : a == a'} (α : p == q) → vert-degen-path (vert-degen-square α) == α vert-degen-path-β {p = idp} α = ap ! (square-to-disc-β (! α)) ∙ !-! α vert-degen-square-β : {a a' : A} {p q : a == a'} (sq : Square idp p q idp) → vert-degen-square (vert-degen-path sq) == sq vert-degen-square-β {p = idp} sq = ap disc-to-square (!-! (square-to-disc sq)) ∙ disc-to-square-β sq horiz-degen-square-idp : {a a' : A} {p : a == a'} → horiz-degen-square (idp {a = p}) == hid-square horiz-degen-square-idp {p = idp} = idp vert-degen-square-idp : {a a' : A} {p : a == a'} → vert-degen-square (idp {a = p}) == vid-square vert-degen-square-idp {p = idp} = idp {- Flipping squares -} module _ {i} {A : Type i} where square-symmetry : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₋₀ p₀₋ p₁₋ p₋₁ square-symmetry ids = ids square-sym-inv : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → square-symmetry (square-symmetry sq) == sq square-sym-inv ids = idp ap-square-symmetry : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → ap-square f (square-symmetry sq) == square-symmetry (ap-square f sq) ap-square-symmetry f ids = idp {- Alternate induction principles -} square-left-J : ∀ {i j} {A : Type i} {a₀₀ a₀₁ : A} {p₀₋ : a₀₀ == a₀₁} (P : {a₁₀ a₁₁ : A} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → Type j) (r : P hid-square) {a₁₀ a₁₁ : A} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → P sq square-left-J P r ids = r square-top-J : ∀ {i j} {A : Type i} {a₀₀ a₁₀ : A} {p₋₀ : a₀₀ == a₁₀} (P : {a₀₁ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → Type j) (r : P vid-square) {a₀₁ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → P sq square-top-J P r ids = r square-bot-J : ∀ {i j} {A : Type i} {a₀₁ a₁₁ : A} {p₋₁ : a₀₁ == a₁₁} (P : {a₀₀ a₁₀ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → Type j) (r : P vid-square) {a₀₀ a₁₀ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → P sq square-bot-J P r ids = r square-right-J : ∀ {i j} {A : Type i} {a₁₀ a₁₁ : A} {p₁₋ : a₁₀ == a₁₁} (P : {a₀₀ a₀₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → Type j) (r : P hid-square) {a₀₀ a₀₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → P sq square-right-J P r ids = r module _ where private lemma : ∀ {i j} {A : Type i} {a₀ : A} (P : {a₁ : A} {p q : a₀ == a₁} → p == q → Type j) (r : P (idp {a = idp})) {a₁ : A} {p q : a₀ == a₁} (α : p == q) → P α lemma P r {p = idp} idp = r horiz-degen-J : ∀ {i j} {A : Type i} {a₀ : A} (P : {a₁ : A} {p q : a₀ == a₁} → Square p idp idp q → Type j) (r : P ids) {a₁ : A} {p q : a₀ == a₁} (sq : Square p idp idp q) → P sq horiz-degen-J P r sq = transport P (horiz-degen-square-β sq) (lemma (P ∘ horiz-degen-square) r (horiz-degen-path sq)) vert-degen-J : ∀ {i j} {A : Type i} {a₀ : A} (P : {a₁ : A} {p q : a₀ == a₁} → Square idp p q idp → Type j) (r : P ids) {a₁ : A} {p q : a₀ == a₁} (sq : Square idp p q idp) → P sq vert-degen-J P r sq = transport P (vert-degen-square-β sq) (lemma (P ∘ vert-degen-square) r (vert-degen-path sq)) {- Square filling -} module _ {i} {A : Type i} where fill-square-left : {a₀₀ a₀₁ a₁₀ a₁₁ : A} (p₋₀ : a₀₀ == a₁₀) (p₋₁ : a₀₁ == a₁₁) (p₁₋ : a₁₀ == a₁₁) → Σ (a₀₀ == a₀₁) (λ p₀₋ → Square p₀₋ p₋₀ p₋₁ p₁₋) fill-square-left idp idp p = (p , hid-square) fill-square-top : {a₀₀ a₀₁ a₁₀ a₁₁ : A} (p₀₋ : a₀₀ == a₀₁) (p₋₁ : a₀₁ == a₁₁) (p₁₋ : a₁₀ == a₁₁) → Σ (a₀₀ == a₁₀) (λ p₋₀ → Square p₀₋ p₋₀ p₋₁ p₁₋) fill-square-top idp p idp = (p , vid-square) fill-square-bot : {a₀₀ a₀₁ a₁₀ a₁₁ : A} (p₀₋ : a₀₀ == a₀₁) (p₋₀ : a₀₀ == a₁₀) (p₁₋ : a₁₀ == a₁₁) → Σ (a₀₁ == a₁₁) (λ p₋₁ → Square p₀₋ p₋₀ p₋₁ p₁₋) fill-square-bot idp p idp = (p , vid-square) fill-square-right : {a₀₀ a₀₁ a₁₀ a₁₁ : A} (p₀₋ : a₀₀ == a₀₁) (p₋₀ : a₀₀ == a₁₀) (p₋₁ : a₀₁ == a₁₁) → Σ (a₁₀ == a₁₁) (λ p₁₋ → Square p₀₋ p₋₀ p₋₁ p₁₋) fill-square-right p idp idp = (p , hid-square) module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where ↓-='-to-square : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → u == v [ (λ z → f z == g z) ↓ p ] → Square u (ap f p) (ap g p) v ↓-='-to-square {p = idp} α = horiz-degen-square α ↓-='-from-square : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → Square u (ap f p) (ap g p) v → u == v [ (λ z → f z == g z) ↓ p ] ↓-='-from-square {p = idp} sq = horiz-degen-path sq module _ {i j} {A : Type i} {B : Type j} {f : A → B} {b : B} where ↓-cst=app-from-square : {x y : A} {p : x == y} {u : b == f x} {v : b == f y} → Square u idp (ap f p) v → u == v [ (λ z → b == f z) ↓ p ] ↓-cst=app-from-square {p = idp} sq = horiz-degen-path sq ↓-cst=app-to-square : {x y : A} {p : x == y} {u : b == f x} {v : b == f y} → u == v [ (λ z → b == f z) ↓ p ] → Square u idp (ap f p) v ↓-cst=app-to-square {p = idp} α = horiz-degen-square α ↓-app=cst-from-square : {x y : A} {p : x == y} {u : f x == b} {v : f y == b} → Square u (ap f p) idp v → u == v [ (λ z → f z == b) ↓ p ] ↓-app=cst-from-square {p = idp} sq = horiz-degen-path sq ↓-app=cst-to-square : {x y : A} {p : x == y} {u : f x == b} {v : f y == b} → u == v [ (λ z → f z == b) ↓ p ] → Square u (ap f p) idp v ↓-app=cst-to-square {p = idp} α = horiz-degen-square α module _ {i} {A : Type i} {f : A → A} where ↓-idf=app-from-square : {x y : A} {p : x == y} {u : x == f x} {v : y == f y} → Square u p (ap f p) v → u == v [ (λ z → z == f z) ↓ p ] ↓-idf=app-from-square {p = idp} sq = horiz-degen-path sq ↓-idf=app-to-square : {x y : A} {p : x == y} {u : x == f x} {v : y == f y} → u == v [ (λ z → z == f z) ↓ p ] → Square u p (ap f p) v ↓-idf=app-to-square {p = idp} α = horiz-degen-square α ↓-app=idf-from-square : {x y : A} {p : x == y} {u : f x == x} {v : f y == y} → Square u (ap f p) p v → u == v [ (λ z → f z == z) ↓ p ] ↓-app=idf-from-square {p = idp} sq = horiz-degen-path sq ↓-app=idf-to-square : {x y : A} {p : x == y} {u : f x == x} {v : f y == y} → u == v [ (λ z → f z == z) ↓ p ] → Square u (ap f p) p v ↓-app=idf-to-square {p = idp} α = horiz-degen-square α module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where ↓-∘=idf-from-square : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y} → Square u (ap g (ap f p)) p v → (u == v [ (λ z → g (f z) == z) ↓ p ]) ↓-∘=idf-from-square {p = idp} sq = horiz-degen-path sq ↓-∘=idf-to-square : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y} → (u == v [ (λ z → g (f z) == z) ↓ p ]) → Square u (ap g (ap f p)) p v ↓-∘=idf-to-square {p = idp} α = horiz-degen-square α module _ {i j} {A : Type i} {B : Type j} where natural-square : {f₁ f₂ : A → B} (p : ∀ a → f₁ a == f₂ a) {a₁ a₂ : A} (q : a₁ == a₂) → Square (p a₁) (ap f₁ q) (ap f₂ q) (p a₂) natural-square p idp = hid-square natural-square-idp : {f₁ : A → B} {a₁ a₂ : A} (q : a₁ == a₂) → natural-square {f₁ = f₁} (λ _ → idp) q == vid-square natural-square-idp idp = idp {- Used for getting square equivalents of glue-β terms -} natural-square-β : {f₁ f₂ : A → B} (p : (a : A) → f₁ a == f₂ a) {x y : A} (q : x == y) {sq : Square (p x) (ap f₁ q) (ap f₂ q) (p y)} → apd p q == ↓-='-from-square sq → natural-square p q == sq natural-square-β _ idp α = ! horiz-degen-square-idp ∙ ap horiz-degen-square α ∙ horiz-degen-square-β _ _⊡v_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₀₂ a₁₂ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} {q₀₋ : a₀₁ == a₀₂} {q₋₂ : a₀₂ == a₁₂} {q₁₋ : a₁₁ == a₁₂} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square q₀₋ p₋₁ q₋₂ q₁₋ → Square (p₀₋ ∙ q₀₋) p₋₀ q₋₂ (p₁₋ ∙ q₁₋) ids ⊡v sq = sq _⊡v'_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₀₂ a₁₂ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} {q₀₋ : a₀₁ == a₀₂} {q₋₂ : a₀₂ == a₁₂} {q₁₋ : a₁₁ == a₁₂} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square q₀₋ p₋₁ q₋₂ q₁₋ → Square (p₀₋ ∙' q₀₋) p₋₀ q₋₂ (p₁₋ ∙' q₁₋) sq ⊡v' ids = sq _∙v⊡_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ p₋₀' : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → p₋₀ == p₋₀' → Square p₀₋ p₋₀' p₋₁ p₁₋ → Square p₀₋ p₋₀ p₋₁ p₁₋ idp ∙v⊡ sq = sq _⊡v∙_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₋₀ : a₀₀ == a₁₀} {p₀₋ : a₀₀ == a₀₁} {p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → p₋₁ == p₋₁' → Square p₀₋ p₋₀ p₋₁' p₁₋ sq ⊡v∙ idp = sq _⊡h_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₂₀ a₂₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} {q₋₀ : a₁₀ == a₂₀} {q₋₁ : a₁₁ == a₂₁} {q₂₋ : a₂₀ == a₂₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₁₋ q₋₀ q₋₁ q₂₋ → Square p₀₋ (p₋₀ ∙ q₋₀) (p₋₁ ∙ q₋₁) q₂₋ ids ⊡h sq = sq _⊡h'_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ a₂₀ a₂₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} {q₋₀ : a₁₀ == a₂₀} {q₋₁ : a₁₁ == a₂₁} {q₂₋ : a₂₀ == a₂₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₁₋ q₋₀ q₋₁ q₂₋ → Square p₀₋ (p₋₀ ∙' q₋₀) (p₋₁ ∙' q₋₁) q₂₋ sq ⊡h' ids = sq _∙h⊡_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ p₀₋' : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → p₀₋ == p₀₋' → Square p₀₋' p₋₀ p₋₁ p₁₋ → Square p₀₋ p₋₀ p₋₁ p₁₋ idp ∙h⊡ sq = sq _⊡h∙_ : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ p₁₋' : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → p₁₋ == p₁₋' → Square p₀₋ p₋₀ p₋₁ p₁₋' sq ⊡h∙ idp = sq infixr 80 _⊡v_ _⊡v'_ _⊡h_ _⊡h'_ infixr 80 _∙v⊡_ _∙h⊡_ infixl 85 _⊡v∙_ _⊡h∙_ module _ {i} {A : Type i} where !□h : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₁₋ (! p₋₀) (! p₋₁) p₀₋ !□h ids = ids !□v : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square (! p₀₋) p₋₁ p₋₀ (! p₁₋) !□v ids = ids module _ {i} {A : Type i} where {- TODO rest of these -} ⊡h-unit-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → hid-square ⊡h sq == sq ⊡h-unit-l ids = idp ⊡h-unit-r : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → sq ⊡h hid-square == ∙-unit-r _ ∙v⊡ (sq ⊡v∙ ! (∙-unit-r _)) ⊡h-unit-r ids = idp ⊡h'-unit-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → hid-square ⊡h' sq == ∙'-unit-l _ ∙v⊡ (sq ⊡v∙ ! (∙'-unit-l _)) ⊡h'-unit-l ids = idp ⊡h-unit-l-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq' : Square p₀₋ idp idp p₀₋) (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → sq' ⊡h sq == sq → sq' == hid-square ⊡h-unit-l-unique sq' ids p = ! (⊡h-unit-r sq') ∙ p module _ {i} {A : Type i} where !□h-inv-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → (!□h sq) ⊡h sq == !-inv-l p₋₀ ∙v⊡ (hid-square ⊡v∙ ! (!-inv-l p₋₁)) !□h-inv-l ids = idp !□h-inv-r : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → sq ⊡h (!□h sq) == !-inv-r p₋₀ ∙v⊡ (hid-square ⊡v∙ ! (!-inv-r p₋₁)) !□h-inv-r ids = idp !□v-inv-l : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → (!□v sq) ⊡v sq == !-inv-l p₀₋ ∙h⊡ (vid-square ⊡h∙ ! (!-inv-l p₁₋)) !□v-inv-l ids = idp !□v-inv-r : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (sq : Square p₀₋ p₋₀ p₋₁ p₁₋) → sq ⊡v (!□v sq) == !-inv-r p₀₋ ∙h⊡ (vid-square ⊡h∙ ! (!-inv-r p₁₋)) !□v-inv-r ids = idp module _ {i} {A : Type i} where square-left-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ p₀₋' : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋' p₋₀ p₋₁ p₁₋ → p₀₋ == p₀₋' square-left-unique {p₋₀ = idp} {p₋₁ = idp} sq₁ sq₂ = horiz-degen-path (sq₁ ⊡h (!□h sq₂)) square-top-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ p₋₀' : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ p₋₀' p₋₁ p₁₋ → p₋₀ == p₋₀' square-top-unique {p₀₋ = idp} {p₁₋ = idp} sq₁ sq₂ = vert-degen-path (sq₁ ⊡v (!□v sq₂)) square-bot-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ p₋₁' : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ p₋₀ p₋₁' p₁₋ → p₋₁ == p₋₁' square-bot-unique {p₀₋ = idp} {p₁₋ = idp} sq₁ sq₂ = vert-degen-path ((!□v sq₁) ⊡v sq₂) square-right-unique : {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ p₁₋' : a₁₀ == a₁₁} → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ p₋₀ p₋₁ p₁₋' → p₁₋ == p₁₋' square-right-unique {p₋₀ = idp} {p₋₁ = idp} sq₁ sq₂ = horiz-degen-path ((!□h sq₁) ⊡h sq₂) module _ {i} {A : Type i} where {- XXX naminig -} connection : {a₀ a₁ : A} {q : a₀ == a₁} → Square idp idp q q connection {q = idp} = ids {- XXX naminig -} connection2 : {a₀ a₁ a₂ : A} {p : a₀ == a₁} {q : a₁ == a₂} → Square p p q q connection2 {p = idp} {q = idp} = ids lb-square : {a₀ a₁ : A} (p : a₀ == a₁) → Square p idp (! p) idp lb-square idp = ids bl-square : {a₀ a₁ : A} (p : a₀ == a₁) → Square (! p) idp p idp bl-square idp = ids br-square : {a₀ a₁ : A} (p : a₀ == a₁) → Square idp idp p p br-square idp = ids rb-square = br-square rt-square : {a₀ a₁ : A} (p : a₀ == a₁) → Square idp (! p) idp p rt-square idp = ids tr-square : {a₀ a₁ : A} (p : a₀ == a₁) → Square idp p idp (! p) tr-square idp = ids lt-square : {a₀ a₁ : A} (p : a₀ == a₁) → Square p p idp idp lt-square idp = ids tl-square = lt-square
{ "alphanum_fraction": 0.4764869736, "avg_line_length": 33.842883549, "ext": "agda", "hexsha": "012c4595d4ee301d8a7e3df809d0b77d7540edcd", "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": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/cubical/Square.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/cubical/Square.agda", "max_line_length": 79, "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/cubical/Square.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 9953, "size": 18309 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.KernelImage open import groups.KernelImageEmap module cohomology.ChainComplex where record ChainComplex i : Type (lsucc i) where field head : AbGroup i chain : ℕ → AbGroup i augment : AbGroup.grp (chain 0) →ᴳ AbGroup.grp head boundary : ∀ n → (AbGroup.grp (chain (S n)) →ᴳ AbGroup.grp (chain n)) record CochainComplex i : Type (lsucc i) where field head : AbGroup i cochain : ℕ → AbGroup i augment : AbGroup.grp head →ᴳ AbGroup.grp (cochain 0) coboundary : ∀ n → (AbGroup.grp (cochain n) →ᴳ AbGroup.grp (cochain (S n))) record CochainComplexEquiv {i₀ i₁} (cc₀ : CochainComplex i₀) (cc₁ : CochainComplex i₁) : Type (lmax i₀ i₁) where private module cc₀ = CochainComplex cc₀ module cc₁ = CochainComplex cc₁ field head : AbGroup.grp cc₀.head ≃ᴳ AbGroup.grp cc₁.head cochain : (n : ℕ) → AbGroup.grp (cc₀.cochain n) ≃ᴳ AbGroup.grp (cc₁.cochain n) augment : CommSquareᴳ cc₀.augment cc₁.augment (–>ᴳ head) (–>ᴳ (cochain 0)) coboundary : ∀ n → CommSquareᴳ (cc₀.coboundary n) (cc₁.coboundary n) (–>ᴳ (cochain n)) (–>ᴳ (cochain (S n))) homology-group : ∀ {i} → ChainComplex i → (n : ℤ) → Group i homology-group cc (pos 0) = Ker/Im cc.augment (cc.boundary 0) (snd (cc.chain 0)) where module cc = ChainComplex cc homology-group cc (pos (S n)) = Ker/Im (cc.boundary n) (cc.boundary (S n)) (snd (cc.chain (S n))) where module cc = ChainComplex cc homology-group {i} cc (negsucc _) = Lift-group {j = i} Unit-group cohomology-group : ∀ {i} → CochainComplex i → (n : ℤ) → Group i cohomology-group cc (pos 0) = Ker/Im (cc.coboundary 0) cc.augment (snd (cc.cochain 0)) where module cc = CochainComplex cc cohomology-group cc (pos (S n)) = Ker/Im (cc.coboundary (S n)) (cc.coboundary n) (snd (cc.cochain (S n))) where module cc = CochainComplex cc cohomology-group {i} cc (negsucc _) = Lift-group {j = i} Unit-group cohomology-group-emap : ∀ {i₀ i₁} {cc₀ : CochainComplex i₀} {cc₁ : CochainComplex i₁} → CochainComplexEquiv cc₀ cc₁ → (n : ℤ) → cohomology-group cc₀ n ≃ᴳ cohomology-group cc₁ n cohomology-group-emap {cc₀ = cc₀} {cc₁} cc= (pos 0) = Ker/Im-emap (snd (cc₀.cochain 0)) (snd (cc₁.cochain 0)) (cc=.coboundary 0) cc=.augment (snd cc=.head) (snd (cc=.cochain 0)) (snd (cc=.cochain 1)) where module cc₀ = CochainComplex cc₀ module cc₁ = CochainComplex cc₁ module cc= = CochainComplexEquiv cc= cohomology-group-emap {cc₀ = cc₀} {cc₁} cc= (pos (S n)) = Ker/Im-emap (snd (cc₀.cochain (S n))) (snd (cc₁.cochain (S n))) (cc=.coboundary (S n)) (cc=.coboundary n) (snd (cc=.cochain n)) (snd (cc=.cochain (S n))) (snd (cc=.cochain (S (S n)))) where module cc₀ = CochainComplex cc₀ module cc₁ = CochainComplex cc₁ module cc= = CochainComplexEquiv cc= cohomology-group-emap _ (negsucc _) = lift-iso ∘eᴳ lower-iso complex-dualize : ∀ {i j} → ChainComplex i → AbGroup j → CochainComplex (lmax i j) complex-dualize {i} {j} cc G = record {M} where module cc = ChainComplex cc module M where head : AbGroup (lmax i j) head = hom-abgroup (AbGroup.grp cc.head) G cochain : ℕ → AbGroup (lmax i j) cochain n = hom-abgroup (AbGroup.grp (cc.chain n)) G augment : AbGroup.grp head →ᴳ AbGroup.grp (cochain 0) augment = pre∘ᴳ-hom G cc.augment coboundary : ∀ n → (AbGroup.grp (cochain n) →ᴳ AbGroup.grp (cochain (S n))) coboundary n = pre∘ᴳ-hom G (cc.boundary n)
{ "alphanum_fraction": 0.6343818985, "avg_line_length": 43.1428571429, "ext": "agda", "hexsha": "234a220077aeb28ce83826a09c6b768281c6fea8", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/ChainComplex.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/ChainComplex.agda", "max_line_length": 107, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/ChainComplex.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": 1298, "size": 3624 }
{-# OPTIONS --without-K #-} open import HoTT -- Associativity of the join (work in progress) module experimental.JoinAssoc {i j k} (A : Type i) (B : Type j) (C : Type k) where {- First map -} to : (A * B) * C → A * (B * C) to = To.f module _ where to-left-glue : (ab : A × B) → left (fst ab) == right (left (snd ab)) :> A * (B * C) to-left-glue (a , b) = glue (a , left b) module ToLeft = PushoutRec left (right ∘ left) to-left-glue to-left : A * B → A * (B * C) to-left = ToLeft.f to-glue-left : (c : C) (a : A) → to-left (left a) == right (right c) to-glue-left c a = glue (a , right c) to-glue-right : (c : C) (b : B) → to-left (right b) == right (right c) to-glue-right c b = ap right (glue (b , c)) to-glue-glue : (c : C) (ab : A × B) → to-glue-left c (fst ab) == to-glue-right c (snd ab) [ (λ x → to-left x == right (right c)) ↓ glue ab ] to-glue-glue c (a , b) = ↓-swap to-left right _ idp (ToLeft.glue-β (a , b) ◃ apd (λ x → glue (a , x)) (glue (b , c))) module ToGlue (c : C) = PushoutElim (to-glue-left c) (to-glue-right c) (to-glue-glue c) to-glue : (ab-c : (A * B) × C) → to-left (fst ab-c) == right (right (snd ab-c)) to-glue (ab , c) = M.f ab where module M = ToGlue c module To = PushoutRec {d = *-span (A * B) C} to-left (right ∘ right) to-glue {- Second map -} from : A * (B * C) → (A * B) * C from = From.f module MM where from-right-glue : (bc : B × C) → left (right (fst bc)) == right (snd bc) from-right-glue (b , c) = glue (right b , c) module FromRight = PushoutRec (left ∘ right) right from-right-glue from-right : B * C → (A * B) * C from-right = FromRight.f from-glue-left : (a : A) (b : B) → left (left a) == from-right (left b) from-glue-left a b = ap left (glue (a , b)) from-glue-right : (a : A) (c : C) → left (left a) == from-right (right c) from-glue-right a c = glue (left a , c) from-glue-glue : (a : A) (bc : B × C) → from-glue-left a (fst bc) == from-glue-right a (snd bc) [ (λ x → left (left a) == from-right x) ↓ glue bc ] from-glue-glue a (b , c) = ↓-swap! left from-right _ idp (apd (λ x → glue (x , c)) (glue (a , b)) ▹! (FromRight.glue-β (b , c))) module FromGlue (a : A) = PushoutElim (from-glue-left a) (from-glue-right a) (from-glue-glue a) from-glue : (a-bc : A × (B * C)) → left (left (fst a-bc)) == from-right (snd a-bc) from-glue (a , bc) = M.f bc where module M = FromGlue a module From = PushoutRec {d = *-span A (B * C)} (left ∘ left) from-right from-glue open MM public {- First composite -} to-from-right-glue' : (b : B) (c : C) → ap (to ∘ from-right) (glue (b , c)) =-= ap right (glue (b , c)) to-from-right-glue' b c = ap (λ z → to (from-right z)) (glue (b , c)) =⟪ ap-∘ to from-right (glue (b , c)) ⟫ ap to (ap from-right (glue (b , c))) =⟪ FromRight.glue-β (b , c) |in-ctx ap to ⟫ ap to (glue ((right b , c) :> ((A * B) × C))) =⟪ To.glue-β (right b , c)⟫ ap right (glue (b , c)) ∎∎ to-from-right-glue : (bc : B × C) → idp == idp [ (λ x → to (from (right x)) == right x) ↓ glue bc ] to-from-right-glue (b , c) = ↓-='-in (! (↯ to-from-right-glue' b c)) module ToFromRight = PushoutElim (λ _ → idp) (λ _ → idp) to-from-right-glue to-from-right : (bc : B * C) → to (from (right bc)) == right bc to-from-right = ToFromRight.f to-from-glue-left' : (a : A) (b : B) → ap to (ap from (glue (a , left b))) =-= glue (a , left b) to-from-glue-left' a b = ap to (ap from (glue (a , left b))) =⟪ From.glue-β (a , left b) |in-ctx ap to ⟫ ap to (ap left (glue (a , b))) =⟪ ∘-ap to left (glue (a , b)) ⟫ ap to-left (glue (a , b)) =⟪ ToLeft.glue-β (a , b) ⟫ glue (a , left b) ∎∎ to-from-glue-left : (a : A) (b : B) → idp == to-from-right (left b) [ (λ x → to (from x) == x) ↓ glue (a , left b) ] to-from-glue-left a b = ↓-∘=idf-in to from (↯ to-from-glue-left' a b) to-from-glue-right' : (a : A) (c : C) → ap to (ap from (glue (a , right c))) =-= glue (a , right c) to-from-glue-right' a c = ap to (ap from (glue (a , right c))) =⟪ From.glue-β (a , right c) |in-ctx ap to ⟫ ap to (glue (left a , c)) =⟪ To.glue-β (left a , c) ⟫ glue (a , right c) ∎∎ to-from-glue-right : (a : A) (c : C) → idp == to-from-right (right c) [ (λ x → to (from x) == x) ↓ glue (a , right c) ] to-from-glue-right a c = ↓-∘=idf-in to from (↯ to-from-glue-right' a c) postulate -- Not proved yet. Some of it is being worked on at JoinAssoc2 *-assoc : ((A * B) * C) ≃ (A * (B * C))
{ "alphanum_fraction": 0.5234899329, "avg_line_length": 41.9909090909, "ext": "agda", "hexsha": "2e64e746be0839e8c7e329c38b44218b4c7ecc58", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/experimental/JoinAssoc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/experimental/JoinAssoc.agda", "max_line_length": 151, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/experimental/JoinAssoc.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1815, "size": 4619 }
-- Andreas, 2016-10-08, issue #2243 -- {-# OPTIONS -v tc.cover.cover:100 #-} open import Agda.Builtin.Char f : Char → Char f 'x' = 'x' f 'x' = 'y' -- should be marked as unreachable clause f _ = 's'
{ "alphanum_fraction": 0.60591133, "avg_line_length": 18.4545454545, "ext": "agda", "hexsha": "d0bd3e744881b231af1ecfcdb32b6e8f3cb932f8", "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/Issue2243.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/Issue2243.agda", "max_line_length": 54, "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/Issue2243.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": 73, "size": 203 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.List.Base where open import Agda.Builtin.List public open import Cubical.Core.Everything module _ {ℓ} {A : Type ℓ} where infixr 5 _++_ [_] : A → List A [ a ] = a ∷ [] _++_ : List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ xs ++ ys rev : List A → List A rev [] = [] rev (x ∷ xs) = rev xs ++ [ x ]
{ "alphanum_fraction": 0.524173028, "avg_line_length": 17.8636363636, "ext": "agda", "hexsha": "f82ea8a6e783d112667a6c1c4cfd2f29f8ec2d06", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/List/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/List/Base.agda", "max_line_length": 43, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/List/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 144, "size": 393 }