Search is not available for this dataset
text
string
meta
dict
-- Andreas, 2015-05-06 issue reported by [email protected] record CoList : Set data CoList : Set where record CoList where -- Error WAS: -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/Syntax/Concrete/Definitions.hs:479 -- Error should be: -- Duplicate definition of CoList
{ "alphanum_fraction": 0.7426900585, "avg_line_length": 22.8, "ext": "agda", "hexsha": "89369c1707f7f8d1833f2739251afc744e3b3779", "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/Issue1500.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/Issue1500.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/Fail/Issue1500.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": 93, "size": 342 }
------------------------------------------------------------------------ -- Sequential colimits ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- The definition of sequential colimits and the statement of the -- non-dependent universal property are based on those in van Doorn's -- "Constructing the Propositional Truncation using Non-recursive -- HITs". -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining sequential colimits uses path -- equality, but the supplied notion of equality is used for many -- other things. import Equality.Path as P module Colimit.Sequential {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Bijection equality-with-J using (_↔_) import Colimit.Sequential.Erased eq as E import Colimit.Sequential.Very-erased eq as VE open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) import Equivalence P.equality-with-J as PEq open import Function-universe equality-with-J hiding (id; _∘_) private variable a b p q : Level A B : Type a P : A → Type p n : ℕ e x : A ------------------------------------------------------------------------ -- The type -- Sequential colimits. data Colimit (P : ℕ → Type p) (step : ∀ {n} → P n → P (suc n)) : Type p where ∣_∣ : P n → Colimit P step ∣∣≡∣∣ᴾ : (x : P n) → ∣ step x ∣ P.≡ ∣ x ∣ -- A variant of ∣∣≡∣∣ᴾ. ∣∣≡∣∣ : {step : ∀ {n} → P n → P (suc n)} (x : P n) → _≡_ {A = Colimit P step} ∣ step x ∣ ∣ x ∣ ∣∣≡∣∣ x = _↔_.from ≡↔≡ (∣∣≡∣∣ᴾ x) ------------------------------------------------------------------------ -- Eliminators -- A dependent eliminator, expressed using paths. record Elimᴾ {P : ℕ → Type p} {step : ∀ {n} → P n → P (suc n)} (Q : Colimit P step → Type q) : Type (p ⊔ q) where no-eta-equality field ∣∣ʳ : (x : P n) → Q ∣ x ∣ ∣∣≡∣∣ʳ : (x : P n) → P.[ (λ i → Q (∣∣≡∣∣ᴾ x i)) ] ∣∣ʳ (step x) ≡ ∣∣ʳ x open Elimᴾ public elimᴾ : {step : ∀ {n} → P n → P (suc n)} {Q : Colimit P step → Type q} → Elimᴾ Q → (x : Colimit P step) → Q x elimᴾ {P = P} {step = step} {Q = Q} e = helper where module E′ = Elimᴾ e helper : (x : Colimit P step) → Q x helper ∣ x ∣ = E′.∣∣ʳ x helper (∣∣≡∣∣ᴾ x i) = E′.∣∣≡∣∣ʳ x i -- A non-dependent eliminator, expressed using paths. record Recᴾ (P : ℕ → Type p) (step : ∀ {n} → P n → P (suc n)) (B : Type b) : Type (p ⊔ b) where no-eta-equality field ∣∣ʳ : P n → B ∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) P.≡ ∣∣ʳ x open Recᴾ public recᴾ : {step : ∀ {n} → P n → P (suc n)} → Recᴾ P step B → Colimit P step → B recᴾ r = elimᴾ λ where .∣∣ʳ → R.∣∣ʳ .∣∣≡∣∣ʳ → R.∣∣≡∣∣ʳ where module R = Recᴾ r -- A dependent eliminator. record Elim {P : ℕ → Type p} {step : ∀ {n} → P n → P (suc n)} (Q : Colimit P step → Type q) : Type (p ⊔ q) where no-eta-equality field ∣∣ʳ : (x : P n) → Q ∣ x ∣ ∣∣≡∣∣ʳ : (x : P n) → subst Q (∣∣≡∣∣ x) (∣∣ʳ (step x)) ≡ ∣∣ʳ x open Elim public elim : {step : ∀ {n} → P n → P (suc n)} {Q : Colimit P step → Type q} → Elim Q → (x : Colimit P step) → Q x elim e = elimᴾ λ where .∣∣ʳ → E′.∣∣ʳ .∣∣≡∣∣ʳ x → subst≡→[]≡ (E′.∣∣≡∣∣ʳ x) where module E′ = Elim e -- A "computation" rule. elim-∣∣≡∣∣ : dcong (elim e) (∣∣≡∣∣ x) ≡ Elim.∣∣≡∣∣ʳ e x elim-∣∣≡∣∣ = dcong-subst≡→[]≡ (refl _) -- A non-dependent eliminator. record Rec (P : ℕ → Type p) (step : ∀ {n} → P n → P (suc n)) (B : Type b) : Type (p ⊔ b) where no-eta-equality field ∣∣ʳ : P n → B ∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) ≡ ∣∣ʳ x open Rec public rec : {step : ∀ {n} → P n → P (suc n)} → Rec P step B → Colimit P step → B rec r = recᴾ λ where .∣∣ʳ → R.∣∣ʳ .∣∣≡∣∣ʳ x → _↔_.to ≡↔≡ (R.∣∣≡∣∣ʳ x) where module R = Rec r -- A "computation" rule. rec-∣∣≡∣∣ : {step : ∀ {n} → P n → P (suc n)} {r : Rec P step B} {x : P n} → cong (rec r) (∣∣≡∣∣ x) ≡ Rec.∣∣≡∣∣ʳ r x rec-∣∣≡∣∣ = cong-≡↔≡ (refl _) ------------------------------------------------------------------------ -- The universal property -- The universal property of the sequential colimit. universal-property : {step : ∀ {n} → P n → P (suc n)} → (Colimit P step → B) ≃ (∃ λ (f : ∀ n → P n → B) → ∀ n x → f (suc n) (step x) ≡ f n x) universal-property {P = P} {B = B} {step = step} = Eq.↔→≃ to from to∘from from∘to where to : (Colimit P step → B) → ∃ λ (f : ∀ n → P n → B) → ∀ n x → f (suc n) (step x) ≡ f n x to h = (λ _ → h ∘ ∣_∣) , (λ _ x → h ∣ step x ∣ ≡⟨ cong h (∣∣≡∣∣ x) ⟩∎ h ∣ x ∣ ∎) from : (∃ λ (f : ∀ n → P n → B) → ∀ n x → f (suc n) (step x) ≡ f n x) → Colimit P step → B from (f , g) = rec λ where .∣∣ʳ → f _ .∣∣≡∣∣ʳ → g _ to∘from : ∀ p → to (from p) ≡ p to∘from (f , g) = cong (f ,_) $ ⟨ext⟩ λ n → ⟨ext⟩ λ x → cong (rec _) (∣∣≡∣∣ x) ≡⟨ rec-∣∣≡∣∣ ⟩∎ g n x ∎ from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣ʳ _ → refl _ .∣∣≡∣∣ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (from (to h)) (∣∣≡∣∣ x))) (trans (refl _) (cong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) rec-∣∣≡∣∣ (trans-reflˡ _) ⟩ trans (sym (cong h (∣∣≡∣∣ x))) (cong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ -- A dependently typed variant of the sequential colimit's universal -- property. universal-property-Π : {step : ∀ {n} → P n → P (suc n)} → {Q : Colimit P step → Type q} → ((x : Colimit P step) → Q x) ≃ (∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → ∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x) universal-property-Π {P = P} {step = step} {Q = Q} = Eq.↔→≃ to from to∘from from∘to where to : ((x : Colimit P step) → Q x) → ∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → ∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x to h = (λ _ → h ∘ ∣_∣) , (λ _ x → subst Q (∣∣≡∣∣ x) (h ∣ step x ∣) ≡⟨ dcong h (∣∣≡∣∣ x) ⟩∎ h ∣ x ∣ ∎) from : (∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → ∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x) → (x : Colimit P step) → Q x from (f , g) = elim λ where .∣∣ʳ → f _ .∣∣≡∣∣ʳ → g _ to∘from : ∀ p → to (from p) ≡ p to∘from (f , g) = cong (f ,_) $ ⟨ext⟩ λ n → ⟨ext⟩ λ x → dcong (elim _) (∣∣≡∣∣ x) ≡⟨ elim-∣∣≡∣∣ ⟩∎ g n x ∎ from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣ʳ _ → refl _ .∣∣≡∣∣ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong (from (to h)) (∣∣≡∣∣ x))) (trans (cong (subst Q (∣∣≡∣∣ x)) (refl _)) (dcong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) elim-∣∣≡∣∣ (trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _) ⟩ trans (sym (dcong h (∣∣≡∣∣ x))) (dcong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ ------------------------------------------------------------------------ -- Some conversion functions -- E.Colimitᴱ P step implies Colimit P step. Colimitᴱ→Colimit : {step : ∀ {n} → P n → P (suc n)} → E.Colimitᴱ P step → Colimit P step Colimitᴱ→Colimit = E.rec λ where .E.∣∣ʳ → ∣_∣ .E.∣∣≡∣∣ʳ → ∣∣≡∣∣ -- In erased contexts E.Colimitᴱ P step is equivalent to -- Colimit P step. @0 Colimitᴱ≃Colimit : {step : ∀ {n} → P n → P (suc n)} → E.Colimitᴱ P step ≃ Colimit P step Colimitᴱ≃Colimit = Eq.↔→≃ Colimitᴱ→Colimit Colimit→Colimitᴱ (elim λ @0 where .∣∣ʳ _ → refl _ .∣∣≡∣∣ʳ x → subst (λ x → Colimitᴱ→Colimit (Colimit→Colimitᴱ x) ≡ x) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (Colimitᴱ→Colimit ∘ Colimit→Colimitᴱ) (∣∣≡∣∣ x))) (trans (refl _) (cong id (∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ _ _) $ trans (cong (cong Colimitᴱ→Colimit) rec-∣∣≡∣∣) $ E.rec-∣∣≡∣∣) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (∣∣≡∣∣ x)) (∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) (E.elim λ where .E.∣∣ʳ _ → refl _ .E.∣∣≡∣∣ʳ x → subst (λ x → Colimit→Colimitᴱ (Colimitᴱ→Colimit x) ≡ x) (E.∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (Colimit→Colimitᴱ ∘ Colimitᴱ→Colimit) (E.∣∣≡∣∣ x))) (trans (refl _) (cong id (E.∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ _ _) $ trans (cong (cong Colimit→Colimitᴱ) E.rec-∣∣≡∣∣) $ rec-∣∣≡∣∣) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (E.∣∣≡∣∣ x)) (E.∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) where Colimit→Colimitᴱ = rec λ @0 where .∣∣ʳ → E.∣_∣ .∣∣≡∣∣ʳ → E.∣∣≡∣∣ -- Some instances of VE.Colimitᴱ can be converted to instances of -- Colimit. Note that P₀ and P₊ target the same universe. Very-Colimitᴱ→Colimit : {P₀ : Type p} {P₊ : ℕ → Type p} {step₀ : P₀ → P₊ zero} → {step₊ : ∀ {n} → P₊ n → P₊ (suc n)} → VE.Colimitᴱ P₀ P₊ step₀ step₊ → Colimit (ℕ-rec P₀ (λ n _ → P₊ n)) (λ {n} → ℕ-rec {P = λ n → ℕ-rec P₀ (λ n _ → P₊ n) n → P₊ n} step₀ (λ _ _ → step₊) n) Very-Colimitᴱ→Colimit = VE.rec λ where .VE.∣∣₀ʳ → ∣_∣ {n = 0} .VE.∣∣₊ʳ → ∣_∣ .VE.∣∣₊≡∣∣₀ʳ → ∣∣≡∣∣ .VE.∣∣₊≡∣∣₊ʳ → ∣∣≡∣∣ -- In erased contexts there are equivalences between some instances of -- VE.Colimitᴱ and some instances of Colimit. @0 Very-Colimitᴱ≃Colimit : {P₀ : Type p} {P₊ : ℕ → Type p} {step₀ : P₀ → P₊ zero} → {step₊ : ∀ {n} → P₊ n → P₊ (suc n)} → VE.Colimitᴱ P₀ P₊ step₀ step₊ ≃ Colimit (ℕ-rec P₀ (λ n _ → P₊ n)) (λ {n} → ℕ-rec {P = λ n → ℕ-rec P₀ (λ n _ → P₊ n) n → P₊ n} step₀ (λ _ _ → step₊) n) Very-Colimitᴱ≃Colimit = Eq.↔→≃ Very-Colimitᴱ→Colimit Colimit→Colimitᴱ (elim λ @0 where .∣∣ʳ {n = zero} _ → refl _ .∣∣ʳ {n = suc _} _ → refl _ .∣∣≡∣∣ʳ {n = zero} x → subst (λ x → Very-Colimitᴱ→Colimit (Colimit→Colimitᴱ x) ≡ x) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (Very-Colimitᴱ→Colimit ∘ Colimit→Colimitᴱ) (∣∣≡∣∣ x))) (trans (refl _) (cong id (∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ _ _) $ trans (cong (cong Very-Colimitᴱ→Colimit) rec-∣∣≡∣∣) $ VE.rec-∣∣₊≡∣∣₀) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (∣∣≡∣∣ x)) (∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ .∣∣≡∣∣ʳ {n = suc _} x → subst (λ x → Very-Colimitᴱ→Colimit (Colimit→Colimitᴱ x) ≡ x) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (Very-Colimitᴱ→Colimit ∘ Colimit→Colimitᴱ) (∣∣≡∣∣ x))) (trans (refl _) (cong id (∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ _ _) $ trans (cong (cong Very-Colimitᴱ→Colimit) rec-∣∣≡∣∣) $ VE.rec-∣∣₊≡∣∣₊) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (∣∣≡∣∣ x)) (∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) (VE.elim λ where .VE.∣∣₀ʳ _ → refl _ .VE.∣∣₊ʳ _ → refl _ .VE.∣∣₊≡∣∣₀ʳ x → subst (λ x → Colimit→Colimitᴱ (Very-Colimitᴱ→Colimit x) ≡ x) (VE.∣∣₊≡∣∣₀ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (Colimit→Colimitᴱ ∘ Very-Colimitᴱ→Colimit) (VE.∣∣₊≡∣∣₀ x))) (trans (refl _) (cong id (VE.∣∣₊≡∣∣₀ x))) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ _ _) $ trans (cong (cong Colimit→Colimitᴱ) VE.rec-∣∣₊≡∣∣₀) $ rec-∣∣≡∣∣) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (VE.∣∣₊≡∣∣₀ x)) (VE.∣∣₊≡∣∣₀ x) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ .VE.∣∣₊≡∣∣₊ʳ x → subst (λ x → Colimit→Colimitᴱ (Very-Colimitᴱ→Colimit x) ≡ x) (VE.∣∣₊≡∣∣₊ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (Colimit→Colimitᴱ ∘ Very-Colimitᴱ→Colimit) (VE.∣∣₊≡∣∣₊ x))) (trans (refl _) (cong id (VE.∣∣₊≡∣∣₊ x))) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ _ _) $ trans (cong (cong Colimit→Colimitᴱ) VE.rec-∣∣₊≡∣∣₊) $ rec-∣∣≡∣∣) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (VE.∣∣₊≡∣∣₊ x)) (VE.∣∣₊≡∣∣₊ x) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) where Colimit→Colimitᴱ = rec λ @0 where .∣∣ʳ {n = zero} → VE.∣_∣₀ .∣∣ʳ {n = suc _} → VE.∣_∣₊ .∣∣≡∣∣ʳ {n = zero} → VE.∣∣₊≡∣∣₀ .∣∣≡∣∣ʳ {n = suc _} → VE.∣∣₊≡∣∣₊
{ "alphanum_fraction": 0.3633509787, "avg_line_length": 37.519630485, "ext": "agda", "hexsha": "121568bb204132ab3fa7bc08e0f216b2da6e095e", "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/Colimit/Sequential.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/Colimit/Sequential.agda", "max_line_length": 128, "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/Colimit/Sequential.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": 6375, "size": 16246 }
{-# OPTIONS --without-K #-} {- Adapted from Ulrik's work in Lean (released under Apache License 2.0) https://github.com/leanprover/lean/blob/master/hott/homotopy/cellcomplex.hlean -} open import HoTT module cw.CW where open import cw.Attached public {- Naming convension: most of them have the "cw-" prefix -} -- skeleton Skeleton : ∀ {i} → ℕ → Type (lsucc i) Realizer : ∀ {i} {n : ℕ} → Skeleton {i} n → Type i Skeleton {i} O = Type i Skeleton {i} (S n) = Σ (Skeleton {i} n) (λ s → Σ (Type i) λ A → Attaching (Realizer s) A (Sphere n)) Realizer {n = O} A = A Realizer {n = S n} (s , (A , attaching)) = Attached attaching ⟦_⟧ = Realizer -- Take a prefix of a skeleton cw-take : ∀ {i} {m n : ℕ} (m≤n : m ≤ n) → Skeleton {i} n → Skeleton {i} m cw-take (inl idp) skel = skel cw-take (inr ltS) (skel , _) = skel cw-take (inr (ltSR m≤n)) (skel , _) = cw-take (inr m≤n) skel cw-head : ∀ {i} {n : ℕ} → Skeleton {i} n → Type i cw-head {n = O} = cw-take (inl idp) cw-head {n = S n} = cw-take (inr (O<S n)) incl^ : ∀ {i} {n : ℕ} (skel : Skeleton {i} n) → cw-head skel → ⟦ skel ⟧ incl^ {n = O} skel c = c incl^ {n = S O} (skel , _) c = incl c incl^ {n = S (S n)} (skel , _) c = incl (incl^ skel c) -- Pointedness ⊙Skeleton : ∀ {i} (n : ℕ) → Type (lsucc i) ⊙Skeleton n = Σ (Skeleton n) cw-head ⊙Realizer : ∀ {i} {n : ℕ} → ⊙Skeleton {i} n → Ptd i ⊙Realizer (skel , pt) = ⟦ skel ⟧ , incl^ skel pt ⊙⟦_⟧ = ⊙Realizer -- Access the [m]th cells cells-last : ∀ {i} {n : ℕ} → Skeleton {i} n → Type i cells-last {n = O} skel = skel cells-last {n = S n} (_ , cells , _) = cells cells-nth : ∀ {i} {m n : ℕ} (m≤n : m ≤ n) → Skeleton {i} n → Type i cells-nth m≤n = cells-last ∘ cw-take m≤n -- Access the [m]th dimensional attaching map Sphere₋₁ : ℕ → Type₀ Sphere₋₁ O = Empty Sphere₋₁ (S n) = Sphere n Realizer₋₁ : ∀ {i} {n : ℕ} → Skeleton {i} n → Type i Realizer₋₁ {n = O} _ = Lift Empty Realizer₋₁ {n = S n} (skel , _) = ⟦ skel ⟧ ⟦_⟧₋₁ = Realizer₋₁ attaching-last : ∀ {i} {n : ℕ} (s : Skeleton {i} n) → cells-last s → (Sphere₋₁ n → ⟦ s ⟧₋₁) attaching-last {n = O} _ = λ{_ ()} attaching-last {n = S n} (_ , _ , attaching) = attaching attaching-nth : ∀ {i} {m n : ℕ} (m≤n : m ≤ n) (skel : Skeleton {i} n) → cells-nth m≤n skel → Sphere₋₁ m → ⟦ cw-take m≤n skel ⟧₋₁ attaching-nth m≤n = attaching-last ∘ cw-take m≤n -- Misc -- Extra conditions on CW complexes -- XXX Needs a better name has-dec-cells : ∀ {i} {n} → Skeleton {i} n → Type i has-dec-cells {n = 0} skel = has-dec-eq skel has-dec-cells {n = S n} (skel , cells , _) = has-dec-cells skel × has-dec-eq cells -- Extra conditions on CW complexes for constructive degrees -- The ideas is that boundaries maps need to be pointed after contraction -- XXX Needs a better name is-aligned : ∀ {i} {n} → Skeleton {i} n → Type i is-aligned {n = 0} _ = Lift ⊤ is-aligned {n = 1} _ = Lift ⊤ is-aligned {n = S (S n)} (skel , _ , boundary) = is-aligned skel × (∀ c → hfiber incl (boundary c north)) {- Some basic CWs -} -- Empty CWEmpty-skel : Skeleton {lzero} 0 CWEmpty-skel = Empty CWEmpty = ⟦ CWEmpty-skel ⟧ CWEmpty≃Empty : CWEmpty ≃ Empty CWEmpty≃Empty = ide _ CWEmpty-is-aligned : is-aligned CWEmpty-skel CWEmpty-is-aligned = lift tt -- Unit CWUnit-skel : Skeleton {lzero} 0 CWUnit-skel = Unit CWUnit = ⟦ CWUnit-skel ⟧ CWUnit≃Unit : CWUnit ≃ Unit CWUnit≃Unit = ide _ CWUnit-is-aligned : is-aligned CWUnit-skel CWUnit-is-aligned = lift tt {- Basic transformation -} -- dimension lifting cw-lift₁ : ∀ {i} {n : ℕ} → Skeleton {i} n → Skeleton {i} (S n) cw-lift₁ skel = skel , Lift Empty , λ{(lift ()) _} -- This slightly extends the naming convension -- to two skeletons being extensionally equal. cw-lift₁-equiv : ∀ {i} {n} (skel : Skeleton {i} n) → ⟦ cw-lift₁ skel ⟧ ≃ ⟦ skel ⟧ cw-lift₁-equiv skel = equiv to incl to-incl incl-to where to : ⟦ cw-lift₁ skel ⟧ → ⟦ skel ⟧ to = Attached-rec (idf ⟦ skel ⟧) (λ{(lift ())}) (λ{(lift ()) _}) to-incl : ∀ x → to (incl x) == x to-incl _ = idp incl-to : ∀ x → incl (to x) == x incl-to = Attached-elim (λ _ → idp) (λ{(lift ())}) (λ{(lift ()) _}) cw-lift : ∀ {i} {n m : ℕ} → n < m → Skeleton {i} n → Skeleton {i} m cw-lift ltS = cw-lift₁ cw-lift (ltSR lt) = cw-lift₁ ∘ cw-lift lt
{ "alphanum_fraction": 0.5842800835, "avg_line_length": 27.2974683544, "ext": "agda", "hexsha": "bcf4bed14ff07394bdd81be33bdedce99113de44", "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/cw/CW.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/cw/CW.agda", "max_line_length": 82, "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/cw/CW.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1697, "size": 4313 }
module Inductive.Examples.Unit where open import Inductive open import Tuple open import Data.Fin open import Data.Product open import Data.List open import Data.Vec ⊤ : Set ⊤ = Inductive (([] , []) ∷ []) unit : ⊤ unit = construct zero [] []
{ "alphanum_fraction": 0.6991869919, "avg_line_length": 15.375, "ext": "agda", "hexsha": "cbfd8af310ac7adbb38daa45aa5038b64fa18b41", "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": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mr-ohman/general-induction", "max_forks_repo_path": "Inductive/Examples/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "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": "mr-ohman/general-induction", "max_issues_repo_path": "Inductive/Examples/Unit.agda", "max_line_length": 36, "max_stars_count": null, "max_stars_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mr-ohman/general-induction", "max_stars_repo_path": "Inductive/Examples/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 69, "size": 246 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for "equational reasoning" using a preorder ------------------------------------------------------------------------ -- I think that the idea behind this library is originally Ulf -- Norell's. I have adapted it to my tastes and mixfix operators, -- though. -- If you need to use several instances of this module in a given -- file, then you can use the following approach: -- -- import Relation.Binary.PreorderReasoning as Pre -- -- f x y z = begin -- ... -- ∎ -- where open Pre preorder₁ -- -- g i j = begin -- ... -- ∎ -- where open Pre preorder₂ open import Relation.Binary module Relation.Binary.PreorderReasoning {p₁ p₂ p₃} (P : Preorder p₁ p₂ p₃) where open Preorder P infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _∼⟨_⟩_ _≈⟨_⟩_ _≈⟨⟩_ infix 1 begin_ -- This seemingly unnecessary type is used to make it possible to -- infer arguments even if the underlying equality evaluates. data _IsRelatedTo_ (x y : Carrier) : Set p₃ where relTo : (x∼y : x ∼ y) → x IsRelatedTo y begin_ : ∀ {x y} → x IsRelatedTo y → x ∼ y begin relTo x∼y = x∼y _∼⟨_⟩_ : ∀ x {y z} → x ∼ y → y IsRelatedTo z → x IsRelatedTo z _ ∼⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z) _≈⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z _ ≈⟨ x≈y ⟩ relTo y∼z = relTo (trans (reflexive x≈y) y∼z) _≈⟨⟩_ : ∀ x {y} → x IsRelatedTo y → x IsRelatedTo y _ ≈⟨⟩ x∼y = x∼y _∎ : ∀ x → x IsRelatedTo x _∎ _ = relTo refl
{ "alphanum_fraction": 0.5770953295, "avg_line_length": 26.9482758621, "ext": "agda", "hexsha": "2bd974aa8a2edbad2580f77405a21cd8a91c843b", "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/PreorderReasoning.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/PreorderReasoning.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/PreorderReasoning.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": 541, "size": 1563 }
{-# OPTIONS --without-K --safe #-} open import Algebra.Structures.Bundles.Field module Algebra.Linear.Structures.GL {k ℓᵏ} (K : Field k ℓᵏ) {a ℓ} where open import Relation.Binary using (Setoid) open import Algebra.Linear.Structures.Bundles open import Algebra.Linear.Morphism.Bundles K open import Categories.Category open LinearMap
{ "alphanum_fraction": 0.7645348837, "avg_line_length": 21.5, "ext": "agda", "hexsha": "4eafe2d8c371814a80ff54d241b73b73a757d212", "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": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_path": "src/Algebra/Linear/Structures/GL.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "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": "felko/linear-algebra", "max_issues_repo_path": "src/Algebra/Linear/Structures/GL.agda", "max_line_length": 45, "max_stars_count": 15, "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_path": "src/Algebra/Linear/Structures/GL.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "num_tokens": 90, "size": 344 }
module Imports.TheWrongName where
{ "alphanum_fraction": 0.8823529412, "avg_line_length": 17, "ext": "agda", "hexsha": "59ae61b3338e1a5cac3db115c61d21d04ea990e7", "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/Imports/WronglyNamedModule.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/Imports/WronglyNamedModule.agda", "max_line_length": 33, "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/Imports/WronglyNamedModule.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 7, "size": 34 }
-- Prop has been removed from the language module PropNoMore where postulate X : Prop
{ "alphanum_fraction": 0.7640449438, "avg_line_length": 14.8333333333, "ext": "agda", "hexsha": "63b231dc0040a3ca1b85f86599753ac8ee124ca6", "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": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/PropNoMore.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/PropNoMore.agda", "max_line_length": 42, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/PropNoMore.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 23, "size": 89 }
{-A Polynomials over commutative rings ================================== -} {-# OPTIONS --safe #-} ---------------------------------- module Cubical.Algebra.Polynomials where open import Cubical.HITs.PropositionalTruncation open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Nat renaming (_+_ to _Nat+_; _·_ to _Nat·_) hiding (·-comm) open import Cubical.Data.Nat.Order open import Cubical.Data.Empty.Base renaming (rec to ⊥rec ) open import Cubical.Data.Bool open import Cubical.Algebra.Group hiding (Bool) open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing ------------------------------------------------------------------------------------ private variable ℓ ℓ' : Level A : Type ℓ module PolyMod (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') public ------------------------------------------------------------------------------------------- -- First definition of a polynomial. -- A polynomial a₁ + a₂x + ... + aⱼxʲ of degree j is represented as a list [a₁, a₂, ...,aⱼ] -- modulo trailing zeros. ------------------------------------------------------------------------------------------- data Poly : Type ℓ where [] : Poly _∷_ : (a : R) → (p : Poly) → Poly drop0 : 0r ∷ [] ≡ [] infixr 5 _∷_ module Elim (B : Poly → Type ℓ') ([]* : B []) (cons* : (r : R) (p : Poly) (b : B p) → B (r ∷ p)) (drop0* : PathP (λ i → B (drop0 i)) (cons* 0r [] []*) []*) where f : (p : Poly) → B p f [] = []* f (x ∷ p) = cons* x p (f p) f (drop0 i) = drop0* i -- Given a proposition (as type) ϕ ranging over polynomials, we prove it by: -- ElimProp.f ϕ ⌜proof for base case []⌝ ⌜proof for induction case a ∷ p⌝ -- ⌜proof that ϕ actually is a proposition over the domain of polynomials⌝ module ElimProp (B : Poly → Type ℓ') ([]* : B []) (cons* : (r : R) (p : Poly) (b : B p) → B (r ∷ p)) (BProp : {p : Poly} → isProp (B p)) where f : (p : Poly) → B p f = Elim.f B []* cons* (toPathP (BProp (transport (λ i → B (drop0 i)) (cons* 0r [] []*)) []*)) module Rec (B : Type ℓ') ([]* : B) (cons* : R → B → B) (drop0* : cons* 0r []* ≡ []*) (Bset : isSet B) where f : Poly → B f = Elim.f (λ _ → B) []* (λ r p b → cons* r b) drop0* module RecPoly ([]* : Poly) (cons* : R → Poly → Poly) (drop0* : cons* 0r []* ≡ []*) where f : Poly → Poly f [] = []* f (a ∷ p) = cons* a (f p) f (drop0 i) = drop0* i -------------------------------------------------------------------------------------------------- -- Second definition of a polynomial. The purpose of this second definition is to -- facilitate the proof that the first definition is a set. The two definitions are -- then shown to be equivalent. -- A polynomial a₀ + a₁x + ... + aⱼxʲ of degree j is represented as a function f -- such that for i ∈ ℕ we have f(i) = aᵢ if i ≤ j, and 0 for i > j -------------------------------------------------------------------------------------------------- PolyFun : Type ℓ PolyFun = Σ[ p ∈ (ℕ → R) ] (∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → p m ≡ 0r)) isSetPolyFun : isSet PolyFun isSetPolyFun = isSetΣSndProp (isSetΠ (λ x → isSetCommRing R')) λ f x y → squash x y --construction of the function that represents the polynomial Poly→Fun : Poly → (ℕ → R) Poly→Fun [] = (λ _ → 0r) Poly→Fun (a ∷ p) = (λ n → if isZero n then a else Poly→Fun p (predℕ n)) Poly→Fun (drop0 i) = lemma i where lemma : (λ n → if isZero n then 0r else 0r) ≡ (λ _ → 0r) lemma i zero = 0r lemma i (suc n) = 0r Poly→Prf : (p : Poly) → ∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → (Poly→Fun p m ≡ 0r)) Poly→Prf = ElimProp.f (λ p → ∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → (Poly→Fun p m ≡ 0r))) ∣ 0 , (λ m ineq → refl) ∣ (λ r p → map ( λ (n , ineq) → (suc n) , λ { zero h → ⊥rec (znots (sym (≤0→≡0 h))) ; (suc m) h → ineq m (pred-≤-pred h) } ) ) squash Poly→PolyFun : Poly → PolyFun Poly→PolyFun p = (Poly→Fun p) , (Poly→Prf p) ---------------------------------------------------- -- Start of code by Anders Mörtberg and Evan Cavallo at0 : (ℕ → R) → R at0 f = f 0 atS : (ℕ → R) → (ℕ → R) atS f n = f (suc n) polyEq : (p p' : Poly) → Poly→Fun p ≡ Poly→Fun p' → p ≡ p' polyEq [] [] _ = refl polyEq [] (a ∷ p') α = sym drop0 ∙∙ cong₂ _∷_ (cong at0 α) (polyEq [] p' (cong atS α)) ∙∙ refl polyEq [] (drop0 j) α k = hcomp (λ l → λ { (j = i1) → drop0 l ; (k = i0) → drop0 l ; (k = i1) → drop0 (j ∧ l) }) (is-set 0r 0r (cong at0 α) refl j k ∷ []) polyEq (a ∷ p) [] α = refl ∙∙ cong₂ _∷_ (cong at0 α) (polyEq p [] (cong atS α)) ∙∙ drop0 polyEq (a ∷ p) (a₁ ∷ p') α = cong₂ _∷_ (cong at0 α) (polyEq p p' (cong atS α)) polyEq (a ∷ p) (drop0 j) α k = hcomp -- filler (λ l → λ { (k = i0) → a ∷ p ; (k = i1) → drop0 (j ∧ l) ; (j = i0) → at0 (α k) ∷ polyEq p [] (cong atS α) k }) (at0 (α k) ∷ polyEq p [] (cong atS α) k) polyEq (drop0 i) [] α k = hcomp (λ l → λ { (i = i1) → drop0 l ; (k = i0) → drop0 (i ∧ l) ; (k = i1) → drop0 l }) (is-set 0r 0r (cong at0 α) refl i k ∷ []) polyEq (drop0 i) (a ∷ p') α k = hcomp -- filler (λ l → λ { (k = i0) → drop0 (i ∧ l) ; (k = i1) → a ∷ p' ; (i = i0) → at0 (α k) ∷ polyEq [] p' (cong atS α) k }) (at0 (α k) ∷ polyEq [] p' (cong atS α) k) polyEq (drop0 i) (drop0 j) α k = hcomp (λ l → λ { (k = i0) → drop0 (i ∧ l) ; (k = i1) → drop0 (j ∧ l) ; (i = i0) (j = i0) → at0 (α k) ∷ [] ; (i = i1) (j = i1) → drop0 l }) (is-set 0r 0r (cong at0 α) refl (i ∧ j) k ∷ []) PolyFun→Poly+ : (q : PolyFun) → Σ[ p ∈ Poly ] Poly→Fun p ≡ q .fst PolyFun→Poly+ (f , pf) = rec lem (λ x → rem1 f (x .fst) (x .snd) , funExt (rem2 f (fst x) (snd x)) ) pf where lem : isProp (Σ[ p ∈ Poly ] Poly→Fun p ≡ f) lem (p , α) (p' , α') = ΣPathP (polyEq p p' (α ∙ sym α'), isProp→PathP (λ i → (isSetΠ λ _ → is-set) _ _) _ _) rem1 : (p : ℕ → R) (n : ℕ) → ((m : ℕ) → n ≤ m → p m ≡ 0r) → Poly rem1 p zero h = [] rem1 p (suc n) h = p 0 ∷ rem1 (λ x → p (suc x)) n (λ m x → h (suc m) (suc-≤-suc x)) rem2 : (f : ℕ → R) (n : ℕ) → (h : (m : ℕ) → n ≤ m → f m ≡ 0r) (m : ℕ) → Poly→Fun (rem1 f n h) m ≡ f m rem2 f zero h m = sym (h m zero-≤) rem2 f (suc n) h zero = refl rem2 f (suc n) h (suc m) = rem2 (λ x → f (suc x)) n (λ k p → h (suc k) (suc-≤-suc p)) m PolyFun→Poly : PolyFun → Poly PolyFun→Poly q = PolyFun→Poly+ q .fst PolyFun→Poly→PolyFun : (p : Poly) → PolyFun→Poly (Poly→PolyFun p) ≡ p PolyFun→Poly→PolyFun p = polyEq _ _ (PolyFun→Poly+ (Poly→PolyFun p) .snd) --End of code by Mörtberg and Cavallo ------------------------------------- isSetPoly : isSet Poly isSetPoly = isSetRetract Poly→PolyFun PolyFun→Poly PolyFun→Poly→PolyFun isSetPolyFun ------------------------------------------------- -- The rest of the file uses the first definition ------------------------------------------------- open CommRingTheory R' open RingTheory (CommRing→Ring R') open GroupTheory (Ring→Group (CommRing→Ring R')) pattern [_] x = x ∷ [] --------------------------------------- -- Definition -- Identity for addition of polynomials --------------------------------------- 0P : Poly 0P = [] --ReplicatePoly(n,p) returns 0 ∷ 0 ∷ ... ∷ [] (n zeros) ReplicatePoly0 : (n : ℕ) → Poly ReplicatePoly0 zero = 0P ReplicatePoly0 (suc n) = 0r ∷ ReplicatePoly0 n --The empty polynomial has multiple equal representations on the form 0 + 0x + 0 x² + ... replicatePoly0Is0P : ∀ (n : ℕ) → ReplicatePoly0 n ≡ 0P replicatePoly0Is0P zero = refl replicatePoly0Is0P (suc n) = (cong (0r ∷_) (replicatePoly0Is0P n)) ∙ drop0 ----------------------------- -- Definition -- subtraction of polynomials ----------------------------- Poly- : Poly → Poly Poly- [] = [] Poly- (a ∷ p) = (- a) ∷ (Poly- p) Poly- (drop0 i) = (cong (_∷ []) (inv1g) ∙ drop0) i -- Double negation (of subtraction of polynomials) is the identity mapping Poly-Poly- : (p : Poly) → Poly- (Poly- p) ≡ p Poly-Poly- = ElimProp.f (λ x → Poly- (Poly- x) ≡ x) refl (λ a p e → cong (_∷ (Poly- (Poly- p))) (-Idempotent a) ∙ cong (a ∷_ ) (e)) (isSetPoly _ _) --------------------------- -- Definition -- addition for polynomials --------------------------- _Poly+_ : Poly → Poly → Poly p Poly+ [] = p [] Poly+ (drop0 i) = drop0 i [] Poly+ (b ∷ q) = b ∷ q (a ∷ p) Poly+ (b ∷ q) = (a + b) ∷ (p Poly+ q) (a ∷ p) Poly+ (drop0 i) = +Rid a i ∷ p (drop0 i) Poly+ (a ∷ q) = lem q i where lem : ∀ q → (0r + a) ∷ ([] Poly+ q) ≡ a ∷ q lem = ElimProp.f (λ q → (0r + a) ∷ ([] Poly+ q) ≡ a ∷ q) (λ i → (+Lid a i ∷ [])) (λ r p _ → λ i → +Lid a i ∷ r ∷ p ) (isSetPoly _ _) (drop0 i) Poly+ (drop0 j) = isSet→isSet' isSetPoly (cong ([_] ) (+Rid 0r)) drop0 (cong ([_] ) (+Lid 0r)) drop0 i j -- [] is the left identity for Poly+ Poly+Lid : ∀ p → ([] Poly+ p ≡ p) Poly+Lid = ElimProp.f (λ p → ([] Poly+ p ≡ p) ) refl (λ r p prf → refl) (λ x y → isSetPoly _ _ x y) -- [] is the right identity for Poly+ Poly+Rid : ∀ p → (p Poly+ [] ≡ p) Poly+Rid p = refl --Poly+ is Associative Poly+Assoc : ∀ p q r → p Poly+ (q Poly+ r) ≡ (p Poly+ q) Poly+ r Poly+Assoc = ElimProp.f (λ p → (∀ q r → p Poly+ (q Poly+ r) ≡ (p Poly+ q) Poly+ r)) (λ q r → Poly+Lid (q Poly+ r) ∙ cong (_Poly+ r) (sym (Poly+Lid q))) (λ a p prf → ElimProp.f ((λ q → ∀ r → ((a ∷ p) Poly+ (q Poly+ r)) ≡ (((a ∷ p) Poly+ q) Poly+ r))) (λ r → cong ((a ∷ p) Poly+_) (Poly+Lid r)) (λ b q prf2 → ElimProp.f (λ r → ((a ∷ p) Poly+ ((b ∷ q) Poly+ r)) ≡ ((a + b ∷ (p Poly+ q)) Poly+ r)) refl (λ c r prfp → cong ((a + (b + c))∷_) (prf q r) ∙ (cong (_∷ ((p Poly+ q) Poly+ r)) (+Assoc a b c))) (isSetPoly _ _)) λ x y i r → isSetPoly (x r i0) (y r i1) (x r) (y r) i) λ x y i q r → isSetPoly _ _ (x q r) (y q r) i -- for any polynomial, p, the additive inverse is given by Poly- p Poly+Inverses : ∀ p → p Poly+ (Poly- p) ≡ [] Poly+Inverses = ElimProp.f ( λ p → p Poly+ (Poly- p) ≡ []) refl --(Poly+Lid (Poly- [])) (λ r p prf → cong (r + - r ∷_) prf ∙ (cong (_∷ []) (+Rinv r) ∙ drop0)) (isSetPoly _ _) --Poly+ is commutative Poly+Comm : ∀ p q → p Poly+ q ≡ q Poly+ p Poly+Comm = ElimProp.f (λ p → (∀ q → p Poly+ q ≡ q Poly+ p)) (λ q → Poly+Lid q) (λ a p prf → ElimProp.f (λ q → ((a ∷ p) Poly+ q) ≡ (q Poly+ (a ∷ p))) refl (λ b q prf2 → cong (_∷ (p Poly+ q)) (+Comm a b) ∙ cong ((b + a) ∷_) (prf q)) (isSetPoly _ _) ) (λ {p} → isPropΠ (λ q → isSetPoly (p Poly+ q) (q Poly+ p))) -------------------------------------------------------------- -- Definition -- multiplication of a polynomial by a (constant) ring element -------------------------------------------------------------- _PolyConst*_ : (R) → Poly → Poly r PolyConst* [] = [] r PolyConst* (a ∷ p) = (r · a) ∷ (r PolyConst* p) r PolyConst* (drop0 i) = lem r i where lem : ∀ r → [ r · 0r ] ≡ [] lem = λ r → [ r · 0r ] ≡⟨ cong (_∷ []) (0RightAnnihilates r) ⟩ [ 0r ] ≡⟨ drop0 ⟩ [] ∎ -- For any polynomial p we have: 0 _PolyConst*_ p = [] 0rLeftAnnihilatesPoly : ∀ q → 0r PolyConst* q ≡ [ 0r ] 0rLeftAnnihilatesPoly = ElimProp.f (λ q → 0r PolyConst* q ≡ [ 0r ]) (sym drop0) (λ r p prf → cong ((0r · r) ∷_) prf ∙ cong (_∷ [ 0r ]) (0LeftAnnihilates r) ∙ cong (0r ∷_) drop0 ) λ x y → isSetPoly _ _ x y -- For any polynomial p we have: 1 _PolyConst*_ p = p PolyConst*Lid : ∀ q → 1r PolyConst* q ≡ q PolyConst*Lid = ElimProp.f (λ q → 1r PolyConst* q ≡ q ) refl (λ a p prf → cong (_∷ (1r PolyConst* p)) (·Lid a) ∙ cong (a ∷_) (prf) ) λ x y → isSetPoly _ _ x y -------------------------------- -- Definition -- Multiplication of polynomials -------------------------------- _Poly*_ : Poly → Poly → Poly [] Poly* q = [] (a ∷ p) Poly* q = (a PolyConst* q) Poly+ (0r ∷ (p Poly* q)) (drop0 i) Poly* q = lem q i where lem : ∀ q → (0r PolyConst* q) Poly+ [ 0r ] ≡ [] lem = λ q → ((0r PolyConst* q) Poly+ [ 0r ]) ≡⟨ cong ( _Poly+ [ 0r ] ) (0rLeftAnnihilatesPoly q)⟩ ([ 0r ] Poly+ [ 0r ]) ≡⟨ cong (_∷ []) 0Idempotent ∙ drop0 ⟩ [] ∎ -------------------- --Definition --Identity for Poly* -------------------- 1P : Poly 1P = [ 1r ] -- For any polynomial p we have: p Poly* [] = [] 0PRightAnnihilates : ∀ q → 0P Poly* q ≡ 0P 0PRightAnnihilates = ElimProp.f (λ q → 0P Poly* q ≡ 0P) refl (λ r p prf → prf) λ x y → isSetPoly _ _ x y -- For any polynomial p we have: [] Poly* p = [] 0PLeftAnnihilates : ∀ p → p Poly* 0P ≡ 0P 0PLeftAnnihilates = ElimProp.f (λ p → p Poly* 0P ≡ 0P ) refl (λ r p prf → cong (0r ∷_) prf ∙ drop0) λ x y → isSetPoly _ _ x y -- For any polynomial p we have: p Poly* [ 1r ] = p Poly*Lid : ∀ q → 1P Poly* q ≡ q Poly*Lid = ElimProp.f (λ q → 1P Poly* q ≡ q) drop0 (λ r p prf → lemma r p) (λ x y → isSetPoly _ _ x y) where lemma : ∀ r p → 1r · r + 0r ∷ (1r PolyConst* p) ≡ r ∷ p lemma = λ r p → 1r · r + 0r ∷ (1r PolyConst* p) ≡⟨ cong (_∷ (1r PolyConst* p) ) (+Rid (1r · r)) ⟩ 1r · r ∷ (1r PolyConst* p) ≡⟨ cong (_∷ 1r PolyConst* p) (·Lid r) ⟩ r ∷ (1r PolyConst* p) ≡⟨ cong (r ∷_) (PolyConst*Lid p) ⟩ r ∷ p ∎ -- Distribution of indeterminate: (p + q)x = px + qx XLDistrPoly+ : ∀ p q → (0r ∷ (p Poly+ q)) ≡ ((0r ∷ p) Poly+ (0r ∷ q)) XLDistrPoly+ = ElimProp.f (λ p → ∀ q → (0r ∷ (p Poly+ q)) ≡ ((0r ∷ p) Poly+ (0r ∷ q)) ) (λ q → (cong (0r ∷_) (Poly+Lid q)) ∙ cong (0r ∷_) (sym (Poly+Lid q)) ∙ sym (cong (_∷ [] Poly+ q) (+Lid 0r))) (λ a p prf → ElimProp.f (λ q → 0r ∷ ((a ∷ p) Poly+ q) ≡ ((0r ∷ a ∷ p) Poly+ (0r ∷ q))) (cong (_∷ a ∷ p ) (sym (+Lid 0r))) (λ b q prf2 → cong (_∷ a + b ∷ (p Poly+ q)) (sym (+Lid 0r))) (λ x y i → isSetPoly (x i0) (x i1) x y i)) (λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i) -- Distribution of a constant ring element over added polynomials p, q: a (p + q) = ap + aq PolyConst*LDistrPoly+ : ∀ a p q → a PolyConst* (p Poly+ q) ≡ (a PolyConst* p) Poly+ (a PolyConst* q) PolyConst*LDistrPoly+ = λ a → ElimProp.f (λ p → ∀ q → a PolyConst* (p Poly+ q) ≡ (a PolyConst* p) Poly+ (a PolyConst* q)) (λ q → cong (a PolyConst*_) (Poly+Lid q) ∙ (sym (Poly+Lid (a PolyConst* q)))) (λ b p prf → ElimProp.f (λ q → (a PolyConst* ((b ∷ p) Poly+ q)) ≡ (a PolyConst* (b ∷ p)) Poly+ (a PolyConst* q)) refl (λ c q prf2 → cong (_∷ (a PolyConst* (p Poly+ q))) (·Rdist+ a b c) ∙ cong (a · b + a · c ∷_) (prf q)) (isSetPoly _ _)) (λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i) --Poly* left distributes over Poly+ Poly*LDistrPoly+ : ∀ p q r → p Poly* (q Poly+ r) ≡ (p Poly* q) Poly+ (p Poly* r) Poly*LDistrPoly+ = ElimProp.f (λ p → ∀ q r → p Poly* (q Poly+ r) ≡ (p Poly* q) Poly+ (p Poly* r)) (λ _ _ → refl) (λ a p prf q r → ((a PolyConst* (q Poly+ r)) Poly+ (0r ∷(p Poly*(q Poly+ r)))) ≡⟨ cong (_Poly+ (0r ∷ (p Poly* (q Poly+ r)))) (PolyConst*LDistrPoly+ a q r) ⟩ (((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+ (0r ∷ (p Poly* (q Poly+ r)))) ≡⟨ cong (((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+_) (cong (0r ∷_) (prf q r)) ⟩ (((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+ (0r ∷ ((p Poly* q) Poly+ (p Poly* r)))) ≡⟨ cong (((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+_) (XLDistrPoly+ (p Poly* q) (p Poly* r)) ⟩ (((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+ ((0r ∷ (p Poly* q)) Poly+ (0r ∷ (p Poly* r)))) ≡⟨ Poly+Assoc ((a PolyConst* q) Poly+ (a PolyConst* r)) (0r ∷ (p Poly* q)) (0r ∷ (p Poly* r)) ⟩ (((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+ (0r ∷ (p Poly* q))) Poly+ (0r ∷ (p Poly* r)) ≡⟨ cong (_Poly+ (0r ∷ (p Poly* r))) (sym (Poly+Assoc (a PolyConst* q) (a PolyConst* r) (0r ∷ (p Poly* q)))) ⟩ (((a PolyConst* q) Poly+ ((a PolyConst* r) Poly+ (0r ∷ (p Poly* q)))) Poly+ (0r ∷ (p Poly* r))) ≡⟨ cong (_Poly+ (0r ∷ (p Poly* r))) (cong ((a PolyConst* q) Poly+_) (Poly+Comm (a PolyConst* r) (0r ∷ (p Poly* q)))) ⟩ (((a PolyConst* q) Poly+ ((0r ∷ (p Poly* q)) Poly+ (a PolyConst* r))) Poly+ (0r ∷ (p Poly* r))) ≡⟨ cong (_Poly+ (0r ∷ (p Poly* r))) (Poly+Assoc (a PolyConst* q) (0r ∷ (p Poly* q)) (a PolyConst* r)) ⟩ ((((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) Poly+ (a PolyConst* r)) Poly+ (0r ∷ (p Poly* r))) ≡⟨ sym (Poly+Assoc ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) ((a PolyConst* r)) ((0r ∷ (p Poly* r)))) ⟩ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) Poly+ ((a PolyConst* r) Poly+ (0r ∷ (p Poly* r))) ∎) (λ x y i q r → isSetPoly _ _ (x q r) (y q r) i) -- The constant multiplication of a ring element, a, with a polynomial, p, can be -- expressed by polynomial multiplication with the singleton polynomial [ a ] PolyConst*r=Poly*[r] : ∀ a p → a PolyConst* p ≡ p Poly* [ a ] PolyConst*r=Poly*[r] = λ a → ElimProp.f (λ p → a PolyConst* p ≡ p Poly* [ a ]) refl ( λ r p prf → a · r ∷ (a PolyConst* p) ≡⟨ cong (a · r ∷_) prf ⟩ a · r ∷ (p Poly* [ a ]) ≡⟨ cong (a · r ∷_) (sym (Poly+Lid (p Poly* [ a ]))) ⟩ a · r ∷ ([] Poly+ (p Poly* [ a ])) ≡⟨ cong (_∷ ([] Poly+ (p Poly* [ a ]))) (·Comm a r ) ⟩ r · a ∷ ([] Poly+ (p Poly* [ a ])) ≡⟨ cong (_∷ ([] Poly+ (p Poly* [ a ]))) (sym (+Rid (r · a))) ⟩ r · a + 0r ∷ ([] Poly+ (p Poly* [ a ])) ∎) ( λ x y i → isSetPoly (x i0) (x i1) x y i) -- Connection between the constant multiplication and the multiplication in the ring PolyConst*Nested· : ∀ a b p → a PolyConst* (b PolyConst* p) ≡ (a · b) PolyConst* p PolyConst*Nested· = λ a b → ElimProp.f (λ p → a PolyConst* (b PolyConst* p) ≡ (a · b) PolyConst* p) refl (λ c p prf → cong ((a · (b · c)) ∷_) prf ∙ cong (_∷ ((a · b) PolyConst* p)) (·Assoc a b c)) (isSetPoly _ _) -- We can move the indeterminate from left to outside: px * q = (p * q)x 0r∷LeftAssoc : ∀ p q → (0r ∷ p) Poly* q ≡ 0r ∷ (p Poly* q) 0r∷LeftAssoc = ElimProp.f (λ p → ∀ q → (0r ∷ p) Poly* q ≡ 0r ∷ (p Poly* q)) (λ q → cong (_Poly+ [ 0r ])((cong (_Poly+ []) (0rLeftAnnihilatesPoly q))) ∙ cong (_∷ []) (+Lid 0r)) (λ r p b q → cong (_Poly+ (0r ∷ ((r PolyConst* q) Poly+ (0r ∷ (p Poly* q))))) ((0rLeftAnnihilatesPoly q) ∙ drop0)) (λ x y i q → isSetPoly _ _ (x q) (y q) i) --Associativity of constant multiplication in relation to polynomial multiplication PolyConst*AssocPoly* : ∀ a p q → a PolyConst* (p Poly* q) ≡ (a PolyConst* p) Poly* q PolyConst*AssocPoly* = λ a → ElimProp.f (λ p → ∀ q → a PolyConst* (p Poly* q) ≡ (a PolyConst* p) Poly* q) (λ q → refl) (λ b p prf q → a PolyConst* ((b PolyConst* q) Poly+ (0r ∷ (p Poly* q))) ≡⟨ PolyConst*LDistrPoly+ a (b PolyConst* q) (0r ∷ (p Poly* q)) ⟩ (a PolyConst* (b PolyConst* q)) Poly+ (a PolyConst* (0r ∷ (p Poly* q))) ≡⟨ cong (_Poly+ (a · 0r ∷ (a PolyConst* (p Poly* q)))) (PolyConst*Nested· a b q) ⟩ ((a · b) PolyConst* q) Poly+ (a PolyConst* (0r ∷ (p Poly* q))) ≡⟨ cong (((a · b) PolyConst* q) Poly+_) (cong (a · 0r ∷_) (PolyConst*r=Poly*[r] a (p Poly* q))) ⟩ ((a · b) PolyConst* q) Poly+ (a · 0r ∷ ((p Poly* q) Poly* [ a ])) ≡⟨ cong (((a · b) PolyConst* q) Poly+_) (cong (_∷ ((p Poly* q) Poly* [ a ])) (0RightAnnihilates a)) ⟩ ((a · b) PolyConst* q) Poly+ (0r ∷ ((p Poly* q) Poly* [ a ])) ≡⟨ cong (((a · b) PolyConst* q) Poly+_) (cong (0r ∷_) (sym (PolyConst*r=Poly*[r] a (p Poly* q)))) ⟩ ((a · b) PolyConst* q) Poly+ (0r ∷ (a PolyConst* (p Poly* q))) ≡⟨ cong (((a · b) PolyConst* q) Poly+_) (cong (0r ∷_) (prf q)) ⟩ ((a · b) PolyConst* q) Poly+ (0r ∷ ((a PolyConst* p) Poly* q)) ∎) (λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i) -- We can move the indeterminate from left to outside: p * qx = (p * q)x 0r∷RightAssoc : ∀ p q → p Poly* (0r ∷ q) ≡ 0r ∷ (p Poly* q) 0r∷RightAssoc = ElimProp.f (λ p → ∀ q → p Poly* (0r ∷ q) ≡ 0r ∷ (p Poly* q)) (λ q → sym drop0) (λ a p prf q → ((a ∷ p) Poly* (0r ∷ q)) ≡⟨ cong ( a · 0r + 0r ∷_) (cong ((a PolyConst* q) Poly+_ ) (prf q)) ⟩ a · 0r + 0r ∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) ≡⟨ cong (_∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q)))) ((+Rid (a · 0r))) ⟩ a · 0r ∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) ≡⟨ cong (_∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q)))) (0RightAnnihilates a) ⟩ 0r ∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) ∎) (λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i) -- We can move the indeterminate around: px * q = p * qx 0r∷Comm : ∀ p q → (0r ∷ p) Poly* q ≡ p Poly* (0r ∷ q) 0r∷Comm = ElimProp.f (λ p → ∀ q → (0r ∷ p) Poly* q ≡ p Poly* (0r ∷ q)) (λ q → (cong ((0r PolyConst* q) Poly+_) drop0) ∙ 0rLeftAnnihilatesPoly q ∙ drop0 ) (λ a p prf q → ((0r ∷ a ∷ p) Poly* q) ≡⟨ 0r∷LeftAssoc (a ∷ p) q ⟩ 0r ∷ ((a ∷ p) Poly* q) ≡⟨ sym (0r∷RightAssoc (a ∷ p) q) ⟩ ((a ∷ p) Poly* (0r ∷ q)) ∎ ) λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i --Poly* is commutative Poly*Commutative : ∀ p q → p Poly* q ≡ q Poly* p Poly*Commutative = ElimProp.f (λ p → ∀ q → p Poly* q ≡ q Poly* p) (λ q → sym (0PLeftAnnihilates q)) (λ a p prf q → (a PolyConst* q) Poly+ (0r ∷ (p Poly* q)) ≡⟨ cong ((a PolyConst* q) Poly+_) (cong (0r ∷_) (prf q)) ⟩ ((a PolyConst* q) Poly+ (0r ∷ (q Poly* p))) ≡⟨ cong ((a PolyConst* q) Poly+_) (sym (0r∷LeftAssoc q p)) ⟩ ((a PolyConst* q) Poly+ ((0r ∷ q) Poly* p)) ≡⟨ cong (_Poly+ ((0r PolyConst* p) Poly+ (0r ∷ (q Poly* p)))) (PolyConst*r=Poly*[r] a q) ⟩ ((q Poly* [ a ]) Poly+ ((0r ∷ q) Poly* p)) ≡⟨ cong ((q Poly* [ a ]) Poly+_) (0r∷Comm q p) ⟩ ((q Poly* [ a ]) Poly+ (q Poly* (0r ∷ p))) ≡⟨ sym (Poly*LDistrPoly+ q [ a ] (0r ∷ p)) ⟩ (((q Poly* ([ a ] Poly+ (0r ∷ p))))) ≡⟨ cong (q Poly*_) (Poly+Comm [ a ] (0r ∷ p)) ⟩ ((q Poly* ((0r ∷ p) Poly+ [ a ]))) ≡⟨ refl ⟩ (q Poly* ((0r + a) ∷ p)) ≡⟨ cong (q Poly*_) (cong (_∷ p) (+Lid a)) ⟩ (q Poly* (a ∷ p)) ∎) (λ x y i q → isSetPoly _ _ (x q ) (y q) i) --1P is the right identity of Poly*. Poly*Rid : ∀ p → p Poly* 1P ≡ p Poly*Rid = λ p → (Poly*Commutative p 1P ∙ Poly*Lid p) --Polynomial multiplication right distributes over polynomial addition. Poly*RDistrPoly+ : ∀ p q r → (p Poly+ q) Poly* r ≡ (p Poly* r) Poly+ (q Poly* r) Poly*RDistrPoly+ = λ p q r → sym (Poly*Commutative r (p Poly+ q)) ∙ Poly*LDistrPoly+ r p q ∙ cong (_Poly+ (r Poly* q)) (Poly*Commutative r p) ∙ cong ((p Poly* r) Poly+_) (Poly*Commutative r q) --Polynomial multiplication is associative Poly*Associative : ∀ p q r → p Poly* (q Poly* r) ≡ (p Poly* q) Poly* r Poly*Associative = ElimProp.f (λ p → ∀ q r → p Poly* (q Poly* r) ≡ (p Poly* q) Poly* r ) (λ _ _ → refl) (λ a p prf q r → ((a ∷ p) Poly* (q Poly* r)) ≡⟨ cong (_Poly+ (0r ∷ (p Poly* (q Poly* r)))) (PolyConst*AssocPoly* a q r) ⟩ (((a PolyConst* q) Poly* r) Poly+ (0r ∷ (p Poly* (q Poly* r)))) ≡⟨ sym (cong (((a PolyConst* q) Poly* r) Poly+_) (cong (_∷ (p Poly* (q Poly* r))) (+Lid 0r))) ⟩ (((a PolyConst* q) Poly* r) Poly+ (0r + 0r ∷ (p Poly* (q Poly* r)))) ≡⟨ cong (((a PolyConst* q) Poly* r) Poly+_) (cong (0r + 0r ∷_) (sym (Poly+Lid (p Poly* (q Poly* r))))) ⟩ (((a PolyConst* q) Poly* r) Poly+ (0r + 0r ∷ ([] Poly+ (p Poly* (q Poly* r))))) ≡⟨ cong (((a PolyConst* q) Poly* r) Poly+_) (cong (0r + 0r ∷_) (cong ([] Poly+_) (prf q r))) ⟩ (((a PolyConst* q) Poly* r) Poly+ (0r + 0r ∷ ([] Poly+ ((p Poly* q) Poly* r)))) ≡⟨ cong (((a PolyConst* q) Poly* r) Poly+_) (cong (_Poly+ (0r ∷ ((p Poly* q) Poly* r))) (sym (0rLeftAnnihilatesPoly r))) ⟩ (((a PolyConst* q) Poly* r) Poly+ ((0r PolyConst* r) Poly+ (0r ∷ ((p Poly* q) Poly* r)))) ≡⟨ sym (Poly*RDistrPoly+ (a PolyConst* q) (0r ∷ (p Poly* q)) r) ⟩ ((((a ∷ p) Poly* q) Poly* r)) ∎) (λ x y i q r → isSetPoly _ _ (x q r) (y q r) i) ---------------------------------------------------------------------------------------------- -- An instantiation of Polynomials as a commutative ring can be found in CommRing/Instances -- ----------------------------------------------------------------------------------------------
{ "alphanum_fraction": 0.3290365229, "avg_line_length": 47.335071708, "ext": "agda", "hexsha": "6f5700c8447b865747686e60fa1440a53d1dc234", "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": "038bcaff93d278c627ccdcec34a4f6df2b56ad5a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AkermanRydbeck/cubical", "max_forks_repo_path": "Cubical/Algebra/Polynomials.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "038bcaff93d278c627ccdcec34a4f6df2b56ad5a", "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": "AkermanRydbeck/cubical", "max_issues_repo_path": "Cubical/Algebra/Polynomials.agda", "max_line_length": 128, "max_stars_count": null, "max_stars_repo_head_hexsha": "038bcaff93d278c627ccdcec34a4f6df2b56ad5a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AkermanRydbeck/cubical", "max_stars_repo_path": "Cubical/Algebra/Polynomials.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 10353, "size": 36306 }
------------------------------------------------------------------------ -- Empty type ------------------------------------------------------------------------ module Data.Empty where data ⊥ : Set where ⊥-elim : {whatever : Set} → ⊥ → whatever ⊥-elim ()
{ "alphanum_fraction": 0.2645914397, "avg_line_length": 23.3636363636, "ext": "agda", "hexsha": "8022ccfedd51384dd25898efdbc96d4dcb727272", "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/Empty.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/Empty.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/Empty.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": 43, "size": 257 }
------------------------------------------------------------------------------ -- Testing the translation of wild card patterns ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module WildCardPattern where infix 4 _≡_ postulate D : Set zero : D succ : D → D -- The identity type. data _≡_ (x : D) : D → Set where refl : x ≡ x -- The LTC natural numbers type. data N : D → Set where zN : N zero sN : ∀ {n} → N n → N (succ n) foo : ∀ m n → N m → N n → n ≡ n foo m n _ _ = prf where postulate prf : n ≡ n {-# ATP prove prf #-}
{ "alphanum_fraction": 0.4270557029, "avg_line_length": 22.8484848485, "ext": "agda", "hexsha": "40d896210fbd4671704909ca3911acfd88119697", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/WildCardPattern.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/WildCardPattern.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/WildCardPattern.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 196, "size": 754 }
open import Oscar.Prelude open import Oscar.Class open import Oscar.Class.Transitivity open import Oscar.Class.Reflexivity open import Oscar.Class.Transleftidentity open import Oscar.Class.Transrightidentity open import Oscar.Class.Symmetry open import Oscar.Class.Hmap open import Oscar.Class.Leftunit module Oscar.Class.Hmap.Transleftidentity where instance Relprop'idFromTransleftidentity : ∀ {𝔵} {𝔛 : Ø 𝔵} {𝔞} {𝔄 : 𝔛 → Ø 𝔞} {𝔟} {𝔅 : 𝔛 → Ø 𝔟} (let _∼_ = Arrow 𝔄 𝔅) {ℓ̇} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ̇} {transitivity : Transitivity.type _∼_} {reflexivity : Reflexivity.type _∼_} {ℓ} ⦃ _ : Transleftidentity.class _∼_ _∼̇_ reflexivity transitivity ⦄ ⦃ _ : ∀ {x y} → Symmetry.class (_∼̇_ {x} {y}) ⦄ → ∀ {m n} → Hmap.class (λ (f : m ∼ n) (P : LeftExtensionṖroperty ℓ _∼_ _∼̇_ m) → π₀ (π₀ P) f) (λ f P → π₀ (π₀ P) (transitivity f reflexivity)) Relprop'idFromTransleftidentity .⋆ _ (_ , P₁) = P₁ $ symmetry transleftidentity
{ "alphanum_fraction": 0.6460618146, "avg_line_length": 33.4333333333, "ext": "agda", "hexsha": "16433051f01bc9d8704b7f6e1da1919396ea1bdc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Hmap/Transleftidentity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Hmap/Transleftidentity.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Hmap/Transleftidentity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 385, "size": 1003 }
module Subset where data Subset (A : Set) (P : A -> Set) : Set where inn : (a : A) -> .(P a) -> Subset A P out : forall {A P} -> Subset A P -> A out (inn a p) = a
{ "alphanum_fraction": 0.5238095238, "avg_line_length": 18.6666666667, "ext": "agda", "hexsha": "2504096de7478508c400260afef81024e9051920", "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/Subset.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/Subset.agda", "max_line_length": 48, "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/Subset.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 64, "size": 168 }
module Bool where import Logic open Logic data Bool : Set where false : Bool true : Bool infixr 5 _&&_ _&&_ : Bool -> Bool -> Bool true && x = x false && _ = false not : Bool -> Bool not true = false not false = true IsTrue : Bool -> Set IsTrue true = True IsTrue false = False IsFalse : Bool -> Set IsFalse x = IsTrue (not x) module BoolEq where _==_ : Bool -> Bool -> Bool true == x = x false == x = not x subst : {x y : Bool}(P : Bool -> Set) -> IsTrue (x == y) -> P x -> P y subst {true}{true} _ _ px = px subst {false}{false} _ _ px = px subst {true}{false} _ () _ subst {false}{true} _ () _ isTrue== : {x : Bool} -> IsTrue x -> IsTrue (x == true) isTrue== {true} _ = tt isTrue== {false} () infix 1 if_then_else_ if_then_else_ : {A : Set} -> Bool -> A -> A -> A if true then x else y = x if false then x else y = y open BoolEq if'_then_else_ : {A : Set} -> (x : Bool) -> (IsTrue x -> A) -> (IsFalse x -> A) -> A if' true then f else g = f tt if' false then f else g = g tt isTrue&&₁ : {x y : Bool} -> IsTrue (x && y) -> IsTrue x isTrue&&₁ {true} _ = tt isTrue&&₁ {false} () isTrue&&₂ : {x y : Bool} -> IsTrue (x && y) -> IsTrue y isTrue&&₂ {true} p = p isTrue&&₂ {false} ()
{ "alphanum_fraction": 0.5622977346, "avg_line_length": 19.3125, "ext": "agda", "hexsha": "08b9633353d66a3a359381e624b096c0f3a9e6e4", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/tactics/ac/Bool.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/tactics/ac/Bool.agda", "max_line_length": 84, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/tactics/ac/Bool.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": 461, "size": 1236 }
-- {-# OPTIONS -v tc.term.let.pattern:20 #-} -- Andreas, 2013-05-06 deep let-bound patterns were translated wrongly module Issue843 {A B C : Set} (a : A) (b : B) (c : C) where open import Common.Product open import Common.Equality T : Set T = A × B × C val : T val = a , (b , c) -- This was translated wrongly: ap : {R : Set} (f : T → R) → R ap f = let x , (y , z) = a , (b , c) -- val in f (x , (y , z)) works : {R : Set} (f : T → R) → R works f = let x , yz = val in let y , z = yz in f (x , (y , z)) ap′ : {R : Set} (f : T → R) → R ap′ f = f (proj₁ val , (proj₁ (proj₂ val) , proj₂ (proj₂ val))) test : ∀ {R} (f : T → R) → ap f ≡ f (a , (b , c)) test f = refl {- WAS: The type of test f reduces to Goal: f (a , proj₂ a , c) ≡ f (a , b , c) even though it should reduce to f (a , b , c) ≡ f (a , b , c) And indeed, refl doesn't fit there. Typechecking the example where the hole has been replaced with refl produces: D:\Agda\Strange.agda:21,10-14 proj₂ a != b of type B when checking that the expression refl has type ap f ≡ f (a , b , c) With ap′, the goal reduces correctly and refl is accepted. I'm using a development version of Agda, about one day old. 64bit Windows 7, if it matters. -}
{ "alphanum_fraction": 0.5849673203, "avg_line_length": 22.6666666667, "ext": "agda", "hexsha": "da5c04bd6c03106a3eab0862e92d82d8b71bbd5b", "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": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/Succeed/Issue843.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue843.agda", "max_line_length": 113, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue843.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": 447, "size": 1224 }
{-# OPTIONS --without-K --allow-unsolved-metas #-} module subuniverses where import 14-univalence open 14-univalence public {- is-local : {l1 l2 l3 l4 : Level} {I : UU l1} {A : I → UU l2} {B : I → UU l3} (f : (i : I) → A i → B i) (X : UU l4) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4))) is-local {I = I} {B = B} f X = (i : I) → is-equiv (λ (h : B i → X) → h ∘ (f i)) is-subuniverse-is-local : {l1 l2 l3 l4 : Level} {I : UU l1} {A : I → UU l2} {B : I → UU l3} (f : (i : I) → A i → B i) → is-subuniverse (is-local {l4 = l4} f) is-subuniverse-is-local f X = is-prop-Π (λ i → is-subtype-is-equiv _) -} universal-property-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) (Y : total-subuniverse P) (l : X → pr1 Y) → UU ((lsuc l1) ⊔ l2) universal-property-localization {l1} (pair P H) X (pair Y p) l = (Z : UU l1) (q : P Z) → is-equiv (λ (h : Y → Z) → h ∘ l) universal-property-localization' : (l : Level) (α : Level → Level) (P : (l : Level) → subuniverse l (α l)) (g : (l1 l2 : Level) → is-global-subuniverse α P l1 l2) {l1 l2 : Level} (X : UU l1) (Y : total-subuniverse (P l2)) (f : X → pr1 Y) → UU ((lsuc l) ⊔ ((α l) ⊔ (l1 ⊔ l2))) universal-property-localization' l α P g X Y f = (Z : total-subuniverse (P l)) → is-equiv (λ (h : (pr1 Y) → (pr1 Z)) → h ∘ f) is-prop-universal-property-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) (Y : total-subuniverse P) (l : X → pr1 Y) → is-prop (universal-property-localization P X Y l) is-prop-universal-property-localization (pair P H) X (pair Y p) l = is-prop-Π (λ Z → is-prop-Π (λ q → is-subtype-is-equiv _)) has-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → UU ((lsuc l1) ⊔ l2) has-localization {l1} P X = Σ ( total-subuniverse P) ( λ Y → Σ (X → pr1 Y) (universal-property-localization P X Y)) Eq-localizations : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → ( s t : has-localization P X) → UU l1 Eq-localizations (pair P H) X (pair (pair Y p) (pair l up)) t = let Y' = pr1 (pr1 t) p' = pr1 (pr1 t) l' = pr1 (pr2 t) up' = pr2 (pr2 t) in Σ ( Y ≃ Y') ( λ e → ((map-equiv e) ∘ l) ~ l' ) reflexive-Eq-localizations : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (s : has-localization P X) → Eq-localizations P X s s reflexive-Eq-localizations (pair P H) X (pair (pair Y p) (pair l up)) = pair (equiv-id Y) (htpy-refl l) Eq-localizations-eq : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → ( s t : has-localization P X) → Id s t → Eq-localizations P X s t Eq-localizations-eq P X s s refl = reflexive-Eq-localizations P X s is-contr-total-Eq-localizations : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) (s : has-localization P X) → is-contr (Σ (has-localization P X) (Eq-localizations P X s)) is-contr-total-Eq-localizations (pair P H) X (pair (pair Y p) (pair l up)) = is-contr-total-Eq-structure ( λ Y' l' e → ((map-equiv e) ∘ l) ~ (pr1 l')) ( is-contr-total-Eq-total-subuniverse (pair P H) (pair Y p)) ( pair (pair Y p) (equiv-id Y)) ( is-contr-total-Eq-substructure ( is-contr-total-htpy l) ( is-prop-universal-property-localization (pair P H) X (pair Y p)) ( l) ( htpy-refl _) ( up)) is-equiv-Eq-localizations-eq : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → ( s t : has-localization P X) → is-equiv (Eq-localizations-eq P X s t) is-equiv-Eq-localizations-eq P X s = fundamental-theorem-id s ( reflexive-Eq-localizations P X s) ( is-contr-total-Eq-localizations P X s) ( Eq-localizations-eq P X s) eq-Eq-localizations : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) ( s t : has-localization P X) → (Eq-localizations P X s t) → Id s t eq-Eq-localizations P X s t = inv-is-equiv (is-equiv-Eq-localizations-eq P X s t) uniqueness-localizations : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → ( s t : has-localization P X) → Eq-localizations P X s t uniqueness-localizations (pair P H) X (pair (pair Y p) (pair l up)) (pair (pair Y' p') (pair l' up')) = pair ( pair ( inv-is-equiv (up Y' p') l') ( is-equiv-has-inverse ( pair ( inv-is-equiv (up' Y p) l) ( pair ( htpy-eq ( ap ( pr1 {B = λ h → Id (h ∘ l') l'}) ( center ( is-prop-is-contr ( is-contr-map-is-equiv (up' Y' p') l') ( pair ( ( inv-is-equiv (up Y' p') l') ∘ ( inv-is-equiv (up' Y p) l)) ( ( ap ( λ t → (inv-is-equiv (up Y' p') l') ∘ t) ( issec-inv-is-equiv (up' Y p) l)) ∙ ( issec-inv-is-equiv (up Y' p') l'))) ( pair id refl))))) ( htpy-eq ( ap ( pr1 {B = λ h → Id (h ∘ l) l}) ( center ( is-prop-is-contr ( is-contr-map-is-equiv (up Y p) l) ( pair ( ( inv-is-equiv (up' Y p) l) ∘ ( inv-is-equiv (up Y' p') l')) ( ( ap ( λ t → (inv-is-equiv (up' Y p) l) ∘ t) ( issec-inv-is-equiv (up Y' p') l')) ∙ issec-inv-is-equiv (up' Y p) l)) ( pair id refl))))))))) ( htpy-eq (issec-inv-is-equiv (up Y' p') l')) is-prop-localizations : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → is-prop (has-localization P X) is-prop-localizations P X = is-prop-is-prop' ( λ Y Y' → eq-Eq-localizations P X Y Y' ( uniqueness-localizations P X Y Y')) universal-property-localization-equiv-is-local : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (Y : UU l1) (p : (pr1 P) Y) (l : X → Y) → is-equiv l → universal-property-localization P X (pair Y p) l universal-property-localization-equiv-is-local (pair P H) X Y p l is-equiv-l Z q = is-equiv-precomp-is-equiv l is-equiv-l Z universal-property-localization-id-is-local : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) (q : (pr1 P) X) → universal-property-localization P X (pair X q) id universal-property-localization-id-is-local P X q = universal-property-localization-equiv-is-local P X X q id (is-equiv-id X) is-equiv-localization-is-local : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → ( Y : has-localization P X) → (pr1 P) X → is-equiv (pr1 (pr2 Y)) is-equiv-localization-is-local (pair P H) X (pair (pair Y p) (pair l up)) q = is-equiv-right-factor ( id) ( inv-is-equiv (up X q) id) ( l) ( htpy-eq (inv (issec-inv-is-equiv (up X q) id))) ( pr2 ( pr1 ( uniqueness-localizations (pair P H) X ( pair (pair Y p) (pair l up)) ( pair ( pair X q) ( pair id ( universal-property-localization-id-is-local (pair P H) X q)))))) ( is-equiv-id X) is-local-is-equiv-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → ( Y : has-localization P X) → is-equiv (pr1 (pr2 Y)) → (pr1 P) X is-local-is-equiv-localization (pair P H) X (pair (pair Y p) (pair l up)) is-equiv-l = in-subuniverse-equiv' P (pair l is-equiv-l) p strong-retraction-property-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (Y : total-subuniverse P) (l : X → pr1 Y) → UU l1 strong-retraction-property-localization (pair P H) X (pair Y p) l = is-equiv (λ (h : Y → X) → h ∘ l) retraction-property-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (Y : total-subuniverse P) (l : X → pr1 Y) → UU l1 retraction-property-localization (pair P H) X (pair Y p) l = retr l strong-retraction-property-localization-is-equiv-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (Y : total-subuniverse P) (l : X → pr1 Y) → is-equiv l → strong-retraction-property-localization P X Y l strong-retraction-property-localization-is-equiv-localization (pair P H) X (pair Y p) l is-equiv-l = is-equiv-precomp-is-equiv l is-equiv-l X retraction-property-localization-strong-retraction-property-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (Y : total-subuniverse P) (l : X → pr1 Y) → strong-retraction-property-localization P X Y l → retraction-property-localization P X Y l retraction-property-localization-strong-retraction-property-localization (pair P H) X (pair Y p) l s = tot (λ h → htpy-eq) (center (is-contr-map-is-equiv s id)) is-equiv-localization-retraction-property-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (Y : has-localization P X) → retraction-property-localization P X (pr1 Y) (pr1 (pr2 Y)) → is-equiv (pr1 (pr2 Y)) is-equiv-localization-retraction-property-localization (pair P H) X (pair (pair Y p) (pair l up)) (pair g isretr-g) = is-equiv-has-inverse ( pair g ( pair ( htpy-eq ( ap ( pr1 {B = λ (h : Y → Y) → Id (h ∘ l) l}) ( center ( is-prop-is-contr ( is-contr-map-is-equiv (up Y p) l) ( pair (l ∘ g) (ap (λ t → l ∘ t) (eq-htpy isretr-g))) ( pair id refl))))) ( isretr-g))) is-local-retraction-property-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (Y : has-localization P X) → retraction-property-localization P X (pr1 Y) (pr1 (pr2 Y)) → (pr1 P) X is-local-retraction-property-localization P X Y r = is-local-is-equiv-localization P X Y ( is-equiv-localization-retraction-property-localization P X Y r) is-local-has-localization-is-contr : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → is-contr X → has-localization P X → (pr1 P) X is-local-has-localization-is-contr (pair P H) X is-contr-X (pair (pair Y p) (pair l up)) = is-local-retraction-property-localization (pair P H) X ( pair (pair Y p) (pair l up)) ( pair ( λ _ → center is-contr-X) ( contraction is-contr-X)) has-localization-is-local-is-contr : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → is-contr X → (pr1 P) X → has-localization P X has-localization-is-local-is-contr (pair P H) X is-contr-X p = pair ( pair X p) ( pair id (universal-property-localization-id-is-local (pair P H) X p)) is-contr-raise-unit : (l : Level) → is-contr (raise l unit) is-contr-raise-unit l = is-contr-is-equiv' unit ( map-raise l unit) ( is-equiv-map-raise l unit) ( is-contr-unit) is-local-unit-localization-unit : {l1 l2 : Level} (P : subuniverse l1 l2) → (Y : has-localization P (raise l1 unit)) → (pr1 P) (raise l1 unit) is-local-unit-localization-unit P Y = is-local-has-localization-is-contr P (raise _ unit) (is-contr-raise-unit _) Y toto-dependent-elimination-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (has-loc-X : has-localization P X) → let Y = pr1 (pr1 has-loc-X) l = pr1 (pr2 has-loc-X) in (Z : Y → UU l1) → Σ (Y → Y) (λ h → (y : Y) → Z (h y)) → Σ (X → Y) (λ h → (x : X) → Z (h x)) toto-dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z = toto ( λ (h : X → Y) → (x : X) → Z (h x)) ( λ h → h ∘ l) ( λ h h' x → h' (l x)) square-dependent-elimination-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (has-loc-X : has-localization P X) → let Y = pr1 (pr1 has-loc-X) l = pr1 (pr2 has-loc-X) in (Z : Y → UU l1) (q : (pr1 P) (Σ _ Z)) → ( ( λ (h : Y → Σ Y Z) → h ∘ l) ∘ ( inv-choice-∞)) ~ ( ( inv-choice-∞) ∘ ( toto-dependent-elimination-localization P X has-loc-X Z)) square-dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z q = htpy-refl is-equiv-toto-dependent-elimination-localization : {l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) → (has-loc-X : has-localization P X) (Z : pr1 (pr1 has-loc-X) → UU l1) (q : (pr1 P) (Σ _ Z)) → is-equiv (toto-dependent-elimination-localization P X has-loc-X Z) is-equiv-toto-dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z q = is-equiv-top-is-equiv-bottom-square ( inv-choice-∞) ( inv-choice-∞) ( toto-dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z) ( λ h → h ∘ l) ( square-dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z q) ( is-equiv-inv-choice-∞) ( is-equiv-inv-choice-∞) ( up (Σ Y Z) q) dependent-elimination-localization : {l1 l2 : Level} (P : subuniverse l1 l2) → (X : UU l1) (Y : has-localization P X) → (Z : (pr1 (pr1 Y)) → UU l1) (q : (pr1 P) (Σ _ Z)) → is-equiv (λ (h : (y : (pr1 (pr1 Y))) → (Z y)) → λ x → h (pr1 (pr2 Y) x)) dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z q = is-fiberwise-equiv-is-equiv-toto-is-equiv-base-map ( λ (h : X → Y) → (x : X) → Z (h x)) ( λ (h : Y → Y) → h ∘ l) ( λ (h : Y → Y) (h' : (y : Y) → Z (h y)) (x : X) → h' (l x)) ( up Y p) ( is-equiv-toto-dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z q) ( id) is-reflective-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) → UU ((lsuc l1) ⊔ l2) is-reflective-subuniverse {l1} P = (X : UU l1) → has-localization P X reflective-subuniverse : (l1 l2 : Level) → UU ((lsuc l1) ⊔ (lsuc l2)) reflective-subuniverse l1 l2 = Σ (subuniverse l1 l2) is-reflective-subuniverse is-local : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) → UU l1 → UU l2 is-local L = pr1 (pr1 L) is-prop-is-local : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) → (X : UU l1) → is-prop (is-local L X) is-prop-is-local L = pr2 (pr1 L) total-reflective-subuniverse : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) → UU ((lsuc l1) ⊔ l2) total-reflective-subuniverse L = total-subuniverse (pr1 L) local-type-localization : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) → total-reflective-subuniverse L local-type-localization L X = pr1 ((pr2 L) X) type-localization : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) → UU l1 → UU l1 type-localization L X = pr1 (local-type-localization L X) is-local-type-localization : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) → is-local L (type-localization L X) is-local-type-localization L X = pr2 (local-type-localization L X) universal-map-localization : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) → Σ ( X → type-localization L X) ( universal-property-localization (pr1 L) X (local-type-localization L X)) universal-map-localization L X = pr2 ((pr2 L) X) unit-localization : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) → X → type-localization L X unit-localization L X = pr1 (universal-map-localization L X) universal-property-map-localization : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) → universal-property-localization (pr1 L) X ( local-type-localization L X) ( unit-localization L X) universal-property-map-localization L X = pr2 (universal-map-localization L X) dependent-elimination-reflective-subuniverse : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) → (Y : type-localization L X → UU l1) (is-loc-total-Y : is-local L (Σ _ Y)) → is-equiv ( λ (h : (x' : type-localization L X) → Y x') x → h (unit-localization L X x)) dependent-elimination-reflective-subuniverse L X = dependent-elimination-localization (pr1 L) X ((pr2 L) X) is-contr-square-localization : {l1 l2 : Level} (L : reflective-subuniverse l1 l2) {X Y : UU l1} (f : X → Y) → is-contr ( Σ (type-localization L X → type-localization L Y) ( λ Lf → coherence-square (unit-localization L X) f Lf (unit-localization L Y))) is-contr-square-localization L f = {!!}
{ "alphanum_fraction": 0.5829104805, "avg_line_length": 37.3840749415, "ext": "agda", "hexsha": "ada21654d68355a2e75f39555392b669c1a413e0", "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": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "tmoux/HoTT-Intro", "max_forks_repo_path": "Agda/subuniverses.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "tmoux/HoTT-Intro", "max_issues_repo_path": "Agda/subuniverses.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "tmoux/HoTT-Intro", "max_stars_repo_path": "Agda/subuniverses.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5811, "size": 15963 }
open import Relation.Binary.Core module PLRTree.Push.Permutation {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import Data.List open import Data.Sum open import Induction.WellFounded open import List.Permutation.Base A open import List.Permutation.Base.Concatenation A open import List.Permutation.Base.Equivalence A open import PLRTree {A} open import PLRTree.Complete {A} open import PLRTree.Drop _≤_ tot≤ open import PLRTree.Equality {A} open import PLRTree.Order {A} open import PLRTree.Order.Properties {A} lemma-push-∼-≃ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ≃ r → (acc : Acc _≺_ (node perfect x l r)) → flatten (push (node perfect x l r) acc) ∼ flatten (node right x l r) lemma-push-∼-≃ {l} {r} x cl cr l≃r (acc rs) with l | r | l≃r | cl | cr ... | leaf | leaf | ≃lf | _ | _ = ∼x /head /head ∼[] ... | node perfect x' l' r' | node perfect x'' l'' r'' | ≃nd .x' .x'' l'≃r' l''≃r'' l'≃l'' | perfect .x' cl' cr' _ | perfect .x'' cl'' cr'' _ with tot≤ x x' | tot≤ x x'' | tot≤ x' x'' ... | inj₁ x≤x' | inj₁ x≤x'' | _ = refl∼ ... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr ... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr lemma-push-∼-⋗ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ⋗ r → (acc : Acc _≺_ (node right x l r)) → flatten (push (node right x l r) acc) ∼ flatten (node right x l r) lemma-push-∼-⋗ {l} {r} x cl cr l⋗r (acc rs) with l | r | l⋗r | cl | cr ... | leaf | _ | () | _ | _ ... | node perfect x' leaf leaf | leaf | ⋗lf .x' | perfect .x' leaf leaf ≃lf | leaf with tot≤ x x' ... | inj₁ x≤x' = ∼x /head /head (∼x /head /head ∼[]) ... | inj₂ x'≤x = ∼x (/tail /head) /head (∼x /head /head ∼[]) lemma-push-∼-⋗ x cl cr l⋗r (acc rs) | node perfect x' l' r' | node perfect x'' l'' r'' | ⋗nd .x' .x'' l'≃r' l''≃r'' l'⋗l'' | perfect .x' cl' cr' _ | perfect .x'' cl'' cr'' _ with tot≤ x x' | tot≤ x x'' | tot≤ x' x'' ... | inj₁ x≤x' | inj₁ x≤x'' | _ = refl∼ ... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr ... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr mutual lemma-push-∼-⋙ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ⋙ r → (acc : Acc _≺_ (node right x l r)) → flatten (push (node right x l r) acc) ∼ flatten (node right x l r) lemma-push-∼-⋙ {l} {r} x cl cr l⋙r (acc rs) with l | r | l⋙r | cl | cr ... | leaf | _ | ⋙p () | _ | _ ... | node perfect x' leaf leaf | leaf | ⋙p (⋗lf .x') | perfect .x' leaf leaf ≃lf | leaf = lemma-push-∼-⋗ x (perfect x' leaf leaf ≃lf) leaf (⋗lf x') (acc rs) ... | node perfect x' l' r' | node perfect x'' l'' r'' | ⋙p (⋗nd .x' .x'' l'≃r' l''≃r'' l'⋗l'') | perfect .x' cl' cr' _ | perfect .x'' cl'' cr'' _ = lemma-push-∼-⋗ x (perfect x' cl' cr' l'≃r') (perfect x'' cl'' cr'' l''≃r'') (⋗nd x' x'' l'≃r' l''≃r'' l'⋗l'') (acc rs) ... | node perfect x' leaf leaf | node left _ _ _ | ⋙p () | _ | _ ... | node perfect x' leaf leaf | node right _ _ _ | ⋙p () | _ | _ ... | node perfect x' l' r' | node left x'' l'' r'' | ⋙l .x' .x'' l'≃r' l''⋘r'' l'⋗r'' | perfect .x' cl' cr' _ | left .x'' cl'' cr'' _ with tot≤ x x' | tot≤ x x'' | tot≤ x' x'' ... | inj₁ x≤x' | inj₁ x≤x'' | _ = refl∼ ... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height left x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node left x l'' r'') (lemma-≺-right perfect x _l (node left x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-⋘ x cl'' cr'' l''⋘r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr ... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' = let _r = node left x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' = let _r = node left x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height left x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node left x l'' r'') (lemma-≺-right perfect x _l (node left x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-⋘ x cl'' cr'' l''⋘r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr lemma-push-∼-⋙ x cl cr l⋙r (acc rs)| node perfect x' l' r' | node right x'' l'' r'' | ⋙r .x' .x'' l'≃r' l''⋙r'' l'≃l'' | perfect .x' cl' cr' _ | right .x'' cl'' cr'' _ with tot≤ x x' | tot≤ x x'' | tot≤ x' x'' ... | inj₁ x≤x' | inj₁ x≤x'' | _ = refl∼ ... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height right x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node right x l'' r'') (lemma-≺-right perfect x _l (node right x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-⋙ x cl'' cr'' l''⋙r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr ... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height perfect x x' l' r' = let _r = node right x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height perfect x x' l' r' = let _r = node right x'' l'' r'' ; acc-xl'r' = rs (node perfect x l' r') (lemma-≺-left perfect x (node perfect x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-≃ x cl' cr' l'≃r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height right x x'' l'' r'' = let _l = node perfect x' l' r' ; acc-xl''r'' = rs (node right x l'' r'') (lemma-≺-right perfect x _l (node right x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-⋙ x cl'' cr'' l''⋙r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr lemma-push-∼-⋙ x cl cr l⋙r (acc rs) | node left _ _ _ | _ | ⋙p () | _ | _ lemma-push-∼-⋙ x cl cr l⋙r (acc rs) | node right _ _ _ | _ | ⋙p () | _ | _ lemma-push-∼-⋘ : {l r : PLRTree}(x : A) → Complete l → Complete r → l ⋘ r → (acc : Acc _≺_ (node left x l r)) → flatten (push (node left x l r) acc) ∼ flatten (node left x l r) lemma-push-∼-⋘ {l} {r} x cl cr l⋘r (acc rs) with l | r | l⋘r | cl | cr ... | node left x' l' r' | node perfect x'' l'' r'' | l⋘ .x' .x'' l'⋘r' l''≃r'' r'≃l'' | left .x' cl' cr' _ | perfect .x'' cl'' cr'' _ with tot≤ x x' | tot≤ x x'' | tot≤ x' x'' ... | inj₁ x≤x' | inj₁ x≤x'' | _ = refl∼ ... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node left x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr ... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height left x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node left x l' r') (lemma-≺-left perfect x (node left x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-⋘ x cl' cr' l'⋘r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height left x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node left x l' r') (lemma-≺-left perfect x (node left x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-⋘ x cl' cr' l'⋘r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node left x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr lemma-push-∼-⋘ x cl cr l⋘r (acc rs) | node right x' (node perfect x'' leaf leaf) leaf | node perfect x''' leaf leaf | x⋘ .x' .x'' .x''' | right .x' (perfect .x'' leaf leaf ≃lf) leaf (⋙p (⋗lf .x'')) | perfect .x''' leaf leaf ≃lf with tot≤ x x' | tot≤ x x''' | tot≤ x' x''' ... | inj₁ x≤x' | inj₁ x≤x''' | _ = refl∼ ... | inj₁ x≤x' | inj₂ x'''≤x | _ = let _l = node perfect x' (node perfect x'' leaf leaf) leaf ; acc-x = rs (node perfect x leaf leaf) (lemma-≺-right perfect x _l (node perfect x''' leaf leaf)) ; x'''flfpx∼x'''flx = lemma++∼l {x''' ∷ flatten _l} (lemma-push-∼-≃ x leaf leaf ≃lf acc-x) ; flxfr/x'''⟶flx = lemma++/l {x'''} {flatten _l} (/tail /head) ; x'''flx∼flxfr = ∼x /head flxfr/x'''⟶flx refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x'''flx∼xflfr = trans∼ x'''flx∼flxfr flxfr∼xflfr in trans∼ x'''flfpx∼x'''flx x'''flx∼xflfr ... | inj₂ x'≤x | inj₁ x≤x''' | _ = let _r = node perfect x''' leaf leaf ; acc-xx'' = rs (node right x (node perfect x'' leaf leaf) leaf) (lemma-≺-left perfect x (node right x' (node perfect x'' leaf leaf) leaf) _r) ; fpxx''x'''∼xx''x''' = lemma++∼r (lemma-push-∼-⋗ x (perfect x'' leaf leaf ≃lf) leaf (⋗lf x'') acc-xx'') ; x'fpxx''x'''∼x'xx''x''' = ∼x /head /head fpxx''x'''∼xx''x''' ; x'xx''x'''∼xx'x''x''' = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxx''x'''∼x'xx''x''' x'xx''x'''∼xx'x''x''' ... | inj₂ x'≤x | inj₂ x'''≤x | inj₁ x'≤x''' = let _r = node perfect x''' leaf leaf ; acc-xx'' = rs (node right x (node perfect x'' leaf leaf) leaf) (lemma-≺-left perfect x (node right x' (node perfect x'' leaf leaf) leaf) _r) ; fpxx''x'''∼xx''x''' = lemma++∼r (lemma-push-∼-⋗ x (perfect x'' leaf leaf ≃lf) leaf (⋗lf x'') acc-xx'') ; x'fpxx''x'''∼x'xx''x''' = ∼x /head /head fpxx''x'''∼xx''x''' ; x'xx''x'''∼xx'x''x''' = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxx''x'''∼x'xx''x''' x'xx''x'''∼xx'x''x''' ... | inj₂ x'≤x | inj₂ x'''≤x | inj₂ x'''≤x' = let _l = node perfect x' (node perfect x'' leaf leaf) leaf ; acc-x = rs (node perfect x leaf leaf) (lemma-≺-right perfect x _l (node perfect x''' leaf leaf)) ; x'''flfpx∼x'''flx = lemma++∼l {x''' ∷ flatten _l} (lemma-push-∼-≃ x leaf leaf ≃lf acc-x) ; flxfr/x'''⟶flx = lemma++/l {x'''} {flatten _l} (/tail /head) ; x'''flx∼flxfr = ∼x /head flxfr/x'''⟶flx refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x'''flx∼xflfr = trans∼ x'''flx∼flxfr flxfr∼xflfr in trans∼ x'''flfpx∼x'''flx x'''flx∼xflfr lemma-push-∼-⋘ x cl cr l⋘r (acc rs) | node right x' l' r' | node perfect x'' l'' r'' | r⋘ .x' .x'' l'⋙r' l''≃r'' l'⋗l'' | right .x' cl' cr' _ | perfect .x'' cl'' cr'' _ with tot≤ x x' | tot≤ x x'' | tot≤ x' x'' ... | inj₁ x≤x' | inj₁ x≤x'' | _ = refl∼ ... | inj₁ x≤x' | inj₂ x''≤x | _ rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node right x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr ... | inj₂ x'≤x | inj₁ x≤x'' | _ rewrite lemma-≡-height right x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node right x l' r') (lemma-≺-left perfect x (node right x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-⋙ x cl' cr' l'⋙r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₁ x'≤x'' rewrite lemma-≡-height right x x' l' r' = let _r = node perfect x'' l'' r'' ; acc-xl'r' = rs (node right x l' r') (lemma-≺-left perfect x (node right x' l' r') _r) ; fpxl'r'fr∼xfl'fr'fr = lemma++∼r (lemma-push-∼-⋙ x cl' cr' l'⋙r' acc-xl'r') ; x'fpxl'r'fr∼x'xfl'fr'fr = ∼x /head /head fpxl'r'fr∼xfl'fr'fr ; x'xfl'fr'fr∼xflfr = ∼x /head (/tail /head) refl∼ in trans∼ x'fpxl'r'fr∼x'xfl'fr'fr x'xfl'fr'fr∼xflfr ... | inj₂ x'≤x | inj₂ x''≤x | inj₂ x''≤x' rewrite lemma-≡-height perfect x x'' l'' r'' = let _l = node right x' l' r' ; acc-xl''r'' = rs (node perfect x l'' r'') (lemma-≺-right perfect x _l (node perfect x'' l'' r'')) ; x''flfpxl''r''∼x''flxfl''fr'' = lemma++∼l {x'' ∷ flatten _l} (lemma-push-∼-≃ x cl'' cr'' l''≃r'' acc-xl''r'') ; flxfr/x''⟶flxfl''fr'' = lemma++/l {x''} {flatten _l} (/tail /head) ; x''flxfl''fr''∼flxfr = ∼x /head flxfr/x''⟶flxfl''fr'' refl∼ ; flxfr/x⟶flfr = lemma++/ {x} {flatten _l} ; flxfr∼xflfr = ∼x flxfr/x⟶flfr /head refl∼ ; x''flxfl''fr''∼xflfr = trans∼ x''flxfl''fr''∼flxfr flxfr∼xflfr in trans∼ x''flfpxl''r''∼x''flxfl''fr'' x''flxfl''fr''∼xflfr lemma-push-∼ : {t : PLRTree} → Complete t → (acc : Acc _≺_ t) → flatten (push t acc) ∼ flatten t lemma-push-∼ leaf _ = ∼[] lemma-push-∼ (perfect {l} {r}x cl cr l≃r) (acc rs) = lemma-push-∼-≃ x cl cr l≃r (acc rs) lemma-push-∼ (left {l} {r}x cl cr l⋘r) (acc rs) = lemma-push-∼-⋘ x cl cr l⋘r (acc rs) lemma-push-∼ (right {l} {r}x cl cr l⋙r) (acc rs) = lemma-push-∼-⋙ x cl cr l⋙r (acc rs)
{ "alphanum_fraction": 0.472022299, "avg_line_length": 76.0664556962, "ext": "agda", "hexsha": "7e33002b460afcd6abf192c2705b1ad8e4740849", "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/PLRTree/Push/Permutation.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/PLRTree/Push/Permutation.agda", "max_line_length": 231, "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/PLRTree/Push/Permutation.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": 10521, "size": 24037 }
{-# OPTIONS --rewriting --prop --confluence-check #-} open import Agda.Primitive open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite open import Agda.Builtin.Sigma open import Agda.Builtin.Unit open import Data.Vec.Base open import Data.Bool open import Data.Sum variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level record Top ℓ : Set ℓ where constructor ⟨⟩ {- Axiomatisation of ExTT -} postulate raise : (A : Set ℓ) → A -- we now state rewrite rules for raise postulate raise-Pi : (A : Set ℓ) (B : A → Set ℓ₁) → raise ((a : A) → B a) ≡ λ a → raise (B a) {-# REWRITE raise-Pi #-} postulate raise-Sigma : (A : Set ℓ) (B : A → Set ℓ₁) → raise (Σ A B) ≡ (raise A , raise (B (raise A))) {-# REWRITE raise-Sigma #-} nat-rec : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (n : Nat) → P n nat-rec P P0 PS zero = P0 nat-rec P P0 PS (suc n) = PS n (nat-rec P P0 PS n) postulate raise-nat-rec : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → nat-rec P P0 PS (raise Nat) ≡ raise (P (raise Nat)) {-# REWRITE raise-nat-rec #-} postulate catch-nat : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → (n : Nat) → P n postulate catch-nat-zero : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → catch-nat P P0 PS Praise 0 ≡ P0 postulate catch-nat-suc : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → (n : Nat) → catch-nat P P0 PS Praise (suc n) ≡ PS n (catch-nat P P0 PS Praise n) postulate catch-nat-raise : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Praise : P (raise Nat)) → catch-nat P P0 PS Praise (raise Nat) ≡ Praise {-# REWRITE catch-nat-zero #-} {-# REWRITE catch-nat-suc #-} {-# REWRITE catch-nat-raise #-} postulate raise-Top : raise (Top ℓ) ≡ ⟨⟩ {-# REWRITE raise-Top #-} postulate raise-Set : raise (Set ℓ) ≡ Top ℓ {-# REWRITE raise-Set #-} {- Axiomatisation of unk -} postulate unk : (A : Set ℓ) → A -- we now state rewrite rules for unk postulate unk-Pi : (A : Set ℓ) (B : A → Set ℓ₁) → unk ((a : A) → B a) ≡ λ a → unk (B a) {-# REWRITE unk-Pi #-} postulate unk-Sigma : (A : Set ℓ) (B : A → Set ℓ₁) → unk (Σ A B) ≡ (unk A , unk (B (unk A))) {-# REWRITE unk-Sigma #-} postulate unk-nat-rec : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → nat-rec P P0 PS (unk Nat) ≡ unk (P (unk Nat)) {-# REWRITE unk-nat-rec #-} postulate catch-unk-nat : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Punk : P (unk Nat)) → (n : Nat) → P n postulate catch-unk-nat-zero : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Punk : P (unk Nat)) → catch-unk-nat P P0 PS Punk 0 ≡ P0 postulate catch-unk-nat-suc : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Punk : P (unk Nat)) → (n : Nat) → catch-unk-nat P P0 PS Punk (suc n) ≡ PS n (catch-unk-nat P P0 PS Punk n) postulate catch-unk-nat-unk : (P : Nat → Set ℓ) (P0 : P 0) (PS : (n : Nat) → P n → P (suc n)) → (Punk : P (unk Nat)) → catch-unk-nat P P0 PS Punk (unk Nat) ≡ Punk {-# REWRITE catch-unk-nat-zero #-} {-# REWRITE catch-unk-nat-suc #-} {-# REWRITE catch-unk-nat-unk #-} postulate unk-Top : unk (Top ℓ) ≡ ⟨⟩ {-# REWRITE unk-Top #-} Unk : ∀ ℓ → Set ℓ Unk ℓ = unk (Set ℓ) -- postulate Unk : ∀ ℓ → Set (lsuc ℓ) -- -- record Unk ℓ : Set (lsuc ℓ) where -- -- constructor box -- -- field -- -- type : Set ℓ -- -- elem : type -- postulate raise-Unk : ∀ ℓ → raise (Unk ℓ) ≡ box (raise (Set ℓ)) (raise _) -- {-# REWRITE raise-Unk #-}
{ "alphanum_fraction": 0.5098277117, "avg_line_length": 30.7537313433, "ext": "agda", "hexsha": "c2386552d8fb61489c8ad9ba9d99530c0ed2399c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-01-06T13:36:28.000Z", "max_forks_repo_forks_event_min_datetime": "2018-04-23T17:34:44.000Z", "max_forks_repo_head_hexsha": "c93256a11d59038998f09a01c5b42f6ffe42d5c4", "max_forks_repo_licenses": [ "WTFPL" ], "max_forks_repo_name": "CoqHott/exceptional-tt", "max_forks_repo_path": "agda-rr/ett-rr.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c93256a11d59038998f09a01c5b42f6ffe42d5c4", "max_issues_repo_issues_event_max_datetime": "2019-02-28T18:28:53.000Z", "max_issues_repo_issues_event_min_datetime": "2019-02-28T16:35:41.000Z", "max_issues_repo_licenses": [ "WTFPL" ], "max_issues_repo_name": "CoqHott/exceptional-tt", "max_issues_repo_path": "agda-rr/ett-rr.agda", "max_line_length": 100, "max_stars_count": 14, "max_stars_repo_head_hexsha": "c93256a11d59038998f09a01c5b42f6ffe42d5c4", "max_stars_repo_licenses": [ "WTFPL" ], "max_stars_repo_name": "CoqHott/exceptional-tt", "max_stars_repo_path": "agda-rr/ett-rr.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-23T12:45:05.000Z", "max_stars_repo_stars_event_min_datetime": "2017-10-13T01:31:56.000Z", "num_tokens": 1515, "size": 4121 }
{-# OPTIONS --without-K --safe #-} open import Algebra.Solver.Ring.AlmostCommutativeRing -- Some specialised tools for equaltional reasoning. module Polynomial.Reasoning {a ℓ} (ring : AlmostCommutativeRing a ℓ) where open AlmostCommutativeRing ring open import Relation.Binary.Reasoning.Inference setoid public infixr 1 ≪+_ +≫_ ≪*_ *≫_ ≪+_ : ∀ {x₁ x₂ y} → x₁ ≈ x₂ → x₁ + y ≈ x₂ + y ≪+ prf = +-cong prf refl +≫_ : ∀ {x y₁ y₂} → y₁ ≈ y₂ → x + y₁ ≈ x + y₂ +≫_ = +-cong refl ≪*_ : ∀ {x₁ x₂ y} → x₁ ≈ x₂ → x₁ * y ≈ x₂ * y ≪* prf = *-cong prf refl *≫_ : ∀ {x y₁ y₂} → y₁ ≈ y₂ → x * y₁ ≈ x * y₂ *≫_ = *-cong refl {-# INLINE ≪*_ #-} {-# INLINE ≪+_ #-} {-# INLINE *≫_ #-} {-# INLINE +≫_ #-} -- transitivity as an operator infixr 0 _⊙_ _⊙_ : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z _⊙_ = trans {-# INLINE _⊙_ #-}
{ "alphanum_fraction": 0.5672009864, "avg_line_length": 22.5277777778, "ext": "agda", "hexsha": "d95b216d5114f74b7388a131ed18a2b4ad4fd5b9", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Polynomial/Reasoning.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Polynomial/Reasoning.agda", "max_line_length": 61, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Polynomial/Reasoning.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 361, "size": 811 }
module Logic.Propositional where open import Data open import Data.Either as Either using (_‖_) open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Functional open import Logic import Lvl open import Type infixl 1010 ¬_ ¬¬_ infixl 1005 _∧_ infixl 1004 _∨_ infixl 1000 _↔_ ------------------------------------------ -- Conjunction (AND) _∧_ : ∀{ℓ₁ ℓ₂} → Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt _∧_ = _⨯_ pattern [∧]-intro p q = p , q [∧]-elimₗ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ∧ Q) → P [∧]-elimₗ = Tuple.left [∧]-elimᵣ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ∧ Q) → Q [∧]-elimᵣ = Tuple.right [∧]-map = Tuple.map ------------------------------------------ -- Implication [→]-elim : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → P → (P → Q) → Q [→]-elim p f = f(p) [→]-intro : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P → Q) → (P → Q) [→]-intro f(p) = f(p) ------------------------------------------ -- Reverse implication open Functional using (_←_) public [←]-intro : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P → Q) → (Q ← P) [←]-intro = [→]-intro [←]-elim : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → P → (Q ← P) → Q [←]-elim = [→]-elim ------------------------------------------ -- Equivalence _↔_ : ∀{ℓ₁ ℓ₂} → Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt P ↔ Q = ((P ← Q) ⨯ (P → Q)) pattern [↔]-intro l r = l , r [↔]-elimₗ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → Q → (P ↔ Q) → P [↔]-elimₗ = swap Tuple.left [↔]-elimᵣ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → P → (P ↔ Q) → Q [↔]-elimᵣ = swap Tuple.right [↔]-to-[←] : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ↔ Q) → (Q → P) [↔]-to-[←] = Tuple.left [↔]-to-[→] : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ↔ Q) → (P → Q) [↔]-to-[→] = Tuple.right ------------------------------------------ -- Disjunction (OR) _∨_ : ∀{ℓ₁ ℓ₂} → Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt _∨_ = _‖_ pattern [∨]-introₗ l = Either.Left l pattern [∨]-introᵣ r = Either.Right r [∨]-elim : ∀{ℓ₁ ℓ₂ ℓ₃}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}}{R : Stmt{ℓ₃}} → (P → R) → (Q → R) → (P ∨ Q) → R [∨]-elim = Either.map1 [∨]-elim2 = Either.map ------------------------------------------ -- Bottom (false, absurdity, empty, contradiction) ⊥ : Stmt{Lvl.𝟎} ⊥ = Empty [⊥]-intro : ∀{ℓ}{P : Stmt{ℓ}} → P → (P → ⊥) → ⊥ [⊥]-intro = apply [⊥]-elim : ∀{ℓ}{P : Stmt{ℓ}} → ⊥ → P [⊥]-elim = empty ------------------------------------------ -- Top (true, truth, unit, validity) ⊤ : Stmt{Lvl.𝟎} ⊤ = Unit pattern [⊤]-intro = <> ------------------------------------------ -- Negation ¬_ : ∀{ℓ} → Stmt{ℓ} → Stmt ¬_ {ℓ} T = (T → ⊥) [¬]-intro : ∀{ℓ}{P : Stmt{ℓ}} → (P → ⊥) → (¬ P) [¬]-intro = id [¬]-elim : ∀{ℓ}{P : Stmt{ℓ}} → (¬ P) → (P → ⊥) -- written like (P → (¬ P) → ⊥) looks like a [⊥]-intro [¬]-elim = id ¬¬_ : ∀{ℓ} → Stmt{ℓ} → Stmt ¬¬ p = ¬(¬ p) ------------------------------------------ -- Exclusive disjunction (XOR) data _⊕_ {ℓ₁ ℓ₂} (P : Stmt{ℓ₁}) (Q : Stmt{ℓ₂}) : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where [⊕]-introₗ : P → (¬ Q) → (P ⊕ Q) [⊕]-introᵣ : Q → (¬ P) → (P ⊕ Q) ------------------------------------------ -- Negative disjunction (NOR) _⊽_ : ∀{ℓ₁ ℓ₂} → Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt p ⊽ q = (¬ p) ∧ (¬ q) [⊽]-intro : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (¬ P) → (¬ Q) → (P ⊽ Q) [⊽]-intro = [∧]-intro [⊽]-elimₗ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ⊽ Q) → ¬ P [⊽]-elimₗ = [∧]-elimₗ [⊽]-elimᵣ : ∀{ℓ₁ ℓ₂}{P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} → (P ⊽ Q) → ¬ Q [⊽]-elimᵣ = [∧]-elimᵣ ------------------------------------------ -- Negative conjunction (NAND) -- data _⊼_ {P : Stmt} {Q : Stmt} : Stmt where -- [⊼]-intro ¬(P ∧ Q) → (P ⊼ Q) -- -- [⊼]-elim : {P Q : Stmt} → (P ⨯ Q ⨯ (P ⊼ Q)) → ⊥ -- [⊼]-elim(p , q , nand)
{ "alphanum_fraction": 0.4161370544, "avg_line_length": 23.9668874172, "ext": "agda", "hexsha": "3e0d402ebf25a9271d818772403035a275fc9074", "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": "Logic/Propositional.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": "Logic/Propositional.agda", "max_line_length": 101, "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": "Logic/Propositional.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": 1741, "size": 3619 }
{- Basic theory about transport: - transport is invertible - transport is an equivalence ([transportEquiv]) -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Transport where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv -- Direct definition of transport filler, note that we have to -- explicitly tell Agda that the type is constant (like in CHM) transpFill : ∀ {ℓ} {A : Type ℓ} (φ : I) (A : (i : I) → Type ℓ [ φ ↦ (λ _ → A) ]) (u0 : outS (A i0)) → -------------------------------------- PathP (λ i → outS (A i)) u0 (transp (λ i → outS (A i)) φ u0) transpFill φ A u0 i = transp (λ j → outS (A (i ∧ j))) (~ i ∨ φ) u0 transport⁻ : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → B → A transport⁻ p = transport (λ i → p (~ i)) transport⁻Transport : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (a : A) → transport⁻ p (transport p a) ≡ a transport⁻Transport p a j = transp (λ i → p (~ i ∧ ~ j)) j (transp (λ i → p (i ∧ ~ j)) j a) transportTransport⁻ : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (b : B) → transport p (transport⁻ p b) ≡ b transportTransport⁻ p b j = transp (λ i → p (i ∨ j)) j (transp (λ i → p (~ i ∨ j)) j b) -- Transport is an equivalence isEquivTransport : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) → isEquiv (transport p) isEquivTransport {A = A} {B = B} p = transport (λ i → isEquiv (λ x → transp (λ j → p (i ∧ j)) (~ i) x)) (idIsEquiv A) transportEquiv : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → A ≃ B transportEquiv p = (transport p , isEquivTransport p)
{ "alphanum_fraction": 0.541003672, "avg_line_length": 36.3111111111, "ext": "agda", "hexsha": "e6711488e753acbe3532788270bcaa6d40b2aa20", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Foundations/Transport.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Foundations/Transport.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Foundations/Transport.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 582, "size": 1634 }
------------------------------------------------------------------------ -- Injections ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Injection {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open Derived-definitions-and-properties eq open import Prelude as P hiding (id) renaming (_∘_ to _⊚_) ------------------------------------------------------------------------ -- Injections -- The property of being injective. Injective : ∀ {a b} {A : Type a} {B : Type b} → (A → B) → Type (a ⊔ b) Injective f = ∀ {x y} → f x ≡ f y → x ≡ y infix 0 _↣_ -- Injections. record _↣_ {f t} (From : Type f) (To : Type t) : Type (f ⊔ t) where field to : From → To injective : Injective to ------------------------------------------------------------------------ -- Preorder -- _↣_ is a preorder. id : ∀ {a} {A : Type a} → A ↣ A id = record { to = P.id ; injective = P.id } infixr 9 _∘_ _∘_ : ∀ {a b c} {A : Type a} {B : Type b} {C : Type c} → B ↣ C → A ↣ B → A ↣ C f ∘ g = record { to = to′ ; injective = injective′ } where open _↣_ to′ = to f ⊚ to g injective′ : Injective to′ injective′ = injective g ⊚ injective f -- "Equational" reasoning combinators. infix -1 finally-↣ infixr -2 step-↣ -- For an explanation of why step-↣ is defined in this way, see -- Equality.step-≡. step-↣ : ∀ {a b c} (A : Type a) {B : Type b} {C : Type c} → B ↣ C → A ↣ B → A ↣ C step-↣ _ = _∘_ syntax step-↣ A B↣C A↣B = A ↣⟨ A↣B ⟩ B↣C finally-↣ : ∀ {a b} (A : Type a) (B : Type b) → A ↣ B → A ↣ B finally-↣ _ _ A↣B = A↣B syntax finally-↣ A B A↣B = A ↣⟨ A↣B ⟩□ B □
{ "alphanum_fraction": 0.4513325608, "avg_line_length": 22.4155844156, "ext": "agda", "hexsha": "2ecbfe82fc6d1a52646995066d65f7af709df2c8", "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/Injection.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/Injection.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/Injection.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": 610, "size": 1726 }
module Negation where -- Imports open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Data.Nat using (ℕ; zero; suc) open import Data.Empty using (⊥; ⊥-elim) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_) -- open import plfa.part1.Isomorphism using (_≃_; extensionality) -- 同型 (isomorphism) infix 0 _≃_ record _≃_ (A B : Set) : Set where field to : A → B from : B → A from∘to : ∀ (x : A) → from (to x) ≡ x to∘from : ∀ (y : B) → to (from y) ≡ y open _≃_ postulate -- 外延性の公理 extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) ----------------------- → f ≡ g -- Negation (否定) infix 3 ¬_ ¬_ : Set → Set ¬ A = A → ⊥ ¬-elim : ∀ {A : Set} → ¬ A → A --- → ⊥ ¬-elim ¬x x = ¬x x -- 二重否定の導入則 ¬¬-intro : ∀ {A : Set} → A ----- → ¬ ¬ A ¬¬-intro x = λ{¬x → ¬x x} -- 二重否定の導入則 ¬¬-intro′ : ∀ {A : Set} → A ----- → ¬ ¬ A ¬¬-intro′ x ¬x = ¬x x -- 三重否定の除去則 ¬¬¬-elim : ∀ {A : Set} → ¬ ¬ ¬ A ------- → ¬ A ¬¬¬-elim ¬¬¬x = λ x → ¬¬¬x (¬¬-intro x) -- 対偶 (contraposition) contraposition : ∀ {A B : Set} → (A → B) ----------- → (¬ B → ¬ A) contraposition f ¬y x = ¬y (f x) -- 不等号(inequality) _≢_ : ∀ {A : Set} → A → A → Set x ≢ y = ¬ (x ≡ y) _ : 1 ≢ 2 _ = λ() peano : ∀ {m : ℕ} → zero ≢ suc m peano = λ() id : ⊥ → ⊥ id x = x id′ : ⊥ → ⊥ id′ () id≡id′ : id ≡ id′ id≡id′ = extensionality (λ()) -- 同化 assimilation : ∀ {A : Set} (¬x ¬x′ : ¬ A) → ¬x ≡ ¬x′ assimilation ¬x ¬x′ = extensionality (λ x → ⊥-elim (¬x x)) -- Excluded middle is irrefutable -- 排中律 (excluded middle) postulate em : ∀ {A : Set} → A ⊎ ¬ A -- 排中律は反駁できない em-irrefutable : ∀ {A : Set} → ¬ ¬ (A ⊎ ¬ A) em-irrefutable k = k (inj₂ λ{ x → k (inj₁ x) })
{ "alphanum_fraction": 0.4791666667, "avg_line_length": 17.4117647059, "ext": "agda", "hexsha": "09f3184d917c67acda7441a98a345efa2e385daa", "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/negation/Negation.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/negation/Negation.agda", "max_line_length": 67, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/negation/Negation.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": 820, "size": 1776 }
{-# OPTIONS --copatterns #-} module Control.Functor.NaturalTransformation where open import Function using (id; _∘_) open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; module ≡-Reasoning) open ≡-Reasoning open import Control.Functor using (Functor; module Functor; Const) open import Control.Category using (Category; module Category) -- Natural transformations. IsNatTrans : (F! G! : Functor) → let open Functor F! using () renaming (F to F; map to mapF) open Functor G! using () renaming (F to G; map to mapG) in (n : ∀ {A} → F A → G A) → Set₁ IsNatTrans F! G! eta = ∀ {A B} (f : A → B) → let open Functor F! using () renaming (F to F; map to mapF) open Functor G! using () renaming (F to G; map to mapG) in eta ∘ mapF f ≡ mapG f ∘ eta -- Constant-Constant natural transformation. KKNat : ∀ {A B} (η : A → B) → IsNatTrans (Const A) (Const B) η KKNat η = λ f → refl -- Natural transformations (packaged). record NatTrans (F! G! : Functor) : Set₁ where open Functor F! using () renaming (F to F; map to mapF) open Functor G! using () renaming (F to G; map to mapG) field eta : ∀ {A} → F A → G A naturality : ∀ {A B} (f : A → B) → eta ∘ mapF f ≡ mapG f ∘ eta -- To use naturality in applications: postulate app-naturality : ∀ {A : Set} {B C : A → Set} (f : (x : A) → B x → C x) (g : (x : A) → F (B x)) (x : A) → eta (mapF (f x) (g x)) ≡ mapG (f x) (eta (g x)) -- app-naturality g f x = {!!} open NatTrans -- The identity natural transformation. Id : ∀ {F! : Functor} → NatTrans F! F! Id {F! = F!} = record { eta = λ x → x ; naturality = λ f → refl } -- Natural transformations compose. Comp : ∀ {F! G! H! : Functor} → NatTrans F! G! → NatTrans G! H! → NatTrans F! H! Comp {F! = F!}{G! = G!}{H! = H!} n m = record { eta = nm ; naturality = snm } where open Functor F! using () renaming (F to F; map to mapF) open Functor G! using () renaming (F to G; map to mapG) open Functor H! using () renaming (F to H; map to mapH) nm : ∀ {A} → F A → H A nm = λ x → eta m (eta n x) snm : ∀ {A B} (f : A → B) → nm ∘ mapF f ≡ mapH f ∘ nm snm f = begin nm ∘ mapF f ≡⟨⟩ eta m ∘ eta n ∘ mapF f ≡⟨ cong (λ z → eta m ∘ z) (naturality n f) ⟩ eta m ∘ mapG f ∘ eta n ≡⟨ cong (λ z → z ∘ eta n) (naturality m f) ⟩ mapH f ∘ eta m ∘ eta n ≡⟨⟩ mapH f ∘ nm ∎ -- Natural transformation between constant functors. ConstNat : ∀ {A B} (η : A → B) → NatTrans (Const A) (Const B) ConstNat η = record { eta = η ; naturality = λ f → refl } -- Functor category. FunctorHom : ∀ (F G : Functor) → Setoid _ _ FunctorHom F G = record { Carrier = NatTrans F G ; _≈_ = λ n m → ∀ {A} → eta n {A} ≡ eta m {A} ; isEquivalence = record { refl = refl ; sym = λ p → sym p ; trans = λ p q → trans p q } } FUNCTOR : Category _ _ _ FUNCTOR = record { Hom = FunctorHom ; isCategory = record { ops = record { id = Id ; _⟫_ = Comp } ; laws = record { id-first = refl ; id-last = refl ; ∘-assoc = λ f → refl ; ∘-cong = λ n≡n' m≡m' → cong₂ (λ m n x → m (n x)) m≡m' n≡n' } } }
{ "alphanum_fraction": 0.5472547255, "avg_line_length": 26.4523809524, "ext": "agda", "hexsha": "787593912f22098d49b63d4d5b8f8215d7abbd74", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_path": "src/Control/Functor/NaturalTransformation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andreasabel/cubical", "max_issues_repo_path": "src/Control/Functor/NaturalTransformation.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_path": "src/Control/Functor/NaturalTransformation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1199, "size": 3333 }
module Test2 where open import Test -- Testing the inter-file goto facility. test : ℕ test = 12 + 34 + 56 -- Testing qualified names. Eq = Test.Equiv {Test.ℕ}
{ "alphanum_fraction": 0.6890243902, "avg_line_length": 12.6153846154, "ext": "agda", "hexsha": "c5e85d09da68cfcddf1da4c74fa4e1a6cb60b776", "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/syntax/highlighting/Test2.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/syntax/highlighting/Test2.agda", "max_line_length": 40, "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/syntax/highlighting/Test2.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": 48, "size": 164 }
module Sort (A : Set)(_<_ : A → A → Set) where
{ "alphanum_fraction": 0.5652173913, "avg_line_length": 46, "ext": "agda", "hexsha": "b7ab4339122de797aebe3af99a2dc894af49cce6", "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": "112a706f266941d6ec8cb107d18476f9d7ffbbc6", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "neosimsim/merkdas", "max_forks_repo_path": "dependently-typed-programming-in-agda_norell-chapman/Sort.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6", "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": "neosimsim/merkdas", "max_issues_repo_path": "dependently-typed-programming-in-agda_norell-chapman/Sort.agda", "max_line_length": 46, "max_stars_count": 1, "max_stars_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "neosimsim/merkdas", "max_stars_repo_path": "dependently-typed-programming-in-agda_norell-chapman/Sort.agda", "max_stars_repo_stars_event_max_datetime": "2020-05-26T08:08:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-26T08:08:13.000Z", "num_tokens": 16, "size": 46 }
module Everything where open import Relation.Binary.Core postulate A : Set postulate _≤_ : A → A → Set postulate tot≤ : Total _≤_ postulate trans≤ : Transitive _≤_ open import BBHeap.Everything _≤_ tot≤ trans≤ open import BHeap.Everything _≤_ tot≤ open import BTree.Complete.Alternative.Correctness {A} open import BubbleSort.Everything _≤_ tot≤ trans≤ open import Heapsort.Everything _≤_ tot≤ trans≤ open import InsertSort.Everything _≤_ tot≤ open import List.Permutation.Base.Bag A open import Mergesort.Everything _≤_ tot≤ open import PLRTree.Everything _≤_ tot≤ trans≤ open import Quicksort.Everything _≤_ tot≤ trans≤ open import SelectSort.Everything _≤_ tot≤ trans≤ open import TreeSort.Everything _≤_ tot≤ trans≤
{ "alphanum_fraction": 0.7752043597, "avg_line_length": 22.2424242424, "ext": "agda", "hexsha": "4a696337d00519e048501af3c107c0f237dc46cb", "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/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/Everything.agda", "max_line_length": 54, "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/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 253, "size": 734 }
----------------------------------------------------------------------- -- This file defines DC₂(Sets) and its SMC structure. -- ----------------------------------------------------------------------- module DC2Sets where open import prelude -- The objects: Obj : Set₁ Obj = Σ[ U ∈ Set ] (Σ[ X ∈ Set ] (U → X → Set)) -- The morphisms: Hom : Obj → Obj → Set Hom (U , X , α) (V , Y , β) = Σ[ f ∈ (U → V) ] (Σ[ F ∈ (U → Y → X) ] (∀{u : U}{y : Y} → α u (F u y) → β (f u) y)) -- Composition: comp : {A B C : Obj} → Hom A B → Hom B C → Hom A C comp {(U , X , α)} {(V , Y , β)} {(W , Z , γ)} (f , F , p₁) (g , G , p₂) = (g ∘ f , (λ u z → F u (G (f u) z)), (λ {u} {y} p₃ → p₂ (p₁ p₃))) infixl 5 _○_ _○_ = comp -- The contravariant hom-functor: Homₐ : {A' A B B' : Obj} → Hom A' A → Hom B B' → Hom A B → Hom A' B' Homₐ f h g = comp f (comp g h) -- The identity function: id : {A : Obj} → Hom A A id {(U , V , α)} = (id-set , curry snd , id-set) -- In this formalization we will only worry about proving that the -- data of morphisms are equivalent, and not worry about the morphism -- conditions. This will make proofs shorter and faster. -- -- If we have parallel morphisms (f,F) and (g,G) in which we know that -- f = g and F = G, then the condition for (f,F) will imply the -- condition of (g,G) and vice versa. Thus, we can safely ignore it. infix 4 _≡h_ _≡h_ : {A B : Obj} → (f g : Hom A B) → Set _≡h_ {(U , X , α)}{(V , Y , β)} (f , F , p₁) (g , G , p₂) = f ≡ g × F ≡ G ≡h-refl : {A B : Obj}{f : Hom A B} → f ≡h f ≡h-refl {U , X , α}{V , Y , β}{f , F , _} = refl , refl ≡h-trans : ∀{A B}{f g h : Hom A B} → f ≡h g → g ≡h h → f ≡h h ≡h-trans {U , X , α}{V , Y , β}{f , F , _}{g , G , _}{h , H , _} (p₁ , p₂) (p₃ , p₄) rewrite p₁ | p₂ | p₃ | p₄ = refl , refl ≡h-sym : ∀{A B}{f g : Hom A B} → f ≡h g → g ≡h f ≡h-sym {U , X , α}{V , Y , β}{f , F , _}{g , G , _} (p₁ , p₂) rewrite p₁ | p₂ = refl , refl ≡h-subst-○ : ∀{A B C}{f₁ f₂ : Hom A B}{g₁ g₂ : Hom B C}{j : Hom A C} → f₁ ≡h f₂ → g₁ ≡h g₂ → f₂ ○ g₂ ≡h j → f₁ ○ g₁ ≡h j ≡h-subst-○ {U , X , α} {V , Y , β} {W , Z , γ} {f₁ , F₁ , _} {f₂ , F₂ , _} {g₁ , G₁ , _} {g₂ , G₂ , _} {j , J , _} (p₅ , p₆) (p₇ , p₈) (p₉ , p₁₀) rewrite p₅ | p₆ | p₇ | p₈ | p₉ | p₁₀ = refl , refl ○-assoc : ∀{A B C D}{f : Hom A B}{g : Hom B C}{h : Hom C D} → f ○ (g ○ h) ≡h (f ○ g) ○ h ○-assoc {U , X , α}{V , Y , β}{W , Z , γ}{S , T , ι} {f , F , _}{g , G , _}{h , H , _} = refl , refl ○-idl : ∀{A B}{f : Hom A B} → id ○ f ≡h f ○-idl {U , X , _}{V , Y , _}{f , F , _} = refl , refl ○-idr : ∀{A B}{f : Hom A B} → f ○ id ≡h f ○-idr {U , X , _}{V , Y , _}{f , F , _} = refl , refl ----------------------------------------------------------------------- -- DC₂(Sets) is a SMC -- ----------------------------------------------------------------------- -- The tensor functor: ⊗ _⊗ᵣ_ : ∀{U X V Y : Set} → (U → X → Set) → (V → Y → Set) → ((U × V) → (X × Y) → Set) _⊗ᵣ_ α β (u , v) (x , y) = (α u x) × (β v y) _⊗ₒ_ : (A B : Obj) → Obj (U , X , α) ⊗ₒ (V , Y , β) = ((U × V) , (X × Y) , α ⊗ᵣ β) F⊗ : ∀{Z T V X U Y : Set}{F : U → Z → X}{G : V → T → Y} → (U × V) → (Z × T) → (X × Y) F⊗ {F = F}{G} (u , v) (z , t) = F u z , G v t _⊗ₐ_ : {A B C D : Obj} → Hom A C → Hom B D → Hom (A ⊗ₒ B) (C ⊗ₒ D) _⊗ₐ_ {(U , X , α)}{(V , Y , β)}{(W , Z , γ)}{(S , T , δ)} (f , F , p₁) (g , G , p₂) = ⟨ f , g ⟩ , F⊗ {F = F}{G} , p⊗ where p⊗ : {u : Σ U (λ x → V)} {y : Σ Z (λ x → T)} → (α ⊗ᵣ β) u (F⊗ {F = F}{G} u y) → (γ ⊗ᵣ δ) (⟨ f , g ⟩ u) y p⊗ {u , v}{z , t} (p₃ , p₄) = p₁ p₃ , p₂ p₄ -- The unit for tensor: ι : ⊤ → ⊤ → Set ι triv triv = ⊤ I : Obj I = (⊤ , ⊤ , ι) J : Obj J = (⊤ , ⊤ , (λ x y → ⊥)) -- The left-unitor: λ⊗-p : ∀{U X α}{u : Σ ⊤ (λ x → U)} {y : X} → (ι ⊗ᵣ α) u (triv , y) → α (snd u) y λ⊗-p {U}{X}{α}{(triv , u)}{x} = snd λ⊗ : ∀{A : Obj} → Hom (I ⊗ₒ A) A λ⊗ {(U , X , α)} = snd , (λ _ x → triv , x) , λ⊗-p λ⊗-inv : ∀{A : Obj} → Hom A (I ⊗ₒ A) λ⊗-inv {(U , X , α)} = (λ u → triv , u) , (λ _ r → snd r) , λ⊗-inv-p where λ⊗-inv-p : ∀{U X α}{u : U} {y : Σ ⊤ (λ x → X)} → α u (snd y) → (ι ⊗ᵣ α) (triv , u) y λ⊗-inv-p {U}{X}{α}{u}{triv , x} p = triv , p -- The right-unitor: ρ⊗ : ∀{A : Obj} → Hom (A ⊗ₒ I) A ρ⊗ {(U , X , α)} = fst , (λ r x → x , triv) , ρ⊗-p where ρ⊗-p : ∀{U X α}{u : Σ U (λ x → ⊤)} {y : X} → (α ⊗ᵣ ι) u (y , triv) → α (fst u) y ρ⊗-p {U}{X}{α}{(u , _)}{x} (p , _) = p ρ⊗-inv : ∀{A : Obj} → Hom A (A ⊗ₒ I) ρ⊗-inv {(U , X , α)} = (λ u → u , triv) , (λ u r → fst r) , ρ⊗-p-inv where ρ⊗-p-inv : ∀{U X α}{u : U} {y : Σ X (λ x → ⊤)} → α u (fst y) → (α ⊗ᵣ ι) (u , triv) y ρ⊗-p-inv {U}{X}{α}{u}{x , triv} p = p , triv -- Symmetry: β⊗ : ∀{A B : Obj} → Hom (A ⊗ₒ B) (B ⊗ₒ A) β⊗ {(U , X , α)}{(V , Y , β)} = twist-× , (λ r₁ r₂ → twist-× r₂) , β⊗-p where β⊗-p : ∀{U V Y X α β}{u : Σ U (λ x → V)} {y : Σ Y (λ x → X)} → (α ⊗ᵣ β) u (twist-× y) → (β ⊗ᵣ α) (twist-× u) y β⊗-p {U}{V}{Y}{X}{α}{β}{u , v}{y , x} = twist-× -- The associator: Fα-inv : ∀{ℓ}{U V W X Y Z : Set ℓ} → (U × (V × W)) → ((X × Y) × Z) → (X × (Y × Z)) Fα-inv (u , (v , w)) ((x , y) , z) = x , y , z α⊗-inv : ∀{A B C : Obj} → Hom (A ⊗ₒ (B ⊗ₒ C)) ((A ⊗ₒ B) ⊗ₒ C) α⊗-inv {(U , X , α)}{(V , Y , β)}{(W , Z , γ)} = rl-assoc-× , Fα-inv , α-inv-cond where α-inv-cond : {u : Σ U (λ x → Σ V (λ x₁ → W))}{y : Σ (Σ X (λ x → Y)) (λ x → Z)} → (α ⊗ᵣ (β ⊗ᵣ γ)) u (Fα-inv u y) → ((α ⊗ᵣ β) ⊗ᵣ γ) (rl-assoc-× u) y α-inv-cond {u , (v , w)}{(x , y) , z} (p₁ , (p₂ , p₃)) = (p₁ , p₂) , p₃ Fα : ∀{V W X Y U Z : Set} → ((U × V) × W) → (X × (Y × Z)) → ((X × Y) × Z) Fα {V}{W}{X}{Y}{U}{Z} ((u , v) , w) (x , (y , z)) = (x , y) , z α⊗ : ∀{A B C : Obj} → Hom ((A ⊗ₒ B) ⊗ₒ C) (A ⊗ₒ (B ⊗ₒ C)) α⊗ {(U , X , α)}{(V , Y , β)}{(W , Z , γ)} = (lr-assoc-× , Fα , α-cond) where α-cond : {u : Σ (Σ U (λ x → V)) (λ x → W)} {y : Σ X (λ x → Σ Y (λ x₁ → Z))} → ((α ⊗ᵣ β) ⊗ᵣ γ) u (Fα u y) → (α ⊗ᵣ (β ⊗ᵣ γ)) (lr-assoc-× u) y α-cond {(u , v) , w}{x , (y , z)} ((p₁ , p₂) , p₃) = p₁ , p₂ , p₃ α⊗-id₁ : ∀{A B C} → (α⊗ {A}{B}{C}) ○ α⊗-inv ≡h id α⊗-id₁ {U , X , α}{V , Y , β}{W , Z , γ} = ext-set aux , ext-set aux' where aux : {a : Σ (Σ U (λ x → V)) (λ x → W)} → rl-assoc-× (lr-assoc-× a) ≡ a aux {(u , v) , w} = refl aux' : {a : Σ (Σ U (λ x → V)) (λ x → W)} → (λ z → Fα {V}{W}{X}{Y}{U}{Z} a (Fα-inv (lr-assoc-× a) z)) ≡ (λ y → y) aux' {(u , v), w} = ext-set aux'' where aux'' : {a : Σ (Σ X (λ x → Y)) (λ x → Z)} → Fα ((u , v) , w) (Fα-inv (u , v , w) a) ≡ a aux'' {(x , y) , z} = refl α⊗-id₂ : ∀{A B C} → (α⊗-inv {A}{B}{C}) ○ α⊗ ≡h id α⊗-id₂ {U , X , α}{V , Y , β}{W , Z , γ} = ext-set aux , ext-set aux' where aux : {a : Σ U (λ x → Σ V (λ x₁ → W))} → lr-assoc-× (rl-assoc-× a) ≡ a aux {u , (v , w)} = refl aux' : {a : Σ U (λ x → Σ V (λ x₁ → W))} → (λ z → Fα-inv {_}{U}{V}{W}{X}{Y}{Z} a (Fα (rl-assoc-× a) z)) ≡ (λ y → y) aux' {u , (v , w)} = ext-set aux'' where aux'' : {a : Σ X (λ x → Σ Y (λ x₁ → Z))} → Fα-inv (u , v , w) (Fα ((u , v) , w) a) ≡ a aux'' {x , (y , z)} = refl -- Internal hom: ⊸-cond : ∀{U V X Y : Set}{α : U → X → Set}{β : V → Y → Set} → Σ (U → V) (λ x → U → Y → X) → Σ U (λ x → Y) → Set ⊸-cond {α = α}{β} (f , F) (u , y) = α u (F u y) → β (f u) y _⊸ₒ_ : Obj → Obj → Obj (U , X , α) ⊸ₒ (V , Y , β) = ((U → V) × (U → Y → X)) , ((U × Y) , ⊸-cond {α = α}{β}) _⊸ₐ_ : {A B C D : Obj} → Hom C A → Hom B D → Hom (A ⊸ₒ B) (C ⊸ₒ D) _⊸ₐ_ {(U , X , α)}{(V , Y , β)}{(W , Z , γ)}{(S , T , δ)} (f , F , p₁) (g , G , p₂) = h , H , cond where h : Σ (U → V) (λ x → U → Y → X) → Σ (W → S) (λ x → W → T → Z) h (i , I) = (λ w → g (i (f w))) , (λ w t → F w (I (f w) (G (i (f w)) t))) H : Σ (U → V) (λ x → U → Y → X) → Σ W (λ x → T) → Σ U (λ x → Y) H (i , I) (w , t) = f w , G (i (f w)) t cond : {u : Σ (U → V) (λ x → U → Y → X)} {y : Σ W (λ x → T)} → ⊸-cond {α = α}{β} u (H u y) → ⊸-cond {α = γ}{δ} (h u) y cond {i , I}{w , y} p₃ p₄ = p₂ (p₃ (p₁ p₄)) cur : {A B C : Obj} → Hom (A ⊗ₒ B) C → Hom A (B ⊸ₒ C) cur {U , X , α}{V , Y , β}{W , Z , γ} (f , F , p₁) = (λ u → (λ v → f (u , v)) , (λ v z → snd (F (u , v) z))) , (λ u r → fst (F (u , (fst r)) (snd r))) , cond where cond : {u : U} {y : Σ V (λ x → Z)} → α u (fst (F (u , fst y) (snd y))) → ⊸-cond {α = β}{γ} ((λ v → f (u , v)) , (λ v z → snd (F (u , v) z))) y cond {u}{v , z} p₂ p₃ with (p₁ {u , v}{z}) ... | p₄ with F (u , v) z ... | (x , y) = p₄ (p₂ , p₃) cur-≡h : ∀{A B C}{f₁ f₂ : Hom (A ⊗ₒ B) C} → f₁ ≡h f₂ → cur f₁ ≡h cur f₂ cur-≡h {U , X , α}{V , Y , β}{W , Z , γ} {f₁ , F₁ , p₁}{f₂ , F₂ , p₂} (p₃ , p₄) rewrite p₃ | p₄ = refl , refl cur-cong : ∀{A B C}{f₁ f₂ : Hom (A ⊗ₒ B) C} → f₁ ≡h f₂ → cur f₁ ≡h cur f₂ cur-cong {(U , X , α)} {(V , Y , β)} {(W , Z , γ)}{f₁ , F₁ , _}{f₂ , F₂ , _} (p₁ , p₂) rewrite p₁ | p₂ = refl , refl uncur : {A B C : Obj} → Hom A (B ⊸ₒ C) → Hom (A ⊗ₒ B) C uncur {U , X , α}{V , Y , β}{W , Z , γ} (f , F , p₁) = let h = λ r → fst (f (fst r)) (snd r) H = λ r z → F (fst r) (snd r , z) , snd (f (fst r)) (snd r) z in h , (H , cond) where cond : {u : Σ U (λ x → V)} {y : Z} → (α ⊗ᵣ β) u (F (fst u) (snd u , y) , snd (f (fst u)) (snd u) y) → γ (fst (f (fst u)) (snd u)) y cond {u , v}{z} (p₂ , p₃) with p₁ {u} {v , z} ... | p₄ with f u ... | i , I = p₄ p₂ p₃ cur-uncur-bij₁ : ∀{A B C}{f : Hom (A ⊗ₒ B) C} → uncur (cur f) ≡h f cur-uncur-bij₁ {U , X , α}{V , Y , β}{W , Z , γ}{f , F , p₁} = ext-set aux₁ , ext-set aux₂ where aux₁ : {a : Σ U (λ x → V)} → f (fst a , snd a) ≡ f a aux₁ {u , v} = refl aux₂ : {a : Σ U (λ x → V)} → (λ z → fst (F (fst a , snd a) z) , snd (F (fst a , snd a) z)) ≡ F a aux₂ {u , v} = ext-set aux₃ where aux₃ : {a : Z} → (fst (F (u , v) a) , snd (F (u , v) a)) ≡ F (u , v) a aux₃ {z} with F (u , v) z ... | x , y = refl cur-uncur-bij₂ : ∀{A B C}{g : Hom A (B ⊸ₒ C)} → cur (uncur g) ≡h g cur-uncur-bij₂ {U , X , α}{V , Y , β}{W , Z , γ}{g , G , p₁} = (ext-set aux) , ext-set (ext-set aux') where aux : {a : U} → ((λ v → fst (g a) v) , (λ v z → snd (g a) v z)) ≡ g a aux {u} with g u ... | i , I = refl aux' : {u : U}{r : Σ V (λ x → Z)} → G u (fst r , snd r) ≡ G u r aux' {u}{v , z} = refl -- The of-course exponential: !ₒ-cond : ∀{U X : Set} → (α : U → X → Set) → U → 𝕃 X → Set !ₒ-cond {U}{X} α u [] = ⊤ !ₒ-cond {U}{X} α u (x :: xs) = (α u x) × (!ₒ-cond α u xs) !ₒ-cond-++ : ∀{U X : Set}{α : U → X → Set}{u : U}{l₁ l₂ : 𝕃 X} → !ₒ-cond α u (l₁ ++ l₂) ≡ ((!ₒ-cond α u l₁) × (!ₒ-cond α u l₂)) !ₒ-cond-++ {U}{X}{α}{u}{[]}{l₂} = ∧-unit !ₒ-cond-++ {U}{X}{α}{u}{x :: xs}{l₂} rewrite !ₒ-cond-++ {U}{X}{α}{u}{xs}{l₂} = ∧-assoc !ₒ : Obj → Obj !ₒ (U , X , α) = U , X * , !ₒ-cond α !ₐ-s : ∀{U Y X : Set} → (U → Y → X) → (U → Y * → X *) !ₐ-s f u l = map (f u) l !ₐ : {A B : Obj} → Hom A B → Hom (!ₒ A) (!ₒ B) !ₐ {U , X , α}{V , Y , β} (f , F , p) = f , (!ₐ-s F , aux) where aux : {u : U} {y : 𝕃 Y} → !ₒ-cond α u (!ₐ-s F u y) → !ₒ-cond β (f u) y aux {u}{[]} p₁ = triv aux {u}{y :: ys} (p₁ , p₂) = p p₁ , aux p₂ -- Of-course is a comonad: ε : ∀{A} → Hom (!ₒ A) A ε {U , X , α} = id-set , (λ u x → [ x ]) , fst δ-s : {U X : Set} → U → 𝕃 (𝕃 X) → 𝕃 X δ-s u xs = foldr _++_ [] xs δ : ∀{A} → Hom (!ₒ A) (!ₒ (!ₒ A)) δ {U , X , α} = id-set , δ-s , cond where cond : {u : U} {y : 𝕃 (𝕃 X)} → !ₒ-cond α u (foldr _++_ [] y) → !ₒ-cond (!ₒ-cond α) u y cond {u}{[]} p = triv cond {u}{l :: ls} p with !ₒ-cond-++ {U}{X}{α}{u}{l}{foldr _++_ [] ls} ... | p' rewrite p' with p ... | p₂ , p₃ = p₂ , cond {u}{ls} p₃ comonand-diag₁ : ∀{A} → (δ {A}) ○ (!ₐ (δ {A})) ≡h (δ {A}) ○ (δ { !ₒ A}) comonand-diag₁ {U , X , α} = refl , ext-set (λ {x} → ext-set (λ {l} → aux {x} {l})) where aux : ∀{x : U}{l : 𝕃 (𝕃 (𝕃 X))} → foldr _++_ [] (!ₐ-s (λ u xs → foldr _++_ [] xs) x l) ≡ foldr _++_ [] (foldr _++_ [] l) aux {u}{[]} = refl aux {u}{x :: xs} rewrite aux {u}{xs} = foldr-append {_}{_}{X}{X}{x}{foldr _++_ [] xs} comonand-diag₂ : ∀{A} → (δ {A}) ○ (ε { !ₒ A}) ≡h (δ {A}) ○ (!ₐ (ε {A})) comonand-diag₂ {U , X , α} = refl , ext-set (λ {u} → ext-set (λ {l} → aux {l})) where aux : ∀{a : 𝕃 X} → a ++ [] ≡ foldr _++_ [] (map (λ x → x :: []) a) aux {[]} = refl aux {x :: xs} rewrite (++[] xs) | sym (foldr-map {_}{X}{xs}) = refl
{ "alphanum_fraction": 0.380553092, "avg_line_length": 36.2660818713, "ext": "agda", "hexsha": "925bd0b10d3da9a1ec85960964873cec8b2205e1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "dialectica-cats/DC2Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "dialectica-cats/DC2Sets.agda", "max_line_length": 124, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "dialectica-cats/DC2Sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6539, "size": 12403 }
module Esterel.Lang.CanFunction.MergePotentialRuleLeftBase where open import utility renaming (_U̬_ to _∪_ ; _|̌_ to _-_) open import Esterel.Lang open import Esterel.Lang.Binding open import Esterel.Lang.CanFunction open import Esterel.Lang.CanFunction.Base open import Esterel.Lang.CanFunction.CanThetaContinuation open import Esterel.Lang.CanFunction.MergePotentialRuleCan open import Esterel.Context using (EvaluationContext1 ; EvaluationContext ; _⟦_⟧e ; _≐_⟦_⟧e) open import Esterel.Context.Properties using (plug ; unplug) open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) open import Esterel.Variable.Sequential as SeqVar using (SeqVar) open EvaluationContext1 open _≐_⟦_⟧e open import Data.Bool using (Bool ; not ; if_then_else_) open import Data.Empty using (⊥ ; ⊥-elim) open import Data.List using (List ; [] ; _∷_ ; _++_ ; map ; concatMap ; foldr) open import Data.List.Properties using (map-id) open import Data.List.Any using (Any ; any ; here ; there) open import Data.List.Any.Properties using (++⁻) renaming (++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ) open import Data.Maybe using (Maybe ; maybe ; just ; nothing) open import Data.Nat using (ℕ ; zero ; suc ; _≟_ ; _+_) open import Data.Nat.Properties.Simple using (+-comm) open import Data.Product using (Σ ; proj₁ ; proj₂ ; ∃ ; _,_ ; _,′_ ; _×_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Function using (_∘_ ; id ; _∋_) open import Relation.Nullary using (¬_ ; Dec ; yes ; no) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary.PropositionalEquality using (_≡_ ; _≢_ ; refl ; trans ; sym ; cong ; subst ; module ≡-Reasoning) open ListSet Data.Nat._≟_ using (set-subtract ; set-subtract-[] ; set-subtract-split ; set-subtract-merge ; set-subtract-notin ; set-remove ; set-remove-mono-∈ ; set-remove-removed ; set-remove-not-removed ; set-subtract-[a]≡set-remove) open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM open ≡-Reasoning distinct'-S∷Ss⇒[S] : ∀ {xs S Ss} status → distinct' xs (S ∷ Ss) → distinct' xs (proj₁ (Dom [ (S ₛ) ↦ status ] )) distinct'-S∷Ss⇒[S] {xs} {S} {Ss} status xs≠S∷Ss S' S'∈xs S'∈[S] rewrite Env.sig-single-∈-eq (S' ₛ) (S ₛ) status S'∈[S] = xs≠S∷Ss S S'∈xs (here refl) canθₖ-mergeˡ-E-induction-base-par₁ : ∀ {E q E⟦nothin⟧∥q BV FV} sigs' S' r θ → E⟦nothin⟧∥q ≐ (epar₁ q ∷ E) ⟦ nothin ⟧e → CorrectBinding E⟦nothin⟧∥q BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → Canθₖ sigs' S' ((E ⟦ r ⟧e) ∥ q) θ ≡ concatMap (λ k → map (Code._⊔_ k) (Canₖ q θ)) (Canθₖ sigs' S' (E ⟦ r ⟧e) θ) canθₖ-mergeˡ-E-induction-base-par₁ [] S' r θ (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' = refl canθₖ-mergeˡ-E-induction-base-par₁ (nothing ∷ sigs') S' r θ (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₖ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (depar₁ E⟦nothin⟧) cb FV≠sigs' canθₖ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.present ∷ sigs') S' r θ (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r (θ ← [S]-env-present (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl canθₖ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.absent ∷ sigs') S' r θ (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl canθₖ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' with any (_≟_ S') (Canθₛ sigs' (suc S') ((E ⟦ r ⟧e) ∥ q) (θ ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) (θ ← [S]-env (S' ₛ))) ... | yes S'∈canθ-sigs'-E⟦r⟧∥q-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r (θ ← [S]-env (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl ... | no S'∉canθ-sigs'-E⟦r⟧∥q-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl ... | yes S'∈canθ-sigs'-E⟦r⟧∥q-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←[S'] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← [S]-env (S' ₛ)) (depar₁ dehole) (CBpar CBnothing cbq distinct-empty-left distinct-empty-left distinct-empty-left (λ _ ())) (dist'++ʳ {V2 = proj₁ FVp} (distinct'-sym (dist'++ʳ {V2 = S' ∷ []} FV≠sigs'))) (S' ₛ) (λ S'∈FVq → FV≠sigs' S' (++ʳ (proj₁ FVp) S'∈FVq) (here refl)) S'∈canθ-sigs'-E⟦r⟧∥q-θ←[S'])) ... | no S'∉canθ-sigs'-E⟦r⟧∥q-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧∥q-θ←[S'] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← [S]-env (S' ₛ)) (epar₁ q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←[S'])) canθₖ-mergeˡ-E-induction-base-par₂ : ∀ {E q q∥E⟦nothin⟧ BV FV} sigs' S' r θ → q∥E⟦nothin⟧ ≐ (epar₂ q ∷ E) ⟦ nothin ⟧e → CorrectBinding q∥E⟦nothin⟧ BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → Canθₖ sigs' S' (q ∥ (E ⟦ r ⟧e)) θ ≡ concatMap (λ k → map (Code._⊔_ k) (Canθₖ sigs' S' (E ⟦ r ⟧e) θ)) (Canₖ q θ) canθₖ-mergeˡ-E-induction-base-par₂ [] S' r θ (depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbq _ _ _ _ _) FV≠sigs' = refl canθₖ-mergeˡ-E-induction-base-par₂ (nothing ∷ sigs') S' r θ (depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbq _ _ _ _ _) FV≠sigs' rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₖ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (depar₂ E⟦nothin⟧) cb FV≠sigs' canθₖ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.present ∷ sigs') S' r θ (depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbq _ _ _ _ _) FV≠sigs' rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left dist'++ˡ (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r (θ ← [S]-env-present (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl canθₖ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.absent ∷ sigs') S' r θ (depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbq _ _ _ _ _) FV≠sigs' rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left dist'++ˡ (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl canθₖ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ (depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbq _ _ _ _ _) FV≠sigs' with any (_≟_ S') (Canθₛ sigs' (suc S') (q ∥ (E ⟦ r ⟧e)) (θ ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) (θ ← [S]-env (S' ₛ))) ... | yes S'∈canθ-sigs'-q∥E⟦r⟧-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env (S' ₛ)) q cbq (distinct'-to-left dist'++ˡ (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r (θ ← [S]-env (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl ... | no S'∉canθ-sigs'-q∥E⟦r⟧-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left dist'++ˡ (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') = refl ... | yes S'∈canθ-sigs'-q∥E⟦r⟧-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←[S'] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← [S]-env (S' ₛ)) (depar₂ dehole) (CBpar cbq CBnothing distinct-empty-right distinct-empty-right distinct-empty-right (λ _ _ ())) (λ S' S'∈map-+-suc-S'-sigs' S'∈FVq++[] → FV≠sigs' S' (++ˡ (x∈xs++[]→x∈xs {xs = proj₁ FVp} S'∈FVq++[])) (there S'∈map-+-suc-S'-sigs')) (S' ₛ) (λ S'∈FVq++[] → FV≠sigs' S' (++ˡ (x∈xs++[]→x∈xs {xs = proj₁ FVp} S'∈FVq++[])) (here refl)) S'∈canθ-sigs'-q∥E⟦r⟧-θ←[S'])) ... | no S'∉canθ-sigs'-q∥E⟦r⟧-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] = ⊥-elim (S'∉canθ-sigs'-q∥E⟦r⟧-θ←[S'] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← [S]-env (S' ₛ)) (epar₂ q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←[S'])) canθₖ-mergeˡ-E-induction-base-seq-notin : ∀ {E q E⟦nothin⟧>>q BV FV} sigs' S' r θ → E⟦nothin⟧>>q ≐ (eseq q ∷ E) ⟦ nothin ⟧e → CorrectBinding E⟦nothin⟧>>q BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → Code.nothin ∉ Canθₖ sigs' S' (E ⟦ r ⟧e) θ → Canθₖ sigs' S' ((E ⟦ r ⟧e) >> q) θ ≡ Canθₖ sigs' S' (E ⟦ r ⟧e) θ canθₖ-mergeˡ-E-induction-base-seq-notin {E} [] S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∉canθ-sigs'-E⟦r⟧-θ with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) θ) ... | no nothin∉can-E⟦r⟧-θ = refl ... | yes nothin∈can-E⟦r⟧-θ = ⊥-elim (nothin∉canθ-sigs'-E⟦r⟧-θ nothin∈can-E⟦r⟧-θ) canθₖ-mergeˡ-E-induction-base-seq-notin (nothing ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∉canθ-sigs'-E⟦r⟧-θ rewrite map-+-compose-suc S' (SigMap.keys sigs') | canθₖ-mergeˡ-E-induction-base-seq-notin sigs' (suc S') r θ (deseq E⟦nothin⟧) cb FV≠sigs' nothin∉canθ-sigs'-E⟦r⟧-θ = refl canθₖ-mergeˡ-E-induction-base-seq-notin {E} (just Signal.present ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∉canθ-sigs'-E⟦r⟧-θ rewrite map-+-compose-suc S' (SigMap.keys sigs') | canθₖ-mergeˡ-E-induction-base-seq-notin sigs' (suc S') r (θ ← [S]-env-present (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') nothin∉canθ-sigs'-E⟦r⟧-θ = refl canθₖ-mergeˡ-E-induction-base-seq-notin {E} (just Signal.absent ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∉canθ-sigs'-E⟦r⟧-θ rewrite map-+-compose-suc S' (SigMap.keys sigs') | canθₖ-mergeˡ-E-induction-base-seq-notin sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') nothin∉canθ-sigs'-E⟦r⟧-θ = refl canθₖ-mergeˡ-E-induction-base-seq-notin {E} {q} (just Signal.unknown ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∉canθ-sigs'-E⟦r⟧-θ with any (_≟_ S') (Canθₛ sigs' (suc S') ((E ⟦ r ⟧e) >> q) (θ ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) (θ ← [S]-env (S' ₛ))) ... | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] rewrite map-+-compose-suc S' (SigMap.keys sigs') | canθₖ-mergeˡ-E-induction-base-seq-notin sigs' (suc S') r (θ ← [S]-env (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') nothin∉canθ-sigs'-E⟦r⟧-θ = refl ... | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite map-+-compose-suc S' (SigMap.keys sigs') | canθₖ-mergeˡ-E-induction-base-seq-notin sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') nothin∉canθ-sigs'-E⟦r⟧-θ = refl ... | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←[S'] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← [S]-env (S' ₛ)) (deseq dehole) (CBseq CBnothing cbq distinct-empty-left) (dist'++ʳ {V2 = proj₁ FVp} (distinct'-sym (dist'++ʳ {V2 = S' ∷ []} FV≠sigs'))) (S' ₛ) (λ S'∈FVq → FV≠sigs' S' (++ʳ (proj₁ FVp) S'∈FVq) (here refl)) S'∈canθ-sigs'-E⟦r⟧>>q-θ←[S'])) ... | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧>>q-θ←[S'] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← [S]-env (S' ₛ)) (eseq q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←[S'])) canθₖ-mergeˡ-E-induction-base-seq-in : ∀ {E q E⟦nothin⟧>>q BV FV} sigs' S' r θ → E⟦nothin⟧>>q ≐ (eseq q ∷ E) ⟦ nothin ⟧e → CorrectBinding E⟦nothin⟧>>q BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → Code.nothin ∈ Canθₖ sigs' S' (E ⟦ r ⟧e) θ → Canθₖ sigs' S' ((E ⟦ r ⟧e) >> q) θ ≡ CodeSet.set-remove (Canθₖ sigs' S' (E ⟦ r ⟧e) θ) Code.nothin ++ Canₖ q θ canθₖ-mergeˡ-E-induction-base-seq-in {E} [] S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∈canθ-sigs'-E⟦r⟧-θ with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) θ) ... | no nothin∉can-E⟦r⟧-θ = ⊥-elim (nothin∉can-E⟦r⟧-θ nothin∈canθ-sigs'-E⟦r⟧-θ) ... | yes nothin∈can-E⟦r⟧-θ = refl canθₖ-mergeˡ-E-induction-base-seq-in (nothing ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∈canθ-sigs'-E⟦r⟧-θ rewrite map-+-compose-suc S' (SigMap.keys sigs') | canθₖ-mergeˡ-E-induction-base-seq-in sigs' (suc S') r θ (deseq E⟦nothin⟧) cb FV≠sigs' nothin∈canθ-sigs'-E⟦r⟧-θ = refl canθₖ-mergeˡ-E-induction-base-seq-in {E} {q} (just Signal.present ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∈canθ-sigs'-E⟦r⟧-θ rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-seq-in sigs' (suc S') r (θ ← [S]-env-present (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') nothin∈canθ-sigs'-E⟦r⟧-θ = refl canθₖ-mergeˡ-E-induction-base-seq-in {E} {q} (just Signal.absent ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∈canθ-sigs'-E⟦r⟧-θ rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-seq-in sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') nothin∈canθ-sigs'-E⟦r⟧-θ = refl canθₖ-mergeˡ-E-induction-base-seq-in {E} {q} (just Signal.unknown ∷ sigs') S' r θ (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} cbp cbq _) FV≠sigs' nothin∈canθ-sigs'-E⟦r⟧-θ with any (_≟_ S') (Canθₛ sigs' (suc S') ((E ⟦ r ⟧e) >> q) (θ ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) (θ ← [S]-env (S' ₛ))) ... | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-seq-in sigs' (suc S') r (θ ← [S]-env (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') nothin∈canθ-sigs'-E⟦r⟧-θ = refl ... | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | can-irr θ ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | canθₖ-mergeˡ-E-induction-base-seq-in sigs' (suc S') r (θ ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' ∷ []} FV≠sigs') nothin∈canθ-sigs'-E⟦r⟧-θ = refl ... | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←[S'] rewrite map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←[S'] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← [S]-env (S' ₛ)) (deseq dehole) (CBseq CBnothing cbq distinct-empty-left) (dist'++ʳ {V2 = proj₁ FVp} (distinct'-sym (dist'++ʳ {V2 = S' ∷ []} FV≠sigs'))) (S' ₛ) (λ S'∈FVq → FV≠sigs' S' (++ʳ (proj₁ FVp) S'∈FVq) (here refl)) S'∈canθ-sigs'-E⟦r⟧>>q-θ←[S'])) ... | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←[S'] = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧>>q-θ←[S'] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← [S]-env (S' ₛ)) (eseq q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←[S'])) canθₛ-mergeˡ-E-induction-base-par₁ : ∀ {E q E⟦nothin⟧∥q BV FV} sigs' S' r θ θo → E⟦nothin⟧∥q ≐ (epar₁ q ∷ E) ⟦ nothin ⟧e → CorrectBinding E⟦nothin⟧∥q BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → ∀ S'' → S'' ∈ Canθₛ sigs' S' ((E ⟦ r ⟧e) ∥ q) (θ ← θo) → S'' ∈ Canθₛ sigs' S' (E ⟦ r ⟧e) (θ ← θo) ⊎ S'' ∈ Canₛ q (θ ← θo) canθₛ-mergeˡ-E-induction-base-par₁ {E} [] S' r θ θo E⟦nothin⟧∥q cb FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo with ++⁻ (Canₛ (E ⟦ r ⟧e) (θ ← θo)) S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ S''∈can-E⟦r⟧-θ←θo = inj₁ S''∈can-E⟦r⟧-θ←θo ... | inj₂ S''∈can-q-θ←θo = inj₂ S''∈can-q-θ←θo canθₛ-mergeˡ-E-induction-base-par₁ (nothing ∷ sigs') S' r θ θo E⟦nothin⟧∥q cb FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₛ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ θo E⟦nothin⟧∥q cb FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo canθₛ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.present ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-present (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env-present (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] ... | inj₂ S''∈can-q-θ←θo←[S'↦present] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | Env.←-assoc θ θo ([S]-env-present (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦present] canθₛ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.absent ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ S''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦absent] canθₛ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo with any (_≟_ S') (Canθₛ sigs' (suc S') ((E ⟦ r ⟧e) ∥ q) ((θ ← θo) ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) ((θ ← θo) ← [S]-env (S' ₛ))) canθₛ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] ... | inj₂ S''∈can-q-θ←θo←[S'↦unknown] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | Env.←-assoc θ θo ([S]-env (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦unknown] canθₛ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ S''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦absent] canθₛ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (epar₁ q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S])) canθₛ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbp cbq _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (depar₁ dehole) (CBpar CBnothing cbq distinct-empty-left distinct-empty-left distinct-empty-left (λ _ ())) (dist'++ʳ {V2 = proj₁ FVp} (distinct'-sym (dist'++ʳ {V2 = S' ∷ []} FV≠sigs'))) (S' ₛ) (λ S'∈FVq → FV≠sigs' S' (++ʳ (proj₁ FVp) S'∈FVq) (here refl)) S'∈canθ-sigs'-E⟦r⟧∥q-θ←θo←[S])) canθₛ-mergeˡ-E-induction-base-par₂ : ∀ {E q q∥E⟦nothin⟧ BV FV} sigs' S' r θ θo → q∥E⟦nothin⟧ ≐ (epar₂ q ∷ E) ⟦ nothin ⟧e → CorrectBinding q∥E⟦nothin⟧ BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → ∀ S'' → S'' ∈ Canθₛ sigs' S' (q ∥ (E ⟦ r ⟧e)) (θ ← θo) → S'' ∈ Canθₛ sigs' S' (E ⟦ r ⟧e) (θ ← θo) ⊎ S'' ∈ Canₛ q (θ ← θo) canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} [] S' r θ θo q∥E⟦nothin⟧ cb FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo with ++⁻ (Canₛ q (θ ← θo)) S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₂ S''∈can-E⟦r⟧-θ←θo = inj₁ S''∈can-E⟦r⟧-θ←θo ... | inj₁ S''∈can-q-θ←θo = inj₂ S''∈can-q-θ←θo canθₛ-mergeˡ-E-induction-base-par₂ (nothing ∷ sigs') S' r θ θo q∥E⟦nothin⟧ cb FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₛ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ θo q∥E⟦nothin⟧ cb FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.present ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-present (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env-present (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] ... | inj₂ S''∈can-q-θ←θo←[S'↦present] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | Env.←-assoc θ θo ([S]-env-present (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦present] canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.absent ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ S''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦absent] canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo with any (_≟_ S') (Canθₛ sigs' (suc S') (q ∥ (E ⟦ r ⟧e)) ((θ ← θo) ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) ((θ ← θo) ← [S]-env (S' ₛ))) canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | yes S'∈canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] ... | inj₂ S''∈can-q-θ←θo←[S'↦unknown] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | Env.←-assoc θ θo ([S]-env (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦unknown] canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | no S'∉canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ S''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ S''∈can-q-θ←θo←[S'↦absent] canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | no S'∉canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) = ⊥-elim (S'∉canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (epar₂ q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S])) canθₛ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbq _ _ _ _ _) FV≠sigs' S'' S''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | yes S'∈canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (depar₂ dehole) (CBpar cbq CBnothing distinct-empty-right distinct-empty-right distinct-empty-right (λ _ _ ())) (λ S''' S'''∈map-+-suc-S'-sigs' S'''∈FVq++[] → FV≠sigs' S''' (++ˡ (x∈xs++[]→x∈xs {xs = proj₁ FVp} S'''∈FVq++[])) (there S'''∈map-+-suc-S'-sigs')) (S' ₛ) (λ S'∈FVq++[] → FV≠sigs' S' (++ˡ (x∈xs++[]→x∈xs {xs = proj₁ FVp} S'∈FVq++[])) (here refl)) S'∈canθ-sigs'-q∥E⟦r⟧-θ←θo←[S])) canθₛ-mergeˡ-E-induction-base-seq : ∀ {E q E⟦nothin⟧>>q BV FV} sigs' S' r θ θo → E⟦nothin⟧>>q ≐ (eseq q ∷ E) ⟦ nothin ⟧e → CorrectBinding E⟦nothin⟧>>q BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → ∀ S'' → S'' ∈ Canθₛ sigs' S' ((E ⟦ r ⟧e) >> q) (θ ← θo) → S'' ∈ Canθₛ sigs' S' (E ⟦ r ⟧e) (θ ← θo) ⊎ (S'' ∈ Canₛ q (θ ← θo) × Code.nothin ∈ Canθₖ sigs' S' (E ⟦ r ⟧e) (θ ← θo)) canθₛ-mergeˡ-E-induction-base-seq {E} {q} [] S' r θ θo E⟦nothin⟧>>q cb FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) (θ ← θo)) ... | no nothin∉can-E⟦r⟧-θ←θo = inj₁ S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | yes nothin∈can-E⟦r⟧-θ←θo with ++⁻ (Canₛ (E ⟦ r ⟧e) (θ ← θo)) S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ S''∈can-E⟦r⟧-θ←θo = inj₁ S''∈can-E⟦r⟧-θ←θo ... | inj₂ S''∈can-q-θ←θo = inj₂ (S''∈can-q-θ←θo ,′ nothin∈can-E⟦r⟧-θ←θo) canθₛ-mergeˡ-E-induction-base-seq {E} {q} (nothing ∷ sigs') S' r θ θo E⟦nothin⟧>>q cb FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₛ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ θo E⟦nothin⟧>>q cb FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo canθₛ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.present ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-present (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env-present (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] ... | inj₂ (S''∈can-q-θ←θo←[S'↦present] , nothin∈can-E⟦r⟧-θ←θo←[S'↦present]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | Env.←-assoc θ θo ([S]-env-present (S' ₛ)) = inj₂ (S''∈can-q-θ←θo←[S'↦present] , nothin∈can-E⟦r⟧-θ←θo←[S'↦present]) canθₛ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.absent ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ (S''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ (S''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) canθₛ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo with any (_≟_ S') (Canθₛ sigs' (suc S') ((E ⟦ r ⟧e) >> q) ((θ ← θo) ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) ((θ ← θo) ← [S]-env (S' ₛ))) canθₛ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] ... | inj₂ (S''∈can-q-θ←θo←[S'↦unknown] , nothin∈can-E⟦r⟧-θ←θo←[S'↦unknown]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | Env.←-assoc θ θo ([S]-env (S' ₛ)) = inj₂ (S''∈can-q-θ←θo←[S'↦unknown] , nothin∈can-E⟦r⟧-θ←θo←[S'↦unknown]) canθₛ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ S''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ (S''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ (S''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) canθₛ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (eseq q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S'])) canθₛ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' S'' S''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S'] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (deseq dehole) (CBseq CBnothing cbq distinct-empty-left) (dist'++ʳ {V2 = proj₁ FVp} (distinct'-sym (dist'++ʳ {V2 = S' ∷ []} FV≠sigs'))) (S' ₛ) (λ S'∈FVq → FV≠sigs' S' (++ʳ (proj₁ FVp) S'∈FVq) (here refl)) S'∈canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'])) canθₛₕ-mergeˡ-E-induction-base-par₁ : ∀ {E q E⟦nothin⟧∥q BV FV} sigs' S' r θ θo → E⟦nothin⟧∥q ≐ (epar₁ q ∷ E) ⟦ nothin ⟧e → CorrectBinding E⟦nothin⟧∥q BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → ∀ s'' → s'' ∈ Canθₛₕ sigs' S' ((E ⟦ r ⟧e) ∥ q) (θ ← θo) → s'' ∈ Canθₛₕ sigs' S' (E ⟦ r ⟧e) (θ ← θo) ⊎ s'' ∈ Canₛₕ q (θ ← θo) canθₛₕ-mergeˡ-E-induction-base-par₁ {E} [] S' r θ θo E⟦nothin⟧∥q cb FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo with ++⁻ (Canₛₕ (E ⟦ r ⟧e) (θ ← θo)) s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ s''∈can-E⟦r⟧-θ←θo = inj₁ s''∈can-E⟦r⟧-θ←θo ... | inj₂ s''∈can-q-θ←θo = inj₂ s''∈can-q-θ←θo canθₛₕ-mergeˡ-E-induction-base-par₁ (nothing ∷ sigs') S' r θ θo E⟦nothin⟧∥q cb FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₛₕ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ θo E⟦nothin⟧∥q cb FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo canθₛₕ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.present ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-present (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env-present (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] ... | inj₂ s''∈can-q-θ←θo←[S'↦present] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | Env.←-assoc θ θo ([S]-env-present (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦present] canθₛₕ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.absent ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ s''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦absent] canθₛₕ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo with any (_≟_ S') (Canθₛ sigs' (suc S') ((E ⟦ r ⟧e) ∥ q) ((θ ← θo) ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) ((θ ← θo) ← [S]-env (S' ₛ))) canθₛₕ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] ... | inj₂ s''∈can-q-θ←θo←[S'↦unknown] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | Env.←-assoc θ θo ([S]-env (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦unknown] canθₛₕ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₁ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₁ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ s''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦absent] canθₛₕ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} _ cbq _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (epar₁ q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S])) canθₛₕ-mergeˡ-E-induction-base-par₁ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₁ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbp cbq _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧∥q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧∥q-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (depar₁ dehole) (CBpar CBnothing cbq distinct-empty-left distinct-empty-left distinct-empty-left (λ _ ())) (dist'++ʳ {V2 = proj₁ FVp} (distinct'-sym (dist'++ʳ {V2 = S' ∷ []} FV≠sigs'))) (S' ₛ) (λ S'∈FVq → FV≠sigs' S' (++ʳ (proj₁ FVp) S'∈FVq) (here refl)) S'∈canθ-sigs'-E⟦r⟧∥q-θ←θo←[S])) canθₛₕ-mergeˡ-E-induction-base-par₂ : ∀ {E q q∥E⟦nothin⟧ BV FV} sigs' S' r θ θo → q∥E⟦nothin⟧ ≐ (epar₂ q ∷ E) ⟦ nothin ⟧e → CorrectBinding q∥E⟦nothin⟧ BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → ∀ s'' → s'' ∈ Canθₛₕ sigs' S' (q ∥ (E ⟦ r ⟧e)) (θ ← θo) → s'' ∈ Canθₛₕ sigs' S' (E ⟦ r ⟧e) (θ ← θo) ⊎ s'' ∈ Canₛₕ q (θ ← θo) canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} [] S' r θ θo q∥E⟦nothin⟧ cb FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo with ++⁻ (Canₛₕ q (θ ← θo)) s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₂ s''∈can-E⟦r⟧-θ←θo = inj₁ s''∈can-E⟦r⟧-θ←θo ... | inj₁ s''∈can-q-θ←θo = inj₂ s''∈can-q-θ←θo canθₛₕ-mergeˡ-E-induction-base-par₂ (nothing ∷ sigs') S' r θ θo q∥E⟦nothin⟧ cb FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₛₕ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ θo q∥E⟦nothin⟧ cb FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.present ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-present (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env-present (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] ... | inj₂ s''∈can-q-θ←θo←[S'↦present] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | Env.←-assoc θ θo ([S]-env-present (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦present] canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.absent ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ s''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦absent] canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo with any (_≟_ S') (Canθₛ sigs' (suc S') (q ∥ (E ⟦ r ⟧e)) ((θ ← θo) ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) ((θ ← θo) ← [S]-env (S' ₛ))) canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | yes S'∈canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] ... | inj₂ s''∈can-q-θ←θo←[S'↦unknown] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | Env.←-assoc θ θo ([S]-env (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦unknown] canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | no S'∉canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-par₂ sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (depar₂ E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ s''∈can-q-θ←θo←[S'↦absent] rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ˡ) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ s''∈can-q-θ←θo←[S'↦absent] canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar cbq _ _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | no S'∉canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) = ⊥-elim (S'∉canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (epar₂ q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S])) canθₛₕ-mergeˡ-E-induction-base-par₂ {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (depar₂ E⟦nothin⟧) cb@(CBpar {FVp = FVp} cbq _ _ _ _ _) FV≠sigs' s'' s''∈canθ-sigs'-q∥E⟦r⟧-θ←θo | yes S'∈canθ-sigs'-q∥E⟦r⟧-θ←θo←[S] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (depar₂ dehole) (CBpar cbq CBnothing distinct-empty-right distinct-empty-right distinct-empty-right (λ _ _ ())) (λ s''' s'''∈map-+-suc-S'-sigs' s'''∈FVq++[] → FV≠sigs' s''' (++ˡ (x∈xs++[]→x∈xs {xs = proj₁ FVp} s'''∈FVq++[])) (there s'''∈map-+-suc-S'-sigs')) (S' ₛ) (λ S'∈FVq++[] → FV≠sigs' S' (++ˡ (x∈xs++[]→x∈xs {xs = proj₁ FVp} S'∈FVq++[])) (here refl)) S'∈canθ-sigs'-q∥E⟦r⟧-θ←θo←[S])) canθₛₕ-mergeˡ-E-induction-base-seq : ∀ {E q E⟦nothin⟧>>q BV FV} sigs' S' r θ θo → E⟦nothin⟧>>q ≐ (eseq q ∷ E) ⟦ nothin ⟧e → CorrectBinding E⟦nothin⟧>>q BV FV → distinct' (proj₁ FV) (map (_+_ S') (SigMap.keys sigs')) → ∀ s'' → s'' ∈ Canθₛₕ sigs' S' ((E ⟦ r ⟧e) >> q) (θ ← θo) → s'' ∈ Canθₛₕ sigs' S' (E ⟦ r ⟧e) (θ ← θo) ⊎ (s'' ∈ Canₛₕ q (θ ← θo) × Code.nothin ∈ Canθₖ sigs' S' (E ⟦ r ⟧e) (θ ← θo)) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} [] S' r θ θo E⟦nothin⟧>>q cb FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) (θ ← θo)) ... | no nothin∉can-E⟦r⟧-θ←θo = inj₁ s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | yes nothin∈can-E⟦r⟧-θ←θo with ++⁻ (Canₛₕ (E ⟦ r ⟧e) (θ ← θo)) s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ s''∈can-E⟦r⟧-θ←θo = inj₁ s''∈can-E⟦r⟧-θ←θo ... | inj₂ s''∈can-q-θ←θo = inj₂ (s''∈can-q-θ←θo ,′ nothin∈can-E⟦r⟧-θ←θo) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (nothing ∷ sigs') S' r θ θo E⟦nothin⟧>>q cb FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθₛₕ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ θo E⟦nothin⟧>>q cb FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.present ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-present (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env-present (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦present] ... | inj₂ (s''∈can-q-θ←θo←[S'↦present] , nothin∈can-E⟦r⟧-θ←θo←[S'↦present]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-present (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.present FV≠sigs')) | Env.←-assoc θ θo ([S]-env-present (S' ₛ)) = inj₂ (s''∈can-q-θ←θo←[S'↦present] , nothin∈can-E⟦r⟧-θ←θo←[S'↦present]) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.absent ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ (s''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ (s''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo with any (_≟_ S') (Canθₛ sigs' (suc S') ((E ⟦ r ⟧e) >> q) ((θ ← θo) ← [S]-env (S' ₛ))) | any (_≟_ S') (Canθₛ sigs' (suc S') (E ⟦ r ⟧e) ((θ ← θo) ← [S]-env (S' ₛ))) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦unknown] ... | inj₂ (s''∈can-q-θ←θo←[S'↦unknown] , nothin∈can-E⟦r⟧-θ←θo←[S'↦unknown]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.unknown FV≠sigs')) | Env.←-assoc θ θo ([S]-env (S' ₛ)) = inj₂ (s''∈can-q-θ←θo←[S'↦unknown] , nothin∈can-E⟦r⟧-θ←θo←[S'↦unknown]) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env-absent (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') with canθₛₕ-mergeˡ-E-induction-base-seq sigs' (suc S') r θ (θo ← [S]-env-absent (S' ₛ)) (deseq E⟦nothin⟧) cb (dist'++ʳ {V2 = S' + 0 ∷ []} FV≠sigs') s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo ... | inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] = inj₁ s''∈canθ-sigs'-E⟦r⟧-θ←θo←[S'↦absent] ... | inj₂ (s''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) rewrite +-comm S' 0 | can-irr (θ ← θo) ([S]-env-absent (S' ₛ)) q cbq (distinct'-to-left (dist'++ʳ {V2 = proj₁ FVp}) (distinct'-S∷Ss⇒[S] Signal.absent FV≠sigs')) | Env.←-assoc θ θo ([S]-env-absent (S' ₛ)) = inj₂ (s''∈can-q-θ←θo←[S'↦absent] , nothin∈can-E⟦r⟧-θ←θo←[S'↦absent]) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | no S'∉canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | yes S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] (canθₛ-p⊆canθₛ-E₁⟦p⟧ sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (eseq q) (E ⟦ r ⟧e) (S' ₛ) S'∈canθ-sigs'-E⟦r⟧-θ←θo←[S'])) canθₛₕ-mergeˡ-E-induction-base-seq {E} {q} (just Signal.unknown ∷ sigs') S' r θ θo (deseq E⟦nothin⟧) cb@(CBseq {FVp = FVp} _ cbq _) FV≠sigs' s'' s''∈canθ-sigs'-E⟦r⟧>>q-θ←θo | yes S'∈canθ-sigs'-E⟦r⟧>>q-θ←θo←[S'] | no S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S'] rewrite sym (Env.←-assoc θ θo ([S]-env (S' ₛ))) | map-+-compose-suc S' (SigMap.keys sigs') | +-comm S' 0 = ⊥-elim (S'∉canθ-sigs'-E⟦r⟧-θ←θo←[S'] (canθₛ-E₁⟦p⟧⊆canθₛ-p sigs' (suc S') (θ ← (θo ← [S]-env (S' ₛ))) (deseq dehole) (CBseq CBnothing cbq distinct-empty-left) (dist'++ʳ {V2 = proj₁ FVp} (distinct'-sym (dist'++ʳ {V2 = S' ∷ []} FV≠sigs'))) (S' ₛ) (λ S'∈FVq → FV≠sigs' S' (++ʳ (proj₁ FVp) S'∈FVq) (here refl)) S'∈canθ-sigs'-E⟦r⟧>>q-θ←θo←[S']))
{ "alphanum_fraction": 0.5338397671, "avg_line_length": 52.6319129646, "ext": "agda", "hexsha": "43cac2311917d4521e62c669b58257bd6a55cfeb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Esterel/Lang/CanFunction/MergePotentialRuleLeftBase.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/Esterel/Lang/CanFunction/MergePotentialRuleLeftBase.agda", "max_line_length": 107, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Esterel/Lang/CanFunction/MergePotentialRuleLeftBase.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 31203, "size": 58053 }
{- This second-order signature was created from the following second-order syntax description: syntax CommMonoid | CM type * : 0-ary term unit : * | ε add : * * -> * | _⊕_ l20 theory (εU⊕ᴸ) a |> add (unit, a) = a (εU⊕ᴿ) a |> add (a, unit) = a (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c)) (⊕C) a b |> add(a, b) = add(b, a) -} module CommMonoid.Signature where open import SOAS.Context open import SOAS.Common open import SOAS.Syntax.Signature *T public open import SOAS.Syntax.Build *T public -- Operator symbols data CMₒ : Set where unitₒ addₒ : CMₒ -- Term signature CM:Sig : Signature CMₒ CM:Sig = sig λ { unitₒ → ⟼₀ * ; addₒ → (⊢₀ *) , (⊢₀ *) ⟼₂ * } open Signature CM:Sig public
{ "alphanum_fraction": 0.6054421769, "avg_line_length": 17.5, "ext": "agda", "hexsha": "dfb4b5a097619506a081a43efa0942a44795b63e", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/CommMonoid/Signature.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/CommMonoid/Signature.agda", "max_line_length": 91, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/CommMonoid/Signature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 292, "size": 735 }
{-# OPTIONS --type-in-type #-} module AgdaPrelude where data Nat : Set where Zero : Nat Succ : Nat -> Nat natElim : (m : Nat -> Set) -> (mz : m Zero) -> (ms : (l : Nat) -> m l -> m (Succ l)) -> (k : Nat) -> m k natElim m mz ms Zero = mz natElim m mz ms (Succ k) = ms k (natElim m mz ms k) data Vec : Set -> Nat -> Set where Nil : (a : Set) -> Vec a Zero Cons : (a : Set) -> (n : Nat) -> (x : a) -> (xs : Vec a n) -> Vec a (Succ n) data Eq : (a : Set) -> a -> a -> Set where Refl : (a : Set) -> (x : a) -> Eq a x x
{ "alphanum_fraction": 0.4990548204, "avg_line_length": 29.3888888889, "ext": "agda", "hexsha": "25de0f71e3ac7e054743e65d1db4f7c457ab24ad", "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": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "JoeyEremondi/lambda-pi-constraint", "max_forks_repo_path": "thesisExamples/AgdaPrelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "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": "JoeyEremondi/lambda-pi-constraint", "max_issues_repo_path": "thesisExamples/AgdaPrelude.agda", "max_line_length": 104, "max_stars_count": 16, "max_stars_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "JoeyEremondi/lambda-pi-constraint", "max_stars_repo_path": "thesisExamples/AgdaPrelude.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-05T20:21:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-16T11:14:56.000Z", "num_tokens": 206, "size": 529 }
module TypeSig where f : {A : Set} → A → A f x = x g : {A : Set} → A → A g x = x h : {A : Set} → A → A h x = f x _ : {A : Set} → A → A _ = λ x → x
{ "alphanum_fraction": 0.3260869565, "avg_line_length": 5.935483871, "ext": "agda", "hexsha": "7f3db954ff34e9c950502620f1c96db619da3aa4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/declaration/TypeSig.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "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": "msuperdock/agda-unused", "max_issues_repo_path": "data/declaration/TypeSig.agda", "max_line_length": 20, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/declaration/TypeSig.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 102, "size": 184 }
module Issue317 (A : Set) where postulate F : Set → Set -- Try evaluating F A at the top-level: -- -- 1,3-4 -- Not in scope: -- A at 1,3-4 -- when scope checking A -- -- OK, in that case the inferred type of F should be -- (A : Set) → Set → Set, right? No, it isn't, it's Set → Set. -- -- I think the parameters should be in scope when "top-level" commands -- are executed, because these commands should behave in the same way -- as commands executed in a top-level goal at the end of the module. -- It seems as if the implementation of -- Agda.Interaction.BasicOps.atTopLevel has to be modified.
{ "alphanum_fraction": 0.68718802, "avg_line_length": 30.05, "ext": "agda", "hexsha": "a3de895e0cea02780ea6295789431769b72347fc", "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/Issue317.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/Issue317.agda", "max_line_length": 70, "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/Issue317.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": 170, "size": 601 }
-- In this document we'll consider various encodings of mutual data types, -- including those that are System Fω compatible. module MutualData where open import Function open import Data.Unit.Base open import Data.Sum open import Data.Product -- In the first part of this document we'll demostrate how various encodings work taking -- the rose tree data type as an example: mutual data Tree₀ (A : Set) : Set where node₀ : A -> Forest₀ A -> Tree₀ A data Forest₀ (A : Set) : Set where nil₀ : Forest₀ A cons₀ : Tree₀ A -> Forest₀ A -> Forest₀ A module Joined where -- For encoding a family of mutually recursive data types in terms of a single data type we can -- create the type of tags each of which denotes a particular data type from the family, then -- merge all constructors of the original data types together into a single data type and index -- each of the constructors by the tag representing the data type it constructs. -- Since we encode a family consisting of two data types, the type of tags has two inhabitants: data TreeForestᵗ : Set where Treeᵗ Forestᵗ : TreeForestᵗ -- The encoding: mutual -- There is nothing inherently mutual about these data types. -- `Tree` and `Forest` are just aliases defined for convenience and readability. Tree : Set -> Set Tree A = TreeForest A Treeᵗ Forest : Set -> Set Forest A = TreeForest A Forestᵗ -- Now we have one big data type that contains all constructors of the `Tree`-`Forest` family: data TreeForest (A : Set) : TreeForestᵗ -> Set where node : A -> Forest A -> Tree A nil : Forest A cons : Tree A -> Forest A -> Forest A -- Note that the constructors have exactly the same type signatures as before, -- but now `Tree` and `Forest` are instances of the same data type. -- As a sanity check we show one side (just to save space and because it's demonstrative enough) -- of the isomorphism between the original family and its encoded version: mutual toTree₀ : ∀ {A} -> Tree A -> Tree₀ A toTree₀ (node x forest) = node₀ x (toForest₀ forest) toForest₀ : ∀ {A} -> Forest A -> Forest₀ A toForest₀ nil = nil₀ toForest₀ (cons tree forest) = cons₀ (toTree₀ tree) (toForest₀ forest) -- The encoding technique described in this module is fairly well-known. module JoinedCompute where -- In this section we'll make `TreeForest` a data type with a single constructor, -- the contents of which depends on the type being constructed. data TreeForestᵗ : Set where Treeᵗ Forestᵗ : TreeForestᵗ mutual -- Again, `Tree` and `Forest` are just aliases. Tree : Set -> Set Tree A = TreeForest A Treeᵗ Forest : Set -> Set Forest A = TreeForest A Forestᵗ -- `TreeForestF` matches on the `TreeForestᵗ` index in order to figure out which data type -- from the original family is being constructed. -- Like in the previous section `TreeForest` defines both the `Tree` and `Forest` data types, -- but now it contains a single constructor that only captures the notion of recursion. -- What data to store in this constructor is determined by the `TreeForestF` function. TreeForestF : Set -> TreeForestᵗ -> Set TreeForestF A Treeᵗ = A × Forest A -- The only constructor of `Tree` is `node` which -- carries an `A` and a `Forest A`. TreeForestF A Forestᵗ = ⊤ ⊎ Tree A × Forest A -- There are two constructors of `Forest`: -- `nil` and `cons`. The former one doesn't -- carry any information while the latter one -- receives a `Tree` and a `Forest`. data TreeForest (A : Set) (tfᵗ : TreeForestᵗ) : Set where treeForest : TreeForestF A tfᵗ -> TreeForest A tfᵗ -- For convenience, we'll be using pattern synonyms in this module and the modules below. pattern node x forest = treeForest (x , forest) pattern nil = treeForest (inj₁ tt) pattern cons tree forest = treeForest (inj₂ (tree , forest)) -- The sanity check. mutual toTree₀ : ∀ {A} -> Tree A -> Tree₀ A toTree₀ (node x forest) = node₀ x (toForest₀ forest) toForest₀ : ∀ {A} -> Forest A -> Forest₀ A toForest₀ nil = nil₀ toForest₀ (cons tree forest) = cons₀ (toTree₀ tree) (toForest₀ forest) -- In the previous section we had the `TreeForest` data type and its `treeForest` constructor -- which together captured the notion of recursion. This pattern can be abstracted, so that we can -- tie knots in arbitrary other data types -- not just `Tree` and `Forest`. Enter `IFix`: {-# NO_POSITIVITY_CHECK #-} data IFix {α β} {A : Set α} (B : (A -> Set β) -> A -> Set β) (x : A) : Set β where wrap : B (IFix B) x -> IFix B x module JoinedComputeIFix where -- In this module we define the `TreeForest` data type using `IFix`. -- The type of tags is as before: data TreeForestᵗ : Set where Treeᵗ Forestᵗ : TreeForestᵗ -- The definition of `TreeForest` is similar to the definition from the previous section: -- we again have the `Tree` and `Forest` type aliases, they're just local now, -- and as before we dispatch on `tfᵗ` and describe the constructors of the `Tree` and `Forest` -- data types using the sum-of-products representation: TreeForest : Set -> TreeForestᵗ -> Set TreeForest A = IFix λ Rec tfᵗ -> let Tree = Rec Treeᵗ Forest = Rec Forestᵗ in case tfᵗ of λ { Treeᵗ -> A × Forest ; Forestᵗ -> ⊤ ⊎ Tree × Forest } -- We've cheated a little bit here by keeping `A` outside of the pattern functor. -- That's just for simplicity, there is no fundamental limitation that prevents us -- from taking fixed points of pattern functors of arbitrary arity. -- Which is a topic for another document. Tree : Set -> Set Tree A = TreeForest A Treeᵗ Forest : Set -> Set Forest A = TreeForest A Forestᵗ pattern node x forest = wrap (x , forest) pattern nil = wrap (inj₁ tt) pattern cons tree forest = wrap (inj₂ (tree , forest)) -- The sanity check. mutual toTree₀ : ∀ {A} -> Tree A -> Tree₀ A toTree₀ (node x forest) = node₀ x (toForest₀ forest) toForest₀ : ∀ {A} -> Forest A -> Forest₀ A toForest₀ nil = nil₀ toForest₀ (cons tree forest) = cons₀ (toTree₀ tree) (toForest₀ forest) module JoinedComputeIFixFω where -- The types we had previously are not System Fω compatible, because we matched on tags at the -- type level. Can we avoid this? Yes, easily. Instead of defining data types representing tags -- we can just lambda-encode them, because we do have lambdas at the type level in System Fω. -- The Church-encoded version of `TreeForestᵗ` at the type level looks like this: -- ∀ R -> (Set -> Set -> R) -> R -- However this is still not System Fω compatible, because here we quantify over `R` which in -- System Fω is a kind and we can't quatify over kinds there. But looking at -- TreeForestF : Set -> TreeForestᵗ -> Set -- TreeForestF A Treeᵗ = A × Forest A -- TreeForestF A Forestᵗ = ⊤ ⊎ Tree A × Forest A -- we see that we match on a `TreeForestᵗ` only to return a `Set`. Hence we can just instantiate -- `R` to `Set` right away as we do not do anything else with tags. We arrive at TreeForestᵗ : Set₁ TreeForestᵗ = Set -> Set -> Set Treeᵗ : TreeForestᵗ Treeᵗ A B = A Forestᵗ : TreeForestᵗ Forestᵗ A B = B -- Where `TreeForestᵗ` is the type of inlined matchers which always return a `Set` and -- `Treeᵗ` and `Forestᵗ` are such matchers. The rest is straightforward: TreeForest : Set -> TreeForestᵗ -> Set TreeForest A = IFix λ Rec tfᵗ -> let Tree = Rec Treeᵗ Forest = Rec Forestᵗ in tfᵗ (A × Forest) -- Returned when `tfᵗ` is `Treeᵗ`. (⊤ ⊎ Tree × Forest) -- Returned when `tfᵗ` is `Forestᵗ`. Tree : Set -> Set Tree A = TreeForest A Treeᵗ Forest : Set -> Set Forest A = TreeForest A Forestᵗ -- All types are System Fω compatible (except the definition of `TreeForestᵗ` has to be inlined) -- as System Fω does not support kind aliases. pattern node x forest = wrap (x , forest) pattern nil = wrap (inj₁ tt) pattern cons tree forest = wrap (inj₂ (tree , forest)) -- The sanity check. mutual toTree₀ : ∀ {A} -> Tree A -> Tree₀ A toTree₀ (node x forest) = node₀ x (toForest₀ forest) toForest₀ : ∀ {A} -> Forest A -> Forest₀ A toForest₀ nil = nil₀ toForest₀ (cons tree forest) = cons₀ (toTree₀ tree) (toForest₀ forest) -- An additional test: mutual mapTree : ∀ {A B} -> (A -> B) -> Tree A -> Tree B mapTree f (node x forest) = node (f x) (mapForest f forest) mapForest : ∀ {A B} -> (A -> B) -> Forest A -> Forest B mapForest f nil = nil mapForest f (cons tree forest) = cons (mapTree f tree) (mapForest f forest) -- The first part ends here. We've just seen how to encode mutual data types in pure System Fω -- with build-in isorecursive `IFix :: ((k -> *) -> k -> *) -> k -> *`. -- In the second part we'll see how to encode mutual data types with distinct kind signatures. -- Due to my lack of imagination, we'll take the following family as an example: mutual data M₀ (A : Set) : Set where p₀ : A -> M₀ A n₀ : N₀ -> M₀ A data N₀ : Set where m₀ : M₀ ⊤ -> N₀ -- `M₀` is of kind `Set -> Set` while `N₀` is of kind `Set`. module DistinctParamsJoined where -- As in the first part we start with a single data type that contains all the constructors of -- the family of data types being encoded. -- The only thing we need to do, is to add all the parameters to the constructors of the type -- of tags. The rest just follows. data MNᵗ : Set₁ where Mᵗ : Set -> MNᵗ -- `M` is parameterized by a `Set`, hence one `Set` argument. Nᵗ : MNᵗ -- `N` is not parameterized, hence no arguments. -- The encoding itself follows the same pattern we've seen previously: mutual M : Set -> Set M A = MN (Mᵗ A) N : Set N = MN Nᵗ data MN : MNᵗ -> Set where -- `∀ {A} -> ...` is an artifact of this particular encoding, it'll disappear later. p : ∀ {A} -> A -> M A n : ∀ {A} -> N -> M A m : M ⊤ -> N -- The sanity check. mutual toM₀ : ∀ {A} -> M A -> M₀ A toM₀ (p x) = p₀ x toM₀ (n y) = n₀ (toN₀ y) toN₀ : N -> N₀ toN₀ (m y) = m₀ (toM₀ y) module DistinctParamsJoinedComputeIFix where -- We skip the `JoinedCompute` stage and jump straight to `JoinedComputeIFix`. -- Again, we just add arguments to tags and the rest follows: data MNᵗ : Set₁ where Mᵗ : Set -> MNᵗ Nᵗ : MNᵗ MN : MNᵗ -> Set MN = IFix λ Rec mnᵗ -> let M A = Rec (Mᵗ A) N = Rec Nᵗ in case mnᵗ of λ { (Mᵗ A) -> A ⊎ N -- `M` has two constructors: one receives an `A` and -- the other receives an `N`. ; Nᵗ -> M ⊤ -- `N` has one constructor which receives an `M ⊤`. } M : Set -> Set M A = MN (Mᵗ A) N : Set N = MN Nᵗ pattern p x = wrap (inj₁ x) pattern n y = wrap (inj₂ y) pattern m y = wrap y -- The sanity check. mutual toM₀ : ∀ {A} -> M A -> M₀ A toM₀ (p x) = p₀ x toM₀ (n y) = n₀ (toN₀ y) toN₀ : N -> N₀ toN₀ (m y) = m₀ (toM₀ y) module DistinctParamsJoinedComputeIFixFω where -- Mechanically performing the restricted Church-encoding transformation that allows to bring -- the types into the realms of System Fω, we get MNᵗ : Set₁ MNᵗ = (Set -> Set) -> Set -> Set Mᵗ : Set -> MNᵗ Mᵗ A = λ rM rN -> rM A Nᵗ : MNᵗ Nᵗ = λ rM rN -> rN -- Nothing new here: MN : MNᵗ -> Set MN = IFix λ Rec mnᵗ -> let M A = Rec (Mᵗ A) N = Rec Nᵗ in mnᵗ (λ A -> A ⊎ N) (M ⊤) M : Set -> Set M A = MN (Mᵗ A) N : Set N = MN Nᵗ pattern p x = wrap (inj₁ x) pattern n y = wrap (inj₂ y) pattern m y = wrap y -- The sanity check. mutual toM₀ : ∀ {A} -> M A -> M₀ A toM₀ (p x) = p₀ x toM₀ (n y) = n₀ (toN₀ y) toN₀ : N -> N₀ toN₀ (m y) = m₀ (toM₀ y) module FakingFix where -- We can look at encoding mutual data types from entirely distinct perspective. -- One of the standard approaches is to have kind-level products and use `Fix :: (k -> k) -> k` -- over them. There is no such `Fix` in Agda, but we can pretend it exists: postulate Fix : ∀ {α} {A : Set α} -> (A -> A) -> A -- Then we can encode `MN` as MN : (Set -> Set) × Set MN = Fix λ Rec -> let M A = proj₁ Rec A N = proj₂ Rec in (λ A -> A ⊎ N) , M ⊤ -- This all is very similar to what we've seen in the previous section: the local definitions -- of `M` and `N` differ and we construct a type-level tuple rather than a `Set`, but the -- pattern is the same. -- The global definitions of `M` and `N` are M : Set -> Set M = proj₁ MN N : Set N = proj₂ MN -- And now we can perform the same restricted Church-encoding trick again and use -- `((Set -> Set) -> Set -> Set) -> Set` instead of `(Set -> Set) × Set`. -- Note that the new type then is exactly the same as the one of `MN` from the previous section: -- MN : MNᵗ -> Set -- which being inlined becomes: -- MN : ((Set -> Set) -> Set -> Set) -> Set -- Hence we arrived at the same encoding taking a folklore technique as a starting point.
{ "alphanum_fraction": 0.6227202813, "avg_line_length": 32.584725537, "ext": "agda", "hexsha": "0bf2bce784d25e884f8d7332c8915cf08369e137", "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": "727151dcf8bce8d7b7ef50b63652c926b3a722ef", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "robkorn/plutus", "max_forks_repo_path": "docs/fomega/mutual-type-level-recursion/MutualData.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "727151dcf8bce8d7b7ef50b63652c926b3a722ef", "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": "robkorn/plutus", "max_issues_repo_path": "docs/fomega/mutual-type-level-recursion/MutualData.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "727151dcf8bce8d7b7ef50b63652c926b3a722ef", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "robkorn/plutus", "max_stars_repo_path": "docs/fomega/mutual-type-level-recursion/MutualData.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4149, "size": 13653 }
module Luau.RuntimeError.ToString where open import Agda.Builtin.Float using (primShowFloat) open import FFI.Data.String using (String; _++_) open import Luau.RuntimeError using (RuntimeErrorᴮ; RuntimeErrorᴱ; local; return; TypeMismatch; UnboundVariable; SEGV; app₁; app₂; block; bin₁; bin₂) open import Luau.RuntimeType.ToString using (runtimeTypeToString) open import Luau.Addr.ToString using (addrToString) open import Luau.Syntax.ToString using (exprToString) open import Luau.Var.ToString using (varToString) open import Luau.Value.ToString using (valueToString) open import Luau.Syntax using (name; _$_) errToStringᴱ : ∀ {a H B} → RuntimeErrorᴱ {a} H B → String errToStringᴮ : ∀ {a H B} → RuntimeErrorᴮ {a} H B → String errToStringᴱ (UnboundVariable x) = "variable " ++ varToString x ++ " is unbound" errToStringᴱ (SEGV a x) = "address " ++ addrToString a ++ " is unallocated" errToStringᴱ (app₁ E) = errToStringᴱ E errToStringᴱ (app₂ E) = errToStringᴱ E errToStringᴱ (bin₁ E) = errToStringᴱ E errToStringᴱ (bin₂ E) = errToStringᴱ E errToStringᴱ (block b E) = errToStringᴮ E ++ "\n in call of function " ++ varToString b errToStringᴱ (TypeMismatch t v _) = "value " ++ valueToString v ++ " is not a " ++ runtimeTypeToString t errToStringᴮ (local x E) = errToStringᴱ E ++ "\n in definition of " ++ varToString (name x) errToStringᴮ (return E) = errToStringᴱ E ++ "\n in return statement"
{ "alphanum_fraction": 0.7448325018, "avg_line_length": 50.1071428571, "ext": "agda", "hexsha": "d5528c8b19cf38aaedb518c2c55edfe4d4d323af", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Luau/RuntimeError/ToString.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Luau/RuntimeError/ToString.agda", "max_line_length": 149, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Luau/RuntimeError/ToString.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 442, "size": 1403 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.DStructures.Structures.SplitEpi where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Functions.FunExtEquiv open import Cubical.Homotopy.Base open import Cubical.Data.Sigma open import Cubical.Relation.Binary open import Cubical.Algebra.Group open import Cubical.Structures.LeftAction open import Cubical.DStructures.Base open import Cubical.DStructures.Meta.Properties open import Cubical.DStructures.Structures.Type open import Cubical.DStructures.Structures.Constant open import Cubical.DStructures.Structures.Group private variable ℓ ℓ' : Level open URGStr --------------------------------------------- -- URG structures on the type of split epis, -- and displayed structures over that -- -- B -- | -- isSplit -- | -- G²FB --------------------------------------------- module _ (ℓ ℓ' : Level) where -- type of Split epimorphisms SplitEpi = Σ[ ((G , H) , f , b) ∈ G²FB ℓ ℓ' ] isGroupSplitEpi f b SplitEpi' = Σ[ G ∈ Group {ℓ} ] Σ[ H ∈ Group {ℓ'} ] Σ[ (f , b) ∈ (GroupHom G H) × (GroupHom H G) ] isGroupSplitEpi f b IsoSplitEpi' : Iso SplitEpi' SplitEpi IsoSplitEpi' = compIso (invIso Σ-assoc-Iso) (invIso Σ-assoc-Iso) -- split epimorphisms + a map back SplitEpiB = Σ[ (((G , H) , f , b) , isRet) ∈ SplitEpi ] GroupHom H G -- split epimorphisms displayed over pairs of groups 𝒮ᴰ-SplitEpi : URGStrᴰ (𝒮-G²FB ℓ ℓ') (λ ((G , H) , (f , b)) → isGroupSplitEpi f b) ℓ-zero 𝒮ᴰ-SplitEpi = Subtype→Sub-𝒮ᴰ (λ ((G , H) , (f , b)) → isGroupSplitEpi f b , isPropIsGroupSplitEpi f b) (𝒮-G²FB ℓ ℓ') -- URG structure on type of split epimorphisms 𝒮-SplitEpi : URGStr SplitEpi (ℓ-max ℓ ℓ') 𝒮-SplitEpi = ∫⟨ 𝒮-G²FB ℓ ℓ' ⟩ 𝒮ᴰ-SplitEpi -- morphisms back displayed over split epimorphisms, -- obtained by lifting the morphisms back over -- 𝒮-G² twice 𝒮ᴰ-G²FBSplit\B : URGStrᴰ 𝒮-SplitEpi (λ (((G , H) , _) , _) → GroupHom H G) (ℓ-max ℓ ℓ') 𝒮ᴰ-G²FBSplit\B = VerticalLift2-𝒮ᴰ (𝒮-group ℓ ×𝒮 𝒮-group ℓ') (𝒮ᴰ-G²\B ℓ ℓ') (𝒮ᴰ-G²\FB ℓ ℓ') 𝒮ᴰ-SplitEpi -- URG structure on split epis with an extra -- morphism back 𝒮-SplitEpiB : URGStr SplitEpiB (ℓ-max ℓ ℓ') 𝒮-SplitEpiB = ∫⟨ 𝒮-SplitEpi ⟩ 𝒮ᴰ-G²FBSplit\B 𝒮ᴰ-G\GFBSplitEpi : URGStrᴰ (𝒮-group ℓ) (λ G → Σ[ H ∈ Group {ℓ'} ] Σ[ (f , b) ∈ (GroupHom G H) × (GroupHom H G) ] isGroupSplitEpi f b ) (ℓ-max ℓ ℓ') 𝒮ᴰ-G\GFBSplitEpi = splitTotal-𝒮ᴰ (𝒮-group ℓ) (𝒮ᴰ-const (𝒮-group ℓ) (𝒮-group ℓ')) (splitTotal-𝒮ᴰ (𝒮-group ℓ ×𝒮 𝒮-group ℓ') (𝒮ᴰ-G²\FB ℓ ℓ') 𝒮ᴰ-SplitEpi) -------------------------------------------------- -- This module introduces convenient notation -- when working with a single split epimorphism --------------------------------------------------- module SplitEpiNotation {G₀ : Group {ℓ}} {G₁ : Group {ℓ'}} (ι : GroupHom G₀ G₁) (σ : GroupHom G₁ G₀) (split : isGroupSplitEpi ι σ) where open GroupNotation₀ G₀ open GroupNotation₁ G₁ ι∘σ : GroupHom G₁ G₁ ι∘σ = compGroupHom σ ι s = GroupHom.fun σ -- i is reserved for an interval variable (i : I) so we use 𝒾 instead 𝒾 = GroupHom.fun ι -i = λ (x : ⟨ G₀ ⟩) → -₁ (𝒾 x) s- = λ (x : ⟨ G₁ ⟩) → s (-₁ x) si = λ (x : ⟨ G₀ ⟩) → s (𝒾 x) is = λ (x : ⟨ G₁ ⟩) → 𝒾 (s x) -si = λ (x : ⟨ G₀ ⟩) → -₀ (si x) -is = λ (x : ⟨ G₁ ⟩) → -₁ (is x) si- = λ (x : ⟨ G₀ ⟩) → si (-₀ x) is- = λ (x : ⟨ G₁ ⟩) → is (-₁ x) s-i = λ (x : ⟨ G₀ ⟩) → s (-₁ (𝒾 x)) isi = λ (x : ⟨ G₀ ⟩) → 𝒾 (s (𝒾 x))
{ "alphanum_fraction": 0.5476249689, "avg_line_length": 33.2314049587, "ext": "agda", "hexsha": "c81ea2543261f2aa47c634a3c5b50d8165b389e9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/DStructures/Structures/SplitEpi.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/DStructures/Structures/SplitEpi.agda", "max_line_length": 124, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/DStructures/Structures/SplitEpi.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1523, "size": 4021 }
open import Relation.Binary.PropositionalEquality using (_≡_; refl; subst) open import Data.Sum import SingleSorted.AlgebraicTheory as SS module SingleSorted.Combinators where module Sum {𝓈} (Σ₁ Σ₂ : SS.Signature) (T₁ : SS.Theory 𝓈 Σ₁) (T₂ : SS.Theory 𝓈 Σ₂) where -- disjoint sum of signatures S : SS.Signature S = record { oper = SS.Signature.oper Σ₁ ⊎ SS.Signature.oper Σ₂ ; oper-arity = [ SS.Signature.oper-arity Σ₁ , SS.Signature.oper-arity Σ₂ ] } inj-term-l : ∀ {Γ : SS.Context} → SS.Signature.Term Σ₁ Γ → SS.Signature.Term S Γ inj-term-l {Γ} (SS.Signature.tm-var x) = SS.Signature.tm-var x inj-term-l {Γ} (SS.Signature.tm-oper f ts) = SS.Signature.tm-oper (inj₁ f) λ{ i → inj-term-l (ts i)} inj-term-r : ∀ {Γ : SS.Context} → SS.Signature.Term Σ₂ Γ → SS.Signature.Term S Γ inj-term-r {Γ} (SS.Signature.tm-var x) = SS.Signature.tm-var x inj-term-r {Γ} (SS.Signature.tm-oper f ts) = SS.Signature.tm-oper (inj₂ f) λ{ i → inj-term-r (ts i)} coerce₁ : SS.Signature.Equation Σ₁ → SS.Signature.Equation S coerce₁ eq = record { eq-ctx = SS.Signature.Equation.eq-ctx eq ; eq-lhs = inj-term-l (SS.Signature.Equation.eq-lhs eq) ; eq-rhs = inj-term-l (SS.Signature.Equation.eq-rhs eq) } coerce₂ : SS.Signature.Equation Σ₂ → SS.Signature.Equation S coerce₂ eq = record { eq-ctx = SS.Signature.Equation.eq-ctx eq ; eq-lhs = inj-term-r (SS.Signature.Equation.eq-lhs eq) ; eq-rhs = inj-term-r (SS.Signature.Equation.eq-rhs eq) } -- define a theory with the set of axioms a union of the axioms of both theories T : SS.Theory 𝓈 S T = record { ax = SS.Theory.ax T₁ ⊎ SS.Theory.ax T₂ ; ax-eq = [ (λ a → coerce₁ (SS.Theory.ax-eq T₁ a)) , (λ a → coerce₂ (SS.Theory.ax-eq T₂ a)) ] }
{ "alphanum_fraction": 0.6121372032, "avg_line_length": 45.119047619, "ext": "agda", "hexsha": "3c53b1d074db999c6dd5a0098696b17100128487", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/SingleSorted/Combinators.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/SingleSorted/Combinators.agda", "max_line_length": 106, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/SingleSorted/Combinators.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 624, "size": 1895 }
{-# OPTIONS --cubical #-} module Type.Cubical.Path.Proofs where import Lvl open import Type open import Type.Cubical open import Type.Cubical.Path private variable ℓ ℓ₁ ℓ₂ : Lvl.Level module _ where private variable A B : Type{ℓ} private variable P : Interval → Type{ℓ} private variable x y z w : A -- The full path from the starting point to the end. path : (point : Interval → A) → Path(point(Interval.𝟎)) (point(Interval.𝟏)) path point i = point i -- The point on the path, given a point of the interval indexing the path. pointOn : ∀{x y : A} → Path x y → (Interval → A) pointOn p i = p i -- The path from a point to itself. -- This path only consists of the point itself. point : Path x x point{x = x} _ = x -- The reverse path of a path. -- Reverses the direction of a path by flipping all points around the point of symmetry. reverseP : PathP(P) x y → PathP(\i → P(Interval.flip i)) y x reverseP p(i) = p(Interval.flip i) reverse : Path x y → Path y x reverse = reverseP -- A function mapping points between two spaces, given a path between the spaces. spaceMap : Path A B → (A → B) spaceMap p = Interval.transp (pointOn p) Interval.𝟎 -- TODO: Move module _ {A : Type{ℓ}} where private variable a₀ a₁ a₂ a₃ : A private variable a₀₀ a₀₁ a₁₀ a₁₁ : A private variable a₀₀₀ a₀₀₁ a₀₁₀ a₀₁₁ a₁₀₀ a₁₀₁ a₁₁₀ a₁₁₁ : A private variable p₀₀₋ p₀₁₋ p₀₋₀ p₀₋₁ p₁₀₋ p₁₁₋ p₁₋₀ p₁₋₁ p₋₀₀ p₋₀₁ p₋₁₀ p₋₁₁ : Path a₀ a₁ Path-missingSide : A → A Path-missingSide a = Interval.hComp diag a where diag : Interval → Interval.Partial Interval.𝟎 A diag i () module _ (p₀₋ : Path a₀₀ a₀₁) (p₁₋ : Path a₁₀ a₁₁) (p₋₀ : Path a₀₀ a₁₀) (p₋₁ : Path a₀₁ a₁₁) where -- a₀₁ → p₋₁ → a₁₁ -- ↑ ↑ -- p₀₋ p₁₋ -- ↑ ↑ -- a₀₀ → p₋₀ → a₁₀ Square : Type Square = PathP (\i → Path (p₋₀ i) (p₋₁ i)) p₀₋ p₁₋ module Square where missingSide : Path a₀₀ a₀₁ → Path a₁₀ a₁₁ → Path a₀₀ a₁₀ → Path a₀₁ a₁₁ missingSide p₀₋ p₁₋ p₋₀ ix = Interval.hComp diagram (p₋₀ ix) where diagram : Interval → Interval.Partial(Interval.max ix (Interval.flip ix)) A diagram iy (ix = Interval.𝟎) = p₀₋ iy diagram iy (ix = Interval.𝟏) = p₁₋ iy module _ {p₀₋ : Path a₀₀ a₀₁} {p₁₋ : Path a₁₀ a₁₁} {p₋₀ : Path a₀₀ a₁₀} {p₋₁ : Path a₀₁ a₁₁} (s : Square p₀₋ p₁₋ p₋₀ p₋₁) where diagonal : Path a₀₀ a₁₁ diagonal i = s i i rotate₊ : Square p₋₁ p₋₀ (reverse p₀₋) (reverse p₁₋) rotate₊ iy ix = s ix (Interval.flip iy) rotate₋ : Square (reverse p₋₀) (reverse p₋₁) p₁₋ p₀₋ rotate₋ iy ix = s (Interval.flip ix) iy flipX : Square p₁₋ p₀₋ (reverse p₋₀) (reverse p₋₁) flipX iy ix = s (Interval.flip iy) ix flipY : Square (reverse p₀₋) (reverse p₁₋) p₋₁ p₋₀ flipY iy ix = s iy (Interval.flip ix) module _ {a₀ a₁ : A} (p : Path a₀ a₁) where lineX : Square point point p p lineX ix iy = p ix lineY : Square p p point point lineY ix iy = p iy min : Square point p point p min ix iy = p(Interval.min ix iy) max : Square p point p point max ix iy = p(Interval.max ix iy) module _ (p₀₋₋ : Square p₀₀₋ p₀₁₋ p₀₋₀ p₀₋₁) (p₁₋₋ : Square p₁₀₋ p₁₁₋ p₁₋₀ p₁₋₁) (p₋₀₋ : Square p₀₀₋ p₁₀₋ p₋₀₀ p₋₀₁) (p₋₁₋ : Square p₀₁₋ p₁₁₋ p₋₁₀ p₋₁₁) (p₋₋₀ : Square p₀₋₀ p₁₋₀ p₋₀₀ p₋₁₀) (p₋₋₁ : Square p₀₋₁ p₁₋₁ p₋₀₁ p₋₁₁) where Cube : Type Cube = PathP (\i → Square (p₋₀₋ i) (p₋₁₋ i) (p₋₋₀ i) (p₋₋₁ i)) p₀₋₋ p₁₋₋ {- module Cube where module _ (p₀₋₋ : Square p₀₀₋ p₀₁₋ p₀₋₀ p₀₋₁) (p₁₋₋ : Square p₁₀₋ p₁₁₋ p₁₋₀ p₁₋₁) (p₋₀₋ : Square p₀₀₋ p₁₀₋ p₋₀₀ p₋₀₁) (p₋₁₋ : Square p₀₁₋ p₁₁₋ p₋₁₀ p₋₁₁) (p₋₋₀ : Square p₀₋₀ p₁₋₀ p₋₀₀ p₋₁₀) where missingSide : Square p₀₋₁ p₁₋₁ p₋₀₁ p₋₁₁ missingSide ix iy = Interval.hComp diagram (p₋₋₀ ix iy) where -- (Square.max {!!} ix iy) diagram : Interval → Interval.Partial {!!} A {-diagram : (i : Interval) → Interval.Partial (Interval.max (Interval.max ix (Interval.flip ix)) (Interval.max iy (Interval.flip iy))) _ diagram iz (ix = Interval.𝟎) = Square.max p₀₋₁ ix iy diagram iz (ix = Interval.𝟏) = Square.min p₁₋₁ ix iy diagram iz (iy = Interval.𝟎) = Square.max p₋₀₁ ix iy diagram iz (iy = Interval.𝟏) = Square.min p₋₁₁ ix iy-} -} -- Concatenates (joins the ends of) two paths. concat : Path x y → Path y z → Path x z concat xy yz = Square.missingSide point yz xy module _ where private variable X : Type{ℓ} private variable Y : X → Type{ℓ} -- Maps a path into another space. mapP : (f : (x : X) → Y(x)) → ∀{x y} → (path : Path x y) → PathP(\i → Y(path(i))) (f(x)) (f(y)) mapP(f) p(i) = f(p(i)) -- When there is a path between two space mappings. mapping : ∀{f g : (x : X) → Y(x)} → (∀{x} → Path(f(x)) (g(x))) → Path f g mapping ppt i x = ppt{x} i mappingPoint : ∀{f g : (x : X) → Y(x)} → Path f g → (∀{x} → Path(f(x)) (g(x))) mappingPoint pfg {x} i = pfg i x module _ where private variable X : Type{ℓ} private variable Y : X → Type{ℓ} private variable Z : (x : X) → Y(x) → Type{ℓ} -- mapP₂' : (f : (x : X) → (y : Y(x)) → Z(x)(y)) → ∀{a₁ b₁ : X}{a₂ : Y(a₁)}{b₂ : Y(b₁)} → (path₁ : Path a₁ b₁) → (path₂ : Path a₂ b₂) → PathP(\i → Z(path₁(i))(?)) (f a₁ a₂) (f b₁ b₂) mapP₂ : (f : (x : X) → (y : (x : X) → Y(x)) → Z(x)(y)) → ∀{a₁ b₁ : X}{a₂ b₂ : (x : X) → Y(x)} → (path₁ : Path a₁ b₁) → (path₂ : Path a₂ b₂) → PathP(\i → Z(path₁(i))(path₂(i))) (f a₁ a₂) (f b₁ b₂) mapP₂ f ab1 ab2 i = mapP (mapP f ab1 i) ab2 i -- mapP₂ : (f : (x : X) → (y : Y(x)) → Z(x)(y)) → ∀{x₁ x₂} → (path : Path x₁ x₂) → PathP(\i → Y(path(i))) (f(x)) (f(y)) -- mapP₂(f) = ? module _ where private variable X X₁ X₂ Y Y₁ Y₂ : Type{ℓ} map : (f : X → Y) → ∀{a b} → Path a b → Path (f(a)) (f(b)) map = mapP map₂ : (f : X₁ → X₂ → Y) → ∀{a₁ b₁}{a₂ b₂} → Path a₁ b₁ → Path a₂ b₂ → Path (f a₁ a₂) (f b₁ b₂) map₂ f ab1 ab2 i = mapP (mapP f ab1 i) ab2 i liftedSpaceMap : (S : X → Type{ℓ}) → ∀{a b} → Path a b → S(a) → S(b) liftedSpaceMap S p = spaceMap(map S p) liftedSpaceMap₂ : (S : X → Y → Type{ℓ}) → ∀{a₁ b₁}{a₂ b₂} → Path a₁ b₁ → Path a₂ b₂ → S a₁ a₂ → S b₁ b₂ liftedSpaceMap₂ S p q = spaceMap(map₂ S p q) -- TODO: Move data Loop{ℓ} : Type{ℓ} where base : Loop loop : Path base base
{ "alphanum_fraction": 0.5516148506, "avg_line_length": 33.9794871795, "ext": "agda", "hexsha": "aec8e1e22ba94c1980ffaa3e6a71af3276da9efe", "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/Cubical/Path/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/Cubical/Path/Proofs.agda", "max_line_length": 197, "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/Cubical/Path/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": 2750, "size": 6626 }
open import lib open import eq-reas-nouni equiv = _≡_ Val = nat data Expn : Set where val : Val -> Expn plus : Expn -> Expn -> Expn eval : Expn -> Val eval (val v) = v eval (plus e1 e2) = (eval e1) + (eval e2) data evalsTo : Expn -> Val -> Set where e-val : forall {v : Val} ------------------------ -> (evalsTo (val v) v) e-add : forall {e1 e2 : Expn}{v1 v2 : Val} -> (evalsTo e1 v1) -> (evalsTo e2 v2) ------------------------------------- -> (evalsTo (plus e1 e2) (v1 + v2)) e-thm-fwd : forall {e : Expn}{v : Val} -> evalsTo e v -> equiv (eval e) v e-thm-fwd (e-val{v}) = begin eval (val v) equiv[ refl ] v qed e-thm-fwd (e-add{e1}{e2}{v1}{v2} e1-evalsTo-v1 e2-evalsTo-v2) = let eval-e1-is-v1 = e-thm-fwd e1-evalsTo-v1 eval-e2-is-v2 = e-thm-fwd e2-evalsTo-v2 in begin eval (plus e1 e2) equiv[ refl ] (eval e1) + (eval e2) equiv[ cong2 _+_ eval-e1-is-v1 eval-e2-is-v2 ] v1 + v2 qed e-thm-alt : forall (e : Expn) -> evalsTo e (eval e) e-thm-alt (val v) = e-val e-thm-alt (plus e1 e2) = (e-add (e-thm-alt e1) (e-thm-alt e2))
{ "alphanum_fraction": 0.5098882201, "avg_line_length": 20.7678571429, "ext": "agda", "hexsha": "4a9428b6926ffbce01225be45746be59e3ef8cd1", "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": "80d9411b2869614cae488cd4a6272894146c9f3c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JimFixGroupResearch/imper-ial", "max_forks_repo_path": "expn-eval-holds.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "80d9411b2869614cae488cd4a6272894146c9f3c", "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": "JimFixGroupResearch/imper-ial", "max_issues_repo_path": "expn-eval-holds.agda", "max_line_length": 63, "max_stars_count": null, "max_stars_repo_head_hexsha": "80d9411b2869614cae488cd4a6272894146c9f3c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JimFixGroupResearch/imper-ial", "max_stars_repo_path": "expn-eval-holds.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 464, "size": 1163 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.PropositionalTruncation where open import Cubical.HITs.PropositionalTruncation.Base public open import Cubical.HITs.PropositionalTruncation.Properties public
{ "alphanum_fraction": 0.8349056604, "avg_line_length": 35.3333333333, "ext": "agda", "hexsha": "77134fa396fcfb7c1d990117f7198a72601270ca", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/HITs/PropositionalTruncation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/HITs/PropositionalTruncation.agda", "max_line_length": 66, "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/HITs/PropositionalTruncation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 55, "size": 212 }
-- Kleene's three-valued logic module bool-kleene where open import bool open import eq data 𝔹ₖ : Set where tt : 𝔹ₖ ff : 𝔹ₖ uu : 𝔹ₖ infix 7 ~ₖ_ infixr 6 _&&ₖ_ infixr 5 _||ₖ_ --infixr 4 _impₖ_ ~ₖ_ : 𝔹ₖ → 𝔹ₖ ~ₖ tt = ff ~ₖ ff = tt ~ₖ uu = uu -- and _&&ₖ_ : 𝔹ₖ → 𝔹ₖ → 𝔹ₖ tt &&ₖ b = b ff &&ₖ b = ff uu &&ₖ ff = ff uu &&ₖ b = uu -- or _||ₖ_ : 𝔹ₖ → 𝔹ₖ → 𝔹ₖ ff ||ₖ b = b tt ||ₖ b = tt uu ||ₖ tt = tt uu ||ₖ b = uu -- implication _impₖ_ : 𝔹ₖ → 𝔹ₖ → 𝔹ₖ tt impₖ b2 = b2 ff impₖ b2 = tt uu impₖ tt = tt uu impₖ b = uu knownₖ : 𝔹ₖ → 𝔹 knownₖ tt = tt knownₖ ff = tt knownₖ uu = ff to-𝔹 : (b : 𝔹ₖ) → knownₖ b ≡ tt → 𝔹 to-𝔹 tt p = tt to-𝔹 ff p = ff to-𝔹 uu ()
{ "alphanum_fraction": 0.5518796992, "avg_line_length": 12.7884615385, "ext": "agda", "hexsha": "24e7f6080b8e119a71121ea8f5e6950d428d20c1", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "bool-kleene.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "bool-kleene.agda", "max_line_length": 35, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "bool-kleene.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 411, "size": 665 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Wedge.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.HITs.Pushout.Base open import Cubical.Data.Unit _⋁_ : ∀ {ℓ ℓ'} → Pointed ℓ → Pointed ℓ' → Type (ℓ-max ℓ ℓ') _⋁_ (A , ptA) (B , ptB) = Pushout {A = Unit} {B = A} {C = B} (λ _ → ptA) (λ _ → ptB) -- pointed versions _⋁∙ₗ_ : ∀ {ℓ ℓ'} → Pointed ℓ → Pointed ℓ' → Pointed (ℓ-max ℓ ℓ') A ⋁∙ₗ B = (A ⋁ B) , (inl (snd A)) _⋁∙ᵣ_ : ∀ {ℓ ℓ'} → Pointed ℓ → Pointed ℓ' → Pointed (ℓ-max ℓ ℓ') A ⋁∙ᵣ B = (A ⋁ B) , (inr (snd B))
{ "alphanum_fraction": 0.597359736, "avg_line_length": 28.8571428571, "ext": "agda", "hexsha": "f63ab6138e76a210f2c6d21559a06bad035a263c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/HITs/Wedge/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/HITs/Wedge/Base.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/HITs/Wedge/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 283, "size": 606 }
module Numeral.Natural.Oper.FlooredDivision.Proofs.Inverse where import Lvl open import Data open import Functional open import Logic.Propositional open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Oper.DivMod.Proofs open import Numeral.Natural.Oper.FlooredDivision open import Numeral.Natural.Oper.Modulo open import Numeral.Natural.Oper.Modulo.Proofs open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.Proofs.Multiplication open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Divisibility open import Numeral.Natural.Relation.Divisibility.Proofs open import Numeral.Natural.Relation.Order open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Function open import Structure.Operator open import Structure.Operator.Properties open import Structure.Relator.Properties open import Syntax.Transitivity [⋅][⌊/⌋]-inverseOperatorᵣ : ∀{x y} ⦃ pos : Positive(y) ⦄ → (y ∣ x) → (x ⌊/⌋ y ⋅ y ≡ x) [⋅][⌊/⌋]-inverseOperatorᵣ {x}{𝐒 y} div = x ⌊/⌋ 𝐒(y) ⋅ 𝐒(y) 🝖[ _≡_ ]-[] x ⌊/⌋ 𝐒(y) ⋅ 𝐒(y) + 𝟎 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(_) ([↔]-to-[←] mod-divisibility div) ]-sym (x ⌊/⌋ 𝐒(y) ⋅ 𝐒(y)) + (x mod 𝐒(y)) 🝖[ _≡_ ]-[ [⌊/⌋][mod]-is-division-with-remainder {x}{y} ] x 🝖-end [⌊/⌋][⋅]-inverseOperatorᵣ : ∀{x y} ⦃ pos : Positive(y) ⦄ → ((x ⋅ y) ⌊/⌋ y ≡ x) [⌊/⌋][⋅]-inverseOperatorᵣ {x}{𝐒 y} = [⋅]-cancellationᵣ {𝐒(y)} ([⋅][⌊/⌋]-inverseOperatorᵣ (divides-with-[⋅] {𝐒(y)}{x} ([∨]-introᵣ (reflexivity(_∣_))))) [⌊/⌋][swap⋅]-inverseOperatorᵣ : ∀{x y} ⦃ pos : Positive(x) ⦄ → ((x ⋅ y) ⌊/⌋ x ≡ y) [⌊/⌋][swap⋅]-inverseOperatorᵣ {x}{y} = congruence₁(_⌊/⌋ x) (commutativity(_⋅_) {x}{y}) 🝖 [⌊/⌋][⋅]-inverseOperatorᵣ {y}{x} [⋅][⌊/⌋₀]-inverseOperatorᵣ : ∀{x y} → (y > 0) → (y ∣ x) → ((x ⌊/⌋₀ y) ⋅ y ≡ x) [⋅][⌊/⌋₀]-inverseOperatorᵣ {x}{𝐒 y} _ = [⋅][⌊/⌋]-inverseOperatorᵣ {x}{𝐒 y}
{ "alphanum_fraction": 0.6414507772, "avg_line_length": 45.9523809524, "ext": "agda", "hexsha": "fea72b2dfd50ac6a023dd11d02d93740f7045d58", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Oper/FlooredDivision/Proofs/Inverse.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Oper/FlooredDivision/Proofs/Inverse.agda", "max_line_length": 150, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Oper/FlooredDivision/Proofs/Inverse.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": 881, "size": 1930 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Properties.Posets where open import Level using (_⊔_; Lift; lift) open import Data.Unit using (⊤; tt) open import Data.Product as Prod using (_,_; <_,_>) renaming (_×_ to _|×|_) open import Function using (flip) open import Relation.Binary using (IsPartialOrder; Poset) open import Relation.Binary.OrderMorphism using (id; _∘_) renaming (_⇒-Poset_ to _⇒_) open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) open import Categories.Category import Categories.Category.CartesianClosed as CCC import Categories.Category.CartesianClosed.Canonical as Canonical open import Categories.Category.Instance.Posets open import Categories.Functor using (Functor; Endofunctor) open import Categories.Utils.Product open Poset renaming (_≈_ to ₍_₎_≈_; _≤_ to ₍_₎_≤_) open _⇒_ -- The pointwise partial order on order preserving maps. -- -- (See the Exponential module below for the definition of the -- exponential/hom object based on this order.) module Pointwise {a₁ a₂ a₃ b₁ b₂ b₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where infix 4 _≤°_ _≤°_ : (f g : A ⇒ B) → Set (a₁ ⊔ b₃) f ≤° g = ∀ {x} → ₍ B ₎ fun f x ≤ fun g x ≤°-isPartialOrder : IsPartialOrder _≗_ _≤°_ ≤°-isPartialOrder = record { isPreorder = record { isEquivalence = ≗-isEquivalence ; reflexive = λ f≗g → reflexive B f≗g ; trans = λ f≤g g≤h → trans B f≤g g≤h } ; antisym = λ f≤g g≤f → antisym B f≤g g≤f } module ≤° = IsPartialOrder ≤°-isPartialOrder open Pointwise -- Poset has a duality involution: the poset obtained by reversing the -- partial order is again a poset. module Opposite where -- NOTE: we flip the direction of the underlying equality _≈_ as -- well, so that |op (op A) ≡ A| definitionally. op : ∀ {a₁ a₂ a₃} → Poset a₁ a₂ a₃ → Poset a₁ a₂ a₃ op A = record { Carrier = Carrier A ; _≈_ = flip ₍ A ₎_≈_ ; _≤_ = flip ₍ A ₎_≤_ ; isPartialOrder = record { isPreorder = record { isEquivalence = record { refl = Eq.refl A ; sym = Eq.sym A ; trans = flip (Eq.trans A) } ; reflexive = reflexive A ; trans = flip (trans A) } ; antisym = antisym A } } module _ {a₁ a₂ a₃} {A : Poset a₁ a₂ a₃} where op-involutive : op (op A) ≡ A op-involutive = ≡.refl module _ {b₁ b₂ b₃} {B : Poset b₁ b₂ b₃} where op₁ : A ⇒ B → op A ⇒ op B op₁ f = record { fun = fun f ; monotone = monotone f } op₂ : {f g : A ⇒ B} → f ≤° g → op₁ g ≤° op₁ f op₂ f≤g = f≤g -- op induces an endofunctor on Posets op-functor : ∀ {a₁ a₂ a₃} → Endofunctor (Posets a₁ a₂ a₃) op-functor = record { F₀ = op ; F₁ = op₁ ; identity = λ {A} → Eq.refl A ; homomorphism = λ {_ _ C} → Eq.refl C ; F-resp-≈ = λ {_ B} x≈y → Eq.sym B x≈y } module op {a₁ a₂ a₃} = Functor (op-functor {a₁} {a₂} {a₃}) -- The category of posets has terminal objects. module Terminals where unit : ∀ a₁ a₂ a₃ → Poset a₁ a₂ a₃ unit a₁ a₂ a₃ = record { Carrier = Lift a₁ ⊤ ; _≈_ = λ _ _ → Lift a₂ ⊤ ; _≤_ = λ _ _ → Lift a₃ ⊤ } module _ {a₁ a₂ a₃ b₁ b₂ b₃} {B : Poset b₁ b₂ b₃} where ! : B ⇒ unit a₁ a₂ a₃ ! = _ !-unique : (f : B ⇒ unit a₁ a₂ a₃) → ! ≗ f !-unique f = _ open Terminals -- The category of posets has products. module Products where infixr 2 _×_ _×_ : ∀ {a₁ a₂ a₃ b₁ b₂ b₃} → Poset a₁ a₂ a₃ → Poset b₁ b₂ b₃ → Poset (a₁ ⊔ b₁) (a₂ ⊔ b₂) (a₃ ⊔ b₃) A × B = record { Carrier = Carrier A |×| Carrier B ; _≈_ = ₍ A ₎_≈_ -< _|×|_ >- ₍ B ₎_≈_ ; _≤_ = ₍ A ₎_≤_ -< _|×|_ >- ₍ B ₎_≤_ ; isPartialOrder = record { isPreorder = record { isEquivalence = record { refl = Eq.refl A , Eq.refl B ; sym = Prod.map (Eq.sym A) (Eq.sym B) ; trans = Prod.zip (Eq.trans A) (Eq.trans B) } ; reflexive = Prod.map (reflexive A) (reflexive B) ; trans = Prod.zip (trans A) (trans B) } ; antisym = Prod.zip (antisym A) (antisym B) } } module _ {a₁ a₂ a₃ b₁ b₂ b₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where π₁ : (A × B) ⇒ A π₁ = record { fun = Prod.proj₁ ; monotone = Prod.proj₁ } π₂ : (A × B) ⇒ B π₂ = record { fun = Prod.proj₂ ; monotone = Prod.proj₂ } module _ {c₁ c₂ c₃} {C : Poset c₁ c₂ c₃} where infix 11 ⟨_,_⟩ ⟨_,_⟩ : C ⇒ A → C ⇒ B → C ⇒ (A × B) ⟨ f , g ⟩ = record { fun = < fun f , fun g > ; monotone = < monotone f , monotone g > } π₁-comp : {f : C ⇒ A} {g : C ⇒ B} → π₁ ∘ ⟨ f , g ⟩ ≗ f π₁-comp = Eq.refl A π₂-comp : {f : C ⇒ A} {g : C ⇒ B} → π₂ ∘ ⟨ f , g ⟩ ≗ g π₂-comp = Eq.refl B ⟨,⟩-unique : {f : C ⇒ A} {g : C ⇒ B} {h : C ⇒ (A × B)} → π₁ ∘ h ≗ f → π₂ ∘ h ≗ g → ⟨ f , g ⟩ ≗ h ⟨,⟩-unique hyp₁ hyp₂ {x} = Eq.sym A hyp₁ , Eq.sym B hyp₂ infixr 2 _×₁_ _×₁_ : ∀ {a₁ a₂ a₃ b₁ b₂ b₃ c₁ c₂ c₃ d₁ d₂ d₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} {C : Poset c₁ c₂ c₃} {D : Poset d₁ d₂ d₃} → A ⇒ C → B ⇒ D → (A × B) ⇒ (C × D) f ×₁ g = ⟨ f ∘ π₁ , g ∘ π₂ ⟩ open Products -- The category of posets has exponential objects. -- -- It's easier to define exponentials with respect to the *canonical* -- product. The more generic version can then be given by appealing -- to uniqueness (up to iso) of products. module Exponentials where -- Use arrow rather than exponential notation for readability. infixr 9 _⇨_ _⇨_ : ∀ {a₁ a₂ a₃ b₁ b₂ b₃} → Poset a₁ a₂ a₃ → Poset b₁ b₂ b₃ → Poset (a₁ ⊔ a₃ ⊔ b₁ ⊔ b₃) (a₁ ⊔ b₂) (a₁ ⊔ b₃) A ⇨ B = record { Carrier = A ⇒ B ; _≈_ = _≗_ ; _≤_ = _≤°_ ; isPartialOrder = ≤°-isPartialOrder } module _ {a₁ a₂ a₃ b₁ b₂ b₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where eval : (A ⇨ B × A) ⇒ B eval = record { fun = λ{ (f , x) → fun f x } ; monotone = λ{ {f , _} (f≤g , x≤y) → trans B (monotone f x≤y) f≤g } } module _ {c₁ c₂ c₃} {C : Poset c₁ c₂ c₃} where curry : (C × A) ⇒ B → C ⇒ (A ⇨ B) curry f = record { fun = λ x → record { fun = Prod.curry (fun f) x ; monotone = Prod.curry (monotone f) (refl C) } ; monotone = λ x≤y → monotone f (x≤y , refl A) } eval-comp : {f : (C × A) ⇒ B} → eval ∘ (curry f ×₁ id) ≗ f eval-comp = Eq.refl B curry-resp-≗ : {f g : (C × A) ⇒ B} → f ≗ g → curry f ≗ curry g curry-resp-≗ hyp = hyp curry-unique : {f : C ⇒ (A ⇨ B)} {g : (C × A) ⇒ B} → eval ∘ (f ×₁ id) ≗ g → f ≗ curry g curry-unique hyp = hyp open Exponentials -- The category of posets is cartesian closed. Posets-CanonicallyCCC : ∀ {a} → Canonical.CartesianClosed (Posets a a a) Posets-CanonicallyCCC = record { ! = ! ; π₁ = π₁ ; π₂ = π₂ ; ⟨_,_⟩ = ⟨_,_⟩ ; !-unique = !-unique ; π₁-comp = λ {_ _ f _ g} → π₁-comp {f = f} {g} ; π₂-comp = λ {_ _ f _ g} → π₂-comp {f = f} {g} ; ⟨,⟩-unique = λ {_ _ f _ h g} → ⟨,⟩-unique {f = f} {g} {h} ; eval = eval ; curry = curry ; eval-comp = λ {_ _ _ f} → eval-comp {f = f} ; curry-resp-≈ = λ {_ _ _ f g} → curry-resp-≗ {f = f} {g} ; curry-unique = λ {_ _ _ f g} → curry-unique {f = f} {g} } module CanonicallyCartesianClosed {a} = Canonical.CartesianClosed (Posets-CanonicallyCCC {a}) Posets-CCC : ∀ {a} → CCC.CartesianClosed (Posets a a a) Posets-CCC = Canonical.Equivalence.fromCanonical _ Posets-CanonicallyCCC module CartesianClosed {a} = CCC.CartesianClosed (Posets-CCC {a})
{ "alphanum_fraction": 0.5230961298, "avg_line_length": 30, "ext": "agda", "hexsha": "3fe1ffd7ae94eae4f140521d80481a8e4cbb10c7", "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": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Category/Instance/Properties/Posets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "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": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Category/Instance/Properties/Posets.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Category/Instance/Properties/Posets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3104, "size": 8010 }
------------------------------------------------------------------------------ -- Totality properties respect to Bool ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.SortList.Properties.Totality.BoolI where open import FOTC.Base open import FOTC.Data.Bool.Type open import FOTC.Data.Bool.PropertiesI open import FOTC.Data.Nat.List.Type open import FOTC.Data.Nat.Type open import FOTC.Program.SortList.SortList ------------------------------------------------------------------------------ le-ItemList-Bool : ∀ {item is} → N item → ListN is → Bool (le-ItemList item is) le-ItemList-Bool {item} Nitem lnnil = subst Bool (sym (le-ItemList-[] item)) btrue le-ItemList-Bool {item} Nitem (lncons {i} {is} Ni Lis) = subst Bool (sym (le-ItemList-∷ item i is)) (&&-Bool (le-Bool Nitem Ni) (le-ItemList-Bool Nitem Lis)) -- See the ATP version. postulate le-Lists-Bool : ∀ {is js} → ListN is → ListN js → Bool (le-Lists is js) -- See the ATP version. postulate ordList-Bool : ∀ {is} → ListN is → Bool (ordList is) le-ItemTree-Bool : ∀ {item t} → N item → Tree t → Bool (le-ItemTree item t) le-ItemTree-Bool {item} _ tnil = subst Bool (sym (le-ItemTree-nil item)) btrue le-ItemTree-Bool {item} Nitem (ttip {i} Ni) = subst Bool (sym (le-ItemTree-tip item i)) (le-Bool Nitem Ni) le-ItemTree-Bool {item} Nitem (tnode {t₁} {i} {t₂} Tt₁ Ni Tt₂) = subst Bool (sym (le-ItemTree-node item t₁ i t₂)) (&&-Bool (le-ItemTree-Bool Nitem Tt₁) (le-ItemTree-Bool Nitem Tt₂)) le-TreeItem-Bool : ∀ {t item} → Tree t → N item → Bool (le-TreeItem t item) le-TreeItem-Bool {item = item} tnil _ = subst Bool (sym (le-TreeItem-nil item)) btrue le-TreeItem-Bool {item = item} (ttip {i} Ni) Nitem = subst Bool (sym (le-TreeItem-tip i item)) (le-Bool Ni Nitem) le-TreeItem-Bool {item = item} (tnode {t₁} {i} {t₂} Tt₁ Ni Tt₂) Nitem = subst Bool (sym (le-TreeItem-node t₁ i t₂ item)) (&&-Bool (le-TreeItem-Bool Tt₁ Nitem) (le-TreeItem-Bool Tt₂ Nitem)) ordTree-Bool : ∀ {t} → Tree t → Bool (ordTree t) ordTree-Bool tnil = subst Bool (sym ordTree-nil) btrue ordTree-Bool (ttip {i} Ni) = subst Bool (sym (ordTree-tip i)) btrue ordTree-Bool (tnode {t₁} {i} {t₂} Tt₁ Ni Tt₂) = subst Bool (sym (ordTree-node t₁ i t₂)) (&&-Bool (ordTree-Bool Tt₁) (&&-Bool (ordTree-Bool Tt₂) (&&-Bool (le-TreeItem-Bool Tt₁ Ni) (le-ItemTree-Bool Ni Tt₂))))
{ "alphanum_fraction": 0.5683241252, "avg_line_length": 42.421875, "ext": "agda", "hexsha": "9eabe8b99fab85c333e42e267c1a10d72c866e76", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/BoolI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/BoolI.agda", "max_line_length": 82, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/BoolI.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": 844, "size": 2715 }
module Issue279 where record Unit : Set where constructor tt open Unit tt -- this no longer brings tt into scope test : Unit test = tt
{ "alphanum_fraction": 0.7253521127, "avg_line_length": 12.9090909091, "ext": "agda", "hexsha": "1d5ff5bba48410ad4a766691584139a07e979d36", "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/Issue279.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/Issue279.agda", "max_line_length": 52, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue279.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": 37, "size": 142 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Disabled to prevent warnings from deprecated monoid solver {-# OPTIONS --warn=noUserWarning #-} module Data.List.Solver where {-# WARNING_ON_IMPORT "Data.List.Solver was deprecated in v1.3. Use the new reflective Tactic.MonoidSolver instead." #-} import Algebra.Solver.Monoid as Solver open import Data.List.Properties using (++-monoid) ------------------------------------------------------------------------ -- A module for automatically solving propositional equivalences -- containing _++_ module ++-Solver {a} {A : Set a} = Solver (++-monoid A) renaming (id to nil)
{ "alphanum_fraction": 0.5338983051, "avg_line_length": 29.5, "ext": "agda", "hexsha": "7054ac71182fe948580f9faa2a71992aca151ca2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Solver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Solver.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Solver.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 151, "size": 826 }
open import Common.Prelude open import Common.Reflection postulate X Y : Set isX : QName → Bool isX (quote X) = true isX _ = false main : IO Unit main = putStrLn ((if isX (quote X) then "yes" else "no") +S+ (if isX (quote Y) then "yes" else "no"))
{ "alphanum_fraction": 0.6176470588, "avg_line_length": 17, "ext": "agda", "hexsha": "e94d433a6342b41c641de9824e995b41d47f88b8", "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/Compiler/simple/CompilingQNamePats.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/Compiler/simple/CompilingQNamePats.agda", "max_line_length": 60, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Compiler/simple/CompilingQNamePats.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 87, "size": 272 }
{-# OPTIONS --safe #-} module Cubical.Categories.Instances.TypePrecategory where open import Cubical.Foundations.Prelude open import Cubical.Categories.Category.Precategory open Precategory -- TYPE precategory has types as objects module _ ℓ where TYPE : Precategory (ℓ-suc ℓ) ℓ TYPE .ob = Type ℓ TYPE .Hom[_,_] A B = A → B TYPE .id = λ x → x TYPE ._⋆_ f g = λ x → g (f x) TYPE .⋆IdL f = refl TYPE .⋆IdR f = refl TYPE .⋆Assoc f g h = refl
{ "alphanum_fraction": 0.627016129, "avg_line_length": 24.8, "ext": "agda", "hexsha": "41f62ef709d3b05ef63a8bf2b20616547562bc5d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/TypePrecategory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/TypePrecategory.agda", "max_line_length": 57, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/TypePrecategory.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 164, "size": 496 }
open import Type module Graph.Category {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where open import Data.Tuple as Tuple using () open import Functional open import Logic.Propositional import Lvl open import Graph{ℓ₁}{ℓ₂}(V) open import Graph.Walk{ℓ₁}{ℓ₂}{V} open import Graph.Walk.Proofs{ℓ₁}{ℓ₂}{V} open import Relator.Equals open import Relator.Equals.Proofs open import Relator.Equals.Proofs.Equiv open import Structure.Category import Structure.Categorical.Names as Names open import Structure.Categorical.Properties open import Structure.Function open import Structure.Operator open import Structure.Relator.Properties open import Syntax.Transitivity module _ (_⟶_ : Graph) where private variable a b c d : V private variable e e₁ e₂ e₃ : a ⟶ b private variable w w₁ w₂ w₃ : Walk(_⟶_) a b Walk-transitivity-raw-identityₗ-raw : (Walk-transitivity-raw at w ≡ w) Walk-transitivity-raw-identityₗ-raw = [≡]-intro Walk-transitivity-raw-identityᵣ-raw : (Walk-transitivity-raw w at ≡ w) Walk-transitivity-raw-identityᵣ-raw {a}{.a} {Walk.at} = [≡]-intro Walk-transitivity-raw-identityᵣ-raw {a}{c} {Walk.prepend {b = b} e w} = congruence₁(prepend e) (Walk-transitivity-raw-identityᵣ-raw {b}{c} {w}) Walk-transitivity-raw-associativity-raw : Names.Morphism.Associativity{Obj = V}(\{w} → Walk-transitivity-raw{_⟶_ = _⟶_}{z = w}) Walk-transitivity-raw-associativity-raw {a}{b}{c}{d} {Walk.at} {w₂}{w₃} = [≡]-intro Walk-transitivity-raw-associativity-raw {a}{b}{c}{d} {Walk.prepend e w₁}{w₂}{w₃} = congruence₁(prepend e) (Walk-transitivity-raw-associativity-raw {a}{b}{c}{_} {w₁}{w₂}{w₃}) instance Walk-transitivity-raw-identityₗ : Morphism.Identityₗ{Obj = V}(\{w} → Walk-transitivity-raw{z = w})(at) Walk-transitivity-raw-identityₗ = Morphism.intro Walk-transitivity-raw-identityₗ-raw instance Walk-transitivity-raw-identityᵣ : Morphism.Identityᵣ{Obj = V}(\{w} → Walk-transitivity-raw{z = w})(at) Walk-transitivity-raw-identityᵣ = Morphism.intro Walk-transitivity-raw-identityᵣ-raw instance Walk-transitivity-raw-identity : Morphism.Identity{Obj = V}(\{w} → Walk-transitivity-raw{_⟶_ = _⟶_}{z = w})(at) Walk-transitivity-raw-identity = [∧]-intro Walk-transitivity-raw-identityₗ Walk-transitivity-raw-identityᵣ -- The category arising from a graph by its vertices and walks. -- Note that `Walk` is defined so that every sequence of edges have an unique walk. For example `ReflexitiveTransitiveClosure` (a relation equivalent to a walk) would not work. free-category : Category(Walk(_⟶_)) Category._∘_ free-category = swap(transitivity(Walk(_⟶_))) Category.id free-category = reflexivity(Walk(_⟶_)) BinaryOperator.congruence (Category.binaryOperator free-category) [≡]-intro [≡]-intro = [≡]-intro Morphism.Associativity.proof (Category.associativity free-category) {a}{b}{c}{d} {w₁}{w₂}{w₃} = symmetry(_≡_) (Walk-transitivity-raw-associativity-raw {d}{c}{b}{a} {w₃}{w₂}{w₁}) Morphism.Identityₗ.proof (Tuple.left (Category.identity free-category)) = Walk-transitivity-raw-identityᵣ-raw Morphism.Identityᵣ.proof (Tuple.right (Category.identity free-category)) = Walk-transitivity-raw-identityₗ-raw
{ "alphanum_fraction": 0.7281858129, "avg_line_length": 53.1, "ext": "agda", "hexsha": "12fdb2b52721fb5010c8eabd62f2f95bb8652185", "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": "Graph/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Graph/Category.agda", "max_line_length": 179, "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": "Graph/Category.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1036, "size": 3186 }
{-# OPTIONS --universe-polymorphism #-} -- {-# OPTIONS --verbose tc.constr.findInScope:15 #-} -- {-# OPTIONS --verbose tc.term.args.ifs:15 #-} -- {-# OPTIONS --verbose tc.checkArgs:15 #-} module 12-constraintFamilies where open import Level open import Function open import Data.Unit open import Data.List open import Data.Product hiding (map) open import Relation.Binary open import Relation.Binary.PropositionalEquality record ConstrainedFunctor {c} (Constraint : Set → Set c) (f : (A : Set) → Set) : Set (suc c) where field fmap : ∀ {A B : Set} → {{cA : Constraint A}} → {{cB : Constraint B}} → (A → B) → f A → f B listConstrainedFunctor : ConstrainedFunctor (const ⊤) List listConstrainedFunctor = record { fmap = map } postulate sort : {A : Set} → {{ordA : ∃ λ (_<_ : A → A → Set) → IsStrictTotalOrder {A = A} _≡_ _<_}} → List A → List A ⋯ : ∀ {a} {A : Set a} {{a : A}} → A ⋯ {{a}} = a sortedListConstrainedFunctor : ConstrainedFunctor (λ A → ∃ λ (_<_ : A → A → Set) → IsStrictTotalOrder _≡_ _<_) List sortedListConstrainedFunctor = record { fmap = λ {{x}} {{y}} → map' {{x}} {{y}} } where map' : {A B : Set} → {{ordA : ∃ λ (_<_ : A → A → Set) → (IsStrictTotalOrder _≡_ _<_)}} → {{ordB : ∃ λ (_<_ : B → B → Set) → (IsStrictTotalOrder _≡_ _<_)}} → (A → B) → List A → List B map' f = sort ∘′ map f
{ "alphanum_fraction": 0.6022140221, "avg_line_length": 35.6578947368, "ext": "agda", "hexsha": "01e6cff6eb138b7b2c372c495036a2ef49c4d407", "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/instance-arguments/12-constraintFamilies.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/instance-arguments/12-constraintFamilies.agda", "max_line_length": 115, "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": "examples/instance-arguments/12-constraintFamilies.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": 466, "size": 1355 }
{-# OPTIONS --without-K #-} module NTypes.Nat where open import NTypes open import PathOperations open import PathStructure.Nat open import Types ℕ-isSet : isSet ℕ ℕ-isSet = ind (λ m → (n : ℕ) (p q : m ≡ n) → p ≡ q) (λ m-1 r → ind (λ n → (p q : suc m-1 ≡ n) → p ≡ q) (λ n-1 r′ p′ q′ → split-eq p′ ⁻¹ · ap (ap suc) (r _ (merge-path m-1 n-1 (tr (F (suc m-1)) p′ (F-lemma (suc m-1)))) (merge-path m-1 n-1 (tr (F (suc m-1)) q′ (F-lemma (suc m-1))))) · split-eq q′ ) (λ p q → 0-elim (split-path _ _ p))) (ind (λ n → (p q : 0 ≡ n) → p ≡ q) (λ _ _ p q → 0-elim (split-path _ _ p)) (λ p q → split-eq p ⁻¹ · split-eq q)) where split-eq : {x y : ℕ} → _ split-eq {x} {y} = π₂ (π₂ (π₂ (split-merge-eq {x} {y})))
{ "alphanum_fraction": 0.4716049383, "avg_line_length": 27, "ext": "agda", "hexsha": "365051c0e586ad822dbd487df395080f9d9524e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_path": "src/NTypes/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_path": "src/NTypes/Nat.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_path": "src/NTypes/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 350, "size": 810 }
{-# OPTIONS --without-K --safe #-} open import Algebra module Data.FingerTree.Measures {r m} (ℳ : Monoid r m) where open import Level using (_⊔_) open Monoid ℳ renaming (Carrier to 𝓡) open import Data.List as List using (List; _∷_; []) open import Data.Product open import Function -- | A measure. record σ {a} (Σ : Set a) : Set (a ⊔ r) where field μ : Σ → 𝓡 open σ ⦃ ... ⦄ {-# DISPLAY σ.μ _ = μ #-} instance σ-List : ∀ {a} {Σ : Set a} → ⦃ _ : σ Σ ⦄ → σ (List Σ) μ ⦃ σ-List ⦄ = List.foldr (_∙_ ∘ μ) ε -- A "fiber" (I think) from the μ function. -- -- μ⟨ Σ ⟩≈ 𝓂 means "There exists a Σ such that μ Σ ≈ 𝓂" infixl 2 _⇑[_] record μ⟨_⟩≈_ {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ (𝓂 : 𝓡) : Set (a ⊔ r ⊔ m) where constructor _⇑[_] field 𝓢 : Σ .𝒻 : μ 𝓢 ≈ 𝓂 open μ⟨_⟩≈_ public -- Construct a measured value without any transformations of the measure. infixl 2 _⇑ _⇑ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ (𝓢 : Σ) → μ⟨ Σ ⟩≈ μ 𝓢 𝓢 (x ⇑) = x 𝒻 (x ⇑) = refl {-# INLINE _⇑ #-} -- These combinators allow for a kind of easoning syntax over the measures. -- The first is used like so: -- -- xs ≈[ assoc _ _ _ ] -- -- Which will have the type: -- -- μ⟨ Σ ⟩≈ x ∙ y ∙ z → μ⟨ Σ ⟩≈ (x ∙ y) ∙ z -- -- The second does the same: -- -- xs ≈[ assoc _ _ _ ]′ -- -- However, when used in a chain, it typechecks after the ones used to its -- left. This means you can call the solver on the left. -- -- xs ≈[ ℳ ↯ ] ≈[ assoc _ _ _ ]′ infixl 2 _≈[_] ≈-rev _≈[_] : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ {x : 𝓡} → μ⟨ Σ ⟩≈ x → ∀ {y} → .(x ≈ y) → μ⟨ Σ ⟩≈ y 𝓢 (xs ≈[ y≈z ]) = 𝓢 xs 𝒻 (xs ≈[ y≈z ]) = trans (𝒻 xs) y≈z {-# INLINE _≈[_] #-} ≈-rev : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ {x : 𝓡} → ∀ {y} → .(x ≈ y) → μ⟨ Σ ⟩≈ x → μ⟨ Σ ⟩≈ y 𝓢 (≈-rev y≈z xs) = 𝓢 xs 𝒻 (≈-rev y≈z xs) = trans (𝒻 xs) y≈z {-# INLINE ≈-rev #-} syntax ≈-rev y≈z x↦y = x↦y ≈[ y≈z ]′ infixr 2 ≈-right ≈-right : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ {x : 𝓡} → μ⟨ Σ ⟩≈ x → ∀ {y} → .(x ≈ y) → μ⟨ Σ ⟩≈ y ≈-right (x ⇑[ x≈y ]) y≈z = x ⇑[ trans x≈y y≈z ] syntax ≈-right x x≈ = [ x≈ ]≈ x infixr 1 _↤_ -- A memoized application of μ record ⟪_⟫ {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ : Set (a ⊔ r ⊔ m) where constructor _↤_ field 𝔐 : 𝓡 𝓕 : μ⟨ Σ ⟩≈ 𝔐 open ⟪_⟫ public -- Construct the memoized version ⟪_⇓⟫ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → Σ → ⟪ Σ ⟫ 𝔐 ⟪ x ⇓⟫ = μ x 𝓕 ⟪ x ⇓⟫ = x ⇑ instance σ-⟪⟫ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → σ ⟪ Σ ⟫ μ ⦃ σ-⟪⟫ ⦄ = 𝔐 open import Algebra.FunctionProperties _≈_ -- This section allows us to use the do-notation to clean up proofs. -- First, we construct arguments: infixl 2 arg-syntax record Arg {a} (Σ : Set a) ⦃ _ : σ Σ ⦄ (𝓂 : 𝓡) (f : 𝓡 → 𝓡) : Set (m ⊔ r ⊔ a) where constructor arg-syntax field .⟨f⟩ : Congruent₁ f arg : μ⟨ Σ ⟩≈ 𝓂 open Arg syntax arg-syntax (λ sz → e₁) xs = xs [ e₁ ⟿ sz ] -- This syntax is meant to be used like so: -- -- do x ← xs [ a ∙> (s <∙ b) ⟿ s ] -- -- And it means "the size of the variable I'm binding here will be stored in this -- part of the expression". See, for example, the listToTree function: -- -- listToTree [] = empty ⇑ -- listToTree (x ∷ xs) = [ ℳ ↯ ]≈ do -- ys ← listToTree xs [ μ x ∙> s ⟿ s ] -- x ◂ ys -- infixl 1 _>>=_ _>>=_ : ∀ {a b} {Σ₁ : Set a} {Σ₂ : Set b} ⦃ _ : σ Σ₁ ⦄ ⦃ _ : σ Σ₂ ⦄ {𝓂 f} → Arg Σ₁ 𝓂 f → ((x : Σ₁) → .⦃ x≈ : μ x ≈ 𝓂 ⦄ → μ⟨ Σ₂ ⟩≈ f (μ x)) → μ⟨ Σ₂ ⟩≈ f 𝓂 arg-syntax cng xs >>= k = k (𝓢 xs) ⦃ 𝒻 xs ⦄ ≈[ cng (𝒻 xs) ] {-# INLINE _>>=_ #-} -- Inside the lambda generated by do notation, we can only pass one argument. -- So, to provide the proof (if needed) _≈?_ : ∀ x y → ⦃ x≈y : x ≈ y ⦄ → x ≈ y _≈?_ _ _ ⦃ x≈y ⦄ = x≈y
{ "alphanum_fraction": 0.5098968497, "avg_line_length": 26.375, "ext": "agda", "hexsha": "74d6e55a02865afce8f7faeb530945d13d2b82ce", "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": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_path": "src/Data/FingerTree/Measures.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "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-indexed-fingertree", "max_issues_repo_path": "src/Data/FingerTree/Measures.agda", "max_line_length": 90, "max_stars_count": 1, "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_path": "src/Data/FingerTree/Measures.agda", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "num_tokens": 1831, "size": 3587 }
{-# OPTIONS --allow-unsolved-metas #-} open import Everything module Test.ProblemWithSym where module _ {a} {A : ¶ → Set a} where private AList = Descender⟨ A ⟩ instance test-works : Transassociativity.class (flip AList) Proposequality transitivity test-works .⋆ f g h = symmetry (transassociativity h g f) test-fails : Transassociativity.class (flip AList) Proposequality transitivity test-fails .⋆ f g h = symmetry (transassociativity h g f) -- FIXME this was problematic when using a version of symmetry which did not include a negative argument in .⋆ It deserves explanation. test-hole : Transassociativity.class (flip AList) Proposequality transitivity test-hole .⋆ f g h = symmetry {!!}
{ "alphanum_fraction": 0.7283950617, "avg_line_length": 34.7142857143, "ext": "agda", "hexsha": "499265e5a2cdf0cf92bd214f9245749ca74828a2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/ProblemWithSym.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/ProblemWithSym.agda", "max_line_length": 197, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/ProblemWithSym.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 195, "size": 729 }
module Ag01 where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) _*_ : ℕ → ℕ → ℕ zero * n = zero suc m * n = n + (m * n) _ : 3 * 4 ≡ 12 _ = refl _^_ : ℕ → ℕ → ℕ m ^ 0 = 1 m ^ (suc n) = m * (m ^ n) _ : 3 ^ 4 ≡ 81 _ = refl _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n infixl 6 _+_ _∸_ infixl 7 _*_ data Bin : Set where nil : Bin x0_ : Bin → Bin x1_ : Bin → Bin inc : Bin → Bin inc nil = nil inc (x1 b) = x0 (inc b) inc (x0 b) = x1 b _ : inc (x0 nil) ≡ (x1 nil) _ = refl _ : inc (x1 x1 x0 x1 nil) ≡ x0 x0 x1 x1 nil _ = refl to : ℕ → Bin to zero = x0 nil to (suc m) = inc (to m) from : Bin → ℕ from nil = zero from (x1 b) = suc (2 * (from b)) from (x0 b) = 2 * (from b)
{ "alphanum_fraction": 0.5149892934, "avg_line_length": 14.59375, "ext": "agda", "hexsha": "5e40f7f6d4e6031abd3795ed3ffc5e6fa2095d7c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_path": "Agda/Ag01.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "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": "Brethland/LEARNING-STUFF", "max_issues_repo_path": "Agda/Ag01.agda", "max_line_length": 50, "max_stars_count": 2, "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_path": "Agda/Ag01.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "num_tokens": 434, "size": 934 }
module Kind (Gnd : Set)(U : Set)(T : U -> Set) where open import Basics open import Pr open import Nom data Kind : Set where Ty : Gnd -> Kind _|>_ : Kind -> Kind -> Kind Pi : (u : U) -> (T u -> Kind) -> Kind infixr 60 _|>_
{ "alphanum_fraction": 0.5606694561, "avg_line_length": 18.3846153846, "ext": "agda", "hexsha": "78db45f89497915f20229e335df5386470cb8359", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "benchmark/Syntacticosmos/Kind.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "benchmark/Syntacticosmos/Kind.agda", "max_line_length": 52, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "benchmark/Syntacticosmos/Kind.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": 85, "size": 239 }
{-# OPTIONS --cubical #-} module Miscellaneous.FiniteMultiset where import Lvl open import Data.List using (List) import Data.List.Functions as List open import Data.List.Relation.Permutation open import Functional as Fn open import Type.Cubical open import Type.Cubical.Quotient open import Type open import Type.Identity private variable ℓ : Lvl.Level private variable T : Type{ℓ} private variable x y z : T FiniteMultiset : Type{ℓ} → Type FiniteMultiset(T) = Quotient(_permutes_ {T = T}) pattern ∅ = class List.∅ add : T → FiniteMultiset(T) → FiniteMultiset(T) add x = Quotient-recursion (class ∘ (x List.⊰_)) (class-extensionalityₗ ∘ prepend) _∪•_ : FiniteMultiset(T) → T → FiniteMultiset(T) _∪•_ = Fn.swap add infixr 1000 _∪•_ open import Data.Boolean open import Data.List.Relation.Membership as List using (use ; skip) open import Numeral.Natural open import Relator.Equals.Proofs.Equivalence open import Type.Cubical.Path.Equality private variable l : FiniteMultiset(T) count : (T → Bool) → FiniteMultiset(T) → ℕ count f = Quotient-function(List.count f) ⦃ Proofs.permutes-countᵣ-function ⦄ satisfiesAny : (T → Bool) → FiniteMultiset(T) → Bool satisfiesAny f = Quotient-function(List.satisfiesAny f) ⦃ Proofs.permutes-satisfiesAny-functionᵣ ⦄ -- _∈_ : T → FiniteMultiset(T) → Type -- _∈_ x = Quotient-function (List._∈_ x) ⦃ {!!} ⦄
{ "alphanum_fraction": 0.7378854626, "avg_line_length": 28.9787234043, "ext": "agda", "hexsha": "1646e4f85ee05d046d9b5ed060d2cf8ca1008b32", "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": "Miscellaneous/FiniteMultiset.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": "Miscellaneous/FiniteMultiset.agda", "max_line_length": 98, "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": "Miscellaneous/FiniteMultiset.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": 431, "size": 1362 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Diagram.Duality {o ℓ e} (C : Category o ℓ e) where open Category C open import Level open import Function using (_$_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Categories.Functor open import Categories.Functor.Bifunctor open import Categories.NaturalTransformation.Dinatural open import Categories.Object.Initial open import Categories.Object.Terminal open import Categories.Object.Duality open import Categories.Diagram.Equalizer op open import Categories.Diagram.Coequalizer C open import Categories.Diagram.Pullback op open import Categories.Diagram.Pushout C open import Categories.Diagram.Cone as Cone open import Categories.Diagram.Cocone as Cocone open import Categories.Diagram.End as End open import Categories.Diagram.Coend as Coend open import Categories.Diagram.Limit as Limit open import Categories.Diagram.Colimit as Colimit open import Categories.Category.Construction.Cocones using (Cocones) private variable o′ ℓ′ e′ : Level D J : Category o′ ℓ′ e′ A B : Obj f g : A ⇒ B Coequalizer⇒coEqualizer : Coequalizer f g → Equalizer f g Coequalizer⇒coEqualizer coe = record { arr = arr ; equality = equality ; equalize = coequalize ; universal = universal ; unique = unique } where open Coequalizer coe coEqualizer⇒Coequalizer : Equalizer f g → Coequalizer f g coEqualizer⇒Coequalizer e = record { arr = arr ; equality = equality ; coequalize = equalize ; universal = universal ; unique = unique } where open Equalizer e coPullback⇒Pushout : Pullback f g → Pushout f g coPullback⇒Pushout p = record { i₁ = p₁ ; i₂ = p₂ ; commute = commute ; universal = universal ; unique = unique ; universal∘i₁≈h₁ = p₁∘universal≈h₁ ; universal∘i₂≈h₂ = p₂∘universal≈h₂ } where open Pullback p Pushout⇒coPullback : Pushout f g → Pullback f g Pushout⇒coPullback p = record { p₁ = i₁ ; p₂ = i₂ ; isPullback = record { commute = commute ; universal = universal ; unique = unique ; p₁∘universal≈h₁ = universal∘i₁≈h₁ ; p₂∘universal≈h₂ = universal∘i₂≈h₂ } } where open Pushout p module _ {F : Functor J C} where open Functor F renaming (op to Fop) coApex⇒Coapex : ∀ X → Apex Fop X → Coapex F X coApex⇒Coapex X apex = record { ψ = ψ ; commute = commute } where open Cone.Apex apex coCone⇒Cocone : Cone Fop → Cocone F coCone⇒Cocone c = record { coapex = coApex⇒Coapex _ apex } where open Cone.Cone c Coapex⇒coApex : ∀ X → Coapex F X → Apex Fop X Coapex⇒coApex X coapex = record { ψ = ψ ; commute = commute } where open Cocone.Coapex coapex Cocone⇒coCone : Cocone F → Cone Fop Cocone⇒coCone c = record { apex = Coapex⇒coApex _ coapex } where open Cocone.Cocone c coCone⇒⇒Cocone⇒ : ∀ {K K′} → Cone⇒ Fop K K′ → Cocone⇒ F (coCone⇒Cocone K′) (coCone⇒Cocone K) coCone⇒⇒Cocone⇒ f = record { arr = arr ; commute = commute } where open Cone⇒ f Cocone⇒⇒coCone⇒ : ∀ {K K′} → Cocone⇒ F K K′ → Cone⇒ Fop (Cocone⇒coCone K′) (Cocone⇒coCone K) Cocone⇒⇒coCone⇒ f = record { arr = arr ; commute = commute } where open Cocone⇒ f coLimit⇒Colimit : Limit Fop → Colimit F coLimit⇒Colimit lim = record { initial = op⊤⇒⊥ (Cocones F) $ record { ⊤ = coCone⇒Cocone ⊤ ; ⊤-is-terminal = record { ! = coCone⇒⇒Cocone⇒ ! ; !-unique = λ f → !-unique (Cocone⇒⇒coCone⇒ f) } } } where open Limit.Limit lim open Terminal terminal Colimit⇒coLimit : Colimit F → Limit Fop Colimit⇒coLimit colim = record { terminal = record { ⊤ = Cocone⇒coCone ⊥ ; ⊤-is-terminal = record { ! = Cocone⇒⇒coCone⇒ ! ; !-unique = λ f → !-unique (coCone⇒⇒Cocone⇒ f) } } } where open Colimit.Colimit colim open Initial initial module _ {F : Bifunctor (Category.op D) D C} where open HomReasoning open Functor F renaming (op to Fop) coWedge⇒Cowedge : Wedge Fop → Cowedge F coWedge⇒Cowedge W = record { E = E ; dinatural = DinaturalTransformation.op dinatural } where open Wedge W Cowedge⇒coWedge : Cowedge F → Wedge Fop Cowedge⇒coWedge W = record { E = E ; dinatural = DinaturalTransformation.op dinatural } where open Cowedge W coEnd⇒Coend : End Fop → Coend F coEnd⇒Coend e = record { cowedge = coWedge⇒Cowedge wedge ; factor = λ W → factor (Cowedge⇒coWedge W) ; universal = universal ; unique = unique } where open End.End e Coend⇒coEnd : Coend F → End Fop Coend⇒coEnd e = record { wedge = Cowedge⇒coWedge cowedge ; factor = λ W → factor (coWedge⇒Cowedge W) ; universal = universal ; unique = unique } where open Coend.Coend e module DiagramDualityConversionProperties where private Coequalizer⇔coEqualizer : ∀ (coequalizer : Coequalizer f g) → coEqualizer⇒Coequalizer (Coequalizer⇒coEqualizer coequalizer) ≡ coequalizer Coequalizer⇔coEqualizer _ = refl coPullback⇔Pushout : ∀ (coPullback : Pullback f g) → Pushout⇒coPullback (coPullback⇒Pushout coPullback) ≡ coPullback coPullback⇔Pushout _ = refl module _ {F : Functor J C} where open Functor F renaming (op to Fop) coApex⇔Coapex : ∀ X → (coApex : Apex Fop X) → Coapex⇒coApex X (coApex⇒Coapex X coApex) ≡ coApex coApex⇔Coapex _ _ = refl coCone⇔Cocone : ∀ (coCone : Cone Fop) → Cocone⇒coCone (coCone⇒Cocone coCone) ≡ coCone coCone⇔Cocone _ = refl coCone⇒⇔Cocone⇒ : ∀ {K K′} → (coCone⇒ : Cone⇒ Fop K K′) → Cocone⇒⇒coCone⇒ (coCone⇒⇒Cocone⇒ coCone⇒) ≡ coCone⇒ coCone⇒⇔Cocone⇒ _ = refl coLimit⇔Colimit : ∀ (coLimit : Limit Fop) → Colimit⇒coLimit (coLimit⇒Colimit coLimit) ≡ coLimit coLimit⇔Colimit _ = refl module _ {F : Bifunctor (Category.op D) D C} where open Functor F renaming (op to Fop) coWedge⇔Cowedge : ∀ (coWedge : Wedge Fop) → Cowedge⇒coWedge (coWedge⇒Cowedge coWedge) ≡ coWedge coWedge⇔Cowedge _ = refl coEnd⇔Coend : ∀ (coEnd : End Fop) → Coend⇒coEnd (coEnd⇒Coend coEnd) ≡ coEnd coEnd⇔Coend _ = refl
{ "alphanum_fraction": 0.6241641337, "avg_line_length": 28.1196581197, "ext": "agda", "hexsha": "62da72411f27e4183f08f3498709ce17ce30bffa", "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": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bolt12/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Duality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "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": "bolt12/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Duality.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bolt12/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Duality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2415, "size": 6580 }
{-# OPTIONS --cubical --safe #-} module Data.Binary.Base where open import Prelude import Data.Nat as ℕ infixr 5 1ᵇ∷_ 2ᵇ∷_ data 𝔹 : Type₀ where [] : 𝔹 1ᵇ∷_ : 𝔹 → 𝔹 2ᵇ∷_ : 𝔹 → 𝔹 inc : 𝔹 → 𝔹 inc [] = 1ᵇ∷ [] inc (1ᵇ∷ xs) = 2ᵇ∷ xs inc (2ᵇ∷ xs) = 1ᵇ∷ inc xs ⟦_⇑⟧ : ℕ → 𝔹 ⟦ zero ⇑⟧ = [] ⟦ suc n ⇑⟧ = inc ⟦ n ⇑⟧ ⟦_⇓⟧ : 𝔹 → ℕ ⟦ [] ⇓⟧ = 0 ⟦ 1ᵇ∷ xs ⇓⟧ = 1 ℕ.+ ⟦ xs ⇓⟧ ℕ.* 2 ⟦ 2ᵇ∷ xs ⇓⟧ = 2 ℕ.+ ⟦ xs ⇓⟧ ℕ.* 2 add₁ : 𝔹 → 𝔹 → 𝔹 add₂ : 𝔹 → 𝔹 → 𝔹 add₁ [] ys = inc ys add₁ xs [] = inc xs add₁ (1ᵇ∷ xs) (1ᵇ∷ ys) = 1ᵇ∷ add₁ xs ys add₁ (1ᵇ∷ xs) (2ᵇ∷ ys) = 2ᵇ∷ add₁ xs ys add₁ (2ᵇ∷ xs) (1ᵇ∷ ys) = 2ᵇ∷ add₁ xs ys add₁ (2ᵇ∷ xs) (2ᵇ∷ ys) = 1ᵇ∷ add₂ xs ys add₂ [] [] = 2ᵇ∷ [] add₂ [] (1ᵇ∷ ys) = 1ᵇ∷ inc ys add₂ [] (2ᵇ∷ ys) = 2ᵇ∷ inc ys add₂ (1ᵇ∷ xs) [] = 1ᵇ∷ inc xs add₂ (2ᵇ∷ xs) [] = 2ᵇ∷ inc xs add₂ (1ᵇ∷ xs) (1ᵇ∷ ys) = 2ᵇ∷ add₁ xs ys add₂ (1ᵇ∷ xs) (2ᵇ∷ ys) = 1ᵇ∷ add₂ xs ys add₂ (2ᵇ∷ xs) (1ᵇ∷ ys) = 1ᵇ∷ add₂ xs ys add₂ (2ᵇ∷ xs) (2ᵇ∷ ys) = 2ᵇ∷ add₂ xs ys infixl 6 _+_ _+_ : 𝔹 → 𝔹 → 𝔹 [] + ys = ys xs + [] = xs (1ᵇ∷ xs) + (1ᵇ∷ ys) = 2ᵇ∷ xs + ys (1ᵇ∷ xs) + (2ᵇ∷ ys) = 1ᵇ∷ add₁ xs ys (2ᵇ∷ xs) + (1ᵇ∷ ys) = 1ᵇ∷ add₁ xs ys (2ᵇ∷ xs) + (2ᵇ∷ ys) = 2ᵇ∷ add₁ xs ys double : 𝔹 → 𝔹 double [] = [] double (1ᵇ∷ xs) = 2ᵇ∷ double xs double (2ᵇ∷ xs) = 2ᵇ∷ 1ᵇ∷ xs infixl 7 _*_ _*_ : 𝔹 → 𝔹 → 𝔹 xs * [] = [] xs * (1ᵇ∷ ys) = go xs where go : 𝔹 → 𝔹 go [] = [] go (1ᵇ∷ xs) = 1ᵇ∷ ys + go xs go (2ᵇ∷ xs) = 2ᵇ∷ double ys + go xs xs * (2ᵇ∷ ys) = go xs where go : 𝔹 → 𝔹 go [] = [] go (1ᵇ∷ xs) = 2ᵇ∷ ys + go xs go (2ᵇ∷ xs) = 2ᵇ∷ (1ᵇ∷ ys) + go xs dec′ : 𝔹 → 𝔹 dec : 𝔹 → 𝔹 dec′ [] = [] dec′ (1ᵇ∷ xs) = 2ᵇ∷ dec′ xs dec′ (2ᵇ∷ xs) = 2ᵇ∷ 1ᵇ∷ xs dec [] = [] dec (2ᵇ∷ xs) = 1ᵇ∷ xs dec (1ᵇ∷ xs) = dec′ xs sub₄ : (𝔹 → 𝔹) → (𝔹 → 𝔹) → 𝔹 → 𝔹 → 𝔹 sub₃ : (𝔹 → 𝔹) → (𝔹 → 𝔹) → 𝔹 → 𝔹 → 𝔹 sub₄ o k [] ys = [] sub₄ o k (1ᵇ∷ xs) (1ᵇ∷ ys) = sub₄ (o ∘ k) 2ᵇ∷_ xs ys sub₄ o k (2ᵇ∷ xs) (2ᵇ∷ ys) = sub₄ (o ∘ k) 2ᵇ∷_ xs ys sub₄ o k (1ᵇ∷ xs) (2ᵇ∷ ys) = sub₄ o (k ∘ 1ᵇ∷_) xs ys sub₄ o k (2ᵇ∷ xs) (1ᵇ∷ ys) = sub₃ o (k ∘ 1ᵇ∷_) xs ys sub₄ o k (1ᵇ∷ []) [] = o [] sub₄ o k (1ᵇ∷ 1ᵇ∷ xs) [] = o (k (1ᵇ∷ (dec′ xs))) sub₄ o k (1ᵇ∷ 2ᵇ∷ xs) [] = o (k (1ᵇ∷ (1ᵇ∷ xs))) sub₄ o k (2ᵇ∷ xs) [] = o (k (dec′ xs)) sub₃ o k [] [] = o [] sub₃ o k [] (1ᵇ∷ ys) = [] sub₃ o k [] (2ᵇ∷ ys) = [] sub₃ o k (1ᵇ∷ xs) [] = o (k (dec′ xs)) sub₃ o k (2ᵇ∷ xs) [] = o (k (1ᵇ∷ xs)) sub₃ o k (1ᵇ∷ xs) (1ᵇ∷ ys) = sub₃ o (k ∘ 1ᵇ∷_) xs ys sub₃ o k (2ᵇ∷ xs) (2ᵇ∷ ys) = sub₃ o (k ∘ 1ᵇ∷_) xs ys sub₃ o k (1ᵇ∷ xs) (2ᵇ∷ ys) = sub₄ (o ∘ k) 2ᵇ∷_ xs ys sub₃ o k (2ᵇ∷ xs) (1ᵇ∷ ys) = sub₃ (o ∘ k) 2ᵇ∷_ xs ys sub₂ : (𝔹 → 𝔹) → 𝔹 → 𝔹 → 𝔹 sub₂ k [] ys = [] sub₂ k (1ᵇ∷ xs) [] = k (dec′ xs) sub₂ k (2ᵇ∷ xs) [] = k (1ᵇ∷ xs) sub₂ k (1ᵇ∷ xs) (1ᵇ∷ ys) = sub₂ (1ᵇ∷_ ∘ k) xs ys sub₂ k (2ᵇ∷ xs) (2ᵇ∷ ys) = sub₂ (1ᵇ∷_ ∘ k) xs ys sub₂ k (1ᵇ∷ xs) (2ᵇ∷ ys) = sub₄ k 2ᵇ∷_ xs ys sub₂ k (2ᵇ∷ xs) (1ᵇ∷ ys) = sub₃ k 2ᵇ∷_ xs ys sub₁ : (𝔹 → 𝔹) → 𝔹 → 𝔹 → 𝔹 sub₁ k xs [] = k xs sub₁ k [] (1ᵇ∷ ys) = [] sub₁ k [] (2ᵇ∷ ys) = [] sub₁ k (1ᵇ∷ xs) (1ᵇ∷ ys) = sub₃ k 2ᵇ∷_ xs ys sub₁ k (2ᵇ∷ xs) (2ᵇ∷ ys) = sub₃ k 2ᵇ∷_ xs ys sub₁ k (2ᵇ∷ xs) (1ᵇ∷ ys) = sub₁ (1ᵇ∷_ ∘ k) xs ys sub₁ k (1ᵇ∷ xs) (2ᵇ∷ ys) = sub₂ (1ᵇ∷_ ∘ k) xs ys infixl 6 _-_ _-_ : 𝔹 → 𝔹 → 𝔹 _-_ = sub₁ id _≡ᵇ_ : 𝔹 → 𝔹 → Bool [] ≡ᵇ [] = true [] ≡ᵇ (1ᵇ∷ ys) = false [] ≡ᵇ (2ᵇ∷ ys) = false (1ᵇ∷ xs) ≡ᵇ [] = false (1ᵇ∷ xs) ≡ᵇ (1ᵇ∷ ys) = xs ≡ᵇ ys (1ᵇ∷ xs) ≡ᵇ (2ᵇ∷ ys) = false (2ᵇ∷ xs) ≡ᵇ [] = false (2ᵇ∷ xs) ≡ᵇ (1ᵇ∷ ys) = false (2ᵇ∷ xs) ≡ᵇ (2ᵇ∷ ys) = xs ≡ᵇ ys -- testers : ℕ → Type₀ -- testers n = bins n n ≡ nats n n -- where -- open import Data.List -- open import Data.List.Syntax -- open import Data.List.Sugar -- import Agda.Builtin.Nat as Nat -- upTo : (ℕ → A) → ℕ → List A -- upTo f zero = [] -- upTo f (suc n) = f zero List.∷ upTo (f ∘ suc) n -- bins : ℕ → ℕ → List 𝔹 -- bins ns ms = do -- n ← upTo id ns -- m ← upTo id ms -- pure (⟦ n ⇑⟧ - ⟦ m ⇑⟧) -- nats : ℕ → ℕ → List 𝔹 -- nats ns ms = do -- n ← upTo id ns -- m ← upTo id ms -- pure ⟦ n Nat.- m ⇑⟧ -- _ : testers 100 -- _ = refl
{ "alphanum_fraction": 0.4517299782, "avg_line_length": 24.0290697674, "ext": "agda", "hexsha": "8d0ab2b05fa86b53e59db387c4209cd39d249544", "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/Binary/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/Binary/Base.agda", "max_line_length": 56, "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/Binary/Base.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": 2849, "size": 4133 }
-- 2011-11-24 Andreas, James {-# OPTIONS --copatterns #-} module CopatternWithoutFieldName where record R : Set2 where field f : Set1 open R test : (f : R -> Set1) -> R test f = bla where bla : R f bla = Set -- not a copattern, since f not a field name
{ "alphanum_fraction": 0.6428571429, "avg_line_length": 16.625, "ext": "agda", "hexsha": "58ff8b2eeff5fc46e7ba67f1157ed45146733138", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/CopatternWithoutFieldName.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/CopatternWithoutFieldName.agda", "max_line_length": 44, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/CopatternWithoutFieldName.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": 88, "size": 266 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Rose trees ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Data.Tree.Rose where open import Level using (Level) open import Size open import Data.List.Base as List using (List; []; _∷_) open import Data.Nat.Base as ℕ using (ℕ; zero; suc) import Data.Nat.Properties as ℕₚ open import Data.List.Extrema.Nat open import Function.Base using (_∘_) private variable a b : Level A : Set a B : Set b i : Size ------------------------------------------------------------------------ -- Type and basic constructions data Rose (A : Set a) : Size → Set a where node : (a : A) (ts : List (Rose A i)) → Rose A (↑ i) leaf : A → Rose A ∞ leaf a = node a [] ------------------------------------------------------------------------ -- Transforming rose trees map : (A → B) → Rose A i → Rose B i map f (node a ts) = node (f a) (List.map (map f) ts) ------------------------------------------------------------------------ -- Reducing rose trees foldr : (A → List B → B) → Rose A i → B foldr n (node a ts) = n a (List.map (foldr n) ts) depth : Rose A i → ℕ depth (node a ts) = suc (max 0 (List.map depth ts))
{ "alphanum_fraction": 0.4526717557, "avg_line_length": 26.7346938776, "ext": "agda", "hexsha": "c3bc5f2ee857ba23af44d59f510b42c950a50506", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Tree/Rose.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Tree/Rose.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Tree/Rose.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 318, "size": 1310 }
postulate A : Set x : A f : A → A → A _●_ : A → A → A infix 20 _●_ syntax f x y = x ○ y doesn't-parse : A doesn't-parse = x ○ x ● x -- Default fixity for syntax is no longer -666, but 20 as for normal operators.
{ "alphanum_fraction": 0.5652173913, "avg_line_length": 15.3333333333, "ext": "agda", "hexsha": "ab3881de998245a265160c0564f13ac890a42e1a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue1109-1.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue1109-1.agda", "max_line_length": 79, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue1109-1.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": 90, "size": 230 }
data Nat : Set where zero : Nat suc : Nat → Nat data Zero : Nat → Set where instance isZero : Zero zero data NonZero : Nat → Set where instance isSuc : ∀ {n : Nat} → NonZero (suc n) pred : ∀ t {{_ : NonZero t}} → Nat pred ._ {{isSuc {n}}} = n test : Nat test = pred (suc zero) data Test (x : Nat) : Set where here : {{_ : Zero x}} → Test x there : {{nz : NonZero x}} → Test (pred x) → Test x broken : Test (suc zero) broken = there here
{ "alphanum_fraction": 0.5784946237, "avg_line_length": 18.6, "ext": "agda", "hexsha": "0c7b7066667296b14c0e9e56bc715f0a26e89dfc", "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/Issue1377.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/Issue1377.agda", "max_line_length": 53, "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/Issue1377.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": 162, "size": 465 }
{- Defines groups and adds some smart constructors -} {-# OPTIONS --safe #-} module Cubical.Algebra.Group.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Data.Sigma open import Cubical.Algebra.Monoid open import Cubical.Algebra.Semigroup private variable ℓ : Level record IsGroup {G : Type ℓ} (1g : G) (_·_ : G → G → G) (inv : G → G) : Type ℓ where constructor isgroup field isMonoid : IsMonoid 1g _·_ inverse : (x : G) → (x · inv x ≡ 1g) × (inv x · x ≡ 1g) open IsMonoid isMonoid public infixl 6 _-_ -- Useful notation for additive groups _-_ : G → G → G x - y = x · inv y invl : (x : G) → inv x · x ≡ 1g invl x = inverse x .snd invr : (x : G) → x · inv x ≡ 1g invr x = inverse x .fst record GroupStr (G : Type ℓ) : Type ℓ where constructor groupstr field 1g : G _·_ : G → G → G inv : G → G isGroup : IsGroup 1g _·_ inv infixr 7 _·_ open IsGroup isGroup public Group : ∀ ℓ → Type (ℓ-suc ℓ) Group ℓ = TypeWithStr ℓ GroupStr Group₀ : Type₁ Group₀ = Group ℓ-zero group : (G : Type ℓ) (1g : G) (_·_ : G → G → G) (inv : G → G) (h : IsGroup 1g _·_ inv) → Group ℓ group G 1g _·_ inv h = G , groupstr 1g _·_ inv h isSetGroup : (G : Group ℓ) → isSet ⟨ G ⟩ isSetGroup G = GroupStr.isGroup (snd G) .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set makeIsGroup : {G : Type ℓ} {e : G} {_·_ : G → G → G} { inv : G → G} (is-setG : isSet G) (assoc : (x y z : G) → x · (y · z) ≡ (x · y) · z) (rid : (x : G) → x · e ≡ x) (lid : (x : G) → e · x ≡ x) (rinv : (x : G) → x · inv x ≡ e) (linv : (x : G) → inv x · x ≡ e) → IsGroup e _·_ inv IsGroup.isMonoid (makeIsGroup is-setG assoc rid lid rinv linv) = makeIsMonoid is-setG assoc rid lid IsGroup.inverse (makeIsGroup is-setG assoc rid lid rinv linv) = λ x → rinv x , linv x makeGroup : {G : Type ℓ} (e : G) (_·_ : G → G → G) (inv : G → G) (is-setG : isSet G) (assoc : (x y z : G) → x · (y · z) ≡ (x · y) · z) (rid : (x : G) → x · e ≡ x) (lid : (x : G) → e · x ≡ x) (rinv : (x : G) → x · inv x ≡ e) (linv : (x : G) → inv x · x ≡ e) → Group ℓ makeGroup e _·_ inv is-setG assoc rid lid rinv linv = _ , helper where helper : GroupStr _ GroupStr.1g helper = e GroupStr._·_ helper = _·_ GroupStr.inv helper = inv GroupStr.isGroup helper = makeIsGroup is-setG assoc rid lid rinv linv makeGroup-right : {A : Type ℓ} → (1g : A) → (_·_ : A → A → A) → (inv : A → A) → (set : isSet A) → (assoc : ∀ a b c → a · (b · c) ≡ (a · b) · c) → (rUnit : ∀ a → a · 1g ≡ a) → (rCancel : ∀ a → a · inv a ≡ 1g) → Group ℓ makeGroup-right 1g _·_ inv set assoc rUnit rCancel = makeGroup 1g _·_ inv set assoc rUnit lUnit rCancel lCancel where abstract lCancel : ∀ a → inv a · a ≡ 1g lCancel a = inv a · a ≡⟨ sym (rUnit _) ⟩ (inv a · a) · 1g ≡⟨ cong (_·_ _) (sym (rCancel (inv a))) ⟩ (inv a · a) · (inv a · (inv (inv a))) ≡⟨ assoc _ _ _ ⟩ ((inv a · a) · (inv a)) · (inv (inv a)) ≡⟨ cong (λ □ → □ · _) (sym (assoc _ _ _)) ⟩ (inv a · (a · inv a)) · (inv (inv a)) ≡⟨ cong (λ □ → (inv a · □) · (inv (inv a))) (rCancel a) ⟩ (inv a · 1g) · (inv (inv a)) ≡⟨ cong (λ □ → □ · (inv (inv a))) (rUnit (inv a)) ⟩ inv a · (inv (inv a)) ≡⟨ rCancel (inv a) ⟩ 1g ∎ lUnit : ∀ a → 1g · a ≡ a lUnit a = 1g · a ≡⟨ cong (λ b → b · a) (sym (rCancel a)) ⟩ (a · inv a) · a ≡⟨ sym (assoc _ _ _) ⟩ a · (inv a · a) ≡⟨ cong (a ·_) (lCancel a) ⟩ a · 1g ≡⟨ rUnit a ⟩ a ∎ makeGroup-left : {A : Type ℓ} → (1g : A) → (_·_ : A → A → A) → (inv : A → A) → (set : isSet A) → (assoc : ∀ a b c → a · (b · c) ≡ (a · b) · c) → (lUnit : ∀ a → 1g · a ≡ a) → (lCancel : ∀ a → (inv a) · a ≡ 1g) → Group ℓ makeGroup-left 1g _·_ inv set assoc lUnit lCancel = makeGroup 1g _·_ inv set assoc rUnit lUnit rCancel lCancel where abstract rCancel : ∀ a → a · inv a ≡ 1g rCancel a = a · inv a ≡⟨ sym (lUnit _) ⟩ 1g · (a · inv a) ≡⟨ cong (λ b → b · (a · inv a)) (sym (lCancel (inv a))) ⟩ (inv (inv a) · inv a) · (a · inv a) ≡⟨ sym (assoc (inv (inv a)) (inv a) _) ⟩ inv (inv a) · (inv a · (a · inv a)) ≡⟨ cong (inv (inv a) ·_) (assoc (inv a) a (inv a)) ⟩ (inv (inv a)) · ((inv a · a) · (inv a)) ≡⟨ cong (λ b → (inv (inv a)) · (b · (inv a))) (lCancel a) ⟩ inv (inv a) · (1g · inv a) ≡⟨ cong (inv (inv a) ·_) (lUnit (inv a)) ⟩ inv (inv a) · inv a ≡⟨ lCancel (inv a) ⟩ 1g ∎ rUnit : ∀ a → a · 1g ≡ a rUnit a = a · 1g ≡⟨ cong (a ·_) (sym (lCancel a)) ⟩ a · (inv a · a) ≡⟨ assoc a (inv a) a ⟩ (a · inv a) · a ≡⟨ cong (λ b → b · a) (rCancel a) ⟩ 1g · a ≡⟨ lUnit a ⟩ a ∎
{ "alphanum_fraction": 0.4613627712, "avg_line_length": 28.5543478261, "ext": "agda", "hexsha": "f6efd7f7758aafb9e53cf15f9399d382bb498a59", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jespercockx/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "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": "jespercockx/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Base.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jespercockx/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2137, "size": 5254 }
---------------------------------------------------------------- -- This file contains the definition natural transformations. -- ---------------------------------------------------------------- module Category.NatTrans where open import Level open import Category.Category public open import Category.Funct public open import Category.CatEq public record NatTrans {l₁ l₂ : Level} {ℂ₁ : Cat {l₁}} {ℂ₂ : Cat {l₂}} (F G : Functor ℂ₁ ℂ₂) : Set (l₁ ⊔ l₂) where field -- The family of components. η : (A : Obj ℂ₁) → el (Hom ℂ₂ (omap F A) (omap G A)) -- The natural transformation law. η-ax : ∀{A B}{f : el (Hom ℂ₁ A B)} → comm-square {ℂ = ℂ₂} (appT (fmap F) f) (η B) (η A) (appT (fmap G) f) open NatTrans public
{ "alphanum_fraction": 0.5044814341, "avg_line_length": 32.5416666667, "ext": "agda", "hexsha": "a3967c348d0dcb957b06f0f7fde81a109675ce1d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "setoid-cats/Category/NatTrans.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "setoid-cats/Category/NatTrans.agda", "max_line_length": 109, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "setoid-cats/Category/NatTrans.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 218, "size": 781 }
open import Data.Bool as Bool using (Bool; false; true; if_then_else_; not) open import Data.String using (String) open import Data.Nat using (ℕ; _+_; _≟_; suc; _>_; _<_; _∸_) open import Relation.Nullary.Decidable using (⌊_⌋) open import Data.List as l using (List; filter; map; take; foldl; length; []; _∷_) open import Data.List.Properties -- open import Data.List.Extrema using (max) open import Data.Maybe using (to-witness) open import Data.Fin using (fromℕ; _-_; zero; Fin) open import Data.Fin.Properties using (≤-totalOrder) open import Data.Product as Prod using (∃; ∃₂; _×_; _,_; Σ) import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong) open Eq.≡-Reasoning open import Level using (Level) open import Data.Vec as v using (Vec; fromList; toList; last; length; []; _∷_; [_]; _∷ʳ_; _++_; lookup; head; initLast; filter; map) open import Data.Vec.Bounded as vb using ([]; _∷_; fromVec; filter; Vec≤) open import Agda.Builtin.Nat public using () renaming (_==_ to _≡ᵇ_) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_; refl; _≗_; cong₂; inspect; [_]) open import Data.Nat.Properties using (+-comm) open import Relation.Unary using (Pred; Decidable) open import Relation.Nullary using (does) open import Data.Vec.Bounded.Base using (padRight; ≤-cast) import Data.Nat.Properties as ℕₚ open import Relation.Nullary.Decidable.Core using (dec-false) open import Function using (_∘_) open import Data.List.Extrema ℕₚ.≤-totalOrder open import Data.Empty using (⊥) -- TODO add to std-lib open import Relation.Nullary dec-¬ : ∀ {a} {P : Set a} → Dec P → Dec (¬ P) dec-¬ (yes p) = no λ prf → prf p dec-¬ (no ¬p) = yes ¬p -- TODO switch to Vec init? allButLast : ∀ {a} {A : Set a} → List A → List A allButLast [] = l.[] allButLast (_ ∷ []) = l.[] allButLast (x ∷ x₁ ∷ l) = x l.∷ (allButLast (x₁ l.∷ l)) allButLast-∷ʳ : ∀ {a} {A : Set a} {l : List A} {x} → allButLast (l l.∷ʳ x) ≡ l allButLast-∷ʳ {l = []} = refl allButLast-∷ʳ {l = _ ∷ []} = refl allButLast-∷ʳ {l = x ∷ x₁ ∷ l} = cong (x l.∷_) (allButLast-∷ʳ {l = x₁ l.∷ l}) filter' : {A : Set} → (A → Bool) → List A → List A filter' p [] = l.[] filter' p (x ∷ xs) with (p x) ... | true = x l.∷ filter' p xs ... | false = filter' p xs record Todo : Set where field text : String completed : Bool id : ℕ -- can't define this for (List any) since (last []) must be defined for each carrier type TodoListLast : List Todo → Todo TodoListLast [] = record {} TodoListLast (x ∷ []) = x TodoListLast (_ ∷ y ∷ l) = TodoListLast (y l.∷ l) AddTodo : List Todo → String → List Todo AddTodo todos text = todos l.∷ʳ record { id = 1 ; completed = false ; text = text } -- AddTodo is well-defined AddTodoAddsNewListItem : (todos : List Todo) (text : String) → l.length (AddTodo todos text) ≡ l.length todos + 1 AddTodoAddsNewListItem todos text = length-++ todos AddTodoSetsNewCompletedToFalse : (todos : List Todo) (text : String) → Todo.completed (TodoListLast (AddTodo todos text)) ≡ false AddTodoSetsNewCompletedToFalse [] text = refl AddTodoSetsNewCompletedToFalse (_ ∷ []) text = refl AddTodoSetsNewCompletedToFalse (_ ∷ _ ∷ l) text = AddTodoSetsNewCompletedToFalse (_ l.∷ l) text -- TODO can't prove this until AddTodo definition changed AddTodoSetsNewIdToNonExistingId : (todos : List Todo) (text : String) → l.length (l.filter (λ todo → dec-¬ (Todo.id todo ≟ Todo.id (TodoListLast (AddTodo todos text)))) (AddTodo todos text)) ≡ 1 AddTodoSetsNewIdToNonExistingId todos text = {! !} AddTodoSetsNewTextToText : (todos : List Todo) (text : String) → Todo.text (TodoListLast (AddTodo todos text)) ≡ text AddTodoSetsNewTextToText [] text = refl AddTodoSetsNewTextToText (_ ∷ []) text = refl AddTodoSetsNewTextToText (_ ∷ _ ∷ l) text = AddTodoSetsNewTextToText (_ l.∷ l) text AddTodoDoesntChangeOtherTodos : (todos : List Todo) (text : String) → l.length todos > 0 → allButLast (AddTodo todos text) ≡ todos AddTodoDoesntChangeOtherTodos (x l.∷ xs) text _<_ = allButLast-∷ʳ -- END AddTodo is well-defined -- TODO text1 ≠ text2 AddTodo-not-comm : (todos : List Todo) → (text1 : String) → (text2 : String) → (AddTodo (AddTodo todos text1) text2 ≢ AddTodo (AddTodo todos text2) text1) AddTodo-not-comm todos text1 text2 = {! !} -- {-# COMPILE JS AddTodo = -- function (todos) { -- return function (text) { -- return [ -- ...todos, -- { -- id: todos.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1, -- completed: false, -- text: text -- } -- ] -- } -- } -- #-} DeleteTodo : (List Todo) → ℕ → (List Todo) DeleteTodo todos id = l.filter (λ todo → dec-¬ (Todo.id todo ≟ id)) todos DeleteTodo' : (List Todo) → ℕ → (List Todo) DeleteTodo' todos id = filter' (λ todo → not (Todo.id todo ≡ᵇ id)) todos DeleteTodo'RemoveTodoWithId : (todos : List Todo) (id : ℕ) → filter' (λ todo → Todo.id todo ≡ᵇ id) (DeleteTodo' todos id) ≡ l.[] DeleteTodo'RemoveTodoWithId [] id = refl DeleteTodo'RemoveTodoWithId (x ∷ xs) id with (Todo.id x ≡ᵇ id) | inspect (_≡ᵇ id) (Todo.id x) ... | true | P.[ eq ] = DeleteTodo'RemoveTodoWithId xs id ... | false | P.[ eq ] rewrite eq = DeleteTodo'RemoveTodoWithId xs id -- TODO this one needs Todo to specify that it can only have one unique id DeleteTodo'Removes1Element : (todos : List Todo) (id : ℕ) → l.length (DeleteTodo' todos id) ≡ l.length todos ∸ 1 DeleteTodo'Removes1Element [] id = refl DeleteTodo'Removes1Element (x ∷ xs) id with (Todo.id x ≡ᵇ id) | inspect (_≡ᵇ id) (Todo.id x) ... | true | P.[ eq ] rewrite eq = {! !} -- DeleteTodo'Removes1Element xs id ... | false | P.[ eq ] rewrite eq = {! !} DeleteTodoDoesntChangeOtherTodos : (todos : List Todo) (id : ℕ) → DeleteTodo todos id ≡ l.filter (λ todo → dec-¬ (Todo.id todo ≟ id)) todos DeleteTodoDoesntChangeOtherTodos todos id = refl -- END DeleteTodo is well-defined DeleteTodo-idem : (todos : List Todo) (id : ℕ) → DeleteTodo (DeleteTodo todos id) id ≡ DeleteTodo todos id DeleteTodo-idem todos id = filter-idem (λ e → dec-¬ (Todo.id e ≟ id)) todos -- {-# COMPILE JS DeleteTodo = -- function (todos) { -- return function (id) { -- return todos.filter(function (todo) { -- return todo.id !== id -- }); -- } -- } -- #-} -- EditTodo: can't use updateAt since id doesn't necessarily correspond to Vec index EditTodo : (List Todo) → ℕ → String → (List Todo) EditTodo todos id text = l.map (λ todo → if (⌊ Todo.id todo ≟ id ⌋) then record todo { text = text } else todo) todos EditTodo' : (List Todo) → ℕ → String → (List Todo) EditTodo' todos id text = l.map (λ todo → if (Todo.id todo ≡ᵇ id) then record todo { text = text } else todo) todos -- EditTodo is well-defined -- EditTodoChangesText : -- (todos : List Todo) (id : ℕ) (text : String) → -- l.map Todo.text (l.filter (λ todo → Todo.id todo ≟ id) (EditTodo todos id text)) ≡ l.[ text ] -- EditTodoChangesText todos id text = {! !} -- -- TODO not necessarily true -- EditTodo'ChangesText : -- (todos : List Todo) (id : ℕ) (text : String) → -- l.map Todo.text (EditTodo' (filter' (λ todo → Todo.id todo ≡ᵇ id) todos) id text) ≡ l.map Todo.text (filter' (λ todo → Todo.id todo ≡ᵇ id) todos) -- EditTodo'ChangesText [] id text = refl -- EditTodo'ChangesText (x ∷ xs) id text with (Todo.id x ≡ᵇ id) | inspect (_≡ᵇ id) (Todo.id x) -- ... | true | P.[ eq ] rewrite eq = {! !} -- cong (Todo.text x l.∷_) (EditTodo'ChangesText xs id text) -- ... | false | P.[ eq ] rewrite eq = EditTodo'ChangesText xs id text EditTodo'DoesntChangeId : (todos : List Todo) (id : ℕ) (text : String) → l.map Todo.id (EditTodo' todos id text) ≡ l.map Todo.id todos EditTodo'DoesntChangeId [] id text = refl EditTodo'DoesntChangeId (x ∷ xs) id text with (Todo.id x ≡ᵇ id) ... | true = cong ((Todo.id x) l.∷_) (EditTodo'DoesntChangeId xs id text) ... | false = cong ((Todo.id x) l.∷_) (EditTodo'DoesntChangeId xs id text) EditTodo'DoesntChangeCompleted : (todos : List Todo) (id : ℕ) (text : String) → l.map Todo.completed (EditTodo' todos id text) ≡ l.map Todo.completed todos EditTodo'DoesntChangeCompleted [] id text = refl EditTodo'DoesntChangeCompleted (x ∷ xs) id text with (Todo.id x ≡ᵇ id) ... | true = cong ((Todo.completed x) l.∷_) (EditTodo'DoesntChangeCompleted xs id text) ... | false = cong ((Todo.completed x) l.∷_) (EditTodo'DoesntChangeCompleted xs id text) EditTodo'DoesntChangeOtherTodos : (todos : List Todo) (id : ℕ) (text : String) → filter' (λ todo → not (Todo.id todo ≡ᵇ id)) (EditTodo' todos id text) ≡ filter' (λ todo → not (Todo.id todo ≡ᵇ id)) todos EditTodo'DoesntChangeOtherTodos [] id text = refl EditTodo'DoesntChangeOtherTodos (x ∷ xs) id text with (Todo.id x ≡ᵇ id) | inspect (_≡ᵇ id) (Todo.id x) ... | true | P.[ eq ] rewrite eq = EditTodo'DoesntChangeOtherTodos xs id text ... | false | P.[ eq ] rewrite eq = cong (x l.∷_) (EditTodo'DoesntChangeOtherTodos xs id text) EditTodoLengthUnchanged : (todos : List Todo) (id' : ℕ) (text : String) → l.length (EditTodo todos id' text) ≡ l.length todos EditTodoLengthUnchanged todos id' text = length-map (λ todo → if (⌊ Todo.id todo ≟ id' ⌋) then record todo { text = text } else todo) todos -- END EditTodo is well-defined EditTodo'-idem : (todos : List Todo) (id : ℕ) (text : String) → EditTodo' (EditTodo' todos id text) id text ≡ EditTodo' todos id text EditTodo'-idem [] id text = refl EditTodo'-idem (x ∷ xs) id text with (Todo.id x ≡ᵇ id) | inspect (_≡ᵇ id) (Todo.id x) ... | true | P.[ eq ] rewrite eq = cong (record x { text = text } List.∷_) (EditTodo'-idem xs id text) ... | false | P.[ eq ] rewrite eq = cong (x List.∷_) (EditTodo'-idem xs id text) -- {-# COMPILE JS EditTodo = -- function (todos) { -- return function (id) { -- return function (text) { -- return todos.map(function (todo) { -- if (todo.id === id) { -- todo.text = text; -- } -- return todo; -- }); -- } -- } -- } -- #-} CompleteTodo : (List Todo) → ℕ → (List Todo) CompleteTodo todos id = l.map (λ todo → if (⌊ Todo.id todo ≟ id ⌋) then record todo { completed = true } else todo) todos CompleteTodo' : (List Todo) → ℕ → (List Todo) CompleteTodo' todos id = l.map (λ todo → if (Todo.id todo ≡ᵇ id) then record todo { completed = true } else todo) todos -- CompleteTodo is well-defined -- TODO don't know if there is only one instance of Todo with that id CompleteTodo'ChangesCompleted : (todos : List Todo) (id : ℕ) → l.map Todo.completed (filter' (λ todo → Todo.id todo ≡ᵇ id) (CompleteTodo' todos id)) ≡ l.map (λ todo → true) (filter' (λ todo → Todo.id todo ≡ᵇ id) todos) CompleteTodo'ChangesCompleted [] id = refl CompleteTodo'ChangesCompleted (x ∷ xs) id with Todo.id x ≡ᵇ id | inspect (_≡ᵇ id) (Todo.id x) ... | true | P.[ eq ] rewrite eq = cong (true l.∷_) (CompleteTodo'ChangesCompleted xs id) ... | false | P.[ eq ] rewrite eq = CompleteTodo'ChangesCompleted xs id CompleteTodoDoesntChangeIds : (todos : List Todo) (id : ℕ) → l.map Todo.id (CompleteTodo todos id) ≡ l.map Todo.id todos CompleteTodoDoesntChangeIds [] id = refl CompleteTodoDoesntChangeIds (x ∷ []) id = cong (l._∷ l.[]) (helper x id) where helper : (x : Todo) (id : ℕ) → Todo.id (if ⌊ Todo.id x ≟ id ⌋ then record { text = Todo.text x ; completed = true ; id = Todo.id x } else x) ≡ Todo.id x helper x id with (⌊ Todo.id x ≟ id ⌋) ... | true = refl ... | false = refl CompleteTodoDoesntChangeIds (x ∷ xs) id = begin l.map Todo.id (CompleteTodo (x l.∷ xs) id) ≡⟨⟩ (l.map Todo.id (CompleteTodo l.[ x ] id)) l.++ l.map Todo.id (CompleteTodo xs id) ≡⟨ cong (l._++ l.map Todo.id (CompleteTodo xs id)) (CompleteTodoDoesntChangeIds (x l.∷ l.[]) id) ⟩ l.map Todo.id (l.[ x ]) l.++ l.map Todo.id (CompleteTodo xs id) ≡⟨⟩ l.[ Todo.id x ] l.++ l.map Todo.id (CompleteTodo xs id) ≡⟨⟩ Todo.id x l.∷ l.map Todo.id (CompleteTodo xs id) ≡⟨ cong (Todo.id x l.∷_) (CompleteTodoDoesntChangeIds xs id) ⟩ Todo.id x l.∷ l.map Todo.id xs ≡⟨⟩ l.map Todo.id (x l.∷ xs) ∎ CompleteTodoDoesntChangeText : (todos : List Todo) (id : ℕ) → l.map Todo.text (CompleteTodo todos id) ≡ l.map Todo.text todos CompleteTodoDoesntChangeText [] id = refl CompleteTodoDoesntChangeText (x ∷ []) id = cong (l._∷ l.[]) (helper x id) where helper : (x : Todo) (id : ℕ) → Todo.text (if ⌊ Todo.id x ≟ id ⌋ then record { text = Todo.text x ; completed = true ; id = Todo.id x } else x) ≡ Todo.text x helper x id with (⌊ Todo.id x ≟ id ⌋) ... | true = refl ... | false = refl CompleteTodoDoesntChangeText (x ∷ xs) id = begin l.map Todo.text (CompleteTodo (x l.∷ xs) id) ≡⟨⟩ (l.map Todo.text (CompleteTodo l.[ x ] id)) l.++ l.map Todo.text (CompleteTodo xs id) ≡⟨ cong (l._++ l.map Todo.text (CompleteTodo xs id)) (CompleteTodoDoesntChangeText (x l.∷ l.[]) id) ⟩ l.map Todo.text (l.[ x ]) l.++ l.map Todo.text (CompleteTodo xs id) ≡⟨⟩ l.[ Todo.text x ] l.++ l.map Todo.text (CompleteTodo xs id) ≡⟨⟩ Todo.text x l.∷ l.map Todo.text (CompleteTodo xs id) ≡⟨ cong (Todo.text x l.∷_) (CompleteTodoDoesntChangeText xs id) ⟩ Todo.text x l.∷ l.map Todo.text xs ≡⟨⟩ l.map Todo.text (x l.∷ xs) ∎ CompleteTodo'DoesntChangeOthersCompleted : (todos : List Todo) (id : ℕ) → l.map Todo.completed (CompleteTodo' (filter' (λ todo → not (Todo.id todo ≡ᵇ id)) todos) id) ≡ l.map Todo.completed (filter' (λ todo → not (Todo.id todo ≡ᵇ id)) todos) CompleteTodo'DoesntChangeOthersCompleted [] id = refl CompleteTodo'DoesntChangeOthersCompleted (x ∷ xs) id with Todo.id x ≡ᵇ id | inspect (_≡ᵇ id) (Todo.id x) ... | true | P.[ eq ] rewrite eq = CompleteTodo'DoesntChangeOthersCompleted xs id -- ... | false | P.[ eq ] rewrite eq = cong (Todo.completed x l.∷_) (CompleteTodo'DoesntChangeOthersCompleted xs id) CompleteTodoLengthUnchanged : (todos : List Todo) (id : ℕ) → l.length (CompleteTodo todos id) ≡ l.length todos CompleteTodoLengthUnchanged todos id = length-map (λ todo → if (⌊ Todo.id todo ≟ id ⌋) then record todo { completed = true } else todo) todos -- END CompleteTodo is well-defined CompleteTodo'-idem : (todos : List Todo) (id : ℕ) → CompleteTodo' (CompleteTodo' todos id) id ≡ CompleteTodo' todos id CompleteTodo'-idem [] id = refl CompleteTodo'-idem (x ∷ xs) id with Todo.id x ≡ᵇ id | inspect (_≡ᵇ id) (Todo.id x) ... | true | P.[ eq ] rewrite eq = cong (record x { completed = true } l.∷_) (CompleteTodo'-idem xs id) ... | false | P.[ eq ] rewrite eq = cong (x l.∷_) (CompleteTodo'-idem xs id) -- {-# COMPILE JS CompleteTodo = -- function (todos) { -- return function (id) { -- return todos.map(function (todo) { -- if (todo.id === id) { -- todo.completed = true; -- } -- return todo; -- }); -- } -- } -- #-} CompleteAllTodos : List Todo → List Todo CompleteAllTodos todos = l.map (λ todo → record todo { completed = true }) todos -- CompleteAllTodos is well-defined CompleteAllTodosAllCompleted : (todos : List Todo) → l.filter (λ todo → (Todo.completed todo) Bool.≟ false) (CompleteAllTodos todos) ≡ l.[] CompleteAllTodosAllCompleted [] = refl CompleteAllTodosAllCompleted (x ∷ xs) = CompleteAllTodosAllCompleted xs CompleteAllTodosDoesntChangeIds : (todos : List Todo) → l.map Todo.id (CompleteAllTodos todos) ≡ l.map Todo.id todos CompleteAllTodosDoesntChangeIds [] = refl CompleteAllTodosDoesntChangeIds (x ∷ []) = cong (l._∷ l.[]) (helper x) where helper : (x : Todo) → Todo.id (record x { completed = true }) ≡ Todo.id x helper x = refl CompleteAllTodosDoesntChangeIds (x ∷ xs) = begin l.map Todo.id (CompleteAllTodos (x l.∷ xs)) ≡⟨⟩ (l.map Todo.id (CompleteAllTodos l.[ x ])) l.++ l.map Todo.id (CompleteAllTodos xs) ≡⟨ cong (l._++ l.map Todo.id (CompleteAllTodos xs)) (CompleteAllTodosDoesntChangeIds (x l.∷ l.[])) ⟩ l.map Todo.id (l.[ x ]) l.++ l.map Todo.id (CompleteAllTodos xs) ≡⟨⟩ l.[ Todo.id x ] l.++ l.map Todo.id (CompleteAllTodos xs) ≡⟨⟩ Todo.id x l.∷ l.map Todo.id (CompleteAllTodos xs) ≡⟨ cong (Todo.id x l.∷_) (CompleteAllTodosDoesntChangeIds xs) ⟩ Todo.id x l.∷ l.map Todo.id xs ≡⟨⟩ l.map Todo.id (x l.∷ xs) ∎ CompleteAllTodosDoesntChangeText : (todos : List Todo) → l.map Todo.text (CompleteAllTodos todos) ≡ l.map Todo.text todos CompleteAllTodosDoesntChangeText [] = refl CompleteAllTodosDoesntChangeText (x ∷ []) = cong (l._∷ l.[]) (helper x) where helper : (x : Todo) → Todo.text (record x { completed = true }) ≡ Todo.text x helper x = refl CompleteAllTodosDoesntChangeText (x ∷ xs) = begin l.map Todo.text (CompleteAllTodos (x l.∷ xs)) ≡⟨⟩ (l.map Todo.text (CompleteAllTodos l.[ x ])) l.++ l.map Todo.text (CompleteAllTodos xs) ≡⟨ cong (l._++ l.map Todo.text (CompleteAllTodos xs)) (CompleteAllTodosDoesntChangeText (x l.∷ l.[])) ⟩ l.map Todo.text (l.[ x ]) l.++ l.map Todo.text (CompleteAllTodos xs) ≡⟨⟩ l.[ Todo.text x ] l.++ l.map Todo.text (CompleteAllTodos xs) ≡⟨⟩ Todo.text x l.∷ l.map Todo.text (CompleteAllTodos xs) ≡⟨ cong (Todo.text x l.∷_) (CompleteAllTodosDoesntChangeText xs) ⟩ Todo.text x l.∷ l.map Todo.text xs ≡⟨⟩ l.map Todo.text (x l.∷ xs) ∎ CompleteAllTodosLengthUnchanged : (todos : List Todo) → l.length (CompleteAllTodos todos) ≡ l.length todos CompleteAllTodosLengthUnchanged todos = length-map (λ todo → record todo { completed = true }) todos -- END CompleteAllTodos is well-defined -- CompleteAllTodos-idem -- {-# COMPILE JS CompleteAllTodos = -- function (todos) { -- return todos.map(function(todo) { -- todo.completed = true; -- return todo; -- }); -- } -- #-} ClearCompleted : (List Todo) → (List Todo) ClearCompleted todos = (l.filter (λ todo → dec-¬ ((Todo.completed todo) Bool.≟ true)) todos) -- ClearCompleted is well-defined ClearCompletedRemovesOnlyCompleted : (todos : List Todo) → l.map Todo.completed (ClearCompleted todos) ≡ l.map Todo.completed (l.filter (λ todo → dec-¬ ((Todo.completed todo) Bool.≟ true)) todos) ClearCompletedRemovesOnlyCompleted todos = refl ClearCompletedDoesntChangeCompleted : (todos : List Todo) → l.map Todo.completed (ClearCompleted todos) ≡ l.map Todo.completed (l.filter (λ todo → dec-¬ ((Todo.completed todo) Bool.≟ true)) todos) ClearCompletedDoesntChangeCompleted todos = refl ClearCompletedDoesntChangeIds : (todos : List Todo) → l.map Todo.id (ClearCompleted todos) ≡ l.map Todo.id (l.filter (λ todo → dec-¬ ((Todo.completed todo) Bool.≟ true)) todos) ClearCompletedDoesntChangeIds todos = refl ClearCompletedDoesntChangeText : (todos : List Todo) → l.map Todo.text (ClearCompleted todos) ≡ l.map Todo.text (l.filter (λ todo → dec-¬ ((Todo.completed todo) Bool.≟ true)) todos) ClearCompletedDoesntChangeText todos = refl -- END ClearCompleted is well-defined ClearCompleted-idem : (todos : List Todo) → ClearCompleted (ClearCompleted todos) ≡ ClearCompleted todos ClearCompleted-idem todos = filter-idem (λ e → dec-¬ (Todo.completed e Bool.≟ true)) todos -- {-# COMPILE JS ClearCompleted = -- function (todos) { -- return todos.filter(function(todo) { -- return !todo.completed; -- }); -- } -- #-} -- interactions -- AddTodo-AddTodo -- DeleteTodo-DeleteTodo -- AddTodo-DeleteTodo -- DeleteTodo-AddTodo -- EditTodo-EditTodo -- AddTodo-EditTodo -- EditTodo-AddTodo -- ...
{ "alphanum_fraction": 0.6347022793, "avg_line_length": 38.0114503817, "ext": "agda", "hexsha": "36117ea339b0ad7aa634f685cc7b43839f09e0c1", "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": "506fba1e27d8c1527f06c285762391b00ed03ced", "max_forks_repo_licenses": [ "CC0-1.0", "MIT" ], "max_forks_repo_name": "frankymacster/redux", "max_forks_repo_path": "examples/todomvc/src/logic/todos.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "506fba1e27d8c1527f06c285762391b00ed03ced", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0", "MIT" ], "max_issues_repo_name": "frankymacster/redux", "max_issues_repo_path": "examples/todomvc/src/logic/todos.agda", "max_line_length": 170, "max_stars_count": null, "max_stars_repo_head_hexsha": "506fba1e27d8c1527f06c285762391b00ed03ced", "max_stars_repo_licenses": [ "CC0-1.0", "MIT" ], "max_stars_repo_name": "frankymacster/redux", "max_stars_repo_path": "examples/todomvc/src/logic/todos.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6475, "size": 19918 }
module aux where open import Data.Nat open import Level renaming (zero to lzero) open import Data.Fin open import Data.Fin.Properties open import Data.Fin.Subset renaming (∣_∣ to ∣_∣ˢ) open import Data.Fin.Subset.Properties open import Data.Vec open import Data.Bool open import Data.Bool.Properties open import Data.Product open import Data.Sum open import Relation.Unary hiding (_∈_ ; _⊆_) open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Nullary.Sum open import Relation.Nullary.Decidable open import Relation.Binary.PropositionalEquality hiding (Extensionality) open import Data.Empty renaming (⊥ to ⊥') postulate ext : {A : Set}{B : A → Set}{f : (x : A) → B x} {g : (x : A) → B x} → (∀ x → f x ≡ g x) → f ≡ g sum-eq : {A B : Set} {x y : A} → (inj₁{B = B} x) ≡ (inj₁{B = B} y) → x ≡ y sum-eq {A} {B} {x} {.x} refl = refl in-subset-eq : {n : ℕ} {x : Fin n} {s : Subset n} → (l l' : x ∈ s) → l ≡ l' in-subset-eq {.(ℕ.suc _)} {.zero} here here = refl in-subset-eq {.(ℕ.suc _)} {.(Fin.suc _)} (there l) (there l') = cong there (in-subset-eq l l') dec-manipulate : {n : ℕ} {A : Set} → (dec : (a a' : A) → Dec (a ≡ a')) → ((a a' : A ⊎ Fin 1) → Dec (a ≡ a')) dec-manipulate {n} {A} dec (inj₁ x) (inj₁ x₁) with dec x x₁ ... | yes p = yes (cong inj₁ p) ... | no ¬p = no λ x₂ → contradiction (sum-eq x₂) ¬p dec-manipulate {n} {A} dec (inj₁ x) (inj₂ y) = no λ () dec-manipulate {n} {A} dec (inj₂ y) (inj₁ x) = no λ () dec-manipulate {n} {A} dec (inj₂ zero) (inj₂ zero) = yes (cong inj₂ refl) f-manipulate : {n : ℕ} {A : Set} {s : Subset n} → ((l : Fin n) → l ∈ s → A) → (Fin n → (A ⊎ Fin 1)) f-manipulate {n} {A} {s} f l with l ∈? s ... | yes p = inj₁ (f l p) ... | no ¬p = inj₂ zero f-equal : {n : ℕ} {A : Set} {dec : (a a' : A) → Dec (a ≡ a')} → (f f' : (l : Fin n) → A) → Dec (f ≡ f') f-equal {n} {A} {dec} f f' with all?{n} λ x → dec (f x) (f' x) ... | yes p = yes (ext p) ... | no ¬p = no λ x → contradiction (cong-app x) ¬p f-manipulate-eq⇒f-eq : {n : ℕ} {A : Set} {s : Subset n} {f f' : (l : Fin n) → l ∈ s → A} → (f-manipulate f) ≡ (f-manipulate f') → f ≡ f' f-manipulate-eq⇒f-eq {n} {A} {s} {f} {f'} eq with (cong-app eq) ... | eq' = ext (λ x → ext (ϱ x)) where ϱ : (l : Fin n) → (i : l ∈ s) → f l i ≡ f' l i ϱ l i with (eq' l) ... | eq'' with l ∈? s ... | yes p rewrite (in-subset-eq i p) = sum-eq eq'' ... | no ¬p = contradiction i ¬p f-eq⇒f-manipulate-eq : {n : ℕ} {A : Set} {s : Subset n} {f f' : (l : Fin n) → l ∈ s → A} → f ≡ f' → (f-manipulate f) ≡ (f-manipulate f') f-eq⇒f-manipulate-eq {n} {A} {s} {f} {f'} eq with (cong-app eq) ... | eq' = ext (λ x → ϱ x) where ϱ : (l : Fin n) → (f-manipulate f l) ≡ (f-manipulate f' l) ϱ l with (eq' l) ... | eq'' with l ∈? s ... | yes p = cong inj₁ ((cong-app eq'') p) ... | no ¬p = refl _≡ᶠ?_ : {n : ℕ} {s : Subset n} {A : Set} {dec : (a a' : A) → Dec (a ≡ a')} (f f' : (l : Fin n) → s Data.Vec.[ l ]= inside → A) → Dec (f ≡ f') _≡ᶠ?_ {n} {s} {A} {dec} f f' with (f-equal{dec = dec-manipulate{n} dec} (f-manipulate f) (f-manipulate f')) ... | yes p = yes (f-manipulate-eq⇒f-eq p) ... | no ¬p = no (contraposition f-eq⇒f-manipulate-eq ¬p) x∷xs≡y∷ys⇒x≡y : {n : ℕ} {xs ys : Subset n} {x y : Bool} → (x ∷ xs) ≡ (y ∷ ys) → x ≡ y x∷xs≡y∷ys⇒x≡y {n} {xs} {.xs} {x} {.x} refl = refl x∷xs≡y∷ys⇒xs≡ys : {n : ℕ} {xs ys : Subset n} {x y : Bool} → (x ∷ xs) ≡ (y ∷ ys) → xs ≡ ys x∷xs≡y∷ys⇒xs≡ys {n} {xs} {.xs} {x} {.x} refl = refl _≡ˢ?_ : {n : ℕ} → (s s' : Subset n) → Dec (s ≡ s') _≡ˢ?_ {zero} [] [] = yes refl _≡ˢ?_ {suc n} (x ∷ s) (x₁ ∷ s') with _≡ˢ?_ {n} s s' | x Data.Bool.Properties.≟ x₁ ... | yes p | yes p' rewrite p | p' = yes refl ... | yes p | no ¬p' rewrite p = no λ x₂ → contradiction (x∷xs≡y∷ys⇒x≡y x₂) ¬p' ... | no ¬p | _ = no (λ x₂ → contradiction (x∷xs≡y∷ys⇒xs≡ys x₂) ¬p) empty-subset-outside : {n : ℕ} → (x : Fin n) → ¬ (⊥ [ x ]= inside) empty-subset-outside {.(ℕ.suc _)} zero () empty-subset-outside {.(ℕ.suc _)} (Fin.suc x) (there ins) = empty-subset-outside x ins x∈[l]⇒x≡l : {n : ℕ} {x l : Fin n} → x ∈ ⁅ l ⁆ → x ≡ l x∈[l]⇒x≡l {.(ℕ.suc _)} {zero} {zero} ins = refl x∈[l]⇒x≡l {.(ℕ.suc _)} {Fin.suc x} {zero} (there ins) = contradiction ins (empty-subset-outside x) x∈[l]⇒x≡l {.(ℕ.suc _)} {Fin.suc x} {Fin.suc l} (there ins) = cong Fin.suc (x∈[l]⇒x≡l ins) l∈L⇒[l]⊆L : {n : ℕ} {l : Fin n} {L : Subset n} → l ∈ L → ⁅ l ⁆ ⊆ L l∈L⇒[l]⊆L {n} {l} {L} ins x rewrite (x∈[l]⇒x≡l x) = ins [l]⊆L⇒l∈L : {n : ℕ} {l : Fin n} {L : Subset n} → ⁅ l ⁆ ⊆ L → l ∈ L [l]⊆L⇒l∈L {n} {l} {L} sub = sub (x∈⁅x⁆ l)
{ "alphanum_fraction": 0.5067854114, "avg_line_length": 41.7345132743, "ext": "agda", "hexsha": "7fcc92a4c04368fb150157b5e221044514752f57", "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": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_path": "src/ldlc-algo/aux.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/ldlc-algo/aux.agda", "max_line_length": 141, "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/ldlc-algo/aux.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2222, "size": 4716 }
module Issue2486 where open import Common.Prelude open import Issue2486.Import open import Issue2486.ImportB open import Issue2486.HaskellB f : MyList String → String f [] = "sdf" f (x :: _) = x xs : MyList String xs = "sdfg" :: [] postulate toBList : ∀ {A} → MyList A → BList A fromBList : ∀ {A} → BList A → MyList A {-# COMPILE GHC toBList = \ _ xs -> xs #-} {-# COMPILE GHC fromBList = \ _ xs -> xs #-} {-# FOREIGN GHC import qualified MAlonzo.Code.Issue2486.HaskellB as B #-} data Test : Set where Con : BBool → Test {-# COMPILE GHC Test = data B.Test ( B.Con ) #-} {- ff : BBool ff = BTrue -} main : IO Unit main = putStrLn (f (fromBList (toBList xs)))
{ "alphanum_fraction": 0.6386430678, "avg_line_length": 18.3243243243, "ext": "agda", "hexsha": "ebeb9a4644afd8bfbe50c90ff7e4ee33e03afac8", "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/Compiler/simple/Issue2486.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/Compiler/simple/Issue2486.agda", "max_line_length": 73, "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/Compiler/simple/Issue2486.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": 226, "size": 678 }
{-# OPTIONS -v treeless.opt:20 #-} -- Tests for case-on-case simplification. module _ where open import Common.Prelude open import Common.Integer data Cmp : Set where less equal greater : Cmp isLess : Cmp → Bool isLess less = true isLess equal = false isLess greater = false {-# INLINE isLess #-} postulate _-_ : Integer → Integer → Integer {-# COMPILED _-_ (-) #-} {-# COMPILED_UHC _-_ UHC.Agda.Builtins.primIntegerMinus #-} {-# COMPILED_JS _-_ function(x) { return function(y) { return agdaRTS.uprimIntegerMinus(x, y); }; } #-} compareInt : Integer → Integer → Cmp compareInt a b with a - b ... | pos 0 = equal ... | pos (suc _) = greater ... | negsuc _ = less {-# INLINE compareInt #-} _<_ : Integer → Integer → Bool a < b = isLess (compareInt a b) {-# INLINE _<_ #-} cmp : Integer → Integer → String cmp a b with a < b ... | true = "less" ... | false = "not less" fancyCase : Nat → Cmp → Nat fancyCase 0 _ = 0 fancyCase (suc (suc (suc n))) greater = n fancyCase (suc (suc (suc _))) equal = 4 fancyCase 1 _ = 1 fancyCase 2 _ = 2 fancyCase (suc n) less = n main : IO Unit main = putStrLn (cmp (pos 31) (negsuc 5)) ,, putStrLn (cmp (pos 5) (pos 5)) ,, putStrLn (cmp (negsuc 4) (negsuc 2))
{ "alphanum_fraction": 0.6334693878, "avg_line_length": 24.5, "ext": "agda", "hexsha": "98ff7018b9ecdde0642445246f174e6cdd9dd8dd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Compiler/simple/CaseOnCase.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pthariensflame/agda", "max_issues_repo_path": "test/Compiler/simple/CaseOnCase.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Compiler/simple/CaseOnCase.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 411, "size": 1225 }
-- Andreas, AIM XIII, 2011-04-07 -- {-# OPTIONS -v tc.rec.proj:50 #-} module DependentIrrelevance where open import Common.Irrelevance ElimSq = {A : Set}(P : Squash A -> Set) (ih : .(a : A) -> P (squash a)) -> (a- : Squash A) -> P a- elimSq : ElimSq elimSq P ih (squash a) = ih a elimSq' : ElimSq elimSq' P ih a- = ih (Squash.unsquash a-) ElimSq' = {A : Set}(P : Squash A -> Set) (ih : forall .a -> P (squash a)) -> (a- : Squash A) -> P a- record Union (A : Set)(B : .A -> Set) : Set where field .index : A elem : B index makeUnion : {A : Set}{B : .A -> Set}.(index : A)(elem : B index) -> Union A B makeUnion i e = record { index = i ; elem = e } {- extended parsing examples (do not work yet) postulate A : Set P : .A -> Set a : A f1 : _ f1 = λ .x -> P x f2 : .A -> A f2 = λ x -> a postulate g : forall .x -> P x f : (.x : A) -> P x f' : .(x : A) -> P x f'' : forall .x .(y : A) -> P x g1 : forall .(x y : A) -> P x g2 : forall (.x .y : A) -> P x g3 : forall {.x .y : A} -> P x g4 : forall x1 {.x2} .{x3 x4} {.x y} -> P x -}
{ "alphanum_fraction": 0.4915254237, "avg_line_length": 21.1509433962, "ext": "agda", "hexsha": "15483051c91da59ad9bb3f4528cb74d0075b8ade", "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": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/DependentIrrelevance.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/DependentIrrelevance.agda", "max_line_length": 77, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/DependentIrrelevance.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": 458, "size": 1121 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Properties where -- Properties valid of all Functors open import Level open import Data.Product using (proj₁; proj₂; _,_; _×_; Σ) open import Function.Surjection using (Surjective) open import Function.Equivalence using (Equivalence) open import Function.Equality using (Π; _⟶_; _⟨$⟩_; cong) open import Relation.Binary using (_Preserves_⟶_) open import Relation.Nullary open import Categories.Category open import Categories.Functor import Categories.Morphism as Morphism import Categories.Morphism.Reasoning as Reas open import Categories.Morphism.IsoEquiv as IsoEquiv open import Categories.Morphism.Isomorphism private variable o ℓ e o′ ℓ′ e′ : Level C D : Category o ℓ e Contravariant : ∀ (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Set _ Contravariant C D = Functor (Category.op C) D Faithful : Functor C D → Set _ Faithful {C = C} {D = D} F = ∀ {X Y} → (f g : C [ X , Y ]) → D [ F₁ f ≈ F₁ g ] → C [ f ≈ g ] where open Functor F Full : Functor C D → Set _ Full {C = C} {D = D} F = ∀ {X Y} → Surjective {To = D.hom-setoid {F₀ X} {F₀ Y}} G where module C = Category C module D = Category D open Functor F G : ∀ {X Y} → (C.hom-setoid {X} {Y}) ⟶ D.hom-setoid {F₀ X} {F₀ Y} G = record { _⟨$⟩_ = F₁ ; cong = F-resp-≈ } FullyFaithful : Functor C D → Set _ FullyFaithful F = Full F × Faithful F -- Note that this is a constructive version of Essentially Surjective, which is -- quite a strong assumption. EssentiallySurjective : Functor C D → Set _ EssentiallySurjective {C = C} {D = D} F = (d : Category.Obj D) → Σ C.Obj (λ c → Functor.F₀ F c ≅ d) where open Morphism D module C = Category C -- a series of [ Functor ]-respects-Thing combinators (with respects -> resp) module _ (F : Functor C D) where private module C = Category C using (Obj; _∘_; _⇒_; id; module HomReasoning) module D = Category D module IsoC = IsoEquiv C module IsoD = IsoEquiv D open C hiding (_∘_) open Functor F open Morphism private variable A B E : Obj f g h i : A ⇒ B [_]-resp-∘ : C [ C [ f ∘ g ] ≈ h ] → D [ D [ F₁ f ∘ F₁ g ] ≈ F₁ h ] [_]-resp-∘ {f = f} {g = g} {h = h} eq = begin F₁ f D.∘ F₁ g ≈˘⟨ homomorphism ⟩ F₁ (C [ f ∘ g ]) ≈⟨ F-resp-≈ eq ⟩ F₁ h ∎ where open D.HomReasoning [_]-resp-square : Definitions.CommutativeSquare C f g h i → Definitions.CommutativeSquare D (F₁ f) (F₁ g) (F₁ h) (F₁ i) [_]-resp-square {f = f} {g = g} {h = h} {i = i} sq = begin D [ F₁ h ∘ F₁ f ] ≈˘⟨ homomorphism ⟩ F₁ (C [ h ∘ f ]) ≈⟨ F-resp-≈ sq ⟩ F₁ (C [ i ∘ g ]) ≈⟨ homomorphism ⟩ D [ F₁ i ∘ F₁ g ] ∎ where open D.HomReasoning [_]-resp-Iso : Iso C f g → Iso D (F₁ f) (F₁ g) [_]-resp-Iso {f = f} {g = g} iso = record { isoˡ = begin F₁ g D.∘ F₁ f ≈⟨ [ isoˡ ]-resp-∘ ⟩ F₁ C.id ≈⟨ identity ⟩ D.id ∎ ; isoʳ = begin F₁ f D.∘ F₁ g ≈⟨ [ isoʳ ]-resp-∘ ⟩ F₁ C.id ≈⟨ identity ⟩ D.id ∎ } where open Iso iso open D.HomReasoning [_]-resp-≅ : F₀ Preserves _≅_ C ⟶ _≅_ D [_]-resp-≅ i≅j = record { from = F₁ from ; to = F₁ to ; iso = [ iso ]-resp-Iso } where open _≅_ i≅j [_]-resp-≃ : ∀ {f g : _≅_ C A B} → f IsoC.≃ g → [ f ]-resp-≅ IsoD.≃ [ g ]-resp-≅ [_]-resp-≃ ⌞ eq ⌟ = ⌞ F-resp-≈ eq ⌟ homomorphismᵢ : ∀ {f : _≅_ C B E} {g : _≅_ C A B} → [ _∘ᵢ_ C f g ]-resp-≅ IsoD.≃ (_∘ᵢ_ D [ f ]-resp-≅ [ g ]-resp-≅ ) homomorphismᵢ = ⌞ homomorphism ⌟ -- Uses a strong version of Essential Surjectivity. EssSurj×Full×Faithful⇒Invertible : EssentiallySurjective F → Full F → Faithful F → Functor D C EssSurj×Full×Faithful⇒Invertible surj full faith = record { F₀ = λ d → proj₁ (surj d) ; F₁ = λ {A} {B} f → let (a , sa) = surj A in let (b , sb) = surj B in let module S = Surjective (full {a} {b}) in S.from ⟨$⟩ (_≅_.to sb) ∘ f ∘ (_≅_.from sa) ; identity = λ {A} → let ff = from full (a , sa) = surj A in begin ff ⟨$⟩ _≅_.to sa ∘ D.id ∘ _≅_.from sa ≈⟨ cong ff (E.refl⟩∘⟨ D.identityˡ) ⟩ ff ⟨$⟩ _≅_.to sa ∘ _≅_.from sa ≈⟨ cong ff (_≅_.isoˡ sa) ⟩ ff ⟨$⟩ D.id ≈˘⟨ cong ff identity ⟩ ff ⟨$⟩ F₁ C.id ≈⟨ faith _ _ (right-inverse-of full (F₁ C.id)) ⟩ C.id ∎ ; homomorphism = λ {X} {Y} {Z} {f} {g} → let (x , sx) = surj X (y , sy) = surj Y (z , sz) = surj Z fsx = from sx tsz = to sz ff {T₁} {T₂} = from (full {T₁} {T₂}) in faith _ _ (E.begin F₁ (ff ⟨$⟩ tsz ∘ (g ∘ f) ∘ fsx) E.≈⟨ right-inverse-of full _ ⟩ (tsz ∘ (g ∘ f) ∘ fsx) E.≈⟨ pullˡ (E.refl⟩∘⟨ (E.refl⟩∘⟨ introˡ (isoʳ sy))) ⟩ (tsz ∘ g ∘ ((from sy ∘ to sy) ∘ f)) ∘ fsx E.≈⟨ pushʳ (E.refl⟩∘⟨ D.assoc) E.⟩∘⟨refl ⟩ ((tsz ∘ g) ∘ (from sy ∘ (to sy ∘ f))) ∘ fsx E.≈⟨ D.sym-assoc E.⟩∘⟨refl ⟩ (((tsz ∘ g) ∘ from sy) ∘ (to sy ∘ f)) ∘ fsx E.≈⟨ D.assoc ⟩ ((tsz ∘ g) ∘ from sy) ∘ ((to sy ∘ f) ∘ fsx) E.≈⟨ D.assoc E.⟩∘⟨ D.assoc ⟩ (tsz ∘ g ∘ from sy) ∘ (to sy ∘ f ∘ fsx) E.≈˘⟨ right-inverse-of full _ E.⟩∘⟨ right-inverse-of full _ ⟩ F₁ (ff ⟨$⟩ tsz ∘ g ∘ from sy) ∘ F₁ (ff ⟨$⟩ to sy ∘ f ∘ fsx) E.≈˘⟨ homomorphism ⟩ F₁ ((ff ⟨$⟩ tsz ∘ g ∘ from sy) C.∘ (ff ⟨$⟩ to sy ∘ f ∘ fsx)) E.∎) ; F-resp-≈ = λ f≈g → cong (from full) (D.∘-resp-≈ʳ (D.∘-resp-≈ˡ f≈g)) } where open Morphism._≅_ open Morphism D open Reas D open Category D open Surjective open C.HomReasoning module E = D.HomReasoning -- Functor Composition is Associative and the unit laws are found in -- NaturalTransformation.NaturalIsomorphism, reified as associator, unitorˡ and unitorʳ.
{ "alphanum_fraction": 0.526026026, "avg_line_length": 37.2298136646, "ext": "agda", "hexsha": "34c0754d6361ae622518d530e63cb8a2e0eff41a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Properties.agda", "max_line_length": 126, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 2448, "size": 5994 }
module RandomAccessList.Standard where open import RandomAccessList.Standard.Core open import RandomAccessList.Standard.Core.Properties open import BuildingBlock.BinaryLeafTree using (BinaryLeafTree; Node; Leaf) import BuildingBlock.BinaryLeafTree as BLT open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit using (⊤; tt) open import Data.Fin using (Fin; fromℕ≤; reduce≥; toℕ) import Data.Fin as Fin open import Data.Nat open import Data.Nat.Properties.Simple open import Data.Nat.Etc open import Data.Product as Prod open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Negation using (contraposition) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; trans; sym; inspect) open PropEq.≡-Reasoning -------------------------------------------------------------------------------- -- Operations consₙ : ∀ {n A} → BinaryLeafTree A n → 0-1-RAL A n → 0-1-RAL A n consₙ a [] = a 1∷ [] consₙ a ( 0∷ xs) = a 1∷ xs consₙ a (x 1∷ xs) = 0∷ (consₙ (Node a x) xs) cons : ∀ {A} → A → 0-1-RAL A 0 → 0-1-RAL A 0 cons a xs = consₙ (Leaf a) xs headₙ : ∀ {n A} → (xs : 0-1-RAL A n) → ⟦ xs ⟧ ≢ 0 → BinaryLeafTree A n headₙ {n} {A} [] p = ⊥-elim (p (⟦[]⟧≡0 ([] {A} {n}) refl)) headₙ ( 0∷ xs) p = proj₁ (BLT.split (headₙ xs (contraposition (trans (⟦0∷xs⟧≡⟦xs⟧ xs)) p))) headₙ (x 1∷ xs) p = x head : ∀ {A} → (xs : 0-1-RAL A 0) → ⟦ xs ⟧ ≢ 0 → A head xs p = BLT.head (headₙ xs p) tailₙ : ∀ {n A} → (xs : 0-1-RAL A n) → ⟦ xs ⟧ ≢ 0 → 0-1-RAL A n tailₙ {n} {A} [] p = ⊥-elim (p (⟦[]⟧≡0 ([] {A} {n}) refl)) tailₙ ( 0∷ xs) p = proj₂ (BLT.split (headₙ xs (contraposition (trans (⟦0∷xs⟧≡⟦xs⟧ xs)) p))) 1∷ tailₙ xs (contraposition (trans (⟦0∷xs⟧≡⟦xs⟧ xs)) p) tailₙ (x 1∷ xs) p = 0∷ xs tail : ∀ {A} → (xs : 0-1-RAL A 0) → ⟦ xs ⟧ ≢ 0 → 0-1-RAL A 0 tail = tailₙ -------------------------------------------------------------------------------- -- Searching transportFin : ∀ {a b} → a ≡ b → Fin a → Fin b transportFin refl i = i splitIndex : ∀ {n A} → (x : BinaryLeafTree A n) → (xs : 0-1-RAL A (suc n)) → ⟦ x 1∷ xs ⟧ ≡ (2 ^ n) + ⟦ xs ⟧ splitIndex {n} x xs = begin 2 ^ n * suc (2 * ⟦ xs ⟧ₙ) ≡⟨ +-*-suc (2 ^ n) (2 * ⟦ xs ⟧ₙ) ⟩ 2 ^ n + 2 ^ n * (2 * ⟦ xs ⟧ₙ) ≡⟨ cong (_+_ (2 ^ n)) (sym (*-assoc (2 ^ n) 2 ⟦ xs ⟧ₙ)) ⟩ 2 ^ n + 2 ^ n * 2 * ⟦ xs ⟧ₙ ≡⟨ cong (λ w → 2 ^ n + w * ⟦ xs ⟧ₙ) (*-comm (2 ^ n) 2) ⟩ 2 ^ n + (2 * 2 ^ n) * ⟦ xs ⟧ₙ ∎ elemAt : ∀ {n A} → (xs : 0-1-RAL A n) → Fin ⟦ xs ⟧ → A elemAt {zero} ( []) () elemAt {suc n} {A} ( []) i = elemAt {n} ([] {n = n}) (transportFin (⟦[]⟧≡⟦[]⟧ {n} {A}) i) elemAt ( 0∷ xs) i with ⟦ 0∷ xs ⟧ | inspect ⟦_⟧ (0∷ xs) elemAt ( 0∷ xs) () | zero | _ elemAt {n} ( 0∷ xs) i | suc z | PropEq.[ eq ] = elemAt xs (transportFin (trans (sym eq) (⟦0∷xs⟧≡⟦xs⟧ xs)) i) elemAt {n} (x 1∷ xs) i with (2 ^ n) ≤? toℕ i elemAt {n} (x 1∷ xs) i | yes p rewrite splitIndex x xs = elemAt xs (reduce≥ i p) elemAt (x 1∷ xs) i | no ¬p = BLT.elemAt x (fromℕ≤ (BLT.¬a≤b⇒b<a ¬p))
{ "alphanum_fraction": 0.5166232073, "avg_line_length": 39.8441558442, "ext": "agda", "hexsha": "ceb6891ee36d1494644cb0c82b3c5cda2b815cfd", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/RandomAccessList/Standard.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/RandomAccessList/Standard.agda", "max_line_length": 149, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/RandomAccessList/Standard.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": 1376, "size": 3068 }
module LearnYouAn2 where data ℕ : Set where zero : ℕ suc : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + n = n (suc n) + n′ = suc (n + n′) data _even : ℕ → Set where ZERO : zero even STEP : ∀ x → x even → (suc (suc x)) even -- To prove four is even proof₁ : suc (suc (suc (suc zero))) even proof₁ = STEP (suc (suc zero)) (STEP zero ZERO) proof₂′ : (A : Set) → A → A proof₂′ _ a = a proof₂ : ℕ → ℕ proof₂ = proof₂′ ℕ
{ "alphanum_fraction": 0.5558194774, "avg_line_length": 15.5925925926, "ext": "agda", "hexsha": "eb970e92d23f52ae1e76844d9a677dc85401d545", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-06-03T06:32:26.000Z", "max_forks_repo_forks_event_min_datetime": "2015-12-02T02:10:26.000Z", "max_forks_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shouya/thinking-dumps", "max_forks_repo_path": "learyouanagda/LearnYouAn2.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_issues_repo_issues_event_max_datetime": "2015-08-04T22:05:11.000Z", "max_issues_repo_issues_event_min_datetime": "2015-06-14T06:07:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shouya/thinking-dumps", "max_issues_repo_path": "learyouanagda/LearnYouAn2.agda", "max_line_length": 47, "max_stars_count": 24, "max_stars_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shouya/thinking-dumps", "max_stars_repo_path": "learyouanagda/LearnYouAn2.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T01:02:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-14T17:18:34.000Z", "num_tokens": 169, "size": 421 }
-- Andreas, 2019-08-10 record R : Set₁ where indutive field A : Set -- The error message is strange: -- This declaration is illegal in a record before the last field -- when scope checking the declaration -- record R where -- indutive -- field A : Set
{ "alphanum_fraction": 0.6802973978, "avg_line_length": 19.2142857143, "ext": "agda", "hexsha": "872308c75ab62822192799250b750e3fe9fb0c17", "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/Bugs/MisspelledKeywordInRecord.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/Bugs/MisspelledKeywordInRecord.agda", "max_line_length": 64, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Bugs/MisspelledKeywordInRecord.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": 269 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Categories where open import Prelude open import Cubical.Foundations.HLevels record PreCategory ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where no-eta-equality field Ob : Type ℓ₁ Hom : Ob → Ob → Type ℓ₂ Id : ∀ {X} → Hom X X Comp : ∀ {X Y Z} → Hom Y Z → Hom X Y → Hom X Z assoc-Comp : ∀ {W X Y Z} (f : Hom Y Z) (g : Hom X Y) (h : Hom W X) → Comp f (Comp g h) ≡ Comp (Comp f g) h Comp-Id : ∀ {X Y} (f : Hom X Y) → Comp f Id ≡ f Id-Comp : ∀ {X Y} (f : Hom X Y) → Comp Id f ≡ f Hom-Set : ∀ {X Y} → isSet (Hom X Y) infixr 0 _⟶_ _⟶_ = Hom infixl 0 _⟵_ _⟵_ = flip Hom infixr 9 _·_ _·_ = Comp variable X Y Z : Ob infix 4 _≅_ _≅_ : Ob → Ob → Type _ Isomorphism : (X ⟶ Y) → Type ℓ₂ Isomorphism {X} {Y} f = Σ[ g ⦂ Y ⟶ X ] × (g · f ≡ Id) × (f · g ≡ Id) X ≅ Y = Σ (X ⟶ Y) Isomorphism Domain : (X ⟶ Y) → Ob Domain {X} {Y} _ = X Codomain : (X ⟶ Y) → Ob Codomain {X} {Y} _ = Y module _ {X Y : Ob} where Monic : (X ⟶ Y) → Type _ Monic f = ∀ {Z} → (g₁ g₂ : Z ⟶ X) → f · g₁ ≡ f · g₂ → g₁ ≡ g₂ Epic : (X ⟶ Y) → Type _ Epic f = ∀ {Z} → (g₁ g₂ : Y ⟶ Z) → g₁ · f ≡ g₂ · f → g₁ ≡ g₂ IsInitial : Ob → Type _ IsInitial I = ∀ {X} → isContr (I ⟶ X) IsTerminal : Ob → Type _ IsTerminal T = ∀ {X} → isContr (X ⟶ T) Initial = ∃ x × IsInitial x Terminal = ∃ x × IsTerminal x refl-≅ : X ≅ X refl-≅ .fst = Id refl-≅ .snd .fst = Id refl-≅ .snd .snd .fst = Comp-Id Id refl-≅ .snd .snd .snd = Comp-Id Id sym-≅ : X ≅ Y → Y ≅ X sym-≅ X≅Y .fst = X≅Y .snd .fst sym-≅ X≅Y .snd .fst = X≅Y .fst sym-≅ X≅Y .snd .snd .fst = X≅Y .snd .snd .snd sym-≅ X≅Y .snd .snd .snd = X≅Y .snd .snd .fst open import Path.Reasoning trans-≅ : X ≅ Y → Y ≅ Z → X ≅ Z trans-≅ X≅Y Y≅Z .fst = Y≅Z .fst · X≅Y .fst trans-≅ X≅Y Y≅Z .snd .fst = X≅Y .snd .fst · Y≅Z .snd .fst trans-≅ X≅Y Y≅Z .snd .snd .fst = (X≅Y .snd .fst · Y≅Z .snd .fst) · (Y≅Z .fst · X≅Y .fst) ≡⟨ assoc-Comp _ _ _ ⟩ ((X≅Y .snd .fst · Y≅Z .snd .fst) · Y≅Z .fst) · X≅Y .fst ≡˘⟨ cong (_· X≅Y .fst) (assoc-Comp _ _ _) ⟩ (X≅Y .snd .fst · (Y≅Z .snd .fst · Y≅Z .fst)) · X≅Y .fst ≡⟨ cong (λ yz → (X≅Y .snd .fst · yz) · X≅Y .fst) (Y≅Z .snd .snd .fst) ⟩ (X≅Y .snd .fst · Id) · X≅Y .fst ≡⟨ cong (_· X≅Y .fst) (Comp-Id (X≅Y .snd .fst)) ⟩ X≅Y .snd .fst · X≅Y .fst ≡⟨ X≅Y .snd .snd .fst ⟩ Id ∎ trans-≅ X≅Y Y≅Z .snd .snd .snd = (Y≅Z .fst · X≅Y .fst) · (X≅Y .snd .fst · Y≅Z .snd .fst) ≡⟨ assoc-Comp _ _ _ ⟩ ((Y≅Z .fst · X≅Y .fst) · X≅Y .snd .fst) · Y≅Z .snd .fst ≡˘⟨ cong (_· Y≅Z .snd .fst) (assoc-Comp _ _ _) ⟩ (Y≅Z .fst · (X≅Y .fst · X≅Y .snd .fst)) · Y≅Z .snd .fst ≡⟨ cong (λ xy → (Y≅Z .fst · xy) · Y≅Z .snd .fst) (X≅Y .snd .snd .snd) ⟩ (Y≅Z .fst · Id) · Y≅Z .snd .fst ≡⟨ cong (_· Y≅Z .snd .fst) (Comp-Id _) ⟩ Y≅Z .fst · Y≅Z .snd .fst ≡⟨ Y≅Z .snd .snd .snd ⟩ Id ∎ idToIso : X ≡ Y → X ≅ Y idToIso {X} {Y} X≡Y = subst (X ≅_) X≡Y refl-≅ ≅-set : isSet (X ≅ Y) ≅-set = isOfHLevelΣ 2 Hom-Set λ _ → isOfHLevelΣ 2 Hom-Set λ _ → isOfHLevelΣ 2 (isOfHLevelSuc 2 Hom-Set _ _) λ _ → isOfHLevelSuc 2 Hom-Set _ _ record Category ℓ₁ ℓ₂ : Type (ℓsuc (ℓ₁ ℓ⊔ ℓ₂)) where no-eta-equality field preCategory : PreCategory ℓ₁ ℓ₂ open PreCategory preCategory public field univalent : {X Y : Ob} → (X ≡ Y) ≃ (X ≅ Y) module _ {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) where open Category C _[_,_] : Ob → Ob → Type ℓ₂ _[_,_] = Hom {-# INLINE _[_,_] #-} _[_∘_] : (Y ⟶ Z) → (X ⟶ Y) → (X ⟶ Z) _[_∘_] = Comp {-# INLINE _[_∘_] #-}
{ "alphanum_fraction": 0.4863908547, "avg_line_length": 29.1587301587, "ext": "agda", "hexsha": "8f28f759d6c28d44f373ded8c282bd5af4b0f895", "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": "Categories.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": "Categories.agda", "max_line_length": 131, "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": "Categories.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": 1852, "size": 3674 }
module hott.types.theorems where open import hott.types.nat.theorems public
{ "alphanum_fraction": 0.8311688312, "avg_line_length": 19.25, "ext": "agda", "hexsha": "44f5d11cd83f440f8942e0447fc754cf883441c7", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/types/theorems.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/types/theorems.agda", "max_line_length": 42, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/types/theorems.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 19, "size": 77 }
-- Issue #1130, test generation of helper function -- {-# OPTIONS -v tc.with:40 #-} id : (A : Set) → A → A id A = {!id′!} -- C-c C-h produces: id′ : ∀ {A} → A -- when it should produce: id′ : ∀ {A} → A → A f : (A : Set) (B : A → Set) (a : A) → B a f A B a = {!g A a!} -- Before: ∀ {A} {B : A → Set} A₁ (a : A₁) → B a -- After: ∀ A (a : A) {B : A → Set} → B a -- Andreas, 2019-10-12: ∀ {A} {B : A → Set} (a : A) → B a open import Agda.Builtin.Bool if_then_else : ∀{a} {A : Set a} (b : Bool) (t e : A) → A if true then t else e = t if false then t else e = e -- Andreas, 2019-10-12, issue #1050: Prevent unnecessary normalization. id₂ : (A B : Set) → if true then A else B → if false then B else A id₂ A B x = {!id₂′ x!} -- C-c C-h produces -- id₂′ : ∀ {A} {B} (x : if true then A else B) → -- if false then B else A
{ "alphanum_fraction": 0.5070422535, "avg_line_length": 29.3793103448, "ext": "agda", "hexsha": "f5e7c5c226302a3f87d7b1288d38c2739e2a9684", "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/Issue1130.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/Issue1130.agda", "max_line_length": 71, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue1130.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": 351, "size": 852 }
module Issue117 where Set′ = Set record ⊤ : Set′ where data ⊥ : Set′ where
{ "alphanum_fraction": 0.6375, "avg_line_length": 10, "ext": "agda", "hexsha": "c7741a73d121ef6afaaf365d43336418df430add", "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/Issue117.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/Issue117.agda", "max_line_length": 21, "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/Issue117.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": 28, "size": 80 }
module PiNF-semantics where open import Data.Nat hiding (_⊔_; suc; _+_; _*_) open import Data.Vec open import Level open import Algebra.Structures open import PiNF-algebra ------------------------------------------------------------------------------ -- Define module over a ring (the types bot, top, disjoint union, and product -- do form a ring as shown in the type-iso library) R-module : ℕ → Set → Set R-module dim c = Vec c dim -- The only element of (R-module 0) is the zero vector zeroV : ∀ {A : Set} → R-module 0 A zeroV = [] -- (R-module 1 A) is isomorphic to A v-R1 : ∀ {A : Set} → A → R-module 1 A v-R1 a = [ a ] R1-v : ∀ {A : Set} → R-module 1 A → A R1-v (a ∷ []) = a -- module MR (C : CommutativeSemiringWithoutAnnihilatingZero Level.zero Level.zero) where open Data.Nat using (ℕ; zero; suc; _+_; _*_) open Data.Vec using ([]; _∷_; map; _++_) open CommutativeSemiringWithoutAnnihilatingZero using (Carrier; _≈_; 0#; 1#) renaming (_+_ to _+r_; _*_ to _*r_) {-- zeroV : ∀ {b : Set} → R-module b 0 zeroV = [] tensorV : {b₁ b₂ : Set } {m₁ m₂ : ℕ} → R-module b₁ m₁ → R-module b₂ m₂ → R-module (b₁ × b₂) (m₁ * m₂) tensorV [] _ = [] tensorV (x ∷ xs) ys = (map (λ y → (x , y)) ys) ++ (tensorV xs ys) addV : {n : ℕ} → R-module (Carrier C) n → R-module (Carrier C) n → R-module (Carrier C) n addV x y = Data.Vec.zipWith (_+r_ C) x y --} open MR ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5305719921, "avg_line_length": 25.7796610169, "ext": "agda", "hexsha": "6c7eb0033234232f96f8daa8f7b23d4648bbb4a6", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "agda/PiNF-semantics.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "agda/PiNF-semantics.agda", "max_line_length": 86, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "agda/PiNF-semantics.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": 498, "size": 1521 }
{-# OPTIONS --allow-unsolved-metas #-} open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Primitive record Graph ℓv ℓe : Set (lsuc (ℓv ⊔ ℓe)) where field Obj : Set ℓv Hom : Obj → Obj → Set ℓe open Graph public postulate t : Nat → Nat → Bool ωGr : Graph lzero lzero Obj ωGr = Nat Hom ωGr m n with t m n ... | true = {!!} -- if n ≡ (suc m) ... | false = {!!} -- otherwise foo : ∀ m n → Hom ωGr m n → {!!} foo m n f with t m n ... | z = {!!}
{ "alphanum_fraction": 0.5892116183, "avg_line_length": 18.5384615385, "ext": "agda", "hexsha": "1918ce8f5cbc34c715f169533b240c6cff569a72", "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/Issue4570.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/Issue4570.agda", "max_line_length": 47, "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/Issue4570.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": 180, "size": 482 }
open import Data.Nat using (ℕ; zero; suc; _+_; _∸_; _≥_; _≤_; z≤n; s≤s) open import Function.Equivalence using (_⇔_) open import Relation.Binary.PropositionalEquality using (→-to-⟶) postulate adjoint : ∀ {x y z} → x + y ≥ z ⇔ x ≥ z ∸ y unit : ∀ {x y} → x ≥ (x + y) ∸ y apply : ∀ {x y} → (x ∸ y) + y ≥ x
{ "alphanum_fraction": 0.5659163987, "avg_line_length": 31.1, "ext": "agda", "hexsha": "28bba263ed57852bf4c9366fb9c60331f76fb40d", "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/Monus.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/Monus.agda", "max_line_length": 71, "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/Monus.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": 136, "size": 311 }
module _ where open import Agda.Builtin.Nat renaming (Nat to Nombre) open import Agda.Builtin.Equality open import Agda.Builtin.String open import Agda.Builtin.Reflection check₁ : primShowQName (quote Nombre) ≡ "Agda.Builtin.Nat.Nat" check₁ = refl check₂ : primShowQName (quote Agda.Builtin.Nat.Nat) ≡ "Agda.Builtin.Nat.Nat" check₂ = refl
{ "alphanum_fraction": 0.778425656, "avg_line_length": 24.5, "ext": "agda", "hexsha": "0f3ab2010a843b28ba8f6cee696c650e3c6db92b", "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/Issue4735.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/Issue4735.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue4735.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 107, "size": 343 }
open import FRP.JS.Nat using ( ℕ ; _+_ ; _≤_ ; _<_ ; _≟_ ) open import FRP.JS.True using ( True ; False ) module FRP.JS.Nat.Properties where postulate ≤-impl-≯ : ∀ {m n} → True (m ≤ n) → False (n < m) ≤≠-impl-< : ∀ {m n} → True (m ≤ n) → False (m ≟ n) → True (m < n) <-impl-s≤ : ∀ {m n} → True (m < n) → True (1 + m ≤ n) ≤-bot : ∀ {n} → True (0 ≤ n)
{ "alphanum_fraction": 0.4903047091, "avg_line_length": 32.8181818182, "ext": "agda", "hexsha": "17d6a49e62e8e3e94cff4f1727d3c17c7855a47f", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Nat/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Nat/Properties.agda", "max_line_length": 67, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Nat/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 161, "size": 361 }
module _ where open import Agda.Builtin.Reflection open import Agda.Builtin.Equality module M where open import Agda.Builtin.Nat renaming (Nat to Nombre) a = quote Nombre fail : M.a ≡ quote Name fail = refl
{ "alphanum_fraction": 0.7534883721, "avg_line_length": 16.5384615385, "ext": "agda", "hexsha": "bf16591bd15225e7f71b93af2ba79cb451ad123e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue5048.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue5048.agda", "max_line_length": 55, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue5048.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": 60, "size": 215 }
{-# OPTIONS --safe --without-K #-} open import Generics.Prelude open import Generics.Telescope open import Generics.Desc open import Generics.All module Generics.Accessibility {P I ℓ} (A : Indexed P I ℓ) {n} (D : DataDesc P I n) (let A′ = uncurry P I A) (split : ∀ {pi} → A′ pi → ⟦ D ⟧Data A′ pi) {p} where -- | Accessibility predicate for datatype A at value x data Acc {i} (x : A′ (p , i)) : Setω where acc : AllDataω Acc D (split x) → Acc x
{ "alphanum_fraction": 0.6336206897, "avg_line_length": 27.2941176471, "ext": "agda", "hexsha": "de327251080cbfc10dfb81da80867c31e7072378", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/Accessibility.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/Accessibility.agda", "max_line_length": 56, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/Accessibility.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 160, "size": 464 }
{- Types Summer School 2007 Bertinoro Aug 19 - 31, 2007 Agda Ulf Norell -} -- Records are labeled sigma types. module Records where open import Nat open import Bool {- A very simple record. -} record Point : Set where field x : Nat y : Nat -- A record can be seen as a one constructor datatype. In this case: data Point' : Set where mkPoint : (x : Nat)(y : Nat) -> Point' -- There are a few differences, though: -- To construct a record you use the syntax record { ..; x = e; .. } origin : Point origin = record { x = 0; y = 0 } -- instead of origin' : Point' origin' = mkPoint 0 0 -- What's more interesting is that you get projection functions -- for free when you declare a record. More precisely, you get a module -- parameterised over a record, containing functions corresponding to the -- fields. In the Point example you get: {- module Point (p : Point) where x : Nat y : Nat -} -- So Point.x : Point -> Nat is the projection function for the field x. getX : Point -> Nat getX = Point.x -- A nifty thing with having the projection functions in a module is that -- you can apply the module to a record value, in effect opening the record. sum : Point -> Nat sum p = x + y where open module Pp = Point p -- The final difference between records and datatypes is that we have -- η-equality on records. data _==_ {A : Set}(x : A) : A -> Set where refl : x == x η-Point : (p : Point) -> p == record { x = Point.x p; y = Point.y p } η-Point p = refl {- The empty record -} -- One interesting benefit of this is that we get a unit type with -- η-equality. record True : Set where tt : True tt = record{} -- Now, since any element of True is equal to tt, metavariables of -- type True will simply disappear. The following cute example exploits -- this: data False : Set where NonZero : Nat -> Set NonZero zero = False NonZero (suc _) = True -- We make the proof that m is non-zero implicit. _/_ : (n m : Nat){p : NonZero m} -> Nat (n / zero) {} zero / suc m = zero suc n / suc m = div (suc n) (suc m) m where div : Nat -> Nat -> Nat -> Nat div zero zero c = suc zero div zero (suc y) c = zero div (suc x) zero c = suc (div x c c) div (suc x) (suc y) c = div x y c -- Now, as long as we're dividing by things which are obviously -- NonZero we can completely ignore the proof. five = 17 / 3 {- A dependent record -} -- Of course, records can be dependent, and have parameters. record ∃ {A : Set}(P : A -> Set) : Set where field witness : A proof : P witness
{ "alphanum_fraction": 0.6268375424, "avg_line_length": 20.5658914729, "ext": "agda", "hexsha": "1dda8aab2e493903d2c933061c4328d63f7f9156", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Records.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": 771, "size": 2653 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Sigma.Base where open import Cubical.Core.Primitives public -- Σ-types are defined in Core/Primitives as they are needed for Glue types.
{ "alphanum_fraction": 0.7552083333, "avg_line_length": 27.4285714286, "ext": "agda", "hexsha": "22a03950b555f496baf024f561f533a76ce348de", "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/Sigma/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/Sigma/Base.agda", "max_line_length": 76, "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/Sigma/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 47, "size": 192 }
module FMSB where data Nat : Set where ze : Nat su : Nat -> Nat data Lam (X : Nat -> Set)(n : Nat) : Set where var : X n -> Lam X n app : Lam X n -> Lam X n -> Lam X n lam : Lam X (su n) -> Lam X n _->>_ : {I : Set}(X Y : I -> Set) -> Set X ->> Y = {i : _} -> X i -> Y i fmsub : {X Y : Nat -> Set} -> (X ->> Lam Y) -> Lam X ->> Lam Y fmsub sb (var x) = sb x fmsub sb (app f s) = app (fmsub sb f) (fmsub sb s) fmsub sb (lam b) = lam (fmsub sb b) data Fin : Nat -> Set where ze : {n : Nat} -> Fin (su n) su : {n : Nat} -> Fin n -> Fin (su n) D : (Nat -> Set) -> Nat -> Set D F n = F (su n) weak : {F : Nat -> Set} -> (Fin ->> F) -> (F ->> D F) -> {m n : Nat}-> (Fin m -> F n) -> D Fin m -> D F n weak v w f ze = v ze weak v w f (su x) = w (f x) _+_ : Nat -> Nat -> Nat ze + y = y su x + y = su (x + y) _!+_ : (Nat -> Set) -> Nat -> (Nat -> Set) F !+ n = \ m -> F (m + n) weaks : {F : Nat -> Set} -> (Fin ->> F) -> (F ->> D F) -> {m n : Nat}-> (Fin m -> F n) -> (Fin !+ m) ->> (F !+ n) weaks v w f {ze} = f weaks v w f {su i} = weak v w (weaks v w f {i}) jing : {m n : Nat} -> Lam Fin (m + n) -> Lam (Fin !+ n) m jing (var x) = var x jing (app f s) = app (jing f) (jing s) jing (lam t) = lam (jing t) gnij : {m n : Nat} -> Lam (Fin !+ n) m -> Lam Fin (m + n) gnij (var x) = var x gnij (app f s) = app (gnij f) (gnij s) gnij (lam t) = lam (gnij t) ren : {m n : Nat} -> (Fin m -> Fin n) -> Lam Fin m -> Lam Fin n ren f t = gnij (fmsub (\ {i} x -> var (weaks (\ z -> z) su f {i} x)) {ze} (jing t)) sub : {m n : Nat} -> (Fin m -> Lam Fin n) -> Lam Fin m -> Lam Fin n sub {m}{n} f t = gnij {ze} (fmsub (\ {i} x -> jing {i} (weaks {Lam Fin} var (ren su) f {i} x)) (jing {ze} t))
{ "alphanum_fraction": 0.450867052, "avg_line_length": 29.8275862069, "ext": "agda", "hexsha": "e7e88d2808911e6ef956b69c8a3561d1fc94befa", "lang": "Agda", "max_forks_count": 12, "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mietek/epigram", "max_forks_repo_path": "models/FMSB.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "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": "mietek/epigram", "max_issues_repo_path": "models/FMSB.agda", "max_line_length": 109, "max_stars_count": 48, "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mietek/epigram", "max_stars_repo_path": "models/FMSB.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "num_tokens": 756, "size": 1730 }
{-# OPTIONS --guardedness #-} module Iterator where import Lvl open import Data.Option as Option using (Option ; Some ; None) open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Type private variable ℓ : Lvl.Level private variable T A B : Type{ℓ} private variable a x init : T private variable f : A → B -- A finite/infinite sequence. record Iterator (T : Type{ℓ}) : Type{ℓ} where coinductive field next : Option(T ⨯ Iterator(T)) open Iterator empty : Iterator(T) next empty = None singleton : T → Iterator(T) next(singleton x) = Some(x , empty) prepend : T → Iterator(T) -> Iterator(T) next(prepend x i) = Some(x , i) import Data.Option.Functions as Option head : Iterator(T) → Option(T) head i = Option.map Tuple.left (next(i)) tail : Iterator(T) → Option(Iterator(T)) tail i = Option.map Tuple.right (next(i)) open import Functional tail₀ : Iterator(T) → Iterator(T) tail₀ = (Option._or empty) ∘ tail open import Numeral.Natural open import Numeral.Natural.Induction index : ℕ → Iterator(T) → Option(T) index n i with next(i) index _ _ | None = None index 𝟎 _ | Some(x , r) = Some x index (𝐒(k)) _ | Some(x , r) = index k r repeat : T → Iterator(T) next(repeat(x)) = Some(x , repeat(x)) map : (A → B) → (Iterator(A) → Iterator(B)) next(map f(i)) with next(i) ... | None = None ... | Some(x , r) = Some(f(x) , map f(r)) -- Option.map (Tuple.map f (map f)) (next i)
{ "alphanum_fraction": 0.6458333333, "avg_line_length": 22.5, "ext": "agda", "hexsha": "945da420c673a646107035735634a606707b9b59", "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": "Iterator.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": "Iterator.agda", "max_line_length": 62, "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": "Iterator.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": 427, "size": 1440 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Properties.Presheaves where open import Categories.Category.Construction.Properties.Presheaves.Cartesian using (module IsCartesian) public open import Categories.Category.Construction.Properties.Presheaves.CartesianClosed using (module IsCCC) public open import Categories.Category.Construction.Properties.Presheaves.Complete using (Presheaves-Complete; Presheaves-Cocomplete) public
{ "alphanum_fraction": 0.8231578947, "avg_line_length": 29.6875, "ext": "agda", "hexsha": "46a8d990c1dddd98cc8b6cd6271e6452d60a4832", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/Properties/Presheaves.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Construction/Properties/Presheaves.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Construction/Properties/Presheaves.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 101, "size": 475 }
------------------------------------------------------------------------ -- An example ------------------------------------------------------------------------ module Mixfix.Acyclic.Example where open import Codata.Musical.Notation open import Data.Vec using ([]; _∷_; [_]) open import Data.List as List using (List; []; _∷_) renaming ([_] to L[_]) open import Data.List.Membership.Propositional using (_∈_) open import Data.List.Relation.Unary.Any using (here; there) import Codata.Musical.Colist as Colist open import Data.Product using (∃₂; -,_) open import Data.Unit.Polymorphic using (⊤) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Nat using (zero; suc) open import Data.Fin using (#_) import Data.List.Relation.Binary.Pointwise as ListEq import Data.String as String open String using (String; _++_) import Data.String.Properties as String open import Relation.Binary open DecSetoid (ListEq.decSetoid String.≡-decSetoid) using (_≟_) open import Function using (_∘_; _$_) open import Data.Bool using (Bool; if_then_else_) import Data.Bool.Show as Bool open import Relation.Nullary.Decidable using (⌊_⌋) import Relation.Binary.PropositionalEquality as P open import IO import Level open import Mixfix.Fixity hiding (_≟_) open import Mixfix.Operator open import Mixfix.Expr open import Mixfix.Acyclic.PrecedenceGraph import Mixfix.Acyclic.Grammar as Grammar import Mixfix.Acyclic.Show as Show import StructurallyRecursiveDescentParsing.Simplified as Simplified open Simplified using (Parser) import StructurallyRecursiveDescentParsing.DepthFirst as DepthFirst import TotalParserCombinators.BreadthFirst as BreadthFirst ------------------------------------------------------------------------ -- Operators atom : Operator closed 0 atom = record { nameParts = "•" ∷ [] } plus : Operator (infx left) 0 plus = record { nameParts = "+" ∷ [] } ifThen : Operator prefx 1 ifThen = record { nameParts = "i" ∷ "t" ∷ [] } ifThenElse : Operator prefx 2 ifThenElse = record { nameParts = "i" ∷ "t" ∷ "e" ∷ [] } comma : Operator (infx left) 0 comma = record { nameParts = "," ∷ [] } wellTyped : Operator postfx 1 wellTyped = record { nameParts = "⊢" ∷ "∶" ∷ [] } ------------------------------------------------------------------------ -- Precedence graph prec : List (∃₂ Operator) → List Precedence → Precedence prec ops = precedence (λ fix → List.mapMaybe (hasFixity fix) ops) mutual a = prec ((-, -, atom) ∷ []) [] pl = prec ((-, -, plus) ∷ []) (a ∷ []) ii = prec ((-, -, ifThen) ∷ (-, -, ifThenElse) ∷ []) (pl ∷ a ∷ []) c = prec ((-, -, comma) ∷ []) (ii ∷ pl ∷ a ∷ []) wt = prec ((-, -, wellTyped) ∷ []) (c ∷ a ∷ []) g : PrecedenceGraph g = wt ∷ c ∷ ii ∷ pl ∷ a ∷ [] ------------------------------------------------------------------------ -- Expressions open PrecedenceCorrect acyclic g • : ExprIn a non • = ⟪ here P.refl ∙ [] ⟫ _+_ : Outer pl left → Expr (a ∷ []) → ExprIn pl left e₁ + e₂ = e₁ ⟨ here P.refl ∙ [] ⟩ˡ e₂ i_t_ : Expr g → Outer ii right → ExprIn ii right i e₁ t e₂ = ⟪ here P.refl ∙ e₁ ∷ [] ⟩ e₂ i_t_e_ : Expr g → Expr g → Outer ii right → ExprIn ii right i e₁ t e₂ e e₃ = ⟪ there (here P.refl) ∙ e₁ ∷ e₂ ∷ [] ⟩ e₃ _,_ : Outer c left → Expr (ii ∷ pl ∷ a ∷ []) → ExprIn c left e₁ , e₂ = e₁ ⟨ here P.refl ∙ [] ⟩ˡ e₂ _⊢_∶ : Outer wt left → Expr g → Expr g e₁ ⊢ e₂ ∶ = here P.refl ∙ (e₁ ⟨ here P.refl ∙ [ e₂ ] ⟫) ------------------------------------------------------------------------ -- Some tests open Show g fromNameParts : List NamePart → String fromNameParts = List.foldr _++_ "" toNameParts : String → List NamePart toNameParts = List.map (String.fromList ∘ L[_]) ∘ String.toList data Backend : Set where depthFirst : Backend breadthFirst : Backend parse : ∀ {Tok e R} → Backend → Parser Tok e R → List Tok → List R parse depthFirst p = DepthFirst.parseComplete p parse breadthFirst p = BreadthFirst.parse (Simplified.⟦_⟧ p) parseExpr : Backend → String → List String parseExpr backend = List.map (fromNameParts ∘ show) ∘ parse backend (Grammar.expression g) ∘ toNameParts -- The breadth-first backend is considerably slower than the -- depth-first one on these examples. backend = depthFirst runTest : String → List String → IO (⊤ {ℓ = Level.zero}) runTest s₁ s₂ = do putStrLn ("Testing: " ++ s₁) Colist.mapM′ putStrLn (Colist.fromList p₁) putStrLn (if ⌊ p₁ ≟ s₂ ⌋ then "Passed" else "Failed") where p₁ = parseExpr backend s₁ main = run do runTest "•+•⊢•∶" [] runTest "•,•⊢∶" [] runTest "•⊢•∶" L[ "•⊢•∶" ] runTest "•,i•t•+•⊢•∶" L[ "•,i•t•+•⊢•∶" ] runTest "i•ti•t•e•" ("i•ti•t•e•" ∷ "i•ti•t•e•" ∷ [])
{ "alphanum_fraction": 0.5834912613, "avg_line_length": 32.5273972603, "ext": "agda", "hexsha": "b20e7dbabeed15fa33cf8dd6b49e693539f7af95", "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": "Mixfix/Acyclic/Example.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": "Mixfix/Acyclic/Example.agda", "max_line_length": 73, "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": "Mixfix/Acyclic/Example.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": 1451, "size": 4749 }
module List.Permutation.Base (A : Set) where open import Data.List data _/_⟶_ : List A → A → List A → Set where /head : {x : A}{xs : List A} → (x ∷ xs) / x ⟶ xs /tail : {x y : A}{xs ys : List A} → xs / y ⟶ ys → (x ∷ xs) / y ⟶ (x ∷ ys) data _∼_ : List A → List A → Set where ∼[] : [] ∼ [] ∼x : {x : A}{xs ys xs' ys' : List A} → xs / x ⟶ xs' → ys / x ⟶ ys' → xs' ∼ ys' → xs ∼ ys
{ "alphanum_fraction": 0.3376383764, "avg_line_length": 27.1, "ext": "agda", "hexsha": "969a1f41f70d25abb6d875152664c6cc521cee79", "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/List/Permutation/Base.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/List/Permutation/Base.agda", "max_line_length": 44, "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/List/Permutation/Base.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": 192, "size": 542 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Lemmas open import Groups.Definition open import Groups.Subgroups.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Rings.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Rings.Ideals.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where open Ring R open Setoid S open Equivalence eq open Group additiveGroup open import Rings.Lemmas R open import Rings.Divisible.Definition R record Ideal {c : _} (pred : A → Set c) : Set (a ⊔ b ⊔ c) where field isSubgroup : Subgroup additiveGroup pred accumulatesTimes : {x : A} → {y : A} → pred x → pred (x * y) closedUnderPlus = Subgroup.closedUnderPlus isSubgroup closedUnderInverse = Subgroup.closedUnderInverse isSubgroup containsIdentity = Subgroup.containsIdentity isSubgroup isSubset = Subgroup.isSubset isSubgroup predicate = pred generatedIdealPred : A → A → Set (a ⊔ b) generatedIdealPred a b = a ∣ b generatedIdeal : (a : A) → Ideal (generatedIdealPred a) Subgroup.isSubset (Ideal.isSubgroup (generatedIdeal a)) {x} {y} x=y (c , prC) = c , transitive prC x=y Subgroup.closedUnderPlus (Ideal.isSubgroup (generatedIdeal a)) {g} {h} (c , prC) (d , prD) = (c + d) , transitive *DistributesOver+ (+WellDefined prC prD) Subgroup.containsIdentity (Ideal.isSubgroup (generatedIdeal a)) = 0G , timesZero Subgroup.closedUnderInverse (Ideal.isSubgroup (generatedIdeal a)) {g} (c , prC) = inverse c , transitive ringMinusExtracts (inverseWellDefined additiveGroup prC) Ideal.accumulatesTimes (generatedIdeal a) {x} {y} (c , prC) = (c * y) , transitive *Associative (*WellDefined prC reflexive)
{ "alphanum_fraction": 0.7322435175, "avg_line_length": 42.2380952381, "ext": "agda", "hexsha": "6db2faade03ed21dbbd56c45b19cd0466a8159ea", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Rings/Ideals/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Rings/Ideals/Definition.agda", "max_line_length": 161, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Rings/Ideals/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 541, "size": 1774 }
-- Note that the flag --guardedness-preserving-type-constructors is -- not (should not be) enabled in this module. module TypeConstructorsWhichPreserveGuardedness1 where open import Common.Coinduction record ⊤ : Set where data _⊎_ (A B : Set) : Set where inj₁ : A → A ⊎ B inj₂ : B → A ⊎ B record ∃ {A : Set} (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ data Rec (A : ∞ Set) : Set where fold : ♭ A → Rec A module ℕ₁ where -- Without the flag, the following is non-terminating, -- hence, not reduced. {-# NON_TERMINATING #-} ℕ : Set ℕ = ⊤ ⊎ Rec (♯ ℕ) zero : ℕ zero = inj₁ _ -- yields a type error since ℕ does not reduce suc : ℕ → ℕ suc n = inj₂ (fold n) ℕ-rec : (P : ℕ → Set) → P zero → (∀ n → P n → P (suc n)) → ∀ n → P n ℕ-rec P z s (inj₁ _) = z ℕ-rec P z s (inj₂ (fold n)) = s n (ℕ-rec P z s n) module ℕ₂ where data ℕC : Set where ′zero : ℕC ′suc : ℕC mutual ℕ : Set ℕ = ∃ λ (c : ℕC) → ℕ′ c ℕ′ : ℕC → Set ℕ′ ′zero = ⊤ ℕ′ ′suc = Rec (♯ ℕ) zero : ℕ zero = (′zero , _) suc : ℕ → ℕ suc n = (′suc , fold n) ℕ-rec : (P : ℕ → Set) → P zero → (∀ n → P n → P (suc n)) → ∀ n → P n ℕ-rec P z s (′zero , _) = z ℕ-rec P z s (′suc , fold n) = s n (ℕ-rec P z s n)
{ "alphanum_fraction": 0.507703595, "avg_line_length": 19.1971830986, "ext": "agda", "hexsha": "0e8739882df7d262e6d632d1ddeeca29f44c66d5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/TypeConstructorsWhichPreserveGuardedness1.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Fail/TypeConstructorsWhichPreserveGuardedness1.agda", "max_line_length": 67, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/TypeConstructorsWhichPreserveGuardedness1.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": 535, "size": 1363 }
-- The same name can not be exported more than once from a module. module Issue154 where module A where postulate X : Set module B where postulate X : Set open A public
{ "alphanum_fraction": 0.7344632768, "avg_line_length": 17.7, "ext": "agda", "hexsha": "21ea9cd1dc6452a63386b6e2172e18bfc906f702", "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/Issue154.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/Issue154.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue154.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": 47, "size": 177 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Homotopy.HopfInvariant.Homomorphism where open import Cubical.Homotopy.HopfInvariant.Base open import Cubical.Homotopy.Group.Base open import Cubical.Homotopy.Group.SuspensionMap open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.MayerVietorisUnreduced open import Cubical.ZCohomology.Groups.Unit open import Cubical.ZCohomology.Groups.Wedge open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.RingStructure.CupProduct open import Cubical.ZCohomology.RingStructure.GradedCommutativity open import Cubical.ZCohomology.Gysin open import Cubical.Foundations.Path open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Data.Sigma open import Cubical.Data.Int hiding (_+'_) open import Cubical.Data.Nat renaming (_+_ to _+ℕ_ ; _·_ to _·ℕ_) open import Cubical.Data.Unit open import Cubical.Algebra.Group open import Cubical.Algebra.Group.DirProd open import Cubical.Algebra.Group.ZAction open import Cubical.Algebra.Group.Exact open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Instances.Int open import Cubical.Algebra.Group.GroupPath open import Cubical.HITs.Pushout open import Cubical.HITs.Sn open import Cubical.HITs.Susp open import Cubical.HITs.Wedge open import Cubical.HITs.Truncation open import Cubical.HITs.SetTruncation renaming (elim to sElim ; elim2 to sElim2 ; map to sMap) open import Cubical.HITs.PropositionalTruncation open PlusBis -- The pushout describing the hopf invariant of the multiplication (∙Π) of -- two maps (S³⁺²ⁿ →∙ S²⁺ⁿ) C·Π : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → Type _ C·Π n f g = Pushout (λ _ → tt) (∙Π f g .fst) -- Another pushout, essentially the same, but starting with -- S³⁺²ⁿ ∨ S³⁺²ⁿ. This will be used to break up the hopf invariant -- of ∙Π f g. C* : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → Type _ C* n f g = Pushout (λ _ → tt) (fst (∨→∙ f g)) -- The coequaliser of ∙Π and ∨→∙ θ : ∀ {ℓ} {A : Pointed ℓ} → Susp (fst A) → (Susp (fst A) , north) ⋁ (Susp (fst A) , north) θ north = inl north θ south = inr north θ {A = A} (merid a i₁) = ((λ i → inl ((merid a ∙ sym (merid (pt A))) i)) ∙∙ push tt ∙∙ λ i → inr ((merid a ∙ sym (merid (pt A))) i)) i₁ ∙Π≡∨→∘θ : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → (x : _) → ∙Π f g .fst x ≡ (f ∨→ g) (θ {A = S₊∙ _} x) ∙Π≡∨→∘θ n f g north = sym (snd f) ∙Π≡∨→∘θ n f g south = sym (snd g) ∙Π≡∨→∘θ n f g (merid a i₁) j = main j i₁ where help : cong (f ∨→ g) (cong (θ {A = S₊∙ _}) (merid a)) ≡ (refl ∙∙ cong (fst f) (merid a ∙ sym (merid north)) ∙∙ snd f) ∙ (sym (snd g) ∙∙ cong (fst g) (merid a ∙ sym (merid north)) ∙∙ refl) help = cong-∙∙ (f ∨→ g) ((λ i → inl ((merid a ∙ sym (merid north)) i))) (push tt) (λ i → inr ((merid a ∙ sym (merid north)) i)) ∙∙ doubleCompPath≡compPath _ _ _ ∙∙ cong (cong (f ∨→ g) (λ i₂ → inl ((merid a ∙ (λ i₃ → merid north (~ i₃))) i₂)) ∙_) (sym (assoc _ _ _)) ∙∙ assoc _ _ _ ∙∙ cong₂ _∙_ refl (compPath≡compPath' _ _) main : PathP (λ i → snd f (~ i) ≡ snd g (~ i)) (λ i₁ → ∙Π f g .fst (merid a i₁)) λ i₁ → (f ∨→ g) (θ {A = S₊∙ _} (merid a i₁)) main = (λ i → ((λ j → snd f (~ i ∧ ~ j)) ∙∙ cong (fst f) (merid a ∙ sym (merid north)) ∙∙ snd f) ∙ (sym (snd g) ∙∙ cong (fst g) (merid a ∙ sym (merid north)) ∙∙ λ j → snd g (~ i ∧ j))) ▷ sym help private WedgeElim : ∀ {ℓ} (n : ℕ) {P : S₊∙ (3 +ℕ (n +ℕ n)) ⋁ S₊∙ (3 +ℕ (n +ℕ n)) → Type ℓ} → ((x : _) → isOfHLevel (3 +ℕ n) (P x)) → P (inl north) → (x : _) → P x WedgeElim n {P = P} x s (inl x₁) = sphereElim _ {A = P ∘ inl} (λ _ → isOfHLevelPlus' {n = n} (3 +ℕ n) (x _)) s x₁ WedgeElim n {P = P} x s (inr x₁) = sphereElim _ {A = P ∘ inr} (sphereElim _ (λ _ → isProp→isOfHLevelSuc ((suc (suc (n +ℕ n)))) (isPropIsOfHLevel (suc (suc (suc (n +ℕ n)))))) (subst (isOfHLevel ((3 +ℕ n) +ℕ n)) (cong P (push tt)) (isOfHLevelPlus' {n = n} (3 +ℕ n) (x _)))) (subst P (push tt) s) x₁ WedgeElim n {P = P} x s (push a j) = transp (λ i → P (push tt (i ∧ j))) (~ j) s H²C*≅ℤ : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → GroupIso (coHomGr (2 +ℕ n) (C* n f g)) ℤGroup H²C*≅ℤ n f g = compGroupIso is (Hⁿ-Sⁿ≅ℤ (suc n)) where ∘inr : (coHom (2 +ℕ n) (C* n f g)) → coHom (2 +ℕ n) (S₊ (2 +ℕ n)) ∘inr = sMap λ f → f ∘ inr invMapPrim : (S₊ (2 +ℕ n) → coHomK (2 +ℕ n)) → C* n f g → coHomK (2 +ℕ n) invMapPrim h (inl x) = h (ptSn _) invMapPrim h (inr x) = h x invMapPrim h (push a i₁) = WedgeElim n {P = λ a → h north ≡ h (fst (∨→∙ f g) a)} (λ _ → isOfHLevelTrunc (4 +ℕ n) _ _) (cong h (sym (snd f))) a i₁ invMap : coHom (2 +ℕ n) (S₊ (2 +ℕ n)) → (coHom (2 +ℕ n) (C* n f g)) invMap = sMap invMapPrim ∘inrSect : (x : coHom (2 +ℕ n) (S₊ (2 +ℕ n))) → ∘inr (invMap x) ≡ x ∘inrSect = sElim (λ _ → isOfHLevelPath 2 squash₂ _ _) λ a → refl ∘inrRetr : (x : (coHom (2 +ℕ n) (C* n f g))) → invMap (∘inr x) ≡ x ∘inrRetr = sElim (λ _ → isOfHLevelPath 2 squash₂ _ _) λ h → cong ∣_∣₂ (funExt λ { (inl x) → cong h ((λ i → inr ((snd f) (~ i))) ∙ sym (push (inl north))) ; (inr x) → refl ; (push a i) → lem₁ h a i}) where lem₁ : (h : C* n f g → coHomK (2 +ℕ n)) (a : _) → PathP (λ i → invMapPrim (h ∘ inr) (push a i) ≡ h (push a i)) (cong h ((λ i → inr ((snd f) (~ i))) ∙ sym (push (inl north)))) refl lem₁ h = WedgeElim n (λ _ → isOfHLevelPathP (3 +ℕ n) (isOfHLevelTrunc (4 +ℕ n) _ _) _ _) lem₂ where lem₂ : PathP (λ i → invMapPrim (h ∘ inr) (push (inl north) i) ≡ h (push (inl north) i)) (cong h ((λ i → inr ((snd f) (~ i))) ∙ sym (push (inl north)))) refl lem₂ i j = h (hcomp (λ k → λ { (i = i1) → inr (fst f north) ; (j = i0) → inr (snd f (~ i)) ; (j = i1) → push (inl north) (i ∨ ~ k)}) (inr (snd f (~ i ∧ ~ j)))) is : GroupIso (coHomGr (2 +ℕ n) (C* n f g)) (coHomGr (2 +ℕ n) (S₊ (2 +ℕ n))) Iso.fun (fst is) = ∘inr Iso.inv (fst is) = invMap Iso.rightInv (fst is) = ∘inrSect Iso.leftInv (fst is) = ∘inrRetr snd is = makeIsGroupHom (sElim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _) λ f g → refl) H⁴-C·Π : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → GroupIso (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C·Π n f g)) ℤGroup H⁴-C·Π n f g = compGroupIso (transportCohomIso (cong (3 +ℕ_) (+-suc n n))) (Hopfβ-Iso n (∙Π f g)) H²-C·Π : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → GroupIso (coHomGr (2 +ℕ n) (C·Π n f g)) ℤGroup H²-C·Π n f g = Hopfα-Iso n (∙Π f g) H⁴-C* : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → GroupIso (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)) (DirProd ℤGroup ℤGroup) H⁴-C* n f g = compGroupIso (GroupEquiv→GroupIso (invGroupEquiv fstIso)) (compGroupIso (transportCohomIso (cong (2 +ℕ_) (+-suc n n))) (compGroupIso (Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n))))) (S₊∙ (suc (suc (suc (n +ℕ n))))) _) (GroupIsoDirProd (Hⁿ-Sⁿ≅ℤ _) (Hⁿ-Sⁿ≅ℤ _)))) where module Ms = MV _ _ _ (λ _ → tt) (fst (∨→∙ f g)) fstIso : GroupEquiv (coHomGr ((suc (suc (n +ℕ suc n)))) (S₊∙ (3 +ℕ (n +ℕ n)) ⋁ S₊∙ (3 +ℕ (n +ℕ n)))) (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)) fst (fst fstIso) = Ms.d (suc (suc (n +ℕ suc n))) .fst snd (fst fstIso) = SES→isEquiv (sym (fst (GroupPath _ _) (isContr→≃Unit (isContrΣ (subst isContr (isoToPath (invIso (fst (Hⁿ-Unit≅0 _)))) isContrUnit) (λ _ → subst isContr (isoToPath (invIso (fst (Hⁿ-Sᵐ≅0 _ _ λ p → ¬lemHopf 0 ((λ _ → north) , refl) n n (cong suc (sym (+-suc n n)) ∙ p))))) isContrUnit)) , makeIsGroupHom λ _ _ → refl))) (GroupPath _ _ .fst (compGroupEquiv (invEquiv (isContr→≃Unit ((tt , tt) , (λ _ → refl))) , makeIsGroupHom λ _ _ → refl) (GroupEquivDirProd (GroupIso→GroupEquiv (invGroupIso (Hⁿ-Unit≅0 _))) (GroupIso→GroupEquiv (invGroupIso (Hⁿ-Sᵐ≅0 _ _ λ p → ¬lemHopf 0 ((λ _ → north) , refl) n (suc n) (cong (2 +ℕ_) (sym (+-suc n n)) ∙ p))))))) (Ms.Δ (suc (suc (n +ℕ suc n)))) (Ms.d (suc (suc (n +ℕ suc n)))) (Ms.i (suc (suc (suc (n +ℕ suc n))))) (Ms.Ker-d⊂Im-Δ _) (Ms.Ker-i⊂Im-d _) snd fstIso = Ms.d (suc (suc (n +ℕ suc n))) .snd module _ (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) where C·Π' = C·Π n f g -- The generators of the cohomology groups of C* and C·Π βₗ : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g) βₗ = Iso.inv (fst (H⁴-C* n f g)) (1 , 0) βᵣ : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g) βᵣ = Iso.inv (fst (H⁴-C* n f g)) (0 , 1) β·Π : coHom ((2 +ℕ n) +' (2 +ℕ n)) C·Π' β·Π = Iso.inv (fst (H⁴-C·Π n f g)) 1 α* : coHom (2 +ℕ n) (C* n f g) α* = Iso.inv (fst (H²C*≅ℤ n f g)) 1 -- They can be difficult to work with in this form. -- We give them simpler forms and prove that these are equivalent βᵣ'-fun : C* n f g → coHomK ((4 +ℕ (n +ℕ n))) βᵣ'-fun (inl x) = 0ₖ _ βᵣ'-fun (inr x) = 0ₖ _ βᵣ'-fun (push (inl x) i₁) = 0ₖ _ βᵣ'-fun (push (inr x) i₁) = Kn→ΩKn+1 _ ∣ x ∣ i₁ βᵣ'-fun (push (push a i₂) i₁) = Kn→ΩKn+10ₖ _ (~ i₂) i₁ βₗ'-fun : C* n f g → coHomK (4 +ℕ (n +ℕ n)) βₗ'-fun (inl x) = 0ₖ _ βₗ'-fun (inr x) = 0ₖ _ βₗ'-fun (push (inl x) i₁) = Kn→ΩKn+1 _ ∣ x ∣ i₁ βₗ'-fun (push (inr x) i₁) = 0ₖ _ βₗ'-fun (push (push a i₂) i₁) = Kn→ΩKn+10ₖ _ i₂ i₁ βₗ''-fun : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g) βₗ''-fun = subst (λ m → coHom m (C* n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∣ βₗ'-fun ∣₂ βᵣ''-fun : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g) βᵣ''-fun = subst (λ m → coHom m (C* n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∣ βᵣ'-fun ∣₂ private 0ₖ≡∨→ : (a : _) → 0ₖ (suc (suc n)) ≡ ∣ (f ∨→ g) a ∣ 0ₖ≡∨→ = WedgeElim _ (λ _ → isOfHLevelTrunc (4 +ℕ n) _ _) (cong ∣_∣ₕ (sym (snd f))) 0ₖ≡∨→-inr : 0ₖ≡∨→ (inr north) ≡ cong ∣_∣ₕ (sym (snd g)) 0ₖ≡∨→-inr = (λ j → transport (λ i → 0ₖ (2 +ℕ n) ≡ ∣ compPath-filler' (snd f) (sym (snd g)) (~ j) i ∣ₕ) λ i → ∣ snd f (~ i ∨ j) ∣ₕ) ∙ λ j → transp (λ i → 0ₖ (2 +ℕ n) ≡ ∣ snd g (~ i ∧ ~ j) ∣ₕ) j λ i → ∣ snd g (~ i ∨ ~ j) ∣ₕ α*'-fun : C* n f g → coHomK (2 +ℕ n) α*'-fun (inl x) = 0ₖ _ α*'-fun (inr x) = ∣ x ∣ α*'-fun (push a i₁) = 0ₖ≡∨→ a i₁ α*' : coHom (2 +ℕ n) (C* n f g) α*' = ∣ α*'-fun ∣₂ -- We also need the following three maps jₗ : HopfInvariantPush n (fst f) → C* n f g jₗ (inl x) = inl x jₗ (inr x) = inr x jₗ (push a i₁) = push (inl a) i₁ jᵣ : HopfInvariantPush n (fst g) → C* n f g jᵣ (inl x) = inl x jᵣ (inr x) = inr x jᵣ (push a i₁) = push (inr a) i₁ q : C·Π' → C* n f g q (inl x) = inl x q (inr x) = inr x q (push a i₁) = (push (θ a) ∙ λ i → inr (∙Π≡∨→∘θ n f g a (~ i))) i₁ α↦1 : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → Iso.fun (fst (H²C*≅ℤ n f g)) (α*' n f g) ≡ 1 α↦1 n f g = sym (cong (Iso.fun (fst (Hⁿ-Sⁿ≅ℤ (suc n)))) (Hⁿ-Sⁿ≅ℤ-nice-generator n)) ∙ Iso.rightInv (fst (Hⁿ-Sⁿ≅ℤ (suc n))) (pos 1) α≡ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → α* n f g ≡ α*' n f g α≡ n f g = sym (Iso.leftInv (fst (H²C*≅ℤ n f g)) _) ∙∙ cong (Iso.inv (fst (H²C*≅ℤ n f g))) lem ∙∙ Iso.leftInv (fst (H²C*≅ℤ n f g)) _ where lem : Iso.fun (fst (H²C*≅ℤ n f g)) (α* n f g) ≡ Iso.fun (fst (H²C*≅ℤ n f g)) (α*' n f g) lem = (Iso.rightInv (fst (H²C*≅ℤ n f g)) (pos 1)) ∙ sym (α↦1 n f g) q-α : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (q n f g) (α* n f g) ≡ Hopfα n (∙Π f g) q-α n f g = (λ i → coHomFun _ (q n f g) (α≡ n f g i)) ∙ sym (Iso.leftInv is _) ∙∙ cong (Iso.inv is) lem ∙∙ Iso.leftInv is _ where is = fst (Hopfα-Iso n (∙Π f g)) lem : Iso.fun is (coHomFun _ (q n f g) (α*' n f g)) ≡ Iso.fun is (Hopfα n (∙Π f g)) lem = sym (cong (Iso.fun (fst (Hⁿ-Sⁿ≅ℤ (suc n)))) (Hⁿ-Sⁿ≅ℤ-nice-generator n)) ∙∙ Iso.rightInv (fst (Hⁿ-Sⁿ≅ℤ (suc n))) (pos 1) ∙∙ sym (Hopfα-Iso-α n (∙Π f g)) βₗ≡ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → βₗ n f g ≡ βₗ''-fun n f g βₗ≡ n f g = cong (∨-d ∘ subber₂) (cong (Iso.inv (fst ((Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n))))) (S₊∙ (suc (suc (suc (n +ℕ n))))) (((suc (suc (n +ℕ n))))))))) help ∙ lem) ∙ funExt⁻ ∨-d∘subber ∣ wedgeGen ∣₂ ∙ cong subber₃ (sym βₗ'-fun≡) where ∨-d = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (n +ℕ suc n))) .fst ∨-d' = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (suc (n +ℕ n)))) .fst help : Iso.inv (fst (GroupIsoDirProd (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))) (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))))) (1 , 0) ≡ (∣ ∣_∣ ∣₂ , 0ₕ _) help = ΣPathP ((Hⁿ-Sⁿ≅ℤ-nice-generator _) , IsGroupHom.pres1 (snd (invGroupIso (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n))))))) subber₃ = subst (λ m → coHom m (C* n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) subber₂ = (subst (λ m → coHom m (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n)))))) (sym (cong (2 +ℕ_) (+-suc n n)))) ∨-d∘subber : ∨-d ∘ subber₂ ≡ subber₃ ∘ ∨-d' ∨-d∘subber = funExt (λ a → (λ j → transp (λ i → coHom ((suc ∘ suc ∘ suc) (+-suc n n (~ i ∧ j))) (C* n f g)) (~ j) (MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (+-suc n n j))) .fst (transp (λ i → coHom (2 +ℕ (+-suc n n (j ∨ ~ i))) (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n)))))) j a)))) wedgeGen : (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n)))) → coHomK (suc (suc (suc (n +ℕ n))))) wedgeGen (inl x) = ∣ x ∣ wedgeGen (inr x) = 0ₖ _ wedgeGen (push a i₁) = 0ₖ _ βₗ'-fun≡ : ∣ βₗ'-fun n f g ∣₂ ≡ ∨-d' ∣ wedgeGen ∣₂ βₗ'-fun≡ = cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push (inl x) i₁) → refl ; (push (inr x) i₁) j → Kn→ΩKn+10ₖ _ (~ j) i₁ ; (push (push a i₂) i₁) j → Kn→ΩKn+10ₖ _ (~ j ∧ i₂) i₁}) lem : Iso.inv (fst (Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n))))) (S₊∙ (suc (suc (suc (n +ℕ n))))) (((suc (suc (n +ℕ n))))))) (∣ ∣_∣ ∣₂ , 0ₕ _) ≡ ∣ wedgeGen ∣₂ lem = cong ∣_∣₂ (funExt λ { (inl x) → rUnitₖ (suc (suc (suc (n +ℕ n)))) ∣ x ∣ ; (inr x) → refl ; (push a i₁) → refl}) βᵣ≡ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → βᵣ n f g ≡ βᵣ''-fun n f g βᵣ≡ n f g = cong (∨-d ∘ subber₂) (cong (Iso.inv (fst (Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n))))) (S₊∙ (suc (suc (suc (n +ℕ n))))) (suc (suc (n +ℕ n)))))) help ∙ lem) ∙ funExt⁻ ∨-d∘subber ∣ wedgeGen ∣₂ ∙ cong (subber₃) (sym βᵣ'-fun≡) where ∨-d = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (n +ℕ suc n))) .fst ∨-d' = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (suc (n +ℕ n)))) .fst help : Iso.inv (fst (GroupIsoDirProd (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))) (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))))) (0 , 1) ≡ (0ₕ _ , ∣ ∣_∣ ∣₂) help = ΣPathP (IsGroupHom.pres1 (snd (invGroupIso (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))))) , (Hⁿ-Sⁿ≅ℤ-nice-generator _)) subber₃ = subst (λ m → coHom m (C* n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) subber₂ = (subst (λ m → coHom m (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n)))))) (sym (cong (2 +ℕ_) (+-suc n n)))) ∨-d∘subber : ∨-d ∘ subber₂ ≡ subber₃ ∘ ∨-d' ∨-d∘subber = funExt (λ a → (λ j → transp (λ i → coHom ((suc ∘ suc ∘ suc) (+-suc n n (~ i ∧ j))) (C* n f g)) (~ j) (MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (+-suc n n j))) .fst (transp (λ i → coHom (2 +ℕ (+-suc n n (j ∨ ~ i))) (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n)))))) j a)))) wedgeGen : (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n)))) → coHomK (suc (suc (suc (n +ℕ n))))) wedgeGen (inl x) = 0ₖ _ wedgeGen (inr x) = ∣ x ∣ wedgeGen (push a i₁) = 0ₖ _ lem : Iso.inv (fst ((Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n))))) (S₊∙ (suc (suc (suc (n +ℕ n))))) (suc (suc (n +ℕ n)))))) (0ₕ _ , ∣ ∣_∣ ∣₂) ≡ ∣ wedgeGen ∣₂ lem = cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → lUnitₖ (suc (suc (suc (n +ℕ n)))) ∣ x ∣ ; (push a i₁) → refl}) βᵣ'-fun≡ : ∣ βᵣ'-fun n f g ∣₂ ≡ ∨-d' ∣ wedgeGen ∣₂ βᵣ'-fun≡ = cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push (inl x) i₁) j → Kn→ΩKn+10ₖ _ (~ j) i₁ ; (push (inr x) i₁) → refl ; (push (push a i₂) i₁) j → Kn→ΩKn+10ₖ _ (~ j ∧ ~ i₂) i₁}) q-βₗ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (q n f g) (βₗ n f g) ≡ β·Π n f g q-βₗ n f g = cong (coHomFun _ (q n f g)) (βₗ≡ n f g) ∙ transportLem ∙ cong (subst (λ m → coHom m (C·Π' n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) (sym (Iso.leftInv (fst (Hopfβ-Iso n (∙Π f g))) (Hopfβ n (∙Π f g))) ∙ cong (Iso.inv ((fst (Hopfβ-Iso n (∙Π f g))))) (Hopfβ↦1 n (∙Π f g))) where transportLem : coHomFun (suc (suc (suc (n +ℕ suc n)))) (q n f g) (βₗ''-fun n f g) ≡ subst (λ m → coHom m (C·Π' n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) (Hopfβ n (∙Π f g)) transportLem = natTranspLem ∣ βₗ'-fun n f g ∣₂ (λ m → coHomFun m (q n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∙ cong (subst (λ m → coHom m (C·Π' n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) (cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push a i₁) → push-lem a i₁})) where push-lem : (x : fst (S₊∙ (3 +ℕ (n +ℕ n)))) → PathP (λ i₁ → βₗ'-fun n f g ((push (θ x) ∙ λ i → inr (∙Π≡∨→∘θ n f g x (~ i))) i₁) ≡ MV.d-pre Unit (fst (S₊∙ (2 +ℕ n))) (fst (S₊∙ (3 +ℕ n +ℕ n))) (λ _ → tt) (fst (∙Π f g)) (3 +ℕ n +ℕ n) ∣_∣ (push x i₁)) (λ _ → βₗ'-fun n f g (q n f g (inl tt))) (λ _ → βₗ'-fun n f g (q n f g (inr (∙Π f g .fst x)))) push-lem x = flipSquare (cong-∙ (βₗ'-fun n f g) (push (θ x)) (λ i → inr (∙Π≡∨→∘θ n f g x (~ i))) ∙∙ sym (rUnit _) ∙∙ lem₁ x) where lem₁ : (x : _) → cong (βₗ'-fun n f g) (push (θ {A = S₊∙ _} x)) ≡ Kn→ΩKn+1 _ ∣ x ∣ lem₁ north = refl lem₁ south = sym (Kn→ΩKn+10ₖ _) ∙ cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n))))) (cong ∣_∣ₕ (merid north)) lem₁ (merid a j) k = merid-lem k j where p = pt (S₊∙ (suc (suc (n +ℕ n)))) merid-lem : PathP (λ k → Kn→ΩKn+1 _ ∣ north ∣ₕ ≡ (sym (Kn→ΩKn+10ₖ _) ∙ cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n))))) (cong ∣_∣ₕ (merid north))) k) (λ j → cong (βₗ'-fun n f g) (push (θ {A = S₊∙ _} (merid a j)))) (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a)) merid-lem = (cong-∙∙ (cong (βₗ'-fun n f g) ∘ push) (λ i₁ → inl ((merid a ∙ (sym (merid p))) i₁)) (push tt) ((λ i₁ → inr ((merid a ∙ (sym (merid p))) i₁))) ∙ sym (compPath≡compPath' _ _) ∙ cong (_∙ Kn→ΩKn+10ₖ _) (cong-∙ ((Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ)) (merid a) (sym (merid north))) ∙ sym (assoc _ _ _) ∙ cong (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a) ∙_) (sym (symDistr (sym ((Kn→ΩKn+10ₖ _))) (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n))))) (cong ∣_∣ₕ (merid north)))))) ◁ λ i j → compPath-filler (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a)) (sym (sym (Kn→ΩKn+10ₖ _) ∙ cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n))))) (cong ∣_∣ₕ (merid north)))) (~ i) j q-βᵣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (q n f g) (βᵣ n f g) ≡ β·Π n f g q-βᵣ n f g = cong (coHomFun _ (q n f g)) (βᵣ≡ n f g) ∙ transportLem ∙ cong (subst (λ m → coHom m (C·Π' n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) (sym (Iso.leftInv (fst (Hopfβ-Iso n (∙Π f g))) (Hopfβ n (∙Π f g))) ∙ cong (Iso.inv ((fst (Hopfβ-Iso n (∙Π f g))))) (Hopfβ↦1 n (∙Π f g))) where transportLem : coHomFun (suc (suc (suc (n +ℕ suc n)))) (q n f g) (βᵣ''-fun n f g) ≡ subst (λ m → coHom m (C·Π' n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) (Hopfβ n (∙Π f g)) transportLem = natTranspLem ∣ βᵣ'-fun n f g ∣₂ (λ m → coHomFun m (q n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∙ cong (subst (λ m → coHom m (C·Π' n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) (cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push a i₁) → push-lem a i₁})) where push-lem : (x : fst (S₊∙ (3 +ℕ (n +ℕ n)))) → PathP (λ i₁ → βᵣ'-fun n f g ((push (θ x) ∙ λ i → inr (∙Π≡∨→∘θ n f g x (~ i))) i₁) ≡ MV.d-pre Unit (fst (S₊∙ (2 +ℕ n))) (fst (S₊∙ (3 +ℕ n +ℕ n))) (λ _ → tt) (fst (∙Π f g)) (3 +ℕ n +ℕ n) ∣_∣ (push x i₁)) (λ _ → βᵣ'-fun n f g (q n f g (inl tt))) (λ _ → βᵣ'-fun n f g (q n f g (inr (∙Π f g .fst x)))) push-lem x = flipSquare (cong-∙ (βᵣ'-fun n f g) (push (θ x)) (λ i → inr (∙Π≡∨→∘θ n f g x (~ i))) ∙∙ sym (rUnit _) ∙∙ lem₁ x) where lem₁ : (x : _) → cong (βᵣ'-fun n f g) (push (θ {A = S₊∙ _} x)) ≡ Kn→ΩKn+1 _ ∣ x ∣ lem₁ north = sym (Kn→ΩKn+10ₖ _) lem₁ south = cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n))))) (cong ∣_∣ₕ (merid north)) lem₁ (merid a j) k = merid-lem k j where p = pt (S₊∙ (suc (suc (n +ℕ n)))) merid-lem : PathP (λ k → (Kn→ΩKn+10ₖ _) (~ k) ≡ (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n))))) (cong ∣_∣ₕ (merid north))) k) (λ j → cong (βᵣ'-fun n f g) (push (θ {A = S₊∙ _} (merid a j)))) (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a)) merid-lem = (cong-∙∙ (cong (βᵣ'-fun n f g) ∘ push) (λ i₁ → inl ((merid a ∙ (sym (merid p))) i₁)) (push tt) (λ i₁ → inr ((merid a ∙ (sym (merid p))) i₁)) ∙∙ (cong (sym (Kn→ΩKn+10ₖ _) ∙_) (cong-∙ (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a) (sym (merid (ptSn _))))) ∙∙ sym (doubleCompPath≡compPath _ _ _)) ◁ symP (doubleCompPath-filler (sym (Kn→ΩKn+10ₖ _)) (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a)) (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (sym (merid north)))) jₗ-α : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (jₗ n f g) (α* n f g) ≡ Hopfα n f jₗ-α n f g = cong (coHomFun _ (jₗ n f g)) (α≡ n f g) ∙ cong ∣_∣₂ (funExt (HopfInvariantPushElim n (fst f) (isOfHLevelPath ((suc (suc (suc (suc (n +ℕ n)))))) (isOfHLevelPlus' {n = n} (4 +ℕ n) (isOfHLevelTrunc (4 +ℕ n))) _ _) refl (λ _ → refl) λ j → refl)) jₗ-βₗ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (jₗ n f g) (βₗ n f g) ≡ subst (λ m → coHom m (HopfInvariantPush n (fst f))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) (Hopfβ n f) jₗ-βₗ n f g = cong (coHomFun _ (jₗ n f g)) (βₗ≡ n f g) ∙∙ natTranspLem ∣ βₗ'-fun n f g ∣₂ (λ m → coHomFun m (jₗ n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst f))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) (cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push a i₁) → refl})) jₗ-βᵣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (jₗ n f g) (βᵣ n f g) ≡ 0ₕ _ jₗ-βᵣ n f g = cong (coHomFun _ (jₗ n f g)) (βᵣ≡ n f g) ∙∙ natTranspLem ∣ βᵣ'-fun n f g ∣₂ (λ m → coHomFun m (jₗ n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst f))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) cool where cool : coHomFun (suc (suc (suc (suc (n +ℕ n))))) (jₗ n f g) ∣ βᵣ'-fun n f g ∣₂ ≡ 0ₕ _ cool = cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push a i₁) → refl}) jᵣ-α : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (jᵣ n f g) (α* n f g) ≡ Hopfα n g jᵣ-α n f g = cong (coHomFun _ (jᵣ n f g)) (α≡ n f g) ∙ cong ∣_∣₂ (funExt (HopfInvariantPushElim n (fst g) (isOfHLevelPath ((suc (suc (suc (suc (n +ℕ n)))))) (isOfHLevelPlus' {n = n} (4 +ℕ n) (isOfHLevelTrunc (4 +ℕ n))) _ _) refl (λ _ → refl) (flipSquare (0ₖ≡∨→-inr n f g)))) jᵣ-βₗ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (jᵣ n f g) (βₗ n f g) ≡ 0ₕ _ jᵣ-βₗ n f g = cong (coHomFun _ (jᵣ n f g)) (βₗ≡ n f g) ∙∙ natTranspLem ∣ βₗ'-fun n f g ∣₂ (λ m → coHomFun m (jᵣ n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst f))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) cool where cool : coHomFun (suc (suc (suc (suc (n +ℕ n))))) (jᵣ n f g) ∣ βₗ'-fun n f g ∣₂ ≡ 0ₕ _ cool = cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push a i₁) → refl}) jᵣ-βᵣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → coHomFun _ (jᵣ n f g) (βᵣ n f g) ≡ subst (λ m → coHom m (HopfInvariantPush n (fst g))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) (Hopfβ n g) jᵣ-βᵣ n f g = cong (coHomFun _ (jᵣ n f g)) (βᵣ≡ n f g) ∙∙ natTranspLem ∣ βᵣ'-fun n f g ∣₂ (λ m → coHomFun m (jᵣ n f g)) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) ∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst g))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))) (cong ∣_∣₂ (funExt λ { (inl x) → refl ; (inr x) → refl ; (push a i₁) → refl})) genH²ⁿC* : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → gen₂-by (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)) (βₗ n f g) (βᵣ n f g) genH²ⁿC* n f g = Iso-pres-gen₂ (DirProd ℤGroup ℤGroup) (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)) (1 , 0) (0 , 1) gen₂ℤ×ℤ (invGroupIso (H⁴-C* n f g)) private H⁴C* : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → Group _ H⁴C* n f g = coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g) X : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → ℤ X n f g = (genH²ⁿC* n f g) (α* n f g ⌣ α* n f g) .fst .fst Y : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → ℤ Y n f g = (genH²ⁿC* n f g) (α* n f g ⌣ α* n f g) .fst .snd α*≡⌣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → α* n f g ⌣ α* n f g ≡ ((X n f g) ℤ[ H⁴C* n f g ]· βₗ n f g) +ₕ ((Y n f g) ℤ[ H⁴C* n f g ]· βᵣ n f g) α*≡⌣ n f g = (genH²ⁿC* n f g) (α* n f g ⌣ α* n f g) .snd coHomFun⌣ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) → (n : ℕ) (x y : coHom n B) → coHomFun _ f (x ⌣ y) ≡ coHomFun _ f x ⌣ coHomFun _ f y coHomFun⌣ f n = sElim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _) λ _ _ → refl isHom-HopfInvariant : (n : ℕ) (f g : S₊∙ (suc (suc (suc (n +ℕ n)))) →∙ S₊∙ (suc (suc n))) → HopfInvariant n (∙Π f g) ≡ HopfInvariant n f + HopfInvariant n g isHom-HopfInvariant n f g = mainL ∙ sym (cong₂ _+_ f-id g-id) where eq₁ : (Hopfα n (∙Π f g)) ⌣ (Hopfα n (∙Π f g)) ≡ ((X n f g + Y n f g) ℤ[ coHomGr _ _ ]· (β·Π n f g)) eq₁ = cong (λ x → x ⌣ x) (sym (q-α n f g) ∙ cong (coHomFun (suc (suc n)) (q n f g)) (α≡ n f g)) ∙ cong ((coHomFun _) (q _ f g)) (cong (λ x → x ⌣ x) (sym (α≡ n f g)) ∙ α*≡⌣ n f g) ∙ IsGroupHom.pres· (coHomMorph _ (q n f g) .snd) _ _ ∙ cong₂ _+ₕ_ (homPresℤ· (coHomMorph _ (q n f g)) (βₗ n f g) (X n f g) ∙ cong (λ z → (X n f g) ℤ[ coHomGr _ _ ]· z) (q-βₗ n f g)) (homPresℤ· (coHomMorph _ (q n f g)) (βᵣ n f g) (Y n f g) ∙ cong (λ z → (Y n f g) ℤ[ coHomGr _ _ ]· z) (q-βᵣ n f g)) ∙ sym (distrℤ· (coHomGr _ _) (β·Π n f g) (X n f g) (Y n f g)) eq₂ : Hopfα n f ⌣ Hopfα n f ≡ (X n f g ℤ[ coHomGr _ _ ]· subst (λ m → coHom m (HopfInvariantPush n (fst f))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) (Hopfβ n f)) eq₂ = cong (λ x → x ⌣ x) (sym (jₗ-α n f g)) ∙∙ sym (coHomFun⌣ (jₗ n f g) _ _ _) ∙∙ cong (coHomFun _ (jₗ n f g)) (α*≡⌣ n f g) ∙∙ IsGroupHom.pres· (snd (coHomMorph _ (jₗ n f g))) _ _ ∙∙ cong₂ _+ₕ_ (homPresℤ· (coHomMorph _ (jₗ n f g)) (βₗ n f g) (X n f g)) (homPresℤ· (coHomMorph _ (jₗ n f g)) (βᵣ n f g) (Y n f g) ∙ cong (λ z → (Y n f g) ℤ[ coHomGr _ _ ]· z) (jₗ-βᵣ n f g)) ∙∙ cong₂ _+ₕ_ refl (rUnitℤ· (coHomGr _ _) (Y n f g)) ∙∙ (rUnitₕ _ _ ∙ cong (X n f g ℤ[ coHomGr _ _ ]·_) (jₗ-βₗ n f g)) eq₃ : Hopfα n g ⌣ Hopfα n g ≡ (Y n f g ℤ[ coHomGr _ _ ]· subst (λ m → coHom m (HopfInvariantPush n (fst f))) (cong (suc ∘ suc ∘ suc) (sym (+-suc n n))) (Hopfβ n g)) eq₃ = cong (λ x → x ⌣ x) (sym (jᵣ-α n f g)) ∙∙ sym (coHomFun⌣ (jᵣ n f g) _ _ _) ∙∙ cong (coHomFun _ (jᵣ n f g)) (α*≡⌣ n f g) ∙∙ IsGroupHom.pres· (snd (coHomMorph _ (jᵣ n f g))) _ _ ∙∙ cong₂ _+ₕ_ (homPresℤ· (coHomMorph _ (jᵣ n f g)) (βₗ n f g) (X n f g) ∙ cong (λ z → (X n f g) ℤ[ coHomGr _ _ ]· z) (jᵣ-βₗ n f g)) (homPresℤ· (coHomMorph _ (jᵣ n f g)) (βᵣ n f g) (Y n f g)) ∙∙ cong₂ _+ₕ_ (rUnitℤ· (coHomGr _ _) (X n f g)) refl ∙∙ ((lUnitₕ _ _) ∙ cong (Y n f g ℤ[ coHomGr _ _ ]·_) (jᵣ-βᵣ n f g)) transpLem : ∀ {ℓ} {G : ℕ → Group ℓ} (n m : ℕ) (x : ℤ) (p : m ≡ n) (g : fst (G n)) → subst (fst ∘ G) p (x ℤ[ G m ]· subst (fst ∘ G) (sym p) g) ≡ (x ℤ[ G n ]· g) transpLem {G = G} n m x = J (λ n p → (g : fst (G n)) → subst (fst ∘ G) p (x ℤ[ G m ]· subst (fst ∘ G) (sym p) g) ≡ (x ℤ[ G n ]· g)) λ g → transportRefl _ ∙ cong (x ℤ[ G m ]·_) (transportRefl _) mainL : HopfInvariant n (∙Π f g) ≡ X n f g + Y n f g mainL = cong (Iso.fun (fst (Hopfβ-Iso n (∙Π f g)))) (cong (subst (λ x → coHom x (HopfInvariantPush n (fst (∙Π f g)))) λ i₁ → suc (suc (suc (+-suc n n i₁)))) eq₁) ∙∙ cong (Iso.fun (fst (Hopfβ-Iso n (∙Π f g)))) (transpLem {G = λ x → coHomGr x (HopfInvariantPush n (fst (∙Π f g)))} _ _ (X n f g + Y n f g) (λ i₁ → suc (suc (suc (+-suc n n i₁)))) (Iso.inv (fst (Hopfβ-Iso n (∙Π f g))) 1)) ∙∙ homPresℤ· (_ , snd (Hopfβ-Iso n (∙Π f g))) (Iso.inv (fst (Hopfβ-Iso n (∙Π f g))) 1) (X n f g + Y n f g) ∙∙ cong ((X n f g + Y n f g) ℤ[ ℤ , ℤGroup .snd ]·_) (Iso.rightInv ((fst (Hopfβ-Iso n (∙Π f g)))) 1) ∙∙ rUnitℤ·ℤ (X n f g + Y n f g) f-id : HopfInvariant n f ≡ X n f g f-id = cong (Iso.fun (fst (Hopfβ-Iso n f))) (cong (subst (λ x → coHom x (HopfInvariantPush n (fst f))) (λ i₁ → suc (suc (suc (+-suc n n i₁))))) eq₂) ∙ cong (Iso.fun (fst (Hopfβ-Iso n f))) (transpLem {G = λ x → coHomGr x (HopfInvariantPush n (fst f))} _ _ (X n f g) ((cong (suc ∘ suc ∘ suc) (+-suc n n))) (Hopfβ n f)) ∙ homPresℤ· (_ , snd (Hopfβ-Iso n f)) (Hopfβ n f) (X n f g) ∙ cong (X n f g ℤ[ ℤ , ℤGroup .snd ]·_) (Hopfβ↦1 n f) ∙ rUnitℤ·ℤ (X n f g) g-id : HopfInvariant n g ≡ Y n f g g-id = cong (Iso.fun (fst (Hopfβ-Iso n g))) (cong (subst (λ x → coHom x (HopfInvariantPush n (fst g))) (λ i₁ → suc (suc (suc (+-suc n n i₁))))) eq₃) ∙∙ cong (Iso.fun (fst (Hopfβ-Iso n g))) (transpLem {G = λ x → coHomGr x (HopfInvariantPush n (fst g))} _ _ (Y n f g) ((cong (suc ∘ suc ∘ suc) (+-suc n n))) (Hopfβ n g)) ∙∙ homPresℤ· (_ , snd (Hopfβ-Iso n g)) (Hopfβ n g) (Y n f g) ∙∙ cong (Y n f g ℤ[ ℤ , ℤGroup .snd ]·_) (Hopfβ↦1 n g) ∙∙ rUnitℤ·ℤ (Y n f g) GroupHom-HopfInvariant-π' : (n : ℕ) → GroupHom (π'Gr (suc (suc (n +ℕ n))) (S₊∙ (suc (suc n)))) ℤGroup fst (GroupHom-HopfInvariant-π' n) = HopfInvariant-π' n snd (GroupHom-HopfInvariant-π' n) = makeIsGroupHom (sElim2 (λ _ _ → isOfHLevelPath 2 isSetℤ _ _) (isHom-HopfInvariant n)) GroupHom-HopfInvariant-π : (n : ℕ) → GroupHom (πGr (suc (suc (n +ℕ n))) (S₊∙ (suc (suc n)))) ℤGroup fst (GroupHom-HopfInvariant-π n) = HopfInvariant-π n snd (GroupHom-HopfInvariant-π n) = makeIsGroupHom (sElim2 (λ _ _ → isOfHLevelPath 2 isSetℤ _ _) λ p q → cong (HopfInvariant-π' n) (IsGroupHom.pres· (snd (invGroupIso (π'Gr≅πGr (suc (suc (n +ℕ n))) (S₊∙ (suc (suc n)))))) ∣ p ∣₂ ∣ q ∣₂) ∙ IsGroupHom.pres· (GroupHom-HopfInvariant-π' n .snd) ∣ Ω→SphereMap _ p ∣₂ ∣ Ω→SphereMap _ q ∣₂)
{ "alphanum_fraction": 0.4230851177, "avg_line_length": 42.1414141414, "ext": "agda", "hexsha": "aee1e99477314dc879ce77a3b505caa326adaa32", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Homotopy/HopfInvariant/Homomorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Homotopy/HopfInvariant/Homomorphism.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Homotopy/HopfInvariant/Homomorphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 16811, "size": 37548 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.types.Paths open import lib.types.Pi open import lib.types.Sigma module lib.types.Pointed where Ptd : ∀ i → Type (lsucc i) Ptd i = Σ (Type i) (λ A → A) Ptd₀ = Ptd lzero ⊙[_,_] : ∀ {i} (A : Type i) (a : A) → Ptd i ⊙[_,_] = _,_ _⊙→_ : ∀ {i j} → Ptd i → Ptd j → Ptd (lmax i j) (A , a₀) ⊙→ (B , b₀) = ⊙[ Σ (A → B) (λ f → f a₀ == b₀) , ((λ _ → b₀), idp) ] infixr 0 _⊙→_ _⊙×_ : ∀ {i j} → Ptd i → Ptd j → Ptd (lmax i j) (A , a₀) ⊙× (B , b₀) = (A × B , (a₀ , b₀)) ⊙fst : ∀ {i j} {X : Ptd i} {Y : Ptd j} → fst (X ⊙× Y ⊙→ X) ⊙fst = (fst , idp) ⊙snd : ∀ {i j} {X : Ptd i} {Y : Ptd j} → fst (X ⊙× Y ⊙→ Y) ⊙snd = (snd , idp) ⊙diag : ∀ {i} {X : Ptd i} → fst (X ⊙→ X ⊙× X) ⊙diag = ((λ x → (x , x)) , idp) pair⊙→ : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} → fst (X ⊙→ Y) → fst (Z ⊙→ W) → fst ((X ⊙× Z) ⊙→ (Y ⊙× W)) pair⊙→ (f , fpt) (g , gpt) = ((λ {(x , z) → (f x , g z)}) , pair×= fpt gpt) infixr 4 _⊙∘_ ⊙idf : ∀ {i} (X : Ptd i) → fst (X ⊙→ X) ⊙idf A = ((λ x → x) , idp) ⊙cst : ∀ {i j} {X : Ptd i} {Y : Ptd j} → fst (X ⊙→ Y) ⊙cst {Y = Y} = ((λ x → snd Y) , idp) _⊙∘_ : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y)) → fst (X ⊙→ Z) (g , gpt) ⊙∘ (f , fpt) = (g ∘ f) , (ap g fpt ∙ gpt) ⊙∘-unit-l : ∀ {i j} {X : Ptd i} {Y : Ptd j} (f : fst (X ⊙→ Y)) → ⊙idf Y ⊙∘ f == f ⊙∘-unit-l (f , idp) = idp ⊙∘-assoc : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (h : fst (Z ⊙→ W)) (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y)) → ((h ⊙∘ g) ⊙∘ f) == (h ⊙∘ (g ⊙∘ f)) ⊙∘-assoc (h , hpt) (g , gpt) (f , fpt) = pair= idp (lemma fpt gpt hpt) where lemma : ∀ {x₁ x₂} (fpt : x₁ == x₂) → ∀ gpt → ∀ hpt → ap (h ∘ g) fpt ∙ ap h gpt ∙ hpt == ap h (ap g fpt ∙ gpt) ∙ hpt lemma idp gpt hpt = idp {- Obtaining equality of pointed types from an equivalence -} ⊙ua : ∀ {i} {A B : Type i} {a₀ : A} {b₀ : B} (e : A ≃ B) → –> e a₀ == b₀ → ⊙[ A , a₀ ] == ⊙[ B , b₀ ] ⊙ua e p = pair= (ua e) (↓-idf-ua-in e p) {- ⊙→ preserves hlevel -} ⊙→-level : ∀ {i j} {X : Ptd i} {Y : Ptd j} {n : ℕ₋₂} → has-level n (fst Y) → has-level n (fst (X ⊙→ Y)) ⊙→-level pY = Σ-level (Π-level (λ _ → pY)) (λ _ → =-preserves-level _ pY) {- function extensionality for pointed functions -} ⊙λ= : ∀ {i j} {X : Ptd i} {Y : Ptd j} {f g : fst (X ⊙→ Y)} (p : ∀ x → fst f x == fst g x) (α : snd f == p (snd X) ∙ snd g) → f == g ⊙λ= {g = g} p α = pair= (λ= p) (↓-app=cst-in (α ∙ ap (λ w → w ∙ snd g) (! (app=-β p _)))) {- Obtaining pointed maps from an pointed equivalence -} module _ {i j} {X : Ptd i} {Y : Ptd j} (e : fst X ≃ fst Y) (p : –> e (snd X) == snd Y) where ⊙–> : fst (X ⊙→ Y) ⊙–> = (–> e , p) ⊙<– : fst (Y ⊙→ X) ⊙<– = (<– e , ap (<– e) (! p) ∙ <–-inv-l e (snd X))
{ "alphanum_fraction": 0.4293381038, "avg_line_length": 30.3804347826, "ext": "agda", "hexsha": "afb5acb48cde4b1bfb251887003bde797155e45c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "lib/types/Pointed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "lib/types/Pointed.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "lib/types/Pointed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1495, "size": 2795 }
data D : Set where d : D foo : D foo = {!!} -- C-c C-r gives me a weird-looking '0'
{ "alphanum_fraction": 0.5340909091, "avg_line_length": 11, "ext": "agda", "hexsha": "c0fdafd21c44f6b15d4c12605cd20b2881a3a8d7", "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/Issue1892.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/Issue1892.agda", "max_line_length": 39, "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/Issue1892.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": 33, "size": 88 }
{-# OPTIONS --without-K --safe #-} -- Some of the obvious properties of cartesian functors module Categories.Functor.Cartesian.Properties where open import Data.Product using (_,_; proj₁; proj₂) open import Level open import Categories.Category.Core using (Category) open import Categories.Category.Cartesian open import Categories.Category.Product using (Product; _⁂_) open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Functor.Cartesian open import Categories.Morphism.Reasoning open import Categories.NaturalTransformation hiding (id) import Categories.Object.Product as OP private variable o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ : Level idF-Cartesian : {A : Category o ℓ e} {CA : Cartesian A} → CartesianF CA CA idF idF-Cartesian {A = A} {CA} = record { ε = id ; ⊗-homo = ntHelper record { η = λ _ → id ; commute = λ _ → id-comm-sym A } } where open Category A ∘-Cartesian : {A : Category o ℓ e} {B : Category o′ ℓ′ e′} {C : Category o″ ℓ″ e″} {CA : Cartesian A} {CB : Cartesian B} {CC : Cartesian C} {F : Functor B C} {G : Functor A B} (CF : CartesianF CB CC F) (CG : CartesianF CA CB G) → CartesianF CA CC (F ∘F G) ∘-Cartesian {B = B} {C} {CA} {CB} {CC} {F} {G} CF CG = record { ε = F.₁ CG.ε ∘ CF.ε ; ⊗-homo = ntHelper record { η = λ X → F.₁ (NTG.η X) ∘ NTF.η (Functor.F₀ (G ⁂ G) X) ; commute = λ { {A} {B} f → let GGA = F₀ (G ⁂ G) A in let GGB = F₀ (G ⁂ G) B in let GGf = F₁ (G ⁂ G) f in begin (F.₁ (NTG.η B) ∘ NTF.η GGB) ∘ F₁ (⊗ CC ∘F ((F ∘F G) ⁂ (F ∘F G))) f ≈⟨ C.assoc ⟩ F.₁ (NTG.η B) ∘ NTF.η GGB ∘ F₁ (⊗ CC ∘F ((F ∘F G) ⁂ (F ∘F G))) f ≈⟨ (refl⟩∘⟨ NTF.commute GGf) ⟩ F.₁ (NTG.η B) ∘ (F.₁ (F₁ (⊗ CB) GGf) ∘ NTF.η GGA) ≈⟨ C.sym-assoc ⟩ (F.₁ (NTG.η B) ∘ F.₁ (F₁ (⊗ CB) GGf)) ∘ NTF.η GGA ≈˘⟨ (F.homomorphism ⟩∘⟨refl) ⟩ (F.₁ (NTG.η B B.∘ F₁ (⊗ CB) GGf)) ∘ NTF.η GGA ≈⟨ (F.F-resp-≈ (NTG.commute f) ⟩∘⟨refl) ⟩ F.F₁ (F₁ G (F₁ (⊗ CA) f) B.∘ NTG.η A) ∘ NTF.η GGA ≈⟨ (F.homomorphism ⟩∘⟨refl) ⟩ (F₁ ((F ∘F G) ∘F ⊗ CA) f ∘ F.₁ (NTG.η A)) ∘ NTF.η GGA ≈⟨ C.assoc ⟩ F₁ ((F ∘F G) ∘F ⊗ CA) f ∘ F.₁ (NTG.η A) ∘ NTF.η GGA ∎} } } where module CF = CartesianF CF module CG = CartesianF CG module NTF = NaturalTransformation CF.⊗-homo module NTG = NaturalTransformation CG.⊗-homo module F = Functor F module B = Category B module C = Category C open C using (_≈_; _∘_) open C.HomReasoning open Cartesian CC using (products) open Functor open OP C using (Product) open Product open Cartesian using (⊗)
{ "alphanum_fraction": 0.5733033371, "avg_line_length": 38.652173913, "ext": "agda", "hexsha": "0d6893383c697469f9dcd04cb3b243c18e97045a", "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": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bond15/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Cartesian/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "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": "bond15/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Cartesian/Properties.agda", "max_line_length": 117, "max_stars_count": null, "max_stars_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bond15/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Cartesian/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1112, "size": 2667 }
-- Sometimes we can't infer a record type module InferRecordTypes-2 where record R : Set₁ where field x₁ : Set x₂ : Set bad = record { x₃ = Set }
{ "alphanum_fraction": 0.6582278481, "avg_line_length": 15.8, "ext": "agda", "hexsha": "e31aa222ad06b424c166699922f315dad3237ca2", "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": "test/fail/InferRecordTypes-2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/InferRecordTypes-2.agda", "max_line_length": 41, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/InferRecordTypes-2.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": 50, "size": 158 }