Search is not available for this dataset
text
string
meta
dict
-- Minimal implicational modal logic, vector-based de Bruijn approach, initial encoding module Vi.BoxMp where open import Lib using (Nat; suc; _+_; Fin; fin; Vec; []; _,_; proj; VMem; mem) -- Types infixr 0 _=>_ data Ty : Set where UNIT : Ty _=>_ : Ty -> Ty -> Ty BOX : Ty -> Ty -- Context and truth/validity judgements Cx : Nat -> Set Cx n = Vec Ty n isTrue : forall {tn} -> Ty -> Fin tn -> Cx tn -> Set isTrue a i tc = VMem a i tc isValid : forall {vn} -> Ty -> Fin vn -> Cx vn -> Set isValid a i vc = VMem a i vc -- Terms module BoxMp where infixl 1 _$_ infixr 0 lam=>_ data Tm {vn tn} (vc : Cx vn) (tc : Cx tn) : Ty -> Set where var : forall {a i} -> isTrue a i tc -> Tm vc tc a lam=>_ : forall {a b} -> Tm vc (tc , a) b -> Tm vc tc (a => b) _$_ : forall {a b} -> Tm vc tc (a => b) -> Tm vc tc a -> Tm vc tc b var# : forall {a i} -> isValid a i vc -> Tm vc tc a box : forall {a} -> Tm vc [] a -> Tm vc tc (BOX a) unbox'' : forall {a b} -> Tm vc tc (BOX a) -> Tm (vc , a) tc b -> Tm vc tc b syntax unbox'' x' x = unbox x' => x v : forall {vn tn} {vc : Cx vn} (k : Nat) {tc : Cx (suc (k + tn))} -> Tm vc tc (proj tc (fin k)) v i = var (mem i) v# : forall {vn tn} (k : Nat) {vc : Cx (suc (k + vn))} {tc : Cx tn} -> Tm vc tc (proj vc (fin k)) v# i = var# (mem i) Thm : Ty -> Set Thm a = forall {vn tn} {vc : Cx vn} {tc : Cx tn} -> Tm vc tc a open BoxMp public -- Example theorems rNec : forall {a} -> Thm a -> Thm (BOX a) rNec x = box x aK : forall {a b} -> Thm (BOX (a => b) => BOX a => BOX b) aK = lam=> lam=> (unbox v 1 => unbox v 0 => box (v# 1 $ v# 0)) aT : forall {a} -> Thm (BOX a => a) aT = lam=> (unbox v 0 => v# 0) a4 : forall {a} -> Thm (BOX a => BOX (BOX a)) a4 = lam=> (unbox v 0 => box (box (v# 0))) t1 : forall {a} -> Thm (a => BOX (a => a)) t1 = lam=> box (lam=> (v 0))
{ "alphanum_fraction": 0.4853598015, "avg_line_length": 24.5731707317, "ext": "agda", "hexsha": "d61c068ef2080c711cab80de0fc8f2f76d60ed14", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_path": "src/Vi/BoxMp.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_path": "src/Vi/BoxMp.agda", "max_line_length": 99, "max_stars_count": 26, "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_path": "src/Vi/BoxMp.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "num_tokens": 787, "size": 2015 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use the -- Relation.Binary.Construct.Closure.ReflexiveTransitive module directly ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Star where open import Relation.Binary.Construct.Closure.ReflexiveTransitive public {-# WARNING_ON_IMPORT "Data.Star was deprecated in v0.16. Use Relation.Binary.Construct.Closure.ReflexiveTransitive instead." #-}
{ "alphanum_fraction": 0.5793226381, "avg_line_length": 31.1666666667, "ext": "agda", "hexsha": "758a4970c8facec793922e902c31203aee18c78a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Star.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Star.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Star.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 101, "size": 561 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Lex.Core directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Lex.Core where open import Data.List.Relation.Binary.Lex.Core public {-# WARNING_ON_IMPORT "Data.List.Relation.Lex.Core was deprecated in v1.0. Use Data.List.Relation.Binary.Lex.Core instead." #-}
{ "alphanum_fraction": 0.5387523629, "avg_line_length": 29.3888888889, "ext": "agda", "hexsha": "d965533c3f73da0dd40821ffb3f47df3a153c596", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Lex/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Lex/Core.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Lex/Core.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 98, "size": 529 }
module Issue2487-1 where postulate get-out-of-jail : {A : Set} -> A
{ "alphanum_fraction": 0.6811594203, "avg_line_length": 17.25, "ext": "agda", "hexsha": "76c5ef4dd787eb05f479f2d5dc0e1c260c352b70", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2487-1.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2487-1.agda", "max_line_length": 42, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2487-1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 24, "size": 69 }
{-# OPTIONS --without-K #-} module overloading.level where open import sum open import equality.core open import overloading.bundle open import function.isomorphism open import hott.level.core open import sets.unit open Bundle bundle-structure-iso : ∀ {i j}{Base : Set i} (Struct : Base → Set j) → Σ Base Struct ≅ Bundle Struct bundle-structure-iso Struct = record { to = λ { (X , s) → bundle X s } ; from = λ { (bundle X s) → X , s } ; iso₁ = λ _ → refl ; iso₂ = λ _ → refl } bundle-equality-iso : ∀ {i j}{Base : Set i} (Struct : Base → Set j) → ((B : Base) → h 1 (Struct B)) → {X Y : Bundle Struct} → (parent X ≡ parent Y) ≅ (X ≡ Y) bundle-equality-iso Struct hS {X}{Y} = begin parent X ≡ parent Y ≅⟨ sym≅ ×-right-unit ⟩ ((parent X ≡ parent Y) × ⊤) ≅⟨ Σ-ap-iso refl≅ (λ p → sym≅ (contr-⊤-iso (hS _ _ _))) ⟩ ( Σ (parent X ≡ parent Y) λ p → (subst Struct p (struct X) ≡ struct Y) ) ≅⟨ Σ-split-iso ⟩ (parent X , struct X) ≡ (parent Y , struct Y) ≅⟨ iso≡ (bundle-structure-iso Struct) ⟩ X ≡ Y ∎ where open ≅-Reasoning
{ "alphanum_fraction": 0.5276630884, "avg_line_length": 28.8333333333, "ext": "agda", "hexsha": "4e8c8ccd60689a760b08caa6f5488900176ec756", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "overloading/level.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/overloading/level.agda", "max_line_length": 59, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "overloading/level.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 402, "size": 1211 }
module Data.Fin.Subset.Properties.Cardinality where open import Data.Nat as ℕ using (ℕ) open import Data.Nat.Properties as NP open import Data.Empty using (⊥-elim) open import Data.Fin open import Data.Fin.Subset open import Data.Fin.Subset.Properties open import Data.Vec using (_∷_; []) open import Data.Vec.Any using (here ; there) open import Data.Vec.Properties as VP open import Data.Product open import Data.Sum open import Relation.Binary open import Relation.Binary.PropositionalEquality as Eq open import Relation.Nullary.Negation open import Function -- some trivial lemma ∣p∣≡0→≡⊥ : ∀ {n}(p : Subset n) → ∣ p ∣ ≡ 0 → p ≡ ⊥ ∣p∣≡0→≡⊥ {ℕ.zero} [] refl = refl ∣p∣≡0→≡⊥ {ℕ.suc n} (outside ∷ p) eq = cong (outside ∷_) (∣p∣≡0→≡⊥ p eq) ∣p∣≡0→≡⊥ {ℕ.suc n} (inside ∷ p) () ∣p∣≡n→≡⊤ : ∀ {n}(p : Subset n) → ∣ p ∣ ≡ n → p ≡ ⊤ ∣p∣≡n→≡⊤ {ℕ.zero} [] refl = refl ∣p∣≡n→≡⊤ {ℕ.suc n} (outside ∷ p) eq = ⊥-elim (1+n≰n (≤-respˡ-≈ eq (∣p∣≤n p))) where open IsPartialOrder NP.≤-isPartialOrder using (≤-respˡ-≈) ∣p∣≡n→≡⊤ {ℕ.suc n} (inside ∷ p) eq = cong (inside ∷_) (∣p∣≡n→≡⊤ p (NP.suc-injective eq)) ∣p∣≡1→≡⁅x⁆ : ∀ {n}(p : Subset n) → ∣ p ∣ ≡ 1 → ∃ λ x → p ≡ ⁅ x ⁆ ∣p∣≡1→≡⁅x⁆ {ℕ.zero} [] () ∣p∣≡1→≡⁅x⁆ {ℕ.suc n} (outside ∷ p) eq with ∣p∣≡1→≡⁅x⁆ p eq ... | x , q = suc x , cong (outside ∷_) q ∣p∣≡1→≡⁅x⁆ {ℕ.suc n} (inside ∷ p) eq rewrite ∣p∣≡0→≡⊥ p (NP.suc-injective eq) = zero , refl -- union ≤∪ˡ : ∀ {n} {p} (q : Subset n) → ∣ p ∣ ℕ.≤ ∣ p ∪ q ∣ ≤∪ˡ {n}{p} q = p⊆q⇒∣p∣<∣q∣ (p⊆p∪q {p = p} q) ≤∪ʳ : ∀ {n} (p q : Subset n) → ∣ q ∣ ℕ.≤ ∣ p ∪ q ∣ ≤∪ʳ p q = p⊆q⇒∣p∣<∣q∣ (q⊆p∪q p q) ∪≤ : ∀ {n} (p q : Subset n) → ∣ p ∪ q ∣ ℕ.≤ ∣ p ∣ ℕ.+ ∣ q ∣ ∪≤ {ℕ.zero} [] [] = ℕ.z≤n ∪≤ {ℕ.suc n} (outside ∷ p) (outside ∷ q) = ∪≤ p q ∪≤ {ℕ.suc n} (outside ∷ p) (inside ∷ q) rewrite +-suc ∣ p ∣ ∣ q ∣ = ℕ.s≤s (∪≤ p q) ∪≤ {ℕ.suc n} (inside ∷ p) (outside ∷ q) = ℕ.s≤s (∪≤ p q) ∪≤ {ℕ.suc n} (inside ∷ p) (inside ∷ q) = ℕ.s≤s (NP.≤-trans (∪≤ p q) (NP.+-mono-≤ (≤-refl {∣ p ∣}) (n≤1+n _))) disjoint-∪≡+ : ∀ {n} (p q : Subset n) → p ∩ q ≡ ⊥ → ∣ p ∪ q ∣ ≡ ∣ p ∣ ℕ.+ ∣ q ∣ disjoint-∪≡+ {ℕ.zero} [] [] refl = refl disjoint-∪≡+ {ℕ.suc n} (outside ∷ p) (outside ∷ q) dis = disjoint-∪≡+ p q (VP.∷-injectiveʳ dis) disjoint-∪≡+ {ℕ.suc n} (outside ∷ p) (inside ∷ q) dis = Eq.trans (Eq.cong ℕ.suc (disjoint-∪≡+ p q (VP.∷-injectiveʳ dis))) (Eq.sym (NP.+-suc _ _)) disjoint-∪≡+ {ℕ.suc n} (inside ∷ p) (outside ∷ q) dis = Eq.cong ℕ.suc (disjoint-∪≡+ p q (VP.∷-injectiveʳ dis)) disjoint-∪≡+ {ℕ.suc n} (inside ∷ p) (inside ∷ q) () x∈p⇒⁅x⁆∪p≡p : ∀ {n} (x : Fin n)(p : Subset n) → x ∈ p → ⁅ x ⁆ ∪ p ≡ p x∈p⇒⁅x⁆∪p≡p x p x∈p = ⊆-antisym from to where from : ∀ {y} → y ∈ ⁅ x ⁆ ∪ p → y ∈ p from h with x∈p∪q⁻ ⁅ x ⁆ p h from h | inj₁ y∈⁅x⁆ rewrite x∈⁅y⁆⇒x≡y _ y∈⁅x⁆ = x∈p from h | inj₂ y∈p = y∈p to : ∀ {y} → y ∈ p → y ∈ ⁅ x ⁆ ∪ p to h = x∈p∪q⁺ (inj₂ h) ∣⁅x⁆∪p∣≡1+∣p∣⇒x∉p : ∀ {n}(x : Fin n)(p : Subset n) → ∣ ⁅ x ⁆ ∪ p ∣ ≡ 1 ℕ.+ ∣ p ∣ → x ∉ p ∣⁅x⁆∪p∣≡1+∣p∣⇒x∉p x p h x∈p rewrite x∈p⇒⁅x⁆∪p≡p x p x∈p = contradiction h lemma where lemma : ∀ {n} → n ≢ ℕ.suc n lemma () ∣⁅x⁆∪⁅y⁆∣≡2⇒x≢y : ∀ {n}(x y : Fin n) → ∣ ⁅ x ⁆ ∪ ⁅ y ⁆ ∣ ≡ 2 → x ≢ y ∣⁅x⁆∪⁅y⁆∣≡2⇒x≢y x .x h refl with ∣⁅x⁆∪p∣≡1+∣p∣⇒x∉p x ⁅ x ⁆ (trans h (cong ℕ.suc (sym (∣⁅x⁆∣≡1 x)))) ... | x∉⁅y⁆ = contradiction (x∈⁅x⁆ _) x∉⁅y⁆ module _ {n : ℕ} where open import Algebra.Structures {A = Subset n} _≡_ open IsBooleanAlgebra (∪-∩-isBooleanAlgebra n) renaming (∧-complementʳ to ∩-complementʳ; ∨-complementʳ to ∪-complementʳ) ∣p∣+∣∁p∣≡n : ∀ (p : Subset n) → ∣ p ∣ ℕ.+ ∣ ∁ p ∣ ≡ n ∣p∣+∣∁p∣≡n p = ∣ p ∣ ℕ.+ ∣ ∁ p ∣ ≡⟨ Eq.sym (disjoint-∪≡+ _ _ (∩-complementʳ p)) ⟩ _ ≡⟨ Eq.cong ∣_∣ (∪-complementʳ p) ⟩ _ ≡⟨ ∣⊤∣≡n _ ⟩ n ∎ where open Eq.≡-Reasoning ∩≤ˡ : ∀ {n} (a b : Subset n) → ∣ a ∩ b ∣ ℕ.≤ ∣ a ∣ ∩≤ˡ {n} a b = p⊆q⇒∣p∣<∣q∣ (p∩q⊆p a b) ∩≤ʳ : ∀ {n} (a b : Subset n) → ∣ a ∩ b ∣ ℕ.≤ ∣ b ∣ ∩≤ʳ {n} a b = p⊆q⇒∣p∣<∣q∣ (p∩q⊆q a b) ∣p∣<∣q∣⇒∣∁q∣<∣∁p∣ : ∀ {n} (p q : Subset n) → ∣ p ∣ ℕ.< ∣ q ∣ → ∣ ∁ q ∣ ℕ.< ∣ ∁ p ∣ ∣p∣<∣q∣⇒∣∁q∣<∣∁p∣ p q p<q = NP.+-cancelˡ-< ∣ q ∣ (begin-strict ∣ q ∣ ℕ.+ ∣ ∁ q ∣ ≡⟨ ∣p∣+∣∁p∣≡n q ⟩ _ ≡⟨ sym (∣p∣+∣∁p∣≡n p) ⟩ ∣ p ∣ ℕ.+ ∣ ∁ p ∣ <⟨ NP.+-monoˡ-< _ p<q ⟩ ∣ q ∣ ℕ.+ ∣ ∁ p ∣ ∎) where open NP.≤-Reasoning -- intersection {- private open import Relation.Nullary.Negation using (contraposition) p∩∁q≡⊥→p⊆q : ∀ {n} {p q : Subset n} → p ∩ ∁ q ≡ ⊥ → p ⊆ q p∩∁q≡⊥→p⊆q {zero} {[]} {[]} refl () p∩∁q≡⊥→p⊆q {suc n} {true ∷ p} {outside ∷ q} () here p∩∁q≡⊥→p⊆q {suc n} {inside ∷ p} {inside ∷ q} eq here = here p∩∁q≡⊥→p⊆q {suc n} {true ∷ p} {_ ∷ q} eq (there x∈p) with ∷-injective eq ... | _ , teq = there (p∩∁q≡⊥→p⊆q teq x∈p) p∩∁q≡⊥→p⊆q {suc n} {outside ∷ p} {_ ∷ q} eq (there x∈p) with ∷-injective eq ... | _ , teq = there (p∩∁q≡⊥→p⊆q teq x∈p) p∩q≡p→p⊆q : ∀ {n} {p q : Subset n} → p ∩ q ≡ p → p ⊆ q p∩q≡p→p⊆q {zero} {[]} {[]} refl () p∩q≡p→p⊆q {suc n} {inside ∷ p} {x ∷ q} eq here with ∷-injective eq p∩q≡p→p⊆q {suc n} {inside ∷ p} {.inside ∷ q} eq here | refl , _ = here p∩q≡p→p⊆q {suc n} {inside ∷ p} {_ ∷ q} eq (there x∈p) with ∷-injective eq ... | _ , teq = there (p∩q≡p→p⊆q teq x∈p) p∩q≡p→p⊆q {suc n} {outside ∷ p} {_ ∷ q} eq (there x∈p) with ∷-injective eq ... | _ , teq = there (p∩q≡p→p⊆q teq x∈p) p⊈q→p∩q≢p : ∀ {n} {p q : Subset n} → p ⊈ q → p ∩ q ≢ p p⊈q→p∩q≢p = contraposition p∩q≡p→p⊆q split-size : ∀ {n} {a} (b : Subset n) → ∣ a ∣ ≡ ∣ a ∩ b ∣ ℕ.+ ∣ a ∩ ∁ b ∣ split-size {n}{a} b = ∣a∣≡∣a∩b∣+∣a∩∁b∣ where open P.≡-Reasoning a∩b∩a∩∁b≡⊥ : (a ∩ b) ∩ (a ∩ ∁ b) ≡ ⊥ a∩b∩a∩∁b≡⊥ = begin (a ∩ b) ∩ (a ∩ ∁ b) ≡⟨ ∩-assoc _ _ _ ⟩ _ ≡⟨ cong (a ∩_ ) (sym (∩-assoc _ _ _)) ⟩ _ ≡⟨ cong (a ∩_ ) (cong (_∩ _) (∩-comm _ _)) ⟩ _ ≡⟨ cong (a ∩_ ) (∩-assoc _ _ _) ⟩ _ ≡⟨ cong (a ∩_ ) (cong (a ∩_) (∩-complementʳ _)) ⟩ _ ≡⟨ cong (a ∩_ ) (∩-zeroʳ _) ⟩ _ ≡⟨ ∩-zeroʳ _ ⟩ ⊥ ∎ a≡a∩b∪a∩∁b : a ≡ (a ∩ b) ∪ (a ∩ ∁ b) a≡a∩b∪a∩∁b = begin a ≡⟨ sym (∩-identityʳ _) ⟩ a ∩ ⊤ ≡⟨ cong (_ ∩_) (sym (∪-complementʳ _)) ⟩ a ∩ (b ∪ ∁ b) ≡⟨ (proj₁ ∪-∩-distrib) _ _ _ ⟩ (a ∩ b) ∪ (a ∩ ∁ b) ∎ ∣a∣≡∣a∩b∣+∣a∩∁b∣ : ∣ a ∣ ≡ ∣ a ∩ b ∣ ℕ.+ ∣ a ∩ ∁ b ∣ ∣a∣≡∣a∩b∣+∣a∩∁b∣ = begin ∣ a ∣ ≡⟨ cong size a≡a∩b∪a∩∁b ⟩ ∣ (a ∩ b) ∪ (a ∩ ∁ b) ∣ ≡⟨ disjoint-∪≡ a∩b∩a∩∁b≡⊥ ⟩ ∣ a ∩ b ∣ ℕ.+ ∣ a ∩ ∁ b ∣ ∎ ⊈→∩<ˡ : ∀ {n} {a b : Subset n} → a ⊈ b → ∣ a ∩ b ∣ ℕ.< ∣ a ∣ ⊈→∩<ˡ {n}{a}{b} a⊈b = ≤+≢⇒< (∩≤ˡ a b) lemma where open P.≡-Reasoning n+m≡n→m≡0 : ∀ {n m} → n ℕ.+ m ≡ n → m ≡ 0 n+m≡n→m≡0 {n}{m} eq = +-cancelˡ-≡ n (P.trans eq (sym (+-identityʳ n))) lemma : ∣ a ∩ b ∣ ≢ ∣ a ∣ lemma eq = (contraposition p∩∁q≡⊥→p⊆q a⊈b) (size0 (n+m≡n→m≡0 (sym (P.trans eq (split-size b))))) -}
{ "alphanum_fraction": 0.4249134948, "avg_line_length": 41.7630057803, "ext": "agda", "hexsha": "dff9f50b3ab5808f51b017dda63a1408f284979f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_path": "src/Data/Fin/Subset/Properties/Cardinality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tizmd/agda-finitary", "max_issues_repo_path": "src/Data/Fin/Subset/Properties/Cardinality.agda", "max_line_length": 141, "max_stars_count": null, "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_path": "src/Data/Fin/Subset/Properties/Cardinality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4301, "size": 7225 }
module _ where open import Agda.Builtin.Nat open import Imports.ImportedDisplayForms postulate T : Nat → Set foo : (a : Nat) → T (a + a) foo a = {!!}
{ "alphanum_fraction": 0.6602564103, "avg_line_length": 13, "ext": "agda", "hexsha": "ad8b49778bd94ee29220b037c06ce9e394928a80", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/ImportedDisplayForms.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/ImportedDisplayForms.agda", "max_line_length": 40, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/ImportedDisplayForms.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 51, "size": 156 }
open import Oscar.Prelude open import Oscar.Class.HasEquivalence open import Oscar.Class.Smap open import Oscar.Class.Surjextensionality open import Oscar.Class.Symmetry open import Oscar.Class.Symmetrical open import Oscar.Class.Transitivity open import Oscar.Data.ProductIndexEquivalence open import Oscar.Data.Surjextenscollation import Oscar.Class.HasEquivalence.ExtensionṖroperty import Oscar.Class.Surjection.⋆ import Oscar.Data.ExtensionṖroperty import Oscar.Data.Proposequality module Oscar.Class.Symmetrical.ExtensionalUnifies where module _ {𝔵} {𝔛 : Ø 𝔵} {𝔞} {𝔄 : 𝔛 → Ø 𝔞} {𝔟} {𝔅 : 𝔛 → Ø 𝔟} (let _↦_ = Arrow 𝔄 𝔅) {𝔠} {ℭ : 𝔛 → Ø 𝔠} {ℓ₁} {_↦̇_ : ∀ {x y} → x ↦ y → x ↦ y → Ø ℓ₁} {ℓ₂} {_∼₂_ : ∀ {y} → ℭ y → ℭ y → Ø ℓ₂} ⦃ _ : ∀ {y} → Symmetry.class (_∼₂_ {y}) ⦄ ⦃ _ : ∀ {y} → Transitivity.class (_∼₂_ {y}) ⦄ ⦃ _ : Smap!.class _↦_ (Extension ℭ) ⦄ ⦃ _ : Surjextensionality!.class _↦_ _↦̇_ (Extension ℭ) (Pointwise _∼₂_) ⦄ where instance 𝓢ymmetricalExtensionalUnifies : ∀ {m} → Symmetrical {𝔄 = (ℭ m)} {𝔅 = (LeftExtensionṖroperty ℓ₂ _↦_ _↦̇_ m)} surjextenscollation⟦ _↦̇_ ⟧ _≈_ 𝓢ymmetricalExtensionalUnifies .𝓢ymmetrical.symmetrical x y .π₀ = ∁ (symmetry , symmetry)
{ "alphanum_fraction": 0.6739659367, "avg_line_length": 34.25, "ext": "agda", "hexsha": "a33bc2f472e1541988777dd52314e2e1156255c0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/ExtensionalUnifies.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/ExtensionalUnifies.agda", "max_line_length": 144, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/ExtensionalUnifies.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 508, "size": 1233 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.AbGroup.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.Data.Unit open import Cubical.Reflection.StrictEquiv open import Cubical.Structures.Axioms open import Cubical.Structures.Macro open import Cubical.Structures.Pointed open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.Group open Iso private variable ℓ ℓ' : Level record IsAbGroup {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where constructor isabgroup field isGroup : IsGroup 0g _+_ -_ comm : (x y : G) → x + y ≡ y + x open IsGroup isGroup public record AbGroupStr (A : Type ℓ) : Type (ℓ-suc ℓ) where constructor abgroupstr field 0g : A _+_ : A → A → A -_ : A → A isAbGroup : IsAbGroup 0g _+_ -_ infix 8 -_ infixr 7 _+_ open IsAbGroup isAbGroup public AbGroup : Type (ℓ-suc ℓ) AbGroup = TypeWithStr _ AbGroupStr makeIsAbGroup : {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G} (is-setG : isSet G) (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z) (rid : (x : G) → x + 0g ≡ x) (rinv : (x : G) → x + (- x) ≡ 0g) (comm : (x y : G) → x + y ≡ y + x) → IsAbGroup 0g _+_ -_ makeIsAbGroup is-setG assoc rid rinv comm = isabgroup (makeIsGroup is-setG assoc rid (λ x → comm _ _ ∙ rid x) rinv (λ x → comm _ _ ∙ rinv x)) comm makeAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) (is-setG : isSet G) (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z) (rid : (x : G) → x + 0g ≡ x) (rinv : (x : G) → x + (- x) ≡ 0g) (comm : (x y : G) → x + y ≡ y + x) → AbGroup makeAbGroup 0g _+_ -_ is-setG assoc rid rinv comm = _ , abgroupstr 0g _+_ -_ (makeIsAbGroup is-setG assoc rid rinv comm) open GroupStr AbGroup→Group : AbGroup {ℓ} → Group fst (AbGroup→Group A) = fst A 0g (snd (AbGroup→Group A)) = AbGroupStr.0g (snd A) _+_ (snd (AbGroup→Group A)) = AbGroupStr._+_ (snd A) - snd (AbGroup→Group A) = AbGroupStr.- (snd A) isGroup (snd (AbGroup→Group A)) = IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd A)) Group→AbGroup : (G : Group {ℓ}) → ((x y : fst G) → _+_ (snd G) x y ≡ _+_ (snd G) y x) → AbGroup fst (Group→AbGroup G comm) = fst G AbGroupStr.0g (snd (Group→AbGroup G comm)) = 0g (snd G) AbGroupStr._+_ (snd (Group→AbGroup G comm)) = _+_ (snd G) AbGroupStr.- snd (Group→AbGroup G comm) = - (snd G) IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = isGroup (snd G) IsAbGroup.comm (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = comm isSetAbGroup : (A : AbGroup {ℓ}) → isSet ⟨ A ⟩ isSetAbGroup A = isSetGroup (AbGroup→Group A) AbGroupHom : (G : AbGroup {ℓ}) (H : AbGroup {ℓ'}) → Type (ℓ-max ℓ ℓ') AbGroupHom G H = GroupHom (AbGroup→Group G) (AbGroup→Group H) AbGroupEquiv : (G : AbGroup {ℓ}) (H : AbGroup {ℓ'}) → Type (ℓ-max ℓ ℓ') AbGroupEquiv G H = GroupEquiv (AbGroup→Group G) (AbGroup→Group H) module AbGroupΣTheory {ℓ} where open GroupΣTheory AbGroupAxioms : (G : Type ℓ) → RawGroupStructure G → Type ℓ AbGroupAxioms G _+_ = GroupAxioms G _+_ × ((x y : G) → x + y ≡ y + x) AbGroupStructure : Type ℓ → Type ℓ AbGroupStructure = AxiomsStructure RawGroupStructure AbGroupAxioms AbGroupΣ : Type (ℓ-suc ℓ) AbGroupΣ = TypeWithStr ℓ AbGroupStructure isSetAbGroupΣ : (A : AbGroupΣ) → isSet _ isSetAbGroupΣ (A , _+_ , (isGroup-A , _)) = isSetGroupΣ (A , _+_ , isGroup-A) AbGroupEquivStr : StrEquiv AbGroupStructure ℓ AbGroupEquivStr = AxiomsEquivStr RawGroupEquivStr AbGroupAxioms isPropAbGroupAxioms : (G : Type ℓ) (s : RawGroupStructure G) → isProp (AbGroupAxioms G s) isPropAbGroupAxioms G _+_ = isPropΣ (isPropGroupAxioms G _+_) λ { (H , _) → isPropΠ2 λ _ _ → IsSemigroup.is-set H _ _} AbGroup→AbGroupΣ : AbGroup → AbGroupΣ AbGroup→AbGroupΣ (_ , abgroupstr _ _ _ (isabgroup G C)) = _ , _ , Group→GroupΣ (group _ _ _ _ G) .snd .snd , C AbGroupΣ→AbGroup : AbGroupΣ → AbGroup AbGroupΣ→AbGroup (_ , _ , G , C) = _ , abgroupstr _ _ _ (isabgroup (GroupΣ→Group (_ , _ , G) .snd .GroupStr.isGroup) C) open AbGroupStr AbGroupIsoAbGroupΣ : Iso AbGroup AbGroupΣ AbGroupIsoAbGroupΣ = iso AbGroup→AbGroupΣ AbGroupΣ→AbGroup (λ _ → refl) (λ _ → refl) abGroupUnivalentStr : UnivalentStr AbGroupStructure AbGroupEquivStr abGroupUnivalentStr = axiomsUnivalentStr _ isPropAbGroupAxioms rawGroupUnivalentStr AbGroupΣPath : (G H : AbGroupΣ) → (G ≃[ AbGroupEquivStr ] H) ≃ (G ≡ H) AbGroupΣPath = SIP abGroupUnivalentStr AbGroupEquivΣ : (G H : AbGroup) → Type ℓ AbGroupEquivΣ G H = AbGroup→AbGroupΣ G ≃[ AbGroupEquivStr ] AbGroup→AbGroupΣ H AbGroupPath : (G H : AbGroup) → (AbGroupEquiv G H) ≃ (G ≡ H) AbGroupPath G H = AbGroupEquiv G H ≃⟨ strictIsoToEquiv GroupIsoΣPath ⟩ AbGroupEquivΣ G H ≃⟨ AbGroupΣPath _ _ ⟩ AbGroup→AbGroupΣ G ≡ AbGroup→AbGroupΣ H ≃⟨ isoToEquiv (invIso (congIso AbGroupIsoAbGroupΣ)) ⟩ G ≡ H ■ AbGroup→RawGroupΣ : AbGroup {ℓ} → RawGroupΣ AbGroup→RawGroupΣ (G , abgroupstr _ _+_ _ _) = G , _+_ InducedAbGroup : (G : AbGroup) (H : RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst) → RawGroupEquivStr (AbGroup→RawGroupΣ G) H e → AbGroup InducedAbGroup G H e r = AbGroupΣ→AbGroup (inducedStructure rawGroupUnivalentStr (AbGroup→AbGroupΣ G) H (e , r)) InducedAbGroupPath : (G : AbGroup {ℓ}) (H : RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst) (E : RawGroupEquivStr (AbGroup→RawGroupΣ G) H e) → G ≡ InducedAbGroup G H e E InducedAbGroupPath G H e E = AbGroupPath G (InducedAbGroup G H e E) .fst (groupequiv e E) -- Extract the characterization of equality of groups AbGroupPath : (G H : AbGroup {ℓ}) → (AbGroupEquiv G H) ≃ (G ≡ H) AbGroupPath = AbGroupΣTheory.AbGroupPath isPropIsAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (- : G → G) → isProp (IsAbGroup 0g _+_ -) isPropIsAbGroup 0g _+_ -_ (isabgroup GG GC) (isabgroup HG HC) = λ i → isabgroup (isPropIsGroup _ _ _ GG HG i) (isPropComm GC HC i) where isSetG : isSet _ isSetG = GG .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropComm : isProp ((x y : _) → x + y ≡ y + x) isPropComm = isPropΠ2 λ _ _ → isSetG _ _ InducedAbGroup : (G : AbGroup {ℓ}) (H : GroupΣTheory.RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst) → GroupΣTheory.RawGroupEquivStr (AbGroupΣTheory.AbGroup→RawGroupΣ G) H e → AbGroup InducedAbGroup = AbGroupΣTheory.InducedAbGroup InducedAbGroupPath : (G : AbGroup {ℓ}) (H : GroupΣTheory.RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst) (E : GroupΣTheory.RawGroupEquivStr (AbGroupΣTheory.AbGroup→RawGroupΣ G) H e) → G ≡ InducedAbGroup G H e E InducedAbGroupPath = AbGroupΣTheory.InducedAbGroupPath open IsMonoid open IsSemigroup open IsGroup open AbGroupStr open IsAbGroup dirProdAb : AbGroup {ℓ} → AbGroup {ℓ'} → AbGroup dirProdAb A B = Group→AbGroup (dirProd (AbGroup→Group A) (AbGroup→Group B)) λ p q → ΣPathP (comm (isAbGroup (snd A)) _ _ , comm (isAbGroup (snd B)) _ _) trivialAbGroup : ∀ {ℓ} → AbGroup {ℓ} fst trivialAbGroup = Unit* 0g (snd trivialAbGroup) = tt* _+_ (snd trivialAbGroup) _ _ = tt* (- snd trivialAbGroup) _ = tt* is-set (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) = isProp→isSet isPropUnit* assoc (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) _ _ _ = refl identity (isMonoid (isGroup (isAbGroup (snd trivialAbGroup)))) _ = refl , refl inverse (isGroup (isAbGroup (snd trivialAbGroup))) _ = refl , refl comm (isAbGroup (snd trivialAbGroup)) _ _ = refl
{ "alphanum_fraction": 0.6391903426, "avg_line_length": 37.4474885845, "ext": "agda", "hexsha": "ee80c20d9bd42baa0cb70b84942cede1cc034792", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Algebra/AbGroup/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Algebra/AbGroup/Base.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Algebra/AbGroup/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3032, "size": 8201 }
{-# OPTIONS --cubical #-} module Type.Cubical.Path.Category{ℓ} where open import Data.Tuple as Tuple using (_,_) open import Data open import Functional open import Function.Axioms open import Logic.Propositional open import Structure.Category open import Structure.Categorical.Properties open import Structure.Operator open import Structure.Relator.Properties open import Type open import Type.Cubical.Path open import Type.Cubical.Path.Equality open import Type.Properties.Singleton -- The type category is a category containing all types of a single universe level in the language. -- The objects are all sets/types. -- The morphisms are all functions where the domain/codomain-pair are from these objects. typeFunctionPathCategory : Category{Obj = Type{ℓ}}(_→ᶠ_) Category._∘_ typeFunctionPathCategory = _∘_ Category.id typeFunctionPathCategory = id Morphism.Associativity.proof (Category.associativity typeFunctionPathCategory) = reflexivity(Path) Morphism.Identityₗ.proof (Tuple.left (Category.identity typeFunctionPathCategory)) = reflexivity(Path) Morphism.Identityᵣ.proof (Tuple.right (Category.identity typeFunctionPathCategory)) = reflexivity(Path) typeFunctionPathCategoryObject : CategoryObject typeFunctionPathCategoryObject = intro typeFunctionPathCategory Empty-initialObject : Object.Initial{Obj = Type{ℓ}}(_→ᶠ_) (Empty) IsUnit.unit Empty-initialObject = empty IsUnit.uniqueness (Empty-initialObject {T}) = functionExtensionality(Empty)(T) \{} Unit-terminalObject : Object.Terminal{Obj = Type{ℓ}}(_→ᶠ_) (Unit) IsUnit.unit Unit-terminalObject = const <> IsUnit.uniqueness Unit-terminalObject = reflexivity(Path)
{ "alphanum_fraction": 0.8009650181, "avg_line_length": 42.5128205128, "ext": "agda", "hexsha": "d725a9cb239328bd849ac45ac128ad6e5a9271da", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Type/Cubical/Path/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Type/Cubical/Path/Category.agda", "max_line_length": 103, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Type/Cubical/Path/Category.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 388, "size": 1658 }
open import Agda.Builtin.Bool f : Bool → Bool f x = let y = x in {!!}
{ "alphanum_fraction": 0.6056338028, "avg_line_length": 14.2, "ext": "agda", "hexsha": "ba6cae6eaef42f7280a809a01c2705cb9635e57a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/SplitLetBound.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/SplitLetBound.agda", "max_line_length": 29, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/SplitLetBound.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 24, "size": 71 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Ints.QuoInt where open import Cubical.HITs.Ints.QuoInt.Base public -- open import Cubical.HITs.Ints.QuoInt.Properties public
{ "alphanum_fraction": 0.7666666667, "avg_line_length": 25.7142857143, "ext": "agda", "hexsha": "1478c4e40129474f1bc01b186ccf34692e270c97", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/HITs/Ints/QuoInt.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/HITs/Ints/QuoInt.agda", "max_line_length": 57, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/HITs/Ints/QuoInt.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 53, "size": 180 }
{-# OPTIONS --without-K --exact-split #-} module dn-sheaves where import rings open rings public {- We postulate a propositional resizing axiom -} raise-UU-Prop : (l : Level) → UU-Prop lzero → UU-Prop l raise-UU-Prop l (pair P is-prop-P) = pair ( raise l P) ( is-prop-is-equiv' P ( map-raise l P) ( is-equiv-map-raise l P) ( is-prop-P)) postulate propositional-resizing : {l : Level} → is-equiv (raise-UU-Prop l) lower-UU-Prop : {l : Level} → UU-Prop l → UU-Prop lzero lower-UU-Prop = inv-is-equiv propositional-resizing issec-lower-UU-Prop : {l : Level} (P : UU-Prop l) → Id (raise-UU-Prop l (lower-UU-Prop P)) P issec-lower-UU-Prop = issec-inv-is-equiv propositional-resizing isretr-lower-UU-Prop : {l : Level} (P : UU-Prop lzero) → Id (lower-UU-Prop (raise-UU-Prop l P)) P isretr-lower-UU-Prop = isretr-inv-is-equiv propositional-resizing {- We define what it means for a type to be a double-negation-sheaf -} is-dn-sheaf : {l : Level} (X : UU l) → UU (l ⊔ (lsuc lzero)) is-dn-sheaf X = (P : UU-Prop lzero) → is-equiv (λ (f : ¬¬ (type-Prop P) → X) → f ∘ intro-dn) universal-property-dn-sheafification : (l : Level) {l1 l2 : Level} {X : UU l1} {Y : UU l2} (f : X → Y) → is-dn-sheaf Y → UU ((lsuc l) ⊔ l1 ⊔ l2) universal-property-dn-sheafification l {Y = Y} f is-dn-sheaf-Y = (Z : UU l) (H : is-dn-sheaf Z) → is-equiv (λ (h : Y → Z) → h ∘ f) postulate dn-sheafification : {l : Level} → UU l → UU l postulate unit-dn-sheafification : {l : Level} (X : UU l) → X → dn-sheafification X postulate is-dn-sheaf-dn-sheafification : {l : Level} (X : UU l) → is-dn-sheaf (dn-sheafification X) postulate is-dn-sheafification : {l1 l2 : Level} (X : UU l1) → universal-property-dn-sheafification l2 (unit-dn-sheafification X) (is-dn-sheaf-dn-sheafification X) {- We show that on propositions, dn-sheafification agrees with double negation. -} is-dn-sheaf-dn : {l : Level} (P : UU l) → is-dn-sheaf (¬¬ P) is-dn-sheaf-dn P Q = is-equiv-is-prop ( is-prop-function-type (¬¬ (type-Prop Q)) (¬¬ P) is-prop-neg) ( is-prop-function-type (type-Prop Q) (¬¬ P) is-prop-neg) ( dn-extend) is-dn-sheafification-intro-dn : (k : Level) {l : Level} (P : UU l) → universal-property-dn-sheafification k (intro-dn {P = P}) (is-dn-sheaf-dn P) is-dn-sheafification-intro-dn k {l} P X is-dn-sheaf-X = is-equiv-top-is-equiv-bottom-square ( λ f → f ∘ ( functor-dn {!map-raise l ?!})) {!!} {!!} {!!} {!!} {!!} {!!} {!!}
{ "alphanum_fraction": 0.6168261563, "avg_line_length": 33, "ext": "agda", "hexsha": "058c390189274159129041b0c0b3ea34f3d8b0af", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/dn-sheaves.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/dn-sheaves.agda", "max_line_length": 163, "max_stars_count": 333, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/dn-sheaves.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 956, "size": 2508 }
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness #-} open import Data.Empty using (⊥-elim) open import Data.Unit using (⊤) open import Data.Product open import Data.Sum open import Data.Vec using ([]; _∷_) open import Data.List as List import Data.Fin as Fin open import Data.Nat open import Relation.Nullary using (¬_; yes; no) open import Relation.Binary.Definitions open import Relation.Unary using (_∈_; _∉_; _⊆_; Satisfiable) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (ε; _◅_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; inspect) open import Common open import is-lib.InfSys module FairTermination-IS {𝕋 : Set} (message : Message 𝕋) where open import SessionType message open import Trace message open import Transitions message open import HasTrace message open import TraceSet message U : Set U = SessionType data RuleNames : Set where nil inp out : RuleNames data CoRuleNames : Set where inp out : CoRuleNames nil-r : FinMetaRule U nil-r .Ctx = ⊤ nil-r .comp _ = [] , ---- nil inp-r : MetaRule U inp-r .Ctx = Continuation inp-r .Pos _ = 𝕋 inp-r .prems f p = f p .force inp-r .conclu f = inp f out-r : MetaRule U out-r .Ctx = Continuation out-r .Pos _ = 𝕋 out-r .prems f p = f p .force out-r .conclu f = out f inp-co-r : FinMetaRule U inp-co-r .Ctx = Σ[ (f , x) ∈ Continuation × 𝕋 ] x ∈ dom f inp-co-r .comp ((f , x) , _) = f x .force ∷ [] , -------------------- inp f out-co-r : FinMetaRule U out-co-r .Ctx = Σ[ (f , x) ∈ Continuation × 𝕋 ] x ∈ dom f out-co-r .comp ((f , x) , _) = f x .force ∷ [] , -------------------- out f WeakTerminationS : SessionType → Set WeakTerminationS T = ∀{φ} → φ ∈ ⟦ T ⟧ → ∃[ ψ ] (φ ++ ψ ∈ Maximal ⟦ T ⟧) WeakTerminationIS : IS U Names WeakTerminationIS = RuleNames rules WeakTerminationIS nil = from nil-r rules WeakTerminationIS inp = inp-r rules WeakTerminationIS out = out-r WeakTerminationCOIS : IS U WeakTerminationCOIS .Names = CoRuleNames WeakTerminationCOIS .rules inp = from inp-co-r WeakTerminationCOIS .rules out = from out-co-r WeakTermination : SessionType → Set WeakTermination = FCoInd⟦ WeakTerminationIS , WeakTerminationCOIS ⟧ WeakTerminationI : SessionType → Set WeakTerminationI = Ind⟦ WeakTerminationIS ∪ WeakTerminationCOIS ⟧ {- Soundness -} lemma-inp : ∀{f φ x} → φ ∈ Maximal ⟦ f x .force ⟧ → I x ∷ φ ∈ Maximal ⟦ inp f ⟧ lemma-inp (maximal wit F) = maximal (inp-has-trace wit) λ { (some le) (_ , def , step inp tr) → cong (_ ∷_) (F le (_ , def , tr))} lemma-out : ∀{f φ x} → φ ∈ Maximal ⟦ f x .force ⟧ → O x ∷ φ ∈ Maximal ⟦ out f ⟧ lemma-out (maximal wit F) = maximal (out-has-trace wit) λ { (some le) (_ , def , step (out _) tr) → cong (_ ∷_) (F le (_ , def , tr))} lemma-end : ∀{f} → (∀{x} → x ∉ dom f) → [] ∈ Maximal ⟦ inp f ⟧ lemma-end no-x = maximal (_ , inp , refl) λ { {[]} none _ → refl ; {O _ ∷ _} none (_ , _ , step () _) ; {I _ ∷ _} none (_ , def , step inp tr) → ⊥-elim (no-x (transitions+defined->defined tr def))} lemma-win : ∀{f} → (∀{x} → x ∉ dom f) → [] ∈ Maximal ⟦ out f ⟧ lemma-win no-x = maximal (_ , out , refl) λ { {[]} none _ → refl ; {I _ ∷ _} none (_ , _ , step () _) ; {O _ ∷ _} none (_ , def , step (out ok) _) → ⊥-elim (no-x ok)} may-terminate : ∀{T} → Defined T → WeakTerminationI T → Satisfiable (Maximal ⟦ T ⟧) may-terminate _ (fold (inj₁ inp , f , refl , pr)) with Empty? f ... | inj₁ e = _ , lemma-end λ x → e _ x ... | inj₂ (p , def) = let tr , max = may-terminate def (pr p) in I p ∷ tr , lemma-inp max may-terminate _ (fold (inj₁ out , f , refl , pr)) with Empty? f ... | inj₁ e = _ , lemma-win λ x → e _ x ... | inj₂ (p , def) = let tr , max = may-terminate def (pr p) in O p ∷ tr , lemma-out max may-terminate _ (fold (inj₂ inp , ((_ , x) , def) , refl , pr)) = let tr , max = may-terminate def (pr Fin.zero) in I x ∷ tr , lemma-inp max may-terminate _ (fold (inj₂ out , ((_ , x) , def) , refl , pr)) = let tr , max = may-terminate def (pr Fin.zero) in O x ∷ tr , lemma-out max wt-sound : WeakTermination ⊆ WeakTerminationS wt-sound wt (_ , def , refl) = may-terminate def (fcoind-to-ind wt) wt-sound wt (_ , def , step t tr) with wt .CoInd⟦_⟧.unfold wt-sound wt (_ , def , step (inp {_} {p}) tr) | inp , _ , refl , pr = let tr' , max = wt-sound (pr p) (_ , def , tr) in tr' , lemma-inp max wt-sound wt (_ , def , step (out {_} {p} fx) tr) | out , _ , refl , pr = let tr' , max = wt-sound (pr p) (_ , def , tr) in tr' , lemma-out max {- Boundedness -} undefined→terminates : ∀{T} → ¬ Defined T → WeakTerminationI T undefined→terminates {nil} _ = apply-ind (inj₁ nil) _ λ () undefined→terminates {inp f} und = ⊥-elim (und inp) undefined→terminates {out f} und = ⊥-elim (und out) input-maximal→terminates : ∀{f x} → [] ∈ Maximal ⟦ inp f ⟧ → WeakTerminationI (f x .force) input-maximal→terminates {f} {x} (maximal (_ , inp , refl) F) with x ∈? f ... | no nfx = undefined→terminates nfx ... | yes fx with F none (_ , fx , step inp refl) ... | () output-maximal→terminates : ∀{f x} → [] ∈ Maximal ⟦ out f ⟧ → WeakTerminationI (f x .force) output-maximal→terminates {f} {x} (maximal (_ , out , refl) F) with x ∈? f ... | no nfx = undefined→terminates nfx ... | yes fx with F none (_ , fx , step (out fx) refl) ... | () bounded-lemma : ∀{T ϕ} → ϕ ∈ Maximal ⟦ T ⟧ → WeakTerminationI T bounded-lemma {nil} (maximal _ _) = apply-ind (inj₁ nil) _ λ () bounded-lemma {inp f} c[]@(maximal (_ , def , refl) F) = apply-ind (inj₁ inp) _ λ p → input-maximal→terminates {f} {p} c[] bounded-lemma {inp f} cϕ@(maximal (_ , def , step inp tr) F) = apply-ind (inj₂ inp) (_ , (transitions+defined->defined tr def)) λ{Fin.zero → bounded-lemma (input-maximal cϕ)} bounded-lemma {out f} c[]@(maximal (_ , def , refl) F) = apply-ind (inj₁ out) _ λ p → output-maximal→terminates {f} {p} c[] bounded-lemma {out f} cϕ@(maximal (_ , def , step (out x) tr) F) = apply-ind (inj₂ out) (_ , x) λ{Fin.zero → bounded-lemma (output-maximal cϕ)} wtS-bounded : WeakTerminationS ⊆ WeakTerminationI wtS-bounded {nil} _ = apply-ind (inj₁ nil) _ λ () wtS-bounded {inp f} s with s (_ , inp , refl) ... | _ , max = bounded-lemma max wtS-bounded {out f} s with s (_ , out , refl) ... | _ , max = bounded-lemma max {- Consistency -} lemma-input-maximal : ∀{f x} → WeakTerminationS (inp f) → WeakTerminationS (f x .force) lemma-input-maximal {f} {x} spec tφ with x ∈? f ... | no nfx = ⊥-elim (nfx (has-trace->defined tφ)) ... | yes fx with spec (inp-has-trace tφ) ... | _ , cψ = _ , input-maximal cψ lemma-output-maximal : ∀{f x} → WeakTerminationS (out f) → WeakTerminationS (f x .force) lemma-output-maximal {f} {x} spec tφ with x ∈? f ... | no nfx = ⊥-elim (nfx (has-trace->defined tφ)) ... | yes fx with spec (out-has-trace tφ) ... | _ , cψ = _ , output-maximal cψ wtS-cons : WeakTerminationS ⊆ ISF[ WeakTerminationIS ] WeakTerminationS wtS-cons {nil} spec = nil , _ , refl , λ () wtS-cons {inp f} spec = inp , f , refl , λ p → lemma-input-maximal {f} {p} spec wtS-cons {out f} spec = out , f , refl , λ p → lemma-output-maximal {f} {p} spec {- Completeness -} wt-complete : WeakTerminationS ⊆ WeakTermination wt-complete = bounded-coind[ WeakTerminationIS , WeakTerminationCOIS ] WeakTerminationS wtS-bounded wtS-cons
{ "alphanum_fraction": 0.6231034483, "avg_line_length": 37.8260869565, "ext": "agda", "hexsha": "9e0fae5e0d33a035f462960a0878c81eb9a09440", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "boystrange/FairSubtypingAgda", "max_forks_repo_path": "src/FairTermination-IS.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "boystrange/FairSubtypingAgda", "max_issues_repo_path": "src/FairTermination-IS.agda", "max_line_length": 115, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "boystrange/FairSubtypingAgda", "max_stars_repo_path": "src/FairTermination-IS.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z", "num_tokens": 2940, "size": 8700 }
module Algebra.Dioid.Bool where open import Algebra.Dioid data Bool : Set where true : Bool false : Bool data _≡_ : (x y : Bool) -> Set where reflexivity : ∀ {x : Bool} -> x ≡ x symmetry : ∀ {x y : Bool} -> x ≡ y -> y ≡ x transitivity : ∀ {x y z : Bool} -> x ≡ y -> y ≡ z -> x ≡ z _or_ : Bool -> Bool -> Bool false or false = false _ or _ = true _and_ : Bool -> Bool -> Bool true and true = true _ and _ = false
{ "alphanum_fraction": 0.5278969957, "avg_line_length": 22.1904761905, "ext": "agda", "hexsha": "05b6e63181d31d24e4d8ec1c9ef844b8c5d856d0", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2019-05-09T23:53:28.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-17T20:48:20.000Z", "max_forks_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "snowleopard/alga-proofs", "max_forks_repo_path": "src/Algebra/Dioid/Bool.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_issues_repo_issues_event_max_datetime": "2018-06-23T13:54:02.000Z", "max_issues_repo_issues_event_min_datetime": "2018-04-12T16:25:13.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "snowleopard/alga-proofs", "max_issues_repo_path": "src/Algebra/Dioid/Bool.agda", "max_line_length": 60, "max_stars_count": 60, "max_stars_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "snowleopard/alga-proofs", "max_stars_repo_path": "src/Algebra/Dioid/Bool.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:05:29.000Z", "max_stars_repo_stars_event_min_datetime": "2017-12-27T14:57:04.000Z", "num_tokens": 158, "size": 466 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Abstract.Types open import LibraBFT.Abstract.Types.EpochConfig open WithAbsVote -- For each desired property (VotesOnce and PreferredRoundRule), we have a -- module containing a Type that defines a property that an implementation -- should prove, and a proof that it implies the corresponding rule used by -- the abstract proofs. Then, we use those proofs to instantiate thmS5, -- and the use thmS5 to prove a number of correctness conditions. -- -- TODO-1: refactor this file to separate the definitions and proofs of -- VotesOnce and PreferredRoundRule from their use in proving the correctness -- properties. module LibraBFT.Abstract.Properties (UID : Set) (_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁)) (NodeId : Set) (𝓔 : EpochConfig UID NodeId) (𝓥 : VoteEvidence UID NodeId 𝓔) where open import LibraBFT.Abstract.Records UID _≟UID_ NodeId 𝓔 𝓥 open import LibraBFT.Abstract.Records.Extends UID _≟UID_ NodeId 𝓔 𝓥 open import LibraBFT.Abstract.RecordChain UID _≟UID_ NodeId 𝓔 𝓥 open import LibraBFT.Abstract.RecordChain.Assumptions UID _≟UID_ NodeId 𝓔 𝓥 open import LibraBFT.Abstract.System UID _≟UID_ NodeId 𝓔 𝓥 open import LibraBFT.Abstract.RecordChain.Properties UID _≟UID_ NodeId 𝓔 𝓥 open EpochConfig 𝓔 module WithAssumptions {ℓ} (InSys : Record → Set ℓ) (votes-only-once : VotesOnlyOnceRule InSys) (preferred-round-rule : PreferredRoundRule InSys) where open All-InSys-props InSys CommitsDoNotConflict : ∀{q q'} → {rc : RecordChain (Q q)} → All-InSys rc → {rc' : RecordChain (Q q')} → All-InSys rc' → {b b' : Block} → CommitRule rc b → CommitRule rc' b' → NonInjective-≡ bId ⊎ ((B b) ∈RC rc' ⊎ (B b') ∈RC rc) CommitsDoNotConflict = WithInvariants.thmS5 InSys votes-only-once preferred-round-rule -- When we are dealing with a /Complete/ InSys predicate, we can go a few steps -- further and prove that commits do not conflict even if we have only partial -- knowledge about Records represented in the system. module _ (∈QC⇒AllSent : Complete InSys) where -- For a /complete/ system we can go even further; if we have evidence that -- only the tip of the record chains is in the system, we can infer -- the rest of it is also in the system (or blockIDs are not injective). CommitsDoNotConflict' : ∀{q q'}{rc : RecordChain (Q q)}{rc' : RecordChain (Q q')}{b b' : Block} → InSys (Q q) → InSys (Q q') → CommitRule rc b → CommitRule rc' b' → NonInjective-≡ bId ⊎ ((B b) ∈RC rc' ⊎ (B b') ∈RC rc) CommitsDoNotConflict' {q} {q'} {step {r = B bb} rc b←q} {step {r = B bb'} rc' b←q'} {b} {b'} q∈sys q'∈sys cr cr' with bft-assumption (qVotes-C1 q) (qVotes-C1 q') ...| α , α∈qmem , α∈q'mem , hα with Any-sym (Any-map⁻ α∈qmem) | Any-sym (Any-map⁻ α∈q'mem) ...| α∈q | α∈q' with ∈QC⇒AllSent {q = q} hα α∈q q∈sys | ∈QC⇒AllSent {q = q'} hα α∈q' q'∈sys ...| ab , (arc , ais) , ab←q | ab' , (arc' , ais') , ab←q' with RecordChain-irrelevant (step arc ab←q) (step rc b←q) | RecordChain-irrelevant (step arc' ab←q') (step rc' b←q') ...| inj₁ hb | _ = inj₁ hb ...| inj₂ _ | inj₁ hb = inj₁ hb ...| inj₂ arc≈rc | inj₂ arc'≈rc' with CommitsDoNotConflict (All-InSys-step ais ab←q q∈sys ) (All-InSys-step ais' ab←q' q'∈sys) (transp-CR (≈RC-sym arc≈rc ) cr ) (transp-CR (≈RC-sym arc'≈rc') cr') ...| inj₁ hb = inj₁ hb ...| inj₂ (inj₁ b∈arc') = inj₂ (inj₁ (transp-B∈RC arc'≈rc' b∈arc')) ...| inj₂ (inj₂ b'∈arc) = inj₂ (inj₂ (transp-B∈RC arc≈rc b'∈arc)) -- The final property is even stronger; it states that even if an observer -- has access only to suffixes of record chains that match the commit rule, -- we can still guarantee that b and b' are non-conflicting blocks. This -- will be important for showing that observers can have confidence in commit -- messages without participating in the protocol and without having access to -- all previously sent records. CommitsDoNotConflict'' : ∀{o o' q q'} → {rcf : RecordChainFrom o (Q q)} → {rcf' : RecordChainFrom o' (Q q')} → {b b' : Block} → InSys (Q q) → InSys (Q q') → CommitRuleFrom rcf b → CommitRuleFrom rcf' b' → NonInjective-≡ bId ⊎ Σ (RecordChain (Q q')) ((B b) ∈RC_) ⊎ Σ (RecordChain (Q q)) ((B b') ∈RC_) CommitsDoNotConflict'' {cb} {q = q} {q'} {rcf} {rcf'} q∈sys q'∈sys crf crf' with bft-assumption (qVotes-C1 q) (qVotes-C1 q') ...| α , α∈qmem , α∈q'mem , hα with Any-sym (Any-map⁻ α∈qmem) | Any-sym (Any-map⁻ α∈q'mem) ...| α∈q | α∈q' with ∈QC⇒AllSent {q = q} hα α∈q q∈sys | ∈QC⇒AllSent {q = q'} hα α∈q' q'∈sys ...| ab , (arc , ais) , ab←q | ab' , (arc' , ais') , ab←q' with step arc ab←q | step arc' ab←q' ...| rcq | rcq' with crf⇒cr rcf rcq crf | crf⇒cr rcf' rcq' crf' ...| inj₁ hb | _ = inj₁ hb ...| inj₂ _ | inj₁ hb = inj₁ hb ...| inj₂ cr | inj₂ cr' with CommitsDoNotConflict' q∈sys q'∈sys cr cr' ...| inj₁ hb = inj₁ hb ...| inj₂ (inj₁ b∈arc') = inj₂ (inj₁ (rcq' , b∈arc')) ...| inj₂ (inj₂ b'∈arc) = inj₂ (inj₂ (rcq , b'∈arc))
{ "alphanum_fraction": 0.6065516641, "avg_line_length": 46.2822580645, "ext": "agda", "hexsha": "ee14fcbcaa062a2b01f39f7579c1517e43366607", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Abstract/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Abstract/Properties.agda", "max_line_length": 116, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Abstract/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2009, "size": 5739 }
module Identity where data _==_ {A : Set}(x : A) : A -> Set where refl : x == x elim== : {A : Set}(x : A)(C : (y : A) -> x == y -> Set) -> C x refl -> (y : A) -> (p : x == y) -> C y p elim== x C Cx .x refl = Cx elim==₁ : {A : Set}(x : A)(C : (y : A) -> x == y -> Set1) -> C x refl -> (y : A) -> (p : x == y) -> C y p elim==₁ x C Cx .x refl = Cx sym : {A : Set}{x y : A} -> x == y -> y == x sym {A}{x}{y} eq = elim== x (\z _ -> z == x) refl y eq cong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y cong {A} f {x}{y} eq = elim== x (\z _ -> f x == f z) refl y eq subst : {A : Set}{x y : A}(P : A -> Set) -> x == y -> P x -> P y subst P xy px = elim== _ (\z _ -> P z) px _ xy subst₁ : {A : Set}{x y : A}(P : A -> Set1) -> x == y -> P x -> P y subst₁ P xy px = elim==₁ _ (\z _ -> P z) px _ xy symRef : (A : Set)(x : A) -> sym (refl{A}{x}) == refl symRef A x = refl symSym : {A : Set}{x y : A}(p : x == y) -> sym (sym p) == p symSym {A}{x}{y} p = elim== x (\y q -> sym (sym q) == q) refl y p -- Proving the symmetric elimination rule is not trivial. elimS : {A : Set}(x : A)(C : (y : A) -> y == x -> Set) -> C x refl -> (y : A) -> (p : y == x) -> C y p elimS x C r y p = subst (C y) (symSym p) h where h : C y (sym (sym p)) h = elim== x (\y p -> C y (sym p)) r y (sym p) data _==¹_ {A : Set1}(x : A) : {B : Set1} -> B -> Set where refl¹ : x ==¹ x subst¹ : {A : Set1}{x y : A}(P : A -> Set) -> x ==¹ y -> P x -> P y subst¹ {A} P refl¹ px = px
{ "alphanum_fraction": 0.4264705882, "avg_line_length": 31.829787234, "ext": "agda", "hexsha": "df2308b02c0dcc0e57a0c7d0b1d8f00833f0228b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/iird/Identity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/iird/Identity.agda", "max_line_length": 67, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/iird/Identity.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 655, "size": 1496 }
{-# OPTIONS --no-auto-inline #-} module Haskell.Prim.Num where open import Agda.Builtin.Nat as Nat hiding (_+_; _-_; _*_; _<_; _==_) open import Agda.Builtin.Int using (pos; negsuc) open import Agda.Builtin.FromNat open import Agda.Builtin.FromNeg open import Agda.Builtin.Unit open import Haskell.Prim open import Haskell.Prim.Word open import Haskell.Prim.Int open import Haskell.Prim.Integer open import Haskell.Prim.Double open import Haskell.Prim.Eq open import Haskell.Prim.Ord open import Haskell.Prim.Monoid -------------------------------------------------- -- Num record Num (a : Set) : Set₁ where infixl 6 _+_ _-_ infixl 7 _*_ field MinusOK : a → a → Set NegateOK : a → Set FromIntegerOK : Integer → Set _+_ : a → a → a _-_ : (x y : a) → ⦃ MinusOK x y ⦄ → a _*_ : a → a → a negate : (x : a) → ⦃ NegateOK x ⦄ → a abs : a → a signum : a → a fromInteger : (n : Integer) → ⦃ FromIntegerOK n ⦄ → a overlap ⦃ number ⦄ : Number a overlap ⦃ numZero ⦄ : number .Number.Constraint 0 overlap ⦃ numOne ⦄ : number .Number.Constraint 1 open Num ⦃ ... ⦄ public hiding (FromIntegerOK; number) instance iNumNat : Num Nat iNumNat .MinusOK n m = IsFalse (n Nat.< m) iNumNat .NegateOK 0 = ⊤ iNumNat .NegateOK (suc _) = ⊥ iNumNat .Num.FromIntegerOK (negsuc _) = ⊥ iNumNat .Num.FromIntegerOK (pos _) = ⊤ iNumNat ._+_ n m = n Nat.+ m iNumNat ._-_ n m = n Nat.- m iNumNat ._*_ n m = n Nat.* m iNumNat .negate n = n iNumNat .abs n = n iNumNat .signum 0 = 0 iNumNat .signum (suc n) = 1 iNumNat .fromInteger (pos n) = n iNumNat .fromInteger (negsuc _) ⦃ () ⦄ iNumInt : Num Int iNumInt .MinusOK _ _ = ⊤ iNumInt .NegateOK _ = ⊤ iNumInt .Num.FromIntegerOK _ = ⊤ iNumInt ._+_ x y = addInt x y iNumInt ._-_ x y = subInt x y iNumInt ._*_ x y = mulInt x y iNumInt .negate x = negateInt x iNumInt .abs x = absInt x iNumInt .signum x = signInt x iNumInt .fromInteger n = integerToInt n iNumInteger : Num Integer iNumInteger .MinusOK _ _ = ⊤ iNumInteger .NegateOK _ = ⊤ iNumInteger .Num.FromIntegerOK _ = ⊤ iNumInteger ._+_ x y = addInteger x y iNumInteger ._-_ x y = subInteger x y iNumInteger ._*_ x y = mulInteger x y iNumInteger .negate x = negateInteger x iNumInteger .abs x = absInteger x iNumInteger .signum x = signInteger x iNumInteger .fromInteger n = n iNumWord : Num Word iNumWord .MinusOK _ _ = ⊤ iNumWord .NegateOK _ = ⊤ iNumWord .Num.FromIntegerOK _ = ⊤ iNumWord ._+_ x y = addWord x y iNumWord ._-_ x y = subWord x y iNumWord ._*_ x y = mulWord x y iNumWord .negate x = negateWord x iNumWord .abs x = x iNumWord .signum x = if x == 0 then 0 else 1 iNumWord .fromInteger n = integerToWord n iNumDouble : Num Double iNumDouble .MinusOK _ _ = ⊤ iNumDouble .NegateOK _ = ⊤ iNumDouble .Num.FromIntegerOK _ = ⊤ iNumDouble ._+_ x y = primFloatPlus x y iNumDouble ._-_ x y = primFloatMinus x y iNumDouble ._*_ x y = primFloatTimes x y iNumDouble .negate x = primFloatMinus 0.0 x iNumDouble .abs x = if x < 0.0 then primFloatMinus 0.0 x else x iNumDouble .signum x = case compare x 0.0 of λ where LT → -1.0 EQ → x GT → 1.0 iNumDouble .fromInteger (pos n) = fromNat n iNumDouble .fromInteger (negsuc n) = fromNeg (suc n) MonoidSum : ⦃ iNum : Num a ⦄ → Monoid a MonoidSum .mempty = 0 MonoidSum .super ._<>_ = _+_ MonoidProduct : ⦃ iNum : Num a ⦄ → Monoid a MonoidProduct .mempty = 1 MonoidProduct .super ._<>_ = _*_
{ "alphanum_fraction": 0.5572763029, "avg_line_length": 34.1848739496, "ext": "agda", "hexsha": "b7730b3959ecadd50700cca0a56ca4ce01d59e23", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/agda2hs", "max_forks_repo_path": "lib/Haskell/Prim/Num.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/agda2hs", "max_issues_repo_path": "lib/Haskell/Prim/Num.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/agda2hs", "max_stars_repo_path": "lib/Haskell/Prim/Num.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1381, "size": 4068 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some derivable properties ------------------------------------------------------------------------ open import Algebra module Algebra.Properties.Lattice {l₁ l₂} (L : Lattice l₁ l₂) where open Lattice L 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 ∧-idempotent : Idempotent _∧_ ∧-idempotent x = begin x ∧ x ≈⟨ refl ⟨ ∧-cong ⟩ sym (proj₁ absorptive _ _) ⟩ x ∧ (x ∨ x ∧ x) ≈⟨ proj₂ absorptive _ _ ⟩ x ∎ ∨-idempotent : Idempotent _∨_ ∨-idempotent x = begin x ∨ x ≈⟨ refl ⟨ ∨-cong ⟩ sym (∧-idempotent _) ⟩ x ∨ x ∧ x ≈⟨ proj₁ absorptive _ _ ⟩ x ∎ -- The dual construction is also a lattice. ∧-∨-isLattice : IsLattice _≈_ _∧_ _∨_ ∧-∨-isLattice = record { isEquivalence = isEquivalence ; ∨-comm = ∧-comm ; ∨-assoc = ∧-assoc ; ∨-cong = ∧-cong ; ∧-comm = ∨-comm ; ∧-assoc = ∨-assoc ; ∧-cong = ∨-cong ; absorptive = swap absorptive } ∧-∨-lattice : Lattice _ _ ∧-∨-lattice = record { _∧_ = _∨_ ; _∨_ = _∧_ ; isLattice = ∧-∨-isLattice } -- Every lattice can be turned into a poset. poset : Poset _ _ _ poset = record { Carrier = Carrier ; _≈_ = _≈_ ; _≤_ = λ x y → x ≈ x ∧ y ; isPartialOrder = record { isPreorder = record { isEquivalence = isEquivalence ; reflexive = λ {i} {j} i≈j → begin i ≈⟨ sym $ ∧-idempotent _ ⟩ i ∧ i ≈⟨ ∧-cong refl i≈j ⟩ i ∧ j ∎ ; trans = λ {i} {j} {k} i≈i∧j j≈j∧k → begin i ≈⟨ i≈i∧j ⟩ i ∧ j ≈⟨ ∧-cong refl j≈j∧k ⟩ i ∧ (j ∧ k) ≈⟨ sym (∧-assoc _ _ _) ⟩ (i ∧ j) ∧ k ≈⟨ ∧-cong (sym i≈i∧j) refl ⟩ i ∧ k ∎ } ; antisym = λ {x} {y} x≈x∧y y≈y∧x → begin x ≈⟨ x≈x∧y ⟩ x ∧ y ≈⟨ ∧-comm _ _ ⟩ y ∧ x ≈⟨ sym y≈y∧x ⟩ y ∎ } } -- One can replace the underlying equality with an equivalent one. replace-equality : {_≈′_ : Rel Carrier l₂} → (∀ {x y} → x ≈ y ⇔ x ≈′ y) → Lattice _ _ replace-equality {_≈′_} ≈⇔≈′ = record { _≈_ = _≈′_ ; _∧_ = _∧_ ; _∨_ = _∨_ ; isLattice = record { isEquivalence = record { refl = to ⟨$⟩ refl ; sym = λ x≈y → to ⟨$⟩ sym (from ⟨$⟩ x≈y) ; trans = λ x≈y y≈z → to ⟨$⟩ trans (from ⟨$⟩ x≈y) (from ⟨$⟩ y≈z) } ; ∨-comm = λ x y → to ⟨$⟩ ∨-comm x y ; ∨-assoc = λ x y z → to ⟨$⟩ ∨-assoc x y z ; ∨-cong = λ x≈y u≈v → to ⟨$⟩ ∨-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v) ; ∧-comm = λ x y → to ⟨$⟩ ∧-comm x y ; ∧-assoc = λ x y z → to ⟨$⟩ ∧-assoc x y z ; ∧-cong = λ x≈y u≈v → to ⟨$⟩ ∧-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v) ; absorptive = (λ x y → to ⟨$⟩ proj₁ absorptive x y) , (λ x y → to ⟨$⟩ proj₂ absorptive x y) } } where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})
{ "alphanum_fraction": 0.4404384194, "avg_line_length": 32.4018691589, "ext": "agda", "hexsha": "13d039104419bf020adf0c94637845186e5f5e7a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 1347, "size": 3467 }
{-# OPTIONS --without-K --safe #-} -- Some of the obvious properties of cartesian functors module Categories.Functor.Cartesian.Properties where open import Level open import Data.Product using (Σ ; _,_) open import Categories.Category open import Categories.Category.Cartesian.Structure open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Functor.Properties open import Categories.Functor.Cartesian open import Categories.Functor.Monoidal open import Categories.NaturalTransformation import Categories.Morphism as M import Categories.Morphism.Reasoning as MR import Categories.Object.Terminal as ⊤ import Categories.Object.Product as P private variable o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ : Level module _ (C : CartesianCategory o ℓ e) where open CartesianCategory C open P U idF-IsCartesianF : IsCartesianF C C idF idF-IsCartesianF = record { F-resp-⊤ = terminal.⊤-is-terminal ; F-resp-× = Product⇒IsProduct product } idF-CartesianF : CartesianF C C idF-CartesianF = record { isCartesian = idF-IsCartesianF } module _ (A : CartesianCategory o ℓ e) (B : CartesianCategory o′ ℓ′ e′) (C : CartesianCategory o″ ℓ″ e″) where private module A = CartesianCategory A module B = CartesianCategory B module C = CartesianCategory C open P C.U ∘-IsCartesianF : ∀ {F : Functor A.U B.U} {G : Functor B.U C.U} → IsCartesianF B C G → IsCartesianF A B F → IsCartesianF A C (G ∘F F) ∘-IsCartesianF {F} {G} CG CF = record { F-resp-⊤ = ⊤.Terminal.⊤-is-terminal (⊤.transport-by-iso C.U C.terminal (M.≅.trans C.U (M.≅.sym C.U CG.⊤-iso) ([ G ]-resp-≅ (M.≅.sym B.U CF.⊤-iso)))) ; F-resp-× = record { ⟨_,_⟩ = λ f g → G.₁ (CF.×-iso.to _ _) C.∘ CG.×-iso.to _ _ C.∘ C.⟨ f , g ⟩ ; project₁ = λ {_ f g} → begin G.₁ (F.₁ A.π₁) C.∘ G.₁ (CF.×-iso.to _ _) C.∘ CG.×-iso.to _ _ C.∘ C.⟨ f , g ⟩ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ([ CG.F-prod _ _ ]⟨⟩∘ ○ CG.F-prod.⟨⟩-cong₂ _ _ C.project₁ C.project₂) ⟩ G.₁ (F.₁ A.π₁) C.∘ G.₁ (CF.×-iso.to _ _) C.∘ CG.F-resp-×.⟨ f , g ⟩ ≈⟨ pullˡ ([ G ]-resp-∘ CF.F-resp-×.project₁) ⟩ G.₁ B.π₁ C.∘ CG.F-resp-×.⟨ f , g ⟩ ≈⟨ CG.F-resp-×.project₁ ⟩ f ∎ ; project₂ = λ {_ f g} → begin G.₁ (F.₁ A.π₂) C.∘ G.₁ (CF.×-iso.to _ _) C.∘ CG.×-iso.to _ _ C.∘ C.⟨ f , g ⟩ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ([ CG.F-prod _ _ ]⟨⟩∘ ○ CG.F-prod.⟨⟩-cong₂ _ _ C.project₁ C.project₂) ⟩ G.₁ (F.₁ A.π₂) C.∘ G.₁ (CF.×-iso.to _ _) C.∘ CG.F-resp-×.⟨ f , g ⟩ ≈⟨ pullˡ ([ G ]-resp-∘ CF.F-resp-×.project₂) ⟩ G.₁ B.π₂ C.∘ CG.F-resp-×.⟨ f , g ⟩ ≈⟨ CG.F-resp-×.project₂ ⟩ g ∎ ; unique = λ {_ h f g} eq₁ eq₂ → begin G.₁ (CF.×-iso.to _ _) C.∘ CG.×-iso.to _ _ C.∘ C.⟨ f , g ⟩ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ C.unique′ (C.project₁ ○ ⟺ eq₁ ○ pushˡ (⟺ ([ G ]-resp-∘ B.project₁)) ○ pushˡ (⟺ C.project₁)) (C.project₂ ○ ⟺ eq₂ ○ pushˡ (⟺ ([ G ]-resp-∘ B.project₂)) ○ pushˡ (⟺ C.project₂)) ⟩ G.₁ (CF.×-iso.to _ _) C.∘ CG.×-iso.to _ _ C.∘ CG.×-iso.from _ _ C.∘ G.₁ (CF.×-iso.from _ _) C.∘ h ≈⟨ refl⟩∘⟨ cancelˡ (CG.×-iso.isoˡ _ _) ⟩ G.₁ (CF.×-iso.to _ _) C.∘ G.₁ (CF.×-iso.from _ _) C.∘ h ≈⟨ cancelˡ (M._≅_.isoˡ ([ G ]-resp-≅ (CF.×-iso _ _))) ⟩ h ∎ } } where module F = Functor F module G = Functor G module CG = IsCartesianF CG module CF = IsCartesianF CF open C.HomReasoning open MR C.U ∘-CartesianF : {A : CartesianCategory o ℓ e} {B : CartesianCategory o′ ℓ′ e′} {C : CartesianCategory o″ ℓ″ e″} → CartesianF B C → CartesianF A B → CartesianF A C ∘-CartesianF G F = record { isCartesian = ∘-IsCartesianF _ _ _ (CartesianF.isCartesian G) (CartesianF.isCartesian F) } module _ {C : CartesianCategory o ℓ e} {D : CartesianCategory o′ ℓ′ e′} where private module C = CartesianCategory C module D = CartesianCategory D open D.HomReasoning open MR D.U open M D.U isMonoidalFunctor : CartesianF C D → MonoidalFunctor C.monoidalCategory D.monoidalCategory isMonoidalFunctor F = record { F = F.F ; isMonoidal = record { ε = F.⊤-iso.to ; ⊗-homo = ntHelper record { η = λ { (X , Y) → F.×-iso.to X Y } ; commute = λ { {X , Y} {Z , W} (f , g) → F.F-prod.unique′ _ _ (begin F.₁ C.π₁ D.∘ F.×-iso.to Z W D.∘ (F.₁ f D.⁂ F.₁ g) ≈⟨ pullˡ F.F-resp-×.project₁ ⟩ D.π₁ D.∘ (F.₁ f D.⁂ F.₁ g) ≈⟨ D.project₁ ⟩ F.₁ f D.∘ D.π₁ ≈˘⟨ pullʳ F.F-resp-×.project₁ ⟩ (F.₁ f D.∘ F.₁ C.π₁) D.∘ F.×-iso.to X Y ≈˘⟨ pullˡ ([ F.F ]-resp-square C.project₁) ⟩ F.₁ C.π₁ D.∘ F.₁ (f C.⁂ g) D.∘ F.×-iso.to X Y ∎) (begin F.₁ C.π₂ D.∘ F.×-iso.to Z W D.∘ (F.₁ f D.⁂ F.₁ g) ≈⟨ pullˡ F.F-resp-×.project₂ ⟩ D.π₂ D.∘ (F.₁ f D.⁂ F.₁ g) ≈⟨ D.project₂ ⟩ F.₁ g D.∘ D.π₂ ≈˘⟨ pullʳ F.F-resp-×.project₂ ⟩ (F.₁ g D.∘ F.₁ C.π₂) D.∘ F.×-iso.to X Y ≈˘⟨ pullˡ ([ F.F ]-resp-square C.project₂) ⟩ F.₁ C.π₂ D.∘ F.₁ (f C.⁂ g) D.∘ F.×-iso.to X Y ∎) } } ; associativity = λ {X Y Z} → let open P D.U in begin F.₁ C.associator.from D.∘ F.×-iso.to (X C.× Y) Z D.∘ (F.×-iso.to X Y D.⁂ D.id) ≈⟨ F.F-resp-⟨⟩′ _ _ ⟩∘⟨ [ D.product ⇒ D.product ⇒ F.F-prod _ _ ]repack∘× ⟩ F.F-resp-×.⟨ F.₁ (C.π₁ C.∘ C.π₁) , F.₁ C.⟨ C.π₂ C.∘ C.π₁ , C.π₂ ⟩ ⟩ D.∘ F.F-resp-×.⟨ F.×-iso.to X Y D.∘ D.π₁ , D.id D.∘ D.π₂ ⟩ ≈⟨ F.F-prod.⟨⟩-cong₂ _ _ F.homomorphism (F.F-resp-⟨⟩′ _ _ ○ F.F-prod.⟨⟩-cong₂ _ _ F.homomorphism D.Equiv.refl) ⟩∘⟨refl ⟩ F.F-resp-×.⟨ F.₁ C.π₁ D.∘ F.₁ C.π₁ , F.F-resp-×.⟨ F.₁ C.π₂ D.∘ F.₁ C.π₁ , F.₁ C.π₂ ⟩ ⟩ D.∘ F.F-resp-×.⟨ F.×-iso.to X Y D.∘ D.π₁ , D.id D.∘ D.π₂ ⟩ ≈⟨ [ F.F-prod _ _ ]⟨⟩∘ ⟩ F.F-resp-×.⟨ (F.₁ C.π₁ D.∘ F.₁ C.π₁) D.∘ _ , F.F-resp-×.⟨ F.₁ C.π₂ D.∘ F.₁ C.π₁ , F.₁ C.π₂ ⟩ D.∘ _ ⟩ ≈⟨ F.F-prod.⟨⟩-cong₂ _ _ (pullʳ F.F-resp-×.project₁ ○ pullˡ F.F-resp-×.project₁) [ F.F-prod _ _ ]⟨⟩∘ ⟩ F.F-resp-×.⟨ D.π₁ D.∘ D.π₁ , F.F-resp-×.⟨ (F.₁ C.π₂ D.∘ F.₁ C.π₁) D.∘ _ , F.₁ C.π₂ D.∘ _ ⟩ ⟩ ≈⟨ F.F-prod.⟨⟩-cong₂ _ _ D.Equiv.refl (F.F-prod.⟨⟩-cong₂ _ _ (pullʳ F.F-resp-×.project₁ ○ pullˡ F.F-resp-×.project₂) (F.F-resp-×.project₂ ○ D.identityˡ)) ⟩ F.F-resp-×.⟨ D.π₁ D.∘ D.π₁ , F.F-resp-×.⟨ D.π₂ D.∘ D.π₁ , D.π₂ ⟩ ⟩ ≈˘⟨ F.F-prod.⟨⟩-cong₂ _ _ D.identityˡ ([ F.F-prod _ _ ]⟨⟩∘ ○ (F.F-prod.⟨⟩-cong₂ _ _ D.project₁ D.project₂)) ⟩ F.F-resp-×.⟨ D.id D.∘ D.π₁ D.∘ D.π₁ , F.×-iso.to Y Z D.∘ D.⟨ D.π₂ D.∘ D.π₁ , D.π₂ ⟩ ⟩ ≈˘⟨ [ D.product ⇒ (F.F-prod _ _) ]×∘⟨⟩ ⟩ F.F-resp-×.⟨ D.id D.∘ D.π₁ , F.×-iso.to Y Z D.∘ D.π₂ ⟩ D.∘ D.associator.from ≈˘⟨ pullˡ [ D.product ⇒ D.product ⇒ F.F-prod _ _ ]repack∘× ⟩ F.×-iso.to X (Y C.× Z) D.∘ (D.id D.⁂ F.×-iso.to Y Z) D.∘ D.associator.from ∎ ; unitaryˡ = begin F.₁ C.π₂ D.∘ F.F-resp-×.⟨ D.π₁ , D.π₂ ⟩ D.∘ (F.F-resp-⊤.! D.⁂ D.id) ≈⟨ pullˡ F.F-resp-×.project₂ ⟩ D.π₂ D.∘ (F.F-resp-⊤.! D.⁂ D.id) ≈⟨ D.project₂ ⟩ D.id D.∘ D.π₂ ≈⟨ D.identityˡ ⟩ D.π₂ ∎ ; unitaryʳ = begin F.₁ C.π₁ D.∘ F.F-resp-×.⟨ D.π₁ , D.π₂ ⟩ D.∘ (D.id D.⁂ F.F-resp-⊤.!) ≈⟨ pullˡ F.F-resp-×.project₁ ⟩ D.π₁ D.∘ (D.id D.⁂ F.F-resp-⊤.!) ≈⟨ D.project₁ ⟩ D.id D.∘ D.π₁ ≈⟨ D.identityˡ ⟩ D.π₁ ∎ } } where module F = CartesianF F isStrongMonoidalFunctor : CartesianF C D → StrongMonoidalFunctor C.monoidalCategory D.monoidalCategory isStrongMonoidalFunctor F = record { F = F.F ; isStrongMonoidal = record { ε = ≅.sym F.⊤-iso ; ⊗-homo = record { F⇒G = MF.⊗-homo ; F⇐G = ntHelper record { η = λ { (X , Y) → F.×-iso.from X Y } ; commute = λ { {X , Y} {Z , W} (f , g) → begin D.⟨ F.₁ C.π₁ , F.₁ C.π₂ ⟩ D.∘ F.₁ (f C.⁂ g) ≈⟨ D.⟨⟩∘ ⟩ D.⟨ F.₁ C.π₁ D.∘ F.₁ (f C.⁂ g) , F.₁ C.π₂ D.∘ F.₁ (f C.⁂ g) ⟩ ≈⟨ D.⟨⟩-cong₂ ([ F.F ]-resp-square C.project₁) ([ F.F ]-resp-square C.project₂) ⟩ D.⟨ F.₁ f D.∘ F.F₁ C.π₁ , F.₁ g D.∘ F.F₁ C.π₂ ⟩ ≈˘⟨ D.⁂∘⟨⟩ ⟩ (F.₁ f D.⁂ F.₁ g) D.∘ D.⟨ F.F₁ C.π₁ , F.F₁ C.π₂ ⟩ ∎ } } ; iso = λ { (X , Y) → record { isoˡ = F.×-iso.isoʳ X Y ; isoʳ = F.×-iso.isoˡ X Y } } } ; associativity = MF.associativity ; unitaryˡ = MF.unitaryˡ ; unitaryʳ = MF.unitaryʳ } } where module F = CartesianF F module MF = MonoidalFunctor (isMonoidalFunctor F)
{ "alphanum_fraction": 0.4630865374, "avg_line_length": 51.3097826087, "ext": "agda", "hexsha": "daf13df4a4255e2d3daaffb765a88b573528066a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Cartesian/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Cartesian/Properties.agda", "max_line_length": 175, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Cartesian/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 4149, "size": 9441 }
-- Andreas, 2012-05-24, issue reported by Nisse {-# OPTIONS --allow-unsolved-metas #-} -- {-# OPTIONS -v tc.meta:50 #-} module Issue658 where import Common.Level postulate A : Set P : A → Set Q : (x : A) → P x → Set p : (x : A) → P x record R : Set where field a : A r : R r = {!!} postulate q : Q (R.a r) (p (R.a r)) -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/TypeChecking/MetaVars.hs:101 -- The internal error was cause by eta-expanding the frozen meta. -- Eta-expansion of frozen metas is now allowed.
{ "alphanum_fraction": 0.6383701188, "avg_line_length": 20.3103448276, "ext": "agda", "hexsha": "50897da48e4aca86bb43f22165320f9975904490", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue658.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue658.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue658.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 191, "size": 589 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Hash open import LibraBFT.Abstract.Types open import LibraBFT.Impl.NetworkMsg open import LibraBFT.Impl.Consensus.Types open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Concrete.Obligations import LibraBFT.Concrete.Properties.VotesOnce as VO import LibraBFT.Concrete.Properties.LockedRound as LR open import LibraBFT.Yasm.System ConcSysParms open import LibraBFT.Yasm.Properties ConcSysParms -- In this module, we assume that the implementation meets its -- obligations, and use this assumption to prove that the -- implementatioon enjoys one of the per-epoch correctness conditions -- proved in Abstract.Properties. It can be extended to other -- properties later. module LibraBFT.Concrete.Properties (impl-correct : ImplObligations) where open ImplObligations impl-correct -- For any reachable state, module _ {e}(st : SystemState e)(r : ReachableSystemState st)(eid : Fin e) where open import LibraBFT.Concrete.System sps-cor open PerState st r open PerEpoch eid import LibraBFT.Abstract.Records 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) as Abs open import LibraBFT.Abstract.RecordChain 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) open import LibraBFT.Abstract.System 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) open import LibraBFT.Abstract.Properties 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) open import LibraBFT.Abstract.Obligations.VotesOnce 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) open import LibraBFT.Abstract.Obligations.LockedRound 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) validState : ValidSysState ConcSystemState validState = record { vss-votes-once = VO.Proof.voo sps-cor vo₁ vo₂ st r eid ; vss-locked-round = LR.Proof.lrr sps-cor lr₁ st r eid } open All-InSys-props (AbsSystemState.InSys ConcSystemState) -- commited blocks do not conflict. S5 : ∀{q q'} → {rc : RecordChain (Abs.Q q)} → All-InSys rc → {rc' : RecordChain (Abs.Q q')} → All-InSys rc' → {b b' : Abs.Block} → CommitRule rc b → CommitRule rc' b' → NonInjective-≡ Abs.bId ⊎ ((Abs.B b) ∈RC rc' ⊎ (Abs.B b') ∈RC rc) S5 = CommitsDoNotConflict ConcSystemState validState
{ "alphanum_fraction": 0.7509113001, "avg_line_length": 39.8225806452, "ext": "agda", "hexsha": "32b6f679d16522bbfbbf7fb37ecee84889fdcd77", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_forks_repo_path": "LibraBFT/Concrete/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_issues_repo_path": "LibraBFT/Concrete/Properties.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_stars_repo_path": "LibraBFT/Concrete/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 727, "size": 2469 }
{-# OPTIONS --without-K --safe #-} -- Pi combinators inspired by duals and traced monoidal categories module PiPointedFracTrace where open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality open import PiPointedFrac ------------------------------------------------------------------ dual : {A B : ∙𝕌} → (f : A ∙⟶ B) → (Recipᵤ B ∙⟶ Recipᵤ A) dual {A} {B} f = ∙uniti⋆l ∙⊚ (η A ∙⊗ ∙id⟷) ∙⊚ ((∙Singᵤ f ∙⊗ ∙id⟷) ∙⊗ ∙id⟷) ∙⊚ ∙assocr⋆ ∙⊚ (∙id⟷ ∙⊗ ∙swap⋆) ∙⊚ ∙assocl⋆ ∙⊚ (ε B ∙⊗ ∙id⟷) ∙⊚ ∙unite⋆l -- name, coname name : {A B : ∙𝕌} → (f : A ∙⟶ B) → ∙𝟙 ∙⟶ Singᵤ B ∙×ᵤ Recipᵤ A name {A} {B} f = η A ∙⊚ (∙Singᵤ f ∙⊗ ∙id⟷) coname : {A B : ∙𝕌} → (f : A ∙⟶ B) → Singᵤ A ∙×ᵤ Recipᵤ B ∙⟶ ∙𝟙 coname {A} {B} f = (∙Singᵤ f ∙⊗ ∙id⟷) ∙⊚ ε B -- and 'trace' reveals something neat: we can't choose just any random 'a' and 'c' -- to start with, but we need that make a coherence choice of a and c !! trace : {A B C : ∙𝕌} → (f : A ∙×ᵤ C ∙⟶ B ∙×ᵤ C) → A ∙⟶ B trace {A} {B} {C} f = ∙uniti⋆r ∙⊚ -- A ×ᵤ 1 (return _ ∙⊗ η C) ∙⊚ -- A ×ᵤ (C ×ᵤ 1/C) ∙assocl⋆ ∙⊚ -- (A ×ᵤ C) ×ᵤ 1/C (tensor ∙⊗ ∙id⟷) ∙⊚ -- bring in the ● (∙Singᵤ f ∙⊗ ∙id⟷) ∙⊚ -- (B ×ᵤ C) ×ᵤ 1/C (untensor ∙⊗ ∙id⟷) ∙⊚ -- bring out the ● ∙assocr⋆ ∙⊚ -- B ×ᵤ (C ×ᵤ 1/C) (extract _ ∙⊗ ε C) ∙⊚ ∙unite⋆r -- Trace terminates! The type C is pointed with point c; trace uses c -- as the initial value for C. So f gets two values (a,c). It can do -- whatever to produce (b',c'). But f is reversible so it is limited -- to essentially either id or swap. Makes sense??? 𝔹 : 𝕌 𝔹 = 𝟙 +ᵤ 𝟙 𝔽 𝕋 : ⟦ 𝔹 ⟧ 𝔽 = inj₁ tt 𝕋 = inj₂ tt zz1 : (A : 𝕌) (v : ⟦ A ⟧) → Σ (⟦ A ⟧ → ⟦ A ⟧) (λ f → f v ≡ v) zz1 A v = ∙eval (trace {A # v} ∙swap⋆) zz3 : (A : 𝕌) (v : ⟦ A ⟧) (T : ∙𝕌) → Σ (⟦ A ⟧ → ⟦ A ⟧) (λ f → f v ≡ v) zz3 A v T = ∙eval (trace {A # v} {_} {T} ∙id⟷) -- There are more thing you can put in trace as long as c is the fixpoint NOT : 𝔹 ⟷ 𝔹 NOT = swap₊ CONTROLLED : {A : 𝕌} → (A ⟷ A) → 𝔹 ×ᵤ A ⟷ 𝔹 ×ᵤ A CONTROLLED c = dist ⊚ (id⟷ ⊕ (id⟷ ⊗ c)) ⊚ factor CNOT : 𝔹 ×ᵤ 𝔹 ⟷ 𝔹 ×ᵤ 𝔹 CNOT = CONTROLLED NOT ex1 : ∀ {b} → 𝔹 # b ∙⟶ 𝔹 # b ex1 = trace {C = 𝔹 # 𝔽} (∙swap⋆ ∙⊚ ∙#times ∙⊚ ∙c CNOT ∙⊚ ∙times# ∙⊚ ∙swap⋆) -- Example in Sec. 4.3 from Abramsky's paper -- http://www.cs.ox.ac.uk/files/341/calco05.pdf ∙q : {A1 A2 A3 A4 B1 B2 B3 B4 : ∙𝕌} → (f1 : A1 ∙⟶ B2) → (f2 : A2 ∙⟶ B4) → (f3 : A3 ∙⟶ B3) → (f4 : A4 ∙⟶ B1) → A1 ∙×ᵤ (A2 ∙×ᵤ (A3 ∙×ᵤ A4)) ∙⟶ B1 ∙×ᵤ (B2 ∙×ᵤ (B3 ∙×ᵤ B4)) ∙q {A1} {A2} {A3} {A4} {B1} {B2} {B3} {B4} f1 f2 f3 f4 = (f1 ∙⊗ (f2 ∙⊗ (f3 ∙⊗ f4))) ∙⊚ ∙assocl⋆ ∙⊚ ∙swap⋆ ∙⊚ ∙swap⋆ ∙⊗ ∙id⟷ ∙⊚ ∙assocr⋆ ∙⊚ (∙id⟷ ∙⊗ ∙assocl⋆) ∙⊚ ∙id⟷ ∙⊗ (∙swap⋆ ∙⊗ ∙id⟷ ∙⊚ ∙assocr⋆) ∙q' : {A1 U2 U3 U4 B1 : ∙𝕌} → (f1 : A1 ∙⟶ U2) → (f2 : U2 ∙⟶ U4) → (f3 : U3 ∙⟶ U3) → (f4 : U4 ∙⟶ B1) → A1 ∙⟶ B1 ∙q' f1 f2 f3 f4 = trace (∙q f1 f2 f3 f4) _⊸_ : (A B : ∙𝕌) → ∙𝕌 A ⊸ B = Recipᵤ A ∙×ᵤ Singᵤ B id⊸ : {A : ∙𝕌} → (A ⊸ A) ∙⟶ ∙𝟙 id⊸ {A} = ∙swap⋆ ∙⊚ ε A comp⊸ : (A B C : ∙𝕌) → (A ⊸ B) ∙×ᵤ (B ⊸ C) ∙⟶ (A ⊸ C) comp⊸ A B C = ∙assocr⋆ ∙⊚ ∙id⟷ ∙⊗ ∙assocl⋆ ∙⊚ ∙id⟷ ∙⊗ (ε B ∙⊗ ∙id⟷) ∙⊚ ∙id⟷ ∙⊗ ∙unite⋆l app : (A B : ∙𝕌) → (A ⊸ B) ∙×ᵤ Singᵤ A ∙⟶ Singᵤ B app A B = ∙swap⋆ ∙⊗ ∙id⟷ ∙⊚ ∙assocr⋆ ∙⊚ (∙id⟷ ∙⊗ (∙swap⋆ ∙⊚ ε A)) ∙⊚ ∙unite⋆r -- B/A × D/C ⟷ B × D / A × C dist×/ : {A B C D : ∙𝕌} → (A ⊸ B) ∙×ᵤ (C ⊸ D) ∙⟶ ((A ∙×ᵤ C) ⊸ (B ∙×ᵤ D)) dist×/ {A} {B} {C} {D} = ∙assocr⋆ ∙⊚ (∙id⟷ ∙⊗ ∙assocl⋆) ∙⊚ ∙id⟷ ∙⊗ (∙swap⋆ ∙⊗ ∙id⟷) ∙⊚ (∙id⟷ ∙⊗ ∙assocr⋆) ∙⊚ ∙assocl⋆ ∙⊚ c ∙⊗ tensor where c : (Recipᵤ A ∙×ᵤ Recipᵤ C) ∙⟶ Recipᵤ (A ∙×ᵤ C) c = ∙uniti⋆l ∙⊚ (η (A ∙×ᵤ C) ∙⊗ ∙id⟷) ∙⊚ (∙swap⋆ ∙⊗ ∙id⟷) ∙⊚ ∙assocr⋆ ∙⊚ (∙id⟷ ∙⊗ (untensor ∙⊗ ∙id⟷)) ∙⊚ (∙id⟷ ∙⊗ (∙swap⋆ ∙⊗ ∙id⟷)) ∙⊚ (∙id⟷ ∙⊗ ∙assocr⋆) ∙⊚ (∙id⟷ ∙⊗ (∙id⟷ ∙⊗ ∙assocl⋆)) ∙⊚ (∙id⟷ ∙⊗ (∙id⟷ ∙⊗ ((ε A ∙⊗ ∙id⟷) ∙⊚ ∙unite⋆l))) ∙⊚ (∙id⟷ ∙⊗ ε C) ∙⊚ ∙unite⋆r -- 1/A x 1/B <-> 1 / (A x B) rev× : {A B : ∙𝕌} → (A ⊸ ∙𝟙) ∙×ᵤ (B ⊸ ∙𝟙) ∙⟶ (A ∙×ᵤ B ⊸ ∙𝟙) rev× {A} {B} = dist×/ ∙⊚ (∙id⟷ ∙⊗ ∙Singᵤ ∙unite⋆l) -- (A <-> B) -> (1/A <-> 1/B) rev : {A B : ∙𝕌} → (f : A ∙⟶ B) → Recipᵤ B ∙⟶ Recipᵤ A rev {A} {B} f = dual f -- A <-> 1 / (1/A) revrev : {A : ∙𝕌} → Singᵤ A ∙⟶ Recipᵤ (Recipᵤ A) revrev {A} = ∙uniti⋆r ∙⊚ ∙id⟷ ∙⊗ η (Recipᵤ A) ∙⊚ ∙assocl⋆ ∙⊚ ((∙id⟷ ∙⊗ extract (Recipᵤ A)) ∙⊗ ∙id⟷) ∙⊚ (ε A ∙⊗ ∙id⟷) ∙⊚ ∙unite⋆l
{ "alphanum_fraction": 0.4102508651, "avg_line_length": 30.8266666667, "ext": "agda", "hexsha": "875167df3b74d032b986e139637486bfa4b7d773", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "fracGC/PiPointedFracTrace.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "fracGC/PiPointedFracTrace.agda", "max_line_length": 86, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "fracGC/PiPointedFracTrace.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3034, "size": 4624 }
module McK-B where open import CS410-Prelude open import CS410-Nat open import CS410-Vec data Bit : Set where O I : Bit exp2 : Nat -> Nat exp2 zero = 1 exp2 (suc n) = exp2 n +N exp2 n WordNZ : Nat -> Set data Word (n : Nat) : Set where O : Word n [_] : WordNZ n -> Word n WordNZ zero = One WordNZ (suc n) = (WordNZ n * Word n) + WordNZ n _!_ : {n : Nat} -> Word n -> Word n -> Word (suc n) O ! O = O O ! [ x ] = [ inr x ] [ x ] ! y = [ inl (x , y) ] _!+_ : {n : Nat} -> Word n -> WordNZ n -> WordNZ (suc n) O !+ y = inr y [ x ] !+ y = inl (x , [ y ]) iNZ : (n : Nat) -> WordNZ n iNZ zero = <> iNZ (suc n) = inr (iNZ n) i : {n : Nat} -> Word n i {n} = [ iNZ n ] where data WViewable : {n : Nat} -> Word n -> Set where O0 : WViewable {zero} O I0 : WViewable {zero} i _!!_ : {n : Nat}(x y : Word n) -> WViewable (x ! y) wView : {n : Nat}(x : Word n) -> WViewable x wView {zero} O = O0 wView {zero} [ <> ] = I0 wView {suc n} O = O !! O wView {suc n} [ inl (x , y) ] = [ x ] !! y wView {suc n} [ inr y ] = O !! [ y ] expand : {n : Nat} -> Word n -> Vec Bit (exp2 n) expand x with wView x expand .O | O0 = O :: [] expand .([ <> ]) | I0 = I :: [] expand .(x ! y) | x !! y = expand x +V expand y inc : {n : Nat}(x : Word n) -> One + WordNZ n inc x with wView x inc .O | O0 = inr (iNZ zero) inc .([ <> ]) | I0 = inl <> inc .(x ! y) | x !! y with inc y inc .(x ! y) | x !! y | inr y' = inr (x !+ y') inc .(x ! y) | x !! y | inl <> with inc x inc .(x ! y) | x !! y | inl <> | inr x' = inr (inl (x' , O)) inc .(x ! y) | x !! y | inl <> | inl <> = inl <> incm : {n : Nat}(x : Word n) -> Word n incm x with inc x incm x | inl <> = O incm x | inr x' = [ x' ] fiveW2 : Word 2 fiveW2 = incm (incm (incm (incm (incm O)))) adc : {n : Nat} -> Word n -> Word n -> Bit -> Bit * Word n adc x y c with wView x | wView y adc .O .O O | O0 | O0 = O , O adc .O .O I | O0 | O0 = O , i adc .O .i O | O0 | I0 = O , i adc .O .i I | O0 | I0 = I , O adc .i .O O | I0 | O0 = O , i adc .i .O I | I0 | O0 = I , O adc .i .i O | I0 | I0 = I , O adc .i .i I | I0 | I0 = I , i adc .(xh ! xl) .(yh ! yl) c | xh !! xl | yh !! yl with adc xl yl c ... | cl , zl with adc xh yh cl ... | ch , zh = ch , zh ! zl
{ "alphanum_fraction": 0.47275144, "avg_line_length": 26.869047619, "ext": "agda", "hexsha": "af4bfbe9cca463b77e37b3f19ed7e303650305db", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-06T19:34:26.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-13T12:44:41.000Z", "max_forks_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ajnavarro/language-dataset", "max_forks_repo_path": "data/github.com/pigworker/CS410-15/043477e6143af6a78b677bb528c46621da11df00/McK-B.agda", "max_issues_count": 91, "max_issues_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ajnavarro/language-dataset", "max_issues_repo_path": "data/github.com/pigworker/CS410-15/043477e6143af6a78b677bb528c46621da11df00/McK-B.agda", "max_line_length": 66, "max_stars_count": 9, "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_path": "data/github.com/pigworker/CS410-15/043477e6143af6a78b677bb528c46621da11df00/McK-B.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-11T09:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2018-08-07T11:54:33.000Z", "num_tokens": 1026, "size": 2257 }
module IdentP where data Bool : Set where false : Bool true : Bool f : {A : Set} → A → A → A f x y = x g : Bool → Bool g false = true g true = true
{ "alphanum_fraction": 0.4787234043, "avg_line_length": 6.4827586207, "ext": "agda", "hexsha": "60ce1b23817909e32f4574fb7c7293e0cc497f30", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/pattern/IdentP.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "msuperdock/agda-unused", "max_issues_repo_path": "data/pattern/IdentP.agda", "max_line_length": 19, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/pattern/IdentP.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 82, "size": 188 }
-- Andreas, 2018-09-03, issue #3207 -- -- Error message for disabled Prop. {-# OPTIONS --no-prop #-} test = Prop
{ "alphanum_fraction": 0.6260869565, "avg_line_length": 14.375, "ext": "agda", "hexsha": "437410a9de72894de6267d0a268e473c33df4407", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue3207.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue3207.agda", "max_line_length": 35, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3207.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 34, "size": 115 }
module Fin where open import Prelude open import Star open import Modal open import Nat Fin : Nat -> Set Fin = Any (\_ -> True) fzero : {n : Nat} -> Fin (suc n) fzero = done _ • ε fsuc : {n : Nat} -> Fin n -> Fin (suc n) fsuc i = step • i
{ "alphanum_fraction": 0.6106557377, "avg_line_length": 14.3529411765, "ext": "agda", "hexsha": "9e8ff81b08ada8e5db0f1dd7b2b809bd26170388", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/AIM6/Path/Fin.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/AIM6/Path/Fin.agda", "max_line_length": 40, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/AIM6/Path/Fin.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 84, "size": 244 }
module HasDecidableSalvation where open import OscarPrelude open import HasSalvation record HasDecidableSalvation (A : Set) : Set₁ where field ⦃ hasSalvation ⦄ : HasSalvation A ▷?_ : (x : A) → Dec $ ▷ x open HasDecidableSalvation ⦃ … ⦄ public {-# DISPLAY HasDecidableSalvation.▷?_ _ = ▷?_ #-}
{ "alphanum_fraction": 0.6957928803, "avg_line_length": 19.3125, "ext": "agda", "hexsha": "c2fad8079e24e749c871c7c608b37e75c3e0ff73", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/HasDecidableSalvation.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/HasDecidableSalvation.agda", "max_line_length": 49, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/HasDecidableSalvation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 109, "size": 309 }
{- A couple of general facts about equivalences: - if f is an equivalence then (cong f) is an equivalence ([equivCong]) - if f is an equivalence then pre- and postcomposition with f are equivalences ([preCompEquiv], [postCompEquiv]) - if f is an equivalence then (Σ[ g ] section f g) and (Σ[ g ] retract f g) are contractible ([isContr-section], [isContr-retract]) - isHAEquiv is a proposition [isPropIsHAEquiv] (these are not in 'Equiv.agda' because they need Univalence.agda (which imports Equiv.agda)) -} {-# OPTIONS --safe #-} module Cubical.Foundations.Equiv.Properties where open import Cubical.Core.Everything open import Cubical.Data.Sigma open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.Univalence open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Path open import Cubical.Foundations.HLevels open import Cubical.Functions.FunExtEquiv private variable ℓ ℓ′ ℓ′′ : Level A B C : Type ℓ isEquivInvEquiv : isEquiv (λ (e : A ≃ B) → invEquiv e) isEquivInvEquiv = isoToIsEquiv goal where open Iso goal : Iso (A ≃ B) (B ≃ A) goal .fun = invEquiv goal .inv = invEquiv goal .rightInv g = equivEq refl goal .leftInv f = equivEq refl invEquivEquiv : (A ≃ B) ≃ (B ≃ A) invEquivEquiv = _ , isEquivInvEquiv isEquivCong : {x y : A} (e : A ≃ B) → isEquiv (λ (p : x ≡ y) → cong (equivFun e) p) isEquivCong e = isoToIsEquiv (congIso (equivToIso e)) congEquiv : {x y : A} (e : A ≃ B) → (x ≡ y) ≃ (equivFun e x ≡ equivFun e y) congEquiv e = isoToEquiv (congIso (equivToIso e)) equivAdjointEquiv : (e : A ≃ B) → ∀ {a b} → (a ≡ invEq e b) ≃ (equivFun e a ≡ b) equivAdjointEquiv e = compEquiv (congEquiv e) (compPathrEquiv (secEq e _)) invEq≡→equivFun≡ : (e : A ≃ B) → ∀ {a b} → invEq e b ≡ a → equivFun e a ≡ b invEq≡→equivFun≡ e = equivFun (equivAdjointEquiv e) ∘ sym isEquivPreComp : (e : A ≃ B) → isEquiv (λ (φ : B → C) → φ ∘ equivFun e) isEquivPreComp e = snd (equiv→ (invEquiv e) (idEquiv _)) preCompEquiv : (e : A ≃ B) → (B → C) ≃ (A → C) preCompEquiv e = (λ φ → φ ∘ fst e) , isEquivPreComp e isEquivPostComp : (e : A ≃ B) → isEquiv (λ (φ : C → A) → e .fst ∘ φ) isEquivPostComp e = snd (equivΠCod (λ _ → e)) postCompEquiv : (e : A ≃ B) → (C → A) ≃ (C → B) postCompEquiv e = _ , isEquivPostComp e -- see also: equivΠCod for a dependent version of postCompEquiv hasSection : (A → B) → Type _ hasSection {A = A} {B = B} f = Σ[ g ∈ (B → A) ] section f g hasRetract : (A → B) → Type _ hasRetract {A = A} {B = B} f = Σ[ g ∈ (B → A) ] retract f g isEquiv→isContrHasSection : {f : A → B} → isEquiv f → isContr (hasSection f) fst (isEquiv→isContrHasSection isEq) = invIsEq isEq , secIsEq isEq snd (isEquiv→isContrHasSection isEq) (f , ε) i = (λ b → fst (p b i)) , (λ b → snd (p b i)) where p : ∀ b → (invIsEq isEq b , secIsEq isEq b) ≡ (f b , ε b) p b = isEq .equiv-proof b .snd (f b , ε b) isEquiv→hasSection : {f : A → B} → isEquiv f → hasSection f isEquiv→hasSection = fst ∘ isEquiv→isContrHasSection isContr-hasSection : (e : A ≃ B) → isContr (hasSection (fst e)) isContr-hasSection e = isEquiv→isContrHasSection (snd e) isEquiv→isContrHasRetract : {f : A → B} → isEquiv f → isContr (hasRetract f) fst (isEquiv→isContrHasRetract isEq) = invIsEq isEq , retIsEq isEq snd (isEquiv→isContrHasRetract {f = f} isEq) (g , η) = λ i → (λ b → p b i) , (λ a → q a i) where p : ∀ b → invIsEq isEq b ≡ g b p b = sym (η (invIsEq isEq b)) ∙' cong g (secIsEq isEq b) -- one square from the definition of invIsEq ieSq : ∀ a → Square (cong g (secIsEq isEq (f a))) refl (cong (g ∘ f) (retIsEq isEq a)) refl ieSq a k j = g (commSqIsEq isEq a k j) -- one square from η ηSq : ∀ a → Square (η (invIsEq isEq (f a))) (η a) (cong (g ∘ f) (retIsEq isEq a)) (retIsEq isEq a) ηSq a i j = η (retIsEq isEq a i) j -- and one last square from the definition of p pSq : ∀ b → Square (η (invIsEq isEq b)) refl (cong g (secIsEq isEq b)) (p b) pSq b i j = compPath'-filler (sym (η (invIsEq isEq b))) (cong g (secIsEq isEq b)) j i q : ∀ a → Square (retIsEq isEq a) (η a) (p (f a)) refl q a i j = hcomp (λ k → λ { (i = i0) → ηSq a j k ; (i = i1) → η a (j ∧ k) ; (j = i0) → pSq (f a) i k ; (j = i1) → η a k }) (ieSq a j i) isEquiv→hasRetract : {f : A → B} → isEquiv f → hasRetract f isEquiv→hasRetract = fst ∘ isEquiv→isContrHasRetract isContr-hasRetract : (e : A ≃ B) → isContr (hasRetract (fst e)) isContr-hasRetract e = isEquiv→isContrHasRetract (snd e) cong≃ : (F : Type ℓ → Type ℓ′) → (A ≃ B) → F A ≃ F B cong≃ F e = pathToEquiv (cong F (ua e)) cong≃-char : (F : Type ℓ → Type ℓ′) {A B : Type ℓ} (e : A ≃ B) → ua (cong≃ F e) ≡ cong F (ua e) cong≃-char F e = ua-pathToEquiv (cong F (ua e)) cong≃-idEquiv : (F : Type ℓ → Type ℓ′) (A : Type ℓ) → cong≃ F (idEquiv A) ≡ idEquiv (F A) cong≃-idEquiv F A = cong≃ F (idEquiv A) ≡⟨ cong (λ p → pathToEquiv (cong F p)) uaIdEquiv ⟩ pathToEquiv refl ≡⟨ pathToEquivRefl ⟩ idEquiv (F A) ∎ isPropIsHAEquiv : {f : A → B} → isProp (isHAEquiv f) isPropIsHAEquiv {f = f} ishaef = goal ishaef where equivF : isEquiv f equivF = isHAEquiv→isEquiv ishaef rCoh1 : (sec : hasSection f) → Type _ rCoh1 (g , ε) = Σ[ η ∈ retract f g ] ∀ x → cong f (η x) ≡ ε (f x) rCoh2 : (sec : hasSection f) → Type _ rCoh2 (g , ε) = Σ[ η ∈ retract f g ] ∀ x → Square (ε (f x)) refl (cong f (η x)) refl rCoh3 : (sec : hasSection f) → Type _ rCoh3 (g , ε) = ∀ x → Σ[ ηx ∈ g (f x) ≡ x ] Square (ε (f x)) refl (cong f ηx) refl rCoh4 : (sec : hasSection f) → Type _ rCoh4 (g , ε) = ∀ x → Path (fiber f (f x)) (g (f x) , ε (f x)) (x , refl) characterization : isHAEquiv f ≃ Σ _ rCoh4 characterization = isHAEquiv f -- first convert between Σ and record ≃⟨ isoToEquiv (iso (λ e → (e .g , e .rinv) , (e .linv , e .com)) (λ e → record { g = e .fst .fst ; rinv = e .fst .snd ; linv = e .snd .fst ; com = e .snd .snd }) (λ _ → refl) λ _ → refl) ⟩ Σ _ rCoh1 -- secondly, convert the path into a dependent path for later convenience ≃⟨ Σ-cong-equiv-snd (λ s → Σ-cong-equiv-snd λ η → equivΠCod λ x → compEquiv (flipSquareEquiv {a₀₀ = f x}) (invEquiv slideSquareEquiv)) ⟩ Σ _ rCoh2 ≃⟨ Σ-cong-equiv-snd (λ s → invEquiv Σ-Π-≃) ⟩ Σ _ rCoh3 ≃⟨ Σ-cong-equiv-snd (λ s → equivΠCod λ x → ΣPath≃PathΣ) ⟩ Σ _ rCoh4 ■ where open isHAEquiv goal : isProp (isHAEquiv f) goal = subst isProp (sym (ua characterization)) (isPropΣ (isContr→isProp (isEquiv→isContrHasSection equivF)) λ s → isPropΠ λ x → isProp→isSet (isContr→isProp (equivF .equiv-proof (f x))) _ _) -- loop spaces connected by a path are equivalent conjugatePathEquiv : {A : Type ℓ} {a b : A} (p : a ≡ b) → (a ≡ a) ≃ (b ≡ b) conjugatePathEquiv p = compEquiv (compPathrEquiv p) (compPathlEquiv (sym p)) -- composition on the right induces an equivalence of path types compr≡Equiv : {A : Type ℓ} {a b c : A} (p q : a ≡ b) (r : b ≡ c) → (p ≡ q) ≃ (p ∙ r ≡ q ∙ r) compr≡Equiv p q r = congEquiv ((λ s → s ∙ r) , compPathr-isEquiv r) -- composition on the left induces an equivalence of path types compl≡Equiv : {A : Type ℓ} {a b c : A} (p : a ≡ b) (q r : b ≡ c) → (q ≡ r) ≃ (p ∙ q ≡ p ∙ r) compl≡Equiv p q r = congEquiv ((λ s → p ∙ s) , (compPathl-isEquiv p)) isEquivFromIsContr : {A : Type ℓ} {B : Type ℓ′} → (f : A → B) → isContr A → isContr B → isEquiv f isEquivFromIsContr f isContrA isContrB = subst isEquiv (λ i x → isContr→isProp isContrB (fst B≃A x) (f x) i) (snd B≃A) where B≃A = isContr→Equiv isContrA isContrB isEquiv[f∘equivFunA≃B]→isEquiv[f] : {A : Type ℓ} {B : Type ℓ′} {C : Type ℓ′′} → (f : B → C) (A≃B : A ≃ B) → isEquiv (f ∘ equivFun A≃B) → isEquiv f isEquiv[f∘equivFunA≃B]→isEquiv[f] f (g , gIsEquiv) f∘gIsEquiv = precomposesToId→Equiv f _ w w' where w : f ∘ g ∘ equivFun (invEquiv (_ , f∘gIsEquiv)) ≡ idfun _ w = (cong fst (invEquiv-is-linv (_ , f∘gIsEquiv))) w' : isEquiv (g ∘ equivFun (invEquiv (_ , f∘gIsEquiv))) w' = (snd (compEquiv (invEquiv (_ , f∘gIsEquiv) ) (_ , gIsEquiv)))
{ "alphanum_fraction": 0.5690645052, "avg_line_length": 41.5093457944, "ext": "agda", "hexsha": "a4b4cf59b210f691dce6622f71a4cb31a8247ff7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Foundations/Equiv/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Foundations/Equiv/Properties.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Foundations/Equiv/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3474, "size": 8883 }
module List where import Prelude import Equiv import Datoid import Nat open Prelude open Equiv open Datoid open Nat data List (a : Set) : Set where nil : List a _::_ : a -> List a -> List a map : {a b : Set} -> (a -> b) -> List a -> List b map f nil = nil map f (x :: xs) = f x :: map f xs member : (a : Datoid) -> El a -> List (El a) -> Set member _ x nil = Absurd member a x (y :: ys) = Either (rel' (datoidEq a) x y) (member a x ys) memberPreservesEq : {a : Datoid} -> {x y : El a} -> datoidRel a x y -> (zs : List (El a)) -> member a x zs -> member a y zs memberPreservesEq xy nil abs = abs memberPreservesEq {a} xy (z :: zs) (left xz) = left (dTrans a (dSym a xy) xz) memberPreservesEq {a} xy (z :: zs) (right xzs) = right (memberPreservesEq {a} xy zs xzs) private noCopies' : (a : Datoid) -> (x y : El a) -> Dec (datoidRel a x y) -> Nat -> Nat noCopies' _ _ _ (left _) n = suc n noCopies' _ _ _ (right _) n = n noCopies : (a : Datoid) -> El a -> List (El a) -> Nat noCopies a x nil = zero noCopies a x (y :: ys) = noCopies' a x y (datoidDecRel a x y) (noCopies a x ys) NoDuplicates : (a : Datoid) -> List (El a) -> Set NoDuplicates _ nil = Unit NoDuplicates a (x :: b) = Pair (Not (member a x b)) (NoDuplicates a b) private delete' : (a : Datoid) -> (x y : El a) -> Dec (datoidRel a x y) -> (ys delXYs : List (El a)) -> List (El a) delete' _ _ _ (left _) ys _ = ys delete' _ _ _ (right _) _ delXYs = delXYs -- Removes first occurrence if any. delete : (a : Datoid) -> El a -> List (El a) -> List (El a) delete a x nil = nil delete a x (y :: ys) = delete' a x y (datoidDecRel a x y) ys (delete a x ys) private Perm : (a : Datoid) -> (xs ys : List (El a)) -> Set Perm a xs ys = forall z -> datoidRel natDatoid (noCopies a z xs) (noCopies a z ys) refl' : {a : Datoid} -> (xs : List (El a)) -> Perm a xs xs refl' {a} xs = \z -> dRefl natDatoid {noCopies a z xs} sym' : {a : Datoid} -> (xs ys : List (El a)) -> Perm a xs ys -> Perm a ys xs sym' {a} xs ys xy = \z -> dSym natDatoid {noCopies a z xs} {noCopies a z ys} (xy z) trans' : {a : Datoid} -> (xs ys zs : List (El a)) -> Perm a xs ys -> Perm a ys zs -> Perm a xs zs trans' {a} xs ys zs xy yz = \z -> dTrans natDatoid {noCopies a z xs} {noCopies a z ys} {noCopies a z zs} (xy z) (yz z) postulate dec' : {a : Datoid} -> (xs ys : List (El a)) -> Either (Perm a xs ys) (Not (Perm a xs ys)) Permutation : (a : Datoid) -> DecidableEquiv (List (El a)) Permutation a = decEquiv (equiv (Perm a) (refl' {a}) (sym' {a}) (trans' {a})) (dec (dec' {a}))
{ "alphanum_fraction": 0.5102249489, "avg_line_length": 30.5625, "ext": "agda", "hexsha": "fa5b916c3a18609f390b1b05950b476e8a1fa970", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/AIM4/bag/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/AIM4/bag/List.agda", "max_line_length": 96, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/AIM4/bag/List.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 1055, "size": 2934 }
interleaved mutual data CoNat : Set record ∞CoNat : Set constructor zero : CoNat record ∞CoNat where coinductive field force : CoNat constructor suc : ∞CoNat → ?
{ "alphanum_fraction": 0.6458333333, "avg_line_length": 12.8, "ext": "agda", "hexsha": "2da9588828f6cbd99e26b3f173aa2c91567b34c9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue2858-codata.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue2858-codata.agda", "max_line_length": 23, "max_stars_count": null, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue2858-codata.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 62, "size": 192 }
------------------------------------------------------------------------------ -- Inductive PA properties using the induction principle ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PA.Inductive.PropertiesByInductionI where open import PA.Inductive.Base open import PA.Inductive.PropertiesByInduction open import PA.Inductive.Relation.Binary.EqReasoning ------------------------------------------------------------------------------ +-comm : ∀ m n → m + n ≡ n + m +-comm m n = ℕ-ind A A0 is m where A : ℕ → Set A i = i + n ≡ n + i A0 : A zero A0 = sym (+-rightIdentity n) is : ∀ i → A i → A (succ i) is i ih = succ (i + n) ≡⟨ succCong ih ⟩ succ (n + i) ≡⟨ sym (x+Sy≡S[x+y] n i) ⟩ n + succ i ∎
{ "alphanum_fraction": 0.4270724029, "avg_line_length": 29.78125, "ext": "agda", "hexsha": "7cd0aae676206d3cde94273c46092926aeb98f4f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/PA/Inductive/PropertiesByInductionI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/PA/Inductive/PropertiesByInductionI.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/PA/Inductive/PropertiesByInductionI.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 235, "size": 953 }
-- Andreas, 2014-03-27 fixed issue {-# OPTIONS --copatterns --sized-types #-} open import Common.Size record R (i : Size) : Set where inductive constructor c field j : Size< i r : R j data ⊥ : Set where elim : (i : Size) → R i → ⊥ elim i (c j r) = elim j r -- elim should be rejected by termination checker. -- Being accepted, its is translated into -- -- elim i x = elim (R.j x) (R.r x) -- -- which is making reduceHead in the injectivity checker -- produce larger and larger applications of elim. -- Leading to a stack overflow. inh : R ∞ R.j inh = ∞ R.r inh = inh -- inh should also be rejected
{ "alphanum_fraction": 0.6426282051, "avg_line_length": 17.8285714286, "ext": "agda", "hexsha": "42cce6ea68a9a1c84fade710b161b5e2a2b65372", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/Fail/Issue1015a.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Fail/Issue1015a.agda", "max_line_length": 56, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/Issue1015a.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 188, "size": 624 }
module Rationals.Properties where open import Nats renaming (_*_ to _:*:_) open import Rationals open import Data.Empty open import Data.Product open import Equality ------------------------------------------------------------------------ -- internal stuffs private a*b÷b=a : ∀ a b → a :*: b ÷ b →ℕ ≡ (a , refl) a*b÷b=a _ _ = refl ------------------------------------------------------------------------ -- public aliases times-div-id : ∀ a b → a :*: b ÷ b →ℕ ≡ (a , refl) times-div-id = a*b÷b=a
{ "alphanum_fraction": 0.45256917, "avg_line_length": 23, "ext": "agda", "hexsha": "de1597559b587ef079cc2d0dae7694d0d1568da1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_path": "src/Rationals/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_path": "src/Rationals/Properties.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_path": "src/Rationals/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "num_tokens": 131, "size": 506 }
module RandomAccessList.Standard.Core where open import BuildingBlock.BinaryLeafTree using (BinaryLeafTree; Node; Leaf) open import Data.Nat open import Data.Nat.Etc -- parameterized by the level of the least significant digit data 0-1-RAL (A : Set) : ℕ → Set where [] : ∀ {n} → 0-1-RAL A n 0∷_ : ∀ {n} → 0-1-RAL A (suc n) → 0-1-RAL A n _1∷_ : ∀ {n} → BinaryLeafTree A n → 0-1-RAL A (suc n) → 0-1-RAL A n -------------------------------------------------------------------------------- -- to ℕ ⟦_⟧ₙ : ∀ {A n} → 0-1-RAL A n → ℕ ⟦ [] ⟧ₙ = 0 ⟦ 0∷ xs ⟧ₙ = 2 * ⟦ xs ⟧ₙ ⟦ x 1∷ xs ⟧ₙ = 1 + 2 * ⟦ xs ⟧ₙ ⟦_⟧ : ∀ {n A} → 0-1-RAL A n → ℕ ⟦_⟧ {n} xs = (2 ^ n) * ⟦ xs ⟧ₙ
{ "alphanum_fraction": 0.4395750332, "avg_line_length": 31.375, "ext": "agda", "hexsha": "6b3bb0df18eed111614e22e9556a39db9a1c5713", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/RandomAccessList/Standard/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/RandomAccessList/Standard/Core.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/RandomAccessList/Standard/Core.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 307, "size": 753 }
------------------------------------------------------------------------------ -- Test the consistency of PA.Axiomatic.Standard.Base ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- In the module PA.Axiomatic.Standard.Base we declare Agda postulates -- as first-order logic axioms. We test if it is possible to prove an -- unprovable theorem from these axioms. module PA.Axiomatic.Standard.Base.Consistency.Axioms where open import PA.Axiomatic.Standard.Base ------------------------------------------------------------------------------ postulate impossible : (m n : ℕ) → m ≡ n {-# ATP prove impossible #-}
{ "alphanum_fraction": 0.4761904762, "avg_line_length": 37.2272727273, "ext": "agda", "hexsha": "1c9db04abbaa28623110c1337874ec7005a8135f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/PA/Axiomatic/Standard/Base/Consistency/Axioms.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/PA/Axiomatic/Standard/Base/Consistency/Axioms.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/PA/Axiomatic/Standard/Base/Consistency/Axioms.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 139, "size": 819 }
-- Box modality: cofree presheaf on a family module SOAS.Abstract.Box {T : Set} where open import SOAS.Common open import SOAS.Context open import SOAS.Sorting open import SOAS.Variable open import SOAS.Families.Core {T} open import SOAS.Families.Isomorphism open import SOAS.Families.BCCC using (_×ₘ_; _+ₘ_; _⇨_; _⇨̣_) open import SOAS.Abstract.Hom open import Categories.Functor.Bifunctor module Unsorted where -- Box modality: the skew-closed action of variables on a family □ : Family → Family □ X = ⟨ ℐ , X ⟩ -- □ is an endofunctor on families □F : Functor 𝔽amilies 𝔽amilies □F = appˡ ⟨-,-⟩F ℐ -- | Properties of □ private variable X Y : Family -- | □ preserves products of families □[X×Y]≅□X×□Y : □ (X ×ₘ Y) ≅ₘ (□ X ×ₘ □ Y) □[X×Y]≅□X×□Y = ⟨𝒳,Y×Z⟩≅⟨𝒳,Y⟩×⟨𝒳,Z⟩ -- □ can be factored out from a sum □X+□Y⇾□[X+Y] : (□ X +ₘ □ Y) ⇾ □ (X +ₘ Y) □X+□Y⇾□[X+Y] = ⟨𝒳,Y⟩+⟨𝒳,Z⟩⇾⟨𝒳,Y+Z⟩ module Sorted where -- Sorted box modality: the skew-closed hom of variables and a family □ : Familyₛ → Familyₛ □ X = 〖 ℐ , X 〗 -- □ is an endofunctor on families □F : Functor 𝔽amiliesₛ 𝔽amiliesₛ □F = appˡ 〖-,-〗F ℐ □₁ : {X Y : Familyₛ} → (X ⇾̣ Y) → □ X ⇾̣ □ Y □₁ f x ρ = f (x ρ) ζ : (X : Familyₛ) → □ X ⇾̣ □ (□ X) ζ X b ρ ϱ = b (ϱ ∘ ρ)
{ "alphanum_fraction": 0.5934833204, "avg_line_length": 22.224137931, "ext": "agda", "hexsha": "b73ddfd902568bc546b7d0aeedad4f0deeb1111e", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Abstract/Box.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Abstract/Box.agda", "max_line_length": 71, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Abstract/Box.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 621, "size": 1289 }
-- 2011-10-04 Andreas {-# OPTIONS --experimental-irrelevance #-} module TerminationOnIrrelevant where data ⊥ : Set where data Empty : Set where c : Empty → Empty d : Empty → Empty d (c x) = x f : .Empty → ⊥ f (c x) = f x g : .Empty → ⊥ g (c x) = g x data _≡_ {A : Set}(a : A) : A → Set where refl : a ≡ a -- the following would loop if we evaluated f x to f (d x) mayloop : .(x y : Empty) → f x ≡ g y mayloop x y = refl
{ "alphanum_fraction": 0.5930232558, "avg_line_length": 17.9166666667, "ext": "agda", "hexsha": "f55a73beaafe3fff560caea260875ad0cb6936b7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/fail/TerminationOnIrrelevant.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/agda-kanso", "max_issues_repo_path": "test/fail/TerminationOnIrrelevant.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/TerminationOnIrrelevant.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 163, "size": 430 }
module RepeatedVariableInPattern where K : Set -> Set K A A = A
{ "alphanum_fraction": 0.7014925373, "avg_line_length": 9.5714285714, "ext": "agda", "hexsha": "26d6bc82940de6eef74917cbcc62a4340a3944a5", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/RepeatedVariableInPattern.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/RepeatedVariableInPattern.agda", "max_line_length": 38, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/RepeatedVariableInPattern.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 21, "size": 67 }
module Categories.Functor.CartesianClosed where open import Categories.Category using (Category; _[_∘_]; _[_,_]) open import Categories.Category.Cartesian using (Cartesian) open import Categories.Category.Cartesian.Bundle using (CartesianCategory) open import Categories.Category.CartesianClosed using (CartesianClosed) open import Categories.Category.CartesianClosed.Bundle using (CartesianClosedCategory) open import Categories.Functor using (Functor) open import Categories.Functor.Cartesian using (IsCartesianF) import Categories.Morphism as Morphism open import Level private variable o ℓ e o′ ℓ′ e′ : Level record IsCartesianClosedF (C : CartesianClosedCategory o ℓ e) (D : CartesianClosedCategory o′ ℓ′ e′) (F : Functor (CartesianClosedCategory.U C) (CartesianClosedCategory.U D)) : Set (levelOfTerm C ⊔ levelOfTerm D) where open Morphism (CartesianClosedCategory.U D) using (IsIso; Iso) open Functor F private CU = CartesianClosedCategory.U C DU = CartesianClosedCategory.U D CC₁ = CartesianClosedCategory.cartesianClosed C CC₂ = CartesianClosedCategory.cartesianClosed D C₁ = CartesianClosed.cartesian CC₁ C₂ = CartesianClosed.cartesian CC₂ C′ = record { U = CU ; cartesian = C₁ } D′ = record { U = DU ; cartesian = C₂ } _^C_ = CartesianClosed._^_ CC₁ _^D_ = CartesianClosed._^_ CC₂ field isCartesianF : IsCartesianF C′ D′ F module isCartesianF = IsCartesianF isCartesianF conv : forall {A B : Category.Obj CU} -> DU [ F₀ (B ^C A) , F₀ B ^D F₀ A ] conv {A} {B} = CartesianClosed.λg CC₂ (DU [ F₁ (CartesianClosed.eval′ CC₁) ∘ IsCartesianF.×-iso.to isCartesianF (B ^C A) A ]) field F-preserve-^ : forall {A B : Category.Obj CU} -> IsIso (conv {A} {B}) module F-preserve-^ {A B : Category.Obj CU} = IsIso (F-preserve-^ {A} {B}) -- Note that F is called strict if `conv` ≈ id. record CartesianClosedF (C : CartesianClosedCategory o ℓ e) (D : CartesianClosedCategory o′ ℓ′ e′) : Set (levelOfTerm C ⊔ levelOfTerm D) where field F : Functor (CartesianClosedCategory.U C) (CartesianClosedCategory.U D) isCartesianClosed : IsCartesianClosedF C D F open Functor F public open IsCartesianClosedF isCartesianClosed public
{ "alphanum_fraction": 0.7250445633, "avg_line_length": 34.5230769231, "ext": "agda", "hexsha": "1b269d220d9c4646d4baa65b68dc56902d9d6e35", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "elpinal/exsub-ccc", "max_forks_repo_path": "Categories/Functor/CartesianClosed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "elpinal/exsub-ccc", "max_issues_repo_path": "Categories/Functor/CartesianClosed.agda", "max_line_length": 93, "max_stars_count": 3, "max_stars_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "elpinal/exsub-ccc", "max_stars_repo_path": "Categories/Functor/CartesianClosed.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T13:30:48.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-05T06:16:32.000Z", "num_tokens": 666, "size": 2244 }
module Issue2937.WithUnicode where foo : _ → _ → Set foo bar x = λ x → foo (bar x {!!}) x
{ "alphanum_fraction": 0.6086956522, "avg_line_length": 18.4, "ext": "agda", "hexsha": "7e1334632341e05c46dc314d3e2eeacc7e2a6bd9", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2937/WithUnicode.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2937/WithUnicode.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2937/WithUnicode.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 32, "size": 92 }
-- Left ℤ-multiplication on groups and some of its properties {-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Group.ZAction where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Data.Sigma open import Cubical.Data.Int renaming (_·_ to _*_ ; _+_ to _+ℤ_ ; _-_ to _-ℤ_) open import Cubical.Data.Nat hiding (_·_) renaming (_+_ to _+ℕ_) open import Cubical.Data.Empty renaming (rec to ⊥-rec) open import Cubical.Data.Sum open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Instances.Int renaming (ℤ to ℤGroup) open import Cubical.Algebra.Group.DirProd open import Cubical.Relation.Nullary private variable ℓ ℓ' : Level open Iso open GroupStr open IsGroupHom _ℤ[_]·_ : ℤ → (G : Group ℓ) → fst G → fst G pos zero ℤ[ G' ]· g = 1g (snd G') pos (suc n) ℤ[ G' ]· g = _·_ (snd G') g (pos n ℤ[ G' ]· g) negsuc zero ℤ[ G' ]· g = inv (snd G') g negsuc (suc n) ℤ[ G' ]· g = _·_ (snd G') (inv (snd G') g) (negsuc n ℤ[ G' ]· g) homPresℤ· : {G : Group ℓ} {H : Group ℓ'} → (ϕ : GroupHom G H) → (x : fst G) (z : ℤ) → fst ϕ (z ℤ[ G ]· x) ≡ (z ℤ[ H ]· fst ϕ x) homPresℤ· (ϕ , ϕhom) x (pos zero) = pres1 ϕhom homPresℤ· {H = H} (ϕ , ϕhom) x (pos (suc n)) = pres· ϕhom _ _ ∙ cong (_·_ (snd H) (ϕ x)) (homPresℤ· (ϕ , ϕhom) x (pos n)) homPresℤ· (ϕ , ϕhom) x (negsuc zero) = presinv ϕhom _ homPresℤ· {H = H} (ϕ , ϕhom) x (negsuc (suc n)) = pres· ϕhom _ _ ∙ cong₂ (_·_ (snd H)) (presinv ϕhom x) (homPresℤ· (ϕ , ϕhom) x (negsuc n)) rUnitℤ· : (G : Group ℓ) (x : ℤ) → (x ℤ[ G ]· 1g (snd G)) ≡ 1g (snd G) rUnitℤ· G (pos zero) = refl rUnitℤ· G (pos (suc n)) = cong (_·_ (snd G) (1g (snd G))) (rUnitℤ· G (pos n)) ∙ lid (snd G) (1g (snd G)) rUnitℤ· G (negsuc zero) = GroupTheory.inv1g G rUnitℤ· G (negsuc (suc n)) = cong₂ (_·_ (snd G)) (GroupTheory.inv1g G) (rUnitℤ· G (negsuc n)) ∙ lid (snd G) (1g (snd G)) rUnitℤ·ℤ : (x : ℤ) → (x ℤ[ ℤGroup ]· 1) ≡ x rUnitℤ·ℤ (pos zero) = refl rUnitℤ·ℤ (pos (suc n)) = cong (pos 1 +ℤ_) (rUnitℤ·ℤ (pos n)) ∙ sym (pos+ 1 n) rUnitℤ·ℤ (negsuc zero) = refl rUnitℤ·ℤ (negsuc (suc n)) = cong (-1 +ℤ_) (rUnitℤ·ℤ (negsuc n)) ∙ +Comm (negsuc 0) (negsuc n) private precommℤ : (G : Group ℓ) (g : fst G) (y : ℤ) → (snd G · (y ℤ[ G ]· g)) g ≡ (sucℤ y ℤ[ G ]· g) precommℤ G g (pos zero) = lid (snd G) g ∙ sym (rid (snd G) g) precommℤ G g (pos (suc n)) = sym (assoc (snd G) _ _ _) ∙ cong ((snd G · g)) (precommℤ G g (pos n)) precommℤ G g (negsuc zero) = invl (snd G) g precommℤ G g (negsuc (suc n)) = sym (assoc (snd G) _ _ _) ∙ cong ((snd G · inv (snd G) g)) (precommℤ G g (negsuc n)) ∙ negsucLem n where negsucLem : (n : ℕ) → (snd G · inv (snd G) g) (sucℤ (negsuc n) ℤ[ G ]· g) ≡ (sucℤ (negsuc (suc n)) ℤ[ G ]· g) negsucLem zero = (rid (snd G) _) negsucLem (suc n) = refl module _ (G : Group ℓ) (g : fst G) where private lem : (y : ℤ) → (predℤ y ℤ[ G ]· g) ≡ (snd G · inv (snd G) g) (y ℤ[ G ]· g) lem (pos zero) = sym (rid (snd G) _) lem (pos (suc n)) = sym (lid (snd G) ((pos n ℤ[ G ]· g))) ∙∙ cong (λ x → _·_ (snd G) x (pos n ℤ[ G ]· g)) (sym (invl (snd G) g)) ∙∙ sym (assoc (snd G) _ _ _) lem (negsuc n) = refl distrℤ· : (x y : ℤ) → ((x +ℤ y) ℤ[ G ]· g) ≡ _·_ (snd G) (x ℤ[ G ]· g) (y ℤ[ G ]· g) distrℤ· (pos zero) y = cong (_ℤ[ G ]· g) (+Comm 0 y) ∙ sym (lid (snd G) _) distrℤ· (pos (suc n)) (pos n₁) = cong (_ℤ[ G ]· g) (sym (pos+ (suc n) n₁)) ∙ cong (_·_ (snd G) g) (cong (_ℤ[ G ]· g) (pos+ n n₁) ∙ distrℤ· (pos n) (pos n₁)) ∙ assoc (snd G) _ _ _ distrℤ· (pos (suc n)) (negsuc zero) = distrℤ· (pos n) 0 ∙ ((rid (snd G) (pos n ℤ[ G ]· g) ∙ sym (lid (snd G) (pos n ℤ[ G ]· g))) ∙ cong (λ x → _·_ (snd G) x (pos n ℤ[ G ]· g)) (sym (invl (snd G) g)) ∙ sym (assoc (snd G) _ _ _)) ∙ (assoc (snd G) _ _ _) ∙ cong (λ x → _·_ (snd G) x (pos n ℤ[ G ]· g)) (invl (snd G) g) ∙ lid (snd G) _ ∙ sym (rid (snd G) _) ∙ (cong (_·_ (snd G) (pos n ℤ[ G ]· g)) (sym (invr (snd G) g)) ∙ assoc (snd G) _ _ _) ∙ cong (λ x → _·_ (snd G) x (inv (snd G) g)) (precommℤ G g (pos n)) distrℤ· (pos (suc n)) (negsuc (suc n₁)) = cong (_ℤ[ G ]· g) (predℤ+negsuc n₁ (pos (suc n))) ∙∙ distrℤ· (pos n) (negsuc n₁) ∙∙ (cong (λ x → _·_ (snd G) x (negsuc n₁ ℤ[ G ]· g)) ((sym (rid (snd G) (pos n ℤ[ G ]· g)) ∙ cong (_·_ (snd G) (pos n ℤ[ G ]· g)) (sym (invr (snd G) g))) ∙∙ assoc (snd G) _ _ _ ∙∙ cong (λ x → _·_ (snd G) x (inv (snd G) g)) (precommℤ G g (pos n))) ∙ sym (assoc (snd G) _ _ _)) distrℤ· (negsuc zero) y = cong (_ℤ[ G ]· g) (+Comm -1 y) ∙ lem y distrℤ· (negsuc (suc n)) y = cong (_ℤ[ G ]· g) (+Comm (negsuc (suc n)) y) ∙∙ lem (y +negsuc n) ∙∙ cong (snd G · inv (snd G) g) (cong (_ℤ[ G ]· g) (+Comm y (negsuc n)) ∙ distrℤ· (negsuc n) y) ∙ (assoc (snd G) _ _ _) GroupHomℤ→ℤpres- : (e : GroupHom ℤGroup ℤGroup) (a : ℤ) → fst e (- a) ≡ - fst e a GroupHomℤ→ℤpres- e a = cong (fst e) (minus≡0- a) ∙∙ presinv (snd e) a ∙∙ sym (minus≡0- _) ℤ·≡· : (a b : ℤ) → a * b ≡ (a ℤ[ ℤGroup ]· b) ℤ·≡· (pos zero) b = refl ℤ·≡· (pos (suc n)) b = cong (b +ℤ_) (ℤ·≡· (pos n) b) ℤ·≡· (negsuc zero) b = minus≡0- b ℤ·≡· (negsuc (suc n)) b = cong₂ _+ℤ_ (minus≡0- b) (ℤ·≡· (negsuc n) b) GroupHomℤ→ℤPres· : (e : GroupHom ℤGroup ℤGroup) (a b : ℤ) → fst e (a * b) ≡ a * fst e b GroupHomℤ→ℤPres· e a b = cong (fst e) (ℤ·≡· a b) ∙∙ homPresℤ· e b a ∙∙ sym (ℤ·≡· a (fst e b)) -- Generators in terms of ℤ-multiplication -- Todo : generalise gen₁-by : (G : Group ℓ) → (g : fst G) → Type _ gen₁-by G g = (h : fst G) → Σ[ a ∈ ℤ ] h ≡ (a ℤ[ G ]· g) gen₂-by : ∀ {ℓ} (G : Group ℓ) → (g₁ g₂ : fst G) → Type _ gen₂-by G g₁ g₂ = (h : fst G) → Σ[ a ∈ ℤ × ℤ ] h ≡ _·_ (snd G) ((fst a) ℤ[ G ]· g₁) ((snd a) ℤ[ G ]· g₂) Iso-pres-gen₁ : ∀ {ℓ ℓ'} (G : Group ℓ) (H : Group ℓ') (g : fst G) → gen₁-by G g → (e : GroupIso G H) → gen₁-by H (Iso.fun (fst e) g) Iso-pres-gen₁ G H g genG is h = (fst (genG (Iso.inv (fst is) h))) , (sym (Iso.rightInv (fst is) h) ∙∙ cong (Iso.fun (fst is)) (snd (genG (Iso.inv (fst is) h))) ∙∙ (homPresℤ· (_ , snd is) g (fst (genG (Iso.inv (fst is) h))))) Iso-pres-gen₂ : (G : Group ℓ) (H : Group ℓ') (g₁ g₂ : fst G) → gen₂-by G g₁ g₂ → (e : GroupIso G H) → gen₂-by H (Iso.fun (fst e) g₁) (Iso.fun (fst e) g₂) fst (Iso-pres-gen₂ G H g₁ g₂ genG is h) = genG (Iso.inv (fst is) h) .fst snd (Iso-pres-gen₂ G H g₁ g₂ genG is h) = sym (Iso.rightInv (fst is) h) ∙∙ cong (fun (fst is)) (snd (genG (Iso.inv (fst is) h))) ∙∙ (pres· (snd is) _ _ ∙ cong₂ (_·_ (snd H)) (homPresℤ· (_ , snd is) g₁ (fst (fst (genG (inv (fst is) h))))) (homPresℤ· (_ , snd is) g₂ (snd (fst (genG (inv (fst is) h)))))) private intLem₁ : (n m : ℕ) → Σ[ a ∈ ℕ ] (negsuc n * pos (suc m)) ≡ negsuc a intLem₁ n zero = n , ·Comm (negsuc n) (pos 1) intLem₁ n (suc m) = lem _ _ .fst , (·Comm (negsuc n) (pos (suc (suc m))) ∙∙ cong (negsuc n +ℤ_) (·Comm (pos (suc m)) (negsuc n) ∙ (intLem₁ n m .snd)) ∙∙ lem _ _ .snd) where lem : (x y : ℕ) → Σ[ a ∈ ℕ ] negsuc x +ℤ negsuc y ≡ negsuc a lem zero zero = 1 , refl lem zero (suc y) = (suc (suc y)) , +Comm (negsuc zero) (negsuc (suc y)) lem (suc x) zero = (suc (suc x)) , refl lem (suc x) (suc y) = (lem (suc (suc x)) y .fst) , (predℤ+negsuc y (negsuc (suc x)) ∙ snd ((lem (suc (suc x))) y)) intLem₂ : (n x : ℕ) → Σ[ a ∈ ℕ ] ((pos (suc x)) * pos (suc (suc n)) ≡ pos (suc (suc a))) intLem₂ n zero = n , refl intLem₂ n (suc x) = lem _ _ (intLem₂ n x) where lem : (x : ℤ) (n : ℕ) → Σ[ a ∈ ℕ ] (x ≡ pos (suc (suc a))) → Σ[ a ∈ ℕ ] pos n +ℤ x ≡ pos (suc (suc a)) lem x n (a , p) = n +ℕ a , cong (pos n +ℤ_) p ∙ cong sucℤ (sucℤ+pos a (pos n)) ∙ sucℤ+pos a (pos (suc n)) ∙ (sym (pos+ (suc (suc n)) a)) ¬1=x·suc-suc : (n : ℕ) (x : ℤ) → ¬ pos 1 ≡ x * pos (suc (suc n)) ¬1=x·suc-suc n (pos zero) p = snotz (injPos p) ¬1=x·suc-suc n (pos (suc n₁)) p = snotz (injPos (sym (cong predℤ (snd (intLem₂ n n₁))) ∙ sym (cong predℤ p))) ¬1=x·suc-suc n (negsuc n₁) p = posNotnegsuc _ _ (p ∙ intLem₁ _ _ .snd) GroupEquivℤ-pres1 : (e : GroupEquiv ℤGroup ℤGroup) (x : ℤ) → (fst (fst e) 1) ≡ x → abs (fst (fst e) 1) ≡ 1 GroupEquivℤ-pres1 e (pos zero) p = ⊥-rec (snotz (injPos (sym (retEq (fst e) 1) ∙∙ (cong (fst (fst (invGroupEquiv e))) p) ∙∙ IsGroupHom.pres1 (snd (invGroupEquiv e))))) GroupEquivℤ-pres1 e (pos (suc zero)) p = cong abs p GroupEquivℤ-pres1 e (pos (suc (suc n))) p = ⊥-rec (¬1=x·suc-suc _ _ (h3 ∙ ·Comm (pos (suc (suc n))) (invEq (fst e) 1))) where h3 : pos 1 ≡ _ h3 = sym (retEq (fst e) 1) ∙∙ cong (fst (fst (invGroupEquiv e))) (p ∙ ·Comm 1 (pos (suc (suc n)))) ∙∙ GroupHomℤ→ℤPres· (_ , snd (invGroupEquiv e)) (pos (suc (suc n))) 1 GroupEquivℤ-pres1 e (negsuc zero) p = cong abs p GroupEquivℤ-pres1 e (negsuc (suc n)) p = ⊥-rec (¬1=x·suc-suc _ _ lem₂) where lem₁ : fst (fst e) (negsuc zero) ≡ pos (suc (suc n)) lem₁ = GroupHomℤ→ℤpres- (_ , snd e) (pos 1) ∙ cong -_ p compGroup : GroupEquiv ℤGroup ℤGroup fst compGroup = isoToEquiv (iso -_ -_ -Involutive -Involutive) snd compGroup = makeIsGroupHom -Dist+ compHom : GroupEquiv ℤGroup ℤGroup compHom = compGroupEquiv compGroup e lem₂ : pos 1 ≡ invEq (fst compHom) (pos 1) * pos (suc (suc n)) lem₂ = sym (retEq (fst compHom) (pos 1)) ∙∙ cong (invEq (fst compHom)) lem₁ ∙∙ (cong (invEq (fst compHom)) (·Comm (pos 1) (pos (suc (suc n)))) ∙ GroupHomℤ→ℤPres· (_ , (snd (invGroupEquiv compHom))) (pos (suc (suc n))) (pos 1) ∙ ·Comm (pos (suc (suc n))) (invEq (fst compHom) (pos 1))) groupEquivPresGen : ∀ {ℓ} (G : Group ℓ) (ϕ : GroupEquiv G ℤGroup) (x : fst G) → (fst (fst ϕ) x ≡ 1) ⊎ (fst (fst ϕ) x ≡ - 1) → (ψ : GroupEquiv G ℤGroup) → (fst (fst ψ) x ≡ 1) ⊎ (fst (fst ψ) x ≡ - 1) groupEquivPresGen G (ϕeq , ϕhom) x (inl r) (ψeq , ψhom) = abs→⊎ _ _ (cong abs (cong (fst ψeq) (sym (retEq ϕeq x) ∙ cong (invEq ϕeq) r)) ∙ GroupEquivℤ-pres1 (compGroupEquiv (invGroupEquiv (ϕeq , ϕhom)) (ψeq , ψhom)) _ refl) groupEquivPresGen G (ϕeq , ϕhom) x (inr r) (ψeq , ψhom) = abs→⊎ _ _ (cong abs (cong (fst ψeq) (sym (retEq ϕeq x) ∙ cong (invEq ϕeq) r)) ∙ cong abs (IsGroupHom.presinv (snd (compGroupEquiv (invGroupEquiv (ϕeq , ϕhom)) (ψeq , ψhom))) 1) ∙ absLem _ (GroupEquivℤ-pres1 (compGroupEquiv (invGroupEquiv (ϕeq , ϕhom)) (ψeq , ψhom)) _ refl)) where absLem : ∀ x → abs x ≡ 1 → abs (pos 0 -ℤ x) ≡ 1 absLem (pos zero) p = ⊥-rec (snotz (sym p)) absLem (pos (suc zero)) p = refl absLem (pos (suc (suc n))) p = ⊥-rec (snotz (cong predℕ p)) absLem (negsuc zero) p = refl absLem (negsuc (suc n)) p = ⊥-rec (snotz (cong predℕ p)) gen₂ℤ×ℤ : gen₂-by (DirProd ℤGroup ℤGroup) (1 , 0) (0 , 1) fst (gen₂ℤ×ℤ (x , y)) = x , y snd (gen₂ℤ×ℤ (x , y)) = ΣPathP ((cong₂ _+ℤ_ ((·Comm 1 x) ∙ cong fst (sym (distrLem 1 0 x))) ((·Comm 0 y) ∙ cong fst (sym (distrLem 0 1 y)))) , +Comm y 0 ∙ cong₂ _+ℤ_ (·Comm 0 x ∙ cong snd (sym (distrLem 1 0 x))) (·Comm 1 y ∙ cong snd (sym (distrLem 0 1 y)))) where ℤ×ℤ = DirProd ℤGroup ℤGroup _+''_ = GroupStr._·_ (snd ℤ×ℤ) -lem : (x : ℤ) → - x ≡ 0 -ℤ x -lem (pos zero) = refl -lem (pos (suc zero)) = refl -lem (pos (suc (suc n))) = cong predℤ (-lem (pos (suc n))) -lem (negsuc zero) = refl -lem (negsuc (suc n)) = cong sucℤ (-lem (negsuc n)) distrLem : (x y : ℤ) (z : ℤ) → Path (ℤ × ℤ) (z ℤ[ ℤ×ℤ ]· (x , y)) (z * x , z * y) distrLem x y (pos zero) = refl distrLem x y (pos (suc n)) = (cong ((x , y) +''_) (distrLem x y (pos n))) distrLem x y (negsuc zero) = ΣPathP (sym (-lem x) , sym (-lem y)) distrLem x y (negsuc (suc n)) = cong₂ _+''_ (ΣPathP (sym (-lem x) , sym (-lem y))) (distrLem x y (negsuc n))
{ "alphanum_fraction": 0.5193361391, "avg_line_length": 39.8512658228, "ext": "agda", "hexsha": "020248927701f367f1b9ae44e80086881897c672", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b1d105aeeab1ba9888394c6a919b99a476390b7b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ecavallo/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/ZAction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b1d105aeeab1ba9888394c6a919b99a476390b7b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ecavallo/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/ZAction.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "b1d105aeeab1ba9888394c6a919b99a476390b7b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ecavallo/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/ZAction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5790, "size": 12593 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Monad syntax for the TC monad ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Reflection.TypeChecking.MonadSyntax where open import Agda.Builtin.Reflection open import Level using (Level) private variable a b : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Monad syntax pure : A → TC A pure = returnTC {-# INLINE pure #-} infixl 3 _<|>_ _<|>_ : TC A → TC A → TC A _<|>_ = catchTC {-# INLINE _<|>_ #-} infixl 1 _>>=_ _>>_ _<&>_ _>>=_ : TC A → (A → TC B) → TC B _>>=_ = bindTC {-# INLINE _>>=_ #-} _>>_ : TC A → TC B → TC B xs >> ys = bindTC xs (λ _ → ys) {-# INLINE _>>_ #-} infixl 4 _<$>_ _<*>_ _<$_ _<*>_ : TC (A → B) → TC A → TC B fs <*> xs = bindTC fs (λ f → bindTC xs (λ x → returnTC (f x))) {-# INLINE _<*>_ #-} _<$>_ : (A → B) → TC A → TC B f <$> xs = bindTC xs (λ x → returnTC (f x)) {-# INLINE _<$>_ #-} _<$_ : A → TC B → TC A x <$ xs = bindTC xs (λ _ → returnTC x) {-# INLINE _<$_ #-} _<&>_ : TC A → (A → B) → TC B xs <&> f = bindTC xs (λ x → returnTC (f x)) {-# INLINE _<&>_ #-}
{ "alphanum_fraction": 0.4322373697, "avg_line_length": 21.8771929825, "ext": "agda", "hexsha": "5df23171cd2cd7b04067973631281734575d6e74", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Reflection/TypeChecking/MonadSyntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Reflection/TypeChecking/MonadSyntax.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Reflection/TypeChecking/MonadSyntax.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 387, "size": 1247 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.HSpace open import homotopy.EM1HSpace open import homotopy.EilenbergMacLane1 using (EM₁-level₁) open import lib.types.TwoSemiCategory open import lib.two-semi-categories.FundamentalCategory module homotopy.EM1HSpaceAssoc where module EM₁HSpaceAssoc {i} (G : AbGroup i) where private module G = AbGroup G open EM₁HSpace G public private module H-⊙EM₁ = HSpaceStructure H-⊙EM₁ mult-loop-assoc : (g : G.El) (y z : EM₁ G.grp) → mult-loop g (mult y z) == ap (λ x' → mult x' z) (mult-loop g y) mult-loop-assoc g y z = EM₁-prop-elim {P = λ y → mult-loop g (mult y z) == ap (λ x' → mult x' z) (mult-loop g y)} {{λ y → has-level-apply (has-level-apply (EM₁-level₁ G.grp) _ _) _ _}} base' y where base' : mult-loop g (mult embase z) == ap (λ x' → mult x' z) (mult-loop g embase) base' = ! (mult-emloop-β g z) H-⊙EM₁-assoc : (x y z : EM₁ G.grp) → mult (mult x y) z == mult x (mult y z) H-⊙EM₁-assoc x y z = EM₁-set-elim {P = λ x → mult (mult x y) z == mult x (mult y z)} {{λ x → has-level-apply (EM₁-level₁ G.grp) _ _}} idp comp' x where abstract comp' : (g : G.El) → idp == idp [ (λ x → mult (mult x y) z == mult x (mult y z)) ↓ emloop g ] comp' g = ↓-='-in $ idp ∙' ap (λ x → mult x (mult y z)) (emloop g) =⟨ ∙'-unit-l _ ⟩ ap (λ x → mult x (mult y z)) (emloop g) =⟨ mult-emloop-β g (mult y z) ⟩ mult-loop g (mult y z) =⟨ mult-loop-assoc g y z ⟩ ap (λ v → mult v z) (mult-loop g y) =⟨ ap (ap (λ v → mult v z)) (! (mult-emloop-β g y)) ⟩ ap (λ v → mult v z) (ap (λ x → mult x y) (emloop g)) =⟨ ∘-ap (λ v → mult v z) (λ x → mult x y) (emloop g) ⟩ ap (λ x → mult (mult x y) z) (emloop g) =⟨ ! (∙-unit-r _) ⟩ ap (λ x → mult (mult x y) z) (emloop g) ∙ idp =∎ H-EM₁-assoc-coh-unit-l : coh-unit-l H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-coh-unit-l x y = =ₛ-in idp H-EM₁-assoc-coh-unit-r : coh-unit-r H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-coh-unit-r = EM₁-prop-elim {P = λ x → ∀ y → P x y} {{λ x → Π-level (P-level x)}} (EM₁-prop-elim {P = P embase} {{P-level embase}} (=ₛ-in idp)) where P : EM₁ G.grp → EM₁ G.grp → Type i P = coh-unit-r-eq H-⊙EM₁ H-⊙EM₁-assoc P-level : ∀ x y → is-prop (P x y) P-level x y = =ₛ-level (EM₁-level₁ G.grp) H-EM₁-assoc-coh-unit-l-r-pentagon : coh-unit-l-r-pentagon H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-coh-unit-l-r-pentagon = coh-unit-l-to-unit-l-r-pentagon H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-coh-unit-l import homotopy.Pi2HSuspCompose H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-coh-unit-l-r-pentagon as Pi2EMSuspCompose open Pi2EMSuspCompose hiding (comp-functor) public abstract H-EM₁-assoc-pentagon : coh-assoc-pentagon H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-pentagon w x y z = EM₁-prop-elim {P = λ w' → P w' x y z} {{λ w' → P-level w' x y z}} (EM₁-prop-elim {P = λ x' → P embase x' y z} {{λ x' → P-level embase x' y z}} (=ₛ-in idp) x) w where P : (w x y z : EM₁ G.grp) → Type i P = coh-assoc-pentagon-eq H-⊙EM₁ H-⊙EM₁-assoc P-level : ∀ w x y z → is-prop (P w x y z) P-level w x y z = =ₛ-level (EM₁-level₁ G.grp) EM₁-2-semi-category : TwoSemiCategory lzero i EM₁-2-semi-category = HSpace-2-semi-category H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-pentagon comp-functor : TwoSemiFunctor EM₁-2-semi-category (=ₜ-fundamental-cat (Susp (EM₁ G.grp))) comp-functor = record { F₀ = λ _ → [ north ] ; F₁ = λ x → [ η x ] ; pres-comp = comp ; pres-comp-coh = comp-coh } -- this is *exactly* the same as -- `Pi2EMSuspCompose.comp-functor H-EM₁-assoc-pentagon` -- inlined but Agda chokes on this shorter definition
{ "alphanum_fraction": 0.5559484718, "avg_line_length": 37.7047619048, "ext": "agda", "hexsha": "8c648234e22cbdad3300f64092da4225f8de5bff", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/EM1HSpaceAssoc.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/EM1HSpaceAssoc.agda", "max_line_length": 107, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/EM1HSpaceAssoc.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 1557, "size": 3959 }
module Vec where open import Basics open import Ix open import All open import Cutting open import Tensor data Vec (X : Set) : Nat -> Set where [] : Vec X zero _,-_ : forall {n} -> X -> Vec X n -> Vec X (suc n) _+V_ : forall {X n m} -> Vec X n -> Vec X m -> Vec X (n +N m) [] +V ys = ys (x ,- xs) +V ys = x ,- (xs +V ys) record Applicative (F : Set -> Set) : Set1 where field pure : {X : Set} -> X -> F X _<*>_ : {S T : Set} -> F (S -> T) -> F S -> F T infixl 2 _<*>_ VecAppl : (n : Nat) -> Applicative \ X -> Vec X n Applicative.pure (VecAppl zero) x = [] Applicative.pure (VecAppl (suc n)) x = x ,- Applicative.pure (VecAppl n) x Applicative._<*>_ (VecAppl .zero) [] [] = [] Applicative._<*>_ (VecAppl .(suc _)) (f ,- fs) (s ,- ss) = f s ,- Applicative._<*>_ (VecAppl _) fs ss module VTRAVERSE {F}(A : Applicative F) where open Applicative A vtraverse : forall {n S T} -> (S -> F T) -> Vec S n -> F (Vec T n) vtraverse f [] = pure [] vtraverse f (s ,- ss) = pure _,-_ <*> f s <*> vtraverse f ss Matrix : Set -> Nat * Nat -> Set Matrix X (i , j) = Vec (Vec X i) j xpose : forall {X ij} -> Matrix X ij -> Matrix X (swap ij) xpose = vtraverse id where open VTRAVERSE (VecAppl _) module VECALL {I : Set}{P : I -> Set}{n : Nat}where open Applicative (VecAppl n) vecAll : {is : List I} -> All (\ i -> Vec (P i) n) is -> Vec (All P is) n vecAll {[]} pss = pure <> vecAll {i ,- is} (ps , pss) = pure _,_ <*> ps <*> vecAll pss VecLiftAlg : (C : I |> I) -> Algebra (Cutting C) P -> Algebra (Cutting C) (\ i -> Vec (P i) n) VecLiftAlg C alg i (c 8>< pss) = pure (alg i << (c 8><_)) <*> vecAll pss open VECALL NatCutVecAlg : {X : Set} -> Algebra (Cutting NatCut) (Vec X) NatCutVecAlg {X} .(m +N n) (m , n , refl .(m +N n) 8>< xm , xn , <>) = xm +V xn open RECTANGLE NatCut2DMatAlg : {X : Set} -> Algebra (Cutting RectCut) (Matrix X) NatCut2DMatAlg _ (inl c 8>< ms) = VecLiftAlg NatCut NatCutVecAlg _ (c 8>< ms) NatCut2DMatAlg _ (inr c 8>< ms) = NatCutVecAlg _ (c 8>< ms)
{ "alphanum_fraction": 0.5501912046, "avg_line_length": 29.8857142857, "ext": "agda", "hexsha": "36021a5fee36b8b7a58c08dfb540065f391b5421", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pigworker/InteriorDesign", "max_forks_repo_path": "Vec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pigworker/InteriorDesign", "max_issues_repo_path": "Vec.agda", "max_line_length": 79, "max_stars_count": 6, "max_stars_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pigworker/InteriorDesign", "max_stars_repo_path": "Vec.agda", "max_stars_repo_stars_event_max_datetime": "2018-07-31T02:00:13.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-18T15:25:39.000Z", "num_tokens": 802, "size": 2092 }
------------------------------------------------------------------------------ -- Test the consistency of FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- In the module FOTC.Relation.Binary.Bisimilarity.Type we declare -- Agda postulates as first-order logic axioms. We test if it is -- possible to prove unprovable theorems from these axioms. module FOTC.Relation.Binary.Bisimilarity.Consistency.Axioms where open import FOTC.Base open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ postulate impossible : ∀ d e → d ≡ e {-# ATP prove impossible #-} postulate ≡→≈ : ∀ {xs ys} → xs ≡ ys → xs ≈ ys {-# ATP prove ≡→≈ #-} postulate ≈→≡ : ∀ {xs ys} → xs ≈ ys → xs ≡ ys {-# ATP prove ≈→≡ #-} postulate ≉→≢ : ∀ {xs ys} → xs ≉ ys → xs ≢ ys {-# ATP prove ≉→≢ #-}
{ "alphanum_fraction": 0.4912442396, "avg_line_length": 33.90625, "ext": "agda", "hexsha": "eeeedb9851e776d83a0a01aefa43bfa958156ac7", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/Consistency/Axioms.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/Consistency/Axioms.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/Consistency/Axioms.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 262, "size": 1085 }
{-# OPTIONS --without-K --safe #-} module Math.NumberTheory.Product.Nat where -- agda-stdlib open import Data.Nat.Properties -- agda-misc open import Math.NumberTheory.Product.Generic open MonoidProduct *-1-monoid public
{ "alphanum_fraction": 0.76, "avg_line_length": 18.75, "ext": "agda", "hexsha": "6b8eecc6c44e92eec05e5c51e14d3a2a0f73a0b6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Math/NumberTheory/Product/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Math/NumberTheory/Product/Nat.agda", "max_line_length": 45, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Math/NumberTheory/Product/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 55, "size": 225 }
open import Prelude module Implicits.Syntax.Context where open import Implicits.Syntax.Type open import Data.List.All open import Data.Vec open import Data.List Ctx : ℕ → ℕ → Set Ctx ν n = Vec (Type ν) n ICtx : ℕ → Set ICtx ν = List (Type ν) -- wellformed implicit contexts _⊢OK : ∀ {ν} → ICtx ν → Set Δ ⊢OK = All (λ a → List.[] ⊢unamb a) Δ Ktx : ℕ → ℕ → Set Ktx ν n = Ctx ν n × ICtx ν _∷Γ_ : ∀ {ν n} → Type ν → Ktx ν n → Ktx ν (suc n) a ∷Γ (Γ , Δ) = (a ∷ Γ) , Δ _∷Δ_ : ∀ {ν n} → Type ν → Ktx ν n → Ktx ν n a ∷Δ (Γ , Δ) = Γ , a List.∷ Δ _∷K_ : ∀ {ν n} → Type ν → Ktx ν n → Ktx ν (suc n) a ∷K (Γ , Δ) = a ∷ Γ , a List.∷ Δ nil : ∀ {ν} → Ktx ν 0 nil = [] , List.[]
{ "alphanum_fraction": 0.5520833333, "avg_line_length": 19.7647058824, "ext": "agda", "hexsha": "afad3da5e97dfb90c1ea73f57d2b0c8eaf5b2e39", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Syntax/Context.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Syntax/Context.agda", "max_line_length": 49, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Syntax/Context.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 308, "size": 672 }
------------------------------------------------------------------------------ -- Distributive laws on a binary operation (Stanovský example) ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module DistributiveLaws.README where ------------------------------------------------------------------------------ -- Description -- Let _·_ be a left-associative binary operation which satifies the -- left and right distributive axioms: -- -- ∀ x y z → x ∙ (y ∙ z) ≡ (x ∙ y) ∙ (x ∙ z) -- ∀ x y z → (x ∙ y) ∙ z ≡ (x ∙ z) ∙ (y ∙ z). -- We prove some properties of Stanovský (2008): Task B, Lemma 3, -- Lemma 4, Lemma 5 (Task A) and Lemma 6. ------------------------------------------------------------------------------ -- The axioms open import DistributiveLaws.Base -- The interactive and combined proofs open import DistributiveLaws.Lemma3-ATP open import DistributiveLaws.Lemma4-ATP open import DistributiveLaws.Lemma5-ATP open import DistributiveLaws.Lemma6-ATP open import DistributiveLaws.TaskB-AllStepsATP open import DistributiveLaws.TaskB-HalvedStepsATP open import DistributiveLaws.TaskB-I open import DistributiveLaws.TaskB-TopDownATP -- Unproven theorem by the ATPs open import DistributiveLaws.TaskB.UnprovedATP ------------------------------------------------------------------------------ -- References: -- -- Stanovský, David (2008). Distributive Groupoids are -- Symmetrical-by-Medial: An Elementary Proof. Commentations -- Mathematicae Universitatis Carolinae 49.4, pp. 541–546.
{ "alphanum_fraction": 0.5488235294, "avg_line_length": 36.170212766, "ext": "agda", "hexsha": "d66c03388c488dfe49c780a7e2985d934253ae67", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/DistributiveLaws/README.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/DistributiveLaws/README.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/DistributiveLaws/README.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 403, "size": 1700 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Sets.EquivalenceRelations open import LogicalFormulae open import Setoids.Setoids open import Rings.Definition open import Modules.Definition open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Lists.Lists open import Vectors open import Groups.Definition open import Orders.Total.Definition open import Groups.Homomorphisms.Definition open import Groups.Homomorphisms.Lemmas open import Rings.Homomorphisms.Definition module Modules.PolynomialModule {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where open Ring R open import Groups.Polynomials.Definition additiveGroup open import Groups.Polynomials.Group additiveGroup open import Rings.Polynomial.Multiplication R open import Rings.Polynomial.Evaluation R open import Rings.Polynomial.Ring R open import Rings.Lemmas polyRing polynomialRingModule : Module R abelianUnderlyingGroup (λ a b → _*P_ (polyInjection a) b) Module.dotWellDefined (polynomialRingModule) r=s t=u = Ring.*WellDefined polyRing (r=s ,, record {}) t=u Module.dotDistributesLeft (polynomialRingModule) {r} {s} {t} = Ring.*DistributesOver+ polyRing {polyInjection r} {s} {t} Module.dotDistributesRight (polynomialRingModule) {r} {s} {t} = Ring.*DistributesOver+' polyRing {polyInjection r} {polyInjection s} {t} Module.dotAssociative (polynomialRingModule) {r} {s} {t} = Equivalence.transitive (Setoid.eq naivePolySetoid) (Ring.*WellDefined polyRing m (Equivalence.reflexive (Setoid.eq naivePolySetoid) {t})) (Equivalence.symmetric (Setoid.eq naivePolySetoid) (Ring.*Associative polyRing {polyInjection r} {polyInjection s} {t})) where m : Setoid._∼_ naivePolySetoid ((r * s) :: []) ((r * s) :: (([] +P []) +P (0R :: []))) m = Equivalence.reflexive (Setoid.eq S) ,, (Equivalence.reflexive (Setoid.eq S) ,, record {}) Module.dotIdentity (polynomialRingModule) = Ring.identIsIdent polyRing open import Modules.Span polynomialRingModule polynomialBasis : ℕ → NaivePoly polynomialBasis zero = polyInjection 1R polynomialBasis (succ a) = 0R :: polynomialBasis a count : (n : ℕ) → Vec ℕ n count zero = [] count (succ n) = 0 ,- vecMap succ (count n) lemma : {d : _} {D : Set d} → (f : D → List A) → {n : ℕ} → (m : Vec D n) (r : Vec A n) → Setoid._∼_ naivePolySetoid (dot (vecMap (λ i → 0R :: f i) m) r) (0R :: dot (vecMap f m) r) lemma f [] [] = reflexive ,, record {} where open Setoid S open Equivalence eq lemma f (m ,- ms) (r ,- rs) rewrite refl {x = 0} = transitive (+WellDefined {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))} {_} {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))} (reflexive {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))}) (lemma f ms rs)) (Equivalence.transitive (Setoid.eq S) (Group.identRight additiveGroup) (Ring.timesZero R) ,, +WellDefined {((map (_*_ r) (f m)) +P []) +P (0R :: [])} {dot (vecMap f ms) rs} {(r :: []) *P f m} {dot (vecMap f ms) rs} t (reflexive {dot (vecMap f ms) rs})) where open Setoid naivePolySetoid open Equivalence eq open Group polyGroup lemm : (v : List A) → polysEqual (map (_*_ r) v) ((r :: []) *P v) lemm [] = record {} lemm (x :: v) = Equivalence.reflexive (Setoid.eq S) ,, symmetric (transitive (+WellDefined {map (_*_ r) v +P []} {0R :: []} {_} {[]} reflexive (Equivalence.reflexive (Setoid.eq S) ,, record {})) (transitive (identRight {(map (_*_ r) v) +P []}) (identRight {map (_*_ r) v}))) t : ((map (_*_ r) (f m) +P []) +P (0R :: [])) ∼ ((r :: []) *P f m) t = transitive (+WellDefined {map (_*_ r) (f m) +P []} {0R :: []} {_} {[]} reflexive (Equivalence.reflexive (Setoid.eq S) ,, record {})) (transitive (identRight {map (_*_ r) (f m) +P []}) (transitive (identRight {map (_*_ r) (f m)}) (lemm (f m)))) identityMap : (v : List A) → Setoid._∼_ naivePolySetoid (dot (vecMap polynomialBasis (count (length v))) (listToVec v)) v identityMap [] = record {} identityMap (x :: v) rewrite vecMapCompose succ polynomialBasis (count (length v)) = transitive (+WellDefined {(x * 1R) :: Group.0G additiveGroup :: []} {dot (vecMap (λ i → Group.0G additiveGroup :: polynomialBasis i) (count (length v))) (listToVec v)} {(x * 1R) :: 0R :: []} {0R :: dot (vecMap polynomialBasis (count (length v))) (listToVec v)} (reflexive {(x * 1R) :: 0R :: []}) (lemma polynomialBasis (count (length v)) (listToVec v))) (Equivalence.transitive (Setoid.eq S) (Group.identRight additiveGroup) (Equivalence.transitive (Setoid.eq S) *Commutative identIsIdent) ,, transitive (+WellDefined {0R :: []} {dot (vecMap polynomialBasis (count (length v))) (listToVec v)} {[]} (Equivalence.reflexive (Setoid.eq S) ,, record {}) reflexive) (transitive identLeft (identityMap v))) where open Group polyGroup open Setoid naivePolySetoid open Equivalence eq polynomialBasisSpans : Spans polynomialBasis polynomialBasisSpans m = length m , ((count (length m) ,, listToVec m) , identityMap m) {- private indepWithZero : {n : ℕ} (rs : Vec ℕ n) (indicesDistinct : {a b : ℕ} → (a<n : a <N succ n) (b<n : b <N succ n) → vecIndex (0 ,- rs) a a<n ≡ vecIndex (0 ,- rs) b b<n → a ≡ b) (b : A) (bs : Vec A n) (dotZero : Setoid._∼_ naivePolySetoid (((b * 1R) :: 0R :: []) +P (dot (vecMap polynomialBasis rs) bs)) []) → (nonzero : {a : ℕ} → (a<n : a <N n) → 0 <N vecIndex rs a a<n) → Setoid._∼_ S 0R b && _=V_ additiveGroup (vecPure 0R) bs indepWithZero rs indicesDistinct b bs dotZero indicesNonzero = symmetric b=0 ,, {!!} where open Setoid S open Equivalence eq open Group additiveGroup t : (inducedFunction (((b * 1R) :: 0R :: []) +P (dot (vecMap polynomialBasis rs) bs)) 0R) ∼ 0R t = inducedFunctionWellDefined dotZero 0R u : ((inducedFunction ((b * 1R) :: 0R :: []) 0R) + inducedFunction (dot (vecMap polynomialBasis rs) bs) 0R) ∼ 0R u = transitive (symmetric (GroupHom.groupHom (RingHom.groupHom (inducedFunctionIsHom 0R)) {((b * 1R) :: 0R :: [])} {dot (vecMap polynomialBasis rs) bs})) t b=0 : b ∼ 0R b=0 = transitive (symmetric (transitive (+WellDefined (transitive (transitive (transitive (+WellDefined reflexive (transitive *Commutative timesZero)) identRight) *Commutative) identIsIdent) {!imageOfIdentityIsIdentity (RingHom.groupHom (inducedFunctionIsHom 0R))!}) (identRight {b}))) u polynomialBasisIndependent : Independent polynomialBasis polynomialBasisIndependent [] indicesDistinct [] dotZero = record {} polynomialBasisIndependent {succ n} (zero ,- rs) indicesDistinct (b ,- bs) dotZero = indepWithZero rs indicesDistinct b bs dotZero t where t : {a : ℕ} (a<n : a <N n) → 0 <N vecIndex rs a a<n t {a} a<n with TotalOrder.totality ℕTotalOrder 0 (vecIndex rs a a<n) t {a} a<n | inl (inl x) = x t {a} a<n | inr x with indicesDistinct {succ a} {0} (succPreservesInequality a<n) (succIsPositive n) (equalityCommutative x) ... | () polynomialBasisIndependent (succ r ,- rs) indicesDistinct (b ,- bs) dotZero = {!!} where rearr : {!!} rearr = {!!} -}
{ "alphanum_fraction": 0.6617793594, "avg_line_length": 66.9047619048, "ext": "agda", "hexsha": "9a590a214ec53f91574dbe1b08b8f38570e65038", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Modules/PolynomialModule.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Modules/PolynomialModule.agda", "max_line_length": 784, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Modules/PolynomialModule.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 2344, "size": 7025 }
{-# OPTIONS --rewriting #-} -- 2014-05-27 Jesper and Andreas postulate A B : Set R : A → B → Set {-# BUILTIN REWRITE R #-}
{ "alphanum_fraction": 0.5681818182, "avg_line_length": 13.2, "ext": "agda", "hexsha": "cd5aeaebde3a8d4b92bfb3031ef49df2caa77830", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/RewriteRelationNotHomogeneous.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/RewriteRelationNotHomogeneous.agda", "max_line_length": 32, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/RewriteRelationNotHomogeneous.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 45, "size": 132 }
{-# 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 ] }
{ "alphanum_fraction": 0.6533430233, "avg_line_length": 28.6666666667, "ext": "agda", "hexsha": "4d3cdf3754f8e2105bfa6d42ec05a9425f156875", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "awswan/nielsenschreier-hott", "max_forks_repo_path": "main/Groups/Definition.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "awswan/nielsenschreier-hott", "max_issues_repo_path": "main/Groups/Definition.agda", "max_line_length": 125, "max_stars_count": null, "max_stars_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "awswan/nielsenschreier-hott", "max_stars_repo_path": "main/Groups/Definition.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 442, "size": 1376 }
module CTL.Proof where open import CTL.Proof.AG public open import CTL.Proof.EG public
{ "alphanum_fraction": 0.8068181818, "avg_line_length": 17.6, "ext": "agda", "hexsha": "da62d6c1681fcca397d2f16f1811abf0f0996e85", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "zimbatm/condatis", "max_forks_repo_path": "CTL/Proof.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "zimbatm/condatis", "max_issues_repo_path": "CTL/Proof.agda", "max_line_length": 31, "max_stars_count": 1, "max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Aerate/condatis", "max_stars_repo_path": "CTL/Proof.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z", "num_tokens": 24, "size": 88 }
module ReflectionExposeConstraints where open import Agda.Builtin.Reflection open import Agda.Builtin.List open import Agda.Builtin.Nat open import Agda.Builtin.Unit open import Agda.Builtin.Equality _>>=_ : ∀ {a b} {A : Set a} {B : Set b} → TC A → (A → TC B) → TC B _>>=_ = bindTC _ifMeta_ : {A : Set} → Term → (Meta → TC A) → TC A meta x x₁ ifMeta f = f x _ ifMeta _ = typeError (strErr "Error1" ∷ []) infixr 0 case_of_ case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x foo : Constraint → TC Term foo (valueCmp cmpEq y t1 (def f args)) = returnTC (def f []) foo _ = typeError (strErr "Error2" ∷ []) q : Nat → Nat q zero = 4 q (suc x) = 4 macro mfun : Term → TC ⊤ mfun hole = delayMacro >>= (λ _ → hole ifMeta (λ x → do c ← getConstraintsMentioning (x ∷ []) case c of λ {[] → typeError (strErr "Error3" ∷ []) ; (c ∷ cs) → do g ← foo c unify hole g } )) postulate g : (Q : Nat → Nat) → ∀ k → Q k ≡ 4 f : ∀ k → q k ≡ 4 f k = g mfun k
{ "alphanum_fraction": 0.4690763052, "avg_line_length": 27.0652173913, "ext": "agda", "hexsha": "b83ab0048b7853a504c07e545817c01049c81eca", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75d3f20f94280881ec0a35ed0ae2ab4f1042c8fe", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "xekoukou/agda", "max_forks_repo_path": "test/Succeed/ReflectionExposeConstraints.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "75d3f20f94280881ec0a35ed0ae2ab4f1042c8fe", "max_issues_repo_issues_event_max_datetime": "2020-01-26T18:22:08.000Z", "max_issues_repo_issues_event_min_datetime": "2020-01-26T18:22:08.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "xekoukou/agda", "max_issues_repo_path": "test/Succeed/ReflectionExposeConstraints.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "75d3f20f94280881ec0a35ed0ae2ab4f1042c8fe", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "xekoukou/agda", "max_stars_repo_path": "test/Succeed/ReflectionExposeConstraints.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 394, "size": 1245 }
open import Relation.Unary open import Relation.Ternary.Separation module Relation.Ternary.Separation.Monad.Free {ℓ} {A : Set ℓ} {{r : RawSep A}} (Cmd : Pred A ℓ) (δ : ∀ {Φ} → Cmd Φ → Pred A ℓ) where open import Level open import Function open import Data.Unit open import Data.Product open import Relation.Unary.PredicateTransformer using (PT) open import Relation.Ternary.Separation.Morphisms open import Relation.Ternary.Separation.Monad open import Relation.Binary.PropositionalEquality mutual Cont : ∀ {Δ} → Cmd Δ → Pred A ℓ → Pred A ℓ Cont c P = δ c ─✴ Free P data Free : PT A A ℓ ℓ where pure : ∀ {P} → ∀[ P ⇒ Free P ] impure : ∀ {P} → ∀[ ∃[ Cmd ]✴ (λ c → Cont c P) ⇒ Free P ] module _ {u} {{_ : IsUnitalSep r u}} where open Monads instance free-monad : Monad ⊤ ℓ (λ _ _ → Free) Monad.return free-monad = pure app (Monad.bind free-monad f) (pure x) σ = app f x σ app (Monad.bind free-monad f) (impure (cmd ×⟨ σ₁ ⟩ κ)) σ = let _ , σ₂ , σ₃ = ⊎-assoc σ₁ (⊎-comm σ) in impure (cmd ×⟨ σ₂ ⟩ wand λ resp σ₄ → let _ , τ₁ , τ₂ = ⊎-assoc (⊎-comm σ₃) σ₄ in app (bind f) (app κ resp τ₂) τ₁) ⟪_⟫ : ∀ {Φ} → (c : Cmd Φ) → Free (δ c) Φ ⟪_⟫ c = impure (c ×⟨ ⊎-idʳ ⟩ wand λ r σ → case ⊎-id⁻ˡ σ of λ where refl → return r ) module _ {B : Set ℓ} {M : PT A B ℓ ℓ} {P : Pred A ℓ} {{rb : RawSep B}} {u} {{_ : IsUnitalSep r u}} {{jm : Morphism A B}} {{_ : IsUnitalSep rb (Morphism.j jm u)}} {{ monad : Monads.Monad {{jm = jm}} ⊤ ℓ (λ _ _ → M) }} where open Morphism jm open Monads.Monad {{jm = jm}} monad open Monads {{jm = jm}} using (str; typed-str) open import Data.Nat -- Unfolding a command tree one step step : (cmd : ∀ {Φ} → (c : Cmd Φ) → M (δ c) (j Φ)) → ∀[ Free P ⇒ⱼ M (Free P) ] step cmd (pure px) = return (pure px) step cmd (impure (c ×⟨ σ ⟩ κ)) = do r ×⟨ σ ⟩ κ ← cmd c &⟨ Cont c P ∥ j-⊎ σ ⟩ κ return (app κ r (⊎-comm σ)) -- A fueled generic interpreter for command trees in Free interpret : ℕ → ∀[ M P ] → (cmd : ∀ {Φ} → (c : Cmd Φ) → M (δ c) (j Φ)) → ∀[ Free P ⇒ⱼ M P ] interpret zero def cmd f = def interpret (suc n) def cmd f = do impure f ← step cmd f where (pure v) → return v interpret n def cmd (impure f)
{ "alphanum_fraction": 0.5713660245, "avg_line_length": 31.7222222222, "ext": "agda", "hexsha": "7385bef34343cb9a4f5046173faa8950a7ee3bd8", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z", "max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z", "max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "laMudri/linear.agda", "max_forks_repo_path": "src/Relation/Ternary/Separation/Monad/Free.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "laMudri/linear.agda", "max_issues_repo_path": "src/Relation/Ternary/Separation/Monad/Free.agda", "max_line_length": 93, "max_stars_count": 34, "max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "laMudri/linear.agda", "max_stars_repo_path": "src/Relation/Ternary/Separation/Monad/Free.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z", "num_tokens": 903, "size": 2284 }
module PLRTree.Complete.Correctness.Alternative {A : Set} where open import BTree.Complete.Alternative {A} open import BTree.Complete.Alternative.Properties {A} open import BTree.Equality {A} open import PLRTree {A} open import PLRTree.Complete {A} renaming (Complete to Complete' ; _⋗_ to _⋗'_ ; _⋘_ to _⋘'_ ; _⋙_ to _⋙'_) open import PLRTree.Equality.Correctness {A} lemma-⋗'-⋗ : {l r : PLRTree} → l ⋗' r → forget l ⋗ forget r lemma-⋗'-⋗ (⋗lf x) = ⋗lf x lemma-⋗'-⋗ (⋗nd x x' l≃'r l'≃'r' l⋗'l') = ⋗nd x x' (lemma-≃'-≃ l≃'r) (lemma-≃'-≃ l'≃'r') (lemma-⋗'-⋗ l⋗'l') mutual lemma-⋘'-⋘ : {l r : PLRTree} → l ⋘' r → forget l ⋘ forget r lemma-⋘'-⋘ (x⋘ x y z) = lr⋘ x z (⋙lf y) ≃lf (⋗lf y) lemma-⋘'-⋘ (l⋘ x x' l'⋘'r' l'≃'r' r≃'l') = ll⋘ x x' (lemma-⋘'-⋘ l'⋘'r') (lemma-≃'-≃ l'≃'r') (lemma-≃'-≃ r≃'l') lemma-⋘'-⋘ (r⋘ x x' l'⋙'r' l'≃'r' l⋗'l') = lr⋘ x x' (lemma-⋙'-⋙ l'⋙'r') (lemma-≃'-≃ l'≃'r') (lemma-⋗'-⋗ l⋗'l') lemma-⋙'-⋙ : {l r : PLRTree} → l ⋙' r → forget l ⋙ forget r lemma-⋙'-⋙ (⋙p l⋗'r) = lemma-⋗-⋙ (lemma-⋗'-⋗ l⋗'r) lemma-⋙'-⋙ (⋙l x x' l≃'r l'⋘'r' l⋗'r') = ⋙rl x x' (lemma-≃'-≃ l≃'r) (lemma-⋘'-⋘ l'⋘'r') (lemma-⋗'-⋗ l⋗'r') lemma-⋙'-⋙ (⋙r x x' l≃'r l'⋙'r' l≃'l') = ⋙rr x x' (lemma-≃'-≃ l≃'r) (lemma-⋙'-⋙ l'⋙'r') (lemma-≃'-≃ l≃'l') lemma-complete'-complete : {t : PLRTree} → Complete' t → Complete (forget t) lemma-complete'-complete leaf = leaf lemma-complete'-complete (perfect x c'l c'r l≃'r) = left x cl cr l⋘r where cl = lemma-complete'-complete c'l ; cr = lemma-complete'-complete c'r ; l⋘r = lemma-≃-⋘ (lemma-≃'-≃ l≃'r) lemma-complete'-complete (left x c'l c'r l⋘'r) = left x cl cr l⋘r where cl = lemma-complete'-complete c'l ; cr = lemma-complete'-complete c'r ; l⋘r = lemma-⋘'-⋘ l⋘'r lemma-complete'-complete (right x c'l c'r l⋙'r) = right x cl cr l⋙r where cl = lemma-complete'-complete c'l ; cr = lemma-complete'-complete c'r ; l⋙r = lemma-⋙'-⋙ l⋙'r
{ "alphanum_fraction": 0.4834653004, "avg_line_length": 53.675, "ext": "agda", "hexsha": "c04dda70b674650b8fe0495a9ca5b08a351d7ae1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/PLRTree/Complete/Correctness/Alternative.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/PLRTree/Complete/Correctness/Alternative.agda", "max_line_length": 112, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/PLRTree/Complete/Correctness/Alternative.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 1072, "size": 2147 }
-- Andreas, 2012-02-13: polarity info must be correct {-# OPTIONS --sized-types --show-implicit #-} -- {-# OPTIONS -v tc.size.solve:20 -v tc.conv.size:20 #-} -- {-# OPTIONS -v tc.polarity.set:10 -v tc.conv.term.shortcut:20 #-} module WrongPolarity where open import Common.Size data ⊥ : Set where data Sink (A : Set) : Set where sink : (A → ⊥) → Sink A postulate dump : {A : Set} → A → Sink A -- A sized type data Nat : {size : Size} → Set where zero : {size : Size} → Nat {↑ size} suc : {size : Size} → Nat {size} → Nat {↑ size} dumpNat : {i : Size} → Nat {i} → Sink (Nat {i}) dumpNat zero = dump zero dumpNat (suc {i} n) = dumpNat {i} n -- should fail! -- i != ↑ i of type Size -- when checking that the expression dumpNat n has type Sink Nat
{ "alphanum_fraction": 0.611183355, "avg_line_length": 27.4642857143, "ext": "agda", "hexsha": "c4abe154e5de6d11725f1ab85c833e7714640677", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/fail/WrongPolarity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/agda-kanso", "max_issues_repo_path": "test/fail/WrongPolarity.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/WrongPolarity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 254, "size": 769 }
module DescStrat where open import StratSigma data Desc42 : Set43 where id42 : Desc42 const42 : Set42 -> Desc42 prod42 : Desc42 -> Desc42 -> Desc42 sigma42 : (S : Set42) -> (S -> Desc42) -> Desc42 pi42 : (S : Set42) -> (S -> Desc42) -> Desc42 [|_|]42_ : Desc42 -> Set42 -> Set42 [| id42 |]42 Z = Z [| const42 X |]42 Z = X [| prod42 D D' |]42 Z = [| D |]42 Z *42 [| D' |]42 Z [| sigma42 S T |]42 Z = Sigma42 S (\s -> [| T s |]42 Z) [| pi42 S T |]42 Z = (s : S) -> [| T s |]42 Z data Mu42 (D : Desc42) : Set42 where con : [| D |]42 (Mu42 D) -> Mu42 D data DescDef41 : Set42 where DescId41 : DescDef41 DescConst41 : DescDef41 DescProd41 : DescDef41 DescSigma41 : DescDef41 DescPi41 : DescDef41 data Lift41 (A : Set41) : Set42 where lifter : A -> Lift41 A unlift41 : {A : Set41} -> Lift41 A -> A unlift41 (lifter a) = a descCases41 : DescDef41 -> Desc42 descCases41 DescId41 = const42 Unit42 descCases41 DescConst41 = sigma42 Set41 (\_ -> const42 Unit42) descCases41 DescProd41 = prod42 id42 (prod42 id42 (const42 Unit42)) descCases41 DescSigma41 = sigma42 Set41 (\S -> prod42 (pi42 (Lift41 S) (\_ -> id42)) (const42 Unit42)) descCases41 DescPi41 = sigma42 Set41 (\S -> prod42 (pi42 (Lift41 S) (\_ -> id42)) (const42 Unit42)) DescD41 : Desc42 DescD41 = sigma42 DescDef41 descCases41 Desc41 : Set42 Desc41 = Mu42 DescD41 id41 : Desc41 id41 = con (DescId41 , Void) const41 : Set41 -> Desc41 const41 K = con (DescConst41 , (K , Void)) prod41 : (D D' : Desc41) -> Desc41 prod41 D D' = con (DescProd41 , (D , ( D' , Void ))) sigma41 : (S : Set41)(D : S -> Desc41) -> Desc41 sigma41 S D = con (DescSigma41 , (S , ((\s -> D (unlift41 s)) , Void ))) pi41 : (S : Set41)(D : S -> Desc41) -> Desc41 pi41 S D = con (DescPi41 , (S , ((\s -> D (unlift41 s)) , Void ))) [|_|]41_ : Desc41 -> Set41 -> Set41 [| con (DescId41 , Void) |]41 Z = Z [| con (DescConst41 , ( S , Void)) |]41 Z = S [| con (DescProd41 , (D , ( D' , Void ))) |]41 Z = [| D |]41 Z *41 [| D' |]41 Z [| con (DescSigma41 , (S , (T , Void))) |]41 Z = Sigma41 S (\s -> [| T (lifter s) |]41 Z ) [| con (DescPi41 , (S , (T , Void))) |]41 Z = (s : S) -> [| T (lifter s) |]41 Z data Mu41 (D : Desc41) : Set41 where con : [| D |]41 (Mu41 D) -> Mu41 D data DescDef40 : Set41 where DescId40 : DescDef40 DescConst40 : DescDef40 DescProd40 : DescDef40 DescSigma40 : DescDef40 DescPi40 : DescDef40 data Lift40 (A : Set40) : Set41 where lifter : A -> Lift40 A unlift40 : {A : Set40} -> Lift40 A -> A unlift40 (lifter a) = a descCases40 : DescDef40 -> Desc41 descCases40 DescId40 = const41 Unit41 descCases40 DescConst40 = sigma41 Set40 (\_ -> const41 Unit41) descCases40 DescProd40 = prod41 id41 (prod41 id41 (const41 Unit41)) descCases40 DescSigma40 = sigma41 Set40 (\S -> prod41 (pi41 (Lift40 S) (\_ -> id41)) (const41 Unit41)) descCases40 DescPi40 = sigma41 Set40 (\S -> prod41 (pi41 (Lift40 S) (\_ -> id41)) (const41 Unit41)) DescD40 : Desc41 DescD40 = sigma41 DescDef40 descCases40 Desc40 : Set41 Desc40 = Mu41 DescD40 id40 : Desc40 id40 = con (DescId40 , Void) const40 : Set40 -> Desc40 const40 K = con (DescConst40 , (K , Void)) prod40 : (D D' : Desc40) -> Desc40 prod40 D D' = con (DescProd40 , (D , ( D' , Void ))) sigma40 : (S : Set40)(D : S -> Desc40) -> Desc40 sigma40 S D = con (DescSigma40 , (S , ((\s -> D (unlift40 s)) , Void ))) pi40 : (S : Set40)(D : S -> Desc40) -> Desc40 pi40 S D = con (DescPi40 , (S , ((\s -> D (unlift40 s)) , Void ))) [|_|]40_ : Desc40 -> Set40 -> Set40 [| con (DescId40 , Void) |]40 Z = Z [| con (DescConst40 , ( S , Void)) |]40 Z = S [| con (DescProd40 , (D , ( D' , Void ))) |]40 Z = [| D |]40 Z *40 [| D' |]40 Z [| con (DescSigma40 , (S , (T , Void))) |]40 Z = Sigma40 S (\s -> [| T (lifter s) |]40 Z ) [| con (DescPi40 , (S , (T , Void))) |]40 Z = (s : S) -> [| T (lifter s) |]40 Z data Mu40 (D : Desc40) : Set40 where con : [| D |]40 (Mu40 D) -> Mu40 D data DescDef39 : Set40 where DescId39 : DescDef39 DescConst39 : DescDef39 DescProd39 : DescDef39 DescSigma39 : DescDef39 DescPi39 : DescDef39 data Lift39 (A : Set39) : Set40 where lifter : A -> Lift39 A unlift39 : {A : Set39} -> Lift39 A -> A unlift39 (lifter a) = a descCases39 : DescDef39 -> Desc40 descCases39 DescId39 = const40 Unit40 descCases39 DescConst39 = sigma40 Set39 (\_ -> const40 Unit40) descCases39 DescProd39 = prod40 id40 (prod40 id40 (const40 Unit40)) descCases39 DescSigma39 = sigma40 Set39 (\S -> prod40 (pi40 (Lift39 S) (\_ -> id40)) (const40 Unit40)) descCases39 DescPi39 = sigma40 Set39 (\S -> prod40 (pi40 (Lift39 S) (\_ -> id40)) (const40 Unit40)) DescD39 : Desc40 DescD39 = sigma40 DescDef39 descCases39 Desc39 : Set40 Desc39 = Mu40 DescD39 id39 : Desc39 id39 = con (DescId39 , Void) const39 : Set39 -> Desc39 const39 K = con (DescConst39 , (K , Void)) prod39 : (D D' : Desc39) -> Desc39 prod39 D D' = con (DescProd39 , (D , ( D' , Void ))) sigma39 : (S : Set39)(D : S -> Desc39) -> Desc39 sigma39 S D = con (DescSigma39 , (S , ((\s -> D (unlift39 s)) , Void ))) pi39 : (S : Set39)(D : S -> Desc39) -> Desc39 pi39 S D = con (DescPi39 , (S , ((\s -> D (unlift39 s)) , Void ))) [|_|]39_ : Desc39 -> Set39 -> Set39 [| con (DescId39 , Void) |]39 Z = Z [| con (DescConst39 , ( S , Void)) |]39 Z = S [| con (DescProd39 , (D , ( D' , Void ))) |]39 Z = [| D |]39 Z *39 [| D' |]39 Z [| con (DescSigma39 , (S , (T , Void))) |]39 Z = Sigma39 S (\s -> [| T (lifter s) |]39 Z ) [| con (DescPi39 , (S , (T , Void))) |]39 Z = (s : S) -> [| T (lifter s) |]39 Z data Mu39 (D : Desc39) : Set39 where con : [| D |]39 (Mu39 D) -> Mu39 D data DescDef38 : Set39 where DescId38 : DescDef38 DescConst38 : DescDef38 DescProd38 : DescDef38 DescSigma38 : DescDef38 DescPi38 : DescDef38 data Lift38 (A : Set38) : Set39 where lifter : A -> Lift38 A unlift38 : {A : Set38} -> Lift38 A -> A unlift38 (lifter a) = a descCases38 : DescDef38 -> Desc39 descCases38 DescId38 = const39 Unit39 descCases38 DescConst38 = sigma39 Set38 (\_ -> const39 Unit39) descCases38 DescProd38 = prod39 id39 (prod39 id39 (const39 Unit39)) descCases38 DescSigma38 = sigma39 Set38 (\S -> prod39 (pi39 (Lift38 S) (\_ -> id39)) (const39 Unit39)) descCases38 DescPi38 = sigma39 Set38 (\S -> prod39 (pi39 (Lift38 S) (\_ -> id39)) (const39 Unit39)) DescD38 : Desc39 DescD38 = sigma39 DescDef38 descCases38 Desc38 : Set39 Desc38 = Mu39 DescD38 id38 : Desc38 id38 = con (DescId38 , Void) const38 : Set38 -> Desc38 const38 K = con (DescConst38 , (K , Void)) prod38 : (D D' : Desc38) -> Desc38 prod38 D D' = con (DescProd38 , (D , ( D' , Void ))) sigma38 : (S : Set38)(D : S -> Desc38) -> Desc38 sigma38 S D = con (DescSigma38 , (S , ((\s -> D (unlift38 s)) , Void ))) pi38 : (S : Set38)(D : S -> Desc38) -> Desc38 pi38 S D = con (DescPi38 , (S , ((\s -> D (unlift38 s)) , Void ))) [|_|]38_ : Desc38 -> Set38 -> Set38 [| con (DescId38 , Void) |]38 Z = Z [| con (DescConst38 , ( S , Void)) |]38 Z = S [| con (DescProd38 , (D , ( D' , Void ))) |]38 Z = [| D |]38 Z *38 [| D' |]38 Z [| con (DescSigma38 , (S , (T , Void))) |]38 Z = Sigma38 S (\s -> [| T (lifter s) |]38 Z ) [| con (DescPi38 , (S , (T , Void))) |]38 Z = (s : S) -> [| T (lifter s) |]38 Z data Mu38 (D : Desc38) : Set38 where con : [| D |]38 (Mu38 D) -> Mu38 D data DescDef37 : Set38 where DescId37 : DescDef37 DescConst37 : DescDef37 DescProd37 : DescDef37 DescSigma37 : DescDef37 DescPi37 : DescDef37 data Lift37 (A : Set37) : Set38 where lifter : A -> Lift37 A unlift37 : {A : Set37} -> Lift37 A -> A unlift37 (lifter a) = a descCases37 : DescDef37 -> Desc38 descCases37 DescId37 = const38 Unit38 descCases37 DescConst37 = sigma38 Set37 (\_ -> const38 Unit38) descCases37 DescProd37 = prod38 id38 (prod38 id38 (const38 Unit38)) descCases37 DescSigma37 = sigma38 Set37 (\S -> prod38 (pi38 (Lift37 S) (\_ -> id38)) (const38 Unit38)) descCases37 DescPi37 = sigma38 Set37 (\S -> prod38 (pi38 (Lift37 S) (\_ -> id38)) (const38 Unit38)) DescD37 : Desc38 DescD37 = sigma38 DescDef37 descCases37 Desc37 : Set38 Desc37 = Mu38 DescD37 id37 : Desc37 id37 = con (DescId37 , Void) const37 : Set37 -> Desc37 const37 K = con (DescConst37 , (K , Void)) prod37 : (D D' : Desc37) -> Desc37 prod37 D D' = con (DescProd37 , (D , ( D' , Void ))) sigma37 : (S : Set37)(D : S -> Desc37) -> Desc37 sigma37 S D = con (DescSigma37 , (S , ((\s -> D (unlift37 s)) , Void ))) pi37 : (S : Set37)(D : S -> Desc37) -> Desc37 pi37 S D = con (DescPi37 , (S , ((\s -> D (unlift37 s)) , Void ))) [|_|]37_ : Desc37 -> Set37 -> Set37 [| con (DescId37 , Void) |]37 Z = Z [| con (DescConst37 , ( S , Void)) |]37 Z = S [| con (DescProd37 , (D , ( D' , Void ))) |]37 Z = [| D |]37 Z *37 [| D' |]37 Z [| con (DescSigma37 , (S , (T , Void))) |]37 Z = Sigma37 S (\s -> [| T (lifter s) |]37 Z ) [| con (DescPi37 , (S , (T , Void))) |]37 Z = (s : S) -> [| T (lifter s) |]37 Z data Mu37 (D : Desc37) : Set37 where con : [| D |]37 (Mu37 D) -> Mu37 D data DescDef36 : Set37 where DescId36 : DescDef36 DescConst36 : DescDef36 DescProd36 : DescDef36 DescSigma36 : DescDef36 DescPi36 : DescDef36 data Lift36 (A : Set36) : Set37 where lifter : A -> Lift36 A unlift36 : {A : Set36} -> Lift36 A -> A unlift36 (lifter a) = a descCases36 : DescDef36 -> Desc37 descCases36 DescId36 = const37 Unit37 descCases36 DescConst36 = sigma37 Set36 (\_ -> const37 Unit37) descCases36 DescProd36 = prod37 id37 (prod37 id37 (const37 Unit37)) descCases36 DescSigma36 = sigma37 Set36 (\S -> prod37 (pi37 (Lift36 S) (\_ -> id37)) (const37 Unit37)) descCases36 DescPi36 = sigma37 Set36 (\S -> prod37 (pi37 (Lift36 S) (\_ -> id37)) (const37 Unit37)) DescD36 : Desc37 DescD36 = sigma37 DescDef36 descCases36 Desc36 : Set37 Desc36 = Mu37 DescD36 id36 : Desc36 id36 = con (DescId36 , Void) const36 : Set36 -> Desc36 const36 K = con (DescConst36 , (K , Void)) prod36 : (D D' : Desc36) -> Desc36 prod36 D D' = con (DescProd36 , (D , ( D' , Void ))) sigma36 : (S : Set36)(D : S -> Desc36) -> Desc36 sigma36 S D = con (DescSigma36 , (S , ((\s -> D (unlift36 s)) , Void ))) pi36 : (S : Set36)(D : S -> Desc36) -> Desc36 pi36 S D = con (DescPi36 , (S , ((\s -> D (unlift36 s)) , Void ))) [|_|]36_ : Desc36 -> Set36 -> Set36 [| con (DescId36 , Void) |]36 Z = Z [| con (DescConst36 , ( S , Void)) |]36 Z = S [| con (DescProd36 , (D , ( D' , Void ))) |]36 Z = [| D |]36 Z *36 [| D' |]36 Z [| con (DescSigma36 , (S , (T , Void))) |]36 Z = Sigma36 S (\s -> [| T (lifter s) |]36 Z ) [| con (DescPi36 , (S , (T , Void))) |]36 Z = (s : S) -> [| T (lifter s) |]36 Z data Mu36 (D : Desc36) : Set36 where con : [| D |]36 (Mu36 D) -> Mu36 D data DescDef35 : Set36 where DescId35 : DescDef35 DescConst35 : DescDef35 DescProd35 : DescDef35 DescSigma35 : DescDef35 DescPi35 : DescDef35 data Lift35 (A : Set35) : Set36 where lifter : A -> Lift35 A unlift35 : {A : Set35} -> Lift35 A -> A unlift35 (lifter a) = a descCases35 : DescDef35 -> Desc36 descCases35 DescId35 = const36 Unit36 descCases35 DescConst35 = sigma36 Set35 (\_ -> const36 Unit36) descCases35 DescProd35 = prod36 id36 (prod36 id36 (const36 Unit36)) descCases35 DescSigma35 = sigma36 Set35 (\S -> prod36 (pi36 (Lift35 S) (\_ -> id36)) (const36 Unit36)) descCases35 DescPi35 = sigma36 Set35 (\S -> prod36 (pi36 (Lift35 S) (\_ -> id36)) (const36 Unit36)) DescD35 : Desc36 DescD35 = sigma36 DescDef35 descCases35 Desc35 : Set36 Desc35 = Mu36 DescD35 id35 : Desc35 id35 = con (DescId35 , Void) const35 : Set35 -> Desc35 const35 K = con (DescConst35 , (K , Void)) prod35 : (D D' : Desc35) -> Desc35 prod35 D D' = con (DescProd35 , (D , ( D' , Void ))) sigma35 : (S : Set35)(D : S -> Desc35) -> Desc35 sigma35 S D = con (DescSigma35 , (S , ((\s -> D (unlift35 s)) , Void ))) pi35 : (S : Set35)(D : S -> Desc35) -> Desc35 pi35 S D = con (DescPi35 , (S , ((\s -> D (unlift35 s)) , Void ))) [|_|]35_ : Desc35 -> Set35 -> Set35 [| con (DescId35 , Void) |]35 Z = Z [| con (DescConst35 , ( S , Void)) |]35 Z = S [| con (DescProd35 , (D , ( D' , Void ))) |]35 Z = [| D |]35 Z *35 [| D' |]35 Z [| con (DescSigma35 , (S , (T , Void))) |]35 Z = Sigma35 S (\s -> [| T (lifter s) |]35 Z ) [| con (DescPi35 , (S , (T , Void))) |]35 Z = (s : S) -> [| T (lifter s) |]35 Z data Mu35 (D : Desc35) : Set35 where con : [| D |]35 (Mu35 D) -> Mu35 D data DescDef34 : Set35 where DescId34 : DescDef34 DescConst34 : DescDef34 DescProd34 : DescDef34 DescSigma34 : DescDef34 DescPi34 : DescDef34 data Lift34 (A : Set34) : Set35 where lifter : A -> Lift34 A unlift34 : {A : Set34} -> Lift34 A -> A unlift34 (lifter a) = a descCases34 : DescDef34 -> Desc35 descCases34 DescId34 = const35 Unit35 descCases34 DescConst34 = sigma35 Set34 (\_ -> const35 Unit35) descCases34 DescProd34 = prod35 id35 (prod35 id35 (const35 Unit35)) descCases34 DescSigma34 = sigma35 Set34 (\S -> prod35 (pi35 (Lift34 S) (\_ -> id35)) (const35 Unit35)) descCases34 DescPi34 = sigma35 Set34 (\S -> prod35 (pi35 (Lift34 S) (\_ -> id35)) (const35 Unit35)) DescD34 : Desc35 DescD34 = sigma35 DescDef34 descCases34 Desc34 : Set35 Desc34 = Mu35 DescD34 id34 : Desc34 id34 = con (DescId34 , Void) const34 : Set34 -> Desc34 const34 K = con (DescConst34 , (K , Void)) prod34 : (D D' : Desc34) -> Desc34 prod34 D D' = con (DescProd34 , (D , ( D' , Void ))) sigma34 : (S : Set34)(D : S -> Desc34) -> Desc34 sigma34 S D = con (DescSigma34 , (S , ((\s -> D (unlift34 s)) , Void ))) pi34 : (S : Set34)(D : S -> Desc34) -> Desc34 pi34 S D = con (DescPi34 , (S , ((\s -> D (unlift34 s)) , Void ))) [|_|]34_ : Desc34 -> Set34 -> Set34 [| con (DescId34 , Void) |]34 Z = Z [| con (DescConst34 , ( S , Void)) |]34 Z = S [| con (DescProd34 , (D , ( D' , Void ))) |]34 Z = [| D |]34 Z *34 [| D' |]34 Z [| con (DescSigma34 , (S , (T , Void))) |]34 Z = Sigma34 S (\s -> [| T (lifter s) |]34 Z ) [| con (DescPi34 , (S , (T , Void))) |]34 Z = (s : S) -> [| T (lifter s) |]34 Z data Mu34 (D : Desc34) : Set34 where con : [| D |]34 (Mu34 D) -> Mu34 D data DescDef33 : Set34 where DescId33 : DescDef33 DescConst33 : DescDef33 DescProd33 : DescDef33 DescSigma33 : DescDef33 DescPi33 : DescDef33 data Lift33 (A : Set33) : Set34 where lifter : A -> Lift33 A unlift33 : {A : Set33} -> Lift33 A -> A unlift33 (lifter a) = a descCases33 : DescDef33 -> Desc34 descCases33 DescId33 = const34 Unit34 descCases33 DescConst33 = sigma34 Set33 (\_ -> const34 Unit34) descCases33 DescProd33 = prod34 id34 (prod34 id34 (const34 Unit34)) descCases33 DescSigma33 = sigma34 Set33 (\S -> prod34 (pi34 (Lift33 S) (\_ -> id34)) (const34 Unit34)) descCases33 DescPi33 = sigma34 Set33 (\S -> prod34 (pi34 (Lift33 S) (\_ -> id34)) (const34 Unit34)) DescD33 : Desc34 DescD33 = sigma34 DescDef33 descCases33 Desc33 : Set34 Desc33 = Mu34 DescD33 id33 : Desc33 id33 = con (DescId33 , Void) const33 : Set33 -> Desc33 const33 K = con (DescConst33 , (K , Void)) prod33 : (D D' : Desc33) -> Desc33 prod33 D D' = con (DescProd33 , (D , ( D' , Void ))) sigma33 : (S : Set33)(D : S -> Desc33) -> Desc33 sigma33 S D = con (DescSigma33 , (S , ((\s -> D (unlift33 s)) , Void ))) pi33 : (S : Set33)(D : S -> Desc33) -> Desc33 pi33 S D = con (DescPi33 , (S , ((\s -> D (unlift33 s)) , Void ))) [|_|]33_ : Desc33 -> Set33 -> Set33 [| con (DescId33 , Void) |]33 Z = Z [| con (DescConst33 , ( S , Void)) |]33 Z = S [| con (DescProd33 , (D , ( D' , Void ))) |]33 Z = [| D |]33 Z *33 [| D' |]33 Z [| con (DescSigma33 , (S , (T , Void))) |]33 Z = Sigma33 S (\s -> [| T (lifter s) |]33 Z ) [| con (DescPi33 , (S , (T , Void))) |]33 Z = (s : S) -> [| T (lifter s) |]33 Z data Mu33 (D : Desc33) : Set33 where con : [| D |]33 (Mu33 D) -> Mu33 D data DescDef32 : Set33 where DescId32 : DescDef32 DescConst32 : DescDef32 DescProd32 : DescDef32 DescSigma32 : DescDef32 DescPi32 : DescDef32 data Lift32 (A : Set32) : Set33 where lifter : A -> Lift32 A unlift32 : {A : Set32} -> Lift32 A -> A unlift32 (lifter a) = a descCases32 : DescDef32 -> Desc33 descCases32 DescId32 = const33 Unit33 descCases32 DescConst32 = sigma33 Set32 (\_ -> const33 Unit33) descCases32 DescProd32 = prod33 id33 (prod33 id33 (const33 Unit33)) descCases32 DescSigma32 = sigma33 Set32 (\S -> prod33 (pi33 (Lift32 S) (\_ -> id33)) (const33 Unit33)) descCases32 DescPi32 = sigma33 Set32 (\S -> prod33 (pi33 (Lift32 S) (\_ -> id33)) (const33 Unit33)) DescD32 : Desc33 DescD32 = sigma33 DescDef32 descCases32 Desc32 : Set33 Desc32 = Mu33 DescD32 id32 : Desc32 id32 = con (DescId32 , Void) const32 : Set32 -> Desc32 const32 K = con (DescConst32 , (K , Void)) prod32 : (D D' : Desc32) -> Desc32 prod32 D D' = con (DescProd32 , (D , ( D' , Void ))) sigma32 : (S : Set32)(D : S -> Desc32) -> Desc32 sigma32 S D = con (DescSigma32 , (S , ((\s -> D (unlift32 s)) , Void ))) pi32 : (S : Set32)(D : S -> Desc32) -> Desc32 pi32 S D = con (DescPi32 , (S , ((\s -> D (unlift32 s)) , Void ))) [|_|]32_ : Desc32 -> Set32 -> Set32 [| con (DescId32 , Void) |]32 Z = Z [| con (DescConst32 , ( S , Void)) |]32 Z = S [| con (DescProd32 , (D , ( D' , Void ))) |]32 Z = [| D |]32 Z *32 [| D' |]32 Z [| con (DescSigma32 , (S , (T , Void))) |]32 Z = Sigma32 S (\s -> [| T (lifter s) |]32 Z ) [| con (DescPi32 , (S , (T , Void))) |]32 Z = (s : S) -> [| T (lifter s) |]32 Z data Mu32 (D : Desc32) : Set32 where con : [| D |]32 (Mu32 D) -> Mu32 D data DescDef31 : Set32 where DescId31 : DescDef31 DescConst31 : DescDef31 DescProd31 : DescDef31 DescSigma31 : DescDef31 DescPi31 : DescDef31 data Lift31 (A : Set31) : Set32 where lifter : A -> Lift31 A unlift31 : {A : Set31} -> Lift31 A -> A unlift31 (lifter a) = a descCases31 : DescDef31 -> Desc32 descCases31 DescId31 = const32 Unit32 descCases31 DescConst31 = sigma32 Set31 (\_ -> const32 Unit32) descCases31 DescProd31 = prod32 id32 (prod32 id32 (const32 Unit32)) descCases31 DescSigma31 = sigma32 Set31 (\S -> prod32 (pi32 (Lift31 S) (\_ -> id32)) (const32 Unit32)) descCases31 DescPi31 = sigma32 Set31 (\S -> prod32 (pi32 (Lift31 S) (\_ -> id32)) (const32 Unit32)) DescD31 : Desc32 DescD31 = sigma32 DescDef31 descCases31 Desc31 : Set32 Desc31 = Mu32 DescD31 id31 : Desc31 id31 = con (DescId31 , Void) const31 : Set31 -> Desc31 const31 K = con (DescConst31 , (K , Void)) prod31 : (D D' : Desc31) -> Desc31 prod31 D D' = con (DescProd31 , (D , ( D' , Void ))) sigma31 : (S : Set31)(D : S -> Desc31) -> Desc31 sigma31 S D = con (DescSigma31 , (S , ((\s -> D (unlift31 s)) , Void ))) pi31 : (S : Set31)(D : S -> Desc31) -> Desc31 pi31 S D = con (DescPi31 , (S , ((\s -> D (unlift31 s)) , Void ))) [|_|]31_ : Desc31 -> Set31 -> Set31 [| con (DescId31 , Void) |]31 Z = Z [| con (DescConst31 , ( S , Void)) |]31 Z = S [| con (DescProd31 , (D , ( D' , Void ))) |]31 Z = [| D |]31 Z *31 [| D' |]31 Z [| con (DescSigma31 , (S , (T , Void))) |]31 Z = Sigma31 S (\s -> [| T (lifter s) |]31 Z ) [| con (DescPi31 , (S , (T , Void))) |]31 Z = (s : S) -> [| T (lifter s) |]31 Z data Mu31 (D : Desc31) : Set31 where con : [| D |]31 (Mu31 D) -> Mu31 D data DescDef30 : Set31 where DescId30 : DescDef30 DescConst30 : DescDef30 DescProd30 : DescDef30 DescSigma30 : DescDef30 DescPi30 : DescDef30 data Lift30 (A : Set30) : Set31 where lifter : A -> Lift30 A unlift30 : {A : Set30} -> Lift30 A -> A unlift30 (lifter a) = a descCases30 : DescDef30 -> Desc31 descCases30 DescId30 = const31 Unit31 descCases30 DescConst30 = sigma31 Set30 (\_ -> const31 Unit31) descCases30 DescProd30 = prod31 id31 (prod31 id31 (const31 Unit31)) descCases30 DescSigma30 = sigma31 Set30 (\S -> prod31 (pi31 (Lift30 S) (\_ -> id31)) (const31 Unit31)) descCases30 DescPi30 = sigma31 Set30 (\S -> prod31 (pi31 (Lift30 S) (\_ -> id31)) (const31 Unit31)) DescD30 : Desc31 DescD30 = sigma31 DescDef30 descCases30 Desc30 : Set31 Desc30 = Mu31 DescD30 id30 : Desc30 id30 = con (DescId30 , Void) const30 : Set30 -> Desc30 const30 K = con (DescConst30 , (K , Void)) prod30 : (D D' : Desc30) -> Desc30 prod30 D D' = con (DescProd30 , (D , ( D' , Void ))) sigma30 : (S : Set30)(D : S -> Desc30) -> Desc30 sigma30 S D = con (DescSigma30 , (S , ((\s -> D (unlift30 s)) , Void ))) pi30 : (S : Set30)(D : S -> Desc30) -> Desc30 pi30 S D = con (DescPi30 , (S , ((\s -> D (unlift30 s)) , Void ))) [|_|]30_ : Desc30 -> Set30 -> Set30 [| con (DescId30 , Void) |]30 Z = Z [| con (DescConst30 , ( S , Void)) |]30 Z = S [| con (DescProd30 , (D , ( D' , Void ))) |]30 Z = [| D |]30 Z *30 [| D' |]30 Z [| con (DescSigma30 , (S , (T , Void))) |]30 Z = Sigma30 S (\s -> [| T (lifter s) |]30 Z ) [| con (DescPi30 , (S , (T , Void))) |]30 Z = (s : S) -> [| T (lifter s) |]30 Z data Mu30 (D : Desc30) : Set30 where con : [| D |]30 (Mu30 D) -> Mu30 D data DescDef29 : Set30 where DescId29 : DescDef29 DescConst29 : DescDef29 DescProd29 : DescDef29 DescSigma29 : DescDef29 DescPi29 : DescDef29 data Lift29 (A : Set29) : Set30 where lifter : A -> Lift29 A unlift29 : {A : Set29} -> Lift29 A -> A unlift29 (lifter a) = a descCases29 : DescDef29 -> Desc30 descCases29 DescId29 = const30 Unit30 descCases29 DescConst29 = sigma30 Set29 (\_ -> const30 Unit30) descCases29 DescProd29 = prod30 id30 (prod30 id30 (const30 Unit30)) descCases29 DescSigma29 = sigma30 Set29 (\S -> prod30 (pi30 (Lift29 S) (\_ -> id30)) (const30 Unit30)) descCases29 DescPi29 = sigma30 Set29 (\S -> prod30 (pi30 (Lift29 S) (\_ -> id30)) (const30 Unit30)) DescD29 : Desc30 DescD29 = sigma30 DescDef29 descCases29 Desc29 : Set30 Desc29 = Mu30 DescD29 id29 : Desc29 id29 = con (DescId29 , Void) const29 : Set29 -> Desc29 const29 K = con (DescConst29 , (K , Void)) prod29 : (D D' : Desc29) -> Desc29 prod29 D D' = con (DescProd29 , (D , ( D' , Void ))) sigma29 : (S : Set29)(D : S -> Desc29) -> Desc29 sigma29 S D = con (DescSigma29 , (S , ((\s -> D (unlift29 s)) , Void ))) pi29 : (S : Set29)(D : S -> Desc29) -> Desc29 pi29 S D = con (DescPi29 , (S , ((\s -> D (unlift29 s)) , Void ))) [|_|]29_ : Desc29 -> Set29 -> Set29 [| con (DescId29 , Void) |]29 Z = Z [| con (DescConst29 , ( S , Void)) |]29 Z = S [| con (DescProd29 , (D , ( D' , Void ))) |]29 Z = [| D |]29 Z *29 [| D' |]29 Z [| con (DescSigma29 , (S , (T , Void))) |]29 Z = Sigma29 S (\s -> [| T (lifter s) |]29 Z ) [| con (DescPi29 , (S , (T , Void))) |]29 Z = (s : S) -> [| T (lifter s) |]29 Z data Mu29 (D : Desc29) : Set29 where con : [| D |]29 (Mu29 D) -> Mu29 D data DescDef28 : Set29 where DescId28 : DescDef28 DescConst28 : DescDef28 DescProd28 : DescDef28 DescSigma28 : DescDef28 DescPi28 : DescDef28 data Lift28 (A : Set28) : Set29 where lifter : A -> Lift28 A unlift28 : {A : Set28} -> Lift28 A -> A unlift28 (lifter a) = a descCases28 : DescDef28 -> Desc29 descCases28 DescId28 = const29 Unit29 descCases28 DescConst28 = sigma29 Set28 (\_ -> const29 Unit29) descCases28 DescProd28 = prod29 id29 (prod29 id29 (const29 Unit29)) descCases28 DescSigma28 = sigma29 Set28 (\S -> prod29 (pi29 (Lift28 S) (\_ -> id29)) (const29 Unit29)) descCases28 DescPi28 = sigma29 Set28 (\S -> prod29 (pi29 (Lift28 S) (\_ -> id29)) (const29 Unit29)) DescD28 : Desc29 DescD28 = sigma29 DescDef28 descCases28 Desc28 : Set29 Desc28 = Mu29 DescD28 id28 : Desc28 id28 = con (DescId28 , Void) const28 : Set28 -> Desc28 const28 K = con (DescConst28 , (K , Void)) prod28 : (D D' : Desc28) -> Desc28 prod28 D D' = con (DescProd28 , (D , ( D' , Void ))) sigma28 : (S : Set28)(D : S -> Desc28) -> Desc28 sigma28 S D = con (DescSigma28 , (S , ((\s -> D (unlift28 s)) , Void ))) pi28 : (S : Set28)(D : S -> Desc28) -> Desc28 pi28 S D = con (DescPi28 , (S , ((\s -> D (unlift28 s)) , Void ))) [|_|]28_ : Desc28 -> Set28 -> Set28 [| con (DescId28 , Void) |]28 Z = Z [| con (DescConst28 , ( S , Void)) |]28 Z = S [| con (DescProd28 , (D , ( D' , Void ))) |]28 Z = [| D |]28 Z *28 [| D' |]28 Z [| con (DescSigma28 , (S , (T , Void))) |]28 Z = Sigma28 S (\s -> [| T (lifter s) |]28 Z ) [| con (DescPi28 , (S , (T , Void))) |]28 Z = (s : S) -> [| T (lifter s) |]28 Z data Mu28 (D : Desc28) : Set28 where con : [| D |]28 (Mu28 D) -> Mu28 D data DescDef27 : Set28 where DescId27 : DescDef27 DescConst27 : DescDef27 DescProd27 : DescDef27 DescSigma27 : DescDef27 DescPi27 : DescDef27 data Lift27 (A : Set27) : Set28 where lifter : A -> Lift27 A unlift27 : {A : Set27} -> Lift27 A -> A unlift27 (lifter a) = a descCases27 : DescDef27 -> Desc28 descCases27 DescId27 = const28 Unit28 descCases27 DescConst27 = sigma28 Set27 (\_ -> const28 Unit28) descCases27 DescProd27 = prod28 id28 (prod28 id28 (const28 Unit28)) descCases27 DescSigma27 = sigma28 Set27 (\S -> prod28 (pi28 (Lift27 S) (\_ -> id28)) (const28 Unit28)) descCases27 DescPi27 = sigma28 Set27 (\S -> prod28 (pi28 (Lift27 S) (\_ -> id28)) (const28 Unit28)) DescD27 : Desc28 DescD27 = sigma28 DescDef27 descCases27 Desc27 : Set28 Desc27 = Mu28 DescD27 id27 : Desc27 id27 = con (DescId27 , Void) const27 : Set27 -> Desc27 const27 K = con (DescConst27 , (K , Void)) prod27 : (D D' : Desc27) -> Desc27 prod27 D D' = con (DescProd27 , (D , ( D' , Void ))) sigma27 : (S : Set27)(D : S -> Desc27) -> Desc27 sigma27 S D = con (DescSigma27 , (S , ((\s -> D (unlift27 s)) , Void ))) pi27 : (S : Set27)(D : S -> Desc27) -> Desc27 pi27 S D = con (DescPi27 , (S , ((\s -> D (unlift27 s)) , Void ))) [|_|]27_ : Desc27 -> Set27 -> Set27 [| con (DescId27 , Void) |]27 Z = Z [| con (DescConst27 , ( S , Void)) |]27 Z = S [| con (DescProd27 , (D , ( D' , Void ))) |]27 Z = [| D |]27 Z *27 [| D' |]27 Z [| con (DescSigma27 , (S , (T , Void))) |]27 Z = Sigma27 S (\s -> [| T (lifter s) |]27 Z ) [| con (DescPi27 , (S , (T , Void))) |]27 Z = (s : S) -> [| T (lifter s) |]27 Z data Mu27 (D : Desc27) : Set27 where con : [| D |]27 (Mu27 D) -> Mu27 D data DescDef26 : Set27 where DescId26 : DescDef26 DescConst26 : DescDef26 DescProd26 : DescDef26 DescSigma26 : DescDef26 DescPi26 : DescDef26 data Lift26 (A : Set26) : Set27 where lifter : A -> Lift26 A unlift26 : {A : Set26} -> Lift26 A -> A unlift26 (lifter a) = a descCases26 : DescDef26 -> Desc27 descCases26 DescId26 = const27 Unit27 descCases26 DescConst26 = sigma27 Set26 (\_ -> const27 Unit27) descCases26 DescProd26 = prod27 id27 (prod27 id27 (const27 Unit27)) descCases26 DescSigma26 = sigma27 Set26 (\S -> prod27 (pi27 (Lift26 S) (\_ -> id27)) (const27 Unit27)) descCases26 DescPi26 = sigma27 Set26 (\S -> prod27 (pi27 (Lift26 S) (\_ -> id27)) (const27 Unit27)) DescD26 : Desc27 DescD26 = sigma27 DescDef26 descCases26 Desc26 : Set27 Desc26 = Mu27 DescD26 id26 : Desc26 id26 = con (DescId26 , Void) const26 : Set26 -> Desc26 const26 K = con (DescConst26 , (K , Void)) prod26 : (D D' : Desc26) -> Desc26 prod26 D D' = con (DescProd26 , (D , ( D' , Void ))) sigma26 : (S : Set26)(D : S -> Desc26) -> Desc26 sigma26 S D = con (DescSigma26 , (S , ((\s -> D (unlift26 s)) , Void ))) pi26 : (S : Set26)(D : S -> Desc26) -> Desc26 pi26 S D = con (DescPi26 , (S , ((\s -> D (unlift26 s)) , Void ))) [|_|]26_ : Desc26 -> Set26 -> Set26 [| con (DescId26 , Void) |]26 Z = Z [| con (DescConst26 , ( S , Void)) |]26 Z = S [| con (DescProd26 , (D , ( D' , Void ))) |]26 Z = [| D |]26 Z *26 [| D' |]26 Z [| con (DescSigma26 , (S , (T , Void))) |]26 Z = Sigma26 S (\s -> [| T (lifter s) |]26 Z ) [| con (DescPi26 , (S , (T , Void))) |]26 Z = (s : S) -> [| T (lifter s) |]26 Z data Mu26 (D : Desc26) : Set26 where con : [| D |]26 (Mu26 D) -> Mu26 D data DescDef25 : Set26 where DescId25 : DescDef25 DescConst25 : DescDef25 DescProd25 : DescDef25 DescSigma25 : DescDef25 DescPi25 : DescDef25 data Lift25 (A : Set25) : Set26 where lifter : A -> Lift25 A unlift25 : {A : Set25} -> Lift25 A -> A unlift25 (lifter a) = a descCases25 : DescDef25 -> Desc26 descCases25 DescId25 = const26 Unit26 descCases25 DescConst25 = sigma26 Set25 (\_ -> const26 Unit26) descCases25 DescProd25 = prod26 id26 (prod26 id26 (const26 Unit26)) descCases25 DescSigma25 = sigma26 Set25 (\S -> prod26 (pi26 (Lift25 S) (\_ -> id26)) (const26 Unit26)) descCases25 DescPi25 = sigma26 Set25 (\S -> prod26 (pi26 (Lift25 S) (\_ -> id26)) (const26 Unit26)) DescD25 : Desc26 DescD25 = sigma26 DescDef25 descCases25 Desc25 : Set26 Desc25 = Mu26 DescD25 id25 : Desc25 id25 = con (DescId25 , Void) const25 : Set25 -> Desc25 const25 K = con (DescConst25 , (K , Void)) prod25 : (D D' : Desc25) -> Desc25 prod25 D D' = con (DescProd25 , (D , ( D' , Void ))) sigma25 : (S : Set25)(D : S -> Desc25) -> Desc25 sigma25 S D = con (DescSigma25 , (S , ((\s -> D (unlift25 s)) , Void ))) pi25 : (S : Set25)(D : S -> Desc25) -> Desc25 pi25 S D = con (DescPi25 , (S , ((\s -> D (unlift25 s)) , Void ))) [|_|]25_ : Desc25 -> Set25 -> Set25 [| con (DescId25 , Void) |]25 Z = Z [| con (DescConst25 , ( S , Void)) |]25 Z = S [| con (DescProd25 , (D , ( D' , Void ))) |]25 Z = [| D |]25 Z *25 [| D' |]25 Z [| con (DescSigma25 , (S , (T , Void))) |]25 Z = Sigma25 S (\s -> [| T (lifter s) |]25 Z ) [| con (DescPi25 , (S , (T , Void))) |]25 Z = (s : S) -> [| T (lifter s) |]25 Z data Mu25 (D : Desc25) : Set25 where con : [| D |]25 (Mu25 D) -> Mu25 D data DescDef24 : Set25 where DescId24 : DescDef24 DescConst24 : DescDef24 DescProd24 : DescDef24 DescSigma24 : DescDef24 DescPi24 : DescDef24 data Lift24 (A : Set24) : Set25 where lifter : A -> Lift24 A unlift24 : {A : Set24} -> Lift24 A -> A unlift24 (lifter a) = a descCases24 : DescDef24 -> Desc25 descCases24 DescId24 = const25 Unit25 descCases24 DescConst24 = sigma25 Set24 (\_ -> const25 Unit25) descCases24 DescProd24 = prod25 id25 (prod25 id25 (const25 Unit25)) descCases24 DescSigma24 = sigma25 Set24 (\S -> prod25 (pi25 (Lift24 S) (\_ -> id25)) (const25 Unit25)) descCases24 DescPi24 = sigma25 Set24 (\S -> prod25 (pi25 (Lift24 S) (\_ -> id25)) (const25 Unit25)) DescD24 : Desc25 DescD24 = sigma25 DescDef24 descCases24 Desc24 : Set25 Desc24 = Mu25 DescD24 id24 : Desc24 id24 = con (DescId24 , Void) const24 : Set24 -> Desc24 const24 K = con (DescConst24 , (K , Void)) prod24 : (D D' : Desc24) -> Desc24 prod24 D D' = con (DescProd24 , (D , ( D' , Void ))) sigma24 : (S : Set24)(D : S -> Desc24) -> Desc24 sigma24 S D = con (DescSigma24 , (S , ((\s -> D (unlift24 s)) , Void ))) pi24 : (S : Set24)(D : S -> Desc24) -> Desc24 pi24 S D = con (DescPi24 , (S , ((\s -> D (unlift24 s)) , Void ))) [|_|]24_ : Desc24 -> Set24 -> Set24 [| con (DescId24 , Void) |]24 Z = Z [| con (DescConst24 , ( S , Void)) |]24 Z = S [| con (DescProd24 , (D , ( D' , Void ))) |]24 Z = [| D |]24 Z *24 [| D' |]24 Z [| con (DescSigma24 , (S , (T , Void))) |]24 Z = Sigma24 S (\s -> [| T (lifter s) |]24 Z ) [| con (DescPi24 , (S , (T , Void))) |]24 Z = (s : S) -> [| T (lifter s) |]24 Z data Mu24 (D : Desc24) : Set24 where con : [| D |]24 (Mu24 D) -> Mu24 D data DescDef23 : Set24 where DescId23 : DescDef23 DescConst23 : DescDef23 DescProd23 : DescDef23 DescSigma23 : DescDef23 DescPi23 : DescDef23 data Lift23 (A : Set23) : Set24 where lifter : A -> Lift23 A unlift23 : {A : Set23} -> Lift23 A -> A unlift23 (lifter a) = a descCases23 : DescDef23 -> Desc24 descCases23 DescId23 = const24 Unit24 descCases23 DescConst23 = sigma24 Set23 (\_ -> const24 Unit24) descCases23 DescProd23 = prod24 id24 (prod24 id24 (const24 Unit24)) descCases23 DescSigma23 = sigma24 Set23 (\S -> prod24 (pi24 (Lift23 S) (\_ -> id24)) (const24 Unit24)) descCases23 DescPi23 = sigma24 Set23 (\S -> prod24 (pi24 (Lift23 S) (\_ -> id24)) (const24 Unit24)) DescD23 : Desc24 DescD23 = sigma24 DescDef23 descCases23 Desc23 : Set24 Desc23 = Mu24 DescD23 id23 : Desc23 id23 = con (DescId23 , Void) const23 : Set23 -> Desc23 const23 K = con (DescConst23 , (K , Void)) prod23 : (D D' : Desc23) -> Desc23 prod23 D D' = con (DescProd23 , (D , ( D' , Void ))) sigma23 : (S : Set23)(D : S -> Desc23) -> Desc23 sigma23 S D = con (DescSigma23 , (S , ((\s -> D (unlift23 s)) , Void ))) pi23 : (S : Set23)(D : S -> Desc23) -> Desc23 pi23 S D = con (DescPi23 , (S , ((\s -> D (unlift23 s)) , Void ))) [|_|]23_ : Desc23 -> Set23 -> Set23 [| con (DescId23 , Void) |]23 Z = Z [| con (DescConst23 , ( S , Void)) |]23 Z = S [| con (DescProd23 , (D , ( D' , Void ))) |]23 Z = [| D |]23 Z *23 [| D' |]23 Z [| con (DescSigma23 , (S , (T , Void))) |]23 Z = Sigma23 S (\s -> [| T (lifter s) |]23 Z ) [| con (DescPi23 , (S , (T , Void))) |]23 Z = (s : S) -> [| T (lifter s) |]23 Z data Mu23 (D : Desc23) : Set23 where con : [| D |]23 (Mu23 D) -> Mu23 D data DescDef22 : Set23 where DescId22 : DescDef22 DescConst22 : DescDef22 DescProd22 : DescDef22 DescSigma22 : DescDef22 DescPi22 : DescDef22 data Lift22 (A : Set22) : Set23 where lifter : A -> Lift22 A unlift22 : {A : Set22} -> Lift22 A -> A unlift22 (lifter a) = a descCases22 : DescDef22 -> Desc23 descCases22 DescId22 = const23 Unit23 descCases22 DescConst22 = sigma23 Set22 (\_ -> const23 Unit23) descCases22 DescProd22 = prod23 id23 (prod23 id23 (const23 Unit23)) descCases22 DescSigma22 = sigma23 Set22 (\S -> prod23 (pi23 (Lift22 S) (\_ -> id23)) (const23 Unit23)) descCases22 DescPi22 = sigma23 Set22 (\S -> prod23 (pi23 (Lift22 S) (\_ -> id23)) (const23 Unit23)) DescD22 : Desc23 DescD22 = sigma23 DescDef22 descCases22 Desc22 : Set23 Desc22 = Mu23 DescD22 id22 : Desc22 id22 = con (DescId22 , Void) const22 : Set22 -> Desc22 const22 K = con (DescConst22 , (K , Void)) prod22 : (D D' : Desc22) -> Desc22 prod22 D D' = con (DescProd22 , (D , ( D' , Void ))) sigma22 : (S : Set22)(D : S -> Desc22) -> Desc22 sigma22 S D = con (DescSigma22 , (S , ((\s -> D (unlift22 s)) , Void ))) pi22 : (S : Set22)(D : S -> Desc22) -> Desc22 pi22 S D = con (DescPi22 , (S , ((\s -> D (unlift22 s)) , Void ))) [|_|]22_ : Desc22 -> Set22 -> Set22 [| con (DescId22 , Void) |]22 Z = Z [| con (DescConst22 , ( S , Void)) |]22 Z = S [| con (DescProd22 , (D , ( D' , Void ))) |]22 Z = [| D |]22 Z *22 [| D' |]22 Z [| con (DescSigma22 , (S , (T , Void))) |]22 Z = Sigma22 S (\s -> [| T (lifter s) |]22 Z ) [| con (DescPi22 , (S , (T , Void))) |]22 Z = (s : S) -> [| T (lifter s) |]22 Z data Mu22 (D : Desc22) : Set22 where con : [| D |]22 (Mu22 D) -> Mu22 D data DescDef21 : Set22 where DescId21 : DescDef21 DescConst21 : DescDef21 DescProd21 : DescDef21 DescSigma21 : DescDef21 DescPi21 : DescDef21 data Lift21 (A : Set21) : Set22 where lifter : A -> Lift21 A unlift21 : {A : Set21} -> Lift21 A -> A unlift21 (lifter a) = a descCases21 : DescDef21 -> Desc22 descCases21 DescId21 = const22 Unit22 descCases21 DescConst21 = sigma22 Set21 (\_ -> const22 Unit22) descCases21 DescProd21 = prod22 id22 (prod22 id22 (const22 Unit22)) descCases21 DescSigma21 = sigma22 Set21 (\S -> prod22 (pi22 (Lift21 S) (\_ -> id22)) (const22 Unit22)) descCases21 DescPi21 = sigma22 Set21 (\S -> prod22 (pi22 (Lift21 S) (\_ -> id22)) (const22 Unit22)) DescD21 : Desc22 DescD21 = sigma22 DescDef21 descCases21 Desc21 : Set22 Desc21 = Mu22 DescD21 id21 : Desc21 id21 = con (DescId21 , Void) const21 : Set21 -> Desc21 const21 K = con (DescConst21 , (K , Void)) prod21 : (D D' : Desc21) -> Desc21 prod21 D D' = con (DescProd21 , (D , ( D' , Void ))) sigma21 : (S : Set21)(D : S -> Desc21) -> Desc21 sigma21 S D = con (DescSigma21 , (S , ((\s -> D (unlift21 s)) , Void ))) pi21 : (S : Set21)(D : S -> Desc21) -> Desc21 pi21 S D = con (DescPi21 , (S , ((\s -> D (unlift21 s)) , Void ))) [|_|]21_ : Desc21 -> Set21 -> Set21 [| con (DescId21 , Void) |]21 Z = Z [| con (DescConst21 , ( S , Void)) |]21 Z = S [| con (DescProd21 , (D , ( D' , Void ))) |]21 Z = [| D |]21 Z *21 [| D' |]21 Z [| con (DescSigma21 , (S , (T , Void))) |]21 Z = Sigma21 S (\s -> [| T (lifter s) |]21 Z ) [| con (DescPi21 , (S , (T , Void))) |]21 Z = (s : S) -> [| T (lifter s) |]21 Z data Mu21 (D : Desc21) : Set21 where con : [| D |]21 (Mu21 D) -> Mu21 D data DescDef20 : Set21 where DescId20 : DescDef20 DescConst20 : DescDef20 DescProd20 : DescDef20 DescSigma20 : DescDef20 DescPi20 : DescDef20 data Lift20 (A : Set20) : Set21 where lifter : A -> Lift20 A unlift20 : {A : Set20} -> Lift20 A -> A unlift20 (lifter a) = a descCases20 : DescDef20 -> Desc21 descCases20 DescId20 = const21 Unit21 descCases20 DescConst20 = sigma21 Set20 (\_ -> const21 Unit21) descCases20 DescProd20 = prod21 id21 (prod21 id21 (const21 Unit21)) descCases20 DescSigma20 = sigma21 Set20 (\S -> prod21 (pi21 (Lift20 S) (\_ -> id21)) (const21 Unit21)) descCases20 DescPi20 = sigma21 Set20 (\S -> prod21 (pi21 (Lift20 S) (\_ -> id21)) (const21 Unit21)) DescD20 : Desc21 DescD20 = sigma21 DescDef20 descCases20 Desc20 : Set21 Desc20 = Mu21 DescD20 id20 : Desc20 id20 = con (DescId20 , Void) const20 : Set20 -> Desc20 const20 K = con (DescConst20 , (K , Void)) prod20 : (D D' : Desc20) -> Desc20 prod20 D D' = con (DescProd20 , (D , ( D' , Void ))) sigma20 : (S : Set20)(D : S -> Desc20) -> Desc20 sigma20 S D = con (DescSigma20 , (S , ((\s -> D (unlift20 s)) , Void ))) pi20 : (S : Set20)(D : S -> Desc20) -> Desc20 pi20 S D = con (DescPi20 , (S , ((\s -> D (unlift20 s)) , Void ))) [|_|]20_ : Desc20 -> Set20 -> Set20 [| con (DescId20 , Void) |]20 Z = Z [| con (DescConst20 , ( S , Void)) |]20 Z = S [| con (DescProd20 , (D , ( D' , Void ))) |]20 Z = [| D |]20 Z *20 [| D' |]20 Z [| con (DescSigma20 , (S , (T , Void))) |]20 Z = Sigma20 S (\s -> [| T (lifter s) |]20 Z ) [| con (DescPi20 , (S , (T , Void))) |]20 Z = (s : S) -> [| T (lifter s) |]20 Z data Mu20 (D : Desc20) : Set20 where con : [| D |]20 (Mu20 D) -> Mu20 D data DescDef19 : Set20 where DescId19 : DescDef19 DescConst19 : DescDef19 DescProd19 : DescDef19 DescSigma19 : DescDef19 DescPi19 : DescDef19 data Lift19 (A : Set19) : Set20 where lifter : A -> Lift19 A unlift19 : {A : Set19} -> Lift19 A -> A unlift19 (lifter a) = a descCases19 : DescDef19 -> Desc20 descCases19 DescId19 = const20 Unit20 descCases19 DescConst19 = sigma20 Set19 (\_ -> const20 Unit20) descCases19 DescProd19 = prod20 id20 (prod20 id20 (const20 Unit20)) descCases19 DescSigma19 = sigma20 Set19 (\S -> prod20 (pi20 (Lift19 S) (\_ -> id20)) (const20 Unit20)) descCases19 DescPi19 = sigma20 Set19 (\S -> prod20 (pi20 (Lift19 S) (\_ -> id20)) (const20 Unit20)) DescD19 : Desc20 DescD19 = sigma20 DescDef19 descCases19 Desc19 : Set20 Desc19 = Mu20 DescD19 id19 : Desc19 id19 = con (DescId19 , Void) const19 : Set19 -> Desc19 const19 K = con (DescConst19 , (K , Void)) prod19 : (D D' : Desc19) -> Desc19 prod19 D D' = con (DescProd19 , (D , ( D' , Void ))) sigma19 : (S : Set19)(D : S -> Desc19) -> Desc19 sigma19 S D = con (DescSigma19 , (S , ((\s -> D (unlift19 s)) , Void ))) pi19 : (S : Set19)(D : S -> Desc19) -> Desc19 pi19 S D = con (DescPi19 , (S , ((\s -> D (unlift19 s)) , Void ))) [|_|]19_ : Desc19 -> Set19 -> Set19 [| con (DescId19 , Void) |]19 Z = Z [| con (DescConst19 , ( S , Void)) |]19 Z = S [| con (DescProd19 , (D , ( D' , Void ))) |]19 Z = [| D |]19 Z *19 [| D' |]19 Z [| con (DescSigma19 , (S , (T , Void))) |]19 Z = Sigma19 S (\s -> [| T (lifter s) |]19 Z ) [| con (DescPi19 , (S , (T , Void))) |]19 Z = (s : S) -> [| T (lifter s) |]19 Z data Mu19 (D : Desc19) : Set19 where con : [| D |]19 (Mu19 D) -> Mu19 D data DescDef18 : Set19 where DescId18 : DescDef18 DescConst18 : DescDef18 DescProd18 : DescDef18 DescSigma18 : DescDef18 DescPi18 : DescDef18 data Lift18 (A : Set18) : Set19 where lifter : A -> Lift18 A unlift18 : {A : Set18} -> Lift18 A -> A unlift18 (lifter a) = a descCases18 : DescDef18 -> Desc19 descCases18 DescId18 = const19 Unit19 descCases18 DescConst18 = sigma19 Set18 (\_ -> const19 Unit19) descCases18 DescProd18 = prod19 id19 (prod19 id19 (const19 Unit19)) descCases18 DescSigma18 = sigma19 Set18 (\S -> prod19 (pi19 (Lift18 S) (\_ -> id19)) (const19 Unit19)) descCases18 DescPi18 = sigma19 Set18 (\S -> prod19 (pi19 (Lift18 S) (\_ -> id19)) (const19 Unit19)) DescD18 : Desc19 DescD18 = sigma19 DescDef18 descCases18 Desc18 : Set19 Desc18 = Mu19 DescD18 id18 : Desc18 id18 = con (DescId18 , Void) const18 : Set18 -> Desc18 const18 K = con (DescConst18 , (K , Void)) prod18 : (D D' : Desc18) -> Desc18 prod18 D D' = con (DescProd18 , (D , ( D' , Void ))) sigma18 : (S : Set18)(D : S -> Desc18) -> Desc18 sigma18 S D = con (DescSigma18 , (S , ((\s -> D (unlift18 s)) , Void ))) pi18 : (S : Set18)(D : S -> Desc18) -> Desc18 pi18 S D = con (DescPi18 , (S , ((\s -> D (unlift18 s)) , Void ))) [|_|]18_ : Desc18 -> Set18 -> Set18 [| con (DescId18 , Void) |]18 Z = Z [| con (DescConst18 , ( S , Void)) |]18 Z = S [| con (DescProd18 , (D , ( D' , Void ))) |]18 Z = [| D |]18 Z *18 [| D' |]18 Z [| con (DescSigma18 , (S , (T , Void))) |]18 Z = Sigma18 S (\s -> [| T (lifter s) |]18 Z ) [| con (DescPi18 , (S , (T , Void))) |]18 Z = (s : S) -> [| T (lifter s) |]18 Z data Mu18 (D : Desc18) : Set18 where con : [| D |]18 (Mu18 D) -> Mu18 D data DescDef17 : Set18 where DescId17 : DescDef17 DescConst17 : DescDef17 DescProd17 : DescDef17 DescSigma17 : DescDef17 DescPi17 : DescDef17 data Lift17 (A : Set17) : Set18 where lifter : A -> Lift17 A unlift17 : {A : Set17} -> Lift17 A -> A unlift17 (lifter a) = a descCases17 : DescDef17 -> Desc18 descCases17 DescId17 = const18 Unit18 descCases17 DescConst17 = sigma18 Set17 (\_ -> const18 Unit18) descCases17 DescProd17 = prod18 id18 (prod18 id18 (const18 Unit18)) descCases17 DescSigma17 = sigma18 Set17 (\S -> prod18 (pi18 (Lift17 S) (\_ -> id18)) (const18 Unit18)) descCases17 DescPi17 = sigma18 Set17 (\S -> prod18 (pi18 (Lift17 S) (\_ -> id18)) (const18 Unit18)) DescD17 : Desc18 DescD17 = sigma18 DescDef17 descCases17 Desc17 : Set18 Desc17 = Mu18 DescD17 id17 : Desc17 id17 = con (DescId17 , Void) const17 : Set17 -> Desc17 const17 K = con (DescConst17 , (K , Void)) prod17 : (D D' : Desc17) -> Desc17 prod17 D D' = con (DescProd17 , (D , ( D' , Void ))) sigma17 : (S : Set17)(D : S -> Desc17) -> Desc17 sigma17 S D = con (DescSigma17 , (S , ((\s -> D (unlift17 s)) , Void ))) pi17 : (S : Set17)(D : S -> Desc17) -> Desc17 pi17 S D = con (DescPi17 , (S , ((\s -> D (unlift17 s)) , Void ))) [|_|]17_ : Desc17 -> Set17 -> Set17 [| con (DescId17 , Void) |]17 Z = Z [| con (DescConst17 , ( S , Void)) |]17 Z = S [| con (DescProd17 , (D , ( D' , Void ))) |]17 Z = [| D |]17 Z *17 [| D' |]17 Z [| con (DescSigma17 , (S , (T , Void))) |]17 Z = Sigma17 S (\s -> [| T (lifter s) |]17 Z ) [| con (DescPi17 , (S , (T , Void))) |]17 Z = (s : S) -> [| T (lifter s) |]17 Z data Mu17 (D : Desc17) : Set17 where con : [| D |]17 (Mu17 D) -> Mu17 D data DescDef16 : Set17 where DescId16 : DescDef16 DescConst16 : DescDef16 DescProd16 : DescDef16 DescSigma16 : DescDef16 DescPi16 : DescDef16 data Lift16 (A : Set16) : Set17 where lifter : A -> Lift16 A unlift16 : {A : Set16} -> Lift16 A -> A unlift16 (lifter a) = a descCases16 : DescDef16 -> Desc17 descCases16 DescId16 = const17 Unit17 descCases16 DescConst16 = sigma17 Set16 (\_ -> const17 Unit17) descCases16 DescProd16 = prod17 id17 (prod17 id17 (const17 Unit17)) descCases16 DescSigma16 = sigma17 Set16 (\S -> prod17 (pi17 (Lift16 S) (\_ -> id17)) (const17 Unit17)) descCases16 DescPi16 = sigma17 Set16 (\S -> prod17 (pi17 (Lift16 S) (\_ -> id17)) (const17 Unit17)) DescD16 : Desc17 DescD16 = sigma17 DescDef16 descCases16 Desc16 : Set17 Desc16 = Mu17 DescD16 id16 : Desc16 id16 = con (DescId16 , Void) const16 : Set16 -> Desc16 const16 K = con (DescConst16 , (K , Void)) prod16 : (D D' : Desc16) -> Desc16 prod16 D D' = con (DescProd16 , (D , ( D' , Void ))) sigma16 : (S : Set16)(D : S -> Desc16) -> Desc16 sigma16 S D = con (DescSigma16 , (S , ((\s -> D (unlift16 s)) , Void ))) pi16 : (S : Set16)(D : S -> Desc16) -> Desc16 pi16 S D = con (DescPi16 , (S , ((\s -> D (unlift16 s)) , Void ))) [|_|]16_ : Desc16 -> Set16 -> Set16 [| con (DescId16 , Void) |]16 Z = Z [| con (DescConst16 , ( S , Void)) |]16 Z = S [| con (DescProd16 , (D , ( D' , Void ))) |]16 Z = [| D |]16 Z *16 [| D' |]16 Z [| con (DescSigma16 , (S , (T , Void))) |]16 Z = Sigma16 S (\s -> [| T (lifter s) |]16 Z ) [| con (DescPi16 , (S , (T , Void))) |]16 Z = (s : S) -> [| T (lifter s) |]16 Z data Mu16 (D : Desc16) : Set16 where con : [| D |]16 (Mu16 D) -> Mu16 D data DescDef15 : Set16 where DescId15 : DescDef15 DescConst15 : DescDef15 DescProd15 : DescDef15 DescSigma15 : DescDef15 DescPi15 : DescDef15 data Lift15 (A : Set15) : Set16 where lifter : A -> Lift15 A unlift15 : {A : Set15} -> Lift15 A -> A unlift15 (lifter a) = a descCases15 : DescDef15 -> Desc16 descCases15 DescId15 = const16 Unit16 descCases15 DescConst15 = sigma16 Set15 (\_ -> const16 Unit16) descCases15 DescProd15 = prod16 id16 (prod16 id16 (const16 Unit16)) descCases15 DescSigma15 = sigma16 Set15 (\S -> prod16 (pi16 (Lift15 S) (\_ -> id16)) (const16 Unit16)) descCases15 DescPi15 = sigma16 Set15 (\S -> prod16 (pi16 (Lift15 S) (\_ -> id16)) (const16 Unit16)) DescD15 : Desc16 DescD15 = sigma16 DescDef15 descCases15 Desc15 : Set16 Desc15 = Mu16 DescD15 id15 : Desc15 id15 = con (DescId15 , Void) const15 : Set15 -> Desc15 const15 K = con (DescConst15 , (K , Void)) prod15 : (D D' : Desc15) -> Desc15 prod15 D D' = con (DescProd15 , (D , ( D' , Void ))) sigma15 : (S : Set15)(D : S -> Desc15) -> Desc15 sigma15 S D = con (DescSigma15 , (S , ((\s -> D (unlift15 s)) , Void ))) pi15 : (S : Set15)(D : S -> Desc15) -> Desc15 pi15 S D = con (DescPi15 , (S , ((\s -> D (unlift15 s)) , Void ))) [|_|]15_ : Desc15 -> Set15 -> Set15 [| con (DescId15 , Void) |]15 Z = Z [| con (DescConst15 , ( S , Void)) |]15 Z = S [| con (DescProd15 , (D , ( D' , Void ))) |]15 Z = [| D |]15 Z *15 [| D' |]15 Z [| con (DescSigma15 , (S , (T , Void))) |]15 Z = Sigma15 S (\s -> [| T (lifter s) |]15 Z ) [| con (DescPi15 , (S , (T , Void))) |]15 Z = (s : S) -> [| T (lifter s) |]15 Z data Mu15 (D : Desc15) : Set15 where con : [| D |]15 (Mu15 D) -> Mu15 D data DescDef14 : Set15 where DescId14 : DescDef14 DescConst14 : DescDef14 DescProd14 : DescDef14 DescSigma14 : DescDef14 DescPi14 : DescDef14 data Lift14 (A : Set14) : Set15 where lifter : A -> Lift14 A unlift14 : {A : Set14} -> Lift14 A -> A unlift14 (lifter a) = a descCases14 : DescDef14 -> Desc15 descCases14 DescId14 = const15 Unit15 descCases14 DescConst14 = sigma15 Set14 (\_ -> const15 Unit15) descCases14 DescProd14 = prod15 id15 (prod15 id15 (const15 Unit15)) descCases14 DescSigma14 = sigma15 Set14 (\S -> prod15 (pi15 (Lift14 S) (\_ -> id15)) (const15 Unit15)) descCases14 DescPi14 = sigma15 Set14 (\S -> prod15 (pi15 (Lift14 S) (\_ -> id15)) (const15 Unit15)) DescD14 : Desc15 DescD14 = sigma15 DescDef14 descCases14 Desc14 : Set15 Desc14 = Mu15 DescD14 id14 : Desc14 id14 = con (DescId14 , Void) const14 : Set14 -> Desc14 const14 K = con (DescConst14 , (K , Void)) prod14 : (D D' : Desc14) -> Desc14 prod14 D D' = con (DescProd14 , (D , ( D' , Void ))) sigma14 : (S : Set14)(D : S -> Desc14) -> Desc14 sigma14 S D = con (DescSigma14 , (S , ((\s -> D (unlift14 s)) , Void ))) pi14 : (S : Set14)(D : S -> Desc14) -> Desc14 pi14 S D = con (DescPi14 , (S , ((\s -> D (unlift14 s)) , Void ))) [|_|]14_ : Desc14 -> Set14 -> Set14 [| con (DescId14 , Void) |]14 Z = Z [| con (DescConst14 , ( S , Void)) |]14 Z = S [| con (DescProd14 , (D , ( D' , Void ))) |]14 Z = [| D |]14 Z *14 [| D' |]14 Z [| con (DescSigma14 , (S , (T , Void))) |]14 Z = Sigma14 S (\s -> [| T (lifter s) |]14 Z ) [| con (DescPi14 , (S , (T , Void))) |]14 Z = (s : S) -> [| T (lifter s) |]14 Z data Mu14 (D : Desc14) : Set14 where con : [| D |]14 (Mu14 D) -> Mu14 D data DescDef13 : Set14 where DescId13 : DescDef13 DescConst13 : DescDef13 DescProd13 : DescDef13 DescSigma13 : DescDef13 DescPi13 : DescDef13 data Lift13 (A : Set13) : Set14 where lifter : A -> Lift13 A unlift13 : {A : Set13} -> Lift13 A -> A unlift13 (lifter a) = a descCases13 : DescDef13 -> Desc14 descCases13 DescId13 = const14 Unit14 descCases13 DescConst13 = sigma14 Set13 (\_ -> const14 Unit14) descCases13 DescProd13 = prod14 id14 (prod14 id14 (const14 Unit14)) descCases13 DescSigma13 = sigma14 Set13 (\S -> prod14 (pi14 (Lift13 S) (\_ -> id14)) (const14 Unit14)) descCases13 DescPi13 = sigma14 Set13 (\S -> prod14 (pi14 (Lift13 S) (\_ -> id14)) (const14 Unit14)) DescD13 : Desc14 DescD13 = sigma14 DescDef13 descCases13 Desc13 : Set14 Desc13 = Mu14 DescD13 id13 : Desc13 id13 = con (DescId13 , Void) const13 : Set13 -> Desc13 const13 K = con (DescConst13 , (K , Void)) prod13 : (D D' : Desc13) -> Desc13 prod13 D D' = con (DescProd13 , (D , ( D' , Void ))) sigma13 : (S : Set13)(D : S -> Desc13) -> Desc13 sigma13 S D = con (DescSigma13 , (S , ((\s -> D (unlift13 s)) , Void ))) pi13 : (S : Set13)(D : S -> Desc13) -> Desc13 pi13 S D = con (DescPi13 , (S , ((\s -> D (unlift13 s)) , Void ))) [|_|]13_ : Desc13 -> Set13 -> Set13 [| con (DescId13 , Void) |]13 Z = Z [| con (DescConst13 , ( S , Void)) |]13 Z = S [| con (DescProd13 , (D , ( D' , Void ))) |]13 Z = [| D |]13 Z *13 [| D' |]13 Z [| con (DescSigma13 , (S , (T , Void))) |]13 Z = Sigma13 S (\s -> [| T (lifter s) |]13 Z ) [| con (DescPi13 , (S , (T , Void))) |]13 Z = (s : S) -> [| T (lifter s) |]13 Z data Mu13 (D : Desc13) : Set13 where con : [| D |]13 (Mu13 D) -> Mu13 D data DescDef12 : Set13 where DescId12 : DescDef12 DescConst12 : DescDef12 DescProd12 : DescDef12 DescSigma12 : DescDef12 DescPi12 : DescDef12 data Lift12 (A : Set12) : Set13 where lifter : A -> Lift12 A unlift12 : {A : Set12} -> Lift12 A -> A unlift12 (lifter a) = a descCases12 : DescDef12 -> Desc13 descCases12 DescId12 = const13 Unit13 descCases12 DescConst12 = sigma13 Set12 (\_ -> const13 Unit13) descCases12 DescProd12 = prod13 id13 (prod13 id13 (const13 Unit13)) descCases12 DescSigma12 = sigma13 Set12 (\S -> prod13 (pi13 (Lift12 S) (\_ -> id13)) (const13 Unit13)) descCases12 DescPi12 = sigma13 Set12 (\S -> prod13 (pi13 (Lift12 S) (\_ -> id13)) (const13 Unit13)) DescD12 : Desc13 DescD12 = sigma13 DescDef12 descCases12 Desc12 : Set13 Desc12 = Mu13 DescD12 id12 : Desc12 id12 = con (DescId12 , Void) const12 : Set12 -> Desc12 const12 K = con (DescConst12 , (K , Void)) prod12 : (D D' : Desc12) -> Desc12 prod12 D D' = con (DescProd12 , (D , ( D' , Void ))) sigma12 : (S : Set12)(D : S -> Desc12) -> Desc12 sigma12 S D = con (DescSigma12 , (S , ((\s -> D (unlift12 s)) , Void ))) pi12 : (S : Set12)(D : S -> Desc12) -> Desc12 pi12 S D = con (DescPi12 , (S , ((\s -> D (unlift12 s)) , Void ))) [|_|]12_ : Desc12 -> Set12 -> Set12 [| con (DescId12 , Void) |]12 Z = Z [| con (DescConst12 , ( S , Void)) |]12 Z = S [| con (DescProd12 , (D , ( D' , Void ))) |]12 Z = [| D |]12 Z *12 [| D' |]12 Z [| con (DescSigma12 , (S , (T , Void))) |]12 Z = Sigma12 S (\s -> [| T (lifter s) |]12 Z ) [| con (DescPi12 , (S , (T , Void))) |]12 Z = (s : S) -> [| T (lifter s) |]12 Z data Mu12 (D : Desc12) : Set12 where con : [| D |]12 (Mu12 D) -> Mu12 D data DescDef11 : Set12 where DescId11 : DescDef11 DescConst11 : DescDef11 DescProd11 : DescDef11 DescSigma11 : DescDef11 DescPi11 : DescDef11 data Lift11 (A : Set11) : Set12 where lifter : A -> Lift11 A unlift11 : {A : Set11} -> Lift11 A -> A unlift11 (lifter a) = a descCases11 : DescDef11 -> Desc12 descCases11 DescId11 = const12 Unit12 descCases11 DescConst11 = sigma12 Set11 (\_ -> const12 Unit12) descCases11 DescProd11 = prod12 id12 (prod12 id12 (const12 Unit12)) descCases11 DescSigma11 = sigma12 Set11 (\S -> prod12 (pi12 (Lift11 S) (\_ -> id12)) (const12 Unit12)) descCases11 DescPi11 = sigma12 Set11 (\S -> prod12 (pi12 (Lift11 S) (\_ -> id12)) (const12 Unit12)) DescD11 : Desc12 DescD11 = sigma12 DescDef11 descCases11 Desc11 : Set12 Desc11 = Mu12 DescD11 id11 : Desc11 id11 = con (DescId11 , Void) const11 : Set11 -> Desc11 const11 K = con (DescConst11 , (K , Void)) prod11 : (D D' : Desc11) -> Desc11 prod11 D D' = con (DescProd11 , (D , ( D' , Void ))) sigma11 : (S : Set11)(D : S -> Desc11) -> Desc11 sigma11 S D = con (DescSigma11 , (S , ((\s -> D (unlift11 s)) , Void ))) pi11 : (S : Set11)(D : S -> Desc11) -> Desc11 pi11 S D = con (DescPi11 , (S , ((\s -> D (unlift11 s)) , Void ))) [|_|]11_ : Desc11 -> Set11 -> Set11 [| con (DescId11 , Void) |]11 Z = Z [| con (DescConst11 , ( S , Void)) |]11 Z = S [| con (DescProd11 , (D , ( D' , Void ))) |]11 Z = [| D |]11 Z *11 [| D' |]11 Z [| con (DescSigma11 , (S , (T , Void))) |]11 Z = Sigma11 S (\s -> [| T (lifter s) |]11 Z ) [| con (DescPi11 , (S , (T , Void))) |]11 Z = (s : S) -> [| T (lifter s) |]11 Z data Mu11 (D : Desc11) : Set11 where con : [| D |]11 (Mu11 D) -> Mu11 D data DescDef10 : Set11 where DescId10 : DescDef10 DescConst10 : DescDef10 DescProd10 : DescDef10 DescSigma10 : DescDef10 DescPi10 : DescDef10 data Lift10 (A : Set10) : Set11 where lifter : A -> Lift10 A unlift10 : {A : Set10} -> Lift10 A -> A unlift10 (lifter a) = a descCases10 : DescDef10 -> Desc11 descCases10 DescId10 = const11 Unit11 descCases10 DescConst10 = sigma11 Set10 (\_ -> const11 Unit11) descCases10 DescProd10 = prod11 id11 (prod11 id11 (const11 Unit11)) descCases10 DescSigma10 = sigma11 Set10 (\S -> prod11 (pi11 (Lift10 S) (\_ -> id11)) (const11 Unit11)) descCases10 DescPi10 = sigma11 Set10 (\S -> prod11 (pi11 (Lift10 S) (\_ -> id11)) (const11 Unit11)) DescD10 : Desc11 DescD10 = sigma11 DescDef10 descCases10 Desc10 : Set11 Desc10 = Mu11 DescD10 id10 : Desc10 id10 = con (DescId10 , Void) const10 : Set10 -> Desc10 const10 K = con (DescConst10 , (K , Void)) prod10 : (D D' : Desc10) -> Desc10 prod10 D D' = con (DescProd10 , (D , ( D' , Void ))) sigma10 : (S : Set10)(D : S -> Desc10) -> Desc10 sigma10 S D = con (DescSigma10 , (S , ((\s -> D (unlift10 s)) , Void ))) pi10 : (S : Set10)(D : S -> Desc10) -> Desc10 pi10 S D = con (DescPi10 , (S , ((\s -> D (unlift10 s)) , Void ))) [|_|]10_ : Desc10 -> Set10 -> Set10 [| con (DescId10 , Void) |]10 Z = Z [| con (DescConst10 , ( S , Void)) |]10 Z = S [| con (DescProd10 , (D , ( D' , Void ))) |]10 Z = [| D |]10 Z *10 [| D' |]10 Z [| con (DescSigma10 , (S , (T , Void))) |]10 Z = Sigma10 S (\s -> [| T (lifter s) |]10 Z ) [| con (DescPi10 , (S , (T , Void))) |]10 Z = (s : S) -> [| T (lifter s) |]10 Z data Mu10 (D : Desc10) : Set10 where con : [| D |]10 (Mu10 D) -> Mu10 D data DescDef9 : Set10 where DescId9 : DescDef9 DescConst9 : DescDef9 DescProd9 : DescDef9 DescSigma9 : DescDef9 DescPi9 : DescDef9 data Lift9 (A : Set9) : Set10 where lifter : A -> Lift9 A unlift9 : {A : Set9} -> Lift9 A -> A unlift9 (lifter a) = a descCases9 : DescDef9 -> Desc10 descCases9 DescId9 = const10 Unit10 descCases9 DescConst9 = sigma10 Set9 (\_ -> const10 Unit10) descCases9 DescProd9 = prod10 id10 (prod10 id10 (const10 Unit10)) descCases9 DescSigma9 = sigma10 Set9 (\S -> prod10 (pi10 (Lift9 S) (\_ -> id10)) (const10 Unit10)) descCases9 DescPi9 = sigma10 Set9 (\S -> prod10 (pi10 (Lift9 S) (\_ -> id10)) (const10 Unit10)) DescD9 : Desc10 DescD9 = sigma10 DescDef9 descCases9 Desc9 : Set10 Desc9 = Mu10 DescD9 id9 : Desc9 id9 = con (DescId9 , Void) const9 : Set9 -> Desc9 const9 K = con (DescConst9 , (K , Void)) prod9 : (D D' : Desc9) -> Desc9 prod9 D D' = con (DescProd9 , (D , ( D' , Void ))) sigma9 : (S : Set9)(D : S -> Desc9) -> Desc9 sigma9 S D = con (DescSigma9 , (S , ((\s -> D (unlift9 s)) , Void ))) pi9 : (S : Set9)(D : S -> Desc9) -> Desc9 pi9 S D = con (DescPi9 , (S , ((\s -> D (unlift9 s)) , Void ))) [|_|]9_ : Desc9 -> Set9 -> Set9 [| con (DescId9 , Void) |]9 Z = Z [| con (DescConst9 , ( S , Void)) |]9 Z = S [| con (DescProd9 , (D , ( D' , Void ))) |]9 Z = [| D |]9 Z *9 [| D' |]9 Z [| con (DescSigma9 , (S , (T , Void))) |]9 Z = Sigma9 S (\s -> [| T (lifter s) |]9 Z ) [| con (DescPi9 , (S , (T , Void))) |]9 Z = (s : S) -> [| T (lifter s) |]9 Z data Mu9 (D : Desc9) : Set9 where con : [| D |]9 (Mu9 D) -> Mu9 D data DescDef8 : Set9 where DescId8 : DescDef8 DescConst8 : DescDef8 DescProd8 : DescDef8 DescSigma8 : DescDef8 DescPi8 : DescDef8 data Lift8 (A : Set8) : Set9 where lifter : A -> Lift8 A unlift8 : {A : Set8} -> Lift8 A -> A unlift8 (lifter a) = a descCases8 : DescDef8 -> Desc9 descCases8 DescId8 = const9 Unit9 descCases8 DescConst8 = sigma9 Set8 (\_ -> const9 Unit9) descCases8 DescProd8 = prod9 id9 (prod9 id9 (const9 Unit9)) descCases8 DescSigma8 = sigma9 Set8 (\S -> prod9 (pi9 (Lift8 S) (\_ -> id9)) (const9 Unit9)) descCases8 DescPi8 = sigma9 Set8 (\S -> prod9 (pi9 (Lift8 S) (\_ -> id9)) (const9 Unit9)) DescD8 : Desc9 DescD8 = sigma9 DescDef8 descCases8 Desc8 : Set9 Desc8 = Mu9 DescD8 id8 : Desc8 id8 = con (DescId8 , Void) const8 : Set8 -> Desc8 const8 K = con (DescConst8 , (K , Void)) prod8 : (D D' : Desc8) -> Desc8 prod8 D D' = con (DescProd8 , (D , ( D' , Void ))) sigma8 : (S : Set8)(D : S -> Desc8) -> Desc8 sigma8 S D = con (DescSigma8 , (S , ((\s -> D (unlift8 s)) , Void ))) pi8 : (S : Set8)(D : S -> Desc8) -> Desc8 pi8 S D = con (DescPi8 , (S , ((\s -> D (unlift8 s)) , Void ))) [|_|]8_ : Desc8 -> Set8 -> Set8 [| con (DescId8 , Void) |]8 Z = Z [| con (DescConst8 , ( S , Void)) |]8 Z = S [| con (DescProd8 , (D , ( D' , Void ))) |]8 Z = [| D |]8 Z *8 [| D' |]8 Z [| con (DescSigma8 , (S , (T , Void))) |]8 Z = Sigma8 S (\s -> [| T (lifter s) |]8 Z ) [| con (DescPi8 , (S , (T , Void))) |]8 Z = (s : S) -> [| T (lifter s) |]8 Z data Mu8 (D : Desc8) : Set8 where con : [| D |]8 (Mu8 D) -> Mu8 D data DescDef7 : Set8 where DescId7 : DescDef7 DescConst7 : DescDef7 DescProd7 : DescDef7 DescSigma7 : DescDef7 DescPi7 : DescDef7 data Lift7 (A : Set7) : Set8 where lifter : A -> Lift7 A unlift7 : {A : Set7} -> Lift7 A -> A unlift7 (lifter a) = a descCases7 : DescDef7 -> Desc8 descCases7 DescId7 = const8 Unit8 descCases7 DescConst7 = sigma8 Set7 (\_ -> const8 Unit8) descCases7 DescProd7 = prod8 id8 (prod8 id8 (const8 Unit8)) descCases7 DescSigma7 = sigma8 Set7 (\S -> prod8 (pi8 (Lift7 S) (\_ -> id8)) (const8 Unit8)) descCases7 DescPi7 = sigma8 Set7 (\S -> prod8 (pi8 (Lift7 S) (\_ -> id8)) (const8 Unit8)) DescD7 : Desc8 DescD7 = sigma8 DescDef7 descCases7 Desc7 : Set8 Desc7 = Mu8 DescD7 id7 : Desc7 id7 = con (DescId7 , Void) const7 : Set7 -> Desc7 const7 K = con (DescConst7 , (K , Void)) prod7 : (D D' : Desc7) -> Desc7 prod7 D D' = con (DescProd7 , (D , ( D' , Void ))) sigma7 : (S : Set7)(D : S -> Desc7) -> Desc7 sigma7 S D = con (DescSigma7 , (S , ((\s -> D (unlift7 s)) , Void ))) pi7 : (S : Set7)(D : S -> Desc7) -> Desc7 pi7 S D = con (DescPi7 , (S , ((\s -> D (unlift7 s)) , Void ))) [|_|]7_ : Desc7 -> Set7 -> Set7 [| con (DescId7 , Void) |]7 Z = Z [| con (DescConst7 , ( S , Void)) |]7 Z = S [| con (DescProd7 , (D , ( D' , Void ))) |]7 Z = [| D |]7 Z *7 [| D' |]7 Z [| con (DescSigma7 , (S , (T , Void))) |]7 Z = Sigma7 S (\s -> [| T (lifter s) |]7 Z ) [| con (DescPi7 , (S , (T , Void))) |]7 Z = (s : S) -> [| T (lifter s) |]7 Z data Mu7 (D : Desc7) : Set7 where con : [| D |]7 (Mu7 D) -> Mu7 D data DescDef6 : Set7 where DescId6 : DescDef6 DescConst6 : DescDef6 DescProd6 : DescDef6 DescSigma6 : DescDef6 DescPi6 : DescDef6 data Lift6 (A : Set6) : Set7 where lifter : A -> Lift6 A unlift6 : {A : Set6} -> Lift6 A -> A unlift6 (lifter a) = a descCases6 : DescDef6 -> Desc7 descCases6 DescId6 = const7 Unit7 descCases6 DescConst6 = sigma7 Set6 (\_ -> const7 Unit7) descCases6 DescProd6 = prod7 id7 (prod7 id7 (const7 Unit7)) descCases6 DescSigma6 = sigma7 Set6 (\S -> prod7 (pi7 (Lift6 S) (\_ -> id7)) (const7 Unit7)) descCases6 DescPi6 = sigma7 Set6 (\S -> prod7 (pi7 (Lift6 S) (\_ -> id7)) (const7 Unit7)) DescD6 : Desc7 DescD6 = sigma7 DescDef6 descCases6 Desc6 : Set7 Desc6 = Mu7 DescD6 id6 : Desc6 id6 = con (DescId6 , Void) const6 : Set6 -> Desc6 const6 K = con (DescConst6 , (K , Void)) prod6 : (D D' : Desc6) -> Desc6 prod6 D D' = con (DescProd6 , (D , ( D' , Void ))) sigma6 : (S : Set6)(D : S -> Desc6) -> Desc6 sigma6 S D = con (DescSigma6 , (S , ((\s -> D (unlift6 s)) , Void ))) pi6 : (S : Set6)(D : S -> Desc6) -> Desc6 pi6 S D = con (DescPi6 , (S , ((\s -> D (unlift6 s)) , Void ))) [|_|]6_ : Desc6 -> Set6 -> Set6 [| con (DescId6 , Void) |]6 Z = Z [| con (DescConst6 , ( S , Void)) |]6 Z = S [| con (DescProd6 , (D , ( D' , Void ))) |]6 Z = [| D |]6 Z *6 [| D' |]6 Z [| con (DescSigma6 , (S , (T , Void))) |]6 Z = Sigma6 S (\s -> [| T (lifter s) |]6 Z ) [| con (DescPi6 , (S , (T , Void))) |]6 Z = (s : S) -> [| T (lifter s) |]6 Z data Mu6 (D : Desc6) : Set6 where con : [| D |]6 (Mu6 D) -> Mu6 D data DescDef5 : Set6 where DescId5 : DescDef5 DescConst5 : DescDef5 DescProd5 : DescDef5 DescSigma5 : DescDef5 DescPi5 : DescDef5 data Lift5 (A : Set5) : Set6 where lifter : A -> Lift5 A unlift5 : {A : Set5} -> Lift5 A -> A unlift5 (lifter a) = a descCases5 : DescDef5 -> Desc6 descCases5 DescId5 = const6 Unit6 descCases5 DescConst5 = sigma6 Set5 (\_ -> const6 Unit6) descCases5 DescProd5 = prod6 id6 (prod6 id6 (const6 Unit6)) descCases5 DescSigma5 = sigma6 Set5 (\S -> prod6 (pi6 (Lift5 S) (\_ -> id6)) (const6 Unit6)) descCases5 DescPi5 = sigma6 Set5 (\S -> prod6 (pi6 (Lift5 S) (\_ -> id6)) (const6 Unit6)) DescD5 : Desc6 DescD5 = sigma6 DescDef5 descCases5 Desc5 : Set6 Desc5 = Mu6 DescD5 id5 : Desc5 id5 = con (DescId5 , Void) const5 : Set5 -> Desc5 const5 K = con (DescConst5 , (K , Void)) prod5 : (D D' : Desc5) -> Desc5 prod5 D D' = con (DescProd5 , (D , ( D' , Void ))) sigma5 : (S : Set5)(D : S -> Desc5) -> Desc5 sigma5 S D = con (DescSigma5 , (S , ((\s -> D (unlift5 s)) , Void ))) pi5 : (S : Set5)(D : S -> Desc5) -> Desc5 pi5 S D = con (DescPi5 , (S , ((\s -> D (unlift5 s)) , Void ))) [|_|]5_ : Desc5 -> Set5 -> Set5 [| con (DescId5 , Void) |]5 Z = Z [| con (DescConst5 , ( S , Void)) |]5 Z = S [| con (DescProd5 , (D , ( D' , Void ))) |]5 Z = [| D |]5 Z *5 [| D' |]5 Z [| con (DescSigma5 , (S , (T , Void))) |]5 Z = Sigma5 S (\s -> [| T (lifter s) |]5 Z ) [| con (DescPi5 , (S , (T , Void))) |]5 Z = (s : S) -> [| T (lifter s) |]5 Z data Mu5 (D : Desc5) : Set5 where con : [| D |]5 (Mu5 D) -> Mu5 D data DescDef4 : Set5 where DescId4 : DescDef4 DescConst4 : DescDef4 DescProd4 : DescDef4 DescSigma4 : DescDef4 DescPi4 : DescDef4 data Lift4 (A : Set4) : Set5 where lifter : A -> Lift4 A unlift4 : {A : Set4} -> Lift4 A -> A unlift4 (lifter a) = a descCases4 : DescDef4 -> Desc5 descCases4 DescId4 = const5 Unit5 descCases4 DescConst4 = sigma5 Set4 (\_ -> const5 Unit5) descCases4 DescProd4 = prod5 id5 (prod5 id5 (const5 Unit5)) descCases4 DescSigma4 = sigma5 Set4 (\S -> prod5 (pi5 (Lift4 S) (\_ -> id5)) (const5 Unit5)) descCases4 DescPi4 = sigma5 Set4 (\S -> prod5 (pi5 (Lift4 S) (\_ -> id5)) (const5 Unit5)) DescD4 : Desc5 DescD4 = sigma5 DescDef4 descCases4 Desc4 : Set5 Desc4 = Mu5 DescD4 id4 : Desc4 id4 = con (DescId4 , Void) const4 : Set4 -> Desc4 const4 K = con (DescConst4 , (K , Void)) prod4 : (D D' : Desc4) -> Desc4 prod4 D D' = con (DescProd4 , (D , ( D' , Void ))) sigma4 : (S : Set4)(D : S -> Desc4) -> Desc4 sigma4 S D = con (DescSigma4 , (S , ((\s -> D (unlift4 s)) , Void ))) pi4 : (S : Set4)(D : S -> Desc4) -> Desc4 pi4 S D = con (DescPi4 , (S , ((\s -> D (unlift4 s)) , Void ))) [|_|]4_ : Desc4 -> Set4 -> Set4 [| con (DescId4 , Void) |]4 Z = Z [| con (DescConst4 , ( S , Void)) |]4 Z = S [| con (DescProd4 , (D , ( D' , Void ))) |]4 Z = [| D |]4 Z *4 [| D' |]4 Z [| con (DescSigma4 , (S , (T , Void))) |]4 Z = Sigma4 S (\s -> [| T (lifter s) |]4 Z ) [| con (DescPi4 , (S , (T , Void))) |]4 Z = (s : S) -> [| T (lifter s) |]4 Z data Mu4 (D : Desc4) : Set4 where con : [| D |]4 (Mu4 D) -> Mu4 D data DescDef3 : Set4 where DescId3 : DescDef3 DescConst3 : DescDef3 DescProd3 : DescDef3 DescSigma3 : DescDef3 DescPi3 : DescDef3 data Lift3 (A : Set3) : Set4 where lifter : A -> Lift3 A unlift3 : {A : Set3} -> Lift3 A -> A unlift3 (lifter a) = a descCases3 : DescDef3 -> Desc4 descCases3 DescId3 = const4 Unit4 descCases3 DescConst3 = sigma4 Set3 (\_ -> const4 Unit4) descCases3 DescProd3 = prod4 id4 (prod4 id4 (const4 Unit4)) descCases3 DescSigma3 = sigma4 Set3 (\S -> prod4 (pi4 (Lift3 S) (\_ -> id4)) (const4 Unit4)) descCases3 DescPi3 = sigma4 Set3 (\S -> prod4 (pi4 (Lift3 S) (\_ -> id4)) (const4 Unit4)) DescD3 : Desc4 DescD3 = sigma4 DescDef3 descCases3 Desc3 : Set4 Desc3 = Mu4 DescD3 id3 : Desc3 id3 = con (DescId3 , Void) const3 : Set3 -> Desc3 const3 K = con (DescConst3 , (K , Void)) prod3 : (D D' : Desc3) -> Desc3 prod3 D D' = con (DescProd3 , (D , ( D' , Void ))) sigma3 : (S : Set3)(D : S -> Desc3) -> Desc3 sigma3 S D = con (DescSigma3 , (S , ((\s -> D (unlift3 s)) , Void ))) pi3 : (S : Set3)(D : S -> Desc3) -> Desc3 pi3 S D = con (DescPi3 , (S , ((\s -> D (unlift3 s)) , Void ))) [|_|]3_ : Desc3 -> Set3 -> Set3 [| con (DescId3 , Void) |]3 Z = Z [| con (DescConst3 , ( S , Void)) |]3 Z = S [| con (DescProd3 , (D , ( D' , Void ))) |]3 Z = [| D |]3 Z *3 [| D' |]3 Z [| con (DescSigma3 , (S , (T , Void))) |]3 Z = Sigma3 S (\s -> [| T (lifter s) |]3 Z ) [| con (DescPi3 , (S , (T , Void))) |]3 Z = (s : S) -> [| T (lifter s) |]3 Z data Mu3 (D : Desc3) : Set3 where con : [| D |]3 (Mu3 D) -> Mu3 D data DescDef2 : Set3 where DescId2 : DescDef2 DescConst2 : DescDef2 DescProd2 : DescDef2 DescSigma2 : DescDef2 DescPi2 : DescDef2 data Lift2 (A : Set2) : Set3 where lifter : A -> Lift2 A unlift2 : {A : Set2} -> Lift2 A -> A unlift2 (lifter a) = a descCases2 : DescDef2 -> Desc3 descCases2 DescId2 = const3 Unit3 descCases2 DescConst2 = sigma3 Set2 (\_ -> const3 Unit3) descCases2 DescProd2 = prod3 id3 (prod3 id3 (const3 Unit3)) descCases2 DescSigma2 = sigma3 Set2 (\S -> prod3 (pi3 (Lift2 S) (\_ -> id3)) (const3 Unit3)) descCases2 DescPi2 = sigma3 Set2 (\S -> prod3 (pi3 (Lift2 S) (\_ -> id3)) (const3 Unit3)) DescD2 : Desc3 DescD2 = sigma3 DescDef2 descCases2 Desc2 : Set3 Desc2 = Mu3 DescD2 id2 : Desc2 id2 = con (DescId2 , Void) const2 : Set2 -> Desc2 const2 K = con (DescConst2 , (K , Void)) prod2 : (D D' : Desc2) -> Desc2 prod2 D D' = con (DescProd2 , (D , ( D' , Void ))) sigma2 : (S : Set2)(D : S -> Desc2) -> Desc2 sigma2 S D = con (DescSigma2 , (S , ((\s -> D (unlift2 s)) , Void ))) pi2 : (S : Set2)(D : S -> Desc2) -> Desc2 pi2 S D = con (DescPi2 , (S , ((\s -> D (unlift2 s)) , Void ))) [|_|]2_ : Desc2 -> Set2 -> Set2 [| con (DescId2 , Void) |]2 Z = Z [| con (DescConst2 , ( S , Void)) |]2 Z = S [| con (DescProd2 , (D , ( D' , Void ))) |]2 Z = [| D |]2 Z *2 [| D' |]2 Z [| con (DescSigma2 , (S , (T , Void))) |]2 Z = Sigma2 S (\s -> [| T (lifter s) |]2 Z ) [| con (DescPi2 , (S , (T , Void))) |]2 Z = (s : S) -> [| T (lifter s) |]2 Z data Mu2 (D : Desc2) : Set2 where con : [| D |]2 (Mu2 D) -> Mu2 D data DescDef1 : Set2 where DescId1 : DescDef1 DescConst1 : DescDef1 DescProd1 : DescDef1 DescSigma1 : DescDef1 DescPi1 : DescDef1 data Lift1 (A : Set1) : Set2 where lifter : A -> Lift1 A unlift1 : {A : Set1} -> Lift1 A -> A unlift1 (lifter a) = a descCases1 : DescDef1 -> Desc2 descCases1 DescId1 = const2 Unit2 descCases1 DescConst1 = sigma2 Set1 (\_ -> const2 Unit2) descCases1 DescProd1 = prod2 id2 (prod2 id2 (const2 Unit2)) descCases1 DescSigma1 = sigma2 Set1 (\S -> prod2 (pi2 (Lift1 S) (\_ -> id2)) (const2 Unit2)) descCases1 DescPi1 = sigma2 Set1 (\S -> prod2 (pi2 (Lift1 S) (\_ -> id2)) (const2 Unit2)) DescD1 : Desc2 DescD1 = sigma2 DescDef1 descCases1 Desc1 : Set2 Desc1 = Mu2 DescD1 id1 : Desc1 id1 = con (DescId1 , Void) const1 : Set1 -> Desc1 const1 K = con (DescConst1 , (K , Void)) prod1 : (D D' : Desc1) -> Desc1 prod1 D D' = con (DescProd1 , (D , ( D' , Void ))) sigma1 : (S : Set1)(D : S -> Desc1) -> Desc1 sigma1 S D = con (DescSigma1 , (S , ((\s -> D (unlift1 s)) , Void ))) pi1 : (S : Set1)(D : S -> Desc1) -> Desc1 pi1 S D = con (DescPi1 , (S , ((\s -> D (unlift1 s)) , Void ))) [|_|]1_ : Desc1 -> Set1 -> Set1 [| con (DescId1 , Void) |]1 Z = Z [| con (DescConst1 , ( S , Void)) |]1 Z = S [| con (DescProd1 , (D , ( D' , Void ))) |]1 Z = [| D |]1 Z *1 [| D' |]1 Z [| con (DescSigma1 , (S , (T , Void))) |]1 Z = Sigma1 S (\s -> [| T (lifter s) |]1 Z ) [| con (DescPi1 , (S , (T , Void))) |]1 Z = (s : S) -> [| T (lifter s) |]1 Z data Mu1 (D : Desc1) : Set1 where con : [| D |]1 (Mu1 D) -> Mu1 D data DescDef0 : Set1 where DescId0 : DescDef0 DescConst0 : DescDef0 DescProd0 : DescDef0 DescSigma0 : DescDef0 DescPi0 : DescDef0 data Lift0 (A : Set0) : Set1 where lifter : A -> Lift0 A unlift0 : {A : Set0} -> Lift0 A -> A unlift0 (lifter a) = a descCases0 : DescDef0 -> Desc1 descCases0 DescId0 = const1 Unit1 descCases0 DescConst0 = sigma1 Set0 (\_ -> const1 Unit1) descCases0 DescProd0 = prod1 id1 (prod1 id1 (const1 Unit1)) descCases0 DescSigma0 = sigma1 Set0 (\S -> prod1 (pi1 (Lift0 S) (\_ -> id1)) (const1 Unit1)) descCases0 DescPi0 = sigma1 Set0 (\S -> prod1 (pi1 (Lift0 S) (\_ -> id1)) (const1 Unit1)) DescD0 : Desc1 DescD0 = sigma1 DescDef0 descCases0 Desc0 : Set1 Desc0 = Mu1 DescD0 id0 : Desc0 id0 = con (DescId0 , Void) const0 : Set0 -> Desc0 const0 K = con (DescConst0 , (K , Void)) prod0 : (D D' : Desc0) -> Desc0 prod0 D D' = con (DescProd0 , (D , ( D' , Void ))) sigma0 : (S : Set0)(D : S -> Desc0) -> Desc0 sigma0 S D = con (DescSigma0 , (S , ((\s -> D (unlift0 s)) , Void ))) pi0 : (S : Set0)(D : S -> Desc0) -> Desc0 pi0 S D = con (DescPi0 , (S , ((\s -> D (unlift0 s)) , Void ))) [|_|]0_ : Desc0 -> Set0 -> Set0 [| con (DescId0 , Void) |]0 Z = Z [| con (DescConst0 , ( S , Void)) |]0 Z = S [| con (DescProd0 , (D , ( D' , Void ))) |]0 Z = [| D |]0 Z *0 [| D' |]0 Z [| con (DescSigma0 , (S , (T , Void))) |]0 Z = Sigma0 S (\s -> [| T (lifter s) |]0 Z ) [| con (DescPi0 , (S , (T , Void))) |]0 Z = (s : S) -> [| T (lifter s) |]0 Z data Mu0 (D : Desc0) : Set0 where con : [| D |]0 (Mu0 D) -> Mu0 D
{ "alphanum_fraction": 0.597567402, "avg_line_length": 32.4609338881, "ext": "agda", "hexsha": "7e8034ee96f0af945e7f7bc9dcfd8a643e377afd", "lang": "Agda", "max_forks_count": 12, "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mietek/epigram", "max_forks_repo_path": "models/DescStrat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mietek/epigram", "max_issues_repo_path": "models/DescStrat.agda", "max_line_length": 103, "max_stars_count": 48, "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mietek/epigram", "max_stars_repo_path": "models/DescStrat.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "num_tokens": 27921, "size": 70213 }
module CombinatoryLogic.Semantics where open import Relation.Binary using (Rel) open import CombinatoryLogic.Syntax -- Kapitel 1, Abschnitt C, §5 (Axiome) data Axiom : Combinator → Set where Q : Axiom (Π ∙ (W ∙ (C ∙ Q))) B : Axiom (C ∙ (B ∙ B ∙ (B ∙ B ∙ B)) ∙ B == B ∙ (B ∙ B) ∙ B) C : Axiom (C ∙ (B ∙ B ∙ (B ∙ B ∙ B)) ∙ W ∙ C == B ∙ (B ∙ C) ∙ (B ∙ B ∙ B)) W : Axiom (C ∙ (B ∙ B ∙ B) ∙ W == B ∙ (B ∙ W) ∙ (B ∙ B ∙ B)) -- NOTE (Curry): this axiom can be proved from the others. I₁ : Axiom (C ∙ (B ∙ B ∙ B) ∙ K == B ∙ (B ∙ K) ∙ I) BC : Axiom (B ∙ B ∙ C == B ∙ (B ∙ (B ∙ C) ∙ C) ∙ (B ∙ B)) BW : Axiom (B ∙ B ∙ W == B ∙ (B ∙ (B ∙ (B ∙ (B ∙ W) ∙ W) ∙ (B ∙ C)) ∙ B ∙ (B ∙ B)) ∙ B) BK : Axiom (B ∙ B ∙ K == B ∙ K ∙ K) CC₁ : Axiom (B ∙ C ∙ C ∙ B ∙ (B ∙ I)) CC₂ : Axiom (B ∙ (B ∙ (B ∙ C) ∙ C) ∙ (B ∙ C) == B ∙ (B ∙ C ∙ (B ∙ C)) ∙ C) CW : Axiom (B ∙ C ∙ W == B ∙ (B ∙ (B ∙ W) ∙ C) ∙ (B ∙ C)) CK : Axiom (B ∙ C ∙ K == B ∙ K) WC : Axiom (B ∙ W ∙ C == W) WW : Axiom (B ∙ W ∙ W == B ∙ W ∙ (B ∙ W)) WK : Axiom (B ∙ W ∙ K == B ∙ I) I₂ : Axiom (B ∙ I == I) -- Kapitel 1, Abschnitt C, §4 (Symbolische Festsetzungen), Festsetzung 1 infix 4 ⊢_ data ⊢_ : Combinator → Set where ax : ∀ {X} → Axiom X → ⊢ X -- Kapitel 1, Abschnitt C, §6 (Regeln) Q₁ : ∀ {X Y} → ⊢ X → ⊢ X == Y → ⊢ Y Q₂ : ∀ {X Y Z} → ⊢ X == Y → ⊢ Z ∙ X == Z ∙ Y Π : ∀ {X Y} → ⊢ Π ∙ X → ⊢ X ∙ Y B : ∀ {X Y Z} → ⊢ B ∙ X ∙ Y ∙ Z == X ∙ (Y ∙ Z) C : ∀ {X Y Z} → ⊢ C ∙ X ∙ Y ∙ Z == X ∙ Z ∙ Y W : ∀ {X Y} → ⊢ W ∙ X ∙ Y == X ∙ Y ∙ Y K : ∀ {X Y} → ⊢ K ∙ X ∙ Y == X P : ∀ {X Y} → ⊢ X → ⊢ P ∙ X ∙ Y → ⊢ Y ∧ : ∀ {X Y} → ⊢ X → ⊢ Y → ⊢ ∧ ∙ X ∙ Y -- We introduce convenience notation for the equality defined in Kapitel 1, -- Abschnitt C, §4 (Symbolische Festsetzungen), Festsetzung 3 (Gleichheit). _≈_ : Rel Combinator _ X ≈ Y = ⊢ X == Y infix 0 _[_] -- An operator that helps write proofs in the style of Curry. Where Curry writes -- ⟨statement⟩ (⟨rule⟩) -- we write -- ⟨statement⟩ [ ⟨rule⟩ ] -- -- Later, we can also use the Agda standard library's reasoning combinators -- (e.g. _≈⟨_⟩_) for proving equalities, but not before it is shown that the -- equality _≈_ is an equivalence relation, which Curry does in propositions 1, -- 2 and 3 of Kapitel 1, Abschnitt D (Die Eigenschaften der Gleichheit). _[_] : ∀ {a} (A : Set a) (x : A) → A _ [ x ] = x
{ "alphanum_fraction": 0.477427598, "avg_line_length": 38.4918032787, "ext": "agda", "hexsha": "0bb3d057fd21df0d9ad27f3891dfc407171a10ed", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "CombinatoryLogic/Semantics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_path": "CombinatoryLogic/Semantics.agda", "max_line_length": 89, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "CombinatoryLogic/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 1162, "size": 2348 }
open import Prelude open import dynamics-core open import progress-checks module finality where finality : Σ[ d ∈ ihexp ] (d final × (Σ[ d' ∈ ihexp ] (d ↦ d'))) → ⊥ finality (π1 , π2 , π3 , π4) = final-not-step π2 (π3 , π4) -- a slight restatement of the above, generalizing it to the -- multistep judgement finality* : ∀{d d'} → d final → d ↦* d' → d == d' finality* fin MSRefl = refl finality* fin (MSStep x ms) = abort (final-not-step fin (_ , x))
{ "alphanum_fraction": 0.6282051282, "avg_line_length": 31.2, "ext": "agda", "hexsha": "72c359edb843a5f60368092a18932dd22922a4bd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "finality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "finality.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "finality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 166, "size": 468 }
postulate A : Set record R : Set where constructor c field f : A open R {{...}} works : {{_ : R}} → A works = f works' : {{_ : R}} → Set → A works' B = f test : {{_ : R}} → A test {{_}} = f -- No variable of type R was found in scope. -- when checking that the expression f has type A test1 : {{_ : R}} → Set → A test1 B = f -- No variable of type R was found in scope. -- when checking that the expression f has type A
{ "alphanum_fraction": 0.5889145497, "avg_line_length": 16.037037037, "ext": "agda", "hexsha": "45c74c2a7af3e357a523456afa978873df082511", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue1613.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue1613.agda", "max_line_length": 49, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue1613.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 141, "size": 433 }
module monad where open import eq record Monad (M : Set → Set) : Set₁ where field return : ∀{A : Set} → A → M A bind : ∀{A B : Set} → M A → (A → M B) → M B monad-left-id : ∀{A B : Set}{a : A}{f : A → M B} → bind (return a) f ≡ f a monad-right-id : ∀{A : Set}{c : M A} → bind c return ≡ c monad-assoc : ∀{A B C : Set}{c : M A}{f : A → M B}{g : B → M C} → bind (bind c f) g ≡ bind c (λ a → bind (f a) g)
{ "alphanum_fraction": 0.4482758621, "avg_line_length": 24.4210526316, "ext": "agda", "hexsha": "ee9d26c8672c84e8b414e84099a5693d02992bdc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "monads.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "monads.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "monads.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 185, "size": 464 }
------------------------------------------------------------------------ -- Higher lenses with erased proofs ------------------------------------------------------------------------ -- At the time of writing there are counterparts in this file of more -- or less everything in Lens.Non-dependent.Higher, except for parts -- of the section called "A category". There is also a counterpart to -- one of the properties related to higher lenses from -- Lens.Non-dependent.Equivalent-preimages -- (higher-lens-preserves-h-level-of-domain). {-# OPTIONS --cubical --safe #-} import Equality.Path as P module Lens.Non-dependent.Higher.Erased {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq import Bi-invertibility.Erased open import Logical-equivalence using (_⇔_) open import Prelude as P hiding (id; [_,_]) renaming (_∘_ to _⊚_) open import Bijection equality-with-J as Bijection using (_↔_) open import Circle eq using (𝕊¹) open import Equality.Decidable-UIP equality-with-J open import Equality.Decision-procedures equality-with-J open import Equality.Path.Isomorphisms eq hiding (univ) open import Equivalence equality-with-J as Eq using (_≃_; Is-equivalence) open import Equivalence.Erased equality-with-J as EEq using (_≃ᴱ_; Is-equivalenceᴱ; Contractibleᴱ; _⁻¹ᴱ_) open import Erased.Cubical eq open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional eq as PT open import Preimage equality-with-J using (_⁻¹_) open import Surjection equality-with-J using (_↠_) open import Univalence-axiom equality-with-J open import Lens.Non-dependent eq as Non-dependent hiding (no-first-projection-lens) import Lens.Non-dependent.Equivalent-preimages eq as EP import Lens.Non-dependent.Higher eq as H import Lens.Non-dependent.Traditional eq as T import Lens.Non-dependent.Traditional.Erased eq as Traditionalᴱ private variable a b c d p r : Level A A₁ A₂ B B₁ B₂ : Set a P : A → Set p n : ℕ ------------------------------------------------------------------------ -- Higher lenses private module Temporarily-private where -- Higher lenses with erased "proofs". record Lens (A : Set a) (B : Set b) : Set (lsuc (a ⊔ b)) where constructor ⟨_,_,_⟩ pattern no-eta-equality field -- Remainder type. R : Set (a ⊔ b) -- Equivalence (with erased proofs). equiv : A ≃ᴱ (R × B) -- The proof of (mere) inhabitance. @0 inhabited : R → ∥ B ∥ open Temporarily-private public hiding (module Lens) -- Lens can be expressed as a nested Σ-type. Lens-as-Σ : {A : Set a} {B : Set b} → Lens A B ≃ ∃ λ (R : Set (a ⊔ b)) → (A ≃ᴱ (R × B)) × Erased (R → ∥ B ∥) Lens-as-Σ = Eq.↔→≃ (λ l → R l , equiv l , [ inhabited l ]) (λ (R , equiv , [ inhabited ]) → record { R = R ; equiv = equiv ; inhabited = inhabited }) refl (λ { ⟨ _ , _ , _ ⟩ → refl _ }) where open Temporarily-private.Lens -- Lenses without erased proofs can be turned into lenses with erased -- proofs. Higher-lens→Lens : H.Lens A B → Lens A B Higher-lens→Lens {A = A} {B = B} l@(H.⟨ _ , _ , _ ⟩) = $⟨ l ⟩ H.Lens A B ↔⟨ H.Lens-as-Σ ⟩ (∃ λ (R : Set _) → (A ≃ (R × B)) × (R → ∥ B ∥)) ↝⟨ Σ-map P.id (Σ-map EEq.≃→≃ᴱ [_]→) ⟩ (∃ λ (R : Set _) → (A ≃ᴱ (R × B)) × Erased (R → ∥ B ∥)) ↔⟨ inverse Lens-as-Σ ⟩□ Lens A B □ -- In erased contexts Lens A B is equivalent to H.Lens A B. @0 Lens≃Higher-lens : Lens A B ≃ H.Lens A B Lens≃Higher-lens {A = A} {B = B} = Eq.with-other-inverse (Lens A B ↝⟨ Lens-as-Σ ⟩ (∃ λ (R : Set _) → (A ≃ᴱ (R × B)) × Erased (R → ∥ B ∥)) ↝⟨ (∃-cong λ _ → inverse (EEq.≃≃≃ᴱ ext) ×-cong Eq.↔⇒≃ (erased Erased↔)) ⟩ (∃ λ (R : Set _) → (A ≃ (R × B)) × (R → ∥ B ∥)) ↔⟨ inverse H.Lens-as-Σ ⟩□ H.Lens A B □) Higher-lens→Lens (λ { H.⟨ _ , _ , _ ⟩ → refl _ }) private -- The forward direction of Lens≃Higher-lens. @0 high : Lens A B → H.Lens A B high = _≃_.to Lens≃Higher-lens -- Some derived definitions. module Lens (l : Lens A B) where open Temporarily-private.Lens l public -- Remainder. remainder : A → R remainder a = proj₁ (_≃ᴱ_.to equiv a) -- Getter. get : A → B get a = proj₂ (_≃ᴱ_.to equiv a) -- Setter. set : A → B → A set a b = _≃ᴱ_.from equiv (remainder a , b) -- A combination of get and set. modify : (B → B) → A → A modify f x = set x (f (get x)) -- Lens laws. @0 get-set : ∀ a b → get (set a b) ≡ b get-set a b = proj₂ (_≃ᴱ_.to equiv (_≃ᴱ_.from equiv (remainder a , b))) ≡⟨ cong proj₂ (_≃ᴱ_.right-inverse-of equiv _) ⟩∎ proj₂ (remainder a , b) ∎ @0 set-get : ∀ a → set a (get a) ≡ a set-get a = _≃ᴱ_.from equiv (_≃ᴱ_.to equiv a) ≡⟨ _≃ᴱ_.left-inverse-of equiv _ ⟩∎ a ∎ @0 set-set : ∀ a b₁ b₂ → set (set a b₁) b₂ ≡ set a b₂ set-set a b₁ b₂ = let r = remainder a in _≃ᴱ_.from equiv (remainder (_≃ᴱ_.from equiv (r , b₁)) , b₂) ≡⟨⟩ _≃ᴱ_.from equiv (proj₁ (_≃ᴱ_.to equiv (_≃ᴱ_.from equiv (r , b₁))) , b₂) ≡⟨ cong (λ p → _≃ᴱ_.from equiv (proj₁ p , b₂)) $ _≃ᴱ_.right-inverse-of equiv _ ⟩∎ _≃ᴱ_.from equiv (r , b₂) ∎ -- Another law. @0 remainder-set : ∀ a b → remainder (set a b) ≡ remainder a remainder-set = H.Lens.remainder-set (high l) -- The remainder function is surjective (in erased contexts). @0 remainder-surjective : Surjective remainder remainder-surjective = H.Lens.remainder-surjective (high l) -- A traditional lens with erased proofs. traditional-lens : Traditionalᴱ.Lens A B traditional-lens = record { get = get ; set = set ; get-set = get-set ; set-get = set-get ; set-set = set-set } -- The following two coherence laws, which do not necessarily hold -- for traditional lenses with erased proofs (see -- Traditionalᴱ.getter-equivalence-but-not-coherent), hold -- unconditionally for higher lenses (in erased contexts). @0 get-set-get : ∀ a → cong get (set-get a) ≡ get-set a (get a) get-set-get a = cong (proj₂ ⊚ _≃ᴱ_.to equiv) (_≃ᴱ_.left-inverse-of equiv _) ≡⟨ sym $ cong-∘ _ _ (_≃ᴱ_.left-inverse-of equiv _) ⟩ cong proj₂ (cong (_≃ᴱ_.to equiv) (_≃ᴱ_.left-inverse-of equiv _)) ≡⟨ cong (cong proj₂) $ _≃ᴱ_.left-right-lemma equiv _ ⟩∎ cong proj₂ (_≃ᴱ_.right-inverse-of equiv _) ∎ @0 get-set-set : ∀ a b₁ b₂ → cong get (set-set a b₁ b₂) ≡ trans (get-set (set a b₁) b₂) (sym (get-set a b₂)) get-set-set a b₁ b₂ = elim₁ (λ eq → cong (proj₂ ⊚ _≃ᴱ_.to equiv) (cong (λ p → _≃ᴱ_.from equiv (proj₁ p , _)) eq) ≡ trans (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _)) (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _)))) (cong (proj₂ ⊚ _≃ᴱ_.to equiv) (cong (λ p → _≃ᴱ_.from equiv (proj₁ p , b₂)) (refl (proj₁ (_≃ᴱ_.to equiv a) , b₁))) ≡⟨ cong (cong (proj₂ ⊚ _≃ᴱ_.to equiv)) $ cong-refl _ ⟩ cong (proj₂ ⊚ _≃ᴱ_.to equiv) (refl _) ≡⟨ cong-refl _ ⟩ refl _ ≡⟨ sym $ trans-symʳ _ ⟩∎ trans (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _)) (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) ∎) (_≃ᴱ_.right-inverse-of equiv _) -- A somewhat coherent lens with erased proofs. coherent-lens : Traditionalᴱ.Coherent-lens A B coherent-lens = record { lens = traditional-lens ; get-set-get = get-set-get ; get-set-set = get-set-set } instance -- Higher lenses have getters and setters. has-getter-and-setter : Has-getter-and-setter (Lens {a = a} {b = b}) has-getter-and-setter = record { get = Lens.get ; set = Lens.set } ------------------------------------------------------------------------ -- Equivalences with erased proofs can be converted to lenses -- Converts equivalences between a domain and the cartesian product of -- a type and a codomain to lenses. ≃ᴱ×→Lens : {A : Set a} {B : Set b} {R : Set (a ⊔ b)} → A ≃ᴱ (R × B) → Lens A B ≃ᴱ×→Lens {A = A} {B = B} {R = R} A≃R×B = record { R = R × Erased ∥ B ∥ ; equiv = A ↝⟨ A≃R×B ⟩ R × B ↔⟨ F.id ×-cong inverse Erased-∥∥×≃ ⟩ R × Erased ∥ B ∥ × B ↔⟨ ×-assoc ⟩□ (R × Erased ∥ B ∥) × B □ ; inhabited = erased ⊚ proj₂ } -- Converts equivalences to lenses. ≃ᴱ→Lens : {A : Set a} {B : Set b} → A ≃ᴱ B → Lens A B ≃ᴱ→Lens {a = a} {A = A} {B = B} A≃B = record { R = Erased ∥ ↑ a B ∥ ; equiv = A ↝⟨ A≃B ⟩ B ↔⟨ inverse Erased-∥∥×≃ ⟩ Erased ∥ B ∥ × B ↔⟨ Erased-cong (∥∥-cong (inverse Bijection.↑↔)) ×-cong F.id ⟩□ Erased ∥ ↑ a B ∥ × B □ ; inhabited = ∥∥-map lower ⊚ erased } -- Converts equivalences between types with the same universe level to -- lenses. ≃ᴱ→Lens′ : {A B : Set a} → A ≃ᴱ B → Lens A B ≃ᴱ→Lens′ {a = a} {A = A} {B = B} A≃B = record { R = Erased ∥ B ∥ ; equiv = A ↝⟨ A≃B ⟩ B ↔⟨ inverse Erased-∥∥×≃ ⟩□ Erased ∥ B ∥ × B □ ; inhabited = erased } ------------------------------------------------------------------------ -- Equality characterisation lemmas for lenses -- An equality characterisation lemma. equality-characterisation₀ : {l₁ l₂ : Lens A B} → let open Lens in l₁ ≡ l₂ ↔ ∃ λ (eq : R l₁ ≡ R l₂) → subst (λ R → A ≃ᴱ (R × B)) eq (equiv l₁) ≡ equiv l₂ equality-characterisation₀ {A = A} {B = B} {l₁ = l₁} {l₂ = l₂} = l₁ ≡ l₂ ↔⟨ inverse $ Eq.≃-≡ Lens-as-Σ ⟩ l₁′ ≡ l₂′ ↝⟨ inverse Bijection.Σ-≡,≡↔≡ ⟩ (∃ λ (eq : R l₁ ≡ R l₂) → subst (λ R → A ≃ᴱ (R × B) × Erased (R → ∥ B ∥)) eq (proj₂ l₁′) ≡ proj₂ l₂′) ↝⟨ (∃-cong λ _ → inverse $ ignore-propositional-component (H-level-Erased 1 ( Π-closure ext 1 λ _ → truncation-is-proposition))) ⟩ (∃ λ (eq : R l₁ ≡ R l₂) → proj₁ (subst (λ R → A ≃ᴱ (R × B) × Erased (R → ∥ B ∥)) eq (proj₂ l₁′)) ≡ equiv l₂) ↝⟨ (∃-cong λ eq → ≡⇒↝ _ $ cong (λ p → proj₁ p ≡ _) (push-subst-, {y≡z = eq} _ _)) ⟩□ (∃ λ (eq : R l₁ ≡ R l₂) → subst (λ R → A ≃ᴱ (R × B)) eq (equiv l₁) ≡ equiv l₂) □ where open Lens l₁′ = _≃_.to Lens-as-Σ l₁ l₂′ = _≃_.to Lens-as-Σ l₂ -- Another equality characterisation lemma. @0 equality-characterisation₁ : {A : Set a} {B : Set b} {l₁ l₂ : Lens A B} → let open Lens in Univalence (a ⊔ b) → l₁ ≡ l₂ ↔ ∃ λ (eq : R l₁ ≃ R l₂) → from-equivalence (eq ×-cong F.id) F.∘ equiv l₁ ≡ equiv l₂ equality-characterisation₁ {A = A} {B = B} {l₁ = l₁} {l₂ = l₂} univ = l₁ ≡ l₂ ↔⟨ inverse $ Eq.≃-≡ Lens≃Higher-lens ⟩ high l₁ ≡ high l₂ ↝⟨ H.equality-characterisation₁ univ ⟩ (∃ λ (eq : R l₁ ≃ R l₂) → (eq ×-cong F.id) F.∘ H.Lens.equiv (high l₁) ≡ H.Lens.equiv (high l₂)) ↔⟨ (∃-cong λ eq → inverse $ Eq.≃-≡ $ EEq.≃≃≃ᴱ ext) ⟩ (∃ λ (eq : R l₁ ≃ R l₂) → EEq.≃→≃ᴱ ((eq ×-cong F.id) F.∘ H.Lens.equiv (high l₁)) ≡ EEq.≃→≃ᴱ (H.Lens.equiv (high l₂))) ↝⟨ (∃-cong λ _ → ≡⇒↝ _ $ cong₂ _≡_ (EEq.to≡to→≡ ext (refl _)) (EEq.to≡to→≡ ext (refl _))) ⟩□ (∃ λ (eq : R l₁ ≃ R l₂) → from-equivalence (eq ×-cong F.id) F.∘ equiv l₁ ≡ equiv l₂) □ where open Lens -- Yet another equality characterisation lemma. @0 equality-characterisation₂ : {A : Set a} {B : Set b} {l₁ l₂ : Lens A B} → let open Lens in Univalence (a ⊔ b) → l₁ ≡ l₂ ↔ ∃ λ (eq : R l₁ ≃ R l₂) → ∀ x → (_≃_.to eq (remainder l₁ x) , get l₁ x) ≡ _≃ᴱ_.to (equiv l₂) x equality-characterisation₂ {l₁ = l₁} {l₂ = l₂} univ = l₁ ≡ l₂ ↔⟨ inverse $ Eq.≃-≡ Lens≃Higher-lens ⟩ high l₁ ≡ high l₂ ↝⟨ H.equality-characterisation₂ univ ⟩□ (∃ λ (eq : R l₁ ≃ R l₂) → ∀ x → (_≃_.to eq (remainder l₁ x) , get l₁ x) ≡ _≃ᴱ_.to (equiv l₂) x) □ where open Lens -- And another one. @0 equality-characterisation₃ : {A : Set a} {B : Set b} {l₁ l₂ : Lens A B} → let open Lens in Univalence (a ⊔ b) → l₁ ≡ l₂ ↔ ∃ λ (eq : R l₁ ≃ R l₂) → (∀ x → _≃_.to eq (remainder l₁ x) ≡ remainder l₂ x) × (∀ x → get l₁ x ≡ get l₂ x) equality-characterisation₃ {l₁ = l₁} {l₂ = l₂} univ = l₁ ≡ l₂ ↔⟨ inverse $ Eq.≃-≡ Lens≃Higher-lens ⟩ high l₁ ≡ high l₂ ↝⟨ H.equality-characterisation₃ univ ⟩□ (∃ λ (eq : R l₁ ≃ R l₂) → (∀ x → _≃_.to eq (remainder l₁ x) ≡ remainder l₂ x) × (∀ x → get l₁ x ≡ get l₂ x)) □ where open Lens -- And a final one. @0 equality-characterisation₄ : {A : Set a} {B : Set b} {l₁ l₂ : Lens A B} → let open Lens in Univalence (a ⊔ b) → l₁ ≡ l₂ ↔ ∃ λ (eq : R l₁ ≃ R l₂) → ∀ p → _≃ᴱ_.from (equiv l₁) (_≃_.from eq (proj₁ p) , proj₂ p) ≡ _≃ᴱ_.from (equiv l₂) p equality-characterisation₄ {l₁ = l₁} {l₂} univ = l₁ ≡ l₂ ↔⟨ inverse $ Eq.≃-≡ Lens≃Higher-lens ⟩ high l₁ ≡ high l₂ ↝⟨ H.equality-characterisation₄ univ ⟩□ (∃ λ (eq : R l₁ ≃ R l₂) → ∀ p → _≃ᴱ_.from (equiv l₁) (_≃_.from eq (proj₁ p) , proj₂ p) ≡ _≃ᴱ_.from (equiv l₂) p) □ where open Lens -- ------------------------------------------------------------------------ -- -- More lens equalities -- If the forward direction of an equivalence with erased proofs is -- Lens.get l, then the setter of l can be expressed using the other -- direction of the equivalence (in erased contexts). @0 from≡set : ∀ (l : Lens A B) is-equiv → let open Lens A≃B = EEq.⟨ get l , is-equiv ⟩ in ∀ a b → _≃ᴱ_.from A≃B b ≡ set l a b from≡set l is-equiv = H.from≡set (high l) (EEq.Is-equivalenceᴱ→Is-equivalence is-equiv) -- If two lenses have equal setters, then they also have equal -- getters (in erased contexts). @0 getters-equal-if-setters-equal : let open Lens in (l₁ l₂ : Lens A B) → set l₁ ≡ set l₂ → get l₁ ≡ get l₂ getters-equal-if-setters-equal l₁ l₂ = Lens.set l₁ ≡ Lens.set l₂ ↔⟨⟩ H.Lens.set (high l₁) ≡ H.Lens.set (high l₂) ↝⟨ H.getters-equal-if-setters-equal (high l₁) (high l₂) ⟩ H.Lens.get (high l₁) ≡ H.Lens.get (high l₂) ↔⟨⟩ Lens.get l₁ ≡ Lens.get l₂ □ -- A generalisation of lenses-equal-if-setters-equal (which is defined -- below). @0 lenses-equal-if-setters-equal′ : let open Lens in {A : Set a} {B : Set b} (univ : Univalence (a ⊔ b)) (l₁ l₂ : Lens A B) (f : R l₁ → R l₂) → (B → ∀ r → ∃ λ b′ → remainder l₂ (_≃ᴱ_.from (equiv l₁) (r , b′)) ≡ f r) → (∀ a → f (remainder l₁ a) ≡ remainder l₂ a) → Lens.set l₁ ≡ Lens.set l₂ → l₁ ≡ l₂ lenses-equal-if-setters-equal′ univ l₁ l₂ f ∃≡f f-remainder≡remainder setters-equal = $⟨ H.lenses-equal-if-setters-equal′ univ (high l₁) (high l₂) f ∃≡f f-remainder≡remainder setters-equal ⟩ high l₁ ≡ high l₂ ↝⟨ Eq.≃-≡ Lens≃Higher-lens {x = l₁} {y = l₂} ⟩□ l₁ ≡ l₂ □ -- If the codomain of a lens is inhabited when it is merely inhabited -- and the remainder type is inhabited, then this lens is equal to -- another lens if their setters are equal (in erased contexts, -- assuming univalence). @0 lenses-equal-if-setters-equal : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → (l₁ l₂ : Lens A B) → (Lens.R l₁ → ∥ B ∥ → B) → Lens.set l₁ ≡ Lens.set l₂ → l₁ ≡ l₂ lenses-equal-if-setters-equal univ l₁ l₂ inh′ setters-equal = $⟨ H.lenses-equal-if-setters-equal univ (high l₁) (high l₂) inh′ setters-equal ⟩ high l₁ ≡ high l₂ ↝⟨ Eq.≃-≡ Lens≃Higher-lens {x = l₁} {y = l₂} ⟩□ l₁ ≡ l₂ □ -- If a lens has a propositional remainder type, then this lens is -- equal to another lens if their setters are equal (in erased -- contexts, assuming univalence). @0 lenses-equal-if-setters-equal-and-remainder-propositional : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → (l₁ l₂ : Lens A B) → Is-proposition (Lens.R l₂) → Lens.set l₁ ≡ Lens.set l₂ → l₁ ≡ l₂ lenses-equal-if-setters-equal-and-remainder-propositional univ l₁ l₂ R₂-prop setters-equal = $⟨ H.lenses-equal-if-setters-equal-and-remainder-propositional univ (high l₁) (high l₂) R₂-prop setters-equal ⟩ high l₁ ≡ high l₂ ↝⟨ Eq.≃-≡ Lens≃Higher-lens {x = l₁} {y = l₂} ⟩□ l₁ ≡ l₂ □ -- The functions ≃ᴱ→Lens and ≃ᴱ→Lens′ are pointwise equal (when -- applicable, in erased contexts, assuming univalence). @0 ≃ᴱ→Lens≡≃ᴱ→Lens′ : {A B : Set a} → Univalence a → (A≃B : A ≃ᴱ B) → ≃ᴱ→Lens A≃B ≡ ≃ᴱ→Lens′ A≃B ≃ᴱ→Lens≡≃ᴱ→Lens′ {B = B} univ A≃B = _↔_.from (equality-characterisation₃ univ) ( (Erased ∥ ↑ _ B ∥ ↔⟨ Erased-cong (∥∥-cong Bijection.↑↔) ⟩□ Erased ∥ B ∥ □) , (λ _ → refl _) , (λ _ → refl _) ) -- If the getter of a lens is an equivalence with erased proofs, then -- the lens formed using the equivalence (using ≃ᴱ→Lens) is equal to -- the lens (in erased contexts, assuming univalence). @0 get-equivalence→≡≃ᴱ→Lens : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → (l : Lens A B) → (eq : Is-equivalenceᴱ (Lens.get l)) → l ≡ ≃ᴱ→Lens EEq.⟨ Lens.get l , eq ⟩ get-equivalence→≡≃ᴱ→Lens {A = A} {B = B} univ l eq = lenses-equal-if-setters-equal-and-remainder-propositional univ l (≃ᴱ→Lens EEq.⟨ Lens.get l , eq ⟩) (H-level-Erased 1 truncation-is-proposition) (⟨ext⟩ λ a → ⟨ext⟩ λ b → set l a b ≡⟨ sym $ from≡set l eq a b ⟩ _≃ᴱ_.from A≃B b ≡⟨⟩ set (≃ᴱ→Lens A≃B) a b ∎) where open Lens A≃B : A ≃ᴱ B A≃B = EEq.⟨ _ , eq ⟩ -- A variant of get-equivalence→≡≃ᴱ→Lens. @0 get-equivalence→≡≃ᴱ→Lens′ : {A B : Set a} → Univalence a → (l : Lens A B) → (eq : Is-equivalenceᴱ (Lens.get l)) → l ≡ ≃ᴱ→Lens′ EEq.⟨ Lens.get l , eq ⟩ get-equivalence→≡≃ᴱ→Lens′ {A = A} {B = B} univ l eq = l ≡⟨ get-equivalence→≡≃ᴱ→Lens univ l eq ⟩ ≃ᴱ→Lens A≃B ≡⟨ ≃ᴱ→Lens≡≃ᴱ→Lens′ univ A≃B ⟩∎ ≃ᴱ→Lens′ A≃B ∎ where A≃B = EEq.⟨ Lens.get l , eq ⟩ ------------------------------------------------------------------------ -- Some lens isomorphisms -- A generalised variant of Lens preserves equivalences with erased -- proofs. Lens-cong′ : A₁ ≃ᴱ A₂ → B₁ ≃ᴱ B₂ → (∃ λ (R : Set r) → A₁ ≃ᴱ (R × B₁) × Erased (R → ∥ B₁ ∥)) ≃ᴱ (∃ λ (R : Set r) → A₂ ≃ᴱ (R × B₂) × Erased (R → ∥ B₂ ∥)) Lens-cong′ A₁≃A₂ B₁≃B₂ = ∃-cong λ _ → EEq.≃ᴱ-cong ext A₁≃A₂ (F.id ×-cong B₁≃B₂) ×-cong Erased-cong (→-cong ext F.id (∥∥-cong B₁≃B₂)) -- Lens preserves level-preserving equivalences with erased proofs. Lens-cong : {A₁ A₂ : Set a} {B₁ B₂ : Set b} → A₁ ≃ᴱ A₂ → B₁ ≃ᴱ B₂ → Lens A₁ B₁ ≃ᴱ Lens A₂ B₂ Lens-cong {A₁ = A₁} {A₂ = A₂} {B₁ = B₁} {B₂ = B₂} A₁≃A₂ B₁≃B₂ = Lens A₁ B₁ ↔⟨ Lens-as-Σ ⟩ (∃ λ R → A₁ ≃ᴱ (R × B₁) × Erased (R → ∥ B₁ ∥)) ↝⟨ Lens-cong′ A₁≃A₂ B₁≃B₂ ⟩ (∃ λ R → A₂ ≃ᴱ (R × B₂) × Erased (R → ∥ B₂ ∥)) ↔⟨ inverse Lens-as-Σ ⟩□ Lens A₂ B₂ □ -- If B is a proposition, then Lens A B is equivalent (with erased -- proofs) to A → B (assuming univalence). lens-to-proposition≃ᴱget : {A : Set a} {B : Set b} → @0 Univalence (a ⊔ b) → @0 Is-proposition B → Lens A B ≃ᴱ (A → B) lens-to-proposition≃ᴱget {b = b} {A = A} {B = B} univ prop = EEq.↔→≃ᴱ get from refl (λ l → let lemma = ↑ b A ↔⟨ Bijection.↑↔ ⟩ A ↝⟨ EEq.≃ᴱ→≃ (equiv l) ⟩ R l × B ↝⟨ (EEq.≃ᴱ→≃ $ drop-⊤-right λ r → _⇔_.to EEq.Contractibleᴱ⇔≃ᴱ⊤ $ PT.rec (EEq.Contractibleᴱ-propositional ext) (λ b → EEq.inhabited→Is-proposition→Contractibleᴱ b prop) (inhabited l r)) ⟩□ R l □ in _↔_.from (equality-characterisation₂ univ) (lemma , λ _ → refl _)) where open Lens from = λ get → record { R = ↑ b A ; equiv = A ↔⟨ inverse Bijection.↑↔ ⟩ ↑ b A ↝⟨ (inverse $ drop-⊤-right λ (lift a) → EEq.inhabited→Is-proposition→≃ᴱ⊤ (get a) prop) ⟩□ ↑ b A × B □ ; inhabited = ∣_∣ ⊚ get ⊚ lower } _ : {A : Set a} {B : Set b} (@0 univ : Univalence (a ⊔ b)) (@0 prop : Is-proposition B) (l : Lens A B) → _≃ᴱ_.to (lens-to-proposition≃ᴱget univ prop) l ≡ Lens.get l _ = λ _ _ _ → refl _ -- If B is contractible (with an erased proof), then Lens A B is -- equivalent (with erased proofs) to ⊤ (assuming univalence). lens-to-contractible≃ᴱ⊤ : {A : Set a} {B : Set b} → @0 Univalence (a ⊔ b) → Contractibleᴱ B → Lens A B ≃ᴱ ⊤ lens-to-contractible≃ᴱ⊤ {A = A} {B} univ cB = Lens A B ↝⟨ lens-to-proposition≃ᴱget univ (mono₁ 0 (EEq.Contractibleᴱ→Contractible cB)) ⟩ (A → B) ↝⟨ →-cong ext F.id $ _⇔_.to EEq.Contractibleᴱ⇔≃ᴱ⊤ cB ⟩ (A → ⊤) ↔⟨ →-right-zero ⟩□ ⊤ □ -- Lens A ⊥ is equivalent (with erased proofs) to ¬ A (assuming -- univalence). lens-to-⊥≃ᴱ¬ : {A : Set a} → @0 Univalence (a ⊔ b) → Lens A (⊥ {ℓ = b}) ≃ᴱ (¬ A) lens-to-⊥≃ᴱ¬ {A = A} univ = Lens A ⊥ ↝⟨ lens-to-proposition≃ᴱget univ ⊥-propositional ⟩ (A → ⊥) ↝⟨ inverse $ ¬↔→⊥ ext ⟩□ ¬ A □ -- If A is contractible (with an erased proof), then Lens A B is -- equivalent (with erased proofs) to Contractibleᴱ B (assuming -- univalence). lens-from-contractible≃ᴱcodomain-contractible : {A : Set a} {B : Set b} → @0 Univalence (a ⊔ b) → Contractibleᴱ A → Lens A B ≃ᴱ Contractibleᴱ B lens-from-contractible≃ᴱcodomain-contractible {A = A} {B} univ cA = Lens A B ↔⟨ Lens-as-Σ ⟩ (∃ λ R → A ≃ᴱ (R × B) × Erased (R → ∥ B ∥)) ↝⟨ (∃-cong λ _ → ×-cong₁ λ _ → EEq.≃ᴱ-cong ext (_⇔_.to EEq.Contractibleᴱ⇔≃ᴱ⊤ cA) F.id) ⟩ (∃ λ R → ⊤ ≃ᴱ (R × B) × Erased (R → ∥ B ∥)) ↝⟨ (∃-cong λ _ → ×-cong₁ λ _ → EEq.inverse-equivalence ext) ⟩ (∃ λ R → (R × B) ≃ᴱ ⊤ × Erased (R → ∥ B ∥)) ↝⟨ (∃-cong λ _ → ×-cong₁ λ _ → inverse $ EEq.Contractibleᴱ≃ᴱ≃ᴱ⊤ ext) ⟩ (∃ λ R → Contractibleᴱ (R × B) × Erased (R → ∥ B ∥)) ↝⟨ (∃-cong λ _ → ×-cong₁ λ _ → EEq.Contractibleᴱ-commutes-with-× ext) ⟩ (∃ λ R → (Contractibleᴱ R × Contractibleᴱ B) × Erased (R → ∥ B ∥)) ↔⟨ (∃-cong λ _ → inverse ×-assoc) ⟩ (∃ λ R → Contractibleᴱ R × Contractibleᴱ B × Erased (R → ∥ B ∥)) ↝⟨ (∃-cong λ _ → ∃-cong λ cR → ∃-cong λ _ → Erased-cong ( →-cong ext (_⇔_.to EEq.Contractibleᴱ⇔≃ᴱ⊤ cR) F.id)) ⟩ (∃ λ R → Contractibleᴱ R × Contractibleᴱ B × Erased (⊤ → ∥ B ∥)) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → Erased-cong Π-left-identity) ⟩ (∃ λ R → Contractibleᴱ R × Contractibleᴱ B × Erased ∥ B ∥) ↔⟨ (∃-cong λ _ → ×-comm) ⟩ (∃ λ R → (Contractibleᴱ B × Erased ∥ B ∥) × Contractibleᴱ R) ↔⟨ ∃-comm ⟩ (Contractibleᴱ B × Erased ∥ B ∥) × (∃ λ R → Contractibleᴱ R) ↝⟨ (drop-⊤-right λ _ → EEq.∃Contractibleᴱ≃ᴱ⊤ ext univ) ⟩ Contractibleᴱ B × Erased ∥ B ∥ ↔⟨ (∃-cong λ cB → Erased-cong (inhabited⇒∥∥↔⊤ ∣ proj₁ cB ∣)) ⟩ Contractibleᴱ B × Erased ⊤ ↔⟨ (drop-⊤-right λ _ → Erased-⊤↔⊤) ⟩□ Contractibleᴱ B □ -- Lens ⊥ B is equivalent (with erased proofs) to the unit type -- (assuming univalence). lens-from-⊥↔⊤ : {B : Set b} → Univalence (a ⊔ b) → Lens (⊥ {ℓ = a}) B ≃ᴱ ⊤ lens-from-⊥↔⊤ {B = B} univ = _⇔_.to EEq.Contractibleᴱ⇔≃ᴱ⊤ $ ≃ᴱ×→Lens (⊥ ↔⟨ inverse ×-left-zero ⟩□ ⊥ × B □) , [ (λ l → _↔_.from (equality-characterisation₂ univ) ( (⊥ × Erased ∥ B ∥ ↔⟨ ×-left-zero ⟩ ⊥₀ ↝⟨ lemma l ⟩□ R l □) , λ x → ⊥-elim x )) ] where open Lens @0 lemma : (l : Lens ⊥ B) → ⊥₀ ≃ R l lemma l = Eq.↔→≃ ⊥-elim whatever whatever (λ x → ⊥-elim x) where whatever : (r : R l) → P r whatever r = ⊥-elim {ℓ = lzero} $ PT.rec ⊥-propositional (λ b → ⊥-elim (_≃ᴱ_.from (equiv l) (r , b))) (inhabited l r) -- There is an equivalence with erased proofs between A ≃ᴱ B and -- ∃ λ (l : Lens A B) → Is-equivalenceᴱ (Lens.get l) (assuming -- univalence). -- -- See also ≃≃≊ below. ≃ᴱ-≃ᴱ-Σ-Lens-Is-equivalenceᴱ-get : {A : Set a} {B : Set b} → @0 Univalence (a ⊔ b) → (A ≃ᴱ B) ≃ᴱ (∃ λ (l : Lens A B) → Is-equivalenceᴱ (Lens.get l)) ≃ᴱ-≃ᴱ-Σ-Lens-Is-equivalenceᴱ-get univ = EEq.↔→≃ᴱ (λ A≃B → ≃ᴱ→Lens A≃B , _≃ᴱ_.is-equivalence A≃B) (λ (l , eq) → EEq.⟨ Lens.get l , eq ⟩) (λ (l , eq) → Σ-≡,≡→≡ (sym $ get-equivalence→≡≃ᴱ→Lens univ l eq) (EEq.Is-equivalenceᴱ-propositional ext _ _ _)) (λ _ → EEq.to≡to→≡ ext (refl _)) -- The right-to-left direction of ≃ᴱ-≃ᴱ-Σ-Lens-Is-equivalenceᴱ-get -- returns the lens's getter (and some proof). to-from-≃ᴱ-≃ᴱ-Σ-Lens-Is-equivalenceᴱ-get≡get : {A : Set a} {B : Set b} → (@0 univ : Univalence (a ⊔ b)) (p@(l , _) : ∃ λ (l : Lens A B) → Is-equivalenceᴱ (Lens.get l)) → _≃ᴱ_.to (_≃ᴱ_.from (≃ᴱ-≃ᴱ-Σ-Lens-Is-equivalenceᴱ-get univ) p) ≡ Lens.get l to-from-≃ᴱ-≃ᴱ-Σ-Lens-Is-equivalenceᴱ-get≡get _ _ = refl _ ------------------------------------------------------------------------ -- Results relating different kinds of lenses -- In general there is no split surjection from Lens A B to -- Traditionalᴱ.Lens A B (assuming univalence). ¬Lens↠Traditional-lens : @0 Univalence lzero → @0 Univalence a → ∃ λ (A : Set a) → ¬ (Lens A ⊤ ↠ Traditionalᴱ.Lens A ⊤) ¬Lens↠Traditional-lens {a = a} univ₀ univ = A′ , Stable-¬ _ [ (Lens A′ ⊤ ↠ Traditionalᴱ.Lens A′ ⊤) ↝⟨ (λ f → from-equivalence Traditionalᴱ.Lens≃Traditional-lens F.∘ f F.∘ from-equivalence (inverse Lens≃Higher-lens)) ⟩ (H.Lens A′ ⊤ ↠ T.Lens A′ ⊤) ↝⟨ proj₂ $ H.¬Lens↠Traditional-lens univ₀ univ ⟩□ ⊥ □ ] where A′ = _ -- In general there is no equivalence with erased proofs between -- Lens A B and Traditionalᴱ.Lens A B (assuming univalence). ¬Lens≃ᴱTraditional-lens : @0 Univalence lzero → @0 Univalence a → ∃ λ (A : Set a) → ¬ (Lens A ⊤ ≃ᴱ Traditionalᴱ.Lens A ⊤) ¬Lens≃ᴱTraditional-lens univ₀ univ = A′ , Stable-¬ _ [ (Lens A′ ⊤ ≃ᴱ Traditionalᴱ.Lens A′ ⊤) ↝⟨ from-equivalence ⊚ EEq.≃ᴱ→≃ ⟩ (Lens A′ ⊤ ↠ Traditionalᴱ.Lens A′ ⊤) ↝⟨ proj₂ $ ¬Lens↠Traditional-lens univ₀ univ ⟩□ ⊥ □ ] where A′ = _ -- Some lemmas used in Lens↠Traditional-lens and -- Lens≃ᴱTraditional-lens below. private module Lens≃ᴱTraditional-lens {A : Set a} {B : Set b} (@0 A-set : Is-set A) where from : Block "conversion" → Traditionalᴱ.Lens A B → Lens A B from ⊠ l = ≃ᴱ×→Lens {R = ∃ λ (f : B → A) → Erased (∀ b b′ → set (f b) b′ ≡ f b′)} (EEq.↔→≃ᴱ (λ a → (set a , [ set-set a ]) , get a) (λ ((f , _) , b) → f b) (λ ((f , [ h ]) , b) → let irr = {p q : Erased (∀ b b′ → set (f b) b′ ≡ f b′)} → p ≡ q irr = (H-level-Erased 1 ( Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → A-set)) _ _ lemma = get (f b) ≡⟨ cong get (sym (h b b)) ⟩ get (set (f b) b) ≡⟨ get-set (f b) b ⟩∎ b ∎ in (set (f b) , [ set-set (f b) ]) , get (f b) ≡⟨ cong₂ _,_ (Σ-≡,≡→≡ (⟨ext⟩ (h b)) irr) lemma ⟩∎ (f , [ h ]) , b ∎) (λ a → set a (get a) ≡⟨ set-get a ⟩∎ a ∎)) where open Traditionalᴱ.Lens l to∘from : ∀ bc l → Lens.traditional-lens (from bc l) ≡ l to∘from ⊠ l = _↔_.from Traditionalᴱ.equality-characterisation₁ ( refl _ , refl _ , [ (λ a _ → B-set a _ _) , (λ _ → A-set _ _) , (λ _ _ _ → A-set _ _) ] ) where open Traditionalᴱ.Lens l @0 B-set : A → Is-set B B-set a = Traditionalᴱ.h-level-respects-lens-from-inhabited 2 l a A-set @0 from∘to : Univalence (a ⊔ b) → ∀ bc l → from bc (Lens.traditional-lens l) ≡ l from∘to univ ⊠ l′ = _↔_.from (equality-characterisation₄ univ) ( lemma , λ p → _≃ᴱ_.from l (subst (λ _ → R) (refl _) (proj₁ p) , proj₂ p) ≡⟨ cong (λ r → _≃ᴱ_.from l (r , proj₂ p)) $ subst-refl _ _ ⟩∎ _≃ᴱ_.from l p ∎ ) where open Lens l′ renaming (equiv to l) B-set : (B → R) → ∥ B ∥ → Is-set B B-set f = PT.rec (H-level-propositional ext 2) (λ b → $⟨ (λ {_ _} → A-set) ⟩ Is-set A ↝⟨ H-level-cong _ 2 (EEq.≃ᴱ→≃ l) ⟩ Is-set (R × B) ↝⟨ proj₂-closure (f b) 2 ⟩□ Is-set B □) R-set : ∥ B ∥ → Is-set R R-set = PT.rec (H-level-propositional ext 2) (λ b → $⟨ (λ {_ _} → A-set) ⟩ Is-set A ↝⟨ H-level-cong _ 2 (EEq.≃ᴱ→≃ l) ⟩ Is-set (R × B) ↝⟨ proj₁-closure (const b) 2 ⟩□ Is-set R □) lemma′ : (∥ B ∥ × (∥ B ∥ → R)) ≃ R lemma′ = Eq.↔→≃ (λ (b , f) → f b) (λ r → inhabited r , λ _ → r) refl (λ (b , f) → curry (_↔_.to ≡×≡↔≡) (PT.truncation-is-proposition _ _) (⟨ext⟩ λ b′ → f b ≡⟨ cong f (PT.truncation-is-proposition _ _) ⟩∎ f b′ ∎)) lemma = (∃ λ (f : B → A) → Erased (∀ b b′ → _≃ᴱ_.from l (proj₁ (_≃ᴱ_.to l (f b)) , b′) ≡ f b′)) × Erased ∥ B ∥ ↔⟨ (∃-cong λ _ → erased Erased↔) ×-cong erased Erased↔ ⟩ (∃ λ (f : B → A) → ∀ b b′ → _≃ᴱ_.from l (proj₁ (_≃ᴱ_.to l (f b)) , b′) ≡ f b′) × ∥ B ∥ ↔⟨ ×-comm ⟩ (∥ B ∥ × ∃ λ (f : B → A) → ∀ b b′ → _≃ᴱ_.from l (proj₁ (_≃ᴱ_.to l (f b)) , b′) ≡ f b′) ↝⟨ (∃-cong λ _ → Σ-cong (→-cong ext F.id (EEq.≃ᴱ→≃ l)) λ f → ∀-cong ext λ b → ∀-cong ext λ b′ → ≡⇒↝ _ $ cong (_≃ᴱ_.from l (proj₁ (_≃ᴱ_.to l (f b)) , b′) ≡_) $ sym $ _≃ᴱ_.left-inverse-of l _) ⟩ (∥ B ∥ × ∃ λ (f : B → R × B) → ∀ b b′ → _≃ᴱ_.from l (proj₁ (f b) , b′) ≡ _≃ᴱ_.from l (f b′)) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → Eq.≃-≡ (inverse (EEq.≃ᴱ→≃ l))) ⟩ (∥ B ∥ × ∃ λ (f : B → R × B) → ∀ b b′ → (proj₁ (f b) , b′) ≡ f b′) ↔⟨ (∃-cong λ _ → Σ-cong ΠΣ-comm λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → inverse $ ≡×≡↔≡) ⟩ (∥ B ∥ × ∃ λ (p : (B → R) × (B → B)) → ∀ b b′ → proj₁ p b ≡ proj₁ p b′ × b′ ≡ proj₂ p b′) ↔⟨ (∃-cong λ _ → inverse Σ-assoc) ⟩ (∥ B ∥ × ∃ λ (f : B → R) → ∃ λ (g : B → B) → ∀ b b′ → f b ≡ f b′ × b′ ≡ g b′) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∀-cong ext λ _ → ΠΣ-comm) ⟩ (∥ B ∥ × ∃ λ (f : B → R) → ∃ λ (g : B → B) → ∀ b → (∀ b′ → f b ≡ f b′) × (∀ b′ → b′ ≡ g b′)) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ΠΣ-comm) ⟩ (∥ B ∥ × ∃ λ (f : B → R) → ∃ λ (g : B → B) → Constant f × (B → ∀ b → b ≡ g b)) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∥ B ∥ × ∃ λ (f : B → R) → Constant f × ∃ λ (g : B → B) → B → ∀ b → b ≡ g b) ↔⟨ (∃-cong λ _ → Σ-assoc) ⟩ (∥ B ∥ × (∃ λ (f : B → R) → Constant f) × (∃ λ (g : B → B) → B → ∀ b → b ≡ g b)) ↔⟨ (∃-cong λ ∥b∥ → ∃-cong $ uncurry λ f _ → ∃-cong λ _ → inverse $ →-intro ext (λ _ → B-set f ∥b∥)) ⟩ (∥ B ∥ × (∃ λ (f : B → R) → Constant f) × (∃ λ (g : B → B) → ∀ b → b ≡ g b)) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → Eq.extensionality-isomorphism ext) ⟩ (∥ B ∥ × (∃ λ (f : B → R) → Constant f) × (∃ λ (g : B → B) → F.id ≡ g)) ↔⟨ (∃-cong λ _ → drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _) ⟩ (∥ B ∥ × ∃ λ (f : B → R) → Constant f) ↝⟨ (∃-cong λ ∥b∥ → PT.constant-function≃∥inhabited∥⇒inhabited (R-set ∥b∥)) ⟩ (∥ B ∥ × (∥ B ∥ → R)) ↔⟨ lemma′ ⟩□ R □ equiv : Block "conversion" → @0 Univalence (a ⊔ b) → Lens A B ≃ᴱ Traditionalᴱ.Lens A B equiv bc univ = EEq.↔→≃ᴱ _ (from bc) (to∘from bc) (from∘to univ bc) -- If the domain A is a set, then there is a split surjection from -- Lens A B to Traditionalᴱ.Lens A B. Lens↠Traditional-lens : Block "conversion" → @0 Is-set A → Lens A B ↠ Traditionalᴱ.Lens A B Lens↠Traditional-lens {A = A} {B = B} bc A-set = record { logical-equivalence = record { to = Lens.traditional-lens ; from = Lens≃ᴱTraditional-lens.from A-set bc } ; right-inverse-of = Lens≃ᴱTraditional-lens.to∘from A-set bc } -- The split surjection above preserves getters and setters. Lens↠Traditional-lens-preserves-getters-and-setters : {A : Set a} (b : Block "conversion") (@0 s : Is-set A) → Preserves-getters-and-setters-⇔ A B (_↠_.logical-equivalence (Lens↠Traditional-lens b s)) Lens↠Traditional-lens-preserves-getters-and-setters ⊠ _ = (λ _ → refl _ , refl _) , (λ _ → refl _ , refl _) -- If the domain A is a set, then there is an equivalence with erased -- proofs between Traditionalᴱ.Lens A B and Lens A B (assuming -- univalence). Lens≃ᴱTraditional-lens : {A : Set a} {B : Set b} → Block "conversion" → @0 Univalence (a ⊔ b) → @0 Is-set A → Lens A B ≃ᴱ Traditionalᴱ.Lens A B Lens≃ᴱTraditional-lens bc univ A-set = Lens≃ᴱTraditional-lens.equiv A-set bc univ -- The equivalence preserves getters and setters. Lens≃ᴱTraditional-lens-preserves-getters-and-setters : {A : Set a} {B : Set b} (bc : Block "conversion") (@0 univ : Univalence (a ⊔ b)) (@0 s : Is-set A) → Preserves-getters-and-setters-⇔ A B (_≃ᴱ_.logical-equivalence (Lens≃ᴱTraditional-lens bc univ s)) Lens≃ᴱTraditional-lens-preserves-getters-and-setters bc _ = Lens↠Traditional-lens-preserves-getters-and-setters bc -- If the codomain B is an inhabited set, then Lens A B and -- Traditionalᴱ.Lens A B are logically equivalent. -- -- This definition is inspired by the statement of Corollary 13 from -- "Algebras and Update Strategies" by Johnson, Rosebrugh and Wood. Lens⇔Traditional-lens : @0 Is-set B → B → Lens A B ⇔ Traditionalᴱ.Lens A B Lens⇔Traditional-lens {B = B} {A = A} B-set b₀ = record { to = Lens.traditional-lens ; from = from } where from : Traditionalᴱ.Lens A B → Lens A B from l = ≃ᴱ×→Lens {R = ∃ λ (a : A) → Erased (get a ≡ b₀)} (EEq.↔→≃ᴱ (λ a → (set a b₀ , [ get-set a b₀ ]) , get a) (λ ((a , _) , b) → set a b) (λ ((a , [ h ]) , b) → let lemma = set (set a b) b₀ ≡⟨ set-set a b b₀ ⟩ set a b₀ ≡⟨ cong (set a) (sym h) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎ in ( (set (set a b) b₀ , [ get-set (set a b) b₀ ]) , get (set a b) ) ≡⟨ cong₂ _,_ (Σ-≡,≡→≡ lemma (H-level-Erased 1 B-set _ _)) (get-set a b) ⟩∎ ((a , [ h ]) , b) ∎) (λ a → set (set a b₀) (get a) ≡⟨ set-set a b₀ (get a) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎)) where open Traditionalᴱ.Lens l -- The logical equivalence preserves getters and setters (in an erased -- context). @0 Lens⇔Traditional-lens-preserves-getters-and-setters : {B : Set b} (s : Is-set B) (b₀ : B) → Preserves-getters-and-setters-⇔ A B (Lens⇔Traditional-lens s b₀) Lens⇔Traditional-lens-preserves-getters-and-setters _ b₀ = (λ _ → refl _ , refl _) , (λ l → refl _ , ⟨ext⟩ λ a → ⟨ext⟩ λ b → set l (set l a b₀) b ≡⟨ set-set l _ _ _ ⟩∎ set l a b ∎) where open Traditionalᴱ.Lens ------------------------------------------------------------------------ -- Some results related to h-levels -- If the domain of a lens is inhabited and has h-level n, then the -- codomain also has h-level n (in erased contexts). @0 h-level-respects-lens-from-inhabited : Lens A B → A → H-level n A → H-level n B h-level-respects-lens-from-inhabited l = H.h-level-respects-lens-from-inhabited (high l) -- This is not necessarily true for arbitrary domains (assuming -- univalence). ¬-h-level-respects-lens : @0 Univalence (a ⊔ b) → ¬ (∀ n {A : Set a} {B : Set b} → Lens A B → H-level n A → H-level n B) ¬-h-level-respects-lens univ = Stable-¬ _ [ (∀ n {A B} → Lens A B → H-level n A → H-level n B) ↝⟨ (λ hyp n l → hyp n (Higher-lens→Lens l)) ⟩ (∀ n {A B} → H.Lens A B → H-level n A → H-level n B) ↝⟨ H.¬-h-level-respects-lens univ ⟩□ ⊥ □ ] -- In fact, there is a lens with a proposition as its domain and a -- non-set as its codomain (assuming univalence). lens-from-proposition-to-non-set : @0 Univalence (# 0) → ∃ λ (A : Set a) → ∃ λ (B : Set b) → Lens A B × Is-proposition A × ¬ Is-set B lens-from-proposition-to-non-set {a = a} {b = b} univ = ⊥ , ↑ b 𝕊¹ , record { R = ⊥ ; equiv = ⊥ ↔⟨ inverse ×-left-zero ⟩□ ⊥ × ↑ _ 𝕊¹ □ ; inhabited = ⊥-elim } , ⊥-propositional , Stable-¬ _ [ Is-set (↑ b 𝕊¹) ↝⟨ proj₂ $ proj₂ $ proj₂ $ proj₂ $ H.lens-from-proposition-to-non-set {a = a} univ ⟩□ ⊥₀ □ ] -- Lenses with contractible domains have contractible codomains (in -- erased contexts). @0 contractible-to-contractible : Lens A B → Contractible A → Contractible B contractible-to-contractible l = H.contractible-to-contractible (high l) -- A variant for Contractibleᴱ. Contractibleᴱ→Contractibleᴱ : Lens A B → Contractibleᴱ A → Contractibleᴱ B Contractibleᴱ→Contractibleᴱ = Traditionalᴱ.Contractibleᴱ→Contractibleᴱ ⊚ Lens.traditional-lens -- If the domain type of a lens is contractible, then the remainder -- type is also contractible (in erased contexts). @0 domain-contractible⇒remainder-contractible : (l : Lens A B) → Contractible A → Contractible (Lens.R l) domain-contractible⇒remainder-contractible = H.domain-contractible⇒remainder-contractible ⊚ high -- A variant for Contractibleᴱ. domain-Contractibleᴱ⇒remainder-Contractibleᴱ : (l : Lens A B) → Contractibleᴱ A → Contractibleᴱ (Lens.R l) domain-Contractibleᴱ⇒remainder-Contractibleᴱ {A = A} {B = B} l = Contractibleᴱ A ↝⟨ EEq.Contractibleᴱ-respects-surjection (_≃ᴱ_.to equiv) (_≃_.split-surjective (EEq.≃ᴱ→≃ equiv)) ⟩ Contractibleᴱ (R × B) ↝⟨ _≃ᴱ_.to (EEq.Contractibleᴱ-commutes-with-× ext) ⟩ Contractibleᴱ R × Contractibleᴱ B ↝⟨ proj₁ ⟩□ Contractibleᴱ R □ where open Lens l -- If the domain type of a lens has h-level n, then the remainder type -- also has h-level n (in erased contexts). @0 remainder-has-same-h-level-as-domain : (l : Lens A B) → ∀ n → H-level n A → H-level n (Lens.R l) remainder-has-same-h-level-as-domain l n = H.remainder-has-same-h-level-as-domain (high l) n -- If the getter function is an equivalence, then the remainder type -- is propositional (in erased contexts). @0 get-equivalence→remainder-propositional : (l : Lens A B) → Is-equivalence (Lens.get l) → Is-proposition (Lens.R l) get-equivalence→remainder-propositional = H.get-equivalence→remainder-propositional ⊚ high -- If the getter function is pointwise equal to the identity function, -- then the remainder type is propositional (in erased contexts). @0 get≡id→remainder-propositional : (l : Lens A A) → (∀ a → Lens.get l a ≡ a) → Is-proposition (Lens.R l) get≡id→remainder-propositional = H.get≡id→remainder-propositional ⊚ high -- It is not necessarily the case that contractibility of A implies -- contractibility of Lens A B (assuming univalence). ¬-Contractible-closed-domain : ∀ {a b} → @0 Univalence (a ⊔ b) → ¬ ({A : Set a} {B : Set b} → Contractible A → Contractible (Lens A B)) ¬-Contractible-closed-domain univ = Stable-¬ _ [ (∀ {A B} → Contractible A → Contractible (Lens A B)) ↝⟨ (λ hyp c → H-level-cong _ 0 Lens≃Higher-lens (hyp c)) ⟩ (∀ {A B} → Contractible A → Contractible (H.Lens A B)) ↝⟨ H.¬-Contractible-closed-domain univ ⟩□ ⊥ □ ] -- Contractibleᴱ is closed under Lens A (assuming univalence). Contractibleᴱ-closed-codomain : {A : Set a} {B : Set b} → @0 Univalence (a ⊔ b) → Contractibleᴱ B → Contractibleᴱ (Lens A B) Contractibleᴱ-closed-codomain {A = A} {B} univ cB = $⟨ lens-to-contractible≃ᴱ⊤ univ cB ⟩ Lens A B ≃ᴱ ⊤ ↝⟨ _⇔_.from EEq.Contractibleᴱ⇔≃ᴱ⊤ ⟩□ Contractibleᴱ (Lens A B) □ -- If B is a proposition, then Lens A B is also a proposition -- (in erased contexts, assuming univalence). @0 Is-proposition-closed-codomain : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → Is-proposition B → Is-proposition (Lens A B) Is-proposition-closed-codomain {A = A} {B = B} univ = Is-proposition B ↝⟨ H.Is-proposition-closed-codomain univ ⟩ Is-proposition (H.Lens A B) ↝⟨ H-level-cong _ 1 (inverse Lens≃Higher-lens) ⟩□ Is-proposition (Lens A B) □ -- If A is a proposition, then Lens A B is also a proposition -- (in erased contexts, assuming univalence). @0 Is-proposition-closed-domain : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → Is-proposition A → Is-proposition (Lens A B) Is-proposition-closed-domain {A = A} {B = B} univ = Is-proposition A ↝⟨ H.Is-proposition-closed-domain univ ⟩ Is-proposition (H.Lens A B) ↝⟨ H-level-cong _ 1 (inverse Lens≃Higher-lens) ⟩□ Is-proposition (Lens A B) □ -- If A is a set, then Lens A B is also a set (in erased contexts, -- assuming univalence). @0 Is-set-closed-domain : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → Is-set A → Is-set (Lens A B) Is-set-closed-domain {A = A} {B = B} univ = Is-set A ↝⟨ H.Is-set-closed-domain univ ⟩ Is-set (H.Lens A B) ↝⟨ H-level-cong _ 2 (inverse Lens≃Higher-lens) ⟩□ Is-set (Lens A B) □ -- If A has h-level n, then Lens A B has h-level 1 + n (in erased -- contexts, assuming univalence). @0 domain-0+⇒lens-1+ : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → ∀ n → H-level n A → H-level (1 + n) (Lens A B) domain-0+⇒lens-1+ {A = A} {B = B} univ n = H-level n A ↝⟨ H.domain-0+⇒lens-1+ univ n ⟩ H-level (1 + n) (H.Lens A B) ↝⟨ H-level-cong _ (1 + n) (inverse Lens≃Higher-lens) ⟩□ H-level (1 + n) (Lens A B) □ -- If B is inhabited when it is merely inhabited and A has positive -- h-level n, then Lens A B also has h-level n (in erased contexts, -- assuming univalence). @0 lens-preserves-h-level-of-domain : {A : Set a} {B : Set b} → Univalence (a ⊔ b) → (∥ B ∥ → B) → ∀ n → H-level (1 + n) A → H-level (1 + n) (Lens A B) lens-preserves-h-level-of-domain {A = A} {B = B} univ ∥B∥→B n = H-level (1 + n) A ↝⟨ EP.higher-lens-preserves-h-level-of-domain univ ∥B∥→B n ⟩ H-level (1 + n) (H.Lens A B) ↝⟨ H-level-cong _ (1 + n) (inverse Lens≃Higher-lens) ⟩□ H-level (1 + n) (Lens A B) □ ------------------------------------------------------------------------ -- An existence result -- There is, in general, no lens for the first projection from a -- Σ-type. no-first-projection-lens : ∃ λ (A : Set a) → ∃ λ (B : A → Set b) → ¬ Lens (Σ A B) A no-first-projection-lens = Non-dependent.no-first-projection-lens Lens contractible-to-contractible ------------------------------------------------------------------------ -- Some results related to the remainder type -- The remainder type of a lens l : Lens A B is, for every b : B, -- equivalent (with erased proofs) to the preimage (with an erased -- proof) of the getter with respect to b. -- -- The corresponding result in Lens.Non-dependent.Higher was pointed -- out to me by Andrea Vezzosi. remainder≃ᴱget⁻¹ᴱ : (l : Lens A B) (b : B) → Lens.R l ≃ᴱ Lens.get l ⁻¹ᴱ b remainder≃ᴱget⁻¹ᴱ l b = EEq.↔→≃ᴱ (λ r → _≃ᴱ_.from equiv (r , b) , [ get (_≃ᴱ_.from equiv (r , b)) ≡⟨⟩ proj₂ (_≃ᴱ_.to equiv (_≃ᴱ_.from equiv (r , b))) ≡⟨ cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _ ⟩∎ b ∎ ]) (λ (a , _) → remainder a) (λ (a , [ get-a≡b ]) → let lemma₁ = cong get (trans (cong (set a) (sym get-a≡b)) (_≃ᴱ_.left-inverse-of equiv _)) ≡⟨ cong-trans _ _ (_≃ᴱ_.left-inverse-of equiv _) ⟩ trans (cong get (cong (set a) (sym get-a≡b))) (cong get (_≃ᴱ_.left-inverse-of equiv _)) ≡⟨ cong₂ trans (cong-∘ _ _ (sym get-a≡b)) (sym $ cong-∘ _ _ (_≃ᴱ_.left-inverse-of equiv _)) ⟩ trans (cong (get ⊚ set a) (sym get-a≡b)) (cong proj₂ (cong (_≃ᴱ_.to equiv) (_≃ᴱ_.left-inverse-of equiv _))) ≡⟨ cong₂ (λ p q → trans p (cong proj₂ q)) (cong-sym _ get-a≡b) (_≃ᴱ_.left-right-lemma equiv _) ⟩ trans (sym (cong (get ⊚ set a) get-a≡b)) (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _)) ≡⟨ sym $ sym-sym _ ⟩ sym (sym (trans (sym (cong (get ⊚ set a) get-a≡b)) (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _)))) ≡⟨ cong sym $ sym-trans _ (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _)) ⟩ sym (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (sym (sym (cong (get ⊚ set a) get-a≡b)))) ≡⟨ cong (λ eq → sym (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) eq)) $ sym-sym (cong (get ⊚ set a) get-a≡b) ⟩∎ sym (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (cong (get ⊚ set a) get-a≡b)) ∎ lemma₂ = subst (λ a → get a ≡ b) (trans (cong (set a) (sym get-a≡b)) (set-get a)) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv (remainder a , b)) ≡⟨⟩ subst (λ a → get a ≡ b) (trans (cong (set a) (sym get-a≡b)) (_≃ᴱ_.left-inverse-of equiv _)) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡⟨ subst-∘ _ _ (trans _ (_≃ᴱ_.left-inverse-of equiv _)) ⟩ subst (_≡ b) (cong get (trans (cong (set a) (sym get-a≡b)) (_≃ᴱ_.left-inverse-of equiv _))) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡⟨ cong (λ eq → subst (_≡ b) eq (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _)) lemma₁ ⟩ subst (_≡ b) (sym (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (cong (get ⊚ set a) get-a≡b))) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡⟨ subst-trans (trans _ (cong (get ⊚ set a) get-a≡b)) ⟩ trans (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (cong (get ⊚ set a) get-a≡b)) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡⟨ elim¹ (λ eq → trans (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (cong (get ⊚ set a) eq)) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡ eq) ( trans (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (cong (get ⊚ set a) (refl _))) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡⟨ cong (λ eq → trans (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) eq) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _)) $ cong-refl _ ⟩ trans (trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (refl _)) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡⟨ cong (flip trans _) $ trans-reflʳ _ ⟩ trans (sym (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _))) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv _) ≡⟨ trans-symˡ (cong proj₂ (_≃ᴱ_.right-inverse-of equiv _)) ⟩∎ refl _ ∎) get-a≡b ⟩∎ get-a≡b ∎ in Σ-≡,≡→≡ (_≃ᴱ_.from equiv (remainder a , b) ≡⟨⟩ set a b ≡⟨ cong (set a) (sym get-a≡b) ⟩ set a (get a) ≡⟨ set-get a ⟩∎ a ∎) (subst (λ a → Erased (get a ≡ b)) (trans (cong (set a) (sym get-a≡b)) (set-get a)) [ cong proj₂ $ _≃ᴱ_.right-inverse-of equiv (remainder a , b) ] ≡⟨ push-subst-[] ⟩ [ subst (λ a → get a ≡ b) (trans (cong (set a) (sym get-a≡b)) (set-get a)) (cong proj₂ $ _≃ᴱ_.right-inverse-of equiv (remainder a , b)) ] ≡⟨ []-cong [ lemma₂ ] ⟩∎ [ get-a≡b ] ∎)) (λ r → remainder (_≃ᴱ_.from equiv (r , b)) ≡⟨⟩ proj₁ (_≃ᴱ_.to equiv (_≃ᴱ_.from equiv (r , b))) ≡⟨ cong proj₁ $ _≃ᴱ_.right-inverse-of equiv _ ⟩∎ r ∎) where open Lens l -- A corollary: Lens.get l ⁻¹ᴱ_ is constant (up to _≃ᴱ_). -- -- Paolo Capriotti discusses this kind of property -- (http://homotopytypetheory.org/2014/04/29/higher-lenses/). get⁻¹ᴱ-constant : (l : Lens A B) (b₁ b₂ : B) → Lens.get l ⁻¹ᴱ b₁ ≃ᴱ Lens.get l ⁻¹ᴱ b₂ get⁻¹ᴱ-constant l b₁ b₂ = Lens.get l ⁻¹ᴱ b₁ ↝⟨ inverse $ remainder≃ᴱget⁻¹ᴱ l b₁ ⟩ Lens.R l ↝⟨ remainder≃ᴱget⁻¹ᴱ l b₂ ⟩□ Lens.get l ⁻¹ᴱ b₂ □ -- The set function can be expressed using get⁻¹ᴱ-constant and get. -- -- Paolo Capriotti defines set in a similar way -- (http://homotopytypetheory.org/2014/04/29/higher-lenses/). set-in-terms-of-get⁻¹ᴱ-constant : (l : Lens A B) → Lens.set l ≡ λ a b → proj₁ (_≃ᴱ_.to (get⁻¹ᴱ-constant l (Lens.get l a) b) (a , [ refl _ ])) set-in-terms-of-get⁻¹ᴱ-constant l = refl _ -- The remainder function can be expressed using remainder≃ᴱget⁻¹ᴱ and -- get. remainder-in-terms-of-remainder≃ᴱget⁻¹ᴱ : (l : Lens A B) → Lens.remainder l ≡ λ a → _≃ᴱ_.from (remainder≃ᴱget⁻¹ᴱ l (Lens.get l a)) (a , [ refl _ ]) remainder-in-terms-of-remainder≃ᴱget⁻¹ᴱ l = refl _ -- The lemma get⁻¹ᴱ-constant satisfies some coherence properties. -- -- The first and third properties are discussed by Paolo Capriotti -- (http://homotopytypetheory.org/2014/04/29/higher-lenses/). @0 get⁻¹ᴱ-constant-∘ : (l : Lens A B) (b₁ b₂ b₃ : B) (p : Lens.get l ⁻¹ᴱ b₁) → _≃ᴱ_.to (get⁻¹ᴱ-constant l b₂ b₃) (_≃ᴱ_.to (get⁻¹ᴱ-constant l b₁ b₂) p) ≡ _≃ᴱ_.to (get⁻¹ᴱ-constant l b₁ b₃) p get⁻¹ᴱ-constant-∘ l _ b₂ b₃ p = from (r₂ , b₃) , [ cong proj₂ (right-inverse-of (r₂ , b₃)) ] ≡⟨ cong (λ r → from (r , b₃) , [ cong proj₂ (right-inverse-of (r , b₃)) ]) $ cong proj₁ $ right-inverse-of _ ⟩∎ from (r₁ , b₃) , [ cong proj₂ (right-inverse-of (r₁ , b₃)) ] ∎ where open Lens l open _≃ᴱ_ equiv r₁ r₂ : R r₁ = proj₁ (to (proj₁ p)) r₂ = proj₁ (to (from (r₁ , b₂))) get⁻¹ᴱ-constant-inverse : (l : Lens A B) (b₁ b₂ : B) (p : Lens.get l ⁻¹ᴱ b₁) → _≃ᴱ_.to (get⁻¹ᴱ-constant l b₁ b₂) p ≡ _≃ᴱ_.from (get⁻¹ᴱ-constant l b₂ b₁) p get⁻¹ᴱ-constant-inverse _ _ _ _ = refl _ @0 get⁻¹ᴱ-constant-id : (l : Lens A B) (b : B) (p : Lens.get l ⁻¹ᴱ b) → _≃ᴱ_.to (get⁻¹ᴱ-constant l b b) p ≡ p get⁻¹ᴱ-constant-id l b p = _≃ᴱ_.to (get⁻¹ᴱ-constant l b b) p ≡⟨ sym $ get⁻¹ᴱ-constant-∘ l b _ _ p ⟩ _≃ᴱ_.to (get⁻¹ᴱ-constant l b b) (_≃ᴱ_.to (get⁻¹ᴱ-constant l b b) p) ≡⟨⟩ _≃ᴱ_.from (get⁻¹ᴱ-constant l b b) (_≃ᴱ_.to (get⁻¹ᴱ-constant l b b) p) ≡⟨ _≃ᴱ_.left-inverse-of (get⁻¹ᴱ-constant l b b) _ ⟩∎ p ∎ -- Another kind of coherence property does not hold for -- get⁻¹ᴱ-constant. -- -- This kind of property came up in a discussion with Andrea Vezzosi. get⁻¹ᴱ-constant-not-coherent : ¬ ({A B : Set} (l : Lens A B) (b₁ b₂ : B) (f : ∀ b → Lens.get l ⁻¹ᴱ b) → _≃ᴱ_.to (get⁻¹ᴱ-constant l b₁ b₂) (f b₁) ≡ f b₂) get⁻¹ᴱ-constant-not-coherent = ({A B : Set} (l : Lens A B) (b₁ b₂ : B) (f : ∀ b → Lens.get l ⁻¹ᴱ b) → _≃ᴱ_.to (get⁻¹ᴱ-constant l b₁ b₂) (f b₁) ≡ f b₂) ↝⟨ (λ hyp → hyp l true false f) ⟩ _≃ᴱ_.to (get⁻¹ᴱ-constant l true false) (f true) ≡ f false ↝⟨ cong (proj₁ ⊚ proj₁) ⟩ true ≡ false ↝⟨ Bool.true≢false ⟩□ ⊥ □ where l : Lens (Bool × Bool) Bool l = record { R = Bool ; equiv = F.id ; inhabited = ∣_∣ } f : ∀ b → Lens.get l ⁻¹ᴱ b f b = (b , b) , [ refl _ ] -- If B is inhabited whenever it is merely inhabited, then the -- remainder type of a lens of type Lens A B can be expressed in terms -- of preimages of the lens's getter (in erased contexts). -- -- TODO: Perhaps a non-erased variant of this result could be proved -- if the inhabited field were made non-erased, possibly with ∥_∥ -- replaced by ∥_∥ᴱ. @0 remainder≃∃get⁻¹ : (l : Lens A B) (∥B∥→B : ∥ B ∥ → B) → Lens.R l ≃ ∃ λ (b : ∥ B ∥) → Lens.get l ⁻¹ (∥B∥→B b) remainder≃∃get⁻¹ = H.remainder≃∃get⁻¹ ⊚ high ------------------------------------------------------------------------ -- Lens combinators private module HLC = H.Lens-combinators module Lens-combinators where -- The definition of the identity lens is unique (in erased -- contexts), if the get function is required to be the identity -- (assuming univalence). @0 id-unique : {A : Set a} → Univalence a → ((l₁ , _) (l₂ , _) : ∃ λ (l : Lens A A) → ∀ a → Lens.get l a ≡ a) → l₁ ≡ l₂ id-unique {A = A} univ (l₁ , g₁) (l₂ , g₂) = $⟨ HLC.id-unique univ (high l₁ , g₁) (high l₂ , g₂) ⟩ high l₁ ≡ high l₂ ↝⟨ Eq.≃-≡ Lens≃Higher-lens {x = l₁} {y = l₂} ⟩□ l₁ ≡ l₂ □ -- The result of composing two lenses is unique (in erased contexts) -- if the codomain type is inhabited whenever it is merely -- inhabited, and we require that the resulting setter function is -- defined in a certain way (assuming univalence). @0 ∘-unique : let open Lens in {A : Set a} {C : Set c} → Univalence (a ⊔ c) → (∥ C ∥ → C) → ((comp₁ , _) (comp₂ , _) : ∃ λ (comp : Lens B C → Lens A B → Lens A C) → ∀ l₁ l₂ a c → set (comp l₁ l₂) a c ≡ set l₂ a (set l₁ (get l₂ a) c)) → comp₁ ≡ comp₂ ∘-unique {A = A} {C = C} univ ∥C∥→C (comp₁ , set₁) (comp₂ , set₂) = ⟨ext⟩ λ l₁ → ⟨ext⟩ λ l₂ → lenses-equal-if-setters-equal univ (comp₁ l₁ l₂) (comp₂ l₁ l₂) (λ _ → ∥C∥→C) $ ⟨ext⟩ λ a → ⟨ext⟩ λ c → set (comp₁ l₁ l₂) a c ≡⟨ set₁ _ _ _ _ ⟩ set l₂ a (set l₁ (get l₂ a) c) ≡⟨ sym $ set₂ _ _ _ _ ⟩∎ set (comp₂ l₁ l₂) a c ∎ where open Lens -- Identity lens. id : Block "id" → Lens A A id {A = A} ⊠ = record { R = Erased ∥ A ∥ ; equiv = A ↔⟨ inverse Erased-∥∥×≃ ⟩□ Erased ∥ A ∥ × A □ ; inhabited = erased } -- The identity lens is equal to the one obtained from the identity -- lens for higher lenses without erased proofs (in erased -- contexts, assuming univalence). @0 Higher-lens-id≡id : {A : Set a} (b : Block "id") (univ : Univalence a) → Higher-lens→Lens (HLC.id b) ≡ id {A = A} b Higher-lens-id≡id {A = A} ⊠ univ = _↔_.from (equality-characterisation₂ univ) ( (∥ A ∥ ↔⟨ inverse $ erased Erased↔ ⟩□ Erased ∥ A ∥ □) , λ _ → refl _ ) -- Composition of lenses. -- -- Note that the domains are required to be at least as large as the -- codomains. -- -- The composition operation matches on the lenses to ensure that it -- does not unfold when applied to neutral lenses. infix 9 ⟨_,_⟩_∘_ ⟨_,_⟩_∘_ : ∀ a b {A : Set (a ⊔ b ⊔ c)} {B : Set (b ⊔ c)} {C : Set c} → Lens B C → Lens A B → Lens A C ⟨_,_⟩_∘_ _ _ {A = A} {B} {C} l₁@(⟨ _ , _ , _ ⟩) l₂@(⟨ _ , _ , _ ⟩) = record { R = R l₂ × R l₁ ; equiv = A ↝⟨ equiv l₂ ⟩ R l₂ × B ↝⟨ F.id ×-cong equiv l₁ ⟩ R l₂ × (R l₁ × C) ↔⟨ ×-assoc ⟩□ (R l₂ × R l₁) × C □ ; inhabited = ∥∥-map (get l₁) ⊚ inhabited l₂ ⊚ proj₁ } where open Lens -- Higher-lens→Lens commutes with composition (in erased contexts, -- assuming univalence). @0 Higher-lens-∘≡∘ : ∀ a b {A : Set (a ⊔ b ⊔ c)} {B : Set (b ⊔ c)} {C : Set c} → Univalence (a ⊔ b ⊔ c) → (l₁ : H.Lens B C) (l₂ : H.Lens A B) → Higher-lens→Lens (HLC.⟨ a , b ⟩ l₁ ∘ l₂) ≡ ⟨ a , b ⟩ Higher-lens→Lens l₁ ∘ Higher-lens→Lens l₂ Higher-lens-∘≡∘ _ _ univ (H.⟨ _ , _ , _ ⟩) (H.⟨ _ , _ , _ ⟩) = _↔_.from (equality-characterisation₂ univ) ( F.id , λ _ → refl _ ) -- A variant of composition for lenses between types with the same -- universe level. infixr 9 _∘_ _∘_ : {A B C : Set a} → Lens B C → Lens A B → Lens A C l₁ ∘ l₂ = ⟨ lzero , lzero ⟩ l₁ ∘ l₂ -- Other definitions of composition match ⟨_,_⟩_∘_ (in erased -- contexts), if the codomain type is inhabited whenever it is -- merely inhabited, and the resulting setter function is defined in -- a certain way (assuming univalence). @0 composition≡∘ : let open Lens in {A : Set (a ⊔ b ⊔ c)} {B : Set (b ⊔ c)} {C : Set c} → Univalence (a ⊔ b ⊔ c) → (∥ C ∥ → C) → (comp : Lens B C → Lens A B → Lens A C) → (∀ l₁ l₂ a c → set (comp l₁ l₂) a c ≡ set l₂ a (set l₁ (get l₂ a) c)) → comp ≡ ⟨ a , b ⟩_∘_ composition≡∘ univ ∥C∥→C comp set-comp = ∘-unique univ ∥C∥→C (comp , set-comp) (_ , λ { ⟨ _ , _ , _ ⟩ ⟨ _ , _ , _ ⟩ _ _ → refl _ }) -- Identity and composition form a kind of precategory (in erased -- contexts, assuming univalence). @0 associativity : ∀ a b c {A : Set (a ⊔ b ⊔ c ⊔ d)} {B : Set (b ⊔ c ⊔ d)} {C : Set (c ⊔ d)} {D : Set d} → Univalence (a ⊔ b ⊔ c ⊔ d) → (l₁ : Lens C D) (l₂ : Lens B C) (l₃ : Lens A B) → ⟨ a ⊔ b , c ⟩ l₁ ∘ (⟨ a , b ⟩ l₂ ∘ l₃) ≡ ⟨ a , b ⊔ c ⟩ (⟨ b , c ⟩ l₁ ∘ l₂) ∘ l₃ associativity _ _ _ univ ⟨ _ , _ , _ ⟩ ⟨ _ , _ , _ ⟩ ⟨ _ , _ , _ ⟩ = _↔_.from (equality-characterisation₂ univ) (Eq.↔⇒≃ (inverse ×-assoc) , λ _ → refl _) @0 left-identity : ∀ bi a {A : Set (a ⊔ b)} {B : Set b} → Univalence (a ⊔ b) → (l : Lens A B) → ⟨ a , lzero ⟩ id bi ∘ l ≡ l left-identity ⊠ _ {B = B} univ l@(⟨ _ , _ , _ ⟩) = _↔_.from (equality-characterisation₂ univ) ( (R × Erased ∥ B ∥ ↔⟨ lemma ⟩□ R □) , λ _ → refl _ ) where open Lens l lemma : R × Erased ∥ B ∥ ↔ R lemma = record { surjection = record { logical-equivalence = record { to = proj₁ ; from = λ r → r , [ inhabited r ] } ; right-inverse-of = λ _ → refl _ } ; left-inverse-of = λ (r , _) → cong (r ,_) $ []-cong [ truncation-is-proposition _ _ ] } @0 right-identity : ∀ bi a {A : Set (a ⊔ b)} {B : Set b} → Univalence (a ⊔ b) → (l : Lens A B) → ⟨ lzero , a ⟩ l ∘ id bi ≡ l right-identity ⊠ _ {A = A} univ l@(⟨ _ , _ , _ ⟩) = _↔_.from (equality-characterisation₂ univ) ( (Erased ∥ A ∥ × R ↔⟨ lemma ⟩□ R □) , λ _ → refl _ ) where open Lens l lemma : Erased ∥ A ∥ × R ↔ R lemma = record { surjection = record { logical-equivalence = record { to = proj₂ ; from = λ r → [ ∥∥-map (λ b → _≃ᴱ_.from equiv (r , b)) (inhabited r) ] , r } ; right-inverse-of = λ _ → refl _ } ; left-inverse-of = λ (_ , r) → cong (_, r) $ []-cong [ truncation-is-proposition _ _ ] } open Lens-combinators ------------------------------------------------------------------------ -- Isomorphisms expressed using lens quasi-inverses private module B {a} (b : Block "id") = Bi-invertibility.Erased equality-with-J (Set a) Lens (id b) _∘_ module BM {a} (b : Block "id") (@0 univ : Univalence a) = B.More b (left-identity b _ univ) (right-identity b _ univ) (associativity _ _ _ univ) -- A form of isomorphism between types, expressed using lenses. open B public renaming (_≅ᴱ_ to [_]_≅ᴱ_) using (Has-quasi-inverseᴱ) private -- Some lemmas used below. @0 ∘≡id→∘≡id : {A B : Set a} (b : Block "id") → Univalence a → (l₁ : H.Lens B A) (l₂ : H.Lens A B) → l₁ HLC.∘ l₂ ≡ HLC.id b → Higher-lens→Lens l₁ ∘ Higher-lens→Lens l₂ ≡ id b ∘≡id→∘≡id b univ l₁ l₂ hyp = Higher-lens→Lens l₁ ∘ Higher-lens→Lens l₂ ≡⟨ sym $ Higher-lens-∘≡∘ lzero lzero univ l₁ l₂ ⟩ Higher-lens→Lens (l₁ HLC.∘ l₂) ≡⟨ cong Higher-lens→Lens hyp ⟩ Higher-lens→Lens (HLC.id b) ≡⟨ Higher-lens-id≡id b univ ⟩∎ id b ∎ @0 l∘l⁻¹≡l∘l⁻¹ : {A B : Set a} → Univalence a → (l : H.Lens B A) (l⁻¹ : Lens A B) → Higher-lens→Lens (l HLC.∘ high l⁻¹) ≡ Higher-lens→Lens l ∘ l⁻¹ l∘l⁻¹≡l∘l⁻¹ univ l l⁻¹ = Higher-lens→Lens (l HLC.∘ high l⁻¹) ≡⟨ Higher-lens-∘≡∘ lzero lzero univ l (high l⁻¹) ⟩ Higher-lens→Lens l ∘ Higher-lens→Lens (high l⁻¹) ≡⟨ cong (Higher-lens→Lens l ∘_) $ _≃_.left-inverse-of Lens≃Higher-lens l⁻¹ ⟩∎ Higher-lens→Lens l ∘ l⁻¹ ∎ @0 l⁻¹∘l≡l⁻¹∘l : {A B : Set a} → Univalence a → (l⁻¹ : Lens B A) (l : H.Lens A B) → Higher-lens→Lens (high l⁻¹ HLC.∘ l) ≡ l⁻¹ ∘ Higher-lens→Lens l l⁻¹∘l≡l⁻¹∘l univ l⁻¹ l = Higher-lens→Lens (high l⁻¹ HLC.∘ l) ≡⟨ Higher-lens-∘≡∘ lzero lzero univ (high l⁻¹) l ⟩ Higher-lens→Lens (high l⁻¹) ∘ Higher-lens→Lens l ≡⟨ cong (_∘ Higher-lens→Lens l) $ _≃_.left-inverse-of Lens≃Higher-lens l⁻¹ ⟩∎ l⁻¹ ∘ Higher-lens→Lens l ∎ -- H.Has-quasi-inverse b l implies -- Has-quasi-inverseᴱ b (Higher-lens→Lens l) (assuming univalence). Has-quasi-inverse→Has-quasi-inverseᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → (l : H.Lens A B) → H.Has-quasi-inverse b l → Has-quasi-inverseᴱ b (Higher-lens→Lens l) Has-quasi-inverse→Has-quasi-inverseᴱ {a = a} b univ l = (∃ λ l⁻¹ → l HLC.∘ l⁻¹ ≡ HLC.id b × l⁻¹ HLC.∘ l ≡ HLC.id b ) ↝⟨ (Σ-map Higher-lens→Lens λ {l⁻¹} (p , q) → [ ∘≡id→∘≡id b univ l l⁻¹ p , ∘≡id→∘≡id b univ l⁻¹ l q ]) ⟩ (∃ λ l⁻¹ → Erased (l′ ∘ l⁻¹ ≡ id b × l⁻¹ ∘ l′ ≡ id b)) □ where l′ = Higher-lens→Lens l -- In erased contexts Has-quasi-inverseᴱ b (Higher-lens→Lens l) is -- equivalent to H.Has-quasi-inverse b l (assuming univalence). @0 Has-quasi-inverseᴱ≃Has-quasi-inverse : {A B : Set a} (b : Block "id") → Univalence a → (l : H.Lens A B) → Has-quasi-inverseᴱ b (Higher-lens→Lens l) ≃ H.Has-quasi-inverse b l Has-quasi-inverseᴱ≃Has-quasi-inverse b univ l = (∃ λ l⁻¹ → Erased (l′ ∘ l⁻¹ ≡ id b × l⁻¹ ∘ l′ ≡ id b)) ↔⟨ (∃-cong λ _ → erased Erased↔) ⟩ (∃ λ l⁻¹ → l′ ∘ l⁻¹ ≡ id b × l⁻¹ ∘ l′ ≡ id b ) ↝⟨ (inverse $ Σ-cong-contra Lens≃Higher-lens λ l⁻¹ → (≡⇒↝ _ (cong₂ _≡_ (l∘l⁻¹≡l∘l⁻¹ univ l l⁻¹) (Higher-lens-id≡id b univ)) F.∘ inverse (Eq.≃-≡ $ inverse Lens≃Higher-lens)) ×-cong (≡⇒↝ _ (cong₂ _≡_ (l⁻¹∘l≡l⁻¹∘l univ l⁻¹ l) (Higher-lens-id≡id b univ)) F.∘ inverse (Eq.≃-≡ $ inverse Lens≃Higher-lens))) ⟩□ (∃ λ l⁻¹ → l HLC.∘ l⁻¹ ≡ HLC.id b × l⁻¹ HLC.∘ l ≡ HLC.id b ) □ where l′ = Higher-lens→Lens l -- H.[ b ] A ≅ B implies [ b ] A ≅ᴱ B (assuming univalence). ≅→≅ᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → H.[ b ] A ≅ B → [ b ] A ≅ᴱ B ≅→≅ᴱ {A = A} {B = B} b univ = (∃ λ (l : H.Lens A B) → H.Has-quasi-inverse b l) ↝⟨ (Σ-map Higher-lens→Lens λ {l} → Has-quasi-inverse→Has-quasi-inverseᴱ b univ l) ⟩□ (∃ λ (l : Lens A B) → Has-quasi-inverseᴱ b l) □ -- In erased contexts [ b ] A ≅ᴱ B is equivalent to H.[ b ] A ≅ B -- (assuming univalence). @0 ≅ᴱ≃≅ : {A B : Set a} (b : Block "id") → Univalence a → ([ b ] A ≅ᴱ B) ≃ (H.[ b ] A ≅ B) ≅ᴱ≃≅ {A = A} {B = B} b univ = (∃ λ (l : Lens A B) → Has-quasi-inverseᴱ b l) ↝⟨ Σ-cong-contra (inverse Lens≃Higher-lens) $ Has-quasi-inverseᴱ≃Has-quasi-inverse b univ ⟩□ (∃ λ (l : H.Lens A B) → H.Has-quasi-inverse b l) □ -- Lenses with quasi-inverses can be converted to equivalences with -- erased proofs. ≅ᴱ→≃ᴱ : ∀ b → [ b ] A ≅ᴱ B → A ≃ᴱ B ≅ᴱ→≃ᴱ ⊠ (l@(⟨ _ , _ , _ ⟩) , l⁻¹@(⟨ _ , _ , _ ⟩) , [ l∘l⁻¹≡id , l⁻¹∘l≡id ]) = EEq.↔→≃ᴱ (get l) (get l⁻¹) (λ b → cong (λ l → get l b) l∘l⁻¹≡id) (λ a → cong (λ l → get l a) l⁻¹∘l≡id) where open Lens -- There is a logical equivalence between [ b ] A ≅ᴱ B and A ≃ᴱ B -- (assuming univalence). ≅ᴱ⇔≃ᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → ([ b ] A ≅ᴱ B) ⇔ (A ≃ᴱ B) ≅ᴱ⇔≃ᴱ {A = A} {B = B} b univ = record { to = ≅ᴱ→≃ᴱ b ; from = from b } where from : ∀ b → A ≃ᴱ B → [ b ] A ≅ᴱ B from b A≃B = l , l⁻¹ , [ l∘l⁻¹≡id b , l⁻¹∘l≡id b ] where l = ≃ᴱ→Lens′ A≃B l⁻¹ = ≃ᴱ→Lens′ (inverse A≃B) @0 l∘l⁻¹≡id : ∀ b → l ∘ l⁻¹ ≡ id b l∘l⁻¹≡id ⊠ = _↔_.from (equality-characterisation₂ univ) ( (Erased ∥ A ∥ × Erased ∥ B ∥ ↔⟨ inverse Erased-Σ↔Σ ⟩ Erased (∥ A ∥ × ∥ B ∥) ↔⟨ Erased-cong ( drop-⊤-left-× λ b → inhabited⇒∥∥↔⊤ (∥∥-map (_≃ᴱ_.from A≃B) b)) ⟩□ Erased ∥ B ∥ □) , λ _ → cong₂ _,_ ([]-cong [ truncation-is-proposition _ _ ]) (_≃ᴱ_.right-inverse-of A≃B _) ) @0 l⁻¹∘l≡id : ∀ b → l⁻¹ ∘ l ≡ id b l⁻¹∘l≡id ⊠ = _↔_.from (equality-characterisation₂ univ) ( (Erased ∥ B ∥ × Erased ∥ A ∥ ↔⟨ inverse Erased-Σ↔Σ ⟩ Erased (∥ B ∥ × ∥ A ∥) ↔⟨ Erased-cong ( drop-⊤-left-× λ a → inhabited⇒∥∥↔⊤ (∥∥-map (_≃ᴱ_.to A≃B) a)) ⟩ Erased ∥ A ∥ □) , λ _ → cong₂ _,_ ([]-cong [ truncation-is-proposition _ _ ]) (_≃ᴱ_.left-inverse-of A≃B _) ) -- In erased contexts the right-to-left direction of ≅ᴱ⇔≃ᴱ is a right -- inverse of the left-to-right direction. @0 ≅ᴱ⇔≃ᴱ∘≅ᴱ⇔≃ᴱ : {A B : Set a} (b : Block "id") (@0 univ : Univalence a) (A≃B : A ≃ᴱ B) → _⇔_.to (≅ᴱ⇔≃ᴱ b univ) (_⇔_.from (≅ᴱ⇔≃ᴱ b univ) A≃B) ≡ A≃B ≅ᴱ⇔≃ᴱ∘≅ᴱ⇔≃ᴱ ⊠ _ _ = EEq.to≡to→≡ ext (refl _) -- There is not necessarily a split surjection from -- Is-equivalenceᴱ (Lens.get l) to Has-quasi-inverseᴱ l, if l is a -- lens between types in the same universe (assuming univalence). ¬Is-equivalenceᴱ-get↠Has-quasi-inverseᴱ : (b : Block "id") → Univalence a → ¬ ({A B : Set a} (l : Lens A B) → Is-equivalenceᴱ (Lens.get l) ↠ Has-quasi-inverseᴱ b l) ¬Is-equivalenceᴱ-get↠Has-quasi-inverseᴱ {a = a} b univ = Stable-¬ _ [ ({A B : Set a} (l : Lens A B) → Is-equivalenceᴱ (Lens.get l) ↠ Has-quasi-inverseᴱ b l) ↝⟨ (λ hyp → lemma hyp) ⟩ ({A B : Set a} (l : H.Lens A B) → Is-equivalence (H.Lens.get l) ↠ H.Has-quasi-inverse b l) ↝⟨ H.¬Is-equivalence-get↠Has-quasi-inverse b univ ⟩□ ⊥ □ ] where @0 lemma : ∀ {A B : Set a} _ (l : H.Lens A B) → _ lemma hyp l@(H.⟨ _ , _ , _ ⟩) = Is-equivalence (Lens.get (Higher-lens→Lens l)) ↝⟨ EEq.Is-equivalence≃Is-equivalenceᴱ ext ⟩ Is-equivalenceᴱ (Lens.get (Higher-lens→Lens l)) ↝⟨ hyp (Higher-lens→Lens l) ⟩ Has-quasi-inverseᴱ b (Higher-lens→Lens l) ↔⟨ Has-quasi-inverseᴱ≃Has-quasi-inverse b univ l ⟩□ H.Has-quasi-inverse b l □ -- There is not necessarily an equivalence with erased proofs from -- Is-equivalenceᴱ (Lens.get l) to Has-quasi-inverseᴱ l, if l is a -- lens between types in the same universe (assuming univalence). ¬Is-equivalenceᴱ-get≃ᴱHas-quasi-inverseᴱ : (b : Block "id") → Univalence a → ¬ ({A B : Set a} (l : Lens A B) → Is-equivalenceᴱ (Lens.get l) ≃ᴱ Has-quasi-inverseᴱ b l) ¬Is-equivalenceᴱ-get≃ᴱHas-quasi-inverseᴱ {a = a} b univ = Stable-¬ _ [ ({A B : Set a} (l : Lens A B) → Is-equivalenceᴱ (Lens.get l) ≃ᴱ Has-quasi-inverseᴱ b l) ↝⟨ (λ hyp l → _≃_.surjection $ EEq.≃ᴱ→≃ $ hyp l) ⟩ ({A B : Set a} (l : Lens A B) → Is-equivalenceᴱ (Lens.get l) ↠ Has-quasi-inverseᴱ b l) ↝⟨ ¬Is-equivalenceᴱ-get↠Has-quasi-inverseᴱ b univ ⟩□ ⊥ □ ] -- See also ≃ᴱ≃ᴱ≅ᴱ below. ------------------------------------------------------------------------ -- Equivalences expressed using bi-invertibility for lenses -- A form of equivalence between types, expressed using lenses. open B public renaming (_≊ᴱ_ to [_]_≊ᴱ_) using (Has-left-inverseᴱ; Has-right-inverseᴱ; Is-bi-invertibleᴱ) open BM public using (equality-characterisation-≊ᴱ) -- H.Has-left-inverse b l implies -- Has-left-inverseᴱ b (Higher-lens→Lens l) (assuming univalence). Has-left-inverse→Has-left-inverseᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → (l : H.Lens A B) → H.Has-left-inverse b l → Has-left-inverseᴱ b (Higher-lens→Lens l) Has-left-inverse→Has-left-inverseᴱ b univ l = (∃ λ l⁻¹ → l⁻¹ HLC.∘ l ≡ HLC.id b ) ↝⟨ (Σ-map Higher-lens→Lens λ {l⁻¹} eq → [ ∘≡id→∘≡id b univ l⁻¹ l eq ]) ⟩□ (∃ λ l⁻¹ → Erased (l⁻¹ ∘ l′ ≡ id b)) □ where l′ = Higher-lens→Lens l -- In erased contexts Has-left-inverseᴱ b (Higher-lens→Lens l) is -- equivalent to H.Has-left-inverse b l (assuming univalence). @0 Has-left-inverseᴱ≃Has-left-inverse : {A B : Set a} (b : Block "id") → Univalence a → (l : H.Lens A B) → Has-left-inverseᴱ b (Higher-lens→Lens l) ≃ H.Has-left-inverse b l Has-left-inverseᴱ≃Has-left-inverse b univ l = (∃ λ l⁻¹ → Erased (l⁻¹ ∘ l′ ≡ id b)) ↔⟨ (∃-cong λ _ → erased Erased↔) ⟩ (∃ λ l⁻¹ → l⁻¹ ∘ l′ ≡ id b ) ↝⟨ (inverse $ Σ-cong-contra Lens≃Higher-lens λ l⁻¹ → ≡⇒↝ _ (cong₂ _≡_ (l⁻¹∘l≡l⁻¹∘l univ l⁻¹ l) (Higher-lens-id≡id b univ)) F.∘ inverse (Eq.≃-≡ $ inverse Lens≃Higher-lens)) ⟩□ (∃ λ l⁻¹ → l⁻¹ HLC.∘ l ≡ HLC.id b ) □ where l′ = Higher-lens→Lens l -- H.Has-right-inverse b l implies -- Has-right-inverseᴱ b (Higher-lens→Lens l) (assuming univalence). Has-right-inverse→Has-right-inverseᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → (l : H.Lens A B) → H.Has-right-inverse b l → Has-right-inverseᴱ b (Higher-lens→Lens l) Has-right-inverse→Has-right-inverseᴱ b univ l = (∃ λ l⁻¹ → l HLC.∘ l⁻¹ ≡ HLC.id b ) ↝⟨ (Σ-map Higher-lens→Lens λ {l⁻¹} eq → [ ∘≡id→∘≡id b univ l l⁻¹ eq ]) ⟩□ (∃ λ l⁻¹ → Erased (l′ ∘ l⁻¹ ≡ id b)) □ where l′ = Higher-lens→Lens l -- In erased contexts Has-right-inverseᴱ b (Higher-lens→Lens l) is -- equivalent to H.Has-right-inverse b l (assuming univalence). @0 Has-right-inverseᴱ≃Has-right-inverse : {A B : Set a} (b : Block "id") → Univalence a → (l : H.Lens A B) → Has-right-inverseᴱ b (Higher-lens→Lens l) ≃ H.Has-right-inverse b l Has-right-inverseᴱ≃Has-right-inverse b univ l = (∃ λ l⁻¹ → Erased (l′ ∘ l⁻¹ ≡ id b)) ↔⟨ (∃-cong λ _ → erased Erased↔) ⟩ (∃ λ l⁻¹ → l′ ∘ l⁻¹ ≡ id b ) ↝⟨ (inverse $ Σ-cong-contra Lens≃Higher-lens λ l⁻¹ → ≡⇒↝ _ (cong₂ _≡_ (l∘l⁻¹≡l∘l⁻¹ univ l l⁻¹) (Higher-lens-id≡id b univ)) F.∘ inverse (Eq.≃-≡ $ inverse Lens≃Higher-lens)) ⟩□ (∃ λ l⁻¹ → l HLC.∘ l⁻¹ ≡ HLC.id b ) □ where l′ = Higher-lens→Lens l -- H.Is-bi-invertible b l implies -- Is-bi-invertibleᴱ b (Higher-lens→Lens l) (assuming univalence). Is-bi-invertible→Is-bi-invertibleᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → (l : H.Lens A B) → H.Is-bi-invertible b l → Is-bi-invertibleᴱ b (Higher-lens→Lens l) Is-bi-invertible→Is-bi-invertibleᴱ b univ l = H.Is-bi-invertible b l ↔⟨⟩ H.Has-left-inverse b l × H.Has-right-inverse b l ↝⟨ Σ-map (Has-left-inverse→Has-left-inverseᴱ b univ l) (Has-right-inverse→Has-right-inverseᴱ b univ l) ⟩ Has-left-inverseᴱ b l′ × Has-right-inverseᴱ b l′ ↔⟨⟩ Is-bi-invertibleᴱ b l′ □ where l′ = Higher-lens→Lens l -- In erased contexts Is-bi-invertibleᴱ b (Higher-lens→Lens l) is -- equivalent to H.Is-bi-invertible b l (assuming univalence). @0 Is-bi-invertibleᴱ≃Is-bi-invertible : {A B : Set a} (b : Block "id") → Univalence a → (l : H.Lens A B) → Is-bi-invertibleᴱ b (Higher-lens→Lens l) ≃ H.Is-bi-invertible b l Is-bi-invertibleᴱ≃Is-bi-invertible b univ l = Is-bi-invertibleᴱ b l′ ↔⟨⟩ Has-left-inverseᴱ b l′ × Has-right-inverseᴱ b l′ ↝⟨ Has-left-inverseᴱ≃Has-left-inverse b univ l ×-cong Has-right-inverseᴱ≃Has-right-inverse b univ l ⟩ H.Has-left-inverse b l × H.Has-right-inverse b l ↔⟨⟩ H.Is-bi-invertible b l □ where l′ = Higher-lens→Lens l -- H.[ b ] A ≊ B implies [ b ] A ≊ᴱ B (assuming univalence). ≊→≊ᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → H.[ b ] A ≊ B → [ b ] A ≊ᴱ B ≊→≊ᴱ {A = A} {B = B} b univ = (∃ λ (l : H.Lens A B) → H.Is-bi-invertible b l) ↝⟨ (Σ-map Higher-lens→Lens λ {l} → Is-bi-invertible→Is-bi-invertibleᴱ b univ l) ⟩□ (∃ λ (l : Lens A B) → Is-bi-invertibleᴱ b l) □ -- In erased contexts [ b ] A ≊ᴱ B is equivalent to H.[ b ] A ≊ B -- (assuming univalence). @0 ≊ᴱ≃≊ : {A B : Set a} (b : Block "id") → Univalence a → ([ b ] A ≊ᴱ B) ≃ (H.[ b ] A ≊ B) ≊ᴱ≃≊ {A = A} {B = B} b univ = (∃ λ (l : Lens A B) → Is-bi-invertibleᴱ b l) ↝⟨ Σ-cong-contra (inverse Lens≃Higher-lens) $ Is-bi-invertibleᴱ≃Is-bi-invertible b univ ⟩□ (∃ λ (l : H.Lens A B) → H.Is-bi-invertible b l) □ -- Lenses with left inverses have propositional remainder types (in -- erased contexts). @0 Has-left-inverseᴱ→remainder-propositional : (b : Block "id") (l : Lens A B) → Has-left-inverseᴱ b l → Is-proposition (Lens.R l) Has-left-inverseᴱ→remainder-propositional ⊠ l@(⟨ _ , _ , _ ⟩) (l⁻¹@(⟨ _ , _ , _ ⟩) , [ l⁻¹∘l≡id ]) = $⟨ get≡id→remainder-propositional (l⁻¹ ∘ l) (λ a → cong (flip get a) l⁻¹∘l≡id) ⟩ Is-proposition (R (l⁻¹ ∘ l)) ↔⟨⟩ Is-proposition (R l × R l⁻¹) ↝⟨ H-level-×₁ (∥∥-map (remainder l⁻¹) ⊚ inhabited l) 1 ⟩□ Is-proposition (R l) □ where open Lens -- Lenses with right inverses have propositional remainder types (in -- erased contexts). @0 Has-right-inverseᴱ→remainder-propositional : (b : Block "id") (l : Lens A B) → Has-right-inverseᴱ b l → Is-proposition (Lens.R l) Has-right-inverseᴱ→remainder-propositional ⊠ l@(⟨ _ , _ , _ ⟩) (l⁻¹@(⟨ _ , _ , _ ⟩) , [ l∘l⁻¹≡id ]) = $⟨ get≡id→remainder-propositional (l ∘ l⁻¹) (λ a → cong (flip get a) l∘l⁻¹≡id) ⟩ Is-proposition (R (l ∘ l⁻¹)) ↔⟨⟩ Is-proposition (R l⁻¹ × R l) ↝⟨ H-level-×₂ (∥∥-map (remainder l⁻¹) ⊚ inhabited l) 1 ⟩□ Is-proposition (R l) □ where open Lens -- There is an equivalence with erased proofs between A ≃ᴱ B and -- [ b ] A ≊ᴱ B (assuming univalence). ≃ᴱ≃ᴱ≊ᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → (A ≃ᴱ B) ≃ᴱ ([ b ] A ≊ᴱ B) ≃ᴱ≃ᴱ≊ᴱ {A = A} {B = B} b univ = EEq.↔→≃ᴱ (to b) (from b) (to∘from b) (from∘to b) where open Lens to : ∀ b → A ≃ᴱ B → [ b ] A ≊ᴱ B to b = B.≅ᴱ→≊ᴱ b ⊚ _⇔_.from (≅ᴱ⇔≃ᴱ b univ) from : ∀ b → [ b ] A ≊ᴱ B → A ≃ᴱ B from b = _⇔_.to (≅ᴱ⇔≃ᴱ b univ) ⊚ _⇔_.from (BM.≅ᴱ⇔≊ᴱ b univ) @0 to∘from : ∀ b A≊ᴱB → to b (from b A≊ᴱB) ≡ A≊ᴱB to∘from b A≊ᴱB = _≃_.from (equality-characterisation-≊ᴱ b univ _ _) $ _↔_.from (equality-characterisation₃ univ) ( ∥B∥≃R b A≊ᴱB , lemma₁ b A≊ᴱB , lemma₂ b A≊ᴱB ) where l′ : ∀ b (A≊ᴱB : [ b ] A ≊ᴱ B) → Lens A B l′ b A≊ᴱB = proj₁ (to b (from b A≊ᴱB)) ∥B∥≃R : ∀ b (A≊ᴱB@(l , _) : [ b ] A ≊ᴱ B) → Erased ∥ B ∥ ≃ R l ∥B∥≃R b (l , (l-inv@(l⁻¹ , _) , _)) = Eq.⇔→≃ (H-level-Erased 1 truncation-is-proposition) R-prop (PT.rec R-prop (remainder l ⊚ get l⁻¹) ⊚ erased) (λ r → [ inhabited l r ]) where R-prop = Has-left-inverseᴱ→remainder-propositional b l l-inv lemma₁ : ∀ b (A≊ᴱB@(l , _) : [ b ] A ≊ᴱ B) a → _≃_.to (∥B∥≃R b A≊ᴱB) (remainder (l′ b A≊ᴱB) a) ≡ remainder l a lemma₁ ⊠ ( l@(⟨ _ , _ , _ ⟩) , (l⁻¹@(⟨ _ , _ , _ ⟩) , [ l⁻¹∘l≡id ]) , (⟨ _ , _ , _ ⟩ , _) ) a = remainder l (get l⁻¹ (get l a)) ≡⟨⟩ remainder l (get (l⁻¹ ∘ l) a) ≡⟨ cong (λ l′ → remainder l (get l′ a)) l⁻¹∘l≡id ⟩ remainder l (get (id ⊠) a) ≡⟨⟩ remainder l a ∎ lemma₂ : ∀ b (A≊ᴱB@(l , _) : [ b ] A ≊ᴱ B) a → get (l′ b A≊ᴱB) a ≡ get l a lemma₂ ⊠ (⟨ _ , _ , _ ⟩ , (⟨ _ , _ , _ ⟩ , _) , (⟨ _ , _ , _ ⟩ , _)) _ = refl _ @0 from∘to : ∀ b A≃B → _⇔_.to (≅ᴱ⇔≃ᴱ b univ) (_⇔_.from (BM.≅ᴱ⇔≊ᴱ b univ) (B.≅ᴱ→≊ᴱ b (_⇔_.from (≅ᴱ⇔≃ᴱ b univ) A≃B))) ≡ A≃B from∘to ⊠ _ = EEq.to≡to→≡ ext (refl _) -- The right-to-left direction of ≃ᴱ≃ᴱ≊ᴱ maps bi-invertible lenses to -- their getter functions. to-from-≃ᴱ≃ᴱ≊ᴱ≡get : (b : Block "id") (@0 univ : Univalence a) (A≊ᴱB@(l , _) : [ b ] A ≊ᴱ B) → _≃ᴱ_.to (_≃ᴱ_.from (≃ᴱ≃ᴱ≊ᴱ b univ) A≊ᴱB) ≡ Lens.get l to-from-≃ᴱ≃ᴱ≊ᴱ≡get ⊠ _ (⟨ _ , _ , _ ⟩ , (⟨ _ , _ , _ ⟩ , _) , (⟨ _ , _ , _ ⟩ , _)) = refl _ -- A variant of ≃ᴱ≃ᴱ≊ᴱ that works even if A and B live in different -- universes. -- -- This kind of variant came up in a discussion with Andrea Vezzosi. ≃ᴱ≃ᴱ≊ᴱ′ : {A : Set a} {B : Set b} (b-id : Block "id") → @0 Univalence (a ⊔ b) → (A ≃ᴱ B) ≃ᴱ ([ b-id ] ↑ b A ≊ᴱ ↑ a B) ≃ᴱ≃ᴱ≊ᴱ′ {a = a} {b = b} {A = A} {B = B} b-id univ = A ≃ᴱ B ↝⟨ inverse $ EEq.≃ᴱ-cong ext (from-isomorphism Bijection.↑↔) (from-isomorphism Bijection.↑↔) ⟩ ↑ b A ≃ᴱ ↑ a B ↝⟨ ≃ᴱ≃ᴱ≊ᴱ b-id univ ⟩□ [ b-id ] ↑ b A ≊ᴱ ↑ a B □ -- The right-to-left direction of ≃ᴱ≃ᴱ≊ᴱ′ maps bi-invertible lenses to a -- variant of their getter functions. to-from-≃ᴱ≃ᴱ≊ᴱ′≡get : {A : Set a} {B : Set b} (b-id : Block "id") (univ : Univalence (a ⊔ b)) → (A≊ᴱB@(l , _) : [ b-id ] ↑ b A ≊ᴱ ↑ a B) → _≃ᴱ_.to (_≃ᴱ_.from (≃ᴱ≃ᴱ≊ᴱ′ b-id univ) A≊ᴱB) ≡ lower ⊚ Lens.get l ⊚ lift to-from-≃ᴱ≃ᴱ≊ᴱ′≡get ⊠ _ (⟨ _ , _ , _ ⟩ , (⟨ _ , _ , _ ⟩ , _) , (⟨ _ , _ , _ ⟩ , _)) = refl _ -- The getter function of a bi-invertible lens is an equivalence with -- erased proofs (assuming univalence). Is-bi-invertibleᴱ→Is-equivalenceᴱ-get : {A : Set a} (b : Block "id") → @0 Univalence a → (l : Lens A B) → Is-bi-invertibleᴱ b l → Is-equivalenceᴱ (Lens.get l) Is-bi-invertibleᴱ→Is-equivalenceᴱ-get b@⊠ univ l@(⟨ _ , _ , _ ⟩) is-bi-inv@((⟨ _ , _ , _ ⟩ , _) , (⟨ _ , _ , _ ⟩ , _)) = _≃ᴱ_.is-equivalence (_≃ᴱ_.from (≃ᴱ≃ᴱ≊ᴱ b univ) (l , is-bi-inv)) -- If l is a lens between types in the same universe, then there is an -- equivalence with erased proofs between "l is bi-invertible (with -- erased proofs)" and "the getter of l is an equivalence (with erased -- proofs)" (assuming univalence). Is-bi-invertible≃Is-equivalence-get : {A B : Set a} (b : Block "id") → @0 Univalence a → (l : Lens A B) → Is-bi-invertibleᴱ b l ≃ᴱ Is-equivalenceᴱ (Lens.get l) Is-bi-invertible≃Is-equivalence-get b univ l = EEq.⇔→≃ᴱ (BM.Is-bi-invertibleᴱ-propositional b univ l) (EEq.Is-equivalenceᴱ-propositional ext _) (Is-bi-invertibleᴱ→Is-equivalenceᴱ-get b univ l) (λ is-equiv → let l′ = ≃ᴱ→Lens′ EEq.⟨ get l , is-equiv ⟩ in $⟨ proj₂ (_≃ᴱ_.to (≃ᴱ≃ᴱ≊ᴱ b univ) EEq.⟨ _ , is-equiv ⟩) ⟩ Is-bi-invertibleᴱ b l′ ↝⟨ subst (λ ([ l ]) → Is-bi-invertibleᴱ b l) $ sym $ []-cong [ get-equivalence→≡≃ᴱ→Lens′ univ l is-equiv ] ⟩□ Is-bi-invertibleᴱ b l □) where open Lens -- If A is a set, then there is an equivalence with erased proofs -- between [ b ] A ≊ᴱ B and [ b ] A ≅ᴱ B (assuming univalence). ≊ᴱ≃ᴱ≅ᴱ : {A B : Set a} (b : Block "id") → @0 Univalence a → @0 Is-set A → ([ b ] A ≊ᴱ B) ≃ᴱ ([ b ] A ≅ᴱ B) ≊ᴱ≃ᴱ≅ᴱ b univ A-set = ∃-cong λ _ → BM.Is-bi-invertibleᴱ≃ᴱHas-quasi-inverseᴱ-domain b univ (Is-set-closed-domain univ A-set) -- If A is a set, then there is an equivalence with erased proofs between A ≃ᴱ B and -- [ b ] A ≅ᴱ B (assuming univalence). ≃ᴱ≃ᴱ≅ᴱ : {A B : Set a} (b : Block "≃ᴱ≃ᴱ≅ᴱ") → @0 Univalence a → @0 Is-set A → (A ≃ᴱ B) ≃ᴱ ([ b ] A ≅ᴱ B) ≃ᴱ≃ᴱ≅ᴱ {A = A} {B = B} b@⊠ univ A-set = A ≃ᴱ B ↝⟨ ≃ᴱ≃ᴱ≊ᴱ b univ ⟩ [ b ] A ≊ᴱ B ↝⟨ ≊ᴱ≃ᴱ≅ᴱ b univ A-set ⟩□ [ b ] A ≅ᴱ B □ -- In erased contexts one can prove that ≃ᴱ≃ᴱ≅ᴱ maps identity to -- identity. @0 ≃ᴱ≃ᴱ≅ᴱ-id≡id : {A : Set a} (b : Block "≃ᴱ≃ᴱ≅ᴱ") (univ : Univalence a) (A-set : Is-set A) → proj₁ (_≃ᴱ_.to (≃ᴱ≃ᴱ≅ᴱ b univ A-set) F.id) ≡ id b ≃ᴱ≃ᴱ≅ᴱ-id≡id ⊠ univ _ = _↔_.from (equality-characterisation₂ univ) (F.id , λ _ → refl _)
{ "alphanum_fraction": 0.4759829242, "avg_line_length": 37.6578059072, "ext": "agda", "hexsha": "ce602a6bc9b80d899389512fe132ed654e4d5ccb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Saizan/dependent-lenses", "max_forks_repo_path": "src/Lens/Non-dependent/Higher/Erased.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Saizan/dependent-lenses", "max_issues_repo_path": "src/Lens/Non-dependent/Higher/Erased.agda", "max_line_length": 147, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Saizan/dependent-lenses", "max_stars_repo_path": "src/Lens/Non-dependent/Higher/Erased.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 34394, "size": 89249 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Cylinder.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Everything open import Cubical.HITs.PropositionalTruncation import Cubical.Data.Everything as Data open Data hiding (inl; inr) open import Cubical.HITs.Interval -- Cylinder A is a cylinder object in the category of cubical types. -- -- https://ncatlab.org/nlab/show/cylinder+object data Cylinder {ℓ} (A : Type ℓ) : Type ℓ where inl : A → Cylinder A inr : A → Cylinder A cross : ∀ x → inl x ≡ inr x -- Dual to this is the cocylinder or path space object. -- -- https://ncatlab.org/nlab/show/path+space+object Cocylinder : ∀ {ℓ} → Type ℓ → Type ℓ Cocylinder A = Interval → A module _ {ℓ} {A : Type ℓ} where -- The cylinder is part of a factorization of the obvious mapping -- of type A ⊎ A → A into a pair of mappings: -- -- A ⊎ A → Cylinder A ≃ A -- -- include is the first part of the factorization. include : A ⊎ A → Cylinder A include (Data.inl x) = inl x include (Data.inr x) = inr x -- The above inclusion is surjective includeSurjective : ∀ c → ∥ Σ[ s ∈ A ⊎ A ] include s ≡ c ∥ includeSurjective (inl x) = ∣ Data.inl x , refl ∣ includeSurjective (inr x) = ∣ Data.inr x , refl ∣ includeSurjective (cross x i) = squash ∣ Data.inl x , (λ j → cross x (i ∧ j)) ∣ ∣ Data.inr x , (λ j → cross x (i ∨ ~ j)) ∣ i elimCyl : ∀{ℓ'} {B : Cylinder A → Type ℓ'} → (f : (x : A) → B (inl x)) → (g : (x : A) → B (inr x)) → (p : ∀ x → PathP (λ i → B (cross x i)) (f x) (g x)) → (c : Cylinder A) → B c elimCyl f _ _ (inl x) = f x elimCyl _ g _ (inr x) = g x elimCyl _ _ p (cross x i) = p x i private out : Cylinder A → A out (inl x) = x out (inr x) = x out (cross x i) = x inl-out : (c : Cylinder A) → inl (out c) ≡ c inl-out (inl x) = refl inl-out (inr x) = cross x inl-out (cross x i) = λ j → cross x (i ∧ j) out-inl : ∀(x : A) → out (inl x) ≡ x out-inl x = refl -- The second part of the factorization above. CylinderA≃A : Cylinder A ≃ A CylinderA≃A = isoToEquiv (iso out inl out-inl inl-out) -- The cocylinder has a similar equivalence that is part -- of factorizing the diagonal mapping. private inco : A → Cocylinder A inco x _ = x outco : Cocylinder A → A outco f = f zero A→CocylinderA→A : (x : A) → outco (inco x) ≡ x A→CocylinderA→A x = refl CocylinderA→A→CocylinderA : (c : Cocylinder A) → inco (outco c) ≡ c CocylinderA→A→CocylinderA c j zero = c zero CocylinderA→A→CocylinderA c j one = c (seg j) CocylinderA→A→CocylinderA c j (seg i) = c (seg (j ∧ i)) A≃CocylinderA : A ≃ Cocylinder A A≃CocylinderA = isoToEquiv (iso inco outco CocylinderA→A→CocylinderA A→CocylinderA→A) project : Cocylinder A → A × A project c = c zero , c one -- Since we can construct cylinders for every type, Cylinder actually -- constitutes a cylinder functor: -- -- https://ncatlab.org/nlab/show/cylinder+functor -- -- e₀ = inl -- e₁ = inr -- σ = out module Functorial where private variable ℓa ℓb ℓc : Level A : Type ℓa B : Type ℓb C : Type ℓc mapCylinder : (A → B) → Cylinder A → Cylinder B mapCylinder f (inl x) = inl (f x) mapCylinder f (inr x) = inr (f x) mapCylinder f (cross x i) = cross (f x) i mapCylinderId : mapCylinder (λ(x : A) → x) ≡ (λ x → x) mapCylinderId i (inl x) = inl x mapCylinderId i (inr x) = inr x mapCylinderId i (cross x j) = cross x j mapCylinder∘ : (f : A → B) → (g : B → C) → mapCylinder (λ x → g (f x)) ≡ (λ x → mapCylinder g (mapCylinder f x)) mapCylinder∘ f g i (inl x) = inl (g (f x)) mapCylinder∘ f g i (inr x) = inr (g (f x)) mapCylinder∘ f g i (cross x j) = cross (g (f x)) j -- There is an adjunction between the cylinder and coyclinder -- functors. -- -- Cylinder ⊣ Cocylinder adj₁ : (Cylinder A → B) → A → Cocylinder B adj₁ f x zero = f (inl x) adj₁ f x one = f (inr x) adj₁ f x (seg i) = f (cross x i) adj₂ : (A → Cocylinder B) → Cylinder A → B adj₂ g (inl x) = g x zero adj₂ g (inr x) = g x one adj₂ g (cross x i) = g x (seg i) adj₁₂ : (g : A → Cocylinder B) → adj₁ (adj₂ g) ≡ g adj₁₂ g _ x zero = g x zero adj₁₂ g _ x one = g x one adj₁₂ g _ x (seg i) = g x (seg i) adj₂₁ : (f : Cylinder A → B) → adj₂ (adj₁ f) ≡ f adj₂₁ f j (inl x) = f (inl x) adj₂₁ f j (inr x) = f (inr x) adj₂₁ f j (cross x i) = f (cross x i) module IntervalEquiv where -- There is an equivalence between the interval and the -- cylinder over the unit type. Interval→CylinderUnit : Interval → Cylinder Unit Interval→CylinderUnit zero = inl _ Interval→CylinderUnit one = inr _ Interval→CylinderUnit (seg i) = cross _ i CylinderUnit→Interval : Cylinder Unit → Interval CylinderUnit→Interval (inl _) = zero CylinderUnit→Interval (inr _) = one CylinderUnit→Interval (cross _ i) = seg i Interval→CylinderUnit→Interval : ∀ i → CylinderUnit→Interval (Interval→CylinderUnit i) ≡ i Interval→CylinderUnit→Interval zero = refl Interval→CylinderUnit→Interval one = refl Interval→CylinderUnit→Interval (seg i) = refl CylinderUnit→Interval→CylinderUnit : ∀ c → Interval→CylinderUnit (CylinderUnit→Interval c) ≡ c CylinderUnit→Interval→CylinderUnit (inl _) = refl CylinderUnit→Interval→CylinderUnit (inr _) = refl CylinderUnit→Interval→CylinderUnit (cross _ i) = refl CylinderUnit≃Interval : Cylinder Unit ≃ Interval CylinderUnit≃Interval = isoToEquiv (iso CylinderUnit→Interval Interval→CylinderUnit Interval→CylinderUnit→Interval CylinderUnit→Interval→CylinderUnit) -- More generally, there is an equivalence between the cylinder -- over any type A and the product of A and the interval. module _ {ℓ} {A : Type ℓ} where private Cyl : Type ℓ Cyl = A × Interval CylinderA→A×Interval : Cylinder A → Cyl CylinderA→A×Interval (inl x) = x , zero CylinderA→A×Interval (inr x) = x , one CylinderA→A×Interval (cross x i) = x , seg i A×Interval→CylinderA : Cyl → Cylinder A A×Interval→CylinderA (x , zero) = inl x A×Interval→CylinderA (x , one) = inr x A×Interval→CylinderA (x , seg i) = cross x i A×Interval→CylinderA→A×Interval : ∀ c → CylinderA→A×Interval (A×Interval→CylinderA c) ≡ c A×Interval→CylinderA→A×Interval (x , zero) = refl A×Interval→CylinderA→A×Interval (x , one) = refl A×Interval→CylinderA→A×Interval (x , seg i) = refl CylinderA→A×Interval→CylinderA : ∀ c → A×Interval→CylinderA (CylinderA→A×Interval c) ≡ c CylinderA→A×Interval→CylinderA (inl x) = refl CylinderA→A×Interval→CylinderA (inr x) = refl CylinderA→A×Interval→CylinderA (cross x i) = refl CylinderA≃A×Interval : Cylinder A ≃ Cyl CylinderA≃A×Interval = isoToEquiv (iso CylinderA→A×Interval A×Interval→CylinderA A×Interval→CylinderA→A×Interval CylinderA→A×Interval→CylinderA) -- The cylinder is also the pushout of the identity on A with itself. module Push {ℓ} {A : Type ℓ} where open import Cubical.HITs.Pushout private Push : Type ℓ Push = Pushout (λ(x : A) → x) (λ x → x) Cyl : Type ℓ Cyl = Cylinder A Cylinder→Pushout : Cyl → Push Cylinder→Pushout (inl x) = inl x Cylinder→Pushout (inr x) = inr x Cylinder→Pushout (cross x i) = push x i Pushout→Cylinder : Push → Cyl Pushout→Cylinder (inl x) = inl x Pushout→Cylinder (inr x) = inr x Pushout→Cylinder (push x i) = cross x i Pushout→Cylinder→Pushout : ∀ p → Cylinder→Pushout (Pushout→Cylinder p) ≡ p Pushout→Cylinder→Pushout (inl x) = refl Pushout→Cylinder→Pushout (inr x) = refl Pushout→Cylinder→Pushout (push x i) = refl Cylinder→Pushout→Cylinder : ∀ c → Pushout→Cylinder (Cylinder→Pushout c) ≡ c Cylinder→Pushout→Cylinder (inl x) = refl Cylinder→Pushout→Cylinder (inr x) = refl Cylinder→Pushout→Cylinder (cross x i) = refl Pushout≃Cylinder : Push ≃ Cyl Pushout≃Cylinder = isoToEquiv (iso Pushout→Cylinder Cylinder→Pushout Cylinder→Pushout→Cylinder Pushout→Cylinder→Pushout)
{ "alphanum_fraction": 0.6373424691, "avg_line_length": 30.6104868914, "ext": "agda", "hexsha": "0d1dfc6f0bd0a10b5af550998d07bb75fed46d33", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/HITs/Cylinder/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/HITs/Cylinder/Base.agda", "max_line_length": 130, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/HITs/Cylinder/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2971, "size": 8173 }
module Editor where open import Agda.Builtin.FromNat open import BasicIO open import Data.Bool open import Data.Char open import Data.List hiding (_++_) open import Data.String open import Data.Unit open import Function open import Int open import Terminal readTimeout : Int readTimeout = 0 readMinChars : Int readMinChars = 1 attrUpdates : TerminalAttributes → TerminalAttributes attrUpdates = (flip withoutMode processInput) ∘ (flip withoutMode enableEcho) ∘ (flip withTime readTimeout) ∘ (flip withMinInput readMinChars) handleInput : String → IO Bool handleInput "q" = return false handleInput cs = termWrite cs >>= const (return true) parsePath : List (List Char) → IO (List Char) parsePath (path ∷ []) = return path parsePath _ = fail (toList "Exactly one file path argument required") {-# NON_TERMINATING #-} mainLoop : IO ⊤ mainLoop = do input ← termRead continue ← handleInput input if continue then mainLoop else return tt setupAndRun : IO ⊤ setupAndRun = do args ← getArgs path ← parsePath args bracket (termWrite (hideCursor ++ altScreenEnable) >> return tt) (const (termWrite (altScreenDisable ++ showCursor))) (const mainLoop) main : IO ⊤ main = withUpdatedAttributes attrUpdates setupAndRun
{ "alphanum_fraction": 0.7489975942, "avg_line_length": 23.5283018868, "ext": "agda", "hexsha": "f651415abb1a2e7ce114557ade0f969f8f336c9f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c5ffd117f6d5a98f7c68a2a6b9be54a150c70945", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda-editor", "max_forks_repo_path": "src/Editor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c5ffd117f6d5a98f7c68a2a6b9be54a150c70945", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda-editor", "max_issues_repo_path": "src/Editor.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "c5ffd117f6d5a98f7c68a2a6b9be54a150c70945", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda-editor", "max_stars_repo_path": "src/Editor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 327, "size": 1247 }
{-# OPTIONS --cubical --safe #-} module Cubical.Foundations.UnivalenceId where open import Cubical.Core.Glue renaming ( isEquiv to isEquivPath ; _≃_ to EquivPath ; equivFun to equivFunPath ) open import Cubical.Core.Id open import Cubical.Foundations.Prelude public hiding ( _≡_ ; _≡⟨_⟩_ ; _∎ ) open import Cubical.Foundations.Id open import Cubical.Foundations.Equiv renaming ( isPropIsEquiv to isPropIsEquivPath ) open import Cubical.Foundations.Univalence renaming ( EquivContr to EquivContrPath ) open import Cubical.Foundations.Isomorphism path≡Id : ∀ {ℓ} {A B : Type ℓ} → Path _ (Path _ A B) (Id A B) path≡Id = isoToPath (iso pathToId idToPath idToPathToId pathToIdToPath ) equivPathToEquivPath : ∀ {ℓ} {A : Type ℓ} {B : Type ℓ} → (p : EquivPath A B) → Path _ (equivToEquivPath (equivPathToEquiv p)) p equivPathToEquivPath (f , p) i = ( f , isPropIsEquivPath f (equivToEquivPath (equivPathToEquiv (f , p)) .snd) p i ) equivPath≡Equiv : ∀ {ℓ} {A B : Type ℓ} → Path _ (EquivPath A B) (A ≃ B) equivPath≡Equiv {ℓ} = isoToPath (iso (equivPathToEquiv {ℓ}) equivToEquivPath equivToEquiv equivPathToEquivPath) univalenceId : ∀ {ℓ} {A B : Type ℓ} → (A ≡ B) ≃ (A ≃ B) univalenceId {ℓ} {A = A} {B = B} = equivPathToEquiv rem where rem0 : Path _ (Lift (EquivPath A B)) (Lift (A ≃ B)) rem0 = congPath Lift equivPath≡Equiv rem1 : Path _ (Id A B) (Lift (A ≃ B)) rem1 i = hcomp (λ j → λ { (i = i0) → path≡Id {A = A} {B = B} j ; (i = i1) → rem0 j }) (univalencePath {A = A} {B = B} i) rem : EquivPath (Id A B) (A ≃ B) rem = compEquiv (eqweqmap rem1) (invEquiv LiftEquiv)
{ "alphanum_fraction": 0.6358823529, "avg_line_length": 39.5348837209, "ext": "agda", "hexsha": "0d74e1bb2ddf616ce70c1429f79ac02225c9ac70", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Foundations/UnivalenceId.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Foundations/UnivalenceId.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Foundations/UnivalenceId.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 637, "size": 1700 }
module Ual.Void where data ⊥ : Set where ¬ : Set → Set ¬ p = p → ⊥
{ "alphanum_fraction": 0.5507246377, "avg_line_length": 9.8571428571, "ext": "agda", "hexsha": "9d4fcef32b685c92f07b0098a093a689bcb091d9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "brunoczim/ual", "max_forks_repo_path": "Void.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "brunoczim/ual", "max_issues_repo_path": "Void.agda", "max_line_length": 21, "max_stars_count": null, "max_stars_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "brunoczim/ual", "max_stars_repo_path": "Void.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 27, "size": 69 }
module Arity where open import OscarPrelude record Arity : Set where constructor ⟨_⟩ field arity : Nat open Arity public instance EqArity : Eq Arity Eq._==_ EqArity _ = decEq₁ (cong arity) ∘ (_≟_ on arity $ _)
{ "alphanum_fraction": 0.6964285714, "avg_line_length": 14, "ext": "agda", "hexsha": "348a98e0f9a20d600a46cf7afc2ae0963f91eadb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/Arity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/Arity.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/Arity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 76, "size": 224 }
open import Common.Reflect open import Common.Prelude data Z : Set where zero : Z foo : QName → Bool → Bool foo (quote Nat.zero) b = {!b!} foo _ _ = false
{ "alphanum_fraction": 0.66875, "avg_line_length": 14.5454545455, "ext": "agda", "hexsha": "0b770b23d6b49038c99f1e4ee4673d0edef3e434", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "test/interaction/Issue619.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "test/interaction/Issue619.agda", "max_line_length": 30, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/interaction/Issue619.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 50, "size": 160 }
open import Oscar.Prelude open import Oscar.Class open import Oscar.Class.Leftunit open import Oscar.Class.Reflexivity open import Oscar.Class.Transitivity open import Oscar.Class.Transleftidentity module Oscar.Class.Transleftidentity.ToLeftunit where module _ {𝔬} {𝔒 : Ø 𝔬} {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯} {ℓ} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ} {ε : Reflexivity.type _∼_} {transitivity : Transitivity.type _∼_} where instance toLeftunitFromTransleftidentity : ⦃ _ : Transleftidentity.class _∼_ _∼̇_ ε transitivity ⦄ → ∀ {x y} {f : x ∼ y} → Leftunit.class _∼̇_ ε (flip transitivity) f toLeftunitFromTransleftidentity .⋆ = transleftidentity
{ "alphanum_fraction": 0.690936107, "avg_line_length": 29.2608695652, "ext": "agda", "hexsha": "53aa3d8f69e51d639420f0de3a4ffaa7e636a1d5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Transleftidentity/ToLeftunit.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Transleftidentity/ToLeftunit.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Transleftidentity/ToLeftunit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 244, "size": 673 }
------------------------------------------------------------------------ -- A map function for the substitutions ------------------------------------------------------------------------ open import Data.Universe.Indexed module deBruijn.Substitution.Function.Map {i u e} {Uni : IndexedUniverse i u e} where import Axiom.Extensionality.Propositional as E import deBruijn.Context; open deBruijn.Context Uni open import deBruijn.Substitution.Function.Basics open import Function using (_$_) open import Level using (_⊔_) import Relation.Binary.PropositionalEquality as P private module Dummy {t₁} {T₁ : Term-like t₁} {t₂} {T₂ : Term-like t₂} where open Term-like T₁ using () renaming (_⊢_ to _⊢₁_; _≅-⊢_ to _≅-⊢₁_; [_] to [_]₁) open Term-like T₂ using () renaming (_≅-⊢_ to _≅-⊢₂_) -- Map. map : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} → [ T₁ ⟶ T₂ ] ρ̂₂ → (ρ₁ : Sub T₁ ρ̂₁) → Sub T₂ (ρ̂₁ ∘̂ ρ̂₂) map f ρ₁ = f [∘] ρ₁ abstract -- An unfolding lemma. map-▻ : E.Extensionality (i ⊔ u ⊔ e) (i ⊔ u ⊔ e ⊔ t₂) → ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} {σ} (f : [ T₁ ⟶ T₂ ] ρ̂₂) (ρ : Sub T₁ ρ̂₁) t → map f (ρ ▻⇨[ σ ] t) ≅-⇨ map f ρ ▻⇨[ σ ] f · t map-▻ ext {Γ} {σ = σ} f ρ t = extensionality ext P.refl lemma where lemma : ∀ {τ} (x : Γ ▻ σ ∋ τ) → f · (x /∋ (ρ ▻⇨ t)) ≅-⊢₂ x /∋ (map f ρ ▻⇨ f · t) lemma zero = P.refl lemma (suc x) = P.refl -- A congruence lemma. map-cong : ∀ {Γ₁ Δ₁ Ε₁} {ρ̂₁₁ : Γ₁ ⇨̂ Δ₁} {ρ̂₂₁ : Δ₁ ⇨̂ Ε₁} {f₁ : [ T₁ ⟶ T₂ ] ρ̂₂₁} {ρ₁ : Sub T₁ ρ̂₁₁} {Γ₂ Δ₂ Ε₂} {ρ̂₁₂ : Γ₂ ⇨̂ Δ₂} {ρ̂₂₂ : Δ₂ ⇨̂ Ε₂} {f₂ : [ T₁ ⟶ T₂ ] ρ̂₂₂} {ρ₂ : Sub T₁ ρ̂₁₂} → f₁ ≅-⟶ f₂ → ρ₁ ≅-⇨ ρ₂ → map f₁ ρ₁ ≅-⇨ map f₂ ρ₂ map-cong {f₁ = _ , _} {ρ₁ = _ , _} {f₂ = ._ , _} {ρ₂ = ._ , _} [ P.refl ] [ P.refl ] = [ P.refl ] abstract -- Variants which only require that the functions are -- extensionally equal. map-cong-ext₁ : E.Extensionality (i ⊔ u ⊔ e) (i ⊔ u ⊔ e ⊔ t₂) → ∀ {Γ₁ Δ Ε₁} {ρ̂₁₁ : Γ₁ ⇨̂ Δ} {ρ̂₂₁ : Δ ⇨̂ Ε₁} {f₁ : [ T₁ ⟶ T₂ ] ρ̂₂₁} {ρ₁ : Sub T₁ ρ̂₁₁} {Γ₂ Ε₂} {ρ̂₁₂ : Γ₂ ⇨̂ Δ} {ρ̂₂₂ : Δ ⇨̂ Ε₂} {f₂ : [ T₁ ⟶ T₂ ] ρ̂₂₂} {ρ₂ : Sub T₁ ρ̂₁₂} → Ε₁ ≅-Ctxt Ε₂ → (∀ {σ} (t : Δ ⊢₁ σ) → f₁ · t ≅-⊢₂ f₂ · t) → ρ₁ ≅-⇨ ρ₂ → map f₁ ρ₁ ≅-⇨ map f₂ ρ₂ map-cong-ext₁ ext {ρ₁ = ρ} {ρ₂ = ._ , _} Ε₁≅Ε₂ f₁≅f₂ [ P.refl ] = extensionality ext Ε₁≅Ε₂ (λ x → f₁≅f₂ (x /∋ ρ)) map-cong-ext₂ : E.Extensionality (i ⊔ u ⊔ e) (i ⊔ u ⊔ e ⊔ t₂) → ∀ {Γ₁ Δ₁ Ε₁} {ρ̂₁₁ : Γ₁ ⇨̂ Δ₁} {ρ̂₂₁ : Δ₁ ⇨̂ Ε₁} {f₁ : [ T₁ ⟶ T₂ ] ρ̂₂₁} {ρ₁ : Sub T₁ ρ̂₁₁} {Γ₂ Δ₂ Ε₂} {ρ̂₁₂ : Γ₂ ⇨̂ Δ₂} {ρ̂₂₂ : Δ₂ ⇨̂ Ε₂} {f₂ : [ T₁ ⟶ T₂ ] ρ̂₂₂} {ρ₂ : Sub T₁ ρ̂₁₂} → Δ₁ ≅-Ctxt Δ₂ → Ε₁ ≅-Ctxt Ε₂ → (∀ {σ₁ σ₂} {t₁ : Δ₁ ⊢₁ σ₁} {t₂ : Δ₂ ⊢₁ σ₂} → t₁ ≅-⊢₁ t₂ → f₁ · t₁ ≅-⊢₂ f₂ · t₂) → ρ₁ ≅-⇨ ρ₂ → map f₁ ρ₁ ≅-⇨ map f₂ ρ₂ map-cong-ext₂ ext P.refl Ε₁≅Ε₂ f₁≅f₂ ρ₁≅ρ₂ = map-cong-ext₁ ext Ε₁≅Ε₂ (λ t → f₁≅f₂ (P.refl {x = [ t ]₁})) ρ₁≅ρ₂ -- Some sort of naturality statement for _/∋_. (Note that this lemma -- holds definitionally. This is not the case for the corresponding -- lemma in deBruijn.Substitution.Data.Map.) /∋-map : ∀ {Γ Δ Ε σ} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} → (x : Γ ∋ σ) (f : [ T₁ ⟶ T₂ ] ρ̂₂) (ρ : Sub T₁ ρ̂₁) → x /∋ map f ρ ≅-⊢₂ f · (x /∋ ρ) /∋-map x f ρ = P.refl open Dummy public -- Map is functorial. map-[id] : ∀ {t} {T : Term-like t} {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρ : Sub T ρ̂) → map ([id] {T = T}) ρ ≅-⇨ ρ map-[id] = [id]-[∘] map-[∘] : ∀ {t₁} {T₁ : Term-like t₁} {t₂} {T₂ : Term-like t₂} {t₃} {T₃ : Term-like t₃} {Γ Δ Ε Ζ} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} {ρ̂₃ : Ε ⇨̂ Ζ} (f₂ : [ T₂ ⟶ T₃ ] ρ̂₃) (f₁ : [ T₁ ⟶ T₂ ] ρ̂₂) (ρ : Sub T₁ ρ̂₁) → map (f₂ [∘] f₁) ρ ≅-⇨ map f₂ (map f₁ ρ) map-[∘] f₂ f₁ ρ = sym-⟶ $ [∘]-[∘] f₂ f₁ ρ
{ "alphanum_fraction": 0.4264846743, "avg_line_length": 36.6315789474, "ext": "agda", "hexsha": "474d7ae5cecab42ea448a878a4035b304d92f8cb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_path": "deBruijn/Substitution/Function/Map.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/dependently-typed-syntax", "max_issues_repo_path": "deBruijn/Substitution/Function/Map.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_path": "deBruijn/Substitution/Function/Map.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "num_tokens": 2104, "size": 4176 }
{-# OPTIONS --sized-types #-} module SList.Properties (A : Set) where open import Data.List open import List.Permutation.Base A open import SList lemma-unsize-size : (xs : List A) → xs ∼ unsize A (size A xs) lemma-unsize-size [] = ∼[] lemma-unsize-size (x ∷ xs) = ∼x /head /head (lemma-unsize-size xs)
{ "alphanum_fraction": 0.6699029126, "avg_line_length": 22.0714285714, "ext": "agda", "hexsha": "c7afcac6214f57a1f3c81c916c07af15e402135b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/SList/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/SList/Properties.agda", "max_line_length": 67, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/SList/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 95, "size": 309 }
open import Relation.Unary using ( ∅ ; _∪_ ) open import Web.Semantic.DL.Concept using ( Concept ) open import Web.Semantic.DL.Role using ( Role ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.Util using ( Subset ; ⁅_⁆ ) module Web.Semantic.DL.TBox where infixl 5 _⊑₁_ _⊑₂_ infixr 4 _,_ data TBox (Σ : Signature) : Set where ε : TBox Σ _,_ : (T U : TBox Σ) → TBox Σ _⊑₁_ : (C D : Concept Σ) → TBox Σ _⊑₂_ : (Q R : Role Σ) → TBox Σ Ref : (R : Role Σ) → TBox Σ Irr : (R : Role Σ) → TBox Σ Tra : (R : Role Σ) → TBox Σ Dis : (Q R : Role Σ) → TBox Σ Axioms : ∀ {Σ} → TBox Σ → Subset (TBox Σ) Axioms ε = ∅ Axioms (T , U) = (Axioms T) ∪ (Axioms U) Axioms (C ⊑₁ D) = ⁅ C ⊑₁ D ⁆ Axioms (Q ⊑₂ R) = ⁅ Q ⊑₂ R ⁆ Axioms (Ref R) = ⁅ Ref R ⁆ Axioms (Irr R) = ⁅ Irr R ⁆ Axioms (Tra R) = ⁅ Tra R ⁆ Axioms (Dis Q R) = ⁅ Dis Q R ⁆
{ "alphanum_fraction": 0.5760992108, "avg_line_length": 28.6129032258, "ext": "agda", "hexsha": "7bb3d281c4e5fca19d512dfd7917d4ae7018752a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/TBox.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/TBox.agda", "max_line_length": 57, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/TBox.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 422, "size": 887 }
module GUIgeneric.GUIFeatures where open import GUIgeneric.Prelude open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib open import StateSizedIO.GUI.WxGraphicsLibLevel3 open Interfaceˢ public -- Components -- frameAndOKButton : ComponentEls _ frameAndOKButton = add (create-button "OK button") create-frame notOptimzed exampleOneButton : Frame exampleOneButton = frameAndOKButton exampleTwoButtons : Frame exampleTwoButtons = add (create-button "Cancel button") frameAndOKButton notOptimzed exampleThreeButtons : Frame exampleThreeButtons = add (create-button "Cancel button") (frameAndOKButton) notOptimzed getFrame : Frame → ComponentEls frame getFrame (createC tt) = create-frame getFrame (add' buttonFrame f f₁ _) = f₁ data StateV : Set where s0 s1 s2 : StateV data StateTea : Set where s0 s1 s2 s3 : StateTea data FeatureTea : Set where yesTea noTea : FeatureTea data FeatureFree : Set where yesFree noFree : FeatureFree data FeatureCancel : Set where yesCancel noCancel : FeatureCancel record FeatureVendingMachine (BaseState : Set) : Set₁ where field Features : Set AddState : Set guiVendingMachine : (f : Features) → BaseState ⊎ AddState → Frame NewState : Set NewState = BaseState ⊎ AddState open FeatureVendingMachine public base : FeatureVendingMachine StateV base .Features = ⊤ base .AddState = ⊥ base .guiVendingMachine f (inj₁ s0) = exampleOneButton base .guiVendingMachine f (inj₁ s1) = exampleOneButton base .guiVendingMachine f (inj₁ s2) = exampleTwoButtons base .guiVendingMachine f (inj₂ ()) upgradeFeatureVM : (baseState : Set)(vm : FeatureVendingMachine baseState) → FeatureVendingMachine (baseState ⊎ vm .AddState) upgradeFeatureVM baseState vm .Features = vm .Features upgradeFeatureVM baseState vm .AddState = ⊥ upgradeFeatureVM baseState vm .guiVendingMachine f (inj₁ (inj₁ s)) = vm .guiVendingMachine f (inj₁ s) upgradeFeatureVM baseState vm .guiVendingMachine f (inj₁ (inj₂ s)) = vm .guiVendingMachine f (inj₂ s) upgradeFeatureVM baseState vm .guiVendingMachine f (inj₂ ()) changeBaseState : (baseState : Set)(vm : FeatureVendingMachine baseState) (newState : Set) (new2base : newState → baseState) → FeatureVendingMachine newState changeBaseState baseState vm newState new2base .Features = vm .Features changeBaseState baseState vm newState new2base .AddState = vm .AddState changeBaseState baseState vm newState new2base .guiVendingMachine f (inj₁ x) = vm .guiVendingMachine f (inj₁ (new2base x)) changeBaseState baseState vm newState new2base .guiVendingMachine f (inj₂ y) = vm .guiVendingMachine f (inj₂ y) upgradeFeatureVM+ : (baseState : Set)(vm : FeatureVendingMachine baseState) (newBaseState : Set) (newAddState : Set) (new2base : newBaseState ⊎ newAddState → baseState ⊎ vm .AddState) → FeatureVendingMachine newBaseState Features (upgradeFeatureVM+ baseState vm newBaseState newAddState new2Base) = vm .Features AddState (upgradeFeatureVM+ baseState vm newBaseState newAddState new2Base) = newAddState guiVendingMachine (upgradeFeatureVM+ baseState vm newBaseState newAddState new2Base) f s = vm .guiVendingMachine f (new2Base s) tea : FeatureVendingMachine StateV → FeatureVendingMachine StateV tea otherVM .Features = otherVM .Features × FeatureTea tea otherVM .AddState = otherVM .AddState ⊎ ⊤ tea otherVM .guiVendingMachine (f , yesTea) (inj₁ s1) = exampleThreeButtons tea otherVM .guiVendingMachine (f , _) (inj₁ s) = otherVM .guiVendingMachine f (inj₁ s) tea otherVM .guiVendingMachine (f , _) (inj₂ (inj₁ s)) = otherVM .guiVendingMachine f (inj₂ s) tea otherVM .guiVendingMachine (f , _) (inj₂ (inj₂ _)) = exampleOneButton -- new state cancel : FeatureVendingMachine StateV → FeatureVendingMachine StateV cancel otherVM .Features = otherVM .Features × FeatureCancel cancel otherVM .AddState = otherVM .AddState ⊎ ⊤ cancel otherVM .guiVendingMachine (f , yesCancel) (inj₁ s1) = exampleThreeButtons cancel otherVM .guiVendingMachine (f , _) (inj₁ s) = otherVM .guiVendingMachine f (inj₁ s) cancel otherVM .guiVendingMachine (f , _) (inj₂ (inj₁ s)) = otherVM .guiVendingMachine f (inj₂ s) cancel otherVM .guiVendingMachine (f , _) (inj₂ (inj₂ _)) = exampleOneButton -- new state teaBase : FeatureVendingMachine StateV teaBase = tea base StateTeaAux : Set StateTeaAux = StateV ⊎ (⊥ ⊎ ⊤) teaBaseUnified : FeatureVendingMachine StateTeaAux teaBaseUnified = upgradeFeatureVM StateV teaBase stateTeaToPrevState : StateTea → StateTeaAux stateTeaToPrevState s0 = inj₁ s0 stateTeaToPrevState s1 = inj₁ s1 stateTeaToPrevState s2 = inj₁ s2 stateTeaToPrevState s3 = inj₂ (inj₂ _) teaBaseImproved : FeatureVendingMachine StateTea teaBaseImproved = changeBaseState StateTeaAux teaBaseUnified StateTea stateTeaToPrevState teaBaseNewToOld : StateTea ⊎ ⊥ → StateV ⊎ teaBase .AddState teaBaseNewToOld (inj₁ s0) = inj₁ s0 teaBaseNewToOld (inj₁ s1) = inj₁ s1 teaBaseNewToOld (inj₁ s2) = inj₁ s2 teaBaseNewToOld (inj₁ s3) = inj₂ (inj₂ _) teaBaseNewToOld (inj₂ ()) teaBaseImproved+ : FeatureVendingMachine StateTea teaBaseImproved+ = upgradeFeatureVM+ StateV teaBase StateTea ⊥ teaBaseNewToOld cancelTeaBase = cancel (tea base) module base' where NewFeatures' : Set NewFeatures' = ⊤ guiVendingMachine' : (f : NewFeatures') → StateV → Frame guiVendingMachine' f s0 = exampleOneButton guiVendingMachine' f s1 = exampleOneButton guiVendingMachine' f s2 = exampleTwoButtons module tea' (OtherFeatures : Set) (oldV : OtherFeatures → StateV → Frame) where NewFeatures' : Set NewFeatures' = OtherFeatures × FeatureTea guiVendingMachine' : (f : NewFeatures')(s : StateV) → Frame guiVendingMachine' (f , yesTea) s1 = exampleThreeButtons guiVendingMachine' (f , _) s = oldV f s module cancel' (OtherFeatures : Set) (oldV : OtherFeatures → StateV → Frame) where NewFeatures' : Set NewFeatures' = OtherFeatures × FeatureCancel guiVendingMachine' : (f : NewFeatures')(s : StateV) → Frame guiVendingMachine' (f , yesCancel) s1 = exampleThreeButtons guiVendingMachine' (f , _) s = oldV f s module teaBase' (OtherFeatures : Set) where open base' renaming (guiVendingMachine' to baseGUIVendingMachine; NewFeatures' to BaseFeatures) open tea' BaseFeatures baseGUIVendingMachine public module cancelTeaBase' (OtherFeatures : Set) where open teaBase' OtherFeatures renaming (guiVendingMachine' to teaBaseGUIVendingMachine; NewFeatures' to TeaBaseFeatures) open cancel' TeaBaseFeatures teaBaseGUIVendingMachine
{ "alphanum_fraction": 0.7480454344, "avg_line_length": 33.7263681592, "ext": "agda", "hexsha": "a749711b4d4260622d51235a48733a4182ea01a4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "examples/GUIgeneric/GUIFeatures.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "stephanadls/state-dependent-gui", "max_issues_repo_path": "examples/GUIgeneric/GUIFeatures.agda", "max_line_length": 128, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "examples/GUIgeneric/GUIFeatures.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 2015, "size": 6779 }
{-# OPTIONS --allow-unsolved-metas #-} {- 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 Haskell.Modules.RWS open import LibraBFT.Base.Types import LibraBFT.Impl.Consensus.BlockStorage.BlockStore as BlockStore open import LibraBFT.Impl.Consensus.EpochManagerTypes import LibraBFT.Impl.Consensus.Liveness.ExponentialTimeInterval as ExponentialTimeInterval import LibraBFT.Impl.Consensus.Liveness.RoundState as RoundState import LibraBFT.Impl.Consensus.MetricsSafetyRules as MetricsSafetyRules import LibraBFT.Impl.Consensus.RoundManager as RoundManager import LibraBFT.Impl.Consensus.SafetyRules.SafetyRulesManager as SafetyRulesManager import LibraBFT.Impl.Consensus.TestUtils.MockStorage as MockStorage open import LibraBFT.Impl.IO.OBM.Messages import LibraBFT.Impl.OBM.ECP-LBFT-OBM-Diff.ECP-LBFT-OBM-Diff-1 as ECP-LBFT-OBM-Diff-1 open import LibraBFT.Impl.OBM.Logging.Logging import LibraBFT.Impl.OBM.Rust.Duration as Duration open import LibraBFT.Impl.OBM.Rust.RustTypes import LibraBFT.Impl.Storage.DiemDB.DiemDB as DiemDB import LibraBFT.Impl.Types.BlockInfo as BlockInfo import LibraBFT.Impl.Types.EpochChangeProof as EpochChangeProof import LibraBFT.Impl.Types.ValidatorVerifier as ValidatorVerifier open import LibraBFT.Impl.Types.Verifier open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.PKCS open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.Consensus.EpochManager where ------------------------------------------------------------------------------ data RlecState : Set where RSNothing : RlecState RSNeedECP : ReconfigEventEpochChange → RlecState RSNeedRLEC : EpochChangeProof → RlecState data ProcessMessageAction : Set where PMContinue : ProcessMessageAction PMInput : Input → ProcessMessageAction PMNewEpoch : EpochManager → List Output → ProcessMessageAction PMSendECP : EpochChangeProof → AccountAddress → Author {-Text-} → Epoch → Round → ProcessMessageAction PMSendEpochRRq : EpRRqWire → AccountAddress → ProcessMessageAction data PMOutput : Set where PMErr : ErrLog → PMOutput PMInfo : InfoLog → PMOutput EM : Set → Set₁ EM = RWS Unit PMOutput RlecState runEM : ∀ {r} → EM r → RlecState → (r × RlecState × List PMOutput) runEM f = RWS-run f unit ------------------------------------------------------------------------------ expectNewEpoch : EpochManager → Instant → ReconfigEventEpochChange → LedgerInfoWithSignatures → Either ErrLog ProcessMessageAction startProcessor-ed : EpochManager → Instant → OnChainConfigPayload → ObmNeedFetch → ProposalGenerator → LedgerInfoWithSignatures → EitherD ErrLog (EpochManager × List Output) startRoundManager'-ed-abs : EpochManager → Instant → RecoveryData → EpochState → ObmNeedFetch → ProposalGenerator → Version → EitherD ErrLog (EpochManager × List Output) ------------------------------------------------------------------------------ new : NodeConfig → StateComputer → PersistentLivenessStorage → Author → SK → Either ErrLog EpochManager new nodeConfig stateComputer persistentLivenessStorage obmAuthor obmSK = do let -- author = node_config.validator_network.as_ref().unwrap().peer_id(); config = nodeConfig ^∙ ncConsensus safetyRulesManager ← SafetyRulesManager.new (config ^∙ ccSafetyRules) obmAuthor obmSK pure $ mkEpochManager obmAuthor config stateComputer persistentLivenessStorage safetyRulesManager nothing epochState : EpochManager → Either ErrLog EpochState epochState self = case self ^∙ emProcessor of λ where nothing → Left fakeErr -- ["EpochManager not started yet"] (just (RoundProcessorNormal p)) → pure (p ^∙ rmEpochState) (just (RoundProcessorRecovery p)) → pure (p ^∙ rcmEpochState) epoch : EpochManager → Either ErrLog Epoch epoch self = (_^∙ esEpoch) <$> epochState self createRoundState : EpochManager → Instant → RoundState createRoundState self now = let timeInterval = ExponentialTimeInterval.new (Duration.fromMillis (self ^∙ emConfig ∙ ccRoundInitialTimeoutMS)) 1.2 6 in RoundState.new timeInterval now abstract createRoundState-abs = createRoundState createRoundState-abs-≡ : createRoundState-abs ≡ createRoundState createRoundState-abs-≡ = refl createProposerElection : EpochState → ProposerElection createProposerElection epochState0 = ProposerElection∙new (ValidatorVerifier.getOrderedAccountAddressesObmTODO (epochState0 ^∙ esVerifier)) processEpochRetrieval : EpochManager {-Text-} → EpRRqWire → AccountAddress → EM ProcessMessageAction processEpochRetrieval self {-wireOrInternal-} (EpRRqWire∙new {-why fromE fromR-} request) peerAddress = do tell (PMInfo fakeInfo ∷ []) -- ["Enter", wireOrInternal, why, lsA peerAddress, lsE fromE, lsR fromR, lsEpochRRq request]))] case DiemDB.getEpochEndingLedgerInfos (self ^∙ emStorage ∙ msObmDiemDB) (request ^∙ eprrqStartEpoch) (request ^∙ eprrqEndEpoch) of λ where (Left e) → do tell ( (PMErr (withErrCtx (here' ("failed to get epoch proof" {-lsA peerAddress, why, lsEpochRRq request-} ∷ [])) e)) ∷ []) pure PMContinue (Right (liws , more)) → eitherSD (self ^∙ emEpoch) (λ err -> do tell (PMErr (withErrCtx (here' []) err) ∷ []); pure PMContinue) $ λ e -> do let ecp = EpochChangeProof∙new liws more me = self ^∙ emAuthor r = eitherS (self ^∙ emObmRoundManager) (const {-Round-} 0) (_^∙ rmRound) tell (PMInfo fakeInfo {-["Exit", "SendEpochRRp", why, lsA peerAddress, lsECP ecp]-} ∷ []) pure (PMSendECP ecp peerAddress me {-why-} e r) where here' : List String → List String here' t = "EpochManager" ∷ "processEpochRetrieval" ∷ t processDifferentEpoch : EpochManager → Input → AccountAddress → Epoch → Round → EM ProcessMessageAction processDifferentEpoch self obmI peerAddress peerDifferentEpoch obmPeerRound = do tell (PMInfo fakeInfo -- (here [ "ReceiveMessageFromDifferentEpoch", lsA peerAddress -- , lsE peerDifferentEpoch, lsR obmPeerRound, logShowI obmI ]) ∷ []) eitherSD (self ^∙ emEpoch) pmerr $ λ epoch' → eitherSD (self ^∙ emObmRoundManager) pmerr $ λ rm-NotUsedInAgda-OnlyLoggingInHaskell → case compare peerDifferentEpoch epoch' of λ where LT → do -- help nodes that have lower epoch -- LBFT-OBM-DIFF : not sure if this is different, but the message that causes -- this request will be dropped. -- await (Rust comment) processEpochRetrieval self {-"diffE"-} (EpRRqWire∙new {-why epoch' (self^.emObmRoundManagerErrExit.rmRound)-} (EpochRetrievalRequest∙new peerDifferentEpoch epoch')) peerAddress GT → do -- LBFT-OBM-DIFF : message dropped in this case too let epRrq = EpochRetrievalRequest∙new epoch' peerDifferentEpoch epprqw = EpRRqWire∙new {-why epoch' (self^.emObmRoundManagerErrExit.rmRound)-} epRrq tell (PMInfo fakeInfo ∷ []) -- (here [ "SendEpochRRq", lsA peerAddress, lsEpochRRq epRrq -- , "request proof to join higher epoch because", logShowI obmI ]))] -- TODO-1 pure (PMSendEpochRRq epprqw peerAddress) EQ → do tell (PMErr fakeErr ∷ []) -- (here ["EQ should not happen"]) pure PMContinue where here' : List String → List String here' t = "EpochManager" ∷ "processDifferentEpoch" ∷ t pmerr : ErrLog → EM ProcessMessageAction pmerr err = do tell (PMErr (withErrCtx (here' []) err) ∷ []); pure PMContinue {- why = show (msgType obmI) <> "/" <> peerAddress^.aAuthorName <> "/" <> show (peerDifferentEpoch^.eEpoch) <> "/" <> show (obmPeerRound^.rRound) -} startNewEpoch : EpochManager → Instant → Maybe ReconfigEventEpochChange → EpochChangeProof → Either ErrLog ProcessMessageAction startNewEpoch self now mrlec proof = do es ← epochState self liws ← withErrCtx' (here' ("invalid EpochChangeProof" ∷ [])) (EpochChangeProof.verify proof es) -- -------------------------------------------------- -- LBFT-OBM-DIFF: scSyncTo, rather than syncing world state to another node, -- it just gets the NextEpochState from the given LIWS. -- -------------------------------------------------- -- Independently, the world state is synced to the Version/LeadCount contained in 'liws'. -- See 'obmVersion' setting in startRoundManager' below. rlec ← case mrlec of λ where (just rlec) → pure rlec nothing → eitherS (Left "fakeErr") -- TODO-2 ((self^.emStateComputer.scSyncTo) liws) (λ e → Left fakeErr) -- (ErrL (here (lsLIWS liws ∷ e)))) Right self' ← ECP-LBFT-OBM-Diff-1.e_EpochManager_startNewEpoch self proof pure PMContinue expectNewEpoch self' now rlec liws where here' : List String → List String here' t = "EpochManager" ∷ "startNewEpoch" ∷ t startRoundManager-ed : EpochManager → Instant → RecoveryData → EpochState → ObmNeedFetch → ProposalGenerator → Version → EitherD ErrLog (EpochManager × List Output) startRoundManager-ed self0 now recoveryData epochState0 obmNeedFetch obmProposalGenerator obmVersion = let self = case self0 ^∙ emProcessor of λ where (just (RoundProcessorNormal rm)) → self0 & emStorage ∙~ rm ^∙ rmBlockStore ∙ bsStorage & emStorage ∙ msObmDiemDB ∙~ self0 ^∙ emStorage ∙ msObmDiemDB _ → self0 -- OBM-DIFF : use the version in the ledger info of the EpochChangeProof obv = eitherS (self ^∙ emObmRoundManager) (const BlockInfo.gENESIS_VERSION) (const obmVersion) in startRoundManager'-ed-abs self now recoveryData epochState0 obmNeedFetch (obmProposalGenerator & pgLastRoundGenerated ∙~ {-Round-} 0) obv module startRoundManager'-ed (self : EpochManager) (now : Instant) (recoveryData : RecoveryData) (epochState0 : EpochState) (obmNeedFetch : ObmNeedFetch) (obmProposalGenerator : ProposalGenerator) (obmVersion : Version) where continue2 continue2-abs : Maybe Vote → BlockStore → SafetyRules → EitherD ErrLog (EpochManager × List Output) continue1 continue1-abs : Maybe Vote → BlockStore → EitherD ErrLog (EpochManager × List Output) err : ∀ {B} → List String → ErrLog → EitherD ErrLog B here' : List String → List String step₀ = do let lastVote = recoveryData ^∙ rdLastVote case BlockStore.new-e-abs -- Either version so we only get Left and Right cases (self ^∙ emStorage) recoveryData -- TODO-2 : use real StateComputer when it exists stateComputer -- (self ^∙ emStateComputer & scObmVersion .~ obv) TODO-2 (self ^∙ emConfig ∙ ccMaxPrunedBlocksInMem) of λ where (Left e) → err ("BlockStore.new" ∷ []) e (Right bs) → continue1-abs lastVote bs err t = withErrCtxD' t ∘ Left here' t = "EpochManager" ∷ "startRoundManager" ∷ t continue1 lastVote blockStore = do -------------------------------------------------- let safetyRules = {-MetricsSafetyRules::new-} SafetyRulesManager.client (self ^∙ emSafetyRulesManager) -- self.storage.clone()); case MetricsSafetyRules.performInitialize-abs safetyRules (self ^∙ emStorage) of λ where (Left e) → err (here' ("MetricsSafetyRules.performInitialize" ∷ [])) e (Right safetyRules') → continue2-abs lastVote blockStore safetyRules' continue2 lastVote blockStore safetyRules = do -------------------------------------------------- let proposalGenerator = obmProposalGenerator -------------------------------------------------- let roundState = createRoundState-abs self now -------------------------------------------------- let proposerElection = createProposerElection epochState0 -------------------------------------------------- let processor = RoundManager∙new obmNeedFetch epochState0 blockStore roundState proposerElection proposalGenerator (safetyRules & srPersistentStorage ∙ pssSafetyData ∙ sdEpoch ∙~ epochState0 ^∙ esEpoch) (self ^∙ emConfig ∙ ccSyncOnly) -------------------------------------------------- let (_ , processor' , output) = LBFT-run (RoundManager.start-abs now lastVote) processor case find' logErrMB output of λ where (just e) → err (here' ("RoundManager.start" ∷ [])) e nothing → pure ( (self & emProcessor ?~ RoundProcessorNormal processor') , output ) abstract continue1-abs = continue1 continue1-abs-≡ : continue1-abs ≡ continue1 continue1-abs-≡ = refl continue2-abs = continue2 continue2-abs-≡ : continue2-abs ≡ continue2 continue2-abs-≡ = refl abstract startRoundManager'-ed-abs = startRoundManager'-ed.step₀ startRoundManager'-ed-abs-≡ : startRoundManager'-ed-abs ≡ startRoundManager'-ed.step₀ startRoundManager'-ed-abs-≡ = refl startProcessor-ed self now payload obmNeedFetch obmProposalGenerator obmLedgerInfoWithSignatures = do let validatorSet = payload ^∙ occpObmValidatorSet vv ← ValidatorVerifier.from-ed-abs validatorSet let epochState0 = EpochState∙new (payload ^∙ occpEpoch) vv -- OBM TODO case storage.start of RecoveryData | LedgerRecoveryData (initialData , _pls) ← MockStorage.startForTesting-ed-abs validatorSet (just obmLedgerInfoWithSignatures) startRoundManager-ed self now initialData epochState0 obmNeedFetch obmProposalGenerator (obmLedgerInfoWithSignatures ^∙ liwsLedgerInfo ∙ liVersion) abstract startProcessor-e-abs : EpochManager → Instant → OnChainConfigPayload → ObmNeedFetch → ProposalGenerator → LedgerInfoWithSignatures → Either ErrLog (EpochManager × List Output) startProcessor-e-abs em now payload nf pg liws = toEither $ startProcessor-ed em now payload nf pg liws startProcessor-ed-abs = startProcessor-ed startProcessor-ed-abs-≡ : startProcessor-ed-abs ≡ startProcessor-ed startProcessor-ed-abs-≡ = refl {- Currently, the implementation is hooked up to the system model in 'LibraBFT.Impl.Handle.InitAndHandlers' It does so such that - 'RoundManager' is the top-level state, and - 'LibraBFT.Impl.IO.OBM.InputOutputHandlers.handle' is the top-level entry into the implementation. In the future, when epoch changes are taken into account (and proved), - 'EpochManager' will become the top-level state - 'EpochManager.processMessage' will become the top-level entry into the implementation. That said, when that change is made, there will be a new obligation. Currently, when 'InputOutputHandlers.handle' cases have been covered, a proof is done. But, in the future, when proving properties of 'EpochManager.processMessage' (besides covering the epoch change properties) when the output is 'PMInput' it will be necessary to "pass" that input to the 'RoundManager' level and continue proving from there. -} processMessage : EpochManager → Instant → Input → EM ProcessMessageAction processMessage self now = λ where a@(IBlockRetrievalRequest _ _) → pure (PMInput a) a@(IBlockRetrievalResponse _ _) → pure (PMInput a) (IEpochChangeProof from (ECPWire∙new {-why e r-} ecp)) → do tell (PMInfo fakeInfo ∷ []) --[ "processEpochChangeProof" -- , why, lsA from, lsE e, lsR r, lsECP ecp ]))] doECP ecp (IEpochRetrievalRequest frm a@(EpRRqWire∙new {- _why _e _r -} epRrq)) → eitherSD (self ^∙ emEpoch) (λ e -> do tell (PMErr (withErrCtx (here' []) e) ∷ []) pure PMContinue) $ λ epoch' → ifD (epRrq ^∙ eprrqEndEpoch >? epoch') then (do tell (PMInfo fakeInfo ∷ []) --["EpochRRq beyond ours", why, lsE (epRrq^.eprrqEndEpoch)]))] pure PMContinue) else processEpochRetrieval self {-"wire"-} a frm a@(IInit _) → pure (PMInput a) a@(IProposal _ from pm) → maybeDifferentEpoch a from (pm ^∙ pmEpoch) (pm ^∙ pmRound) (IReconfigLocalEpochChange rlec) → do tell (PMInfo fakeInfo ∷ []) --(here ["receive", lsRLEC rlec]))] doRLEC rlec a@(ISyncInfo _ from si) → case ECP-LBFT-OBM-Diff-1.e_EpochManager_processMessage_ISyncInfo self si of λ where (Left e) → do tell (PMErr e ∷ []) pure PMContinue (Right _) → maybeDifferentEpoch a from (si ^∙ siEpoch) (si ^∙ siObmRound) a@(ITimeout _ _ _ _) → pure (PMInput a) a@(IVote _ from vm) → maybeDifferentEpoch a from (vm ^∙ vmEpoch) (vm ^∙ vmRound) where doRlecEcp : Maybe ReconfigEventEpochChange → EpochChangeProof → EM ProcessMessageAction here' : List String → List String here' t = "EpochManager" ∷ "processMessage" ∷ t maybeDifferentEpoch : Input → AccountAddress → Epoch → Round → EM ProcessMessageAction maybeDifferentEpoch a from e r = eitherSD (self ^∙ emEpoch) (λ err → do tell (PMErr (withErrCtx (here' []) err) ∷ []); pure PMContinue) $ λ epoch' → ifD e == epoch' then pure (PMInput a) else processDifferentEpoch self a from e r doECP : EpochChangeProof → EM ProcessMessageAction doECP ecp = get >>= λ where RSNothing → case ECP-LBFT-OBM-Diff-1.e_EpochManager_checkEpc self ecp of λ where (Left e) → do tell (PMErr e ∷ []) pure PMContinue (Right _) → do eitherSD (ECP-LBFT-OBM-Diff-1.e_EpochManager_doECP_waitForRlec self ecp) (λ e → do tell (PMErr (withErrCtx (here' []) e) ∷ []); pure PMContinue) $ λ b → ifD b then (do tell (PMInfo fakeInfo ∷ []) -- [ "doECP", "got ECP", "waiting for RLEC" -- , "my epoch", lsEE (self^.emEpoch), lsECP ecp])] put (RSNeedRLEC ecp) pure PMContinue) else do tell (PMInfo fakeInfo ∷ []) -- ["doECP", "got ECP", "NOT waiting for RLEC" -- , "my epoch", lsEE (self^.emEpoch), lsECP ecp])] put RSNothing doRlecEcp nothing ecp (RSNeedRLEC ecpX) → do tell (PMInfo fakeInfo ∷ []) -- ["got another ECP while waiting for RLEC", lsECP ecp, lsECP ecpX])] pure PMContinue -- TODO (RSNeedECP rlec) → do put RSNothing doRlecEcp (just rlec) ecp doRLEC : ReconfigEventEpochChange → EM ProcessMessageAction doRLEC rlec = get >>= λ where RSNothing → do tell (PMInfo fakeInfo ∷ []) -- ["doRLEC", "got RLEC", "waiting for ECP", lsRLEC rlec])] put (RSNeedECP rlec) pure PMContinue (RSNeedRLEC ecp) → do put RSNothing doRlecEcp (just rlec) ecp (RSNeedECP rlecX) → do tell (PMInfo fakeInfo ∷ []) -- ["doRLEC", "got another RLEC while waiting for ECP", lsRLEC rlec, lsRLEC rlecX])] pure PMContinue -- TODO doRlecEcp rlec ecp = case startNewEpoch self now rlec ecp of λ where (Left err) → do tell (PMErr err ∷ []) pure PMContinue (Right r) → pure r expectNewEpoch self now (ReconfigEventEpochChange∙new payload) obmLedgerInfoWithSignatures = do rm ← self ^∙ emObmRoundManager (em , o) ← startProcessor-e-abs self now payload (rm ^∙ rmObmNeedFetch) (rm ^∙ rmProposalGenerator) obmLedgerInfoWithSignatures pure (PMNewEpoch em o) start-ed : EpochManager → Instant → OnChainConfigPayload → ObmNeedFetch → ProposalGenerator → LedgerInfoWithSignatures → EitherD ErrLog (EpochManager × List Output) start-ed self0 now obmPayload obmNeedFetch obmProposalGenerator obmLedgerInfoWithSignatures = startProcessor-ed self0 now obmPayload obmNeedFetch obmProposalGenerator obmLedgerInfoWithSignatures ------------------------------------------------------------------------------ -- IMPL-DIFF {- 'obmStartLoop' is the function that - gets input (e.g., from the network) - runs that input through the EpochManager in the 'EM' monad - logs any errors that happen in the EpochManager - dispatches on the output of the EpochManager - in some cases it runs the RoundManager in the LBFT monad - in other cases it sends messages (via 'stps') to other nodes The following "implementation" compiles, but has lots of TEMPORARY things to get it to compile. In the proofs, the System Model "handles" input and output. Therefore 'obmStartLoop' will not be implemented nor "proved". It is here to show what is done in the Haskell code. If the Agda code were ever to be extracted to executable Haskell code, then this code would be completed. The system model will be instantiated with 'EpochManager.processMessage' and that will be the system about which properties are proved. See the comments before that function. -} IO : Set → Set₁ IO = RWS Unit Unit Unit {-# TERMINATING #-} obmStartLoop : EpochManager → List Output {-→ CLI.FakeNetworkDelay → DAR.DispatchConfig a → INPUT_CHANNEL_READ a-} → IO Unit obmStartLoop self initializationOutput {-(CLI.FakeNetworkDelay fnd) (DAR.DispatchConfig _rm0 toDAR ih oh lg lc stps m) lbftInR-} = do eitherS (self ^∙ emObmRoundManager) ee $ λ rm → do -- This line roughly corresponds to Rust expect_new_epoch. -- It processes the output from start/startProcessor above. -- TODO (rm' , to') ← DAR.runOutputHandler rm toDAR pe initializationOutput oh rm' ← pure rm -- TEMPORARY for previous line loop (setProcessor self rm') {-to'-} RSNothing where show : ∀ {A : Set} → A → String show _ = "" singleShow : ∀ {A : Set} → A → List String singleShow {A} x = show {A} x ∷ [] errorExit : List String → IO Unit errorExit _ = pure unit here' : List String → List String here' t = "EpochManager" ∷ "obmStartLoop" ∷ t ee : ErrLog → IO Unit ee = errorExit ∘ here' ∘ singleShow setProcessor : EpochManager → RoundManager → EpochManager setProcessor em p = em & emProcessor ?~ RoundProcessorNormal p loop : EpochManager {-→ Map ScheduledInputKey ThreadId-} → RlecState → IO Unit loop em {-to-} rlec0 = do -- i ← U.readChan lbftInR i ← pure (IInit 0) -- TEMPORARY for previous line -- when (fnd > 0) $ -- threadDelay (fnd * oneMillisecond) -- now ← Time.getCurrentInstant now ← pure (0) -- TEMPORARY for previous line let (pma , rlec , pmo) = runEM (processMessage em now i) rlec0 let myName = em ^∙ emAuthor ∙ aAuthorName forM_ pmo $ λ where -- (PMErr (ErrInfo (lc', x)) → Logger.log (lg myName) lc (LogInfo lc' x) (PMErr x) → pure unit -- Logger.log (lg myName) lc (LogErr x) (PMInfo x) → pure unit -- Logger.log (lg myName) lc (LogInfo lEC x) case pma of λ where PMContinue → loop em {-to-} rlec (PMInput i') → eitherSD (em ^∙ emObmRoundManager) ee $ λ rm → do --(rm' , o) ← DAR.runInputHandler rm to pe i' ih --(rm'' , to'') ← DAR.runOutputHandler rm' to pe o oh rm'' ← pure rm -- TEMPORARY for previous two lines loop (setProcessor em rm'') {-to''-} rlec (PMNewEpoch em' newEpochInitializationOutput) → do eitherSD (em' ^∙ emObmRoundManager) ee $ λ rm → do -- (rm', to') ← DAR.runOutputHandler rm to pe newEpochInitializationOutput oh rm' ← pure rm -- TEMPORARY for previous line loop (setProcessor em' rm') {-to'-} RSNothing -- reset RLEC state (PMSendECP ecp peerAddress me {-why-} e r) → do -- stps [peerAddress ^∙ aAuthorName] (Messages.mkIEpochChangeProof me why e r ecp) loop em {-to-} rlec (PMSendEpochRRq epRrq sendTo) → do -- stps [sendTo ^∙ aAuthorName] (IEpochRetrievalRequest (em ^∙ emAuthor) epRrq) loop em {-to-} rlec {- pe = PeerEnv (""::Text) Map.empty (RunEnv (lg (self ^∙ emAuthor.aAuthorName)) lc (Just stps) (Just m)) -}
{ "alphanum_fraction": 0.6204232968, "avg_line_length": 45.6649029982, "ext": "agda", "hexsha": "b460eb3d52bbcf64a38dd1e69635d6a5d5105d6a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Consensus/EpochManager.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Consensus/EpochManager.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Consensus/EpochManager.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6905, "size": 25892 }
------------------------------------------------------------------------ -- From the Agda standard library -- -- Sizes for Agda's sized types ------------------------------------------------------------------------ module Common.Size where open import Agda.Builtin.Size public renaming (ω to ∞; SizeU to SizeUniv)
{ "alphanum_fraction": 0.4018987342, "avg_line_length": 31.6, "ext": "agda", "hexsha": "235a824b62084edce3febd84b8c52ad2634a5a3e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:39:14.000Z", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Common/Size.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": "2017-02-24T19:38:17.000Z", "max_issues_repo_issues_event_min_datetime": "2017-02-24T19:27:31.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Common/Size.agda", "max_line_length": 73, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Common/Size.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-23T04:56:23.000Z", "max_stars_repo_stars_event_min_datetime": "2017-02-24T16:53:22.000Z", "num_tokens": 49, "size": 316 }
module cfg1 where open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Nat hiding ( _≟_ ) -- open import Data.Fin -- open import Data.Product open import Data.List open import Data.Maybe -- open import Data.Bool using ( Bool ; true ; false ; _∧_ ; _∨_ ) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Nullary using (¬_; Dec; yes; no) open import logic -- -- Java → Java Byte Code -- -- CFG Stack Machine (PDA) -- data Node (Symbol : Set) : Set where T : Symbol → Node Symbol N : Symbol → Node Symbol data Seq (Symbol : Set) : Set where _,_ : Symbol → Seq Symbol → Seq Symbol _. : Symbol → Seq Symbol Error : Seq Symbol data Body (Symbol : Set) : Set where _|_ : Seq Symbol → Body Symbol → Body Symbol _; : Seq Symbol → Body Symbol record CFGGrammer (Symbol : Set) : Set where field cfg : Symbol → Body Symbol top : Symbol eq? : Symbol → Symbol → Bool typeof : Symbol → Node Symbol infixr 80 _|_ infixr 90 _; infixr 100 _,_ infixr 110 _. open CFGGrammer ----------------- -- -- CGF language -- ----------------- split : {Σ : Set} → (List Σ → Bool) → ( List Σ → Bool) → List Σ → Bool split x y [] = x [] /\ y [] split x y (h ∷ t) = (x [] /\ y (h ∷ t)) \/ split (λ t1 → x ( h ∷ t1 )) (λ t2 → y t2 ) t cfg-language0 : {Symbol : Set} → CFGGrammer Symbol → Body Symbol → List Symbol → Bool {-# TERMINATING #-} cfg-language1 : {Symbol : Set} → CFGGrammer Symbol → Seq Symbol → List Symbol → Bool cfg-language1 cg Error x = false cfg-language1 cg (S , seq) x with typeof cg S cfg-language1 cg (_ , seq) (x' ∷ t) | T x = eq? cg x x' /\ cfg-language1 cg seq t cfg-language1 cg (_ , seq) [] | T x = false cfg-language1 cg (_ , seq) x | N nonTerminal = split (cfg-language0 cg (cfg cg nonTerminal) )(cfg-language1 cg seq ) x cfg-language1 cg (S .) x with typeof cg S cfg-language1 cg (_ .) (x' ∷ []) | T x = eq? cg x x' cfg-language1 cg (_ .) _ | T x = false cfg-language1 cg (_ .) x | N nonTerminal = cfg-language0 cg (cfg cg nonTerminal) x cfg-language0 cg _ [] = false cfg-language0 cg (rule | b) x = cfg-language1 cg rule x \/ cfg-language0 cg b x cfg-language0 cg (rule ;) x = cfg-language1 cg rule x cfg-language : {Symbol : Set} → CFGGrammer Symbol → List Symbol → Bool cfg-language cg = cfg-language0 cg (cfg cg (top cg )) data IFToken : Set where EA : IFToken EB : IFToken EC : IFToken IF : IFToken THEN : IFToken ELSE : IFToken SA : IFToken SB : IFToken SC : IFToken expr : IFToken statement : IFToken token-eq? : IFToken → IFToken → Bool token-eq? EA EA = true token-eq? EB EB = true token-eq? EC EC = true token-eq? IF IF = true token-eq? THEN THEN = true token-eq? ELSE ELSE = true token-eq? SA SA = true token-eq? SB SB = true token-eq? SC SC = true token-eq? expr expr = true token-eq? statement statement = true token-eq? _ _ = false typeof-IFG : IFToken → Node IFToken typeof-IFG expr = N expr typeof-IFG statement = N statement typeof-IFG x = T x IFGrammer : CFGGrammer IFToken IFGrammer = record { cfg = cfg' ; top = statement ; eq? = token-eq? ; typeof = typeof-IFG } where cfg' : IFToken → Body IFToken cfg' expr = EA . | EB . | EC . ; cfg' statement = SA . | SB . | SC . | IF , expr , THEN , statement . | IF , expr , THEN , statement , ELSE , statement . ; cfg' x = Error ; cfgtest1 = cfg-language IFGrammer ( SA ∷ [] ) cfgtest2 = cfg-language1 IFGrammer ( SA .) ( SA ∷ [] ) cfgtest3 = cfg-language1 IFGrammer ( SA . ) ( SA ∷ [] ) cfgtest4 = cfg-language IFGrammer (IF ∷ EA ∷ THEN ∷ SA ∷ [] ) cfgtest5 = cfg-language1 IFGrammer ( IF , expr , THEN , statement . ) (IF ∷ EA ∷ THEN ∷ SA ∷ [] ) cfgtest6 = cfg-language1 IFGrammer ( statement .)(IF ∷ EA ∷ SA ∷ [] ) cfgtest7 = cfg-language1 IFGrammer ( IF , expr , THEN , statement , ELSE , statement . ) (IF ∷ EA ∷ THEN ∷ SA ∷ ELSE ∷ SB ∷ [] ) cfgtest8 = cfg-language IFGrammer (IF ∷ EA ∷ THEN ∷ IF ∷ EB ∷ THEN ∷ SA ∷ ELSE ∷ SB ∷ [] ) cfgtest9 = cfg-language IFGrammer (IF ∷ EB ∷ THEN ∷ SA ∷ ELSE ∷ SB ∷ [] ) data E1Token : Set where e1 : E1Token e[ : E1Token e] : E1Token expr : E1Token term : E1Token E1-token-eq? : E1Token → E1Token → Bool E1-token-eq? e1 e1 = true E1-token-eq? e[ e] = true E1-token-eq? e] e] = true E1-token-eq? expr expr = true E1-token-eq? term term = true E1-token-eq? _ _ = false typeof-E1 : E1Token → Node E1Token typeof-E1 expr = N expr typeof-E1 term = N term typeof-E1 x = T x E1Grammer : CFGGrammer E1Token E1Grammer = record { cfg = cfgE ; top = expr ; eq? = E1-token-eq? ; typeof = typeof-E1 } where cfgE : E1Token → Body E1Token cfgE expr = term . ; cfgE term = e1 . | e[ , expr , e] . ; cfgE x = Error ; ecfgtest1 = cfg-language E1Grammer ( e1 ∷ [] ) ecfgtest2 = cfg-language E1Grammer ( e[ ∷ e1 ∷ e] ∷ [] ) ecfgtest3 = cfg-language E1Grammer ( e[ ∷ e[ ∷ e1 ∷ e] ∷ e] ∷ [] ) ecfgtest4 = cfg-language E1Grammer ( e[ ∷ e1 ∷ [] ) open import Function left : {t : Set } → List E1Token → ( fail next : List E1Token → t ) → t left ( e[ ∷ t ) fail next = next t left t fail next = fail t right : {t : Set } → List E1Token → ( fail next : List E1Token → t ) → t right ( e] ∷ t ) fail next = next t right t fail next = fail t {-# TERMINATING #-} expr1 : {t : Set } → List E1Token → ( fail next : List E1Token → t ) → t expr1 ( e1 ∷ t ) fail next = next t expr1 ( expr ∷ t ) fail next = next t expr1 ( term ∷ t ) fail next = next t expr1 x fail next = left x fail $ λ x → expr1 x fail $ λ x → right x fail $ next -- expr1 x fail next = left x fail ( λ x → expr1 x fail ( λ x → right x fail ( next ))) cfgtest01 = expr1 ( e[ ∷ e[ ∷ e1 ∷ e] ∷ e] ∷ [] ) (λ x → ⟪ false , x ⟫ ) (λ x → ⟪ true , x ⟫ ) cfgtest02 = expr1 ( e[ ∷ e[ ∷ e1 ∷ e] ∷ [] ) (λ x → ⟪ false , x ⟫ ) (λ x → ⟪ true , x ⟫ ) cfgtest03 = expr1 ( e[ ∷ e[ ∷ e1 ∷ e] ∷ e] ∷ e] ∷ [] ) (λ x → ⟪ false , x ⟫ ) (λ x → ⟪ true , x ⟫ ) open import pushdown data CG1 : Set where ce : CG1 c1 : CG1 pd : CG1 → E1Token → CG1 → CG1 ∧ PushDown CG1 pd c1 e[ s = ⟪ c1 , push c1 ⟫ pd c1 e] c1 = ⟪ c1 , pop ⟫ pd c1 e1 c1 = ⟪ c1 , none ⟫ pd s expr s1 = ⟪ c1 , none ⟫ pd s term s1 = ⟪ c1 , none ⟫ pd s _ s1 = ⟪ ce , none ⟫ pok : CG1 → Bool pok c1 = true pok s = false pnc : PushDownAutomaton CG1 E1Token CG1 pnc = record { pδ = pd ; pempty = ce ; pok = pok } pda-ce-test1 = PushDownAutomaton.paccept pnc c1 ( e[ ∷ e[ ∷ e1 ∷ e] ∷ e] ∷ [] ) [] pda-ce-test2 = PushDownAutomaton.paccept pnc c1 ( e[ ∷ e[ ∷ e1 ∷ e] ∷ [] ) [] pda-ce-test3 = PushDownAutomaton.paccept pnc c1 ( e[ ∷ e1 ∷ e] ∷ e1 ∷ [] ) [] record PNC (accept : Bool ) : Set where field orig-x : List E1Token pnc-q : CG1 pnc-st : List CG1 pnc-p : CG1 → List CG1 → Bool success : accept ≡ true → pnc-p pnc-q pnc-st ≡ true → PushDownAutomaton.paccept pnc c1 orig-x [] ≡ true failure : accept ≡ false → pnc-p pnc-q pnc-st ≡ false → PushDownAutomaton.paccept pnc c1 orig-x [] ≡ false open import Data.Unit {-# TERMINATING #-} expr1P : {n : Level } {t : Set n } → (x : List E1Token ) → PNC true → ( fail : List E1Token → PNC false → t ) → ( next : List E1Token → PNC true → t ) → t expr1P x _ _ _ = {!!} expr1P-test : (x : List E1Token ) → ⊤ expr1P-test x = expr1P x record { orig-x = x ; pnc-q = c1 ; pnc-st = [] ; pnc-p = λ q st → PushDownAutomaton.paccept pnc q x st ; success = λ _ p → p ; failure = λ _ p → p } (λ x p → {!!} ) (λ x p → {!!} ) ---- -- -- CFG to PDA -- cfg→pda-state : {Symbol : Set} → CFGGrammer Symbol → Set cfg→pda-state cfg = {!!} cfg→pda-start : {Symbol : Set} → (cfg : CFGGrammer Symbol) → cfg→pda-state cfg cfg→pda-start cfg = {!!} cfg→pda : {Symbol : Set} → (cfg : CFGGrammer Symbol) → PDA (cfg→pda-state cfg) Symbol (cfg→pda-state cfg) cfg→pda cfg = {!!} cfg->pda : {Symbol : Set} → (input : List Symbol) → (cfg : CFGGrammer Symbol) → PDA.paccept (cfg→pda cfg ) (cfg→pda-start cfg) input [] ≡ cfg-language cfg input cfg->pda = {!!} ---- -- -- PDA to CFG -- open import pushdown pda→cfg : {Symbol : Set} { Q : Set} → (pda : PDA Q Symbol Q) → CFGGrammer Symbol pda→cfg pda = record { cfg = {!!} ; top = {!!} ; eq? = {!!} ; typeof = {!!} } pda->cfg : {Symbol : Set} { Q : Set} → (start : Q) → (input : List Symbol) → (pda : PDA Q Symbol Q) → PDA.paccept pda start input [] ≡ cfg-language (pda→cfg pda) input pda->cfg = {!!} record CDGGrammer (Symbol : Set) : Set where field cdg : Seq Symbol → Body Symbol top : Symbol eq? : Symbol → Symbol → Bool typeof : Symbol → Node Symbol
{ "alphanum_fraction": 0.5688381464, "avg_line_length": 29.2918032787, "ext": "agda", "hexsha": "5ac732363ae45c4f9aeb13649a216d54de451115", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/cfg1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/cfg1.agda", "max_line_length": 118, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/cfg1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3356, "size": 8934 }
open import Agda.Builtin.Equality variable A B : Set f g : A postulate F : Set → Set map : (A → B) → F A → F B lemma : (x : F A) → map (λ x → f (g x)) x ≡ map f (map g x) → F A lemma {A = A} {f = f} {g = g} x _ = x
{ "alphanum_fraction": 0.4912280702, "avg_line_length": 17.5384615385, "ext": "agda", "hexsha": "d0e168068c0be7f0c3803fabc2ef853d5517ddf7", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue3779.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue3779.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3779.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 103, "size": 228 }
------------------------------------------------------------------------ -- Coinductive higher lenses with erased "proofs" ------------------------------------------------------------------------ {-# OPTIONS --guardedness #-} import Equality.Path as P module Lens.Non-dependent.Higher.Coinductive.Erased {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude import Colimit.Sequential.Very-erased eq as CS open import Equality.Decidable-UIP equality-with-J using (Constant) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_; Is-equivalence) open import Equivalence.Erased.Cubical eq as EEq using (_≃ᴱ_) open import Equivalence.Erased.Contractible-preimages.Cubical eq using (_⁻¹ᴱ_) open import Erased.Cubical eq open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional.Erased eq as T using (∥_∥ᴱ; ∣_∣) import H-level.Truncation.Propositional.Non-recursive.Erased eq as N open import H-level.Truncation.Propositional.One-step eq as O using (∣_∣; ∥_∥¹-out-^; ∥_∥¹-in-^; ∣_,_∣-in-^) open import Univalence-axiom equality-with-J open import Lens.Non-dependent eq import Lens.Non-dependent.Higher.Erased eq as Higher import Lens.Non-dependent.Higher.Capriotti.Variant.Erased.Variant eq as V open import Lens.Non-dependent.Higher.Coherently.Coinductive eq import Lens.Non-dependent.Higher.Coinductive eq as C import Lens.Non-dependent.Higher.Coinductive.Small eq as S private variable a b p : Level A B : Type a n : ℕ ------------------------------------------------------------------------ -- The lemma ∥∥ᴱ→≃ private -- A lemma used in the implementation of ∥∥ᴱ→≃. -- -- This definition is erased because its implementation makes use of -- code related to O.∥_∥¹ (a HIT with a non-erased higher -- constructor). @0 ∥∥ᴱ→≃-lemma : Block "∥∥ᴱ→≃-lemma" → (f₀ : A → B) → (∃ λ (f₊ : ∀ n → ∥ A ∥¹-out-^ (1 + n) → B) → (∀ x → f₊ zero ∣ x ∣ ≡ f₀ x) × (∀ n x → f₊ (suc n) ∣ x ∣ ≡ f₊ n x)) ≃ (∃ λ (f₊ : ∀ n → ∥ A ∥¹-in-^ (1 + n) → B) → (∀ x → f₊ zero ∣ x ∣ ≡ f₀ x) × (∀ n x → f₊ (suc n) ∣ n , x ∣-in-^ ≡ f₊ n x)) ∥∥ᴱ→≃-lemma ⊠ _ = inverse $ Σ-cong {k₁ = equivalence} (∀-cong ext λ n → →-cong₁ ext (inverse $ O.∥∥¹-out-^≃∥∥¹-in-^ (suc n))) λ f → ∃-cong λ _ → ∀-cong ext λ n → Π-cong-contra ext (O.∥∥¹-out-^≃∥∥¹-in-^ (suc n)) λ x → ≡⇒≃ $ cong (λ y → f (suc n) y ≡ f n (_≃_.to (O.∥∥¹-out-^≃∥∥¹-in-^ (suc n)) x)) $ sym $ O.∣∣≡∣,∣-in-^ (1 + n) -- Functions from ∥ A ∥ᴱ can be expressed as coherently constant -- functions from A with erased "proofs" (assuming univalence). ∥∥ᴱ→≃ : Block "∥∥ᴱ→≃" → {A : Type a} {B : Type b} → @0 Univalence (a ⊔ b) → (∥ A ∥ᴱ → B) ≃ (∃ λ (f : A → B) → Erased (C.Coherently-constant f)) ∥∥ᴱ→≃ bl {A = A} {B = B} univ = (∥ A ∥ᴱ → B) ↝⟨ →-cong ext T.∥∥ᴱ≃∥∥ᴱ F.id ⟩ (N.∥ A ∥ᴱ → B) ↝⟨ CS.universal-property ⟩ (∃ λ (f₀ : A → B) → Erased (∃ λ (f₊ : ∀ n → ∥ A ∥¹-out-^ (1 + n) → B) → (∀ x → f₊ zero ∣ x ∣ ≡ f₀ x) × (∀ n x → f₊ (suc n) ∣ x ∣ ≡ f₊ n x))) ↝⟨ ∃-cong (λ f → Erased-cong (∥∥ᴱ→≃-lemma bl f)) ⟩ (∃ λ (f₀ : A → B) → Erased (∃ λ (f₊ : ∀ n → ∥ A ∥¹-in-^ (1 + n) → B) → (∀ x → f₊ zero ∣ x ∣ ≡ f₀ x) × (∀ n x → f₊ (suc n) ∣ n , x ∣-in-^ ≡ f₊ n x))) ↝⟨ ∃-cong (λ f → Erased-cong (inverse $ C.Coherently-constant′≃ bl)) ⟩ (∃ λ (f : A → B) → Erased (C.Coherently-constant′ f)) ↝⟨ ∃-cong (λ f → Erased-cong (inverse $ C.Coherently-constant≃Coherently-constant′ bl univ)) ⟩□ (∃ λ (f : A → B) → Erased (C.Coherently-constant f)) □ -- A "computation" rule for ∥∥ᴱ→≃. @0 cong-from-∥∥ᴱ→≃-truncation-is-proposition : (bl : Block "∥∥ᴱ→≃") {A : Type a} {B : Type b} (univ : Univalence (a ⊔ b)) → {f : A → B} {c : C.Coherently-constant f} {x y : A} {p : ∣ x ∣ ≡ ∣ y ∣} → cong (_≃_.from (∥∥ᴱ→≃ bl univ) (f , [ c ])) p ≡ c .property x y cong-from-∥∥ᴱ→≃-truncation-is-proposition bl {A = A} univ {f = f} {c = c} {x = x} {y = y} {p = p} = cong (_≃_.from (∥∥ᴱ→≃ bl univ) (f , [ c ])) p ≡⟨⟩ cong (_≃_.from CS.universal-property (f , [ g bl ]) ∘ _≃_.to T.∥∥ᴱ≃∥∥ᴱ) p ≡⟨ sym $ cong-∘ _ _ _ ⟩ (cong (_≃_.from CS.universal-property (f , [ g bl ])) $ cong (_≃_.to T.∥∥ᴱ≃∥∥ᴱ) p) ≡⟨ cong (cong _) $ mono₁ 1 N.∥∥ᴱ-proposition _ _ ⟩ cong (_≃_.from CS.universal-property (f , [ g bl ])) (N.∥∥ᴱ-proposition N.∣ x ∣ N.∣ y ∣) ≡⟨⟩ cong (_≃_.from CS.universal-property (f , [ g bl ])) (trans (sym (CS.∣∣₊≡∣∣₀ x)) (trans (cong CS.∣_∣₊ (O.∣∣-constant x y)) (CS.∣∣₊≡∣∣₀ y))) ≡⟨ trans (cong-trans _ _ _) $ cong₂ trans (cong-sym _ _) (trans (cong-trans _ _ _) $ cong (flip trans _) $ cong-∘ _ _ _) ⟩ trans (sym $ cong (_≃_.from CS.universal-property (f , [ g bl ])) (CS.∣∣₊≡∣∣₀ x)) (trans (cong (_≃_.from CS.universal-property (f , [ g bl ]) ∘ CS.∣_∣₊) (O.∣∣-constant x y)) (cong (_≃_.from CS.universal-property (f , [ g bl ])) (CS.∣∣₊≡∣∣₀ y))) ≡⟨ cong₂ trans (cong sym CS.rec-∣∣₊≡∣∣₀) (cong (trans _) CS.rec-∣∣₊≡∣∣₀) ⟩ trans (sym $ proj₁ (proj₂ (g bl)) x) (trans (cong (proj₁ (g bl) 0) (O.∣∣-constant x y)) (proj₁ (proj₂ (g bl)) y)) ≡⟨ lemma bl ⟩∎ c .property x y ∎ where g : ∀ _ → _ g bl = _≃_.from (∥∥ᴱ→≃-lemma bl _) $ _≃_.to (C.Coherently-constant′≃ bl) $ _≃_.to (C.Coherently-constant≃Coherently-constant′ bl univ) c lemma : ∀ bl → trans (sym $ proj₁ (proj₂ (g bl)) x) (trans (cong (proj₁ (g bl) 0) (O.∣∣-constant x y)) (proj₁ (proj₂ (g bl)) y)) ≡ c .property x y lemma bl@⊠ = trans (sym $ proj₁ (proj₂ (g bl)) x) (trans (cong (proj₁ (g bl) 0) (O.∣∣-constant x y)) (proj₁ (proj₂ (g bl)) y)) ≡⟨⟩ trans (sym $ refl _) (trans (cong (O.rec′ f (c .property)) (O.∣∣-constant x y)) (refl _)) ≡⟨ trans (cong₂ trans sym-refl (trans-reflʳ _)) $ trans-reflˡ _ ⟩ cong (O.rec′ f (c .property)) (O.∣∣-constant x y) ≡⟨ O.rec-∣∣-constant ⟩∎ c .property x y ∎ ------------------------------------------------------------------------ -- Coherently-constant -- Coherently constant type-valued functions. Coherently-constant : {A : Type a} → (A → Type p) → Type (a ⊔ lsuc p) Coherently-constant P = ∃ λ (f : ∀ x y → P x → P y) → Erased (∃ λ (c : C.Coherently-constant P) → ∀ x y → f x y ≡ subst id (c .property x y)) -- Coherently-constant is pointwise equivalent (with erased proofs) to -- V.Coherently-constant (assuming univalence). Coherently-constant≃ᴱCoherently-constant : {A : Type a} {P : A → Type p} → @0 Univalence (a ⊔ lsuc p) → @0 Univalence p → Coherently-constant P ≃ᴱ V.Coherently-constant P Coherently-constant≃ᴱCoherently-constant {a = a} {p = p} {A = A} {P = P} univ′ univ = block λ bl → Coherently-constant P ↔⟨⟩ (∃ λ (P-const : ∀ x y → P x → P y) → Erased ( ∃ λ (c : C.Coherently-constant P) → ∀ x y → P-const x y ≡ subst id (c .property x y))) ↔⟨ (∃-cong λ P-const → Erased-cong ( ∃-cong λ c → ∀-cong ext λ x → ∀-cong ext λ y → ≡⇒≃ $ cong (P-const x y ≡_) ( subst id (c .property x y) ≡⟨ cong (subst id) $ sym $ cong-from-∥∥ᴱ→≃-truncation-is-proposition bl univ′ ⟩ subst id (cong (_≃_.from (∥∥ᴱ→≃ bl univ′) (P , [ c ])) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣)) ≡⟨ (⟨ext⟩ λ _ → sym $ subst-∘ _ _ _) ⟩∎ subst (_≃_.from (∥∥ᴱ→≃ bl univ′) (P , [ c ])) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣) ∎))) ⟩ (∃ λ (P-const : ∀ x y → P x → P y) → Erased ( ∃ λ (c : C.Coherently-constant P) → ∀ x y → P-const x y ≡ subst (_≃_.from (∥∥ᴱ→≃ bl univ′) (P , [ c ])) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣))) ↔⟨ (∃-cong λ _ → Erased-cong (∃-cong λ _ → Eq.extensionality-isomorphism bad-ext F.∘ (∀-cong ext λ _ → Eq.extensionality-isomorphism bad-ext))) ⟩ (∃ λ (P-const : ∀ x y → P x → P y) → Erased ( ∃ λ (c : C.Coherently-constant P) → P-const ≡ λ x y → subst (_≃_.from (∥∥ᴱ→≃ bl univ′) (P , [ c ])) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣))) ↔⟨ (∃-cong λ P-const → Erased-cong ( ∃-cong λ c → ≡⇒≃ $ cong (P-const ≡_) $ sym $ ⟨ext⟩ λ x → ⟨ext⟩ λ y → cong₂ (λ (f : P y → P y) (g : P x → P x) → f ∘ subst (_≃_.from (∥∥ᴱ→≃ bl univ′) (P , [ c ])) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣) ∘ g) (cong _≃_.to $ trans (cong ≡⇒≃ $ cong-refl (_$ y)) $ ≡⇒↝-refl) (cong _≃_.from $ trans (cong ≡⇒≃ $ cong-refl (_$ x)) $ ≡⇒↝-refl))) ⟩ (∃ λ (P-const : ∀ x y → P x → P y) → Erased ( ∃ λ (c : C.Coherently-constant P) → P-const ≡ λ x y → ≡⇒→ (cong (_$ y) (refl P)) ∘ subst (_≃_.from (∥∥ᴱ→≃ bl univ′) (P , [ c ])) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣) ∘ _≃_.from (≡⇒≃ (cong (_$ x) (refl P))))) ↝⟨ (∃-cong λ P-const → inverse $ EEq.drop-⊤-left-Σ-≃ᴱ-Erased (EEq.other-singleton-with-Π-≃ᴱ-≃ᴱ-⊤ ext univ)) ⟩ (∃ λ (P-const : ∀ x y → P x → P y) → ∃ λ ((Q , P≃) : ∃ λ (Q : A → Type p) → ∀ x → P x ≃ᴱ Q x) → Erased ( ∃ λ (c : C.Coherently-constant Q) → P-const ≡ λ x y → _≃ᴱ_.from (P≃ y) ∘ subst (_≃_.from (∥∥ᴱ→≃ bl univ′) (Q , [ c ])) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣) ∘ _≃ᴱ_.to (P≃ x))) ↔⟨ (∃-cong λ _ → Σ-assoc F.∘ (∃-cong λ _ → ∃-comm) F.∘ inverse Σ-assoc F.∘ (∃-cong λ _ → Erased-Σ↔Σ)) ⟩ (∃ λ (P-const : ∀ x y → P x → P y) → ∃ λ ((Q , c) : ∃ λ (Q : A → Type p) → Erased (C.Coherently-constant Q)) → ∃ λ (P≃ : ∀ x → P x ≃ᴱ Q x) → Erased (P-const ≡ λ x y → _≃ᴱ_.from (P≃ y) ∘ subst (_≃_.from (∥∥ᴱ→≃ bl univ′) (Q , c)) (T.truncation-is-proposition ∣ x ∣ ∣ y ∣) ∘ _≃ᴱ_.to (P≃ x))) ↔⟨ (∃-cong λ _ → Σ-cong (inverse $ ∥∥ᴱ→≃ bl univ′) λ _ → Eq.id) ⟩ (∃ λ (P-const : ∀ x y → P x → P y) → ∃ λ (Q : ∥ A ∥ᴱ → Type p) → ∃ λ (P≃ : ∀ x → P x ≃ᴱ Q ∣ x ∣) → Erased (P-const ≡ λ x y → _≃ᴱ_.from (P≃ y) ∘ subst Q (T.truncation-is-proposition ∣ x ∣ ∣ y ∣) ∘ _≃ᴱ_.to (P≃ x))) ↔⟨⟩ V.Coherently-constant′ P ↝⟨ inverse V.Coherently-constant≃ᴱCoherently-constant′ ⟩□ V.Coherently-constant P □ ------------------------------------------------------------------------ -- The lens type family -- Coinductive lenses. Lens : Type a → Type b → Type (lsuc (a ⊔ b)) Lens A B = ∃ λ (get : A → B) → Coherently-constant (get ⁻¹ᴱ_) -- Some derived definitions. module Lens {A : Type a} {B : Type b} (l : Lens A B) where -- A getter. get : A → B get = proj₁ l -- One can convert from any "preimage" (with an erased proof) of the -- getter to any other. get⁻¹ᴱ-const : (b₁ b₂ : B) → get ⁻¹ᴱ b₁ → get ⁻¹ᴱ b₂ get⁻¹ᴱ-const b₁ b₂ = proj₁ (proj₂ l) b₁ b₂ -- A setter. set : A → B → A set a b = $⟨ get⁻¹ᴱ-const (get a) b ⟩ (get ⁻¹ᴱ get a → get ⁻¹ᴱ b) ↝⟨ _$ (a , [ refl _ ]) ⟩ get ⁻¹ᴱ b ↝⟨ proj₁ ⟩□ A □ instance -- The lenses defined above have getters and setters. has-getter-and-setter : Has-getter-and-setter (Lens {a = a} {b = b}) has-getter-and-setter = record { get = Lens.get ; set = Lens.set } -- Lens A B is equivalent to V.Lens A B (with erased proofs, assuming -- univalence). Lens≃ᴱLens : Block "Lens≃ᴱLens" → {A : Type a} {B : Type b} → @0 Univalence (lsuc (a ⊔ b)) → @0 Univalence (a ⊔ b) → Lens A B ≃ᴱ V.Lens A B Lens≃ᴱLens ⊠ {A = A} {B = B} univ′ univ = (∃ λ (get : A → B) → Coherently-constant (get ⁻¹ᴱ_)) ↝⟨ (∃-cong λ _ → Coherently-constant≃ᴱCoherently-constant univ′ univ) ⟩□ (∃ λ (get : A → B) → V.Coherently-constant (get ⁻¹ᴱ_)) □ -- The right-to-left direction of the equivalence preserves getters -- and setters. from-Lens≃ᴱLens-preserves-getters-and-setters : (bl : Block "Lens≃ᴱLens") {A : Type a} {B : Type b} (@0 univ′ : Univalence (lsuc (a ⊔ b))) (@0 univ : Univalence (a ⊔ b)) → Preserves-getters-and-setters-→ A B (_≃ᴱ_.from (Lens≃ᴱLens bl univ′ univ)) from-Lens≃ᴱLens-preserves-getters-and-setters ⊠ _ _ l = refl _ , ⟨ext⟩ λ a → ⟨ext⟩ λ b → proj₁ (get⁻¹ᴱ-const (get a) b (a , [ refl (get a) ])) ∎ where open V.Lens l -- In erased contexts the equivalence preserves getters and setters. -- -- (I do not know if this result can be proved in non-erased -- contexts.) @0 Lens≃ᴱLens-preserves-getters-and-setters : (bl : Block "Lens≃ᴱLens") {A : Type a} {B : Type b} (@0 univ′ : Univalence (lsuc (a ⊔ b))) (@0 univ : Univalence (a ⊔ b)) → Preserves-getters-and-setters-⇔ A B (_≃ᴱ_.logical-equivalence (Lens≃ᴱLens bl univ′ univ)) Lens≃ᴱLens-preserves-getters-and-setters bl univ′ univ = Preserves-getters-and-setters-⇔-inverse {f = _≃ᴱ_.logical-equivalence (inverse $ Lens≃ᴱLens bl univ′ univ)} $ Preserves-getters-and-setters-→-↠-⇔ (_≃_.surjection (EEq.≃ᴱ→≃ $ inverse $ Lens≃ᴱLens bl univ′ univ)) (from-Lens≃ᴱLens-preserves-getters-and-setters bl univ′ univ) -- Lens A B is equivalent to Higher.Lens A B (with erased proofs, -- assuming univalence). Lens≃ᴱHigher-lens : Block "Lens≃ᴱHigher-Lens" → {A : Type a} {B : Type b} → @0 Univalence (lsuc (a ⊔ b)) → @0 Univalence (a ⊔ b) → Lens A B ≃ᴱ Higher.Lens A B Lens≃ᴱHigher-lens bl {A = A} {B = B} univ′ univ = Lens A B ↝⟨ Lens≃ᴱLens bl univ′ univ ⟩ V.Lens A B ↝⟨ V.Lens≃ᴱHigher-lens bl univ ⟩□ Higher.Lens A B □ -- In erased contexts the equivalence preserves getters and setters. @0 Lens≃ᴱHigher-lens-preserves-getters-and-setters : (bl : Block "Lens≃ᴱHigher-lens") {A : Type a} {B : Type b} (@0 univ′ : Univalence (lsuc (a ⊔ b))) (@0 univ : Univalence (a ⊔ b)) → Preserves-getters-and-setters-⇔ A B (_≃ᴱ_.logical-equivalence (Lens≃ᴱHigher-lens bl univ′ univ)) Lens≃ᴱHigher-lens-preserves-getters-and-setters bl univ′ univ = Preserves-getters-and-setters-⇔-∘ {f = _≃ᴱ_.logical-equivalence $ V.Lens≃ᴱHigher-lens bl univ} {g = _≃ᴱ_.logical-equivalence $ Lens≃ᴱLens bl univ′ univ} (V.Lens≃ᴱHigher-lens-preserves-getters-and-setters bl univ) (Lens≃ᴱLens-preserves-getters-and-setters bl univ′ univ) ------------------------------------------------------------------------ -- H-levels -- If P has h-level n (pointwise), then Coherently-constant P has -- h-level n (assuming univalence). H-level-Coherently-constant : {A : Type a} {P : A → Type p} → @0 Univalence (lsuc (a ⊔ p)) → @0 Univalence (a ⊔ lsuc p) → @0 Univalence p → ((a : A) → H-level n (P a)) → H-level n (Coherently-constant P) H-level-Coherently-constant {n = n} univ₁ univ₂ univ₃ h = Σ-closure n (Π-closure ext n λ _ → Π-closure ext n λ _ → Π-closure ext n λ _ → h _) λ _ → H-level-Erased n ( Σ-closure n (S.H-level-Coinductive-Coherently-constant univ₁ univ₂ univ₃ h) λ _ → Π-closure ext n λ _ → Π-closure ext n λ _ → H-level.⇒≡ n $ Π-closure ext n λ _ → h _) -- If A and B have h-level n given the assumption that the other type -- is inhabited, then Lens A B has h-level n (assuming univalence). lens-preserves-h-level : {A : Type a} {B : Type b} → @0 Univalence (lsuc (a ⊔ b)) → @0 Univalence (a ⊔ b) → ∀ n → (B → H-level n A) → (A → H-level n B) → H-level n (Lens A B) lens-preserves-h-level univ₁ univ₂ n hA hB = Σ-closure n (Π-closure ext n λ a → hB a) λ _ → H-level-Coherently-constant univ₁ univ₁ univ₂ λ b → Σ-closure n (hA b) λ a → H-level-Erased n ( H-level.⇒≡ n (hB a)) -- If the domain of a lens is inhabited and has h-level n, then the -- codomain also has h-level n (in erased contexts, assuming -- univalence). @0 h-level-respects-lens-from-inhabited : {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → Univalence (a ⊔ b) → ∀ n → Lens A B → A → H-level n A → H-level n B h-level-respects-lens-from-inhabited univ′ univ n = Higher.h-level-respects-lens-from-inhabited n ∘ _≃ᴱ_.to (Lens≃ᴱHigher-lens ⊠ univ′ univ) -- If A has positive h-level n, then Lens A B also has h-level n (in -- erased contexts, assuming univalence). @0 lens-preserves-h-level-of-domain : {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → Univalence (a ⊔ b) → ∀ n → H-level (1 + n) A → H-level (1 + n) (Lens A B) lens-preserves-h-level-of-domain univ′ univ n hA = H-level.[inhabited⇒+]⇒+ n λ l → lens-preserves-h-level univ′ univ (1 + n) (λ _ → hA) λ a → h-level-respects-lens-from-inhabited univ′ univ _ l a hA
{ "alphanum_fraction": 0.4397508273, "avg_line_length": 41.096, "ext": "agda", "hexsha": "f7ba0d3a597dbb2a96a84693cc3555d4719aef79", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependent-lenses", "max_forks_repo_path": "src/Lens/Non-dependent/Higher/Coinductive/Erased.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/dependent-lenses", "max_issues_repo_path": "src/Lens/Non-dependent/Higher/Coinductive/Erased.agda", "max_line_length": 136, "max_stars_count": 3, "max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependent-lenses", "max_stars_repo_path": "src/Lens/Non-dependent/Higher/Coinductive/Erased.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z", "num_tokens": 7328, "size": 20548 }
{-# OPTIONS --warning=error --without-K --safe #-} open import LogicalFormulae open import Categories.Definition open import Categories.Functor.Definition module Categories.Functor.Lemmas where functorCompose : {a b c d e f : _} {B : Category {a} {b}} {C : Category {c} {d}} {D : Category {e} {f}} → (Functor C D) → (Functor B C) → (Functor B D) functorCompose G F = record { onObj = λ x → Functor.onObj G (Functor.onObj F x) ; onArrow = λ f → Functor.onArrow G (Functor.onArrow F f) ; mapId = λ {T} → mapIdHelp G F T ; mapCompose = λ r s → mapComposeHelp G F r s } where mapIdHelp : {a b c d e f : _} {B : Category {a} {b}} {C : Category {c} {d}} {D : Category {e} {f}} → (G : Functor C D) → (F : Functor B C) → (T : Category.objects B) → Functor.onArrow G (Functor.onArrow F (Category.id B T)) ≡ Category.id D (Functor.onObj G (Functor.onObj F T)) mapIdHelp {B = B} {C} {D} record { onObj = onObjG ; onArrow = onArrowG ; mapId = mapIdG ; mapCompose = mapComposeG } record { onObj = onObj ; onArrow = onArrow ; mapId = mapId ; mapCompose = mapCompose } T rewrite mapId {T} = mapIdG {onObj T} mapComposeHelp : {a b c d e f : _} {B : Category {a} {b}} {C : Category {c} {d}} {D : Category {e} {f}} → (G : Functor C D) → (F : Functor B C) → {S T U : Category.objects B} → (r : Category.arrows B S T) → (s : Category.arrows B T U) → (Functor.onArrow G (Functor.onArrow F (Category._∘_ B s r))) ≡ (Category._∘_ D (Functor.onArrow G (Functor.onArrow F s)) (Functor.onArrow G (Functor.onArrow F r))) mapComposeHelp {B = record { objects = objectsB ; arrows = arrowsB ; id = idB ; _∘_ = _∘B_ ; rightId = rightIdB ; leftId = leftIdB ; compositionAssociative = associativeB }} {record { objects = objectsC ; arrows = arrowsC ; id = idC ; _∘_ = _∘C_ ; rightId = rightIdC ; leftId = leftIdC ; compositionAssociative = associativeC }} {record { objects = objectsD ; arrows = arrowsD ; id = idD ; _∘_ = _∘D_ ; rightId = rightIdD ; leftId = leftIdD ; compositionAssociative = associativeD }} record { onObj = onObjG ; onArrow = onArrowG ; mapId = mapIdG ; mapCompose = mapComposeG } record { onObj = onObjF ; onArrow = onArrowF ; mapId = mapIdF ; mapCompose = mapComposeF } {S} {T} {U} r s rewrite mapComposeF r s | mapComposeG (onArrowF r) (onArrowF s) = refl idFunctor : {a b : _} (C : Category {a} {b}) → Functor C C Functor.onObj (idFunctor C) = λ x → x Functor.onArrow (idFunctor C) = λ f → f Functor.mapId (idFunctor C) = refl Functor.mapCompose (idFunctor C) = λ f g → refl
{ "alphanum_fraction": 0.6532744074, "avg_line_length": 113.1363636364, "ext": "agda", "hexsha": "1c159f3b42974f373c687e0c1e1eec0fc6eb32f2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Categories/Functor/Lemmas.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Categories/Functor/Lemmas.agda", "max_line_length": 756, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Categories/Functor/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 871, "size": 2489 }
{-# OPTIONS --without-K #-} module Pi0Examples where open import PiU using (U; ZERO; ONE; PLUS; TIMES) open import PiLevel0 using (_⟷_; unite₊l; uniti₊l; unite₊r; uniti₊r; swap₊; assocl₊; assocr₊; unite⋆l; uniti⋆l; unite⋆r; uniti⋆r; swap⋆; assocl⋆; assocr⋆; absorbr; absorbl; factorzr; factorzl; dist; factor; distl; factorl; id⟷; _◎_; _⊕_; _⊗_) ------------------------------------------------------------------------------ -- Example circuits on booleans BOOL : U BOOL = PLUS ONE ONE BOOL² : U BOOL² = TIMES BOOL BOOL -- Nicer syntax that shows intermediate values instead of the above -- point-free notation of permutations infixr 2 _⟷⟨_⟩_ infix 3 _□ _⟷⟨_⟩_ : (t₁ : U) {t₂ : U} {t₃ : U} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) _ ⟷⟨ α ⟩ β = α ◎ β _□ : (t : U) → {t : U} → (t ⟷ t) _□ t = id⟷ foldBool unfoldBool : BOOL ⟷ BOOL foldBool = id⟷ unfoldBool = id⟷ ------------------------------------------------------------------------------ -- Many ways of negating a BOOL. NOT : BOOL ⟷ BOOL NOT = unfoldBool ◎ swap₊ ◎ foldBool -- spec: (false , true) ∷ (true , false) ∷ [] NEG1 NEG2 NEG3 NEG4 NEG5 : BOOL ⟷ BOOL NEG1 = unfoldBool ◎ swap₊ ◎ foldBool -- spec: (false , true) ∷ (true , false) ∷ [] NEG2 = id⟷ ◎ NOT -- spec: (false , true) ∷ (true , false) ∷ [] NEG3 = NOT ◎ NOT ◎ NOT -- spec: (false , true) ∷ (true , false) ∷ [] NEG4 = NOT ◎ id⟷ -- spec: (false , true) ∷ (true , false) ∷ [] NEG5 = uniti⋆l ◎ swap⋆ ◎ (NOT ⊗ id⟷) ◎ swap⋆ ◎ unite⋆l -- spec: (false , true) ∷ (true , false) ∷ [] NEG6 = uniti⋆r ◎ (NOT ⊗ id⟷) ◎ unite⋆r -- same as above, but shorter -- CNOT CNOT : BOOL² ⟷ BOOL² CNOT = TIMES BOOL BOOL ⟷⟨ unfoldBool ⊗ id⟷ ⟩ TIMES (PLUS x y) BOOL ⟷⟨ dist ⟩ PLUS (TIMES x BOOL) (TIMES y BOOL) ⟷⟨ id⟷ ⊕ (id⟷ ⊗ NOT) ⟩ PLUS (TIMES x BOOL) (TIMES y BOOL) ⟷⟨ factor ⟩ TIMES (PLUS x y) BOOL ⟷⟨ foldBool ⊗ id⟷ ⟩ TIMES BOOL BOOL □ where x = ONE; y = ONE -- spec: -- ((false , false) , false , false) ∷ -- ((false , true) , false , true) ∷ -- ((true , false) , true , true) ∷ -- ((true , true) , true , false) ∷ [] -- TOFFOLI TOFFOLI : TIMES BOOL BOOL² ⟷ TIMES BOOL BOOL² TOFFOLI = TIMES BOOL BOOL² ⟷⟨ unfoldBool ⊗ id⟷ ⟩ TIMES (PLUS x y) BOOL² ⟷⟨ dist ⟩ PLUS (TIMES x BOOL²) (TIMES y BOOL²) ⟷⟨ id⟷ ⊕ (id⟷ ⊗ CNOT) ⟩ PLUS (TIMES x BOOL²) (TIMES y BOOL²) ⟷⟨ factor ⟩ TIMES (PLUS x y) BOOL² ⟷⟨ foldBool ⊗ id⟷ ⟩ TIMES BOOL BOOL² □ where x = ONE; y = ONE -- spec: -- ((false , false , false) , false , false , false) ∷ -- ((false , false , true) , false , false , true) ∷ -- ((false , true , false) , false , true , false) ∷ -- ((false , true , true) , false , true , true) ∷ -- ((true , false , false) , true , false , false) ∷ -- ((true , false , true) , true , false , true) ∷ -- ((true , true , false) , true , true , true) ∷ -- ((true , true , true) , true , true , false) ∷ [] -- Swaps for the type 1+(1+1) -- We have three values in the type 1+(1+1) -- Let's call them a, b, and c -- There 6 permutations. Using the swaps below we can express every permutation: -- a b c id⟷ -- a c b SWAP23 -- b a c SWAP12 -- b c a ROTL -- c a b ROTR -- c b a SWAP13 SWAP12 SWAP23 SWAP13 ROTL ROTR : PLUS ONE (PLUS ONE ONE) ⟷ PLUS ONE (PLUS ONE ONE) SWAP12 = assocl₊ ◎ (swap₊ ⊕ id⟷) ◎ assocr₊ -- spec: -- (inj₁ tt , inj₂ (inj₁ tt)) ∷ -- (inj₂ (inj₁ tt) , inj₁ tt) ∷ -- (inj₂ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ [] SWAP23 = id⟷ ⊕ swap₊ -- spec: -- (inj₁ tt , inj₁ tt) ∷ -- (inj₂ (inj₁ tt) , inj₂ (inj₂ tt)) ∷ -- (inj₂ (inj₂ tt) , inj₂ (inj₁ tt)) ∷ [] SWAP13 = SWAP23 ◎ SWAP12 ◎ SWAP23 -- spec: -- (inj₁ tt , inj₂ (inj₂ tt)) ∷ -- (inj₂ (inj₁ tt) , inj₂ (inj₁ tt)) ∷ -- (inj₂ (inj₂ tt) , inj₁ tt) ∷ [] ROTR = SWAP12 ◎ SWAP23 -- spec: -- (inj₁ tt , inj₂ (inj₂ tt)) ∷ -- (inj₂ (inj₁ tt) , inj₁ tt) ∷ -- (inj₂ (inj₂ tt) , inj₂ (inj₁ tt)) ∷ [] ROTL = SWAP13 ◎ SWAP23 -- spec: -- (inj₁ tt , inj₂ (inj₁ tt)) ∷ -- (inj₂ (inj₁ tt) , inj₂ (inj₂ tt)) ∷ -- (inj₂ (inj₂ tt) , inj₁ tt) ∷ [] -- The Peres gate is a universal gate: it takes three inputs a, b, and c, and -- produces a, a xor b, (a and b) xor c PERES : TIMES (TIMES BOOL BOOL) BOOL ⟷ TIMES (TIMES BOOL BOOL) BOOL PERES = (id⟷ ⊗ NOT) ◎ assocr⋆ ◎ (id⟷ ⊗ swap⋆) ◎ TOFFOLI ◎ (id⟷ ⊗ (NOT ⊗ id⟷)) ◎ TOFFOLI ◎ (id⟷ ⊗ swap⋆) ◎ (id⟷ ⊗ (NOT ⊗ id⟷)) ◎ TOFFOLI ◎ (id⟷ ⊗ (NOT ⊗ id⟷)) ◎ assocl⋆ -- spec: -- (((false , false) , false) , (false , false) , false) ∷ -- (((false , false) , true) , (false , false) , true) ∷ -- (((false , true) , false) , (false , true) , false) ∷ -- (((false , true) , true) , (false , true) , true) ∷ -- (((true , false) , false) , (true , true) , false) ∷ -- (((true , false) , true) , (true , true) , true) ∷ -- (((true , true) , false) , (true , false) , true) ∷ -- (((true , true) , true) , (true , false) , false) ∷ [] -- A reversible full adder: See http://arxiv.org/pdf/1008.3533.pdf -- Input: (z, ((n1, n2), cin))) -- Output (g1, (g2, (sum, cout))) -- where sum = n1 xor n2 xor cin -- and cout = ((n1 xor n2) and cin) xor (n1 and n2) xor z FULLADDER : TIMES BOOL (TIMES (TIMES BOOL BOOL) BOOL) ⟷ TIMES BOOL (TIMES BOOL (TIMES BOOL BOOL)) FULLADDER = -- (z,((n1,n2),cin)) swap⋆ ◎ -- (((n1,n2),cin),z) (swap⋆ ⊗ id⟷) ◎ -- ((cin,(n1,n2)),z) assocr⋆ ◎ -- (cin,((n1,n2),z)) swap⋆ ◎ -- (((n1,n2),z),cin) (PERES ⊗ id⟷) ◎ -- (((n1,n1 xor n2),(n1 and n2) xor z),cin) assocr⋆ ◎ -- ((n1,n1 xor n2),((n1 and n2) xor z,cin)) (id⟷ ⊗ swap⋆) ◎ -- ((n1,n1 xor n2),(cin,(n1 and n2) xor z)) assocr⋆ ◎ -- (n1,(n1 xor n2,(cin,(n1 and n2) xor z))) (id⟷ ⊗ assocl⋆) ◎ -- (n1,((n1 xor n2,cin),(n1 and n2) xor z)) (id⟷ ⊗ PERES) ◎ -- (n1,((n1 xor n2,n1 xor n2 xor cin), -- ((n1 xor n2) and cin) xor (n1 and n2) xor z)) (id⟷ ⊗ assocr⋆) -- (n1,(n1 xor n2, -- (n1 xor n2 xor cin,((n1 xor n2) and cin) xor (n1 and n2) xor z))) -- spec: -- ((false , (false , false) , false) , false , false , false , false) ∷ -- ((false , (false , false) , true) , false , false , true , false) ∷ -- ((false , (false , true) , false) , false , true , true , false) ∷ -- ((false , (false , true) , true) , false , true , false , true) ∷ -- ((false , (true , false) , false) , true , true , true , false) ∷ -- ((false , (true , false) , true) , true , true , false , true) ∷ -- ((false , (true , true) , false) , true , false , false , true) ∷ -- ((false , (true , true) , true) , true , false , true , true) ∷ -- ((true , (false , false) , false) , false , false , false , true) ∷ -- ((true , (false , false) , true) , false , false , true , true) ∷ -- ((true , (false , true) , false) , false , true , true , true) ∷ -- ((true , (false , true) , true) , false , true , false , false) ∷ -- ((true , (true , false) , false) , true , true , true , true) ∷ -- ((true , (true , false) , true) , true , true , false , false) ∷ -- ((true , (true , true) , false) , true , false , false , false) ∷ -- ((true , (true , true) , true) , true , false , true , false) ∷ [] ------------------------------------------------------------------------------ -- Generalized CNOT and TOFFOLI ttt : {t₁ t₂ t₃ t₄ : U} → (TIMES (PLUS t₁ t₂) (PLUS t₃ t₄)) ⟷ (PLUS (PLUS (PLUS (TIMES t₁ t₃) (TIMES t₂ t₃)) (TIMES t₁ t₄))) (TIMES t₂ t₄) ttt {t₁} {t₂} {t₃} {t₄} = (distl ◎ (dist {t₁} {t₂} {t₃} ⊕ dist {t₁} {t₂} {t₄})) ◎ assocl₊ -- generalized CNOT gcnot : {A B C : U} → (TIMES (PLUS A B) (PLUS C C)) ⟷ (TIMES (PLUS A B) (PLUS C C)) gcnot = dist ◎ (id⟷ ⊕ (id⟷ ⊗ swap₊)) ◎ factor -- Generalized Toffolli gate. See what 'arithmetic' it performs. GToffoli : {A B C D E : U} → TIMES (PLUS A B) (TIMES (PLUS C D) (PLUS E E)) ⟷ TIMES (PLUS A B) (TIMES (PLUS C D) (PLUS E E)) GToffoli = dist ◎ (id⟷ ⊕ (id⟷ ⊗ gcnot)) ◎ factor ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4940258474, "avg_line_length": 33.8925619835, "ext": "agda", "hexsha": "a97cc6c9524805076f0809ba11847b8e4ebcafb9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Pi0Examples.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Pi0Examples.agda", "max_line_length": 80, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Pi0Examples.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3449, "size": 8202 }
import Lvl open import Data.Boolean open import Type module Data.List.Sorting.MergeSort {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where open import Data.List open import Data.List.Functions as List open import Data.List.Relation.Membership as Membership using (_∈_ ; use ; skip) open import Data.List.Relation.Membership.Proofs open import Data.List.Sorting.Functions(_≤?_) open import Relator.Equals.Proofs open import Structure.Relator.Ordering module _ (split : List(T) → List(List(T))) (_<_ : _) ⦃ well-founded : Strict.Properties.WellFounded{ℓ₂ = ℓ}(_<_) ⦄ ⦃ shrinking-proof : ∀{l}{ll} → ⦃ _ : (ll ∈ split(l)) ⦄ → (ll < l) ⦄ where import Data.List.FunctionsProven as Listₚ -- Definition without using well-founded recursion: -- merge-sort = Sorted.concat ∘ List.map merge-sort ∘ split -- TODO: Correctness requires proof of split(l) being a partition of l merge-sort : List(T) → List(T) merge-sort = Strict.Properties.wellfounded-recursion(_<_) f where f : (l : List(T)) → ((prev : List(T)) → ⦃ _ : prev < l ⦄ → List(T)) → List(T) f(l) rec = mergeAll(Listₚ.map (\ll p → rec ll ⦃ shrinking-proof ⦃ p ⦄ ⦄) (split l) [∈]-self) module Proofs where open import Data.Boolean.Stmt open import Data.List.Relation.Permutation open import Data.List.Sorting(_≤?_) open import Data.List.Sorting.Proofs(_≤?_) open import Functional using (_∘₂_) open import Logic.Propositional open import Relator.Equals open import Structure.Relator.Properties open import Syntax.Transitivity module _ (asym : ∀{x y} → (x ≤? y ≡ not(y ≤? x))) where -- TODO: Use Structure.Relator.Properties.Asymmetry by the relation (IsTrue ∘₂ (_≤?_)) -- module _ (asym : ∀{x y} → (x ≤? y ≡ not(y ≤? x))) (trans : ∀{x y z} → IsTrue(x ≤? y) → IsTrue(y ≤? z) → IsTrue(x ≤? z)) where {- merge-sort-sorted-proof : ∀{l} → Sorted(merge-sort l) merge-sort-sorted-proof {∅} = Sorted.empty merge-sort-sorted-proof {a ⊰ ∅} = single merge-sort-sorted-proof l@{_ ⊰ _ ⊰ _} with Tuple.map1 merge-sort (split2 l) ... | (a , b) = Sorted.merge-sorted-proof asym trans (merge-sort-sorted-proof{l = ∅}) (merge-sort-sorted-proof{l = l}) -}
{ "alphanum_fraction": 0.6584249084, "avg_line_length": 42, "ext": "agda", "hexsha": "799a478a9bb4a09f927773789f5178dfdb4773aa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/List/Sorting/MergeSort.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/List/Sorting/MergeSort.agda", "max_line_length": 144, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/List/Sorting/MergeSort.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 701, "size": 2184 }
{- This file contains basic theory about subgroups. The definition is the same as the first definition of subgroups in: https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#subgroups-sip -} {-# OPTIONS --safe #-} module Cubical.Algebra.Group.Subgroup where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Foundations.Powerset open import Cubical.Foundations.GroupoidLaws hiding (assoc) open import Cubical.Data.Sigma open import Cubical.HITs.PropositionalTruncation open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties private variable ℓ : Level -- We assume an ambient group module _ (G' : Group ℓ) where open GroupStr (snd G') private G = ⟨ G' ⟩ record isSubgroup (H : ℙ G) : Type ℓ where field id-closed : (1g ∈ H) op-closed : {x y : G} → x ∈ H → y ∈ H → x · y ∈ H inv-closed : {x : G} → x ∈ H → inv x ∈ H open isSubgroup Subgroup : Type (ℓ-suc ℓ) Subgroup = Σ[ H ∈ ℙ G ] isSubgroup H isPropIsSubgroup : (H : ℙ G) → isProp (isSubgroup H) id-closed (isPropIsSubgroup H h1 h2 i) = ∈-isProp H 1g (h1 .id-closed) (h2 .id-closed) i op-closed (isPropIsSubgroup H h1 h2 i) Hx Hy = ∈-isProp H _ (h1 .op-closed Hx Hy) (h2 .op-closed Hx Hy) i inv-closed (isPropIsSubgroup H h1 h2 i) Hx = ∈-isProp H _ (h1 .inv-closed Hx) (h2 .inv-closed Hx) i isSetSubgroup : isSet Subgroup isSetSubgroup = isSetΣ isSetℙ λ x → isProp→isSet (isPropIsSubgroup x) Subgroup→Group : Subgroup → Group ℓ Subgroup→Group (H , Hh) = makeGroup-right 1HG _·HG_ invHG isSetHG assocHG ridHG invrHG where HG = Σ[ x ∈ G ] ⟨ H x ⟩ isSetHG = isSetΣ is-set (λ x → isProp→isSet (H x .snd)) 1HG : HG 1HG = (1g , (id-closed Hh)) _·HG_ : HG → HG → HG (x , Hx) ·HG (y , Hy) = (x · y) , (op-closed Hh Hx Hy) invHG : HG → HG invHG (x , Hx) = inv x , inv-closed Hh Hx assocHG : (x y z : HG) → x ·HG (y ·HG z) ≡ (x ·HG y) ·HG z assocHG (x , Hx) (y , Hy) (z , Hz) = ΣPathP (·Assoc x y z , isProp→PathP (λ i → H (·Assoc x y z i) .snd) _ _) ridHG : (x : HG) → x ·HG 1HG ≡ x ridHG (x , Hx) = ΣPathP (·IdR x , isProp→PathP (λ i → H (·IdR x i) .snd) _ _) invrHG : (x : HG) → x ·HG invHG x ≡ 1HG invrHG (x , Hx) = ΣPathP (·InvR x , isProp→PathP (λ i → H (·InvR x i) .snd) _ _) ⟪_⟫ : {G' : Group ℓ} → Subgroup G' → ℙ (G' .fst) ⟪ H , _ ⟫ = H module _ {G' : Group ℓ} where open GroupStr (snd G') open isSubgroup open GroupTheory G' private G = ⟨ G' ⟩ isNormal : Subgroup G' → Type ℓ isNormal H = (g h : G) → h ∈ ⟪ H ⟫ → g · h · inv g ∈ ⟪ H ⟫ isPropIsNormal : (H : Subgroup G') → isProp (isNormal H) isPropIsNormal H = isPropΠ3 λ g h _ → ∈-isProp ⟪ H ⟫ (g · h · inv g) ·CommNormalSubgroup : (H : Subgroup G') (Hnormal : isNormal H) {x y : G} → x · y ∈ ⟪ H ⟫ → y · x ∈ ⟪ H ⟫ ·CommNormalSubgroup H Hnormal {x = x} {y = y} Hxy = subst-∈ ⟪ H ⟫ rem (Hnormal (inv x) (x · y) Hxy) where rem : inv x · (x · y) · inv (inv x) ≡ y · x rem = inv x · (x · y) · inv (inv x) ≡⟨ ·Assoc _ _ _ ⟩ (inv x · x · y) · inv (inv x) ≡⟨ (λ i → ·Assoc (inv x) x y i · invInv x i) ⟩ ((inv x · x) · y) · x ≡⟨ cong (λ z → (z · y) · x) (·InvL x) ⟩ (1g · y) · x ≡⟨ cong (_· x) (·IdL y) ⟩ y · x ∎ -- Examples of subgroups -- We can view all of G as a subset of itself groupSubset : ℙ G groupSubset x = (x ≡ x) , is-set x x isSubgroupGroup : isSubgroup G' groupSubset id-closed isSubgroupGroup = refl op-closed isSubgroupGroup _ _ = refl inv-closed isSubgroupGroup _ = refl groupSubgroup : Subgroup G' groupSubgroup = groupSubset , isSubgroupGroup -- The trivial subgroup trivialSubset : ℙ G trivialSubset x = (x ≡ 1g) , is-set x 1g isSubgroupTrivialGroup : isSubgroup G' trivialSubset id-closed isSubgroupTrivialGroup = refl op-closed isSubgroupTrivialGroup hx hy = cong (_· _) hx ∙∙ ·IdL _ ∙∙ hy inv-closed isSubgroupTrivialGroup hx = cong inv hx ∙ inv1g trivialSubgroup : Subgroup G' trivialSubgroup = trivialSubset , isSubgroupTrivialGroup isNormalTrivialSubgroup : isNormal trivialSubgroup isNormalTrivialSubgroup g h h≡1 = (g · h · inv g) ≡⟨ (λ i → g · h≡1 i · inv g) ⟩ (g · 1g · inv g) ≡⟨ ·Assoc _ _ _ ∙ cong (_· inv g) (·IdR g) ⟩ (g · inv g) ≡⟨ ·InvR g ⟩ 1g ∎ NormalSubgroup : (G : Group ℓ) → Type _ NormalSubgroup G = Σ[ G ∈ Subgroup G ] isNormal G -- Can one get this to work with different universes for G and H? module _ {G H : Group ℓ} (ϕ : GroupHom G H) where open isSubgroup open GroupTheory private module G = GroupStr (snd G) module H = GroupStr (snd H) f = ϕ .fst module ϕ = IsGroupHom (ϕ .snd) imSubset : ℙ ⟨ H ⟩ imSubset x = isInIm ϕ x , isPropIsInIm ϕ x isSubgroupIm : isSubgroup H imSubset id-closed isSubgroupIm = ∣ G.1g , ϕ.pres1 ∣₁ op-closed isSubgroupIm = map2 λ { (x , hx) (y , hy) → x G.· y , ϕ.pres· x y ∙ λ i → hx i H.· hy i } inv-closed isSubgroupIm = map λ { (x , hx) → G.inv x , ϕ.presinv x ∙ cong H.inv hx } imSubgroup : Subgroup H imSubgroup = imSubset , isSubgroupIm imGroup : Group ℓ imGroup = Subgroup→Group _ imSubgroup isNormalIm : ((x y : ⟨ H ⟩) → x H.· y ≡ y H.· x) → isNormal imSubgroup isNormalIm comm x y = map λ {(g , p) → g , (ϕ .fst g ≡⟨ p ⟩ y ≡⟨ sym (H.·IdR y) ⟩ (y H.· H.1g) ≡⟨ cong (y H.·_) (sym (H.·InvR x)) ⟩ (y H.· (x H.· H.inv x)) ≡⟨ H.·Assoc y x (H.inv x) ⟩ ((y H.· x) H.· H.inv x) ≡⟨ cong (H._· H.inv x) (comm y x) ⟩ ((x H.· y) H.· H.inv x) ≡⟨ sym (H.·Assoc x y (H.inv x)) ⟩ x H.· y H.· H.inv x ∎ )} kerSubset : ℙ ⟨ G ⟩ kerSubset x = isInKer ϕ x , isPropIsInKer ϕ x isSubgroupKer : isSubgroup G kerSubset id-closed isSubgroupKer = ϕ.pres1 op-closed isSubgroupKer {x} {y} hx hy = ϕ.pres· x y ∙∙ (λ i → hx i H.· hy i) ∙∙ H.·IdR _ inv-closed isSubgroupKer hx = ϕ.presinv _ ∙∙ cong H.inv hx ∙∙ inv1g H kerSubgroup : Subgroup G kerSubgroup = kerSubset , isSubgroupKer isNormalKer : isNormal kerSubgroup isNormalKer x y hy = f (x G.· y G.· G.inv x) ≡⟨ ϕ.pres· _ _ ⟩ f x H.· f (y G.· G.inv x) ≡⟨ cong (f x H.·_) (ϕ.pres· _ _) ⟩ f x H.· f y H.· f (G.inv x) ≡⟨ (λ i → f x H.· hy i H.· f (G.inv x)) ⟩ f x H.· (H.1g H.· f (G.inv x)) ≡⟨ cong (f x H.·_) (H.·IdL _) ⟩ f x H.· f (G.inv x) ≡⟨ cong (f x H.·_) (ϕ.presinv x) ⟩ f x H.· H.inv (f x) ≡⟨ H.·InvR _ ⟩ H.1g ∎
{ "alphanum_fraction": 0.5703692934, "avg_line_length": 32.7523809524, "ext": "agda", "hexsha": "3e060f289b790f8a05a6152c2a8e754bf53b48c3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Subgroup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Subgroup.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Subgroup.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2799, "size": 6878 }
module CompleteSemantics.Iemhoff where open import Syntax public -- Introspective brilliant Kripke models. record Model : Set₁ where infix 3 _⊩ᵅ_ field World : Set _≤_ : World → World → Set refl≤ : ∀ {w} → w ≤ w trans≤ : ∀ {w w′ w″} → w ≤ w′ → w′ ≤ w″ → w ≤ w″ _R_ : World → World → Set reflR : ∀ {w} → w R w transR : ∀ {w w′ w″} → w R w′ → w′ R w″ → w R w″ _⊩ᵅ_ : World → Atom → Set mono⊩ᵅ : ∀ {w w′ P} → w ≤ w′ → w ⊩ᵅ P → w′ ⊩ᵅ P -- Introspection. field peek : World → Context _R⨾≤_ : World → World → Set _R⨾≤_ = _R_ ⨾ _≤_ -- Brilliance. field R⨾≤→R : ∀ {w v′} → w R⨾≤ v′ → w R v′ -- Vindication, as a consequence of brilliance. ≤→R : ∀ {w v′} → w ≤ v′ → w R v′ ≤→R {w} ψ = R⨾≤→R (w , (reflR , ψ)) open Model {{…}} public -- Forcing in a particular world of a particular model. module _ {{_ : Model}} where mutual infix 3 _⊪_ _⊪_ : World → Type → Set w ⊪ α P = w ⊩ᵅ P w ⊪ A ⇒ B = ∀ {w′} → w ≤ w′ → w′ ⊩ A → w′ ⊩ B w ⊪ □ A = ∀ {v′} → w R v′ → ∅ ⁏ π₂ (peek v′) ⊢ A ∧ v′ ⊩ A w ⊪ A ⩕ B = w ⊩ A ∧ w ⊩ B w ⊪ ⫪ = ⊤ w ⊪ ⫫ = ⊥ w ⊪ A ⩖ B = w ⊩ A ∨ w ⊩ B infix 3 _⊩_ _⊩_ : World → Type → Set w ⊩ A = ∀ {C w′} → w ≤ w′ → (∀ {w″} → w′ ≤ w″ → w″ ⊪ A → peek w″ ⊢ⁿᶠ C) → peek w′ ⊢ⁿᶠ C infix 3 _⊩⋆_ _⊩⋆_ : World → Stack Type → Set w ⊩⋆ ∅ = ⊤ w ⊩⋆ Ξ , A = w ⊩⋆ Ξ ∧ w ⊩ A -- Monotonicity of forcing with respect to constructive accessibility. module _ {{_ : Model}} where mutual mono⊪ : ∀ {A w w′} → w ≤ w′ → w ⊪ A → w′ ⊪ A mono⊪ {α P} ψ s = mono⊩ᵅ ψ s mono⊪ {A ⇒ B} ψ f = λ ψ′ a → f (trans≤ ψ ψ′) a mono⊪ {□ A} ψ f = λ ρ → f (transR (≤→R ψ) ρ) mono⊪ {A ⩕ B} ψ (a , b) = mono⊩ {A} ψ a , mono⊩ {B} ψ b mono⊪ {⫪} ψ ∙ = ∙ mono⊪ {⫫} ψ () mono⊪ {A ⩖ B} ψ (ι₁ a) = ι₁ (mono⊩ {A} ψ a) mono⊪ {A ⩖ B} ψ (ι₂ b) = ι₂ (mono⊩ {B} ψ b) mono⊩ : ∀ {A w w′} → w ≤ w′ → w ⊩ A → w′ ⊩ A mono⊩ ψ a = λ ψ′ κ → a (trans≤ ψ ψ′) κ mono⊩⋆ : ∀ {Ξ w w′} → w ≤ w′ → w ⊩⋆ Ξ → w′ ⊩⋆ Ξ mono⊩⋆ {∅} ψ ∙ = ∙ mono⊩⋆ {Ξ , A} ψ (ξ , s) = mono⊩⋆ {Ξ} ψ ξ , mono⊩ {A} ψ s -- Continuation-passing equipment. module _ {{_ : Model}} where return : ∀ {A w} → w ⊪ A → w ⊩ A return {A} a = λ ψ κ → κ refl≤ (mono⊪ {A} ψ a) bind : ∀ {A B w} → w ⊩ A → (∀ {w′} → w ≤ w′ → w′ ⊪ A → w′ ⊩ B) → w ⊩ B bind a κ = λ ψ κ′ → a ψ λ ψ′ a′ → κ (trans≤ ψ ψ′) a′ refl≤ λ ψ″ a″ → κ′ (trans≤ ψ′ ψ″) a″ -- Additional equipment. module _ {{_ : Model}} where lookup : ∀ {Ξ A w} → A ∈ Ξ → w ⊩⋆ Ξ → w ⊩ A lookup top (ξ , s) = s lookup (pop i) (ξ , s) = lookup i ξ -- Forcing in all worlds of all models, or semantic entailment. infix 3 _⊨_ _⊨_ : Context → Type → Set₁ Γ ⁏ Δ ⊨ A = ∀ {{_ : Model}} {w} → w ⊩⋆ Γ → (∀ {v′} → w R v′ → ∅ ⁏ π₂ (peek v′) ⊢⋆ Δ) → (∀ {v′} → w R v′ → v′ ⊩⋆ Δ) → w ⊩ A -- Soundness of the semantics with respect to the syntax. reflect : ∀ {Γ Δ A} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊨ A reflect (var i) γ τ δ = lookup i γ reflect (mvar i) γ τ δ = lookup i (δ reflR) reflect (lam {A} {B} d) γ τ δ = return {A ⇒ B} λ ψ a → reflect d (mono⊩⋆ ψ γ , a) (λ ρ → τ (transR (≤→R ψ) ρ)) (λ ρ → δ (transR (≤→R ψ) ρ)) reflect (app {A} {B} d e) γ τ δ = bind {A ⇒ B} {B} (reflect d γ τ δ) λ ψ f → f refl≤ (mono⊩ {A} ψ (reflect e γ τ δ)) reflect (box {A} d) γ τ δ = return {□ A} λ ρ → graft⊢ ∙ (τ ρ) d , reflect d ∙ (λ ρ′ → τ (transR ρ ρ′)) (λ ρ′ → δ (transR ρ ρ′)) reflect (unbox {A} {C} d e) γ τ δ = bind {□ A} {C} (reflect d γ τ δ) λ ψ s → reflect e (mono⊩⋆ ψ γ) (λ ρ → τ (transR (≤→R ψ) ρ) , π₁ (s ρ)) (λ ρ → δ (transR (≤→R ψ) ρ) , π₂ (s ρ)) reflect (pair {A} {B} d e) γ τ δ = return {A ⩕ B} (reflect d γ τ δ , reflect e γ τ δ) reflect (fst {A} {B} d) γ τ δ = bind {A ⩕ B} {A} (reflect d γ τ δ) λ { ψ (a , b) → a } reflect (snd {A} {B} d) γ τ δ = bind {A ⩕ B} {B} (reflect d γ τ δ) λ { ψ (a , b) → b } reflect unit γ τ δ = return {⫪} ∙ reflect (boom {C} d) γ τ δ = bind {⫫} {C} (reflect d γ τ δ) λ ψ → elim⊥ reflect (left {A} {B} d) γ τ δ = return {A ⩖ B} (ι₁ (reflect d γ τ δ)) reflect (right {A} {B} d) γ τ δ = return {A ⩖ B} (ι₂ (reflect d γ τ δ)) reflect (case {A} {B} {C} d e f) γ τ δ = bind {A ⩖ B} {C} (reflect d γ τ δ) λ { ψ (ι₁ a) → reflect e (mono⊩⋆ ψ γ , a) (λ ρ → τ (transR (≤→R ψ) ρ)) (λ ρ → δ (transR (≤→R ψ) ρ)) ; ψ (ι₂ b) → reflect f (mono⊩⋆ ψ γ , b) (λ ρ → τ (transR (≤→R ψ) ρ)) (λ ρ → δ (transR (≤→R ψ) ρ)) } -- The canonical model. private instance canon : Model canon = record { World = Context ; _≤_ = _⊆²_ ; refl≤ = refl⊆² ; trans≤ = trans⊆² ; _R_ = λ { (_ ⁏ Δ) (_ ⁏ Δ′) → Δ ⊆ Δ′ } ; reflR = refl⊆ ; transR = trans⊆ ; _⊩ᵅ_ = λ { (Γ ⁏ Δ) P → Γ ⁏ Δ ⊢ⁿᵉ α P } ; mono⊩ᵅ = mono⊢ⁿᵉ ; peek = id ; R⨾≤→R = λ { (_ , (ρ , (_ , ρ′))) → trans⊆ ρ ρ′ } } -- Soundness and completeness of the canonical model with respect to the syntax. mutual reflectᶜ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A → Γ ⁏ Δ ⊩ A reflectᶜ {α P} d = return {α P} d reflectᶜ {A ⇒ B} d = return {A ⇒ B} λ ψ a → reflectᶜ (appⁿᵉ (mono⊢ⁿᵉ ψ d) (reifyᶜ a)) reflectᶜ {□ A} d = λ ψ κ → neⁿᶠ (unboxⁿᵉ (mono⊢ⁿᵉ ψ d) (κ (refl⊆ , weak⊆) λ ρ′ → mono⊢ (bot , ρ′) mv₀ , reflectᶜ (mono⊢ⁿᵉ (bot , ρ′) mv₀ⁿᵉ))) reflectᶜ {A ⩕ B} d = return {A ⩕ B} (reflectᶜ (fstⁿᵉ d) , reflectᶜ (sndⁿᵉ d)) reflectᶜ {⫪} d = return {⫪} ∙ reflectᶜ {⫫} d = λ ψ κ → neⁿᶠ (boomⁿᵉ (mono⊢ⁿᵉ ψ d)) reflectᶜ {A ⩖ B} d = λ ψ κ → neⁿᶠ (caseⁿᵉ (mono⊢ⁿᵉ ψ d) (κ (weak⊆ , refl⊆) (ι₁ (reflectᶜ v₀ⁿᵉ))) (κ (weak⊆ , refl⊆) (ι₂ (reflectᶜ v₀ⁿᵉ)))) reifyᶜ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊩ A → Γ ⁏ Δ ⊢ⁿᶠ A reifyᶜ {α P} κ = κ refl⊆² λ ψ s → neⁿᶠ s reifyᶜ {A ⇒ B} κ = κ refl⊆² λ ψ f → lamⁿᶠ (reifyᶜ (f (weak⊆ , refl⊆) (reflectᶜ v₀ⁿᵉ))) reifyᶜ {□ A} κ = κ refl⊆² λ ψ f → boxⁿᶠ (π₁ (f {∅ ⁏ _} refl⊆)) reifyᶜ {A ⩕ B} κ = κ refl⊆² λ { ψ (a , b) → pairⁿᶠ (reifyᶜ a) (reifyᶜ b) } reifyᶜ {⫪} κ = κ refl⊆² λ { ψ ∙ → unitⁿᶠ } reifyᶜ {⫫} κ = κ refl⊆² λ ψ () reifyᶜ {A ⩖ B} κ = κ refl⊆² λ { ψ (ι₁ a) → leftⁿᶠ (reifyᶜ a) ; ψ (ι₂ b) → rightⁿᶠ (reifyᶜ b) } -- Reflexivity of simultaneous forcing. refl⊩⋆ : ∀ {Γ Δ} → Γ ⁏ Δ ⊩⋆ Γ refl⊩⋆ {∅} = ∙ refl⊩⋆ {Γ , A} = mono⊩⋆ (weak⊆ , refl⊆) refl⊩⋆ , reflectᶜ v₀ⁿᵉ mrefl⊩⋆ : ∀ {Δ Γ} → Γ ⁏ Δ ⊩⋆ Δ mrefl⊩⋆ {∅} = ∙ mrefl⊩⋆ {Δ , A} = mono⊩⋆ (refl⊆ , weak⊆) mrefl⊩⋆ , reflectᶜ mv₀ⁿᵉ -- Completeness of the semantics with respect to the syntax. reify : ∀ {Γ Δ A} → Γ ⁏ Δ ⊨ A → Γ ⁏ Δ ⊢ⁿᶠ A reify s = reifyᶜ (s refl⊩⋆ (λ ρ → mono⊢⋆ (refl⊆ , ρ) mrefl⊢⋆) (λ ρ → mono⊩⋆ (refl⊆ , ρ) mrefl⊩⋆)) -- Normalisation by evaluation. nbe : ∀ {Γ Δ A} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ⁿᶠ A nbe = reify ∘ reflect
{ "alphanum_fraction": 0.3620250232, "avg_line_length": 36.1171548117, "ext": "agda", "hexsha": "ff02449ca83473f32d3e3238e86a1456befc206e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/imla2017", "max_forks_repo_path": "src/CompleteSemantics/Iemhoff.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/imla2017", "max_issues_repo_path": "src/CompleteSemantics/Iemhoff.agda", "max_line_length": 101, "max_stars_count": 17, "max_stars_repo_head_hexsha": "accc6c57390c435728d568ae590a02b2776b8891", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/imla2017", "max_stars_repo_path": "src/CompleteSemantics/Iemhoff.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-17T13:02:58.000Z", "max_stars_repo_stars_event_min_datetime": "2017-02-27T05:04:55.000Z", "num_tokens": 3872, "size": 8632 }
module sum-thms where open import eq open import sum open import list open import product inj₁-inj : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}{x : A}{x'} → inj₁{ℓ}{ℓ'}{A}{B} x ≡ inj₁ x' → x ≡ x' inj₁-inj refl = refl
{ "alphanum_fraction": 0.6105769231, "avg_line_length": 18.9090909091, "ext": "agda", "hexsha": "75c084e2c667222edcbfb97ec7c65508628c634a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_path": "sum-thms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "logicshan/IAL", "max_issues_repo_path": "sum-thms.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_path": "sum-thms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 92, "size": 208 }
module MultiSorted.Context {s} (Sort : Set s) where -- An attempt to define more structured context -- that directly support the cartesian structure data Context : Set s where ctx-empty : Context ctx-slot : Sort → Context ctx-concat : Context → Context → Context -- the variables in a context data var : Context → Set where var-var : ∀ {A} → var (ctx-slot A) var-inl : ∀ {Γ Δ} → var Γ → var (ctx-concat Γ Δ) var-inr : ∀ {Γ Δ} → var Δ → var (ctx-concat Γ Δ) sort-of : ∀ (Γ : Context) → var Γ → Sort sort-of (ctx-slot A) _ = A sort-of (ctx-concat Γ Δ) (var-inl x) = sort-of Γ x sort-of (ctx-concat Γ Δ) (var-inr x) = sort-of Δ x -- It is absurd to have a variable in the empty context ctx-empty-absurd : ∀ {ℓ} {P : var ctx-empty → Set ℓ} (x : var ctx-empty) → P x ctx-empty-absurd ()
{ "alphanum_fraction": 0.6425902864, "avg_line_length": 32.12, "ext": "agda", "hexsha": "0c0c7f04252d6be2072b6ffe6fcebedd55f8c5b9", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/MultiSorted/Context.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/MultiSorted/Context.agda", "max_line_length": 78, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/MultiSorted/Context.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 263, "size": 803 }
{-# OPTIONS --prop #-} open import Agda.Primitive record LiftP {ℓ ℓ'}(A : Prop ℓ) : Prop (ℓ ⊔ ℓ') where constructor liftP field unliftP : A open LiftP public unliftP' : {ℓ ℓ' ℓ'' : Level} {A : Prop ℓ}{B : Set ℓ''}(f : A → B) → LiftP {ℓ}{ℓ'} A → B unliftP' f (liftP x) = f x
{ "alphanum_fraction": 0.5684210526, "avg_line_length": 21.9230769231, "ext": "agda", "hexsha": "b92630ba0529918218732b28fa0ebfd6469f84e3", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/SplitPropRecord.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/SplitPropRecord.agda", "max_line_length": 88, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/SplitPropRecord.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 125, "size": 285 }
{-# OPTIONS --cubical --no-import-sorts #-} module Cubical.Codata.Everything where open import Cubical.Codata.EverythingSafe public --- Modules making assumptions that might be incompatible with other -- flags or make use of potentially unsafe features. -- Assumes --guardedness open import Cubical.Codata.Stream public open import Cubical.Codata.Conat public open import Cubical.Codata.M public -- Also uses {-# TERMINATING #-}. open import Cubical.Codata.M.Bisimilarity public {- -- Alternative M type implemetation, based on -- https://arxiv.org/pdf/1504.02949.pdf -- "Non-wellfounded trees in Homotopy Type Theory" -- Benedikt Ahrens, Paolo Capriotti, Régis Spadotti -} open import Cubical.Codata.M.AsLimit.M open import Cubical.Codata.M.AsLimit.Coalg open import Cubical.Codata.M.AsLimit.helper open import Cubical.Codata.M.AsLimit.Container open import Cubical.Codata.M.AsLimit.itree open import Cubical.Codata.M.AsLimit.stream
{ "alphanum_fraction": 0.7857900318, "avg_line_length": 29.46875, "ext": "agda", "hexsha": "cbe837ff3ae8033f5410a65b0e9fceea26dc43f2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Codata/Everything.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Codata/Everything.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Codata/Everything.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 244, "size": 943 }
module Automaton.Pushdown where
{ "alphanum_fraction": 0.875, "avg_line_length": 16, "ext": "agda", "hexsha": "bc3187ac2d661584de3fe936123e5e031f659483", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Automaton/Pushdown.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Automaton/Pushdown.agda", "max_line_length": 31, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Automaton/Pushdown.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 7, "size": 32 }
module Naturals where open import Library open import Categories open import Functors open Fun record NatT {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(F G : Fun C D) : Set (a ⊔ b ⊔ c ⊔ d) where constructor natural open Cat field cmp : ∀ {X} → Hom D (OMap F X) (OMap G X) nat : ∀{X Y}{f : Hom C X Y} → comp D (HMap G f) cmp ≅ comp D cmp (HMap F f) NatTEq : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G : Fun C D} {α β : NatT F G} → (λ {X} → NatT.cmp α {X}) ≅ (λ {X} → NatT.cmp β {X}) → α ≅ β NatTEq {α = natural cmp _} {natural .cmp _} refl = cong (natural cmp) (iext λ _ → iext λ _ → iext λ _ → ir _ _) idNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F : Fun C D} → NatT F F idNat {D = D}{F} = let open Cat D in record { cmp = iden; nat = λ{X}{Y}{f} → proof comp (HMap F f) iden ≅⟨ idr ⟩ HMap F f ≅⟨ sym idl ⟩ comp iden (HMap F f) ∎} compNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G H : Fun C D} → NatT G H → NatT F G → NatT F H compNat {D = D}{F}{G}{H} α β = let open Cat D; open NatT in record { cmp = comp (cmp α) (cmp β); nat = λ{X}{Y}{f} → proof comp (HMap H f) (comp (cmp α) (cmp β)) ≅⟨ sym ass ⟩ comp (comp (HMap H f) (cmp α)) (cmp β) ≅⟨ cong (λ f₁ → comp f₁ (cmp β)) (nat α) ⟩ comp (comp (cmp α) (HMap G f)) (cmp β) ≅⟨ ass ⟩ comp (cmp α) (comp (HMap G f) (cmp β)) ≅⟨ cong (comp (cmp α)) (nat β) ⟩ comp (cmp α) (comp (cmp β) (HMap F f)) ≅⟨ sym ass ⟩ comp (comp (cmp α) (cmp β)) (HMap F f) ∎} idlNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G : Fun C D} {α : NatT F G} → compNat idNat α ≅ α idlNat {D = D} = NatTEq (iext λ _ → Cat.idl D) idrNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{F G : Fun C D} {α : NatT F G} → compNat α idNat ≅ α idrNat {D = D} = NatTEq (iext λ _ → Cat.idr D) assNat : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{E F G H : Fun C D} {α : NatT G H}{β : NatT F G}{η : NatT E F} → compNat (compNat α β) η ≅ compNat α (compNat β η) assNat {D = D} = NatTEq (iext λ _ → Cat.ass D) -- Natural isomorphism record Iso {l m}(C : Cat {l}{m}){A B}(f : Cat.Hom C A B) : Set (l ⊔ m) where constructor iso open Cat C field inv : Hom B A rinv : comp f inv ≅ iden {B} linv : comp inv f ≅ iden {A} record NatI {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(F G : Fun C D) : Set (a ⊔ b ⊔ c ⊔ d) where constructor natural open Cat field cmp : ∀ {X} → Hom D (OMap F X) (OMap G X) cmpI : ∀{X} -> Iso D (cmp {X}) nat : ∀{X Y}{f : Hom C X Y} → comp D (HMap G f) cmp ≅ comp D cmp (HMap F f)
{ "alphanum_fraction": 0.4864463424, "avg_line_length": 30.9540229885, "ext": "agda", "hexsha": "5600dc0ae58742db06a99c1fa14f49107643ca07", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "Naturals.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "Naturals.agda", "max_line_length": 74, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "Naturals.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 1189, "size": 2693 }
module PushProdPull where open import Categories.Category open import Categories.Category.Cartesian.Bundle open import Categories.Category.CartesianClosed.Canonical open import Categories.Category.Core open import Categories.Category.Product open import Categories.Diagram.Pullback open import Categories.Diagram.Pushout open import Categories.Functor open import Categories.Functor.Bifunctor open import Data.Product open import Function using (const) open import Level open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality open Relation.Binary.PropositionalEquality.≡-Reasoning postulate extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) → f ≡ g data t : Set where ⊤ : t !-unique-lemma : ∀ (x : t) → ⊤ ≡ x !-unique-lemma ⊤ = refl arrow : Category (suc zero) zero zero arrow = record { Obj = Σ (Set × Set) (λ x → proj₁ x → proj₂ x) ; _⇒_ = arr ; _≈_ = _≡_ ; id = (λ z → z) , λ z → z ; _∘_ = λ {A} {B} {C} f g → comp {A} {B} {C} f g ; assoc = refl ; sym-assoc = refl ; identityˡ = refl ; identityʳ = refl ; identity² = refl ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = λ {refl refl → refl} } where arr : Rel (Σ (Set × Set) (λ x → proj₁ x → proj₂ x)) zero arr ((a , b) , x1) ((c , d) , y1) = (a → c) × (b → d) comp : {A B C : Σ (Set × Set) (λ x → proj₁ x → proj₂ x)} → arr B C → arr A B → arr A C comp {A} {B} {C} (f0 , f1) (g0 , g1) = (λ x → f0 (g0 x)) , λ x → f1 (g1 x) open Category arrow SetC : Category (suc zero) zero zero SetC = record { Obj = Set ; _⇒_ = λ x y → x → y ; _≈_ = _≡_ ; id = λ x → x ; _∘_ = λ f g a → f (g a) ; assoc = refl ; sym-assoc = refl ; identityˡ = refl ; identityʳ = refl ; identity² = refl ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = λ {refl refl → refl} } pushout-prod : (f g : Obj) → Obj pushout-prod ((A0 , A1) , f) ((B0 , B1) , g) = {! !} -- Pushout SetC f×1 1×g -- where -- f×1 : A0 × B0 → A1 × B0 -- f×1 (a , b) = f a , b -- 1×g : A0 × B0 → A0 × B1 -- 1×g (a , b) = a , g b pullback-hom : (f g : Obj) → Obj pullback-hom ((A0 , A1) , f) ((B0 , B1) , g) = {! !} -- Pullback SetC [f,1] [1,g] -- where -- [f,1] : (A1 → B1) → A0 → B1 -- [f,1] u = λ x → u (f x) -- [1,g] : (A0 → B0) → A0 → B1 -- [1,g] u = λ x → g (u x) pp-is-functor : Endobifunctor arrow pp-is-functor = record { F₀ = F0 ; F₁ = {! !} ; identity = {! !} ; homomorphism = {! !} ; F-resp-≈ = {! !} } where F0 : Category.Obj (Categories.Category.Product.Product arrow arrow) → Obj F0 x = pullback-hom (proj₁ x) (proj₂ x) F1 : {A B : Obj × Obj} → Product arrow arrow Categories.Category.[ A , B ] → arrow Categories.Category.[ F0 A , F0 B ] F1 {((A0 , A1) , a) , ((B0 , B1) , b)} {((C0 , C1) , c) , ((D0 , D1) , d)} ((u , v) , s , t) = {! !}
{ "alphanum_fraction": 0.5584866366, "avg_line_length": 28.5247524752, "ext": "agda", "hexsha": "c22edf11c15e71da837ae70960890c23c5f30ecf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cfa6aefd3069d4db995191b458c886edcfba8294", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tetrapharmakon/agda-categories", "max_forks_repo_path": "src/PushProdPull.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cfa6aefd3069d4db995191b458c886edcfba8294", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tetrapharmakon/agda-categories", "max_issues_repo_path": "src/PushProdPull.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "cfa6aefd3069d4db995191b458c886edcfba8294", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tetrapharmakon/agda-categories", "max_stars_repo_path": "src/PushProdPull.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1172, "size": 2881 }
module Esterel.Lang.Properties where open import Esterel.Lang open import Relation.Binary.PropositionalEquality open import Relation.Unary open import Relation.Nullary using (¬_ ; Dec ; yes ; no) open import Esterel.Environment open import Esterel.Variable.Signal as Signal open import Esterel.Variable.Shared as SharedVar open import Esterel.Context using (EvaluationContext ; EvaluationContext1 ; _⟦_⟧e ; _≐_⟦_⟧e ; Context ; Context1 ; _⟦_⟧c ; _≐_⟦_⟧c) open import Esterel.Context.Properties open import Data.Empty using (⊥ ; ⊥-elim) open import Data.Nat using (ℕ ; zero ; suc) renaming (_⊔_ to _⊔ℕ_) open import Data.MoreNatProp using (⊔-sym) open import Data.Product using (Σ-syntax ; Σ ; _,_ ; _,′_ ; proj₁ ; proj₂ ; _×_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Data.List open import Data.Maybe open import Data.List.Any open import Data.List.All open import Data.OrderedListMap open import Function using (_$_) import Data.OrderedListMap(Signal)(Signal.unwrap)(Signal.Status) as SigOMap import Data.OrderedListMap(SharedVar)(SharedVar.unwrap)(SharedVar.Status × ℕ) as ShrOMap open ≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎) open EvaluationContext1 open _≐_⟦_⟧e open Context1 open _≐_⟦_⟧c data halted : Term → Set where hnothin : halted nothin hexit : (n : ℕ) → halted (exit n) data paused : Term → Set where ppause : paused pause pseq : ∀{p q} → paused p → paused (p >> q) ploopˢ : ∀{p q} → paused p → paused (loopˢ p q) ppar : ∀{p q} → paused p → paused q → paused (p ∥ q) psuspend : ∀{p S} → paused p → paused (suspend p S) ptrap : ∀{p} → paused p → paused (trap p) data done : Term → Set where dhalted : ∀{p} → (p/halted : halted p) → done p dpaused : ∀{p} → (p/paused : paused p) → done p data complete-θ : Env → Set where θcomplete : ∀{θ} → (∀ S → (S∈ : isSig∈ S θ) → ((sig-stats{S} θ S∈ ≡ Signal.absent) ⊎ (sig-stats{S} θ S∈ ≡ Signal.present))) → (∀ s → (s∈ : isShr∈ s θ) → (shr-stats{s} θ s∈ ≡ SharedVar.ready)) → --------------- complete-θ θ data complete : Term → Set where codone : ∀{p} → done p → complete p coenv : ∀{θ A p} → complete-θ θ → done p → complete (ρ⟨ θ , A ⟩· p) -- Halted and paused programs are disjoint halted-paused-disjoint : ∀{p} → halted p → paused p → ⊥ halted-paused-disjoint hnothin () halted-paused-disjoint (hexit _) () ↓_ : ∀ {p} → halted p → Term ↓ hnothin = nothin ↓ hexit zero = nothin ↓ hexit (suc n) = exit n ↓-well-behaved : ∀ p -> (haltedp : halted p) -> halted (↓ haltedp) ↓-well-behaved .nothin hnothin = hnothin ↓-well-behaved .(exit 0) (hexit zero) = hnothin ↓-well-behaved .(exit (suc n)) (hexit (suc n)) = hexit n A-max : Ctrl → Ctrl → Ctrl A-max GO GO = GO A-max GO WAIT = GO A-max WAIT GO = GO A-max WAIT WAIT = WAIT value-max : ∀{p q} → done p → done q → (halted p ⊎ halted q) → Term value-max {q = q} (dhalted hnothin) done-q h⊎h = q value-max {p = p} done-p (dhalted hnothin) h⊎h = p value-max (dhalted (hexit n)) (dhalted (hexit m)) h⊎h = exit (n ⊔ℕ m) value-max (dhalted (hexit n)) (dpaused _) h⊎h = exit n value-max (dpaused _) (dhalted (hexit m)) h⊎h = exit m value-max (dpaused paused-p) (dpaused paused-q) (inj₁ halted-p) = ⊥-elim (halted-paused-disjoint halted-p paused-p) value-max (dpaused paused-p) (dpaused paused-q) (inj₂ halted-q) = ⊥-elim (halted-paused-disjoint halted-q paused-q) value-max-unique : ∀{p q d1 d2 d3 d4 ij1 ij2} → value-max{p}{q} d1 d2 ij1 ≡ value-max{p}{q} d3 d4 ij2 value-max-unique {d1 = dhalted hnothin} {d2} {dhalted hnothin} {d4} {ij1} {ij2} = refl value-max-unique {d1 = dhalted (hexit n)} {dhalted hnothin} {dhalted (hexit .n)} {dhalted hnothin} {ij1} {ij2} = refl value-max-unique {d1 = dpaused p/paused} {dhalted hnothin} {dpaused p/paused'} {dhalted hnothin} {ij1} {ij2} = refl value-max-unique {d1 = dhalted (hexit n)} {dhalted (hexit m)} {dhalted (hexit .n)} {dhalted (hexit .m)} {ij1} {ij2} = refl value-max-unique {d1 = dhalted (hexit n)} {dpaused q/paused} {dhalted (hexit .n)} {dpaused q/paused'} {ij1} {ij2} = refl value-max-unique {d1 = dpaused p/paused} {dhalted (hexit n)} {dpaused p/paused'} {dhalted (hexit .n)} {ij1} {ij2} = refl value-max-unique {d1 = dpaused p/paused} {dpaused q/paused} {dpaused p/paused'} {dpaused q/paused'} {inj₁ p/halted} {ij2} = ⊥-elim (halted-paused-disjoint p/halted p/paused') value-max-unique {d1 = dpaused p/paused} {dpaused q/paused} {dpaused p/paused'} {dpaused q/paused'} {inj₂ q/halted} {ij2} = ⊥-elim (halted-paused-disjoint q/halted q/paused') value-max-unique {d1 = dhalted p/halted} {d2} {dpaused p/paused'} {d4} {ij1} {ij2} = ⊥-elim (halted-paused-disjoint p/halted p/paused') value-max-unique {d1 = dpaused p/paused} {d2} {dhalted p/halted'} {d4} {ij1} {ij2} = ⊥-elim (halted-paused-disjoint p/halted' p/paused) value-max-unique {d1 = d1} {dhalted q/halted} {d3} {dpaused q/paused} {ij1} {ij2} = ⊥-elim (halted-paused-disjoint q/halted q/paused) value-max-unique {d1 = d1} {dpaused q/paused} {d3} {dhalted q/halted} {ij1} {ij2} = ⊥-elim (halted-paused-disjoint q/halted q/paused) value-max-sym : ∀ {p q} -> (donep : done p) -> (haltedq : halted q) -> value-max donep (dhalted haltedq) (inj₂ haltedq) ≡ value-max (dhalted haltedq) donep (inj₁ haltedq) value-max-sym (dhalted hnothin) hnothin = refl value-max-sym (dhalted hnothin) (hexit n) = refl value-max-sym (dhalted (hexit n)) hnothin = refl value-max-sym (dhalted (hexit n)) (hexit m) rewrite ⊔-sym n m = refl value-max-sym (dpaused p/paused) hnothin = refl value-max-sym (dpaused p/paused) (hexit n) = refl value-max-done : ∀ {p q} → (p/done : done p) → (q/done : done q) → (p/halted⊎q/halted : halted p ⊎ halted q) → done (value-max p/done q/done p/halted⊎q/halted) value-max-done (dhalted hnothin) q/done ⟨p⊎q⟩/halted = q/done value-max-done (dhalted (hexit n)) (dhalted hnothin) ⟨p⊎q⟩/halted = dhalted (hexit n) value-max-done (dhalted (hexit n)) (dhalted (hexit m)) ⟨p⊎q⟩/halted = dhalted (hexit (n ⊔ℕ m)) value-max-done (dhalted (hexit n)) (dpaused q/paused) ⟨p⊎q⟩/halted = dhalted (hexit n) value-max-done (dpaused p/paused) (dhalted hnothin) ⟨p⊎q⟩/halted = dpaused p/paused value-max-done (dpaused p/paused) (dhalted (hexit m)) ⟨p⊎q⟩/halted = dhalted (hexit m) value-max-done (dpaused p/paused) (dpaused q/paused) (inj₁ p/halted) = ⊥-elim (halted-paused-disjoint p/halted p/paused) value-max-done (dpaused p/paused) (dpaused q/paused) (inj₂ q/halted) = ⊥-elim (halted-paused-disjoint q/halted q/paused) {- Properties relating halted, paused, done programs and the contexts. There's no way to decompose halted programs, so the result must remain halted. The decomposition of paused programs under the evaluation context must result in paused programs. halted-⟦⟧c : ∀{p p' C} → halted p → p ≐ C ⟦ p' ⟧c → halted p' paused-⟦⟧e : ∀{p p' E} → paused p → p ≐ E ⟦ p' ⟧e → paused p' -} halted-⟦⟧c : ∀{p p' C} → halted p → p ≐ C ⟦ p' ⟧c → halted p' halted-⟦⟧c hnothin dchole = hnothin halted-⟦⟧c (hexit n) dchole = hexit n -- In fact, the only valid case would be E ≡ [] and p ≡ p' halted-⟦⟧e : ∀{p p' E} → halted p → p ≐ E ⟦ p' ⟧e → halted p' halted-⟦⟧e p/halted p≐E⟦p'⟧ = halted-⟦⟧c p/halted (⟦⟧e-to-⟦⟧c p≐E⟦p'⟧) paused-⟦⟧e : ∀{p p' E} → paused p → p ≐ E ⟦ p' ⟧e → paused p' paused-⟦⟧e ppause dehole = ppause paused-⟦⟧e (pseq paused) dehole = pseq paused paused-⟦⟧e (pseq paused) (deseq d) = paused-⟦⟧e paused d paused-⟦⟧e (ploopˢ paused) dehole = ploopˢ paused paused-⟦⟧e (ploopˢ paused) (deloopˢ d) = paused-⟦⟧e paused d paused-⟦⟧e (ppar paused₁ paused₂) dehole = ppar paused₁ paused₂ paused-⟦⟧e (ppar paused₁ paused₂) (depar₁ d) = paused-⟦⟧e paused₁ d paused-⟦⟧e (ppar paused₁ paused₂) (depar₂ d) = paused-⟦⟧e paused₂ d paused-⟦⟧e (psuspend paused) dehole = psuspend paused paused-⟦⟧e (psuspend paused) (desuspend d) = paused-⟦⟧e paused d paused-⟦⟧e (ptrap paused) dehole = ptrap paused paused-⟦⟧e (ptrap paused) (detrap d) = paused-⟦⟧e paused d done-⟦⟧e : ∀ {p p' E} → done p → p ≐ E ⟦ p' ⟧e → done p' done-⟦⟧e (dhalted p/halted) p≐E⟦p'⟧ = dhalted (halted-⟦⟧e p/halted p≐E⟦p'⟧) done-⟦⟧e (dpaused p/paused) p≐E⟦p'⟧ = dpaused (paused-⟦⟧e p/paused p≐E⟦p'⟧) halted-dec : ∀ p -> Dec (halted p) halted-dec nothin = yes hnothin halted-dec pause = no (λ ()) halted-dec (signl S p) = no (λ ()) halted-dec (present S ∣⇒ p ∣⇒ p₁) = no (λ ()) halted-dec (emit S) = no (λ ()) halted-dec (p ∥ q) = no (λ ()) halted-dec (loop p) = no (λ ()) halted-dec (loopˢ p q) = no (λ ()) halted-dec (p >> q) = no (λ ()) halted-dec (suspend p S) = no (λ ()) halted-dec (trap p) = no (λ ()) halted-dec (exit x) = yes (hexit x) halted-dec (shared s ≔ e in: p) = no (λ ()) halted-dec (s ⇐ e) = no (λ ()) halted-dec (var x ≔ e in: p) = no (λ ()) halted-dec (x ≔ e) = no (λ ()) halted-dec (if x ∣⇒ p ∣⇒ q) = no (λ ()) halted-dec (ρ⟨ θ , A ⟩· p) = no (λ ()) paused-dec : ∀ p -> Dec (paused p) paused-dec nothin = no (λ ()) paused-dec pause = yes ppause paused-dec (signl S p) = no (λ ()) paused-dec (present S ∣⇒ p ∣⇒ p₁) = no (λ ()) paused-dec (emit S) = no (λ ()) paused-dec (p ∥ q) with paused-dec p | paused-dec q paused-dec (p ∥ q) | yes pausedp | yes pausedq = yes (ppar pausedp pausedq) paused-dec (p ∥ q) | _ | no ¬pausedq = no (λ { (ppar _ pausedq) → ¬pausedq pausedq } ) paused-dec (p ∥ q) | no ¬pausedp | _ = no (λ { (ppar pausedp _) → ¬pausedp pausedp } ) paused-dec (loop p) = no (λ ()) paused-dec (loopˢ p q) with paused-dec p paused-dec (loopˢ p q) | yes pausedp = yes (ploopˢ pausedp) paused-dec (loopˢ p q) | no ¬pausedp = no (λ { (ploopˢ pausedp) → ¬pausedp pausedp }) paused-dec (p >> q) with paused-dec p paused-dec (p >> q) | yes pausedp = yes (pseq pausedp) paused-dec (p >> q) | no ¬pausedp = no (λ { (pseq pausedp) → ¬pausedp pausedp }) paused-dec (suspend p S) with paused-dec p paused-dec (suspend p S) | yes pausedp = yes (psuspend pausedp) paused-dec (suspend p S) | no ¬pausedp = no (λ { (psuspend pausedp) → ¬pausedp pausedp }) paused-dec (trap p) with paused-dec p paused-dec (trap p) | yes pasuedp = yes (ptrap pasuedp) paused-dec (trap p) | no ¬pausedp = no (λ { (ptrap pausedp) → ¬pausedp pausedp }) paused-dec (exit x) = no (λ ()) paused-dec (shared s ≔ e in: p) = no (λ ()) paused-dec (s ⇐ e) = no (λ ()) paused-dec (var x ≔ e in: p) = no (λ ()) paused-dec (x ≔ e) = no (λ ()) paused-dec (if x ∣⇒ p ∣⇒ q) = no (λ ()) paused-dec (ρ⟨ θ , A ⟩· p) = no (λ ()) done-dec : ∀ p → Dec (done p) done-dec p with halted-dec p done-dec p | yes halted-p = yes (dhalted halted-p) done-dec p | no ¬halted-p with paused-dec p done-dec p | no _ | yes paused-p = yes (dpaused paused-p) done-dec p | no ¬halted-p | (no ¬paused-p) = no (λ { (dhalted p/halted) → ¬halted-p p/halted ; (dpaused p/paused) → ¬paused-p p/paused}) signal-absent-or-present : Signal.Status → Set signal-absent-or-present S = S ≡ Signal.absent ⊎ S ≡ Signal.present signal-absent-or-present-dec : Decidable signal-absent-or-present signal-absent-or-present-dec present = yes (inj₂ refl) signal-absent-or-present-dec absent = yes (inj₁ refl) signal-absent-or-present-dec unknown = no (λ { (inj₁ ()) ; (inj₂ ())}) signals-all-absent-or-present-dec : (Ss : SigMap.Map Signal.Status) -> Dec (∀ S → (S∈ : (SigMap.∈Dom S Ss)) → (signal-absent-or-present (SigMap.lookup{k = S} Ss S∈))) signals-all-absent-or-present-dec m with SigOMap.andmap{_}{signal-absent-or-present} signal-absent-or-present-dec m signals-all-absent-or-present-dec m | yes p = yes (λ S → p (Signal.unwrap S)) signals-all-absent-or-present-dec m | no ¬p = no (λ z → ¬p (λ n → z (n ₛ))) var-is-ready : SharedVar.Status × ℕ → Set var-is-ready p = (proj₁ p) ≡ SharedVar.ready var-is-ready-dec : Decidable var-is-ready var-is-ready-dec (ready , _) = yes refl var-is-ready-dec (new , _) = no (λ ()) var-is-ready-dec (old , _) = no (λ ()) vars-all-ready-dec : (ss : ShrMap.Map (SharedVar.Status × ℕ)) -> Dec (∀ s → (s∈ : ShrMap.∈Dom s ss) → var-is-ready (ShrMap.lookup{k = s} ss s∈)) vars-all-ready-dec ss with ShrOMap.andmap{_}{var-is-ready} var-is-ready-dec ss vars-all-ready-dec ss | yes p = yes (λ s → p (SharedVar.unwrap s)) vars-all-ready-dec ss | no ¬p = no (λ z → ¬p (λ n → z (n ₛₕ))) complete-θ-dec : ∀ θ → Dec (complete-θ θ) complete-θ-dec (Θ sigs shr _) with signals-all-absent-or-present-dec sigs complete-θ-dec (Θ sigs shrs _) | yes p with vars-all-ready-dec shrs complete-θ-dec (Θ sigs shrs _) | yes p₁ | yes p₂ = yes (θcomplete p₁ p₂) complete-θ-dec (Θ sigs shrs _) | yes _ | no ¬p = no (λ { (θcomplete _ x) → ¬p x } ) complete-θ-dec (Θ sigs shrs _) | no ¬p = no (λ { (θcomplete x _) → ¬p x } ) complete-dec : ∀ p → Dec (complete p) complete-dec p with done-dec p complete-dec p | yes donep = yes (codone donep) complete-dec nothin | no ¬donep = no (λ _ → ¬donep (dhalted hnothin)) complete-dec pause | no ¬donep = no (λ _ → ¬donep (dpaused ppause)) complete-dec (signl S p) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (present S ∣⇒ p ∣⇒ p₁) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (emit S) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (p ∥ p₁) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (loop p) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (loopˢ p q) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (p >> p₁) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (suspend p S) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (trap p) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (exit x) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (shared s ≔ e in: p) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (s ⇐ e) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (var x ≔ e in: p) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (x ≔ e) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (if x ∣⇒ p ∣⇒ p₁) | no ¬donep = no (λ { (codone x) → ¬donep x } ) complete-dec (ρ⟨ θ , A ⟩· p) | _ with done-dec p complete-dec (ρ⟨ θ , A ⟩· p) | _ | yes donep with complete-θ-dec θ complete-dec (ρ⟨ θ , A ⟩· p) | _ | yes donep | (yes complete-θ) = yes (coenv complete-θ donep) complete-dec (ρ⟨ θ , A ⟩· p) | _ | yes donep | (no ¬complete-θ) = no (λ { (codone (dhalted ())) ; (codone (dpaused ())) ; (coenv complete-θ _) → ¬complete-θ complete-θ }) complete-dec (ρ⟨ θ , A ⟩· p) | _ | no ¬donep = no (λ { (codone (dhalted ())) ; (codone (dpaused ())) ; (coenv _ donep) → ¬donep donep }) A-max-GO-≡-left : ∀ A → A-max GO A ≡ GO A-max-GO-≡-left GO = refl A-max-GO-≡-left WAIT = refl A-max-GO-≡-right : ∀ A → A-max A GO ≡ GO A-max-GO-≡-right GO = refl A-max-GO-≡-right WAIT = refl A-max-comm : ∀ A1 A2 → A-max A1 A2 ≡ A-max A2 A1 A-max-comm GO GO = refl A-max-comm GO WAIT = refl A-max-comm WAIT GO = refl A-max-comm WAIT WAIT = refl A-max-assoc : ∀ A1 A2 A3 → (A-max A1 $ A-max A2 A3) ≡ A-max (A-max A1 A2) A3 A-max-assoc GO GO GO = refl A-max-assoc GO GO WAIT = refl A-max-assoc GO WAIT GO = refl A-max-assoc GO WAIT WAIT = refl A-max-assoc WAIT GO GO = refl A-max-assoc WAIT GO WAIT = refl A-max-assoc WAIT WAIT GO = refl A-max-assoc WAIT WAIT WAIT = refl A-max-swap : ∀ A1 A2 A3 → (A-max (A-max A1 A2) A3) ≡ (A-max (A-max A1 A3) A2) A-max-swap A1 A2 A3 = begin (A-max (A-max A1 A2) A3) ≡⟨ sym (A-max-assoc A1 A2 A3) ⟩ (A-max A1 $ A-max A2 A3) ≡⟨ sym (cong (A-max A1) (A-max-comm A3 A2)) ⟩ (A-max A1 $ A-max A3 A2) ≡⟨ A-max-assoc A1 A3 A2 ⟩ (A-max (A-max A1 A3) A2) ∎
{ "alphanum_fraction": 0.6146771654, "avg_line_length": 45.2279202279, "ext": "agda", "hexsha": "4091afc553536dbc359b39a2ef2ba87a5bd3a503", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Esterel/Lang/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/Esterel/Lang/Properties.agda", "max_line_length": 126, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Esterel/Lang/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 6339, "size": 15875 }
------------------------------------------------------------------------ -- Safe modules that use --erased-cubical and --guardedness ------------------------------------------------------------------------ {-# OPTIONS --safe --erased-cubical --guardedness #-} module README.Safe.Cubical.Erased.Guardedness where -- M-types for indexed containers, defined coinductively (in Cubical -- Agda). import Container.Indexed.Variant.M.Codata import Container.Indexed.M.Codata
{ "alphanum_fraction": 0.5286624204, "avg_line_length": 33.6428571429, "ext": "agda", "hexsha": "37a3a3842669512c07c0cb86108057bf1223e940", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "README/Safe/Cubical/Erased/Guardedness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "README/Safe/Cubical/Erased/Guardedness.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "README/Safe/Cubical/Erased/Guardedness.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 88, "size": 471 }
module OpenModule where module A where postulate X : Set -- Both open import and open module applies the directives -- to the "open" rather than to the module. open import Nat hiding (zero) renaming (Nat to N) open module B = A renaming (X to Y) Test : Set Test = Y → B.X → N → Nat.Nat zero : N zero = Nat.zero -- If the module isn't opened the directives are applied to -- the module. import Nat as N renaming (Nat to N) module C = A renaming (X to Z) Test₂ : Set Test₂ = N.N → C.Z
{ "alphanum_fraction": 0.6820925553, "avg_line_length": 19.88, "ext": "agda", "hexsha": "b9bc34242074ed9e5841cfbd45012ff3814e260c", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/OpenModule.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/OpenModule.agda", "max_line_length": 59, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/OpenModule.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 143, "size": 497 }
-- The category of contexts and renamings module SOAS.ContextMaps.CategoryOfRenamings {T : Set} where open import SOAS.Common open import SOAS.Context {T} open import SOAS.Variable open import SOAS.ContextMaps.Combinators (ℐ {T}) open import Categories.Functor.Bifunctor open import Categories.Object.Initial open import Categories.Object.Coproduct open import Categories.Category.Cocartesian import Categories.Morphism -- The category of contexts and renamings, defined as the Lawvere theory -- associated with the clone of variables. In elementary terms it has -- contexts Γ, Δ as objects, and renamings Γ ↝ Δ ≜ Γ ~[ ℐ → ℐ ]↝ Δ as arrows. 𝔽 : Category 0ℓ 0ℓ 0ℓ 𝔽 = categoryHelper (record { Obj = Ctx ; _⇒_ = _↝_ ; _≈_ = λ {Γ} ρ₁ ρ₂ → ∀{α : T}{v : ℐ α Γ} → ρ₁ v ≡ ρ₂ v ; id = λ x → x ; _∘_ = λ ϱ ρ v → ϱ (ρ v) ; assoc = refl ; identityˡ = refl ; identityʳ = refl ; equiv = record { refl = refl ; sym = λ p → sym p ; trans = λ p q → trans p q } ; ∘-resp-≈ = λ{ {f = ρ₁} p₁ p₂ → trans (cong ρ₁ p₂) p₁ } }) module 𝔽 = Category 𝔽 using (op) renaming ( _∘_ to _∘ᵣ_ ; _≈_ to _≈ᵣ_ ; id to idᵣ ; ∘-resp-≈ to ∘-resp-≈ᵣ ) open 𝔽 public id′ᵣ : (Γ : Ctx) → Γ ↝ Γ id′ᵣ Γ = idᵣ {Γ} -- Category of context is co-Cartesian, given by the empty initial context and -- context concatenation as the monoidal product. 𝔽:Cocartesian : Cocartesian 𝔽 𝔽:Cocartesian = record { initial = record { ⊥ = ∅ ; ⊥-is-initial = record { ! = λ{()} ; !-unique = λ{ f {_} {()}} } } ; coproducts = record { coproduct = λ {Γ}{Δ} → record { A+B = Γ ∔ Δ ; i₁ = expandʳ Δ ; i₂ = expandˡ Γ ; [_,_] = copair ; inject₁ = λ{ {Θ}{ρ}{ϱ} → i₁-commute ρ ϱ _ } ; inject₂ = λ{ {Θ}{ρ}{ϱ} → i₂-commute ρ ϱ _ } ; unique = λ{ p₁ p₂ → unique {Γ}{Δ} _ _ _ p₁ p₂ _ } } } } where in₁ : (Γ Δ : Ctx) → Γ ↝ Γ ∔ Δ in₁ (α ∙ Γ) Δ new = new in₁ (α ∙ Γ) Δ (old v) = old (in₁ Γ Δ v) in₂ : (Γ Δ : Ctx) → Δ ↝ Γ ∔ Δ in₂ ∅ Δ v = v in₂ (α ∙ Γ) Δ v = old (in₂ Γ Δ v) i₁-commute : {Γ Δ Θ : Ctx}{α : T}(ρ : Γ ↝ Θ)(ϱ : Δ ↝ Θ)(v : ℐ α Γ) → copair ρ ϱ (expandʳ Δ v) ≡ ρ v i₁-commute ρ ϱ new = refl i₁-commute ρ ϱ (old v) = i₁-commute (ρ ∘ old) ϱ v i₂-commute : {Γ Δ Θ : Ctx}{α : T}(ρ : Γ ↝ Θ)(ϱ : Δ ↝ Θ)(v : ℐ α Δ) → copair ρ ϱ (expandˡ Γ v) ≡ ϱ v i₂-commute {∅} ρ ϱ v = refl i₂-commute {α ∙ Γ} ρ ϱ v = i₂-commute (ρ ∘ old) ϱ v unique : {Γ Δ Θ : Ctx}{α : T}(ρ : Γ ↝ Θ)(ϱ : Δ ↝ Θ)(π : Γ ∔ Δ ↝ Θ) → (π ∘ᵣ expandʳ Δ ≈ᵣ ρ) → (π ∘ᵣ expandˡ Γ ≈ᵣ ϱ) → (v : ℐ α (Γ ∔ Δ)) → copair ρ ϱ v ≡ π v unique {∅} ρ ϱ π p₁ p₂ v = sym p₂ unique {α ∙ Γ} ρ ϱ π p₁ p₂ new = sym p₁ unique {α ∙ Γ} ρ ϱ π p₁ p₂ (old v) = unique (ρ ∘ old) ϱ (π ∘ old) p₁ p₂ v module 𝔽:Co = Cocartesian 𝔽:Cocartesian module ∔ = BinaryCoproducts (Cocartesian.coproducts 𝔽:Cocartesian) -- | Special operations coming from the coproduct structure -- Concatenation is a bifunctor ∔:Bifunctor : Bifunctor 𝔽 𝔽 𝔽 ∔:Bifunctor = 𝔽:Co.-+- -- Left context concatenation functor Γ ∔ (-) : 𝔽 ⟶ 𝔽, for any context Γ _∔F- : Ctx → Functor 𝔽 𝔽 Γ ∔F- = Γ ∔.+- -- Right context concatenation functor (-) ∔ Δ : 𝔽 ⟶ 𝔽, for any context Δ -∔F_ : Ctx → Functor 𝔽 𝔽 -∔F Δ = ∔.-+ Δ -- Functorial mapping and injections _∣∔∣_ : {Γ₁ Γ₂ Δ₁ Δ₂ : Ctx}(ρ : Γ₁ ↝ Γ₂)(ϱ : Δ₁ ↝ Δ₂) → (Γ₁ ∔ Δ₁) ↝ (Γ₂ ∔ Δ₂) _∣∔∣_ = ∔._+₁_ _∣∔_ : {Γ₁ Γ₂ : Ctx}(ρ : Γ₁ ↝ Γ₂)(Δ : Ctx) → (Γ₁ ∔ Δ) ↝ (Γ₂ ∔ Δ) ρ ∣∔ Δ = ρ ∣∔∣ id′ᵣ Δ _∔∣_ : {Δ₁ Δ₂ : Ctx}(Γ : Ctx)(ϱ : Δ₁ ↝ Δ₂) → (Γ ∔ Δ₁) ↝ (Γ ∔ Δ₂) Γ ∔∣ ϱ = id′ᵣ Γ ∣∔∣ ϱ inl : (Γ {Δ} : Ctx) → Γ ↝ Γ ∔ Δ inl Γ {Δ} v = ∔.i₁ {Γ}{Δ} v inr : (Γ {Δ} : Ctx) → Δ ↝ Γ ∔ Δ inr Γ {Δ} v = ∔.i₂ {Γ}{Δ} v -- Left context concatenation represents weakening a variable in Γ by an -- arbitrary new context Θ to get a variable in context (Θ ∔ Γ). module Concatˡ Γ = Functor (Γ ∔F-) using () renaming ( F₁ to _∔ᵣ_ ; identity to ∔identity ; homomorphism to ∔homomorphism ; F-resp-≈ to ∔F-resp-≈) open Concatˡ public -- Context extension represents weakening by a single type, and it's a special -- case of context concatenation with a singleton context. module Ext τ = Functor (⌊ τ ⌋ ∔F-) using () renaming ( F₁ to _∙ᵣ_ ; identity to ∙identity ; homomorphism to ∙homomorphism ; F-resp-≈ to ∙F-resp-≈) open Ext public -- The two coincide (since add is a special case of copair) -- but not definitionally: ∙ᵣ is the parallel sum of id : ⌊ τ ⌋ ↝ ⌊ τ ⌋ and ρ : Γ ↝ Δ -- (i.e. the copairing of expandʳ ⌊ τ ⌋ Δ : ⌊ τ ⌋ ↝ τ ∙ Δ and old ∘ ρ : Γ ↝ τ ∙ Δ) -- while liftᵣ is the copairing of new : ⌊ τ ⌋ ↝ τ ∙ Δ and old ∘ ρ : Γ ↝ τ ∙ Δ ∙ᵣ-as-add : {α τ : T}{Γ Δ : Ctx} → (ρ : Γ ↝ Δ)(v : ℐ α (τ ∙ Γ)) → add new (old ∘ ρ) v ≡ (τ ∙ᵣ ρ) v ∙ᵣ-as-add ρ new = refl ∙ᵣ-as-add ρ (old v) = refl -- Making this a definitional equality simplifies things significantly -- Right context concatenation is possible but rarely needed. module Concatʳ Δ = Functor (-∔F Δ )
{ "alphanum_fraction": 0.5402144772, "avg_line_length": 33.4743589744, "ext": "agda", "hexsha": "ed18dc393846cc7ef78d6d9112460b5883dfa25d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "k4rtik/agda-soas", "max_forks_repo_path": "SOAS/ContextMaps/CategoryOfRenamings.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "k4rtik/agda-soas", "max_issues_repo_path": "SOAS/ContextMaps/CategoryOfRenamings.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "k4rtik/agda-soas", "max_stars_repo_path": "SOAS/ContextMaps/CategoryOfRenamings.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2317, "size": 5222 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Support.SetoidPi where open import Level open import Function as Fun using (_on_) open import Relation.Binary as B using () renaming (_=[_]⇒_ to _=[_]⇒₀_; _⇒_ to _⊆_) open import Relation.Binary.PropositionalEquality as PE using (_≡_) open import Relation.Binary.HeterogeneousEquality using (_≅_) renaming (refl to ≅-refl) open import Relation.Binary.Indexed.Heterogeneous as I using (_=[_]⇒_) open import Categories.Support.Equivalence open import Categories.Support.SetoidFunctions as SF using (_⟶_) renaming (_⟨$⟩_ to _⟨$⟩₀_; cong to cong₀) open Setoid using () renaming (Carrier to Carrier₀; _≈_ to _[_≈_]) _⟶[_,_] : ∀ {cf ℓf} (From : Setoid cf ℓf) (ct ℓt : Level) → Set (cf ⊔ ℓf ⊔ suc (ct ⊔ ℓt)) From ⟶[ ct , ℓt ] = From ⟶ set→setoid (Setoid ct ℓt) ------------------------------------------------------------------------ -- Indexed binary relations ------------------------------------------------------------------------ record IndexedSetoid {i iℓ} (I : Set i) (_∼_ : B.Rel I iℓ) c ℓ : Set (suc (i ⊔ iℓ ⊔ c ⊔ ℓ)) where infix 4 _≈_ field Carrier : I → Set c _≈_ : I.IRel Carrier ℓ .isEquivalence : I.IsIndexedEquivalence Carrier _≈_ -- NOTE one more field, see resp below -- no irrelevant opens ☹ -- .open I.IsEquivalence isEquivalence public private module E = I.IsIndexedEquivalence .refl : I.Reflexive Carrier _≈_ refl = E.refl isEquivalence .sym : I.Symmetric Carrier _≈_ sym = E.sym isEquivalence .trans : I.Transitive Carrier _≈_ trans = E.trans isEquivalence .reflexive : ∀ {i} → _≡_ ⊆ (_≈_ {i}) reflexive = E.reflexive isEquivalence -- conversion to regular setoids by evaluating at an index _at_ : I → Setoid c ℓ _at_ i = record { Carrier = Carrier i ; _≈_ = _≈_ ; isEquivalence = record { refl = E.refl isEquivalence ; sym = E.sym isEquivalence ; trans = E.trans isEquivalence } } -- XXX ideally i should redo the resp stuff and promotion and everything -- with the proper setoid of setoids under equivalence, but first i didn't -- make it yet and second OH MY GOD ─xplat Resp-Type = _∼_ =[ _at_ ]⇒₀ _≡_ {A = Setoid c ℓ} field .resp : Resp-Type resp-per : ∀ {c ℓ} {C₁ C₂ : Set c} {_≈₁_ : B.Rel C₁ ℓ} {_≈₂_ : B.Rel C₂ ℓ} {equiv₁ : B.IsEquivalence _≈₁_} {equiv₂ : B.IsEquivalence _≈₂_} → C₁ ≡ C₂ → _≈₁_ ≅ _≈₂_ → _≡_ {A = Setoid c ℓ} record {Carrier = C₁; _≈_ = _≈₁_; isEquivalence = equiv₁} record {Carrier = C₂; _≈_ = _≈₂_; isEquivalence = equiv₂} resp-per _≡_.refl ≅-refl = _≡_.refl .resp-per′ : ∀ {c ℓ} (S T : Setoid c ℓ) → (Carrier₀ S ≡ Carrier₀ T) → (Setoid._≈_ S ≅ Setoid._≈_ T) → S ≡ T resp-per′ S T = resp-per {equiv₁ = Setoid.isEquivalence S} {equiv₂ = Setoid.isEquivalence T} open IndexedSetoid using (_at_) weaken : ∀ {c ℓ} → Setoid c ℓ → ∀ {i iℓ} {I : Set i} {_∼_ : B.Rel I iℓ} → IndexedSetoid I _∼_ c ℓ weaken S {I = I} {_∼_} = record { Carrier = Fun.const S.Carrier ; _≈_ = S._≈_ ; isEquivalence = record { refl = S.refl; sym = S.sym; trans = S.trans } ; resp = Fun.const _≡_.refl } where module S = Setoid S {- -- this definition is unusable because agda spins in circles trying to infer -- ct and ℓt before it will extract any information from f's type, but f's -- type is the only thing it can infer them from... test is below ☹ _[$]_ : ∀ {cf ℓf ct ℓt} {From : Setoid cf ℓf} → (From ⟶[ ct , ℓt ]) → Carrier From → Set ct f [$] x = Carrier (f ⟨$⟩₀ x) .test : ∀ {cf ℓf ct ℓt} {From : Setoid cf ℓf} (To : From ⟶[ ct , ℓt ]) (x : Carrier From) → (_[$]_ {ct = ct}{ℓt = ℓt} To x) → Set ℓt test = {!!} -} -- i think this approach would work beautifully with regular setoids, but -- with irrelevant setoids the type of cong can't depend on localize -- ─ xplat -- .localize : ∀ {cf ℓf ct ℓt} {From : Setoid cf ℓf} (To : From ⟶[ ct , ℓt ]) {x y : Carrier₀ From} → From [ x ≈ y ] → B.REL (Carrier₀ (To ⟨$⟩₀ x)) (Carrier₀ (To ⟨$⟩₀ y)) ℓt -- localize To {x} x≈y with To ⟨$⟩₀ x | cong₀ To x≈y -- localize To x≈y | ._ | _≡_.refl = Setoid._≈_ (To ⟨$⟩₀ _) -- ... so it's on to yet another annoying heterogeneous equality type module SetoidHetero {cf ℓf} (From : Setoid cf ℓf) (ct ℓt : Level) (To : From ⟶[ ct , ℓt ]) where I = Carrier₀ From To$ = _⟨$⟩₀_ To To$C = Fun._∘_ Carrier₀ (_⟨$⟩₀_ To) localize′ : ∀ {S T : Setoid ct ℓt} → (S ≡ T) → B.REL (Carrier₀ S) (Carrier₀ T) ℓt -- localize′ {S} {T} S≡T localize′ {S} _≡_.refl = Setoid._≈_ S localize : ∀ {x y : I} → (To$ x ≡ To$ y) → B.REL (To$C x) (To$C y) ℓt localize {x} {y} To$x≡To$y with To$ y localize {x} _≡_.refl | ._ = Setoid._≈_ (To$ x) data _≈∗_ {S T : Setoid ct ℓt} (x : Carrier₀ S) : (y : Carrier₀ T) → Set (suc (ct ⊔ ℓt)) where locally : (S≡T : S ≡ T) {y : Carrier₀ T} (x≈y : localize′ S≡T x y) → _≈∗_ {S} {T} x y _≈⋆_ : {iˣ iʸ : I} → B.REL (To$C iˣ) (To$C iʸ) (suc (ct ⊔ ℓt)) _≈⋆_ {iˣ} {iʸ} = _≈∗_ {To$ iˣ} {To$ iʸ} asIndexed : ∀ {cf ℓf} ct ℓt {From : Setoid cf ℓf} → (From ⟶[ ct , ℓt ]) → IndexedSetoid (Carrier₀ From) (Setoid._≈_ From) ct (suc (ct ⊔ ℓt)) asIndexed ct ℓt {From} To = record { Carrier = To$C ; _≈_ = _≈⋆_ ; isEquivalence = record { refl = my-refl ; sym = my-sym ; trans = my-trans } ; resp = λ {i j} i∼j → resp-per′ (fake-at i) (fake-at j) (resp-helper i∼j) (resp-helper₂ i∼j) } where open SetoidHetero _ ct ℓt To .my-refl : I.Reflexive To$C _≈⋆_ my-refl {i} {x} = locally {To$ i} _≡_.refl ((Setoid.refl (To$ i))) .sym-helper : ∀ i j (To$i≡To$j : To$ i ≡ To$ j) (x : To$C i) (y : To$C j) (x≈y : localize′ To$i≡To$j x y) → localize′ (PE.sym To$i≡To$j) y x sym-helper i j To$i≡To$j x y with To$ j sym-helper i j _≡_.refl x y | ._ = Setoid.sym (To$ i) .my-sym : I.Symmetric To$C _≈⋆_ my-sym {i} {j} {x} {y} (locally To$i≡To$j x≈y) = locally (PE.sym To$i≡To$j) (sym-helper i j To$i≡To$j x y x≈y) .trans-helper : ∀ i j k (To$i≡To$j : To$ i ≡ To$ j) (To$j≡To$k : To$ j ≡ To$ k) (x : To$C i) (y : To$C j) (z : To$C k) (x≈y : localize′ To$i≡To$j x y) (y≈z : localize′ To$j≡To$k y z) → localize′ (PE.trans To$i≡To$j To$j≡To$k) x z trans-helper i j k To$i≡To$j To$j≡To$k x y z with To$ j | To$ k trans-helper i j k _≡_.refl _≡_.refl x y z | ._ | ._ = Setoid.trans (To$ i) .my-trans : I.Transitive To$C _≈⋆_ my-trans (locally To$i≡To$j x≈y) (locally To$j≡To$k y≈z) = locally (PE.trans To$i≡To$j To$j≡To$k) (trans-helper _ _ _ To$i≡To$j To$j≡To$k _ _ _ x≈y y≈z) .resp-helper : ∀ {i j} → From [ i ≈ j ] → To$C i ≡ To$C j resp-helper i∼j = PE.cong Carrier₀ (cong₀ To i∼j) .resp-helper₃ : (S T : Setoid ct ℓt) → S ≡ T → _≈∗_ {S} {S} ≅ _≈∗_ {T} {T} resp-helper₃ S .S _≡_.refl = ≅-refl .resp-helper₂ : ∀ {i j} → From [ i ≈ j ] → _≈⋆_ {i} {i} ≅ _≈⋆_ {j} {j} resp-helper₂ {i} {j} i∼j = resp-helper₃ (To$ i) (To$ j) (cong₀ To i∼j) fake-at : ∀ i → Setoid ct (suc (ct ⊔ ℓt)) fake-at i = record { Carrier = To$C i ; _≈_ = _≈⋆_ {i} {i} ; isEquivalence = record { refl = my-refl ; sym = my-sym ; trans = my-trans } } ------------------------------------------------------------------------ -- Functions which preserve equality record Π {f₁ f₂ t₁ t₂} (From : Setoid f₁ f₂) (To : IndexedSetoid (Carrier₀ From) (Setoid._≈_ From) t₁ t₂) : Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where open I using (_=[_]⇒_) infixl 5 _⟨$⟩_ field _⟨$⟩_ : (x : Carrier₀ From) → IndexedSetoid.Carrier To x .cong : Setoid._≈_ From =[ _⟨$⟩_ ]⇒ IndexedSetoid._≈_ To open Π public Π′ : ∀ {cf ℓf} (ct ℓt : Level) (From : Setoid cf ℓf) (To : From ⟶[ ct , ℓt ]) → Set (cf ⊔ ℓf ⊔ suc (ct ⊔ ℓt)) Π′ ct ℓt From To = Π From (asIndexed ct ℓt To) -- Pis that 'just happen' to be independent, instead of being necessarily so. infixr 0 _⟶Π_ _⟶Π_ : ∀ {f₁ f₂ t₁ t₂} → Setoid f₁ f₂ → Setoid t₁ t₂ → Set _ From ⟶Π To = Π From (weaken To) -- Identity and composition. id : ∀ {a₁ a₂} {A : Setoid a₁ a₂} → A ⟶Π A id = record { _⟨$⟩_ = Fun.id; cong = Fun.id } infixr 9 _∙′_ _∙′_ : ∀ {a₁ a₂} {A : Setoid a₁ a₂} {b₁ b₂} {B : Setoid b₁ b₂} {c₁ c₂} {C : Setoid c₁ c₂} → B ⟶Π C → A ⟶Π B → A ⟶Π C f ∙′ g = record { _⟨$⟩_ = Fun._∘_ (_⟨$⟩_ f) (_⟨$⟩_ g) ; cong = Fun._∘_ (cong f) (cong g) } infixr 9 _[_○_] -- XXX this shouldn't need B, but it can't be inferred from f's type _[_○_] : ∀ {a₁ a₂} {A : Setoid a₁ a₂} {b₁ b₂} (B : Setoid b₁ b₂) {c₁ c₂} (C : IndexedSetoid _ (Setoid._≈_ B) c₁ c₂) → (A ⟶Π B) → IndexedSetoid _ _ c₁ c₂ B [ C ○ f ] = record { Carrier = Fun._∘_ C.Carrier (_⟨$⟩_ f) ; _≈_ = C._≈_ ; isEquivalence = record { refl = C.refl; sym = C.sym; trans = C.trans } ; resp = Fun._∘_ C.resp (cong f) } where module C = IndexedSetoid C -- PROPER. well, halfway. infixr 9 _∙_ _∙_ : ∀ {a₁ a₂} {A : Setoid a₁ a₂} {b₁ b₂} {B : Setoid b₁ b₂} {c₁ c₂} {C : IndexedSetoid _ _ c₁ c₂} → (f : Π B C) → (g : A ⟶Π B) → Π A (B [ C ○ g ]) f ∙ g = record { _⟨$⟩_ = Fun._∘_ (_⟨$⟩_ f) (_⟨$⟩_ g) ; cong = Fun._∘_ (cong f) (cong g) } -- Constant equality-preserving function. const : ∀ {a₁ a₂} {A : Setoid a₁ a₂} {b₁ b₂} {B : Setoid b₁ b₂} → Carrier₀ B → A ⟶Π B const {B = B} b = record { _⟨$⟩_ = Fun.const b ; cong = Fun.const (Setoid.refl B) } ------------------------------------------------------------------------ -- Function setoids -- Dependent. setoid : ∀ {f₁ f₂ t₁ t₂} (From : Setoid f₁ f₂) → IndexedSetoid (Carrier₀ From) (Setoid._≈_ From) t₁ t₂ → Setoid _ _ setoid From To = record { Carrier = Π From To ; _≈_ = λ f g → ∀ {x y} → x ≈₁ y → f ⟨$⟩ x ≈₂ g ⟨$⟩ y ; isEquivalence = record { refl = λ {f} → cong f ; sym = λ f∼g x∼y → To.sym (f∼g (From.sym x∼y)) ; trans = λ f∼g g∼h x∼y → To.trans (f∼g From.refl) (g∼h x∼y) } } where open module From = Setoid From using () renaming (_≈_ to _≈₁_) open module To = IndexedSetoid To using () renaming (_≈_ to _≈₂_)
{ "alphanum_fraction": 0.5519223147, "avg_line_length": 37.1029411765, "ext": "agda", "hexsha": "506065a875fa7725e9a1b849cedc654e443e0653", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Support/SetoidPi.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Support/SetoidPi.agda", "max_line_length": 301, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Support/SetoidPi.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 4258, "size": 10092 }
{-# OPTIONS --without-K --safe #-} -- This module provides the basic expression type for polynomials. module Polynomial.Expr where open import Data.Nat using (ℕ) open import Data.Fin using (Fin) infixl 6 _⊕_ infixl 7 _⊗_ infixr 8 _⊛_ data Expr {ℓ} (A : Set ℓ) (n : ℕ) : Set ℓ where Κ : A → Expr A n Ι : Fin n → Expr A n _⊕_ : Expr A n → Expr A n → Expr A n _⊗_ : Expr A n → Expr A n → Expr A n _⊛_ : Expr A n → ℕ → Expr A n ⊝_ : Expr A n → Expr A n open import Polynomial.Parameters module Eval {c r₁ r₂ r₃} (homo : Homomorphism c r₁ r₂ r₃) where open Homomorphism homo open import Polynomial.Exponentiation rawRing open import Data.Vec as Vec using (Vec) ⟦_⟧ : ∀ {n} → Expr Raw.Carrier n → Vec Carrier n → Carrier ⟦ Κ x ⟧ ρ = ⟦ x ⟧ᵣ ⟦ Ι x ⟧ ρ = Vec.lookup ρ x ⟦ x ⊕ y ⟧ ρ = ⟦ x ⟧ ρ + ⟦ y ⟧ ρ ⟦ x ⊗ y ⟧ ρ = ⟦ x ⟧ ρ * ⟦ y ⟧ ρ ⟦ ⊝ x ⟧ ρ = - ⟦ x ⟧ ρ ⟦ x ⊛ i ⟧ ρ = ⟦ x ⟧ ρ ^ i
{ "alphanum_fraction": 0.5756256801, "avg_line_length": 25.5277777778, "ext": "agda", "hexsha": "d453b9def9169483b03a0bb25d043a0dadb2981a", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Polynomial/Expr.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Polynomial/Expr.agda", "max_line_length": 66, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Polynomial/Expr.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 414, "size": 919 }
-- 2012-09-25 Andreas, reported by Nicolas Pouillard {-# OPTIONS --sized-types #-} module Issue700 where import Common.Level open import Common.Size postulate Size< : Size → Set {-# BUILTIN SIZELT Size< #-} postulate A : Set data T (i : Size) : Set where c : (j : Size< i) → T j → T _ bug : ∀ i → T i → A bug i (c j x) = bug j x {- WAS: de Bruijn index out of scope Issue700.bug is projection like in argument 1 for type Issue700.T Translated clause: delta = (j : Size< @0) (x : T j) perm = x0,x1 -> x0,x1 ps = [r(ConP Issue700.T.c Nothing [r(VarP "j"),r(VarP "x")])] body = Bind (Abs "h1" Bind (Abs "h2" Body (Def Issue700.bug [r(Var 1 []),r(Var 0 [])]))) body = [h1 h2] bug h1 h2 -}
{ "alphanum_fraction": 0.6092436975, "avg_line_length": 23.0322580645, "ext": "agda", "hexsha": "6d849c7bca1e3761fd7c1a564f5aeb3ec11b13e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/Issue700.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/Issue700.agda", "max_line_length": 91, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/Issue700.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 266, "size": 714 }
-- {-# OPTIONS -v term:30 #-} {-# OPTIONS --copatterns #-} module ColistMutual where mutual data CoList (A : Set) : Set where [] : CoList A _∷_ : (x : A)(xs : ∞CoList A) → CoList A record ∞CoList (A : Set) : Set where coinductive field out : CoList A open ∞CoList mutual repeat : {A : Set}(a : A) → CoList A repeat a = a ∷ ∞repeat a ∞repeat : {A : Set}(a : A) → ∞CoList A out (∞repeat a) = repeat a -- example by Thorsten and Nisse, PAR 2010 data Tree : Set where node : CoList Tree → Tree mutual bad : Tree bad = node (node [] ∷ bads) bads : ∞CoList Tree out bads = bad ∷ bads -- should not termination check CRASH -- TODO fix termination checker {- data Bool : Set where true false : Bool mutual shape : Tree → Bool shape (node []) = false shape (node (_ ∷ l)) = shapes (out l) shapes : CoList Tree → Bool shapes [] = false shapes (t ∷ _) = shape t -- shape/shapes may not termination check -}
{ "alphanum_fraction": 0.6016511868, "avg_line_length": 17, "ext": "agda", "hexsha": "61ec7a2d943e99d804b56f52996815934af54e7d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/ColistMutual.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Fail/ColistMutual.agda", "max_line_length": 44, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/ColistMutual.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 339, "size": 969 }
-- Saturated sets. module SAT3 where open import Library open import Terms open import Substitution open import Reduction open import SN open import SN.AntiRename -- Kripke predicates on well-typed terms. TmSet : (a : Ty) → Set₁ TmSet a = {Γ : Cxt} (t : Tm Γ a) → Set _⊆_ : ∀{a} (𝑨 𝑨′ : TmSet a) → Set 𝑨 ⊆ 𝑨′ = ∀{Γ}{t : Tm Γ _} → 𝑨 t → 𝑨′ t -- Closure by strong head expansion Closed : ∀ {a} (𝑨 : TmSet a) → Set Closed 𝑨 = ∀{Γ}{t t' : Tm Γ _} → t ⟨ _ ⟩⇒ t' → 𝑨 t' → 𝑨 t data Cl {a} (𝑨 : TmSet a) {Γ} (t : Tm Γ a) : Set where emb : 𝑨 t → Cl 𝑨 t exp : ∀{t'} → t ⟨ _ ⟩⇒ t' → Cl 𝑨 t' → Cl 𝑨 t -- Function space. _[→]_ : ∀{a b} → TmSet a → TmSet b → TmSet (a →̂ b) (𝓐 [→] 𝓑) {Γ} t = ∀{Δ} (ρ : Δ ≤ Γ) → {u : Tm Δ _} → 𝓐 u → 𝓑 (app (rename ρ t) u) -- Saturated term sets. record IsSAT {a} (𝑨 : TmSet a) : Set where -- constructor isSat field satSNe : SNe ⊆ 𝑨 satSN : 𝑨 ⊆ SN satExp : Closed 𝑨 satRename : ∀ {Γ Δ} → (ρ : Ren Γ Δ) → ∀ {t} → 𝑨 t → 𝑨 (subst ρ t) --open IsSAT record SAT (a : Ty) : Set₁ where -- constructor sat field satSet : TmSet a satProp : IsSAT satSet open IsSAT satProp public open SAT public -- Elementhood for saturated sets. -- We use a record to instead of just application to help Agda's unifier. record _∈_ {a Γ} (t : Tm Γ a) (𝓐 : SAT a) : Set where constructor ↿_ field ⇃_ : satSet 𝓐 t open _∈_ public -- Variables inhabit saturated sets. ⟦var⟧ : ∀{a} (𝓐 : SAT a) {Γ} (x : Var Γ a) → var x ∈ 𝓐 ⟦var⟧ 𝓐 x = ↿ (satSNe 𝓐 (var x)) -- Smallest semantic type. ⟦⊥⟧ : SAT base ⟦⊥⟧ = record { satSet = SN ; satProp = record { satSNe = ne ; satSN = id ; satExp = exp ; satRename = renameSN } } -- Semantic function type. _⟦→⟧_ : ∀ {a b} (𝓐 : SAT a) (𝓑 : SAT b) → SAT (a →̂ b) 𝓐 ⟦→⟧ 𝓑 = record { satSet = 𝑪 ; satProp = record { satSNe = CSNe ; satSN = CSN ; satExp = CExp ; satRename = λ ρ {t} 𝒕 ρ₁ {u} 𝒖 → ≡.subst (λ t₁ → 𝑩 (app t₁ u)) (subst-∙ ρ₁ ρ t) (𝒕 (λ x₂ → ρ₁ (ρ x₂)) 𝒖) } } where module 𝓐 = SAT 𝓐 module 𝓑 = SAT 𝓑 𝑨 = 𝓐.satSet 𝑩 = 𝓑.satSet 𝑪 : TmSet (_ →̂ _) 𝑪 t = (𝑨 [→] 𝑩) t CSNe : SNe ⊆ 𝑪 CSNe 𝒏 ρ 𝒖 = 𝓑.satSNe (sneApp (renameSNe ρ 𝒏) (𝓐.satSN 𝒖)) CSN : 𝑪 ⊆ SN CSN 𝒕 = unRenameSN (prop→Ind suc ≡.refl) (absVarSN (𝓑.satSN (𝒕 _ (𝓐.satSNe (var v₀))))) CExp : ∀{Γ}{t t' : Tm Γ _} → t ⟨ _ ⟩⇒ t' → 𝑪 t' → 𝑪 t CExp t⇒ 𝒕 ρ 𝒖 = 𝓑.satExp ((cong (appl _) (appl _) (subst⇒ (renSN ρ) t⇒))) (𝒕 ρ 𝒖) -- Lemma: If 𝓐, 𝓑 ∈ SAT and t[u] ∈ 𝓑 for all a ∈ 𝓐, then λt ∈ 𝓐 ⟦→⟧ 𝓑 ⟦abs⟧ : ∀{a b}{𝓐 : SAT a}{𝓑 : SAT b}{Γ}{t : Tm (a ∷ Γ) b} → (∀ {Δ} (ρ : Δ ≤ Γ) {u : Tm Δ a} → u ∈ 𝓐 → (subst0 u (subst (lifts ρ) t)) ∈ 𝓑 ) → abs t ∈ (𝓐 ⟦→⟧ 𝓑) (⇃ ⟦abs⟧ {𝓐 = 𝓐}{𝓑 = 𝓑} 𝒕) ρ 𝒖 = SAT.satExp 𝓑 (β (SAT.satSN 𝓐 𝒖)) (⇃ 𝒕 ρ (↿ 𝒖)) -- Lemma: If 𝓐, 𝓑 ∈ SAT and t ∈ 𝓐 ⟦→⟧ 𝓑 and u ∈ 𝓐, then app t u ∈ 𝓑 ⟦app⟧ : ∀ {a b} {𝓐 : SAT a} {𝓑 : SAT b} {Γ} {t : Tm Γ (a →̂ b)} {u : Tm Γ a} → t ∈ (𝓐 ⟦→⟧ 𝓑) → u ∈ 𝓐 → app t u ∈ 𝓑 ⟦app⟧ {𝓑 = 𝓑} {u = u} (↿ 𝒕) (↿ 𝒖) = ≡.subst (λ t → app t u ∈ 𝓑) renId (↿ 𝒕 _ 𝒖)
{ "alphanum_fraction": 0.4975969241, "avg_line_length": 25.5819672131, "ext": "agda", "hexsha": "c35f407196079386b8e189cc44a420befe86cca7", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z", "max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z", "max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "ryanakca/strong-normalization", "max_forks_repo_path": "agda-aplas14/SAT3.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z", "max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "ryanakca/strong-normalization", "max_issues_repo_path": "agda-aplas14/SAT3.agda", "max_line_length": 110, "max_stars_count": 32, "max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "ryanakca/strong-normalization", "max_stars_repo_path": "agda-aplas14/SAT3.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z", "num_tokens": 1662, "size": 3121 }