hexsha
stringlengths
40
40
size
int64
3
1.05M
ext
stringclasses
163 values
lang
stringclasses
53 values
max_stars_repo_path
stringlengths
3
945
max_stars_repo_name
stringlengths
4
112
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
945
max_issues_repo_name
stringlengths
4
113
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
116k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
945
max_forks_repo_name
stringlengths
4
113
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
3
1.05M
avg_line_length
float64
1
966k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
1e0ccb4ce3722891503c29f85cc6f4b4ce0c9d8d
2,688
agda
Agda
BasicIPC/Metatheory/Hilbert-KripkeConcreteGluedHilbert.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
29
2016-07-03T18:51:56.000Z
2022-01-01T10:29:18.000Z
BasicIPC/Metatheory/Hilbert-KripkeConcreteGluedHilbert.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
1
2018-06-10T09:11:22.000Z
2018-06-10T09:11:22.000Z
BasicIPC/Metatheory/Hilbert-KripkeConcreteGluedHilbert.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
null
null
null
module BasicIPC.Metatheory.Hilbert-KripkeConcreteGluedHilbert where open import BasicIPC.Syntax.Hilbert public open import BasicIPC.Semantics.KripkeConcreteGluedHilbert public -- Internalisation of syntax as syntax representation in a particular model. module _ {{_ : Model}} where [_] : ∀ {A Γ} → Γ ⊢ A → Γ [⊢] A [ var i ] = [var] i [ app t u ] = [app] [ t ] [ u ] [ ci ] = [ci] [ ck ] = [ck] [ cs ] = [cs] [ cpair ] = [cpair] [ cfst ] = [cfst] [ csnd ] = [csnd] [ unit ] = [unit] -- Soundness with respect to all models, or evaluation. eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A eval (var i) γ = lookup i γ eval (app t u) γ = eval t γ ⟪$⟫ eval u γ eval ci γ = [ci] ⅋ K I eval ck γ = [ck] ⅋ K ⟪K⟫ eval cs γ = [cs] ⅋ K ⟪S⟫′ eval cpair γ = [cpair] ⅋ K _⟪,⟫′_ eval cfst γ = [cfst] ⅋ K π₁ eval csnd γ = [csnd] ⅋ K π₂ eval unit γ = ∙ -- TODO: Correctness of evaluation with respect to conversion. -- The canonical model. private instance canon : Model canon = record { _⊩ᵅ_ = λ w P → unwrap w ⊢ α P ; mono⊩ᵅ = λ ξ t → mono⊢ (unwrap≤ ξ) t ; _[⊢]_ = _⊢_ ; mono[⊢] = mono⊢ ; [var] = var ; [app] = app ; [ci] = ci ; [ck] = ck ; [cs] = cs ; [cpair] = cpair ; [cfst] = cfst ; [csnd] = csnd ; [unit] = unit ; [lam] = lam } -- Soundness and completeness with respect to the canonical model. mutual reflectᶜ : ∀ {A w} → unwrap w ⊢ A → w ⊩ A reflectᶜ {α P} t = t ⅋ t reflectᶜ {A ▻ B} t = t ⅋ λ ξ a → reflectᶜ (app (mono⊢ (unwrap≤ ξ) t) (reifyᶜ a)) reflectᶜ {A ∧ B} t = reflectᶜ (fst t) , reflectᶜ (snd t) reflectᶜ {⊤} t = ∙ reifyᶜ : ∀ {A w} → w ⊩ A → unwrap w ⊢ A reifyᶜ {α P} s = syn s reifyᶜ {A ▻ B} s = syn s reifyᶜ {A ∧ B} s = pair (reifyᶜ (π₁ s)) (reifyᶜ (π₂ s)) reifyᶜ {⊤} s = unit reflectᶜ⋆ : ∀ {Ξ w} → unwrap w ⊢⋆ Ξ → w ⊩⋆ Ξ reflectᶜ⋆ {∅} ∙ = ∙ reflectᶜ⋆ {Ξ , A} (ts , t) = reflectᶜ⋆ ts , reflectᶜ t reifyᶜ⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → unwrap w ⊢⋆ Ξ reifyᶜ⋆ {∅} ∙ = ∙ reifyᶜ⋆ {Ξ , A} (ts , t) = reifyᶜ⋆ ts , reifyᶜ t -- Reflexivity and transitivity. refl⊩⋆ : ∀ {w} → w ⊩⋆ unwrap w refl⊩⋆ = reflectᶜ⋆ refl⊢⋆ trans⊩⋆ : ∀ {w w′ w″} → w ⊩⋆ unwrap w′ → w′ ⊩⋆ unwrap w″ → w ⊩⋆ unwrap w″ trans⊩⋆ ts us = reflectᶜ⋆ (trans⊢⋆ (reifyᶜ⋆ ts) (reifyᶜ⋆ us)) -- Completeness with respect to all models, or quotation. quot : ∀ {A Γ} → Γ ⊨ A → Γ ⊢ A quot s = reifyᶜ (s refl⊩⋆) -- Normalisation by evaluation. norm : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ A norm = quot ∘ eval -- TODO: Correctness of normalisation with respect to conversion.
24.888889
82
0.514137
30693668f6ff0ac8a22ff5df17643f35f3d862b0
350
agda
Agda
test/Compiler/with-stdlib/DivMod.agda
andreasabel/agda-with-old-branches
04941fb75be06039b0085ab047117625294cbc99
[ "BSD-3-Clause" ]
3
2015-03-28T14:51:03.000Z
2015-12-07T20:14:00.000Z
test/Compiler/with-stdlib/DivMod.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
null
null
null
test/Compiler/with-stdlib/DivMod.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
1
2019-03-05T20:02:38.000Z
2019-03-05T20:02:38.000Z
module DivMod where open import IO open import Data.Nat open import Data.Nat.DivMod open import Coinduction open import Data.String open import Data.Fin g : ℕ g = 7 div 5 k : ℕ k = toℕ (7 mod 5) showNat : ℕ → String showNat zero = "Z" showNat (suc x) = "S (" ++ showNat x ++ ")" main = run (♯ (putStrLn (showNat g)) >> ♯ (putStrLn (showNat k)))
16.666667
65
0.66
35eac384da02ec395548d85b0d180fa801423d5e
17,731
agda
Agda
Cubical/Data/Fin/Properties.agda
knrafto/cubical
f6771617374bfe65a7043d00731fed5a673aa729
[ "MIT" ]
null
null
null
Cubical/Data/Fin/Properties.agda
knrafto/cubical
f6771617374bfe65a7043d00731fed5a673aa729
[ "MIT" ]
null
null
null
Cubical/Data/Fin/Properties.agda
knrafto/cubical
f6771617374bfe65a7043d00731fed5a673aa729
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Fin.Properties where open import Cubical.Core.Everything open import Cubical.Functions.Embedding open import Cubical.Functions.Surjection open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Prelude open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Data.Fin.Base as Fin open import Cubical.Data.Nat open import Cubical.Data.Nat.Order open import Cubical.Data.Empty as Empty open import Cubical.Data.Unit open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq open import Cubical.Induction.WellFounded open import Cubical.Relation.Nullary private variable a b ℓ : Level n : ℕ A : Type a -- Fin 0 is empty, and thus a proposition. isPropFin0 : isProp (Fin 0) isPropFin0 = Empty.rec ∘ ¬Fin0 -- Fin 1 has only one value. isContrFin1 : isContr (Fin 1) isContrFin1 = fzero , λ { (zero , _) → toℕ-injective refl ; (suc k , sk<1) → Empty.rec (¬-<-zero (pred-≤-pred sk<1)) } Unit≃Fin1 : Unit ≃ Fin 1 Unit≃Fin1 = isoToEquiv (iso (const fzero) (const tt) (isContrFin1 .snd) (isContrUnit .snd) ) -- Regardless of k, Fin k is a set. isSetFin : ∀{k} → isSet (Fin k) isSetFin {k} = isSetΣ isSetℕ (λ _ → isProp→isSet m≤n-isProp) discreteFin : ∀ {n} → Discrete (Fin n) discreteFin {n} (x , hx) (y , hy) with discreteℕ x y ... | yes prf = yes (Σ≡Prop (λ _ → m≤n-isProp) prf) ... | no prf = no λ h → prf (cong fst h) inject<-ne : ∀ {n} (i : Fin n) → ¬ inject< ≤-refl i ≡ (n , ≤-refl) inject<-ne {n} (k , k<n) p = <→≢ k<n (cong fst p) Fin-fst-≡ : ∀ {n} {i j : Fin n} → fst i ≡ fst j → i ≡ j Fin-fst-≡ = Σ≡Prop (λ _ → m≤n-isProp) private subst-app : (B : A → Type b) (f : (x : A) → B x) {x y : A} (x≡y : x ≡ y) → subst B x≡y (f x) ≡ f y subst-app B f {x = x} = J (λ y e → subst B e (f x) ≡ f y) (substRefl {B = B} (f x)) -- Computation rules for the eliminator. module _ (P : ∀ {k} → Fin k → Type ℓ) (fz : ∀ {k} → P {suc k} fzero) (fs : ∀ {k} {fn : Fin k} → P fn → P (fsuc fn)) {k : ℕ} where elim-fzero : Fin.elim P fz fs {k = suc k} fzero ≡ fz elim-fzero = subst P (toℕ-injective _) fz ≡⟨ cong (λ p → subst P p fz) (isSetFin _ _ _ _) ⟩ subst P refl fz ≡⟨ substRefl {B = P} fz ⟩ fz ∎ elim-fsuc : (fk : Fin k) → Fin.elim P fz fs (fsuc fk) ≡ fs (Fin.elim P fz fs fk) elim-fsuc fk = subst P (toℕ-injective (λ _ → toℕ (fsuc fk′))) (fs (Fin.elim P fz fs fk′)) ≡⟨ cong (λ p → subst P p (fs (Fin.elim P fz fs fk′)) ) (isSetFin _ _ _ _) ⟩ subst P (cong fsuc fk′≡fk) (fs (Fin.elim P fz fs fk′)) ≡⟨ subst-app _ (λ fj → fs (Fin.elim P fz fs fj)) fk′≡fk ⟩ fs (Fin.elim P fz fs fk) ∎ where fk′ = fst fk , pred-≤-pred (snd (fsuc fk)) fk′≡fk : fk′ ≡ fk fk′≡fk = toℕ-injective refl -- Helper function for the reduction procedure below. -- -- If n = expand o k m, then n is congruent to m modulo k. expand : ℕ → ℕ → ℕ → ℕ expand 0 k m = m expand (suc o) k m = k + expand o k m expand≡ : ∀ k m o → expand o k m ≡ o * k + m expand≡ k m zero = refl expand≡ k m (suc o) = cong (k +_) (expand≡ k m o) ∙ +-assoc k (o * k) m -- Expand a pair. This is useful because the whole function is -- injective. expand× : ∀{k} → (Fin k × ℕ) → ℕ expand× {k} (f , o) = expand o k (toℕ f) private lemma₀ : ∀{k m n r} → r ≡ n → k + m ≡ n → k ≤ r lemma₀ {k = k} {m} p q = m , +-comm m k ∙ q ∙ sym p expand×Inj : ∀ k → {t1 t2 : Fin (suc k) × ℕ} → expand× t1 ≡ expand× t2 → t1 ≡ t2 expand×Inj k {f1 , zero} {f2 , zero} p i = toℕ-injective {fj = f1} {f2} p i , zero expand×Inj k {f1 , suc o1} {(r , r<sk) , zero} p = Empty.rec (<-asym r<sk (lemma₀ refl p)) expand×Inj k {(r , r<sk) , zero} {f2 , suc o2} p = Empty.rec (<-asym r<sk (lemma₀ refl (sym p))) expand×Inj k {f1 , suc o1} {f2 , suc o2} = cong (λ { (f , o) → (f , suc o) }) ∘ expand×Inj k {f1 , o1} {f2 , o2} ∘ inj-m+ {suc k} expand×Emb : ∀ k → isEmbedding (expand× {k}) expand×Emb 0 = Empty.rec ∘ ¬Fin0 ∘ fst expand×Emb (suc k) = injEmbedding (isSetΣ isSetFin (λ _ → isSetℕ)) isSetℕ (expand×Inj k) -- A Residue is a family of types representing evidence that a -- natural is congruent to a value of a finite type. Residue : ℕ → ℕ → Type₀ Residue k n = Σ[ tup ∈ Fin k × ℕ ] expand× tup ≡ n -- There is at most one canonical finite value congruent to each -- natural. isPropResidue : ∀ k n → isProp (Residue k n) isPropResidue k = isEmbedding→hasPropFibers (expand×Emb k) -- A value of a finite type is its own residue. Fin→Residue : ∀{k} → (f : Fin k) → Residue k (toℕ f) Fin→Residue f = (f , 0) , refl -- Fibers of numbers that differ by k are equivalent in a more obvious -- way than via the fact that they are propositions. Residue+k : (k n : ℕ) → Residue k n → Residue k (k + n) Residue+k k n ((f , o) , p) = (f , suc o) , cong (k +_) p Residue-k : (k n : ℕ) → Residue k (k + n) → Residue k n Residue-k k n (((r , r<k) , zero) , p) = Empty.rec (<-asym r<k (lemma₀ p refl)) Residue-k k n ((f , suc o) , p) = ((f , o) , inj-m+ p) Residue+k-k : (k n : ℕ) → (R : Residue k (k + n)) → Residue+k k n (Residue-k k n R) ≡ R Residue+k-k k n (((r , r<k) , zero) , p) = Empty.rec (<-asym r<k (lemma₀ p refl)) Residue+k-k k n ((f , suc o) , p) = Σ≡Prop (λ tup → isSetℕ (expand× tup) (k + n)) refl Residue-k+k : (k n : ℕ) → (R : Residue k n) → Residue-k k n (Residue+k k n R) ≡ R Residue-k+k k n ((f , o) , p) = Σ≡Prop (λ tup → isSetℕ (expand× tup) n) refl private Residue≃ : ∀ k n → Residue k n ≃ Residue k (k + n) Residue≃ k n = Residue+k k n , isoToIsEquiv (iso (Residue+k k n) (Residue-k k n) (Residue+k-k k n) (Residue-k+k k n)) Residue≡ : ∀ k n → Residue k n ≡ Residue k (k + n) Residue≡ k n = ua (Residue≃ k n) -- For positive `k`, all `n` have a canonical residue mod `k`. module Reduce (k₀ : ℕ) where k : ℕ k = suc k₀ base : ∀ n (n<k : n < k) → Residue k n base n n<k = Fin→Residue (n , n<k) step : ∀ n → Residue k n → Residue k (k + n) step n = transport (Residue≡ k n) reduce : ∀ n → Residue k n reduce = +induction k₀ (Residue k) base step reduce≡ : ∀ n → transport (Residue≡ k n) (reduce n) ≡ reduce (k + n) reduce≡ n = sym (+inductionStep k₀ _ base step n) reduceP : ∀ n → PathP (λ i → Residue≡ k n i) (reduce n) (reduce (k + n)) reduceP n = toPathP (reduce≡ n) open Reduce using (reduce; reduce≡) public extract : ∀{k n} → Residue k n → Fin k extract = fst ∘ fst private lemma₅ : ∀ k n (R : Residue k n) → extract R ≡ extract (transport (Residue≡ k n) R) lemma₅ k n = sym ∘ cong extract ∘ uaβ (Residue≃ k n) -- The residue of n modulo k is the same as the residue of k + n. extract≡ : ∀ k n → extract (reduce k n) ≡ extract (reduce k (suc k + n)) extract≡ k n = lemma₅ (suc k) n (reduce k n) ∙ cong extract (Reduce.reduce≡ k n) isContrResidue : ∀{k n} → isContr (Residue (suc k) n) isContrResidue {k} {n} = inhProp→isContr (reduce k n) (isPropResidue (suc k) n) -- the modulo operator on ℕ _%_ : ℕ → ℕ → ℕ n % zero = n n % (suc k) = toℕ (extract (reduce k n)) _/_ : ℕ → ℕ → ℕ n / zero = zero n / (suc k) = reduce k n .fst .snd moddiv : ∀ n k → (n / k) * k + n % k ≡ n moddiv n zero = refl moddiv n (suc k) = sym (expand≡ _ _ (n / suc k)) ∙ reduce k n .snd n%k≡n[modk] : ∀ n k → Σ[ o ∈ ℕ ] o * k + n % k ≡ n n%k≡n[modk] n k = (n / k) , moddiv n k n%sk<sk : (n k : ℕ) → (n % suc k) < suc k n%sk<sk n k = extract (reduce k n) .snd fznotfs : ∀ {m : ℕ} {k : Fin m} → ¬ fzero ≡ fsuc k fznotfs {m} p = subst F p tt where F : Fin (suc m) → Type₀ F (zero , _) = Unit F (suc _ , _) = ⊥ fsuc-inj : {fj fk : Fin n} → fsuc fj ≡ fsuc fk → fj ≡ fk fsuc-inj = toℕ-injective ∘ injSuc ∘ cong toℕ punchOut : ∀ {m} {i j : Fin (suc m)} → (¬ i ≡ j) → Fin m punchOut {_} {i} {j} p with fsplit i | fsplit j punchOut {_} {i} {j} p | inl prfi | inl prfj = Empty.elim (p (i ≡⟨ sym prfi ⟩ fzero ≡⟨ prfj ⟩ j ∎)) punchOut {_} {i} {j} p | inl prfi | inr (kj , prfj) = kj punchOut {zero} {i} {j} p | inr (ki , prfi) | inl prfj = Empty.elim (p ( i ≡⟨ sym (isContrFin1 .snd i) ⟩ c ≡⟨ isContrFin1 .snd j ⟩ j ∎ )) where c = isContrFin1 .fst punchOut {suc _} {i} {j} p | inr (ki , prfi) | inl prfj = fzero punchOut {zero} {i} {j} p | inr (ki , prfi) | inr (kj , prfj) = Empty.elim ((p ( i ≡⟨ sym (isContrFin1 .snd i) ⟩ c ≡⟨ isContrFin1 .snd j ⟩ j ∎) )) where c = isContrFin1 .fst punchOut {suc _} {i} {j} p | inr (ki , prfi) | inr (kj , prfj) = fsuc (punchOut {i = ki} {j = kj} (λ q → p (i ≡⟨ sym prfi ⟩ fsuc ki ≡⟨ cong fsuc q ⟩ fsuc kj ≡⟨ prfj ⟩ j ∎)) ) punchOut-inj : ∀ {m} {i j k : Fin (suc m)} (i≢j : ¬ i ≡ j) (i≢k : ¬ i ≡ k) → punchOut i≢j ≡ punchOut i≢k → j ≡ k punchOut-inj {_} {i} {j} {k} i≢j i≢k p with fsplit i | fsplit j | fsplit k punchOut-inj {zero} {i} {j} {k} i≢j i≢k p | _ | _ | _ = Empty.elim (i≢j (i ≡⟨ sym (isContrFin1 .snd i) ⟩ c ≡⟨ isContrFin1 .snd j ⟩ j ∎)) where c = isContrFin1 .fst punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inl prfi | inl prfj | _ = Empty.elim (i≢j (i ≡⟨ sym prfi ⟩ fzero ≡⟨ prfj ⟩ j ∎)) punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inl prfi | _ | inl prfk = Empty.elim (i≢k (i ≡⟨ sym prfi ⟩ fzero ≡⟨ prfk ⟩ k ∎)) punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inl prfi | inr (kj , prfj) | inr (kk , prfk) = j ≡⟨ sym prfj ⟩ fsuc kj ≡⟨ cong fsuc p ⟩ fsuc kk ≡⟨ prfk ⟩ k ∎ punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inl prfj | inl prfk = j ≡⟨ sym prfj ⟩ fzero ≡⟨ prfk ⟩ k ∎ punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inr (kj , prfj) | inr (kk , prfk) = j ≡⟨ sym prfj ⟩ fsuc kj ≡⟨ cong fsuc lemma4 ⟩ fsuc kk ≡⟨ prfk ⟩ k ∎ where lemma1 = λ q → i≢j (i ≡⟨ sym prfi ⟩ fsuc ki ≡⟨ cong fsuc q ⟩ fsuc kj ≡⟨ prfj ⟩ j ∎) lemma2 = λ q → i≢k (i ≡⟨ sym prfi ⟩ fsuc ki ≡⟨ cong fsuc q ⟩ fsuc kk ≡⟨ prfk ⟩ k ∎) lemma3 = fsuc-inj p lemma4 = punchOut-inj lemma1 lemma2 lemma3 punchOut-inj {suc m} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inl prfj | inr (kk , prfk) = Empty.rec (fznotfs p) punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inr (kj , prfj) | inl prfk = Empty.rec (fznotfs (sym p)) pigeonhole-special : ∀ {n} → (f : Fin (suc n) → Fin n) → Σ[ i ∈ Fin (suc n) ] Σ[ j ∈ Fin (suc n) ] (¬ i ≡ j) × (f i ≡ f j) pigeonhole-special {zero} f = Empty.rec (¬Fin0 (f fzero)) pigeonhole-special {suc n} f = proof (any? (λ (i : Fin (suc n)) → discreteFin (f (inject< ≤-refl i)) (f (suc n , ≤-refl)) )) where proof : Dec (Σ (Fin (suc n)) (λ z → f (inject< ≤-refl z) ≡ f (suc n , ≤-refl))) → Σ[ i ∈ Fin (suc (suc n)) ] Σ[ j ∈ Fin (suc (suc n)) ] (¬ i ≡ j) × (f i ≡ f j) proof (yes (i , prf)) = inject< ≤-refl i , (suc n , ≤-refl) , inject<-ne i , prf proof (no h) = let g : Fin (suc n) → Fin n g k = punchOut {i = f (suc n , ≤-refl)} {j = f (inject< ≤-refl k)} (λ p → h (k , Fin-fst-≡ (sym (cong fst p)))) i , j , i≢j , p = pigeonhole-special g in inject< ≤-refl i , inject< ≤-refl j , (λ q → i≢j (Fin-fst-≡ (cong fst q))) , punchOut-inj {i = f (suc n , ≤-refl)} {j = f (inject< ≤-refl i)} {k = f (inject< ≤-refl j)} (λ q → h (i , Fin-fst-≡ (sym (cong fst q)))) (λ q → h (j , Fin-fst-≡ (sym (cong fst q)))) (Fin-fst-≡ (cong fst p)) pigeonhole : ∀ {m n} → m < n → (f : Fin n → Fin m) → Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] (¬ i ≡ j) × (f i ≡ f j) pigeonhole {m} {n} (zero , sm≡n) f = transport transport-prf (pigeonhole-special f′) where f′ : Fin (suc m) → Fin m f′ = subst (λ h → Fin h → Fin m) (sym sm≡n) f f′≡f : PathP (λ i → Fin (sm≡n i) → Fin m) f′ f f′≡f i = transport-fillerExt (cong (λ h → Fin h → Fin m) (sym sm≡n)) (~ i) f transport-prf : (Σ[ i ∈ Fin (suc m) ] Σ[ j ∈ Fin (suc m) ] (¬ i ≡ j) × (f′ i ≡ f′ j)) ≡ (Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] (¬ i ≡ j) × (f i ≡ f j)) transport-prf φ = Σ[ i ∈ Fin (sm≡n φ) ] Σ[ j ∈ Fin (sm≡n φ) ] (¬ i ≡ j) × (f′≡f φ i ≡ f′≡f φ j) pigeonhole {m} {n} (suc k , prf) f = let g : Fin (suc n′) → Fin n′ g k = fst (f′ k) , <-trans (snd (f′ k)) m<n′ i , j , ¬q , r = pigeonhole-special g in transport transport-prf (i , j , ¬q , Σ≡Prop (λ _ → m≤n-isProp) (cong fst r)) where n′ : ℕ n′ = k + suc m n≡sn′ : n ≡ suc n′ n≡sn′ = n ≡⟨ sym prf ⟩ suc (k + suc m) ≡⟨ refl ⟩ suc n′ ∎ m<n′ : m < n′ m<n′ = k , injSuc (suc (k + suc m) ≡⟨ prf ⟩ n ≡⟨ n≡sn′ ⟩ suc n′ ∎) f′ : Fin (suc n′) → Fin m f′ = subst (λ h → Fin h → Fin m) n≡sn′ f f′≡f : PathP (λ i → Fin (n≡sn′ (~ i)) → Fin m) f′ f f′≡f i = transport-fillerExt (cong (λ h → Fin h → Fin m) n≡sn′) (~ i) f transport-prf : (Σ[ i ∈ Fin (suc n′) ] Σ[ j ∈ Fin (suc n′) ] (¬ i ≡ j) × (f′ i ≡ f′ j)) ≡ (Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] (¬ i ≡ j) × (f i ≡ f j)) transport-prf φ = Σ[ i ∈ Fin (n≡sn′ (~ φ)) ] Σ[ j ∈ Fin (n≡sn′ (~ φ)) ] (¬ i ≡ j) × (f′≡f φ i ≡ f′≡f φ j) Fin-inj′ : {n m : ℕ} → n < m → ¬ Fin m ≡ Fin n Fin-inj′ n<m p = let i , j , i≢j , q = pigeonhole n<m (transport p) in i≢j ( i ≡⟨ refl ⟩ fst (pigeonhole n<m (transport p)) ≡⟨ transport-p-inj {p = p} q ⟩ fst (snd (pigeonhole n<m (transport p))) ≡⟨ refl ⟩ j ∎ ) where transport-p-inj : ∀ {A B : Type ℓ} {x y : A} {p : A ≡ B} → transport p x ≡ transport p y → x ≡ y transport-p-inj {x = x} {y = y} {p = p} q = x ≡⟨ sym (transport⁻Transport p x) ⟩ transport (sym p) (transport p x) ≡⟨ cong (transport (sym p)) q ⟩ transport (sym p) (transport p y) ≡⟨ transport⁻Transport p y ⟩ y ∎ Fin-inj : (n m : ℕ) → Fin n ≡ Fin m → n ≡ m Fin-inj n m p with n ≟ m ... | eq prf = prf ... | lt n<m = Empty.rec (Fin-inj′ n<m (sym p)) ... | gt n>m = Empty.rec (Fin-inj′ n>m p) ≤-*sk-cancel : ∀ {m} {k} {n} → m * suc k ≤ n * suc k → m ≤ n ≤-*sk-cancel {m} {k} {n} (d , p) = o , inj-*sm {m = k} goal where r = d % suc k o = d / suc k resn*k : Residue (suc k) (n * suc k) resn*k = ((r , n%sk<sk d k) , (o + m)) , reason where reason = expand× ((r , n%sk<sk d k) , o + m) ≡⟨ expand≡ (suc k) r (o + m) ⟩ (o + m) * suc k + r ≡[ i ]⟨ +-comm (*-distribʳ o m (suc k) (~ i)) r i ⟩ r + (o * suc k + m * suc k) ≡⟨ +-assoc r (o * suc k) (m * suc k) ⟩ (r + o * suc k) + m * suc k ≡⟨ cong (_+ m * suc k) (+-comm r (o * suc k) ∙ moddiv d (suc k)) ⟩ d + m * suc k ≡⟨ p ⟩ n * suc k ∎ residuek*n : ∀ k n → (r : Residue (suc k) (n * suc k)) → ((fzero , n) , expand≡ (suc k) 0 n ∙ +-zero _) ≡ r residuek*n _ _ = isContr→isProp isContrResidue _ r≡0 : r ≡ 0 r≡0 = cong (toℕ ∘ extract) (sym (residuek*n k n resn*k)) d≡o*sk : d ≡ o * suc k d≡o*sk = sym (moddiv d (suc k)) ∙∙ cong (o * suc k +_) r≡0 ∙∙ +-zero _ goal : (o + m) * suc k ≡ n * suc k goal = sym (*-distribʳ o m (suc k)) ∙∙ cong (_+ m * suc k) (sym d≡o*sk) ∙∙ p <-*sk-cancel : ∀ {m} {k} {n} → m * suc k < n * suc k → m < n <-*sk-cancel {m} {k} {n} p = goal where ≤-helper : m ≤ n ≤-helper = ≤-*sk-cancel (pred-≤-pred (<≤-trans p (≤-suc ≤-refl))) goal : m < n goal = case <-split (suc-≤-suc ≤-helper) of λ { (inl g) → g ; (inr e) → Empty.rec (¬m<m (subst (λ m → m * suc k < n * suc k) e p)) } factorEquiv : ∀ {n} {m} → Fin n × Fin m ≃ Fin (n * m) factorEquiv {zero} {m} = uninhabEquiv (¬Fin0 ∘ fst) ¬Fin0 factorEquiv {suc n} {m} = intro , isEmbedding×isSurjection→isEquiv (isEmbeddingIntro , isSurjectionIntro) where intro : Fin (suc n) × Fin m → Fin (suc n * m) intro (nn , mm) = nm , subst (λ nm₁ → nm₁ < suc n * m) (sym (expand≡ _ (toℕ nn) (toℕ mm))) nm<n*m where nm : ℕ nm = expand× (nn , toℕ mm) nm<n*m : toℕ mm * suc n + toℕ nn < suc n * m nm<n*m = toℕ mm * suc n + toℕ nn <≤⟨ <-k+ (snd nn) ⟩ toℕ mm * suc n + suc n ≡≤⟨ +-comm _ (suc n) ⟩ suc (toℕ mm) * suc n ≤≡⟨ ≤-*k (snd mm) ⟩ m * suc n ≡⟨ *-comm _ (suc n) ⟩ suc n * m ∎ where open <-Reasoning intro-injective : ∀ {o} {p} → intro o ≡ intro p → o ≡ p intro-injective {o} {p} io≡ip = λ i → io′≡ip′ i .fst , toℕ-injective {fj = snd o} {fk = snd p} (cong snd io′≡ip′) i where io′≡ip′ : (fst o , toℕ (snd o)) ≡ (fst p , toℕ (snd p)) io′≡ip′ = expand×Inj _ (cong fst io≡ip) isEmbeddingIntro : isEmbedding intro isEmbeddingIntro = injEmbedding (isSet× isSetFin isSetFin) isSetFin intro-injective elimF : ∀ nm → fiber intro nm elimF nm = ((nn , nn<n) , (mm , mm<m)) , toℕ-injective (reduce n (toℕ nm) .snd) where mm = toℕ nm / suc n nn = toℕ nm % suc n nmmoddiv : mm * suc n + nn ≡ toℕ nm nmmoddiv = moddiv _ (suc n) nn<n : nn < suc n nn<n = n%sk<sk (toℕ nm) _ nmsnd : mm * suc n + nn < suc n * m nmsnd = subst (λ l → l < suc n * m) (sym nmmoddiv) (snd nm) mm*sn<m*sn : mm * suc n < m * suc n mm*sn<m*sn = mm * suc n ≤<⟨ nn , +-comm nn (mm * suc n) ⟩ mm * suc n + nn <≡⟨ nmsnd ⟩ suc n * m ≡⟨ *-comm (suc n) m ⟩ m * suc n ∎ where open <-Reasoning mm<m : mm < m mm<m = <-*sk-cancel mm*sn<m*sn isSurjectionIntro : isSurjection intro isSurjectionIntro = ∣_∣ ∘ elimF
34.295938
123
0.523377
d1cf16a614597a513781f4326b4dfffef1ec84f2
8,508
agda
Agda
src/utm.agda
shinji-kono/automaton-in-agda
eba0538f088f3d0c0fedb19c47c081954fbc69cb
[ "MIT" ]
null
null
null
src/utm.agda
shinji-kono/automaton-in-agda
eba0538f088f3d0c0fedb19c47c081954fbc69cb
[ "MIT" ]
null
null
null
src/utm.agda
shinji-kono/automaton-in-agda
eba0538f088f3d0c0fedb19c47c081954fbc69cb
[ "MIT" ]
null
null
null
module utm where open import turing open import Data.Product -- open import Data.Bool open import Data.List open import Data.Nat open import logic data utmStates : Set where reads : utmStates read0 : utmStates read1 : utmStates read2 : utmStates read3 : utmStates read4 : utmStates read5 : utmStates read6 : utmStates loc0 : utmStates loc1 : utmStates loc2 : utmStates loc3 : utmStates loc4 : utmStates loc5 : utmStates loc6 : utmStates fetch0 : utmStates fetch1 : utmStates fetch2 : utmStates fetch3 : utmStates fetch4 : utmStates fetch5 : utmStates fetch6 : utmStates fetch7 : utmStates print0 : utmStates print1 : utmStates print2 : utmStates print3 : utmStates print4 : utmStates print5 : utmStates print6 : utmStates print7 : utmStates mov0 : utmStates mov1 : utmStates mov2 : utmStates mov3 : utmStates mov4 : utmStates mov5 : utmStates mov6 : utmStates tidy0 : utmStates tidy1 : utmStates halt : utmStates data utmΣ : Set where 0 : utmΣ 1 : utmΣ B : utmΣ * : utmΣ $ : utmΣ ^ : utmΣ X : utmΣ Y : utmΣ Z : utmΣ @ : utmΣ b : utmΣ utmδ : utmStates → utmΣ → utmStates × (Write utmΣ) × Move utmδ reads x = read0 , wnone , mnone utmδ read0 * = read1 , write * , left utmδ read0 x = read0 , write x , right utmδ read1 x = read2 , write @ , right utmδ read2 ^ = read3 , write ^ , right utmδ read2 x = read2 , write x , right utmδ read3 0 = read4 , write 0 , left utmδ read3 1 = read5 , write 1 , left utmδ read3 b = read6 , write b , left utmδ read4 @ = loc0 , write 0 , right utmδ read4 x = read4 , write x , left utmδ read5 @ = loc0 , write 1 , right utmδ read5 x = read5 , write x , left utmδ read6 @ = loc0 , write B , right utmδ read6 x = read6 , write x , left utmδ loc0 0 = loc0 , write X , left utmδ loc0 1 = loc0 , write Y , left utmδ loc0 B = loc0 , write Z , left utmδ loc0 $ = loc1 , write $ , right utmδ loc0 x = loc0 , write x , left utmδ loc1 X = loc2 , write 0 , right utmδ loc1 Y = loc3 , write 1 , right utmδ loc1 Z = loc4 , write B , right utmδ loc1 * = fetch0 , write * , right utmδ loc1 x = loc1 , write x , right utmδ loc2 0 = loc5 , write X , right utmδ loc2 1 = loc6 , write Y , right utmδ loc2 B = loc6 , write Z , right utmδ loc2 x = loc2 , write x , right utmδ loc3 1 = loc5 , write Y , right utmδ loc3 0 = loc6 , write X , right utmδ loc3 B = loc6 , write Z , right utmδ loc3 x = loc3 , write x , right utmδ loc4 B = loc5 , write Z , right utmδ loc4 0 = loc6 , write X , right utmδ loc4 1 = loc6 , write Y , right utmδ loc4 x = loc4 , write x , right utmδ loc5 $ = loc1 , write $ , right utmδ loc5 x = loc5 , write x , left utmδ loc6 $ = halt , write $ , right utmδ loc6 * = loc0 , write * , left utmδ loc6 x = loc6 , write x , right utmδ fetch0 0 = fetch1 , write X , left utmδ fetch0 1 = fetch2 , write Y , left utmδ fetch0 B = fetch3 , write Z , left utmδ fetch0 x = fetch0 , write x , right utmδ fetch1 $ = fetch4 , write $ , right utmδ fetch1 x = fetch1 , write x , left utmδ fetch2 $ = fetch5 , write $ , right utmδ fetch2 x = fetch2 , write x , left utmδ fetch3 $ = fetch6 , write $ , right utmδ fetch3 x = fetch3 , write x , left utmδ fetch4 0 = fetch7 , write X , right utmδ fetch4 1 = fetch7 , write X , right utmδ fetch4 B = fetch7 , write X , right utmδ fetch4 * = print0 , write * , left utmδ fetch4 x = fetch4 , write x , right utmδ fetch5 0 = fetch7 , write Y , right utmδ fetch5 1 = fetch7 , write Y , right utmδ fetch5 B = fetch7 , write Y , right utmδ fetch5 * = print0 , write * , left utmδ fetch5 x = fetch5 , write x , right utmδ fetch6 0 = fetch7 , write Z , right utmδ fetch6 1 = fetch7 , write Z , right utmδ fetch6 B = fetch7 , write Z , right utmδ fetch6 * = print0 , write * , left utmδ fetch6 x = fetch6 , write x , right utmδ fetch7 * = fetch0 , write * , right utmδ fetch7 x = fetch7 , write x , right utmδ print0 X = print1 , write X , right utmδ print0 Y = print2 , write Y , right utmδ print0 Z = print3 , write Z , right utmδ print1 ^ = print4 , write ^ , right utmδ print1 x = print1 , write x , right utmδ print2 ^ = print5 , write ^ , right utmδ print2 x = print2 , write x , right utmδ print3 ^ = print6 , write ^ , right utmδ print3 x = print3 , write x , right utmδ print4 x = print7 , write 0 , left utmδ print5 x = print7 , write 1 , left utmδ print6 x = print7 , write B , left utmδ print7 X = mov0 , write X , right utmδ print7 Y = mov1 , write Y , right utmδ print7 x = print7 , write x , left utmδ mov0 ^ = mov2 , write ^ , left utmδ mov0 x = mov0 , write x , right utmδ mov1 ^ = mov3 , write ^ , right utmδ mov1 x = mov1 , write x , right utmδ mov2 0 = mov4 , write ^ , right utmδ mov2 1 = mov5 , write ^ , right utmδ mov2 B = mov6 , write ^ , right utmδ mov3 0 = mov4 , write ^ , left utmδ mov3 1 = mov5 , write ^ , left utmδ mov3 B = mov6 , write ^ , left utmδ mov4 ^ = tidy0 , write 0 , left utmδ mov5 ^ = tidy0 , write 1 , left utmδ mov6 ^ = tidy0 , write B , left utmδ tidy0 $ = tidy1 , write $ , left utmδ tidy0 x = tidy0 , write x , left utmδ tidy1 X = tidy1 , write 0 , left utmδ tidy1 Y = tidy1 , write 1 , left utmδ tidy1 Z = tidy1 , write B , left utmδ tidy1 $ = reads , write $ , right utmδ tidy1 x = tidy1 , write x , left utmδ _ x = halt , write x , mnone U-TM : Turing utmStates utmΣ U-TM = record { tδ = utmδ ; tstart = read0 ; tend = tend ; tnone = b } where tend : utmStates → Bool tend halt = true tend _ = false -- Copyδ : CopyStates → ℕ → CopyStates × ( Write ℕ ) × Move -- Copyδ s1 0 = H , wnone , mnone -- Copyδ s1 1 = s2 , write 0 , right -- Copyδ s2 0 = s3 , write 0 , right -- Copyδ s2 1 = s2 , write 1 , right -- Copyδ s3 0 = s4 , write 1 , left -- Copyδ s3 1 = s3 , write 1 , right -- Copyδ s4 0 = s5 , write 0 , left -- Copyδ s4 1 = s4 , write 1 , left -- Copyδ s5 0 = s1 , write 1 , right -- Copyδ s5 1 = s5 , write 1 , left -- Copyδ H _ = H , wnone , mnone -- Copyδ _ (suc (suc _)) = H , wnone , mnone Copyδ-encode : List utmΣ Copyδ-encode = 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ -- s1 0 = H , wnone , mnone * ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ -- s1 1 = s2 , write 0 , right * ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ -- s2 0 = s3 , write 0 , right * ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ -- s2 1 = s2 , write 1 , right * ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ -- s3 0 = s4 , write 1 , left * ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ -- s3 1 = s3 , write 1 , right * ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ -- s4 0 = s5 , write 0 , left * ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ -- s4 1 = s4 , write 1 , left * ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ -- s5 0 = s1 , write 1 , right * ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ -- s5 1 = s5 , write 1 , left [] input-encode : List utmΣ input-encode = 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ [] input+Copyδ : List utmΣ input+Copyδ = ( $ ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ * ∷ [] ) -- start state ++ Copyδ-encode ++ ( $ ∷ ^ ∷ input-encode ) short-input : List utmΣ short-input = $ ∷ 0 ∷ 0 ∷ 0 ∷ * ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ * ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ * ∷ 0 ∷ 1 ∷ B ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ * ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ $ ∷ ^ ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ [] utm-test1 : List utmΣ → utmStates × ( List utmΣ ) × ( List utmΣ ) utm-test1 inp = Turing.taccept U-TM inp {-# TERMINATING #-} utm-test2 : ℕ → List utmΣ → utmStates × ( List utmΣ ) × ( List utmΣ ) utm-test2 n inp = loop n (Turing.tstart U-TM) inp [] where loop : ℕ → utmStates → ( List utmΣ ) → ( List utmΣ ) → utmStates × ( List utmΣ ) × ( List utmΣ ) loop zero q L R = ( q , L , R ) loop (suc n) q L R with move {utmStates} {utmΣ} {0} {utmδ} q L R | q ... | nq , nL , nR | reads = loop n nq nL nR ... | nq , nL , nR | _ = loop (suc n) nq nL nR t1 = utm-test2 20 short-input t : (n : ℕ) → utmStates × ( List utmΣ ) × ( List utmΣ ) -- t n = utm-test2 n input+Copyδ t n = utm-test2 n short-input
33.761905
109
0.551951
1ea71170036f6dc08f1cfb317a695c1805f97225
1,559
agda
Agda
src/Lib.agda
mietek/formal-logic
2dd761bfa96ccda089888e8defa6814776fa2922
[ "X11" ]
26
2015-08-31T09:49:52.000Z
2021-11-13T12:37:44.000Z
src/Lib.agda
mietek/formal-logic
2dd761bfa96ccda089888e8defa6814776fa2922
[ "X11" ]
null
null
null
src/Lib.agda
mietek/formal-logic
2dd761bfa96ccda089888e8defa6814776fa2922
[ "X11" ]
null
null
null
module Lib where -- Natural numbers data Nat : Set where zero : Nat suc : Nat -> Nat {-# BUILTIN NATURAL Nat #-} _+_ : Nat -> Nat -> Nat zero + n = n suc k + n = suc (k + n) -- Finite sets data Fin : Nat -> Set where fzero : forall {n} -> Fin (suc n) fsuc : forall {n} -> Fin n -> Fin (suc n) fin : forall {n} (k : Nat) -> Fin (suc (k + n)) fin zero = fzero fin (suc i) = fsuc (fin i) -- Lists infixl 0 _,_ data List (X : Set) : Set where [] : List X _,_ : List X -> X -> List X -- List membership data LMem {X : Set} (a : X) : List X -> Set where lzero : forall {l} -> LMem a (l , a) lsuc : forall {l b} -> LMem a l -> LMem a (l , b) -- Vectors data Vec (X : Set) : Nat -> Set where [] : Vec X zero _,_ : forall {n} -> Vec X n -> X -> Vec X (suc n) proj : forall {X n} -> Vec X n -> Fin n -> X proj [] () proj (_ , a) fzero = a proj (v , _) (fsuc i) = proj v i -- Vector membership data VMem {X : Set} (a : X) : forall {n} -> Fin n -> Vec X n -> Set where mzero : forall {n} {v : Vec X n} -> VMem a fzero (v , a) msuc : forall {n i b} {v : Vec X n} -> VMem a i v -> VMem a (fsuc i) (v , b) fmem : forall {X n} -> (i : Fin n) -> {v : Vec X n} -> VMem (proj v i) i v fmem {_} {zero} () fmem {_} {suc n} fzero {_ , a} = mzero fmem {_} {suc n} (fsuc i) {v , _} = msuc (fmem i) mem : forall {X n} -> (k : Nat) -> {v : Vec X (suc (k + n))} -> VMem (proj v (fin k)) (fin k) v mem i = fmem (fin i)
22.594203
95
0.474663
fd2f1a3719d7f4fb59eb0ea129f740a7b26224b3
2,357
agda
Agda
examples/simple-lib/Lib/List.agda
pthariensflame/agda
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
[ "BSD-3-Clause" ]
null
null
null
examples/simple-lib/Lib/List.agda
pthariensflame/agda
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
[ "BSD-3-Clause" ]
null
null
null
examples/simple-lib/Lib/List.agda
pthariensflame/agda
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
[ "BSD-3-Clause" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
module Lib.List where open import Lib.Prelude open import Lib.Id infix 30 _∈_ infixr 40 _::_ _++_ infix 45 _!_ data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A {-# COMPILED_DATA List [] [] (:) #-} {-# BUILTIN LIST List #-} {-# BUILTIN NIL [] #-} {-# BUILTIN CONS _::_ #-} _++_ : {A : Set} -> List A -> List A -> List A [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) foldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B foldr f z [] = z foldr f z (x :: xs) = f x (foldr f z xs) map : {A B : Set} -> (A -> B) -> List A -> List B map f [] = [] map f (x :: xs) = f x :: map f xs map-id : forall {A}(xs : List A) -> map id xs ≡ xs map-id [] = refl map-id (x :: xs) with map id xs | map-id xs ... | .xs | refl = refl data _∈_ {A : Set} : A -> List A -> Set where hd : forall {x xs} -> x ∈ x :: xs tl : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs data All {A : Set}(P : A -> Set) : List A -> Set where [] : All P [] _::_ : forall {x xs} -> P x -> All P xs -> All P (x :: xs) head : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> P x head (x :: xs) = x tail : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> All P xs tail (x :: xs) = xs _!_ : forall {A}{P : A -> Set}{x xs} -> All P xs -> x ∈ xs -> P x xs ! hd = head xs xs ! tl n = tail xs ! n tabulate : forall {A}{P : A -> Set}{xs} -> ({x : A} -> x ∈ xs -> P x) -> All P xs tabulate {xs = []} f = [] tabulate {xs = x :: xs} f = f hd :: tabulate (f ∘ tl) mapAll : forall {A B}{P : A -> Set}{Q : B -> Set}{xs}(f : A -> B) -> ({x : A} -> P x -> Q (f x)) -> All P xs -> All Q (map f xs) mapAll f h [] = [] mapAll f h (x :: xs) = h x :: mapAll f h xs mapAll- : forall {A}{P Q : A -> Set}{xs} -> ({x : A} -> P x -> Q x) -> All P xs -> All Q xs mapAll- {xs = xs} f zs with map id xs | map-id xs | mapAll id f zs ... | .xs | refl | r = r infix 20 _⊆_ data _⊆_ {A : Set} : List A -> List A -> Set where stop : [] ⊆ [] drop : forall {xs y ys} -> xs ⊆ ys -> xs ⊆ y :: ys keep : forall {x xs ys} -> xs ⊆ ys -> x :: xs ⊆ x :: ys ⊆-refl : forall {A}{xs : List A} -> xs ⊆ xs ⊆-refl {xs = []} = stop ⊆-refl {xs = x :: xs} = keep ⊆-refl _∣_ : forall {A}{P : A -> Set}{xs ys} -> All P ys -> xs ⊆ ys -> All P xs [] ∣ stop = [] (x :: xs) ∣ drop p = xs ∣ p (x :: xs) ∣ keep p = x :: (xs ∣ p)
28.059524
81
0.450573
34d91d239f5cb6e1a752a915086835dca2f2e58c
541
agda
Agda
test/interaction/Issue2729.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue2729.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue2729.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2017-09-03, issue #2729. -- Expect non-indexed or -primed variables when splitting. -- {-# OPTIONS -v interaction.case:100 #-} -- {-# OPTIONS -v tc.cover:40 #-} data Size : Set where ↑ : Size → Size data Nat : Size → Set where zero : ∀ i → Nat (↑ i) suc : ∀ i → Nat i → Nat (↑ i) pred : ∀ i → Nat i → Nat i pred i x = {!x!} -- C-c C-c -- WRONG (agda-2.5.3): -- pred .(↑ i₁) (zero i₁) = ? -- pred .(↑ i₁) (suc i₁ x) = ? -- EXPECTED (correct in agda-2.5.1.1): -- pred .(↑ i) (zero i) = ? -- pred .(↑ i) (suc i x) = ?
22.541667
58
0.521257
fd00f8150e5f6ad2a145714a5efc7e9049219010
230
agda
Agda
test/Fail/Erased-cubical-Higher-constructor.agda
banacorn/agda
2a07bfdf2c1c4ae87f428809af0887aceb6632c0
[ "MIT" ]
null
null
null
test/Fail/Erased-cubical-Higher-constructor.agda
banacorn/agda
2a07bfdf2c1c4ae87f428809af0887aceb6632c0
[ "MIT" ]
null
null
null
test/Fail/Erased-cubical-Higher-constructor.agda
banacorn/agda
2a07bfdf2c1c4ae87f428809af0887aceb6632c0
[ "MIT" ]
1
2021-04-18T13:34:07.000Z
2021-04-18T13:34:07.000Z
{-# OPTIONS --erased-cubical #-} open import Agda.Builtin.Cubical.Path -- Higher constructors must be erased when --erased-cubical is used. data ∥_∥ (A : Set) : Set where ∣_∣ : A → ∥ A ∥ trivial : (x y : ∥ A ∥) → x ≡ y
23
68
0.595652
13bd40439363d5b693968e4d57506c0e1aec73f2
5,999
agda
Agda
Cubical/Foundations/Equiv.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Foundations/Equiv.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Foundations/Equiv.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{- Theory about equivalences Definitions are in Core/Glue.agda but re-exported by this module - isEquiv is a proposition ([isPropIsEquiv]) - Any isomorphism is an equivalence ([isoToEquiv]) There are more statements about equivalences in Equiv/Properties.agda: - if f is an equivalence then (cong f) is an equivalence - if f is an equivalence then precomposition with f is an equivalence - if f is an equivalence then postcomposition with f is an equivalence -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Equiv where open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv.Base public private variable ℓ ℓ' ℓ'' : Level A B C : Type ℓ fiber : ∀ {A : Type ℓ} {B : Type ℓ'} (f : A → B) (y : B) → Type (ℓ-max ℓ ℓ') fiber {A = A} f y = Σ[ x ∈ A ] f x ≡ y equivIsEquiv : ∀ {A : Type ℓ} {B : Type ℓ'} (e : A ≃ B) → isEquiv (equivFun e) equivIsEquiv e = snd e equivCtr : ∀ {A : Type ℓ} {B : Type ℓ'} (e : A ≃ B) (y : B) → fiber (equivFun e) y equivCtr e y = e .snd .equiv-proof y .fst equivCtrPath : ∀ {A : Type ℓ} {B : Type ℓ'} (e : A ≃ B) (y : B) → (v : fiber (equivFun e) y) → Path _ (equivCtr e y) v equivCtrPath e y = e .snd .equiv-proof y .snd -- Proof using isPropIsContr. This is slow and the direct proof below is better isPropIsEquiv' : (f : A → B) → isProp (isEquiv f) equiv-proof (isPropIsEquiv' f u0 u1 i) y = isPropIsContr (u0 .equiv-proof y) (u1 .equiv-proof y) i -- Direct proof that computes quite ok (can be optimized further if -- necessary, see: -- https://github.com/mortberg/cubicaltt/blob/pi4s3_dimclosures/examples/brunerie2.ctt#L562 isPropIsEquiv : (f : A → B) → isProp (isEquiv f) equiv-proof (isPropIsEquiv f p q i) y = let p2 = p .equiv-proof y .snd q2 = q .equiv-proof y .snd in p2 (q .equiv-proof y .fst) i , λ w j → hcomp (λ k → λ { (i = i0) → p2 w j ; (i = i1) → q2 w (j ∨ ~ k) ; (j = i0) → p2 (q2 w (~ k)) i ; (j = i1) → w }) (p2 w (i ∨ j)) equivEq : (e f : A ≃ B) → (h : e .fst ≡ f .fst) → e ≡ f equivEq e f h = λ i → (h i) , isProp→PathP (λ i → isPropIsEquiv (h i)) (e .snd) (f .snd) i module _ (w : A ≃ B) where invEq : B → A invEq y = fst (fst (snd w .equiv-proof y)) secEq : section invEq (w .fst) secEq x = λ i → fst (snd (snd w .equiv-proof (fst w x)) (x , (λ j → fst w x)) i) retEq : retract invEq (w .fst) retEq y = λ i → snd (fst (snd w .equiv-proof y)) i equivToIso : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → A ≃ B → Iso A B equivToIso {A = A} {B = B} e = iso (e .fst) (invEq e ) (retEq e) (secEq e) invEquiv : A ≃ B → B ≃ A invEquiv f = isoToEquiv (iso (invEq f) (fst f) (secEq f) (retEq f)) invEquivIdEquiv : (A : Type ℓ) → invEquiv (idEquiv A) ≡ idEquiv A invEquivIdEquiv _ = equivEq _ _ refl compEquiv : A ≃ B → B ≃ C → A ≃ C compEquiv f g = isoToEquiv (iso (λ x → g .fst (f .fst x)) (λ x → invEq f (invEq g x)) (λ y → (cong (g .fst) (retEq f (invEq g y))) ∙ (retEq g y)) (λ y → (cong (invEq f) (secEq g (f .fst y))) ∙ (secEq f y))) compEquivIdEquiv : {A B : Type ℓ} (e : A ≃ B) → compEquiv (idEquiv A) e ≡ e compEquivIdEquiv e = equivEq _ _ refl LiftEquiv : {A : Type ℓ} → A ≃ Lift {i = ℓ} {j = ℓ'} A LiftEquiv = isoToEquiv (iso lift lower (λ _ → refl) (λ _ → refl)) -- module _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} where -- invEquivInvol : (f : A ≃ B) → invEquiv (invEquiv f) ≡ f -- invEquivInvol f i .fst = fst f -- invEquivInvol f i .snd = propIsEquiv (fst f) (snd (invEquiv (invEquiv f))) (snd f) i Contr→Equiv : isContr A → isContr B → A ≃ B Contr→Equiv Actr Bctr = isoToEquiv (iso (λ _ → fst Bctr) (λ _ → fst Actr) (snd Bctr) (snd Actr)) PropEquiv→Equiv : (Aprop : isProp A) (Bprop : isProp B) (f : A → B) (g : B → A) → (A ≃ B) PropEquiv→Equiv Aprop Bprop f g = isoToEquiv (iso f g (λ b → Bprop (f (g b)) b) λ a → Aprop (g (f a)) a) homotopyNatural : {f g : A → B} (H : ∀ a → f a ≡ g a) {x y : A} (p : x ≡ y) → H x ∙ cong g p ≡ cong f p ∙ H y homotopyNatural {f = f} {g = g} H {x} {y} p i j = hcomp (λ k → λ { (i = i0) → compPath-filler (H x) (cong g p) k j ; (i = i1) → compPath-filler' (cong f p) (H y) k j ; (j = i0) → cong f p (i ∧ (~ k)) ; (j = i1) → cong g p (i ∨ k) }) (H (p i) j) Hfa≡fHa : ∀ {A : Type ℓ} (f : A → A) → (H : ∀ a → f a ≡ a) → ∀ a → H (f a) ≡ cong f (H a) Hfa≡fHa {A = A} f H a = H (f a) ≡⟨ rUnit (H (f a)) ⟩ H (f a) ∙ refl ≡⟨ cong (_∙_ (H (f a))) (sym (rCancel (H a))) ⟩ H (f a) ∙ H a ∙ sym (H a) ≡⟨ assoc _ _ _ ⟩ (H (f a) ∙ H a) ∙ sym (H a) ≡⟨ cong (λ x → x ∙ (sym (H a))) (homotopyNatural H (H a)) ⟩ (cong f (H a) ∙ H a) ∙ sym (H a) ≡⟨ sym (assoc _ _ _) ⟩ cong f (H a) ∙ H a ∙ sym (H a) ≡⟨ cong (_∙_ (cong f (H a))) (rCancel _) ⟩ cong f (H a) ∙ refl ≡⟨ sym (rUnit _) ⟩ cong f (H a) ∎ invEq≡→equivFun≡ : ∀ (e : A ≃ B) {x y} → invEq e x ≡ y → equivFun e y ≡ x invEq≡→equivFun≡ e {x} p = cong (equivFun e) (sym p) ∙ retEq e x equivPi : ∀{F : A → Set ℓ} {G : A → Set ℓ'} → ((x : A) → F x ≃ G x) → (((x : A) → F x) ≃ ((x : A) → G x)) equivPi k .fst f x = k x .fst (f x) equivPi k .snd .equiv-proof f .fst .fst x = equivCtr (k x) (f x) .fst equivPi k .snd .equiv-proof f .fst .snd i x = equivCtr (k x) (f x) .snd i equivPi k .snd .equiv-proof f .snd (g , p) i .fst x = equivCtrPath (k x) (f x) (g x , λ j → p j x) i .fst equivPi k .snd .equiv-proof f .snd (g , p) i .snd j x = equivCtrPath (k x) (f x) (g x , λ k → p k x) i .snd j -- Some helpful notation: _≃⟨_⟩_ : (X : Type ℓ) → (X ≃ B) → (B ≃ C) → (X ≃ C) _ ≃⟨ f ⟩ g = compEquiv f g _■ : (X : Type ℓ) → (X ≃ X) _■ = idEquiv infixr 0 _≃⟨_⟩_ infix 1 _■
37.968354
104
0.53759
4bcf9a5295e11636c77d886b8b4439b6dbf831e8
13,962
agda
Agda
examples/outdated-and-incorrect/univ/univ.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
examples/outdated-and-incorrect/univ/univ.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
examples/outdated-and-incorrect/univ/univ.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --no-positivity-check #-} module univ where open import Base open import Nat import Logic.ChainReasoning module Chain {A : Set}( _==_ : A -> A -> Set) (refl : {x : A} -> x == x) (trans : {x y z : A} -> x == y -> y == z -> x == z) = Logic.ChainReasoning.Mono.Homogenous _==_ (\x -> refl) (\x y z -> trans) -- mutual inductive recursive definition of S and the functions _=S_, El, eq, -- and all the proofs on these functions mutual infix 40 _==_ _=S_ _=Fam_ infixr 80 _<<_ infixl 80 _>>_ infixl 150 _!_ data S : Set where nat : S pi : (A : S)(F : Fam A) -> S sigma : (A : S)(F : Fam A) -> S data Fam (A : S) : Set where fam : (F : El A -> S) -> Map _==_ _=S_ F -> Fam A _=S'_ : rel S nat =S' pi _ _ = False nat =S' sigma _ _ = False pi _ _ =S' nat = False pi _ _ =S' sigma _ _ = False sigma _ _ =S' nat = False sigma _ _ =S' pi _ _ = False nat =S' nat = True pi A F =S' pi B G = (B =S A) * \ B=A -> F =Fam G >> B=A sigma A F =S' sigma B G = (A =S B) * \A=B -> F >> A=B =Fam G data _=S_ (A B : S) : Set where eqS : A =S' B -> A =S B El' : S -> Set El' nat = Nat El' (pi A F) = ((x : El A) -> El (F ! x)) * \f -> {x y : El A}(x=y : x == y) -> f x == pFam F x=y << f y El' (sigma A F) = El A * \x -> El (F ! x) data El (A : S) : Set where el : El' A -> El A _=='_ : {A : S} -> rel (El A) _=='_ {nat} (el x) (el y) = x =N y _=='_ {pi A F} (el < f , pf >) (el < g , pg >) = (x : El A) -> f x == g x _=='_ {sigma A F} (el < x , Fx >) (el < y , Fy >) = x == y * \x=y -> Fx == pFam F x=y << Fy data _==_ {A : S}(x y : El A) : Set where eq : x ==' y -> x == y _=Fam_ : {A : S} -> rel (Fam A) F =Fam G = (x : El _) -> F ! x =S G ! x _!_ : {A : S} -> Fam A -> El A -> S fam F _ ! x = F x pFam : {A : S}(F : Fam A) -> Map _==_ _=S_ (_!_ F) pFam (fam F pF) = pF -- Families are contravariant so they cast in the other direction. _>>_ : {A B : S} -> Fam A -> A =S B -> Fam B _>>_ {A}{B} F A=B = fam G pG where G : El B -> S G x = F ! (A=B << x) pG : Map _==_ _=S_ G pG x=y = pFam F (p<< A=B x=y) pfiFam : {A B : S}(p q : A =S B)(F : Fam A) -> F >> p =Fam F >> q pfiFam p q F x = pFam F (pfi p q x) _<<_ : {A B : S} -> A =S B -> El B -> El A _<<_ {nat }{pi _ _ } (eqS ()) _ _<<_ {nat }{sigma _ _ } (eqS ()) _ _<<_ {pi _ _ }{nat } (eqS ()) _ _<<_ {pi _ _ }{sigma _ _ } (eqS ()) _ _<<_ {sigma _ _ }{nat } (eqS ()) _ _<<_ {sigma _ _ }{pi _ _ } (eqS ()) _ _<<_ {nat }{nat } p x = x _<<_ {pi A F }{pi B G } (eqS < B=A , F=G >) (el < g , pg >) = el < f , (\{x}{y} -> pf x y) > where f : (x : El A) -> El (F ! x) f x = F=G x << g (B=A << x) pf : (x y : El A)(x=y : x == y) -> f x == pFam F x=y << f y pf x y x=y = chain> F=G x << g (B=A << x) === F=G x << _ << g (B=A << y) by p<< _ (pg (p<< B=A x=y)) === pFam F x=y << F=G y << g (B=A << y) by pfi2 _ _ _ _ _ where open module C = Chain _==_ (ref {_}) (trans {_}) _<<_ {sigma A F}{sigma B G} (eqS < A=B , F=G >) (el < y , Gy >) = el < A=B << y , F=G y << Gy > p<< : {A B : S}(A=B : A =S B) -> Map _==_ _==_ (_<<_ A=B) p<< {nat}{nat} _ x=y = x=y p<< {pi A F} {pi B G} (eqS < B=A , F=G >) {el < f , pf >} {el < g , pg >} (eq f=g) = eq cf=cg where cf=cg : (x : El A) -> F=G x << f (B=A << x) == F=G x << g (B=A << x) cf=cg x = p<< (F=G x) (f=g (B=A << x)) p<< {sigma A F}{sigma B G}(eqS < A=B , F=G >) {el < x , Gx >}{el < y , Gy >} (eq < x=y , Gx=Gy >) = eq < cx=cy , cGx=cGy > where cx=cy : A=B << x == A=B << y cx=cy = p<< A=B x=y cGx=cGy : F=G x << Gx == pFam F cx=cy << F=G y << Gy cGx=cGy = chain> F=G x << Gx === F=G x << pFam G x=y << Gy by p<< (F=G x) Gx=Gy === pFam F cx=cy << F=G y << Gy by pfi2 _ _ _ _ Gy where open module C = Chain _==_ (ref {_}) (trans {_}) p<< {nat }{pi _ _ } (eqS ()) _ p<< {nat }{sigma _ _} (eqS ()) _ p<< {pi _ _ }{nat } (eqS ()) _ p<< {pi _ _ }{sigma _ _} (eqS ()) _ p<< {sigma _ _}{nat } (eqS ()) _ p<< {sigma _ _}{pi _ _ } (eqS ()) _ refS : Refl _=S_ refS {nat} = eqS T refS {pi A F} = eqS < refS , (\x -> symS (pFam F (ref<< x))) > refS {sigma A F} = eqS < refS , (\x -> pFam F (ref<< x)) > transS : Trans _=S_ transS {nat }{nat }{pi _ _ } _ (eqS ()) transS {nat }{nat }{sigma _ _ } _ (eqS ()) transS {nat }{pi _ _ } (eqS ()) _ transS {nat }{sigma _ _ } (eqS ()) _ transS {pi _ _ }{nat } (eqS ()) _ transS {pi _ _ }{pi _ _ }{nat } _ (eqS ()) transS {pi _ _ }{pi _ _ }{sigma _ _ } _ (eqS ()) transS {pi _ _ }{sigma _ _ } (eqS ()) _ transS {sigma _ _ }{nat } (eqS ()) _ transS {sigma _ _ }{pi _ _ } (eqS ()) _ transS {sigma _ _ }{sigma _ _ }{nat } _ (eqS ()) transS {sigma _ _ }{sigma _ _ }{pi _ _ } _ (eqS ()) transS {nat}{nat}{nat} p q = p transS {pi A F}{pi B G}{pi C H} (eqS < B=A , F=G >) (eqS < C=B , G=H >) = eqS < C=A , F=H > where open module C = Chain _=S_ refS transS C=A = transS C=B B=A F=H : F =Fam H >> C=A F=H x = chain> F ! x === G ! (B=A << x) by F=G x === H ! (C=B << B=A << x) by G=H (B=A << x) === H ! (C=A << x) by pFam H (sym (trans<< C=B B=A x)) transS {sigma A F}{sigma B G}{sigma C H} (eqS < A=B , F=G >)(eqS < B=C , G=H >) = eqS < A=C , F=H > where open module C = Chain _=S_ refS transS A=C = transS A=B B=C F=H : F >> A=C =Fam H F=H x = chain> F ! (A=C << x) === F ! (A=B << B=C << x) by pFam F (trans<< A=B B=C x) === G ! (B=C << x) by F=G (B=C << x) === H ! x by G=H x symS : Sym _=S_ symS {nat }{pi _ _ } (eqS ()) symS {nat }{sigma _ _ } (eqS ()) symS {pi _ _ }{nat } (eqS ()) symS {pi _ _ }{sigma _ _ } (eqS ()) symS {sigma _ _ }{nat } (eqS ()) symS {sigma _ _ }{pi _ _ } (eqS ()) symS {nat}{nat} p = p symS {pi A F}{pi B G} (eqS < B=A , F=G >) = eqS < A=B , G=F > where open module C = Chain _=S_ refS transS A=B = symS B=A G=F : G =Fam F >> A=B G=F x = symS ( chain> F ! (A=B << x) === G ! (B=A << A=B << x) by F=G (A=B << x) === G ! (refS << x) by pFam G (casttrans B=A A=B refS x) === G ! x by pFam G (ref<< x) ) symS {sigma A F}{sigma B G}(eqS < A=B , F=G >) = eqS < B=A , G=F > where open module C = Chain _=S_ refS transS B=A = symS A=B G=F : G >> B=A =Fam F G=F x = chain> G ! (B=A << x) === F ! (A=B << B=A << x) by symS (F=G _) === F ! (refS << x) by pFam F (casttrans _ _ _ x) === F ! x by pFam F (castref _ x) pfi : {A B : S}(p q : A =S B)(x : El B) -> p << x == q << x pfi {nat }{pi _ _ } (eqS ()) _ _ pfi {nat }{sigma _ _ } (eqS ()) _ _ pfi {pi _ _ }{nat } (eqS ()) _ _ pfi {pi _ _ }{sigma _ _ } (eqS ()) _ _ pfi {sigma _ _ }{nat } (eqS ()) _ _ pfi {sigma _ _ }{pi _ _ } (eqS ()) _ _ pfi {nat}{nat} _ _ x = ref pfi {pi A F}{pi B G} (eqS < B=A1 , F=G1 >) (eqS < B=A2 , F=G2 >) (el < g , pg >) = eq g1=g2 where g1=g2 : (x : El A) -> F=G1 x << g (B=A1 << x) == F=G2 x << g (B=A2 << x) g1=g2 x = chain> F=G1 x << g (B=A1 << x) === F=G1 x << _ << g (B=A2 << x) by p<< _ (pg (pfi B=A1 B=A2 x)) === F=G2 x << g (B=A2 << x) by casttrans _ _ _ _ where open module C = Chain _==_ (ref {_}) (trans {_}) pfi {sigma A F}{sigma B G} (eqS < A=B1 , F=G1 >) (eqS < A=B2 , F=G2 >) (el < y , Gy >) = eq < x1=x2 , Fx1=Fx2 > where x1=x2 : A=B1 << y == A=B2 << y x1=x2 = pfi A=B1 A=B2 y Fx1=Fx2 : F=G1 y << Gy == pFam F x1=x2 << F=G2 y << Gy Fx1=Fx2 = sym (casttrans _ _ _ _) ref<< : {A : S}(x : El A) -> refS << x == x ref<< {nat} x = ref ref<< {sigma A F} (el < x , Fx >) = eq < ref<< x , pfi _ _ Fx > ref<< {pi A F } (el < f , pf >) = eq rf=f where rf=f : (x : El A) -> _ << f (refS << x) == f x rf=f x = chain> _ << f (refS << x) === _ << pFam F (ref<< x) << f x by p<< _ (pf (ref<< x)) === _ << f x by sym (trans<< _ _ (f x)) === f x by castref _ _ where open module C = Chain _==_ (ref {_}) (trans {_}) trans<< : {A B C : S}(A=B : A =S B)(B=C : B =S C)(x : El C) -> transS A=B B=C << x == A=B << B=C << x trans<< {nat }{nat }{pi _ _ } _ (eqS ()) _ trans<< {nat }{nat }{sigma _ _ } _ (eqS ()) _ trans<< {nat }{pi _ _ } (eqS ()) _ _ trans<< {nat }{sigma _ _ } (eqS ()) _ _ trans<< {pi _ _ }{nat } (eqS ()) _ _ trans<< {pi _ _ }{pi _ _ }{nat } _ (eqS ()) _ trans<< {pi _ _ }{pi _ _ }{sigma _ _ } _ (eqS ()) _ trans<< {pi _ _ }{sigma _ _ } (eqS ()) _ _ trans<< {sigma _ _ }{nat } (eqS ()) _ _ trans<< {sigma _ _ }{pi _ _ } (eqS ()) _ _ trans<< {sigma _ _ }{sigma _ _ }{nat } _ (eqS ()) _ trans<< {sigma _ _ }{sigma _ _ }{pi _ _ } _ (eqS ()) _ trans<< {nat}{nat}{nat} _ _ _ = ref trans<< {pi A F}{pi B G}{pi C H} (eqS < B=A , F=G >)(eqS < C=B , G=H >) (el < h , ph >) = eq prf where C=A = transS C=B B=A prf : (x : El A) -> _ prf x = chain> _ << h (C=A << x) === _ << _ << h (C=B << B=A << x) by p<< _ (ph (trans<< _ _ x)) === F=G x << G=H _ << h (_ << _ << x) by pfi2 _ _ _ _ _ where open module C' = Chain _==_ (ref {_}) (trans {_}) trans<< {sigma A F}{sigma B G}{sigma C H} (eqS < A=B , F=G >)(eqS < B=C , G=H >) (el < z , Hz >) = eq < trans<< A=B B=C z , prf > where prf = chain> _ << Hz === _ << Hz by pfi _ _ _ === _ << _ << Hz by trans<< _ _ _ === _ << F=G _ << G=H z << Hz by trans<< _ _ _ where open module C' = Chain _==_ (ref {_}) (trans {_}) -- we never need this one, but it feels like it should be here... sym<< : {A B : S}(A=B : A =S B)(x : El B) -> symS A=B << A=B << x == x sym<< A=B x = chain> symS A=B << A=B << x === refS << x by casttrans _ _ _ x === x by ref<< x where open module C' = Chain _==_ (ref {_}) (trans {_}) castref : {A : S}(p : A =S A)(x : El A) -> p << x == x castref A=A x = chain> A=A << x === refS << x by pfi A=A refS x === x by ref<< x where open module C = Chain _==_ (ref {_}) (trans {_}) casttrans : {A B C : S}(A=B : A =S B)(B=C : B =S C)(A=C : A =S C)(x : El C) -> A=B << B=C << x == A=C << x casttrans A=B B=C A=C x = chain> A=B << B=C << x === _ << x by sym (trans<< _ _ _) === A=C << x by pfi _ _ _ where open module C' = Chain _==_ (ref {_}) (trans {_}) pfi2 : {A B1 B2 C : S} (A=B1 : A =S B1)(A=B2 : A =S B2)(B1=C : B1 =S C)(B2=C : B2 =S C) (x : El C) -> A=B1 << B1=C << x == A=B2 << B2=C << x pfi2 A=B1 A=B2 B1=C B2=C x = chain> A=B1 << B1=C << x === _ << x by casttrans _ _ _ x === A=B2 << B2=C << x by trans<< _ _ x where open module C = Chain _==_ (ref {_}) (trans {_}) ref : {A : S} -> Refl {El A} _==_ ref {nat} {el n} = eq (refN {n}) ref {pi A F} {el < f , pf >} = eq \x -> ref ref {sigma A F} {el < x , Fx >} = eq < ref , sym (castref _ _) > trans : {A : S} -> Trans {El A} _==_ trans {nat}{el x}{el y}{el z} (eq p) (eq q) = eq (transN {x}{y}{z} p q) trans {pi A F}{el < f , pf >}{el < g , pg >}{el < h , ph >} (eq f=g)(eq g=h) = eq \x -> trans (f=g x) (g=h x) trans {sigma A F}{el < x , Fx >}{el < y , Fy >}{el < z , Fz >} (eq < x=y , Fx=Fy >)(eq < y=z , Fy=Fz >) = eq < x=z , Fx=Fz > where x=z = trans x=y y=z Fx=Fz = chain> Fx === pFam F x=y << Fy by Fx=Fy === pFam F x=y << pFam F y=z << Fz by p<< _ Fy=Fz === pFam F x=z << Fz by casttrans _ _ _ _ where open module C = Chain _==_ (ref {_}) (trans {_}) sym : {A : S} -> Sym {El A} _==_ sym {nat}{el x}{el y} (eq p) = eq (symN {x}{y} p) sym {pi A F}{el < f , pf >}{el < g , pg >} (eq f=g) = eq \x -> sym (f=g x) sym {sigma A F}{el < x , Fx >}{el < y , Fy >} (eq < x=y , Fx=Fy >) = eq < y=x , Fy=Fx > where y=x = sym x=y Fy=Fx = sym ( chain> pFam F y=x << Fx === pFam F y=x << pFam F x=y << Fy by p<< (pFam F y=x) Fx=Fy === refS << Fy by casttrans _ _ _ _ === Fy by castref _ _ ) where open module C = Chain _==_ (ref {_}) (trans {_}) refFam : {A : S} -> Refl (_=Fam_ {A}) refFam x = refS transFam : {A : S} -> Trans (_=Fam_ {A}) transFam F=G G=H x = transS (F=G x) (G=H x) symFam : {A : S} -> Sym (_=Fam_ {A}) symFam F=G x = symS (F=G x) castref2 : {A B : S}(A=B : A =S B)(B=A : B =S A)(x : El A) -> A=B << B=A << x == x castref2 A=B B=A x = trans (casttrans A=B B=A refS x) (ref<< x)
36.742105
80
0.387767
35fc5ee37c9192e94782d563726ffe6f56668e32
2,511
agda
Agda
src/Equality/Propositional.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
3
2020-05-21T22:58:50.000Z
2021-09-02T17:18:15.000Z
src/Equality/Propositional.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
null
null
null
src/Equality/Propositional.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Propositional equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Equality.Propositional where open import Equality open import Logical-equivalence hiding (_∘_) open import Prelude ------------------------------------------------------------------------ -- Equality open import Agda.Builtin.Equality public using (_≡_; refl) private refl′ : ∀ {a} {A : Type a} (x : A) → x ≡ x refl′ x = refl elim : ∀ {a p} {A : Type a} {x y} (P : {x y : A} → x ≡ y → Type p) → (∀ x → P (refl′ x)) → (x≡y : x ≡ y) → P x≡y elim P r refl = r _ elim-refl : ∀ {a p} {A : Type a} {x} (P : {x y : A} → x ≡ y → Type p) (r : ∀ x → P (refl′ x)) → elim P r (refl′ x) ≡ r x elim-refl P r = refl ------------------------------------------------------------------------ -- Various derived definitions and properties reflexive-relation : ∀ ℓ → Reflexive-relation ℓ Reflexive-relation._≡_ (reflexive-relation _) = _≡_ Reflexive-relation.refl (reflexive-relation _) = refl′ equality-with-J₀ : ∀ {a p} → Equality-with-J₀ a p reflexive-relation Equality-with-J₀.elim equality-with-J₀ = elim Equality-with-J₀.elim-refl equality-with-J₀ = elim-refl equivalence-relation⁺ : ∀ ℓ → Equivalence-relation⁺ ℓ equivalence-relation⁺ _ = J₀⇒Equivalence-relation⁺ equality-with-J₀ -- The following definition has been expanded in order to ensure that -- it does not reduce (unless a projection is applied to it). equality-with-J : ∀ {a p} → Equality-with-J a p equivalence-relation⁺ equality-with-J .Equality-with-J.equality-with-J₀ = J₀⇒J equality-with-J₀ .Equality-with-J.equality-with-J₀ equality-with-J .Equality-with-J.cong = J₀⇒J equality-with-J₀ .Equality-with-J.cong equality-with-J .Equality-with-J.cong-refl = J₀⇒J equality-with-J₀ .Equality-with-J.cong-refl equality-with-J .Equality-with-J.subst = J₀⇒J equality-with-J₀ .Equality-with-J.subst equality-with-J .Equality-with-J.subst-refl = J₀⇒J equality-with-J₀ .Equality-with-J.subst-refl equality-with-J .Equality-with-J.dcong = J₀⇒J equality-with-J₀ .Equality-with-J.dcong equality-with-J .Equality-with-J.dcong-refl = J₀⇒J equality-with-J₀ .Equality-with-J.dcong-refl open Derived-definitions-and-properties equality-with-J public hiding (_≡_; refl; reflexive-relation; equality-with-J₀)
39.857143
107
0.585026
34de47eb49a40fca6baad10e6640577a5c8f439a
840
agda
Agda
Tools/Product.agda
Vtec234/logrel-mltt
4746894adb5b8edbddc8463904ee45c2e9b29b69
[ "MIT" ]
null
null
null
Tools/Product.agda
Vtec234/logrel-mltt
4746894adb5b8edbddc8463904ee45c2e9b29b69
[ "MIT" ]
null
null
null
Tools/Product.agda
Vtec234/logrel-mltt
4746894adb5b8edbddc8463904ee45c2e9b29b69
[ "MIT" ]
null
null
null
-- Σ type (also used as existential) and -- cartesian product (also used as conjunction). {-# OPTIONS --without-K --safe #-} module Tools.Product where open import Agda.Primitive open import Agda.Builtin.Sigma public using (Σ; _,_) open import Agda.Builtin.Sigma using (fst; snd) infixr 2 _×_ -- Dependent pair type (aka dependent sum, Σ type). private variable ℓ₁ ℓ₂ ℓ₃ : Level proj₁ : ∀ {A : Set ℓ₁} {B : A → Set ℓ₂} → Σ A B → A proj₁ = fst proj₂ : ∀ {A : Set ℓ₁} {B : A → Set ℓ₂} → (S : Σ A B) → B (fst S) proj₂ = snd -- Existential quantification. ∃ : {A : Set ℓ₁} → (A → Set ℓ₂) → Set (ℓ₁ ⊔ ℓ₂) ∃ = Σ _ ∃₂ : {A : Set ℓ₁} {B : A → Set ℓ₂} (C : (x : A) → B x → Set ℓ₃) → Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) ∃₂ C = ∃ λ a → ∃ λ b → C a b -- Cartesian product. _×_ : (A : Set ℓ₁) (B : Set ℓ₂) → Set (ℓ₁ ⊔ ℓ₂) A × B = Σ A (λ x → B)
21.538462
65
0.567857
fd14a18395301abbac8171ccf38247c9b07aab4f
2,247
agda
Agda
Algebra/Construct/Cayley/Propositional.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
Algebra/Construct/Cayley/Propositional.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
null
null
null
Algebra/Construct/Cayley/Propositional.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --cubical --safe --prop #-} open import Algebra open import Prelude open import Relation.Binary.Equivalence.PropTruncated module Algebra.Construct.Cayley.Propositional {a} (mon : Monoid a) where open Monoid mon record 𝒞 : Type a where constructor cayley infixr 7 _⇓_ field _⇓_ : 𝑆 → 𝑆 small : ∀ x → _⇓_ ε ∙ x ≐ _⇓_ x open 𝒞 public ⟦_⇓⟧ : 𝒞 → 𝑆 ⟦ x ⇓⟧ = x ⇓ ε ⟦_⇑⟧ : 𝑆 → 𝒞 ⟦ x ⇑⟧ ⇓ y = x ∙ y ⟦ x ⇑⟧ .small y = ∣ cong (_∙ y) (∙ε x) ∣ ⓔ : 𝒞 ⓔ ⇓ x = x ⓔ .small x = ∣ ε∙ x ∣ module _ where open Reasoning _⊙_ : 𝒞 → 𝒞 → 𝒞 (x ⊙ y) ⇓ z = x ⇓ y ⇓ z (x ⊙ y) .small z = x ⇓ y ⇓ ε ∙ z ≐˘⟨ ∙cong (_∙ z) (x .small (y ⇓ ε)) ⟩ x ⇓ ε ∙ y ⇓ ε ∙ z ≡⟨ assoc (x ⇓ ε) (y ⇓ ε) z ⟩ x ⇓ ε ∙ (y ⇓ ε ∙ z) ≐⟨ ∙cong (x ⇓ ε ∙_) (y .small z) ⟩ x ⇓ ε ∙ y ⇓ z ≐⟨ x .small (y ⇓ z) ⟩ x ⇓ y ⇓ z ∎ ⊙-assoc : Associative _⊙_ ⊙-assoc x y z = refl ⓔ⊙ : ∀ x → ⓔ ⊙ x ≡ x ⓔ⊙ x = refl ⊙ⓔ : ∀ x → x ⊙ ⓔ ≡ x ⊙ⓔ x = refl cayleyMonoid : Monoid a Monoid.𝑆 cayleyMonoid = 𝒞 Monoid._∙_ cayleyMonoid = _⊙_ Monoid.ε cayleyMonoid = ⓔ Monoid.assoc cayleyMonoid = ⊙-assoc Monoid.ε∙ cayleyMonoid = ⓔ⊙ Monoid.∙ε cayleyMonoid = ⊙ⓔ open import Data.Sigma.Properties open import Relation.Nullary.Stable 𝒞≡ : {x y : 𝒞} → (∀ z → x ⇓ z ≡ y ⇓ z) → x ≡ y 𝒞≡ { f } { cayley g q } f≡g = subst (λ (g′ : 𝑆 → 𝑆) → (q′ : ∀ x → g′ ε ∙ x ≐ g′ x) → f ≡ cayley g′ q′) (funExt f≡g) (λ _ → refl) q ∙-homo : ∀ x y → ⟦ x ∙ y ⇑⟧ ≡ ⟦ x ⇑⟧ ⊙ ⟦ y ⇑⟧ ∙-homo x y = 𝒞≡ (assoc x y) ε-homo : ⟦ ε ⇑⟧ ≡ ⓔ ε-homo = 𝒞≡ ε∙ homo-to : MonoidHomomorphism mon ⟶ cayleyMonoid MonoidHomomorphism_⟶_.f homo-to = ⟦_⇑⟧ MonoidHomomorphism_⟶_.∙-homo homo-to = ∙-homo MonoidHomomorphism_⟶_.ε-homo homo-to = ε-homo ⓔ-homo : ⟦ ⓔ ⇓⟧ ≡ ε ⓔ-homo = refl module _ (sIsStable : ∀ {x y : 𝑆} → Stable (x ≡ y)) where ⊙-homo : ∀ x y → ⟦ x ⊙ y ⇓⟧ ≡ ⟦ x ⇓⟧ ∙ ⟦ y ⇓⟧ ⊙-homo x y = sym (unsquash sIsStable (x .small ⟦ y ⇓⟧)) 𝒞-iso : 𝒞 ⇔ 𝑆 fun 𝒞-iso = ⟦_⇓⟧ inv 𝒞-iso = ⟦_⇑⟧ rightInv 𝒞-iso = ∙ε leftInv 𝒞-iso x = 𝒞≡ λ y → unsquash sIsStable (x .small y) homo-from : MonoidHomomorphism cayleyMonoid ⟶ mon MonoidHomomorphism_⟶_.f homo-from = ⟦_⇓⟧ MonoidHomomorphism_⟶_.∙-homo homo-from = ⊙-homo MonoidHomomorphism_⟶_.ε-homo homo-from = ⓔ-homo
23.164948
72
0.53182
30e23ef44b2be7036aa8b2d756b36dcb6d3807c2
50
agda
Agda
test/interaction/Issue2162.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue2162.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue2162.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
record ⊤ : Set where abstract a : ⊤ a = {!!}
8.333333
20
0.48
046926637689b29893de0b63363235f05308ca32
867
agda
Agda
Cubical/HITs/S1/Properties.agda
Rotsor/cubical
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
[ "MIT" ]
null
null
null
Cubical/HITs/S1/Properties.agda
Rotsor/cubical
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
[ "MIT" ]
null
null
null
Cubical/HITs/S1/Properties.agda
Rotsor/cubical
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.S1.Properties where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.HITs.S1.Base open import Cubical.HITs.PropositionalTruncation isConnectedS¹ : (s : S¹) → ∥ base ≡ s ∥ isConnectedS¹ base = ∣ refl ∣ isConnectedS¹ (loop i) = squash ∣ (λ j → loop (i ∧ j)) ∣ ∣ (λ j → loop (i ∨ ~ j)) ∣ i isGroupoidS¹ : isGroupoid S¹ isGroupoidS¹ s t = recPropTrunc isPropIsSet (λ p → subst (λ s → isSet (s ≡ t)) p (recPropTrunc isPropIsSet (λ q → subst (λ t → isSet (base ≡ t)) q isSetΩS¹) (isConnectedS¹ t))) (isConnectedS¹ s)
27.967742
62
0.701269
d1c177ab3bbaee2ccfcb613104d751d1c762fd00
15,459
agda
Agda
Cubical/Categories/Instances/CommAlgebras.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
1
2021-10-31T17:32:49.000Z
2021-10-31T17:32:49.000Z
Cubical/Categories/Instances/CommAlgebras.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
Cubical/Categories/Instances/CommAlgebras.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Categories.Instances.CommAlgebras where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Powerset open import Cubical.Foundations.HLevels open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.Algebra open import Cubical.Algebra.CommAlgebra open import Cubical.Algebra.CommAlgebra.Instances.Unit open import Cubical.Categories.Category open import Cubical.Categories.Functor.Base open import Cubical.Categories.Limits.Terminal open import Cubical.Categories.Limits.Pullback open import Cubical.Categories.Instances.CommRings open import Cubical.HITs.PropositionalTruncation open Category hiding (_∘_) renaming (_⋆_ to _⋆c_) open CommAlgebraHoms open Cospan open Pullback private variable ℓ ℓ' ℓ'' : Level module _ (R : CommRing ℓ) where CommAlgebrasCategory : Category (ℓ-suc (ℓ-max ℓ ℓ')) (ℓ-max ℓ ℓ') ob CommAlgebrasCategory = CommAlgebra R _ Hom[_,_] CommAlgebrasCategory = CommAlgebraHom id CommAlgebrasCategory {A} = idCommAlgebraHom A _⋆c_ CommAlgebrasCategory {A} {B} {C} = compCommAlgebraHom A B C ⋆IdL CommAlgebrasCategory {A} {B} = compIdCommAlgebraHom {A = A} {B} ⋆IdR CommAlgebrasCategory {A} {B} = idCompCommAlgebraHom {A = A} {B} ⋆Assoc CommAlgebrasCategory {A} {B} {C} {D} = compAssocCommAlgebraHom {A = A} {B} {C} {D} isSetHom CommAlgebrasCategory = isSetAlgebraHom _ _ TerminalCommAlgebra : Terminal (CommAlgebrasCategory {ℓ' = ℓ'}) fst TerminalCommAlgebra = UnitCommAlgebra R fst (fst (snd TerminalCommAlgebra A)) = λ _ → tt* snd (fst (snd TerminalCommAlgebra A)) = makeIsAlgebraHom refl (λ _ _ → refl) (λ _ _ → refl) (λ _ _ → refl) snd (snd TerminalCommAlgebra A) f = AlgebraHom≡ (funExt (λ _ → refl)) module PullbackFromCommRing (R : CommRing ℓ) (commRingCospan : Cospan (CommRingsCategory {ℓ = ℓ})) (commRingPB : Pullback _ commRingCospan) (f₁ : CommRingHom R (commRingPB .pbOb)) (f₂ : CommRingHom R (commRingCospan .r)) (f₃ : CommRingHom R (commRingCospan .l)) (f₄ : CommRingHom R (commRingCospan .m)) where open AlgebraHoms open CommAlgChar R open CommAlgebraStr ⦃...⦄ private CommAlgCat = CommAlgebrasCategory {ℓ = ℓ} R {ℓ' = ℓ} A = commRingPB .pbOb B = commRingCospan .r C = commRingCospan .l D = commRingCospan .m g₁ = commRingPB .pbPr₂ g₂ = commRingPB .pbPr₁ g₃ = commRingCospan .s₂ g₄ = commRingCospan .s₁ {- g₁ A → B ⌟ g₂ ↓ ↓ g₃ C → D g₄ -} open RingHoms univPropCommRingWithHomHom : (isRHom₁ : isCommRingWithHomHom (A , f₁) (B , f₂) g₁) (isRHom₂ : isCommRingWithHomHom (A , f₁) (C , f₃) g₂) (isRHom₃ : isCommRingWithHomHom (B , f₂) (D , f₄) g₃) (isRHom₄ : isCommRingWithHomHom (C , f₃) (D , f₄) g₄) (E,f₅ : CommRingWithHom) (h₂ : CommRingWithHomHom E,f₅ (C , f₃)) (h₁ : CommRingWithHomHom E,f₅ (B , f₂)) → g₄ ∘r fst h₂ ≡ g₃ ∘r fst h₁ → ∃![ h₃ ∈ CommRingWithHomHom E,f₅ (A , f₁) ] (fst h₂ ≡ g₂ ∘r fst h₃) × (fst h₁ ≡ g₁ ∘r fst h₃) univPropCommRingWithHomHom isRHom₁ isRHom₂ isRHom₃ isRHom₄ (E , f₅) (h₂ , comm₂) (h₁ , comm₁) squareComm = ((h₃ , h₃∘f₅≡f₁) , h₂≡g₂∘h₃ , h₁≡g₁∘h₃) , λ h₃' → Σ≡Prop (λ _ → isProp× (isSetRingHom _ _ _ _) (isSetRingHom _ _ _ _)) (Σ≡Prop (λ _ → isSetRingHom _ _ _ _) (cong fst (commRingPB .univProp h₂ h₁ squareComm .snd (h₃' .fst .fst , h₃' .snd .fst , h₃' .snd .snd)))) where h₃ : CommRingHom E A h₃ = commRingPB .univProp h₂ h₁ squareComm .fst .fst h₂≡g₂∘h₃ : h₂ ≡ g₂ ∘r h₃ h₂≡g₂∘h₃ = commRingPB .univProp h₂ h₁ squareComm .fst .snd .fst h₁≡g₁∘h₃ : h₁ ≡ g₁ ∘r h₃ h₁≡g₁∘h₃ = commRingPB .univProp h₂ h₁ squareComm .fst .snd .snd -- the crucial obervation: -- we can apply the universal property to maps R → A fgSquare : g₄ ∘r f₃ ≡ g₃ ∘r f₂ fgSquare = isRHom₄ ∙ sym isRHom₃ h₃∘f₅≡f₁ : h₃ ∘r f₅ ≡ f₁ h₃∘f₅≡f₁ = cong fst (isContr→isProp (commRingPB .univProp f₃ f₂ fgSquare) (h₃ ∘r f₅ , triangle1 , triangle2) (f₁ , (sym isRHom₂) , sym isRHom₁)) where triangle1 : f₃ ≡ g₂ ∘r (h₃ ∘r f₅) triangle1 = sym comm₂ ∙∙ cong (compRingHom f₅) h₂≡g₂∘h₃ ∙∙ sym (compAssocRingHom f₅ h₃ g₂) triangle2 : f₂ ≡ g₁ ∘r (h₃ ∘r f₅) triangle2 = sym comm₁ ∙∙ cong (compRingHom f₅) h₁≡g₁∘h₃ ∙∙ sym (compAssocRingHom f₅ h₃ g₁) algCospan : (isRHom₁ : isCommRingWithHomHom (A , f₁) (B , f₂) g₁) (isRHom₂ : isCommRingWithHomHom (A , f₁) (C , f₃) g₂) (isRHom₃ : isCommRingWithHomHom (B , f₂) (D , f₄) g₃) (isRHom₄ : isCommRingWithHomHom (C , f₃) (D , f₄) g₄) → Cospan CommAlgCat l (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (C , f₃) m (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (D , f₄) r (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (B , f₂) s₁ (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₄ isRHom₄ s₂ (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₃ isRHom₃ algPullback : (isRHom₁ : isCommRingWithHomHom (A , f₁) (B , f₂) g₁) (isRHom₂ : isCommRingWithHomHom (A , f₁) (C , f₃) g₂) (isRHom₃ : isCommRingWithHomHom (B , f₂) (D , f₄) g₃) (isRHom₄ : isCommRingWithHomHom (C , f₃) (D , f₄) g₄) → Pullback CommAlgCat (algCospan isRHom₁ isRHom₂ isRHom₃ isRHom₄) pbOb (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlg (A , f₁) pbPr₁ (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₂ isRHom₂ pbPr₂ (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) = toCommAlgebraHom _ _ g₁ isRHom₁ pbCommutes (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) = AlgebraHom≡ (cong fst (pbCommutes commRingPB)) univProp (algPullback isRHom₁ isRHom₂ isRHom₃ isRHom₄) {d = F} h₂' h₁' g₄∘h₂'≡g₃∘h₁' = (k , kComm₂ , kComm₁) , uniqueness where E = fromCommAlg F .fst f₅ = fromCommAlg F .snd h₁ : CommRingHom E B fst h₁ = fst h₁' IsRingHom.pres0 (snd h₁) = IsAlgebraHom.pres0 (snd h₁') IsRingHom.pres1 (snd h₁) = IsAlgebraHom.pres1 (snd h₁') IsRingHom.pres+ (snd h₁) = IsAlgebraHom.pres+ (snd h₁') IsRingHom.pres· (snd h₁) = IsAlgebraHom.pres· (snd h₁') IsRingHom.pres- (snd h₁) = IsAlgebraHom.pres- (snd h₁') h₁comm : h₁ ∘r f₅ ≡ f₂ h₁comm = RingHom≡ (funExt (λ x → IsAlgebraHom.pres⋆ (snd h₁') x 1a ∙∙ cong (fst f₂ x ·_) (IsAlgebraHom.pres1 (snd h₁')) ∙∙ ·Rid _)) where instance _ = snd F _ = snd (toCommAlg (B , f₂)) h₂ : CommRingHom E C fst h₂ = fst h₂' IsRingHom.pres0 (snd h₂) = IsAlgebraHom.pres0 (snd h₂') IsRingHom.pres1 (snd h₂) = IsAlgebraHom.pres1 (snd h₂') IsRingHom.pres+ (snd h₂) = IsAlgebraHom.pres+ (snd h₂') IsRingHom.pres· (snd h₂) = IsAlgebraHom.pres· (snd h₂') IsRingHom.pres- (snd h₂) = IsAlgebraHom.pres- (snd h₂') h₂comm : h₂ ∘r f₅ ≡ f₃ h₂comm = RingHom≡ (funExt (λ x → IsAlgebraHom.pres⋆ (snd h₂') x 1a ∙∙ cong (fst f₃ x ·_) (IsAlgebraHom.pres1 (snd h₂')) ∙∙ ·Rid _)) where instance _ = snd F _ = snd (toCommAlg (C , f₃)) commRingSquare : g₄ ∘r h₂ ≡ g₃ ∘r h₁ commRingSquare = RingHom≡ (funExt (λ x → funExt⁻ (cong fst g₄∘h₂'≡g₃∘h₁') x)) uniqueH₃ : ∃![ h₃ ∈ CommRingWithHomHom (E , f₅) (A , f₁) ] (h₂ ≡ g₂ ∘r fst h₃) × (h₁ ≡ g₁ ∘r fst h₃) uniqueH₃ = univPropCommRingWithHomHom isRHom₁ isRHom₂ isRHom₃ isRHom₄ (E , f₅) (h₂ , h₂comm) (h₁ , h₁comm) commRingSquare h₃ : CommRingHom E A h₃ = uniqueH₃ .fst .fst .fst h₃comm = uniqueH₃ .fst .fst .snd k : CommAlgebraHom F (toCommAlg (A , f₁)) fst k = fst h₃ IsAlgebraHom.pres0 (snd k) = IsRingHom.pres0 (snd h₃) IsAlgebraHom.pres1 (snd k) = IsRingHom.pres1 (snd h₃) IsAlgebraHom.pres+ (snd k) = IsRingHom.pres+ (snd h₃) IsAlgebraHom.pres· (snd k) = IsRingHom.pres· (snd h₃) IsAlgebraHom.pres- (snd k) = IsRingHom.pres- (snd h₃) IsAlgebraHom.pres⋆ (snd k) = λ r y → sym (fst f₁ r · fst h₃ y ≡⟨ cong (_· fst h₃ y) (sym (funExt⁻ (cong fst h₃comm) r)) ⟩ fst h₃ (fst f₅ r) · fst h₃ y ≡⟨ sym (IsRingHom.pres· (snd h₃) _ _) ⟩ fst h₃ (fst f₅ r · y) ≡⟨ refl ⟩ fst h₃ ((r ⋆ 1a) · y) ≡⟨ cong (fst h₃) (⋆-lassoc _ _ _) ⟩ fst h₃ (r ⋆ (1a · y)) ≡⟨ cong (λ x → fst h₃ (r ⋆ x)) (·Lid y) ⟩ fst h₃ (r ⋆ y) ∎) where instance _ = snd F _ = (toCommAlg (A , f₁) .snd) kComm₂ : h₂' ≡ toCommAlgebraHom _ _ g₂ isRHom₂ ∘a k kComm₂ = AlgebraHom≡ (cong fst (uniqueH₃ .fst .snd .fst)) kComm₁ : h₁' ≡ toCommAlgebraHom _ _ g₁ isRHom₁ ∘a k kComm₁ = AlgebraHom≡ (cong fst (uniqueH₃ .fst .snd .snd)) uniqueness : (y : Σ[ k' ∈ CommAlgebraHom F (toCommAlg (A , f₁)) ] (h₂' ≡ toCommAlgebraHom _ _ g₂ isRHom₂ ∘a k') × (h₁' ≡ toCommAlgebraHom _ _ g₁ isRHom₁ ∘a k')) → (k , kComm₂ , kComm₁) ≡ y uniqueness (k' , k'Comm₂ , k'Comm₁) = Σ≡Prop (λ _ → isProp× (isSetAlgebraHom _ _ _ _) (isSetAlgebraHom _ _ _ _)) (AlgebraHom≡ (cong (fst ∘ fst ∘ fst) uniqHelper)) where h₃' : CommRingHom E A fst h₃' = fst k' IsRingHom.pres0 (snd h₃') = IsAlgebraHom.pres0 (snd k') IsRingHom.pres1 (snd h₃') = IsAlgebraHom.pres1 (snd k') IsRingHom.pres+ (snd h₃') = IsAlgebraHom.pres+ (snd k') IsRingHom.pres· (snd h₃') = IsAlgebraHom.pres· (snd k') IsRingHom.pres- (snd h₃') = IsAlgebraHom.pres- (snd k') h₃'IsRHom : h₃' ∘r f₅ ≡ f₁ h₃'IsRHom = RingHom≡ (funExt (λ x → IsAlgebraHom.pres⋆ (snd k') x 1a ∙ cong (fst f₁ x ·_) (IsAlgebraHom.pres1 (snd k')) ∙ ·Rid (fst f₁ x))) where instance _ = snd F _ = (toCommAlg (A , f₁) .snd) h₃'Comm₂ : h₂ ≡ g₂ ∘r h₃' h₃'Comm₂ = RingHom≡ (cong fst k'Comm₂) h₃'Comm₁ : h₁ ≡ g₁ ∘r h₃' h₃'Comm₁ = RingHom≡ (cong fst k'Comm₁) -- basically saying that h₃≡h₃' but we have to give all the commuting triangles uniqHelper : uniqueH₃ .fst ≡ ((h₃' , h₃'IsRHom) , h₃'Comm₂ , h₃'Comm₁) uniqHelper = uniqueH₃ .snd ((h₃' , h₃'IsRHom) , h₃'Comm₂ , h₃'Comm₁) module PreSheafFromUniversalProp (C : Category ℓ ℓ') (P : ob C → Type ℓ) {R : CommRing ℓ''} (𝓕 : Σ (ob C) P → CommAlgebra R ℓ'') (uniqueHom : ∀ x y → C [ fst x , fst y ] → isContr (CommAlgebraHom (𝓕 y) (𝓕 x))) where private ∥P∥ : ℙ (ob C) ∥P∥ x = ∥ P x ∥₁ , isPropPropTrunc ΣC∥P∥Cat = ΣPropCat C ∥P∥ CommAlgCat = CommAlgebrasCategory {ℓ = ℓ''} R {ℓ' = ℓ''} 𝓕UniqueEquiv : (x : ob C) (p q : P x) → isContr (CommAlgebraEquiv (𝓕 (x , p)) (𝓕 (x , q))) 𝓕UniqueEquiv x = contrCommAlgebraHom→contrCommAlgebraEquiv (curry 𝓕 x) λ p q → uniqueHom _ _ (id C) theMap : (x : ob C) → ∥ P x ∥₁ → CommAlgebra R ℓ'' theMap x = recPT→CommAlgebra (curry 𝓕 x) (λ p q → 𝓕UniqueEquiv x p q .fst) λ p q r → 𝓕UniqueEquiv x p r .snd _ theAction : (x y : ob C) → C [ x , y ] → (p : ∥ P x ∥₁) (q : ∥ P y ∥₁) → isContr (CommAlgebraHom (theMap y q) (theMap x p)) theAction _ _ f = elim2 (λ _ _ → isPropIsContr) λ _ _ → uniqueHom _ _ f open Functor universalPShf : Functor (ΣC∥P∥Cat ^op) CommAlgCat F-ob universalPShf = uncurry theMap F-hom universalPShf {x = x} {y = y} f = theAction _ _ f (y .snd) (x. snd) .fst F-id universalPShf {x = x} = theAction (x .fst) (x .fst) (id C) (x .snd) (x .snd) .snd _ F-seq universalPShf {x = x} {z = z} f g = theAction _ _ (g ⋆⟨ C ⟩ f) (z .snd) (x .snd) .snd _ -- a big transport to help verifying the sheaf property module toSheaf (x y u v : ob ΣC∥P∥Cat) {f : C [ v .fst , y . fst ]} {g : C [ v .fst , u .fst ]} {h : C [ u .fst , x . fst ]} {k : C [ y .fst , x .fst ]} (Csquare : g ⋆⟨ C ⟩ h ≡ f ⋆⟨ C ⟩ k) {- v → y ↓ ↓ u → x -} (AlgCospan : Cospan CommAlgCat) (AlgPB : Pullback _ AlgCospan) (p₁ : AlgPB .pbOb ≡ F-ob universalPShf x) (p₂ : AlgCospan .l ≡ F-ob universalPShf u) (p₃ : AlgCospan .r ≡ F-ob universalPShf y) (p₄ : AlgCospan .m ≡ F-ob universalPShf v) where private -- just: 𝓕 k ⋆ 𝓕 f ≡ 𝓕 h ⋆ 𝓕 g inducedSquare : seq' CommAlgCat {x = F-ob universalPShf x} {y = F-ob universalPShf u} {z = F-ob universalPShf v} (F-hom universalPShf h) (F-hom universalPShf g) ≡ seq' CommAlgCat {x = F-ob universalPShf x} {y = F-ob universalPShf y} {z = F-ob universalPShf v} (F-hom universalPShf k) (F-hom universalPShf f) inducedSquare = F-square universalPShf Csquare f' = F-hom universalPShf {x = y} {y = v} f g' = F-hom universalPShf {x = u} {y = v} g h' = F-hom universalPShf {x = x} {y = u} h k' = F-hom universalPShf {x = x} {y = y} k gPathP : PathP (λ i → CommAlgCat [ p₂ i , p₄ i ]) (AlgCospan .s₁) g' gPathP = toPathP (sym (theAction _ _ g (v .snd) (u .snd) .snd _)) fPathP : PathP (λ i → CommAlgCat [ p₃ i , p₄ i ]) (AlgCospan .s₂) f' fPathP = toPathP (sym (theAction _ _ f (v .snd) (y .snd) .snd _)) kPathP : PathP (λ i → CommAlgCat [ p₁ i , p₃ i ]) (AlgPB .pbPr₂) k' kPathP = toPathP (sym (theAction _ _ k (y .snd) (x .snd) .snd _)) hPathP : PathP (λ i → CommAlgCat [ p₁ i , p₂ i ]) (AlgPB .pbPr₁) h' hPathP = toPathP (sym (theAction _ _ h (u .snd) (x .snd) .snd _)) fgCospan : Cospan CommAlgCat l fgCospan = F-ob universalPShf u m fgCospan = F-ob universalPShf v r fgCospan = F-ob universalPShf y s₁ fgCospan = g' s₂ fgCospan = f' cospanPath : AlgCospan ≡ fgCospan l (cospanPath i) = p₂ i m (cospanPath i) = p₄ i r (cospanPath i) = p₃ i s₁ (cospanPath i) = gPathP i s₂ (cospanPath i) = fPathP i squarePathP : PathP (λ i → hPathP i ⋆⟨ CommAlgCat ⟩ gPathP i ≡ kPathP i ⋆⟨ CommAlgCat ⟩ fPathP i) (AlgPB .pbCommutes) inducedSquare squarePathP = toPathP (CommAlgCat .isSetHom _ _ _ _) abstract lemma : isPullback CommAlgCat fgCospan {c = F-ob universalPShf x} h' k' inducedSquare lemma = transport (λ i → isPullback CommAlgCat (cospanPath i) {c = p₁ i} (hPathP i) (kPathP i) (squarePathP i)) (AlgPB .univProp)
42.237705
102
0.5697
ad26fe9c64a39bca297a77b0017e60c22171c2b9
1,591
agda
Agda
src/Categories/Category/Construction/Monoids.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Category/Construction/Monoids.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Category/Construction/Monoids.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core open import Categories.Category.Monoidal.Core -- This module defines the category of monoids internal to a given monoidal -- category. module Categories.Category.Construction.Monoids {o ℓ e} {𝒞 : Category o ℓ e} (C : Monoidal 𝒞) where open import Level open import Categories.Functor using (Functor) open import Categories.Morphism.Reasoning 𝒞 open import Categories.Object.Monoid C open Category 𝒞 open Monoidal C open HomReasoning open Monoid using (η; μ) open Monoid⇒ Monoids : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e Monoids = record { Obj = Monoid ; _⇒_ = Monoid⇒ ; _≈_ = λ f g → arr f ≈ arr g ; id = record { arr = id ; preserves-μ = identityˡ ○ introʳ (Functor.identity ⊗) ; preserves-η = identityˡ } ; _∘_ = λ {A B C} f g → record { arr = arr f ∘ arr g ; preserves-μ = begin (arr f ∘ arr g) ∘ μ A ≈⟨ pullʳ (preserves-μ g) ⟩ arr f ∘ (μ B ∘ arr g ⊗₁ arr g) ≈⟨ pullˡ (preserves-μ f) ⟩ (μ C ∘ arr f ⊗₁ arr f) ∘ arr g ⊗₁ arr g ≈˘⟨ pushʳ (Functor.homomorphism ⊗) ⟩ μ C ∘ (arr f ∘ arr g) ⊗₁ (arr f ∘ arr g) ∎ ; preserves-η = pullʳ (preserves-η g) ○ preserves-η f } ; assoc = assoc ; sym-assoc = sym-assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; identity² = identity² -- We cannot define equiv = equiv here, because _⇒_ of this category is a -- different level to the _⇒_ of 𝒞. ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = ∘-resp-≈ } where open Equiv
28.927273
99
0.612822
1e2c532eae2879425f07a0e4b1703d6863d2ff87
9,287
agda
Agda
src/STLC/Kovacs/PresheafRefinement.agda
mietek/coquand-kovacs
bd626509948fbf8503ec2e31c1852e1ac6edcc79
[ "X11" ]
null
null
null
src/STLC/Kovacs/PresheafRefinement.agda
mietek/coquand-kovacs
bd626509948fbf8503ec2e31c1852e1ac6edcc79
[ "X11" ]
null
null
null
src/STLC/Kovacs/PresheafRefinement.agda
mietek/coquand-kovacs
bd626509948fbf8503ec2e31c1852e1ac6edcc79
[ "X11" ]
null
null
null
module STLC.Kovacs.PresheafRefinement where open import STLC.Kovacs.Substitution public open import STLC.Kovacs.Normalisation public open import Category -------------------------------------------------------------------------------- -- (Tyᴺ-idₑ) idacc : ∀ {A Γ} → (a : Γ ⊩ A) → acc idₑ a ≡ a idacc {⎵} M = idrenⁿᶠ M idacc {A ⇒ B} f = fext¡ (fext! (λ η → f & lid○ η)) -- (Tyᴺ-∘ₑ) acc○ : ∀ {A Γ Γ′ Γ″} → (η₁ : Γ″ ⊇ Γ′) (η₂ : Γ′ ⊇ Γ) (a : Γ ⊩ A) → acc (η₂ ○ η₁) a ≡ (acc η₁ ∘ acc η₂) a acc○ {⎵} η₁ η₂ M = renⁿᶠ○ η₁ η₂ M acc○ {A ⇒ B} η₁ η₂ f = fext¡ (fext! (λ η′ → f & assoc○ η′ η₁ η₂)) -- (Conᴺ-idₑ) lid⬖ : ∀ {Γ Ξ} → (ρ : Γ ⊩⋆ Ξ) → ρ ⬖ idₑ ≡ ρ lid⬖ ∅ = refl lid⬖ (ρ , a) = _,_ & lid⬖ ρ ⊗ idacc a -- (Conᴺ-∘ₑ) comp⬖○ : ∀ {Γ Γ′ Γ″ Ξ} → (η₁ : Γ″ ⊇ Γ′) (η₂ : Γ′ ⊇ Γ) (ρ : Γ ⊩⋆ Ξ) → (ρ ⬖ η₂) ⬖ η₁ ≡ ρ ⬖ (η₂ ○ η₁) comp⬖○ η₁ η₂ ∅ = refl comp⬖○ η₁ η₂ (ρ , a) = _,_ & comp⬖○ η₁ η₂ ρ ⊗ (acc○ η₁ η₂ a ⁻¹) -- (∈ᴺ-nat) get⬖ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ⊇ Γ) (ρ : Γ ⊩⋆ Ξ) (i : Ξ ∋ A) → getᵥ (ρ ⬖ η) i ≡ (acc η ∘ getᵥ ρ) i get⬖ η (ρ , a) zero = refl get⬖ η (ρ , a) (suc i) = get⬖ η ρ i -------------------------------------------------------------------------------- -- (Tyᴾ) 𝒰 : ∀ {A Γ} → Γ ⊩ A → Set 𝒰 {⎵} {Γ} M = ⊤ 𝒰 {A ⇒ B} {Γ} f = ∀ {Γ′} → (η : Γ′ ⊇ Γ) {a : Γ′ ⊩ A} (u : 𝒰 a) → (∀ {Γ″} → (η′ : Γ″ ⊇ Γ′) → (f (η ○ η′) ∘ acc η′) a ≡ (acc η′ ∘ f η) a) × 𝒰 (f η a) -- (Tyᴾₑ) acc𝒰 : ∀ {A Γ Γ′} → {a : Γ ⊩ A} → (η : Γ′ ⊇ Γ) → 𝒰 a → 𝒰 (acc η a) acc𝒰 {⎵} {a = M} η tt = tt acc𝒰 {A ⇒ B} {a = f} η u = λ η′ {a} u′ → let natf , u″ = u (η ○ η′) u′ in (λ η″ → (λ η‴ → (f η‴ ∘ acc η″) a) & (assoc○ η″ η′ η ⁻¹) ⦙ natf η″) , u″ -- (Conᴾ ; ∙ ; _,_) data 𝒰⋆ : ∀ {Γ Ξ} → Γ ⊩⋆ Ξ → Set where ∅ : ∀ {Γ} → 𝒰⋆ (∅ {Γ}) _,_ : ∀ {Γ Ξ A} → {ρ : Γ ⊩⋆ Ξ} {a : Γ ⊩ A} → (υ : 𝒰⋆ ρ) (u : 𝒰 a) → 𝒰⋆ (ρ , a) -- (Conᴾₑ) -- NOTE _⬖𝒰_ = acc𝒰⋆ _⬖𝒰_ : ∀ {Γ Γ′ Ξ} → {ρ : Γ ⊩⋆ Ξ} → 𝒰⋆ ρ → (η : Γ′ ⊇ Γ) → 𝒰⋆ (ρ ⬖ η) ∅ ⬖𝒰 η = ∅ (υ , u) ⬖𝒰 η = υ ⬖𝒰 η , acc𝒰 η u -------------------------------------------------------------------------------- -- (∈ᴾ) get𝒰 : ∀ {Γ Ξ A} → {ρ : Γ ⊩⋆ Ξ} → 𝒰⋆ ρ → (i : Ξ ∋ A) → 𝒰 (getᵥ ρ i) get𝒰 (υ , u) zero = u get𝒰 (υ , u) (suc i) = get𝒰 υ i mutual -- (Tmᴾ) eval𝒰 : ∀ {Γ Ξ A} → {ρ : Γ ⊩⋆ Ξ} → 𝒰⋆ ρ → (M : Ξ ⊢ A) → 𝒰 (eval ρ M) eval𝒰 {ρ = ρ} υ (𝓋 i) = get𝒰 υ i eval𝒰 {ρ = ρ} υ (ƛ M) = λ η {a} u → (λ η′ → (λ ρ′ → eval (ρ′ , acc η′ a) M) & (comp⬖○ η′ η ρ ⁻¹) ⦙ eval⬖ η′ (υ ⬖𝒰 η , u) M) , eval𝒰 (υ ⬖𝒰 η , u) M eval𝒰 {ρ = ρ} υ (M ∙ N) = proj₂ (eval𝒰 υ M idₑ (eval𝒰 υ N)) -- (Tmᴺ-nat) eval⬖ : ∀ {Γ Γ′ Ξ A} → {ρ : Γ ⊩⋆ Ξ} → (η : Γ′ ⊇ Γ) → 𝒰⋆ ρ → (M : Ξ ⊢ A) → eval (ρ ⬖ η) M ≡ (acc η ∘ eval ρ) M eval⬖ {ρ = ρ} η υ (𝓋 i) = get⬖ η ρ i eval⬖ {ρ = ρ} η υ (ƛ M) = fext¡ (fext! (λ η′ → fext! (λ a → (λ ρ′ → eval ρ′ M) & ((_, a) & comp⬖○ η′ η ρ)))) eval⬖ {ρ = ρ} η υ (M ∙ N) rewrite eval⬖ η υ M | eval⬖ η υ N = (λ η′ → eval ρ M η′ (acc η (eval ρ N))) & (rid○ η ⦙ lid○ η ⁻¹) ⦙ proj₁ (eval𝒰 υ M idₑ (eval𝒰 υ N)) η mutual -- (uᴾ) reflect𝒰 : ∀ {A Γ} → (M : Γ ⊢ⁿᵉ A) → 𝒰 (reflect M) reflect𝒰 {⎵} M = tt reflect𝒰 {A ⇒ B} M = λ η {a} u → (λ η′ → (λ M′ N′ → reflect (M′ ∙ N′)) & renⁿᵉ○ η′ η M ⊗ (natreify η′ a u) ⦙ natreflect η′ (renⁿᵉ η M ∙ reify a)) , reflect𝒰 (renⁿᵉ η M ∙ reify a) -- (qᴺ-nat) natreify : ∀ {A Γ Γ′} → (η : Γ′ ⊇ Γ) (a : Γ ⊩ A) → 𝒰 a → (reify ∘ acc η) a ≡ (renⁿᶠ η ∘ reify) a natreify {⎵} η M u = refl natreify {A ⇒ B} η f u = let natf , u′ = u (wkₑ idₑ) (reflect𝒰 0) in ƛ & ( reify & ( f & (wkₑ & ( rid○ η ⦙ lid○ η ⁻¹ )) ⊗ natreflect (liftₑ η) 0 ⦙ natf (liftₑ η) ) ⦙ natreify (liftₑ η) (f (wkₑ idₑ) (reflect 0)) u′ ) -- (uᴺ-nat) natreflect : ∀ {A Γ Γ′} → (η : Γ′ ⊇ Γ) (M : Γ ⊢ⁿᵉ A) → (reflect ∘ renⁿᵉ η) M ≡ (acc η ∘ reflect) M natreflect {⎵} η M = refl natreflect {A ⇒ B} η M = fext¡ (fext! (λ η′ → fext! (λ a → (λ M′ → reflect (M′ ∙ reify a)) & (renⁿᵉ○ η′ η M ⁻¹)))) -- (uᶜᴾ) id𝒰 : ∀ {Γ} → 𝒰⋆ (idᵥ {Γ}) id𝒰 {∅} = ∅ id𝒰 {Γ , A} = id𝒰 ⬖𝒰 wkₑ idₑ , reflect𝒰 0 -------------------------------------------------------------------------------- -- (OPEᴺ) _⬗_ : ∀ {Γ Ξ Ξ′} → Ξ′ ⊇ Ξ → Γ ⊩⋆ Ξ′ → Γ ⊩⋆ Ξ done ⬗ ρ = ρ wkₑ η ⬗ (ρ , a) = η ⬗ ρ liftₑ η ⬗ (ρ , a) = η ⬗ ρ , a -- (OPEᴺ-nat) nat⬗ : ∀ {Γ Γ′ Ξ Ξ′} → (η₁ : Γ′ ⊇ Γ) (ρ : Γ ⊩⋆ Ξ′) (η₂ : Ξ′ ⊇ Ξ) → η₂ ⬗ (ρ ⬖ η₁) ≡ (η₂ ⬗ ρ) ⬖ η₁ nat⬗ η₁ ρ done = refl nat⬗ η₁ (ρ , a) (wkₑ η₂) = nat⬗ η₁ ρ η₂ nat⬗ η₁ (ρ , a) (liftₑ η₂) = (_, acc η₁ a) & nat⬗ η₁ ρ η₂ -- (OPEᴺ-idₑ) lid⬗ : ∀ {Γ Ξ} → (ρ : Γ ⊩⋆ Ξ) → idₑ ⬗ ρ ≡ ρ lid⬗ ∅ = refl lid⬗ (ρ , a) = (_, a) & lid⬗ ρ -------------------------------------------------------------------------------- -- (∈ₑᴺ) get⬗ : ∀ {Γ Ξ Ξ′ A} → (ρ : Γ ⊩⋆ Ξ′) (η : Ξ′ ⊇ Ξ) (i : Ξ ∋ A) → getᵥ (η ⬗ ρ) i ≡ (getᵥ ρ ∘ getₑ η) i get⬗ ρ done i = refl get⬗ (ρ , a) (wkₑ η) i = get⬗ ρ η i get⬗ (ρ , a) (liftₑ η) zero = refl get⬗ (ρ , a) (liftₑ η) (suc i) = get⬗ ρ η i -- (Tmₑᴺ) eval⬗ : ∀ {Γ Ξ Ξ′ A} → (ρ : Γ ⊩⋆ Ξ′) (η : Ξ′ ⊇ Ξ) (M : Ξ ⊢ A) → eval (η ⬗ ρ) M ≡ (eval ρ ∘ ren η) M eval⬗ ρ η (𝓋 i) = get⬗ ρ η i eval⬗ ρ η (ƛ M) = fext¡ (fext! (λ η′ → fext! (λ a → (λ ρ′ → eval (ρ′ , a) M) & nat⬗ η′ ρ η ⁻¹ ⦙ eval⬗ (ρ ⬖ η′ , a) (liftₑ η) M))) eval⬗ ρ η (M ∙ N) rewrite eval⬗ ρ η M | eval⬗ ρ η N = refl -------------------------------------------------------------------------------- -- (Subᴺ) -- NOTE: _◆_ = eval⋆ _◆_ : ∀ {Γ Ξ Φ} → Ξ ⊢⋆ Φ → Γ ⊩⋆ Ξ → Γ ⊩⋆ Φ ∅ ◆ ρ = ∅ (σ , M) ◆ ρ = σ ◆ ρ , eval ρ M -- (Subᴺ-nat) comp◆⬖ : ∀ {Γ Γ′ Ξ Φ} → {ρ : Γ ⊩⋆ Ξ} → (η : Γ′ ⊇ Γ) → 𝒰⋆ ρ → (σ : Ξ ⊢⋆ Φ) → (σ ◆ ρ) ⬖ η ≡ σ ◆ (ρ ⬖ η) comp◆⬖ η υ ∅ = refl comp◆⬖ η υ (σ , M) = _,_ & comp◆⬖ η υ σ ⊗ (eval⬖ η υ M ⁻¹) -- (Subᴺ-ₛ∘ₑ) comp◆⬗ : ∀ {Γ Ξ Ξ′ Φ} → (ρ : Γ ⊩⋆ Ξ′) (η : Ξ′ ⊇ Ξ) (σ : Ξ ⊢⋆ Φ) → (σ ◐ η) ◆ ρ ≡ σ ◆ (η ⬗ ρ) comp◆⬗ ρ η ∅ = refl comp◆⬗ ρ η (σ , M) = _,_ & comp◆⬗ ρ η σ ⊗ (eval⬗ ρ η M ⁻¹) -- (∈ₛᴺ) get◆ : ∀ {Γ Ξ Φ A} → (ρ : Γ ⊩⋆ Ξ) (σ : Ξ ⊢⋆ Φ) (i : Φ ∋ A) → getᵥ (σ ◆ ρ) i ≡ (eval ρ ∘ getₛ σ) i get◆ ρ (σ , M) zero = refl get◆ ρ (σ , M) (suc i) = get◆ ρ σ i -- (Subᴺ-idₛ) lid◆ : ∀ {Γ Ξ} → (ρ : Γ ⊩⋆ Ξ) → idₛ ◆ ρ ≡ ρ lid◆ ∅ = refl lid◆ (ρ , a) = (_, a) & ( comp◆⬗ (ρ , a) (wkₑ idₑ) idₛ ⦙ lid◆ (idₑ ⬗ ρ) ⦙ lid⬗ ρ ) -------------------------------------------------------------------------------- accPsh : 𝒯 → Presheaf₀ 𝗢𝗣𝗘 accPsh A = record { Fₓ = _⊩ A ; F = acc ; idF = fext! idacc ; F⋄ = λ η₁ η₂ → fext! (acc○ η₂ η₁) } flip⬖Psh : 𝒞 → Presheaf₀ 𝗢𝗣𝗘 flip⬖Psh Ξ = record { Fₓ = _⊩⋆ Ξ ; F = flip _⬖_ ; idF = fext! lid⬖ ; F⋄ = λ η₁ η₂ → fext! (λ ρ → comp⬖○ η₂ η₁ ρ ⁻¹) } getᵥNT : ∀ {Ξ A} → (i : Ξ ∋ A) → NaturalTransformation (flip⬖Psh Ξ) (accPsh A) getᵥNT i = record { N = flip getᵥ i ; natN = λ η → fext! (λ ρ → get⬖ η ρ i) } -- TODO -- evalNT : ∀ {Ξ A} → (M : Ξ ⊢ A) -- → NaturalTransformation (flip⬖Psh Ξ) (accPsh A) -- evalNT M = -- record -- { N = flip eval M -- ; natN = λ η → fext! (λ ρ → eval⬖ {ρ = ρ} η {!!} M) -- } -- TODO -- reifyNT : ∀ {A} → NaturalTransformation (accPsh A) (renⁿᶠPsh A) -- reifyNT = -- record -- { N = reify -- ; natN = λ η → fext! (λ a → natreify η a {!!}) -- } reflectNT : ∀ {A} → NaturalTransformation (renⁿᵉPsh A) (accPsh A) reflectNT = record { N = reflect ; natN = λ η → fext! (λ M → natreflect η M) } --------------------------------------------------------------------------------
29.861736
80
0.299128
433bac51dc5869c26ed03296c2736c3d95680f35
23,213
agda
Agda
src/Data/Fin/Substitution/ExtraLemmas.agda
sstucki/f-omega-int-agda
ae648c9520895a8428a7ad80f47bb55ecf4d50ea
[ "MIT" ]
12
2017-06-13T16:05:35.000Z
2021-09-27T05:53:06.000Z
src/Data/Fin/Substitution/ExtraLemmas.agda
sstucki/f-omega-int-agda
ae648c9520895a8428a7ad80f47bb55ecf4d50ea
[ "MIT" ]
1
2021-05-14T08:09:40.000Z
2021-05-14T08:54:39.000Z
src/Data/Fin/Substitution/ExtraLemmas.agda
sstucki/f-omega-int-agda
ae648c9520895a8428a7ad80f47bb55ecf4d50ea
[ "MIT" ]
2
2021-05-13T22:29:48.000Z
2021-05-14T10:25:05.000Z
------------------------------------------------------------------------ -- Extra lemmas about substitutions ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module Data.Fin.Substitution.ExtraLemmas where open import Data.Fin using (Fin; zero; suc) open import Data.Fin.Substitution open import Data.Fin.Substitution.Extra open import Data.Fin.Substitution.Lemmas open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Vec using (_∷_; lookup; map) open import Data.Vec.Properties using (map-cong; map-∘; lookup-map) open import Data.Vec.Relation.Unary.All hiding (lookup; map) open import Function using (_∘_; _$_; flip) open import Level using (_⊔_) renaming (zero to lzero; suc to lsuc) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (Star; ε; _◅_; _▻_) open import Relation.Binary.PropositionalEquality as PropEq hiding (subst) open PropEq.≡-Reasoning open import Relation.Unary using (Pred) ------------------------------------------------------------------------ -- Lemmas generalizing those in Data.Fin.Substitution.Lemmas. -- -- NOTE. The modules below generalize the Lemmasᵢ record modules from -- Data.Fin.Substitution.Lemmas in two ways: -- -- 1) by proving generalized versions of existing lemmas that relate -- extended substitutions t /∷ ρ instead of lifted ones ρ ↑ and -- -- 2) by adding extra lemmas that were not present in the original -- modules. -- An generalized version of Data.Fin.Lemmas.Lemmas₀ module ExtLemmas₀ {ℓ} {T : Pred ℕ ℓ} (lemmas₀ : Lemmas₀ T) where open Data.Fin using (lift; raise) open Lemmas₀ lemmas₀ public hiding (lookup-map-weaken-↑⋆) open SimpleExt simple -- A generalized variant of Lemmas₀.lookup-map-weaken-↑⋆. lookup-map-weaken-↑⋆ : ∀ {m n} k x {ρ : Sub T m n} {t} → lookup (map weaken ρ ↑⋆ k) x ≡ lookup ((t /∷ ρ) ↑⋆ k) (lift k suc x) lookup-map-weaken-↑⋆ zero x = refl lookup-map-weaken-↑⋆ (suc k) zero = refl lookup-map-weaken-↑⋆ (suc k) (suc x) {ρ} {t} = begin lookup (map weaken (map weaken ρ ↑⋆ k)) x ≡⟨ lookup-map x weaken (map weaken ρ ↑⋆ k) ⟩ weaken (lookup (map weaken ρ ↑⋆ k) x) ≡⟨ cong weaken (lookup-map-weaken-↑⋆ k x) ⟩ weaken (lookup ((t /∷ ρ) ↑⋆ k) (lift k suc x)) ≡⟨ sym (lookup-map (lift k suc x) weaken ((t /∷ ρ) ↑⋆ k)) ⟩ lookup (map weaken ((t /∷ ρ) ↑⋆ k)) (lift k suc x) ∎ -- A version of Data.Fin.Lemmas.Lemmas₁ with additional lemmas. module ExtLemmas₁ {ℓ} {T : Pred ℕ ℓ} (lemmas₁ : Lemmas₁ T) where open Data.Fin using (raise; fromℕ; lift) open Lemmas₁ lemmas₁ open Simple simple lookup-wk⋆ : ∀ {n} (x : Fin n) k → lookup (wk⋆ k) x ≡ var (raise k x) lookup-wk⋆ x zero = lookup-id x lookup-wk⋆ x (suc k) = lookup-map-weaken x {_} {wk⋆ k} (lookup-wk⋆ x k) lookup-raise-↑⋆ : ∀ k {m n} x {y} {σ : Sub T m n} → lookup σ x ≡ var y → lookup (σ ↑⋆ k) (raise k x) ≡ var (raise k y) lookup-raise-↑⋆ zero x hyp = hyp lookup-raise-↑⋆ (suc k) x {y} {σ} hyp = lookup-map-weaken (raise k x) {_} {σ ↑⋆ k} (lookup-raise-↑⋆ k x hyp) -- A generalized version of Data.Fin.Lemmas.Lemmas₄ module ExtLemmas₄ {ℓ} {T : Pred ℕ ℓ} (lemmas₄ : Lemmas₄ T) where open Data.Fin using (lift; raise) open Lemmas₄ lemmas₄ public hiding (⊙-wk; wk-commutes) open Lemmas₃ lemmas₃ using (lookup-wk-↑⋆-⊙; /✶-↑✶′) open SimpleExt simple using (_/∷_; weaken⋆) open ExtLemmas₀ lemmas₀ using (lookup-map-weaken-↑⋆) ⊙-wk-↑⋆ : ∀ {m n} {ρ : Sub T m n} {t} k → ρ ↑⋆ k ⊙ wk ↑⋆ k ≡ wk ↑⋆ k ⊙ (t /∷ ρ) ↑⋆ k ⊙-wk-↑⋆ {ρ = ρ} {t} k = sym (begin wk ↑⋆ k ⊙ (t /∷ ρ) ↑⋆ k ≡⟨ lemma ⟩ map weaken ρ ↑⋆ k ≡⟨ cong (λ ρ′ → ρ′ ↑⋆ k) map-weaken ⟩ (ρ ⊙ wk) ↑⋆ k ≡⟨ ↑⋆-distrib k ⟩ ρ ↑⋆ k ⊙ wk ↑⋆ k ∎) where lemma = extensionality λ x → begin lookup (wk ↑⋆ k ⊙ (t /∷ ρ) ↑⋆ k) x ≡⟨ lookup-wk-↑⋆-⊙ k ⟩ lookup ((t /∷ ρ) ↑⋆ k) (lift k suc x) ≡⟨ sym (lookup-map-weaken-↑⋆ k x) ⟩ lookup (map weaken ρ ↑⋆ k) x ∎ ⊙-wk : ∀ {m n} {ρ : Sub T m n} {t} → ρ ⊙ wk ≡ wk ⊙ (t /∷ ρ) ⊙-wk = ⊙-wk-↑⋆ zero wk-⊙-∷ : ∀ {n m} t {ρ : Sub T m n} → wk ⊙ (t ∷ ρ) ≡ ρ wk-⊙-∷ t {ρ} = extensionality λ x → begin lookup (wk ⊙ (t ∷ ρ)) x ≡⟨ lookup-wk-↑⋆-⊙ zero {x} ⟩ lookup (t ∷ ρ) (suc x) ≡⟨⟩ lookup ρ x ∎ wk-↑⋆-commutes : ∀ {m n} {ρ : Sub T m n} {t′} k t → t / ρ ↑⋆ k / wk ↑⋆ k ≡ t / wk ↑⋆ k / (t′ /∷ ρ) ↑⋆ k wk-↑⋆-commutes {ρ = ρ} {t} k = /✶-↑✶′ (ε ▻ ρ ▻ wk) (ε ▻ wk ▻ (t /∷ ρ)) ⊙-wk-↑⋆ k wk-commutes : ∀ {m n} {ρ : Sub T m n} {t′} t → t / ρ / wk ≡ t / wk / (t′ /∷ ρ) wk-commutes = wk-↑⋆-commutes zero raise-/-↑⋆ : ∀ {m n} k x {ρ : Sub T m n} → var (raise k x) / ρ ↑⋆ k ≡ var x / ρ / wk⋆ k raise-/-↑⋆ zero x {ρ} = sym (id-vanishes (var x / ρ)) raise-/-↑⋆ (suc k) x {ρ} = begin var (suc (raise k x)) / ρ ↑⋆ suc k ≡⟨ suc-/-↑ (raise k x) ⟩ var (raise k x) / ρ ↑⋆ k / wk ≡⟨ cong (_/ wk) (raise-/-↑⋆ k x) ⟩ var x / ρ / wk⋆ k / wk ≡⟨ sym (/-⊙ (var x / ρ)) ⟩ var x / ρ / wk⋆ k ⊙ wk ≡⟨ cong (var x / ρ /_) (sym map-weaken) ⟩ var x / ρ / wk⋆ (suc k) ∎ /-wk⋆ : ∀ {n} k {t : T n} → t / wk⋆ k ≡ weaken⋆ k t /-wk⋆ zero {t} = id-vanishes t /-wk⋆ (suc k) {t} = begin t / map weaken (wk⋆ k) ≡⟨ cong (t /_) map-weaken ⟩ t / wk⋆ k ⊙ wk ≡⟨ /-⊙ t ⟩ t / wk⋆ k / wk ≡⟨ /-wk ⟩ weaken (t / wk⋆ k) ≡⟨ cong weaken (/-wk⋆ k) ⟩ weaken (weaken⋆ k t) ∎ -- Weakening commutes with substitution. weaken-/ : ∀ {m n} {ρ : Sub T m n} {t′} t → weaken (t / ρ) ≡ weaken t / (t′ /∷ ρ) weaken-/ {ρ = ρ} {t′} t = begin weaken (t / ρ) ≡⟨ sym /-wk ⟩ t / ρ / wk ≡⟨ wk-commutes t ⟩ t / wk / (t′ /∷ ρ) ≡⟨ cong₂ _/_ /-wk refl ⟩ weaken t / (t′ /∷ ρ) ∎ weaken-/-∷ : ∀ {n m} {t′} {ρ : Sub T m n} t → weaken t / (t′ ∷ ρ) ≡ t / ρ weaken-/-∷ {_} {_} {t′} {ρ} t = begin weaken t / (t′ ∷ ρ) ≡⟨ cong (_/ (t′ ∷ ρ)) (sym /-wk) ⟩ t / wk / (t′ ∷ ρ) ≡⟨ sym (/-⊙ t) ⟩ t / (wk ⊙ (t′ ∷ ρ)) ≡⟨ cong (t /_) (wk-⊙-∷ t′) ⟩ t / ρ ∎ -- A generalized version of Data.Fin.Lemmas.AppLemmas module ExtAppLemmas {ℓ₁ ℓ₂} {T₁ : Pred ℕ ℓ₁} {T₂ : Pred ℕ ℓ₂} (appLemmas : AppLemmas T₁ T₂) where open AppLemmas appLemmas public hiding (wk-commutes) open SimpleExt simple using (_/∷_) private module L₄ = ExtLemmas₄ lemmas₄ open L₄ public using (wk-⊙-∷) wk-↑⋆-commutes : ∀ {m n} {ρ : Sub T₂ m n} {t′} k t → t / ρ ↑⋆ k / wk ↑⋆ k ≡ t / wk ↑⋆ k / (t′ /∷ ρ) ↑⋆ k wk-↑⋆-commutes {ρ = ρ} {t} k = ⨀→/✶ (ε ▻ ρ ↑⋆ k ▻ wk ↑⋆ k) (ε ▻ wk ↑⋆ k ▻ (t /∷ ρ) ↑⋆ k) (L₄.⊙-wk-↑⋆ k) wk-commutes : ∀ {m n} {ρ : Sub T₂ m n} {t′} t → t / ρ / wk ≡ t / wk / (t′ /∷ ρ) wk-commutes = wk-↑⋆-commutes zero ------------------------------------------------------------------------ -- Lemmas relating substitutions defined over and applied to different -- kinds of terms. -- Lemmas relating T₃ substitutions in T₁ and T₂. record LiftAppLemmas {ℓ₁ ℓ₂ ℓ₃} (T₁ : Pred ℕ ℓ₁) (T₂ : Pred ℕ ℓ₂) (T₃ : Pred ℕ ℓ₃) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where field lift : ∀ {n} → T₃ n → T₂ n application₁₃ : Application T₁ T₃ application₂₃ : Application T₂ T₃ lemmas₂ : Lemmas₄ T₂ lemmas₃ : Lemmas₄ T₃ private module L₂ = ExtLemmas₄ lemmas₂ module L₃ = ExtLemmas₄ lemmas₃ module A₁ = Application application₁₃ module A₂ = Application application₂₃ field -- Lifting commutes with application of T₃ substitutions. lift-/ : ∀ {m n} t {σ : Sub T₃ m n} → lift (t L₃./ σ) ≡ lift t A₂./ σ -- Lifting preserves variables. lift-var : ∀ {n} (x : Fin n) → lift (L₃.var x) ≡ L₂.var x -- Sequences of T₃ substitutions are equivalent when applied to -- T₁s if they are equivalent when applied to T₂ variables. /✶-↑✶ : ∀ {m n} (σs₁ σs₂ : Subs T₃ m n) → (∀ k x → L₂.var x A₂./✶ σs₁ L₃.↑✶ k ≡ L₂.var x A₂./✶ σs₂ L₃.↑✶ k) → ∀ k t → t A₁./✶ σs₁ L₃.↑✶ k ≡ t A₁./✶ σs₂ L₃.↑✶ k lift-lookup-⊙ : ∀ {m n k} x {σ₁ : Sub T₃ m n} {σ₂ : Sub T₃ n k} → lift (lookup (σ₁ L₃.⊙ σ₂) x) ≡ lift (lookup σ₁ x) A₂./ σ₂ lift-lookup-⊙ x {σ₁} {σ₂} = begin lift (lookup (σ₁ L₃.⊙ σ₂) x) ≡⟨ cong lift (L₃.lookup-⊙ x {σ₁}) ⟩ lift (lookup σ₁ x L₃./ σ₂) ≡⟨ lift-/ (lookup σ₁ x) ⟩ lift (lookup σ₁ x) A₂./ σ₂ ∎ lift-lookup-⨀ : ∀ {m n} x (σs : Subs T₃ m n) → lift (lookup (L₃.⨀ σs) x) ≡ L₂.var x A₂./✶ σs lift-lookup-⨀ x ε = begin lift (lookup L₃.id x) ≡⟨ cong lift (L₃.lookup-id x) ⟩ lift (L₃.var x) ≡⟨ lift-var x ⟩ L₂.var x ∎ lift-lookup-⨀ x (σ ◅ ε) = begin lift (lookup σ x) ≡⟨ cong lift (sym L₃.var-/) ⟩ lift (L₃.var x L₃./ σ) ≡⟨ lift-/ _ ⟩ lift (L₃.var x) A₂./ σ ≡⟨ cong₂ A₂._/_ (lift-var x) refl ⟩ L₂.var x A₂./ σ ∎ lift-lookup-⨀ x (σ ◅ (σ′ ◅ σs′)) = begin lift (lookup (L₃.⨀ σs L₃.⊙ σ) x) ≡⟨ lift-lookup-⊙ x {L₃.⨀ σs} ⟩ lift (lookup (L₃.⨀ σs) x) A₂./ σ ≡⟨ cong₂ A₂._/_ (lift-lookup-⨀ x (σ′ ◅ σs′)) refl ⟩ L₂.var x A₂./✶ σs A₂./ σ ∎ where σs = σ′ ◅ σs′ -- Sequences of T₃ substitutions are equivalent when applied to -- T₁s if they are equivalent when applied as composites. /✶-↑✶′ : ∀ {m n} (σs₁ σs₂ : Subs T₃ m n) → (∀ k → L₃.⨀ (σs₁ L₃.↑✶ k) ≡ L₃.⨀ (σs₂ L₃.↑✶ k)) → ∀ k t → t A₁./✶ σs₁ L₃.↑✶ k ≡ t A₁./✶ σs₂ L₃.↑✶ k /✶-↑✶′ σs₁ σs₂ hyp = /✶-↑✶ σs₁ σs₂ (λ k x → begin L₂.var x A₂./✶ σs₁ L₃.↑✶ k ≡⟨ sym (lift-lookup-⨀ x (σs₁ L₃.↑✶ k)) ⟩ lift (lookup (L₃.⨀ (σs₁ L₃.↑✶ k)) x) ≡⟨ cong (λ σ → lift (lookup σ x)) (hyp k) ⟩ lift (lookup (L₃.⨀ (σs₂ L₃.↑✶ k)) x) ≡⟨ lift-lookup-⨀ x (σs₂ L₃.↑✶ k) ⟩ L₂.var x A₂./✶ σs₂ L₃.↑✶ k ∎) -- Derived lemmas about applications of T₃ substitutions to T₁s. appLemmas : AppLemmas T₁ T₃ appLemmas = record { application = application₁₃ ; lemmas₄ = lemmas₃ ; id-vanishes = /✶-↑✶′ (ε ▻ L₃.id) ε L₃.id-↑⋆ 0 ; /-⊙ = /✶-↑✶′ (ε ▻ _ L₃.⊙ _) (ε ▻ _ ▻ _) L₃.↑⋆-distrib 0 } open ExtAppLemmas appLemmas public hiding (application; lemmas₂; lemmas₃; var; weaken; subst; simple) -- Lemmas relating T₂ and T₃ substitutions in T₁. record LiftSubLemmas {ℓ₁ ℓ₂ ℓ₃} (T₁ : Pred ℕ ℓ₁) (T₂ : Pred ℕ ℓ₂) (T₃ : Pred ℕ ℓ₃) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where field application₁₂ : Application T₁ T₂ liftAppLemmas : LiftAppLemmas T₁ T₂ T₃ open LiftAppLemmas liftAppLemmas hiding (/✶-↑✶; /-wk) private module L₃ = ExtLemmas₄ lemmas₃ module L₂ = ExtLemmas₄ lemmas₂ module A₁₂ = Application application₁₂ module A₁₃ = Application (AppLemmas.application appLemmas) module A₂₃ = Application application₂₃ field -- Weakening commutes with lifting. weaken-lift : ∀ {n} (t : T₃ n) → L₂.weaken (lift t) ≡ lift (L₃.weaken t) -- Applying a composition of T₂ substitutions to T₁s -- corresponds to two consecutive applications. /-⊙₂ : ∀ {m n k} {σ₁ : Sub T₂ m n} {σ₂ : Sub T₂ n k} t → t A₁₂./ σ₁ L₂.⊙ σ₂ ≡ t A₁₂./ σ₁ A₁₂./ σ₂ -- Sequences of T₃ substitutions are equivalent to T₂ -- substitutions when applied to T₁s if they are equivalent when -- applied to variables. /✶-↑✶₁ : ∀ {m n} (σs₁ : Subs T₃ m n) (σs₂ : Subs T₂ m n) → (∀ k x → L₂.var x A₂₃./✶ σs₁ ↑✶ k ≡ L₂.var x L₂./✶ σs₂ L₂.↑✶ k) → ∀ k t → t A₁₃./✶ σs₁ ↑✶ k ≡ t A₁₂./✶ σs₂ L₂.↑✶ k -- Sequences of T₃ substitutions are equivalent to T₂ -- substitutions when applied to T₂s if they are equivalent when -- applied to variables. /✶-↑✶₂ : ∀ {m n} (σs₁ : Subs T₃ m n) (σs₂ : Subs T₂ m n) → (∀ k x → L₂.var x A₂₃./✶ σs₁ ↑✶ k ≡ L₂.var x L₂./✶ σs₂ L₂.↑✶ k) → ∀ k t → t A₂₃./✶ σs₁ ↑✶ k ≡ t L₂./✶ σs₂ L₂.↑✶ k -- Lifting of T₃ substitutions to T₂ substitutions. liftSub : ∀ {m n} → Sub T₃ m n → Sub T₂ m n liftSub σ = map lift σ -- The two types of lifting commute. liftSub-↑⋆ : ∀ {m n} (σ : Sub T₃ m n) k → liftSub σ L₂.↑⋆ k ≡ liftSub (σ ↑⋆ k) liftSub-↑⋆ σ zero = refl liftSub-↑⋆ σ (suc k) = cong₂ _∷_ (sym (lift-var _)) (begin map L₂.weaken (liftSub σ L₂.↑⋆ k) ≡⟨ cong (map _) (liftSub-↑⋆ σ k) ⟩ map L₂.weaken (map lift (σ ↑⋆ k)) ≡⟨ sym (map-∘ _ _ _) ⟩ map (L₂.weaken ∘ lift) (σ ↑⋆ k) ≡⟨ map-cong weaken-lift _ ⟩ map (lift ∘ L₃.weaken) (σ ↑⋆ k) ≡⟨ map-∘ _ _ _ ⟩ map lift (map L₃.weaken (σ ↑⋆ k)) ∎) -- The identity substitutions are equivalent up to lifting. liftSub-id : ∀ {n} → liftSub (L₃.id {n}) ≡ L₂.id {n} liftSub-id {zero} = refl liftSub-id {suc n} = begin liftSub (L₃.id L₃.↑) ≡⟨ sym (liftSub-↑⋆ L₃.id 1) ⟩ liftSub L₃.id L₂.↑ ≡⟨ cong L₂._↑ liftSub-id ⟩ L₂.id ∎ -- Weakening is equivalent up to lifting. liftSub-wk⋆ : ∀ k {n} → liftSub (L₃.wk⋆ k {n}) ≡ L₂.wk⋆ k {n} liftSub-wk⋆ zero = liftSub-id liftSub-wk⋆ (suc k) = begin liftSub (map L₃.weaken (L₃.wk⋆ k)) ≡⟨ sym (map-∘ _ _ _) ⟩ map (lift ∘ L₃.weaken) (L₃.wk⋆ k) ≡⟨ sym (map-cong weaken-lift _) ⟩ map (L₂.weaken ∘ lift) (L₃.wk⋆ k) ≡⟨ map-∘ _ _ _ ⟩ map L₂.weaken (liftSub (L₃.wk⋆ k)) ≡⟨ cong (map _) (liftSub-wk⋆ k) ⟩ map L₂.weaken (L₂.wk⋆ k) ∎ -- Weakening is equivalent up to lifting. liftSub-wk : ∀ {n} → liftSub (L₃.wk {n}) ≡ L₂.wk {n} liftSub-wk = liftSub-wk⋆ 1 -- Single variable substitution is equivalent up to lifting. liftSub-sub : ∀ {n} (t : T₃ n) → liftSub (L₃.sub t) ≡ L₂.sub (lift t) liftSub-sub t = cong₂ _∷_ refl liftSub-id -- Lifting commutes with application to variables. var-/-liftSub-↑⋆ : ∀ {m n} (σ : Sub T₃ m n) k x → L₂.var x A₂₃./ σ ↑⋆ k ≡ L₂.var x L₂./ liftSub σ L₂.↑⋆ k var-/-liftSub-↑⋆ σ k x = begin L₂.var x A₂₃./ σ ↑⋆ k ≡⟨ cong₂ A₂₃._/_ (sym (lift-var x)) refl ⟩ lift (L₃.var x) A₂₃./ σ ↑⋆ k ≡⟨ sym (lift-/ _) ⟩ lift (L₃.var x L₃./ σ ↑⋆ k) ≡⟨ cong lift L₃.var-/ ⟩ lift (lookup (σ ↑⋆ k) x) ≡⟨ sym (lookup-map x lift (σ ↑⋆ k)) ⟩ lookup (liftSub (σ ↑⋆ k)) x ≡⟨ sym L₂.var-/ ⟩ L₂.var x L₂./ liftSub (σ ↑⋆ k) ≡⟨ cong (L₂._/_ (L₂.var x)) (sym (liftSub-↑⋆ σ k)) ⟩ L₂.var x L₂./ liftSub σ L₂.↑⋆ k ∎ -- Lifting commutes with application. /-liftSub-↑⋆ : ∀ {m n} k t {σ : Sub T₃ m n} → t A₁₃./ σ ↑⋆ k ≡ t A₁₂./ liftSub σ L₂.↑⋆ k /-liftSub-↑⋆ k t {σ} = /✶-↑✶₁ (ε ▻ σ) (ε ▻ liftSub σ) (var-/-liftSub-↑⋆ σ) k t /-liftSub : ∀ {m n} t {σ : Sub T₃ m n} → t A₁₃./ σ ≡ t A₁₂./ liftSub σ /-liftSub = /-liftSub-↑⋆ zero -- Weakening is equivalent up to choice of application. /-wk-↑⋆ : ∀ {n} k {t : T₁ (k + n)} → t A₁₃./ L₃.wk ↑⋆ k ≡ t A₁₂./ L₂.wk L₂.↑⋆ k /-wk-↑⋆ k {t = t} = begin t A₁₃./ L₃.wk ↑⋆ k ≡⟨ /-liftSub-↑⋆ k t ⟩ t A₁₂./ (liftSub L₃.wk) L₂.↑⋆ k ≡⟨ cong (λ σ → t A₁₂./ σ L₂.↑⋆ k) liftSub-wk ⟩ t A₁₂./ L₂.wk L₂.↑⋆ k ∎ /-wk : ∀ {n} {t : T₁ n} → t A₁₃./ L₃.wk ≡ t A₁₂./ L₂.wk /-wk = /-wk-↑⋆ zero -- Single-variable substitution is equivalent up to choice of -- application. /-sub-↑⋆ : ∀ {n} k t (s : T₃ n) → t A₁₃./ L₃.sub s ↑⋆ k ≡ t A₁₂./ L₂.sub (lift s) L₂.↑⋆ k /-sub-↑⋆ k t s = begin t A₁₃./ L₃.sub s ↑⋆ k ≡⟨ /-liftSub-↑⋆ k t ⟩ t A₁₂./ liftSub (L₃.sub s) L₂.↑⋆ k ≡⟨ cong (λ σ → t A₁₂./ σ L₂.↑⋆ k) (liftSub-sub s) ⟩ t A₁₂./ L₂.sub (lift s) L₂.↑⋆ k ∎ /-sub : ∀ {n} t (s : T₃ n) → t A₁₃./ L₃.sub s ≡ t A₁₂./ L₂.sub (lift s) /-sub = /-sub-↑⋆ zero -- Lifting commutes with application. /-sub-↑ : ∀ {m n} t s (σ : Sub T₃ m n) → t A₁₂./ L₂.sub s A₁₃./ σ ≡ (t A₁₃./ σ ↑) A₁₂./ L₂.sub (s A₂₃./ σ) /-sub-↑ t s σ = begin t A₁₂./ L₂.sub s A₁₃./ σ ≡⟨ /-liftSub _ ⟩ t A₁₂./ L₂.sub s A₁₂./ liftSub σ ≡⟨ sym (/-⊙₂ t) ⟩ t A₁₂./ (L₂.sub s L₂.⊙ liftSub σ) ≡⟨ cong₂ A₁₂._/_ refl (L₂.sub-⊙ s) ⟩ t A₁₂./ (liftSub σ L₂.↑ L₂.⊙ L₂.sub (s L₂./ liftSub σ)) ≡⟨ /-⊙₂ t ⟩ t A₁₂./ liftSub σ L₂.↑ A₁₂./ L₂.sub (s L₂./ liftSub σ) ≡⟨ cong₂ (A₁₂._/_ ∘ A₁₂._/_ t) (liftSub-↑⋆ _ 1) (cong L₂.sub (sym (/-liftSub₂ s))) ⟩ t A₁₂./ liftSub (σ ↑) A₁₂./ L₂.sub (s A₂₃./ σ) ≡⟨ cong₂ A₁₂._/_ (sym (/-liftSub t)) refl ⟩ t A₁₃./ σ ↑ A₁₂./ L₂.sub (s A₂₃./ σ) ∎ where /-liftSub₂ : ∀ {m n} s {σ : Sub T₃ m n} → s A₂₃./ σ ≡ s L₂./ liftSub σ /-liftSub₂ s {σ} = /✶-↑✶₂ (ε ▻ σ) (ε ▻ liftSub σ) (var-/-liftSub-↑⋆ σ) zero s -- Lemmas relating weakening of T₁ to T₂ substitutions in T₁. record WeakenLemmas {ℓ₁ ℓ₂} (T₁ : Pred ℕ ℓ₁) (T₂ : Pred ℕ ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where field weaken : ∀ {n} → T₁ n → T₁ (suc n) -- Weakening of T₁s. -- Lemmas about application of T₂ substitutions in T₁ appLemmas : AppLemmas T₁ T₂ open ExtAppLemmas appLemmas hiding (/-wk; weaken; _⊙_) open Lemmas₄ lemmas₄ using (_⊙_) renaming (weaken to weaken′) -- A lemma relating weakening to the wk substitution field /-wk : ∀ {n} {t : T₁ n} → t / wk ≡ weaken t extension : Extension T₁ extension = record { weaken = weaken } open Extension extension public using (weaken⋆) -- A generalized version of wk-sub-vanishes for T₁s. weaken-sub : ∀ {n t′} → (t : T₁ n) → weaken t / sub t′ ≡ t weaken-sub t = begin weaken t / sub _ ≡⟨ cong₂ _/_ (sym /-wk) refl ⟩ t / wk / sub _ ≡⟨ wk-sub-vanishes t ⟩ t ∎ -- A variants of /-wk⋆ for T₁s. /-wk⋆ : ∀ {n} k {t : T₁ n} → t / wk⋆ k ≡ weaken⋆ k t /-wk⋆ zero {t} = id-vanishes t /-wk⋆ (suc k) {t} = begin t / map weaken′ (wk⋆ k) ≡⟨ /-weaken t ⟩ t / wk⋆ k / wk ≡⟨ /-wk ⟩ weaken (t / wk⋆ k) ≡⟨ cong weaken (/-wk⋆ k) ⟩ weaken (weaken⋆ k t) ∎ open SimpleExt simple public using (_/∷_) -- Weakening commutes with substitution. weaken-/ : ∀ {m n} {σ : Sub T₂ m n} {t′} t → weaken (t / σ) ≡ weaken t / (t′ /∷ σ) weaken-/ {σ = σ} {t′} t = begin weaken (t / σ) ≡⟨ sym /-wk ⟩ t / σ / wk ≡⟨ wk-commutes t ⟩ t / wk / (t′ /∷ σ) ≡⟨ cong₂ _/_ /-wk refl ⟩ weaken t / (t′ /∷ σ) ∎ weaken-/-∷ : ∀ {n m} {t′} {σ : Sub T₂ m n} (t : T₁ m) → weaken t / (t′ ∷ σ) ≡ t / σ weaken-/-∷ {_} {_} {t′} {σ} t = begin weaken t / (t′ ∷ σ) ≡⟨ cong (_/ (t′ ∷ σ)) (sym /-wk) ⟩ t / wk / (t′ ∷ σ) ≡⟨ sym (/-⊙ t) ⟩ t / wk ⊙ (t′ ∷ σ) ≡⟨ cong (t /_) (wk-⊙-∷ t′) ⟩ t / σ ∎ -- Lemmas for a term-like T₁ derived from term lemmas for T₂ record TermLikeLemmas {ℓ} (T₁ : Pred ℕ ℓ) (T₂ : ℕ → Set) : Set (lsuc (ℓ ⊔ lzero)) where field app : ∀ {T₃} → Lift T₃ T₂ → ∀ {m n} → T₁ m → Sub T₃ m n → T₁ n termLemmas : TermLemmas T₂ termLikeSubst : TermLikeSubst T₁ T₂ termLikeSubst = record { app = app ; termSubst = TermLemmas.termSubst termLemmas } open TermLikeSubst termLikeSubst using (termSubst; termLift; varLift; weaken) open TermSubst termSubst using (var; _⊙_; module Lifted) field /✶-↑✶₁ : ∀ {T₃} {lift : Lift T₃ T₂} → let open Application (record { _/_ = app lift }) using () renaming (_/✶_ to _/✶₁_) open Lifted lift using (_↑✶_) renaming (_/✶_ to _/✶₂_) in ∀ {m n} (σs₁ : Subs T₃ m n) (σs₂ : Subs T₃ m n) → (∀ k x → var x /✶₂ σs₁ ↑✶ k ≡ var x /✶₂ σs₂ ↑✶ k) → ∀ k t → t /✶₁ σs₁ ↑✶ k ≡ t /✶₁ σs₂ ↑✶ k termApplication : Application T₁ T₂ termApplication = record { _/_ = app termLift } varApplication : Application T₁ Fin varApplication = record { _/_ = app varLift } field /✶-↑✶₂ : let open Application varApplication using () renaming (_/✶_ to _/✶₁₃_) open Application termApplication using () renaming (_/✶_ to _/✶₁₂_) open Lifted varLift using () renaming (_↑✶_ to _↑✶₃_; _/✶_ to _/✶₂₃_) open TermSubst termSubst using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂₂_) in ∀ {m n} (σs₁ : Subs Fin m n) (σs₂ : Subs T₂ m n) → (∀ k x → var x /✶₂₃ σs₁ ↑✶₃ k ≡ var x /✶₂₂ σs₂ ↑✶₂ k) → ∀ k t → t /✶₁₃ σs₁ ↑✶₃ k ≡ t /✶₁₂ σs₂ ↑✶₂ k -- An instantiation of the above lemmas for T₂ substitutions in T₁s. termLiftAppLemmas : LiftAppLemmas T₁ T₂ T₂ termLiftAppLemmas = record { lift = Lift.lift termLift ; application₁₃ = termApplication ; application₂₃ = TermLemmas.application termLemmas ; lemmas₂ = TermLemmas.lemmas₄ termLemmas ; lemmas₃ = TermLemmas.lemmas₄ termLemmas ; lift-/ = λ _ → refl ; lift-var = λ _ → refl ; /✶-↑✶ = /✶-↑✶₁ } open LiftAppLemmas termLiftAppLemmas public hiding (/-wk; _⊙_) -- An instantiation of the above lemmas for variable substitutions -- (renamings) in T₁s. varLiftSubLemmas : LiftSubLemmas T₁ T₂ Fin varLiftSubLemmas = record { application₁₂ = termApplication ; liftAppLemmas = record { lift = Lift.lift varLift ; application₁₃ = varApplication ; application₂₃ = Lifted.application varLift ; lemmas₂ = TermLemmas.lemmas₄ termLemmas ; lemmas₃ = VarLemmas.lemmas₄ ; lift-/ = λ _ → sym (TermLemmas.app-var termLemmas) ; lift-var = λ _ → refl ; /✶-↑✶ = /✶-↑✶₁ } ; weaken-lift = λ _ → TermLemmas.weaken-var termLemmas ; /-⊙₂ = AppLemmas./-⊙ appLemmas ; /✶-↑✶₁ = /✶-↑✶₂ ; /✶-↑✶₂ = TermLemmas./✶-↑✶ termLemmas } open Application varApplication public using () renaming (_/_ to _/Var_) open LiftSubLemmas varLiftSubLemmas public hiding (/✶-↑✶₁; /✶-↑✶₂; /-wk) renaming (liftAppLemmas to varLiftAppLemmas) -- Lemmas relating weakening of T₁s to T₂-substitutions in T₁s. weakenLemmas : WeakenLemmas T₁ T₂ weakenLemmas = record { weaken = weaken ; appLemmas = appLemmas ; /-wk = sym /-wk } where open LiftSubLemmas varLiftSubLemmas using (/-wk) open WeakenLemmas weakenLemmas public hiding (appLemmas) -- Another variant of /-wk⋆ relating VarSubst.wk to weakening of T₁s. /Var-wk⋆ : ∀ {n} k {t : T₁ n} → t /Var VarSubst.wk⋆ k ≡ weaken⋆ k t /Var-wk⋆ k {t} = begin t /Var VarSubst.wk⋆ k ≡⟨ /-liftSub t ⟩ t / liftSub (VarSubst.wk⋆ k) ≡⟨ cong (t /_) (liftSub-wk⋆ k) ⟩ t / wk⋆ k ≡⟨ /-wk⋆ k ⟩ weaken⋆ k t ∎
37.022329
79
0.505579
13a3cde54a3536630517ec9bdab5e445a5562e64
1,143
agda
Agda
hott/equivalence/core.agda
HoTT/M-types
beebe176981953ab48f37de5eb74557cfc5402f4
[ "BSD-3-Clause" ]
27
2015-04-14T15:47:03.000Z
2022-01-09T07:26:57.000Z
src/hott/equivalence/core.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T14:32:16.000Z
2016-10-26T11:57:26.000Z
src/hott/equivalence/core.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T12:17:00.000Z
2019-05-04T19:31:00.000Z
{-# OPTIONS --without-K #-} module hott.equivalence.core where open import equality.core using (_≡_ ; refl ; ap) open import sum using (Σ ; proj₁ ; proj₂ ; _,_) open import level using (_⊔_) open import hott.level.core using (contr ; prop ; _⁻¹_) open import function.core using (_$_) open import function.isomorphism.core using (_≅_ ; iso) -- a function is a weak equivalence, if the inverse images of all points are contractible weak-equiv : ∀ {i k} {X : Set i} {Y : Set k} (f : X → Y) → Set (i ⊔ k) weak-equiv {_} {_} {X} {Y} f = (y : Y) → contr $ f ⁻¹ y -- weak equivalences _≈_ : ∀ {i j} (X : Set i) (Y : Set j) → Set _ X ≈ Y = Σ (X → Y) λ f → weak-equiv f apply≈ : ∀ {i j} {X : Set i}{Y : Set j} → X ≈ Y → X → Y apply≈ = proj₁ ≈⇒≅ : ∀ {i j} {X : Set i} {Y : Set j} → X ≈ Y → X ≅ Y ≈⇒≅ {X = X}{Y} (f , we) = iso f g iso₁ iso₂ where g : Y → X g y = proj₁ (proj₁ (we y)) iso₁ : (x : X) → g (f x) ≡ x iso₁ x = ap proj₁ (proj₂ (we (f x)) (x , refl)) iso₂ : (y : Y) → f (g y) ≡ y iso₂ y = proj₂ (proj₁ (we y)) invert≈ : ∀ {i j} {X : Set i}{Y : Set j} → X ≈ Y → Y → X invert≈ (_ , we) y = proj₁ (proj₁ (we y))
31.75
89
0.540682
ad98d878552c6f72035eea9d0dc746bf0605d272
382
agda
Agda
Lists/Definition.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
4
2019-08-08T12:44:19.000Z
2022-01-28T06:04:15.000Z
Lists/Definition.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
14
2019-01-06T21:11:59.000Z
2020-04-11T11:03:39.000Z
Lists/Definition.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
1
2021-11-29T13:23:07.000Z
2021-11-29T13:23:07.000Z
{-# OPTIONS --safe --warning=error --without-K #-} module Lists.Definition where data List {a : _} (A : Set a) : Set a where [] : List A _::_ : (x : A) (xs : List A) → List A infixr 10 _::_ {-# BUILTIN LIST List #-} [_] : {a : _} {A : Set a} → (a : A) → List A [ a ] = a :: [] _++_ : {a : _} {A : Set a} → List A → List A → List A [] ++ m = m (x :: l) ++ m = x :: (l ++ m)
21.222222
53
0.460733
341c03aad60d00bd990be17132ba927fc576c7b1
15
agda
Agda
test/interaction/Issue4835.agda
zliu41/agda
73405f70bced057d24dd4bf122d53f9548544aba
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue4835.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue4835.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Dummy file.
7.5
14
0.6
2207a5789894e6497f96028bb47d708c27d0845e
4,077
agda
Agda
agda-stdlib/src/Function/Construct/Identity.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Function/Construct/Identity.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Function/Construct/Identity.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- The identity function ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Function.Construct.Identity where open import Data.Product using (_,_) open import Function using (id) open import Function.Bundles import Function.Definitions as Definitions import Function.Structures as Structures open import Level open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; setoid) private variable a ℓ : Level A : Set a ------------------------------------------------------------------------ -- Properties module _ (_≈_ : Rel A ℓ) where open Definitions _≈_ _≈_ injective : Injective id injective = id surjective : Reflexive _≈_ → Surjective id surjective refl x = x , refl bijective : Reflexive _≈_ → Bijective id bijective refl = injective , surjective refl inverseˡ : Reflexive _≈_ → Inverseˡ id id inverseˡ refl x = refl inverseʳ : Reflexive _≈_ → Inverseʳ id id inverseʳ refl x = refl inverseᵇ : Reflexive _≈_ → Inverseᵇ id id inverseᵇ refl = inverseˡ refl , inverseʳ refl ------------------------------------------------------------------------ -- Structures module _ {_≈_ : Rel A ℓ} (isEq : IsEquivalence _≈_) where open Structures _≈_ _≈_ open IsEquivalence isEq isCongruent : IsCongruent id isCongruent = record { cong = id ; isEquivalence₁ = isEq ; isEquivalence₂ = isEq } isInjection : IsInjection id isInjection = record { isCongruent = isCongruent ; injective = injective _≈_ } isSurjection : IsSurjection id isSurjection = record { isCongruent = isCongruent ; surjective = surjective _≈_ refl } isBijection : IsBijection id isBijection = record { isInjection = isInjection ; surjective = surjective _≈_ refl } isLeftInverse : IsLeftInverse id id isLeftInverse = record { isCongruent = isCongruent ; cong₂ = id ; inverseˡ = inverseˡ _≈_ refl } isRightInverse : IsRightInverse id id isRightInverse = record { isCongruent = isCongruent ; cong₂ = id ; inverseʳ = inverseʳ _≈_ refl } isInverse : IsInverse id id isInverse = record { isLeftInverse = isLeftInverse ; inverseʳ = inverseʳ _≈_ refl } ------------------------------------------------------------------------ -- Setoid bundles module _ (S : Setoid a ℓ) where open Setoid S injection : Injection S S injection = record { f = id ; cong = id ; injective = injective _≈_ } surjection : Surjection S S surjection = record { f = id ; cong = id ; surjective = surjective _≈_ refl } bijection : Bijection S S bijection = record { f = id ; cong = id ; bijective = bijective _≈_ refl } equivalence : Equivalence S S equivalence = record { f = id ; g = id ; cong₁ = id ; cong₂ = id } leftInverse : LeftInverse S S leftInverse = record { f = id ; g = id ; cong₁ = id ; cong₂ = id ; inverseˡ = inverseˡ _≈_ refl } rightInverse : RightInverse S S rightInverse = record { f = id ; g = id ; cong₁ = id ; cong₂ = id ; inverseʳ = inverseʳ _≈_ refl } inverse : Inverse S S inverse = record { f = id ; f⁻¹ = id ; cong₁ = id ; cong₂ = id ; inverse = inverseᵇ _≈_ refl } ------------------------------------------------------------------------ -- Propositional bundles module _ (A : Set a) where id-↣ : A ↣ A id-↣ = injection (setoid A) id-↠ : A ↠ A id-↠ = surjection (setoid A) id-⤖ : A ⤖ A id-⤖ = bijection (setoid A) id-⇔ : A ⇔ A id-⇔ = equivalence (setoid A) id-↩ : A ↩ A id-↩ = leftInverse (setoid A) id-↪ : A ↪ A id-↪ = rightInverse (setoid A) id-↔ : A ↔ A id-↔ = inverse (setoid A)
21.34555
72
0.540594
19bfcd20ffcff7db1dc9632d27a0093f502a2a0b
3,161
agda
Agda
test/Succeed/SizedTypesMergeSort.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/SizedTypesMergeSort.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/SizedTypesMergeSort.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- {-# OPTIONS -v tc.size:100 #-} {-# OPTIONS --sized-types #-} module SizedTypesMergeSort where open import Common.Size open import Common.Prelude using (Bool; true; false; if_then_else_) open import Common.Product module Old where -- sized lists data List (A : Set) : {_ : Size} -> Set where [] : {size : Size} -> List A {↑ size} _::_ : {size : Size} -> A -> List A {size} -> List A {↑ size} -- CPS split (non-size increasing) split : {A : Set}{i : Size} -> List A {i} -> {C : Set} -> (List A {i} -> List A {i} -> C) -> C split [] k = k [] [] split (x :: xs) k = split xs (\ l r -> k (x :: r) l) module Sort (A : Set) (compare : A -> A -> {B : Set} -> B -> B -> B) where -- Andreas, 4 Sep 2008 -- the size indices i and j should not be necessary here -- but without them, the termination checker does not recognise that -- the pattern x :: xs is equal to the term x :: xs -- I suspect that _::_ {∞} x xs is not equal to itself since ∞ is a term -- not a constructor or variable merge : {i j : Size} -> List A {i} -> List A {j} -> List A merge [] ys = ys merge xs [] = xs merge (x :: xs) (y :: ys) = compare x y (x :: merge xs (y :: ys)) (y :: merge (x :: xs) ys) sort : {i : Size} -> List A {i} -> List A sort [] = [] sort (x :: []) = x :: [] sort (x :: (y :: xs)) = split xs (\ l r -> merge (sort (x :: l)) (sort (y :: r))) module New where -- sized lists data List (A : Set) {i} : Set where [] : List A _::_ : {i' : Size< i} → A → List A {i'} → List A module CPS where -- CPS split (non-size increasing) split : ∀ {A i} → List A {i} → {C : Set} → (List A {i} → List A {i} → C) → C split [] k = k [] [] split (x :: xs) k = split xs (\ l r → k (x :: r) l) module Sort (A : Set) (compare : A → A → {B : Set} → B → B → B) where merge : List A → List A → List A merge [] ys = ys merge xs [] = xs merge (x :: xs) (y :: ys) = compare x y (x :: merge xs (y :: ys)) (y :: merge (x :: xs) ys) sort : {i : Size} → List A {i} → List A sort [] = [] sort (x :: []) = x :: [] sort (x :: (y :: xs)) = split xs (\ l r → merge (sort (x :: l)) (sort (y :: r))) module Direct where split : ∀ {A i} → List A {i} → List A {i} × List A {i} split [] = [] , [] split (x :: xs) = let l , r = split xs in (x :: r) , l module Sort (A : Set) (_≤_ : A → A → Bool) where merge : List A → List A → List A merge [] ys = ys merge xs [] = xs merge (x :: xs) (y :: ys) = if x ≤ y then (x :: merge xs (y :: ys)) else (y :: merge (x :: xs) ys) sort : {i : Size} → List A {i} → List A sort [] = [] sort (x :: []) = x :: [] sort (x :: (y :: xs)) = let l , r = split xs in merge (sort (x :: l)) (sort (y :: r))
30.990196
76
0.427396
fd5db6b72e9e33e4fd60e1ffca93e35ea381d208
1,571
agda
Agda
Cubical/Structures/Transfer.agda
maxdore/cubical
ef62b84397396d48135d73ba7400b71c721ddc94
[ "MIT" ]
null
null
null
Cubical/Structures/Transfer.agda
maxdore/cubical
ef62b84397396d48135d73ba7400b71c721ddc94
[ "MIT" ]
null
null
null
Cubical/Structures/Transfer.agda
maxdore/cubical
ef62b84397396d48135d73ba7400b71c721ddc94
[ "MIT" ]
null
null
null
{- Transferring properties of terms between equivalent structures -} {-# OPTIONS --safe #-} module Cubical.Structures.Transfer where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.SIP open import Cubical.Foundations.Transport open import Cubical.Structures.Product private variable ℓ ℓ₀ ℓ₁ ℓ₂ ℓ₂' : Level transfer : {ℓ₂' ℓ₀ : Level} {S : Type ℓ → Type ℓ₁} {H : Type ℓ → Type ℓ₂} (P : ∀ X → S X → H X → Type ℓ₀) (α : EquivAction H) (τ : TransportStr α) (ι : StrEquiv S ℓ₂') (θ : UnivalentStr S ι) {X Y : Type ℓ} {s : S X} {t : S Y} (e : (X , s) ≃[ ι ] (Y , t)) → (h : H Y) → P X s (invEq (α (e .fst)) h) → P Y t h transfer P α τ ι θ {X} {Y} {s} {t} e h = subst (λ {(Z , u , h) → P Z u h}) (sip (productUnivalentStr ι θ (EquivAction→StrEquiv α) (TransportStr→UnivalentStr α τ)) (X , s , invEq (α (e .fst)) h) (Y , t , h) (e .fst , e .snd , retEq (α (e .fst)) h)) transfer⁻ : {ℓ₂' ℓ₀ : Level} {S : Type ℓ → Type ℓ₁} {H : Type ℓ → Type ℓ₂} (P : ∀ X → S X → H X → Type ℓ₀) (α : EquivAction H) (τ : TransportStr α) (ι : StrEquiv S ℓ₂') (θ : UnivalentStr S ι) {X Y : Type ℓ} {s : S X} {t : S Y} (e : (X , s) ≃[ ι ] (Y , t)) → (h : H X) → P Y t (equivFun (α (e .fst)) h) → P X s h transfer⁻ P α τ ι θ {X} {Y} {s} {t} e h = subst⁻ (λ {(Z , u , h) → P Z u h}) (sip (productUnivalentStr ι θ (EquivAction→StrEquiv α) (TransportStr→UnivalentStr α τ)) (X , s , h) (Y , t , equivFun (α (e .fst)) h) (e .fst , e .snd , refl))
32.729167
89
0.553151
2224b434dde64f4794088e2fdd2c50d9a76a6b4b
965
agda
Agda
test/Fail/Issue2455.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue2455.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue2455.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2017-02-14 issue #2455 reported by mechvel -- Test case by Andrea -- Seem that the fix for issue #44 was not complete. -- When inserting module parameters for a definition, -- we need to respect polarities! -- Jesper, 2017-05-10 temporarily moved to Fail -- {-# OPTIONS -v tc.decl:10 -v tc.polarity:70 -v tc.sig.inst:30 #-} module Issue2455 where data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x data Unit : Set where unit : Unit postulate A : Set P : A → Set p : ∀ {e} → P e module M (e : A) (f : Unit) where aux : Unit → P e aux unit = p -- se does not depent on f -- se gets type (e : A) (f :{UnusedArg} Unit) -> A se = e -- aux' should not depend on f -- For this to work, the module parameters for se must be -- respecting UnusedArg. aux' : Unit → P se aux' unit = p works : ∀ x y e → M.aux e x ≡ M.aux e y works _ _ _ = refl fails : ∀ x y e → M.aux' e x ≡ M.aux' e y fails _ _ _ = refl
20.978261
68
0.603109
3564307722fb2da9a947f067d590b2e35c24c26c
368
agda
Agda
test/Fail/Issue721b.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue721b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue721b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- 2012-10-20 Andreas module Issue721b where data Bool : Set where false true : Bool record Foo (b : Bool) : Set where field _*_ : Bool → Bool → Bool data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x test : (F : Foo false) → let open Foo F in (x : Bool) → _*_ x ≡ (λ x → x) test F x = x where open Foo F -- Don't want to see any anonymous module
20.444444
73
0.597826
35a7d01af419e6a37f11c4bac8e3a40feffd1a00
115
agda
Agda
test/Fail/Issue.1947.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue.1947.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue.1947.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2016-06-02 -- The filename "Issue.1947.agda" is invalid as "1947" is not a valid name. module _ where
23
75
0.704348
13c3e24b7e34796a90e0a05862ab32d5f6c8d5b1
186
agda
Agda
Cubical/HITs/FiniteMultiset.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/HITs/FiniteMultiset.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
Cubical/HITs/FiniteMultiset.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.FiniteMultiset where open import Cubical.HITs.FiniteMultiset.Base public open import Cubical.HITs.FiniteMultiset.Properties public
26.571429
57
0.806452
383e71c7ce874ea4b79e5b1f8db97b64d2722945
548
agda
Agda
internal/well-typed-syntax-interpreter-full.agda
JasonGross/lob
716129208eaf4fe3b5f629f95dde4254805942b3
[ "MIT" ]
19
2015-07-17T17:53:30.000Z
2021-03-17T14:04:53.000Z
internal/well-typed-syntax-interpreter-full.agda
JasonGross/lob
716129208eaf4fe3b5f629f95dde4254805942b3
[ "MIT" ]
1
2015-07-17T20:20:43.000Z
2015-07-17T20:20:43.000Z
internal/well-typed-syntax-interpreter-full.agda
JasonGross/lob
716129208eaf4fe3b5f629f95dde4254805942b3
[ "MIT" ]
1
2015-07-17T18:53:37.000Z
2015-07-17T18:53:37.000Z
{-# OPTIONS --without-K #-} module well-typed-syntax-interpreter-full where open import common public open import well-typed-syntax open import well-typed-syntax-interpreter Contextε⇓ : Context⇓ ε Contextε⇓ = tt Typε⇓ : Typ ε → Set max-level Typε⇓ T = Typ⇓ T Contextε⇓ Termε⇓ : {T : Typ ε} → Term T → Typε⇓ T Termε⇓ t = Term⇓ t Contextε⇓ Typε▻⇓ : ∀ {A} → Typ (ε ▻ A) → Typε⇓ A → Set max-level Typε▻⇓ T A⇓ = Typ⇓ T (Contextε⇓ , A⇓) Termε▻⇓ : ∀ {A} → {T : Typ (ε ▻ A)} → Term T → (x : Typε⇓ A) → Typε▻⇓ T x Termε▻⇓ t x = Term⇓ t (Contextε⇓ , x)
26.095238
73
0.611314
3447436857ce4dbfc13a814955593c1da6b90190
624
agda
Agda
Rings/Divisible/Definition.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
4
2019-08-08T12:44:19.000Z
2022-01-28T06:04:15.000Z
Rings/Divisible/Definition.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
14
2019-01-06T21:11:59.000Z
2020-04-11T11:03:39.000Z
Rings/Divisible/Definition.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
1
2021-11-29T13:23:07.000Z
2021-11-29T13:23:07.000Z
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Setoids.Setoids open import Functions.Definition open import Sets.EquivalenceRelations open import Rings.Definition module Rings.Divisible.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where open Setoid S open Equivalence eq open Ring R _∣_ : Rel A a ∣ b = Sg A (λ c → (a * c) ∼ b) divisibleWellDefined : {x y a b : A} → (x ∼ y) → (a ∼ b) → x ∣ a → y ∣ b divisibleWellDefined x=y a=b (c , xc=a) = c , transitive (*WellDefined (symmetric x=y) reflexive) (transitive xc=a a=b)
31.2
127
0.655449
1ead1ccb4ed7fc5aba7a9560766e09c559b6c246
944
agda
Agda
test/Succeed/Issue5944.agda
KDr2/agda
98c9382a59f707c2c97d75919e389fc2a783ac75
[ "BSD-2-Clause" ]
null
null
null
test/Succeed/Issue5944.agda
KDr2/agda
98c9382a59f707c2c97d75919e389fc2a783ac75
[ "BSD-2-Clause" ]
null
null
null
test/Succeed/Issue5944.agda
KDr2/agda
98c9382a59f707c2c97d75919e389fc2a783ac75
[ "BSD-2-Clause" ]
null
null
null
-- Andreas Abel, 2022-06-06, issue #5944 reported by Mike Shulman -- Support rewriting with 2ltt (match SSet). {-# OPTIONS --type-in-type --rewriting --two-level #-} open import Agda.Primitive public postulate Tel : SSet ε : Tel _≡_ : {A : SSet} (a : A) → A → SSet cong : (A B : SSet) (f : A → B) {x y : A} (p : x ≡ y) → f x ≡ f y coe← : (A B : SSet) → (A ≡ B) → B → A el : Tel → SSet [] : el ε ID : (Δ : Tel) → Tel ID′ : (Δ : Tel) (Θ : el Δ → Tel) → Tel ID′ε : (Δ : Tel) → ID′ Δ (λ _ → ε) ≡ ε {-# BUILTIN REWRITE _≡_ #-} {-# REWRITE ID′ε #-} postulate ID′-CONST : (Θ : Tel) (Δ : Tel) → ID′ Θ (λ _ → Δ) ≡ ID Δ ID′-CONST-ε : (Θ : Tel) (δ₂ : el (ID ε)) → coe← (el (ID′ Θ (λ _ → ε))) (el (ID ε)) (cong Tel (SSet lzero) el (ID′-CONST Θ ε)) δ₂ ≡ [] {-# REWRITE ID′-CONST-ε #-} -- WAS: internal error when trying to make a pattern from SSet -- Should succeed now
25.513514
106
0.495763
fda4c070f6e6b785b54703984c9c0f6a964600aa
6,743
agda
Agda
test/succeed/PatternSynonyms.agda
larrytheliquid/agda
477c8c37f948e6038b773409358fd8f38395f827
[ "MIT" ]
1
2018-10-10T17:08:44.000Z
2018-10-10T17:08:44.000Z
test/succeed/PatternSynonyms.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
null
null
null
test/succeed/PatternSynonyms.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
-- {-# OPTIONS -v scope.pat:10 #-} -- {-# OPTIONS -v tc.lhs:10 #-} module PatternSynonyms where data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} pattern z = zero pattern sz = suc z pattern ss x = suc (suc x) data _≡_ {A : Set}(x : A) : A → Set where refl : x ≡ x test : z ≡ zero test = refl test′ : sz ≡ suc zero test′ = refl test″ : ss z ≡ suc (suc zero) test″ = refl test‴ : ss ≡ λ x → suc (suc x) test‴ = refl f : ℕ → ℕ f z = zero f sz = suc z f (ss 0) = 2 f (ss (suc n)) = n test-f : f zero ≡ zero test-f = refl test-f′ : f (suc zero) ≡ suc zero test-f′ = refl test-f″ : f (suc (suc 0)) ≡ 2 test-f″ = refl test-f‴ : ∀ {n} → f (suc (suc (suc n))) ≡ n test-f‴ = refl ------------------------------------------------------------------------ data L (A : Set) : Set where nil : L A cons : A → L A → L A pattern cc x y xs = cons x (cons y xs) test-cc : ∀ {A} → cc ≡ λ (x : A) y xs → cons x (cons y xs) test-cc = refl crazyLength : ∀ {A} → L A → ℕ crazyLength nil = 0 crazyLength (cons x nil) = 1 crazyLength (cc x y xs) = 9000 swap : ∀ {A} → L A → L A swap nil = nil swap (cons x nil) = cons x nil swap (cc x y xs) = cc y x xs test-swap : ∀ {xs} → swap (cons 1 (cons 2 xs)) ≡ cons 2 (cons 1 xs) test-swap = refl ------------------------------------------------------------------------ -- refl and _ record ⊤ : Set where constructor tt data _⊎_ (A B : Set) : Set where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B infixr 4 _,_ record Σ (A : Set)(B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ _×_ : (A B : Set) → Set A × B = Σ A λ _ → B infixr 5 _+_ infixr 6 _*_ data Sig (O : Set) : Set₁ where ε ψ : Sig O ρ : (o : O) → Sig O ι : (o : O) → Sig O _+_ _*_ : (Σ Σ′ : Sig O) → Sig O σ π : (A : Set)(φ : A → Sig O) → Sig O ⟦_⟧ : ∀ {O} → Sig O → (Set → (O → Set) → (O → Set)) ⟦ ε ⟧ P R o = ⊤ ⟦ ψ ⟧ P R o = P ⟦ ρ o′ ⟧ P R o = R o′ ⟦ ι o′ ⟧ P R o = o ≡ o′ ⟦ Σ + Σ′ ⟧ P R o = ⟦ Σ ⟧ P R o ⊎ ⟦ Σ′ ⟧ P R o ⟦ Σ * Σ′ ⟧ P R o = ⟦ Σ ⟧ P R o × ⟦ Σ′ ⟧ P R o ⟦ σ A φ ⟧ P R o = Σ A λ x → ⟦ φ x ⟧ P R o ⟦ π A φ ⟧ P R o = (x : A) → ⟦ φ x ⟧ P R o ′List : Sig ⊤ ′List = ε + ψ * ρ _ data μ {O}(Σ : Sig O)(P : Set)(o : O) : Set where ⟨_⟩ : ⟦ Σ ⟧ P (μ Σ P) o → μ Σ P o List : Set → Set List A = μ ′List A _ infixr 5 _∷_ pattern [] = ⟨ inj₁ _ ⟩ pattern _∷_ x xs = ⟨ inj₂ (x , xs) ⟩ length : ∀ {A} → List A → ℕ length [] = zero length (x ∷ xs) = suc (length xs) test-list : List ℕ test-list = 1 ∷ 2 ∷ [] test-length : length test-list ≡ 2 test-length = refl ′Vec : Sig ℕ ′Vec = ι 0 + σ ℕ λ m → ψ * ρ m * ι (suc m) Vec : Set → ℕ → Set Vec A n = μ ′Vec A n pattern []V = ⟨ inj₁ refl ⟩ pattern _∷V_ x xs = ⟨ inj₂ (_ , x , xs , refl) ⟩ nilV : ∀ {A} → Vec A zero nilV = []V consV : ∀ {A n} → A → Vec A n → Vec A (suc n) consV x xs = x ∷V xs lengthV : ∀ {A n} → Vec A n → ℕ lengthV []V = 0 lengthV (x ∷V xs) = suc (lengthV xs) test-lengthV : lengthV (consV 1 (consV 2 (consV 3 nilV))) ≡ 3 test-lengthV = refl ------------------------------------------------------------------------ -- .-patterns pattern zr = (.zero , refl) pattern underscore² = _ , _ dot : (p : Σ ℕ λ n → n ≡ zero) → ⊤ × ⊤ dot zr = underscore² ------------------------------------------------------------------------ -- Implicit arguments {- pattern hiddenUnit = {_} -- XXX: We get lhs error msgs, can we refine -- that? imp : {p : ⊤} → ⊤ imp hiddenUnit = _ -} data Box (A : Set) : Set where box : {x : A} → Box A pattern [_] y = box {x = y} b : Box ℕ b = [ 1 ] test-box : b ≡ box {x = 1} test-box = refl ------------------------------------------------------------------------ -- Anonymous λs g : ℕ → ℕ g = λ { z → z ; sz → sz ; (ss n) → n } test-g : g zero ≡ zero test-g = refl test-g′ : g sz ≡ suc zero test-g′ = refl test-g″ : ∀ {n} → g (suc (suc n)) ≡ n test-g″ = refl ------------------------------------------------------------------------ -- λs postulate X Y : Set h : X → Y p : (x : X)(y : Y) → h x ≡ y → ⊤ p x .((λ x → x) (h x)) refl = _ pattern app x = x , .((λ x → x) (h x)) p′ : (p : X × Y) → h (proj₁ p) ≡ proj₂ p → ⊤ p′ (app x) refl = _ ------------------------------------------------------------------------ -- records record Rec : Set where constructor rr field r : ℕ rrr : (x : Rec) → x ≡ record { r = 0 } → ⊤ rrr .(record { r = 0}) refl = _ rrr′ : (x : Rec) → x ≡ record { r = 0 } → ⊤ rrr′ .(rr 0) refl = _ rrrr : (a : Rec × ℕ) → proj₁ a ≡ record { r = proj₂ a } → ⊤ rrrr (.(rr 0) , 0) refl = _ rrrr (.(rr (suc n)) , suc n) refl = _ pattern pair x = (.(record { r = x }) , x) rrrr′ : (a : Rec × ℕ) → proj₁ a ≡ record { r = proj₂ a } → ⊤ rrrr′ (pair 0) refl = _ rrrr′ (pair (suc n)) refl = _ ------------------------------------------------------------------------ -- lets -- Ulf, 2013-11-07: Lets are no longer allowed in patterns. -- pp : (x : X)(y : Y) → h x ≡ y → ⊤ -- pp x .(let i = (λ x → x) in i (h x)) refl = _ -- pattern llet x = x , .(let i = (λ x → x) in i (h x)) -- pp′ : (p : X × Y) → h (proj₁ p) ≡ proj₂ p → ⊤ -- pp′ (llet x) refl = _ ------------------------------------------------------------------------ -- absurd patterns pattern absurd = () data ⊥ : Set where ⊥-elim : ∀ {A : Set} → ⊥ → A ⊥-elim absurd ------------------------------------------------------------------------ -- ambiguous constructors data ℕ2 : Set where zero : ℕ2 suc : ℕ2 -> ℕ2 -- This needs a type signature, because it is ambiguous: amb : ℕ2 amb = suc (suc zero) -- This isn't ambiguous, because the overloading is resolved when the -- pattern synonym is scope-checked: unamb = ss z ------------------------------------------------------------------------ -- underscore pattern trivial = ._ trivf : (a : ⊤) -> a ≡ tt -> ⊤ trivf trivial refl = trivial ------------------------------------------------------------------------ -- let open -- Ulf, 2013-11-07: Lets are no longer allowed in patterns. -- pattern nuts = .(let open Σ in z) -- foo : (n : ℕ) -> n ≡ z -> ℕ -- foo nuts refl = nuts ------------------------------------------------------------------------ -- pattern synonym inside unparamterised module module M where pattern sss x = suc (suc (suc x)) a : ℕ a = sss 2 mb : ℕ mb = M.sss 0 mf : ℕ -> ℕ -> ℕ mf (M.sss _) = M.sss mf _ = \ _ -> 0 {- module M (A : Set)(a : A) where pattern peep x = x , .a pop : (z : A × A) -> proj₂ z ≡ a -> ⊤ pop (peep x) refl = _ peep' = peep pop' : (z : ⊤ × ⊤) -> proj₂ z ≡ tt -> ⊤ pop' (M.peep tt) refl = _ peep' = M.peep -}
19.432277
72
0.424885
fde6f77dbcfdb7efb171db8f8bd41f3b39d5e319
469
agda
Agda
src/data/lib/prim/Agda/Builtin/Int.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2016-05-20T13:58:52.000Z
2016-05-20T13:58:52.000Z
src/data/lib/prim/Agda/Builtin/Int.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2015-09-15T15:49:15.000Z
2015-09-15T15:49:15.000Z
src/data/lib/prim/Agda/Builtin/Int.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2020-05-16T20:10:05.000Z
2020-05-16T20:10:05.000Z
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Int where open import Agda.Builtin.Nat open import Agda.Builtin.String infix 8 pos -- Standard library uses this as +_ data Int : Set where pos : (n : Nat) → Int negsuc : (n : Nat) → Int {-# BUILTIN INTEGER Int #-} {-# BUILTIN INTEGERPOS pos #-} {-# BUILTIN INTEGERNEGSUC negsuc #-} primitive primShowInteger : Int → String
23.45
64
0.639659
34d399fa8c0ef9b0c5e3c8f11a4add28679d6599
1,003
agda
Agda
archive/agda-2/Oscar/Class/Substitution.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
archive/agda-2/Oscar/Class/Substitution.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
1
2019-04-29T00:35:04.000Z
2019-05-11T23:33:04.000Z
archive/agda-2/Oscar/Class/Substitution.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
module Oscar.Class.Substitution where open import Oscar.Data.Equality open import Oscar.Function open import Oscar.Relation open import Oscar.Level record Substitution {a} {A : Set a} {b} (B : A → Set b) {c} (C : A → Set c) : Set (a ⊔ b ⊔ c) where field ε : ∀ {m} → B m → C m _◇_ : ∀ {l m n} → (g : B m → C n) (f : B l → C m) → B l → C n ◇-left-identity : ∀ {m n} → (f : B m → C n) → ε ◇ f ≡̇ f ◇-right-identity : ∀ {m n} → (f : B m → C n) → f ◇ ε ≡̇ f ◇-associativity : ∀ {k l m n} (f : B k → C l) (g : B l → C m) (h : B m → C n) → h ◇ (g ◇ f) ≡̇ (h ◇ g) ◇ f open Substitution ⦃ … ⦄ public {-# DISPLAY Substitution._◇_ _ = _◇_ #-} instance Substitution-id : ∀ {a} {A : Set a} {bc} {BC : A → Set bc} → Substitution BC BC Substitution.ε Substitution-id = id Substitution._◇_ Substitution-id g f = g ∘ f Substitution.◇-left-identity Substitution-id _ _ = refl Substitution.◇-right-identity Substitution-id _ _ = refl Substitution.◇-associativity Substitution-id _ _ _ _ = refl
37.148148
110
0.58325
21f708be731970838702e15360ba81fa98cf8b89
155
agda
Agda
test/Fail/Issue5448-2.agda
MxmUrw/agda
6ede01fa854c5472e54f7d1799ca2c08ed316129
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue5448-2.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue5448-2.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --without-K #-} open import Agda.Builtin.Equality subst : {@0 A : Set} {x y : A} (@0 P : A → Set) → x ≡ y → P x → P y subst P refl p = p
17.222222
38
0.522581
35c59d14b4932ff3203bf69f203a736d2a110128
1,182
agda
Agda
notes/FOT/PA/Inductive/ImplicitArgumentInductionSL.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
11
2015-09-03T20:53:42.000Z
2021-09-12T16:09:54.000Z
notes/FOT/PA/Inductive/ImplicitArgumentInductionSL.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
2
2016-10-12T17:28:16.000Z
2017-01-01T14:34:26.000Z
notes/FOT/PA/Inductive/ImplicitArgumentInductionSL.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
3
2016-09-19T14:18:30.000Z
2018-03-14T08:50:00.000Z
------------------------------------------------------------------------------ -- Testing an implicit argument for natural numbers induction ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.PA.Inductive.ImplicitArgumentInductionSL where open import Data.Nat renaming ( suc to succ ) open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ succCong : ∀ {m n} → m ≡ n → succ m ≡ succ n succCong refl = refl -- N.B. It is not possible to use an implicit argument in the -- inductive hypothesis. ℕ-ind : (A : ℕ → Set) → A zero → (∀ {n} → A n → A (succ n)) → ∀ n → A n ℕ-ind A A0 h zero = A0 ℕ-ind A A0 h (succ n) = h (ℕ-ind A A0 h n) +-assoc : ∀ m n o → m + n + o ≡ m + (n + o) +-assoc m n o = ℕ-ind A A0 is m where A : ℕ → Set A i = i + n + o ≡ i + (n + o) A0 : A zero A0 = refl is : ∀ {i} → A i → A (succ i) is ih = succCong ih
31.105263
78
0.456853
34855abc8f404c585f18eeeb40d344ec01319f7c
344
agda
Agda
test/Fail/MissingDefinitions.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/MissingDefinitions.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/MissingDefinitions.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module MissingDefinitions where open import Agda.Builtin.Equality Q : Set data U : Set S : Set S = U T : S → Set T _ = U V : Set W : V → Set private X : Set module AB where data A : Set B : (a b : A) → a ≡ b mutual U₂ : Set data T₂ : U₂ → Set V₂ : (u₂ : U₂) → T₂ u₂ → Set data W₂ (u₂ : U₂) (t₂ : T₂ u₂) : V₂ u₂ t₂ → Set
11.096774
49
0.555233
041b6a6ce5413b9b86911e15e6e0692473a08513
6,094
agda
Agda
Cubical/Algebra/Semigroup/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/Algebra/Semigroup/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
1
2022-01-27T02:07:48.000Z
2022-01-27T02:07:48.000Z
Cubical/Algebra/Semigroup/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Semigroup.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Structures.Record open Iso private variable ℓ : Level -- Semigroups as a record, inspired by the Agda standard library: -- -- https://github.com/agda/agda-stdlib/blob/master/src/Algebra/Bundles.agda#L48 -- https://github.com/agda/agda-stdlib/blob/master/src/Algebra/Structures.agda#L50 -- -- Note that as we are using Path for all equations the IsMagma record -- would only contain isSet A if we had it. record IsSemigroup {A : Type ℓ} (_·_ : A → A → A) : Type ℓ where constructor issemigroup field is-set : isSet A assoc : (x y z : A) → x · (y · z) ≡ (x · y) · z record SemigroupStr (A : Type ℓ) : Type (ℓ-suc ℓ) where constructor semigroupstr field _·_ : A → A → A isSemigroup : IsSemigroup _·_ infixl 7 _·_ open IsSemigroup isSemigroup public Semigroup : Type (ℓ-suc ℓ) Semigroup = TypeWithStr _ SemigroupStr semigroup : (A : Type ℓ) (_·_ : A → A → A) (h : IsSemigroup _·_) → Semigroup semigroup A _·_ h = A , semigroupstr _·_ h record SemigroupEquiv (M N : Semigroup {ℓ}) (e : ⟨ M ⟩ ≃ ⟨ N ⟩) : Type ℓ where constructor semigroupequiv -- Shorter qualified names private module M = SemigroupStr (snd M) module N = SemigroupStr (snd N) field isHom : (x y : ⟨ M ⟩) → equivFun e (x M.· y) ≡ equivFun e x N.· equivFun e y open SemigroupStr open IsSemigroup open SemigroupEquiv -- Develop some theory about Semigroups using various general results -- that are stated using Σ-types. For this we define Semigroup as a -- nested Σ-type, prove that it's equivalent to the above record -- definition and then transport results along this equivalence. module SemigroupΣTheory {ℓ} where RawSemigroupStructure : Type ℓ → Type ℓ RawSemigroupStructure X = X → X → X RawSemigroupEquivStr = AutoEquivStr RawSemigroupStructure rawSemigroupUnivalentStr : UnivalentStr _ RawSemigroupEquivStr rawSemigroupUnivalentStr = autoUnivalentStr RawSemigroupStructure SemigroupAxioms : (A : Type ℓ) → RawSemigroupStructure A → Type ℓ SemigroupAxioms A _·_ = isSet A × ((x y z : A) → x · (y · z) ≡ (x · y) · z) SemigroupStructure : Type ℓ → Type ℓ SemigroupStructure = AxiomsStructure RawSemigroupStructure SemigroupAxioms SemigroupΣ : Type (ℓ-suc ℓ) SemigroupΣ = TypeWithStr ℓ SemigroupStructure isPropSemigroupAxioms : (A : Type ℓ) (_·_ : RawSemigroupStructure A) → isProp (SemigroupAxioms A _·_) isPropSemigroupAxioms _ _ = isPropΣ isPropIsSet λ isSetA → isPropΠ3 λ _ _ _ → isSetA _ _ SemigroupEquivStr : StrEquiv SemigroupStructure ℓ SemigroupEquivStr = AxiomsEquivStr RawSemigroupEquivStr SemigroupAxioms SemigroupAxiomsIsoIsSemigroup : {A : Type ℓ} (_·_ : RawSemigroupStructure A) → Iso (SemigroupAxioms A _·_) (IsSemigroup _·_) fun (SemigroupAxiomsIsoIsSemigroup s) (x , y) = issemigroup x y inv (SemigroupAxiomsIsoIsSemigroup s) M = is-set M , assoc M rightInv (SemigroupAxiomsIsoIsSemigroup s) _ = refl leftInv (SemigroupAxiomsIsoIsSemigroup s) _ = refl SemigroupAxioms≡IsSemigroup : {A : Type ℓ} (_·_ : RawSemigroupStructure A) → SemigroupAxioms _ _·_ ≡ IsSemigroup _·_ SemigroupAxioms≡IsSemigroup s = isoToPath (SemigroupAxiomsIsoIsSemigroup s) Semigroup→SemigroupΣ : Semigroup → SemigroupΣ Semigroup→SemigroupΣ (A , semigroupstr _·_ isSemigroup) = A , _·_ , SemigroupAxiomsIsoIsSemigroup _ .inv isSemigroup SemigroupΣ→Semigroup : SemigroupΣ → Semigroup SemigroupΣ→Semigroup (A , _·_ , isSemigroupΣ) = semigroup A _·_ (SemigroupAxiomsIsoIsSemigroup _ .fun isSemigroupΣ) SemigroupIsoSemigroupΣ : Iso Semigroup SemigroupΣ SemigroupIsoSemigroupΣ = iso Semigroup→SemigroupΣ SemigroupΣ→Semigroup (λ _ → refl) (λ _ → refl) semigroupUnivalentStr : UnivalentStr SemigroupStructure SemigroupEquivStr semigroupUnivalentStr = axiomsUnivalentStr _ isPropSemigroupAxioms rawSemigroupUnivalentStr SemigroupΣPath : (M N : SemigroupΣ) → (M ≃[ SemigroupEquivStr ] N) ≃ (M ≡ N) SemigroupΣPath = SIP semigroupUnivalentStr SemigroupEquivΣ : (M N : Semigroup) → Type ℓ SemigroupEquivΣ M N = Semigroup→SemigroupΣ M ≃[ SemigroupEquivStr ] Semigroup→SemigroupΣ N SemigroupIsoΣPath : {M N : Semigroup} → Iso (Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] SemigroupEquiv M N e) (SemigroupEquivΣ M N) fun SemigroupIsoΣPath (e , x) = e , isHom x inv SemigroupIsoΣPath (e , h) = e , semigroupequiv h rightInv SemigroupIsoΣPath _ = refl leftInv SemigroupIsoΣPath _ = refl SemigroupPath : (M N : Semigroup) → (Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] SemigroupEquiv M N e) ≃ (M ≡ N) SemigroupPath M N = Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] SemigroupEquiv M N e ≃⟨ isoToEquiv SemigroupIsoΣPath ⟩ SemigroupEquivΣ M N ≃⟨ SemigroupΣPath _ _ ⟩ Semigroup→SemigroupΣ M ≡ Semigroup→SemigroupΣ N ≃⟨ isoToEquiv (invIso (congIso SemigroupIsoSemigroupΣ)) ⟩ M ≡ N ■ -- We now extract the important results from the above module isPropIsSemigroup : {A : Type ℓ} (_·_ : A → A → A) → isProp (IsSemigroup _·_) isPropIsSemigroup _·_ = subst isProp (SemigroupΣTheory.SemigroupAxioms≡IsSemigroup _·_) (SemigroupΣTheory.isPropSemigroupAxioms _ _·_) SemigroupPath : (M N : Semigroup {ℓ}) → (Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] SemigroupEquiv M N e) ≃ (M ≡ N) SemigroupPath {ℓ = ℓ} = SIP (autoUnivalentRecord (autoRecordSpec (SemigroupStr {ℓ}) SemigroupEquiv (fields: data[ _·_ ∣ isHom ] prop[ isSemigroup ∣ (λ _ → isPropIsSemigroup _) ])) _ _)
36.491018
113
0.702822
fd3e89cb89848f21ca93f687bf3b33174b841d38
106
agda
Agda
test/Fail/Issue1644.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue1644.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue1644.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module _ where postulate A B : Set {-# DISPLAY A = B #-} {-# DISPLAY B = A #-} loop : A loop = {!!}
8.833333
21
0.5
21e9a449e68be768a1335d9b446fd28988cf3607
11,197
agda
Agda
Definition/Conversion.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
2
2018-06-21T08:39:01.000Z
2022-01-17T16:13:53.000Z
Definition/Conversion.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
null
null
null
Definition/Conversion.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
2
2022-01-26T14:55:51.000Z
2022-02-15T19:42:19.000Z
-- Algorithmic equality. {-# OPTIONS --safe #-} module Definition.Conversion where open import Definition.Untyped open import Definition.Typed open import Tools.Nat import Tools.PropositionalEquality as PE infix 10 _⊢_~_↑_^_ infix 10 _⊢_[conv↑]_^_ infix 10 _⊢_[conv↓]_^_ infix 10 _⊢_[conv↑]_∷_^_ infix 10 _⊢_[conv↓]_∷_^_ infix 10 _⊢_[genconv↑]_∷_^_ mutual -- Neutral equality. data _⊢_~_↑!_^_ (Γ : Con Term) : (k l A : Term) → TypeLevel → Set where var-refl : ∀ {x y A l} → Γ ⊢ var x ∷ A ^ [ ! , l ] → x PE.≡ y → Γ ⊢ var x ~ var y ↑! A ^ l app-cong : ∀ {k l t v F rF lF lG G lΠ} → Γ ⊢ k ~ l ↓! Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ ι lΠ → Γ ⊢ t [genconv↑] v ∷ F ^ [ rF , ι lF ] → Γ ⊢ k ∘ t ^ lΠ ~ l ∘ v ^ lΠ ↑! G [ t ] ^ ι lG natrec-cong : ∀ {k l h g a₀ b₀ F G lF} → Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F [conv↑] G ^ [ ! , ι lF ] → Γ ⊢ a₀ [conv↑] b₀ ∷ F [ zero ] ^ ι lF → Γ ⊢ h [conv↑] g ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° lF ▹▹ F [ suc (var 0) ]↑ ° lF ° lF) ° lF ° lF ^ ι lF → Γ ⊢ k ~ l ↓! ℕ ^ ι ⁰ → Γ ⊢ natrec lF F a₀ h k ~ natrec lF G b₀ g l ↑! F [ k ] ^ ι lF Emptyrec-cong : ∀ {k l F G ll lEmpty} → Γ ⊢ F [conv↑] G ^ [ ! , ι ll ] → Γ ⊢ k ~ l ↑% Empty lEmpty ^ ι lEmpty → Γ ⊢ Emptyrec ll lEmpty F k ~ Emptyrec ll lEmpty G l ↑! F ^ ι ll Id-cong : ∀ {l A A' t t' u u'} → Γ ⊢ A ~ A' ↓! U l ^ next l → Γ ⊢ t [conv↑] t' ∷ A ^ ι l → Γ ⊢ u [conv↑] u' ∷ A ^ ι l → Γ ⊢ Id A t u ~ Id A' t' u' ↑! SProp l ^ next l Id-ℕ : ∀ {t t' u u'} → Γ ⊢ t ~ t' ↓! ℕ ^ ι ⁰ → Γ ⊢ u [conv↑] u' ∷ ℕ ^ ι ⁰ → Γ ⊢ Id ℕ t u ~ Id ℕ t' u' ↑! SProp ⁰ ^ next ⁰ Id-ℕ0 : ∀ {t t'} → Γ ⊢ t ~ t' ↓! ℕ ^ ι ⁰ → Γ ⊢ Id ℕ zero t ~ Id ℕ zero t' ↑! SProp ⁰ ^ next ⁰ Id-ℕS : ∀ {t t' u u'} → Γ ⊢ t [conv↑] t' ∷ ℕ ^ ι ⁰ → Γ ⊢ u ~ u' ↓! ℕ ^ ι ⁰ → Γ ⊢ Id ℕ (suc t) u ~ Id ℕ (suc t') u' ↑! SProp ⁰ ^ next ⁰ Id-U : ∀ {t t' u u'} → Γ ⊢ t ~ t' ↓! U ⁰ ^ ι ¹ → Γ ⊢ u [conv↑] u' ∷ U ⁰ ^ ι ¹ → Γ ⊢ Id (U ⁰) t u ~ Id (U ⁰) t' u' ↑! SProp ¹ ^ next ¹ Id-Uℕ : ∀ {t t'} → Γ ⊢ t ~ t' ↓! U ⁰ ^ ι ¹ → Γ ⊢ Id (U ⁰) ℕ t ~ Id (U ⁰) ℕ t' ↑! SProp ¹ ^ next ¹ Id-UΠ : ∀ {A rA B A' B' t t'} → Γ ⊢ Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹ → Γ ⊢ t ~ t' ↓! U ⁰ ^ ι ¹ → Γ ⊢ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰ ) t ~ Id (U ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰ ) t' ↑! SProp ¹ ^ next ¹ cast-cong : ∀ {A A' B B' t t' e e'} → Γ ⊢ A ~ A' ↓! U ⁰ ^ next ⁰ → Γ ⊢ B [conv↑] B' ∷ U ⁰ ^ ι ¹ → Γ ⊢ t [conv↑] t' ∷ A ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) A B) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) A' B') ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ A B e t ~ cast ⁰ A' B' e' t' ↑! B ^ ι ⁰ cast-ℕ : ∀ {A A' t t' e e'} → Γ ⊢ A ~ A' ↓! U ⁰ ^ next ⁰ → Γ ⊢ t [conv↑] t' ∷ ℕ ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) ℕ A) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) ℕ A') ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ ℕ A e t ~ cast ⁰ ℕ A' e' t' ↑! A ^ ι ⁰ cast-ℕℕ : ∀ {t t' e e'} → Γ ⊢ t ~ t' ↓! ℕ ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) ℕ ℕ) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) ℕ ℕ) ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ ℕ ℕ e t ~ cast ⁰ ℕ ℕ e' t' ↑! ℕ ^ ι ⁰ cast-Π : ∀ {A rA P A' P' B B' t t' e e'} → Γ ⊢ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ next ⁰ → Γ ⊢ B ~ B' ↓! U ⁰ ^ next ⁰ → Γ ⊢ t [conv↑] t' ∷ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) B) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) B') ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) B e t ~ cast ⁰ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) B' e' t' ↑! B ^ ι ⁰ cast-Πℕ : ∀ {A rA P A' P' t t' e e'} → Γ ⊢ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹ → Γ ⊢ t [conv↑] t' ∷ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) ℕ) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) ℕ) ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) ℕ e t ~ cast ⁰ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) ℕ e' t' ↑! ℕ ^ ι ⁰ cast-ℕΠ : ∀ {A rA P A' P' t t' e e'} → Γ ⊢ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹ → Γ ⊢ t [conv↑] t' ∷ ℕ ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) ℕ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) ℕ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ ℕ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) e t ~ cast ⁰ ℕ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) e' t' ↑! (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) ^ ι ⁰ cast-ΠΠ%! : ∀ {A P A' P' B Q B' Q' t t' e e'} → Γ ⊢ Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ % ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹ → Γ ⊢ Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ [conv↑] Π B' ^ ! ° ⁰ ▹ Q' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹ → Γ ⊢ t [conv↑] t' ∷ Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ % ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ ! ° ⁰ ▹ Q' ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ (Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ ) e t ~ cast ⁰ (Π A' ^ % ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ ! ° ⁰ ▹ Q' ° ⁰ ° ⁰ ) e' t' ↑! (Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ ) ^ ι ⁰ cast-ΠΠ!% : ∀ {A P A' P' B Q B' Q' t t' e e'} → Γ ⊢ Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ ! ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹ → Γ ⊢ Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ [conv↑] Π B' ^ % ° ⁰ ▹ Q' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹ → Γ ⊢ t [conv↑] t' ∷ Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰ → Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ] → Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ ! ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ % ° ⁰ ▹ Q' ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ] → Γ ⊢ cast ⁰ (Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ ) e t ~ cast ⁰ (Π A' ^ ! ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ % ° ⁰ ▹ Q' ° ⁰ ° ⁰ ) e' t' ↑! (Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ ) ^ ι ⁰ record _⊢_~_↑%_^_ (Γ : Con Term) (k l A : Term) (ll : TypeLevel) : Set where inductive constructor %~↑ field ⊢k : Γ ⊢ k ∷ A ^ [ % , ll ] ⊢l : Γ ⊢ l ∷ A ^ [ % , ll ] data _⊢_~_↑_^_ (Γ : Con Term) : (k l A : Term) → TypeInfo → Set where ~↑! : ∀ {k l A ll} → Γ ⊢ k ~ l ↑! A ^ ll → Γ ⊢ k ~ l ↑ A ^ [ ! , ll ] ~↑% : ∀ {k l A ll} → Γ ⊢ k ~ l ↑% A ^ ll → Γ ⊢ k ~ l ↑ A ^ [ % , ll ] -- Neutral equality with types in WHNF. record _⊢_~_↓!_^_ (Γ : Con Term) (k l B : Term) (ll : TypeLevel) : Set where inductive constructor [~] field A : Term D : Γ ⊢ A ⇒* B ^ [ ! , ll ] whnfB : Whnf B k~l : Γ ⊢ k ~ l ↑! A ^ ll -- Type equality. record _⊢_[conv↑]_^_ (Γ : Con Term) (A B : Term) (rA : TypeInfo) : Set where inductive constructor [↑] field A′ B′ : Term D : Γ ⊢ A ⇒* A′ ^ rA D′ : Γ ⊢ B ⇒* B′ ^ rA whnfA′ : Whnf A′ whnfB′ : Whnf B′ A′<>B′ : Γ ⊢ A′ [conv↓] B′ ^ rA -- Type equality with types in WHNF. data _⊢_[conv↓]_^_ (Γ : Con Term) : (A B : Term) → TypeInfo → Set where U-refl : ∀ {r r' } → r PE.≡ r' -- needed for K issues → ⊢ Γ → Γ ⊢ Univ r ¹ [conv↓] Univ r' ¹ ^ [ ! , next ¹ ] univ : ∀ {A B r l} → Γ ⊢ A [conv↓] B ∷ Univ r l ^ next l → Γ ⊢ A [conv↓] B ^ [ r , ι l ] -- Term equality. record _⊢_[conv↑]_∷_^_ (Γ : Con Term) (t u A : Term) (l : TypeLevel) : Set where inductive constructor [↑]ₜ field B t′ u′ : Term D : Γ ⊢ A ⇒* B ^ [ ! , l ] d : Γ ⊢ t ⇒* t′ ∷ B ^ l d′ : Γ ⊢ u ⇒* u′ ∷ B ^ l whnfB : Whnf B whnft′ : Whnf t′ whnfu′ : Whnf u′ t<>u : Γ ⊢ t′ [conv↓] u′ ∷ B ^ l -- Term equality with types and terms in WHNF. data _⊢_[conv↓]_∷_^_ (Γ : Con Term) : (t u A : Term) (l : TypeLevel) → Set where U-refl : ∀ {r r' } → r PE.≡ r' -- needed for K issues → ⊢ Γ → Γ ⊢ Univ r ⁰ [conv↓] Univ r' ⁰ ∷ U ¹ ^ next ¹ ne : ∀ {r K L lU l} → Γ ⊢ K ~ L ↓! Univ r lU ^ l → Γ ⊢ K [conv↓] L ∷ Univ r lU ^ l ℕ-refl : ⊢ Γ → Γ ⊢ ℕ [conv↓] ℕ ∷ U ⁰ ^ next ⁰ Empty-refl : ∀ {l ll} → ll PE.≡ next l → ⊢ Γ → Γ ⊢ Empty l [conv↓] Empty l ∷ SProp l ^ ll Π-cong : ∀ {F G H E rF rH rΠ lF lH lG lE lΠ ll} → ll PE.≡ next lΠ → rF PE.≡ rH -- needed for K issues → lF PE.≡ lH -- needed for K issues → lG PE.≡ lE -- needed for K issues → lF ≤ lΠ → lG ≤ lΠ → Γ ⊢ F ^ [ rF , ι lF ] → Γ ⊢ F [conv↑] H ∷ Univ rF lF ^ next lF → Γ ∙ F ^ [ rF , ι lF ] ⊢ G [conv↑] E ∷ Univ rΠ lG ^ next lG → Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° lΠ [conv↓] Π H ^ rH ° lH ▹ E ° lE ° lΠ ∷ Univ rΠ lΠ ^ ll ∃-cong : ∀ {F G H E l ll} → ll PE.≡ next l → Γ ⊢ F ^ [ % , ι l ] → Γ ⊢ F [conv↑] H ∷ SProp l ^ next l → Γ ∙ F ^ [ % , ι l ] ⊢ G [conv↑] E ∷ SProp l ^ next l → Γ ⊢ ∃ F ▹ G [conv↓] ∃ H ▹ E ∷ SProp l ^ ll ℕ-ins : ∀ {k l} → Γ ⊢ k ~ l ↓! ℕ ^ ι ⁰ → Γ ⊢ k [conv↓] l ∷ ℕ ^ ι ⁰ ne-ins : ∀ {k l M N ll} → Γ ⊢ k ∷ N ^ [ ! , ι ll ] → Γ ⊢ l ∷ N ^ [ ! , ι ll ] → Neutral N → Γ ⊢ k ~ l ↓! M ^ ι ll → Γ ⊢ k [conv↓] l ∷ N ^ ι ll zero-refl : ⊢ Γ → Γ ⊢ zero [conv↓] zero ∷ ℕ ^ ι ⁰ suc-cong : ∀ {m n} → Γ ⊢ m [conv↑] n ∷ ℕ ^ ι ⁰ → Γ ⊢ suc m [conv↓] suc n ∷ ℕ ^ ι ⁰ η-eq : ∀ {f g F G rF lF lG l} → lF ≤ l → lG ≤ l → Γ ⊢ F ^ [ rF , ι lF ] → Γ ⊢ f ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ] → Γ ⊢ g ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ] → Function f → Function g → Γ ∙ F ^ [ rF , ι lF ] ⊢ wk1 f ∘ var 0 ^ l [conv↑] wk1 g ∘ var 0 ^ l ∷ G ^ ι lG → Γ ⊢ f [conv↓] g ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ ι l _⊢_[genconv↑]_∷_^_ : (Γ : Con Term) (t u A : Term) (r : TypeInfo) → Set _⊢_[genconv↑]_∷_^_ Γ k l A [ ! , ll ] = Γ ⊢ k [conv↑] l ∷ A ^ ll _⊢_[genconv↑]_∷_^_ Γ k l A [ % , ll ] = Γ ⊢ k ~ l ↑% A ^ ll var-refl′ : ∀ {Γ x A rA ll} → Γ ⊢ var x ∷ A ^ [ rA , ll ] → Γ ⊢ var x ~ var x ↑ A ^ [ rA , ll ] var-refl′ {rA = !} ⊢x = ~↑! (var-refl ⊢x PE.refl) var-refl′ {rA = %} ⊢x = ~↑% (%~↑ ⊢x ⊢x)
46.460581
144
0.327052
fd4b6472c93d9f288f3f37b3a3fdda6688d1a0da
1,021
agda
Agda
test/fail/Issue970.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
1
2018-10-10T17:08:44.000Z
2018-10-10T17:08:44.000Z
test/fail/Issue970.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
null
null
null
test/fail/Issue970.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
null
null
null
data Dec (A : Set) : Set where yes : A → Dec A no : Dec A record ⊤ : Set where constructor tt data _≡_ {A : Set}(x : A) : A → Set where refl : x ≡ x subst : ∀ {A}(P : A → Set){x y} → x ≡ y → P x → P y subst P refl px = px cong : ∀ {A B}(f : A → B){x y} → x ≡ y → f x ≡ f y cong f refl = refl postulate _≟_ : (n n' : ⊤) → Dec (n ≡ n') record _×_ A B : Set where constructor _,_ field proj₁ : A proj₂ : B open _×_ data Maybe : Set where nothing : Maybe data Blah (a : Maybe × ⊤) : Set where blah : {b : Maybe × ⊤} → Blah b → Blah a update : {A : Set} → ⊤ → A → A update n m with n ≟ n update n m | yes p = m update n m | no = m lem-upd : ∀ {A} n (m : A) → update n m ≡ m lem-upd n m with n ≟ n ... | yes p = refl ... | no = refl bug : {x : Maybe × ⊤} → proj₁ x ≡ nothing → Blah x bug ia = blah (bug (subst {⊤} (λ _ → proj₁ {B = ⊤} (update tt (nothing , tt)) ≡ nothing) refl (cong proj₁ (lem-upd _ _))))
22.195652
72
0.476983
210439c8c2e2d91359e987cc187cbd02fe133adc
872
agda
Agda
theorems/homotopy/PathSetIsInitalCover.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/homotopy/PathSetIsInitalCover.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/homotopy/PathSetIsInitalCover.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.PathSetIsInitalCover {i} (X : Ptd i) -- and an arbitrary covering {k} (⊙cov : ⊙Cover X k) where open Cover private univ-cover = path-set-cover X module ⊙cov = ⊙Cover ⊙cov -- Weak initiality by transport. quotient-cover : CoverHom univ-cover ⊙cov.cov quotient-cover _ p = cover-trace ⊙cov.cov ⊙cov.pt p -- Strong initiality by path induction. module Uniqueness (cover-hom : CoverHom univ-cover ⊙cov.cov) (pres-pt : cover-hom (pt X) idp₀ == ⊙cov.pt) where private lemma₁ : ∀ a p → cover-hom a [ p ] == quotient-cover a [ p ] lemma₁ ._ idp = pres-pt lemma₂ : ∀ a p → cover-hom a p == quotient-cover a p lemma₂ a = Trunc-elim (lemma₁ a) theorem : cover-hom == quotient-cover theorem = λ= λ a → λ= $ lemma₂ a
24.914286
66
0.614679
34562899aa5dcc1099db0468ba7dd9a82004dc3e
1,447
agda
Agda
notes/FOT/FOTC/UnguardedCorecursion/Alter/PropertiesI.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
11
2015-09-03T20:53:42.000Z
2021-09-12T16:09:54.000Z
notes/FOT/FOTC/UnguardedCorecursion/Alter/PropertiesI.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
2
2016-10-12T17:28:16.000Z
2017-01-01T14:34:26.000Z
notes/FOT/FOTC/UnguardedCorecursion/Alter/PropertiesI.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
3
2016-09-19T14:18:30.000Z
2018-03-14T08:50:00.000Z
------------------------------------------------------------------------------ -- Properties of the alter list ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.UnguardedCorecursion.Alter.PropertiesI where open import FOT.FOTC.UnguardedCorecursion.Alter.Alter open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.List open import FOTC.Data.Stream.Type open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ -- TODO (23 December 2013). -- alter-Stream : Stream alter -- alter-Stream = Stream-coind A h refl -- where -- A : D → Set -- A xs = xs ≡ alter -- h : ∀ {xs} → A xs → ∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs' -- h Ax = true , (false ∷ alter) , trans Ax alter-eq , {!!} -- TODO (23 December 2013). -- alter≈alter' : alter ≈ alter' -- alter≈alter' = ≈-coind B h₁ h₂ -- where -- B : D → D → Set -- B xs ys = xs ≡ xs -- h₁ : B alter alter' → ∃[ x' ] ∃[ xs' ] ∃[ ys' ] -- alter ≡ x' ∷ xs' ∧ alter' ≡ x' ∷ ys' ∧ B xs' ys' -- h₁ _ = true -- , false ∷ alter -- , map not₀ alter' -- , alter-eq -- , alter'-eq -- , refl -- h₂ : B alter alter' -- h₂ = refl
29.530612
78
0.454734
4b3aa74abacf4f0f1343bff4d96077cd2c9426e3
1,148
agda
Agda
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Symmetric.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
null
null
null
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Symmetric.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
null
null
null
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Symmetric.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- The Agda standard library -- -- Symmetric closures of binary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.Construct.Closure.Symmetric where open import Data.Sum as Sum using (_⊎_) open import Function using (id) open import Relation.Binary open Sum public using () renaming (inj₁ to fwd; inj₂ to bwd) -- The symmetric closure of a relation. SymClosure : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Rel A ℓ SymClosure _∼_ a b = a ∼ b ⊎ b ∼ a module _ {a ℓ} {A : Set a} where -- Symmetric closures are symmetric. symmetric : (_∼_ : Rel A ℓ) → Symmetric (SymClosure _∼_) symmetric _ (fwd a∼b) = bwd a∼b symmetric _ (bwd b∼a) = fwd b∼a -- A generalised variant of map which allows the index type to change. gmap : ∀ {b ℓ₂} {B : Set b} {P : Rel A ℓ} {Q : Rel B ℓ₂} → (f : A → B) → P =[ f ]⇒ Q → SymClosure P =[ f ]⇒ SymClosure Q gmap _ g = Sum.map g g map : ∀ {ℓ₂} {P : Rel A ℓ} {Q : Rel A ℓ₂} → P ⇒ Q → SymClosure P ⇒ SymClosure Q map = gmap id
29.435897
72
0.540941
212067b74910ba670b440a4993266af759ae9a39
137
agda
Agda
prototyping/Examples.agda
JohnnyMorganz/luau
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
[ "MIT" ]
1
2022-03-18T04:10:20.000Z
2022-03-18T04:10:20.000Z
prototyping/Examples.agda
JohnnyMorganz/luau
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
[ "MIT" ]
null
null
null
prototyping/Examples.agda
JohnnyMorganz/luau
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
[ "MIT" ]
null
null
null
{-# OPTIONS --rewriting #-} module Examples where import Examples.Syntax import Examples.OpSem import Examples.Run import Examples.Type
17.125
27
0.79562
d1dc4973749fac1a0305091492f83002d6e52751
10,028
agda
Agda
Data/AVLTree/Internal.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
Data/AVLTree/Internal.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
null
null
null
Data/AVLTree/Internal.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --cubical --safe --postfix-projections #-} open import Prelude open import Relation.Binary module Data.AVLTree.Internal {k} {K : Type k} {r₁ r₂} (totalOrder : TotalOrder K r₁ r₂) where open import Relation.Binary.Construct.Bounded totalOrder open import Data.Nat using (_+_) open TotalOrder totalOrder using (_<?_; compare) open TotalOrder b-ord using (<-trans) renaming (refl to <-refl) import Data.Empty.UniversePolymorphic as Poly private variable n m l : ℕ data Bal : ℕ → ℕ → ℕ → Type where ll : Bal (suc n) n (suc n) ee : Bal n n n rr : Bal n (suc n) (suc n) balr : Bal n m l → Bal l n l balr ll = ee balr ee = ee balr rr = ll ball : Bal n m l → Bal m l l ball ll = rr ball ee = ee ball rr = ee private variable v : Level Val : K → Type v data Tree {v} (Val : K → Type v) (lb ub : [∙]) : ℕ → Type (k ℓ⊔ r₁ ℓ⊔ v) where leaf : (lb<ub : lb [<] ub) → Tree Val lb ub zero node : (key : K) (val : Val key) (bal : Bal n m l) (lchild : Tree Val lb [ key ] n) (rchild : Tree Val [ key ] ub m) → Tree Val lb ub (suc l) private variable lb ub : [∙] data Inc {t} (T : ℕ → Type t) (n : ℕ) : Type t where stay : T n → Inc T n high : T (suc n) → Inc T n private variable t : Level N : ℕ → Type t rotʳ : (x : K) → (xv : Val x) → (ls : Tree Val lb [ x ] (2 + n)) → (rs : Tree Val [ x ] ub n) → Inc (Tree Val lb ub) (2 + n) rotʳ y yv (node x xv ll xl xr) zs = stay (node x xv ee xl (node y yv ee xr zs)) rotʳ y yv (node x xv ee xl xr) zs = high (node x xv rr xl (node y yv ll xr zs)) rotʳ z zv (node x xv rr xl (node y yv bl yl yr)) zr = stay (node y yv ee (node x xv (balr bl) xl yl) (node z zv (ball bl) yr zr)) rotˡ : (x : K) → (xv : Val x) → (ls : Tree Val lb [ x ] n) → (rs : Tree Val [ x ] ub (2 + n)) → Inc (Tree Val lb ub) (2 + n) rotˡ x xv xl (node y yv ee yl yr) = high (node y yv ll (node x xv rr xl yl) yr) rotˡ x xv xl (node y yv rr yl yr) = stay (node y yv ee (node x xv ee xl yl) yr) rotˡ x xv xl (node z zv ll (node y yv bl yl yr) zr) = stay (node y yv ee (node x xv (balr bl) xl yl) (node z zv (ball bl) yr zr)) insertWith : (x : K) → Val x → ((new : Val x) → (old : Val x) → Val x) → (lb [<] [ x ]) → ([ x ] [<] ub) → (tr : Tree Val lb ub n) → Inc (Tree Val lb ub) n insertWith x xv xf lb<x x<ub (leaf lb<ub) = high (node x xv ee (leaf lb<x) (leaf x<ub)) insertWith x xv xf lb<x x<ub (node y yv bal ls rs) with compare x y ... | lt x<y with insertWith x xv xf lb<x x<y ls ... | stay ls′ = stay (node y yv bal ls′ rs) ... | high ls′ with bal ... | ll = rotʳ y yv ls′ rs ... | ee = high (node y yv ll ls′ rs) ... | rr = stay (node y yv ee ls′ rs) insertWith x xv xf lb<x x<ub (node y yv bal ls rs) | gt y<x with insertWith x xv xf y<x x<ub rs ... | stay rs′ = stay (node y yv bal ls rs′) ... | high rs′ with bal ... | ll = stay (node y yv ee ls rs′) ... | ee = high (node y yv rr ls rs′) ... | rr = rotˡ y yv ls rs′ insertWith x xv xf lb<x x<ub (node y yv bal ls rs) | eq x≡y = stay (node y (subst _ x≡y (xf xv (subst _ (sym x≡y) yv))) bal ls rs) lookup : (x : K) → Tree Val lb ub n → Maybe (Val x) lookup x (leaf lb<ub) = nothing lookup x (node y val bal lhs rhs) with compare y x ... | lt x<y = lookup x lhs ... | eq x≡y = just (subst _ x≡y val) ... | gt x>y = lookup x rhs record Cons (Val : K → Type v) (lb ub : [∙]) (h : ℕ) : Type (k ℓ⊔ v ℓ⊔ r₁) where constructor cons field head : K val : Val head bounds : lb [<] [ head ] tail : Inc (Tree Val [ head ] ub) h open Cons public map-tail : ∀ {ub₁ ub₂} → Cons Val lb ub₁ n → (∀ {lb} → Inc (Tree Val lb ub₁) n → Inc (Tree Val lb ub₂) m) → Cons Val lb ub₂ m map-tail (cons h v b t) f = cons h v b (f t) uncons : (x : K) → Val x → Bal n m l → Tree Val lb [ x ] n → Tree Val [ x ] ub m → Cons Val lb ub l uncons x xv bl (leaf lb<ub) rhs .head = x uncons x xv bl (leaf lb<ub) rhs .val = xv uncons x xv bl (leaf lb<ub) rhs .bounds = lb<ub uncons x xv ee (leaf lb<ub) rhs .tail = stay rhs uncons x xv rr (leaf lb<ub) rhs .tail = stay rhs uncons x xv bl (node y yv yb ls yrs) rs = map-tail (uncons y yv yb ls yrs) λ { (high ys) → high (node x xv bl ys rs) ; (stay ys) → case bl of λ { ll → stay (node x xv ee ys rs) ; ee → high (node x xv rr ys rs) ; rr → rotˡ x xv ys rs } } ext : ∀ {ub′} → ub [<] ub′ → Tree Val lb ub n → Tree Val lb ub′ n ext {lb = lb} ub<ub′ (leaf lb<ub) = leaf (<-trans {x = lb} lb<ub ub<ub′) ext ub<ub′ (node x xv bal lhs rhs) = node x xv bal lhs (ext ub<ub′ rhs) join : ∀ {x} → Tree Val lb [ x ] m → Bal m n l → Tree Val [ x ] ub n → Inc (Tree Val lb ub) l join lhs ll (leaf lb<ub) = stay (ext lb<ub lhs) join {lb = lb} (leaf lb<ub₁) ee (leaf lb<ub) = stay (leaf (<-trans {x = lb} lb<ub₁ lb<ub)) join lhs bl (node x xv xb xl xr) with uncons x xv xb xl xr ... | cons k′ v′ l<u (high tr′) = high (node k′ v′ bl (ext l<u lhs) tr′) ... | cons k′ v′ l<u (stay tr′) with bl ... | ll = rotʳ k′ v′ (ext l<u lhs) tr′ ... | ee = high (node k′ v′ ll (ext l<u lhs) tr′) ... | rr = stay (node k′ v′ ee (ext l<u lhs) tr′) data Decr {t} (T : ℕ → Type t) : ℕ → Type t where same : T n → Decr T n decr : T n → Decr T (suc n) inc→dec : Inc N n → Decr N (suc n) inc→dec (stay x) = decr x inc→dec (high x) = same x delete : (x : K) → Tree Val lb ub n → Decr (Tree Val lb ub) n delete x (leaf l<u) = same (leaf l<u) delete x (node y yv b l r) with compare x y delete x (node y yv b l r) | eq _ = inc→dec (join l b r) delete x (node y yv b l r) | lt a with delete x l ... | same l′ = same (node y yv b l′ r) ... | decr l′ with b ... | ll = decr (node y yv ee l′ r) ... | ee = same (node y yv rr l′ r) ... | rr = inc→dec (rotˡ y yv l′ r) delete x (node y yv b l r) | gt c with delete x r ... | same r′ = same (node y yv b l r′) ... | decr r′ with b ... | ll = inc→dec (rotʳ y yv l r′) ... | ee = same (node y yv ll l r′) ... | rr = decr (node y yv ee l r′) data Change {t} (T : ℕ → Type t) : ℕ → Type t where up : T (suc n) → Change T n ev : T n → Change T n dn : T n → Change T (suc n) inc→changeup : Inc N n → Change N (suc n) inc→changeup (stay x) = dn x inc→changeup (high x) = ev x inc→changedn : Inc N n → Change N n inc→changedn (stay x) = ev x inc→changedn (high x) = up x _<_<_ : [∙] → K → [∙] → Type _ l < x < u = l [<] [ x ] × [ x ] [<] u alter : (x : K) → (Maybe (Val x) → Maybe (Val x)) → Tree Val lb ub n → lb < x < ub → Change (Tree Val lb ub) n alter x f (leaf l<u) (l , u) with f nothing ... | just xv = up (node x xv ee (leaf l) (leaf u)) ... | nothing = ev (leaf l<u) alter x f (node y yv b tl tr) (l , u) with compare x y alter x f (node y yv b tl tr) (l , u) | eq x≡y with f (just (subst _ (sym x≡y) yv)) ... | just xv = ev (node y (subst _ x≡y xv) b tl tr) ... | nothing = inc→changeup (join tl b tr) alter x f (node y yv b tl tr) (l , u) | lt a with alter x f tl (l , a) | b ... | ev tl′ | _ = ev (node y yv b tl′ tr) ... | up tl′ | ll = inc→changedn (rotʳ y yv tl′ tr) ... | up tl′ | ee = up (node y yv ll tl′ tr) ... | up tl′ | rr = ev (node y yv ee tl′ tr) ... | dn tl′ | ll = dn (node y yv ee tl′ tr) ... | dn tl′ | ee = ev (node y yv rr tl′ tr) ... | dn tl′ | rr = inc→changeup (rotˡ y yv tl′ tr) alter x f (node y yv b tl tr) (l , u) | gt c with alter x f tr (c , u) | b ... | ev tr′ | _ = ev (node y yv b tl tr′) ... | up tr′ | ll = ev (node y yv ee tl tr′) ... | up tr′ | ee = up (node y yv rr tl tr′) ... | up tr′ | rr = inc→changedn (rotˡ y yv tl tr′) ... | dn tr′ | ll = inc→changeup (rotʳ y yv tl tr′) ... | dn tr′ | ee = ev (node y yv ll tl tr′) ... | dn tr′ | rr = dn (node y yv ee tl tr′) open import Lens alterF : (x : K) → Tree Val lb ub n → lb < x < ub → LensPart (Change (Tree Val lb ub) n) (Maybe (Val x)) alterF x xs bnds = go (ev xs) x xs bnds id where go : A → (x : K) → Tree Val lb ub n → lb < x < ub → (Change (Tree Val lb ub) n → A) → LensPart A (Maybe (Val x)) go xs x (leaf lb<ub) (l , u) k = λ where .get → nothing .set nothing → xs .set (just xv) → k (up (node x xv ee (leaf l) (leaf u))) go xs x (node y yv bl yl yr) (l , u) k with compare x y go xs x (node y yv bl yl yr) (l , u) k | eq x≡y = λ where .get → just (subst _ (sym x≡y) yv) .set nothing → k (inc→changeup (join yl bl yr)) .set (just xv) → k (ev (node y (subst _ x≡y xv) bl yl yr)) go xs x (node y yv bl yl yr) (l , u) k | lt x<y = go xs x yl (l , x<y) λ { (up yl′) → case bl of λ { ll → k (inc→changedn (rotʳ y yv yl′ yr)) ; ee → k (up (node y yv ll yl′ yr)) ; rr → k (ev (node y yv ee yl′ yr)) } ; (ev yl′) → k (ev (node y yv bl yl′ yr)) ; (dn yl′) → case bl of λ { rr → k (inc→changeup (rotˡ y yv yl′ yr)) ; ee → k (ev (node y yv rr yl′ yr)) ; ll → k (dn (node y yv ee yl′ yr)) } } go xs x (node y yv bl yl yr) (l , u) k | gt x>y = go xs x yr (x>y , u) λ { (up yr′) → case bl of λ { rr → k (inc→changedn (rotˡ y yv yl yr′)) ; ee → k (up (node y yv rr yl yr′)) ; ll → k (ev (node y yv ee yl yr′)) } ; (ev yr′) → k (ev (node y yv bl yl yr′)) ; (dn yr′) → case bl of λ { ll → k (inc→changeup (rotʳ y yv yl yr′)) ; ee → k (ev (node y yv ll yl yr′)) ; rr → k (dn (node y yv ee yl yr′)) } } open import Data.List toList⊙ : Tree Val lb ub n → List (∃ x × Val x) → List (∃ x × Val x) toList⊙ (leaf lb<ub) ks = ks toList⊙ (node x xv bal xl xr) ks = toList⊙ xl ((x , xv) ∷ toList⊙ xr ks) toList : Tree Val lb ub n → List (∃ x × Val x) toList xs = toList⊙ xs []
33.651007
129
0.51446
fdb959123b24fa66fbb299406cebe83e7a0ecdb7
1,746
agda
Agda
src/Algebra/Dioid.agda
algebraic-graphs/alga-theory
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
[ "MIT" ]
60
2017-12-27T14:57:04.000Z
2022-03-22T23:05:29.000Z
src/Algebra/Dioid.agda
algebraic-graphs/alga-theory
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
[ "MIT" ]
3
2018-04-12T16:25:13.000Z
2018-06-23T13:54:02.000Z
src/Algebra/Dioid.agda
algebraic-graphs/alga-theory
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
[ "MIT" ]
6
2017-12-17T20:48:20.000Z
2019-05-09T23:53:28.000Z
module Algebra.Dioid where record Dioid A (_≡_ : A -> A -> Set) : Set where field zero : A one : A _+_ : A -> A -> A _*_ : A -> A -> A reflexivity : ∀ {r : A} -> r ≡ r symmetry : ∀ {r s : A} -> r ≡ s -> s ≡ r transitivity : ∀ {r s t : A} -> r ≡ s -> s ≡ t -> r ≡ t +left-congruence : ∀ {r s t : A} -> r ≡ s -> (r + t) ≡ (s + t) -- +right-congruence holds but as a theorem, please see below *left-congruence : ∀ {r s t : A} -> r ≡ s -> (r * t) ≡ (s * t) *right-congruence : ∀ {r s t : A} -> r ≡ s -> (t * r) ≡ (t * s) +idempotence : ∀ {r : A} -> (r + r) ≡ r +commutativity : ∀ {r s : A} -> (r + s) ≡ (s + r) +associativity : ∀ {r s t : A} -> (r + (s + t)) ≡ ((r + s) + t) +zero-identity : ∀ {r : A} -> (r + zero) ≡ r *associativity : ∀ {r s t : A} -> (r * (s * t)) ≡ ((r * s) * t) *left-zero : ∀ {r : A} -> (zero * r) ≡ zero *right-zero : ∀ {r : A} -> (r * zero) ≡ zero *left-identity : ∀ {r : A} -> (one * r) ≡ r *right-identity : ∀ {r : A} -> (r * one) ≡ r left-distributivity : ∀ {r s t : A} -> (r * (s + t)) ≡ ((r * s) + (r * t)) right-distributivity : ∀ {r s t : A} -> ((r + s) * t) ≡ ((r * t) + (s * t)) -- For convenience to avoid `Dioid._+_ d r s` plus : A -> A -> A plus x y = x + y times : A -> A -> A times x y = x * y +right-congruence : ∀ {D eq} {d : Dioid D eq} {r s t : D} -> eq r s -> eq (Dioid.plus d t r) (Dioid.plus d t s) +right-congruence {_} {_} {d} {r} {s} {t} e = trans commut (trans (Dioid.+left-congruence d e) commut) where trans = Dioid.transitivity d commut = Dioid.+commutativity d
38.8
111
0.41638
3176c89c379feab32995354a595adab0d08108b9
709
agda
Agda
test/Fail/Issue690a.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue690a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue690a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue690a where data ℕ : Set where zero : ℕ succ : ℕ → ℕ -- A negative type. data T : Set → Set where c : T (T ℕ) -- From Andreas (2012-09-07) message on Agda mailing list "Forget -- Hurken's paradox ..." -- -- Trying to make sense of T in terms of inductive types, explaining -- indices via equalities, one arrives at -- -- data T (X : Set) : Set where -- c : (X ≡ T ℕ) → T X -- -- which has a non-positive occurrence of T in (X ≡ T ℕ). -- -- An argument for the existence of T would have to argue for the -- existence this least fixed point: -- -- lfp \lambda T X → (X ≡ T ℕ) -- ASR (14 August 2014): In Coq'Art, § 14.1.2.1, the type T is -- rejected due to the head type constrains.
23.633333
68
0.634697
30f7bc8aa04e7977dab32d8b748e4f09d1c5e761
199
agda
Agda
cohesion/david_jaz_261/Axiom/LEM.agda
glangmead/formalization
497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a
[ "CC0-1.0" ]
6
2021-10-06T17:39:22.000Z
2022-02-13T05:51:12.000Z
cohesion/david_jaz_261/Axiom/LEM.agda
glangmead/formalization
497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a
[ "CC0-1.0" ]
null
null
null
cohesion/david_jaz_261/Axiom/LEM.agda
glangmead/formalization
497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a
[ "CC0-1.0" ]
null
null
null
{-# OPTIONS --without-K --rewriting #-} module Axiom.LEM where open import Basics open import Flat open import lib.Basics postulate LEM : {@♭ i : ULevel} (@♭ P : PropT i) → Dec (P holds)
22.111111
66
0.638191
2136bcf601c2ec8df12e796b2c0887ff319c3a3e
966
agda
Agda
src/StateSizedIO/IOObject.agda
stephanadls/state-dependent-gui
2bc84cb14a568b560acb546c440cbe0ddcbb2a01
[ "MIT" ]
2
2020-07-31T15:37:39.000Z
2020-07-31T17:20:59.000Z
src/StateSizedIO/IOObject.agda
stephanadls/state-dependent-gui
2bc84cb14a568b560acb546c440cbe0ddcbb2a01
[ "MIT" ]
null
null
null
src/StateSizedIO/IOObject.agda
stephanadls/state-dependent-gui
2bc84cb14a568b560acb546c440cbe0ddcbb2a01
[ "MIT" ]
null
null
null
module StateSizedIO.IOObject where open import Data.Product open import Size open import SizedIO.Base open import StateSizedIO.Object -- --- -- --- -- --- FILE IS DELETED !!! -- --- -- --- -- An IO object is like a simple object, -- but the method returns IO applied to the result type of a simple object -- which means the method returns an IO program which when terminating -- returns the result of the simple object {- NOTE IOObject is now replaced by IOObjectˢ as defined in StateSizedIO.Base -} {- module _ (ioi : IOInterface) (let C = Command ioi) (let R = Response ioi) (oi : Interfaceˢ) (let S = Stateˢ oi) (let M = Methodˢ oi) (let Rt = Resultˢ oi) (let next = nextˢ oi) where record IOObject (i : Size) (s : S) : Set where coinductive field method : ∀{j : Size< i} (m : M s) → IO ioi ∞ (Σ[ r ∈ Rt s m ] IOObject j (next s m r) ) open IOObject public -}
21.954545
93
0.613872
43e030b23935250e3370d8449a6ec7760ff22bbe
1,305
agda
Agda
test/Succeed/TerminationListInsertionNaive.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/TerminationListInsertionNaive.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/TerminationListInsertionNaive.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module TerminationListInsertionNaive where data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A infixr 50 _::_ -- non-deterministic choice postulate _⊕_ : {A : Set} -> A -> A -> A infixl 10 _⊕_ -- a funny formulation of insert -- insert (a :: l) inserts a into l -- -- this example cannot be handled with subpatterns -- it is done with structured orders -- could also be done with sized types insert : {A : Set} -> List A -> List A insert [] = [] insert (a :: []) = a :: [] insert (a :: b :: bs) = a :: b :: bs ⊕ -- case a <= b b :: insert (a :: bs) -- case a > b -- list flattening -- termination using structured orders flat : {A : Set} -> List (List A) -> List A flat [] = [] flat ([] :: ll) = flat ll flat ((x :: l) :: ll) = x :: flat (l :: ll) {- generates two recursive calls with the following call matrices [] :: ll (x :: l) ll ll < l < . ll . = during composition, the second is collapsed to =, so the call graph is already complete. Both matrices are idempotent and contain a strictly decreasing argument. It could also be done with sized types; lexicographic in (i,j) with type flat : {A : Set} -> (1 + Listʲ A × List^i (List^∞ A)) -> List^∞ A -}
24.166667
70
0.563218
30926a049b890cf8faca77298f598d072495c65a
2,867
agda
Agda
Cubical/Algebra/CommAlgebra/QuotientAlgebra.agda
barrettj12/cubical
7b41b9171f90473efc98487cb2ea7a4d02320cb2
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Algebra/CommAlgebra/QuotientAlgebra.agda
barrettj12/cubical
7b41b9171f90473efc98487cb2ea7a4d02320cb2
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Algebra/CommAlgebra/QuotientAlgebra.agda
barrettj12/cubical
7b41b9171f90473efc98487cb2ea7a4d02320cb2
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{-# OPTIONS --safe #-} module Cubical.Algebra.CommAlgebra.QuotientAlgebra where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset using (_∈_) open import Cubical.HITs.SetQuotients hiding (_/_) open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.QuotientRing renaming (_/_ to _/Ring_) hiding ([_]/) open import Cubical.Algebra.CommAlgebra open import Cubical.Algebra.CommAlgebra.Ideal open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.Ideal using (isIdeal) open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level module _ {R : CommRing ℓ} (A : CommAlgebra R ℓ) where open CommRingStr {{...}} hiding (_-_; -_; dist; ·Lid; ·Rdist+) renaming (_·_ to _·R_; _+_ to _+R_) open CommAlgebraStr {{...}} open RingTheory (CommRing→Ring (CommAlgebra→CommRing A)) using (-DistR·) instance _ : CommRingStr _ _ = snd R _ : CommAlgebraStr _ _ _ = snd A _/_ : (I : IdealsIn A) → CommAlgebra R ℓ _/_ I = commAlgebraFromCommRing ((CommAlgebra→CommRing A) /Ring I) (λ r → elim (λ _ → squash/) (λ x → [ r ⋆ x ]) (eq r)) (λ r s → elimProp (λ _ → squash/ _ _) λ x i → [ ((r ·R s) ⋆ x ≡⟨ ⋆-assoc r s x ⟩ r ⋆ (s ⋆ x) ∎) i ]) (λ r s → elimProp (λ _ → squash/ _ _) λ x i → [ ((r +R s) ⋆ x ≡⟨ ⋆-ldist r s x ⟩ r ⋆ x + s ⋆ x ∎) i ]) (λ r → elimProp2 (λ _ _ → squash/ _ _) λ x y i → [ (r ⋆ (x + y) ≡⟨ ⋆-rdist r x y ⟩ r ⋆ x + r ⋆ y ∎) i ]) (elimProp (λ _ → squash/ _ _) (λ x i → [ (1r ⋆ x ≡⟨ ⋆-lid x ⟩ x ∎) i ])) λ r → elimProp2 (λ _ _ → squash/ _ _) λ x y i → [ ((r ⋆ x) · y ≡⟨ ⋆-lassoc r x y ⟩ r ⋆ (x · y) ∎) i ] where eq : (r : fst R) (x y : fst A) → x - y ∈ (fst I) → [ r ⋆ x ] ≡ [ r ⋆ y ] eq r x y x-y∈I = eq/ _ _ (subst (λ u → u ∈ fst I) ((r ⋆ 1a) · (x - y) ≡⟨ ·Rdist+ (r ⋆ 1a) x (- y) ⟩ (r ⋆ 1a) · x + (r ⋆ 1a) · (- y) ≡[ i ]⟨ (r ⋆ 1a) · x + -DistR· (r ⋆ 1a) y i ⟩ (r ⋆ 1a) · x - (r ⋆ 1a) · y ≡[ i ]⟨ ⋆-lassoc r 1a x i - ⋆-lassoc r 1a y i ⟩ r ⋆ (1a · x) - r ⋆ (1a · y) ≡[ i ]⟨ r ⋆ (·Lid x i) - r ⋆ (·Lid y i) ⟩ r ⋆ x - r ⋆ y ∎ ) (isIdeal.·-closedLeft (snd I) _ x-y∈I)) [_]/ : {R : CommRing ℓ} {A : CommAlgebra R ℓ} {I : IdealsIn A} → (a : fst A) → fst (A / I) [ a ]/ = [ a ]
43.439394
100
0.44053
34e53ea0ef51703a4acc35bf2906e2780fb499ad
3,429
agda
Agda
lib/cubical/elims/CofWedge.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
null
null
null
lib/cubical/elims/CofWedge.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
null
null
null
lib/cubical/elims/CofWedge.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K #-} open import HoTT open import lib.cubical.elims.CubeMove module lib.cubical.elims.CofWedge where cof-wedge-path-rec : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {C : Type k} {D : Type l} {f : X ∨ Y → C} {d₁ d₂ : D} → (p : d₁ == d₂) → (q : C → d₁ == d₂) → ((x : fst X) → p == q (f (winl x))) → ((y : fst Y) → p == q (f (winr y))) → ((κ : Cofiber f) → d₁ == d₂) cof-wedge-path-rec {X = X} {Y = Y} {f = f} base* cod* winl* winr* = CofiberRec.f _ base* cod* (WedgeElim.f winl* (λ y → (winl* (snd X) ∙ ap (cod* ∘ f) wglue) ∙ ! (winr* (snd Y)) ∙ winr* y) (↓-cst=app-from-square $ disc-to-square $ ! $ ap (λ w → (winl* (snd X) ∙ ap (cod* ∘ f) wglue) ∙ w) (!-inv-l (winr* (snd Y))) ∙ ∙-unit-r _)) cof-wedge-path-elim : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {C : Type k} {D : Type l} {f : X ∨ Y → C} (g h : Cofiber f → D) → (p : g (cfbase _) == h (cfbase _)) → (q : (c : C) → g (cfcod _ c) == h (cfcod _ c)) → ((x : fst X) → Square p (ap g (cfglue _ (winl x))) (ap h (cfglue _ (winl x))) (q (f (winl x)))) → ((y : fst Y) → Square p (ap g (cfglue _ (winr y))) (ap h (cfglue _ (winr y))) (q (f (winr y)))) → ((κ : Cofiber f) → g κ == h κ) cof-wedge-path-elim {X = X} {Y = Y} {f = f} g h base* cod* winl* winr* = Cofiber-elim _ base* cod* (↓-='-from-square ∘ Wedge-elim winl* (λ y → fst fill ⊡h winr* y) (cube-to-↓-square $ cube-right-from-front _ (winr* (snd Y)) (snd fill))) where fill : Σ (Square base* idp idp base*) (λ sq' → Cube (winl* (snd X)) sq' (natural-square (λ _ → base*) wglue) (square-push-rb _ _ (natural-square (ap g ∘ cfglue _) wglue)) (square-push-rb _ _ (natural-square (ap h ∘ cfglue _) wglue)) (natural-square (cod* ∘ f) wglue ⊡h' !□h (winr* (snd Y)))) fill = fill-cube-right _ _ _ _ _ {- Note, only squares with constant endpoints. General case? -} cof-wedge-square-elim : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {C : Type k} {D : Type l} {f : X ∨ Y → C} {d₀₀ d₀₁ d₁₀ d₁₁ : D} (p₀₋ : (κ : Cofiber f) → d₀₀ == d₀₁) (p₋₀ : (κ : Cofiber f) → d₀₀ == d₁₀) (p₋₁ : (κ : Cofiber f) → d₀₁ == d₁₁) (p₁₋ : (κ : Cofiber f) → d₁₀ == d₁₁) → (base* : Square (p₀₋ (cfbase _)) (p₋₀ (cfbase _)) (p₋₁ (cfbase _)) (p₁₋ (cfbase _))) → (cod* : (c : C) → Square (p₀₋ (cfcod _ c)) (p₋₀ (cfcod _ c)) (p₋₁ (cfcod _ c)) (p₁₋ (cfcod _ c))) → ((x : fst X) → Cube base* (cod* (f (winl x))) (natural-square p₀₋ (cfglue _ (winl x))) (natural-square p₋₀ (cfglue _ (winl x))) (natural-square p₋₁ (cfglue _ (winl x))) (natural-square p₁₋ (cfglue _ (winl x)))) → ((y : fst Y) → Cube base* (cod* (f (winr y))) (natural-square p₀₋ (cfglue _ (winr y))) (natural-square p₋₀ (cfglue _ (winr y))) (natural-square p₋₁ (cfglue _ (winr y))) (natural-square p₁₋ (cfglue _ (winr y)))) → ((κ : Cofiber f) → Square (p₀₋ κ) (p₋₀ κ) (p₋₁ κ) (p₁₋ κ)) cof-wedge-square-elim p₀₋ p₋₀ p₋₁ p₁₋ base* cod* winl* winr* = disc-to-square ∘ cof-wedge-path-elim _ _ (square-to-disc base*) (square-to-disc ∘ cod*) (cube-to-disc-square ∘ winl*) (cube-to-disc-square ∘ winr*)
38.965909
72
0.473024
0651da043aaaa9c2a2f5fb8ae8aae95c661a08fe
947
agda
Agda
test/succeed/Issue286.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2019-11-27T07:26:06.000Z
2019-11-27T07:26:06.000Z
test/succeed/Issue286.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
test/succeed/Issue286.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
{-# OPTIONS --universe-polymorphism #-} module Issue286 where open import Common.Level data Bool : Set where true false : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN TRUE true #-} {-# BUILTIN FALSE false #-} data _≡_ {ℓ : Level} {A : Set ℓ} : A → A → Set ℓ where refl : {a : A} → a ≡ a {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} primitive primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y postulate String : Set {-# BUILTIN STRING String #-} primitive primStringEquality : String → String → Bool data Maybe (A : Set) : Set where just : A → Maybe A nothing : Maybe A _≟_ : (s₁ s₂ : String) → Maybe (s₁ ≡ s₂) s₁ ≟ s₂ with primStringEquality s₁ s₂ ... | true = just primTrustMe ... | false = nothing _≟′_ : (s₁ s₂ : String) → Maybe (s₁ ≡ s₂) s₁ ≟′ s₂ with s₁ ≟ s₂ s ≟′ .s | just refl = just refl _ ≟′ _ | nothing = nothing test : Maybe ("" ≡ "") test = "" ≟′ "" ok : test ≡ just refl ok = refl
19.326531
54
0.579725
ada3fc13cbf06713a798a3a123f6f29b580f52c0
2,046
agda
Agda
agda-stdlib/src/Data/Container/FreeMonad.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/Container/FreeMonad.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/Container/FreeMonad.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- The free monad construction on containers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Data.Container.FreeMonad where open import Level open import Data.Sum.Base using (inj₁; inj₂ ; [_,_]′) open import Data.Product open import Data.Container open import Data.Container.Combinator using (const; _⊎_) open import Data.W open import Category.Monad infixl 1 _⋆C_ infix 1 _⋆_ ------------------------------------------------------------------------ -- The free monad construction over a container and a set is, in -- universal algebra terminology, also known as the term algebra over a -- signature (a container) and a set (of variable symbols). The return -- of the free monad corresponds to variables and the bind operator -- corresponds to (parallel) substitution. -- A useful intuition is to think of containers describing single -- operations and the free monad construction over a container and a set -- describing a tree of operations as nodes and elements of the set as -- leafs. If one starts at the root, then any path will pass finitely -- many nodes (operations described by the container) and eventually end -- up in a leaf (element of the set) -- hence the Kleene star notation -- (the type can be read as a regular expression). _⋆C_ : ∀ {x s p} → Container s p → Set x → Container (s ⊔ x) p C ⋆C X = const X ⊎ C _⋆_ : ∀ {x s p} → Container s p → Set x → Set (x ⊔ s ⊔ p) C ⋆ X = μ (C ⋆C X) module _ {s p} {C : Container s p} where inn : ∀ {x} {X : Set x} → ⟦ C ⟧ (C ⋆ X) → C ⋆ X inn (s , f) = sup (inj₂ s , f) rawMonad : ∀ {x} → RawMonad {s ⊔ p ⊔ x} (C ⋆_) rawMonad = record { return = return; _>>=_ = _>>=_ } where return : ∀ {X} → X → C ⋆ X return x = sup (inj₁ x , λ ()) _>>=_ : ∀ {X Y} → C ⋆ X → (X → C ⋆ Y) → C ⋆ Y sup (inj₁ x , _) >>= k = k x sup (inj₂ s , f) >>= k = inn (s , λ p → f p >>= k)
35.894737
72
0.575269
35fa2cbfca4b569737007f886827b02a18e1cdaa
4,024
agda
Agda
Cubical/ZCohomology/Groups/Unit.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
1
2021-10-31T17:32:49.000Z
2021-10-31T17:32:49.000Z
Cubical/ZCohomology/Groups/Unit.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
Cubical/ZCohomology/Groups/Unit.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.ZCohomology.Groups.Unit where open import Cubical.Foundations.HLevels open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Data.Unit open import Cubical.Data.Nat open import Cubical.Data.Int hiding (ℤ ; _+_ ; +Comm) open import Cubical.Data.Sigma open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Instances.Int open import Cubical.Algebra.Group.Instances.Unit open import Cubical.HITs.SetTruncation as ST open import Cubical.HITs.Sn open import Cubical.HITs.Susp open import Cubical.HITs.Truncation open import Cubical.Homotopy.Connected open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.GroupStructure -- H⁰(Unit) open IsGroupHom open Iso H⁰-Unit≅ℤ : GroupIso (coHomGr 0 Unit) ℤGroup fun (fst H⁰-Unit≅ℤ) = ST.rec isSetℤ (λ f → f tt) inv (fst H⁰-Unit≅ℤ) a = ∣ (λ _ → a) ∣₂ rightInv (fst H⁰-Unit≅ℤ) _ = refl leftInv (fst H⁰-Unit≅ℤ) = ST.elim (λ _ → isOfHLevelPath 2 isSetSetTrunc _ _) λ a → refl snd H⁰-Unit≅ℤ = makeIsGroupHom (ST.elim2 (λ _ _ → isOfHLevelPath 2 isSetℤ _ _) λ a b → refl) {- Hⁿ(Unit) for n ≥ 1 -} isContrHⁿ-Unit : (n : ℕ) → isContr (coHom (suc n) Unit) isContrHⁿ-Unit n = subst isContr (λ i → ∥ UnitToTypePath (coHomK (suc n)) (~ i) ∥₂) (helper' n) where helper' : (n : ℕ) → isContr (∥ coHomK (suc n) ∥₂) helper' n = subst isContr ((isoToPath (truncOfTruncIso {A = S₊ (1 + n)} 2 (1 + n))) ∙∙ sym propTrunc≡Trunc2 ∙∙ λ i → ∥ hLevelTrunc (suc (+-comm n 2 i)) (S₊ (1 + n)) ∥₂) (isConnectedSubtr 2 (helper2 n .fst) (subst (λ x → isConnected x (S₊ (suc n))) (sym (helper2 n .snd)) (sphereConnected (suc n))) ) where helper2 : (n : ℕ) → Σ[ m ∈ ℕ ] m + 2 ≡ 2 + n helper2 zero = 0 , refl helper2 (suc n) = (suc n) , λ i → suc (+-comm n 2 i) Hⁿ-Unit≅0 : (n : ℕ) → GroupIso (coHomGr (suc n) Unit) UnitGroup₀ fun (fst (Hⁿ-Unit≅0 n)) _ = _ inv (fst (Hⁿ-Unit≅0 n)) _ = 0ₕ (suc n) rightInv (fst (Hⁿ-Unit≅0 n)) _ = refl leftInv (fst (Hⁿ-Unit≅0 n)) _ = isOfHLevelSuc 0 (isContrHⁿ-Unit n) _ _ snd (Hⁿ-Unit≅0 n) = makeIsGroupHom λ _ _ → refl {- Hⁿ for arbitrary contractible types -} private Hⁿ-contrTypeIso : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A → Iso (coHom (suc n) A) (coHom (suc n) Unit) Hⁿ-contrTypeIso n contr = compIso (setTruncIso (isContr→Iso2 contr)) (setTruncIso (invIso (isContr→Iso2 isContrUnit))) Hⁿ-contrType≅0 : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A → GroupIso (coHomGr (suc n) A) UnitGroup₀ fun (fst (Hⁿ-contrType≅0 n contr)) _ = _ inv (fst (Hⁿ-contrType≅0 n contr)) _ = 0ₕ (suc n) rightInv (fst (Hⁿ-contrType≅0 n contr)) _ = refl leftInv (fst (Hⁿ-contrType≅0 {A = A} n contr)) _ = isOfHLevelSuc 0 helper _ _ where helper : isContr (coHom (suc n) A) helper = (inv (Hⁿ-contrTypeIso n contr) (0ₕ (suc n))) , λ y → cong (inv (Hⁿ-contrTypeIso n contr)) (isOfHLevelSuc 0 (isContrHⁿ-Unit n) (0ₕ (suc n)) (fun (Hⁿ-contrTypeIso n contr) y)) ∙ leftInv (Hⁿ-contrTypeIso n contr) y snd (Hⁿ-contrType≅0 n contr) = makeIsGroupHom λ _ _ → refl isContr-HⁿRed-Unit : (n : ℕ) → isContr (coHomRed n (Unit , tt)) fst (isContr-HⁿRed-Unit n) = 0ₕ∙ _ snd (isContr-HⁿRed-Unit n) = ST.elim (λ _ → isOfHLevelPath 2 isSetSetTrunc _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP (funExt (λ _ → sym p) , λ i j → p (~ i ∨ j)))} ×rUnitCohomIso : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → GroupIso (×coHomGr (suc n) A Unit) (coHomGr (suc n) A) fun (fst (×rUnitCohomIso n)) = fst inv (fst (×rUnitCohomIso n)) x = x , 0ₕ (suc n) rightInv (fst (×rUnitCohomIso n)) _ = refl leftInv (fst (×rUnitCohomIso n)) x = ΣPathP (refl , isContr→isProp (isContrHⁿ-Unit n) (0ₕ (suc n)) (snd x)) snd (×rUnitCohomIso n) = makeIsGroupHom λ _ _ → refl
39.067961
108
0.637674
2121a7ac94ccdc939dfcc25b39b1bef22223745c
794
agda
Agda
agda/Heapsort/Impl1.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
6
2015-05-21T12:50:35.000Z
2021-08-24T22:11:15.000Z
agda/Heapsort/Impl1.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
agda/Heapsort/Impl1.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
open import Relation.Binary.Core module Heapsort.Impl1 {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import BBHeap _≤_ hiding (flatten) open import BBHeap.Heapify _≤_ tot≤ trans≤ open import BHeap _≤_ hiding (flatten) open import BHeap.Order _≤_ open import BHeap.Order.Properties _≤_ open import BHeap.Properties _≤_ open import Bound.Lower A open import Data.List open import OList _≤_ flatten : {b : Bound}(h : BHeap b) → Acc h → OList b flatten lf _ = onil flatten (nd {x = x} b≤x l r) (acc rs) = :< b≤x (flatten (merge tot≤ l r) (rs (merge tot≤ l r) (lemma-merge≤′ tot≤ b≤x l r))) heapsort : List A → OList bot heapsort xs = flatten (relax (heapify xs)) (≺-wf (relax (heapify xs)))
33.083333
124
0.630982
34c0a9649601cce1b49a0bb512e7bdd60ff5cf1a
9,969
agda
Agda
core/lib/groups/GroupProduct.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/groups/GroupProduct.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/groups/GroupProduct.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Bool open import lib.types.Group open import lib.types.Nat open import lib.types.Pi open import lib.types.Sigma open import lib.types.Coproduct open import lib.types.Truncation open import lib.groups.Homomorphism open import lib.groups.Isomorphism open import lib.groups.SubgroupProp open import lib.groups.Lift open import lib.groups.Unit module lib.groups.GroupProduct where {- binary product -} ×-group-struct : ∀ {i j} {A : Type i} {B : Type j} (GS : GroupStructure A) (HS : GroupStructure B) → GroupStructure (A × B) ×-group-struct {A = A} {B = B} GS HS = record {M} where module G = GroupStructure GS module H = GroupStructure HS module M where ident : A × B ident = G.ident , H.ident inv : A × B → A × B inv (g , h) = G.inv g , H.inv h comp : A × B → A × B → A × B comp (g₁ , h₁) (g₂ , h₂) = G.comp g₁ g₂ , H.comp h₁ h₂ abstract unit-l : ∀ ab → comp ident ab == ab unit-l (g , h) = pair×= (G.unit-l g) (H.unit-l h) assoc : ∀ ab₁ ab₂ ab₃ → comp (comp ab₁ ab₂) ab₃ == comp ab₁ (comp ab₂ ab₃) assoc (g₁ , h₁) (g₂ , h₂) (g₃ , h₃) = pair×= (G.assoc g₁ g₂ g₃) (H.assoc h₁ h₂ h₃) inv-l : ∀ ab → comp (inv ab) ab == ident inv-l (g , h) = pair×= (G.inv-l g) (H.inv-l h) infix 80 _×ᴳ_ _×ᴳ_ : ∀ {i j} → Group i → Group j → Group (lmax i j) _×ᴳ_ (group A A-level A-struct) (group B B-level B-struct) = group (A × B) (×-level A-level B-level) (×-group-struct A-struct B-struct) {- general product -} Π-group-struct : ∀ {i j} {I : Type i} {A : I → Type j} (FS : (i : I) → GroupStructure (A i)) → GroupStructure (Π I A) Π-group-struct FS = record { ident = ident ∘ FS; inv = λ f i → inv (FS i) (f i); comp = λ f g i → comp (FS i) (f i) (g i); unit-l = λ f → (λ= (λ i → unit-l (FS i) (f i))); assoc = λ f g h → (λ= (λ i → assoc (FS i) (f i) (g i) (h i))); inv-l = λ f → (λ= (λ i → inv-l (FS i) (f i)))} where open GroupStructure Πᴳ : ∀ {i j} (I : Type i) (F : I → Group j) → Group (lmax i j) Πᴳ I F = group (Π I (El ∘ F)) (Π-level (λ i → El-level (F i))) (Π-group-struct (group-struct ∘ F)) where open Group {- functorial behavior of [Πᴳ] -} Πᴳ-emap-r : ∀ {i j k} (I : Type i) {F : I → Group j} {G : I → Group k} → (∀ i → F i ≃ᴳ G i) → Πᴳ I F ≃ᴳ Πᴳ I G Πᴳ-emap-r I {F} {G} iso = ≃-to-≃ᴳ (Π-emap-r (GroupIso.f-equiv ∘ iso)) (λ f g → λ= λ i → GroupIso.pres-comp (iso i) (f i) (g i)) {- the product of abelian groups is abelian -} ×ᴳ-is-abelian : ∀ {i j} (G : Group i) (H : Group j) → is-abelian G → is-abelian H → is-abelian (G ×ᴳ H) ×ᴳ-is-abelian G H aG aH (g₁ , h₁) (g₂ , h₂) = pair×= (aG g₁ g₂) (aH h₁ h₂) ×ᴳ-abgroup : ∀ {i j} → AbGroup i → AbGroup j → AbGroup (lmax i j) ×ᴳ-abgroup (G , aG) (H , aH) = G ×ᴳ H , ×ᴳ-is-abelian G H aG aH Πᴳ-is-abelian : ∀ {i j} {I : Type i} {F : I → Group j} → (∀ i → is-abelian (F i)) → is-abelian (Πᴳ I F) Πᴳ-is-abelian aF f₁ f₂ = λ= (λ i → aF i (f₁ i) (f₂ i)) {- defining a homomorphism into a product -} ×ᴳ-fanout : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} → (G →ᴳ H) → (G →ᴳ K) → (G →ᴳ H ×ᴳ K) ×ᴳ-fanout (group-hom h h-comp) (group-hom k k-comp) = group-hom (λ x → (h x , k x)) (λ x y → pair×= (h-comp x y) (k-comp x y)) Πᴳ-fanout : ∀ {i j k} {I : Type i} {G : Group j} {F : I → Group k} → ((i : I) → G →ᴳ F i) → (G →ᴳ Πᴳ I F) Πᴳ-fanout h = group-hom (λ x i → GroupHom.f (h i) x) (λ x y → λ= (λ i → GroupHom.pres-comp (h i) x y)) ×ᴳ-fanout-pre∘ : ∀ {i j k l} {G : Group i} {H : Group j} {K : Group k} {J : Group l} (φ : G →ᴳ H) (ψ : G →ᴳ K) (χ : J →ᴳ G) → ×ᴳ-fanout φ ψ ∘ᴳ χ == ×ᴳ-fanout (φ ∘ᴳ χ) (ψ ∘ᴳ χ) ×ᴳ-fanout-pre∘ φ ψ χ = group-hom= idp {- projection homomorphisms -} ×ᴳ-fst : ∀ {i j} {G : Group i} {H : Group j} → (G ×ᴳ H →ᴳ G) ×ᴳ-fst = group-hom fst (λ _ _ → idp) ×ᴳ-snd : ∀ {i j} {G : Group i} {H : Group j} → (G ×ᴳ H →ᴳ H) ×ᴳ-snd = group-hom snd (λ _ _ → idp) ×ᴳ-snd-is-surj : ∀ {i j} {G : Group i} {H : Group j} → is-surjᴳ (×ᴳ-snd {G = G} {H = H}) ×ᴳ-snd-is-surj {G = G} h = [ (Group.ident G , h) , idp ] Πᴳ-proj : ∀ {i j} {I : Type i} {F : I → Group j} (i : I) → (Πᴳ I F →ᴳ F i) Πᴳ-proj i = group-hom (λ f → f i) (λ _ _ → idp) {- injection homomorphisms -} module _ {i j} {G : Group i} {H : Group j} where ×ᴳ-inl : G →ᴳ G ×ᴳ H ×ᴳ-inl = ×ᴳ-fanout (idhom G) cst-hom ×ᴳ-inr : H →ᴳ G ×ᴳ H ×ᴳ-inr = ×ᴳ-fanout (cst-hom {H = G}) (idhom H) ×ᴳ-diag : ∀ {i} {G : Group i} → (G →ᴳ G ×ᴳ G) ×ᴳ-diag = ×ᴳ-fanout (idhom _) (idhom _) {- when G is abelian, we can define a map H×K → G as a sum of maps - H → G and K → G (that is, the product behaves as a sum) -} module _ {i j k} {G : Group i} {H : Group j} {K : Group k} (G-abelian : is-abelian G) where private module G = Group G module H = Group H module K = Group K abstract interchange : (g₁ g₂ g₃ g₄ : G.El) → G.comp (G.comp g₁ g₂) (G.comp g₃ g₄) == G.comp (G.comp g₁ g₃) (G.comp g₂ g₄) interchange g₁ g₂ g₃ g₄ = (g₁ □ g₂) □ (g₃ □ g₄) =⟨ G.assoc g₁ g₂ (g₃ □ g₄) ⟩ g₁ □ (g₂ □ (g₃ □ g₄)) =⟨ G-abelian g₃ g₄ |in-ctx (λ w → g₁ □ (g₂ □ w)) ⟩ g₁ □ (g₂ □ (g₄ □ g₃)) =⟨ ! (G.assoc g₂ g₄ g₃) |in-ctx (λ w → g₁ □ w) ⟩ g₁ □ ((g₂ □ g₄) □ g₃) =⟨ G-abelian (g₂ □ g₄) g₃ |in-ctx (λ w → g₁ □ w) ⟩ g₁ □ (g₃ □ (g₂ □ g₄)) =⟨ ! (G.assoc g₁ g₃ (g₂ □ g₄)) ⟩ (g₁ □ g₃) □ (g₂ □ g₄) =∎ where infix 80 _□_ _□_ = G.comp ×ᴳ-fanin : (H →ᴳ G) → (K →ᴳ G) → (H ×ᴳ K →ᴳ G) ×ᴳ-fanin φ ψ = group-hom (λ {(h , k) → G.comp (φ.f h) (ψ.f k)}) lemma where module φ = GroupHom φ module ψ = GroupHom ψ abstract lemma : preserves-comp (Group.comp (H ×ᴳ K)) G.comp (λ {(h , k) → G.comp (φ.f h) (ψ.f k)}) lemma (h₁ , k₁) (h₂ , k₂) = G.comp (φ.f (H.comp h₁ h₂)) (ψ.f (K.comp k₁ k₂)) =⟨ φ.pres-comp h₁ h₂ |in-ctx (λ w → G.comp w (ψ.f (K.comp k₁ k₂))) ⟩ G.comp (G.comp (φ.f h₁) (φ.f h₂)) (ψ.f (K.comp k₁ k₂)) =⟨ ψ.pres-comp k₁ k₂ |in-ctx (λ w → G.comp (G.comp (φ.f h₁) (φ.f h₂)) w) ⟩ G.comp (G.comp (φ.f h₁) (φ.f h₂)) (G.comp (ψ.f k₁) (ψ.f k₂)) =⟨ interchange (φ.f h₁) (φ.f h₂) (ψ.f k₁) (ψ.f k₂) ⟩ G.comp (G.comp (φ.f h₁) (ψ.f k₁)) (G.comp (φ.f h₂) (ψ.f k₂)) =∎ abstract ×ᴳ-fanin-η : ∀ {i j} (G : Group i) (H : Group j) (aGH : is-abelian (G ×ᴳ H)) → idhom (G ×ᴳ H) == ×ᴳ-fanin aGH (×ᴳ-inl {G = G}) (×ᴳ-inr {G = G}) ×ᴳ-fanin-η G H aGH = group-hom= $ λ= λ {(g , h) → ! (pair×= (Group.unit-r G g) (Group.unit-l H h))} ×ᴳ-fanin-pre∘ : ∀ {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l} (aK : is-abelian K) (aL : is-abelian L) (φ : K →ᴳ L) (ψ : G →ᴳ K) (χ : H →ᴳ K) → ×ᴳ-fanin aL (φ ∘ᴳ ψ) (φ ∘ᴳ χ) == φ ∘ᴳ (×ᴳ-fanin aK ψ χ) ×ᴳ-fanin-pre∘ aK aL φ ψ χ = group-hom= $ λ= λ {(g , h) → ! (GroupHom.pres-comp φ (GroupHom.f ψ g) (GroupHom.f χ h))} {- define a homomorphism [G₁ × G₂ → H₁ × H₂] from homomorphisms - [G₁ → H₁] and [G₂ → H₂] -} ×ᴳ-fmap : ∀ {i j k l} {G₁ : Group i} {G₂ : Group j} {H₁ : Group k} {H₂ : Group l} → (G₁ →ᴳ H₁) → (G₂ →ᴳ H₂) → (G₁ ×ᴳ G₂ →ᴳ H₁ ×ᴳ H₂) ×ᴳ-fmap {G₁ = G₁} {G₂} {H₁} {H₂} φ ψ = group-hom (×-fmap φ.f ψ.f) lemma where module φ = GroupHom φ module ψ = GroupHom ψ abstract lemma : preserves-comp (Group.comp (G₁ ×ᴳ G₂)) (Group.comp (H₁ ×ᴳ H₂)) (λ {(h₁ , h₂) → (φ.f h₁ , ψ.f h₂)}) lemma (h₁ , h₂) (h₁' , h₂') = pair×= (φ.pres-comp h₁ h₁') (ψ.pres-comp h₂ h₂') ×ᴳ-emap : ∀ {i j k l} {G₁ : Group i} {G₂ : Group j} {H₁ : Group k} {H₂ : Group l} → (G₁ ≃ᴳ H₁) → (G₂ ≃ᴳ H₂) → (G₁ ×ᴳ G₂ ≃ᴳ H₁ ×ᴳ H₂) ×ᴳ-emap (φ , φ-is-equiv) (ψ , ψ-is-equiv) = ×ᴳ-fmap φ ψ , ×-isemap φ-is-equiv ψ-is-equiv {- equivalences in Πᴳ -} Πᴳ-emap-l : ∀ {i j k} {A : Type i} {B : Type j} (F : B → Group k) → (e : A ≃ B) → Πᴳ A (F ∘ –> e) ≃ᴳ Πᴳ B F Πᴳ-emap-l {A = A} {B = B} F e = ≃-to-≃ᴳ (Π-emap-l (Group.El ∘ F) e) lemma where abstract lemma = λ f g → λ= λ b → transp-El-pres-comp F (<–-inv-r e b) (f (<– e b)) (g (<– e b)) {- 0ᴳ is a unit for product -} ×ᴳ-unit-l : ∀ {i} (G : Group i) → 0ᴳ ×ᴳ G ≃ᴳ G ×ᴳ-unit-l _ = ×ᴳ-snd {G = 0ᴳ} , is-eq snd (λ g → (unit , g)) (λ _ → idp) (λ _ → idp) ×ᴳ-unit-r : ∀ {i} (G : Group i) → G ×ᴳ 0ᴳ ≃ᴳ G ×ᴳ-unit-r _ = ×ᴳ-fst , is-eq fst (λ g → (g , unit)) (λ _ → idp) (λ _ → idp) {- A product Πᴳ indexed by Bool is the same as a binary product -} module _ {i j k} {A : Type i} {B : Type j} (F : A ⊔ B → Group k) where Πᴳ₁-⊔-iso-×ᴳ : Πᴳ (A ⊔ B) F ≃ᴳ Πᴳ A (F ∘ inl) ×ᴳ Πᴳ B (F ∘ inr) Πᴳ₁-⊔-iso-×ᴳ = ≃-to-≃ᴳ (Π₁-⊔-equiv-× (Group.El ∘ F)) (λ _ _ → idp) {- Commutativity of ×ᴳ -} ×ᴳ-comm : ∀ {i j} (H : Group i) (K : Group j) → H ×ᴳ K ≃ᴳ K ×ᴳ H ×ᴳ-comm H K = group-hom (λ {(h , k) → (k , h)}) (λ _ _ → idp) , is-eq _ (λ {(k , h) → (h , k)}) (λ _ → idp) (λ _ → idp) {- Associativity of ×ᴳ -} ×ᴳ-assoc : ∀ {i j k} (G : Group i) (H : Group j) (K : Group k) → ((G ×ᴳ H) ×ᴳ K) ≃ᴳ (G ×ᴳ (H ×ᴳ K)) ×ᴳ-assoc G H K = group-hom (λ {((g , h) , k) → (g , (h , k))}) (λ _ _ → idp) , is-eq _ (λ {(g , (h , k)) → ((g , h) , k)}) (λ _ → idp) (λ _ → idp) module _ {i} where infixl 80 _^ᴳ_ _^ᴳ_ : Group i → ℕ → Group i H ^ᴳ O = Lift-group {j = i} 0ᴳ H ^ᴳ (S n) = H ×ᴳ (H ^ᴳ n) ^ᴳ-+ : (H : Group i) (m n : ℕ) → H ^ᴳ (m + n) ≃ᴳ (H ^ᴳ m) ×ᴳ (H ^ᴳ n) ^ᴳ-+ H O n = ×ᴳ-emap (lift-iso {G = 0ᴳ}) (idiso (H ^ᴳ n)) ∘eᴳ ×ᴳ-unit-l (H ^ᴳ n) ⁻¹ᴳ ^ᴳ-+ H (S m) n = ×ᴳ-assoc H (H ^ᴳ m) (H ^ᴳ n) ⁻¹ᴳ ∘eᴳ ×ᴳ-emap (idiso H) (^ᴳ-+ H m n) module _ where Πᴳ-is-trivial : ∀ {i j} (I : Type i) (F : I → Group j) → (∀ (i : I) → is-trivialᴳ (F i)) → is-trivialᴳ (Πᴳ I F) Πᴳ-is-trivial I F F-is-trivial = λ f → λ= λ i → F-is-trivial i (f i) module _ {j} {F : Unit → Group j} where Πᴳ₁-Unit : Πᴳ Unit F ≃ᴳ F unit Πᴳ₁-Unit = ≃-to-≃ᴳ Π₁-Unit (λ _ _ → idp)
36.785978
104
0.49674
21d8f94ce9d4fb09c6188bd7614f99c0991fad6e
235
agda
Agda
src/Pair.agda
cruhland/agda-editor
c5ffd117f6d5a98f7c68a2a6b9be54a150c70945
[ "MIT" ]
null
null
null
src/Pair.agda
cruhland/agda-editor
c5ffd117f6d5a98f7c68a2a6b9be54a150c70945
[ "MIT" ]
null
null
null
src/Pair.agda
cruhland/agda-editor
c5ffd117f6d5a98f7c68a2a6b9be54a150c70945
[ "MIT" ]
null
null
null
module Pair where postulate _,_ : Set → Set → Set fst : {A B : Set} → (A , B) → A snd : {A B : Set} → (A , B) → B {-# COMPILE GHC _,_ = type (,) #-} {-# COMPILE GHC fst = \ _ _ -> fst #-} {-# COMPILE GHC snd = \ _ _ -> snd #-}
21.363636
38
0.46383
214383e4dc3e8ebaab0603f364448129eda726ae
787
agda
Agda
Data.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Data.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Data.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Data where import Lvl open import Type -- An empty type which cannot be constructed. -- By default, this should be used to represent _the_ empty type. data Empty {ℓ} : Type{ℓ} where {-# FOREIGN GHC data Empty ℓ #-} {-# COMPILE GHC Empty = data Empty () #-} -- Empty functions. -- The empty type eliminator. -- Any type can be constructed from the empty type. empty : ∀{ℓ₁ ℓ₂}{T : Type{ℓ₁}} → Empty{ℓ₂} → T empty () {-# COMPILE GHC empty = \_ _ _ e -> case e of{} #-} -- An unit type which can only be constructed in one way. -- By default, this should be used to represent _the_ unit type. record Unit {ℓ} : Type{ℓ} where instance constructor <> open Unit public {-# BUILTIN UNIT Unit #-} {-# FOREIGN GHC type Unit ℓ = () #-} {-# COMPILE GHC Unit = data Unit (()) #-}
28.107143
65
0.659466
19d5e57d3c5e578b065c7a953a72d8d2d6fce848
1,413
agda
Agda
src/fot/GroupTheory/Commutator.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
11
2015-09-03T20:53:42.000Z
2021-09-12T16:09:54.000Z
src/fot/GroupTheory/Commutator.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
2
2016-10-12T17:28:16.000Z
2017-01-01T14:34:26.000Z
src/fot/GroupTheory/Commutator.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
3
2016-09-19T14:18:30.000Z
2018-03-14T08:50:00.000Z
------------------------------------------------------------------------------ -- The group commutator ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module GroupTheory.Commutator where open import GroupTheory.Base ------------------------------------------------------------------------------ -- The group commutator -- -- There are two definitions for the group commutator: -- -- [a,b] = aba⁻¹b⁻¹ (Mac Lane and Garret 1999, p. 418), or -- -- [a,b] = a⁻¹b⁻¹ab (Kurosh 1960, p. 99). -- -- We use Kurosh's definition, because this is the definition used by -- the TPTP 6.4.0 problem GRP/GRP024-5.p. Actually the problem uses -- the definition -- -- [a,b] = a⁻¹(b⁻¹(ab)). [_,_] : G → G → G [ a , b ] = a ⁻¹ · b ⁻¹ · a · b {-# ATP definition [_,_] #-} commutatorAssoc : G → G → G → Set commutatorAssoc a b c = [ [ a , b ] , c ] ≡ [ a , [ b , c ] ] {-# ATP definition commutatorAssoc #-} ------------------------------------------------------------------------------ -- References -- -- Mac Lane, S. and Birkhof, G. (1999). Algebra. 3rd ed. AMS Chelsea -- Publishing. -- -- Kurosh, A. G. (1960). The Theory of Groups. 2nd -- ed. Vol. 1. Translated and edited by K. A. Hirsch. Chelsea -- Publising Company.
30.717391
78
0.46143
1b0de47b64a83139df46d0350d6cd2e35268b2c9
11,030
agda
Agda
core/lib/Base.agda
cmknapp/HoTT-Agda
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
[ "MIT" ]
null
null
null
core/lib/Base.agda
cmknapp/HoTT-Agda
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
[ "MIT" ]
null
null
null
core/lib/Base.agda
cmknapp/HoTT-Agda
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K #-} {- This file contains a bunch of basic stuff which is needed early. Maybe it should be organised better. -} module lib.Base where {- Universes and typing Agda has explicit universe polymorphism, which means that there is an actual type of universe levels on which you can quantify. This type is called [ULevel] and comes equipped with the following operations: - [lzero] : [ULevel] (in order to have at least one universe) - [lsucc] : [ULevel → ULevel] (the [i]th universe level is a term in the [lsucc i]th universe) - [lmax] : [ULevel → ULevel → ULevel] (in order to type dependent products (where the codomain is in a uniform universe level) This type is postulated below and linked to Agda’s universe polymorphism mechanism via the built-in module Agda.Primitive (it’s the new way). In plain Agda, the [i]th universe is called [Set i], which is not a very good name from the point of view of HoTT, so we define [Type] as a synonym of [Set] and [Set] should never be used again. -} open import Agda.Primitive public using (lzero) renaming (Level to ULevel; lsuc to lsucc; _⊔_ to lmax) Type : (i : ULevel) → Set (lsucc i) Type i = Set i Type₀ = Type lzero Type0 = Type lzero Type₁ = Type (lsucc lzero) Type1 = Type (lsucc lzero) {- There is no built-in or standard way to coerce an ambiguous term to a given type (like [u : A] in ML), the symbol [:] is reserved, and the Unicode [∶] is really a bad idea. So we’re using the symbol [_:>_], which has the advantage that it can micmic Coq’s [u = v :> A]. -} of-type : ∀ {i} (A : Type i) (u : A) → A of-type A u = u infix 40 of-type syntax of-type A u = u :> A {- Identity type The identity type is called [Path] and [_==_] because the symbol [=] is reserved in Agda. The constant path is [idp]. Note that all arguments of [idp] are implicit. -} infix 30 _==_ data _==_ {i} {A : Type i} (a : A) : A → Type i where idp : a == a Path = _==_ {-# BUILTIN EQUALITY _==_ #-} {-# BUILTIN REFL idp #-} {- Paulin-Mohring J rule At the time I’m writing this (July 2013), the identity type is somehow broken in Agda dev, it behaves more or less as the Martin-Löf identity type instead of behaving like the Paulin-Mohring identity type. So here is the Paulin-Mohring J rule -} J : ∀ {i j} {A : Type i} {a : A} (B : (a' : A) (p : a == a') → Type j) (d : B a idp) {a' : A} (p : a == a') → B a' p J B d idp = d J' : ∀ {i j} {A : Type i} {a : A} (B : (a' : A) (p : a' == a) → Type j) (d : B a idp) {a' : A} (p : a' == a) → B a' p J' B d idp = d {- Unit type The unit type is defined as record so that we also get the η-rule definitionally. -} record ⊤ : Type₀ where instance constructor unit Unit = ⊤ {-# BUILTIN UNIT ⊤ #-} {- Dependent paths The notion of dependent path is a very important notion. If you have a dependent type [B] over [A], a path [p : x == y] in [A] and two points [u : B x] and [v : B y], there is a type [u == v [ B ↓ p ]] of paths from [u] to [v] lying over the path [p]. By definition, if [p] is a constant path, then [u == v [ B ↓ p ]] is just an ordinary path in the fiber. -} PathOver : ∀ {i j} {A : Type i} (B : A → Type j) {x y : A} (p : x == y) (u : B x) (v : B y) → Type j PathOver B idp u v = (u == v) infix 30 PathOver syntax PathOver B p u v = u == v [ B ↓ p ] {- Ap, coe and transport Given two fibrations over a type [A], a fiberwise map between the two fibrations can be applied to any dependent path in the first fibration ([ap↓]). As a special case, when [A] is [Unit], we find the familiar [ap] ([ap] is defined in terms of [ap↓] because it shouldn’t change anything for the user and this is helpful in some rare cases) -} ap : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y : A} → (x == y → f x == f y) ap f idp = idp ap↓ : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} (g : {a : A} → B a → C a) {x y : A} {p : x == y} {u : B x} {v : B y} → (u == v [ B ↓ p ] → g u == g v [ C ↓ p ]) ap↓ g {p = idp} p = ap g p {- [apd↓] is defined in lib.PathOver. Unlike [ap↓] and [ap], [apd] is not definitionally a special case of [apd↓] -} apd : ∀ {i j} {A : Type i} {B : A → Type j} (f : (a : A) → B a) {x y : A} → (p : x == y) → f x == f y [ B ↓ p ] apd f idp = idp {- An equality between types gives two maps back and forth -} coe : ∀ {i} {A B : Type i} (p : A == B) → A → B coe idp x = x coe! : ∀ {i} {A B : Type i} (p : A == B) → B → A coe! idp x = x {- The operations of transport forward and backward are defined in terms of [ap] and [coe], because this is more convenient in practice. -} transport : ∀ {i j} {A : Type i} (B : A → Type j) {x y : A} (p : x == y) → (B x → B y) transport B p = coe (ap B p) transport! : ∀ {i j} {A : Type i} (B : A → Type j) {x y : A} (p : x == y) → (B y → B x) transport! B p = coe! (ap B p) {- Π-types Shorter notation for Π-types. -} Π : ∀ {i j} (A : Type i) (P : A → Type j) → Type (lmax i j) Π A P = (x : A) → P x {- Σ-types Σ-types are defined as a record so that we have definitional η. -} infixr 60 _,_ record Σ {i j} (A : Type i) (B : A → Type j) : Type (lmax i j) where constructor _,_ field fst : A snd : B fst open Σ public pair= : ∀ {i j} {A : Type i} {B : A → Type j} {a a' : A} (p : a == a') {b : B a} {b' : B a'} (q : b == b' [ B ↓ p ]) → (a , b) == (a' , b') pair= idp q = ap (_,_ _) q pair×= : ∀ {i j} {A : Type i} {B : Type j} {a a' : A} (p : a == a') {b b' : B} (q : b == b') → (a , b) == (a' , b') pair×= idp q = pair= idp q {- Empty type We define the eliminator of the empty type using an absurd pattern. Given that absurd patterns are not consistent with HIT, we will not use empty patterns anymore after that. -} data ⊥ : Type₀ where Empty = ⊥ ⊥-elim : ∀ {i} {P : ⊥ → Type i} → ((x : ⊥) → P x) ⊥-elim () Empty-elim = ⊥-elim {- Negation and disequality -} ¬ : ∀ {i} (A : Type i) → Type i ¬ A = A → ⊥ _≠_ : ∀ {i} {A : Type i} → (A → A → Type i) x ≠ y = ¬ (x == y) {- Natural numbers -} data ℕ : Type₀ where O : ℕ S : (n : ℕ) → ℕ Nat = ℕ {-# BUILTIN NATURAL ℕ #-} {- Lifting to a higher universe level The operation of lifting enjoys both β and η definitionally. It’s a bit annoying to use, but it’s not used much (for now). -} record Lift {i j} (A : Type i) : Type (lmax i j) where instance constructor lift field lower : A open Lift public {- Equational reasoning Equational reasoning is a way to write readable chains of equalities. The idea is that you can write the following: t : a == e t = a =⟨ p ⟩ b =⟨ q ⟩ c =⟨ r ⟩ d =⟨ s ⟩ e ∎ where [p] is a path from [a] to [b], [q] is a path from [b] to [c], and so on. You often have to apply some equality in some context, for instance [p] could be [ap ctx thm] where [thm] is the interesting theorem used to prove that [a] is equal to [b], and [ctx] is the context. In such cases, you can use instead [thm |in-ctx ctx]. The advantage is that [ctx] is usually boring whereas the first word of [thm] is the most interesting part. _=⟨_⟩ is not definitionally the same thing as concatenation of paths _∙_ because we haven’t defined concatenation of paths yet, and also you probably shouldn’t reason on paths constructed with equational reasoning. If you do want to reason on paths constructed with equational reasoning, check out lib.types.PathSeq instead. -} infix 15 _∎ infixr 10 _=⟨_⟩_ _=⟨_⟩_ : ∀ {i} {A : Type i} (x : A) {y z : A} → x == y → y == z → x == z _ =⟨ idp ⟩ idp = idp _∎ : ∀ {i} {A : Type i} (x : A) → x == x _ ∎ = idp infixr 40 ap syntax ap f p = p |in-ctx f {- Various basic functions and function operations The identity function on a type [A] is [idf A] and the constant function at some point [b] is [cst b]. Composition of functions ([_∘_]) can handle dependent functions. -} idf : ∀ {i} (A : Type i) → (A → A) idf A = λ x → x cst : ∀ {i j} {A : Type i} {B : Type j} (b : B) → (A → B) cst b = λ _ → b infixr 80 _∘_ _∘_ : ∀ {i j k} {A : Type i} {B : A → Type j} {C : (a : A) → (B a → Type k)} → (g : {a : A} → Π (B a) (C a)) → (f : Π A B) → Π A (λ a → C a (f a)) g ∘ f = λ x → g (f x) -- Application infixr 0 _$_ _$_ : ∀ {i j} {A : Type i} {B : A → Type j} → (∀ x → B x) → (∀ x → B x) f $ x = f x -- (Un)curryfication curry : ∀ {i j k} {A : Type i} {B : A → Type j} {C : Σ A B → Type k} → (∀ s → C s) → (∀ x y → C (x , y)) curry f x y = f (x , y) uncurry : ∀ {i j k} {A : Type i} {B : A → Type j} {C : ∀ x → B x → Type k} → (∀ x y → C x y) → (∀ s → C (fst s) (snd s)) uncurry f (x , y) = f x y -- (Un)curryfication with the first argument made implicit curryi : ∀ {i j k} {A : Type i} {B : A → Type j} {C : Σ A B → Type k} → (∀ s → C s) → (∀ {x} y → C (x , y)) curryi f y = f (_ , y) uncurryi : ∀ {i j k} {A : Type i} {B : A → Type j} {C : ∀ x → B x → Type k} → (∀ {x} y → C x y) → (∀ s → C (fst s) (snd s)) uncurryi f (x , y) = f y {- Truncation levels The type of truncation levels is isomorphic to the type of natural numbers but "starts at -2". -} data TLevel : Type₀ where ⟨-2⟩ : TLevel S : (n : TLevel) → TLevel ℕ₋₂ = TLevel ⟨_⟩₋₂ : ℕ → ℕ₋₂ ⟨ O ⟩₋₂ = ⟨-2⟩ ⟨ S n ⟩₋₂ = S ⟨ n ⟩₋₂ {- Coproducts and case analysis -} data Coprod {i j} (A : Type i) (B : Type j) : Type (lmax i j) where inl : A → Coprod A B inr : B → Coprod A B infixr 80 _⊔_ _⊔_ = Coprod match_withl_withr_ : ∀ {i j k} {A : Type i} {B : Type j} {C : Coprod A B → Type k} (x : Coprod A B) (l : (a : A) → C (inl a)) (r : (b : B) → C (inr b)) → C x match (inl a) withl l withr r = l a match (inr b) withl l withr r = r b Dec : ∀ {i} (P : Type i) → Type i Dec P = P ⊔ ¬ P {- Used in a hack to make HITs maybe consistent. This is just a parametrized unit type (positively) -} data Phantom {i} {A : Type i} (a : A) : Type₀ where phantom : Phantom a {- -- When you want to cheat module ADMIT where postulate ADMIT : ∀ {i} {A : Type i} → A -} {- Numeric literal overloading - - This enables writing numeric literals -} record FromNat {i} (A : Type i) : Type (lsucc i) where field in-range : ℕ → Type i read : ∀ n → ⦃ _ : in-range n ⦄ → A open FromNat ⦃...⦄ public using () renaming (read to from-nat) {-# BUILTIN FROMNAT from-nat #-} record FromNeg {i} (A : Type i) : Type (lsucc i) where field in-range : ℕ → Type i read : ∀ n → ⦃ _ : in-range n ⦄ → A open FromNeg ⦃...⦄ public using () renaming (read to from-neg) {-# BUILTIN FROMNEG from-neg #-} instance ℕ-reader : FromNat ℕ FromNat.in-range ℕ-reader _ = ⊤ FromNat.read ℕ-reader n = n TLevel-reader : FromNat TLevel FromNat.in-range TLevel-reader _ = ⊤ FromNat.read TLevel-reader n = S (S ⟨ n ⟩₋₂) TLevel-neg-reader : FromNeg TLevel FromNeg.in-range TLevel-neg-reader O = ⊤ FromNeg.in-range TLevel-neg-reader 1 = ⊤ FromNeg.in-range TLevel-neg-reader 2 = ⊤ FromNeg.in-range TLevel-neg-reader (S (S (S _))) = ⊥ FromNeg.read TLevel-neg-reader O = S (S ⟨-2⟩) FromNeg.read TLevel-neg-reader 1 = S ⟨-2⟩ FromNeg.read TLevel-neg-reader 2 = ⟨-2⟩ FromNeg.read TLevel-neg-reader (S (S (S _))) ⦃()⦄
25.771028
85
0.586673
21ea9cd1dc6452a63386b6e2172e18bfc906f702
177
agda
Agda
test/Fail/Issue154.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue154.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue154.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- 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
17.7
66
0.734463
58715c0ac2cde6a19681fc4b45e7443fd1b2e86a
8,192
agda
Agda
Fields/CauchyCompletion/BaseExpansion.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
4
2019-08-08T12:44:19.000Z
2022-01-28T06:04:15.000Z
Fields/CauchyCompletion/BaseExpansion.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
14
2019-01-06T21:11:59.000Z
2020-04-11T11:03:39.000Z
Fields/CauchyCompletion/BaseExpansion.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
1
2021-11-29T13:23:07.000Z
2021-11-29T13:23:07.000Z
{-# OPTIONS --safe --warning=error --without-K --guardedness #-} open import Setoids.Setoids open import Rings.Definition open import Rings.Lemmas open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Groups.Definition open import Groups.Lemmas open import Fields.Fields open import Sets.EquivalenceRelations open import Sequences open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Functions.Definition open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Numbers.Naturals.Order.Lemmas open import Semirings.Definition open import Numbers.Modulo.Definition open import Orders.Total.Definition module Fields.CauchyCompletion.BaseExpansion {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where open Setoid S open SetoidTotalOrder (TotallyOrderedRing.total order) open SetoidPartialOrder pOrder open Equivalence eq open PartiallyOrderedRing pRing open Ring R open Group additiveGroup open Field F open import Fields.Orders.Limits.Definition {F = F} (record { oRing = order }) open import Fields.Orders.Total.Lemmas {F = F} (record { oRing = order }) open import Fields.Orders.Limits.Lemmas {F = F} (record { oRing = order }) open import Fields.Lemmas F open import Fields.Orders.Lemmas {F = F} record { oRing = order } open import Rings.Orders.Total.Lemmas order open import Rings.Orders.Total.AbsoluteValue order open import Rings.Orders.Partial.Lemmas pRing open import Fields.CauchyCompletion.Definition order F open import Fields.CauchyCompletion.Setoid order F open import Fields.CauchyCompletion.Addition order F open import Fields.CauchyCompletion.Comparison order F open import Fields.CauchyCompletion.Approximation order F open import Rings.InitialRing R open import Rings.Orders.Partial.Bounded pRing open import Rings.Orders.Total.Bounded order open import Rings.Orders.Total.Cauchy order -- TODO this is not necessarily true :( the bounded sequence could oscillate between 1 and -1 cauchyTimesBoundedIsCauchy : {s : Sequence A} → cauchy s → {t : Sequence A} → Bounded t → cauchy (apply _*_ s t) cauchyTimesBoundedIsCauchy {s} cau {t} (K , bounded) e 0<e with allInvertible K (boundNonzero (K , bounded)) ... | 1/K , prK with cau (1/K * e) (orderRespectsMultiplication (reciprocalPositive K 1/K (boundGreaterThanZero (K , bounded)) (transitive *Commutative prK)) 0<e) ... | N , cauPr = N , ans where ans : {m n : ℕ} (N<m : N <N m) (N<n : N <N n) → (abs (index (apply _*_ s t) m + inverse (index (apply _*_ s t) n))) < e ans N<m N<n with cauPr N<m N<n ... | r = {!!} boundedTimesCauchyIsCauchy : {s : Sequence A} → cauchy s → {t : Sequence A} → Bounded t → cauchy (apply _*_ t s) boundedTimesCauchyIsCauchy {s} cau {t} bou = cauchyWellDefined (ans s t) (cauchyTimesBoundedIsCauchy cau bou) where ans : (s t : Sequence A) (m : ℕ) → index (apply _*_ s t) m ∼ index (apply _*_ t s) m ans s t m rewrite indexAndApply t s _*_ {m} | indexAndApply s t _*_ {m} = *Commutative private digitExpansionSeq : {n : ℕ} → .(0<n : 0 <N n) → Sequence (ℤn n 0<n) → Sequence A Sequence.head (digitExpansionSeq {n} 0<n seq) = fromN (ℤn.x (Sequence.head seq)) Sequence.tail (digitExpansionSeq {n} 0<n seq) = digitExpansionSeq 0<n (Sequence.tail seq) powerSeq : (i : A) → (start : A) → Sequence A Sequence.head (powerSeq i start) = start Sequence.tail (powerSeq i start) = powerSeq i (start * i) powerSeqInduction : (i : A) (start : A) → (m : ℕ) → (index (powerSeq i start) (succ m)) ∼ i * (index (powerSeq i start) m) powerSeqInduction i start zero = *Commutative powerSeqInduction i start (succ m) = powerSeqInduction i (start * i) m ofBaseExpansionSeq : {n : ℕ} → .(0<n : 0 <N n) → Sequence (ℤn n 0<n) → Sequence A ofBaseExpansionSeq {succ n} 0<n seq = apply _*_ (digitExpansionSeq 0<n seq) (powerSeq pow pow) where pow : A pow = underlying (allInvertible (fromN (succ n)) (charNotN n)) powerSeqPositive : {i : A} → (0R < i) → {s : A} → (0R < s) → (m : ℕ) → 0R < index (powerSeq i s) m powerSeqPositive {i} 0<i {s} 0<s zero = 0<s powerSeqPositive {i} 0<i {s} 0<s (succ m) = <WellDefined reflexive (symmetric (powerSeqInduction i s m)) (orderRespectsMultiplication 0<i (powerSeqPositive 0<i 0<s m)) powerSeqConvergesTo0 : (i : A) → (0R < i) → (i < 1R) → {s : A} → (0R < s) → (powerSeq i s) ~> 0G powerSeqConvergesTo0 i 0<i i<1 {s} 0<s e 0<e = {!!} powerSeqConverges : (i : A) → (0R < i) → (i < 1R) → {s : A} → (0R < s) → cauchy (powerSeq i s) powerSeqConverges i 0<i i<1 {s} 0<s = convergentSequenceCauchy nontrivial {r = 0R} (powerSeqConvergesTo0 i 0<i i<1 0<s) 0<n : {n : ℕ} → 1 <N n → 0 <N n 0<n 1<n = TotalOrder.<Transitive ℕTotalOrder (le 0 refl) 1<n digitExpansionBoundedLemma : {n : ℕ} → .(0<n : 0 <N n) → (seq : Sequence (ℤn n 0<n)) → (m : ℕ) → index (digitExpansionSeq _ seq) m < fromN n digitExpansionBoundedLemma {n} 0<n seq zero with Sequence.head seq ... | record { x = x ; xLess = xLess } = fromNPreservesOrder (0<1 nontrivial) {x} {n} ((squash<N xLess)) digitExpansionBoundedLemma 0<n seq (succ m) = digitExpansionBoundedLemma 0<n (Sequence.tail seq) m digitExpansionBoundedLemma2 : {n : ℕ} → .(0<n : 0 <N n) → (seq : Sequence (ℤn n 0<n)) → (m : ℕ) → inverse (fromN n) < index (digitExpansionSeq 0<n seq) m digitExpansionBoundedLemma2 {n} 0<n seq zero = <WellDefined identLeft (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invRight) identRight)) (orderRespectsAddition {_} {fromN (ℤn.x (Sequence.head seq)) + fromN n} (<WellDefined reflexive (fromNPreserves+ (ℤn.x (Sequence.head seq)) n) (fromNPreservesOrder (0<1 nontrivial) {0} {ℤn.x (Sequence.head seq) +N n} (canAddToOneSideOfInequality' _ (squash<N 0<n)))) (inverse (fromN n))) digitExpansionBoundedLemma2 0<n seq (succ m) = digitExpansionBoundedLemma2 0<n (Sequence.tail seq) m digitExpansionBounded : {n : ℕ} → .(0<n : 0 <N n) → (seq : Sequence (ℤn n 0<n)) → Bounded (digitExpansionSeq 0<n seq) digitExpansionBounded {n} 0<n seq = fromN n , λ m → ((digitExpansionBoundedLemma2 0<n seq m) ,, digitExpansionBoundedLemma 0<n seq m) private 1/nPositive : (n : ℕ) → 0R < underlying (allInvertible (fromN (succ n)) (charNotN n)) 1/nPositive n with allInvertible (fromN (succ n)) (charNotN n) ... | a , b = reciprocalPositive (fromN (succ n)) a (fromNPreservesOrder (0<1 nontrivial) (succIsPositive n)) (transitive *Commutative b) 1/n<1 : (n : ℕ) → (0 <N n) → underlying (allInvertible (fromN (succ n)) (charNotN n)) < 1R 1/n<1 n 1<n with allInvertible (fromN (succ n)) (charNotN n) ... | a , b = reciprocal<1 (fromN (succ n)) a (<WellDefined identRight reflexive (fromNPreservesOrder (0<1 nontrivial) {1} {succ n} (succPreservesInequality 1<n))) (transitive *Commutative b) -- Construct the real that is the given base-n expansion between 0 and 1. ofBaseExpansion : {n : ℕ} → .(1<n : 1 <N n) → (fromN n ∼ 0R → False) → Sequence (ℤn n (0<n 1<n)) → CauchyCompletion ofBaseExpansion {succ n} 1<n charNotN seq = record { elts = ofBaseExpansionSeq (0<n 1<n) seq ; converges = boundedTimesCauchyIsCauchy (powerSeqConverges _ (1/nPositive n) (1/n<1 n (canRemoveSuccFrom<N (squash<N 1<n))) (1/nPositive n)) (digitExpansionBounded (0<n 1<n) seq)} toBaseExpansion : {n : ℕ} → .(1<n : 1 <N n) → (fromN n ∼ 0R → False) → (a : CauchyCompletion) → 0R r<C a → a <Cr 1R → Sequence (ℤn n (0<n 1<n)) Sequence.head (toBaseExpansion {n} 1<n charNotN c 0<c c<1) = {!!} -- TOOD: approximate c to within 1/n^2, extract the first decimal of the result. Sequence.tail (toBaseExpansion {n} 1<n charNotN c 0<c c<1) = toBaseExpansion 1<n charNotN {!!} {!!} {!!} baseExpansionProof : {n : ℕ} → .{1<n : 1 <N n} → {charNotN : fromN n ∼ 0R → False} → (as : CauchyCompletion) → (0<a : 0R r<C as) → (a<1 : as <Cr 1R) → Setoid._∼_ cauchyCompletionSetoid (ofBaseExpansion 1<n charNotN (toBaseExpansion 1<n charNotN as 0<a a<1)) as baseExpansionProof = {!!}
61.593985
455
0.693481
ad5894d5b424a0146ec9fff97e221f96125c9e72
2,584
agda
Agda
Cubical/Codata/M/AsLimit/itree.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/Codata/M/AsLimit/itree.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2022-01-27T02:07:48.000Z
2022-01-27T02:07:48.000Z
Cubical/Codata/M/AsLimit/itree.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2021-11-22T02:02:01.000Z
2021-11-22T02:02:01.000Z
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-} module Cubical.Codata.M.AsLimit.itree where open import Cubical.Data.Unit open import Cubical.Data.Prod open import Cubical.Data.Nat as ℕ using (ℕ ; suc ; _+_ ) open import Cubical.Data.Sum open import Cubical.Data.Empty open import Cubical.Data.Bool open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Codata.M.AsLimit.Container open import Cubical.Codata.M.AsLimit.M open import Cubical.Codata.M.AsLimit.Coalg -- Delay monad defined as an M-type delay-S : (R : Type₀) -> Container ℓ-zero delay-S R = (Unit ⊎ R) , λ { (inr _) -> ⊥ ; (inl tt) -> Unit } delay : (R : Type₀) -> Type₀ delay R = M (delay-S R) delay-ret : {R : Type₀} -> R -> delay R delay-ret r = in-fun (inr r , λ ()) delay-tau : {R : Type₀} -> delay R -> delay R delay-tau S = in-fun (inl tt , λ x → S) -- Bottom element raised data ⊥₁ : Type₁ where -- TREES tree-S : (E : Type₀ -> Type₁) (R : Type₀) -> Container (ℓ-suc ℓ-zero) tree-S E R = (R ⊎ (Σ[ A ∈ Type₀ ] (E A))) , (λ { (inl _) -> ⊥₁ ; (inr (A , e)) -> Lift A } ) tree : (E : Type₀ -> Type₁) (R : Type₀) -> Type₁ tree E R = M (tree-S E R) tree-ret : ∀ {E} {R} -> R -> tree E R tree-ret {E} {R} r = in-fun (inl r , λ ()) tree-vis : ∀ {E} {R} -> ∀ {A} -> E A -> (A -> tree E R) -> tree E R tree-vis {A = A} e k = in-fun (inr (A , e) , λ { (lift x) -> k x } ) -- ITrees (and buildup examples) -- https://arxiv.org/pdf/1906.00046.pdf -- Interaction Trees: Representing Recursive and Impure Programs in Coq -- Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, Steve Zdancewic itree-S : ∀ (E : Type₀ -> Type₁) (R : Type₀) -> Container (ℓ-suc ℓ-zero) itree-S E R = ((Unit ⊎ R) ⊎ (Σ[ A ∈ Type₀ ] (E A))) , (λ { (inl (inl _)) -> Lift Unit ; (inl (inr _)) -> ⊥₁ ; (inr (A , e)) -> Lift A } ) itree : ∀ (E : Type₀ -> Type₁) (R : Type₀) -> Type₁ itree E R = M (itree-S E R) ret' : ∀ {E} {R} -> R -> P₀ (itree-S E R) (itree E R) ret' {E} {R} r = inl (inr r) , λ () tau' : {E : Type₀ -> Type₁} -> {R : Type₀} -> itree E R -> P₀ (itree-S E R) (itree E R) tau' t = inl (inl tt) , λ x → t vis' : ∀ {E} {R} -> ∀ {A : Type₀} -> E A -> (A -> itree E R) -> P₀ (itree-S E R) (itree E R) vis' {A = A} e k = inr (A , e) , λ { (lift x) -> k x } ret : ∀ {E} {R} -> R -> itree E R ret = in-fun ∘ ret' tau : {E : Type₀ -> Type₁} -> {R : Type₀} -> itree E R -> itree E R tau = in-fun ∘ tau' vis : ∀ {E} {R} -> ∀ {A : Type₀} -> E A -> (A -> itree E R) -> itree E R vis {A = A} e = in-fun ∘ (vis' {A = A} e)
34
137
0.565402
439b9aaa63d823bac058fd0b0de9e578e0d951ab
658
agda
Agda
test/Succeed/Issue856.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue856.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue856.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- {-# OPTIONS -v tc.conv.inequal:20 #-} module Issue856 where import Common.Level record ⊤ : Set where data ⊥ : Set where data Bool : Set where true : Bool false : Bool T : Bool → Set T true = ⊤ T false = ⊥ record ∃ {A : Set} (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ postulate G : Set → Set D : ∀ {A} → G A → A → Set P : {A : Set} → G A → Set P g = ∀ x → D g x postulate f : ∀ {A} {g : G A} → P g → P g g : (p : ⊥ → Bool) → G (∃ λ t → T (p t)) h : ∀ {p : ⊥ → Bool} {t pt} → D (g p) (t , pt) p : ⊥ → Bool works : P (g p) works = f (λ _ → h {p = p}) fails : P (g p) fails = f (λ _ → h)
16.04878
48
0.487842
43aff7ccfd4ad5e86a9d5ddd78eeae3536a8a3ea
41,575
agda
Agda
Cubical/ZCohomology/GroupStructure.agda
howsiyu/cubical
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
[ "MIT" ]
1
2022-03-05T00:28:39.000Z
2022-03-05T00:28:39.000Z
Cubical/ZCohomology/GroupStructure.agda
snu-development/cubical
58f2d0dd07e51f8aa5b348a522691097b6695d1c
[ "MIT" ]
null
null
null
Cubical/ZCohomology/GroupStructure.agda
snu-development/cubical
58f2d0dd07e51f8aa5b348a522691097b6695d1c
[ "MIT" ]
null
null
null
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.GroupStructure where open import Cubical.ZCohomology.Base open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed hiding (id) open import Cubical.Foundations.Path open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws renaming (assoc to assoc∙) open import Cubical.Data.Sigma open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2 ; isSetSetTrunc to §) open import Cubical.Data.Int renaming (_+_ to _ℤ+_ ; -_ to -ℤ_) open import Cubical.Data.Nat renaming (+-assoc to +-assocℕ ; +-comm to +-commℕ) open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3 ; map2 to trMap2) open import Cubical.Homotopy.Loopspace open import Cubical.Algebra.Group renaming (ℤ to ℤGroup) open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open Iso renaming (inv to inv') private variable ℓ ℓ' : Level A : Type ℓ B : Type ℓ' A' : Pointed ℓ infixr 34 _+ₖ_ infixr 34 _+ₕ_ infixr 34 _+ₕ∙_ -- Addition in the Eilenberg-Maclane spaces is uniquely determined if we require it to have left- and right-unit laws, -- such that these agree on 0. In particular, any h-structure (see http://ericfinster.github.io/files/emhott.pdf) is unique. +ₖ-unique : (n : ℕ) → (comp1 comp2 : coHomK (suc n) → coHomK (suc n) → coHomK (suc n)) → (rUnit1 : (x : _) → comp1 x (coHom-pt (suc n)) ≡ x) → (lUnit1 : (x : _) → comp1 (coHom-pt (suc n)) x ≡ x) → (rUnit2 : (x : _) → comp2 x (coHom-pt (suc n)) ≡ x) → (lUnit2 : (x : _) → comp2 (coHom-pt (suc n)) x ≡ x) → (unId1 : rUnit1 (coHom-pt (suc n)) ≡ lUnit1 (coHom-pt (suc n))) → (unId2 : rUnit2 (coHom-pt (suc n)) ≡ lUnit2 (coHom-pt (suc n))) → (x y : _) → comp1 x y ≡ comp2 x y +ₖ-unique n comp1 comp2 rUnit1 lUnit1 rUnit2 lUnit2 unId1 unId2 = elim2 (λ _ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) (wedgeconFun _ _ (λ _ _ → help _ _) (λ x → lUnit1 ∣ x ∣ ∙ sym (lUnit2 ∣ x ∣)) (λ x → rUnit1 ∣ x ∣ ∙ sym (rUnit2 ∣ x ∣)) (cong₂ _∙_ unId1 (cong sym unId2))) where help : isOfHLevel (2 + (n + suc n)) (coHomK (suc n)) help = subst (λ x → isOfHLevel x (coHomK (suc n))) (+-suc n (2 + n) ∙ +-suc (suc n) (suc n)) (isOfHLevelPlus n (isOfHLevelTrunc (3 + n))) wedgeConHLev : (n : ℕ) → isOfHLevel ((2 + n) + (2 + n)) (coHomK (2 + n)) wedgeConHLev n = subst (λ x → isOfHLevel x (coHomK (2 + n))) (sym (+-suc (2 + n) (suc n) ∙ +-suc (3 + n) n)) (isOfHLevelPlus' {n = n} (4 + n) (isOfHLevelTrunc (4 + n))) wedgeConHLev' : (n : ℕ) → isOfHLevel ((2 + n) + (2 + n)) (typ (Ω (coHomK-ptd (3 + n)))) wedgeConHLev' n = subst (λ x → isOfHLevel x (typ (Ω (coHomK-ptd (3 + n))))) (sym (+-suc (2 + n) (suc n) ∙ +-suc (3 + n) n)) (isOfHLevelPlus' {n = n} (4 + n) (isOfHLevelTrunc (5 + n) _ _)) wedgeConHLevPath : (n : ℕ) → (x y : coHomK (suc n)) → isOfHLevel ((suc n) + (suc n)) (x ≡ y) wedgeConHLevPath zero x y = isOfHLevelTrunc 3 _ _ wedgeConHLevPath (suc n) x y = isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _ -- addition for n ≥ 2 together with the left- and right-unit laws (modulo truncations) preAdd : (n : ℕ) → (S₊ (2 + n) → S₊ (2 + n) → coHomK (2 + n)) preAdd n = wedgeconFun _ _ (λ _ _ → wedgeConHLev n) ∣_∣ ∣_∣ refl preAdd-l : (n : ℕ) → (x : (S₊ (2 + n))) → preAdd n north x ≡ ∣ x ∣ preAdd-l n _ = refl preAdd-r : (n : ℕ) → (x : (S₊ (2 + n))) → preAdd n x north ≡ ∣ x ∣ preAdd-r n = wedgeconRight _ (suc n) (λ _ _ → wedgeConHLev n) ∣_∣ ∣_∣ refl -- addition for n = 1 wedgeMapS¹ : S¹ → S¹ → S¹ wedgeMapS¹ base y = y wedgeMapS¹ (loop i) base = loop i wedgeMapS¹ (loop i) (loop j) = hcomp (λ k → λ { (i = i0) → loop j ; (i = i1) → loop (j ∧ k) ; (j = i0) → loop i ; (j = i1) → loop (i ∧ k)}) (loop (i ∨ j)) ---------- Algebra/Group stuff -------- 0ₖ : (n : ℕ) → coHomK n 0ₖ = coHom-pt _+ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n _+ₖ_ {n = zero} x y = x ℤ+ y _+ₖ_ {n = suc zero} = trMap2 wedgeMapS¹ _+ₖ_ {n = suc (suc n)} = trRec (isOfHLevelΠ (4 + n) λ _ → isOfHLevelTrunc (4 + n)) λ x → trRec (isOfHLevelTrunc (4 + n)) (preAdd n x) private isEquiv+ : (n : ℕ) → (x : coHomK (suc n)) → isEquiv (_+ₖ_ {n = (suc n)} x) isEquiv+ zero = trElim (λ _ → isProp→isOfHLevelSuc 2 (isPropIsEquiv _)) (toPropElim (λ _ → isPropIsEquiv _) (subst isEquiv (sym help) (idIsEquiv _))) where help : _+ₖ_ {n = 1} (coHom-pt 1) ≡ idfun _ help = funExt (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ _ → refl) isEquiv+ (suc n) = trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isPropIsEquiv _)) (suspToPropElim (ptSn (suc n)) (λ _ → isPropIsEquiv _) (subst isEquiv (sym help) (idIsEquiv _))) where help : _+ₖ_ {n = (2 + n)} (coHom-pt (2 + n)) ≡ idfun _ help = funExt (trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) λ _ → refl) Kₙ≃Kₙ : (n : ℕ) (x : coHomK (suc n)) → coHomK (suc n) ≃ coHomK (suc n) Kₙ≃Kₙ n x = _ , isEquiv+ n x -ₖ_ : {n : ℕ} → coHomK n → coHomK n -ₖ_ {n = zero} x = 0 - x -ₖ_ {n = suc zero} = trMap λ {base → base ; (loop i) → (loop (~ i))} -ₖ_ {n = suc (suc n)} = trMap λ {north → north ; south → north ; (merid a i) → ((merid (ptSn (suc n)) ∙ sym (merid a))) i} _-ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n _-ₖ_ {n = n} x y = _+ₖ_ {n = n} x (-ₖ_ {n = n} y) +ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n +ₖ-syntax n = _+ₖ_ {n = n} -ₖ-syntax : (n : ℕ) → coHomK n → coHomK n -ₖ-syntax n = -ₖ_ {n = n} -'ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n -'ₖ-syntax n = _-ₖ_ {n = n} syntax +ₖ-syntax n x y = x +[ n ]ₖ y syntax -ₖ-syntax n x = -[ n ]ₖ x syntax -'ₖ-syntax n x y = x -[ n ]ₖ y -ₖ^2 : {n : ℕ} → (x : coHomK n) → (-ₖ (-ₖ x)) ≡ x -ₖ^2 {n = zero} x = +Comm (pos zero) (-ℤ (pos zero ℤ+ (-ℤ x))) ∙∙ -Dist+ (pos zero) (-ℤ x) ∙∙ (+Comm (pos zero) (-ℤ (-ℤ x)) ∙ -Involutive x) -ₖ^2 {n = suc zero} = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ { base → refl ; (loop i) → refl} -ₖ^2 {n = suc (suc n)} = trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) λ { north → refl ; south j → ∣ merid (ptSn _) j ∣ₕ ; (merid a i) j → hcomp (λ k → λ { (i = i0) → ∣ north ∣ ; (i = i1) → ∣ compPath-filler' (merid a) (sym (merid (ptSn _))) (~ k) (~ j) ∣ₕ ; (j = i0) → help a (~ k) i ; (j = i1) → ∣ merid a (i ∧ k) ∣}) ∣ (merid a ∙ sym (merid (ptSn _))) (i ∧ ~ j) ∣ₕ} where help : (a : _) → cong (-ₖ_ ∘ (-ₖ_ {n = suc (suc n)})) (cong ∣_∣ₕ (merid a)) ≡ cong ∣_∣ₕ (merid a ∙ sym (merid (ptSn _))) help a = cong (cong ((-ₖ_ {n = suc (suc n)}))) (cong-∙ ∣_∣ₕ (merid (ptSn (suc n))) (sym (merid a))) ∙∙ cong-∙ (-ₖ_ {n = suc (suc n)}) (cong ∣_∣ₕ (merid (ptSn (suc n)))) (cong ∣_∣ₕ (sym (merid a))) ∙∙ (λ i → (λ j → ∣ rCancel (merid (ptSn (suc n))) i j ∣ₕ) ∙ λ j → ∣ symDistr (merid (ptSn (suc n))) (sym (merid a)) i j ∣ₕ) ∙ sym (lUnit _) ------- Groupoid Laws for Kₙ --------- commₖ : (n : ℕ) → (x y : coHomK n) → x +[ n ]ₖ y ≡ y +[ n ]ₖ x commₖ zero = +Comm commₖ (suc zero) = elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) (wedgeconFun _ _ (λ _ _ → isOfHLevelTrunc 3 _ _) (λ {base → refl ; (loop i) → refl}) (λ {base → refl ; (loop i) → refl}) refl) commₖ (suc (suc n)) = elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) (wedgeconFun _ _ (λ x y → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _) (λ x → preAdd-l n x ∙ sym (preAdd-r n x)) (λ x → preAdd-r n x ∙ sym (preAdd-l n x)) refl) commₖ-base : (n : ℕ) → commₖ n (coHom-pt n) (coHom-pt n) ≡ refl commₖ-base zero = refl commₖ-base (suc zero) = refl commₖ-base (suc (suc n)) = sym (rUnit _) rUnitₖ : (n : ℕ) → (x : coHomK n) → x +[ n ]ₖ coHom-pt n ≡ x rUnitₖ zero x = refl rUnitₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ {base → refl ; (loop i) → refl} rUnitₖ (suc (suc n)) = trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) (preAdd-r n) lUnitₖ : (n : ℕ) → (x : coHomK n) → coHom-pt n +[ n ]ₖ x ≡ x lUnitₖ zero x = sym (pos0+ x) lUnitₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ {base → refl ; (loop i) → refl} lUnitₖ (suc (suc n)) = trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) λ x → refl ∙≡+₁ : (p q : typ (Ω (coHomK-ptd 1))) → p ∙ q ≡ cong₂ _+ₖ_ p q ∙≡+₁ p q = (λ i → (λ j → rUnitₖ 1 (p j) (~ i)) ∙ λ j → lUnitₖ 1 (q j) (~ i)) ∙ sym (cong₂Funct _+ₖ_ p q) ∙≡+₂ : (n : ℕ) (p q : typ (Ω (coHomK-ptd (suc (suc n))))) → p ∙ q ≡ cong₂ _+ₖ_ p q ∙≡+₂ n p q = (λ i → (λ j → rUnitₖ (2 + n) (p j) (~ i)) ∙ λ j → lUnitₖ (2 + n) (q j) (~ i)) ∙ sym (cong₂Funct _+ₖ_ p q) lCancelₖ : (n : ℕ) → (x : coHomK n) → (-ₖ_ {n = n} x) +ₖ x ≡ coHom-pt n lCancelₖ zero x = minusPlus x 0 lCancelₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ {base → refl ; (loop i) j → help j i} where help : cong₂ _+ₖ_ (sym (cong ∣_∣ loop)) (cong ∣_∣ loop) ≡ refl help = sym (∙≡+₁ (sym (cong ∣_∣ loop)) (cong ∣_∣ loop)) ∙ lCancel _ lCancelₖ (suc (suc n)) = trElim (λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) λ {north → refl ; south → cong ∣_∣ (sym (merid (ptSn (suc n)))) ; (merid a i) → help a i } where s : (a : _) → _ ≡ _ s x = cong₂ _+ₖ_ (sym (cong ∣_∣ (merid (ptSn (suc n)) ∙ sym (merid x)))) (cong ∣_∣ (sym (merid x))) help : (a : _) → PathP (λ i → (preAdd n ((merid (ptSn (suc n)) ∙ (λ i₁ → merid a (~ i₁))) i) (merid a i)) ≡ ∣ north ∣) refl λ i₁ → ∣ merid (ptSn (suc n)) (~ i₁) ∣ help x = compPathR→PathP ((sym (lCancel _) ∙∙ (λ i → ∙≡+₂ _ (cong ∣_∣ (symDistr (merid x) (sym (merid (ptSn (suc n)))) i)) (cong ∣_∣ ((merid x) ∙ sym (merid (ptSn (suc n))))) i) ∙∙ rUnit _) ∙∙ (λ j → cong₂ _+ₖ_ ((cong ∣_∣ (merid (ptSn (suc n)) ∙ sym (merid x)))) (λ i → ∣ compPath-filler ((merid x)) ((sym (merid (ptSn (suc n))))) (~ j) i ∣) ∙ λ i → ∣ merid (ptSn (suc n)) (~ i ∧ j) ∣) ∙∙ λ i → sym (s x) ∙ rUnit (cong ∣_∣ (sym (merid (ptSn (suc n))))) i) rCancelₖ : (n : ℕ) → (x : coHomK n) → x +ₖ (-ₖ_ {n = n} x) ≡ coHom-pt n rCancelₖ zero x = +Comm x (pos 0 - x) ∙ minusPlus x 0 -- +-comm x (pos 0 - x) ∙ minusPlus x 0 rCancelₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ {base → refl ; (loop i) j → help j i} where help : (λ i → ∣ loop i ∣ₕ +ₖ (-ₖ ∣ loop i ∣ₕ)) ≡ refl help = sym (∙≡+₁ (cong ∣_∣ₕ loop) (sym (cong ∣_∣ₕ loop))) ∙ rCancel _ rCancelₖ (suc (suc n)) x = commₖ _ x (-ₖ x) ∙ lCancelₖ _ x rCancel≡refl : (n : ℕ) → rCancelₖ (2 + n) (0ₖ _) ≡ refl rCancel≡refl n i = rUnit (rUnit refl (~ i)) (~ i) assocₖ : (n : ℕ) → (x y z : coHomK n) → x +[ n ]ₖ (y +[ n ]ₖ z) ≡ (x +[ n ]ₖ y) +[ n ]ₖ z assocₖ zero = +Assoc assocₖ (suc zero) = trElim3 (λ _ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ x → wedgeconFun _ _ (λ _ _ → isOfHLevelTrunc 3 _ _) (λ y i → rUnitₖ 1 ∣ x ∣ (~ i) +ₖ ∣ y ∣) (λ z → cong (∣ x ∣ +ₖ_) (rUnitₖ 1 ∣ z ∣) ∙ sym (rUnitₖ 1 (∣ x ∣ +ₖ ∣ z ∣))) (helper x) where helper : (x : S¹) → cong (∣ x ∣ +ₖ_) (rUnitₖ 1 ∣ base ∣) ∙ sym (rUnitₖ 1 (∣ x ∣ +ₖ ∣ base ∣)) ≡ (cong (_+ₖ ∣ base ∣) (sym (rUnitₖ 1 ∣ x ∣))) helper = toPropElim (λ _ → isOfHLevelTrunc 3 _ _ _ _) (sym (lUnit refl)) assocₖ (suc (suc n)) = trElim3 (λ _ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) (wedgeConSn-×3 _ (λ x z i → preAdd-r n x (~ i) +ₖ ∣ z ∣) (λ x y → cong (∣ x ∣ +ₖ_) (rUnitₖ (2 + n) ∣ y ∣) ∙ sym (rUnitₖ (2 + n) (∣ x ∣ +ₖ ∣ y ∣))) (lUnit (sym (rUnitₖ (2 + n) (∣ north ∣ +ₖ ∣ north ∣))))) where wedgeConSn-×3 : (n : ℕ) → (f : (x z : S₊ (2 + n))→ ∣ x ∣ +ₖ ((0ₖ _) +ₖ ∣ z ∣) ≡ (∣ x ∣ +ₖ (0ₖ _)) +ₖ ∣ z ∣) → (g : (x y : S₊ (2 + n)) → ∣ x ∣ +ₖ (∣ y ∣ +ₖ 0ₖ _) ≡ (∣ x ∣ +ₖ ∣ y ∣) +ₖ 0ₖ _) → (f (ptSn _) (ptSn _) ≡ g (ptSn _) (ptSn _)) → (x y z : S₊ (2 + n)) → ∣ x ∣ +ₖ (∣ y ∣ +ₖ ∣ z ∣) ≡ (∣ x ∣ +ₖ ∣ y ∣) +ₖ ∣ z ∣ wedgeConSn-×3 n f g d x = wedgeconFun _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _) (f x) (g x) (sphereElim _ {A = λ x → g x (ptSn (suc (suc n))) ≡ f x (ptSn (suc (suc n))) } (λ _ → isOfHLevelTrunc (4 + n) _ _ _ _) (sym d) x) {- This was the original proof for the case n ≥ 2: For some reason it doesn't check in reasonable time anymore: assocₖ (suc (suc n)) = trElim3 (λ _ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) λ x → wedgeConSn _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _) (λ z i → preAdd n .snd .snd x (~ i) +ₖ ∣ z ∣) (λ y → cong (∣ x ∣ +ₖ_) (rUnitₖ (2 + n) ∣ y ∣) ∙ sym (rUnitₖ (2 + n) (∣ x ∣ +ₖ ∣ y ∣))) (helper x) .fst where helper : (x : S₊ (2 + n)) → cong (∣ x ∣ +ₖ_) (rUnitₖ (2 + n) ∣ north ∣) ∙ sym (rUnitₖ (2 + n) (∣ x ∣ +ₖ ∣ north ∣)) ≡ cong (_+ₖ ∣ north ∣) (sym (preAdd n .snd .snd x)) helper = sphereElim (suc n) (λ _ → isOfHLevelTrunc (4 + n) _ _ _ _) (sym (lUnit (sym (rUnitₖ (2 + n) (∣ north ∣ +ₖ ∣ north ∣))))) -} lUnitₖ≡rUnitₖ : (n : ℕ) → lUnitₖ n (coHom-pt n) ≡ rUnitₖ n (coHom-pt n) lUnitₖ≡rUnitₖ zero = isSetℤ _ _ _ _ lUnitₖ≡rUnitₖ (suc zero) = refl lUnitₖ≡rUnitₖ (suc (suc n)) = refl ------ Commutativity of ΩKₙ -- We show that p ∙ q ≡ (λ i → (p i) +ₖ (q i)) for any p q : ΩKₙ₊₁. This allows us to prove that p ∙ q ≡ q ∙ p -- without having to use the equivalence Kₙ ≃ ΩKₙ₊₁ cong+ₖ-comm : (n : ℕ) (p q : typ (Ω (coHomK-ptd (suc n)))) → cong₂ _+ₖ_ p q ≡ cong₂ _+ₖ_ q p cong+ₖ-comm zero p q = rUnit (cong₂ _+ₖ_ p q) ∙∙ (λ i → (λ j → commₖ 1 ∣ base ∣ ∣ base ∣ (i ∧ j)) ∙∙ (λ j → commₖ 1 (p j) (q j) i) ∙∙ λ j → commₖ 1 ∣ base ∣ ∣ base ∣ (i ∧ ~ j)) ∙∙ ((λ i → commₖ-base 1 i ∙∙ cong₂ _+ₖ_ q p ∙∙ sym (commₖ-base 1 i)) ∙ sym (rUnit (cong₂ _+ₖ_ q p))) cong+ₖ-comm (suc n) p q = rUnit (cong₂ _+ₖ_ p q) ∙∙ (λ i → (λ j → commₖ (2 + n) ∣ north ∣ ∣ north ∣ (i ∧ j)) ∙∙ (λ j → commₖ (2 + n) (p j) (q j) i ) ∙∙ λ j → commₖ (2 + n) ∣ north ∣ ∣ north ∣ (i ∧ ~ j)) ∙∙ ((λ i → commₖ-base (2 + n) i ∙∙ cong₂ _+ₖ_ q p ∙∙ sym (commₖ-base (2 + n) i)) ∙ sym (rUnit (cong₂ _+ₖ_ q p))) isCommΩK : (n : ℕ) → isComm∙ (coHomK-ptd n) isCommΩK zero p q = isSetℤ _ _ (p ∙ q) (q ∙ p) isCommΩK (suc zero) p q = ∙≡+₁ p q ∙∙ cong+ₖ-comm 0 p q ∙∙ sym (∙≡+₁ q p) isCommΩK (suc (suc n)) p q = ∙≡+₂ n p q ∙∙ cong+ₖ-comm (suc n) p q ∙∙ sym (∙≡+₂ n q p) ----- some other useful lemmas about algebra in Kₙ -0ₖ : {n : ℕ} → -[ n ]ₖ (0ₖ n) ≡ (0ₖ n) -0ₖ {n = zero} = refl -0ₖ {n = suc zero} = refl -0ₖ {n = suc (suc n)} = refl -distrₖ : (n : ℕ) (x y : coHomK n) → -[ n ]ₖ (x +[ n ]ₖ y) ≡ (-[ n ]ₖ x) +[ n ]ₖ (-[ n ]ₖ y) -distrₖ zero x y = GroupTheory.invDistr ℤGroup x y ∙ +Comm (0 - y) (0 - x) -distrₖ (suc zero) = elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) (wedgeconFun _ _ (λ _ _ → isOfHLevelTrunc 3 _ _) (λ x → sym (lUnitₖ 1 (-[ 1 ]ₖ ∣ x ∣))) (λ x → cong (λ x → -[ 1 ]ₖ x) (rUnitₖ 1 ∣ x ∣) ∙ sym (rUnitₖ 1 (-[ 1 ]ₖ ∣ x ∣))) (sym (rUnit refl))) -distrₖ (suc (suc n)) = elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) (wedgeconFun _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev n) _ _) (λ x → sym (lUnitₖ (2 + n) (-[ (2 + n) ]ₖ ∣ x ∣))) (λ x → cong (λ x → -[ (2 + n) ]ₖ x) (rUnitₖ (2 + n) ∣ x ∣ ) ∙ sym (rUnitₖ (2 + n) (-[ (2 + n) ]ₖ ∣ x ∣))) (sym (rUnit refl))) -cancelRₖ : (n : ℕ) (x y : coHomK n) → (y +[ n ]ₖ x) -[ n ]ₖ x ≡ y -cancelRₖ zero x y = sym (+Assoc y x (0 - x)) ∙∙ cong (y ℤ+_) (+Comm x (0 - x)) ∙∙ cong (y ℤ+_) (minusPlus x (pos 0)) -cancelRₖ (suc zero) = elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) (wedgeconFun _ _ (λ _ _ → wedgeConHLevPath 0 _ _) (λ x → cong (_+ₖ ∣ base ∣) (rUnitₖ 1 ∣ x ∣) ∙ rUnitₖ 1 ∣ x ∣) (λ x → rCancelₖ 1 ∣ x ∣) (rUnit refl)) -cancelRₖ (suc (suc n)) = elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) (wedgeconFun _ _ (λ _ _ → wedgeConHLevPath (suc n) _ _) (λ x → cong (_+ₖ ∣ north ∣) (rUnitₖ (2 + n) ∣ x ∣) ∙ rUnitₖ (2 + n) ∣ x ∣) (λ x → rCancelₖ (2 + n) ∣ x ∣) (sym (rUnit _))) -cancelLₖ : (n : ℕ) (x y : coHomK n) → (x +[ n ]ₖ y) -[ n ]ₖ x ≡ y -cancelLₖ n x y = cong (λ z → z -[ n ]ₖ x) (commₖ n x y) ∙ -cancelRₖ n x y -+cancelₖ : (n : ℕ) (x y : coHomK n) → (x -[ n ]ₖ y) +[ n ]ₖ y ≡ x -+cancelₖ zero x y = sym (+Assoc x (0 - y) y) ∙ cong (x ℤ+_) (minusPlus y (pos 0)) -+cancelₖ (suc zero) = elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) (wedgeconFun _ _ (λ _ _ → wedgeConHLevPath 0 _ _) (λ x → cong (_+ₖ ∣ x ∣) (lUnitₖ 1 (-ₖ ∣ x ∣)) ∙ lCancelₖ 1 ∣ x ∣) (λ x → cong (_+ₖ ∣ base ∣) (rUnitₖ 1 ∣ x ∣) ∙ rUnitₖ 1 ∣ x ∣) refl) -+cancelₖ (suc (suc n)) = elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) (wedgeconFun _ _ (λ _ _ → wedgeConHLevPath (suc n) _ _) (λ x → cong (_+ₖ ∣ x ∣) (lUnitₖ (2 + n) (-ₖ ∣ x ∣)) ∙ lCancelₖ (2 + n) ∣ x ∣) (λ x → cong (_+ₖ ∣ north ∣) (rUnitₖ (2 + n) ∣ x ∣) ∙ rUnitₖ (2 + n) ∣ x ∣) refl) ---- Group structure of cohomology groups _+ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A _+ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x +[ n ]ₖ b x) ∣₂ -ₕ_ : {n : ℕ} → coHom n A → coHom n A -ₕ_ {n = n} = sRec § λ a → ∣ (λ x → -[ n ]ₖ a x) ∣₂ _-ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A _-ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x -[ n ]ₖ b x) ∣₂ +ₕ-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A +ₕ-syntax n = _+ₕ_ {n = n} -ₕ-syntax : (n : ℕ) → coHom n A → coHom n A -ₕ-syntax n = -ₕ_ {n = n} -ₕ'-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A -ₕ'-syntax n = _-ₕ_ {n = n} syntax +ₕ-syntax n x y = x +[ n ]ₕ y syntax -ₕ-syntax n x = -[ n ]ₕ x syntax -ₕ'-syntax n x y = x -[ n ]ₕ y 0ₕ : (n : ℕ) → coHom n A 0ₕ n = ∣ (λ _ → (0ₖ n)) ∣₂ _+'ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A _+'ₕ_ {n = n} x y = (x +ₕ 0ₕ _) +ₕ y +ₕ 0ₕ _ rUnitₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (0ₕ n) ≡ x rUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rUnitₖ n (a x)) i ∣₂ lUnitₕ : (n : ℕ) (x : coHom n A) → (0ₕ n) +[ n ]ₕ x ≡ x lUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lUnitₖ n (a x)) i ∣₂ rCancelₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (-[ n ]ₕ x) ≡ 0ₕ n rCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rCancelₖ n (a x)) i ∣₂ lCancelₕ : (n : ℕ) (x : coHom n A) → (-[ n ]ₕ x) +[ n ]ₕ x ≡ 0ₕ n lCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lCancelₖ n (a x)) i ∣₂ assocₕ : (n : ℕ) (x y z : coHom n A) → (x +[ n ]ₕ (y +[ n ]ₕ z)) ≡ ((x +[ n ]ₕ y) +[ n ]ₕ z) assocₕ n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b c i → ∣ funExt (λ x → assocₖ n (a x) (b x) (c x)) i ∣₂ commₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) ≡ (y +[ n ]ₕ x) commₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ funExt (λ x → commₖ n (a x) (b x)) i ∣₂ -cancelLₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) -[ n ]ₕ x ≡ y -cancelLₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelLₖ n (a x) (b x) i) ∣₂ -cancelRₕ : (n : ℕ) (x y : coHom n A) → (y +[ n ]ₕ x) -[ n ]ₕ x ≡ y -cancelRₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelRₖ n (a x) (b x) i) ∣₂ -+cancelₕ : (n : ℕ) (x y : coHom n A) → (x -[ n ]ₕ y) +[ n ]ₕ y ≡ x -+cancelₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -+cancelₖ n (a x) (b x) i) ∣₂ -- Group structure of reduced cohomology groups (in progress - might need K to compute properly first) _+ₕ∙_ : {A : Pointed ℓ} {n : ℕ} → coHomRed n A → coHomRed n A → coHomRed n A _+ₕ∙_ {n = zero} = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ zero ]ₖ b x) , (λ i → (pa i +[ zero ]ₖ pb i)) ∣₂ } _+ₕ∙_ {n = (suc zero)} = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ 1 ]ₖ b x) , (λ i → pa i +[ 1 ]ₖ pb i) ∣₂ } _+ₕ∙_ {n = (suc (suc n))} = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ (2 + n) ]ₖ b x) , (λ i → pa i +[ (2 + n) ]ₖ pb i) ∣₂ } -ₕ∙_ : {A : Pointed ℓ} {n : ℕ} → coHomRed n A → coHomRed n A -ₕ∙_ {n = zero} = sRec § λ {(f , p) → ∣ (λ x → -[ 0 ]ₖ (f x)) , cong (λ x → -[ 0 ]ₖ x) p ∣₂} -ₕ∙_ {n = suc zero} = sRec § λ {(f , p) → ∣ (λ x → -ₖ (f x)) , cong -ₖ_ p ∣₂} -ₕ∙_ {n = suc (suc n)} = sRec § λ {(f , p) → ∣ (λ x → -ₖ (f x)) , cong -ₖ_ p ∣₂} 0ₕ∙ : {A : Pointed ℓ} (n : ℕ) → coHomRed n A 0ₕ∙ n = ∣ (λ _ → 0ₖ n) , refl ∣₂ +ₕ∙-syntax : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A → coHomRed n A +ₕ∙-syntax n = _+ₕ∙_ {n = n} -ₕ∙-syntax : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A -ₕ∙-syntax n = -ₕ∙_ {n = n} -'ₕ∙-syntax : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A → coHomRed n A -'ₕ∙-syntax n x y = _+ₕ∙_ {n = n} x (-ₕ∙_ {n = n} y) syntax +ₕ∙-syntax n x y = x +[ n ]ₕ∙ y syntax -ₕ∙-syntax n x = -[ n ]ₕ∙ x syntax -'ₕ∙-syntax n x y = x -[ n ]ₕ∙ y commₕ∙ : {A : Pointed ℓ} (n : ℕ) (x y : coHomRed n A) → x +[ n ]ₕ∙ y ≡ y +[ n ]ₕ∙ x commₕ∙ zero = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ {(f , p) (g , q) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → commₖ 0 (f x) (g x) i)} commₕ∙ (suc zero) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ {(f , p) (g , q) → cong ∣_∣₂ (ΣPathP ((λ i x → commₖ 1 (f x) (g x) i) , λ i j → commₖ 1 (p j) (q j) i))} commₕ∙ {A = A} (suc (suc n)) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ {(f , p) (g , q) → cong ∣_∣₂ (ΣPathP ((λ i x → commₖ (2 + n) (f x) (g x) i) , λ i j → hcomp (λ k → λ {(i = i0) → p j +ₖ q j ; (i = i1) → q j +ₖ p j ; (j = i0) → commₖ (2 + n) (f (pt A)) (g (pt A)) i ; (j = i1) → rUnit (refl {x = 0ₖ (2 + n)}) (~ k) i}) (commₖ (2 + n) (p j) (q j) i)))} rUnitₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → x +[ n ]ₕ∙ 0ₕ∙ n ≡ x rUnitₕ∙ zero = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → rUnitₖ zero (f x) i)} rUnitₕ∙ (suc zero) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → rUnitₖ 1 (f x) i) , λ i j → rUnitₖ 1 (p j) i))} rUnitₕ∙ (suc (suc n)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → rUnitₖ (2 + n) (f x) i) , λ i j → rUnitₖ (2 + n) (p j) i))} lUnitₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → 0ₕ∙ n +[ n ]ₕ∙ x ≡ x lUnitₕ∙ zero = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → lUnitₖ zero (f x) i)} lUnitₕ∙ (suc zero) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → lUnitₖ 1 (f x) i) , λ i j → lUnitₖ 1 (p j) i))} lUnitₕ∙ (suc (suc n)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → lUnitₖ (2 + n) (f x) i) , λ i j → lUnitₖ (2 + n) (p j) i))} private pp : {A : Pointed ℓ} (n : ℕ) → (f : fst A → coHomK (suc (suc n))) → (p : f (snd A) ≡ snd (coHomK-ptd (suc (suc n)))) → PathP (λ i → rCancelₖ (2 + n) (f (snd A)) i ≡ 0ₖ (suc (suc n))) (λ i → (p i) +ₖ (-ₖ p i)) (λ _ → 0ₖ (suc (suc n))) pp {A = A} n f p i j = hcomp (λ k → λ {(i = i0) → rCancelₖ (suc (suc n)) (p j) (~ k) ; (i = i1) → 0ₖ (suc (suc n)) ; (j = i0) → rCancelₖ (2 + n) (f (snd A)) (i ∨ ~ k) ; (j = i1) → rUnit (rUnit (λ _ → 0ₖ (suc (suc n))) (~ i)) (~ i) k}) (0ₖ (suc (suc n))) rCancelₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → x +[ n ]ₕ∙ (-[ n ]ₕ∙ x) ≡ 0ₕ∙ n rCancelₕ∙ zero = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → rCancelₖ zero (f x) i)} rCancelₕ∙ {A = A} (suc zero) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → rCancelₖ 1 (f x) i) , λ i j → rCancelₖ 1 (p j) i))} rCancelₕ∙ {A = A} (suc (suc n)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → rCancelₖ (2 + n) (f x) i) , pp n f p))} lCancelₕ∙ : {A : Pointed ℓ} (n : ℕ) (x : coHomRed n A) → (-[ n ]ₕ∙ x) +[ n ]ₕ∙ x ≡ 0ₕ∙ n lCancelₕ∙ zero = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) λ i x → lCancelₖ zero (f x) i)} lCancelₕ∙ {A = A} (suc zero) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → lCancelₖ 1 (f x) i) , λ i j → (lCancelₖ 1 (p j) i)))} lCancelₕ∙ {A = A} (suc (suc n)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP ((λ i x → lCancelₖ (2 + n) (f x) i) , λ i j → lCancelₖ (2 + n) (p j) i))} assocₕ∙ : {A : Pointed ℓ} (n : ℕ) (x y z : coHomRed n A) → (x +[ n ]ₕ∙ (y +[ n ]ₕ∙ z)) ≡ ((x +[ n ]ₕ∙ y) +[ n ]ₕ∙ z) assocₕ∙ zero = elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _) λ {(f , p) (g , q) (h , r) → cong ∣_∣₂ (Σ≡Prop (λ _ → isSetℤ _ _) (λ i x → assocₖ zero (f x) (g x) (h x) i))} assocₕ∙ (suc zero) = elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _) λ {(f , p) (g , q) (h , r) → cong ∣_∣₂ (ΣPathP ((λ i x → assocₖ 1 (f x) (g x) (h x) i) , λ i j → assocₖ 1 (p j) (q j) (r j) i))} assocₕ∙ (suc (suc n)) = elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _) λ {(f , p) (g , q) (h , r) → cong ∣_∣₂ (ΣPathP ((λ i x → assocₖ (2 + n) (f x) (g x) (h x) i) , λ i j → assocₖ (2 + n) (p j) (q j) (r j) i))} open IsSemigroup open IsMonoid open GroupStr open IsGroupHom coHomGr : (n : ℕ) (A : Type ℓ) → Group ℓ coHomGr n A = coHom n A , coHomGrnA where coHomGrnA : GroupStr (coHom n A) 1g coHomGrnA = 0ₕ n GroupStr._·_ coHomGrnA = λ x y → x +[ n ]ₕ y inv coHomGrnA = λ x → -[ n ]ₕ x isGroup coHomGrnA = helper where abstract helper : IsGroup {G = coHom n A} (0ₕ n) (λ x y → x +[ n ]ₕ y) (λ x → -[ n ]ₕ x) helper = makeIsGroup § (assocₕ n) (rUnitₕ n) (lUnitₕ n) (rCancelₕ n) (lCancelₕ n) ×coHomGr : (n : ℕ) (A : Type ℓ) (B : Type ℓ') → Group _ ×coHomGr n A B = DirProd (coHomGr n A) (coHomGr n B) coHomGroup : (n : ℕ) (A : Type ℓ) → AbGroup ℓ fst (coHomGroup n A) = coHom n A AbGroupStr.0g (snd (coHomGroup n A)) = 0ₕ n AbGroupStr._+_ (snd (coHomGroup n A)) = _+ₕ_ {n = n} AbGroupStr.- snd (coHomGroup n A) = -ₕ_ {n = n} IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (coHomGroup n A))) = isGroup (snd (coHomGr n A)) IsAbGroup.comm (AbGroupStr.isAbGroup (snd (coHomGroup n A))) = commₕ n -- Reduced cohomology group (direct def) coHomRedGroupDir : (n : ℕ) (A : Pointed ℓ) → AbGroup ℓ fst (coHomRedGroupDir n A) = coHomRed n A AbGroupStr.0g (snd (coHomRedGroupDir n A)) = 0ₕ∙ n AbGroupStr._+_ (snd (coHomRedGroupDir n A)) = _+ₕ∙_ {n = n} AbGroupStr.- snd (coHomRedGroupDir n A) = -ₕ∙_ {n = n} IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (coHomRedGroupDir n A))) = helper where abstract helper : IsGroup {G = coHomRed n A} (0ₕ∙ n) (_+ₕ∙_ {n = n}) (-ₕ∙_ {n = n}) helper = makeIsGroup § (assocₕ∙ n) (rUnitₕ∙ n) (lUnitₕ∙ n) (rCancelₕ∙ n) (lCancelₕ∙ n) IsAbGroup.comm (AbGroupStr.isAbGroup (snd (coHomRedGroupDir n A))) = commₕ∙ n coHomRedGrDir : (n : ℕ) (A : Pointed ℓ) → Group ℓ coHomRedGrDir n A = AbGroup→Group (coHomRedGroupDir n A) -- Induced map coHomFun : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) (f : A → B) → coHom n B → coHom n A coHomFun n f = sRec § λ β → ∣ β ∘ f ∣₂ coHomMorph : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) (f : A → B) → GroupHom (coHomGr n B) (coHomGr n A) fst (coHomMorph n f) = coHomFun n f snd (coHomMorph n f) = makeIsGroupHom (helper n) where helper : ℕ → _ helper zero = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl helper (suc zero) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl helper (suc (suc n)) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl coHomIso : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) → Iso A B → GroupIso (coHomGr n B) (coHomGr n A) fun (fst (coHomIso n is)) = fst (coHomMorph n (fun is)) inv' (fst (coHomIso n is)) = fst (coHomMorph n (inv' is)) rightInv (fst (coHomIso n is)) = sElim (λ _ → isSetPathImplicit) λ f → cong ∣_∣₂ (funExt λ x → cong f (leftInv is x)) leftInv (fst (coHomIso n is)) = sElim (λ _ → isSetPathImplicit) λ f → cong ∣_∣₂ (funExt λ x → cong f (rightInv is x)) snd (coHomIso n is) = snd (coHomMorph n (fun is)) -- Alternative definition of cohomology using ΩKₙ instead. Useful for breaking proofs of group isos -- up into smaller parts coHomGrΩ : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → Group ℓ coHomGrΩ n A = ∥ (A → typ (Ω (coHomK-ptd (suc n)))) ∥₂ , coHomGrnA where coHomGrnA : GroupStr ∥ (A → typ (Ω (coHomK-ptd (suc n)))) ∥₂ 1g coHomGrnA = ∣ (λ _ → refl) ∣₂ GroupStr._·_ coHomGrnA = sRec2 § λ p q → ∣ (λ x → p x ∙ q x) ∣₂ inv coHomGrnA = map λ f x → sym (f x) isGroup coHomGrnA = helper where abstract helper : IsGroup {G = ∥ (A → typ (Ω (coHomK-ptd (suc n)))) ∥₂} (∣ (λ _ → refl) ∣₂) (sRec2 § λ p q → ∣ (λ x → p x ∙ q x) ∣₂) (map λ f x → sym (f x)) helper = makeIsGroup § (elim3 (λ _ _ _ → isOfHLevelPath 2 § _ _) (λ p q r → cong ∣_∣₂ (funExt λ x → assoc∙ (p x) (q x) (r x)))) (sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → sym (rUnit (p x)))) (sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → sym (lUnit (p x)))) (sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → rCancel (p x))) (sElim (λ _ → isOfHLevelPath 2 § _ _) λ p → cong ∣_∣₂ (funExt λ x → lCancel (p x))) --- the loopspace of Kₙ is commutative regardless of base addIso : (n : ℕ) (x : coHomK n) → Iso (coHomK n) (coHomK n) fun (addIso n x) y = y +[ n ]ₖ x inv' (addIso n x) y = y -[ n ]ₖ x rightInv (addIso n x) y = -+cancelₖ n y x leftInv (addIso n x) y = -cancelRₖ n x y baseChange : (n : ℕ) (x : coHomK (suc n)) → (0ₖ (suc n) ≡ 0ₖ (suc n)) ≃ (x ≡ x) baseChange n x = isoToEquiv is where f : (n : ℕ) (x : coHomK (suc n)) → (0ₖ (suc n) ≡ 0ₖ (suc n)) → (x ≡ x) f n x p = sym (rUnitₖ _ x) ∙∙ cong (x +ₖ_) p ∙∙ rUnitₖ _ x g : (n : ℕ) (x : coHomK (suc n)) → (x ≡ x) → (0ₖ (suc n) ≡ 0ₖ (suc n)) g n x p = sym (rCancelₖ _ x) ∙∙ cong (λ y → y -ₖ x) p ∙∙ rCancelₖ _ x f-g : (n : ℕ) (x : coHomK (suc n)) (p : x ≡ x) → f n x (g n x p) ≡ p f-g n = trElim (λ _ → isOfHLevelΠ (3 + n) λ _ → isOfHLevelPath (3 + n) (isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) _ _) (ind n) where ind : (n : ℕ) (a : S₊ (suc n)) (p : ∣ a ∣ₕ ≡ ∣ a ∣ₕ) → f n ∣ a ∣ₕ (g n ∣ a ∣ₕ p) ≡ p ind zero = toPropElim (λ _ → isPropΠ λ _ → isOfHLevelTrunc 3 _ _ _ _) λ p → cong (f zero (0ₖ 1)) (sym (rUnit _) ∙ (λ k i → rUnitₖ _ (p i) k)) ∙∙ sym (rUnit _) ∙∙ λ k i → lUnitₖ _ (p i) k ind (suc n) = sphereElim (suc n) (λ _ → isOfHLevelΠ (2 + n) λ _ → isOfHLevelTrunc (4 + n) _ _ _ _) λ p → cong (f (suc n) (0ₖ (2 + n))) ((λ k → (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k ∙∙ (λ i → p i +ₖ 0ₖ (2 + n)) ∙∙ (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k) ∙ (λ k → rUnit (λ i → rUnitₖ _ (p i) k) (~ k))) ∙ λ k → rUnit (λ i → lUnitₖ _ (p i) k) (~ k) g-f : (n : ℕ) (x : coHomK (suc n)) (p : 0ₖ _ ≡ 0ₖ _) → g n x (f n x p) ≡ p g-f n = trElim (λ _ → isOfHLevelΠ (3 + n) λ _ → isOfHLevelPath (3 + n) (isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) _ _) (ind n) where ind : (n : ℕ) (a : S₊ (suc n)) (p : 0ₖ (suc n) ≡ 0ₖ (suc n)) → g n ∣ a ∣ₕ (f n ∣ a ∣ₕ p) ≡ p ind zero = toPropElim (λ _ → isPropΠ λ _ → isOfHLevelTrunc 3 _ _ _ _) λ p → cong (g zero (0ₖ 1)) (λ k → rUnit (λ i → lUnitₖ _ (p i) k) (~ k)) ∙ (λ k → rUnit (λ i → rUnitₖ _ (p i) k) (~ k)) ind (suc n) = sphereElim (suc n) (λ _ → isOfHLevelΠ (2 + n) λ _ → isOfHLevelTrunc (4 + n) _ _ _ _) λ p → cong (g (suc n) (0ₖ (2 + n))) (λ k → rUnit (λ i → lUnitₖ _ (p i) k) (~ k)) ∙∙ (λ k → (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k ∙∙ (λ i → p i +ₖ 0ₖ (2 + n)) ∙∙ (sym (rUnit (refl ∙ refl)) ∙ sym (rUnit refl)) k) ∙∙ λ k → rUnit (λ i → rUnitₖ _ (p i) k) (~ k) is : Iso _ _ fun is = f n x inv' is = g n x rightInv is = f-g n x leftInv is = g-f n x isCommΩK-based : (n : ℕ) (x : coHomK n) → isComm∙ (coHomK n , x) isCommΩK-based zero x p q = isSetℤ _ _ (p ∙ q) (q ∙ p) isCommΩK-based (suc zero) x = subst isComm∙ (λ i → coHomK 1 , lUnitₖ 1 x i) (ptdIso→comm {A = (_ , 0ₖ 1)} (addIso 1 x) (isCommΩK 1)) isCommΩK-based (suc (suc n)) x = subst isComm∙ (λ i → coHomK (suc (suc n)) , lUnitₖ (suc (suc n)) x i) (ptdIso→comm {A = (_ , 0ₖ (suc (suc n)))} (addIso (suc (suc n)) x) (isCommΩK (suc (suc n)))) -- hidden versions of cohom stuff using the "lock" hack. The locked versions can be used when proving things. -- Swapping "key" for "tt*" will then give computing functions. Unit' : Type₀ Unit' = lockUnit {ℓ-zero} lock : ∀ {ℓ} {A : Type ℓ} → Unit' → A → A lock unlock = λ x → x module lockedCohom (key : Unit') where +K : (n : ℕ) → coHomK n → coHomK n → coHomK n +K n = lock key (_+ₖ_ {n = n}) -K : (n : ℕ) → coHomK n → coHomK n -K n = lock key (-ₖ_ {n = n}) -Kbin : (n : ℕ) → coHomK n → coHomK n → coHomK n -Kbin n x y = +K n x (-K n y) rUnitK : (n : ℕ) (x : coHomK n) → +K n x (0ₖ n) ≡ x rUnitK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (0ₖ n) ≡ x pm unlock = rUnitₖ n x lUnitK : (n : ℕ) (x : coHomK n) → +K n (0ₖ n) x ≡ x lUnitK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (0ₖ n) x ≡ x pm unlock = lUnitₖ n x rCancelK : (n : ℕ) (x : coHomK n) → +K n x (-K n x) ≡ 0ₖ n rCancelK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (lock t (-ₖ_ {n = n}) x) ≡ 0ₖ n pm unlock = rCancelₖ n x lCancelK : (n : ℕ) (x : coHomK n) → +K n (-K n x) x ≡ 0ₖ n lCancelK n x = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (-ₖ_ {n = n}) x) x ≡ 0ₖ n pm unlock = lCancelₖ n x -cancelRK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n y x) x ≡ y -cancelRK n x y = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) y x) (lock t (-ₖ_ {n = n}) x) ≡ y pm unlock = -cancelRₖ n x y -cancelLK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n x y) x ≡ y -cancelLK n x y = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) (lock t (-ₖ_ {n = n}) x) ≡ y pm unlock = -cancelLₖ n x y -+cancelK : (n : ℕ) (x y : coHomK n) → +K n (-Kbin n x y) y ≡ x -+cancelK n x y = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x (lock t (-ₖ_ {n = n}) y)) y ≡ x pm unlock = -+cancelₖ n x y assocK : (n : ℕ) (x y z : coHomK n) → +K n x (+K n y z) ≡ +K n (+K n x y) z assocK n x y z = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (lock t (_+ₖ_ {n = n}) y z) ≡ lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) z pm unlock = assocₖ n x y z commK : (n : ℕ) (x y : coHomK n) → +K n x y ≡ +K n y x commK n x y = pm key where pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x y ≡ lock t (_+ₖ_ {n = n}) y x pm unlock = commₖ n x y -- cohom +H : (n : ℕ) (x y : coHom n A) → coHom n A +H n = sRec2 § λ a b → ∣ (λ x → +K n (a x) (b x)) ∣₂ -H : (n : ℕ) (x : coHom n A) → coHom n A -H n = sRec § λ a → ∣ (λ x → -K n (a x)) ∣₂ -Hbin : (n : ℕ) → coHom n A → coHom n A → coHom n A -Hbin n = sRec2 § λ a b → ∣ (λ x → -Kbin n (a x) (b x)) ∣₂ rUnitH : (n : ℕ) (x : coHom n A) → +H n x (0ₕ n) ≡ x rUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rUnitK n (a x)) i ∣₂ lUnitH : (n : ℕ) (x : coHom n A) → +H n (0ₕ n) x ≡ x lUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lUnitK n (a x)) i ∣₂ rCancelH : (n : ℕ) (x : coHom n A) → +H n x (-H n x) ≡ 0ₕ n rCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → rCancelK n (a x)) i ∣₂ lCancelH : (n : ℕ) (x : coHom n A) → +H n (-H n x) x ≡ 0ₕ n lCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _)) λ a i → ∣ funExt (λ x → lCancelK n (a x)) i ∣₂ assocH : (n : ℕ) (x y z : coHom n A) → (+H n x (+H n y z)) ≡ (+H n (+H n x y) z) assocH n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b c i → ∣ funExt (λ x → assocK n (a x) (b x) (c x)) i ∣₂ commH : (n : ℕ) (x y : coHom n A) → (+H n x y) ≡ (+H n y x) commH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ funExt (λ x → commK n (a x) (b x)) i ∣₂ -cancelRH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n y x) x ≡ y -cancelRH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelRK n (a x) (b x) i) ∣₂ -cancelLH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n x y) x ≡ y -cancelLH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -cancelLK n (a x) (b x) i) ∣₂ -+cancelH : (n : ℕ) (x y : coHom n A) → +H n (-Hbin n x y) y ≡ x -+cancelH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _)) λ a b i → ∣ (λ x → -+cancelK n (a x) (b x) i) ∣₂ lUnitK≡rUnitK : (key : Unit') (n : ℕ) → lockedCohom.lUnitK key n (0ₖ n) ≡ lockedCohom.rUnitK key n (0ₖ n) lUnitK≡rUnitK unlock = lUnitₖ≡rUnitₖ open GroupStr renaming (_·_ to _+gr_) open IsGroupHom -- inducedCoHom : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ} -- → GroupIso (coHomGr n A) G -- → Group -- inducedCoHom {A = A} {G = G} {n = n} e = -- InducedGroup (coHomGr n A) -- (coHom n A , λ x y → Iso.inv (isom e) (_+gr_ (snd G) (fun (isom e) x) -- (fun (isom e) y))) -- (idEquiv _) -- λ x y → sym (leftInv (isom e) _) -- ∙ cong (Iso.inv (isom e)) (isHom e x y) -- induced+ : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ} -- → (e : GroupIso (coHomGr n A) G) -- → fst (inducedCoHom e) → fst (inducedCoHom e) → fst (inducedCoHom e) -- induced+ e = _+gr_ (snd (inducedCoHom e)) -- inducedCoHomIso : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ} -- → (e : GroupIso (coHomGr n A) G) -- → GroupIso (coHomGr n A) (inducedCoHom e) -- isom (inducedCoHomIso e) = idIso -- isHom (inducedCoHomIso e) x y = sym (leftInv (isom e) _) -- ∙ cong (Iso.inv (isom e)) (isHom e x y) -- inducedCoHomPath : ∀ {ℓ ℓ'} {A : Type ℓ} {G : Group {ℓ'}} {n : ℕ} -- → (e : GroupIso (coHomGr n A) G) -- → coHomGr n A ≡ inducedCoHom e -- inducedCoHomPath e = InducedGroupPath _ _ _ _
44.656284
138
0.478196
2130015862777b2b99dff9cefeaec86649927c42
1,176
agda
Agda
Cats/Category/Lift.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
24
2017-11-03T15:18:57.000Z
2021-08-06T05:00:46.000Z
Cats/Category/Lift.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
null
null
null
Cats/Category/Lift.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
1
2019-03-18T15:35:07.000Z
2019-03-18T15:35:07.000Z
{-# OPTIONS --without-K --safe #-} module Cats.Category.Lift where open import Relation.Binary using (IsEquivalence) open import Level as L using (Level ; suc ; _⊔_ ; lift ; lower) open import Cats.Category.Base open IsEquivalence LCategory : (l : Level) → Set (suc l) LCategory l = Category l l l Lift : ∀ {lo la l≈ lo′ la′ l≈′} → Category lo la l≈ → Category (lo ⊔ lo′) (la ⊔ la′) (l≈ ⊔ l≈′) Lift {lo′ = lo′} {la′} {l≈′} C = record { Obj = L.Lift lo′ C.Obj ; _⇒_ = λ A B → L.Lift la′ (lower A C.⇒ lower B) ; _≈_ = λ f g → L.Lift l≈′ (lower f C.≈ lower g) ; id = lift C.id ; _∘_ = λ f g → lift (lower f C.∘ lower g) ; equiv = record { refl = lift (refl C.equiv) ; sym = λ eq → lift (sym C.equiv (lower eq)) ; trans = λ eq₁ eq₂ → lift (trans C.equiv (lower eq₁) (lower eq₂)) } ; ∘-resp = λ eq₁ eq₂ → lift (C.∘-resp (lower eq₁) (lower eq₂)) ; id-r = lift C.id-r ; id-l = lift C.id-l ; assoc = lift C.assoc } where module C = Category C LiftEq : ∀ {lo la l≈} → Category lo la l≈ → LCategory (lo ⊔ la ⊔ l≈) LiftEq {lo} {la} {l≈} = Lift {lo′ = la ⊔ l≈} {la′ = lo ⊔ l≈} {l≈′ = lo ⊔ la}
28.682927
76
0.538265
8bd7414c0651da15b1d19bb547b300538ef5af02
7,838
agda
Agda
core/lib/types/NatColim.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/NatColim.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/NatColim.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NConnected open import lib.NType2 open import lib.cubical.Square open import lib.types.Lift open import lib.types.Nat open import lib.types.Sigma open import lib.types.TLevel open import lib.types.Truncation open import lib.types.Unit {- Sequential colimits -} module lib.types.NatColim where module _ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) where postulate -- HIT ℕColim : Type i ncin' : (n : ℕ) → D n → ℕColim ncglue' : (n : ℕ) → (x : D n) → ncin' n x == ncin' (S n) (d n x) module _ {i} {D : ℕ → Type i} {d : (n : ℕ) → D n → D (S n)} where ncin = ncin' d ncglue = ncglue' d module _ {i} {D : ℕ → Ptd i} where ⊙ℕColim : (d : (n : ℕ) → (D n ⊙→ D (S n))) → Ptd i ⊙ℕColim d = ⊙[ ℕColim (fst ∘ d) , ncin 0 (pt (D 0)) ] module _ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) where module ℕColimElim {j} {P : ℕColim d → Type j} (ncin* : (n : ℕ) (x : D n) → P (ncin n x)) (ncglue* : (n : ℕ) (x : D n) → ncin* n x == ncin* (S n) (d n x) [ P ↓ ncglue n x ]) where postulate -- HIT f : Π (ℕColim d) P ncin-β : ∀ n x → f (ncin n x) ↦ ncin* n x {-# REWRITE ncin-β #-} postulate -- HIT ncglue-β : (n : ℕ) (x : D n) → apd f (ncglue n x) == ncglue* n x open ℕColimElim public using () renaming (f to ℕColim-elim) module ℕColimRec {j} {A : Type j} (ncin* : (n : ℕ) → D n → A) (ncglue* : (n : ℕ) → (x : D n) → ncin* n x == ncin* (S n) (d n x)) where private module M = ℕColimElim ncin* (λ n x → ↓-cst-in (ncglue* n x)) f : ℕColim d → A f = M.f ncglue-β : (n : ℕ) (x : D n) → ap f (ncglue n x) == ncglue* n x ncglue-β n x = apd=cst-in {f = f} (M.ncglue-β n x) {- Raising and lifting -} module _ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) where {- Can define a function [nc-raise d : ℕColim d → ℕColim d] so that [inn (S n) ∘ d = nc-raise d ∘ inn n] -} module ℕCRaise = ℕColimRec d {A = ℕColim d} (λ n x → ncin (S n) (d n x)) (λ n x → ncglue (S n) (d n x)) nc-raise : ℕColim d → ℕColim d nc-raise = ℕCRaise.f nc-raise-= : (c : ℕColim d) → c == nc-raise c nc-raise-= = ℕColimElim.f d (λ n x → ncglue n x) (λ n x → ↓-='-from-square $ ap-idf (ncglue n x) ∙v⊡ (connection2 ⊡v∙ (! (ℕCRaise.ncglue-β n x)))) {- Lift an element of D₀ to any level -} nc-lift : (n : ℕ) → D O → D n nc-lift O x = x nc-lift (S n) x = d n (nc-lift n x) nc-lift-= : (n : ℕ) (x : D O) → ncin' d O x == ncin n (nc-lift n x) nc-lift-= O x = idp nc-lift-= (S n) x = nc-lift-= n x ∙ ncglue n (nc-lift n x) {- Lift an element of D₀ to the 'same level' as some element of ℕColim d -} module ℕCMatch (x : D O) = ℕColimRec d {A = ℕColim d} (λ n _ → ncin n (nc-lift n x)) (λ n _ → ncglue n (nc-lift n x)) nc-match = ℕCMatch.f nc-match-=-base : (x : D O) (c : ℕColim d) → ncin O x == nc-match x c nc-match-=-base x = ℕColimElim.f d (λ n _ → nc-lift-= n x) (λ n y → ↓-cst=app-from-square $ disc-to-square idp ⊡v∙ ! (ℕCMatch.ncglue-β x n y)) {- If all Dₙ are m-connected, then the colim is m-connected -} ncolim-conn : ∀ {i} {D : ℕ → Type i} (d : (n : ℕ) → D n → D (S n)) (m : ℕ₋₂) → ((n : ℕ) → is-connected m (D n)) → is-connected m (ℕColim d) ncolim-conn {D = D} d ⟨-2⟩ cD = -2-conn (ℕColim d) ncolim-conn {D = D} d (S m) cD = Trunc-rec (prop-has-level-S is-contr-is-prop) (λ x → ([ ncin O x ] , (Trunc-elim (λ _ → =-preserves-level Trunc-level) $ λ c → ap [_] (nc-match-=-base d x c) ∙ nc-match-=-point x c))) (fst (cD O)) where nc-match-=-point : (x : D O) (c : ℕColim d) → [_] {n = S m} (nc-match d x c) == [ c ] nc-match-=-point x = ℕColimElim.f d (λ n y → ap (Trunc-fmap (ncin n)) (contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ])) (λ n y → ↓-='-from-square $ (ap-∘ [_] (nc-match d x) (ncglue n y) ∙ ap (ap [_]) (ℕCMatch.ncglue-β d x n y)) ∙v⊡ ! (ap-idf _) ∙h⊡ square-symmetry (natural-square (Trunc-elim (λ _ → =-preserves-level Trunc-level) (λ c → ap [_] (nc-raise-= d c))) (ap (Trunc-fmap (ncin n)) (contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ]))) ⊡h∙ ∘-ap (Trunc-fmap (nc-raise d)) (Trunc-fmap (ncin n)) (contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ]) ⊡h∙ vert-degen-path (natural-square (λ t → Trunc-fmap-∘ (nc-raise d) (ncin n) t ∙ ! (Trunc-fmap-∘ (ncin (S n)) (d n) t)) (contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ])) ⊡h∙ ap-∘ (Trunc-fmap (ncin (S n))) (Trunc-fmap (d n)) (contr-has-all-paths (cD n) [ nc-lift d n x ] [ y ]) ⊡h∙ ap (ap (Trunc-fmap (ncin (S n)))) (contr-has-all-paths (=-preserves-level (cD (S n))) _ _)) {- Type of finite tuples -} ⊙FinTuplesType : ∀ {i} → (ℕ → Ptd i) → ℕ → Ptd i ⊙FinTuplesType F O = ⊙Lift ⊙Unit ⊙FinTuplesType F (S n) = F O ⊙× ⊙FinTuplesType (F ∘ S) n FinTuplesType : ∀ {i} → (ℕ → Ptd i) → ℕ → Type i FinTuplesType F n = de⊙ (⊙FinTuplesType F n) fin-tuples-map : ∀ {i} (F : ℕ → Ptd i) (n : ℕ) → (⊙FinTuplesType F n ⊙→ ⊙FinTuplesType F (S n)) fin-tuples-map F O = (_ , idp) fin-tuples-map F (S n) = ((λ {(x , r) → (x , fst (fin-tuples-map (F ∘ S) n) r)}) , pair×= idp (snd (fin-tuples-map (F ∘ S) n))) ⊙FinTuples : ∀ {i} → (ℕ → Ptd i) → Ptd i ⊙FinTuples {i} F = ⊙ℕColim (fin-tuples-map F) FinTuples : ∀ {i} → (ℕ → Ptd i) → Type i FinTuples = de⊙ ∘ ⊙FinTuples fin-tuples-cons : ∀ {i} (F : ℕ → Ptd i) → de⊙ (F O) × FinTuples (F ∘ S) ≃ FinTuples F fin-tuples-cons {i} F = equiv into out into-out out-into where module Into (x : de⊙ (F O)) = ℕColimRec (fst ∘ fin-tuples-map (F ∘ S)) {A = FinTuples F} (λ n r → ncin (S n) (x , r)) (λ n r → ncglue (S n) (x , r)) into = uncurry Into.f out-ncin : (n : ℕ) → FinTuplesType F n → de⊙ (F O) × FinTuples (F ∘ S) out-ncin O x = (pt (F O) , ncin O _) out-ncin (S n) (x , r) = (x , ncin n r) out-ncglue : (n : ℕ) (r : FinTuplesType F n) → out-ncin n r == out-ncin (S n) (fst (fin-tuples-map F n) r) out-ncglue O x = idp out-ncglue (S n) (x , r) = pair= idp (ncglue n r) module Out = ℕColimRec _ out-ncin out-ncglue out = Out.f abstract into-out-ncin : (n : ℕ) (r : FinTuplesType F n) → into (out-ncin n r) == ncin n r into-out-ncin O x = ! (ncglue O x) into-out-ncin (S n) (x , r) = idp into-out-ncglue : (n : ℕ) (r : FinTuplesType F n) → into-out-ncin n r == into-out-ncin (S n) (fst (fin-tuples-map F n) r) [ (λ s → into (out s) == s) ↓ ncglue n r ] into-out-ncglue O x = ↓-∘=idf-from-square into out $ ap (ap into) (Out.ncglue-β O x) ∙v⊡ bl-square (ncglue O x) into-out-ncglue (S n) (x , r) = ↓-∘=idf-from-square into out $ (ap (ap into) (Out.ncglue-β (S n) (x , r)) ∙ ∘-ap into (_,_ x) (ncglue n r) ∙ Into.ncglue-β x n r) ∙v⊡ vid-square into-out : (r : FinTuples F) → into (out r) == r into-out = ℕColimElim.f _ into-out-ncin into-out-ncglue out-into : (t : de⊙ (F O) × FinTuples (F ∘ S)) → out (into t) == t out-into = uncurry $ λ x → ℕColimElim.f _ (λ n r → idp) (λ n r → ↓-='-from-square $ (ap-∘ out (Into.f x) (ncglue n r) ∙ ap (ap out) (Into.ncglue-β x n r) ∙ Out.ncglue-β (S n) (x , r)) ∙v⊡ vid-square) ⊙fin-tuples-cons : ∀ {i} (F : ℕ → Ptd i) → (F O ⊙× ⊙FinTuples (F ∘ S)) ⊙≃ ⊙FinTuples F ⊙fin-tuples-cons F = ≃-to-⊙≃ (fin-tuples-cons F) (! (ncglue O _))
32.658333
79
0.501786
353e16250d8eaff4fca3f4706cb838ec4b0be58f
1,915
agda
Agda
test/Succeed/RecordUpdateSyntax.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2021-06-14T11:08:59.000Z
2021-06-14T11:08:59.000Z
test/Succeed/RecordUpdateSyntax.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2020-05-29T19:45:38.000Z
2020-05-29T19:45:38.000Z
test/Succeed/RecordUpdateSyntax.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2021-06-14T11:07:38.000Z
2021-06-14T11:07:38.000Z
module RecordUpdateSyntax where open import Common.Prelude open import Common.Equality data Param : Nat → Set where param : ∀ n → Param (suc n) record R : Set where field {i} : Nat p : Param i s : Nat old : R old = record { p = param 0; s = 1 } -- Simple update, it should be able to infer the type and the implicit. new : _ new = record old { p = param 1 } new′ : R new′ = record { i = 2; p = param 1; s = 1 } -- Here's a needlessly complex update. upd-p-s : Nat → _ → _ → R upd-p-s zero s r = record r { p = param zero; s = s } upd-p-s (suc n) s r = record (upd-p-s n 0 r) { p = param n; s = s } eq₁ : new ≡ new′ eq₁ = refl eq₂ : upd-p-s zero 1 (record new { s = 0 }) ≡ old eq₂ = refl -- Check that instance arguments are handled properly postulate T : Nat → Set instance t0 : T 0 t1 : T 1 record Instance : Set where field n : Nat {{t}} : T n r0 : Instance r0 = record { n = 0 } r1 : Instance r1 = record r0 { n = 1 } check : Instance.t r1 ≡ t1 check = refl -- Andreas, 2020-03-27, issue #3684 -- warn only if there are invalid or duplicate fields _ = record old { invalidField = 1 } _ = record old { s = 1; s = 0 } _ = record old { foo = 1; bar = 0; s = 1; s = 0 } -- The record type R does not have the field invalidField but it would -- have the fields i, p, s -- when checking that the expression record old { invalidField = 1 } -- has type R -- Duplicate field s in record -- when checking that the expression record old { s = 1 ; s = 0 } has -- type R -- /Users/abel/agda-erasure/test/Succeed/RecordUpdateSyntax.agda:59,5-50 -- The record type R does not have the fields foo, bar but it would -- have the fields i, p -- when checking that the expression -- record old { foo = 1 ; bar = 0 ; s = 1 ; s = 0 } has type R -- Duplicate field s in record -- when checking that the expression -- record old { foo = 1 ; bar = 0 ; s = 1 ; s = 0 } has type R
23.353659
72
0.622454
19cb581494bdcb594c7b4d11afe0ad2ae69b6342
2,773
agda
Agda
src/LibraBFT/Impl/Consensus/ConsensusTypes/QuorumCert.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/Consensus/ConsensusTypes/QuorumCert.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/Consensus/ConsensusTypes/QuorumCert.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types import LibraBFT.Impl.Consensus.ConsensusTypes.VoteData as VoteData open import LibraBFT.Impl.OBM.Logging.Logging import LibraBFT.Impl.Types.LedgerInfoWithSignatures as LedgerInfoWithSignatures open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.Hash import Util.KVMap as Map open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.Consensus.ConsensusTypes.QuorumCert where certificateForGenesisFromLedgerInfo : LedgerInfo → HashValue → QuorumCert certificateForGenesisFromLedgerInfo ledgerInfo genesisId = let ancestor = BlockInfo∙new (ledgerInfo ^∙ liEpoch + 1) 0 genesisId (ledgerInfo ^∙ liTransactionAccumulatorHash) (ledgerInfo ^∙ liVersion) --(ledgerInfo ^∙ liTimestamp) nothing voteData = VoteData.new ancestor ancestor li = LedgerInfo∙new ancestor (hashVD voteData) in QuorumCert∙new voteData (LedgerInfoWithSignatures∙new li Map.empty) verify : QuorumCert → ValidatorVerifier → Either ErrLog Unit verify self validator = do let voteHash = hashVD (self ^∙ qcVoteData) lcheck (self ^∙ qcSignedLedgerInfo ∙ liwsLedgerInfo ∙ liConsensusDataHash == voteHash) (here' ("Quorum Cert's hash mismatch LedgerInfo" ∷ [])) if (self ^∙ qcCertifiedBlock ∙ biRound == 0) -- TODO-?: It would be nice not to require the parens around the do block then (do lcheck (self ^∙ qcParentBlock == self ^∙ qcCertifiedBlock) (here' ("Genesis QC has inconsistent parent block with certified block" ∷ [])) lcheck (self ^∙ qcCertifiedBlock == self ^∙ qcLedgerInfo ∙ liwsLedgerInfo ∙ liCommitInfo) (here' ("Genesis QC has inconsistent commit block with certified block" ∷ [])) lcheck (Map.kvm-size (self ^∙ qcLedgerInfo ∙ liwsSignatures) == 0) (here' ("Genesis QC should not carry signatures" ∷ [])) ) else do withErrCtx' ("fail to verify QuorumCert" ∷ []) (LedgerInfoWithSignatures.verifySignatures (self ^∙ qcLedgerInfo) validator) VoteData.verify (self ^∙ qcVoteData) where here' : List String → List String here' t = "QuorumCert" ∷ "verify" {- ∷ lsQC self-} ∷ t
45.459016
111
0.652362
21ca2d356cd0c788b719c61efe9cb9914bcc882d
284
agda
Agda
test/Succeed/Issue3666.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue3666.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue3666.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
data Unit : Set where unit : Unit F : Unit → Set₁ F unit = Set data D (u : Unit) (f : F u) : Set where variable u : Unit f : F u d : D u f postulate P : {u : Unit} {f : F u} → D u f → Set p : P d p' : (u : Unit) (f : F u) (d : D u f) → P d p' u f d = p {u} {f} {d}
13.52381
43
0.464789
30a8dc6b567d7d761798c2a260f945deb524e2e1
2,131
agda
Agda
src/Implicits/Resolution/GenericFinite/Expressiveness.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
4
2019-04-05T17:57:11.000Z
2021-05-07T04:08:41.000Z
src/Implicits/Resolution/GenericFinite/Expressiveness.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
src/Implicits/Resolution/GenericFinite/Expressiveness.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
open import Prelude module Implicits.Resolution.GenericFinite.Expressiveness where open import Coinduction open import Data.Fin.Substitution open import Implicits.Syntax open import Implicits.Substitutions open import Implicits.Resolution.Deterministic.Resolution as D open import Implicits.Resolution.Ambiguous.Resolution as A open import Implicits.Resolution.Finite.Resolution as F open import Implicits.Resolution.Infinite.Resolution as ∞ open import Implicits.Resolution.Termination open import Extensions.ListFirst module Finite⊆Infinite where p : ∀ {ν} {a} {Δ : ICtx ν} → Δ F.⊢ᵣ a → Δ ∞.⊢ᵣ a p (r-simp a a↓τ) = r-simp a (lem a↓τ) where lem : ∀ {ν} {a τ} {Δ : ICtx ν} → Δ F.⊢ a ↓ τ → Δ ∞.⊢ a ↓ τ lem (i-simp τ) = i-simp τ lem (i-iabs _ ⊢ᵣa b↓τ) = i-iabs (p ⊢ᵣa) (lem b↓τ) lem (i-tabs b a[/b]↓τ) = i-tabs b (lem a[/b]↓τ) p (r-iabs x) = r-iabs (p x) p (r-tabs x) = r-tabs (p x) module Finite⊆Ambiguous where p : ∀ {ν} {a} {Δ : ICtx ν} → Δ F.⊢ᵣ a → Δ A.⊢ᵣ a p (r-simp a a↓τ) = lem a↓τ (r-ivar a) where lem : ∀ {ν} {a τ} {Δ : ICtx ν} → Δ F.⊢ a ↓ τ → Δ A.⊢ᵣ a → Δ A.⊢ᵣ simpl τ lem (i-simp τ) K⊢ᵣτ = K⊢ᵣτ lem (i-iabs _ ⊢ᵣa b↓τ) K⊢ᵣa⇒b = lem b↓τ (r-iapp K⊢ᵣa⇒b (p ⊢ᵣa)) lem (i-tabs b a[/b]↓τ) K⊢ᵣ∀a = lem a[/b]↓τ (r-tapp b K⊢ᵣ∀a) p (r-iabs x) = r-iabs (p x) p (r-tabs x) = r-tabs (p x) module Deterministic⊆Finite where open FirstLemmas -- Oliveira's termination condition is part of the well-formdness of types -- So we assume here that ⊢term x holds for all types x p : ∀ {ν} {a : Type ν} {Δ : ICtx ν} → (∀ {ν} (a : Type ν) → ⊢term a) → Δ D.⊢ᵣ a → Δ F.⊢ᵣ a p term (r-simp {ρ = r} x r↓a) = r-simp (proj₁ $ first⟶∈ x) (lem r↓a) where lem : ∀ {ν} {Δ : ICtx ν} {a r} → Δ D.⊢ r ↓ a → Δ F.⊢ r ↓ a lem (i-simp a) = i-simp a lem (i-iabs {ρ₁ = ρ₁} {ρ₂ = ρ₂} ⊢ᵣρ₁ ρ₂↓τ) with term (ρ₁ ⇒ ρ₂) lem (i-iabs ⊢ᵣρ₁ ρ₂↓τ) | term-iabs _ _ a-ρ<-b _ = i-iabs a-ρ<-b (p term ⊢ᵣρ₁) (lem ρ₂↓τ) lem (i-tabs b x₁) = i-tabs b (lem x₁) p term (r-iabs ρ₁ {ρ₂ = ρ₂} x) = r-iabs (p term x) p term (r-tabs x) = r-tabs (p term x)
36.741379
94
0.584702
523f8c4d533408799ad349e7c226d9306daf144c
1,698
agda
Agda
src/Categories/Category/Restriction.agda
yourboynico/agda-categories
6a087c592dbe58fc4bd9d02e1be9b94a9e138aca
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Category/Restriction.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Category/Restriction.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} -- Defines Restriction Category -- https://ncatlab.org/nlab/show/restriction+category -- but see also -- https://github.com/jmchapman/restriction-categories -- Notation choice: one of the interpretations is that the -- restriction structure captures the "domain of definedness" -- of a morphism, as a (partial) identity. As this is positive -- information, we will use f ↓ (as a postfix operation) to -- denote this. Note that computability theory uses the same -- notation to mean definedness. -- Note, as we're working in Setoid-Enriched Categories, we need -- to add an explicit axiom, that ↓ preserves ≈ module Categories.Category.Restriction where open import Level using (Level; _⊔_) open import Categories.Category.Core using (Category) private variable o ℓ e : Level record Restriction (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where open Category C using (Obj; _⇒_; _∘_; _≈_; id) field _↓ : {A B : Obj} → A ⇒ B → A ⇒ A -- partial identity on the right pidʳ : {A B : Obj} {f : A ⇒ B} → f ∘ f ↓ ≈ f -- the domain-of-definition arrows commute ↓-comm : {A B C : Obj} {f : A ⇒ B} {g : A ⇒ C} → f ↓ ∘ g ↓ ≈ g ↓ ∘ f ↓ -- domain-of-definition denests (on the right) ↓-denestʳ : {A B C : Obj} {f : A ⇒ B} {g : A ⇒ C} → (g ∘ f ↓) ↓ ≈ g ↓ ∘ f ↓ -- domain-of-definition has a skew-commutative law ↓-skew-comm : {A B C : Obj} {g : A ⇒ B} {f : C ⇒ A} → g ↓ ∘ f ≈ f ∘ (g ∘ f) ↓ -- and the new axiom, ↓ is a congruence ↓-cong : {A B : Obj} {f g : A ⇒ B} → f ≈ g → f ↓ ≈ g ↓ -- it is convenient to define the total predicate in this context total : {A B : Obj} (f : A ⇒ B) → Set e total f = f ↓ ≈ id
36.913043
81
0.610718
c74634b9e4c714b01e42708e4cc5fe100a6ddb70
2,599
agda
Agda
test/succeed/EtaContractionDefBody.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
null
null
null
test/succeed/EtaContractionDefBody.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
null
null
null
test/succeed/EtaContractionDefBody.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
null
null
null
-- 2010-11-16 -- compactification of Data.Set.Decoration.gmapAll -- -- This test case fails if we remove instantiateFull -- (and with it eta-contraction) from definition bodies in Def.hs -- see Issue 361 -- {-# OPTIONS -v tc.lhs.unify:25 #-} module EtaContractionDefBody where ------------------------------------------------------------------------ -- Binary relations -- Homogeneous binary relations Rel : Set → Set1 Rel A = A → A → Set -- Generalised implication. If P ≡ Q it can be read as "f preserves -- P". _=[_]⇒_ : {A B : Set} → Rel A → (A → B) → Rel B → Set P =[ f ]⇒ Q = ∀ {x y} → P x y → Q (f x) (f y) record Σ₂ {A B : Set} (T : A → B → Set) : Set where constructor pack₂ field {x} : A {y} : B proof : T x y -- Data.Star infixr 5 _◅_ -- Reflexive transitive closure. data Star {I : Set} (T : Rel I) : Rel I where ε : ∀ {i} → Star T i i _◅_ : ∀ {i j k} (x : T i j) (xs : Star T j k) → Star T i k -- The type of _◅_ is Trans T (Star T) (Star T); I expanded -- the definition in order to be able to name the arguments (x -- and xs). -- A generalised variant of map which allows the index type to change. gmap : ∀ {I} {T : Rel I} {J} {U : Rel J} → (f : I → J) → T =[ f ]⇒ U → Star T =[ f ]⇒ Star U gmap f g ε = ε gmap f g (x ◅ xs) = g x ◅ gmap f g xs -- Data.Star.Decoration EdgePred : ∀ {I} → Rel I → Set₁ EdgePred T = ∀ {i j} → T i j → Set -- Decorating an edge with more information. data DecoratedWith {I : Set} {T : Rel I} (P : EdgePred T) : Rel (Σ₂ (Star T)) where ↦ : ∀ {i j k} {x : T i j} {xs : Star T j k} (p : P x) → DecoratedWith P (pack₂ (x ◅ xs)) (pack₂ xs) -- Star-lists decorated with extra information. All P xs means that -- all edges in xs satisfy P. All : ∀ {I} {T : Rel I} → EdgePred T → EdgePred (Star T) All P {j = j} xs = Star (DecoratedWith P) (pack₂ xs) (pack₂ {y = j} ε) -- We can map over decorated vectors. gmapAll : ∀ {I} {T : Rel I} {P : EdgePred T} {J} {U : Rel J} {Q : EdgePred U} {i j} {xs : Star T i j} (f : I → J) (g : T =[ f ]⇒ U) → (∀ {i j} {x : T i j} → P x → Q (g x)) → All P xs → All {T = U} Q (gmap f g xs) gmapAll f g h ε = ε gmapAll f g h (↦ x ◅ xs) = ↦ (h x) ◅ gmapAll f g h xs {- THIS WOULD BE THE ERROR MESSAGE: /Users/abel/cover/alfa/Agda2/test/succeed/EtaContractionDefBody.agda:76,15-16 xs != ε of type Star (λ .i' .j → T .i' .j) j j when checking that the pattern ε has type Star (DecoratedWith (λ {.i} {.j} → P)) (pack₂ xs) (pack₂ ε) -}
28.56044
77
0.532128
1946d7ff8b2fb047c95dfb9294a950bfa520283d
18,158
agda
Agda
TotalRecognisers/LeftRecursion.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
7
2016-12-13T05:23:14.000Z
2021-06-22T05:35:31.000Z
TotalRecognisers/LeftRecursion.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
1
2018-01-22T22:21:41.000Z
2018-01-24T16:39:37.000Z
TotalRecognisers/LeftRecursion.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Total recognisers which can handle left recursion ------------------------------------------------------------------------ -- The recognisers are parametrised on the alphabet. module TotalRecognisers.LeftRecursion (Tok : Set) where open import Algebra open import Coinduction open import Data.Bool as Bool hiding (_∧_) import Data.Bool.Properties as Bool private module BoolCS = CommutativeSemiring Bool.commutativeSemiring-∧-∨ open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence as Eq using (_⇔_; equivalence; module Equivalence) renaming (_∘_ to _⟨∘⟩_) open import Data.List using (List; []; _∷_; _++_; [_]) import Data.List.Properties private module ListMonoid {A : Set} = Monoid (Data.List.Properties.++-monoid A) open import Data.Product as Prod open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary open import Relation.Nullary.Decidable as Decidable ------------------------------------------------------------------------ -- A "right-strict" variant of _∧_ -- If the left-strict variant of _∧_ were used to type _·_ below, then -- the inferred definition of D-nullable would not be total; it would -- contain expressions of the form "D-nullable t (♭ p₁) ∧ false". With -- the right-strict definition of _∧_ such expressions reduce to -- "false". infixr 6 _∧_ _∧_ : Bool → Bool → Bool b ∧ true = b b ∧ false = false -- A lemma. left-zero : ∀ b → false ∧ b ≡ false left-zero true = refl left-zero false = refl ------------------------------------------------------------------------ -- Recogniser combinators infixl 10 _·_ infixl 5 _∣_ mutual -- The index is true if the corresponding language contains the empty -- string (is nullable). data P : Bool → Set where fail : P false empty : P true sat : (Tok → Bool) → P false _∣_ : ∀ {n₁ n₂} → P n₁ → P n₂ → P (n₁ ∨ n₂) _·_ : ∀ {n₁ n₂} → ∞⟨ n₂ ⟩P n₁ → ∞⟨ n₁ ⟩P n₂ → P (n₁ ∧ n₂) nonempty : ∀ {n} → P n → P false cast : ∀ {n₁ n₂} → n₁ ≡ n₂ → P n₁ → P n₂ -- Delayed if the index is /false/. ∞⟨_⟩P : Bool → Bool → Set ∞⟨ false ⟩P n = ∞ (P n) ∞⟨ true ⟩P n = P n -- Note that fail, nonempty and cast could be defined as derived -- combinators. (For cast this is obvious, fail could be defined -- either using sat or the combinator leftRight below, and nonempty is -- defined in the module AlternativeNonempty. Note also that the proof -- in TotalRecognisers.LeftRecursion.ExpressiveStrength does not rely -- on these constructors.) However, Agda uses /guarded/ corecursion, -- so the fact that nonempty and cast are constructors can be very -- convenient when constructing other recognisers. -- For an example of the use of nonempty, see the Kleene star example -- in TotalRecognisers.LeftRecursion.Lib. For examples of the use of -- cast, see TotalRecognisers.LeftRecursion.ExpressiveStrength and -- TotalRecognisers.LeftRecursion.NotOnlyContextFree. ------------------------------------------------------------------------ -- Helpers ♭? : ∀ {b n} → ∞⟨ b ⟩P n → P n ♭? {b = false} x = ♭ x ♭? {b = true} x = x ♯? : ∀ {b n} → P n → ∞⟨ b ⟩P n ♯? {b = false} x = ♯ x ♯? {b = true} x = x forced? : ∀ {b n} → ∞⟨ b ⟩P n → Bool forced? {b = b} _ = b -- A lemma. ♭?♯? : ∀ b {n} {p : P n} → ♭? {b} (♯? p) ≡ p ♭?♯? false = refl ♭?♯? true = refl ------------------------------------------------------------------------ -- Semantics -- The semantics is defined inductively: s ∈ p iff the string s is -- contained in the language defined by p. infix 4 _∈_ data _∈_ : ∀ {n} → List Tok → P n → Set where empty : [] ∈ empty sat : ∀ {f t} → T (f t) → [ t ] ∈ sat f ∣-left : ∀ {s n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → s ∈ p₁ → s ∈ p₁ ∣ p₂ ∣-right : ∀ {s n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → s ∈ p₂ → s ∈ p₁ ∣ p₂ _·_ : ∀ {s₁ s₂ n₁ n₂} {p₁ : ∞⟨ n₂ ⟩P n₁} {p₂ : ∞⟨ n₁ ⟩P n₂} → s₁ ∈ ♭? p₁ → s₂ ∈ ♭? p₂ → s₁ ++ s₂ ∈ p₁ · p₂ nonempty : ∀ {n t s} {p : P n} → t ∷ s ∈ p → t ∷ s ∈ nonempty p cast : ∀ {n₁ n₂ s} {p : P n₁} {eq : n₁ ≡ n₂} → s ∈ p → s ∈ cast eq p infix 4 _≤_ _≈_ -- p₁ ≤ p₂ iff the language (defined by) p₂ contains all the strings -- in the language p₁. _≤_ : ∀ {n₁ n₂} → P n₁ → P n₂ → Set p₁ ≤ p₂ = ∀ {s} → s ∈ p₁ → s ∈ p₂ -- p₁ ≈ p₂ iff the languages p₁ and p₂ contain the same strings. _≈_ : ∀ {n₁ n₂} → P n₁ → P n₂ → Set p₁ ≈ p₂ = ∀ {s} → s ∈ p₁ ⇔ s ∈ p₂ -- p₁ ≈ p₂ iff both p₁ ≤ p₂ and p₂ ≤ p₁. ≈⇔≤≥ : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈ p₂ ⇔ (p₁ ≤ p₂ × p₂ ≤ p₁) ≈⇔≤≥ = equivalence (λ p₁≈p₂ → ((λ {s} → _⟨$⟩_ (Equivalence.to (p₁≈p₂ {s = s}))) , λ {s} → _⟨$⟩_ (Equivalence.from (p₁≈p₂ {s = s})))) (λ p₁≤≥p₂ {s} → equivalence (proj₁ p₁≤≥p₂ {s = s}) (proj₂ p₁≤≥p₂ {s = s})) -- Some lemmas. cast∈ : ∀ {n} {p p′ : P n} {s s′} → s ≡ s′ → p ≡ p′ → s ∈ p → s′ ∈ p′ cast∈ refl refl s∈ = s∈ drop-♭♯ : ∀ n {n′} {p : P n′} → ♭? (♯? {n} p) ≤ p drop-♭♯ n = cast∈ refl (♭?♯? n) add-♭♯ : ∀ n {n′} {p : P n′} → p ≤ ♭? (♯? {n} p) add-♭♯ n = cast∈ refl (sym $ ♭?♯? n) ------------------------------------------------------------------------ -- Example: A definition which is left and right recursive leftRight : P false leftRight = ♯ leftRight · ♯ leftRight -- Note that leftRight is equivalent to fail, so fail does not need to -- be a primitive combinator. leftRight≈fail : leftRight ≈ fail leftRight≈fail = equivalence ≤fail (λ ()) where ≤fail : ∀ {s A} → s ∈ leftRight → A ≤fail (∈₁ · ∈₂) = ≤fail ∈₁ -- For more examples, see TotalRecognisers.LeftRecursion.Lib. ------------------------------------------------------------------------ -- Nullability -- The nullability index is correct. ⇒ : ∀ {n} {p : P n} → [] ∈ p → n ≡ true ⇒ pr = ⇒′ pr refl where ⇒′ : ∀ {n s} {p : P n} → s ∈ p → s ≡ [] → n ≡ true ⇒′ empty refl = refl ⇒′ (sat _) () ⇒′ (∣-left pr₁) refl with ⇒ pr₁ ⇒′ (∣-left pr₁) refl | refl = refl ⇒′ (∣-right pr₂) refl with ⇒ pr₂ ⇒′ (∣-right {n₁ = n₁} pr₂) refl | refl = proj₂ BoolCS.zero n₁ ⇒′ (nonempty p) () ⇒′ (cast {eq = refl} p) refl = ⇒′ p refl ⇒′ (_·_ {[]} pr₁ pr₂) refl = cong₂ _∧_ (⇒ pr₁) (⇒ pr₂) ⇒′ (_·_ {_ ∷ _} pr₁ pr₂) () ⇐ : ∀ {n} (p : P n) → n ≡ true → [] ∈ p ⇐ fail () ⇐ empty refl = empty ⇐ (sat f) () ⇐ (_∣_ {true} p₁ p₂) refl = ∣-left (⇐ p₁ refl) ⇐ (_∣_ {false} {true} p₁ p₂) refl = ∣-right {p₁ = p₁} (⇐ p₂ refl) ⇐ (_∣_ {false} {false} p₁ p₂) () ⇐ (nonempty p) () ⇐ (cast refl p) refl = cast (⇐ p refl) ⇐ (_·_ {.true} {true} p₁ p₂) refl = ⇐ p₁ refl · ⇐ p₂ refl ⇐ (_·_ {_} {false} p₁ p₂) () index-correct : ∀ {n} {p : P n} → [] ∈ p ⇔ n ≡ true index-correct = equivalence ⇒ (⇐ _) -- We can decide if the empty string belongs to a given language. nullable? : ∀ {n} (p : P n) → Dec ([] ∈ p) nullable? {n} p = Decidable.map (Eq.sym index-correct) (Bool._≟_ n true) ------------------------------------------------------------------------ -- Derivative -- The index of the derivative. D-nullable : ∀ {n} → Tok → P n → Bool D-nullable t fail = false D-nullable t empty = false D-nullable t (sat f) = f t D-nullable t (p₁ ∣ p₂) = D-nullable t p₁ ∨ D-nullable t p₂ D-nullable t (nonempty p) = D-nullable t p D-nullable t (cast _ p) = D-nullable t p D-nullable t (p₁ · p₂) with forced? p₁ | forced? p₂ ... | true | false = D-nullable t p₁ ... | false | false = false ... | true | true = D-nullable t p₁ ∨ D-nullable t p₂ ... | false | true = D-nullable t p₂ -- D t p is the "derivative" of p with respect to t. It is specified -- by the equivalence s ∈ D t p ⇔ t ∷ s ∈ p (proved below). D : ∀ {n} (t : Tok) (p : P n) → P (D-nullable t p) D t fail = fail D t empty = fail D t (sat f) with f t ... | true = empty ... | false = fail D t (p₁ ∣ p₂) = D t p₁ ∣ D t p₂ D t (nonempty p) = D t p D t (cast _ p) = D t p D t (p₁ · p₂) with forced? p₁ | forced? p₂ ... | true | false = D t p₁ · ♯? (♭ p₂) ... | false | false = ♯ D t (♭ p₁) · ♯? (♭ p₂) ... | true | true = D t p₁ · ♯? p₂ ∣ D t p₂ ... | false | true = ♯ D t (♭ p₁) · ♯? p₂ ∣ D t p₂ -- D is correct. D-sound : ∀ {n s t} {p : P n} → s ∈ D t p → t ∷ s ∈ p D-sound s∈ = D-sound′ _ _ s∈ where sat-lemma : ∀ {s} f t → s ∈ D t (sat f) → T (f t) × s ≡ [] sat-lemma f t ∈ with f t sat-lemma f t empty | true = (_ , refl) sat-lemma f t () | false D-sound′ : ∀ {s n} (p : P n) t → s ∈ D t p → t ∷ s ∈ p D-sound′ fail t () D-sound′ empty t () D-sound′ (sat f) t s∈ with sat-lemma f t s∈ ... | (ok , refl) = sat ok D-sound′ (p₁ ∣ p₂) t (∣-left ∈₁) = ∣-left (D-sound′ p₁ t ∈₁) D-sound′ (p₁ ∣ p₂) t (∣-right ∈₂) = ∣-right {p₁ = p₁} (D-sound′ p₂ t ∈₂) D-sound′ (nonempty p) t ∈ = nonempty (D-sound ∈) D-sound′ (cast _ p) t ∈ = cast (D-sound ∈) D-sound′ (p₁ · p₂) t s∈ with forced? p₁ | forced? p₂ D-sound′ (p₁ · p₂) t (∣-left (∈₁ · ∈₂)) | true | true = D-sound ∈₁ · drop-♭♯ (D-nullable t p₁) ∈₂ D-sound′ (p₁ · p₂) t (∣-right ∈₂) | true | true = ⇐ p₁ refl · D-sound′ p₂ t ∈₂ D-sound′ (p₁ · p₂) t (∣-left (∈₁ · ∈₂)) | false | true = D-sound ∈₁ · drop-♭♯ (D-nullable t (♭ p₁)) ∈₂ D-sound′ (p₁ · p₂) t (∣-right ∈₂) | false | true = ⇐ (♭ p₁) refl · D-sound′ p₂ t ∈₂ D-sound′ (p₁ · p₂) t (∈₁ · ∈₂) | true | false = D-sound ∈₁ · drop-♭♯ (D-nullable t p₁ ) ∈₂ D-sound′ (p₁ · p₂) t (∈₁ · ∈₂) | false | false = D-sound ∈₁ · drop-♭♯ (D-nullable t (♭ p₁)) ∈₂ D-complete : ∀ {n s t} {p : P n} → t ∷ s ∈ p → s ∈ D t p D-complete {t = t} t∷s∈ = D-complete′ _ t∷s∈ refl where D-complete′ : ∀ {s s′ n} (p : P n) → s′ ∈ p → s′ ≡ t ∷ s → s ∈ D t p D-complete′ fail () refl D-complete′ empty () refl D-complete′ (sat f) (sat ok) refl with f t D-complete′ (sat f) (sat ok) refl | true = empty D-complete′ (sat f) (sat ()) refl | false D-complete′ (p₁ ∣ p₂) (∣-left ∈₁) refl = ∣-left (D-complete ∈₁) D-complete′ (p₁ ∣ p₂) (∣-right ∈₂) refl = ∣-right {p₁ = D t p₁} (D-complete ∈₂) D-complete′ (nonempty p) (nonempty ∈) refl = D-complete ∈ D-complete′ (cast _ p) (cast ∈) refl = D-complete ∈ D-complete′ (p₁ · p₂) _ _ with forced? p₁ | forced? p₂ D-complete′ (p₁ · p₂) (_·_ {[]} ∈₁ ∈₂) refl | true | true = ∣-right {p₁ = D t p₁ · _} (D-complete ∈₂) D-complete′ (p₁ · p₂) (_·_ {._ ∷ _} ∈₁ ∈₂) refl | true | true = ∣-left (D-complete ∈₁ · add-♭♯ (D-nullable t p₁) ∈₂) D-complete′ (p₁ · p₂) (_·_ {[]} ∈₁ ∈₂) refl | true | false with ⇒ ∈₁ D-complete′ (p₁ · p₂) (_·_ {[]} ∈₁ ∈₂) refl | true | false | () D-complete′ (p₁ · p₂) (_·_ {._ ∷ _} ∈₁ ∈₂) refl | true | false = D-complete ∈₁ · add-♭♯ (D-nullable t p₁) ∈₂ D-complete′ (p₁ · p₂) (_·_ {[]} ∈₁ ∈₂) refl | false | true = ∣-right {p₁ = _·_ {n₂ = false} _ _} (D-complete ∈₂) D-complete′ (p₁ · p₂) (_·_ {._ ∷ _} ∈₁ ∈₂) refl | false | true = ∣-left (D-complete ∈₁ · add-♭♯ (D-nullable t (♭ p₁)) ∈₂) D-complete′ (p₁ · p₂) (_·_ {[]} ∈₁ ∈₂) refl | false | false with ⇒ ∈₁ D-complete′ (p₁ · p₂) (_·_ {[]} ∈₁ ∈₂) refl | false | false | () D-complete′ (p₁ · p₂) (_·_ {._ ∷ _} ∈₁ ∈₂) refl | false | false = D-complete ∈₁ · add-♭♯ (D-nullable t (♭ p₁)) ∈₂ D-correct : ∀ {n s t} {p : P n} → s ∈ D t p ⇔ t ∷ s ∈ p D-correct = equivalence D-sound D-complete ------------------------------------------------------------------------ -- _∈_ is decidable -- _∈?_ runs a recogniser. Note that the result is yes or no plus a -- /proof/ verifying that the answer is correct. infix 4 _∈?_ _∈?_ : ∀ {n} (s : List Tok) (p : P n) → Dec (s ∈ p) [] ∈? p = nullable? p t ∷ s ∈? p with s ∈? D t p t ∷ s ∈? p | yes s∈Dtp = yes (D-sound s∈Dtp) t ∷ s ∈? p | no s∉Dtp = no (s∉Dtp ∘ D-complete) -- The last three lines could be replaced by the following one: -- -- t ∷ s ∈? p = Decidable.map D-correct (s ∈? D t p) ------------------------------------------------------------------------ -- Alternative characterisation of equality infix 5 _∷_ infix 4 _≈′_ -- Two recognisers/languages are equal if their nullability indices -- are equal and all their derivatives are equal (coinductively). Note -- that the elements of this type are bisimulations. data _≈′_ {n₁ n₂} (p₁ : P n₁) (p₂ : P n₂) : Set where _∷_ : n₁ ≡ n₂ → (∀ t → ∞ (D t p₁ ≈′ D t p₂)) → p₁ ≈′ p₂ -- This definition is equivalent to the one above. ≈′-sound : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈′ p₂ → p₁ ≈ p₂ ≈′-sound (refl ∷ rest) {[]} = Eq.sym index-correct ⟨∘⟩ index-correct ≈′-sound (refl ∷ rest) {t ∷ s} = D-correct ⟨∘⟩ ≈′-sound (♭ (rest t)) ⟨∘⟩ Eq.sym D-correct same-nullability : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈ p₂ → n₁ ≡ n₂ same-nullability p₁≈p₂ = Bool.⇔→≡ (index-correct ⟨∘⟩ p₁≈p₂ ⟨∘⟩ Eq.sym index-correct) D-cong : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} {t} → p₁ ≈ p₂ → D t p₁ ≈ D t p₂ D-cong p₁≈p₂ = Eq.sym D-correct ⟨∘⟩ p₁≈p₂ ⟨∘⟩ D-correct ≈′-complete : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈ p₂ → p₁ ≈′ p₂ ≈′-complete p₁≈p₂ = same-nullability p₁≈p₂ ∷ λ _ → ♯ ≈′-complete (D-cong p₁≈p₂) ≈′-correct : ∀ {n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → p₁ ≈′ p₂ ⇔ p₁ ≈ p₂ ≈′-correct = equivalence ≈′-sound ≈′-complete ------------------------------------------------------------------------ -- The combinator nonempty does not need to be primitive -- The variant of nonempty which is defined below (nonempty′) makes -- many recognisers larger, though. module AlternativeNonempty where nonempty′ : ∀ {n} → P n → P false nonempty′ fail = fail nonempty′ empty = fail nonempty′ (sat f) = sat f nonempty′ (p₁ ∣ p₂) = nonempty′ p₁ ∣ nonempty′ p₂ nonempty′ (nonempty p) = nonempty′ p nonempty′ (cast eq p) = nonempty′ p nonempty′ (p₁ · p₂) with forced? p₁ | forced? p₂ ... | false | _ = p₁ · p₂ ... | true | false = p₁ · p₂ ... | true | true = nonempty′ p₁ ∣ nonempty′ p₂ ∣ ♯ nonempty′ p₁ · ♯ nonempty′ p₂ sound : ∀ {n} {p : P n} → nonempty′ p ≤ nonempty p sound {s = []} pr with ⇒ pr ... | () sound {s = _ ∷ _} pr = nonempty (sound′ _ pr refl) where sound′ : ∀ {n t s s′} (p : P n) → s′ ∈ nonempty′ p → s′ ≡ t ∷ s → t ∷ s ∈ p sound′ fail () refl sound′ empty () refl sound′ (sat f) (sat ok) refl = sat ok sound′ (p₁ ∣ p₂) (∣-left pr) refl = ∣-left (sound′ p₁ pr refl) sound′ (p₁ ∣ p₂) (∣-right pr) refl = ∣-right {p₁ = p₁} (sound′ p₂ pr refl) sound′ (nonempty p) pr refl = nonempty (sound′ p pr refl) sound′ (cast _ p) pr refl = cast (sound′ p pr refl) sound′ (p₁ · p₂) pr _ with forced? p₁ | forced? p₂ sound′ (p₁ · p₂) pr refl | false | _ = pr sound′ (p₁ · p₂) pr refl | true | false = pr sound′ (p₁ · p₂) (∣-left (∣-left pr)) refl | true | true = cast∈ (proj₂ ListMonoid.identity _) refl $ sound′ p₁ pr refl · ⇐ p₂ refl sound′ (p₁ · p₂) (∣-left (∣-right pr)) refl | true | true = ⇐ p₁ refl · sound′ p₂ pr refl sound′ (p₁ · p₂) (∣-right (_·_ {[]} pr₁ pr₂)) refl | true | true with ⇒ pr₁ ... | () sound′ (p₁ · p₂) (∣-right (_·_ {_ ∷ _} pr₁ pr₂)) refl | true | true with sound {p = p₂} pr₂ ... | nonempty pr₂′ = sound′ p₁ pr₁ refl · pr₂′ complete : ∀ {n} {p : P n} → nonempty p ≤ nonempty′ p complete (nonempty pr) = complete′ _ pr refl where complete′ : ∀ {n t s s′} (p : P n) → s ∈ p → s ≡ t ∷ s′ → t ∷ s′ ∈ nonempty′ p complete′ fail () refl complete′ empty () refl complete′ (sat f) (sat ok) refl = sat ok complete′ (p₁ ∣ p₂) (∣-left pr) refl = ∣-left (complete′ p₁ pr refl) complete′ (p₁ ∣ p₂) (∣-right pr) refl = ∣-right {n₁ = false} (complete′ p₂ pr refl) complete′ (nonempty p) (nonempty pr) refl = complete′ p pr refl complete′ (cast _ p) (cast pr) refl = complete′ p pr refl complete′ (p₁ · p₂) pr _ with forced? p₁ | forced? p₂ complete′ (p₁ · p₂) pr refl | false | _ = pr complete′ (p₁ · p₂) pr refl | true | false = pr complete′ (p₁ · p₂) (_·_ {[]} pr₁ pr₂) refl | true | true = ∣-left (∣-right {n₁ = false} (complete′ p₂ pr₂ refl)) complete′ (p₁ · p₂) (_·_ {_ ∷ _} {[]} pr₁ pr₂) refl | true | true = cast∈ (sym $ proj₂ ListMonoid.identity _) refl $ ∣-left (∣-left {n₂ = false} (complete′ p₁ pr₁ refl)) complete′ (p₁ · p₂) (_·_ {_ ∷ _} {_ ∷ _} pr₁ pr₂) refl | true | true = ∣-right {n₁ = false} (complete′ p₁ pr₁ refl · complete′ p₂ pr₂ refl) correct : ∀ {n} {p : P n} → nonempty′ p ≈ nonempty p correct = equivalence sound complete
41.362187
134
0.472574
1b388f3455c9b2fa23f8795c858cae1c58c0f8fa
2,042
agda
Agda
test/Fail/Issue2170-subtyping.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2020-04-26T09:35:17.000Z
2020-04-26T09:35:17.000Z
test/Fail/Issue2170-subtyping.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2015-09-15T15:49:15.000Z
2015-09-15T15:49:15.000Z
test/Fail/Issue2170-subtyping.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2021-04-18T13:34:07.000Z
2021-04-18T13:34:07.000Z
-- Andreas, 2018-06-12, issue #2170 -- Reported by tomjack {-# OPTIONS --irrelevant-projections --subtyping #-} open import Agda.Builtin.Equality open import Agda.Builtin.Bool infixr 42 _,_ record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field fst : A snd : B fst open Σ record Irr (A : Set) : Set where constructor irr field .unirr : A open Irr -- Usually, unirr (irr a) = .(a) which is DontCare a in internal syntax. -- The DontCare protection of an irrelevant field could be circumvented -- using subtyping irr : (.Bool → Irr Bool) ≤ (Bool → Irr Bool): -- The argument a in (i a) would not have ArgInfo Irrelevant, even -- after substitution irr/i. Since the DontCare came from the ArgInfo of a, -- there was none. Now, the record constructor name also carries ArgInfo for -- each of its fields, which is used to produce a DontCare. bizarre : Irr (Σ (Bool → Irr Bool) (λ i → Σ (Irr Bool → Bool) (λ u → (a : Bool) → u (i a) ≡ a))) bizarre = irr (irr , unirr , λ a → refl) -- Should not pass -- Expected error: -- .(a) != a of type Bool -- when checking that the expression refl has type .(a) ≡ a -- The rest is proving False. data ⊥ : Set where ¬_ : Set → Set ¬ A = (A → ⊥) true≠false : ¬ (true ≡ false) true≠false () infixr 30 _∙_ _∙_ : {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z refl ∙ q = q infix 42 !_ !_ : {A : Set} {x y : A} → x ≡ y → y ≡ x ! refl = refl map-irr : {A B : Set} → (A → B) → Irr A → Irr B map-irr f (irr x) = irr (f x) factivity : ¬ (Irr ⊥) factivity (irr ()) bad : Irr (true ≡ false) bad = map-irr (λ { (i , u , s) → ! (s true) ∙ s false }) bizarre boom : ⊥ boom = factivity (map-irr true≠false bad) -- the hole here is is .(a) ≡ a -- bizarre' : Irr (Σ (Irr Bool → Bool) (λ u → (a : Bool) → u (irr a) ≡ a)) -- bizarre' = irr (unirr , (λ a → {!!})) -- also fails, unirr (irr a) = .(a) -- bizarre' : Irr (Σ (Bool → Irr Bool) (λ i → Σ (Irr Bool → Bool) (λ u → (a : Bool) → u (i a) ≡ a))) -- bizarre' = irr (irr , unirr , (λ a → refl {x = unirr (irr a)})
26.868421
100
0.588639
3511b0226337a8aabe42b5dc320175949186917d
377
agda
Agda
test/Succeed/WarningInstanceWithExplicitArg.agda
strake/agda
c8a3cfa002e77acc5ae1993bae413fde42d4f93b
[ "BSD-3-Clause" ]
2
2019-10-29T09:40:30.000Z
2020-09-20T00:28:57.000Z
test/Succeed/WarningInstanceWithExplicitArg.agda
vikfret/agda
49ad0b3f0d39c01bc35123478b857e702b29fb9d
[ "BSD-3-Clause" ]
3
2018-11-14T15:31:44.000Z
2019-04-01T19:39:26.000Z
test/Succeed/WarningInstanceWithExplicitArg.agda
vikfret/agda
49ad0b3f0d39c01bc35123478b857e702b29fb9d
[ "BSD-3-Clause" ]
1
2021-04-01T18:30:09.000Z
2021-04-01T18:30:09.000Z
-- Jesper, 2018-11-29: Instances with explicit arguments will never be -- used, so declaring them should give a warning. postulate X : Set instance _ : Set → X -- this should give a warning it : {{_ : X}} → X it {{x}} = x -- OTOH, this is fine as the instance can be used inside the module module _ (A : Set) where postulate instance instX : X test : X test = it
22.176471
70
0.66313
22267f9d48c8c8ea2569c21eced19c1eb01bc3c7
373
agda
Agda
src/data/lib/prim/Agda/Builtin/Int.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/Int.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/Int.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
module Agda.Builtin.Int where open import Agda.Builtin.Nat open import Agda.Builtin.String infix 8 pos -- Standard library uses this as +_ data Int : Set where pos : (n : Nat) → Int negsuc : (n : Nat) → Int {-# BUILTIN INTEGER Int #-} {-# BUILTIN INTEGERPOS pos #-} {-# BUILTIN INTEGERNEGSUC negsuc #-} primitive primShowInteger : Int → String
20.722222
48
0.656836
196ef20434e9838458db58062d397514e0b4d6a6
251
agda
Agda
src/Data/Star/Properties/Extra.agda
metaborg/mj.agda
0c096fea1716d714db0ff204ef2a9450b7a816df
[ "Apache-2.0" ]
10
2017-11-17T17:10:36.000Z
2021-09-24T08:02:33.000Z
src/Data/Star/Properties/Extra.agda
metaborg/mj.agda
0c096fea1716d714db0ff204ef2a9450b7a816df
[ "Apache-2.0" ]
1
2019-01-13T13:03:47.000Z
2020-10-14T13:41:58.000Z
src/Data/Star/Properties/Extra.agda
metaborg/mj.agda
0c096fea1716d714db0ff204ef2a9450b7a816df
[ "Apache-2.0" ]
1
2021-12-28T17:38:05.000Z
2021-12-28T17:38:05.000Z
module Data.Star.Properties.Extra where open import Relation.Binary.Core open import Data.Star module _ {i}{I : Set i}{r}{R : Rel I r} where _◅◅-ε : ∀ {i j} → (xs : Star R i j) → xs ◅◅ ε ≡ xs ε ◅◅-ε = refl (x ◅ xs) ◅◅-ε rewrite xs ◅◅-ε = refl
25.1
52
0.585657
4130d0f360e7429edbbc3359c69beccd8e743f8b
96
agda
Agda
Data/Empty.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
Data/Empty.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
null
null
null
Data/Empty.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --without-K --safe #-} module Data.Empty where open import Data.Empty.Base public
16
34
0.708333
4d3cdf3754f8e2105bfa6d42ec05a9425f156875
1,376
agda
Agda
main/Groups/Definition.agda
awswan/nielsenschreier-hott
84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d
[ "MIT" ]
null
null
null
main/Groups/Definition.agda
awswan/nielsenschreier-hott
84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d
[ "MIT" ]
null
null
null
main/Groups/Definition.agda
awswan/nielsenschreier-hott
84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --exact-split --rewriting --overlapping-instances #-} open import lib.Basics open import lib.NConnected open import lib.NType2 open import lib.types.Truncation open import Coequalizers.Definition open import Coequalizers.Misc open import Graphs.Definition open import Util.Misc module Groups.Definition where {- BG has the structure of a type theoretic group if it is pointed, connected and 1-truncated. -} record TTGroup {i : ULevel} (BG : Type i) : Type i where field base : BG ⦃ gp-conn ⦄ : is-connected 0 BG ⦃ gp-trunc ⦄ : is-gpd BG open TTGroup ⦃...⦄ public {- Some functions related to free higher groups (which we never define explicitly). -} module _ {i : ULevel} {A : Type i} where instance -- Whenever we need a pair of maps A ⇉ 1 they are defined as follows gph-fhg : Graph A Unit gph-fhg = record { π₀ = λ _ → unit ; π₁ = λ _ → unit } conn-fhg : is-connected 0 (⊤ / A) conn-fhg = has-level-in ([ c[ unit ] ] , Trunc-elim (λ x → Trunc-rec (λ { (t , p) → ap [_] p}) (quotient-map-is-surj x))) fhg-base : ⊤ / A fhg-base = c[ unit ] {- The definition of a free group. -} FreeGroup : {i : ULevel} (A : Type i) → Type i FreeGroup A = ∥ ⊤ / A ∥₁ instance -- free groups are groups free-gp-str : {i : ULevel} {A : Type i} → TTGroup (FreeGroup A) free-gp-str = record { base = [ fhg-base ] }
28.666667
125
0.653343
57e8878bf2242dfef3e619bb93887b1f9be962a6
3,226
agda
Agda
Structure/Category/NaturalTransformation/NaturalTransformations.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Structure/Category/NaturalTransformation/NaturalTransformations.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Structure/Category/NaturalTransformation/NaturalTransformations.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Structure.Category.NaturalTransformation.NaturalTransformations where open import Functional using () renaming (id to idᶠⁿ) open import Functional.Dependent using () renaming (_∘_ to _∘ᶠⁿ_) open import Logic open import Logic.Predicate import Lvl open import Structure.Category open import Structure.Category.Functor open import Structure.Category.NaturalTransformation open import Structure.Categorical.Properties open import Structure.Operator open import Structure.Relator.Equivalence open import Structure.Setoid open import Syntax.Transitivity open import Type open CategoryObject private variable ℓₒₗ ℓₒᵣ ℓₘₗ ℓₘᵣ ℓₑₗ ℓₑᵣ : Lvl.Level module Raw (catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ}) (catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ}) where private variable F F₁ F₂ F₃ : Object(catₗ) → Object(catᵣ) private instance _ = category catₗ private instance _ = category catᵣ open Category.ArrowNotation ⦃ … ⦄ open Category ⦃ … ⦄ hiding (identity) idᴺᵀ : (x : Object(catₗ)) → (F(x) ⟶ F(x)) idᴺᵀ _ = id _∘ᴺᵀ_ : ((x : Object(catₗ)) → (F₂(x) ⟶ F₃(x))) → ((x : Object(catₗ)) → (F₁(x) ⟶ F₂(x))) → ((x : Object(catₗ)) → (F₁(x) ⟶ F₃(x))) (comp₁ ∘ᴺᵀ comp₂)(x) = comp₁(x) ∘ comp₂(x) module _ {catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ}} {catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ}} where private instance _ = category catₗ private instance _ = category catᵣ open Category ⦃ … ⦄ hiding (identity) open Functor ⦃ … ⦄ private open module Equivᵣ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv(catᵣ){x}{y} ⦄) using () module _ where open Raw(catₗ)(catᵣ) module _ {functor@([∃]-intro F) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where identity : NaturalTransformation(functor)(functor)(idᴺᵀ) NaturalTransformation.natural identity {x} {y} {f} = id ∘ map f 🝖-[ Morphism.identityₗ(_)(id) ⦃ identityₗ ⦄ ] map f 🝖-[ Morphism.identityᵣ(_)(id) ⦃ identityᵣ ⦄ ]-sym map f ∘ id 🝖-end module _ {functor₁@([∃]-intro F₁) functor₂@([∃]-intro F₂) functor₃@([∃]-intro F₃) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where composition : ∀{comp₁ comp₂} → NaturalTransformation(functor₂)(functor₃)(comp₁) → NaturalTransformation(functor₁)(functor₂)(comp₂) → NaturalTransformation(functor₁)(functor₃)(comp₁ ∘ᴺᵀ comp₂) NaturalTransformation.natural (composition {comp₁} {comp₂} nat₁ nat₂) {x} {y} {f} = (comp₁(y) ∘ comp₂(y)) ∘ map f 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ] comp₁(y) ∘ (comp₂(y) ∘ map f) 🝖-[ congruence₂ᵣ(_∘_)(comp₁(y)) (NaturalTransformation.natural nat₂) ] comp₁(y) ∘ (map f ∘ comp₂(x)) 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ]-sym (comp₁(y) ∘ map f) ∘ comp₂(x) 🝖-[ congruence₂ₗ(_∘_)(comp₂(x)) (NaturalTransformation.natural nat₁) ] (map f ∘ comp₁(x)) ∘ comp₂(x) 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ] map f ∘ (comp₁(x) ∘ comp₂(x)) 🝖-end module Wrapped where private variable F F₁ F₂ F₃ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ idᴺᵀ : (F →ᴺᵀ F) idᴺᵀ = [∃]-intro (Raw.idᴺᵀ(catₗ)(catᵣ)) ⦃ identity ⦄ _∘ᴺᵀ_ : (F₂ →ᴺᵀ F₃) → (F₁ →ᴺᵀ F₂) → (F₁ →ᴺᵀ F₃) _∘ᴺᵀ_ ([∃]-intro F ⦃ F-proof ⦄) ([∃]-intro G ⦃ G-proof ⦄) = [∃]-intro (Raw._∘ᴺᵀ_ (catₗ)(catᵣ) F G) ⦃ composition F-proof G-proof ⦄
40.835443
197
0.65933
52dbe194f0d7de6c045733c2998466f751ec5387
2,479
agda
Agda
Cubical/HITs/Rationals/QuoQ/Base.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
Cubical/HITs/Rationals/QuoQ/Base.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
Cubical/HITs/Rationals/QuoQ/Base.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Rationals.QuoQ.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Data.Nat as ℕ using (discreteℕ) open import Cubical.Data.NatPlusOne open import Cubical.Data.Sigma open import Cubical.HITs.Ints.QuoInt open import Cubical.HITs.SetQuotients as SetQuotient using ([_]; eq/; discreteSetQuotients) renaming (_/_ to _//_) public open import Cubical.Relation.Nullary open import Cubical.Relation.Binary.Base ℕ₊₁→ℤ : ℕ₊₁ → ℤ ℕ₊₁→ℤ n = pos (ℕ₊₁→ℕ n) private ℕ₊₁→ℤ-hom : ∀ m n → ℕ₊₁→ℤ (m ·₊₁ n) ≡ ℕ₊₁→ℤ m · ℕ₊₁→ℤ n ℕ₊₁→ℤ-hom _ _ = refl -- ℚ as a set quotient of ℤ × ℕ₊₁ (as in the HoTT book) _∼_ : ℤ × ℕ₊₁ → ℤ × ℕ₊₁ → Type₀ (a , b) ∼ (c , d) = a · ℕ₊₁→ℤ d ≡ c · ℕ₊₁→ℤ b ℚ : Type₀ ℚ = (ℤ × ℕ₊₁) // _∼_ isSetℚ : isSet ℚ isSetℚ = SetQuotient.squash/ [_/_] : ℤ → ℕ₊₁ → ℚ [ a / b ] = [ a , b ] isEquivRel∼ : isEquivRel _∼_ isEquivRel.reflexive isEquivRel∼ (a , b) = refl isEquivRel.symmetric isEquivRel∼ (a , b) (c , d) = sym isEquivRel.transitive isEquivRel∼ (a , b) (c , d) (e , f) p q = ·-injʳ _ _ _ r where r = (a · ℕ₊₁→ℤ f) · ℕ₊₁→ℤ d ≡[ i ]⟨ ·-comm a (ℕ₊₁→ℤ f) i · ℕ₊₁→ℤ d ⟩ (ℕ₊₁→ℤ f · a) · ℕ₊₁→ℤ d ≡⟨ sym (·-assoc (ℕ₊₁→ℤ f) a (ℕ₊₁→ℤ d)) ⟩ ℕ₊₁→ℤ f · (a · ℕ₊₁→ℤ d) ≡[ i ]⟨ ℕ₊₁→ℤ f · p i ⟩ ℕ₊₁→ℤ f · (c · ℕ₊₁→ℤ b) ≡⟨ ·-assoc (ℕ₊₁→ℤ f) c (ℕ₊₁→ℤ b) ⟩ (ℕ₊₁→ℤ f · c) · ℕ₊₁→ℤ b ≡[ i ]⟨ ·-comm (ℕ₊₁→ℤ f) c i · ℕ₊₁→ℤ b ⟩ (c · ℕ₊₁→ℤ f) · ℕ₊₁→ℤ b ≡[ i ]⟨ q i · ℕ₊₁→ℤ b ⟩ (e · ℕ₊₁→ℤ d) · ℕ₊₁→ℤ b ≡⟨ sym (·-assoc e (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b)) ⟩ e · (ℕ₊₁→ℤ d · ℕ₊₁→ℤ b) ≡[ i ]⟨ e · ·-comm (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b) i ⟩ e · (ℕ₊₁→ℤ b · ℕ₊₁→ℤ d) ≡⟨ ·-assoc e (ℕ₊₁→ℤ b) (ℕ₊₁→ℤ d) ⟩ (e · ℕ₊₁→ℤ b) · ℕ₊₁→ℤ d ∎ eq/⁻¹ : ∀ x y → Path ℚ [ x ] [ y ] → x ∼ y eq/⁻¹ = SetQuotient.effective (λ _ _ → isSetℤ _ _) isEquivRel∼ discreteℚ : Discrete ℚ discreteℚ = discreteSetQuotients (discreteΣ discreteℤ (λ _ → subst Discrete 1+Path discreteℕ)) (λ _ _ → isSetℤ _ _) isEquivRel∼ (λ _ _ → discreteℤ _ _) -- Natural number and negative integer literals for ℚ open import Cubical.Data.Nat.Literals public instance fromNatℚ : HasFromNat ℚ fromNatℚ = record { Constraint = λ _ → Unit ; fromNat = λ n → [ pos n / 1 ] } instance fromNegℚ : HasFromNeg ℚ fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → [ neg n / 1 ] }
32.194805
94
0.553046
8b119e571de4f1f26fa5f581acd8eccf9ec7b2ee
139
agda
Agda
test/fail/Issue481NonExistentModule.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
1
2019-11-27T04:41:05.000Z
2019-11-27T04:41:05.000Z
test/fail/Issue481NonExistentModule.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
test/fail/Issue481NonExistentModule.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
-- Andreas, 2012-10-20 module Issue481NonExistentModule where open import NonExistentModule Set -- test the error message and location
15.444444
38
0.798561
8b23988cee18fbd687f47e36742a0921ee219ee6
788
agda
Agda
test/Succeed/HereditarilySingletonRecord.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
test/Succeed/HereditarilySingletonRecord.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
test/Succeed/HereditarilySingletonRecord.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
-- Modified: Andreas, 2011-04-11 freezing Metas module HereditarilySingletonRecord where data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x -- * trivial unit type record Singleton : Set where foo : Singleton foo = _ -- * product of unit types record HereditarilySingleton : Set where field singleton : Singleton also-singleton : Singleton bar : HereditarilySingleton bar = _ -- * hiding the unit types behind a type case data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ Unit : ℕ → Set Unit zero = Singleton Unit (suc n) = Unit n mutual -- needed to avoid freezing one : ℕ one = _ record HereditarilySingleton₂ : Set where field singleton : Unit one baz : HereditarilySingleton₂ baz = _ force : one ≡ suc zero force = refl
16.416667
47
0.661168
52670f36d5cdc79183cf9030633df77598689685
250
agda
Agda
src/Implicits/Resolution/Termination.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
4
2019-04-05T17:57:11.000Z
2021-05-07T04:08:41.000Z
src/Implicits/Resolution/Termination.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
src/Implicits/Resolution/Termination.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
open import Prelude module Implicits.Resolution.Termination where open import Implicits.Resolution.Termination.SizeMeasures public open import Implicits.Resolution.Termination.Stack public open import Implicits.Resolution.Termination.Lemmas public
31.25
64
0.876
1b7f614a3fa09d957bd8c1ca0ae68ba11aa7abe5
2,984
agda
Agda
agda-stdlib-0.9/src/Algebra/Properties/DistributiveLattice.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
1
2016-10-20T15:52:05.000Z
2016-10-20T15:52:05.000Z
agda-stdlib-0.9/src/Algebra/Properties/DistributiveLattice.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
null
null
null
agda-stdlib-0.9/src/Algebra/Properties/DistributiveLattice.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
null
null
null
------------------------------------------------------------------------ -- The Agda standard library -- -- Some derivable properties ------------------------------------------------------------------------ open import Algebra module Algebra.Properties.DistributiveLattice {dl₁ dl₂} (DL : DistributiveLattice dl₁ dl₂) where open DistributiveLattice DL import Algebra.Properties.Lattice private open module L = Algebra.Properties.Lattice lattice public hiding (replace-equality) open import Algebra.Structures import Algebra.FunctionProperties as P; open P _≈_ open import Relation.Binary import Relation.Binary.EqReasoning as EqR; open EqR setoid open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; module Equivalence) open import Data.Product ∨-∧-distrib : _∨_ DistributesOver _∧_ ∨-∧-distrib = ∨-∧-distribˡ , ∨-∧-distribʳ where ∨-∧-distribˡ : _∨_ DistributesOverˡ _∧_ ∨-∧-distribˡ x y z = begin x ∨ y ∧ z ≈⟨ ∨-comm _ _ ⟩ y ∧ z ∨ x ≈⟨ ∨-∧-distribʳ _ _ _ ⟩ (y ∨ x) ∧ (z ∨ x) ≈⟨ ∨-comm _ _ ⟨ ∧-cong ⟩ ∨-comm _ _ ⟩ (x ∨ y) ∧ (x ∨ z) ∎ ∧-∨-distrib : _∧_ DistributesOver _∨_ ∧-∨-distrib = ∧-∨-distribˡ , ∧-∨-distribʳ where ∧-∨-distribˡ : _∧_ DistributesOverˡ _∨_ ∧-∨-distribˡ x y z = begin x ∧ (y ∨ z) ≈⟨ sym (proj₂ absorptive _ _) ⟨ ∧-cong ⟩ refl ⟩ (x ∧ (x ∨ y)) ∧ (y ∨ z) ≈⟨ (refl ⟨ ∧-cong ⟩ ∨-comm _ _) ⟨ ∧-cong ⟩ refl ⟩ (x ∧ (y ∨ x)) ∧ (y ∨ z) ≈⟨ ∧-assoc _ _ _ ⟩ x ∧ ((y ∨ x) ∧ (y ∨ z)) ≈⟨ refl ⟨ ∧-cong ⟩ sym (proj₁ ∨-∧-distrib _ _ _) ⟩ x ∧ (y ∨ x ∧ z) ≈⟨ sym (proj₁ absorptive _ _) ⟨ ∧-cong ⟩ refl ⟩ (x ∨ x ∧ z) ∧ (y ∨ x ∧ z) ≈⟨ sym $ proj₂ ∨-∧-distrib _ _ _ ⟩ x ∧ y ∨ x ∧ z ∎ ∧-∨-distribʳ : _∧_ DistributesOverʳ _∨_ ∧-∨-distribʳ x y z = begin (y ∨ z) ∧ x ≈⟨ ∧-comm _ _ ⟩ x ∧ (y ∨ z) ≈⟨ ∧-∨-distribˡ _ _ _ ⟩ x ∧ y ∨ x ∧ z ≈⟨ ∧-comm _ _ ⟨ ∨-cong ⟩ ∧-comm _ _ ⟩ y ∧ x ∨ z ∧ x ∎ -- The dual construction is also a distributive lattice. ∧-∨-isDistributiveLattice : IsDistributiveLattice _≈_ _∧_ _∨_ ∧-∨-isDistributiveLattice = record { isLattice = ∧-∨-isLattice ; ∨-∧-distribʳ = proj₂ ∧-∨-distrib } ∧-∨-distributiveLattice : DistributiveLattice _ _ ∧-∨-distributiveLattice = record { _∧_ = _∨_ ; _∨_ = _∧_ ; isDistributiveLattice = ∧-∨-isDistributiveLattice } -- One can replace the underlying equality with an equivalent one. replace-equality : {_≈′_ : Rel Carrier dl₂} → (∀ {x y} → x ≈ y ⇔ x ≈′ y) → DistributiveLattice _ _ replace-equality {_≈′_} ≈⇔≈′ = record { _≈_ = _≈′_ ; _∧_ = _∧_ ; _∨_ = _∨_ ; isDistributiveLattice = record { isLattice = Lattice.isLattice (L.replace-equality ≈⇔≈′) ; ∨-∧-distribʳ = λ x y z → to ⟨$⟩ ∨-∧-distribʳ x y z } } where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})
34.697674
81
0.528485
fdc8e6d10f86b9a195ec450754a3821f7a4f3565
480
agda
Agda
old/Mathematical/Type/Quotient.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
old/Mathematical/Type/Quotient.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
old/Mathematical/Type/Quotient.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Type.Quotient where open import Logic open import Relator.Equals open import Type open import Lvl private variable ℓ₁ : Lvl.Level private variable ℓ₂ : Lvl.Level data _/_ (T : Type{ℓ₁}) (_≅_ : T → T → Stmt{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where [_] : T → (T / (_≅_)) [/]-equiv-to-eq : ∀{x y : T} → (x ≅ y) → ([ x ] ≡ [ y ]) [/]-uip : ∀{X Y : (T / (_≅_))} → (proof₁ proof₂ : (X ≡ Y)) → (proof₁ ≡ proof₂) -- TODO: [/]-eq-to-equiv : (x y : A) → (x ≅ y) ← ([ x ] ≡ [ y ])
28.235294
80
0.525
388284763c06517a6f81d1ffff6fee4b4c5e8fb8
2,576
agda
Agda
Experiment/Categories/Solver/Functor.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
3
2020-04-07T17:49:42.000Z
2020-04-21T00:03:43.000Z
Experiment/Categories/Solver/Functor.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
Experiment/Categories/Solver/Functor.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
-- Solver for Functor {-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Functor renaming (id to idF) module Experiment.Categories.Solver.Functor {o ℓ e o′ ℓ′ e′} {𝒞 : Category o ℓ e} {𝒟 : Category o′ ℓ′ e′} (F : Functor 𝒞 𝒟) where open import Level open import Relation.Binary using (Rel) import Categories.Morphism.Reasoning as MR import Experiment.Categories.Solver.Category module 𝒞 = Category 𝒞 module CS = Experiment.Categories.Solver.Category 𝒞 open CS using (:id; _:∘_; ∥_∥) renaming (∥-∥ to ∥-∥′) public open Category 𝒟 open HomReasoning open MR 𝒟 open Functor F private variable A B C D E : Obj infixr 9 _:∘_ data Expr : Rel Obj (o ⊔ o′ ⊔ ℓ ⊔ ℓ′) where :id : Expr A A _:∘_ : Expr B C → Expr A B → Expr A C :F₁ : ∀ {A B} → CS.Expr A B → Expr (F₀ A) (F₀ B) ∥_∥ : A ⇒ B → Expr A B -- Semantics ⟦_⟧ : Expr A B → A ⇒ B ⟦ :id ⟧ = id ⟦ e₁ :∘ e₂ ⟧ = ⟦ e₁ ⟧ ∘ ⟦ e₂ ⟧ ⟦ :F₁ e ⟧ = F₁ CS.⟦ e ⟧ ⟦ ∥ f ∥ ⟧ = f F₁⟦_⟧N∘_ : ∀ {B C} → CS.Expr B C → A ⇒ F₀ B → A ⇒ F₀ C F₁⟦ :id ⟧N∘ g = g F₁⟦ e₁ :∘ e₂ ⟧N∘ g = F₁⟦ e₁ ⟧N∘ (F₁⟦ e₂ ⟧N∘ g) F₁⟦ ∥ f ∥ ⟧N∘ g = F₁ f ∘ g ⟦_⟧N∘_ : Expr B C → A ⇒ B → A ⇒ C ⟦ :id ⟧N∘ g = g ⟦ e₁ :∘ e₂ ⟧N∘ g = ⟦ e₁ ⟧N∘ (⟦ e₂ ⟧N∘ g) ⟦ :F₁ e ⟧N∘ g = F₁⟦ e ⟧N∘ g ⟦ ∥ f ∥ ⟧N∘ g = f ∘ g ⟦_⟧N : Expr A B → A ⇒ B ⟦ e ⟧N = ⟦ e ⟧N∘ id F₁⟦e⟧N∘f≈F₁⟦e⟧∘f : ∀ {B C} (e : CS.Expr B C) (g : A ⇒ F₀ B) → F₁⟦ e ⟧N∘ g ≈ F₁ CS.⟦ e ⟧ ∘ g F₁⟦e⟧N∘f≈F₁⟦e⟧∘f :id g = begin g ≈˘⟨ identityˡ ⟩ id ∘ g ≈˘⟨ identity ⟩∘⟨refl ⟩ F₁ 𝒞.id ∘ g ∎ F₁⟦e⟧N∘f≈F₁⟦e⟧∘f (e₁ :∘ e₂) g = begin F₁⟦ e₁ ⟧N∘ (F₁⟦ e₂ ⟧N∘ g) ≈⟨ F₁⟦e⟧N∘f≈F₁⟦e⟧∘f e₁ (F₁⟦ e₂ ⟧N∘ g) ⟩ F₁ CS.⟦ e₁ ⟧ ∘ (F₁⟦ e₂ ⟧N∘ g) ≈⟨ pushʳ (F₁⟦e⟧N∘f≈F₁⟦e⟧∘f e₂ g) ⟩ (F₁ CS.⟦ e₁ ⟧ ∘ F₁ CS.⟦ e₂ ⟧) ∘ g ≈˘⟨ homomorphism ⟩∘⟨refl ⟩ F₁ (CS.⟦ e₁ ⟧ 𝒞.∘ CS.⟦ e₂ ⟧) ∘ g ∎ F₁⟦e⟧N∘f≈F₁⟦e⟧∘f ∥ x ∥ g = refl ⟦e⟧N∘f≈⟦e⟧∘f : (e : Expr B C) (g : A ⇒ B) → ⟦ e ⟧N∘ g ≈ ⟦ e ⟧ ∘ g ⟦e⟧N∘f≈⟦e⟧∘f :id g = ⟺ identityˡ ⟦e⟧N∘f≈⟦e⟧∘f (e₁ :∘ e₂) g = begin ⟦ e₁ ⟧N∘ (⟦ e₂ ⟧N∘ g) ≈⟨ ⟦e⟧N∘f≈⟦e⟧∘f e₁ (⟦ e₂ ⟧N∘ g) ⟩ ⟦ e₁ ⟧ ∘ (⟦ e₂ ⟧N∘ g) ≈⟨ pushʳ (⟦e⟧N∘f≈⟦e⟧∘f e₂ g) ⟩ (⟦ e₁ ⟧ ∘ ⟦ e₂ ⟧) ∘ g ∎ ⟦e⟧N∘f≈⟦e⟧∘f (:F₁ e) g = F₁⟦e⟧N∘f≈F₁⟦e⟧∘f e g ⟦e⟧N∘f≈⟦e⟧∘f ∥ f ∥ g = refl ⟦e⟧N≈⟦e⟧ : (e : Expr A B) → ⟦ e ⟧N ≈ ⟦ e ⟧ ⟦e⟧N≈⟦e⟧ e = ⟦e⟧N∘f≈⟦e⟧∘f e id ○ identityʳ solve : (e₁ e₂ : Expr A B) → ⟦ e₁ ⟧N ≈ ⟦ e₂ ⟧N → ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ solve e₁ e₂ eq = begin ⟦ e₁ ⟧ ≈˘⟨ ⟦e⟧N≈⟦e⟧ e₁ ⟩ ⟦ e₁ ⟧N ≈⟨ eq ⟩ ⟦ e₂ ⟧N ≈⟨ ⟦e⟧N≈⟦e⟧ e₂ ⟩ ⟦ e₂ ⟧ ∎ ∥-∥ : ∀ {f : A ⇒ B} → Expr A B ∥-∥ {f = f} = ∥ f ∥
26.556701
75
0.456522
fd1757f80e7939be639151acdad4034ad90382ab
358
agda
Agda
examples/outdated-and-incorrect/clowns/Zipper.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
examples/outdated-and-incorrect/clowns/Zipper.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
examples/outdated-and-incorrect/clowns/Zipper.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Zipper where import Derivative import Functor import Sets open Functor open Derivative open Semantics open Recursive open Sets Zipper : U -> Set Zipper F = List (⟦ ∂ F ⟧ (μ F)) -- Plugging a zipper unzip : {F : U} -> Zipper F -> μ F -> μ F unzip [] t = t unzip {F} (c :: γ) t = inn (plug-∂ F c (unzip γ t))
16.272727
53
0.569832
19d378cebdddfb5e5bad83cdfed9f424ddc89b59
6,120
agda
Agda
src/Categories/Adjoint/AFT.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Adjoint/AFT.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Adjoint/AFT.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} -- Adjoint Functor Theorem module Categories.Adjoint.AFT where open import Level open import Data.Product open import Data.Product using (Σ) open import Categories.Category open import Categories.Category.Complete open import Categories.Category.Complete.Properties open import Categories.Category.Construction.Cones open import Categories.Category.Construction.Comma open import Categories.Functor open import Categories.Functor.Limits open import Categories.Functor.Properties open import Categories.Adjoint open import Categories.Adjoint.Properties open import Categories.Diagram.Limit as Lim open import Categories.Diagram.Cone.Properties open import Categories.Morphism as Mor open import Categories.Morphism.Universal import Categories.Adjoint.AFT.SolutionSet as SS import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level C D : Category o ℓ e module _ {R : Functor C D} where private module C = Category C module D = Category D module R = Functor R o-level : Level o-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level ℓ-level : Level ℓ-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level e-level : Level e-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level open SS R using (SolutionSet′) module _ {L : Functor D C} (L⊣R : L ⊣ R) where private module L = Functor L open Adjoint L⊣R L⊣R⇒solutionSet′ : SolutionSet′ L⊣R⇒solutionSet′ = record { S₀ = λ {_ X} _ → L.₀ X ; S₁ = Radjunct ; ϕ = λ _ → unit.η _ ; commute = λ _ → LRadjunct≈id } module _ (Com : Complete o-level ℓ-level e-level C) (Rcon : Continuous o-level ℓ-level e-level R) (s : SolutionSet′) where open SolutionSet′ s open D.Equiv open D.HomReasoning open MR D private module _ X where X↙R : Category (C.o-level ⊔ D.ℓ-level) (C.ℓ-level ⊔ D.e-level) C.e-level X↙R = X ↙ R module X↙R = Category X↙R s′ : SolutionSet X↙R s′ = record { D = D′ ; arr = arr′ } where D′ : X↙R.Obj → X↙R.Obj D′ Z = record { f = ϕ Z.f } where module Z = CommaObj Z arr′ : ∀ Z → X↙R [ D′ Z , Z ] arr′ Z = record { h = S₁ Z.f ; commute = commute _ ○ ⟺ D.identityʳ } where module Z = CommaObj Z open D.HomReasoning module _ {J : Category o-level ℓ-level e-level} (F : Functor J X↙R) where module J = Category J module F = Functor F F′ : Functor J C F′ = Cod _ _ ∘F F LimF′ : Limit F′ LimF′ = Com F′ module LimF′ = Limit LimF′ RLimF′ : Cone (R ∘F F′) RLimF′ = F-map-Coneˡ R LimF′.limit module RLimF′ = Cone _ RLimF′ LimRF′ : Limit (R ∘F F′) LimRF′ = record { terminal = record { ⊤ = RLimF′ ; ⊤-is-terminal = Rcon LimF′ } } module LimRF′ = Limit LimRF′ coneF : Cone (R ∘F F′) coneF = record { N = X ; apex = record { ψ = λ j → CommaObj.f (F.₀ j) ; commute = λ f → Comma⇒.commute (F.₁ f) ○ D.identityʳ } } ⊤-arr : Cone⇒ (R ∘F F′) coneF RLimF′ ⊤-arr = LimRF′.rep-cone coneF module ⊤-arr = Cone⇒ (R ∘F F′) ⊤-arr ⊤ : Cone F ⊤ = record { N = record { f = ⊤-arr.arr } ; apex = record { ψ = λ j → record { h = LimF′.proj j ; commute = begin R.₁ (LimF′.proj j) D.∘ ⊤-arr.arr ≈⟨ ⊤-arr.commute ⟩ CommaObj.f (F.₀ j) ≈˘⟨ D.identityʳ ⟩ CommaObj.f (F.₀ j) D.∘ D.id ∎ } ; commute = λ f → -, LimF′.limit-commute f } } K-conv : Cone F → Cone F′ K-conv = F-map-Coneˡ (Cod _ _) K-conv′ : Cone F → Cone (R ∘F F′) K-conv′ K = F-map-Coneˡ R (K-conv K) ! : (K : Cone F) → Cones F [ K , ⊤ ] ! K = record { arr = record { h = LimF′.rep (K-conv K) ; commute = ⟺ (LimRF′.terminal.!-unique (record { arr = R.₁ (LimF′.rep (K-conv K)) D.∘ CommaObj.f N ; commute = λ {j} → begin LimRF′.proj j D.∘ R.₁ (LimF′.rep (K-conv K)) D.∘ CommaObj.f N ≈⟨ pullˡ ([ R ]-resp-∘ LimF′.commute) ⟩ R.₁ (Comma⇒.h (ψ j)) D.∘ CommaObj.f N ≈⟨ Comma⇒.commute (ψ j) ⟩ CommaObj.f (F.F₀ j) D.∘ D.id ≈⟨ D.identityʳ ⟩ CommaObj.f (F.₀ j) ∎ })) ○ ⟺ D.identityʳ } ; commute = -, LimF′.commute } where open Cone _ K !-unique : {K : Cone F} (f : Cones F [ K , ⊤ ]) → Cones F [ ! K ≈ f ] !-unique f = -, LimF′.terminal.!-unique record { arr = Comma⇒.h f.arr ; commute = proj₂ f.commute } where module f = Cone⇒ _ f complete : Limit F complete = record { terminal = record { ⊤ = ⊤ ; ⊤-is-terminal = record { ! = ! _ ; !-unique = !-unique } } } solutionSet′⇒universalMorphism : UniversalMorphism X R solutionSet′⇒universalMorphism = record { initial = SolutionSet⇒Initial {o′ = 0ℓ} {0ℓ} {0ℓ} {C = X ↙ R} complete s′ } solutionSet⇒adjoint : Σ (Functor D C) (λ L → L ⊣ R) solutionSet⇒adjoint = universalMophisms⇒adjoint solutionSet′⇒universalMorphism
30.29703
85
0.470915
a0fc42d2bc54ca32f3e7af4e39714eb9af7bf125
3,438
agda
Agda
agda-stdlib/src/Relation/Binary/Indexed/Homogeneous/Bundles.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Relation/Binary/Indexed/Homogeneous/Bundles.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Relation/Binary/Indexed/Homogeneous/Bundles.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- Homogeneously-indexed binary relations ------------------------------------------------------------------------ -- The contents of this module should be accessed via -- `Relation.Binary.Indexed.Homogeneous`. {-# OPTIONS --without-K --safe #-} module Relation.Binary.Indexed.Homogeneous.Bundles where open import Data.Product using (_,_) open import Function using (_⟨_⟩_) open import Level using (Level; _⊔_; suc) open import Relation.Binary as B using (_⇒_) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Nullary using (¬_) open import Relation.Binary.Indexed.Homogeneous.Core open import Relation.Binary.Indexed.Homogeneous.Structures -- Indexed structures are laid out in a similar manner as to those -- in Relation.Binary. The main difference is each structure also -- contains proofs for the lifted version of the relation. ------------------------------------------------------------------------ -- Equivalences record IndexedSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where infix 4 _≈ᵢ_ _≈_ field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ isEquivalenceᵢ : IsIndexedEquivalence Carrierᵢ _≈ᵢ_ open IsIndexedEquivalence isEquivalenceᵢ public Carrier : Set _ Carrier = ∀ i → Carrierᵢ i _≈_ : B.Rel Carrier _ _≈_ = Lift Carrierᵢ _≈ᵢ_ _≉_ : B.Rel Carrier _ x ≉ y = ¬ (x ≈ y) setoid : B.Setoid _ _ setoid = record { isEquivalence = isEquivalence } record IndexedDecSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where infix 4 _≈ᵢ_ field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ isDecEquivalenceᵢ : IsIndexedDecEquivalence Carrierᵢ _≈ᵢ_ open IsIndexedDecEquivalence isDecEquivalenceᵢ public indexedSetoid : IndexedSetoid I c ℓ indexedSetoid = record { isEquivalenceᵢ = isEquivalenceᵢ } open IndexedSetoid indexedSetoid public using (Carrier; _≈_; _≉_; setoid) ------------------------------------------------------------------------ -- Preorders record IndexedPreorder {i} (I : Set i) c ℓ₁ ℓ₂ : Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈ᵢ_ _∼ᵢ_ _≈_ _∼_ field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ₁ _∼ᵢ_ : IRel Carrierᵢ ℓ₂ isPreorderᵢ : IsIndexedPreorder Carrierᵢ _≈ᵢ_ _∼ᵢ_ open IsIndexedPreorder isPreorderᵢ public Carrier : Set _ Carrier = ∀ i → Carrierᵢ i _≈_ : B.Rel Carrier _ x ≈ y = ∀ i → x i ≈ᵢ y i _∼_ : B.Rel Carrier _ x ∼ y = ∀ i → x i ∼ᵢ y i preorder : B.Preorder _ _ _ preorder = record { isPreorder = isPreorder } ------------------------------------------------------------------------ -- Partial orders record IndexedPoset {i} (I : Set i) c ℓ₁ ℓ₂ : Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ₁ _≤ᵢ_ : IRel Carrierᵢ ℓ₂ isPartialOrderᵢ : IsIndexedPartialOrder Carrierᵢ _≈ᵢ_ _≤ᵢ_ open IsIndexedPartialOrder isPartialOrderᵢ public preorderᵢ : IndexedPreorder I c ℓ₁ ℓ₂ preorderᵢ = record { isPreorderᵢ = isPreorderᵢ } open IndexedPreorder preorderᵢ public using (Carrier; _≈_; preorder) renaming (_∼_ to _≤_) poset : B.Poset _ _ _ poset = record { isPartialOrder = isPartialOrder }
27.285714
73
0.587551
34072165c2d17f70c9829ee3d74f5e9cf92307e5
607
agda
Agda
test/Succeed/Issue483.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue483.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue483.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2011-10-02 -- {-# OPTIONS -v tc.meta:20 #-} module Issue483 where data _≡_ (a : Set) : Set → Set where refl : a ≡ a test : (P : .Set → Set) → let X : .Set → Set X = _ in (x : Set) → X x ≡ P (P x) test P x = refl -- expected behavior: solving X = P {- THE FOLLOWING COULD BE SOLVED IN THE SPECIFIC CASE, BUT NOT IN GENERAL postulate A : Set a : A f : .A → A test2 : let X : .A → A X = _ in (x : A) → X a ≡ f x test2 x = refl -- should solve as X = f -- it was treated as X _ = f _ before with solution X = \ x -> f _ -- which eta-contracts to X = f -}
20.931034
74
0.540362
cbf49c5c36f0507d252af84a749fe41c44e119a5
543
agda
Agda
test/Fail/RewritingNonConfluent1.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/RewritingNonConfluent1.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/RewritingNonConfluent1.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Nat using (Nat; zero; suc) open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite variable k l m n : Nat postulate max : Nat → Nat → Nat max-0l : max 0 n ≡ n max-0r : max m 0 ≡ m max-diag : max m m ≡ m max-ss : max (suc m) (suc n) ≡ suc (max m n) max-assoc : max (max k l) m ≡ max k (max l m) {-# REWRITE max-0l #-} {-# REWRITE max-0r #-} {-# REWRITE max-diag #-} {-# REWRITE max-ss #-} {-# REWRITE max-assoc #-} -- not confluent!
22.625
51
0.61326
35d0191060b48fa96dc95ee2edbe1eb7c418e202
8,156
agda
Agda
legacy/Data/Num.agda
banacorn/numeral
aae093cc9bf21f11064e7f7b12049448cd6449f1
[ "MIT" ]
1
2015-04-23T15:58:28.000Z
2015-04-23T15:58:28.000Z
legacy/Data/Num.agda
banacorn/numeral
aae093cc9bf21f11064e7f7b12049448cd6449f1
[ "MIT" ]
null
null
null
legacy/Data/Num.agda
banacorn/numeral
aae093cc9bf21f11064e7f7b12049448cd6449f1
[ "MIT" ]
1
2015-05-30T05:50:50.000Z
2015-05-30T05:50:50.000Z
module Data.Num where open import Data.List using (List; []; _∷_; foldr) open import Data.Nat open ≤-Reasoning open import Data.Nat.Etc open import Data.Nat.DivMod open import Data.Nat.DivMod.Properties using (div-mono) open import Data.Nat.Properties using (m≤m+n; n≤m+n;_+-mono_; pred-mono; ∸-mono; ≰⇒>; n∸n≡0; +-∸-assoc; m+n∸n≡m) open import Data.Nat.Properties.Simple using (+-right-identity; +-suc; +-assoc; +-comm; distribʳ-*-+) open import Data.Fin.Properties using (bounded) open import Data.Fin using (Fin; fromℕ≤; inject≤; #_) renaming (toℕ to F→N; fromℕ to N→F; zero to Fz; suc to Fs) open import Data.Product open import Data.Maybe open import Induction.Nat using (rec; Rec) import Level open import Function open import Data.Unit using (tt) open import Relation.Nullary open import Relation.Nullary.Decidable using (True; False; toWitness; toWitnessFalse; fromWitness; fromWitnessFalse) open import Relation.Nullary.Negation using (contradiction; contraposition) open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; sym; trans; inspect) open PropEq.≡-Reasoning renaming (begin_ to beginEq_; _≡⟨_⟩_ to _≡Eq⟨_⟩_; _∎ to _∎Eq) -- Surjective (ℕm): -- base = 1, digits = {m ... (m + n) - 1}, m ≥ 1, n ≥ m -- base > 1, digits = {m ... (m + n) - 1}, m ≥ 0, n ≥ max base (base × m) -- Bijective: -- base ≥ 1, digits = {1 .. base} -- -- Digits: -- Digit m n represents a Digit ranging from m to (m + n - 1) -- e.g. Digit 2 0 2 = {0, 1} for ordinary binary number -- Digit 2 1 2 = {1, 2} for zeroless binary number -- Digit 2 0 3 = {0, 1, 2} for redundant binary number -- data Digit : (base from range : ℕ) → Set where -- unary digit: {0, 1 .. n-1} U0 : ∀ {n} → Fin n → {2≤n : True (2 ≤? n)} -- i.e. must have digit '1' → Digit 1 0 n -- unary digit: {m .. m+n-1} U1 : ∀ {m n} → Fin n → {m≤n : True (suc m ≤? n)} → Digit 1 (suc m) n -- k-adic digit: {m .. m+n-1} D : ∀ {b m n} → Fin n → let base = suc (suc b) in {b≤n : True (base ≤? n)} → {bm≤n : True ((base * m) ≤? n)} → Digit base m n -- without offset, {0 .. n-1} D→F : ∀ {b m n} → Digit b m n → Fin n D→F (U0 x) = x D→F (U1 x) = x D→F (D x) = x -- with offset, {m .. m+n-1} D→N : ∀ {b m n} → Digit b m n → ℕ D→N {m = m} d = m + F→N (D→F d) -- infix 4 _D≤_ -- _D<_ _≥′_ _>′_ -- data _D≤_ {b m n} (x : Digit b m n) : (y : Digit b m n) → Set where -- D≤-refl : x D≤ x -- D≤-step : ∀ {y} (xD≤y : x D≤ y) → x D≤ -- ≤′-step : ∀ {n} (m≤′n : m ≤′ n) → m ≤′ suc n private -- alias ℕ-isDecTotalOrder = DecTotalOrder.isDecTotalOrder decTotalOrder ℕ-isTotalOrder = IsDecTotalOrder.isTotalOrder ℕ-isDecTotalOrder ℕ-isPartialOrder = IsTotalOrder.isPartialOrder ℕ-isTotalOrder ℕ-isPreorder = IsPartialOrder.isPreorder ℕ-isPartialOrder ≤-refl = IsPreorder.reflexive ℕ-isPreorder ≤-antisym = IsPartialOrder.antisym ℕ-isPartialOrder ≤-total = IsTotalOrder.total ℕ-isTotalOrder -- helper function for adding two 'Fin n' with offset 'm' -- (m + x) + (m + y) - m = m + x + y D+sum : ∀ {n} (m : ℕ) → (x y : Fin n) → ℕ D+sum m x y = m + (F→N x) + (F→N y) maxpress-pred : ℕ → Set maxpress-pred _ = ℕ → ℕ maxpress-rec-struct : (x : ℕ) → Rec Level.zero maxpress-pred x → (bound : ℕ) → ℕ maxpress-rec-struct zero p bound = 0 maxpress-rec-struct (suc x) p bound with bound ≤? suc (p bound) maxpress-rec-struct (suc x) p bound | yes q = suc (p bound) ∸ bound maxpress-rec-struct (suc x) p bound | no ¬q = suc (p bound) -- if x ≥ bound, then substract bound from x, until x < bound maxpress : (x bound : ℕ) → ℕ maxpress = rec maxpress-pred maxpress-rec-struct maxpressed<bound : (x bound : ℕ) → (≢0 : False (bound ≟ 0)) → maxpress x bound < bound maxpressed<bound zero zero () maxpressed<bound zero (suc bound) ≢0 = s≤s z≤n maxpressed<bound (suc x) zero () maxpressed<bound (suc x) (suc bound) ≢0 with suc bound ≤? suc (maxpress x (suc bound)) maxpressed<bound (suc x) (suc bound) ≢0 | yes p = begin suc (maxpress x (suc bound) ∸ bound) ≤⟨ ≤-refl (sym (+-∸-assoc 1 p)) ⟩ suc (maxpress x (suc bound)) ∸ bound ≤⟨ ∸-mono {suc (maxpress x (suc bound))} {suc bound} {bound} {bound} (maxpressed<bound x (suc bound) tt) (≤-refl refl) ⟩ suc bound ∸ bound ≤⟨ ≤-refl (m+n∸n≡m 1 bound) ⟩ suc zero ≤⟨ s≤s z≤n ⟩ suc bound ∎ maxpressed<bound (suc x) (suc bound) ≢0 | no ¬p = ≰⇒> ¬p maxpress′ : (x bound : ℕ) → (≢0 : False (bound ≟ 0)) → Fin bound maxpress′ x bound ≢0 = fromℕ≤ {maxpress x bound} (maxpressed<bound x bound ≢0) _D+_ : ∀ {b m n} → Digit b m n → Digit b m n → Digit b m n _D+_ {zero} () () _D+_ {suc zero} x _ = x _D+_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) = D (maxpress′ (D+sum m x y) n n≢0) {b≤n} {bm≤n} where n≢0 = fromWitnessFalse $ >⇒≢ $ begin suc zero ≤⟨ s≤s z≤n ⟩ suc (suc b) ≤⟨ toWitness b≤n ⟩ n ∎ -- 2 ≤ base -- ⇒ max * 2 ≤ max * base -- ⇒ max * 2 / base ≤ max {- _D⊕_ : ∀ {b m n} → Digit b m n → Digit b m n → Maybe (Digit b m n) _D⊕_ (U0 x) y = just y _D⊕_ (U1 x) y = just y _D⊕_ {suc (suc b)} {m} {n} (D x) (D y) with suc (D+sum m x y) ≤? n _D⊕_ {suc (suc b)} {m} {n} (D x) (D y) | yes p = nothing _D⊕_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) | no ¬p with D+sum m x y divMod (suc (suc b)) | inspect (λ w → _divMod_ (D+sum m x y) (suc (suc b)) {≢0 = w}) tt _D⊕_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) | no ¬p | result quotient remainder property | PropEq.[ eq ] = let base = suc (suc b) sum = D+sum m x y quotient<n = begin suc quotient ≤⟨ div-mono base tt {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ n ∎ in just (D (fromℕ≤ {quotient} quotient<n) {b≤n} {bm≤n}) -} {- let base = suc (suc b) sum = D+sum m x y result quotient remainder property = _divMod_ sum base {tt} quotient<n = begin DivMod.quotient (sum divMod {! base !}) ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ n ∎ in just (D (fromℕ≤ {quotient} quotient<n) {b≤n} {bm≤n}) -} {- begin {! !} <⟨ {! !} ⟩ {! !} <⟨ {! !} ⟩ {! !} ∎ begin {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ∎ beginEq {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ∎Eq -} data System : (base from range : ℕ) → Set where Sys : ∀ {b m n} → List (Digit (suc b) m n) → System (suc b) m n {- _S+_ : ∀ {b m n} → System b m n → System b m n → System b m n Sys [] S+ Sys ys = Sys ys Sys xs S+ Sys [] = Sys xs Sys (x ∷ xs) S+ Sys (y ∷ ys) = {! x !} S→N : ∀ {b m n} → System b m n → ℕ S→N {zero} () S→N {suc b} (Sys list) = foldr (shift-then-add (suc b)) 0 list where shift-then-add : ∀ {m n} → (b : ℕ) → Digit b m n → ℕ → ℕ shift-then-add b x acc = (D→N x) + (acc * b) -} -- -- Example -- private one : Digit 2 1 2 one = D Fz two : Digit 2 1 2 two = D (Fs Fz) u0 : Digit 1 0 2 u0 = U0 Fz u1 : Digit 1 1 1 u1 = U1 Fz a0 : Digit 3 0 4 a0 = D Fz a1 : Digit 3 0 4 a1 = D (Fs Fz) a2 : Digit 3 0 4 a2 = D (Fs (Fs Fz)) a3 : Digit 3 0 4 a3 = D (Fs (Fs (Fs Fz))) a : System 2 1 2 a = Sys (one ∷ two ∷ two ∷ [])
30.319703
164
0.48541
437bf4eb1819e32a63725fd04ff37541f4169d0a
10,911
agda
Agda
Cubical/Foundations/HLevels.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
Cubical/Foundations/HLevels.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
Cubical/Foundations/HLevels.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
{- Basic theory about h-levels/n-types: - Basic properties of isContr, isProp and isSet (definitions are in Prelude) - Hedberg's theorem can be found in Cubical/Relation/Nullary/DecidableEq -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.HLevels where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.FunExtEquiv open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Path open import Cubical.Foundations.Transport open import Cubical.Foundations.HAEquiv using (congEquiv) open import Cubical.Foundations.Univalence using (ua; univalence) open import Cubical.Data.Sigma using (ΣPathP; sigmaPath→pathSigma; pathSigma≡sigmaPath; _Σ≡T_) open import Cubical.Data.Nat using (ℕ; zero; suc; _+_; +-comm) private variable ℓ ℓ' : Level A : Type ℓ B : A → Type ℓ x y : A n : ℕ hProp : ∀ ℓ → Type (ℓ-suc ℓ) hProp ℓ = Σ (Type ℓ) isProp isOfHLevel : ℕ → Type ℓ → Type ℓ isOfHLevel 0 A = isContr A isOfHLevel 1 A = isProp A isOfHLevel (suc (suc n)) A = (x y : A) → isOfHLevel (suc n) (x ≡ y) HLevel : ∀ ℓ → ℕ → Type (ℓ-suc ℓ) HLevel ℓ n = Σ[ A ∈ Type ℓ ] (isOfHLevel n A) inhProp→isContr : A → isProp A → isContr A inhProp→isContr x h = x , h x isContrPartial→isContr : ∀ {ℓ} {A : Type ℓ} → (extend : ∀ φ → Partial φ A → A) → (∀ u → u ≡ (extend i1 λ { _ → u})) → isContr A isContrPartial→isContr {A = A} extend law = ex , λ y → law ex ∙ (λ i → Aux.v y i) ∙ sym (law y) where ex = extend i0 empty module Aux (y : A) (i : I) where φ = ~ i ∨ i u : Partial φ A u = λ { (i = i0) → ex ; (i = i1) → y } v = extend φ u -- Dependent h-level over a type isOfHLevelDep : ℕ → {A : Type ℓ} (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') isOfHLevelDep 0 {A = A} B = {a : A} → Σ[ b ∈ B a ] ({a' : A} (b' : B a') (p : a ≡ a') → PathP (λ i → B (p i)) b b') isOfHLevelDep 1 {A = A} B = {a0 a1 : A} (b0 : B a0) (b1 : B a1) (p : a0 ≡ a1) → PathP (λ i → B (p i)) b0 b1 isOfHLevelDep (suc (suc n)) {A = A} B = {a0 a1 : A} (b0 : B a0) (b1 : B a1) → isOfHLevelDep (suc n) {A = a0 ≡ a1} (λ p → PathP (λ i → B (p i)) b0 b1) isOfHLevel→isOfHLevelDep : (n : ℕ) → {A : Type ℓ} {B : A → Type ℓ'} (h : (a : A) → isOfHLevel n (B a)) → isOfHLevelDep n {A = A} B isOfHLevel→isOfHLevelDep 0 h {a} = (h a .fst , λ b' p → isProp→PathP (λ i → isContr→isProp (h (p i))) (h a .fst) b') isOfHLevel→isOfHLevelDep 1 h = λ b0 b1 p → isProp→PathP (λ i → h (p i)) b0 b1 isOfHLevel→isOfHLevelDep (suc (suc n)) {A = A} {B} h {a0} {a1} b0 b1 = isOfHLevel→isOfHLevelDep (suc n) (λ p → helper a1 p b1) where helper : (a1 : A) (p : a0 ≡ a1) (b1 : B a1) → isOfHLevel (suc n) (PathP (λ i → B (p i)) b0 b1) helper a1 p b1 = J (λ a1 p → ∀ b1 → isOfHLevel (suc n) (PathP (λ i → B (p i)) b0 b1)) (λ _ → h _ _ _) p b1 -- Fillers for cubes from h-level isSet→isSet' : isSet A → isSet' A isSet→isSet' {A = A} Aset a₀₋ a₁₋ a₋₀ a₋₁ = transport⁻ (PathP≡Path (λ i → a₋₀ i ≡ a₋₁ i) a₀₋ a₁₋) (Aset _ _ _ _) isSet'→isSet : isSet' A → isSet A isSet'→isSet {A = A} Aset' x y p q = Aset' p q refl refl isGroupoid→isGroupoid' : {A : Type ℓ} → isGroupoid A → isGroupoid' A isGroupoid→isGroupoid' {A = A} Agpd a₀₋₋ a₁₋₋ a₋₀₋ a₋₁₋ a₋₋₀ a₋₋₁ = transport⁻ (PathP≡Path (λ i → Square (a₋₀₋ i) (a₋₁₋ i) (a₋₋₀ i) (a₋₋₁ i)) a₀₋₋ a₁₋₋) (isGroupoid→isPropSquare _ _ _ _ _ _) where isGroupoid→isPropSquare : {a₀₀ a₀₁ : A} (a₀₋ : a₀₀ ≡ a₀₁) {a₁₀ a₁₁ : A} (a₁₋ : a₁₀ ≡ a₁₁) (a₋₀ : a₀₀ ≡ a₁₀) (a₋₁ : a₀₁ ≡ a₁₁) → isProp (Square a₀₋ a₁₋ a₋₀ a₋₁) isGroupoid→isPropSquare a₀₋ a₁₋ a₋₀ a₋₁ = transport⁻ (cong isProp (PathP≡Path (λ i → a₋₀ i ≡ a₋₁ i) a₀₋ a₁₋)) (Agpd _ _ _ _) isGroupoid'→isGroupoid : isGroupoid' A → isGroupoid A isGroupoid'→isGroupoid Agpd' x y p q r s = Agpd' r s refl refl refl refl -- hlevels are preserved by retracts (and consequently equivalences) retractIsContr : ∀ {B : Type ℓ} → (f : A → B) (g : B → A) → (h : retract f g) → (v : isContr B) → isContr A retractIsContr f g h (b , p) = (g b , λ x → (cong g (p (f x))) ∙ (h x)) retractIsProp : {B : Type ℓ} (f : A → B) (g : B → A) (h : (x : A) → g (f x) ≡ x) → isProp B → isProp A retractIsProp f g h p x y i = hcomp (λ j → λ { (i = i0) → h x j ; (i = i1) → h y j}) (g (p (f x) (f y) i)) retractIsOfHLevel : (n : ℕ) {B : Type ℓ} (f : A → B) (g : B → A) (h : (x : A) → g (f x) ≡ x) → isOfHLevel n B → isOfHLevel n A retractIsOfHLevel 0 = retractIsContr retractIsOfHLevel 1 = retractIsProp retractIsOfHLevel (suc (suc n)) f g h ofLevel x y = retractIsOfHLevel (suc n) (cong f) (λ q i → hcomp (λ j → λ { (i = i0) → h x j ; (i = i1) → h y j}) (g (q i))) (λ p k i → hcomp (λ j → λ { (i = i0) → h x (j ∨ k) ; (i = i1) → h y (j ∨ k) ; (k = i1) → p i}) (h (p i) k)) (ofLevel (f x) (f y)) hLevelRespectEquiv : {A : Type ℓ} {B : Type ℓ'} → (n : ℕ) → A ≃ B → isOfHLevel n A → isOfHLevel n B hLevelRespectEquiv n eq = retractIsOfHLevel n (invEq eq) (eq .fst) (retEq eq) -- hlevel of path and dependent path types isProp→isPropPathP : {A : I → Type ℓ} (isPropA : ∀ i → isProp (A i)) (g : A i0) (h : A i1) → isProp (PathP A g h) isProp→isPropPathP {A = A} isPropA g h = transport⁻ (λ i → isProp (PathP≡Path A g h i)) (isProp→isSet (isPropA i1) _ _) isProp→isContrPathP : {A : I → Type ℓ} (isPropA : ∀ i → isProp (A i)) (g : A i0) (h : A i1) → isContr (PathP A g h) isProp→isContrPathP isPropA g h = inhProp→isContr (isProp→PathP isPropA g h) (isProp→isPropPathP isPropA g h) -- inhProp→isContr (isProp→PathP (λ i → isPropB (m i)) g h) (isProp→isPropPathP isPropB m g h) isProp→isContr≡ : isProp A → (x y : A) → isContr (x ≡ y) isProp→isContr≡ isPropA x y = inhProp→isContr (isPropA x y) (isProp→isSet isPropA x y) isContrPath : isContr A → (x y : A) → isContr (x ≡ y) isContrPath cA = isProp→isContr≡ (isContr→isProp cA) hLevelPath : (n : ℕ) → isOfHLevel (suc n) A → (x y : A) → isOfHLevel n (x ≡ y) hLevelPath zero h = isProp→isContr≡ h hLevelPath (suc n) h = h -- h-level of Σ-types isContrSigma : isContr A → ((x : A) → isContr (B x)) → isContr (Σ[ x ∈ A ] B x) isContrSigma {A = A} {B = B} (a , p) q = let h : (x : A) (y : B x) → (q x) .fst ≡ y h x y = (q x) .snd y in (( a , q a .fst) , ( λ x i → p (x .fst) i , h (p (x .fst) i) (transp (λ j → B (p (x .fst) (i ∨ ~ j))) i (x .snd)) i)) ΣProp≡ : ((x : A) → isProp (B x)) → {u v : Σ[ a ∈ A ] B a} → (p : u .fst ≡ v .fst) → u ≡ v ΣProp≡ pB {u} {v} p i = (p i) , isProp→PathP (λ i → pB (p i)) (u .snd) (v .snd) i isPropSigma : isProp A → ((x : A) → isProp (B x)) → isProp (Σ[ x ∈ A ] B x) isPropSigma pA pB t u = ΣProp≡ pB (pA (t .fst) (u .fst)) isOfHLevelΣ : ∀ n → isOfHLevel n A → ((x : A) → isOfHLevel n (B x)) → isOfHLevel n (Σ A B) isOfHLevelΣ 0 = isContrSigma isOfHLevelΣ 1 = isPropSigma isOfHLevelΣ {B = B} (suc (suc n)) h1 h2 x y = let h3 : isOfHLevel (suc n) (x Σ≡T y) h3 = isOfHLevelΣ (suc n) (h1 (fst x) (fst y)) λ p → h2 (p i1) (subst B p (snd x)) (snd y) in transport (λ i → isOfHLevel (suc n) (pathSigma≡sigmaPath x y (~ i))) h3 -- h-level of Π-types propPi : (h : (x : A) → isProp (B x)) → isProp ((x : A) → B x) propPi h f0 f1 i x = h x (f0 x) (f1 x) i hLevelPi : ∀ n → ((x : A) → isOfHLevel n (B x)) → isOfHLevel n ((x : A) → B x) hLevelPi 0 h = (λ x → fst (h x)) , λ f i y → snd (h y) (f y) i hLevelPi {B = B} 1 h f g i x = (h x) (f x) (g x) i hLevelPi (suc (suc n)) h f g = subst (isOfHLevel (suc n)) funExtPath (hLevelPi (suc n) λ x → h x (f x) (g x)) isSetPi : ((x : A) → isSet (B x)) → isSet ((x : A) → B x) isSetPi Bset = hLevelPi 2 (λ a → Bset a) -- lower h-levels imply higher h-levels hLevelSuc : (n : ℕ) (A : Type ℓ) → isOfHLevel n A → isOfHLevel (suc n) A hLevelSuc 0 A = isContr→isProp hLevelSuc 1 A = isProp→isSet hLevelSuc (suc (suc n)) A h a b = hLevelSuc (suc n) (a ≡ b) (h a b) hLevelLift : (m : ℕ) (hA : isOfHLevel n A) → isOfHLevel (m + n) A hLevelLift zero hA = hA hLevelLift {A = A} (suc m) hA = hLevelSuc _ A (hLevelLift m hA) -- h-level of isOfHLevel isPropIsProp : isProp (isProp A) isPropIsProp f g i a b = isProp→isSet f a b (f a b) (g a b) i isPropIsOfHLevel : (n : ℕ) (A : Type ℓ) → isProp (isOfHLevel n A) isPropIsOfHLevel 0 A = isPropIsContr isPropIsOfHLevel 1 A = isPropIsProp isPropIsOfHLevel (suc (suc n)) A f g i a b = isPropIsOfHLevel (suc n) (a ≡ b) (f a b) (g a b) i isPropIsSet : isProp (isSet A) isPropIsSet {A = A} = isPropIsOfHLevel 2 A -- h-level of A ≃ B and A ≡ B hLevel≃ : ∀ n → {A B : Type ℓ} (hA : isOfHLevel n A) (hB : isOfHLevel n B) → isOfHLevel n (A ≃ B) hLevel≃ zero {A = A} {B = B} hA hB = A≃B , contr where A≃B : A ≃ B A≃B = isoToEquiv (iso (λ _ → fst hB) (λ _ → fst hA) (snd hB ) (snd hA)) contr : (y : A ≃ B) → A≃B ≡ y contr y = ΣProp≡ isPropIsEquiv (funExt (λ a → snd hB (fst y a))) hLevel≃ (suc n) hA hB = isOfHLevelΣ (suc n) (hLevelPi (suc n) (λ _ → hB)) (λ a → subst (λ n → isOfHLevel n (isEquiv a)) (+-comm n 1) (hLevelLift n (isPropIsEquiv a))) hLevel≡ : ∀ n → {A B : Type ℓ} (hA : isOfHLevel n A) (hB : isOfHLevel n B) → isOfHLevel n (A ≡ B) hLevel≡ n hA hB = hLevelRespectEquiv n (invEquiv univalence) (hLevel≃ n hA hB) -- h-level of HLevel HLevel≡ : ∀ {A B : Type ℓ} {hA : isOfHLevel n A} {hB : isOfHLevel n B} → (A ≡ B) ≡ ((A , hA) ≡ (B , hB)) HLevel≡ {n = n} {A = A} {B = B} {hA} {hB} = isoToPath (iso intro elim intro-elim elim-intro) where intro : A ≡ B → (A , hA) ≡ (B , hB) intro eq = ΣProp≡ (λ A → isPropIsOfHLevel n _) eq elim : (A , hA) ≡ (B , hB) → A ≡ B elim = cong fst intro-elim : ∀ x → intro (elim x) ≡ x intro-elim eq = cong ΣPathP (ΣProp≡ (λ e → J (λ B e → ∀ k → (x y : PathP (λ i → isOfHLevel n (e i)) hA k) → x ≡ y) (λ k → isProp→isSet (isPropIsOfHLevel n _) _ _) e hB) refl) elim-intro : ∀ x → elim (intro x) ≡ x elim-intro eq = refl isPropHContr : isProp (HLevel ℓ 0) isPropHContr x y = ΣProp≡ (λ _ → isPropIsContr) ((hLevel≡ 0 (x .snd) (y .snd) .fst)) hLevelHLevel : ∀ n → isOfHLevel (suc n) (HLevel ℓ n) hLevelHLevel 0 = isPropHContr hLevelHLevel (suc n) x y = subst (λ e → isOfHLevel (suc n) e) HLevel≡ (hLevel≡ (suc n) (snd x) (snd y)) isSetHProp : isSet (hProp ℓ) isSetHProp = hLevelHLevel 1 -- h-level of lifted type isOfHLevelLift : ∀ {ℓ ℓ'} (n : ℕ) {A : Type ℓ} → isOfHLevel n A → isOfHLevel n (Lift {j = ℓ'} A) isOfHLevelLift n = retractIsOfHLevel n lower lift λ _ → refl
34.971154
150
0.56136
22b17a03b41880725c723b0795dfa7c90256bcd0
3,760
agda
Agda
TotalParserCombinators/Laws/ReturnStar.agda
nad/parser-combinators
76774f54f466cfe943debf2da731074fe0c33644
[ "MIT" ]
1
2020-07-03T08:56:13.000Z
2020-07-03T08:56:13.000Z
TotalParserCombinators/Laws/ReturnStar.agda
nad/parser-combinators
76774f54f466cfe943debf2da731074fe0c33644
[ "MIT" ]
null
null
null
TotalParserCombinators/Laws/ReturnStar.agda
nad/parser-combinators
76774f54f466cfe943debf2da731074fe0c33644
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Laws related to return⋆ ------------------------------------------------------------------------ module TotalParserCombinators.Laws.ReturnStar where open import Algebra open import Category.Monad open import Codata.Musical.Notation open import Data.List import Data.List.Categorical open import Data.List.Relation.Binary.BagAndSetEquality as Eq using (bag) renaming (_∼[_]_ to _List-∼[_]_) open import Function open import Level private module BagMonoid {A : Set} = CommutativeMonoid (Eq.commutativeMonoid bag A) open module ListMonad = RawMonad {f = zero} Data.List.Categorical.monad using () renaming (_⊛_ to _⊛′_; _>>=_ to _>>=′_) open import TotalParserCombinators.Derivative using (D) open import TotalParserCombinators.Congruence hiding (fail) import TotalParserCombinators.Laws.AdditiveMonoid as AdditiveMonoid open import TotalParserCombinators.Laws.Derivative open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser -- return⋆ preserves equality. cong : ∀ {k Tok R} {xs₁ xs₂ : List R} → xs₁ List-∼[ k ] xs₂ → return⋆ {Tok = Tok} xs₁ ∼[ k ]P return⋆ xs₂ cong {xs₁ = xs₁} {xs₂} xs₁≈xs₂ = xs₁≈xs₂ ∷ λ t → ♯ ( D t (return⋆ xs₁) ≅⟨ D-return⋆ xs₁ ⟩ fail ≅⟨ sym $ D-return⋆ xs₂ ⟩ D t (return⋆ xs₂) ∎) -- return⋆ is homomorphic with respect to _++_/_∣_. distrib-∣ : ∀ {Tok R} (xs₁ xs₂ : List R) → return⋆ {Tok = Tok} (xs₁ ++ xs₂) ≅P return⋆ xs₁ ∣ return⋆ xs₂ distrib-∣ xs₁ xs₂ = BagMonoid.refl ∷ λ t → ♯ ( D t (return⋆ (xs₁ ++ xs₂)) ≅⟨ D-return⋆ (xs₁ ++ xs₂) ⟩ fail ≅⟨ sym $ AdditiveMonoid.left-identity fail ⟩ fail ∣ fail ≅⟨ sym $ D-return⋆ xs₁ ∣ D-return⋆ xs₂ ⟩ D t (return⋆ xs₁) ∣ D t (return⋆ xs₂) ∎) -- return⋆ is homomorphic with respect to _⊛′_/_⊛_. distrib-⊛ : ∀ {Tok R₁ R₂} (fs : List (R₁ → R₂)) xs → return⋆ {Tok = Tok} (fs ⊛′ xs) ≅P return⋆ fs ⊛ return⋆ xs distrib-⊛ fs xs = BagMonoid.refl ∷ λ t → ♯ ( D t (return⋆ (fs ⊛′ xs)) ≅⟨ D-return⋆ (fs ⊛′ xs) ⟩ fail ≅⟨ sym $ AdditiveMonoid.left-identity fail ⟩ fail ∣ fail ≅⟨ sym $ left-zero-⊛ (return⋆ xs) ∣ right-zero-⊛ (return⋆ fs) ⟩ fail ⊛ return⋆ xs ∣ return⋆ fs ⊛ fail ≅⟨ sym $ [ ○ - ○ - ○ - ○ ] D-return⋆ fs ⊛ (return⋆ xs ∎) ∣ [ ○ - ○ - ○ - ○ ] return⋆ fs ∎ ⊛ D-return⋆ xs ⟩ D t (return⋆ fs) ⊛ return⋆ xs ∣ return⋆ fs ⊛ D t (return⋆ xs) ≅⟨ sym $ D-⊛ (return⋆ fs) (return⋆ xs) ⟩ D t (return⋆ fs ⊛ return⋆ xs) ∎) -- return⋆ is homomorphic with respect to _>>=′_/_>>=_. distrib->>= : ∀ {Tok R₁ R₂} xs (f : R₁ → List R₂) → return⋆ {Tok = Tok} (xs >>=′ f) ≅P return⋆ xs >>= (return⋆ ∘ f) distrib->>= xs f = BagMonoid.refl ∷ λ t → ♯ ( D t (return⋆ (xs >>=′ f)) ≅⟨ D-return⋆ (xs >>=′ f) ⟩ fail ≅⟨ sym $ AdditiveMonoid.left-identity fail ⟩ fail ∣ fail ≅⟨ sym $ left-zero->>= (return⋆ ∘ f) ∣ right-zero->>= (return⋆ xs) ⟩ fail >>= (return⋆ ∘ f) ∣ return⋆ xs >>= (λ _ → fail) ≅⟨ sym $ [ ○ - ○ - ○ - ○ ] D-return⋆ xs >>= (λ x → return⋆ (f x) ∎) ∣ [ ○ - ○ - ○ - ○ ] return⋆ xs ∎ >>= (λ x → D-return⋆ (f x)) ⟩ D t (return⋆ xs) >>= (return⋆ ∘ f) ∣ return⋆ xs >>= (λ x → D t (return⋆ (f x))) ≅⟨ sym $ D->>= (return⋆ xs) (return⋆ ∘ f) ⟩ D t (return⋆ xs >>= (return⋆ ∘ f)) ∎)
40
117
0.488032
c783d28c18ad643a710e5b0fc42fdc81970f51d5
4,497
agda
Agda
theorems/groups/ProductRepr.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
theorems/groups/ProductRepr.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
theorems/groups/ProductRepr.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT module groups.ProductRepr {i j} {G : Group (lmax i j)} {H₁ : Group i} {H₂ : Group j} (i₁ : H₁ →ᴳ G) (i₂ : H₂ →ᴳ G) (j₁ : G →ᴳ H₁) (j₂ : G →ᴳ H₂) (p₁ : ∀ h₁ → GroupHom.f j₁ (GroupHom.f i₁ h₁) == h₁) (p₂ : ∀ h₂ → GroupHom.f j₂ (GroupHom.f i₂ h₂) == h₂) (ex₁ : is-exact i₁ j₂) (ex₂ : is-exact i₂ j₁) where {- Given the following commutative diagram of homomorphisms, H₁ i₁ i₂ H₂ ↘ ↙ id ↓ G ↓ id ↙ ↘ H₁ j₁ j₂ H₂ - assuming i₁,j₂ and i₂,j₁ are exact sequences, - there exists an isomorphism G == H₁ × H₂ such that i₁,i₂ correspond - to the natural injections and j₁,j₂ correspond to the natural - projections. -} private module G = Group G module H₁ = Group H₁ module H₂ = Group H₂ module i₁ = GroupHom i₁ module i₂ = GroupHom i₂ module j₁ = GroupHom j₁ module j₂ = GroupHom j₂ fanout-has-trivial-ker : has-trivial-kerᴳ (×ᴳ-fanout j₁ j₂) fanout-has-trivial-ker g q = Trunc-rec (G.El-level _ _) (lemma g (fst×= q)) (ker-sub-im ex₁ g (snd×= q)) where lemma : ∀ g → j₁.f g == H₁.ident → hfiber i₁.f g → g == G.ident lemma ._ r (h , idp) = ap i₁.f (! (p₁ h) ∙ r) ∙ i₁.pres-ident β₁ : (h₁ : H₁.El) (h₂ : H₂.El) → j₁.f (G.comp (i₁.f h₁) (i₂.f h₂)) == h₁ β₁ h₁ h₂ = j₁.pres-comp (i₁.f h₁) (i₂.f h₂) ∙ ap2 H₁.comp (p₁ h₁) (im-sub-ker ex₂ _ [ h₂ , idp ]) ∙ H₁.unit-r h₁ β₂ : (h₁ : H₁.El) (h₂ : H₂.El) → j₂.f (G.comp (i₁.f h₁) (i₂.f h₂)) == h₂ β₂ h₁ h₂ = j₂.pres-comp (i₁.f h₁) (i₂.f h₂) ∙ ap2 H₂.comp (im-sub-ker ex₁ _ [ h₁ , idp ]) (p₂ h₂) ∙ H₂.unit-l h₂ iso : G ≃ᴳ (H₁ ×ᴳ H₂) iso = surjᴳ-and-injᴳ-iso (×ᴳ-fanout j₁ j₂) (λ {(h₁ , h₂) → [ G.comp (i₁.f h₁) (i₂.f h₂) , pair×= (β₁ h₁ h₂) (β₂ h₁ h₂) ]}) (has-trivial-ker-is-injᴳ (×ᴳ-fanout j₁ j₂) fanout-has-trivial-ker) j₁-fst-comm-sqr : CommSquareᴳ j₁ ×ᴳ-fst (–>ᴳ iso) (idhom _) j₁-fst-comm-sqr = comm-sqrᴳ λ _ → idp j₂-snd-comm-sqr : CommSquareᴳ j₂ (×ᴳ-snd {G = H₁}) (–>ᴳ iso) (idhom _) j₂-snd-comm-sqr = comm-sqrᴳ λ _ → idp abstract i₁-inl-comm-sqr : CommSquareᴳ i₁ ×ᴳ-inl (idhom _) (–>ᴳ iso) i₁-inl-comm-sqr = comm-sqrᴳ λ h₁ → pair×= (p₁ h₁) (im-sub-ker ex₁ _ [ h₁ , idp ]) i₂-inr-comm-sqr : CommSquareᴳ i₂ ×ᴳ-inr (idhom _) (–>ᴳ iso) i₂-inr-comm-sqr = comm-sqrᴳ λ h₂ → pair×= (im-sub-ker ex₂ _ [ h₂ , idp ]) (p₂ h₂) {- Given additionally maps i₀ j₀ K –––→ G ––→ L - such that j₀∘i₀ = 0, we have j₀(i₁(j₁(i₀ k)))⁻¹ = j₀(i₂(j₂(i₀ k))). - (This is called the hexagon lemma in Eilenberg & Steenrod's book. - The hexagon is not visible in this presentation.) -} module HexagonLemma {k l} {K : Group k} {L : Group l} (i₀ : K →ᴳ G) (j₀ : G →ᴳ L) (ex₀ : ∀ g → GroupHom.f j₀ (GroupHom.f i₀ g) == Group.ident L) where abstract decomp : ∀ g → G.comp (i₁.f (j₁.f g)) (i₂.f (j₂.f g)) == g decomp g = <– (ap-equiv (GroupIso.f-equiv iso) _ g) $ GroupIso.f iso (G.comp (i₁.f (j₁.f g)) (i₂.f (j₂.f g))) =⟨ GroupIso.pres-comp iso (i₁.f (j₁.f g)) (i₂.f (j₂.f g)) ⟩ Group.comp (H₁ ×ᴳ H₂) (GroupIso.f iso (i₁.f (j₁.f g))) (GroupIso.f iso (i₂.f (j₂.f g))) =⟨ ap2 (Group.comp (H₁ ×ᴳ H₂)) ((i₁-inl-comm-sqr □$ᴳ j₁.f g) ∙ ap (_, H₂.ident) (j₁-fst-comm-sqr □$ᴳ g)) ((i₂-inr-comm-sqr □$ᴳ j₂.f g) ∙ ap (H₁.ident ,_) (j₂-snd-comm-sqr □$ᴳ g)) ⟩ (H₁.comp (fst (GroupIso.f iso g)) H₁.ident , H₂.comp H₂.ident (snd (GroupIso.f iso g))) =⟨ pair×= (H₁.unit-r (fst (GroupIso.f iso g))) (H₂.unit-l (snd (GroupIso.f iso g))) ⟩ (fst (GroupIso.f iso g) , snd (GroupIso.f iso g)) =⟨ idp ⟩ GroupIso.f iso g =∎ cancel : ∀ k → Group.comp L (GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k) (GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k) == Group.ident L cancel k = ! (GroupHom.pres-comp j₀ _ _) ∙ ap (GroupHom.f j₀) (decomp (GroupHom.f i₀ k)) ∙ ex₀ k inv₁ : ∀ k → Group.inv L (GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k) == GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k inv₁ k = Group.inv-unique-r L _ _ (cancel k) inv₂ : ∀ k → Group.inv L (GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k) == GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k inv₂ k = Group.inv-unique-l L _ _ (cancel k)
35.690476
95
0.522793